emdash 0.4.0 → 0.6.0

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 (212) hide show
  1. package/dist/{adapters-C2BzVy0p.d.mts → adapters-Di31kZ28.d.mts} +16 -1
  2. package/dist/adapters-Di31kZ28.d.mts.map +1 -0
  3. package/dist/{apply-Cma_PiF6.mjs → apply-B4MsLM-w.mjs} +27 -12
  4. package/dist/apply-B4MsLM-w.mjs.map +1 -0
  5. package/dist/astro/index.d.mts +6 -6
  6. package/dist/astro/index.d.mts.map +1 -1
  7. package/dist/astro/index.mjs +208 -34
  8. package/dist/astro/index.mjs.map +1 -1
  9. package/dist/astro/middleware/auth.d.mts +5 -5
  10. package/dist/astro/middleware/auth.d.mts.map +1 -1
  11. package/dist/astro/middleware/auth.mjs +34 -9
  12. package/dist/astro/middleware/auth.mjs.map +1 -1
  13. package/dist/astro/middleware/redirect.mjs +1 -1
  14. package/dist/astro/middleware/request-context.d.mts.map +1 -1
  15. package/dist/astro/middleware/request-context.mjs +5 -3
  16. package/dist/astro/middleware/request-context.mjs.map +1 -1
  17. package/dist/astro/middleware/setup.mjs +1 -1
  18. package/dist/astro/middleware.d.mts.map +1 -1
  19. package/dist/astro/middleware.mjs +460 -180
  20. package/dist/astro/middleware.mjs.map +1 -1
  21. package/dist/astro/types.d.mts +8 -8
  22. package/dist/{byline-WuOq9MFJ.mjs → byline-C4OVd8b3.mjs} +3 -19
  23. package/dist/byline-C4OVd8b3.mjs.map +1 -0
  24. package/dist/{bylines-C_Wsnz4L.mjs → bylines-hPTW79hw.mjs} +20 -33
  25. package/dist/bylines-hPTW79hw.mjs.map +1 -0
  26. package/dist/{cache-E3Dts-yT.mjs → cache-BkKBuIvS.mjs} +1 -1
  27. package/dist/{cache-E3Dts-yT.mjs.map → cache-BkKBuIvS.mjs.map} +1 -1
  28. package/dist/chunks-HGz06Soa.mjs +19 -0
  29. package/dist/chunks-HGz06Soa.mjs.map +1 -0
  30. package/dist/cli/index.mjs +9 -8
  31. package/dist/cli/index.mjs.map +1 -1
  32. package/dist/client/cf-access.d.mts +1 -1
  33. package/dist/client/index.d.mts +1 -1
  34. package/dist/client/index.mjs +1 -1
  35. package/dist/{config-DkxPrM9l.mjs → config-BXwuX8Bx.mjs} +1 -1
  36. package/dist/{config-DkxPrM9l.mjs.map → config-BXwuX8Bx.mjs.map} +1 -1
  37. package/dist/{connection-B4zVnQIa.mjs → connection-2igzM-AT.mjs} +19 -2
  38. package/dist/connection-2igzM-AT.mjs.map +1 -0
  39. package/dist/database/instrumentation.d.mts +45 -0
  40. package/dist/database/instrumentation.d.mts.map +1 -0
  41. package/dist/database/instrumentation.mjs +61 -0
  42. package/dist/database/instrumentation.mjs.map +1 -0
  43. package/dist/db/index.d.mts +3 -3
  44. package/dist/db/index.mjs.map +1 -1
  45. package/dist/db/libsql.d.mts +1 -1
  46. package/dist/db/postgres.d.mts +1 -1
  47. package/dist/db/sqlite.d.mts +1 -1
  48. package/dist/db-errors-D0UT85nC.mjs +41 -0
  49. package/dist/db-errors-D0UT85nC.mjs.map +1 -0
  50. package/dist/{default-PUx9RK6u.mjs → default-CME5YdZ3.mjs} +1 -1
  51. package/dist/{default-PUx9RK6u.mjs.map → default-CME5YdZ3.mjs.map} +1 -1
  52. package/dist/{error-HBeQbVhV.mjs → error-CiYn9yDu.mjs} +1 -1
  53. package/dist/{error-HBeQbVhV.mjs.map → error-CiYn9yDu.mjs.map} +1 -1
  54. package/dist/{index-CRg3PWfZ.d.mts → index-BYv0mB9g.d.mts} +135 -19
  55. package/dist/index-BYv0mB9g.d.mts.map +1 -0
  56. package/dist/index.d.mts +11 -11
  57. package/dist/index.mjs +20 -18
  58. package/dist/{load-BhSSm-TS.mjs → load-CBcmDIot.mjs} +1 -1
  59. package/dist/{load-BhSSm-TS.mjs.map → load-CBcmDIot.mjs.map} +1 -1
  60. package/dist/{loader-BYzwzORf.mjs → loader-DeiBJEMe.mjs} +18 -12
  61. package/dist/loader-DeiBJEMe.mjs.map +1 -0
  62. package/dist/{manifest-schema-BsXINkQD.mjs → manifest-schema-V30qsMft.mjs} +1 -1
  63. package/dist/{manifest-schema-BsXINkQD.mjs.map → manifest-schema-V30qsMft.mjs.map} +1 -1
  64. package/dist/media/index.d.mts +1 -1
  65. package/dist/media/index.mjs +1 -1
  66. package/dist/media/local-runtime.d.mts +7 -7
  67. package/dist/{mode-CyPLdO3C.mjs → mode-CpNnGkPz.mjs} +1 -1
  68. package/dist/{mode-CyPLdO3C.mjs.map → mode-CpNnGkPz.mjs.map} +1 -1
  69. package/dist/page/index.d.mts +11 -2
  70. package/dist/page/index.d.mts.map +1 -1
  71. package/dist/page/index.mjs +23 -1
  72. package/dist/page/index.mjs.map +1 -1
  73. package/dist/{placeholder-DntBEQo7.mjs → placeholder-C-fk5hYI.mjs} +1 -1
  74. package/dist/{placeholder-DntBEQo7.mjs.map → placeholder-C-fk5hYI.mjs.map} +1 -1
  75. package/dist/{placeholder-BBCtpTES.d.mts → placeholder-tzpqGWII.d.mts} +1 -1
  76. package/dist/{placeholder-BBCtpTES.d.mts.map → placeholder-tzpqGWII.d.mts.map} +1 -1
  77. package/dist/plugins/adapt-sandbox-entry.d.mts +5 -5
  78. package/dist/plugins/adapt-sandbox-entry.mjs +1 -1
  79. package/dist/{query-B6Vu0d2i.mjs → query-Bk_3vKvU.mjs} +78 -11
  80. package/dist/query-Bk_3vKvU.mjs.map +1 -0
  81. package/dist/{registry-BgnP3ysR.mjs → registry-Ci3WxVAr.mjs} +133 -97
  82. package/dist/registry-Ci3WxVAr.mjs.map +1 -0
  83. package/dist/request-cache-DiR961CV.mjs +79 -0
  84. package/dist/request-cache-DiR961CV.mjs.map +1 -0
  85. package/dist/request-context.d.mts +19 -16
  86. package/dist/request-context.d.mts.map +1 -1
  87. package/dist/request-context.mjs.map +1 -1
  88. package/dist/{runner-DYv3rX8P.d.mts → runner-Fl2NcUUz.d.mts} +2 -2
  89. package/dist/{runner-DYv3rX8P.d.mts.map → runner-Fl2NcUUz.d.mts.map} +1 -1
  90. package/dist/runtime.d.mts +6 -6
  91. package/dist/runtime.mjs +1 -1
  92. package/dist/{search-B5p9D36n.mjs → search-DI4bM2w9.mjs} +110 -209
  93. package/dist/search-DI4bM2w9.mjs.map +1 -0
  94. package/dist/seed/index.d.mts +2 -2
  95. package/dist/seed/index.mjs +8 -7
  96. package/dist/seo/index.d.mts +1 -1
  97. package/dist/storage/local.d.mts +1 -1
  98. package/dist/storage/local.mjs +1 -1
  99. package/dist/storage/s3.d.mts +1 -1
  100. package/dist/storage/s3.mjs +1 -1
  101. package/dist/taxonomies-DbrKzDju.mjs +308 -0
  102. package/dist/taxonomies-DbrKzDju.mjs.map +1 -0
  103. package/dist/{tokens-DKHiCYCB.mjs → tokens-BFPFx3CA.mjs} +1 -1
  104. package/dist/{tokens-DKHiCYCB.mjs.map → tokens-BFPFx3CA.mjs.map} +1 -1
  105. package/dist/{transport-BtcQ-Z7T.mjs → transport-BykRfpyy.mjs} +1 -1
  106. package/dist/{transport-BtcQ-Z7T.mjs.map → transport-BykRfpyy.mjs.map} +1 -1
  107. package/dist/{transport-CKQA_G44.d.mts → transport-H4Iwx7tC.d.mts} +1 -1
  108. package/dist/{transport-CKQA_G44.d.mts.map → transport-H4Iwx7tC.d.mts.map} +1 -1
  109. package/dist/{types-BmkQR1En.d.mts → types-6CUZRrZP.d.mts} +1 -1
  110. package/dist/{types-BmkQR1En.d.mts.map → types-6CUZRrZP.d.mts.map} +1 -1
  111. package/dist/{types-B6BzlZxx.d.mts → types-8xrvl_68.d.mts} +1 -1
  112. package/dist/{types-B6BzlZxx.d.mts.map → types-8xrvl_68.d.mts.map} +1 -1
  113. package/dist/{types-Dz9_WMS6.mjs → types-BH2L167P.mjs} +1 -1
  114. package/dist/{types-Dz9_WMS6.mjs.map → types-BH2L167P.mjs.map} +1 -1
  115. package/dist/{types-DNZpaCBk.d.mts → types-CFWjXmus.d.mts} +1 -1
  116. package/dist/{types-DNZpaCBk.d.mts.map → types-CFWjXmus.d.mts.map} +1 -1
  117. package/dist/{types-gLYVCXCQ.d.mts → types-CnZYHyLW.d.mts} +55 -5
  118. package/dist/types-CnZYHyLW.d.mts.map +1 -0
  119. package/dist/{types-xxCWI3j0.mjs → types-DDS4MxsT.mjs} +11 -3
  120. package/dist/types-DDS4MxsT.mjs.map +1 -0
  121. package/dist/{types-BYWYxLcp.d.mts → types-DgrIP0tF.d.mts} +9 -2
  122. package/dist/types-DgrIP0tF.d.mts.map +1 -0
  123. package/dist/{validate-CcNRWH6I.d.mts → validate-CaLH1Ia2.d.mts} +5 -52
  124. package/dist/validate-CaLH1Ia2.d.mts.map +1 -0
  125. package/dist/{validate-DuZDIxfy.mjs → validate-CqsNItbt.mjs} +2 -2
  126. package/dist/{validate-DuZDIxfy.mjs.map → validate-CqsNItbt.mjs.map} +1 -1
  127. package/dist/version-Uaf2ynPX.mjs +7 -0
  128. package/dist/{version-DlTDRdpv.mjs.map → version-Uaf2ynPX.mjs.map} +1 -1
  129. package/package.json +10 -5
  130. package/src/after.ts +62 -0
  131. package/src/api/handlers/oauth-authorization.ts +2 -32
  132. package/src/api/handlers/oauth-clients.ts +40 -4
  133. package/src/api/handlers/taxonomies.ts +13 -0
  134. package/src/api/oauth/redirect-uri.ts +34 -0
  135. package/src/api/openapi/document.ts +126 -118
  136. package/src/api/schemas/auth.ts +7 -0
  137. package/src/api/schemas/media.ts +26 -15
  138. package/src/api/schemas/schema.ts +1 -0
  139. package/src/astro/integration/font-provider.ts +176 -0
  140. package/src/astro/integration/index.ts +42 -0
  141. package/src/astro/integration/routes.ts +17 -1
  142. package/src/astro/integration/runtime.ts +63 -0
  143. package/src/astro/integration/virtual-modules.ts +41 -39
  144. package/src/astro/integration/vite-config.ts +16 -5
  145. package/src/astro/middleware/auth.ts +39 -6
  146. package/src/astro/middleware/request-context.ts +15 -3
  147. package/src/astro/middleware.ts +340 -263
  148. package/src/astro/routes/admin.astro +10 -5
  149. package/src/astro/routes/api/auth/invite/register-options.ts +78 -0
  150. package/src/astro/routes/api/auth/passkey/verify.ts +5 -1
  151. package/src/astro/routes/api/content/[collection]/[id]/terms/[taxonomy].ts +5 -0
  152. package/src/astro/routes/api/import/wordpress/execute.ts +1 -1
  153. package/src/astro/routes/api/import/wordpress-plugin/execute.ts +1 -1
  154. package/src/astro/routes/api/media/upload-url.ts +10 -2
  155. package/src/astro/routes/api/media.ts +10 -7
  156. package/src/astro/routes/api/oauth/register.ts +178 -0
  157. package/src/astro/routes/api/oauth/token.ts +15 -0
  158. package/src/astro/routes/api/openapi.json.ts +15 -5
  159. package/src/astro/routes/api/schema/collections/[slug]/fields/[fieldSlug].ts +2 -0
  160. package/src/astro/routes/api/schema/collections/[slug]/fields/index.ts +1 -0
  161. package/src/astro/routes/api/schema/collections/[slug]/fields/reorder.ts +1 -0
  162. package/src/astro/routes/api/search/index.ts +5 -0
  163. package/src/astro/routes/api/search/suggest.ts +3 -0
  164. package/src/astro/routes/api/taxonomies/index.ts +1 -0
  165. package/src/astro/routes/api/well-known/oauth-authorization-server.ts +6 -4
  166. package/src/bylines/index.ts +22 -45
  167. package/src/components/EmDashHead.astro +23 -7
  168. package/src/components/Table.astro +73 -41
  169. package/src/components/index.ts +2 -12
  170. package/src/components/marks.ts +20 -0
  171. package/src/database/connection.ts +23 -1
  172. package/src/database/instrumentation.ts +98 -0
  173. package/src/db/adapters.ts +15 -0
  174. package/src/emdash-runtime.ts +309 -91
  175. package/src/index.ts +6 -0
  176. package/src/loader.ts +19 -24
  177. package/src/menus/index.ts +6 -3
  178. package/src/page/index.ts +1 -1
  179. package/src/page/seo-contributions.ts +36 -0
  180. package/src/plugins/context.ts +1 -0
  181. package/src/plugins/email-console.ts +9 -2
  182. package/src/plugins/types.ts +8 -0
  183. package/src/query.ts +104 -7
  184. package/src/request-cache.ts +106 -0
  185. package/src/request-context.ts +19 -0
  186. package/src/schema/query.ts +5 -2
  187. package/src/schema/registry.ts +243 -166
  188. package/src/schema/types.ts +13 -2
  189. package/src/schema/zod-generator.ts +4 -0
  190. package/src/search/fts-manager.ts +19 -5
  191. package/src/search/query.ts +4 -3
  192. package/src/seed/apply.ts +15 -1
  193. package/src/settings/index.ts +24 -5
  194. package/src/taxonomies/index.ts +324 -124
  195. package/src/utils/db-errors.ts +46 -0
  196. package/src/virtual-modules.d.ts +31 -10
  197. package/src/widgets/index.ts +54 -25
  198. package/dist/adapters-C2BzVy0p.d.mts.map +0 -1
  199. package/dist/apply-Cma_PiF6.mjs.map +0 -1
  200. package/dist/byline-WuOq9MFJ.mjs.map +0 -1
  201. package/dist/bylines-C_Wsnz4L.mjs.map +0 -1
  202. package/dist/connection-B4zVnQIa.mjs.map +0 -1
  203. package/dist/index-CRg3PWfZ.d.mts.map +0 -1
  204. package/dist/loader-BYzwzORf.mjs.map +0 -1
  205. package/dist/query-B6Vu0d2i.mjs.map +0 -1
  206. package/dist/registry-BgnP3ysR.mjs.map +0 -1
  207. package/dist/search-B5p9D36n.mjs.map +0 -1
  208. package/dist/types-BYWYxLcp.d.mts.map +0 -1
  209. package/dist/types-gLYVCXCQ.d.mts.map +0 -1
  210. package/dist/types-xxCWI3j0.mjs.map +0 -1
  211. package/dist/validate-CcNRWH6I.d.mts.map +0 -1
  212. package/dist/version-DlTDRdpv.mjs +0 -7
@@ -1,8 +1,10 @@
1
1
  import { t as __exportAll } from "./chunk-ClPoSABd.mjs";
2
+ import { getRequestContext } from "./request-context.mjs";
3
+ import { kyselyLogOption } from "./database/instrumentation.mjs";
2
4
  import { t as validateIdentifier } from "./validate-VPnKoIzW.mjs";
3
5
  import { i as isPostgres, r as currentTimestampValue } from "./dialect-helpers-DhTzaUxP.mjs";
4
6
  import { n as decodeCursor, r as encodeCursor } from "./types-CMMN0pNg.mjs";
5
- import { getRequestContext } from "./request-context.mjs";
7
+ import { t as isMissingTableError } from "./db-errors-D0UT85nC.mjs";
6
8
  import { Kysely, sql } from "kysely";
7
9
 
8
10
  //#region src/loader.ts
@@ -48,19 +50,22 @@ function getTableName(type) {
48
50
  */
49
51
  let taxonomyNames = null;
50
52
  /**
51
- * Get all taxonomy names (cached for primary DB, fresh for overrides)
53
+ * Get all taxonomy names (cached for the primary DB, bypassed only when
54
+ * the per-request DB is an isolated instance — playground / DO preview).
55
+ * Plain D1 Sessions routing shares schema with the singleton, so the
56
+ * module-scoped cache stays valid.
52
57
  */
53
58
  async function getTaxonomyNames(db) {
54
- const hasDbOverride = !!getRequestContext()?.db;
55
- if (!hasDbOverride && taxonomyNames) return taxonomyNames;
59
+ const hasIsolatedDb = getRequestContext()?.dbIsIsolated === true;
60
+ if (!hasIsolatedDb && taxonomyNames) return taxonomyNames;
56
61
  try {
57
62
  const defs = await db.selectFrom("_emdash_taxonomy_defs").select("name").execute();
58
63
  const names = new Set(defs.map((d) => d.name));
59
- if (!hasDbOverride) taxonomyNames = names;
64
+ if (!hasIsolatedDb) taxonomyNames = names;
60
65
  return names;
61
66
  } catch {
62
67
  const empty = /* @__PURE__ */ new Set();
63
- if (!hasDbOverride) taxonomyNames = empty;
68
+ if (!hasIsolatedDb) taxonomyNames = empty;
64
69
  return empty;
65
70
  }
66
71
  }
@@ -221,7 +226,10 @@ async function getDb() {
221
226
  if (!dbInstance) {
222
227
  await loadVirtualModules();
223
228
  if (!virtualConfig?.database || typeof virtualCreateDialect !== "function") throw new Error("EmDash database not configured. Add database config to emdash() in astro.config.mjs");
224
- dbInstance = new Kysely({ dialect: virtualCreateDialect(virtualConfig.database.config) });
229
+ dbInstance = new Kysely({
230
+ dialect: virtualCreateDialect(virtualConfig.database.config),
231
+ log: kyselyLogOption()
232
+ });
225
233
  }
226
234
  return dbInstance;
227
235
  }
@@ -362,9 +370,8 @@ function emdashLoader() {
362
370
  }
363
371
  };
364
372
  } catch (error) {
373
+ if (isMissingTableError(error)) return { entries: [] };
365
374
  const message = error instanceof Error ? error.message : String(error);
366
- const lowerMessage = message.toLowerCase();
367
- if (lowerMessage.includes("no such table") || lowerMessage.includes("table") && lowerMessage.includes("does not exist") || lowerMessage.includes("relation") && lowerMessage.includes("does not exist")) return { entries: [] };
368
375
  return { error: /* @__PURE__ */ new Error(`Failed to load collection: ${message}`) };
369
376
  }
370
377
  },
@@ -435,9 +442,8 @@ function emdashLoader() {
435
442
  }
436
443
  };
437
444
  } catch (error) {
445
+ if (isMissingTableError(error)) return;
438
446
  const message = error instanceof Error ? error.message : String(error);
439
- const lowerMessage = message.toLowerCase();
440
- if (lowerMessage.includes("no such table") || lowerMessage.includes("table") && lowerMessage.includes("does not exist") || lowerMessage.includes("relation") && lowerMessage.includes("does not exist")) return;
441
447
  return { error: /* @__PURE__ */ new Error(`Failed to load entry: ${message}`) };
442
448
  }
443
449
  }
@@ -446,4 +452,4 @@ function emdashLoader() {
446
452
 
447
453
  //#endregion
448
454
  export { getDb as n, loader_exports as r, emdashLoader as t };
449
- //# sourceMappingURL=loader-BYzwzORf.mjs.map
455
+ //# sourceMappingURL=loader-DeiBJEMe.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loader-DeiBJEMe.mjs","names":[],"sources":["../src/loader.ts"],"sourcesContent":["/**\n * Astro Live Collections loader for EmDash\n *\n * This loader implements the Astro LiveLoader interface to fetch content\n * at runtime from the database, enabling live editing without rebuilds.\n *\n * Architecture:\n * - Single `_emdash` Astro collection handles all content types\n * - Dialect comes from virtual module (configured in astro.config.mjs)\n * - Each content type maps to its own database table: ec_posts, ec_products, etc.\n * - `getEmDashCollection()` / `getEmDashEntry()` wrap Astro's live collection API\n */\n\nimport type { LiveLoader } from \"astro/loaders\";\nimport { Kysely, sql, type Dialect } from \"kysely\";\n\nimport { currentTimestampValue, isPostgres } from \"./database/dialect-helpers.js\";\nimport { kyselyLogOption } from \"./database/instrumentation.js\";\nimport { decodeCursor, encodeCursor } from \"./database/repositories/types.js\";\nimport { validateIdentifier } from \"./database/validate.js\";\nimport type { Database } from \"./index.js\";\nimport { getRequestContext } from \"./request-context.js\";\nimport { isMissingTableError } from \"./utils/db-errors.js\";\n\nconst FIELD_NAME_PATTERN = /^[a-zA-Z_][a-zA-Z0-9_]*$/;\n\n/**\n * System columns that are not part of the content data\n */\n/**\n * System columns excluded from entry.data\n * Note: slug is intentionally NOT excluded - it's useful as data.slug in templates\n */\nconst SYSTEM_COLUMNS = new Set([\n\t\"id\",\n\t// \"slug\" - kept in data for template access\n\t\"status\",\n\t\"author_id\",\n\t\"primary_byline_id\",\n\t\"created_at\",\n\t\"updated_at\",\n\t\"published_at\",\n\t\"scheduled_at\",\n\t\"deleted_at\",\n\t\"version\",\n\t\"live_revision_id\",\n\t\"draft_revision_id\",\n\t\"locale\",\n\t\"translation_group\",\n]);\n\n/**\n * Get the table name for a collection type\n */\nfunction getTableName(type: string): string {\n\tvalidateIdentifier(type, \"collection type\");\n\treturn `ec_${type}`;\n}\n\n/**\n * Cache for taxonomy names (only used for the primary database).\n * Skipped when a per-request DB override is active (e.g. preview mode)\n * because the override DB may have different taxonomies.\n */\nlet taxonomyNames: Set<string> | null = null;\n\n/**\n * Get all taxonomy names (cached for the primary DB, bypassed only when\n * the per-request DB is an isolated instance — playground / DO preview).\n * Plain D1 Sessions routing shares schema with the singleton, so the\n * module-scoped cache stays valid.\n */\nasync function getTaxonomyNames(db: Kysely<Database>): Promise<Set<string>> {\n\tconst hasIsolatedDb = getRequestContext()?.dbIsIsolated === true;\n\n\tif (!hasIsolatedDb && taxonomyNames) {\n\t\treturn taxonomyNames;\n\t}\n\n\ttry {\n\t\tconst defs = await db.selectFrom(\"_emdash_taxonomy_defs\").select(\"name\").execute();\n\t\tconst names = new Set(defs.map((d) => d.name));\n\t\tif (!hasIsolatedDb) {\n\t\t\ttaxonomyNames = names;\n\t\t}\n\t\treturn names;\n\t} catch {\n\t\t// Table doesn't exist yet, return empty set\n\t\tconst empty = new Set<string>();\n\t\tif (!hasIsolatedDb) {\n\t\t\ttaxonomyNames = empty;\n\t\t}\n\t\treturn empty;\n\t}\n}\n\n/**\n * System columns to include in data (mapped to camelCase where needed)\n */\nconst INCLUDE_IN_DATA: Record<string, string> = {\n\tid: \"id\",\n\tstatus: \"status\",\n\tauthor_id: \"authorId\",\n\tprimary_byline_id: \"primaryBylineId\",\n\tcreated_at: \"createdAt\",\n\tupdated_at: \"updatedAt\",\n\tpublished_at: \"publishedAt\",\n\tscheduled_at: \"scheduledAt\",\n\tdraft_revision_id: \"draftRevisionId\",\n\tlive_revision_id: \"liveRevisionId\",\n\tlocale: \"locale\",\n\ttranslation_group: \"translationGroup\",\n};\n\n/** System date columns that should be converted to Date objects */\nconst DATE_COLUMNS = new Set([\"created_at\", \"updated_at\", \"published_at\", \"scheduled_at\"]);\n\n/** Safely extract a string value from a record, returning fallback if not a string */\nfunction rowStr(row: Record<string, unknown>, key: string, fallback = \"\"): string {\n\tconst val = row[key];\n\treturn typeof val === \"string\" ? val : fallback;\n}\n\n/**\n * Map a database row to entry data\n * Extracts content fields (non-system columns) and parses JSON where needed.\n * System columns needed for templates (id, status, dates) are included with camelCase names.\n */\nfunction mapRowToData(row: Record<string, unknown>): Record<string, unknown> {\n\tconst data: Record<string, unknown> = {};\n\n\tfor (const [key, value] of Object.entries(row)) {\n\t\t// Include certain system columns (mapped to camelCase where needed)\n\t\tif (key in INCLUDE_IN_DATA) {\n\t\t\t// Convert date columns from ISO strings to Date objects\n\t\t\tif (DATE_COLUMNS.has(key)) {\n\t\t\t\tdata[INCLUDE_IN_DATA[key]] = typeof value === \"string\" ? new Date(value) : null;\n\t\t\t} else {\n\t\t\t\tdata[INCLUDE_IN_DATA[key]] = value;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (SYSTEM_COLUMNS.has(key)) continue;\n\n\t\t// Try to parse JSON strings (for portableText, json fields, etc.)\n\t\tif (typeof value === \"string\") {\n\t\t\ttry {\n\t\t\t\t// Only parse if it looks like JSON (starts with { or [)\n\t\t\t\tif (value.startsWith(\"{\") || value.startsWith(\"[\")) {\n\t\t\t\t\tdata[key] = JSON.parse(value);\n\t\t\t\t} else {\n\t\t\t\t\tdata[key] = value;\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\tdata[key] = value;\n\t\t\t}\n\t\t} else {\n\t\t\tdata[key] = value;\n\t\t}\n\t}\n\n\treturn data;\n}\n\n/**\n * Map revision data (already-parsed JSON object) to entry data.\n * Strips _-prefixed metadata keys (e.g. _slug) used internally by revisions.\n */\nfunction mapRevisionData(data: Record<string, unknown>): Record<string, unknown> {\n\tconst result: Record<string, unknown> = {};\n\tfor (const [key, value] of Object.entries(data)) {\n\t\tif (key.startsWith(\"_\")) continue; // revision metadata\n\t\tresult[key] = value;\n\t}\n\treturn result;\n}\n\n// Virtual module imports are lazy-loaded to avoid errors when importing\n// emdash outside of Astro/Vite context (e.g., in astro.config.mjs)\nlet virtualConfig:\n\t| {\n\t\t\tdatabase?: { config: unknown };\n\t\t\ti18n?: { defaultLocale: string; locales: string[]; prefixDefaultLocale?: boolean } | null;\n\t }\n\t| undefined;\nlet virtualCreateDialect: ((config: unknown) => Dialect) | undefined;\n\nasync function loadVirtualModules() {\n\tif (virtualConfig === undefined) {\n\t\t// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n\t\t// @ts-ignore - virtual module\n\t\tconst configModule = await import(\"virtual:emdash/config\");\n\t\tvirtualConfig = configModule.default;\n\t}\n\tif (virtualCreateDialect === undefined) {\n\t\t// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n\t\t// @ts-ignore - virtual module\n\t\tconst dialectModule = await import(\"virtual:emdash/dialect\");\n\t\tvirtualCreateDialect = dialectModule.createDialect;\n\t\t// dialectType is no longer needed here — dialect detection is\n\t\t// done via the db adapter instance in dialect-helpers.ts\n\t}\n}\n\n/**\n * Entry data type - generic object\n */\nexport type EntryData = Record<string, unknown>;\n\n/**\n * Sort direction\n */\nexport type SortDirection = \"asc\" | \"desc\";\n\n/**\n * Order by specification - field name to direction\n * @example { created_at: \"desc\" } - Sort by created_at descending\n * @example { title: \"asc\" } - Sort by title ascending\n */\nexport type OrderBySpec = Record<string, SortDirection>;\n\n/**\n * Build WHERE clause for status filtering.\n * When filtering for 'published' status, also include scheduled content\n * whose scheduled_at time has passed (treating it as effectively published).\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any -- accepts any Kysely instance\nfunction buildStatusCondition(\n\tdb: Kysely<any>,\n\tstatus: string,\n\ttablePrefix?: string,\n): ReturnType<typeof sql> {\n\tconst statusField = tablePrefix ? `${tablePrefix}.status` : \"status\";\n\tconst scheduledAtField = tablePrefix ? `${tablePrefix}.scheduled_at` : \"scheduled_at\";\n\n\tif (status === \"published\") {\n\t\t// Include both published content AND scheduled content past its publish time.\n\t\t// scheduled_at is stored as text (ISO 8601). On Postgres, we must cast it\n\t\t// to timestamptz for the comparison with CURRENT_TIMESTAMP to work.\n\t\tconst scheduledAtExpr = isPostgres(db)\n\t\t\t? sql`${sql.ref(scheduledAtField)}::timestamptz`\n\t\t\t: sql.ref(scheduledAtField);\n\t\treturn sql`(${sql.ref(statusField)} = 'published' OR (${sql.ref(statusField)} = 'scheduled' AND ${scheduledAtExpr} <= ${currentTimestampValue(db)}))`;\n\t}\n\n\t// For other statuses (draft, archived), just match exactly\n\treturn sql`${sql.ref(statusField)} = ${status}`;\n}\n\n/**\n * Resolved primary sort field and direction (used for cursor pagination).\n */\ninterface PrimarySort {\n\tfield: string;\n\tdirection: SortDirection;\n}\n\n/**\n * Get the primary sort field from an orderBy spec (first valid field, or default).\n */\nfunction getPrimarySort(orderBy: OrderBySpec | undefined, tablePrefix?: string): PrimarySort {\n\tif (orderBy) {\n\t\tfor (const [field, direction] of Object.entries(orderBy)) {\n\t\t\tif (FIELD_NAME_PATTERN.test(field)) {\n\t\t\t\tconst fullField = tablePrefix ? `${tablePrefix}.${field}` : field;\n\t\t\t\treturn { field: fullField, direction };\n\t\t\t}\n\t\t}\n\t}\n\tconst defaultField = tablePrefix ? `${tablePrefix}.created_at` : \"created_at\";\n\treturn { field: defaultField, direction: \"desc\" };\n}\n\n/**\n * Build ORDER BY clause from orderBy spec\n * Validates field names to prevent SQL injection (alphanumeric + underscore only)\n * Supports multiple sort fields in object key order\n */\nfunction buildOrderByClause(\n\torderBy: OrderBySpec | undefined,\n\ttablePrefix?: string,\n): ReturnType<typeof sql> {\n\t// Default to created_at DESC\n\tif (!orderBy || Object.keys(orderBy).length === 0) {\n\t\tconst field = tablePrefix ? `${tablePrefix}.created_at` : \"created_at\";\n\t\treturn sql`ORDER BY ${sql.ref(field)} DESC, ${sql.ref(tablePrefix ? `${tablePrefix}.id` : \"id\")} DESC`;\n\t}\n\n\tconst sortParts: ReturnType<typeof sql>[] = [];\n\n\tfor (const [field, direction] of Object.entries(orderBy)) {\n\t\t// Validate field name (alphanumeric + underscore only)\n\t\tif (!FIELD_NAME_PATTERN.test(field)) {\n\t\t\tcontinue; // Skip invalid field names\n\t\t}\n\n\t\tconst fullField = tablePrefix ? `${tablePrefix}.${field}` : field;\n\t\tconst dir = direction === \"asc\" ? sql`ASC` : sql`DESC`;\n\t\tsortParts.push(sql`${sql.ref(fullField)} ${dir}`);\n\t}\n\n\t// If no valid sort fields, fall back to default\n\tif (sortParts.length === 0) {\n\t\tconst defaultField = tablePrefix ? `${tablePrefix}.created_at` : \"created_at\";\n\t\treturn sql`ORDER BY ${sql.ref(defaultField)} DESC, ${sql.ref(tablePrefix ? `${tablePrefix}.id` : \"id\")} DESC`;\n\t}\n\n\t// Add id as tiebreaker to ensure stable cursor ordering\n\tconst primary = getPrimarySort(orderBy, tablePrefix);\n\tconst idField = tablePrefix ? `${tablePrefix}.id` : \"id\";\n\tconst idDir = primary.direction === \"asc\" ? sql`ASC` : sql`DESC`;\n\tsortParts.push(sql`${sql.ref(idField)} ${idDir}`);\n\n\treturn sql`ORDER BY ${sql.join(sortParts, sql`, `)}`;\n}\n\n/**\n * Build a cursor WHERE condition for keyset pagination.\n * Uses the primary sort field + id as tiebreaker for stable ordering.\n */\nfunction buildCursorCondition(\n\tcursor: string,\n\torderBy: OrderBySpec | undefined,\n\ttablePrefix?: string,\n): ReturnType<typeof sql> | null {\n\tconst decoded = decodeCursor(cursor);\n\tif (!decoded) return null;\n\n\tconst { orderValue, id: cursorId } = decoded;\n\tconst primary = getPrimarySort(orderBy, tablePrefix);\n\tconst idField = tablePrefix ? `${tablePrefix}.id` : \"id\";\n\n\tif (primary.direction === \"desc\") {\n\t\treturn sql`(${sql.ref(primary.field)} < ${orderValue} OR (${sql.ref(primary.field)} = ${orderValue} AND ${sql.ref(idField)} < ${cursorId}))`;\n\t}\n\treturn sql`(${sql.ref(primary.field)} > ${orderValue} OR (${sql.ref(primary.field)} = ${orderValue} AND ${sql.ref(idField)} > ${cursorId}))`;\n}\n\n/**\n * Filter for loadCollection - type is required\n */\nexport interface CollectionFilter {\n\ttype: string;\n\tstatus?: \"draft\" | \"published\" | \"archived\";\n\tlimit?: number;\n\t/**\n\t * Opaque cursor for keyset pagination.\n\t * Pass the `nextCursor` value from a previous result to fetch the next page.\n\t */\n\tcursor?: string;\n\t/**\n\t * Filter by field values or taxonomy terms\n\t */\n\twhere?: Record<string, string | string[]>;\n\t/**\n\t * Order results by field(s)\n\t * @default { created_at: \"desc\" }\n\t */\n\torderBy?: OrderBySpec;\n\t/**\n\t * Filter by locale (e.g. 'en', 'fr').\n\t * When set, only returns content in this locale.\n\t */\n\tlocale?: string;\n}\n\n/**\n * Filter for loadEntry - type and id are required\n */\nexport interface EntryFilter {\n\ttype: string;\n\tid: string;\n\t/**\n\t * When set, fetch content data from this revision instead of the content table.\n\t * Used by preview mode to serve draft revision data.\n\t */\n\trevisionId?: string;\n\t/**\n\t * Locale to scope slug lookup. Only affects slug resolution;\n\t * IDs are globally unique and always resolve regardless of locale.\n\t */\n\tlocale?: string;\n}\n\n// Cached database instance (shared across calls)\nlet dbInstance: Kysely<Database> | null = null;\n\n/**\n * Get the database instance. Used by query wrapper functions and middleware.\n *\n * Checks the ALS request context first — if a per-request DB override is set\n * (e.g. by DO preview middleware), it takes precedence over the module-level\n * cached instance. This allows preview mode to route queries to an isolated\n * Durable Object database without modifying any calling code.\n *\n * Initializes the default database on first call using config from virtual module.\n */\nexport async function getDb(): Promise<Kysely<Database>> {\n\t// Per-request DB override via ALS (normal mode)\n\tconst ctx = getRequestContext();\n\tif (ctx?.db) {\n\t\treturn ctx.db as Kysely<Database>; // eslint-disable-line typescript-eslint(no-unsafe-type-assertion) -- db is typed as unknown in RequestContext to avoid circular deps\n\t}\n\n\tif (!dbInstance) {\n\t\tawait loadVirtualModules();\n\t\tif (!virtualConfig?.database || typeof virtualCreateDialect !== \"function\") {\n\t\t\tthrow new Error(\n\t\t\t\t\"EmDash database not configured. Add database config to emdash() in astro.config.mjs\",\n\t\t\t);\n\t\t}\n\t\tconst dialect = virtualCreateDialect(virtualConfig.database.config);\n\t\tdbInstance = new Kysely<Database>({ dialect, log: kyselyLogOption() });\n\t}\n\treturn dbInstance;\n}\n\n/**\n * Create an EmDash Live Collections loader\n *\n * This loader handles ALL content types in a single Astro collection.\n * Use `getEmDashCollection()` and `getEmDashEntry()` to query\n * specific content types.\n *\n * Database is configured in astro.config.mjs via the emdash() integration.\n *\n * @example\n * ```ts\n * // src/live.config.ts\n * import { defineLiveCollection } from \"astro:content\";\n * import { emdashLoader } from \"emdash\";\n *\n * export const collections = {\n * emdash: defineLiveCollection({\n * loader: emdashLoader(),\n * }),\n * };\n * ```\n */\nexport function emdashLoader(): LiveLoader<EntryData, EntryFilter, CollectionFilter> {\n\treturn {\n\t\tname: \"emdash\",\n\n\t\t/**\n\t\t * Load all entries for a content type\n\t\t */\n\t\tasync loadCollection({ filter }) {\n\t\t\ttry {\n\t\t\t\t// Get DB instance (initializes on first use)\n\t\t\t\tconst db = await getDb();\n\n\t\t\t\t// Type filter is required\n\t\t\t\tconst type = filter?.type;\n\t\t\t\tif (!type) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\terror: new Error(\n\t\t\t\t\t\t\t\"type filter is required. Use getEmDashCollection() instead of getLiveCollection() directly.\",\n\t\t\t\t\t\t),\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\t// Query the per-collection table (ec_posts, ec_products, etc.)\n\t\t\t\tconst tableName = getTableName(type);\n\n\t\t\t\t// Build query with dynamic table name\n\t\t\t\tconst status = filter?.status || \"published\";\n\t\t\t\tconst limit = filter?.limit;\n\t\t\t\tconst cursor = filter?.cursor;\n\t\t\t\tconst where = filter?.where;\n\t\t\t\tconst orderBy = filter?.orderBy;\n\t\t\t\tconst locale = filter?.locale;\n\n\t\t\t\t// Cursor pagination: over-fetch by 1 to detect next page\n\t\t\t\tconst fetchLimit = limit ? limit + 1 : undefined;\n\n\t\t\t\t// Build cursor condition if cursor is provided\n\t\t\t\tconst cursorCondition = cursor ? buildCursorCondition(cursor, orderBy) : null;\n\t\t\t\tconst cursorConditionPrefixed = cursor\n\t\t\t\t\t? buildCursorCondition(cursor, orderBy, tableName)\n\t\t\t\t\t: null;\n\n\t\t\t\t// Check if we need taxonomy filtering\n\t\t\t\tlet result: { rows: Record<string, unknown>[] };\n\n\t\t\t\tif (where && Object.keys(where).length > 0) {\n\t\t\t\t\t// Get taxonomy names to detect taxonomy filters\n\t\t\t\t\tconst taxNames = await getTaxonomyNames(db);\n\t\t\t\t\tconst taxonomyFilters: Record<string, string | string[]> = {};\n\n\t\t\t\t\tfor (const [key, value] of Object.entries(where)) {\n\t\t\t\t\t\tif (taxNames.has(key)) {\n\t\t\t\t\t\t\ttaxonomyFilters[key] = value;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// If we have taxonomy filters, use JOIN\n\t\t\t\t\tif (Object.keys(taxonomyFilters).length > 0) {\n\t\t\t\t\t\t// Build query with taxonomy JOIN\n\t\t\t\t\t\t// For now, support single taxonomy filter (can extend later for multiple)\n\t\t\t\t\t\tconst [taxName, termSlugs] = Object.entries(taxonomyFilters)[0];\n\t\t\t\t\t\tconst slugs = Array.isArray(termSlugs) ? termSlugs : [termSlugs];\n\t\t\t\t\t\tconst orderByClause = buildOrderByClause(orderBy, tableName);\n\n\t\t\t\t\t\tconst statusCondition = buildStatusCondition(db, status, tableName);\n\t\t\t\t\t\tconst localeCondition = locale\n\t\t\t\t\t\t\t? sql`AND ${sql.ref(tableName)}.locale = ${locale}`\n\t\t\t\t\t\t\t: sql``;\n\t\t\t\t\t\tconst cursorCond = cursorConditionPrefixed\n\t\t\t\t\t\t\t? sql`AND ${cursorConditionPrefixed}`\n\t\t\t\t\t\t\t: sql``;\n\t\t\t\t\t\tresult = await sql<Record<string, unknown>>`\n\t\t\t\t\t\t\tSELECT DISTINCT ${sql.ref(tableName)}.* FROM ${sql.ref(tableName)}\n\t\t\t\t\t\t\tINNER JOIN content_taxonomies ct\n\t\t\t\t\t\t\t\tON ct.collection = ${type}\n\t\t\t\t\t\t\t\tAND ct.entry_id = ${sql.ref(tableName)}.id\n\t\t\t\t\t\t\tINNER JOIN taxonomies t\n\t\t\t\t\t\t\t\tON t.id = ct.taxonomy_id\n\t\t\t\t\t\t\tWHERE ${sql.ref(tableName)}.deleted_at IS NULL\n\t\t\t\t\t\t\t\tAND ${statusCondition}\n\t\t\t\t\t\t\t\t${localeCondition}\n\t\t\t\t\t\t\t\t${cursorCond}\n\t\t\t\t\t\t\t\tAND t.name = ${taxName}\n\t\t\t\t\t\t\t\tAND t.slug IN (${sql.join(slugs.map((s) => sql`${s}`))})\n\t\t\t\t\t\t\t${orderByClause}\n\t\t\t\t\t\t\t${fetchLimit ? sql`LIMIT ${fetchLimit}` : sql``}\n\t\t\t\t\t\t`.execute(db);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// No taxonomy filters, use simple query\n\t\t\t\t\t\tconst orderByClause = buildOrderByClause(orderBy);\n\t\t\t\t\t\tconst statusCondition = buildStatusCondition(db, status);\n\t\t\t\t\t\tconst localeFilter = locale ? sql`AND locale = ${locale}` : sql``;\n\t\t\t\t\t\tconst cursorCond = cursorCondition ? sql`AND ${cursorCondition}` : sql``;\n\t\t\t\t\t\tresult = await sql<Record<string, unknown>>`\n\t\t\t\t\t\t\tSELECT * FROM ${sql.ref(tableName)}\n\t\t\t\t\t\t\tWHERE deleted_at IS NULL\n\t\t\t\t\t\t\tAND ${statusCondition}\n\t\t\t\t\t\t\t${localeFilter}\n\t\t\t\t\t\t\t${cursorCond}\n\t\t\t\t\t\t\t${orderByClause}\n\t\t\t\t\t\t\t${fetchLimit ? sql`LIMIT ${fetchLimit}` : sql``}\n\t\t\t\t\t\t`.execute(db);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// No where clause, use simple query\n\t\t\t\t\tconst orderByClause = buildOrderByClause(orderBy);\n\t\t\t\t\tconst statusCondition = buildStatusCondition(db, status);\n\t\t\t\t\tconst localeFilter = locale ? sql`AND locale = ${locale}` : sql``;\n\t\t\t\t\tconst cursorCond = cursorCondition ? sql`AND ${cursorCondition}` : sql``;\n\t\t\t\t\tresult = await sql<Record<string, unknown>>`\n\t\t\t\t\t\tSELECT * FROM ${sql.ref(tableName)}\n\t\t\t\t\t\tWHERE deleted_at IS NULL\n\t\t\t\t\t\tAND ${statusCondition}\n\t\t\t\t\t\t${localeFilter}\n\t\t\t\t\t\t${cursorCond}\n\t\t\t\t\t\t${orderByClause}\n\t\t\t\t\t\t${fetchLimit ? sql`LIMIT ${fetchLimit}` : sql``}\n\t\t\t\t\t`.execute(db);\n\t\t\t\t}\n\n\t\t\t\t// Detect whether there are more results (over-fetched by 1)\n\t\t\t\tconst hasMore = limit ? result.rows.length > limit : false;\n\t\t\t\tconst rows = hasMore ? result.rows.slice(0, limit) : result.rows;\n\n\t\t\t\t// Map rows to entries\n\t\t\t\tconst i18nConfig = virtualConfig?.i18n;\n\t\t\t\tconst i18nEnabled = i18nConfig && i18nConfig.locales.length > 1;\n\t\t\t\tconst entries = rows.map((row) => {\n\t\t\t\t\tconst slug = rowStr(row, \"slug\") || rowStr(row, \"id\");\n\t\t\t\t\tconst rowLocale = rowStr(row, \"locale\");\n\t\t\t\t\tconst shouldPrefix =\n\t\t\t\t\t\ti18nEnabled &&\n\t\t\t\t\t\trowLocale !== \"\" &&\n\t\t\t\t\t\t(rowLocale !== i18nConfig.defaultLocale || i18nConfig.prefixDefaultLocale);\n\t\t\t\t\tconst id = shouldPrefix ? `${rowLocale}/${slug}` : slug;\n\t\t\t\t\treturn {\n\t\t\t\t\t\tid,\n\t\t\t\t\t\tslug: rowStr(row, \"slug\"),\n\t\t\t\t\t\tstatus: rowStr(row, \"status\", \"draft\"),\n\t\t\t\t\t\tdata: mapRowToData(row),\n\t\t\t\t\t\tcacheHint: {\n\t\t\t\t\t\t\ttags: [rowStr(row, \"id\")],\n\t\t\t\t\t\t\tlastModified: row.updated_at ? new Date(rowStr(row, \"updated_at\")) : undefined,\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t});\n\n\t\t\t\t// Encode nextCursor from the last row if there are more results\n\t\t\t\tlet nextCursor: string | undefined;\n\t\t\t\tif (hasMore && rows.length > 0) {\n\t\t\t\t\tconst lastRow = rows.at(-1)!;\n\t\t\t\t\tconst primary = getPrimarySort(orderBy);\n\t\t\t\t\t// Strip table prefix from field name for row lookup\n\t\t\t\t\tconst fieldName = primary.field.includes(\".\")\n\t\t\t\t\t\t? primary.field.split(\".\").pop()!\n\t\t\t\t\t\t: primary.field;\n\t\t\t\t\tconst lastOrderValue = lastRow[fieldName];\n\t\t\t\t\tconst orderStr =\n\t\t\t\t\t\ttypeof lastOrderValue === \"string\" || typeof lastOrderValue === \"number\"\n\t\t\t\t\t\t\t? String(lastOrderValue)\n\t\t\t\t\t\t\t: \"\";\n\t\t\t\t\tnextCursor = encodeCursor(orderStr, String(lastRow.id));\n\t\t\t\t}\n\n\t\t\t\t// Collection-level cache hint uses the most recent updated_at\n\t\t\t\tlet collectionLastModified: Date | undefined;\n\t\t\t\tfor (const row of rows) {\n\t\t\t\t\tif (row.updated_at) {\n\t\t\t\t\t\tconst d = new Date(rowStr(row, \"updated_at\"));\n\t\t\t\t\t\tif (!collectionLastModified || d > collectionLastModified) {\n\t\t\t\t\t\t\tcollectionLastModified = d;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tentries,\n\t\t\t\t\tnextCursor,\n\t\t\t\t\tcacheHint: {\n\t\t\t\t\t\ttags: [type],\n\t\t\t\t\t\tlastModified: collectionLastModified,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\t// Handle missing table gracefully - return empty collection.\n\t\t\t\t// This happens before migrations have run.\n\t\t\t\tif (isMissingTableError(error)) {\n\t\t\t\t\treturn { entries: [] };\n\t\t\t\t}\n\n\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\treturn {\n\t\t\t\t\terror: new Error(`Failed to load collection: ${message}`),\n\t\t\t\t};\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Load a single entry by type and ID/slug\n\t\t *\n\t\t * When filter.revisionId is set (preview mode), the entry's data\n\t\t * comes from the revisions table instead of the content table columns.\n\t\t */\n\t\tasync loadEntry({ filter }) {\n\t\t\ttry {\n\t\t\t\t// Get DB instance\n\t\t\t\tconst db = await getDb();\n\n\t\t\t\t// Both type and id are required\n\t\t\t\tconst type = filter?.type;\n\t\t\t\tconst id = filter?.id;\n\n\t\t\t\tif (!type || !id) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\terror: new Error(\n\t\t\t\t\t\t\t\"type and id filters are required. Use getEmDashEntry() instead of getLiveEntry() directly.\",\n\t\t\t\t\t\t),\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\t// Query the per-collection table\n\t\t\t\tconst tableName = getTableName(type);\n\t\t\t\tconst locale = filter?.locale;\n\n\t\t\t\t// Use raw SQL for dynamic table name, match by slug or id\n\t\t\t\t// When locale is specified, prefer locale-scoped slug match,\n\t\t\t\t// but IDs are globally unique so always check id without locale scope\n\t\t\t\tconst result = locale\n\t\t\t\t\t? await sql<Record<string, unknown>>`\n\t\t\t\t\t\t\tSELECT * FROM ${sql.ref(tableName)}\n\t\t\t\t\t\t\tWHERE deleted_at IS NULL\n\t\t\t\t\t\t\tAND ((slug = ${id} AND locale = ${locale}) OR id = ${id})\n\t\t\t\t\t\t\tLIMIT 1\n\t\t\t\t\t\t`.execute(db)\n\t\t\t\t\t: await sql<Record<string, unknown>>`\n\t\t\t\t\t\t\tSELECT * FROM ${sql.ref(tableName)}\n\t\t\t\t\t\t\tWHERE deleted_at IS NULL\n\t\t\t\t\t\t\tAND (slug = ${id} OR id = ${id})\n\t\t\t\t\t\t\tLIMIT 1\n\t\t\t\t\t\t`.execute(db);\n\n\t\t\t\tconst row = result.rows[0];\n\t\t\t\tif (!row) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\tconst i18nConfig = virtualConfig?.i18n;\n\t\t\t\tconst i18nEnabled = i18nConfig && i18nConfig.locales.length > 1;\n\t\t\t\tconst entrySlug = rowStr(row, \"slug\") || rowStr(row, \"id\");\n\t\t\t\tconst entryLocale = rowStr(row, \"locale\");\n\t\t\t\tconst shouldPrefixEntry =\n\t\t\t\t\ti18nEnabled &&\n\t\t\t\t\tentryLocale !== \"\" &&\n\t\t\t\t\t(entryLocale !== i18nConfig.defaultLocale || i18nConfig.prefixDefaultLocale);\n\t\t\t\tconst entryId = shouldPrefixEntry ? `${entryLocale}/${entrySlug}` : entrySlug;\n\n\t\t\t\t// Preview mode: override content fields with revision data,\n\t\t\t\t// keeping system metadata from the content table row.\n\t\t\t\tconst revisionId = filter?.revisionId;\n\t\t\t\tif (revisionId) {\n\t\t\t\t\tconst revRow = await sql<{ data: string }>`\n\t\t\t\t\t\tSELECT data FROM revisions\n\t\t\t\t\t\tWHERE id = ${revisionId}\n\t\t\t\t\t\tLIMIT 1\n\t\t\t\t\t`.execute(db);\n\n\t\t\t\t\tconst revData = revRow.rows[0];\n\t\t\t\t\tif (revData) {\n\t\t\t\t\t\tconst parsed: Record<string, unknown> = JSON.parse(revData.data);\n\t\t\t\t\t\t// System metadata from content table + content fields from revision\n\t\t\t\t\t\tconst systemData: Record<string, unknown> = {};\n\t\t\t\t\t\tfor (const [key, mappedKey] of Object.entries(INCLUDE_IN_DATA)) {\n\t\t\t\t\t\t\tif (key in row) {\n\t\t\t\t\t\t\t\tif (DATE_COLUMNS.has(key)) {\n\t\t\t\t\t\t\t\t\tsystemData[mappedKey] = typeof row[key] === \"string\" ? new Date(row[key]) : null;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tsystemData[mappedKey] = row[key];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// Use slug from revision metadata if present, else from content table\n\t\t\t\t\t\tconst slug = typeof parsed._slug === \"string\" ? parsed._slug : rowStr(row, \"slug\");\n\t\t\t\t\t\tconst revSlug = slug || rowStr(row, \"id\");\n\t\t\t\t\t\tconst revLocale = rowStr(row, \"locale\");\n\t\t\t\t\t\tconst shouldPrefixRev =\n\t\t\t\t\t\t\ti18nEnabled &&\n\t\t\t\t\t\t\trevLocale !== \"\" &&\n\t\t\t\t\t\t\t(revLocale !== i18nConfig.defaultLocale || i18nConfig.prefixDefaultLocale);\n\t\t\t\t\t\tconst revId = shouldPrefixRev ? `${revLocale}/${revSlug}` : revSlug;\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tid: revId,\n\t\t\t\t\t\t\tslug,\n\t\t\t\t\t\t\tstatus: rowStr(row, \"status\", \"draft\"),\n\t\t\t\t\t\t\tdata: { ...systemData, slug, ...mapRevisionData(parsed) },\n\t\t\t\t\t\t\tcacheHint: {\n\t\t\t\t\t\t\t\ttags: [rowStr(row, \"id\")],\n\t\t\t\t\t\t\t\tlastModified: row.updated_at ? new Date(rowStr(row, \"updated_at\")) : undefined,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tid: entryId,\n\t\t\t\t\tslug: rowStr(row, \"slug\"),\n\t\t\t\t\tstatus: rowStr(row, \"status\", \"draft\"),\n\t\t\t\t\tdata: mapRowToData(row),\n\t\t\t\t\tcacheHint: {\n\t\t\t\t\t\ttags: [rowStr(row, \"id\")],\n\t\t\t\t\t\tlastModified: row.updated_at ? new Date(rowStr(row, \"updated_at\")) : undefined,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\t// Handle missing table gracefully - return undefined (not found).\n\t\t\t\t// This happens before migrations have run.\n\t\t\t\tif (isMissingTableError(error)) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\treturn {\n\t\t\t\t\terror: new Error(`Failed to load entry: ${message}`),\n\t\t\t\t};\n\t\t\t}\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;AAwBA,MAAM,qBAAqB;;;;;;;;AAS3B,MAAM,iBAAiB,IAAI,IAAI;CAC9B;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA,CAAC;;;;AAKF,SAAS,aAAa,MAAsB;AAC3C,oBAAmB,MAAM,kBAAkB;AAC3C,QAAO,MAAM;;;;;;;AAQd,IAAI,gBAAoC;;;;;;;AAQxC,eAAe,iBAAiB,IAA4C;CAC3E,MAAM,gBAAgB,mBAAmB,EAAE,iBAAiB;AAE5D,KAAI,CAAC,iBAAiB,cACrB,QAAO;AAGR,KAAI;EACH,MAAM,OAAO,MAAM,GAAG,WAAW,wBAAwB,CAAC,OAAO,OAAO,CAAC,SAAS;EAClF,MAAM,QAAQ,IAAI,IAAI,KAAK,KAAK,MAAM,EAAE,KAAK,CAAC;AAC9C,MAAI,CAAC,cACJ,iBAAgB;AAEjB,SAAO;SACA;EAEP,MAAM,wBAAQ,IAAI,KAAa;AAC/B,MAAI,CAAC,cACJ,iBAAgB;AAEjB,SAAO;;;;;;AAOT,MAAM,kBAA0C;CAC/C,IAAI;CACJ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aAAa,IAAI,IAAI,CACxB,YAAW,aAAa,OAAO,IAAI,SAAS,WAAW,IAAI,KAAK,IAAI,KAAK,GAAG;UAE5E,YAAW,aAAa,IAAI;MAK/B,MAAM,OAAO,OAAO,OAAO,UAAU,WAAW,OAAO,QAAQ,OAAO,KAAK,OAAO;MAClF,MAAM,UAAU,QAAQ,OAAO,KAAK,KAAK;MACzC,MAAM,YAAY,OAAO,KAAK,SAAS;AAMvC,aAAO;OACN,IALA,eACA,cAAc,OACb,cAAc,WAAW,iBAAiB,WAAW,uBACvB,GAAG,UAAU,GAAG,YAAY;OAG3D;OACA,QAAQ,OAAO,KAAK,UAAU,QAAQ;OACtC,MAAM;QAAE,GAAG;QAAY;QAAM,GAAG,gBAAgB,OAAO;QAAE;OACzD,WAAW;QACV,MAAM,CAAC,OAAO,KAAK,KAAK,CAAC;QACzB,cAAc,IAAI,aAAa,IAAI,KAAK,OAAO,KAAK,aAAa,CAAC,GAAG;QACrE;OACD;;;AAIH,WAAO;KACN,IAAI;KACJ,MAAM,OAAO,KAAK,OAAO;KACzB,QAAQ,OAAO,KAAK,UAAU,QAAQ;KACtC,MAAM,aAAa,IAAI;KACvB,WAAW;MACV,MAAM,CAAC,OAAO,KAAK,KAAK,CAAC;MACzB,cAAc,IAAI,aAAa,IAAI,KAAK,OAAO,KAAK,aAAa,CAAC,GAAG;MACrE;KACD;YACO,OAAO;AAGf,QAAI,oBAAoB,MAAM,CAC7B;IAGD,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;AACtE,WAAO,EACN,uBAAO,IAAI,MAAM,yBAAyB,UAAU,EACpD;;;EAGH"}
@@ -184,4 +184,4 @@ function normalizeManifestRoute(entry) {
184
184
 
185
185
  //#endregion
186
186
  export { pluginManifestSchema as i, PLUGIN_CAPABILITIES as n, normalizeManifestRoute as r, HOOK_NAMES as t };
187
- //# sourceMappingURL=manifest-schema-BsXINkQD.mjs.map
187
+ //# sourceMappingURL=manifest-schema-V30qsMft.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"manifest-schema-BsXINkQD.mjs","names":[],"sources":["../src/plugins/manifest-schema.ts"],"sourcesContent":["/**\n * Zod schema for PluginManifest validation\n *\n * Used to validate manifest.json from plugin bundles at every parse site:\n * - Client-side download (marketplace.ts extractBundle)\n * - R2 load (api/handlers/marketplace.ts loadBundleFromR2)\n * - CLI publish preview (cli/commands/publish.ts readManifestFromTarball)\n * - Marketplace ingest extends this with publishing-specific fields\n */\n\nimport { z } from \"zod\";\n\n// ── Enum values (must stay in sync with types.ts) ───────────────\n\nexport const PLUGIN_CAPABILITIES = [\n\t\"network:fetch\",\n\t\"network:fetch:any\",\n\t\"read:content\",\n\t\"write:content\",\n\t\"read:media\",\n\t\"write:media\",\n\t\"read:users\",\n\t\"email:send\",\n\t\"email:provide\",\n\t\"email:intercept\",\n\t\"page:inject\",\n] as const;\n\n/** Must stay in sync with FieldType in schema/types.ts */\nconst FIELD_TYPES = [\n\t\"string\",\n\t\"text\",\n\t\"number\",\n\t\"integer\",\n\t\"boolean\",\n\t\"datetime\",\n\t\"select\",\n\t\"multiSelect\",\n\t\"portableText\",\n\t\"image\",\n\t\"file\",\n\t\"reference\",\n\t\"json\",\n\t\"slug\",\n\t\"repeater\",\n] as const;\n\nexport const HOOK_NAMES = [\n\t\"plugin:install\",\n\t\"plugin:activate\",\n\t\"plugin:deactivate\",\n\t\"plugin:uninstall\",\n\t\"content:beforeSave\",\n\t\"content:afterSave\",\n\t\"content:beforeDelete\",\n\t\"content:afterDelete\",\n\t\"content:afterPublish\",\n\t\"content:afterUnpublish\",\n\t\"media:beforeUpload\",\n\t\"media:afterUpload\",\n\t\"cron\",\n\t\"email:beforeSend\",\n\t\"email:deliver\",\n\t\"email:afterSend\",\n\t\"comment:beforeCreate\",\n\t\"comment:moderate\",\n\t\"comment:afterCreate\",\n\t\"comment:afterModerate\",\n\t\"page:metadata\",\n\t\"page:fragments\",\n] as const;\n\n/**\n * Structured hook entry for manifest — name plus optional metadata.\n * During a transition period, both plain strings and objects are accepted.\n */\nconst manifestHookEntrySchema = z.object({\n\tname: z.enum(HOOK_NAMES),\n\texclusive: z.boolean().optional(),\n\tpriority: z.number().int().optional(),\n\ttimeout: z.number().int().positive().optional(),\n});\n\n/**\n * Structured route entry for manifest — name plus optional metadata.\n * Both plain strings and objects are accepted; strings are normalized\n * to `{ name }` objects via `normalizeManifestRoute()`.\n */\n/** Route names must be safe path segments — alphanumeric, hyphens, underscores, forward slashes */\nconst routeNamePattern = /^[a-zA-Z0-9][a-zA-Z0-9_\\-/]*$/;\n\nconst manifestRouteEntrySchema = z.object({\n\tname: z.string().min(1).regex(routeNamePattern, \"Route name must be a safe path segment\"),\n\tpublic: z.boolean().optional(),\n});\n\n// ── Sub-schemas ─────────────────────────────────────────────────\n\n/** Index field names must be valid identifiers to prevent SQL injection via JSON path expressions */\nconst indexFieldName = z.string().regex(/^[a-zA-Z][a-zA-Z0-9_]*$/);\n\nconst storageCollectionSchema = z.object({\n\tindexes: z.array(z.union([indexFieldName, z.array(indexFieldName)])),\n\tuniqueIndexes: z.array(z.union([indexFieldName, z.array(indexFieldName)])).optional(),\n});\n\nconst baseSettingFields = {\n\tlabel: z.string(),\n\tdescription: z.string().optional(),\n};\n\nconst settingFieldSchema = z.discriminatedUnion(\"type\", [\n\tz.object({\n\t\t...baseSettingFields,\n\t\ttype: z.literal(\"string\"),\n\t\tdefault: z.string().optional(),\n\t\tmultiline: z.boolean().optional(),\n\t}),\n\tz.object({\n\t\t...baseSettingFields,\n\t\ttype: z.literal(\"number\"),\n\t\tdefault: z.number().optional(),\n\t\tmin: z.number().optional(),\n\t\tmax: z.number().optional(),\n\t}),\n\tz.object({ ...baseSettingFields, type: z.literal(\"boolean\"), default: z.boolean().optional() }),\n\tz.object({\n\t\t...baseSettingFields,\n\t\ttype: z.literal(\"select\"),\n\t\toptions: z.array(z.object({ value: z.string(), label: z.string() })),\n\t\tdefault: z.string().optional(),\n\t}),\n\tz.object({ ...baseSettingFields, type: z.literal(\"secret\") }),\n]);\n\nconst adminPageSchema = z.object({\n\tpath: z.string(),\n\tlabel: z.string(),\n\ticon: z.string().optional(),\n});\n\nconst dashboardWidgetSchema = z.object({\n\tid: z.string(),\n\tsize: z.enum([\"full\", \"half\", \"third\"]).optional(),\n\ttitle: z.string().optional(),\n});\n\nconst pluginAdminConfigSchema = z.object({\n\tentry: z.string().optional(),\n\tsettingsSchema: z.record(z.string(), settingFieldSchema).optional(),\n\tpages: z.array(adminPageSchema).optional(),\n\twidgets: z.array(dashboardWidgetSchema).optional(),\n\tfieldWidgets: z\n\t\t.array(\n\t\t\tz.object({\n\t\t\t\tname: z.string().min(1),\n\t\t\t\tlabel: z.string().min(1),\n\t\t\t\tfieldTypes: z.array(z.enum(FIELD_TYPES)),\n\t\t\t\telements: z\n\t\t\t\t\t.array(\n\t\t\t\t\t\tz\n\t\t\t\t\t\t\t.object({\n\t\t\t\t\t\t\t\ttype: z.string(),\n\t\t\t\t\t\t\t\taction_id: z.string(),\n\t\t\t\t\t\t\t\tlabel: z.string().optional(),\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t.passthrough(),\n\t\t\t\t\t)\n\t\t\t\t\t.optional(),\n\t\t\t}),\n\t\t)\n\t\t.optional(),\n});\n\n// ── Main schema ─────────────────────────────────────────────────\n\n/**\n * Zod schema matching the PluginManifest interface from types.ts.\n *\n * Every JSON.parse of a manifest.json should validate through this.\n */\nexport const pluginManifestSchema = z.object({\n\tid: z.string().min(1),\n\tversion: z.string().min(1),\n\tcapabilities: z.array(z.enum(PLUGIN_CAPABILITIES)),\n\tallowedHosts: z.array(z.string()),\n\tstorage: z.record(z.string(), storageCollectionSchema),\n\t/**\n\t * Hook declarations — accepts both plain name strings (legacy) and\n\t * structured objects with exclusive/priority/timeout metadata.\n\t * Plain strings are normalized to `{ name }` objects after parsing.\n\t */\n\thooks: z.array(z.union([z.enum(HOOK_NAMES), manifestHookEntrySchema])),\n\t/**\n\t * Route declarations — accepts both plain name strings and\n\t * structured objects with public metadata.\n\t * Plain strings are normalized to `{ name }` objects after parsing.\n\t */\n\troutes: z.array(\n\t\tz.union([\n\t\t\tz.string().min(1).regex(routeNamePattern, \"Route name must be a safe path segment\"),\n\t\t\tmanifestRouteEntrySchema,\n\t\t]),\n\t),\n\tadmin: pluginAdminConfigSchema,\n});\n\nexport type ValidatedPluginManifest = z.infer<typeof pluginManifestSchema>;\n\n/**\n * Normalize a manifest hook entry — plain strings become `{ name }` objects.\n */\nexport function normalizeManifestHook(\n\tentry: string | { name: string; exclusive?: boolean; priority?: number; timeout?: number },\n): { name: string; exclusive?: boolean; priority?: number; timeout?: number } {\n\tif (typeof entry === \"string\") {\n\t\treturn { name: entry };\n\t}\n\treturn entry;\n}\n\n/**\n * Normalize a manifest route entry — plain strings become `{ name }` objects.\n */\nexport function normalizeManifestRoute(entry: string | { name: string; public?: boolean }): {\n\tname: string;\n\tpublic?: boolean;\n} {\n\tif (typeof entry === \"string\") {\n\t\treturn { name: entry };\n\t}\n\treturn entry;\n}\n"],"mappings":";;;;;;;;;;;;AAcA,MAAa,sBAAsB;CAClC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;AAGD,MAAM,cAAc;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AAED,MAAa,aAAa;CACzB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;;;;AAMD,MAAM,0BAA0B,EAAE,OAAO;CACxC,MAAM,EAAE,KAAK,WAAW;CACxB,WAAW,EAAE,SAAS,CAAC,UAAU;CACjC,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,UAAU;CACrC,SAAS,EAAE,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU;CAC/C,CAAC;;;;;;;AAQF,MAAM,mBAAmB;A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AE,QAAQ,EAAE,wBAAwB;CAMtD,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,KAAK,WAAW,EAAE,wBAAwB,CAAC,CAAC;CAMtE,QAAQ,EAAE,MACT,EAAE,MAAM,CACP,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,MAAM,kBAAkB,yCAAyC,EACnF,yBACA,CAAC,CACF;CACD,OAAO;CACP,CAAC;;;;AAmBF,SAAgB,uBAAuB,OAGrC;AACD,KAAI,OAAO,UAAU,SACpB,QAAO,EAAE,MAAM,OAAO;AAEvB,QAAO"}
1
+ {"version":3,"file":"manifest-schema-V30qsMft.mjs","names":[],"sources":["../src/plugins/manifest-schema.ts"],"sourcesContent":["/**\n * Zod schema for PluginManifest validation\n *\n * Used to validate manifest.json from plugin bundles at every parse site:\n * - Client-side download (marketplace.ts extractBundle)\n * - R2 load (api/handlers/marketplace.ts loadBundleFromR2)\n * - CLI publish preview (cli/commands/publish.ts readManifestFromTarball)\n * - Marketplace ingest extends this with publishing-specific fields\n */\n\nimport { z } from \"zod\";\n\n// ── Enum values (must stay in sync with types.ts) ───────────────\n\nexport const PLUGIN_CAPABILITIES = [\n\t\"network:fetch\",\n\t\"network:fetch:any\",\n\t\"read:content\",\n\t\"write:content\",\n\t\"read:media\",\n\t\"write:media\",\n\t\"read:users\",\n\t\"email:send\",\n\t\"email:provide\",\n\t\"email:intercept\",\n\t\"page:inject\",\n] as const;\n\n/** Must stay in sync with FieldType in schema/types.ts */\nconst FIELD_TYPES = [\n\t\"string\",\n\t\"text\",\n\t\"number\",\n\t\"integer\",\n\t\"boolean\",\n\t\"datetime\",\n\t\"select\",\n\t\"multiSelect\",\n\t\"portableText\",\n\t\"image\",\n\t\"file\",\n\t\"reference\",\n\t\"json\",\n\t\"slug\",\n\t\"repeater\",\n] as const;\n\nexport const HOOK_NAMES = [\n\t\"plugin:install\",\n\t\"plugin:activate\",\n\t\"plugin:deactivate\",\n\t\"plugin:uninstall\",\n\t\"content:beforeSave\",\n\t\"content:afterSave\",\n\t\"content:beforeDelete\",\n\t\"content:afterDelete\",\n\t\"content:afterPublish\",\n\t\"content:afterUnpublish\",\n\t\"media:beforeUpload\",\n\t\"media:afterUpload\",\n\t\"cron\",\n\t\"email:beforeSend\",\n\t\"email:deliver\",\n\t\"email:afterSend\",\n\t\"comment:beforeCreate\",\n\t\"comment:moderate\",\n\t\"comment:afterCreate\",\n\t\"comment:afterModerate\",\n\t\"page:metadata\",\n\t\"page:fragments\",\n] as const;\n\n/**\n * Structured hook entry for manifest — name plus optional metadata.\n * During a transition period, both plain strings and objects are accepted.\n */\nconst manifestHookEntrySchema = z.object({\n\tname: z.enum(HOOK_NAMES),\n\texclusive: z.boolean().optional(),\n\tpriority: z.number().int().optional(),\n\ttimeout: z.number().int().positive().optional(),\n});\n\n/**\n * Structured route entry for manifest — name plus optional metadata.\n * Both plain strings and objects are accepted; strings are normalized\n * to `{ name }` objects via `normalizeManifestRoute()`.\n */\n/** Route names must be safe path segments — alphanumeric, hyphens, underscores, forward slashes */\nconst routeNamePattern = /^[a-zA-Z0-9][a-zA-Z0-9_\\-/]*$/;\n\nconst manifestRouteEntrySchema = z.object({\n\tname: z.string().min(1).regex(routeNamePattern, \"Route name must be a safe path segment\"),\n\tpublic: z.boolean().optional(),\n});\n\n// ── Sub-schemas ─────────────────────────────────────────────────\n\n/** Index field names must be valid identifiers to prevent SQL injection via JSON path expressions */\nconst indexFieldName = z.string().regex(/^[a-zA-Z][a-zA-Z0-9_]*$/);\n\nconst storageCollectionSchema = z.object({\n\tindexes: z.array(z.union([indexFieldName, z.array(indexFieldName)])),\n\tuniqueIndexes: z.array(z.union([indexFieldName, z.array(indexFieldName)])).optional(),\n});\n\nconst baseSettingFields = {\n\tlabel: z.string(),\n\tdescription: z.string().optional(),\n};\n\nconst settingFieldSchema = z.discriminatedUnion(\"type\", [\n\tz.object({\n\t\t...baseSettingFields,\n\t\ttype: z.literal(\"string\"),\n\t\tdefault: z.string().optional(),\n\t\tmultiline: z.boolean().optional(),\n\t}),\n\tz.object({\n\t\t...baseSettingFields,\n\t\ttype: z.literal(\"number\"),\n\t\tdefault: z.number().optional(),\n\t\tmin: z.number().optional(),\n\t\tmax: z.number().optional(),\n\t}),\n\tz.object({ ...baseSettingFields, type: z.literal(\"boolean\"), default: z.boolean().optional() }),\n\tz.object({\n\t\t...baseSettingFields,\n\t\ttype: z.literal(\"select\"),\n\t\toptions: z.array(z.object({ value: z.string(), label: z.string() })),\n\t\tdefault: z.string().optional(),\n\t}),\n\tz.object({ ...baseSettingFields, type: z.literal(\"secret\") }),\n]);\n\nconst adminPageSchema = z.object({\n\tpath: z.string(),\n\tlabel: z.string(),\n\ticon: z.string().optional(),\n});\n\nconst dashboardWidgetSchema = z.object({\n\tid: z.string(),\n\tsize: z.enum([\"full\", \"half\", \"third\"]).optional(),\n\ttitle: z.string().optional(),\n});\n\nconst pluginAdminConfigSchema = z.object({\n\tentry: z.string().optional(),\n\tsettingsSchema: z.record(z.string(), settingFieldSchema).optional(),\n\tpages: z.array(adminPageSchema).optional(),\n\twidgets: z.array(dashboardWidgetSchema).optional(),\n\tfieldWidgets: z\n\t\t.array(\n\t\t\tz.object({\n\t\t\t\tname: z.string().min(1),\n\t\t\t\tlabel: z.string().min(1),\n\t\t\t\tfieldTypes: z.array(z.enum(FIELD_TYPES)),\n\t\t\t\telements: z\n\t\t\t\t\t.array(\n\t\t\t\t\t\tz\n\t\t\t\t\t\t\t.object({\n\t\t\t\t\t\t\t\ttype: z.string(),\n\t\t\t\t\t\t\t\taction_id: z.string(),\n\t\t\t\t\t\t\t\tlabel: z.string().optional(),\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t.passthrough(),\n\t\t\t\t\t)\n\t\t\t\t\t.optional(),\n\t\t\t}),\n\t\t)\n\t\t.optional(),\n});\n\n// ── Main schema ─────────────────────────────────────────────────\n\n/**\n * Zod schema matching the PluginManifest interface from types.ts.\n *\n * Every JSON.parse of a manifest.json should validate through this.\n */\nexport const pluginManifestSchema = z.object({\n\tid: z.string().min(1),\n\tversion: z.string().min(1),\n\tcapabilities: z.array(z.enum(PLUGIN_CAPABILITIES)),\n\tallowedHosts: z.array(z.string()),\n\tstorage: z.record(z.string(), storageCollectionSchema),\n\t/**\n\t * Hook declarations — accepts both plain name strings (legacy) and\n\t * structured objects with exclusive/priority/timeout metadata.\n\t * Plain strings are normalized to `{ name }` objects after parsing.\n\t */\n\thooks: z.array(z.union([z.enum(HOOK_NAMES), manifestHookEntrySchema])),\n\t/**\n\t * Route declarations — accepts both plain name strings and\n\t * structured objects with public metadata.\n\t * Plain strings are normalized to `{ name }` objects after parsing.\n\t */\n\troutes: z.array(\n\t\tz.union([\n\t\t\tz.string().min(1).regex(routeNamePattern, \"Route name must be a safe path segment\"),\n\t\t\tmanifestRouteEntrySchema,\n\t\t]),\n\t),\n\tadmin: pluginAdminConfigSchema,\n});\n\nexport type ValidatedPluginManifest = z.infer<typeof pluginManifestSchema>;\n\n/**\n * Normalize a manifest hook entry — plain strings become `{ name }` objects.\n */\nexport function normalizeManifestHook(\n\tentry: string | { name: string; exclusive?: boolean; priority?: number; timeout?: number },\n): { name: string; exclusive?: boolean; priority?: number; timeout?: number } {\n\tif (typeof entry === \"string\") {\n\t\treturn { name: entry };\n\t}\n\treturn entry;\n}\n\n/**\n * Normalize a manifest route entry — plain strings become `{ name }` objects.\n */\nexport function normalizeManifestRoute(entry: string | { name: string; public?: boolean }): {\n\tname: string;\n\tpublic?: boolean;\n} {\n\tif (typeof entry === \"string\") {\n\t\treturn { name: entry };\n\t}\n\treturn entry;\n}\n"],"mappings":";;;;;;;;;;;;AAcA,MAAa,sBAAsB;CAClC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;AAGD,MAAM,cAAc;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AAED,MAAa,aAAa;CACzB;CACA;CACA;CACA;CACA;CACA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,CAAC,UAAU;GAC5B,CAAC,CACD,aAAa,CACf,CACA,UAAU;EACZ,CAAC,CACF,CACA,UAAU;CACZ,CAAC;;;;;;AASF,MAAa,uBAAuB,EAAE,OAAO;CAC5C,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE;CACrB,SAAS,EAAE,QAAQ,CAAC,IAAI,EAAE;CAC1B,cAAc,EAAE,MAAM,EAAE,KAAK,oBAAoB,CAAC;CAClD,cAAc,EAAE,MAAM,EAAE,QAAQ,CAAC;CACjC,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,wBAAwB;CAMtD,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,KAAK,WAAW,EAAE,wBAAwB,CAAC,CAAC;CAMtE,QAAQ,EAAE,MACT,EAAE,MAAM,CACP,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,MAAM,kBAAkB,yCAAyC,EACnF,yBACA,CAAC,CACF;CACD,OAAO;CACP,CAAC;;;;AAmBF,SAAgB,uBAAuB,OAGrC;AACD,KAAI,OAAO,UAAU,SACpB,QAAO,EAAE,MAAM,OAAO;AAEvB,QAAO"}
@@ -1,4 +1,4 @@
1
- import { _ as MediaValue, a as ComponentEmbed, b as mediaItemToValue, c as EmbedResult, d as MediaListResult, f as MediaProvider, g as MediaUploadInput, h as MediaProviderItem, i as AudioEmbed, l as ImageEmbed, m as MediaProviderDescriptor, n as generatePlaceholder, o as CreateMediaProviderFn, p as MediaProviderCapabilities, r as normalizeMediaValue, s as EmbedOptions, t as PlaceholderData, u as MediaListOptions, v as ThumbnailOptions, y as VideoEmbed } from "../placeholder-BBCtpTES.mjs";
1
+ import { _ as MediaValue, a as ComponentEmbed, b as mediaItemToValue, c as EmbedResult, d as MediaListResult, f as MediaProvider, g as MediaUploadInput, h as MediaProviderItem, i as AudioEmbed, l as ImageEmbed, m as MediaProviderDescriptor, n as generatePlaceholder, o as CreateMediaProviderFn, p as MediaProviderCapabilities, r as normalizeMediaValue, s as EmbedOptions, t as PlaceholderData, u as MediaListOptions, v as ThumbnailOptions, y as VideoEmbed } from "../placeholder-tzpqGWII.mjs";
2
2
 
3
3
  //#region src/media/local.d.ts
4
4
  interface LocalMediaConfig {
@@ -1,4 +1,4 @@
1
- import { n as normalizeMediaValue, t as generatePlaceholder } from "../placeholder-DntBEQo7.mjs";
1
+ import { n as normalizeMediaValue, t as generatePlaceholder } from "../placeholder-C-fk5hYI.mjs";
2
2
 
3
3
  //#region src/media/types.ts
4
4
  /**
@@ -1,10 +1,10 @@
1
- import { h as MediaProviderItem, o as CreateMediaProviderFn } from "../placeholder-BBCtpTES.mjs";
2
- import { t as Database } from "../types-B6BzlZxx.mjs";
3
- import "../index-CRg3PWfZ.mjs";
4
- import "../runner-DYv3rX8P.mjs";
5
- import "../types-BYWYxLcp.mjs";
6
- import "../validate-CcNRWH6I.mjs";
7
- import { d as Storage } from "../types-DNZpaCBk.mjs";
1
+ import { h as MediaProviderItem, o as CreateMediaProviderFn } from "../placeholder-tzpqGWII.mjs";
2
+ import { t as Database } from "../types-8xrvl_68.mjs";
3
+ import "../index-BYv0mB9g.mjs";
4
+ import "../runner-Fl2NcUUz.mjs";
5
+ import "../types-DgrIP0tF.mjs";
6
+ import { d as Storage } from "../types-CFWjXmus.mjs";
7
+ import "../validate-CaLH1Ia2.mjs";
8
8
  import "../index.mjs";
9
9
  import { Kysely } from "kysely";
10
10
 
@@ -20,4 +20,4 @@ function getAuthMode(config) {
20
20
 
21
21
  //#endregion
22
22
  export { getAuthMode as t };
23
- //# sourceMappingURL=mode-CyPLdO3C.mjs.map
23
+ //# sourceMappingURL=mode-CpNnGkPz.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"mode-CyPLdO3C.mjs","names":[],"sources":["../src/auth/mode.ts"],"sourcesContent":["/**\n * Auth Mode Detection\n *\n * Determines which authentication provider is active based on config.\n * Supports both passkey (default) and external auth providers via AuthDescriptor.\n */\n\nimport type { EmDashConfig } from \"../astro/integration/runtime.js\";\nimport type { AuthDescriptor, AuthResult, ExternalAuthConfig } from \"./types.js\";\n\nexport type { AuthDescriptor, AuthResult, ExternalAuthConfig };\n\n/**\n * Passkey auth mode (default)\n */\nexport interface PasskeyAuthMode {\n\ttype: \"passkey\";\n}\n\n/**\n * External auth provider mode (Cloudflare Access, etc.)\n */\nexport interface ExternalAuthMode {\n\ttype: \"external\";\n\t/** Provider type identifier (e.g., \"cloudflare-access\") */\n\tproviderType: string;\n\t/** Module to import for authentication */\n\tentrypoint: string;\n\t/** Provider-specific configuration */\n\tconfig: unknown;\n}\n\n/**\n * Union of all auth modes\n */\nexport type AuthMode = PasskeyAuthMode | ExternalAuthMode;\n\n/**\n * Extended config type with auth.\n *\n * This is the same as `EmDashConfig` with an optional `auth` field.\n * Kept for backwards compatibility — prefer `EmDashConfig` in new code\n * since `getAuthMode` now accepts `EmDashConfig` directly.\n */\nexport interface EmDashConfigWithAuth extends EmDashConfig {\n\tauth?: AuthDescriptor;\n}\n\n/**\n * Determine the active auth mode from config.\n *\n * Accepts `EmDashConfig` (or subtype) — checks for `auth` field via duck typing.\n *\n * @param config EmDash configuration\n * @returns The active auth mode\n */\nexport function getAuthMode(\n\tconfig: (EmDashConfig & { auth?: AuthDescriptor }) | null | undefined,\n): AuthMode {\n\tconst auth = config?.auth;\n\n\t// Check for AuthDescriptor (new style)\n\tif (auth && \"entrypoint\" in auth && auth.entrypoint) {\n\t\treturn {\n\t\t\ttype: \"external\",\n\t\t\tproviderType: auth.type,\n\t\t\tentrypoint: auth.entrypoint,\n\t\t\tconfig: auth.config,\n\t\t};\n\t}\n\n\t// Default to passkey\n\treturn { type: \"passkey\" };\n}\n\n/**\n * Check if an external auth provider is active\n */\nexport function isExternalAuthEnabled(\n\tconfig: (EmDashConfig & { auth?: AuthDescriptor }) | null | undefined,\n): boolean {\n\treturn getAuthMode(config).type === \"external\";\n}\n\n/**\n * Get external auth config if enabled\n */\nexport function getExternalAuthConfig(\n\tconfig: (EmDashConfig & { auth?: AuthDescriptor }) | null | undefined,\n): ExternalAuthMode | null {\n\tconst mode = getAuthMode(config);\n\tif (mode.type === \"external\") {\n\t\treturn mode;\n\t}\n\treturn null;\n}\n"],"mappings":";;;;;;;;;AAwDA,SAAgB,YACf,QACW;CACX,MAAM,OAAO,QAAQ;AAGrB,KAAI,QAAQ,gBAAgB,QAAQ,KAAK,WACxC,QAAO;EACN,MAAM;EACN,cAAc,KAAK;EACnB,YAAY,KAAK;EACjB,QAAQ,KAAK;EACb;AAIF,QAAO,EAAE,MAAM,WAAW"}
1
+ {"version":3,"file":"mode-CpNnGkPz.mjs","names":[],"sources":["../src/auth/mode.ts"],"sourcesContent":["/**\n * Auth Mode Detection\n *\n * Determines which authentication provider is active based on config.\n * Supports both passkey (default) and external auth providers via AuthDescriptor.\n */\n\nimport type { EmDashConfig } from \"../astro/integration/runtime.js\";\nimport type { AuthDescriptor, AuthResult, ExternalAuthConfig } from \"./types.js\";\n\nexport type { AuthDescriptor, AuthResult, ExternalAuthConfig };\n\n/**\n * Passkey auth mode (default)\n */\nexport interface PasskeyAuthMode {\n\ttype: \"passkey\";\n}\n\n/**\n * External auth provider mode (Cloudflare Access, etc.)\n */\nexport interface ExternalAuthMode {\n\ttype: \"external\";\n\t/** Provider type identifier (e.g., \"cloudflare-access\") */\n\tproviderType: string;\n\t/** Module to import for authentication */\n\tentrypoint: string;\n\t/** Provider-specific configuration */\n\tconfig: unknown;\n}\n\n/**\n * Union of all auth modes\n */\nexport type AuthMode = PasskeyAuthMode | ExternalAuthMode;\n\n/**\n * Extended config type with auth.\n *\n * This is the same as `EmDashConfig` with an optional `auth` field.\n * Kept for backwards compatibility — prefer `EmDashConfig` in new code\n * since `getAuthMode` now accepts `EmDashConfig` directly.\n */\nexport interface EmDashConfigWithAuth extends EmDashConfig {\n\tauth?: AuthDescriptor;\n}\n\n/**\n * Determine the active auth mode from config.\n *\n * Accepts `EmDashConfig` (or subtype) — checks for `auth` field via duck typing.\n *\n * @param config EmDash configuration\n * @returns The active auth mode\n */\nexport function getAuthMode(\n\tconfig: (EmDashConfig & { auth?: AuthDescriptor }) | null | undefined,\n): AuthMode {\n\tconst auth = config?.auth;\n\n\t// Check for AuthDescriptor (new style)\n\tif (auth && \"entrypoint\" in auth && auth.entrypoint) {\n\t\treturn {\n\t\t\ttype: \"external\",\n\t\t\tproviderType: auth.type,\n\t\t\tentrypoint: auth.entrypoint,\n\t\t\tconfig: auth.config,\n\t\t};\n\t}\n\n\t// Default to passkey\n\treturn { type: \"passkey\" };\n}\n\n/**\n * Check if an external auth provider is active\n */\nexport function isExternalAuthEnabled(\n\tconfig: (EmDashConfig & { auth?: AuthDescriptor }) | null | undefined,\n): boolean {\n\treturn getAuthMode(config).type === \"external\";\n}\n\n/**\n * Get external auth config if enabled\n */\nexport function getExternalAuthConfig(\n\tconfig: (EmDashConfig & { auth?: AuthDescriptor }) | null | undefined,\n): ExternalAuthMode | null {\n\tconst mode = getAuthMode(config);\n\tif (mode.type === \"external\") {\n\t\treturn mode;\n\t}\n\treturn null;\n}\n"],"mappings":";;;;;;;;;AAwDA,SAAgB,YACf,QACW;CACX,MAAM,OAAO,QAAQ;AAGrB,KAAI,QAAQ,gBAAgB,QAAQ,KAAK,WACxC,QAAO;EACN,MAAM;EACN,cAAc,KAAK;EACnB,YAAY,KAAK;EACjB,QAAQ,KAAK;EACb;AAIF,QAAO,EAAE,MAAM,WAAW"}
@@ -1,4 +1,5 @@
1
- import { A as PageMetadataContribution, D as PageFragmentContribution, N as PageMetadataLinkRel, P as PagePlacement, q as PublicPageContext, t as BreadcrumbItem } from "../types-BYWYxLcp.mjs";
1
+ import { A as PageMetadataContribution, D as PageFragmentContribution, N as PageMetadataLinkRel, P as PagePlacement, q as PublicPageContext, t as BreadcrumbItem } from "../types-DgrIP0tF.mjs";
2
+ import { n as SeoSettings } from "../types-CnZYHyLW.mjs";
2
3
 
3
4
  //#region src/page/context.d.ts
4
5
  /** Fields shared by both input forms */
@@ -112,6 +113,14 @@ declare function renderFragments(contributions: PageFragmentContribution[], plac
112
113
  * Returns an empty array if no SEO-relevant data is present.
113
114
  */
114
115
  declare function generateBaseSeoContributions(page: PublicPageContext): PageMetadataContribution[];
116
+ /**
117
+ * Generate site-level SEO metadata contributions from SiteSettings.seo.
118
+ *
119
+ * These tags apply to every page (search engine ownership verification),
120
+ * so they're sourced from site settings rather than per-page context.
121
+ * Returns an empty array when no relevant settings are configured.
122
+ */
123
+ declare function generateSiteSeoContributions(seoSettings: SeoSettings | undefined): PageMetadataContribution[];
115
124
  //#endregion
116
125
  //#region src/page/jsonld.d.ts
117
126
  /**
@@ -145,5 +154,5 @@ interface EmDashPageRuntime {
145
154
  */
146
155
  declare function getPageRuntime(locals: Record<string, unknown>): EmDashPageRuntime | undefined;
147
156
  //#endregion
148
- export { type CreatePublicPageContextInput, EmDashPageRuntime, type ResolvedPageMetadata, buildBlogPostingJsonLd, buildWebSiteJsonLd, cleanJsonLd, createPublicPageContext, escapeHtmlAttr, generateBaseSeoContributions, getPageRuntime, renderFragments, renderPageMetadata, resolveFragments, resolvePageMetadata, safeJsonLdSerialize };
157
+ export { type CreatePublicPageContextInput, EmDashPageRuntime, type ResolvedPageMetadata, buildBlogPostingJsonLd, buildWebSiteJsonLd, cleanJsonLd, createPublicPageContext, escapeHtmlAttr, generateBaseSeoContributions, generateSiteSeoContributions, getPageRuntime, renderFragments, renderPageMetadata, resolveFragments, resolvePageMetadata, safeJsonLdSerialize };
149
158
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/page/context.ts","../../src/page/metadata.ts","../../src/page/fragments.ts","../../src/page/seo-contributions.ts","../../src/page/jsonld.ts","../../src/page/index.ts"],"mappings":";;;;UAUU,iBAAA;EACT,IAAA;EACA,QAAA;EACA,KAAA;EACA,SAAA;EACA,WAAA;EACA,SAAA;EACA,KAAA;EACA,OAAA;IAAY,UAAA;IAAoB,EAAA;IAAY,IAAA;EAAA;EAK3C;EAHD,GAAA;IACC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A2CjD,kBAAA,CAAmB,IAAA,EAAM,iBAAA,GAAoB,MAAA;;;;;;;UC1C5C,iBAAA;EAChB,mBAAA,GAAsB,IAAA,EAAM,iBAAA,KAAsB,OAAA,CAAQ,wBAAA;EAC1D,oBAAA,GAAuB,IAAA,EAAM,iBAAA,KAAsB,OAAA,CAAQ,wBAAA;AAAA;;;;;iBAO5C,cAAA,CAAe,MAAA,EAAQ,MAAA,oBAA0B,iBAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/page/context.ts","../../src/page/metadata.ts","../../src/page/fragments.ts","../../src/page/seo-contributions.ts","../../src/page/jsonld.ts","../../src/page/index.ts"],"mappings":";;;;;UAUU,iBAAA;EACT,IAAA;EACA,QAAA;EACA,KAAA;EACA,SAAA;EACA,WAAA;EACA,SAAA;EACA,KAAA;EACA,OAAA;IAAY,UAAA;IAAoB,EAAA;IAAY,IAAA;EAAA;EAI3C;EAFD,GAAA;IACC,OAAA;IACA,aAAA;IACA,OAAA;IACA,MAAA;EAAA;EASD;EANA,WAAA;IACC,aAAA;IACA,YAAA;IACA,MAAA;EAAA;EAeQ;EAZT,QAAA;;;;;;EAMA,WAAA,GAAc,cAAA;EAOK;EALnB,OAAA;AAAA;AAKgC;AAAA,UADvB,UAAA,SAAmB,iBAAA;EAC5B,KAAA;IAAS,GAAA,EAAK,GAAA;IAAK,aAAA;EAAA;AAAA;;UAIV,QAAA,SAAiB,iBAAA;EAC1B,GAAA,EAAK,GAAA;EACL,MAAA;AAAA;AAAA,KAGW,4BAAA,GAA+B,UAAA,GAAa,QAAA;;;AASxD;iBAAgB,uBAAA,CAAwB,KAAA,EAAO,4BAAA,GAA+B,iBAAA;;;UCrD7D,oBAAA;EAChB,IAAA,EAAM,KAAA;IAAQ,IAAA;IAAc,OAAA;EAAA;EAC5B,UAAA,EAAY,KAAA;IAAQ,QAAA;IAAkB,OAAA;EAAA;EACtC,KAAA,EAAO,KAAA;IACN,GAAA,EAAK,mBAAA;IACL,IAAA;IACA,QAAA;EAAA;EAED,MAAA,EAAQ,KAAA;IAAQ,EAAA;IAAa,IAAA;EAAA;AAAA;;iBAiBd,cAAA,CAAe,KAAA;;;;;;;ADKvB;;iBCmBQ,mBAAA,CAAoB,KAAA;;;;;iBAcpB,mBAAA,CACf,aAAA,EAAe,wBAAA,KACb,oBAAA;;iBAiFa,kBAAA,CAAmB,QAAA,EAAU,oBAAA;;;;;;;;iBCzI7B,gBAAA,CACf,aAAA,EAAe,wBAAA,IACf,SAAA,EAAW,aAAA,GACT,wBAAA;;iBA2Da,eAAA,CACf,aAAA,EAAe,wBAAA,IACf,SAAA,EAAW,aAAA;;;;;;;iBCjEI,4BAAA,CAA6B,IAAA,EAAM,iBAAA,GAAoB,wBAAA;;;;;;;;iBA8HvD,4BAAA,CACf,WAAA,EAAa,WAAA,eACX,wBAAA;;;;;;;iBCtIa,WAAA,CAAY,GAAA,EAAK,MAAA,oBAA0B,MAAA;;;;;iBAmB3C,sBAAA,CAAuB,IAAA,EAAM,iBAAA,GAAoB,MAAA;;;;;iBA2CjD,kBAAA,CAAmB,IAAA,EAAM,iBAAA,GAAoB,MAAA;;;;;;;UC1C5C,iBAAA;EAChB,mBAAA,GAAsB,IAAA,EAAM,iBAAA,KAAsB,OAAA,CAAQ,wBAAA;EAC1D,oBAAA,GAAuB,IAAA,EAAM,iBAAA,KAAsB,OAAA,CAAQ,wBAAA;AAAA;;;;;iBAO5C,cAAA,CAAe,MAAA,EAAQ,MAAA,oBAA0B,iBAAA"}
@@ -403,6 +403,28 @@ function generateBaseSeoContributions(page) {
403
403
  }
404
404
  return contributions;
405
405
  }
406
+ /**
407
+ * Generate site-level SEO metadata contributions from SiteSettings.seo.
408
+ *
409
+ * These tags apply to every page (search engine ownership verification),
410
+ * so they're sourced from site settings rather than per-page context.
411
+ * Returns an empty array when no relevant settings are configured.
412
+ */
413
+ function generateSiteSeoContributions(seoSettings) {
414
+ const contributions = [];
415
+ if (!seoSettings) return contributions;
416
+ if (seoSettings.googleVerification) contributions.push({
417
+ kind: "meta",
418
+ name: "google-site-verification",
419
+ content: seoSettings.googleVerification
420
+ });
421
+ if (seoSettings.bingVerification) contributions.push({
422
+ kind: "meta",
423
+ name: "msvalidate.01",
424
+ content: seoSettings.bingVerification
425
+ });
426
+ return contributions;
427
+ }
406
428
 
407
429
  //#endregion
408
430
  //#region src/page/index.ts
@@ -416,5 +438,5 @@ function getPageRuntime(locals) {
416
438
  }
417
439
 
418
440
  //#endregion
419
- export { buildBlogPostingJsonLd, buildWebSiteJsonLd, cleanJsonLd, createPublicPageContext, escapeHtmlAttr, generateBaseSeoContributions, getPageRuntime, renderFragments, renderPageMetadata, resolveFragments, resolvePageMetadata, safeJsonLdSerialize };
441
+ export { buildBlogPostingJsonLd, buildWebSiteJsonLd, cleanJsonLd, createPublicPageContext, escapeHtmlAttr, generateBaseSeoContributions, generateSiteSeoContributions, getPageRuntime, renderFragments, renderPageMetadata, resolveFragments, resolvePageMetadata, safeJsonLdSerialize };
420
442
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../src/page/context.ts","../../src/page/metadata.ts","../../src/page/fragments.ts","../../src/page/jsonld.ts","../../src/page/seo-contributions.ts","../../src/page/index.ts"],"sourcesContent":["/**\n * Public page context builder\n *\n * Templates call this to describe the page being rendered.\n * The resulting context is passed to EmDashHead / EmDashBodyStart / EmDashBodyEnd.\n */\n\nimport type { BreadcrumbItem, PublicPageContext } from \"../plugins/types.js\";\n\n/** Fields shared by both input forms */\ninterface PageContextFields {\n\tkind: \"content\" | \"custom\";\n\tpageType?: string;\n\ttitle?: string | null;\n\tpageTitle?: string | null;\n\tdescription?: string | null;\n\tcanonical?: string | null;\n\timage?: string | null;\n\tcontent?: { collection: string; id: string; slug?: string | null };\n\t/** SEO overrides for OG/Twitter meta generation */\n\tseo?: {\n\t\togTitle?: string | null;\n\t\togDescription?: string | null;\n\t\togImage?: string | null;\n\t\trobots?: string | null;\n\t};\n\t/** Article metadata for Open Graph article: tags */\n\tarticleMeta?: {\n\t\tpublishedTime?: string | null;\n\t\tmodifiedTime?: string | null;\n\t\tauthor?: string | null;\n\t};\n\t/** Site name for structured data and og:site_name */\n\tsiteName?: string;\n\t/**\n\t * Breadcrumb trail for this page, root first. Pass an empty array\n\t * to explicitly opt out of breadcrumbs (e.g. homepage), or omit the\n\t * field to let consumers fall back to their own derivation.\n\t */\n\tbreadcrumbs?: BreadcrumbItem[];\n\t/** Public-facing site URL (origin) for structured data */\n\tsiteUrl?: string;\n}\n\n/** Input with Astro global -- used in .astro files */\ninterface AstroInput extends PageContextFields {\n\tAstro: { url: URL; currentLocale?: string };\n}\n\n/** Input with explicit URL -- used outside .astro files */\ninterface UrlInput extends PageContextFields {\n\turl: URL | string;\n\tlocale?: string;\n}\n\nexport type CreatePublicPageContextInput = AstroInput | UrlInput;\n\nfunction isAstroInput(input: CreatePublicPageContextInput): input is AstroInput {\n\treturn \"Astro\" in input;\n}\n\n/**\n * Build a PublicPageContext from template input.\n */\nexport function createPublicPageContext(input: CreatePublicPageContextInput): PublicPageContext {\n\tlet url: string;\n\tlet path: string;\n\tlet locale: string | null;\n\n\tif (isAstroInput(input)) {\n\t\turl = input.Astro.url.href;\n\t\tpath = input.Astro.url.pathname;\n\t\tlocale = input.Astro.currentLocale ?? null;\n\t} else {\n\t\tconst parsed = typeof input.url === \"string\" ? new URL(input.url) : input.url;\n\t\turl = parsed.href;\n\t\tpath = parsed.pathname;\n\t\tlocale = input.locale ?? null;\n\t}\n\n\treturn {\n\t\turl,\n\t\tpath,\n\t\tlocale,\n\t\tkind: input.kind,\n\t\tpageType: input.pageType ?? (input.kind === \"content\" ? \"article\" : \"website\"),\n\t\ttitle: input.title ?? null,\n\t\tpageTitle: input.pageTitle ?? null,\n\t\tdescription: input.description ?? null,\n\t\tcanonical: input.canonical ?? null,\n\t\timage: input.image ?? null,\n\t\tcontent: input.content\n\t\t\t? {\n\t\t\t\t\tcollection: input.content.collection,\n\t\t\t\t\tid: input.content.id,\n\t\t\t\t\tslug: input.content.slug ?? null,\n\t\t\t\t}\n\t\t\t: undefined,\n\t\tseo: input.seo,\n\t\tarticleMeta: input.articleMeta,\n\t\tsiteName: input.siteName,\n\t\tbreadcrumbs: input.breadcrumbs,\n\t\tsiteUrl: input.siteUrl,\n\t};\n}\n","/**\n * Page metadata collection and rendering\n *\n * Collects typed metadata contributions from plugins via the page:metadata hook,\n * validates them, and resolves them into a deduplicated structure ready to render.\n */\n\nimport type { PageMetadataContribution, PageMetadataLinkRel } from \"../plugins/types.js\";\n\n// ── Resolved output ─────────────────────────────────────────────\n\nexport interface ResolvedPageMetadata {\n\tmeta: Array<{ name: string; content: string }>;\n\tproperties: Array<{ property: string; content: string }>;\n\tlinks: Array<{\n\t\trel: PageMetadataLinkRel;\n\t\thref: string;\n\t\threflang?: string;\n\t}>;\n\tjsonld: Array<{ id?: string; json: string }>;\n}\n\n// ── Validation ──────────────────────────────────────────────────\n\n/** Schemes safe for use in link href attributes */\nconst SAFE_HREF_RE = /^(https?|at):\\/\\//i;\nconst HTML_ESCAPE_MAP: Record<string, string> = {\n\t\"&\": \"&amp;\",\n\t\"<\": \"&lt;\",\n\t\">\": \"&gt;\",\n\t'\"': \"&quot;\",\n\t\"'\": \"&#39;\",\n};\nconst HTML_ESCAPE_RE = /[&<>\"']/g;\n\n/** Escape a string for safe use in an HTML attribute value */\nexport function escapeHtmlAttr(value: string): string {\n\treturn value.replace(HTML_ESCAPE_RE, (ch) => HTML_ESCAPE_MAP[ch] ?? ch);\n}\n\n/** Validate that a URL uses a safe scheme (http, https, at) */\nfunction isSafeHref(url: string): boolean {\n\treturn SAFE_HREF_RE.test(url);\n}\n\n// ── JSON-LD serialization ───────────────────────────────────────\n\nconst JSONLD_LT_RE = /</g;\nconst JSONLD_GT_RE = />/g;\nconst JSONLD_U2028_RE = /\\u2028/g;\nconst JSONLD_U2029_RE = /\\u2029/g;\n\n/**\n * Safely serialize a value for embedding in a <script type=\"application/ld+json\"> tag.\n *\n * Plain JSON.stringify is not sufficient because:\n * - \"</script>\" in a nested string breaks out of the script tag\n * - \"<!--\" can open an HTML comment\n * - U+2028/U+2029 are line terminators in some JS engines\n */\nexport function safeJsonLdSerialize(value: unknown): string {\n\treturn JSON.stringify(value)\n\t\t.replace(JSONLD_LT_RE, \"\\\\u003c\")\n\t\t.replace(JSONLD_GT_RE, \"\\\\u003e\")\n\t\t.replace(JSONLD_U2028_RE, \"\\\\u2028\")\n\t\t.replace(JSONLD_U2029_RE, \"\\\\u2029\");\n}\n\n// ── Merge / dedupe ──────────────────────────────────────────────\n\n/**\n * Resolve a flat list of contributions into deduplicated metadata.\n * First contribution wins for any given dedupe key.\n */\nexport function resolvePageMetadata(\n\tcontributions: PageMetadataContribution[],\n): ResolvedPageMetadata {\n\tconst result: ResolvedPageMetadata = {\n\t\tmeta: [],\n\t\tproperties: [],\n\t\tlinks: [],\n\t\tjsonld: [],\n\t};\n\n\tconst seenMeta = new Set<string>();\n\tconst seenProperties = new Set<string>();\n\tconst seenLinks = new Set<string>();\n\tconst seenJsonLd = new Set<string>();\n\n\tfor (const c of contributions) {\n\t\tswitch (c.kind) {\n\t\t\tcase \"meta\": {\n\t\t\t\tconst dedupeKey = c.key ?? c.name;\n\t\t\t\tif (seenMeta.has(dedupeKey)) continue;\n\t\t\t\tseenMeta.add(dedupeKey);\n\t\t\t\tresult.meta.push({ name: c.name, content: c.content });\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"property\": {\n\t\t\t\tconst dedupeKey = c.key ?? c.property;\n\t\t\t\tif (seenProperties.has(dedupeKey)) continue;\n\t\t\t\tseenProperties.add(dedupeKey);\n\t\t\t\tresult.properties.push({\n\t\t\t\t\tproperty: c.property,\n\t\t\t\t\tcontent: c.content,\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"link\": {\n\t\t\t\tif (!isSafeHref(c.href)) {\n\t\t\t\t\tif (import.meta.env?.DEV) {\n\t\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t\t`[page:metadata] Rejected link contribution with unsafe href scheme: ${c.href}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (c.rel === \"canonical\") {\n\t\t\t\t\tif (seenLinks.has(\"canonical\")) continue;\n\t\t\t\t\tseenLinks.add(\"canonical\");\n\t\t\t\t} else {\n\t\t\t\t\tconst dedupeKey = c.key ?? c.hreflang ?? c.href;\n\t\t\t\t\tif (seenLinks.has(dedupeKey)) continue;\n\t\t\t\t\tseenLinks.add(dedupeKey);\n\t\t\t\t}\n\t\t\t\tresult.links.push({\n\t\t\t\t\trel: c.rel,\n\t\t\t\t\thref: c.href,\n\t\t\t\t\t...(c.hreflang && { hreflang: c.hreflang }),\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"jsonld\": {\n\t\t\t\tif (c.id) {\n\t\t\t\t\tif (seenJsonLd.has(c.id)) continue;\n\t\t\t\t\tseenJsonLd.add(c.id);\n\t\t\t\t}\n\t\t\t\tresult.jsonld.push({\n\t\t\t\t\tid: c.id,\n\t\t\t\t\tjson: safeJsonLdSerialize(c.graph),\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\t// Unknown contribution kind -- skip silently at runtime.\n\t\t\t\t// TypeScript catches this at compile time for typed callers,\n\t\t\t\t// but sandboxed plugins may return unexpected shapes.\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn result;\n}\n\n// ── HTML rendering ──────────────────────────────────────────────\n\n/** Render resolved metadata to an HTML string for embedding in <head> */\nexport function renderPageMetadata(metadata: ResolvedPageMetadata): string {\n\tconst parts: string[] = [];\n\n\tfor (const m of metadata.meta) {\n\t\tparts.push(`<meta name=\"${escapeHtmlAttr(m.name)}\" content=\"${escapeHtmlAttr(m.content)}\">`);\n\t}\n\n\tfor (const p of metadata.properties) {\n\t\tparts.push(\n\t\t\t`<meta property=\"${escapeHtmlAttr(p.property)}\" content=\"${escapeHtmlAttr(p.content)}\">`,\n\t\t);\n\t}\n\n\tfor (const l of metadata.links) {\n\t\tlet tag = `<link rel=\"${escapeHtmlAttr(l.rel)}\" href=\"${escapeHtmlAttr(l.href)}\"`;\n\t\tif (l.hreflang) {\n\t\t\ttag += ` hreflang=\"${escapeHtmlAttr(l.hreflang)}\"`;\n\t\t}\n\t\ttag += \">\";\n\t\tparts.push(tag);\n\t}\n\n\tfor (const j of metadata.jsonld) {\n\t\tparts.push(`<script type=\"application/ld+json\">${j.json}</script>`);\n\t}\n\n\treturn parts.join(\"\\n\");\n}\n","/**\n * Page fragment collection and rendering\n *\n * Collects raw markup / script contributions from trusted plugins via\n * the page:fragments hook. Sandboxed plugins are never invoked.\n */\n\nimport type { PageFragmentContribution, PagePlacement } from \"../plugins/types.js\";\nimport { escapeHtmlAttr } from \"./metadata.js\";\n\n/** Escape sequences that would break out of a script tag */\nconst SCRIPT_CLOSE_RE = /<\\//g;\n\n// ── Dedupe and filter ───────────────────────────────────────────\n\n/**\n * Filter contributions to a specific placement and deduplicate.\n * - Contributions with the same `key + placement` are deduped (first wins).\n * - External scripts with the same `src + placement` are deduped.\n */\nexport function resolveFragments(\n\tcontributions: PageFragmentContribution[],\n\tplacement: PagePlacement,\n): PageFragmentContribution[] {\n\tconst filtered = contributions.filter((c) => c.placement === placement);\n\tconst seen = new Set<string>();\n\tconst result: PageFragmentContribution[] = [];\n\n\tfor (const c of filtered) {\n\t\t// Key-based dedupe\n\t\tif (c.key) {\n\t\t\tconst dedupeKey = `key:${c.key}`;\n\t\t\tif (seen.has(dedupeKey)) continue;\n\t\t\tseen.add(dedupeKey);\n\t\t} else if (c.kind === \"external-script\") {\n\t\t\tconst dedupeKey = `src:${c.src}`;\n\t\t\tif (seen.has(dedupeKey)) continue;\n\t\t\tseen.add(dedupeKey);\n\t\t}\n\n\t\tresult.push(c);\n\t}\n\n\treturn result;\n}\n\n// ── HTML rendering ──────────────────────────────────────────────\n\nconst EVENT_HANDLER_RE = /^on/i;\n\nfunction renderAttributes(attrs: Record<string, string>): string {\n\treturn Object.entries(attrs)\n\t\t.filter(([k]) => !EVENT_HANDLER_RE.test(k))\n\t\t.map(([k, v]) => ` ${escapeHtmlAttr(k)}=\"${escapeHtmlAttr(v)}\"`)\n\t\t.join(\"\");\n}\n\n/** Render a single fragment contribution to HTML */\nfunction renderFragment(c: PageFragmentContribution): string {\n\tswitch (c.kind) {\n\t\tcase \"external-script\": {\n\t\t\tlet tag = `<script src=\"${escapeHtmlAttr(c.src)}\"`;\n\t\t\tif (c.async) tag += \" async\";\n\t\t\tif (c.defer) tag += \" defer\";\n\t\t\tif (c.attributes) tag += renderAttributes(c.attributes);\n\t\t\ttag += \"></script>\";\n\t\t\treturn tag;\n\t\t}\n\t\tcase \"inline-script\": {\n\t\t\tlet tag = \"<script\";\n\t\t\tif (c.attributes) tag += renderAttributes(c.attributes);\n\t\t\t// Escape </ to <\\/ to prevent breaking out of the script tag.\n\t\t\t// This is valid JS and protects against code built from user data.\n\t\t\ttag += `>${c.code.replace(SCRIPT_CLOSE_RE, \"<\\\\/\")}</script>`;\n\t\t\treturn tag;\n\t\t}\n\t\tcase \"html\":\n\t\t\treturn c.html;\n\t}\n}\n\n/** Render a list of fragment contributions to an HTML string */\nexport function renderFragments(\n\tcontributions: PageFragmentContribution[],\n\tplacement: PagePlacement,\n): string {\n\tconst resolved = resolveFragments(contributions, placement);\n\treturn resolved.map(renderFragment).join(\"\\n\");\n}\n","/**\n * JSON-LD structured data builders\n *\n * Moved from template SEO.astro components into core so all JSON-LD\n * is serialized via safeJsonLdSerialize() and never hand-rolled in templates.\n */\n\nimport type { PublicPageContext } from \"../plugins/types.js\";\n\n/**\n * Remove null/undefined values from a JSON-LD object recursively.\n * JSON-LD validators prefer absent keys over null values.\n */\nexport function cleanJsonLd(obj: Record<string, unknown>): Record<string, unknown> {\n\tconst cleaned: Record<string, unknown> = {};\n\tfor (const [key, value] of Object.entries(obj)) {\n\t\tif (value !== undefined && value !== null) {\n\t\t\tif (typeof value === \"object\" && !Array.isArray(value)) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- non-null, non-array object is safely treated as Record<string, unknown> for JSON-LD traversal\n\t\t\t\tcleaned[key] = cleanJsonLd(value as Record<string, unknown>);\n\t\t\t} else {\n\t\t\t\tcleaned[key] = value;\n\t\t\t}\n\t\t}\n\t}\n\treturn cleaned;\n}\n\n/**\n * Build a BlogPosting JSON-LD graph from page context.\n * Used for article-type content pages.\n */\nexport function buildBlogPostingJsonLd(page: PublicPageContext): Record<string, unknown> | null {\n\tif (page.pageType !== \"article\" || !page.canonical) return null;\n\n\tconst ogTitle = page.seo?.ogTitle ?? page.pageTitle ?? page.title;\n\tconst description = page.seo?.ogDescription || page.description;\n\tconst ogImage = page.seo?.ogImage || page.image;\n\tconst publishedTime = page.articleMeta?.publishedTime;\n\tconst modifiedTime = page.articleMeta?.modifiedTime;\n\tconst author = page.articleMeta?.author;\n\tconst siteName = page.siteName;\n\n\treturn cleanJsonLd({\n\t\t\"@context\": \"https://schema.org\",\n\t\t\"@type\": \"BlogPosting\",\n\t\theadline: ogTitle,\n\t\tdescription,\n\t\timage: ogImage || undefined,\n\t\turl: page.canonical,\n\t\tdatePublished: publishedTime || undefined,\n\t\tdateModified: modifiedTime || publishedTime || undefined,\n\t\tauthor: author\n\t\t\t? {\n\t\t\t\t\t\"@type\": \"Person\",\n\t\t\t\t\tname: author,\n\t\t\t\t}\n\t\t\t: undefined,\n\t\tpublisher: siteName\n\t\t\t? {\n\t\t\t\t\t\"@type\": \"Organization\",\n\t\t\t\t\tname: siteName,\n\t\t\t\t}\n\t\t\t: undefined,\n\t\tmainEntityOfPage: {\n\t\t\t\"@type\": \"WebPage\",\n\t\t\t\"@id\": page.canonical,\n\t\t},\n\t});\n}\n\n/**\n * Build a WebSite JSON-LD graph from page context.\n * Used for non-article pages (homepage, listing pages, etc.)\n */\nexport function buildWebSiteJsonLd(page: PublicPageContext): Record<string, unknown> | null {\n\tconst siteName = page.siteName;\n\tif (!siteName) return null;\n\n\t// Use configured public origin, falling back to page URL origin\n\tlet siteUrl: string;\n\tif (page.siteUrl) {\n\t\tsiteUrl = page.siteUrl;\n\t} else {\n\t\ttry {\n\t\t\tsiteUrl = new URL(page.url).origin;\n\t\t} catch {\n\t\t\tsiteUrl = page.canonical || page.url;\n\t\t}\n\t}\n\n\treturn cleanJsonLd({\n\t\t\"@context\": \"https://schema.org\",\n\t\t\"@type\": \"WebSite\",\n\t\tname: siteName,\n\t\turl: siteUrl,\n\t});\n}\n","/**\n * Generate base SEO metadata contributions from PublicPageContext.\n *\n * These contributions are prepended BEFORE plugin contributions in\n * resolvePageMetadata(), which uses first-wins dedup. This means\n * plugins can override any base SEO tag by contributing the same key.\n *\n * This replaces the per-template SEO.astro components, eliminating\n * the class of XSS bugs where templates hand-rolled JSON-LD serialization.\n */\n\nimport type { PageMetadataContribution, PublicPageContext } from \"../plugins/types.js\";\nimport { buildBlogPostingJsonLd, buildWebSiteJsonLd } from \"./jsonld.js\";\n\n/**\n * Generate base metadata contributions from a page context's SEO data.\n * Returns an empty array if no SEO-relevant data is present.\n */\nexport function generateBaseSeoContributions(page: PublicPageContext): PageMetadataContribution[] {\n\tconst contributions: PageMetadataContribution[] = [];\n\n\tconst description = page.description;\n\tconst ogTitle = page.seo?.ogTitle ?? page.pageTitle ?? page.title;\n\tconst ogDescription = page.seo?.ogDescription || description;\n\tconst ogImage = page.seo?.ogImage || page.image;\n\tconst robots = page.seo?.robots;\n\tconst canonical = page.canonical;\n\tconst siteName = page.siteName;\n\n\t// -- Meta tags --\n\n\tif (description) {\n\t\tcontributions.push({ kind: \"meta\", name: \"description\", content: description });\n\t}\n\n\tif (robots) {\n\t\tcontributions.push({ kind: \"meta\", name: \"robots\", content: robots });\n\t}\n\n\t// -- Canonical link --\n\n\tif (canonical) {\n\t\tcontributions.push({ kind: \"link\", rel: \"canonical\", href: canonical });\n\t}\n\n\t// -- Open Graph --\n\n\tcontributions.push({\n\t\tkind: \"property\",\n\t\tproperty: \"og:type\",\n\t\tcontent: page.pageType === \"article\" ? \"article\" : \"website\",\n\t});\n\n\tif (ogTitle) {\n\t\tcontributions.push({ kind: \"property\", property: \"og:title\", content: ogTitle });\n\t}\n\n\tif (ogDescription) {\n\t\tcontributions.push({ kind: \"property\", property: \"og:description\", content: ogDescription });\n\t}\n\n\tif (ogImage) {\n\t\tcontributions.push({ kind: \"property\", property: \"og:image\", content: ogImage });\n\t}\n\n\tif (canonical) {\n\t\tcontributions.push({ kind: \"property\", property: \"og:url\", content: canonical });\n\t}\n\n\tif (siteName) {\n\t\tcontributions.push({ kind: \"property\", property: \"og:site_name\", content: siteName });\n\t}\n\n\t// -- Twitter Card --\n\n\tcontributions.push({\n\t\tkind: \"meta\",\n\t\tname: \"twitter:card\",\n\t\tcontent: ogImage ? \"summary_large_image\" : \"summary\",\n\t});\n\n\tif (ogTitle) {\n\t\tcontributions.push({ kind: \"meta\", name: \"twitter:title\", content: ogTitle });\n\t}\n\n\tif (ogDescription) {\n\t\tcontributions.push({ kind: \"meta\", name: \"twitter:description\", content: ogDescription });\n\t}\n\n\tif (ogImage) {\n\t\tcontributions.push({ kind: \"meta\", name: \"twitter:image\", content: ogImage });\n\t}\n\n\t// -- Article metadata --\n\n\tif (page.pageType === \"article\" && page.articleMeta) {\n\t\tconst { publishedTime, modifiedTime, author } = page.articleMeta;\n\t\tif (publishedTime) {\n\t\t\tcontributions.push({\n\t\t\t\tkind: \"property\",\n\t\t\t\tproperty: \"article:published_time\",\n\t\t\t\tcontent: publishedTime,\n\t\t\t});\n\t\t}\n\t\tif (modifiedTime) {\n\t\t\tcontributions.push({\n\t\t\t\tkind: \"property\",\n\t\t\t\tproperty: \"article:modified_time\",\n\t\t\t\tcontent: modifiedTime,\n\t\t\t});\n\t\t}\n\t\tif (author) {\n\t\t\tcontributions.push({\n\t\t\t\tkind: \"property\",\n\t\t\t\tproperty: \"article:author\",\n\t\t\t\tcontent: author,\n\t\t\t});\n\t\t}\n\t}\n\n\t// -- JSON-LD --\n\n\tif (page.pageType === \"article\") {\n\t\tconst blogPosting = buildBlogPostingJsonLd(page);\n\t\tif (blogPosting) {\n\t\t\tcontributions.push({ kind: \"jsonld\", id: \"primary\", graph: blogPosting });\n\t\t}\n\t} else if (siteName) {\n\t\tconst webSite = buildWebSiteJsonLd(page);\n\t\tif (webSite) {\n\t\t\tcontributions.push({ kind: \"jsonld\", id: \"primary\", graph: webSite });\n\t\t}\n\t}\n\n\treturn contributions;\n}\n","/**\n * emdash/page — Public page contribution API\n *\n * Template integration points for plugin-driven head metadata\n * and trusted body fragments.\n */\n\nimport type {\n\tPublicPageContext,\n\tPageMetadataContribution,\n\tPageFragmentContribution,\n} from \"../plugins/types.js\";\n\nexport { createPublicPageContext } from \"./context.js\";\nexport type { CreatePublicPageContextInput } from \"./context.js\";\n\nexport {\n\tresolvePageMetadata,\n\trenderPageMetadata,\n\tsafeJsonLdSerialize,\n\tescapeHtmlAttr,\n} from \"./metadata.js\";\nexport type { ResolvedPageMetadata } from \"./metadata.js\";\n\nexport { resolveFragments, renderFragments } from \"./fragments.js\";\n\nexport { generateBaseSeoContributions } from \"./seo-contributions.js\";\nexport { cleanJsonLd, buildBlogPostingJsonLd, buildWebSiteJsonLd } from \"./jsonld.js\";\n\n/**\n * Shape of the EmDash runtime methods used by the render components.\n * Extracted here so all three components share a single type definition.\n */\nexport interface EmDashPageRuntime {\n\tcollectPageMetadata: (page: PublicPageContext) => Promise<PageMetadataContribution[]>;\n\tcollectPageFragments: (page: PublicPageContext) => Promise<PageFragmentContribution[]>;\n}\n\n/**\n * Get the page runtime from Astro locals. Returns undefined when\n * EmDash is not initialized (components render nothing in that case).\n */\nexport function getPageRuntime(locals: Record<string, unknown>): EmDashPageRuntime | undefined {\n\tconst emdash = locals.emdash;\n\tif (\n\t\temdash &&\n\t\ttypeof emdash === \"object\" &&\n\t\t\"collectPageMetadata\" in emdash &&\n\t\t\"collectPageFragments\" in emdash\n\t) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- structural check above confirms presence of required methods\n\t\treturn emdash as EmDashPageRuntime;\n\t}\n\treturn undefined;\n}\n\n// Astro render components are exported from \"emdash/ui\":\n// import { EmDashHead, EmDashBodyStart, EmDashBodyEnd } from \"emdash/ui\";\n"],"mappings":";AAyDA,SAAS,aAAa,OAA0D;AAC/E,QAAO,WAAW;;;;;AAMnB,SAAgB,wBAAwB,OAAwD;CAC/F,IAAI;CACJ,IAAI;CACJ,IAAI;AAEJ,KAAI,aAAa,MAAM,EAAE;AACxB,QAAM,MAAM,MAAM,IAAI;AACtB,SAAO,MAAM,MAAM,IAAI;AACvB,WAAS,MAAM,MAAM,iBAAiB;QAChC;EACN,MAAM,SAAS,OAAO,MAAM,QAAQ,WAAW,IAAI,IAAI,MAAM,IAAI,GAAG,MAAM;AAC1E,QAAM,OAAO;AACb,SAAO,OAAO;AACd,WAAS,MAAM,UAAU;;AAG1B,QAAO;EACN;EACA;EACA;EACA,MAAM,MAAM;EACZ,UAAU,MAAM,aAAa,MAAM,SAAS,YAAY,YAAY;EACpE,OAAO,MAAM,SAAS;EACtB,WAAW,MAAM,aAAa;EAC9B,aAAa,MAAM,eAAe;EAClC,WAAW,MAAM,aAAa;EAC9B,OAAO,MAAM,SAAS;EACtB,SAAS,MAAM,UACZ;GACA,YAAY,MAAM,QAAQ;GAC1B,IAAI,MAAM,QAAQ;GAClB,MAAM,MAAM,QAAQ,QAAQ;GAC5B,GACA;EACH,KAAK,MAAM;EACX,aAAa,MAAM;EACnB,UAAU,MAAM;EAChB,aAAa,MAAM;EACnB,SAAS,MAAM;EACf;;;;;;AC9EF,MAAM,eAAe;AACrB,MAAM,kBAA0C;CAC/C,KAAK;CACL,KAAK;CACL,KAAK;CACL,MAAK;CACL,KAAK;CACL;AACD,MAAM,iBAAiB;;AAGvB,SAAgB,eAAe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,eAAc,KAAK;EAAE,MAAM;EAAQ,MAAM;EAAiB,SAAS;EAAS,CAAC;AAK9E,KAAI,KAAK,aAAa,aAAa,KAAK,aAAa;EACpD,MAAM,EAAE,eAAe,cAAc,WAAW,KAAK;AACrD,MAAI,cACH,eAAc,KAAK;GAClB,MAAM;GACN,UAAU;GACV,SAAS;GACT,CAAC;AAEH,MAAI,aACH,eAAc,KAAK;GAClB,MAAM;GACN,UAAU;GACV,SAAS;GACT,CAAC;AAEH,MAAI,OACH,eAAc,KAAK;GAClB,MAAM;GACN,UAAU;GACV,SAAS;GACT,CAAC;;AAMJ,KAAI,KAAK,aAAa,WAAW;EAChC,MAAM,cAAc,uBAAuB,KAAK;AAChD,MAAI,YACH,eAAc,KAAK;GAAE,MAAM;GAAU,IAAI;GAAW,OAAO;GAAa,CAAC;YAEhE,UAAU;EACpB,MAAM,UAAU,mBAAmB,KAAK;AACxC,MAAI,QACH,eAAc,KAAK;GAAE,MAAM;GAAU,IAAI;GAAW,OAAO;GAAS,CAAC;;AAIvE,QAAO;;;;;;;;;AC5FR,SAAgB,eAAe,QAAgE;CAC9F,MAAM,SAAS,OAAO;AACtB,KACC,UACA,OAAO,WAAW,YAClB,yBAAyB,UACzB,0BAA0B,OAG1B,QAAO"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/page/context.ts","../../src/page/metadata.ts","../../src/page/fragments.ts","../../src/page/jsonld.ts","../../src/page/seo-contributions.ts","../../src/page/index.ts"],"sourcesContent":["/**\n * Public page context builder\n *\n * Templates call this to describe the page being rendered.\n * The resulting context is passed to EmDashHead / EmDashBodyStart / EmDashBodyEnd.\n */\n\nimport type { BreadcrumbItem, PublicPageContext } from \"../plugins/types.js\";\n\n/** Fields shared by both input forms */\ninterface PageContextFields {\n\tkind: \"content\" | \"custom\";\n\tpageType?: string;\n\ttitle?: string | null;\n\tpageTitle?: string | null;\n\tdescription?: string | null;\n\tcanonical?: string | null;\n\timage?: string | null;\n\tcontent?: { collection: string; id: string; slug?: string | null };\n\t/** SEO overrides for OG/Twitter meta generation */\n\tseo?: {\n\t\togTitle?: string | null;\n\t\togDescription?: string | null;\n\t\togImage?: string | null;\n\t\trobots?: string | null;\n\t};\n\t/** Article metadata for Open Graph article: tags */\n\tarticleMeta?: {\n\t\tpublishedTime?: string | null;\n\t\tmodifiedTime?: string | null;\n\t\tauthor?: string | null;\n\t};\n\t/** Site name for structured data and og:site_name */\n\tsiteName?: string;\n\t/**\n\t * Breadcrumb trail for this page, root first. Pass an empty array\n\t * to explicitly opt out of breadcrumbs (e.g. homepage), or omit the\n\t * field to let consumers fall back to their own derivation.\n\t */\n\tbreadcrumbs?: BreadcrumbItem[];\n\t/** Public-facing site URL (origin) for structured data */\n\tsiteUrl?: string;\n}\n\n/** Input with Astro global -- used in .astro files */\ninterface AstroInput extends PageContextFields {\n\tAstro: { url: URL; currentLocale?: string };\n}\n\n/** Input with explicit URL -- used outside .astro files */\ninterface UrlInput extends PageContextFields {\n\turl: URL | string;\n\tlocale?: string;\n}\n\nexport type CreatePublicPageContextInput = AstroInput | UrlInput;\n\nfunction isAstroInput(input: CreatePublicPageContextInput): input is AstroInput {\n\treturn \"Astro\" in input;\n}\n\n/**\n * Build a PublicPageContext from template input.\n */\nexport function createPublicPageContext(input: CreatePublicPageContextInput): PublicPageContext {\n\tlet url: string;\n\tlet path: string;\n\tlet locale: string | null;\n\n\tif (isAstroInput(input)) {\n\t\turl = input.Astro.url.href;\n\t\tpath = input.Astro.url.pathname;\n\t\tlocale = input.Astro.currentLocale ?? null;\n\t} else {\n\t\tconst parsed = typeof input.url === \"string\" ? new URL(input.url) : input.url;\n\t\turl = parsed.href;\n\t\tpath = parsed.pathname;\n\t\tlocale = input.locale ?? null;\n\t}\n\n\treturn {\n\t\turl,\n\t\tpath,\n\t\tlocale,\n\t\tkind: input.kind,\n\t\tpageType: input.pageType ?? (input.kind === \"content\" ? \"article\" : \"website\"),\n\t\ttitle: input.title ?? null,\n\t\tpageTitle: input.pageTitle ?? null,\n\t\tdescription: input.description ?? null,\n\t\tcanonical: input.canonical ?? null,\n\t\timage: input.image ?? null,\n\t\tcontent: input.content\n\t\t\t? {\n\t\t\t\t\tcollection: input.content.collection,\n\t\t\t\t\tid: input.content.id,\n\t\t\t\t\tslug: input.content.slug ?? null,\n\t\t\t\t}\n\t\t\t: undefined,\n\t\tseo: input.seo,\n\t\tarticleMeta: input.articleMeta,\n\t\tsiteName: input.siteName,\n\t\tbreadcrumbs: input.breadcrumbs,\n\t\tsiteUrl: input.siteUrl,\n\t};\n}\n","/**\n * Page metadata collection and rendering\n *\n * Collects typed metadata contributions from plugins via the page:metadata hook,\n * validates them, and resolves them into a deduplicated structure ready to render.\n */\n\nimport type { PageMetadataContribution, PageMetadataLinkRel } from \"../plugins/types.js\";\n\n// ── Resolved output ─────────────────────────────────────────────\n\nexport interface ResolvedPageMetadata {\n\tmeta: Array<{ name: string; content: string }>;\n\tproperties: Array<{ property: string; content: string }>;\n\tlinks: Array<{\n\t\trel: PageMetadataLinkRel;\n\t\thref: string;\n\t\threflang?: string;\n\t}>;\n\tjsonld: Array<{ id?: string; json: string }>;\n}\n\n// ── Validation ──────────────────────────────────────────────────\n\n/** Schemes safe for use in link href attributes */\nconst SAFE_HREF_RE = /^(https?|at):\\/\\//i;\nconst HTML_ESCAPE_MAP: Record<string, string> = {\n\t\"&\": \"&amp;\",\n\t\"<\": \"&lt;\",\n\t\">\": \"&gt;\",\n\t'\"': \"&quot;\",\n\t\"'\": \"&#39;\",\n};\nconst HTML_ESCAPE_RE = /[&<>\"']/g;\n\n/** Escape a string for safe use in an HTML attribute value */\nexport function escapeHtmlAttr(value: string): string {\n\treturn value.replace(HTML_ESCAPE_RE, (ch) => HTML_ESCAPE_MAP[ch] ?? ch);\n}\n\n/** Validate that a URL uses a safe scheme (http, https, at) */\nfunction isSafeHref(url: string): boolean {\n\treturn SAFE_HREF_RE.test(url);\n}\n\n// ── JSON-LD serialization ───────────────────────────────────────\n\nconst JSONLD_LT_RE = /</g;\nconst JSONLD_GT_RE = />/g;\nconst JSONLD_U2028_RE = /\\u2028/g;\nconst JSONLD_U2029_RE = /\\u2029/g;\n\n/**\n * Safely serialize a value for embedding in a <script type=\"application/ld+json\"> tag.\n *\n * Plain JSON.stringify is not sufficient because:\n * - \"</script>\" in a nested string breaks out of the script tag\n * - \"<!--\" can open an HTML comment\n * - U+2028/U+2029 are line terminators in some JS engines\n */\nexport function safeJsonLdSerialize(value: unknown): string {\n\treturn JSON.stringify(value)\n\t\t.replace(JSONLD_LT_RE, \"\\\\u003c\")\n\t\t.replace(JSONLD_GT_RE, \"\\\\u003e\")\n\t\t.replace(JSONLD_U2028_RE, \"\\\\u2028\")\n\t\t.replace(JSONLD_U2029_RE, \"\\\\u2029\");\n}\n\n// ── Merge / dedupe ──────────────────────────────────────────────\n\n/**\n * Resolve a flat list of contributions into deduplicated metadata.\n * First contribution wins for any given dedupe key.\n */\nexport function resolvePageMetadata(\n\tcontributions: PageMetadataContribution[],\n): ResolvedPageMetadata {\n\tconst result: ResolvedPageMetadata = {\n\t\tmeta: [],\n\t\tproperties: [],\n\t\tlinks: [],\n\t\tjsonld: [],\n\t};\n\n\tconst seenMeta = new Set<string>();\n\tconst seenProperties = new Set<string>();\n\tconst seenLinks = new Set<string>();\n\tconst seenJsonLd = new Set<string>();\n\n\tfor (const c of contributions) {\n\t\tswitch (c.kind) {\n\t\t\tcase \"meta\": {\n\t\t\t\tconst dedupeKey = c.key ?? c.name;\n\t\t\t\tif (seenMeta.has(dedupeKey)) continue;\n\t\t\t\tseenMeta.add(dedupeKey);\n\t\t\t\tresult.meta.push({ name: c.name, content: c.content });\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"property\": {\n\t\t\t\tconst dedupeKey = c.key ?? c.property;\n\t\t\t\tif (seenProperties.has(dedupeKey)) continue;\n\t\t\t\tseenProperties.add(dedupeKey);\n\t\t\t\tresult.properties.push({\n\t\t\t\t\tproperty: c.property,\n\t\t\t\t\tcontent: c.content,\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"link\": {\n\t\t\t\tif (!isSafeHref(c.href)) {\n\t\t\t\t\tif (import.meta.env?.DEV) {\n\t\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t\t`[page:metadata] Rejected link contribution with unsafe href scheme: ${c.href}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (c.rel === \"canonical\") {\n\t\t\t\t\tif (seenLinks.has(\"canonical\")) continue;\n\t\t\t\t\tseenLinks.add(\"canonical\");\n\t\t\t\t} else {\n\t\t\t\t\tconst dedupeKey = c.key ?? c.hreflang ?? c.href;\n\t\t\t\t\tif (seenLinks.has(dedupeKey)) continue;\n\t\t\t\t\tseenLinks.add(dedupeKey);\n\t\t\t\t}\n\t\t\t\tresult.links.push({\n\t\t\t\t\trel: c.rel,\n\t\t\t\t\thref: c.href,\n\t\t\t\t\t...(c.hreflang && { hreflang: c.hreflang }),\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"jsonld\": {\n\t\t\t\tif (c.id) {\n\t\t\t\t\tif (seenJsonLd.has(c.id)) continue;\n\t\t\t\t\tseenJsonLd.add(c.id);\n\t\t\t\t}\n\t\t\t\tresult.jsonld.push({\n\t\t\t\t\tid: c.id,\n\t\t\t\t\tjson: safeJsonLdSerialize(c.graph),\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\t// Unknown contribution kind -- skip silently at runtime.\n\t\t\t\t// TypeScript catches this at compile time for typed callers,\n\t\t\t\t// but sandboxed plugins may return unexpected shapes.\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn result;\n}\n\n// ── HTML rendering ──────────────────────────────────────────────\n\n/** Render resolved metadata to an HTML string for embedding in <head> */\nexport function renderPageMetadata(metadata: ResolvedPageMetadata): string {\n\tconst parts: string[] = [];\n\n\tfor (const m of metadata.meta) {\n\t\tparts.push(`<meta name=\"${escapeHtmlAttr(m.name)}\" content=\"${escapeHtmlAttr(m.content)}\">`);\n\t}\n\n\tfor (const p of metadata.properties) {\n\t\tparts.push(\n\t\t\t`<meta property=\"${escapeHtmlAttr(p.property)}\" content=\"${escapeHtmlAttr(p.content)}\">`,\n\t\t);\n\t}\n\n\tfor (const l of metadata.links) {\n\t\tlet tag = `<link rel=\"${escapeHtmlAttr(l.rel)}\" href=\"${escapeHtmlAttr(l.href)}\"`;\n\t\tif (l.hreflang) {\n\t\t\ttag += ` hreflang=\"${escapeHtmlAttr(l.hreflang)}\"`;\n\t\t}\n\t\ttag += \">\";\n\t\tparts.push(tag);\n\t}\n\n\tfor (const j of metadata.jsonld) {\n\t\tparts.push(`<script type=\"application/ld+json\">${j.json}</script>`);\n\t}\n\n\treturn parts.join(\"\\n\");\n}\n","/**\n * Page fragment collection and rendering\n *\n * Collects raw markup / script contributions from trusted plugins via\n * the page:fragments hook. Sandboxed plugins are never invoked.\n */\n\nimport type { PageFragmentContribution, PagePlacement } from \"../plugins/types.js\";\nimport { escapeHtmlAttr } from \"./metadata.js\";\n\n/** Escape sequences that would break out of a script tag */\nconst SCRIPT_CLOSE_RE = /<\\//g;\n\n// ── Dedupe and filter ───────────────────────────────────────────\n\n/**\n * Filter contributions to a specific placement and deduplicate.\n * - Contributions with the same `key + placement` are deduped (first wins).\n * - External scripts with the same `src + placement` are deduped.\n */\nexport function resolveFragments(\n\tcontributions: PageFragmentContribution[],\n\tplacement: PagePlacement,\n): PageFragmentContribution[] {\n\tconst filtered = contributions.filter((c) => c.placement === placement);\n\tconst seen = new Set<string>();\n\tconst result: PageFragmentContribution[] = [];\n\n\tfor (const c of filtered) {\n\t\t// Key-based dedupe\n\t\tif (c.key) {\n\t\t\tconst dedupeKey = `key:${c.key}`;\n\t\t\tif (seen.has(dedupeKey)) continue;\n\t\t\tseen.add(dedupeKey);\n\t\t} else if (c.kind === \"external-script\") {\n\t\t\tconst dedupeKey = `src:${c.src}`;\n\t\t\tif (seen.has(dedupeKey)) continue;\n\t\t\tseen.add(dedupeKey);\n\t\t}\n\n\t\tresult.push(c);\n\t}\n\n\treturn result;\n}\n\n// ── HTML rendering ──────────────────────────────────────────────\n\nconst EVENT_HANDLER_RE = /^on/i;\n\nfunction renderAttributes(attrs: Record<string, string>): string {\n\treturn Object.entries(attrs)\n\t\t.filter(([k]) => !EVENT_HANDLER_RE.test(k))\n\t\t.map(([k, v]) => ` ${escapeHtmlAttr(k)}=\"${escapeHtmlAttr(v)}\"`)\n\t\t.join(\"\");\n}\n\n/** Render a single fragment contribution to HTML */\nfunction renderFragment(c: PageFragmentContribution): string {\n\tswitch (c.kind) {\n\t\tcase \"external-script\": {\n\t\t\tlet tag = `<script src=\"${escapeHtmlAttr(c.src)}\"`;\n\t\t\tif (c.async) tag += \" async\";\n\t\t\tif (c.defer) tag += \" defer\";\n\t\t\tif (c.attributes) tag += renderAttributes(c.attributes);\n\t\t\ttag += \"></script>\";\n\t\t\treturn tag;\n\t\t}\n\t\tcase \"inline-script\": {\n\t\t\tlet tag = \"<script\";\n\t\t\tif (c.attributes) tag += renderAttributes(c.attributes);\n\t\t\t// Escape </ to <\\/ to prevent breaking out of the script tag.\n\t\t\t// This is valid JS and protects against code built from user data.\n\t\t\ttag += `>${c.code.replace(SCRIPT_CLOSE_RE, \"<\\\\/\")}</script>`;\n\t\t\treturn tag;\n\t\t}\n\t\tcase \"html\":\n\t\t\treturn c.html;\n\t}\n}\n\n/** Render a list of fragment contributions to an HTML string */\nexport function renderFragments(\n\tcontributions: PageFragmentContribution[],\n\tplacement: PagePlacement,\n): string {\n\tconst resolved = resolveFragments(contributions, placement);\n\treturn resolved.map(renderFragment).join(\"\\n\");\n}\n","/**\n * JSON-LD structured data builders\n *\n * Moved from template SEO.astro components into core so all JSON-LD\n * is serialized via safeJsonLdSerialize() and never hand-rolled in templates.\n */\n\nimport type { PublicPageContext } from \"../plugins/types.js\";\n\n/**\n * Remove null/undefined values from a JSON-LD object recursively.\n * JSON-LD validators prefer absent keys over null values.\n */\nexport function cleanJsonLd(obj: Record<string, unknown>): Record<string, unknown> {\n\tconst cleaned: Record<string, unknown> = {};\n\tfor (const [key, value] of Object.entries(obj)) {\n\t\tif (value !== undefined && value !== null) {\n\t\t\tif (typeof value === \"object\" && !Array.isArray(value)) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- non-null, non-array object is safely treated as Record<string, unknown> for JSON-LD traversal\n\t\t\t\tcleaned[key] = cleanJsonLd(value as Record<string, unknown>);\n\t\t\t} else {\n\t\t\t\tcleaned[key] = value;\n\t\t\t}\n\t\t}\n\t}\n\treturn cleaned;\n}\n\n/**\n * Build a BlogPosting JSON-LD graph from page context.\n * Used for article-type content pages.\n */\nexport function buildBlogPostingJsonLd(page: PublicPageContext): Record<string, unknown> | null {\n\tif (page.pageType !== \"article\" || !page.canonical) return null;\n\n\tconst ogTitle = page.seo?.ogTitle ?? page.pageTitle ?? page.title;\n\tconst description = page.seo?.ogDescription || page.description;\n\tconst ogImage = page.seo?.ogImage || page.image;\n\tconst publishedTime = page.articleMeta?.publishedTime;\n\tconst modifiedTime = page.articleMeta?.modifiedTime;\n\tconst author = page.articleMeta?.author;\n\tconst siteName = page.siteName;\n\n\treturn cleanJsonLd({\n\t\t\"@context\": \"https://schema.org\",\n\t\t\"@type\": \"BlogPosting\",\n\t\theadline: ogTitle,\n\t\tdescription,\n\t\timage: ogImage || undefined,\n\t\turl: page.canonical,\n\t\tdatePublished: publishedTime || undefined,\n\t\tdateModified: modifiedTime || publishedTime || undefined,\n\t\tauthor: author\n\t\t\t? {\n\t\t\t\t\t\"@type\": \"Person\",\n\t\t\t\t\tname: author,\n\t\t\t\t}\n\t\t\t: undefined,\n\t\tpublisher: siteName\n\t\t\t? {\n\t\t\t\t\t\"@type\": \"Organization\",\n\t\t\t\t\tname: siteName,\n\t\t\t\t}\n\t\t\t: undefined,\n\t\tmainEntityOfPage: {\n\t\t\t\"@type\": \"WebPage\",\n\t\t\t\"@id\": page.canonical,\n\t\t},\n\t});\n}\n\n/**\n * Build a WebSite JSON-LD graph from page context.\n * Used for non-article pages (homepage, listing pages, etc.)\n */\nexport function buildWebSiteJsonLd(page: PublicPageContext): Record<string, unknown> | null {\n\tconst siteName = page.siteName;\n\tif (!siteName) return null;\n\n\t// Use configured public origin, falling back to page URL origin\n\tlet siteUrl: string;\n\tif (page.siteUrl) {\n\t\tsiteUrl = page.siteUrl;\n\t} else {\n\t\ttry {\n\t\t\tsiteUrl = new URL(page.url).origin;\n\t\t} catch {\n\t\t\tsiteUrl = page.canonical || page.url;\n\t\t}\n\t}\n\n\treturn cleanJsonLd({\n\t\t\"@context\": \"https://schema.org\",\n\t\t\"@type\": \"WebSite\",\n\t\tname: siteName,\n\t\turl: siteUrl,\n\t});\n}\n","/**\n * Generate base SEO metadata contributions from PublicPageContext.\n *\n * These contributions are prepended BEFORE plugin contributions in\n * resolvePageMetadata(), which uses first-wins dedup. This means\n * plugins can override any base SEO tag by contributing the same key.\n *\n * This replaces the per-template SEO.astro components, eliminating\n * the class of XSS bugs where templates hand-rolled JSON-LD serialization.\n */\n\nimport type { PageMetadataContribution, PublicPageContext } from \"../plugins/types.js\";\nimport type { SeoSettings } from \"../settings/types.js\";\nimport { buildBlogPostingJsonLd, buildWebSiteJsonLd } from \"./jsonld.js\";\n\n/**\n * Generate base metadata contributions from a page context's SEO data.\n * Returns an empty array if no SEO-relevant data is present.\n */\nexport function generateBaseSeoContributions(page: PublicPageContext): PageMetadataContribution[] {\n\tconst contributions: PageMetadataContribution[] = [];\n\n\tconst description = page.description;\n\tconst ogTitle = page.seo?.ogTitle ?? page.pageTitle ?? page.title;\n\tconst ogDescription = page.seo?.ogDescription || description;\n\tconst ogImage = page.seo?.ogImage || page.image;\n\tconst robots = page.seo?.robots;\n\tconst canonical = page.canonical;\n\tconst siteName = page.siteName;\n\n\t// -- Meta tags --\n\n\tif (description) {\n\t\tcontributions.push({ kind: \"meta\", name: \"description\", content: description });\n\t}\n\n\tif (robots) {\n\t\tcontributions.push({ kind: \"meta\", name: \"robots\", content: robots });\n\t}\n\n\t// -- Canonical link --\n\n\tif (canonical) {\n\t\tcontributions.push({ kind: \"link\", rel: \"canonical\", href: canonical });\n\t}\n\n\t// -- Open Graph --\n\n\tcontributions.push({\n\t\tkind: \"property\",\n\t\tproperty: \"og:type\",\n\t\tcontent: page.pageType === \"article\" ? \"article\" : \"website\",\n\t});\n\n\tif (ogTitle) {\n\t\tcontributions.push({ kind: \"property\", property: \"og:title\", content: ogTitle });\n\t}\n\n\tif (ogDescription) {\n\t\tcontributions.push({ kind: \"property\", property: \"og:description\", content: ogDescription });\n\t}\n\n\tif (ogImage) {\n\t\tcontributions.push({ kind: \"property\", property: \"og:image\", content: ogImage });\n\t}\n\n\tif (canonical) {\n\t\tcontributions.push({ kind: \"property\", property: \"og:url\", content: canonical });\n\t}\n\n\tif (siteName) {\n\t\tcontributions.push({ kind: \"property\", property: \"og:site_name\", content: siteName });\n\t}\n\n\t// -- Twitter Card --\n\n\tcontributions.push({\n\t\tkind: \"meta\",\n\t\tname: \"twitter:card\",\n\t\tcontent: ogImage ? \"summary_large_image\" : \"summary\",\n\t});\n\n\tif (ogTitle) {\n\t\tcontributions.push({ kind: \"meta\", name: \"twitter:title\", content: ogTitle });\n\t}\n\n\tif (ogDescription) {\n\t\tcontributions.push({ kind: \"meta\", name: \"twitter:description\", content: ogDescription });\n\t}\n\n\tif (ogImage) {\n\t\tcontributions.push({ kind: \"meta\", name: \"twitter:image\", content: ogImage });\n\t}\n\n\t// -- Article metadata --\n\n\tif (page.pageType === \"article\" && page.articleMeta) {\n\t\tconst { publishedTime, modifiedTime, author } = page.articleMeta;\n\t\tif (publishedTime) {\n\t\t\tcontributions.push({\n\t\t\t\tkind: \"property\",\n\t\t\t\tproperty: \"article:published_time\",\n\t\t\t\tcontent: publishedTime,\n\t\t\t});\n\t\t}\n\t\tif (modifiedTime) {\n\t\t\tcontributions.push({\n\t\t\t\tkind: \"property\",\n\t\t\t\tproperty: \"article:modified_time\",\n\t\t\t\tcontent: modifiedTime,\n\t\t\t});\n\t\t}\n\t\tif (author) {\n\t\t\tcontributions.push({\n\t\t\t\tkind: \"property\",\n\t\t\t\tproperty: \"article:author\",\n\t\t\t\tcontent: author,\n\t\t\t});\n\t\t}\n\t}\n\n\t// -- JSON-LD --\n\n\tif (page.pageType === \"article\") {\n\t\tconst blogPosting = buildBlogPostingJsonLd(page);\n\t\tif (blogPosting) {\n\t\t\tcontributions.push({ kind: \"jsonld\", id: \"primary\", graph: blogPosting });\n\t\t}\n\t} else if (siteName) {\n\t\tconst webSite = buildWebSiteJsonLd(page);\n\t\tif (webSite) {\n\t\t\tcontributions.push({ kind: \"jsonld\", id: \"primary\", graph: webSite });\n\t\t}\n\t}\n\n\treturn contributions;\n}\n\n/**\n * Generate site-level SEO metadata contributions from SiteSettings.seo.\n *\n * These tags apply to every page (search engine ownership verification),\n * so they're sourced from site settings rather than per-page context.\n * Returns an empty array when no relevant settings are configured.\n */\nexport function generateSiteSeoContributions(\n\tseoSettings: SeoSettings | undefined,\n): PageMetadataContribution[] {\n\tconst contributions: PageMetadataContribution[] = [];\n\n\tif (!seoSettings) {\n\t\treturn contributions;\n\t}\n\n\tif (seoSettings.googleVerification) {\n\t\tcontributions.push({\n\t\t\tkind: \"meta\",\n\t\t\tname: \"google-site-verification\",\n\t\t\tcontent: seoSettings.googleVerification,\n\t\t});\n\t}\n\n\tif (seoSettings.bingVerification) {\n\t\tcontributions.push({\n\t\t\tkind: \"meta\",\n\t\t\tname: \"msvalidate.01\",\n\t\t\tcontent: seoSettings.bingVerification,\n\t\t});\n\t}\n\n\treturn contributions;\n}\n","/**\n * emdash/page — Public page contribution API\n *\n * Template integration points for plugin-driven head metadata\n * and trusted body fragments.\n */\n\nimport type {\n\tPublicPageContext,\n\tPageMetadataContribution,\n\tPageFragmentContribution,\n} from \"../plugins/types.js\";\n\nexport { createPublicPageContext } from \"./context.js\";\nexport type { CreatePublicPageContextInput } from \"./context.js\";\n\nexport {\n\tresolvePageMetadata,\n\trenderPageMetadata,\n\tsafeJsonLdSerialize,\n\tescapeHtmlAttr,\n} from \"./metadata.js\";\nexport type { ResolvedPageMetadata } from \"./metadata.js\";\n\nexport { resolveFragments, renderFragments } from \"./fragments.js\";\n\nexport { generateBaseSeoContributions, generateSiteSeoContributions } from \"./seo-contributions.js\";\nexport { cleanJsonLd, buildBlogPostingJsonLd, buildWebSiteJsonLd } from \"./jsonld.js\";\n\n/**\n * Shape of the EmDash runtime methods used by the render components.\n * Extracted here so all three components share a single type definition.\n */\nexport interface EmDashPageRuntime {\n\tcollectPageMetadata: (page: PublicPageContext) => Promise<PageMetadataContribution[]>;\n\tcollectPageFragments: (page: PublicPageContext) => Promise<PageFragmentContribution[]>;\n}\n\n/**\n * Get the page runtime from Astro locals. Returns undefined when\n * EmDash is not initialized (components render nothing in that case).\n */\nexport function getPageRuntime(locals: Record<string, unknown>): EmDashPageRuntime | undefined {\n\tconst emdash = locals.emdash;\n\tif (\n\t\temdash &&\n\t\ttypeof emdash === \"object\" &&\n\t\t\"collectPageMetadata\" in emdash &&\n\t\t\"collectPageFragments\" in emdash\n\t) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- structural check above confirms presence of required methods\n\t\treturn emdash as EmDashPageRuntime;\n\t}\n\treturn undefined;\n}\n\n// Astro render components are exported from \"emdash/ui\":\n// import { EmDashHead, EmDashBodyStart, EmDashBodyEnd } from \"emdash/ui\";\n"],"mappings":";AAyDA,SAAS,aAAa,OAA0D;AAC/E,QAAO,WAAW;;;;;AAMnB,SAAgB,wBAAwB,OAAwD;CAC/F,IAAI;CACJ,IAAI;CACJ,IAAI;AAEJ,KAAI,aAAa,MAAM,EAAE;AACxB,QAAM,MAAM,MAAM,IAAI;AACtB,SAAO,MAAM,MAAM,IAAI;AACvB,WAAS,MAAM,MAAM,iBAAiB;QAChC;EACN,MAA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B,MAAM,UAAU,mBAAmB,KAAK;AACxC,MAAI,QACH,eAAc,KAAK;GAAE,MAAM;GAAU,IAAI;GAAW,OAAO;GAAS,CAAC;;AAIvE,QAAO;;;;;;;;;AAUR,SAAgB,6BACf,aAC6B;CAC7B,MAAM,gBAA4C,EAAE;AAEpD,KAAI,CAAC,YACJ,QAAO;AAGR,KAAI,YAAY,mBACf,eAAc,KAAK;EAClB,MAAM;EACN,MAAM;EACN,SAAS,YAAY;EACrB,CAAC;AAGH,KAAI,YAAY,iBACf,eAAc,KAAK;EAClB,MAAM;EACN,MAAM;EACN,SAAS,YAAY;EACrB,CAAC;AAGH,QAAO;;;;;;;;;AChIR,SAAgB,eAAe,QAAgE;CAC9F,MAAM,SAAS,OAAO;AACtB,KACC,UACA,OAAO,WAAW,YAClB,yBAAyB,UACzB,0BAA0B,OAG1B,QAAO"}
@@ -265,4 +265,4 @@ function downsample(src, srcW, srcH, dstW, dstH) {
265
265
 
266
266
  //#endregion
267
267
  export { normalizeMediaValue as n, generatePlaceholder as t };
268
- //# sourceMappingURL=placeholder-DntBEQo7.mjs.map
268
+ //# sourceMappingURL=placeholder-C-fk5hYI.mjs.map