@lvce-editor/editor-worker 19.72.2 → 19.72.3

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.
@@ -8315,7 +8315,7 @@ const cancelSelection = editor => {
8315
8315
  return scheduleSelections(editor, newSelections);
8316
8316
  };
8317
8317
 
8318
- const colorPattern = /#[\dA-Fa-f]+/g;
8318
+ const colorPattern$2 = /#[\dA-Fa-f]+/g;
8319
8319
  const numberPattern = /(?<![\w.#])[+-]?(?:(?:\d+(?:\.\d*)?)|(?:\.\d+))(?:[eE][+-]?\d+)?(?![\d.])/g;
8320
8320
  const validColorLengths = new Set([4, 5, 7, 9]);
8321
8321
  const isColor = value => {
@@ -8398,7 +8398,7 @@ const findMatchAt = (line, columnIndex, pattern, predicate) => {
8398
8398
  return undefined;
8399
8399
  };
8400
8400
  const findValueAt = (line, columnIndex) => {
8401
- return findMatchAt(line, columnIndex, colorPattern, isColor) ?? findMatchAt(line, columnIndex, numberPattern, isNumber);
8401
+ return findMatchAt(line, columnIndex, colorPattern$2, isColor) ?? findMatchAt(line, columnIndex, numberPattern, isNumber);
8402
8402
  };
8403
8403
  const getSelectionTarget = (editor, index) => {
8404
8404
  const selectionStartRow = editor.selections[index];
@@ -8766,7 +8766,7 @@ const openColorPicker = async editor => {
8766
8766
  const bounds = getColorPickerBounds(editor);
8767
8767
  const {
8768
8768
  getColorPickerRange
8769
- } = await import('./GetColorPickerRange-CsGZK202.js');
8769
+ } = await Promise.resolve().then(function () { return GetColorPickerRange; });
8770
8770
  const range = await getColorPickerRange(editor);
8771
8771
  const createWidget = () => create$6(bounds, range, editor.undoStack.length);
8772
8772
  return addWidgetToEditor(ColorPicker$2, ColorPicker, editor, createWidget, newStateGenerator$5, fullFocus);
@@ -11409,10 +11409,17 @@ const continueScrollingAndMovingSelection = async editorUid => {
11409
11409
  return;
11410
11410
  }
11411
11411
  set$a(editor.uid, editor, derivedEditor);
11412
+ await invoke$d('Editor.renderPending', editor.uid);
11412
11413
  if (derivedEditor.hasListener) {
11413
11414
  requestAnimationFrame(() => continueScrollingAndMovingSelection(editorUid));
11414
11415
  }
11415
11416
  };
11417
+ const scheduleInitialSelectionAutoScroll = editorUid => {
11418
+ // Let the wrapped pointer-move command commit hasListener before the loop reads state.
11419
+ requestAnimationFrame(() => {
11420
+ requestAnimationFrame(() => continueScrollingAndMovingSelection(editorUid));
11421
+ });
11422
+ };
11416
11423
  const moveSelectionPx = async (editor, x, y) => {
11417
11424
  object(editor);
11418
11425
  number(x);
@@ -11428,7 +11435,7 @@ const moveSelectionPx = async (editor, x, y) => {
11428
11435
  };
11429
11436
  }
11430
11437
  if (!editor.hasListener) {
11431
- requestAnimationFrame(() => continueScrollingAndMovingSelection(editor.uid));
11438
+ scheduleInitialSelectionAutoScroll(editor.uid);
11432
11439
  }
11433
11440
  return {
11434
11441
  ...newEditor,
@@ -15389,6 +15396,20 @@ const getPositionAtCursor = editorUid => {
15389
15396
  const editor = getEditor$1(editorUid);
15390
15397
  return getPositionAtCursor$1(editor);
15391
15398
  };
15399
+ const getCompletionContext = (editorUid, includeLine = false) => {
15400
+ const editor = getEditor$1(editorUid);
15401
+ const position = getPositionAtCursor$1(editor);
15402
+ if (!includeLine) {
15403
+ return {
15404
+ ...position,
15405
+ wordBefore: getWordBefore(editor, position.rowIndex, position.columnIndex)
15406
+ };
15407
+ }
15408
+ return {
15409
+ ...position,
15410
+ line: editor.lines[position.rowIndex] || ''
15411
+ };
15412
+ };
15392
15413
  const getUri = editorUid => {
15393
15414
  const editor = getEditor$1(editorUid);
15394
15415
  return editor.uri;
@@ -18769,6 +18790,7 @@ const commandMap = {
18769
18790
  'Editor.fold': wrapCommand(fold$1),
18770
18791
  'Editor.format': wrapCommand(format),
18771
18792
  'Editor.getCommandIds': getCommandIds,
18793
+ 'Editor.getCompletionContext': getCompletionContext,
18772
18794
  'Editor.getDiagnostics': getDiagnostics,
18773
18795
  'Editor.getKeyBindings': getKeyBindings,
18774
18796
  'Editor.getKeys': getKeys,
@@ -19442,4 +19464,100 @@ const main = async () => {
19442
19464
 
19443
19465
  main();
19444
19466
 
19445
- export { offsetAt as o };
19467
+ const noColorRange = {
19468
+ endOffset: -1,
19469
+ startOffset: -1,
19470
+ value: ''
19471
+ };
19472
+ const colorPattern$1 = /#[\da-f]{3,8}\b|(?<![\w$])0x[\da-f]{6}(?![\w$])|\b(?:hsla?|rgba?)\([^)]*\)/gi;
19473
+ const getColorPickerRange = async editor => {
19474
+ const {
19475
+ lines,
19476
+ selections
19477
+ } = editor;
19478
+ if (!selections || selections.length < 4) {
19479
+ return noColorRange;
19480
+ }
19481
+ const selectionStartRow = selections[0];
19482
+ const selectionEndRow = selections[2];
19483
+ if (selectionStartRow !== selectionEndRow) {
19484
+ return noColorRange;
19485
+ }
19486
+ const selectionStartColumn = selections[1];
19487
+ const selectionEndColumn = selections[3];
19488
+ const rowIndex = selectionEndRow;
19489
+ const line = lines[rowIndex];
19490
+ if (typeof line !== 'string') {
19491
+ return noColorRange;
19492
+ }
19493
+ if (selectionStartColumn !== selectionEndColumn) {
19494
+ const startColumn = Math.min(selectionStartColumn, selectionEndColumn);
19495
+ const endColumn = Math.max(selectionStartColumn, selectionEndColumn);
19496
+ return {
19497
+ endOffset: offsetAt(editor, rowIndex, endColumn),
19498
+ startOffset: offsetAt(editor, rowIndex, startColumn),
19499
+ value: line.slice(startColumn, endColumn)
19500
+ };
19501
+ }
19502
+ const columnIndex = selectionEndColumn;
19503
+ for (const match of line.matchAll(colorPattern$1)) {
19504
+ const startColumn = match.index;
19505
+ const endColumn = startColumn + match[0].length;
19506
+ if (columnIndex >= startColumn && columnIndex <= endColumn) {
19507
+ return {
19508
+ endOffset: offsetAt(editor, rowIndex, endColumn),
19509
+ startOffset: offsetAt(editor, rowIndex, startColumn),
19510
+ value: match[0]
19511
+ };
19512
+ }
19513
+ }
19514
+ const {
19515
+ getNamedColorRange
19516
+ } = await Promise.resolve().then(function () { return GetNamedColorRange; });
19517
+ const namedColorRange = getNamedColorRange(line, columnIndex);
19518
+ if (!namedColorRange) {
19519
+ return noColorRange;
19520
+ }
19521
+ return {
19522
+ endOffset: offsetAt(editor, rowIndex, namedColorRange.end),
19523
+ startOffset: offsetAt(editor, rowIndex, namedColorRange.start),
19524
+ value: namedColorRange.value
19525
+ };
19526
+ };
19527
+
19528
+ const GetColorPickerRange = {
19529
+ __proto__: null,
19530
+ getColorPickerRange
19531
+ };
19532
+
19533
+ const colorPattern = /\b[a-z]+\b/gi;
19534
+ const getNamedColorRange = (line, columnIndex) => {
19535
+ for (const match of line.matchAll(colorPattern)) {
19536
+ const start = match.index;
19537
+ const end = start + match[0].length;
19538
+ if (columnIndex < start || columnIndex > end || line[start - 1] === '-' || line[end] === '-') {
19539
+ continue;
19540
+ }
19541
+ const value = match[0];
19542
+ if (value.toLowerCase() === 'currentcolor') {
19543
+ return undefined;
19544
+ }
19545
+ const context = new OffscreenCanvas(1, 1).getContext('2d');
19546
+ context.fillStyle = '#010203';
19547
+ context.fillStyle = value;
19548
+ if (context.fillStyle === '#010203') {
19549
+ return undefined;
19550
+ }
19551
+ return {
19552
+ end,
19553
+ start,
19554
+ value
19555
+ };
19556
+ }
19557
+ return undefined;
19558
+ };
19559
+
19560
+ const GetNamedColorRange = {
19561
+ __proto__: null,
19562
+ getNamedColorRange
19563
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "19.72.2",
3
+ "version": "19.72.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"
@@ -1,64 +0,0 @@
1
- import { o as offsetAt } from './editorWorkerMain.js';
2
-
3
- const noColorRange = {
4
- endOffset: -1,
5
- startOffset: -1,
6
- value: ''
7
- };
8
- const colorPattern = /#[\da-f]{3,8}\b|(?<![\w$])0x[\da-f]{6}(?![\w$])|\b(?:hsla?|rgba?)\([^)]*\)/gi;
9
- const getColorPickerRange = async editor => {
10
- const {
11
- lines,
12
- selections
13
- } = editor;
14
- if (!selections || selections.length < 4) {
15
- return noColorRange;
16
- }
17
- const selectionStartRow = selections[0];
18
- const selectionEndRow = selections[2];
19
- if (selectionStartRow !== selectionEndRow) {
20
- return noColorRange;
21
- }
22
- const selectionStartColumn = selections[1];
23
- const selectionEndColumn = selections[3];
24
- const rowIndex = selectionEndRow;
25
- const line = lines[rowIndex];
26
- if (typeof line !== 'string') {
27
- return noColorRange;
28
- }
29
- if (selectionStartColumn !== selectionEndColumn) {
30
- const startColumn = Math.min(selectionStartColumn, selectionEndColumn);
31
- const endColumn = Math.max(selectionStartColumn, selectionEndColumn);
32
- return {
33
- endOffset: offsetAt(editor, rowIndex, endColumn),
34
- startOffset: offsetAt(editor, rowIndex, startColumn),
35
- value: line.slice(startColumn, endColumn)
36
- };
37
- }
38
- const columnIndex = selectionEndColumn;
39
- for (const match of line.matchAll(colorPattern)) {
40
- const startColumn = match.index;
41
- const endColumn = startColumn + match[0].length;
42
- if (columnIndex >= startColumn && columnIndex <= endColumn) {
43
- return {
44
- endOffset: offsetAt(editor, rowIndex, endColumn),
45
- startOffset: offsetAt(editor, rowIndex, startColumn),
46
- value: match[0]
47
- };
48
- }
49
- }
50
- const {
51
- getNamedColorRange
52
- } = await import('./GetNamedColorRange-LJAB8ndU.js');
53
- const namedColorRange = getNamedColorRange(line, columnIndex);
54
- if (!namedColorRange) {
55
- return noColorRange;
56
- }
57
- return {
58
- endOffset: offsetAt(editor, rowIndex, namedColorRange.end),
59
- startOffset: offsetAt(editor, rowIndex, namedColorRange.start),
60
- value: namedColorRange.value
61
- };
62
- };
63
-
64
- export { getColorPickerRange };
@@ -1,28 +0,0 @@
1
- const colorPattern = /\b[a-z]+\b/gi;
2
- const getNamedColorRange = (line, columnIndex) => {
3
- for (const match of line.matchAll(colorPattern)) {
4
- const start = match.index;
5
- const end = start + match[0].length;
6
- if (columnIndex < start || columnIndex > end || line[start - 1] === '-' || line[end] === '-') {
7
- continue;
8
- }
9
- const value = match[0];
10
- if (value.toLowerCase() === 'currentcolor') {
11
- return undefined;
12
- }
13
- const context = new OffscreenCanvas(1, 1).getContext('2d');
14
- context.fillStyle = '#010203';
15
- context.fillStyle = value;
16
- if (context.fillStyle === '#010203') {
17
- return undefined;
18
- }
19
- return {
20
- end,
21
- start,
22
- value
23
- };
24
- }
25
- return undefined;
26
- };
27
-
28
- export { getNamedColorRange };