@phtngyn/cms 0.1.0-beta.0 → 0.1.0-beta.2

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 (181) hide show
  1. package/README.md +260 -6
  2. package/package.json +31 -16
  3. package/src/Authoring.d.ts +13 -1
  4. package/src/Configuration-Br7tE9Qt.d.ts +68 -0
  5. package/src/{AuthoringSchema-BQ5kbhVB.js → Configuration-CA_jvQKG.js} +599 -492
  6. package/src/Configuration-CA_jvQKG.js.map +1 -0
  7. package/src/Configuration.d.ts +2 -44
  8. package/src/Configuration.js +0 -1
  9. package/src/Configuration.js.map +1 -1
  10. package/src/{DocumentEngine-Da0kWotL.js → DocumentEngine-CgiBQU4g.js} +110 -84
  11. package/src/DocumentEngine-CgiBQU4g.js.map +1 -0
  12. package/src/DocumentModel-BB9igGC7.d.ts +34 -0
  13. package/src/DocumentModel.d.ts +2 -30
  14. package/src/DocumentModel.js +13 -3
  15. package/src/DocumentModel.js.map +1 -1
  16. package/src/Forms-BsJMev5_.d.ts +74 -0
  17. package/src/Forms-CfcI3tPU.js +79 -0
  18. package/src/Forms-CfcI3tPU.js.map +1 -0
  19. package/src/Forms-DxbkU3_5.js +367 -0
  20. package/src/Forms-DxbkU3_5.js.map +1 -0
  21. package/src/Forms.d.ts +35 -0
  22. package/src/Forms.js +13 -0
  23. package/src/Forms.js.map +1 -0
  24. package/src/HttpPaths-c9nLZ9H2.js +21 -0
  25. package/src/HttpPaths-c9nLZ9H2.js.map +1 -0
  26. package/src/I18n-DZK4CkJF.d.ts +21 -0
  27. package/src/I18n.d.ts +2 -0
  28. package/src/I18n.js +1 -0
  29. package/src/Module.js +78 -81
  30. package/src/Module.js.map +1 -1
  31. package/src/S3MediaObjects-JKMAWyVB.js +2664 -0
  32. package/src/S3MediaObjects-JKMAWyVB.js.map +1 -0
  33. package/src/Seed.d.ts +6 -0
  34. package/src/Seed.js +34 -0
  35. package/src/Seed.js.map +1 -0
  36. package/src/Seo-402YumpT.d.ts +198 -0
  37. package/src/{connection-ZGtL54qY.js → connection-B-iz0Y9Y.js} +5 -7
  38. package/src/connection-B-iz0Y9Y.js.map +1 -0
  39. package/src/{installation-BNKaVjni.js → installation-DgF2M1gL.js} +1162 -2147
  40. package/src/installation-DgF2M1gL.js.map +1 -0
  41. package/src/internal/authoring-catalog.js +153 -0
  42. package/src/internal/authoring-catalog.js.map +1 -0
  43. package/src/internal/authoring-compiler.js +2 -2
  44. package/src/internal/authoring-compiler.js.map +1 -1
  45. package/src/internal/authoring-metadata.js +68 -49
  46. package/src/internal/authoring-metadata.js.map +1 -1
  47. package/src/internal/cms-config.js +0 -1
  48. package/src/internal/cms-config.js.map +1 -1
  49. package/src/internal/configuration.js +25 -13
  50. package/src/internal/configuration.js.map +1 -1
  51. package/src/internal/document-model.js +66 -20
  52. package/src/internal/document-model.js.map +1 -1
  53. package/src/internal/form-capabilities.js +12 -0
  54. package/src/internal/form-capabilities.js.map +1 -0
  55. package/src/internal/i18n.js +47 -0
  56. package/src/internal/i18n.js.map +1 -0
  57. package/src/internal/studio-app.js +66 -0
  58. package/src/internal/studio-app.js.map +1 -0
  59. package/src/location-CFKTeK1K.js +35 -0
  60. package/src/location-CFKTeK1K.js.map +1 -0
  61. package/src/{metadata-Czvi3E4K.js → metadata-BEZPWh-3.js} +3 -72
  62. package/src/metadata-BEZPWh-3.js.map +1 -0
  63. package/src/{models-DS5ClMsH.js → models-BWm1pTAf.js} +9 -31
  64. package/src/models-BWm1pTAf.js.map +1 -0
  65. package/src/models-DwYioyNV.js +726 -0
  66. package/src/models-DwYioyNV.js.map +1 -0
  67. package/src/runtime/blocks.js +30 -0
  68. package/src/runtime/blocks.js.map +1 -0
  69. package/src/runtime/collaboration.js +9 -4
  70. package/src/runtime/collaboration.js.map +1 -1
  71. package/src/runtime/delivery/DocumentRenderer.js +10 -4
  72. package/src/runtime/delivery/DocumentRenderer.js.map +1 -1
  73. package/src/runtime/delivery/blocks.js +8 -0
  74. package/src/runtime/delivery/blocks.js.map +1 -0
  75. package/src/runtime/delivery/context.js +12 -0
  76. package/src/runtime/delivery/context.js.map +1 -0
  77. package/src/runtime/delivery/document-page.js +14 -12
  78. package/src/runtime/delivery/document-page.js.map +1 -1
  79. package/src/runtime/delivery/document.js +21 -3
  80. package/src/runtime/delivery/document.js.map +1 -1
  81. package/src/runtime/delivery/error.js +11 -0
  82. package/src/runtime/delivery/error.js.map +1 -0
  83. package/src/runtime/delivery/plugin.js +41 -0
  84. package/src/runtime/delivery/plugin.js.map +1 -0
  85. package/src/runtime/delivery/types.d.ts +5 -0
  86. package/src/runtime/delivery/useCmsDocumentSeo.d.ts +56 -0
  87. package/src/runtime/delivery/useCmsDocumentSeo.js +99 -0
  88. package/src/runtime/delivery/useCmsDocumentSeo.js.map +1 -0
  89. package/src/runtime/delivery/useDocument.js +5 -2
  90. package/src/runtime/delivery/useDocument.js.map +1 -1
  91. package/src/runtime/delivery/useDocumentQuery.js +5 -2
  92. package/src/runtime/delivery/useDocumentQuery.js.map +1 -1
  93. package/src/runtime/forms/document.js +38 -0
  94. package/src/runtime/forms/document.js.map +1 -0
  95. package/src/runtime/forms/useCmsForm.js +149 -0
  96. package/src/runtime/forms/useCmsForm.js.map +1 -0
  97. package/src/runtime/i18n/translator.js +22 -0
  98. package/src/runtime/i18n/translator.js.map +1 -0
  99. package/src/runtime/i18n/useCmsI18n.d.ts +9 -0
  100. package/src/runtime/i18n/useCmsI18n.js +29 -0
  101. package/src/runtime/i18n/useCmsI18n.js.map +1 -0
  102. package/src/runtime/installation.js +1 -1
  103. package/src/runtime/plugin.js +3 -3
  104. package/src/runtime/plugin.js.map +1 -1
  105. package/src/runtime/preview/comark-document.js +0 -1
  106. package/src/runtime/preview/comark-document.js.map +1 -1
  107. package/src/runtime/preview/connection.js +1 -1
  108. package/src/runtime/preview/controller.js +37 -11
  109. package/src/runtime/preview/controller.js.map +1 -1
  110. package/src/runtime/preview/overlay.js +65 -0
  111. package/src/runtime/preview/overlay.js.map +1 -0
  112. package/src/runtime/preview/plugin.client.js +59 -61
  113. package/src/runtime/preview/plugin.client.js.map +1 -1
  114. package/src/runtime/preview/preview.css +72 -4
  115. package/src/runtime/preview/protocol.js.map +1 -1
  116. package/src/runtime/preview/store.js +1 -1
  117. package/src/runtime/preview/targets.js +0 -1
  118. package/src/runtime/preview/targets.js.map +1 -1
  119. package/src/runtime/sitemap-entries.js +17 -0
  120. package/src/runtime/sitemap-entries.js.map +1 -0
  121. package/src/runtime/sitemap.js +24 -0
  122. package/src/runtime/sitemap.js.map +1 -0
  123. package/src/runtime/studio-app.js +5 -1
  124. package/src/runtime/studio-app.js.map +1 -1
  125. package/src/runtime/studio-entry.js +36 -0
  126. package/src/runtime/studio-entry.js.map +1 -0
  127. package/src/runtime/studio-navigation.js +11 -0
  128. package/src/runtime/studio-navigation.js.map +1 -0
  129. package/src/scalars-B2lgGUnj.js +26 -0
  130. package/src/scalars-B2lgGUnj.js.map +1 -0
  131. package/src/{store-Nl4uxEXx.js → store-DjJs3I7k.js} +12 -7
  132. package/src/store-DjJs3I7k.js.map +1 -0
  133. package/studio/CreateDocumentDialog-CTeIFlPb.js +256 -0
  134. package/studio/collaboration-DcK2F6v9.js +4566 -0
  135. package/studio/documentPlanning-Bfv-d7OU.js +29820 -0
  136. package/studio/dom-to-image-more.min-D6jGGdrW.js +877 -0
  137. package/studio/editor-Bzlh3zXt.js +30827 -0
  138. package/studio/host.css +3 -0
  139. package/studio/host.js +46614 -0
  140. package/studio/rolldown-runtime-B0aSnxlc.js +20 -0
  141. package/dist/studio/assets/ActivityEntryRow-D--fRvWI.js +0 -1
  142. package/dist/studio/assets/ActivityView-D-XBBUHb.js +0 -1
  143. package/dist/studio/assets/CreateDocumentDialog-CH8UH1QM.js +0 -1
  144. package/dist/studio/assets/DocumentsView-CxRpmAxt.js +0 -34
  145. package/dist/studio/assets/DropdownMenu-BSb1l7fr.js +0 -1
  146. package/dist/studio/assets/Input-DVao38h7.js +0 -3
  147. package/dist/studio/assets/MediaView-BHrPIjxB.js +0 -1
  148. package/dist/studio/assets/Modal-VNrXGa5C.js +0 -1
  149. package/dist/studio/assets/OverviewView-DfP6-mLZ.js +0 -1
  150. package/dist/studio/assets/Select-BJZIs9sY.js +0 -1
  151. package/dist/studio/assets/SettingsView-CerHe-ua.js +0 -1
  152. package/dist/studio/assets/Skeleton-CWJNi3nS.js +0 -1
  153. package/dist/studio/assets/StudioPageHeader-DP9HDAF2.js +0 -1
  154. package/dist/studio/assets/UsersView-cP3REkH2.js +0 -1
  155. package/dist/studio/assets/collaboration-BLnCzfvV.js +0 -4
  156. package/dist/studio/assets/context-dY4fNbn3.js +0 -1
  157. package/dist/studio/assets/editor-CE07wW83.js +0 -137
  158. package/dist/studio/assets/gateway-BAyQgCse.js +0 -10
  159. package/dist/studio/assets/index-CjoaPLhZ.js +0 -28
  160. package/dist/studio/assets/index-s2rPqCmP.css +0 -2
  161. package/dist/studio/assets/render-BkxbK2St.js +0 -83
  162. package/dist/studio/assets/rolldown-runtime-DK3Fl9T5.js +0 -1
  163. package/dist/studio/assets/useMediaLibrary-D7qR7aBf.js +0 -1
  164. package/dist/studio/index.html +0 -76
  165. package/src/AuthoringSchema-BQ5kbhVB.js.map +0 -1
  166. package/src/Configuration-BGYFD2N1.js +0 -150
  167. package/src/Configuration-BGYFD2N1.js.map +0 -1
  168. package/src/DocumentEngine-Da0kWotL.js.map +0 -1
  169. package/src/HttpPaths-86qLGB90.js +0 -15
  170. package/src/HttpPaths-86qLGB90.js.map +0 -1
  171. package/src/StudioHttp-BTLLooh0.js +0 -916
  172. package/src/StudioHttp-BTLLooh0.js.map +0 -1
  173. package/src/connection-ZGtL54qY.js.map +0 -1
  174. package/src/installation-BNKaVjni.js.map +0 -1
  175. package/src/internal/component-metadata.js +0 -37
  176. package/src/internal/component-metadata.js.map +0 -1
  177. package/src/metadata-Czvi3E4K.js.map +0 -1
  178. package/src/models-Citx8jBi.js +0 -306
  179. package/src/models-Citx8jBi.js.map +0 -1
  180. package/src/models-DS5ClMsH.js.map +0 -1
  181. package/src/store-Nl4uxEXx.js.map +0 -1
@@ -0,0 +1,24 @@
1
+ import { X as SitemapEntry } from "../models-DwYioyNV.js";
2
+ import { i as CMS_DELIVERY_SITEMAP_PATH } from "../HttpPaths-c9nLZ9H2.js";
3
+ import { useCmsInstallation } from "./plugin.js";
4
+ import { toNuxtSitemapEntries } from "./sitemap-entries.js";
5
+ import { Effect, Schema } from "effect";
6
+ import { createError, defineEventHandler, getRequestURL } from "h3";
7
+
8
+ //#region src/runtime/sitemap.ts
9
+ const SitemapDelivery = Schema.Array(SitemapEntry);
10
+ var sitemap_default = defineEventHandler((event) => Effect.runPromise(Effect.gen(function* () {
11
+ const installation = yield* Effect.promise(useCmsInstallation);
12
+ const response = yield* Effect.promise(() => installation.fetch(new Request(new URL(CMS_DELIVERY_SITEMAP_PATH, getRequestURL(event).origin))));
13
+ if (!response.ok) return yield* Effect.fail(createError({
14
+ statusCode: response.status,
15
+ statusMessage: "CMS sitemap delivery failed"
16
+ }));
17
+ const payload = yield* Effect.promise(() => response.json());
18
+ const entries = yield* Schema.decodeUnknownEffect(SitemapDelivery)(payload);
19
+ return toNuxtSitemapEntries(entries);
20
+ })));
21
+
22
+ //#endregion
23
+ export { sitemap_default as default };
24
+ //# sourceMappingURL=sitemap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sitemap.js","names":[],"sources":["../../../../src/runtime/sitemap.ts"],"sourcesContent":["import { CMS_DELIVERY_SITEMAP_PATH } from '@internal/protocol/HttpPaths'\nimport { SitemapEntry } from '@internal/protocol/Seo'\nimport { Effect, Schema } from 'effect'\nimport { createError, defineEventHandler, getRequestURL } from 'h3'\nimport { useCmsInstallation } from './plugin'\nimport { toNuxtSitemapEntries } from './sitemap-entries'\n\nconst SitemapDelivery = Schema.Array(SitemapEntry)\n\nexport default defineEventHandler((event) =>\n Effect.runPromise(\n Effect.gen(function* () {\n const installation = yield* Effect.promise(useCmsInstallation)\n\n const response = yield* Effect.promise(() =>\n installation.fetch(new Request(new URL(CMS_DELIVERY_SITEMAP_PATH, getRequestURL(event).origin))),\n )\n\n if (!response.ok) {\n return yield* Effect.fail(\n createError({\n statusCode: response.status,\n statusMessage: 'CMS sitemap delivery failed',\n }),\n )\n }\n\n const payload = yield* Effect.promise(() => response.json())\n const entries = yield* Schema.decodeUnknownEffect(SitemapDelivery)(payload)\n\n return toNuxtSitemapEntries(entries)\n }),\n ),\n)\n"],"mappings":";;;;;;;;AAOA,MAAM,kBAAkB,OAAO,MAAM,YAAY;AAEjD,sBAAe,oBAAoB,UACjC,OAAO,WACL,OAAO,IAAI,aAAa;CACtB,MAAM,eAAe,OAAO,OAAO,QAAQ,kBAAkB;CAE7D,MAAM,WAAW,OAAO,OAAO,cAC7B,aAAa,MAAM,IAAI,QAAQ,IAAI,IAAI,2BAA2B,cAAc,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CACjG;CAEA,IAAI,CAAC,SAAS,IACZ,OAAO,OAAO,OAAO,KACnB,YAAY;EACV,YAAY,SAAS;EACrB,eAAe;CACjB,CAAC,CACH;CAGF,MAAM,UAAU,OAAO,OAAO,cAAc,SAAS,KAAK,CAAC;CAC3D,MAAM,UAAU,OAAO,OAAO,oBAAoB,eAAe,CAAC,CAAC,OAAO;CAE1E,OAAO,qBAAqB,OAAO;AACrC,CAAC,CACH,CACF"}
@@ -1,9 +1,13 @@
1
1
  import { defineEventHandler, setResponseHeader } from "h3";
2
2
 
3
3
  //#region src/runtime/studio-app.ts
4
- function createStudioAppHandler(shell) {
4
+ function createStudioAppHandler(entryUrl, hmrUrl) {
5
+ const escape = (value) => value.replaceAll("&", "&amp;").replaceAll("\"", "&quot;").replaceAll("<", "&lt;");
6
+ const script = (url) => `<script type="module" src="${escape(url)}"><\/script>`;
7
+ const shell = `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>CMS Studio</title></head><body><div id="cms-studio"></div>${hmrUrl ? script(hmrUrl) : ""}${script(entryUrl)}</body></html>`;
5
8
  return defineEventHandler((event) => {
6
9
  setResponseHeader(event, "content-type", "text/html; charset=utf-8");
10
+ setResponseHeader(event, "cache-control", "no-store");
7
11
  return shell;
8
12
  });
9
13
  }
@@ -1 +1 @@
1
- {"version":3,"file":"studio-app.js","names":[],"sources":["../../../../src/runtime/studio-app.ts"],"sourcesContent":["import { defineEventHandler, setResponseHeader } from 'h3'\n\nexport function createStudioAppHandler(shell: string) {\n return defineEventHandler((event) => {\n setResponseHeader(event, 'content-type', 'text/html; charset=utf-8')\n return shell\n })\n}\n"],"mappings":";;;AAEA,SAAgB,uBAAuB,OAAe;CACpD,OAAO,oBAAoB,UAAU;EACnC,kBAAkB,OAAO,gBAAgB,0BAA0B;EACnE,OAAO;CACT,CAAC;AACH"}
1
+ {"version":3,"file":"studio-app.js","names":[],"sources":["../../../../src/runtime/studio-app.ts"],"sourcesContent":["import { defineEventHandler, setResponseHeader } from 'h3'\n\nexport function createStudioAppHandler(entryUrl: string, hmrUrl?: string) {\n const escape = (value: string) => value.replaceAll('&', '&amp;').replaceAll('\"', '&quot;').replaceAll('<', '&lt;')\n const script = (url: string) => `<script type=\"module\" src=\"${escape(url)}\"></script>`\n const shell = `<!doctype html><html lang=\"en\"><head><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><title>CMS Studio</title></head><body><div id=\"cms-studio\"></div>${hmrUrl ? script(hmrUrl) : ''}${script(entryUrl)}</body></html>`\n\n return defineEventHandler((event) => {\n setResponseHeader(event, 'content-type', 'text/html; charset=utf-8')\n setResponseHeader(event, 'cache-control', 'no-store')\n\n return shell\n })\n}\n"],"mappings":";;;AAEA,SAAgB,uBAAuB,UAAkB,QAAiB;CACxE,MAAM,UAAU,UAAkB,MAAM,WAAW,KAAK,OAAO,CAAC,CAAC,WAAW,MAAK,QAAQ,CAAC,CAAC,WAAW,KAAK,MAAM;CACjH,MAAM,UAAU,QAAgB,8BAA8B,OAAO,GAAG,EAAE;CAC1E,MAAM,QAAQ,mMAAmM,SAAS,OAAO,MAAM,IAAI,KAAK,OAAO,QAAQ,EAAE;CAEjQ,OAAO,oBAAoB,UAAU;EACnC,kBAAkB,OAAO,gBAAgB,0BAA0B;EACnE,kBAAkB,OAAO,iBAAiB,UAAU;EAEpD,OAAO;CACT,CAAC;AACH"}
@@ -0,0 +1,36 @@
1
+ import authoring from "#cms/authoring";
2
+ import { mountStudio } from "#cms/studio";
3
+ import stylesheet from "#cms/studio-styles";
4
+
5
+ //#region src/runtime/studio-entry.ts
6
+ const root = document.getElementById("cms-studio");
7
+ if (!root) throw new Error("CMS Studio root is missing.");
8
+ let currentCatalog = authoring;
9
+ let studio;
10
+ const link = document.createElement("link");
11
+ link.rel = "stylesheet";
12
+ link.href = stylesheet;
13
+ link.onload = () => {
14
+ studio = mountStudio(root, currentCatalog);
15
+ };
16
+ link.onerror = () => {
17
+ root.textContent = "CMS Studio styles could not load. Reload this page to retry.";
18
+ };
19
+ document.head.append(link);
20
+ if (import.meta.hot) {
21
+ import.meta.hot.accept("#cms/authoring", (module) => {
22
+ if (!module) return;
23
+ currentCatalog = module.default;
24
+ studio?.updateAuthoring(currentCatalog);
25
+ });
26
+ import.meta.hot.dispose(() => {
27
+ link.onload = null;
28
+ link.onerror = null;
29
+ studio?.unmount();
30
+ link.remove();
31
+ });
32
+ }
33
+
34
+ //#endregion
35
+ export { };
36
+ //# sourceMappingURL=studio-entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"studio-entry.js","names":["catalog"],"sources":["../../../../src/runtime/studio-entry.ts"],"sourcesContent":["import { mountStudio } from '#cms/studio'\nimport catalog from '#cms/authoring'\nimport stylesheet from '#cms/studio-styles'\n\nconst root = document.getElementById('cms-studio')\n\nif (!root) throw new Error('CMS Studio root is missing.')\n\nlet currentCatalog = catalog\n\nlet studio: ReturnType<typeof mountStudio> | undefined\n\nconst link = document.createElement('link')\n\nlink.rel = 'stylesheet'\n\nlink.href = stylesheet\n\nlink.onload = () => {\n studio = mountStudio(root, currentCatalog)\n}\n\nlink.onerror = () => {\n root.textContent = 'CMS Studio styles could not load. Reload this page to retry.'\n}\n\ndocument.head.append(link)\n\nif (import.meta.hot) {\n import.meta.hot.accept('#cms/authoring', (module) => {\n if (!module) return\n currentCatalog = module.default\n studio?.updateAuthoring(currentCatalog)\n })\n import.meta.hot.dispose(() => {\n link.onload = null\n link.onerror = null\n studio?.unmount()\n link.remove()\n })\n}\n"],"mappings":";;;;;AAIA,MAAM,OAAO,SAAS,eAAe,YAAY;AAEjD,IAAI,CAAC,MAAM,MAAM,IAAI,MAAM,6BAA6B;AAExD,IAAI,iBAAiBA;AAErB,IAAI;AAEJ,MAAM,OAAO,SAAS,cAAc,MAAM;AAE1C,KAAK,MAAM;AAEX,KAAK,OAAO;AAEZ,KAAK,eAAe;CAClB,SAAS,YAAY,MAAM,cAAc;AAC3C;AAEA,KAAK,gBAAgB;CACnB,KAAK,cAAc;AACrB;AAEA,SAAS,KAAK,OAAO,IAAI;AAEzB,IAAI,YAAY,KAAK;CACnB,YAAY,IAAI,OAAO,mBAAmB,WAAW;EACnD,IAAI,CAAC,QAAQ;EACb,iBAAiB,OAAO;EACxB,QAAQ,gBAAgB,cAAc;CACxC,CAAC;CACD,YAAY,IAAI,cAAc;EAC5B,KAAK,SAAS;EACd,KAAK,UAAU;EACf,QAAQ,QAAQ;EAChB,KAAK,OAAO;CACd,CAAC;AACH"}
@@ -0,0 +1,11 @@
1
+ import { d as STUDIO_APP_PATH, f as STUDIO_BASE_PATH } from "../HttpPaths-c9nLZ9H2.js";
2
+ import { defineNuxtRouteMiddleware, navigateTo } from "nuxt/app";
3
+
4
+ //#region src/runtime/studio-navigation.ts
5
+ var studio_navigation_default = defineNuxtRouteMiddleware((to) => {
6
+ if (to.path === "/_cms" || to.path === STUDIO_APP_PATH || to.path.startsWith(`${STUDIO_APP_PATH}/`)) return navigateTo(to.fullPath, { external: true });
7
+ });
8
+
9
+ //#endregion
10
+ export { studio_navigation_default as default };
11
+ //# sourceMappingURL=studio-navigation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"studio-navigation.js","names":[],"sources":["../../../../src/runtime/studio-navigation.ts"],"sourcesContent":["import { defineNuxtRouteMiddleware, navigateTo } from 'nuxt/app'\nimport { STUDIO_APP_PATH, STUDIO_BASE_PATH } from '@internal/protocol/HttpPaths'\n\nexport default defineNuxtRouteMiddleware((to) => {\n if (to.path === STUDIO_BASE_PATH || to.path === STUDIO_APP_PATH || to.path.startsWith(`${STUDIO_APP_PATH}/`)) {\n return navigateTo(to.fullPath, { external: true })\n }\n})\n"],"mappings":";;;;AAGA,gCAAe,2BAA2B,OAAO;CAC/C,IAAI,GAAG,oBAA6B,GAAG,SAAS,mBAAmB,GAAG,KAAK,WAAW,GAAG,gBAAgB,EAAE,GACzG,OAAO,WAAW,GAAG,UAAU,EAAE,UAAU,KAAK,CAAC;AAErD,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { Schema } from "effect";
2
+
3
+ //#region ../protocol/src/internal/scalars.ts
4
+ const nonNegativeInt = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));
5
+ const publicPathPattern = /^\/(?!(?:[^/]+\/)*\.\.?(?:\/|$))(?:[^/?#\\]+(?:\/[^/?#\\]+)*)?$/u;
6
+
7
+ //#endregion
8
+ //#region ../protocol/src/internal/documents/scalars.ts
9
+ const relativeDocumentPathPattern = /^(?!(?:[^/]+\/)*\.\.?(?:\/|$))[^/?#\\]+(?:\/[^/?#\\]+)*$/u;
10
+ const slugPattern = /^[\p{Letter}\p{Number}][\p{Letter}\p{Number}_-]*$/u;
11
+ const sourcePathPattern = /^(?!\.)[^/?#\\]+(?:\/(?!\.)[^/?#\\]+)*\.(?:md|mdc)$/u;
12
+ const DocumentGeneration = Schema.String.check(Schema.isPattern(/^(?:0|[1-9]\d*)$/u)).pipe(Schema.brand("DocumentGeneration"));
13
+ const DocumentVersion = Schema.NonEmptyString.pipe(Schema.brand("DocumentVersion"));
14
+ const DocumentHistoryCursor = Schema.NonEmptyString.pipe(Schema.brand("DocumentHistoryCursor"));
15
+ const DocumentId = Schema.String.check(Schema.isUUID()).pipe(Schema.brand("DocumentId"));
16
+ const EditorNodeId = Schema.String.check(Schema.isUUID()).pipe(Schema.brand("EditorNodeId"));
17
+ const PublicPath = Schema.String.check(Schema.isPattern(publicPathPattern)).pipe(Schema.brand("PublicPath"));
18
+ const RelativeDocumentPath = Schema.String.check(Schema.isPattern(relativeDocumentPathPattern)).pipe(Schema.brand("RelativeDocumentPath"));
19
+ const RevisionId = Schema.String.check(Schema.isUUID()).pipe(Schema.brand("RevisionId"));
20
+ const RevisionNumber = nonNegativeInt.pipe(Schema.brand("RevisionNumber"));
21
+ const Slug = Schema.String.check(Schema.isPattern(slugPattern)).pipe(Schema.brand("Slug"));
22
+ const SourcePath = Schema.String.check(Schema.isPattern(sourcePathPattern)).pipe(Schema.brand("SourcePath"));
23
+
24
+ //#endregion
25
+ export { EditorNodeId as a, RevisionId as c, SourcePath as d, nonNegativeInt as f, DocumentVersion as i, RevisionNumber as l, DocumentHistoryCursor as n, PublicPath as o, publicPathPattern as p, DocumentId as r, RelativeDocumentPath as s, DocumentGeneration as t, Slug as u };
26
+ //# sourceMappingURL=scalars-B2lgGUnj.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scalars-B2lgGUnj.js","names":[],"sources":["../../../../protocol/src/internal/scalars.ts","../../../../protocol/src/internal/documents/scalars.ts"],"sourcesContent":["import { Schema } from 'effect'\n\nexport const nonNegativeInt = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))\n\nexport const publicPathPattern = /^\\/(?!(?:[^/]+\\/)*\\.\\.?(?:\\/|$))(?:[^/?#\\\\]+(?:\\/[^/?#\\\\]+)*)?$/u\n","import { Schema } from 'effect'\nimport { nonNegativeInt, publicPathPattern } from '../scalars'\n\nconst relativeDocumentPathPattern = /^(?!(?:[^/]+\\/)*\\.\\.?(?:\\/|$))[^/?#\\\\]+(?:\\/[^/?#\\\\]+)*$/u\n\nconst slugPattern = /^[\\p{Letter}\\p{Number}][\\p{Letter}\\p{Number}_-]*$/u\n\nconst sourcePathPattern = /^(?!\\.)[^/?#\\\\]+(?:\\/(?!\\.)[^/?#\\\\]+)*\\.(?:md|mdc)$/u\n\nexport const DocumentGeneration = Schema.String.check(Schema.isPattern(/^(?:0|[1-9]\\d*)$/u)).pipe(\n Schema.brand('DocumentGeneration'),\n)\n\nexport type DocumentGeneration = typeof DocumentGeneration.Type\n\nexport const DocumentVersion = Schema.NonEmptyString.pipe(Schema.brand('DocumentVersion'))\n\nexport type DocumentVersion = typeof DocumentVersion.Type\n\nexport const DocumentHistoryCursor = Schema.NonEmptyString.pipe(Schema.brand('DocumentHistoryCursor'))\n\nexport type DocumentHistoryCursor = typeof DocumentHistoryCursor.Type\n\nexport const DocumentId = Schema.String.check(Schema.isUUID()).pipe(Schema.brand('DocumentId'))\n\nexport type DocumentId = typeof DocumentId.Type\n\nexport const EditorNodeId = Schema.String.check(Schema.isUUID()).pipe(Schema.brand('EditorNodeId'))\n\nexport type EditorNodeId = typeof EditorNodeId.Type\n\nexport const PublicPath = Schema.String.check(Schema.isPattern(publicPathPattern)).pipe(Schema.brand('PublicPath'))\n\nexport type PublicPath = typeof PublicPath.Type\n\nexport const RelativeDocumentPath = Schema.String.check(Schema.isPattern(relativeDocumentPathPattern)).pipe(\n Schema.brand('RelativeDocumentPath'),\n)\n\nexport type RelativeDocumentPath = typeof RelativeDocumentPath.Type\n\nexport const RevisionId = Schema.String.check(Schema.isUUID()).pipe(Schema.brand('RevisionId'))\n\nexport type RevisionId = typeof RevisionId.Type\n\nexport const RevisionNumber = nonNegativeInt.pipe(Schema.brand('RevisionNumber'))\n\nexport type RevisionNumber = typeof RevisionNumber.Type\n\nexport const Slug = Schema.String.check(Schema.isPattern(slugPattern)).pipe(Schema.brand('Slug'))\n\nexport type Slug = typeof Slug.Type\n\nexport const SourcePath = Schema.String.check(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AAK,OAAO,MAAM,YAAY,CAAC"}
@@ -1,5 +1,8 @@
1
- import { H as PublicPath, P as CollectionName, n as CmsMarkdownDocument, z as DocumentId } from "./models-Citx8jBi.js";
2
- import { l as mutableJson, n as editorMetadata, u as mutableJsonObject } from "./metadata-Czvi3E4K.js";
1
+ import { o as PublicPath, r as DocumentId } from "./scalars-B2lgGUnj.js";
2
+ import { f as mutableJson, p as mutableJsonObject } from "./Forms-DxbkU3_5.js";
3
+ import { Et as CollectionName, n as CmsMarkdownDocument } from "./models-DwYioyNV.js";
4
+ import { n as editorMetadata } from "./metadata-BEZPWh-3.js";
5
+ import { prepareFormDocument } from "./runtime/forms/document.js";
3
6
  import { CMS_PREVIEW_INLINE_HOST_ATTRIBUTE, CMS_PREVIEW_MARKER_TAG, CMS_PREVIEW_NODE_ATTRIBUTE, CMS_PREVIEW_TARGET_ATTRIBUTE, CMS_PREVIEW_WRAPPER_ATTRIBUTE } from "./runtime/preview/protocol.js";
4
7
  import { toPreviewRenderDocument } from "./runtime/preview/comark-document.js";
5
8
  import { Predicate, Result, Schema } from "effect";
@@ -44,7 +47,6 @@ const INLINE_TAGS = /* @__PURE__ */ new Set([
44
47
  "strong",
45
48
  "u"
46
49
  ]);
47
- /** Projects private authoring identities into an ephemeral preview without mutating the canonical body. */
48
50
  function projectPreviewDocument(body, markers) {
49
51
  return Result.try({
50
52
  try: () => projectPreviewDocumentUnsafe(body, markers),
@@ -135,7 +137,7 @@ function hasInlineImplicitDefaultContent(nodes) {
135
137
 
136
138
  //#endregion
137
139
  //#region src/runtime/preview/store.ts
138
- function createStudioPreviewStore(route) {
140
+ function createStudioPreviewStore(route, forms = () => []) {
139
141
  const context = createComarkContext();
140
142
  const patches = shallowReactive(/* @__PURE__ */ new Map());
141
143
  const registrations = /* @__PURE__ */ new Map();
@@ -152,9 +154,12 @@ function createStudioPreviewStore(route) {
152
154
  manifest,
153
155
  async patch(document) {
154
156
  const preview = createPreviewDocument(document.body);
155
- const patched = Object.assign({}, document, { body: preview.body });
157
+ const patched = prepareFormDocument({
158
+ ...document,
159
+ body: preview.body
160
+ }, forms(), true);
156
161
  patches.set(document.id, patched);
157
- const renderBody = toPreviewRenderDocument(preview.body);
162
+ const renderBody = toPreviewRenderDocument(patched.body);
158
163
  context.get(document.id, renderBody).set(renderBody);
159
164
  notify();
160
165
  return preview.fallbacks;
@@ -218,4 +223,4 @@ function createPreviewDocument(body) {
218
223
 
219
224
  //#endregion
220
225
  export { createStudioPreviewStore as t };
221
- //# sourceMappingURL=store-Nl4uxEXx.js.map
226
+ //# sourceMappingURL=store-DjJs3I7k.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store-DjJs3I7k.js","names":["CmsMarkdownDocumentSchema"],"sources":["../../../../document/src/PreviewProjection.ts","../../../src/runtime/preview/store.ts"],"sourcesContent":["import type { CmsMarkdownDocument, MarkdownNode } from '@internal/protocol/Documents'\nimport type { EditorNodeId } from '@internal/protocol/Documents'\nimport { CmsMarkdownDocument as CmsMarkdownDocumentSchema } from '@internal/protocol/Documents'\nimport { Predicate, Result, Schema } from 'effect'\nimport { mutableJson, mutableJsonObject } from './internal/comark/document-adapter'\nimport { editorMetadata } from './internal/editor/metadata'\n\nexport interface PreviewProjectionMarkers {\n readonly inlineHostAttribute: string\n readonly markerTag: string\n readonly nodeAttribute: string\n readonly targetAttribute: string\n readonly wrapperAttribute: string\n}\n\nexport interface PreviewProjection {\n readonly body: CmsMarkdownDocument\n readonly fallbacks: Readonly<Record<string, string>>\n}\n\nexport class PreviewProjectionInvalid extends Schema.TaggedError<PreviewProjectionInvalid>()(\n 'PreviewProjection.Invalid',\n {\n message: Schema.NonEmptyString,\n cause: Schema.Defect(),\n },\n) {}\n\nconst NATIVE_BLOCK_TAGS = new Set([\n 'blockquote',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'hr',\n 'img',\n 'li',\n 'math',\n 'ol',\n 'p',\n 'pre',\n 'table',\n 'tbody',\n 'td',\n 'th',\n 'thead',\n 'tr',\n 'ul',\n])\n\nconst INLINE_TAGS = new Set(['a', 'br', 'code', 'del', 'em', 'img', 'strong', 'u'])\n\nexport function projectPreviewDocument(\n body: CmsMarkdownDocument,\n markers: PreviewProjectionMarkers,\n): Result.Result<PreviewProjection, PreviewProjectionInvalid> {\n return Result.try({\n try: () => projectPreviewDocumentUnsafe(body, markers),\n catch: (cause) =>\n new PreviewProjectionInvalid({\n cause,\n message: cause instanceof Error && cause.message ? cause.message : 'The preview projection is invalid.',\n }),\n })\n}\n\nfunction projectPreviewDocumentUnsafe(body: CmsMarkdownDocument, markers: PreviewProjectionMarkers): PreviewProjection {\n const fallbacks: Record<string, string> = {}\n let identifiedTargets = 0\n\n const cloneNodes = (nodes: ReadonlyArray<MarkdownNode>, componentId?: EditorNodeId): ReadonlyArray<Schema.Json> =>\n nodes.map((node) => {\n if (Predicate.isString(node) || node[0] === null) return mutableJson(node)\n const [tag, originalAttributes, ...originalChildren] = node\n const isSlot = tag === 'template'\n const isNative = NATIVE_BLOCK_TAGS.has(tag)\n const attributes = mutableJsonObject(originalAttributes)\n const metadata = editorMetadata(attributes)\n const id = metadata?.nodeId\n\n if (id) {\n identifiedTargets++\n\n if (componentId) fallbacks[id] = componentId\n\n if (!isSlot && !isNative) {\n attributes[markers.nodeAttribute] = id\n attributes[markers.targetAttribute] = 'component'\n }\n }\n\n const nextComponentId = !isNative && !isSlot && id ? id : componentId\n const children = [...cloneNodes(originalChildren, nextComponentId)]\n\n if (id && metadata?.implicitSlotId && !isNative && !isSlot && hasImplicitDefaultContent(originalChildren)) {\n const slotId = metadata.implicitSlotId\n fallbacks[slotId] = id\n const markerChildren = hasInlineImplicitDefaultContent(originalChildren) ? children.splice(0) : []\n\n const markerAttributes = {\n [markers.nodeAttribute]: slotId,\n [markers.targetAttribute]: 'slot',\n [markers.wrapperAttribute]: '',\n }\n\n if (markerChildren.length) markerAttributes[markers.inlineHostAttribute] = ''\n children.unshift([markers.markerTag, markerAttributes, ...markerChildren])\n }\n\n if (isSlot && id) {\n children.unshift([\n markers.markerTag,\n {\n [markers.nodeAttribute]: id,\n [markers.targetAttribute]: 'slot',\n [markers.wrapperAttribute]: '',\n },\n ])\n }\n\n const cloned: Schema.Json = [tag, attributes, ...children]\n\n if (id && isNative) return previewWrapper(id, 'native', cloned, markers)\n\n if (id && !isNative && !isSlot) return previewWrapper(id, 'component', cloned, markers)\n\n return cloned\n })\n\n const nodes = cloneNodes(body.nodes)\n\n if (body.nodes.length && !identifiedTargets)\n throw new Error('Studio preview requires an identified authoring document.')\n\n return {\n body: CmsMarkdownDocumentSchema.make({\n frontmatter: mutableJsonObject(body.frontmatter),\n meta: mutableJsonObject(body.meta),\n nodes,\n }),\n fallbacks,\n }\n}\n\nfunction previewWrapper(\n nodeId: EditorNodeId,\n kind: 'component' | 'native' | 'slot',\n child: Schema.Json,\n markers: PreviewProjectionMarkers,\n): Schema.Json {\n return [\n markers.markerTag,\n {\n [markers.nodeAttribute]: nodeId,\n [markers.targetAttribute]: kind,\n [markers.wrapperAttribute]: '',\n },\n child,\n ]\n}\n\nfunction hasImplicitDefaultContent(nodes: ReadonlyArray<MarkdownNode>): boolean {\n const hasExplicitDefault = nodes.some(\n (node) => Array.isArray(node) && node[0] === 'template' && node[1].name === 'default',\n )\n\n return (\n !hasExplicitDefault && nodes.some((node) => (Predicate.isString(node) ? Boolean(node) : node[0] !== 'template'))\n )\n}\n\nfunction hasInlineImplicitDefaultContent(nodes: ReadonlyArray<MarkdownNode>): boolean {\n return (\n nodes.length > 0 &&\n nodes.every(\n (node) => Predicate.isString(node) || (Array.isArray(node) && node[0] !== null && INLINE_TAGS.has(node[0])),\n )\n )\n}\n","import { prepareFormDocument } from '../forms/document'\nimport type { ComponentDefinition } from '@internal/protocol/Configuration'\nimport type { RenderedCompiledDocument, RenderedDocumentManifest } from '@internal/protocol/Preview'\nimport { projectPreviewDocument } from '@internal/document/PreviewProjection'\nimport { CollectionName } from '@internal/protocol/Configuration'\nimport { DocumentId, PublicPath } from '@internal/protocol/Documents'\nimport { Result } from 'effect'\nimport { createComarkContext } from 'comark'\nimport { shallowReactive } from 'vue'\nimport type { DeliveryDocument as PreviewCompiledDocument } from '../delivery/types'\nimport type { DocumentPreviewStore, PreviewDocumentRole } from '../delivery/preview'\nimport { toPreviewRenderDocument } from './comark-document'\nimport {\n CMS_PREVIEW_INLINE_HOST_ATTRIBUTE,\n CMS_PREVIEW_MARKER_TAG,\n CMS_PREVIEW_NODE_ATTRIBUTE,\n CMS_PREVIEW_TARGET_ATTRIBUTE,\n CMS_PREVIEW_WRAPPER_ATTRIBUTE,\n} from './protocol'\n\nexport { documentPreviewStoreKey, type DocumentPreviewStore, type PreviewDocumentRole } from '../delivery/preview'\n\nexport type { DeliveryDocument as PreviewCompiledDocument } from '../delivery/types'\n\nexport interface StudioPreviewStore extends DocumentPreviewStore {\n readonly manifest: () => RenderedDocumentManifest\n readonly patch: (document: PreviewCompiledDocument) => Promise<Readonly<Record<string, string>>>\n readonly routeChanged: () => void\n readonly subscribe: (listener: (manifest: RenderedDocumentManifest) => void) => () => void\n}\n\nexport function createStudioPreviewStore(\n route: () => RenderedDocumentManifest['route'],\n forms: () => ReadonlyArray<ComponentDefinition> = () => [],\n): StudioPreviewStore {\n const context = createComarkContext()\n const patches = shallowReactive(new Map<string, PreviewCompiledDocument>())\n\n const registrations = new Map<\n symbol,\n { readonly document: PreviewCompiledDocument; readonly role: PreviewDocumentRole }\n >()\n\n const listeners = new Set<(manifest: RenderedDocumentManifest) => void>()\n\n const manifest = (): RenderedDocumentManifest => ({\n documents: renderedDocuments(registrations.values(), patches),\n route: route(),\n })\n\n const notify = (): void => {\n const value = manifest()\n\n for (const listener of listeners) listener(value)\n }\n\n return {\n manifest,\n async patch(document) {\n const preview = createPreviewDocument(document.body)\n const patched = prepareFormDocument({ ...document, body: preview.body }, forms(), true)\n patches.set(document.id, patched)\n const renderBody = toPreviewRenderDocument(patched.body)\n context.get(document.id, renderBody).set(renderBody)\n notify()\n\n return preview.fallbacks\n },\n register(document, role) {\n const registration = Symbol(document.id)\n registrations.set(registration, { document, role })\n notify()\n\n return () => {\n registrations.delete(registration)\n notify()\n }\n },\n resolve(document) {\n return patches.get(document.id) ?? document\n },\n routeChanged: notify,\n subscribe(listener) {\n listeners.add(listener)\n listener(manifest())\n\n return () => listeners.delete(listener)\n },\n }\n}\n\nfunction renderedDocuments(\n registrations: Iterable<{ readonly document: PreviewCompiledDocument; readonly role: PreviewDocumentRole }>,\n patches: ReadonlyMap<string, PreviewCompiledDocument>,\n): ReadonlyArray<RenderedCompiledDocument> {\n const priority = { embedded: 1, primary: 4, related: 2, summary: 3 } satisfies Record<PreviewDocumentRole, number>\n const documents = new Map<string, RenderedCompiledDocument>()\n\n for (const registration of registrations) {\n const document = patches.get(registration.document.id) ?? registration.document\n const current = documents.get(document.id)\n\n if (current && priority[current.role] >= priority[registration.role]) continue\n documents.set(document.id, {\n collection: CollectionName.make(document.collection),\n documentId: DocumentId.make(document.id),\n path: PublicPath.make(document.path),\n role: registration.role,\n title: document.title,\n })\n }\n\n return [...documents.values()].sort(\n (left, right) => priority[right.role] - priority[left.role] || left.title.localeCompare(right.title),\n )\n}\n\nfunction createPreviewDocument(body: PreviewCompiledDocument['body']) {\n const projection = projectPreviewDocument(body, {\n inlineHostAttribute: CMS_PREVIEW_INLINE_HOST_ATTRIBUTE,\n markerTag: CMS_PREVIEW_MARKER_TAG,\n nodeAttribute: CMS_PREVIEW_NODE_ATTRIBUTE,\n targetAttribute: CMS_PREVIEW_TARGET_ATTRIBUTE,\n wrapperAttribute: CMS_PREVIEW_WRAPPER_ATTRIBUTE,\n })\n\n if (Result.isFailure(projection)) throw projection.failure\n\n return projection.success\n}\n"],"mappings":";;;;;;;;;;;;AAoBA,IAAa,2BAAb,cAA8C,OAAO,YAAsC,CAAC,CAC1F,6BACA;CACE,SAAS,OAAO;CAChB,OAAO,OAAO,OAAO;AACvB,CACF,CAAC,CAAC,CAAC;AAEH,MAAM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B,aAAa,UAAU,OAAO,QAAQ;EACxC;CACF;AACF;AAEA,SAAS,kBACP,eACA,SACyC;CACzC,MAAM,WAAW;EAAE,UAAU;EAAG,SAAS;EAAG,SAAS;EAAG,SAAS;CAAE;CACnE,MAAM,4BAAY,IAAI,IAAsC;CAE5D,KAAK,MAAM,gBAAgB,eAAe;EACxC,MAAM,WAAW,QAAQ,IAAI,aAAa,SAAS,EAAE,KAAK,aAAa;EACvE,MAAM,UAAU,UAAU,IAAI,SAAS,EAAE;EAEzC,IAAI,WAAW,SAAS,QAAQ,SAAS,SAAS,aAAa,OAAO;EACtE,UAAU,IAAI,SAAS,IAAI;GACzB,YAAY,eAAe,KAAK,SAAS,UAAU;GACnD,YAAY,WAAW,KAAK,SAAS,EAAE;GACvC,MAAM,WAAW,KAAK,SAAS,IAAI;GACnC,MAAM,aAAa;GACnB,OAAO,SAAS;EAClB,CAAC;CACH;CAEA,OAAO,CAAC,GAAG,UAAU,OAAO,CAAC,CAAC,CAAC,MAC5B,MAAM,UAAU,SAAS,MAAM,QAAQ,SAAS,KAAK,SAAS,KAAK,MAAM,cAAc,MAAM,KAAK,CACrG;AACF;AAEA,SAAS,sBAAsB,MAAuC;CACpE,MAAM,aAAa,uBAAuB,MAAM;EAC9C,qBAAqB;EACrB,WAAW;EACX,eAAe;EACf,iBAAiB;EACjB,kBAAkB;CACpB,CAAC;CAED,IAAI,OAAO,UAAU,UAAU,GAAG,MAAM,WAAW;CAEnD,OAAO,WAAW;AACpB"}
@@ -0,0 +1,256 @@
1
+ import { $ as e, $t as t, Ct as n, Ft as r, J as ee, K as i, Mt as a, Q as o, Tt as te, Z as s, an as c, et as l, it as u, ot as d, pt as f, sn as p, tt as m, un as h, zt as g } from "./editor-Bzlh3zXt.js";
2
+ import { A as _, F as v, I as y, N as b, P as x, R as S, a as ne, n as re, nr as C, pr as ie, r as ae, rr as oe, t as w } from "./documentPlanning-Bfv-d7OU.js";
3
+ //#region src/documents/CreateDocumentDialog.vue?vue&type=script&setup=true&lang.ts
4
+ var se = { key: 2 }, ce = { class: "grid grid-flow-col auto-cols-fr overflow-x-auto rounded-md border border-default" }, T = ["title", "onClick"], E = { class: "block truncate" }, le = {
5
+ key: 0,
6
+ class: "mt-2 flex min-w-0 items-center justify-between gap-3 text-xs text-muted"
7
+ }, D = { class: "truncate" }, O = { class: "shrink-0 font-mono text-[11px] text-dimmed" }, k = {
8
+ key: 5,
9
+ class: "flex min-w-0 items-center gap-3 rounded-md border border-default px-3 py-2"
10
+ }, ue = {
11
+ key: 6,
12
+ class: "-mt-2 text-xs text-error"
13
+ }, de = {
14
+ key: 7,
15
+ class: "-mt-2 text-xs text-error"
16
+ }, fe = { class: "flex w-full justify-end gap-2" }, A = "__top_level__", j = /* @__PURE__ */ d({
17
+ __name: "CreateDocumentDialog",
18
+ props: /*@__PURE__*/ f({
19
+ catalog: {},
20
+ context: {}
21
+ }, {
22
+ open: { type: Boolean },
23
+ openModifiers: {}
24
+ }),
25
+ emits: /*@__PURE__*/ f(["close"], ["update:open"]),
26
+ setup(d, { emit: f }) {
27
+ let j = f, M = a(d, "open"), N = b(), P = N.bootstrap.documents, F = P.types.filter((e) => e.canCreate), I = (P.locales?.locales ?? []).map((e) => ({
28
+ label: he(e),
29
+ value: String(e)
30
+ })), L = t(""), R = t(!1), z = t(""), B = t(""), V = t(!1), H = t(""), U = t(A), W = t(P.locales?.defaultLocale ?? ""), G = s(() => {
31
+ let e = F.map((e) => ({
32
+ collection: e.collection,
33
+ description: e.description,
34
+ key: `entry:${e.collection}`,
35
+ kind: "entry",
36
+ label: e.label,
37
+ type: e,
38
+ urlHint: e.addressPattern.replace(/:[a-z][\w.]*\*?/giu, "…")
39
+ }));
40
+ return [...F.filter((e) => e.addressPattern === "/:path*").slice(0, 1).flatMap((e) => {
41
+ let t = w(P, {
42
+ collection: e.collection,
43
+ locale: W.value || void 0,
44
+ location: { kind: "home" },
45
+ title: "Home"
46
+ });
47
+ return C(t) || d.catalog.entries.value.some((e) => e.document.path === t.success.path) ? [] : [{
48
+ collection: e.collection,
49
+ description: "The first document visitors see when they open the website.",
50
+ key: `home:${e.collection}`,
51
+ kind: "home",
52
+ label: "Home",
53
+ type: e,
54
+ urlHint: t.success.path
55
+ }];
56
+ }), ...e];
57
+ }), K = s(() => G.value.find((e) => e.key === H.value)), q = s(() => K.value?.kind === "home" ? { kind: "home" } : U.value === A ? {
58
+ kind: "entry",
59
+ slug: B.value
60
+ } : {
61
+ kind: "entry",
62
+ parent: U.value,
63
+ slug: B.value
64
+ }), J = s(() => {
65
+ let e = K.value;
66
+ if (!e || e.kind === "entry" && !B.value.trim()) return;
67
+ let t = {
68
+ collection: e.collection,
69
+ location: q.value,
70
+ title: z.value || "Untitled"
71
+ };
72
+ return w(P, W.value ? {
73
+ ...t,
74
+ locale: W.value
75
+ } : t);
76
+ }), Y = s(() => {
77
+ let e = J.value;
78
+ return e && oe(e) ? e.success : void 0;
79
+ }), X = s(() => {
80
+ let e = J.value;
81
+ return e && C(e) ? e.failure : "";
82
+ }), Z = s(() => Y.value && d.catalog.entries.value.some((e) => e.document.path === Y.value?.path)), pe = s(() => {
83
+ let e = K.value;
84
+ if (!e || e.kind === "home" || !e.type.hierarchy) return [];
85
+ let t = d.catalog.entries.value.flatMap((t) => {
86
+ if (t.document.collection !== e.collection || t.document.locale !== (W.value || void 0)) return [];
87
+ let n = ae(e.type, t);
88
+ return n ? [{
89
+ label: `${t.document.title} · /${n}`,
90
+ value: n
91
+ }] : [];
92
+ });
93
+ return d.context?.parent && !t.some((e) => e.value === d.context.parent) && t.push({
94
+ label: `/${d.context.parent}`,
95
+ value: d.context.parent
96
+ }), [{
97
+ label: "Top level",
98
+ value: A
99
+ }, ...t];
100
+ }), Q = s(() => !!z.value.trim() && !!K.value && !!Y.value && !Z.value);
101
+ r(z, (e) => {
102
+ V.value || (B.value = re(e));
103
+ }), r(H, () => U.value = A, { flush: "sync" }), r(W, () => {
104
+ U.value = A, K.value || (H.value = $());
105
+ }, { flush: "sync" }), r(M, (e) => {
106
+ e && (L.value = "", z.value = "", B.value = "", V.value = !1, W.value = d.context?.locale ?? P.locales?.defaultLocale ?? "", H.value = d.context?.collection ? `entry:${d.context.collection}` : $(), U.value = d.context?.parent || A, d.context?.slug && (B.value = d.context.slug, V.value = !0));
107
+ }, { immediate: !0 });
108
+ async function me() {
109
+ let e = K.value;
110
+ if (Q.value && e && !R.value) {
111
+ R.value = !0, L.value = "";
112
+ try {
113
+ let t = {
114
+ collection: e.collection,
115
+ location: q.value,
116
+ title: z.value
117
+ }, n = await N.gateway.documents.create(W.value ? {
118
+ ...t,
119
+ locale: W.value
120
+ } : t);
121
+ await d.catalog.refresh(!0);
122
+ let r = d.catalog.byId(n.documentId);
123
+ if (!r) throw Error("The page was created but could not be opened.");
124
+ j("close", r.document.id);
125
+ } catch (e) {
126
+ L.value = S(e);
127
+ } finally {
128
+ R.value = !1;
129
+ }
130
+ }
131
+ }
132
+ function $() {
133
+ return G.value[0]?.key ?? "";
134
+ }
135
+ function he(e) {
136
+ try {
137
+ return new Intl.DisplayNames(void 0, { type: "language" }).of(e) ?? e.toLocaleUpperCase();
138
+ } catch {
139
+ return e.toLocaleUpperCase();
140
+ }
141
+ }
142
+ return (t, r) => {
143
+ let a = y, s = x, d = v, f = ne, b = ie, S = _;
144
+ return n(), e(S, {
145
+ open: M.value,
146
+ "onUpdate:open": r[6] ||= (e) => M.value = e,
147
+ title: "New page",
148
+ description: "Add a document to your website.",
149
+ ui: { content: "max-w-lg" }
150
+ }, {
151
+ body: g(() => [o("form", {
152
+ id: "create-document-form",
153
+ class: "space-y-4",
154
+ onSubmit: i(me, ["prevent"])
155
+ }, [
156
+ L.value ? (n(), e(a, {
157
+ key: 0,
158
+ description: L.value,
159
+ color: "error",
160
+ variant: "subtle"
161
+ }, null, 8, ["description"])) : l("", !0),
162
+ G.value.length ? G.value.length > 1 ? (n(), m("fieldset", se, [
163
+ r[7] ||= o("legend", { class: "mb-2 text-sm font-medium text-highlighted" }, "Collection", -1),
164
+ o("div", ce, [(n(!0), m(ee, null, te(G.value, (e) => (n(), m("button", {
165
+ key: e.key,
166
+ type: "button",
167
+ title: e.description,
168
+ class: p(["min-w-28 border-l border-default px-3 py-2 text-center text-sm transition-colors first:border-l-0", e.key === H.value ? "bg-muted font-medium text-highlighted" : "bg-default text-muted hover:bg-muted/50 hover:text-highlighted"]),
169
+ onClick: (t) => H.value = e.key
170
+ }, [o("span", E, h(e.label), 1)], 10, T))), 128))]),
171
+ K.value ? (n(), m("div", le, [o("span", D, h(K.value.description), 1), o("code", O, h(K.value.urlHint), 1)])) : l("", !0)
172
+ ])) : l("", !0) : (n(), e(a, {
173
+ key: 1,
174
+ title: "Document creation is not configured",
175
+ description: "A developer needs to make at least one collection creatable in Studio.",
176
+ color: "warning",
177
+ variant: "subtle"
178
+ })),
179
+ K.value ? (n(), m("div", {
180
+ key: 3,
181
+ class: p(["grid gap-4", c(I).length ? "sm:grid-cols-[minmax(0,2fr)_minmax(9rem,1fr)]" : ""])
182
+ }, [u(d, {
183
+ label: "Title",
184
+ required: ""
185
+ }, {
186
+ default: g(() => [u(s, {
187
+ modelValue: z.value,
188
+ "onUpdate:modelValue": r[0] ||= (e) => z.value = e,
189
+ autofocus: "",
190
+ placeholder: "About us",
191
+ class: "w-full"
192
+ }, null, 8, ["modelValue"])]),
193
+ _: 1
194
+ }), c(I).length ? (n(), e(d, {
195
+ key: 0,
196
+ label: "Language"
197
+ }, {
198
+ default: g(() => [u(f, {
199
+ modelValue: W.value,
200
+ "onUpdate:modelValue": r[1] ||= (e) => W.value = e,
201
+ items: c(I),
202
+ "value-key": "value",
203
+ class: "w-full"
204
+ }, null, 8, ["modelValue", "items"])]),
205
+ _: 1
206
+ })) : l("", !0)], 2)) : l("", !0),
207
+ K.value?.kind === "entry" ? (n(), m("div", {
208
+ key: 4,
209
+ class: p(["grid gap-4", K.value.type.hierarchy ? "sm:grid-cols-2" : ""])
210
+ }, [K.value.type.hierarchy ? (n(), e(d, {
211
+ key: 0,
212
+ label: "Parent document"
213
+ }, {
214
+ default: g(() => [u(f, {
215
+ modelValue: U.value,
216
+ "onUpdate:modelValue": r[2] ||= (e) => U.value = e,
217
+ items: pe.value,
218
+ "value-key": "value",
219
+ class: "w-full"
220
+ }, null, 8, ["modelValue", "items"])]),
221
+ _: 1
222
+ })) : l("", !0), u(d, {
223
+ label: "URL ending",
224
+ required: ""
225
+ }, {
226
+ default: g(() => [u(s, {
227
+ modelValue: B.value,
228
+ "onUpdate:modelValue": [r[3] ||= (e) => B.value = e, r[4] ||= (e) => V.value = !0],
229
+ placeholder: "about-us",
230
+ class: "w-full"
231
+ }, null, 8, ["modelValue"])]),
232
+ _: 1
233
+ })], 2)) : l("", !0),
234
+ K.value ? (n(), m("div", k, [r[8] ||= o("span", { class: "shrink-0 text-xs text-muted" }, "URL", -1), o("p", { class: p(["min-w-0 flex-1 truncate text-right font-mono text-xs", Z.value ? "text-error" : "text-highlighted"]) }, h(Y.value?.path || K.value.urlHint), 3)])) : l("", !0),
235
+ Z.value ? (n(), m("p", ue, "This URL is already in use.")) : X.value ? (n(), m("p", de, h(X.value), 1)) : l("", !0)
236
+ ], 32)]),
237
+ footer: g(() => [o("div", fe, [u(b, {
238
+ color: "neutral",
239
+ variant: "ghost",
240
+ label: "Cancel",
241
+ onClick: r[5] ||= (e) => M.value = !1
242
+ }), u(b, {
243
+ type: "submit",
244
+ form: "create-document-form",
245
+ color: "neutral",
246
+ label: "Create page",
247
+ loading: R.value,
248
+ disabled: !Q.value
249
+ }, null, 8, ["loading", "disabled"])])]),
250
+ _: 1
251
+ }, 8, ["open"]);
252
+ };
253
+ }
254
+ });
255
+ //#endregion
256
+ export { j as default };