@lvce-editor/editor-worker 4.12.0 → 5.0.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.
@@ -531,11 +531,8 @@ const measureTextWidth = (text, fontWeight, fontSize, fontFamily, letterSpacing,
531
531
  const letterSpacingString = getLetterSpacingString(letterSpacing);
532
532
  const fontString = getFontString(fontWeight, fontSize, fontFamily);
533
533
  const ctx = getContext();
534
- // @ts-ignore
535
534
  ctx.letterSpacing = letterSpacingString;
536
- // @ts-ignore
537
535
  ctx.font = fontString;
538
- // @ts-ignore
539
536
  const metrics = ctx.measureText(text);
540
537
  const width = metrics.width;
541
538
  return width;
@@ -1415,7 +1412,7 @@ const preparePrettyError = error => {
1415
1412
  const logError$1 = error => {
1416
1413
  // handled in renderer worker
1417
1414
  };
1418
- const handleMessage = event => {
1415
+ const handleMessage = async event => {
1419
1416
  return handleJsonRpcMessage(event.target, event.data, execute$1, resolve, preparePrettyError, logError$1, requiresSocket);
1420
1417
  };
1421
1418
 
@@ -1468,7 +1465,7 @@ const set$4 = ipc => {
1468
1465
  state$8.ipc = ipc;
1469
1466
  };
1470
1467
 
1471
- const invoke$4 = (method, ...params) => {
1468
+ const invoke$4 = async (method, ...params) => {
1472
1469
  const ipc = get$4();
1473
1470
  return invoke$5(ipc, method, ...params);
1474
1471
  };
@@ -1711,7 +1708,7 @@ const createRpc = method => {
1711
1708
  handleIpc(ipc);
1712
1709
  _ipc = ipc;
1713
1710
  };
1714
- const invoke = (method, ...params) => {
1711
+ const invoke = async (method, ...params) => {
1715
1712
  return invoke$5(_ipc, method, ...params);
1716
1713
  };
1717
1714
  return {
@@ -2205,7 +2202,7 @@ const editorShowMessage = async (editor, rowIndex, columnIndex, message, isError
2205
2202
  * @returns
2206
2203
  */
2207
2204
  // @ts-ignore
2208
- const showErrorMessage = (editor, rowIndex, columnIndex, message) => {
2205
+ const showErrorMessage = async (editor, rowIndex, columnIndex, message) => {
2209
2206
  return editorShowMessage(editor, rowIndex, columnIndex, message, /* isError */true);
2210
2207
  };
2211
2208
 
@@ -2268,8 +2265,7 @@ const cancelSelection = editor => {
2268
2265
  };
2269
2266
 
2270
2267
  const getIndex = (widgets, id) => {
2271
- for (let i = 0; i < widgets.length; i++) {
2272
- const widget = widgets[i];
2268
+ for (const [i, widget] of widgets.entries()) {
2273
2269
  if (widget.id === id) {
2274
2270
  return i;
2275
2271
  }
@@ -2324,7 +2320,8 @@ const closeFind = editor => {
2324
2320
  const newWidgets = removeEditorWidget(widgets, Find);
2325
2321
  return {
2326
2322
  ...editor,
2327
- widgets: newWidgets
2323
+ widgets: newWidgets,
2324
+ focused: true
2328
2325
  };
2329
2326
  };
2330
2327
 
@@ -2405,12 +2402,8 @@ const addWidgetToEditor = async (widgetId, focusKey, editor, factory, newStateGe
2405
2402
  };
2406
2403
  const newWidgets = [...widgets, latestWidget];
2407
2404
  // TODO avoid side effect, apply focus shift during render
2408
- if (fullFocus) {
2409
- await setFocus(focusKey);
2410
- } else {
2411
- await setAdditionalFocus(focusKey);
2412
- }
2413
- const newFocus = fullFocus ? false : true;
2405
+ await (fullFocus ? setFocus(focusKey) : setAdditionalFocus(focusKey));
2406
+ const newFocus = !fullFocus;
2414
2407
  const newEditor = {
2415
2408
  ...editor,
2416
2409
  widgets: newWidgets,
@@ -3021,7 +3014,7 @@ const cutSelectedText = async editor => {
3021
3014
  return scheduleDocumentAndCursorsSelections(editor, changes, selectionChanges);
3022
3015
  };
3023
3016
 
3024
- const cut = editor => {
3017
+ const cut = async editor => {
3025
3018
  const {
3026
3019
  selections
3027
3020
  } = editor;
@@ -3351,7 +3344,9 @@ const UiStrings$1 = {
3351
3344
  SourceAction: 'Source Action',
3352
3345
  OrganizeImports: 'Organize Imports',
3353
3346
  SortImports: 'Sort Imports',
3354
- NoCodeActionsAvailable: 'No code actions available'
3347
+ NoCodeActionsAvailable: 'No code actions available',
3348
+ EscapeToClose: 'Escape to close',
3349
+ EnterCode: 'Enter Code'
3355
3350
  };
3356
3351
  const noDefinitionFound = () => {
3357
3352
  return i18nString(UiStrings$1.NoDefinitionFound);
@@ -3378,6 +3373,12 @@ const sourceAction = () => {
3378
3373
  const noCodeActionsAvailable = () => {
3379
3374
  return i18nString(UiStrings$1.NoCodeActionsAvailable);
3380
3375
  };
3376
+ const escapeToClose = () => {
3377
+ return i18nString(UiStrings$1.EscapeToClose);
3378
+ };
3379
+ const enterCode = () => {
3380
+ return i18nString(UiStrings$1.EnterCode);
3381
+ };
3381
3382
 
3382
3383
  // @ts-ignore
3383
3384
  const goTo = async ({
@@ -3479,13 +3480,9 @@ const getErrorMessage$3 = error => {
3479
3480
 
3480
3481
  // @ts-ignore
3481
3482
  const isNoProviderFoundError$1 = error => {
3482
- return error &&
3483
- // @ts-ignore
3484
- error.message &&
3485
- // @ts-ignore
3486
- error.message.startsWith('Failed to execute definition provider: No definition provider found');
3483
+ return error?.message?.startsWith('Failed to execute definition provider: No definition provider found');
3487
3484
  };
3488
- const goToDefinition = editor => {
3485
+ const goToDefinition = async editor => {
3489
3486
  return goTo({
3490
3487
  editor,
3491
3488
  getLocation: getLocation$1,
@@ -3528,13 +3525,9 @@ const getErrorMessage$2 = error => {
3528
3525
  return `${error}`;
3529
3526
  };
3530
3527
  const isNoProviderFoundError = error => {
3531
- return error &&
3532
- // @ts-ignore
3533
- error.message &&
3534
- // @ts-ignore
3535
- error.message.startsWith('Failed to execute type definition provider: No type definition provider found');
3528
+ return error?.message?.startsWith('Failed to execute type definition provider: No type definition provider found');
3536
3529
  };
3537
- const goToTypeDefinition = (editor, explicit = true) => {
3530
+ const goToTypeDefinition = async (editor, explicit = true) => {
3538
3531
  return goTo({
3539
3532
  editor,
3540
3533
  getLocation,
@@ -4089,6 +4082,29 @@ const handleScrollBarPointerDown = (state, eventY) => {
4089
4082
  };
4090
4083
  };
4091
4084
 
4085
+ // const LONG_TOUCH_THRESHOLD = 150
4086
+
4087
+ // @ts-ignore
4088
+ const handleTouchEnd = (editor, touchEvent) => {
4089
+ // if (touchEvent.changedTouches.length === 0) {
4090
+ // return
4091
+ // }
4092
+ // const firstTouch = touchEvent.changedTouches[0]
4093
+ // const position = EditorPosition.at(editor, firstTouch.x, firstTouch.y)
4094
+ // @ts-ignore
4095
+ // if (EditorMoveSelection.state.position.rowIndex === position.rowIndex && EditorMoveSelection.state.position.columnIndex === position.columnIndex) {
4096
+ // // @ts-ignore
4097
+ // if (Date.now() - EditorHandleTouchStart.state.date > LONG_TOUCH_THRESHOLD) {
4098
+ // EditorSelectWord.selectWord(editor, position.rowIndex, position.columnIndex)
4099
+ // } else {
4100
+ // // @ts-ignore
4101
+ // EditorCursorSet.cursorSet(editor, position)
4102
+ // }
4103
+ // } else {
4104
+ // console.log('different position')
4105
+ // }
4106
+ };
4107
+
4092
4108
  const state$2 = {
4093
4109
  touchOffsetY: 0,
4094
4110
  deltaY: 0
@@ -4107,89 +4123,6 @@ const handleTouchStart = (editor, touchEvent) => {
4107
4123
  // state.date = Date.now()
4108
4124
  };
4109
4125
 
4110
- const LessThan = -1;
4111
- const Equal = 0;
4112
- const GreaterThan = 1;
4113
-
4114
- // @ts-ignore
4115
-
4116
- // @ts-ignore
4117
- const compare = (positionA, positionB) => {
4118
- if (positionA.rowIndex > positionB.rowIndex) {
4119
- return GreaterThan;
4120
- }
4121
- if (positionA.rowIndex === positionB.rowIndex) {
4122
- if (positionA.columnIndex > positionB.columnIndex) {
4123
- return GreaterThan;
4124
- }
4125
- if (positionA.columnIndex < positionB.columnIndex) {
4126
- return LessThan;
4127
- }
4128
- return Equal;
4129
- }
4130
- return LessThan;
4131
- };
4132
-
4133
- // @ts-ignore
4134
- const editorMoveSelectionBackwards = (anchor, position) => {
4135
- return new Uint32Array([anchor.rowIndex, anchor.columnIndex, position.rowIndex, position.columnIndex]);
4136
- };
4137
-
4138
- // @ts-ignore
4139
- const editorMoveSelectionEqual = (anchor, position) => {
4140
- return new Uint32Array([position.rowIndex, position.columnIndex, position.rowIndex, position.columnIndex]);
4141
- };
4142
-
4143
- // @ts-ignore
4144
- const editorMoveSelectionForwards = (anchor, position) => {
4145
- return new Uint32Array([anchor.rowIndex, anchor.columnIndex, position.rowIndex, position.columnIndex]);
4146
- };
4147
-
4148
- // @ts-ignore
4149
- const getNewSelections$5 = (anchor, position) => {
4150
- switch (compare(position, anchor)) {
4151
- case LessThan:
4152
- return editorMoveSelectionBackwards(anchor, position);
4153
- case Equal:
4154
- return editorMoveSelectionEqual(anchor, position);
4155
- case GreaterThan:
4156
- return editorMoveSelectionForwards(anchor, position);
4157
- default:
4158
- throw new Error('unexpected comparison result');
4159
- }
4160
- };
4161
-
4162
- // @ts-ignore
4163
- const editorMoveSelection = (editor, position) => {
4164
- const anchor = getPosition$1();
4165
- const newSelections = getNewSelections$5(anchor, position);
4166
- // TODO if selection equals previous selection -> do nothing
4167
- return scheduleSelections(editor, newSelections);
4168
- };
4169
-
4170
- const LONG_TOUCH_THRESHOLD = 150;
4171
-
4172
- // @ts-ignore
4173
- const handleTouchEnd = (editor, touchEvent) => {
4174
- if (touchEvent.changedTouches.length === 0) {
4175
- return;
4176
- }
4177
- const firstTouch = touchEvent.changedTouches[0];
4178
- const position = at(editor, firstTouch.x, firstTouch.y);
4179
- // @ts-ignore
4180
- if (undefined.position.rowIndex === position.rowIndex && undefined.position.columnIndex === position.columnIndex) {
4181
- // @ts-ignore
4182
- if (Date.now() - state$2.date > LONG_TOUCH_THRESHOLD) {
4183
- selectWord(editor, position.rowIndex, position.columnIndex);
4184
- } else {
4185
- // @ts-ignore
4186
- cursorSet(editor, position);
4187
- }
4188
- } else {
4189
- console.log('different position');
4190
- }
4191
- };
4192
-
4193
4126
  // @ts-ignore
4194
4127
  const setDeltaY$1 = (editor, deltaY) => {
4195
4128
  return setDeltaY$2(editor, deltaY);
@@ -4301,7 +4234,7 @@ const indentMore = editor => {
4301
4234
  return scheduleDocumentAndCursorsSelections(editor, changes);
4302
4235
  };
4303
4236
 
4304
- const getLanguageConfiguration = editor => {
4237
+ const getLanguageConfiguration = async editor => {
4305
4238
  return invoke$3('Languages.getLanguageConfiguration', {
4306
4239
  uri: editor.uri,
4307
4240
  languageId: editor.languageId
@@ -4309,7 +4242,7 @@ const getLanguageConfiguration = editor => {
4309
4242
  };
4310
4243
 
4311
4244
  const getIncreaseIndentRegex = languageConfiguration => {
4312
- if (languageConfiguration && languageConfiguration.indentationRules && languageConfiguration.indentationRules.increaseIndentPattern && typeof languageConfiguration.indentationRules.increaseIndentPattern === 'string') {
4245
+ if (languageConfiguration?.indentationRules?.increaseIndentPattern && typeof languageConfiguration.indentationRules.increaseIndentPattern === 'string') {
4313
4246
  const regex = new RegExp(languageConfiguration.indentationRules.increaseIndentPattern);
4314
4247
  return regex;
4315
4248
  }
@@ -4397,39 +4330,96 @@ const insertLineBreak = async editor => {
4397
4330
  return scheduleDocumentAndCursorsSelections(editor, changes, selectionChanges);
4398
4331
  };
4399
4332
 
4333
+ const moveRectangleSelection = (editor, position) => {
4334
+ // @ts-ignore
4335
+ // const anchor = EditorMoveSelection.state.position
4336
+ // const startRowIndex = anchor.rowIndex
4337
+ // const startColumnIndex = anchor.columnIndex
4338
+ // const endRowIndex = position.rowIndex
4339
+ // const endColumnIndex = position.columnIndex
4340
+ // const selectionEdits: any[] = []
4341
+ // for (let i = startRowIndex; i <= endRowIndex; i++) {
4342
+ // selectionEdits.push({
4343
+ // start: {
4344
+ // rowIndex: i,
4345
+ // columnIndex: startColumnIndex,
4346
+ // },
4347
+ // end: {
4348
+ // rowIndex: i,
4349
+ // columnIndex: endColumnIndex,
4350
+ // },
4351
+ // })
4352
+ // }
4353
+ // // @ts-ignore
4354
+ // const cursorEdits = [selectionEdits.at(-1).end]
4355
+ // // @ts-ignore
4356
+ // Editor.scheduleCursorsAndSelections(editor, cursorEdits, selectionEdits)
4357
+ return editor;
4358
+ };
4359
+
4400
4360
  // @ts-ignore
4361
+ const moveRectangleSelectionPx = (editor, x, y) => {
4362
+ at(editor, x, y);
4363
+ };
4364
+
4365
+ const LessThan = -1;
4366
+ const Equal = 0;
4367
+ const GreaterThan = 1;
4401
4368
 
4402
4369
  // @ts-ignore
4403
- const moveRectangleSelection = (editor, position) => {
4404
- // @ts-ignore
4405
- const anchor = undefined.position;
4406
- const startRowIndex = anchor.rowIndex;
4407
- const startColumnIndex = anchor.columnIndex;
4408
- const endRowIndex = position.rowIndex;
4409
- const endColumnIndex = position.columnIndex;
4410
- const selectionEdits = [];
4411
- for (let i = startRowIndex; i <= endRowIndex; i++) {
4412
- selectionEdits.push({
4413
- start: {
4414
- rowIndex: i,
4415
- columnIndex: startColumnIndex
4416
- },
4417
- end: {
4418
- rowIndex: i,
4419
- columnIndex: endColumnIndex
4420
- }
4421
- });
4370
+
4371
+ // @ts-ignore
4372
+ const compare = (positionA, positionB) => {
4373
+ if (positionA.rowIndex > positionB.rowIndex) {
4374
+ return GreaterThan;
4422
4375
  }
4423
- // @ts-ignore
4424
- const cursorEdits = [selectionEdits.at(-1).end];
4425
- // @ts-ignore
4426
- undefined(editor, cursorEdits, selectionEdits);
4376
+ if (positionA.rowIndex === positionB.rowIndex) {
4377
+ if (positionA.columnIndex > positionB.columnIndex) {
4378
+ return GreaterThan;
4379
+ }
4380
+ if (positionA.columnIndex < positionB.columnIndex) {
4381
+ return LessThan;
4382
+ }
4383
+ return Equal;
4384
+ }
4385
+ return LessThan;
4427
4386
  };
4428
4387
 
4429
4388
  // @ts-ignore
4430
- const moveRectangleSelectionPx = (editor, x, y) => {
4431
- const position = at(editor, x, y);
4432
- moveRectangleSelection(editor, position);
4389
+ const editorMoveSelectionBackwards = (anchor, position) => {
4390
+ return new Uint32Array([anchor.rowIndex, anchor.columnIndex, position.rowIndex, position.columnIndex]);
4391
+ };
4392
+
4393
+ // @ts-ignore
4394
+ const editorMoveSelectionEqual = (anchor, position) => {
4395
+ return new Uint32Array([position.rowIndex, position.columnIndex, position.rowIndex, position.columnIndex]);
4396
+ };
4397
+
4398
+ // @ts-ignore
4399
+ const editorMoveSelectionForwards = (anchor, position) => {
4400
+ return new Uint32Array([anchor.rowIndex, anchor.columnIndex, position.rowIndex, position.columnIndex]);
4401
+ };
4402
+
4403
+ // @ts-ignore
4404
+ const getNewSelections$5 = (anchor, position) => {
4405
+ switch (compare(position, anchor)) {
4406
+ case LessThan:
4407
+ return editorMoveSelectionBackwards(anchor, position);
4408
+ case Equal:
4409
+ return editorMoveSelectionEqual(anchor, position);
4410
+ case GreaterThan:
4411
+ return editorMoveSelectionForwards(anchor, position);
4412
+ default:
4413
+ throw new Error('unexpected comparison result');
4414
+ }
4415
+ };
4416
+
4417
+ // @ts-ignore
4418
+ const editorMoveSelection = (editor, position) => {
4419
+ const anchor = getPosition$1();
4420
+ const newSelections = getNewSelections$5(anchor, position);
4421
+ // TODO if selection equals previous selection -> do nothing
4422
+ return scheduleSelections(editor, newSelections);
4433
4423
  };
4434
4424
 
4435
4425
  const requestAnimationFrame = fn => {
@@ -4586,7 +4576,7 @@ const execute = async ({
4586
4576
  const combineResults$2 = results => {
4587
4577
  return results[0] ?? [];
4588
4578
  };
4589
- const executeCompletionProvider = (editor, offset) => {
4579
+ const executeCompletionProvider = async (editor, offset) => {
4590
4580
  return execute({
4591
4581
  editor,
4592
4582
  event: OnCompletion,
@@ -4600,7 +4590,7 @@ const executeCompletionProvider = (editor, offset) => {
4600
4590
  const combineResultsResolve = items => {
4601
4591
  return items[0] ?? undefined;
4602
4592
  };
4603
- const executeResolveCompletionItem = (editor, offset, name, completionItem) => {
4593
+ const executeResolveCompletionItem = async (editor, offset, name, completionItem) => {
4604
4594
  return execute({
4605
4595
  editor,
4606
4596
  event: OnCompletion,
@@ -5127,7 +5117,7 @@ const getSearchRegex = searchString => {
5127
5117
 
5128
5118
  const findRegexMatches = (lines, regex) => {
5129
5119
  if (!regex.global) {
5130
- throw new Error(`regex must be global`);
5120
+ throw new Error('regex must be global');
5131
5121
  }
5132
5122
  const {
5133
5123
  length
@@ -6349,7 +6339,6 @@ const loadTokenizer = async (languageId, tokenizePath) => {
6349
6339
  } catch (error) {
6350
6340
  // TODO better error handling
6351
6341
  console.error(error);
6352
- return;
6353
6342
  }
6354
6343
  };
6355
6344
  const getTokenizer = languageId => {
@@ -6471,7 +6460,7 @@ const create$3 = () => {
6471
6460
  return widget;
6472
6461
  };
6473
6462
 
6474
- const executeHoverProvider = (editor, offset) => {
6463
+ const executeHoverProvider = async (editor, offset) => {
6475
6464
  object(editor);
6476
6465
  number$1(offset);
6477
6466
  return execute({
@@ -6503,7 +6492,7 @@ const invoke = async (method, ...args) => {
6503
6492
  return invoke$5(_ipc, method, ...args);
6504
6493
  };
6505
6494
 
6506
- const measureTextBlockHeight = (text, fontFamily, fontSize, lineHeight, width) => {
6495
+ const measureTextBlockHeight = async (text, fontFamily, fontSize, lineHeight, width) => {
6507
6496
  return invoke('MeasureTextBlockHeight.measureTextBlockHeight', text, fontSize, fontFamily, lineHeight, width);
6508
6497
  };
6509
6498
 
@@ -6554,7 +6543,7 @@ const warnDeprecatedArrayReturn = (languageId, fn) => {
6554
6543
  const safeTokenizeLine = (languageId, tokenizeLine, line, lineStateAtStart, hasArrayReturn) => {
6555
6544
  try {
6556
6545
  const lineState = tokenizeLine(line, lineStateAtStart);
6557
- if (!lineState || !lineState.tokens || !lineState.state) {
6546
+ if (!lineState?.tokens || !lineState.state) {
6558
6547
  throw new Error('invalid tokenization result');
6559
6548
  }
6560
6549
  if (!hasArrayReturn) {
@@ -6705,7 +6694,7 @@ const loadHoverContent = async state => {
6705
6694
  };
6706
6695
  };
6707
6696
 
6708
- const newStateGenerator$1 = state => {
6697
+ const newStateGenerator$1 = async state => {
6709
6698
  return loadHoverContent(state);
6710
6699
  };
6711
6700
  const showHover2 = async editor => {
@@ -6791,7 +6780,7 @@ const create$2 = () => {
6791
6780
  };
6792
6781
 
6793
6782
  const showSourceActions = async editor => {
6794
- const newStateGenerator = state => {
6783
+ const newStateGenerator = async state => {
6795
6784
  return loadSourceActions(editor, state);
6796
6785
  };
6797
6786
  return addWidgetToEditor(SourceAction, SourceActions, editor, create$2, newStateGenerator);
@@ -6859,7 +6848,7 @@ const sortLinesAscending = editor => {
6859
6848
  const combineResults$1 = results => {
6860
6849
  return results[0];
6861
6850
  };
6862
- const executeTabCompletionProvider = (editor, offset) => {
6851
+ const executeTabCompletionProvider = async (editor, offset) => {
6863
6852
  return execute({
6864
6853
  editor,
6865
6854
  event: OnTabCompletion,
@@ -6996,7 +6985,7 @@ const tabCompletion = async editor => {
6996
6985
 
6997
6986
  const getBlockComment = async editor => {
6998
6987
  const languageConfiguration = await getLanguageConfiguration(editor);
6999
- if (!languageConfiguration || !languageConfiguration.comments || !languageConfiguration.comments.blockComment) {
6988
+ if (!languageConfiguration?.comments?.blockComment) {
7000
6989
  return undefined;
7001
6990
  }
7002
6991
  return languageConfiguration.comments.blockComment;
@@ -7204,7 +7193,7 @@ const toggleBlockComment = async editor => {
7204
7193
 
7205
7194
  const getLineComment = async editor => {
7206
7195
  const languageConfiguration = await getLanguageConfiguration(editor);
7207
- if (!languageConfiguration || !languageConfiguration.comments || !languageConfiguration.comments.lineComment) {
7196
+ if (!languageConfiguration?.comments?.lineComment) {
7208
7197
  return undefined;
7209
7198
  }
7210
7199
  return languageConfiguration.comments.lineComment;
@@ -7468,96 +7457,98 @@ const undo = state => {
7468
7457
  };
7469
7458
 
7470
7459
  // @ts-ignore
7471
- const INDENT = ' ';
7460
+
7461
+ // const INDENT = ' '
7472
7462
 
7473
7463
  // @ts-ignore
7474
7464
  const editorUnindent = editor => {
7475
- if (hasSelection(editor)) {
7476
- const documentEdits = [];
7477
- const cursorEdits = [];
7478
- const selectionEdits = [];
7479
- // @ts-ignore
7480
- const canUnindentSelection = selection => {
7481
- for (let i = selection.start.rowIndex; i <= selection.end.rowIndex; i++) {
7482
- if (editor.lines[i].startsWith(INDENT)) {
7483
- return true;
7484
- }
7485
- }
7486
- return false;
7487
- };
7488
- // TODO replace check with flag that indicates whether change occurred
7489
- // -> only iterate once over selection lines
7490
-
7491
- if (!editor.selections.some(canUnindentSelection)) {
7492
- return;
7493
- }
7494
- // @ts-ignore
7495
- const indentLineMaybe = rowIndex => {
7496
- if (editor.lines[rowIndex].startsWith(INDENT)) {
7497
- documentEdits.push({
7498
- type: /* singleLineEdit */1,
7499
- rowIndex,
7500
- columnIndex: INDENT.length,
7501
- deleted: INDENT.length,
7502
- inserted: ''
7503
- });
7504
- }
7505
- };
7506
- let previousRowIndex = -1;
7507
- for (const selection of editor.selections) {
7508
- let startRowIndex = selection.start.rowIndex;
7509
- const endRowIndex = selection.end.rowIndex;
7510
- if (startRowIndex === previousRowIndex) {
7511
- startRowIndex++;
7512
- }
7513
- for (let i = startRowIndex; i <= endRowIndex; i++) {
7514
- indentLineMaybe(i);
7515
- }
7516
- let start = selection.start;
7517
- let end = selection.end;
7518
- if (editor.lines[start.rowIndex].startsWith(INDENT)) {
7519
- start = {
7520
- rowIndex: start.rowIndex,
7521
- columnIndex: Math.max(start.columnIndex - INDENT.length, 0)
7522
- };
7523
- }
7524
- if (editor.lines[end.rowIndex].startsWith(INDENT)) {
7525
- end = {
7526
- rowIndex: end.rowIndex,
7527
- columnIndex: Math.max(end.columnIndex - INDENT.length, 0)
7528
- };
7529
- }
7530
- cursorEdits.push(end);
7531
- selectionEdits.push({
7532
- start,
7533
- end
7534
- });
7535
- previousRowIndex = endRowIndex;
7536
- }
7537
- // @ts-ignore
7538
- undefined(editor, documentEdits, cursorEdits, selectionEdits);
7539
- return;
7540
- }
7541
- const documentEdits = [];
7542
- const cursorEdits = [];
7543
- if (!editor.lines[editor.cursor.rowIndex].startsWith(INDENT)) {
7544
- return;
7545
- }
7546
- // @ts-ignore
7547
- documentEdits.push({
7548
- type: /* singleLineEdit */1,
7549
- rowIndex: editor.cursor.rowIndex,
7550
- inserted: '',
7551
- columnIndex: 2,
7552
- deleted: 2
7553
- });
7554
- // @ts-ignore
7555
- cursorEdits.push({
7556
- rowIndex: editor.cursor.rowIndex,
7557
- columnIndex: editor.cursor.columnIndex - 2
7558
- });
7559
- // @ts-ignore
7560
- undefined(editor, documentEdits, cursorEdits);
7465
+ // if (Editor.hasSelection(editor)) {
7466
+ // const documentEdits: any[] = []
7467
+ // const cursorEdits: any[] = []
7468
+ // const selectionEdits: any[] = []
7469
+ // // @ts-ignore
7470
+ // const canUnindentSelection = (selection) => {
7471
+ // for (let i = selection.start.rowIndex; i <= selection.end.rowIndex; i++) {
7472
+ // if (editor.lines[i].startsWith(INDENT)) {
7473
+ // return true
7474
+ // }
7475
+ // }
7476
+ // return false
7477
+ // }
7478
+ // // TODO replace check with flag that indicates whether change occurred
7479
+ // // -> only iterate once over selection lines
7480
+
7481
+ // if (!editor.selections.some(canUnindentSelection)) {
7482
+ // return
7483
+ // }
7484
+ // // @ts-ignore
7485
+ // const indentLineMaybe = (rowIndex) => {
7486
+ // if (editor.lines[rowIndex].startsWith(INDENT)) {
7487
+ // documentEdits.push({
7488
+ // type: /* singleLineEdit */ 1,
7489
+ // rowIndex,
7490
+ // columnIndex: INDENT.length,
7491
+ // deleted: INDENT.length,
7492
+ // inserted: '',
7493
+ // })
7494
+ // }
7495
+ // }
7496
+ // let previousRowIndex = -1
7497
+ // for (const selection of editor.selections) {
7498
+ // let startRowIndex = selection.start.rowIndex
7499
+ // const endRowIndex = selection.end.rowIndex
7500
+ // if (startRowIndex === previousRowIndex) {
7501
+ // startRowIndex++
7502
+ // }
7503
+ // for (let i = startRowIndex; i <= endRowIndex; i++) {
7504
+ // indentLineMaybe(i)
7505
+ // }
7506
+ // let start = selection.start
7507
+ // let end = selection.end
7508
+ // if (editor.lines[start.rowIndex].startsWith(INDENT)) {
7509
+ // start = {
7510
+ // rowIndex: start.rowIndex,
7511
+ // columnIndex: Math.max(start.columnIndex - INDENT.length, 0),
7512
+ // }
7513
+ // }
7514
+ // if (editor.lines[end.rowIndex].startsWith(INDENT)) {
7515
+ // end = {
7516
+ // rowIndex: end.rowIndex,
7517
+ // columnIndex: Math.max(end.columnIndex - INDENT.length, 0),
7518
+ // }
7519
+ // }
7520
+ // cursorEdits.push(end)
7521
+ // selectionEdits.push({
7522
+ // start,
7523
+ // end,
7524
+ // })
7525
+ // previousRowIndex = endRowIndex
7526
+ // }
7527
+ // // @ts-ignore
7528
+ // Editor.scheduleDocumentAndCursorsAndSelections(editor, documentEdits, cursorEdits, selectionEdits)
7529
+ // return
7530
+ // }
7531
+ // const documentEdits = []
7532
+ // const cursorEdits = []
7533
+ // if (!editor.lines[editor.cursor.rowIndex].startsWith(INDENT)) {
7534
+ // return
7535
+ // }
7536
+ // // @ts-ignore
7537
+ // documentEdits.push({
7538
+ // type: /* singleLineEdit */ 1,
7539
+ // rowIndex: editor.cursor.rowIndex,
7540
+ // inserted: '',
7541
+ // columnIndex: 2,
7542
+ // deleted: 2,
7543
+ // })
7544
+ // // @ts-ignore
7545
+ // cursorEdits.push({
7546
+ // rowIndex: editor.cursor.rowIndex,
7547
+ // columnIndex: editor.cursor.columnIndex - 2,
7548
+ // })
7549
+ // // @ts-ignore
7550
+ // Editor.scheduleDocumentAndCursors(editor, documentEdits, cursorEdits)
7551
+ return editor;
7561
7552
  };
7562
7553
  // const editor = {
7563
7554
  // textDocument: {
@@ -7854,6 +7845,9 @@ const handleSashPointerUp = (state, eventX, eventY) => {
7854
7845
  return state;
7855
7846
  };
7856
7847
 
7848
+ const CodeGeneratorInput = 'CodeGeneratorInput';
7849
+ const CodeGeneratorMessage = 'CodeGeneratorMessage';
7850
+ const CodeGeneratorWidget = 'CodeGeneratorWidget';
7857
7851
  const ColoredMaskIcon = 'ColoredMaskIcon';
7858
7852
  const ColorPicker = 'ColorPicker';
7859
7853
  const ColorPickerBackgroundColor = 'ColorPickerBackgroundColor';
@@ -7862,20 +7856,9 @@ const ColorPickerLight = 'ColorPickerLight';
7862
7856
  const ColorPickerRectangle = 'ColorPickerRectangle';
7863
7857
  const ColorPickerSlider = 'ColorPickerSlider';
7864
7858
  const ColorPickerSliderThumb = 'ColorPickerSliderThumb';
7865
- const SourceActionItem = 'SourceActionItem';
7866
- const SourceActionItemFocused = 'SourceActionItemFocused';
7867
7859
  const CompletionDetailCloseButton = 'CompletionDetailCloseButton';
7868
- const EditorSourceActionsList = 'EditorSourceActionsList';
7869
- const IconButtonDisabled = 'IconButtonDisabled';
7870
- const IconButton = 'IconButton';
7871
- const SourceActionHeading = 'SourceActionHeading';
7872
7860
  const CompletionDetailContent = 'CompletionDetailContent';
7873
7861
  const Diagnostic = 'Diagnostic';
7874
- const FindWidgetReplace = 'FindWidgetReplace';
7875
- const FindWidgetFind = 'FindWidgetFind';
7876
- const FindWidgetMatchCount = 'FindWidgetMatchCount';
7877
- const FindWidgetMatchCountEmpty = 'FindWidgetMatchCountEmpty';
7878
- const FindWidgetRight = 'FindWidgetRight';
7879
7862
  const EditorCompletionItem = 'EditorCompletionItem';
7880
7863
  const EditorCompletionItemDeprecated = 'EditorCompletionItemDeprecated';
7881
7864
  const EditorCompletionItemFocused = 'EditorCompletionItemFocused';
@@ -7883,19 +7866,34 @@ const EditorCompletionItemHighlight = 'EditorCompletionItemHighlight';
7883
7866
  const EditorCursor = 'EditorCursor';
7884
7867
  const EditorRow = 'EditorRow';
7885
7868
  const EditorSelection = 'EditorSelection';
7869
+ const EditorSourceActions = 'EditorSourceActions';
7870
+ const EditorSourceActionsList = 'EditorSourceActionsList';
7886
7871
  const FileIcon = 'FileIcon';
7872
+ const FindWidgetFind = 'FindWidgetFind';
7873
+ const FindWidgetMatchCount = 'FindWidgetMatchCount';
7874
+ const FindWidgetMatchCountEmpty = 'FindWidgetMatchCountEmpty';
7875
+ const FindWidgetReplace = 'FindWidgetReplace';
7876
+ const FindWidgetRight = 'FindWidgetRight';
7887
7877
  const HoverDisplayString = 'HoverDisplayString';
7888
7878
  const HoverDocumentation = 'HoverDocumentation';
7889
- const SearchFieldButtons = 'SearchFieldButtons';
7890
7879
  const HoverEditorRow = 'HoverEditorRow';
7891
- const MultilineInputBox = 'MultilineInputBox';
7892
- const SearchField = 'SearchField';
7893
7880
  const HoverProblem = 'HoverProblem';
7894
7881
  const HoverProblemDetail = 'HoverProblemDetail';
7895
7882
  const HoverProblemMessage = 'HoverProblemMessage';
7883
+ const IconButton = 'IconButton';
7884
+ const IconButtonDisabled = 'IconButtonDisabled';
7896
7885
  const IconClose = 'IconClose';
7886
+ const InputBox = 'InputBox';
7897
7887
  const Label = 'Label';
7898
7888
  const MaskIcon = 'MaskIcon';
7889
+ const MaskIconSymbolFile = 'MaskIconSymbolFile';
7890
+ const MultilineInputBox = 'MultilineInputBox';
7891
+ const SearchField = 'SearchField';
7892
+ const SearchFieldButtons = 'SearchFieldButtons';
7893
+ const SourceActionHeading = 'SourceActionHeading';
7894
+ const SourceActionIcon = 'SourceActionIcon';
7895
+ const SourceActionItem = 'SourceActionItem';
7896
+ const SourceActionItemFocused = 'SourceActionItemFocused';
7899
7897
  const Viewlet = 'Viewlet';
7900
7898
 
7901
7899
  const Button = 1;
@@ -8014,6 +8012,8 @@ const SetNegativeMargin = 'setNegativeMargin';
8014
8012
  const SetOffsetX = 'setOffsetX';
8015
8013
  const SetScrollBar = 'setScrollBar';
8016
8014
  const SetValue = 'setValue';
8015
+ const SetDom2 = 'Viewlet.setDom2';
8016
+ const Focus = 'focus';
8017
8017
 
8018
8018
  const renderHoverDom = {
8019
8019
  isEqual(oldState, newState) {
@@ -8021,10 +8021,10 @@ const renderHoverDom = {
8021
8021
  },
8022
8022
  apply(oldState, newState) {
8023
8023
  const dom = getHoverVirtualDom(newState.lineInfos, newState.documentation, newState.diagnostics);
8024
- return [/* method */'Viewlet.setDom2', dom];
8024
+ return [/* method */SetDom2, dom];
8025
8025
  }
8026
8026
  };
8027
- const renderBounds$6 = {
8027
+ const renderBounds$7 = {
8028
8028
  isEqual(oldState, newState) {
8029
8029
  return oldState.x === newState.x && oldState.y === newState.y;
8030
8030
  },
@@ -8038,10 +8038,10 @@ const renderBounds$6 = {
8038
8038
  return [SetBounds, x, y, renderWidth, height];
8039
8039
  }
8040
8040
  };
8041
- const render$f = [renderHoverDom, renderBounds$6];
8041
+ const render$g = [renderHoverDom, renderBounds$7];
8042
8042
  const renderHover = (oldState, newState) => {
8043
8043
  const commands = [];
8044
- for (const item of render$f) {
8044
+ for (const item of render$g) {
8045
8045
  if (!item.isEqual(oldState, newState)) {
8046
8046
  commands.push(item.apply(oldState, newState));
8047
8047
  }
@@ -8052,7 +8052,7 @@ const renderHover = (oldState, newState) => {
8052
8052
  const combineResults = results => {
8053
8053
  return results[0] ?? [];
8054
8054
  };
8055
- const executeRenameProvider = (editor, offset, newName) => {
8055
+ const executeRenameProvider = async (editor, offset, newName) => {
8056
8056
  return execute({
8057
8057
  editor,
8058
8058
  event: OnRename,
@@ -8069,7 +8069,7 @@ const getRenameState = editor => {
8069
8069
  };
8070
8070
 
8071
8071
  const getRenameChanges = (editor, result) => {
8072
- if (!result || !result.edits) {
8072
+ if (!result?.edits) {
8073
8073
  return [];
8074
8074
  }
8075
8075
  const changes = [];
@@ -8314,25 +8314,28 @@ const intialize = async (syntaxHighlightingEnabled, syncIncremental) => {
8314
8314
  // TODO multiple cursors -> vscode removes multiple cursors
8315
8315
  // TODO with selection -> vscode moves whole selection
8316
8316
  const moveLineDown = editor => {
8317
- const rowIndex = editor.cursor.rowIndex;
8318
- if (rowIndex === editor.lines.length - 1) {
8319
- return;
8320
- }
8321
- const documentEdits = [{
8322
- type: /* splice */2,
8323
- rowIndex: rowIndex,
8324
- count: 2,
8325
- newLines: [getLine(editor.textDocument, rowIndex + 1), getLine(editor.textDocument, rowIndex)]
8326
- }];
8327
- // @ts-ignore
8328
- const cursorEdits = undefined(editor, (editor, cursor) => {
8329
- return {
8330
- rowIndex: cursor.rowIndex + 1,
8331
- columnIndex: cursor.columnIndex
8332
- };
8333
- });
8317
+ // const rowIndex = editor.cursor.rowIndex
8318
+ // if (rowIndex === editor.lines.length - 1) {
8319
+ // return
8320
+ // }
8321
+ // const documentEdits = [
8322
+ // {
8323
+ // type: /* splice */ 2,
8324
+ // rowIndex: rowIndex,
8325
+ // count: 2,
8326
+ // newLines: [TextDocument.getLine(editor.textDocument, rowIndex + 1), TextDocument.getLine(editor.textDocument, rowIndex)],
8327
+ // },
8328
+ // ]
8329
+ // // @ts-ignore
8330
+ // const cursorEdits = Editor.moveCursors(editor, (editor, cursor) => {
8331
+ // return {
8332
+ // rowIndex: cursor.rowIndex + 1,
8333
+ // columnIndex: cursor.columnIndex,
8334
+ // }
8335
+ // })
8334
8336
  // @ts-ignore
8335
- undefined(editor, documentEdits, cursorEdits);
8337
+ // Editor.scheduleDocumentAndCursors(editor, documentEdits, cursorEdits)
8338
+ return editor;
8336
8339
  };
8337
8340
 
8338
8341
  const create = () => {
@@ -8341,11 +8344,23 @@ const create = () => {
8341
8344
  id: CodeGenerator,
8342
8345
  oldState: {
8343
8346
  uid: completionUid,
8344
- questions: []
8347
+ questions: [],
8348
+ x: 0,
8349
+ y: 0,
8350
+ width: 0,
8351
+ height: 0,
8352
+ focused: false,
8353
+ focusSource: Unknown$1
8345
8354
  },
8346
8355
  newState: {
8347
8356
  uid: completionUid,
8348
- questions: []
8357
+ questions: [],
8358
+ x: 0,
8359
+ y: 0,
8360
+ width: 0,
8361
+ height: 0,
8362
+ focused: true,
8363
+ focusSource: Script
8349
8364
  }
8350
8365
  };
8351
8366
  return widget;
@@ -8353,7 +8368,11 @@ const create = () => {
8353
8368
 
8354
8369
  const newStateGenerator = async state => {
8355
8370
  const latestState = {
8356
- ...state
8371
+ ...state,
8372
+ x: 100,
8373
+ y: 100,
8374
+ width: 150,
8375
+ height: 45
8357
8376
  };
8358
8377
  return latestState;
8359
8378
  };
@@ -8364,26 +8383,29 @@ const openCodeGenerator = async editor => {
8364
8383
 
8365
8384
  // TODO handle multiple cursors
8366
8385
  const moveLineUp = editor => {
8367
- const rowIndex = editor.cursor.rowIndex;
8368
- if (rowIndex === 0) {
8369
- return;
8370
- }
8371
- const documentEdits = [{
8372
- type: /* splice */2,
8373
- rowIndex: rowIndex - 1,
8374
- count: 2,
8375
- newLines: [getLine(editor.textDocument, rowIndex), getLine(editor.textDocument, rowIndex - 1)]
8376
- }];
8377
- // @ts-ignore
8378
- const cursorEdits = undefined(editor, (editor, cursor) => {
8379
- return {
8380
- // TODO handle bottom 0
8381
- rowIndex: cursor.rowIndex - 1,
8382
- columnIndex: cursor.columnIndex
8383
- };
8384
- });
8385
- // @ts-ignore
8386
- undefined(editor, documentEdits, cursorEdits);
8386
+ // const rowIndex = editor.cursor.rowIndex
8387
+ // if (rowIndex === 0) {
8388
+ // return
8389
+ // }
8390
+ // const documentEdits = [
8391
+ // {
8392
+ // type: /* splice */ 2,
8393
+ // rowIndex: rowIndex - 1,
8394
+ // count: 2,
8395
+ // newLines: [TextDocument.getLine(editor.textDocument, rowIndex), TextDocument.getLine(editor.textDocument, rowIndex - 1)],
8396
+ // },
8397
+ // ]
8398
+ // // @ts-ignore
8399
+ // const cursorEdits = Editor.moveCursors(editor, (editor, cursor) => {
8400
+ // return {
8401
+ // // TODO handle bottom 0
8402
+ // rowIndex: cursor.rowIndex - 1,
8403
+ // columnIndex: cursor.columnIndex,
8404
+ // }
8405
+ // })
8406
+ // // @ts-ignore
8407
+ // Editor.scheduleDocumentAndCursors(editor, documentEdits, cursorEdits)
8408
+ return editor;
8387
8409
  };
8388
8410
 
8389
8411
  const Link$1 = 'Link';
@@ -8596,7 +8618,7 @@ const getTokensViewport = (editor, startLineIndex, endLineIndex) => {
8596
8618
  const sentLines = Object.create(null);
8597
8619
 
8598
8620
  // TODO only send changed lines to renderer process instead of all lines in viewport
8599
- const getTokensViewport2 = (editor, startLineIndex, endLineIndex, syncIncremental) => {
8621
+ const getTokensViewport2 = async (editor, startLineIndex, endLineIndex, syncIncremental) => {
8600
8622
  if (getEnabled$1()) {
8601
8623
  if (syncIncremental) {
8602
8624
  const {
@@ -8797,7 +8819,7 @@ const getLineInfo = (line, tokenResults, embeddedResults, decorations, TokenMap,
8797
8819
  } = getOffsets(deltaX, width, averageCharWidth);
8798
8820
  if (embeddedResults.length > 0 && tokenResults.embeddedResultIndex !== undefined) {
8799
8821
  const embeddedResult = embeddedResults[tokenResults.embeddedResultIndex];
8800
- if (embeddedResult && embeddedResult.isFull) {
8822
+ if (embeddedResult?.isFull) {
8801
8823
  return getLineInfoEmbeddedFull(embeddedResults, tokenResults, line, normalize, tabSize, width, deltaX, averageCharWidth, minOffset, maxOffset);
8802
8824
  }
8803
8825
  }
@@ -9008,14 +9030,14 @@ const addWidget$1 = widget => {
9008
9030
  const renderWidget = widget => {
9009
9031
  const module = get$7(widget.id);
9010
9032
  if (!module) {
9011
- throw new Error(`unsupported widget`);
9033
+ throw new Error('unsupported widget');
9012
9034
  }
9013
9035
  return module.render(widget);
9014
9036
  };
9015
9037
  const removeWidget$1 = widget => {
9016
9038
  const module = get$7(widget.id);
9017
9039
  if (!module) {
9018
- throw new Error(`unsupported widget`);
9040
+ throw new Error('unsupported widget');
9019
9041
  }
9020
9042
  return module.remove(widget);
9021
9043
  };
@@ -9074,7 +9096,7 @@ const renderScrollBarX = {
9074
9096
  return [/* method */'setScrollBarHorizontal', /* scrollBarX */scrollBarX, /* scrollBarWidth */scrollBarWidth, /* deltaX */newState.deltaX];
9075
9097
  }
9076
9098
  };
9077
- const renderFocus$2 = {
9099
+ const renderFocus$3 = {
9078
9100
  isEqual(oldState, newState) {
9079
9101
  return oldState.focused === newState.focused;
9080
9102
  },
@@ -9172,7 +9194,7 @@ const renderWidgets = {
9172
9194
  },
9173
9195
  multiple: true
9174
9196
  };
9175
- const render$e = [renderLines, renderSelections, renderScrollBarX, renderScrollBarY, renderFocus$2, renderDecorations, renderGutterInfo, renderWidgets];
9197
+ const render$f = [renderLines, renderSelections, renderScrollBarX, renderScrollBarY, renderFocus$3, renderDecorations, renderGutterInfo, renderWidgets];
9176
9198
  const renderEditor = async id => {
9177
9199
  const instance = get$6(id);
9178
9200
  if (!instance) {
@@ -9184,7 +9206,7 @@ const renderEditor = async id => {
9184
9206
  } = instance;
9185
9207
  const commands = [];
9186
9208
  set$6(id, newState, newState);
9187
- for (const item of render$e) {
9209
+ for (const item of render$f) {
9188
9210
  if (!item.isEqual(oldState, newState)) {
9189
9211
  const result = await item.apply(oldState, newState);
9190
9212
  // @ts-ignore
@@ -9212,7 +9234,8 @@ const closeCodeGenerator = editor => {
9212
9234
  const newWidgets = removeEditorWidget(widgets, CodeGenerator);
9213
9235
  return {
9214
9236
  ...editor,
9215
- widgets: newWidgets
9237
+ widgets: newWidgets,
9238
+ focused: true
9216
9239
  };
9217
9240
  };
9218
9241
 
@@ -9294,7 +9317,13 @@ const wrapCommands = commands => {
9294
9317
  }
9295
9318
  };
9296
9319
 
9320
+ const codeGeneratorAccept = state => {
9321
+ // TODO close code generator widget
9322
+ return state;
9323
+ };
9324
+
9297
9325
  const commandMap = {
9326
+ 'CodeGenerator.accept': codeGeneratorAccept,
9298
9327
  'ColorPicker.handleSliderPointerDown': handleSliderPointerDown,
9299
9328
  'ColorPicker.handleSliderPointerMove': handleSliderPointerMove,
9300
9329
  'ColorPicker.loadContent': loadContent$3,
@@ -9999,26 +10028,81 @@ const removeWidget = widget => {
9999
10028
  return [['Viewlet.send', widget.newState.uid, 'dispose']];
10000
10029
  };
10001
10030
 
10031
+ const mergeClassNames = (...classNames) => {
10032
+ return classNames.filter(Boolean).join(' ');
10033
+ };
10034
+
10002
10035
  const getCodeGeneratorVirtualDom = state => {
10036
+ const escapeToClose$1 = escapeToClose();
10037
+ const enterCode$1 = enterCode();
10003
10038
  return [{
10004
10039
  type: Div,
10005
- className: 'Viewlet CodeGeneratorWidget',
10006
- childCount: 0
10007
- }];
10040
+ className: mergeClassNames(Viewlet, CodeGeneratorWidget),
10041
+ childCount: 2
10042
+ }, {
10043
+ type: Input,
10044
+ className: mergeClassNames(CodeGeneratorInput, InputBox),
10045
+ childCount: 0,
10046
+ placeholder: enterCode$1,
10047
+ name: 'CodeGeneratorInput'
10048
+ }, {
10049
+ type: Div,
10050
+ className: CodeGeneratorMessage,
10051
+ childCount: 1
10052
+ }, text(escapeToClose$1)];
10008
10053
  };
10009
- const renderCodeGeneratorWidget = (oldState, newState) => {
10010
- const dom = getCodeGeneratorVirtualDom();
10011
- return dom;
10054
+
10055
+ const renderContent$3 = {
10056
+ isEqual(oldState, newState) {
10057
+ return oldState.questions === newState.questions;
10058
+ },
10059
+ apply(oldState, newState) {
10060
+ const dom = getCodeGeneratorVirtualDom();
10061
+ return [SetDom2, newState.uid, dom];
10062
+ }
10063
+ };
10064
+ const renderBounds$6 = {
10065
+ isEqual(oldState, newState) {
10066
+ return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
10067
+ },
10068
+ apply(oldState, newState) {
10069
+ const {
10070
+ x,
10071
+ y,
10072
+ width,
10073
+ height
10074
+ } = newState;
10075
+ return [/* method */SetBounds, /* x */x, /* y */y, /* width */width, /* height */height];
10076
+ }
10077
+ };
10078
+ const renderFocus$2 = {
10079
+ isEqual(oldState, newState) {
10080
+ return oldState.focused === newState.focused && oldState.focusSource === newState.focusSource;
10081
+ },
10082
+ apply(oldState, newState) {
10083
+ return [Focus, '.CodeGeneratorInput', newState.focusSource];
10084
+ }
10085
+ };
10086
+ const render$e = [renderContent$3, renderBounds$6, renderFocus$2];
10087
+ const renderFull$3 = (oldState, newState) => {
10088
+ const commands = [];
10089
+ for (const item of render$e) {
10090
+ if (!item.isEqual(oldState, newState)) {
10091
+ commands.push(item.apply(oldState, newState));
10092
+ }
10093
+ }
10094
+ return commands;
10012
10095
  };
10013
10096
 
10014
10097
  const render$d = widget => {
10015
- const commands = renderCodeGeneratorWidget();
10098
+ const commands = renderFull$3(widget.oldState, widget.newState);
10016
10099
  const wrappedCommands = [];
10017
10100
  const uid = widget.newState.uid;
10018
10101
  for (const command of commands) {
10019
- if (command[0] === 'Viewlet.setDom2') {
10102
+ if (command[0] === SetDom2) {
10020
10103
  wrappedCommands.push(command);
10021
10104
  } else {
10105
+ // @ts-ignore
10022
10106
  wrappedCommands.push(['Viewlet.send', uid, ...command]);
10023
10107
  }
10024
10108
  }
@@ -10036,10 +10120,6 @@ const EditorCodeGeneratorWidget = {
10036
10120
  render: render$d
10037
10121
  };
10038
10122
 
10039
- const mergeClassNames = (...classNames) => {
10040
- return classNames.filter(Boolean).join(' ');
10041
- };
10042
-
10043
10123
  const getColorPickerVirtualDom = () => {
10044
10124
  return [{
10045
10125
  type: Div,
@@ -10095,7 +10175,7 @@ const renderContent$2 = {
10095
10175
  },
10096
10176
  apply(oldState, newState) {
10097
10177
  const dom = getColorPickerVirtualDom();
10098
- return ['Viewlet.setDom2', newState.uid, dom];
10178
+ return [SetDom2, newState.uid, dom];
10099
10179
  }
10100
10180
  };
10101
10181
  const renderBounds$5 = {
@@ -10128,7 +10208,7 @@ const render$b = widget => {
10128
10208
  const wrappedCommands = [];
10129
10209
  const uid = widget.newState.uid;
10130
10210
  for (const command of commands) {
10131
- if (command[0] === 'Viewlet.setDom2') {
10211
+ if (command[0] === SetDom2) {
10132
10212
  wrappedCommands.push(command);
10133
10213
  } else {
10134
10214
  wrappedCommands.push(['Viewlet.send', uid, ...command]);
@@ -10191,7 +10271,7 @@ const renderContent$1 = {
10191
10271
  },
10192
10272
  apply(oldState, newState) {
10193
10273
  const dom = getCompletionDetailVirtualDom(newState.content);
10194
- return ['Viewlet.setDom2', newState.uid, dom];
10274
+ return [SetDom2, newState.uid, dom];
10195
10275
  }
10196
10276
  };
10197
10277
  const renderBounds$4 = {
@@ -10218,7 +10298,7 @@ const render$9 = widget => {
10218
10298
  const wrappedCommands = [];
10219
10299
  const uid = widget.newState.uid;
10220
10300
  for (const command of commands) {
10221
- if (command[0] === 'Viewlet.setDom2') {
10301
+ if (command[0] === SetDom2) {
10222
10302
  wrappedCommands.push(command);
10223
10303
  } else {
10224
10304
  wrappedCommands.push(['Viewlet.send', uid, ...command]);
@@ -10726,23 +10806,41 @@ const getFindWidgetButtonsEnabled = (matchCount, value) => {
10726
10806
  const getFindWidgetFocusSelector = focus => {
10727
10807
  switch (focus) {
10728
10808
  case FindWidget:
10729
- return `[name="${SearchValue}"]`;
10809
+ {
10810
+ return `[name="${SearchValue}"]`;
10811
+ }
10730
10812
  case FocusFindWidgetReplace:
10731
- return `[name="${ReplaceValue}"]`;
10813
+ {
10814
+ return `[name="${ReplaceValue}"]`;
10815
+ }
10732
10816
  case FocusFindWidgetReplaceAllButton:
10733
- return `[name="${ReplaceAll}"]`;
10817
+ {
10818
+ return `[name="${ReplaceAll}"]`;
10819
+ }
10734
10820
  case FocusFindWidgetCloseButton:
10735
- return `[name="${Close}"]`;
10821
+ {
10822
+ return `[name="${Close}"]`;
10823
+ }
10736
10824
  case FocusFindWidgetToggleReplace:
10737
- return `[name="${ToggleReplace}"]`;
10825
+ {
10826
+ return `[name="${ToggleReplace}"]`;
10827
+ }
10738
10828
  case FocusFindWidgetNextMatchButton:
10739
- return `[name="${FocusNext}"]`;
10829
+ {
10830
+ return `[name="${FocusNext}"]`;
10831
+ }
10740
10832
  case FocusFindWidgetPreviousMatchButton:
10741
- return `[name="${FocusPrevious}"]`;
10833
+ {
10834
+ return `[name="${FocusPrevious}"]`;
10835
+ }
10742
10836
  case FocusFindWidgetReplaceButton:
10743
- return `[name="${Replace}"]`;
10837
+ {
10838
+ return `[name="${Replace}"]`;
10839
+ }
10744
10840
  default:
10745
- return '';
10841
+ {
10842
+ return '';
10843
+ }
10746
10844
  }
10747
10845
  };
10748
10846
 
@@ -10934,7 +11032,7 @@ const renderDetails = {
10934
11032
  replaceButtons
10935
11033
  } = getFindWidgetButtons(findButtonsEnabled, replaceButtonsEnabled);
10936
11034
  const dom = getFindWidgetVirtualDom(matchCountText, newState.replaceExpanded, findButtons, replaceButtons, newState.matchCase, newState.matchWholeWord, newState.useRegularExpression, newState.matchCount, newState.value);
10937
- return ['Viewlet.setDom2', dom];
11035
+ return [SetDom2, dom];
10938
11036
  }
10939
11037
  };
10940
11038
  const renderBounds$2 = {
@@ -10957,7 +11055,7 @@ const renderFocus$1 = {
10957
11055
  },
10958
11056
  apply(oldState, newState) {
10959
11057
  const key = getFindWidgetFocusSelector(newState.focus);
10960
- return ['focus', key, newState.focusSource];
11058
+ return [Focus, key, newState.focusSource];
10961
11059
  }
10962
11060
  };
10963
11061
  // const getAriaLabel = (state: FindWidgetState) => {
@@ -10994,7 +11092,7 @@ const render$5 = widget => {
10994
11092
  const wrappedCommands = [];
10995
11093
  const uid = widget.newState.uid;
10996
11094
  for (const command of commands) {
10997
- if (command[0] === 'Viewlet.setDom2') {
11095
+ if (command[0] === SetDom2) {
10998
11096
  wrappedCommands.push([command[0], uid, ...command.slice(1)]);
10999
11097
  } else {
11000
11098
  wrappedCommands.push(['Viewlet.send', uid, ...command]);
@@ -11030,7 +11128,7 @@ const render$4 = widget => {
11030
11128
  const wrappedCommands = [];
11031
11129
  const uid = widget.newState.uid;
11032
11130
  for (const command of commands) {
11033
- if (command[0] === 'Viewlet.setDom2') {
11131
+ if (command[0] === SetDom2) {
11034
11132
  wrappedCommands.push([command[0], uid, ...command.slice(1)]);
11035
11133
  } else {
11036
11134
  wrappedCommands.push(['Viewlet.send', uid, ...command]);
@@ -11070,7 +11168,7 @@ const renderContent = {
11070
11168
  },
11071
11169
  apply(oldState, newState) {
11072
11170
  const dom = getRenameVirtualDom(newState);
11073
- return ['Viewlet.setDom2', newState.uid, dom];
11171
+ return [SetDom2, newState.uid, dom];
11074
11172
  }
11075
11173
  };
11076
11174
  const renderBounds$1 = {
@@ -11105,7 +11203,7 @@ const render$2 = widget => {
11105
11203
  const wrappedCommands = [];
11106
11204
  const uid = widget.newState.uid;
11107
11205
  for (const command of commands) {
11108
- if (command[0] === 'Viewlet.setDom2') {
11206
+ if (command[0] === SetDom2) {
11109
11207
  wrappedCommands.push(command);
11110
11208
  } else if (command[0] === 'Viewlet.focusSelector') {
11111
11209
  wrappedCommands.push(command);
@@ -11127,28 +11225,6 @@ const EditorRenameWidget = {
11127
11225
  render: render$2
11128
11226
  };
11129
11227
 
11130
- const getActionClassName = isFocused => {
11131
- if (isFocused) {
11132
- return mergeClassNames(SourceActionItem, SourceActionItemFocused);
11133
- }
11134
- return SourceActionItem;
11135
- };
11136
- const getSourceActionListItemVirtualDom = sourceAction => {
11137
- const {
11138
- name,
11139
- isFocused
11140
- } = sourceAction;
11141
- const actionClassName = getActionClassName(isFocused);
11142
- return [{
11143
- type: Div,
11144
- className: actionClassName,
11145
- childCount: 2
11146
- }, {
11147
- type: Div,
11148
- className: 'SourceActionIcon MaskIcon MaskIconSymbolFile'
11149
- }, text(name)];
11150
- };
11151
-
11152
11228
  const getEditorMessageVirtualDom = message => {
11153
11229
  const dom = [{
11154
11230
  type: Div,
@@ -11171,13 +11247,35 @@ const getEmptySourceActionsVirtualDom = () => {
11171
11247
  return getEditorMessageVirtualDom(noCodeActionsAvailable());
11172
11248
  };
11173
11249
 
11250
+ const getActionClassName = isFocused => {
11251
+ if (isFocused) {
11252
+ return mergeClassNames(SourceActionItem, SourceActionItemFocused);
11253
+ }
11254
+ return SourceActionItem;
11255
+ };
11256
+ const getSourceActionListItemVirtualDom = sourceAction => {
11257
+ const {
11258
+ name,
11259
+ isFocused
11260
+ } = sourceAction;
11261
+ const actionClassName = getActionClassName(isFocused);
11262
+ return [{
11263
+ type: Div,
11264
+ className: actionClassName,
11265
+ childCount: 2
11266
+ }, {
11267
+ type: Div,
11268
+ className: mergeClassNames(SourceActionIcon, MaskIcon, MaskIconSymbolFile)
11269
+ }, text(name)];
11270
+ };
11271
+
11174
11272
  const getSourceActionsVirtualDom = sourceActions => {
11175
11273
  if (sourceActions.length === 0) {
11176
11274
  return getEmptySourceActionsVirtualDom();
11177
11275
  }
11178
11276
  const dom = [{
11179
11277
  type: Div,
11180
- className: 'Viewlet EditorSourceActions',
11278
+ className: mergeClassNames(Viewlet, EditorSourceActions),
11181
11279
  tabIndex: -1,
11182
11280
  childCount: 2,
11183
11281
  onFocusIn: HandleFocusIn
@@ -11214,7 +11312,7 @@ const renderSourceActions = {
11214
11312
  apply(oldStatem, newState) {
11215
11313
  const visible = getVisibleSourceActions(newState.sourceActions, newState.focusedIndex);
11216
11314
  const dom = getSourceActionsVirtualDom(visible);
11217
- return ['Viewlet.setDom2', newState.uid, dom];
11315
+ return [SetDom2, newState.uid, dom];
11218
11316
  }
11219
11317
  };
11220
11318
  const renderBounds = {
@@ -11222,7 +11320,7 @@ const renderBounds = {
11222
11320
  return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
11223
11321
  },
11224
11322
  apply(oldState, newState) {
11225
- return ['setBounds', newState.x, newState.y, newState.width, newState.height];
11323
+ return [SetBounds, newState.x, newState.y, newState.width, newState.height];
11226
11324
  }
11227
11325
  };
11228
11326
  const render$1 = [renderSourceActions, renderBounds];
@@ -11241,7 +11339,7 @@ const render = widget => {
11241
11339
  const wrappedCommands = [];
11242
11340
  const uid = widget.newState.uid;
11243
11341
  for (const command of commands) {
11244
- if (command[0] === 'Viewlet.setDom2') {
11342
+ if (command[0] === SetDom2) {
11245
11343
  wrappedCommands.push(command);
11246
11344
  } else {
11247
11345
  wrappedCommands.push(['Viewlet.send', uid, ...command]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "4.12.0",
3
+ "version": "5.0.0",
4
4
  "description": "",
5
5
  "main": "dist/editorWorkerMain.js",
6
6
  "type": "module",