@lvce-editor/output-view 2.17.1 → 2.18.1

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.
@@ -1117,7 +1117,7 @@ const createMockRpc = ({
1117
1117
  };
1118
1118
 
1119
1119
  const rpcs = Object.create(null);
1120
- const set$4 = (id, rpc) => {
1120
+ const set$6 = (id, rpc) => {
1121
1121
  rpcs[id] = rpc;
1122
1122
  };
1123
1123
  const get$1 = id => {
@@ -1150,7 +1150,7 @@ const create$2 = rpcId => {
1150
1150
  const mockRpc = createMockRpc({
1151
1151
  commandMap
1152
1152
  });
1153
- set$4(rpcId, mockRpc);
1153
+ set$6(rpcId, mockRpc);
1154
1154
  // @ts-ignore
1155
1155
  mockRpc[Symbol.dispose] = () => {
1156
1156
  remove(rpcId);
@@ -1159,7 +1159,7 @@ const create$2 = rpcId => {
1159
1159
  return mockRpc;
1160
1160
  },
1161
1161
  set(rpc) {
1162
- set$4(rpcId, rpc);
1162
+ set$6(rpcId, rpc);
1163
1163
  }
1164
1164
  };
1165
1165
  };
@@ -1167,34 +1167,40 @@ const create$2 = rpcId => {
1167
1167
  const ExtensionManagementWorker = 9006;
1168
1168
  const FileSystemWorker = 209;
1169
1169
  const OutputWorker = 7001;
1170
+ const RendererProcess = 1670;
1170
1171
  const RendererWorker = 1;
1171
1172
 
1172
1173
  const {
1173
- invoke: invoke$2,
1174
- set: set$3
1174
+ invoke: invoke$4,
1175
+ set: set$5
1175
1176
  } = create$2(ExtensionManagementWorker);
1176
1177
 
1177
1178
  const {
1178
- invoke: invoke$1,
1179
- set: set$2
1179
+ invoke: invoke$3,
1180
+ set: set$4
1180
1181
  } = create$2(FileSystemWorker);
1181
1182
  const readFile = async uri => {
1182
- return invoke$1('FileSystem.readFile', uri);
1183
+ return invoke$3('FileSystem.readFile', uri);
1183
1184
  };
1184
1185
  const writeFile = async (uri, content) => {
1185
- return invoke$1('FileSystem.writeFile', uri, content);
1186
+ return invoke$3('FileSystem.writeFile', uri, content);
1186
1187
  };
1187
1188
  const watchFile = async (watchId, uri, rpcId) => {
1188
- await invoke$1('FileSystem.watchFile', watchId, uri, rpcId);
1189
+ await invoke$3('FileSystem.watchFile', watchId, uri, rpcId);
1189
1190
  };
1190
1191
  const unwatchFile = async watchId => {
1191
- await invoke$1('FileSystem.unwatchFile', watchId);
1192
+ await invoke$3('FileSystem.unwatchFile', watchId);
1192
1193
  };
1193
1194
 
1194
1195
  const {
1195
- invoke,
1196
+ invoke: invoke$2,
1197
+ set: set$3
1198
+ } = create$2(RendererProcess);
1199
+
1200
+ const {
1201
+ invoke: invoke$1,
1196
1202
  invokeAndTransfer,
1197
- set: set$1
1203
+ set: set$2
1198
1204
  } = create$2(RendererWorker);
1199
1205
  const sendMessagePortToFileSystemWorker$1 = async (port, rpcId) => {
1200
1206
  const command = 'FileSystem.handleMessagePort';
@@ -1205,10 +1211,10 @@ const sendMessagePortToExtensionManagementWorker = async (port, rpcId) => {
1205
1211
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionManagementWorker', port, command, rpcId);
1206
1212
  };
1207
1213
  const showSaveFilePicker = async () => {
1208
- return invoke('FilePicker.showSaveFilePicker');
1214
+ return invoke$1('FilePicker.showSaveFilePicker');
1209
1215
  };
1210
1216
  const getLogsDir$1 = async () => {
1211
- return invoke('PlatformPaths.getLogsDir');
1217
+ return invoke$1('PlatformPaths.getLogsDir');
1212
1218
  };
1213
1219
 
1214
1220
  const toCommandId = key => {
@@ -1499,7 +1505,7 @@ const parseLine = line => {
1499
1505
 
1500
1506
  const readOutput = async uri => {
1501
1507
  if (isExtensionOutputUri(uri)) {
1502
- return invoke$2('Extensions.readOutputChannel', uri);
1508
+ return invoke$4('Extensions.readOutputChannel', uri);
1503
1509
  }
1504
1510
  return readFile(uri);
1505
1511
  };
@@ -1530,7 +1536,7 @@ const loadLines = async uri => {
1530
1536
 
1531
1537
  const clearOutput$1 = async uri => {
1532
1538
  if (isExtensionOutputUri(uri)) {
1533
- await invoke$2('Extensions.clearOutputChannel', uri);
1539
+ await invoke$4('Extensions.clearOutputChannel', uri);
1534
1540
  return;
1535
1541
  }
1536
1542
  await writeFile(uri, '');
@@ -1580,7 +1586,7 @@ const {
1580
1586
  getCommandIds,
1581
1587
  getKeys,
1582
1588
  registerCommands,
1583
- set,
1589
+ set: set$1,
1584
1590
  wrapCommand,
1585
1591
  wrapGetter
1586
1592
  } = create$1();
@@ -1617,7 +1623,7 @@ const create = (id, uri, x, y, width, height, platform, parentId) => {
1617
1623
  x,
1618
1624
  y
1619
1625
  };
1620
- set(id, state, state);
1626
+ set$1(id, state, state);
1621
1627
  };
1622
1628
 
1623
1629
  const isEqual$2 = (oldState, newState) => {
@@ -1834,6 +1840,31 @@ const handleFilterInput = async (state, value, inputSource = User) => {
1834
1840
  };
1835
1841
  };
1836
1842
 
1843
+ const state = {
1844
+ connected: false
1845
+ };
1846
+ const isConnected = () => {
1847
+ const {
1848
+ connected
1849
+ } = state;
1850
+ return connected;
1851
+ };
1852
+ const invoke = (method, ...params) => {
1853
+ return invoke$2(method, ...params);
1854
+ };
1855
+ const set = rpc => {
1856
+ set$3(rpc);
1857
+ state.connected = true;
1858
+ };
1859
+
1860
+ const handleMessagePort = async port => {
1861
+ const rpc = await create$6({
1862
+ commandMap: {},
1863
+ messagePort: port
1864
+ });
1865
+ set(rpc);
1866
+ };
1867
+
1837
1868
  const createWatchId = () => {
1838
1869
  const watchId = Math.random();
1839
1870
  return watchId;
@@ -1845,7 +1876,7 @@ const handleFileChange = async watchId => {
1845
1876
  const instance = get(key);
1846
1877
  if (instance.newState.watchId === watchId) {
1847
1878
  // @ts-ignore
1848
- await invoke('Output.refresh');
1879
+ await invoke$1('Output.refresh');
1849
1880
  }
1850
1881
  }
1851
1882
  };
@@ -1920,13 +1951,13 @@ const handleSourceLinkClick = async (state, uri, lineNumber, columnNumber) => {
1920
1951
  }
1921
1952
  const line = Number(lineNumber);
1922
1953
  if (!Number.isSafeInteger(line) || line <= 0) {
1923
- await invoke('Main.openUri', uri);
1954
+ await invoke$1('Main.openUri', uri);
1924
1955
  return state;
1925
1956
  }
1926
1957
  const column = Number(columnNumber);
1927
1958
  const rowIndex = line - 1;
1928
1959
  const columnIndex = Number.isSafeInteger(column) && column > 0 ? column - 1 : 0;
1929
- await invoke('Main.openUri', uri, true, {
1960
+ await invoke$1('Main.openUri', uri, true, {
1930
1961
  selections: new Uint32Array([rowIndex, columnIndex, rowIndex, columnIndex])
1931
1962
  });
1932
1963
  return state;
@@ -1942,7 +1973,7 @@ const createExtensionManagementWorkerRpc = async () => {
1942
1973
 
1943
1974
  const initializeExtensionManagementWorker = async () => {
1944
1975
  const rpc = await createExtensionManagementWorkerRpc();
1945
- set$3(rpc);
1976
+ set$5(rpc);
1946
1977
  };
1947
1978
 
1948
1979
  const sendMessagePortToFileSystemWorker = async port => {
@@ -1963,7 +1994,7 @@ const createFileSystemWorkerRpc = async () => {
1963
1994
 
1964
1995
  const initializeFileSystemWorker = async () => {
1965
1996
  const rpc = await createFileSystemWorkerRpc();
1966
- set$2(rpc);
1997
+ set$4(rpc);
1967
1998
  };
1968
1999
 
1969
2000
  const initialize = async () => {
@@ -2038,7 +2069,7 @@ const error = error => {
2038
2069
 
2039
2070
  const getExtensionOptions = async () => {
2040
2071
  try {
2041
- const channels = await invoke$2('Extensions.getOutputChannelProviders');
2072
+ const channels = await invoke$4('Extensions.getOutputChannelProviders');
2042
2073
  return channels;
2043
2074
  } catch (error$1) {
2044
2075
  error(error$1);
@@ -2199,7 +2230,7 @@ const refresh = async state => {
2199
2230
  };
2200
2231
 
2201
2232
  const renderFilterValue = (oldState, newState) => {
2202
- return ['Viewlet.setValueByName', Filter$1, newState.filterValue];
2233
+ return ['Viewlet.setValueByName', newState.uid, Filter$1, newState.filterValue];
2203
2234
  };
2204
2235
 
2205
2236
  const HandleBlur = 'handleBlur';
@@ -2339,13 +2370,13 @@ const getOutputVirtualDom = (lines, errorCode, error) => {
2339
2370
 
2340
2371
  const renderItems = (oldState, newState) => {
2341
2372
  const dom = getOutputVirtualDom(newState.filteredItems, newState.errorCode, newState.error);
2342
- return ['Viewlet.setDom2', dom];
2373
+ return ['Viewlet.setDom2', newState.uid, dom];
2343
2374
  };
2344
2375
 
2345
2376
  const renderSelectedItem = (oldState, newState) => {
2346
2377
  const value = newState.selectedOption;
2347
2378
  const name = Output;
2348
- return ['Viewlet.setValueByName', name, value];
2379
+ return ['Viewlet.setValueByName', newState.uid, name, value];
2349
2380
  };
2350
2381
 
2351
2382
  const getRenderer = diffType => {
@@ -2370,14 +2401,23 @@ const applyRender = (oldState, newState, diffResult) => {
2370
2401
  return commands;
2371
2402
  };
2372
2403
 
2404
+ const renderDirect = async (uid, commands) => {
2405
+ const rendererWorkerCommands = commands.filter(command => command[0] === 'Viewlet.setFocusContext');
2406
+ const rendererProcessCommands = commands.filter(command => command[0] !== 'Viewlet.setFocusContext');
2407
+ const transactionId = await invoke('Viewlet.queueCommands', uid, rendererProcessCommands);
2408
+ return [...rendererWorkerCommands, ['Viewlet.commitPending', uid, transactionId]];
2409
+ };
2373
2410
  const render2 = (uid, diffResult) => {
2374
2411
  const {
2375
2412
  newState,
2376
2413
  oldState
2377
2414
  } = get(uid);
2378
- set(uid, newState, newState);
2415
+ set$1(uid, newState, newState);
2379
2416
  const commands = applyRender(oldState, newState, diffResult);
2380
- return commands;
2417
+ if (!isConnected()) {
2418
+ return commands;
2419
+ }
2420
+ return renderDirect(uid, commands);
2381
2421
  };
2382
2422
 
2383
2423
  const getActionButtonVirtualDom = button => {
@@ -2578,6 +2618,7 @@ const commandMap = {
2578
2618
  'Output.handleData': wrapCommand(handleData),
2579
2619
  'Output.handleError': wrapCommand(handleError),
2580
2620
  'Output.handleFilterInput': wrapCommand(handleFilterInput),
2621
+ 'Output.handleMessagePort': handleMessagePort,
2581
2622
  'Output.handleSelect': wrapCommand(handleSelect),
2582
2623
  'Output.handleSourceLinkClick': wrapCommand(handleSourceLinkClick),
2583
2624
  'Output.initialize': initialize,
@@ -2604,7 +2645,7 @@ const listen = async () => {
2604
2645
  const rpc = await create$3({
2605
2646
  commandMap: commandMapRef
2606
2647
  });
2607
- set$1(rpc);
2648
+ set$2(rpc);
2608
2649
  };
2609
2650
 
2610
2651
  const main = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/output-view",
3
- "version": "2.17.1",
3
+ "version": "2.18.1",
4
4
  "description": "Output View Worker",
5
5
  "repository": {
6
6
  "type": "git",