@elytracms/studio 0.0.15 → 0.0.16

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 (69) hide show
  1. package/dist/components/app-views/default-modules.d.ts +41 -0
  2. package/dist/components/app-views/default-modules.js +201 -0
  3. package/dist/components/app-views/default-modules.js.map +1 -0
  4. package/dist/components/app-views/module.d.ts +93 -0
  5. package/dist/components/app-views/module.js +75 -0
  6. package/dist/components/app-views/module.js.map +1 -0
  7. package/dist/components/app-views/sidebar.d.ts +95 -0
  8. package/dist/components/app-views/sidebar.js +153 -0
  9. package/dist/components/app-views/sidebar.js.map +1 -0
  10. package/dist/components/builder/builder-store.d.ts +7 -1
  11. package/dist/components/builder/builder-store.js +1 -1
  12. package/dist/components/builder/builder-store.js.map +1 -1
  13. package/dist/components/builder/canvas-breakpoints.d.ts +53 -0
  14. package/dist/components/builder/canvas-breakpoints.js +55 -0
  15. package/dist/components/builder/canvas-breakpoints.js.map +1 -0
  16. package/dist/components/builder/canvas.js +14 -8
  17. package/dist/components/builder/canvas.js.map +1 -1
  18. package/dist/components/builder/composition-field-editor.js +18 -17
  19. package/dist/components/builder/composition-field-editor.js.map +1 -1
  20. package/dist/components/cms/bulk-actions.d.ts +23 -5
  21. package/dist/components/cms/bulk-actions.js +7 -3
  22. package/dist/components/cms/bulk-actions.js.map +1 -1
  23. package/dist/components/cms/bulk-bar.d.ts +22 -6
  24. package/dist/components/cms/bulk-bar.js +46 -9
  25. package/dist/components/cms/bulk-bar.js.map +1 -1
  26. package/dist/components/cms/cms-index.d.ts +4 -2
  27. package/dist/components/cms/cms-index.js +6 -4
  28. package/dist/components/cms/cms-index.js.map +1 -1
  29. package/dist/components/cms/cms-store.d.ts +6 -5
  30. package/dist/components/cms/cms-store.js +51 -9
  31. package/dist/components/cms/cms-store.js.map +1 -1
  32. package/dist/components/cms/collection-table.js +7 -3
  33. package/dist/components/cms/collection-table.js.map +1 -1
  34. package/dist/components/cms/collections-sidebar.d.ts +10 -1
  35. package/dist/components/cms/collections-sidebar.js +13 -2
  36. package/dist/components/cms/collections-sidebar.js.map +1 -1
  37. package/dist/components/cms/field-control.d.ts +11 -2
  38. package/dist/components/cms/field-control.js +22 -1
  39. package/dist/components/cms/field-control.js.map +1 -1
  40. package/dist/components/cms/field-renderer.d.ts +71 -0
  41. package/dist/components/cms/field-renderer.js +67 -0
  42. package/dist/components/cms/field-renderer.js.map +1 -0
  43. package/dist/components/cms/filter-builder.js +6 -28
  44. package/dist/components/cms/filter-builder.js.map +1 -1
  45. package/dist/components/cms/scalar-value-editor.d.ts +35 -0
  46. package/dist/components/cms/scalar-value-editor.js +43 -0
  47. package/dist/components/cms/scalar-value-editor.js.map +1 -0
  48. package/dist/components/project-session.js +8 -3
  49. package/dist/components/project-session.js.map +1 -1
  50. package/dist/components/section-nav.d.ts +10 -10
  51. package/dist/components/section-nav.js +48 -25
  52. package/dist/components/section-nav.js.map +1 -1
  53. package/dist/components/section-surface.js +2 -3
  54. package/dist/components/section-surface.js.map +1 -1
  55. package/dist/components/studio-project-screen.d.ts +3 -4
  56. package/dist/components/studio-project-screen.js +29 -147
  57. package/dist/components/studio-project-screen.js.map +1 -1
  58. package/dist/components/studio-shell.js +13 -9
  59. package/dist/components/studio-shell.js.map +1 -1
  60. package/dist/lib/data/collection-content.d.ts +19 -1
  61. package/dist/lib/data/collection-content.js +16 -0
  62. package/dist/lib/data/collection-content.js.map +1 -1
  63. package/dist/lib/workspace/index.d.ts +27 -1
  64. package/dist/lib/workspace/index.js +34 -0
  65. package/dist/lib/workspace/index.js.map +1 -1
  66. package/dist/router/match.d.ts +22 -34
  67. package/dist/router/match.js +22 -40
  68. package/dist/router/match.js.map +1 -1
  69. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"collection-content.js","sourceRoot":"","sources":["../../../src/lib/data/collection-content.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,yBA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ms/core/content'\nimport type {\n ContentClient,\n ContentDocumentSource,\n ContentLookup,\n GetDocumentResult,\n ListDocumentsQuery,\n ListDocumentsResult,\n ResolvedDocument,\n} from '@elytracms/core/content'\nimport { documentKey, sampleLocaleConfig } from '@elytracms/core/cms-core'\nimport type {\n CmsDocument,\n CollectionDef,\n DocumentRef,\n Locale,\n LocaleConfig,\n} from '@elytracms/core/cms-core'\nimport type { AssetRecord } from '@elytracms/core/persistence'\nimport type { ListingQuery } from '@elytracms/core/runtime-renderer'\nimport { getStudioLocale } from '../locale/locale-store'\n\n/**\n * The studio's content delivery engine for canvas previews (EC-166).\n *\n * Repeating sections and template pages preview *delivery-shaped* documents —\n * the exact shape `@elytracms/core/content` serves in production — so the canvas\n * shows what publishing will show. This module wires the canonical content\n * client (closed AD-3 query vocabulary, published perspective, EC-018 locale\n * fallback, depth-1 population, resolved assets) over a **content session**:\n *\n * - Playground mode (and tests): the deterministic EC-145 sample fixtures —\n * byte-identical to the pre-hydration behavior, no backend.\n * - Convex mode: the project-session gate (`components/studio/project-session`)\n * configures the session with the project's HYDRATED schema + documents, so\n * \"Preview with\" lists and section previews show the live content — never\n * fixture titles (EC-177 gap 1).\n *\n * Nothing here invents query semantics; both shapes go through the same\n * canonical client.\n */\n\n/** The schema + documents the preview engine serves (one project session). */\nexport interface ContentSessionState {\n collections: readonly CollectionDef[]\n documents: readonly CmsDocument[]\n /**\n * Published document keys via the version POINTER (EC-224). When present, the\n * preview's published perspective resolves by the pin — never the flat\n * `state` enum — so it matches what delivery serves. Absent (playground\n * fixtures / tests) → the rows' own `state` gates the perspective, unchanged.\n */\n publishedKeys?: readonly string[]\n /** Locale config of the session content; defaults to the sample config. */\n localeConfig?: LocaleConfig\n /**\n * The project's asset records (assets table). Wired into the lookup so the\n * content client resolves `asset`-typed FIELDS on listing/relation results\n * (e.g. a ProductGrid product's `gallery`) to delivery shape — the same assets\n * the renderer's `resolveAsset` reads for static props (EC-262). Absent\n * (playground/tests) → assets come only from `asset`-collection fixture docs.\n */\n assets?: readonly AssetRecord[]\n}\n\n/**\n * Default (no-session) collection schema: EMPTY. The studio ships no demo content\n * (Oli, 2026-06-19) — with no backend/content session configured, there is nothing\n * to preview, and the studio says so rather than serving fixtures. A real project's\n * collections + documents arrive via {@link configureContentSession} (Convex mode).\n */\nexport const playgroundCollections: readonly CollectionDef[] = []\n\nlet contentSession: ContentSessionState | null = null\nlet lookup: ContentLookup = createLookup(playgroundCollections, [], [])\nconst clients = new Map<Locale, ContentClient>()\n\n/**\n * Point the preview engine at a project's hydrated content (Convex mode), or\n * back at the deterministic playground fixtures (`null` — the default, and\n * the only state playground mode ever sees).\n */\nexport function configureContentSession(next: ContentSessionState | null): void {\n contentSession = next\n lookup = next\n ? createLookup(next.collections, next.documents, next.publishedKeys, next.assets)\n : createLookup(playgroundCollections, [], [])\n clients.clear()\n}\n\n/** Whether a hydrated content session is configured (Convex mode). */\nexport function hasContentSession(): boolean {\n return contentSession !== null\n}\n\n/** The collections the preview engine currently serves (session or fixtures). */\nfunction activeCollections(): readonly CollectionDef[] {\n return contentSession?.collections ?? playgroundCollections\n}\n\nfunction activeLocaleConfig(): LocaleConfig {\n return contentSession?.localeConfig ?? sampleLocaleConfig\n}\n\n/** Resolve a collection in the active content session (fixtures in playground). */\nexport function playgroundCollection(id: string): CollectionDef | undefined {\n return activeCollections().find((collection) => collection.id === id)\n}\n\n/**\n * Overlay the active session's canonical `filterable` declarations onto a\n * schema that doesn't carry any of its own. The inspector hands the Content\n * tab fixture collection defs; the filter/sort pickers must offer exactly the\n * EC-143 declaration set the delivery engine enforces, so both ends agree. A\n * collection that declares its own filterable fields is left untouched.\n */\nexport function withPlaygroundFilterable(\n collections: readonly CollectionDef[],\n): readonly CollectionDef[] {\n return collections.map((collection) => {\n if (collection.fields.some((field) => field.filterable === true)) return collection\n const counterpart = playgroundCollection(collection.id)\n if (counterpart === undefined) return collection\n const flagged = new Set(\n counterpart.fields.filter((field) => field.filterable === true).map((field) => field.name),\n )\n if (flagged.size === 0) return collection\n return {\n ...collection,\n fields: collection.fields.map((field) =>\n flagged.has(field.name) ? { ...field, filterable: true } : field,\n ),\n }\n })\n}\n\n/** Synthesize the persistence-shaped asset record the asset resolver reads. */\nfunction assetRecordOf(doc: CmsDocument): AssetRecord {\n const values = doc.values\n const alt = doc.localized?.en?.alt\n return {\n id: doc.id,\n projectId: 'playground',\n filename: typeof values.filename === 'string' ? values.filename : doc.id,\n contentType: 'image/png',\n byteSize: 0,\n alt: typeof alt === 'string' ? alt : undefined,\n storageKey: typeof values.url === 'string' ? values.url : doc.id,\n createdAt: '2026-01-01T00:00:00.000Z',\n updatedAt: '2026-01-01T00:00:00.000Z',\n }\n}\n\nfunction createLookup(\n collectionDefs: readonly CollectionDef[],\n documents: readonly CmsDocument[],\n publishedKeys?: readonly string[],\n assetRecords?: readonly AssetRecord[],\n): ContentLookup {\n const collections = new Map(collectionDefs.map((c) => [c.id, c]))\n // EC-224: published-ness is the version POINTER, not the flat `state` enum.\n // A hydrated session hands `publishedKeys` (the pinned set) → wrap each row as\n // a `DocumentHistory` so the published perspective resolves by the pin (the\n // live row is always a draft now) with ZERO dependence on `state`. Without a\n // pointer set (playground fixtures / tests) we keep bare rows, whose own\n // `state` gates the published perspective — byte-identical to before.\n const published = publishedKeys ? new Set(publishedKeys) : null\n const toSource = (doc: CmsDocument): ContentDocumentSource => {\n if (!published) return doc\n return published.has(documentKey({ collection: doc.collection, id: doc.id }))\n ? { draft: doc, published: doc, versions: [] }\n : { draft: doc, published: undefined, versions: [] }\n }\n const byKey = new Map(\n documents.map((doc) => [`${doc.collection}:${doc.id}`, toSource(doc)] as const),\n )\n // Asset resolution source for `asset`-typed FIELDS on resolved documents\n // (listing/relation results, e.g. a product's `gallery`). Two sources, real\n // records last so they win: (1) `asset`-collection fixture documents — how\n // playground/tests model assets; (2) the project's real asset-table records\n // (EC-262) — a Convex session has its assets here, NOT as `asset` documents,\n // so without these the content client resolves no nested image.\n const assets = new Map<string, AssetRecord>()\n for (const doc of documents) {\n if (doc.collection === 'asset') assets.set(doc.id, assetRecordOf(doc))\n }\n for (const record of assetRecords ?? []) assets.set(record.id, record)\n return {\n collection: (id) => collections.get(id),\n document: (ref) => byKey.get(`${ref.collection}:${ref.id}`),\n documents: (collectionId) =>\n documents.filter((doc) => doc.collection === collectionId).map(toSource),\n asset: (id) => assets.get(id),\n // Prefer the record's resolved servable `url` — the one the renderer's\n // resolveAsset reads (EC-262). Real asset-table records carry a Convex blob\n // locator in `storageKey` and the servable URL in `url`; fixture/`asset`-document\n // records (assetRecordOf) leave `url` unset and store the servable url in\n // `storageKey`. Falling back keeps both correct.\n assetUrl: (asset) => asset.url ?? asset.storageKey,\n }\n}\n\n/**\n * One deterministic client per locale: published perspective, EC-018 locale\n * fallback. The studio's ambient active locale (EC-176, `lib/locale`) picks\n * the client at query time, so the canvas previews follow the locale switcher\n * exactly like delivery would. The cache resets whenever the content session changes.\n */\nfunction clientFor(locale: Locale): ContentClient {\n const existing = clients.get(locale)\n if (existing) return existing\n const client = createContentClient({\n lookup,\n context: createContentContext({\n locale,\n perspective: 'published',\n locales: activeLocaleConfig(),\n }),\n })\n clients.set(locale, client)\n return client\n}\n\n/**\n * Run a closed-vocabulary list query (AD-3: eq/in/lt/lte/gt/gte, AND-only,\n * filterable fields only) and return the delivery-shaped result. Invalid\n * queries come back as structured errors — never thrown, never silently\n * widened. Resolves in the studio's active locale unless one is passed.\n */\nexport function runCollectionListQuery(\n collectionId: string,\n query: ListDocumentsQuery = {},\n locale: Locale = getStudioLocale(),\n): ListDocumentsResult {\n return clientFor(locale).listDocuments(collectionId, query)\n}\n\n/** Resolve one document (by id or slug) into delivery shape. */\nexport function getCollectionDocument(\n collectionId: string,\n idOrSlug: string,\n locale: Locale = getStudioLocale(),\n): GetDocumentResult {\n return clientFor(locale).getDocument(collectionId, idOrSlug)\n}\n\n/**\n * Populate a composition-node `relation` prop to delivery shape for the canvas\n * (EC-254) — the studio analog of the host's baked relations map. Resolves the\n * ref through the active session's client (published perspective, active locale),\n * so the canvas previews a block's picked documents (a ProductGrid's products, a\n * Reusable's element) exactly as delivery renders them. `null` when the target is\n * missing or not visible → the block degrades to its own empty state.\n */\nexport function resolveCanvasRelation(\n ref: DocumentRef,\n locale: Locale = getStudioLocale(),\n): ResolvedDocument | null {\n return clientFor(locale).resolveRelation(ref)\n}\n\n/**\n * Resolve a listing block's query to its documents for the canvas (EC-255) — the\n * studio analog of the host's baked listings map. Runs the query (collection +\n * AND-only filter, optional sort/limit) through the active session's client\n * (published perspective, active locale), so the canvas previews a dynamic grid (a\n * ProductGrid keyed to a category) exactly as delivery renders it. An invalid query\n * (structured, never thrown) or a non-list lookup yields `[]` → the block's empty\n * state. Reuses the same `listDocuments` path as `runCollectionListQuery`.\n */\nexport function resolveCanvasListing(\n query: ListingQuery,\n locale: Locale = getStudioLocale(),\n): ResolvedDocument[] {\n const result = clientFor(locale).listDocuments(query.collection, {\n where: query.where,\n ...(query.sort ? { sort: query.sort } : {}),\n ...(query.limit !== undefined ? { limit: query.limit } : {}),\n })\n return result.ok ? result.documents : []\n}\n\n/** A pickable entry of a collection (the template-page preview switcher). */\nexport interface CollectionEntrySummary {\n id: string\n label: string\n}\n\n/** Published entries of a collection, labeled by the schema's title field. */\nexport function listCollectionEntries(collectionId: string): CollectionEntrySummary[] {\n const collection = playgroundCollection(collectionId)\n const result = runCollectionListQuery(collectionId)\n if (!result.ok) return []\n return result.documents.map((doc) => {\n const title = collection?.titleField ? doc[collection.titleField] : undefined\n return { id: doc.id, label: typeof title === 'string' && title.length > 0 ? title : doc.id }\n })\n}\n"]}
1
+ {"version":3,"file":"collection-content.js","sourceRoot":"","sources":["../../../src/lib/data/collection-content.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,yBAAyB,CAAA;AAUhC,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAW1E,OAAO,EAAE,eAAe,EA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G,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAA;IAC9F,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {\n createContentClient,\n createContentContext,\n} from '@elytracms/core/content'\nimport type {\n ContentClient,\n ContentDocumentSource,\n ContentLookup,\n GetDocumentResult,\n ListDocumentsQuery,\n ListDocumentsResult,\n ResolvedDocument,\n} from '@elytracms/core/content'\nimport { documentKey, sampleLocaleConfig } from '@elytracms/core/cms-core'\nimport type {\n CmsDocument,\n CollectionDef,\n DocumentRef,\n Locale,\n LocaleConfig,\n RouteRecord,\n} from '@elytracms/core/cms-core'\nimport type { AssetRecord } from '@elytracms/core/persistence'\nimport type { ListingQuery } from '@elytracms/core/runtime-renderer'\nimport { getStudioLocale } from '../locale/locale-store'\n\n/**\n * The studio's content delivery engine for canvas previews (EC-166).\n *\n * Repeating sections and template pages preview *delivery-shaped* documents —\n * the exact shape `@elytracms/core/content` serves in production — so the canvas\n * shows what publishing will show. This module wires the canonical content\n * client (closed AD-3 query vocabulary, published perspective, EC-018 locale\n * fallback, depth-1 population, resolved assets) over a **content session**:\n *\n * - Playground mode (and tests): the deterministic EC-145 sample fixtures —\n * byte-identical to the pre-hydration behavior, no backend.\n * - Convex mode: the project-session gate (`components/studio/project-session`)\n * configures the session with the project's HYDRATED schema + documents, so\n * \"Preview with\" lists and section previews show the live content — never\n * fixture titles (EC-177 gap 1).\n *\n * Nothing here invents query semantics; both shapes go through the same\n * canonical client.\n */\n\n/** The schema + documents the preview engine serves (one project session). */\nexport interface ContentSessionState {\n collections: readonly CollectionDef[]\n documents: readonly CmsDocument[]\n /**\n * Published document keys via the version POINTER (EC-224). When present, the\n * preview's published perspective resolves by the pin — never the flat\n * `state` enum — so it matches what delivery serves. Absent (playground\n * fixtures / tests) → the rows' own `state` gates the perspective, unchanged.\n */\n publishedKeys?: readonly string[]\n /** Locale config of the session content; defaults to the sample config. */\n localeConfig?: LocaleConfig\n /**\n * The project's config-sourced routes (EC-207). Wired into the content client so\n * the canvas preview's `resolveLink` (EC-291) derives a rich-text link's URL from\n * the SAME routes delivery serves — the studio-live half of the host link bake.\n * Absent (playground/tests) → no routes, so `resolveLink` returns null and a\n * reference link degrades to the visible `unresolved-ref` issue.\n */\n routes?: readonly RouteRecord[]\n /**\n * The project's asset records (assets table). Wired into the lookup so the\n * content client resolves `asset`-typed FIELDS on listing/relation results\n * (e.g. a ProductGrid product's `gallery`) to delivery shape — the same assets\n * the renderer's `resolveAsset` reads for static props (EC-262). Absent\n * (playground/tests) → assets come only from `asset`-collection fixture docs.\n */\n assets?: readonly AssetRecord[]\n}\n\n/**\n * Default (no-session) collection schema: EMPTY. The studio ships no demo content\n * (Oli, 2026-06-19) — with no backend/content session configured, there is nothing\n * to preview, and the studio says so rather than serving fixtures. A real project's\n * collections + documents arrive via {@link configureContentSession} (Convex mode).\n */\nexport const playgroundCollections: readonly CollectionDef[] = []\n\nlet contentSession: ContentSessionState | null = null\nlet lookup: ContentLookup = createLookup(playgroundCollections, [], [])\nconst clients = new Map<Locale, ContentClient>()\n\n/**\n * Point the preview engine at a project's hydrated content (Convex mode), or\n * back at the deterministic playground fixtures (`null` — the default, and\n * the only state playground mode ever sees).\n */\nexport function configureContentSession(next: ContentSessionState | null): void {\n contentSession = next\n lookup = next\n ? createLookup(next.collections, next.documents, next.publishedKeys, next.assets)\n : createLookup(playgroundCollections, [], [])\n clients.clear()\n}\n\n/** Whether a hydrated content session is configured (Convex mode). */\nexport function hasContentSession(): boolean {\n return contentSession !== null\n}\n\n/** The collections the preview engine currently serves (session or fixtures). */\nfunction activeCollections(): readonly CollectionDef[] {\n return contentSession?.collections ?? playgroundCollections\n}\n\nfunction activeLocaleConfig(): LocaleConfig {\n return contentSession?.localeConfig ?? sampleLocaleConfig\n}\n\n/** Resolve a collection in the active content session (fixtures in playground). */\nexport function playgroundCollection(id: string): CollectionDef | undefined {\n return activeCollections().find((collection) => collection.id === id)\n}\n\n/**\n * Overlay the active session's canonical `filterable` declarations onto a\n * schema that doesn't carry any of its own. The inspector hands the Content\n * tab fixture collection defs; the filter/sort pickers must offer exactly the\n * EC-143 declaration set the delivery engine enforces, so both ends agree. A\n * collection that declares its own filterable fields is left untouched.\n */\nexport function withPlaygroundFilterable(\n collections: readonly CollectionDef[],\n): readonly CollectionDef[] {\n return collections.map((collection) => {\n if (collection.fields.some((field) => field.filterable === true)) return collection\n const counterpart = playgroundCollection(collection.id)\n if (counterpart === undefined) return collection\n const flagged = new Set(\n counterpart.fields.filter((field) => field.filterable === true).map((field) => field.name),\n )\n if (flagged.size === 0) return collection\n return {\n ...collection,\n fields: collection.fields.map((field) =>\n flagged.has(field.name) ? { ...field, filterable: true } : field,\n ),\n }\n })\n}\n\n/** Synthesize the persistence-shaped asset record the asset resolver reads. */\nfunction assetRecordOf(doc: CmsDocument): AssetRecord {\n const values = doc.values\n const alt = doc.localized?.en?.alt\n return {\n id: doc.id,\n projectId: 'playground',\n filename: typeof values.filename === 'string' ? values.filename : doc.id,\n contentType: 'image/png',\n byteSize: 0,\n alt: typeof alt === 'string' ? alt : undefined,\n storageKey: typeof values.url === 'string' ? values.url : doc.id,\n createdAt: '2026-01-01T00:00:00.000Z',\n updatedAt: '2026-01-01T00:00:00.000Z',\n }\n}\n\nfunction createLookup(\n collectionDefs: readonly CollectionDef[],\n documents: readonly CmsDocument[],\n publishedKeys?: readonly string[],\n assetRecords?: readonly AssetRecord[],\n): ContentLookup {\n const collections = new Map(collectionDefs.map((c) => [c.id, c]))\n // EC-224: published-ness is the version POINTER, not the flat `state` enum.\n // A hydrated session hands `publishedKeys` (the pinned set) → wrap each row as\n // a `DocumentHistory` so the published perspective resolves by the pin (the\n // live row is always a draft now) with ZERO dependence on `state`. Without a\n // pointer set (playground fixtures / tests) we keep bare rows, whose own\n // `state` gates the published perspective — byte-identical to before.\n const published = publishedKeys ? new Set(publishedKeys) : null\n const toSource = (doc: CmsDocument): ContentDocumentSource => {\n if (!published) return doc\n return published.has(documentKey({ collection: doc.collection, id: doc.id }))\n ? { draft: doc, published: doc, versions: [] }\n : { draft: doc, published: undefined, versions: [] }\n }\n const byKey = new Map(\n documents.map((doc) => [`${doc.collection}:${doc.id}`, toSource(doc)] as const),\n )\n // Asset resolution source for `asset`-typed FIELDS on resolved documents\n // (listing/relation results, e.g. a product's `gallery`). Two sources, real\n // records last so they win: (1) `asset`-collection fixture documents — how\n // playground/tests model assets; (2) the project's real asset-table records\n // (EC-262) — a Convex session has its assets here, NOT as `asset` documents,\n // so without these the content client resolves no nested image.\n const assets = new Map<string, AssetRecord>()\n for (const doc of documents) {\n if (doc.collection === 'asset') assets.set(doc.id, assetRecordOf(doc))\n }\n for (const record of assetRecords ?? []) assets.set(record.id, record)\n return {\n collection: (id) => collections.get(id),\n document: (ref) => byKey.get(`${ref.collection}:${ref.id}`),\n documents: (collectionId) =>\n documents.filter((doc) => doc.collection === collectionId).map(toSource),\n asset: (id) => assets.get(id),\n // Prefer the record's resolved servable `url` — the one the renderer's\n // resolveAsset reads (EC-262). Real asset-table records carry a Convex blob\n // locator in `storageKey` and the servable URL in `url`; fixture/`asset`-document\n // records (assetRecordOf) leave `url` unset and store the servable url in\n // `storageKey`. Falling back keeps both correct.\n assetUrl: (asset) => asset.url ?? asset.storageKey,\n }\n}\n\n/**\n * One deterministic client per locale: published perspective, EC-018 locale\n * fallback. The studio's ambient active locale (EC-176, `lib/locale`) picks\n * the client at query time, so the canvas previews follow the locale switcher\n * exactly like delivery would. The cache resets whenever the content session changes.\n */\nfunction clientFor(locale: Locale): ContentClient {\n const existing = clients.get(locale)\n if (existing) return existing\n const client = createContentClient({\n lookup,\n context: createContentContext({\n locale,\n perspective: 'published',\n locales: activeLocaleConfig(),\n }),\n // EC-291: the routes a rich-text link resolves against (config-sourced). The\n // canvas previews PUBLISHED content, so a link derives the live URL — matching\n // the host's baked link map.\n routes: contentSession?.routes ?? [],\n })\n clients.set(locale, client)\n return client\n}\n\n/**\n * Run a closed-vocabulary list query (AD-3: eq/in/lt/lte/gt/gte, AND-only,\n * filterable fields only) and return the delivery-shaped result. Invalid\n * queries come back as structured errors — never thrown, never silently\n * widened. Resolves in the studio's active locale unless one is passed.\n */\nexport function runCollectionListQuery(\n collectionId: string,\n query: ListDocumentsQuery = {},\n locale: Locale = getStudioLocale(),\n): ListDocumentsResult {\n return clientFor(locale).listDocuments(collectionId, query)\n}\n\n/** Resolve one document (by id or slug) into delivery shape. */\nexport function getCollectionDocument(\n collectionId: string,\n idOrSlug: string,\n locale: Locale = getStudioLocale(),\n): GetDocumentResult {\n return clientFor(locale).getDocument(collectionId, idOrSlug)\n}\n\n/**\n * Populate a composition-node `relation` prop to delivery shape for the canvas\n * (EC-254) — the studio analog of the host's baked relations map. Resolves the\n * ref through the active session's client (published perspective, active locale),\n * so the canvas previews a block's picked documents (a ProductGrid's products, a\n * Reusable's element) exactly as delivery renders them. `null` when the target is\n * missing or not visible → the block degrades to its own empty state.\n */\nexport function resolveCanvasRelation(\n ref: DocumentRef,\n locale: Locale = getStudioLocale(),\n): ResolvedDocument | null {\n return clientFor(locale).resolveRelation(ref)\n}\n\n/**\n * Resolve a listing block's query to its documents for the canvas (EC-255) — the\n * studio analog of the host's baked listings map. Runs the query (collection +\n * AND-only filter, optional sort/limit) through the active session's client\n * (published perspective, active locale), so the canvas previews a dynamic grid (a\n * ProductGrid keyed to a category) exactly as delivery renders it. An invalid query\n * (structured, never thrown) or a non-list lookup yields `[]` → the block's empty\n * state. Reuses the same `listDocuments` path as `runCollectionListQuery`.\n */\nexport function resolveCanvasListing(\n query: ListingQuery,\n locale: Locale = getStudioLocale(),\n): ResolvedDocument[] {\n const result = clientFor(locale).listDocuments(query.collection, {\n where: query.where,\n ...(query.sort ? { sort: query.sort } : {}),\n ...(query.limit !== undefined ? { limit: query.limit } : {}),\n })\n return result.ok ? result.documents : []\n}\n\n/**\n * Resolve a rich-text internal link's target document to its URL path for the canvas\n * (EC-291) — the studio analog of the host's baked links map. Derives the URL through\n * the active session's client (published perspective, active locale, config-sourced\n * routes), so the canvas previews a `{type:'reference'}` link's `href` exactly as\n * delivery serves it. `null` when the target is unpublished, missing, or addressed by\n * no route → the rich-text renderer shows the EC-290 `unresolved-ref` issue. Reuses\n * the same `resolveLink` path as the host bake, so both agree on the derived URL.\n */\nexport function resolveCanvasLink(\n ref: DocumentRef,\n locale: Locale = getStudioLocale(),\n): string | null {\n return clientFor(locale).resolveLink(ref)\n}\n\n/** A pickable entry of a collection (the template-page preview switcher). */\nexport interface CollectionEntrySummary {\n id: string\n label: string\n}\n\n/** Published entries of a collection, labeled by the schema's title field. */\nexport function listCollectionEntries(collectionId: string): CollectionEntrySummary[] {\n const collection = playgroundCollection(collectionId)\n const result = runCollectionListQuery(collectionId)\n if (!result.ok) return []\n return result.documents.map((doc) => {\n const title = collection?.titleField ? doc[collection.titleField] : undefined\n return { id: doc.id, label: typeof title === 'string' && title.length > 0 ? title : doc.id }\n })\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { ElytraConfigInput } from '@elytracms/core/studio-core';
1
+ import type { AppViewEntry, BreakpointConfig, ElytraConfigInput, FieldRendererEntry, SidebarEntry } from '@elytracms/core/studio-core';
2
2
  import type { CollectionDef, RedirectRecord, RouteRecord } from '@elytracms/core/cms-core';
3
3
  import type { WorkspaceState } from './workspace-source';
4
4
  export { resolveWorkspaceState, WORKSPACE_ENV_VAR } from './workspace-source';
@@ -65,6 +65,32 @@ export declare function resolveDeploymentProjectId(fallbackId: string): string;
65
65
  * studio is wired by env alone with no config.
66
66
  */
67
67
  export declare function resolveDeploymentCollections(): CollectionDef[];
68
+ /**
69
+ * The canvas preview breakpoints of the active config project (EC-250).
70
+ * Config-sourced (config-as-code, derived from the site's Tailwind `screens`);
71
+ * `undefined` when the project declares none — the canvas then falls back to
72
+ * Tailwind's default screens (see `resolveCanvasViewports`), never a baked-in triple.
73
+ */
74
+ export declare function resolveDeploymentBreakpoints(): BreakpointConfig[] | undefined;
75
+ /**
76
+ * The custom field renderers of the active config project (EC-238). Config-sourced
77
+ * live React code (omitted from the serializable projection); `[]` when none — the
78
+ * document editor then uses its built-in control for every field type.
79
+ */
80
+ export declare function resolveDeploymentFieldRenderers(): FieldRendererEntry[];
81
+ /**
82
+ * The custom app-view modules of the active config project (EC-239). Config-sourced
83
+ * live React modules (omitted from the serializable projection); `[]` when none —
84
+ * the studio then mounts only its default module registry (CMS/Routes/Assets/…).
85
+ */
86
+ export declare function resolveDeploymentAppViews(): AppViewEntry[];
87
+ /**
88
+ * The configurable sidebar of the active config project (EC-237). Config-sourced
89
+ * live entries (carry icons; omitted from the projection); `undefined` when the
90
+ * project declares none — the studio then derives the default rail from its module
91
+ * registry (declared-but-invalid entries surface as visible issues, never silent).
92
+ */
93
+ export declare function resolveDeploymentSidebar(): SidebarEntry[] | undefined;
68
94
  /**
69
95
  * The resolved URL routes of the active config project (EC-207, "routes as
70
96
  * code"). Routes are config-sourced: the studio reads the materialized
@@ -147,6 +147,40 @@ export function resolveDeploymentProjectId(fallbackId) {
147
147
  export function resolveDeploymentCollections() {
148
148
  return activeConfigProject()?.collections ?? [];
149
149
  }
150
+ /**
151
+ * The canvas preview breakpoints of the active config project (EC-250).
152
+ * Config-sourced (config-as-code, derived from the site's Tailwind `screens`);
153
+ * `undefined` when the project declares none — the canvas then falls back to
154
+ * Tailwind's default screens (see `resolveCanvasViewports`), never a baked-in triple.
155
+ */
156
+ export function resolveDeploymentBreakpoints() {
157
+ return activeConfigProject()?.breakpoints;
158
+ }
159
+ /**
160
+ * The custom field renderers of the active config project (EC-238). Config-sourced
161
+ * live React code (omitted from the serializable projection); `[]` when none — the
162
+ * document editor then uses its built-in control for every field type.
163
+ */
164
+ export function resolveDeploymentFieldRenderers() {
165
+ return activeConfigProject()?.fieldRenderers ?? [];
166
+ }
167
+ /**
168
+ * The custom app-view modules of the active config project (EC-239). Config-sourced
169
+ * live React modules (omitted from the serializable projection); `[]` when none —
170
+ * the studio then mounts only its default module registry (CMS/Routes/Assets/…).
171
+ */
172
+ export function resolveDeploymentAppViews() {
173
+ return activeConfigProject()?.appViews ?? [];
174
+ }
175
+ /**
176
+ * The configurable sidebar of the active config project (EC-237). Config-sourced
177
+ * live entries (carry icons; omitted from the projection); `undefined` when the
178
+ * project declares none — the studio then derives the default rail from its module
179
+ * registry (declared-but-invalid entries surface as visible issues, never silent).
180
+ */
181
+ export function resolveDeploymentSidebar() {
182
+ return activeConfigProject()?.sidebar;
183
+ }
150
184
  /**
151
185
  * The resolved URL routes of the active config project (EC-207, "routes as
152
186
  * code"). Routes are config-sourced: the studio reads the materialized
@@ -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;AAGvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAG1D,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAE7E,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAGpG,IAAI,MAAM,GAA0B,IAAI,CAAA;AAExC;;;;;;;;GAQG;AACH,MAAM,UAAU,YAAY,CAAC,MAAyB;IACpD,MAAM,GAAG,qBAAqB,CAAC;QAC7B,UAAU,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;QAC/B,QAAQ,EAAE,kBAAkB;KAC7B,CAAC,CAAA;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,IAAI,iBAAiB,GAAkB,IAAI,CAAA;AAE3C,oFAAoF;AACpF,MAAM,UAAU,oBAAoB,CAAC,IAAmB;IACtD,MAAM,MAAM,GAAG,oBAAoB,CAAC,EAAE,CAAC,CAAA;IACvC,iBAAiB,GAAG,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IA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ytraConfigInput, ResolvedWorkspaceProject } from '@elytracms/core/studio-core'\nimport type { CollectionDef, RedirectRecord, RouteRecord } from '@elytracms/core/cms-core'\nimport { resolveWorkspaceState } from './workspace-source'\nimport type { WorkspaceState } from './workspace-source'\n\nexport { resolveWorkspaceState, WORKSPACE_ENV_VAR } from './workspace-source'\nexport type { WorkspaceSources, WorkspaceState } from './workspace-source'\nexport { persistedProjects, selectSwitcherProjects, unprovisionedProjects } from './switcher-source'\nexport type { SwitcherEntry, SwitcherSourceInput } from './switcher-source'\n\nlet cached: WorkspaceState | null = null\n\n/**\n * Mount the studio against a project config (EC-223 mount contract). The\n * consumer's entry point does `import config from './elytra.config'` and calls\n * this — an explicit init, NOT an `import.meta.glob` autoload that reaches into\n * the consumer's filesystem (Oli, 2026-06-19: \"there's always an entry point that\n * can trigger a function call\"). This is the config-injection responsibility of\n * the eventual `createStudio(config)` package export; it seeds the workspace state\n * every later query (`getActiveProjectSlug`, `resolveDeployment*`) reads.\n */\nexport function createStudio(config: ElytraConfigInput): void {\n cached = resolveWorkspaceState({\n fileModule: { default: config },\n fileName: 'elytra.config.ts',\n })\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 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/**\n * The resolved redirects of the active config project (EC-207). Config-sourced\n * exactly like {@link resolveDeploymentRoutes}: the `redirects` system\n * collection is retired and nothing is read from the backend. `[]` when none\n * are declared.\n */\nexport function resolveDeploymentRedirects(): RedirectRecord[] {\n return activeConfigProject()?.redirects ?? []\n}\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 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":["../../../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Entry,\n BreakpointConfig,\n ElytraConfigInput,\n FieldRendererEntry,\n ResolvedWorkspaceProject,\n SidebarEntry,\n} from '@elytracms/core/studio-core'\nimport type { CollectionDef, RedirectRecord, RouteRecord } from '@elytracms/core/cms-core'\nimport { resolveWorkspaceState } from './workspace-source'\nimport type { WorkspaceState } from './workspace-source'\n\nexport { resolveWorkspaceState, WORKSPACE_ENV_VAR } from './workspace-source'\nexport type { WorkspaceSources, WorkspaceState } from './workspace-source'\nexport { persistedProjects, selectSwitcherProjects, unprovisionedProjects } from './switcher-source'\nexport type { SwitcherEntry, SwitcherSourceInput } from './switcher-source'\n\nlet cached: WorkspaceState | null = null\n\n/**\n * Mount the studio against a project config (EC-223 mount contract). The\n * consumer's entry point does `import config from './elytra.config'` and calls\n * this — an explicit init, NOT an `import.meta.glob` autoload that reaches into\n * the consumer's filesystem (Oli, 2026-06-19: \"there's always an entry point that\n * can trigger a function call\"). This is the config-injection responsibility of\n * the eventual `createStudio(config)` package export; it seeds the workspace state\n * every later query (`getActiveProjectSlug`, `resolveDeployment*`) reads.\n */\nexport function createStudio(config: ElytraConfigInput): void {\n cached = resolveWorkspaceState({\n fileModule: { default: config },\n fileName: 'elytra.config.ts',\n })\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 of the active config project (EC-238). Config-sourced\n * live React code (omitted from the serializable projection); `[]` when none — the\n * document editor then uses its built-in control for every field type.\n */\nexport function resolveDeploymentFieldRenderers(): FieldRendererEntry[] {\n return activeConfigProject()?.fieldRenderers ?? []\n}\n\n/**\n * The custom app-view modules of the active config project (EC-239). Config-sourced\n * live React modules (omitted from the serializable projection); `[]` when none —\n * the studio then mounts only its default module registry (CMS/Routes/Assets/…).\n */\nexport function resolveDeploymentAppViews(): AppViewEntry[] {\n return activeConfigProject()?.appViews ?? []\n}\n\n/**\n * The configurable sidebar of the active config project (EC-237). Config-sourced\n * live entries (carry icons; omitted from the projection); `undefined` when the\n * project declares none — the studio then derives the default rail from its module\n * registry (declared-but-invalid entries surface as visible issues, never silent).\n */\nexport function resolveDeploymentSidebar(): SidebarEntry[] | undefined {\n return activeConfigProject()?.sidebar\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/**\n * The resolved redirects of the active config project (EC-207). Config-sourced\n * exactly like {@link resolveDeploymentRoutes}: the `redirects` system\n * collection is retired and nothing is read from the backend. `[]` when none\n * are declared.\n */\nexport function resolveDeploymentRedirects(): RedirectRecord[] {\n return activeConfigProject()?.redirects ?? []\n}\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 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"]}
@@ -10,46 +10,34 @@
10
10
  * pathname string (see `match.test.ts`), satisfying the fixtures-reproducibility
11
11
  * convention without needing a router instance.
12
12
  *
13
- * The shape mirrors the retired file tree:
14
- * /$projectId → { section: 'index' } (redirect to first section)
15
- * /$projectId/settings → { section: 'settings' }
16
- * /$projectId/assets → { section: 'assets' }
17
- * /$projectId/routes → { section: 'routes' }
18
- * /$projectId/extensions → { section: 'extensions' }
19
- * /$projectId/builder → { section: 'builder' } (legacy redirect)
20
- * /$projectId/components → { section: 'components', componentId: null }
21
- * /$projectId/components/:id → { section: 'components', componentId: ':id' }
22
- * /$projectId/cms → { section: 'cms', collectionId: null, documentId: null }
23
- * /$projectId/cms/:c → { section: 'cms', collectionId: ':c', documentId: null }
24
- * /$projectId/cms/:c/:d → { section: 'cms', collectionId: ':c', documentId: ':d' }
25
- * anything else → { section: 'not-found' }
13
+ * EC-239 (app-view modularization): the route table is no longer a hardcoded
14
+ * per-section switch — the studio's surfaces are a config-extendable module
15
+ * registry, so the matcher is now registry-AGNOSTIC. It splits the splat into a
16
+ * module id (the first segment) + that module's trailing segments; the screen
17
+ * resolver looks the id up in the registry and the module's own `parsePath`
18
+ * interprets the segments (CMS: collection/document; components: id; flat: none).
19
+ * Keeping the matcher free of the surface list is what lets a consuming repo add
20
+ * a routable custom module purely from config.
21
+ *
22
+ * /$projectId → { section: 'index' } (redirect to first module)
23
+ * /$projectId/<id> → { section: 'module', moduleId: '<id>', segments: [] }
24
+ * /$projectId/<id>/a/b → { section: 'module', moduleId: '<id>', segments: ['a','b'] }
25
+ *
26
+ * The module decides whether its segments resolve; an unknown id or an
27
+ * over-deep path becomes a not-found at the resolver, not here.
26
28
  */
27
29
  export type StudioRouteMatch = {
28
30
  section: 'index';
29
31
  } | {
30
- section: 'settings';
31
- } | {
32
- section: 'assets';
33
- } | {
34
- section: 'routes';
35
- } | {
36
- section: 'extensions';
37
- } | {
38
- section: 'builder';
39
- } | {
40
- section: 'components';
41
- componentId: string | null;
42
- } | {
43
- section: 'cms';
44
- collectionId: string | null;
45
- documentId: string | null;
46
- } | {
47
- section: 'not-found';
32
+ section: 'module';
33
+ moduleId: string;
34
+ segments: string[];
48
35
  };
49
36
  /**
50
- * Match the trailing pathname of the project splat (`_splat`) against the studio
51
- * route table. `splat` is everything after `/$projectId/` — e.g. `'cms/page/abc'`
52
- * for `/p1/cms/page/abc`. An empty splat is the bare project index.
37
+ * Match the trailing pathname of the project splat (`_splat`) into a module id +
38
+ * its segments. `splat` is everything after `/$projectId/` — e.g. `'cms/page/abc'`
39
+ * for `/p1/cms/page/abc` → `{ moduleId: 'cms', segments: ['page', 'abc'] }`. An
40
+ * empty splat is the bare project index (which redirects to the first module).
53
41
  */
54
42
  export declare function matchStudioRoute(splat: string): StudioRouteMatch;
55
43
  /**
@@ -10,19 +10,21 @@
10
10
  * pathname string (see `match.test.ts`), satisfying the fixtures-reproducibility
11
11
  * convention without needing a router instance.
12
12
  *
13
- * The shape mirrors the retired file tree:
14
- * /$projectId → { section: 'index' } (redirect to first section)
15
- * /$projectId/settings → { section: 'settings' }
16
- * /$projectId/assets → { section: 'assets' }
17
- * /$projectId/routes → { section: 'routes' }
18
- * /$projectId/extensions → { section: 'extensions' }
19
- * /$projectId/builder → { section: 'builder' } (legacy redirect)
20
- * /$projectId/components → { section: 'components', componentId: null }
21
- * /$projectId/components/:id → { section: 'components', componentId: ':id' }
22
- * /$projectId/cms → { section: 'cms', collectionId: null, documentId: null }
23
- * /$projectId/cms/:c → { section: 'cms', collectionId: ':c', documentId: null }
24
- * /$projectId/cms/:c/:d → { section: 'cms', collectionId: ':c', documentId: ':d' }
25
- * anything else → { section: 'not-found' }
13
+ * EC-239 (app-view modularization): the route table is no longer a hardcoded
14
+ * per-section switch — the studio's surfaces are a config-extendable module
15
+ * registry, so the matcher is now registry-AGNOSTIC. It splits the splat into a
16
+ * module id (the first segment) + that module's trailing segments; the screen
17
+ * resolver looks the id up in the registry and the module's own `parsePath`
18
+ * interprets the segments (CMS: collection/document; components: id; flat: none).
19
+ * Keeping the matcher free of the surface list is what lets a consuming repo add
20
+ * a routable custom module purely from config.
21
+ *
22
+ * /$projectId → { section: 'index' } (redirect to first module)
23
+ * /$projectId/<id> → { section: 'module', moduleId: '<id>', segments: [] }
24
+ * /$projectId/<id>/a/b → { section: 'module', moduleId: '<id>', segments: ['a','b'] }
25
+ *
26
+ * The module decides whether its segments resolve; an unknown id or an
27
+ * over-deep path becomes a not-found at the resolver, not here.
26
28
  */
27
29
  /** Split a splat pathname into clean segments (drops empty/leading/trailing slashes). */
28
30
  function segments(splat) {
@@ -32,36 +34,16 @@ function segments(splat) {
32
34
  .filter(Boolean);
33
35
  }
34
36
  /**
35
- * Match the trailing pathname of the project splat (`_splat`) against the studio
36
- * route table. `splat` is everything after `/$projectId/` — e.g. `'cms/page/abc'`
37
- * for `/p1/cms/page/abc`. An empty splat is the bare project index.
37
+ * Match the trailing pathname of the project splat (`_splat`) into a module id +
38
+ * its segments. `splat` is everything after `/$projectId/` — e.g. `'cms/page/abc'`
39
+ * for `/p1/cms/page/abc` → `{ moduleId: 'cms', segments: ['page', 'abc'] }`. An
40
+ * empty splat is the bare project index (which redirects to the first module).
38
41
  */
39
42
  export function matchStudioRoute(splat) {
40
- const [head, a, b, ...rest] = segments(splat);
41
- // Bare `/$projectId` → the project index (redirects to the first section).
42
- if (head === undefined)
43
+ const [moduleId, ...rest] = segments(splat);
44
+ if (moduleId === undefined)
43
45
  return { section: 'index' };
44
- switch (head) {
45
- case 'settings':
46
- case 'assets':
47
- case 'routes':
48
- case 'extensions':
49
- case 'builder':
50
- // Flat sections take no path params; any trailing segment is not a route.
51
- return a === undefined ? { section: head } : { section: 'not-found' };
52
- case 'components':
53
- // `components` (index) or `components/:id` (detail); deeper is not a route.
54
- if (b !== undefined)
55
- return { section: 'not-found' };
56
- return { section: 'components', componentId: a ?? null };
57
- case 'cms':
58
- // `cms` (index) | `cms/:c` (collection) | `cms/:c/:d` (document); deeper is not a route.
59
- if (rest.length > 0)
60
- return { section: 'not-found' };
61
- return { section: 'cms', collectionId: a ?? null, documentId: b ?? null };
62
- default:
63
- return { section: 'not-found' };
64
- }
46
+ return { section: 'module', moduleId, segments: rest };
65
47
  }
66
48
  /**
67
49
  * The inverse of {@link matchStudioRoute}: build the `_splat` subpath for a
@@ -1 +1 @@
1
- {"version":3,"file":"match.js","sourceRoot":"","sources":["../../src/router/match.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAaH,yFAAyF;AACzF,SAAS,QAAQ,CAAC,KAAa;IAC7B,OAAO,KAAK;SACT,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO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EAAE;IACf,QAAQ,EAAE,GAAG,EAAE,CAAC,UAAU;IAC1B,MAAM,EAAE,GAAG,EAAE,CAAC,QAAQ;IACtB,MAAM,EAAE,GAAG,EAAE,CAAC,QAAQ;IACtB,UAAU,EAAE,GAAG,EAAE,CAAC,YAAY;IAC9B,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS;IACxB,UAAU,EAAE,GAAG,EAAE,CAAC,YAAY;IAC9B,SAAS,EAAE,CAAC,WAAmB,EAAE,EAAE,CAAC,cAAc,WAAW,EAAE;IAC/D,GAAG,EAAE,GAAG,EAAE,CAAC,KAAK;IAChB,aAAa,EAAE,CAAC,YAAoB,EAAE,EAAE,CAAC,OAAO,YAAY,EAAE;IAC9D,WAAW,EAAE,CAAC,YAAoB,EAAE,UAAkB,EAAE,EAAE,CACxD,OAAO,YAAY,IAAI,UAAU,EAAE;CAC7B,CAAA","sourcesContent":["/**\n * Studio route table (EC-223 Stage 6 — catch-all routing). The studio mounts as\n * a SINGLE splat route per project (`/$projectId/$`); this pure matcher turns the\n * splat's trailing pathname into a typed match that the screen resolver renders.\n * Keeping the URL→screen map inside the engine (instead of in per-consumer route\n * files) is what lets the package own its navigation with a near-empty consumer\n * route tree — the goal of Stage 6.\n *\n * Deterministic and dependency-free: every screen state is reproducible from a\n * pathname string (see `match.test.ts`), satisfying the fixtures-reproducibility\n * convention without needing a router instance.\n *\n * The shape mirrors the retired file tree:\n * /$projectId → { section: 'index' } (redirect to first section)\n * /$projectId/settings → { section: 'settings' }\n * /$projectId/assets → { section: 'assets' }\n * /$projectId/routes → { section: 'routes' }\n * /$projectId/extensions → { section: 'extensions' }\n * /$projectId/builder → { section: 'builder' } (legacy redirect)\n * /$projectId/components → { section: 'components', componentId: null }\n * /$projectId/components/:id → { section: 'components', componentId: ':id' }\n * /$projectId/cms → { section: 'cms', collectionId: null, documentId: null }\n * /$projectId/cms/:c → { section: 'cms', collectionId: ':c', documentId: null }\n * /$projectId/cms/:c/:d → { section: 'cms', collectionId: ':c', documentId: ':d' }\n * anything else → { section: 'not-found' }\n */\n\nexport type StudioRouteMatch =\n | { section: 'index' }\n | { section: 'settings' }\n | { section: 'assets' }\n | { section: 'routes' }\n | { section: 'extensions' }\n | { section: 'builder' }\n | { section: 'components'; componentId: string | null }\n | { section: 'cms'; collectionId: string | null; documentId: string | null }\n | { section: 'not-found' }\n\n/** Split a splat pathname into clean segments (drops empty/leading/trailing slashes). */\nfunction segments(splat: string): string[] {\n return splat\n .split('/')\n .map((segment) => segment.trim())\n .filter(Boolean)\n}\n\n/**\n * Match the trailing pathname of the project splat (`_splat`) against the studio\n * route table. `splat` is everything after `/$projectId/` — e.g. `'cms/page/abc'`\n * for `/p1/cms/page/abc`. An empty splat is the bare project index.\n */\nexport function matchStudioRoute(splat: string): StudioRouteMatch {\n const [head, a, b, ...rest] = segments(splat)\n\n // Bare `/$projectId` → the project index (redirects to the first section).\n if (head === undefined) return { section: 'index' }\n\n switch (head) {\n case 'settings':\n case 'assets':\n case 'routes':\n case 'extensions':\n case 'builder':\n // Flat sections take no path params; any trailing segment is not a route.\n return a === undefined ? { section: head } : { section: 'not-found' }\n\n case 'components':\n // `components` (index) or `components/:id` (detail); deeper is not a route.\n if (b !== undefined) return { section: 'not-found' }\n return { section: 'components', componentId: a ?? null }\n\n case 'cms':\n // `cms` (index) | `cms/:c` (collection) | `cms/:c/:d` (document); deeper is not a route.\n if (rest.length > 0) return { section: 'not-found' }\n return { section: 'cms', collectionId: a ?? null, documentId: b ?? null }\n\n default:\n return { section: 'not-found' }\n }\n}\n\n/**\n * The inverse of {@link matchStudioRoute}: build the `_splat` subpath for a\n * screen. Navigation addresses the single project splat as\n * `to={STUDIO_PROJECT_ROUTE} params={{ projectId, _splat: studioPath.X(...) }}`,\n * so the URL-construction lives in exactly one place — the same module that\n * parses it back. `matchStudioRoute(studioPath.cmsDocument(c, d))` round-trips\n * (pinned in `match.test.ts`), which is what keeps the two directions in sync.\n */\nexport const studioPath = {\n index: () => '',\n settings: () => 'settings',\n assets: () => 'assets',\n routes: () => 'routes',\n extensions: () => 'extensions',\n builder: () => 'builder',\n components: () => 'components',\n component: (componentId: string) => `components/${componentId}`,\n cms: () => 'cms',\n cmsCollection: (collectionId: string) => `cms/${collectionId}`,\n cmsDocument: (collectionId: string, documentId: string) =>\n `cms/${collectionId}/${documentId}`,\n} as const\n"]}
1
+ {"version":3,"file":"match.js","sourceRoot":"","sources":["../../src/router/match.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAMH,yFAAyF;AACzF,SAAS,QAAQ,CAAC,KAAa;IAC7B,OAAO,KAAK;SACT,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;SAChC,MAAM,CAAC,OAAO,CAAC,CAAA;AACpB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC5C,MAAM,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;IAC3C,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAA;IACvD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAA;AACxD,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,KAAK,EAAE,GAAG,EAAE,CAAC,EAAE;IACf,QAAQ,EAAE,GAAG,EAAE,CAAC,UAAU;IAC1B,MAAM,EAAE,GAAG,EAAE,CAAC,QAAQ;IACtB,MAAM,EAAE,GAAG,EAAE,CAAC,QAAQ;IACtB,UAAU,EAAE,GAAG,EAAE,CAAC,YAAY;IAC9B,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS;IACxB,UAAU,EAAE,GAAG,EAAE,CAAC,YAAY;IAC9B,SAAS,EAAE,CAAC,WAAmB,EAAE,EAAE,CAAC,cAAc,WAAW,EAAE;IAC/D,GAAG,EAAE,GAAG,EAAE,CAAC,KAAK;IAChB,aAAa,EAAE,CAAC,YAAoB,EAAE,EAAE,CAAC,OAAO,YAAY,EAAE;IAC9D,WAAW,EAAE,CAAC,YAAoB,EAAE,UAAkB,EAAE,EAAE,CACxD,OAAO,YAAY,IAAI,UAAU,EAAE;CAC7B,CAAA","sourcesContent":["/**\n * Studio route table (EC-223 Stage 6 — catch-all routing). The studio mounts as\n * a SINGLE splat route per project (`/$projectId/$`); this pure matcher turns the\n * splat's trailing pathname into a typed match that the screen resolver renders.\n * Keeping the URL→screen map inside the engine (instead of in per-consumer route\n * files) is what lets the package own its navigation with a near-empty consumer\n * route tree — the goal of Stage 6.\n *\n * Deterministic and dependency-free: every screen state is reproducible from a\n * pathname string (see `match.test.ts`), satisfying the fixtures-reproducibility\n * convention without needing a router instance.\n *\n * EC-239 (app-view modularization): the route table is no longer a hardcoded\n * per-section switch — the studio's surfaces are a config-extendable module\n * registry, so the matcher is now registry-AGNOSTIC. It splits the splat into a\n * module id (the first segment) + that module's trailing segments; the screen\n * resolver looks the id up in the registry and the module's own `parsePath`\n * interprets the segments (CMS: collection/document; components: id; flat: none).\n * Keeping the matcher free of the surface list is what lets a consuming repo add\n * a routable custom module purely from config.\n *\n * /$projectId → { section: 'index' } (redirect to first module)\n * /$projectId/<id> → { section: 'module', moduleId: '<id>', segments: [] }\n * /$projectId/<id>/a/b → { section: 'module', moduleId: '<id>', segments: ['a','b'] }\n *\n * The module decides whether its segments resolve; an unknown id or an\n * over-deep path becomes a not-found at the resolver, not here.\n */\n\nexport type StudioRouteMatch =\n | { section: 'index' }\n | { section: 'module'; moduleId: string; segments: string[] }\n\n/** Split a splat pathname into clean segments (drops empty/leading/trailing slashes). */\nfunction segments(splat: string): string[] {\n return splat\n .split('/')\n .map((segment) => segment.trim())\n .filter(Boolean)\n}\n\n/**\n * Match the trailing pathname of the project splat (`_splat`) into a module id +\n * its segments. `splat` is everything after `/$projectId/` — e.g. `'cms/page/abc'`\n * for `/p1/cms/page/abc` → `{ moduleId: 'cms', segments: ['page', 'abc'] }`. An\n * empty splat is the bare project index (which redirects to the first module).\n */\nexport function matchStudioRoute(splat: string): StudioRouteMatch {\n const [moduleId, ...rest] = segments(splat)\n if (moduleId === undefined) return { section: 'index' }\n return { section: 'module', moduleId, segments: rest }\n}\n\n/**\n * The inverse of {@link matchStudioRoute}: build the `_splat` subpath for a\n * screen. Navigation addresses the single project splat as\n * `to={STUDIO_PROJECT_ROUTE} params={{ projectId, _splat: studioPath.X(...) }}`,\n * so the URL-construction lives in exactly one place — the same module that\n * parses it back. `matchStudioRoute(studioPath.cmsDocument(c, d))` round-trips\n * (pinned in `match.test.ts`), which is what keeps the two directions in sync.\n */\nexport const studioPath = {\n index: () => '',\n settings: () => 'settings',\n assets: () => 'assets',\n routes: () => 'routes',\n extensions: () => 'extensions',\n builder: () => 'builder',\n components: () => 'components',\n component: (componentId: string) => `components/${componentId}`,\n cms: () => 'cms',\n cmsCollection: (collectionId: string) => `cms/${collectionId}`,\n cmsDocument: (collectionId: string, documentId: string) =>\n `cms/${collectionId}/${documentId}`,\n} as const\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.15",
4
+ "version": "0.0.16",
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",
@@ -113,7 +113,7 @@
113
113
  "lucide-react": "^1.17.0",
114
114
  "tailwind-merge": "^3.6.0",
115
115
  "zod": "^4.0.0",
116
- "@elytracms/core": "^0.0.15"
116
+ "@elytracms/core": "^0.0.16"
117
117
  },
118
118
  "peerDependencies": {
119
119
  "@tanstack/react-router": "^1.170.0",