@lvce-editor/chat-message-parsing-worker 1.7.0 → 1.8.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.
@@ -1018,6 +1018,404 @@ const initialize = async (_, port) => {
1018
1018
  await handleMessagePort(port);
1019
1019
  };
1020
1020
 
1021
+ const createMockRpc = ({
1022
+ commandMap
1023
+ }) => {
1024
+ const invocations = [];
1025
+ const invoke = (method, ...params) => {
1026
+ invocations.push([method, ...params]);
1027
+ const command = commandMap[method];
1028
+ if (!command) {
1029
+ throw new Error(`command ${method} not found`);
1030
+ }
1031
+ return command(...params);
1032
+ };
1033
+ const mockRpc = {
1034
+ invocations,
1035
+ invoke,
1036
+ invokeAndTransfer: invoke
1037
+ };
1038
+ return mockRpc;
1039
+ };
1040
+
1041
+ const rpcs = Object.create(null);
1042
+ const set$1 = (id, rpc) => {
1043
+ rpcs[id] = rpc;
1044
+ };
1045
+ const get = id => {
1046
+ return rpcs[id];
1047
+ };
1048
+ const remove = id => {
1049
+ delete rpcs[id];
1050
+ };
1051
+
1052
+ /* eslint-disable @typescript-eslint/explicit-function-return-type */
1053
+ const create = rpcId => {
1054
+ return {
1055
+ async dispose() {
1056
+ const rpc = get(rpcId);
1057
+ await rpc.dispose();
1058
+ },
1059
+ // @ts-ignore
1060
+ invoke(method, ...params) {
1061
+ const rpc = get(rpcId);
1062
+ // @ts-ignore
1063
+ return rpc.invoke(method, ...params);
1064
+ },
1065
+ // @ts-ignore
1066
+ invokeAndTransfer(method, ...params) {
1067
+ const rpc = get(rpcId);
1068
+ // @ts-ignore
1069
+ return rpc.invokeAndTransfer(method, ...params);
1070
+ },
1071
+ registerMockRpc(commandMap) {
1072
+ const mockRpc = createMockRpc({
1073
+ commandMap
1074
+ });
1075
+ set$1(rpcId, mockRpc);
1076
+ // @ts-ignore
1077
+ mockRpc[Symbol.dispose] = () => {
1078
+ remove(rpcId);
1079
+ };
1080
+ // @ts-ignore
1081
+ return mockRpc;
1082
+ },
1083
+ set(rpc) {
1084
+ set$1(rpcId, rpc);
1085
+ }
1086
+ };
1087
+ };
1088
+
1089
+ const {
1090
+ invoke,
1091
+ set
1092
+ } = create(6007);
1093
+ const getMathBlockDom = async node => {
1094
+ return invoke('ChatMath.getMathBlockDom', node);
1095
+ };
1096
+ const getMathInlineDom = async node => {
1097
+ return invoke('ChatMath.getMathInlineDom', node);
1098
+ };
1099
+
1100
+ const RendererWorker = 1;
1101
+
1102
+ const {
1103
+ invokeAndTransfer} = create(RendererWorker);
1104
+ const sendMessagePortToChatMathWorker$1 = async (port, rpcId) => {
1105
+ const command = 'HandleMessagePort.handleMessagePort';
1106
+ await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToChatMathWorker', port, command, rpcId);
1107
+ };
1108
+
1109
+ const parseMathInline = async children => {
1110
+ const nextChildren = [];
1111
+ for (const child of children) {
1112
+ if (child.type === 'math-inline') {
1113
+ const dom = await getMathInlineDom(child);
1114
+ nextChildren.push({
1115
+ dom,
1116
+ type: 'math-inline-dom'
1117
+ });
1118
+ continue;
1119
+ }
1120
+ if (child.type === 'bold') {
1121
+ nextChildren.push({
1122
+ ...child,
1123
+ children: await parseMathInline(child.children)
1124
+ });
1125
+ continue;
1126
+ }
1127
+ if (child.type === 'italic') {
1128
+ nextChildren.push({
1129
+ ...child,
1130
+ children: await parseMathInline(child.children)
1131
+ });
1132
+ continue;
1133
+ }
1134
+ if (child.type === 'strikethrough') {
1135
+ nextChildren.push({
1136
+ ...child,
1137
+ children: await parseMathInline(child.children)
1138
+ });
1139
+ continue;
1140
+ }
1141
+ nextChildren.push(child);
1142
+ }
1143
+ return nextChildren;
1144
+ };
1145
+ const parseMathListItem = async item => {
1146
+ const children = await parseMathInline(item.children);
1147
+ if (!item.nestedItems) {
1148
+ return {
1149
+ ...item,
1150
+ children
1151
+ };
1152
+ }
1153
+ const nestedItems = [];
1154
+ for (const nestedItem of item.nestedItems) {
1155
+ nestedItems.push(await parseMathListItem(nestedItem));
1156
+ }
1157
+ return {
1158
+ ...item,
1159
+ children,
1160
+ nestedItems
1161
+ };
1162
+ };
1163
+ const parseMathTableCell = async cell => {
1164
+ return {
1165
+ ...cell,
1166
+ children: await parseMathInline(cell.children)
1167
+ };
1168
+ };
1169
+ const parseMathNode = async node => {
1170
+ if (node.type === 'math-block') {
1171
+ const dom = await getMathBlockDom(node);
1172
+ return {
1173
+ dom,
1174
+ type: 'math-block-dom'
1175
+ };
1176
+ }
1177
+ if (node.type === 'text' || node.type === 'heading') {
1178
+ return {
1179
+ ...node,
1180
+ children: await parseMathInline(node.children)
1181
+ };
1182
+ }
1183
+ if (node.type === 'blockquote') {
1184
+ const children = [];
1185
+ for (const child of node.children) {
1186
+ children.push(await parseMathNode(child));
1187
+ }
1188
+ return {
1189
+ ...node,
1190
+ children
1191
+ };
1192
+ }
1193
+ if (node.type === 'ordered-list' || node.type === 'unordered-list') {
1194
+ const items = [];
1195
+ for (const item of node.items) {
1196
+ items.push(await parseMathListItem(item));
1197
+ }
1198
+ return {
1199
+ ...node,
1200
+ items
1201
+ };
1202
+ }
1203
+ if (node.type === 'table') {
1204
+ const headers = [];
1205
+ for (const header of node.headers) {
1206
+ headers.push(await parseMathTableCell(header));
1207
+ }
1208
+ const rows = [];
1209
+ for (const row of node.rows) {
1210
+ const cells = [];
1211
+ for (const cell of row.cells) {
1212
+ cells.push(await parseMathTableCell(cell));
1213
+ }
1214
+ rows.push({
1215
+ ...row,
1216
+ cells
1217
+ });
1218
+ }
1219
+ return {
1220
+ ...node,
1221
+ headers,
1222
+ rows
1223
+ };
1224
+ }
1225
+ return node;
1226
+ };
1227
+
1228
+ const TokenAttribute = 'TokenAttribute';
1229
+ const TokenComment = 'TokenComment';
1230
+ const TokenKeyword = 'TokenKeyword';
1231
+ const TokenNumber = 'TokenNumber';
1232
+ const TokenProperty = 'TokenProperty';
1233
+ const TokenString = 'TokenString';
1234
+ const TokenTag = 'TokenTag';
1235
+ const TokenValue = 'TokenValue';
1236
+
1237
+ const jsRules = [{
1238
+ className: TokenComment,
1239
+ regex: /\/\/[^\n]*/
1240
+ }, {
1241
+ className: TokenComment,
1242
+ regex: /\/\*[\s\S]*?\*\//
1243
+ }, {
1244
+ className: TokenString,
1245
+ regex: /"[^"\\]*(?:\\.[^"\\]*)*"/
1246
+ }, {
1247
+ className: TokenString,
1248
+ regex: /'[^'\\]*(?:\\.[^'\\]*)*'/
1249
+ }, {
1250
+ className: TokenString,
1251
+ regex: /`[^`\\]*(?:\\.[^`\\]*)*`/
1252
+ }, {
1253
+ className: TokenNumber,
1254
+ regex: /\b\d+\.?\d*\b/
1255
+ }, {
1256
+ className: TokenKeyword,
1257
+ regex: /\b(?:const|let|var|function|return|if|else|for|while|class|new|typeof|instanceof|import|export|from|default|async|await|try|catch|finally|throw|this|true|false|null|undefined)\b/
1258
+ }];
1259
+ const tsRules = [{
1260
+ className: TokenComment,
1261
+ regex: /\/\/[^\n]*/
1262
+ }, {
1263
+ className: TokenComment,
1264
+ regex: /\/\*[\s\S]*?\*\//
1265
+ }, {
1266
+ className: TokenString,
1267
+ regex: /"[^"\\]*(?:\\.[^"\\]*)*"/
1268
+ }, {
1269
+ className: TokenString,
1270
+ regex: /'[^'\\]*(?:\\.[^'\\]*)*'/
1271
+ }, {
1272
+ className: TokenString,
1273
+ regex: /`[^`\\]*(?:\\.[^`\\]*)*`/
1274
+ }, {
1275
+ className: TokenNumber,
1276
+ regex: /\b\d+\.?\d*\b/
1277
+ }, {
1278
+ className: TokenKeyword,
1279
+ regex: /\b(?:abstract|any|as|asserts|async|await|boolean|class|const|constructor|declare|default|enum|export|extends|false|finally|for|from|function|get|if|implements|import|in|infer|instanceof|interface|is|keyof|let|module|namespace|never|new|null|number|object|override|private|protected|public|readonly|return|satisfies|set|static|string|super|switch|symbol|this|throw|true|try|type|typeof|undefined|unknown|var|void|while)\b/
1280
+ }];
1281
+ const htmlRules = [{
1282
+ className: TokenComment,
1283
+ regex: /<!--[\s\S]*?-->/
1284
+ }, {
1285
+ className: TokenTag,
1286
+ regex: /<\/[a-zA-Z][a-zA-Z0-9-]*\s*>/
1287
+ }, {
1288
+ className: TokenTag,
1289
+ regex: /<[a-zA-Z][a-zA-Z0-9-]*/
1290
+ }, {
1291
+ className: TokenTag,
1292
+ regex: /\/?>/
1293
+ }, {
1294
+ className: TokenString,
1295
+ regex: /"[^"]*"/
1296
+ }, {
1297
+ className: TokenString,
1298
+ regex: /'[^']*'/
1299
+ }, {
1300
+ className: TokenAttribute,
1301
+ regex: /[a-zA-Z-]+(?=\s*=)/
1302
+ }];
1303
+ const cssRules = [{
1304
+ className: TokenComment,
1305
+ regex: /\/\*[\s\S]*?\*\//
1306
+ }, {
1307
+ className: TokenString,
1308
+ regex: /"[^"]*"/
1309
+ }, {
1310
+ className: TokenString,
1311
+ regex: /'[^']*'/
1312
+ }, {
1313
+ className: TokenValue,
1314
+ regex: /#[0-9a-fA-F]{3,8}/
1315
+ }, {
1316
+ className: TokenValue,
1317
+ regex: /\b\d+(?:\.\d+)?(?:px|em|rem|%|vh|vw|pt|s|ms|fr)?\b/
1318
+ }, {
1319
+ className: TokenProperty,
1320
+ regex: /[a-zA-Z-]+(?=\s*:)/
1321
+ }];
1322
+ const pythonRules = [{
1323
+ className: TokenComment,
1324
+ regex: /#[^\n]*/
1325
+ }, {
1326
+ className: TokenString,
1327
+ regex: /"[^"\\]*(?:\\.[^"\\]*)*"/
1328
+ }, {
1329
+ className: TokenString,
1330
+ regex: /'[^'\\]*(?:\\.[^'\\]*)*'/
1331
+ }, {
1332
+ className: TokenNumber,
1333
+ regex: /\b\d+\.?\d*\b/
1334
+ }, {
1335
+ className: TokenKeyword,
1336
+ regex: /\b(?:def|class|return|if|elif|else|for|while|in|import|from|as|with|try|except|finally|raise|lambda|yield|pass|break|continue|True|False|None|and|or|not|is)\b/
1337
+ }];
1338
+ const jsonRules = [{
1339
+ className: TokenProperty,
1340
+ regex: /"[^"\\]*(?:\\.[^"\\]*)*"(?=\s*:)/
1341
+ }, {
1342
+ className: TokenString,
1343
+ regex: /"[^"\\]*(?:\\.[^"\\]*)*"/
1344
+ }, {
1345
+ className: TokenNumber,
1346
+ regex: /-?\b\d+\.?\d*(?:[eE][+-]?\d+)?\b/
1347
+ }, {
1348
+ className: TokenKeyword,
1349
+ regex: /\b(?:true|false|null)\b/
1350
+ }];
1351
+ const tokenize = (code, rules) => {
1352
+ const tokens = [];
1353
+ let pos = 0;
1354
+ while (pos < code.length) {
1355
+ let matched = false;
1356
+ for (const rule of rules) {
1357
+ const match = rule.regex.exec(code.slice(pos));
1358
+ if (match && match.index === 0) {
1359
+ tokens.push({
1360
+ className: rule.className,
1361
+ text: match[0]
1362
+ });
1363
+ pos += match[0].length;
1364
+ matched = true;
1365
+ break;
1366
+ }
1367
+ }
1368
+ if (!matched) {
1369
+ const last = tokens.at(-1);
1370
+ if (last && last.className === '') {
1371
+ tokens.pop();
1372
+ tokens.push({
1373
+ className: '',
1374
+ text: last.text + code[pos]
1375
+ });
1376
+ } else {
1377
+ tokens.push({
1378
+ className: '',
1379
+ text: code[pos]
1380
+ });
1381
+ }
1382
+ pos++;
1383
+ }
1384
+ }
1385
+ return tokens;
1386
+ };
1387
+ const highlightCode = (code, language) => {
1388
+ if (!language) {
1389
+ return [{
1390
+ className: '',
1391
+ text: code
1392
+ }];
1393
+ }
1394
+ const normalized = language.toLowerCase();
1395
+ if (normalized === 'html') {
1396
+ return tokenize(code, htmlRules);
1397
+ }
1398
+ if (normalized === 'css') {
1399
+ return tokenize(code, cssRules);
1400
+ }
1401
+ if (normalized === 'js' || normalized === 'javascript') {
1402
+ return tokenize(code, jsRules);
1403
+ }
1404
+ if (normalized === 'ts' || normalized === 'typescript') {
1405
+ return tokenize(code, tsRules);
1406
+ }
1407
+ if (normalized === 'py' || normalized === 'python') {
1408
+ return tokenize(code, pythonRules);
1409
+ }
1410
+ if (normalized === 'json') {
1411
+ return tokenize(code, jsonRules);
1412
+ }
1413
+ return [{
1414
+ className: '',
1415
+ text: code
1416
+ }];
1417
+ };
1418
+
1021
1419
  const windowsAbsolutePathRegex = /^[a-zA-Z]:[\\/]/;
1022
1420
  const pathSeparatorRegex$1 = /[\\/]/;
1023
1421
  const isPathTraversalAttempt = path => {
@@ -1738,8 +2136,6 @@ const getEmptyTextNode = () => {
1738
2136
  type: 'text'
1739
2137
  }];
1740
2138
  };
1741
-
1742
- // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
1743
2139
  const parseBlockTokens = tokens => {
1744
2140
  if (tokens.length === 0) {
1745
2141
  return getEmptyTextNode();
@@ -1749,6 +2145,16 @@ const parseBlockTokens = tokens => {
1749
2145
  let listItems = [];
1750
2146
  let listType = '';
1751
2147
  let orderedListPathStack = [];
2148
+ let canContinueOrderedListItemParagraph = false;
2149
+ const createListItem = (text, index) => {
2150
+ return {
2151
+ children: parseInlineNodes(text),
2152
+ ...(index === undefined ? {} : {
2153
+ index
2154
+ }),
2155
+ type: 'list-item'
2156
+ };
2157
+ };
1752
2158
  const getListItemAtPath = (items, path) => {
1753
2159
  let currentItems = items;
1754
2160
  let currentItem;
@@ -1778,6 +2184,29 @@ const parseBlockTokens = tokens => {
1778
2184
  };
1779
2185
  return [...items.slice(0, index), nextItem, ...items.slice(index + 1)];
1780
2186
  };
2187
+ const appendInlineChildrenAtPath = (items, path, children) => {
2188
+ if (path.length === 0) {
2189
+ return [...items];
2190
+ }
2191
+ const [index, ...rest] = path;
2192
+ const current = items[index];
2193
+ if (!current) {
2194
+ return [...items];
2195
+ }
2196
+ const lineBreakNode = {
2197
+ text: '\n',
2198
+ type: 'text'
2199
+ };
2200
+ const nextChildren = [...current.children, lineBreakNode, ...children];
2201
+ const nextItem = rest.length > 0 ? {
2202
+ ...current,
2203
+ nestedItems: appendInlineChildrenAtPath(current.nestedItems || [], rest, children)
2204
+ } : {
2205
+ ...current,
2206
+ children: nextChildren
2207
+ };
2208
+ return [...items.slice(0, index), nextItem, ...items.slice(index + 1)];
2209
+ };
1781
2210
  const flushParagraph = () => {
1782
2211
  if (paragraphLines.length === 0) {
1783
2212
  return;
@@ -1799,11 +2228,13 @@ const parseBlockTokens = tokens => {
1799
2228
  listItems = [];
1800
2229
  listType = '';
1801
2230
  orderedListPathStack = [];
2231
+ canContinueOrderedListItemParagraph = false;
1802
2232
  };
1803
2233
  for (let i = 0; i < tokens.length; i++) {
1804
2234
  const token = tokens[i];
1805
2235
  if (token.type === 'blank-line') {
1806
2236
  flushParagraph();
2237
+ canContinueOrderedListItemParagraph = false;
1807
2238
  continue;
1808
2239
  }
1809
2240
  if (token.type === 'code-block') {
@@ -1811,12 +2242,14 @@ const parseBlockTokens = tokens => {
1811
2242
  flushParagraph();
1812
2243
  if (token.language) {
1813
2244
  nodes.push({
2245
+ codeTokens: highlightCode(token.text, token.language),
1814
2246
  language: token.language,
1815
2247
  text: token.text,
1816
2248
  type: 'code-block'
1817
2249
  });
1818
2250
  } else {
1819
2251
  nodes.push({
2252
+ codeTokens: highlightCode(token.text, undefined),
1820
2253
  text: token.text,
1821
2254
  type: 'code-block'
1822
2255
  });
@@ -1893,17 +2326,15 @@ const parseBlockTokens = tokens => {
1893
2326
  if (parentEntry) {
1894
2327
  const parentItem = getListItemAtPath(listItems, parentEntry.path);
1895
2328
  if (parentItem) {
1896
- const nextItem = {
1897
- children: parseInlineNodes(token.text),
1898
- type: 'list-item'
1899
- };
1900
2329
  const nextIndex = parentItem.nestedItems?.length || 0;
2330
+ const nextItem = createListItem(token.text, nextIndex + 1);
1901
2331
  listItems = appendNestedItemAtPath(listItems, parentEntry.path, nextItem, 'ordered-list');
1902
2332
  const nextPath = [...parentEntry.path, nextIndex];
1903
2333
  orderedListPathStack = [...orderedListPathStack.filter(entry => entry.indentation < token.indentation), {
1904
2334
  indentation: token.indentation,
1905
2335
  path: nextPath
1906
2336
  }];
2337
+ canContinueOrderedListItemParagraph = true;
1907
2338
  continue;
1908
2339
  }
1909
2340
  }
@@ -1913,27 +2344,23 @@ const parseBlockTokens = tokens => {
1913
2344
  }
1914
2345
  flushParagraph();
1915
2346
  listType = 'ordered-list';
1916
- const nextItem = {
1917
- children: parseInlineNodes(token.text),
1918
- type: 'list-item'
1919
- };
2347
+ const nextIndex = listItems.length;
2348
+ const nextItem = createListItem(token.text, nextIndex + 1);
1920
2349
  listItems.push(nextItem);
1921
- const nextIndex = listItems.length - 1;
1922
2350
  orderedListPathStack = [...orderedListPathStack.filter(entry => entry.indentation < token.indentation), {
1923
2351
  indentation: token.indentation,
1924
2352
  path: [nextIndex]
1925
2353
  }];
2354
+ canContinueOrderedListItemParagraph = true;
1926
2355
  continue;
1927
2356
  }
1928
2357
  if (token.type === 'unordered-list-item-line') {
1929
2358
  if (listType === 'ordered-list' && listItems.length > 0 && token.indentation > 0 && orderedListPathStack.length > 0) {
1930
2359
  const parentEntry = orderedListPathStack.toReversed().find(entry => entry.indentation < token.indentation);
1931
2360
  if (parentEntry) {
1932
- const nextItem = {
1933
- children: parseInlineNodes(token.text),
1934
- type: 'list-item'
1935
- };
2361
+ const nextItem = createListItem(token.text);
1936
2362
  listItems = appendNestedItemAtPath(listItems, parentEntry.path, nextItem, 'unordered-list');
2363
+ canContinueOrderedListItemParagraph = false;
1937
2364
  continue;
1938
2365
  }
1939
2366
  }
@@ -1942,10 +2369,8 @@ const parseBlockTokens = tokens => {
1942
2369
  }
1943
2370
  flushParagraph();
1944
2371
  listType = 'unordered-list';
1945
- listItems.push({
1946
- children: parseInlineNodes(token.text),
1947
- type: 'list-item'
1948
- });
2372
+ listItems.push(createListItem(token.text));
2373
+ canContinueOrderedListItemParagraph = false;
1949
2374
  continue;
1950
2375
  }
1951
2376
  if (token.type === 'heading-line') {
@@ -1958,8 +2383,16 @@ const parseBlockTokens = tokens => {
1958
2383
  });
1959
2384
  continue;
1960
2385
  }
2386
+ if (token.type === 'paragraph-line' && listType === 'ordered-list' && listItems.length > 0 && canContinueOrderedListItemParagraph) {
2387
+ const currentPath = orderedListPathStack.at(-1)?.path;
2388
+ if (currentPath) {
2389
+ listItems = appendInlineChildrenAtPath(listItems, currentPath, parseInlineNodes(token.text));
2390
+ continue;
2391
+ }
2392
+ }
1961
2393
  flushList();
1962
2394
  paragraphLines.push(token.text);
2395
+ canContinueOrderedListItemParagraph = false;
1963
2396
  }
1964
2397
  flushList();
1965
2398
  flushParagraph();
@@ -1970,6 +2403,15 @@ const parseMessageContent = rawMessage => {
1970
2403
  return parseBlockTokens(scanBlockTokens(rawMessage));
1971
2404
  };
1972
2405
 
2406
+ const parseMessage = async rawMessage => {
2407
+ const parsedContent = parseMessageContent(rawMessage);
2408
+ const nextParsedContent = [];
2409
+ for (const node of parsedContent) {
2410
+ nextParsedContent.push(await parseMathNode(node));
2411
+ }
2412
+ return nextParsedContent;
2413
+ };
2414
+
1973
2415
  const parseMessageContents = rawMessages => {
1974
2416
  return rawMessages.map(parseMessageContent);
1975
2417
  };
@@ -1977,93 +2419,13 @@ const parseMessageContents = rawMessages => {
1977
2419
  const commandMap = {
1978
2420
  'ChatMessageParsing.parseMessageContent': parseMessageContent,
1979
2421
  'ChatMessageParsing.parseMessageContents': parseMessageContents,
2422
+ 'ChatParser.parseMessage': parseMessage,
1980
2423
  'ChatParser.parseMessageContent': parseMessageContent,
1981
2424
  'ChatParser.parseMessageContents': parseMessageContents,
1982
2425
  'HandleMessagePort.handleMessagePort': handleMessagePort,
1983
2426
  initialize: initialize
1984
2427
  };
1985
2428
 
1986
- const createMockRpc = ({
1987
- commandMap
1988
- }) => {
1989
- const invocations = [];
1990
- const invoke = (method, ...params) => {
1991
- invocations.push([method, ...params]);
1992
- const command = commandMap[method];
1993
- if (!command) {
1994
- throw new Error(`command ${method} not found`);
1995
- }
1996
- return command(...params);
1997
- };
1998
- const mockRpc = {
1999
- invocations,
2000
- invoke,
2001
- invokeAndTransfer: invoke
2002
- };
2003
- return mockRpc;
2004
- };
2005
-
2006
- const rpcs = Object.create(null);
2007
- const set$1 = (id, rpc) => {
2008
- rpcs[id] = rpc;
2009
- };
2010
- const get = id => {
2011
- return rpcs[id];
2012
- };
2013
- const remove = id => {
2014
- delete rpcs[id];
2015
- };
2016
-
2017
- /* eslint-disable @typescript-eslint/explicit-function-return-type */
2018
- const create = rpcId => {
2019
- return {
2020
- async dispose() {
2021
- const rpc = get(rpcId);
2022
- await rpc.dispose();
2023
- },
2024
- // @ts-ignore
2025
- invoke(method, ...params) {
2026
- const rpc = get(rpcId);
2027
- // @ts-ignore
2028
- return rpc.invoke(method, ...params);
2029
- },
2030
- // @ts-ignore
2031
- invokeAndTransfer(method, ...params) {
2032
- const rpc = get(rpcId);
2033
- // @ts-ignore
2034
- return rpc.invokeAndTransfer(method, ...params);
2035
- },
2036
- registerMockRpc(commandMap) {
2037
- const mockRpc = createMockRpc({
2038
- commandMap
2039
- });
2040
- set$1(rpcId, mockRpc);
2041
- // @ts-ignore
2042
- mockRpc[Symbol.dispose] = () => {
2043
- remove(rpcId);
2044
- };
2045
- // @ts-ignore
2046
- return mockRpc;
2047
- },
2048
- set(rpc) {
2049
- set$1(rpcId, rpc);
2050
- }
2051
- };
2052
- };
2053
-
2054
- const {
2055
- set
2056
- } = create(6007);
2057
-
2058
- const RendererWorker = 1;
2059
-
2060
- const {
2061
- invokeAndTransfer} = create(RendererWorker);
2062
- const sendMessagePortToChatMathWorker$1 = async (port, rpcId) => {
2063
- const command = 'HandleMessagePort.handleMessagePort';
2064
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToChatMathWorker', port, command, rpcId);
2065
- };
2066
-
2067
2429
  const sendMessagePortToChatMathWorker = async port => {
2068
2430
  await sendMessagePortToChatMathWorker$1(port, 0);
2069
2431
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/chat-message-parsing-worker",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "description": "Chat Message Parsing Worker",
5
5
  "repository": {
6
6
  "type": "git",