@lvce-editor/editor-worker 3.4.0 → 3.5.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.
@@ -1,3 +1,16 @@
1
+ const addWidget$1 = (widget, id, render) => {
2
+ const commands = render(widget);
3
+ // TODO how to generate a unique integer id
4
+ // that doesn't collide with ids created in renderer worker?
5
+ // @ts-ignore
6
+ const uid = widget.newState.uid;
7
+ const allCommands = [];
8
+ allCommands.push(['Viewlet.createFunctionalRoot', id, uid]);
9
+ allCommands.push(...commands);
10
+ allCommands.push(['Viewlet.send', uid, 'appendWidget']);
11
+ return allCommands;
12
+ };
13
+
1
14
  const ColoredMaskIcon = 'ColoredMaskIcon';
2
15
  const ColorPicker$2 = 'ColorPicker';
3
16
  const ColorPickerBackgroundColor = 'ColorPickerBackgroundColor';
@@ -131,6 +144,11 @@ const renderFull$1 = (oldState, newState) => {
131
144
  return commands;
132
145
  };
133
146
 
147
+ const removeWidget$1 = widget => {
148
+ // @ts-ignore
149
+ return [['Viewlet.send', widget.newState.uid, 'dispose']];
150
+ };
151
+
134
152
  const render$7 = widget => {
135
153
  const commands = renderFull$1(widget.oldState, widget.newState);
136
154
  const wrappedCommands = [];
@@ -145,20 +163,9 @@ const render$7 = widget => {
145
163
  return wrappedCommands;
146
164
  };
147
165
  const add$2 = widget => {
148
- const commands = render$7(widget);
149
- const id = 'ColorPicker';
150
- // TODO how to generate a unique integer id
151
- // that doesn't collide with ids created in renderer worker?
152
- const uid = widget.newState.uid;
153
- const allCommands = [];
154
- allCommands.push(['Viewlet.createFunctionalRoot', id, uid]);
155
- allCommands.push(...commands);
156
- allCommands.push(['Viewlet.send', uid, 'appendWidget']);
157
- return allCommands;
158
- };
159
- const remove$3 = widget => {
160
- return [['Viewlet.send', widget.newState.uid, 'dispose']];
166
+ return addWidget$1(widget, 'ColorPicker', render$7);
161
167
  };
168
+ const remove$3 = removeWidget$1;
162
169
 
163
170
  const EditorColorPickerWidget = {
164
171
  __proto__: null,
@@ -197,6 +204,16 @@ const getCompletionDetailVirtualDom = content => {
197
204
  return dom;
198
205
  };
199
206
 
207
+ const renderParts = (render, oldState, newState) => {
208
+ const commands = [];
209
+ for (const item of render) {
210
+ if (!item.isEqual(oldState, newState)) {
211
+ commands.push(item.apply(oldState, newState));
212
+ }
213
+ }
214
+ return commands;
215
+ };
216
+
200
217
  const renderContent = {
201
218
  isEqual(oldState, newState) {
202
219
  return oldState.content === newState.content;
@@ -222,13 +239,7 @@ const renderBounds$2 = {
222
239
  };
223
240
  const render$6 = [renderContent, renderBounds$2];
224
241
  const renderFull = (oldState, newState) => {
225
- const commands = [];
226
- for (const item of render$6) {
227
- if (!item.isEqual(oldState, newState)) {
228
- commands.push(item.apply(oldState, newState));
229
- }
230
- }
231
- return commands;
242
+ return renderParts(render$6, oldState, newState);
232
243
  };
233
244
 
234
245
  const render$5 = widget => {
@@ -245,20 +256,9 @@ const render$5 = widget => {
245
256
  return wrappedCommands;
246
257
  };
247
258
  const add$1 = widget => {
248
- const commands = render$5(widget);
249
- const id = 'EditorCompletionDetails';
250
- // TODO how to generate a unique integer id
251
- // that doesn't collide with ids created in renderer worker?
252
- const uid = widget.newState.uid;
253
- const allCommands = [];
254
- allCommands.push(['Viewlet.createFunctionalRoot', id, uid]);
255
- allCommands.push(...commands);
256
- allCommands.push(['Viewlet.send', uid, 'appendWidget']);
257
- return allCommands;
258
- };
259
- const remove$2 = widget => {
260
- return [['Viewlet.send', widget.newState.uid, 'dispose']];
259
+ return addWidget$1(widget, 'EditorCompletionDetails', render$5);
261
260
  };
261
+ const remove$2 = removeWidget$1;
262
262
 
263
263
  const EditorCompletionDetailWidget = {
264
264
  __proto__: null,
@@ -456,7 +456,7 @@ const getAccurateColumnIndexAscii = (line, guess, averageCharWidth, eventX, font
456
456
  const supported = () => {
457
457
  return 'Segmenter' in Intl;
458
458
  };
459
- const create$9 = () => {
459
+ const create$a = () => {
460
460
  // @ts-ignore
461
461
  const segmenter = new Intl.Segmenter();
462
462
  return {
@@ -494,7 +494,7 @@ const create$9 = () => {
494
494
 
495
495
  // @ts-ignore
496
496
  const getAccurateColumnIndexUnicode = (line, guess, averageCharWidth, eventX, fontWeight, fontSize, fontFamily, letterSpacing) => {
497
- const segmenter = create$9();
497
+ const segmenter = create$a();
498
498
  const segments = segmenter.getSegments(line);
499
499
  const isMonospaceFont = false;
500
500
  const charWidth = 0;
@@ -645,7 +645,8 @@ const UiStrings = {
645
645
  NoDefinitionFoundFor: "No definition found for '{PH1}'",
646
646
  NoTypeDefinitionFound: 'No type definition found',
647
647
  NoTypeDefinitionFoundFor: "No type definition found for '{PH1}'",
648
- NoResults: 'No Results'
648
+ NoResults: 'No Results',
649
+ Replace: 'Replace'
649
650
  };
650
651
  const noDefinitionFound = () => {
651
652
  return i18nString(UiStrings.NoDefinitionFound);
@@ -1187,9 +1188,7 @@ const add = widget => {
1187
1188
  allCommands.push(...commands);
1188
1189
  return allCommands;
1189
1190
  };
1190
- const remove$1 = widget => {
1191
- return [['Viewlet.send', widget.newState.uid, 'dispose']];
1192
- };
1191
+ const remove$1 = removeWidget$1;
1193
1192
  const handleEditorType$1 = (editor, state) => {
1194
1193
  const {
1195
1194
  unfilteredItems,
@@ -1332,13 +1331,7 @@ const renderColorPickerDom = {
1332
1331
  };
1333
1332
  const render$2 = [renderColorPickerDom, renderColor, renderOffsetX];
1334
1333
  const renderColorPicker = async (oldState, newState) => {
1335
- const commands = [];
1336
- for (const item of render$2) {
1337
- if (!item.isEqual(oldState, newState)) {
1338
- commands.push(item.apply(oldState, newState));
1339
- }
1340
- }
1341
- return commands;
1334
+ return renderParts(render$2, oldState, newState);
1342
1335
  };
1343
1336
 
1344
1337
  // TODO use numeric enum
@@ -2413,7 +2406,7 @@ const getErrorResponse = (message, error, preparePrettyError, logError) => {
2413
2406
  const errorProperty = getErrorProperty(error, prettyError);
2414
2407
  return create$1$1(message, errorProperty);
2415
2408
  };
2416
- const create$8 = (message, result) => {
2409
+ const create$9 = (message, result) => {
2417
2410
  return {
2418
2411
  jsonrpc: Two,
2419
2412
  id: message.id,
@@ -2422,7 +2415,7 @@ const create$8 = (message, result) => {
2422
2415
  };
2423
2416
  const getSuccessResponse = (message, result) => {
2424
2417
  const resultProperty = result ?? null;
2425
- return create$8(message, resultProperty);
2418
+ return create$9(message, resultProperty);
2426
2419
  };
2427
2420
  const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
2428
2421
  try {
@@ -2654,7 +2647,7 @@ const waitForFirstMessage$1 = async port => {
2654
2647
  return event;
2655
2648
  };
2656
2649
 
2657
- const create$7 = async () => {
2650
+ const create$8 = async () => {
2658
2651
  const {
2659
2652
  port1,
2660
2653
  port2
@@ -2699,7 +2692,7 @@ const wrap$3 = port => {
2699
2692
 
2700
2693
  const IpcParentWithExtensionHostWorker = {
2701
2694
  __proto__: null,
2702
- create: create$7,
2695
+ create: create$8,
2703
2696
  wrap: wrap$3
2704
2697
  };
2705
2698
 
@@ -2707,7 +2700,7 @@ const sendMessagePortToSyntaxHighlightingWorker = async port => {
2707
2700
  await invokeAndTransfer('SendMessagePortToSyntaxHighlightingWorker.sendMessagePortToSyntaxHighlightingWorker', port, 'HandleMessagePort.handleMessagePort');
2708
2701
  };
2709
2702
 
2710
- const create$6 = async () => {
2703
+ const create$7 = async () => {
2711
2704
  const {
2712
2705
  port1,
2713
2706
  port2
@@ -2752,7 +2745,7 @@ const wrap$1 = port => {
2752
2745
 
2753
2746
  const IpcParentWithSyntaxHighlightingWorker = {
2754
2747
  __proto__: null,
2755
- create: create$6,
2748
+ create: create$7,
2756
2749
  wrap: wrap$1
2757
2750
  };
2758
2751
 
@@ -2760,7 +2753,7 @@ const sendMessagePortToRendererProcess = async port => {
2760
2753
  await invokeAndTransfer('SendMessagePortToRendererProcess.sendMessagePortToRendererProcess', port, 'HandleMessagePort.handleMessagePort');
2761
2754
  };
2762
2755
 
2763
- const create$5 = async () => {
2756
+ const create$6 = async () => {
2764
2757
  const {
2765
2758
  port1,
2766
2759
  port2
@@ -2805,7 +2798,7 @@ const wrap = port => {
2805
2798
 
2806
2799
  const IpcParentWithRendererProcess = {
2807
2800
  __proto__: null,
2808
- create: create$5,
2801
+ create: create$6,
2809
2802
  wrap
2810
2803
  };
2811
2804
 
@@ -2822,7 +2815,7 @@ const getModule$1 = method => {
2822
2815
  }
2823
2816
  };
2824
2817
 
2825
- const create$4 = async ({
2818
+ const create$5 = async ({
2826
2819
  method,
2827
2820
  ...options
2828
2821
  }) => {
@@ -2840,7 +2833,7 @@ const create$4 = async ({
2840
2833
  const createRpc = method => {
2841
2834
  let _ipc;
2842
2835
  const listen = async () => {
2843
- const ipc = await create$4({
2836
+ const ipc = await create$5({
2844
2837
  method
2845
2838
  });
2846
2839
  handleIpc(ipc);
@@ -3214,6 +3207,7 @@ const cancelSelection = editor => {
3214
3207
  const Completion = 'completion';
3215
3208
  const CompletionDetail = 'completionDetail';
3216
3209
  const ColorPicker$1 = 'colorPicker';
3210
+ const Find = 'find';
3217
3211
 
3218
3212
  const isCompletionWidget = widget => {
3219
3213
  return widget.id === Completion;
@@ -3233,6 +3227,84 @@ const closeCompletion = editor => {
3233
3227
  };
3234
3228
  };
3235
3229
 
3230
+ const create$4 = () => {
3231
+ return Math.random();
3232
+ };
3233
+
3234
+ const create$3 = () => {
3235
+ const completionUid = create$4();
3236
+ const widget = {
3237
+ id: ColorPicker$1,
3238
+ oldState: {
3239
+ color: '',
3240
+ offsetX: 0,
3241
+ min: 0,
3242
+ max: 0,
3243
+ uid: completionUid,
3244
+ x: 0,
3245
+ y: 0,
3246
+ width: 0,
3247
+ height: 0
3248
+ },
3249
+ newState: {
3250
+ color: '',
3251
+ offsetX: 0,
3252
+ min: 0,
3253
+ max: 0,
3254
+ uid: completionUid,
3255
+ x: 0,
3256
+ y: 0,
3257
+ width: 0,
3258
+ height: 0
3259
+ }
3260
+ };
3261
+ return widget;
3262
+ };
3263
+
3264
+ const ColorPicker = 41;
3265
+ const FindWidget$1 = 16;
3266
+ const EditorCompletion = 9;
3267
+
3268
+ const hasWidget = (widgets, id) => {
3269
+ for (const widget of widgets) {
3270
+ if (widget.id === id) {
3271
+ return true;
3272
+ }
3273
+ }
3274
+ return false;
3275
+ };
3276
+
3277
+ const setAdditionalFocus = async focusKey => {
3278
+ await invoke$3('Focus.setAdditionalFocus', focusKey);
3279
+ };
3280
+
3281
+ const openColorPicker = async editor => {
3282
+ const {
3283
+ widgets
3284
+ } = editor;
3285
+ if (hasWidget(widgets, ColorPicker$1)) {
3286
+ return editor;
3287
+ }
3288
+ const colorPickerWidget = create$3();
3289
+ const newState = loadContent$3(colorPickerWidget.newState);
3290
+ const newWidget = {
3291
+ ...colorPickerWidget,
3292
+ newState
3293
+ };
3294
+ const newWidgets = [...widgets, newWidget];
3295
+
3296
+ // TODO avoid side effect, apply focus shift during render
3297
+ await setAdditionalFocus(ColorPicker);
3298
+ const newEditor = {
3299
+ ...editor,
3300
+ widgets: newWidgets
3301
+ };
3302
+ // TODO
3303
+ return {
3304
+ ...newEditor
3305
+ };
3306
+ };
3307
+
3236
3308
  const state$6 = {
3237
3309
  isComposing: false,
3238
3310
  compositionText: ''
@@ -3527,7 +3599,7 @@ const characterLeft = (line, columnIndex) => {
3527
3599
  if (!supported()) {
3528
3600
  return 1;
3529
3601
  }
3530
- const segmenter = create$9();
3602
+ const segmenter = create$a();
3531
3603
  const last = segmenter.at(line, columnIndex - 1);
3532
3604
  return columnIndex - last.index;
3533
3605
  };
@@ -3538,7 +3610,7 @@ const characterRight = (line, columnIndex) => {
3538
3610
  if (!supported()) {
3539
3611
  return 1;
3540
3612
  }
3541
- const segmenter = create$9();
3613
+ const segmenter = create$a();
3542
3614
  const next = segmenter.at(line, columnIndex);
3543
3615
  return next.segment.length;
3544
3616
  };
@@ -5213,12 +5285,8 @@ const moveSelectionPx = (editor, x, y) => {
5213
5285
  return editorMoveSelection(editor, position);
5214
5286
  };
5215
5287
 
5216
- const create$3 = () => {
5217
- return Math.random();
5218
- };
5219
-
5220
5288
  const create$2 = () => {
5221
- const completionUid = create$3();
5289
+ const completionUid = create$4();
5222
5290
  const completionWidget = {
5223
5291
  id: Completion,
5224
5292
  oldState: {
@@ -5491,22 +5559,6 @@ const advance = (state, word) => {
5491
5559
  };
5492
5560
  };
5493
5561
 
5494
- const ColorPicker = 41;
5495
- const EditorCompletion = 9;
5496
-
5497
- const hasWidget = (widgets, id) => {
5498
- for (const widget of widgets) {
5499
- if (widget.id === id) {
5500
- return true;
5501
- }
5502
- }
5503
- return false;
5504
- };
5505
-
5506
- const setAdditionalFocus = async focusKey => {
5507
- await invoke$3('Focus.setAdditionalFocus', focusKey);
5508
- };
5509
-
5510
5562
  const openCompletion = async editor => {
5511
5563
  const {
5512
5564
  widgets,
@@ -5540,53 +5592,62 @@ const openCompletion = async editor => {
5540
5592
  };
5541
5593
  };
5542
5594
 
5595
+ const FindWidget = 'FindWidget';
5596
+ const openFind = async state => {
5597
+ await invoke$3('Viewlet.openWidget', FindWidget);
5598
+ return state;
5599
+ };
5600
+
5543
5601
  const create$1 = () => {
5544
- const completionUid = create$3();
5602
+ const uid = create$4();
5545
5603
  const widget = {
5546
- id: ColorPicker$1,
5604
+ id: Find,
5547
5605
  oldState: {
5548
- color: '',
5549
- offsetX: 0,
5550
- min: 0,
5551
- max: 0,
5552
- uid: completionUid,
5553
- x: 0,
5554
- y: 0,
5555
- width: 0,
5556
- height: 0
5606
+ value: '',
5607
+ ariaAnnouncement: '',
5608
+ matches: new Uint32Array(),
5609
+ matchIndex: -1,
5610
+ matchCount: 0,
5611
+ uid,
5612
+ replaceExpanded: false,
5613
+ useRegularExpression: false,
5614
+ matchCase: false,
5615
+ matchWholeWord: false,
5616
+ replacement: '',
5617
+ editorUid: 0
5557
5618
  },
5558
5619
  newState: {
5559
- color: '',
5560
- offsetX: 0,
5561
- min: 0,
5562
- max: 0,
5563
- uid: completionUid,
5564
- x: 0,
5565
- y: 0,
5566
- width: 0,
5567
- height: 0
5620
+ value: '',
5621
+ ariaAnnouncement: '',
5622
+ matches: new Uint32Array(),
5623
+ matchIndex: -1,
5624
+ matchCount: 0,
5625
+ uid,
5626
+ replaceExpanded: false,
5627
+ useRegularExpression: false,
5628
+ matchCase: false,
5629
+ matchWholeWord: false,
5630
+ replacement: '',
5631
+ editorUid: 0
5568
5632
  }
5569
5633
  };
5570
5634
  return widget;
5571
5635
  };
5572
5636
 
5573
- const openColorPicker = async editor => {
5637
+ const openFind2 = async editor => {
5574
5638
  const {
5575
5639
  widgets
5576
5640
  } = editor;
5577
- if (hasWidget(widgets, ColorPicker$1)) {
5641
+ if (hasWidget(widgets, Find)) {
5578
5642
  return editor;
5579
5643
  }
5580
- const colorPickerWidget = create$1();
5581
- const newState = loadContent$3(colorPickerWidget.newState);
5644
+ const findWidget = create$1();
5582
5645
  const newWidget = {
5583
- ...colorPickerWidget,
5584
- newState
5646
+ ...findWidget
5585
5647
  };
5586
5648
  const newWidgets = [...widgets, newWidget];
5587
-
5588
5649
  // TODO avoid side effect, apply focus shift during render
5589
- await setAdditionalFocus(ColorPicker);
5650
+ await setAdditionalFocus(FindWidget$1);
5590
5651
  const newEditor = {
5591
5652
  ...editor,
5592
5653
  widgets: newWidgets
@@ -5597,12 +5658,6 @@ const openColorPicker = async editor => {
5597
5658
  };
5598
5659
  };
5599
5660
 
5600
- const FindWidget = 'FindWidget';
5601
- const openFind = async state => {
5602
- await invoke$3('Viewlet.openWidget', FindWidget);
5603
- return state;
5604
- };
5605
-
5606
5661
  const organizeImports = async editor => {
5607
5662
  // TODO ask extension host worker directly
5608
5663
  const edits = await invoke$3('ExtensionHostOrganizeImports.organizeImports', editor);
@@ -7367,7 +7422,7 @@ const focusPrevious$1 = editor => {
7367
7422
  };
7368
7423
 
7369
7424
  const create = () => {
7370
- const completionUid = create$3();
7425
+ const completionUid = create$4();
7371
7426
  const completionWidget = {
7372
7427
  id: CompletionDetail,
7373
7428
  oldState: {
@@ -7536,7 +7591,7 @@ const getHover = async (editor, offset) => {
7536
7591
 
7537
7592
  let _ipc;
7538
7593
  const listen$5 = async () => {
7539
- const ipc = await create$4({
7594
+ const ipc = await create$5({
7540
7595
  method: RendererProcess
7541
7596
  });
7542
7597
  handleIpc(ipc);
@@ -9153,9 +9208,10 @@ const commandMap = {
9153
9208
  'Editor.moveSelection': editorMoveSelection,
9154
9209
  'Editor.moveSelectionPx': moveSelectionPx,
9155
9210
  'Editor.offsetAt': offsetAt,
9156
- 'Editor.openCompletion': openCompletion,
9157
9211
  'Editor.openColorPicker': openColorPicker,
9212
+ 'Editor.openCompletion': openCompletion,
9158
9213
  'Editor.openFind': openFind,
9214
+ 'Editor.openFind2': openFind2,
9159
9215
  'Editor.organizeImports': organizeImports,
9160
9216
  'Editor.paste': paste,
9161
9217
  'Editor.pasteText': pasteText,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "3.4.0",
3
+ "version": "3.5.0",
4
4
  "description": "",
5
5
  "main": "dist/testWorkerMain.js",
6
6
  "type": "module",