@btc-vision/bitcoin 7.0.0-alpha.4 → 7.0.0-alpha.5

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.
Files changed (40) hide show
  1. package/browser/chunks/index.browser-CUaPaKyS.js +10742 -0
  2. package/browser/index.js +1884 -12608
  3. package/browser/workers/index.browser.d.ts +16 -0
  4. package/browser/workers/index.browser.d.ts.map +1 -0
  5. package/browser/workers/index.d.ts +3 -16
  6. package/browser/workers/index.d.ts.map +1 -1
  7. package/browser/workers/index.js +21 -0
  8. package/browser/workers/index.node.d.ts +12 -19
  9. package/browser/workers/index.node.d.ts.map +1 -1
  10. package/browser/workers/index.shared.d.ts +15 -0
  11. package/browser/workers/index.shared.d.ts.map +1 -0
  12. package/browser/workers/types.d.ts +5 -0
  13. package/browser/workers/types.d.ts.map +1 -1
  14. package/build/tsconfig.build.tsbuildinfo +1 -1
  15. package/build/workers/index.browser.d.ts +24 -0
  16. package/build/workers/index.browser.d.ts.map +1 -0
  17. package/build/workers/index.browser.js +30 -0
  18. package/build/workers/index.browser.js.map +1 -0
  19. package/build/workers/index.d.ts +5 -17
  20. package/build/workers/index.d.ts.map +1 -1
  21. package/build/workers/index.js +3 -11
  22. package/build/workers/index.js.map +1 -1
  23. package/build/workers/index.node.d.ts +17 -3
  24. package/build/workers/index.node.d.ts.map +1 -1
  25. package/build/workers/index.node.js +23 -4
  26. package/build/workers/index.node.js.map +1 -1
  27. package/build/workers/index.shared.d.ts +15 -0
  28. package/build/workers/index.shared.d.ts.map +1 -0
  29. package/build/workers/index.shared.js +20 -0
  30. package/build/workers/index.shared.js.map +1 -0
  31. package/build/workers/types.d.ts +5 -0
  32. package/build/workers/types.d.ts.map +1 -1
  33. package/package.json +9 -1
  34. package/src/workers/index.browser.ts +34 -0
  35. package/src/workers/index.node.ts +28 -5
  36. package/src/workers/index.shared.ts +58 -0
  37. package/src/workers/index.ts +6 -64
  38. package/src/workers/types.ts +5 -0
  39. package/vite.config.browser.ts +31 -6
  40. package/browser/chunks/WorkerSigningPool.sequential-DHha7j0b.js +0 -113
@@ -1,8 +1,32 @@
1
1
  import { resolve } from 'path';
2
- import { defineConfig } from 'vite';
2
+ import { defineConfig, type Plugin } from 'vite';
3
3
  import { nodePolyfills } from 'vite-plugin-node-polyfills';
4
4
  import dts from 'vite-plugin-dts';
5
5
 
6
+ const BROWSER_WORKERS_INDEX = resolve(__dirname, 'src/workers/index.browser.ts');
7
+
8
+ // Redirect all imports of workers/index to the browser-specific entry
9
+ // which never references Node.js modules (worker_threads, os, etc.)
10
+ function browserWorkersRedirect(): Plugin {
11
+ const workersIndex = resolve(__dirname, 'src/workers/index.ts');
12
+ return {
13
+ name: 'browser-workers-redirect',
14
+ enforce: 'pre',
15
+ resolveId(source, importer) {
16
+ if (!importer) return null;
17
+ // Match resolved path to workers/index.ts (from relative ./workers/index.js imports)
18
+ if (source === './workers/index.js' || source === './workers/index.ts') {
19
+ const resolvedDir = resolve(importer, '..');
20
+ const resolved = resolve(resolvedDir, 'workers/index.ts');
21
+ if (resolved === workersIndex) {
22
+ return BROWSER_WORKERS_INDEX;
23
+ }
24
+ }
25
+ return null;
26
+ },
27
+ };
28
+ }
29
+
6
30
  export default defineConfig({
7
31
  build: {
8
32
  outDir: 'browser',
@@ -10,16 +34,16 @@ export default defineConfig({
10
34
  target: 'esnext',
11
35
  minify: 'esbuild',
12
36
  lib: {
13
- entry: resolve(__dirname, 'src/index.ts'),
37
+ entry: {
38
+ index: resolve(__dirname, 'src/index.ts'),
39
+ 'workers/index': BROWSER_WORKERS_INDEX,
40
+ },
14
41
  formats: ['es'],
15
- fileName: () => 'index.js',
42
+ fileName: (_format, entryName) => `${entryName}.js`,
16
43
  },
17
44
  rollupOptions: {
18
- external: [/WorkerSigningPool\.node/],
19
45
  output: {
20
46
  chunkFileNames: 'chunks/[name]-[hash].js',
21
- // Tree-shaking enabled - no manual chunks needed
22
- // This allows bundlers to only include what's actually used
23
47
  },
24
48
  },
25
49
  },
@@ -36,6 +60,7 @@ export default defineConfig({
36
60
  global: 'globalThis',
37
61
  },
38
62
  plugins: [
63
+ browserWorkersRedirect(),
39
64
  nodePolyfills({
40
65
  globals: {
41
66
  Buffer: true,
@@ -1,113 +0,0 @@
1
- import { EccContext as f, SignatureType as g } from "../index.js";
2
- class r {
3
- static #e = null;
4
- constructor(t = {}) {
5
- }
6
- /**
7
- * Number of workers — always 0 for sequential pool.
8
- */
9
- get workerCount() {
10
- return 0;
11
- }
12
- /**
13
- * Idle workers — always 0.
14
- */
15
- get idleWorkerCount() {
16
- return 0;
17
- }
18
- /**
19
- * Busy workers — always 0.
20
- */
21
- get busyWorkerCount() {
22
- return 0;
23
- }
24
- /**
25
- * Whether workers are preserved — always false (no workers to preserve).
26
- */
27
- get isPreservingWorkers() {
28
- return !1;
29
- }
30
- /**
31
- * Gets the singleton instance.
32
- */
33
- static getInstance(t) {
34
- return r.#e || (r.#e = new r(t)), r.#e;
35
- }
36
- /**
37
- * Resets the singleton instance (for testing).
38
- */
39
- static resetInstance() {
40
- r.#e = null;
41
- }
42
- /**
43
- * No-op — no workers to preserve.
44
- */
45
- preserveWorkers() {
46
- }
47
- /**
48
- * No-op — no workers to release.
49
- */
50
- releaseWorkers() {
51
- }
52
- /**
53
- * No-op — no initialization required.
54
- */
55
- async initialize() {
56
- }
57
- /**
58
- * Signs tasks sequentially on the main thread.
59
- */
60
- // eslint-disable-next-line @typescript-eslint/require-await
61
- async signBatch(t, c) {
62
- const o = performance.now();
63
- if (t.length === 0)
64
- return {
65
- success: !0,
66
- signatures: /* @__PURE__ */ new Map(),
67
- errors: /* @__PURE__ */ new Map(),
68
- durationMs: performance.now() - o
69
- };
70
- const i = f.get().lib, u = c.getPrivateKey(), p = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map();
71
- try {
72
- for (const e of t)
73
- try {
74
- let s;
75
- const n = e.hash, y = u;
76
- e.signatureType === g.Schnorr ? s = i.signSchnorr(n, y) : s = i.sign(n, y), p.set(e.inputIndex, {
77
- type: "result",
78
- taskId: e.taskId,
79
- signature: s,
80
- inputIndex: e.inputIndex,
81
- publicKey: c.publicKey,
82
- signatureType: e.signatureType,
83
- leafHash: e.leafHash
84
- });
85
- } catch (s) {
86
- const n = s instanceof Error ? s.message : "Signing failed";
87
- a.set(e.inputIndex, n);
88
- }
89
- } finally {
90
- u.fill(0);
91
- }
92
- return {
93
- success: a.size === 0,
94
- signatures: p,
95
- errors: a,
96
- durationMs: performance.now() - o
97
- };
98
- }
99
- /**
100
- * No-op — no workers to shut down.
101
- */
102
- async shutdown() {
103
- }
104
- /**
105
- * Enables `await using pool = ...` syntax.
106
- */
107
- async [Symbol.asyncDispose]() {
108
- await this.shutdown();
109
- }
110
- }
111
- export {
112
- r as SequentialSigningPool
113
- };