@bettercms-ai/astro 0.28.3 → 0.29.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -16,6 +16,7 @@ export { DRAFT_COOKIE } from '@bettercms-ai/sdk/draft';
16
16
  * `bettercms:client` → server runtime (client + typed loaders) — has the key.
17
17
  * `bettercms:config` → browser-safe public config — no secrets.
18
18
  * - Adds the draft-mode middleware and injects the draft enable/disable routes.
19
+ * - Stamps `<meta name="generator" content="BetterCMS">` into every prerendered page.
19
20
  */
20
21
 
21
22
  declare function bettercms(options?: BetterCMSAstroOptions): AstroIntegration;
package/dist/index.js CHANGED
@@ -68,6 +68,26 @@ function toPublicConfig(c) {
68
68
  return pub;
69
69
  }
70
70
 
71
+ // src/generator.ts
72
+ import { readdir, readFile, writeFile } from "fs/promises";
73
+ import { join } from "path";
74
+ import { fileURLToPath } from "url";
75
+ var GENERATOR_META = '<meta name="generator" content="BetterCMS">';
76
+ function withGenerator(html) {
77
+ const at = html.search(/<\/head>/i);
78
+ return at < 0 || html.includes(GENERATOR_META) ? html : html.slice(0, at) + GENERATOR_META + html.slice(at);
79
+ }
80
+ async function stampGenerator(dir) {
81
+ const root = fileURLToPath(dir);
82
+ for (const file of await readdir(root, { recursive: true })) {
83
+ if (!file.endsWith(".html")) continue;
84
+ const path = join(root, file);
85
+ const html = await readFile(path, "utf8");
86
+ const stamped = withGenerator(html);
87
+ if (stamped !== html) await writeFile(path, stamped);
88
+ }
89
+ }
90
+
71
91
  // src/integration.ts
72
92
  var CLIENT_ID = "bettercms:client";
73
93
  var CONFIG_ID = "bettercms:config";
@@ -193,7 +213,9 @@ function bettercms(options = {}) {
193
213
  */
194
214
  "astro:build:start": () => {
195
215
  decide?.();
196
- }
216
+ },
217
+ /** Names BetterCMS in every prerendered page's `<head>`: see generator.ts. */
218
+ "astro:build:done": ({ dir }) => stampGenerator(dir)
197
219
  }
198
220
  };
199
221
  }
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/config.ts","../src/public-config.ts","../src/integration.ts","../src/runtime.ts","../src/index.ts","../src/section-root.ts","../src/field-attrs.ts"],"sourcesContent":["/**\n * Resolved configuration shared by the integration, runtime, middleware and\n * draft routes. Public values are safe to ship to the browser; the API key and\n * draft secret are read from server env at runtime and never live here.\n *\n * Resolution order is options → `PUBLIC_BCMS_*` env → the build snapshot. Config-time\n * only: this module is reached exclusively through `dist/index.js`, which only an\n * `astro.config.*` imports, so the `node:fs` read below never enters a client bundle.\n * Browser code gets the `bettercms:config` virtual module instead.\n */\n\nimport { readFileSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\n\nimport { resolveBcmsConfig } from \"@bettercms-ai/sdk/config\";\n\nimport { DRAFT_COOKIE } from \"./public-config.js\";\n\nexport { DRAFT_COOKIE };\nconst SNAPSHOT_FILE = \"bcms-content.json\";\n\nexport interface BetterCMSAstroOptions {\n /** Backend base, e.g. `https://api.bettercms.ai`. Falls back to `PUBLIC_BCMS_API_URL`. */\n apiUrl?: string;\n /** Workspace slug. Falls back to `PUBLIC_BCMS_WORKSPACE`. */\n workspace?: string;\n /** Optional project scope for forms. Falls back to `PUBLIC_BCMS_PROJECT_ID`. */\n projectId?: string;\n /** Media host for the image-url builder. Defaults to the prod media host. */\n mediaUrl?: string;\n /** Dashboard base for visual-editing deep links. */\n studioUrl?: string;\n /** Enable the draft-mode middleware + injected draft routes. Default true. */\n draft?: boolean;\n}\n\n/** Browser-safe config — exposed via the `bettercms:config` virtual module. */\nexport interface PublicConfig {\n apiUrl: string;\n workspace: string;\n projectId?: string;\n mediaUrl: string;\n studioUrl?: string;\n draftCookie: string;\n}\n\nexport interface ResolvedConfig extends PublicConfig {\n draft: boolean;\n}\n\n/** The fields of the deploy Action's content snapshot that identify the site. */\ninterface Snapshot {\n apiUrl?: string;\n workspace?: string;\n projectId?: string;\n}\n\n/**\n * Read `bcms-content.json` — the snapshot the deploy Action writes next to the build,\n * BEFORE `astro build` runs — which already carries the workspace this site belongs to.\n *\n * This is what lets `bettercms()` work with no arguments and no env at all. Not reading it\n * was the whole bug: a hosted build had the answer sitting in its own working directory and\n * threw anyway, and every starter template had to reimplement this by hand to survive.\n *\n * Lazy: only consulted when options and env both miss, so the configured path does no I/O.\n * Absent/corrupt file ⇒ `{}`, and the caller raises the actionable error below.\n */\nlet snapshotCache: Snapshot | undefined;\nfunction snapshot(cwd: string): Snapshot {\n if (snapshotCache === undefined) {\n try {\n snapshotCache = JSON.parse(readFileSync(resolve(cwd, SNAPSHOT_FILE), \"utf8\")) as Snapshot;\n } catch {\n snapshotCache = {};\n }\n }\n return snapshotCache;\n}\n\n/** Test seam — the snapshot is memoised for the life of the process. */\nexport function resetSnapshotCache(): void {\n snapshotCache = undefined;\n}\n\nconst required = (name: string, envVar: string, extra: string) =>\n new Error(\n `[@bettercms-ai/astro] \\`${name}\\` is required. Pass \\`bettercms({ ${name} })\\`, set ` +\n `${envVar}, or ${extra}\\n` +\n `On BetterCMS hosting these are injected automatically — if this failed in a hosted ` +\n `build, the repository is running an outdated deploy workflow: publish once, or save ` +\n `Hosting settings, to refresh it.`,\n );\n\n/**\n * Merge integration options with `PUBLIC_BCMS_*` env and the build snapshot, validating the\n * essentials. Precedence: explicit options → env → snapshot.\n */\nexport function resolveConfig(\n options: BetterCMSAstroOptions,\n env: Record<string, string | undefined> = process.env,\n cwd: string = process.cwd(),\n): ResolvedConfig {\n // The precedence every adapter shares (@bettercms-ai/sdk/config); the words of the error are Astro's.\n const { config, missing } = resolveBcmsConfig({ options, env, prefixes: [\"PUBLIC_\"], snapshot: () => snapshot(cwd) });\n // No default origin on purpose: guessing one produces a site that builds cleanly against\n // the wrong backend, which is far harder to notice than this error.\n if (missing.includes(\"apiUrl\")) throw required(\"apiUrl\", \"PUBLIC_BCMS_API_URL\", `run the content fetch so ${SNAPSHOT_FILE} is present.`);\n if (missing.includes(\"workspace\")) {\n throw required(\"workspace\", \"PUBLIC_BCMS_WORKSPACE\", `run the content fetch so ${SNAPSHOT_FILE} is present.`);\n }\n return { ...config, draftCookie: DRAFT_COOKIE, draft: options.draft ?? true };\n}\n\nexport function toPublicConfig(c: ResolvedConfig): PublicConfig {\n const { draft: _draft, ...pub } = c;\n return pub;\n}\n","/**\n * The public config the shipped components read (`BcmsImage`, `BcmsForm`).\n *\n * Where `bettercms()` is registered, its Vite plugin answers this very specifier with the config it\n * resolved, options included (@see integration.ts). Where it is not, this file is what resolves:\n * the same values from the build's environment and its content snapshot.\n *\n * WHY A REAL MODULE. The components imported the virtual `bettercms:config`, which only the\n * integration can resolve. A site that registers it conditionally (ScrewFast:\n * `...(bcmsReady ? [bettercms({})] : [])`) could not compile a page that imported `<BcmsBlocks>`,\n * so `<BcmsSections>` was given no block renderer there and a section added in the editor had\n * nothing to draw it.\n *\n * No `node:fs` import: this is bundled into a server render, an edge runtime's included. Read on\n * use, never once at module scope: a server's environment and snapshot are the run's.\n */\nimport { readPublishedContent } from \"@bettercms-ai/sdk\";\nimport type { PublicConfig } from \"./config.js\";\n\n/**\n * The platform's canonical media host, matching `@bettercms-ai/image-url`'s own\n * `DEFAULT_BASE_URL` and the `CDN_URL` the backend mints asset URLs on.\n *\n * This used to be `media.bettercms.ai`. Both hostnames route to the backend — they are both in\n * `$bcms_api_host` in infra/nginx/backend-lb.conf — so nothing was broken, but a site built by\n * this integration disagreed with the URL the server itself hands out for the same asset. That\n * splits the CDN cache for identical bytes and makes an asset URL's origin depend on which code\n * path produced it, which is the exact drift image-url was moved off this host to end.\n *\n * A project that serves media from the API origin instead (`useCdn: false`) overrides this with\n * `PUBLIC_BCMS_MEDIA_URL` or the `mediaUrl` option.\n */\nexport { DEFAULT_MEDIA_URL } from \"@bettercms-ai/sdk/config\";\nexport { DRAFT_COOKIE } from \"@bettercms-ai/sdk/draft\";\nimport { DEFAULT_MEDIA_URL } from \"@bettercms-ai/sdk/config\";\nimport { DRAFT_COOKIE } from \"@bettercms-ai/sdk/draft\";\n/** The specifier the components import, and the integration's plugin answers. */\nexport const PUBLIC_CONFIG_ID = \"@bettercms-ai/astro/public-config\";\n\n/** The server's runtime env first (hosting injects it), then the build's. */\nfunction env(name: string): string | undefined {\n const fromProcess = typeof process !== \"undefined\" ? process.env?.[name] : undefined;\n if (fromProcess) return fromProcess;\n try {\n return ((import.meta.env as Record<string, string | undefined> | undefined)?.[name]) || undefined;\n } catch {\n return undefined;\n }\n}\n\nconst trim = (url: string): string => url.replace(/\\/+$/, \"\");\nconst text = (value: unknown): string | undefined => (typeof value === \"string\" && value ? value : undefined);\n\n/**\n * The config with no integration: `PUBLIC_BCMS_*`, then the snapshot. Never throws: with neither,\n * `apiUrl` and `workspace` are empty, which a build that never talks to the API renders with.\n */\nexport function fallbackConfig(): PublicConfig {\n const snapshot = (readPublishedContent() ?? {}) as { apiUrl?: unknown; workspace?: unknown; projectId?: unknown };\n return {\n apiUrl: trim(env(\"PUBLIC_BCMS_API_URL\") ?? text(snapshot.apiUrl) ?? \"\"),\n workspace: env(\"PUBLIC_BCMS_WORKSPACE\") ?? text(snapshot.workspace) ?? \"\",\n projectId: env(\"PUBLIC_BCMS_PROJECT_ID\") ?? text(snapshot.projectId),\n mediaUrl: trim(env(\"PUBLIC_BCMS_MEDIA_URL\") ?? DEFAULT_MEDIA_URL),\n studioUrl: env(\"PUBLIC_BCMS_STUDIO_URL\"),\n draftCookie: DRAFT_COOKIE,\n };\n}\n\nconst KEYS = [\"apiUrl\", \"workspace\", \"projectId\", \"mediaUrl\", \"studioUrl\", \"draftCookie\"] as const;\n\nexport const config = Object.defineProperties(\n {},\n Object.fromEntries(KEYS.map((key) => [key, { enumerable: true, get: () => fallbackConfig()[key] }])),\n) as PublicConfig;\nexport default config;\n","/**\n * `bettercms()` — the Astro integration.\n *\n * - Registers two virtual modules:\n * `bettercms:client` → server runtime (client + typed loaders) — has the key.\n * `bettercms:config` → browser-safe public config — no secrets.\n * - Adds the draft-mode middleware and injects the draft enable/disable routes.\n */\nimport type { AstroIntegration } from \"astro\";\nimport {\n resolveConfig,\n toPublicConfig,\n type BetterCMSAstroOptions,\n type ResolvedConfig,\n} from \"./config.js\";\n\nimport { PUBLIC_CONFIG_ID } from \"./public-config.js\";\n\nconst CLIENT_ID = \"bettercms:client\";\nconst CONFIG_ID = \"bettercms:config\";\nconst RESOLVED = (id: string) => `\\0${id}`;\n\nfunction configModule(cfg: ResolvedConfig): string {\n return `export const config = ${JSON.stringify(toPublicConfig(cfg))};\\nexport default config;\\n`;\n}\n\nfunction clientModule(cfg: ResolvedConfig, buildCache: boolean): string {\n // The key is optional: published reads are addressed by the inlined projectId. When one is\n // set it is read from the server's env at run time (a server-output site gets it from its\n // host, not the build), falling back to the build's env; it never lands in a client bundle.\n return [\n `import { createRuntime } from \"@bettercms-ai/astro/runtime\";`,\n `const runtime = createRuntime({`,\n ` apiUrl: ${JSON.stringify(cfg.apiUrl)},`,\n ` workspace: ${JSON.stringify(cfg.workspace)},`,\n ` projectId: ${JSON.stringify(cfg.projectId)},`,\n ` apiKey: globalThis.process?.env?.BCMS_API_KEY ?? import.meta.env.BCMS_API_KEY,`,\n ` buildCache: ${JSON.stringify(buildCache)},`,\n `});`,\n `export const client = runtime.client;`,\n `export const getClient = runtime.getClient;`,\n `export const loadEntry = runtime.loadEntry;`,\n `export const loadEntries = runtime.loadEntries;`,\n `export const loadPage = runtime.loadPage;`,\n `export const loadComponents = runtime.loadComponents;`,\n `export const loadForms = runtime.loadForms;`,\n `export const loadLayout = runtime.loadLayout;`,\n `export default runtime;`,\n ].join(\"\\n\");\n}\n\nfunction virtualPlugin(cfg: ResolvedConfig, buildCache: () => boolean) {\n return {\n name: \"@bettercms-ai/astro:virtual\",\n // Before Vite's own resolver: `PUBLIC_CONFIG_ID` names a real file of this package, and a\n // plugin that runs after the resolver is never asked about a specifier it already resolved.\n enforce: \"pre\" as const,\n resolveId(id: string) {\n if (id === CLIENT_ID || id === CONFIG_ID) return RESOLVED(id);\n // The components' own import: answered with the config resolved here, options included.\n // Without this plugin it resolves to the package's file, which reads the environment.\n if (id === PUBLIC_CONFIG_ID) return RESOLVED(CONFIG_ID);\n return null;\n },\n load(id: string) {\n if (id === RESOLVED(CONFIG_ID)) return configModule(cfg);\n if (id === RESOLVED(CLIENT_ID)) return clientModule(cfg, buildCache());\n return null;\n },\n };\n}\n\nexport function bettercms(options: BetterCMSAstroOptions = {}): AstroIntegration {\n /**\n * Whether identical delivery GETs may be collapsed for the life of the process.\n *\n * Read lazily by the virtual module (see `astro:config:done` below) because only the\n * FINAL config settles `output` and `adapter` — another integration can add an adapter\n * after `astro:config:setup` runs.\n */\n const buildCache = { on: false, command: \"\", resolved: false };\n /** Set in `astro:config:done`, re-run in `astro:build:start` — see both hooks below. */\n let decide: (() => void) | undefined;\n\n return {\n name: \"@bettercms-ai/astro\",\n hooks: {\n \"astro:config:setup\": ({ command, updateConfig, addMiddleware, injectRoute, logger }) => {\n const cfg = resolveConfig(options);\n buildCache.command = command;\n\n updateConfig({ vite: { plugins: [virtualPlugin(cfg, () => buildCache.on)] } });\n\n if (cfg.draft) {\n addMiddleware({ entrypoint: \"@bettercms-ai/astro/middleware\", order: \"pre\" });\n injectRoute({\n pattern: \"/api/bcms/draft/enable\",\n entrypoint: \"@bettercms-ai/astro/draft-enable\",\n prerender: false,\n });\n injectRoute({\n pattern: \"/api/bcms/draft/disable\",\n entrypoint: \"@bettercms-ai/astro/draft-disable\",\n prerender: false,\n });\n logger.info(\"draft mode enabled — /api/bcms/draft/{enable,disable} injected\");\n }\n },\n\n /**\n * Decide whether the build-time request cache is safe, on the FINAL config.\n *\n * A fully static build renders every route from one published dataset, so identical\n * delivery GETs can collapse to a single round-trip. Without that a large site\n * re-fetched its nav/settings/collections once PER ROUTE and exhausted the delivery\n * rate limit mid-build — a 429 the build could not avoid.\n *\n * `command === \"build\"` is NOT sufficient to detect that, and getting this wrong is\n * far worse than the problem it solves: Astro also reports `command === \"build\"` when\n * it compiles `output: \"server\"`, whose bundle then runs as a LONG-LIVED process. A\n * module-lifetime cache there would pin the first response for every URL and serve it\n * to unrelated visitors until the process restarted — permanent stale content on a\n * production site.\n *\n * `buildOutput` (Astro 5) is Astro's OWN answer to \"will this emit a server?\", so it\n * is what we trust when present. Inferring it from `config.adapter` is not equivalent:\n * `setAdapter()` is documented as being called from inside `astro:config:done`, so an\n * adapter integration whose hook runs after this one would still read as absent here.\n *\n * On Astro 4 there is no `buildOutput`, and there `output: \"static\"` genuinely\n * prerenders everything — on-demand rendering required `\"server\"` or `\"hybrid\"`, both\n * of which fail this check. The adapter test stays as a second line of defence.\n */\n \"astro:config:done\": ({ config, logger, ...rest }) => {\n // Astro >= 5 only; undefined on 4, hence the fallback rather than a bare read.\n const buildOutput = (rest as { buildOutput?: \"static\" | \"server\" }).buildOutput;\n const staticOutput =\n buildOutput !== undefined\n ? buildOutput === \"static\"\n : config.output === \"static\" && !config.adapter;\n\n buildCache.on = buildCache.command === \"build\" && staticOutput;\n // Re-checked in astro:build:start below; only announce once it is final.\n decide = () => {\n const late = (rest as { buildOutput?: \"static\" | \"server\" }).buildOutput;\n const stillStatic =\n late !== undefined ? late === \"static\" : config.output === \"static\" && !config.adapter;\n buildCache.on = buildCache.command === \"build\" && stillStatic;\n buildCache.resolved = true;\n if (buildCache.on) {\n logger.info(\"static build — identical content reads will be fetched once\");\n }\n };\n },\n\n /**\n * Last word on the cache, and the reason this is not decided in `astro:config:done`\n * alone: Astro runs every integration's `config:done` in order, and `setAdapter()` is\n * called FROM that hook. An adapter registered by an integration ordered after this one\n * would flip the project to on-demand rendering *after* we had already recorded\n * \"static\" — and the stale `true` would ship a module-lifetime cache into a\n * long-lived server. `astro:build:start` runs after all of them and before Vite loads\n * the virtual module, so re-reading here is the value that is actually true.\n *\n * It never fires for `dev` or `preview`, which is exactly right: both must stay\n * uncached, and `buildCache.on` is only ever set to true under `command === \"build\"`.\n */\n \"astro:build:start\": () => {\n decide?.();\n },\n },\n };\n}\n\nexport default bettercms;\n","/**\n * Runtime for @bettercms-ai/astro — the code the `bettercms:client` virtual\n * module binds to. Provides a published client, per-request draft client\n * selection, typed loaders, and signed-cookie helpers for draft mode.\n *\n * Read-only; no I/O at import time. Safe in Node and edge runtimes (uses Web\n * Crypto + global fetch only).\n */\nimport { createClient, type BetterCMSReadClient } from \"@bettercms-ai/sdk\";\nimport type {\n DeliveredLayout,\n DeliveryComponent,\n DeliveryEntry,\n DeliveryList,\n DeliveryPage,\n} from \"@bettercms-ai/types\";\n\nexport interface RuntimeConfig {\n apiUrl: string;\n workspace: string;\n projectId?: string;\n /** Server-only delivery key (a `content:read:draft` key for drafts). */\n apiKey?: string;\n /**\n * Collapse identical delivery GETs for the life of the process. Set by the integration\n * when Astro's `command === \"build\"` — a static build renders every route from one\n * published dataset, so a repeat read cannot legitimately differ.\n *\n * Never set for `dev` or SSR, where each request must see current content.\n */\n buildCache?: boolean;\n}\n\n/** Per-request draft state, set on `Astro.locals.bcms` by the middleware. */\nexport interface BcmsLocals {\n draft: boolean;\n token?: string;\n}\n\ninterface HasLocals {\n locals: { bcms?: BcmsLocals };\n}\n\nexport interface BetterCMSRuntime {\n /** Published-perspective client (use for SSG / non-draft reads). */\n client: BetterCMSReadClient;\n /** Pick the right client for a request (draft client when draft mode is on). */\n getClient(astro?: HasLocals): BetterCMSReadClient;\n loadEntry<T = Record<string, unknown>>(\n astro: HasLocals,\n slug: string,\n opts?: Parameters<BetterCMSReadClient[\"getEntry\"]>[1],\n ): Promise<DeliveryEntry<T>>;\n loadEntries<T = Record<string, unknown>>(\n astro: HasLocals,\n opts?: Parameters<BetterCMSReadClient[\"listEntries\"]>[0],\n ): Promise<DeliveryList<DeliveryEntry<T>>>;\n loadPage(astro: HasLocals, slug: string): Promise<DeliveryPage | null>;\n /** Component definitions for `<BcmsBlocks components={…}>` — draft-side in draft mode. */\n loadComponents(astro: HasLocals): Promise<DeliveryComponent[]>;\n loadLayout(astro: HasLocals): Promise<DeliveredLayout | null>;\n loadForms(\n astro: HasLocals,\n opts?: Parameters<BetterCMSReadClient[\"listForms\"]>[0],\n ): Promise<Awaited<ReturnType<BetterCMSReadClient[\"listForms\"]>>>;\n}\n\nexport function createRuntime(config: RuntimeConfig): BetterCMSRuntime {\n const { buildCache, ...clientConfig } = config;\n // One client for the whole build, so the cache below is shared across every route\n // rather than rebuilt per render.\n const published = createClient({ ...clientConfig, perspective: \"published\", cache: buildCache });\n\n const getClient = (astro?: HasLocals): BetterCMSReadClient => {\n const bcms = astro?.locals?.bcms;\n if (bcms?.draft) {\n // Explicitly uncached: a draft read exists to show the edit that just happened.\n return createClient({\n ...clientConfig,\n perspective: \"drafts\",\n previewToken: bcms.token,\n cache: false,\n });\n }\n return published;\n };\n\n return {\n client: published,\n getClient,\n loadEntry: (astro, slug, opts) => getClient(astro).getEntry(slug, opts),\n loadEntries: (astro, opts) => getClient(astro).listEntries(opts),\n loadPage: (astro, slug) => getClient(astro).getPage(slug),\n loadComponents: (astro) => getClient(astro).listComponents(),\n loadLayout: (astro) => getClient(astro).getLayout(),\n loadForms: (astro, opts) => getClient(astro).listForms(opts),\n };\n}\n\n/**\n * Build the live SSE URL for `<BcmsLive>`. The key is a query param because\n * browser EventSource cannot send headers — use a content:read key.\n *\n * `depth` sets the hydration depth of the document the stream pushes (default 1,\n * matching the delivery API). `drafts` streams autosaves so a preview surface\n * repaints as the editor types — it needs a `content:read:draft` key, and the\n * server ignores the flag for any other key rather than failing the connection.\n * Never enable it on a public site.\n */\nexport function liveSrc(opts: {\n apiUrl: string;\n workspace: string;\n apiKey: string;\n depth?: 0 | 1 | 2;\n drafts?: boolean;\n}): string {\n const base = opts.apiUrl.replace(/\\/+$/, \"\");\n const q = new URLSearchParams({ key: opts.apiKey });\n if (opts.depth !== undefined) q.set(\"depth\", String(opts.depth));\n if (opts.drafts) q.set(\"drafts\", \"1\");\n return `${base}/api/v1/delivery/${opts.workspace}/live?${q}`;\n}\n\n/**\n * The published content snapshot, read at request time on a server BetterCMS hosts (it rewrites the\n * file on every publish) and from `bcms-content.json` at build time. Read content through this —\n * never `import` bcms-content.json or `import.meta.glob` it: a bundled copy is frozen at build, and\n * the platform has to rebuild the whole site for every publish to change it.\n */\nexport { readPublishedContent, publishedEntry, type PublishedContent } from \"@bettercms-ai/sdk\";\n\n// Signed-cookie and draft-route helpers: one implementation for every adapter (@bettercms-ai/sdk/draft).\nexport { signValue, verifyValue, safeRedirectPath, decodeTokenSlug } from \"@bettercms-ai/sdk/draft\";\n\n/**\n * The draft-cookie signing secret, `process.env` FIRST.\n *\n * Vite may INLINE `import.meta.env.BCMS_DRAFT_SECRET` at build time, and the value present\n * when the customer's site is built is not the value the hosting container is given at start\n * — BetterCMS derives it per project and injects it as a real env var. Reading the runtime\n * env first is what makes managed hosting work without asking anyone to rebuild. The\n * `import.meta.env` read stays as the fallback for `astro dev` and for adapters with no\n * `process` (guarded, since touching `import.meta.env` outside Vite throws).\n */\nexport function draftSecret(): string | undefined {\n const fromProcess =\n typeof process !== \"undefined\" ? (process.env?.BCMS_DRAFT_SECRET as string | undefined) : undefined;\n if (fromProcess) return fromProcess;\n try {\n return import.meta.env?.BCMS_DRAFT_SECRET as string | undefined;\n } catch {\n return undefined;\n }\n}\n","/**\n * @bettercms-ai/astro — the BetterCMS adapter for Astro.\n *\n * import { defineConfig } from \"astro/config\";\n * import bettercms from \"@bettercms-ai/astro\";\n *\n * export default defineConfig({\n * integrations: [bettercms({ apiUrl, workspace })],\n * output: \"server\",\n * });\n *\n * Then in any page: `import { loadPage } from \"bettercms:client\"`.\n */\nexport { bettercms, default } from \"./integration.js\";\nexport {\n resolveConfig,\n DRAFT_COOKIE,\n type BetterCMSAstroOptions,\n type PublicConfig,\n type ResolvedConfig,\n} from \"./config.js\";\nexport { liveSrc } from \"./runtime.js\";\n// C3/C4: a site's own section root declares that it paints block.style.\nexport { RESPONSIVE_CSS } from \"@bettercms-ai/types\";\n// A `link` value (or a button's `href`) is a string or a link object: `linkHref` reads either as the href.\nexport { linkHref, type LinkValue } from \"@bettercms-ai/types\";\nexport { sectionRootAttrs, type SectionRootAttrs, type SectionRootBlock } from \"./section-root.js\";\nexport { fieldAttrs, fieldStyleOf, type FieldAttrs, entryAttrs, entryField, type EntryRef, type EntryTransform, type EntryFieldAttrs } from \"./field-attrs.js\";\nexport { sectionColumnAttrs, type SectionColumnAttrs } from \"./section-root.js\";\nexport type { BcmsLocals, BetterCMSRuntime, RuntimeConfig } from \"./runtime.js\";\n\n// Image URL builder, re-exported for `<BcmsImage>` and host code.\nexport {\n default as imageUrlBuilder,\n imageUrl,\n imageValueUrl,\n imageValueObjectPosition,\n} from \"@bettercms-ai/image-url\";\nexport type {\n ImageUrlBuilder,\n ImageSource,\n ImageFormat,\n ImageFit,\n ImageCrop,\n ImageFocal,\n ImageValueUrlOptions,\n} from \"@bettercms-ai/image-url\";\n\n// Delivery read types, re-exported for typing page/entry data.\nexport type {\n Perspective,\n DeliveryEntry,\n DeliveryPage,\n DeliveryList,\n PageMetaJson,\n SiteSeoDefaults,\n ContentBlock,\n DeliveredLayout,\n} from \"@bettercms-ai/types\";\nexport type { DeliveryForm, DeliveryFormField } from \"@bettercms-ai/sdk\";\n\n// SEO (FLO-302): page-over-site meta resolver. In a page's frontmatter,\n// `const seo = resolveSeo(page, siteDefaults)`, then map `seo.*` into `<head>`.\nexport { resolveSeo } from \"@bettercms-ai/sdk\";\nexport type { SeoInput, ResolvedSeo } from \"@bettercms-ai/sdk\";\n","/**\n * C3/C4 — `sectionRootAttrs(block)`: the attributes a site's OWN section root spreads so the\n * BetterCMS editor offers that section's spacing and style handles.\n *\n * <section class=\"hero\" {...sectionRootAttrs(block)}>…</section>\n *\n * The editor shows those handles on a site-rendered page only when EVERY root the site stamps\n * with `data-bcms-block` also carries `data-bcms-style`, which is the site's promise that \"this\n * root's inline style is `blockStyleToCss(block.style)`\" — the same declarations `<BcmsBlocks>`\n * puts on its own wrapper. A root that stamps the block without applying its style would get a\n * capsule that paints the canvas and never ships, so the marker must travel with the style.\n *\n * The marker is present even when the style is EMPTY (then there is no `style` attribute at all):\n * an unstyled section is exactly the one an author is about to give its first spacing edit.\n */\nimport { blockStyleToColumnCss, blockStyleToCss, hideOnAttr, type BlockStyle } from \"@bettercms-ai/types\";\n\nexport interface SectionRootBlock {\n id?: string | null;\n style?: BlockStyle | Record<string, unknown> | null;\n}\n\nexport interface SectionRootAttrs {\n \"data-bcms-block\"?: string;\n \"data-bcms-style\": \"\";\n /** `\"mobile tablet\"` when `style.hideOn` hides it there; the site ships `RESPONSIVE_CSS` for it. */\n \"data-bcms-hide\"?: string;\n /** `blockStyleToCss(block.style)` as a CSS string; absent when the block has no style. */\n style?: string;\n}\n\n/** `paddingTop` → `padding-top`, joined the way `<BcmsBlocks>` writes its wrapper's attribute. */\nfunction cssText(css: Record<string, string | number>): string {\n return Object.entries(css)\n .map(([k, v]) => `${k.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`)}:${v}`)\n .join(\";\");\n}\n\nexport function sectionRootAttrs(block: SectionRootBlock | null | undefined): SectionRootAttrs {\n const css = blockStyleToCss((block?.style ?? undefined) as BlockStyle | undefined);\n const id = typeof block?.id === \"string\" && block.id !== \"\" ? block.id : undefined;\n const hide = hideOnAttr(block?.style);\n return {\n ...(id !== undefined ? { \"data-bcms-block\": id } : {}),\n \"data-bcms-style\": \"\",\n ...(hide ? { \"data-bcms-hide\": hide } : {}),\n ...(css ? { style: cssText(css) } : {}),\n };\n}\n\nexport interface SectionColumnAttrs {\n \"data-bcms-column\": \"\";\n /** `blockStyleToColumnCss(block.style)` as a CSS string; absent when the section has no column. */\n style?: string;\n}\n\n/**\n * C3 — `sectionColumnAttrs(block)`: the attributes a site's own INNER container spreads so the\n * section's content WIDTH (`style.contentWidth`, placed by `contentAlign`) ships.\n *\n * <section {...sectionRootAttrs(block)}>\n * <div class=\"container\" {...sectionColumnAttrs(block)}>…</div>\n * </section>\n *\n * The width is the column BetterCMS draws as `.bcms-block-inner` inside the section's styled box —\n * never on the root itself, whose background must stay full-bleed. `data-bcms-column` is the\n * site's promise that this box's inline style is the column; the editor offers the width handle\n * on a site-rendered page only where every styled root holds one. Max-width plus left/right\n * margins, so the container keeps its own vertical margins and, with no column, its own width.\n */\nexport function sectionColumnAttrs(block: SectionRootBlock | null | undefined): SectionColumnAttrs {\n const css = blockStyleToColumnCss((block?.style ?? undefined) as BlockStyle | undefined);\n return { \"data-bcms-column\": \"\", ...(css ? { style: cssText(css) } : {}) };\n}\n","/**\n * C3 — `fieldAttrs(path, fieldStyles)`: the attributes a site's OWN element spreads to bind a PAGE\n * FIELD and apply that field's stored style, so the BetterCMS editor offers its width and spacing\n * handles and its Align / Size / Weight controls.\n *\n * ---\n * const page = await loadPage(Astro, \"home\");\n * ---\n * <h1 class=\"title\" {...fieldAttrs(\"hero-title\", page?.fieldStyles)}>{entry.data[\"hero-title\"]}</h1>\n *\n * `data-bcms-style` is the site's promise that \"this element's inline style is\n * `fieldStyleToCss(fieldStyles[path])`\". The editor offers a field's handles only on an element that\n * carries it: a handle on one that does not would paint the canvas and never ship. The marker is\n * present even when the field has no style (then there is no `style` attribute at all, byte for\n * byte the element it was): an unstyled field is the one an author is about to give its first edit.\n * Twin: `fieldAttrs` in @bettercms-ai/next (a React style object there).\n */\nimport { fieldStyleCssText, type FieldStyle, type FieldStyles } from \"@bettercms-ai/types\";\n\nexport interface FieldAttrs {\n \"data-bcms-field\": string;\n /** The marker's revision: \"2\" promises `size` (zoom) too. Section roots keep \"\". */\n \"data-bcms-style\": \"2\";\n /** `fieldStyleToCss(fieldStyles[path])` as a CSS string; absent when the field has no style. */\n style?: string;\n}\n\n/** The stored style for `path`, by OWN key only — a path like `constructor` never reads the prototype. */\nexport function fieldStyleOf(path: string, fieldStyles: FieldStyles | Record<string, unknown> | null | undefined): FieldStyle | undefined {\n if (!fieldStyles || typeof fieldStyles !== \"object\" || !Object.prototype.hasOwnProperty.call(fieldStyles, path)) return undefined;\n const style = (fieldStyles as Record<string, unknown>)[path];\n return style && typeof style === \"object\" ? (style as FieldStyle) : undefined;\n}\n\nexport function fieldAttrs(path: string, fieldStyles?: FieldStyles | Record<string, unknown> | null): FieldAttrs {\n const style = fieldStyleCssText(fieldStyleOf(path, fieldStyles));\n return { \"data-bcms-field\": path, \"data-bcms-style\": \"2\", ...(style ? { style } : {}) };\n}\n\n/**\n * P7 — `entryAttrs(entry)` and `entryField(entry, path)`: the attributes a site's OWN card spreads to\n * declare a collection ENTRY, so the editor binds it without guessing from the rendered text.\n *\n * <article {...entryAttrs(post)}><h3 {...entryField(post, \"title\")}>{post.fields.title}</h3></article>\n *\n * The field address is ABSOLUTE (`entry:<id>:<path>`). With a `transform` the value is shown\n * changed (a date formatted, text truncated), so it is declared as `data-bcms-entry-from`: the\n * editor knows where it is but cannot re-render it. Twin: same helpers in @bettercms-ai/next.\n */\nexport type EntryRef = { id?: string } | string;\nexport type EntryTransform = \"format\" | \"truncate\" | \"rendition\" | \"route\";\n/** One key is present: `data-bcms-entry-field`, or `data-bcms-entry-from` when transformed; none without an id. */\nexport interface EntryFieldAttrs {\n \"data-bcms-entry-field\"?: string;\n \"data-bcms-entry-from\"?: string;\n}\n\nfunction entryIdOf(entry: EntryRef): string | null {\n const id = typeof entry === \"string\" ? entry : entry?.id;\n return typeof id === \"string\" && id.trim() !== \"\" ? id : null;\n}\n\n/** An entry with no id (a snapshot written before ids were kept) renders unbound, never fails the build. */\nexport function entryAttrs(entry: EntryRef): { \"data-bcms-entry\"?: string } {\n const id = entryIdOf(entry);\n return id ? { \"data-bcms-entry\": id } : {};\n}\n\nexport function entryField(entry: EntryRef, path: string, opts?: { transform?: EntryTransform }): EntryFieldAttrs {\n const id = entryIdOf(entry);\n if (typeof path !== \"string\" || path.trim() === \"\") throw new Error(`entryField: no field path given for entry ${id ?? \"(no id)\"}`);\n if (!id) return {};\n const address = `entry:${id}:${path}`;\n return opts?.transform ? { \"data-bcms-entry-from\": `${address}|${opts.transform}` } : { \"data-bcms-entry-field\": address };\n}\n"],"mappings":";AAWA,SAAS,oBAAoB;AA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,MAAc,aAAwE;AAC/G,QAAM,QAAQ,kBAAkB,aAAa,MAAM,WAAW,CAAC;AAC/D,SAAO,EAAE,mBAAmB,MAAM,mBAAmB,KAAK,GAAI,QAAQ,EAAE,MAAM,IAAI,CAAC,EAAG;AACxF;AAoBA,SAAS,UAAU,OAAgC;AACjD,QAAM,KAAK,OAAO,UAAU,WAAW,QAAQ,OAAO;AACtD,SAAO,OAAO,OAAO,YAAY,GAAG,KAAK,MAAM,KAAK,KAAK;AAC3D;AAGO,SAAS,WAAW,OAAiD;AAC1E,QAAM,KAAK,UAAU,KAAK;AAC1B,SAAO,KAAK,EAAE,mBAAmB,GAAG,IAAI,CAAC;AAC3C;AAEO,SAAS,WAAW,OAAiB,MAAc,MAAwD;AAChH,QAAM,KAAK,UAAU,KAAK;AAC1B,MAAI,OAAO,SAAS,YAAY,KAAK,KAAK,MAAM,GAAI,OAAM,IAAI,MAAM,6CAA6C,MAAM,SAAS,EAAE;AAClI,MAAI,CAAC,GAAI,QAAO,CAAC;AACjB,QAAM,UAAU,SAAS,EAAE,IAAI,IAAI;AACnC,SAAO,MAAM,YAAY,EAAE,wBAAwB,GAAG,OAAO,IAAI,KAAK,SAAS,GAAG,IAAI,EAAE,yBAAyB,QAAQ;AAC3H;;;AF1CA;AAAA,EACa,WAAXC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AA0BP,SAAS,kBAAkB;","names":["DEFAULT_MEDIA_URL","DRAFT_COOKIE","snapshot","env","config","config","readPublishedContent","default"]}
1
+ {"version":3,"sources":["../src/config.ts","../src/public-config.ts","../src/generator.ts","../src/integration.ts","../src/runtime.ts","../src/index.ts","../src/section-root.ts","../src/field-attrs.ts"],"sourcesContent":["/**\n * Resolved configuration shared by the integration, runtime, middleware and\n * draft routes. Public values are safe to ship to the browser; the API key and\n * draft secret are read from server env at runtime and never live here.\n *\n * Resolution order is options → `PUBLIC_BCMS_*` env → the build snapshot. Config-time\n * only: this module is reached exclusively through `dist/index.js`, which only an\n * `astro.config.*` imports, so the `node:fs` read below never enters a client bundle.\n * Browser code gets the `bettercms:config` virtual module instead.\n */\n\nimport { readFileSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\n\nimport { resolveBcmsConfig } from \"@bettercms-ai/sdk/config\";\n\nimport { DRAFT_COOKIE } from \"./public-config.js\";\n\nexport { DRAFT_COOKIE };\nconst SNAPSHOT_FILE = \"bcms-content.json\";\n\nexport interface BetterCMSAstroOptions {\n /** Backend base, e.g. `https://api.bettercms.ai`. Falls back to `PUBLIC_BCMS_API_URL`. */\n apiUrl?: string;\n /** Workspace slug. Falls back to `PUBLIC_BCMS_WORKSPACE`. */\n workspace?: string;\n /** Optional project scope for forms. Falls back to `PUBLIC_BCMS_PROJECT_ID`. */\n projectId?: string;\n /** Media host for the image-url builder. Defaults to the prod media host. */\n mediaUrl?: string;\n /** Dashboard base for visual-editing deep links. */\n studioUrl?: string;\n /** Enable the draft-mode middleware + injected draft routes. Default true. */\n draft?: boolean;\n}\n\n/** Browser-safe config — exposed via the `bettercms:config` virtual module. */\nexport interface PublicConfig {\n apiUrl: string;\n workspace: string;\n projectId?: string;\n mediaUrl: string;\n studioUrl?: string;\n draftCookie: string;\n}\n\nexport interface ResolvedConfig extends PublicConfig {\n draft: boolean;\n}\n\n/** The fields of the deploy Action's content snapshot that identify the site. */\ninterface Snapshot {\n apiUrl?: string;\n workspace?: string;\n projectId?: string;\n}\n\n/**\n * Read `bcms-content.json` — the snapshot the deploy Action writes next to the build,\n * BEFORE `astro build` runs — which already carries the workspace this site belongs to.\n *\n * This is what lets `bettercms()` work with no arguments and no env at all. Not reading it\n * was the whole bug: a hosted build had the answer sitting in its own working directory and\n * threw anyway, and every starter template had to reimplement this by hand to survive.\n *\n * Lazy: only consulted when options and env both miss, so the configured path does no I/O.\n * Absent/corrupt file ⇒ `{}`, and the caller raises the actionable error below.\n */\nlet snapshotCache: Snapshot | undefined;\nfunction snapshot(cwd: string): Snapshot {\n if (snapshotCache === undefined) {\n try {\n snapshotCache = JSON.parse(readFileSync(resolve(cwd, SNAPSHOT_FILE), \"utf8\")) as Snapshot;\n } catch {\n snapshotCache = {};\n }\n }\n return snapshotCache;\n}\n\n/** Test seam — the snapshot is memoised for the life of the process. */\nexport function resetSnapshotCache(): void {\n snapshotCache = undefined;\n}\n\nconst required = (name: string, envVar: string, extra: string) =>\n new Error(\n `[@bettercms-ai/astro] \\`${name}\\` is required. Pass \\`bettercms({ ${name} })\\`, set ` +\n `${envVar}, or ${extra}\\n` +\n `On BetterCMS hosting these are injected automatically — if this failed in a hosted ` +\n `build, the repository is running an outdated deploy workflow: publish once, or save ` +\n `Hosting settings, to refresh it.`,\n );\n\n/**\n * Merge integration options with `PUBLIC_BCMS_*` env and the build snapshot, validating the\n * essentials. Precedence: explicit options → env → snapshot.\n */\nexport function resolveConfig(\n options: BetterCMSAstroOptions,\n env: Record<string, string | undefined> = process.env,\n cwd: string = process.cwd(),\n): ResolvedConfig {\n // The precedence every adapter shares (@bettercms-ai/sdk/config); the words of the error are Astro's.\n const { config, missing } = resolveBcmsConfig({ options, env, prefixes: [\"PUBLIC_\"], snapshot: () => snapshot(cwd) });\n // No default origin on purpose: guessing one produces a site that builds cleanly against\n // the wrong backend, which is far harder to notice than this error.\n if (missing.includes(\"apiUrl\")) throw required(\"apiUrl\", \"PUBLIC_BCMS_API_URL\", `run the content fetch so ${SNAPSHOT_FILE} is present.`);\n if (missing.includes(\"workspace\")) {\n throw required(\"workspace\", \"PUBLIC_BCMS_WORKSPACE\", `run the content fetch so ${SNAPSHOT_FILE} is present.`);\n }\n return { ...config, draftCookie: DRAFT_COOKIE, draft: options.draft ?? true };\n}\n\nexport function toPublicConfig(c: ResolvedConfig): PublicConfig {\n const { draft: _draft, ...pub } = c;\n return pub;\n}\n","/**\n * The public config the shipped components read (`BcmsImage`, `BcmsForm`).\n *\n * Where `bettercms()` is registered, its Vite plugin answers this very specifier with the config it\n * resolved, options included (@see integration.ts). Where it is not, this file is what resolves:\n * the same values from the build's environment and its content snapshot.\n *\n * WHY A REAL MODULE. The components imported the virtual `bettercms:config`, which only the\n * integration can resolve. A site that registers it conditionally (ScrewFast:\n * `...(bcmsReady ? [bettercms({})] : [])`) could not compile a page that imported `<BcmsBlocks>`,\n * so `<BcmsSections>` was given no block renderer there and a section added in the editor had\n * nothing to draw it.\n *\n * No `node:fs` import: this is bundled into a server render, an edge runtime's included. Read on\n * use, never once at module scope: a server's environment and snapshot are the run's.\n */\nimport { readPublishedContent } from \"@bettercms-ai/sdk\";\nimport type { PublicConfig } from \"./config.js\";\n\n/**\n * The platform's canonical media host, matching `@bettercms-ai/image-url`'s own\n * `DEFAULT_BASE_URL` and the `CDN_URL` the backend mints asset URLs on.\n *\n * This used to be `media.bettercms.ai`. Both hostnames route to the backend — they are both in\n * `$bcms_api_host` in infra/nginx/backend-lb.conf — so nothing was broken, but a site built by\n * this integration disagreed with the URL the server itself hands out for the same asset. That\n * splits the CDN cache for identical bytes and makes an asset URL's origin depend on which code\n * path produced it, which is the exact drift image-url was moved off this host to end.\n *\n * A project that serves media from the API origin instead (`useCdn: false`) overrides this with\n * `PUBLIC_BCMS_MEDIA_URL` or the `mediaUrl` option.\n */\nexport { DEFAULT_MEDIA_URL } from \"@bettercms-ai/sdk/config\";\nexport { DRAFT_COOKIE } from \"@bettercms-ai/sdk/draft\";\nimport { DEFAULT_MEDIA_URL } from \"@bettercms-ai/sdk/config\";\nimport { DRAFT_COOKIE } from \"@bettercms-ai/sdk/draft\";\n/** The specifier the components import, and the integration's plugin answers. */\nexport const PUBLIC_CONFIG_ID = \"@bettercms-ai/astro/public-config\";\n\n/** The server's runtime env first (hosting injects it), then the build's. */\nfunction env(name: string): string | undefined {\n const fromProcess = typeof process !== \"undefined\" ? process.env?.[name] : undefined;\n if (fromProcess) return fromProcess;\n try {\n return ((import.meta.env as Record<string, string | undefined> | undefined)?.[name]) || undefined;\n } catch {\n return undefined;\n }\n}\n\nconst trim = (url: string): string => url.replace(/\\/+$/, \"\");\nconst text = (value: unknown): string | undefined => (typeof value === \"string\" && value ? value : undefined);\n\n/**\n * The config with no integration: `PUBLIC_BCMS_*`, then the snapshot. Never throws: with neither,\n * `apiUrl` and `workspace` are empty, which a build that never talks to the API renders with.\n */\nexport function fallbackConfig(): PublicConfig {\n const snapshot = (readPublishedContent() ?? {}) as { apiUrl?: unknown; workspace?: unknown; projectId?: unknown };\n return {\n apiUrl: trim(env(\"PUBLIC_BCMS_API_URL\") ?? text(snapshot.apiUrl) ?? \"\"),\n workspace: env(\"PUBLIC_BCMS_WORKSPACE\") ?? text(snapshot.workspace) ?? \"\",\n projectId: env(\"PUBLIC_BCMS_PROJECT_ID\") ?? text(snapshot.projectId),\n mediaUrl: trim(env(\"PUBLIC_BCMS_MEDIA_URL\") ?? DEFAULT_MEDIA_URL),\n studioUrl: env(\"PUBLIC_BCMS_STUDIO_URL\"),\n draftCookie: DRAFT_COOKIE,\n };\n}\n\nconst KEYS = [\"apiUrl\", \"workspace\", \"projectId\", \"mediaUrl\", \"studioUrl\", \"draftCookie\"] as const;\n\nexport const config = Object.defineProperties(\n {},\n Object.fromEntries(KEYS.map((key) => [key, { enumerable: true, get: () => fallbackConfig()[key] }])),\n) as PublicConfig;\nexport default config;\n","/**\n * The standard `<meta name=\"generator\">` Wappalyzer and BuiltWith read to name the CMS, stamped\n * into every prerendered page once, at build time. A page Astro renders on demand is never\n * buffered for it: that would cost every request (see middleware-entry.ts).\n */\nimport { readdir, readFile, writeFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nexport const GENERATOR_META = '<meta name=\"generator\" content=\"BetterCMS\">';\n\n/** The tag before the first `</head>`; unchanged without one, or when the page already has it. */\nexport function withGenerator(html: string): string {\n const at = html.search(/<\\/head>/i);\n return at < 0 || html.includes(GENERATOR_META) ? html : html.slice(0, at) + GENERATOR_META + html.slice(at);\n}\n\n/** Every `.html` file under the build's output `dir`; writes only the files it changed. */\nexport async function stampGenerator(dir: URL): Promise<void> {\n const root = fileURLToPath(dir);\n // ponytail: one file at a time, linear in page count; a few ms per page, no fd limit to hit.\n for (const file of await readdir(root, { recursive: true })) {\n if (!file.endsWith(\".html\")) continue;\n const path = join(root, file);\n const html = await readFile(path, \"utf8\");\n const stamped = withGenerator(html);\n if (stamped !== html) await writeFile(path, stamped);\n }\n}\n","/**\n * `bettercms()` — the Astro integration.\n *\n * - Registers two virtual modules:\n * `bettercms:client` → server runtime (client + typed loaders) — has the key.\n * `bettercms:config` → browser-safe public config — no secrets.\n * - Adds the draft-mode middleware and injects the draft enable/disable routes.\n * - Stamps `<meta name=\"generator\" content=\"BetterCMS\">` into every prerendered page.\n */\nimport type { AstroIntegration } from \"astro\";\nimport {\n resolveConfig,\n toPublicConfig,\n type BetterCMSAstroOptions,\n type ResolvedConfig,\n} from \"./config.js\";\n\nimport { PUBLIC_CONFIG_ID } from \"./public-config.js\";\nimport { stampGenerator } from \"./generator.js\";\n\nconst CLIENT_ID = \"bettercms:client\";\nconst CONFIG_ID = \"bettercms:config\";\nconst RESOLVED = (id: string) => `\\0${id}`;\n\nfunction configModule(cfg: ResolvedConfig): string {\n return `export const config = ${JSON.stringify(toPublicConfig(cfg))};\\nexport default config;\\n`;\n}\n\nfunction clientModule(cfg: ResolvedConfig, buildCache: boolean): string {\n // The key is optional: published reads are addressed by the inlined projectId. When one is\n // set it is read from the server's env at run time (a server-output site gets it from its\n // host, not the build), falling back to the build's env; it never lands in a client bundle.\n return [\n `import { createRuntime } from \"@bettercms-ai/astro/runtime\";`,\n `const runtime = createRuntime({`,\n ` apiUrl: ${JSON.stringify(cfg.apiUrl)},`,\n ` workspace: ${JSON.stringify(cfg.workspace)},`,\n ` projectId: ${JSON.stringify(cfg.projectId)},`,\n ` apiKey: globalThis.process?.env?.BCMS_API_KEY ?? import.meta.env.BCMS_API_KEY,`,\n ` buildCache: ${JSON.stringify(buildCache)},`,\n `});`,\n `export const client = runtime.client;`,\n `export const getClient = runtime.getClient;`,\n `export const loadEntry = runtime.loadEntry;`,\n `export const loadEntries = runtime.loadEntries;`,\n `export const loadPage = runtime.loadPage;`,\n `export const loadComponents = runtime.loadComponents;`,\n `export const loadForms = runtime.loadForms;`,\n `export const loadLayout = runtime.loadLayout;`,\n `export default runtime;`,\n ].join(\"\\n\");\n}\n\nfunction virtualPlugin(cfg: ResolvedConfig, buildCache: () => boolean) {\n return {\n name: \"@bettercms-ai/astro:virtual\",\n // Before Vite's own resolver: `PUBLIC_CONFIG_ID` names a real file of this package, and a\n // plugin that runs after the resolver is never asked about a specifier it already resolved.\n enforce: \"pre\" as const,\n resolveId(id: string) {\n if (id === CLIENT_ID || id === CONFIG_ID) return RESOLVED(id);\n // The components' own import: answered with the config resolved here, options included.\n // Without this plugin it resolves to the package's file, which reads the environment.\n if (id === PUBLIC_CONFIG_ID) return RESOLVED(CONFIG_ID);\n return null;\n },\n load(id: string) {\n if (id === RESOLVED(CONFIG_ID)) return configModule(cfg);\n if (id === RESOLVED(CLIENT_ID)) return clientModule(cfg, buildCache());\n return null;\n },\n };\n}\n\nexport function bettercms(options: BetterCMSAstroOptions = {}): AstroIntegration {\n /**\n * Whether identical delivery GETs may be collapsed for the life of the process.\n *\n * Read lazily by the virtual module (see `astro:config:done` below) because only the\n * FINAL config settles `output` and `adapter` — another integration can add an adapter\n * after `astro:config:setup` runs.\n */\n const buildCache = { on: false, command: \"\", resolved: false };\n /** Set in `astro:config:done`, re-run in `astro:build:start` — see both hooks below. */\n let decide: (() => void) | undefined;\n\n return {\n name: \"@bettercms-ai/astro\",\n hooks: {\n \"astro:config:setup\": ({ command, updateConfig, addMiddleware, injectRoute, logger }) => {\n const cfg = resolveConfig(options);\n buildCache.command = command;\n\n updateConfig({ vite: { plugins: [virtualPlugin(cfg, () => buildCache.on)] } });\n\n if (cfg.draft) {\n addMiddleware({ entrypoint: \"@bettercms-ai/astro/middleware\", order: \"pre\" });\n injectRoute({\n pattern: \"/api/bcms/draft/enable\",\n entrypoint: \"@bettercms-ai/astro/draft-enable\",\n prerender: false,\n });\n injectRoute({\n pattern: \"/api/bcms/draft/disable\",\n entrypoint: \"@bettercms-ai/astro/draft-disable\",\n prerender: false,\n });\n logger.info(\"draft mode enabled — /api/bcms/draft/{enable,disable} injected\");\n }\n },\n\n /**\n * Decide whether the build-time request cache is safe, on the FINAL config.\n *\n * A fully static build renders every route from one published dataset, so identical\n * delivery GETs can collapse to a single round-trip. Without that a large site\n * re-fetched its nav/settings/collections once PER ROUTE and exhausted the delivery\n * rate limit mid-build — a 429 the build could not avoid.\n *\n * `command === \"build\"` is NOT sufficient to detect that, and getting this wrong is\n * far worse than the problem it solves: Astro also reports `command === \"build\"` when\n * it compiles `output: \"server\"`, whose bundle then runs as a LONG-LIVED process. A\n * module-lifetime cache there would pin the first response for every URL and serve it\n * to unrelated visitors until the process restarted — permanent stale content on a\n * production site.\n *\n * `buildOutput` (Astro 5) is Astro's OWN answer to \"will this emit a server?\", so it\n * is what we trust when present. Inferring it from `config.adapter` is not equivalent:\n * `setAdapter()` is documented as being called from inside `astro:config:done`, so an\n * adapter integration whose hook runs after this one would still read as absent here.\n *\n * On Astro 4 there is no `buildOutput`, and there `output: \"static\"` genuinely\n * prerenders everything — on-demand rendering required `\"server\"` or `\"hybrid\"`, both\n * of which fail this check. The adapter test stays as a second line of defence.\n */\n \"astro:config:done\": ({ config, logger, ...rest }) => {\n // Astro >= 5 only; undefined on 4, hence the fallback rather than a bare read.\n const buildOutput = (rest as { buildOutput?: \"static\" | \"server\" }).buildOutput;\n const staticOutput =\n buildOutput !== undefined\n ? buildOutput === \"static\"\n : config.output === \"static\" && !config.adapter;\n\n buildCache.on = buildCache.command === \"build\" && staticOutput;\n // Re-checked in astro:build:start below; only announce once it is final.\n decide = () => {\n const late = (rest as { buildOutput?: \"static\" | \"server\" }).buildOutput;\n const stillStatic =\n late !== undefined ? late === \"static\" : config.output === \"static\" && !config.adapter;\n buildCache.on = buildCache.command === \"build\" && stillStatic;\n buildCache.resolved = true;\n if (buildCache.on) {\n logger.info(\"static build — identical content reads will be fetched once\");\n }\n };\n },\n\n /**\n * Last word on the cache, and the reason this is not decided in `astro:config:done`\n * alone: Astro runs every integration's `config:done` in order, and `setAdapter()` is\n * called FROM that hook. An adapter registered by an integration ordered after this one\n * would flip the project to on-demand rendering *after* we had already recorded\n * \"static\" — and the stale `true` would ship a module-lifetime cache into a\n * long-lived server. `astro:build:start` runs after all of them and before Vite loads\n * the virtual module, so re-reading here is the value that is actually true.\n *\n * It never fires for `dev` or `preview`, which is exactly right: both must stay\n * uncached, and `buildCache.on` is only ever set to true under `command === \"build\"`.\n */\n \"astro:build:start\": () => {\n decide?.();\n },\n\n /** Names BetterCMS in every prerendered page's `<head>`: see generator.ts. */\n \"astro:build:done\": ({ dir }) => stampGenerator(dir),\n },\n };\n}\n\nexport default bettercms;\n","/**\n * Runtime for @bettercms-ai/astro — the code the `bettercms:client` virtual\n * module binds to. Provides a published client, per-request draft client\n * selection, typed loaders, and signed-cookie helpers for draft mode.\n *\n * Read-only; no I/O at import time. Safe in Node and edge runtimes (uses Web\n * Crypto + global fetch only).\n */\nimport { createClient, type BetterCMSReadClient } from \"@bettercms-ai/sdk\";\nimport type {\n DeliveredLayout,\n DeliveryComponent,\n DeliveryEntry,\n DeliveryList,\n DeliveryPage,\n} from \"@bettercms-ai/types\";\n\nexport interface RuntimeConfig {\n apiUrl: string;\n workspace: string;\n projectId?: string;\n /** Server-only delivery key (a `content:read:draft` key for drafts). */\n apiKey?: string;\n /**\n * Collapse identical delivery GETs for the life of the process. Set by the integration\n * when Astro's `command === \"build\"` — a static build renders every route from one\n * published dataset, so a repeat read cannot legitimately differ.\n *\n * Never set for `dev` or SSR, where each request must see current content.\n */\n buildCache?: boolean;\n}\n\n/** Per-request draft state, set on `Astro.locals.bcms` by the middleware. */\nexport interface BcmsLocals {\n draft: boolean;\n token?: string;\n}\n\ninterface HasLocals {\n locals: { bcms?: BcmsLocals };\n}\n\nexport interface BetterCMSRuntime {\n /** Published-perspective client (use for SSG / non-draft reads). */\n client: BetterCMSReadClient;\n /** Pick the right client for a request (draft client when draft mode is on). */\n getClient(astro?: HasLocals): BetterCMSReadClient;\n loadEntry<T = Record<string, unknown>>(\n astro: HasLocals,\n slug: string,\n opts?: Parameters<BetterCMSReadClient[\"getEntry\"]>[1],\n ): Promise<DeliveryEntry<T>>;\n loadEntries<T = Record<string, unknown>>(\n astro: HasLocals,\n opts?: Parameters<BetterCMSReadClient[\"listEntries\"]>[0],\n ): Promise<DeliveryList<DeliveryEntry<T>>>;\n loadPage(astro: HasLocals, slug: string): Promise<DeliveryPage | null>;\n /** Component definitions for `<BcmsBlocks components={…}>` — draft-side in draft mode. */\n loadComponents(astro: HasLocals): Promise<DeliveryComponent[]>;\n loadLayout(astro: HasLocals): Promise<DeliveredLayout | null>;\n loadForms(\n astro: HasLocals,\n opts?: Parameters<BetterCMSReadClient[\"listForms\"]>[0],\n ): Promise<Awaited<ReturnType<BetterCMSReadClient[\"listForms\"]>>>;\n}\n\nexport function createRuntime(config: RuntimeConfig): BetterCMSRuntime {\n const { buildCache, ...clientConfig } = config;\n // One client for the whole build, so the cache below is shared across every route\n // rather than rebuilt per render.\n const published = createClient({ ...clientConfig, perspective: \"published\", cache: buildCache });\n\n const getClient = (astro?: HasLocals): BetterCMSReadClient => {\n const bcms = astro?.locals?.bcms;\n if (bcms?.draft) {\n // Explicitly uncached: a draft read exists to show the edit that just happened.\n return createClient({\n ...clientConfig,\n perspective: \"drafts\",\n previewToken: bcms.token,\n cache: false,\n });\n }\n return published;\n };\n\n return {\n client: published,\n getClient,\n loadEntry: (astro, slug, opts) => getClient(astro).getEntry(slug, opts),\n loadEntries: (astro, opts) => getClient(astro).listEntries(opts),\n loadPage: (astro, slug) => getClient(astro).getPage(slug),\n loadComponents: (astro) => getClient(astro).listComponents(),\n loadLayout: (astro) => getClient(astro).getLayout(),\n loadForms: (astro, opts) => getClient(astro).listForms(opts),\n };\n}\n\n/**\n * Build the live SSE URL for `<BcmsLive>`. The key is a query param because\n * browser EventSource cannot send headers — use a content:read key.\n *\n * `depth` sets the hydration depth of the document the stream pushes (default 1,\n * matching the delivery API). `drafts` streams autosaves so a preview surface\n * repaints as the editor types — it needs a `content:read:draft` key, and the\n * server ignores the flag for any other key rather than failing the connection.\n * Never enable it on a public site.\n */\nexport function liveSrc(opts: {\n apiUrl: string;\n workspace: string;\n apiKey: string;\n depth?: 0 | 1 | 2;\n drafts?: boolean;\n}): string {\n const base = opts.apiUrl.replace(/\\/+$/, \"\");\n const q = new URLSearchParams({ key: opts.apiKey });\n if (opts.depth !== undefined) q.set(\"depth\", String(opts.depth));\n if (opts.drafts) q.set(\"drafts\", \"1\");\n return `${base}/api/v1/delivery/${opts.workspace}/live?${q}`;\n}\n\n/**\n * The published content snapshot, read at request time on a server BetterCMS hosts (it rewrites the\n * file on every publish) and from `bcms-content.json` at build time. Read content through this —\n * never `import` bcms-content.json or `import.meta.glob` it: a bundled copy is frozen at build, and\n * the platform has to rebuild the whole site for every publish to change it.\n */\nexport { readPublishedContent, publishedEntry, type PublishedContent } from \"@bettercms-ai/sdk\";\n\n// Signed-cookie and draft-route helpers: one implementation for every adapter (@bettercms-ai/sdk/draft).\nexport { signValue, verifyValue, safeRedirectPath, decodeTokenSlug } from \"@bettercms-ai/sdk/draft\";\n\n/**\n * The draft-cookie signing secret, `process.env` FIRST.\n *\n * Vite may INLINE `import.meta.env.BCMS_DRAFT_SECRET` at build time, and the value present\n * when the customer's site is built is not the value the hosting container is given at start\n * — BetterCMS derives it per project and injects it as a real env var. Reading the runtime\n * env first is what makes managed hosting work without asking anyone to rebuild. The\n * `import.meta.env` read stays as the fallback for `astro dev` and for adapters with no\n * `process` (guarded, since touching `import.meta.env` outside Vite throws).\n */\nexport function draftSecret(): string | undefined {\n const fromProcess =\n typeof process !== \"undefined\" ? (process.env?.BCMS_DRAFT_SECRET as string | undefined) : undefined;\n if (fromProcess) return fromProcess;\n try {\n return import.meta.env?.BCMS_DRAFT_SECRET as string | undefined;\n } catch {\n return undefined;\n }\n}\n","/**\n * @bettercms-ai/astro — the BetterCMS adapter for Astro.\n *\n * import { defineConfig } from \"astro/config\";\n * import bettercms from \"@bettercms-ai/astro\";\n *\n * export default defineConfig({\n * integrations: [bettercms({ apiUrl, workspace })],\n * output: \"server\",\n * });\n *\n * Then in any page: `import { loadPage } from \"bettercms:client\"`.\n */\nexport { bettercms, default } from \"./integration.js\";\nexport {\n resolveConfig,\n DRAFT_COOKIE,\n type BetterCMSAstroOptions,\n type PublicConfig,\n type ResolvedConfig,\n} from \"./config.js\";\nexport { liveSrc } from \"./runtime.js\";\n// C3/C4: a site's own section root declares that it paints block.style.\nexport { RESPONSIVE_CSS } from \"@bettercms-ai/types\";\n// A `link` value (or a button's `href`) is a string or a link object: `linkHref` reads either as the href.\nexport { linkHref, type LinkValue } from \"@bettercms-ai/types\";\nexport { sectionRootAttrs, type SectionRootAttrs, type SectionRootBlock } from \"./section-root.js\";\nexport { fieldAttrs, fieldStyleOf, type FieldAttrs, entryAttrs, entryField, type EntryRef, type EntryTransform, type EntryFieldAttrs } from \"./field-attrs.js\";\nexport { sectionColumnAttrs, type SectionColumnAttrs } from \"./section-root.js\";\nexport type { BcmsLocals, BetterCMSRuntime, RuntimeConfig } from \"./runtime.js\";\n\n// Image URL builder, re-exported for `<BcmsImage>` and host code.\nexport {\n default as imageUrlBuilder,\n imageUrl,\n imageValueUrl,\n imageValueObjectPosition,\n} from \"@bettercms-ai/image-url\";\nexport type {\n ImageUrlBuilder,\n ImageSource,\n ImageFormat,\n ImageFit,\n ImageCrop,\n ImageFocal,\n ImageValueUrlOptions,\n} from \"@bettercms-ai/image-url\";\n\n// Delivery read types, re-exported for typing page/entry data.\nexport type {\n Perspective,\n DeliveryEntry,\n DeliveryPage,\n DeliveryList,\n PageMetaJson,\n SiteSeoDefaults,\n ContentBlock,\n DeliveredLayout,\n} from \"@bettercms-ai/types\";\nexport type { DeliveryForm, DeliveryFormField } from \"@bettercms-ai/sdk\";\n\n// SEO (FLO-302): page-over-site meta resolver. In a page's frontmatter,\n// `const seo = resolveSeo(page, siteDefaults)`, then map `seo.*` into `<head>`.\nexport { resolveSeo } from \"@bettercms-ai/sdk\";\nexport type { SeoInput, ResolvedSeo } from \"@bettercms-ai/sdk\";\n","/**\n * C3/C4 — `sectionRootAttrs(block)`: the attributes a site's OWN section root spreads so the\n * BetterCMS editor offers that section's spacing and style handles.\n *\n * <section class=\"hero\" {...sectionRootAttrs(block)}>…</section>\n *\n * The editor shows those handles on a site-rendered page only when EVERY root the site stamps\n * with `data-bcms-block` also carries `data-bcms-style`, which is the site's promise that \"this\n * root's inline style is `blockStyleToCss(block.style)`\" — the same declarations `<BcmsBlocks>`\n * puts on its own wrapper. A root that stamps the block without applying its style would get a\n * capsule that paints the canvas and never ships, so the marker must travel with the style.\n *\n * The marker is present even when the style is EMPTY (then there is no `style` attribute at all):\n * an unstyled section is exactly the one an author is about to give its first spacing edit.\n */\nimport { blockStyleToColumnCss, blockStyleToCss, hideOnAttr, type BlockStyle } from \"@bettercms-ai/types\";\n\nexport interface SectionRootBlock {\n id?: string | null;\n style?: BlockStyle | Record<string, unknown> | null;\n}\n\nexport interface SectionRootAttrs {\n \"data-bcms-block\"?: string;\n \"data-bcms-style\": \"\";\n /** `\"mobile tablet\"` when `style.hideOn` hides it there; the site ships `RESPONSIVE_CSS` for it. */\n \"data-bcms-hide\"?: string;\n /** `blockStyleToCss(block.style)` as a CSS string; absent when the block has no style. */\n style?: string;\n}\n\n/** `paddingTop` → `padding-top`, joined the way `<BcmsBlocks>` writes its wrapper's attribute. */\nfunction cssText(css: Record<string, string | number>): string {\n return Object.entries(css)\n .map(([k, v]) => `${k.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`)}:${v}`)\n .join(\";\");\n}\n\nexport function sectionRootAttrs(block: SectionRootBlock | null | undefined): SectionRootAttrs {\n const css = blockStyleToCss((block?.style ?? undefined) as BlockStyle | undefined);\n const id = typeof block?.id === \"string\" && block.id !== \"\" ? block.id : undefined;\n const hide = hideOnAttr(block?.style);\n return {\n ...(id !== undefined ? { \"data-bcms-block\": id } : {}),\n \"data-bcms-style\": \"\",\n ...(hide ? { \"data-bcms-hide\": hide } : {}),\n ...(css ? { style: cssText(css) } : {}),\n };\n}\n\nexport interface SectionColumnAttrs {\n \"data-bcms-column\": \"\";\n /** `blockStyleToColumnCss(block.style)` as a CSS string; absent when the section has no column. */\n style?: string;\n}\n\n/**\n * C3 — `sectionColumnAttrs(block)`: the attributes a site's own INNER container spreads so the\n * section's content WIDTH (`style.contentWidth`, placed by `contentAlign`) ships.\n *\n * <section {...sectionRootAttrs(block)}>\n * <div class=\"container\" {...sectionColumnAttrs(block)}>…</div>\n * </section>\n *\n * The width is the column BetterCMS draws as `.bcms-block-inner` inside the section's styled box —\n * never on the root itself, whose background must stay full-bleed. `data-bcms-column` is the\n * site's promise that this box's inline style is the column; the editor offers the width handle\n * on a site-rendered page only where every styled root holds one. Max-width plus left/right\n * margins, so the container keeps its own vertical margins and, with no column, its own width.\n */\nexport function sectionColumnAttrs(block: SectionRootBlock | null | undefined): SectionColumnAttrs {\n const css = blockStyleToColumnCss((block?.style ?? undefined) as BlockStyle | undefined);\n return { \"data-bcms-column\": \"\", ...(css ? { style: cssText(css) } : {}) };\n}\n","/**\n * C3 — `fieldAttrs(path, fieldStyles)`: the attributes a site's OWN element spreads to bind a PAGE\n * FIELD and apply that field's stored style, so the BetterCMS editor offers its width and spacing\n * handles and its Align / Size / Weight controls.\n *\n * ---\n * const page = await loadPage(Astro, \"home\");\n * ---\n * <h1 class=\"title\" {...fieldAttrs(\"hero-title\", page?.fieldStyles)}>{entry.data[\"hero-title\"]}</h1>\n *\n * `data-bcms-style` is the site's promise that \"this element's inline style is\n * `fieldStyleToCss(fieldStyles[path])`\". The editor offers a field's handles only on an element that\n * carries it: a handle on one that does not would paint the canvas and never ship. The marker is\n * present even when the field has no style (then there is no `style` attribute at all, byte for\n * byte the element it was): an unstyled field is the one an author is about to give its first edit.\n * Twin: `fieldAttrs` in @bettercms-ai/next (a React style object there).\n */\nimport { fieldStyleCssText, type FieldStyle, type FieldStyles } from \"@bettercms-ai/types\";\n\nexport interface FieldAttrs {\n \"data-bcms-field\": string;\n /** The marker's revision: \"2\" promises `size` (zoom) too. Section roots keep \"\". */\n \"data-bcms-style\": \"2\";\n /** `fieldStyleToCss(fieldStyles[path])` as a CSS string; absent when the field has no style. */\n style?: string;\n}\n\n/** The stored style for `path`, by OWN key only — a path like `constructor` never reads the prototype. */\nexport function fieldStyleOf(path: string, fieldStyles: FieldStyles | Record<string, unknown> | null | undefined): FieldStyle | undefined {\n if (!fieldStyles || typeof fieldStyles !== \"object\" || !Object.prototype.hasOwnProperty.call(fieldStyles, path)) return undefined;\n const style = (fieldStyles as Record<string, unknown>)[path];\n return style && typeof style === \"object\" ? (style as FieldStyle) : undefined;\n}\n\nexport function fieldAttrs(path: string, fieldStyles?: FieldStyles | Record<string, unknown> | null): FieldAttrs {\n const style = fieldStyleCssText(fieldStyleOf(path, fieldStyles));\n return { \"data-bcms-field\": path, \"data-bcms-style\": \"2\", ...(style ? { style } : {}) };\n}\n\n/**\n * P7 — `entryAttrs(entry)` and `entryField(entry, path)`: the attributes a site's OWN card spreads to\n * declare a collection ENTRY, so the editor binds it without guessing from the rendered text.\n *\n * <article {...entryAttrs(post)}><h3 {...entryField(post, \"title\")}>{post.fields.title}</h3></article>\n *\n * The field address is ABSOLUTE (`entry:<id>:<path>`). With a `transform` the value is shown\n * changed (a date formatted, text truncated), so it is declared as `data-bcms-entry-from`: the\n * editor knows where it is but cannot re-render it. Twin: same helpers in @bettercms-ai/next.\n */\nexport type EntryRef = { id?: string } | string;\nexport type EntryTransform = \"format\" | \"truncate\" | \"rendition\" | \"route\";\n/** One key is present: `data-bcms-entry-field`, or `data-bcms-entry-from` when transformed; none without an id. */\nexport interface EntryFieldAttrs {\n \"data-bcms-entry-field\"?: string;\n \"data-bcms-entry-from\"?: string;\n}\n\nfunction entryIdOf(entry: EntryRef): string | null {\n const id = typeof entry === \"string\" ? entry : entry?.id;\n return typeof id === \"string\" && id.trim() !== \"\" ? id : null;\n}\n\n/** An entry with no id (a snapshot written before ids were kept) renders unbound, never fails the build. */\nexport function entryAttrs(entry: EntryRef): { \"data-bcms-entry\"?: string } {\n const id = entryIdOf(entry);\n return id ? { \"data-bcms-entry\": id } : {};\n}\n\nexport function entryField(entry: EntryRef, path: string, opts?: { transform?: EntryTransform }): EntryFieldAttrs {\n const id = entryIdOf(entry);\n if (typeof path !== \"string\" || path.trim() === \"\") throw new Error(`entryField: no field path given for entry ${id ?? \"(no id)\"}`);\n if (!id) return {};\n const address = `entry:${id}:${path}`;\n return opts?.transform ? { \"data-bcms-entry-from\": `${address}|${opts.transform}` } : { \"data-bcms-entry-field\": address };\n}\n"],"mappings":";AAWA,SAAS,oBAAoB;AAC7B,SAAS,eAAe;AAExB,SAAS,yBAAyB;;;ACElC,SAAS,4BAA4B;AAgBrC,SAAS,yBAAyB;AAClC,SAAS,oBAAoB;AAC7B,SAAS,qBAAAA,0BAAyB;AAClC,SAAS,gBAAAC,qBAAoB;AAEtB,IAAM,mBAAmB;AAGhC,SAAS,IAAI,MAAkC;AAC7C,QAAM,cAAc,OAAO,YAAY,cAAc,QAAQ,MAAM,IAAI,IAAI;AAC3E,MAAI,YAAa,QAAO;AACxB,MAAI;AACF,WAAS,YAAY,MAAyD,IAAI,KAAM;AAAA,EAC1F,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEA,IAAM,OAAO,CAAC,QAAwB,IAAI,QAAQ,QAAQ,EAAE;AAC5D,IAAM,OAAO,CAAC,UAAwC,OAAO,UAAU,YAAY,QAAQ,QAAQ;AAM5F,SAAS,iBAA+B;AAC7C,QAAMC,YAAY,qBAAqB,KAAK,CAAC;AAC7C,SAAO;AAAA,IACL,QAAQ,KAAK,IAAI,qBAAqB,KAAK,KAAKA,UAAS,MAAM,KAAK,EAAE;AAAA,IACtE,WAAW,IAAI,uBAAuB,KAAK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C/G,QAAM,QAAQ,kBAAkB,aAAa,MAAM,WAAW,CAAC;AAC/D,SAAO,EAAE,mBAAmB,MAAM,mBAAmB,KAAK,GAAI,QAAQ,EAAE,MAAM,IAAI,CAAC,EAAG;AACxF;AAoBA,SAAS,UAAU,OAAgC;AACjD,QAAM,KAAK,OAAO,UAAU,WAAW,QAAQ,OAAO;AACtD,SAAO,OAAO,OAAO,YAAY,GAAG,KAAK,MAAM,KAAK,KAAK;AAC3D;AAGO,SAAS,WAAW,OAAiD;AAC1E,QAAM,KAAK,UAAU,KAAK;AAC1B,SAAO,KAAK,EAAE,mBAAmB,GAAG,IAAI,CAAC;AAC3C;AAEO,SAAS,WAAW,OAAiB,MAAc,MAAwD;AAChH,QAAM,KAAK,UAAU,KAAK;AAC1B,MAAI,OAAO,SAAS,YAAY,KAAK,KAAK,MAAM,GAAI,OAAM,IAAI,MAAM,6CAA6C,MAAM,SAAS,EAAE;AAClI,MAAI,CAAC,GAAI,QAAO,CAAC;AACjB,QAAM,UAAU,SAAS,EAAE,IAAI,IAAI;AACnC,SAAO,MAAM,YAAY,EAAE,wBAAwB,GAAG,OAAO,IAAI,KAAK,SAAS,GAAG,IAAI,EAAE,yBAAyB,QAAQ;AAC3H;;;AF1CA;AAAA,EACa,WAAXC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AA0BP,SAAS,kBAAkB;","names":["DEFAULT_MEDIA_URL","DRAFT_COOKIE","snapshot","env","config","config","readPublishedContent","default"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bettercms-ai/astro",
3
- "version": "0.28.3",
3
+ "version": "0.29.1",
4
4
  "type": "module",
5
5
  "description": "The BetterCMS adapter for Astro — a `bettercms()` integration, a `bettercms:client` virtual module, typed content loaders, draft preview, and native .astro rendering components.",
6
6
  "main": "./dist/index.js",
@@ -61,11 +61,11 @@
61
61
  },
62
62
  "dependencies": {
63
63
  "@bettercms-ai/image-url": "^0.4.0",
64
- "@bettercms-ai/next": "^0.29.0",
65
- "@bettercms-ai/richtext": "^0.12.0",
64
+ "@bettercms-ai/next": "^0.30.2",
65
+ "@bettercms-ai/richtext": "^0.13.0",
66
66
  "@bettercms-ai/sdk": "^1.34.0",
67
- "@bettercms-ai/types": "^1.48.0",
68
- "@bettercms-ai/ui": "^0.20.0",
67
+ "@bettercms-ai/types": "^1.54.0",
68
+ "@bettercms-ai/ui": "^0.21.0",
69
69
  "libphonenumber-js": "^1.13.13"
70
70
  },
71
71
  "peerDependencies": {