@lvce-editor/output-view 2.23.1 → 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';
@@ -2274,6 +2297,20 @@ const loadButtons = () => {
2274
2297
  }];
2275
2298
  };
2276
2299
 
2300
+ const getExtensionDetailOptions = async () => {
2301
+ const uri = 'memfs:///extension-detail-output.txt';
2302
+ try {
2303
+ await readFile(uri);
2304
+ return [{
2305
+ id: 'ExtensionDetail',
2306
+ label: 'Extension Detail',
2307
+ uri
2308
+ }];
2309
+ } catch {
2310
+ return [];
2311
+ }
2312
+ };
2313
+
2277
2314
  const error = error => {
2278
2315
  console.error(error);
2279
2316
  };
@@ -2327,10 +2364,19 @@ const getWindowLogUri = async logsFolderUri => {
2327
2364
 
2328
2365
  const loadOptions = async platform => {
2329
2366
  const extensionOptions = await getExtensionOptions();
2367
+ const detailOptions = await getExtensionDetailOptions();
2330
2368
  if (platform === Web) {
2331
- return extensionOptions;
2369
+ return [...detailOptions, ...extensionOptions];
2332
2370
  }
2333
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
+ }
2334
2380
  const windowLogUri = platform === Electron ? await getWindowLogUri(logsFolderUri) : `${logsFolderUri}/log-window.txt`;
2335
2381
  return [{
2336
2382
  id: MainProcess,
@@ -2344,7 +2390,11 @@ const loadOptions = async platform => {
2344
2390
  id: Window,
2345
2391
  label: 'Window',
2346
2392
  uri: windowLogUri
2347
- }, ...extensionOptions];
2393
+ }, {
2394
+ id: PreviewSandbox,
2395
+ label: 'Preview Sandbox',
2396
+ uri: previewSandboxLogUri
2397
+ }, ...detailOptions, ...extensionOptions];
2348
2398
  };
2349
2399
 
2350
2400
  const getSavedFilterValue = savedState => {
@@ -2752,6 +2802,7 @@ const getActionButtonsVirtualDom = buttons => {
2752
2802
  return buttons.flatMap(getActionButtonVirtualDom);
2753
2803
  };
2754
2804
 
2805
+ const filterInputClassName = mergeClassNames(InputBox, FilterInput);
2755
2806
  const filterNode = {
2756
2807
  childCount: 1,
2757
2808
  className: Filter$2,
@@ -2761,7 +2812,7 @@ const getFilterVirtualDom = () => {
2761
2812
  const placeholder = filter();
2762
2813
  return [filterNode, {
2763
2814
  childCount: 0,
2764
- className: mergeClassNames(InputBox, FilterInput),
2815
+ className: filterInputClassName,
2765
2816
  name: Filter$1,
2766
2817
  onInput: HandleFilterInput,
2767
2818
  placeholder,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/output-view",
3
- "version": "2.23.1",
3
+ "version": "2.24.1",
4
4
  "description": "Output View Worker",
5
5
  "repository": {
6
6
  "type": "git",