@stream-mdx/worker 0.0.1 → 0.0.3
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/CHANGELOG.md +30 -0
- package/README.md +28 -36
- package/dist/hosted/markdown-worker.js +81868 -394
- package/dist/index.cjs +0 -1
- package/dist/index.mjs +0 -1
- package/dist/mdx-compile.cjs +81 -0
- package/dist/mdx-compile.d.cts +13 -0
- package/dist/mdx-compile.d.ts +13 -0
- package/dist/mdx-compile.mjs +46 -0
- package/dist/node/index.cjs +75 -0
- package/dist/node/index.d.cts +29 -0
- package/dist/node/index.d.ts +29 -0
- package/dist/node/index.mjs +38 -0
- package/dist/node/worker-thread-entry.cjs +75 -0
- package/dist/node/worker-thread-entry.d.cts +1 -0
- package/dist/node/worker-thread-entry.d.ts +1 -0
- package/dist/node/worker-thread-entry.mjs +72 -0
- package/dist/streaming/custom-matcher.cjs +0 -1
- package/dist/streaming/custom-matcher.mjs +0 -1
- package/dist/worker-client.cjs +0 -1
- package/dist/worker-client.d.cts +3 -0
- package/dist/worker-client.d.ts +3 -0
- package/dist/worker-client.mjs +0 -1
- package/package.json +19 -5
- package/dist/hosted/markdown-worker.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/streaming/custom-matcher.cjs.map +0 -1
- package/dist/streaming/custom-matcher.mjs.map +0 -1
- package/dist/worker-client.cjs.map +0 -1
- package/dist/worker-client.mjs.map +0 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# @stream-mdx/worker
|
|
2
|
+
|
|
3
|
+
## 0.0.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 47d1374: Add opt-in streaming format anticipation and an optional Mermaid diagram addon for ` ```mermaid ` code blocks.
|
|
8
|
+
- 7c79f09: Port the docs demo page to match the ql-homepage streaming UI, and fix several streaming parser/rendering edge cases (hard line breaks and display-math handling) while keeping the hosted worker bundle self-contained for static hosting.
|
|
9
|
+
- Updated dependencies [47d1374]
|
|
10
|
+
- Updated dependencies [7c79f09]
|
|
11
|
+
- @stream-mdx/core@0.0.3
|
|
12
|
+
- @stream-mdx/plugins@0.0.3
|
|
13
|
+
|
|
14
|
+
## 0.0.2
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- 9e94660: Docs and release-quality improvements: ship package READMEs/CHANGELOGs, add pack+install smoke tests, expose MDX parity helper entrypoints, and add a deployable docs site workflow.
|
|
19
|
+
- Updated dependencies [9e94660]
|
|
20
|
+
- @stream-mdx/core@0.0.2
|
|
21
|
+
- @stream-mdx/plugins@0.0.2
|
|
22
|
+
|
|
23
|
+
## 0.0.1
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- Release maintenance: CI/build fixes, missing runtime deps (e.g. `rehype-katex`), and improved docs/README wiring for the `stream-mdx` package page.
|
|
28
|
+
- Updated dependencies
|
|
29
|
+
- @stream-mdx/core@0.0.1
|
|
30
|
+
- @stream-mdx/plugins@0.0.1
|
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# `@stream-mdx/worker`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Worker client utilities and hosted worker bundle used by StreamMDX.
|
|
4
|
+
|
|
5
|
+
Most consumers interact with this package indirectly via `<StreamingMarkdown />`. You only need `@stream-mdx/worker` directly if you want explicit control over worker instantiation, MDX compilation parity helpers, or strict CSP setups.
|
|
4
6
|
|
|
5
7
|
## Install
|
|
6
8
|
|
|
@@ -8,53 +10,43 @@ Web Worker entry point for the streaming renderer. Handles markdown parsing (Lez
|
|
|
8
10
|
npm install @stream-mdx/worker
|
|
9
11
|
```
|
|
10
12
|
|
|
11
|
-
##
|
|
13
|
+
## Hosted worker bundle (recommended)
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
import { MarkdownWorkerClient } from "@stream-mdx/worker";
|
|
15
|
+
For production, host the worker bundle from static assets (avoids `blob:` CSP requirements):
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
```bash
|
|
18
|
+
mkdir -p public/workers
|
|
19
|
+
cp node_modules/@stream-mdx/worker/dist/hosted/markdown-worker.js public/workers/markdown-worker.js
|
|
20
|
+
```
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
if (msg.type === "PATCH") {
|
|
23
|
-
// apply patches
|
|
24
|
-
}
|
|
25
|
-
});
|
|
22
|
+
Then point StreamMDX at it:
|
|
26
23
|
|
|
27
|
-
|
|
24
|
+
```tsx
|
|
25
|
+
<StreamingMarkdown worker="/workers/markdown-worker.js" />
|
|
28
26
|
```
|
|
29
27
|
|
|
30
|
-
|
|
28
|
+
## Node / CLI worker threads
|
|
31
29
|
|
|
32
|
-
|
|
30
|
+
To run the hosted worker bundle in Node (e.g., Ink TUIs), use:
|
|
33
31
|
|
|
34
|
-
|
|
32
|
+
```ts
|
|
33
|
+
import { createWorkerThread } from "@stream-mdx/worker/node";
|
|
34
|
+
```
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
| --- | --- | --- |
|
|
38
|
-
| `INIT` | Main → Worker | `{ text?: string; stream?: boolean; prewarmLangs?: string[]; plugins?: PluginConfig }` |
|
|
39
|
-
| `APPEND` | Main → Worker | `{ chunk: string }` |
|
|
40
|
-
| `FINALIZE` | Main → Worker | Flush + emit remaining patches. |
|
|
41
|
-
| `RESET` | Main → Worker | Clear state (used on restart). |
|
|
42
|
-
| `PATCH` | Worker → Main | `{ tx, at, patches: Patch[], notes }` |
|
|
43
|
-
| `METRICS` | Worker → Main | Parse/highlight timings, block stats. |
|
|
44
|
-
| `INITIALIZED`, `ERROR`, `DEBUG` | Worker → Main | Lifecycle events. |
|
|
36
|
+
This spawns a `worker_threads` worker and installs WebWorker-like shims so the hosted bundle can run under Node.
|
|
45
37
|
|
|
46
|
-
|
|
38
|
+
## MDX compilation parity helper
|
|
47
39
|
|
|
48
|
-
|
|
40
|
+
If you compile MDX on the server (e.g. Next.js API route), use the same compilation logic as the worker:
|
|
49
41
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
42
|
+
```ts
|
|
43
|
+
import { compileMdxContent } from "@stream-mdx/worker/mdx-compile";
|
|
44
|
+
```
|
|
53
45
|
|
|
54
|
-
|
|
46
|
+
See `docs/REACT_INTEGRATION_GUIDE.md` for the full wiring and parity notes.
|
|
55
47
|
|
|
56
|
-
##
|
|
48
|
+
## Docs
|
|
57
49
|
|
|
58
|
-
-
|
|
59
|
-
-
|
|
60
|
-
-
|
|
50
|
+
- React integration guide: `docs/REACT_INTEGRATION_GUIDE.md`
|
|
51
|
+
- Security model / CSP: `docs/SECURITY_MODEL.md`
|
|
52
|
+
- Plugins & custom worker bundles: `docs/STREAMING_MARKDOWN_PLUGINS_COOKBOOK.md`
|