@lvce-editor/renderer-process 10.23.0 → 10.25.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.
@@ -458,57 +458,21 @@ const create$4$1 = (method, params) => {
458
458
  params
459
459
  };
460
460
  };
461
- let AssertionError$2 = class AssertionError extends Error {
462
- constructor(message) {
463
- super(message);
464
- this.name = 'AssertionError';
465
- }
466
- };
467
- const getType$1 = value => {
468
- switch (typeof value) {
469
- case 'number':
470
- return 'number';
471
- case 'function':
472
- return 'function';
473
- case 'string':
474
- return 'string';
475
- case 'object':
476
- if (value === null) {
477
- return 'null';
478
- }
479
- if (Array.isArray(value)) {
480
- return 'array';
481
- }
482
- return 'object';
483
- case 'boolean':
484
- return 'boolean';
485
- default:
486
- return 'unknown';
487
- }
488
- };
489
- const number$1 = value => {
490
- const type = getType$1(value);
491
- if (type !== 'number') {
492
- throw new AssertionError$2('expected value to be of type number');
493
- }
494
- };
495
- const state$1$1 = {
461
+ const state$a = {
496
462
  callbacks: Object.create(null)
497
463
  };
498
464
  const set$6 = (id, fn) => {
499
- state$1$1.callbacks[id] = fn;
465
+ state$a.callbacks[id] = fn;
500
466
  };
501
467
  const get$7 = id => {
502
- return state$1$1.callbacks[id];
468
+ return state$a.callbacks[id];
503
469
  };
504
470
  const remove$3 = id => {
505
- delete state$1$1.callbacks[id];
506
- };
507
- const state$a = {
508
- id: 0
471
+ delete state$a.callbacks[id];
509
472
  };
473
+ let id = 0;
510
474
  const create$3$1 = () => {
511
- return ++state$a.id;
475
+ return ++id;
512
476
  };
513
477
  const warn$1 = (...args) => {
514
478
  console.warn(...args);
@@ -525,15 +489,14 @@ const registerPromise = () => {
525
489
  promise
526
490
  };
527
491
  };
528
- const resolve = (id, args) => {
529
- number$1(id);
492
+ const resolve = (id, response) => {
530
493
  const fn = get$7(id);
531
494
  if (!fn) {
532
- console.log(args);
495
+ console.log(response);
533
496
  warn$1(`callback ${id} may already be disposed`);
534
497
  return;
535
498
  }
536
- fn(args);
499
+ fn(response);
537
500
  remove$3(id);
538
501
  };
539
502
  const create$2$1 = (method, params) => {
@@ -755,32 +718,42 @@ const defaultRequiresSocket = () => {
755
718
  return false;
756
719
  };
757
720
  const defaultResolve = resolve;
758
- const handleJsonRpcMessage = async (...args) => {
759
- let message;
760
- let ipc;
761
- let execute;
762
- let preparePrettyError;
763
- let logError;
764
- let resolve;
765
- let requiresSocket;
721
+
722
+ // TODO maybe remove this in v6 or v7, only accept options object to simplify the code
723
+ const normalizeParams = args => {
766
724
  if (args.length === 1) {
767
- const arg = args[0];
768
- message = arg.message;
769
- ipc = arg.ipc;
770
- execute = arg.execute;
771
- preparePrettyError = arg.preparePrettyError || defaultPreparePrettyError;
772
- logError = arg.logError || defaultLogError;
773
- requiresSocket = arg.requiresSocket || defaultRequiresSocket;
774
- resolve = arg.resolve || defaultResolve;
775
- } else {
776
- ipc = args[0];
777
- message = args[1];
778
- execute = args[2];
779
- resolve = args[3];
780
- preparePrettyError = args[4];
781
- logError = args[5];
782
- requiresSocket = args[6];
725
+ const options = args[0];
726
+ return {
727
+ ipc: options.ipc,
728
+ message: options.message,
729
+ execute: options.execute,
730
+ resolve: options.resolve || defaultResolve,
731
+ preparePrettyError: options.preparePrettyError || defaultPreparePrettyError,
732
+ logError: options.logError || defaultLogError,
733
+ requiresSocket: options.requiresSocket || defaultRequiresSocket
734
+ };
783
735
  }
736
+ return {
737
+ ipc: args[0],
738
+ message: args[1],
739
+ execute: args[2],
740
+ resolve: args[3],
741
+ preparePrettyError: args[4],
742
+ logError: args[5],
743
+ requiresSocket: args[6]
744
+ };
745
+ };
746
+ const handleJsonRpcMessage = async (...args) => {
747
+ const options = normalizeParams(args);
748
+ const {
749
+ message,
750
+ ipc,
751
+ execute,
752
+ resolve,
753
+ preparePrettyError,
754
+ logError,
755
+ requiresSocket
756
+ } = options;
784
757
  if ('id' in message) {
785
758
  if ('method' in message) {
786
759
  const response = await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
@@ -801,29 +774,28 @@ const handleJsonRpcMessage = async (...args) => {
801
774
  }
802
775
  throw new JsonRpcError('unexpected message');
803
776
  };
804
- const send$1 = (transport, method, ...params) => {
805
- const message = create$4$1(method, params);
806
- transport.send(message);
807
- };
808
- const invoke$2 = async (ipc, method, ...params) => {
777
+ const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
809
778
  const {
810
779
  message,
811
780
  promise
812
781
  } = create$2$1(method, params);
813
- ipc.send(message);
782
+ if (useSendAndTransfer && ipc.sendAndTransfer) {
783
+ ipc.sendAndTransfer(message);
784
+ } else {
785
+ ipc.send(message);
786
+ }
814
787
  const responseMessage = await promise;
815
- const result = unwrapJsonRpcResult(responseMessage);
816
- return result;
788
+ return unwrapJsonRpcResult(responseMessage);
817
789
  };
818
- const invokeAndTransfer$1 = async (ipc, method, ...params) => {
819
- const {
820
- message,
821
- promise
822
- } = create$2$1(method, params);
823
- ipc.sendAndTransfer(message);
824
- const responseMessage = await promise;
825
- const result = unwrapJsonRpcResult(responseMessage);
826
- return result;
790
+ const send$1 = (transport, method, ...params) => {
791
+ const message = create$4$1(method, params);
792
+ transport.send(message);
793
+ };
794
+ const invoke$2 = (ipc, method, ...params) => {
795
+ return invokeHelper(ipc, method, params, false);
796
+ };
797
+ const invokeAndTransfer$1 = (ipc, method, ...params) => {
798
+ return invokeHelper(ipc, method, params, true);
827
799
  };
828
800
 
829
801
  const requiresSocket = () => {
@@ -985,7 +957,7 @@ const hydrate$4 = async () => {
985
957
  };
986
958
 
987
959
  // TODO needed?
988
- const dispose$o = () => {
960
+ const dispose$p = () => {
989
961
  // @ts-expect-error
990
962
  if (state$9.rendererWorker) {
991
963
  // @ts-expect-error
@@ -1008,7 +980,7 @@ const invokeAndTransfer = (method, ...params) => {
1008
980
 
1009
981
  const RendererWorker = {
1010
982
  __proto__: null,
1011
- dispose: dispose$o,
983
+ dispose: dispose$p,
1012
984
  hydrate: hydrate$4,
1013
985
  invoke: invoke$1,
1014
986
  invokeAndTransfer,
@@ -1696,7 +1668,7 @@ const applyUidWorkaround = element => {
1696
1668
  set$5(element, editorUid);
1697
1669
  };
1698
1670
 
1699
- const setBounds$9 = ($Element, x, y, width, height) => {
1671
+ const setBounds$a = ($Element, x, y, width, height) => {
1700
1672
  $Element.style.top = `${y}px`;
1701
1673
  $Element.style.left = `${x}px`;
1702
1674
  $Element.style.width = `${width}px`;
@@ -1911,7 +1883,7 @@ const setOffsetX = (state, offsetX) => {
1911
1883
  setXAndYTransform($ColorPickerSliderThumb, offsetX, 0);
1912
1884
  applyUidWorkaround($Viewlet);
1913
1885
  };
1914
- const appendWidget$5 = state => {
1886
+ const appendWidget$6 = state => {
1915
1887
  const {
1916
1888
  $Viewlet
1917
1889
  } = state;
@@ -1921,45 +1893,12 @@ const appendWidget$5 = state => {
1921
1893
  const ViewletColorPicker = {
1922
1894
  __proto__: null,
1923
1895
  Events: ViewletColorPickerEvents,
1924
- appendWidget: appendWidget$5,
1896
+ appendWidget: appendWidget$6,
1925
1897
  setColor,
1926
1898
  setOffsetX
1927
1899
  };
1928
1900
 
1929
- const Alert = 'alert';
1930
- const Application = 'application';
1931
- const Code = 'code';
1932
- const Complementary = 'complementary';
1933
- const ContentInfo = 'contentinfo';
1934
- const Group = 'group';
1935
- const List$1 = 'list';
1936
- const ListBox = 'listbox';
1937
- const Log = 'log';
1938
- const Main$1 = 'main';
1939
- const Menu = 'menu';
1940
- const None$2 = 'none';
1941
- const Status = 'status';
1942
- const TabList = 'tablist';
1943
- const TextBox = 'textbox';
1944
- const ToolBar = 'toolbar';
1945
- const Tree = 'tree';
1946
- const ComboBox = 'combobox';
1947
-
1948
- const attachEvents$c = ($Node, eventMap) => {
1949
- for (const [key, value] of Object.entries(eventMap)) {
1950
- $Node.addEventListener(key, value);
1951
- }
1952
- };
1953
-
1954
- const Passive = {
1955
- passive: true
1956
- };
1957
- const Active = {
1958
- passive: false
1959
- };
1960
- const Capture = {
1961
- capture: true
1962
- };
1901
+ const Script = 2;
1963
1902
 
1964
1903
  /**
1965
1904
  * @param {Event} event
@@ -2039,19 +1978,6 @@ const executeViewletCommand = (uid, command, ...args) => {
2039
1978
  send('Viewlet.executeViewletCommand', uid, command, ...args);
2040
1979
  };
2041
1980
 
2042
- const startTracking = ($Target, pointerId, handlePointerMove, handlePointerUp) => {
2043
- $Target.setPointerCapture(pointerId);
2044
- $Target.addEventListener(PointerMove, handlePointerMove);
2045
- // TODO use pointerlost event instead
2046
- $Target.addEventListener(PointerUp, handlePointerUp);
2047
- };
2048
- const stopTracking = ($Target, pointerId, handlePointerMove, handlePointerUp) => {
2049
- $Target.releasePointerCapture(pointerId);
2050
- $Target.removeEventListener(PointerMove, handlePointerMove);
2051
- // TODO use pointerlost event instead
2052
- $Target.removeEventListener(PointerUp, handlePointerUp);
2053
- };
2054
-
2055
1981
  const nameAnonymousFunction = (fn, name) => {
2056
1982
  Object.defineProperty(fn, 'name', {
2057
1983
  value: name
@@ -2106,7 +2032,7 @@ const handleDropFilePath = forwardViewletCommand('handleDropFilePath');
2106
2032
  const handleDropFiles = forwardViewletCommand('handleDrop');
2107
2033
  forwardViewletCommand('handleFilterInput');
2108
2034
  const handleFocus$c = forwardViewletCommand('handleFocus');
2109
- const handleFocusIn$4 = forwardViewletCommand('handleFocusIn');
2035
+ const handleFocusIn$5 = forwardViewletCommand('handleFocusIn');
2110
2036
  const handleIconError$1 = forwardViewletCommand('handleIconError');
2111
2037
  const handleImageError$1 = forwardViewletCommand('handleImageError');
2112
2038
  const handleInput$9 = forwardViewletCommand('handleInput');
@@ -2163,6 +2089,109 @@ forwardViewletCommand('type');
2163
2089
  forwardViewletCommand('typeWithAutoClosing');
2164
2090
  const updateEditingValue = forwardViewletCommand('updateEditingValue');
2165
2091
 
2092
+ const handleFocusIn$4 = event => {
2093
+ preventDefault(event);
2094
+ const uid = fromEvent(event);
2095
+ handleFocusIn$5(uid);
2096
+ };
2097
+
2098
+ const ViewletEditorCodeGeneratorEvents = {
2099
+ __proto__: null,
2100
+ handleFocusIn: handleFocusIn$4
2101
+ };
2102
+
2103
+ const setBounds$9 = (state, x, y, width, height) => {
2104
+ const {
2105
+ $Viewlet
2106
+ } = state;
2107
+ setBounds$a($Viewlet, x, y, width, height);
2108
+ applyUidWorkaround($Viewlet);
2109
+ };
2110
+ const appendWidget$5 = state => {
2111
+ const {
2112
+ $Viewlet
2113
+ } = state;
2114
+ append$1($Viewlet);
2115
+ };
2116
+ const dispose$o = state => {
2117
+ remove$2(state.$Viewlet);
2118
+ };
2119
+ const focus$j = (state, key, source) => {
2120
+ if (!key) {
2121
+ return;
2122
+ }
2123
+ if (source !== Script) {
2124
+ return;
2125
+ }
2126
+ const {
2127
+ $Viewlet
2128
+ } = state;
2129
+ const $Element = $Viewlet.querySelector(key);
2130
+ if (!$Element) {
2131
+ console.warn(`element not found: ${key}`);
2132
+ return;
2133
+ }
2134
+ $Element.focus();
2135
+ applyUidWorkaround($Viewlet);
2136
+ };
2137
+
2138
+ const ViewletEditorCodeGenerator = {
2139
+ __proto__: null,
2140
+ Events: ViewletEditorCodeGeneratorEvents,
2141
+ appendWidget: appendWidget$5,
2142
+ dispose: dispose$o,
2143
+ focus: focus$j,
2144
+ setBounds: setBounds$9
2145
+ };
2146
+
2147
+ const Alert = 'alert';
2148
+ const Application = 'application';
2149
+ const Code = 'code';
2150
+ const Complementary = 'complementary';
2151
+ const ContentInfo = 'contentinfo';
2152
+ const Group = 'group';
2153
+ const List$1 = 'list';
2154
+ const ListBox = 'listbox';
2155
+ const Log = 'log';
2156
+ const Main$1 = 'main';
2157
+ const Menu = 'menu';
2158
+ const None$2 = 'none';
2159
+ const Status = 'status';
2160
+ const TabList = 'tablist';
2161
+ const TextBox = 'textbox';
2162
+ const ToolBar = 'toolbar';
2163
+ const Tree = 'tree';
2164
+ const ComboBox = 'combobox';
2165
+
2166
+ const attachEvents$c = ($Node, eventMap) => {
2167
+ for (const [key, value] of Object.entries(eventMap)) {
2168
+ $Node.addEventListener(key, value);
2169
+ }
2170
+ };
2171
+
2172
+ const Passive = {
2173
+ passive: true
2174
+ };
2175
+ const Active = {
2176
+ passive: false
2177
+ };
2178
+ const Capture = {
2179
+ capture: true
2180
+ };
2181
+
2182
+ const startTracking = ($Target, pointerId, handlePointerMove, handlePointerUp) => {
2183
+ $Target.setPointerCapture(pointerId);
2184
+ $Target.addEventListener(PointerMove, handlePointerMove);
2185
+ // TODO use pointerlost event instead
2186
+ $Target.addEventListener(PointerUp, handlePointerUp);
2187
+ };
2188
+ const stopTracking = ($Target, pointerId, handlePointerMove, handlePointerUp) => {
2189
+ $Target.releasePointerCapture(pointerId);
2190
+ $Target.removeEventListener(PointerMove, handlePointerMove);
2191
+ // TODO use pointerlost event instead
2192
+ $Target.removeEventListener(PointerUp, handlePointerUp);
2193
+ };
2194
+
2166
2195
  const handleMousedown = event => {
2167
2196
  preventDefault(event);
2168
2197
  const {
@@ -2340,7 +2369,7 @@ const setBounds$8 = (state, x, y, width, height) => {
2340
2369
  const {
2341
2370
  $Viewlet
2342
2371
  } = state;
2343
- setBounds$9($Viewlet, x, y, width, height);
2372
+ setBounds$a($Viewlet, x, y, width, height);
2344
2373
  applyUidWorkaround($Viewlet);
2345
2374
  };
2346
2375
 
@@ -2403,7 +2432,7 @@ const setBounds$7 = (state, x, y, width, height) => {
2403
2432
  const {
2404
2433
  $Viewlet
2405
2434
  } = state;
2406
- setBounds$9($Viewlet, x, y, width, height);
2435
+ setBounds$a($Viewlet, x, y, width, height);
2407
2436
  };
2408
2437
 
2409
2438
  const ViewletEditorCompletionDetails = {
@@ -2477,7 +2506,7 @@ const ViewletEditorHover = {
2477
2506
  const handleFocusIn$3 = event => {
2478
2507
  preventDefault(event);
2479
2508
  const uid = fromEvent(event);
2480
- handleFocusIn$4(uid);
2509
+ handleFocusIn$5(uid);
2481
2510
  };
2482
2511
  const handleBlur$a = event => {
2483
2512
  const uid = fromEvent(event);
@@ -2505,7 +2534,7 @@ const setBounds$5 = (state, x, y, width, height) => {
2505
2534
  const {
2506
2535
  $Viewlet
2507
2536
  } = state;
2508
- setBounds$9($Viewlet, x, y, width, height);
2537
+ setBounds$a($Viewlet, x, y, width, height);
2509
2538
  applyUidWorkaround($Viewlet);
2510
2539
  };
2511
2540
  const appendWidget$2 = state => {
@@ -2529,7 +2558,7 @@ const ViewletEditorRename = {
2529
2558
  const handleFocusIn$2 = event => {
2530
2559
  preventDefault(event);
2531
2560
  const uid = fromEvent(event);
2532
- handleFocusIn$4(uid);
2561
+ handleFocusIn$5(uid);
2533
2562
  };
2534
2563
 
2535
2564
  const ViewletEditorSourceActionsEvents = {
@@ -2541,7 +2570,7 @@ const setBounds$4 = (state, x, y, width, height) => {
2541
2570
  const {
2542
2571
  $Viewlet
2543
2572
  } = state;
2544
- setBounds$9($Viewlet, x, y, width, height);
2573
+ setBounds$a($Viewlet, x, y, width, height);
2545
2574
  applyUidWorkaround($Viewlet);
2546
2575
  };
2547
2576
  const appendWidget$1 = state => {
@@ -2663,7 +2692,7 @@ const focus$i = (state, key, source) => {
2663
2692
  if (!key) {
2664
2693
  return;
2665
2694
  }
2666
- if (source !== /* script */2) {
2695
+ if (source !== Script) {
2667
2696
  return;
2668
2697
  }
2669
2698
  const {
@@ -2703,7 +2732,7 @@ const setBounds$3 = (state, x, y, width, height) => {
2703
2732
  const {
2704
2733
  $Viewlet
2705
2734
  } = state;
2706
- setBounds$9($Viewlet, x, y, width, height);
2735
+ setBounds$a($Viewlet, x, y, width, height);
2707
2736
  };
2708
2737
  const dispose$j = state => {
2709
2738
  remove$2(state.$Viewlet);
@@ -2781,6 +2810,7 @@ const WebView = 'WebView';
2781
2810
  const EditorCompletionDetails = 'EditorCompletionDetails';
2782
2811
  const EditorTextError = 'EditorTextError';
2783
2812
  const EditorRename = 'EditorRename';
2813
+ const EditorCodeGenerator = 'EditorCodeGenerator';
2784
2814
 
2785
2815
  const state$6 = {
2786
2816
  instances: Object.create(null),
@@ -3124,6 +3154,7 @@ const enable = async window => {
3124
3154
  const main = async () => {
3125
3155
  enable(window);
3126
3156
  state$6.modules[ColorPicker] = ViewletColorPicker;
3157
+ state$6.modules[EditorCodeGenerator] = ViewletEditorCodeGenerator;
3127
3158
  state$6.modules[EditorCompletion] = ViewletEditorCompletion;
3128
3159
  state$6.modules[EditorCompletionDetails] = ViewletEditorCompletionDetails;
3129
3160
  state$6.modules[EditorHover] = ViewletEditorHover;
@@ -3381,6 +3412,27 @@ const handleIpcOnce = ipc => {
3381
3412
  const getData$1 = event => {
3382
3413
  return event.data;
3383
3414
  };
3415
+ const attachEvents$9 = that => {
3416
+ const handleMessage = (...args) => {
3417
+ const data = that.getData(...args);
3418
+ that.dispatchEvent(new MessageEvent('message', {
3419
+ data
3420
+ }));
3421
+ };
3422
+ that.onMessage(handleMessage);
3423
+ const handleClose = event => {
3424
+ that.dispatchEvent(new Event('close'));
3425
+ };
3426
+ that.onClose(handleClose);
3427
+ };
3428
+ class Ipc extends EventTarget {
3429
+ constructor(rawIpc) {
3430
+ super();
3431
+ this._rawIpc = rawIpc;
3432
+ attachEvents$9(this);
3433
+ }
3434
+ }
3435
+ const readyMessage = 'ready';
3384
3436
  const walkValue = (value, transferrables, isTransferrable) => {
3385
3437
  if (!value) {
3386
3438
  return;
@@ -3431,35 +3483,141 @@ const getTransferrables = value => {
3431
3483
  walkValue(value, transferrables, isTransferrable);
3432
3484
  return transferrables;
3433
3485
  };
3434
- const attachEvents$9 = that => {
3435
- const handleMessage = (...args) => {
3436
- const data = that.getData(...args);
3437
- that.dispatchEvent(new MessageEvent('message', {
3438
- data
3439
- }));
3440
- };
3441
- that.onMessage(handleMessage);
3442
- const handleClose = event => {
3443
- that.dispatchEvent(new Event('close'));
3486
+ const removeValues = (value, toRemove) => {
3487
+ if (!value) {
3488
+ return value;
3489
+ }
3490
+ if (Array.isArray(value)) {
3491
+ const newItems = [];
3492
+ for (const item of value) {
3493
+ if (!toRemove.includes(item)) {
3494
+ newItems.push(removeValues(item, toRemove));
3495
+ }
3496
+ }
3497
+ return newItems;
3498
+ }
3499
+ if (typeof value === 'object') {
3500
+ const newObject = Object.create(null);
3501
+ for (const [key, property] of Object.entries(value)) {
3502
+ if (!toRemove.includes(property)) {
3503
+ newObject[key] = removeValues(property, toRemove);
3504
+ }
3505
+ }
3506
+ return newObject;
3507
+ }
3508
+ return value;
3509
+ };
3510
+
3511
+ // workaround for electron not supporting transferrable objects
3512
+ // as parameters. If the transferrable object is a parameter, in electron
3513
+ // only an empty objected is received in the main process
3514
+ const fixElectronParameters = value => {
3515
+ const transfer = getTransferrables(value);
3516
+ const newValue = removeValues(value, transfer);
3517
+ return {
3518
+ newValue,
3519
+ transfer
3444
3520
  };
3445
- that.onClose(handleClose);
3446
3521
  };
3447
- class Ipc extends EventTarget {
3448
- constructor(rawIpc) {
3449
- super();
3450
- this._rawIpc = rawIpc;
3451
- attachEvents$9(this);
3522
+ const listen$4 = () => {
3523
+ return window;
3524
+ };
3525
+ const signal$4 = global => {
3526
+ global.postMessage(readyMessage);
3527
+ };
3528
+ class IpcChildWithElectronWindow extends Ipc {
3529
+ getData(event) {
3530
+ return getData$1(event);
3531
+ }
3532
+ send(message) {
3533
+ this._rawIpc.postMessage(message);
3534
+ }
3535
+ sendAndTransfer(message) {
3536
+ const {
3537
+ newValue,
3538
+ transfer
3539
+ } = fixElectronParameters(message);
3540
+ this._rawIpc.postMessage(newValue, location.origin, transfer);
3541
+ }
3542
+ dispose() {
3543
+ // ignore
3544
+ }
3545
+ onClose(callback) {
3546
+ // ignore
3547
+ }
3548
+ onMessage(callback) {
3549
+ const wrapped = event => {
3550
+ const {
3551
+ ports
3552
+ } = event;
3553
+ if (ports.length) {
3554
+ return;
3555
+ }
3556
+ callback(event);
3557
+ this._rawIpc.removeEventListener('message', wrapped);
3558
+ };
3559
+ this._rawIpc.addEventListener('message', wrapped);
3452
3560
  }
3453
3561
  }
3454
- const readyMessage = 'ready';
3455
- const listen$4 = () => {
3562
+ const wrap$7 = window => {
3563
+ return new IpcChildWithElectronWindow(window);
3564
+ };
3565
+ const IpcChildWithElectronWindow$1 = {
3566
+ __proto__: null,
3567
+ listen: listen$4,
3568
+ signal: signal$4,
3569
+ wrap: wrap$7
3570
+ };
3571
+ const listen$3 = ({
3572
+ port
3573
+ }) => {
3574
+ return port;
3575
+ };
3576
+ const signal$3 = port => {
3577
+ port.postMessage(readyMessage);
3578
+ };
3579
+ class IpcChildWithMessagePort extends Ipc {
3580
+ constructor(port) {
3581
+ super(port);
3582
+ }
3583
+ getData(event) {
3584
+ return getData$1(event);
3585
+ }
3586
+ send(message) {
3587
+ this._rawIpc.postMessage(message);
3588
+ }
3589
+ sendAndTransfer(message) {
3590
+ const transfer = getTransferrables(message);
3591
+ this._rawIpc.postMessage(message, transfer);
3592
+ }
3593
+ dispose() {
3594
+ // ignore
3595
+ }
3596
+ onClose(callback) {
3597
+ // ignore
3598
+ }
3599
+ onMessage(callback) {
3600
+ this._rawIpc.addEventListener('message', callback);
3601
+ this._rawIpc.start();
3602
+ }
3603
+ }
3604
+ const wrap$6 = port => {
3605
+ return new IpcChildWithMessagePort(port);
3606
+ };
3607
+ const IpcChildWithMessagePort$1 = {
3608
+ __proto__: null,
3609
+ listen: listen$3,
3610
+ signal: signal$3,
3611
+ wrap: wrap$6
3612
+ };
3613
+ const listen$2 = () => {
3456
3614
  // @ts-ignore
3457
3615
  if (typeof WorkerGlobalScope === 'undefined') {
3458
3616
  throw new TypeError('module is not in web worker scope');
3459
3617
  }
3460
3618
  return globalThis;
3461
3619
  };
3462
- const signal$3 = global => {
3620
+ const signal$2 = global => {
3463
3621
  global.postMessage(readyMessage);
3464
3622
  };
3465
3623
  class IpcChildWithModuleWorker extends Ipc {
@@ -3485,14 +3643,14 @@ class IpcChildWithModuleWorker extends Ipc {
3485
3643
  this._rawIpc.addEventListener('message', callback);
3486
3644
  }
3487
3645
  }
3488
- const wrap$6 = global => {
3646
+ const wrap$5 = global => {
3489
3647
  return new IpcChildWithModuleWorker(global);
3490
3648
  };
3491
3649
  const IpcChildWithModuleWorker$1 = {
3492
3650
  __proto__: null,
3493
- listen: listen$4,
3494
- signal: signal$3,
3495
- wrap: wrap$6
3651
+ listen: listen$2,
3652
+ signal: signal$2,
3653
+ wrap: wrap$5
3496
3654
  };
3497
3655
  const E_INCOMPATIBLE_NATIVE_MODULE = 'E_INCOMPATIBLE_NATIVE_MODULE';
3498
3656
  const E_MODULES_NOT_SUPPORTED_IN_ELECTRON = 'E_MODULES_NOT_SUPPORTED_IN_ELECTRON';
@@ -3609,10 +3767,10 @@ const getHelpfulChildProcessError = (stdout, stderr) => {
3609
3767
  };
3610
3768
  const normalizeLine = line => {
3611
3769
  if (line.startsWith('Error: ')) {
3612
- return line.slice(`Error: `.length);
3770
+ return line.slice('Error: '.length);
3613
3771
  }
3614
3772
  if (line.startsWith('VError: ')) {
3615
- return line.slice(`VError: `.length);
3773
+ return line.slice('VError: '.length);
3616
3774
  }
3617
3775
  return line;
3618
3776
  };
@@ -3710,10 +3868,10 @@ const waitForFirstMessage = async port => {
3710
3868
  // @ts-ignore
3711
3869
  return event.data;
3712
3870
  };
3713
- const listen$3 = async () => {
3714
- const parentIpcRaw = listen$4();
3715
- signal$3(parentIpcRaw);
3716
- const parentIpc = wrap$6(parentIpcRaw);
3871
+ const listen$1 = async () => {
3872
+ const parentIpcRaw = listen$2();
3873
+ signal$2(parentIpcRaw);
3874
+ const parentIpc = wrap$5(parentIpcRaw);
3717
3875
  const firstMessage = await waitForFirstMessage(parentIpc);
3718
3876
  if (firstMessage.method !== 'initialize') {
3719
3877
  throw new IpcError('unexpected first message');
@@ -3758,140 +3916,13 @@ class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
3758
3916
  this._rawIpc.start();
3759
3917
  }
3760
3918
  }
3761
- const wrap$5 = port => {
3919
+ const wrap$4 = port => {
3762
3920
  return new IpcChildWithModuleWorkerAndMessagePort(port);
3763
3921
  };
3764
3922
  const IpcChildWithModuleWorkerAndMessagePort$1 = {
3765
- __proto__: null,
3766
- listen: listen$3,
3767
- wrap: wrap$5
3768
- };
3769
- const removeValues = (value, toRemove) => {
3770
- if (!value) {
3771
- return value;
3772
- }
3773
- if (Array.isArray(value)) {
3774
- const newItems = [];
3775
- for (const item of value) {
3776
- if (!toRemove.includes(item)) {
3777
- newItems.push(removeValues(item, toRemove));
3778
- }
3779
- }
3780
- return newItems;
3781
- }
3782
- if (typeof value === 'object') {
3783
- const newObject = Object.create(null);
3784
- for (const [key, property] of Object.entries(value)) {
3785
- if (!toRemove.includes(property)) {
3786
- newObject[key] = removeValues(property, toRemove);
3787
- }
3788
- }
3789
- return newObject;
3790
- }
3791
- return value;
3792
- };
3793
-
3794
- // workaround for electron not supporting transferrable objects
3795
- // as parameters. If the transferrable object is a parameter, in electron
3796
- // only an empty objected is received in the main process
3797
- const fixElectronParameters = value => {
3798
- const transfer = getTransferrables(value);
3799
- const newValue = removeValues(value, transfer);
3800
- return {
3801
- newValue,
3802
- transfer
3803
- };
3804
- };
3805
- const listen$1 = () => {
3806
- return window;
3807
- };
3808
- const signal$1 = global => {
3809
- global.postMessage(readyMessage);
3810
- };
3811
- class IpcChildWithElectronWindow extends Ipc {
3812
- getData(event) {
3813
- return getData$1(event);
3814
- }
3815
- send(message) {
3816
- this._rawIpc.postMessage(message);
3817
- }
3818
- sendAndTransfer(message) {
3819
- const {
3820
- newValue,
3821
- transfer
3822
- } = fixElectronParameters(message);
3823
- this._rawIpc.postMessage(newValue, location.origin, transfer);
3824
- }
3825
- dispose() {
3826
- // ignore
3827
- }
3828
- onClose(callback) {
3829
- // ignore
3830
- }
3831
- onMessage(callback) {
3832
- const wrapped = event => {
3833
- const {
3834
- ports
3835
- } = event;
3836
- if (ports.length) {
3837
- return;
3838
- }
3839
- callback(event);
3840
- this._rawIpc.removeEventListener('message', wrapped);
3841
- };
3842
- this._rawIpc.addEventListener('message', wrapped);
3843
- }
3844
- }
3845
- const wrap$3 = window => {
3846
- return new IpcChildWithElectronWindow(window);
3847
- };
3848
- const IpcChildWithElectronWindow$1 = {
3849
3923
  __proto__: null,
3850
3924
  listen: listen$1,
3851
- signal: signal$1,
3852
- wrap: wrap$3
3853
- };
3854
- const listen$2 = ({
3855
- port
3856
- }) => {
3857
- return port;
3858
- };
3859
- const signal = port => {
3860
- port.postMessage(readyMessage);
3861
- };
3862
- class IpcChildWithMessagePort extends Ipc {
3863
- constructor(port) {
3864
- super(port);
3865
- }
3866
- getData(event) {
3867
- return getData$1(event);
3868
- }
3869
- send(message) {
3870
- this._rawIpc.postMessage(message);
3871
- }
3872
- sendAndTransfer(message) {
3873
- const transfer = getTransferrables(message);
3874
- this._rawIpc.postMessage(message, transfer);
3875
- }
3876
- dispose() {
3877
- // ignore
3878
- }
3879
- onClose(callback) {
3880
- // ignore
3881
- }
3882
- onMessage(callback) {
3883
- this._rawIpc.addEventListener('message', callback);
3884
- this._rawIpc.start();
3885
- }
3886
- }
3887
- const wrap$2 = port => {
3888
- return new IpcChildWithMessagePort(port);
3889
- };
3890
- const IpcChildWithMessagePort$1 = {
3891
- __proto__: null,
3892
- listen: listen$2,
3893
- signal,
3894
- wrap: wrap$2
3925
+ wrap: wrap$4
3895
3926
  };
3896
3927
 
3897
3928
  // TODO use handleIncomingIpc function
@@ -5829,6 +5860,8 @@ const load$1 = moduleId => {
5829
5860
  return Promise.resolve().then(function () { return ViewletEditorCompletionDetails; });
5830
5861
  case EditorTextError:
5831
5862
  return Promise.resolve().then(function () { return ViewletEditorTextError; });
5863
+ case EditorCodeGenerator:
5864
+ return Promise.resolve().then(function () { return ViewletEditorCodeGenerator; });
5832
5865
  default:
5833
5866
  throw new Error(`${moduleId} module not found in renderer process`);
5834
5867
  }
@@ -5941,7 +5974,7 @@ const isSpecial = id => {
5941
5974
  const createPlaceholder = (viewletId, parentId, top, left, width, height) => {
5942
5975
  const $PlaceHolder = document.createElement('div');
5943
5976
  $PlaceHolder.className = `Viewlet ${viewletId}`;
5944
- setBounds$9($PlaceHolder, left, top, width, height);
5977
+ setBounds$a($PlaceHolder, left, top, width, height);
5945
5978
  if (isSpecial(viewletId)) {
5946
5979
  $PlaceHolder.id = viewletId;
5947
5980
  }
@@ -6262,7 +6295,7 @@ const setBounds$2 = (id, left, top, width, height) => {
6262
6295
  return;
6263
6296
  }
6264
6297
  const $Viewlet = instance.state.$Viewlet;
6265
- setBounds$9($Viewlet, left, top, width, height);
6298
+ setBounds$a($Viewlet, left, top, width, height);
6266
6299
  };
6267
6300
 
6268
6301
  const name$8 = 'Viewlet';
@@ -7019,7 +7052,7 @@ const setBounds$1 = (state, x, y, width, height) => {
7019
7052
  const {
7020
7053
  $Viewlet
7021
7054
  } = state;
7022
- setBounds$9($Viewlet, x, y, width, height);
7055
+ setBounds$a($Viewlet, x, y, width, height);
7023
7056
  };
7024
7057
 
7025
7058
  const ViewletEditorError = {
@@ -7819,7 +7852,7 @@ const setBounds = (state, x, y, width, height) => {
7819
7852
  const {
7820
7853
  $Viewlet
7821
7854
  } = state;
7822
- setBounds$9($Viewlet, x, y, width, height);
7855
+ setBounds$a($Viewlet, x, y, width, height);
7823
7856
  };
7824
7857
 
7825
7858
  const ViewletEditorWidgetError = {
@@ -9161,9 +9194,9 @@ const setSashes = (state, sashSideBar, sashPanel) => {
9161
9194
  $SashSideBar,
9162
9195
  $SashPanel
9163
9196
  } = state;
9164
- setBounds$9($SashSideBar, sashSideBar.x, sashSideBar.y, sashSideBar.width, sashSideBar.height);
9197
+ setBounds$a($SashSideBar, sashSideBar.x, sashSideBar.y, sashSideBar.width, sashSideBar.height);
9165
9198
  $SashSideBar.classList.toggle('SashActive', sashSideBar.active);
9166
- setBounds$9($SashPanel, sashPanel.x, sashPanel.y, sashPanel.width, sashPanel.height);
9199
+ setBounds$a($SashPanel, sashPanel.x, sashPanel.y, sashPanel.width, sashPanel.height);
9167
9200
  $SashPanel.classList.toggle('SashActive', sashPanel.active);
9168
9201
  };
9169
9202
 
@@ -9276,7 +9309,7 @@ const setDragOverlay = (state, visible, x, y, width, height) => {
9276
9309
  const {
9277
9310
  $DragOverlay
9278
9311
  } = state;
9279
- setBounds$9($DragOverlay, x, y, width, height);
9312
+ setBounds$a($DragOverlay, x, y, width, height);
9280
9313
  if (!hasOverlay) {
9281
9314
  document.body.append($DragOverlay);
9282
9315
  }
@@ -10188,6 +10221,8 @@ const handleHeaderClick$1 = event => {
10188
10221
  return ['replaceAll'];
10189
10222
  case 'Match Whole Word':
10190
10223
  return ['toggleMatchWholeWord'];
10224
+ case 'Preserve Case':
10225
+ return ['togglePreserveCase'];
10191
10226
  default:
10192
10227
  return [];
10193
10228
  }
@@ -10259,7 +10294,12 @@ const focus$5 = state => {
10259
10294
  object(state);
10260
10295
  state.$ViewletSearchInput.focus();
10261
10296
  };
10262
- const setValue = (state, value) => {
10297
+ const setValue = (state, value, key) => {
10298
+ if (key) {
10299
+ const $Element = state.$Viewlet.querySelector(key);
10300
+ $Element.value = value;
10301
+ return;
10302
+ }
10263
10303
  const {
10264
10304
  $ViewletSearchInput
10265
10305
  } = state;
@@ -11219,7 +11259,7 @@ const setMenus = (state, changes, uid) => {
11219
11259
  level,
11220
11260
  focusedIndex
11221
11261
  } = menu;
11222
- setBounds$9($Menu, x, y, width, height);
11262
+ setBounds$a($Menu, x, y, width, height);
11223
11263
  renderInto($Menu, dom);
11224
11264
  $Menu.id = `Menu-${level}`;
11225
11265
  append$1($Menu);
@@ -11245,7 +11285,7 @@ const setMenus = (state, changes, uid) => {
11245
11285
  focusedIndex
11246
11286
  } = menu;
11247
11287
  const $Menu = $$Menus[level];
11248
- setBounds$9($Menu, x, y, width, height);
11288
+ setBounds$a($Menu, x, y, width, height);
11249
11289
  renderInto($Menu, dom);
11250
11290
  if (level === newLength - 1) {
11251
11291
  if (focusedIndex === -1) {
@@ -11670,7 +11710,7 @@ const setPort = (state, portId, origin) => {
11670
11710
  };
11671
11711
  const setPosition = (state, id, x, y, width, height) => {
11672
11712
  const $Iframe = get(id);
11673
- setBounds$9($Iframe, x, y, width, height);
11713
+ setBounds$a($Iframe, x, y, width, height);
11674
11714
  };
11675
11715
 
11676
11716
  const ViewletWebView = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/renderer-process",
3
- "version": "10.23.0",
3
+ "version": "10.25.0",
4
4
  "description": "",
5
5
  "main": "dist/rendererProcessMain.js",
6
6
  "type": "module",