@lvce-editor/editor-worker 4.12.0 → 4.13.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.
@@ -3351,7 +3351,9 @@ const UiStrings$1 = {
3351
3351
  SourceAction: 'Source Action',
3352
3352
  OrganizeImports: 'Organize Imports',
3353
3353
  SortImports: 'Sort Imports',
3354
- NoCodeActionsAvailable: 'No code actions available'
3354
+ NoCodeActionsAvailable: 'No code actions available',
3355
+ EscapeToClose: 'Escape to close',
3356
+ EnterCode: 'Enter Code'
3355
3357
  };
3356
3358
  const noDefinitionFound = () => {
3357
3359
  return i18nString(UiStrings$1.NoDefinitionFound);
@@ -3378,6 +3380,12 @@ const sourceAction = () => {
3378
3380
  const noCodeActionsAvailable = () => {
3379
3381
  return i18nString(UiStrings$1.NoCodeActionsAvailable);
3380
3382
  };
3383
+ const escapeToClose = () => {
3384
+ return i18nString(UiStrings$1.EscapeToClose);
3385
+ };
3386
+ const enterCode = () => {
3387
+ return i18nString(UiStrings$1.EnterCode);
3388
+ };
3381
3389
 
3382
3390
  // @ts-ignore
3383
3391
  const goTo = async ({
@@ -7854,6 +7862,8 @@ const handleSashPointerUp = (state, eventX, eventY) => {
7854
7862
  return state;
7855
7863
  };
7856
7864
 
7865
+ const CodeGeneratorInput = 'CodeGeneratorInput';
7866
+ const CodeGeneratorWidget = 'CodeGeneratorWidget';
7857
7867
  const ColoredMaskIcon = 'ColoredMaskIcon';
7858
7868
  const ColorPicker = 'ColorPicker';
7859
7869
  const ColorPickerBackgroundColor = 'ColorPickerBackgroundColor';
@@ -7862,20 +7872,10 @@ const ColorPickerLight = 'ColorPickerLight';
7862
7872
  const ColorPickerRectangle = 'ColorPickerRectangle';
7863
7873
  const ColorPickerSlider = 'ColorPickerSlider';
7864
7874
  const ColorPickerSliderThumb = 'ColorPickerSliderThumb';
7865
- const SourceActionItem = 'SourceActionItem';
7866
- const SourceActionItemFocused = 'SourceActionItemFocused';
7875
+ const CodeGeneratorMessage = 'CodeGeneratorMessage';
7867
7876
  const CompletionDetailCloseButton = 'CompletionDetailCloseButton';
7868
- const EditorSourceActionsList = 'EditorSourceActionsList';
7869
- const IconButtonDisabled = 'IconButtonDisabled';
7870
- const IconButton = 'IconButton';
7871
- const SourceActionHeading = 'SourceActionHeading';
7872
7877
  const CompletionDetailContent = 'CompletionDetailContent';
7873
7878
  const Diagnostic = 'Diagnostic';
7874
- const FindWidgetReplace = 'FindWidgetReplace';
7875
- const FindWidgetFind = 'FindWidgetFind';
7876
- const FindWidgetMatchCount = 'FindWidgetMatchCount';
7877
- const FindWidgetMatchCountEmpty = 'FindWidgetMatchCountEmpty';
7878
- const FindWidgetRight = 'FindWidgetRight';
7879
7879
  const EditorCompletionItem = 'EditorCompletionItem';
7880
7880
  const EditorCompletionItemDeprecated = 'EditorCompletionItemDeprecated';
7881
7881
  const EditorCompletionItemFocused = 'EditorCompletionItemFocused';
@@ -7883,19 +7883,32 @@ const EditorCompletionItemHighlight = 'EditorCompletionItemHighlight';
7883
7883
  const EditorCursor = 'EditorCursor';
7884
7884
  const EditorRow = 'EditorRow';
7885
7885
  const EditorSelection = 'EditorSelection';
7886
+ const EditorSourceActions = 'EditorSourceActions';
7887
+ const EditorSourceActionsList = 'EditorSourceActionsList';
7886
7888
  const FileIcon = 'FileIcon';
7889
+ const FindWidgetFind = 'FindWidgetFind';
7890
+ const FindWidgetMatchCount = 'FindWidgetMatchCount';
7891
+ const FindWidgetMatchCountEmpty = 'FindWidgetMatchCountEmpty';
7892
+ const FindWidgetReplace = 'FindWidgetReplace';
7893
+ const FindWidgetRight = 'FindWidgetRight';
7887
7894
  const HoverDisplayString = 'HoverDisplayString';
7888
7895
  const HoverDocumentation = 'HoverDocumentation';
7889
- const SearchFieldButtons = 'SearchFieldButtons';
7890
7896
  const HoverEditorRow = 'HoverEditorRow';
7891
- const MultilineInputBox = 'MultilineInputBox';
7892
- const SearchField = 'SearchField';
7893
7897
  const HoverProblem = 'HoverProblem';
7894
7898
  const HoverProblemDetail = 'HoverProblemDetail';
7895
7899
  const HoverProblemMessage = 'HoverProblemMessage';
7900
+ const IconButton = 'IconButton';
7901
+ const IconButtonDisabled = 'IconButtonDisabled';
7896
7902
  const IconClose = 'IconClose';
7903
+ const InputBox = 'InputBox';
7897
7904
  const Label = 'Label';
7898
7905
  const MaskIcon = 'MaskIcon';
7906
+ const MultilineInputBox = 'MultilineInputBox';
7907
+ const SearchField = 'SearchField';
7908
+ const SearchFieldButtons = 'SearchFieldButtons';
7909
+ const SourceActionHeading = 'SourceActionHeading';
7910
+ const SourceActionItem = 'SourceActionItem';
7911
+ const SourceActionItemFocused = 'SourceActionItemFocused';
7899
7912
  const Viewlet = 'Viewlet';
7900
7913
 
7901
7914
  const Button = 1;
@@ -8014,6 +8027,8 @@ const SetNegativeMargin = 'setNegativeMargin';
8014
8027
  const SetOffsetX = 'setOffsetX';
8015
8028
  const SetScrollBar = 'setScrollBar';
8016
8029
  const SetValue = 'setValue';
8030
+ const SetDom2 = 'Viewlet.setDom2';
8031
+ const Focus = 'focus';
8017
8032
 
8018
8033
  const renderHoverDom = {
8019
8034
  isEqual(oldState, newState) {
@@ -8021,10 +8036,10 @@ const renderHoverDom = {
8021
8036
  },
8022
8037
  apply(oldState, newState) {
8023
8038
  const dom = getHoverVirtualDom(newState.lineInfos, newState.documentation, newState.diagnostics);
8024
- return [/* method */'Viewlet.setDom2', dom];
8039
+ return [/* method */SetDom2, dom];
8025
8040
  }
8026
8041
  };
8027
- const renderBounds$6 = {
8042
+ const renderBounds$7 = {
8028
8043
  isEqual(oldState, newState) {
8029
8044
  return oldState.x === newState.x && oldState.y === newState.y;
8030
8045
  },
@@ -8038,10 +8053,10 @@ const renderBounds$6 = {
8038
8053
  return [SetBounds, x, y, renderWidth, height];
8039
8054
  }
8040
8055
  };
8041
- const render$f = [renderHoverDom, renderBounds$6];
8056
+ const render$g = [renderHoverDom, renderBounds$7];
8042
8057
  const renderHover = (oldState, newState) => {
8043
8058
  const commands = [];
8044
- for (const item of render$f) {
8059
+ for (const item of render$g) {
8045
8060
  if (!item.isEqual(oldState, newState)) {
8046
8061
  commands.push(item.apply(oldState, newState));
8047
8062
  }
@@ -8341,11 +8356,23 @@ const create = () => {
8341
8356
  id: CodeGenerator,
8342
8357
  oldState: {
8343
8358
  uid: completionUid,
8344
- questions: []
8359
+ questions: [],
8360
+ x: 0,
8361
+ y: 0,
8362
+ width: 0,
8363
+ height: 0,
8364
+ focused: false,
8365
+ focusSource: Unknown$1
8345
8366
  },
8346
8367
  newState: {
8347
8368
  uid: completionUid,
8348
- questions: []
8369
+ questions: [],
8370
+ x: 0,
8371
+ y: 0,
8372
+ width: 0,
8373
+ height: 0,
8374
+ focused: true,
8375
+ focusSource: Script
8349
8376
  }
8350
8377
  };
8351
8378
  return widget;
@@ -8353,7 +8380,11 @@ const create = () => {
8353
8380
 
8354
8381
  const newStateGenerator = async state => {
8355
8382
  const latestState = {
8356
- ...state
8383
+ ...state,
8384
+ x: 100,
8385
+ y: 100,
8386
+ width: 150,
8387
+ height: 45
8357
8388
  };
8358
8389
  return latestState;
8359
8390
  };
@@ -9074,7 +9105,7 @@ const renderScrollBarX = {
9074
9105
  return [/* method */'setScrollBarHorizontal', /* scrollBarX */scrollBarX, /* scrollBarWidth */scrollBarWidth, /* deltaX */newState.deltaX];
9075
9106
  }
9076
9107
  };
9077
- const renderFocus$2 = {
9108
+ const renderFocus$3 = {
9078
9109
  isEqual(oldState, newState) {
9079
9110
  return oldState.focused === newState.focused;
9080
9111
  },
@@ -9172,7 +9203,7 @@ const renderWidgets = {
9172
9203
  },
9173
9204
  multiple: true
9174
9205
  };
9175
- const render$e = [renderLines, renderSelections, renderScrollBarX, renderScrollBarY, renderFocus$2, renderDecorations, renderGutterInfo, renderWidgets];
9206
+ const render$f = [renderLines, renderSelections, renderScrollBarX, renderScrollBarY, renderFocus$3, renderDecorations, renderGutterInfo, renderWidgets];
9176
9207
  const renderEditor = async id => {
9177
9208
  const instance = get$6(id);
9178
9209
  if (!instance) {
@@ -9184,7 +9215,7 @@ const renderEditor = async id => {
9184
9215
  } = instance;
9185
9216
  const commands = [];
9186
9217
  set$6(id, newState, newState);
9187
- for (const item of render$e) {
9218
+ for (const item of render$f) {
9188
9219
  if (!item.isEqual(oldState, newState)) {
9189
9220
  const result = await item.apply(oldState, newState);
9190
9221
  // @ts-ignore
@@ -9999,26 +10030,81 @@ const removeWidget = widget => {
9999
10030
  return [['Viewlet.send', widget.newState.uid, 'dispose']];
10000
10031
  };
10001
10032
 
10033
+ const mergeClassNames = (...classNames) => {
10034
+ return classNames.filter(Boolean).join(' ');
10035
+ };
10036
+
10002
10037
  const getCodeGeneratorVirtualDom = state => {
10038
+ const escapeToClose$1 = escapeToClose();
10039
+ const enterCode$1 = enterCode();
10003
10040
  return [{
10004
10041
  type: Div,
10005
- className: 'Viewlet CodeGeneratorWidget',
10006
- childCount: 0
10007
- }];
10042
+ className: mergeClassNames(Viewlet, CodeGeneratorWidget),
10043
+ childCount: 2
10044
+ }, {
10045
+ type: Input,
10046
+ className: mergeClassNames(CodeGeneratorInput, InputBox),
10047
+ childCount: 0,
10048
+ placeholder: enterCode$1,
10049
+ name: 'CodeGeneratorInput'
10050
+ }, {
10051
+ type: Div,
10052
+ className: CodeGeneratorMessage,
10053
+ childCount: 1
10054
+ }, text(escapeToClose$1)];
10008
10055
  };
10009
- const renderCodeGeneratorWidget = (oldState, newState) => {
10010
- const dom = getCodeGeneratorVirtualDom();
10011
- return dom;
10056
+
10057
+ const renderContent$3 = {
10058
+ isEqual(oldState, newState) {
10059
+ return oldState.questions === newState.questions;
10060
+ },
10061
+ apply(oldState, newState) {
10062
+ const dom = getCodeGeneratorVirtualDom();
10063
+ return [SetDom2, newState.uid, dom];
10064
+ }
10065
+ };
10066
+ const renderBounds$6 = {
10067
+ isEqual(oldState, newState) {
10068
+ return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
10069
+ },
10070
+ apply(oldState, newState) {
10071
+ const {
10072
+ x,
10073
+ y,
10074
+ width,
10075
+ height
10076
+ } = newState;
10077
+ return [/* method */SetBounds, /* x */x, /* y */y, /* width */width, /* height */height];
10078
+ }
10079
+ };
10080
+ const renderFocus$2 = {
10081
+ isEqual(oldState, newState) {
10082
+ return oldState.focused === newState.focused && oldState.focusSource === newState.focusSource;
10083
+ },
10084
+ apply(oldState, newState) {
10085
+ return [Focus, '.CodeGeneratorInput', newState.focusSource];
10086
+ }
10087
+ };
10088
+ const render$e = [renderContent$3, renderBounds$6, renderFocus$2];
10089
+ const renderFull$3 = (oldState, newState) => {
10090
+ const commands = [];
10091
+ for (const item of render$e) {
10092
+ if (!item.isEqual(oldState, newState)) {
10093
+ commands.push(item.apply(oldState, newState));
10094
+ }
10095
+ }
10096
+ return commands;
10012
10097
  };
10013
10098
 
10014
10099
  const render$d = widget => {
10015
- const commands = renderCodeGeneratorWidget();
10100
+ const commands = renderFull$3(widget.oldState, widget.newState);
10016
10101
  const wrappedCommands = [];
10017
10102
  const uid = widget.newState.uid;
10018
10103
  for (const command of commands) {
10019
- if (command[0] === 'Viewlet.setDom2') {
10104
+ if (command[0] === SetDom2) {
10020
10105
  wrappedCommands.push(command);
10021
10106
  } else {
10107
+ // @ts-ignore
10022
10108
  wrappedCommands.push(['Viewlet.send', uid, ...command]);
10023
10109
  }
10024
10110
  }
@@ -10036,10 +10122,6 @@ const EditorCodeGeneratorWidget = {
10036
10122
  render: render$d
10037
10123
  };
10038
10124
 
10039
- const mergeClassNames = (...classNames) => {
10040
- return classNames.filter(Boolean).join(' ');
10041
- };
10042
-
10043
10125
  const getColorPickerVirtualDom = () => {
10044
10126
  return [{
10045
10127
  type: Div,
@@ -10095,7 +10177,7 @@ const renderContent$2 = {
10095
10177
  },
10096
10178
  apply(oldState, newState) {
10097
10179
  const dom = getColorPickerVirtualDom();
10098
- return ['Viewlet.setDom2', newState.uid, dom];
10180
+ return [SetDom2, newState.uid, dom];
10099
10181
  }
10100
10182
  };
10101
10183
  const renderBounds$5 = {
@@ -10128,7 +10210,7 @@ const render$b = widget => {
10128
10210
  const wrappedCommands = [];
10129
10211
  const uid = widget.newState.uid;
10130
10212
  for (const command of commands) {
10131
- if (command[0] === 'Viewlet.setDom2') {
10213
+ if (command[0] === SetDom2) {
10132
10214
  wrappedCommands.push(command);
10133
10215
  } else {
10134
10216
  wrappedCommands.push(['Viewlet.send', uid, ...command]);
@@ -10191,7 +10273,7 @@ const renderContent$1 = {
10191
10273
  },
10192
10274
  apply(oldState, newState) {
10193
10275
  const dom = getCompletionDetailVirtualDom(newState.content);
10194
- return ['Viewlet.setDom2', newState.uid, dom];
10276
+ return [SetDom2, newState.uid, dom];
10195
10277
  }
10196
10278
  };
10197
10279
  const renderBounds$4 = {
@@ -10218,7 +10300,7 @@ const render$9 = widget => {
10218
10300
  const wrappedCommands = [];
10219
10301
  const uid = widget.newState.uid;
10220
10302
  for (const command of commands) {
10221
- if (command[0] === 'Viewlet.setDom2') {
10303
+ if (command[0] === SetDom2) {
10222
10304
  wrappedCommands.push(command);
10223
10305
  } else {
10224
10306
  wrappedCommands.push(['Viewlet.send', uid, ...command]);
@@ -10934,7 +11016,7 @@ const renderDetails = {
10934
11016
  replaceButtons
10935
11017
  } = getFindWidgetButtons(findButtonsEnabled, replaceButtonsEnabled);
10936
11018
  const dom = getFindWidgetVirtualDom(matchCountText, newState.replaceExpanded, findButtons, replaceButtons, newState.matchCase, newState.matchWholeWord, newState.useRegularExpression, newState.matchCount, newState.value);
10937
- return ['Viewlet.setDom2', dom];
11019
+ return [SetDom2, dom];
10938
11020
  }
10939
11021
  };
10940
11022
  const renderBounds$2 = {
@@ -10957,7 +11039,7 @@ const renderFocus$1 = {
10957
11039
  },
10958
11040
  apply(oldState, newState) {
10959
11041
  const key = getFindWidgetFocusSelector(newState.focus);
10960
- return ['focus', key, newState.focusSource];
11042
+ return [Focus, key, newState.focusSource];
10961
11043
  }
10962
11044
  };
10963
11045
  // const getAriaLabel = (state: FindWidgetState) => {
@@ -10994,7 +11076,7 @@ const render$5 = widget => {
10994
11076
  const wrappedCommands = [];
10995
11077
  const uid = widget.newState.uid;
10996
11078
  for (const command of commands) {
10997
- if (command[0] === 'Viewlet.setDom2') {
11079
+ if (command[0] === SetDom2) {
10998
11080
  wrappedCommands.push([command[0], uid, ...command.slice(1)]);
10999
11081
  } else {
11000
11082
  wrappedCommands.push(['Viewlet.send', uid, ...command]);
@@ -11030,7 +11112,7 @@ const render$4 = widget => {
11030
11112
  const wrappedCommands = [];
11031
11113
  const uid = widget.newState.uid;
11032
11114
  for (const command of commands) {
11033
- if (command[0] === 'Viewlet.setDom2') {
11115
+ if (command[0] === SetDom2) {
11034
11116
  wrappedCommands.push([command[0], uid, ...command.slice(1)]);
11035
11117
  } else {
11036
11118
  wrappedCommands.push(['Viewlet.send', uid, ...command]);
@@ -11070,7 +11152,7 @@ const renderContent = {
11070
11152
  },
11071
11153
  apply(oldState, newState) {
11072
11154
  const dom = getRenameVirtualDom(newState);
11073
- return ['Viewlet.setDom2', newState.uid, dom];
11155
+ return [SetDom2, newState.uid, dom];
11074
11156
  }
11075
11157
  };
11076
11158
  const renderBounds$1 = {
@@ -11105,7 +11187,7 @@ const render$2 = widget => {
11105
11187
  const wrappedCommands = [];
11106
11188
  const uid = widget.newState.uid;
11107
11189
  for (const command of commands) {
11108
- if (command[0] === 'Viewlet.setDom2') {
11190
+ if (command[0] === SetDom2) {
11109
11191
  wrappedCommands.push(command);
11110
11192
  } else if (command[0] === 'Viewlet.focusSelector') {
11111
11193
  wrappedCommands.push(command);
@@ -11127,28 +11209,6 @@ const EditorRenameWidget = {
11127
11209
  render: render$2
11128
11210
  };
11129
11211
 
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
11212
  const getEditorMessageVirtualDom = message => {
11153
11213
  const dom = [{
11154
11214
  type: Div,
@@ -11171,13 +11231,35 @@ const getEmptySourceActionsVirtualDom = () => {
11171
11231
  return getEditorMessageVirtualDom(noCodeActionsAvailable());
11172
11232
  };
11173
11233
 
11234
+ const getActionClassName = isFocused => {
11235
+ if (isFocused) {
11236
+ return mergeClassNames(SourceActionItem, SourceActionItemFocused);
11237
+ }
11238
+ return SourceActionItem;
11239
+ };
11240
+ const getSourceActionListItemVirtualDom = sourceAction => {
11241
+ const {
11242
+ name,
11243
+ isFocused
11244
+ } = sourceAction;
11245
+ const actionClassName = getActionClassName(isFocused);
11246
+ return [{
11247
+ type: Div,
11248
+ className: actionClassName,
11249
+ childCount: 2
11250
+ }, {
11251
+ type: Div,
11252
+ className: 'SourceActionIcon MaskIcon MaskIconSymbolFile'
11253
+ }, text(name)];
11254
+ };
11255
+
11174
11256
  const getSourceActionsVirtualDom = sourceActions => {
11175
11257
  if (sourceActions.length === 0) {
11176
11258
  return getEmptySourceActionsVirtualDom();
11177
11259
  }
11178
11260
  const dom = [{
11179
11261
  type: Div,
11180
- className: 'Viewlet EditorSourceActions',
11262
+ className: mergeClassNames(Viewlet, EditorSourceActions),
11181
11263
  tabIndex: -1,
11182
11264
  childCount: 2,
11183
11265
  onFocusIn: HandleFocusIn
@@ -11214,7 +11296,7 @@ const renderSourceActions = {
11214
11296
  apply(oldStatem, newState) {
11215
11297
  const visible = getVisibleSourceActions(newState.sourceActions, newState.focusedIndex);
11216
11298
  const dom = getSourceActionsVirtualDom(visible);
11217
- return ['Viewlet.setDom2', newState.uid, dom];
11299
+ return [SetDom2, newState.uid, dom];
11218
11300
  }
11219
11301
  };
11220
11302
  const renderBounds = {
@@ -11222,7 +11304,7 @@ const renderBounds = {
11222
11304
  return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
11223
11305
  },
11224
11306
  apply(oldState, newState) {
11225
- return ['setBounds', newState.x, newState.y, newState.width, newState.height];
11307
+ return [SetBounds, newState.x, newState.y, newState.width, newState.height];
11226
11308
  }
11227
11309
  };
11228
11310
  const render$1 = [renderSourceActions, renderBounds];
@@ -11241,7 +11323,7 @@ const render = widget => {
11241
11323
  const wrappedCommands = [];
11242
11324
  const uid = widget.newState.uid;
11243
11325
  for (const command of commands) {
11244
- if (command[0] === 'Viewlet.setDom2') {
11326
+ if (command[0] === SetDom2) {
11245
11327
  wrappedCommands.push(command);
11246
11328
  } else {
11247
11329
  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": "4.13.0",
4
4
  "description": "",
5
5
  "main": "dist/editorWorkerMain.js",
6
6
  "type": "module",