@lvce-editor/editor-worker 19.30.9 → 19.30.11

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.
@@ -1413,7 +1413,7 @@ const BracketLeft = 90;
1413
1413
  const BracketRight = 92;
1414
1414
 
1415
1415
  const CodeGenerator = 1;
1416
- const ColorPicker$1 = 2;
1416
+ const ColorPicker$2 = 2;
1417
1417
  const Completion = 3;
1418
1418
  const CompletionDetail = 4;
1419
1419
  const Find = 5;
@@ -1883,64 +1883,6 @@ const codeGeneratorAccept = state => {
1883
1883
  return state;
1884
1884
  };
1885
1885
 
1886
- const ModuleWorkerAndWorkaroundForChromeDevtoolsBug = 6;
1887
-
1888
- const launchWorker = async (name, url, intializeCommand, commandMap = {}) => {
1889
- const rpc = await create$e({
1890
- commandMap,
1891
- isMessagePortOpen: true,
1892
- async send(port) {
1893
- await invokeAndTransfer('IpcParent.create', {
1894
- method: ModuleWorkerAndWorkaroundForChromeDevtoolsBug,
1895
- name,
1896
- port,
1897
- raw: true,
1898
- url
1899
- });
1900
- }
1901
- });
1902
- if (intializeCommand) {
1903
- await rpc.invoke(intializeCommand);
1904
- }
1905
- return rpc;
1906
- };
1907
-
1908
- const launchColorPickerWorker = async () => {
1909
- const name = 'Color Picker Worker';
1910
- const url = 'colorPickerWorkerMain.js';
1911
- return launchWorker(name, url);
1912
- };
1913
-
1914
- const state$d = {};
1915
- const getOrCreate$3 = () => {
1916
- if (!state$d.workerPromise) {
1917
- state$d.workerPromise = launchColorPickerWorker();
1918
- }
1919
- return state$d.workerPromise;
1920
- };
1921
- const invoke$8 = async (method, ...params) => {
1922
- const worker = await getOrCreate$3();
1923
- return await worker.invoke(method, ...params);
1924
- };
1925
-
1926
- const loadContent$3 = async (state, parentUid) => {
1927
- const {
1928
- height,
1929
- uid,
1930
- width,
1931
- x,
1932
- y
1933
- } = state;
1934
- await invoke$8('ColorPicker.create', uid, x, y, width, height, parentUid);
1935
- await invoke$8('ColorPicker.loadContent', uid);
1936
- const diff = await invoke$8('ColorPicker.diff2', uid);
1937
- const commands = await invoke$8('ColorPicker.render2', uid, diff);
1938
- return {
1939
- ...state,
1940
- commands
1941
- };
1942
- };
1943
-
1944
1886
  const editorStates = create$9();
1945
1887
  const {
1946
1888
  dispose: dispose$3,
@@ -1959,120 +1901,32 @@ const set$8 = (id, oldEditor, newEditor) => {
1959
1901
  editorStates.set(id, oldEditor, newEditor);
1960
1902
  };
1961
1903
 
1962
- const emptyIncrementalEdits = [];
1963
-
1964
- const ColorPicker = 41;
1965
- const EditorCompletion = 9;
1966
- const Empty = 0;
1967
- const FindWidget = 16;
1968
- const FocusEditorHover = 51;
1969
- const FocusEditorRename$1 = 11;
1970
- const FocusFindWidgetCloseButton = 48;
1971
- const FocusFindWidgetNextMatchButton = 49;
1972
- const FocusFindWidgetOptions = 44;
1973
- const FocusFindWidgetPreviousMatchButton = 50;
1974
- const FocusFindWidgetReplace$1 = 43;
1975
- const FocusFindWidgetReplaceAllButton = 47;
1976
- const FocusFindWidgetReplaceButton = 46;
1977
- const FocusFindWidgetToggleReplace = 42;
1978
- const SourceActions = 38;
1979
- const FocusCodeGenerator = 52;
1904
+ const getEditor$1 = editorUid => {
1905
+ const instance = get$8(editorUid);
1906
+ if (!instance) {
1907
+ throw new Error(`editor ${editorUid} not found`);
1908
+ }
1909
+ const {
1910
+ newState
1911
+ } = instance;
1912
+ return newState;
1913
+ };
1980
1914
 
1981
- const createEditor2 = (id, uri, x, y, width, height, platform, assetDir) => {
1982
- number(id);
1983
- const editor = {
1984
- additionalFocus: 0,
1985
- assetDir,
1986
- breakPoints: [],
1987
- charWidth: 0,
1988
- columnWidth: 0,
1989
- completionState: '',
1990
- completionTriggerCharacters: [],
1991
- completionUid: 0,
1992
- cursorInfos: [],
1993
- cursorWidth: 2,
1994
- debugEnabled: false,
1995
- decorations: [],
1996
- deltaX: 0,
1997
- deltaY: 0,
1998
- diagnostics: [],
1999
- diagnosticsEnabled: false,
2000
- differences: [],
2001
- embeds: [],
2002
- finalDeltaY: 0,
2003
- finalY: 0,
2004
- focus: 0,
2005
- focused: false,
2006
- focusKey: Empty,
2007
- foldingRanges: [],
2008
- fontFamily: '',
2009
- fontSize: 0,
2010
- fontWeight: 0,
2011
- handleOffset: 0,
2012
- handleOffsetX: 0,
2013
- hasListener: false,
2014
- height,
2015
- highlightedLine: -1,
2016
- hoverEnabled: false,
2017
- id,
2018
- incrementalEdits: emptyIncrementalEdits,
2019
- initial: true,
2020
- invalidStartIndex: 0,
2021
- isAutoClosingBracketsEnabled: false,
2022
- isAutoClosingQuotesEnabled: false,
2023
- isAutoClosingTagsEnabled: false,
2024
- isMonospaceFont: false,
2025
- isQuickSuggestionsEnabled: false,
2026
- isSelecting: false,
2027
- itemHeight: 20,
2028
- languageId: '',
2029
- letterSpacing: 0,
2030
- lineCache: [],
2031
- lineNumbers: false,
2032
- lines: [],
2033
- longestLineWidth: 0,
2034
- maxLineY: 0,
2035
- minimumSliderSize: 20,
2036
- minLineY: 0,
2037
- modified: false,
2038
- numberOfLines: 0,
2039
- numberOfVisibleLines: 0,
2040
- platform,
2041
- primarySelectionIndex: 0,
2042
- redoStack: [],
2043
- rowHeight: 0,
2044
- savedSelections: [],
2045
- scrollBarHeight: 0,
2046
- scrollBarWidth: 0,
2047
- selectionAnchorPosition: {
2048
- columnIndex: 0,
2049
- rowIndex: 0
2050
- },
2051
- selectionAutoMovePosition: {
2052
- columnIndex: 0,
2053
- rowIndex: 0
2054
- },
2055
- selectionInfos: [],
2056
- selections: new Uint32Array(),
2057
- tabSize: 0,
2058
- textInfos: [],
2059
- tokenizerId: 0,
2060
- uid: id,
2061
- undoStack: [],
2062
- uri,
2063
- validLines: [],
2064
- visibleLineIndices: [],
2065
- visualDecorations: [],
2066
- widgetRevision: 0,
2067
- widgets: [],
2068
- width,
2069
- x,
2070
- y
1915
+ const coalesceColorPickerUndoStack = (undoStack, undoStackIndex) => {
1916
+ if (undoStackIndex < 0 || undoStackIndex >= undoStack.length) {
1917
+ return undoStack;
1918
+ }
1919
+ const originalChange = undoStack[undoStackIndex][0];
1920
+ const latestChange = undoStack.at(-1)[0];
1921
+ const coalescedChange = {
1922
+ ...originalChange,
1923
+ inserted: latestChange.inserted
2071
1924
  };
2072
- set$8(id, editor, editor);
1925
+ return [...undoStack.slice(0, undoStackIndex), [coalescedChange]];
2073
1926
  };
2074
1927
 
2075
1928
  // TODO use numeric enum
1929
+ const ColorPicker$1 = 'colorPicker';
2076
1930
  const CompositionUpdate = 'compositionUpdate';
2077
1931
  const ContentEditableInput = 'contentEditableInput';
2078
1932
  const Delete = 'delete';
@@ -2479,7 +2333,7 @@ const getInitialLineState = initialLineState => {
2479
2333
  return deepCopy(initialLineState);
2480
2334
  };
2481
2335
 
2482
- const state$c = {
2336
+ const state$d = {
2483
2337
  warned: []
2484
2338
  };
2485
2339
  const flattenTokensArray = tokens => {
@@ -2491,10 +2345,10 @@ const flattenTokensArray = tokens => {
2491
2345
  return flattened;
2492
2346
  };
2493
2347
  const warnDeprecatedArrayReturn = (languageId, fn) => {
2494
- if (state$c.warned.includes(fn)) {
2348
+ if (state$d.warned.includes(fn)) {
2495
2349
  return;
2496
2350
  }
2497
- state$c.warned.push(fn);
2351
+ state$d.warned.push(fn);
2498
2352
  console.warn(`tokenizers without hasArrayReturn=false are deprecated (language ${languageId})`);
2499
2353
  };
2500
2354
  const safeTokenizeLine = (languageId, tokenizeLine, line, lineStateAtStart, hasArrayReturn) => {
@@ -2555,40 +2409,40 @@ const TokenizePlainText = {
2555
2409
  tokenizeLine
2556
2410
  };
2557
2411
 
2558
- const state$b = {
2412
+ const state$c = {
2559
2413
  enabled: false
2560
2414
  };
2561
2415
  const setEnabled$1 = value => {
2562
- state$b.enabled = value;
2416
+ state$c.enabled = value;
2563
2417
  };
2564
2418
  const getEnabled$1 = () => {
2565
- return state$b.enabled;
2419
+ return state$c.enabled;
2566
2420
  };
2567
2421
 
2568
2422
  const {
2569
- invoke: invoke$7,
2423
+ invoke: invoke$8,
2570
2424
  set: set$6
2571
2425
  } = SyntaxHighlightingWorker;
2572
2426
 
2573
- const state$a = {
2427
+ const state$b = {
2574
2428
  pending: Object.create(null),
2575
2429
  tokenizePaths: Object.create(null),
2576
2430
  tokenizers: Object.create(null)
2577
2431
  };
2578
2432
  const has = languageId => {
2579
- return Object.hasOwn(state$a.tokenizers, languageId);
2433
+ return Object.hasOwn(state$b.tokenizers, languageId);
2580
2434
  };
2581
2435
  const set$5 = (languageId, tokenizer) => {
2582
- state$a.tokenizers[languageId] = tokenizer;
2436
+ state$b.tokenizers[languageId] = tokenizer;
2583
2437
  };
2584
2438
  const get$6 = languageId => {
2585
- return state$a.tokenizers[languageId];
2439
+ return state$b.tokenizers[languageId];
2586
2440
  };
2587
2441
  const setTokenizePath = (languageId, tokenizePath) => {
2588
- state$a.tokenizePaths[languageId] = tokenizePath;
2442
+ state$b.tokenizePaths[languageId] = tokenizePath;
2589
2443
  };
2590
2444
  const getTokenizePath$1 = languageId => {
2591
- return state$a.tokenizePaths[languageId] || '';
2445
+ return state$b.tokenizePaths[languageId] || '';
2592
2446
  };
2593
2447
  const setTokenizePaths = languages => {
2594
2448
  for (const language of languages) {
@@ -2598,7 +2452,7 @@ const setTokenizePaths = languages => {
2598
2452
  }
2599
2453
  };
2600
2454
  const isPending = languageId => {
2601
- return Object.hasOwn(state$a.pending, languageId);
2455
+ return Object.hasOwn(state$b.pending, languageId);
2602
2456
  };
2603
2457
 
2604
2458
  const tokenMaps = Object.create(null);
@@ -2617,7 +2471,7 @@ const loadTokenizer = async (languageId, tokenizePath) => {
2617
2471
  setTokenizePath(languageId, tokenizePath);
2618
2472
  if (getEnabled$1()) {
2619
2473
  // @ts-ignore
2620
- const tokenMap = await invoke$7('Tokenizer.load', languageId, tokenizePath);
2474
+ const tokenMap = await invoke$8('Tokenizer.load', languageId, tokenizePath);
2621
2475
  set$4(languageId, tokenMap);
2622
2476
  return;
2623
2477
  }
@@ -2805,13 +2659,13 @@ const getTokensViewport2 = async (editor, startLineIndex, endLineIndex, syncIncr
2805
2659
  invalidStartIndex,
2806
2660
  languageId
2807
2661
  };
2808
- return invoke$7('GetTokensViewport.getTokensViewport', slimEditor,
2662
+ return invoke$8('GetTokensViewport.getTokensViewport', slimEditor,
2809
2663
  // @ts-ignore
2810
2664
  startLineIndex, endLineIndex, hasLinesToSend, id, linesToSend);
2811
2665
  }
2812
2666
  // TODO only send needed lines of text
2813
2667
  // @ts-ignore
2814
- return invoke$7('GetTokensViewport.getTokensViewport', editor, startLineIndex, endLineIndex, true, editor.id, editor.lines);
2668
+ return invoke$8('GetTokensViewport.getTokensViewport', editor, startLineIndex, endLineIndex, true, editor.id, editor.lines);
2815
2669
  }
2816
2670
  return getTokensViewport(editor, startLineIndex, endLineIndex);
2817
2671
  };
@@ -3394,14 +3248,14 @@ const getVisible$1 = async (editor, syncIncremental) => {
3394
3248
  };
3395
3249
  };
3396
3250
 
3397
- const state$9 = {
3251
+ const state$a = {
3398
3252
  enabled: false
3399
3253
  };
3400
3254
  const setEnabled = value => {
3401
- state$9.enabled = value;
3255
+ state$a.enabled = value;
3402
3256
  };
3403
3257
  const getEnabled = () => {
3404
- return state$9.enabled;
3258
+ return state$a.enabled;
3405
3259
  };
3406
3260
 
3407
3261
  // TODO this should be in a separate scrolling module
@@ -3450,6 +3304,8 @@ const setDeltaY$2 = async (state, value) => {
3450
3304
  return newEditor2;
3451
3305
  };
3452
3306
 
3307
+ const emptyIncrementalEdits = [];
3308
+
3453
3309
  const getIncrementalEdits = async (oldState, newState) => {
3454
3310
  if (!newState.undoStack) {
3455
3311
  return emptyIncrementalEdits;
@@ -3470,7 +3326,7 @@ const getIncrementalEdits = async (oldState, newState) => {
3470
3326
  const oldLine = oldState.lines[rowIndex];
3471
3327
  const newLine = lines[rowIndex];
3472
3328
  // @ts-ignore
3473
- const incrementalEdits = await invoke$7(
3329
+ const incrementalEdits = await invoke$8(
3474
3330
  // @ts-ignore
3475
3331
  'TokenizeIncremental.tokenizeIncremental', newState.uid,
3476
3332
  // @ts-ignore
@@ -3626,7 +3482,7 @@ const getUrlAtOffset = (editor, offset) => {
3626
3482
 
3627
3483
  const EditorChange = 1;
3628
3484
 
3629
- const state$8 = Object.create(null);
3485
+ const state$9 = Object.create(null);
3630
3486
 
3631
3487
  /**
3632
3488
  * Register a listener for a specific event type
@@ -3636,13 +3492,13 @@ const state$8 = Object.create(null);
3636
3492
  const registerListener$1 = (listenerType, rpcId) => {
3637
3493
  number(listenerType);
3638
3494
  number(rpcId);
3639
- if (!Object.hasOwn(state$8, listenerType)) {
3640
- state$8[listenerType] = [];
3495
+ if (!Object.hasOwn(state$9, listenerType)) {
3496
+ state$9[listenerType] = [];
3641
3497
  }
3642
3498
 
3643
3499
  // Avoid duplicate registrations
3644
- if (!state$8[listenerType].includes(rpcId)) {
3645
- state$8[listenerType].push(rpcId);
3500
+ if (!state$9[listenerType].includes(rpcId)) {
3501
+ state$9[listenerType].push(rpcId);
3646
3502
  }
3647
3503
  };
3648
3504
 
@@ -3654,10 +3510,10 @@ const registerListener$1 = (listenerType, rpcId) => {
3654
3510
  const unregisterListener$1 = (listenerType, rpcId) => {
3655
3511
  number(listenerType);
3656
3512
  number(rpcId);
3657
- if (Object.hasOwn(state$8, listenerType)) {
3658
- const index = state$8[listenerType].indexOf(rpcId);
3513
+ if (Object.hasOwn(state$9, listenerType)) {
3514
+ const index = state$9[listenerType].indexOf(rpcId);
3659
3515
  if (index !== -1) {
3660
- state$8[listenerType].splice(index, 1);
3516
+ state$9[listenerType].splice(index, 1);
3661
3517
  }
3662
3518
  }
3663
3519
  };
@@ -3669,7 +3525,7 @@ const unregisterListener$1 = (listenerType, rpcId) => {
3669
3525
  */
3670
3526
  const getListeners = listenerType => {
3671
3527
  number(listenerType);
3672
- return state$8[listenerType] || [];
3528
+ return state$9[listenerType] || [];
3673
3529
  };
3674
3530
 
3675
3531
  /**
@@ -3749,12 +3605,12 @@ const splitLines = lines => {
3749
3605
  return lines.split('\n');
3750
3606
  };
3751
3607
 
3752
- const invoke$6 = (...args) => invoke$a(...args);
3608
+ const invoke$7 = (...args) => invoke$a(...args);
3753
3609
  const readFile = (...args) => readFile$1(...args);
3754
3610
 
3755
3611
  const notifyTabModifiedStatusChange = async (uri, modified) => {
3756
3612
  try {
3757
- await invoke$6('Main.handleModifiedStatusChange', uri, modified);
3613
+ await invoke$7('Main.handleModifiedStatusChange', uri, modified);
3758
3614
  } catch {
3759
3615
  // ignore
3760
3616
  }
@@ -4378,14 +4234,386 @@ const setBounds = (editor, x, y, width, height, columnWidth) => {
4378
4234
  width,
4379
4235
  x,
4380
4236
  y
4381
- }, columnWidth);
4382
- };
4383
- const setText$1 = (editor, text) => {
4384
- const lines = splitLines(text);
4385
- return updateLayout({
4386
- ...editor,
4387
- lines
4388
- }, []);
4237
+ }, columnWidth);
4238
+ };
4239
+ const setText$1 = (editor, text) => {
4240
+ const lines = splitLines(text);
4241
+ return updateLayout({
4242
+ ...editor,
4243
+ lines
4244
+ }, []);
4245
+ };
4246
+
4247
+ const getDocumentEdits = (editor, edits) => {
4248
+ const documentEdits = [];
4249
+ let currentDocument = editor;
4250
+ let linesDelta = 0;
4251
+ let offsetDelta = 0;
4252
+ const sortedEdits = edits.toSorted((a, b) => a.startOffset - b.startOffset || a.endOffset - b.endOffset);
4253
+ for (const edit of sortedEdits) {
4254
+ const currentStart = positionAt(currentDocument, edit.startOffset + offsetDelta);
4255
+ const currentEnd = positionAt(currentDocument, edit.endOffset + offsetDelta);
4256
+ const deleted = getSelectionText(currentDocument, {
4257
+ end: currentEnd,
4258
+ start: currentStart
4259
+ });
4260
+ const documentEdit = {
4261
+ deleted,
4262
+ end: {
4263
+ columnIndex: currentEnd.columnIndex,
4264
+ rowIndex: currentEnd.rowIndex - linesDelta
4265
+ },
4266
+ inserted: splitLines(edit.inserted),
4267
+ origin: Format,
4268
+ start: {
4269
+ columnIndex: currentStart.columnIndex,
4270
+ rowIndex: currentStart.rowIndex - linesDelta
4271
+ }
4272
+ };
4273
+ if (documentEdit.inserted.length === 0) {
4274
+ documentEdit.inserted = [''];
4275
+ }
4276
+ documentEdits.push(documentEdit);
4277
+ const currentEdit = {
4278
+ ...documentEdit,
4279
+ end: currentEnd,
4280
+ start: currentStart
4281
+ };
4282
+ currentDocument = {
4283
+ ...currentDocument,
4284
+ lines: applyEdits(currentDocument, [currentEdit])
4285
+ };
4286
+ linesDelta += documentEdit.inserted.length - documentEdit.deleted.length;
4287
+ offsetDelta += edit.inserted.length - (edit.endOffset - edit.startOffset);
4288
+ }
4289
+ return documentEdits;
4290
+ };
4291
+
4292
+ const updateColorPickerValue$1 = async (editor, value) => {
4293
+ if (typeof value !== 'string') {
4294
+ return editor;
4295
+ }
4296
+ const widget = editor.widgets.find(candidate => candidate.id === ColorPicker$2);
4297
+ if (!widget) {
4298
+ return editor;
4299
+ }
4300
+ const {
4301
+ endOffset,
4302
+ startOffset,
4303
+ undoStackIndex
4304
+ } = widget.newState;
4305
+ if (startOffset < 0 || endOffset < startOffset) {
4306
+ return editor;
4307
+ }
4308
+ const edits = getDocumentEdits(editor, [{
4309
+ endOffset,
4310
+ inserted: value,
4311
+ startOffset
4312
+ }]).map(edit => ({
4313
+ ...edit,
4314
+ origin: ColorPicker$1
4315
+ }));
4316
+ const updatedEditor = await scheduleDocumentAndCursorsSelections(editor, edits);
4317
+ const newEndOffset = startOffset + value.length;
4318
+ const widgets = updatedEditor.widgets.map(candidate => {
4319
+ if (candidate.id !== ColorPicker$2) {
4320
+ return candidate;
4321
+ }
4322
+ return {
4323
+ ...candidate,
4324
+ newState: {
4325
+ ...candidate.newState,
4326
+ endOffset: newEndOffset
4327
+ },
4328
+ oldState: {
4329
+ ...candidate.oldState,
4330
+ endOffset: newEndOffset
4331
+ }
4332
+ };
4333
+ });
4334
+ return {
4335
+ ...updatedEditor,
4336
+ undoStack: coalesceColorPickerUndoStack(updatedEditor.undoStack, undoStackIndex),
4337
+ widgets
4338
+ };
4339
+ };
4340
+
4341
+ const getDiagnosticType = diagnostic => {
4342
+ return diagnostic.type;
4343
+ };
4344
+
4345
+ const getY = (row, minLineY, rowHeight) => {
4346
+ return (row - minLineY) * rowHeight;
4347
+ };
4348
+
4349
+ const getVisibleDiagnostics = async (editor, diagnostics) => {
4350
+ const visibleDiagnostics = [];
4351
+ const {
4352
+ charWidth,
4353
+ fontFamily,
4354
+ fontSize,
4355
+ fontWeight,
4356
+ isMonospaceFont,
4357
+ letterSpacing,
4358
+ lines,
4359
+ minLineY,
4360
+ rowHeight,
4361
+ tabSize,
4362
+ width
4363
+ } = editor;
4364
+ for (const diagnostic of diagnostics) {
4365
+ const {
4366
+ columnIndex,
4367
+ endColumnIndex,
4368
+ rowIndex
4369
+ } = diagnostic;
4370
+ const columnDelta = endColumnIndex - columnIndex;
4371
+ const diagnosticWidth = columnDelta * charWidth;
4372
+ const endLineDifference = 0;
4373
+ const halfCursorWidth = 0;
4374
+ const x = await getX(lines[rowIndex], columnIndex, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, halfCursorWidth, width, charWidth, endLineDifference);
4375
+ const y = getY(rowIndex, minLineY, rowHeight);
4376
+ visibleDiagnostics.push({
4377
+ height: rowHeight,
4378
+ type: getDiagnosticType(diagnostic),
4379
+ width: diagnosticWidth,
4380
+ x,
4381
+ y
4382
+ });
4383
+ }
4384
+ return visibleDiagnostics;
4385
+ };
4386
+
4387
+ const shouldUpdateDiagnosticData = (oldState, newState) => {
4388
+ return oldState.diagnostics !== newState.diagnostics || (newState.diagnostics?.length ?? 0) > 0 && (oldState.minLineY !== newState.minLineY || oldState.charWidth !== newState.charWidth || oldState.fontFamily !== newState.fontFamily || oldState.fontSize !== newState.fontSize || oldState.fontWeight !== newState.fontWeight || oldState.isMonospaceFont !== newState.isMonospaceFont || oldState.letterSpacing !== newState.letterSpacing || oldState.lines !== newState.lines || oldState.rowHeight !== newState.rowHeight || oldState.tabSize !== newState.tabSize || oldState.width !== newState.width);
4389
+ };
4390
+ const shouldUpdateSelectionData = (oldState, newState) => {
4391
+ return oldState.selections !== newState.selections || oldState.focused !== newState.focused || oldState.minLineY !== newState.minLineY || oldState.maxLineY !== newState.maxLineY || oldState.foldingRanges !== newState.foldingRanges || oldState.differences !== newState.differences || oldState.charWidth !== newState.charWidth || oldState.cursorWidth !== newState.cursorWidth || oldState.fontFamily !== newState.fontFamily || oldState.fontSize !== newState.fontSize || oldState.fontWeight !== newState.fontWeight || oldState.isMonospaceFont !== newState.isMonospaceFont || oldState.letterSpacing !== newState.letterSpacing || oldState.lines !== newState.lines || oldState.rowHeight !== newState.rowHeight || oldState.tabSize !== newState.tabSize || oldState.width !== newState.width;
4392
+ };
4393
+ const shouldUpdateVisibleTextData = (oldState, newState) => {
4394
+ if (oldState.textInfos !== newState.textInfos || oldState.differences !== newState.differences) {
4395
+ return false;
4396
+ }
4397
+ return oldState.lines !== newState.lines || oldState.tokenizerId !== newState.tokenizerId || oldState.minLineY !== newState.minLineY || oldState.maxLineY !== newState.maxLineY || oldState.decorations !== newState.decorations || oldState.embeds !== newState.embeds || oldState.deltaX !== newState.deltaX || oldState.width !== newState.width || oldState.highlightedLine !== newState.highlightedLine || oldState.foldingRanges !== newState.foldingRanges || oldState.debugEnabled !== newState.debugEnabled;
4398
+ };
4399
+ const updateDerivedState = async (oldState, newState) => {
4400
+ const nextState = oldState.lines !== newState.lines && 'foldingRanges' in newState ? updateLayout(newState, []) : newState;
4401
+ let finalState = nextState;
4402
+ if (shouldUpdateVisibleTextData(oldState, nextState)) {
4403
+ const syncIncremental = getEnabled();
4404
+ const {
4405
+ differences,
4406
+ textInfos
4407
+ } = await getVisible$1(nextState, syncIncremental);
4408
+ finalState = {
4409
+ ...nextState,
4410
+ differences,
4411
+ textInfos
4412
+ };
4413
+ }
4414
+ if (shouldUpdateDiagnosticData(oldState, nextState)) {
4415
+ const visualDecorations = await getVisibleDiagnostics(finalState, finalState.diagnostics ?? []);
4416
+ finalState = {
4417
+ ...finalState,
4418
+ visualDecorations
4419
+ };
4420
+ }
4421
+ if (!shouldUpdateSelectionData(oldState, nextState)) {
4422
+ return finalState;
4423
+ }
4424
+ const {
4425
+ cursorInfos,
4426
+ selectionInfos
4427
+ } = await getVisible(finalState);
4428
+ return {
4429
+ ...finalState,
4430
+ cursorInfos,
4431
+ selectionInfos
4432
+ };
4433
+ };
4434
+
4435
+ const updateColorPickerValue = async (editorUid, value) => {
4436
+ const editor = getEditor$1(editorUid);
4437
+ const newEditor = await updateColorPickerValue$1(editor, value);
4438
+ if (newEditor === editor) {
4439
+ return;
4440
+ }
4441
+ const newEditorWithDerivedState = await updateDerivedState(editor, newEditor);
4442
+ set$8(editorUid, editor, newEditorWithDerivedState);
4443
+ };
4444
+
4445
+ const getColorPickerWorkerCommandMap = () => ({
4446
+ 'Editor.updateColorPickerValue': updateColorPickerValue
4447
+ });
4448
+
4449
+ const ModuleWorkerAndWorkaroundForChromeDevtoolsBug = 6;
4450
+
4451
+ const launchWorker = async (name, url, intializeCommand, commandMap = {}) => {
4452
+ const rpc = await create$e({
4453
+ commandMap,
4454
+ isMessagePortOpen: true,
4455
+ async send(port) {
4456
+ await invokeAndTransfer('IpcParent.create', {
4457
+ method: ModuleWorkerAndWorkaroundForChromeDevtoolsBug,
4458
+ name,
4459
+ port,
4460
+ raw: true,
4461
+ url
4462
+ });
4463
+ }
4464
+ });
4465
+ if (intializeCommand) {
4466
+ await rpc.invoke(intializeCommand);
4467
+ }
4468
+ return rpc;
4469
+ };
4470
+
4471
+ const launchColorPickerWorker = async () => {
4472
+ const name = 'Color Picker Worker';
4473
+ const url = 'colorPickerWorkerMain.js';
4474
+ return launchWorker(name, url, undefined, getColorPickerWorkerCommandMap());
4475
+ };
4476
+
4477
+ const state$8 = {};
4478
+ const getOrCreate$3 = () => {
4479
+ if (!state$8.workerPromise) {
4480
+ state$8.workerPromise = launchColorPickerWorker();
4481
+ }
4482
+ return state$8.workerPromise;
4483
+ };
4484
+ const invoke$6 = async (method, ...params) => {
4485
+ const worker = await getOrCreate$3();
4486
+ return await worker.invoke(method, ...params);
4487
+ };
4488
+
4489
+ const loadContent$3 = async (state, parentUid) => {
4490
+ const {
4491
+ height,
4492
+ uid,
4493
+ value,
4494
+ width,
4495
+ x,
4496
+ y
4497
+ } = state;
4498
+ await invoke$6('ColorPicker.create', uid, x, y, width, height, parentUid);
4499
+ await invoke$6('ColorPicker.loadContent', uid, value);
4500
+ const diff = await invoke$6('ColorPicker.diff2', uid);
4501
+ const commands = await invoke$6('ColorPicker.render2', uid, diff);
4502
+ return {
4503
+ ...state,
4504
+ commands
4505
+ };
4506
+ };
4507
+
4508
+ const ColorPicker = 41;
4509
+ const EditorCompletion = 9;
4510
+ const Empty = 0;
4511
+ const FindWidget = 16;
4512
+ const FocusEditorHover = 51;
4513
+ const FocusEditorRename$1 = 11;
4514
+ const FocusFindWidgetCloseButton = 48;
4515
+ const FocusFindWidgetNextMatchButton = 49;
4516
+ const FocusFindWidgetOptions = 44;
4517
+ const FocusFindWidgetPreviousMatchButton = 50;
4518
+ const FocusFindWidgetReplace$1 = 43;
4519
+ const FocusFindWidgetReplaceAllButton = 47;
4520
+ const FocusFindWidgetReplaceButton = 46;
4521
+ const FocusFindWidgetToggleReplace = 42;
4522
+ const SourceActions = 38;
4523
+ const FocusCodeGenerator = 52;
4524
+
4525
+ const createEditor2 = (id, uri, x, y, width, height, platform, assetDir) => {
4526
+ number(id);
4527
+ const editor = {
4528
+ additionalFocus: 0,
4529
+ assetDir,
4530
+ breakPoints: [],
4531
+ charWidth: 0,
4532
+ columnWidth: 0,
4533
+ completionState: '',
4534
+ completionTriggerCharacters: [],
4535
+ completionUid: 0,
4536
+ cursorInfos: [],
4537
+ cursorWidth: 2,
4538
+ debugEnabled: false,
4539
+ decorations: [],
4540
+ deltaX: 0,
4541
+ deltaY: 0,
4542
+ diagnostics: [],
4543
+ diagnosticsEnabled: false,
4544
+ differences: [],
4545
+ embeds: [],
4546
+ finalDeltaY: 0,
4547
+ finalY: 0,
4548
+ focus: 0,
4549
+ focused: false,
4550
+ focusKey: Empty,
4551
+ foldingRanges: [],
4552
+ fontFamily: '',
4553
+ fontSize: 0,
4554
+ fontWeight: 0,
4555
+ handleOffset: 0,
4556
+ handleOffsetX: 0,
4557
+ hasListener: false,
4558
+ height,
4559
+ highlightedLine: -1,
4560
+ hoverEnabled: false,
4561
+ id,
4562
+ incrementalEdits: emptyIncrementalEdits,
4563
+ initial: true,
4564
+ invalidStartIndex: 0,
4565
+ isAutoClosingBracketsEnabled: false,
4566
+ isAutoClosingQuotesEnabled: false,
4567
+ isAutoClosingTagsEnabled: false,
4568
+ isMonospaceFont: false,
4569
+ isQuickSuggestionsEnabled: false,
4570
+ isSelecting: false,
4571
+ itemHeight: 20,
4572
+ languageId: '',
4573
+ letterSpacing: 0,
4574
+ lineCache: [],
4575
+ lineNumbers: false,
4576
+ lines: [],
4577
+ longestLineWidth: 0,
4578
+ maxLineY: 0,
4579
+ minimumSliderSize: 20,
4580
+ minLineY: 0,
4581
+ modified: false,
4582
+ numberOfLines: 0,
4583
+ numberOfVisibleLines: 0,
4584
+ platform,
4585
+ primarySelectionIndex: 0,
4586
+ redoStack: [],
4587
+ rowHeight: 0,
4588
+ savedSelections: [],
4589
+ scrollBarHeight: 0,
4590
+ scrollBarWidth: 0,
4591
+ selectionAnchorPosition: {
4592
+ columnIndex: 0,
4593
+ rowIndex: 0
4594
+ },
4595
+ selectionAutoMovePosition: {
4596
+ columnIndex: 0,
4597
+ rowIndex: 0
4598
+ },
4599
+ selectionInfos: [],
4600
+ selections: new Uint32Array(),
4601
+ tabSize: 0,
4602
+ textInfos: [],
4603
+ tokenizerId: 0,
4604
+ uid: id,
4605
+ undoStack: [],
4606
+ uri,
4607
+ validLines: [],
4608
+ visibleLineIndices: [],
4609
+ visualDecorations: [],
4610
+ widgetRevision: 0,
4611
+ widgets: [],
4612
+ width,
4613
+ x,
4614
+ y
4615
+ };
4616
+ set$8(id, editor, editor);
4389
4617
  };
4390
4618
 
4391
4619
  const emptyEditor = {
@@ -4917,8 +5145,8 @@ const disposeEditor = async editorUid => {
4917
5145
  return [];
4918
5146
  }
4919
5147
  for (const widget of editor.widgets) {
4920
- if (widget.id === ColorPicker$1) {
4921
- await invoke$8('ColorPicker.dispose', widget.newState.uid);
5148
+ if (widget.id === ColorPicker$2) {
5149
+ await invoke$6('ColorPicker.dispose', widget.newState.uid);
4922
5150
  }
4923
5151
  }
4924
5152
  const commands = renderWidgets$1(editor, {
@@ -4988,51 +5216,6 @@ const addCursorBelow = editor => {
4988
5216
  };
4989
5217
  };
4990
5218
 
4991
- const getDocumentEdits = (editor, edits) => {
4992
- const documentEdits = [];
4993
- let currentDocument = editor;
4994
- let linesDelta = 0;
4995
- let offsetDelta = 0;
4996
- const sortedEdits = edits.toSorted((a, b) => a.startOffset - b.startOffset || a.endOffset - b.endOffset);
4997
- for (const edit of sortedEdits) {
4998
- const currentStart = positionAt(currentDocument, edit.startOffset + offsetDelta);
4999
- const currentEnd = positionAt(currentDocument, edit.endOffset + offsetDelta);
5000
- const deleted = getSelectionText(currentDocument, {
5001
- end: currentEnd,
5002
- start: currentStart
5003
- });
5004
- const documentEdit = {
5005
- deleted,
5006
- end: {
5007
- columnIndex: currentEnd.columnIndex,
5008
- rowIndex: currentEnd.rowIndex - linesDelta
5009
- },
5010
- inserted: splitLines(edit.inserted),
5011
- origin: Format,
5012
- start: {
5013
- columnIndex: currentStart.columnIndex,
5014
- rowIndex: currentStart.rowIndex - linesDelta
5015
- }
5016
- };
5017
- if (documentEdit.inserted.length === 0) {
5018
- documentEdit.inserted = [''];
5019
- }
5020
- documentEdits.push(documentEdit);
5021
- const currentEdit = {
5022
- ...documentEdit,
5023
- end: currentEnd,
5024
- start: currentStart
5025
- };
5026
- currentDocument = {
5027
- ...currentDocument,
5028
- lines: applyEdits(currentDocument, [currentEdit])
5029
- };
5030
- linesDelta += documentEdit.inserted.length - documentEdit.deleted.length;
5031
- offsetDelta += edit.inserted.length - (edit.endOffset - edit.startOffset);
5032
- }
5033
- return documentEdits;
5034
- };
5035
-
5036
5219
  const warn = (...args) => {
5037
5220
  console.warn(...args);
5038
5221
  };
@@ -5131,7 +5314,7 @@ const applyWorkspaceEdit = async (editor, changes) => {
5131
5314
  }
5132
5315
  const text = await readFile(uri);
5133
5316
  const newText = applyEditsToText(text, edits);
5134
- await invoke$6('FileSystem.writeFile', uri, newText);
5317
+ await invoke$7('FileSystem.writeFile', uri, newText);
5135
5318
  }
5136
5319
  return currentEditor;
5137
5320
  };
@@ -5443,7 +5626,7 @@ const isUntitledFile = uri => {
5443
5626
  };
5444
5627
 
5445
5628
  const saveNormalFile = async (uri, content) => {
5446
- await invoke$a('FileSystem.writeFile', uri, content);
5629
+ await invoke$a('FileSystem.writeFile', uri, content, 'utf8', false);
5447
5630
  };
5448
5631
 
5449
5632
  const showFilePicker = async platform => {
@@ -5887,43 +6070,125 @@ const addWidgetToEditor = async (widgetId, focusKey, editor, factory, newStateGe
5887
6070
  return newEditor;
5888
6071
  };
5889
6072
 
5890
- const create$6 = () => {
6073
+ const create$6 = (bounds, range, undoStackIndex) => {
5891
6074
  const completionUid = create$8();
6075
+ const state = {
6076
+ ...bounds,
6077
+ commands: [],
6078
+ ...range,
6079
+ uid: completionUid,
6080
+ undoStackIndex
6081
+ };
5892
6082
  const widget = {
5893
- id: ColorPicker$1,
5894
- newState: {
5895
- commands: [],
5896
- height: 0,
5897
- uid: completionUid,
5898
- width: 0,
5899
- x: 0,
5900
- y: 0
5901
- },
5902
- oldState: {
5903
- commands: [],
5904
- height: 0,
5905
- uid: completionUid,
5906
- width: 0,
5907
- x: 0,
5908
- y: 0
5909
- }
6083
+ id: ColorPicker$2,
6084
+ newState: state,
6085
+ oldState: state
5910
6086
  };
5911
6087
  return widget;
5912
6088
  };
5913
6089
 
6090
+ const preferredHeight = 200;
6091
+ const preferredWidth$1 = 300;
6092
+ const getColorPickerBounds = editor => {
6093
+ const {
6094
+ columnWidth,
6095
+ deltaX = 0,
6096
+ deltaY = 0,
6097
+ foldingRanges = [],
6098
+ height: editorHeight,
6099
+ rowHeight,
6100
+ selections,
6101
+ width: editorWidth,
6102
+ x: editorX,
6103
+ y: editorY
6104
+ } = editor;
6105
+ const rowIndex = selections[0];
6106
+ const columnIndex = selections[1];
6107
+ const width = Math.min(preferredWidth$1, editorWidth);
6108
+ const height = Math.min(preferredHeight, editorHeight);
6109
+ const editorRight = editorX + editorWidth;
6110
+ const editorBottom = editorY + editorHeight;
6111
+ const cursorX = editorX + columnIndex * columnWidth - deltaX;
6112
+ const visualRowIndex = getVisualRowForDocumentRow(rowIndex, foldingRanges);
6113
+ const lineTop = editorY + visualRowIndex * rowHeight - deltaY;
6114
+ const lineBottom = lineTop + rowHeight;
6115
+ const yAbove = lineTop - height;
6116
+ const yBelow = lineBottom;
6117
+ const preferredY = yAbove >= editorY ? yAbove : yBelow;
6118
+ return {
6119
+ height,
6120
+ width,
6121
+ x: clamp(cursorX, editorX, editorRight - width),
6122
+ y: clamp(preferredY, editorY, editorBottom - height)
6123
+ };
6124
+ };
6125
+
6126
+ const noColorRange = {
6127
+ endOffset: -1,
6128
+ startOffset: -1,
6129
+ value: ''
6130
+ };
6131
+ const colorPattern = /#[\da-f]{3,8}\b|\b(?:hsla?|rgba?)\([^)]*\)/gi;
6132
+ const getColorPickerRange = editor => {
6133
+ const {
6134
+ lines,
6135
+ selections
6136
+ } = editor;
6137
+ if (!selections || selections.length < 4) {
6138
+ return noColorRange;
6139
+ }
6140
+ const selectionStartRow = selections[0];
6141
+ const selectionEndRow = selections[2];
6142
+ if (selectionStartRow !== selectionEndRow) {
6143
+ return noColorRange;
6144
+ }
6145
+ const selectionStartColumn = selections[1];
6146
+ const selectionEndColumn = selections[3];
6147
+ const rowIndex = selectionEndRow;
6148
+ const line = lines[rowIndex];
6149
+ if (typeof line !== 'string') {
6150
+ return noColorRange;
6151
+ }
6152
+ if (selectionStartColumn !== selectionEndColumn) {
6153
+ const startColumn = Math.min(selectionStartColumn, selectionEndColumn);
6154
+ const endColumn = Math.max(selectionStartColumn, selectionEndColumn);
6155
+ return {
6156
+ endOffset: offsetAt(editor, rowIndex, endColumn),
6157
+ startOffset: offsetAt(editor, rowIndex, startColumn),
6158
+ value: line.slice(startColumn, endColumn)
6159
+ };
6160
+ }
6161
+ const columnIndex = selectionEndColumn;
6162
+ for (const match of line.matchAll(colorPattern)) {
6163
+ const startColumn = match.index;
6164
+ const endColumn = startColumn + match[0].length;
6165
+ if (columnIndex >= startColumn && columnIndex <= endColumn) {
6166
+ return {
6167
+ endOffset: offsetAt(editor, rowIndex, endColumn),
6168
+ startOffset: offsetAt(editor, rowIndex, startColumn),
6169
+ value: match[0]
6170
+ };
6171
+ }
6172
+ }
6173
+ return noColorRange;
6174
+ };
6175
+
5914
6176
  const newStateGenerator$5 = (state, parentUid) => {
5915
6177
  return loadContent$3(state, parentUid);
5916
6178
  };
5917
6179
  const openColorPicker = async editor => {
5918
6180
  const fullFocus = true;
5919
- return addWidgetToEditor(ColorPicker$1, ColorPicker, editor, create$6, newStateGenerator$5, fullFocus);
6181
+ const bounds = getColorPickerBounds(editor);
6182
+ const range = getColorPickerRange(editor);
6183
+ const createWidget = () => create$6(bounds, range, editor.undoStack.length);
6184
+ return addWidgetToEditor(ColorPicker$2, ColorPicker, editor, createWidget, newStateGenerator$5, fullFocus);
5920
6185
  };
5921
6186
  const closeColorPicker = editor => {
5922
6187
  const {
5923
6188
  widgets
5924
6189
  } = editor;
5925
6190
  const widgetRevision = next(editor.uid);
5926
- if (widgets.every(widget => widget.id !== ColorPicker$1)) {
6191
+ if (widgets.every(widget => widget.id !== ColorPicker$2)) {
5927
6192
  return editor;
5928
6193
  }
5929
6194
  return {
@@ -5932,7 +6197,7 @@ const closeColorPicker = editor => {
5932
6197
  focus: FocusEditorText$1,
5933
6198
  focused: true,
5934
6199
  widgetRevision,
5935
- widgets: removeEditorWidget(widgets, ColorPicker$1)
6200
+ widgets: removeEditorWidget(widgets, ColorPicker$2)
5936
6201
  };
5937
6202
  };
5938
6203
 
@@ -8087,100 +8352,6 @@ const requestAnimationFrame = fn => {
8087
8352
  globalThis.requestAnimationFrame(fn);
8088
8353
  };
8089
8354
 
8090
- const getDiagnosticType = diagnostic => {
8091
- return diagnostic.type;
8092
- };
8093
-
8094
- const getY = (row, minLineY, rowHeight) => {
8095
- return (row - minLineY) * rowHeight;
8096
- };
8097
-
8098
- const getVisibleDiagnostics = async (editor, diagnostics) => {
8099
- const visibleDiagnostics = [];
8100
- const {
8101
- charWidth,
8102
- fontFamily,
8103
- fontSize,
8104
- fontWeight,
8105
- isMonospaceFont,
8106
- letterSpacing,
8107
- lines,
8108
- minLineY,
8109
- rowHeight,
8110
- tabSize,
8111
- width
8112
- } = editor;
8113
- for (const diagnostic of diagnostics) {
8114
- const {
8115
- columnIndex,
8116
- endColumnIndex,
8117
- rowIndex
8118
- } = diagnostic;
8119
- const columnDelta = endColumnIndex - columnIndex;
8120
- const diagnosticWidth = columnDelta * charWidth;
8121
- const endLineDifference = 0;
8122
- const halfCursorWidth = 0;
8123
- const x = await getX(lines[rowIndex], columnIndex, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, halfCursorWidth, width, charWidth, endLineDifference);
8124
- const y = getY(rowIndex, minLineY, rowHeight);
8125
- visibleDiagnostics.push({
8126
- height: rowHeight,
8127
- type: getDiagnosticType(diagnostic),
8128
- width: diagnosticWidth,
8129
- x,
8130
- y
8131
- });
8132
- }
8133
- return visibleDiagnostics;
8134
- };
8135
-
8136
- const shouldUpdateDiagnosticData = (oldState, newState) => {
8137
- return oldState.diagnostics !== newState.diagnostics || (newState.diagnostics?.length ?? 0) > 0 && (oldState.minLineY !== newState.minLineY || oldState.charWidth !== newState.charWidth || oldState.fontFamily !== newState.fontFamily || oldState.fontSize !== newState.fontSize || oldState.fontWeight !== newState.fontWeight || oldState.isMonospaceFont !== newState.isMonospaceFont || oldState.letterSpacing !== newState.letterSpacing || oldState.lines !== newState.lines || oldState.rowHeight !== newState.rowHeight || oldState.tabSize !== newState.tabSize || oldState.width !== newState.width);
8138
- };
8139
- const shouldUpdateSelectionData = (oldState, newState) => {
8140
- return oldState.selections !== newState.selections || oldState.focused !== newState.focused || oldState.minLineY !== newState.minLineY || oldState.maxLineY !== newState.maxLineY || oldState.foldingRanges !== newState.foldingRanges || oldState.differences !== newState.differences || oldState.charWidth !== newState.charWidth || oldState.cursorWidth !== newState.cursorWidth || oldState.fontFamily !== newState.fontFamily || oldState.fontSize !== newState.fontSize || oldState.fontWeight !== newState.fontWeight || oldState.isMonospaceFont !== newState.isMonospaceFont || oldState.letterSpacing !== newState.letterSpacing || oldState.lines !== newState.lines || oldState.rowHeight !== newState.rowHeight || oldState.tabSize !== newState.tabSize || oldState.width !== newState.width;
8141
- };
8142
- const shouldUpdateVisibleTextData = (oldState, newState) => {
8143
- if (oldState.textInfos !== newState.textInfos || oldState.differences !== newState.differences) {
8144
- return false;
8145
- }
8146
- return oldState.lines !== newState.lines || oldState.tokenizerId !== newState.tokenizerId || oldState.minLineY !== newState.minLineY || oldState.maxLineY !== newState.maxLineY || oldState.decorations !== newState.decorations || oldState.embeds !== newState.embeds || oldState.deltaX !== newState.deltaX || oldState.width !== newState.width || oldState.highlightedLine !== newState.highlightedLine || oldState.foldingRanges !== newState.foldingRanges || oldState.debugEnabled !== newState.debugEnabled;
8147
- };
8148
- const updateDerivedState = async (oldState, newState) => {
8149
- const nextState = oldState.lines !== newState.lines && 'foldingRanges' in newState ? updateLayout(newState, []) : newState;
8150
- let finalState = nextState;
8151
- if (shouldUpdateVisibleTextData(oldState, nextState)) {
8152
- const syncIncremental = getEnabled();
8153
- const {
8154
- differences,
8155
- textInfos
8156
- } = await getVisible$1(nextState, syncIncremental);
8157
- finalState = {
8158
- ...nextState,
8159
- differences,
8160
- textInfos
8161
- };
8162
- }
8163
- if (shouldUpdateDiagnosticData(oldState, nextState)) {
8164
- const visualDecorations = await getVisibleDiagnostics(finalState, finalState.diagnostics ?? []);
8165
- finalState = {
8166
- ...finalState,
8167
- visualDecorations
8168
- };
8169
- }
8170
- if (!shouldUpdateSelectionData(oldState, nextState)) {
8171
- return finalState;
8172
- }
8173
- const {
8174
- cursorInfos,
8175
- selectionInfos
8176
- } = await getVisible(finalState);
8177
- return {
8178
- ...finalState,
8179
- cursorInfos,
8180
- selectionInfos
8181
- };
8182
- };
8183
-
8184
8355
  const LessThan = -1;
8185
8356
  const Equal = 0;
8186
8357
  const GreaterThan = 1;
@@ -8863,7 +9034,7 @@ const openCompletion = async editor => {
8863
9034
  const isFunctional = widgetId => {
8864
9035
  switch (widgetId) {
8865
9036
  case Message:
8866
- case ColorPicker$1:
9037
+ case ColorPicker$2:
8867
9038
  case Completion:
8868
9039
  case Find:
8869
9040
  case Hover:
@@ -8901,17 +9072,6 @@ const addWidget = (widget, id, render) => {
8901
9072
  return allCommands;
8902
9073
  };
8903
9074
 
8904
- const getEditor$1 = editorUid => {
8905
- const instance = get$8(editorUid);
8906
- if (!instance) {
8907
- throw new Error(`editor ${editorUid} not found`);
8908
- }
8909
- const {
8910
- newState
8911
- } = instance;
8912
- return newState;
8913
- };
8914
-
8915
9075
  const setFocus = async focusKey => {
8916
9076
  await invoke$a('Focus.setFocus', focusKey);
8917
9077
  };
@@ -9047,8 +9207,8 @@ const invoke$1 = async (method, ...params) => {
9047
9207
 
9048
9208
  const getWidgetInvoke = widgetId => {
9049
9209
  switch (widgetId) {
9050
- case ColorPicker$1:
9051
- return invoke$8;
9210
+ case ColorPicker$2:
9211
+ return invoke$6;
9052
9212
  case Completion:
9053
9213
  return invoke$4;
9054
9214
  case Find:
@@ -10905,7 +11065,7 @@ const undo = state => {
10905
11065
  return state;
10906
11066
  }
10907
11067
  const last = undoStack.at(-1);
10908
- const inverseChanges = last.map(inverseChange);
11068
+ const inverseChanges = last.toReversed().map(inverseChange);
10909
11069
  const newState = {
10910
11070
  ...state,
10911
11071
  redoStack: [...(state.redoStack || []), last],
@@ -13880,7 +14040,7 @@ const handleError = async (error, editor) => {
13880
14040
  };
13881
14041
  const notifyDiagnosticsChange = async uri => {
13882
14042
  try {
13883
- await invoke$6('Layout.handleDiagnosticsChange', uri);
14043
+ await invoke$7('Layout.handleDiagnosticsChange', uri);
13884
14044
  } catch {
13885
14045
  // Older renderer workers do not support diagnostics change listeners.
13886
14046
  }
@@ -14256,6 +14416,7 @@ const commandMap = {
14256
14416
  'Editor.undo': wrapCommand(undo),
14257
14417
  'Editor.unfold': wrapCommand(unfold),
14258
14418
  'Editor.unIndent': wrapCommand(editorUnindent),
14419
+ 'Editor.updateColorPickerValue': wrapCommand(updateColorPickerValue$1),
14259
14420
  'Editor.updateDebugInfo': updateDebugInfo,
14260
14421
  'Editor.updateDiagnostics': wrapCommand(updateDiagnostics),
14261
14422
  'Editor.updateDiagnosticsAll': updateDiagnosticsAll,
@@ -14726,7 +14887,7 @@ const EditorMessageWidget = {
14726
14887
  };
14727
14888
 
14728
14889
  const registerWidgets = () => {
14729
- set$7(ColorPicker$1, EditorColorPickerWidget);
14890
+ set$7(ColorPicker$2, EditorColorPickerWidget);
14730
14891
  set$7(Completion, EditorCompletionWidget);
14731
14892
  set$7(CompletionDetail, EditorCompletionDetailWidget);
14732
14893
  set$7(Find, EditorFindWidget);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "19.30.9",
3
+ "version": "19.30.11",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"