@iwsdk/vite-plugin-dev 0.5.2 → 0.5.3

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.
package/dist/index.js CHANGED
@@ -4810,6 +4810,7 @@ let runtimeDispatch = async () => {
4810
4810
  };
4811
4811
  let runtimeHandles = (method) =>
4812
4812
  String(method).startsWith('scene_') ||
4813
+ String(method).startsWith('ui_') ||
4813
4814
  String(method).startsWith('workspace_');
4814
4815
  const collapsedOutlinerNodeIds = new Set();
4815
4816
  const hiddenOutlinerNodeIds = new Set();
@@ -4887,6 +4888,29 @@ function handlesWorkspaceMethod(method) {
4887
4888
  ].includes(method);
4888
4889
  }
4889
4890
 
4891
+ function handlesEditorMethodWithoutSession(method) {
4892
+ const value = String(method);
4893
+ return (
4894
+ handlesWorkspaceMethod(value) ||
4895
+ value.startsWith('scene_') ||
4896
+ value.startsWith('ui_')
4897
+ );
4898
+ }
4899
+
4900
+ function dispatchEditorMethodWithoutSession(
4901
+ method,
4902
+ params = {},
4903
+ unavailableMessage =
4904
+ 'No scene is open in the IWSDK editor. Open the Editor view and select a scene, or run npx iwsdk scene open --input-json with the scene path.',
4905
+ ) {
4906
+ if (handlesWorkspaceMethod(method)) {
4907
+ return dispatchWorkspaceCommand(null, method, params);
4908
+ }
4909
+ throw new Error(
4910
+ unavailableMessage + \` Then retry "\${String(method)}".\`,
4911
+ );
4912
+ }
4913
+
4890
4914
  function readStoredWorkspaceScenePath() {
4891
4915
  try {
4892
4916
  const value = sessionStorage.getItem(WORKSPACE_SCENE_PATH_KEY);
@@ -15751,9 +15775,9 @@ async function init() {
15751
15775
  syncWorkspaceLocation('editor', currentScenePath(), { replace: true });
15752
15776
  }
15753
15777
  } else {
15754
- runtimeHandles = (method) => handlesWorkspaceMethod(method);
15778
+ runtimeHandles = (method) => handlesEditorMethodWithoutSession(method);
15755
15779
  runtimeDispatch = (method, params = {}) =>
15756
- dispatchWorkspaceCommand(null, method, params);
15780
+ dispatchEditorMethodWithoutSession(method, params);
15757
15781
  window.IWSDK_SCENE_EDITOR = {
15758
15782
  listContributions: () => [],
15759
15783
  registerContribution: registerEditorContribution,
@@ -15770,9 +15794,13 @@ async function init() {
15770
15794
  updateEditorStartupProgress('Loading scene…', 48);
15771
15795
  const loadedScene = await fetchComposedSceneDocument(currentScenePath());
15772
15796
  if ((loadedScene.sourceDocument?.imports?.length || 0) > 0) {
15773
- runtimeHandles = (method) => handlesWorkspaceMethod(method);
15797
+ runtimeHandles = (method) => handlesEditorMethodWithoutSession(method);
15774
15798
  runtimeDispatch = (method, params = {}) =>
15775
- dispatchWorkspaceCommand(null, method, params);
15799
+ dispatchEditorMethodWithoutSession(
15800
+ method,
15801
+ params,
15802
+ 'The selected scene uses imports and cannot be edited directly. Flatten it first, then open the flattened scene.',
15803
+ );
15776
15804
  window.IWSDK_SCENE_EDITOR = {
15777
15805
  listContributions: () => [],
15778
15806
  registerContribution: registerEditorContribution,
@@ -52319,6 +52347,7 @@ function iwsdkDev(options = {}) {
52319
52347
  WORKSPACE_REVIEW_CAPTURES_ROUTE,
52320
52348
  WORKSPACE_REVIEW_TRANSITIONS_ROUTE,
52321
52349
  WORKSPACE_PUBLISH_ROUTE,
52350
+ WORKSPACE_OPEN_RUNTIME_ROUTE,
52322
52351
  WORKSPACE_RUNTIME_PREFLIGHT_ROUTE,
52323
52352
  `${EDITOR_ROUTE}/document`,
52324
52353
  ],