]> git.codecow.com Git - nano-pow.git/commitdiff
Move exported typings to main index export and use bare specifier to reference them...
authorChris Duncan <chris@codecow.com>
Tue, 7 Apr 2026 04:51:37 +0000 (21:51 -0700)
committerChris Duncan <chris@codecow.com>
Tue, 7 Apr 2026 04:51:37 +0000 (21:51 -0700)
12 files changed:
src/bin/cli.ts
src/bin/server.ts
src/index.d.ts [deleted file]
src/index.ts
src/lib/generate/cpu/index.ts
src/lib/generate/wasm/index.ts
src/lib/generate/webgl/index.ts
src/lib/generate/webgpu/index.ts
src/lib/index.ts
src/lib/validate/index.ts
src/utils/cache.ts
tsconfig.json

index a1beaf03099265a9ea3f07e122caa5ae8b43a367..138b7cabbac7ff4a8d6c37cc77050e30175a4f6e 100755 (executable)
@@ -2,7 +2,7 @@
 //! SPDX-FileCopyrightText: 2025 Chris Duncan <chris@codecow.com>
 //! SPDX-License-Identifier: GPL-3.0-or-later
 
-import { WorkErrorResponse, WorkGenerateResponse, WorkValidateResponse } from '#types'
+import { WorkErrorResponse, WorkGenerateResponse, WorkValidateResponse } from 'nano-pow'
 import { isHex32, isHex8, Logger, stats } from 'nano-pow/utils'
 import { Serializable, spawn } from 'node:child_process'
 import { getRandomValues } from 'node:crypto'
index 2c54c0700ebf890b62876633a8223f63c9777825..bf381bd50910e88c8f8880e272fdd68b9d81beb1 100755 (executable)
@@ -2,7 +2,7 @@
 //! SPDX-FileCopyrightText: 2025 Chris Duncan <chris@codecow.com>
 //! SPDX-License-Identifier: GPL-3.0-or-later
 
-import { WorkErrorResponse, WorkGenerateResponse, WorkValidateResponse } from '#types'
+import { WorkErrorResponse, WorkGenerateResponse, WorkValidateResponse } from 'nano-pow'
 import { isHex32, isHex8, Logger } from 'nano-pow/utils'
 import { Serializable } from 'node:child_process'
 import { hash } from 'node:crypto'
diff --git a/src/index.d.ts b/src/index.d.ts
deleted file mode 100644 (file)
index b845df7..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-//! SPDX-FileCopyrightText: 2025 Chris Duncan <chris@codecow.com>
-//! SPDX-License-Identifier: GPL-3.0-or-later
-
-/**
-* Provide consumer with error information in response to request.
-*
-* @param {string} error - Informative message about error.
-*/
-export type WorkErrorResponse = {
-       error: string
-}
-
-/**
-* Structure of response to `work_generate` call.
-*
-* @param {string} hash - Hash from generate request
-* @param {string} work - Valid proof-of-work nonce generated for input hash
-* @param {string} difficulty - BLAKE2b output which met or exceeded specified minimum threshold
-*/
-export type WorkGenerateResponse = {
-       hash: string
-       work: string
-       difficulty: string
-}
-
-/**
-* Structure of response to `work_validate` call.
-*
-* @param {string} hash - Hash from validate request
-* @param {string} work - Nonce from validate request
-* @param {string} difficulty - BLAKE2b output of `work` + `hash` which is compared to specified minimum threshold to determine validity
-* @param {string} valid_all - 1 for true if nonce is valid for send blocks, else 0 for false
-* @param {string} valid_receive - 1 for true if nonce is valid for receive blocks, else 0 for false
-* @param {string} [valid] - Excluded if optional difficulty was not included in the request. 1 for true if nonce is valid for requested difficulty, else 0 for false
-*/
-export type WorkValidateResponse = {
-       hash: string
-       work: string
-       difficulty: string
-       valid_all: '0' | '1'
-       valid_receive: '0' | '1'
-       valid?: '0' | '1'
-}
index b745051e01dfd578efa7ee71bac17cc2f3669970..1ea806cdce02b6b0e73cae7f1be05d1803ccd06b 100644 (file)
@@ -2,9 +2,55 @@
 //! SPDX-License-Identifier: GPL-3.0-or-later
 
 import { NanoPowOptions } from '#lib/config'
-import { WorkErrorResponse, WorkGenerateResponse, WorkValidateResponse } from '#types'
 import { generate, validate } from './lib'
 
+declare global {
+       interface Window {
+               NanoPow: typeof NanoPow
+       }
+}
+
+/**
+ * Provide consumer with error information in response to request.
+ *
+ * @param {string} error - Informative message about error.
+ */
+export type WorkErrorResponse = {
+       error: string
+}
+
+/**
+ * Structure of response to `work_generate` call.
+ *
+ * @param {string} hash - Hash from generate request
+ * @param {string} work - Valid proof-of-work nonce generated for input hash
+ * @param {string} difficulty - BLAKE2b output which met or exceeded specified minimum threshold
+ */
+export type WorkGenerateResponse = {
+       hash: string
+       work: string
+       difficulty: string
+}
+
+/**
+ * Structure of response to `work_validate` call.
+ *
+ * @param {string} hash - Hash from validate request
+ * @param {string} work - Nonce from validate request
+ * @param {string} difficulty - BLAKE2b output of `work` + `hash` which is compared to specified minimum threshold to determine validity
+ * @param {string} valid_all - 1 for true if nonce is valid for send blocks, else 0 for false
+ * @param {string} valid_receive - 1 for true if nonce is valid for receive blocks, else 0 for false
+ * @param {string} [valid] - Excluded if optional difficulty was not included in the request. 1 for true if nonce is valid for requested difficulty, else 0 for false
+ */
+export type WorkValidateResponse = {
+       hash: string
+       work: string
+       difficulty: string
+       valid_all: '0' | '1'
+       valid_receive: '0' | '1'
+       valid?: '0' | '1'
+}
+
 /**
  * Finds a nonce that satisfies the Nano proof-of-work requirements.
  *
index ae3a1c301a5dfe4f2b5126104eadd9c733e9ae8e..211e4eb466527ce693236c22e1dcc879eb23ee44 100644 (file)
@@ -1,8 +1,8 @@
 //! SPDX-FileCopyrightText: 2025 Chris Duncan <chris@codecow.com>
 //! SPDX-License-Identifier: GPL-3.0-or-later
 
+import { WorkGenerateResponse } from 'nano-pow'
 import { NanoPowValidate } from '#lib/validate'
-import { WorkGenerateResponse } from '#types'
 import { bigintRandom, Logger } from '#utils'
 
 const logger = new Logger()
index b96204fe712c8218d22d21e36e5f903ef24f5d43..8ec7344b596d3693a681c367caf0f177d861a322 100644 (file)
@@ -1,8 +1,8 @@
 //! SPDX-FileCopyrightText: 2025 Chris Duncan <chris@codecow.com>
 //! SPDX-License-Identifier: GPL-3.0-or-later
 
+import { WorkGenerateResponse } from 'nano-pow'
 import { NanoPowValidate } from '#lib/validate'
-import { WorkGenerateResponse } from '#types'
 import { bigintRandom, bigintToHex, Logger } from '#utils'
 import { NanoPowWasmWorker } from './worker.js'
 
index 2340749dba69eb57865fbc860052bc15e472b29d..36781bad9b61b5adf96e223b6c1942c22b0f360a 100644 (file)
@@ -2,9 +2,9 @@
 //! SPDX-FileContributor: Ben Green <ben@latenightsketches.com>
 //! SPDX-License-Identifier: GPL-3.0-or-later AND MIT
 
-import { downsampleSource, drawSource, quadSource } from './shaders'
-import { WorkGenerateResponse } from '#types'
+import { WorkGenerateResponse } from 'nano-pow'
 import { bigintAsUintNArray, bigintRandom, bigintToHex, Logger } from '#utils'
+import { downsampleSource, drawSource, quadSource } from './shaders'
 
 /**
 * Used to create WebGL framebuffer objects.
index 9c021cc0d7919408aac8c0a868d1b4abc126c0c3..fbd2a79388c6c61e360abf2c2329bbd7fadf60dd 100644 (file)
@@ -1,9 +1,9 @@
 //! SPDX-FileCopyrightText: 2025 Chris Duncan <chris@codecow.com>
 //! SPDX-License-Identifier: GPL-3.0-or-later
 
-import { default as NanoPowGpuComputeShader } from './shaders/compute.wgsl'
-import { WorkGenerateResponse } from '#types'
+import { WorkGenerateResponse } from 'nano-pow'
 import { bigintAsUintNArray, bigintRandom, bigintToHex, Logger, Queue } from '#utils'
+import { default as NanoPowGpuComputeShader } from './shaders/compute.wgsl'
 
 type NanoPowDeviceStatus = 'Idle' | 'Starting' | 'Unsupported' | 'Ready' | 'Restoring' | 'Crashed'
 
index 2ab700cb3c38a52cd104acdc1ce432687a7e7d44..13fffa1737f5a3cfc39dedf800d9a1ab007c416d 100644 (file)
@@ -1,10 +1,10 @@
 //! SPDX-FileCopyrightText: 2025 Chris Duncan <chris@codecow.com>
 //! SPDX-License-Identifier: GPL-3.0-or-later
 
+import { WorkErrorResponse, WorkGenerateResponse, WorkValidateResponse } from 'nano-pow'
 import { NanoPowConfig } from '#lib/config'
 import { NanoPowCpu, NanoPowWasm, NanoPowWebgl, NanoPowWebgpu } from '#lib/generate'
 import { NanoPowValidate } from '#lib/validate'
-import { WorkErrorResponse, WorkGenerateResponse, WorkValidateResponse } from '#types'
 import { bigintFrom, Cache, Logger, Queue } from '#utils'
 
 const logger = new Logger()
index f1970978d9c70aac1a13c1f821c1d78be8fa0828..285b1930eca738d748812aa1b51073c5e4ea7dc3 100644 (file)
@@ -1,7 +1,7 @@
 //! SPDX-FileCopyrightText: 2025 Chris Duncan <chris@codecow.com>
 //! SPDX-License-Identifier: GPL-3.0-or-later
 
-import { WorkValidateResponse } from '#types'
+import { WorkValidateResponse } from 'nano-pow'
 import { bigintAsUintNArray, bigintToHex, Logger, RECEIVE, SEND } from '#utils'
 
 const logger = new Logger()
index 5d446f82a23ec4a52c6a662ad483e9a202151549..b56e7b7f9cdcdc32a257c42d74572b279b5fe137 100644 (file)
@@ -1,7 +1,7 @@
 //! SPDX-FileCopyrightText: 2025 Chris Duncan <chris@codecow.com>
 //! SPDX-License-Identifier: GPL-3.0-or-later
 
-import { WorkGenerateResponse } from "#types"
+import { WorkGenerateResponse } from "nano-pow"
 import { bigintFrom } from "#utils"
 
 export class Cache {
index a7f60a7c523456e07b17a185814595b38d586100..caeff0e7f3cc30675151ee0ab96aef4eef9b0237 100644 (file)
@@ -18,9 +18,6 @@
                        "#lib/*": [
                                "./src/lib/*"
                        ],
-                       "#types": [
-                               "./src/index.d.ts"
-                       ],
                        "#utils": [
                                "./src/utils/index.ts"
                        ]