@elytracms/studio 0.0.80 → 0.0.82

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.
Files changed (196) hide show
  1. package/convex/contract-parity.test.ts +1 -1
  2. package/convex/functions.ts +13 -3
  3. package/convex/http-routes.test.ts +143 -0
  4. package/convex/http.ts +19 -9
  5. package/convex/redirect-revalidate.test.ts +130 -0
  6. package/convex/revalidate.ts +9 -7
  7. package/convex/schema.ts +0 -19
  8. package/convex/triggers.ts +33 -3
  9. package/convex/users.ts +1 -1
  10. package/dist/components/ai/ai-chat-panel.js +26 -4
  11. package/dist/components/ai/ai-chat-panel.js.map +1 -1
  12. package/dist/components/ai/proposal-card.d.ts +27 -0
  13. package/dist/components/ai/proposal-card.js +31 -3
  14. package/dist/components/ai/proposal-card.js.map +1 -1
  15. package/dist/components/ai/proposal-issues.d.ts +55 -0
  16. package/dist/components/ai/proposal-issues.js +69 -0
  17. package/dist/components/ai/proposal-issues.js.map +1 -0
  18. package/dist/components/ai/translate-document-dialog.js +38 -3
  19. package/dist/components/ai/translate-document-dialog.js.map +1 -1
  20. package/dist/components/app-views/default-modules.d.ts +141 -44
  21. package/dist/components/app-views/default-modules.js +229 -65
  22. package/dist/components/app-views/default-modules.js.map +1 -1
  23. package/dist/components/app-views/module.d.ts +38 -0
  24. package/dist/components/app-views/module.js.map +1 -1
  25. package/dist/components/app-views/sidebar.d.ts +5 -2
  26. package/dist/components/app-views/sidebar.js +16 -5
  27. package/dist/components/app-views/sidebar.js.map +1 -1
  28. package/dist/components/app-views/studio-config.d.ts +28 -1
  29. package/dist/components/app-views/studio-config.js +1 -1
  30. package/dist/components/app-views/studio-config.js.map +1 -1
  31. package/dist/components/builder/canvas-render-context.js +10 -2
  32. package/dist/components/builder/canvas-render-context.js.map +1 -1
  33. package/dist/components/builder/clipboard-actions.js +5 -3
  34. package/dist/components/builder/clipboard-actions.js.map +1 -1
  35. package/dist/components/builder/reuse-context.js +7 -1
  36. package/dist/components/builder/reuse-context.js.map +1 -1
  37. package/dist/components/builder/reuse.d.ts +94 -16
  38. package/dist/components/builder/reuse.js +201 -19
  39. package/dist/components/builder/reuse.js.map +1 -1
  40. package/dist/components/cms/bulk-actions.js +10 -5
  41. package/dist/components/cms/bulk-actions.js.map +1 -1
  42. package/dist/components/cms/cell-edit.d.ts +18 -3
  43. package/dist/components/cms/cell-edit.js +29 -7
  44. package/dist/components/cms/cell-edit.js.map +1 -1
  45. package/dist/components/cms/cms-store.d.ts +54 -14
  46. package/dist/components/cms/cms-store.js +142 -45
  47. package/dist/components/cms/cms-store.js.map +1 -1
  48. package/dist/components/cms/collection-table.js +2 -2
  49. package/dist/components/cms/collection-table.js.map +1 -1
  50. package/dist/components/cms/detail-editor.js +15 -14
  51. package/dist/components/cms/detail-editor.js.map +1 -1
  52. package/dist/components/cms/document-editor-context.d.ts +12 -1
  53. package/dist/components/cms/document-editor-context.js.map +1 -1
  54. package/dist/components/cms/field-control.js +22 -8
  55. package/dist/components/cms/field-control.js.map +1 -1
  56. package/dist/components/cms/field-renderer.js +8 -1
  57. package/dist/components/cms/field-renderer.js.map +1 -1
  58. package/dist/components/cms/gate-validation.d.ts +36 -0
  59. package/dist/components/cms/gate-validation.js +17 -0
  60. package/dist/components/cms/gate-validation.js.map +1 -0
  61. package/dist/components/cms/import-export.js +2 -1
  62. package/dist/components/cms/import-export.js.map +1 -1
  63. package/dist/components/cms/inline-field-errors.d.ts +8 -0
  64. package/dist/components/cms/inline-field-errors.js +52 -0
  65. package/dist/components/cms/inline-field-errors.js.map +1 -0
  66. package/dist/components/cms/issues-pane.d.ts +4 -2
  67. package/dist/components/cms/issues-pane.js +13 -7
  68. package/dist/components/cms/issues-pane.js.map +1 -1
  69. package/dist/components/cms/slug-collision-report.d.ts +41 -0
  70. package/dist/components/cms/slug-collision-report.js +52 -0
  71. package/dist/components/cms/slug-collision-report.js.map +1 -0
  72. package/dist/components/components/transfer-dialog.js +10 -12
  73. package/dist/components/components/transfer-dialog.js.map +1 -1
  74. package/dist/components/deployment-setup-gate.d.ts +24 -0
  75. package/dist/components/deployment-setup-gate.js +29 -4
  76. package/dist/components/deployment-setup-gate.js.map +1 -1
  77. package/dist/components/issue-severity.d.ts +73 -0
  78. package/dist/components/issue-severity.js +56 -0
  79. package/dist/components/issue-severity.js.map +1 -0
  80. package/dist/components/nav-issues.d.ts +68 -0
  81. package/dist/components/nav-issues.js +78 -0
  82. package/dist/components/nav-issues.js.map +1 -0
  83. package/dist/components/operation-error.js +3 -3
  84. package/dist/components/operation-error.js.map +1 -1
  85. package/dist/components/project-list.d.ts +9 -3
  86. package/dist/components/project-list.js +11 -5
  87. package/dist/components/project-list.js.map +1 -1
  88. package/dist/components/project-switcher.d.ts +3 -1
  89. package/dist/components/project-switcher.js +4 -2
  90. package/dist/components/project-switcher.js.map +1 -1
  91. package/dist/components/redirects/redirects-store.d.ts +21 -0
  92. package/dist/components/redirects/redirects-store.js +17 -4
  93. package/dist/components/redirects/redirects-store.js.map +1 -1
  94. package/dist/components/section-nav.js +75 -10
  95. package/dist/components/section-nav.js.map +1 -1
  96. package/dist/customization.d.ts +7 -0
  97. package/dist/customization.js.map +1 -1
  98. package/dist/lib/ai/apply-content.js +6 -7
  99. package/dist/lib/ai/apply-content.js.map +1 -1
  100. package/dist/lib/ai/chat-context.d.ts +32 -26
  101. package/dist/lib/ai/chat-context.js +81 -9
  102. package/dist/lib/ai/chat-context.js.map +1 -1
  103. package/dist/lib/ai/constraints.d.ts +42 -0
  104. package/dist/lib/ai/constraints.js +259 -0
  105. package/dist/lib/ai/constraints.js.map +1 -0
  106. package/dist/lib/ai/index.d.ts +2 -0
  107. package/dist/lib/ai/index.js +2 -0
  108. package/dist/lib/ai/index.js.map +1 -1
  109. package/dist/lib/ai/proposal-validation.d.ts +26 -0
  110. package/dist/lib/ai/proposal-validation.js +17 -0
  111. package/dist/lib/ai/proposal-validation.js.map +1 -0
  112. package/dist/lib/ai/shape.js +60 -13
  113. package/dist/lib/ai/shape.js.map +1 -1
  114. package/dist/lib/ai/tools.d.ts +8 -4
  115. package/dist/lib/ai/tools.js +43 -14
  116. package/dist/lib/ai/tools.js.map +1 -1
  117. package/dist/lib/ai/translate-document.d.ts +35 -1
  118. package/dist/lib/ai/translate-document.js +16 -1
  119. package/dist/lib/ai/translate-document.js.map +1 -1
  120. package/dist/lib/ai/types.d.ts +11 -6
  121. package/dist/lib/ai/types.js.map +1 -1
  122. package/dist/lib/ai/update-fields.d.ts +8 -6
  123. package/dist/lib/ai/update-fields.js +9 -22
  124. package/dist/lib/ai/update-fields.js.map +1 -1
  125. package/dist/lib/clipboard/paste-issues.d.ts +5 -0
  126. package/dist/lib/clipboard/paste-issues.js +16 -6
  127. package/dist/lib/clipboard/paste-issues.js.map +1 -1
  128. package/dist/lib/cms/document-gate.d.ts +37 -0
  129. package/dist/lib/cms/document-gate.js +40 -0
  130. package/dist/lib/cms/document-gate.js.map +1 -0
  131. package/dist/lib/cms-views/view-model.d.ts +5 -0
  132. package/dist/lib/cms-views/view-model.js +10 -4
  133. package/dist/lib/cms-views/view-model.js.map +1 -1
  134. package/dist/lib/data/collection-content.d.ts +6 -1
  135. package/dist/lib/data/collection-content.js +51 -15
  136. package/dist/lib/data/collection-content.js.map +1 -1
  137. package/dist/lib/i18n/i18n.d.ts +51 -16
  138. package/dist/lib/i18n/i18n.js +119 -43
  139. package/dist/lib/i18n/i18n.js.map +1 -1
  140. package/dist/lib/i18n/index.d.ts +8 -1
  141. package/dist/lib/i18n/index.js +1 -1
  142. package/dist/lib/i18n/index.js.map +1 -1
  143. package/dist/lib/i18n/messages.de.js +200 -0
  144. package/dist/lib/i18n/messages.de.js.map +1 -1
  145. package/dist/lib/i18n/messages.en.d.ts +162 -0
  146. package/dist/lib/i18n/messages.en.js +226 -0
  147. package/dist/lib/i18n/messages.en.js.map +1 -1
  148. package/dist/lib/i18n/types.d.ts +15 -9
  149. package/dist/lib/i18n/types.js.map +1 -1
  150. package/dist/lib/locale/binding-fallback.d.ts +8 -1
  151. package/dist/lib/locale/binding-fallback.js +8 -1
  152. package/dist/lib/locale/binding-fallback.js.map +1 -1
  153. package/dist/lib/locale/locale-store.d.ts +41 -9
  154. package/dist/lib/locale/locale-store.js +34 -15
  155. package/dist/lib/locale/locale-store.js.map +1 -1
  156. package/dist/lib/locale/locale-switcher.d.ts +3 -1
  157. package/dist/lib/locale/locale-switcher.js +4 -2
  158. package/dist/lib/locale/locale-switcher.js.map +1 -1
  159. package/dist/lib/locale/use-studio-locale.d.ts +9 -4
  160. package/dist/lib/locale/use-studio-locale.js.map +1 -1
  161. package/dist/lib/operations/studio-operations.js +19 -2
  162. package/dist/lib/operations/studio-operations.js.map +1 -1
  163. package/dist/lib/persistence/convex-adapter.d.ts +1 -3
  164. package/dist/lib/persistence/convex-adapter.js +0 -55
  165. package/dist/lib/persistence/convex-adapter.js.map +1 -1
  166. package/dist/lib/persistence/deployment-readiness.js +10 -0
  167. package/dist/lib/persistence/deployment-readiness.js.map +1 -1
  168. package/dist/lib/persona/labels.d.ts +85 -9
  169. package/dist/lib/persona/labels.js +198 -58
  170. package/dist/lib/persona/labels.js.map +1 -1
  171. package/dist/lib/routes/route-issues.d.ts +9 -0
  172. package/dist/lib/routes/route-issues.js +117 -0
  173. package/dist/lib/routes/route-issues.js.map +1 -0
  174. package/dist/lib/webhooks/dispatcher.d.ts +5 -2
  175. package/dist/lib/webhooks/dispatcher.js.map +1 -1
  176. package/dist/lib/webhooks/tags.js +150 -17
  177. package/dist/lib/webhooks/tags.js.map +1 -1
  178. package/dist/lib/workspace/config-issues.d.ts +56 -0
  179. package/dist/lib/workspace/config-issues.js +72 -0
  180. package/dist/lib/workspace/config-issues.js.map +1 -0
  181. package/dist/lib/workspace/index.d.ts +24 -8
  182. package/dist/lib/workspace/index.js +28 -18
  183. package/dist/lib/workspace/index.js.map +1 -1
  184. package/dist/lib/workspace/switcher-source.d.ts +20 -3
  185. package/dist/lib/workspace/switcher-source.js.map +1 -1
  186. package/dist/lib/workspace/workspace-source.js +27 -0
  187. package/dist/lib/workspace/workspace-source.js.map +1 -1
  188. package/dist/previews/manifest-format.d.ts +13 -6
  189. package/dist/previews/manifest-format.js +9 -2
  190. package/dist/previews/manifest-format.js.map +1 -1
  191. package/dist/router/root.d.ts +36 -1
  192. package/dist/router/root.js +54 -7
  193. package/dist/router/root.js.map +1 -1
  194. package/package.json +2 -2
  195. package/convex/cliTokens.ts +0 -63
  196. package/convex/sync.ts +0 -297
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/workspace/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAA;AAUvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAG1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAE1D,OAAO,EACL,wBAAwB,EACxB,yBAAyB,EACzB,iBAAiB,EACjB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,mBAAmB,CAAA;AAG1B,IAAI,MAAM,GAA0B,IAAI,CAAA;AACxC,IAAI,YAAY,GAAwB,IAAI,CAAA;AA8B5C,MAAM,UAAU,YAAY,CAC1B,MAAyB,EACzB,MAAqB,EACrB,OAA4B;IAE5B,gBAAgB,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;IAC9B,MAAM,GAAG,qBAAqB,CAAC;QAC7B,UAAU,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;QAC/B,QAAQ,EAAE,kBAAkB;KAC7B,CAAC,CAAA;IACF,YAAY,GAAG,MAAM,IAAI,IAAI,CAAA;AAC/B,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,uBAAuB,CAAC,IAAyB;IAC/D,YAAY,GAAG,IAAI,CAAA;AACrB,CAAC;AAED;;;;;;;;;GASG;AACH,IAAI,i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CAAA;IACvE,OAAO,yBAAyB,CAAC,OAAO,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAA;AAC1D,CAAC","sourcesContent":["import { frontendUrlForEnvironment } from '@elytracms/core/studio-core'\nimport type {\n BreakpointConfig,\n ElytraConfigInput,\n ResolvedWorkspaceProject,\n} from '@elytracms/core/studio-core'\nimport type { CollectionDef, LocaleConfig, RouteRecord } from '@elytracms/core/cms-core'\nimport type { SidebarNode } from '../../components/app-views/module'\nimport type { CustomFieldRenderer, StudioConfig } from '../../components/app-views/studio-config'\nimport type { GeneratedPreviewLookup } from '../../components/builder/blocks-model'\nimport { provideStudioEnv } from '../persistence/backend-mode'\nimport { resolveWorkspaceState } from './workspace-source'\nimport type { WorkspaceState } from './workspace-source'\n\nexport { resolveWorkspaceState } from './workspace-source'\nexport type { WorkspaceSources, WorkspaceState } from './workspace-source'\nexport {\n isSingleProjectWorkspace,\n launcherAutoForwardTarget,\n persistedProjects,\n selectSwitcherProjects,\n soleWorkspaceProject,\n unprovisionedProjects,\n} from './switcher-source'\nexport type { SwitcherEntry, SwitcherSourceInput } from './switcher-source'\n\nlet cached: WorkspaceState | null = null\nlet studioConfig: StudioConfig | null = null\n\n/**\n * Mount the studio against a project config (EC-223 mount contract) and an\n * optional studio-only customization config (EC-236). The consumer's entry point\n * does `import config from './elytra.config'` + `import studio from\n * './studio.config'` and calls this — an explicit init, NOT an `import.meta.glob`\n * autoload that reaches into the consumer's filesystem (Oli, 2026-06-19: \"there's\n * always an entry point that can trigger a function call\").\n *\n * Two configs, deliberately: `config` (`elytra.config.ts`) is the project\n * definition, shared with the `frontend/` delivery bundle and projected to data;\n * `studio` (`studio.config.tsx` via `defineStudio`) is live builder UI code — the\n * section rail, custom field renderers, branding — that must NEVER reach delivery.\n * Keeping them separate is the customization boundary principle in the mount\n * signature. Seeds the workspace state + the studio-config holder every later\n * query (`getActiveProjectSlug`, `resolveDeployment*`) reads.\n *\n * EC-357 — `options.env`: the consumer's `import.meta.env`, captured HERE because\n * the entry module is code Vite always transforms live. The engine's own\n * `import.meta.env` reads are unreliable inside dep-optimized package code (Vite ≥8\n * omits custom `VITE_*` values there; Vite 7 froze them at optimize time), which\n * silently broke backend URL / mode / dev-login resolution in real consumers.\n * Always pass it: `createStudio(config, studioConfig, { env: import.meta.env })`.\n */\nexport interface StudioMountOptions {\n /** The consumer entry's `import.meta.env` (see `provideStudioEnv` for the contract). */\n env?: Record<string, unknown>\n}\n\nexport function createStudio(\n config: ElytraConfigInput,\n studio?: StudioConfig,\n options?: StudioMountOptions,\n): void {\n provideStudioEnv(options?.env)\n cached = resolveWorkspaceState({\n fileModule: { default: config },\n fileName: 'elytra.config.ts',\n })\n studioConfig = studio ?? null\n}\n\n/** Test seam: set/clear the studio customization config. Never used by app code. */\nexport function setStudioConfigForTests(next: StudioConfig | null): void {\n studioConfig = next\n}\n\n/**\n * The active project slug (EC-179, vision AD-8). One project per backend, so the\n * active project selects which Convex deployment the studio talks to. The root\n * layout sets this from the URL (`/<slug>`) — or, on the sign-in screen, from\n * the `redirect` target's slug — before the auth/persistence adapters are\n * selected, so the *initial* sign-in authenticates against the project the user\n * is heading for (Sanity-style: authenticate to one workspace, then the full\n * config-based switcher is available). `null` at the launcher → the default\n * (first) configured project's deployment.\n */\nlet activeProjectSlug: string | null = null\n\n/** Set the active project slug; returns whether the resolved deployment changed. */\nexport function setActiveProjectSlug(slug: string | null): boolean {\n const before = resolveDeploymentUrl('')\n activeProjectSlug = slug && slug.trim() !== '' ? slug : null\n return resolveDeploymentUrl('') !== before\n}\n\nexport function getActiveProjectSlug(): string | null {\n return activeProjectSlug\n}\n\n/** Test seam: reset the active project slug. Never used by app code. */\nexport function setActiveProjectSlugForTests(slug: string | null): void {\n activeProjectSlug = slug\n}\n\n/**\n * Reserved first-path segments that are NOT project slugs: the studio's own\n * root routes (EC-220). Project surfaces now live at `/<slug>/...` (no `/p/`\n * prefix), so the studio's root namespace is shared between project slugs and\n * these fixed routes — they must be excluded from slug extraction. Keep in\n * sync with the non-`$projectId` files in `src/routes/`; the launcher (`/`) is\n * the empty segment, excluded by the regex requiring one path char.\n */\nconst RESERVED_ROOT_SEGMENTS: ReadonlySet<string> = new Set(['sign-in', 'styleguide'])\n\n/** Extract a project slug from a studio path (`/<slug>/...`), else `null`. */\nexport function projectSlugFromPath(pathname: string): string | null {\n const match = /^\\/([^/?#]+)/.exec(pathname)\n if (!match) return null\n const segment = decodeURIComponent(match[1]!)\n return RESERVED_ROOT_SEGMENTS.has(segment) ? null : segment\n}\n\n/**\n * The project whose backend the studio should bind for a given location\n * (EC-179). A project path (`/<slug>`) binds that project; the sign-in screen\n * binds the project from its `redirect` target so the *initial* sign-in\n * authenticates against the backend the user is heading for (Sanity-style).\n * Anywhere else (the launcher) → `null`, i.e. the default/first project.\n */\nexport function activeSlugForLocation(pathname: string, redirect?: string): string | null {\n const direct = projectSlugFromPath(pathname)\n if (direct) return direct\n if (pathname === '/sign-in' && redirect) return projectSlugFromPath(redirect)\n return null\n}\n\n/** The active config project (by slug), or the first configured project. */\nfunction activeConfigProject() {\n const state = getWorkspaceState()\n if (state.kind !== 'config') return undefined\n if (activeProjectSlug) {\n const match = state.projects.find((p) => p.slug === activeProjectSlug)\n if (match) return match\n }\n return state.projects[0]\n}\n\n/**\n * The studio's resolved workspace state. Deterministic per boot: the config is\n * static input (bundled file or deployment env), so it is resolved once and\n * cached — every consumer (gate, switcher, launcher) sees the same state.\n */\nexport function getWorkspaceState(): WorkspaceState {\n // Seeded by `createStudio(config)` at the entry point. Until then — or when the\n // consumer wires no config — resolve to the empty `none` state (the single-project\n // golden path), rather than reaching for the filesystem.\n if (!cached) cached = resolveWorkspaceState({})\n return cached\n}\n\n/** Test seam: clear/replace the cached state. Never used by app code. */\nexport function setWorkspaceStateForTests(next: WorkspaceState | null): void {\n cached = next\n}\n\n/**\n * Resolve the Convex deployment URL the studio should connect to (vision AD-8:\n * the backend is wired in config). One project per backend, so the **active**\n * project (see {@link setActiveProjectSlug}) selects the deployment via its\n * `convex.deployment` (or its production environment's). At the launcher (no\n * active project) the first configured project is the default backend. Absent\n * config — or a project without a wired deployment — falls back to\n * `VITE_CONVEX_URL` (`fallbackUrl`) for local single-deployment development.\n */\nexport function resolveDeploymentUrl(fallbackUrl: string): string {\n return projectDeploymentUrl(activeConfigProject(), fallbackUrl)\n}\n\n/** The deployment URL for a specific project slug (per-backend auth checks). */\nexport function deploymentUrlForSlug(slug: string, fallbackUrl: string): string {\n const state = getWorkspaceState()\n const project = state.kind === 'config' ? state.projects.find((p) => p.slug === slug) : undefined\n return projectDeploymentUrl(project, fallbackUrl)\n}\n\n/** A project's wired deployment: per-environment ref → project ref → env fallback. */\nfunction projectDeploymentUrl(\n project: ResolvedWorkspaceProject | undefined,\n fallbackUrl: string,\n): string {\n if (!project) return fallbackUrl\n const envDeployment = project.environments.find((e) => e.convex?.deployment)?.convex?.deployment\n return envDeployment ?? project.convex?.deployment ?? fallbackUrl\n}\n\n/**\n * The slug of the project bound to the active deployment (EC-179). One project\n * per backend, so the active config project's slug identifies the deployment's\n * one project; the Convex adapter stamps it onto deployment-scoped records.\n * Absent config falls back to `fallbackId` (used only when wired by env alone).\n */\nexport function resolveDeploymentProjectId(fallbackId: string): string {\n return activeConfigProject()?.slug ?? fallbackId\n}\n\n/**\n * The CMS collections of the active config project (AD-11, EC-183). CMS\n * collection schemas are config-owned: the studio reads the model from\n * `elytra.config.ts` (served through the persistence port — the backend has no\n * `cmsSchemas` table). `[]` when the active project declares none, or when the\n * studio is wired by env alone with no config.\n */\nexport function resolveDeploymentCollections(): CollectionDef[] {\n return activeConfigProject()?.collections ?? []\n}\n\n/**\n * The canvas preview breakpoints of the active config project (EC-250).\n * Config-sourced (config-as-code, derived from the site's Tailwind `screens`);\n * `undefined` when the project declares none — the canvas then falls back to\n * Tailwind's default screens (see `resolveCanvasViewports`), never a baked-in triple.\n */\nexport function resolveDeploymentBreakpoints(): BreakpointConfig[] | undefined {\n return activeConfigProject()?.breakpoints\n}\n\n/**\n * The custom field renderers from the studio config (EC-238): control name →\n * component. Studio-only live code (from `defineStudio`, never the project schema\n * or the delivery bundle); `undefined` when none — the document editor then uses\n * its built-in control for every field. Studio-wide (not per-project): the rail and\n * renderers customize the studio, not one backend.\n */\nexport function resolveDeploymentFieldRenderers(): Record<string, CustomFieldRenderer> | undefined {\n return studioConfig?.fieldRenderers\n}\n\n/**\n * The studio-UI localization config from the studio config (EC-241): the default\n * locale + imported translation catalogs. Studio-only live code (from `defineStudio`,\n * never the project schema or the delivery bundle); `undefined` when none — the\n * studio then renders its built-in English chrome. Studio-wide, like the rail and\n * field renderers (localizes the studio, not one backend).\n */\nexport function resolveDeploymentI18n(): StudioConfig['i18n'] {\n return studioConfig?.i18n\n}\n\n/**\n * The AI platform config from the studio config (EC-331): provider, knowledge, and\n * limits. Studio-only live code (from `defineStudio`, never the delivery bundle);\n * `undefined` when no `ai` block is configured — the feature is then fully absent\n * (the AI subsystem never boots, so `@elytracms/studio/lib/ai`'s runtime — and the\n * `ai`/`@ai-sdk/*` SDK behind it — is never imported). Studio-wide, like the rail\n * and field renderers.\n */\nexport function resolveDeploymentAi(): StudioConfig['ai'] {\n return studioConfig?.ai\n}\n\n/**\n * The generated-preview lookup from the studio config (EC-439 AD-2, the seam\n * EC-440 fills): a pure `componentId + fixtureName → URL` function the blocks\n * panel threads into its tile model. Studio-only live code (from `defineStudio`,\n * never the delivery bundle); `undefined` when none — tiles then fall back from\n * a curated `manifest.previewImage` straight to the icon+name placeholder.\n * Studio-wide, like the rail and field renderers.\n */\nexport function resolveDeploymentGeneratedPreviews(): GeneratedPreviewLookup | undefined {\n return studioConfig?.previews?.generated\n}\n\n/**\n * The configurable section rail from the studio config (EC-237): an ordered list of\n * `nav.*` nodes (views / groups / separators). Studio-only live code (carries view\n * objects + icons); `undefined` when none — the studio then derives the default\n * rail from its built-in views. Invalid entries surface as visible issues at\n * resolution, never silent.\n */\nexport function resolveDeploymentSidebar(): SidebarNode[] | undefined {\n return studioConfig?.sidebar\n}\n\n/**\n * The canvas page-surface theme from the studio config (EC-389): body classes +\n * raw CSS for the preview iframe, so the canvas wears the SITE's chrome. Studio-only\n * (from `defineStudio`, never the delivery bundle); `undefined` when none — the\n * canvas keeps its built-in defaults (`bg-background text-foreground font-sans`\n * body, kit `tokensCss` only). Studio-wide, like the rail and field renderers.\n */\nexport function resolveDeploymentCanvasTheme(): StudioConfig['canvas'] {\n return studioConfig?.canvas\n}\n\n/**\n * The resolved URL routes of the active config project (EC-207, \"routes as\n * code\"). Routes are config-sourced: the studio reads the materialized\n * `RouteRecord[]` from the active `elytra.config.ts` project — never from the\n * backend (the `routes` system collection is retired). The Routes surface and\n * the per-page URL preview both read through here. `[]` when the active project\n * declares none, or when the studio is wired by env alone with no config.\n */\nexport function resolveDeploymentRoutes(): RouteRecord[] {\n return activeConfigProject()?.routes ?? []\n}\n\n// Redirects are editorial DATA now (EC-303), managed in the studio Redirects rail\n// and served dynamically — no longer resolved from config. `resolveDeploymentRedirects`\n// is retired; static/infra redirects are the dev's job via native next.config/vercel.\n\n/**\n * The configured locales of the active config project (AD-8). The same locale\n * set the host stamps onto its per-locale cache tags — used by the revalidation\n * webhook layer (EC-192) so a publish always invalidates EVERY configured locale\n * (e.g. `/de`, `/fr`), never just the default. `[]` when wired by env alone.\n */\nexport function resolveDeploymentLocales(): string[] {\n return activeConfigProject()?.locales ?? []\n}\n\n/**\n * The active config project's locales as a `LocaleConfig` (EC-357 finding #3).\n * Locales are structure and structure is code: when `elytra.config.ts` declares\n * them, they drive the studio's ambient locale switcher in EVERY mode — the CMS\n * surface must not fall back to the sample `en/de` fixture (playground, or a\n * connected first run with nothing persisted) when the config says otherwise.\n * `undefined` when no config project is active or it declares no locales (env-only\n * wiring keeps the existing kit/sample fallbacks). A missing/invalid explicit\n * default falls back to the first declared locale.\n */\nexport function resolveDeploymentLocaleConfig(): LocaleConfig | undefined {\n const project = activeConfigProject()\n if (!project || project.locales.length === 0) return undefined\n const fallback = project.locales[0]!\n const explicit = project.defaultLocale\n return {\n default: explicit && project.locales.includes(explicit) ? explicit : fallback,\n locales: [...project.locales],\n }\n}\n\n/**\n * The active project's components reference (EC-194, AD-11): where the consuming\n * repo's OWN real components live (`{ package }` or `{ dir }`). When set, the\n * studio registry composes with the repo's components instead of the built-in\n * demo fixtures — so the page builder edits the repo's actual component library.\n * `undefined` → the project ships no code components; the studio falls back to the\n * golden-path fixtures.\n */\nexport function resolveDeploymentComponents() {\n return activeConfigProject()?.components\n}\n\n/**\n * The active project's public site URL (EC-215): the live site's base URL the\n * studio links to (a document's live URL + open-live button, EC-216). Resolved\n * in lockstep with {@link resolveDeploymentUrl} — the environment bound to the\n * active deployment (the first with a wired deployment) provides the URL, falling\n * back to the project-level `frontendUrl`. No active-environment selector exists\n * yet, so the bound environment is the active one. `undefined` when the active\n * project (or env-only wiring) configures no frontend URL.\n */\nexport function resolveDeploymentFrontendUrl(): string | undefined {\n const project = activeConfigProject()\n if (!project) return undefined\n const boundEnv = project.environments.find((e) => e.convex?.deployment)\n return frontendUrlForEnvironment(project, boundEnv?.key)\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/workspace/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAA;AAUvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAG1D,OAAO,EACL,yBAAyB,EACzB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAE1D,OAAO,EACL,wBAAwB,EACxB,yBAAyB,EACzB,iBAAiB,EACjB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,mBAAmB,CAAA;AAG1B,IAAI,MAAM,GAA0B,IAAI,CAAA;AACxC,IAAI,YAAY,GAAwB,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AA;IAC9B,MAAM,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;IACvE,OAAO,yBAAyB,CAAC,OAAO,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAA;AAC1D,CAAC","sourcesContent":["import { frontendUrlForEnvironment } from '@elytracms/core/studio-core'\nimport type {\n BreakpointConfig,\n ElytraConfigInput,\n ResolvedWorkspaceProject,\n} from '@elytracms/core/studio-core'\nimport type { CollectionDef, LocaleConfig, RouteRecord } from '@elytracms/core/cms-core'\nimport type { SidebarNode } from '../../components/app-views/module'\nimport type { CustomFieldRenderer, StudioConfig } from '../../components/app-views/studio-config'\nimport type { GeneratedPreviewLookup } from '../../components/builder/blocks-model'\nimport { provideStudioEnv } from '../persistence/backend-mode'\nimport { resolveWorkspaceState } from './workspace-source'\nimport type { WorkspaceState } from './workspace-source'\n\nexport {\n PROJECT_CONFIG_ISSUE_KEYS,\n PROJECT_CONFIG_POINT,\n projectConfigIssues,\n} from './config-issues'\nexport { resolveWorkspaceState } from './workspace-source'\nexport type { WorkspaceSources, WorkspaceState } from './workspace-source'\nexport {\n isSingleProjectWorkspace,\n launcherAutoForwardTarget,\n persistedProjects,\n selectSwitcherProjects,\n soleWorkspaceProject,\n unprovisionedProjects,\n} from './switcher-source'\nexport type { SwitcherEntry, SwitcherSourceInput } from './switcher-source'\n\nlet cached: WorkspaceState | null = null\nlet studioConfig: StudioConfig | null = null\n\n/**\n * Mount the studio against a project config (EC-223 mount contract) and an\n * optional studio-only customization config (EC-236). The consumer's entry point\n * does `import config from './elytra.config'` + `import studio from\n * './studio.config'` and calls this — an explicit init, NOT an `import.meta.glob`\n * autoload that reaches into the consumer's filesystem (Oli, 2026-06-19: \"there's\n * always an entry point that can trigger a function call\").\n *\n * Two configs, deliberately: `config` (`elytra.config.ts`) is the project\n * definition, shared with the `frontend/` delivery bundle and projected to data;\n * `studio` (`studio.config.tsx` via `defineStudio`) is live builder UI code — the\n * section rail, custom field renderers, branding — that must NEVER reach delivery.\n * Keeping them separate is the customization boundary principle in the mount\n * signature. Seeds the workspace state + the studio-config holder every later\n * query (`getActiveProjectSlug`, `resolveDeployment*`) reads.\n *\n * EC-357 — `options.env`: the consumer's `import.meta.env`, captured HERE because\n * the entry module is code Vite always transforms live. The engine's own\n * `import.meta.env` reads are unreliable inside dep-optimized package code (Vite ≥8\n * omits custom `VITE_*` values there; Vite 7 froze them at optimize time), which\n * silently broke backend URL / mode / dev-login resolution in real consumers.\n * Always pass it: `createStudio(config, studioConfig, { env: import.meta.env })`.\n */\nexport interface StudioMountOptions {\n /** The consumer entry's `import.meta.env` (see `provideStudioEnv` for the contract). */\n env?: Record<string, unknown>\n}\n\nexport function createStudio(\n config: ElytraConfigInput,\n studio?: StudioConfig,\n options?: StudioMountOptions,\n): void {\n provideStudioEnv(options?.env)\n cached = resolveWorkspaceState({\n fileModule: { default: config },\n fileName: 'elytra.config.ts',\n })\n studioConfig = studio ?? null\n}\n\n/** Test seam: set/clear the studio customization config. Never used by app code. */\nexport function setStudioConfigForTests(next: StudioConfig | null): void {\n studioConfig = next\n}\n\n/**\n * The active project slug (EC-179, vision AD-8). One project per backend, so the\n * active project selects which Convex deployment the studio talks to. The root\n * layout sets this from the URL (`/<slug>`) — or, on the sign-in screen, from\n * the `redirect` target's slug — before the auth/persistence adapters are\n * selected, so the *initial* sign-in authenticates against the project the user\n * is heading for (Sanity-style: authenticate to one workspace, then the full\n * config-based switcher is available). `null` at the launcher → the default\n * (first) configured project's deployment.\n */\nlet activeProjectSlug: string | null = null\n\n/** Set the active project slug; returns whether the resolved deployment changed. */\nexport function setActiveProjectSlug(slug: string | null): boolean {\n const before = resolveDeploymentUrl('')\n activeProjectSlug = slug && slug.trim() !== '' ? slug : null\n return resolveDeploymentUrl('') !== before\n}\n\nexport function getActiveProjectSlug(): string | null {\n return activeProjectSlug\n}\n\n/** Test seam: reset the active project slug. Never used by app code. */\nexport function setActiveProjectSlugForTests(slug: string | null): void {\n activeProjectSlug = slug\n}\n\n/**\n * Reserved first-path segments that are NOT project slugs: the studio's own\n * root routes (EC-220). Project surfaces now live at `/<slug>/...` (no `/p/`\n * prefix), so the studio's root namespace is shared between project slugs and\n * these fixed routes — they must be excluded from slug extraction. Keep in\n * sync with the non-`$projectId` files in `src/routes/`; the launcher (`/`) is\n * the empty segment, excluded by the regex requiring one path char.\n */\nconst RESERVED_ROOT_SEGMENTS: ReadonlySet<string> = new Set(['sign-in', 'styleguide'])\n\n/** Extract a project slug from a studio path (`/<slug>/...`), else `null`. */\nexport function projectSlugFromPath(pathname: string): string | null {\n const match = /^\\/([^/?#]+)/.exec(pathname)\n if (!match) return null\n const segment = decodeURIComponent(match[1]!)\n return RESERVED_ROOT_SEGMENTS.has(segment) ? null : segment\n}\n\n/**\n * The project whose backend the studio should bind for a given location\n * (EC-179). A project path (`/<slug>`) binds that project; the sign-in screen\n * binds the project from its `redirect` target so the *initial* sign-in\n * authenticates against the backend the user is heading for (Sanity-style).\n * Anywhere else (the launcher) → `null`, i.e. the default/first project.\n */\nexport function activeSlugForLocation(pathname: string, redirect?: string): string | null {\n const direct = projectSlugFromPath(pathname)\n if (direct) return direct\n if (pathname === '/sign-in' && redirect) return projectSlugFromPath(redirect)\n return null\n}\n\n/** The active config project (by slug), or the first configured project. */\nfunction activeConfigProject() {\n const state = getWorkspaceState()\n if (state.kind !== 'config') return undefined\n if (activeProjectSlug) {\n const match = state.projects.find((p) => p.slug === activeProjectSlug)\n if (match) return match\n }\n return state.projects[0]\n}\n\n/**\n * The studio's resolved workspace state. Deterministic per boot: the config is\n * static input (bundled file or deployment env), so it is resolved once and\n * cached — every consumer (gate, switcher, launcher) sees the same state.\n */\nexport function getWorkspaceState(): WorkspaceState {\n // Seeded by `createStudio(config)` at the entry point. Until then — or when the\n // consumer wires no config — resolve to the empty `none` state (the single-project\n // golden path), rather than reaching for the filesystem.\n if (!cached) cached = resolveWorkspaceState({})\n return cached\n}\n\n/** Test seam: clear/replace the cached state. Never used by app code. */\nexport function setWorkspaceStateForTests(next: WorkspaceState | null): void {\n cached = next\n}\n\n/**\n * Resolve the Convex deployment URL the studio should connect to (vision AD-8:\n * the backend is wired in config). One project per backend, so the **active**\n * project (see {@link setActiveProjectSlug}) selects the deployment via its\n * `convex.deployment` (or its production environment's). At the launcher (no\n * active project) the first configured project is the default backend. Absent\n * config — or a project without a wired deployment — falls back to\n * `VITE_CONVEX_URL` (`fallbackUrl`) for local single-deployment development.\n */\nexport function resolveDeploymentUrl(fallbackUrl: string): string {\n return projectDeploymentUrl(activeConfigProject(), fallbackUrl)\n}\n\n/** The deployment URL for a specific project slug (per-backend auth checks). */\nexport function deploymentUrlForSlug(slug: string, fallbackUrl: string): string {\n const state = getWorkspaceState()\n const project = state.kind === 'config' ? state.projects.find((p) => p.slug === slug) : undefined\n return projectDeploymentUrl(project, fallbackUrl)\n}\n\n/** A project's wired deployment: per-environment ref → project ref → env fallback. */\nfunction projectDeploymentUrl(\n project: ResolvedWorkspaceProject | undefined,\n fallbackUrl: string,\n): string {\n if (!project) return fallbackUrl\n const envDeployment = project.environments.find((e) => e.convex?.deployment)?.convex?.deployment\n return envDeployment ?? project.convex?.deployment ?? fallbackUrl\n}\n\n/**\n * The slug of the project bound to the active deployment (EC-179). One project\n * per backend, so the active config project's slug identifies the deployment's\n * one project; the Convex adapter stamps it onto deployment-scoped records.\n * Absent config falls back to `fallbackId` (used only when wired by env alone).\n */\nexport function resolveDeploymentProjectId(fallbackId: string): string {\n return activeConfigProject()?.slug ?? fallbackId\n}\n\n/**\n * The CMS collections of the active config project (AD-11, EC-183). CMS\n * collection schemas are config-owned: the studio reads the model from\n * `elytra.config.ts` (served through the persistence port — the backend has no\n * `cmsSchemas` table). `[]` when the active project declares none, or when the\n * studio is wired by env alone with no config.\n */\nexport function resolveDeploymentCollections(): CollectionDef[] {\n return activeConfigProject()?.collections ?? []\n}\n\n/**\n * The canvas preview breakpoints of the active config project (EC-250).\n * Config-sourced (config-as-code, derived from the site's Tailwind `screens`);\n * `undefined` when the project declares none — the canvas then falls back to\n * Tailwind's default screens (see `resolveCanvasViewports`), never a baked-in triple.\n */\nexport function resolveDeploymentBreakpoints(): BreakpointConfig[] | undefined {\n return activeConfigProject()?.breakpoints\n}\n\n/**\n * The custom field renderers from the studio config (EC-238): control name →\n * component. Studio-only live code (from `defineStudio`, never the project schema\n * or the delivery bundle); `undefined` when none — the document editor then uses\n * its built-in control for every field. Studio-wide (not per-project): the rail and\n * renderers customize the studio, not one backend.\n */\nexport function resolveDeploymentFieldRenderers(): Record<string, CustomFieldRenderer> | undefined {\n return studioConfig?.fieldRenderers\n}\n\n/**\n * The studio-UI localization config from the studio config (EC-241): the default\n * locale + imported translation catalogs. Studio-only live code (from `defineStudio`,\n * never the project schema or the delivery bundle); `undefined` when none — the\n * studio then renders its built-in English chrome. Studio-wide, like the rail and\n * field renderers (localizes the studio, not one backend).\n */\nexport function resolveDeploymentI18n(): StudioConfig['i18n'] {\n return studioConfig?.i18n\n}\n\n/**\n * The AI platform config from the studio config (EC-331): provider, knowledge, and\n * limits. Studio-only live code (from `defineStudio`, never the delivery bundle);\n * `undefined` when no `ai` block is configured — the feature is then fully absent\n * (the AI subsystem never boots, so `@elytracms/studio/lib/ai`'s runtime — and the\n * `ai`/`@ai-sdk/*` SDK behind it — is never imported). Studio-wide, like the rail\n * and field renderers.\n */\nexport function resolveDeploymentAi(): StudioConfig['ai'] {\n return studioConfig?.ai\n}\n\n/**\n * The generated-preview lookup from the studio config (EC-439 AD-2, the seam\n * EC-440 fills): a pure `componentId + fixtureName → URL` function the blocks\n * panel threads into its tile model. Studio-only live code (from `defineStudio`,\n * never the delivery bundle); `undefined` when none — tiles then fall back from\n * a curated `manifest.previewImage` straight to the icon+name placeholder.\n * Studio-wide, like the rail and field renderers.\n */\nexport function resolveDeploymentGeneratedPreviews(): GeneratedPreviewLookup | undefined {\n return studioConfig?.previews?.generated\n}\n\n/**\n * The configurable section rail from the studio config (EC-237): an ordered list of\n * `nav.*` nodes (views / groups / separators). Studio-only live code (carries view\n * objects + icons); `undefined` when none — the studio then derives the default\n * rail from its built-in views. Invalid entries surface as visible issues at\n * resolution, never silent.\n */\nexport function resolveDeploymentSidebar(): SidebarNode[] | undefined {\n return studioConfig?.sidebar\n}\n\n/**\n * The canvas page-surface theme from the studio config (EC-389): body classes +\n * raw CSS for the preview iframe, so the canvas wears the SITE's chrome. Studio-only\n * (from `defineStudio`, never the delivery bundle); `undefined` when none — the\n * canvas keeps its built-in defaults (`bg-background text-foreground font-sans`\n * body, kit `tokensCss` only). Studio-wide, like the rail and field renderers.\n */\nexport function resolveDeploymentCanvasTheme(): StudioConfig['canvas'] {\n return studioConfig?.canvas\n}\n\n/**\n * The reusable-elements declaration from the studio config (EC-467): WHICH\n * component is the project's reuse embed. Studio-only (from `defineStudio`, never\n * the delivery bundle); `undefined` when none — the studio then INFERS the embed\n * from the manifests + collections exactly as it always has (absence means infer,\n * not off). Studio-wide, like the rail and field renderers.\n */\nexport function resolveDeploymentReuse(): StudioConfig['reuse'] {\n return studioConfig?.reuse\n}\n\n/**\n * The resolved URL routes of the active config project (EC-207, \"routes as\n * code\"). Routes are config-sourced: the studio reads the materialized\n * `RouteRecord[]` from the active `elytra.config.ts` project — never from the\n * backend (the `routes` system collection is retired). The Routes surface and\n * the per-page URL preview both read through here. `[]` when the active project\n * declares none, or when the studio is wired by env alone with no config.\n */\nexport function resolveDeploymentRoutes(): RouteRecord[] {\n return activeConfigProject()?.routes ?? []\n}\n\n// Redirects are editorial DATA now (EC-303), managed in the studio Redirects rail\n// and served dynamically — no longer resolved from config. `resolveDeploymentRedirects`\n// is retired; static/infra redirects are the dev's job via native next.config/vercel.\n\n/**\n * The configured locales of the active config project (AD-8). The same locale\n * set the host stamps onto its per-locale cache tags — used by the revalidation\n * webhook layer (EC-192) so a publish always invalidates EVERY configured locale\n * (e.g. `/de`, `/fr`), never just the default. `[]` when wired by env alone.\n */\nexport function resolveDeploymentLocales(): string[] {\n return activeConfigProject()?.locales.locales ?? []\n}\n\n/**\n * The active config project's `LocaleConfig` (EC-357 finding #3). Locales are\n * structure and structure is code: when `elytra.config.ts` declares them, they\n * drive the studio's ambient locale switcher in EVERY mode — the CMS surface must\n * not fall back to the sample `en/de` fixture (playground, or a connected first\n * run with nothing persisted) when the config says otherwise. `undefined` when no\n * config project is active (env-only wiring keeps the existing kit/sample\n * fallbacks).\n *\n * EC-519: this used to REASSEMBLE the config's flat `locales` + `defaultLocale`\n * pair into a `LocaleConfig`, and had grown its own repair rule — an absent or\n * out-of-set default fell back to `locales[0]`. That is a fourth place a locale\n * could be invented, in the surface furthest from the author. The resolver now\n * hands over the same `LocaleConfig` the delivery host takes, so there is nothing\n * to reassemble and nothing to repair: a default outside the set is a config\n * ERROR (`default-locale-not-in-locales`) and the project never resolves.\n */\nexport function resolveDeploymentLocaleConfig(): LocaleConfig | undefined {\n return activeConfigProject()?.locales\n}\n\n/**\n * The active project's components reference (EC-194, AD-11): where the consuming\n * repo's OWN real components live (`{ package }` or `{ dir }`). When set, the\n * studio registry composes with the repo's components instead of the built-in\n * demo fixtures — so the page builder edits the repo's actual component library.\n * `undefined` → the project ships no code components; the studio falls back to the\n * golden-path fixtures.\n */\nexport function resolveDeploymentComponents() {\n return activeConfigProject()?.components\n}\n\n/**\n * The active project's public site URL (EC-215): the live site's base URL the\n * studio links to (a document's live URL + open-live button, EC-216). Resolved\n * in lockstep with {@link resolveDeploymentUrl} — the environment bound to the\n * active deployment (the first with a wired deployment) provides the URL, falling\n * back to the project-level `frontendUrl`. No active-environment selector exists\n * yet, so the bound environment is the active one. `undefined` when the active\n * project (or env-only wiring) configures no frontend URL.\n */\nexport function resolveDeploymentFrontendUrl(): string | undefined {\n const project = activeConfigProject()\n if (!project) return undefined\n const boundEnv = project.environments.find((e) => e.convex?.deployment)\n return frontendUrlForEnvironment(project, boundEnv?.key)\n}\n"]}
@@ -9,9 +9,26 @@ import type { WorkspaceState } from './workspace-source.js';
9
9
  * projects, untouched (single-project golden path).
10
10
  * - **Config present** → every configured project, in config order, as a
11
11
  * navigable entry; one that has no persisted counterpart yet is an explicit
12
- * `unprovisioned` state ("run `builder init --project <slug>`") rather than an
13
- * error. Persisted projects *not* in the config are not listed: the config is
14
- * the source of truth for what this workspace is.
12
+ * `unprovisioned` state ("run `elytra init`") rather than an error. Persisted
13
+ * projects *not* in the config are not listed: the config is the source of
14
+ * truth for what this workspace is.
15
+ *
16
+ * ## The `unprovisioned` branch is currently unreachable FROM THE STUDIO (EC-470)
17
+ *
18
+ * This function will happily produce `unprovisioned` — `switcher-source.test.ts`
19
+ * covers it directly. But the live studio can no longer feed it inputs that do:
20
+ * `studio-context.tsx`'s `configProjects()` derives `persisted` from the SAME
21
+ * `workspace.projects` array this function iterates (via `configProject`, which
22
+ * sets `slug` from the config entry), so the `bySlug` lookup below always hits.
23
+ * Under AD-8 project identity became config-owned, and "provisioned" stopped
24
+ * being a per-project row the studio could miss — it is now a property of the
25
+ * DEPLOYMENT (see `DeploymentSetupGate` / `elytra doctor`).
26
+ *
27
+ * Left in place deliberately rather than removed: the entry kind is load-bearing
28
+ * for the EC-401 single-project predicates below (`soleWorkspaceProject` treats a
29
+ * lone unprovisioned entry as "do not auto-forward"), so retiring it is a
30
+ * separate, owner-sized decision — not a docs sweep. Recorded so the next reader
31
+ * does not mistake it for live UI.
15
32
  *
16
33
  * Visibility is **not** filtered by membership. One project per backend (vision
17
34
  * AD-8): a configured project lives on its own deployment, so the *active*
@@ -1 +1 @@
1
- {"version":3,"file":"switcher-source.js","sourceRoot":"","sources":["../../../src/lib/workspace/switcher-source.ts"],"names":[],"mappings":"AAkCA,MAAM,UAAU,sBAAsB,CAAC,KAA0B;IAC/D,IAAI,KAAK,CAAC,SAAS,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QACtC,wEAAwE;QACxE,yEAAyE;QACzE,OAAO,KAAK,CAAC,SAAS,CAAC,G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oB,CAAC,OAAO,CAAC,KAAK,IAAI,CAAA;AAC/C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,yBAAyB,CAAC,KAMzC;IACC,IAAI,KAAK,CAAC,WAAW,IAAI,KAAK,CAAC,aAAa;QAAE,OAAO,IAAI,CAAA;IACzD,OAAO,oBAAoB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;AAC5C,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,qBAAqB,CACnC,OAAiC;IAEjC,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,KAAK,eAAe,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;AAC3F,CAAC","sourcesContent":["import type { Project } from '@elytracms/core/studio-core'\nimport type { ResolvedWorkspaceProject } from '@elytracms/core/studio-core'\nimport type { WorkspaceState } from './workspace-source'\n\n/**\n * Config-driven switcher source (EC-154, reframed for EC-179 per-backend\n * projects). Pure logic deciding what the project switcher and launcher list:\n *\n * - **No workspace config** → exactly today's behavior: the adapter-listed\n * projects, untouched (single-project golden path).\n * - **Config present** → every configured project, in config order, as a\n * navigable entry; one that has no persisted counterpart yet is an explicit\n * `unprovisioned` state (\"run `builder init --project <slug>`\") rather than an\n * error. Persisted projects *not* in the config are not listed: the config is\n * the source of truth for what this workspace is.\n *\n * Visibility is **not** filtered by membership. One project per backend (vision\n * AD-8): a configured project lives on its own deployment, so the *active*\n * backend's memberships cannot speak to another project's. Access is enforced\n * where it belongs — per-backend sign-in plus the EC-150 role hook on entry —\n * not by hiding projects you'd authenticate into. (Hiding them was the\n * single-backend assumption; cross-backend it just made projects unreachable.)\n */\n\nexport type SwitcherEntry =\n | { kind: 'project'; project: Project }\n | { kind: 'unprovisioned'; config: ResolvedWorkspaceProject }\n\nexport interface SwitcherSourceInput {\n workspace: WorkspaceState\n /** The studio store's read model (config-derived under a workspace config). */\n persisted: readonly Project[]\n}\n\nexport function selectSwitcherProjects(input: SwitcherSourceInput): SwitcherEntry[] {\n if (input.workspace.kind !== 'config') {\n // No-config golden path (an invalid config never reaches the switcher —\n // the DeploymentSetupGate blocks boot): today's adapter-listed behavior.\n return input.persisted.map((project) => ({ kind: 'project', project }))\n }\n\n const bySlug = new Map(input.persisted.map((project) => [project.slug, project]))\n return input.workspace.projects.map((config) => {\n const persisted = bySlug.get(config.slug)\n return persisted\n ? { kind: 'project' as const, project: persisted }\n : { kind: 'unprovisioned' as const, config }\n })\n}\n\n/** The persisted projects among the entries (for list surfaces filtering by status). */\nexport function persistedProjects(entries: readonly SwitcherEntry[]): Project[] {\n return entries.flatMap((entry) => (entry.kind === 'project' ? [entry.project] : []))\n}\n\n/**\n * The workspace's sole navigable project, or `null` (EC-401). Non-null exactly\n * when the workspace has ONE entry total and it is a real `project` — a single\n * *unprovisioned* entry keeps this `null` (the launcher's setup gate must stay\n * visible), and a second entry of any kind does too.\n */\nexport function soleWorkspaceProject(entries: readonly SwitcherEntry[]): Project | null {\n const [only] = entries\n return entries.length === 1 && only?.kind === 'project' ? only.project : null\n}\n\n/**\n * EC-401 — the ONE single-project predicate, shared by the launcher (skip the\n * dashboard hop) and the shell header (plain project name instead of the\n * switcher dropdown) so the two surfaces can never disagree.\n */\nexport function isSingleProjectWorkspace(entries: readonly SwitcherEntry[]): boolean {\n return soleWorkspaceProject(entries) !== null\n}\n\n/**\n * The launcher's auto-forward decision (EC-401), pure: the sole project to\n * redirect to, or `null` to render the launcher. A forced `?state=` verification\n * state and an explicit \"all projects\" navigation (see `launcherVisitState` in\n * the router seam) both keep the launcher visible; otherwise a single-project\n * workspace forwards straight into its project.\n */\nexport function launcherAutoForwardTarget(input: {\n entries: readonly SwitcherEntry[]\n /** Whether the launcher was opened with a forced `?state=` verification state. */\n forcedState: boolean\n /** Whether this location is an explicit \"all projects\" navigation. */\n explicitVisit: boolean\n}): Project | null {\n if (input.forcedState || input.explicitVisit) return null\n return soleWorkspaceProject(input.entries)\n}\n\n/** The not-yet-provisioned config entries (rendered as explicit CLI-hint states). */\nexport function unprovisionedProjects(\n entries: readonly SwitcherEntry[],\n): ResolvedWorkspaceProject[] {\n return entries.flatMap((entry) => (entry.kind === 'unprovisioned' ? [entry.config] : []))\n}\n"]}
1
+ {"version":3,"file":"switcher-source.js","sourceRoot":"","sources":["../../../src/lib/workspace/switcher-source.ts"],"names":[],"mappings":"AAmDA,MAAM,UAAU,sBAAsB,CAAC,KAA0B;IAC/D,IAAI,KAAK,CAAC,SAAS,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QACtC,wEAAwE;QACxE,yEAAyE;QACzE,OAAO,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC,CAAA;IACzE,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAA;IACjF,OAAO,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;QAC7C,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QACzC,OAAO,SAAS;YACd,CAAC,CAAC,EAAE,IAAI,EAAE,SAAkB,EAAE,OAAO,EAAE,SAAS,EAAE;YAClD,CAAC,CAAC,EAAE,IAAI,EAAE,eAAwB,EAAE,MAAM,EAAE,CAAA;IAChD,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,wFAAwF;AACxF,MAAM,UAAU,iBAAiB,CAAC,OAAiC;IACjE,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;AACtF,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAiC;IACpE,MAAM,CAAC,IAAI,CAAC,GAAG,OAAO,CAAA;IACtB,OAAO,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,EAAE,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAA;AAC/E,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CAAC,OAAiC;IACxE,OAAO,oBAAoB,CAAC,OAAO,CAAC,KAAK,IAAI,CAAA;AAC/C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,yBAAyB,CAAC,KAMzC;IACC,IAAI,KAAK,CAAC,WAAW,IAAI,KAAK,CAAC,aAAa;QAAE,OAAO,IAAI,CAAA;IACzD,OAAO,oBAAoB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;AAC5C,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,qBAAqB,CACnC,OAAiC;IAEjC,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,KAAK,eAAe,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;AAC3F,CAAC","sourcesContent":["import type { Project } from '@elytracms/core/studio-core'\nimport type { ResolvedWorkspaceProject } from '@elytracms/core/studio-core'\nimport type { WorkspaceState } from './workspace-source'\n\n/**\n * Config-driven switcher source (EC-154, reframed for EC-179 per-backend\n * projects). Pure logic deciding what the project switcher and launcher list:\n *\n * - **No workspace config** → exactly today's behavior: the adapter-listed\n * projects, untouched (single-project golden path).\n * - **Config present** → every configured project, in config order, as a\n * navigable entry; one that has no persisted counterpart yet is an explicit\n * `unprovisioned` state (\"run `elytra init`\") rather than an error. Persisted\n * projects *not* in the config are not listed: the config is the source of\n * truth for what this workspace is.\n *\n * ## The `unprovisioned` branch is currently unreachable FROM THE STUDIO (EC-470)\n *\n * This function will happily produce `unprovisioned` — `switcher-source.test.ts`\n * covers it directly. But the live studio can no longer feed it inputs that do:\n * `studio-context.tsx`'s `configProjects()` derives `persisted` from the SAME\n * `workspace.projects` array this function iterates (via `configProject`, which\n * sets `slug` from the config entry), so the `bySlug` lookup below always hits.\n * Under AD-8 project identity became config-owned, and \"provisioned\" stopped\n * being a per-project row the studio could miss — it is now a property of the\n * DEPLOYMENT (see `DeploymentSetupGate` / `elytra doctor`).\n *\n * Left in place deliberately rather than removed: the entry kind is load-bearing\n * for the EC-401 single-project predicates below (`soleWorkspaceProject` treats a\n * lone unprovisioned entry as \"do not auto-forward\"), so retiring it is a\n * separate, owner-sized decision — not a docs sweep. Recorded so the next reader\n * does not mistake it for live UI.\n *\n * Visibility is **not** filtered by membership. One project per backend (vision\n * AD-8): a configured project lives on its own deployment, so the *active*\n * backend's memberships cannot speak to another project's. Access is enforced\n * where it belongs — per-backend sign-in plus the EC-150 role hook on entry —\n * not by hiding projects you'd authenticate into. (Hiding them was the\n * single-backend assumption; cross-backend it just made projects unreachable.)\n */\n\nexport type SwitcherEntry =\n | { kind: 'project'; project: Project }\n | { kind: 'unprovisioned'; config: ResolvedWorkspaceProject }\n\nexport interface SwitcherSourceInput {\n workspace: WorkspaceState\n /** The studio store's read model (config-derived under a workspace config). */\n persisted: readonly Project[]\n}\n\nexport function selectSwitcherProjects(input: SwitcherSourceInput): SwitcherEntry[] {\n if (input.workspace.kind !== 'config') {\n // No-config golden path (an invalid config never reaches the switcher —\n // the DeploymentSetupGate blocks boot): today's adapter-listed behavior.\n return input.persisted.map((project) => ({ kind: 'project', project }))\n }\n\n const bySlug = new Map(input.persisted.map((project) => [project.slug, project]))\n return input.workspace.projects.map((config) => {\n const persisted = bySlug.get(config.slug)\n return persisted\n ? { kind: 'project' as const, project: persisted }\n : { kind: 'unprovisioned' as const, config }\n })\n}\n\n/** The persisted projects among the entries (for list surfaces filtering by status). */\nexport function persistedProjects(entries: readonly SwitcherEntry[]): Project[] {\n return entries.flatMap((entry) => (entry.kind === 'project' ? [entry.project] : []))\n}\n\n/**\n * The workspace's sole navigable project, or `null` (EC-401). Non-null exactly\n * when the workspace has ONE entry total and it is a real `project` — a single\n * *unprovisioned* entry keeps this `null` (the launcher's setup gate must stay\n * visible), and a second entry of any kind does too.\n */\nexport function soleWorkspaceProject(entries: readonly SwitcherEntry[]): Project | null {\n const [only] = entries\n return entries.length === 1 && only?.kind === 'project' ? only.project : null\n}\n\n/**\n * EC-401 — the ONE single-project predicate, shared by the launcher (skip the\n * dashboard hop) and the shell header (plain project name instead of the\n * switcher dropdown) so the two surfaces can never disagree.\n */\nexport function isSingleProjectWorkspace(entries: readonly SwitcherEntry[]): boolean {\n return soleWorkspaceProject(entries) !== null\n}\n\n/**\n * The launcher's auto-forward decision (EC-401), pure: the sole project to\n * redirect to, or `null` to render the launcher. A forced `?state=` verification\n * state and an explicit \"all projects\" navigation (see `launcherVisitState` in\n * the router seam) both keep the launcher visible; otherwise a single-project\n * workspace forwards straight into its project.\n */\nexport function launcherAutoForwardTarget(input: {\n entries: readonly SwitcherEntry[]\n /** Whether the launcher was opened with a forced `?state=` verification state. */\n forcedState: boolean\n /** Whether this location is an explicit \"all projects\" navigation. */\n explicitVisit: boolean\n}): Project | null {\n if (input.forcedState || input.explicitVisit) return null\n return soleWorkspaceProject(input.entries)\n}\n\n/** The not-yet-provisioned config entries (rendered as explicit CLI-hint states). */\nexport function unprovisionedProjects(\n entries: readonly SwitcherEntry[],\n): ResolvedWorkspaceProject[] {\n return entries.flatMap((entry) => (entry.kind === 'unprovisioned' ? [entry.config] : []))\n}\n"]}
@@ -1,4 +1,31 @@
1
1
  import { extractWorkspaceConfigExport, resolveWorkspaceConfig, WORKSPACE_CONFIG_FILE, } from '@elytracms/core/studio-core';
2
+ /**
3
+ * `result.issues` is carried on the `invalid` path and **deliberately dropped on the
4
+ * ok path** (EC-506, decided 2026-08-01) — not overlooked.
5
+ *
6
+ * `ok` means "no error-severity issue", so what would be dropped is warnings — and
7
+ * the resolver has **no warning-severity producer** (measured 2026-08-01: every
8
+ * `severity:` literal in `studio-core/workspace-config.ts` is `'error'`, and its one
9
+ * pass-through of a foreign severity cannot carry `validateProjectSettings`'s only
10
+ * warning; both gates are pinned by `workspace-config.test.ts`). Adding an `issues`
11
+ * field here today would be a channel with a writer, no producer and no reader —
12
+ * exactly the latent plumbing EC-376 deleted from this file (see the NOTE above).
13
+ *
14
+ * The consequence is a KNOWN, deliberate divergence from `elytra doctor`, which does
15
+ * carry the count (`cli/src/doctor.js` `configFactsFromOutcome` sets
16
+ * `issueCount: issues.length` unconditionally, and `deployment-ready.ts`'s
17
+ * `config-valid` check has a `warn` branch for a valid-config-with-issues that the
18
+ * studio can therefore never reach). It is **latent, not live**: with zero producers
19
+ * the count on a valid config is always 0, and `deployment-ready.ts` tests it for
20
+ * truthiness — so both tools render the same `ok` today. (Read at both sites and
21
+ * inferred from them; not exercised end-to-end through the studio gate.)
22
+ *
23
+ * **Resurface trigger.** The first warning-severity `WorkspaceConfigIssue` makes the
24
+ * divergence live and this decision expires. At that point EC-506's audience question
25
+ * ("does an EDITOR need to know?") returns as a real design call, and the shape is in
26
+ * the EC-506 task file: `issues` here, a mapper in `config-issues.ts`, a rail-foot
27
+ * reader, and a localized catalog key. Do not add the field ahead of the producer.
28
+ */
2
29
  function fromValue(value, source) {
3
30
  const result = resolveWorkspaceConfig(value, { file: source });
4
31
  return result.ok
@@ -1 +1 @@
1
- {"version":3,"file":"workspace-source.js","sourceRoot":"","sources":["../../../src/lib/workspace/workspace-source.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,EAC5B,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,6BAA6B,CAAA;AAsCpC,SAAS,SAAS,CAAC,KAAc,EAAE,MAAc;IAC/C,MAAM,MAAM,GAAG,sBAAsB,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAA;IAC9D,OAAO,MAAM,CAAC,EAAE;QACd,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE;QACvD,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAA;AACxD,CAAC;AAED,0FAA0F;AAC1F,MAAM,UAAU,qBAAqB,CAAC,OAAyB;IAC7D,IAAI,OAAO,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QACrC,MAAM,IAAI,GAAG,OAAO,CAAC,QAAQ,IAAI,qBAAqB,CAAA;QACtD,MAAM,SAAS,GAAG,4BAA4B,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;QACxE,IAAI,OAAO,IAAI,SAAS;YAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAA;QAC7F,OAAO,SAAS,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;IACzC,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAA;AACzB,CAAC","sourcesContent":["import {\n extractWorkspaceConfigExport,\n resolveWorkspaceConfig,\n WORKSPACE_CONFIG_FILE,\n} from '@elytracms/core/studio-core'\nimport type { ResolvedWorkspaceProject, WorkspaceConfigIssue } from '@elytracms/core/studio-core'\n\n/**\n * Workspace-config resolution for the studio (EC-154, vision AD-8).\n *\n * The studio receives its code-first workspace config as the default export of\n * the consumer's `elytra.config.ts`, handed in at the mount point\n * (`createStudio(config)` in `./index.ts`) and resolved here as pure, testable\n * logic. A bundled `elytra.config.ts` at the builder app root — picked up by\n * Vite (`import.meta.glob`) — is the same channel for studio development and for\n * a self-hosted builder whose repo *is* the workspace.\n *\n * No channel → `none`: the single-project golden path, identical to today's\n * adapter-listed behavior. An invalid config is a deterministic boot-error state\n * (see `DeploymentSetupGate`) — never a silent fallback to unconfigured behavior.\n *\n * NOTE (EC-376): an earlier env-injected-JSON channel (`VITE_ELYTRA_WORKSPACE`)\n * for a hosted builder serving a *separate* host repo was plumbed here but never\n * wired end-to-end — no caller ever set it (EC-357 inventory). It was removed as\n * dead code. If hosted workspace-selection ever returns, wire it deliberately\n * through the EC-357 mount-env seam (`createStudio(config, studioConfig, { env })`\n * → `provideStudioEnv`/`studioEnv()` in `lib/persistence/backend-mode.ts`) rather\n * than resurrecting latent plumbing.\n */\n\nexport type WorkspaceState =\n | { kind: 'none' }\n | { kind: 'config'; source: string; projects: ResolvedWorkspaceProject[] }\n | { kind: 'invalid'; source: string; issues: WorkspaceConfigIssue[] }\n\nexport interface WorkspaceSources {\n /** Module namespace of the bundled `elytra.config.ts`, when one was bundled. */\n fileModule?: unknown\n /** Source label for file-channel issues (defaults to the conventional name). */\n fileName?: string\n}\n\nfunction fromValue(value: unknown, source: string): WorkspaceState {\n const result = resolveWorkspaceConfig(value, { file: source })\n return result.ok\n ? { kind: 'config', source, projects: result.projects }\n : { kind: 'invalid', source, issues: result.issues }\n}\n\n/** Resolve the workspace state from the bundled config module. Pure and deterministic. */\nexport function resolveWorkspaceState(sources: WorkspaceSources): WorkspaceState {\n if (sources.fileModule !== undefined) {\n const file = sources.fileName ?? WORKSPACE_CONFIG_FILE\n const extracted = extractWorkspaceConfigExport(sources.fileModule, file)\n if ('issue' in extracted) return { kind: 'invalid', source: file, issues: [extracted.issue] }\n return fromValue(extracted.value, file)\n }\n\n return { kind: 'none' }\n}\n"]}
1
+ {"version":3,"file":"workspace-source.js","sourceRoot":"","sources":["../../../src/lib/workspace/workspace-source.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,EAC5B,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,6BAA6B,CAAA;AAsCpC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,SAAS,SAAS,CAAC,KAAc,EAAE,MAAc;IAC/C,MAAM,MAAM,GAAG,sBAAsB,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAA;IAC9D,OAAO,MAAM,CAAC,EAAE;QACd,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE;QACvD,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAA;AACxD,CAAC;AAED,0FAA0F;AAC1F,MAAM,UAAU,qBAAqB,CAAC,OAAyB;IAC7D,IAAI,OAAO,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QACrC,MAAM,IAAI,GAAG,OAAO,CAAC,QAAQ,IAAI,qBAAqB,CAAA;QACtD,MAAM,SAAS,GAAG,4BAA4B,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;QACxE,IAAI,OAAO,IAAI,SAAS;YAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAA;QAC7F,OAAO,SAAS,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;IACzC,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAA;AACzB,CAAC","sourcesContent":["import {\n extractWorkspaceConfigExport,\n resolveWorkspaceConfig,\n WORKSPACE_CONFIG_FILE,\n} from '@elytracms/core/studio-core'\nimport type { ResolvedWorkspaceProject, WorkspaceConfigIssue } from '@elytracms/core/studio-core'\n\n/**\n * Workspace-config resolution for the studio (EC-154, vision AD-8).\n *\n * The studio receives its code-first workspace config as the default export of\n * the consumer's `elytra.config.ts`, handed in at the mount point\n * (`createStudio(config)` in `./index.ts`) and resolved here as pure, testable\n * logic. A bundled `elytra.config.ts` at the builder app root — picked up by\n * Vite (`import.meta.glob`) — is the same channel for studio development and for\n * a self-hosted builder whose repo *is* the workspace.\n *\n * No channel → `none`: the single-project golden path, identical to today's\n * adapter-listed behavior. An invalid config is a deterministic boot-error state\n * (see `DeploymentSetupGate`) — never a silent fallback to unconfigured behavior.\n *\n * NOTE (EC-376): an earlier env-injected-JSON channel (`VITE_ELYTRA_WORKSPACE`)\n * for a hosted builder serving a *separate* host repo was plumbed here but never\n * wired end-to-end — no caller ever set it (EC-357 inventory). It was removed as\n * dead code. If hosted workspace-selection ever returns, wire it deliberately\n * through the EC-357 mount-env seam (`createStudio(config, studioConfig, { env })`\n * → `provideStudioEnv`/`studioEnv()` in `lib/persistence/backend-mode.ts`) rather\n * than resurrecting latent plumbing.\n */\n\nexport type WorkspaceState =\n | { kind: 'none' }\n | { kind: 'config'; source: string; projects: ResolvedWorkspaceProject[] }\n | { kind: 'invalid'; source: string; issues: WorkspaceConfigIssue[] }\n\nexport interface WorkspaceSources {\n /** Module namespace of the bundled `elytra.config.ts`, when one was bundled. */\n fileModule?: unknown\n /** Source label for file-channel issues (defaults to the conventional name). */\n fileName?: string\n}\n\n/**\n * `result.issues` is carried on the `invalid` path and **deliberately dropped on the\n * ok path** (EC-506, decided 2026-08-01) — not overlooked.\n *\n * `ok` means \"no error-severity issue\", so what would be dropped is warnings — and\n * the resolver has **no warning-severity producer** (measured 2026-08-01: every\n * `severity:` literal in `studio-core/workspace-config.ts` is `'error'`, and its one\n * pass-through of a foreign severity cannot carry `validateProjectSettings`'s only\n * warning; both gates are pinned by `workspace-config.test.ts`). Adding an `issues`\n * field here today would be a channel with a writer, no producer and no reader —\n * exactly the latent plumbing EC-376 deleted from this file (see the NOTE above).\n *\n * The consequence is a KNOWN, deliberate divergence from `elytra doctor`, which does\n * carry the count (`cli/src/doctor.js` `configFactsFromOutcome` sets\n * `issueCount: issues.length` unconditionally, and `deployment-ready.ts`'s\n * `config-valid` check has a `warn` branch for a valid-config-with-issues that the\n * studio can therefore never reach). It is **latent, not live**: with zero producers\n * the count on a valid config is always 0, and `deployment-ready.ts` tests it for\n * truthiness — so both tools render the same `ok` today. (Read at both sites and\n * inferred from them; not exercised end-to-end through the studio gate.)\n *\n * **Resurface trigger.** The first warning-severity `WorkspaceConfigIssue` makes the\n * divergence live and this decision expires. At that point EC-506's audience question\n * (\"does an EDITOR need to know?\") returns as a real design call, and the shape is in\n * the EC-506 task file: `issues` here, a mapper in `config-issues.ts`, a rail-foot\n * reader, and a localized catalog key. Do not add the field ahead of the producer.\n */\nfunction fromValue(value: unknown, source: string): WorkspaceState {\n const result = resolveWorkspaceConfig(value, { file: source })\n return result.ok\n ? { kind: 'config', source, projects: result.projects }\n : { kind: 'invalid', source, issues: result.issues }\n}\n\n/** Resolve the workspace state from the bundled config module. Pure and deterministic. */\nexport function resolveWorkspaceState(sources: WorkspaceSources): WorkspaceState {\n if (sources.fileModule !== undefined) {\n const file = sources.fileName ?? WORKSPACE_CONFIG_FILE\n const extracted = extractWorkspaceConfigExport(sources.fileModule, file)\n if ('issue' in extracted) return { kind: 'invalid', source: file, issues: [extracted.issue] }\n return fromValue(extracted.value, file)\n }\n\n return { kind: 'none' }\n}\n"]}
@@ -11,8 +11,15 @@ import type { GeneratedPreviewLookup } from '../components/builder/blocks-model.
11
11
  * so it is importable as a plain JSON module. Everything in it is
12
12
  * deterministic — no timestamps — so an unchanged re-run rewrites nothing.
13
13
  */
14
- /** Format version the CLI writes; bump on incompatible schema/hash changes. */
15
- export declare const PREVIEWS_MANIFEST_VERSION = 1;
14
+ /**
15
+ * Format version the CLI writes; bump on incompatible schema/hash changes.
16
+ *
17
+ * `2` (EC-502): the entry hash no longer folds in the engine version, so v1 and v2
18
+ * hashes are not comparable. `elytra previews --check` reports a version mismatch
19
+ * as itself and regenerates, rather than printing one bogus `stale` line per entry.
20
+ * The READER below is unaffected — it only ever looks at componentId/fixture/url.
21
+ */
22
+ export declare const PREVIEWS_MANIFEST_VERSION = 2;
16
23
  /** One generated preview artifact: a component fixture and its rendered image. */
17
24
  export interface GeneratedPreviewsManifestEntry {
18
25
  componentId: string;
@@ -22,10 +29,10 @@ export interface GeneratedPreviewsManifestEntry {
22
29
  url: string;
23
30
  /**
24
31
  * Input hash (sha-256 hex over the stable-serialized inputs: manifest prop +
25
- * slot shape, fixture props/slotChildren, engine version). `elytra previews`
26
- * skips entries whose hash is unchanged; `elytra previews --check` flags
27
- * entries whose hash drifted as stale. Deliberately NOT part of the lookup —
28
- * the studio only reads `componentId`/`fixture`/`url`.
32
+ * slot shape, fixture props/slotChildren — NOT the engine version, EC-502).
33
+ * `elytra previews` skips entries whose hash is unchanged; `elytra previews
34
+ * --check` flags entries whose hash drifted as stale. Deliberately NOT part of
35
+ * the lookup — the studio only reads `componentId`/`fixture`/`url`.
29
36
  */
30
37
  hash: string;
31
38
  }
@@ -10,8 +10,15 @@
10
10
  * so it is importable as a plain JSON module. Everything in it is
11
11
  * deterministic — no timestamps — so an unchanged re-run rewrites nothing.
12
12
  */
13
- /** Format version the CLI writes; bump on incompatible schema/hash changes. */
14
- export const PREVIEWS_MANIFEST_VERSION = 1;
13
+ /**
14
+ * Format version the CLI writes; bump on incompatible schema/hash changes.
15
+ *
16
+ * `2` (EC-502): the entry hash no longer folds in the engine version, so v1 and v2
17
+ * hashes are not comparable. `elytra previews --check` reports a version mismatch
18
+ * as itself and regenerates, rather than printing one bogus `stale` line per entry.
19
+ * The READER below is unaffected — it only ever looks at componentId/fixture/url.
20
+ */
21
+ export const PREVIEWS_MANIFEST_VERSION = 2;
15
22
  /** Tolerant entry guard — a malformed entry is skipped, never a crash. */
16
23
  function isManifestEntry(value) {
17
24
  if (typeof value !== 'object' || value === null)
@@ -1 +1 @@
1
- {"version":3,"file":"manifest-format.js","sourceRoot":"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AAG,WAAW,SAAS,OAAO,EAAE,CAAA;AACzC,CAAC","sourcesContent":["import type { GeneratedPreviewLookup } from '../components/builder/blocks-model'\n\n/**\n * The previews-manifest format (EC-440) — the JSON contract between the\n * `elytra previews` CLI (the writer) and a consumer's `studio.config.tsx`\n * (the reader, via {@link generatedPreviewsFromManifest}).\n *\n * The CLI renders every canvas-eligible component's fixtures headlessly\n * against the consumer theme, writes the images to the studio app's\n * `public/elytra-previews/` (served at `/elytra-previews/...`), and writes\n * this manifest next to `studio.config.tsx` (`studio/elytra-previews.json`)\n * so it is importable as a plain JSON module. Everything in it is\n * deterministic — no timestamps — so an unchanged re-run rewrites nothing.\n */\n\n/** Format version the CLI writes; bump on incompatible schema/hash changes. */\nexport const PREVIEWS_MANIFEST_VERSION = 1\n\n/** One generated preview artifact: a component fixture and its rendered image. */\nexport interface GeneratedPreviewsManifestEntry {\n componentId: string\n /** The fixture name, or `'Default'` for a fixture-less component's implicit variant. */\n fixture: string\n /** Root-relative image URL (the file lives in the studio app's `public/`). */\n url: string\n /**\n * Input hash (sha-256 hex over the stable-serialized inputs: manifest prop +\n * slot shape, fixture props/slotChildren, engine version). `elytra previews`\n * skips entries whose hash is unchanged; `elytra previews --check` flags\n * entries whose hash drifted as stale. Deliberately NOT part of the lookup —\n * the studio only reads `componentId`/`fixture`/`url`.\n */\n hash: string\n}\n\n/** The manifest document `elytra previews` writes (`studio/elytra-previews.json`). */\nexport interface GeneratedPreviewsManifest {\n version: number\n /** The `@elytracms/studio` version the images were rendered with. */\n engine: string\n entries: GeneratedPreviewsManifestEntry[]\n}\n\n/** Tolerant entry guard — a malformed entry is skipped, never a crash. */\nfunction isManifestEntry(value: unknown): value is GeneratedPreviewsManifestEntry {\n if (typeof value !== 'object' || value === null) return false\n const entry = value as Record<string, unknown>\n return (\n typeof entry.componentId === 'string' &&\n typeof entry.fixture === 'string' &&\n typeof entry.url === 'string'\n )\n}\n\n/**\n * Adapt a previews manifest (a plain JSON import) into the EC-439\n * {@link GeneratedPreviewLookup} seam. The whole consumer wiring is ~2 lines:\n *\n * ```tsx\n * // studio.config.tsx\n * import previewsManifest from './elytra-previews.json'\n * export default defineStudio({\n * previews: { generated: generatedPreviewsFromManifest(previewsManifest) },\n * })\n * ```\n *\n * Tolerant by design (the input is a generated file a human may hand-edit or\n * delete): a malformed document or entry yields lookup misses — the blocks\n * panel then falls back to the icon+name placeholder — never a crash. A\n * fixture-less component's single implicit variant is looked up (and written\n * by the CLI) under the fixture name `'Default'`.\n */\nexport function generatedPreviewsFromManifest(manifest: unknown): GeneratedPreviewLookup {\n const byKey = new Map<string, string>()\n if (typeof manifest === 'object' && manifest !== null) {\n const entries = (manifest as { entries?: unknown }).entries\n if (Array.isArray(entries)) {\n for (const entry of entries) {\n if (isManifestEntry(entry)) byKey.set(lookupKey(entry.componentId, entry.fixture), entry.url)\n }\n }\n }\n return (componentId, fixtureName) => byKey.get(lookupKey(componentId, fixtureName))\n}\n\nfunction lookupKey(componentId: string, fixture: string): string {\n // NUL (\\u0000) can appear in neither a component id nor a fixture name.\n return `${componentId}\\u0000${fixture}`\n}\n"]}
1
+ {"version":3,"file":"manifest-format.js","sourceRoot":"","sources":["../../src/previews/manifest-format.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AAEH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAA;AA2B1C,0EAA0E;AAC1E,SAAS,eAAe,CAAC,KAAc;IACrC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAA;IAC7D,MAAM,KAAK,GAAG,KAAgC,CAAA;IAC9C,OAAO,CACL,OAAO,KAAK,CAAC,WAAW,KAAK,QAAQ;QACrC,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ;QACjC,OAAO,KAAK,CAAC,GAAG,KAAK,QAAQ,CAC9B,CAAA;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,6BAA6B,CAAC,QAAiB;IAC7D,MAAM,KAAK,GAAG,IAAI,GAAG,EAAkB,CAAA;IACvC,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACtD,MAAM,OAAO,GAAI,QAAkC,CAAC,OAAO,CAAA;QAC3D,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YAC3B,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;gBAC5B,IAAI,eAAe,CAAC,KAAK,CAAC;oBAAE,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAA;YAC/F,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,CAAC,WAAW,EAAE,WAAW,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC,CAAA;AACrF,CAAC;AAED,SAAS,SAAS,CAAC,WAAmB,EAAE,OAAe;IACrD,wEAAwE;IACxE,OAAO,GAAG,WAAW,SAAS,OAAO,EAAE,CAAA;AACzC,CAAC","sourcesContent":["import type { GeneratedPreviewLookup } from '../components/builder/blocks-model'\n\n/**\n * The previews-manifest format (EC-440) — the JSON contract between the\n * `elytra previews` CLI (the writer) and a consumer's `studio.config.tsx`\n * (the reader, via {@link generatedPreviewsFromManifest}).\n *\n * The CLI renders every canvas-eligible component's fixtures headlessly\n * against the consumer theme, writes the images to the studio app's\n * `public/elytra-previews/` (served at `/elytra-previews/...`), and writes\n * this manifest next to `studio.config.tsx` (`studio/elytra-previews.json`)\n * so it is importable as a plain JSON module. Everything in it is\n * deterministic — no timestamps — so an unchanged re-run rewrites nothing.\n */\n\n/**\n * Format version the CLI writes; bump on incompatible schema/hash changes.\n *\n * `2` (EC-502): the entry hash no longer folds in the engine version, so v1 and v2\n * hashes are not comparable. `elytra previews --check` reports a version mismatch\n * as itself and regenerates, rather than printing one bogus `stale` line per entry.\n * The READER below is unaffected — it only ever looks at componentId/fixture/url.\n */\nexport const PREVIEWS_MANIFEST_VERSION = 2\n\n/** One generated preview artifact: a component fixture and its rendered image. */\nexport interface GeneratedPreviewsManifestEntry {\n componentId: string\n /** The fixture name, or `'Default'` for a fixture-less component's implicit variant. */\n fixture: string\n /** Root-relative image URL (the file lives in the studio app's `public/`). */\n url: string\n /**\n * Input hash (sha-256 hex over the stable-serialized inputs: manifest prop +\n * slot shape, fixture props/slotChildren — NOT the engine version, EC-502).\n * `elytra previews` skips entries whose hash is unchanged; `elytra previews\n * --check` flags entries whose hash drifted as stale. Deliberately NOT part of\n * the lookup — the studio only reads `componentId`/`fixture`/`url`.\n */\n hash: string\n}\n\n/** The manifest document `elytra previews` writes (`studio/elytra-previews.json`). */\nexport interface GeneratedPreviewsManifest {\n version: number\n /** The `@elytracms/studio` version the images were rendered with. */\n engine: string\n entries: GeneratedPreviewsManifestEntry[]\n}\n\n/** Tolerant entry guard — a malformed entry is skipped, never a crash. */\nfunction isManifestEntry(value: unknown): value is GeneratedPreviewsManifestEntry {\n if (typeof value !== 'object' || value === null) return false\n const entry = value as Record<string, unknown>\n return (\n typeof entry.componentId === 'string' &&\n typeof entry.fixture === 'string' &&\n typeof entry.url === 'string'\n )\n}\n\n/**\n * Adapt a previews manifest (a plain JSON import) into the EC-439\n * {@link GeneratedPreviewLookup} seam. The whole consumer wiring is ~2 lines:\n *\n * ```tsx\n * // studio.config.tsx\n * import previewsManifest from './elytra-previews.json'\n * export default defineStudio({\n * previews: { generated: generatedPreviewsFromManifest(previewsManifest) },\n * })\n * ```\n *\n * Tolerant by design (the input is a generated file a human may hand-edit or\n * delete): a malformed document or entry yields lookup misses — the blocks\n * panel then falls back to the icon+name placeholder — never a crash. A\n * fixture-less component's single implicit variant is looked up (and written\n * by the CLI) under the fixture name `'Default'`.\n */\nexport function generatedPreviewsFromManifest(manifest: unknown): GeneratedPreviewLookup {\n const byKey = new Map<string, string>()\n if (typeof manifest === 'object' && manifest !== null) {\n const entries = (manifest as { entries?: unknown }).entries\n if (Array.isArray(entries)) {\n for (const entry of entries) {\n if (isManifestEntry(entry)) byKey.set(lookupKey(entry.componentId, entry.fixture), entry.url)\n }\n }\n }\n return (componentId, fixtureName) => byKey.get(lookupKey(componentId, fixtureName))\n}\n\nfunction lookupKey(componentId: string, fixture: string): string {\n // NUL (\\u0000) can appear in neither a component id nor a fixture name.\n return `${componentId}\\u0000${fixture}`\n}\n"]}
@@ -30,7 +30,13 @@ export interface StudioRootRouteOptions {
30
30
  appCssUrl: string;
31
31
  /** Document `<title>`. Default: `'Elytra'`. */
32
32
  title?: string;
33
- /** `<html lang>`. Default: `'en'`. */
33
+ /**
34
+ * `<html lang>`. Defaults to the **resolved studio-UI locale** (EC-513): the
35
+ * config-pinned `i18n.locale` if there is one, otherwise the default locale on the
36
+ * server and, once browser detection takes over after hydration, the visitor's
37
+ * preferred locale. Pass a value only to fix `lang` to something the chrome is not
38
+ * actually rendered in.
39
+ */
34
40
  htmlLang?: string;
35
41
  /**
36
42
  * Extra `<head>` meta entries appended after the defaults (charset, viewport,
@@ -48,3 +54,32 @@ export interface StudioRootRouteOptions {
48
54
  providers?: (children: ReactNode) => ReactNode;
49
55
  }
50
56
  export declare function createStudioRootRoute(options: StudioRootRouteOptions): import("@tanstack/react-router").RootRoute<import("@tanstack/router-core").Register, undefined, {}, import("@tanstack/router-core").AnyContext, import("@tanstack/router-core").AnyContext, {}, undefined, unknown, unknown, unknown, unknown, undefined>;
57
+ /**
58
+ * The studio's boot screen: the deterministic session-restore state and — because a
59
+ * request-less render always finds the auth gate `pending` — the entire body of the
60
+ * build-time prerendered SPA shell (`dist/client/_shell.html`).
61
+ *
62
+ * **It is deliberately wordless** (EC-523; owner-ratified 2026-08-01: *"remove the text
63
+ * — if we really need something while loading, add a simple spinner, but not mandatory —
64
+ * the shell should stay free of side-effects"*). A build-time prerender has no request,
65
+ * hence no `Accept-Language` and no session, so it cannot know the visitor's language.
66
+ * EC-513 fixed the one string that flipped after hydration; removing the words removes
67
+ * the possibility of the next one.
68
+ *
69
+ * **Accessibility**, because "no words" must not mean "no accessible name": moving the
70
+ * text into an `aria-label` bakes the very same wrong-language string into the shell,
71
+ * only somewhere a screen-reader user cannot notice it flip. So the shell ships an
72
+ * **empty** `role="status"` region — the correct live-region shape in any case, since a
73
+ * region must already exist in the DOM for a later insertion to be announced — and
74
+ * `useHydrated` fills it once hydration is done, in the visitor's actual locale. The
75
+ * unannounced window is bounded by hydration, i.e. exactly the window in which no
76
+ * announcement could have been correct.
77
+ *
78
+ * Do **not** add `aria-busy` here: on a live region it tells assistive tech to withhold
79
+ * updates, which would suppress the very announcement this shape exists to deliver.
80
+ *
81
+ * Exported so the shell's pre-hydration markup is pinnable with `renderToStaticMarkup`
82
+ * (`root.test.tsx`) — the built artefact is the real proof, but nothing else in the
83
+ * node test pattern can reach this render.
84
+ */
85
+ export declare function SessionLoading(): import("react").JSX.Element;
@@ -6,14 +6,14 @@ import { DeploymentSetupGate } from '@elytracms/studio/components/deployment-set
6
6
  import { SessionExpiredOverlay } from '@elytracms/studio/components/session-expired-overlay';
7
7
  import { StudioProvider } from '@elytracms/studio/components/studio-context';
8
8
  import { ThemeProvider } from '@elytracms/studio/components/theme-context';
9
- import { Text } from '@elytracms/studio/ui';
9
+ import { Loader2 } from 'lucide-react';
10
10
  import { SIGN_IN_PATH, resolveRouteGuard } from '@elytracms/studio/lib/auth';
11
- import { useT } from '@elytracms/studio/lib/i18n';
11
+ import { useHydrated, useT, useUiLocale } from '@elytracms/studio/lib/i18n';
12
12
  import { setStudioBaseTitle } from '@elytracms/studio/lib/tab-title';
13
13
  import { activeSlugForLocation, setActiveProjectSlug } from '@elytracms/studio/lib/workspace';
14
14
  import { THEME_INIT_SCRIPT } from '@elytracms/studio/lib/theme';
15
15
  export function createStudioRootRoute(options) {
16
- const { appCssUrl, title = 'Elytra', htmlLang = 'en', meta = [], links = [], providers } = options;
16
+ const { appCssUrl, title = 'Elytra', htmlLang, meta = [], links = [], providers } = options;
17
17
  // EC-402: register the base title for the shell's per-view tab-title effect
18
18
  // (`StudioTabTitle` composes `deepest crumb · view · project · <this title>`
19
19
  // and restores exactly this value when leaving a project view). Module-holder
@@ -22,6 +22,15 @@ export function createStudioRootRoute(options) {
22
22
  setStudioBaseTitle(title);
23
23
  function RootComponent() {
24
24
  const location = useLocation();
25
+ // EC-513: locale resolution is client-side, so the studio boots in the server's
26
+ // locale (default, or the `i18n.locale` pin) and hands over to the browser's
27
+ // preference AFTER hydration — the hydration render has to reproduce the server's
28
+ // markup or React discards the tree with a mismatch error. Subscribing HERE, at the
29
+ // one root above the whole chrome, is what makes the handover visible everywhere:
30
+ // ~948 of the studio's localized render sites call the non-hook `translate()` and
31
+ // would otherwise never re-render for it. It also keeps `<html lang>` honest —
32
+ // it names the language the chrome is actually rendered in, at every moment.
33
+ const uiLocale = useUiLocale();
25
34
  // EC-179: the active project selects its Convex backend. Resolve it from the
26
35
  // URL (or the sign-in redirect target) and bind it *before* the auth and
27
36
  // persistence adapters are selected, so the initial sign-in authenticates
@@ -30,7 +39,7 @@ export function createStudioRootRoute(options) {
30
39
  // re-select against the new backend and the session is restored per-backend.
31
40
  const activeSlug = activeSlugForLocation(location.pathname, location.search.redirect);
32
41
  setActiveProjectSlug(activeSlug);
33
- return (_jsx(RootDocument, { htmlLang: htmlLang, children: _jsx(ThemeProvider, { children: _jsx(DeploymentSetupGate, { children: _jsx(AuthProvider, { children: _jsx(AuthGate, { children: _jsxs(StudioProvider, { children: [providers ? providers(_jsx(Outlet, {})) : _jsx(Outlet, {}), _jsx(SessionExpiredOverlay, {})] }) }) }, activeSlug ?? '__launcher__') }) }) }));
42
+ return (_jsx(RootDocument, { htmlLang: htmlLang ?? uiLocale, children: _jsx(ThemeProvider, { children: _jsx(DeploymentSetupGate, { children: _jsx(AuthProvider, { children: _jsx(AuthGate, { children: _jsxs(StudioProvider, { children: [providers ? providers(_jsx(Outlet, {})) : _jsx(Outlet, {}), _jsx(SessionExpiredOverlay, {})] }) }) }, activeSlug ?? '__launcher__') }) }) }));
34
43
  }
35
44
  return createRootRoute({
36
45
  head: () => ({
@@ -77,10 +86,38 @@ function AuthGate({ children }) {
77
86
  return _jsx(NavigateOnce, { to: decision.target, replace: true });
78
87
  return children;
79
88
  }
80
- /** Deterministic session-restore state (also the SSR output for protected paths). */
81
- function SessionLoading() {
89
+ /**
90
+ * The studio's boot screen: the deterministic session-restore state and — because a
91
+ * request-less render always finds the auth gate `pending` — the entire body of the
92
+ * build-time prerendered SPA shell (`dist/client/_shell.html`).
93
+ *
94
+ * **It is deliberately wordless** (EC-523; owner-ratified 2026-08-01: *"remove the text
95
+ * — if we really need something while loading, add a simple spinner, but not mandatory —
96
+ * the shell should stay free of side-effects"*). A build-time prerender has no request,
97
+ * hence no `Accept-Language` and no session, so it cannot know the visitor's language.
98
+ * EC-513 fixed the one string that flipped after hydration; removing the words removes
99
+ * the possibility of the next one.
100
+ *
101
+ * **Accessibility**, because "no words" must not mean "no accessible name": moving the
102
+ * text into an `aria-label` bakes the very same wrong-language string into the shell,
103
+ * only somewhere a screen-reader user cannot notice it flip. So the shell ships an
104
+ * **empty** `role="status"` region — the correct live-region shape in any case, since a
105
+ * region must already exist in the DOM for a later insertion to be announced — and
106
+ * `useHydrated` fills it once hydration is done, in the visitor's actual locale. The
107
+ * unannounced window is bounded by hydration, i.e. exactly the window in which no
108
+ * announcement could have been correct.
109
+ *
110
+ * Do **not** add `aria-busy` here: on a live region it tells assistive tech to withhold
111
+ * updates, which would suppress the very announcement this shape exists to deliver.
112
+ *
113
+ * Exported so the shell's pre-hydration markup is pinnable with `renderToStaticMarkup`
114
+ * (`root.test.tsx`) — the built artefact is the real proof, but nothing else in the
115
+ * node test pattern can reach this render.
116
+ */
117
+ export function SessionLoading() {
118
+ const hydrated = useHydrated();
82
119
  const t = useT();
83
- return (_jsx("div", { className: "grid min-h-dvh place-items-center bg-background", children: _jsx(Text, { size: "sm", tone: "muted", children: t('auth.boot.checkingSession') }) }));
120
+ return (_jsxs("div", { className: "grid min-h-dvh place-items-center bg-background", role: "status", children: [_jsx(Loader2, { className: "size-6 animate-spin text-muted-foreground", "aria-hidden": "true" }), hydrated ? _jsx("span", { className: "sr-only", children: t('auth.boot.checkingSession') }) : null] }));
84
121
  }
85
122
  function RootDocument({ children, htmlLang }) {
86
123
  // Dark-first SSR baseline; THEME_INIT_SCRIPT flips the class pre-hydration
@@ -88,6 +125,16 @@ function RootDocument({ children, htmlLang }) {
88
125
  // suppressHydrationWarning: the script intentionally mutates the class before
89
126
  // React hydrates, so a className mismatch on <html> is expected, not a bug.
90
127
  // The app stylesheet is emitted via head().links and rendered by <HeadContent />.
128
+ //
129
+ // EC-523: `lang` is the ONE locale-dependent value that stays in the prerendered
130
+ // shell, and it must. There is no locale-free value for it, and dropping it is a real
131
+ // accessibility regression (a screen reader picks its voice from the document
132
+ // language). It is baked as the build's default locale and flips to the visitor's
133
+ // after hydration — honest at every moment, since EC-513 made it name the language the
134
+ // chrome is actually rendered in. The mismatch it would otherwise raise is covered by
135
+ // the same `suppressHydrationWarning` the theme script needs. Do not "fix" it by
136
+ // hard-coding a value: that trades an attribute that is briefly stale for one that is
137
+ // permanently wrong.
91
138
  return (_jsxs("html", { lang: htmlLang, className: "dark", suppressHydrationWarning: true, children: [_jsxs("head", { children: [_jsx(HeadContent, {}), _jsx("script", { dangerouslySetInnerHTML: { __html: THEME_INIT_SCRIPT } })] }), _jsxs("body", { className: "min-h-screen bg-background font-sans text-foreground antialiased", children: [children, _jsx(Scripts, {})] })] }));
92
139
  }
93
140
  //# sourceMappingURL=root.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"root.js","sourceRoot":"","sources":["../../src/router/root.tsx"],"names":[],"mappings":";AACA,OAAO,EACL,eAAe,EACf,WAAW,EACX,MAAM,EACN,OAAO,EACP,WAAW,GACZ,MAAM,wBAAw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AAC,kEAAkE,aAC/E,QAAQ,EACT,KAAC,OAAO,KAAG,IACN,IACF,CACR,CAAA;AACH,CAAC","sourcesContent":["import type { ReactNode } from 'react'\nimport {\n createRootRoute,\n HeadContent,\n Outlet,\n Scripts,\n useLocation,\n} from '@tanstack/react-router'\nimport { NavigateOnce } from './navigate-once'\nimport { AuthProvider, useAuth } from '@elytracms/studio/components/auth-context'\nimport { DeploymentSetupGate } from '@elytracms/studio/components/deployment-setup-gate'\nimport { SessionExpiredOverlay } from '@elytracms/studio/components/session-expired-overlay'\nimport { StudioProvider } from '@elytracms/studio/components/studio-context'\nimport { ThemeProvider } from '@elytracms/studio/components/theme-context'\nimport { Text } from '@elytracms/studio/ui'\nimport { SIGN_IN_PATH, resolveRouteGuard } from '@elytracms/studio/lib/auth'\nimport { useT } from '@elytracms/studio/lib/i18n'\nimport { setStudioBaseTitle } from '@elytracms/studio/lib/tab-title'\nimport { activeSlugForLocation, setActiveProjectSlug } from '@elytracms/studio/lib/workspace'\nimport { THEME_INIT_SCRIPT } from '@elytracms/studio/lib/theme'\n\n/**\n * Studio root-route boot factory (EC-375; consolidated from the copy-pasted\n * consumer `__root.tsx` by EC-369 finding #7). It assembles the ONE canonical\n * provider/gate stack — ThemeProvider → DeploymentSetupGate → AuthProvider(keyed)\n * → AuthGate → StudioProvider → Outlet — plus the `RootDocument` shell\n * (html/head with the pre-hydration theme script + the chrome stylesheet).\n *\n * Its whole purpose is to make the NEXT required-gate addition automatic on\n * package upgrade: when EC-258 added `DeploymentSetupGate`, every hand-copied\n * `__root.tsx` had to be manually re-synced, and Konditorei's silently missed\n * it for five releases (EC-367). Owning the composition here means a consumer's\n * `__root.tsx` shrinks to a thin shell and picks up new gates for free.\n *\n * The consumer re-exports the returned route as `Route` (the generated route\n * tree imports `Route` from `./routes/__root`):\n *\n * ```tsx\n * import { createStudioRootRoute } from '@elytracms/studio/router/root'\n * import appCss from '../styles/app.css?url'\n * export const Route = createStudioRootRoute({ appCssUrl: appCss })\n * ```\n */\nexport interface StudioRootRouteOptions {\n /**\n * URL of the studio chrome stylesheet, from the consumer's Vite `?url` import\n * (`import appCss from '../styles/app.css?url'`). The one option every consumer\n * must pass — the sheet is project-owned (it carries the delivery theme).\n */\n appCssUrl: string\n /** Document `<title>`. Default: `'Elytra'`. */\n title?: string\n /** `<html lang>`. Default: `'en'`. */\n htmlLang?: string\n /**\n * Extra `<head>` meta entries appended after the defaults (charset, viewport,\n * title). Same shape TanStack Router's `head().meta` takes.\n */\n meta?: Array<Record<string, string>>\n /** Extra `<head>` link entries appended after the app stylesheet. */\n links?: Array<Record<string, string>>\n /**\n * Escape hatch: wrap additional project-specific providers around the routed\n * subtree. Rendered INSIDE `StudioProvider` and around `<Outlet />`, so nested\n * providers see the full studio/auth/theme context and remount with the active\n * project. Return the passed `children` wrapped in your providers.\n */\n providers?: (children: ReactNode) => ReactNode\n}\n\nexport function createStudioRootRoute(options: StudioRootRouteOptions) {\n const { appCssUrl, title = 'Elytra', htmlLang = 'en', meta = [], links = [], providers } = options\n\n // EC-402: register the base title for the shell's per-view tab-title effect\n // (`StudioTabTitle` composes `deepest crumb · view · project · <this title>`\n // and restores exactly this value when leaving a project view). Module-holder\n // seam — same pattern as `setActiveProjectSlug` — so the shell never has to\n // capture `document.title` and race the router's own head effect.\n setStudioBaseTitle(title)\n\n function RootComponent() {\n const location = useLocation()\n // EC-179: the active project selects its Convex backend. Resolve it from the\n // URL (or the sign-in redirect target) and bind it *before* the auth and\n // persistence adapters are selected, so the initial sign-in authenticates\n // against the project the user is heading for. Keying the auth/studio subtree\n // by the active project remounts it on a project switch, so the adapters\n // re-select against the new backend and the session is restored per-backend.\n const activeSlug = activeSlugForLocation(\n location.pathname,\n (location.search as { redirect?: string }).redirect,\n )\n setActiveProjectSlug(activeSlug)\n\n return (\n <RootDocument htmlLang={htmlLang}>\n <ThemeProvider>\n {/* EC-258: one deployment-setup gate runs before auth — a misconfigured or\n unreachable backend, an invalid workspace config, or any failing readiness\n precondition (missing auth signing key, required collections, …) is a\n single visible boot screen with copy-pasteable fixes, never a silent\n in-memory fallback or a misleading downstream error. All checks passing\n renders children as before. */}\n <DeploymentSetupGate>\n <AuthProvider key={activeSlug ?? '__launcher__'}>\n <AuthGate>\n <StudioProvider>\n {providers ? providers(<Outlet />) : <Outlet />}\n {/* EC-403: the blocking in-place re-auth overlay — mounted over\n every route, INSIDE StudioProvider (it invalidates the studio\n query cache on re-auth) and inside AuthProvider (it reads the\n sessionExpired state). Renders null unless the session died. */}\n <SessionExpiredOverlay />\n </StudioProvider>\n </AuthGate>\n </AuthProvider>\n </DeploymentSetupGate>\n </ThemeProvider>\n </RootDocument>\n )\n }\n\n return createRootRoute({\n head: () => ({\n meta: [\n { charSet: 'utf-8' },\n { name: 'viewport', content: 'width=device-width, initial-scale=1' },\n { title },\n ...meta,\n ],\n links: [{ rel: 'stylesheet', href: appCssUrl }, ...links],\n }),\n component: RootComponent,\n })\n}\n\n/**\n * Route guard (EC-150): one chokepoint in the root layout. Unauthenticated\n * visitors on protected paths are redirected to the sign-in screen (with the\n * intended target preserved); signed-in users never see the sign-in screen.\n * The decision logic is the pure, unit-tested `resolveRouteGuard`.\n */\nfunction AuthGate({ children }: { children: ReactNode }) {\n const { status } = useAuth()\n const location = useLocation()\n // EC-451: feed the still-pending `?redirect` search param into the decision.\n // Dev auto-login (or any fast real sign-in — SSO return, password-manager\n // autofill) can flip the session to signed-in while the location is still\n // `/sign-in?redirect=…`, BEFORE `SignInView`'s own post-sign-in navigation\n // runs; the gate's bounce then fires first and must consume the target\n // instead of dropping it on an unconditional `/`. The target is validated\n // by `postSignInTarget` inside `resolveRouteGuard` (same-origin relative\n // paths only — redirect is an attacker-suppliable search param).\n const rawRedirect = (location.search as { redirect?: unknown }).redirect\n const redirect = typeof rawRedirect === 'string' ? rawRedirect : undefined\n const decision = resolveRouteGuard(location.pathname, status, redirect)\n\n if (decision.kind === 'pending') return <SessionLoading />\n if (decision.kind === 'redirect-to-sign-in') {\n // EC-441: `NavigateOnce`, not `<Navigate>` — the gate stays mounted while\n // the sign-in transition is pending, and a per-render re-navigate spirals\n // into the router's update-depth rejection.\n return <NavigateOnce to={SIGN_IN_PATH} search={{ redirect: decision.redirect }} replace />\n }\n if (decision.kind === 'redirect-home') return <NavigateOnce to={decision.target} replace />\n return children\n}\n\n/** Deterministic session-restore state (also the SSR output for protected paths). */\nfunction SessionLoading() {\n const t = useT()\n return (\n <div className=\"grid min-h-dvh place-items-center bg-background\">\n <Text size=\"sm\" tone=\"muted\">\n {t('auth.boot.checkingSession')}\n </Text>\n </div>\n )\n}\n\nfunction RootDocument({ children, htmlLang }: { children: ReactNode; htmlLang: string }) {\n // Dark-first SSR baseline; THEME_INIT_SCRIPT flips the class pre-hydration\n // from the stored preference, and ThemeProvider keeps it reactive thereafter.\n // suppressHydrationWarning: the script intentionally mutates the class before\n // React hydrates, so a className mismatch on <html> is expected, not a bug.\n // The app stylesheet is emitted via head().links and rendered by <HeadContent />.\n return (\n <html lang={htmlLang} className=\"dark\" suppressHydrationWarning>\n <head>\n <HeadContent />\n <script dangerouslySetInnerHTML={{ __html: THEME_INIT_SCRIPT }} />\n </head>\n <body className=\"min-h-screen bg-background font-sans text-foreground antialiased\">\n {children}\n <Scripts />\n </body>\n </html>\n )\n}\n"]}
1
+ {"version":3,"file":"root.js","sourceRoot":"","sources":["../../src/router/root.tsx"],"names":[],"mappings":";AACA,OAAO,EACL,eAAe,EACf,WAAW,EACX,MAAM,EACN,OAAO,EACP,WAAW,GACZ,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,2CAA2C,CAAA;AACjF,OAAO,EAAE,mBAAmB,EAAE,MAAM,oDAAoD,CAAA;AACxF,OAAO,EAAE,qBAAqB,EAAE,MAAM,sDAAsD,CAAA;AAC5F,OAAO,EAAE,cAAc,EAAE,MAAM,6CAA6C,CAAA;AA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sFAAsF;IACtF,qBAAqB;IACrB,OAAO,CACL,gBAAM,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAC,MAAM,EAAC,wBAAwB,mBAC7D,2BACE,KAAC,WAAW,KAAG,EACf,iBAAQ,uBAAuB,EAAE,EAAE,MAAM,EAAE,iBAAiB,EAAE,GAAI,IAC7D,EACP,gBAAM,SAAS,EAAC,kEAAkE,aAC/E,QAAQ,EACT,KAAC,OAAO,KAAG,IACN,IACF,CACR,CAAA;AACH,CAAC","sourcesContent":["import type { ReactNode } from 'react'\nimport {\n createRootRoute,\n HeadContent,\n Outlet,\n Scripts,\n useLocation,\n} from '@tanstack/react-router'\nimport { NavigateOnce } from './navigate-once'\nimport { AuthProvider, useAuth } from '@elytracms/studio/components/auth-context'\nimport { DeploymentSetupGate } from '@elytracms/studio/components/deployment-setup-gate'\nimport { SessionExpiredOverlay } from '@elytracms/studio/components/session-expired-overlay'\nimport { StudioProvider } from '@elytracms/studio/components/studio-context'\nimport { ThemeProvider } from '@elytracms/studio/components/theme-context'\nimport { Loader2 } from 'lucide-react'\nimport { SIGN_IN_PATH, resolveRouteGuard } from '@elytracms/studio/lib/auth'\nimport { useHydrated, useT, useUiLocale } from '@elytracms/studio/lib/i18n'\nimport { setStudioBaseTitle } from '@elytracms/studio/lib/tab-title'\nimport { activeSlugForLocation, setActiveProjectSlug } from '@elytracms/studio/lib/workspace'\nimport { THEME_INIT_SCRIPT } from '@elytracms/studio/lib/theme'\n\n/**\n * Studio root-route boot factory (EC-375; consolidated from the copy-pasted\n * consumer `__root.tsx` by EC-369 finding #7). It assembles the ONE canonical\n * provider/gate stack — ThemeProvider → DeploymentSetupGate → AuthProvider(keyed)\n * → AuthGate → StudioProvider → Outlet — plus the `RootDocument` shell\n * (html/head with the pre-hydration theme script + the chrome stylesheet).\n *\n * Its whole purpose is to make the NEXT required-gate addition automatic on\n * package upgrade: when EC-258 added `DeploymentSetupGate`, every hand-copied\n * `__root.tsx` had to be manually re-synced, and Konditorei's silently missed\n * it for five releases (EC-367). Owning the composition here means a consumer's\n * `__root.tsx` shrinks to a thin shell and picks up new gates for free.\n *\n * The consumer re-exports the returned route as `Route` (the generated route\n * tree imports `Route` from `./routes/__root`):\n *\n * ```tsx\n * import { createStudioRootRoute } from '@elytracms/studio/router/root'\n * import appCss from '../styles/app.css?url'\n * export const Route = createStudioRootRoute({ appCssUrl: appCss })\n * ```\n */\nexport interface StudioRootRouteOptions {\n /**\n * URL of the studio chrome stylesheet, from the consumer's Vite `?url` import\n * (`import appCss from '../styles/app.css?url'`). The one option every consumer\n * must pass — the sheet is project-owned (it carries the delivery theme).\n */\n appCssUrl: string\n /** Document `<title>`. Default: `'Elytra'`. */\n title?: string\n /**\n * `<html lang>`. Defaults to the **resolved studio-UI locale** (EC-513): the\n * config-pinned `i18n.locale` if there is one, otherwise the default locale on the\n * server and, once browser detection takes over after hydration, the visitor's\n * preferred locale. Pass a value only to fix `lang` to something the chrome is not\n * actually rendered in.\n */\n htmlLang?: string\n /**\n * Extra `<head>` meta entries appended after the defaults (charset, viewport,\n * title). Same shape TanStack Router's `head().meta` takes.\n */\n meta?: Array<Record<string, string>>\n /** Extra `<head>` link entries appended after the app stylesheet. */\n links?: Array<Record<string, string>>\n /**\n * Escape hatch: wrap additional project-specific providers around the routed\n * subtree. Rendered INSIDE `StudioProvider` and around `<Outlet />`, so nested\n * providers see the full studio/auth/theme context and remount with the active\n * project. Return the passed `children` wrapped in your providers.\n */\n providers?: (children: ReactNode) => ReactNode\n}\n\nexport function createStudioRootRoute(options: StudioRootRouteOptions) {\n const { appCssUrl, title = 'Elytra', htmlLang, meta = [], links = [], providers } = options\n\n // EC-402: register the base title for the shell's per-view tab-title effect\n // (`StudioTabTitle` composes `deepest crumb · view · project · <this title>`\n // and restores exactly this value when leaving a project view). Module-holder\n // seam — same pattern as `setActiveProjectSlug` — so the shell never has to\n // capture `document.title` and race the router's own head effect.\n setStudioBaseTitle(title)\n\n function RootComponent() {\n const location = useLocation()\n // EC-513: locale resolution is client-side, so the studio boots in the server's\n // locale (default, or the `i18n.locale` pin) and hands over to the browser's\n // preference AFTER hydration — the hydration render has to reproduce the server's\n // markup or React discards the tree with a mismatch error. Subscribing HERE, at the\n // one root above the whole chrome, is what makes the handover visible everywhere:\n // ~948 of the studio's localized render sites call the non-hook `translate()` and\n // would otherwise never re-render for it. It also keeps `<html lang>` honest —\n // it names the language the chrome is actually rendered in, at every moment.\n const uiLocale = useUiLocale()\n // EC-179: the active project selects its Convex backend. Resolve it from the\n // URL (or the sign-in redirect target) and bind it *before* the auth and\n // persistence adapters are selected, so the initial sign-in authenticates\n // against the project the user is heading for. Keying the auth/studio subtree\n // by the active project remounts it on a project switch, so the adapters\n // re-select against the new backend and the session is restored per-backend.\n const activeSlug = activeSlugForLocation(\n location.pathname,\n (location.search as { redirect?: string }).redirect,\n )\n setActiveProjectSlug(activeSlug)\n\n return (\n <RootDocument htmlLang={htmlLang ?? uiLocale}>\n <ThemeProvider>\n {/* EC-258: one deployment-setup gate runs before auth — a misconfigured or\n unreachable backend, an invalid workspace config, or any failing readiness\n precondition (missing auth signing key, required collections, …) is a\n single visible boot screen with copy-pasteable fixes, never a silent\n in-memory fallback or a misleading downstream error. All checks passing\n renders children as before. */}\n <DeploymentSetupGate>\n <AuthProvider key={activeSlug ?? '__launcher__'}>\n <AuthGate>\n <StudioProvider>\n {providers ? providers(<Outlet />) : <Outlet />}\n {/* EC-403: the blocking in-place re-auth overlay — mounted over\n every route, INSIDE StudioProvider (it invalidates the studio\n query cache on re-auth) and inside AuthProvider (it reads the\n sessionExpired state). Renders null unless the session died. */}\n <SessionExpiredOverlay />\n </StudioProvider>\n </AuthGate>\n </AuthProvider>\n </DeploymentSetupGate>\n </ThemeProvider>\n </RootDocument>\n )\n }\n\n return createRootRoute({\n head: () => ({\n meta: [\n { charSet: 'utf-8' },\n { name: 'viewport', content: 'width=device-width, initial-scale=1' },\n { title },\n ...meta,\n ],\n links: [{ rel: 'stylesheet', href: appCssUrl }, ...links],\n }),\n component: RootComponent,\n })\n}\n\n/**\n * Route guard (EC-150): one chokepoint in the root layout. Unauthenticated\n * visitors on protected paths are redirected to the sign-in screen (with the\n * intended target preserved); signed-in users never see the sign-in screen.\n * The decision logic is the pure, unit-tested `resolveRouteGuard`.\n */\nfunction AuthGate({ children }: { children: ReactNode }) {\n const { status } = useAuth()\n const location = useLocation()\n // EC-451: feed the still-pending `?redirect` search param into the decision.\n // Dev auto-login (or any fast real sign-in — SSO return, password-manager\n // autofill) can flip the session to signed-in while the location is still\n // `/sign-in?redirect=…`, BEFORE `SignInView`'s own post-sign-in navigation\n // runs; the gate's bounce then fires first and must consume the target\n // instead of dropping it on an unconditional `/`. The target is validated\n // by `postSignInTarget` inside `resolveRouteGuard` (same-origin relative\n // paths only — redirect is an attacker-suppliable search param).\n const rawRedirect = (location.search as { redirect?: unknown }).redirect\n const redirect = typeof rawRedirect === 'string' ? rawRedirect : undefined\n const decision = resolveRouteGuard(location.pathname, status, redirect)\n\n if (decision.kind === 'pending') return <SessionLoading />\n if (decision.kind === 'redirect-to-sign-in') {\n // EC-441: `NavigateOnce`, not `<Navigate>` — the gate stays mounted while\n // the sign-in transition is pending, and a per-render re-navigate spirals\n // into the router's update-depth rejection.\n return <NavigateOnce to={SIGN_IN_PATH} search={{ redirect: decision.redirect }} replace />\n }\n if (decision.kind === 'redirect-home') return <NavigateOnce to={decision.target} replace />\n return children\n}\n\n/**\n * The studio's boot screen: the deterministic session-restore state and — because a\n * request-less render always finds the auth gate `pending` — the entire body of the\n * build-time prerendered SPA shell (`dist/client/_shell.html`).\n *\n * **It is deliberately wordless** (EC-523; owner-ratified 2026-08-01: *\"remove the text\n * — if we really need something while loading, add a simple spinner, but not mandatory —\n * the shell should stay free of side-effects\"*). A build-time prerender has no request,\n * hence no `Accept-Language` and no session, so it cannot know the visitor's language.\n * EC-513 fixed the one string that flipped after hydration; removing the words removes\n * the possibility of the next one.\n *\n * **Accessibility**, because \"no words\" must not mean \"no accessible name\": moving the\n * text into an `aria-label` bakes the very same wrong-language string into the shell,\n * only somewhere a screen-reader user cannot notice it flip. So the shell ships an\n * **empty** `role=\"status\"` region — the correct live-region shape in any case, since a\n * region must already exist in the DOM for a later insertion to be announced — and\n * `useHydrated` fills it once hydration is done, in the visitor's actual locale. The\n * unannounced window is bounded by hydration, i.e. exactly the window in which no\n * announcement could have been correct.\n *\n * Do **not** add `aria-busy` here: on a live region it tells assistive tech to withhold\n * updates, which would suppress the very announcement this shape exists to deliver.\n *\n * Exported so the shell's pre-hydration markup is pinnable with `renderToStaticMarkup`\n * (`root.test.tsx`) — the built artefact is the real proof, but nothing else in the\n * node test pattern can reach this render.\n */\nexport function SessionLoading() {\n const hydrated = useHydrated()\n const t = useT()\n return (\n <div className=\"grid min-h-dvh place-items-center bg-background\" role=\"status\">\n <Loader2 className=\"size-6 animate-spin text-muted-foreground\" aria-hidden=\"true\" />\n {hydrated ? <span className=\"sr-only\">{t('auth.boot.checkingSession')}</span> : null}\n </div>\n )\n}\n\nfunction RootDocument({ children, htmlLang }: { children: ReactNode; htmlLang: string }) {\n // Dark-first SSR baseline; THEME_INIT_SCRIPT flips the class pre-hydration\n // from the stored preference, and ThemeProvider keeps it reactive thereafter.\n // suppressHydrationWarning: the script intentionally mutates the class before\n // React hydrates, so a className mismatch on <html> is expected, not a bug.\n // The app stylesheet is emitted via head().links and rendered by <HeadContent />.\n //\n // EC-523: `lang` is the ONE locale-dependent value that stays in the prerendered\n // shell, and it must. There is no locale-free value for it, and dropping it is a real\n // accessibility regression (a screen reader picks its voice from the document\n // language). It is baked as the build's default locale and flips to the visitor's\n // after hydration — honest at every moment, since EC-513 made it name the language the\n // chrome is actually rendered in. The mismatch it would otherwise raise is covered by\n // the same `suppressHydrationWarning` the theme script needs. Do not \"fix\" it by\n // hard-coding a value: that trades an attribute that is briefly stale for one that is\n // permanently wrong.\n return (\n <html lang={htmlLang} className=\"dark\" suppressHydrationWarning>\n <head>\n <HeadContent />\n <script dangerouslySetInnerHTML={{ __html: THEME_INIT_SCRIPT }} />\n </head>\n <body className=\"min-h-screen bg-background font-sans text-foreground antialiased\">\n {children}\n <Scripts />\n </body>\n </html>\n )\n}\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@elytracms/studio",
3
3
  "author": "finaldream <hi@finaldream.de>",
4
- "version": "0.0.80",
4
+ "version": "0.0.82",
5
5
  "private": false,
6
6
  "description": "The Elytra studio engine (UI + lib + routes + data-only Convex schema) as an importable package. Extraction staged in EXTRACTION.md (EC-223); Stages 1-2 = UI primitives + router-free lib leaves.",
7
7
  "license": "MIT",
@@ -150,7 +150,7 @@
150
150
  "lucide-react": "^1.23.0",
151
151
  "tailwind-merge": "^3.6.0",
152
152
  "zod": "^4.4.3",
153
- "@elytracms/core": "^0.0.80"
153
+ "@elytracms/core": "^0.0.82"
154
154
  },
155
155
  "peerDependencies": {
156
156
  "@tanstack/react-router": "^1.170.0",