@lvce-editor/editor-worker 1.0.0 → 1.2.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.
@@ -401,7 +401,7 @@ const getSelectionPairs = (selections, i) => {
401
401
  return [first, second, third, fourth, 0];
402
402
  };
403
403
 
404
- const state$c = {
404
+ const state$b = {
405
405
  ctx: undefined
406
406
  };
407
407
 
@@ -410,11 +410,11 @@ const state$c = {
410
410
  * @returns {OffscreenCanvasRenderingContext2D}
411
411
  */
412
412
  const getOrCreate = createCtx => {
413
- if (state$c.ctx) {
414
- return state$c.ctx;
413
+ if (state$b.ctx) {
414
+ return state$b.ctx;
415
415
  }
416
- state$c.ctx = createCtx();
417
- return state$c.ctx;
416
+ state$b.ctx = createCtx();
417
+ return state$b.ctx;
418
418
  };
419
419
 
420
420
  const createCtx = () => {
@@ -1055,11 +1055,11 @@ const get$4 = id => {
1055
1055
  const remove = id => {
1056
1056
  delete state$1$1.callbacks[id];
1057
1057
  };
1058
- const state$b = {
1058
+ const state$a = {
1059
1059
  id: 0
1060
1060
  };
1061
1061
  const create$3$1 = () => {
1062
- return ++state$b.id;
1062
+ return ++state$a.id;
1063
1063
  };
1064
1064
  const warn$1 = (...args) => {
1065
1065
  console.warn(...args);
@@ -1344,13 +1344,13 @@ const invokeAndTransfer$2 = async (ipc, handle, method, ...params) => {
1344
1344
  return result;
1345
1345
  };
1346
1346
 
1347
- const state$a = {
1347
+ const state$9 = {
1348
1348
  commands: Object.create(null)
1349
1349
  };
1350
1350
 
1351
1351
  // @ts-ignore
1352
1352
  const registerCommand = (key, fn) => {
1353
- state$a.commands[key] = fn;
1353
+ state$9.commands[key] = fn;
1354
1354
  };
1355
1355
 
1356
1356
  // @ts-ignore
@@ -1362,7 +1362,7 @@ const registerCommands = commandMap => {
1362
1362
 
1363
1363
  // @ts-ignore
1364
1364
  const getCommand = key => {
1365
- return state$a.commands[key];
1365
+ return state$9.commands[key];
1366
1366
  };
1367
1367
 
1368
1368
  const processName = 'editor-worker';
@@ -1383,7 +1383,7 @@ const preparePrettyError = error => {
1383
1383
  return error;
1384
1384
  };
1385
1385
  const logError$1 = error => {
1386
- console.error(error);
1386
+ // handled in renderer worker
1387
1387
  };
1388
1388
  const handleMessage = event => {
1389
1389
  return handleJsonRpcMessage(event.target, event.data, execute$1, resolve, preparePrettyError, logError$1, requiresSocket);
@@ -1424,17 +1424,17 @@ let IpcError$1 = class IpcError extends Error {
1424
1424
  }
1425
1425
  };
1426
1426
 
1427
- const state$9 = {
1427
+ const state$8 = {
1428
1428
  /**
1429
1429
  * @type {any}
1430
1430
  */
1431
1431
  ipc: undefined
1432
1432
  };
1433
1433
  const get$3 = () => {
1434
- return state$9.ipc;
1434
+ return state$8.ipc;
1435
1435
  };
1436
1436
  const set$3 = ipc => {
1437
- state$9.ipc = ipc;
1437
+ state$8.ipc = ipc;
1438
1438
  };
1439
1439
 
1440
1440
  const invoke$3 = (method, ...params) => {
@@ -2071,7 +2071,7 @@ const y = (editor, rowIndex) => {
2071
2071
  return offsetY;
2072
2072
  };
2073
2073
 
2074
- const state$8 = {
2074
+ const state$7 = {
2075
2075
  timeout: -1
2076
2076
  };
2077
2077
 
@@ -2101,7 +2101,7 @@ const editorShowMessage = async (editor, rowIndex, columnIndex, message, isError
2101
2101
 
2102
2102
  // TODO use wrapper timing module instead of this
2103
2103
  // @ts-ignore
2104
- state$8.timeout = setTimeout(handleTimeout, 3_000);
2104
+ state$7.timeout = setTimeout(handleTimeout, 3_000);
2105
2105
  }
2106
2106
  return editor;
2107
2107
  };
@@ -2121,8 +2121,8 @@ const showErrorMessage = (editor, rowIndex, columnIndex, message) => {
2121
2121
 
2122
2122
  // @ts-ignore
2123
2123
  const editorHideMessage = async editor => {
2124
- clearTimeout(state$8.timeout);
2125
- state$8.timeout = -1;
2124
+ clearTimeout(state$7.timeout);
2125
+ state$7.timeout = -1;
2126
2126
  // await RendererProcess.invoke(/* Viewlet.send */ 'Viewlet.send', /* id */ editor.uid, /* method */ 'hideOverlayMessage')
2127
2127
  return editor;
2128
2128
  };
@@ -2189,14 +2189,14 @@ const closeCompletion = async editor => {
2189
2189
  };
2190
2190
 
2191
2191
  // @ts-ignore
2192
- const state$7 = {
2192
+ const state$6 = {
2193
2193
  isComposing: false,
2194
2194
  compositionText: ''
2195
2195
  };
2196
2196
 
2197
2197
  // @ts-ignore
2198
2198
  const compositionStart = (editor, event) => {
2199
- state$7.isComposing = true;
2199
+ state$6.isComposing = true;
2200
2200
  return editor;
2201
2201
  };
2202
2202
 
@@ -2208,7 +2208,7 @@ const getCompositionChanges = (selections, data) => {
2208
2208
  const selectionStartColumn = selections[i + 1];
2209
2209
  const selectionEndRow = selections[i + 2];
2210
2210
  const selectionEndColumn = selections[i + 3];
2211
- const startColumnIndex = selectionStartColumn - state$7.compositionText.length;
2211
+ const startColumnIndex = selectionStartColumn - state$6.compositionText.length;
2212
2212
  changes.push({
2213
2213
  start: {
2214
2214
  rowIndex: selectionStartRow,
@@ -2219,7 +2219,7 @@ const getCompositionChanges = (selections, data) => {
2219
2219
  columnIndex: selectionEndColumn
2220
2220
  },
2221
2221
  inserted: [data],
2222
- deleted: [state$7.compositionText],
2222
+ deleted: [state$6.compositionText],
2223
2223
  origin: CompositionUpdate
2224
2224
  });
2225
2225
  }
@@ -2230,7 +2230,7 @@ const getCompositionChanges = (selections, data) => {
2230
2230
  const compositionUpdate = (editor, data) => {
2231
2231
  const selections = editor.selections;
2232
2232
  const changes = getCompositionChanges(selections, data);
2233
- state$7.compositionText = data;
2233
+ state$6.compositionText = data;
2234
2234
  return scheduleDocumentAndCursorsSelections(editor, changes);
2235
2235
  };
2236
2236
 
@@ -2238,8 +2238,8 @@ const compositionUpdate = (editor, data) => {
2238
2238
  const compositionEnd = (editor, data) => {
2239
2239
  const selections = editor.selections;
2240
2240
  const changes = getCompositionChanges(selections, data);
2241
- state$7.isComposing = false;
2242
- state$7.compositionText = '';
2241
+ state$6.isComposing = false;
2242
+ state$6.compositionText = '';
2243
2243
  return scheduleDocumentAndCursorsSelections(editor, changes);
2244
2244
  };
2245
2245
 
@@ -3439,19 +3439,19 @@ const Single = 1;
3439
3439
  const Double = 2;
3440
3440
  const Triple = 3;
3441
3441
 
3442
- const state$6 = {
3442
+ const state$5 = {
3443
3443
  position: {
3444
3444
  rowIndex: 0,
3445
3445
  columnIndex: 0
3446
3446
  }
3447
3447
  };
3448
3448
  const getPosition$1 = () => {
3449
- return state$6.position;
3449
+ return state$5.position;
3450
3450
  };
3451
3451
 
3452
3452
  // @ts-ignore
3453
3453
  const setPosition$1 = position => {
3454
- state$6.position = position;
3454
+ state$5.position = position;
3455
3455
  };
3456
3456
 
3457
3457
  const Ctrl = 1;
@@ -3588,20 +3588,20 @@ const handleMouseDown = (state, modifier, x, y, detail) => {
3588
3588
  }
3589
3589
  };
3590
3590
 
3591
- const state$5 = {
3591
+ const state$4 = {
3592
3592
  timeout: -1,
3593
3593
  x: 0,
3594
3594
  y: 0,
3595
3595
  editor: undefined
3596
3596
  };
3597
3597
  const get$2 = () => {
3598
- return state$5;
3598
+ return state$4;
3599
3599
  };
3600
3600
  const set$2 = (editor, timeout, x, y) => {
3601
- state$5.editor = editor;
3602
- state$5.timeout = timeout;
3603
- state$5.x = x;
3604
- state$5.y = y;
3601
+ state$4.editor = editor;
3602
+ state$4.timeout = timeout;
3603
+ state$4.x = x;
3604
+ state$4.y = y;
3605
3605
  };
3606
3606
 
3607
3607
  const showHover$1 = async (editor, position) => {
@@ -3759,7 +3759,7 @@ const editorHandleNativeSelectionChange = (editor, range) => {
3759
3759
  return scheduleSelections(editor, selections);
3760
3760
  };
3761
3761
 
3762
- const state$4 = {
3762
+ const state$3 = {
3763
3763
  /**
3764
3764
  * @type {any}
3765
3765
  */
@@ -3773,26 +3773,26 @@ const state$4 = {
3773
3773
 
3774
3774
  // @ts-ignore
3775
3775
  const setEditor = editor => {
3776
- state$4.currentEditor = editor;
3777
- state$4.hasListener = true;
3776
+ state$3.currentEditor = editor;
3777
+ state$3.hasListener = true;
3778
3778
  };
3779
3779
  const clearEditor = () => {
3780
- state$4.currentEditor = undefined;
3781
- state$4.hasListener = false;
3780
+ state$3.currentEditor = undefined;
3781
+ state$3.hasListener = false;
3782
3782
  };
3783
3783
 
3784
3784
  // @ts-ignore
3785
3785
  const setPosition = position => {
3786
- state$4.position = position;
3786
+ state$3.position = position;
3787
3787
  };
3788
3788
  const getEditor$1 = () => {
3789
- return state$4.currentEditor;
3789
+ return state$3.currentEditor;
3790
3790
  };
3791
3791
  const getPosition = () => {
3792
- return state$4.position;
3792
+ return state$3.position;
3793
3793
  };
3794
3794
  const hasListener = () => {
3795
- return state$4.hasListener;
3795
+ return state$3.hasListener;
3796
3796
  };
3797
3797
 
3798
3798
  // @ts-ignore
@@ -3961,7 +3961,7 @@ const handleScrollBarPointerDown = (state, eventY) => {
3961
3961
  };
3962
3962
  };
3963
3963
 
3964
- const state$3 = {
3964
+ const state$2 = {
3965
3965
  touchOffsetY: 0,
3966
3966
  deltaY: 0
3967
3967
  };
@@ -3972,8 +3972,8 @@ const handleTouchStart = (editor, touchEvent) => {
3972
3972
  return;
3973
3973
  }
3974
3974
  const firstTouch = touchEvent.touches[0];
3975
- state$3.touchOffsetY = firstTouch.y;
3976
- state$3.deltaY = editor.deltaY;
3975
+ state$2.touchOffsetY = firstTouch.y;
3976
+ state$2.deltaY = editor.deltaY;
3977
3977
  // const position = EditorPosition.at(editor, firstTouch.x, firstTouch.y)
3978
3978
  // EditorMoveSelection.state.position = position
3979
3979
  // state.date = Date.now()
@@ -4051,7 +4051,7 @@ const handleTouchEnd = (editor, touchEvent) => {
4051
4051
  // @ts-ignore
4052
4052
  if (undefined.position.rowIndex === position.rowIndex && undefined.position.columnIndex === position.columnIndex) {
4053
4053
  // @ts-ignore
4054
- if (Date.now() - state$3.date > LONG_TOUCH_THRESHOLD) {
4054
+ if (Date.now() - state$2.date > LONG_TOUCH_THRESHOLD) {
4055
4055
  selectWord(editor, position.rowIndex, position.columnIndex);
4056
4056
  } else {
4057
4057
  // @ts-ignore
@@ -4098,7 +4098,7 @@ const handleTouchMove = (editor, touchEvent) => {
4098
4098
  return;
4099
4099
  }
4100
4100
  const firstTouch = touchEvent.touches[0];
4101
- const offsetY = state$3.deltaY + (state$3.touchOffsetY - firstTouch.y);
4101
+ const offsetY = state$2.deltaY + (state$2.touchOffsetY - firstTouch.y);
4102
4102
  setDeltaYFixedValue(editor, offsetY);
4103
4103
  };
4104
4104
 
@@ -5156,7 +5156,7 @@ const TokenizePlainText = {
5156
5156
  tokenizeLine
5157
5157
  };
5158
5158
 
5159
- const state$2 = {
5159
+ const state$1 = {
5160
5160
  tokenizers: Object.create(null),
5161
5161
  tokenizePaths: Object.create(null),
5162
5162
  listeners: [],
@@ -5167,16 +5167,16 @@ const state$2 = {
5167
5167
  connectedEditors: []
5168
5168
  };
5169
5169
  const has = languageId => {
5170
- return languageId in state$2.tokenizers;
5170
+ return languageId in state$1.tokenizers;
5171
5171
  };
5172
5172
  const set$1 = (languageId, tokenizer) => {
5173
- state$2.tokenizers[languageId] = tokenizer;
5173
+ state$1.tokenizers[languageId] = tokenizer;
5174
5174
  };
5175
5175
  const get$1 = languageId => {
5176
- return state$2.tokenizers[languageId];
5176
+ return state$1.tokenizers[languageId];
5177
5177
  };
5178
5178
  const isPending = languageId => {
5179
- return languageId in state$2.pending;
5179
+ return languageId in state$1.pending;
5180
5180
  };
5181
5181
 
5182
5182
  // TODO loadTokenizer should be invoked from renderer worker
@@ -6222,24 +6222,25 @@ const focusPrevious = state => {
6222
6222
  return focusIndex(state, matchIndex - 1);
6223
6223
  };
6224
6224
 
6225
- const state$1 = {
6226
- pending: Object.create(null),
6227
- loaded: Object.create(null)
6228
- };
6225
+ const pending = Object.create(null);
6226
+ const loaded = Object.create(null);
6229
6227
  const setPending = (id, promise) => {
6230
- state$1.pending[id] = promise;
6228
+ pending[id] = promise;
6231
6229
  };
6232
6230
  const getPending = id => {
6233
- return state$1.pending[id];
6231
+ return pending[id];
6234
6232
  };
6235
6233
  const hasPending = id => {
6236
- return id in state$1.pending;
6234
+ return id in pending;
6237
6235
  };
6238
6236
  const removePending = id => {
6239
- delete state$1.pending[id];
6237
+ delete pending[id];
6238
+ };
6239
+ const setLoaded = id => {
6240
+ loaded[id] = true;
6240
6241
  };
6241
6242
  const isLoaded = id => {
6242
- return state$1.loaded[id];
6243
+ return loaded[id];
6243
6244
  };
6244
6245
 
6245
6246
  const getFonts = () => {
@@ -6278,6 +6279,7 @@ const ensure = async (fontName, fontUrl) => {
6278
6279
  setPending(fontName, promise);
6279
6280
  await promise;
6280
6281
  removePending(fontName);
6282
+ setLoaded(fontName);
6281
6283
  };
6282
6284
 
6283
6285
  const OnHover = 'onHover';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "",
5
5
  "main": "dist/testWorkerMain.js",
6
6
  "type": "module",
@@ -49,6 +49,5 @@
49
49
  "ignores": [
50
50
  "distmin"
51
51
  ]
52
- },
53
- "dependencies": {}
52
+ }
54
53
  }