@dfosco/storyboard-react 3.8.1 → 3.8.2

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/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@dfosco/storyboard-react",
3
- "version": "3.8.1",
3
+ "version": "3.8.2",
4
4
  "type": "module",
5
5
  "dependencies": {
6
- "@dfosco/storyboard-core": "3.8.1",
6
+ "@dfosco/storyboard-core": "3.8.2",
7
7
  "@dfosco/tiny-canvas": "^1.1.0",
8
8
  "@neodrag/react": "^2.3.1",
9
9
  "glob": "^11.0.0",
@@ -59,14 +59,20 @@ export function useCanvas(name) {
59
59
  })
60
60
  }, [name, buildTimeCanvas])
61
61
 
62
+ const jsxModule = canvas?._jsxModule
63
+ const jsxImport = canvas?._jsxImport
64
+
62
65
  useEffect(() => {
63
- if (!canvas?._jsxModule) {
66
+ if (!jsxModule) {
64
67
  setJsxExports(null)
65
68
  return
66
69
  }
67
70
 
68
- const moduleImportPath = resolveCanvasModuleImport(canvas._jsxModule)
69
- import(/* @vite-ignore */ moduleImportPath)
71
+ const loadPromise = jsxImport
72
+ ? jsxImport()
73
+ : import(/* @vite-ignore */ resolveCanvasModuleImport(jsxModule))
74
+
75
+ loadPromise
70
76
  .then((mod) => {
71
77
  const exports = {}
72
78
  for (const [key, value] of Object.entries(mod)) {
@@ -77,10 +83,10 @@ export function useCanvas(name) {
77
83
  setJsxExports(exports)
78
84
  })
79
85
  .catch((err) => {
80
- console.error(`[storyboard] Failed to load canvas JSX module: ${moduleImportPath}`, err)
86
+ console.error(`[storyboard] Failed to load canvas JSX module: ${jsxModule}`, err)
81
87
  setJsxExports(null)
82
88
  })
83
- }, [canvas?._jsxModule])
89
+ }, [jsxModule, jsxImport])
84
90
 
85
91
  // In dev, react to file mutations from the data plugin without reloading
86
92
  // the current page. This keeps canvas editing state and route stable.
@@ -73,7 +73,9 @@ export function useFlowData(path) {
73
73
  }
74
74
 
75
75
  if (sceneValue === undefined) {
76
- console.warn(`[useFlowData] Path "${path}" not found in flow data.`)
76
+ if (data != null && Object.keys(data).length > 0) {
77
+ console.warn(`[useFlowData] Path "${path}" not found in flow data.`)
78
+ }
77
79
  return {}
78
80
  }
79
81
 
@@ -444,7 +444,11 @@ function generateModule({ index, protoFolders, flowRoutes, canvasRoutes }, root)
444
444
  }
445
445
  parsed = resolveTemplateVars(parsed, templateVars)
446
446
 
447
- declarations.push(`const ${varName} = ${JSON.stringify(parsed)}`)
447
+ if (suffix === 'canvas' && parsed._jsxModule) {
448
+ declarations.push(`const ${varName} = Object.assign(${JSON.stringify(parsed)}, { _jsxImport: () => import(${JSON.stringify(parsed._jsxModule)}) })`)
449
+ } else {
450
+ declarations.push(`const ${varName} = ${JSON.stringify(parsed)}`)
451
+ }
448
452
  entries[suffix].push(` ${JSON.stringify(name)}: ${varName}`)
449
453
  }
450
454
  }