satteri 0.9.4 → 0.10.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.
- package/README.md +11 -1
- package/dist/binding.browser.d.ts +1 -1
- package/dist/binding.browser.js +1 -1
- package/dist/binding.d.ts +1 -1
- package/dist/binding.js +1 -1
- package/dist/byte-writer.d.ts +4 -0
- package/dist/byte-writer.js +13 -4
- package/dist/child-stub.d.ts +7 -3
- package/dist/child-stub.js +18 -7
- package/dist/command-buffer.d.ts +36 -50
- package/dist/command-buffer.js +102 -49
- package/dist/compile.d.ts +80 -32
- package/dist/compile.js +295 -70
- package/dist/freeze.d.ts +2 -0
- package/dist/freeze.js +10 -0
- package/dist/generated/wire-constants.d.ts +3 -2
- package/dist/generated/wire-constants.js +4 -2
- package/dist/hast/child-stub.d.ts +2 -3
- package/dist/hast/child-stub.js +18 -11
- package/dist/hast/element-props.d.ts +1 -1
- package/dist/hast/element-props.js +14 -6
- package/dist/hast/hast-materializer.d.ts +6 -2
- package/dist/hast/hast-materializer.js +48 -134
- package/dist/hast/hast-reader.d.ts +7 -13
- package/dist/hast/hast-reader.js +76 -21
- package/dist/hast/hast-visitor.d.ts +55 -5
- package/dist/hast/hast-visitor.js +320 -154
- package/dist/index.d.ts +6 -6
- package/dist/index.js +1 -1
- package/dist/lazy-child-resolver.d.ts +20 -13
- package/dist/lazy-child-resolver.js +66 -38
- package/dist/materializer-cache.d.ts +42 -0
- package/dist/materializer-cache.js +192 -0
- package/dist/mdast/child-stub.d.ts +6 -3
- package/dist/mdast/child-stub.js +71 -8
- package/dist/mdast/generated/layout.d.ts +2 -3
- package/dist/mdast/generated/layout.js +24 -28
- package/dist/mdast/generated/node-types.d.ts +4 -0
- package/dist/mdast/generated/node-types.js +25 -0
- package/dist/mdast/mdast-materializer.d.ts +12 -3
- package/dist/mdast/mdast-materializer.js +83 -78
- package/dist/mdast/mdast-reader.d.ts +15 -0
- package/dist/mdast/mdast-reader.js +55 -10
- package/dist/mdast/mdast-visitor.d.ts +79 -32
- package/dist/mdast/mdast-visitor.js +305 -122
- package/dist/op-stream.d.ts +5 -12
- package/dist/op-stream.js +6 -21
- package/dist/plugin.d.ts +36 -10
- package/dist/plugin.js +50 -2
- package/dist/string-pool.d.ts +13 -0
- package/dist/string-pool.js +91 -0
- package/dist/types.d.ts +44 -1
- package/dist/visitor-shared.d.ts +27 -4
- package/dist/visitor-shared.js +36 -10
- package/dist/wire-read.js +3 -1
- package/index.d.ts +130 -7
- package/index.js +89 -68
- package/package.json +24 -19
- package/dist/lazy-props.d.ts +0 -10
- package/dist/lazy-props.js +0 -50
- package/satteri_napi.wasi-browser.js +0 -83
- package/satteri_napi.wasi.cjs +0 -134
- package/wasi-worker-browser.mjs +0 -36
- package/wasi-worker.mjs +0 -63
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "satteri",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "High-performance Markdown and MDX processing",
|
|
5
|
+
"license": "MIT",
|
|
5
6
|
"repository": {
|
|
6
7
|
"type": "git",
|
|
7
8
|
"url": "git+https://github.com/bruits/satteri.git"
|
|
@@ -11,10 +12,6 @@
|
|
|
11
12
|
"browser.js",
|
|
12
13
|
"index.js",
|
|
13
14
|
"index.d.ts",
|
|
14
|
-
"satteri_napi.wasi.cjs",
|
|
15
|
-
"satteri_napi.wasi-browser.js",
|
|
16
|
-
"wasi-worker.mjs",
|
|
17
|
-
"wasi-worker-browser.mjs",
|
|
18
15
|
"webcontainer-fallback.cjs"
|
|
19
16
|
],
|
|
20
17
|
"type": "module",
|
|
@@ -36,7 +33,7 @@
|
|
|
36
33
|
},
|
|
37
34
|
"dependencies": {
|
|
38
35
|
"@types/estree-jsx": "^1.0.5",
|
|
39
|
-
"@types/hast": "^3.0.
|
|
36
|
+
"@types/hast": "^3.0.5",
|
|
40
37
|
"@types/mdast": "^4.0.4",
|
|
41
38
|
"@types/unist": "^3.0.3"
|
|
42
39
|
},
|
|
@@ -46,17 +43,19 @@
|
|
|
46
43
|
"@emnapi/runtime": "^1.11.1",
|
|
47
44
|
"@mdx-js/mdx": "^3.1.1",
|
|
48
45
|
"@napi-rs/wasm-runtime": "^1.1.5",
|
|
49
|
-
"@types/node": "^
|
|
50
|
-
"@types/react": "^19.2.
|
|
51
|
-
"@types/react-dom": "^19.2.
|
|
46
|
+
"@types/node": "^26.2.0",
|
|
47
|
+
"@types/react": "^19.2.18",
|
|
48
|
+
"@types/react-dom": "^19.2.4",
|
|
52
49
|
"fast-check": "^4.7.0",
|
|
53
50
|
"hastscript": "^9.0.1",
|
|
54
51
|
"mdast-util-mdx": "^3.0.0",
|
|
55
52
|
"mdast-util-to-hast": "^13.2.1",
|
|
56
53
|
"react": "^19.2.5",
|
|
57
54
|
"react-dom": "^19.2.5",
|
|
55
|
+
"rehype-raw": "^7.0.0",
|
|
58
56
|
"rehype-stringify": "^10.0.1",
|
|
59
57
|
"remark": "^15.0.1",
|
|
58
|
+
"remark-definition-list": "^2.0.0",
|
|
60
59
|
"remark-directive": "^4.0.0",
|
|
61
60
|
"remark-frontmatter": "^5.0.0",
|
|
62
61
|
"remark-gfm": "^4.0.1",
|
|
@@ -81,18 +80,23 @@
|
|
|
81
80
|
"x86_64-pc-windows-msvc",
|
|
82
81
|
"aarch64-pc-windows-msvc",
|
|
83
82
|
"wasm32-wasip1-threads"
|
|
84
|
-
]
|
|
83
|
+
],
|
|
84
|
+
"wasm": {
|
|
85
|
+
"browser": {
|
|
86
|
+
"asyncInit": true
|
|
87
|
+
}
|
|
88
|
+
}
|
|
85
89
|
},
|
|
86
90
|
"optionalDependencies": {
|
|
87
|
-
"@bruits/satteri-linux-x64-gnu": "0.
|
|
88
|
-
"@bruits/satteri-linux-arm64-gnu": "0.
|
|
89
|
-
"@bruits/satteri-linux-x64-musl": "0.
|
|
90
|
-
"@bruits/satteri-linux-arm64-musl": "0.
|
|
91
|
-
"@bruits/satteri-darwin-x64": "0.
|
|
92
|
-
"@bruits/satteri-darwin-arm64": "0.
|
|
93
|
-
"@bruits/satteri-win32-x64-msvc": "0.
|
|
94
|
-
"@bruits/satteri-win32-arm64-msvc": "0.
|
|
95
|
-
"@bruits/satteri-wasm32-wasi": "0.
|
|
91
|
+
"@bruits/satteri-linux-x64-gnu": "0.10.0",
|
|
92
|
+
"@bruits/satteri-linux-arm64-gnu": "0.10.0",
|
|
93
|
+
"@bruits/satteri-linux-x64-musl": "0.10.0",
|
|
94
|
+
"@bruits/satteri-linux-arm64-musl": "0.10.0",
|
|
95
|
+
"@bruits/satteri-darwin-x64": "0.10.0",
|
|
96
|
+
"@bruits/satteri-darwin-arm64": "0.10.0",
|
|
97
|
+
"@bruits/satteri-win32-x64-msvc": "0.10.0",
|
|
98
|
+
"@bruits/satteri-win32-arm64-msvc": "0.10.0",
|
|
99
|
+
"@bruits/satteri-wasm32-wasi": "0.10.0"
|
|
96
100
|
},
|
|
97
101
|
"scripts": {
|
|
98
102
|
"build:binary:wasm": "napi build --manifest-path ../../crates/satteri-napi-binding/Cargo.toml --output-dir . --platform --release --esm --strip --target wasm32-wasip1-threads",
|
|
@@ -106,6 +110,7 @@
|
|
|
106
110
|
"build:binary:native:debug": "napi build --manifest-path ../../crates/satteri-napi-binding/Cargo.toml --output-dir . --platform --esm",
|
|
107
111
|
"postbuild:binary:native:debug": "node patch-binding.js",
|
|
108
112
|
"build:ts": "tsc --project tsconfig.build.json",
|
|
113
|
+
"typecheck": "tsc --project tsconfig.json --noEmit",
|
|
109
114
|
"build": "pnpm build:ts && pnpm build:binary:native",
|
|
110
115
|
"build:wasm": "pnpm build:ts && pnpm build:binary:wasm",
|
|
111
116
|
"artifacts": "napi create-npm-dirs && napi artifacts",
|
package/dist/lazy-props.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Build a lazy getter descriptor that caches the value on first access.
|
|
3
|
-
*/
|
|
4
|
-
export declare function lazyProp<T>(key: string, get: () => T): PropertyDescriptor;
|
|
5
|
-
/**
|
|
6
|
-
* First access to any field in the group resolves all fields from one reader call.
|
|
7
|
-
* Uses a shared resolve-once pattern: the first getter to fire reads all data,
|
|
8
|
-
* defines own properties for every key, then each per-key getter returns its value.
|
|
9
|
-
*/
|
|
10
|
-
export declare function lazyGroup(node: object, keys: readonly string[], resolve: () => Record<string, unknown>): void;
|
package/dist/lazy-props.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Build a lazy getter descriptor that caches the value on first access.
|
|
3
|
-
*/
|
|
4
|
-
export function lazyProp(key, get) {
|
|
5
|
-
return {
|
|
6
|
-
get() {
|
|
7
|
-
const value = get();
|
|
8
|
-
Object.defineProperty(this, key, {
|
|
9
|
-
value,
|
|
10
|
-
writable: true,
|
|
11
|
-
configurable: true,
|
|
12
|
-
enumerable: true,
|
|
13
|
-
});
|
|
14
|
-
return value;
|
|
15
|
-
},
|
|
16
|
-
configurable: true,
|
|
17
|
-
enumerable: true,
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* First access to any field in the group resolves all fields from one reader call.
|
|
22
|
-
* Uses a shared resolve-once pattern: the first getter to fire reads all data,
|
|
23
|
-
* defines own properties for every key, then each per-key getter returns its value.
|
|
24
|
-
*/
|
|
25
|
-
export function lazyGroup(node, keys, resolve) {
|
|
26
|
-
let cached;
|
|
27
|
-
const ensureResolved = () => {
|
|
28
|
-
if (cached)
|
|
29
|
-
return cached;
|
|
30
|
-
cached = resolve();
|
|
31
|
-
for (const k of keys) {
|
|
32
|
-
Object.defineProperty(node, k, {
|
|
33
|
-
value: cached[k],
|
|
34
|
-
writable: true,
|
|
35
|
-
configurable: true,
|
|
36
|
-
enumerable: true,
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
return cached;
|
|
40
|
-
};
|
|
41
|
-
for (const key of keys) {
|
|
42
|
-
Object.defineProperty(node, key, {
|
|
43
|
-
get() {
|
|
44
|
-
return ensureResolved()[key];
|
|
45
|
-
},
|
|
46
|
-
configurable: true,
|
|
47
|
-
enumerable: true,
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createOnMessage as __wasmCreateOnMessageForFsProxy,
|
|
3
|
-
getDefaultContext as __emnapiGetDefaultContext,
|
|
4
|
-
instantiateNapiModuleSync as __emnapiInstantiateNapiModuleSync,
|
|
5
|
-
WASI as __WASI,
|
|
6
|
-
} from '@napi-rs/wasm-runtime'
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const __wasi = new __WASI({
|
|
11
|
-
version: 'preview1',
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
const __wasmUrl = new URL('./satteri_napi.wasm32-wasi.wasm', import.meta.url).href
|
|
15
|
-
const __emnapiContext = __emnapiGetDefaultContext()
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const __sharedMemory = new WebAssembly.Memory({
|
|
19
|
-
initial: 4000,
|
|
20
|
-
maximum: 65536,
|
|
21
|
-
shared: true,
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
const __wasmFile = await fetch(__wasmUrl).then((res) => res.arrayBuffer())
|
|
25
|
-
|
|
26
|
-
const {
|
|
27
|
-
instance: __napiInstance,
|
|
28
|
-
module: __wasiModule,
|
|
29
|
-
napiModule: __napiModule,
|
|
30
|
-
} = __emnapiInstantiateNapiModuleSync(__wasmFile, {
|
|
31
|
-
context: __emnapiContext,
|
|
32
|
-
asyncWorkPoolSize: 4,
|
|
33
|
-
wasi: __wasi,
|
|
34
|
-
onCreateWorker() {
|
|
35
|
-
const worker = new Worker(new URL('./wasi-worker-browser.mjs', import.meta.url), {
|
|
36
|
-
type: 'module',
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return worker
|
|
41
|
-
},
|
|
42
|
-
overwriteImports(importObject) {
|
|
43
|
-
importObject.env = {
|
|
44
|
-
...importObject.env,
|
|
45
|
-
...importObject.napi,
|
|
46
|
-
...importObject.emnapi,
|
|
47
|
-
memory: __sharedMemory,
|
|
48
|
-
}
|
|
49
|
-
return importObject
|
|
50
|
-
},
|
|
51
|
-
beforeInit({ instance }) {
|
|
52
|
-
for (const name of Object.keys(instance.exports)) {
|
|
53
|
-
if (name.startsWith('__napi_register__')) {
|
|
54
|
-
instance.exports[name]()
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
})
|
|
59
|
-
export default __napiModule.exports
|
|
60
|
-
export const applyCommandsAndConvertToHastHandle = __napiModule.exports.applyCommandsAndConvertToHastHandle
|
|
61
|
-
export const applyCommandsToHandle = __napiModule.exports.applyCommandsToHandle
|
|
62
|
-
export const applyCommandsToMdastHandle = __napiModule.exports.applyCommandsToMdastHandle
|
|
63
|
-
export const compileHandle = __napiModule.exports.compileHandle
|
|
64
|
-
export const compileMdx = __napiModule.exports.compileMdx
|
|
65
|
-
export const convertMdastToHastHandle = __napiModule.exports.convertMdastToHastHandle
|
|
66
|
-
export const createHastHandle = __napiModule.exports.createHastHandle
|
|
67
|
-
export const createMdastHandle = __napiModule.exports.createMdastHandle
|
|
68
|
-
export const createMdxHastHandle = __napiModule.exports.createMdxHastHandle
|
|
69
|
-
export const createMdxMdastHandle = __napiModule.exports.createMdxMdastHandle
|
|
70
|
-
export const dropHandle = __napiModule.exports.dropHandle
|
|
71
|
-
export const getHandleSource = __napiModule.exports.getHandleSource
|
|
72
|
-
export const getMdastFrontmatter = __napiModule.exports.getMdastFrontmatter
|
|
73
|
-
export const getNodeData = __napiModule.exports.getNodeData
|
|
74
|
-
export const mdastTextContentHandle = __napiModule.exports.mdastTextContentHandle
|
|
75
|
-
export const parseEsm = __napiModule.exports.parseEsm
|
|
76
|
-
export const parseExpression = __napiModule.exports.parseExpression
|
|
77
|
-
export const parseToHtml = __napiModule.exports.parseToHtml
|
|
78
|
-
export const renderHandle = __napiModule.exports.renderHandle
|
|
79
|
-
export const serializeHandle = __napiModule.exports.serializeHandle
|
|
80
|
-
export const setNodeData = __napiModule.exports.setNodeData
|
|
81
|
-
export const textContentHandle = __napiModule.exports.textContentHandle
|
|
82
|
-
export const walkHandle = __napiModule.exports.walkHandle
|
|
83
|
-
export const walkMdastHandle = __napiModule.exports.walkMdastHandle
|
package/satteri_napi.wasi.cjs
DELETED
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
/* prettier-ignore */
|
|
3
|
-
|
|
4
|
-
/* auto-generated by NAPI-RS */
|
|
5
|
-
|
|
6
|
-
const __nodeFs = require('node:fs')
|
|
7
|
-
const __nodePath = require('node:path')
|
|
8
|
-
const { WASI: __nodeWASI } = require('node:wasi')
|
|
9
|
-
const { Worker } = require('node:worker_threads')
|
|
10
|
-
|
|
11
|
-
const {
|
|
12
|
-
createOnMessage: __wasmCreateOnMessageForFsProxy,
|
|
13
|
-
getDefaultContext: __emnapiGetDefaultContext,
|
|
14
|
-
instantiateNapiModuleSync: __emnapiInstantiateNapiModuleSync,
|
|
15
|
-
} = require('@napi-rs/wasm-runtime')
|
|
16
|
-
|
|
17
|
-
const __rootDir = __nodePath.parse(process.cwd()).root
|
|
18
|
-
|
|
19
|
-
const __wasi = new __nodeWASI({
|
|
20
|
-
version: 'preview1',
|
|
21
|
-
env: process.env,
|
|
22
|
-
preopens: {
|
|
23
|
-
[__rootDir]: __rootDir,
|
|
24
|
-
}
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
const __emnapiContext = __emnapiGetDefaultContext()
|
|
28
|
-
|
|
29
|
-
const __sharedMemory = new WebAssembly.Memory({
|
|
30
|
-
initial: 4000,
|
|
31
|
-
maximum: 65536,
|
|
32
|
-
shared: true,
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
let __wasmFilePath = __nodePath.join(__dirname, 'satteri_napi.wasm32-wasi.wasm')
|
|
36
|
-
const __wasmDebugFilePath = __nodePath.join(__dirname, 'satteri_napi.wasm32-wasi.debug.wasm')
|
|
37
|
-
|
|
38
|
-
if (__nodeFs.existsSync(__wasmDebugFilePath)) {
|
|
39
|
-
__wasmFilePath = __wasmDebugFilePath
|
|
40
|
-
} else if (!__nodeFs.existsSync(__wasmFilePath)) {
|
|
41
|
-
try {
|
|
42
|
-
__wasmFilePath = require.resolve('@bruits/satteri-wasm32-wasi/satteri_napi.wasm32-wasi.wasm')
|
|
43
|
-
} catch {
|
|
44
|
-
throw new Error('Cannot find satteri_napi.wasm32-wasi.wasm file, and @bruits/satteri-wasm32-wasi package is not installed.')
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const { instance: __napiInstance, module: __wasiModule, napiModule: __napiModule } = __emnapiInstantiateNapiModuleSync(__nodeFs.readFileSync(__wasmFilePath), {
|
|
49
|
-
context: __emnapiContext,
|
|
50
|
-
asyncWorkPoolSize: (function() {
|
|
51
|
-
const threadsSizeFromEnv = Number(process.env.NAPI_RS_ASYNC_WORK_POOL_SIZE ?? process.env.UV_THREADPOOL_SIZE)
|
|
52
|
-
// NaN > 0 is false
|
|
53
|
-
if (threadsSizeFromEnv > 0) {
|
|
54
|
-
return threadsSizeFromEnv
|
|
55
|
-
} else {
|
|
56
|
-
return 4
|
|
57
|
-
}
|
|
58
|
-
})(),
|
|
59
|
-
reuseWorker: true,
|
|
60
|
-
wasi: __wasi,
|
|
61
|
-
onCreateWorker() {
|
|
62
|
-
const worker = new Worker(__nodePath.join(__dirname, 'wasi-worker.mjs'), {
|
|
63
|
-
env: process.env,
|
|
64
|
-
})
|
|
65
|
-
worker.onmessage = ({ data }) => {
|
|
66
|
-
__wasmCreateOnMessageForFsProxy(__nodeFs)(data)
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// The main thread of Node.js waits for all the active handles before exiting.
|
|
70
|
-
// But Rust threads are never waited without `thread::join`.
|
|
71
|
-
// So here we hack the code of Node.js to prevent the workers from being referenced (active).
|
|
72
|
-
// According to https://github.com/nodejs/node/blob/19e0d472728c79d418b74bddff588bea70a403d0/lib/internal/worker.js#L415,
|
|
73
|
-
// a worker is consist of two handles: kPublicPort and kHandle.
|
|
74
|
-
{
|
|
75
|
-
const kPublicPort = Object.getOwnPropertySymbols(worker).find(s =>
|
|
76
|
-
s.toString().includes("kPublicPort")
|
|
77
|
-
);
|
|
78
|
-
if (kPublicPort) {
|
|
79
|
-
worker[kPublicPort].ref = () => {};
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const kHandle = Object.getOwnPropertySymbols(worker).find(s =>
|
|
83
|
-
s.toString().includes("kHandle")
|
|
84
|
-
);
|
|
85
|
-
if (kHandle) {
|
|
86
|
-
worker[kHandle].ref = () => {};
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
worker.unref();
|
|
90
|
-
}
|
|
91
|
-
return worker
|
|
92
|
-
},
|
|
93
|
-
overwriteImports(importObject) {
|
|
94
|
-
importObject.env = {
|
|
95
|
-
...importObject.env,
|
|
96
|
-
...importObject.napi,
|
|
97
|
-
...importObject.emnapi,
|
|
98
|
-
memory: __sharedMemory,
|
|
99
|
-
}
|
|
100
|
-
return importObject
|
|
101
|
-
},
|
|
102
|
-
beforeInit({ instance }) {
|
|
103
|
-
for (const name of Object.keys(instance.exports)) {
|
|
104
|
-
if (name.startsWith('__napi_register__')) {
|
|
105
|
-
instance.exports[name]()
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
},
|
|
109
|
-
})
|
|
110
|
-
module.exports = __napiModule.exports
|
|
111
|
-
module.exports.applyCommandsAndConvertToHastHandle = __napiModule.exports.applyCommandsAndConvertToHastHandle
|
|
112
|
-
module.exports.applyCommandsToHandle = __napiModule.exports.applyCommandsToHandle
|
|
113
|
-
module.exports.applyCommandsToMdastHandle = __napiModule.exports.applyCommandsToMdastHandle
|
|
114
|
-
module.exports.compileHandle = __napiModule.exports.compileHandle
|
|
115
|
-
module.exports.compileMdx = __napiModule.exports.compileMdx
|
|
116
|
-
module.exports.convertMdastToHastHandle = __napiModule.exports.convertMdastToHastHandle
|
|
117
|
-
module.exports.createHastHandle = __napiModule.exports.createHastHandle
|
|
118
|
-
module.exports.createMdastHandle = __napiModule.exports.createMdastHandle
|
|
119
|
-
module.exports.createMdxHastHandle = __napiModule.exports.createMdxHastHandle
|
|
120
|
-
module.exports.createMdxMdastHandle = __napiModule.exports.createMdxMdastHandle
|
|
121
|
-
module.exports.dropHandle = __napiModule.exports.dropHandle
|
|
122
|
-
module.exports.getHandleSource = __napiModule.exports.getHandleSource
|
|
123
|
-
module.exports.getMdastFrontmatter = __napiModule.exports.getMdastFrontmatter
|
|
124
|
-
module.exports.getNodeData = __napiModule.exports.getNodeData
|
|
125
|
-
module.exports.mdastTextContentHandle = __napiModule.exports.mdastTextContentHandle
|
|
126
|
-
module.exports.parseEsm = __napiModule.exports.parseEsm
|
|
127
|
-
module.exports.parseExpression = __napiModule.exports.parseExpression
|
|
128
|
-
module.exports.parseToHtml = __napiModule.exports.parseToHtml
|
|
129
|
-
module.exports.renderHandle = __napiModule.exports.renderHandle
|
|
130
|
-
module.exports.serializeHandle = __napiModule.exports.serializeHandle
|
|
131
|
-
module.exports.setNodeData = __napiModule.exports.setNodeData
|
|
132
|
-
module.exports.textContentHandle = __napiModule.exports.textContentHandle
|
|
133
|
-
module.exports.walkHandle = __napiModule.exports.walkHandle
|
|
134
|
-
module.exports.walkMdastHandle = __napiModule.exports.walkMdastHandle
|
package/wasi-worker-browser.mjs
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { instantiateNapiModuleSync, MessageHandler, WASI } from '@napi-rs/wasm-runtime'
|
|
2
|
-
|
|
3
|
-
const errorOutputs = []
|
|
4
|
-
|
|
5
|
-
const handler = new MessageHandler({
|
|
6
|
-
onLoad({ wasmModule, wasmMemory }) {
|
|
7
|
-
const wasi = new WASI({
|
|
8
|
-
print: function () {
|
|
9
|
-
// eslint-disable-next-line no-console
|
|
10
|
-
console.log.apply(console, arguments)
|
|
11
|
-
},
|
|
12
|
-
printErr: function() {
|
|
13
|
-
// eslint-disable-next-line no-console
|
|
14
|
-
console.error.apply(console, arguments)
|
|
15
|
-
|
|
16
|
-
},
|
|
17
|
-
})
|
|
18
|
-
return instantiateNapiModuleSync(wasmModule, {
|
|
19
|
-
childThread: true,
|
|
20
|
-
wasi,
|
|
21
|
-
overwriteImports(importObject) {
|
|
22
|
-
importObject.env = {
|
|
23
|
-
...importObject.env,
|
|
24
|
-
...importObject.napi,
|
|
25
|
-
...importObject.emnapi,
|
|
26
|
-
memory: wasmMemory,
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
})
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
globalThis.onmessage = function (e) {
|
|
35
|
-
handler.handle(e)
|
|
36
|
-
}
|
package/wasi-worker.mjs
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
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 } from "node:worker_threads";
|
|
6
|
-
|
|
7
|
-
const require = createRequire(import.meta.url);
|
|
8
|
-
|
|
9
|
-
const { instantiateNapiModuleSync, MessageHandler, getDefaultContext } = require("@napi-rs/wasm-runtime");
|
|
10
|
-
|
|
11
|
-
if (parentPort) {
|
|
12
|
-
parentPort.on("message", (data) => {
|
|
13
|
-
globalThis.onmessage({ data });
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
Object.assign(globalThis, {
|
|
18
|
-
self: globalThis,
|
|
19
|
-
require,
|
|
20
|
-
Worker,
|
|
21
|
-
importScripts: function (f) {
|
|
22
|
-
;(0, eval)(fs.readFileSync(f, "utf8") + "//# sourceURL=" + f);
|
|
23
|
-
},
|
|
24
|
-
postMessage: function (msg) {
|
|
25
|
-
if (parentPort) {
|
|
26
|
-
parentPort.postMessage(msg);
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
const emnapiContext = getDefaultContext();
|
|
32
|
-
|
|
33
|
-
const __rootDir = parse(process.cwd()).root;
|
|
34
|
-
|
|
35
|
-
const handler = new MessageHandler({
|
|
36
|
-
onLoad({ wasmModule, wasmMemory }) {
|
|
37
|
-
const wasi = new WASI({
|
|
38
|
-
version: 'preview1',
|
|
39
|
-
env: process.env,
|
|
40
|
-
preopens: {
|
|
41
|
-
[__rootDir]: __rootDir,
|
|
42
|
-
},
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
return instantiateNapiModuleSync(wasmModule, {
|
|
46
|
-
childThread: true,
|
|
47
|
-
wasi,
|
|
48
|
-
context: emnapiContext,
|
|
49
|
-
overwriteImports(importObject) {
|
|
50
|
-
importObject.env = {
|
|
51
|
-
...importObject.env,
|
|
52
|
-
...importObject.napi,
|
|
53
|
-
...importObject.emnapi,
|
|
54
|
-
memory: wasmMemory
|
|
55
|
-
};
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
},
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
globalThis.onmessage = function (e) {
|
|
62
|
-
handler.handle(e);
|
|
63
|
-
};
|