@lvce-editor/editor-worker 18.25.0 → 18.26.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.
@@ -1537,12 +1537,12 @@ const launchColorPickerWorker = async () => {
1537
1537
  return launchWorker(name, url);
1538
1538
  };
1539
1539
 
1540
- let workerPromise$3;
1540
+ const state$f = {};
1541
1541
  const getOrCreate$3 = () => {
1542
- if (!workerPromise$3) {
1543
- workerPromise$3 = launchColorPickerWorker();
1542
+ if (!state$f.workerPromise) {
1543
+ state$f.workerPromise = launchColorPickerWorker();
1544
1544
  }
1545
- return workerPromise$3;
1545
+ return state$f.workerPromise;
1546
1546
  };
1547
1547
  const invoke$9 = async (method, ...params) => {
1548
1548
  const worker = await getOrCreate$3();
@@ -1845,7 +1845,7 @@ const getInitialLineState = initialLineState => {
1845
1845
  return deepCopy(initialLineState);
1846
1846
  };
1847
1847
 
1848
- const state$8 = {
1848
+ const state$e = {
1849
1849
  warned: []
1850
1850
  };
1851
1851
  const flattenTokensArray = tokens => {
@@ -1857,10 +1857,10 @@ const flattenTokensArray = tokens => {
1857
1857
  return flattened;
1858
1858
  };
1859
1859
  const warnDeprecatedArrayReturn = (languageId, fn) => {
1860
- if (state$8.warned.includes(fn)) {
1860
+ if (state$e.warned.includes(fn)) {
1861
1861
  return;
1862
1862
  }
1863
- state$8.warned.push(fn);
1863
+ state$e.warned.push(fn);
1864
1864
  console.warn(`tokenizers without hasArrayReturn=false are deprecated (language ${languageId})`);
1865
1865
  };
1866
1866
  const safeTokenizeLine = (languageId, tokenizeLine, line, lineStateAtStart, hasArrayReturn) => {
@@ -1921,12 +1921,14 @@ const TokenizePlainText = {
1921
1921
  tokenizeLine
1922
1922
  };
1923
1923
 
1924
- let enabled$1 = false;
1924
+ const state$d = {
1925
+ enabled: false
1926
+ };
1925
1927
  const setEnabled$1 = value => {
1926
- enabled$1 = value;
1928
+ state$d.enabled = value;
1927
1929
  };
1928
1930
  const getEnabled$1 = () => {
1929
- return enabled$1;
1931
+ return state$d.enabled;
1930
1932
  };
1931
1933
 
1932
1934
  const {
@@ -1934,25 +1936,25 @@ const {
1934
1936
  set: set$5
1935
1937
  } = SyntaxHighlightingWorker;
1936
1938
 
1937
- const state$7 = {
1939
+ const state$c = {
1938
1940
  pending: Object.create(null),
1939
1941
  tokenizePaths: Object.create(null),
1940
1942
  tokenizers: Object.create(null)
1941
1943
  };
1942
1944
  const has = languageId => {
1943
- return Object.hasOwn(state$7.tokenizers, languageId);
1945
+ return Object.hasOwn(state$c.tokenizers, languageId);
1944
1946
  };
1945
1947
  const set$4 = (languageId, tokenizer) => {
1946
- state$7.tokenizers[languageId] = tokenizer;
1948
+ state$c.tokenizers[languageId] = tokenizer;
1947
1949
  };
1948
1950
  const get$4 = languageId => {
1949
- return state$7.tokenizers[languageId];
1951
+ return state$c.tokenizers[languageId];
1950
1952
  };
1951
1953
  const setTokenizePath = (languageId, tokenizePath) => {
1952
- state$7.tokenizePaths[languageId] = tokenizePath;
1954
+ state$c.tokenizePaths[languageId] = tokenizePath;
1953
1955
  };
1954
1956
  const getTokenizePath$1 = languageId => {
1955
- return state$7.tokenizePaths[languageId] || '';
1957
+ return state$c.tokenizePaths[languageId] || '';
1956
1958
  };
1957
1959
  const setTokenizePaths = languages => {
1958
1960
  for (const language of languages) {
@@ -1962,7 +1964,7 @@ const setTokenizePaths = languages => {
1962
1964
  }
1963
1965
  };
1964
1966
  const isPending = languageId => {
1965
- return Object.hasOwn(state$7.pending, languageId);
1967
+ return Object.hasOwn(state$c.pending, languageId);
1966
1968
  };
1967
1969
 
1968
1970
  const tokenMaps = Object.create(null);
@@ -2808,12 +2810,14 @@ const getNewDeltaPercent = (height, scrollBarHeight, relativeY) => {
2808
2810
  };
2809
2811
  };
2810
2812
 
2811
- let enabled = false;
2813
+ const state$b = {
2814
+ enabled: false
2815
+ };
2812
2816
  const setEnabled = value => {
2813
- enabled = value;
2817
+ state$b.enabled = value;
2814
2818
  };
2815
2819
  const getEnabled = () => {
2816
- return enabled;
2820
+ return state$b.enabled;
2817
2821
  };
2818
2822
 
2819
2823
  // TODO this should be in a separate scrolling module
@@ -2993,7 +2997,7 @@ const getUrlAtOffset = (editor, offset) => {
2993
2997
 
2994
2998
  const EditorChange = 1;
2995
2999
 
2996
- const state$6 = Object.create(null);
3000
+ const state$a = Object.create(null);
2997
3001
 
2998
3002
  /**
2999
3003
  * Register a listener for a specific event type
@@ -3003,13 +3007,13 @@ const state$6 = Object.create(null);
3003
3007
  const registerListener$1 = (listenerType, rpcId) => {
3004
3008
  number(listenerType);
3005
3009
  number(rpcId);
3006
- if (!Object.hasOwn(state$6, listenerType)) {
3007
- state$6[listenerType] = [];
3010
+ if (!Object.hasOwn(state$a, listenerType)) {
3011
+ state$a[listenerType] = [];
3008
3012
  }
3009
3013
 
3010
3014
  // Avoid duplicate registrations
3011
- if (!state$6[listenerType].includes(rpcId)) {
3012
- state$6[listenerType].push(rpcId);
3015
+ if (!state$a[listenerType].includes(rpcId)) {
3016
+ state$a[listenerType].push(rpcId);
3013
3017
  }
3014
3018
  };
3015
3019
 
@@ -3021,10 +3025,10 @@ const registerListener$1 = (listenerType, rpcId) => {
3021
3025
  const unregisterListener$1 = (listenerType, rpcId) => {
3022
3026
  number(listenerType);
3023
3027
  number(rpcId);
3024
- if (Object.hasOwn(state$6, listenerType)) {
3025
- const index = state$6[listenerType].indexOf(rpcId);
3028
+ if (Object.hasOwn(state$a, listenerType)) {
3029
+ const index = state$a[listenerType].indexOf(rpcId);
3026
3030
  if (index !== -1) {
3027
- state$6[listenerType].splice(index, 1);
3031
+ state$a[listenerType].splice(index, 1);
3028
3032
  }
3029
3033
  }
3030
3034
  };
@@ -3036,7 +3040,7 @@ const unregisterListener$1 = (listenerType, rpcId) => {
3036
3040
  */
3037
3041
  const getListeners = listenerType => {
3038
3042
  number(listenerType);
3039
- return state$6[listenerType] || [];
3043
+ return state$a[listenerType] || [];
3040
3044
  };
3041
3045
 
3042
3046
  /**
@@ -3264,16 +3268,6 @@ const from = (array, getSelection) => {
3264
3268
  }
3265
3269
  return newSelections;
3266
3270
  };
3267
- const push = (selections, startRowIndex, startColumnIndex, endRowIndex, endColumnIndex) => {
3268
- const oldLength = selections.length;
3269
- const newSelections = alloc(oldLength + 4);
3270
- newSelections.set(selections);
3271
- newSelections[oldLength + 1] = startRowIndex;
3272
- newSelections[oldLength + 2] = startColumnIndex;
3273
- newSelections[oldLength + 3] = endRowIndex;
3274
- newSelections[oldLength + 4] = endColumnIndex;
3275
- return newSelections;
3276
- };
3277
3271
 
3278
3272
  // TODO maybe only accept sorted selection edits in the first place
3279
3273
 
@@ -4524,7 +4518,7 @@ const y = (editor, rowIndex) => {
4524
4518
  return offsetY;
4525
4519
  };
4526
4520
 
4527
- const state$5 = {
4521
+ const state$9 = {
4528
4522
  timeout: -1
4529
4523
  };
4530
4524
 
@@ -4555,7 +4549,7 @@ const editorShowMessage = async (editor, rowIndex, columnIndex, message, isError
4555
4549
 
4556
4550
  // TODO use wrapper timing module instead of this
4557
4551
  // @ts-ignore
4558
- state$5.timeout = setTimeout(handleTimeout, 3000);
4552
+ state$9.timeout = setTimeout(handleTimeout, 3000);
4559
4553
  }
4560
4554
  return editor;
4561
4555
  };
@@ -4575,8 +4569,8 @@ const showErrorMessage = async (editor, rowIndex, columnIndex, message) => {
4575
4569
 
4576
4570
  // @ts-ignore
4577
4571
  const editorHideMessage = async editor => {
4578
- clearTimeout(state$5.timeout);
4579
- state$5.timeout = -1;
4572
+ clearTimeout(state$9.timeout);
4573
+ state$9.timeout = -1;
4580
4574
  // await RendererProcess.invoke(/* Viewlet.send */ 'Viewlet.send', /* id */ editor.uid, /* method */ 'hideOverlayMessage')
4581
4575
  return editor;
4582
4576
  };
@@ -4692,12 +4686,12 @@ const launchRenameWorker = async () => {
4692
4686
  return rpc;
4693
4687
  };
4694
4688
 
4695
- let workerPromise$2;
4689
+ const state$8 = {};
4696
4690
  const getOrCreate$2 = () => {
4697
- if (!workerPromise$2) {
4698
- workerPromise$2 = launchRenameWorker();
4691
+ if (!state$8.workerPromise) {
4692
+ state$8.workerPromise = launchRenameWorker();
4699
4693
  }
4700
- return workerPromise$2;
4694
+ return state$8.workerPromise;
4701
4695
  };
4702
4696
  const invoke$5 = async (method, ...params) => {
4703
4697
  const worker = await getOrCreate$2();
@@ -4817,12 +4811,12 @@ const openColorPicker = async editor => {
4817
4811
  return addWidgetToEditor(ColorPicker$1, ColorPicker, editor, create$6, newStateGenerator$6);
4818
4812
  };
4819
4813
 
4820
- const state$4 = {
4814
+ const state$7 = {
4821
4815
  compositionText: '',
4822
4816
  isComposing: false
4823
4817
  };
4824
4818
  const compositionStart = (editor, event) => {
4825
- state$4.isComposing = true;
4819
+ state$7.isComposing = true;
4826
4820
  return editor;
4827
4821
  };
4828
4822
  const getCompositionChanges = (selections, data) => {
@@ -4832,9 +4826,9 @@ const getCompositionChanges = (selections, data) => {
4832
4826
  const selectionStartColumn = selections[i + 1];
4833
4827
  const selectionEndRow = selections[i + 2];
4834
4828
  const selectionEndColumn = selections[i + 3];
4835
- const startColumnIndex = selectionStartColumn - state$4.compositionText.length;
4829
+ const startColumnIndex = selectionStartColumn - state$7.compositionText.length;
4836
4830
  changes.push({
4837
- deleted: [state$4.compositionText],
4831
+ deleted: [state$7.compositionText],
4838
4832
  end: {
4839
4833
  columnIndex: selectionEndColumn,
4840
4834
  rowIndex: selectionEndRow
@@ -4854,7 +4848,7 @@ const compositionUpdate = (editor, data) => {
4854
4848
  selections
4855
4849
  } = editor;
4856
4850
  const changes = getCompositionChanges(selections, data);
4857
- state$4.compositionText = data;
4851
+ state$7.compositionText = data;
4858
4852
  return scheduleDocumentAndCursorsSelections(editor, changes);
4859
4853
  };
4860
4854
  const compositionEnd = (editor, data) => {
@@ -4862,8 +4856,8 @@ const compositionEnd = (editor, data) => {
4862
4856
  selections
4863
4857
  } = editor;
4864
4858
  const changes = getCompositionChanges(selections, data);
4865
- state$4.isComposing = false;
4866
- state$4.compositionText = '';
4859
+ state$7.isComposing = false;
4860
+ state$7.compositionText = '';
4867
4861
  return scheduleDocumentAndCursorsSelections(editor, changes);
4868
4862
  };
4869
4863
 
@@ -5939,19 +5933,19 @@ const closeWidgetsMaybe = widgets => {
5939
5933
  return widgets.filter(isPersistentWidget);
5940
5934
  };
5941
5935
 
5942
- const state$3 = {
5936
+ const state$6 = {
5943
5937
  position: {
5944
5938
  columnIndex: 0,
5945
5939
  rowIndex: 0
5946
5940
  }
5947
5941
  };
5948
5942
  const getPosition$1 = () => {
5949
- return state$3.position;
5943
+ return state$6.position;
5950
5944
  };
5951
5945
 
5952
5946
  // @ts-ignore
5953
5947
  const setPosition$1 = position => {
5954
- state$3.position = position;
5948
+ state$6.position = position;
5955
5949
  };
5956
5950
 
5957
5951
  const openExternal = async (url, platform) => {
@@ -6169,20 +6163,20 @@ const handleMouseDown = (state, button, altKey, ctrlKey, x, y, detail) => {
6169
6163
  }
6170
6164
  };
6171
6165
 
6172
- const state$2 = {
6166
+ const state$5 = {
6173
6167
  editor: undefined,
6174
6168
  timeout: -1,
6175
6169
  x: 0,
6176
6170
  y: 0
6177
6171
  };
6178
6172
  const get = () => {
6179
- return state$2;
6173
+ return state$5;
6180
6174
  };
6181
6175
  const set = (editor, timeout, x, y) => {
6182
- state$2.editor = editor;
6183
- state$2.timeout = timeout;
6184
- state$2.x = x;
6185
- state$2.y = y;
6176
+ state$5.editor = editor;
6177
+ state$5.timeout = timeout;
6178
+ state$5.x = x;
6179
+ state$5.y = y;
6186
6180
  };
6187
6181
 
6188
6182
  const showHover$1 = async (editor, position) => {
@@ -6323,7 +6317,7 @@ const editorHandleNativeSelectionChange = (editor, range) => {
6323
6317
  return scheduleSelections(editor, selections);
6324
6318
  };
6325
6319
 
6326
- const state$1 = {
6320
+ const state$4 = {
6327
6321
  /**
6328
6322
  * @type {any}
6329
6323
  */
@@ -6338,33 +6332,33 @@ const state$1 = {
6338
6332
 
6339
6333
  // @ts-ignore
6340
6334
  const setEditor = editor => {
6341
- state$1.currentEditor = editor;
6342
- state$1.hasListener = true;
6335
+ state$4.currentEditor = editor;
6336
+ state$4.hasListener = true;
6343
6337
  };
6344
6338
  const clearEditor = () => {
6345
- state$1.currentEditor = undefined;
6346
- state$1.hasListener = false;
6347
- state$1.isSelecting = false;
6339
+ state$4.currentEditor = undefined;
6340
+ state$4.hasListener = false;
6341
+ state$4.isSelecting = false;
6348
6342
  };
6349
6343
  const startSelecting = () => {
6350
- state$1.isSelecting = true;
6344
+ state$4.isSelecting = true;
6351
6345
  };
6352
6346
  const isSelecting = () => {
6353
- return state$1.isSelecting;
6347
+ return state$4.isSelecting;
6354
6348
  };
6355
6349
 
6356
6350
  // @ts-ignore
6357
6351
  const setPosition = position => {
6358
- state$1.position = position;
6352
+ state$4.position = position;
6359
6353
  };
6360
6354
  const getEditor$1 = () => {
6361
- return state$1.currentEditor;
6355
+ return state$4.currentEditor;
6362
6356
  };
6363
6357
  const getPosition = () => {
6364
- return state$1.position;
6358
+ return state$4.position;
6365
6359
  };
6366
6360
  const hasListener = () => {
6367
- return state$1.hasListener;
6361
+ return state$4.hasListener;
6368
6362
  };
6369
6363
 
6370
6364
  // @ts-ignore
@@ -6744,7 +6738,7 @@ const handleTouchEnd = (editor, touchEvent) => {
6744
6738
  // }
6745
6739
  };
6746
6740
 
6747
- const state = {
6741
+ const state$3 = {
6748
6742
  deltaY: 0,
6749
6743
  touchOffsetY: 0
6750
6744
  };
@@ -6755,8 +6749,8 @@ const handleTouchStart = (editor, touchEvent) => {
6755
6749
  return;
6756
6750
  }
6757
6751
  const firstTouch = touchEvent.touches[0];
6758
- state.touchOffsetY = firstTouch.y;
6759
- state.deltaY = editor.deltaY;
6752
+ state$3.touchOffsetY = firstTouch.y;
6753
+ state$3.deltaY = editor.deltaY;
6760
6754
  // const position = EditorPosition.at(editor, firstTouch.x, firstTouch.y)
6761
6755
  // EditorMoveSelection.state.position = position
6762
6756
  // state.date = Date.now()
@@ -6797,7 +6791,7 @@ const handleTouchMove = (editor, touchEvent) => {
6797
6791
  return;
6798
6792
  }
6799
6793
  const firstTouch = touchEvent.touches[0];
6800
- const offsetY = state.deltaY + (state.touchOffsetY - firstTouch.y);
6794
+ const offsetY = state$3.deltaY + (state$3.touchOffsetY - firstTouch.y);
6801
6795
  setDeltaYFixedValue(editor, offsetY);
6802
6796
  };
6803
6797
 
@@ -7819,7 +7813,13 @@ const getSelectionEditsSingleLineWord = (lines, selections) => {
7819
7813
  const columnIndexAfter = line.indexOf(word, lastSelectionEndColumnIndex);
7820
7814
  if (columnIndexAfter !== -1) {
7821
7815
  const columnIndexAfterEnd = columnIndexAfter + word.length;
7822
- const newSelections = push(selections, rowIndex, columnIndexAfter, rowIndex, columnIndexAfterEnd);
7816
+ const newSelections = new Uint32Array(selections.length + 4);
7817
+ newSelections.set(selections, 0);
7818
+ const insertIndex = selections.length;
7819
+ newSelections[insertIndex] = rowIndex;
7820
+ newSelections[insertIndex + 1] = columnIndexAfter;
7821
+ newSelections[insertIndex + 2] = rowIndex;
7822
+ newSelections[insertIndex + 3] = columnIndexAfterEnd;
7823
7823
  return {
7824
7824
  revealRange: newSelections.length - 4,
7825
7825
  selectionEdits: newSelections
@@ -8165,12 +8165,12 @@ const launchHoverWorker = async () => {
8165
8165
  return rpc;
8166
8166
  };
8167
8167
 
8168
- let workerPromise$1;
8168
+ const state$2 = {};
8169
8169
  const getOrCreate$1 = () => {
8170
- if (!workerPromise$1) {
8171
- workerPromise$1 = launchHoverWorker();
8170
+ if (!state$2.workerPromise) {
8171
+ state$2.workerPromise = launchHoverWorker();
8172
8172
  }
8173
- return workerPromise$1;
8173
+ return state$2.workerPromise;
8174
8174
  };
8175
8175
  const invoke$2 = async (method, ...params) => {
8176
8176
  const worker = await getOrCreate$1();
@@ -8249,12 +8249,12 @@ const launchSourceActionWorker = async () => {
8249
8249
  return rpc;
8250
8250
  };
8251
8251
 
8252
- let workerPromise;
8252
+ const state$1 = {};
8253
8253
  const getOrCreate = () => {
8254
- if (!workerPromise) {
8255
- workerPromise = launchSourceActionWorker();
8254
+ if (!state$1.workerPromise) {
8255
+ state$1.workerPromise = launchSourceActionWorker();
8256
8256
  }
8257
- return workerPromise;
8257
+ return state$1.workerPromise;
8258
8258
  };
8259
8259
  const invoke$1 = async (method, ...params) => {
8260
8260
  const worker = await getOrCreate();
@@ -10741,12 +10741,14 @@ const restoreWidgetState = async (keys, savedStates) => {
10741
10741
  return newEditors;
10742
10742
  };
10743
10743
 
10744
- let isReloading = false;
10744
+ const state = {
10745
+ isReloading: false
10746
+ };
10745
10747
  const hotReload = async () => {
10746
- if (isReloading) {
10748
+ if (state.isReloading) {
10747
10749
  return;
10748
10750
  }
10749
- isReloading = true;
10751
+ state.isReloading = true;
10750
10752
 
10751
10753
  // TODO use getEditors
10752
10754
  const keys = getKeys$2();
@@ -10760,7 +10762,7 @@ const hotReload = async () => {
10760
10762
  // TODO ask renderer worker to rerender all editors
10761
10763
  // @ts-ignore
10762
10764
  await invoke$b(`Editor.rerender`);
10763
- isReloading = false;
10765
+ state.isReloading = false;
10764
10766
  };
10765
10767
 
10766
10768
  const sendMessagePortToSyntaxHighlightingWorker = async port => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "18.25.0",
3
+ "version": "18.26.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"