@lvce-editor/output-view 2.24.0 → 2.24.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.
@@ -645,6 +645,9 @@ const restoreExistingError = (error, currentStack) => {
645
645
  };
646
646
  const restoreMethodNotFoundError = (error, currentStack) => {
647
647
  const restoredError = new JsonRpcError(error.message);
648
+ Object.assign(restoredError, {
649
+ code: error.code
650
+ });
648
651
  const parentStack = getParentStack(error);
649
652
  setStack(restoredError, `${parentStack}${NewLine}${currentStack}`);
650
653
  return restoredError;
@@ -664,9 +667,13 @@ const applyDataProperties = (restoredError, error) => {
664
667
  // @ts-ignore
665
668
  restoredError.codeFrame = error.data.codeFrame;
666
669
  }
667
- if (error.data.code) {
670
+ if (typeof error.data.code === 'string' || typeof error.data.code === 'number') {
668
671
  // @ts-ignore
669
- restoredError.code = error.data.code;
672
+ Object.defineProperty(restoredError, 'code', {
673
+ configurable: true,
674
+ value: error.data.code,
675
+ writable: true
676
+ });
670
677
  }
671
678
  if (error.data.type) {
672
679
  // @ts-ignore
@@ -688,6 +695,13 @@ const applyDirectProperties = (restoredError, error) => {
688
695
  };
689
696
  const restoreMessageError = (error, _currentStack) => {
690
697
  const restoredError = constructError(error.message, error.type, error.name);
698
+ if (typeof error.code === 'string' || typeof error.code === 'number') {
699
+ Object.defineProperty(restoredError, 'code', {
700
+ configurable: true,
701
+ value: error.code,
702
+ writable: true
703
+ });
704
+ }
691
705
  if (error.data) {
692
706
  applyDataProperties(restoredError, error);
693
707
  } else {
@@ -766,7 +780,7 @@ const getErrorProperty = (error, prettyError) => {
766
780
  return {
767
781
  code: Custom,
768
782
  data: {
769
- code: prettyError.code,
783
+ code: prettyError.code ?? error?.code,
770
784
  codeFrame: prettyError.codeFrame,
771
785
  name: prettyError.name,
772
786
  stack: getStack(prettyError),
@@ -803,7 +817,12 @@ const getErrorResponseSimple = (id, error) => {
803
817
  return {
804
818
  error: {
805
819
  code: Custom,
806
- data: error,
820
+ data: error instanceof Error ? {
821
+ ...error,
822
+ code: 'code' in error ? error.code : undefined,
823
+ stack: error.stack,
824
+ type: error.name
825
+ } : error,
807
826
  // @ts-ignore
808
827
  message: error.message
809
828
  },
@@ -1210,6 +1229,9 @@ const readFile = async uri => {
1210
1229
  const writeFile = async (uri, content) => {
1211
1230
  return invoke$3('FileSystem.writeFile', uri, content);
1212
1231
  };
1232
+ const exists = async uri => {
1233
+ return invoke$3('FileSystem.exists', uri);
1234
+ };
1213
1235
  const watchFile = async (watchId, uri, rpcId) => {
1214
1236
  await invoke$3('FileSystem.watchFile', watchId, uri, rpcId);
1215
1237
  };
@@ -1874,6 +1896,7 @@ const Output = 'output';
1874
1896
  const MainProcess = 'MainProcess';
1875
1897
  const SharedProcess = 'SharedProcess';
1876
1898
  const Window = 'Window';
1899
+ const PreviewSandbox = 'PreviewSandbox';
1877
1900
  const Clear = 'Clear';
1878
1901
  const Settings$1 = 'Settings';
1879
1902
  const ScrollLock = 'ScrollLock';
@@ -2225,15 +2248,15 @@ const getSelectedItem = (selectedOption, platform) => {
2225
2248
  };
2226
2249
 
2227
2250
  const emptyObject = {};
2228
- const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
2229
2251
  const i18nString = (key, placeholders = emptyObject) => {
2230
2252
  if (placeholders === emptyObject) {
2231
2253
  return key;
2232
2254
  }
2233
- const replacer = (match, rest) => {
2234
- return placeholders[rest];
2235
- };
2236
- return key.replaceAll(RE_PLACEHOLDER, replacer);
2255
+ let result = key;
2256
+ for (const [placeholder, replacement] of Object.entries(placeholders)) {
2257
+ result = result.split(`{${placeholder}}`).join(String(replacement));
2258
+ }
2259
+ return result;
2237
2260
  };
2238
2261
 
2239
2262
  const ClearOutput = 'clear output';
@@ -2346,6 +2369,14 @@ const loadOptions = async platform => {
2346
2369
  return [...detailOptions, ...extensionOptions];
2347
2370
  }
2348
2371
  const logsFolderUri = await getLogsDir();
2372
+ const previewSandboxLogUri = `${logsFolderUri}/log-preview-sandbox.txt`;
2373
+ try {
2374
+ if (!(await exists(previewSandboxLogUri))) {
2375
+ await writeFile(previewSandboxLogUri, '');
2376
+ }
2377
+ } catch {
2378
+ // Keep the Output view usable if the preview log cannot be initialized.
2379
+ }
2349
2380
  const windowLogUri = platform === Electron ? await getWindowLogUri(logsFolderUri) : `${logsFolderUri}/log-window.txt`;
2350
2381
  return [{
2351
2382
  id: MainProcess,
@@ -2359,6 +2390,10 @@ const loadOptions = async platform => {
2359
2390
  id: Window,
2360
2391
  label: 'Window',
2361
2392
  uri: windowLogUri
2393
+ }, {
2394
+ id: PreviewSandbox,
2395
+ label: 'Preview Sandbox',
2396
+ uri: previewSandboxLogUri
2362
2397
  }, ...detailOptions, ...extensionOptions];
2363
2398
  };
2364
2399
 
@@ -2767,6 +2802,7 @@ const getActionButtonsVirtualDom = buttons => {
2767
2802
  return buttons.flatMap(getActionButtonVirtualDom);
2768
2803
  };
2769
2804
 
2805
+ const filterInputClassName = mergeClassNames(InputBox, FilterInput);
2770
2806
  const filterNode = {
2771
2807
  childCount: 1,
2772
2808
  className: Filter$2,
@@ -2776,7 +2812,7 @@ const getFilterVirtualDom = () => {
2776
2812
  const placeholder = filter();
2777
2813
  return [filterNode, {
2778
2814
  childCount: 0,
2779
- className: mergeClassNames(InputBox, FilterInput),
2815
+ className: filterInputClassName,
2780
2816
  name: Filter$1,
2781
2817
  onInput: HandleFilterInput,
2782
2818
  placeholder,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/output-view",
3
- "version": "2.24.0",
3
+ "version": "2.24.1",
4
4
  "description": "Output View Worker",
5
5
  "repository": {
6
6
  "type": "git",