@lvce-editor/text-search-worker 6.0.0 → 6.1.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.
- package/dist/textSearchWorkerMain.js +103 -68
- package/package.json +1 -1
|
@@ -788,7 +788,7 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
788
788
|
}
|
|
789
789
|
};
|
|
790
790
|
};
|
|
791
|
-
const create$1$
|
|
791
|
+
const create$1$1 = (id, error) => {
|
|
792
792
|
return {
|
|
793
793
|
jsonrpc: Two$1,
|
|
794
794
|
id,
|
|
@@ -799,9 +799,9 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
|
799
799
|
const prettyError = preparePrettyError(error);
|
|
800
800
|
logError(error, prettyError);
|
|
801
801
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
802
|
-
return create$1$
|
|
802
|
+
return create$1$1(id, errorProperty);
|
|
803
803
|
};
|
|
804
|
-
const create$
|
|
804
|
+
const create$4 = (message, result) => {
|
|
805
805
|
return {
|
|
806
806
|
jsonrpc: Two$1,
|
|
807
807
|
id: message.id,
|
|
@@ -810,7 +810,7 @@ const create$5 = (message, result) => {
|
|
|
810
810
|
};
|
|
811
811
|
const getSuccessResponse = (message, result) => {
|
|
812
812
|
const resultProperty = result ?? null;
|
|
813
|
-
return create$
|
|
813
|
+
return create$4(message, resultProperty);
|
|
814
814
|
};
|
|
815
815
|
const getErrorResponseSimple = (id, error) => {
|
|
816
816
|
return {
|
|
@@ -924,14 +924,14 @@ const execute = (command, ...args) => {
|
|
|
924
924
|
};
|
|
925
925
|
|
|
926
926
|
const Two = '2.0';
|
|
927
|
-
const create$
|
|
927
|
+
const create$t = (method, params) => {
|
|
928
928
|
return {
|
|
929
929
|
jsonrpc: Two,
|
|
930
930
|
method,
|
|
931
931
|
params
|
|
932
932
|
};
|
|
933
933
|
};
|
|
934
|
-
const create$
|
|
934
|
+
const create$s = (id, method, params) => {
|
|
935
935
|
const message = {
|
|
936
936
|
id,
|
|
937
937
|
jsonrpc: Two,
|
|
@@ -941,14 +941,14 @@ const create$r = (id, method, params) => {
|
|
|
941
941
|
return message;
|
|
942
942
|
};
|
|
943
943
|
let id = 0;
|
|
944
|
-
const create$
|
|
944
|
+
const create$r = () => {
|
|
945
945
|
return ++id;
|
|
946
946
|
};
|
|
947
947
|
|
|
948
948
|
/* eslint-disable n/no-unsupported-features/es-syntax */
|
|
949
949
|
|
|
950
950
|
const registerPromise = map => {
|
|
951
|
-
const id = create$
|
|
951
|
+
const id = create$r();
|
|
952
952
|
const {
|
|
953
953
|
promise,
|
|
954
954
|
resolve
|
|
@@ -966,7 +966,7 @@ const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer)
|
|
|
966
966
|
id,
|
|
967
967
|
promise
|
|
968
968
|
} = registerPromise(callbacks);
|
|
969
|
-
const message = create$
|
|
969
|
+
const message = create$s(id, method, params);
|
|
970
970
|
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
971
971
|
ipc.sendAndTransfer(message);
|
|
972
972
|
} else {
|
|
@@ -1002,7 +1002,7 @@ const createRpc = ipc => {
|
|
|
1002
1002
|
* @deprecated
|
|
1003
1003
|
*/
|
|
1004
1004
|
send(method, ...params) {
|
|
1005
|
-
const message = create$
|
|
1005
|
+
const message = create$t(method, params);
|
|
1006
1006
|
ipc.send(message);
|
|
1007
1007
|
}
|
|
1008
1008
|
};
|
|
@@ -1068,13 +1068,13 @@ const createSharedLazyRpc = factory => {
|
|
|
1068
1068
|
}
|
|
1069
1069
|
};
|
|
1070
1070
|
};
|
|
1071
|
-
const create$
|
|
1071
|
+
const create$j = async ({
|
|
1072
1072
|
commandMap,
|
|
1073
1073
|
isMessagePortOpen,
|
|
1074
1074
|
send
|
|
1075
1075
|
}) => {
|
|
1076
1076
|
return createSharedLazyRpc(() => {
|
|
1077
|
-
return create$
|
|
1077
|
+
return create$3$1({
|
|
1078
1078
|
commandMap,
|
|
1079
1079
|
isMessagePortOpen,
|
|
1080
1080
|
send
|
|
@@ -1083,7 +1083,7 @@ const create$i = async ({
|
|
|
1083
1083
|
};
|
|
1084
1084
|
const LazyTransferMessagePortRpcParent = {
|
|
1085
1085
|
__proto__: null,
|
|
1086
|
-
create: create$
|
|
1086
|
+
create: create$j
|
|
1087
1087
|
};
|
|
1088
1088
|
const Https = 'https:';
|
|
1089
1089
|
const Ws = 'ws:';
|
|
@@ -1101,7 +1101,7 @@ const getHost = () => {
|
|
|
1101
1101
|
const getProtocol$1 = () => {
|
|
1102
1102
|
return location.protocol;
|
|
1103
1103
|
};
|
|
1104
|
-
const create$
|
|
1104
|
+
const create$i = async ({
|
|
1105
1105
|
commandMap,
|
|
1106
1106
|
webSocket
|
|
1107
1107
|
}) => {
|
|
@@ -1115,7 +1115,7 @@ const create$h = async ({
|
|
|
1115
1115
|
const rpc = createRpc(ipc);
|
|
1116
1116
|
return rpc;
|
|
1117
1117
|
};
|
|
1118
|
-
const create$
|
|
1118
|
+
const create$h = async ({
|
|
1119
1119
|
commandMap,
|
|
1120
1120
|
type
|
|
1121
1121
|
}) => {
|
|
@@ -1123,18 +1123,18 @@ const create$g = async ({
|
|
|
1123
1123
|
const protocol = getProtocol$1();
|
|
1124
1124
|
const wsUrl = getWebSocketUrl(type, host, protocol);
|
|
1125
1125
|
const webSocket = new WebSocket(wsUrl);
|
|
1126
|
-
const rpc = await create$
|
|
1126
|
+
const rpc = await create$i({
|
|
1127
1127
|
commandMap,
|
|
1128
1128
|
webSocket
|
|
1129
1129
|
});
|
|
1130
1130
|
return rpc;
|
|
1131
1131
|
};
|
|
1132
|
-
const create$
|
|
1132
|
+
const create$g = async ({
|
|
1133
1133
|
commandMap,
|
|
1134
1134
|
type
|
|
1135
1135
|
}) => {
|
|
1136
1136
|
return createSharedLazyRpc(() => {
|
|
1137
|
-
return create$
|
|
1137
|
+
return create$h({
|
|
1138
1138
|
commandMap,
|
|
1139
1139
|
type
|
|
1140
1140
|
});
|
|
@@ -1142,9 +1142,9 @@ const create$f = async ({
|
|
|
1142
1142
|
};
|
|
1143
1143
|
const LazyWebSocketRpcParent2 = {
|
|
1144
1144
|
__proto__: null,
|
|
1145
|
-
create: create$
|
|
1145
|
+
create: create$g
|
|
1146
1146
|
};
|
|
1147
|
-
const create$
|
|
1147
|
+
const create$5 = async ({
|
|
1148
1148
|
commandMap,
|
|
1149
1149
|
isMessagePortOpen = true,
|
|
1150
1150
|
messagePort
|
|
@@ -1161,7 +1161,7 @@ const create$4 = async ({
|
|
|
1161
1161
|
messagePort.start();
|
|
1162
1162
|
return rpc;
|
|
1163
1163
|
};
|
|
1164
|
-
const create$
|
|
1164
|
+
const create$3$1 = async ({
|
|
1165
1165
|
commandMap,
|
|
1166
1166
|
isMessagePortOpen,
|
|
1167
1167
|
send
|
|
@@ -1171,7 +1171,7 @@ const create$2$1 = async ({
|
|
|
1171
1171
|
port2
|
|
1172
1172
|
} = new MessageChannel();
|
|
1173
1173
|
await send(port1);
|
|
1174
|
-
return create$
|
|
1174
|
+
return create$5({
|
|
1175
1175
|
commandMap,
|
|
1176
1176
|
isMessagePortOpen,
|
|
1177
1177
|
messagePort: port2
|
|
@@ -1179,9 +1179,9 @@ const create$2$1 = async ({
|
|
|
1179
1179
|
};
|
|
1180
1180
|
const TransferMessagePortRpcParent = {
|
|
1181
1181
|
__proto__: null,
|
|
1182
|
-
create: create$
|
|
1182
|
+
create: create$3$1
|
|
1183
1183
|
};
|
|
1184
|
-
const create$
|
|
1184
|
+
const create$2$1 = async ({
|
|
1185
1185
|
commandMap
|
|
1186
1186
|
}) => {
|
|
1187
1187
|
// TODO create a commandMap per rpc instance
|
|
@@ -1193,7 +1193,7 @@ const create$1$1 = async ({
|
|
|
1193
1193
|
};
|
|
1194
1194
|
const WebWorkerRpcClient = {
|
|
1195
1195
|
__proto__: null,
|
|
1196
|
-
create: create$
|
|
1196
|
+
create: create$2$1
|
|
1197
1197
|
};
|
|
1198
1198
|
const createMockRpc = ({
|
|
1199
1199
|
commandMap
|
|
@@ -1295,6 +1295,7 @@ const Ins = 20;
|
|
|
1295
1295
|
const Del = 21;
|
|
1296
1296
|
const H4 = 24;
|
|
1297
1297
|
const TextArea = 62;
|
|
1298
|
+
const Reference = 100;
|
|
1298
1299
|
|
|
1299
1300
|
const Button$1 = 'event.button';
|
|
1300
1301
|
const ClientX = 'event.clientX';
|
|
@@ -1415,12 +1416,10 @@ const showContextMenu2 = async (uid, menuId, x, y, args) => {
|
|
|
1415
1416
|
number(menuId);
|
|
1416
1417
|
number(x);
|
|
1417
1418
|
number(y);
|
|
1418
|
-
// @ts-ignore
|
|
1419
1419
|
await invoke$1('ContextMenu.show2', uid, menuId, x, y, args);
|
|
1420
1420
|
};
|
|
1421
1421
|
const sendMessagePortToIconThemeWorker = async (port, rpcId) => {
|
|
1422
1422
|
const command = 'IconTheme.handleMessagePort';
|
|
1423
|
-
// @ts-ignore
|
|
1424
1423
|
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToIconThemeWorker', port, command, rpcId);
|
|
1425
1424
|
};
|
|
1426
1425
|
const handleWorkspaceRefresh = async () => {
|
|
@@ -1449,42 +1448,68 @@ const create$2 = () => {
|
|
|
1449
1448
|
const states = Object.create(null);
|
|
1450
1449
|
const commandMapRef = {};
|
|
1451
1450
|
return {
|
|
1452
|
-
|
|
1453
|
-
|
|
1451
|
+
clear() {
|
|
1452
|
+
for (const key of Object.keys(states)) {
|
|
1453
|
+
delete states[key];
|
|
1454
|
+
}
|
|
1454
1455
|
},
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
};
|
|
1456
|
+
diff(uid, modules, numbers) {
|
|
1457
|
+
const {
|
|
1458
|
+
newState,
|
|
1459
|
+
oldState
|
|
1460
|
+
} = states[uid];
|
|
1461
|
+
const diffResult = [];
|
|
1462
|
+
for (let i = 0; i < modules.length; i++) {
|
|
1463
|
+
const fn = modules[i];
|
|
1464
|
+
if (!fn(oldState, newState)) {
|
|
1465
|
+
diffResult.push(numbers[i]);
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
return diffResult;
|
|
1460
1469
|
},
|
|
1461
1470
|
dispose(uid) {
|
|
1462
1471
|
delete states[uid];
|
|
1463
1472
|
},
|
|
1473
|
+
get(uid) {
|
|
1474
|
+
return states[uid];
|
|
1475
|
+
},
|
|
1476
|
+
getCommandIds() {
|
|
1477
|
+
const keys = Object.keys(commandMapRef);
|
|
1478
|
+
const ids = keys.map(toCommandId);
|
|
1479
|
+
return ids;
|
|
1480
|
+
},
|
|
1464
1481
|
getKeys() {
|
|
1465
1482
|
return Object.keys(states).map(key => {
|
|
1466
1483
|
return Number.parseInt(key);
|
|
1467
1484
|
});
|
|
1468
1485
|
},
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1486
|
+
registerCommands(commandMap) {
|
|
1487
|
+
Object.assign(commandMapRef, commandMap);
|
|
1488
|
+
},
|
|
1489
|
+
set(uid, oldState, newState) {
|
|
1490
|
+
states[uid] = {
|
|
1491
|
+
newState,
|
|
1492
|
+
oldState
|
|
1493
|
+
};
|
|
1473
1494
|
},
|
|
1474
1495
|
wrapCommand(fn) {
|
|
1475
1496
|
const wrapped = async (uid, ...args) => {
|
|
1476
1497
|
const {
|
|
1477
|
-
|
|
1478
|
-
|
|
1498
|
+
newState,
|
|
1499
|
+
oldState
|
|
1479
1500
|
} = states[uid];
|
|
1480
1501
|
const newerState = await fn(newState, ...args);
|
|
1481
1502
|
if (oldState === newerState || newState === newerState) {
|
|
1482
1503
|
return;
|
|
1483
1504
|
}
|
|
1484
|
-
const
|
|
1505
|
+
const latestOld = states[uid];
|
|
1506
|
+
const latestNew = {
|
|
1507
|
+
...latestOld.newState,
|
|
1508
|
+
...newerState
|
|
1509
|
+
};
|
|
1485
1510
|
states[uid] = {
|
|
1486
|
-
|
|
1487
|
-
|
|
1511
|
+
newState: latestNew,
|
|
1512
|
+
oldState: latestOld.oldState
|
|
1488
1513
|
};
|
|
1489
1514
|
};
|
|
1490
1515
|
return wrapped;
|
|
@@ -1497,28 +1522,6 @@ const create$2 = () => {
|
|
|
1497
1522
|
return fn(newState, ...args);
|
|
1498
1523
|
};
|
|
1499
1524
|
return wrapped;
|
|
1500
|
-
},
|
|
1501
|
-
diff(uid, modules, numbers) {
|
|
1502
|
-
const {
|
|
1503
|
-
oldState,
|
|
1504
|
-
newState
|
|
1505
|
-
} = states[uid];
|
|
1506
|
-
const diffResult = [];
|
|
1507
|
-
for (let i = 0; i < modules.length; i++) {
|
|
1508
|
-
const fn = modules[i];
|
|
1509
|
-
if (!fn(oldState, newState)) {
|
|
1510
|
-
diffResult.push(numbers[i]);
|
|
1511
|
-
}
|
|
1512
|
-
}
|
|
1513
|
-
return diffResult;
|
|
1514
|
-
},
|
|
1515
|
-
getCommandIds() {
|
|
1516
|
-
const keys = Object.keys(commandMapRef);
|
|
1517
|
-
const ids = keys.map(toCommandId);
|
|
1518
|
-
return ids;
|
|
1519
|
-
},
|
|
1520
|
-
registerCommands(commandMap) {
|
|
1521
|
-
Object.assign(commandMapRef, commandMap);
|
|
1522
1525
|
}
|
|
1523
1526
|
};
|
|
1524
1527
|
};
|
|
@@ -1547,6 +1550,7 @@ const NavigateChild = 7;
|
|
|
1547
1550
|
const NavigateParent = 8;
|
|
1548
1551
|
const RemoveChild = 9;
|
|
1549
1552
|
const NavigateSibling = 10;
|
|
1553
|
+
const SetReferenceNodeUid = 11;
|
|
1550
1554
|
|
|
1551
1555
|
const isKey = key => {
|
|
1552
1556
|
return key !== 'type' && key !== 'childCount';
|
|
@@ -1614,6 +1618,16 @@ const compareNodes = (oldNode, newNode) => {
|
|
|
1614
1618
|
if (oldNode.type !== newNode.type) {
|
|
1615
1619
|
return null;
|
|
1616
1620
|
}
|
|
1621
|
+
// Handle reference nodes - special handling for uid changes
|
|
1622
|
+
if (oldNode.type === Reference) {
|
|
1623
|
+
if (oldNode.uid !== newNode.uid) {
|
|
1624
|
+
patches.push({
|
|
1625
|
+
type: SetReferenceNodeUid,
|
|
1626
|
+
uid: newNode.uid
|
|
1627
|
+
});
|
|
1628
|
+
}
|
|
1629
|
+
return patches;
|
|
1630
|
+
}
|
|
1617
1631
|
// Handle text nodes
|
|
1618
1632
|
if (oldNode.type === Text && newNode.type === Text) {
|
|
1619
1633
|
if (oldNode.text !== newNode.text) {
|
|
@@ -2006,6 +2020,9 @@ const hasReplaceExpanded = flags => {
|
|
|
2006
2020
|
const hasDetailsExpanded = flags => {
|
|
2007
2021
|
return (flags & DetailsExpanded) === DetailsExpanded;
|
|
2008
2022
|
};
|
|
2023
|
+
const hasUseIgnoreFiles = flags => {
|
|
2024
|
+
return (flags & UseIgnoreFiles) === UseIgnoreFiles;
|
|
2025
|
+
};
|
|
2009
2026
|
|
|
2010
2027
|
const collapseDetails = state => {
|
|
2011
2028
|
const {
|
|
@@ -2047,6 +2064,9 @@ const copyPath$1 = async state => {
|
|
|
2047
2064
|
return state;
|
|
2048
2065
|
};
|
|
2049
2066
|
|
|
2067
|
+
const defaultExcludes = ['.git', 'node_modules'];
|
|
2068
|
+
defaultExcludes.join(',');
|
|
2069
|
+
|
|
2050
2070
|
const minimumSliderSize = 20;
|
|
2051
2071
|
|
|
2052
2072
|
const {
|
|
@@ -2105,11 +2125,12 @@ const create = (uid, x, y, width, height, workspacePath, assetDir, itemHeight, v
|
|
|
2105
2125
|
}),
|
|
2106
2126
|
assetDir,
|
|
2107
2127
|
collapsedPaths: [],
|
|
2128
|
+
defaultExcludes: defaultExcludes,
|
|
2108
2129
|
deltaY: 0,
|
|
2109
2130
|
excludeValue: '',
|
|
2110
2131
|
fileIconCache: {},
|
|
2111
2132
|
finalDeltaY: 0,
|
|
2112
|
-
flags:
|
|
2133
|
+
flags: UseIgnoreFiles,
|
|
2113
2134
|
focus: Empty,
|
|
2114
2135
|
focused: false,
|
|
2115
2136
|
focusedIndex: -1,
|
|
@@ -3119,6 +3140,7 @@ const handleUpdateFull = async (state, update) => {
|
|
|
3119
3140
|
results
|
|
3120
3141
|
} = await textSearch$6(root, value, {
|
|
3121
3142
|
assetDir,
|
|
3143
|
+
defaultExcludes: hasUseIgnoreFiles(flags) ? partialNewState.defaultExcludes : [],
|
|
3122
3144
|
exclude: excludeValue,
|
|
3123
3145
|
flags,
|
|
3124
3146
|
include: includeValue,
|
|
@@ -3177,12 +3199,20 @@ const handleUpdateFull = async (state, update) => {
|
|
|
3177
3199
|
};
|
|
3178
3200
|
|
|
3179
3201
|
const getRipGrepArgs = ({
|
|
3202
|
+
defaultExcludes,
|
|
3203
|
+
exclude,
|
|
3180
3204
|
isCaseSensitive,
|
|
3181
3205
|
searchString,
|
|
3182
3206
|
threads,
|
|
3183
3207
|
useRegularExpression
|
|
3184
3208
|
}) => {
|
|
3185
3209
|
const ripGrepArgs = ['--hidden', '--no-require-git', '--smart-case', '--stats', '--json', '--threads', `${threads}`];
|
|
3210
|
+
const excludePatternsFromValue = exclude ? exclude.split(',').map(part => part.trim()).filter(Boolean) : [];
|
|
3211
|
+
const excludePatternsFromDefaults = defaultExcludes?.filter(Boolean) || [];
|
|
3212
|
+
const uniqueExcludePatterns = [...new Set([...excludePatternsFromDefaults, ...excludePatternsFromValue])];
|
|
3213
|
+
for (const excludePattern of uniqueExcludePatterns) {
|
|
3214
|
+
ripGrepArgs.push('--glob', `!**/${excludePattern}/**`);
|
|
3215
|
+
}
|
|
3186
3216
|
if (isCaseSensitive) {
|
|
3187
3217
|
ripGrepArgs.push('--case-sensitive');
|
|
3188
3218
|
} else {
|
|
@@ -3284,6 +3314,7 @@ const handleUpdateIncremental = async (state, update) => {
|
|
|
3284
3314
|
// TODO await promise?
|
|
3285
3315
|
void textSearchIncremental(root, value, {
|
|
3286
3316
|
assetDir: assetDir,
|
|
3317
|
+
defaultExcludes: hasUseIgnoreFiles(flags) ? partialNewState.defaultExcludes : [],
|
|
3287
3318
|
exclude: excludeValue,
|
|
3288
3319
|
flags,
|
|
3289
3320
|
include: includeValue,
|
|
@@ -3542,6 +3573,7 @@ const toggleUseRegularExpression = state => {
|
|
|
3542
3573
|
};
|
|
3543
3574
|
|
|
3544
3575
|
const getClickHandler = name => {
|
|
3576
|
+
// TODO maybe add a click handler to each button instead
|
|
3545
3577
|
switch (name) {
|
|
3546
3578
|
case MatchCase:
|
|
3547
3579
|
return toggleMatchCase;
|
|
@@ -4510,7 +4542,7 @@ const getSavedFlags = savedState => {
|
|
|
4510
4542
|
if (savedState && typeof savedState === 'object' && 'flags' in savedState && typeof savedState.flags === 'number') {
|
|
4511
4543
|
return savedState.flags;
|
|
4512
4544
|
}
|
|
4513
|
-
return
|
|
4545
|
+
return UseIgnoreFiles;
|
|
4514
4546
|
};
|
|
4515
4547
|
const getSavedIncludeValue = savedState => {
|
|
4516
4548
|
if (savedState && typeof savedState === 'object' && 'includeValue' in savedState && typeof savedState.includeValue === 'string') {
|
|
@@ -5803,8 +5835,11 @@ const focusElement = (state, focusKey) => {
|
|
|
5803
5835
|
};
|
|
5804
5836
|
|
|
5805
5837
|
const handleFocusIn = async (state, key) => {
|
|
5838
|
+
const {
|
|
5839
|
+
focus
|
|
5840
|
+
} = state;
|
|
5806
5841
|
const focusKey = getSearchFocusKey(key);
|
|
5807
|
-
if (
|
|
5842
|
+
if (focus === focusKey) {
|
|
5808
5843
|
return state;
|
|
5809
5844
|
}
|
|
5810
5845
|
return {
|