@lvce-editor/editor-worker 19.61.5 → 19.62.1
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.
|
@@ -0,0 +1,64 @@
|
|
|
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|\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 };
|
|
@@ -0,0 +1,28 @@
|
|
|
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 };
|
package/dist/editorWorkerMain.js
CHANGED
|
@@ -1764,7 +1764,7 @@ const codeGeneratorAccept = state => {
|
|
|
1764
1764
|
|
|
1765
1765
|
const editorStates = create$9();
|
|
1766
1766
|
const {
|
|
1767
|
-
dispose: dispose$
|
|
1767
|
+
dispose: dispose$5,
|
|
1768
1768
|
getCommandIds,
|
|
1769
1769
|
registerCommands,
|
|
1770
1770
|
wrapGetter
|
|
@@ -2333,7 +2333,7 @@ const getInitialLineState = initialLineState => {
|
|
|
2333
2333
|
return deepCopy(initialLineState);
|
|
2334
2334
|
};
|
|
2335
2335
|
|
|
2336
|
-
const state$
|
|
2336
|
+
const state$d = {
|
|
2337
2337
|
warned: []
|
|
2338
2338
|
};
|
|
2339
2339
|
const flattenTokensArray = tokens => {
|
|
@@ -2345,10 +2345,10 @@ const flattenTokensArray = tokens => {
|
|
|
2345
2345
|
return flattened;
|
|
2346
2346
|
};
|
|
2347
2347
|
const warnDeprecatedArrayReturn = (languageId, fn) => {
|
|
2348
|
-
if (state$
|
|
2348
|
+
if (state$d.warned.includes(fn)) {
|
|
2349
2349
|
return;
|
|
2350
2350
|
}
|
|
2351
|
-
state$
|
|
2351
|
+
state$d.warned.push(fn);
|
|
2352
2352
|
console.warn(`tokenizers without hasArrayReturn=false are deprecated (language ${languageId})`);
|
|
2353
2353
|
};
|
|
2354
2354
|
const safeTokenizeLine = (languageId, tokenizeLine, line, lineStateAtStart, hasArrayReturn) => {
|
|
@@ -2409,14 +2409,14 @@ const TokenizePlainText = {
|
|
|
2409
2409
|
tokenizeLine
|
|
2410
2410
|
};
|
|
2411
2411
|
|
|
2412
|
-
const state$
|
|
2412
|
+
const state$c = {
|
|
2413
2413
|
enabled: false
|
|
2414
2414
|
};
|
|
2415
2415
|
const setEnabled$1 = value => {
|
|
2416
|
-
state$
|
|
2416
|
+
state$c.enabled = value;
|
|
2417
2417
|
};
|
|
2418
2418
|
const getEnabled$1 = () => {
|
|
2419
|
-
return state$
|
|
2419
|
+
return state$c.enabled;
|
|
2420
2420
|
};
|
|
2421
2421
|
|
|
2422
2422
|
const {
|
|
@@ -2424,25 +2424,25 @@ const {
|
|
|
2424
2424
|
set: set$6
|
|
2425
2425
|
} = SyntaxHighlightingWorker;
|
|
2426
2426
|
|
|
2427
|
-
const state$
|
|
2427
|
+
const state$b = {
|
|
2428
2428
|
pending: Object.create(null),
|
|
2429
2429
|
tokenizePaths: Object.create(null),
|
|
2430
2430
|
tokenizers: Object.create(null)
|
|
2431
2431
|
};
|
|
2432
2432
|
const has = languageId => {
|
|
2433
|
-
return Object.hasOwn(state$
|
|
2433
|
+
return Object.hasOwn(state$b.tokenizers, languageId);
|
|
2434
2434
|
};
|
|
2435
2435
|
const set$5 = (languageId, tokenizer) => {
|
|
2436
|
-
state$
|
|
2436
|
+
state$b.tokenizers[languageId] = tokenizer;
|
|
2437
2437
|
};
|
|
2438
2438
|
const get$6 = languageId => {
|
|
2439
|
-
return state$
|
|
2439
|
+
return state$b.tokenizers[languageId];
|
|
2440
2440
|
};
|
|
2441
2441
|
const setTokenizePath = (languageId, tokenizePath) => {
|
|
2442
|
-
state$
|
|
2442
|
+
state$b.tokenizePaths[languageId] = tokenizePath;
|
|
2443
2443
|
};
|
|
2444
2444
|
const getTokenizePath$1 = languageId => {
|
|
2445
|
-
return state$
|
|
2445
|
+
return state$b.tokenizePaths[languageId] || '';
|
|
2446
2446
|
};
|
|
2447
2447
|
const setTokenizePaths = languages => {
|
|
2448
2448
|
for (const language of languages) {
|
|
@@ -2452,7 +2452,7 @@ const setTokenizePaths = languages => {
|
|
|
2452
2452
|
}
|
|
2453
2453
|
};
|
|
2454
2454
|
const isPending = languageId => {
|
|
2455
|
-
return Object.hasOwn(state$
|
|
2455
|
+
return Object.hasOwn(state$b.pending, languageId);
|
|
2456
2456
|
};
|
|
2457
2457
|
|
|
2458
2458
|
const tokenMaps = Object.create(null);
|
|
@@ -3280,14 +3280,14 @@ const getVisible$1 = async (editor, syncIncremental) => {
|
|
|
3280
3280
|
};
|
|
3281
3281
|
};
|
|
3282
3282
|
|
|
3283
|
-
const state$
|
|
3283
|
+
const state$a = {
|
|
3284
3284
|
enabled: false
|
|
3285
3285
|
};
|
|
3286
3286
|
const setEnabled = value => {
|
|
3287
|
-
state$
|
|
3287
|
+
state$a.enabled = value;
|
|
3288
3288
|
};
|
|
3289
3289
|
const getEnabled = () => {
|
|
3290
|
-
return state$
|
|
3290
|
+
return state$a.enabled;
|
|
3291
3291
|
};
|
|
3292
3292
|
|
|
3293
3293
|
// TODO this should be in a separate scrolling module
|
|
@@ -3573,7 +3573,7 @@ const start = delivery => {
|
|
|
3573
3573
|
delivery.running = run$1(delivery);
|
|
3574
3574
|
return delivery.running;
|
|
3575
3575
|
};
|
|
3576
|
-
const dispose$
|
|
3576
|
+
const dispose$4 = rpcId => {
|
|
3577
3577
|
const delivery = deliveries.get(rpcId);
|
|
3578
3578
|
if (delivery) {
|
|
3579
3579
|
delivery.disposed = true;
|
|
@@ -3583,7 +3583,7 @@ const dispose$3 = rpcId => {
|
|
|
3583
3583
|
const send$2 = (rpcId, rpc, status) => {
|
|
3584
3584
|
let delivery = deliveries.get(rpcId);
|
|
3585
3585
|
if (!delivery || delivery.rpc !== rpc) {
|
|
3586
|
-
dispose$
|
|
3586
|
+
dispose$4(rpcId);
|
|
3587
3587
|
delivery = {
|
|
3588
3588
|
baseline: undefined,
|
|
3589
3589
|
disposed: false,
|
|
@@ -3601,7 +3601,7 @@ const send$2 = (rpcId, rpc, status) => {
|
|
|
3601
3601
|
return delivery.running || start(delivery);
|
|
3602
3602
|
};
|
|
3603
3603
|
|
|
3604
|
-
const state$
|
|
3604
|
+
const state$9 = Object.create(null);
|
|
3605
3605
|
|
|
3606
3606
|
/**
|
|
3607
3607
|
* Register a listener for a specific event type
|
|
@@ -3611,13 +3611,13 @@ const state$a = Object.create(null);
|
|
|
3611
3611
|
const registerListener$1 = (listenerType, rpcId) => {
|
|
3612
3612
|
number(listenerType);
|
|
3613
3613
|
number(rpcId);
|
|
3614
|
-
if (!Object.hasOwn(state$
|
|
3615
|
-
state$
|
|
3614
|
+
if (!Object.hasOwn(state$9, listenerType)) {
|
|
3615
|
+
state$9[listenerType] = [];
|
|
3616
3616
|
}
|
|
3617
3617
|
|
|
3618
3618
|
// Avoid duplicate registrations
|
|
3619
|
-
if (!state$
|
|
3620
|
-
state$
|
|
3619
|
+
if (!state$9[listenerType].includes(rpcId)) {
|
|
3620
|
+
state$9[listenerType].push(rpcId);
|
|
3621
3621
|
}
|
|
3622
3622
|
};
|
|
3623
3623
|
|
|
@@ -3630,12 +3630,12 @@ const unregisterListener$1 = (listenerType, rpcId) => {
|
|
|
3630
3630
|
number(listenerType);
|
|
3631
3631
|
number(rpcId);
|
|
3632
3632
|
if (listenerType === EditorSelection$1) {
|
|
3633
|
-
dispose$
|
|
3633
|
+
dispose$4(rpcId);
|
|
3634
3634
|
}
|
|
3635
|
-
if (Object.hasOwn(state$
|
|
3636
|
-
const index = state$
|
|
3635
|
+
if (Object.hasOwn(state$9, listenerType)) {
|
|
3636
|
+
const index = state$9[listenerType].indexOf(rpcId);
|
|
3637
3637
|
if (index !== -1) {
|
|
3638
|
-
state$
|
|
3638
|
+
state$9[listenerType].splice(index, 1);
|
|
3639
3639
|
}
|
|
3640
3640
|
}
|
|
3641
3641
|
};
|
|
@@ -3647,7 +3647,7 @@ const unregisterListener$1 = (listenerType, rpcId) => {
|
|
|
3647
3647
|
*/
|
|
3648
3648
|
const getListeners = listenerType => {
|
|
3649
3649
|
number(listenerType);
|
|
3650
|
-
return state$
|
|
3650
|
+
return state$9[listenerType] || [];
|
|
3651
3651
|
};
|
|
3652
3652
|
|
|
3653
3653
|
/**
|
|
@@ -5093,15 +5093,15 @@ const launchColorPickerWorker = async () => {
|
|
|
5093
5093
|
return launchWorker(name, url, undefined, getColorPickerWorkerCommandMap());
|
|
5094
5094
|
};
|
|
5095
5095
|
|
|
5096
|
-
const state$
|
|
5097
|
-
const getOrCreate$
|
|
5098
|
-
if (!state$
|
|
5099
|
-
state$
|
|
5096
|
+
const state$8 = {};
|
|
5097
|
+
const getOrCreate$2 = () => {
|
|
5098
|
+
if (!state$8.workerPromise) {
|
|
5099
|
+
state$8.workerPromise = launchColorPickerWorker();
|
|
5100
5100
|
}
|
|
5101
|
-
return state$
|
|
5101
|
+
return state$8.workerPromise;
|
|
5102
5102
|
};
|
|
5103
5103
|
const invoke$7 = async (method, ...params) => {
|
|
5104
|
-
const worker = await getOrCreate$
|
|
5104
|
+
const worker = await getOrCreate$2();
|
|
5105
5105
|
return await worker.invoke(method, ...params);
|
|
5106
5106
|
};
|
|
5107
5107
|
|
|
@@ -5757,7 +5757,7 @@ const diff2 = uid => {
|
|
|
5757
5757
|
|
|
5758
5758
|
const autoSaveDelay = 1000;
|
|
5759
5759
|
const pendingSaves = new Map();
|
|
5760
|
-
const state$
|
|
5760
|
+
const state$7 = {
|
|
5761
5761
|
nextToken: 0
|
|
5762
5762
|
};
|
|
5763
5763
|
const run = async (uid, token, save) => {
|
|
@@ -5767,8 +5767,8 @@ const run = async (uid, token, save) => {
|
|
|
5767
5767
|
await save(token);
|
|
5768
5768
|
};
|
|
5769
5769
|
const schedule = (uid, save) => {
|
|
5770
|
-
dispose$
|
|
5771
|
-
const token = ++state$
|
|
5770
|
+
dispose$3(uid);
|
|
5771
|
+
const token = ++state$7.nextToken;
|
|
5772
5772
|
const timeout = setTimeout(run, autoSaveDelay, uid, token, save);
|
|
5773
5773
|
pendingSaves.set(uid, {
|
|
5774
5774
|
timeout,
|
|
@@ -5782,9 +5782,9 @@ const consume = (uid, token) => {
|
|
|
5782
5782
|
if (!isLatest(uid, token)) {
|
|
5783
5783
|
return;
|
|
5784
5784
|
}
|
|
5785
|
-
dispose$
|
|
5785
|
+
dispose$3(uid);
|
|
5786
5786
|
};
|
|
5787
|
-
const dispose$
|
|
5787
|
+
const dispose$3 = uid => {
|
|
5788
5788
|
const pendingSave = pendingSaves.get(uid);
|
|
5789
5789
|
if (!pendingSave) {
|
|
5790
5790
|
return;
|
|
@@ -5859,6 +5859,34 @@ const notifyEditorStatusCleared = async () => {
|
|
|
5859
5859
|
await Promise.all(getListeners(EditorSelection$1).map(rpcId => sendToListener(rpcId, undefined)));
|
|
5860
5860
|
};
|
|
5861
5861
|
|
|
5862
|
+
const launchRenameWorker = async () => {
|
|
5863
|
+
const name = 'Rename Worker';
|
|
5864
|
+
const url = 'renameWorkerMain.js';
|
|
5865
|
+
const rpc = await launchWorker(name, url);
|
|
5866
|
+
await rpc.invoke('Rename.initialize');
|
|
5867
|
+
return rpc;
|
|
5868
|
+
};
|
|
5869
|
+
|
|
5870
|
+
let workerPromise;
|
|
5871
|
+
const invoke$6 = async (method, ...params) => {
|
|
5872
|
+
// eslint-disable-next-line unicorn/no-top-level-assignment-in-function
|
|
5873
|
+
workerPromise ||= launchRenameWorker();
|
|
5874
|
+
const worker = await workerPromise;
|
|
5875
|
+
return await worker.invoke(method, ...params);
|
|
5876
|
+
};
|
|
5877
|
+
const dispose$2 = async () => {
|
|
5878
|
+
if (getKeys$2().length > 1) {
|
|
5879
|
+
return;
|
|
5880
|
+
}
|
|
5881
|
+
const promise = workerPromise;
|
|
5882
|
+
// eslint-disable-next-line unicorn/no-top-level-assignment-in-function
|
|
5883
|
+
workerPromise = undefined;
|
|
5884
|
+
try {
|
|
5885
|
+
// eslint-disable-next-line unicorn/prefer-await
|
|
5886
|
+
await promise?.then(worker => worker.dispose(), () => {});
|
|
5887
|
+
} catch {}
|
|
5888
|
+
};
|
|
5889
|
+
|
|
5862
5890
|
const addWidget$1 = widget => {
|
|
5863
5891
|
const module = get$7(widget.id);
|
|
5864
5892
|
if (!module) {
|
|
@@ -5950,8 +5978,9 @@ const disposeEditor = async editorUid => {
|
|
|
5950
5978
|
widgets: []
|
|
5951
5979
|
});
|
|
5952
5980
|
dispose$1(editorUid);
|
|
5953
|
-
dispose$
|
|
5954
|
-
dispose$
|
|
5981
|
+
dispose$3(editorUid);
|
|
5982
|
+
dispose$5(editorUid);
|
|
5983
|
+
await dispose$2();
|
|
5955
5984
|
if (getKeys$2().length === 0) {
|
|
5956
5985
|
await notifyEditorStatusCleared();
|
|
5957
5986
|
}
|
|
@@ -6225,7 +6254,7 @@ const isFormattingError = error => {
|
|
|
6225
6254
|
return error && error instanceof Error && error.message.startsWith(expectedErrorMessage$1);
|
|
6226
6255
|
};
|
|
6227
6256
|
|
|
6228
|
-
const state$
|
|
6257
|
+
const state$6 = {
|
|
6229
6258
|
configured: false,
|
|
6230
6259
|
lastId: -1,
|
|
6231
6260
|
nextId: 0
|
|
@@ -6233,23 +6262,23 @@ const state$7 = {
|
|
|
6233
6262
|
const configure = (start, end) => {
|
|
6234
6263
|
const {
|
|
6235
6264
|
configured
|
|
6236
|
-
} = state$
|
|
6265
|
+
} = state$6;
|
|
6237
6266
|
if (configured) {
|
|
6238
6267
|
throw new Error('Component id range is already configured');
|
|
6239
6268
|
}
|
|
6240
6269
|
if (!Number.isSafeInteger(start) || !Number.isSafeInteger(end) || start <= 0 || end < start) {
|
|
6241
6270
|
throw new Error('Invalid component id range');
|
|
6242
6271
|
}
|
|
6243
|
-
state$
|
|
6244
|
-
state$
|
|
6245
|
-
state$
|
|
6272
|
+
state$6.nextId = start;
|
|
6273
|
+
state$6.lastId = end;
|
|
6274
|
+
state$6.configured = true;
|
|
6246
6275
|
};
|
|
6247
6276
|
const create$8 = () => {
|
|
6248
6277
|
const {
|
|
6249
6278
|
configured,
|
|
6250
6279
|
lastId,
|
|
6251
6280
|
nextId
|
|
6252
|
-
} = state$
|
|
6281
|
+
} = state$6;
|
|
6253
6282
|
if (!configured) {
|
|
6254
6283
|
// Compatibility with renderer versions that do not assign worker id ranges.
|
|
6255
6284
|
return Math.random();
|
|
@@ -6257,7 +6286,7 @@ const create$8 = () => {
|
|
|
6257
6286
|
if (nextId > lastId) {
|
|
6258
6287
|
throw new Error('Component id range exhausted');
|
|
6259
6288
|
}
|
|
6260
|
-
return state$
|
|
6289
|
+
return state$6.nextId++;
|
|
6261
6290
|
};
|
|
6262
6291
|
|
|
6263
6292
|
const Message = 9;
|
|
@@ -6792,7 +6821,7 @@ const cancelSelection = editor => {
|
|
|
6792
6821
|
return scheduleSelections(editor, newSelections);
|
|
6793
6822
|
};
|
|
6794
6823
|
|
|
6795
|
-
const colorPattern
|
|
6824
|
+
const colorPattern = /#[\dA-Fa-f]+/g;
|
|
6796
6825
|
const numberPattern = /(?<![\w.#])[+-]?(?:(?:\d+(?:\.\d*)?)|(?:\.\d+))(?:[eE][+-]?\d+)?(?![\d.])/g;
|
|
6797
6826
|
const validColorLengths = new Set([4, 5, 7, 9]);
|
|
6798
6827
|
const isColor = value => {
|
|
@@ -6875,7 +6904,7 @@ const findMatchAt = (line, columnIndex, pattern, predicate) => {
|
|
|
6875
6904
|
return undefined;
|
|
6876
6905
|
};
|
|
6877
6906
|
const findValueAt = (line, columnIndex) => {
|
|
6878
|
-
return findMatchAt(line, columnIndex, colorPattern
|
|
6907
|
+
return findMatchAt(line, columnIndex, colorPattern, isColor) ?? findMatchAt(line, columnIndex, numberPattern, isNumber);
|
|
6879
6908
|
};
|
|
6880
6909
|
const getSelectionTarget = (editor, index) => {
|
|
6881
6910
|
const selectionStartRow = editor.selections[index];
|
|
@@ -7098,26 +7127,6 @@ const closeFind$1 = editor => {
|
|
|
7098
7127
|
};
|
|
7099
7128
|
};
|
|
7100
7129
|
|
|
7101
|
-
const launchRenameWorker = async () => {
|
|
7102
|
-
const name = 'Rename Worker';
|
|
7103
|
-
const url = 'renameWorkerMain.js';
|
|
7104
|
-
const rpc = await launchWorker(name, url);
|
|
7105
|
-
await rpc.invoke('Rename.initialize');
|
|
7106
|
-
return rpc;
|
|
7107
|
-
};
|
|
7108
|
-
|
|
7109
|
-
const state$6 = {};
|
|
7110
|
-
const getOrCreate$2 = () => {
|
|
7111
|
-
if (!state$6.workerPromise) {
|
|
7112
|
-
state$6.workerPromise = launchRenameWorker();
|
|
7113
|
-
}
|
|
7114
|
-
return state$6.workerPromise;
|
|
7115
|
-
};
|
|
7116
|
-
const invoke$6 = async (method, ...params) => {
|
|
7117
|
-
const worker = await getOrCreate$2();
|
|
7118
|
-
return await worker.invoke(method, ...params);
|
|
7119
|
-
};
|
|
7120
|
-
|
|
7121
7130
|
// TODO duplicate code
|
|
7122
7131
|
const isRenameWidget = widget => {
|
|
7123
7132
|
return widget.id === Rename$1;
|
|
@@ -7264,63 +7273,16 @@ const getColorPickerBounds = editor => {
|
|
|
7264
7273
|
};
|
|
7265
7274
|
};
|
|
7266
7275
|
|
|
7267
|
-
const noColorRange = {
|
|
7268
|
-
endOffset: -1,
|
|
7269
|
-
startOffset: -1,
|
|
7270
|
-
value: ''
|
|
7271
|
-
};
|
|
7272
|
-
const colorPattern = /#[\da-f]{3,8}\b|\b(?:hsla?|rgba?)\([^)]*\)/gi;
|
|
7273
|
-
const getColorPickerRange = editor => {
|
|
7274
|
-
const {
|
|
7275
|
-
lines,
|
|
7276
|
-
selections
|
|
7277
|
-
} = editor;
|
|
7278
|
-
if (!selections || selections.length < 4) {
|
|
7279
|
-
return noColorRange;
|
|
7280
|
-
}
|
|
7281
|
-
const selectionStartRow = selections[0];
|
|
7282
|
-
const selectionEndRow = selections[2];
|
|
7283
|
-
if (selectionStartRow !== selectionEndRow) {
|
|
7284
|
-
return noColorRange;
|
|
7285
|
-
}
|
|
7286
|
-
const selectionStartColumn = selections[1];
|
|
7287
|
-
const selectionEndColumn = selections[3];
|
|
7288
|
-
const rowIndex = selectionEndRow;
|
|
7289
|
-
const line = lines[rowIndex];
|
|
7290
|
-
if (typeof line !== 'string') {
|
|
7291
|
-
return noColorRange;
|
|
7292
|
-
}
|
|
7293
|
-
if (selectionStartColumn !== selectionEndColumn) {
|
|
7294
|
-
const startColumn = Math.min(selectionStartColumn, selectionEndColumn);
|
|
7295
|
-
const endColumn = Math.max(selectionStartColumn, selectionEndColumn);
|
|
7296
|
-
return {
|
|
7297
|
-
endOffset: offsetAt(editor, rowIndex, endColumn),
|
|
7298
|
-
startOffset: offsetAt(editor, rowIndex, startColumn),
|
|
7299
|
-
value: line.slice(startColumn, endColumn)
|
|
7300
|
-
};
|
|
7301
|
-
}
|
|
7302
|
-
const columnIndex = selectionEndColumn;
|
|
7303
|
-
for (const match of line.matchAll(colorPattern)) {
|
|
7304
|
-
const startColumn = match.index;
|
|
7305
|
-
const endColumn = startColumn + match[0].length;
|
|
7306
|
-
if (columnIndex >= startColumn && columnIndex <= endColumn) {
|
|
7307
|
-
return {
|
|
7308
|
-
endOffset: offsetAt(editor, rowIndex, endColumn),
|
|
7309
|
-
startOffset: offsetAt(editor, rowIndex, startColumn),
|
|
7310
|
-
value: match[0]
|
|
7311
|
-
};
|
|
7312
|
-
}
|
|
7313
|
-
}
|
|
7314
|
-
return noColorRange;
|
|
7315
|
-
};
|
|
7316
|
-
|
|
7317
7276
|
const newStateGenerator$5 = (state, parentUid) => {
|
|
7318
7277
|
return loadContent$3(state, parentUid);
|
|
7319
7278
|
};
|
|
7320
7279
|
const openColorPicker = async editor => {
|
|
7321
7280
|
const fullFocus = true;
|
|
7322
7281
|
const bounds = getColorPickerBounds(editor);
|
|
7323
|
-
const
|
|
7282
|
+
const {
|
|
7283
|
+
getColorPickerRange
|
|
7284
|
+
} = await import('./GetColorPickerRange-B84IlfRJ.js');
|
|
7285
|
+
const range = await getColorPickerRange(editor);
|
|
7324
7286
|
const createWidget = () => create$6(bounds, range, editor.undoStack.length);
|
|
7325
7287
|
return addWidgetToEditor(ColorPicker$2, ColorPicker, editor, createWidget, newStateGenerator$5, fullFocus);
|
|
7326
7288
|
};
|
|
@@ -10797,6 +10759,7 @@ const createFn = (key, name, widgetId) => {
|
|
|
10797
10759
|
const latestChildIndex = latestAfterInvoke.widgets.findIndex(isWidget);
|
|
10798
10760
|
if (latestChildIndex === -1) {
|
|
10799
10761
|
set$8(editor.uid, editor, latestAfterInvoke);
|
|
10762
|
+
await dispose$2();
|
|
10800
10763
|
return latestAfterInvoke;
|
|
10801
10764
|
}
|
|
10802
10765
|
const diff = await invoke(`${name}.diff2`, uid);
|
|
@@ -11092,8 +11055,15 @@ const openRename = async editor => {
|
|
|
11092
11055
|
return editor;
|
|
11093
11056
|
}
|
|
11094
11057
|
const fullFocus = true;
|
|
11095
|
-
|
|
11058
|
+
let editorWithRenameWidget;
|
|
11059
|
+
try {
|
|
11060
|
+
editorWithRenameWidget = await addWidgetToEditor(Rename$1, FocusEditorRename$1, editor, create$1, newStateGenerator$1, fullFocus);
|
|
11061
|
+
} catch (error) {
|
|
11062
|
+
await dispose$2();
|
|
11063
|
+
throw error;
|
|
11064
|
+
}
|
|
11096
11065
|
if (editorWithRenameWidget === editor) {
|
|
11066
|
+
await dispose$2();
|
|
11097
11067
|
return editor;
|
|
11098
11068
|
}
|
|
11099
11069
|
const wordBefore = getWordBefore(editor, rowIndex, columnIndex);
|
|
@@ -12116,7 +12086,7 @@ const getSnippetChanges = (lines, selections, snippet) => {
|
|
|
12116
12086
|
});
|
|
12117
12087
|
} else {
|
|
12118
12088
|
const inserted = line.replace('$0', '');
|
|
12119
|
-
const cursorColumnIndex =
|
|
12089
|
+
const cursorColumnIndex = selectionStartColumn - snippet.deleted + placeholderIndex;
|
|
12120
12090
|
selectionChanges.push(selectionStartRow, cursorColumnIndex, selectionStartRow, cursorColumnIndex);
|
|
12121
12091
|
changes.push({
|
|
12122
12092
|
deleted: [''],
|
|
@@ -16651,6 +16621,7 @@ const wrapCommand = (fn, preservesTypingCoalescing = false) => async (uid, ...ar
|
|
|
16651
16621
|
}
|
|
16652
16622
|
const newEditorWithDerivedState = await updateDerivedState(state, newEditor);
|
|
16653
16623
|
set$8(uid, state, newEditorWithDerivedState);
|
|
16624
|
+
await dispose$2();
|
|
16654
16625
|
if (editorDiagnosticEffect.isActive(state, newEditorWithDerivedState)) {
|
|
16655
16626
|
void editorDiagnosticEffect.apply(newEditorWithDerivedState);
|
|
16656
16627
|
}
|
|
@@ -16687,7 +16658,7 @@ const wrapCommand = (fn, preservesTypingCoalescing = false) => async (uid, ...ar
|
|
|
16687
16658
|
if (lines !== finalEditor.lines && !isUntitledFile(finalEditor.uri)) {
|
|
16688
16659
|
schedule(uid, token => saveAfterDelay(uid, token));
|
|
16689
16660
|
} else if (modified && !finalEditor.modified) {
|
|
16690
|
-
dispose$
|
|
16661
|
+
dispose$3(uid);
|
|
16691
16662
|
}
|
|
16692
16663
|
return finalEditor;
|
|
16693
16664
|
});
|
|
@@ -17442,3 +17413,5 @@ const main = async () => {
|
|
|
17442
17413
|
};
|
|
17443
17414
|
|
|
17444
17415
|
main();
|
|
17416
|
+
|
|
17417
|
+
export { offsetAt as o };
|