@lvce-editor/extension-detail-view 6.8.0 → 7.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -85,7 +85,7 @@ const copyLink = () => {
85
85
  const resources = () => {
86
86
  return i18nString(Resources$1);
87
87
  };
88
- const copy$1 = () => {
88
+ const copy = () => {
89
89
  return i18nString(Copy);
90
90
  };
91
91
  const copyImage$1 = () => {
@@ -324,22 +324,339 @@ const A = 53;
324
324
  const Ul = 60;
325
325
  const Code$2 = 65;
326
326
  const Dt = 67;
327
+ const Reference = 100;
328
+
329
+ const ClientX = 'event.clientX';
330
+ const ClientY = 'event.clientY';
331
+ const TargetHref = 'event.target.href';
332
+ const TargetName = 'event.target.name';
327
333
 
328
334
  const LeftArrow = 13;
329
335
  const RightArrow = 15;
330
336
 
337
+ const Script$1 = 2;
338
+
339
+ const ExtensionDetailReadme = 20;
340
+ const ExtensionDetailIconContextMenu$2 = 4091;
341
+
342
+ const None$2 = 0;
343
+
344
+ const Web$1 = 1;
345
+ const Electron$1 = 2;
346
+
347
+ const ExtensionHostWorker = 44;
348
+ const ExtensionManagementWorker = 9006;
349
+ const FileSystemWorker$1 = 209;
350
+ const MarkdownWorker$1 = 300;
351
+ const RendererWorker = 1;
352
+
353
+ const FocusElementByName = 'Viewlet.focusElementByName';
354
+ const SetDom2 = 'Viewlet.setDom2';
355
+ const SetFocusContext = 'Viewlet.setFocusContext';
356
+ const SetPatches = 'Viewlet.setPatches';
357
+
358
+ const FocusExtensionDetailTabs = 451;
359
+
331
360
  const mergeClassNames = (...classNames) => {
332
361
  return classNames.filter(Boolean).join(' ');
333
362
  };
334
363
 
335
364
  const text = data => {
336
365
  return {
337
- type: Text$1,
366
+ childCount: 0,
338
367
  text: data,
339
- childCount: 0
368
+ type: Text$1
369
+ };
370
+ };
371
+
372
+ const SetText = 1;
373
+ const Replace = 2;
374
+ const SetAttribute = 3;
375
+ const RemoveAttribute = 4;
376
+ const Add = 6;
377
+ const NavigateChild = 7;
378
+ const NavigateParent = 8;
379
+ const RemoveChild = 9;
380
+ const NavigateSibling = 10;
381
+ const SetReferenceNodeUid = 11;
382
+
383
+ const isKey = key => {
384
+ return key !== 'type' && key !== 'childCount';
385
+ };
386
+
387
+ const getKeys = node => {
388
+ const keys = Object.keys(node).filter(isKey);
389
+ return keys;
390
+ };
391
+
392
+ const arrayToTree = nodes => {
393
+ const result = [];
394
+ let i = 0;
395
+ while (i < nodes.length) {
396
+ const node = nodes[i];
397
+ const {
398
+ children,
399
+ nodesConsumed
400
+ } = getChildrenWithCount(nodes, i + 1, node.childCount || 0);
401
+ result.push({
402
+ node,
403
+ children
404
+ });
405
+ i += 1 + nodesConsumed;
406
+ }
407
+ return result;
408
+ };
409
+ const getChildrenWithCount = (nodes, startIndex, childCount) => {
410
+ if (childCount === 0) {
411
+ return {
412
+ children: [],
413
+ nodesConsumed: 0
414
+ };
415
+ }
416
+ const children = [];
417
+ let i = startIndex;
418
+ let remaining = childCount;
419
+ let totalConsumed = 0;
420
+ while (remaining > 0 && i < nodes.length) {
421
+ const node = nodes[i];
422
+ const nodeChildCount = node.childCount || 0;
423
+ const {
424
+ children: nodeChildren,
425
+ nodesConsumed
426
+ } = getChildrenWithCount(nodes, i + 1, nodeChildCount);
427
+ children.push({
428
+ node,
429
+ children: nodeChildren
430
+ });
431
+ const nodeSize = 1 + nodesConsumed;
432
+ i += nodeSize;
433
+ totalConsumed += nodeSize;
434
+ remaining--;
435
+ }
436
+ return {
437
+ children,
438
+ nodesConsumed: totalConsumed
340
439
  };
341
440
  };
342
441
 
442
+ const compareNodes = (oldNode, newNode) => {
443
+ const patches = [];
444
+ // Check if node type changed - return null to signal incompatible nodes
445
+ // (caller should handle this with a Replace operation)
446
+ if (oldNode.type !== newNode.type) {
447
+ return null;
448
+ }
449
+ // Handle reference nodes - special handling for uid changes
450
+ if (oldNode.type === Reference) {
451
+ if (oldNode.uid !== newNode.uid) {
452
+ patches.push({
453
+ type: SetReferenceNodeUid,
454
+ uid: newNode.uid
455
+ });
456
+ }
457
+ return patches;
458
+ }
459
+ // Handle text nodes
460
+ if (oldNode.type === Text$1 && newNode.type === Text$1) {
461
+ if (oldNode.text !== newNode.text) {
462
+ patches.push({
463
+ type: SetText,
464
+ value: newNode.text
465
+ });
466
+ }
467
+ return patches;
468
+ }
469
+ // Compare attributes
470
+ const oldKeys = getKeys(oldNode);
471
+ const newKeys = getKeys(newNode);
472
+ // Check for attribute changes
473
+ for (const key of newKeys) {
474
+ if (oldNode[key] !== newNode[key]) {
475
+ patches.push({
476
+ type: SetAttribute,
477
+ key,
478
+ value: newNode[key]
479
+ });
480
+ }
481
+ }
482
+ // Check for removed attributes
483
+ for (const key of oldKeys) {
484
+ if (!(key in newNode)) {
485
+ patches.push({
486
+ type: RemoveAttribute,
487
+ key
488
+ });
489
+ }
490
+ }
491
+ return patches;
492
+ };
493
+
494
+ const treeToArray = node => {
495
+ const result = [node.node];
496
+ for (const child of node.children) {
497
+ result.push(...treeToArray(child));
498
+ }
499
+ return result;
500
+ };
501
+
502
+ const diffChildren = (oldChildren, newChildren, patches) => {
503
+ const maxLength = Math.max(oldChildren.length, newChildren.length);
504
+ // Track where we are: -1 means at parent, >= 0 means at child index
505
+ let currentChildIndex = -1;
506
+ // Collect indices of children to remove (we'll add these patches at the end in reverse order)
507
+ const indicesToRemove = [];
508
+ for (let i = 0; i < maxLength; i++) {
509
+ const oldNode = oldChildren[i];
510
+ const newNode = newChildren[i];
511
+ if (!oldNode && !newNode) {
512
+ continue;
513
+ }
514
+ if (!oldNode) {
515
+ // Add new node - we should be at the parent
516
+ if (currentChildIndex >= 0) {
517
+ // Navigate back to parent
518
+ patches.push({
519
+ type: NavigateParent
520
+ });
521
+ currentChildIndex = -1;
522
+ }
523
+ // Flatten the entire subtree so renderInternal can handle it
524
+ const flatNodes = treeToArray(newNode);
525
+ patches.push({
526
+ type: Add,
527
+ nodes: flatNodes
528
+ });
529
+ } else if (newNode) {
530
+ // Compare nodes to see if we need any patches
531
+ const nodePatches = compareNodes(oldNode.node, newNode.node);
532
+ // If nodePatches is null, the node types are incompatible - need to replace
533
+ if (nodePatches === null) {
534
+ // Navigate to this child
535
+ if (currentChildIndex === -1) {
536
+ patches.push({
537
+ type: NavigateChild,
538
+ index: i
539
+ });
540
+ currentChildIndex = i;
541
+ } else if (currentChildIndex !== i) {
542
+ patches.push({
543
+ type: NavigateSibling,
544
+ index: i
545
+ });
546
+ currentChildIndex = i;
547
+ }
548
+ // Replace the entire subtree
549
+ const flatNodes = treeToArray(newNode);
550
+ patches.push({
551
+ type: Replace,
552
+ nodes: flatNodes
553
+ });
554
+ // After replace, we're at the new element (same position)
555
+ continue;
556
+ }
557
+ // Check if we need to recurse into children
558
+ const hasChildrenToCompare = oldNode.children.length > 0 || newNode.children.length > 0;
559
+ // Only navigate to this element if we need to do something
560
+ if (nodePatches.length > 0 || hasChildrenToCompare) {
561
+ // Navigate to this child if not already there
562
+ if (currentChildIndex === -1) {
563
+ patches.push({
564
+ type: NavigateChild,
565
+ index: i
566
+ });
567
+ currentChildIndex = i;
568
+ } else if (currentChildIndex !== i) {
569
+ patches.push({
570
+ type: NavigateSibling,
571
+ index: i
572
+ });
573
+ currentChildIndex = i;
574
+ }
575
+ // Apply node patches (these apply to the current element, not children)
576
+ if (nodePatches.length > 0) {
577
+ patches.push(...nodePatches);
578
+ }
579
+ // Compare children recursively
580
+ if (hasChildrenToCompare) {
581
+ diffChildren(oldNode.children, newNode.children, patches);
582
+ }
583
+ }
584
+ } else {
585
+ // Remove old node - collect the index for later removal
586
+ indicesToRemove.push(i);
587
+ }
588
+ }
589
+ // Navigate back to parent if we ended at a child
590
+ if (currentChildIndex >= 0) {
591
+ patches.push({
592
+ type: NavigateParent
593
+ });
594
+ currentChildIndex = -1;
595
+ }
596
+ // Add remove patches in reverse order (highest index first)
597
+ // This ensures indices remain valid as we remove
598
+ for (let j = indicesToRemove.length - 1; j >= 0; j--) {
599
+ patches.push({
600
+ type: RemoveChild,
601
+ index: indicesToRemove[j]
602
+ });
603
+ }
604
+ };
605
+ const diffTrees = (oldTree, newTree, patches, path) => {
606
+ // At the root level (path.length === 0), we're already AT the element
607
+ // So we compare the root node directly, then compare its children
608
+ if (path.length === 0 && oldTree.length === 1 && newTree.length === 1) {
609
+ const oldNode = oldTree[0];
610
+ const newNode = newTree[0];
611
+ // Compare root nodes
612
+ const nodePatches = compareNodes(oldNode.node, newNode.node);
613
+ // If nodePatches is null, the root node types are incompatible - need to replace
614
+ if (nodePatches === null) {
615
+ const flatNodes = treeToArray(newNode);
616
+ patches.push({
617
+ type: Replace,
618
+ nodes: flatNodes
619
+ });
620
+ return;
621
+ }
622
+ if (nodePatches.length > 0) {
623
+ patches.push(...nodePatches);
624
+ }
625
+ // Compare children
626
+ if (oldNode.children.length > 0 || newNode.children.length > 0) {
627
+ diffChildren(oldNode.children, newNode.children, patches);
628
+ }
629
+ } else {
630
+ // Non-root level or multiple root elements - use the regular comparison
631
+ diffChildren(oldTree, newTree, patches);
632
+ }
633
+ };
634
+
635
+ const removeTrailingNavigationPatches = patches => {
636
+ // Find the last non-navigation patch
637
+ let lastNonNavigationIndex = -1;
638
+ for (let i = patches.length - 1; i >= 0; i--) {
639
+ const patch = patches[i];
640
+ if (patch.type !== NavigateChild && patch.type !== NavigateParent && patch.type !== NavigateSibling) {
641
+ lastNonNavigationIndex = i;
642
+ break;
643
+ }
644
+ }
645
+ // Return patches up to and including the last non-navigation patch
646
+ return lastNonNavigationIndex === -1 ? [] : patches.slice(0, lastNonNavigationIndex + 1);
647
+ };
648
+
649
+ const diffTree = (oldNodes, newNodes) => {
650
+ // Step 1: Convert flat arrays to tree structures
651
+ const oldTree = arrayToTree(oldNodes);
652
+ const newTree = arrayToTree(newNodes);
653
+ // Step 3: Compare the trees
654
+ const patches = [];
655
+ diffTrees(oldTree, newTree, patches, []);
656
+ // Remove trailing navigation patches since they serve no purpose
657
+ return removeTrailingNavigationPatches(patches);
658
+ };
659
+
343
660
  const AdditionalDetails = 'AdditionalDetails';
344
661
  const AdditionalDetailsEntry = 'AdditionalDetailsEntry';
345
662
  const AdditionalDetailsTitle = 'AdditionalDetailsTitle';
@@ -1021,64 +1338,6 @@ const getFeatureVirtualDomHandler = featureName => {
1021
1338
  return feature.getVirtualDom;
1022
1339
  };
1023
1340
 
1024
- const ClientX = 'event.clientX';
1025
- const ClientY = 'event.clientY';
1026
- const TargetHref = 'event.target.href';
1027
- const TargetName = 'event.target.name';
1028
-
1029
- const Script$1 = 2;
1030
-
1031
- const ExtensionDetailReadme = 20;
1032
- const ExtensionDetailIconContextMenu$2 = 4091;
1033
-
1034
- const None$2 = 0;
1035
-
1036
- const Web$1 = 1;
1037
- const Electron$1 = 2;
1038
-
1039
- const ExtensionHostWorker = 44;
1040
- const ExtensionManagementWorker = 9006;
1041
- const FileSystemWorker$1 = 209;
1042
- const MarkdownWorker$1 = 300;
1043
- const RendererWorker = 1;
1044
-
1045
- const FocusElementByName = 'Viewlet.focusElementByName';
1046
- const SetFocusContext = 'Viewlet.setFocusContext';
1047
-
1048
- const FocusExtensionDetailTabs = 451;
1049
-
1050
- const rpcs = Object.create(null);
1051
- const set$a = (id, rpc) => {
1052
- rpcs[id] = rpc;
1053
- };
1054
- const get$3 = id => {
1055
- return rpcs[id];
1056
- };
1057
-
1058
- const create$4 = rpcId => {
1059
- return {
1060
- async dispose() {
1061
- const rpc = get$3(rpcId);
1062
- await rpc.dispose();
1063
- },
1064
- // @ts-ignore
1065
- invoke(method, ...params) {
1066
- const rpc = get$3(rpcId);
1067
- // @ts-ignore
1068
- return rpc.invoke(method, ...params);
1069
- },
1070
- // @ts-ignore
1071
- invokeAndTransfer(method, ...params) {
1072
- const rpc = get$3(rpcId);
1073
- // @ts-ignore
1074
- return rpc.invokeAndTransfer(method, ...params);
1075
- },
1076
- set(rpc) {
1077
- set$a(rpcId, rpc);
1078
- }
1079
- };
1080
- };
1081
-
1082
1341
  const normalizeLine = line => {
1083
1342
  if (line.startsWith('Error: ')) {
1084
1343
  return line.slice('Error: '.length);
@@ -1184,1797 +1443,1771 @@ const string = value => {
1184
1443
  }
1185
1444
  };
1186
1445
 
1187
- const isMessagePort = value => {
1188
- return value && value instanceof MessagePort;
1189
- };
1190
- const isMessagePortMain = value => {
1191
- return value && value.constructor && value.constructor.name === 'MessagePortMain';
1192
- };
1193
- const isOffscreenCanvas = value => {
1194
- return typeof OffscreenCanvas !== 'undefined' && value instanceof OffscreenCanvas;
1195
- };
1196
- const isInstanceOf = (value, constructorName) => {
1197
- return value?.constructor?.name === constructorName;
1446
+ class CommandNotFoundError extends Error {
1447
+ constructor(command) {
1448
+ super(`Command not found ${command}`);
1449
+ this.name = 'CommandNotFoundError';
1450
+ }
1451
+ }
1452
+ const commands = Object.create(null);
1453
+ const register = commandMap => {
1454
+ Object.assign(commands, commandMap);
1198
1455
  };
1199
- const isSocket = value => {
1200
- return isInstanceOf(value, 'Socket');
1456
+ const getCommand = key => {
1457
+ return commands[key];
1201
1458
  };
1202
- const transferrables = [isMessagePort, isMessagePortMain, isOffscreenCanvas, isSocket];
1203
- const isTransferrable = value => {
1204
- for (const fn of transferrables) {
1205
- if (fn(value)) {
1206
- return true;
1207
- }
1459
+ const execute = (command, ...args) => {
1460
+ const fn = getCommand(command);
1461
+ if (!fn) {
1462
+ throw new CommandNotFoundError(command);
1208
1463
  }
1209
- return false;
1464
+ return fn(...args);
1210
1465
  };
1211
- const walkValue = (value, transferrables, isTransferrable) => {
1212
- if (!value) {
1213
- return;
1214
- }
1215
- if (isTransferrable(value)) {
1216
- transferrables.push(value);
1217
- return;
1218
- }
1219
- if (Array.isArray(value)) {
1220
- for (const item of value) {
1221
- walkValue(item, transferrables, isTransferrable);
1222
- }
1223
- return;
1224
- }
1225
- if (typeof value === 'object') {
1226
- for (const property of Object.values(value)) {
1227
- walkValue(property, transferrables, isTransferrable);
1466
+
1467
+ const createMockRpc = ({
1468
+ commandMap
1469
+ }) => {
1470
+ const invocations = [];
1471
+ const invoke = (method, ...params) => {
1472
+ invocations.push([method, ...params]);
1473
+ const command = commandMap[method];
1474
+ if (!command) {
1475
+ throw new Error(`command ${method} not found`);
1228
1476
  }
1229
- return;
1230
- }
1231
- };
1232
- const getTransferrables = value => {
1233
- const transferrables = [];
1234
- walkValue(value, transferrables, isTransferrable);
1235
- return transferrables;
1236
- };
1237
- const attachEvents = that => {
1238
- const handleMessage = (...args) => {
1239
- const data = that.getData(...args);
1240
- that.dispatchEvent(new MessageEvent('message', {
1241
- data
1242
- }));
1477
+ return command(...params);
1243
1478
  };
1244
- that.onMessage(handleMessage);
1245
- const handleClose = event => {
1246
- that.dispatchEvent(new Event('close'));
1479
+ const mockRpc = {
1480
+ invocations,
1481
+ invoke,
1482
+ invokeAndTransfer: invoke
1247
1483
  };
1248
- that.onClose(handleClose);
1484
+ return mockRpc;
1249
1485
  };
1250
- class Ipc extends EventTarget {
1251
- constructor(rawIpc) {
1252
- super();
1253
- this._rawIpc = rawIpc;
1254
- attachEvents(this);
1255
- }
1256
- }
1257
- const E_INCOMPATIBLE_NATIVE_MODULE = 'E_INCOMPATIBLE_NATIVE_MODULE';
1258
- const E_MODULES_NOT_SUPPORTED_IN_ELECTRON = 'E_MODULES_NOT_SUPPORTED_IN_ELECTRON';
1259
- const ERR_MODULE_NOT_FOUND = 'ERR_MODULE_NOT_FOUND';
1260
- const NewLine$1 = '\n';
1261
- const joinLines$1 = lines => {
1262
- return lines.join(NewLine$1);
1486
+
1487
+ const rpcs = Object.create(null);
1488
+ const set$a = (id, rpc) => {
1489
+ rpcs[id] = rpc;
1263
1490
  };
1264
- const RE_AT = /^\s+at/;
1265
- const RE_AT_PROMISE_INDEX = /^\s*at async Promise.all \(index \d+\)$/;
1266
- const isNormalStackLine = line => {
1267
- return RE_AT.test(line) && !RE_AT_PROMISE_INDEX.test(line);
1491
+ const get$3 = id => {
1492
+ return rpcs[id];
1268
1493
  };
1269
- const getDetails = lines => {
1270
- const index = lines.findIndex(isNormalStackLine);
1271
- if (index === -1) {
1272
- return {
1273
- actualMessage: joinLines$1(lines),
1274
- rest: []
1275
- };
1276
- }
1277
- let lastIndex = index - 1;
1278
- while (++lastIndex < lines.length) {
1279
- if (!isNormalStackLine(lines[lastIndex])) {
1280
- break;
1281
- }
1282
- }
1494
+ const remove$1 = id => {
1495
+ delete rpcs[id];
1496
+ };
1497
+
1498
+ /* eslint-disable @typescript-eslint/explicit-function-return-type */
1499
+ const create$a = rpcId => {
1283
1500
  return {
1284
- actualMessage: lines[index - 1],
1285
- rest: lines.slice(index, lastIndex)
1501
+ async dispose() {
1502
+ const rpc = get$3(rpcId);
1503
+ await rpc.dispose();
1504
+ },
1505
+ // @ts-ignore
1506
+ invoke(method, ...params) {
1507
+ const rpc = get$3(rpcId);
1508
+ // @ts-ignore
1509
+ return rpc.invoke(method, ...params);
1510
+ },
1511
+ // @ts-ignore
1512
+ invokeAndTransfer(method, ...params) {
1513
+ const rpc = get$3(rpcId);
1514
+ // @ts-ignore
1515
+ return rpc.invokeAndTransfer(method, ...params);
1516
+ },
1517
+ registerMockRpc(commandMap) {
1518
+ const mockRpc = createMockRpc({
1519
+ commandMap
1520
+ });
1521
+ set$a(rpcId, mockRpc);
1522
+ // @ts-ignore
1523
+ mockRpc[Symbol.dispose] = () => {
1524
+ remove$1(rpcId);
1525
+ };
1526
+ // @ts-ignore
1527
+ return mockRpc;
1528
+ },
1529
+ set(rpc) {
1530
+ set$a(rpcId, rpc);
1531
+ }
1286
1532
  };
1287
1533
  };
1288
- const splitLines$1 = lines => {
1289
- return lines.split(NewLine$1);
1534
+
1535
+ const {
1536
+ invoke: invoke$5,
1537
+ set: set$9
1538
+ } = create$a(ExtensionHostWorker);
1539
+ const getRuntimeStatus$2 = async extensionId => {
1540
+ // @ts-ignore
1541
+ return invoke$5('ExtensionHost.getRuntimeStatus', extensionId);
1290
1542
  };
1291
- const RE_MESSAGE_CODE_BLOCK_START = /^Error: The module '.*'$/;
1292
- const RE_MESSAGE_CODE_BLOCK_END = /^\s* at/;
1293
- const isMessageCodeBlockStartIndex = line => {
1294
- return RE_MESSAGE_CODE_BLOCK_START.test(line);
1543
+
1544
+ const ExtensionHost = {
1545
+ __proto__: null,
1546
+ getRuntimeStatus: getRuntimeStatus$2,
1547
+ invoke: invoke$5,
1548
+ set: set$9
1295
1549
  };
1296
- const isMessageCodeBlockEndIndex = line => {
1297
- return RE_MESSAGE_CODE_BLOCK_END.test(line);
1550
+
1551
+ const {
1552
+ invoke: invoke$4,
1553
+ set: set$8
1554
+ } = create$a(ExtensionManagementWorker);
1555
+ const enable2 = (id, platform) => {
1556
+ return invoke$4(`Extensions.enable2`, id, platform);
1298
1557
  };
1299
- const getMessageCodeBlock = stderr => {
1300
- const lines = splitLines$1(stderr);
1301
- const startIndex = lines.findIndex(isMessageCodeBlockStartIndex);
1302
- const endIndex = startIndex + lines.slice(startIndex).findIndex(isMessageCodeBlockEndIndex, startIndex);
1303
- const relevantLines = lines.slice(startIndex, endIndex);
1304
- const relevantMessage = relevantLines.join(' ').slice('Error: '.length);
1305
- return relevantMessage;
1558
+ const disable2 = (id, platform) => {
1559
+ return invoke$4(`Extensions.disable2`, id, platform);
1306
1560
  };
1307
- const isModuleNotFoundMessage = line => {
1308
- return line.includes('[ERR_MODULE_NOT_FOUND]');
1561
+
1562
+ const {
1563
+ invoke: invoke$3,
1564
+ set: set$7
1565
+ } = create$a(FileSystemWorker$1);
1566
+ const readFile$2 = async uri => {
1567
+ return invoke$3('FileSystem.readFile', uri);
1309
1568
  };
1310
- const getModuleNotFoundError = stderr => {
1311
- const lines = splitLines$1(stderr);
1312
- const messageIndex = lines.findIndex(isModuleNotFoundMessage);
1313
- const message = lines[messageIndex];
1314
- return {
1315
- code: ERR_MODULE_NOT_FOUND,
1316
- message
1317
- };
1569
+ const exists$1 = async uri => {
1570
+ return invoke$3('FileSystem.exists', uri);
1318
1571
  };
1319
- const isModuleNotFoundError = stderr => {
1320
- if (!stderr) {
1321
- return false;
1322
- }
1323
- return stderr.includes('ERR_MODULE_NOT_FOUND');
1572
+
1573
+ const FileSystemWorker = {
1574
+ __proto__: null,
1575
+ exists: exists$1,
1576
+ invoke: invoke$3,
1577
+ readFile: readFile$2,
1578
+ set: set$7
1324
1579
  };
1325
- const isModulesSyntaxError = stderr => {
1326
- if (!stderr) {
1327
- return false;
1328
- }
1329
- return stderr.includes('SyntaxError: Cannot use import statement outside a module');
1580
+
1581
+ const {
1582
+ invoke: invoke$2,
1583
+ set: set$6
1584
+ } = create$a(MarkdownWorker$1);
1585
+ const getVirtualDom$1 = async html => {
1586
+ // @ts-ignore
1587
+ return invoke$2('Markdown.getVirtualDom', html);
1330
1588
  };
1331
- const RE_NATIVE_MODULE_ERROR = /^innerError Error: Cannot find module '.*.node'/;
1332
- const RE_NATIVE_MODULE_ERROR_2 = /was compiled against a different Node.js version/;
1333
- const isUnhelpfulNativeModuleError = stderr => {
1334
- return RE_NATIVE_MODULE_ERROR.test(stderr) && RE_NATIVE_MODULE_ERROR_2.test(stderr);
1589
+ const render$1 = async (markdown, options) => {
1590
+ // @ts-ignore
1591
+ return invoke$2('Markdown.render', markdown, options);
1335
1592
  };
1336
- const getNativeModuleErrorMessage = stderr => {
1337
- const message = getMessageCodeBlock(stderr);
1338
- return {
1339
- code: E_INCOMPATIBLE_NATIVE_MODULE,
1340
- message: `Incompatible native node module: ${message}`
1341
- };
1593
+
1594
+ const MarkdownWorker = {
1595
+ __proto__: null,
1596
+ getVirtualDom: getVirtualDom$1,
1597
+ invoke: invoke$2,
1598
+ render: render$1,
1599
+ set: set$6
1342
1600
  };
1343
- const getModuleSyntaxError = () => {
1344
- return {
1345
- code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON,
1346
- message: `ES Modules are not supported in electron`
1347
- };
1601
+
1602
+ const {
1603
+ invoke: invoke$1,
1604
+ invokeAndTransfer,
1605
+ set: set$5
1606
+ } = create$a(RendererWorker);
1607
+ const showContextMenu2 = async (uid, menuId, x, y, args) => {
1608
+ number(uid);
1609
+ number(menuId);
1610
+ number(x);
1611
+ number(y);
1612
+ await invoke$1('ContextMenu.show2', uid, menuId, x, y, args);
1348
1613
  };
1349
- const getHelpfulChildProcessError = (stdout, stderr) => {
1350
- if (isUnhelpfulNativeModuleError(stderr)) {
1351
- return getNativeModuleErrorMessage(stderr);
1352
- }
1353
- if (isModulesSyntaxError(stderr)) {
1354
- return getModuleSyntaxError();
1355
- }
1356
- if (isModuleNotFoundError(stderr)) {
1357
- return getModuleNotFoundError(stderr);
1358
- }
1359
- const lines = splitLines$1(stderr);
1360
- const {
1361
- actualMessage,
1362
- rest
1363
- } = getDetails(lines);
1364
- return {
1365
- code: '',
1366
- message: actualMessage,
1367
- stack: rest
1368
- };
1614
+ const setColorTheme$1 = async id => {
1615
+ return invoke$1(/* ColorTheme.setColorTheme */'ColorTheme.setColorTheme', /* colorThemeId */id);
1369
1616
  };
1370
- class IpcError extends VError {
1371
- // @ts-ignore
1372
- constructor(betterMessage, stdout = '', stderr = '') {
1373
- if (stdout || stderr) {
1374
- // @ts-ignore
1375
- const {
1376
- code,
1377
- message,
1378
- stack
1379
- } = getHelpfulChildProcessError(stdout, stderr);
1380
- const cause = new Error(message);
1381
- // @ts-ignore
1382
- cause.code = code;
1383
- cause.stack = stack;
1384
- super(cause, betterMessage);
1385
- } else {
1386
- super(betterMessage);
1387
- }
1388
- // @ts-ignore
1389
- this.name = 'IpcError';
1390
- // @ts-ignore
1391
- this.stdout = stdout;
1392
- // @ts-ignore
1393
- this.stderr = stderr;
1394
- }
1395
- }
1396
- const readyMessage = 'ready';
1397
- const getData$2 = event => {
1398
- return event.data;
1617
+ const sendMessagePortToMarkdownWorker$1 = async (port, rpcId) => {
1618
+ const command = 'Markdown.handleMessagePort';
1619
+ await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToMarkdownWorker', port, command, rpcId);
1399
1620
  };
1400
- const listen$7 = () => {
1401
- // @ts-ignore
1402
- if (typeof WorkerGlobalScope === 'undefined') {
1403
- throw new TypeError('module is not in web worker scope');
1404
- }
1405
- return globalThis;
1621
+ const sendMessagePortToFileSystemWorker$1 = async (port, rpcId) => {
1622
+ const command = 'FileSystem.handleMessagePort';
1623
+ await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToFileSystemWorker', port, command, rpcId);
1406
1624
  };
1407
- const signal$8 = global => {
1408
- global.postMessage(readyMessage);
1625
+ const sendMessagePortToExtensionHostWorker$1 = async (port, rpcId = 0) => {
1626
+ const command = 'HandleMessagePort.handleMessagePort2';
1627
+ await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', port, command, rpcId);
1409
1628
  };
1410
- class IpcChildWithModuleWorker extends Ipc {
1411
- getData(event) {
1412
- return getData$2(event);
1413
- }
1414
- send(message) {
1415
- // @ts-ignore
1416
- this._rawIpc.postMessage(message);
1417
- }
1418
- sendAndTransfer(message) {
1419
- const transfer = getTransferrables(message);
1420
- // @ts-ignore
1421
- this._rawIpc.postMessage(message, transfer);
1422
- }
1423
- dispose() {
1424
- // ignore
1425
- }
1426
- onClose(callback) {
1427
- // ignore
1428
- }
1429
- onMessage(callback) {
1430
- this._rawIpc.addEventListener('message', callback);
1431
- }
1432
- }
1433
- const wrap$f = global => {
1434
- return new IpcChildWithModuleWorker(global);
1629
+ const confirm = async (message, options) => {
1630
+ const result = await invoke$1('ConfirmPrompt.prompt', message, options);
1631
+ return result;
1435
1632
  };
1436
- const waitForFirstMessage = async port => {
1437
- const {
1438
- promise,
1439
- resolve
1440
- } = Promise.withResolvers();
1441
- port.addEventListener('message', resolve, {
1442
- once: true
1443
- });
1444
- const event = await promise;
1445
- // @ts-ignore
1446
- return event.data;
1633
+ const writeClipBoardText = async text => {
1634
+ await invoke$1('ClipBoard.writeText', /* text */text);
1447
1635
  };
1448
- const listen$6 = async () => {
1449
- const parentIpcRaw = listen$7();
1450
- signal$8(parentIpcRaw);
1451
- const parentIpc = wrap$f(parentIpcRaw);
1452
- const firstMessage = await waitForFirstMessage(parentIpc);
1453
- if (firstMessage.method !== 'initialize') {
1454
- throw new IpcError('unexpected first message');
1455
- }
1456
- const type = firstMessage.params[0];
1457
- if (type === 'message-port') {
1458
- parentIpc.send({
1459
- id: firstMessage.id,
1460
- jsonrpc: '2.0',
1461
- result: null
1462
- });
1463
- parentIpc.dispose();
1464
- const port = firstMessage.params[1];
1465
- return port;
1466
- }
1467
- return globalThis;
1636
+ const writeClipBoardImage = async blob => {
1637
+ await invoke$1('ClipBoard.writeImage', /* text */blob);
1468
1638
  };
1469
- class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
1470
- getData(event) {
1471
- return getData$2(event);
1472
- }
1473
- send(message) {
1474
- this._rawIpc.postMessage(message);
1475
- }
1476
- sendAndTransfer(message) {
1477
- const transfer = getTransferrables(message);
1478
- this._rawIpc.postMessage(message, transfer);
1479
- }
1480
- dispose() {
1481
- if (this._rawIpc.close) {
1482
- this._rawIpc.close();
1483
- }
1484
- }
1485
- onClose(callback) {
1486
- // ignore
1487
- }
1488
- onMessage(callback) {
1489
- this._rawIpc.addEventListener('message', callback);
1490
- this._rawIpc.start();
1491
- }
1492
- }
1493
- const wrap$e = port => {
1494
- return new IpcChildWithModuleWorkerAndMessagePort(port);
1639
+ const sendMessagePortToExtensionManagementWorker = async (port, rpcId) => {
1640
+ const command = 'Extensions.handleMessagePort';
1641
+ await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionManagementWorker', port, command, rpcId);
1495
1642
  };
1496
- const IpcChildWithModuleWorkerAndMessagePort$1 = {
1497
- __proto__: null,
1498
- listen: listen$6,
1499
- wrap: wrap$e
1643
+ const getPreference = async key => {
1644
+ return await invoke$1('Preferences.get', key);
1500
1645
  };
1501
- const addListener = (emitter, type, callback) => {
1502
- if ('addEventListener' in emitter) {
1503
- emitter.addEventListener(type, callback);
1504
- } else {
1505
- emitter.on(type, callback);
1506
- }
1646
+ const getAllExtensions$1 = async () => {
1647
+ return invoke$1('ExtensionManagement.getAllExtensions');
1507
1648
  };
1508
- const removeListener = (emitter, type, callback) => {
1509
- if ('removeEventListener' in emitter) {
1510
- emitter.removeEventListener(type, callback);
1511
- } else {
1512
- emitter.off(type, callback);
1513
- }
1649
+ const getExtension$2 = async id => {
1650
+ return invoke$1('ExtensionManagement.getExtension', id);
1514
1651
  };
1515
- const getFirstEvent = (eventEmitter, eventMap) => {
1516
- const {
1517
- promise,
1518
- resolve
1519
- } = Promise.withResolvers();
1520
- const listenerMap = Object.create(null);
1521
- const cleanup = value => {
1522
- for (const event of Object.keys(eventMap)) {
1523
- removeListener(eventEmitter, event, listenerMap[event]);
1524
- }
1525
- resolve(value);
1526
- };
1527
- for (const [event, type] of Object.entries(eventMap)) {
1528
- const listener = event => {
1529
- cleanup({
1530
- event,
1531
- type
1532
- });
1533
- };
1534
- addListener(eventEmitter, event, listener);
1535
- listenerMap[event] = listener;
1536
- }
1537
- return promise;
1652
+ const openNativeFolder = async uri => {
1653
+ await invoke$1('OpenNativeFolder.openNativeFolder', uri);
1538
1654
  };
1539
- const Message$1 = 3;
1540
- const create$5$1 = async ({
1541
- isMessagePortOpen,
1542
- messagePort
1543
- }) => {
1544
- if (!isMessagePort(messagePort)) {
1545
- throw new IpcError('port must be of type MessagePort');
1546
- }
1547
- if (isMessagePortOpen) {
1548
- return messagePort;
1549
- }
1550
- const eventPromise = getFirstEvent(messagePort, {
1551
- message: Message$1
1552
- });
1553
- messagePort.start();
1554
- const {
1555
- event,
1556
- type
1557
- } = await eventPromise;
1558
- if (type !== Message$1) {
1559
- throw new IpcError('Failed to wait for ipc message');
1560
- }
1561
- if (event.data !== readyMessage) {
1562
- throw new IpcError('unexpected first message');
1563
- }
1564
- return messagePort;
1655
+ const uninstallExtension = async id => {
1656
+ return invoke$1('ExtensionManagement.uninstall', id);
1565
1657
  };
1566
- const signal$1 = messagePort => {
1567
- messagePort.start();
1658
+ const openExtensionSearch$1 = async () => {
1659
+ return invoke$1('SideBar.openViewlet', 'Extensions');
1568
1660
  };
1569
- class IpcParentWithMessagePort extends Ipc {
1570
- getData = getData$2;
1571
- send(message) {
1572
- this._rawIpc.postMessage(message);
1573
- }
1574
- sendAndTransfer(message) {
1575
- const transfer = getTransferrables(message);
1576
- this._rawIpc.postMessage(message, transfer);
1577
- }
1578
- dispose() {
1579
- this._rawIpc.close();
1580
- }
1581
- onMessage(callback) {
1582
- this._rawIpc.addEventListener('message', callback);
1583
- }
1584
- onClose(callback) {}
1585
- }
1586
- const wrap$5 = messagePort => {
1587
- return new IpcParentWithMessagePort(messagePort);
1661
+ const setExtensionsSearchValue = async searchValue => {
1662
+ return invoke$1('Extensions.handleInput', searchValue, Script$1);
1588
1663
  };
1589
- const IpcParentWithMessagePort$1 = {
1590
- __proto__: null,
1591
- create: create$5$1,
1592
- signal: signal$1,
1593
- wrap: wrap$5
1664
+ const openExternal$1 = async uri => {
1665
+ await invoke$1('Open.openExternal', uri);
1666
+ };
1667
+ const openUrl = async uri => {
1668
+ await invoke$1('Open.openUrl', uri);
1594
1669
  };
1595
1670
 
1596
- const Two$1 = '2.0';
1597
- const callbacks = Object.create(null);
1598
- const get$2 = id => {
1599
- return callbacks[id];
1671
+ /* eslint-disable unicorn/prefer-export-from */
1672
+
1673
+ const {
1674
+ getRuntimeStatus: getRuntimeStatus$1,
1675
+ set: set$4
1676
+ } = ExtensionHost;
1677
+
1678
+ const getRuntimeStatus = async extensionId => {
1679
+ // @ts-ignore
1680
+ const status = await getRuntimeStatus$1(extensionId);
1681
+ // @ts-ignore
1682
+ return status;
1600
1683
  };
1601
- const remove$1 = id => {
1602
- delete callbacks[id];
1684
+
1685
+ const getRuntimeStatusDetails = async extension => {
1686
+ const {
1687
+ activationEvent,
1688
+ activationTime,
1689
+ importTime,
1690
+ status
1691
+ } = await getRuntimeStatus(extension.id);
1692
+ return {
1693
+ activationTime,
1694
+ importTime,
1695
+ status,
1696
+ wasActivatedByEvent: activationEvent
1697
+ };
1603
1698
  };
1604
- class JsonRpcError extends Error {
1605
- constructor(message) {
1606
- super(message);
1607
- this.name = 'JsonRpcError';
1608
- }
1609
- }
1610
- const NewLine = '\n';
1611
- const DomException = 'DOMException';
1612
- const ReferenceError$1 = 'ReferenceError';
1613
- const SyntaxError$1 = 'SyntaxError';
1614
- const TypeError$1 = 'TypeError';
1615
- const getErrorConstructor = (message, type) => {
1616
- if (type) {
1617
- switch (type) {
1618
- case DomException:
1619
- return DOMException;
1620
- case TypeError$1:
1621
- return TypeError;
1622
- case SyntaxError$1:
1623
- return SyntaxError;
1624
- case ReferenceError$1:
1625
- return ReferenceError;
1626
- default:
1627
- return Error;
1628
- }
1629
- }
1630
- if (message.startsWith('TypeError: ')) {
1631
- return TypeError;
1632
- }
1633
- if (message.startsWith('SyntaxError: ')) {
1634
- return SyntaxError;
1699
+
1700
+ const featureRuntimeStatusEnabled = extension => {
1701
+ if (!extension || typeof extension !== 'object') {
1702
+ return false;
1635
1703
  }
1636
- if (message.startsWith('ReferenceError: ')) {
1637
- return ReferenceError;
1704
+ if ('main' in extension || 'browser' in extension) {
1705
+ return true;
1638
1706
  }
1639
- return Error;
1707
+ return false;
1640
1708
  };
1641
- const constructError = (message, type, name) => {
1642
- const ErrorConstructor = getErrorConstructor(message, type);
1643
- if (ErrorConstructor === DOMException && name) {
1644
- return new ErrorConstructor(message, name);
1645
- }
1646
- if (ErrorConstructor === Error) {
1647
- const error = new Error(message);
1648
- if (name && name !== 'VError') {
1649
- error.name = name;
1650
- }
1651
- return error;
1652
- }
1653
- return new ErrorConstructor(message);
1654
- };
1655
- const joinLines = lines => {
1656
- return lines.join(NewLine);
1657
- };
1658
- const splitLines = lines => {
1659
- return lines.split(NewLine);
1660
- };
1661
- const getCurrentStack = () => {
1662
- const stackLinesToSkip = 3;
1663
- const currentStack = joinLines(splitLines(new Error().stack || '').slice(stackLinesToSkip));
1664
- return currentStack;
1665
- };
1666
- const getNewLineIndex = (string, startIndex = undefined) => {
1667
- return string.indexOf(NewLine, startIndex);
1709
+
1710
+ const formatTime = time => {
1711
+ return time.toFixed(2) + 'ms';
1668
1712
  };
1669
- const getParentStack = error => {
1670
- let parentStack = error.stack || error.data || error.message || '';
1671
- if (parentStack.startsWith(' at')) {
1672
- parentStack = error.message + NewLine + parentStack;
1713
+
1714
+ const getActivationTimeVirtualDom = (importTime$1, activationTime$1) => {
1715
+ if (!activationTime$1 && !importTime$1) {
1716
+ return [];
1673
1717
  }
1674
- return parentStack;
1718
+ const formattedImportTime = formatTime(importTime$1);
1719
+ const formattedTime = formatTime(activationTime$1);
1720
+ return [{
1721
+ childCount: 1,
1722
+ type: Dt
1723
+ }, text(importTime()), {
1724
+ childCount: 1,
1725
+ type: Dd
1726
+ }, text(formattedImportTime), {
1727
+ childCount: 1,
1728
+ type: Dt
1729
+ }, text(activationTime()), {
1730
+ childCount: 1,
1731
+ type: Dd
1732
+ }, text(formattedTime)];
1675
1733
  };
1676
- const MethodNotFound = -32601;
1677
- const Custom = -32001;
1678
- const restoreJsonRpcError = error => {
1679
- const currentStack = getCurrentStack();
1680
- if (error && error instanceof Error) {
1681
- if (typeof error.stack === 'string') {
1682
- error.stack = error.stack + NewLine + currentStack;
1683
- }
1684
- return error;
1685
- }
1686
- if (error && error.code && error.code === MethodNotFound) {
1687
- const restoredError = new JsonRpcError(error.message);
1688
- const parentStack = getParentStack(error);
1689
- restoredError.stack = parentStack + NewLine + currentStack;
1690
- return restoredError;
1691
- }
1692
- if (error && error.message) {
1693
- const restoredError = constructError(error.message, error.type, error.name);
1694
- if (error.data) {
1695
- if (error.data.stack && error.data.type && error.message) {
1696
- restoredError.stack = error.data.type + ': ' + error.message + NewLine + error.data.stack + NewLine + currentStack;
1697
- } else if (error.data.stack) {
1698
- restoredError.stack = error.data.stack;
1699
- }
1700
- if (error.data.codeFrame) {
1701
- // @ts-ignore
1702
- restoredError.codeFrame = error.data.codeFrame;
1703
- }
1704
- if (error.data.code) {
1705
- // @ts-ignore
1706
- restoredError.code = error.data.code;
1707
- }
1708
- if (error.data.type) {
1709
- // @ts-ignore
1710
- restoredError.name = error.data.type;
1711
- }
1712
- } else {
1713
- if (error.stack) {
1714
- const lowerStack = restoredError.stack || '';
1715
- // @ts-ignore
1716
- const indexNewLine = getNewLineIndex(lowerStack);
1717
- const parentStack = getParentStack(error);
1718
- // @ts-ignore
1719
- restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
1720
- }
1721
- if (error.codeFrame) {
1722
- // @ts-ignore
1723
- restoredError.codeFrame = error.codeFrame;
1724
- }
1725
- }
1726
- return restoredError;
1727
- }
1728
- if (typeof error === 'string') {
1729
- return new Error(`JsonRpc Error: ${error}`);
1734
+
1735
+ const None$1 = 0;
1736
+ const Importing = 1;
1737
+ const Activating = 2;
1738
+ const Activated = 3;
1739
+ const Error$1 = 4;
1740
+
1741
+ const getStatusMessage = statusType => {
1742
+ switch (statusType) {
1743
+ case Activated:
1744
+ return 'activated';
1745
+ case Activating:
1746
+ return 'Activating';
1747
+ case Error$1:
1748
+ return 'error';
1749
+ case Importing:
1750
+ return 'importing';
1751
+ case None$1:
1752
+ return 'none';
1753
+ default:
1754
+ return 'unknown';
1730
1755
  }
1731
- return new Error(`JsonRpc Error: ${error}`);
1732
1756
  };
1733
- const unwrapJsonRpcResult = responseMessage => {
1734
- if ('error' in responseMessage) {
1735
- const restoredError = restoreJsonRpcError(responseMessage.error);
1736
- throw restoredError;
1737
- }
1738
- if ('result' in responseMessage) {
1739
- return responseMessage.result;
1740
- }
1741
- throw new JsonRpcError('unexpected response message');
1757
+
1758
+ const key = {
1759
+ childCount: 1,
1760
+ className: 'RuntimeStatusDefinitionListKey',
1761
+ type: Dt
1742
1762
  };
1743
- const warn = (...args) => {
1744
- console.warn(...args);
1763
+ const value = {
1764
+ childCount: 1,
1765
+ className: 'RuntimeStatusDefinitionListValue',
1766
+ type: Dd
1745
1767
  };
1746
- const resolve = (id, response) => {
1747
- const fn = get$2(id);
1748
- if (!fn) {
1749
- console.log(response);
1750
- warn(`callback ${id} may already be disposed`);
1751
- return;
1752
- }
1753
- fn(response);
1754
- remove$1(id);
1768
+ const getStatusVirtualDom = status$1 => {
1769
+ const statusKey = status();
1770
+ const statusValue = getStatusMessage(status$1);
1771
+ return [key, text(`${statusKey}: `), value, text(`${statusValue}`)];
1755
1772
  };
1756
- const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
1757
- const getErrorType = prettyError => {
1758
- if (prettyError && prettyError.type) {
1759
- return prettyError.type;
1760
- }
1761
- if (prettyError && prettyError.constructor && prettyError.constructor.name) {
1762
- return prettyError.constructor.name;
1773
+
1774
+ const getChildCount$1 = (status, activationTime, importTime) => {
1775
+ let childCount = 0;
1776
+ childCount += 2; // status
1777
+ if (importTime || activationTime) {
1778
+ childCount += 4;
1763
1779
  }
1764
- return undefined;
1765
- };
1766
- const isAlreadyStack = line => {
1767
- return line.trim().startsWith('at ');
1780
+ return childCount;
1768
1781
  };
1769
- const getStack = prettyError => {
1770
- const stackString = prettyError.stack || '';
1771
- const newLineIndex = stackString.indexOf('\n');
1772
- if (newLineIndex !== -1 && !isAlreadyStack(stackString.slice(0, newLineIndex))) {
1773
- return stackString.slice(newLineIndex + 1);
1774
- }
1775
- return stackString;
1782
+ const getRuntimeStatusVirtualDom = state => {
1783
+ const {
1784
+ activationTime,
1785
+ importTime,
1786
+ status
1787
+ } = state;
1788
+ const heading = runtimeStatus();
1789
+ const childCount = getChildCount$1(status, activationTime, importTime);
1790
+ return [{
1791
+ childCount: 2,
1792
+ className: FeatureContent,
1793
+ type: Div
1794
+ }, ...getFeatureContentHeadingVirtualDom(heading), {
1795
+ childCount,
1796
+ className: 'RuntimeStatusDefinitionList',
1797
+ type: Dl
1798
+ }, ...getStatusVirtualDom(status), ...getActivationTimeVirtualDom(activationTime, importTime)];
1776
1799
  };
1777
- const getErrorProperty = (error, prettyError) => {
1778
- if (error && error.code === E_COMMAND_NOT_FOUND) {
1779
- return {
1780
- code: MethodNotFound,
1781
- message: error.message,
1782
- data: error.stack
1783
- };
1784
- }
1785
- return {
1786
- code: Custom,
1787
- message: prettyError.message,
1788
- data: {
1789
- stack: getStack(prettyError),
1790
- codeFrame: prettyError.codeFrame,
1791
- type: getErrorType(prettyError),
1792
- code: prettyError.code,
1793
- name: prettyError.name
1794
- }
1795
- };
1800
+
1801
+ const getSettingsTableEntry = setting => {
1802
+ const {
1803
+ id,
1804
+ label
1805
+ } = setting;
1806
+ // TODO watch out for null/undefined/number/string/array
1807
+ return [{
1808
+ type: Text,
1809
+ value: id
1810
+ }, {
1811
+ type: Text,
1812
+ value: label
1813
+ }];
1796
1814
  };
1797
- const create$1$1 = (id, error) => {
1815
+
1816
+ const getSettingsDetails = async extension => {
1817
+ const settings = extension.settings || [];
1818
+ const rows = settings.map(getSettingsTableEntry);
1798
1819
  return {
1799
- jsonrpc: Two$1,
1800
- id,
1801
- error
1820
+ settings: rows
1802
1821
  };
1803
1822
  };
1804
- const getErrorResponse = (id, error, preparePrettyError, logError) => {
1805
- const prettyError = preparePrettyError(error);
1806
- logError(error, prettyError);
1807
- const errorProperty = getErrorProperty(error, prettyError);
1808
- return create$1$1(id, errorProperty);
1823
+
1824
+ const featureSettingsEnabled = extension => {
1825
+ if (!hasProperty(extension, 'settings')) {
1826
+ return false;
1827
+ }
1828
+ return Array.isArray(extension.settings);
1809
1829
  };
1810
- const create$3 = (message, result) => {
1830
+
1831
+ const getSettingsTableEntries = rows => {
1832
+ const textId = id$1();
1833
+ const textLabel = label();
1811
1834
  return {
1812
- jsonrpc: Two$1,
1813
- id: message.id,
1814
- result: result ?? null
1835
+ headings: [textId, textLabel],
1836
+ rows
1815
1837
  };
1816
1838
  };
1817
- const getSuccessResponse = (message, result) => {
1818
- const resultProperty = result ?? null;
1819
- return create$3(message, resultProperty);
1820
- };
1821
- const getErrorResponseSimple = (id, error) => {
1822
- return {
1823
- jsonrpc: Two$1,
1824
- id,
1825
- error: {
1826
- code: Custom,
1827
- // @ts-ignore
1828
- message: error.message,
1829
- data: error
1830
- }
1831
- };
1832
- };
1833
- const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
1834
- try {
1835
- const result = requiresSocket(message.method) ? await execute(message.method, ipc, ...message.params) : await execute(message.method, ...message.params);
1836
- return getSuccessResponse(message, result);
1837
- } catch (error) {
1838
- if (ipc.canUseSimpleErrorResponse) {
1839
- return getErrorResponseSimple(message.id, error);
1840
- }
1841
- return getErrorResponse(message.id, error, preparePrettyError, logError);
1842
- }
1843
- };
1844
- const defaultPreparePrettyError = error => {
1845
- return error;
1839
+
1840
+ const getFeatureSettingsVirtualDom = rows => {
1841
+ const heading = settings();
1842
+ const tableInfo = getSettingsTableEntries(rows);
1843
+ return [{
1844
+ childCount: 2,
1845
+ className: FeatureContent,
1846
+ type: Div
1847
+ }, ...getFeatureContentHeadingVirtualDom(heading), ...getTableVirtualDom(tableInfo)];
1846
1848
  };
1847
- const defaultLogError = () => {
1848
- // ignore
1849
+
1850
+ const getSettingsVirtualDom = state => {
1851
+ return getFeatureSettingsVirtualDom(state.settings);
1849
1852
  };
1850
- const defaultRequiresSocket = () => {
1851
- return false;
1853
+
1854
+ const HandleClickCategory = 1;
1855
+ const HandleClickDisable = 2;
1856
+ const HandleClickEnable = 3;
1857
+ const HandleClickScrollToTop = 4;
1858
+ const HandleClickSetColorTheme = 5;
1859
+ const HandleClickSettings = 6;
1860
+ const HandleClickSize = 7;
1861
+ const HandleClickUninstall = 8;
1862
+ const HandleFeaturesClick = 9;
1863
+ const HandleIconError = 10;
1864
+ const HandleImageContextMenu = 11;
1865
+ const HandleReadmeContextMenu = 12;
1866
+ const HandleReadmeScroll = 13;
1867
+ const HandleTabsClick = 14;
1868
+ const HandleAdditionalDetailContextMenu = 15;
1869
+ const HandleReadmeClick = 16;
1870
+ const HandleSelectionChange = 17;
1871
+ const HandleTabFocus = 18;
1872
+ const HandleResourceLinkClick = 19;
1873
+
1874
+ const ActivationEvents = 'ActivationEvents';
1875
+ const Changelog = 'Changelog';
1876
+ const Commands = 'Commands';
1877
+ const Details = 'Details';
1878
+ const Enable = 'Enable';
1879
+ const Disable = 'Disable';
1880
+ const Features = 'Features';
1881
+ const JsonValidation = 'JsonValidation';
1882
+ const ProgrammingLanguages = 'ProgrammingLanguages';
1883
+ const RuntimeStatus = 'RuntimeStatus';
1884
+ const ScrollToTop = 'scrolltotop';
1885
+ const SetColorTheme = 'SetColorTheme';
1886
+ const Settings = 'Settings';
1887
+ const Theme = 'Theme';
1888
+ const Uninstall = 'Uninstall';
1889
+ const WebViews = 'WebViews';
1890
+
1891
+ const getScrollToTopVirtualDom = scrollToTopButtonEnabled => {
1892
+ return [{
1893
+ ariaLabel: scrollToTop(),
1894
+ childCount: 1,
1895
+ className: ScrollToTopButton,
1896
+ name: ScrollToTop,
1897
+ onClick: HandleClickScrollToTop,
1898
+ type: Button$1
1899
+ }, {
1900
+ childCount: 0,
1901
+ className: mergeClassNames(MaskIcon, MaskIconChevronUp),
1902
+ role: None$3,
1903
+ type: Div
1904
+ }];
1852
1905
  };
1853
- const defaultResolve = resolve;
1854
1906
 
1855
- // TODO maybe remove this in v6 or v7, only accept options object to simplify the code
1856
- const normalizeParams = args => {
1857
- if (args.length === 1) {
1858
- const options = args[0];
1859
- return {
1860
- ipc: options.ipc,
1861
- message: options.message,
1862
- execute: options.execute,
1863
- resolve: options.resolve || defaultResolve,
1864
- preparePrettyError: options.preparePrettyError || defaultPreparePrettyError,
1865
- logError: options.logError || defaultLogError,
1866
- requiresSocket: options.requiresSocket || defaultRequiresSocket
1867
- };
1907
+ /* eslint-disable unicorn/prefer-export-from */
1908
+
1909
+ const {
1910
+ getVirtualDom,
1911
+ render,
1912
+ set: set$3
1913
+ } = MarkdownWorker;
1914
+
1915
+ const getMarkdownVirtualDom = async (html, options) => {
1916
+ string(html);
1917
+ const dom = await getVirtualDom(html);
1918
+ if (options?.scrollToTopEnabled) {
1919
+ const [firstNode, ...rest] = dom;
1920
+ const extraDom = getScrollToTopVirtualDom();
1921
+ return [{
1922
+ ...firstNode,
1923
+ childCount: firstNode.childCount + 1,
1924
+ onClick: HandleReadmeClick,
1925
+ onScroll: HandleReadmeScroll,
1926
+ onSelectionChange: HandleSelectionChange
1927
+ }, ...extraDom, ...rest];
1868
1928
  }
1869
- return {
1870
- ipc: args[0],
1871
- message: args[1],
1872
- execute: args[2],
1873
- resolve: args[3],
1874
- preparePrettyError: args[4],
1875
- logError: args[5],
1876
- requiresSocket: args[6]
1877
- };
1929
+ return dom;
1878
1930
  };
1879
- const handleJsonRpcMessage = async (...args) => {
1880
- const options = normalizeParams(args);
1881
- const {
1882
- message,
1883
- ipc,
1884
- execute,
1885
- resolve,
1886
- preparePrettyError,
1887
- logError,
1888
- requiresSocket
1889
- } = options;
1890
- if ('id' in message) {
1891
- if ('method' in message) {
1892
- const response = await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
1893
- try {
1894
- ipc.send(response);
1895
- } catch (error) {
1896
- const errorResponse = getErrorResponse(message.id, error, preparePrettyError, logError);
1897
- ipc.send(errorResponse);
1898
- }
1899
- return;
1931
+
1932
+ const getThemeItemMarkdown = (heading, items) => {
1933
+ let markdown = '';
1934
+ if (items.length > 0) {
1935
+ markdown += `### ${heading}`;
1936
+ markdown += '\n\n';
1937
+ for (const item of items) {
1938
+ markdown += `- ${item.label}`;
1939
+ markdown += '\n';
1900
1940
  }
1901
- resolve(message.id, message);
1902
- return;
1903
- }
1904
- if ('method' in message) {
1905
- await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
1906
- return;
1907
1941
  }
1908
- throw new JsonRpcError('unexpected message');
1942
+ return markdown;
1909
1943
  };
1910
1944
 
1911
- class CommandNotFoundError extends Error {
1912
- constructor(command) {
1913
- super(`Command not found ${command}`);
1914
- this.name = 'CommandNotFoundError';
1915
- }
1916
- }
1917
- const commands = Object.create(null);
1918
- const register = commandMap => {
1919
- Object.assign(commands, commandMap);
1945
+ const getColorThemeMarkdown = themes => {
1946
+ const heading = 'Color Themes';
1947
+ return getThemeItemMarkdown(heading, themes);
1920
1948
  };
1921
- const getCommand = key => {
1922
- return commands[key];
1949
+ const getIconThemeMarkdown = iconThemes => {
1950
+ const heading = 'File Icon Themes';
1951
+ return getThemeItemMarkdown(heading, iconThemes);
1923
1952
  };
1924
- const execute = (command, ...args) => {
1925
- const fn = getCommand(command);
1926
- if (!fn) {
1927
- throw new CommandNotFoundError(command);
1928
- }
1929
- return fn(...args);
1953
+ const getProductIconThemeMarkdown = iconThemes => {
1954
+ const heading = 'Product Icon Themes';
1955
+ return getThemeItemMarkdown(heading, iconThemes);
1930
1956
  };
1931
-
1932
- const Two = '2.0';
1933
- const create$p = (method, params) => {
1934
- return {
1935
- jsonrpc: Two,
1936
- method,
1937
- params
1938
- };
1957
+ const getThemeMarkdown = (themes, iconThemes, productIconThemes) => {
1958
+ let markdown = '';
1959
+ markdown += getColorThemeMarkdown(themes);
1960
+ markdown += getIconThemeMarkdown(iconThemes);
1961
+ markdown += getProductIconThemeMarkdown(productIconThemes);
1962
+ return markdown;
1939
1963
  };
1940
- const create$o = (id, method, params) => {
1941
- const message = {
1942
- id,
1943
- jsonrpc: Two,
1944
- method,
1945
- params
1946
- };
1947
- return message;
1964
+
1965
+ const padBytes = bytes => {
1966
+ return bytes.toString(16).padStart(2, '0');
1948
1967
  };
1949
- let id = 0;
1950
- const create$n = () => {
1951
- return ++id;
1968
+ const hash = async content => {
1969
+ const sourceBytes = new TextEncoder().encode(content);
1970
+ const digest = await crypto.subtle.digest('SHA-256', sourceBytes);
1971
+ const resultBytes = [...new Uint8Array(digest)];
1972
+ return resultBytes.map(padBytes).join('');
1952
1973
  };
1953
1974
 
1954
- /* eslint-disable n/no-unsupported-features/es-syntax */
1955
-
1956
- const registerPromise = map => {
1957
- const id = create$n();
1958
- const {
1959
- promise,
1960
- resolve
1961
- } = Promise.withResolvers();
1962
- map[id] = resolve;
1963
- return {
1964
- id,
1965
- promise
1966
- };
1975
+ const supportsNormalCacheKey = locationProtocol => {
1976
+ return locationProtocol === 'http:' || locationProtocol === 'https:';
1967
1977
  };
1968
1978
 
1969
- // @ts-ignore
1970
- const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer) => {
1971
- const {
1972
- id,
1973
- promise
1974
- } = registerPromise(callbacks);
1975
- const message = create$o(id, method, params);
1976
- if (useSendAndTransfer && ipc.sendAndTransfer) {
1977
- ipc.sendAndTransfer(message);
1978
- } else {
1979
- ipc.send(message);
1980
- }
1981
- const responseMessage = await promise;
1982
- return unwrapJsonRpcResult(responseMessage);
1979
+ const getMarkdownCacheHash = async (markdown, options) => {
1980
+ const stringifiedOptions = JSON.stringify(options);
1981
+ const contents = `${markdown}:${stringifiedOptions}:${options.commit}`;
1982
+ return hash(contents);
1983
1983
  };
1984
- const createRpc = ipc => {
1985
- const callbacks = Object.create(null);
1986
- ipc._resolve = (id, response) => {
1987
- const fn = callbacks[id];
1988
- if (!fn) {
1989
- console.warn(`callback ${id} may already be disposed`);
1990
- return;
1991
- }
1992
- fn(response);
1993
- delete callbacks[id];
1994
- };
1995
- const rpc = {
1996
- async dispose() {
1997
- await ipc?.dispose();
1998
- },
1999
- invoke(method, ...params) {
2000
- return invokeHelper(callbacks, ipc, method, params, false);
2001
- },
2002
- invokeAndTransfer(method, ...params) {
2003
- return invokeHelper(callbacks, ipc, method, params, true);
2004
- },
2005
- // @ts-ignore
2006
- ipc,
2007
- /**
2008
- * @deprecated
2009
- */
2010
- send(method, ...params) {
2011
- const message = create$p(method, params);
2012
- ipc.send(message);
2013
- }
2014
- };
2015
- return rpc;
2016
- };
2017
- const requiresSocket = () => {
2018
- return false;
2019
- };
2020
- const preparePrettyError = error => {
2021
- return error;
2022
- };
2023
- const logError = () => {
2024
- // handled by renderer worker
2025
- };
2026
- const handleMessage = event => {
2027
- const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket;
2028
- const actualExecute = event?.target?.execute || execute;
2029
- return handleJsonRpcMessage(event.target, event.data, actualExecute, event.target._resolve, preparePrettyError, logError, actualRequiresSocket);
2030
- };
2031
- const handleIpc = ipc => {
2032
- if ('addEventListener' in ipc) {
2033
- ipc.addEventListener('message', handleMessage);
2034
- } else if ('on' in ipc) {
2035
- // deprecated
2036
- ipc.on('message', handleMessage);
1984
+ const getMarkdownCacheKey = async (markdown, options) => {
1985
+ const hash = await getMarkdownCacheHash(markdown, options);
1986
+ if (supportsNormalCacheKey(options.locationProtocol)) {
1987
+ return `/markdown/${hash}`;
2037
1988
  }
1989
+ // workaround for electron bug
1990
+ return `https://-/markdown/${hash}`;
2038
1991
  };
2039
- const listen$1 = async (module, options) => {
2040
- const rawIpc = await module.listen(options);
2041
- if (module.signal) {
2042
- module.signal(rawIpc);
2043
- }
2044
- const ipc = module.wrap(rawIpc);
2045
- return ipc;
1992
+
1993
+ // TODO pass application name from renderer worker to not hardcode it
1994
+
1995
+ const cachedCaches = Object.create(null);
1996
+ const noopCache = {
1997
+ async match() {
1998
+ return undefined;
1999
+ },
2000
+ async put() {}
2046
2001
  };
2047
- const create$7 = async ({
2048
- commandMap,
2049
- isMessagePortOpen = true,
2050
- messagePort
2051
- }) => {
2052
- // TODO create a commandMap per rpc instance
2053
- register(commandMap);
2054
- const rawIpc = await IpcParentWithMessagePort$1.create({
2055
- isMessagePortOpen,
2056
- messagePort
2057
- });
2058
- const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
2059
- handleIpc(ipc);
2060
- const rpc = createRpc(ipc);
2061
- messagePort.start();
2062
- return rpc;
2002
+ const supportsStorageBuckets = () => {
2003
+ // @ts-ignore
2004
+ return Boolean(navigator.storageBuckets);
2063
2005
  };
2064
- const create$5 = async ({
2065
- commandMap,
2066
- isMessagePortOpen,
2067
- send
2068
- }) => {
2069
- const {
2070
- port1,
2071
- port2
2072
- } = new MessageChannel();
2073
- await send(port1);
2074
- return create$7({
2075
- commandMap,
2076
- isMessagePortOpen,
2077
- messagePort: port2
2006
+ const getCacheInternal = async (cacheName, bucketName) => {
2007
+ if (!supportsStorageBuckets()) {
2008
+ return noopCache;
2009
+ }
2010
+ const twoWeeks = 14 * 24 * 60 * 60 * 1000;
2011
+ // @ts-ignore
2012
+ const bucket = await navigator.storageBuckets.open(bucketName, {
2013
+ expires: Date.now() + twoWeeks,
2014
+ quota: 100 * 1024 * 1024 // 100MB
2078
2015
  });
2016
+ const cache = await bucket.caches.open(cacheName);
2017
+ return cache;
2079
2018
  };
2080
- const TransferMessagePortRpcParent = {
2081
- __proto__: null,
2082
- create: create$5
2019
+ const getCache = (cacheName, bucketName) => {
2020
+ if (!(cacheName in cachedCaches)) {
2021
+ cachedCaches[cacheName] = getCacheInternal(cacheName, bucketName);
2022
+ }
2023
+ return cachedCaches[cacheName];
2083
2024
  };
2084
- const create$2 = async ({
2085
- commandMap
2086
- }) => {
2087
- // TODO create a commandMap per rpc instance
2088
- register(commandMap);
2089
- const ipc = await listen$1(IpcChildWithModuleWorkerAndMessagePort$1);
2090
- handleIpc(ipc);
2091
- const rpc = createRpc(ipc);
2092
- return rpc;
2025
+
2026
+ // TODO pass application name from renderer worker to not hardcode it
2027
+ const cacheName = 'lvce-editor/markdown-cache';
2028
+ const has = async (key, bucketName) => {
2029
+ const cache = await getCache(cacheName, bucketName);
2030
+ const response = await cache.match(key);
2031
+ return Boolean(response);
2093
2032
  };
2094
- const WebWorkerRpcClient = {
2095
- __proto__: null,
2096
- create: create$2
2033
+ const get$2 = async (key, bucketName) => {
2034
+ const cache = await getCache(cacheName, bucketName);
2035
+ const response = await cache.match(key);
2036
+ const text = await response?.text();
2037
+ return text || '';
2097
2038
  };
2098
- const createMockRpc = ({
2099
- commandMap
2100
- }) => {
2101
- const invocations = [];
2102
- const invoke = (method, ...params) => {
2103
- invocations.push([method, ...params]);
2104
- const command = commandMap[method];
2105
- if (!command) {
2106
- throw new Error(`command ${method} not found`);
2039
+ const set$2 = async (key, bucketName, value) => {
2040
+ const cache = await getCache(cacheName, bucketName);
2041
+ await cache.put(key, new Response(value, {
2042
+ headers: {
2043
+ 'Content-Length': `${value.length}`,
2044
+ 'Content-Type': 'application/markdown'
2107
2045
  }
2108
- return command(...params);
2109
- };
2110
- const mockRpc = {
2111
- invocations,
2112
- invoke,
2113
- invokeAndTransfer: invoke
2114
- };
2115
- return mockRpc;
2046
+ }));
2116
2047
  };
2117
2048
 
2118
- const {
2119
- dispose: dispose$4,
2120
- invoke: invoke$5,
2121
- invokeAndTransfer: invokeAndTransfer$3,
2122
- set: set$9
2123
- } = create$4(ExtensionHostWorker);
2124
- const executeReferenceProvider = async (id, offset) => {
2125
- // @ts-ignore
2126
- return invoke$5('ExtensionHostReference.executeReferenceProvider', id, offset);
2127
- };
2128
- const executeFileReferenceProvider = async id => {
2129
- // @ts-ignore
2130
- return invoke$5('ExtensionHostReference.executeFileReferenceProvider', id);
2049
+ const renderMarkdownCached = async (markdown, options) => {
2050
+ const cacheKey = await getMarkdownCacheKey(markdown, options);
2051
+ const bucketName = `markdown-cache`;
2052
+ const hasItem = await has(cacheKey, bucketName);
2053
+ if (hasItem) {
2054
+ const value = await get$2(cacheKey, bucketName);
2055
+ return value; // TODO validate if it's valid
2056
+ }
2057
+ const html = await render(markdown, options);
2058
+ await set$2(cacheKey, bucketName, html);
2059
+ return html;
2131
2060
  };
2132
- const getRuntimeStatus$2 = async extensionId => {
2133
- // @ts-ignore
2134
- return invoke$5('ExtensionHost.getRuntimeStatus', extensionId);
2061
+
2062
+ const renderMarkdown = async (markdown, options) => {
2063
+ const html = await renderMarkdownCached(markdown, options);
2064
+ return html;
2135
2065
  };
2136
- const registerMockRpc$2 = commandMap => {
2137
- const mockRpc = createMockRpc({
2138
- commandMap
2066
+
2067
+ const getThemeDetails = async (extension, baseUrl, locationProtocol) => {
2068
+ const {
2069
+ colorThemes,
2070
+ iconThemes,
2071
+ productIconThemes
2072
+ } = extension;
2073
+ const markdown = getThemeMarkdown(colorThemes || [], iconThemes || [], productIconThemes || []);
2074
+ const rendered = await renderMarkdown(markdown, {
2075
+ baseUrl,
2076
+ locationProtocol
2139
2077
  });
2140
- set$9(mockRpc);
2141
- return mockRpc;
2078
+ const themesMarkdownDom = await getMarkdownVirtualDom(rendered);
2079
+ return {
2080
+ themesMarkdownDom
2081
+ };
2142
2082
  };
2143
2083
 
2144
- const ExtensionHost = {
2145
- __proto__: null,
2146
- dispose: dispose$4,
2147
- executeFileReferenceProvider,
2148
- executeReferenceProvider,
2149
- getRuntimeStatus: getRuntimeStatus$2,
2150
- invoke: invoke$5,
2151
- invokeAndTransfer: invokeAndTransfer$3,
2152
- registerMockRpc: registerMockRpc$2,
2153
- set: set$9
2084
+ const featureColorThemeEnabled = extension => {
2085
+ if (!hasProperty(extension, 'colorThemes')) {
2086
+ return false;
2087
+ }
2088
+ return Array.isArray(extension.colorThemes);
2154
2089
  };
2155
2090
 
2156
- const {
2157
- invoke: invoke$4,
2158
- set: set$8
2159
- } = create$4(ExtensionManagementWorker);
2160
- const enable2 = (id, platform) => {
2161
- return invoke$4(`Extensions.enable2`, id, platform);
2162
- };
2163
- const disable2 = (id, platform) => {
2164
- return invoke$4(`Extensions.disable2`, id, platform);
2091
+ const featureIconThemeEnabled = extension => {
2092
+ if (!hasProperty(extension, 'iconThemes')) {
2093
+ return false;
2094
+ }
2095
+ return Array.isArray(extension.iconThemes);
2165
2096
  };
2166
2097
 
2167
- const {
2168
- dispose: dispose$3,
2169
- invoke: invoke$3,
2170
- invokeAndTransfer: invokeAndTransfer$2,
2171
- set: set$7
2172
- } = create$4(FileSystemWorker$1);
2173
- const remove = async dirent => {
2174
- return invoke$3('FileSystem.remove', dirent);
2175
- };
2176
- const readDirWithFileTypes = async uri => {
2177
- return invoke$3('FileSystem.readDirWithFileTypes', uri);
2178
- };
2179
- const getPathSeparator = async root => {
2180
- // @ts-ignore
2181
- return invoke$3('FileSystem.getPathSeparator', root);
2182
- };
2183
- const getRealPath = async path => {
2184
- return invoke$3('FileSystem.getRealPath', path);
2098
+ const featureProductIconThemeEnabled = extension => {
2099
+ if (!hasProperty(extension, 'productIconThemes')) {
2100
+ return false;
2101
+ }
2102
+ return Array.isArray(extension.productIconThemes);
2185
2103
  };
2186
- const stat = async dirent => {
2187
- return invoke$3('FileSystem.stat', dirent);
2104
+
2105
+ const featureThemeEnabled = extension => {
2106
+ return featureColorThemeEnabled(extension) || featureIconThemeEnabled(extension) || featureProductIconThemeEnabled(extension);
2188
2107
  };
2189
- const createFile = async uri => {
2190
- return invoke$3('FileSystem.writeFile', uri, '');
2108
+
2109
+ const getVirtualDomChildCount = dom => {
2110
+ const max = dom.length - 1;
2111
+ let stack = [];
2112
+ for (let i = max; i >= 0; i--) {
2113
+ const element = dom[i];
2114
+ if (element.childCount > 0) {
2115
+ stack = stack.slice(element.childCount);
2116
+ }
2117
+ stack.unshift(element);
2118
+ }
2119
+ return stack.length;
2191
2120
  };
2192
- const readFile$2 = async uri => {
2193
- return invoke$3('FileSystem.readFile', uri);
2121
+
2122
+ const getFeatureThemesVirtualDom = themesDom => {
2123
+ const childCount = getVirtualDomChildCount(themesDom);
2124
+ const heading = theme();
2125
+ return [{
2126
+ childCount: 2,
2127
+ className: FeatureContent,
2128
+ type: Div
2129
+ }, ...getFeatureContentHeadingVirtualDom(heading), {
2130
+ childCount,
2131
+ className: DefaultMarkdown,
2132
+ type: Div
2133
+ }, ...themesDom];
2194
2134
  };
2195
- const writeFile = async (uri, content) => {
2196
- return invoke$3('FileSystem.writeFile', uri, content);
2135
+
2136
+ const getThemeVirtualDom = state => {
2137
+ return getFeatureThemesVirtualDom(state.themesMarkdownDom);
2197
2138
  };
2198
- const mkdir = async uri => {
2199
- return invoke$3('FileSystem.mkdir', uri);
2139
+
2140
+ const toWebView = rawWebView => {
2141
+ const {
2142
+ contentSecurityPolicy,
2143
+ elements,
2144
+ id,
2145
+ selector
2146
+ } = rawWebView;
2147
+ return {
2148
+ contentSecurityPolicyString: JSON.stringify(contentSecurityPolicy),
2149
+ elementsString: JSON.stringify(elements, null, 2),
2150
+ id,
2151
+ selectorString: JSON.stringify(selector)
2152
+ };
2200
2153
  };
2201
- const rename = async (oldUri, newUri) => {
2202
- return invoke$3('FileSystem.rename', oldUri, newUri);
2154
+
2155
+ const getWebViews = extension => {
2156
+ const rawWebViews = extension.webViews || [];
2157
+ return rawWebViews.map(toWebView);
2203
2158
  };
2204
- const copy = async (oldUri, newUri) => {
2205
- return invoke$3('FileSystem.copy', oldUri, newUri);
2159
+
2160
+ const getWebViewsDetails = async extension => {
2161
+ const webViews = getWebViews(extension);
2162
+ return {
2163
+ webViews
2164
+ };
2206
2165
  };
2207
- const exists$1 = async uri => {
2208
- // @ts-ignore
2209
- return invoke$3('FileSystem.exists', uri);
2166
+
2167
+ const featureWebViewsEnabled = extension => {
2168
+ if (!hasProperty(extension, 'webViews')) {
2169
+ return false;
2170
+ }
2171
+ return Array.isArray(extension.webViews);
2210
2172
  };
2211
- const getFolderSize$1 = async uri => {
2212
- // @ts-ignore
2213
- return invoke$3('FileSystem.getFolderSize', uri);
2173
+
2174
+ const heading = {
2175
+ childCount: 1,
2176
+ className: DefinitionListItemHeading,
2177
+ type: H2
2214
2178
  };
2215
- const readFileAsBlob$1 = async uri => {
2216
- // @ts-ignore
2217
- return invoke$3('FileSystem.readFileAsBlob', uri);
2179
+ const pre = {
2180
+ childCount: 1,
2181
+ className: DefinitionListItemValue,
2182
+ type: Pre
2218
2183
  };
2219
- const appendFile = async (uri, text) => {
2220
- // @ts-ignore
2221
- return invoke$3('FileSystem.appendFile', uri, text);
2184
+ const item = {
2185
+ childCount: 2,
2186
+ className: DefinitionListItem,
2187
+ type: Div
2222
2188
  };
2223
- const registerMockRpc$1 = commandMap => {
2224
- const mockRpc = createMockRpc({
2225
- commandMap
2226
- });
2227
- set$7(mockRpc);
2228
- return mockRpc;
2189
+ const getWebViewVirtualDom = webView => {
2190
+ const {
2191
+ contentSecurityPolicyString,
2192
+ elementsString,
2193
+ id,
2194
+ selectorString
2195
+ } = webView;
2196
+ const textId = id$1();
2197
+ const textSelector = selector();
2198
+ const textContentSecurityPolicy = contentSecurityPolicy();
2199
+ const textElements = elements();
2200
+ return [{
2201
+ childCount: 4,
2202
+ className: FeatureWebView,
2203
+ type: Div
2204
+ }, item, heading, text(textId), pre, text(id), item, heading, text(textSelector), pre, text(selectorString), item, heading, text(textContentSecurityPolicy), pre, text(contentSecurityPolicyString), item, heading, text(textElements), pre, text(elementsString)];
2229
2205
  };
2230
2206
 
2231
- const FileSystemWorker = {
2232
- __proto__: null,
2233
- appendFile,
2234
- copy,
2235
- createFile,
2236
- dispose: dispose$3,
2237
- exists: exists$1,
2238
- getFolderSize: getFolderSize$1,
2239
- getPathSeparator,
2240
- getRealPath,
2241
- invoke: invoke$3,
2242
- invokeAndTransfer: invokeAndTransfer$2,
2243
- mkdir,
2244
- readDirWithFileTypes,
2245
- readFile: readFile$2,
2246
- readFileAsBlob: readFileAsBlob$1,
2247
- registerMockRpc: registerMockRpc$1,
2248
- remove,
2249
- rename,
2250
- set: set$7,
2251
- stat,
2252
- writeFile
2207
+ const getFeatureWebViewsVirtualDom = webViews$1 => {
2208
+ const heading = webViews();
2209
+ return [{
2210
+ childCount: 2,
2211
+ className: FeatureContent,
2212
+ type: Div
2213
+ }, ...getFeatureContentHeadingVirtualDom(heading), {
2214
+ childCount: webViews$1.length,
2215
+ type: Div
2216
+ }, ...webViews$1.flatMap(getWebViewVirtualDom)];
2253
2217
  };
2254
2218
 
2255
- const {
2256
- dispose: dispose$2,
2257
- invoke: invoke$2,
2258
- invokeAndTransfer: invokeAndTransfer$1,
2259
- set: set$6
2260
- } = create$4(MarkdownWorker$1);
2261
- const getVirtualDom$1 = async html => {
2262
- // @ts-ignore
2263
- return invoke$2('Markdown.getVirtualDom', html);
2264
- };
2265
- const render$1 = async (markdown, options) => {
2266
- // @ts-ignore
2267
- return invoke$2('Markdown.render', markdown, options);
2268
- };
2269
- const registerMockRpc = commandMap => {
2270
- const mockRpc = createMockRpc({
2271
- commandMap
2272
- });
2273
- set$6(mockRpc);
2274
- return mockRpc;
2219
+ const getWebViewsVirtualDom = state => {
2220
+ return getFeatureWebViewsVirtualDom(state.webViews);
2275
2221
  };
2276
2222
 
2277
- const MarkdownWorker = {
2278
- __proto__: null,
2279
- dispose: dispose$2,
2280
- getVirtualDom: getVirtualDom$1,
2281
- invoke: invoke$2,
2282
- invokeAndTransfer: invokeAndTransfer$1,
2283
- registerMockRpc,
2284
- render: render$1,
2285
- set: set$6
2223
+ const registerAllFeatures = () => {
2224
+ register$1({
2225
+ getDetails: getThemeDetails,
2226
+ getLabel: theme,
2227
+ getVirtualDom: getThemeVirtualDom,
2228
+ id: Theme,
2229
+ isEnabled: featureThemeEnabled
2230
+ });
2231
+ register$1({
2232
+ getDetails: getCommandsDetails,
2233
+ getLabel: commands$1,
2234
+ getVirtualDom: getCommandsVirtualDom,
2235
+ id: Commands,
2236
+ isEnabled: featureCommandsEnabled
2237
+ });
2238
+ register$1({
2239
+ getDetails: getSettingsDetails,
2240
+ getLabel: settings,
2241
+ getVirtualDom: getSettingsVirtualDom,
2242
+ id: Settings,
2243
+ isEnabled: featureSettingsEnabled
2244
+ });
2245
+ register$1({
2246
+ getDetails: getJsonValidationDetails,
2247
+ getLabel: jsonValidation,
2248
+ getVirtualDom: getJsonValidationVirtualDom,
2249
+ id: JsonValidation,
2250
+ isEnabled: featureJsonValidationEnabled
2251
+ });
2252
+ register$1({
2253
+ getDetails: getFeatureDetailsProgrammingLanguages,
2254
+ getLabel: programmingLanguages,
2255
+ getVirtualDom: getProgrammingLanguagesVirtualDom,
2256
+ id: ProgrammingLanguages,
2257
+ isEnabled: featureProgrammingLanguagesEnabled
2258
+ });
2259
+ register$1({
2260
+ getDetails: getWebViewsDetails,
2261
+ getLabel: webViews,
2262
+ getVirtualDom: getWebViewsVirtualDom,
2263
+ id: WebViews,
2264
+ isEnabled: featureWebViewsEnabled
2265
+ });
2266
+ register$1({
2267
+ getDetails: getActivationEventsDetails,
2268
+ getLabel: activationEvents,
2269
+ getVirtualDom: getActivationEventsVirtualDom,
2270
+ id: ActivationEvents,
2271
+ isEnabled: featureActivationEventsEnabled
2272
+ });
2273
+ register$1({
2274
+ getDetails: getRuntimeStatusDetails,
2275
+ getLabel: runtimeStatus,
2276
+ getVirtualDom: getRuntimeStatusVirtualDom,
2277
+ id: RuntimeStatus,
2278
+ isEnabled: featureRuntimeStatusEnabled
2279
+ });
2286
2280
  };
2287
2281
 
2288
- const {
2289
- invoke: invoke$1,
2290
- invokeAndTransfer,
2291
- set: set$5
2292
- } = create$4(RendererWorker);
2293
- const showContextMenu2 = async (uid, menuId, x, y, args) => {
2294
- number(uid);
2295
- number(menuId);
2296
- number(x);
2297
- number(y);
2298
- // @ts-ignore
2299
- await invoke$1('ContextMenu.show2', uid, menuId, x, y, args);
2282
+ const isMessagePort = value => {
2283
+ return value && value instanceof MessagePort;
2300
2284
  };
2301
- const setColorTheme$1 = async id => {
2302
- // @ts-ignore
2303
- return invoke$1(/* ColorTheme.setColorTheme */'ColorTheme.setColorTheme', /* colorThemeId */id);
2285
+ const isMessagePortMain = value => {
2286
+ return value && value.constructor && value.constructor.name === 'MessagePortMain';
2304
2287
  };
2305
- const sendMessagePortToMarkdownWorker$1 = async (port, rpcId) => {
2306
- const command = 'Markdown.handleMessagePort';
2307
- // @ts-ignore
2308
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToMarkdownWorker', port, command, rpcId);
2288
+ const isOffscreenCanvas = value => {
2289
+ return typeof OffscreenCanvas !== 'undefined' && value instanceof OffscreenCanvas;
2309
2290
  };
2310
- const sendMessagePortToFileSystemWorker$1 = async (port, rpcId) => {
2311
- const command = 'FileSystem.handleMessagePort';
2312
- // @ts-ignore
2313
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToFileSystemWorker', port, command, rpcId);
2291
+ const isInstanceOf = (value, constructorName) => {
2292
+ return value?.constructor?.name === constructorName;
2314
2293
  };
2315
- const sendMessagePortToExtensionHostWorker$1 = async (port, rpcId = 0) => {
2316
- const command = 'HandleMessagePort.handleMessagePort2';
2317
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', port, command, rpcId);
2294
+ const isSocket = value => {
2295
+ return isInstanceOf(value, 'Socket');
2318
2296
  };
2319
- const confirm = async (message, options) => {
2320
- // @ts-ignore
2321
- const result = await invoke$1('ConfirmPrompt.prompt', message, options);
2322
- return result;
2297
+ const transferrables = [isMessagePort, isMessagePortMain, isOffscreenCanvas, isSocket];
2298
+ const isTransferrable = value => {
2299
+ for (const fn of transferrables) {
2300
+ if (fn(value)) {
2301
+ return true;
2302
+ }
2303
+ }
2304
+ return false;
2323
2305
  };
2324
- const writeClipBoardText = async text => {
2325
- await invoke$1('ClipBoard.writeText', /* text */text);
2306
+ const walkValue = (value, transferrables, isTransferrable) => {
2307
+ if (!value) {
2308
+ return;
2309
+ }
2310
+ if (isTransferrable(value)) {
2311
+ transferrables.push(value);
2312
+ return;
2313
+ }
2314
+ if (Array.isArray(value)) {
2315
+ for (const item of value) {
2316
+ walkValue(item, transferrables, isTransferrable);
2317
+ }
2318
+ return;
2319
+ }
2320
+ if (typeof value === 'object') {
2321
+ for (const property of Object.values(value)) {
2322
+ walkValue(property, transferrables, isTransferrable);
2323
+ }
2324
+ return;
2325
+ }
2326
2326
  };
2327
- const writeClipBoardImage = async blob => {
2328
- // @ts-ignore
2329
- await invoke$1('ClipBoard.writeImage', /* text */blob);
2327
+ const getTransferrables = value => {
2328
+ const transferrables = [];
2329
+ walkValue(value, transferrables, isTransferrable);
2330
+ return transferrables;
2330
2331
  };
2331
- const sendMessagePortToExtensionManagementWorker = async (port, rpcId) => {
2332
- const command = 'Extensions.handleMessagePort';
2333
- await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionManagementWorker', port, command, rpcId);
2334
- };
2335
- const getPreference = async key => {
2336
- return await invoke$1('Preferences.get', key);
2337
- };
2338
- const getAllExtensions$1 = async () => {
2339
- return invoke$1('ExtensionManagement.getAllExtensions');
2332
+ const attachEvents = that => {
2333
+ const handleMessage = (...args) => {
2334
+ const data = that.getData(...args);
2335
+ that.dispatchEvent(new MessageEvent('message', {
2336
+ data
2337
+ }));
2338
+ };
2339
+ that.onMessage(handleMessage);
2340
+ const handleClose = event => {
2341
+ that.dispatchEvent(new Event('close'));
2342
+ };
2343
+ that.onClose(handleClose);
2340
2344
  };
2341
- const getExtension$2 = async id => {
2342
- // @ts-ignore
2343
- return invoke$1('ExtensionManagement.getExtension', id);
2345
+ class Ipc extends EventTarget {
2346
+ constructor(rawIpc) {
2347
+ super();
2348
+ this._rawIpc = rawIpc;
2349
+ attachEvents(this);
2350
+ }
2351
+ }
2352
+ const E_INCOMPATIBLE_NATIVE_MODULE = 'E_INCOMPATIBLE_NATIVE_MODULE';
2353
+ const E_MODULES_NOT_SUPPORTED_IN_ELECTRON = 'E_MODULES_NOT_SUPPORTED_IN_ELECTRON';
2354
+ const ERR_MODULE_NOT_FOUND = 'ERR_MODULE_NOT_FOUND';
2355
+ const NewLine$1 = '\n';
2356
+ const joinLines$1 = lines => {
2357
+ return lines.join(NewLine$1);
2344
2358
  };
2345
- const openNativeFolder = async uri => {
2346
- // @ts-ignore
2347
- await invoke$1('OpenNativeFolder.openNativeFolder', uri);
2359
+ const RE_AT = /^\s+at/;
2360
+ const RE_AT_PROMISE_INDEX = /^\s*at async Promise.all \(index \d+\)$/;
2361
+ const isNormalStackLine = line => {
2362
+ return RE_AT.test(line) && !RE_AT_PROMISE_INDEX.test(line);
2348
2363
  };
2349
- const uninstallExtension = async id => {
2350
- return invoke$1('ExtensionManagement.uninstall', id);
2364
+ const getDetails = lines => {
2365
+ const index = lines.findIndex(isNormalStackLine);
2366
+ if (index === -1) {
2367
+ return {
2368
+ actualMessage: joinLines$1(lines),
2369
+ rest: []
2370
+ };
2371
+ }
2372
+ let lastIndex = index - 1;
2373
+ while (++lastIndex < lines.length) {
2374
+ if (!isNormalStackLine(lines[lastIndex])) {
2375
+ break;
2376
+ }
2377
+ }
2378
+ return {
2379
+ actualMessage: lines[index - 1],
2380
+ rest: lines.slice(index, lastIndex)
2381
+ };
2351
2382
  };
2352
- const openExtensionSearch$1 = async () => {
2353
- // @ts-ignore
2354
- return invoke$1('SideBar.openViewlet', 'Extensions');
2383
+ const splitLines$1 = lines => {
2384
+ return lines.split(NewLine$1);
2355
2385
  };
2356
- const setExtensionsSearchValue = async searchValue => {
2357
- // @ts-ignore
2358
- return invoke$1('Extensions.handleInput', searchValue, Script$1);
2386
+ const RE_MESSAGE_CODE_BLOCK_START = /^Error: The module '.*'$/;
2387
+ const RE_MESSAGE_CODE_BLOCK_END = /^\s* at/;
2388
+ const isMessageCodeBlockStartIndex = line => {
2389
+ return RE_MESSAGE_CODE_BLOCK_START.test(line);
2359
2390
  };
2360
- const openExternal$1 = async uri => {
2361
- // @ts-ignore
2362
- await invoke$1('Open.openExternal', uri);
2391
+ const isMessageCodeBlockEndIndex = line => {
2392
+ return RE_MESSAGE_CODE_BLOCK_END.test(line);
2363
2393
  };
2364
- const openUrl = async uri => {
2365
- // @ts-ignore
2366
- await invoke$1('Open.openUrl', uri);
2394
+ const getMessageCodeBlock = stderr => {
2395
+ const lines = splitLines$1(stderr);
2396
+ const startIndex = lines.findIndex(isMessageCodeBlockStartIndex);
2397
+ const endIndex = startIndex + lines.slice(startIndex).findIndex(isMessageCodeBlockEndIndex, startIndex);
2398
+ const relevantLines = lines.slice(startIndex, endIndex);
2399
+ const relevantMessage = relevantLines.join(' ').slice('Error: '.length);
2400
+ return relevantMessage;
2367
2401
  };
2368
-
2369
- /* eslint-disable unicorn/prefer-export-from */
2370
-
2371
- const {
2372
- getRuntimeStatus: getRuntimeStatus$1,
2373
- set: set$4
2374
- } = ExtensionHost;
2375
-
2376
- const getRuntimeStatus = async extensionId => {
2377
- // @ts-ignore
2378
- const status = await getRuntimeStatus$1(extensionId);
2379
- // @ts-ignore
2380
- return status;
2402
+ const isModuleNotFoundMessage = line => {
2403
+ return line.includes('[ERR_MODULE_NOT_FOUND]');
2381
2404
  };
2382
-
2383
- const getRuntimeStatusDetails = async extension => {
2384
- const {
2385
- activationEvent,
2386
- activationTime,
2387
- importTime,
2388
- status
2389
- } = await getRuntimeStatus(extension.id);
2405
+ const getModuleNotFoundError = stderr => {
2406
+ const lines = splitLines$1(stderr);
2407
+ const messageIndex = lines.findIndex(isModuleNotFoundMessage);
2408
+ const message = lines[messageIndex];
2390
2409
  return {
2391
- activationTime,
2392
- importTime,
2393
- status,
2394
- wasActivatedByEvent: activationEvent
2410
+ code: ERR_MODULE_NOT_FOUND,
2411
+ message
2395
2412
  };
2396
2413
  };
2397
-
2398
- const featureRuntimeStatusEnabled = extension => {
2399
- if (!extension || typeof extension !== 'object') {
2414
+ const isModuleNotFoundError = stderr => {
2415
+ if (!stderr) {
2400
2416
  return false;
2401
2417
  }
2402
- if ('main' in extension || 'browser' in extension) {
2403
- return true;
2404
- }
2405
- return false;
2406
- };
2407
-
2408
- const formatTime = time => {
2409
- return time.toFixed(2) + 'ms';
2410
- };
2411
-
2412
- const getActivationTimeVirtualDom = (importTime$1, activationTime$1) => {
2413
- if (!activationTime$1 && !importTime$1) {
2414
- return [];
2415
- }
2416
- const formattedImportTime = formatTime(importTime$1);
2417
- const formattedTime = formatTime(activationTime$1);
2418
- return [{
2419
- childCount: 1,
2420
- type: Dt
2421
- }, text(importTime()), {
2422
- childCount: 1,
2423
- type: Dd
2424
- }, text(formattedImportTime), {
2425
- childCount: 1,
2426
- type: Dt
2427
- }, text(activationTime()), {
2428
- childCount: 1,
2429
- type: Dd
2430
- }, text(formattedTime)];
2418
+ return stderr.includes('ERR_MODULE_NOT_FOUND');
2431
2419
  };
2432
-
2433
- const None$1 = 0;
2434
- const Importing = 1;
2435
- const Activating = 2;
2436
- const Activated = 3;
2437
- const Error$1 = 4;
2438
-
2439
- const getStatusMessage = statusType => {
2440
- switch (statusType) {
2441
- case Activated:
2442
- return 'activated';
2443
- case Activating:
2444
- return 'Activating';
2445
- case Error$1:
2446
- return 'error';
2447
- case Importing:
2448
- return 'importing';
2449
- case None$1:
2450
- return 'none';
2451
- default:
2452
- return 'unknown';
2420
+ const isModulesSyntaxError = stderr => {
2421
+ if (!stderr) {
2422
+ return false;
2453
2423
  }
2424
+ return stderr.includes('SyntaxError: Cannot use import statement outside a module');
2454
2425
  };
2455
-
2456
- const key = {
2457
- childCount: 1,
2458
- className: 'RuntimeStatusDefinitionListKey',
2459
- type: Dt
2426
+ const RE_NATIVE_MODULE_ERROR = /^innerError Error: Cannot find module '.*.node'/;
2427
+ const RE_NATIVE_MODULE_ERROR_2 = /was compiled against a different Node.js version/;
2428
+ const isUnhelpfulNativeModuleError = stderr => {
2429
+ return RE_NATIVE_MODULE_ERROR.test(stderr) && RE_NATIVE_MODULE_ERROR_2.test(stderr);
2460
2430
  };
2461
- const value = {
2462
- childCount: 1,
2463
- className: 'RuntimeStatusDefinitionListValue',
2464
- type: Dd
2431
+ const getNativeModuleErrorMessage = stderr => {
2432
+ const message = getMessageCodeBlock(stderr);
2433
+ return {
2434
+ code: E_INCOMPATIBLE_NATIVE_MODULE,
2435
+ message: `Incompatible native node module: ${message}`
2436
+ };
2465
2437
  };
2466
- const getStatusVirtualDom = status$1 => {
2467
- const statusKey = status();
2468
- const statusValue = getStatusMessage(status$1);
2469
- return [key, text(`${statusKey}: `), value, text(`${statusValue}`)];
2438
+ const getModuleSyntaxError = () => {
2439
+ return {
2440
+ code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON,
2441
+ message: `ES Modules are not supported in electron`
2442
+ };
2470
2443
  };
2471
-
2472
- const getChildCount$1 = (status, activationTime, importTime) => {
2473
- let childCount = 0;
2474
- childCount += 2; // status
2475
- if (importTime || activationTime) {
2476
- childCount += 4;
2444
+ const getHelpfulChildProcessError = (stdout, stderr) => {
2445
+ if (isUnhelpfulNativeModuleError(stderr)) {
2446
+ return getNativeModuleErrorMessage(stderr);
2477
2447
  }
2478
- return childCount;
2479
- };
2480
- const getRuntimeStatusVirtualDom = state => {
2448
+ if (isModulesSyntaxError(stderr)) {
2449
+ return getModuleSyntaxError();
2450
+ }
2451
+ if (isModuleNotFoundError(stderr)) {
2452
+ return getModuleNotFoundError(stderr);
2453
+ }
2454
+ const lines = splitLines$1(stderr);
2481
2455
  const {
2482
- activationTime,
2483
- importTime,
2484
- status
2485
- } = state;
2486
- const heading = runtimeStatus();
2487
- const childCount = getChildCount$1(status, activationTime, importTime);
2488
- return [{
2489
- childCount: 2,
2490
- className: FeatureContent,
2491
- type: Div
2492
- }, ...getFeatureContentHeadingVirtualDom(heading), {
2493
- childCount,
2494
- className: 'RuntimeStatusDefinitionList',
2495
- type: Dl
2496
- }, ...getStatusVirtualDom(status), ...getActivationTimeVirtualDom(activationTime, importTime)];
2456
+ actualMessage,
2457
+ rest
2458
+ } = getDetails(lines);
2459
+ return {
2460
+ code: '',
2461
+ message: actualMessage,
2462
+ stack: rest
2463
+ };
2497
2464
  };
2498
-
2499
- const getSettingsTableEntry = setting => {
2500
- const {
2501
- id,
2502
- label
2503
- } = setting;
2504
- // TODO watch out for null/undefined/number/string/array
2505
- return [{
2506
- type: Text,
2507
- value: id
2508
- }, {
2509
- type: Text,
2510
- value: label
2511
- }];
2465
+ class IpcError extends VError {
2466
+ // @ts-ignore
2467
+ constructor(betterMessage, stdout = '', stderr = '') {
2468
+ if (stdout || stderr) {
2469
+ // @ts-ignore
2470
+ const {
2471
+ code,
2472
+ message,
2473
+ stack
2474
+ } = getHelpfulChildProcessError(stdout, stderr);
2475
+ const cause = new Error(message);
2476
+ // @ts-ignore
2477
+ cause.code = code;
2478
+ cause.stack = stack;
2479
+ super(cause, betterMessage);
2480
+ } else {
2481
+ super(betterMessage);
2482
+ }
2483
+ // @ts-ignore
2484
+ this.name = 'IpcError';
2485
+ // @ts-ignore
2486
+ this.stdout = stdout;
2487
+ // @ts-ignore
2488
+ this.stderr = stderr;
2489
+ }
2490
+ }
2491
+ const readyMessage = 'ready';
2492
+ const getData$2 = event => {
2493
+ return event.data;
2512
2494
  };
2513
-
2514
- const getSettingsDetails = async extension => {
2515
- const settings = extension.settings || [];
2516
- const rows = settings.map(getSettingsTableEntry);
2517
- return {
2518
- settings: rows
2519
- };
2495
+ const listen$7 = () => {
2496
+ // @ts-ignore
2497
+ if (typeof WorkerGlobalScope === 'undefined') {
2498
+ throw new TypeError('module is not in web worker scope');
2499
+ }
2500
+ return globalThis;
2520
2501
  };
2521
-
2522
- const featureSettingsEnabled = extension => {
2523
- if (!hasProperty(extension, 'settings')) {
2524
- return false;
2502
+ const signal$8 = global => {
2503
+ global.postMessage(readyMessage);
2504
+ };
2505
+ class IpcChildWithModuleWorker extends Ipc {
2506
+ getData(event) {
2507
+ return getData$2(event);
2525
2508
  }
2526
- return Array.isArray(extension.settings);
2509
+ send(message) {
2510
+ // @ts-ignore
2511
+ this._rawIpc.postMessage(message);
2512
+ }
2513
+ sendAndTransfer(message) {
2514
+ const transfer = getTransferrables(message);
2515
+ // @ts-ignore
2516
+ this._rawIpc.postMessage(message, transfer);
2517
+ }
2518
+ dispose() {
2519
+ // ignore
2520
+ }
2521
+ onClose(callback) {
2522
+ // ignore
2523
+ }
2524
+ onMessage(callback) {
2525
+ this._rawIpc.addEventListener('message', callback);
2526
+ }
2527
+ }
2528
+ const wrap$f = global => {
2529
+ return new IpcChildWithModuleWorker(global);
2527
2530
  };
2528
-
2529
- const getSettingsTableEntries = rows => {
2530
- const textId = id$1();
2531
- const textLabel = label();
2532
- return {
2533
- headings: [textId, textLabel],
2534
- rows
2531
+ const waitForFirstMessage = async port => {
2532
+ const {
2533
+ promise,
2534
+ resolve
2535
+ } = Promise.withResolvers();
2536
+ port.addEventListener('message', resolve, {
2537
+ once: true
2538
+ });
2539
+ const event = await promise;
2540
+ // @ts-ignore
2541
+ return event.data;
2542
+ };
2543
+ const listen$6 = async () => {
2544
+ const parentIpcRaw = listen$7();
2545
+ signal$8(parentIpcRaw);
2546
+ const parentIpc = wrap$f(parentIpcRaw);
2547
+ const firstMessage = await waitForFirstMessage(parentIpc);
2548
+ if (firstMessage.method !== 'initialize') {
2549
+ throw new IpcError('unexpected first message');
2550
+ }
2551
+ const type = firstMessage.params[0];
2552
+ if (type === 'message-port') {
2553
+ parentIpc.send({
2554
+ id: firstMessage.id,
2555
+ jsonrpc: '2.0',
2556
+ result: null
2557
+ });
2558
+ parentIpc.dispose();
2559
+ const port = firstMessage.params[1];
2560
+ return port;
2561
+ }
2562
+ return globalThis;
2563
+ };
2564
+ class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
2565
+ getData(event) {
2566
+ return getData$2(event);
2567
+ }
2568
+ send(message) {
2569
+ this._rawIpc.postMessage(message);
2570
+ }
2571
+ sendAndTransfer(message) {
2572
+ const transfer = getTransferrables(message);
2573
+ this._rawIpc.postMessage(message, transfer);
2574
+ }
2575
+ dispose() {
2576
+ if (this._rawIpc.close) {
2577
+ this._rawIpc.close();
2578
+ }
2579
+ }
2580
+ onClose(callback) {
2581
+ // ignore
2582
+ }
2583
+ onMessage(callback) {
2584
+ this._rawIpc.addEventListener('message', callback);
2585
+ this._rawIpc.start();
2586
+ }
2587
+ }
2588
+ const wrap$e = port => {
2589
+ return new IpcChildWithModuleWorkerAndMessagePort(port);
2590
+ };
2591
+ const IpcChildWithModuleWorkerAndMessagePort$1 = {
2592
+ __proto__: null,
2593
+ listen: listen$6,
2594
+ wrap: wrap$e
2595
+ };
2596
+ const addListener = (emitter, type, callback) => {
2597
+ if ('addEventListener' in emitter) {
2598
+ emitter.addEventListener(type, callback);
2599
+ } else {
2600
+ emitter.on(type, callback);
2601
+ }
2602
+ };
2603
+ const removeListener = (emitter, type, callback) => {
2604
+ if ('removeEventListener' in emitter) {
2605
+ emitter.removeEventListener(type, callback);
2606
+ } else {
2607
+ emitter.off(type, callback);
2608
+ }
2609
+ };
2610
+ const getFirstEvent = (eventEmitter, eventMap) => {
2611
+ const {
2612
+ promise,
2613
+ resolve
2614
+ } = Promise.withResolvers();
2615
+ const listenerMap = Object.create(null);
2616
+ const cleanup = value => {
2617
+ for (const event of Object.keys(eventMap)) {
2618
+ removeListener(eventEmitter, event, listenerMap[event]);
2619
+ }
2620
+ resolve(value);
2535
2621
  };
2622
+ for (const [event, type] of Object.entries(eventMap)) {
2623
+ const listener = event => {
2624
+ cleanup({
2625
+ event,
2626
+ type
2627
+ });
2628
+ };
2629
+ addListener(eventEmitter, event, listener);
2630
+ listenerMap[event] = listener;
2631
+ }
2632
+ return promise;
2536
2633
  };
2537
-
2538
- const getFeatureSettingsVirtualDom = rows => {
2539
- const heading = settings();
2540
- const tableInfo = getSettingsTableEntries(rows);
2541
- return [{
2542
- childCount: 2,
2543
- className: FeatureContent,
2544
- type: Div
2545
- }, ...getFeatureContentHeadingVirtualDom(heading), ...getTableVirtualDom(tableInfo)];
2634
+ const Message$1 = 3;
2635
+ const create$5$1 = async ({
2636
+ isMessagePortOpen,
2637
+ messagePort
2638
+ }) => {
2639
+ if (!isMessagePort(messagePort)) {
2640
+ throw new IpcError('port must be of type MessagePort');
2641
+ }
2642
+ if (isMessagePortOpen) {
2643
+ return messagePort;
2644
+ }
2645
+ const eventPromise = getFirstEvent(messagePort, {
2646
+ message: Message$1
2647
+ });
2648
+ messagePort.start();
2649
+ const {
2650
+ event,
2651
+ type
2652
+ } = await eventPromise;
2653
+ if (type !== Message$1) {
2654
+ throw new IpcError('Failed to wait for ipc message');
2655
+ }
2656
+ if (event.data !== readyMessage) {
2657
+ throw new IpcError('unexpected first message');
2658
+ }
2659
+ return messagePort;
2546
2660
  };
2547
-
2548
- const getSettingsVirtualDom = state => {
2549
- return getFeatureSettingsVirtualDom(state.settings);
2661
+ const signal$1 = messagePort => {
2662
+ messagePort.start();
2550
2663
  };
2551
-
2552
- const HandleClickCategory = 1;
2553
- const HandleClickDisable = 2;
2554
- const HandleClickEnable = 3;
2555
- const HandleClickScrollToTop = 4;
2556
- const HandleClickSetColorTheme = 5;
2557
- const HandleClickSettings = 6;
2558
- const HandleClickSize = 7;
2559
- const HandleClickUninstall = 8;
2560
- const HandleFeaturesClick = 9;
2561
- const HandleIconError = 10;
2562
- const HandleImageContextMenu = 11;
2563
- const HandleReadmeContextMenu = 12;
2564
- const HandleReadmeScroll = 13;
2565
- const HandleTabsClick = 14;
2566
- const HandleAdditionalDetailContextMenu = 15;
2567
- const HandleReadmeClick = 16;
2568
- const HandleSelectionChange = 17;
2569
- const HandleTabFocus = 18;
2570
- const HandleResourceLinkClick = 19;
2571
-
2572
- const ActivationEvents = 'ActivationEvents';
2573
- const Changelog = 'Changelog';
2574
- const Commands = 'Commands';
2575
- const Details = 'Details';
2576
- const Enable = 'Enable';
2577
- const Disable = 'Disable';
2578
- const Features = 'Features';
2579
- const JsonValidation = 'JsonValidation';
2580
- const ProgrammingLanguages = 'ProgrammingLanguages';
2581
- const RuntimeStatus = 'RuntimeStatus';
2582
- const ScrollToTop = 'scrolltotop';
2583
- const SetColorTheme = 'SetColorTheme';
2584
- const Settings = 'Settings';
2585
- const Theme = 'Theme';
2586
- const Uninstall = 'Uninstall';
2587
- const WebViews = 'WebViews';
2588
-
2589
- const getScrollToTopVirtualDom = scrollToTopButtonEnabled => {
2590
- return [{
2591
- ariaLabel: scrollToTop(),
2592
- childCount: 1,
2593
- className: ScrollToTopButton,
2594
- name: ScrollToTop,
2595
- onClick: HandleClickScrollToTop,
2596
- type: Button$1
2597
- }, {
2598
- childCount: 0,
2599
- className: mergeClassNames(MaskIcon, MaskIconChevronUp),
2600
- role: None$3,
2601
- type: Div
2602
- }];
2664
+ class IpcParentWithMessagePort extends Ipc {
2665
+ getData = getData$2;
2666
+ send(message) {
2667
+ this._rawIpc.postMessage(message);
2668
+ }
2669
+ sendAndTransfer(message) {
2670
+ const transfer = getTransferrables(message);
2671
+ this._rawIpc.postMessage(message, transfer);
2672
+ }
2673
+ dispose() {
2674
+ this._rawIpc.close();
2675
+ }
2676
+ onMessage(callback) {
2677
+ this._rawIpc.addEventListener('message', callback);
2678
+ }
2679
+ onClose(callback) {}
2680
+ }
2681
+ const wrap$5 = messagePort => {
2682
+ return new IpcParentWithMessagePort(messagePort);
2683
+ };
2684
+ const IpcParentWithMessagePort$1 = {
2685
+ __proto__: null,
2686
+ create: create$5$1,
2687
+ signal: signal$1,
2688
+ wrap: wrap$5
2603
2689
  };
2604
2690
 
2605
- /* eslint-disable unicorn/prefer-export-from */
2606
-
2607
- const {
2608
- getVirtualDom,
2609
- render,
2610
- set: set$3
2611
- } = MarkdownWorker;
2612
-
2613
- const getMarkdownVirtualDom = async (html, options) => {
2614
- string(html);
2615
- const dom = await getVirtualDom(html);
2616
- if (options?.scrollToTopEnabled) {
2617
- const [firstNode, ...rest] = dom;
2618
- const extraDom = getScrollToTopVirtualDom();
2619
- return [{
2620
- ...firstNode,
2621
- childCount: firstNode.childCount + 1,
2622
- onClick: HandleReadmeClick,
2623
- onScroll: HandleReadmeScroll,
2624
- onSelectionChange: HandleSelectionChange
2625
- }, ...extraDom, ...rest];
2691
+ const Two$1 = '2.0';
2692
+ const callbacks = Object.create(null);
2693
+ const get$1 = id => {
2694
+ return callbacks[id];
2695
+ };
2696
+ const remove = id => {
2697
+ delete callbacks[id];
2698
+ };
2699
+ class JsonRpcError extends Error {
2700
+ constructor(message) {
2701
+ super(message);
2702
+ this.name = 'JsonRpcError';
2626
2703
  }
2627
- return dom;
2704
+ }
2705
+ const NewLine = '\n';
2706
+ const DomException = 'DOMException';
2707
+ const ReferenceError$1 = 'ReferenceError';
2708
+ const SyntaxError$1 = 'SyntaxError';
2709
+ const TypeError$1 = 'TypeError';
2710
+ const getErrorConstructor = (message, type) => {
2711
+ if (type) {
2712
+ switch (type) {
2713
+ case DomException:
2714
+ return DOMException;
2715
+ case ReferenceError$1:
2716
+ return ReferenceError;
2717
+ case SyntaxError$1:
2718
+ return SyntaxError;
2719
+ case TypeError$1:
2720
+ return TypeError;
2721
+ default:
2722
+ return Error;
2723
+ }
2724
+ }
2725
+ if (message.startsWith('TypeError: ')) {
2726
+ return TypeError;
2727
+ }
2728
+ if (message.startsWith('SyntaxError: ')) {
2729
+ return SyntaxError;
2730
+ }
2731
+ if (message.startsWith('ReferenceError: ')) {
2732
+ return ReferenceError;
2733
+ }
2734
+ return Error;
2628
2735
  };
2629
-
2630
- const getThemeItemMarkdown = (heading, items) => {
2631
- let markdown = '';
2632
- if (items.length > 0) {
2633
- markdown += `### ${heading}`;
2634
- markdown += '\n\n';
2635
- for (const item of items) {
2636
- markdown += `- ${item.label}`;
2637
- markdown += '\n';
2736
+ const constructError = (message, type, name) => {
2737
+ const ErrorConstructor = getErrorConstructor(message, type);
2738
+ if (ErrorConstructor === DOMException && name) {
2739
+ return new ErrorConstructor(message, name);
2740
+ }
2741
+ if (ErrorConstructor === Error) {
2742
+ const error = new Error(message);
2743
+ if (name && name !== 'VError') {
2744
+ error.name = name;
2638
2745
  }
2746
+ return error;
2639
2747
  }
2640
- return markdown;
2748
+ return new ErrorConstructor(message);
2641
2749
  };
2642
-
2643
- const getColorThemeMarkdown = themes => {
2644
- const heading = 'Color Themes';
2645
- return getThemeItemMarkdown(heading, themes);
2750
+ const joinLines = lines => {
2751
+ return lines.join(NewLine);
2646
2752
  };
2647
- const getIconThemeMarkdown = iconThemes => {
2648
- const heading = 'File Icon Themes';
2649
- return getThemeItemMarkdown(heading, iconThemes);
2753
+ const splitLines = lines => {
2754
+ return lines.split(NewLine);
2650
2755
  };
2651
- const getProductIconThemeMarkdown = iconThemes => {
2652
- const heading = 'Product Icon Themes';
2653
- return getThemeItemMarkdown(heading, iconThemes);
2756
+ const getCurrentStack = () => {
2757
+ const stackLinesToSkip = 3;
2758
+ const currentStack = joinLines(splitLines(new Error().stack || '').slice(stackLinesToSkip));
2759
+ return currentStack;
2654
2760
  };
2655
- const getThemeMarkdown = (themes, iconThemes, productIconThemes) => {
2656
- let markdown = '';
2657
- markdown += getColorThemeMarkdown(themes);
2658
- markdown += getIconThemeMarkdown(iconThemes);
2659
- markdown += getProductIconThemeMarkdown(productIconThemes);
2660
- return markdown;
2761
+ const getNewLineIndex = (string, startIndex = undefined) => {
2762
+ return string.indexOf(NewLine, startIndex);
2661
2763
  };
2662
-
2663
- const padBytes = bytes => {
2664
- return bytes.toString(16).padStart(2, '0');
2764
+ const getParentStack = error => {
2765
+ let parentStack = error.stack || error.data || error.message || '';
2766
+ if (parentStack.startsWith(' at')) {
2767
+ parentStack = error.message + NewLine + parentStack;
2768
+ }
2769
+ return parentStack;
2665
2770
  };
2666
- const hash = async content => {
2667
- const sourceBytes = new TextEncoder().encode(content);
2668
- const digest = await crypto.subtle.digest('SHA-256', sourceBytes);
2669
- const resultBytes = [...new Uint8Array(digest)];
2670
- return resultBytes.map(padBytes).join('');
2771
+ const MethodNotFound = -32601;
2772
+ const Custom = -32001;
2773
+ const restoreJsonRpcError = error => {
2774
+ const currentStack = getCurrentStack();
2775
+ if (error && error instanceof Error) {
2776
+ if (typeof error.stack === 'string') {
2777
+ error.stack = error.stack + NewLine + currentStack;
2778
+ }
2779
+ return error;
2780
+ }
2781
+ if (error && error.code && error.code === MethodNotFound) {
2782
+ const restoredError = new JsonRpcError(error.message);
2783
+ const parentStack = getParentStack(error);
2784
+ restoredError.stack = parentStack + NewLine + currentStack;
2785
+ return restoredError;
2786
+ }
2787
+ if (error && error.message) {
2788
+ const restoredError = constructError(error.message, error.type, error.name);
2789
+ if (error.data) {
2790
+ if (error.data.stack && error.data.type && error.message) {
2791
+ restoredError.stack = error.data.type + ': ' + error.message + NewLine + error.data.stack + NewLine + currentStack;
2792
+ } else if (error.data.stack) {
2793
+ restoredError.stack = error.data.stack;
2794
+ }
2795
+ if (error.data.codeFrame) {
2796
+ // @ts-ignore
2797
+ restoredError.codeFrame = error.data.codeFrame;
2798
+ }
2799
+ if (error.data.code) {
2800
+ // @ts-ignore
2801
+ restoredError.code = error.data.code;
2802
+ }
2803
+ if (error.data.type) {
2804
+ // @ts-ignore
2805
+ restoredError.name = error.data.type;
2806
+ }
2807
+ } else {
2808
+ if (error.stack) {
2809
+ const lowerStack = restoredError.stack || '';
2810
+ // @ts-ignore
2811
+ const indexNewLine = getNewLineIndex(lowerStack);
2812
+ const parentStack = getParentStack(error);
2813
+ // @ts-ignore
2814
+ restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
2815
+ }
2816
+ if (error.codeFrame) {
2817
+ // @ts-ignore
2818
+ restoredError.codeFrame = error.codeFrame;
2819
+ }
2820
+ }
2821
+ return restoredError;
2822
+ }
2823
+ if (typeof error === 'string') {
2824
+ return new Error(`JsonRpc Error: ${error}`);
2825
+ }
2826
+ return new Error(`JsonRpc Error: ${error}`);
2671
2827
  };
2672
-
2673
- const supportsNormalCacheKey = locationProtocol => {
2674
- return locationProtocol === 'http:' || locationProtocol === 'https:';
2828
+ const unwrapJsonRpcResult = responseMessage => {
2829
+ if ('error' in responseMessage) {
2830
+ const restoredError = restoreJsonRpcError(responseMessage.error);
2831
+ throw restoredError;
2832
+ }
2833
+ if ('result' in responseMessage) {
2834
+ return responseMessage.result;
2835
+ }
2836
+ throw new JsonRpcError('unexpected response message');
2675
2837
  };
2676
-
2677
- const getMarkdownCacheHash = async (markdown, options) => {
2678
- const stringifiedOptions = JSON.stringify(options);
2679
- const contents = `${markdown}:${stringifiedOptions}:${options.commit}`;
2680
- return hash(contents);
2838
+ const warn = (...args) => {
2839
+ console.warn(...args);
2681
2840
  };
2682
- const getMarkdownCacheKey = async (markdown, options) => {
2683
- const hash = await getMarkdownCacheHash(markdown, options);
2684
- if (supportsNormalCacheKey(options.locationProtocol)) {
2685
- return `/markdown/${hash}`;
2841
+ const resolve = (id, response) => {
2842
+ const fn = get$1(id);
2843
+ if (!fn) {
2844
+ console.log(response);
2845
+ warn(`callback ${id} may already be disposed`);
2846
+ return;
2686
2847
  }
2687
- // workaround for electron bug
2688
- return `https://-/markdown/${hash}`;
2848
+ fn(response);
2849
+ remove(id);
2689
2850
  };
2690
-
2691
- // TODO pass application name from renderer worker to not hardcode it
2692
-
2693
- const cachedCaches = Object.create(null);
2694
- const noopCache = {
2695
- async match() {
2696
- return undefined;
2697
- },
2698
- async put() {}
2851
+ const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
2852
+ const getErrorType = prettyError => {
2853
+ if (prettyError && prettyError.type) {
2854
+ return prettyError.type;
2855
+ }
2856
+ if (prettyError && prettyError.constructor && prettyError.constructor.name) {
2857
+ return prettyError.constructor.name;
2858
+ }
2859
+ return undefined;
2699
2860
  };
2700
- const supportsStorageBuckets = () => {
2701
- // @ts-ignore
2702
- return Boolean(navigator.storageBuckets);
2861
+ const isAlreadyStack = line => {
2862
+ return line.trim().startsWith('at ');
2703
2863
  };
2704
- const getCacheInternal = async (cacheName, bucketName) => {
2705
- if (!supportsStorageBuckets()) {
2706
- return noopCache;
2864
+ const getStack = prettyError => {
2865
+ const stackString = prettyError.stack || '';
2866
+ const newLineIndex = stackString.indexOf('\n');
2867
+ if (newLineIndex !== -1 && !isAlreadyStack(stackString.slice(0, newLineIndex))) {
2868
+ return stackString.slice(newLineIndex + 1);
2707
2869
  }
2708
- const twoWeeks = 14 * 24 * 60 * 60 * 1000;
2709
- // @ts-ignore
2710
- const bucket = await navigator.storageBuckets.open(bucketName, {
2711
- expires: Date.now() + twoWeeks,
2712
- quota: 100 * 1024 * 1024 // 100MB
2713
- });
2714
- const cache = await bucket.caches.open(cacheName);
2715
- return cache;
2870
+ return stackString;
2716
2871
  };
2717
- const getCache = (cacheName, bucketName) => {
2718
- if (!(cacheName in cachedCaches)) {
2719
- cachedCaches[cacheName] = getCacheInternal(cacheName, bucketName);
2872
+ const getErrorProperty = (error, prettyError) => {
2873
+ if (error && error.code === E_COMMAND_NOT_FOUND) {
2874
+ return {
2875
+ code: MethodNotFound,
2876
+ data: error.stack,
2877
+ message: error.message
2878
+ };
2720
2879
  }
2721
- return cachedCaches[cacheName];
2880
+ return {
2881
+ code: Custom,
2882
+ data: {
2883
+ code: prettyError.code,
2884
+ codeFrame: prettyError.codeFrame,
2885
+ name: prettyError.name,
2886
+ stack: getStack(prettyError),
2887
+ type: getErrorType(prettyError)
2888
+ },
2889
+ message: prettyError.message
2890
+ };
2891
+ };
2892
+ const create$1$1 = (id, error) => {
2893
+ return {
2894
+ error,
2895
+ id,
2896
+ jsonrpc: Two$1
2897
+ };
2898
+ };
2899
+ const getErrorResponse = (id, error, preparePrettyError, logError) => {
2900
+ const prettyError = preparePrettyError(error);
2901
+ logError(error, prettyError);
2902
+ const errorProperty = getErrorProperty(error, prettyError);
2903
+ return create$1$1(id, errorProperty);
2722
2904
  };
2723
-
2724
- // TODO pass application name from renderer worker to not hardcode it
2725
- const cacheName = 'lvce-editor/markdown-cache';
2726
- const has = async (key, bucketName) => {
2727
- const cache = await getCache(cacheName, bucketName);
2728
- const response = await cache.match(key);
2729
- return Boolean(response);
2905
+ const create$9 = (message, result) => {
2906
+ return {
2907
+ id: message.id,
2908
+ jsonrpc: Two$1,
2909
+ result: result ?? null
2910
+ };
2730
2911
  };
2731
- const get$1 = async (key, bucketName) => {
2732
- const cache = await getCache(cacheName, bucketName);
2733
- const response = await cache.match(key);
2734
- const text = await response?.text();
2735
- return text || '';
2912
+ const getSuccessResponse = (message, result) => {
2913
+ const resultProperty = result ?? null;
2914
+ return create$9(message, resultProperty);
2736
2915
  };
2737
- const set$2 = async (key, bucketName, value) => {
2738
- const cache = await getCache(cacheName, bucketName);
2739
- await cache.put(key, new Response(value, {
2740
- headers: {
2741
- 'Content-Length': `${value.length}`,
2742
- 'Content-Type': 'application/markdown'
2743
- }
2744
- }));
2916
+ const getErrorResponseSimple = (id, error) => {
2917
+ return {
2918
+ error: {
2919
+ code: Custom,
2920
+ data: error,
2921
+ // @ts-ignore
2922
+ message: error.message
2923
+ },
2924
+ id,
2925
+ jsonrpc: Two$1
2926
+ };
2745
2927
  };
2746
-
2747
- const renderMarkdownCached = async (markdown, options) => {
2748
- const cacheKey = await getMarkdownCacheKey(markdown, options);
2749
- const bucketName = `markdown-cache`;
2750
- const hasItem = await has(cacheKey, bucketName);
2751
- if (hasItem) {
2752
- const value = await get$1(cacheKey, bucketName);
2753
- return value; // TODO validate if it's valid
2928
+ const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
2929
+ try {
2930
+ const result = requiresSocket(message.method) ? await execute(message.method, ipc, ...message.params) : await execute(message.method, ...message.params);
2931
+ return getSuccessResponse(message, result);
2932
+ } catch (error) {
2933
+ if (ipc.canUseSimpleErrorResponse) {
2934
+ return getErrorResponseSimple(message.id, error);
2935
+ }
2936
+ return getErrorResponse(message.id, error, preparePrettyError, logError);
2754
2937
  }
2755
- const html = await render(markdown, options);
2756
- await set$2(cacheKey, bucketName, html);
2757
- return html;
2758
2938
  };
2759
-
2760
- const renderMarkdown = async (markdown, options) => {
2761
- const html = await renderMarkdownCached(markdown, options);
2762
- return html;
2939
+ const defaultPreparePrettyError = error => {
2940
+ return error;
2941
+ };
2942
+ const defaultLogError = () => {
2943
+ // ignore
2944
+ };
2945
+ const defaultRequiresSocket = () => {
2946
+ return false;
2763
2947
  };
2948
+ const defaultResolve = resolve;
2764
2949
 
2765
- const getThemeDetails = async (extension, baseUrl, locationProtocol) => {
2766
- const {
2767
- colorThemes,
2768
- iconThemes,
2769
- productIconThemes
2770
- } = extension;
2771
- const markdown = getThemeMarkdown(colorThemes || [], iconThemes || [], productIconThemes || []);
2772
- const rendered = await renderMarkdown(markdown, {
2773
- baseUrl,
2774
- locationProtocol
2775
- });
2776
- const themesMarkdownDom = await getMarkdownVirtualDom(rendered);
2950
+ // TODO maybe remove this in v6 or v7, only accept options object to simplify the code
2951
+ const normalizeParams = args => {
2952
+ if (args.length === 1) {
2953
+ const options = args[0];
2954
+ return {
2955
+ execute: options.execute,
2956
+ ipc: options.ipc,
2957
+ logError: options.logError || defaultLogError,
2958
+ message: options.message,
2959
+ preparePrettyError: options.preparePrettyError || defaultPreparePrettyError,
2960
+ requiresSocket: options.requiresSocket || defaultRequiresSocket,
2961
+ resolve: options.resolve || defaultResolve
2962
+ };
2963
+ }
2777
2964
  return {
2778
- themesMarkdownDom
2965
+ execute: args[2],
2966
+ ipc: args[0],
2967
+ logError: args[5],
2968
+ message: args[1],
2969
+ preparePrettyError: args[4],
2970
+ requiresSocket: args[6],
2971
+ resolve: args[3]
2779
2972
  };
2780
2973
  };
2781
-
2782
- const featureColorThemeEnabled = extension => {
2783
- if (!hasProperty(extension, 'colorThemes')) {
2784
- return false;
2974
+ const handleJsonRpcMessage = async (...args) => {
2975
+ const options = normalizeParams(args);
2976
+ const {
2977
+ execute,
2978
+ ipc,
2979
+ logError,
2980
+ message,
2981
+ preparePrettyError,
2982
+ requiresSocket,
2983
+ resolve
2984
+ } = options;
2985
+ if ('id' in message) {
2986
+ if ('method' in message) {
2987
+ const response = await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
2988
+ try {
2989
+ ipc.send(response);
2990
+ } catch (error) {
2991
+ const errorResponse = getErrorResponse(message.id, error, preparePrettyError, logError);
2992
+ ipc.send(errorResponse);
2993
+ }
2994
+ return;
2995
+ }
2996
+ resolve(message.id, message);
2997
+ return;
2785
2998
  }
2786
- return Array.isArray(extension.colorThemes);
2787
- };
2788
-
2789
- const featureIconThemeEnabled = extension => {
2790
- if (!hasProperty(extension, 'iconThemes')) {
2791
- return false;
2999
+ if ('method' in message) {
3000
+ await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
3001
+ return;
2792
3002
  }
2793
- return Array.isArray(extension.iconThemes);
3003
+ throw new JsonRpcError('unexpected message');
2794
3004
  };
2795
3005
 
2796
- const featureProductIconThemeEnabled = extension => {
2797
- if (!hasProperty(extension, 'productIconThemes')) {
2798
- return false;
2799
- }
2800
- return Array.isArray(extension.productIconThemes);
2801
- };
3006
+ const Two = '2.0';
2802
3007
 
2803
- const featureThemeEnabled = extension => {
2804
- return featureColorThemeEnabled(extension) || featureIconThemeEnabled(extension) || featureProductIconThemeEnabled(extension);
3008
+ const create$8 = (method, params) => {
3009
+ return {
3010
+ jsonrpc: Two,
3011
+ method,
3012
+ params
3013
+ };
2805
3014
  };
2806
3015
 
2807
- const getVirtualDomChildCount = dom => {
2808
- const max = dom.length - 1;
2809
- let stack = [];
2810
- for (let i = max; i >= 0; i--) {
2811
- const element = dom[i];
2812
- if (element.childCount > 0) {
2813
- stack = stack.slice(element.childCount);
2814
- }
2815
- stack.unshift(element);
2816
- }
2817
- return stack.length;
3016
+ const create$7 = (id, method, params) => {
3017
+ const message = {
3018
+ id,
3019
+ jsonrpc: Two,
3020
+ method,
3021
+ params
3022
+ };
3023
+ return message;
2818
3024
  };
2819
3025
 
2820
- const getFeatureThemesVirtualDom = themesDom => {
2821
- const childCount = getVirtualDomChildCount(themesDom);
2822
- const heading = theme();
2823
- return [{
2824
- childCount: 2,
2825
- className: FeatureContent,
2826
- type: Div
2827
- }, ...getFeatureContentHeadingVirtualDom(heading), {
2828
- childCount,
2829
- className: DefaultMarkdown,
2830
- type: Div
2831
- }, ...themesDom];
3026
+ let id = 0;
3027
+ const create$6 = () => {
3028
+ return ++id;
2832
3029
  };
2833
3030
 
2834
- const getThemeVirtualDom = state => {
2835
- return getFeatureThemesVirtualDom(state.themesMarkdownDom);
3031
+ const registerPromise = map => {
3032
+ const id = create$6();
3033
+ const {
3034
+ promise,
3035
+ resolve
3036
+ } = Promise.withResolvers();
3037
+ map[id] = resolve;
3038
+ return {
3039
+ id,
3040
+ promise
3041
+ };
2836
3042
  };
2837
3043
 
2838
- const toWebView = rawWebView => {
3044
+ const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer) => {
2839
3045
  const {
2840
- contentSecurityPolicy,
2841
- elements,
2842
- id,
2843
- selector
2844
- } = rawWebView;
2845
- return {
2846
- contentSecurityPolicyString: JSON.stringify(contentSecurityPolicy),
2847
- elementsString: JSON.stringify(elements, null, 2),
2848
3046
  id,
2849
- selectorString: JSON.stringify(selector)
3047
+ promise
3048
+ } = registerPromise(callbacks);
3049
+ const message = create$7(id, method, params);
3050
+ if (useSendAndTransfer && ipc.sendAndTransfer) {
3051
+ ipc.sendAndTransfer(message);
3052
+ } else {
3053
+ ipc.send(message);
3054
+ }
3055
+ const responseMessage = await promise;
3056
+ return unwrapJsonRpcResult(responseMessage);
3057
+ };
3058
+ const createRpc = ipc => {
3059
+ const callbacks = Object.create(null);
3060
+ ipc._resolve = (id, response) => {
3061
+ const fn = callbacks[id];
3062
+ if (!fn) {
3063
+ console.warn(`callback ${id} may already be disposed`);
3064
+ return;
3065
+ }
3066
+ fn(response);
3067
+ delete callbacks[id];
3068
+ };
3069
+ const rpc = {
3070
+ async dispose() {
3071
+ await ipc?.dispose();
3072
+ },
3073
+ invoke(method, ...params) {
3074
+ return invokeHelper(callbacks, ipc, method, params, false);
3075
+ },
3076
+ invokeAndTransfer(method, ...params) {
3077
+ return invokeHelper(callbacks, ipc, method, params, true);
3078
+ },
3079
+ // @ts-ignore
3080
+ ipc,
3081
+ /**
3082
+ * @deprecated
3083
+ */
3084
+ send(method, ...params) {
3085
+ const message = create$8(method, params);
3086
+ ipc.send(message);
3087
+ }
2850
3088
  };
3089
+ return rpc;
2851
3090
  };
2852
3091
 
2853
- const getWebViews = extension => {
2854
- const rawWebViews = extension.webViews || [];
2855
- return rawWebViews.map(toWebView);
3092
+ const requiresSocket = () => {
3093
+ return false;
3094
+ };
3095
+ const preparePrettyError = error => {
3096
+ return error;
3097
+ };
3098
+ const logError = () => {
3099
+ // handled by renderer worker
3100
+ };
3101
+ const handleMessage = event => {
3102
+ const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket;
3103
+ const actualExecute = event?.target?.execute || execute;
3104
+ return handleJsonRpcMessage(event.target, event.data, actualExecute, event.target._resolve, preparePrettyError, logError, actualRequiresSocket);
2856
3105
  };
2857
3106
 
2858
- const getWebViewsDetails = async extension => {
2859
- const webViews = getWebViews(extension);
2860
- return {
2861
- webViews
2862
- };
3107
+ const handleIpc = ipc => {
3108
+ if ('addEventListener' in ipc) {
3109
+ ipc.addEventListener('message', handleMessage);
3110
+ } else if ('on' in ipc) {
3111
+ // deprecated
3112
+ ipc.on('message', handleMessage);
3113
+ }
2863
3114
  };
2864
3115
 
2865
- const featureWebViewsEnabled = extension => {
2866
- if (!hasProperty(extension, 'webViews')) {
2867
- return false;
3116
+ const listen$1 = async (module, options) => {
3117
+ const rawIpc = await module.listen(options);
3118
+ if (module.signal) {
3119
+ module.signal(rawIpc);
2868
3120
  }
2869
- return Array.isArray(extension.webViews);
3121
+ const ipc = module.wrap(rawIpc);
3122
+ return ipc;
2870
3123
  };
2871
3124
 
2872
- const heading = {
2873
- childCount: 1,
2874
- className: DefinitionListItemHeading,
2875
- type: H2
2876
- };
2877
- const pre = {
2878
- childCount: 1,
2879
- className: DefinitionListItemValue,
2880
- type: Pre
2881
- };
2882
- const item = {
2883
- childCount: 2,
2884
- className: DefinitionListItem,
2885
- type: Div
3125
+ const create$5 = async ({
3126
+ commandMap,
3127
+ isMessagePortOpen = true,
3128
+ messagePort
3129
+ }) => {
3130
+ // TODO create a commandMap per rpc instance
3131
+ register(commandMap);
3132
+ const rawIpc = await IpcParentWithMessagePort$1.create({
3133
+ isMessagePortOpen,
3134
+ messagePort
3135
+ });
3136
+ const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
3137
+ handleIpc(ipc);
3138
+ const rpc = createRpc(ipc);
3139
+ messagePort.start();
3140
+ return rpc;
2886
3141
  };
2887
- const getWebViewVirtualDom = webView => {
3142
+
3143
+ const create$4 = async ({
3144
+ commandMap,
3145
+ isMessagePortOpen,
3146
+ send
3147
+ }) => {
2888
3148
  const {
2889
- contentSecurityPolicyString,
2890
- elementsString,
2891
- id,
2892
- selectorString
2893
- } = webView;
2894
- const textId = id$1();
2895
- const textSelector = selector();
2896
- const textContentSecurityPolicy = contentSecurityPolicy();
2897
- const textElements = elements();
2898
- return [{
2899
- childCount: 4,
2900
- className: FeatureWebView,
2901
- type: Div
2902
- }, item, heading, text(textId), pre, text(id), item, heading, text(textSelector), pre, text(selectorString), item, heading, text(textContentSecurityPolicy), pre, text(contentSecurityPolicyString), item, heading, text(textElements), pre, text(elementsString)];
3149
+ port1,
3150
+ port2
3151
+ } = new MessageChannel();
3152
+ await send(port1);
3153
+ return create$5({
3154
+ commandMap,
3155
+ isMessagePortOpen,
3156
+ messagePort: port2
3157
+ });
2903
3158
  };
2904
3159
 
2905
- const getFeatureWebViewsVirtualDom = webViews$1 => {
2906
- const heading = webViews();
2907
- return [{
2908
- childCount: 2,
2909
- className: FeatureContent,
2910
- type: Div
2911
- }, ...getFeatureContentHeadingVirtualDom(heading), {
2912
- childCount: webViews$1.length,
2913
- type: Div
2914
- }, ...webViews$1.flatMap(getWebViewVirtualDom)];
3160
+ const createSharedLazyRpc = factory => {
3161
+ let rpcPromise;
3162
+ const getOrCreate = () => {
3163
+ if (!rpcPromise) {
3164
+ rpcPromise = factory();
3165
+ }
3166
+ return rpcPromise;
3167
+ };
3168
+ return {
3169
+ async dispose() {
3170
+ const rpc = await getOrCreate();
3171
+ await rpc.dispose();
3172
+ },
3173
+ async invoke(method, ...params) {
3174
+ const rpc = await getOrCreate();
3175
+ return rpc.invoke(method, ...params);
3176
+ },
3177
+ async invokeAndTransfer(method, ...params) {
3178
+ const rpc = await getOrCreate();
3179
+ return rpc.invokeAndTransfer(method, ...params);
3180
+ },
3181
+ async send(method, ...params) {
3182
+ const rpc = await getOrCreate();
3183
+ rpc.send(method, ...params);
3184
+ }
3185
+ };
2915
3186
  };
2916
3187
 
2917
- const getWebViewsVirtualDom = state => {
2918
- return getFeatureWebViewsVirtualDom(state.webViews);
3188
+ const create$3 = async ({
3189
+ commandMap,
3190
+ isMessagePortOpen,
3191
+ send
3192
+ }) => {
3193
+ return createSharedLazyRpc(() => {
3194
+ return create$4({
3195
+ commandMap,
3196
+ isMessagePortOpen,
3197
+ send
3198
+ });
3199
+ });
2919
3200
  };
2920
3201
 
2921
- const registerAllFeatures = () => {
2922
- register$1({
2923
- getDetails: getThemeDetails,
2924
- getLabel: theme,
2925
- getVirtualDom: getThemeVirtualDom,
2926
- id: Theme,
2927
- isEnabled: featureThemeEnabled
2928
- });
2929
- register$1({
2930
- getDetails: getCommandsDetails,
2931
- getLabel: commands$1,
2932
- getVirtualDom: getCommandsVirtualDom,
2933
- id: Commands,
2934
- isEnabled: featureCommandsEnabled
2935
- });
2936
- register$1({
2937
- getDetails: getSettingsDetails,
2938
- getLabel: settings,
2939
- getVirtualDom: getSettingsVirtualDom,
2940
- id: Settings,
2941
- isEnabled: featureSettingsEnabled
2942
- });
2943
- register$1({
2944
- getDetails: getJsonValidationDetails,
2945
- getLabel: jsonValidation,
2946
- getVirtualDom: getJsonValidationVirtualDom,
2947
- id: JsonValidation,
2948
- isEnabled: featureJsonValidationEnabled
2949
- });
2950
- register$1({
2951
- getDetails: getFeatureDetailsProgrammingLanguages,
2952
- getLabel: programmingLanguages,
2953
- getVirtualDom: getProgrammingLanguagesVirtualDom,
2954
- id: ProgrammingLanguages,
2955
- isEnabled: featureProgrammingLanguagesEnabled
2956
- });
2957
- register$1({
2958
- getDetails: getWebViewsDetails,
2959
- getLabel: webViews,
2960
- getVirtualDom: getWebViewsVirtualDom,
2961
- id: WebViews,
2962
- isEnabled: featureWebViewsEnabled
2963
- });
2964
- register$1({
2965
- getDetails: getActivationEventsDetails,
2966
- getLabel: activationEvents,
2967
- getVirtualDom: getActivationEventsVirtualDom,
2968
- id: ActivationEvents,
2969
- isEnabled: featureActivationEventsEnabled
2970
- });
2971
- register$1({
2972
- getDetails: getRuntimeStatusDetails,
2973
- getLabel: runtimeStatus,
2974
- getVirtualDom: getRuntimeStatusVirtualDom,
2975
- id: RuntimeStatus,
2976
- isEnabled: featureRuntimeStatusEnabled
2977
- });
3202
+ const create$2 = async ({
3203
+ commandMap
3204
+ }) => {
3205
+ // TODO create a commandMap per rpc instance
3206
+ register(commandMap);
3207
+ const ipc = await listen$1(IpcChildWithModuleWorkerAndMessagePort$1);
3208
+ handleIpc(ipc);
3209
+ const rpc = createRpc(ipc);
3210
+ return rpc;
2978
3211
  };
2979
3212
 
2980
3213
  const toCommandId = key => {
@@ -2985,42 +3218,68 @@ const create$1 = () => {
2985
3218
  const states = Object.create(null);
2986
3219
  const commandMapRef = {};
2987
3220
  return {
2988
- get(uid) {
2989
- return states[uid];
3221
+ clear() {
3222
+ for (const key of Object.keys(states)) {
3223
+ delete states[key];
3224
+ }
2990
3225
  },
2991
- set(uid, oldState, newState) {
2992
- states[uid] = {
2993
- oldState,
2994
- newState
2995
- };
3226
+ diff(uid, modules, numbers) {
3227
+ const {
3228
+ newState,
3229
+ oldState
3230
+ } = states[uid];
3231
+ const diffResult = [];
3232
+ for (let i = 0; i < modules.length; i++) {
3233
+ const fn = modules[i];
3234
+ if (!fn(oldState, newState)) {
3235
+ diffResult.push(numbers[i]);
3236
+ }
3237
+ }
3238
+ return diffResult;
2996
3239
  },
2997
3240
  dispose(uid) {
2998
3241
  delete states[uid];
2999
3242
  },
3243
+ get(uid) {
3244
+ return states[uid];
3245
+ },
3246
+ getCommandIds() {
3247
+ const keys = Object.keys(commandMapRef);
3248
+ const ids = keys.map(toCommandId);
3249
+ return ids;
3250
+ },
3000
3251
  getKeys() {
3001
3252
  return Object.keys(states).map(key => {
3002
- return Number.parseInt(key);
3253
+ return Number.parseFloat(key);
3003
3254
  });
3004
3255
  },
3005
- clear() {
3006
- for (const key of Object.keys(states)) {
3007
- delete states[key];
3008
- }
3256
+ registerCommands(commandMap) {
3257
+ Object.assign(commandMapRef, commandMap);
3258
+ },
3259
+ set(uid, oldState, newState) {
3260
+ states[uid] = {
3261
+ newState,
3262
+ oldState
3263
+ };
3009
3264
  },
3010
3265
  wrapCommand(fn) {
3011
3266
  const wrapped = async (uid, ...args) => {
3012
3267
  const {
3013
- oldState,
3014
- newState
3268
+ newState,
3269
+ oldState
3015
3270
  } = states[uid];
3016
3271
  const newerState = await fn(newState, ...args);
3017
3272
  if (oldState === newerState || newState === newerState) {
3018
3273
  return;
3019
3274
  }
3020
- const latest = states[uid];
3275
+ const latestOld = states[uid];
3276
+ const latestNew = {
3277
+ ...latestOld.newState,
3278
+ ...newerState
3279
+ };
3021
3280
  states[uid] = {
3022
- oldState: latest.oldState,
3023
- newState: newerState
3281
+ newState: latestNew,
3282
+ oldState: latestOld.oldState
3024
3283
  };
3025
3284
  };
3026
3285
  return wrapped;
@@ -3034,27 +3293,36 @@ const create$1 = () => {
3034
3293
  };
3035
3294
  return wrapped;
3036
3295
  },
3037
- diff(uid, modules, numbers) {
3038
- const {
3039
- oldState,
3040
- newState
3041
- } = states[uid];
3042
- const diffResult = [];
3043
- for (let i = 0; i < modules.length; i++) {
3044
- const fn = modules[i];
3045
- if (!fn(oldState, newState)) {
3046
- diffResult.push(numbers[i]);
3296
+ wrapLoadContent(fn) {
3297
+ const wrapped = async (uid, ...args) => {
3298
+ const {
3299
+ newState,
3300
+ oldState
3301
+ } = states[uid];
3302
+ const result = await fn(newState, ...args);
3303
+ const {
3304
+ error,
3305
+ state
3306
+ } = result;
3307
+ if (oldState === state || newState === state) {
3308
+ return {
3309
+ error
3310
+ };
3047
3311
  }
3048
- }
3049
- return diffResult;
3050
- },
3051
- getCommandIds() {
3052
- const keys = Object.keys(commandMapRef);
3053
- const ids = keys.map(toCommandId);
3054
- return ids;
3055
- },
3056
- registerCommands(commandMap) {
3057
- Object.assign(commandMapRef, commandMap);
3312
+ const latestOld = states[uid];
3313
+ const latestNew = {
3314
+ ...latestOld.newState,
3315
+ ...state
3316
+ };
3317
+ states[uid] = {
3318
+ newState: latestNew,
3319
+ oldState: latestOld.oldState
3320
+ };
3321
+ return {
3322
+ error
3323
+ };
3324
+ };
3325
+ return wrapped;
3058
3326
  }
3059
3327
  };
3060
3328
  };
@@ -3166,6 +3434,7 @@ const create = (uid, uri, x, y, width, height, platform, assetDir) => {
3166
3434
  hasReadme: false,
3167
3435
  iconSrc: '',
3168
3436
  importTime: 0,
3437
+ initial: true,
3169
3438
  installationEntries: [],
3170
3439
  jsonValidation: [],
3171
3440
  lastUpdated: null,
@@ -3230,9 +3499,10 @@ const RenderItems = 3;
3230
3499
  const RenderScrollTop = 4;
3231
3500
  const RenderCss = 5;
3232
3501
  const RenderFocusContext = 6;
3502
+ const RenderIncremental = 7;
3233
3503
 
3234
3504
  const modules = [isEqual$1, isEqual$2, isEqual, isEqual$3, isEqual$2];
3235
- const numbers = [RenderItems, RenderFocus, RenderScrollTop, RenderCss, RenderFocusContext];
3505
+ const numbers = [RenderIncremental, RenderFocus, RenderScrollTop, RenderCss, RenderFocusContext];
3236
3506
 
3237
3507
  const diff2 = uid => {
3238
3508
  const {
@@ -3326,7 +3596,7 @@ const getMenuEntries2 = (state, props) => {
3326
3596
  command: 'ExtensionDetail.executeCopy',
3327
3597
  flags: None$2,
3328
3598
  id: 'copy',
3329
- label: copy$1()
3599
+ label: copy()
3330
3600
  }];
3331
3601
  }
3332
3602
  return [{
@@ -3334,7 +3604,7 @@ const getMenuEntries2 = (state, props) => {
3334
3604
  command: 'ExtensionDetail.executeCopy',
3335
3605
  flags: None$2,
3336
3606
  id: 'copy',
3337
- label: copy$1()
3607
+ label: copy()
3338
3608
  }];
3339
3609
  };
3340
3610
 
@@ -3344,7 +3614,7 @@ const getCopyMenuEntry = () => ({
3344
3614
  command: 'ClipBoard.execCopy',
3345
3615
  flags: None,
3346
3616
  id: 'copy',
3347
- label: copy$1()
3617
+ label: copy()
3348
3618
  });
3349
3619
 
3350
3620
  const getImageMenuEntries = props => {
@@ -3390,7 +3660,7 @@ const getMenuEntriesReadme = () => [{
3390
3660
  command: 'ExtensionDetail.copyReadmeText',
3391
3661
  flags: None$2,
3392
3662
  id: 'copy',
3393
- label: copy$1()
3663
+ label: copy()
3394
3664
  }];
3395
3665
 
3396
3666
  const ExtensionDetailIconContextMenu$1 = 4091;
@@ -4425,6 +4695,7 @@ const loadContent = async (state, platform, savedState, isTest = false) => {
4425
4695
  hasColorTheme,
4426
4696
  hasReadme,
4427
4697
  iconSrc,
4698
+ initial: false,
4428
4699
  installationEntries,
4429
4700
  lastUpdated,
4430
4701
  linkProtectionEnabled,
@@ -4764,7 +5035,7 @@ const sendMessagePortToExtensionHostWorker = async port => {
4764
5035
 
4765
5036
  const createExtensionHostWorkerRpc = async () => {
4766
5037
  try {
4767
- const rpc = await TransferMessagePortRpcParent.create({
5038
+ const rpc = await create$4({
4768
5039
  commandMap: {},
4769
5040
  send: sendMessagePortToExtensionHostWorker
4770
5041
  });
@@ -4781,7 +5052,7 @@ const initializeExtensionHostWorker = async () => {
4781
5052
 
4782
5053
  const createExtensionManagementWorkerRpc = async () => {
4783
5054
  try {
4784
- const rpc = await TransferMessagePortRpcParent.create({
5055
+ const rpc = await create$4({
4785
5056
  commandMap: {},
4786
5057
  send: port => sendMessagePortToExtensionManagementWorker(port, 0)
4787
5058
  });
@@ -4806,7 +5077,7 @@ const sendMessagePortToFileSystemWorker = async port => {
4806
5077
 
4807
5078
  const createFileSystemWorkerRpc = async () => {
4808
5079
  try {
4809
- const rpc = await TransferMessagePortRpcParent.create({
5080
+ const rpc = await create$4({
4810
5081
  commandMap: {},
4811
5082
  send: sendMessagePortToFileSystemWorker
4812
5083
  });
@@ -4827,7 +5098,7 @@ const sendMessagePortToMarkdownWorker = async port => {
4827
5098
 
4828
5099
  const createMarkdownWorkerRpc = async () => {
4829
5100
  try {
4830
- const rpc = await TransferMessagePortRpcParent.create({
5101
+ const rpc = await create$3({
4831
5102
  commandMap: {},
4832
5103
  send: sendMessagePortToMarkdownWorker
4833
5104
  });
@@ -5387,8 +5658,15 @@ const getExtensionDetailVirtualDom = (newState, selectedTab) => {
5387
5658
  };
5388
5659
 
5389
5660
  const renderDom = (oldState, newState) => {
5661
+ const {
5662
+ initial,
5663
+ uid
5664
+ } = newState;
5665
+ if (initial) {
5666
+ return [SetDom2, uid, []];
5667
+ }
5390
5668
  const dom = getExtensionDetailVirtualDom(newState, newState.selectedTab);
5391
- return ['Viewlet.setDom2', dom];
5669
+ return [SetDom2, uid, dom];
5392
5670
  };
5393
5671
 
5394
5672
  const renderFocus = (oldState, newState) => {
@@ -5419,6 +5697,16 @@ const renderFocusContext = (oldState, newState) => {
5419
5697
  return [FocusElementByName, ''];
5420
5698
  };
5421
5699
 
5700
+ const renderIncremental = (oldState, newState) => {
5701
+ const {
5702
+ uid
5703
+ } = newState;
5704
+ const oldDom = renderDom(oldState, oldState)[2];
5705
+ const newDom = renderDom(newState, newState)[2];
5706
+ const patches = diffTree(oldDom, newDom);
5707
+ return [SetPatches, uid, patches];
5708
+ };
5709
+
5422
5710
  const getScrollTop = (selectedTab, readmeScrollTop, changelogScrollTop) => {
5423
5711
  if (selectedTab === Details) {
5424
5712
  return readmeScrollTop;
@@ -5452,6 +5740,8 @@ const getRenderer = diffType => {
5452
5740
  return renderFocus;
5453
5741
  case RenderFocusContext:
5454
5742
  return renderFocusContext;
5743
+ case RenderIncremental:
5744
+ return renderIncremental;
5455
5745
  case RenderItems:
5456
5746
  return renderDom;
5457
5747
  case RenderScrollTop:
@@ -5632,7 +5922,7 @@ const commandMap = {
5632
5922
 
5633
5923
  const listen = async () => {
5634
5924
  registerCommands(commandMap);
5635
- const rpc = await WebWorkerRpcClient.create({
5925
+ const rpc = await create$2({
5636
5926
  commandMap: commandMap
5637
5927
  });
5638
5928
  set$5(rpc);