{"_id":"@dicexp/naive-evaluator-in-worker","_rev":"2-7bcc1386163fa0cc4fb859a3031390d2","name":"@dicexp/naive-evaluator-in-worker","dist-tags":{"latest":"0.5.3"},"versions":{"0.5.0":{"packageManager":"pnpm@8.10.0","name":"@dicexp/naive-evaluator-in-worker","version":"0.5.0","type":"module","sideEffects":false,"module":"./dist/lib.js","types":"./dist/lib.d.ts","exports":{".":{"import":{"types":"./dist/lib.d.ts","default":"./dist/lib.js"}},"./internal":"./internal.ts"},"repository":{"type":"git","url":"git+https://github.com/umajho/dicexp.git"},"keywords":["dicexp"],"author":{"name":"Umaĵo"},"license":"MIT","homepage":"https://github.com/umajho/dicexp/tree/main/packages/naive-evaluator-in-worker#readme","devDependencies":{"@types/node":"^20.8.6","esbuild":"^0.18.20","terser":"^5.21.0","tsup":"^7.1.0","@dicexp/build-utils":"0.0.0","@dicexp/naive-evaluator-runtime":"0.0.0","@dicexp/interface":"0.5.0","@dicexp/errors":"0.0.0","@dicexp/naive-evaluator":"0.5.0"},"scripts":{"type-check":"tsc --noEmit","build":"tsup"},"description":"## Usage","bugs":{"url":"https://github.com/umajho/dicexp/issues"},"_id":"@dicexp/naive-evaluator-in-worker@0.5.0","_integrity":"sha512-NIY955bPpQBGg+VSY9zXvYp5oG2weh6zb6rAD5bCYn7CACG3s6AGR0WjIcPGk9D/qNLQiUz8nkgU5iKKR2kj5w==","_resolved":"/private/var/folders/q2/ns2h7tk5153c4dfsy55s6jyw0000gn/T/fb58e450acd4b0614d3647325264baaf/dicexp-naive-evaluator-in-worker-0.5.0.tgz","_from":"file:dicexp-naive-evaluator-in-worker-0.5.0.tgz","_nodeVersion":"16.20.2","_npmVersion":"8.19.4","dist":{"integrity":"sha512-NIY955bPpQBGg+VSY9zXvYp5oG2weh6zb6rAD5bCYn7CACG3s6AGR0WjIcPGk9D/qNLQiUz8nkgU5iKKR2kj5w==","shasum":"00c24a338549ebcf5f6078e636aff6c706723ee1","tarball":"https://registry.npmjs.org/@dicexp/naive-evaluator-in-worker/-/naive-evaluator-in-worker-0.5.0.tgz","fileCount":5,"unpackedSize":23000,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDDs9+pIR4yHmQrTHni57RKLXNkIn+4sQ1jt8hsyXyWZAiBGgiqHrxn0agzK926DUP1Q2FHmz0aYEttHP1IDlb5jDw=="}]},"_npmUser":{"name":"umajho","email":"umajho@proton.me"},"directories":{},"maintainers":[{"name":"umajho","email":"umajho@proton.me"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/naive-evaluator-in-worker_0.5.0_1713365368113_0.3312338338227958"},"_hasShrinkwrap":false},"0.5.1":{"packageManager":"pnpm@8.10.0","name":"@dicexp/naive-evaluator-in-worker","version":"0.5.1","type":"module","sideEffects":false,"module":"./dist/lib.js","types":"./dist/lib.d.ts","exports":{".":{"import":{"types":"./dist/lib.d.ts","default":"./dist/lib.js"}},"./internal":"./internal.ts"},"repository":{"type":"git","url":"git+https://github.com/umajho/dicexp.git"},"keywords":["dicexp"],"author":{"name":"Umaĵo"},"license":"MIT","homepage":"https://github.com/umajho/dicexp/tree/main/packages/naive-evaluator-in-worker#readme","devDependencies":{"@types/node":"^20.8.6","esbuild":"^0.18.20","terser":"^5.21.0","tsup":"^7.1.0","@dicexp/build-utils":"0.0.0","@dicexp/errors":"0.0.0","@dicexp/interface":"0.5.0","@dicexp/naive-evaluator":"0.5.0","@dicexp/naive-evaluator-runtime":"0.0.0"},"scripts":{"type-check":"tsc --noEmit","build":"tsup"},"description":"## Usage","bugs":{"url":"https://github.com/umajho/dicexp/issues"},"_id":"@dicexp/naive-evaluator-in-worker@0.5.1","_integrity":"sha512-oZF79dmPtvvG5rAxCfG7D3p80F5V+U/ZbRtmgufSd0MPNLiP4Gl1qT5xcm+Szd7MmLGQk/PFm3CTpnvj3pT3Gg==","_resolved":"/private/var/folders/q2/ns2h7tk5153c4dfsy55s6jyw0000gn/T/0f00fbb69a66754eb8eb4b81ef8de735/dicexp-naive-evaluator-in-worker-0.5.1.tgz","_from":"file:dicexp-naive-evaluator-in-worker-0.5.1.tgz","_nodeVersion":"16.20.2","_npmVersion":"8.19.4","dist":{"integrity":"sha512-oZF79dmPtvvG5rAxCfG7D3p80F5V+U/ZbRtmgufSd0MPNLiP4Gl1qT5xcm+Szd7MmLGQk/PFm3CTpnvj3pT3Gg==","shasum":"5f24c27006472bf702089e9d896572224b2639c6","tarball":"https://registry.npmjs.org/@dicexp/naive-evaluator-in-worker/-/naive-evaluator-in-worker-0.5.1.tgz","fileCount":5,"unpackedSize":22912,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIASHp32/KY/dE+0gPc3RYQvh0m2nochHsxNlqMi3Wl4yAiEAgrnpOC1d8iiRiiUAyyUjUVsjW0Qrmh1TdPfGbqeLdrk="}]},"_npmUser":{"name":"umajho","email":"umajho@proton.me"},"directories":{},"maintainers":[{"name":"umajho","email":"umajho@proton.me"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/naive-evaluator-in-worker_0.5.1_1713511337531_0.9564495933436588"},"_hasShrinkwrap":false},"0.5.3":{"packageManager":"pnpm@8.10.0","name":"@dicexp/naive-evaluator-in-worker","version":"0.5.3","type":"module","sideEffects":false,"module":"./dist/lib.js","types":"./dist/lib.d.ts","exports":{".":{"import":{"types":"./dist/lib.d.ts","default":"./dist/lib.js"}},"./internal":"./internal.ts"},"repository":{"type":"git","url":"git+https://github.com/umajho/dicexp.git"},"keywords":["dicexp"],"author":{"name":"Umaĵo"},"license":"MIT","homepage":"https://github.com/umajho/dicexp/tree/main/packages/naive-evaluator-in-worker#readme","devDependencies":{"@types/node":"^20.8.6","esbuild":"^0.18.20","terser":"^5.21.0","tsup":"^7.1.0","@dicexp/naive-evaluator":"0.5.0","@dicexp/build-utils":"0.0.0","@dicexp/errors":"0.0.0","@dicexp/naive-evaluator-runtime":"0.0.0","@dicexp/interface":"0.5.0"},"scripts":{"type-check":"tsc --noEmit","build":"tsup"},"description":"## Usage","bugs":{"url":"https://github.com/umajho/dicexp/issues"},"_id":"@dicexp/naive-evaluator-in-worker@0.5.3","_integrity":"sha512-GRuTW3Y/r6WWN706yjdc74p434USyakDQsmavfoS1gmiEDySD76vEjMCmMlGT/CrXUK2F4elOL3YTaDoDY3MLg==","_resolved":"/private/var/folders/q2/ns2h7tk5153c4dfsy55s6jyw0000gn/T/7a0e0715e52c44780d5e056176876470/dicexp-naive-evaluator-in-worker-0.5.3.tgz","_from":"file:dicexp-naive-evaluator-in-worker-0.5.3.tgz","_nodeVersion":"20.12.2","_npmVersion":"10.5.0","dist":{"integrity":"sha512-GRuTW3Y/r6WWN706yjdc74p434USyakDQsmavfoS1gmiEDySD76vEjMCmMlGT/CrXUK2F4elOL3YTaDoDY3MLg==","shasum":"9e88df3c1bfdb456e4621a7b4d073dcc17675121","tarball":"https://registry.npmjs.org/@dicexp/naive-evaluator-in-worker/-/naive-evaluator-in-worker-0.5.3.tgz","fileCount":5,"unpackedSize":17897,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFVk4whyrk582eCffqkNkvru7rVQ7Qi8wec8txLJ0DIxAiByP49gdMh8H1+wydHJ1Q1AP4ndrVKANzrLR9F+hMb5Wg=="}]},"_npmUser":{"name":"umajho","email":"umajho@proton.me"},"directories":{},"maintainers":[{"name":"umajho","email":"umajho@proton.me"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/naive-evaluator-in-worker_0.5.3_1713875209020_0.6037939358216824"},"_hasShrinkwrap":false}},"time":{"created":"2024-04-17T14:49:27.944Z","0.5.0":"2024-04-17T14:49:28.260Z","modified":"2024-04-23T12:26:49.383Z","0.5.1":"2024-04-19T07:22:17.695Z","0.5.3":"2024-04-23T12:26:49.188Z"},"maintainers":[{"name":"umajho","email":"umajho@proton.me"}],"description":"## Usage","homepage":"https://github.com/umajho/dicexp/tree/main/packages/naive-evaluator-in-worker#readme","keywords":["dicexp"],"repository":{"type":"git","url":"git+https://github.com/umajho/dicexp.git"},"author":{"name":"Umaĵo"},"bugs":{"url":"https://github.com/umajho/dicexp/issues"},"license":"MIT","readme":"# naive-evaluator-in-worker\n\n## Usage\n\n`evaluating.worker.js`:\n\n```javascript\nimport { startWorkerServer } from \"@dicexp/naive-evaluator-in-worker\";\n\nimport { asScope, Evaluator } from \"@dicexp/naive-evaluator\";\nimport { functionScope, operatorScope } from \"@dicexp/naive-evaluator-builtins\";\n\n// 将 “运算符作用域” 与 “函数作用域” 合并为一个作用域。\nconst topLevelScope = asScope([operatorScope, functionScope]);\n\nstartWorkerServer((opts) => (new Evaluator(opts)), topLevelScope);\n```\n\n`main.js`:\n\n```javascript\nimport { EvaluatingWorkerManager } from \"@dicexp/naive-evaluator-in-worker\";\n\n// 如果运行环境是并不存在原生 Web Worker 的 node：\n// 可以将 “web-worker” 包添加为依赖。（目前的最新版本 1.3.0 对模块的支持有问题，\n// 可以考虑使用更老的 1.2.0。）\nimport Worker from \"web-worker\";\nconst workerProvider = () =>\n  new Worker(new URL(\"./evaluating.worker.js\", import.meta.url), {\n    type: \"module\",\n  });\n\n// 如果运行环境是浏览器，假设使用 Vite 打包：\nimport DicexpEvaluatingWorker from \"./evaluating.worker?worker\";\nconst workerProvider = () => new DicexpEvaluatingWorker();\n\nconst result = await new Promise((resolve) => {\n  const manager = new EvaluatingWorkerManager(\n    workerProvider,\n    async (ready) => {\n      if (!ready) return;\n\n      // `result` 的类型是 `EvaluationResult`。\n      // “dicexp” 包的 README 中有列举 `EvaluationResult` 需要处理的分支。\n      const result = await manager.evaluateRemote(\"d100\", {\n        execution: { seed: 42 },\n      });\n\n      resolve(result);\n      manager.destroy();\n    },\n    {\n      newEvaluatorOptions: {\n        randomSourceMaker: \"xorshift7\",\n      },\n    },\n  );\n});\n\nconsole.log(result);\n```\n","readmeFilename":"README.md"}