@dfosco/storyboard 0.9.1 → 0.9.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,6 +1,6 @@
1
1
  {
2
2
  "name": "@dfosco/storyboard",
3
- "version": "0.9.1",
3
+ "version": "0.9.2",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Storyboard prototyping framework — core engine, React integration, and canvas",
@@ -418,6 +418,21 @@ export async function mountStoryboardCore(config = {}, options = {}) {
418
418
  // Apply saved theme to DOM immediately — before React mount
419
419
  applyEarlyTheme(config)
420
420
 
421
+ // Apply customer mode synchronously, before any `await`. The homepage
422
+ // redirect (`canvasHomepage` / `protoHomepage`) must mutate
423
+ // window.location.pathname BEFORE the consumer's router reads it — and
424
+ // because most consumers call `createBrowserRouter` and
425
+ // `mountStoryboardCore` back-to-back without awaiting, any await in
426
+ // this function would push the redirect past router instantiation and
427
+ // the wrong route would render.
428
+ //
429
+ // Reads config.customerMode directly (skips the unified-config store)
430
+ // so it works even when the virtual `initConfig()` hasn't run yet.
431
+ if (config.customerMode) {
432
+ initCustomerModeConfig(config.customerMode)
433
+ applyCustomerMode(basePath)
434
+ }
435
+
421
436
  // Forward cmd/ctrl+click on links to the host shell when running in
422
437
  // an iframe. Installed early so it covers both the embed-only path
423
438
  // and the full canvas/workspace mount below.
@@ -489,17 +504,16 @@ export async function mountStoryboardCore(config = {}, options = {}) {
489
504
  }
490
505
  }
491
506
 
492
- // Initialize customer mode config
493
- if (uc.customerMode && Object.keys(uc.customerMode).length > 0) {
507
+ // Initialize customer mode config — fall back to the unified config store
508
+ // when the consumer didn't pass customerMode directly. The early sync path
509
+ // at the top of this function already handled the synchronous redirect for
510
+ // consumers passing `config.customerMode` directly; this branch covers
511
+ // consumers that seed customer-mode purely through the unified store.
512
+ if (!config.customerMode && uc.customerMode && Object.keys(uc.customerMode).length > 0) {
494
513
  initCustomerModeConfig(uc.customerMode)
495
- } else if (config.customerMode) {
496
- initCustomerModeConfig(config.customerMode)
514
+ applyCustomerMode(basePath)
497
515
  }
498
516
 
499
- // Apply customer-mode side effects (DOM classes + early redirect).
500
- // Reads from the now-initialized customerMode store.
501
- applyCustomerMode(basePath)
502
-
503
517
  // Initialize comments config (framework-agnostic)
504
518
  const commentsConfig = uc.comments && Object.keys(uc.comments).length > 0 ? uc.comments : config.comments
505
519
  if (commentsConfig) {