@cleocode/cant 2026.9.18 → 2026.9.20
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/README.md +28 -5
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -1
- package/dist/native-loader.d.ts +60 -10
- package/dist/native-loader.js +79 -43
- package/dist/parse.js +2 -1
- package/napi/cant.darwin-arm64.node +0 -0
- package/napi/cant.darwin-x64.node +0 -0
- package/napi/cant.linux-arm64-gnu.node +0 -0
- package/napi/cant.linux-arm64-musl.node +0 -0
- package/napi/cant.linux-x64-gnu.node +0 -0
- package/napi/cant.linux-x64-musl.node +0 -0
- package/napi/cant.wasi.cjs +1757 -0
- package/napi/cant.wasm32-wasi.wasm +0 -0
- package/napi/cant.win32-arm64-msvc.node +0 -0
- package/napi/cant.win32-x64-msvc.node +0 -0
- package/napi/index.cjs +789 -0
- package/napi/wasi-worker.mjs +82 -0
- package/package.json +27 -16
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import fs from 'node:fs'
|
|
2
|
+
import { createRequire } from 'node:module'
|
|
3
|
+
import { parse } from 'node:path'
|
|
4
|
+
import { WASI } from 'node:wasi'
|
|
5
|
+
import { parentPort, Worker, workerData } from 'node:worker_threads'
|
|
6
|
+
|
|
7
|
+
const require = createRequire(import.meta.url)
|
|
8
|
+
|
|
9
|
+
const {
|
|
10
|
+
instantiateNapiModuleSync,
|
|
11
|
+
MessageHandler,
|
|
12
|
+
getDefaultContext,
|
|
13
|
+
emnapiAsyncWorkPlugin,
|
|
14
|
+
emnapiTSFNPlugin,
|
|
15
|
+
} = require('@napi-rs/wasm-runtime')
|
|
16
|
+
|
|
17
|
+
if (parentPort) {
|
|
18
|
+
parentPort.on('message', (data) => {
|
|
19
|
+
globalThis.onmessage({ data })
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
Object.assign(globalThis, {
|
|
24
|
+
self: globalThis,
|
|
25
|
+
require,
|
|
26
|
+
Worker,
|
|
27
|
+
importScripts: function (f) {
|
|
28
|
+
// oxlint-disable-next-line no-eval -- WASI importScripts polyfill
|
|
29
|
+
;(0, eval)(fs.readFileSync(f, 'utf8') + '//# sourceURL=' + f)
|
|
30
|
+
},
|
|
31
|
+
postMessage: function (msg) {
|
|
32
|
+
if (parentPort) {
|
|
33
|
+
parentPort.postMessage(msg)
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
const emnapiContext = getDefaultContext()
|
|
39
|
+
|
|
40
|
+
const __cwd = process.cwd()
|
|
41
|
+
const __rootDir =
|
|
42
|
+
(workerData && typeof workerData.rootDir === 'string' && workerData.rootDir) ||
|
|
43
|
+
parse(__cwd).root
|
|
44
|
+
const __hostRoot =
|
|
45
|
+
(workerData && typeof workerData.hostRoot === 'string' && workerData.hostRoot) ||
|
|
46
|
+
(process.platform === 'android' ? __cwd : __rootDir)
|
|
47
|
+
|
|
48
|
+
const handler = new MessageHandler({
|
|
49
|
+
onLoad({ wasmModule, wasmMemory }) {
|
|
50
|
+
const wasi = new WASI({
|
|
51
|
+
version: 'preview1',
|
|
52
|
+
env: process.env,
|
|
53
|
+
preopens: {
|
|
54
|
+
[__rootDir]: __hostRoot,
|
|
55
|
+
[__hostRoot]: __hostRoot,
|
|
56
|
+
},
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
return instantiateNapiModuleSync(wasmModule, {
|
|
60
|
+
childThread: true,
|
|
61
|
+
wasi,
|
|
62
|
+
context: emnapiContext,
|
|
63
|
+
// The wasm links a "basic" emnapi archive (no C async-work /
|
|
64
|
+
// threadsafe-function implementations), so every thread that
|
|
65
|
+
// instantiates it must provide the JavaScript implementations
|
|
66
|
+
// through the emnapi plugins.
|
|
67
|
+
plugins: [emnapiAsyncWorkPlugin, emnapiTSFNPlugin],
|
|
68
|
+
overwriteImports(importObject) {
|
|
69
|
+
importObject.env = {
|
|
70
|
+
...importObject.env,
|
|
71
|
+
...importObject.napi,
|
|
72
|
+
...importObject.emnapi,
|
|
73
|
+
memory: wasmMemory,
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
})
|
|
77
|
+
},
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
globalThis.onmessage = function (e) {
|
|
81
|
+
handler.handle(e)
|
|
82
|
+
}
|
package/package.json
CHANGED
|
@@ -1,33 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cleocode/cant",
|
|
3
|
-
"version": "2026.9.
|
|
3
|
+
"version": "2026.9.20",
|
|
4
4
|
"description": "CANT DSL — cant-core (SSoT) parser, validator, and pipeline executor via napi-rs; agent identity, message parsing, and migration utilities",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist/",
|
|
9
|
-
"napi/"
|
|
9
|
+
"napi/index.cjs",
|
|
10
|
+
"napi/cant.*.node",
|
|
11
|
+
"napi/cant.wasi.cjs",
|
|
12
|
+
"napi/wasi-worker.mjs",
|
|
13
|
+
"napi/cant.wasm32-wasi.wasm"
|
|
10
14
|
],
|
|
11
15
|
"dependencies": {
|
|
12
|
-
"@
|
|
13
|
-
"@
|
|
14
|
-
"@
|
|
16
|
+
"@emnapi/core": "1.11.3",
|
|
17
|
+
"@emnapi/runtime": "1.11.3",
|
|
18
|
+
"@napi-rs/wasm-runtime": "1.2.4",
|
|
19
|
+
"@cleocode/contracts": "2026.9.20",
|
|
20
|
+
"@cleocode/core": "2026.9.20",
|
|
21
|
+
"@cleocode/lafs": "2026.9.20"
|
|
15
22
|
},
|
|
16
23
|
"devDependencies": {
|
|
17
24
|
"typescript": "^6.0.2",
|
|
18
25
|
"vitest": "^4.1.4"
|
|
19
26
|
},
|
|
20
27
|
"napi": {
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
"binaryName": "cant",
|
|
29
|
+
"packageName": "@cleocode/cant",
|
|
30
|
+
"targets": [
|
|
31
|
+
"x86_64-unknown-linux-gnu",
|
|
32
|
+
"aarch64-unknown-linux-gnu",
|
|
33
|
+
"x86_64-unknown-linux-musl",
|
|
34
|
+
"aarch64-unknown-linux-musl",
|
|
35
|
+
"aarch64-apple-darwin",
|
|
36
|
+
"x86_64-apple-darwin",
|
|
37
|
+
"x86_64-pc-windows-msvc",
|
|
38
|
+
"aarch64-pc-windows-msvc",
|
|
39
|
+
"wasm32-wasip1-threads"
|
|
40
|
+
]
|
|
31
41
|
},
|
|
32
42
|
"keywords": [
|
|
33
43
|
"cleo",
|
|
@@ -50,7 +60,8 @@
|
|
|
50
60
|
},
|
|
51
61
|
"scripts": {
|
|
52
62
|
"build": "tsc -b",
|
|
53
|
-
"build:napi": "
|
|
63
|
+
"build:napi": "pnpm --package=@napi-rs/cli@3.10.5 dlx napi build --platform --release --manifest-path ../../crates/cant-napi/Cargo.toml --package-json-path package.json --output-dir napi --js index.cjs --dts index.d.ts",
|
|
64
|
+
"build:napi:wasi": "pnpm --package=@napi-rs/cli@3.10.5 --package=emnapi@1.11.3 dlx napi build --platform --release --manifest-path ../../crates/cant-napi/Cargo.toml --package-json-path package.json --output-dir napi --js index.cjs --dts index.d.ts --target wasm32-wasip1-threads",
|
|
54
65
|
"test": "vitest run",
|
|
55
66
|
"test:watch": "vitest"
|
|
56
67
|
}
|