@candypoets/nipworker 1.0.0

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 (67) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +341 -0
  3. package/dist/hooks.d.ts +6 -0
  4. package/dist/hooks.d.ts.map +1 -0
  5. package/dist/hooks.js +33 -0
  6. package/dist/hooks.js.map +1 -0
  7. package/dist/index.d.ts +81 -0
  8. package/dist/index.d.ts.map +1 -0
  9. package/dist/index.js +13 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/index2.js +8 -0
  12. package/dist/index2.js.map +1 -0
  13. package/dist/index3.js +270 -0
  14. package/dist/index3.js.map +1 -0
  15. package/dist/lib/sharedBuffer.d.ts +50 -0
  16. package/dist/lib/sharedBuffer.d.ts.map +1 -0
  17. package/dist/nostr_worker.js +1001 -0
  18. package/dist/nostr_worker.js.map +1 -0
  19. package/dist/types/index.d.ts +53 -0
  20. package/dist/types/index.d.ts.map +1 -0
  21. package/dist/types/kind0.d.ts +24 -0
  22. package/dist/types/kind0.d.ts.map +1 -0
  23. package/dist/types/kind1.d.ts +17 -0
  24. package/dist/types/kind1.d.ts.map +1 -0
  25. package/dist/types/kind10002.d.ts +7 -0
  26. package/dist/types/kind10002.d.ts.map +1 -0
  27. package/dist/types/kind10019.d.ts +9 -0
  28. package/dist/types/kind10019.d.ts.map +1 -0
  29. package/dist/types/kind17.d.ts +4 -0
  30. package/dist/types/kind17.d.ts.map +1 -0
  31. package/dist/types/kind17375.d.ts +7 -0
  32. package/dist/types/kind17375.d.ts.map +1 -0
  33. package/dist/types/kind3.d.ts +7 -0
  34. package/dist/types/kind3.d.ts.map +1 -0
  35. package/dist/types/kind39089.d.ts +11 -0
  36. package/dist/types/kind39089.d.ts.map +1 -0
  37. package/dist/types/kind4.d.ts +9 -0
  38. package/dist/types/kind4.d.ts.map +1 -0
  39. package/dist/types/kind6.d.ts +6 -0
  40. package/dist/types/kind6.d.ts.map +1 -0
  41. package/dist/types/kind7.d.ts +18 -0
  42. package/dist/types/kind7.d.ts.map +1 -0
  43. package/dist/types/kind7374.d.ts +6 -0
  44. package/dist/types/kind7374.d.ts.map +1 -0
  45. package/dist/types/kind7375.d.ts +9 -0
  46. package/dist/types/kind7375.d.ts.map +1 -0
  47. package/dist/types/kind7376.d.ts +16 -0
  48. package/dist/types/kind7376.d.ts.map +1 -0
  49. package/dist/types/kind9321.d.ts +11 -0
  50. package/dist/types/kind9321.d.ts.map +1 -0
  51. package/dist/types/kind9735.d.ts +15 -0
  52. package/dist/types/kind9735.d.ts.map +1 -0
  53. package/dist/types/proofs.d.ts +21 -0
  54. package/dist/types/proofs.d.ts.map +1 -0
  55. package/dist/utils.d.ts +23 -0
  56. package/dist/utils.d.ts.map +1 -0
  57. package/dist/utils.js +56 -0
  58. package/dist/utils.js.map +1 -0
  59. package/dist/wasm/main/nostr_main.d.ts +74 -0
  60. package/dist/wasm/main/nostr_main_bg.wasm.d.ts +20 -0
  61. package/dist/wasm/worker/nostr_worker.d.ts +45 -0
  62. package/dist/wasm/worker/nostr_worker_bg.wasm.d.ts +41 -0
  63. package/dist/worker.d.ts +3 -0
  64. package/dist/worker.d.ts.map +1 -0
  65. package/dist/worker.js +13 -0
  66. package/dist/worker.js.map +1 -0
  67. package/package.json +71 -0
@@ -0,0 +1,3 @@
1
+ declare const initWorker: () => Promise<import('./wasm/worker/nostr_worker.js').NostrClient>;
2
+ declare const initialized: Promise<import('./wasm/worker/nostr_worker.js').NostrClient>;
3
+ //# sourceMappingURL=worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,UAAU,sEAiBf,CAAC;AAEF,QAAA,MAAM,WAAW,gEAAe,CAAC"}
package/dist/worker.js ADDED
@@ -0,0 +1,13 @@
1
+ const e = async () => {
2
+ try {
3
+ console.log("WASM worker module initialized successfully");
4
+ const { init_nostr_client: o } = await import("./nostr_worker.js");
5
+ return await o();
6
+ } catch (o) {
7
+ throw console.log("oops"), console.error("Failed to initialize WASM worker module:", o), o;
8
+ }
9
+ }, i = e();
10
+ self.onmessage = async (o) => {
11
+ (await i).handle_message(o.data);
12
+ };
13
+ //# sourceMappingURL=worker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker.js","sources":["../src/worker.ts"],"sourcesContent":["// import { openDB } from 'idb';\n\n// Initialize WASM and set up the worker\nconst initWorker = async () => {\n try {\n // Initialize the WASM module\n // init_worker() is called automatically via #[wasm_bindgen(start)]\n\n console.log(\"WASM worker module initialized successfully\");\n\n const { init_nostr_client } = await import(\n \"src/wasm/worker/nostr_worker.js\"\n );\n // await init();\n return await init_nostr_client();\n } catch (error) {\n console.log(\"oops\");\n console.error(\"Failed to initialize WASM worker module:\", error);\n throw error;\n }\n};\n\nconst initialized = initWorker();\n\nself.onmessage = async (event) => {\n // const { type, data } = event.data;\n const client = await initialized;\n\n client.handle_message(event.data);\n};\n"],"names":["initWorker","init_nostr_client","error","initialized","event"],"mappings":"AAGA,MAAMA,IAAa,YAAY;AAC7B,MAAI;AAIF,YAAQ,IAAI,6CAA6C;AAEzD,UAAM,EAAE,mBAAAC,EAAA,IAAsB,MAAM,OAClC,mBACF;AAEA,WAAO,MAAMA,EAAA;AAAA,EACf,SAASC,GAAO;AACd,kBAAQ,IAAI,MAAM,GAClB,QAAQ,MAAM,4CAA4CA,CAAK,GACzDA;AAAA,EACR;AACF,GAEMC,IAAcH,EAAA;AAEpB,KAAK,YAAY,OAAOI,MAAU;AAIhC,GAFe,MAAMD,GAEd,eAAeC,EAAM,IAAI;AAClC;"}
package/package.json ADDED
@@ -0,0 +1,71 @@
1
+ {
2
+ "name": "@candypoets/nipworker",
3
+ "version": "1.0.0",
4
+ "description": "Nostr client library with worker-based architecture using Rust WASM",
5
+ "type": "module",
6
+ "module": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ },
13
+ "./hooks": {
14
+ "import": "./dist/hooks.js",
15
+ "types": "./dist/hooks.d.ts"
16
+ },
17
+ "./utils": {
18
+ "import": "./dist/utils.js",
19
+ "types": "./dist/utils.d.ts"
20
+ }
21
+ },
22
+ "files": [
23
+ "dist",
24
+ "README.md"
25
+ ],
26
+ "scripts": {
27
+ "dev": "vite",
28
+ "build": "npm run build:wasm && vite build",
29
+ "build:wasm": "npm run build:wasm:main && npm run build:wasm:worker",
30
+ "build:wasm:main": "cd nostr-main && wasm-pack build --target bundler --out-dir ../src/wasm/main --no-pack && rm ../src/wasm/main/.gitignore",
31
+ "build:wasm:worker": "cd nostr-worker && wasm-pack build --target bundler --out-dir ../src/wasm/worker --no-pack && rm ../src/wasm/worker/.gitignore",
32
+ "build:types": "tsc --emitDeclarationOnly --outDir dist",
33
+ "preview": "vite preview",
34
+ "prepublishOnly": "npm run build",
35
+ "clean": "rm -rf dist src/wasm",
36
+ "test": "echo \"No tests yet\" && exit 0"
37
+ },
38
+ "keywords": [
39
+ "nostr",
40
+ "protocol",
41
+ "web-worker",
42
+ "wasm",
43
+ "rust"
44
+ ],
45
+ "author": "So Tachi <sotachi@proton.me>",
46
+ "license": "MIT",
47
+ "repository": {
48
+ "type": "git",
49
+ "url": "https://github.com/candypoets/nipworker.git"
50
+ },
51
+ "bugs": {
52
+ "url": "https://github.com/candypoets/nipworker/issues"
53
+ },
54
+ "homepage": "https://github.com/candypoets/nipworker#readme",
55
+ "devDependencies": {
56
+ "@types/node": "^20.0.0",
57
+ "typescript": "^5.0.0",
58
+ "vite": "^5.0.0",
59
+ "vite-plugin-dts": "^3.0.0",
60
+ "vite-plugin-static-copy": "^3.1.1",
61
+ "vite-plugin-wasm": "^3.0.0"
62
+ },
63
+ "dependencies": {
64
+ "@msgpack/msgpack": "^3.0.0",
65
+ "msgpackr": "^1.11.5",
66
+ "nostr-tools": "^2.0.0"
67
+ },
68
+ "engines": {
69
+ "node": ">=18.0.0"
70
+ }
71
+ }