@lvce-editor/editor-worker 5.12.0 → 5.15.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.
@@ -236,6 +236,34 @@ const getNewDeltaPercent = (height, scrollBarHeight, relativeY) => {
236
236
  };
237
237
  };
238
238
 
239
+ // TODO this should be in a separate scrolling module
240
+ const setDeltaY$3 = (state, value) => {
241
+ object(state);
242
+ number(value);
243
+ const {
244
+ finalDeltaY,
245
+ deltaY,
246
+ numberOfVisibleLines,
247
+ height,
248
+ scrollBarHeight,
249
+ itemHeight
250
+ } = state;
251
+ const newDeltaY = clamp(value, 0, finalDeltaY);
252
+ if (deltaY === newDeltaY) {
253
+ return state;
254
+ }
255
+ const newMinLineY = Math.floor(newDeltaY / itemHeight);
256
+ const newMaxLineY = newMinLineY + numberOfVisibleLines;
257
+ const scrollBarY = getScrollBarY(newDeltaY, finalDeltaY, height, scrollBarHeight);
258
+ return {
259
+ ...state,
260
+ minLineY: newMinLineY,
261
+ maxLineY: newMaxLineY,
262
+ deltaY: newDeltaY,
263
+ scrollBarY
264
+ };
265
+ };
266
+
239
267
  const splitLines$2 = lines => {
240
268
  if (!lines) {
241
269
  return [];
@@ -424,34 +452,6 @@ const positionAt = (textDocument, offset) => {
424
452
  };
425
453
  };
426
454
 
427
- // TODO this should be in a separate scrolling module
428
- const setDeltaY$3 = (state, value) => {
429
- object(state);
430
- number(value);
431
- const {
432
- finalDeltaY,
433
- deltaY,
434
- numberOfVisibleLines,
435
- height,
436
- scrollBarHeight,
437
- itemHeight
438
- } = state;
439
- const newDeltaY = clamp(value, 0, finalDeltaY);
440
- if (deltaY === newDeltaY) {
441
- return state;
442
- }
443
- const newMinLineY = Math.floor(newDeltaY / itemHeight);
444
- const newMaxLineY = newMinLineY + numberOfVisibleLines;
445
- const scrollBarY = getScrollBarY(newDeltaY, finalDeltaY, height, scrollBarHeight);
446
- return {
447
- ...state,
448
- minLineY: newMinLineY,
449
- maxLineY: newMaxLineY,
450
- deltaY: newDeltaY,
451
- scrollBarY
452
- };
453
- };
454
-
455
455
  const getSelectionPairs = (selections, i) => {
456
456
  const first = selections[i];
457
457
  const second = selections[i + 1];
@@ -464,7 +464,7 @@ const getSelectionPairs = (selections, i) => {
464
464
  };
465
465
 
466
466
  const EmptyString$1 = '';
467
- const NewLine$4 = '\n';
467
+ const NewLine$3 = '\n';
468
468
  const Space$2 = ' ';
469
469
  const Tab$1 = '\t';
470
470
  const DoubleQuote$1 = '"';
@@ -500,15 +500,15 @@ const createMeasureContext = () => {
500
500
  return ctx;
501
501
  };
502
502
 
503
- const state$a = {
503
+ const state$9 = {
504
504
  ctx: undefined
505
505
  };
506
506
  const getOrCreate = createCtx => {
507
- if (state$a.ctx) {
508
- return state$a.ctx;
507
+ if (state$9.ctx) {
508
+ return state$9.ctx;
509
509
  }
510
- state$a.ctx = createCtx();
511
- return state$a.ctx;
510
+ state$9.ctx = createCtx();
511
+ return state$9.ctx;
512
512
  };
513
513
 
514
514
  const getContext = () => {
@@ -1053,25 +1053,20 @@ const TabCompletionExecuteTabCompletionProvider = 'ExtensionHost.executeTabCompl
1053
1053
  const TextDocumentSyncFull = 'ExtensionHostTextDocument.syncFull';
1054
1054
 
1055
1055
  const Two = '2.0';
1056
- const state$9 = {
1057
- callbacks: Object.create(null)
1058
- };
1056
+ const callbacks = Object.create(null);
1059
1057
  const set$5 = (id, fn) => {
1060
- state$9.callbacks[id] = fn;
1058
+ callbacks[id] = fn;
1061
1059
  };
1062
1060
  const get$5 = id => {
1063
- return state$9.callbacks[id];
1061
+ return callbacks[id];
1064
1062
  };
1065
1063
  const remove$8 = id => {
1066
- delete state$9.callbacks[id];
1064
+ delete callbacks[id];
1067
1065
  };
1068
1066
  let id = 0;
1069
1067
  const create$3$1 = () => {
1070
1068
  return ++id;
1071
1069
  };
1072
- const warn$1 = (...args) => {
1073
- console.warn(...args);
1074
- };
1075
1070
  const registerPromise = () => {
1076
1071
  const id = create$3$1();
1077
1072
  const {
@@ -1084,16 +1079,6 @@ const registerPromise = () => {
1084
1079
  promise
1085
1080
  };
1086
1081
  };
1087
- const resolve = (id, response) => {
1088
- const fn = get$5(id);
1089
- if (!fn) {
1090
- console.log(response);
1091
- warn$1(`callback ${id} may already be disposed`);
1092
- return;
1093
- }
1094
- fn(response);
1095
- remove$8(id);
1096
- };
1097
1082
  const create$2$1 = (method, params) => {
1098
1083
  const {
1099
1084
  id,
@@ -1116,7 +1101,7 @@ class JsonRpcError extends Error {
1116
1101
  this.name = 'JsonRpcError';
1117
1102
  }
1118
1103
  }
1119
- const NewLine$3 = '\n';
1104
+ const NewLine$2 = '\n';
1120
1105
  const DomException = 'DOMException';
1121
1106
  const ReferenceError$1 = 'ReferenceError';
1122
1107
  const SyntaxError$1 = 'SyntaxError';
@@ -1161,23 +1146,23 @@ const constructError = (message, type, name) => {
1161
1146
  }
1162
1147
  return new ErrorConstructor(message);
1163
1148
  };
1164
- const getNewLineIndex$2 = (string, startIndex = undefined) => {
1165
- return string.indexOf(NewLine$3, startIndex);
1149
+ const getNewLineIndex$1 = (string, startIndex = undefined) => {
1150
+ return string.indexOf(NewLine$2, startIndex);
1166
1151
  };
1167
1152
  const getParentStack = error => {
1168
1153
  let parentStack = error.stack || error.data || error.message || '';
1169
1154
  if (parentStack.startsWith(' at')) {
1170
- parentStack = error.message + NewLine$3 + parentStack;
1155
+ parentStack = error.message + NewLine$2 + parentStack;
1171
1156
  }
1172
1157
  return parentStack;
1173
1158
  };
1174
1159
  const joinLines$1 = lines => {
1175
- return lines.join(NewLine$3);
1160
+ return lines.join(NewLine$2);
1176
1161
  };
1177
1162
  const MethodNotFound = -32601;
1178
1163
  const Custom = -32001;
1179
1164
  const splitLines$1 = lines => {
1180
- return lines.split(NewLine$3);
1165
+ return lines.split(NewLine$2);
1181
1166
  };
1182
1167
  const restoreJsonRpcError = error => {
1183
1168
  if (error && error instanceof Error) {
@@ -1187,14 +1172,14 @@ const restoreJsonRpcError = error => {
1187
1172
  if (error && error.code && error.code === MethodNotFound) {
1188
1173
  const restoredError = new JsonRpcError(error.message);
1189
1174
  const parentStack = getParentStack(error);
1190
- restoredError.stack = parentStack + NewLine$3 + currentStack;
1175
+ restoredError.stack = parentStack + NewLine$2 + currentStack;
1191
1176
  return restoredError;
1192
1177
  }
1193
1178
  if (error && error.message) {
1194
1179
  const restoredError = constructError(error.message, error.type, error.name);
1195
1180
  if (error.data) {
1196
1181
  if (error.data.stack && error.data.type && error.message) {
1197
- restoredError.stack = error.data.type + ': ' + error.message + NewLine$3 + error.data.stack + NewLine$3 + currentStack;
1182
+ restoredError.stack = error.data.type + ': ' + error.message + NewLine$2 + error.data.stack + NewLine$2 + currentStack;
1198
1183
  } else if (error.data.stack) {
1199
1184
  restoredError.stack = error.data.stack;
1200
1185
  }
@@ -1214,7 +1199,7 @@ const restoreJsonRpcError = error => {
1214
1199
  if (error.stack) {
1215
1200
  const lowerStack = restoredError.stack || '';
1216
1201
  // @ts-ignore
1217
- const indexNewLine = getNewLineIndex$2(lowerStack);
1202
+ const indexNewLine = getNewLineIndex$1(lowerStack);
1218
1203
  const parentStack = getParentStack(error);
1219
1204
  // @ts-ignore
1220
1205
  restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
@@ -1241,6 +1226,19 @@ const unwrapJsonRpcResult = responseMessage => {
1241
1226
  }
1242
1227
  throw new JsonRpcError('unexpected response message');
1243
1228
  };
1229
+ const warn$1 = (...args) => {
1230
+ console.warn(...args);
1231
+ };
1232
+ const resolve = (id, response) => {
1233
+ const fn = get$5(id);
1234
+ if (!fn) {
1235
+ console.log(response);
1236
+ warn$1(`callback ${id} may already be disposed`);
1237
+ return;
1238
+ }
1239
+ fn(response);
1240
+ remove$8(id);
1241
+ };
1244
1242
  const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
1245
1243
  const getErrorType = prettyError => {
1246
1244
  if (prettyError && prettyError.type) {
@@ -1459,7 +1457,7 @@ const invokeAndTransfer$1 = async (method, ...params) => {
1459
1457
  const ipc = get$4();
1460
1458
  return invokeAndTransfer$2(ipc, method, ...params);
1461
1459
  };
1462
- const listen$7 = ipc => {
1460
+ const listen$5 = ipc => {
1463
1461
  set$4(ipc);
1464
1462
  };
1465
1463
 
@@ -1551,8 +1549,8 @@ const IpcParentWithExtensionHostWorker = {
1551
1549
  wrap: wrap$2
1552
1550
  };
1553
1551
 
1554
- const sendMessagePortToSyntaxHighlightingWorker = async port => {
1555
- await invokeAndTransfer('SendMessagePortToSyntaxHighlightingWorker.sendMessagePortToSyntaxHighlightingWorker', port, 'HandleMessagePort.handleMessagePort');
1552
+ const sendMessagePortToRendererProcess = async port => {
1553
+ await invokeAndTransfer('SendMessagePortToRendererProcess.sendMessagePortToRendererProcess', port, 'HandleMessagePort.handleMessagePort');
1556
1554
  };
1557
1555
 
1558
1556
  const create$c = async () => {
@@ -1560,7 +1558,7 @@ const create$c = async () => {
1560
1558
  port1,
1561
1559
  port2
1562
1560
  } = getPortTuple();
1563
- await sendMessagePortToSyntaxHighlightingWorker(port1);
1561
+ await sendMessagePortToRendererProcess(port1);
1564
1562
  const event = await waitForFirstMessage$1(port2);
1565
1563
  if (event.data !== 'ready') {
1566
1564
  throw new IpcError$1('unexpected first message');
@@ -1598,14 +1596,14 @@ const wrap$1 = port => {
1598
1596
  };
1599
1597
  };
1600
1598
 
1601
- const IpcParentWithSyntaxHighlightingWorker = {
1599
+ const IpcParentWithRendererProcess = {
1602
1600
  __proto__: null,
1603
1601
  create: create$c,
1604
1602
  wrap: wrap$1
1605
1603
  };
1606
1604
 
1607
- const sendMessagePortToRendererProcess = async port => {
1608
- await invokeAndTransfer('SendMessagePortToRendererProcess.sendMessagePortToRendererProcess', port, 'HandleMessagePort.handleMessagePort');
1605
+ const sendMessagePortToSyntaxHighlightingWorker = async port => {
1606
+ await invokeAndTransfer('SendMessagePortToSyntaxHighlightingWorker.sendMessagePortToSyntaxHighlightingWorker', port, 'HandleMessagePort.handleMessagePort');
1609
1607
  };
1610
1608
 
1611
1609
  const create$b = async () => {
@@ -1613,7 +1611,7 @@ const create$b = async () => {
1613
1611
  port1,
1614
1612
  port2
1615
1613
  } = getPortTuple();
1616
- await sendMessagePortToRendererProcess(port1);
1614
+ await sendMessagePortToSyntaxHighlightingWorker(port1);
1617
1615
  const event = await waitForFirstMessage$1(port2);
1618
1616
  if (event.data !== 'ready') {
1619
1617
  throw new IpcError$1('unexpected first message');
@@ -1651,7 +1649,7 @@ const wrap = port => {
1651
1649
  };
1652
1650
  };
1653
1651
 
1654
- const IpcParentWithRendererProcess = {
1652
+ const IpcParentWithSyntaxHighlightingWorker = {
1655
1653
  __proto__: null,
1656
1654
  create: create$b,
1657
1655
  wrap
@@ -1704,7 +1702,7 @@ const createRpc = method => {
1704
1702
  };
1705
1703
 
1706
1704
  const {
1707
- listen: listen$6,
1705
+ listen: listen$4,
1708
1706
  invoke: invoke$2
1709
1707
  } = createRpc(ExtensionHostWorker);
1710
1708
 
@@ -2366,16 +2364,6 @@ const cancelSelection = editor => {
2366
2364
  return scheduleSelections(editor, newSelections);
2367
2365
  };
2368
2366
 
2369
- // TODO use numeric widget id
2370
- const CodeGenerator = 1;
2371
- const ColorPicker$1 = 2;
2372
- const Completion = 3;
2373
- const CompletionDetail = 4;
2374
- const Find = 5;
2375
- const Hover = 6;
2376
- const Rename = 7;
2377
- const SourceAction = 8;
2378
-
2379
2367
  const getIndex = (widgets, id) => {
2380
2368
  for (const [i, widget] of widgets.entries()) {
2381
2369
  if (widget.id === id) {
@@ -2390,6 +2378,15 @@ const removeEditorWidget = (widgets, id) => {
2390
2378
  return newWidgets;
2391
2379
  };
2392
2380
 
2381
+ const CodeGenerator = 1;
2382
+ const ColorPicker$1 = 2;
2383
+ const Completion = 3;
2384
+ const CompletionDetail = 4;
2385
+ const Find = 5;
2386
+ const Hover = 6;
2387
+ const Rename = 7;
2388
+ const SourceAction = 8;
2389
+
2393
2390
  const isMatchingWidget$2 = widget => {
2394
2391
  return widget.id === CodeGenerator;
2395
2392
  };
@@ -2621,7 +2618,7 @@ const compositionEnd = (editor, data) => {
2621
2618
  return scheduleDocumentAndCursorsSelections(editor, changes);
2622
2619
  };
2623
2620
 
2624
- const normalizeLine$1 = line => {
2621
+ const normalizeLine = line => {
2625
2622
  if (line.startsWith('Error: ')) {
2626
2623
  return line.slice('Error: '.length);
2627
2624
  }
@@ -2630,41 +2627,41 @@ const normalizeLine$1 = line => {
2630
2627
  }
2631
2628
  return line;
2632
2629
  };
2633
- const getCombinedMessage$1 = (error, message) => {
2634
- const stringifiedError = normalizeLine$1(`${error}`);
2630
+ const getCombinedMessage = (error, message) => {
2631
+ const stringifiedError = normalizeLine(`${error}`);
2635
2632
  if (message) {
2636
2633
  return `${message}: ${stringifiedError}`;
2637
2634
  }
2638
2635
  return stringifiedError;
2639
2636
  };
2640
- const NewLine$2 = '\n';
2641
- const getNewLineIndex$1 = (string, startIndex = undefined) => {
2642
- return string.indexOf(NewLine$2, startIndex);
2637
+ const NewLine$1 = '\n';
2638
+ const getNewLineIndex = (string, startIndex = undefined) => {
2639
+ return string.indexOf(NewLine$1, startIndex);
2643
2640
  };
2644
- const mergeStacks$1 = (parent, child) => {
2641
+ const mergeStacks = (parent, child) => {
2645
2642
  if (!child) {
2646
2643
  return parent;
2647
2644
  }
2648
- const parentNewLineIndex = getNewLineIndex$1(parent);
2649
- const childNewLineIndex = getNewLineIndex$1(child);
2645
+ const parentNewLineIndex = getNewLineIndex(parent);
2646
+ const childNewLineIndex = getNewLineIndex(child);
2650
2647
  if (childNewLineIndex === -1) {
2651
2648
  return parent;
2652
2649
  }
2653
2650
  const parentFirstLine = parent.slice(0, parentNewLineIndex);
2654
2651
  const childRest = child.slice(childNewLineIndex);
2655
- const childFirstLine = normalizeLine$1(child.slice(0, childNewLineIndex));
2652
+ const childFirstLine = normalizeLine(child.slice(0, childNewLineIndex));
2656
2653
  if (parentFirstLine.includes(childFirstLine)) {
2657
2654
  return parentFirstLine + childRest;
2658
2655
  }
2659
2656
  return child;
2660
2657
  };
2661
- let VError$1 = class VError extends Error {
2658
+ class VError extends Error {
2662
2659
  constructor(error, message) {
2663
- const combinedMessage = getCombinedMessage$1(error, message);
2660
+ const combinedMessage = getCombinedMessage(error, message);
2664
2661
  super(combinedMessage);
2665
2662
  this.name = 'VError';
2666
2663
  if (error instanceof Error) {
2667
- this.stack = mergeStacks$1(this.stack, error.stack);
2664
+ this.stack = mergeStacks(this.stack, error.stack);
2668
2665
  }
2669
2666
  if (error.codeFrame) {
2670
2667
  // @ts-ignore
@@ -2675,14 +2672,14 @@ let VError$1 = class VError extends Error {
2675
2672
  this.code = error.code;
2676
2673
  }
2677
2674
  }
2678
- };
2675
+ }
2679
2676
 
2680
2677
  const writeText = async text => {
2681
2678
  try {
2682
2679
  string(text);
2683
2680
  await invoke$3('ClipBoard.writeText', /* text */text);
2684
2681
  } catch (error) {
2685
- throw new VError$1(error, 'Failed to write text to clipboard');
2682
+ throw new VError(error, 'Failed to write text to clipboard');
2686
2683
  }
2687
2684
  };
2688
2685
 
@@ -3820,9 +3817,6 @@ const setPosition$1 = position => {
3820
3817
  state$5.position = position;
3821
3818
  };
3822
3819
 
3823
- const Ctrl = 1;
3824
- const Alt$1 = 2;
3825
-
3826
3820
  // TODO first change cursor position, then run go to definition
3827
3821
  // cursor should appear at mousedown position immediately
3828
3822
  const handleSingleClickWithAlt = async (editor, position) => {
@@ -3839,6 +3833,7 @@ const handleSingleClickWithAlt = async (editor, position) => {
3839
3833
  const newEditor2 = await goToDefinition(newEditor);
3840
3834
  return newEditor2;
3841
3835
  };
3836
+
3842
3837
  const handleSingleClickWithCtrl = async (editor, position) => {
3843
3838
  const selections = editor.selections;
3844
3839
  for (let i = 0; i < selections.length; i += 4) {
@@ -3862,6 +3857,10 @@ const handleSingleClickWithCtrl = async (editor, position) => {
3862
3857
  newSelections[insertIndex + 3] = position.columnIndex;
3863
3858
  return scheduleSelections(editor, newSelections);
3864
3859
  };
3860
+
3861
+ const Ctrl = 1;
3862
+ const Alt$1 = 2;
3863
+
3865
3864
  const handleSingleClickDefault = (editor, position) => {
3866
3865
  setPosition$1(position);
3867
3866
  return {
@@ -3870,7 +3869,7 @@ const handleSingleClickDefault = (editor, position) => {
3870
3869
  focused: true
3871
3870
  };
3872
3871
  };
3873
- const getFn = modifier => {
3872
+ const getClickHandler = modifier => {
3874
3873
  switch (modifier) {
3875
3874
  case Alt$1:
3876
3875
  return handleSingleClickWithAlt;
@@ -3880,13 +3879,14 @@ const getFn = modifier => {
3880
3879
  return handleSingleClickDefault;
3881
3880
  }
3882
3881
  };
3882
+
3883
3883
  const handleSingleClick = async (editor, modifier, x, y) => {
3884
3884
  object(editor);
3885
3885
  number(modifier);
3886
3886
  number(x);
3887
3887
  number(y);
3888
3888
  const position = at(editor, x, y);
3889
- const fn = getFn(modifier);
3889
+ const fn = getClickHandler(modifier);
3890
3890
  const newEditor = await fn(editor, position);
3891
3891
  // switch (newEditor.completionState) {
3892
3892
  // case EditorCompletionState.None:
@@ -5340,19 +5340,6 @@ const create$4 = () => {
5340
5340
  return widget;
5341
5341
  };
5342
5342
 
5343
- // copied from https://github.com/microsoft/vscode/tree/main/src/vs/base/common/strings.ts by Microsoft (License MIT)
5344
-
5345
- const RE_ESCAPE = /[\\\{\}\*\+\?\|\^\$\.\[\]\(\)]/g;
5346
- const escapeRegExpCharacters = value => {
5347
- return value.replaceAll(RE_ESCAPE, '\\$&');
5348
- };
5349
-
5350
- const regexFlags = 'gi';
5351
- const getSearchRegex = searchString => {
5352
- const escaped = escapeRegExpCharacters(searchString);
5353
- return new RegExp(escaped, regexFlags);
5354
- };
5355
-
5356
5343
  const findRegexMatches = (lines, regex) => {
5357
5344
  if (!regex.global) {
5358
5345
  throw new Error('regex must be global');
@@ -5375,6 +5362,19 @@ const findRegexMatches = (lines, regex) => {
5375
5362
  return new Uint32Array(matches);
5376
5363
  };
5377
5364
 
5365
+ // copied from https://github.com/microsoft/vscode/tree/main/src/vs/base/common/strings.ts by Microsoft (License MIT)
5366
+
5367
+ const RE_ESCAPE = /[\\\{\}\*\+\?\|\^\$\.\[\]\(\)]/g;
5368
+ const escapeRegExpCharacters = value => {
5369
+ return value.replaceAll(RE_ESCAPE, '\\$&');
5370
+ };
5371
+
5372
+ const regexFlags = 'gi';
5373
+ const getSearchRegex = searchString => {
5374
+ const escaped = escapeRegExpCharacters(searchString);
5375
+ return new RegExp(escaped, regexFlags);
5376
+ };
5377
+
5378
5378
  const findMatchesCaseInsensitive = (lines, searchString) => {
5379
5379
  if (searchString.length === 0) {
5380
5380
  return new Uint32Array([]);
@@ -5949,7 +5949,7 @@ const save = async editor => {
5949
5949
  return newEditor;
5950
5950
  } catch (error) {
5951
5951
  // @ts-ignore
5952
- const betterError = new VError$1(error, `Failed to save file "${editor.uri}"`);
5952
+ const betterError = new VError(error, `Failed to save file "${editor.uri}"`);
5953
5953
  await handleError(betterError);
5954
5954
  return editor;
5955
5955
  }
@@ -6238,6 +6238,23 @@ const selectInsideString = editor => {
6238
6238
  return scheduleSelections(editor, newSelections);
6239
6239
  };
6240
6240
 
6241
+ // import * as ExtensionHostSelection from '../ExtensionHost/ExtensionHostSelection.ts'
6242
+
6243
+ const getNewSelections = async (editor, selections) => {
6244
+ const newSelections = await invoke$3('ExtensionHostSelection.executeGrowSelection', editor, selections);
6245
+ if (newSelections.length === 0) {
6246
+ return selections;
6247
+ }
6248
+ return new Uint32Array(newSelections);
6249
+ };
6250
+ const selectionGrow = async editor => {
6251
+ const {
6252
+ selections
6253
+ } = editor;
6254
+ const newSelections = await getNewSelections(editor, selections);
6255
+ return scheduleSelections(editor, newSelections);
6256
+ };
6257
+
6241
6258
  // TODO handle virtual space
6242
6259
 
6243
6260
  // TODO editors behave differently when selecting next occurrence, for example:
@@ -6449,23 +6466,6 @@ const selectWordRight = editor => {
6449
6466
  return editorSelectHorizontalRight(editor, wordRight);
6450
6467
  };
6451
6468
 
6452
- // import * as ExtensionHostSelection from '../ExtensionHost/ExtensionHostSelection.ts'
6453
-
6454
- const getNewSelections = async (editor, selections) => {
6455
- const newSelections = await invoke$3('ExtensionHostSelection.executeGrowSelection', editor, selections);
6456
- if (newSelections.length === 0) {
6457
- return selections;
6458
- }
6459
- return new Uint32Array(newSelections);
6460
- };
6461
- const selectionGrow = async editor => {
6462
- const {
6463
- selections
6464
- } = editor;
6465
- const newSelections = await getNewSelections(editor, selections);
6466
- return scheduleSelections(editor, newSelections);
6467
- };
6468
-
6469
6469
  const setDecorations = (editor, decorations, diagnostics) => {
6470
6470
  if (editor.decorations.length === 0 && decorations.length === 0) {
6471
6471
  return editor;
@@ -6477,6 +6477,19 @@ const setDecorations = (editor, decorations, diagnostics) => {
6477
6477
  };
6478
6478
  };
6479
6479
 
6480
+ let enabled$1 = false;
6481
+ const setEnabled$1 = value => {
6482
+ enabled$1 = value;
6483
+ };
6484
+ const getEnabled$1 = () => {
6485
+ return enabled$1;
6486
+ };
6487
+
6488
+ const {
6489
+ listen: listen$3,
6490
+ invoke: invoke$1
6491
+ } = createRpc(SyntaxHighlightingWorker);
6492
+
6480
6493
  /**
6481
6494
  * @enum number
6482
6495
  */
@@ -6537,19 +6550,6 @@ const isPending = languageId => {
6537
6550
  return languageId in state$1.pending;
6538
6551
  };
6539
6552
 
6540
- let enabled$1 = false;
6541
- const setEnabled$1 = value => {
6542
- enabled$1 = value;
6543
- };
6544
- const getEnabled$1 = () => {
6545
- return enabled$1;
6546
- };
6547
-
6548
- const {
6549
- listen: listen$5,
6550
- invoke: invoke$1
6551
- } = createRpc(SyntaxHighlightingWorker);
6552
-
6553
6553
  const tokenMaps = Object.create(null);
6554
6554
  const set$1 = (languageId, tokenMap) => {
6555
6555
  tokenMaps[languageId] = tokenMap;
@@ -6669,12 +6669,6 @@ const setSelections = (editor, selections) => {
6669
6669
  };
6670
6670
  };
6671
6671
 
6672
- const EditorHover = 'EditorHover';
6673
- const showHover = async state => {
6674
- await invoke$3('Viewlet.openWidget', EditorHover);
6675
- return state;
6676
- };
6677
-
6678
6672
  const create$2 = () => {
6679
6673
  const uid = create$8();
6680
6674
  const widget = {
@@ -6728,7 +6722,7 @@ const getHover = async (editor, offset) => {
6728
6722
  };
6729
6723
 
6730
6724
  let _ipc;
6731
- const listen$4 = async () => {
6725
+ const listen$2 = async () => {
6732
6726
  const ipc = await create$a({
6733
6727
  method: RendererProcess
6734
6728
  });
@@ -6949,6 +6943,12 @@ const showHover2 = async editor => {
6949
6943
  return addWidgetToEditor(Hover, FocusEditorHover, editor, create$2, newStateGenerator);
6950
6944
  };
6951
6945
 
6946
+ const EditorHover = 'EditorHover';
6947
+ const showHover = async state => {
6948
+ await invoke$3('Viewlet.openWidget', EditorHover);
6949
+ return state;
6950
+ };
6951
+
6952
6952
  // TODO ask extension host worker instead
6953
6953
  const getEditorSourceActions = async () => {
6954
6954
  const sourceActions = await invoke$3('GetEditorSourceActions.getEditorSourceActions');
@@ -8142,13 +8142,28 @@ const SourceActionItem = 'SourceActionItem';
8142
8142
  const SourceActionItemFocused = 'SourceActionItemFocused';
8143
8143
  const Viewlet = 'Viewlet';
8144
8144
 
8145
- const Button = 1;
8146
- const Div = 4;
8147
- const Input = 6;
8148
- const Span = 8;
8149
- const Text = 12;
8150
- const Img = 17;
8151
- const TextArea = 62;
8145
+ const HandlePointerDown = 'handlePointerDown';
8146
+ const HandleSashPointerDown = 'handleSashPointerDown';
8147
+ const HandleClose = 'handleClose';
8148
+ const HandleFocusIn = 'handleFocusIn';
8149
+ const HandleClick = 'handleClick';
8150
+ const HandleInput = 'handleInput';
8151
+ const HandleFocus = 'handleFocus';
8152
+ const HandleClickPreviousMatch = 'handleClickPreviousMatch';
8153
+ const HandleClickNextMatch = 'handleClickNextMatch';
8154
+ const HandleClickClose = 'handleClickClose';
8155
+ const HandleClickReplace = 'handleClickReplace';
8156
+ const HandleClickReplaceAll = 'handleClickReplaceAll';
8157
+ const HandleReplaceInput = 'handleReplaceInput';
8158
+ const HandleReplaceFocus = 'handleReplaceFocus';
8159
+
8160
+ const Button = 1;
8161
+ const Div = 4;
8162
+ const Input = 6;
8163
+ const Span = 8;
8164
+ const Text = 12;
8165
+ const Img = 17;
8166
+ const TextArea = 62;
8152
8167
 
8153
8168
  const text = data => {
8154
8169
  return {
@@ -8180,21 +8195,6 @@ const getLineInfosVirtualDom = lineInfos => {
8180
8195
  return dom;
8181
8196
  };
8182
8197
 
8183
- const HandlePointerDown = 'handlePointerDown';
8184
- const HandleSashPointerDown = 'handleSashPointerDown';
8185
- const HandleClose = 'handleClose';
8186
- const HandleFocusIn = 'handleFocusIn';
8187
- const HandleClick = 'handleClick';
8188
- const HandleInput = 'handleInput';
8189
- const HandleFocus = 'handleFocus';
8190
- const HandleClickPreviousMatch = 'handleClickPreviousMatch';
8191
- const HandleClickNextMatch = 'handleClickNextMatch';
8192
- const HandleClickClose = 'handleClickClose';
8193
- const HandleClickReplace = 'handleClickReplace';
8194
- const HandleClickReplaceAll = 'handleClickReplaceAll';
8195
- const HandleReplaceInput = 'handleReplaceInput';
8196
- const HandleReplaceFocus = 'handleReplaceFocus';
8197
-
8198
8198
  const hoverProblemMessage = {
8199
8199
  type: Span,
8200
8200
  className: HoverProblemMessage,
@@ -8478,7 +8478,7 @@ const loadFont = async (fontName, fontUrl) => {
8478
8478
  // @ts-ignore
8479
8479
  fonts.add(fontFace);
8480
8480
  } catch (error) {
8481
- throw new VError$1(error, `Failed to load font ${fontName}`);
8481
+ throw new VError(error, `Failed to load font ${fontName}`);
8482
8482
  }
8483
8483
  };
8484
8484
 
@@ -8984,7 +8984,7 @@ const getText = editorUid => {
8984
8984
  const {
8985
8985
  lines
8986
8986
  } = editor;
8987
- return lines.join(NewLine$4);
8987
+ return lines.join(NewLine$3);
8988
8988
  };
8989
8989
 
8990
8990
  const InsertText = 'insertText';
@@ -9020,15 +9020,15 @@ const getEnabled = () => {
9020
9020
  };
9021
9021
 
9022
9022
  const intialize = async (syntaxHighlightingEnabled, syncIncremental) => {
9023
- await listen$4();
9023
+ await listen$2();
9024
9024
  if (syntaxHighlightingEnabled) {
9025
9025
  setEnabled$1(true);
9026
- await listen$5();
9026
+ await listen$3();
9027
9027
  }
9028
9028
  if (syncIncremental) {
9029
9029
  setEnabled(true);
9030
9030
  }
9031
- await listen$6();
9031
+ await listen$4();
9032
9032
  };
9033
9033
 
9034
9034
  // TODO move cursor
@@ -10194,67 +10194,6 @@ const commandMap = {
10194
10194
  };
10195
10195
  wrapCommands(commandMap);
10196
10196
 
10197
- const MessagePort$1 = 1;
10198
- const ModuleWorker = 2;
10199
- const ReferencePort = 3;
10200
- const ModuleWorkerAndMessagePort = 8;
10201
- const Auto = () => {
10202
- // @ts-ignore
10203
- if (globalThis.acceptPort) {
10204
- return MessagePort$1;
10205
- }
10206
- // @ts-ignore
10207
- if (globalThis.acceptReferencePort) {
10208
- return ReferencePort;
10209
- }
10210
- return ModuleWorkerAndMessagePort;
10211
- };
10212
-
10213
- const getData$1 = event => {
10214
- return event.data;
10215
- };
10216
- const attachEvents = that => {
10217
- const handleMessage = (...args) => {
10218
- const data = that.getData(...args);
10219
- that.dispatchEvent(new MessageEvent('message', {
10220
- data
10221
- }));
10222
- };
10223
- that.onMessage(handleMessage);
10224
- const handleClose = event => {
10225
- that.dispatchEvent(new Event('close'));
10226
- };
10227
- that.onClose(handleClose);
10228
- };
10229
- class Ipc extends EventTarget {
10230
- constructor(rawIpc) {
10231
- super();
10232
- this._rawIpc = rawIpc;
10233
- attachEvents(this);
10234
- }
10235
- }
10236
- const readyMessage = 'ready';
10237
- const walkValue = (value, transferrables, isTransferrable) => {
10238
- if (!value) {
10239
- return;
10240
- }
10241
- if (isTransferrable(value)) {
10242
- transferrables.push(value);
10243
- return;
10244
- }
10245
- if (Array.isArray(value)) {
10246
- for (const item of value) {
10247
- walkValue(item, transferrables, isTransferrable);
10248
- }
10249
- return;
10250
- }
10251
- if (typeof value === 'object') {
10252
- for (const property of Object.values(value)) {
10253
- walkValue(property, transferrables, isTransferrable);
10254
- }
10255
- return;
10256
- }
10257
- };
10258
10197
  const isMessagePort = value => {
10259
10198
  return value && value instanceof MessagePort;
10260
10199
  };
@@ -10279,126 +10218,88 @@ const isTransferrable = value => {
10279
10218
  }
10280
10219
  return false;
10281
10220
  };
10282
- const getTransferrables = value => {
10283
- const transferrables = [];
10284
- walkValue(value, transferrables, isTransferrable);
10285
- return transferrables;
10286
- };
10287
- const listen$3 = ({
10288
- port
10289
- }) => {
10290
- return port;
10291
- };
10292
- const signal$3 = port => {
10293
- port.postMessage(readyMessage);
10294
- };
10295
- class IpcChildWithMessagePort extends Ipc {
10296
- constructor(port) {
10297
- super(port);
10298
- }
10299
- getData(event) {
10300
- return getData$1(event);
10301
- }
10302
- send(message) {
10303
- this._rawIpc.postMessage(message);
10304
- }
10305
- sendAndTransfer(message) {
10306
- const transfer = getTransferrables(message);
10307
- this._rawIpc.postMessage(message, transfer);
10221
+ const walkValue = (value, transferrables, isTransferrable) => {
10222
+ if (!value) {
10223
+ return;
10308
10224
  }
10309
- dispose() {
10310
- // ignore
10225
+ if (isTransferrable(value)) {
10226
+ transferrables.push(value);
10227
+ return;
10311
10228
  }
10312
- onClose(callback) {
10313
- // ignore
10229
+ if (Array.isArray(value)) {
10230
+ for (const item of value) {
10231
+ walkValue(item, transferrables, isTransferrable);
10232
+ }
10233
+ return;
10314
10234
  }
10315
- onMessage(callback) {
10316
- this._rawIpc.addEventListener('message', callback);
10317
- this._rawIpc.start();
10235
+ if (typeof value === 'object') {
10236
+ for (const property of Object.values(value)) {
10237
+ walkValue(property, transferrables, isTransferrable);
10238
+ }
10239
+ return;
10318
10240
  }
10319
- }
10320
- const wrap$6 = port => {
10321
- return new IpcChildWithMessagePort(port);
10322
- };
10323
- const IpcChildWithMessagePort$1 = {
10324
- __proto__: null,
10325
- listen: listen$3,
10326
- signal: signal$3,
10327
- wrap: wrap$6
10328
10241
  };
10329
- const listen$2 = () => {
10330
- // @ts-ignore
10331
- if (typeof WorkerGlobalScope === 'undefined') {
10332
- throw new TypeError('module is not in web worker scope');
10333
- }
10334
- return globalThis;
10242
+ const getTransferrables = value => {
10243
+ const transferrables = [];
10244
+ walkValue(value, transferrables, isTransferrable);
10245
+ return transferrables;
10335
10246
  };
10336
- const signal$2 = global => {
10337
- global.postMessage(readyMessage);
10247
+ const attachEvents = that => {
10248
+ const handleMessage = (...args) => {
10249
+ const data = that.getData(...args);
10250
+ that.dispatchEvent(new MessageEvent('message', {
10251
+ data
10252
+ }));
10253
+ };
10254
+ that.onMessage(handleMessage);
10255
+ const handleClose = event => {
10256
+ that.dispatchEvent(new Event('close'));
10257
+ };
10258
+ that.onClose(handleClose);
10338
10259
  };
10339
- class IpcChildWithModuleWorker extends Ipc {
10340
- getData(event) {
10341
- return getData$1(event);
10342
- }
10343
- send(message) {
10344
- // @ts-ignore
10345
- this._rawIpc.postMessage(message);
10346
- }
10347
- sendAndTransfer(message) {
10348
- const transfer = getTransferrables(message);
10349
- // @ts-ignore
10350
- this._rawIpc.postMessage(message, transfer);
10351
- }
10352
- dispose() {
10353
- // ignore
10354
- }
10355
- onClose(callback) {
10356
- // ignore
10357
- }
10358
- onMessage(callback) {
10359
- this._rawIpc.addEventListener('message', callback);
10260
+ class Ipc extends EventTarget {
10261
+ constructor(rawIpc) {
10262
+ super();
10263
+ this._rawIpc = rawIpc;
10264
+ attachEvents(this);
10360
10265
  }
10361
10266
  }
10362
- const wrap$5 = global => {
10363
- return new IpcChildWithModuleWorker(global);
10364
- };
10365
- const IpcChildWithModuleWorker$1 = {
10366
- __proto__: null,
10367
- listen: listen$2,
10368
- signal: signal$2,
10369
- wrap: wrap$5
10370
- };
10371
10267
  const E_INCOMPATIBLE_NATIVE_MODULE = 'E_INCOMPATIBLE_NATIVE_MODULE';
10372
10268
  const E_MODULES_NOT_SUPPORTED_IN_ELECTRON = 'E_MODULES_NOT_SUPPORTED_IN_ELECTRON';
10373
10269
  const ERR_MODULE_NOT_FOUND = 'ERR_MODULE_NOT_FOUND';
10374
- const NewLine$1 = '\n';
10270
+ const NewLine = '\n';
10375
10271
  const joinLines = lines => {
10376
- return lines.join(NewLine$1);
10377
- };
10378
- const splitLines = lines => {
10379
- return lines.split(NewLine$1);
10272
+ return lines.join(NewLine);
10380
10273
  };
10381
- const isModuleNotFoundMessage = line => {
10382
- return line.includes('[ERR_MODULE_NOT_FOUND]');
10274
+ const RE_AT = /^\s+at/;
10275
+ const RE_AT_PROMISE_INDEX = /^\s*at async Promise.all \(index \d+\)$/;
10276
+ const isNormalStackLine = line => {
10277
+ return RE_AT.test(line) && !RE_AT_PROMISE_INDEX.test(line);
10383
10278
  };
10384
- const getModuleNotFoundError = stderr => {
10385
- const lines = splitLines(stderr);
10386
- const messageIndex = lines.findIndex(isModuleNotFoundMessage);
10387
- const message = lines[messageIndex];
10279
+ const getDetails = lines => {
10280
+ const index = lines.findIndex(isNormalStackLine);
10281
+ if (index === -1) {
10282
+ return {
10283
+ actualMessage: joinLines(lines),
10284
+ rest: []
10285
+ };
10286
+ }
10287
+ let lastIndex = index - 1;
10288
+ while (++lastIndex < lines.length) {
10289
+ if (!isNormalStackLine(lines[lastIndex])) {
10290
+ break;
10291
+ }
10292
+ }
10388
10293
  return {
10389
- message,
10390
- code: ERR_MODULE_NOT_FOUND
10294
+ actualMessage: lines[index - 1],
10295
+ rest: lines.slice(index, lastIndex)
10391
10296
  };
10392
10297
  };
10393
- const RE_NATIVE_MODULE_ERROR = /^innerError Error: Cannot find module '.*.node'/;
10394
- const RE_NATIVE_MODULE_ERROR_2 = /was compiled against a different Node.js version/;
10298
+ const splitLines = lines => {
10299
+ return lines.split(NewLine);
10300
+ };
10395
10301
  const RE_MESSAGE_CODE_BLOCK_START = /^Error: The module '.*'$/;
10396
10302
  const RE_MESSAGE_CODE_BLOCK_END = /^\s* at/;
10397
- const RE_AT = /^\s+at/;
10398
- const RE_AT_PROMISE_INDEX = /^\s*at async Promise.all \(index \d+\)$/;
10399
- const isUnhelpfulNativeModuleError = stderr => {
10400
- return RE_NATIVE_MODULE_ERROR.test(stderr) && RE_NATIVE_MODULE_ERROR_2.test(stderr);
10401
- };
10402
10303
  const isMessageCodeBlockStartIndex = line => {
10403
10304
  return RE_MESSAGE_CODE_BLOCK_START.test(line);
10404
10305
  };
@@ -10413,51 +10314,46 @@ const getMessageCodeBlock = stderr => {
10413
10314
  const relevantMessage = relevantLines.join(' ').slice('Error: '.length);
10414
10315
  return relevantMessage;
10415
10316
  };
10416
- const getNativeModuleErrorMessage = stderr => {
10417
- const message = getMessageCodeBlock(stderr);
10317
+ const isModuleNotFoundMessage = line => {
10318
+ return line.includes('[ERR_MODULE_NOT_FOUND]');
10319
+ };
10320
+ const getModuleNotFoundError = stderr => {
10321
+ const lines = splitLines(stderr);
10322
+ const messageIndex = lines.findIndex(isModuleNotFoundMessage);
10323
+ const message = lines[messageIndex];
10418
10324
  return {
10419
- message: `Incompatible native node module: ${message}`,
10420
- code: E_INCOMPATIBLE_NATIVE_MODULE
10325
+ message,
10326
+ code: ERR_MODULE_NOT_FOUND
10421
10327
  };
10422
10328
  };
10423
- const isModulesSyntaxError = stderr => {
10329
+ const isModuleNotFoundError = stderr => {
10424
10330
  if (!stderr) {
10425
10331
  return false;
10426
10332
  }
10427
- return stderr.includes('SyntaxError: Cannot use import statement outside a module');
10428
- };
10429
- const getModuleSyntaxError = () => {
10430
- return {
10431
- message: `ES Modules are not supported in electron`,
10432
- code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON
10433
- };
10333
+ return stderr.includes('ERR_MODULE_NOT_FOUND');
10434
10334
  };
10435
- const isModuleNotFoundError = stderr => {
10335
+ const isModulesSyntaxError = stderr => {
10436
10336
  if (!stderr) {
10437
10337
  return false;
10438
10338
  }
10439
- return stderr.includes('ERR_MODULE_NOT_FOUND');
10339
+ return stderr.includes('SyntaxError: Cannot use import statement outside a module');
10440
10340
  };
10441
- const isNormalStackLine = line => {
10442
- return RE_AT.test(line) && !RE_AT_PROMISE_INDEX.test(line);
10341
+ const RE_NATIVE_MODULE_ERROR = /^innerError Error: Cannot find module '.*.node'/;
10342
+ const RE_NATIVE_MODULE_ERROR_2 = /was compiled against a different Node.js version/;
10343
+ const isUnhelpfulNativeModuleError = stderr => {
10344
+ return RE_NATIVE_MODULE_ERROR.test(stderr) && RE_NATIVE_MODULE_ERROR_2.test(stderr);
10443
10345
  };
10444
- const getDetails = lines => {
10445
- const index = lines.findIndex(isNormalStackLine);
10446
- if (index === -1) {
10447
- return {
10448
- actualMessage: joinLines(lines),
10449
- rest: []
10450
- };
10451
- }
10452
- let lastIndex = index - 1;
10453
- while (++lastIndex < lines.length) {
10454
- if (!isNormalStackLine(lines[lastIndex])) {
10455
- break;
10456
- }
10457
- }
10346
+ const getNativeModuleErrorMessage = stderr => {
10347
+ const message = getMessageCodeBlock(stderr);
10458
10348
  return {
10459
- actualMessage: lines[index - 1],
10460
- rest: lines.slice(index, lastIndex)
10349
+ message: `Incompatible native node module: ${message}`,
10350
+ code: E_INCOMPATIBLE_NATIVE_MODULE
10351
+ };
10352
+ };
10353
+ const getModuleSyntaxError = () => {
10354
+ return {
10355
+ message: `ES Modules are not supported in electron`,
10356
+ code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON
10461
10357
  };
10462
10358
  };
10463
10359
  const getHelpfulChildProcessError = (stdout, stderr) => {
@@ -10476,66 +10372,11 @@ const getHelpfulChildProcessError = (stdout, stderr) => {
10476
10372
  rest
10477
10373
  } = getDetails(lines);
10478
10374
  return {
10479
- message: `${actualMessage}`,
10375
+ message: actualMessage,
10480
10376
  code: '',
10481
10377
  stack: rest
10482
10378
  };
10483
10379
  };
10484
- const normalizeLine = line => {
10485
- if (line.startsWith('Error: ')) {
10486
- return line.slice('Error: '.length);
10487
- }
10488
- if (line.startsWith('VError: ')) {
10489
- return line.slice('VError: '.length);
10490
- }
10491
- return line;
10492
- };
10493
- const getCombinedMessage = (error, message) => {
10494
- const stringifiedError = normalizeLine(`${error}`);
10495
- if (message) {
10496
- return `${message}: ${stringifiedError}`;
10497
- }
10498
- return stringifiedError;
10499
- };
10500
- const NewLine = '\n';
10501
- const getNewLineIndex = (string, startIndex = undefined) => {
10502
- return string.indexOf(NewLine, startIndex);
10503
- };
10504
- const mergeStacks = (parent, child) => {
10505
- if (!child) {
10506
- return parent;
10507
- }
10508
- const parentNewLineIndex = getNewLineIndex(parent);
10509
- const childNewLineIndex = getNewLineIndex(child);
10510
- if (childNewLineIndex === -1) {
10511
- return parent;
10512
- }
10513
- const parentFirstLine = parent.slice(0, parentNewLineIndex);
10514
- const childRest = child.slice(childNewLineIndex);
10515
- const childFirstLine = normalizeLine(child.slice(0, childNewLineIndex));
10516
- if (parentFirstLine.includes(childFirstLine)) {
10517
- return parentFirstLine + childRest;
10518
- }
10519
- return child;
10520
- };
10521
- class VError extends Error {
10522
- constructor(error, message) {
10523
- const combinedMessage = getCombinedMessage(error, message);
10524
- super(combinedMessage);
10525
- this.name = 'VError';
10526
- if (error instanceof Error) {
10527
- this.stack = mergeStacks(this.stack, error.stack);
10528
- }
10529
- if (error.codeFrame) {
10530
- // @ts-ignore
10531
- this.codeFrame = error.codeFrame;
10532
- }
10533
- if (error.code) {
10534
- // @ts-ignore
10535
- this.code = error.code;
10536
- }
10537
- }
10538
- }
10539
10380
  class IpcError extends VError {
10540
10381
  // @ts-ignore
10541
10382
  constructor(betterMessage, stdout = '', stderr = '') {
@@ -10562,12 +10403,98 @@ class IpcError extends VError {
10562
10403
  this.stderr = stderr;
10563
10404
  }
10564
10405
  }
10406
+ const readyMessage = 'ready';
10407
+ const getData$2 = event => {
10408
+ return event.data;
10409
+ };
10410
+ const listen$8 = ({
10411
+ port
10412
+ }) => {
10413
+ return port;
10414
+ };
10415
+ const signal$9 = port => {
10416
+ port.postMessage(readyMessage);
10417
+ };
10418
+ class IpcChildWithMessagePort extends Ipc {
10419
+ getData(event) {
10420
+ return getData$2(event);
10421
+ }
10422
+ send(message) {
10423
+ this._rawIpc.postMessage(message);
10424
+ }
10425
+ sendAndTransfer(message) {
10426
+ const transfer = getTransferrables(message);
10427
+ this._rawIpc.postMessage(message, transfer);
10428
+ }
10429
+ dispose() {
10430
+ // ignore
10431
+ }
10432
+ onClose(callback) {
10433
+ // ignore
10434
+ }
10435
+ onMessage(callback) {
10436
+ this._rawIpc.addEventListener('message', callback);
10437
+ this._rawIpc.start();
10438
+ }
10439
+ }
10440
+ const wrap$g = port => {
10441
+ return new IpcChildWithMessagePort(port);
10442
+ };
10443
+ const IpcChildWithMessagePort$1 = {
10444
+ __proto__: null,
10445
+ listen: listen$8,
10446
+ signal: signal$9,
10447
+ wrap: wrap$g
10448
+ };
10449
+ const listen$7 = () => {
10450
+ // @ts-ignore
10451
+ if (typeof WorkerGlobalScope === 'undefined') {
10452
+ throw new TypeError('module is not in web worker scope');
10453
+ }
10454
+ return globalThis;
10455
+ };
10456
+ const signal$8 = global => {
10457
+ global.postMessage(readyMessage);
10458
+ };
10459
+ class IpcChildWithModuleWorker extends Ipc {
10460
+ getData(event) {
10461
+ return getData$2(event);
10462
+ }
10463
+ send(message) {
10464
+ // @ts-ignore
10465
+ this._rawIpc.postMessage(message);
10466
+ }
10467
+ sendAndTransfer(message) {
10468
+ const transfer = getTransferrables(message);
10469
+ // @ts-ignore
10470
+ this._rawIpc.postMessage(message, transfer);
10471
+ }
10472
+ dispose() {
10473
+ // ignore
10474
+ }
10475
+ onClose(callback) {
10476
+ // ignore
10477
+ }
10478
+ onMessage(callback) {
10479
+ this._rawIpc.addEventListener('message', callback);
10480
+ }
10481
+ }
10482
+ const wrap$f = global => {
10483
+ return new IpcChildWithModuleWorker(global);
10484
+ };
10485
+ const IpcChildWithModuleWorker$1 = {
10486
+ __proto__: null,
10487
+ listen: listen$7,
10488
+ signal: signal$8,
10489
+ wrap: wrap$f
10490
+ };
10565
10491
  const withResolvers = () => {
10566
10492
  let _resolve;
10567
10493
  const promise = new Promise(resolve => {
10568
10494
  _resolve = resolve;
10569
10495
  });
10570
10496
  return {
10497
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
10571
10498
  resolve: _resolve,
10572
10499
  promise
10573
10500
  };
@@ -10584,10 +10511,10 @@ const waitForFirstMessage = async port => {
10584
10511
  // @ts-ignore
10585
10512
  return event.data;
10586
10513
  };
10587
- const listen$1$1 = async () => {
10588
- const parentIpcRaw = listen$2();
10589
- signal$2(parentIpcRaw);
10590
- const parentIpc = wrap$5(parentIpcRaw);
10514
+ const listen$6 = async () => {
10515
+ const parentIpcRaw = listen$7();
10516
+ signal$8(parentIpcRaw);
10517
+ const parentIpc = wrap$f(parentIpcRaw);
10591
10518
  const firstMessage = await waitForFirstMessage(parentIpc);
10592
10519
  if (firstMessage.method !== 'initialize') {
10593
10520
  throw new IpcError('unexpected first message');
@@ -10606,11 +10533,8 @@ const listen$1$1 = async () => {
10606
10533
  return globalThis;
10607
10534
  };
10608
10535
  class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
10609
- constructor(port) {
10610
- super(port);
10611
- }
10612
10536
  getData(event) {
10613
- return getData$1(event);
10537
+ return getData$2(event);
10614
10538
  }
10615
10539
  send(message) {
10616
10540
  this._rawIpc.postMessage(message);
@@ -10632,13 +10556,29 @@ class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
10632
10556
  this._rawIpc.start();
10633
10557
  }
10634
10558
  }
10635
- const wrap$4 = port => {
10559
+ const wrap$e = port => {
10636
10560
  return new IpcChildWithModuleWorkerAndMessagePort(port);
10637
10561
  };
10638
10562
  const IpcChildWithModuleWorkerAndMessagePort$1 = {
10639
10563
  __proto__: null,
10640
- listen: listen$1$1,
10641
- wrap: wrap$4
10564
+ listen: listen$6,
10565
+ wrap: wrap$e
10566
+ };
10567
+
10568
+ const MessagePort$1 = 1;
10569
+ const ModuleWorker = 2;
10570
+ const ReferencePort = 3;
10571
+ const ModuleWorkerAndMessagePort = 8;
10572
+ const Auto = () => {
10573
+ // @ts-ignore
10574
+ if (globalThis.acceptPort) {
10575
+ return MessagePort$1;
10576
+ }
10577
+ // @ts-ignore
10578
+ if (globalThis.acceptReferencePort) {
10579
+ return ReferencePort;
10580
+ }
10581
+ return ModuleWorkerAndMessagePort;
10642
10582
  };
10643
10583
 
10644
10584
  const getModule = method => {
@@ -10659,12 +10599,14 @@ const listen$1 = async ({
10659
10599
  method
10660
10600
  }) => {
10661
10601
  const module = await getModule(method);
10602
+ // @ts-ignore
10662
10603
  const rawIpc = await module.listen();
10663
10604
  // @ts-ignore
10664
10605
  if (module.signal) {
10665
10606
  // @ts-ignore
10666
10607
  module.signal(rawIpc);
10667
10608
  }
10609
+ // @ts-ignore
10668
10610
  const ipc = module.wrap(rawIpc);
10669
10611
  return ipc;
10670
10612
  };
@@ -10675,7 +10617,7 @@ const listen = async () => {
10675
10617
  method: Auto()
10676
10618
  });
10677
10619
  handleIpc(ipc);
10678
- listen$7(ipc);
10620
+ listen$5(ipc);
10679
10621
  };
10680
10622
 
10681
10623
  const addWidget = (widget, id, render) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "5.12.0",
3
+ "version": "5.15.0",
4
4
  "description": "",
5
5
  "main": "dist/editorWorkerMain.js",
6
6
  "type": "module",