@stream-mdx/worker 0.2.0 → 0.4.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 +6 -4
- package/dist/direct.cjs +3978 -0
- package/dist/direct.d.cts +50 -0
- package/dist/direct.d.ts +50 -0
- package/dist/direct.mjs +3961 -0
- package/dist/hosted/markdown-worker.js +303 -23
- package/dist/index.cjs +3954 -3
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.mjs +3960 -0
- package/dist/node/index.cjs +383 -4
- package/dist/node/index.d.cts +68 -1
- package/dist/node/index.d.ts +68 -1
- package/dist/node/index.mjs +381 -4
- package/dist/node/worker-thread-entry.cjs +127 -3
- package/dist/node/worker-thread-entry.d.cts +2 -1
- package/dist/node/worker-thread-entry.d.ts +2 -1
- package/dist/node/worker-thread-entry.mjs +106 -3
- package/dist/worker-client-wln-351a.d.cts +84 -0
- package/dist/worker-client-wln-351a.d.ts +84 -0
- package/dist/worker-client.d.cts +2 -81
- package/dist/worker-client.d.ts +2 -81
- package/package.json +8 -3
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
// src/node/worker-thread-entry.ts
|
|
2
|
-
import
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { existsSync } from "fs";
|
|
4
|
+
import { createRequire } from "module";
|
|
5
|
+
import { fileURLToPath, pathToFileURL } from "url";
|
|
3
6
|
import { parentPort, workerData } from "worker_threads";
|
|
4
7
|
var port = parentPort;
|
|
5
8
|
if (!port) {
|
|
@@ -51,7 +54,7 @@ port.on("message", (data) => {
|
|
|
51
54
|
dispatchMessage(data);
|
|
52
55
|
});
|
|
53
56
|
var bootstrap = workerData ?? {};
|
|
54
|
-
var bundleUrl = typeof bootstrap.bundleUrl === "string" && bootstrap.bundleUrl.length > 0 ? bootstrap.bundleUrl :
|
|
57
|
+
var bundleUrl = typeof bootstrap.bundleUrl === "string" && bootstrap.bundleUrl.length > 0 ? bootstrap.bundleUrl : resolveDefaultBundleUrl().href;
|
|
55
58
|
void (async () => {
|
|
56
59
|
await import(bundleUrl);
|
|
57
60
|
ready = true;
|
|
@@ -65,8 +68,108 @@ void (async () => {
|
|
|
65
68
|
throw error;
|
|
66
69
|
});
|
|
67
70
|
function getModuleUrl() {
|
|
71
|
+
const fromImportMeta = getImportMetaUrl();
|
|
72
|
+
if (fromImportMeta) {
|
|
73
|
+
return fromImportMeta;
|
|
74
|
+
}
|
|
68
75
|
if (typeof __filename === "string" && __filename.length > 0) {
|
|
69
76
|
return pathToFileURL(__filename).href;
|
|
70
77
|
}
|
|
71
|
-
|
|
78
|
+
const fromStack = getModuleUrlFromStack();
|
|
79
|
+
if (fromStack) {
|
|
80
|
+
return fromStack;
|
|
81
|
+
}
|
|
82
|
+
throw new Error("[stream-mdx] Unable to resolve worker-thread module URL.");
|
|
83
|
+
}
|
|
84
|
+
function getImportMetaUrl() {
|
|
85
|
+
try {
|
|
86
|
+
const candidate = (0, eval)("import.meta.url");
|
|
87
|
+
return typeof candidate === "string" && candidate.length > 0 ? candidate : void 0;
|
|
88
|
+
} catch {
|
|
89
|
+
return void 0;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function resolveDefaultBundleUrl() {
|
|
93
|
+
const packageRoot = resolvePackageRootFromRequire();
|
|
94
|
+
if (packageRoot) {
|
|
95
|
+
const resolved = firstExistingPath([
|
|
96
|
+
path.join(packageRoot, "dist/hosted/markdown-worker.js"),
|
|
97
|
+
path.join(packageRoot, "dist/worker.mjs"),
|
|
98
|
+
path.join(packageRoot, "dist/worker.js"),
|
|
99
|
+
path.join(packageRoot, "src/worker.ts")
|
|
100
|
+
]);
|
|
101
|
+
if (resolved) {
|
|
102
|
+
return pathToFileURL(resolved);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
const moduleUrl = getModuleUrl();
|
|
106
|
+
const candidates = [
|
|
107
|
+
new URL("../hosted/markdown-worker.js", moduleUrl),
|
|
108
|
+
new URL("../../dist/hosted/markdown-worker.js", moduleUrl),
|
|
109
|
+
new URL("../../../public/workers/markdown-worker.js", moduleUrl),
|
|
110
|
+
new URL("../../../../public/workers/markdown-worker.js", moduleUrl),
|
|
111
|
+
new URL("../../dist/worker.mjs", moduleUrl),
|
|
112
|
+
new URL("../../dist/worker.js", moduleUrl),
|
|
113
|
+
new URL("../worker.mjs", moduleUrl),
|
|
114
|
+
new URL("../worker.js", moduleUrl),
|
|
115
|
+
new URL("../worker.ts", moduleUrl)
|
|
116
|
+
];
|
|
117
|
+
for (const candidate of candidates) {
|
|
118
|
+
if (urlExists(candidate)) return candidate;
|
|
119
|
+
}
|
|
120
|
+
return candidates[0];
|
|
121
|
+
}
|
|
122
|
+
function urlExists(url) {
|
|
123
|
+
if (url.protocol !== "file:") return false;
|
|
124
|
+
try {
|
|
125
|
+
return existsSync(path.normalize(fileURLToPath(url)));
|
|
126
|
+
} catch {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function firstExistingPath(candidates) {
|
|
131
|
+
for (const candidate of candidates) {
|
|
132
|
+
try {
|
|
133
|
+
if (existsSync(candidate)) return candidate;
|
|
134
|
+
} catch {
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return void 0;
|
|
138
|
+
}
|
|
139
|
+
function resolvePackageRootFromRequire() {
|
|
140
|
+
const bases = [
|
|
141
|
+
path.join(process.cwd(), "package.json"),
|
|
142
|
+
typeof __filename === "string" && __filename.length > 0 ? __filename : path.join(process.cwd(), "__stream-mdx-worker-thread-resolver__.cjs")
|
|
143
|
+
];
|
|
144
|
+
for (const base of bases) {
|
|
145
|
+
try {
|
|
146
|
+
const req = createRequire(base);
|
|
147
|
+
const nodeEntry = req.resolve("@stream-mdx/worker/node");
|
|
148
|
+
return path.resolve(path.dirname(nodeEntry), "..", "..");
|
|
149
|
+
} catch {
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return void 0;
|
|
153
|
+
}
|
|
154
|
+
function getModuleUrlFromStack() {
|
|
155
|
+
const previous = Error.prepareStackTrace;
|
|
156
|
+
try {
|
|
157
|
+
Error.prepareStackTrace = (_error, stackTrace2) => stackTrace2;
|
|
158
|
+
const stackTrace = new Error().stack;
|
|
159
|
+
if (!Array.isArray(stackTrace)) return void 0;
|
|
160
|
+
const files = stackTrace.map((frame) => frame.getFileName()).filter((fileName) => Boolean(fileName));
|
|
161
|
+
const preferred = files.find(
|
|
162
|
+
(fileName) => fileName.includes("/markdown-v2-worker/src/node/worker-thread-entry.") || fileName.includes("/markdown-v2-worker/dist/node/worker-thread-entry.") || fileName.includes("\\markdown-v2-worker\\src\\node\\worker-thread-entry.") || fileName.includes("\\markdown-v2-worker\\dist\\node\\worker-thread-entry.")
|
|
163
|
+
);
|
|
164
|
+
if (preferred) {
|
|
165
|
+
return preferred.startsWith("file://") ? preferred : pathToFileURL(preferred).href;
|
|
166
|
+
}
|
|
167
|
+
const firstAbsolute = files.find((fileName) => fileName.startsWith("file://") || path.isAbsolute(fileName));
|
|
168
|
+
if (!firstAbsolute) return void 0;
|
|
169
|
+
return firstAbsolute.startsWith("file://") ? firstAbsolute : pathToFileURL(firstAbsolute).href;
|
|
170
|
+
} catch {
|
|
171
|
+
return void 0;
|
|
172
|
+
} finally {
|
|
173
|
+
Error.prepareStackTrace = previous;
|
|
174
|
+
}
|
|
72
175
|
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { WorkerOut, FormatAnticipationConfig, CodeHighlightingMode, CodeHighlightOutputMode } from '@stream-mdx/core';
|
|
2
|
+
|
|
3
|
+
type DefaultWorkerMode = "auto" | "hosted" | "blob";
|
|
4
|
+
interface CreateDefaultWorkerOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Selects how the helper instantiates the worker.
|
|
7
|
+
* - `auto` (default) tries to use inline source when available, then falls back to hosted URL.
|
|
8
|
+
* - `hosted` always instantiates from the provided URL.
|
|
9
|
+
* - `blob` requires `inlineSource` (or an inline `<script data-markdown-v2-worker-source>` element) and never touches the hosted URL.
|
|
10
|
+
*/
|
|
11
|
+
mode?: DefaultWorkerMode;
|
|
12
|
+
/**
|
|
13
|
+
* Hosted worker URL. Defaults to `/workers/markdown-worker.js` or whatever is declared via
|
|
14
|
+
* `<script data-markdown-v2-worker-url="...">`.
|
|
15
|
+
*/
|
|
16
|
+
url?: string | URL;
|
|
17
|
+
/**
|
|
18
|
+
* Inline worker source (module string) used when `mode` is `blob` or `auto`.
|
|
19
|
+
*/
|
|
20
|
+
inlineSource?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Override the worker name (shows up in devtools).
|
|
23
|
+
*/
|
|
24
|
+
name?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Credentials to use when instantiating a hosted worker.
|
|
27
|
+
*/
|
|
28
|
+
credentials?: WorkerOptions["credentials"];
|
|
29
|
+
}
|
|
30
|
+
declare function createDefaultWorker(options?: CreateDefaultWorkerOptions): Worker | null;
|
|
31
|
+
declare function releaseDefaultWorker(worker: Worker | null | undefined): void;
|
|
32
|
+
|
|
33
|
+
interface MarkdownWorkerClientOptions {
|
|
34
|
+
worker?: Worker | (() => Worker);
|
|
35
|
+
workerUrl?: string | URL;
|
|
36
|
+
name?: string;
|
|
37
|
+
defaultWorker?: CreateDefaultWorkerOptions;
|
|
38
|
+
}
|
|
39
|
+
declare class MarkdownWorkerClient {
|
|
40
|
+
private worker?;
|
|
41
|
+
private readonly ownsWorker;
|
|
42
|
+
private listeners;
|
|
43
|
+
private messageListener?;
|
|
44
|
+
private errorListener?;
|
|
45
|
+
private messageErrorListener?;
|
|
46
|
+
private cleanupCallbacks;
|
|
47
|
+
constructor(options?: MarkdownWorkerClientOptions);
|
|
48
|
+
private createWorkerInstance;
|
|
49
|
+
onMessage(cb: (msg: WorkerOut) => void): () => boolean;
|
|
50
|
+
init(initialContent?: string, prewarmLangs?: string[], docPlugins?: {
|
|
51
|
+
footnotes?: boolean;
|
|
52
|
+
html?: boolean;
|
|
53
|
+
mdx?: boolean;
|
|
54
|
+
tables?: boolean;
|
|
55
|
+
callouts?: boolean;
|
|
56
|
+
math?: boolean;
|
|
57
|
+
formatAnticipation?: FormatAnticipationConfig;
|
|
58
|
+
codeHighlighting?: CodeHighlightingMode;
|
|
59
|
+
outputMode?: CodeHighlightOutputMode;
|
|
60
|
+
liveCodeHighlighting?: boolean;
|
|
61
|
+
liveTokenization?: boolean;
|
|
62
|
+
emitHighlightTokens?: boolean;
|
|
63
|
+
emitDiffBlocks?: boolean;
|
|
64
|
+
mdxComponentNames?: string[];
|
|
65
|
+
lazyTokenization?: {
|
|
66
|
+
enabled?: boolean;
|
|
67
|
+
thresholdLines?: number;
|
|
68
|
+
};
|
|
69
|
+
}, mdxOptions?: {
|
|
70
|
+
compileMode?: "server" | "worker";
|
|
71
|
+
}): void;
|
|
72
|
+
append(text: string): void;
|
|
73
|
+
finalize(): void;
|
|
74
|
+
setCredits(credits: number): void;
|
|
75
|
+
setMdxCompiled(blockId: string, compiledId: string): void;
|
|
76
|
+
setMdxError(blockId: string, error?: string): void;
|
|
77
|
+
terminate(options?: {
|
|
78
|
+
force?: boolean;
|
|
79
|
+
}): void;
|
|
80
|
+
getWorker(): Worker | undefined;
|
|
81
|
+
private post;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export { type CreateDefaultWorkerOptions as C, type DefaultWorkerMode as D, type MarkdownWorkerClientOptions as M, MarkdownWorkerClient as a, createDefaultWorker as c, releaseDefaultWorker as r };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { WorkerOut, FormatAnticipationConfig, CodeHighlightingMode, CodeHighlightOutputMode } from '@stream-mdx/core';
|
|
2
|
+
|
|
3
|
+
type DefaultWorkerMode = "auto" | "hosted" | "blob";
|
|
4
|
+
interface CreateDefaultWorkerOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Selects how the helper instantiates the worker.
|
|
7
|
+
* - `auto` (default) tries to use inline source when available, then falls back to hosted URL.
|
|
8
|
+
* - `hosted` always instantiates from the provided URL.
|
|
9
|
+
* - `blob` requires `inlineSource` (or an inline `<script data-markdown-v2-worker-source>` element) and never touches the hosted URL.
|
|
10
|
+
*/
|
|
11
|
+
mode?: DefaultWorkerMode;
|
|
12
|
+
/**
|
|
13
|
+
* Hosted worker URL. Defaults to `/workers/markdown-worker.js` or whatever is declared via
|
|
14
|
+
* `<script data-markdown-v2-worker-url="...">`.
|
|
15
|
+
*/
|
|
16
|
+
url?: string | URL;
|
|
17
|
+
/**
|
|
18
|
+
* Inline worker source (module string) used when `mode` is `blob` or `auto`.
|
|
19
|
+
*/
|
|
20
|
+
inlineSource?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Override the worker name (shows up in devtools).
|
|
23
|
+
*/
|
|
24
|
+
name?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Credentials to use when instantiating a hosted worker.
|
|
27
|
+
*/
|
|
28
|
+
credentials?: WorkerOptions["credentials"];
|
|
29
|
+
}
|
|
30
|
+
declare function createDefaultWorker(options?: CreateDefaultWorkerOptions): Worker | null;
|
|
31
|
+
declare function releaseDefaultWorker(worker: Worker | null | undefined): void;
|
|
32
|
+
|
|
33
|
+
interface MarkdownWorkerClientOptions {
|
|
34
|
+
worker?: Worker | (() => Worker);
|
|
35
|
+
workerUrl?: string | URL;
|
|
36
|
+
name?: string;
|
|
37
|
+
defaultWorker?: CreateDefaultWorkerOptions;
|
|
38
|
+
}
|
|
39
|
+
declare class MarkdownWorkerClient {
|
|
40
|
+
private worker?;
|
|
41
|
+
private readonly ownsWorker;
|
|
42
|
+
private listeners;
|
|
43
|
+
private messageListener?;
|
|
44
|
+
private errorListener?;
|
|
45
|
+
private messageErrorListener?;
|
|
46
|
+
private cleanupCallbacks;
|
|
47
|
+
constructor(options?: MarkdownWorkerClientOptions);
|
|
48
|
+
private createWorkerInstance;
|
|
49
|
+
onMessage(cb: (msg: WorkerOut) => void): () => boolean;
|
|
50
|
+
init(initialContent?: string, prewarmLangs?: string[], docPlugins?: {
|
|
51
|
+
footnotes?: boolean;
|
|
52
|
+
html?: boolean;
|
|
53
|
+
mdx?: boolean;
|
|
54
|
+
tables?: boolean;
|
|
55
|
+
callouts?: boolean;
|
|
56
|
+
math?: boolean;
|
|
57
|
+
formatAnticipation?: FormatAnticipationConfig;
|
|
58
|
+
codeHighlighting?: CodeHighlightingMode;
|
|
59
|
+
outputMode?: CodeHighlightOutputMode;
|
|
60
|
+
liveCodeHighlighting?: boolean;
|
|
61
|
+
liveTokenization?: boolean;
|
|
62
|
+
emitHighlightTokens?: boolean;
|
|
63
|
+
emitDiffBlocks?: boolean;
|
|
64
|
+
mdxComponentNames?: string[];
|
|
65
|
+
lazyTokenization?: {
|
|
66
|
+
enabled?: boolean;
|
|
67
|
+
thresholdLines?: number;
|
|
68
|
+
};
|
|
69
|
+
}, mdxOptions?: {
|
|
70
|
+
compileMode?: "server" | "worker";
|
|
71
|
+
}): void;
|
|
72
|
+
append(text: string): void;
|
|
73
|
+
finalize(): void;
|
|
74
|
+
setCredits(credits: number): void;
|
|
75
|
+
setMdxCompiled(blockId: string, compiledId: string): void;
|
|
76
|
+
setMdxError(blockId: string, error?: string): void;
|
|
77
|
+
terminate(options?: {
|
|
78
|
+
force?: boolean;
|
|
79
|
+
}): void;
|
|
80
|
+
getWorker(): Worker | undefined;
|
|
81
|
+
private post;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export { type CreateDefaultWorkerOptions as C, type DefaultWorkerMode as D, type MarkdownWorkerClientOptions as M, MarkdownWorkerClient as a, createDefaultWorker as c, releaseDefaultWorker as r };
|
package/dist/worker-client.d.cts
CHANGED
|
@@ -1,81 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
type DefaultWorkerMode = "auto" | "hosted" | "blob";
|
|
4
|
-
interface CreateDefaultWorkerOptions {
|
|
5
|
-
/**
|
|
6
|
-
* Selects how the helper instantiates the worker.
|
|
7
|
-
* - `auto` (default) tries to use inline source when available, then falls back to hosted URL.
|
|
8
|
-
* - `hosted` always instantiates from the provided URL.
|
|
9
|
-
* - `blob` requires `inlineSource` (or an inline `<script data-markdown-v2-worker-source>` element) and never touches the hosted URL.
|
|
10
|
-
*/
|
|
11
|
-
mode?: DefaultWorkerMode;
|
|
12
|
-
/**
|
|
13
|
-
* Hosted worker URL. Defaults to `/workers/markdown-worker.js` or whatever is declared via
|
|
14
|
-
* `<script data-markdown-v2-worker-url="...">`.
|
|
15
|
-
*/
|
|
16
|
-
url?: string | URL;
|
|
17
|
-
/**
|
|
18
|
-
* Inline worker source (module string) used when `mode` is `blob` or `auto`.
|
|
19
|
-
*/
|
|
20
|
-
inlineSource?: string;
|
|
21
|
-
/**
|
|
22
|
-
* Override the worker name (shows up in devtools).
|
|
23
|
-
*/
|
|
24
|
-
name?: string;
|
|
25
|
-
/**
|
|
26
|
-
* Credentials to use when instantiating a hosted worker.
|
|
27
|
-
*/
|
|
28
|
-
credentials?: WorkerOptions["credentials"];
|
|
29
|
-
}
|
|
30
|
-
declare function createDefaultWorker(options?: CreateDefaultWorkerOptions): Worker | null;
|
|
31
|
-
declare function releaseDefaultWorker(worker: Worker | null | undefined): void;
|
|
32
|
-
|
|
33
|
-
interface MarkdownWorkerClientOptions {
|
|
34
|
-
worker?: Worker | (() => Worker);
|
|
35
|
-
workerUrl?: string | URL;
|
|
36
|
-
name?: string;
|
|
37
|
-
defaultWorker?: CreateDefaultWorkerOptions;
|
|
38
|
-
}
|
|
39
|
-
declare class MarkdownWorkerClient {
|
|
40
|
-
private worker?;
|
|
41
|
-
private readonly ownsWorker;
|
|
42
|
-
private listeners;
|
|
43
|
-
private messageListener?;
|
|
44
|
-
private errorListener?;
|
|
45
|
-
private messageErrorListener?;
|
|
46
|
-
private cleanupCallbacks;
|
|
47
|
-
constructor(options?: MarkdownWorkerClientOptions);
|
|
48
|
-
private createWorkerInstance;
|
|
49
|
-
onMessage(cb: (msg: WorkerOut) => void): () => boolean;
|
|
50
|
-
init(initialContent?: string, prewarmLangs?: string[], docPlugins?: {
|
|
51
|
-
footnotes?: boolean;
|
|
52
|
-
html?: boolean;
|
|
53
|
-
mdx?: boolean;
|
|
54
|
-
tables?: boolean;
|
|
55
|
-
callouts?: boolean;
|
|
56
|
-
math?: boolean;
|
|
57
|
-
formatAnticipation?: FormatAnticipationConfig;
|
|
58
|
-
codeHighlighting?: CodeHighlightingMode;
|
|
59
|
-
outputMode?: CodeHighlightOutputMode;
|
|
60
|
-
liveCodeHighlighting?: boolean;
|
|
61
|
-
mdxComponentNames?: string[];
|
|
62
|
-
lazyTokenization?: {
|
|
63
|
-
enabled?: boolean;
|
|
64
|
-
thresholdLines?: number;
|
|
65
|
-
};
|
|
66
|
-
}, mdxOptions?: {
|
|
67
|
-
compileMode?: "server" | "worker";
|
|
68
|
-
}): void;
|
|
69
|
-
append(text: string): void;
|
|
70
|
-
finalize(): void;
|
|
71
|
-
setCredits(credits: number): void;
|
|
72
|
-
setMdxCompiled(blockId: string, compiledId: string): void;
|
|
73
|
-
setMdxError(blockId: string, error?: string): void;
|
|
74
|
-
terminate(options?: {
|
|
75
|
-
force?: boolean;
|
|
76
|
-
}): void;
|
|
77
|
-
getWorker(): Worker | undefined;
|
|
78
|
-
private post;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export { type CreateDefaultWorkerOptions as C, type DefaultWorkerMode as D, MarkdownWorkerClient, type MarkdownWorkerClientOptions, createDefaultWorker as c, releaseDefaultWorker as r };
|
|
1
|
+
import '@stream-mdx/core';
|
|
2
|
+
export { a as MarkdownWorkerClient, M as MarkdownWorkerClientOptions } from './worker-client-wln-351a.cjs';
|
package/dist/worker-client.d.ts
CHANGED
|
@@ -1,81 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
type DefaultWorkerMode = "auto" | "hosted" | "blob";
|
|
4
|
-
interface CreateDefaultWorkerOptions {
|
|
5
|
-
/**
|
|
6
|
-
* Selects how the helper instantiates the worker.
|
|
7
|
-
* - `auto` (default) tries to use inline source when available, then falls back to hosted URL.
|
|
8
|
-
* - `hosted` always instantiates from the provided URL.
|
|
9
|
-
* - `blob` requires `inlineSource` (or an inline `<script data-markdown-v2-worker-source>` element) and never touches the hosted URL.
|
|
10
|
-
*/
|
|
11
|
-
mode?: DefaultWorkerMode;
|
|
12
|
-
/**
|
|
13
|
-
* Hosted worker URL. Defaults to `/workers/markdown-worker.js` or whatever is declared via
|
|
14
|
-
* `<script data-markdown-v2-worker-url="...">`.
|
|
15
|
-
*/
|
|
16
|
-
url?: string | URL;
|
|
17
|
-
/**
|
|
18
|
-
* Inline worker source (module string) used when `mode` is `blob` or `auto`.
|
|
19
|
-
*/
|
|
20
|
-
inlineSource?: string;
|
|
21
|
-
/**
|
|
22
|
-
* Override the worker name (shows up in devtools).
|
|
23
|
-
*/
|
|
24
|
-
name?: string;
|
|
25
|
-
/**
|
|
26
|
-
* Credentials to use when instantiating a hosted worker.
|
|
27
|
-
*/
|
|
28
|
-
credentials?: WorkerOptions["credentials"];
|
|
29
|
-
}
|
|
30
|
-
declare function createDefaultWorker(options?: CreateDefaultWorkerOptions): Worker | null;
|
|
31
|
-
declare function releaseDefaultWorker(worker: Worker | null | undefined): void;
|
|
32
|
-
|
|
33
|
-
interface MarkdownWorkerClientOptions {
|
|
34
|
-
worker?: Worker | (() => Worker);
|
|
35
|
-
workerUrl?: string | URL;
|
|
36
|
-
name?: string;
|
|
37
|
-
defaultWorker?: CreateDefaultWorkerOptions;
|
|
38
|
-
}
|
|
39
|
-
declare class MarkdownWorkerClient {
|
|
40
|
-
private worker?;
|
|
41
|
-
private readonly ownsWorker;
|
|
42
|
-
private listeners;
|
|
43
|
-
private messageListener?;
|
|
44
|
-
private errorListener?;
|
|
45
|
-
private messageErrorListener?;
|
|
46
|
-
private cleanupCallbacks;
|
|
47
|
-
constructor(options?: MarkdownWorkerClientOptions);
|
|
48
|
-
private createWorkerInstance;
|
|
49
|
-
onMessage(cb: (msg: WorkerOut) => void): () => boolean;
|
|
50
|
-
init(initialContent?: string, prewarmLangs?: string[], docPlugins?: {
|
|
51
|
-
footnotes?: boolean;
|
|
52
|
-
html?: boolean;
|
|
53
|
-
mdx?: boolean;
|
|
54
|
-
tables?: boolean;
|
|
55
|
-
callouts?: boolean;
|
|
56
|
-
math?: boolean;
|
|
57
|
-
formatAnticipation?: FormatAnticipationConfig;
|
|
58
|
-
codeHighlighting?: CodeHighlightingMode;
|
|
59
|
-
outputMode?: CodeHighlightOutputMode;
|
|
60
|
-
liveCodeHighlighting?: boolean;
|
|
61
|
-
mdxComponentNames?: string[];
|
|
62
|
-
lazyTokenization?: {
|
|
63
|
-
enabled?: boolean;
|
|
64
|
-
thresholdLines?: number;
|
|
65
|
-
};
|
|
66
|
-
}, mdxOptions?: {
|
|
67
|
-
compileMode?: "server" | "worker";
|
|
68
|
-
}): void;
|
|
69
|
-
append(text: string): void;
|
|
70
|
-
finalize(): void;
|
|
71
|
-
setCredits(credits: number): void;
|
|
72
|
-
setMdxCompiled(blockId: string, compiledId: string): void;
|
|
73
|
-
setMdxError(blockId: string, error?: string): void;
|
|
74
|
-
terminate(options?: {
|
|
75
|
-
force?: boolean;
|
|
76
|
-
}): void;
|
|
77
|
-
getWorker(): Worker | undefined;
|
|
78
|
-
private post;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export { type CreateDefaultWorkerOptions as C, type DefaultWorkerMode as D, MarkdownWorkerClient, type MarkdownWorkerClientOptions, createDefaultWorker as c, releaseDefaultWorker as r };
|
|
1
|
+
import '@stream-mdx/core';
|
|
2
|
+
export { a as MarkdownWorkerClient, M as MarkdownWorkerClientOptions } from './worker-client-wln-351a.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stream-mdx/worker",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Worker client utilities and shared worker helpers for the Streaming Markdown V2 pipeline",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -26,6 +26,11 @@
|
|
|
26
26
|
"import": "./dist/worker-client.mjs",
|
|
27
27
|
"require": "./dist/worker-client.cjs"
|
|
28
28
|
},
|
|
29
|
+
"./direct": {
|
|
30
|
+
"types": "./dist/direct.d.ts",
|
|
31
|
+
"import": "./dist/direct.mjs",
|
|
32
|
+
"require": "./dist/direct.cjs"
|
|
33
|
+
},
|
|
29
34
|
"./mdx-compile": {
|
|
30
35
|
"types": "./dist/mdx-compile.d.ts",
|
|
31
36
|
"import": "./dist/mdx-compile.mjs",
|
|
@@ -63,8 +68,8 @@
|
|
|
63
68
|
"@lezer/common": "^1.2.3",
|
|
64
69
|
"@lezer/lr": "^1.4.2",
|
|
65
70
|
"@lezer/markdown": "^1.3.0",
|
|
66
|
-
"@stream-mdx/core": "0.
|
|
67
|
-
"@stream-mdx/plugins": "0.
|
|
71
|
+
"@stream-mdx/core": "0.4.0",
|
|
72
|
+
"@stream-mdx/plugins": "0.4.0",
|
|
68
73
|
"@mdx-js/mdx": "^3.1.0",
|
|
69
74
|
"@shikijs/engine-javascript": "^1.29.2",
|
|
70
75
|
"@shikijs/engine-oniguruma": "^1.29.2",
|