@aparte/plugin-streaming-markdown 0.7.1 → 0.9.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/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +3 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type AparteConfig } from '@aparte/core';
|
|
1
2
|
/**
|
|
2
3
|
* Register `streaming-markdown` as aparté's incremental (streaming) Markdown
|
|
3
4
|
* renderer.
|
|
@@ -11,7 +12,7 @@
|
|
|
11
12
|
* Framework-agnostic — vanilla DOM, no framework imports.
|
|
12
13
|
*
|
|
13
14
|
* **Security**: the streaming path writes DOM nodes directly and therefore
|
|
14
|
-
* bypasses the one-shot `
|
|
15
|
+
* bypasses the one-shot `aparteGlobalConfig.sanitizeHtml`. To keep the same URL policy
|
|
15
16
|
* live (an attacker-controlled `[x](javascript:…)` streamed token would produce
|
|
16
17
|
* a clickable `javascript:` link before the final re-render sanitises it), the
|
|
17
18
|
* renderer's `set_attr` is wrapped to drop any `href`/`src` whose scheme fails
|
|
@@ -20,5 +21,5 @@
|
|
|
20
21
|
*
|
|
21
22
|
* Call once at application startup.
|
|
22
23
|
*/
|
|
23
|
-
export declare function setupStreamingMarkdownProvider(): void;
|
|
24
|
+
export declare function setupStreamingMarkdownProvider(config?: AparteConfig): void;
|
|
24
25
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,KAAK,YAAY,EAAC,MAAM,cAAc,CAAC;AAGhF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,8BAA8B,CAAC,MAAM,GAAE,YAAiC,GAAG,IAAI,CAe9F"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { aparteGlobalConfig, isSafeUrl } from "@aparte/core";
|
|
2
2
|
import { default_renderer, HREF, SRC, parser, parser_end, parser_write } from "streaming-markdown";
|
|
3
|
-
function setupStreamingMarkdownProvider() {
|
|
4
|
-
|
|
3
|
+
function setupStreamingMarkdownProvider(config = aparteGlobalConfig) {
|
|
4
|
+
config.setStreamingMarkdownProvider((target) => {
|
|
5
5
|
const renderer = default_renderer(target);
|
|
6
6
|
const originalSetAttr = renderer.set_attr;
|
|
7
7
|
renderer.set_attr = (data, type, value) => {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { aparteGlobalConfig, isSafeUrl , type AparteConfig} from '@aparte/core';\nimport { parser, parser_write, parser_end, default_renderer, HREF, SRC } from 'streaming-markdown';\n\n/**\n * Register `streaming-markdown` as aparté's incremental (streaming) Markdown\n * renderer.\n *\n * Once registered, the chat bubble feeds each streamed token chunk to a\n * persistent incremental parser that parses only the new text and APPENDS DOM\n * nodes — O(n) over the whole message, with no per-token re-parse or\n * `innerHTML` rebuild. Finished / re-rendered messages still go through the\n * one-shot `setMarkdownProvider` (e.g. `@aparte/plugin-marked`).\n *\n * Framework-agnostic — vanilla DOM, no framework imports.\n *\n * **Security**: the streaming path writes DOM nodes directly and therefore\n * bypasses the one-shot `aparteGlobalConfig.sanitizeHtml`. To keep the same URL policy\n * live (an attacker-controlled `[x](javascript:…)` streamed token would produce\n * a clickable `javascript:` link before the final re-render sanitises it), the\n * renderer's `set_attr` is wrapped to drop any `href`/`src` whose scheme fails\n * {@link isSafeUrl}. The one-shot re-render at `end()` remains the full-fidelity\n * re-sanitisation.\n *\n * Call once at application startup.\n */\nexport function setupStreamingMarkdownProvider(config: AparteConfig = aparteGlobalConfig): void {\n config.setStreamingMarkdownProvider((target: HTMLElement) => {\n const renderer = default_renderer(target);\n const originalSetAttr = renderer.set_attr;\n renderer.set_attr = (data, type, value) => {\n if (type === HREF && !isSafeUrl(value, 'a')) return;\n if (type === SRC && !isSafeUrl(value, 'img')) return;\n originalSetAttr(data, type, value);\n };\n const p = parser(renderer);\n return {\n write: (chunk: string): void => { parser_write(p, chunk); },\n end: (): void => { parser_end(p); },\n };\n });\n}\n"],"names":[],"mappings":";;AAyBO,SAAS,+BAA+B,SAAuB,oBAA0B;AAC5F,SAAO,6BAA6B,CAAC,WAAwB;AACzD,UAAM,WAAW,iBAAiB,MAAM;AACxC,UAAM,kBAAkB,SAAS;AACjC,aAAS,WAAW,CAAC,MAAM,MAAM,UAAU;AACvC,UAAI,SAAS,QAAQ,CAAC,UAAU,OAAO,GAAG,EAAG;AAC7C,UAAI,SAAS,OAAO,CAAC,UAAU,OAAO,KAAK,EAAG;AAC9C,sBAAgB,MAAM,MAAM,KAAK;AAAA,IACrC;AACA,UAAM,IAAI,OAAO,QAAQ;AACzB,WAAO;AAAA,MACH,OAAO,CAAC,UAAwB;AAAE,qBAAa,GAAG,KAAK;AAAA,MAAG;AAAA,MAC1D,KAAK,MAAY;AAAE,mBAAW,CAAC;AAAA,MAAG;AAAA,IAAA;AAAA,EAE1C,CAAC;AACL;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aparte/plugin-streaming-markdown",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Incremental (token-by-token) Markdown rendering for aparté via streaming-markdown, with a live URL-scheme guard.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -24,15 +24,14 @@
|
|
|
24
24
|
"node": ">=18"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"@aparte/core": ">=0.
|
|
27
|
+
"@aparte/core": ">=0.7.0 <1.0.0",
|
|
28
28
|
"streaming-markdown": "^0.2.15"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"streaming-markdown": "^0.2.15",
|
|
32
32
|
"typescript": "^5.4.0",
|
|
33
33
|
"vite": "^6.0.0",
|
|
34
|
-
"
|
|
35
|
-
"@aparte/core": "0.7.1"
|
|
34
|
+
"@aparte/core": "0.9.0"
|
|
36
35
|
},
|
|
37
36
|
"keywords": [
|
|
38
37
|
"aparte",
|