nano-pow 4.0.5 → 4.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.min.js +13 -5
- package/package.json +2 -2
package/dist/main.min.js
CHANGED
|
@@ -43,6 +43,7 @@ layout(location=0)in vec4 position;void main(){gl_Position=position;}`;
|
|
|
43
43
|
var NanoPowGl = class _NanoPowGl {
|
|
44
44
|
static #SEND = 0xfffffff800000000n;
|
|
45
45
|
static #RECEIVE = 0xfffffe0000000000n;
|
|
46
|
+
static #isInitialized = false;
|
|
46
47
|
static #busy = false;
|
|
47
48
|
static #debug = false;
|
|
48
49
|
static #raf = 0;
|
|
@@ -187,12 +188,13 @@ var NanoPowGl = class _NanoPowGl {
|
|
|
187
188
|
this.#gl.bindBuffer(this.#gl.UNIFORM_BUFFER, null);
|
|
188
189
|
this.#query = this.#gl.createQuery();
|
|
189
190
|
this.#pixels = new Uint32Array(this.size * 4);
|
|
190
|
-
console.log(`NanoPow WebGL initialized at ${this.#gl.drawingBufferWidth}x${this.#gl.drawingBufferHeight}. Maximum nonces checked per frame: ${this.size}`);
|
|
191
191
|
} catch (err) {
|
|
192
192
|
throw new Error("WebGL initialization failed.", { cause: err });
|
|
193
193
|
} finally {
|
|
194
194
|
this.#busy = false;
|
|
195
195
|
}
|
|
196
|
+
this.#isInitialized = true;
|
|
197
|
+
console.log(`NanoPow WebGL initialized at ${this.#gl.drawingBufferWidth}x${this.#gl.drawingBufferHeight}. Maximum nonces checked per frame: ${this.size}`);
|
|
196
198
|
}
|
|
197
199
|
/**
|
|
198
200
|
* On WebGL context loss, attempts to clear all program variables and then
|
|
@@ -358,6 +360,7 @@ var NanoPowGl = class _NanoPowGl {
|
|
|
358
360
|
}, 100);
|
|
359
361
|
});
|
|
360
362
|
}
|
|
363
|
+
if (this.#isInitialized === false) this.init();
|
|
361
364
|
this.#busy = true;
|
|
362
365
|
if (typeof options?.threshold === "string") {
|
|
363
366
|
try {
|
|
@@ -442,6 +445,7 @@ var NanoPowGl = class _NanoPowGl {
|
|
|
442
445
|
}, 100);
|
|
443
446
|
});
|
|
444
447
|
}
|
|
448
|
+
if (this.#isInitialized === false) this.init();
|
|
445
449
|
this.#busy = true;
|
|
446
450
|
if (typeof options?.threshold === "string") {
|
|
447
451
|
try {
|
|
@@ -514,6 +518,7 @@ var NanoPowGpu = class _NanoPowGpu {
|
|
|
514
518
|
static #SEND = 0xfffffff800000000n;
|
|
515
519
|
static #RECEIVE = 0xfffffe0000000000n;
|
|
516
520
|
// Initialize WebGPU
|
|
521
|
+
static #isInitialized = false;
|
|
517
522
|
static #busy = false;
|
|
518
523
|
static #debug = false;
|
|
519
524
|
static #device = null;
|
|
@@ -543,6 +548,7 @@ var NanoPowGpu = class _NanoPowGpu {
|
|
|
543
548
|
} finally {
|
|
544
549
|
this.#busy = false;
|
|
545
550
|
}
|
|
551
|
+
this.#isInitialized = true;
|
|
546
552
|
}
|
|
547
553
|
static setup() {
|
|
548
554
|
if (this.#device == null) throw new Error(`WebGPU device failed to load.`);
|
|
@@ -704,6 +710,7 @@ var NanoPowGpu = class _NanoPowGpu {
|
|
|
704
710
|
}, 100);
|
|
705
711
|
});
|
|
706
712
|
}
|
|
713
|
+
if (this.#isInitialized === false) this.init();
|
|
707
714
|
this.#busy = true;
|
|
708
715
|
if (typeof options?.threshold === "string") {
|
|
709
716
|
try {
|
|
@@ -773,6 +780,7 @@ var NanoPowGpu = class _NanoPowGpu {
|
|
|
773
780
|
}, 100);
|
|
774
781
|
});
|
|
775
782
|
}
|
|
783
|
+
if (this.#isInitialized === false) this.init();
|
|
776
784
|
this.#busy = true;
|
|
777
785
|
if (typeof options?.threshold === "string") {
|
|
778
786
|
try {
|
|
@@ -824,15 +832,15 @@ var NanoPowGpu = class _NanoPowGpu {
|
|
|
824
832
|
var isGlSupported;
|
|
825
833
|
var isGpuSupported = false;
|
|
826
834
|
try {
|
|
827
|
-
await
|
|
828
|
-
isGpuSupported =
|
|
835
|
+
const adapter = await navigator?.gpu?.requestAdapter?.();
|
|
836
|
+
isGpuSupported = adapter instanceof GPUAdapter;
|
|
829
837
|
} catch (err) {
|
|
830
838
|
console.warn("WebGPU is not supported in this environment.\n", err);
|
|
831
839
|
isGpuSupported = false;
|
|
832
840
|
}
|
|
833
841
|
try {
|
|
834
|
-
|
|
835
|
-
isGlSupported =
|
|
842
|
+
const gl = new OffscreenCanvas(0, 0)?.getContext?.("webgl2");
|
|
843
|
+
isGlSupported = gl instanceof WebGL2RenderingContext;
|
|
836
844
|
} catch (err) {
|
|
837
845
|
console.warn("WebGL is not supported in this environment.\n", err);
|
|
838
846
|
isGlSupported = false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nano-pow",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.6",
|
|
4
4
|
"description": "Proof-of-work generation and validation with WebGPU/WebGL for Nano cryptocurrency.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"nemo",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"build": "rm -rf {dist,types} && tsc && node esbuild.mjs && cp -p src/bin/nano-pow.sh dist/bin",
|
|
49
49
|
"prepare": "npm run build",
|
|
50
50
|
"start": "./dist/bin/nano-pow.sh --server",
|
|
51
|
-
"test": "./test/script.sh"
|
|
51
|
+
"test": "npm run build && ./test/script.sh"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/node": "^22.13.11",
|