@lvce-editor/renderer-process 14.1.0 → 14.3.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/rendererProcessMain.js +520 -504
- package/package.json +1 -1
|
@@ -590,6 +590,7 @@ const setProp = ($Element, key, value, eventMap, newEventMap) => {
|
|
|
590
590
|
case 'onPointerMove':
|
|
591
591
|
case 'onPointerOut':
|
|
592
592
|
case 'onPointerOver':
|
|
593
|
+
case 'onScroll':
|
|
593
594
|
case 'onWheel':
|
|
594
595
|
const eventName = key.slice(2).toLowerCase();
|
|
595
596
|
if (!eventMap || !value) {
|
|
@@ -1091,35 +1092,262 @@ const ReferencePort = 3;
|
|
|
1091
1092
|
const ModuleWorkerWithMessagePort = 4;
|
|
1092
1093
|
const Electron$1 = 5;
|
|
1093
1094
|
|
|
1094
|
-
const
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1095
|
+
const Message$2 = 'message';
|
|
1096
|
+
const Error$3 = 'error';
|
|
1097
|
+
|
|
1098
|
+
const withResolvers = () => {
|
|
1099
|
+
/**
|
|
1100
|
+
* @type {any}
|
|
1101
|
+
*/
|
|
1102
|
+
let _resolve;
|
|
1103
|
+
/**
|
|
1104
|
+
* @type {any}
|
|
1105
|
+
*/
|
|
1106
|
+
let _reject;
|
|
1107
|
+
const promise = new Promise((resolve, reject) => {
|
|
1108
|
+
_resolve = resolve;
|
|
1109
|
+
_reject = reject;
|
|
1110
|
+
});
|
|
1111
|
+
return {
|
|
1112
|
+
resolve: _resolve,
|
|
1113
|
+
reject: _reject,
|
|
1114
|
+
promise
|
|
1115
|
+
};
|
|
1116
|
+
};
|
|
1117
|
+
|
|
1118
|
+
const getFirstEvent$1 = (eventTarget, eventMap) => {
|
|
1119
|
+
const {
|
|
1120
|
+
resolve,
|
|
1121
|
+
promise
|
|
1122
|
+
} = withResolvers();
|
|
1123
|
+
const listenerMap = Object.create(null);
|
|
1124
|
+
const cleanup = value => {
|
|
1125
|
+
for (const event of Object.keys(eventMap)) {
|
|
1126
|
+
eventTarget.removeEventListener(event, listenerMap[event]);
|
|
1127
|
+
}
|
|
1128
|
+
resolve(value);
|
|
1129
|
+
};
|
|
1130
|
+
for (const [event, type] of Object.entries(eventMap)) {
|
|
1131
|
+
const listener = event => {
|
|
1132
|
+
cleanup({
|
|
1133
|
+
type,
|
|
1134
|
+
event
|
|
1135
|
+
});
|
|
1136
|
+
};
|
|
1137
|
+
eventTarget.addEventListener(event, listener);
|
|
1138
|
+
listenerMap[event] = listener;
|
|
1108
1139
|
}
|
|
1140
|
+
return promise;
|
|
1109
1141
|
};
|
|
1110
1142
|
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1143
|
+
/**
|
|
1144
|
+
*
|
|
1145
|
+
* @param {Worker} worker
|
|
1146
|
+
* @returns
|
|
1147
|
+
*/
|
|
1148
|
+
const getFirstWorkerEvent$1 = worker => {
|
|
1149
|
+
return getFirstEvent$1(worker, {
|
|
1150
|
+
message: Message$2,
|
|
1151
|
+
error: Error$3
|
|
1152
|
+
});
|
|
1114
1153
|
};
|
|
1115
|
-
|
|
1116
|
-
|
|
1154
|
+
|
|
1155
|
+
const transferrables$1 = [];
|
|
1156
|
+
if (typeof MessagePort !== 'undefined') {
|
|
1157
|
+
transferrables$1.push(MessagePort);
|
|
1158
|
+
}
|
|
1159
|
+
if (typeof OffscreenCanvas !== 'undefined') {
|
|
1160
|
+
transferrables$1.push(OffscreenCanvas);
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
const isTransferrable$1 = value => {
|
|
1164
|
+
for (const fn of transferrables$1) {
|
|
1165
|
+
if (value instanceof fn) {
|
|
1166
|
+
return true;
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
return false;
|
|
1117
1170
|
};
|
|
1118
|
-
|
|
1119
|
-
|
|
1171
|
+
|
|
1172
|
+
const walkValue$1 = (value, transferrables) => {
|
|
1173
|
+
if (!value) {
|
|
1174
|
+
return;
|
|
1175
|
+
}
|
|
1176
|
+
if (isTransferrable$1(value)) {
|
|
1177
|
+
transferrables.push(value);
|
|
1178
|
+
}
|
|
1179
|
+
if (Array.isArray(value)) {
|
|
1180
|
+
for (const item of value) {
|
|
1181
|
+
walkValue$1(item, transferrables);
|
|
1182
|
+
}
|
|
1183
|
+
return;
|
|
1184
|
+
}
|
|
1185
|
+
if (typeof value === 'object') {
|
|
1186
|
+
for (const property of Object.values(value)) {
|
|
1187
|
+
walkValue$1(property, transferrables);
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1120
1190
|
};
|
|
1121
|
-
|
|
1122
|
-
|
|
1191
|
+
|
|
1192
|
+
const getTransfer = value => {
|
|
1193
|
+
const transferrables = [];
|
|
1194
|
+
walkValue$1(value, transferrables);
|
|
1195
|
+
return transferrables;
|
|
1196
|
+
};
|
|
1197
|
+
|
|
1198
|
+
let IpcError$1 = class IpcError extends Error {
|
|
1199
|
+
constructor(message) {
|
|
1200
|
+
super(message);
|
|
1201
|
+
this.name = 'IpcError';
|
|
1202
|
+
}
|
|
1203
|
+
};
|
|
1204
|
+
|
|
1205
|
+
const isErrorEvent$1 = event => {
|
|
1206
|
+
return event instanceof ErrorEvent;
|
|
1207
|
+
};
|
|
1208
|
+
|
|
1209
|
+
const NewLine$3 = '\n';
|
|
1210
|
+
|
|
1211
|
+
const joinLines$2 = lines => {
|
|
1212
|
+
return lines.join(NewLine$3);
|
|
1213
|
+
};
|
|
1214
|
+
|
|
1215
|
+
const splitLines$2 = lines => {
|
|
1216
|
+
string(lines);
|
|
1217
|
+
return lines.split(NewLine$3);
|
|
1218
|
+
};
|
|
1219
|
+
|
|
1220
|
+
let WorkerError$1 = class WorkerError extends Error {
|
|
1221
|
+
constructor(event) {
|
|
1222
|
+
super(event.message);
|
|
1223
|
+
const stackLines = splitLines$2(this.stack);
|
|
1224
|
+
const relevantLines = stackLines.slice(1);
|
|
1225
|
+
const relevant = joinLines$2(relevantLines);
|
|
1226
|
+
this.stack = `${event.message}
|
|
1227
|
+
at Module (${event.filename}:${event.lineno}:${event.colno})
|
|
1228
|
+
${relevant}`;
|
|
1229
|
+
}
|
|
1230
|
+
};
|
|
1231
|
+
|
|
1232
|
+
const Module$1 = 'module';
|
|
1233
|
+
|
|
1234
|
+
const getWorkerDisplayName$1 = name => {
|
|
1235
|
+
if (name && name.endsWith('Worker')) {
|
|
1236
|
+
return name;
|
|
1237
|
+
}
|
|
1238
|
+
return `${name} worker`;
|
|
1239
|
+
};
|
|
1240
|
+
const create$H = async ({
|
|
1241
|
+
url,
|
|
1242
|
+
name
|
|
1243
|
+
}) => {
|
|
1244
|
+
const worker = new Worker(url, {
|
|
1245
|
+
type: Module$1,
|
|
1246
|
+
name
|
|
1247
|
+
});
|
|
1248
|
+
// @ts-expect-error
|
|
1249
|
+
const {
|
|
1250
|
+
type,
|
|
1251
|
+
event
|
|
1252
|
+
} = await getFirstWorkerEvent$1(worker);
|
|
1253
|
+
switch (type) {
|
|
1254
|
+
case Message$2:
|
|
1255
|
+
if (event.data !== 'ready') {
|
|
1256
|
+
throw new IpcError$1('unexpected first message from worker');
|
|
1257
|
+
}
|
|
1258
|
+
break;
|
|
1259
|
+
case Error$3:
|
|
1260
|
+
if (isErrorEvent$1(event)) {
|
|
1261
|
+
throw new WorkerError$1(event);
|
|
1262
|
+
}
|
|
1263
|
+
const displayName = getWorkerDisplayName$1(name);
|
|
1264
|
+
throw new IpcError$1(`Failed to start ${displayName}`);
|
|
1265
|
+
}
|
|
1266
|
+
return worker;
|
|
1267
|
+
};
|
|
1268
|
+
const getData$1 = event => {
|
|
1269
|
+
// TODO why are some events not instance of message event?
|
|
1270
|
+
if (event instanceof MessageEvent) {
|
|
1271
|
+
return event.data;
|
|
1272
|
+
}
|
|
1273
|
+
return event;
|
|
1274
|
+
};
|
|
1275
|
+
const wrap = worker => {
|
|
1276
|
+
let handleMessage;
|
|
1277
|
+
return {
|
|
1278
|
+
get onmessage() {
|
|
1279
|
+
return handleMessage;
|
|
1280
|
+
},
|
|
1281
|
+
set onmessage(listener) {
|
|
1282
|
+
if (listener) {
|
|
1283
|
+
handleMessage = event => {
|
|
1284
|
+
const data = getData$1(event);
|
|
1285
|
+
listener({
|
|
1286
|
+
data,
|
|
1287
|
+
target: this
|
|
1288
|
+
});
|
|
1289
|
+
};
|
|
1290
|
+
} else {
|
|
1291
|
+
handleMessage = null;
|
|
1292
|
+
}
|
|
1293
|
+
worker.onmessage = handleMessage;
|
|
1294
|
+
},
|
|
1295
|
+
send(message) {
|
|
1296
|
+
worker.postMessage(message);
|
|
1297
|
+
},
|
|
1298
|
+
sendAndTransfer(message) {
|
|
1299
|
+
const transfer = getTransfer(message);
|
|
1300
|
+
worker.postMessage(message, transfer);
|
|
1301
|
+
}
|
|
1302
|
+
};
|
|
1303
|
+
};
|
|
1304
|
+
|
|
1305
|
+
const IpcParentWithModuleWorker$2 = {
|
|
1306
|
+
__proto__: null,
|
|
1307
|
+
create: create$H,
|
|
1308
|
+
wrap
|
|
1309
|
+
};
|
|
1310
|
+
|
|
1311
|
+
const isMessagePort$1 = value => {
|
|
1312
|
+
return value instanceof MessagePort;
|
|
1313
|
+
};
|
|
1314
|
+
|
|
1315
|
+
const create$G = async ({
|
|
1316
|
+
url
|
|
1317
|
+
}) => {
|
|
1318
|
+
string(url);
|
|
1319
|
+
const portPromise = await new Promise(resolve => {
|
|
1320
|
+
globalThis.acceptPort = resolve;
|
|
1321
|
+
});
|
|
1322
|
+
await import(url);
|
|
1323
|
+
const port = await portPromise;
|
|
1324
|
+
delete globalThis.acceptPort;
|
|
1325
|
+
if (!port) {
|
|
1326
|
+
throw new IpcError$1('port must be defined');
|
|
1327
|
+
}
|
|
1328
|
+
if (!isMessagePort$1(port)) {
|
|
1329
|
+
throw new IpcError$1('port must be of type MessagePort');
|
|
1330
|
+
}
|
|
1331
|
+
return port;
|
|
1332
|
+
};
|
|
1333
|
+
|
|
1334
|
+
const IpcParentWithMessagePort$2 = {
|
|
1335
|
+
__proto__: null,
|
|
1336
|
+
create: create$G
|
|
1337
|
+
};
|
|
1338
|
+
|
|
1339
|
+
const create$F = async url => {
|
|
1340
|
+
const referencePort = await new Promise(resolve => {
|
|
1341
|
+
globalThis.acceptReferencePort = resolve;
|
|
1342
|
+
import(url);
|
|
1343
|
+
});
|
|
1344
|
+
delete globalThis.acceptReferencePort;
|
|
1345
|
+
return referencePort;
|
|
1346
|
+
};
|
|
1347
|
+
|
|
1348
|
+
const IpcParentWithReferencePort = {
|
|
1349
|
+
__proto__: null,
|
|
1350
|
+
create: create$F
|
|
1123
1351
|
};
|
|
1124
1352
|
|
|
1125
1353
|
const normalizeLine = line => {
|
|
@@ -1138,9 +1366,9 @@ const getCombinedMessage = (error, message) => {
|
|
|
1138
1366
|
}
|
|
1139
1367
|
return stringifiedError;
|
|
1140
1368
|
};
|
|
1141
|
-
const NewLine$
|
|
1369
|
+
const NewLine$2 = '\n';
|
|
1142
1370
|
const getNewLineIndex$1 = (string, startIndex = undefined) => {
|
|
1143
|
-
return string.indexOf(NewLine$
|
|
1371
|
+
return string.indexOf(NewLine$2, startIndex);
|
|
1144
1372
|
};
|
|
1145
1373
|
const mergeStacks$1 = (parent, child) => {
|
|
1146
1374
|
if (!child) {
|
|
@@ -1178,7 +1406,7 @@ let VError$1 = class VError extends Error {
|
|
|
1178
1406
|
}
|
|
1179
1407
|
};
|
|
1180
1408
|
|
|
1181
|
-
const isMessagePort
|
|
1409
|
+
const isMessagePort = value => {
|
|
1182
1410
|
return value && value instanceof MessagePort;
|
|
1183
1411
|
};
|
|
1184
1412
|
const isMessagePortMain = value => {
|
|
@@ -1193,16 +1421,16 @@ const isInstanceOf = (value, constructorName) => {
|
|
|
1193
1421
|
const isSocket = value => {
|
|
1194
1422
|
return isInstanceOf(value, 'Socket');
|
|
1195
1423
|
};
|
|
1196
|
-
const transferrables
|
|
1197
|
-
const isTransferrable
|
|
1198
|
-
for (const fn of transferrables
|
|
1424
|
+
const transferrables = [isMessagePort, isMessagePortMain, isOffscreenCanvas, isSocket];
|
|
1425
|
+
const isTransferrable = value => {
|
|
1426
|
+
for (const fn of transferrables) {
|
|
1199
1427
|
if (fn(value)) {
|
|
1200
1428
|
return true;
|
|
1201
1429
|
}
|
|
1202
1430
|
}
|
|
1203
1431
|
return false;
|
|
1204
1432
|
};
|
|
1205
|
-
const walkValue
|
|
1433
|
+
const walkValue = (value, transferrables, isTransferrable) => {
|
|
1206
1434
|
if (!value) {
|
|
1207
1435
|
return;
|
|
1208
1436
|
}
|
|
@@ -1212,20 +1440,20 @@ const walkValue$1 = (value, transferrables, isTransferrable) => {
|
|
|
1212
1440
|
}
|
|
1213
1441
|
if (Array.isArray(value)) {
|
|
1214
1442
|
for (const item of value) {
|
|
1215
|
-
walkValue
|
|
1443
|
+
walkValue(item, transferrables, isTransferrable);
|
|
1216
1444
|
}
|
|
1217
1445
|
return;
|
|
1218
1446
|
}
|
|
1219
1447
|
if (typeof value === 'object') {
|
|
1220
1448
|
for (const property of Object.values(value)) {
|
|
1221
|
-
walkValue
|
|
1449
|
+
walkValue(property, transferrables, isTransferrable);
|
|
1222
1450
|
}
|
|
1223
1451
|
return;
|
|
1224
1452
|
}
|
|
1225
1453
|
};
|
|
1226
1454
|
const getTransferrables = value => {
|
|
1227
1455
|
const transferrables = [];
|
|
1228
|
-
walkValue
|
|
1456
|
+
walkValue(value, transferrables, isTransferrable);
|
|
1229
1457
|
return transferrables;
|
|
1230
1458
|
};
|
|
1231
1459
|
const removeValues = (value, toRemove) => {
|
|
@@ -1287,9 +1515,9 @@ class Ipc extends EventTarget {
|
|
|
1287
1515
|
const E_INCOMPATIBLE_NATIVE_MODULE = 'E_INCOMPATIBLE_NATIVE_MODULE';
|
|
1288
1516
|
const E_MODULES_NOT_SUPPORTED_IN_ELECTRON = 'E_MODULES_NOT_SUPPORTED_IN_ELECTRON';
|
|
1289
1517
|
const ERR_MODULE_NOT_FOUND = 'ERR_MODULE_NOT_FOUND';
|
|
1290
|
-
const NewLine$
|
|
1291
|
-
const joinLines$
|
|
1292
|
-
return lines.join(NewLine$
|
|
1518
|
+
const NewLine$1 = '\n';
|
|
1519
|
+
const joinLines$1 = lines => {
|
|
1520
|
+
return lines.join(NewLine$1);
|
|
1293
1521
|
};
|
|
1294
1522
|
const RE_AT$1 = /^\s+at/;
|
|
1295
1523
|
const RE_AT_PROMISE_INDEX$1 = /^\s*at async Promise.all \(index \d+\)$/;
|
|
@@ -1300,7 +1528,7 @@ const getDetails$1 = lines => {
|
|
|
1300
1528
|
const index = lines.findIndex(isNormalStackLine$1);
|
|
1301
1529
|
if (index === -1) {
|
|
1302
1530
|
return {
|
|
1303
|
-
actualMessage: joinLines$
|
|
1531
|
+
actualMessage: joinLines$1(lines),
|
|
1304
1532
|
rest: []
|
|
1305
1533
|
};
|
|
1306
1534
|
}
|
|
@@ -1315,8 +1543,8 @@ const getDetails$1 = lines => {
|
|
|
1315
1543
|
rest: lines.slice(index, lastIndex)
|
|
1316
1544
|
};
|
|
1317
1545
|
};
|
|
1318
|
-
const splitLines$
|
|
1319
|
-
return lines.split(NewLine$
|
|
1546
|
+
const splitLines$1 = lines => {
|
|
1547
|
+
return lines.split(NewLine$1);
|
|
1320
1548
|
};
|
|
1321
1549
|
const RE_MESSAGE_CODE_BLOCK_START = /^Error: The module '.*'$/;
|
|
1322
1550
|
const RE_MESSAGE_CODE_BLOCK_END = /^\s* at/;
|
|
@@ -1327,7 +1555,7 @@ const isMessageCodeBlockEndIndex = line => {
|
|
|
1327
1555
|
return RE_MESSAGE_CODE_BLOCK_END.test(line);
|
|
1328
1556
|
};
|
|
1329
1557
|
const getMessageCodeBlock = stderr => {
|
|
1330
|
-
const lines = splitLines$
|
|
1558
|
+
const lines = splitLines$1(stderr);
|
|
1331
1559
|
const startIndex = lines.findIndex(isMessageCodeBlockStartIndex);
|
|
1332
1560
|
const endIndex = startIndex + lines.slice(startIndex).findIndex(isMessageCodeBlockEndIndex, startIndex);
|
|
1333
1561
|
const relevantLines = lines.slice(startIndex, endIndex);
|
|
@@ -1338,7 +1566,7 @@ const isModuleNotFoundMessage = line => {
|
|
|
1338
1566
|
return line.includes('[ERR_MODULE_NOT_FOUND]');
|
|
1339
1567
|
};
|
|
1340
1568
|
const getModuleNotFoundError = stderr => {
|
|
1341
|
-
const lines = splitLines$
|
|
1569
|
+
const lines = splitLines$1(stderr);
|
|
1342
1570
|
const messageIndex = lines.findIndex(isModuleNotFoundMessage);
|
|
1343
1571
|
const message = lines[messageIndex];
|
|
1344
1572
|
return {
|
|
@@ -1386,7 +1614,7 @@ const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
|
1386
1614
|
if (isModuleNotFoundError(stderr)) {
|
|
1387
1615
|
return getModuleNotFoundError(stderr);
|
|
1388
1616
|
}
|
|
1389
|
-
const lines = splitLines$
|
|
1617
|
+
const lines = splitLines$1(stderr);
|
|
1390
1618
|
const {
|
|
1391
1619
|
actualMessage,
|
|
1392
1620
|
rest
|
|
@@ -1397,7 +1625,7 @@ const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
|
1397
1625
|
stack: rest
|
|
1398
1626
|
};
|
|
1399
1627
|
};
|
|
1400
|
-
|
|
1628
|
+
class IpcError extends VError$1 {
|
|
1401
1629
|
// @ts-ignore
|
|
1402
1630
|
constructor(betterMessage, stdout = '', stderr = '') {
|
|
1403
1631
|
if (stdout || stderr) {
|
|
@@ -1422,7 +1650,7 @@ let IpcError$1 = class IpcError extends VError$1 {
|
|
|
1422
1650
|
// @ts-ignore
|
|
1423
1651
|
this.stderr = stderr;
|
|
1424
1652
|
}
|
|
1425
|
-
}
|
|
1653
|
+
}
|
|
1426
1654
|
const readyMessage = 'ready';
|
|
1427
1655
|
const getData$2 = event => {
|
|
1428
1656
|
return event.data;
|
|
@@ -1490,7 +1718,7 @@ const removeListener = (emitter, type, callback) => {
|
|
|
1490
1718
|
emitter.off(type, callback);
|
|
1491
1719
|
}
|
|
1492
1720
|
};
|
|
1493
|
-
const getFirstEvent
|
|
1721
|
+
const getFirstEvent = (eventEmitter, eventMap) => {
|
|
1494
1722
|
const {
|
|
1495
1723
|
resolve,
|
|
1496
1724
|
promise
|
|
@@ -1519,13 +1747,13 @@ const create$5$2 = async ({
|
|
|
1519
1747
|
messagePort,
|
|
1520
1748
|
isMessagePortOpen
|
|
1521
1749
|
}) => {
|
|
1522
|
-
if (!isMessagePort
|
|
1523
|
-
throw new IpcError
|
|
1750
|
+
if (!isMessagePort(messagePort)) {
|
|
1751
|
+
throw new IpcError('port must be of type MessagePort');
|
|
1524
1752
|
}
|
|
1525
1753
|
if (isMessagePortOpen) {
|
|
1526
1754
|
return messagePort;
|
|
1527
1755
|
}
|
|
1528
|
-
const eventPromise = getFirstEvent
|
|
1756
|
+
const eventPromise = getFirstEvent(messagePort, {
|
|
1529
1757
|
message: Message$1
|
|
1530
1758
|
});
|
|
1531
1759
|
messagePort.start();
|
|
@@ -1534,17 +1762,17 @@ const create$5$2 = async ({
|
|
|
1534
1762
|
event
|
|
1535
1763
|
} = await eventPromise;
|
|
1536
1764
|
if (type !== Message$1) {
|
|
1537
|
-
throw new IpcError
|
|
1765
|
+
throw new IpcError('Failed to wait for ipc message');
|
|
1538
1766
|
}
|
|
1539
1767
|
if (event.data !== readyMessage) {
|
|
1540
|
-
throw new IpcError
|
|
1768
|
+
throw new IpcError('unexpected first message');
|
|
1541
1769
|
}
|
|
1542
1770
|
return messagePort;
|
|
1543
1771
|
};
|
|
1544
1772
|
const signal$1 = messagePort => {
|
|
1545
1773
|
messagePort.start();
|
|
1546
1774
|
};
|
|
1547
|
-
|
|
1775
|
+
class IpcParentWithMessagePort extends Ipc {
|
|
1548
1776
|
getData = getData$2;
|
|
1549
1777
|
send(message) {
|
|
1550
1778
|
this._rawIpc.postMessage(message);
|
|
@@ -1560,28 +1788,28 @@ let IpcParentWithMessagePort$1 = class IpcParentWithMessagePort extends Ipc {
|
|
|
1560
1788
|
this._rawIpc.addEventListener('message', callback);
|
|
1561
1789
|
}
|
|
1562
1790
|
onClose(callback) {}
|
|
1563
|
-
}
|
|
1791
|
+
}
|
|
1564
1792
|
const wrap$5 = messagePort => {
|
|
1565
|
-
return new IpcParentWithMessagePort
|
|
1793
|
+
return new IpcParentWithMessagePort(messagePort);
|
|
1566
1794
|
};
|
|
1567
|
-
const IpcParentWithMessagePort$1
|
|
1795
|
+
const IpcParentWithMessagePort$1 = {
|
|
1568
1796
|
__proto__: null,
|
|
1569
1797
|
create: create$5$2,
|
|
1570
1798
|
signal: signal$1,
|
|
1571
1799
|
wrap: wrap$5
|
|
1572
1800
|
};
|
|
1573
|
-
const Message
|
|
1801
|
+
const Message = 'message';
|
|
1574
1802
|
const Error$1$1 = 'error';
|
|
1575
|
-
const getFirstWorkerEvent
|
|
1576
|
-
return getFirstEvent
|
|
1577
|
-
message: Message
|
|
1803
|
+
const getFirstWorkerEvent = worker => {
|
|
1804
|
+
return getFirstEvent(worker, {
|
|
1805
|
+
message: Message,
|
|
1578
1806
|
error: Error$1$1
|
|
1579
1807
|
});
|
|
1580
1808
|
};
|
|
1581
|
-
const isErrorEvent
|
|
1809
|
+
const isErrorEvent = event => {
|
|
1582
1810
|
return event instanceof ErrorEvent;
|
|
1583
1811
|
};
|
|
1584
|
-
const getWorkerDisplayName
|
|
1812
|
+
const getWorkerDisplayName = name => {
|
|
1585
1813
|
if (!name) {
|
|
1586
1814
|
return '<unknown> worker';
|
|
1587
1815
|
}
|
|
@@ -1593,42 +1821,42 @@ const getWorkerDisplayName$1 = name => {
|
|
|
1593
1821
|
const tryToGetActualErrorMessage = async ({
|
|
1594
1822
|
name
|
|
1595
1823
|
}) => {
|
|
1596
|
-
const displayName = getWorkerDisplayName
|
|
1824
|
+
const displayName = getWorkerDisplayName(name);
|
|
1597
1825
|
return `Failed to start ${displayName}: Worker Launch Error`;
|
|
1598
1826
|
};
|
|
1599
|
-
|
|
1827
|
+
class WorkerError extends Error {
|
|
1600
1828
|
constructor(event) {
|
|
1601
1829
|
super(event.message);
|
|
1602
|
-
const stackLines = splitLines$
|
|
1830
|
+
const stackLines = splitLines$1(this.stack || '');
|
|
1603
1831
|
const relevantLines = stackLines.slice(1);
|
|
1604
|
-
const relevant = joinLines$
|
|
1832
|
+
const relevant = joinLines$1(relevantLines);
|
|
1605
1833
|
this.stack = `${event.message}
|
|
1606
1834
|
at Module (${event.filename}:${event.lineno}:${event.colno})
|
|
1607
1835
|
${relevant}`;
|
|
1608
1836
|
}
|
|
1609
|
-
}
|
|
1610
|
-
const Module
|
|
1837
|
+
}
|
|
1838
|
+
const Module = 'module';
|
|
1611
1839
|
const create$4$3 = async ({
|
|
1612
1840
|
url,
|
|
1613
1841
|
name
|
|
1614
1842
|
}) => {
|
|
1615
1843
|
const worker = new Worker(url, {
|
|
1616
|
-
type: Module
|
|
1844
|
+
type: Module,
|
|
1617
1845
|
name
|
|
1618
1846
|
});
|
|
1619
1847
|
const {
|
|
1620
1848
|
type,
|
|
1621
1849
|
event
|
|
1622
|
-
} = await getFirstWorkerEvent
|
|
1850
|
+
} = await getFirstWorkerEvent(worker);
|
|
1623
1851
|
switch (type) {
|
|
1624
|
-
case Message
|
|
1852
|
+
case Message:
|
|
1625
1853
|
if (event.data !== readyMessage) {
|
|
1626
|
-
throw new IpcError
|
|
1854
|
+
throw new IpcError('unexpected first message from worker');
|
|
1627
1855
|
}
|
|
1628
1856
|
break;
|
|
1629
1857
|
case Error$1$1:
|
|
1630
|
-
if (isErrorEvent
|
|
1631
|
-
throw new WorkerError
|
|
1858
|
+
if (isErrorEvent(event)) {
|
|
1859
|
+
throw new WorkerError(event);
|
|
1632
1860
|
}
|
|
1633
1861
|
const actualErrorMessage = await tryToGetActualErrorMessage({
|
|
1634
1862
|
name
|
|
@@ -1637,16 +1865,16 @@ const create$4$3 = async ({
|
|
|
1637
1865
|
}
|
|
1638
1866
|
return worker;
|
|
1639
1867
|
};
|
|
1640
|
-
const getData
|
|
1868
|
+
const getData = event => {
|
|
1641
1869
|
// TODO why are some events not instance of message event?
|
|
1642
1870
|
if (event instanceof MessageEvent) {
|
|
1643
1871
|
return event.data;
|
|
1644
1872
|
}
|
|
1645
1873
|
return event;
|
|
1646
1874
|
};
|
|
1647
|
-
|
|
1875
|
+
class IpcParentWithModuleWorker extends Ipc {
|
|
1648
1876
|
getData(event) {
|
|
1649
|
-
return getData
|
|
1877
|
+
return getData(event);
|
|
1650
1878
|
}
|
|
1651
1879
|
send(message) {
|
|
1652
1880
|
this._rawIpc.postMessage(message);
|
|
@@ -1664,11 +1892,11 @@ let IpcParentWithModuleWorker$1 = class IpcParentWithModuleWorker extends Ipc {
|
|
|
1664
1892
|
onMessage(callback) {
|
|
1665
1893
|
this._rawIpc.addEventListener('message', callback);
|
|
1666
1894
|
}
|
|
1667
|
-
}
|
|
1895
|
+
}
|
|
1668
1896
|
const wrap$4 = worker => {
|
|
1669
|
-
return new IpcParentWithModuleWorker
|
|
1897
|
+
return new IpcParentWithModuleWorker(worker);
|
|
1670
1898
|
};
|
|
1671
|
-
const IpcParentWithModuleWorker$1
|
|
1899
|
+
const IpcParentWithModuleWorker$1 = {
|
|
1672
1900
|
__proto__: null,
|
|
1673
1901
|
create: create$4$3,
|
|
1674
1902
|
wrap: wrap$4
|
|
@@ -1683,13 +1911,13 @@ const create$4$2 = (method, params) => {
|
|
|
1683
1911
|
};
|
|
1684
1912
|
};
|
|
1685
1913
|
const callbacks = Object.create(null);
|
|
1686
|
-
const set$
|
|
1914
|
+
const set$8 = (id, fn) => {
|
|
1687
1915
|
callbacks[id] = fn;
|
|
1688
1916
|
};
|
|
1689
|
-
const get$
|
|
1917
|
+
const get$7 = id => {
|
|
1690
1918
|
return callbacks[id];
|
|
1691
1919
|
};
|
|
1692
|
-
const remove$
|
|
1920
|
+
const remove$3 = id => {
|
|
1693
1921
|
delete callbacks[id];
|
|
1694
1922
|
};
|
|
1695
1923
|
let id = 0;
|
|
@@ -1702,7 +1930,7 @@ const registerPromise = () => {
|
|
|
1702
1930
|
resolve,
|
|
1703
1931
|
promise
|
|
1704
1932
|
} = Promise.withResolvers();
|
|
1705
|
-
set$
|
|
1933
|
+
set$8(id, resolve);
|
|
1706
1934
|
return {
|
|
1707
1935
|
id,
|
|
1708
1936
|
promise
|
|
@@ -1730,7 +1958,7 @@ class JsonRpcError extends Error {
|
|
|
1730
1958
|
this.name = 'JsonRpcError';
|
|
1731
1959
|
}
|
|
1732
1960
|
}
|
|
1733
|
-
const NewLine
|
|
1961
|
+
const NewLine = '\n';
|
|
1734
1962
|
const DomException = 'DOMException';
|
|
1735
1963
|
const ReferenceError$1 = 'ReferenceError';
|
|
1736
1964
|
const SyntaxError$1 = 'SyntaxError';
|
|
@@ -1775,23 +2003,23 @@ const constructError = (message, type, name) => {
|
|
|
1775
2003
|
}
|
|
1776
2004
|
return new ErrorConstructor(message);
|
|
1777
2005
|
};
|
|
1778
|
-
const joinLines
|
|
1779
|
-
return lines.join(NewLine
|
|
2006
|
+
const joinLines = lines => {
|
|
2007
|
+
return lines.join(NewLine);
|
|
1780
2008
|
};
|
|
1781
|
-
const splitLines
|
|
1782
|
-
return lines.split(NewLine
|
|
2009
|
+
const splitLines = lines => {
|
|
2010
|
+
return lines.split(NewLine);
|
|
1783
2011
|
};
|
|
1784
2012
|
const getCurrentStack = () => {
|
|
1785
|
-
const currentStack = joinLines
|
|
2013
|
+
const currentStack = joinLines(splitLines(new Error().stack || '').slice(2));
|
|
1786
2014
|
return currentStack;
|
|
1787
2015
|
};
|
|
1788
2016
|
const getNewLineIndex = (string, startIndex = undefined) => {
|
|
1789
|
-
return string.indexOf(NewLine
|
|
2017
|
+
return string.indexOf(NewLine, startIndex);
|
|
1790
2018
|
};
|
|
1791
2019
|
const getParentStack = error => {
|
|
1792
2020
|
let parentStack = error.stack || error.data || error.message || '';
|
|
1793
2021
|
if (parentStack.startsWith(' at')) {
|
|
1794
|
-
parentStack = error.message + NewLine
|
|
2022
|
+
parentStack = error.message + NewLine + parentStack;
|
|
1795
2023
|
}
|
|
1796
2024
|
return parentStack;
|
|
1797
2025
|
};
|
|
@@ -1801,21 +2029,21 @@ const restoreJsonRpcError = error => {
|
|
|
1801
2029
|
const currentStack = getCurrentStack();
|
|
1802
2030
|
if (error && error instanceof Error) {
|
|
1803
2031
|
if (typeof error.stack === 'string') {
|
|
1804
|
-
error.stack = error.stack + NewLine
|
|
2032
|
+
error.stack = error.stack + NewLine + currentStack;
|
|
1805
2033
|
}
|
|
1806
2034
|
return error;
|
|
1807
2035
|
}
|
|
1808
2036
|
if (error && error.code && error.code === MethodNotFound) {
|
|
1809
2037
|
const restoredError = new JsonRpcError(error.message);
|
|
1810
2038
|
const parentStack = getParentStack(error);
|
|
1811
|
-
restoredError.stack = parentStack + NewLine
|
|
2039
|
+
restoredError.stack = parentStack + NewLine + currentStack;
|
|
1812
2040
|
return restoredError;
|
|
1813
2041
|
}
|
|
1814
2042
|
if (error && error.message) {
|
|
1815
2043
|
const restoredError = constructError(error.message, error.type, error.name);
|
|
1816
2044
|
if (error.data) {
|
|
1817
2045
|
if (error.data.stack && error.data.type && error.message) {
|
|
1818
|
-
restoredError.stack = error.data.type + ': ' + error.message + NewLine
|
|
2046
|
+
restoredError.stack = error.data.type + ': ' + error.message + NewLine + error.data.stack + NewLine + currentStack;
|
|
1819
2047
|
} else if (error.data.stack) {
|
|
1820
2048
|
restoredError.stack = error.data.stack;
|
|
1821
2049
|
}
|
|
@@ -1866,14 +2094,14 @@ const warn = (...args) => {
|
|
|
1866
2094
|
console.warn(...args);
|
|
1867
2095
|
};
|
|
1868
2096
|
const resolve = (id, response) => {
|
|
1869
|
-
const fn = get$
|
|
2097
|
+
const fn = get$7(id);
|
|
1870
2098
|
if (!fn) {
|
|
1871
2099
|
console.log(response);
|
|
1872
2100
|
warn(`callback ${id} may already be disposed`);
|
|
1873
2101
|
return;
|
|
1874
2102
|
}
|
|
1875
2103
|
fn(response);
|
|
1876
|
-
remove$
|
|
2104
|
+
remove$3(id);
|
|
1877
2105
|
};
|
|
1878
2106
|
const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
|
|
1879
2107
|
const getErrorType = prettyError => {
|
|
@@ -1929,7 +2157,7 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
|
1929
2157
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
1930
2158
|
return create$1$1(id, errorProperty);
|
|
1931
2159
|
};
|
|
1932
|
-
const create$
|
|
2160
|
+
const create$E = (message, result) => {
|
|
1933
2161
|
return {
|
|
1934
2162
|
jsonrpc: Two,
|
|
1935
2163
|
id: message.id,
|
|
@@ -1938,7 +2166,7 @@ const create$H = (message, result) => {
|
|
|
1938
2166
|
};
|
|
1939
2167
|
const getSuccessResponse = (message, result) => {
|
|
1940
2168
|
const resultProperty = result ?? null;
|
|
1941
|
-
return create$
|
|
2169
|
+
return create$E(message, resultProperty);
|
|
1942
2170
|
};
|
|
1943
2171
|
const getErrorResponseSimple = (id, error) => {
|
|
1944
2172
|
return {
|
|
@@ -2145,14 +2373,14 @@ const create$b$1 = async ({
|
|
|
2145
2373
|
}) => {
|
|
2146
2374
|
// TODO create a commandMap per rpc instance
|
|
2147
2375
|
register(commandMap);
|
|
2148
|
-
const worker = await IpcParentWithModuleWorker$1
|
|
2376
|
+
const worker = await IpcParentWithModuleWorker$1.create({
|
|
2149
2377
|
url,
|
|
2150
2378
|
name
|
|
2151
2379
|
});
|
|
2152
2380
|
if (!isWorker(worker)) {
|
|
2153
2381
|
throw new Error(`worker must be of type Worker`);
|
|
2154
2382
|
}
|
|
2155
|
-
const ipc = IpcParentWithModuleWorker$1
|
|
2383
|
+
const ipc = IpcParentWithModuleWorker$1.wrap(worker);
|
|
2156
2384
|
handleIpc(ipc);
|
|
2157
2385
|
const workerRpc = createRpc(ipc);
|
|
2158
2386
|
return workerRpc;
|
|
@@ -2169,14 +2397,14 @@ const create$a$1 = async ({
|
|
|
2169
2397
|
}) => {
|
|
2170
2398
|
// TODO create a commandMap per rpc instance
|
|
2171
2399
|
register(commandMap);
|
|
2172
|
-
const worker = await IpcParentWithModuleWorker$1
|
|
2400
|
+
const worker = await IpcParentWithModuleWorker$1.create({
|
|
2173
2401
|
url,
|
|
2174
2402
|
name
|
|
2175
2403
|
});
|
|
2176
2404
|
if (!isWorker(worker)) {
|
|
2177
2405
|
throw new Error(`worker must be of type Worker`);
|
|
2178
2406
|
}
|
|
2179
|
-
const ipc = IpcParentWithModuleWorker$1
|
|
2407
|
+
const ipc = IpcParentWithModuleWorker$1.wrap(worker);
|
|
2180
2408
|
handleIpc(ipc);
|
|
2181
2409
|
const workerRpc = createRpc(ipc);
|
|
2182
2410
|
await workerRpc.invokeAndTransfer('initialize', 'message-port', port);
|
|
@@ -2193,11 +2421,11 @@ const create$5$1 = async ({
|
|
|
2193
2421
|
}) => {
|
|
2194
2422
|
// TODO create a commandMap per rpc instance
|
|
2195
2423
|
register(commandMap);
|
|
2196
|
-
const rawIpc = await IpcParentWithMessagePort$1
|
|
2424
|
+
const rawIpc = await IpcParentWithMessagePort$1.create({
|
|
2197
2425
|
messagePort,
|
|
2198
2426
|
isMessagePortOpen: true
|
|
2199
2427
|
});
|
|
2200
|
-
const ipc = IpcParentWithMessagePort$1
|
|
2428
|
+
const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
|
|
2201
2429
|
handleIpc(ipc);
|
|
2202
2430
|
const rpc = createRpc(ipc);
|
|
2203
2431
|
messagePort.start();
|
|
@@ -2217,18 +2445,24 @@ const PlainMessagePortRpcParent = {
|
|
|
2217
2445
|
create: create$4$1
|
|
2218
2446
|
};
|
|
2219
2447
|
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2448
|
+
// TODO add test
|
|
2449
|
+
const create$D = async ({
|
|
2450
|
+
url,
|
|
2223
2451
|
name,
|
|
2224
|
-
|
|
2452
|
+
port
|
|
2225
2453
|
}) => {
|
|
2226
|
-
|
|
2454
|
+
await ModuleWorkerWithMessagePortRpcParent.create({
|
|
2227
2455
|
url,
|
|
2228
2456
|
name,
|
|
2229
|
-
commandMap:
|
|
2457
|
+
commandMap: {},
|
|
2458
|
+
port
|
|
2230
2459
|
});
|
|
2231
|
-
return
|
|
2460
|
+
return undefined;
|
|
2461
|
+
};
|
|
2462
|
+
|
|
2463
|
+
const IpcParentWithModuleWorkerWithMessagePort = {
|
|
2464
|
+
__proto__: null,
|
|
2465
|
+
create: create$D
|
|
2232
2466
|
};
|
|
2233
2467
|
|
|
2234
2468
|
const Web = 1;
|
|
@@ -2258,6 +2492,75 @@ const getPlatform = () => {
|
|
|
2258
2492
|
};
|
|
2259
2493
|
const platform = getPlatform();
|
|
2260
2494
|
|
|
2495
|
+
const isElectron = platform === Electron;
|
|
2496
|
+
|
|
2497
|
+
// TODO use handleIncomingIpc function
|
|
2498
|
+
const create$C = async ({
|
|
2499
|
+
port,
|
|
2500
|
+
ipcId
|
|
2501
|
+
}) => {
|
|
2502
|
+
number(ipcId);
|
|
2503
|
+
if (!isElectron) {
|
|
2504
|
+
throw new Error('Electron api was requested but is not available');
|
|
2505
|
+
}
|
|
2506
|
+
const rpc = await ElectronWindowRpcClient.create({
|
|
2507
|
+
commandMap: {},
|
|
2508
|
+
window
|
|
2509
|
+
});
|
|
2510
|
+
const webContentsIds = await rpc.invokeAndTransfer('CreateMessagePort.createMessagePort', ipcId, port);
|
|
2511
|
+
return webContentsIds;
|
|
2512
|
+
};
|
|
2513
|
+
|
|
2514
|
+
const IpcParentWithElectron = {
|
|
2515
|
+
__proto__: null,
|
|
2516
|
+
create: create$C
|
|
2517
|
+
};
|
|
2518
|
+
|
|
2519
|
+
const getModule = method => {
|
|
2520
|
+
switch (method) {
|
|
2521
|
+
case ModuleWorker:
|
|
2522
|
+
return IpcParentWithModuleWorker$2;
|
|
2523
|
+
case MessagePort$1:
|
|
2524
|
+
return IpcParentWithMessagePort$2;
|
|
2525
|
+
case ReferencePort:
|
|
2526
|
+
return IpcParentWithReferencePort;
|
|
2527
|
+
case ModuleWorkerWithMessagePort:
|
|
2528
|
+
return IpcParentWithModuleWorkerWithMessagePort;
|
|
2529
|
+
case Electron$1:
|
|
2530
|
+
return IpcParentWithElectron;
|
|
2531
|
+
default:
|
|
2532
|
+
throw new Error('unexpected ipc type');
|
|
2533
|
+
}
|
|
2534
|
+
};
|
|
2535
|
+
|
|
2536
|
+
const ipcs = Object.create(null);
|
|
2537
|
+
const set$7 = (name, ipc) => {
|
|
2538
|
+
ipcs[name] = ipc;
|
|
2539
|
+
};
|
|
2540
|
+
const get$6 = name => {
|
|
2541
|
+
return ipcs[name];
|
|
2542
|
+
};
|
|
2543
|
+
const remove$2 = name => {
|
|
2544
|
+
delete ipcs[name];
|
|
2545
|
+
};
|
|
2546
|
+
const has = name => {
|
|
2547
|
+
return ipcs[name];
|
|
2548
|
+
};
|
|
2549
|
+
|
|
2550
|
+
const commandMapRef = {};
|
|
2551
|
+
|
|
2552
|
+
const launchWorker = async ({
|
|
2553
|
+
name,
|
|
2554
|
+
url
|
|
2555
|
+
}) => {
|
|
2556
|
+
const rpc = await ModuleWorkerRpcParent.create({
|
|
2557
|
+
url,
|
|
2558
|
+
name,
|
|
2559
|
+
commandMap: commandMapRef
|
|
2560
|
+
});
|
|
2561
|
+
return rpc;
|
|
2562
|
+
};
|
|
2563
|
+
|
|
2261
2564
|
const getAssetDir = () => {
|
|
2262
2565
|
// @ts-expect-error
|
|
2263
2566
|
if (typeof ASSET_DIR !== 'undefined') {
|
|
@@ -2335,7 +2638,7 @@ const RendererWorker = {
|
|
|
2335
2638
|
state: state$7
|
|
2336
2639
|
};
|
|
2337
2640
|
|
|
2338
|
-
const create$
|
|
2641
|
+
const create$B = async ({
|
|
2339
2642
|
method,
|
|
2340
2643
|
...options
|
|
2341
2644
|
}) => {
|
|
@@ -2345,8 +2648,8 @@ const create$G = async ({
|
|
|
2345
2648
|
}
|
|
2346
2649
|
// TODO rename method
|
|
2347
2650
|
// TODO avoid cyclic dependency
|
|
2348
|
-
const port = get$
|
|
2349
|
-
remove$
|
|
2651
|
+
const port = get$6(options.name);
|
|
2652
|
+
remove$2(options.name);
|
|
2350
2653
|
await invokeAndTransfer('Transferrable.transfer', options.id, port);
|
|
2351
2654
|
return;
|
|
2352
2655
|
}
|
|
@@ -2452,7 +2755,7 @@ const create$Notification = message => {
|
|
|
2452
2755
|
$Notification.textContent = message;
|
|
2453
2756
|
return $Notification;
|
|
2454
2757
|
};
|
|
2455
|
-
const create$
|
|
2758
|
+
const create$A = (type, message) => {
|
|
2456
2759
|
// TODO this pattern might be also useful for activitybar, sidebar etc., creating elements as late as possible, only when actually needed
|
|
2457
2760
|
const $Notification = create$Notification(message);
|
|
2458
2761
|
append$1($Notification);
|
|
@@ -2514,7 +2817,7 @@ const set$6 = (canvasId, canvas) => {
|
|
|
2514
2817
|
const get$4 = id => {
|
|
2515
2818
|
return get$5(id);
|
|
2516
2819
|
};
|
|
2517
|
-
const create$
|
|
2820
|
+
const create$z = async (canvasId, objectId) => {
|
|
2518
2821
|
const canvas = document.createElement('canvas');
|
|
2519
2822
|
const offscreenCanvas = canvas.transferControlToOffscreen();
|
|
2520
2823
|
set$6(canvasId, canvas);
|
|
@@ -2568,7 +2871,7 @@ const DragLeave = 'dragleave';
|
|
|
2568
2871
|
const DragOver = 'dragover';
|
|
2569
2872
|
const DragStart = 'dragstart';
|
|
2570
2873
|
const Drop = 'drop';
|
|
2571
|
-
const Error$
|
|
2874
|
+
const Error$2 = 'error';
|
|
2572
2875
|
const Focus = 'focus';
|
|
2573
2876
|
const FocusIn = 'focusin';
|
|
2574
2877
|
const FocusOut = 'focusout';
|
|
@@ -3718,7 +4021,7 @@ const showError = (message, y, x) => {
|
|
|
3718
4021
|
$ImagePreviewImage
|
|
3719
4022
|
};
|
|
3720
4023
|
};
|
|
3721
|
-
const create$
|
|
4024
|
+
const create$y = (uri, top, left) => {
|
|
3722
4025
|
const $ImagePreviewImage = document.createElement('img');
|
|
3723
4026
|
$ImagePreviewImage.className = 'ImagePreviewImage';
|
|
3724
4027
|
$ImagePreviewImage.src = uri;
|
|
@@ -3749,7 +4052,7 @@ const dispose$i = state => {
|
|
|
3749
4052
|
|
|
3750
4053
|
const ImagePreview$1 = {
|
|
3751
4054
|
__proto__: null,
|
|
3752
|
-
create: create$
|
|
4055
|
+
create: create$y,
|
|
3753
4056
|
dispose: dispose$i,
|
|
3754
4057
|
showError,
|
|
3755
4058
|
update
|
|
@@ -3974,7 +4277,7 @@ const ViewletAudio = {
|
|
|
3974
4277
|
Events: Events$4
|
|
3975
4278
|
};
|
|
3976
4279
|
|
|
3977
|
-
const create$
|
|
4280
|
+
const create$x = () => {
|
|
3978
4281
|
const $Viewlet = document.createElement('div');
|
|
3979
4282
|
$Viewlet.className = 'Viewlet Clock';
|
|
3980
4283
|
return {
|
|
@@ -3991,7 +4294,7 @@ const setTime = (state, time) => {
|
|
|
3991
4294
|
|
|
3992
4295
|
const ViewletClock = {
|
|
3993
4296
|
__proto__: null,
|
|
3994
|
-
create: create$
|
|
4297
|
+
create: create$x,
|
|
3995
4298
|
dispose: dispose$h,
|
|
3996
4299
|
refresh: refresh$4,
|
|
3997
4300
|
setTime
|
|
@@ -4020,7 +4323,7 @@ const stopTracking$1 = ($Target, pointerId, handlePointerMove, handlePointerUp)
|
|
|
4020
4323
|
// TODO use pointerlost event instead
|
|
4021
4324
|
$Target.removeEventListener(PointerUp, handlePointerUp);
|
|
4022
4325
|
};
|
|
4023
|
-
const create$
|
|
4326
|
+
const create$w = (pointerDown, pointerMove, pointerUp) => {
|
|
4024
4327
|
const shared = (fn, event) => {
|
|
4025
4328
|
const message = fn(event);
|
|
4026
4329
|
if (!message || message.length === 0) {
|
|
@@ -4053,7 +4356,7 @@ const create$B = (pointerDown, pointerMove, pointerUp) => {
|
|
|
4053
4356
|
};
|
|
4054
4357
|
|
|
4055
4358
|
const handleOffset = 20;
|
|
4056
|
-
const handleSliderPointerDown = create$
|
|
4359
|
+
const handleSliderPointerDown = create$w(event => {
|
|
4057
4360
|
const {
|
|
4058
4361
|
clientX,
|
|
4059
4362
|
clientY
|
|
@@ -4135,7 +4438,7 @@ const ViewletDebugConsoleEvents = {
|
|
|
4135
4438
|
handleInput: handleInput$6
|
|
4136
4439
|
};
|
|
4137
4440
|
|
|
4138
|
-
const create$
|
|
4441
|
+
const create$v = () => {
|
|
4139
4442
|
const $Viewlet = document.createElement('div');
|
|
4140
4443
|
$Viewlet.className = 'Viewlet DebugConsole';
|
|
4141
4444
|
return {
|
|
@@ -4151,7 +4454,7 @@ const setDom$9 = (state, dom) => {
|
|
|
4151
4454
|
|
|
4152
4455
|
const ViewletDebugConsole = {
|
|
4153
4456
|
__proto__: null,
|
|
4154
|
-
create: create$
|
|
4457
|
+
create: create$v,
|
|
4155
4458
|
setDom: setDom$9
|
|
4156
4459
|
};
|
|
4157
4460
|
|
|
@@ -4212,7 +4515,7 @@ const setMaskImage = ($Element, icon) => {
|
|
|
4212
4515
|
}
|
|
4213
4516
|
};
|
|
4214
4517
|
|
|
4215
|
-
const create$
|
|
4518
|
+
const create$u = icon => {
|
|
4216
4519
|
const $Icon = document.createElement('div');
|
|
4217
4520
|
$Icon.className = 'MaskIcon';
|
|
4218
4521
|
setMaskImage($Icon, icon);
|
|
@@ -4222,7 +4525,7 @@ const create$z = icon => {
|
|
|
4222
4525
|
|
|
4223
4526
|
const create$Button = (label, icon) => {
|
|
4224
4527
|
// TODO icon div might not be needed (unnecessary html element)
|
|
4225
|
-
const $Icon = create$
|
|
4528
|
+
const $Icon = create$u(icon);
|
|
4226
4529
|
const $Button = document.createElement('button');
|
|
4227
4530
|
$Button.className = 'IconButton';
|
|
4228
4531
|
$Button.title = label;
|
|
@@ -4243,7 +4546,7 @@ const handleClick$4 = event => {
|
|
|
4243
4546
|
handleClick$5(index);
|
|
4244
4547
|
};
|
|
4245
4548
|
|
|
4246
|
-
const create$
|
|
4549
|
+
const create$t = () => {
|
|
4247
4550
|
const $DialogTitle = document.createElement('h2');
|
|
4248
4551
|
$DialogTitle.id = 'DialogTitle';
|
|
4249
4552
|
const $DialogCloseButton = create$Button('Close', 'Close');
|
|
@@ -4324,7 +4627,7 @@ const setErrorStack = (state, errorStack) => {
|
|
|
4324
4627
|
|
|
4325
4628
|
const ViewletDialog = {
|
|
4326
4629
|
__proto__: null,
|
|
4327
|
-
create: create$
|
|
4630
|
+
create: create$t,
|
|
4328
4631
|
postAppend,
|
|
4329
4632
|
setButtons,
|
|
4330
4633
|
setCodeFrame,
|
|
@@ -4387,7 +4690,7 @@ const handleContextMenu$8 = event => {
|
|
|
4387
4690
|
} = event;
|
|
4388
4691
|
return ['handleContextMenu', button, clientX, clientY];
|
|
4389
4692
|
};
|
|
4390
|
-
const handleSashCornerPointerDown = create$
|
|
4693
|
+
const handleSashCornerPointerDown = create$w(event => {
|
|
4391
4694
|
const {
|
|
4392
4695
|
clientX,
|
|
4393
4696
|
clientY
|
|
@@ -4736,7 +5039,7 @@ const setNegativeMargin = (state, negativeMargin) => {
|
|
|
4736
5039
|
setTop($ListItems, negativeMargin);
|
|
4737
5040
|
};
|
|
4738
5041
|
|
|
4739
|
-
const create$
|
|
5042
|
+
const create$s = () => {
|
|
4740
5043
|
const $ListItems = document.createElement('div');
|
|
4741
5044
|
$ListItems.className = 'ListItems';
|
|
4742
5045
|
$ListItems.role = ListBox;
|
|
@@ -4820,7 +5123,7 @@ const setBounds$8 = (state, x, y, width, height) => {
|
|
|
4820
5123
|
const ViewletEditorCompletion = {
|
|
4821
5124
|
__proto__: null,
|
|
4822
5125
|
attachEvents: attachEvents$9,
|
|
4823
|
-
create: create$
|
|
5126
|
+
create: create$s,
|
|
4824
5127
|
dispose: dispose$f,
|
|
4825
5128
|
handleError: handleError$7,
|
|
4826
5129
|
setBounds: setBounds$8,
|
|
@@ -4843,7 +5146,7 @@ const ViewletEditorCompletionDetailsEvents = {
|
|
|
4843
5146
|
returnValue: returnValue$5
|
|
4844
5147
|
};
|
|
4845
5148
|
|
|
4846
|
-
const create$
|
|
5149
|
+
const create$r = () => {
|
|
4847
5150
|
const $Viewlet = document.createElement('div');
|
|
4848
5151
|
$Viewlet.className = 'Viewlet EditorCompletionDetails';
|
|
4849
5152
|
$Viewlet.id = 'CompletionsDetails';
|
|
@@ -4884,7 +5187,7 @@ const ViewletEditorCompletionDetails = {
|
|
|
4884
5187
|
Events: ViewletEditorCompletionDetailsEvents,
|
|
4885
5188
|
appendWidget: appendWidget$4,
|
|
4886
5189
|
attachEvents: attachEvents$8,
|
|
4887
|
-
create: create$
|
|
5190
|
+
create: create$r,
|
|
4888
5191
|
dispose: dispose$e,
|
|
4889
5192
|
setBounds: setBounds$7,
|
|
4890
5193
|
setDom: setDom$7
|
|
@@ -4903,7 +5206,7 @@ const ViewletEditorCompletionDetails = {
|
|
|
4903
5206
|
|
|
4904
5207
|
// TODO aria alert
|
|
4905
5208
|
|
|
4906
|
-
const create$
|
|
5209
|
+
const create$q = () => {
|
|
4907
5210
|
const $Viewlet = document.createElement('div');
|
|
4908
5211
|
$Viewlet.className = 'Viewlet EditorError';
|
|
4909
5212
|
return {
|
|
@@ -4925,13 +5228,13 @@ const setBounds$6 = (state, x, y, width, height) => {
|
|
|
4925
5228
|
|
|
4926
5229
|
const ViewletEditorError = {
|
|
4927
5230
|
__proto__: null,
|
|
4928
|
-
create: create$
|
|
5231
|
+
create: create$q,
|
|
4929
5232
|
setBounds: setBounds$6,
|
|
4930
5233
|
setDom: setDom$6
|
|
4931
5234
|
};
|
|
4932
5235
|
|
|
4933
5236
|
const returnValue$4 = true;
|
|
4934
|
-
const handleSashPointerDown$2 = create$
|
|
5237
|
+
const handleSashPointerDown$2 = create$w(event => {
|
|
4935
5238
|
const {
|
|
4936
5239
|
clientX,
|
|
4937
5240
|
clientY
|
|
@@ -5084,7 +5387,7 @@ const handleFocus$7 = event => {
|
|
|
5084
5387
|
handleFocus$9(uid);
|
|
5085
5388
|
};
|
|
5086
5389
|
|
|
5087
|
-
const create$
|
|
5390
|
+
const create$p = () => {
|
|
5088
5391
|
const $Viewlet = document.createElement('div');
|
|
5089
5392
|
$Viewlet.className = 'Viewlet EditorImage';
|
|
5090
5393
|
return {
|
|
@@ -5101,7 +5404,7 @@ const attachEvents$7 = state => {
|
|
|
5101
5404
|
[ContextMenu]: handleContextMenu$6,
|
|
5102
5405
|
[FocusIn]: handleFocus$7
|
|
5103
5406
|
});
|
|
5104
|
-
$Viewlet.addEventListener(Error$
|
|
5407
|
+
$Viewlet.addEventListener(Error$2, handleError$6, Capture);
|
|
5105
5408
|
$Viewlet.addEventListener(Wheel, handleWheel$1, Passive);
|
|
5106
5409
|
};
|
|
5107
5410
|
const setTransform = (state, transform) => {
|
|
@@ -5127,13 +5430,13 @@ const setDom$4 = (state, dom) => {
|
|
|
5127
5430
|
const ViewletEditorImage = {
|
|
5128
5431
|
__proto__: null,
|
|
5129
5432
|
attachEvents: attachEvents$7,
|
|
5130
|
-
create: create$
|
|
5433
|
+
create: create$p,
|
|
5131
5434
|
setDom: setDom$4,
|
|
5132
5435
|
setDragging,
|
|
5133
5436
|
setTransform
|
|
5134
5437
|
};
|
|
5135
5438
|
|
|
5136
|
-
const create$
|
|
5439
|
+
const create$o = () => {
|
|
5137
5440
|
const $Viewlet = document.createElement('div');
|
|
5138
5441
|
$Viewlet.className = 'Viewlet EditorText';
|
|
5139
5442
|
$Viewlet.textContent = 'loading...';
|
|
@@ -5150,7 +5453,7 @@ const refresh$3 = (state, context) => {
|
|
|
5150
5453
|
|
|
5151
5454
|
const ViewletEditorPlainText = {
|
|
5152
5455
|
__proto__: null,
|
|
5153
|
-
create: create$
|
|
5456
|
+
create: create$o,
|
|
5154
5457
|
dispose: dispose$d,
|
|
5155
5458
|
refresh: refresh$3
|
|
5156
5459
|
};
|
|
@@ -5444,7 +5747,7 @@ const handlePaste = event => {
|
|
|
5444
5747
|
const text = getText(clipboardData);
|
|
5445
5748
|
return ['paste', text];
|
|
5446
5749
|
};
|
|
5447
|
-
const handleScrollBarVerticalPointerDown = create$
|
|
5750
|
+
const handleScrollBarVerticalPointerDown = create$w(event => {
|
|
5448
5751
|
const {
|
|
5449
5752
|
clientY
|
|
5450
5753
|
} = event;
|
|
@@ -5567,7 +5870,7 @@ const setLineInfos = (state, dom) => {
|
|
|
5567
5870
|
// 1. create -> only create dom elements
|
|
5568
5871
|
// 2. render -> fill elements with attributes and data
|
|
5569
5872
|
// that way all dom nodes can be recycled
|
|
5570
|
-
const create$
|
|
5873
|
+
const create$n = () => {
|
|
5571
5874
|
const $EditorInput = document.createElement('textarea');
|
|
5572
5875
|
$EditorInput.className = 'EditorInput';
|
|
5573
5876
|
$EditorInput.ariaAutoComplete = List;
|
|
@@ -5734,7 +6037,7 @@ const setDecorationsDom$1 = (state, decorations) => {
|
|
|
5734
6037
|
setDecorationsDom$2(state, decorations);
|
|
5735
6038
|
};
|
|
5736
6039
|
|
|
5737
|
-
const create$
|
|
6040
|
+
const create$m = create$n;
|
|
5738
6041
|
const setText$1 = setText$2;
|
|
5739
6042
|
const setSelections = setSelections$1;
|
|
5740
6043
|
const setIncrementalEdits = setIncrementalEdits$1;
|
|
@@ -5776,7 +6079,7 @@ const setDecorationsDom = setDecorationsDom$1;
|
|
|
5776
6079
|
|
|
5777
6080
|
const ViewletEditorText = {
|
|
5778
6081
|
__proto__: null,
|
|
5779
|
-
create: create$
|
|
6082
|
+
create: create$m,
|
|
5780
6083
|
focus: focus$e,
|
|
5781
6084
|
handleError: handleError$5,
|
|
5782
6085
|
hideOverlayMessage,
|
|
@@ -5792,7 +6095,7 @@ const ViewletEditorText = {
|
|
|
5792
6095
|
showOverlayMessage
|
|
5793
6096
|
};
|
|
5794
6097
|
|
|
5795
|
-
const create$
|
|
6098
|
+
const create$l = () => {
|
|
5796
6099
|
const $Viewlet = document.createElement('div');
|
|
5797
6100
|
$Viewlet.className = 'Viewlet EditorTextError';
|
|
5798
6101
|
return {
|
|
@@ -5808,11 +6111,11 @@ const setMessage$4 = (state, message) => {
|
|
|
5808
6111
|
|
|
5809
6112
|
const ViewletEditorTextError = {
|
|
5810
6113
|
__proto__: null,
|
|
5811
|
-
create: create$
|
|
6114
|
+
create: create$l,
|
|
5812
6115
|
setMessage: setMessage$4
|
|
5813
6116
|
};
|
|
5814
6117
|
|
|
5815
|
-
const create$
|
|
6118
|
+
const create$k = () => {
|
|
5816
6119
|
const $Viewlet = document.createElement('div');
|
|
5817
6120
|
$Viewlet.className = 'Viewlet EditorWidgetError EditorOverlayMessage';
|
|
5818
6121
|
return {
|
|
@@ -5835,12 +6138,12 @@ const setBounds$3 = (state, x, y, width, height) => {
|
|
|
5835
6138
|
|
|
5836
6139
|
const ViewletEditorWidgetError = {
|
|
5837
6140
|
__proto__: null,
|
|
5838
|
-
create: create$
|
|
6141
|
+
create: create$k,
|
|
5839
6142
|
setBounds: setBounds$3,
|
|
5840
6143
|
setMessage: setMessage$3
|
|
5841
6144
|
};
|
|
5842
6145
|
|
|
5843
|
-
const create$
|
|
6146
|
+
const create$j = () => {
|
|
5844
6147
|
const $Viewlet = document.createElement('div');
|
|
5845
6148
|
$Viewlet.dataset.viewlet = 'Empty';
|
|
5846
6149
|
$Viewlet.className = 'Viewlet';
|
|
@@ -5854,13 +6157,13 @@ const dispose$b = state => {};
|
|
|
5854
6157
|
|
|
5855
6158
|
const ViewletEmpty = {
|
|
5856
6159
|
__proto__: null,
|
|
5857
|
-
create: create$
|
|
6160
|
+
create: create$j,
|
|
5858
6161
|
dispose: dispose$b,
|
|
5859
6162
|
focus: focus$d,
|
|
5860
6163
|
refresh: refresh$2
|
|
5861
6164
|
};
|
|
5862
6165
|
|
|
5863
|
-
const create$
|
|
6166
|
+
const create$i = () => {
|
|
5864
6167
|
const $Viewlet = document.createElement('div');
|
|
5865
6168
|
$Viewlet.className = 'Viewlet EmptyEditor';
|
|
5866
6169
|
return {
|
|
@@ -5870,10 +6173,10 @@ const create$n = () => {
|
|
|
5870
6173
|
|
|
5871
6174
|
const ViewletEmptyEditor = {
|
|
5872
6175
|
__proto__: null,
|
|
5873
|
-
create: create$
|
|
6176
|
+
create: create$i
|
|
5874
6177
|
};
|
|
5875
6178
|
|
|
5876
|
-
const create$
|
|
6179
|
+
const create$h = () => {
|
|
5877
6180
|
const $Viewlet = document.createElement('div');
|
|
5878
6181
|
$Viewlet.className = 'Viewlet Error';
|
|
5879
6182
|
return {
|
|
@@ -5889,7 +6192,7 @@ const setMessage$2 = (state, message) => {
|
|
|
5889
6192
|
|
|
5890
6193
|
const ViewletError = {
|
|
5891
6194
|
__proto__: null,
|
|
5892
|
-
create: create$
|
|
6195
|
+
create: create$h,
|
|
5893
6196
|
setMessage: setMessage$2
|
|
5894
6197
|
};
|
|
5895
6198
|
|
|
@@ -6001,7 +6304,7 @@ const handleTouchEnd = event => {
|
|
|
6001
6304
|
|
|
6002
6305
|
// based on https://github.com/microsoft/vscode/blob/main/src/vs/workbench/contrib/extensions/browser/extensionsList.ts (License MIT)
|
|
6003
6306
|
|
|
6004
|
-
const create$
|
|
6307
|
+
const create$g = () => {
|
|
6005
6308
|
const $ExtensionHeader = document.createElement('div');
|
|
6006
6309
|
$ExtensionHeader.className = 'ExtensionHeader';
|
|
6007
6310
|
|
|
@@ -6146,7 +6449,7 @@ const ViewletExtensions = {
|
|
|
6146
6449
|
__proto__: null,
|
|
6147
6450
|
attachEvents: attachEvents$6,
|
|
6148
6451
|
closeSuggest,
|
|
6149
|
-
create: create$
|
|
6452
|
+
create: create$g,
|
|
6150
6453
|
dispose: dispose$a,
|
|
6151
6454
|
focus: focus$c,
|
|
6152
6455
|
handleError: handleError$4,
|
|
@@ -6251,7 +6554,7 @@ const ViewletFindWidgetEvents = {
|
|
|
6251
6554
|
returnValue: returnValue$3
|
|
6252
6555
|
};
|
|
6253
6556
|
|
|
6254
|
-
const create$
|
|
6557
|
+
const create$f = () => {
|
|
6255
6558
|
const $Viewlet = document.createElement('div');
|
|
6256
6559
|
$Viewlet.className = 'Viewlet FindWidget';
|
|
6257
6560
|
$Viewlet.role = Group;
|
|
@@ -6314,7 +6617,7 @@ const ViewletFindWidget = {
|
|
|
6314
6617
|
__proto__: null,
|
|
6315
6618
|
Events: Events$3,
|
|
6316
6619
|
appendWidget: appendWidget$1,
|
|
6317
|
-
create: create$
|
|
6620
|
+
create: create$f,
|
|
6318
6621
|
dispose: dispose$9,
|
|
6319
6622
|
focus: focus$b,
|
|
6320
6623
|
setBounds: setBounds$2,
|
|
@@ -6969,7 +7272,7 @@ const handleBlur$3 = () => {
|
|
|
6969
7272
|
const handleKeyDown$1 = handleKeyDown$2;
|
|
6970
7273
|
const handleKeyUp = handleKeyUp$1;
|
|
6971
7274
|
|
|
6972
|
-
const create$
|
|
7275
|
+
const create$e = () => {
|
|
6973
7276
|
// TODO use aria role splitter once supported https://github.com/w3c/aria/issues/1348
|
|
6974
7277
|
const $SashSideBar = document.createElement('div');
|
|
6975
7278
|
$SashSideBar.className = 'Viewlet Sash SashVertical';
|
|
@@ -7025,7 +7328,7 @@ const setSashes = (state, sashSideBar, sashPanel) => {
|
|
|
7025
7328
|
const ViewletLayout = {
|
|
7026
7329
|
__proto__: null,
|
|
7027
7330
|
attachEvents: attachEvents$5,
|
|
7028
|
-
create: create$
|
|
7331
|
+
create: create$e,
|
|
7029
7332
|
setSashes
|
|
7030
7333
|
};
|
|
7031
7334
|
|
|
@@ -7120,7 +7423,7 @@ const handleContextMenu$3 = event => {
|
|
|
7120
7423
|
};
|
|
7121
7424
|
|
|
7122
7425
|
// TODO Main should not be bound to Editor -> Lazy load Editor
|
|
7123
|
-
const create$
|
|
7426
|
+
const create$d = () => {
|
|
7124
7427
|
const $Viewlet = document.createElement('div');
|
|
7125
7428
|
$Viewlet.id = 'Main';
|
|
7126
7429
|
$Viewlet.className = 'Viewlet Main';
|
|
@@ -7220,7 +7523,7 @@ const ViewletMain = {
|
|
|
7220
7523
|
attachEvents: attachEvents$4,
|
|
7221
7524
|
closeAllViewlets,
|
|
7222
7525
|
closeViewletAndTab,
|
|
7223
|
-
create: create$
|
|
7526
|
+
create: create$d,
|
|
7224
7527
|
dispose: dispose$8,
|
|
7225
7528
|
focus: focus$9,
|
|
7226
7529
|
highlightDragOver,
|
|
@@ -7297,7 +7600,7 @@ const handleTabsContextMenu = event => {
|
|
|
7297
7600
|
handleTabContextMenu(uid, clientX, clientY);
|
|
7298
7601
|
};
|
|
7299
7602
|
|
|
7300
|
-
const create$
|
|
7603
|
+
const create$c = () => {
|
|
7301
7604
|
const $MainTabs = document.createElement('div');
|
|
7302
7605
|
$MainTabs.className = 'Viewlet MainTabs';
|
|
7303
7606
|
$MainTabs.role = TabList;
|
|
@@ -7346,7 +7649,7 @@ const setHighlight = (state, highlightLeft) => {
|
|
|
7346
7649
|
const ViewletMainTabs = {
|
|
7347
7650
|
__proto__: null,
|
|
7348
7651
|
attachEvents: attachEvents$3,
|
|
7349
|
-
create: create$
|
|
7652
|
+
create: create$c,
|
|
7350
7653
|
setHighlight,
|
|
7351
7654
|
setScrollLeft,
|
|
7352
7655
|
setTabsDom: setTabsDom$2
|
|
@@ -7369,7 +7672,7 @@ const EditorPlainText = 'EditorPlainText';
|
|
|
7369
7672
|
const EditorText = 'Editor';
|
|
7370
7673
|
const EditorWidgetError = 'EditorWidgetError';
|
|
7371
7674
|
const Empty = 'Empty';
|
|
7372
|
-
const Error$
|
|
7675
|
+
const Error$1 = 'Error';
|
|
7373
7676
|
const Extensions = 'Extensions';
|
|
7374
7677
|
const FindWidget = 'FindWidget';
|
|
7375
7678
|
const ImagePreview = 'ImagePreview';
|
|
@@ -7407,7 +7710,7 @@ const EditorTextError = 'EditorTextError';
|
|
|
7407
7710
|
const EditorRename = 'EditorRename';
|
|
7408
7711
|
const EditorCodeGenerator = 'EditorCodeGenerator';
|
|
7409
7712
|
|
|
7410
|
-
const create$
|
|
7713
|
+
const create$b = () => {
|
|
7411
7714
|
const $ViewletOutputContent = document.createElement('div');
|
|
7412
7715
|
$ViewletOutputContent.className = 'OutputContent';
|
|
7413
7716
|
$ViewletOutputContent.role = Log;
|
|
@@ -7459,7 +7762,7 @@ const dispose$7 = state => {};
|
|
|
7459
7762
|
const ViewletOutput = {
|
|
7460
7763
|
__proto__: null,
|
|
7461
7764
|
clear: clear$1,
|
|
7462
|
-
create: create$
|
|
7765
|
+
create: create$b,
|
|
7463
7766
|
dispose: dispose$7,
|
|
7464
7767
|
disposeFindWidget,
|
|
7465
7768
|
focus: focus$8,
|
|
@@ -7520,7 +7823,7 @@ const UiStrings = {
|
|
|
7520
7823
|
Close: 'Close',
|
|
7521
7824
|
Maximize: 'Maximize'
|
|
7522
7825
|
};
|
|
7523
|
-
const create$
|
|
7826
|
+
const create$a = () => {
|
|
7524
7827
|
const $PanelTabs = document.createElement('div');
|
|
7525
7828
|
$PanelTabs.className = 'PanelTabs';
|
|
7526
7829
|
$PanelTabs.role = TabList;
|
|
@@ -7633,7 +7936,7 @@ const setActionsDom$1 = (state, actions, childUid) => {
|
|
|
7633
7936
|
const ViewletPanel = {
|
|
7634
7937
|
__proto__: null,
|
|
7635
7938
|
attachEvents: attachEvents$2,
|
|
7636
|
-
create: create$
|
|
7939
|
+
create: create$a,
|
|
7637
7940
|
dispose: dispose$6,
|
|
7638
7941
|
focus: focus$7,
|
|
7639
7942
|
setActionsDom: setActionsDom$1,
|
|
@@ -7724,7 +8027,7 @@ const handleLoadedMetaData = event => {
|
|
|
7724
8027
|
target.play();
|
|
7725
8028
|
};
|
|
7726
8029
|
|
|
7727
|
-
const create$
|
|
8030
|
+
const create$9 = () => {
|
|
7728
8031
|
const $Viewlet = document.createElement('div');
|
|
7729
8032
|
$Viewlet.className = 'Viewlet ScreenCapture';
|
|
7730
8033
|
return {
|
|
@@ -7744,7 +8047,7 @@ const setScreenCapture = (state, id) => {
|
|
|
7744
8047
|
|
|
7745
8048
|
const ViewletScreenCapture = {
|
|
7746
8049
|
__proto__: null,
|
|
7747
|
-
create: create$
|
|
8050
|
+
create: create$9,
|
|
7748
8051
|
setScreenCapture
|
|
7749
8052
|
};
|
|
7750
8053
|
|
|
@@ -7764,7 +8067,7 @@ const handleHeaderClick = event => {
|
|
|
7764
8067
|
}
|
|
7765
8068
|
};
|
|
7766
8069
|
|
|
7767
|
-
const create$
|
|
8070
|
+
const create$8 = () => {
|
|
7768
8071
|
const $SideBarTitleAreaTitle = document.createElement('h2');
|
|
7769
8072
|
$SideBarTitleAreaTitle.className = 'SideBarTitleAreaTitle';
|
|
7770
8073
|
const $SideBarTitleArea = document.createElement('div');
|
|
@@ -7828,7 +8131,7 @@ const focus$5 = async () => {
|
|
|
7828
8131
|
const ViewletSideBar = {
|
|
7829
8132
|
__proto__: null,
|
|
7830
8133
|
attachEvents: attachEvents$1,
|
|
7831
|
-
create: create$
|
|
8134
|
+
create: create$8,
|
|
7832
8135
|
dispose: dispose$5,
|
|
7833
8136
|
focus: focus$5,
|
|
7834
8137
|
setActionsDom,
|
|
@@ -8029,7 +8332,7 @@ const ViewletStatusBarEvents = {
|
|
|
8029
8332
|
handleClick: handleClick$2
|
|
8030
8333
|
};
|
|
8031
8334
|
|
|
8032
|
-
const create$
|
|
8335
|
+
const create$7 = () => {
|
|
8033
8336
|
const $Viewlet = document.createElement('div');
|
|
8034
8337
|
$Viewlet.id = 'StatusBar';
|
|
8035
8338
|
$Viewlet.className = 'Viewlet StatusBar';
|
|
@@ -8058,7 +8361,7 @@ const focus$3 = state => {
|
|
|
8058
8361
|
|
|
8059
8362
|
const ViewletStatusBar = {
|
|
8060
8363
|
__proto__: null,
|
|
8061
|
-
create: create$
|
|
8364
|
+
create: create$7,
|
|
8062
8365
|
focus: focus$3,
|
|
8063
8366
|
setDom: setDom$2
|
|
8064
8367
|
};
|
|
@@ -8089,7 +8392,7 @@ const handleClickTab = event => {
|
|
|
8089
8392
|
handleClickTab$2(uid, index);
|
|
8090
8393
|
};
|
|
8091
8394
|
|
|
8092
|
-
const create$
|
|
8395
|
+
const create$6 = () => {
|
|
8093
8396
|
const $Viewlet = document.createElement('div');
|
|
8094
8397
|
$Viewlet.className = 'Viewlet Terminals';
|
|
8095
8398
|
return {
|
|
@@ -8116,7 +8419,7 @@ const setTabsDom = (state, dom) => {
|
|
|
8116
8419
|
|
|
8117
8420
|
const ViewletTerminals = {
|
|
8118
8421
|
__proto__: null,
|
|
8119
|
-
create: create$
|
|
8422
|
+
create: create$6,
|
|
8120
8423
|
setTabsDom
|
|
8121
8424
|
};
|
|
8122
8425
|
|
|
@@ -8130,7 +8433,7 @@ const handleContextMenu$1 = event => {
|
|
|
8130
8433
|
return ['handleContextMenu', button, clientX, clientY];
|
|
8131
8434
|
};
|
|
8132
8435
|
|
|
8133
|
-
const create$
|
|
8436
|
+
const create$5 = () => {
|
|
8134
8437
|
// TODO set aria label for title bar menu
|
|
8135
8438
|
// TODO add tests for aria properties
|
|
8136
8439
|
const $Viewlet = document.createElement('div');
|
|
@@ -8166,7 +8469,7 @@ const setFocused = (state, isFocused) => {
|
|
|
8166
8469
|
const ViewletTitleBar = {
|
|
8167
8470
|
__proto__: null,
|
|
8168
8471
|
attachEvents,
|
|
8169
|
-
create: create$
|
|
8472
|
+
create: create$5,
|
|
8170
8473
|
setFocused
|
|
8171
8474
|
};
|
|
8172
8475
|
|
|
@@ -8541,7 +8844,7 @@ const ViewletTitleBarMenuBar = {
|
|
|
8541
8844
|
setMenus
|
|
8542
8845
|
};
|
|
8543
8846
|
|
|
8544
|
-
const create$
|
|
8847
|
+
const create$4 = () => {
|
|
8545
8848
|
const $Viewlet = document.createElement('div');
|
|
8546
8849
|
$Viewlet.className = 'Viewlet TitleBarTitle';
|
|
8547
8850
|
return {
|
|
@@ -8557,7 +8860,7 @@ const setDom$1 = (state, dom) => {
|
|
|
8557
8860
|
|
|
8558
8861
|
const ViewletTitleBarTitle = {
|
|
8559
8862
|
__proto__: null,
|
|
8560
|
-
create: create$
|
|
8863
|
+
create: create$4,
|
|
8561
8864
|
setDom: setDom$1
|
|
8562
8865
|
};
|
|
8563
8866
|
|
|
@@ -8743,7 +9046,7 @@ const load$1 = moduleId => {
|
|
|
8743
9046
|
return ViewletEditorWidgetError;
|
|
8744
9047
|
case Empty:
|
|
8745
9048
|
return ViewletEmpty;
|
|
8746
|
-
case Error$
|
|
9049
|
+
case Error$1:
|
|
8747
9050
|
return ViewletError;
|
|
8748
9051
|
case Extensions:
|
|
8749
9052
|
return ViewletExtensions;
|
|
@@ -8820,7 +9123,7 @@ const load$1 = moduleId => {
|
|
|
8820
9123
|
}
|
|
8821
9124
|
};
|
|
8822
9125
|
|
|
8823
|
-
const create$
|
|
9126
|
+
const create$3 = (id, uid = id) => {
|
|
8824
9127
|
const module = state$1.modules[id];
|
|
8825
9128
|
if (!module) {
|
|
8826
9129
|
throw new Error(`module not found: ${id}`);
|
|
@@ -9081,7 +9384,7 @@ const sendMultiple = commands => {
|
|
|
9081
9384
|
}
|
|
9082
9385
|
case 'Viewlet.create':
|
|
9083
9386
|
{
|
|
9084
|
-
create$
|
|
9387
|
+
create$3(viewletId, method);
|
|
9085
9388
|
break;
|
|
9086
9389
|
}
|
|
9087
9390
|
case 'Viewlet.createFunctionalRoot':
|
|
@@ -9139,6 +9442,10 @@ const sendMultiple = commands => {
|
|
|
9139
9442
|
case 'Viewlet.addKeyBindings':
|
|
9140
9443
|
addKeyBindings(viewletId, method);
|
|
9141
9444
|
break;
|
|
9445
|
+
case 'Viewlet.setProperty':
|
|
9446
|
+
// @ts-ignore
|
|
9447
|
+
setProperty(viewletId, method, ...args);
|
|
9448
|
+
break;
|
|
9142
9449
|
case 'Viewlet.removeKeyBindings':
|
|
9143
9450
|
removeKeyBindings(viewletId);
|
|
9144
9451
|
break;
|
|
@@ -9327,7 +9634,7 @@ const appendToBody = childId => {
|
|
|
9327
9634
|
const getFn = command => {
|
|
9328
9635
|
switch (command) {
|
|
9329
9636
|
case 'Viewlet.create':
|
|
9330
|
-
return create$
|
|
9637
|
+
return create$3;
|
|
9331
9638
|
case 'Viewlet.send':
|
|
9332
9639
|
return invoke;
|
|
9333
9640
|
case 'Viewlet.show':
|
|
@@ -9370,6 +9677,8 @@ const getFn = command => {
|
|
|
9370
9677
|
return setDragData;
|
|
9371
9678
|
case 'Viewlet.focusSelector':
|
|
9372
9679
|
return focusSelector;
|
|
9680
|
+
case 'Viewlet.setProperty':
|
|
9681
|
+
return setProperty;
|
|
9373
9682
|
case 'Css.addCssStyleSheet':
|
|
9374
9683
|
case 'Viewlet.addCss':
|
|
9375
9684
|
case 'Viewlet.setCss':
|
|
@@ -9403,6 +9712,15 @@ const setBounds$1 = (id, left, top, width, height) => {
|
|
|
9403
9712
|
const $Viewlet = instance.state.$Viewlet;
|
|
9404
9713
|
setBounds$a($Viewlet, left, top, width, height);
|
|
9405
9714
|
};
|
|
9715
|
+
const setProperty = (id, selector, property, value) => {
|
|
9716
|
+
const instance = state$1.instances[id];
|
|
9717
|
+
if (!instance) {
|
|
9718
|
+
return;
|
|
9719
|
+
}
|
|
9720
|
+
const $Viewlet = instance.state.$Viewlet;
|
|
9721
|
+
const $Element = $Viewlet.querySelector(selector);
|
|
9722
|
+
$Element[property] = value;
|
|
9723
|
+
};
|
|
9406
9724
|
|
|
9407
9725
|
const LocalStorage = 1;
|
|
9408
9726
|
const SessionStorage = 2;
|
|
@@ -9506,29 +9824,9 @@ const handleMessagePort = async port => {
|
|
|
9506
9824
|
|
|
9507
9825
|
const set = ($Iframe, permissionPolicy) => {
|
|
9508
9826
|
if (permissionPolicy === undefined) {
|
|
9509
|
-
return;
|
|
9510
|
-
}
|
|
9511
|
-
$Iframe.allow = permissionPolicy;
|
|
9512
|
-
};
|
|
9513
|
-
|
|
9514
|
-
const withResolvers = () => {
|
|
9515
|
-
/**
|
|
9516
|
-
* @type {any}
|
|
9517
|
-
*/
|
|
9518
|
-
let _resolve;
|
|
9519
|
-
/**
|
|
9520
|
-
* @type {any}
|
|
9521
|
-
*/
|
|
9522
|
-
let _reject;
|
|
9523
|
-
const promise = new Promise((resolve, reject) => {
|
|
9524
|
-
_resolve = resolve;
|
|
9525
|
-
_reject = reject;
|
|
9526
|
-
});
|
|
9527
|
-
return {
|
|
9528
|
-
resolve: _resolve,
|
|
9529
|
-
reject: _reject,
|
|
9530
|
-
promise
|
|
9531
|
-
};
|
|
9827
|
+
return;
|
|
9828
|
+
}
|
|
9829
|
+
$Iframe.allow = permissionPolicy;
|
|
9532
9830
|
};
|
|
9533
9831
|
|
|
9534
9832
|
const waitForFrameToLoad = $Frame => {
|
|
@@ -9543,7 +9841,7 @@ const waitForFrameToLoad = $Frame => {
|
|
|
9543
9841
|
};
|
|
9544
9842
|
|
|
9545
9843
|
// TODO could use browser view when running in electron
|
|
9546
|
-
const create$
|
|
9844
|
+
const create$2 = async (uid, src, sandbox, csp, credentialless, permissionPolicy, title) => {
|
|
9547
9845
|
const $Iframe = document.createElement('iframe');
|
|
9548
9846
|
setIframeCredentialless($Iframe, credentialless);
|
|
9549
9847
|
setIframeCsp($Iframe, csp);
|
|
@@ -9624,7 +9922,7 @@ const commandMap = {
|
|
|
9624
9922
|
'GetFilePathElectron.getFilePathElectron': getFilePathElectron,
|
|
9625
9923
|
'HandleMessagePort.handleMessagePort': handleMessagePort,
|
|
9626
9924
|
'InitData.getInitData': getInitData,
|
|
9627
|
-
'IpcParent.create': create$
|
|
9925
|
+
'IpcParent.create': create$B,
|
|
9628
9926
|
'KeyBindings.setIdentifiers': setIdentifiers,
|
|
9629
9927
|
'Layout.getBounds': getBounds,
|
|
9630
9928
|
'Location.getHref': getHref,
|
|
@@ -9639,10 +9937,10 @@ const commandMap = {
|
|
|
9639
9937
|
'Menu.showControlled': showControlled,
|
|
9640
9938
|
'Menu.showMenu': showMenu,
|
|
9641
9939
|
'Meta.setThemeColor': setThemeColor,
|
|
9642
|
-
'Notification.create': create$
|
|
9940
|
+
'Notification.create': create$A,
|
|
9643
9941
|
'Notification.createWithOptions': createWithOptions,
|
|
9644
9942
|
'Notification.dispose': dispose$j,
|
|
9645
|
-
'OffscreenCanvas.create': create$
|
|
9943
|
+
'OffscreenCanvas.create': create$z,
|
|
9646
9944
|
'Open.openUrl': openUrl,
|
|
9647
9945
|
'Performance.getMemory': getMemory,
|
|
9648
9946
|
'Performance.measureUserAgentSpecificMemory': measureUserAgentSpecificMemory,
|
|
@@ -9681,7 +9979,7 @@ const commandMap = {
|
|
|
9681
9979
|
'WebStorage.setItem': setItem,
|
|
9682
9980
|
'WebStorage.setJsonObjects': setJsonObjects,
|
|
9683
9981
|
'WebView.appendOnly': appendOnly,
|
|
9684
|
-
'WebView.create': create$
|
|
9982
|
+
'WebView.create': create$2,
|
|
9685
9983
|
'WebView.dispose': dispose$2,
|
|
9686
9984
|
'WebView.load': load,
|
|
9687
9985
|
'WebView.loadOnly': loadOnly,
|
|
@@ -9718,7 +10016,7 @@ const getConfiguredEditorWorkerUrl = () => {
|
|
|
9718
10016
|
const editorWorkerUrl = getConfiguredEditorWorkerUrl() || `${assetDir}/packages/renderer-worker/node_modules/@lvce-editor/editor-worker/dist/editorWorkerMain.js`;
|
|
9719
10017
|
|
|
9720
10018
|
const launchEditorWorker = async port => {
|
|
9721
|
-
const ipc = await create$
|
|
10019
|
+
const ipc = await create$B({
|
|
9722
10020
|
name: 'Editor Worker',
|
|
9723
10021
|
url: editorWorkerUrl,
|
|
9724
10022
|
method: ModuleWorkerWithMessagePort,
|
|
@@ -9734,12 +10032,10 @@ const hydrate$2 = async () => {
|
|
|
9734
10032
|
} = new MessageChannel();
|
|
9735
10033
|
// TODO only launch port and send to renderer worker
|
|
9736
10034
|
const promise = launchEditorWorker(port1);
|
|
9737
|
-
set$
|
|
10035
|
+
set$7('Editor Worker', port2);
|
|
9738
10036
|
await promise;
|
|
9739
10037
|
};
|
|
9740
10038
|
|
|
9741
|
-
const isElectron = platform === Electron;
|
|
9742
|
-
|
|
9743
10039
|
const getConfiguredExtensionHostWorkerUrl = () => {
|
|
9744
10040
|
return getConfiguredWorkerUrl('extensionHostWorkerUrl');
|
|
9745
10041
|
};
|
|
@@ -9748,7 +10044,7 @@ const extensionHostWorkerUrl = getConfiguredExtensionHostWorkerUrl() || `${asset
|
|
|
9748
10044
|
|
|
9749
10045
|
const launchExtensionHostWorker = async port => {
|
|
9750
10046
|
const name = isElectron ? 'Extension Host (Electron)' : 'Extension Host';
|
|
9751
|
-
const ipc = await create$
|
|
10047
|
+
const ipc = await create$B({
|
|
9752
10048
|
name,
|
|
9753
10049
|
url: extensionHostWorkerUrl,
|
|
9754
10050
|
method: ModuleWorkerWithMessagePort,
|
|
@@ -9765,14 +10061,14 @@ const hydrate$1 = async () => {
|
|
|
9765
10061
|
// TODO only launch port and send to renderer worker
|
|
9766
10062
|
const promise = launchExtensionHostWorker(port1);
|
|
9767
10063
|
const name = isElectron ? 'Extension Host (Electron)' : 'Extension Host';
|
|
9768
|
-
set$
|
|
10064
|
+
set$7(name, port2);
|
|
9769
10065
|
await promise;
|
|
9770
10066
|
};
|
|
9771
10067
|
|
|
9772
10068
|
const syntaxHighlightingWorkerUrl = `${assetDir}/packages/renderer-worker/node_modules/@lvce-editor/syntax-highlighting-worker/dist/syntaxHighlightingWorkerMain.js`;
|
|
9773
10069
|
|
|
9774
10070
|
const launchSyntaxHighlightingWorker = async port => {
|
|
9775
|
-
const ipc = await create$
|
|
10071
|
+
const ipc = await create$B({
|
|
9776
10072
|
name: 'Syntax Highlighting Worker',
|
|
9777
10073
|
url: syntaxHighlightingWorkerUrl,
|
|
9778
10074
|
method: ModuleWorkerWithMessagePort,
|
|
@@ -9788,7 +10084,7 @@ const hydrate = async () => {
|
|
|
9788
10084
|
} = new MessageChannel();
|
|
9789
10085
|
// TODO only launch port and send to renderer worker
|
|
9790
10086
|
const promise = launchSyntaxHighlightingWorker(port1);
|
|
9791
|
-
set$
|
|
10087
|
+
set$7('Syntax Highlighting Worker', port2);
|
|
9792
10088
|
await promise;
|
|
9793
10089
|
};
|
|
9794
10090
|
|
|
@@ -9857,13 +10153,6 @@ const ViewletEditorRename = {
|
|
|
9857
10153
|
const handleContentSecurityPolicyViolation = event => {
|
|
9858
10154
|
};
|
|
9859
10155
|
|
|
9860
|
-
const NewLine = '\n';
|
|
9861
|
-
|
|
9862
|
-
const splitLines = lines => {
|
|
9863
|
-
string(lines);
|
|
9864
|
-
return lines.split(NewLine);
|
|
9865
|
-
};
|
|
9866
|
-
|
|
9867
10156
|
const RE_AT = /^\s+at/;
|
|
9868
10157
|
const RE_AT_PROMISE_INDEX = /^\s*at async Promise.all \(index \d+\)$/;
|
|
9869
10158
|
const RE_OBJECT_AS = /^\s*at Object\.\w+ \[as ([\w.]+)]/;
|
|
@@ -9940,7 +10229,7 @@ const mergeCustom = (custom, relevantStack) => {
|
|
|
9940
10229
|
};
|
|
9941
10230
|
const cleanStack = stack => {
|
|
9942
10231
|
string(stack);
|
|
9943
|
-
const lines = splitLines(stack);
|
|
10232
|
+
const lines = splitLines$2(stack);
|
|
9944
10233
|
const {
|
|
9945
10234
|
custom,
|
|
9946
10235
|
actualStack
|
|
@@ -9975,10 +10264,6 @@ const getIsFirefox = () => {
|
|
|
9975
10264
|
*/
|
|
9976
10265
|
const isFirefox = getIsFirefox();
|
|
9977
10266
|
|
|
9978
|
-
const joinLines = lines => {
|
|
9979
|
-
return lines.join(NewLine);
|
|
9980
|
-
};
|
|
9981
|
-
|
|
9982
10267
|
const getErrorMessage = error => {
|
|
9983
10268
|
if (!error) {
|
|
9984
10269
|
return `Error: ${error}`;
|
|
@@ -10002,7 +10287,7 @@ const prepareErrorMessageWithCodeFrame = error => {
|
|
|
10002
10287
|
}
|
|
10003
10288
|
const message = getErrorMessage(error);
|
|
10004
10289
|
const lines = cleanStack(error.stack);
|
|
10005
|
-
const relevantStack = joinLines(lines);
|
|
10290
|
+
const relevantStack = joinLines$2(lines);
|
|
10006
10291
|
if (error.codeFrame) {
|
|
10007
10292
|
return {
|
|
10008
10293
|
message,
|
|
@@ -10186,275 +10471,6 @@ const main = async () => {
|
|
|
10186
10471
|
|
|
10187
10472
|
main();
|
|
10188
10473
|
|
|
10189
|
-
const Message = 'message';
|
|
10190
|
-
const Error$1 = 'error';
|
|
10191
|
-
|
|
10192
|
-
const getFirstEvent = (eventTarget, eventMap) => {
|
|
10193
|
-
const {
|
|
10194
|
-
resolve,
|
|
10195
|
-
promise
|
|
10196
|
-
} = withResolvers();
|
|
10197
|
-
const listenerMap = Object.create(null);
|
|
10198
|
-
const cleanup = value => {
|
|
10199
|
-
for (const event of Object.keys(eventMap)) {
|
|
10200
|
-
eventTarget.removeEventListener(event, listenerMap[event]);
|
|
10201
|
-
}
|
|
10202
|
-
resolve(value);
|
|
10203
|
-
};
|
|
10204
|
-
for (const [event, type] of Object.entries(eventMap)) {
|
|
10205
|
-
const listener = event => {
|
|
10206
|
-
cleanup({
|
|
10207
|
-
type,
|
|
10208
|
-
event
|
|
10209
|
-
});
|
|
10210
|
-
};
|
|
10211
|
-
eventTarget.addEventListener(event, listener);
|
|
10212
|
-
listenerMap[event] = listener;
|
|
10213
|
-
}
|
|
10214
|
-
return promise;
|
|
10215
|
-
};
|
|
10216
|
-
|
|
10217
|
-
/**
|
|
10218
|
-
*
|
|
10219
|
-
* @param {Worker} worker
|
|
10220
|
-
* @returns
|
|
10221
|
-
*/
|
|
10222
|
-
const getFirstWorkerEvent = worker => {
|
|
10223
|
-
return getFirstEvent(worker, {
|
|
10224
|
-
message: Message,
|
|
10225
|
-
error: Error$1
|
|
10226
|
-
});
|
|
10227
|
-
};
|
|
10228
|
-
|
|
10229
|
-
const transferrables = [];
|
|
10230
|
-
if (typeof MessagePort !== 'undefined') {
|
|
10231
|
-
transferrables.push(MessagePort);
|
|
10232
|
-
}
|
|
10233
|
-
if (typeof OffscreenCanvas !== 'undefined') {
|
|
10234
|
-
transferrables.push(OffscreenCanvas);
|
|
10235
|
-
}
|
|
10236
|
-
|
|
10237
|
-
const isTransferrable = value => {
|
|
10238
|
-
for (const fn of transferrables) {
|
|
10239
|
-
if (value instanceof fn) {
|
|
10240
|
-
return true;
|
|
10241
|
-
}
|
|
10242
|
-
}
|
|
10243
|
-
return false;
|
|
10244
|
-
};
|
|
10245
|
-
|
|
10246
|
-
const walkValue = (value, transferrables) => {
|
|
10247
|
-
if (!value) {
|
|
10248
|
-
return;
|
|
10249
|
-
}
|
|
10250
|
-
if (isTransferrable(value)) {
|
|
10251
|
-
transferrables.push(value);
|
|
10252
|
-
}
|
|
10253
|
-
if (Array.isArray(value)) {
|
|
10254
|
-
for (const item of value) {
|
|
10255
|
-
walkValue(item, transferrables);
|
|
10256
|
-
}
|
|
10257
|
-
return;
|
|
10258
|
-
}
|
|
10259
|
-
if (typeof value === 'object') {
|
|
10260
|
-
for (const property of Object.values(value)) {
|
|
10261
|
-
walkValue(property, transferrables);
|
|
10262
|
-
}
|
|
10263
|
-
}
|
|
10264
|
-
};
|
|
10265
|
-
|
|
10266
|
-
const getTransfer = value => {
|
|
10267
|
-
const transferrables = [];
|
|
10268
|
-
walkValue(value, transferrables);
|
|
10269
|
-
return transferrables;
|
|
10270
|
-
};
|
|
10271
|
-
|
|
10272
|
-
class IpcError extends Error {
|
|
10273
|
-
constructor(message) {
|
|
10274
|
-
super(message);
|
|
10275
|
-
this.name = 'IpcError';
|
|
10276
|
-
}
|
|
10277
|
-
}
|
|
10278
|
-
|
|
10279
|
-
const isErrorEvent = event => {
|
|
10280
|
-
return event instanceof ErrorEvent;
|
|
10281
|
-
};
|
|
10282
|
-
|
|
10283
|
-
class WorkerError extends Error {
|
|
10284
|
-
constructor(event) {
|
|
10285
|
-
super(event.message);
|
|
10286
|
-
const stackLines = splitLines(this.stack);
|
|
10287
|
-
const relevantLines = stackLines.slice(1);
|
|
10288
|
-
const relevant = joinLines(relevantLines);
|
|
10289
|
-
this.stack = `${event.message}
|
|
10290
|
-
at Module (${event.filename}:${event.lineno}:${event.colno})
|
|
10291
|
-
${relevant}`;
|
|
10292
|
-
}
|
|
10293
|
-
}
|
|
10294
|
-
|
|
10295
|
-
const Module = 'module';
|
|
10296
|
-
|
|
10297
|
-
const getWorkerDisplayName = name => {
|
|
10298
|
-
if (name && name.endsWith('Worker')) {
|
|
10299
|
-
return name;
|
|
10300
|
-
}
|
|
10301
|
-
return `${name} worker`;
|
|
10302
|
-
};
|
|
10303
|
-
const create$6 = async ({
|
|
10304
|
-
url,
|
|
10305
|
-
name
|
|
10306
|
-
}) => {
|
|
10307
|
-
const worker = new Worker(url, {
|
|
10308
|
-
type: Module,
|
|
10309
|
-
name
|
|
10310
|
-
});
|
|
10311
|
-
// @ts-expect-error
|
|
10312
|
-
const {
|
|
10313
|
-
type,
|
|
10314
|
-
event
|
|
10315
|
-
} = await getFirstWorkerEvent(worker);
|
|
10316
|
-
switch (type) {
|
|
10317
|
-
case Message:
|
|
10318
|
-
if (event.data !== 'ready') {
|
|
10319
|
-
throw new IpcError('unexpected first message from worker');
|
|
10320
|
-
}
|
|
10321
|
-
break;
|
|
10322
|
-
case Error$1:
|
|
10323
|
-
if (isErrorEvent(event)) {
|
|
10324
|
-
throw new WorkerError(event);
|
|
10325
|
-
}
|
|
10326
|
-
const displayName = getWorkerDisplayName(name);
|
|
10327
|
-
throw new IpcError(`Failed to start ${displayName}`);
|
|
10328
|
-
}
|
|
10329
|
-
return worker;
|
|
10330
|
-
};
|
|
10331
|
-
const getData = event => {
|
|
10332
|
-
// TODO why are some events not instance of message event?
|
|
10333
|
-
if (event instanceof MessageEvent) {
|
|
10334
|
-
return event.data;
|
|
10335
|
-
}
|
|
10336
|
-
return event;
|
|
10337
|
-
};
|
|
10338
|
-
const wrap = worker => {
|
|
10339
|
-
let handleMessage;
|
|
10340
|
-
return {
|
|
10341
|
-
get onmessage() {
|
|
10342
|
-
return handleMessage;
|
|
10343
|
-
},
|
|
10344
|
-
set onmessage(listener) {
|
|
10345
|
-
if (listener) {
|
|
10346
|
-
handleMessage = event => {
|
|
10347
|
-
const data = getData(event);
|
|
10348
|
-
listener({
|
|
10349
|
-
data,
|
|
10350
|
-
target: this
|
|
10351
|
-
});
|
|
10352
|
-
};
|
|
10353
|
-
} else {
|
|
10354
|
-
handleMessage = null;
|
|
10355
|
-
}
|
|
10356
|
-
worker.onmessage = handleMessage;
|
|
10357
|
-
},
|
|
10358
|
-
send(message) {
|
|
10359
|
-
worker.postMessage(message);
|
|
10360
|
-
},
|
|
10361
|
-
sendAndTransfer(message) {
|
|
10362
|
-
const transfer = getTransfer(message);
|
|
10363
|
-
worker.postMessage(message, transfer);
|
|
10364
|
-
}
|
|
10365
|
-
};
|
|
10366
|
-
};
|
|
10367
|
-
|
|
10368
|
-
const IpcParentWithModuleWorker = {
|
|
10369
|
-
__proto__: null,
|
|
10370
|
-
create: create$6,
|
|
10371
|
-
wrap
|
|
10372
|
-
};
|
|
10373
|
-
|
|
10374
|
-
const isMessagePort = value => {
|
|
10375
|
-
return value instanceof MessagePort;
|
|
10376
|
-
};
|
|
10377
|
-
|
|
10378
|
-
const create$5 = async ({
|
|
10379
|
-
url
|
|
10380
|
-
}) => {
|
|
10381
|
-
string(url);
|
|
10382
|
-
const portPromise = await new Promise(resolve => {
|
|
10383
|
-
globalThis.acceptPort = resolve;
|
|
10384
|
-
});
|
|
10385
|
-
await import(url);
|
|
10386
|
-
const port = await portPromise;
|
|
10387
|
-
delete globalThis.acceptPort;
|
|
10388
|
-
if (!port) {
|
|
10389
|
-
throw new IpcError('port must be defined');
|
|
10390
|
-
}
|
|
10391
|
-
if (!isMessagePort(port)) {
|
|
10392
|
-
throw new IpcError('port must be of type MessagePort');
|
|
10393
|
-
}
|
|
10394
|
-
return port;
|
|
10395
|
-
};
|
|
10396
|
-
|
|
10397
|
-
const IpcParentWithMessagePort = {
|
|
10398
|
-
__proto__: null,
|
|
10399
|
-
create: create$5
|
|
10400
|
-
};
|
|
10401
|
-
|
|
10402
|
-
const create$4 = async url => {
|
|
10403
|
-
const referencePort = await new Promise(resolve => {
|
|
10404
|
-
globalThis.acceptReferencePort = resolve;
|
|
10405
|
-
import(url);
|
|
10406
|
-
});
|
|
10407
|
-
delete globalThis.acceptReferencePort;
|
|
10408
|
-
return referencePort;
|
|
10409
|
-
};
|
|
10410
|
-
|
|
10411
|
-
const IpcParentWithReferencePort = {
|
|
10412
|
-
__proto__: null,
|
|
10413
|
-
create: create$4
|
|
10414
|
-
};
|
|
10415
|
-
|
|
10416
|
-
// TODO add test
|
|
10417
|
-
const create$3 = async ({
|
|
10418
|
-
url,
|
|
10419
|
-
name,
|
|
10420
|
-
port
|
|
10421
|
-
}) => {
|
|
10422
|
-
await ModuleWorkerWithMessagePortRpcParent.create({
|
|
10423
|
-
url,
|
|
10424
|
-
name,
|
|
10425
|
-
commandMap: {},
|
|
10426
|
-
port
|
|
10427
|
-
});
|
|
10428
|
-
return undefined;
|
|
10429
|
-
};
|
|
10430
|
-
|
|
10431
|
-
const IpcParentWithModuleWorkerWithMessagePort = {
|
|
10432
|
-
__proto__: null,
|
|
10433
|
-
create: create$3
|
|
10434
|
-
};
|
|
10435
|
-
|
|
10436
|
-
// TODO use handleIncomingIpc function
|
|
10437
|
-
const create$2 = async ({
|
|
10438
|
-
port,
|
|
10439
|
-
ipcId
|
|
10440
|
-
}) => {
|
|
10441
|
-
number(ipcId);
|
|
10442
|
-
if (!isElectron) {
|
|
10443
|
-
throw new Error('Electron api was requested but is not available');
|
|
10444
|
-
}
|
|
10445
|
-
const rpc = await ElectronWindowRpcClient.create({
|
|
10446
|
-
commandMap: {},
|
|
10447
|
-
window
|
|
10448
|
-
});
|
|
10449
|
-
const webContentsIds = await rpc.invokeAndTransfer('CreateMessagePort.createMessagePort', ipcId, port);
|
|
10450
|
-
return webContentsIds;
|
|
10451
|
-
};
|
|
10452
|
-
|
|
10453
|
-
const IpcParentWithElectron = {
|
|
10454
|
-
__proto__: null,
|
|
10455
|
-
create: create$2
|
|
10456
|
-
};
|
|
10457
|
-
|
|
10458
10474
|
const isUint8Array = value => {
|
|
10459
10475
|
return value instanceof Uint8Array;
|
|
10460
10476
|
};
|