@stream-mdx/worker 0.0.0 → 0.0.1
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/hosted/markdown-worker.js +23 -16832
- package/dist/hosted/markdown-worker.js.map +1 -1
- package/dist/streaming/custom-matcher.cjs +3 -118
- package/dist/streaming/custom-matcher.cjs.map +1 -1
- package/dist/streaming/custom-matcher.d.cts +1 -54
- package/dist/streaming/custom-matcher.d.ts +1 -54
- package/dist/streaming/custom-matcher.mjs +1 -113
- package/dist/streaming/custom-matcher.mjs.map +1 -1
- package/package.json +11 -5
|
@@ -3,10 +3,6 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
6
|
var __copyProps = (to, from, except, desc) => {
|
|
11
7
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
8
|
for (let key of __getOwnPropNames(from))
|
|
@@ -15,126 +11,15 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
11
|
}
|
|
16
12
|
return to;
|
|
17
13
|
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
15
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
16
|
|
|
20
17
|
// src/streaming/custom-matcher.ts
|
|
21
18
|
var custom_matcher_exports = {};
|
|
22
|
-
__export(custom_matcher_exports, {
|
|
23
|
-
CustomStreamingMatcher: () => CustomStreamingMatcher
|
|
24
|
-
});
|
|
25
19
|
module.exports = __toCommonJS(custom_matcher_exports);
|
|
26
|
-
|
|
27
|
-
constructor(pattern) {
|
|
28
|
-
this.buffer = "";
|
|
29
|
-
this.possibleMatches = [];
|
|
30
|
-
this.pattern = pattern;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Add character to buffer and check for matches
|
|
34
|
-
*/
|
|
35
|
-
addCharacter(char) {
|
|
36
|
-
this.buffer += char;
|
|
37
|
-
const fullMatch = this.buffer.match(this.pattern);
|
|
38
|
-
if (fullMatch && fullMatch.index === 0) {
|
|
39
|
-
const match = {
|
|
40
|
-
matched: true,
|
|
41
|
-
content: fullMatch[0],
|
|
42
|
-
length: fullMatch[0].length,
|
|
43
|
-
isComplete: true
|
|
44
|
-
};
|
|
45
|
-
this.buffer = this.buffer.slice(fullMatch[0].length);
|
|
46
|
-
this.possibleMatches = [];
|
|
47
|
-
return match;
|
|
48
|
-
}
|
|
49
|
-
const confidence = this.calculatePartialConfidence();
|
|
50
|
-
return {
|
|
51
|
-
matched: false,
|
|
52
|
-
content: this.buffer,
|
|
53
|
-
length: this.buffer.length,
|
|
54
|
-
isComplete: false,
|
|
55
|
-
confidence
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Add string to buffer and check for matches
|
|
60
|
-
*/
|
|
61
|
-
addString(str) {
|
|
62
|
-
const results = [];
|
|
63
|
-
for (const char of str) {
|
|
64
|
-
const result = this.addCharacter(char);
|
|
65
|
-
if (result.matched) {
|
|
66
|
-
results.push(result);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
if (results.length === 0 && this.buffer.length > 0) {
|
|
70
|
-
results.push({
|
|
71
|
-
matched: false,
|
|
72
|
-
content: this.buffer,
|
|
73
|
-
length: this.buffer.length,
|
|
74
|
-
isComplete: false,
|
|
75
|
-
confidence: this.calculatePartialConfidence()
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
return results;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Check if current buffer could lead to a match
|
|
82
|
-
*/
|
|
83
|
-
couldMatch() {
|
|
84
|
-
if (this.buffer.length === 0) return true;
|
|
85
|
-
const patternSource = this.pattern.source;
|
|
86
|
-
const flags = this.pattern.flags;
|
|
87
|
-
try {
|
|
88
|
-
const partialPattern = new RegExp(`^${patternSource.replace(/\$$/, "")}`, flags);
|
|
89
|
-
const testString = this.buffer + "X".repeat(100);
|
|
90
|
-
return partialPattern.test(testString);
|
|
91
|
-
} catch {
|
|
92
|
-
return this.isValidPrefix();
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Reset the matcher
|
|
97
|
-
*/
|
|
98
|
-
reset() {
|
|
99
|
-
this.buffer = "";
|
|
100
|
-
this.possibleMatches = [];
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Get current buffer content
|
|
104
|
-
*/
|
|
105
|
-
getBuffer() {
|
|
106
|
-
return this.buffer;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Calculate confidence for partial matches
|
|
110
|
-
*/
|
|
111
|
-
calculatePartialConfidence() {
|
|
112
|
-
if (this.buffer.length === 0) return 0;
|
|
113
|
-
let confidence = 0.1;
|
|
114
|
-
confidence += Math.min(0.4, this.buffer.length * 0.1);
|
|
115
|
-
if (this.couldMatch()) {
|
|
116
|
-
confidence += 0.3;
|
|
117
|
-
}
|
|
118
|
-
if (this.buffer.startsWith("$")) confidence += 0.2;
|
|
119
|
-
if (this.buffer.startsWith("$$")) confidence += 0.3;
|
|
120
|
-
return Math.min(1, confidence);
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Check if current buffer is a valid prefix
|
|
124
|
-
*/
|
|
125
|
-
isValidPrefix() {
|
|
126
|
-
const patternStr = this.pattern.source;
|
|
127
|
-
if (patternStr.includes("\\$\\$") && (this.buffer === "$" || this.buffer === "$$")) {
|
|
128
|
-
return true;
|
|
129
|
-
}
|
|
130
|
-
if (patternStr.includes("\\$") && this.buffer === "$") {
|
|
131
|
-
return true;
|
|
132
|
-
}
|
|
133
|
-
return false;
|
|
134
|
-
}
|
|
135
|
-
};
|
|
20
|
+
__reExport(custom_matcher_exports, require("@stream-mdx/core/streaming/custom-matcher"), module.exports);
|
|
136
21
|
// Annotate the CommonJS export names for ESM import in node:
|
|
137
22
|
0 && (module.exports = {
|
|
138
|
-
|
|
23
|
+
...require("@stream-mdx/core/streaming/custom-matcher")
|
|
139
24
|
});
|
|
140
25
|
//# sourceMappingURL=custom-matcher.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/streaming/custom-matcher.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../src/streaming/custom-matcher.ts"],"sourcesContent":["export * from \"@stream-mdx/core/streaming/custom-matcher\";\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,mCAAc,sDAAd;","names":[]}
|
|
@@ -1,54 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Custom streaming pattern matcher
|
|
3
|
-
*/
|
|
4
|
-
declare class CustomStreamingMatcher {
|
|
5
|
-
private pattern;
|
|
6
|
-
private buffer;
|
|
7
|
-
private possibleMatches;
|
|
8
|
-
constructor(pattern: RegExp);
|
|
9
|
-
/**
|
|
10
|
-
* Add character to buffer and check for matches
|
|
11
|
-
*/
|
|
12
|
-
addCharacter(char: string): MatchResult;
|
|
13
|
-
/**
|
|
14
|
-
* Add string to buffer and check for matches
|
|
15
|
-
*/
|
|
16
|
-
addString(str: string): MatchResult[];
|
|
17
|
-
/**
|
|
18
|
-
* Check if current buffer could lead to a match
|
|
19
|
-
*/
|
|
20
|
-
couldMatch(): boolean;
|
|
21
|
-
/**
|
|
22
|
-
* Reset the matcher
|
|
23
|
-
*/
|
|
24
|
-
reset(): void;
|
|
25
|
-
/**
|
|
26
|
-
* Get current buffer content
|
|
27
|
-
*/
|
|
28
|
-
getBuffer(): string;
|
|
29
|
-
/**
|
|
30
|
-
* Calculate confidence for partial matches
|
|
31
|
-
*/
|
|
32
|
-
private calculatePartialConfidence;
|
|
33
|
-
/**
|
|
34
|
-
* Check if current buffer is a valid prefix
|
|
35
|
-
*/
|
|
36
|
-
private isValidPrefix;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Result of streaming match attempt
|
|
40
|
-
*/
|
|
41
|
-
interface MatchResult {
|
|
42
|
-
/** Whether a complete match was found */
|
|
43
|
-
matched: boolean;
|
|
44
|
-
/** Content that was matched or current buffer */
|
|
45
|
-
content: string;
|
|
46
|
-
/** Length of match or buffer */
|
|
47
|
-
length: number;
|
|
48
|
-
/** Whether this is a complete match */
|
|
49
|
-
isComplete: boolean;
|
|
50
|
-
/** Confidence that this will become a match (0-1) */
|
|
51
|
-
confidence?: number;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export { CustomStreamingMatcher, type MatchResult };
|
|
1
|
+
export * from '@stream-mdx/core/streaming/custom-matcher';
|
|
@@ -1,54 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Custom streaming pattern matcher
|
|
3
|
-
*/
|
|
4
|
-
declare class CustomStreamingMatcher {
|
|
5
|
-
private pattern;
|
|
6
|
-
private buffer;
|
|
7
|
-
private possibleMatches;
|
|
8
|
-
constructor(pattern: RegExp);
|
|
9
|
-
/**
|
|
10
|
-
* Add character to buffer and check for matches
|
|
11
|
-
*/
|
|
12
|
-
addCharacter(char: string): MatchResult;
|
|
13
|
-
/**
|
|
14
|
-
* Add string to buffer and check for matches
|
|
15
|
-
*/
|
|
16
|
-
addString(str: string): MatchResult[];
|
|
17
|
-
/**
|
|
18
|
-
* Check if current buffer could lead to a match
|
|
19
|
-
*/
|
|
20
|
-
couldMatch(): boolean;
|
|
21
|
-
/**
|
|
22
|
-
* Reset the matcher
|
|
23
|
-
*/
|
|
24
|
-
reset(): void;
|
|
25
|
-
/**
|
|
26
|
-
* Get current buffer content
|
|
27
|
-
*/
|
|
28
|
-
getBuffer(): string;
|
|
29
|
-
/**
|
|
30
|
-
* Calculate confidence for partial matches
|
|
31
|
-
*/
|
|
32
|
-
private calculatePartialConfidence;
|
|
33
|
-
/**
|
|
34
|
-
* Check if current buffer is a valid prefix
|
|
35
|
-
*/
|
|
36
|
-
private isValidPrefix;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Result of streaming match attempt
|
|
40
|
-
*/
|
|
41
|
-
interface MatchResult {
|
|
42
|
-
/** Whether a complete match was found */
|
|
43
|
-
matched: boolean;
|
|
44
|
-
/** Content that was matched or current buffer */
|
|
45
|
-
content: string;
|
|
46
|
-
/** Length of match or buffer */
|
|
47
|
-
length: number;
|
|
48
|
-
/** Whether this is a complete match */
|
|
49
|
-
isComplete: boolean;
|
|
50
|
-
/** Confidence that this will become a match (0-1) */
|
|
51
|
-
confidence?: number;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export { CustomStreamingMatcher, type MatchResult };
|
|
1
|
+
export * from '@stream-mdx/core/streaming/custom-matcher';
|
|
@@ -1,115 +1,3 @@
|
|
|
1
1
|
// src/streaming/custom-matcher.ts
|
|
2
|
-
|
|
3
|
-
constructor(pattern) {
|
|
4
|
-
this.buffer = "";
|
|
5
|
-
this.possibleMatches = [];
|
|
6
|
-
this.pattern = pattern;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Add character to buffer and check for matches
|
|
10
|
-
*/
|
|
11
|
-
addCharacter(char) {
|
|
12
|
-
this.buffer += char;
|
|
13
|
-
const fullMatch = this.buffer.match(this.pattern);
|
|
14
|
-
if (fullMatch && fullMatch.index === 0) {
|
|
15
|
-
const match = {
|
|
16
|
-
matched: true,
|
|
17
|
-
content: fullMatch[0],
|
|
18
|
-
length: fullMatch[0].length,
|
|
19
|
-
isComplete: true
|
|
20
|
-
};
|
|
21
|
-
this.buffer = this.buffer.slice(fullMatch[0].length);
|
|
22
|
-
this.possibleMatches = [];
|
|
23
|
-
return match;
|
|
24
|
-
}
|
|
25
|
-
const confidence = this.calculatePartialConfidence();
|
|
26
|
-
return {
|
|
27
|
-
matched: false,
|
|
28
|
-
content: this.buffer,
|
|
29
|
-
length: this.buffer.length,
|
|
30
|
-
isComplete: false,
|
|
31
|
-
confidence
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Add string to buffer and check for matches
|
|
36
|
-
*/
|
|
37
|
-
addString(str) {
|
|
38
|
-
const results = [];
|
|
39
|
-
for (const char of str) {
|
|
40
|
-
const result = this.addCharacter(char);
|
|
41
|
-
if (result.matched) {
|
|
42
|
-
results.push(result);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
if (results.length === 0 && this.buffer.length > 0) {
|
|
46
|
-
results.push({
|
|
47
|
-
matched: false,
|
|
48
|
-
content: this.buffer,
|
|
49
|
-
length: this.buffer.length,
|
|
50
|
-
isComplete: false,
|
|
51
|
-
confidence: this.calculatePartialConfidence()
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
return results;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Check if current buffer could lead to a match
|
|
58
|
-
*/
|
|
59
|
-
couldMatch() {
|
|
60
|
-
if (this.buffer.length === 0) return true;
|
|
61
|
-
const patternSource = this.pattern.source;
|
|
62
|
-
const flags = this.pattern.flags;
|
|
63
|
-
try {
|
|
64
|
-
const partialPattern = new RegExp(`^${patternSource.replace(/\$$/, "")}`, flags);
|
|
65
|
-
const testString = this.buffer + "X".repeat(100);
|
|
66
|
-
return partialPattern.test(testString);
|
|
67
|
-
} catch {
|
|
68
|
-
return this.isValidPrefix();
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Reset the matcher
|
|
73
|
-
*/
|
|
74
|
-
reset() {
|
|
75
|
-
this.buffer = "";
|
|
76
|
-
this.possibleMatches = [];
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Get current buffer content
|
|
80
|
-
*/
|
|
81
|
-
getBuffer() {
|
|
82
|
-
return this.buffer;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Calculate confidence for partial matches
|
|
86
|
-
*/
|
|
87
|
-
calculatePartialConfidence() {
|
|
88
|
-
if (this.buffer.length === 0) return 0;
|
|
89
|
-
let confidence = 0.1;
|
|
90
|
-
confidence += Math.min(0.4, this.buffer.length * 0.1);
|
|
91
|
-
if (this.couldMatch()) {
|
|
92
|
-
confidence += 0.3;
|
|
93
|
-
}
|
|
94
|
-
if (this.buffer.startsWith("$")) confidence += 0.2;
|
|
95
|
-
if (this.buffer.startsWith("$$")) confidence += 0.3;
|
|
96
|
-
return Math.min(1, confidence);
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Check if current buffer is a valid prefix
|
|
100
|
-
*/
|
|
101
|
-
isValidPrefix() {
|
|
102
|
-
const patternStr = this.pattern.source;
|
|
103
|
-
if (patternStr.includes("\\$\\$") && (this.buffer === "$" || this.buffer === "$$")) {
|
|
104
|
-
return true;
|
|
105
|
-
}
|
|
106
|
-
if (patternStr.includes("\\$") && this.buffer === "$") {
|
|
107
|
-
return true;
|
|
108
|
-
}
|
|
109
|
-
return false;
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
export {
|
|
113
|
-
CustomStreamingMatcher
|
|
114
|
-
};
|
|
2
|
+
export * from "@stream-mdx/core/streaming/custom-matcher";
|
|
115
3
|
//# sourceMappingURL=custom-matcher.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/streaming/custom-matcher.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../src/streaming/custom-matcher.ts"],"sourcesContent":["export * from \"@stream-mdx/core/streaming/custom-matcher\";\n"],"mappings":";AAAA,cAAc;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stream-mdx/worker",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.1",
|
|
4
4
|
"description": "Worker client utilities and shared worker helpers for the Streaming Markdown V2 pipeline",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -32,8 +32,12 @@
|
|
|
32
32
|
"require": "./dist/streaming/custom-matcher.cjs"
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
|
-
"files": [
|
|
36
|
-
|
|
35
|
+
"files": [
|
|
36
|
+
"dist"
|
|
37
|
+
],
|
|
38
|
+
"sideEffects": [
|
|
39
|
+
"src/worker-dom-stub.ts"
|
|
40
|
+
],
|
|
37
41
|
"scripts": {
|
|
38
42
|
"build": "tsup",
|
|
39
43
|
"build:hosted": "tsup --config tsup.hosted-worker.config.ts",
|
|
@@ -42,14 +46,16 @@
|
|
|
42
46
|
"prepack": "npm run build && npm run build:hosted"
|
|
43
47
|
},
|
|
44
48
|
"dependencies": {
|
|
49
|
+
"@lezer/common": "^1.2.3",
|
|
45
50
|
"@lezer/lr": "^1.4.2",
|
|
46
51
|
"@lezer/markdown": "^1.3.0",
|
|
47
|
-
"@stream-mdx/core": "0.0.
|
|
48
|
-
"@stream-mdx/plugins": "0.0.
|
|
52
|
+
"@stream-mdx/core": "0.0.1",
|
|
53
|
+
"@stream-mdx/plugins": "0.0.1",
|
|
49
54
|
"@mdx-js/mdx": "^3.1.0",
|
|
50
55
|
"@shikijs/engine-javascript": "^1.29.2",
|
|
51
56
|
"@shikijs/engine-oniguruma": "^1.29.2",
|
|
52
57
|
"character-entities": "^2.0.2",
|
|
58
|
+
"rehype-katex": "^7.0.1",
|
|
53
59
|
"rehype-slug": "^6.0.0",
|
|
54
60
|
"remark-gfm": "^4.0.0",
|
|
55
61
|
"remark-math": "^6.0.0",
|