mihailik commited on
Commit
f059dc2
·
1 Parent(s): 9f3e6d3

Introducing a worker to handle transformers.js without blocking.

Browse files
chat5.js ADDED
@@ -0,0 +1,233 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-check
2
+
3
+
4
+
5
+
6
+ function chat5() {
7
+
8
+ function initHTML() {
9
+ const ui = document.createElement('div');
10
+ ui.innerHTML = `
11
+ <div class=chat-log>Loading...</div>
12
+ <div class=chat-input>[Input]</div>
13
+ <style>
14
+ body {
15
+ position: absolute;
16
+ left: 0; top: 0;
17
+ width: 100%; height: 100%;
18
+ margin: 0;
19
+ padding: 0;
20
+ border: none;
21
+ display: grid;
22
+ grid-template: 1fr auto / 1fr;
23
+ }
24
+
25
+ .chat-log {
26
+ display: grid;
27
+ grid-template: 1fr / 1fr;
28
+ }
29
+ .chat-input {
30
+ border-top: solid 1px black;
31
+ display: grid;
32
+ grid-template: 1fr auto / 1fr;
33
+ }
34
+ .prose-mirror {
35
+ overflow-y: auto;
36
+ }
37
+
38
+ .milkdown {
39
+ display: grid;
40
+ grid-template: 1fr / 1fr;
41
+ }
42
+
43
+ .milkdown .ProseMirror {
44
+ min-height: 2em;
45
+ padding: 0.6em;
46
+ font-family: inherit;
47
+ white-space: pre-wrap;
48
+ }
49
+
50
+ </style>
51
+ `;
52
+
53
+ if (!document.body) {
54
+ document.documentElement.appendChild(document.createElement('body'));
55
+ } else {
56
+ cleanBody();
57
+ }
58
+
59
+ for (const elem of [...ui.children]) {
60
+ document.body.appendChild(elem);
61
+ }
62
+
63
+ const chatLog = /** @type {HTMLElement|null} */ (document.querySelector('.chat-log'));
64
+ const chatInput = /** @type {HTMLElement|null} */ (document.querySelector('.chat-input'));
65
+
66
+ return { chatLog, chatInput };
67
+ }
68
+
69
+ function cleanBody() {
70
+ for (const elem of [...document.body.childNodes]) {
71
+ if ((/** @type {HTMLElement} */ (elem).tagName || '').toLowerCase() === 'script') continue;
72
+ elem.remove();
73
+ }
74
+ }
75
+
76
+ async function initMilkdown({ chatLog, chatInput }) {
77
+ if (chatLog) chatLog.textContent = 'Loading Milkdown...';
78
+
79
+ try {
80
+ // Import all necessary Milkdown modules with the same version
81
+ const version = '7.15.3';
82
+ const [
83
+ kitCore,
84
+ kitCommonmark,
85
+ milkdownCore,
86
+ milkdownPresetCommonmark,
87
+ milkdownProse,
88
+ prosemirrorKeymap,
89
+ prosemirrorState
90
+ ] = await Promise.all([
91
+ import(`https://esm.sh/@milkdown/kit@${version}/core`),
92
+ import(`https://esm.sh/@milkdown/kit@${version}/preset/commonmark`),
93
+ import(`https://esm.sh/@milkdown/core@${version}`),
94
+ import(`https://esm.sh/@milkdown/preset-commonmark@${version}`),
95
+ import(`https://esm.sh/@milkdown/prose@${version}`),
96
+ import('https://esm.sh/[email protected]'),
97
+ import('https://esm.sh/[email protected]')
98
+ ]);
99
+
100
+ if (chatLog) chatLog.innerHTML = '';
101
+ if (chatInput) chatInput.innerHTML = '';
102
+
103
+ // Use context keys from milkdownCore only
104
+ const { rootCtx, defaultValueCtx, editorViewOptionsCtx } = milkdownCore;
105
+
106
+ // Create read-only editor in .chat-log
107
+ const chatLogEditor = await milkdownCore.Editor.make()
108
+ .config((ctx) => {
109
+ ctx.set(rootCtx, chatLog);
110
+ ctx.set(defaultValueCtx, 'Loaded.');
111
+ ctx.set(editorViewOptionsCtx, { editable: () => false });
112
+ })
113
+ .use(kitCommonmark.commonmark)
114
+ .create();
115
+
116
+ // Create editable editor in .chat-input, no placeholder, starts empty
117
+ const chatInputEditor = await milkdownCore.Editor.make()
118
+ .config((ctx) => {
119
+ ctx.set(rootCtx, chatInput);
120
+ ctx.set(defaultValueCtx, '');
121
+ })
122
+ .use(kitCommonmark.commonmark)
123
+ .create();
124
+
125
+ return {
126
+ kitCore,
127
+ kitCommonmark,
128
+ milkdownCore,
129
+ milkdownPresetCommonmark,
130
+ milkdownProse,
131
+ prosemirrorKeymap,
132
+ prosemirrorState,
133
+ chatLogEditor,
134
+ chatInputEditor
135
+ };
136
+ } catch (error) {
137
+ console.log(error);
138
+ const errorElem = document.createElement('pre');
139
+ errorElem.innerText = error.stack || 'ERR ' + error.message;
140
+ errorElem.style.whiteSpace = 'pre-wrap';
141
+ (chatLog || document.body).appendChild(errorElem);
142
+ }
143
+ }
144
+
145
+ async function outputMessage(chatLogEditor, milkdownCore, msg) {
146
+ await chatLogEditor.action((ctx) => {
147
+ const view = ctx.get(milkdownCore.editorViewCtx);
148
+ const parser = ctx.get(milkdownCore.parserCtx);
149
+ const serializer = ctx.get(milkdownCore.serializerCtx);
150
+ const state = view.state;
151
+ // Get current markdown, append new message, and parse
152
+ const currentMarkdown = serializer(state.doc);
153
+ const newMarkdown = currentMarkdown ? (currentMarkdown + '\n' + msg) : msg;
154
+ const doc = parser(newMarkdown);
155
+ // Use replaceWith and doc.content to avoid TransformError
156
+ const tr = state.tr.replaceWith(0, state.doc.content.size, doc.content);
157
+ view.dispatch(tr);
158
+ });
159
+ // Scroll chat log to bottom (smooth if possible)
160
+ const chatLogElem = document.querySelector('.chat-log');
161
+ if (chatLogElem) {
162
+ if ('scrollTo' in chatLogElem) {
163
+ chatLogElem.scrollTo({ top: chatLogElem.scrollHeight, behavior: 'smooth' });
164
+ } else {
165
+ chatLogElem.scrollTop = chatLogElem.scrollHeight;
166
+ }
167
+ }
168
+ }
169
+
170
+ async function runBrowser() {
171
+ window.onerror = (...args) => {
172
+ alert(args.map(String).join('\n'));
173
+ };
174
+ const { kitCore, kitCommonmark, chatLog, chatInput } = initHTML();
175
+ const milkdownResult = await initMilkdown({ chatLog, chatInput });
176
+ if (!milkdownResult) return;
177
+ const { chatLogEditor, chatInputEditor, milkdownCore, prosemirrorKeymap, prosemirrorState } = milkdownResult;
178
+
179
+ outputMessage(chatLogEditor, milkdownCore, 'Milkdown editor component is loaded correctly. Please try typing...');
180
+
181
+ // Add a ProseMirror plugin to handle Enter key in chat input editor
182
+ await chatInputEditor.action((ctx) => {
183
+ const serializer = ctx.get(milkdownCore.serializerCtx);
184
+ const view = ctx.get(milkdownCore.editorViewCtx);
185
+ const { Plugin } = prosemirrorState;
186
+ // Add a keymap plugin for Enter
187
+ const enterPlugin = new Plugin({
188
+ props: {
189
+ handleKeyDown(view, event) {
190
+ if (
191
+ event.key === 'Enter' &&
192
+ !event.ctrlKey && !event.altKey && !event.shiftKey && !event.metaKey
193
+ ) {
194
+ event.preventDefault();
195
+ const inputMarkdown = serializer(view.state.doc).trim();
196
+ if (inputMarkdown) {
197
+ const msg = `user typed:\n> ${inputMarkdown.replace(/\n/g, '\n> ')}`;
198
+ outputMessage(chatLogEditor, milkdownCore, msg);
199
+ // Clear input
200
+ const tr = view.state.tr.replaceWith(
201
+ 0,
202
+ view.state.doc.content.size,
203
+ view.state.schema.nodes.doc.createAndFill().content
204
+ );
205
+ view.dispatch(tr);
206
+ }
207
+ return true;
208
+ }
209
+ return false;
210
+ },
211
+ },
212
+ });
213
+ view.state = view.state.reconfigure({
214
+ plugins: [...view.state.plugins, enterPlugin],
215
+ });
216
+ view.updateState(view.state);
217
+ });
218
+
219
+ window.onerror = (...args) => {
220
+ try {
221
+ outputMessage(chatLogEditor, milkdownCore, args.map(String).join('\n'));
222
+ } catch (errorNext) {
223
+ alert(args.map(String).join('\n') + '\n\n' + errorNext.stack);
224
+ }
225
+ };
226
+ }
227
+
228
+ if (typeof window !== 'undefined' && typeof window?.alert === 'function'
229
+ && typeof document !== 'undefined' && typeof document?.createElement === 'function') {
230
+ runBrowser();
231
+ }
232
+ }
233
+ chat5();
package-lock.json CHANGED
@@ -1,14 +1,15 @@
1
  {
2
  "name": "localm",
3
- "version": "1.0.1",
4
  "lockfileVersion": 3,
5
  "requires": true,
6
  "packages": {
7
  "": {
8
  "name": "localm",
9
- "version": "1.0.1",
10
  "license": "ISC",
11
  "dependencies": {
 
12
  "@milkdown/crepe": "^7.15.3",
13
  "esbuild": "^0.25.9"
14
  }
@@ -455,6 +456,16 @@
455
  "w3c-keyname": "^2.2.4"
456
  }
457
  },
 
 
 
 
 
 
 
 
 
 
458
  "node_modules/@esbuild/aix-ppc64": {
459
  "version": "0.25.9",
460
  "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.9.tgz",
@@ -890,11 +901,462 @@
890
  "@floating-ui/utils": "^0.2.10"
891
  }
892
  },
893
- "node_modules/@floating-ui/utils": {
894
- "version": "0.2.10",
895
- "resolved": "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.2.10.tgz",
896
- "integrity": "sha512-aGTxbpbg8/b5JfU1HXSrbH3wXZuLPJcNEcZQFMxLs3oSzgtVu6nFPkbbGGUvBcUjKV2YyB9Wxxabo+HEH9tcRQ==",
897
- "license": "MIT"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
898
  },
899
  "node_modules/@jridgewell/sourcemap-codec": {
900
  "version": "1.5.5",
@@ -1439,6 +1901,70 @@
1439
  "tslib": "^2.8.1"
1440
  }
1441
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1442
  "node_modules/@types/debug": {
1443
  "version": "4.1.12",
1444
  "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.12.tgz",
@@ -1493,6 +2019,15 @@
1493
  "integrity": "sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA==",
1494
  "license": "MIT"
1495
  },
 
 
 
 
 
 
 
 
 
1496
  "node_modules/@types/trusted-types": {
1497
  "version": "2.0.7",
1498
  "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz",
@@ -1616,6 +2151,13 @@
1616
  "url": "https://github.com/sponsors/wooorm"
1617
  }
1618
  },
 
 
 
 
 
 
 
1619
  "node_modules/ccount": {
1620
  "version": "2.0.1",
1621
  "resolved": "https://registry.npmjs.org/ccount/-/ccount-2.0.1.tgz",
@@ -1636,6 +2178,15 @@
1636
  "url": "https://github.com/sponsors/wooorm"
1637
  }
1638
  },
 
 
 
 
 
 
 
 
 
1639
  "node_modules/clsx": {
1640
  "version": "2.1.1",
1641
  "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz",
@@ -1660,6 +2211,47 @@
1660
  "@codemirror/view": "^6.0.0"
1661
  }
1662
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1663
  "node_modules/commander": {
1664
  "version": "8.3.0",
1665
  "resolved": "https://registry.npmjs.org/commander/-/commander-8.3.0.tgz",
@@ -1711,6 +2303,40 @@
1711
  "url": "https://github.com/sponsors/wooorm"
1712
  }
1713
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1714
  "node_modules/dequal": {
1715
  "version": "2.0.3",
1716
  "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz",
@@ -1720,6 +2346,21 @@
1720
  "node": ">=6"
1721
  }
1722
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1723
  "node_modules/devlop": {
1724
  "version": "1.1.0",
1725
  "resolved": "https://registry.npmjs.org/devlop/-/devlop-1.1.0.tgz",
@@ -1754,6 +2395,30 @@
1754
  "url": "https://github.com/fb55/entities?sponsor=1"
1755
  }
1756
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1757
  "node_modules/esbuild": {
1758
  "version": "0.25.9",
1759
  "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.9.tgz",
@@ -1819,6 +2484,81 @@
1819
  "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==",
1820
  "license": "MIT"
1821
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1822
  "node_modules/is-plain-obj": {
1823
  "version": "4.1.0",
1824
  "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-4.1.0.tgz",
@@ -1831,6 +2571,12 @@
1831
  "url": "https://github.com/sponsors/sindresorhus"
1832
  }
1833
  },
 
 
 
 
 
 
1834
  "node_modules/katex": {
1835
  "version": "0.16.22",
1836
  "resolved": "https://registry.npmjs.org/katex/-/katex-0.16.22.tgz",
@@ -1853,6 +2599,12 @@
1853
  "integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==",
1854
  "license": "MIT"
1855
  },
 
 
 
 
 
 
1856
  "node_modules/longest-streak": {
1857
  "version": "3.1.0",
1858
  "resolved": "https://registry.npmjs.org/longest-streak/-/longest-streak-3.1.0.tgz",
@@ -1882,6 +2634,30 @@
1882
  "url": "https://github.com/sponsors/wooorm"
1883
  }
1884
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1885
  "node_modules/mdast-util-definitions": {
1886
  "version": "6.0.0",
1887
  "resolved": "https://registry.npmjs.org/mdast-util-definitions/-/mdast-util-definitions-6.0.0.tgz",
@@ -2687,6 +3463,42 @@
2687
  ],
2688
  "license": "MIT"
2689
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2690
  "node_modules/ms": {
2691
  "version": "2.1.3",
2692
  "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
@@ -2711,6 +3523,58 @@
2711
  "node": "^18 || >=20"
2712
  }
2713
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2714
  "node_modules/orderedmap": {
2715
  "version": "2.1.1",
2716
  "resolved": "https://registry.npmjs.org/orderedmap/-/orderedmap-2.1.1.tgz",
@@ -2723,6 +3587,12 @@
2723
  "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",
2724
  "license": "ISC"
2725
  },
 
 
 
 
 
 
2726
  "node_modules/postcss": {
2727
  "version": "8.5.6",
2728
  "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.6.tgz",
@@ -2946,6 +3816,30 @@
2946
  }
2947
  }
2948
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2949
  "node_modules/remark": {
2950
  "version": "15.0.1",
2951
  "resolved": "https://registry.npmjs.org/remark/-/remark-15.0.1.tgz",
@@ -3042,12 +3936,113 @@
3042
  "url": "https://opencollective.com/unified"
3043
  }
3044
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3045
  "node_modules/rope-sequence": {
3046
  "version": "1.3.4",
3047
  "resolved": "https://registry.npmjs.org/rope-sequence/-/rope-sequence-1.3.4.tgz",
3048
  "integrity": "sha512-UT5EDe2cu2E/6O4igUr5PSFs23nvvukicWHx6GnOPlHAiiYbzNuCRQCuiUdHJQcqKalLKlrYJnjY0ySGsXNQXQ==",
3049
  "license": "MIT"
3050
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3051
  "node_modules/source-map-js": {
3052
  "version": "1.2.1",
3053
  "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz",
@@ -3057,12 +4052,35 @@
3057
  "node": ">=0.10.0"
3058
  }
3059
  },
 
 
 
 
 
 
3060
  "node_modules/style-mod": {
3061
  "version": "4.1.2",
3062
  "resolved": "https://registry.npmjs.org/style-mod/-/style-mod-4.1.2.tgz",
3063
  "integrity": "sha512-wnD1HyVqpJUI2+eKZ+eo1UwghftP6yuFheBqqe+bWCotBjC2K1YnteJILRMs3SM4V/0dLEW1SC27MWP5y+mwmw==",
3064
  "license": "MIT"
3065
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3066
  "node_modules/trough": {
3067
  "version": "2.2.0",
3068
  "resolved": "https://registry.npmjs.org/trough/-/trough-2.2.0.tgz",
@@ -3079,6 +4097,24 @@
3079
  "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
3080
  "license": "0BSD"
3081
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3082
  "node_modules/unified": {
3083
  "version": "11.0.5",
3084
  "resolved": "https://registry.npmjs.org/unified/-/unified-11.0.5.tgz",
@@ -3222,6 +4258,15 @@
3222
  "integrity": "sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ==",
3223
  "license": "MIT"
3224
  },
 
 
 
 
 
 
 
 
 
3225
  "node_modules/zwitch": {
3226
  "version": "2.0.4",
3227
  "resolved": "https://registry.npmjs.org/zwitch/-/zwitch-2.0.4.tgz",
 
1
  {
2
  "name": "localm",
3
+ "version": "1.0.6",
4
  "lockfileVersion": 3,
5
  "requires": true,
6
  "packages": {
7
  "": {
8
  "name": "localm",
9
+ "version": "1.0.6",
10
  "license": "ISC",
11
  "dependencies": {
12
+ "@huggingface/transformers": "^3.7.2",
13
  "@milkdown/crepe": "^7.15.3",
14
  "esbuild": "^0.25.9"
15
  }
 
456
  "w3c-keyname": "^2.2.4"
457
  }
458
  },
459
+ "node_modules/@emnapi/runtime": {
460
+ "version": "1.4.5",
461
+ "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.4.5.tgz",
462
+ "integrity": "sha512-++LApOtY0pEEz1zrd9vy1/zXVaVJJ/EbAF3u0fXIzPJEDtnITsBGbbK0EkM72amhl/R5b+5xx0Y/QhcVOpuulg==",
463
+ "license": "MIT",
464
+ "optional": true,
465
+ "dependencies": {
466
+ "tslib": "^2.4.0"
467
+ }
468
+ },
469
  "node_modules/@esbuild/aix-ppc64": {
470
  "version": "0.25.9",
471
  "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.9.tgz",
 
901
  "@floating-ui/utils": "^0.2.10"
902
  }
903
  },
904
+ "node_modules/@floating-ui/utils": {
905
+ "version": "0.2.10",
906
+ "resolved": "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.2.10.tgz",
907
+ "integrity": "sha512-aGTxbpbg8/b5JfU1HXSrbH3wXZuLPJcNEcZQFMxLs3oSzgtVu6nFPkbbGGUvBcUjKV2YyB9Wxxabo+HEH9tcRQ==",
908
+ "license": "MIT"
909
+ },
910
+ "node_modules/@huggingface/jinja": {
911
+ "version": "0.5.1",
912
+ "resolved": "https://registry.npmjs.org/@huggingface/jinja/-/jinja-0.5.1.tgz",
913
+ "integrity": "sha512-yUZLld4lrM9iFxHCwFQ7D1HW2MWMwSbeB7WzWqFYDWK+rEb+WldkLdAJxUPOmgICMHZLzZGVcVjFh3w/YGubng==",
914
+ "license": "MIT",
915
+ "engines": {
916
+ "node": ">=18"
917
+ }
918
+ },
919
+ "node_modules/@huggingface/transformers": {
920
+ "version": "3.7.2",
921
+ "resolved": "https://registry.npmjs.org/@huggingface/transformers/-/transformers-3.7.2.tgz",
922
+ "integrity": "sha512-6SOxo6XziupnQ5Vs5vbbs74CNB6ViHLHGQJjY6zj88JeiDtJ2d/ADKxaay688Sf2KcjtdF3dyBL11C5pJS2NxQ==",
923
+ "license": "Apache-2.0",
924
+ "dependencies": {
925
+ "@huggingface/jinja": "^0.5.1",
926
+ "onnxruntime-node": "1.21.0",
927
+ "onnxruntime-web": "1.22.0-dev.20250409-89f8206ba4",
928
+ "sharp": "^0.34.1"
929
+ }
930
+ },
931
+ "node_modules/@img/sharp-darwin-arm64": {
932
+ "version": "0.34.3",
933
+ "resolved": "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.34.3.tgz",
934
+ "integrity": "sha512-ryFMfvxxpQRsgZJqBd4wsttYQbCxsJksrv9Lw/v798JcQ8+w84mBWuXwl+TT0WJ/WrYOLaYpwQXi3sA9nTIaIg==",
935
+ "cpu": [
936
+ "arm64"
937
+ ],
938
+ "license": "Apache-2.0",
939
+ "optional": true,
940
+ "os": [
941
+ "darwin"
942
+ ],
943
+ "engines": {
944
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
945
+ },
946
+ "funding": {
947
+ "url": "https://opencollective.com/libvips"
948
+ },
949
+ "optionalDependencies": {
950
+ "@img/sharp-libvips-darwin-arm64": "1.2.0"
951
+ }
952
+ },
953
+ "node_modules/@img/sharp-darwin-x64": {
954
+ "version": "0.34.3",
955
+ "resolved": "https://registry.npmjs.org/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.34.3.tgz",
956
+ "integrity": "sha512-yHpJYynROAj12TA6qil58hmPmAwxKKC7reUqtGLzsOHfP7/rniNGTL8tjWX6L3CTV4+5P4ypcS7Pp+7OB+8ihA==",
957
+ "cpu": [
958
+ "x64"
959
+ ],
960
+ "license": "Apache-2.0",
961
+ "optional": true,
962
+ "os": [
963
+ "darwin"
964
+ ],
965
+ "engines": {
966
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
967
+ },
968
+ "funding": {
969
+ "url": "https://opencollective.com/libvips"
970
+ },
971
+ "optionalDependencies": {
972
+ "@img/sharp-libvips-darwin-x64": "1.2.0"
973
+ }
974
+ },
975
+ "node_modules/@img/sharp-libvips-darwin-arm64": {
976
+ "version": "1.2.0",
977
+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.2.0.tgz",
978
+ "integrity": "sha512-sBZmpwmxqwlqG9ueWFXtockhsxefaV6O84BMOrhtg/YqbTaRdqDE7hxraVE3y6gVM4eExmfzW4a8el9ArLeEiQ==",
979
+ "cpu": [
980
+ "arm64"
981
+ ],
982
+ "license": "LGPL-3.0-or-later",
983
+ "optional": true,
984
+ "os": [
985
+ "darwin"
986
+ ],
987
+ "funding": {
988
+ "url": "https://opencollective.com/libvips"
989
+ }
990
+ },
991
+ "node_modules/@img/sharp-libvips-darwin-x64": {
992
+ "version": "1.2.0",
993
+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.2.0.tgz",
994
+ "integrity": "sha512-M64XVuL94OgiNHa5/m2YvEQI5q2cl9d/wk0qFTDVXcYzi43lxuiFTftMR1tOnFQovVXNZJ5TURSDK2pNe9Yzqg==",
995
+ "cpu": [
996
+ "x64"
997
+ ],
998
+ "license": "LGPL-3.0-or-later",
999
+ "optional": true,
1000
+ "os": [
1001
+ "darwin"
1002
+ ],
1003
+ "funding": {
1004
+ "url": "https://opencollective.com/libvips"
1005
+ }
1006
+ },
1007
+ "node_modules/@img/sharp-libvips-linux-arm": {
1008
+ "version": "1.2.0",
1009
+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.2.0.tgz",
1010
+ "integrity": "sha512-mWd2uWvDtL/nvIzThLq3fr2nnGfyr/XMXlq8ZJ9WMR6PXijHlC3ksp0IpuhK6bougvQrchUAfzRLnbsen0Cqvw==",
1011
+ "cpu": [
1012
+ "arm"
1013
+ ],
1014
+ "license": "LGPL-3.0-or-later",
1015
+ "optional": true,
1016
+ "os": [
1017
+ "linux"
1018
+ ],
1019
+ "funding": {
1020
+ "url": "https://opencollective.com/libvips"
1021
+ }
1022
+ },
1023
+ "node_modules/@img/sharp-libvips-linux-arm64": {
1024
+ "version": "1.2.0",
1025
+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.2.0.tgz",
1026
+ "integrity": "sha512-RXwd0CgG+uPRX5YYrkzKyalt2OJYRiJQ8ED/fi1tq9WQW2jsQIn0tqrlR5l5dr/rjqq6AHAxURhj2DVjyQWSOA==",
1027
+ "cpu": [
1028
+ "arm64"
1029
+ ],
1030
+ "license": "LGPL-3.0-or-later",
1031
+ "optional": true,
1032
+ "os": [
1033
+ "linux"
1034
+ ],
1035
+ "funding": {
1036
+ "url": "https://opencollective.com/libvips"
1037
+ }
1038
+ },
1039
+ "node_modules/@img/sharp-libvips-linux-ppc64": {
1040
+ "version": "1.2.0",
1041
+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-ppc64/-/sharp-libvips-linux-ppc64-1.2.0.tgz",
1042
+ "integrity": "sha512-Xod/7KaDDHkYu2phxxfeEPXfVXFKx70EAFZ0qyUdOjCcxbjqyJOEUpDe6RIyaunGxT34Anf9ue/wuWOqBW2WcQ==",
1043
+ "cpu": [
1044
+ "ppc64"
1045
+ ],
1046
+ "license": "LGPL-3.0-or-later",
1047
+ "optional": true,
1048
+ "os": [
1049
+ "linux"
1050
+ ],
1051
+ "funding": {
1052
+ "url": "https://opencollective.com/libvips"
1053
+ }
1054
+ },
1055
+ "node_modules/@img/sharp-libvips-linux-s390x": {
1056
+ "version": "1.2.0",
1057
+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.2.0.tgz",
1058
+ "integrity": "sha512-eMKfzDxLGT8mnmPJTNMcjfO33fLiTDsrMlUVcp6b96ETbnJmd4uvZxVJSKPQfS+odwfVaGifhsB07J1LynFehw==",
1059
+ "cpu": [
1060
+ "s390x"
1061
+ ],
1062
+ "license": "LGPL-3.0-or-later",
1063
+ "optional": true,
1064
+ "os": [
1065
+ "linux"
1066
+ ],
1067
+ "funding": {
1068
+ "url": "https://opencollective.com/libvips"
1069
+ }
1070
+ },
1071
+ "node_modules/@img/sharp-libvips-linux-x64": {
1072
+ "version": "1.2.0",
1073
+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.2.0.tgz",
1074
+ "integrity": "sha512-ZW3FPWIc7K1sH9E3nxIGB3y3dZkpJlMnkk7z5tu1nSkBoCgw2nSRTFHI5pB/3CQaJM0pdzMF3paf9ckKMSE9Tg==",
1075
+ "cpu": [
1076
+ "x64"
1077
+ ],
1078
+ "license": "LGPL-3.0-or-later",
1079
+ "optional": true,
1080
+ "os": [
1081
+ "linux"
1082
+ ],
1083
+ "funding": {
1084
+ "url": "https://opencollective.com/libvips"
1085
+ }
1086
+ },
1087
+ "node_modules/@img/sharp-libvips-linuxmusl-arm64": {
1088
+ "version": "1.2.0",
1089
+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.2.0.tgz",
1090
+ "integrity": "sha512-UG+LqQJbf5VJ8NWJ5Z3tdIe/HXjuIdo4JeVNADXBFuG7z9zjoegpzzGIyV5zQKi4zaJjnAd2+g2nna8TZvuW9Q==",
1091
+ "cpu": [
1092
+ "arm64"
1093
+ ],
1094
+ "license": "LGPL-3.0-or-later",
1095
+ "optional": true,
1096
+ "os": [
1097
+ "linux"
1098
+ ],
1099
+ "funding": {
1100
+ "url": "https://opencollective.com/libvips"
1101
+ }
1102
+ },
1103
+ "node_modules/@img/sharp-libvips-linuxmusl-x64": {
1104
+ "version": "1.2.0",
1105
+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.2.0.tgz",
1106
+ "integrity": "sha512-SRYOLR7CXPgNze8akZwjoGBoN1ThNZoqpOgfnOxmWsklTGVfJiGJoC/Lod7aNMGA1jSsKWM1+HRX43OP6p9+6Q==",
1107
+ "cpu": [
1108
+ "x64"
1109
+ ],
1110
+ "license": "LGPL-3.0-or-later",
1111
+ "optional": true,
1112
+ "os": [
1113
+ "linux"
1114
+ ],
1115
+ "funding": {
1116
+ "url": "https://opencollective.com/libvips"
1117
+ }
1118
+ },
1119
+ "node_modules/@img/sharp-linux-arm": {
1120
+ "version": "0.34.3",
1121
+ "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm/-/sharp-linux-arm-0.34.3.tgz",
1122
+ "integrity": "sha512-oBK9l+h6KBN0i3dC8rYntLiVfW8D8wH+NPNT3O/WBHeW0OQWCjfWksLUaPidsrDKpJgXp3G3/hkmhptAW0I3+A==",
1123
+ "cpu": [
1124
+ "arm"
1125
+ ],
1126
+ "license": "Apache-2.0",
1127
+ "optional": true,
1128
+ "os": [
1129
+ "linux"
1130
+ ],
1131
+ "engines": {
1132
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
1133
+ },
1134
+ "funding": {
1135
+ "url": "https://opencollective.com/libvips"
1136
+ },
1137
+ "optionalDependencies": {
1138
+ "@img/sharp-libvips-linux-arm": "1.2.0"
1139
+ }
1140
+ },
1141
+ "node_modules/@img/sharp-linux-arm64": {
1142
+ "version": "0.34.3",
1143
+ "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.34.3.tgz",
1144
+ "integrity": "sha512-QdrKe3EvQrqwkDrtuTIjI0bu6YEJHTgEeqdzI3uWJOH6G1O8Nl1iEeVYRGdj1h5I21CqxSvQp1Yv7xeU3ZewbA==",
1145
+ "cpu": [
1146
+ "arm64"
1147
+ ],
1148
+ "license": "Apache-2.0",
1149
+ "optional": true,
1150
+ "os": [
1151
+ "linux"
1152
+ ],
1153
+ "engines": {
1154
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
1155
+ },
1156
+ "funding": {
1157
+ "url": "https://opencollective.com/libvips"
1158
+ },
1159
+ "optionalDependencies": {
1160
+ "@img/sharp-libvips-linux-arm64": "1.2.0"
1161
+ }
1162
+ },
1163
+ "node_modules/@img/sharp-linux-ppc64": {
1164
+ "version": "0.34.3",
1165
+ "resolved": "https://registry.npmjs.org/@img/sharp-linux-ppc64/-/sharp-linux-ppc64-0.34.3.tgz",
1166
+ "integrity": "sha512-GLtbLQMCNC5nxuImPR2+RgrviwKwVql28FWZIW1zWruy6zLgA5/x2ZXk3mxj58X/tszVF69KK0Is83V8YgWhLA==",
1167
+ "cpu": [
1168
+ "ppc64"
1169
+ ],
1170
+ "license": "Apache-2.0",
1171
+ "optional": true,
1172
+ "os": [
1173
+ "linux"
1174
+ ],
1175
+ "engines": {
1176
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
1177
+ },
1178
+ "funding": {
1179
+ "url": "https://opencollective.com/libvips"
1180
+ },
1181
+ "optionalDependencies": {
1182
+ "@img/sharp-libvips-linux-ppc64": "1.2.0"
1183
+ }
1184
+ },
1185
+ "node_modules/@img/sharp-linux-s390x": {
1186
+ "version": "0.34.3",
1187
+ "resolved": "https://registry.npmjs.org/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.34.3.tgz",
1188
+ "integrity": "sha512-3gahT+A6c4cdc2edhsLHmIOXMb17ltffJlxR0aC2VPZfwKoTGZec6u5GrFgdR7ciJSsHT27BD3TIuGcuRT0KmQ==",
1189
+ "cpu": [
1190
+ "s390x"
1191
+ ],
1192
+ "license": "Apache-2.0",
1193
+ "optional": true,
1194
+ "os": [
1195
+ "linux"
1196
+ ],
1197
+ "engines": {
1198
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
1199
+ },
1200
+ "funding": {
1201
+ "url": "https://opencollective.com/libvips"
1202
+ },
1203
+ "optionalDependencies": {
1204
+ "@img/sharp-libvips-linux-s390x": "1.2.0"
1205
+ }
1206
+ },
1207
+ "node_modules/@img/sharp-linux-x64": {
1208
+ "version": "0.34.3",
1209
+ "resolved": "https://registry.npmjs.org/@img/sharp-linux-x64/-/sharp-linux-x64-0.34.3.tgz",
1210
+ "integrity": "sha512-8kYso8d806ypnSq3/Ly0QEw90V5ZoHh10yH0HnrzOCr6DKAPI6QVHvwleqMkVQ0m+fc7EH8ah0BB0QPuWY6zJQ==",
1211
+ "cpu": [
1212
+ "x64"
1213
+ ],
1214
+ "license": "Apache-2.0",
1215
+ "optional": true,
1216
+ "os": [
1217
+ "linux"
1218
+ ],
1219
+ "engines": {
1220
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
1221
+ },
1222
+ "funding": {
1223
+ "url": "https://opencollective.com/libvips"
1224
+ },
1225
+ "optionalDependencies": {
1226
+ "@img/sharp-libvips-linux-x64": "1.2.0"
1227
+ }
1228
+ },
1229
+ "node_modules/@img/sharp-linuxmusl-arm64": {
1230
+ "version": "0.34.3",
1231
+ "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.34.3.tgz",
1232
+ "integrity": "sha512-vAjbHDlr4izEiXM1OTggpCcPg9tn4YriK5vAjowJsHwdBIdx0fYRsURkxLG2RLm9gyBq66gwtWI8Gx0/ov+JKQ==",
1233
+ "cpu": [
1234
+ "arm64"
1235
+ ],
1236
+ "license": "Apache-2.0",
1237
+ "optional": true,
1238
+ "os": [
1239
+ "linux"
1240
+ ],
1241
+ "engines": {
1242
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
1243
+ },
1244
+ "funding": {
1245
+ "url": "https://opencollective.com/libvips"
1246
+ },
1247
+ "optionalDependencies": {
1248
+ "@img/sharp-libvips-linuxmusl-arm64": "1.2.0"
1249
+ }
1250
+ },
1251
+ "node_modules/@img/sharp-linuxmusl-x64": {
1252
+ "version": "0.34.3",
1253
+ "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.34.3.tgz",
1254
+ "integrity": "sha512-gCWUn9547K5bwvOn9l5XGAEjVTTRji4aPTqLzGXHvIr6bIDZKNTA34seMPgM0WmSf+RYBH411VavCejp3PkOeQ==",
1255
+ "cpu": [
1256
+ "x64"
1257
+ ],
1258
+ "license": "Apache-2.0",
1259
+ "optional": true,
1260
+ "os": [
1261
+ "linux"
1262
+ ],
1263
+ "engines": {
1264
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
1265
+ },
1266
+ "funding": {
1267
+ "url": "https://opencollective.com/libvips"
1268
+ },
1269
+ "optionalDependencies": {
1270
+ "@img/sharp-libvips-linuxmusl-x64": "1.2.0"
1271
+ }
1272
+ },
1273
+ "node_modules/@img/sharp-wasm32": {
1274
+ "version": "0.34.3",
1275
+ "resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.34.3.tgz",
1276
+ "integrity": "sha512-+CyRcpagHMGteySaWos8IbnXcHgfDn7pO2fiC2slJxvNq9gDipYBN42/RagzctVRKgxATmfqOSulgZv5e1RdMg==",
1277
+ "cpu": [
1278
+ "wasm32"
1279
+ ],
1280
+ "license": "Apache-2.0 AND LGPL-3.0-or-later AND MIT",
1281
+ "optional": true,
1282
+ "dependencies": {
1283
+ "@emnapi/runtime": "^1.4.4"
1284
+ },
1285
+ "engines": {
1286
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
1287
+ },
1288
+ "funding": {
1289
+ "url": "https://opencollective.com/libvips"
1290
+ }
1291
+ },
1292
+ "node_modules/@img/sharp-win32-arm64": {
1293
+ "version": "0.34.3",
1294
+ "resolved": "https://registry.npmjs.org/@img/sharp-win32-arm64/-/sharp-win32-arm64-0.34.3.tgz",
1295
+ "integrity": "sha512-MjnHPnbqMXNC2UgeLJtX4XqoVHHlZNd+nPt1kRPmj63wURegwBhZlApELdtxM2OIZDRv/DFtLcNhVbd1z8GYXQ==",
1296
+ "cpu": [
1297
+ "arm64"
1298
+ ],
1299
+ "license": "Apache-2.0 AND LGPL-3.0-or-later",
1300
+ "optional": true,
1301
+ "os": [
1302
+ "win32"
1303
+ ],
1304
+ "engines": {
1305
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
1306
+ },
1307
+ "funding": {
1308
+ "url": "https://opencollective.com/libvips"
1309
+ }
1310
+ },
1311
+ "node_modules/@img/sharp-win32-ia32": {
1312
+ "version": "0.34.3",
1313
+ "resolved": "https://registry.npmjs.org/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.34.3.tgz",
1314
+ "integrity": "sha512-xuCdhH44WxuXgOM714hn4amodJMZl3OEvf0GVTm0BEyMeA2to+8HEdRPShH0SLYptJY1uBw+SCFP9WVQi1Q/cw==",
1315
+ "cpu": [
1316
+ "ia32"
1317
+ ],
1318
+ "license": "Apache-2.0 AND LGPL-3.0-or-later",
1319
+ "optional": true,
1320
+ "os": [
1321
+ "win32"
1322
+ ],
1323
+ "engines": {
1324
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
1325
+ },
1326
+ "funding": {
1327
+ "url": "https://opencollective.com/libvips"
1328
+ }
1329
+ },
1330
+ "node_modules/@img/sharp-win32-x64": {
1331
+ "version": "0.34.3",
1332
+ "resolved": "https://registry.npmjs.org/@img/sharp-win32-x64/-/sharp-win32-x64-0.34.3.tgz",
1333
+ "integrity": "sha512-OWwz05d++TxzLEv4VnsTz5CmZ6mI6S05sfQGEMrNrQcOEERbX46332IvE7pO/EUiw7jUrrS40z/M7kPyjfl04g==",
1334
+ "cpu": [
1335
+ "x64"
1336
+ ],
1337
+ "license": "Apache-2.0 AND LGPL-3.0-or-later",
1338
+ "optional": true,
1339
+ "os": [
1340
+ "win32"
1341
+ ],
1342
+ "engines": {
1343
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
1344
+ },
1345
+ "funding": {
1346
+ "url": "https://opencollective.com/libvips"
1347
+ }
1348
+ },
1349
+ "node_modules/@isaacs/fs-minipass": {
1350
+ "version": "4.0.1",
1351
+ "resolved": "https://registry.npmjs.org/@isaacs/fs-minipass/-/fs-minipass-4.0.1.tgz",
1352
+ "integrity": "sha512-wgm9Ehl2jpeqP3zw/7mo3kRHFp5MEDhqAdwy1fTGkHAwnkGOVsgpvQhL8B5n1qlb01jV3n/bI0ZfZp5lWA1k4w==",
1353
+ "license": "ISC",
1354
+ "dependencies": {
1355
+ "minipass": "^7.0.4"
1356
+ },
1357
+ "engines": {
1358
+ "node": ">=18.0.0"
1359
+ }
1360
  },
1361
  "node_modules/@jridgewell/sourcemap-codec": {
1362
  "version": "1.5.5",
 
1901
  "tslib": "^2.8.1"
1902
  }
1903
  },
1904
+ "node_modules/@protobufjs/aspromise": {
1905
+ "version": "1.1.2",
1906
+ "resolved": "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz",
1907
+ "integrity": "sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ==",
1908
+ "license": "BSD-3-Clause"
1909
+ },
1910
+ "node_modules/@protobufjs/base64": {
1911
+ "version": "1.1.2",
1912
+ "resolved": "https://registry.npmjs.org/@protobufjs/base64/-/base64-1.1.2.tgz",
1913
+ "integrity": "sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg==",
1914
+ "license": "BSD-3-Clause"
1915
+ },
1916
+ "node_modules/@protobufjs/codegen": {
1917
+ "version": "2.0.4",
1918
+ "resolved": "https://registry.npmjs.org/@protobufjs/codegen/-/codegen-2.0.4.tgz",
1919
+ "integrity": "sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg==",
1920
+ "license": "BSD-3-Clause"
1921
+ },
1922
+ "node_modules/@protobufjs/eventemitter": {
1923
+ "version": "1.1.0",
1924
+ "resolved": "https://registry.npmjs.org/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz",
1925
+ "integrity": "sha512-j9ednRT81vYJ9OfVuXG6ERSTdEL1xVsNgqpkxMsbIabzSo3goCjDIveeGv5d03om39ML71RdmrGNjG5SReBP/Q==",
1926
+ "license": "BSD-3-Clause"
1927
+ },
1928
+ "node_modules/@protobufjs/fetch": {
1929
+ "version": "1.1.0",
1930
+ "resolved": "https://registry.npmjs.org/@protobufjs/fetch/-/fetch-1.1.0.tgz",
1931
+ "integrity": "sha512-lljVXpqXebpsijW71PZaCYeIcE5on1w5DlQy5WH6GLbFryLUrBD4932W/E2BSpfRJWseIL4v/KPgBFxDOIdKpQ==",
1932
+ "license": "BSD-3-Clause",
1933
+ "dependencies": {
1934
+ "@protobufjs/aspromise": "^1.1.1",
1935
+ "@protobufjs/inquire": "^1.1.0"
1936
+ }
1937
+ },
1938
+ "node_modules/@protobufjs/float": {
1939
+ "version": "1.0.2",
1940
+ "resolved": "https://registry.npmjs.org/@protobufjs/float/-/float-1.0.2.tgz",
1941
+ "integrity": "sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ==",
1942
+ "license": "BSD-3-Clause"
1943
+ },
1944
+ "node_modules/@protobufjs/inquire": {
1945
+ "version": "1.1.0",
1946
+ "resolved": "https://registry.npmjs.org/@protobufjs/inquire/-/inquire-1.1.0.tgz",
1947
+ "integrity": "sha512-kdSefcPdruJiFMVSbn801t4vFK7KB/5gd2fYvrxhuJYg8ILrmn9SKSX2tZdV6V+ksulWqS7aXjBcRXl3wHoD9Q==",
1948
+ "license": "BSD-3-Clause"
1949
+ },
1950
+ "node_modules/@protobufjs/path": {
1951
+ "version": "1.1.2",
1952
+ "resolved": "https://registry.npmjs.org/@protobufjs/path/-/path-1.1.2.tgz",
1953
+ "integrity": "sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA==",
1954
+ "license": "BSD-3-Clause"
1955
+ },
1956
+ "node_modules/@protobufjs/pool": {
1957
+ "version": "1.1.0",
1958
+ "resolved": "https://registry.npmjs.org/@protobufjs/pool/-/pool-1.1.0.tgz",
1959
+ "integrity": "sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw==",
1960
+ "license": "BSD-3-Clause"
1961
+ },
1962
+ "node_modules/@protobufjs/utf8": {
1963
+ "version": "1.1.0",
1964
+ "resolved": "https://registry.npmjs.org/@protobufjs/utf8/-/utf8-1.1.0.tgz",
1965
+ "integrity": "sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==",
1966
+ "license": "BSD-3-Clause"
1967
+ },
1968
  "node_modules/@types/debug": {
1969
  "version": "4.1.12",
1970
  "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.12.tgz",
 
2019
  "integrity": "sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA==",
2020
  "license": "MIT"
2021
  },
2022
+ "node_modules/@types/node": {
2023
+ "version": "24.3.0",
2024
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-24.3.0.tgz",
2025
+ "integrity": "sha512-aPTXCrfwnDLj4VvXrm+UUCQjNEvJgNA8s5F1cvwQU+3KNltTOkBm1j30uNLyqqPNe7gE3KFzImYoZEfLhp4Yow==",
2026
+ "license": "MIT",
2027
+ "dependencies": {
2028
+ "undici-types": "~7.10.0"
2029
+ }
2030
+ },
2031
  "node_modules/@types/trusted-types": {
2032
  "version": "2.0.7",
2033
  "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz",
 
2151
  "url": "https://github.com/sponsors/wooorm"
2152
  }
2153
  },
2154
+ "node_modules/boolean": {
2155
+ "version": "3.2.0",
2156
+ "resolved": "https://registry.npmjs.org/boolean/-/boolean-3.2.0.tgz",
2157
+ "integrity": "sha512-d0II/GO9uf9lfUHH2BQsjxzRJZBdsjgsBiW4BvhWk/3qoKwQFjIDVN19PfX8F2D/r9PCMTtLWjYVCFrpeYUzsw==",
2158
+ "deprecated": "Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.",
2159
+ "license": "MIT"
2160
+ },
2161
  "node_modules/ccount": {
2162
  "version": "2.0.1",
2163
  "resolved": "https://registry.npmjs.org/ccount/-/ccount-2.0.1.tgz",
 
2178
  "url": "https://github.com/sponsors/wooorm"
2179
  }
2180
  },
2181
+ "node_modules/chownr": {
2182
+ "version": "3.0.0",
2183
+ "resolved": "https://registry.npmjs.org/chownr/-/chownr-3.0.0.tgz",
2184
+ "integrity": "sha512-+IxzY9BZOQd/XuYPRmrvEVjF/nqj5kgT4kEq7VofrDoM1MxoRjEWkrCC3EtLi59TVawxTAn+orJwFQcrqEN1+g==",
2185
+ "license": "BlueOak-1.0.0",
2186
+ "engines": {
2187
+ "node": ">=18"
2188
+ }
2189
+ },
2190
  "node_modules/clsx": {
2191
  "version": "2.1.1",
2192
  "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz",
 
2211
  "@codemirror/view": "^6.0.0"
2212
  }
2213
  },
2214
+ "node_modules/color": {
2215
+ "version": "4.2.3",
2216
+ "resolved": "https://registry.npmjs.org/color/-/color-4.2.3.tgz",
2217
+ "integrity": "sha512-1rXeuUUiGGrykh+CeBdu5Ie7OJwinCgQY0bc7GCRxy5xVHy+moaqkpL/jqQq0MtQOeYcrqEz4abc5f0KtU7W4A==",
2218
+ "license": "MIT",
2219
+ "dependencies": {
2220
+ "color-convert": "^2.0.1",
2221
+ "color-string": "^1.9.0"
2222
+ },
2223
+ "engines": {
2224
+ "node": ">=12.5.0"
2225
+ }
2226
+ },
2227
+ "node_modules/color-convert": {
2228
+ "version": "2.0.1",
2229
+ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
2230
+ "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
2231
+ "license": "MIT",
2232
+ "dependencies": {
2233
+ "color-name": "~1.1.4"
2234
+ },
2235
+ "engines": {
2236
+ "node": ">=7.0.0"
2237
+ }
2238
+ },
2239
+ "node_modules/color-name": {
2240
+ "version": "1.1.4",
2241
+ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
2242
+ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
2243
+ "license": "MIT"
2244
+ },
2245
+ "node_modules/color-string": {
2246
+ "version": "1.9.1",
2247
+ "resolved": "https://registry.npmjs.org/color-string/-/color-string-1.9.1.tgz",
2248
+ "integrity": "sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg==",
2249
+ "license": "MIT",
2250
+ "dependencies": {
2251
+ "color-name": "^1.0.0",
2252
+ "simple-swizzle": "^0.2.2"
2253
+ }
2254
+ },
2255
  "node_modules/commander": {
2256
  "version": "8.3.0",
2257
  "resolved": "https://registry.npmjs.org/commander/-/commander-8.3.0.tgz",
 
2303
  "url": "https://github.com/sponsors/wooorm"
2304
  }
2305
  },
2306
+ "node_modules/define-data-property": {
2307
+ "version": "1.1.4",
2308
+ "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz",
2309
+ "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==",
2310
+ "license": "MIT",
2311
+ "dependencies": {
2312
+ "es-define-property": "^1.0.0",
2313
+ "es-errors": "^1.3.0",
2314
+ "gopd": "^1.0.1"
2315
+ },
2316
+ "engines": {
2317
+ "node": ">= 0.4"
2318
+ },
2319
+ "funding": {
2320
+ "url": "https://github.com/sponsors/ljharb"
2321
+ }
2322
+ },
2323
+ "node_modules/define-properties": {
2324
+ "version": "1.2.1",
2325
+ "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.1.tgz",
2326
+ "integrity": "sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==",
2327
+ "license": "MIT",
2328
+ "dependencies": {
2329
+ "define-data-property": "^1.0.1",
2330
+ "has-property-descriptors": "^1.0.0",
2331
+ "object-keys": "^1.1.1"
2332
+ },
2333
+ "engines": {
2334
+ "node": ">= 0.4"
2335
+ },
2336
+ "funding": {
2337
+ "url": "https://github.com/sponsors/ljharb"
2338
+ }
2339
+ },
2340
  "node_modules/dequal": {
2341
  "version": "2.0.3",
2342
  "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz",
 
2346
  "node": ">=6"
2347
  }
2348
  },
2349
+ "node_modules/detect-libc": {
2350
+ "version": "2.0.4",
2351
+ "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.4.tgz",
2352
+ "integrity": "sha512-3UDv+G9CsCKO1WKMGw9fwq/SWJYbI0c5Y7LU1AXYoDdbhE2AHQ6N6Nb34sG8Fj7T5APy8qXDCKuuIHd1BR0tVA==",
2353
+ "license": "Apache-2.0",
2354
+ "engines": {
2355
+ "node": ">=8"
2356
+ }
2357
+ },
2358
+ "node_modules/detect-node": {
2359
+ "version": "2.1.0",
2360
+ "resolved": "https://registry.npmjs.org/detect-node/-/detect-node-2.1.0.tgz",
2361
+ "integrity": "sha512-T0NIuQpnTvFDATNuHN5roPwSBG83rFsuO+MXXH9/3N1eFbn4wcPjttvjMLEPWJ0RGUYgQE7cGgS3tNxbqCGM7g==",
2362
+ "license": "MIT"
2363
+ },
2364
  "node_modules/devlop": {
2365
  "version": "1.1.0",
2366
  "resolved": "https://registry.npmjs.org/devlop/-/devlop-1.1.0.tgz",
 
2395
  "url": "https://github.com/fb55/entities?sponsor=1"
2396
  }
2397
  },
2398
+ "node_modules/es-define-property": {
2399
+ "version": "1.0.1",
2400
+ "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
2401
+ "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==",
2402
+ "license": "MIT",
2403
+ "engines": {
2404
+ "node": ">= 0.4"
2405
+ }
2406
+ },
2407
+ "node_modules/es-errors": {
2408
+ "version": "1.3.0",
2409
+ "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
2410
+ "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
2411
+ "license": "MIT",
2412
+ "engines": {
2413
+ "node": ">= 0.4"
2414
+ }
2415
+ },
2416
+ "node_modules/es6-error": {
2417
+ "version": "4.1.1",
2418
+ "resolved": "https://registry.npmjs.org/es6-error/-/es6-error-4.1.1.tgz",
2419
+ "integrity": "sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg==",
2420
+ "license": "MIT"
2421
+ },
2422
  "node_modules/esbuild": {
2423
  "version": "0.25.9",
2424
  "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.9.tgz",
 
2484
  "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==",
2485
  "license": "MIT"
2486
  },
2487
+ "node_modules/flatbuffers": {
2488
+ "version": "25.2.10",
2489
+ "resolved": "https://registry.npmjs.org/flatbuffers/-/flatbuffers-25.2.10.tgz",
2490
+ "integrity": "sha512-7JlN9ZvLDG1McO3kbX0k4v+SUAg48L1rIwEvN6ZQl/eCtgJz9UylTMzE9wrmYrcorgxm3CX/3T/w5VAub99UUw==",
2491
+ "license": "Apache-2.0"
2492
+ },
2493
+ "node_modules/global-agent": {
2494
+ "version": "3.0.0",
2495
+ "resolved": "https://registry.npmjs.org/global-agent/-/global-agent-3.0.0.tgz",
2496
+ "integrity": "sha512-PT6XReJ+D07JvGoxQMkT6qji/jVNfX/h364XHZOWeRzy64sSFr+xJ5OX7LI3b4MPQzdL4H8Y8M0xzPpsVMwA8Q==",
2497
+ "license": "BSD-3-Clause",
2498
+ "dependencies": {
2499
+ "boolean": "^3.0.1",
2500
+ "es6-error": "^4.1.1",
2501
+ "matcher": "^3.0.0",
2502
+ "roarr": "^2.15.3",
2503
+ "semver": "^7.3.2",
2504
+ "serialize-error": "^7.0.1"
2505
+ },
2506
+ "engines": {
2507
+ "node": ">=10.0"
2508
+ }
2509
+ },
2510
+ "node_modules/globalthis": {
2511
+ "version": "1.0.4",
2512
+ "resolved": "https://registry.npmjs.org/globalthis/-/globalthis-1.0.4.tgz",
2513
+ "integrity": "sha512-DpLKbNU4WylpxJykQujfCcwYWiV/Jhm50Goo0wrVILAv5jOr9d+H+UR3PhSCD2rCCEIg0uc+G+muBTwD54JhDQ==",
2514
+ "license": "MIT",
2515
+ "dependencies": {
2516
+ "define-properties": "^1.2.1",
2517
+ "gopd": "^1.0.1"
2518
+ },
2519
+ "engines": {
2520
+ "node": ">= 0.4"
2521
+ },
2522
+ "funding": {
2523
+ "url": "https://github.com/sponsors/ljharb"
2524
+ }
2525
+ },
2526
+ "node_modules/gopd": {
2527
+ "version": "1.2.0",
2528
+ "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
2529
+ "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",
2530
+ "license": "MIT",
2531
+ "engines": {
2532
+ "node": ">= 0.4"
2533
+ },
2534
+ "funding": {
2535
+ "url": "https://github.com/sponsors/ljharb"
2536
+ }
2537
+ },
2538
+ "node_modules/guid-typescript": {
2539
+ "version": "1.0.9",
2540
+ "resolved": "https://registry.npmjs.org/guid-typescript/-/guid-typescript-1.0.9.tgz",
2541
+ "integrity": "sha512-Y8T4vYhEfwJOTbouREvG+3XDsjr8E3kIr7uf+JZ0BYloFsttiHU0WfvANVsR7TxNUJa/WpCnw/Ino/p+DeBhBQ==",
2542
+ "license": "ISC"
2543
+ },
2544
+ "node_modules/has-property-descriptors": {
2545
+ "version": "1.0.2",
2546
+ "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz",
2547
+ "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==",
2548
+ "license": "MIT",
2549
+ "dependencies": {
2550
+ "es-define-property": "^1.0.0"
2551
+ },
2552
+ "funding": {
2553
+ "url": "https://github.com/sponsors/ljharb"
2554
+ }
2555
+ },
2556
+ "node_modules/is-arrayish": {
2557
+ "version": "0.3.2",
2558
+ "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.3.2.tgz",
2559
+ "integrity": "sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==",
2560
+ "license": "MIT"
2561
+ },
2562
  "node_modules/is-plain-obj": {
2563
  "version": "4.1.0",
2564
  "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-4.1.0.tgz",
 
2571
  "url": "https://github.com/sponsors/sindresorhus"
2572
  }
2573
  },
2574
+ "node_modules/json-stringify-safe": {
2575
+ "version": "5.0.1",
2576
+ "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz",
2577
+ "integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==",
2578
+ "license": "ISC"
2579
+ },
2580
  "node_modules/katex": {
2581
  "version": "0.16.22",
2582
  "resolved": "https://registry.npmjs.org/katex/-/katex-0.16.22.tgz",
 
2599
  "integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==",
2600
  "license": "MIT"
2601
  },
2602
+ "node_modules/long": {
2603
+ "version": "5.3.2",
2604
+ "resolved": "https://registry.npmjs.org/long/-/long-5.3.2.tgz",
2605
+ "integrity": "sha512-mNAgZ1GmyNhD7AuqnTG3/VQ26o760+ZYBPKjPvugO8+nLbYfX6TVpJPseBvopbdY+qpZ/lKUnmEc1LeZYS3QAA==",
2606
+ "license": "Apache-2.0"
2607
+ },
2608
  "node_modules/longest-streak": {
2609
  "version": "3.1.0",
2610
  "resolved": "https://registry.npmjs.org/longest-streak/-/longest-streak-3.1.0.tgz",
 
2634
  "url": "https://github.com/sponsors/wooorm"
2635
  }
2636
  },
2637
+ "node_modules/matcher": {
2638
+ "version": "3.0.0",
2639
+ "resolved": "https://registry.npmjs.org/matcher/-/matcher-3.0.0.tgz",
2640
+ "integrity": "sha512-OkeDaAZ/bQCxeFAozM55PKcKU0yJMPGifLwV4Qgjitu+5MoAfSQN4lsLJeXZ1b8w0x+/Emda6MZgXS1jvsapng==",
2641
+ "license": "MIT",
2642
+ "dependencies": {
2643
+ "escape-string-regexp": "^4.0.0"
2644
+ },
2645
+ "engines": {
2646
+ "node": ">=10"
2647
+ }
2648
+ },
2649
+ "node_modules/matcher/node_modules/escape-string-regexp": {
2650
+ "version": "4.0.0",
2651
+ "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz",
2652
+ "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==",
2653
+ "license": "MIT",
2654
+ "engines": {
2655
+ "node": ">=10"
2656
+ },
2657
+ "funding": {
2658
+ "url": "https://github.com/sponsors/sindresorhus"
2659
+ }
2660
+ },
2661
  "node_modules/mdast-util-definitions": {
2662
  "version": "6.0.0",
2663
  "resolved": "https://registry.npmjs.org/mdast-util-definitions/-/mdast-util-definitions-6.0.0.tgz",
 
3463
  ],
3464
  "license": "MIT"
3465
  },
3466
+ "node_modules/minipass": {
3467
+ "version": "7.1.2",
3468
+ "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz",
3469
+ "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==",
3470
+ "license": "ISC",
3471
+ "engines": {
3472
+ "node": ">=16 || 14 >=14.17"
3473
+ }
3474
+ },
3475
+ "node_modules/minizlib": {
3476
+ "version": "3.0.2",
3477
+ "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-3.0.2.tgz",
3478
+ "integrity": "sha512-oG62iEk+CYt5Xj2YqI5Xi9xWUeZhDI8jjQmC5oThVH5JGCTgIjr7ciJDzC7MBzYd//WvR1OTmP5Q38Q8ShQtVA==",
3479
+ "license": "MIT",
3480
+ "dependencies": {
3481
+ "minipass": "^7.1.2"
3482
+ },
3483
+ "engines": {
3484
+ "node": ">= 18"
3485
+ }
3486
+ },
3487
+ "node_modules/mkdirp": {
3488
+ "version": "3.0.1",
3489
+ "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-3.0.1.tgz",
3490
+ "integrity": "sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg==",
3491
+ "license": "MIT",
3492
+ "bin": {
3493
+ "mkdirp": "dist/cjs/src/bin.js"
3494
+ },
3495
+ "engines": {
3496
+ "node": ">=10"
3497
+ },
3498
+ "funding": {
3499
+ "url": "https://github.com/sponsors/isaacs"
3500
+ }
3501
+ },
3502
  "node_modules/ms": {
3503
  "version": "2.1.3",
3504
  "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
 
3523
  "node": "^18 || >=20"
3524
  }
3525
  },
3526
+ "node_modules/object-keys": {
3527
+ "version": "1.1.1",
3528
+ "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz",
3529
+ "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==",
3530
+ "license": "MIT",
3531
+ "engines": {
3532
+ "node": ">= 0.4"
3533
+ }
3534
+ },
3535
+ "node_modules/onnxruntime-common": {
3536
+ "version": "1.21.0",
3537
+ "resolved": "https://registry.npmjs.org/onnxruntime-common/-/onnxruntime-common-1.21.0.tgz",
3538
+ "integrity": "sha512-Q632iLLrtCAVOTO65dh2+mNbQir/QNTVBG3h/QdZBpns7mZ0RYbLRBgGABPbpU9351AgYy7SJf1WaeVwMrBFPQ==",
3539
+ "license": "MIT"
3540
+ },
3541
+ "node_modules/onnxruntime-node": {
3542
+ "version": "1.21.0",
3543
+ "resolved": "https://registry.npmjs.org/onnxruntime-node/-/onnxruntime-node-1.21.0.tgz",
3544
+ "integrity": "sha512-NeaCX6WW2L8cRCSqy3bInlo5ojjQqu2fD3D+9W5qb5irwxhEyWKXeH2vZ8W9r6VxaMPUan+4/7NDwZMtouZxEw==",
3545
+ "hasInstallScript": true,
3546
+ "license": "MIT",
3547
+ "os": [
3548
+ "win32",
3549
+ "darwin",
3550
+ "linux"
3551
+ ],
3552
+ "dependencies": {
3553
+ "global-agent": "^3.0.0",
3554
+ "onnxruntime-common": "1.21.0",
3555
+ "tar": "^7.0.1"
3556
+ }
3557
+ },
3558
+ "node_modules/onnxruntime-web": {
3559
+ "version": "1.22.0-dev.20250409-89f8206ba4",
3560
+ "resolved": "https://registry.npmjs.org/onnxruntime-web/-/onnxruntime-web-1.22.0-dev.20250409-89f8206ba4.tgz",
3561
+ "integrity": "sha512-0uS76OPgH0hWCPrFKlL8kYVV7ckM7t/36HfbgoFw6Nd0CZVVbQC4PkrR8mBX8LtNUFZO25IQBqV2Hx2ho3FlbQ==",
3562
+ "license": "MIT",
3563
+ "dependencies": {
3564
+ "flatbuffers": "^25.1.24",
3565
+ "guid-typescript": "^1.0.9",
3566
+ "long": "^5.2.3",
3567
+ "onnxruntime-common": "1.22.0-dev.20250409-89f8206ba4",
3568
+ "platform": "^1.3.6",
3569
+ "protobufjs": "^7.2.4"
3570
+ }
3571
+ },
3572
+ "node_modules/onnxruntime-web/node_modules/onnxruntime-common": {
3573
+ "version": "1.22.0-dev.20250409-89f8206ba4",
3574
+ "resolved": "https://registry.npmjs.org/onnxruntime-common/-/onnxruntime-common-1.22.0-dev.20250409-89f8206ba4.tgz",
3575
+ "integrity": "sha512-vDJMkfCfb0b1A836rgHj+ORuZf4B4+cc2bASQtpeoJLueuFc5DuYwjIZUBrSvx/fO5IrLjLz+oTrB3pcGlhovQ==",
3576
+ "license": "MIT"
3577
+ },
3578
  "node_modules/orderedmap": {
3579
  "version": "2.1.1",
3580
  "resolved": "https://registry.npmjs.org/orderedmap/-/orderedmap-2.1.1.tgz",
 
3587
  "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",
3588
  "license": "ISC"
3589
  },
3590
+ "node_modules/platform": {
3591
+ "version": "1.3.6",
3592
+ "resolved": "https://registry.npmjs.org/platform/-/platform-1.3.6.tgz",
3593
+ "integrity": "sha512-fnWVljUchTro6RiCFvCXBbNhJc2NijN7oIQxbwsyL0buWJPG85v81ehlHI9fXrJsMNgTofEoWIQeClKpgxFLrg==",
3594
+ "license": "MIT"
3595
+ },
3596
  "node_modules/postcss": {
3597
  "version": "8.5.6",
3598
  "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.6.tgz",
 
3816
  }
3817
  }
3818
  },
3819
+ "node_modules/protobufjs": {
3820
+ "version": "7.5.4",
3821
+ "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-7.5.4.tgz",
3822
+ "integrity": "sha512-CvexbZtbov6jW2eXAvLukXjXUW1TzFaivC46BpWc/3BpcCysb5Vffu+B3XHMm8lVEuy2Mm4XGex8hBSg1yapPg==",
3823
+ "hasInstallScript": true,
3824
+ "license": "BSD-3-Clause",
3825
+ "dependencies": {
3826
+ "@protobufjs/aspromise": "^1.1.2",
3827
+ "@protobufjs/base64": "^1.1.2",
3828
+ "@protobufjs/codegen": "^2.0.4",
3829
+ "@protobufjs/eventemitter": "^1.1.0",
3830
+ "@protobufjs/fetch": "^1.1.0",
3831
+ "@protobufjs/float": "^1.0.2",
3832
+ "@protobufjs/inquire": "^1.1.0",
3833
+ "@protobufjs/path": "^1.1.2",
3834
+ "@protobufjs/pool": "^1.1.0",
3835
+ "@protobufjs/utf8": "^1.1.0",
3836
+ "@types/node": ">=13.7.0",
3837
+ "long": "^5.0.0"
3838
+ },
3839
+ "engines": {
3840
+ "node": ">=12.0.0"
3841
+ }
3842
+ },
3843
  "node_modules/remark": {
3844
  "version": "15.0.1",
3845
  "resolved": "https://registry.npmjs.org/remark/-/remark-15.0.1.tgz",
 
3936
  "url": "https://opencollective.com/unified"
3937
  }
3938
  },
3939
+ "node_modules/roarr": {
3940
+ "version": "2.15.4",
3941
+ "resolved": "https://registry.npmjs.org/roarr/-/roarr-2.15.4.tgz",
3942
+ "integrity": "sha512-CHhPh+UNHD2GTXNYhPWLnU8ONHdI+5DI+4EYIAOaiD63rHeYlZvyh8P+in5999TTSFgUYuKUAjzRI4mdh/p+2A==",
3943
+ "license": "BSD-3-Clause",
3944
+ "dependencies": {
3945
+ "boolean": "^3.0.1",
3946
+ "detect-node": "^2.0.4",
3947
+ "globalthis": "^1.0.1",
3948
+ "json-stringify-safe": "^5.0.1",
3949
+ "semver-compare": "^1.0.0",
3950
+ "sprintf-js": "^1.1.2"
3951
+ },
3952
+ "engines": {
3953
+ "node": ">=8.0"
3954
+ }
3955
+ },
3956
  "node_modules/rope-sequence": {
3957
  "version": "1.3.4",
3958
  "resolved": "https://registry.npmjs.org/rope-sequence/-/rope-sequence-1.3.4.tgz",
3959
  "integrity": "sha512-UT5EDe2cu2E/6O4igUr5PSFs23nvvukicWHx6GnOPlHAiiYbzNuCRQCuiUdHJQcqKalLKlrYJnjY0ySGsXNQXQ==",
3960
  "license": "MIT"
3961
  },
3962
+ "node_modules/semver": {
3963
+ "version": "7.7.2",
3964
+ "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz",
3965
+ "integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==",
3966
+ "license": "ISC",
3967
+ "bin": {
3968
+ "semver": "bin/semver.js"
3969
+ },
3970
+ "engines": {
3971
+ "node": ">=10"
3972
+ }
3973
+ },
3974
+ "node_modules/semver-compare": {
3975
+ "version": "1.0.0",
3976
+ "resolved": "https://registry.npmjs.org/semver-compare/-/semver-compare-1.0.0.tgz",
3977
+ "integrity": "sha512-YM3/ITh2MJ5MtzaM429anh+x2jiLVjqILF4m4oyQB18W7Ggea7BfqdH/wGMK7dDiMghv/6WG7znWMwUDzJiXow==",
3978
+ "license": "MIT"
3979
+ },
3980
+ "node_modules/serialize-error": {
3981
+ "version": "7.0.1",
3982
+ "resolved": "https://registry.npmjs.org/serialize-error/-/serialize-error-7.0.1.tgz",
3983
+ "integrity": "sha512-8I8TjW5KMOKsZQTvoxjuSIa7foAwPWGOts+6o7sgjz41/qMD9VQHEDxi6PBvK2l0MXUmqZyNpUK+T2tQaaElvw==",
3984
+ "license": "MIT",
3985
+ "dependencies": {
3986
+ "type-fest": "^0.13.1"
3987
+ },
3988
+ "engines": {
3989
+ "node": ">=10"
3990
+ },
3991
+ "funding": {
3992
+ "url": "https://github.com/sponsors/sindresorhus"
3993
+ }
3994
+ },
3995
+ "node_modules/sharp": {
3996
+ "version": "0.34.3",
3997
+ "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.34.3.tgz",
3998
+ "integrity": "sha512-eX2IQ6nFohW4DbvHIOLRB3MHFpYqaqvXd3Tp5e/T/dSH83fxaNJQRvDMhASmkNTsNTVF2/OOopzRCt7xokgPfg==",
3999
+ "hasInstallScript": true,
4000
+ "license": "Apache-2.0",
4001
+ "dependencies": {
4002
+ "color": "^4.2.3",
4003
+ "detect-libc": "^2.0.4",
4004
+ "semver": "^7.7.2"
4005
+ },
4006
+ "engines": {
4007
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
4008
+ },
4009
+ "funding": {
4010
+ "url": "https://opencollective.com/libvips"
4011
+ },
4012
+ "optionalDependencies": {
4013
+ "@img/sharp-darwin-arm64": "0.34.3",
4014
+ "@img/sharp-darwin-x64": "0.34.3",
4015
+ "@img/sharp-libvips-darwin-arm64": "1.2.0",
4016
+ "@img/sharp-libvips-darwin-x64": "1.2.0",
4017
+ "@img/sharp-libvips-linux-arm": "1.2.0",
4018
+ "@img/sharp-libvips-linux-arm64": "1.2.0",
4019
+ "@img/sharp-libvips-linux-ppc64": "1.2.0",
4020
+ "@img/sharp-libvips-linux-s390x": "1.2.0",
4021
+ "@img/sharp-libvips-linux-x64": "1.2.0",
4022
+ "@img/sharp-libvips-linuxmusl-arm64": "1.2.0",
4023
+ "@img/sharp-libvips-linuxmusl-x64": "1.2.0",
4024
+ "@img/sharp-linux-arm": "0.34.3",
4025
+ "@img/sharp-linux-arm64": "0.34.3",
4026
+ "@img/sharp-linux-ppc64": "0.34.3",
4027
+ "@img/sharp-linux-s390x": "0.34.3",
4028
+ "@img/sharp-linux-x64": "0.34.3",
4029
+ "@img/sharp-linuxmusl-arm64": "0.34.3",
4030
+ "@img/sharp-linuxmusl-x64": "0.34.3",
4031
+ "@img/sharp-wasm32": "0.34.3",
4032
+ "@img/sharp-win32-arm64": "0.34.3",
4033
+ "@img/sharp-win32-ia32": "0.34.3",
4034
+ "@img/sharp-win32-x64": "0.34.3"
4035
+ }
4036
+ },
4037
+ "node_modules/simple-swizzle": {
4038
+ "version": "0.2.2",
4039
+ "resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz",
4040
+ "integrity": "sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg==",
4041
+ "license": "MIT",
4042
+ "dependencies": {
4043
+ "is-arrayish": "^0.3.1"
4044
+ }
4045
+ },
4046
  "node_modules/source-map-js": {
4047
  "version": "1.2.1",
4048
  "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz",
 
4052
  "node": ">=0.10.0"
4053
  }
4054
  },
4055
+ "node_modules/sprintf-js": {
4056
+ "version": "1.1.3",
4057
+ "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.3.tgz",
4058
+ "integrity": "sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA==",
4059
+ "license": "BSD-3-Clause"
4060
+ },
4061
  "node_modules/style-mod": {
4062
  "version": "4.1.2",
4063
  "resolved": "https://registry.npmjs.org/style-mod/-/style-mod-4.1.2.tgz",
4064
  "integrity": "sha512-wnD1HyVqpJUI2+eKZ+eo1UwghftP6yuFheBqqe+bWCotBjC2K1YnteJILRMs3SM4V/0dLEW1SC27MWP5y+mwmw==",
4065
  "license": "MIT"
4066
  },
4067
+ "node_modules/tar": {
4068
+ "version": "7.4.3",
4069
+ "resolved": "https://registry.npmjs.org/tar/-/tar-7.4.3.tgz",
4070
+ "integrity": "sha512-5S7Va8hKfV7W5U6g3aYxXmlPoZVAwUMy9AOKyF2fVuZa2UD3qZjg578OrLRt8PcNN1PleVaL/5/yYATNL0ICUw==",
4071
+ "license": "ISC",
4072
+ "dependencies": {
4073
+ "@isaacs/fs-minipass": "^4.0.0",
4074
+ "chownr": "^3.0.0",
4075
+ "minipass": "^7.1.2",
4076
+ "minizlib": "^3.0.1",
4077
+ "mkdirp": "^3.0.1",
4078
+ "yallist": "^5.0.0"
4079
+ },
4080
+ "engines": {
4081
+ "node": ">=18"
4082
+ }
4083
+ },
4084
  "node_modules/trough": {
4085
  "version": "2.2.0",
4086
  "resolved": "https://registry.npmjs.org/trough/-/trough-2.2.0.tgz",
 
4097
  "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
4098
  "license": "0BSD"
4099
  },
4100
+ "node_modules/type-fest": {
4101
+ "version": "0.13.1",
4102
+ "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.13.1.tgz",
4103
+ "integrity": "sha512-34R7HTnG0XIJcBSn5XhDd7nNFPRcXYRZrBB2O2jdKqYODldSzBAqzsWoZYYvduky73toYS/ESqxPvkDf/F0XMg==",
4104
+ "license": "(MIT OR CC0-1.0)",
4105
+ "engines": {
4106
+ "node": ">=10"
4107
+ },
4108
+ "funding": {
4109
+ "url": "https://github.com/sponsors/sindresorhus"
4110
+ }
4111
+ },
4112
+ "node_modules/undici-types": {
4113
+ "version": "7.10.0",
4114
+ "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.10.0.tgz",
4115
+ "integrity": "sha512-t5Fy/nfn+14LuOc2KNYg75vZqClpAiqscVvMygNnlsHBFpSXdJaYtXMcdNLpl/Qvc3P2cB3s6lOV51nqsFq4ag==",
4116
+ "license": "MIT"
4117
+ },
4118
  "node_modules/unified": {
4119
  "version": "11.0.5",
4120
  "resolved": "https://registry.npmjs.org/unified/-/unified-11.0.5.tgz",
 
4258
  "integrity": "sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ==",
4259
  "license": "MIT"
4260
  },
4261
+ "node_modules/yallist": {
4262
+ "version": "5.0.0",
4263
+ "resolved": "https://registry.npmjs.org/yallist/-/yallist-5.0.0.tgz",
4264
+ "integrity": "sha512-YgvUTfwqyc7UXVMrB+SImsVYSmTS8X/tSrtdNZMImM+n7+QTriRXyXim0mBrTXNeqzVF0KWGgHPeiyViFFrNDw==",
4265
+ "license": "BlueOak-1.0.0",
4266
+ "engines": {
4267
+ "node": ">=18"
4268
+ }
4269
+ },
4270
  "node_modules/zwitch": {
4271
  "version": "2.0.4",
4272
  "resolved": "https://registry.npmjs.org/zwitch/-/zwitch-2.0.4.tgz",
package.json CHANGED
@@ -1,6 +1,6 @@
1
  {
2
  "name": "localm",
3
- "version": "1.0.5",
4
  "description": "",
5
  "main": "chat-full.js",
6
  "scripts": {
@@ -21,6 +21,7 @@
21
  },
22
  "homepage": "https://github.com/oyin-bo/localm#readme",
23
  "dependencies": {
 
24
  "@milkdown/crepe": "^7.15.3",
25
  "esbuild": "^0.25.9"
26
  }
 
1
  {
2
  "name": "localm",
3
+ "version": "1.0.6",
4
  "description": "",
5
  "main": "chat-full.js",
6
  "scripts": {
 
21
  },
22
  "homepage": "https://github.com/oyin-bo/localm#readme",
23
  "dependencies": {
24
+ "@huggingface/transformers": "^3.7.2",
25
  "@milkdown/crepe": "^7.15.3",
26
  "esbuild": "^0.25.9"
27
  }
src/app/boot-app.js CHANGED
@@ -1,11 +1,10 @@
1
  // @ts-check
2
 
3
- import { editorViewCtx, parserCtx, serializerCtx, commandsCtx } from '@milkdown/core';
4
- import { $command, $useKeymap } from '@milkdown/utils';
5
  import { initHTML } from './init-html';
6
  import { initMilkdown } from './init-milkdown';
7
  import { outputMessage } from './output-message';
8
- import { makeEnterPlugins } from './enter-key';
9
 
10
  /** @type {import('@milkdown/core').Editor} */
11
  export var chatLogEditor;
@@ -13,9 +12,11 @@ export var chatLogEditor;
13
  /** @type {import('@milkdown/core').Editor} */
14
  export var chatInputEditor;
15
 
 
16
 
17
  export async function bootApp() {
18
  const { chatLog, chatInput } = initHTML();
 
19
  const { chatLogEditor: chatLogEditorInstance, chatInputEditor: chatInputEditorInstance } = await initMilkdown({
20
  chatLog,
21
  chatInput,
 
1
  // @ts-check
2
 
3
+ import { makeEnterPlugins } from './enter-key';
 
4
  import { initHTML } from './init-html';
5
  import { initMilkdown } from './init-milkdown';
6
  import { outputMessage } from './output-message';
7
+ import { workerConnection } from './worker-connection';
8
 
9
  /** @type {import('@milkdown/core').Editor} */
10
  export var chatLogEditor;
 
12
  /** @type {import('@milkdown/core').Editor} */
13
  export var chatInputEditor;
14
 
15
+ export var worker;
16
 
17
  export async function bootApp() {
18
  const { chatLog, chatInput } = initHTML();
19
+ worker = workerConnection();
20
  const { chatLogEditor: chatLogEditorInstance, chatInputEditor: chatInputEditorInstance } = await initMilkdown({
21
  chatLog,
22
  chatInput,
src/app/enter-key.js CHANGED
@@ -8,7 +8,6 @@ import {
8
  } from '@milkdown/core';
9
  import { $command, $useKeymap } from '@milkdown/utils';
10
 
11
- import { outputMessage } from './output-message';
12
  import { handlePrompt } from './handle-prompt';
13
 
14
  export function makeEnterPlugins() {
 
8
  } from '@milkdown/core';
9
  import { $command, $useKeymap } from '@milkdown/utils';
10
 
 
11
  import { handlePrompt } from './handle-prompt';
12
 
13
  export function makeEnterPlugins() {
src/app/worker-connection.js ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-check
2
+
3
+ export function workerConnection() {
4
+ // TODO: load worker and expose an API for the rest of app to use
5
+
6
+ const workerLoaded = loadWorker();
7
+
8
+ const connection = {
9
+ listModels,
10
+ loadModel,
11
+ runPrompt
12
+ };
13
+
14
+ return connection;
15
+
16
+ function loadWorker() {
17
+ // Create a worker from the same URL as the currently executing script.
18
+ // We locate the current script URL via document.currentScript when in the window context.
19
+ // Build a blob that imports this script and calls bootWorker when executed inside a worker.
20
+ return new Promise((resolve, reject) => {
21
+ try {
22
+ const scriptUrl = (typeof document !== 'undefined' && (document.currentScript && document.currentScript.src)) ||
23
+ (typeof document !== 'undefined' && document.scripts && document.scripts[document.scripts.length - 1] && document.scripts[document.scripts.length - 1].src) ||
24
+ (typeof window !== 'undefined' && window.location && window.location.href) || '';
25
+
26
+ const worker = new Worker(scriptUrl, { type: 'module' });
27
+
28
+ const pending = new Map();
29
+ let ready = false;
30
+
31
+ worker.addEventListener('message', (ev) => {
32
+ const msg = ev.data || {};
33
+ if (msg && msg.type === 'ready') {
34
+ ready = true;
35
+ resolve({ worker: worker, pending, send });
36
+ return;
37
+ }
38
+
39
+ if (msg && msg.id) {
40
+ const id = msg.id;
41
+ const entry = pending.get(id);
42
+ if (!entry) return;
43
+ pending.delete(id);
44
+ if (msg.type === 'response') entry.resolve(msg.result);
45
+ else if (msg.type === 'error') entry.reject(new Error(msg.error));
46
+ else entry.resolve(msg);
47
+ }
48
+ });
49
+
50
+ worker.addEventListener('error', (err) => {
51
+ if (!ready) reject(err);
52
+ });
53
+
54
+ function send(message) {
55
+ return new Promise((res, rej) => {
56
+ const id = String(Math.random()).slice(2);
57
+ pending.set(id, { resolve: res, reject: rej });
58
+ worker.postMessage(Object.assign({}, message, { id }));
59
+ });
60
+ }
61
+ } catch (err) {
62
+ reject(err);
63
+ }
64
+ });
65
+ }
66
+
67
+ async function listModels() {
68
+ await workerLoaded;
69
+ const { send } = await workerLoaded;
70
+ return send({ type: 'listModels' });
71
+ }
72
+
73
+ /** @param {string} modelName */
74
+ async function loadModel(modelName) {
75
+ await workerLoaded;
76
+ const { send } = await workerLoaded;
77
+ return send({ type: 'loadModel', model: modelName });
78
+ }
79
+
80
+ /**
81
+ * @param {string} promptText
82
+ * @param {string} modelName
83
+ */
84
+ async function runPrompt(promptText, modelName) {
85
+ await workerLoaded;
86
+ const { send } = await workerLoaded;
87
+ return send({ type: 'runPrompt', prompt: promptText, model: modelName });
88
+ }
89
+ }
src/index.js CHANGED
@@ -1,8 +1,13 @@
1
  // @ts-check
2
-
3
- import { bootApp } from './app/boot-app';
4
 
5
  if (typeof window !== 'undefined' && typeof window?.alert === 'function'
6
  && typeof document !== 'undefined' && typeof document?.createElement === 'function') {
7
- bootApp();
 
 
 
 
 
 
8
  }
 
1
  // @ts-check
2
+ /// <reference lib="webworker" />
 
3
 
4
  if (typeof window !== 'undefined' && typeof window?.alert === 'function'
5
  && typeof document !== 'undefined' && typeof document?.createElement === 'function') {
6
+ import('./app/boot-app.js').then(({ bootApp }) => {
7
+ bootApp();
8
+ });
9
+ } else if (typeof WorkerGlobalScope === 'function' && self instanceof WorkerGlobalScope) {
10
+ import('./worker/boot-worker.js').then(({ bootWorker }) => {
11
+ bootWorker();
12
+ });
13
  }
src/worker/boot-worker.js ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-check
2
+
3
+ // Use a normal static import from the official package. This keeps import semantics
4
+ // predictable and lets your bundler (esbuild) resolve the package during build.
5
+ import * as hf from '@huggingface/transformers';
6
+
7
+ export function bootWorker() {
8
+ // Report starting
9
+ try {
10
+ self.postMessage({ type: 'status', status: 'initializing' });
11
+ } catch (e) {
12
+ // ignore if postMessage not available for some reason
13
+ }
14
+
15
+ (async () => {
16
+ // Use the imported @huggingface/transformers module
17
+ let transformersLib = hf;
18
+ try {
19
+ if (!transformersLib) throw new Error('transformers module not available');
20
+ self.postMessage({ type: 'status', status: 'transformers-loaded', source: '@huggingface/transformers' });
21
+ } catch (err) {
22
+ self.postMessage({ type: 'status', status: 'transformers-load-failed', error: String(err) });
23
+ }
24
+
25
+ // Minimal in-worker state for later model operations
26
+ const availableModels = ['dummy-model'];
27
+ let currentModel = null;
28
+
29
+ // signal ready to main thread
30
+ self.postMessage({ type: 'ready' });
31
+
32
+ // handle incoming requests from the UI thread
33
+ self.addEventListener('message', async (ev) => {
34
+ const msg = ev.data || {};
35
+ const id = msg.id;
36
+ try {
37
+ if (msg.type === 'listModels') {
38
+ self.postMessage({ id, type: 'response', result: availableModels });
39
+ } else if (msg.type === 'loadModel') {
40
+ const modelName = msg.model;
41
+ // TODO: replace with real model loading code using transformersLib
42
+ await new Promise((r) => setTimeout(r, 150));
43
+ currentModel = modelName;
44
+ self.postMessage({ id, type: 'response', result: { model: modelName, status: 'loaded' } });
45
+ } else if (msg.type === 'runPrompt') {
46
+ const prompt = msg.prompt || '';
47
+ // TODO: run the prompt with transformersLib pipeline once integrated
48
+ const text = `Worker(${currentModel || 'no-model'}): ${prompt}`;
49
+ self.postMessage({ id, type: 'response', result: text });
50
+ } else {
51
+ if (id) self.postMessage({ id, type: 'error', error: 'unknown-message-type' });
52
+ }
53
+ } catch (err) {
54
+ if (id) self.postMessage({ id, type: 'error', error: String(err) });
55
+ }
56
+ });
57
+ })();
58
+ }