@lvce-editor/main-area-worker 9.54.1 → 9.54.3

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.
@@ -158,55 +158,6 @@ const getTransferrables = value => {
158
158
  walkValue(value, transferrables, isTransferrable);
159
159
  return transferrables;
160
160
  };
161
- const removeValues = (value, toRemove) => {
162
- if (!value) {
163
- return value;
164
- }
165
- if (Array.isArray(value)) {
166
- const newItems = [];
167
- for (const item of value) {
168
- if (!toRemove.includes(item)) {
169
- newItems.push(removeValues(item, toRemove));
170
- }
171
- }
172
- return newItems;
173
- }
174
- if (typeof value === 'object') {
175
- const newObject = Object.create(null);
176
- for (const [key, property] of Object.entries(value)) {
177
- if (!toRemove.includes(property)) {
178
- newObject[key] = removeValues(property, toRemove);
179
- }
180
- }
181
- return newObject;
182
- }
183
- return value;
184
- };
185
-
186
- // workaround for electron not supporting transferrable objects
187
- // as parameters. If the transferrable object is a parameter, in electron
188
- // only an empty objected is received in the main process
189
- const fixElectronParameters = value => {
190
- const transfer = getTransferrables(value);
191
- const newValue = removeValues(value, transfer);
192
- return {
193
- newValue,
194
- transfer
195
- };
196
- };
197
- const getActualDataElectron = event => {
198
- const {
199
- data,
200
- ports
201
- } = event;
202
- if (ports.length === 0) {
203
- return data;
204
- }
205
- return {
206
- ...data,
207
- params: [...ports, ...data.params]
208
- };
209
- };
210
161
  const attachEvents = that => {
211
162
  const handleMessage = (...args) => {
212
163
  const data = that.getData(...args);
@@ -373,48 +324,6 @@ class IpcError extends VError {
373
324
  this.stderr = stderr;
374
325
  }
375
326
  }
376
- const listen$b = ({
377
- messagePort
378
- }) => {
379
- if (!isMessagePortMain(messagePort)) {
380
- throw new IpcError('port must be of type MessagePortMain');
381
- }
382
- return messagePort;
383
- };
384
- const signal$c = messagePort => {
385
- messagePort.start();
386
- };
387
- class IpcChildWithElectronMessagePort extends Ipc {
388
- getData = getActualDataElectron;
389
- send(message) {
390
- this._rawIpc.postMessage(message);
391
- }
392
- sendAndTransfer(message) {
393
- const {
394
- newValue,
395
- transfer
396
- } = fixElectronParameters(message);
397
- this._rawIpc.postMessage(newValue, transfer);
398
- }
399
- dispose() {
400
- this._rawIpc.close();
401
- }
402
- onMessage(callback) {
403
- this._rawIpc.on('message', callback);
404
- }
405
- onClose(callback) {
406
- this._rawIpc.on('close', callback);
407
- }
408
- }
409
- const wrap$j = messagePort => {
410
- return new IpcChildWithElectronMessagePort(messagePort);
411
- };
412
- const IpcChildWithElectronMessagePort$1 = {
413
- __proto__: null,
414
- listen: listen$b,
415
- signal: signal$c,
416
- wrap: wrap$j
417
- };
418
327
  const readyMessage = 'ready';
419
328
  const getData$2 = event => {
420
329
  return event.data;
@@ -832,7 +741,7 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
832
741
  const errorProperty = getErrorProperty(error, prettyError);
833
742
  return create$1$1(id, errorProperty);
834
743
  };
835
- const create$f = (message, result) => {
744
+ const create$c = (message, result) => {
836
745
  return {
837
746
  id: message.id,
838
747
  jsonrpc: Two$1,
@@ -841,7 +750,7 @@ const create$f = (message, result) => {
841
750
  };
842
751
  const getSuccessResponse = (message, result) => {
843
752
  const resultProperty = result ?? null;
844
- return create$f(message, resultProperty);
753
+ return create$c(message, resultProperty);
845
754
  };
846
755
  const getErrorResponseSimple = (id, error) => {
847
756
  return {
@@ -935,7 +844,7 @@ const handleJsonRpcMessage = async (...args) => {
935
844
 
936
845
  const Two = '2.0';
937
846
 
938
- const create$e = (method, params) => {
847
+ const create$b = (method, params) => {
939
848
  return {
940
849
  jsonrpc: Two,
941
850
  method,
@@ -943,7 +852,7 @@ const create$e = (method, params) => {
943
852
  };
944
853
  };
945
854
 
946
- const create$d = (id, method, params) => {
855
+ const create$a = (id, method, params) => {
947
856
  const message = {
948
857
  id,
949
858
  jsonrpc: Two,
@@ -954,12 +863,12 @@ const create$d = (id, method, params) => {
954
863
  };
955
864
 
956
865
  let id = 0;
957
- const create$c = () => {
866
+ const create$9 = () => {
958
867
  return ++id;
959
868
  };
960
869
 
961
870
  const registerPromise = map => {
962
- const id = create$c();
871
+ const id = create$9();
963
872
  const {
964
873
  promise,
965
874
  resolve
@@ -976,7 +885,7 @@ const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer)
976
885
  id,
977
886
  promise
978
887
  } = registerPromise(callbacks);
979
- const message = create$d(id, method, params);
888
+ const message = create$a(id, method, params);
980
889
  if (useSendAndTransfer && ipc.sendAndTransfer) {
981
890
  ipc.sendAndTransfer(message);
982
891
  } else {
@@ -1012,7 +921,7 @@ const createRpc = ipc => {
1012
921
  * @deprecated
1013
922
  */
1014
923
  send(method, ...params) {
1015
- const message = create$e(method, params);
924
+ const message = create$b(method, params);
1016
925
  ipc.send(message);
1017
926
  }
1018
927
  };
@@ -1052,24 +961,6 @@ const listen$1 = async (module, options) => {
1052
961
  return ipc;
1053
962
  };
1054
963
 
1055
- const create$b = async ({
1056
- commandMap,
1057
- messagePort,
1058
- requiresSocket
1059
- }) => {
1060
- // TODO create a commandMap per rpc instance
1061
- register(commandMap);
1062
- const ipc = await listen$1(IpcChildWithElectronMessagePort$1, {
1063
- messagePort
1064
- });
1065
- if (requiresSocket) {
1066
- ipc.requiresSocket = requiresSocket;
1067
- }
1068
- handleIpc(ipc);
1069
- const rpc = createRpc(ipc);
1070
- return rpc;
1071
- };
1072
-
1073
964
  const createSharedLazyRpc = factory => {
1074
965
  let rpcPromise;
1075
966
  const getOrCreate = () => {
@@ -1098,37 +989,6 @@ const createSharedLazyRpc = factory => {
1098
989
  };
1099
990
  };
1100
991
 
1101
- const create$a = async ({
1102
- commandMap,
1103
- getPortTuple,
1104
- send
1105
- }) => {
1106
- const {
1107
- port1,
1108
- port2
1109
- } = await getPortTuple();
1110
- await send(port1);
1111
- const rpc = create$b({
1112
- commandMap,
1113
- messagePort: port2
1114
- });
1115
- return rpc;
1116
- };
1117
-
1118
- const create$9 = async ({
1119
- commandMap,
1120
- getPortTuple,
1121
- send
1122
- }) => {
1123
- return createSharedLazyRpc(() => {
1124
- return create$a({
1125
- commandMap,
1126
- getPortTuple,
1127
- send
1128
- });
1129
- });
1130
- };
1131
-
1132
992
  const create$8 = async ({
1133
993
  commandMap,
1134
994
  isMessagePortOpen = true,
@@ -4107,8 +3967,6 @@ const getIconsCached = (dirents, fileIconCache) => {
4107
3967
  return dirents.map(dirent => fileIconCache[dirent]);
4108
3968
  };
4109
3969
 
4110
- const ExtensionDetailScheme$1 = 'extension-detail://';
4111
- const RunningExtensionsScheme$1 = 'running-extensions://';
4112
3970
  const getBasename = uri => {
4113
3971
  const lastSlashIndex = uri.lastIndexOf('/');
4114
3972
  if (lastSlashIndex === -1) {
@@ -4119,7 +3977,7 @@ const getBasename = uri => {
4119
3977
  const getMissingTabs = (tabs, fileIconCache) => {
4120
3978
  const missingTabs = [];
4121
3979
  for (const tab of tabs) {
4122
- if (tab.uri && !tab.uri.startsWith(ExtensionDetailScheme$1) && !tab.uri.startsWith(RunningExtensionsScheme$1) && !(tab.uri in fileIconCache)) {
3980
+ if (tab.uri && !getFileIcon(tab.uri) && !(tab.uri in fileIconCache)) {
4123
3981
  missingTabs.push(tab);
4124
3982
  }
4125
3983
  }
@@ -5609,40 +5467,53 @@ const getAllTabs$1 = layout => {
5609
5467
  return allTabs;
5610
5468
  };
5611
5469
 
5470
+ const updateLayoutIcons = (layout, fileIconCache, preserveExisting) => {
5471
+ const {
5472
+ groups
5473
+ } = layout;
5474
+ return {
5475
+ ...layout,
5476
+ groups: groups.map(group => ({
5477
+ ...group,
5478
+ tabs: group.tabs.map(tab => {
5479
+ const {
5480
+ icon: existingIcon
5481
+ } = tab;
5482
+ const uri = tab.uri || '';
5483
+ const builtInIcon = getFileIcon(uri);
5484
+ let icon = fileIconCache[uri];
5485
+ if (preserveExisting && !(uri in fileIconCache)) {
5486
+ icon = existingIcon;
5487
+ }
5488
+ if (builtInIcon) {
5489
+ icon = builtInIcon;
5490
+ }
5491
+ return {
5492
+ ...tab,
5493
+ icon
5494
+ };
5495
+ })
5496
+ }))
5497
+ };
5498
+ };
5612
5499
  const loadFileIcons = async state => {
5613
5500
  const {
5614
5501
  fileIconCache,
5615
5502
  layout
5616
5503
  } = state;
5617
- const {
5618
- groups
5619
- } = layout;
5620
5504
  try {
5621
5505
  const allTabs = getAllTabs$1(layout);
5622
5506
  const {
5623
5507
  newFileIconCache
5624
5508
  } = await getFileIconsForTabs(allTabs, fileIconCache);
5625
-
5626
- // Update tabs with their icons
5627
- const updatedLayout = {
5628
- ...layout,
5629
- groups: groups.map(group => ({
5630
- ...group,
5631
- tabs: group.tabs.map(tab => ({
5632
- ...tab,
5633
- icon: newFileIconCache[tab.uri || '']
5634
- }))
5635
- }))
5636
- };
5637
5509
  return {
5638
5510
  fileIconCache: newFileIconCache,
5639
- updatedLayout
5511
+ updatedLayout: updateLayoutIcons(layout, newFileIconCache, false)
5640
5512
  };
5641
5513
  } catch {
5642
- // If icon request fails, continue without icons
5643
5514
  return {
5644
5515
  fileIconCache,
5645
- updatedLayout: layout
5516
+ updatedLayout: updateLayoutIcons(layout, fileIconCache, true)
5646
5517
  };
5647
5518
  }
5648
5519
  };
@@ -8817,7 +8688,7 @@ const sendMessagePortToClipBoardWorker = async port => {
8817
8688
  };
8818
8689
 
8819
8690
  const initializeClipBoardWorker = async () => {
8820
- const rpc = await create$9({
8691
+ const rpc = await create$6({
8821
8692
  commandMap: {},
8822
8693
  send: sendMessagePortToClipBoardWorker
8823
8694
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-area-worker",
3
- "version": "9.54.1",
3
+ "version": "9.54.3",
4
4
  "description": "Main Area Worker",
5
5
  "repository": {
6
6
  "type": "git",