@phtngyn/cms 0.2.0-beta.7 → 0.2.0-beta.8

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 (55) hide show
  1. package/CHANGELOG.md +1 -0
  2. package/README.md +7 -4
  3. package/package.json +1 -1
  4. package/src/ApplicationTypes.d.ts +1 -1
  5. package/src/{Configuration-Da5B2PVH.js → Configuration-CMweD9bn.js} +2 -2
  6. package/src/{Configuration-Da5B2PVH.js.map → Configuration-CMweD9bn.js.map} +1 -1
  7. package/src/Configuration.d.ts +1 -1
  8. package/src/Content.js +1 -1
  9. package/src/{DocumentEngine-hh_IGPXO.js → DocumentEngine-tYtwbBjr.js} +7 -7
  10. package/src/DocumentEngine-tYtwbBjr.js.map +1 -0
  11. package/src/{HttpPaths-c9nLZ9H2.js → HttpPaths-Be3vshPJ.js} +2 -3
  12. package/src/HttpPaths-Be3vshPJ.js.map +1 -0
  13. package/src/{I18n-zbqpWxki.d.ts → I18n-wxswIRyY.d.ts} +3 -2
  14. package/src/I18n.d.ts +1 -1
  15. package/src/Module.js +1 -12
  16. package/src/Module.js.map +1 -1
  17. package/src/{S3MediaObjects-Dwhl2deX.js → S3MediaObjects-BXfjaZOu.js} +19 -5
  18. package/src/S3MediaObjects-BXfjaZOu.js.map +1 -0
  19. package/src/cli.js +3 -3
  20. package/src/{dev-lifecycle-CjDq63Ft.js → dev-lifecycle-3I_pozUl.js} +4 -4
  21. package/src/{dev-lifecycle-CjDq63Ft.js.map → dev-lifecycle-3I_pozUl.js.map} +1 -1
  22. package/src/{installation-DYNQQBD3.js → installation-DxqSSVbH.js} +8 -17
  23. package/src/installation-DxqSSVbH.js.map +1 -0
  24. package/src/internal/authoring-catalog.js +1 -1
  25. package/src/internal/authoring-metadata.js +1 -1
  26. package/src/internal/configuration.js +1 -1
  27. package/src/internal/dev-lifecycle.js +1 -1
  28. package/src/internal/document-model.js +3 -3
  29. package/src/internal/document-model.js.map +1 -1
  30. package/src/internal/i18n.js +2 -2
  31. package/src/internal/i18n.js.map +1 -1
  32. package/src/internal/studio-app.js +3 -3
  33. package/src/internal/studio-app.js.map +1 -1
  34. package/src/runtime/delivery/plugin.js +7 -2
  35. package/src/runtime/delivery/plugin.js.map +1 -1
  36. package/src/runtime/delivery/useDocument.js +1 -1
  37. package/src/runtime/delivery/useDocumentQuery.js +1 -1
  38. package/src/runtime/forms/useCmsForm.js +1 -1
  39. package/src/runtime/i18n/translator.js +10 -3
  40. package/src/runtime/i18n/translator.js.map +1 -1
  41. package/src/runtime/i18n/useCmsI18n.d.ts +1 -1
  42. package/src/runtime/installation.js +1 -1
  43. package/src/runtime/plugin.js +1 -1
  44. package/src/runtime/sitemap.js +1 -1
  45. package/src/runtime/studio-document.js +2 -2
  46. package/src/runtime/studio-document.js.map +1 -1
  47. package/src/runtime/studio-navigation.js +2 -2
  48. package/src/runtime/studio-navigation.js.map +1 -1
  49. package/studio/{CreateDocumentDialog-BpjBYGfI.js → CreateDocumentDialog-C4_JBo1w.js} +93 -93
  50. package/studio/{SelectMenu-KiXwx4Y_.js → SelectMenu-wXqxymUw.js} +5456 -5443
  51. package/studio/host.js +4775 -4594
  52. package/src/DocumentEngine-hh_IGPXO.js.map +0 -1
  53. package/src/HttpPaths-c9nLZ9H2.js.map +0 -1
  54. package/src/S3MediaObjects-Dwhl2deX.js.map +0 -1
  55. package/src/installation-DYNQQBD3.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { n as formAuthoring } from "../Forms-CX-hwmJF.js";
2
- import { l as validateCollectionBody, n as ComponentDefinition, t as AuthoringCatalog } from "../Configuration-Da5B2PVH.js";
2
+ import { l as validateCollectionBody, n as ComponentDefinition, t as AuthoringCatalog } from "../Configuration-CMweD9bn.js";
3
3
  import { resolveBlockAuthoring } from "./authoring-metadata.js";
4
4
  import { Crypto, Effect, Encoding, FileSystem, Path, Schema } from "effect";
5
5
  import { addTemplate, addVitePlugin, updateTemplates } from "@nuxt/kit";
@@ -1,4 +1,4 @@
1
- import { a as BlockAuthoring, c as parseAuthoringContent, n as ComponentDefinition, s as createAuthoringSchema } from "../Configuration-Da5B2PVH.js";
1
+ import { a as BlockAuthoring, c as parseAuthoringContent, n as ComponentDefinition, s as createAuthoringSchema } from "../Configuration-CMweD9bn.js";
2
2
  import { compileCmsBlock, readAuthoringDefault } from "./authoring-compiler.js";
3
3
  import { Effect, Result, Schema } from "effect";
4
4
  import ts from "typescript";
@@ -1,5 +1,5 @@
1
1
  import { B as SeoConfiguration } from "../models-VmGmG19-.js";
2
- import { M as StudioBootstrap, t as maxS3SingleCopyBytes, u as makeDefaultSeoOptions } from "../S3MediaObjects-Dwhl2deX.js";
2
+ import { M as StudioBootstrap, t as maxS3SingleCopyBytes, u as makeDefaultSeoOptions } from "../S3MediaObjects-BXfjaZOu.js";
3
3
  import { validateFormCapabilities } from "./form-capabilities.js";
4
4
  import { compileCmsI18n } from "./i18n.js";
5
5
  import { i as PreviewOrigin } from "../models-5j67LMqW.js";
@@ -1,3 +1,3 @@
1
- import { a as resetCmsDevelopment, i as loadCmsProjectEnvironment, n as checkCmsConfiguration, r as doctorCmsDevelopment, t as bootstrapCmsDevelopment } from "../dev-lifecycle-CjDq63Ft.js";
1
+ import { a as resetCmsDevelopment, i as loadCmsProjectEnvironment, n as checkCmsConfiguration, r as doctorCmsDevelopment, t as bootstrapCmsDevelopment } from "../dev-lifecycle-3I_pozUl.js";
2
2
 
3
3
  export { bootstrapCmsDevelopment, checkCmsConfiguration, doctorCmsDevelopment, loadCmsProjectEnvironment, resetCmsDevelopment };
@@ -1,6 +1,6 @@
1
1
  import { FIELD_INPUT_METADATA, FIELD_OPTIONS_METADATA } from "./field-metadata.js";
2
- import { r as DocumentConfiguration, u as compileStructuredFields } from "../Configuration-Da5B2PVH.js";
3
- import { t as createDocumentEngine } from "../DocumentEngine-hh_IGPXO.js";
2
+ import { r as DocumentConfiguration, u as compileStructuredFields } from "../Configuration-CMweD9bn.js";
3
+ import { t as createDocumentEngine } from "../DocumentEngine-tYtwbBjr.js";
4
4
  import { Effect, Predicate, Result, Schema } from "effect";
5
5
 
6
6
  //#region src/internal/document-model.ts
@@ -18,7 +18,7 @@ function compileCmsDocumentModel(documents, i18n) {
18
18
  defaultLocale: i18n.defaultLocale,
19
19
  fallbackLocale: i18n.fallbackLocale ?? null,
20
20
  locales: Object.keys(i18n.locales),
21
- prefixDefaultLocale: i18n.prefixDefaultLocale ?? false
21
+ prefix: i18n.prefix ?? null
22
22
  } },
23
23
  types: compiled.map((entry) => entry.authoring)
24
24
  });
@@ -1 +1 @@
1
- {"version":3,"file":"document-model.js","names":[],"sources":["../../../../src/internal/document-model.ts"],"sourcesContent":["import type { CmsI18nOptions } from '../I18n'\nimport type { StandardJSONSchemaV1 } from '@standard-schema/spec'\nimport type {\n DocumentSchemaProjection,\n ExecutableDocumentModel,\n ExecutableDocumentSchema,\n} from '@internal/document/DocumentEngine'\nimport type { DocumentConfiguration as DocumentConfigurationType } from '@internal/protocol/Configuration'\nimport type { StructuredField } from '@internal/protocol/StructuredFields'\nimport type {\n CmsCollectionOptions,\n CmsCollectionSchema,\n CmsDocumentModelOptions,\n CmsFieldInput,\n} from '../DocumentModel'\nimport { createDocumentEngine } from '@internal/document/DocumentEngine'\nimport { compileStructuredFields } from '@internal/document/StructuredFields'\nimport { DocumentConfiguration } from '@internal/protocol/Configuration'\nimport { Effect, Predicate, Result, Schema } from 'effect'\nimport { FIELD_INPUT_METADATA, FIELD_OPTIONS_METADATA } from './field-metadata'\n\nconst isJsonObject = Schema.is(Schema.JsonObject)\n\ntype EncodedDocumentConfiguration = Schema.Codec.Encoded<typeof DocumentConfiguration>\n\ninterface CmsDocumentModel {\n readonly authoring: DocumentConfigurationType\n readonly executable: ExecutableDocumentModel\n}\n\ninterface CompiledCollection {\n readonly authoring: EncodedDocumentConfiguration['types'][number]\n readonly executable: ExecutableDocumentSchema\n}\n\nexport class CmsDocumentModelInvalid extends Schema.TaggedError<CmsDocumentModelInvalid>()('Cms.DocumentModelInvalid', {\n message: Schema.NonEmptyString,\n path: Schema.NonEmptyString,\n}) {}\n\nconst isCmsDocumentModelInvalid = Schema.is(CmsDocumentModelInvalid)\n\nexport function compileCmsDocumentModel(documents: CmsDocumentModelOptions, i18n?: CmsI18nOptions): CmsDocumentModel {\n try {\n const compiled = Object.entries(documents.collections).map(([collection, options]) =>\n compileCollection(collection, options),\n )\n\n const decoded = Schema.decodeResult(DocumentConfiguration)({\n ...(i18n === undefined\n ? undefined\n : {\n locales: {\n defaultLocale: i18n.defaultLocale,\n fallbackLocale: i18n.fallbackLocale ?? null,\n locales: Object.keys(i18n.locales),\n prefixDefaultLocale: i18n.prefixDefaultLocale ?? false,\n },\n }),\n types: compiled.map((entry) => entry.authoring),\n })\n\n if (Result.isFailure(decoded)) throw invalid('documents', String(decoded.failure))\n\n const model = {\n authoring: decoded.success,\n executable: {\n types: Object.fromEntries(compiled.map((entry) => [entry.authoring.collection, entry.executable])),\n },\n }\n\n const engine = Effect.runSync(\n Effect.result(createDocumentEngine(model.authoring, { documentModel: model.executable })),\n )\n\n if (Result.isFailure(engine)) throw invalid('documents', engine.failure.message)\n\n return model\n } catch (cause) {\n throw isCmsDocumentModelInvalid(cause)\n ? cause\n : invalid('documents.collections', cause instanceof Error ? cause.message : String(cause))\n }\n}\n\nfunction compileCollection(collection: string, options: CmsCollectionOptions): CompiledCollection {\n const path = `documents.collections.${collection}`\n let generated: ReturnType<StandardJSONSchemaV1.Converter['input']>\n\n try {\n if (isEffectCollectionSchema(options.schema)) {\n const document = Schema.toJsonSchemaDocument(options.schema, {\n includeAnnotationKey: (key) => key === FIELD_INPUT_METADATA || key === FIELD_OPTIONS_METADATA,\n referencePolicy: () => undefined,\n })\n\n generated = { ...document.schema, $defs: document.definitions }\n } else {\n if (!Predicate.isFunction(options.schema['~standard']?.jsonSchema?.input)) {\n throw new Error('Studio needs Standard JSON Schema V1 input conversion (or an adapter that supplies it).')\n }\n\n generated = options.schema['~standard'].jsonSchema.input({ target: 'draft-2020-12' })\n }\n } catch (cause) {\n throw invalid(`${path}.schema`, cause instanceof Error ? cause.message : String(cause))\n }\n\n const decoded = Schema.decodeUnknownResult(Schema.JsonObject)(generated)\n\n if (Result.isFailure(decoded)) throw invalid(`${path}.schema`, 'The generated input structure is not serializable.')\n const input = resolveInputStructure(decoded.success, `${path}.schema`)\n\n if (input.type !== 'object') throw invalid(`${path}.schema`, 'A collection schema must describe an object input.')\n const projection = compileProjection(input, `${path}.schema`)\n const authoringFields = compileAuthoringFields(input, `${path}.schema`)\n const structuredFields = compileStructuredFields(authoringFields)\n\n const validator = isEffectCollectionSchema(options.schema)\n ? Schema.toStandardSchemaV1(options.schema)\n : options.schema\n\n return {\n authoring: {\n ...(options.body === undefined ? undefined : { body: options.body }),\n authoringFields,\n canCreate: options.canCreate ?? true,\n collection,\n description: options.description ?? '',\n hierarchy: options.hierarchy ?? options.route.includes('*'),\n label: options.label,\n routes: { entry: options.route, home: collectionHomeRoute(options.route) },\n },\n executable: {\n project: projection,\n validate: (value) =>\n Effect.tryPromise(() =>\n Promise.resolve(validator['~standard'].validate(value)).then((validation) => {\n if ('issues' in validation || !Schema.is(Schema.JsonObject)(validation.value)) return validation\n const issues = structuredFields.validateIdentities(validation.value)\n\n return issues.length > 0 ? { issues } : validation\n }),\n ),\n },\n }\n}\n\nfunction collectionHomeRoute(entryRoute: string): string {\n const token = entryRoute.indexOf(':')\n const prefix = token < 0 ? entryRoute : entryRoute.slice(0, token)\n const normalized = `/${prefix.split('/').filter(Boolean).join('/')}`\n\n return normalized === '/' ? '/' : normalized.replace(/\\/$/u, '')\n}\n\ntype ProjectDocumentProjection = (input: Schema.JsonObject, parent?: string) => DocumentSchemaProjection\n\nfunction compileProjection(schema: Schema.JsonObject, path: string): ProjectDocumentProjection {\n const properties = objectKeyword(schema, 'properties', path, true)\n\n const declarations = new Map(\n Object.entries(properties).map(([name, value]) => {\n const property = requireObject(value, `${path}.${name}`)\n const nested = property.type === 'object' ? compileProjection(property, `${path}.${name}`) : undefined\n const items = property.type === 'array' ? requireObject(property.items, `${path}.${name}[]`) : undefined\n const listItem = items?.type === 'object' ? compileProjection(items, `${path}.${name}[]`) : undefined\n\n return [name, { listItem, nested }] as const\n }),\n )\n\n return (input, parent = '') => {\n const value: Record<string, Schema.Json> = {}\n const unknownPaths: string[] = []\n\n for (const [name, child] of Object.entries(input)) {\n const declaration = declarations.get(name)\n const fieldPath = parent ? `${parent}.${name}` : name\n\n if (!declarations.has(name)) {\n unknownPaths.push(fieldPath)\n } else if (declaration?.nested && isJsonObject(child)) {\n const projected = declaration.nested(child, fieldPath)\n value[name] = projected.value\n unknownPaths.push(...projected.unknownPaths)\n } else if (declaration?.listItem && Array.isArray(child)) {\n value[name] = child.map((item, index) => {\n if (!isJsonObject(item)) return item\n const projected = declaration.listItem?.(item, `${fieldPath}.${index}`)\n\n if (!projected) return item\n unknownPaths.push(...projected.unknownPaths)\n\n return projected.value\n })\n } else {\n value[name] = child\n }\n }\n\n return { unknownPaths, value }\n }\n}\n\nfunction compileAuthoringFields(\n schema: Schema.JsonObject,\n path: string,\n listItem = false,\n): ReadonlyArray<StructuredField> {\n const properties = objectKeyword(schema, 'properties', path, true)\n const required = stringArrayKeyword(schema, 'required', path)\n\n return Object.entries(properties).flatMap(([name, value]) => {\n if (!name || name.includes('.')) {\n throw invalid(`${path}.${name || '<empty>'}`, 'Field names must be non-empty and cannot contain dots.')\n }\n\n if (name === 'id') {\n if (listItem) return []\n throw invalid(`${path}.id`, 'Field \"id\" is reserved for CMS identity.')\n }\n\n const property = requireObject(value, `${path}.${name}`)\n const fieldRequired = required.has(name)\n\n if (property.type === 'object') {\n return [\n {\n ...fieldPresentation(property, `${path}.${name}`, name, fieldRequired),\n fields: compileAuthoringFields(property, `${path}.${name}`),\n input: 'object',\n options: [],\n type: 'object',\n },\n ]\n }\n\n return [compileAuthoringField(property, `${path}.${name}`, name, fieldRequired)]\n })\n}\n\nfunction compileAuthoringField(\n schema: Schema.JsonObject,\n schemaPath: string,\n name: string,\n required: boolean,\n): StructuredField {\n const presentation = fieldPresentation(schema, schemaPath, name, required)\n\n switch (schema.type) {\n case 'boolean':\n return { ...presentation, input: input(schema, schemaPath, 'toggle', ['toggle']), options: [], type: 'boolean' }\n case 'integer':\n case 'number': {\n const options = numericOptions(schema, schemaPath)\n\n return {\n ...presentation,\n input: input(schema, schemaPath, options.length > 0 ? 'select' : 'number', ['number', 'select']),\n options,\n type: 'number',\n }\n }\n\n case 'string': {\n if (schema.format === 'date') {\n return { ...presentation, input: input(schema, schemaPath, 'date', ['date']), options: [], type: 'date' }\n }\n\n if (schema.format === 'cms-document-reference') {\n return { ...presentation, input: 'document', options: [], type: 'string' }\n }\n\n if (schema.format === 'cms-managed-media-reference') {\n return { ...presentation, input: 'media', options: [], type: 'string' }\n }\n\n const options = stringOptions(schema, schemaPath)\n\n return {\n ...presentation,\n input: input(schema, schemaPath, options.length > 0 ? 'select' : 'text', [\n 'select',\n 'text',\n 'textarea',\n 'image',\n 'link',\n 'document',\n 'media',\n ]),\n options,\n type: 'string',\n }\n }\n\n case 'array': {\n const items = requireObject(schema.items, `${schemaPath}[]`)\n\n if (items.type === 'object') {\n const itemProperties = objectKeyword(items, 'properties', `${schemaPath}[]`, true)\n const itemRequired = stringArrayKeyword(items, 'required', `${schemaPath}[]`)\n const identity = itemProperties.id\n\n if (!identity || requireObject(identity, `${schemaPath}[].id`).type !== 'string' || !itemRequired.has('id')) {\n throw invalid(schemaPath, 'Repeatable object items need a required string id managed by the CMS.')\n }\n\n return {\n ...presentation,\n fields: compileAuthoringFields(items, `${schemaPath}[]`, true),\n input: 'list',\n options: [],\n type: 'array',\n }\n }\n\n if (items.type !== 'string')\n throw invalid(schemaPath, 'Studio supports scalar string lists or repeatable objects with stable identity.')\n\n return {\n ...presentation,\n input: input(schema, schemaPath, 'multiselect', ['multiselect']),\n options: stringOptions(items, `${schemaPath}[]`, schema[FIELD_OPTIONS_METADATA]),\n type: 'string[]',\n }\n }\n\n default:\n throw invalid(schemaPath, `Studio cannot generate an input for schema type \"${displayJson(schema.type)}\".`)\n }\n}\n\nfunction fieldPresentation(schema: Schema.JsonObject, schemaPath: string, name: string, required: boolean) {\n const defaultValue = schema.default\n const description = stringKeyword(schema, 'description', schemaPath)\n const title = stringKeyword(schema, 'title', schemaPath)\n\n return {\n ...(defaultValue === undefined ? undefined : { defaultValue }),\n ...(description === undefined ? undefined : { description }),\n label: title?.trim() || humanize(name),\n name,\n nullable: schema['x-cms-nullable'] === true,\n required,\n }\n}\n\nfunction input<const Supported extends ReadonlyArray<CmsFieldInput>>(\n schema: Schema.JsonObject,\n path: string,\n fallback: Supported[number],\n supported: Supported,\n): Supported[number] {\n const configured = schema[FIELD_INPUT_METADATA]\n\n if (configured === undefined) return fallback\n const decoded = Schema.decodeUnknownResult(Schema.Literals([...supported]))(configured)\n\n if (Result.isSuccess(decoded)) return decoded.success\n throw invalid(path, `Input \"${displayJson(configured)}\" is not compatible with this field.`)\n}\n\nfunction stringOptions(\n schema: Schema.JsonObject,\n path: string,\n configured: Schema.Json | undefined = schema[FIELD_OPTIONS_METADATA],\n): ReadonlyArray<{ label: string; value: string }> {\n const value = schema.enum\n\n if (value === undefined) return []\n const decoded = Schema.decodeUnknownResult(Schema.Array(Schema.String))(value)\n\n if (Result.isFailure(decoded)) throw invalid(path, 'Field options must all be strings.')\n\n return labeledOptions(configured, decoded.success, path)\n}\n\nfunction numericOptions(schema: Schema.JsonObject, path: string): ReadonlyArray<{ label: string; value: number }> {\n const value = schema.enum\n\n if (value === undefined) return []\n const decoded = Schema.decodeUnknownResult(Schema.Array(Schema.Finite))(value)\n\n if (Result.isFailure(decoded)) throw invalid(path, 'Field options must all be finite numbers.')\n\n return labeledOptions(schema[FIELD_OPTIONS_METADATA], decoded.success, path)\n}\n\nfunction labeledOptions<const Value extends string | number>(\n configured: Schema.Json | undefined,\n values: ReadonlyArray<Value>,\n path: string,\n): ReadonlyArray<{ label: string; value: Value }> {\n if (configured === undefined) return values.map((value) => ({ label: String(value), value }))\n\n const decoded = Schema.decodeUnknownResult(\n Schema.Array(Schema.Struct({ label: Schema.String, value: Schema.Union([Schema.String, Schema.Finite]) })),\n )(configured)\n\n if (\n Result.isFailure(decoded) ||\n decoded.success.length !== values.length ||\n decoded.success.some((option, index) => option.value !== values[index])\n )\n throw invalid(path, 'Labeled options must match the schema enum values in order.')\n\n return values.map((value, index) => ({ label: decoded.success[index]?.label ?? String(value), value }))\n}\n\nfunction objectKeyword(schema: Schema.JsonObject, keyword: string, path: string, optional = false): Schema.JsonObject {\n const value = schema[keyword]\n\n if (value === undefined && optional) return {}\n\n return requireObject(value, `${path}.${keyword}`)\n}\n\nfunction stringArrayKeyword(schema: Schema.JsonObject, keyword: string, path: string): ReadonlySet<string> {\n const value = schema[keyword]\n\n if (value === undefined) return new Set()\n const decoded = Schema.decodeUnknownResult(Schema.Array(Schema.String))(value)\n\n if (Result.isFailure(decoded)) throw invalid(`${path}.${keyword}`, `Expected \"${keyword}\" to be an array of strings.`)\n\n return new Set(decoded.success)\n}\n\nfunction stringKeyword(schema: Schema.JsonObject, keyword: string, path: string): string | undefined {\n const value = schema[keyword]\n\n if (value === undefined) return undefined\n const decoded = Schema.decodeUnknownResult(Schema.String)(value)\n\n if (Result.isFailure(decoded)) throw invalid(`${path}.${keyword}`, `Expected \"${keyword}\" to be a string.`)\n\n return decoded.success\n}\n\nfunction requireObject(value: Schema.Json | undefined, path: string): Schema.JsonObject {\n if (!isJsonObject(value)) throw invalid(path, 'Studio requires an object input structure at this location.')\n\n return value\n}\n\nfunction humanize(path: string): string {\n const name = path.split('.').at(-1) ?? path\n\n const words = name\n .replace(/([a-z\\d])([A-Z])/gu, '$1 $2')\n .replace(/[-_]+/gu, ' ')\n .trim()\n\n return words ? `${words.charAt(0).toUpperCase()}${words.slice(1)}` : name\n}\n\nfunction displayJson(value: Schema.Json | undefined): string {\n return value === undefined ? 'undefined' : (JSON.stringify(value) ?? 'undefined')\n}\n\nfunction invalid(path: string, message: string): CmsDocumentModelInvalid {\n return new CmsDocumentModelInvalid({ message, path })\n}\n\n/** Resolve local input references while rejecting recursive or ambiguous editor structures. */\nfunction resolveInputStructure(root: Schema.JsonObject, path: string): Schema.JsonObject {\n function visit(node: Schema.JsonObject, currentPath: string, ancestors: ReadonlySet<string>): Schema.JsonObject {\n if (node.$ref !== undefined) {\n const decodedRef = Schema.decodeUnknownResult(Schema.String)(node.$ref)\n\n if (Result.isFailure(decodedRef)) throw invalid(currentPath, 'Expected a string schema reference.')\n const ref = decodedRef.success\n\n if (!ref.startsWith('#/') || ancestors.has(ref)) {\n throw invalid(currentPath, 'Studio requires non-recursive local schema references.')\n }\n\n let target: Schema.Json | undefined = root\n\n for (const segment of ref.slice(2).split('/')) {\n target = isJsonObject(target) ? target[segment.replace(/~1/gu, '/').replace(/~0/gu, '~')] : undefined\n }\n\n const { $ref: _, ...siblings } = node\n\n return visit(\n Object.assign({}, requireObject(target, currentPath), siblings),\n currentPath,\n new Set([...ancestors, ref]),\n )\n }\n\n if (node.anyOf !== undefined) {\n if (!Array.isArray(node.anyOf)) throw invalid(currentPath, 'Expected an array of schema alternatives.')\n const alternatives = node.anyOf.map((value) => requireObject(value, currentPath))\n const nulls = alternatives.filter((value) => value.type === 'null')\n const values = alternatives.filter((value) => value.type !== 'null')\n\n if (nulls.length === 1 && values.length === 1) {\n const { anyOf: _, ...siblings } = node\n\n return Object.assign(visit(Object.assign({}, values[0], siblings), currentPath, ancestors), {\n 'x-cms-nullable': true,\n })\n }\n\n throw invalid(currentPath, 'Studio requires a single supported input type per field.')\n }\n\n if (node.oneOf !== undefined) {\n throw invalid(currentPath, 'Studio requires a single supported input type per field.')\n }\n\n const out = Object.fromEntries(Object.entries(node))\n\n if (node.allOf !== undefined) {\n if (!Array.isArray(node.allOf)) throw invalid(currentPath, 'Expected an array of schema constraints.')\n\n for (const constraint of node.allOf) {\n const part = visit(requireObject(constraint, currentPath), currentPath, ancestors)\n\n if (\n part.properties !== undefined ||\n part.items !== undefined ||\n (part.type !== undefined && part.type !== node.type)\n ) {\n throw invalid(currentPath, 'Studio cannot combine structural schema intersections.')\n }\n\n for (const key of [\n 'title',\n 'description',\n 'default',\n 'format',\n 'enum',\n FIELD_INPUT_METADATA,\n FIELD_OPTIONS_METADATA,\n ]) {\n if (part[key] === undefined) continue\n\n if (out[key] !== undefined && JSON.stringify(out[key]) !== JSON.stringify(part[key])) {\n throw invalid(currentPath, `Conflicting field metadata \"${key}\" in schema intersection.`)\n }\n\n out[key] = part[key]\n }\n }\n }\n\n if (node.properties !== undefined) {\n out.properties = Object.fromEntries(\n Object.entries(requireObject(node.properties, currentPath)).map(([name, value]) => [\n name,\n visit(requireObject(value, `${currentPath}.${name}`), `${currentPath}.${name}`, ancestors),\n ]),\n )\n }\n\n if (node.items !== undefined)\n out.items = visit(requireObject(node.items, `${currentPath}[]`), `${currentPath}[]`, ancestors)\n\n return out\n }\n\n return visit(root, path, new Set())\n}\n\nfunction isEffectCollectionSchema(schema: CmsCollectionSchema): schema is Schema.ConstraintDecoder<unknown> {\n return Schema.isSchema(schema)\n}\n"],"mappings":";;;;;;AAqBA,MAAM,eAAe,OAAO,GAAG,OAAO,UAAU;AAchD,IAAa,0BAAb,cAA6C,OAAO,YAAqC,CAAC,CAAC,4BAA4B;CACrH,SAAS,OAAO;CAChB,MAAM,OAAO;AACf,CAAC,CAAC,CAAC,CAAC;AAEJ,MAAM,4BAA4B,OAAO,GAAG,uBAAuB;AAEnE,SAAgB,wBAAwB,WAAoC,MAAyC;CACnH,IAAI;EACF,MAAM,WAAW,OAAO,QAAQ,UAAU,WAAW,CAAC,CAAC,KAAK,CAAC,YAAY,aACvE,kBAAkB,YAAY,OAAO,CACvC;EAEA,MAAM,UAAU,OAAO,aAAa,qBAAqB,CAAC,CAAC;GACzD,GAAI,SAAS,SACT,SACA,EACE,SAAS;IACP,eAAe,KAAK;IACpB,gBAAgB,KAAK,kBAAkB;IACvC,SAAS,OAAO,KAAK,KAAK,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model.js","names":[],"sources":["../../../../src/internal/document-model.ts"],"sourcesContent":["import type { CmsI18nOptions } from '../I18n'\nimport type { StandardJSONSchemaV1 } from '@standard-schema/spec'\nimport type {\n DocumentSchemaProjection,\n ExecutableDocumentModel,\n ExecutableDocumentSchema,\n} from '@internal/document/DocumentEngine'\nimport type { DocumentConfiguration as DocumentConfigurationType } from '@internal/protocol/Configuration'\nimport type { StructuredField } from '@internal/protocol/StructuredFields'\nimport type {\n CmsCollectionOptions,\n CmsCollectionSchema,\n CmsDocumentModelOptions,\n CmsFieldInput,\n} from '../DocumentModel'\nimport { createDocumentEngine } from '@internal/document/DocumentEngine'\nimport { compileStructuredFields } from '@internal/document/StructuredFields'\nimport { DocumentConfiguration } from '@internal/protocol/Configuration'\nimport { Effect, Predicate, Result, Schema } from 'effect'\nimport { FIELD_INPUT_METADATA, FIELD_OPTIONS_METADATA } from './field-metadata'\n\nconst isJsonObject = Schema.is(Schema.JsonObject)\n\ntype EncodedDocumentConfiguration = Schema.Codec.Encoded<typeof DocumentConfiguration>\n\ninterface CmsDocumentModel {\n readonly authoring: DocumentConfigurationType\n readonly executable: ExecutableDocumentModel\n}\n\ninterface CompiledCollection {\n readonly authoring: EncodedDocumentConfiguration['types'][number]\n readonly executable: ExecutableDocumentSchema\n}\n\nexport class CmsDocumentModelInvalid extends Schema.TaggedError<CmsDocumentModelInvalid>()('Cms.DocumentModelInvalid', {\n message: Schema.NonEmptyString,\n path: Schema.NonEmptyString,\n}) {}\n\nconst isCmsDocumentModelInvalid = Schema.is(CmsDocumentModelInvalid)\n\nexport function compileCmsDocumentModel(documents: CmsDocumentModelOptions, i18n?: CmsI18nOptions): CmsDocumentModel {\n try {\n const compiled = Object.entries(documents.collections).map(([collection, options]) =>\n compileCollection(collection, options),\n )\n\n const decoded = Schema.decodeResult(DocumentConfiguration)({\n ...(i18n === undefined\n ? undefined\n : {\n locales: {\n defaultLocale: i18n.defaultLocale,\n fallbackLocale: i18n.fallbackLocale ?? null,\n locales: Object.keys(i18n.locales),\n prefix: i18n.prefix ?? null,\n },\n }),\n types: compiled.map((entry) => entry.authoring),\n })\n\n if (Result.isFailure(decoded)) throw invalid('documents', String(decoded.failure))\n\n const model = {\n authoring: decoded.success,\n executable: {\n types: Object.fromEntries(compiled.map((entry) => [entry.authoring.collection, entry.executable])),\n },\n }\n\n const engine = Effect.runSync(\n Effect.result(createDocumentEngine(model.authoring, { documentModel: model.executable })),\n )\n\n if (Result.isFailure(engine)) throw invalid('documents', engine.failure.message)\n\n return model\n } catch (cause) {\n throw isCmsDocumentModelInvalid(cause)\n ? cause\n : invalid('documents.collections', cause instanceof Error ? cause.message : String(cause))\n }\n}\n\nfunction compileCollection(collection: string, options: CmsCollectionOptions): CompiledCollection {\n const path = `documents.collections.${collection}`\n let generated: ReturnType<StandardJSONSchemaV1.Converter['input']>\n\n try {\n if (isEffectCollectionSchema(options.schema)) {\n const document = Schema.toJsonSchemaDocument(options.schema, {\n includeAnnotationKey: (key) => key === FIELD_INPUT_METADATA || key === FIELD_OPTIONS_METADATA,\n referencePolicy: () => undefined,\n })\n\n generated = { ...document.schema, $defs: document.definitions }\n } else {\n if (!Predicate.isFunction(options.schema['~standard']?.jsonSchema?.input)) {\n throw new Error('Studio needs Standard JSON Schema V1 input conversion (or an adapter that supplies it).')\n }\n\n generated = options.schema['~standard'].jsonSchema.input({ target: 'draft-2020-12' })\n }\n } catch (cause) {\n throw invalid(`${path}.schema`, cause instanceof Error ? cause.message : String(cause))\n }\n\n const decoded = Schema.decodeUnknownResult(Schema.JsonObject)(generated)\n\n if (Result.isFailure(decoded)) throw invalid(`${path}.schema`, 'The generated input structure is not serializable.')\n const input = resolveInputStructure(decoded.success, `${path}.schema`)\n\n if (input.type !== 'object') throw invalid(`${path}.schema`, 'A collection schema must describe an object input.')\n const projection = compileProjection(input, `${path}.schema`)\n const authoringFields = compileAuthoringFields(input, `${path}.schema`)\n const structuredFields = compileStructuredFields(authoringFields)\n\n const validator = isEffectCollectionSchema(options.schema)\n ? Schema.toStandardSchemaV1(options.schema)\n : options.schema\n\n return {\n authoring: {\n ...(options.body === undefined ? undefined : { body: options.body }),\n authoringFields,\n canCreate: options.canCreate ?? true,\n collection,\n description: options.description ?? '',\n hierarchy: options.hierarchy ?? options.route.includes('*'),\n label: options.label,\n routes: { entry: options.route, home: collectionHomeRoute(options.route) },\n },\n executable: {\n project: projection,\n validate: (value) =>\n Effect.tryPromise(() =>\n Promise.resolve(validator['~standard'].validate(value)).then((validation) => {\n if ('issues' in validation || !Schema.is(Schema.JsonObject)(validation.value)) return validation\n const issues = structuredFields.validateIdentities(validation.value)\n\n return issues.length > 0 ? { issues } : validation\n }),\n ),\n },\n }\n}\n\nfunction collectionHomeRoute(entryRoute: string): string {\n const token = entryRoute.indexOf(':')\n const prefix = token < 0 ? entryRoute : entryRoute.slice(0, token)\n const normalized = `/${prefix.split('/').filter(Boolean).join('/')}`\n\n return normalized === '/' ? '/' : normalized.replace(/\\/$/u, '')\n}\n\ntype ProjectDocumentProjection = (input: Schema.JsonObject, parent?: string) => DocumentSchemaProjection\n\nfunction compileProjection(schema: Schema.JsonObject, path: string): ProjectDocumentProjection {\n const properties = objectKeyword(schema, 'properties', path, true)\n\n const declarations = new Map(\n Object.entries(properties).map(([name, value]) => {\n const property = requireObject(value, `${path}.${name}`)\n const nested = property.type === 'object' ? compileProjection(property, `${path}.${name}`) : undefined\n const items = property.type === 'array' ? requireObject(property.items, `${path}.${name}[]`) : undefined\n const listItem = items?.type === 'object' ? compileProjection(items, `${path}.${name}[]`) : undefined\n\n return [name, { listItem, nested }] as const\n }),\n )\n\n return (input, parent = '') => {\n const value: Record<string, Schema.Json> = {}\n const unknownPaths: string[] = []\n\n for (const [name, child] of Object.entries(input)) {\n const declaration = declarations.get(name)\n const fieldPath = parent ? `${parent}.${name}` : name\n\n if (!declarations.has(name)) {\n unknownPaths.push(fieldPath)\n } else if (declaration?.nested && isJsonObject(child)) {\n const projected = declaration.nested(child, fieldPath)\n value[name] = projected.value\n unknownPaths.push(...projected.unknownPaths)\n } else if (declaration?.listItem && Array.isArray(child)) {\n value[name] = child.map((item, index) => {\n if (!isJsonObject(item)) return item\n const projected = declaration.listItem?.(item, `${fieldPath}.${index}`)\n\n if (!projected) return item\n unknownPaths.push(...projected.unknownPaths)\n\n return projected.value\n })\n } else {\n value[name] = child\n }\n }\n\n return { unknownPaths, value }\n }\n}\n\nfunction compileAuthoringFields(\n schema: Schema.JsonObject,\n path: string,\n listItem = false,\n): ReadonlyArray<StructuredField> {\n const properties = objectKeyword(schema, 'properties', path, true)\n const required = stringArrayKeyword(schema, 'required', path)\n\n return Object.entries(properties).flatMap(([name, value]) => {\n if (!name || name.includes('.')) {\n throw invalid(`${path}.${name || '<empty>'}`, 'Field names must be non-empty and cannot contain dots.')\n }\n\n if (name === 'id') {\n if (listItem) return []\n throw invalid(`${path}.id`, 'Field \"id\" is reserved for CMS identity.')\n }\n\n const property = requireObject(value, `${path}.${name}`)\n const fieldRequired = required.has(name)\n\n if (property.type === 'object') {\n return [\n {\n ...fieldPresentation(property, `${path}.${name}`, name, fieldRequired),\n fields: compileAuthoringFields(property, `${path}.${name}`),\n input: 'object',\n options: [],\n type: 'object',\n },\n ]\n }\n\n return [compileAuthoringField(property, `${path}.${name}`, name, fieldRequired)]\n })\n}\n\nfunction compileAuthoringField(\n schema: Schema.JsonObject,\n schemaPath: string,\n name: string,\n required: boolean,\n): StructuredField {\n const presentation = fieldPresentation(schema, schemaPath, name, required)\n\n switch (schema.type) {\n case 'boolean':\n return { ...presentation, input: input(schema, schemaPath, 'toggle', ['toggle']), options: [], type: 'boolean' }\n case 'integer':\n case 'number': {\n const options = numericOptions(schema, schemaPath)\n\n return {\n ...presentation,\n input: input(schema, schemaPath, options.length > 0 ? 'select' : 'number', ['number', 'select']),\n options,\n type: 'number',\n }\n }\n\n case 'string': {\n if (schema.format === 'date') {\n return { ...presentation, input: input(schema, schemaPath, 'date', ['date']), options: [], type: 'date' }\n }\n\n if (schema.format === 'cms-document-reference') {\n return { ...presentation, input: 'document', options: [], type: 'string' }\n }\n\n if (schema.format === 'cms-managed-media-reference') {\n return { ...presentation, input: 'media', options: [], type: 'string' }\n }\n\n const options = stringOptions(schema, schemaPath)\n\n return {\n ...presentation,\n input: input(schema, schemaPath, options.length > 0 ? 'select' : 'text', [\n 'select',\n 'text',\n 'textarea',\n 'image',\n 'link',\n 'document',\n 'media',\n ]),\n options,\n type: 'string',\n }\n }\n\n case 'array': {\n const items = requireObject(schema.items, `${schemaPath}[]`)\n\n if (items.type === 'object') {\n const itemProperties = objectKeyword(items, 'properties', `${schemaPath}[]`, true)\n const itemRequired = stringArrayKeyword(items, 'required', `${schemaPath}[]`)\n const identity = itemProperties.id\n\n if (!identity || requireObject(identity, `${schemaPath}[].id`).type !== 'string' || !itemRequired.has('id')) {\n throw invalid(schemaPath, 'Repeatable object items need a required string id managed by the CMS.')\n }\n\n return {\n ...presentation,\n fields: compileAuthoringFields(items, `${schemaPath}[]`, true),\n input: 'list',\n options: [],\n type: 'array',\n }\n }\n\n if (items.type !== 'string')\n throw invalid(schemaPath, 'Studio supports scalar string lists or repeatable objects with stable identity.')\n\n return {\n ...presentation,\n input: input(schema, schemaPath, 'multiselect', ['multiselect']),\n options: stringOptions(items, `${schemaPath}[]`, schema[FIELD_OPTIONS_METADATA]),\n type: 'string[]',\n }\n }\n\n default:\n throw invalid(schemaPath, `Studio cannot generate an input for schema type \"${displayJson(schema.type)}\".`)\n }\n}\n\nfunction fieldPresentation(schema: Schema.JsonObject, schemaPath: string, name: string, required: boolean) {\n const defaultValue = schema.default\n const description = stringKeyword(schema, 'description', schemaPath)\n const title = stringKeyword(schema, 'title', schemaPath)\n\n return {\n ...(defaultValue === undefined ? undefined : { defaultValue }),\n ...(description === undefined ? undefined : { description }),\n label: title?.trim() || humanize(name),\n name,\n nullable: schema['x-cms-nullable'] === true,\n required,\n }\n}\n\nfunction input<const Supported extends ReadonlyArray<CmsFieldInput>>(\n schema: Schema.JsonObject,\n path: string,\n fallback: Supported[number],\n supported: Supported,\n): Supported[number] {\n const configured = schema[FIELD_INPUT_METADATA]\n\n if (configured === undefined) return fallback\n const decoded = Schema.decodeUnknownResult(Schema.Literals([...supported]))(configured)\n\n if (Result.isSuccess(decoded)) return decoded.success\n throw invalid(path, `Input \"${displayJson(configured)}\" is not compatible with this field.`)\n}\n\nfunction stringOptions(\n schema: Schema.JsonObject,\n path: string,\n configured: Schema.Json | undefined = schema[FIELD_OPTIONS_METADATA],\n): ReadonlyArray<{ label: string; value: string }> {\n const value = schema.enum\n\n if (value === undefined) return []\n const decoded = Schema.decodeUnknownResult(Schema.Array(Schema.String))(value)\n\n if (Result.isFailure(decoded)) throw invalid(path, 'Field options must all be strings.')\n\n return labeledOptions(configured, decoded.success, path)\n}\n\nfunction numericOptions(schema: Schema.JsonObject, path: string): ReadonlyArray<{ label: string; value: number }> {\n const value = schema.enum\n\n if (value === undefined) return []\n const decoded = Schema.decodeUnknownResult(Schema.Array(Schema.Finite))(value)\n\n if (Result.isFailure(decoded)) throw invalid(path, 'Field options must all be finite numbers.')\n\n return labeledOptions(schema[FIELD_OPTIONS_METADATA], decoded.success, path)\n}\n\nfunction labeledOptions<const Value extends string | number>(\n configured: Schema.Json | undefined,\n values: ReadonlyArray<Value>,\n path: string,\n): ReadonlyArray<{ label: string; value: Value }> {\n if (configured === undefined) return values.map((value) => ({ label: String(value), value }))\n\n const decoded = Schema.decodeUnknownResult(\n Schema.Array(Schema.Struct({ label: Schema.String, value: Schema.Union([Schema.String, Schema.Finite]) })),\n )(configured)\n\n if (\n Result.isFailure(decoded) ||\n decoded.success.length !== values.length ||\n decoded.success.some((option, index) => option.value !== values[index])\n )\n throw invalid(path, 'Labeled options must match the schema enum values in order.')\n\n return values.map((value, index) => ({ label: decoded.success[index]?.label ?? String(value), value }))\n}\n\nfunction objectKeyword(schema: Schema.JsonObject, keyword: string, path: string, optional = false): Schema.JsonObject {\n const value = schema[keyword]\n\n if (value === undefined && optional) return {}\n\n return requireObject(value, `${path}.${keyword}`)\n}\n\nfunction stringArrayKeyword(schema: Schema.JsonObject, keyword: string, path: string): ReadonlySet<string> {\n const value = schema[keyword]\n\n if (value === undefined) return new Set()\n const decoded = Schema.decodeUnknownResult(Schema.Array(Schema.String))(value)\n\n if (Result.isFailure(decoded)) throw invalid(`${path}.${keyword}`, `Expected \"${keyword}\" to be an array of strings.`)\n\n return new Set(decoded.success)\n}\n\nfunction stringKeyword(schema: Schema.JsonObject, keyword: string, path: string): string | undefined {\n const value = schema[keyword]\n\n if (value === undefined) return undefined\n const decoded = Schema.decodeUnknownResult(Schema.String)(value)\n\n if (Result.isFailure(decoded)) throw invalid(`${path}.${keyword}`, `Expected \"${keyword}\" to be a string.`)\n\n return decoded.success\n}\n\nfunction requireObject(value: Schema.Json | undefined, path: string): Schema.JsonObject {\n if (!isJsonObject(value)) throw invalid(path, 'Studio requires an object input structure at this location.')\n\n return value\n}\n\nfunction humanize(path: string): string {\n const name = path.split('.').at(-1) ?? path\n\n const words = name\n .replace(/([a-z\\d])([A-Z])/gu, '$1 $2')\n .replace(/[-_]+/gu, ' ')\n .trim()\n\n return words ? `${words.charAt(0).toUpperCase()}${words.slice(1)}` : name\n}\n\nfunction displayJson(value: Schema.Json | undefined): string {\n return value === undefined ? 'undefined' : (JSON.stringify(value) ?? 'undefined')\n}\n\nfunction invalid(path: string, message: string): CmsDocumentModelInvalid {\n return new CmsDocumentModelInvalid({ message, path })\n}\n\n/** Resolve local input references while rejecting recursive or ambiguous editor structures. */\nfunction resolveInputStructure(root: Schema.JsonObject, path: string): Schema.JsonObject {\n function visit(node: Schema.JsonObject, currentPath: string, ancestors: ReadonlySet<string>): Schema.JsonObject {\n if (node.$ref !== undefined) {\n const decodedRef = Schema.decodeUnknownResult(Schema.String)(node.$ref)\n\n if (Result.isFailure(decodedRef)) throw invalid(currentPath, 'Expected a string schema reference.')\n const ref = decodedRef.success\n\n if (!ref.startsWith('#/') || ancestors.has(ref)) {\n throw invalid(currentPath, 'Studio requires non-recursive local schema references.')\n }\n\n let target: Schema.Json | undefined = root\n\n for (const segment of ref.slice(2).split('/')) {\n target = isJsonObject(target) ? target[segment.replace(/~1/gu, '/').replace(/~0/gu, '~')] : undefined\n }\n\n const { $ref: _, ...siblings } = node\n\n return visit(\n Object.assign({}, requireObject(target, currentPath), siblings),\n currentPath,\n new Set([...ancestors, ref]),\n )\n }\n\n if (node.anyOf !== undefined) {\n if (!Array.isArray(node.anyOf)) throw invalid(currentPath, 'Expected an array of schema alternatives.')\n const alternatives = node.anyOf.map((value) => requireObject(value, currentPath))\n const nulls = alternatives.filter((value) => value.type === 'null')\n const values = alternatives.filter((value) => value.type !== 'null')\n\n if (nulls.length === 1 && values.length === 1) {\n const { anyOf: _, ...siblings } = node\n\n return Object.assign(visit(Object.assign({}, values[0], siblings), currentPath, ancestors), {\n 'x-cms-nullable': true,\n })\n }\n\n throw invalid(currentPath, 'Studio requires a single supported input type per field.')\n }\n\n if (node.oneOf !== undefined) {\n throw invalid(currentPath, 'Studio requires a single supported input type per field.')\n }\n\n const out = Object.fromEntries(Object.entries(node))\n\n if (node.allOf !== undefined) {\n if (!Array.isArray(node.allOf)) throw invalid(currentPath, 'Expected an array of schema constraints.')\n\n for (const constraint of node.allOf) {\n const part = visit(requireObject(constraint, currentPath), currentPath, ancestors)\n\n if (\n part.properties !== undefined ||\n part.items !== undefined ||\n (part.type !== undefined && part.type !== node.type)\n ) {\n throw invalid(currentPath, 'Studio cannot combine structural schema intersections.')\n }\n\n for (const key of [\n 'title',\n 'description',\n 'default',\n 'format',\n 'enum',\n FIELD_INPUT_METADATA,\n FIELD_OPTIONS_METADATA,\n ]) {\n if (part[key] === undefined) continue\n\n if (out[key] !== undefined && JSON.stringify(out[key]) !== JSON.stringify(part[key])) {\n throw invalid(currentPath, `Conflicting field metadata \"${key}\" in schema intersection.`)\n }\n\n out[key] = part[key]\n }\n }\n }\n\n if (node.properties !== undefined) {\n out.properties = Object.fromEntries(\n Object.entries(requireObject(node.properties, currentPath)).map(([name, value]) => [\n name,\n visit(requireObject(value, `${currentPath}.${name}`), `${currentPath}.${name}`, ancestors),\n ]),\n )\n }\n\n if (node.items !== undefined)\n out.items = visit(requireObject(node.items, `${currentPath}[]`), `${currentPath}[]`, ancestors)\n\n return out\n }\n\n return visit(root, path, new Set())\n}\n\nfunction isEffectCollectionSchema(schema: CmsCollectionSchema): schema is Schema.ConstraintDecoder<unknown> {\n return Schema.isSchema(schema)\n}\n"],"mappings":";;;;;;AAqBA,MAAM,eAAe,OAAO,GAAG,OAAO,UAAU;AAchD,IAAa,0BAAb,cAA6C,OAAO,YAAqC,CAAC,CAAC,4BAA4B;CACrH,SAAS,OAAO;CAChB,MAAM,OAAO;AACf,CAAC,CAAC,CAAC,CAAC;AAEJ,MAAM,4BAA4B,OAAO,GAAG,uBAAuB;AAEnE,SAAgB,wBAAwB,WAAoC,MAAyC;CACnH,IAAI;EACF,MAAM,WAAW,OAAO,QAAQ,UAAU,WAAW,CAAC,CAAC,KAAK,CAAC,YAAY,aACvE,kBAAkB,YAAY,OAAO,CACvC;EAEA,MAAM,UAAU,OAAO,aAAa,qBAAqB,CAAC,CAAC;GACzD,GAAI,SAAS,SACT,SACA,EACE,SAAS;IACP,eAAe,KAAK;IACpB,gBAAgB,KAAK,kBAAkB;IACvC,SAAS,OAAO,KAAK,KAAK,OAAO;IACjC,QAAQ,KAAK,UAAU;GACzB,EACF;GACJ,OAAO,SAAS,KAAK,UAAU,MAAM,SAAS;EAChD,CAAC;EAED,IAAI,OAAO,UAAU,OAAO,GAAG,MAAM,QAAQ,aAAa,OAAO,QAAQ,OAAO,CAAC;EAEjF,MAAM,QAAQ;GACZ,WAAW,QAAQ;GACnB,YAAY,EACV,OAAO,OAAO,YAAY,SAAS,KAAK,UAAU,CAAC,MAAM,UAAU,YAAY,MAAM,UAAU,CAAC,CAAC,EACnG;EACF;EAEA,MAAM,SAAS,OAAO,QACpB,OAAO,OAAO,qBAAqB,MAAM,WAAW,EAAE,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AAK,MAE/C,MAAM,QAAQ,aAAa,wDAAwD;IAGrF,KAAK,MAAM,OAAO;KAChB;KACA;KACA;KACA;KACA;KACA;KACA;IACF,GAAG;KACD,IAAI,KAAK,SAAS,QAAW;KAE7B,IAAI,IAAI,SAAS,UAAa,KAAK,UAAU,IAAI,IAAI,MAAM,KAAK,UAAU,KAAK,IAAI,GACjF,MAAM,QAAQ,aAAa,+BAA+B,IAAI,0BAA0B;KAG1F,IAAI,OAAO,KAAK;IAClB;GACF;EACF;EAEA,IAAI,KAAK,eAAe,QACtB,IAAI,aAAa,OAAO,YACtB,OAAO,QAAQ,cAAc,KAAK,YAAY,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,WAAW,CACjF,MACA,MAAM,cAAc,OAAO,GAAG,YAAY,GAAG,MAAM,GAAG,GAAG,YAAY,GAAG,QAAQ,SAAS,CAC3F,CAAC,CACH;EAGF,IAAI,KAAK,UAAU,QACjB,IAAI,QAAQ,MAAM,cAAc,KAAK,OAAO,GAAG,YAAY,GAAG,GAAG,GAAG,YAAY,KAAK,SAAS;EAEhG,OAAO;CACT;CAEA,OAAO,MAAM,MAAM,sBAAM,IAAI,IAAI,CAAC;AACpC;AAEA,SAAS,yBAAyB,QAA0E;CAC1G,OAAO,OAAO,SAAS,MAAM;AAC/B"}
@@ -6,7 +6,7 @@ function compileCmsI18n(options) {
6
6
  if (!options) return {
7
7
  defaultLocale: "",
8
8
  fallbackLocale: null,
9
- prefixDefaultLocale: false,
9
+ prefix: null,
10
10
  siteConfig: "documents",
11
11
  messageParameters: {},
12
12
  locales: {}
@@ -55,7 +55,7 @@ function compileCmsI18n(options) {
55
55
  return {
56
56
  defaultLocale: options.defaultLocale,
57
57
  fallbackLocale: options.fallbackLocale ?? null,
58
- prefixDefaultLocale: options.prefixDefaultLocale ?? false,
58
+ prefix: options.prefix ?? null,
59
59
  siteConfig: options.siteConfig ?? "documents",
60
60
  messageParameters,
61
61
  locales
@@ -1 +1 @@
1
- {"version":3,"file":"i18n.js","names":[],"sources":["../../../../src/internal/i18n.ts"],"sourcesContent":["import { Result, Schema } from 'effect'\nimport type { CmsI18nOptions } from '../I18n'\n\nexport interface CompiledCmsI18n {\n readonly defaultLocale: string\n readonly fallbackLocale: string | null\n readonly prefixDefaultLocale: boolean\n readonly siteConfig: 'documents' | 'localized-routes'\n readonly messageParameters: Readonly<Record<string, ReadonlyArray<string>>>\n readonly locales: Readonly<\n Record<string, { readonly name: string; readonly messages: Readonly<Record<string, string>> }>\n >\n}\n\n/** Copies only public, serializable fields; executable installation configuration stays on the server. */\nexport function compileCmsI18n(options?: CmsI18nOptions): CompiledCmsI18n {\n if (!options)\n return {\n defaultLocale: '',\n fallbackLocale: null,\n prefixDefaultLocale: false,\n siteConfig: 'documents',\n messageParameters: {},\n locales: {},\n }\n const codes = Object.keys(options.locales)\n\n if (\n !codes.includes(options.defaultLocale) ||\n (options.fallbackLocale != null && !codes.includes(options.fallbackLocale))\n ) {\n throw new Error('i18n defaultLocale and fallbackLocale must be declared in i18n.locales.')\n }\n\n const locales = Object.fromEntries(\n Object.entries(options.locales).map(([code, locale]) => {\n if (\n !/^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u.test(code) ||\n !Schema.is(Schema.String)(locale.name) ||\n !locale.name.trim()\n ) {\n throw new Error(`Invalid i18n locale: ${code}. Supply a locale code and display name.`)\n }\n\n const entries: [string, string][] = []\n const ancestors = new Set<object>()\n\n function visit(value: Schema.Json, path: string): void {\n if (Schema.is(Schema.String)(value)) {\n entries.push([path, value])\n\n return\n }\n\n if (!Schema.is(Schema.JsonObject)(value) || ancestors.has(value)) {\n throw new Error(`Invalid i18n message ${code}.${path}: expected a string or nested dictionary.`)\n }\n\n ancestors.add(value)\n\n for (const [key, child] of Object.entries(value)) {\n if (!key || key.includes('.')) throw new Error(`Invalid i18n message key: ${code}.${path}.${key}`)\n visit(child, path ? `${path}.${key}` : key)\n }\n\n ancestors.delete(value)\n }\n\n visit(Result.getOrThrow(Schema.decodeResult(Schema.JsonObject)(locale.messages ?? {})), '')\n\n return [code, { name: locale.name, messages: Object.fromEntries(entries) }]\n }),\n )\n\n const canonicalLocale = options.fallbackLocale ?? options.defaultLocale\n const canonicalMessages = locales[canonicalLocale]?.messages ?? {}\n const canonicalKeys = Object.keys(canonicalMessages)\n\n const messageParameters = Object.fromEntries(\n canonicalKeys.map((key) => [key, placeholders(canonicalMessages[key] ?? '')]),\n )\n\n for (const [code, locale] of Object.entries(locales)) {\n for (const key of Object.keys(locale.messages)) {\n if (!Object.hasOwn(canonicalMessages, key))\n throw new Error(`Invalid i18n message ${code}.${key}: the canonical locale ${canonicalLocale} has no such key.`)\n\n const expected = messageParameters[key] ?? []\n const actual = placeholders(locale.messages[key] ?? '')\n\n if (expected.join('\\0') !== actual.join('\\0'))\n throw new Error(\n `Invalid i18n message ${code}.${key}: placeholders must match ${canonicalLocale}.${key} (${expected.join(', ')}).`,\n )\n }\n\n if (options.fallbackLocale == null) {\n const missing = canonicalKeys.find((key) => !Object.hasOwn(locale.messages, key))\n\n if (missing)\n throw new Error(`Invalid i18n locale ${code}: missing message ${missing} and no fallback locale is configured.`)\n }\n }\n\n return {\n defaultLocale: options.defaultLocale,\n fallbackLocale: options.fallbackLocale ?? null,\n prefixDefaultLocale: options.prefixDefaultLocale ?? false,\n siteConfig: options.siteConfig ?? 'documents',\n messageParameters,\n locales,\n }\n}\n\nexport function ownsCmsLocale(configuration: CompiledCmsI18n, documentRoute: boolean): boolean {\n return Boolean(configuration.defaultLocale) && (configuration.siteConfig === 'localized-routes' || documentRoute)\n}\n\nfunction placeholders(message: string): ReadonlyArray<string> {\n return [...message.matchAll(/\\{([\\w]+)\\}/gu)]\n .flatMap((match) => (match[1] ? [match[1]] : []))\n .filter((name, index, names) => names.indexOf(name) === index)\n .sort((left, right) => left.localeCompare(right))\n}\n"],"mappings":";;;;AAeA,SAAgB,eAAe,SAA2C;CACxE,IAAI,CAAC,SACH,OAAO;EACL,eAAe;EACf,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AAEA,SAAgB,cAAc,eAAgC,eAAiC;CAC7F,OAAO,QAAQ,cAAc,aAAa,MAAM,cAAc,eAAe,sBAAsB;AACrG;AAEA,SAAS,aAAa,SAAwC;CAC5D,OAAO,CAAC,GAAG,QAAQ,SAAS,eAAe,CAAC,CAAC,CAC1C,SAAS,UAAW,MAAM,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAE,CAAC,CAChD,QAAQ,MAAM,OAAO,UAAU,MAAM,QAAQ,IAAI,MAAM,KAAK,CAAC,CAC7D,MAAM,MAAM,UAAU,KAAK,cAAc,KAAK,CAAC;AACpD"}
1
+ {"version":3,"file":"i18n.js","names":[],"sources":["../../../../src/internal/i18n.ts"],"sourcesContent":["import { Result, Schema } from 'effect'\nimport type { CmsI18nOptions } from '../I18n'\n\nexport interface CompiledCmsI18n {\n readonly defaultLocale: string\n readonly fallbackLocale: string | null\n readonly prefix: 'always' | null\n readonly siteConfig: 'documents' | 'localized-routes'\n readonly messageParameters: Readonly<Record<string, ReadonlyArray<string>>>\n readonly locales: Readonly<\n Record<string, { readonly name: string; readonly messages: Readonly<Record<string, string>> }>\n >\n}\n\n/** Copies only public, serializable fields; executable installation configuration stays on the server. */\nexport function compileCmsI18n(options?: CmsI18nOptions): CompiledCmsI18n {\n if (!options)\n return {\n defaultLocale: '',\n fallbackLocale: null,\n prefix: null,\n siteConfig: 'documents',\n messageParameters: {},\n locales: {},\n }\n const codes = Object.keys(options.locales)\n\n if (\n !codes.includes(options.defaultLocale) ||\n (options.fallbackLocale != null && !codes.includes(options.fallbackLocale))\n ) {\n throw new Error('i18n defaultLocale and fallbackLocale must be declared in i18n.locales.')\n }\n\n const locales = Object.fromEntries(\n Object.entries(options.locales).map(([code, locale]) => {\n if (\n !/^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u.test(code) ||\n !Schema.is(Schema.String)(locale.name) ||\n !locale.name.trim()\n ) {\n throw new Error(`Invalid i18n locale: ${code}. Supply a locale code and display name.`)\n }\n\n const entries: [string, string][] = []\n const ancestors = new Set<object>()\n\n function visit(value: Schema.Json, path: string): void {\n if (Schema.is(Schema.String)(value)) {\n entries.push([path, value])\n\n return\n }\n\n if (!Schema.is(Schema.JsonObject)(value) || ancestors.has(value)) {\n throw new Error(`Invalid i18n message ${code}.${path}: expected a string or nested dictionary.`)\n }\n\n ancestors.add(value)\n\n for (const [key, child] of Object.entries(value)) {\n if (!key || key.includes('.')) throw new Error(`Invalid i18n message key: ${code}.${path}.${key}`)\n visit(child, path ? `${path}.${key}` : key)\n }\n\n ancestors.delete(value)\n }\n\n visit(Result.getOrThrow(Schema.decodeResult(Schema.JsonObject)(locale.messages ?? {})), '')\n\n return [code, { name: locale.name, messages: Object.fromEntries(entries) }]\n }),\n )\n\n const canonicalLocale = options.fallbackLocale ?? options.defaultLocale\n const canonicalMessages = locales[canonicalLocale]?.messages ?? {}\n const canonicalKeys = Object.keys(canonicalMessages)\n\n const messageParameters = Object.fromEntries(\n canonicalKeys.map((key) => [key, placeholders(canonicalMessages[key] ?? '')]),\n )\n\n for (const [code, locale] of Object.entries(locales)) {\n for (const key of Object.keys(locale.messages)) {\n if (!Object.hasOwn(canonicalMessages, key))\n throw new Error(`Invalid i18n message ${code}.${key}: the canonical locale ${canonicalLocale} has no such key.`)\n\n const expected = messageParameters[key] ?? []\n const actual = placeholders(locale.messages[key] ?? '')\n\n if (expected.join('\\0') !== actual.join('\\0'))\n throw new Error(\n `Invalid i18n message ${code}.${key}: placeholders must match ${canonicalLocale}.${key} (${expected.join(', ')}).`,\n )\n }\n\n if (options.fallbackLocale == null) {\n const missing = canonicalKeys.find((key) => !Object.hasOwn(locale.messages, key))\n\n if (missing)\n throw new Error(`Invalid i18n locale ${code}: missing message ${missing} and no fallback locale is configured.`)\n }\n }\n\n return {\n defaultLocale: options.defaultLocale,\n fallbackLocale: options.fallbackLocale ?? null,\n prefix: options.prefix ?? null,\n siteConfig: options.siteConfig ?? 'documents',\n messageParameters,\n locales,\n }\n}\n\nexport function ownsCmsLocale(configuration: CompiledCmsI18n, documentRoute: boolean): boolean {\n return Boolean(configuration.defaultLocale) && (configuration.siteConfig === 'localized-routes' || documentRoute)\n}\n\nfunction placeholders(message: string): ReadonlyArray<string> {\n return [...message.matchAll(/\\{([\\w]+)\\}/gu)]\n .flatMap((match) => (match[1] ? [match[1]] : []))\n .filter((name, index, names) => names.indexOf(name) === index)\n .sort((left, right) => left.localeCompare(right))\n}\n"],"mappings":";;;;AAeA,SAAgB,eAAe,SAA2C;CACxE,IAAI,CAAC,SACH,OAAO;EACL,eAAe;EACf,gBAAgB;EAChB,QAAQ;EACR,YAAY;EACZ,mBAAmB,CAAC;EACpB,SAAS,CAAC;CACZ;CACF,MAAM,QAAQ,OAAO,KAAK,QAAQ,OAAO;CAEzC,IACE,CAAC,MAAM,SAAS,QAAQ,aAAa,KACpC,QAAQ,kBAAkB,QAAQ,CAAC,MAAM,SAAS,QAAQ,cAAc,GAEzE,MAAM,IAAI,MAAM,yEAAyE;CAG3F,MAAM,UAAU,OAAO,YACrB,OAAO,QAAQ,QAAQ,OAAO,CAAC,CAAC,KAAK,CAAC,MAAM,YAAY;EACtD,IACE,CAAC,yCAAyC,KAAK,IAAI,KACnD,CAAC,OAAO,GAAG,OAAO,MAAM,CAAC,CAAC,OAAO,IAAI,KACrC,CAAC,OAAO,KAAK,KAAK,GAElB,MAAM,IAAI,MAAM,wBAAwB,KAAK,yCAAyC;EAGxF,MAAM,UAA8B,CAAC;EACrC,MAAM,4BAAY,IAAI,IAAY;EAElC,SAAS,MAAM,OAAoB,MAAoB;GACrD,IAAI,OAAO,GAAG,OAAO,MAAM,CAAC,CAAC,KAAK,GAAG;IACnC,QAAQ,KAAK,CAAC,MAAM,KAAK,CAAC;IAE1B;GACF;GAEA,IAAI,CAAC,OAAO,GAAG,OAAO,UAAU,CAAC,CAAC,KAAK,KAAK,UAAU,IAAI,KAAK,GAC7D,MAAM,IAAI,MAAM,wBAAwB,KAAK,GAAG,KAAK,0CA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AAI,EAAE,GACjH;EACJ;EAEA,IAAI,QAAQ,kBAAkB,MAAM;GAClC,MAAM,UAAU,cAAc,MAAM,QAAQ,CAAC,OAAO,OAAO,OAAO,UAAU,GAAG,CAAC;GAEhF,IAAI,SACF,MAAM,IAAI,MAAM,uBAAuB,KAAK,oBAAoB,QAAQ,uCAAuC;EACnH;CACF;CAEA,OAAO;EACL,eAAe,QAAQ;EACvB,gBAAgB,QAAQ,kBAAkB;EAC1C,QAAQ,QAAQ,UAAU;EAC1B,YAAY,QAAQ,cAAc;EAClC;EACA;CACF;AACF;AAEA,SAAgB,cAAc,eAAgC,eAAiC;CAC7F,OAAO,QAAQ,cAAc,aAAa,MAAM,cAAc,eAAe,sBAAsB;AACrG;AAEA,SAAS,aAAa,SAAwC;CAC5D,OAAO,CAAC,GAAG,QAAQ,SAAS,eAAe,CAAC,CAAC,CAC1C,SAAS,UAAW,MAAM,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAE,CAAC,CAChD,QAAQ,MAAM,OAAO,UAAU,MAAM,QAAQ,IAAI,MAAM,KAAK,CAAC,CAC7D,MAAM,MAAM,UAAU,KAAK,cAAc,KAAK,CAAC;AACpD"}
@@ -1,4 +1,4 @@
1
- import { d as STUDIO_APP_PATH } from "../HttpPaths-c9nLZ9H2.js";
1
+ import { d as STUDIO_BASE_PATH } from "../HttpPaths-Be3vshPJ.js";
2
2
  import { Config, Effect, FileSystem, Path } from "effect";
3
3
  import { fileURLToPath } from "node:url";
4
4
  import { addRouteMiddleware, addServerHandler, addServerTemplate, addVitePlugin } from "@nuxt/kit";
@@ -55,11 +55,11 @@ const registerStudioApp = Effect.fn("CmsNuxtModule.registerStudioApp")(function*
55
55
  });
56
56
  addServerHandler({
57
57
  handler: handler.filename,
58
- route: STUDIO_APP_PATH
58
+ route: STUDIO_BASE_PATH
59
59
  });
60
60
  addServerHandler({
61
61
  handler: handler.filename,
62
- route: `${STUDIO_APP_PATH}/**:path`
62
+ route: `${STUDIO_BASE_PATH}/**:path`
63
63
  });
64
64
  });
65
65
 
@@ -1 +1 @@
1
- {"version":3,"file":"studio-app.js","names":[],"sources":["../../../../src/internal/studio-app.ts"],"sourcesContent":["import type { Nuxt } from '@nuxt/schema'\nimport { fileURLToPath } from 'node:url'\nimport { addRouteMiddleware, addServerHandler, addServerTemplate, addVitePlugin, createResolver } from '@nuxt/kit'\nimport { Config, Effect, FileSystem, Path } from 'effect'\nimport { STUDIO_APP_PATH } from '@internal/protocol/HttpPaths'\n\n/** A separate HTML entry shares Nuxt's Vite graph, but never its document or Vue app. */\nexport const registerStudioApp = Effect.fn('CmsNuxtModule.registerStudioApp')(function* (\n nuxt: Nuxt,\n resolver: ReturnType<typeof createResolver>,\n) {\n addRouteMiddleware({\n name: 'cms-studio-document',\n path: resolver.resolve('./runtime/studio-navigation'),\n global: true,\n })\n const fileSystem = yield* FileSystem.FileSystem\n const path = yield* Path.Path\n const packagedHost = resolver.resolve('../studio/host.js')\n const packaged = yield* fileSystem.exists(packagedHost)\n let host = packagedHost\n\n if (!packaged) {\n const source = fileURLToPath(import.meta.resolve('@internal/studio/host'))\n const root = path.dirname(path.dirname(source))\n host = `${root}/dist/host.js`\n const reuseStudioBuild = yield* Config.Boolean('CMS_REUSE_STUDIO_BUILD').pipe(Config.withDefault(false))\n\n if (\n !reuseStudioBuild ||\n !(yield* fileSystem.exists(host)) ||\n !(yield* fileSystem.exists(host.replace(/\\.js$/u, '.css')))\n ) {\n const { build } = yield* Effect.promise(() => import('vite'))\n yield* Effect.promise(() => build({ root, configFile: `${root}/vite.config.ts` }))\n }\n }\n\n nuxt.options.alias['#cms/studio'] = host\n nuxt.options.alias['#cms/studio-styles'] = host.replace(/\\.js$/u, '.css?url')\n const entryBase = resolver.resolve('./runtime/studio-entry')\n const entry = `${entryBase}.${(yield* fileSystem.exists(`${entryBase}.ts`)) ? 'ts' : 'js'}`\n const assets = `${nuxt.options.app.baseURL}${nuxt.options.app.buildAssetsDir}`.replace(/\\/+/gu, '/')\n let entryUrl = `${assets}@fs${entry}`\n addVitePlugin(\n {\n name: 'cms-studio-entry',\n apply: 'build',\n buildStart() {\n this.emitFile({ type: 'chunk', id: entry, name: 'cms-studio' })\n },\n generateBundle(_options, bundle) {\n const chunk = Object.values(bundle).find((output) => output.type === 'chunk' && output.name === 'cms-studio')\n\n if (chunk) entryUrl = `${nuxt.options.app.baseURL}${chunk.fileName}`\n },\n },\n { server: false },\n )\n\n const handler = addServerTemplate({\n filename: resolver.resolve('./runtime/studio-shell.virtual.mjs'),\n getContents: () =>\n [\n `import { createStudioAppHandler } from ${JSON.stringify(resolver.resolve('./runtime/studio-app'))}`,\n `export default createStudioAppHandler(${JSON.stringify(entryUrl)}, ${JSON.stringify(nuxt.options.dev ? `${assets}@vite/client` : undefined)})`,\n ].join('\\n'),\n })\n\n addServerHandler({ handler: handler.filename, route: STUDIO_APP_PATH })\n addServerHandler({ handler: handler.filename, route: `${STUDIO_APP_PATH}/**:path` })\n})\n"],"mappings":";;;;;;;AAOA,MAAa,oBAAoB,OAAO,GAAG,iCAAiC,CAAC,CAAC,WAC5E,MACA,UACA;CACA,mBAAmB;EACjB,MAAM;EACN,MAAM,SAAS,QAAQ,6BAA6B;EACpD,QAAQ;CACV,CAAC;CACD,MAAM,aAAa,OAAO,WAAW;CACrC,MAAM,OAAO,OAAO,KAAK;CACzB,MAAM,eAAe,SAAS,QAAQ,mBAAmB;CACzD,MAAM,WAAW,OAAO,WAAW,OAAO,YAAY;CACtD,IAAI,OAAO;CAEX,IAAI,CAAC,UAAU;EACb,MAAM,SAAS,cAAc,YAAY,QAAQ,uBAAuB,CAAC;EACzE,MAAM,OAAO,KAAK,QAAQ,KAAK,QAAQ,MAAM,CAAC;EAC9C,OAAO,GAAG,KAAK;EAGf,IACE,EAAC,OAH6B,OAAO,QAAQ,wBAAwB,CAAC,CAAC,KAAK,OAAO,YAAY,KAAK,CAAC,MAIrG,EAAE,OAAO,WAAW,OAAO,IAAI,MAC/B,EAAE,OAAO,WA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AiB;EAAE,SAAS,QAAQ;EAAU,OAAO,GAAG,gBAAgB;CAAU,CAAC;AACrF,CAAC"}
1
+ {"version":3,"file":"studio-app.js","names":[],"sources":["../../../../src/internal/studio-app.ts"],"sourcesContent":["import type { Nuxt } from '@nuxt/schema'\nimport { fileURLToPath } from 'node:url'\nimport { addRouteMiddleware, addServerHandler, addServerTemplate, addVitePlugin, createResolver } from '@nuxt/kit'\nimport { Config, Effect, FileSystem, Path } from 'effect'\nimport { STUDIO_BASE_PATH } from '@internal/protocol/HttpPaths'\n\n/** A separate HTML entry shares Nuxt's Vite graph, but never its document or Vue app. */\nexport const registerStudioApp = Effect.fn('CmsNuxtModule.registerStudioApp')(function* (\n nuxt: Nuxt,\n resolver: ReturnType<typeof createResolver>,\n) {\n addRouteMiddleware({\n name: 'cms-studio-document',\n path: resolver.resolve('./runtime/studio-navigation'),\n global: true,\n })\n const fileSystem = yield* FileSystem.FileSystem\n const path = yield* Path.Path\n const packagedHost = resolver.resolve('../studio/host.js')\n const packaged = yield* fileSystem.exists(packagedHost)\n let host = packagedHost\n\n if (!packaged) {\n const source = fileURLToPath(import.meta.resolve('@internal/studio/host'))\n const root = path.dirname(path.dirname(source))\n host = `${root}/dist/host.js`\n const reuseStudioBuild = yield* Config.Boolean('CMS_REUSE_STUDIO_BUILD').pipe(Config.withDefault(false))\n\n if (\n !reuseStudioBuild ||\n !(yield* fileSystem.exists(host)) ||\n !(yield* fileSystem.exists(host.replace(/\\.js$/u, '.css')))\n ) {\n const { build } = yield* Effect.promise(() => import('vite'))\n yield* Effect.promise(() => build({ root, configFile: `${root}/vite.config.ts` }))\n }\n }\n\n nuxt.options.alias['#cms/studio'] = host\n nuxt.options.alias['#cms/studio-styles'] = host.replace(/\\.js$/u, '.css?url')\n const entryBase = resolver.resolve('./runtime/studio-entry')\n const entry = `${entryBase}.${(yield* fileSystem.exists(`${entryBase}.ts`)) ? 'ts' : 'js'}`\n const assets = `${nuxt.options.app.baseURL}${nuxt.options.app.buildAssetsDir}`.replace(/\\/+/gu, '/')\n let entryUrl = `${assets}@fs${entry}`\n addVitePlugin(\n {\n name: 'cms-studio-entry',\n apply: 'build',\n buildStart() {\n this.emitFile({ type: 'chunk', id: entry, name: 'cms-studio' })\n },\n generateBundle(_options, bundle) {\n const chunk = Object.values(bundle).find((output) => output.type === 'chunk' && output.name === 'cms-studio')\n\n if (chunk) entryUrl = `${nuxt.options.app.baseURL}${chunk.fileName}`\n },\n },\n { server: false },\n )\n\n const handler = addServerTemplate({\n filename: resolver.resolve('./runtime/studio-shell.virtual.mjs'),\n getContents: () =>\n [\n `import { createStudioAppHandler } from ${JSON.stringify(resolver.resolve('./runtime/studio-app'))}`,\n `export default createStudioAppHandler(${JSON.stringify(entryUrl)}, ${JSON.stringify(nuxt.options.dev ? `${assets}@vite/client` : undefined)})`,\n ].join('\\n'),\n })\n\n addServerHandler({ handler: handler.filename, route: STUDIO_BASE_PATH })\n addServerHandler({ handler: handler.filename, route: `${STUDIO_BASE_PATH}/**:path` })\n})\n"],"mappings":";;;;;;;AAOA,MAAa,oBAAoB,OAAO,GAAG,iCAAiC,CAAC,CAAC,WAC5E,MACA,UACA;CACA,mBAAmB;EACjB,MAAM;EACN,MAAM,SAAS,QAAQ,6BAA6B;EACpD,QAAQ;CACV,CAAC;CACD,MAAM,aAAa,OAAO,WAAW;CACrC,MAAM,OAAO,OAAO,KAAK;CACzB,MAAM,eAAe,SAAS,QAAQ,mBAAmB;CACzD,MAAM,WAAW,OAAO,WAAW,OAAO,YAAY;CACtD,IAAI,OAAO;CAEX,IAAI,CAAC,UAAU;EACb,MAAM,SAAS,cAAc,YAAY,QAAQ,uBAAuB,CAAC;EACzE,MAAM,OAAO,KAAK,QAAQ,KAAK,QAAQ,MAAM,CAAC;EAC9C,OAAO,GAAG,KAAK;EAGf,IACE,EAAC,OAH6B,OAAO,QAAQ,wBAAwB,CAAC,CAAC,KAAK,OAAO,YAAY,KAAK,CAAC,MAIrG,EAAE,OAAO,WAAW,OA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U,OAAO;CAAiB,CAAC;CACvE,iBAAiB;EAAE,SAAS,QAAQ;EAAU,OAAO,GAAG,iBAAiB;CAAU,CAAC;AACtF,CAAC"}
@@ -2,9 +2,9 @@ import { ownsCmsLocale } from "../../internal/i18n.js";
2
2
  import { n as readPreviewLocation, t as previewRedirect } from "../../location-CMNGO3lU.js";
3
3
  import { usePreviewDelivery } from "./context.js";
4
4
  import { installCmsDocumentSeoAdapters } from "./useCmsDocumentSeo.js";
5
- import { localeFromPath } from "../i18n/translator.js";
5
+ import { canonicalLocalePath, localeFromPath } from "../i18n/translator.js";
6
6
  import { computed, watch } from "vue";
7
- import { addRouteMiddleware, defineNuxtPlugin, useHead, useRequestURL, useResponseHeader, useRoute, useState } from "nuxt/app";
7
+ import { addRouteMiddleware, defineNuxtPlugin, navigateTo, useHead, useRequestURL, useResponseHeader, useRoute, useState } from "nuxt/app";
8
8
  import configuration from "#cms/i18n";
9
9
  import { updateSiteConfig, useRobotsRule, useSchemaOrg } from "#imports";
10
10
 
@@ -30,6 +30,11 @@ var plugin_default = defineNuxtPlugin(() => {
30
30
  name: value.name
31
31
  })) : void 0)
32
32
  });
33
+ addRouteMiddleware("cms-locale", (to) => {
34
+ if (!ownsCmsLocale(configuration, to.meta.cmsDocument === true)) return;
35
+ const canonical = canonicalLocalePath(configuration, to.fullPath);
36
+ if (canonical !== to.fullPath) return navigateTo(canonical, { redirectCode: 301 });
37
+ }, { global: true });
33
38
  }
34
39
  installCmsDocumentSeoAdapters({
35
40
  head: (input) => {
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","names":[],"sources":["../../../../../src/runtime/delivery/plugin.ts"],"sourcesContent":["import configuration from '#cms/i18n'\nimport {\n addRouteMiddleware,\n defineNuxtPlugin,\n useHead,\n useRequestURL,\n useResponseHeader,\n useRoute,\n useState,\n} from 'nuxt/app'\nimport { updateSiteConfig, useRobotsRule, useSchemaOrg } from '#imports'\nimport { previewRedirect, readPreviewLocation } from '@internal/protocol/Preview'\nimport { computed, watch } from 'vue'\nimport { usePreviewDelivery } from './context'\nimport { installCmsDocumentSeoAdapters } from './useCmsDocumentSeo'\nimport { ownsCmsLocale } from '../../internal/i18n'\nimport { localeFromPath } from '../i18n/translator'\n\nexport default defineNuxtPlugin(() => {\n const route = useRoute()\n const url = useRequestURL()\n const documentLocale = useState<string | undefined>('cms-document-locale', () => undefined)\n\n if (configuration.defaultLocale) {\n const ownsRoute = computed(() => ownsCmsLocale(configuration, route.meta.cmsDocument === true))\n const locale = computed(() => documentLocale.value ?? localeFromPath(configuration, route.path))\n\n watch(\n () => route.fullPath,\n () => {\n documentLocale.value = undefined\n },\n { flush: 'sync' },\n )\n useHead({ htmlAttrs: { lang: computed(() => (ownsRoute.value ? locale.value : undefined)) } })\n updateSiteConfig({\n _context: '@phtngyn/cms',\n _priority: 0,\n currentLocale: computed(() => (ownsRoute.value ? locale.value : undefined)),\n defaultLocale: computed(() => (ownsRoute.value ? configuration.defaultLocale : undefined)),\n locales: computed(() =>\n ownsRoute.value\n ? Object.entries(configuration.locales).map(([code, value]) => ({ code, name: value.name }))\n : undefined,\n ),\n })\n }\n\n installCmsDocumentSeoAdapters({\n head: (input) => {\n useHead(input)\n },\n robots: (input) => {\n const robots = useRobotsRule(input)\n\n if (import.meta.server) {\n watch(\n input,\n (value) => {\n robots.value = value\n },\n { flush: 'sync', immediate: true },\n )\n }\n },\n schema: (input) => {\n useSchemaOrg(input)\n },\n seoMeta: (input) => {\n useHead(() => {\n const meta: Array<{ content: string; name: string } | { content: string; property: string }> = []\n\n const addName = (name: string, content: string | undefined) => {\n if (content) meta.push({ content, name })\n }\n\n const addProperty = (property: string, content: string | undefined) => {\n if (content) meta.push({ content, property })\n }\n\n addName('description', input.description())\n addName('robots', input.robots())\n addProperty('og:title', input.ogTitle())\n addProperty('og:description', input.ogDescription())\n addProperty('og:image', input.ogImage())\n addProperty('og:image:alt', input.ogImageAlt())\n addProperty('og:locale', input.ogLocale())\n addProperty('og:url', input.ogUrl() ?? (input.robots()?.startsWith('noindex') ? url.href : undefined))\n\n return { meta, title: input.title() }\n })\n },\n locale: (input) => {\n watch(input, (value) => (documentLocale.value = value), { immediate: true, flush: 'sync' })\n },\n })\n\n const parameters = readPreviewLocation(url)\n const preview = usePreviewDelivery()\n\n if (!preview.value || !parameters) return\n\n if (import.meta.server) {\n useResponseHeader('cache-control').value = 'private, no-store'\n useResponseHeader('x-frame-options').value = 'SAMEORIGIN'\n }\n\n addRouteMiddleware(\n 'cms-preview',\n (to) => {\n return previewRedirect(new URL(to.fullPath, url.origin), parameters)\n },\n { global: true },\n )\n})\n"],"mappings":";;;;;;;;;;;AAkBA,qBAAe,uBAAuB;CACpC,MAAM,QAAQ,SAAS;CACvB,MAAM,MAAM,cAAc;CAC1B,MAAM,iBAAiB,SAA6B,6BAA6B,MAAS;CAE1F,IAAI,cAAc,eAAe;EAC/B,MAAM,YAAY,eAAe,cAAc,eAAe,MAAM,KAAK,gBAAgB,IAAI,CAAC;EAC9F,MAAM,SAAS,eAAe,eAAe,SAAS,eAAe,eAAe,MAAM,IAAI,CAAC;EAE/F,YACQ,MAAM,gBACN;GACJ,eAAe,QAAQ;EACzB,GACA,EAAE,OAAO,OAAO,CAClB;EACA,QAAQ,EAAE,WAAW,EAAE,MAAM,eAAgB,UAAU,QAAQ,OAAO,QAAQ,MAAU,EAAE,EAAE,CAAC;EAC7F,iBAAiB;GACf,UAAU;GACV,WAAW;GACX,eAAe,eAAgB,UAAU,QAAQ,OAAO,QAAQ,MAAU;GAC1E,eAAe,eAAgB,UAAU,QAAQ,cAAc,gBAAgB,MAAU;GACzF,SAAS,eACP,UAAU,QACN,OAAO,QAAQ,cAAc,OAAO,CAAC,CAAC,KAAK,CAAC,MAAM,YAAY;IAAE;IAAM,MAAM,MAAM;GAAK,EAAE,IACzF,MACN;EACF,CAAC;CACH;CAEA,8BAA8B;EAC5B,OAAO,UAAU;GACf,QAAQ,KAAK;EACf;EACA,SAAS,UAAU;GACjB,MAAM,SAAS,cAA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AAG,UAAU;CACrE,GACA,EAAE,QAAQ,KAAK,CACjB;AACF,CAAC"}
1
+ {"version":3,"file":"plugin.js","names":[],"sources":["../../../../../src/runtime/delivery/plugin.ts"],"sourcesContent":["import configuration from '#cms/i18n'\nimport {\n addRouteMiddleware,\n defineNuxtPlugin,\n navigateTo,\n useHead,\n useRequestURL,\n useResponseHeader,\n useRoute,\n useState,\n} from 'nuxt/app'\nimport { updateSiteConfig, useRobotsRule, useSchemaOrg } from '#imports'\nimport { previewRedirect, readPreviewLocation } from '@internal/protocol/Preview'\nimport { computed, watch } from 'vue'\nimport { usePreviewDelivery } from './context'\nimport { installCmsDocumentSeoAdapters } from './useCmsDocumentSeo'\nimport { ownsCmsLocale } from '../../internal/i18n'\nimport { canonicalLocalePath, localeFromPath } from '../i18n/translator'\n\nexport default defineNuxtPlugin(() => {\n const route = useRoute()\n const url = useRequestURL()\n const documentLocale = useState<string | undefined>('cms-document-locale', () => undefined)\n\n if (configuration.defaultLocale) {\n const ownsRoute = computed(() => ownsCmsLocale(configuration, route.meta.cmsDocument === true))\n const locale = computed(() => documentLocale.value ?? localeFromPath(configuration, route.path))\n\n watch(\n () => route.fullPath,\n () => {\n documentLocale.value = undefined\n },\n { flush: 'sync' },\n )\n useHead({ htmlAttrs: { lang: computed(() => (ownsRoute.value ? locale.value : undefined)) } })\n updateSiteConfig({\n _context: '@phtngyn/cms',\n _priority: 0,\n currentLocale: computed(() => (ownsRoute.value ? locale.value : undefined)),\n defaultLocale: computed(() => (ownsRoute.value ? configuration.defaultLocale : undefined)),\n locales: computed(() =>\n ownsRoute.value\n ? Object.entries(configuration.locales).map(([code, value]) => ({ code, name: value.name }))\n : undefined,\n ),\n })\n addRouteMiddleware(\n 'cms-locale',\n (to) => {\n if (!ownsCmsLocale(configuration, to.meta.cmsDocument === true)) return\n const canonical = canonicalLocalePath(configuration, to.fullPath)\n\n if (canonical !== to.fullPath) return navigateTo(canonical, { redirectCode: 301 })\n },\n { global: true },\n )\n }\n\n installCmsDocumentSeoAdapters({\n head: (input) => {\n useHead(input)\n },\n robots: (input) => {\n const robots = useRobotsRule(input)\n\n if (import.meta.server) {\n watch(\n input,\n (value) => {\n robots.value = value\n },\n { flush: 'sync', immediate: true },\n )\n }\n },\n schema: (input) => {\n useSchemaOrg(input)\n },\n seoMeta: (input) => {\n useHead(() => {\n const meta: Array<{ content: string; name: string } | { content: string; property: string }> = []\n\n const addName = (name: string, content: string | undefined) => {\n if (content) meta.push({ content, name })\n }\n\n const addProperty = (property: string, content: string | undefined) => {\n if (content) meta.push({ content, property })\n }\n\n addName('description', input.description())\n addName('robots', input.robots())\n addProperty('og:title', input.ogTitle())\n addProperty('og:description', input.ogDescription())\n addProperty('og:image', input.ogImage())\n addProperty('og:image:alt', input.ogImageAlt())\n addProperty('og:locale', input.ogLocale())\n addProperty('og:url', input.ogUrl() ?? (input.robots()?.startsWith('noindex') ? url.href : undefined))\n\n return { meta, title: input.title() }\n })\n },\n locale: (input) => {\n watch(input, (value) => (documentLocale.value = value), { immediate: true, flush: 'sync' })\n },\n })\n\n const parameters = readPreviewLocation(url)\n const preview = usePreviewDelivery()\n\n if (!preview.value || !parameters) return\n\n if (import.meta.server) {\n useResponseHeader('cache-control').value = 'private, no-store'\n useResponseHeader('x-frame-options').value = 'SAMEORIGIN'\n }\n\n addRouteMiddleware(\n 'cms-preview',\n (to) => {\n return previewRedirect(new URL(to.fullPath, url.origin), parameters)\n },\n { global: true },\n )\n})\n"],"mappings":";;;;;;;;;;;AAmBA,qBAAe,uBAAuB;CACpC,MAAM,QAAQ,SAAS;CACvB,MAAM,MAAM,cAAc;CAC1B,MAAM,iBAAiB,SAA6B,6BAA6B,MAAS;CAE1F,IAAI,cAAc,eAAe;EAC/B,MAAM,YAAY,eAAe,cAAc,eAAe,MAAM,KAAK,gBAAgB,IAAI,CAAC;EAC9F,MAAM,SAAS,eAAe,eAAe,SAAS,eAAe,eAAe,MAAM,IAAI,CAAC;EAE/F,YACQ,MAAM,gBACN;GAC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U,MAAM,OAAO,CAAC;IAChC,YAAY,YAAY,MAAM,QAAQ,CAAC;IACvC,YAAY,kBAAkB,MAAM,cAAc,CAAC;IACnD,YAAY,YAAY,MAAM,QAAQ,CAAC;IACvC,YAAY,gBAAgB,MAAM,WAAW,CAAC;IAC9C,YAAY,aAAa,MAAM,SAAS,CAAC;IACzC,YAAY,UAAU,MAAM,MAAM,MAAM,MAAM,OAAO,CAAC,EAAE,WAAW,SAAS,IAAI,IAAI,OAAO,OAAU;IAErG,OAAO;KAAE;KAAM,OAAO,MAAM,MAAM;IAAE;GACtC,CAAC;EACH;EACA,SAAS,UAAU;GACjB,MAAM,QAAQ,UAAW,eAAe,QAAQ,OAAQ;IAAE,WAAW;IAAM,OAAO;GAAO,CAAC;EAC5F;CACF,CAAC;CAED,MAAM,aAAa,oBAAoB,GAAG;CAG1C,IAAI,CAFY,mBAEL,CAAC,CAAC,SAAS,CAAC,YAAY;CAEnC,IAAI,YAAY,QAAQ;EACtB,kBAAkB,eAAe,CAAC,CAAC,QAAQ;EAC3C,kBAAkB,iBAAiB,CAAC,CAAC,QAAQ;CAC/C;CAEA,mBACE,gBACC,OAAO;EACN,OAAO,gBAAgB,IAAI,IAAI,GAAG,UAAU,IAAI,MAAM,GAAG,UAAU;CACrE,GACA,EAAE,QAAQ,KAAK,CACjB;AACF,CAAC"}
@@ -1,4 +1,4 @@
1
- import { c as CMS_PREVIEW_READ_PATH, r as CMS_DELIVERY_READ_PATH } from "../../HttpPaths-c9nLZ9H2.js";
1
+ import { c as CMS_PREVIEW_READ_PATH, r as CMS_DELIVERY_READ_PATH } from "../../HttpPaths-Be3vshPJ.js";
2
2
  import { usePreviewDelivery } from "./context.js";
3
3
  import { computed, toValue } from "vue";
4
4
  import { useFetch } from "nuxt/app";
@@ -1,4 +1,4 @@
1
- import { n as CMS_DELIVERY_QUERY_PATH, s as CMS_PREVIEW_QUERY_PATH } from "../../HttpPaths-c9nLZ9H2.js";
1
+ import { n as CMS_DELIVERY_QUERY_PATH, s as CMS_PREVIEW_QUERY_PATH } from "../../HttpPaths-Be3vshPJ.js";
2
2
  import { usePreviewDelivery } from "./context.js";
3
3
  import { computed, toValue } from "vue";
4
4
  import { useFetch } from "nuxt/app";
@@ -1,4 +1,4 @@
1
- import { a as CMS_FORM_SUBMIT_PATH } from "../../HttpPaths-c9nLZ9H2.js";
1
+ import { a as CMS_FORM_SUBMIT_PATH } from "../../HttpPaths-Be3vshPJ.js";
2
2
  import { o as FormResult } from "../../Forms-CfNPTiCr.js";
3
3
  import { i as validateFormValues } from "../../Forms-CX-hwmJF.js";
4
4
  import { Result, Schema } from "effect";
@@ -2,13 +2,20 @@
2
2
  function localeFromPath(configuration, path) {
3
3
  return prefixedLocale(configuration, path) ?? configuration.defaultLocale;
4
4
  }
5
+ /** Returns the canonical localized form of a site path. */
6
+ function canonicalLocalePath(configuration, path) {
7
+ const { pathname, suffix } = splitSitePath(path);
8
+ const prefix = prefixedLocale(configuration, pathname);
9
+ const locale = prefix ?? configuration.defaultLocale;
10
+ return `${localePath(configuration, prefix === void 0 ? pathname : pathname === `/${prefix}` ? "/" : pathname.slice(prefix.length + 1), locale)}${suffix}`;
11
+ }
5
12
  /** Prefixes a site path according to the configured locale URL policy. */
6
13
  function localePath(configuration, path, locale) {
7
14
  const { pathname, suffix } = splitSitePath(path);
8
15
  if (!pathname.startsWith("/") || pathname.startsWith("//")) throw new Error("A locale path must start with one slash.");
9
16
  if (!configuration.defaultLocale) return path;
10
17
  if (!Object.hasOwn(configuration.locales, locale)) throw new Error(`Unknown locale "${locale}".`);
11
- return `${`${locale === configuration.defaultLocale && !configuration.prefixDefaultLocale ? "" : `/${locale}`}${pathname === "/" ? "" : pathname}` || "/"}${suffix}`;
18
+ return `${`${locale === configuration.defaultLocale && configuration.prefix !== "always" ? "" : `/${locale}`}${pathname === "/" ? "" : pathname}` || "/"}${suffix}`;
12
19
  }
13
20
  /** Switches the locale prefix of a site path while preserving its query and fragment. */
14
21
  function switchLocalePath(configuration, path, locale) {
@@ -23,7 +30,7 @@ function switchLocalePath(configuration, path, locale) {
23
30
  }
24
31
  function prefixedLocale(configuration, path) {
25
32
  const segment = path.split("/")[1] ?? "";
26
- return Object.hasOwn(configuration.locales, segment) && (segment !== configuration.defaultLocale || configuration.prefixDefaultLocale) ? segment : void 0;
33
+ return Object.hasOwn(configuration.locales, segment) ? segment : void 0;
27
34
  }
28
35
  function splitSitePath(path) {
29
36
  const suffixIndex = path.search(/[?#]/u);
@@ -47,5 +54,5 @@ function translate(configuration, locale, key, parameters = {}, missing) {
47
54
  }
48
55
 
49
56
  //#endregion
50
- export { localeFromPath, localePath, switchLocalePath, translate };
57
+ export { canonicalLocalePath, localeFromPath, localePath, switchLocalePath, translate };
51
58
  //# sourceMappingURL=translator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"translator.js","names":[],"sources":["../../../../../src/runtime/i18n/translator.ts"],"sourcesContent":["import type { CompiledCmsI18n } from '../../internal/i18n'\n\nexport function localeFromPath(configuration: CompiledCmsI18n, path: string): string {\n return prefixedLocale(configuration, path) ?? configuration.defaultLocale\n}\n\n/** Prefixes a site path according to the configured locale URL policy. */\nexport function localePath(configuration: CompiledCmsI18n, path: string, locale: string): string {\n const { pathname, suffix } = splitSitePath(path)\n\n if (!pathname.startsWith('/') || pathname.startsWith('//'))\n throw new Error('A locale path must start with one slash.')\n\n if (!configuration.defaultLocale) return path\n\n if (!Object.hasOwn(configuration.locales, locale)) throw new Error(`Unknown locale \"${locale}\".`)\n\n const prefix = locale === configuration.defaultLocale && !configuration.prefixDefaultLocale ? '' : `/${locale}`\n const localized = `${prefix}${pathname === '/' ? '' : pathname}` || '/'\n\n return `${localized}${suffix}`\n}\n\n/** Switches the locale prefix of a site path while preserving its query and fragment. */\nexport function switchLocalePath(configuration: CompiledCmsI18n, path: string, locale: string): string {\n const { pathname, suffix } = splitSitePath(path)\n const current = prefixedLocale(configuration, pathname)\n let unprefixed = pathname\n\n if (current !== undefined) {\n const prefix = `/${current}`\n\n unprefixed = pathname === prefix ? '/' : pathname.slice(prefix.length)\n }\n\n return `${localePath(configuration, unprefixed, locale)}${suffix}`\n}\n\nfunction prefixedLocale(configuration: CompiledCmsI18n, path: string): string | undefined {\n const segment = path.split('/')[1] ?? ''\n\n return Object.hasOwn(configuration.locales, segment) &&\n (segment !== configuration.defaultLocale || configuration.prefixDefaultLocale)\n ? segment\n : undefined\n}\n\nfunction splitSitePath(path: string) {\n const suffixIndex = path.search(/[?#]/u)\n\n return {\n pathname: suffixIndex === -1 ? path : path.slice(0, suffixIndex),\n suffix: suffixIndex === -1 ? '' : path.slice(suffixIndex),\n }\n}\n\nexport function translate(\n configuration: CompiledCmsI18n,\n locale: string,\n key: string,\n parameters: Readonly<Record<string, string | number>> = {},\n missing?: (key: string, locale: string) => void,\n): string {\n function lookup(code: string): string | undefined {\n const messages = Object.hasOwn(configuration.locales, code) ? configuration.locales[code]?.messages : undefined\n\n return messages && Object.hasOwn(messages, key) ? messages[key] : undefined\n }\n\n let message = lookup(locale)\n\n if (message === undefined) {\n missing?.(key, locale)\n message = configuration.fallbackLocale === null ? undefined : lookup(configuration.fallbackLocale)\n }\n\n if (message === undefined) return key\n\n return message.replace(/\\{([\\w]+)\\}/gu, (placeholder: string, name: string) =>\n Object.hasOwn(parameters, name) ? String(parameters[name]) : placeholder,\n )\n}\n"],"mappings":";AAEA,SAAgB,eAAe,eAAgC,MAAsB;CACnF,OAAO,eAAe,eAAe,IAAI,KAAK,cAAc;AAC9D;;AAGA,SAAgB,WAAW,eAAgC,MAAc,QAAwB;CAC/F,MAAM,EAAE,UAAU,WAAW,cAAc,IAAI;CAE/C,IAAI,CAAC,SAAS,WAAW,GAAG,KAAK,SAAS,WAAW,IAAI,GACvD,MAAM,IAAI,MAAM,0CAA0C;CAE5D,IAAI,CAAC,cAAc,eAAe,OAAO;CAEzC,IAAI,CAAC,OAAO,OAAO,cAAc,SAAS,MAAM,GAAG,MAAM,IAAI,MAAM,mBAAmB,OAAO,GAAG;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,kBAAkB,aAAqB,SAC5D,OAAO,OAAO,YAAY,IAAI,IAAI,OAAO,WAAW,KAAK,IAAI,WAC/D;AACF"}
1
+ {"version":3,"file":"translator.js","names":[],"sources":["../../../../../src/runtime/i18n/translator.ts"],"sourcesContent":["import type { CompiledCmsI18n } from '../../internal/i18n'\n\nexport function localeFromPath(configuration: CompiledCmsI18n, path: string): string {\n return prefixedLocale(configuration, path) ?? configuration.defaultLocale\n}\n\n/** Returns the canonical localized form of a site path. */\nexport function canonicalLocalePath(configuration: CompiledCmsI18n, path: string): string {\n const { pathname, suffix } = splitSitePath(path)\n const prefix = prefixedLocale(configuration, pathname)\n const locale = prefix ?? configuration.defaultLocale\n\n const unprefixed =\n prefix === undefined ? pathname : pathname === `/${prefix}` ? '/' : pathname.slice(prefix.length + 1)\n\n return `${localePath(configuration, unprefixed, locale)}${suffix}`\n}\n\n/** Prefixes a site path according to the configured locale URL policy. */\nexport function localePath(configuration: CompiledCmsI18n, path: string, locale: string): string {\n const { pathname, suffix } = splitSitePath(path)\n\n if (!pathname.startsWith('/') || pathname.startsWith('//'))\n throw new Error('A locale path must start with one slash.')\n\n if (!configuration.defaultLocale) return path\n\n if (!Object.hasOwn(configuration.locales, locale)) throw new Error(`Unknown locale \"${locale}\".`)\n\n const prefix = locale === configuration.defaultLocale && configuration.prefix !== 'always' ? '' : `/${locale}`\n const localized = `${prefix}${pathname === '/' ? '' : pathname}` || '/'\n\n return `${localized}${suffix}`\n}\n\n/** Switches the locale prefix of a site path while preserving its query and fragment. */\nexport function switchLocalePath(configuration: CompiledCmsI18n, path: string, locale: string): string {\n const { pathname, suffix } = splitSitePath(path)\n const current = prefixedLocale(configuration, pathname)\n let unprefixed = pathname\n\n if (current !== undefined) {\n const prefix = `/${current}`\n\n unprefixed = pathname === prefix ? '/' : pathname.slice(prefix.length)\n }\n\n return `${localePath(configuration, unprefixed, locale)}${suffix}`\n}\n\nfunction prefixedLocale(configuration: CompiledCmsI18n, path: string): string | undefined {\n const segment = path.split('/')[1] ?? ''\n\n return Object.hasOwn(configuration.locales, segment) ? segment : undefined\n}\n\nfunction splitSitePath(path: string) {\n const suffixIndex = path.search(/[?#]/u)\n\n return {\n pathname: suffixIndex === -1 ? path : path.slice(0, suffixIndex),\n suffix: suffixIndex === -1 ? '' : path.slice(suffixIndex),\n }\n}\n\nexport function translate(\n configuration: CompiledCmsI18n,\n locale: string,\n key: string,\n parameters: Readonly<Record<string, string | number>> = {},\n missing?: (key: string, locale: string) => void,\n): string {\n function lookup(code: string): string | undefined {\n const messages = Object.hasOwn(configuration.locales, code) ? configuration.locales[code]?.messages : undefined\n\n return messages && Object.hasOwn(messages, key) ? messages[key] : undefined\n }\n\n let message = lookup(locale)\n\n if (message === undefined) {\n missing?.(key, locale)\n message = configuration.fallbackLocale === null ? undefined : lookup(configuration.fallbackLocale)\n }\n\n if (message === undefined) return key\n\n return message.replace(/\\{([\\w]+)\\}/gu, (placeholder: string, name: string) =>\n Object.hasOwn(parameters, name) ? String(parameters[name]) : placeholder,\n )\n}\n"],"mappings":";AAEA,SAAgB,eAAe,eAAgC,MAAsB;CACnF,OAAO,eAAe,eAAe,IAAI,KAAK,cAAc;AAC9D;;AAGA,SAAgB,oBAAoB,eAAgC,MAAsB;CACxF,MAAM,EAAE,UAAU,WAAW,cAAc,IAAI;CAC/C,MAAM,SAAS,eAAe,eAAe,QAAQ;CACrD,MAAM,SAAS,UAAU,cAAc;CAKvC,OAAO,GAAG,WAAW,eAFnB,WAAW,SAAY,WAAW,aAAa,IAAI,WAAW,MAAM,SAAS,MAAM,OAAO,SAAS,CAAC,GAEtD,MAAM,IAAI;AAC5D;;AAGA,SAAgB,WAAW,eAAgC,MAAc,QAAwB;CAC/F,MAAM,EAAE,UAAU,WAAW,cAAc,IAAI;CAE/C,IAAI,CAAC,SAAS,WAAW,GAAG,KAAK,SAAS,WAAW,IAAI,GACvD,MAAM,IAAI,MAAM,0CAA0C;CAE5D,IAAI,CAAC,cAAc,eAAe,OAAO;CA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nG;CAEA,IAAI,YAAY,QAAW,OAAO;CAElC,OAAO,QAAQ,QAAQ,kBAAkB,aAAqB,SAC5D,OAAO,OAAO,YAAY,IAAI,IAAI,OAAO,WAAW,KAAK,IAAI,WAC/D;AACF"}
@@ -1,4 +1,4 @@
1
- import { a as CmsMessageParameters, i as CmsMessageKey, r as CmsLocale } from "../../I18n-zbqpWxki.js";
1
+ import { a as CmsMessageParameters, i as CmsMessageKey, r as CmsLocale } from "../../I18n-wxswIRyY.js";
2
2
  import { ComputedRef } from "vue";
3
3
  //#region src/runtime/i18n/useCmsI18n.d.ts
4
4
  export interface UseCmsI18nReturn {
@@ -1,3 +1,3 @@
1
- import { n as scopedDatabaseUrl, r as toS3MediaObjectStoreOptions, t as installCms } from "../installation-DYNQQBD3.js";
1
+ import { n as scopedDatabaseUrl, r as toS3MediaObjectStoreOptions, t as installCms } from "../installation-DxqSSVbH.js";
2
2
 
3
3
  export { installCms, scopedDatabaseUrl, toS3MediaObjectStoreOptions };
@@ -1,5 +1,5 @@
1
1
  import { resolveCmsInstallation } from "../internal/configuration.js";
2
- import { t as installCms } from "../installation-DYNQQBD3.js";
2
+ import { t as installCms } from "../installation-DxqSSVbH.js";
3
3
  import { diagnosticFromCause, renderDiagnostic } from "../internal/diagnostics.js";
4
4
  import { Effect } from "effect";
5
5
  import { defineNitroPlugin, useNitroApp, useRuntimeConfig } from "nitropack/runtime";
@@ -1,5 +1,5 @@
1
1
  import { Y as SitemapEntry } from "../models-VmGmG19-.js";
2
- import { i as CMS_DELIVERY_SITEMAP_PATH } from "../HttpPaths-c9nLZ9H2.js";
2
+ import { i as CMS_DELIVERY_SITEMAP_PATH } from "../HttpPaths-Be3vshPJ.js";
3
3
  import { useCmsInstallation } from "./plugin.js";
4
4
  import { toNuxtSitemapEntries } from "./sitemap-entries.js";
5
5
  import { Schema } from "effect";
@@ -1,10 +1,10 @@
1
- import { d as STUDIO_APP_PATH } from "../HttpPaths-c9nLZ9H2.js";
1
+ import { d as STUDIO_BASE_PATH } from "../HttpPaths-Be3vshPJ.js";
2
2
 
3
3
  //#region src/runtime/studio-document.ts
4
4
  function resolveStudioRoot(document, pathname) {
5
5
  const root = document.getElementById("cms-studio");
6
6
  if (root) return root;
7
- if (pathname !== STUDIO_APP_PATH && !pathname.startsWith(`${STUDIO_APP_PATH}/`)) return null;
7
+ if (pathname !== "/_cms" && !pathname.startsWith(`${"/_cms"}/`)) return null;
8
8
  const created = document.createElement("div");
9
9
  created.id = "cms-studio";
10
10
  document.body.replaceChildren(created);
@@ -1 +1 @@
1
- {"version":3,"file":"studio-document.js","names":[],"sources":["../../../../src/runtime/studio-document.ts"],"sourcesContent":["import type { AuthoringCatalog } from '@internal/protocol/Configuration'\nimport { STUDIO_APP_PATH } from '@internal/protocol/HttpPaths'\n\ninterface MountedStudio {\n readonly unmount: () => void\n readonly updateAuthoring: (catalog: AuthoringCatalog) => void\n}\n\ninterface StudioDocument {\n readonly unmount: () => void\n readonly updateAuthoring: (catalog: AuthoringCatalog) => void\n}\n\nexport function resolveStudioRoot(document: Document, pathname: string): HTMLElement | null {\n const root = document.getElementById('cms-studio')\n\n if (root) return root\n\n if (pathname !== STUDIO_APP_PATH && !pathname.startsWith(`${STUDIO_APP_PATH}/`)) return null\n\n const created = document.createElement('div')\n created.id = 'cms-studio'\n document.body.replaceChildren(created)\n\n return created\n}\n\nexport function startStudioDocument(\n root: HTMLElement | null,\n catalog: AuthoringCatalog,\n stylesheet: string,\n mountStudio: (root: HTMLElement, catalog: AuthoringCatalog) => MountedStudio,\n): StudioDocument {\n if (!root) return { unmount: () => undefined, updateAuthoring: () => undefined }\n\n let currentCatalog = catalog\n let studio: MountedStudio | undefined\n const link = document.createElement('link')\n link.rel = 'stylesheet'\n link.href = stylesheet\n link.onload = () => {\n studio = mountStudio(root, currentCatalog)\n }\n\n link.onerror = () => {\n root.textContent = 'CMS Studio styles could not load. Reload this page to retry.'\n }\n\n document.head.append(link)\n\n return {\n unmount() {\n link.onload = null\n link.onerror = null\n studio?.unmount()\n link.remove()\n },\n updateAuthoring(next: AuthoringCatalog) {\n currentCatalog = next\n studio?.updateAuthoring(next)\n },\n }\n}\n"],"mappings":";;;AAaA,SAAgB,kBAAkB,UAAoB,UAAsC;CAC1F,MAAM,OAAO,SAAS,eAAe,YAAY;CAEjD,IAAI,MAAM,OAAO;CAEjB,IAAI,aAAa,mBAAmB,CAAC,SAAS,WAAW,GAAG,gBAAgB,EAAE,GAAG,OAAO;CAExF,MAAM,UAAU,SAAS,cAAc,KAAK;CAC5C,QAAQ,KAAK;CACb,SAAS,KAAK,gBAAgB,OAAO;CAErC,OAAO;AACT;AAEA,SAAgB,oBACd,MACA,SACA,YACA,aACgB;CAChB,IAAI,CAAC,MAAM,OAAO;EAAE,eAAe;EAAW,uBAAuB;CAAU;CAE/E,IAAI,iBAAiB;CACrB,IAAI;CACJ,MAAM,OAAO,SAAS,cAAc,MAAM;CAC1C,KAAK,MAAM;CACX,KAAK,OAAO;CACZ,KAAK,eAAe;EAClB,SAAS,YAAY,MAAM,cAAc;CAC3C;CAEA,KAAK,gBAAgB;EACnB,KAAK,cAAc;CACrB;CAEA,SAAS,KAAK,OAAO,IAAI;CAEzB,OAAO;EACL,UAAU;GACR,KAAK,SAAS;GACd,KAAK,UAAU;GACf,QAAQ,QAAQ;GAChB,KAAK,OAAO;EACd;EACA,gBAAgB,MAAwB;GACtC,iBAAiB;GACjB,QAAQ,gBAAgB,IAAI;EAC9B;CACF;AACF"}
1
+ {"version":3,"file":"studio-document.js","names":[],"sources":["../../../../src/runtime/studio-document.ts"],"sourcesContent":["import type { AuthoringCatalog } from '@internal/protocol/Configuration'\nimport { STUDIO_BASE_PATH } from '@internal/protocol/HttpPaths'\n\ninterface MountedStudio {\n readonly unmount: () => void\n readonly updateAuthoring: (catalog: AuthoringCatalog) => void\n}\n\ninterface StudioDocument {\n readonly unmount: () => void\n readonly updateAuthoring: (catalog: AuthoringCatalog) => void\n}\n\nexport function resolveStudioRoot(document: Document, pathname: string): HTMLElement | null {\n const root = document.getElementById('cms-studio')\n\n if (root) return root\n\n if (pathname !== STUDIO_BASE_PATH && !pathname.startsWith(`${STUDIO_BASE_PATH}/`)) return null\n\n const created = document.createElement('div')\n created.id = 'cms-studio'\n document.body.replaceChildren(created)\n\n return created\n}\n\nexport function startStudioDocument(\n root: HTMLElement | null,\n catalog: AuthoringCatalog,\n stylesheet: string,\n mountStudio: (root: HTMLElement, catalog: AuthoringCatalog) => MountedStudio,\n): StudioDocument {\n if (!root) return { unmount: () => undefined, updateAuthoring: () => undefined }\n\n let currentCatalog = catalog\n let studio: MountedStudio | undefined\n const link = document.createElement('link')\n link.rel = 'stylesheet'\n link.href = stylesheet\n link.onload = () => {\n studio = mountStudio(root, currentCatalog)\n }\n\n link.onerror = () => {\n root.textContent = 'CMS Studio styles could not load. Reload this page to retry.'\n }\n\n document.head.append(link)\n\n return {\n unmount() {\n link.onload = null\n link.onerror = null\n studio?.unmount()\n link.remove()\n },\n updateAuthoring(next: AuthoringCatalog) {\n currentCatalog = next\n studio?.updateAuthoring(next)\n },\n }\n}\n"],"mappings":";;;AAaA,SAAgB,kBAAkB,UAAoB,UAAsC;CAC1F,MAAM,OAAO,SAAS,eAAe,YAAY;CAEjD,IAAI,MAAM,OAAO;CAEjB,IAAI,wBAAiC,CAAC,SAAS,WAAW,WAAoB,EAAE,GAAG,OAAO;CAE1F,MAAM,UAAU,SAAS,cAAc,KAAK;CAC5C,QAAQ,KAAK;CACb,SAAS,KAAK,gBAAgB,OAAO;CAErC,OAAO;AACT;AAEA,SAAgB,oBACd,MACA,SACA,YACA,aACgB;CAChB,IAAI,CAAC,MAAM,OAAO;EAAE,eAAe;EAAW,uBAAuB;CAAU;CAE/E,IAAI,iBAAiB;CACrB,IAAI;CACJ,MAAM,OAAO,SAAS,cAAc,MAAM;CAC1C,KAAK,MAAM;CACX,KAAK,OAAO;CACZ,KAAK,eAAe;EAClB,SAAS,YAAY,MAAM,cAAc;CAC3C;CAEA,KAAK,gBAAgB;EACnB,KAAK,cAAc;CACrB;CAEA,SAAS,KAAK,OAAO,IAAI;CAEzB,OAAO;EACL,UAAU;GACR,KAAK,SAAS;GACd,KAAK,UAAU;GACf,QAAQ,QAAQ;GAChB,KAAK,OAAO;EACd;EACA,gBAAgB,MAAwB;GACtC,iBAAiB;GACjB,QAAQ,gBAAgB,IAAI;EAC9B;CACF;AACF"}
@@ -1,9 +1,9 @@
1
- import { d as STUDIO_APP_PATH, f as STUDIO_BASE_PATH } from "../HttpPaths-c9nLZ9H2.js";
1
+ import { d as STUDIO_BASE_PATH } from "../HttpPaths-Be3vshPJ.js";
2
2
  import { defineNuxtRouteMiddleware, navigateTo } from "nuxt/app";
3
3
 
4
4
  //#region src/runtime/studio-navigation.ts
5
5
  var studio_navigation_default = defineNuxtRouteMiddleware((to) => {
6
- if (to.path === "/_cms" || to.path === STUDIO_APP_PATH || to.path.startsWith(`${STUDIO_APP_PATH}/`)) return navigateTo(to.fullPath, { external: true });
6
+ if (to.path === "/_cms" || to.path.startsWith(`${"/_cms"}/`)) return navigateTo(to.fullPath, { external: true });
7
7
  });
8
8
 
9
9
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"studio-navigation.js","names":[],"sources":["../../../../src/runtime/studio-navigation.ts"],"sourcesContent":["import { defineNuxtRouteMiddleware, navigateTo } from 'nuxt/app'\nimport { STUDIO_APP_PATH, STUDIO_BASE_PATH } from '@internal/protocol/HttpPaths'\n\nexport default defineNuxtRouteMiddleware((to) => {\n if (to.path === STUDIO_BASE_PATH || to.path === STUDIO_APP_PATH || to.path.startsWith(`${STUDIO_APP_PATH}/`)) {\n return navigateTo(to.fullPath, { external: true })\n }\n})\n"],"mappings":";;;;AAGA,gCAAe,2BAA2B,OAAO;CAC/C,IAAI,GAAG,oBAA6B,GAAG,SAAS,mBAAmB,GAAG,KAAK,WAAW,GAAG,gBAAgB,EAAE,GACzG,OAAO,WAAW,GAAG,UAAU,EAAE,UAAU,KAAK,CAAC;AAErD,CAAC"}
1
+ {"version":3,"file":"studio-navigation.js","names":[],"sources":["../../../../src/runtime/studio-navigation.ts"],"sourcesContent":["import { defineNuxtRouteMiddleware, navigateTo } from 'nuxt/app'\nimport { STUDIO_BASE_PATH } from '@internal/protocol/HttpPaths'\n\nexport default defineNuxtRouteMiddleware((to) => {\n if (to.path === STUDIO_BASE_PATH || to.path.startsWith(`${STUDIO_BASE_PATH}/`)) {\n return navigateTo(to.fullPath, { external: true })\n }\n})\n"],"mappings":";;;;AAGA,gCAAe,2BAA2B,OAAO;CAC/C,IAAI,GAAG,oBAA6B,GAAG,KAAK,WAAW,WAAoB,EAAE,GAC3E,OAAO,WAAW,GAAG,UAAU,EAAE,UAAU,KAAK,CAAC;AAErD,CAAC"}