@lvce-editor/output-view 2.24.3 → 2.24.5

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.
@@ -1530,7 +1530,7 @@ const parseStructuredLogLine = line => {
1530
1530
  }];
1531
1531
  };
1532
1532
 
1533
- const RE_SOURCE_LINK = /^lvce(?:-oss)?:\/\//;
1533
+ const RE_SOURCE_LINK = /^(?:lvce(?:-oss)?:\/\/|file:\/\/)/;
1534
1534
  const RE_SOURCE_LOCATION = /:(\d+)(?::(\d+))?$/;
1535
1535
  const getLinkPart = match => {
1536
1536
  if (RE_SOURCE_LINK.test(match)) {
@@ -2539,6 +2539,22 @@ const getWindowLogUri = async logsFolderUri => {
2539
2539
  return legacyWindowLogUri;
2540
2540
  };
2541
2541
 
2542
+ const createState = () => {
2543
+ let active = false;
2544
+ const isActive = () => active;
2545
+ const setActive = value => {
2546
+ active = value;
2547
+ };
2548
+ return {
2549
+ isActive,
2550
+ setActive
2551
+ };
2552
+ };
2553
+ const {
2554
+ isActive,
2555
+ setActive
2556
+ } = createState();
2557
+
2542
2558
  const loadOptions = async platform => {
2543
2559
  const extensionOptions = await getExtensionOptions();
2544
2560
  const detailOptions = await getExtensionDetailOptions();
@@ -2546,13 +2562,16 @@ const loadOptions = async platform => {
2546
2562
  return [...detailOptions, ...extensionOptions];
2547
2563
  }
2548
2564
  const logsFolderUri = await getLogsDir();
2565
+ const previewSandboxActive = isActive();
2549
2566
  const previewSandboxLogUri = `${logsFolderUri}/log-preview-sandbox.txt`;
2550
- try {
2551
- if (!(await exists(previewSandboxLogUri))) {
2552
- await writeFile(previewSandboxLogUri, '');
2567
+ if (previewSandboxActive) {
2568
+ try {
2569
+ if (!(await exists(previewSandboxLogUri))) {
2570
+ await writeFile(previewSandboxLogUri, '');
2571
+ }
2572
+ } catch {
2573
+ // Keep the Output view usable if the preview log cannot be initialized.
2553
2574
  }
2554
- } catch {
2555
- // Keep the Output view usable if the preview log cannot be initialized.
2556
2575
  }
2557
2576
  const windowLogUri = platform === Electron ? await getWindowLogUri(logsFolderUri) : `${logsFolderUri}/log-window.txt`;
2558
2577
  return [{
@@ -2567,11 +2586,11 @@ const loadOptions = async platform => {
2567
2586
  id: Window,
2568
2587
  label: 'Window',
2569
2588
  uri: windowLogUri
2570
- }, {
2589
+ }, ...(previewSandboxActive ? [{
2571
2590
  id: PreviewSandbox,
2572
2591
  label: 'Preview Sandbox',
2573
2592
  uri: previewSandboxLogUri
2574
- }, ...detailOptions, ...extensionOptions];
2593
+ }] : []), ...detailOptions, ...extensionOptions];
2575
2594
  };
2576
2595
 
2577
2596
  const getSavedFilterValue = savedState => {
@@ -2713,6 +2732,54 @@ const refresh = async state => {
2713
2732
  };
2714
2733
  };
2715
2734
 
2735
+ const refreshOptions = async state => {
2736
+ const {
2737
+ filterValue,
2738
+ platform,
2739
+ selectedOption,
2740
+ watchId
2741
+ } = state;
2742
+ const options = await loadOptions(platform);
2743
+ const option = options.find(option => option.id === selectedOption) || options[0];
2744
+ if (!option) {
2745
+ await setupChangeListener(watchId, 0, '');
2746
+ return {
2747
+ ...state,
2748
+ error: '',
2749
+ errorCode: 0,
2750
+ filteredItems: [],
2751
+ listItems: [],
2752
+ options,
2753
+ selectedOption: '',
2754
+ watchId: 0
2755
+ };
2756
+ }
2757
+ if (option.id === selectedOption) {
2758
+ return {
2759
+ ...state,
2760
+ options
2761
+ };
2762
+ }
2763
+ const {
2764
+ code,
2765
+ error,
2766
+ lines
2767
+ } = await loadLines(option.uri);
2768
+ const filteredItems = filterItems(lines, filterValue);
2769
+ const newWatchId = isExtensionOutputUri(option.uri) ? 0 : createWatchId();
2770
+ await setupChangeListener(watchId, newWatchId, option.uri);
2771
+ return {
2772
+ ...state,
2773
+ error,
2774
+ errorCode: code,
2775
+ filteredItems,
2776
+ listItems: lines,
2777
+ options,
2778
+ selectedOption: option.id,
2779
+ watchId: newWatchId
2780
+ };
2781
+ };
2782
+
2716
2783
  const renderCss = (oldState, newState) => {
2717
2784
  const {
2718
2785
  deltaY,
@@ -3032,6 +3099,28 @@ const setOutputChannel = async state => {
3032
3099
  };
3033
3100
 
3034
3101
  const handleDirectMessagePort = (port, setAsRendererProcess = true) => handleMessagePort(port, commandMap, setAsRendererProcess);
3102
+ const setPreviewSandboxActive = async active => {
3103
+ if (isActive() === active) {
3104
+ return;
3105
+ }
3106
+ setActive(active);
3107
+ for (const uid of getKeys()) {
3108
+ const current = get(uid);
3109
+ if (!current) {
3110
+ continue;
3111
+ }
3112
+ const updatedState = await refreshOptions(current.newState);
3113
+ const latest = get(uid);
3114
+ if (!latest) {
3115
+ continue;
3116
+ }
3117
+ set$1(uid, latest.oldState, {
3118
+ ...latest.newState,
3119
+ ...updatedState
3120
+ });
3121
+ await invoke$1('Viewlet.requestRender', uid);
3122
+ }
3123
+ };
3035
3124
  const commandMap = {
3036
3125
  'Output.clear': wrapCommand(clear),
3037
3126
  'Output.closeFindWidget': wrapCommand(closeFindWidget),
@@ -3074,6 +3163,7 @@ const commandMap = {
3074
3163
  'Output.setDeltaY': wrapCommand(setDeltaY),
3075
3164
  'Output.setLogLevel': setLogLevel,
3076
3165
  'Output.setOutputChannel': wrapCommand(setOutputChannel),
3166
+ 'Output.setPreviewSandboxActive': setPreviewSandboxActive,
3077
3167
  'Output.terminate': terminate
3078
3168
  };
3079
3169
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/output-view",
3
- "version": "2.24.3",
3
+ "version": "2.24.5",
4
4
  "description": "Output View Worker",
5
5
  "repository": {
6
6
  "type": "git",