@lvce-editor/extension-management-worker 1.8.0 → 1.10.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.
|
@@ -14,9 +14,9 @@ const getCombinedMessage = (error, message) => {
|
|
|
14
14
|
}
|
|
15
15
|
return stringifiedError;
|
|
16
16
|
};
|
|
17
|
-
const NewLine$
|
|
17
|
+
const NewLine$3 = '\n';
|
|
18
18
|
const getNewLineIndex$1 = (string, startIndex = undefined) => {
|
|
19
|
-
return string.indexOf(NewLine$
|
|
19
|
+
return string.indexOf(NewLine$3, startIndex);
|
|
20
20
|
};
|
|
21
21
|
const mergeStacks = (parent, child) => {
|
|
22
22
|
if (!child) {
|
|
@@ -90,6 +90,12 @@ const getType = value => {
|
|
|
90
90
|
return Unknown;
|
|
91
91
|
}
|
|
92
92
|
};
|
|
93
|
+
const object = value => {
|
|
94
|
+
const type = getType(value);
|
|
95
|
+
if (type !== Object$1) {
|
|
96
|
+
throw new AssertionError('expected value to be of type object');
|
|
97
|
+
}
|
|
98
|
+
};
|
|
93
99
|
const string = value => {
|
|
94
100
|
const type = getType(value);
|
|
95
101
|
if (type !== String) {
|
|
@@ -170,9 +176,9 @@ class Ipc extends EventTarget {
|
|
|
170
176
|
const E_INCOMPATIBLE_NATIVE_MODULE = 'E_INCOMPATIBLE_NATIVE_MODULE';
|
|
171
177
|
const E_MODULES_NOT_SUPPORTED_IN_ELECTRON = 'E_MODULES_NOT_SUPPORTED_IN_ELECTRON';
|
|
172
178
|
const ERR_MODULE_NOT_FOUND = 'ERR_MODULE_NOT_FOUND';
|
|
173
|
-
const NewLine$
|
|
179
|
+
const NewLine$2 = '\n';
|
|
174
180
|
const joinLines$1 = lines => {
|
|
175
|
-
return lines.join(NewLine$
|
|
181
|
+
return lines.join(NewLine$2);
|
|
176
182
|
};
|
|
177
183
|
const RE_AT = /^\s+at/;
|
|
178
184
|
const RE_AT_PROMISE_INDEX = /^\s*at async Promise.all \(index \d+\)$/;
|
|
@@ -199,7 +205,7 @@ const getDetails = lines => {
|
|
|
199
205
|
};
|
|
200
206
|
};
|
|
201
207
|
const splitLines$1 = lines => {
|
|
202
|
-
return lines.split(NewLine$
|
|
208
|
+
return lines.split(NewLine$2);
|
|
203
209
|
};
|
|
204
210
|
const RE_MESSAGE_CODE_BLOCK_START = /^Error: The module '.*'$/;
|
|
205
211
|
const RE_MESSAGE_CODE_BLOCK_END = /^\s* at/;
|
|
@@ -578,10 +584,10 @@ const create$4$1 = (method, params) => {
|
|
|
578
584
|
};
|
|
579
585
|
};
|
|
580
586
|
const callbacks = Object.create(null);
|
|
581
|
-
const set$
|
|
587
|
+
const set$8 = (id, fn) => {
|
|
582
588
|
callbacks[id] = fn;
|
|
583
589
|
};
|
|
584
|
-
const get$
|
|
590
|
+
const get$4 = id => {
|
|
585
591
|
return callbacks[id];
|
|
586
592
|
};
|
|
587
593
|
const remove = id => {
|
|
@@ -597,7 +603,7 @@ const registerPromise = () => {
|
|
|
597
603
|
resolve,
|
|
598
604
|
promise
|
|
599
605
|
} = Promise.withResolvers();
|
|
600
|
-
set$
|
|
606
|
+
set$8(id, resolve);
|
|
601
607
|
return {
|
|
602
608
|
id,
|
|
603
609
|
promise
|
|
@@ -625,7 +631,7 @@ class JsonRpcError extends Error {
|
|
|
625
631
|
this.name = 'JsonRpcError';
|
|
626
632
|
}
|
|
627
633
|
}
|
|
628
|
-
const NewLine = '\n';
|
|
634
|
+
const NewLine$1 = '\n';
|
|
629
635
|
const DomException = 'DOMException';
|
|
630
636
|
const ReferenceError$1 = 'ReferenceError';
|
|
631
637
|
const SyntaxError$1 = 'SyntaxError';
|
|
@@ -671,10 +677,10 @@ const constructError = (message, type, name) => {
|
|
|
671
677
|
return new ErrorConstructor(message);
|
|
672
678
|
};
|
|
673
679
|
const joinLines = lines => {
|
|
674
|
-
return lines.join(NewLine);
|
|
680
|
+
return lines.join(NewLine$1);
|
|
675
681
|
};
|
|
676
682
|
const splitLines = lines => {
|
|
677
|
-
return lines.split(NewLine);
|
|
683
|
+
return lines.split(NewLine$1);
|
|
678
684
|
};
|
|
679
685
|
const getCurrentStack = () => {
|
|
680
686
|
const stackLinesToSkip = 3;
|
|
@@ -682,12 +688,12 @@ const getCurrentStack = () => {
|
|
|
682
688
|
return currentStack;
|
|
683
689
|
};
|
|
684
690
|
const getNewLineIndex = (string, startIndex = undefined) => {
|
|
685
|
-
return string.indexOf(NewLine, startIndex);
|
|
691
|
+
return string.indexOf(NewLine$1, startIndex);
|
|
686
692
|
};
|
|
687
693
|
const getParentStack = error => {
|
|
688
694
|
let parentStack = error.stack || error.data || error.message || '';
|
|
689
695
|
if (parentStack.startsWith(' at')) {
|
|
690
|
-
parentStack = error.message + NewLine + parentStack;
|
|
696
|
+
parentStack = error.message + NewLine$1 + parentStack;
|
|
691
697
|
}
|
|
692
698
|
return parentStack;
|
|
693
699
|
};
|
|
@@ -697,21 +703,21 @@ const restoreJsonRpcError = error => {
|
|
|
697
703
|
const currentStack = getCurrentStack();
|
|
698
704
|
if (error && error instanceof Error) {
|
|
699
705
|
if (typeof error.stack === 'string') {
|
|
700
|
-
error.stack = error.stack + NewLine + currentStack;
|
|
706
|
+
error.stack = error.stack + NewLine$1 + currentStack;
|
|
701
707
|
}
|
|
702
708
|
return error;
|
|
703
709
|
}
|
|
704
710
|
if (error && error.code && error.code === MethodNotFound) {
|
|
705
711
|
const restoredError = new JsonRpcError(error.message);
|
|
706
712
|
const parentStack = getParentStack(error);
|
|
707
|
-
restoredError.stack = parentStack + NewLine + currentStack;
|
|
713
|
+
restoredError.stack = parentStack + NewLine$1 + currentStack;
|
|
708
714
|
return restoredError;
|
|
709
715
|
}
|
|
710
716
|
if (error && error.message) {
|
|
711
717
|
const restoredError = constructError(error.message, error.type, error.name);
|
|
712
718
|
if (error.data) {
|
|
713
719
|
if (error.data.stack && error.data.type && error.message) {
|
|
714
|
-
restoredError.stack = error.data.type + ': ' + error.message + NewLine + error.data.stack + NewLine + currentStack;
|
|
720
|
+
restoredError.stack = error.data.type + ': ' + error.message + NewLine$1 + error.data.stack + NewLine$1 + currentStack;
|
|
715
721
|
} else if (error.data.stack) {
|
|
716
722
|
restoredError.stack = error.data.stack;
|
|
717
723
|
}
|
|
@@ -758,14 +764,14 @@ const unwrapJsonRpcResult = responseMessage => {
|
|
|
758
764
|
}
|
|
759
765
|
throw new JsonRpcError('unexpected response message');
|
|
760
766
|
};
|
|
761
|
-
const warn = (...args) => {
|
|
767
|
+
const warn$1 = (...args) => {
|
|
762
768
|
console.warn(...args);
|
|
763
769
|
};
|
|
764
770
|
const resolve = (id, response) => {
|
|
765
|
-
const fn = get$
|
|
771
|
+
const fn = get$4(id);
|
|
766
772
|
if (!fn) {
|
|
767
773
|
console.log(response);
|
|
768
|
-
warn(`callback ${id} may already be disposed`);
|
|
774
|
+
warn$1(`callback ${id} may already be disposed`);
|
|
769
775
|
return;
|
|
770
776
|
}
|
|
771
777
|
fn(response);
|
|
@@ -1133,45 +1139,45 @@ const RendererWorker = 1;
|
|
|
1133
1139
|
const SharedProcess = 1;
|
|
1134
1140
|
|
|
1135
1141
|
const rpcs = Object.create(null);
|
|
1136
|
-
const set$
|
|
1142
|
+
const set$7 = (id, rpc) => {
|
|
1137
1143
|
rpcs[id] = rpc;
|
|
1138
1144
|
};
|
|
1139
|
-
const get$
|
|
1145
|
+
const get$3 = id => {
|
|
1140
1146
|
return rpcs[id];
|
|
1141
1147
|
};
|
|
1142
1148
|
|
|
1143
1149
|
const create$1 = rpcId => {
|
|
1144
1150
|
return {
|
|
1145
1151
|
async dispose() {
|
|
1146
|
-
const rpc = get$
|
|
1152
|
+
const rpc = get$3(rpcId);
|
|
1147
1153
|
await rpc.dispose();
|
|
1148
1154
|
},
|
|
1149
1155
|
// @ts-ignore
|
|
1150
1156
|
invoke(method, ...params) {
|
|
1151
|
-
const rpc = get$
|
|
1157
|
+
const rpc = get$3(rpcId);
|
|
1152
1158
|
// @ts-ignore
|
|
1153
1159
|
return rpc.invoke(method, ...params);
|
|
1154
1160
|
},
|
|
1155
1161
|
// @ts-ignore
|
|
1156
1162
|
invokeAndTransfer(method, ...params) {
|
|
1157
|
-
const rpc = get$
|
|
1163
|
+
const rpc = get$3(rpcId);
|
|
1158
1164
|
// @ts-ignore
|
|
1159
1165
|
return rpc.invokeAndTransfer(method, ...params);
|
|
1160
1166
|
},
|
|
1161
1167
|
set(rpc) {
|
|
1162
|
-
set$
|
|
1168
|
+
set$7(rpcId, rpc);
|
|
1163
1169
|
}
|
|
1164
1170
|
};
|
|
1165
1171
|
};
|
|
1166
1172
|
|
|
1167
1173
|
const {
|
|
1168
1174
|
invoke: invoke$3,
|
|
1169
|
-
set: set$
|
|
1175
|
+
set: set$6
|
|
1170
1176
|
} = create$1(ExtensionHostWorker);
|
|
1171
1177
|
|
|
1172
1178
|
const {
|
|
1173
1179
|
invoke: invoke$2,
|
|
1174
|
-
set: set$
|
|
1180
|
+
set: set$5
|
|
1175
1181
|
} = create$1(FileSystemWorker);
|
|
1176
1182
|
const readFile = async uri => {
|
|
1177
1183
|
return invoke$2('FileSystem.readFile', uri);
|
|
@@ -1187,7 +1193,7 @@ const exists = async uri => {
|
|
|
1187
1193
|
const {
|
|
1188
1194
|
invoke: invoke$1,
|
|
1189
1195
|
invokeAndTransfer,
|
|
1190
|
-
set: set$
|
|
1196
|
+
set: set$4
|
|
1191
1197
|
} = create$1(RendererWorker);
|
|
1192
1198
|
const sendMessagePortToFileSystemWorker = async (port, rpcId) => {
|
|
1193
1199
|
const command = 'FileSystem.handleMessagePort';
|
|
@@ -1206,7 +1212,7 @@ const sendMessagePortToSharedProcess = async port => {
|
|
|
1206
1212
|
|
|
1207
1213
|
const {
|
|
1208
1214
|
invoke,
|
|
1209
|
-
set: set$
|
|
1215
|
+
set: set$3
|
|
1210
1216
|
} = create$1(SharedProcess);
|
|
1211
1217
|
|
|
1212
1218
|
const create = () => {
|
|
@@ -1252,10 +1258,10 @@ const isImportError = error => {
|
|
|
1252
1258
|
};
|
|
1253
1259
|
|
|
1254
1260
|
const states = Object.create(null);
|
|
1255
|
-
const set$
|
|
1261
|
+
const set$2 = status => {
|
|
1256
1262
|
states[status.id] = status;
|
|
1257
1263
|
};
|
|
1258
|
-
const get$
|
|
1264
|
+
const get$2 = extensionId => {
|
|
1259
1265
|
return states[extensionId];
|
|
1260
1266
|
};
|
|
1261
1267
|
const update$1 = (id, update) => {
|
|
@@ -1314,6 +1320,9 @@ const activate = async (extensionId, extension) => {
|
|
|
1314
1320
|
await invoke$3('ExtensionHost.activateExtension3', extensionId, extension);
|
|
1315
1321
|
};
|
|
1316
1322
|
const activateExtension2 = async (extensionId, extension, absolutePath) => {
|
|
1323
|
+
string(extensionId);
|
|
1324
|
+
object(extension);
|
|
1325
|
+
string(absolutePath);
|
|
1317
1326
|
const token = create();
|
|
1318
1327
|
try {
|
|
1319
1328
|
const startTime = performance.now();
|
|
@@ -1344,6 +1353,50 @@ const activateExtension2 = async (extensionId, extension, absolutePath) => {
|
|
|
1344
1353
|
}
|
|
1345
1354
|
};
|
|
1346
1355
|
|
|
1356
|
+
const importExtension = async (extensionId, absolutePath, activationEvent) => {
|
|
1357
|
+
try {
|
|
1358
|
+
string(absolutePath);
|
|
1359
|
+
const startTime = performance.now();
|
|
1360
|
+
set$2({
|
|
1361
|
+
activationEndTime: 0,
|
|
1362
|
+
activationEvent: activationEvent,
|
|
1363
|
+
activationStartTime: performance.now(),
|
|
1364
|
+
activationTime: 0,
|
|
1365
|
+
id: extensionId,
|
|
1366
|
+
importEndTime: 0,
|
|
1367
|
+
importStartTime: startTime,
|
|
1368
|
+
importTime: 0,
|
|
1369
|
+
status: Importing
|
|
1370
|
+
});
|
|
1371
|
+
try {
|
|
1372
|
+
await invoke$3('ExtensionHost.importExtension2', extensionId, absolutePath);
|
|
1373
|
+
const endTime = performance.now();
|
|
1374
|
+
const time = endTime - startTime;
|
|
1375
|
+
update$1(extensionId, {
|
|
1376
|
+
importEndTime: endTime,
|
|
1377
|
+
importTime: time
|
|
1378
|
+
});
|
|
1379
|
+
} catch (error) {
|
|
1380
|
+
update$1(extensionId, {
|
|
1381
|
+
status: Error$1 // TODO maybe store error also in runtime status state
|
|
1382
|
+
});
|
|
1383
|
+
if (isImportError(error)) {
|
|
1384
|
+
const actualErrorMessage = await tryToGetActualImportErrorMessage(absolutePath, error);
|
|
1385
|
+
throw new Error(actualErrorMessage);
|
|
1386
|
+
}
|
|
1387
|
+
throw error;
|
|
1388
|
+
}
|
|
1389
|
+
} catch (error) {
|
|
1390
|
+
throw new VError(error, `Failed to import extension ${extensionId}`);
|
|
1391
|
+
}
|
|
1392
|
+
};
|
|
1393
|
+
|
|
1394
|
+
const activateExtension3 = async (extension, absolutePath, activationEvent) => {
|
|
1395
|
+
const extensionId = extension.id;
|
|
1396
|
+
await importExtension(extensionId, absolutePath, activationEvent);
|
|
1397
|
+
await activateExtension2(extensionId, extension, absolutePath);
|
|
1398
|
+
};
|
|
1399
|
+
|
|
1347
1400
|
const cache = Object.create(null);
|
|
1348
1401
|
const id = 1;
|
|
1349
1402
|
const clear = () => {
|
|
@@ -1363,6 +1416,7 @@ const getJson = async url => {
|
|
|
1363
1416
|
}
|
|
1364
1417
|
};
|
|
1365
1418
|
|
|
1419
|
+
const NewLine = '\n';
|
|
1366
1420
|
const Slash = '/';
|
|
1367
1421
|
|
|
1368
1422
|
const interExtensionId = path => {
|
|
@@ -1404,7 +1458,7 @@ let state = {
|
|
|
1404
1458
|
disabledIds: [],
|
|
1405
1459
|
platform: 0
|
|
1406
1460
|
};
|
|
1407
|
-
const set = newState => {
|
|
1461
|
+
const set$1 = newState => {
|
|
1408
1462
|
state = newState;
|
|
1409
1463
|
};
|
|
1410
1464
|
const update = newState => {
|
|
@@ -1414,19 +1468,19 @@ const update = newState => {
|
|
|
1414
1468
|
};
|
|
1415
1469
|
state = fullNewState;
|
|
1416
1470
|
};
|
|
1417
|
-
const get = () => {
|
|
1471
|
+
const get$1 = () => {
|
|
1418
1472
|
return state;
|
|
1419
1473
|
};
|
|
1420
1474
|
|
|
1421
1475
|
const disableExtension = async (id, isTest) => {
|
|
1422
|
-
const oldState = get();
|
|
1476
|
+
const oldState = get$1();
|
|
1423
1477
|
try {
|
|
1424
1478
|
if (isTest) {
|
|
1425
1479
|
const newState = {
|
|
1426
1480
|
...oldState,
|
|
1427
1481
|
disabledIds: [...oldState.disabledIds, id]
|
|
1428
1482
|
};
|
|
1429
|
-
set(newState);
|
|
1483
|
+
set$1(newState);
|
|
1430
1484
|
} else {
|
|
1431
1485
|
await invoke('ExtensionManagement.disable', id);
|
|
1432
1486
|
}
|
|
@@ -1438,7 +1492,7 @@ const disableExtension = async (id, isTest) => {
|
|
|
1438
1492
|
};
|
|
1439
1493
|
|
|
1440
1494
|
const enableExtension = async (id, isTest) => {
|
|
1441
|
-
const oldState = get();
|
|
1495
|
+
const oldState = get$1();
|
|
1442
1496
|
const {
|
|
1443
1497
|
platform
|
|
1444
1498
|
} = oldState;
|
|
@@ -1463,11 +1517,151 @@ const enableExtension = async (id, isTest) => {
|
|
|
1463
1517
|
...oldState,
|
|
1464
1518
|
disabledIds: oldState.disabledIds.filter(existing => existing !== id)
|
|
1465
1519
|
};
|
|
1466
|
-
set(newState);
|
|
1520
|
+
set$1(newState);
|
|
1467
1521
|
}
|
|
1468
1522
|
return undefined;
|
|
1469
1523
|
};
|
|
1470
1524
|
|
|
1525
|
+
/* eslint-disable @typescript-eslint/prefer-readonly-parameter-types */
|
|
1526
|
+
const warn = (...args) => {
|
|
1527
|
+
console.warn(...args);
|
|
1528
|
+
};
|
|
1529
|
+
|
|
1530
|
+
const transparent = (color, factor) => {
|
|
1531
|
+
return color;
|
|
1532
|
+
};
|
|
1533
|
+
const toColorRule = ([key, value]) => {
|
|
1534
|
+
return ` --${key}: ${value};`;
|
|
1535
|
+
};
|
|
1536
|
+
const toTokenColorRule = tokenColor => {
|
|
1537
|
+
return `.${tokenColor.name} { color: ${tokenColor.foreground} }`;
|
|
1538
|
+
};
|
|
1539
|
+
const addFallbackColors = colors => {
|
|
1540
|
+
const newColors = {
|
|
1541
|
+
...colors
|
|
1542
|
+
};
|
|
1543
|
+
if (!newColors.ActivityBarInactiveForeground) {
|
|
1544
|
+
// TODO don't assign, avoid mutation
|
|
1545
|
+
newColors.ActivityBarInactiveForeground = transparent(newColors.ActivityBarForeground);
|
|
1546
|
+
}
|
|
1547
|
+
newColors.CssVariableName ||= colors.VariableName;
|
|
1548
|
+
return newColors;
|
|
1549
|
+
};
|
|
1550
|
+
const createColorThemeFromJson = (colorThemeId, colorThemeJson) => {
|
|
1551
|
+
if (!colorThemeJson) {
|
|
1552
|
+
warn(`color theme json for "${colorThemeId}" is empty: "${colorThemeJson}"`);
|
|
1553
|
+
return '';
|
|
1554
|
+
}
|
|
1555
|
+
if (typeof colorThemeJson !== 'object') {
|
|
1556
|
+
warn(`color theme json for "${colorThemeId}" cannot be converted to css: "${colorThemeJson}"`);
|
|
1557
|
+
return '';
|
|
1558
|
+
}
|
|
1559
|
+
if (Array.isArray(colorThemeJson)) {
|
|
1560
|
+
warn(`color theme json for "${colorThemeId}" cannot be converted to css, it must be of type object but was of type array`);
|
|
1561
|
+
return '';
|
|
1562
|
+
}
|
|
1563
|
+
const {
|
|
1564
|
+
colors
|
|
1565
|
+
} = colorThemeJson;
|
|
1566
|
+
if (!colors) {
|
|
1567
|
+
return '';
|
|
1568
|
+
}
|
|
1569
|
+
const newColors = addFallbackColors(colors);
|
|
1570
|
+
const colorRules = Object.entries(newColors).map(toColorRule);
|
|
1571
|
+
const tokenColors = colorThemeJson.tokenColors || [];
|
|
1572
|
+
const tokenColorRules = tokenColors.map(toTokenColorRule);
|
|
1573
|
+
const extraRules = [];
|
|
1574
|
+
if (colors.ContrastBorder) {
|
|
1575
|
+
extraRules.push(`#ActivityBar, #SideBar {
|
|
1576
|
+
border-left: 1px solid var(--ContrastBorder);
|
|
1577
|
+
}`, `#Panel {
|
|
1578
|
+
border-top: 1px solid var(--ContrastBorder);
|
|
1579
|
+
}`, `#StatusBar {
|
|
1580
|
+
border-top: 1px solid var(--ContrastBorder);
|
|
1581
|
+
}`, `.ActivityBarItemBadge {
|
|
1582
|
+
border: 1px solid var(--ContrastBorder);
|
|
1583
|
+
}`, `#QuickPick {
|
|
1584
|
+
border: 1px solid var(--ContrastBorder);
|
|
1585
|
+
}`);
|
|
1586
|
+
}
|
|
1587
|
+
const colorThemeCss = `:root {\n${colorRules.join(NewLine)}\n}\n\n${tokenColorRules.join(NewLine)}\n\n${extraRules.join(NewLine)}`;
|
|
1588
|
+
return colorThemeCss;
|
|
1589
|
+
};
|
|
1590
|
+
|
|
1591
|
+
// for (let i = 0; i < 10000; i++) {
|
|
1592
|
+
// createColorThemeFromJson({
|
|
1593
|
+
// type: 'dark',
|
|
1594
|
+
// colors: {
|
|
1595
|
+
// ActivityBarBackground: 'rgb(40, 46, 47)',
|
|
1596
|
+
// ActivityBarForeground: '#878f8c',
|
|
1597
|
+
// ActivityBarActiveBackground: '#1f2727',
|
|
1598
|
+
|
|
1599
|
+
// EditorBackGround: '#1e2324',
|
|
1600
|
+
// EditorScrollBarBackground: 'rgba(57, 71, 71, 0.6)',
|
|
1601
|
+
// EditorCursorBackground: '#a8df5a',
|
|
1602
|
+
|
|
1603
|
+
// ListActiveSelectionBackground: '#515f59',
|
|
1604
|
+
// ListActiveSelectionForeground: '#ffffff',
|
|
1605
|
+
// ListHoverBackground: '#405c5033',
|
|
1606
|
+
// ListHoverForeground: '#e0e0e0',
|
|
1607
|
+
// ListInactiveSelectionBackground: '#3b474280',
|
|
1608
|
+
|
|
1609
|
+
// MainBackground: '#1e2324',
|
|
1610
|
+
|
|
1611
|
+
// PanelBackground: '#1b2020',
|
|
1612
|
+
// PanelBorderTopColor: 'rgba(128, 128, 128, 0.35)',
|
|
1613
|
+
|
|
1614
|
+
// SideBarBackground: '#1b2020',
|
|
1615
|
+
|
|
1616
|
+
// StatusBarBackground: 'rgb(40, 46, 47)',
|
|
1617
|
+
// StatusBarBorderTopColor: '#222222',
|
|
1618
|
+
|
|
1619
|
+
// TabActiveBackground: '#24292a',
|
|
1620
|
+
// TabInactiveBackground: '#282e2f',
|
|
1621
|
+
|
|
1622
|
+
// TitleBarBackground: 'rgb(40, 46, 47)',
|
|
1623
|
+
// TitleBarBorderBottomColor: '#222',
|
|
1624
|
+
// TitleBarColor: '#cccccc',
|
|
1625
|
+
// TitleBarColorInactive: 'rgba(204, 204, 204, 0.6)',
|
|
1626
|
+
// },
|
|
1627
|
+
// }) //?.
|
|
1628
|
+
// }
|
|
1629
|
+
|
|
1630
|
+
const get = colorThemeId => {
|
|
1631
|
+
return '';
|
|
1632
|
+
};
|
|
1633
|
+
const set = (colorThemeId, data) => {
|
|
1634
|
+
// noop
|
|
1635
|
+
};
|
|
1636
|
+
|
|
1637
|
+
const GetColorThemeCssCachedNoop = {
|
|
1638
|
+
__proto__: null,
|
|
1639
|
+
get,
|
|
1640
|
+
set
|
|
1641
|
+
};
|
|
1642
|
+
|
|
1643
|
+
// TODO make storage configurable via settings as localstorage or indexeddb
|
|
1644
|
+
// also allow disabling caching via settings
|
|
1645
|
+
// then measure which option could be fastest
|
|
1646
|
+
|
|
1647
|
+
const getCacheFn = config => {
|
|
1648
|
+
switch (config) {
|
|
1649
|
+
default:
|
|
1650
|
+
return GetColorThemeCssCachedNoop;
|
|
1651
|
+
}
|
|
1652
|
+
};
|
|
1653
|
+
const getColorThemeCssCached = async (colorThemeId, platform, getData) => {
|
|
1654
|
+
const config = '';
|
|
1655
|
+
const module = getCacheFn(config);
|
|
1656
|
+
const cachedData = module.get(colorThemeId);
|
|
1657
|
+
if (cachedData) {
|
|
1658
|
+
return cachedData;
|
|
1659
|
+
}
|
|
1660
|
+
const newData = await getData(colorThemeId, platform);
|
|
1661
|
+
module.set(colorThemeId, newData);
|
|
1662
|
+
return newData;
|
|
1663
|
+
};
|
|
1664
|
+
|
|
1471
1665
|
const readJson = url => {
|
|
1472
1666
|
return invoke$1('FileSystem.readJson', url);
|
|
1473
1667
|
};
|
|
@@ -1493,7 +1687,7 @@ const getColorThemeUri = (extensions, colorThemeId) => {
|
|
|
1493
1687
|
};
|
|
1494
1688
|
|
|
1495
1689
|
const getAllExtensions = async () => {
|
|
1496
|
-
const state = get();
|
|
1690
|
+
const state = get$1();
|
|
1497
1691
|
if (state.platform === Web) {
|
|
1498
1692
|
return [];
|
|
1499
1693
|
}
|
|
@@ -1528,6 +1722,20 @@ const getColorThemeJson = (colorThemeId, platform) => {
|
|
|
1528
1722
|
return getColorThemeJson$2(colorThemeId);
|
|
1529
1723
|
};
|
|
1530
1724
|
|
|
1725
|
+
const getColorThemeCssFromJson = async (colorThemeId, colorThemeJson) => {
|
|
1726
|
+
const colorThemeCss = createColorThemeFromJson(/* colorThemeId */colorThemeId, /* colorThemeJson */colorThemeJson);
|
|
1727
|
+
return colorThemeCss;
|
|
1728
|
+
// TODO generate color theme from jsonc
|
|
1729
|
+
};
|
|
1730
|
+
const getColorThemeCssNew = async (colorThemeId, platform) => {
|
|
1731
|
+
const colorThemeJson = await getColorThemeJson(colorThemeId, platform);
|
|
1732
|
+
const colorThemeCss = await getColorThemeCssFromJson(colorThemeId, colorThemeJson);
|
|
1733
|
+
return colorThemeCss;
|
|
1734
|
+
};
|
|
1735
|
+
const getColorThemeCss = (colorThemeId, platform) => {
|
|
1736
|
+
return getColorThemeCssCached(colorThemeId, platform, getColorThemeCssNew);
|
|
1737
|
+
};
|
|
1738
|
+
|
|
1531
1739
|
const getExtensionColorThemeNames = extension => {
|
|
1532
1740
|
return extension.colorThemes || [];
|
|
1533
1741
|
};
|
|
@@ -1570,7 +1778,7 @@ const emptyStatus = {
|
|
|
1570
1778
|
status: None
|
|
1571
1779
|
};
|
|
1572
1780
|
const getRuntimeStatus = extensionId => {
|
|
1573
|
-
return get$
|
|
1781
|
+
return get$2(extensionId) || emptyStatus;
|
|
1574
1782
|
};
|
|
1575
1783
|
|
|
1576
1784
|
const commandMapRef = {};
|
|
@@ -1582,44 +1790,6 @@ const handleMessagePort = async port => {
|
|
|
1582
1790
|
});
|
|
1583
1791
|
};
|
|
1584
1792
|
|
|
1585
|
-
const importExtension = async (extensionId, absolutePath, activationEvent) => {
|
|
1586
|
-
try {
|
|
1587
|
-
string(absolutePath);
|
|
1588
|
-
const startTime = performance.now();
|
|
1589
|
-
set$1({
|
|
1590
|
-
activationEndTime: 0,
|
|
1591
|
-
activationEvent: activationEvent,
|
|
1592
|
-
activationStartTime: performance.now(),
|
|
1593
|
-
activationTime: 0,
|
|
1594
|
-
id: extensionId,
|
|
1595
|
-
importEndTime: 0,
|
|
1596
|
-
importStartTime: startTime,
|
|
1597
|
-
importTime: 0,
|
|
1598
|
-
status: Importing
|
|
1599
|
-
});
|
|
1600
|
-
try {
|
|
1601
|
-
await invoke$3('ExtneionHost.importExtension2', extensionId, absolutePath);
|
|
1602
|
-
const endTime = performance.now();
|
|
1603
|
-
const time = endTime - startTime;
|
|
1604
|
-
update$1(extensionId, {
|
|
1605
|
-
importEndTime: endTime,
|
|
1606
|
-
importTime: time
|
|
1607
|
-
});
|
|
1608
|
-
} catch (error) {
|
|
1609
|
-
update$1(extensionId, {
|
|
1610
|
-
status: Error$1 // TODO maybe store error also in runtime status state
|
|
1611
|
-
});
|
|
1612
|
-
if (isImportError(error)) {
|
|
1613
|
-
const actualErrorMessage = await tryToGetActualImportErrorMessage(absolutePath, error);
|
|
1614
|
-
throw new Error(actualErrorMessage);
|
|
1615
|
-
}
|
|
1616
|
-
throw error;
|
|
1617
|
-
}
|
|
1618
|
-
} catch (error) {
|
|
1619
|
-
throw new VError(error, `Failed to import extension ${extensionId}`);
|
|
1620
|
-
}
|
|
1621
|
-
};
|
|
1622
|
-
|
|
1623
1793
|
const initializeExtensionHostWorker = async () => {
|
|
1624
1794
|
const rpc = await TransferMessagePortRpcParent.create({
|
|
1625
1795
|
commandMap: commandMapRef,
|
|
@@ -1627,7 +1797,7 @@ const initializeExtensionHostWorker = async () => {
|
|
|
1627
1797
|
await sendMessagePortToExtensionHostWorker(port, 0);
|
|
1628
1798
|
}
|
|
1629
1799
|
});
|
|
1630
|
-
set$
|
|
1800
|
+
set$6(rpc);
|
|
1631
1801
|
};
|
|
1632
1802
|
|
|
1633
1803
|
const initializeFileSystemWorker = async () => {
|
|
@@ -1637,7 +1807,7 @@ const initializeFileSystemWorker = async () => {
|
|
|
1637
1807
|
await sendMessagePortToFileSystemWorker(port, 0);
|
|
1638
1808
|
}
|
|
1639
1809
|
});
|
|
1640
|
-
set$
|
|
1810
|
+
set$5(rpc);
|
|
1641
1811
|
};
|
|
1642
1812
|
|
|
1643
1813
|
const getRpc = async platform => {
|
|
@@ -1663,7 +1833,7 @@ const getRpc = async platform => {
|
|
|
1663
1833
|
const initializeSharedProcess = async platform => {
|
|
1664
1834
|
const rpc = await getRpc(platform);
|
|
1665
1835
|
if (rpc) {
|
|
1666
|
-
set$
|
|
1836
|
+
set$3(rpc);
|
|
1667
1837
|
}
|
|
1668
1838
|
};
|
|
1669
1839
|
|
|
@@ -1728,10 +1898,12 @@ const uninstallExtension = async () => {
|
|
|
1728
1898
|
|
|
1729
1899
|
const commandMap = {
|
|
1730
1900
|
'Extensions.activate2': activateExtension2,
|
|
1901
|
+
'Extensions.activate3': activateExtension3,
|
|
1731
1902
|
'Extensions.addWebExtension': addWebExtension,
|
|
1732
1903
|
'Extensions.disable': disableExtension,
|
|
1733
1904
|
'Extensions.enable': enableExtension,
|
|
1734
1905
|
'Extensions.getAllExtensions': getAllExtensions,
|
|
1906
|
+
'Extensions.getColorThemeCssFromJson': getColorThemeCss,
|
|
1735
1907
|
'Extensions.getColorThemeJson': getColorThemeJson,
|
|
1736
1908
|
'Extensions.getColorThemeNames': getColorThemeNames,
|
|
1737
1909
|
'Extensions.getExtension': getExtension,
|
|
@@ -1750,7 +1922,7 @@ const listen = async () => {
|
|
|
1750
1922
|
const rpc = await WebWorkerRpcClient.create({
|
|
1751
1923
|
commandMap: commandMap
|
|
1752
1924
|
});
|
|
1753
|
-
set$
|
|
1925
|
+
set$4(rpc);
|
|
1754
1926
|
};
|
|
1755
1927
|
|
|
1756
1928
|
const main = async () => {
|