@lvce-editor/output-view 2.18.1 → 2.20.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.
@@ -1857,12 +1857,24 @@ const set = rpc => {
1857
1857
  state.connected = true;
1858
1858
  };
1859
1859
 
1860
- const handleMessagePort = async port => {
1860
+ const handleMessagePort = async (port, viewletCommandMap, setAsRendererProcess = true) => {
1861
+ const executeViewletCommand = async (uid, command, ...args) => {
1862
+ const fn = viewletCommandMap[`Output.${command}`];
1863
+ if (typeof fn !== 'function') {
1864
+ throw new TypeError(`Viewlet command not found: ${command}`);
1865
+ }
1866
+ await fn(uid, ...args);
1867
+ await invoke$1('Viewlet.requestRender', uid);
1868
+ };
1861
1869
  const rpc = await create$6({
1862
- commandMap: {},
1870
+ commandMap: {
1871
+ 'Viewlet.executeViewletCommand': executeViewletCommand
1872
+ },
1863
1873
  messagePort: port
1864
1874
  });
1865
- set(rpc);
1875
+ if (setAsRendererProcess) {
1876
+ set(rpc);
1877
+ }
1866
1878
  };
1867
1879
 
1868
1880
  const createWatchId = () => {
@@ -2601,6 +2613,7 @@ const setOutputChannel = async state => {
2601
2613
  };
2602
2614
  };
2603
2615
 
2616
+ const handleDirectMessagePort = (port, setAsRendererProcess = true) => handleMessagePort(port, commandMap, setAsRendererProcess);
2604
2617
  const commandMap = {
2605
2618
  'Output.clear': wrapCommand(clear),
2606
2619
  'Output.closeFindWidget': wrapCommand(closeFindWidget),
@@ -2618,7 +2631,7 @@ const commandMap = {
2618
2631
  'Output.handleData': wrapCommand(handleData),
2619
2632
  'Output.handleError': wrapCommand(handleError),
2620
2633
  'Output.handleFilterInput': wrapCommand(handleFilterInput),
2621
- 'Output.handleMessagePort': handleMessagePort,
2634
+ 'Output.handleMessagePort': handleDirectMessagePort,
2622
2635
  'Output.handleSelect': wrapCommand(handleSelect),
2623
2636
  'Output.handleSourceLinkClick': wrapCommand(handleSourceLinkClick),
2624
2637
  'Output.initialize': initialize,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/output-view",
3
- "version": "2.18.1",
3
+ "version": "2.20.0",
4
4
  "description": "Output View Worker",
5
5
  "repository": {
6
6
  "type": "git",