@conloca/cms-spa 0.2.2 → 0.2.4

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 (259) hide show
  1. package/README.md +26 -0
  2. package/dist/spa/main.css +229 -1
  3. package/dist/ts/.build-inputs.json +187 -0
  4. package/dist/ts/App.d.ts +5 -1
  5. package/dist/ts/App.d.ts.map +1 -1
  6. package/dist/ts/App.js +13 -6
  7. package/dist/ts/App.js.map +1 -1
  8. package/dist/ts/CmsSpaApp.d.ts.map +1 -1
  9. package/dist/ts/CmsSpaApp.js +4 -1
  10. package/dist/ts/CmsSpaApp.js.map +1 -1
  11. package/dist/ts/components/CMSDashboard.d.ts.map +1 -1
  12. package/dist/ts/components/CMSDashboard.js +2 -1
  13. package/dist/ts/components/CMSDashboard.js.map +1 -1
  14. package/dist/ts/components/cards/DataEntryCard.d.ts +1 -1
  15. package/dist/ts/components/cards/DataEntryCard.d.ts.map +1 -1
  16. package/dist/ts/components/cards/SectionCard.d.ts +1 -1
  17. package/dist/ts/components/cards/SectionCard.d.ts.map +1 -1
  18. package/dist/ts/components/dialogs/DeleteConfirmDialog.d.ts +6 -1
  19. package/dist/ts/components/dialogs/DeleteConfirmDialog.d.ts.map +1 -1
  20. package/dist/ts/components/dialogs/DeleteConfirmDialog.js +2 -2
  21. package/dist/ts/components/dialogs/DeleteConfirmDialog.js.map +1 -1
  22. package/dist/ts/components/dialogs/FragmentPropertiesDialog.d.ts +1 -1
  23. package/dist/ts/components/dialogs/FragmentPropertiesDialog.d.ts.map +1 -1
  24. package/dist/ts/components/dialogs/MakePagesEditableDialog.d.ts +10 -0
  25. package/dist/ts/components/dialogs/MakePagesEditableDialog.d.ts.map +1 -0
  26. package/dist/ts/components/dialogs/MakePagesEditableDialog.js +35 -0
  27. package/dist/ts/components/dialogs/MakePagesEditableDialog.js.map +1 -0
  28. package/dist/ts/components/dialogs/MoveFolderDialog.d.ts +6 -1
  29. package/dist/ts/components/dialogs/MoveFolderDialog.d.ts.map +1 -1
  30. package/dist/ts/components/dialogs/MoveFolderDialog.js +3 -3
  31. package/dist/ts/components/dialogs/MoveFolderDialog.js.map +1 -1
  32. package/dist/ts/components/editor/CMSMDXEditor.d.ts.map +1 -1
  33. package/dist/ts/components/editor/CMSMDXEditor.js +53 -62
  34. package/dist/ts/components/editor/CMSMDXEditor.js.map +1 -1
  35. package/dist/ts/components/editor/DocsPreviewButton.d.ts +6 -0
  36. package/dist/ts/components/editor/DocsPreviewButton.d.ts.map +1 -0
  37. package/dist/ts/components/editor/DocsPreviewButton.js +15 -0
  38. package/dist/ts/components/editor/DocsPreviewButton.js.map +1 -0
  39. package/dist/ts/components/editor/ImagePickerDialog.js +2 -2
  40. package/dist/ts/components/editor/ImagePickerDialog.js.map +1 -1
  41. package/dist/ts/components/editor/LocaleSelector.d.ts +1 -1
  42. package/dist/ts/components/editor/LocaleSelector.d.ts.map +1 -1
  43. package/dist/ts/components/editor/MdxPageEditor.d.ts.map +1 -1
  44. package/dist/ts/components/editor/MdxPageEditor.js +2 -1
  45. package/dist/ts/components/editor/MdxPageEditor.js.map +1 -1
  46. package/dist/ts/components/editor/PageEditor.d.ts +1 -1
  47. package/dist/ts/components/editor/PageEditor.d.ts.map +1 -1
  48. package/dist/ts/components/editor/PageEditor.js +47 -19
  49. package/dist/ts/components/editor/PageEditor.js.map +1 -1
  50. package/dist/ts/components/editor/PageEditorHeaderActions.d.ts +1 -1
  51. package/dist/ts/components/editor/PageEditorHeaderActions.d.ts.map +1 -1
  52. package/dist/ts/components/editor/PageEditorWrapper.js +31 -5
  53. package/dist/ts/components/editor/PageEditorWrapper.js.map +1 -1
  54. package/dist/ts/components/editor/draft-media-config.d.ts +32 -2
  55. package/dist/ts/components/editor/draft-media-config.d.ts.map +1 -1
  56. package/dist/ts/components/editor/draft-media-config.js +194 -39
  57. package/dist/ts/components/editor/draft-media-config.js.map +1 -1
  58. package/dist/ts/components/editor/page-setting-targets.d.ts +1 -1
  59. package/dist/ts/components/editor/page-setting-targets.d.ts.map +1 -1
  60. package/dist/ts/components/editor/preview-availability.d.ts +8 -5
  61. package/dist/ts/components/editor/preview-availability.d.ts.map +1 -1
  62. package/dist/ts/components/editor/preview-availability.js +8 -5
  63. package/dist/ts/components/editor/preview-availability.js.map +1 -1
  64. package/dist/ts/components/editors/DataEditor.d.ts +6 -2
  65. package/dist/ts/components/editors/DataEditor.d.ts.map +1 -1
  66. package/dist/ts/components/editors/DataEditor.js +46 -19
  67. package/dist/ts/components/editors/DataEditor.js.map +1 -1
  68. package/dist/ts/components/fields/ImageField.js +2 -2
  69. package/dist/ts/components/fields/ImageField.js.map +1 -1
  70. package/dist/ts/components/media/AssetCard.d.ts +1 -1
  71. package/dist/ts/components/media/AssetCard.d.ts.map +1 -1
  72. package/dist/ts/components/media/AssetCard.js +3 -2
  73. package/dist/ts/components/media/AssetCard.js.map +1 -1
  74. package/dist/ts/components/media/AssetDetailSidebar.d.ts +1 -1
  75. package/dist/ts/components/media/AssetDetailSidebar.d.ts.map +1 -1
  76. package/dist/ts/components/media/AssetDetailSidebar.js +7 -2
  77. package/dist/ts/components/media/AssetDetailSidebar.js.map +1 -1
  78. package/dist/ts/components/media/AssetUsageList.d.ts +13 -0
  79. package/dist/ts/components/media/AssetUsageList.d.ts.map +1 -0
  80. package/dist/ts/components/media/AssetUsageList.js +35 -0
  81. package/dist/ts/components/media/AssetUsageList.js.map +1 -0
  82. package/dist/ts/components/media/MediaLibrary.d.ts +1 -1
  83. package/dist/ts/components/media/MediaLibrary.d.ts.map +1 -1
  84. package/dist/ts/components/media/MediaLibrary.js +6 -4
  85. package/dist/ts/components/media/MediaLibrary.js.map +1 -1
  86. package/dist/ts/components/media/MediaToolbar.d.ts +1 -1
  87. package/dist/ts/components/media/MediaToolbar.d.ts.map +1 -1
  88. package/dist/ts/components/media/index.d.ts +1 -0
  89. package/dist/ts/components/media/index.d.ts.map +1 -1
  90. package/dist/ts/components/media/index.js +1 -0
  91. package/dist/ts/components/media/index.js.map +1 -1
  92. package/dist/ts/components/pages/DataList.d.ts.map +1 -1
  93. package/dist/ts/components/pages/DataList.js +48 -31
  94. package/dist/ts/components/pages/DataList.js.map +1 -1
  95. package/dist/ts/components/pages/MediaPage.d.ts.map +1 -1
  96. package/dist/ts/components/pages/MediaPage.js +7 -5
  97. package/dist/ts/components/pages/MediaPage.js.map +1 -1
  98. package/dist/ts/components/pages/NoPagesYet.d.ts +5 -0
  99. package/dist/ts/components/pages/NoPagesYet.d.ts.map +1 -0
  100. package/dist/ts/components/pages/NoPagesYet.js +16 -0
  101. package/dist/ts/components/pages/NoPagesYet.js.map +1 -0
  102. package/dist/ts/components/pages/PageList.d.ts.map +1 -1
  103. package/dist/ts/components/pages/PageList.js +19 -8
  104. package/dist/ts/components/pages/PageList.js.map +1 -1
  105. package/dist/ts/components/sandbox/ContentSandbox.d.ts +1 -1
  106. package/dist/ts/components/sandbox/ContentSandbox.d.ts.map +1 -1
  107. package/dist/ts/components/sandbox/ContentSandbox.js +36 -5
  108. package/dist/ts/components/sandbox/ContentSandbox.js.map +1 -1
  109. package/dist/ts/components/ui/IconButton.d.ts +1 -1
  110. package/dist/ts/components/ui/IconButton.d.ts.map +1 -1
  111. package/dist/ts/content-wrapper.d.ts +65 -0
  112. package/dist/ts/content-wrapper.d.ts.map +1 -0
  113. package/dist/ts/content-wrapper.js +190 -0
  114. package/dist/ts/content-wrapper.js.map +1 -0
  115. package/dist/ts/convert-pages.d.ts +30 -0
  116. package/dist/ts/convert-pages.d.ts.map +1 -0
  117. package/dist/ts/convert-pages.js +85 -0
  118. package/dist/ts/convert-pages.js.map +1 -0
  119. package/dist/ts/data-schemas.d.ts.map +1 -1
  120. package/dist/ts/frame/channel.d.ts +40 -0
  121. package/dist/ts/frame/channel.d.ts.map +1 -0
  122. package/dist/ts/frame/channel.js +233 -0
  123. package/dist/ts/frame/channel.js.map +1 -0
  124. package/dist/ts/frame/editor-frame.d.ts +23 -0
  125. package/dist/ts/frame/editor-frame.d.ts.map +1 -0
  126. package/dist/ts/frame/editor-frame.js +159 -0
  127. package/dist/ts/frame/editor-frame.js.map +1 -0
  128. package/dist/ts/frame/media-cache.d.ts +37 -0
  129. package/dist/ts/frame/media-cache.d.ts.map +1 -0
  130. package/dist/ts/frame/media-cache.js +138 -0
  131. package/dist/ts/frame/media-cache.js.map +1 -0
  132. package/dist/ts/frame/memory-router.d.ts +10 -0
  133. package/dist/ts/frame/memory-router.d.ts.map +1 -0
  134. package/dist/ts/frame/memory-router.js +39 -0
  135. package/dist/ts/frame/memory-router.js.map +1 -0
  136. package/dist/ts/frame/parent-hello.d.ts +11 -0
  137. package/dist/ts/frame/parent-hello.d.ts.map +1 -0
  138. package/dist/ts/frame/parent-hello.js +53 -0
  139. package/dist/ts/frame/parent-hello.js.map +1 -0
  140. package/dist/ts/frame/protocol.d.ts +209 -0
  141. package/dist/ts/frame/protocol.d.ts.map +1 -0
  142. package/dist/ts/frame/protocol.js +200 -0
  143. package/dist/ts/frame/protocol.js.map +1 -0
  144. package/dist/ts/frame/rpc-content-client.d.ts +10 -0
  145. package/dist/ts/frame/rpc-content-client.d.ts.map +1 -0
  146. package/dist/ts/frame/rpc-content-client.js +51 -0
  147. package/dist/ts/frame/rpc-content-client.js.map +1 -0
  148. package/dist/ts/frame/save-shortcut.d.ts +8 -0
  149. package/dist/ts/frame/save-shortcut.d.ts.map +1 -0
  150. package/dist/ts/frame/save-shortcut.js +26 -0
  151. package/dist/ts/frame/save-shortcut.js.map +1 -0
  152. package/dist/ts/hooks/index.d.ts +2 -0
  153. package/dist/ts/hooks/index.d.ts.map +1 -1
  154. package/dist/ts/hooks/index.js +1 -0
  155. package/dist/ts/hooks/index.js.map +1 -1
  156. package/dist/ts/hooks/usePageConversion.d.ts +11 -0
  157. package/dist/ts/hooks/usePageConversion.d.ts.map +1 -0
  158. package/dist/ts/hooks/usePageConversion.js +47 -0
  159. package/dist/ts/hooks/usePageConversion.js.map +1 -0
  160. package/dist/ts/hooks/useUploadFlow.d.ts.map +1 -1
  161. package/dist/ts/hooks/useUploadFlow.js +41 -7
  162. package/dist/ts/hooks/useUploadFlow.js.map +1 -1
  163. package/dist/ts/host-style-probe.d.ts +32 -37
  164. package/dist/ts/host-style-probe.d.ts.map +1 -1
  165. package/dist/ts/host-style-probe.js +86 -68
  166. package/dist/ts/host-style-probe.js.map +1 -1
  167. package/dist/ts/index.d.ts +6 -2
  168. package/dist/ts/index.d.ts.map +1 -1
  169. package/dist/ts/index.js +9 -2
  170. package/dist/ts/index.js.map +1 -1
  171. package/dist/ts/main-spa.d.ts.map +1 -1
  172. package/dist/ts/main-spa.js +2 -1
  173. package/dist/ts/main-spa.js.map +1 -1
  174. package/dist/ts/media/prepare-image-upload.d.ts +19 -0
  175. package/dist/ts/media/prepare-image-upload.d.ts.map +1 -0
  176. package/dist/ts/media/prepare-image-upload.js +93 -0
  177. package/dist/ts/media/prepare-image-upload.js.map +1 -0
  178. package/dist/ts/media/use-asset-serve-src.d.ts +7 -0
  179. package/dist/ts/media/use-asset-serve-src.d.ts.map +1 -0
  180. package/dist/ts/media/use-asset-serve-src.js +17 -0
  181. package/dist/ts/media/use-asset-serve-src.js.map +1 -0
  182. package/dist/ts/page-schemas.d.ts.map +1 -1
  183. package/dist/ts/prose-surface-css.d.ts +3 -5
  184. package/dist/ts/prose-surface-css.d.ts.map +1 -1
  185. package/dist/ts/prose-surface-css.js +3 -5
  186. package/dist/ts/prose-surface-css.js.map +1 -1
  187. package/dist/ts/puck-config.d.ts.map +1 -1
  188. package/dist/ts/selected-block.d.ts.map +1 -1
  189. package/dist/ts/site-styles.d.ts +4 -21
  190. package/dist/ts/site-styles.d.ts.map +1 -1
  191. package/dist/ts/site-styles.js.map +1 -1
  192. package/dist/ts/ui-config.d.ts +62 -3
  193. package/dist/ts/ui-config.d.ts.map +1 -1
  194. package/dist/ts/ui-config.js +18 -0
  195. package/dist/ts/ui-config.js.map +1 -1
  196. package/dist/ts/utils/asset-url.d.ts +3 -0
  197. package/dist/ts/utils/asset-url.d.ts.map +1 -1
  198. package/dist/ts/utils/asset-url.js +4 -0
  199. package/dist/ts/utils/asset-url.js.map +1 -1
  200. package/dist/ts/utils/data-entry-validation.d.ts +11 -0
  201. package/dist/ts/utils/data-entry-validation.d.ts.map +1 -0
  202. package/dist/ts/utils/data-entry-validation.js +15 -0
  203. package/dist/ts/utils/data-entry-validation.js.map +1 -0
  204. package/package.json +20 -11
  205. package/src/App.tsx +22 -10
  206. package/src/CmsSpaApp.tsx +5 -1
  207. package/src/components/CMSDashboard.tsx +16 -8
  208. package/src/components/dialogs/DeleteConfirmDialog.tsx +14 -1
  209. package/src/components/dialogs/MakePagesEditableDialog.tsx +112 -0
  210. package/src/components/dialogs/MoveFolderDialog.tsx +9 -2
  211. package/src/components/editor/CMSMDXEditor.tsx +56 -76
  212. package/src/components/editor/DocsPreviewButton.tsx +25 -0
  213. package/src/components/editor/ImagePickerDialog.tsx +2 -2
  214. package/src/components/editor/MdxPageEditor.tsx +2 -0
  215. package/src/components/editor/PageEditor.tsx +46 -22
  216. package/src/components/editor/PageEditorWrapper.tsx +34 -5
  217. package/src/components/editor/draft-media-config.ts +199 -41
  218. package/src/components/editor/preview-availability.ts +9 -5
  219. package/src/components/editors/DataEditor.tsx +65 -32
  220. package/src/components/fields/ImageField.tsx +2 -2
  221. package/src/components/media/AssetCard.tsx +12 -9
  222. package/src/components/media/AssetDetailSidebar.tsx +38 -25
  223. package/src/components/media/AssetUsageList.tsx +84 -0
  224. package/src/components/media/MediaLibrary.tsx +6 -4
  225. package/src/components/media/index.ts +1 -0
  226. package/src/components/pages/DataList.tsx +53 -29
  227. package/src/components/pages/MediaPage.tsx +14 -5
  228. package/src/components/pages/NoPagesYet.tsx +41 -0
  229. package/src/components/pages/PageList.tsx +40 -27
  230. package/src/components/sandbox/ContentSandbox.tsx +34 -5
  231. package/src/content-wrapper.ts +284 -0
  232. package/src/convert-pages.ts +110 -0
  233. package/src/frame/channel.ts +258 -0
  234. package/src/frame/editor-frame.ts +184 -0
  235. package/src/frame/media-cache.ts +157 -0
  236. package/src/frame/memory-router.ts +39 -0
  237. package/src/frame/parent-hello.ts +62 -0
  238. package/src/frame/protocol.ts +332 -0
  239. package/src/frame/rpc-content-client.ts +58 -0
  240. package/src/frame/save-shortcut.ts +25 -0
  241. package/src/hooks/index.ts +2 -0
  242. package/src/hooks/usePageConversion.ts +55 -0
  243. package/src/hooks/useUploadFlow.ts +44 -7
  244. package/src/host-style-probe.ts +104 -90
  245. package/src/index.ts +10 -2
  246. package/src/main-spa.tsx +2 -0
  247. package/src/main.css +2 -1
  248. package/src/media/prepare-image-upload.ts +118 -0
  249. package/src/media/use-asset-serve-src.ts +22 -0
  250. package/src/prose-surface-css.ts +3 -5
  251. package/src/site-styles.ts +4 -22
  252. package/src/ui-config.ts +74 -3
  253. package/src/utils/asset-url.ts +6 -0
  254. package/src/utils/data-entry-validation.ts +16 -0
  255. package/dist/ts/host-discovery.d.ts +0 -40
  256. package/dist/ts/host-discovery.d.ts.map +0 -1
  257. package/dist/ts/host-discovery.js +0 -39
  258. package/dist/ts/host-discovery.js.map +0 -1
  259. package/src/host-discovery.ts +0 -77
package/src/ui-config.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  /* oxlint-disable no-underscore-dangle -- __UI_CONFIG__ is the existing browser-global compatibility contract read by embedded hosts. */
2
2
  import type { ContentAPIClient, EditorDataBindings } from '@conloca/content-api-client';
3
3
  import type { QueryClientConfig } from '@tanstack/react-query';
4
+ import type { PageConversionFacts } from './convert-pages.js';
5
+ import type { MediaLoadInput, PreviewOpenResult } from './frame/protocol.js';
4
6
  import type { MediaBridge } from './media/types.js';
5
7
 
6
8
  export interface TemplateConfig {
@@ -136,8 +138,6 @@ export interface UIConfig {
136
138
  * literal default.
137
139
  */
138
140
  assetsBasePath?: string;
139
- /** Draft-image render base; render URLs must never replace canonical saved asset refs. */
140
- draftAssetsBasePath?: string;
141
141
  /**
142
142
  * Base the STORED asset reference is built on (`buildAssetRef(folder,
143
143
  * filename)`) — the sibling of `assetsBasePath`, and deliberately a
@@ -161,7 +161,20 @@ export interface UIConfig {
161
161
  * about that site — not a failure of the call. The two must
162
162
  * stay distinguishable: one is the site's setup, the other is a fault.
163
163
  */
164
- openPreview?: (input: { path: string }) => Promise<OpenPreviewResult>;
164
+ openPreview?: (input: { path: string }) => Promise<OpenPreviewResult | PreviewOpenResult>;
165
+ /**
166
+ * Who opens the preview tab. Default `'editor'`. With `'parent'` the parent
167
+ * frame opens the tab during the click, so the editor opens none and only
168
+ * asks through `openPreview`.
169
+ */
170
+ previewTab?: 'editor' | 'parent';
171
+ /**
172
+ * Opens the published page at `path` from outside the editor frame, so the
173
+ * tab is not born inside a sandboxed frame. Without it the editor keeps
174
+ * `window.open`. Whoever opens the tab explains a blocked popup, so the
175
+ * editor only waits for the request to settle.
176
+ */
177
+ openSiteUrl?: (input: { path: string }) => Promise<void>;
165
178
  /**
166
179
  * Whether the site actually serves draft preview.
167
180
  * `'unknown'` (the default) means not established yet and the editor leaves
@@ -181,6 +194,50 @@ export interface UIConfig {
181
194
  * is refused with {@link EditorWriteRefusal.reason}.
182
195
  */
183
196
  readOnly?: EditorWriteRefusal;
197
+ /**
198
+ * Path the MDX sandbox frame loads from. An editor page that ships its own
199
+ * static copy of the frame sets it; default `SANDBOX_FRAME_PATH`.
200
+ */
201
+ sandboxFramePath?: string;
202
+ /**
203
+ * The site's `editorCSS` text, appended after the MDX canvas styles so it
204
+ * wins. An editor page that loads it at run time sets it; otherwise the
205
+ * build's copy applies.
206
+ */
207
+ editorCss?: string;
208
+ /**
209
+ * Loads the bytes of a media file. When set, media surfaces never hand media
210
+ * URLs to `<img>`; they show object URLs of the loaded bytes. Draft addresses
211
+ * (`/api/v1/assets/serve/<path>`) load through it from `serve` and show a
212
+ * transparent placeholder until their bytes arrive.
213
+ */
214
+ loadMedia?: (input: MediaLoadInput) => Promise<Blob>;
215
+ /**
216
+ * Set by a parent frame: the editor routes in memory and reports each route
217
+ * to it. It also marks the editor as running in a parent frame, where the
218
+ * dev-server endpoints do not exist.
219
+ */
220
+ memoryRouter?: MemoryRouterConfig;
221
+ /**
222
+ * Set by the workspace editor around the framed editor or by the local
223
+ * integration; absent means the editor does not offer page conversion.
224
+ */
225
+ pageConversion?: PageConversionFacts;
226
+ }
227
+
228
+ /** How the editor routes when a parent frame owns the address bar. */
229
+ export interface MemoryRouterConfig {
230
+ /** The editor route to open first, `pathname + search`. */
231
+ initialPath: string;
232
+ /** Called with each route the editor commits, `pathname + search`. */
233
+ onNavigate(path: string, replace: boolean): void;
234
+ /** Listens for routes the parent asks for; returns the function that stops listening. */
235
+ subscribe(navigate: (path: string) => void): () => void;
236
+ }
237
+
238
+ /** Whether the editor runs inside a parent frame (see `UIConfig.memoryRouter`). */
239
+ export function inEditorFrame(config: UIConfig = getUIConfig()): boolean {
240
+ return config.memoryRouter !== undefined;
184
241
  }
185
242
 
186
243
  const defaultConfig: UIConfig = {
@@ -206,6 +263,9 @@ declare global {
206
263
 
207
264
  let config: UIConfig = { ...defaultConfig };
208
265
 
266
+ /** Fired on window when a parent frame changes `readOnly` or `pageConversion` after `configureUI`. */
267
+ export const EDITOR_CONFIG_CHANGED_EVENT = 'conloca:editor-config-changed';
268
+
209
269
  export function configureUI(options: Partial<UIConfig>) {
210
270
  // `readOnly` survives a reinstall unless the caller states a new answer.
211
271
  //
@@ -243,6 +303,17 @@ export function setEditorReadOnly(readOnly: EditorWriteRefusal | null) {
243
303
  // The runtime mirror `getUIConfig` reads from.
244
304
  const runtimeConfig = window.__UI_CONFIG__;
245
305
  if (runtimeConfig) runtimeConfig.readOnly = next;
306
+ window.dispatchEvent(new Event(EDITOR_CONFIG_CHANGED_EVENT));
307
+ }
308
+
309
+ /** Install (or clear, with `null`) the page conversion facts after `configureUI`, like {@link setEditorReadOnly}. */
310
+ export function setPageConversion(facts: PageConversionFacts | null) {
311
+ const next = facts ?? undefined;
312
+ config.pageConversion = next;
313
+ if (typeof window === 'undefined') return;
314
+ const runtimeConfig = window.__UI_CONFIG__;
315
+ if (runtimeConfig) runtimeConfig.pageConversion = next;
316
+ window.dispatchEvent(new Event(EDITOR_CONFIG_CHANGED_EVENT));
246
317
  }
247
318
 
248
319
  /**
@@ -1,3 +1,4 @@
1
+ import type { AssetEntry } from '@conloca/content-api-client';
1
2
  import { getUIConfig } from '../ui-config.js';
2
3
 
3
4
  /** An asset path relative to the media root; this is the identity accepted by asset routes. */
@@ -28,3 +29,8 @@ export function buildAssetServeUrl(basePath: string, folder: string | undefined,
28
29
  export function buildAssetRef(folder: string | undefined, filename: string): string {
29
30
  return buildAssetServeUrl(getUIConfig().assetRefBase ?? '/assets', folder, filename);
30
31
  }
32
+
33
+ /** The link a pick of `asset` stores: the one the server gave it, else the site link `buildAssetRef` builds. */
34
+ export function assetRefOf(asset: Pick<AssetEntry, 'folder' | 'filename' | 'ref'>): string {
35
+ return asset.ref ?? buildAssetRef(asset.folder, asset.filename);
36
+ }
@@ -0,0 +1,16 @@
1
+ import type { DataCollectionEntry } from '@conloca/content-api-client';
2
+ import type { HostSchema } from '../host-schema.js';
3
+
4
+ /**
5
+ * Why the build would reject `values` as a data entry of `schema`, or null when it accepts them.
6
+ *
7
+ * Only the verdict is read: a pruning validator (`typia.plain.createValidatePrune`) drops undeclared
8
+ * keys from what it validates, so it gets a copy and the caller stores `values` as they are, keys
9
+ * written outside the form included.
10
+ */
11
+ export function validateEntryData(schema: HostSchema, values: DataCollectionEntry['data']): string | null {
12
+ const result = schema.validate(structuredClone(values));
13
+ if (result.success) return null;
14
+ const fields = result.errors.map((error) => `${error.path.replace(/^\$input\./, '')} (expected ${error.expected})`);
15
+ return `Fix these fields before saving: ${fields.join(', ')}`;
16
+ }
@@ -1,40 +0,0 @@
1
- import type { HostWrappers } from './site-styles.js';
2
- /**
3
- * Registered style-discovery results, written by a host app that embeds the
4
- * editor and read by the MDX editor.
5
- *
6
- * The astro-cms dev server discovers the same facts at runtime
7
- * (`/api/styles`, `/api/content-wrapper`, the computed-style probe); those
8
- * mechanisms need a Vite graph and a same-origin page, which an editor served
9
- * from another origin does not have. A host app that learns the same facts
10
- * some other way writes them into this registry — the editor's consumption
11
- * chain then treats them as the same tier, one layer below live discovery.
12
- *
13
- * astro-cms never writes this, so the chain simply skips it there.
14
- */
15
- export interface HostDiscovery {
16
- /** The discovery route's collected CSS. */
17
- routeCss?: string;
18
- /** The discovery route's content-wrapper shape, same contract as the endpoint's. */
19
- wrappers?: HostWrappers;
20
- }
21
- interface DiscoveryState {
22
- value: HostDiscovery;
23
- subscribers: Set<(value: HostDiscovery) => void>;
24
- }
25
- declare global {
26
- interface Window {
27
- __HOST_DISCOVERY_STATE__?: DiscoveryState;
28
- }
29
- }
30
- /**
31
- * Replace the registered discovery wholesale. Wholesale on purpose: the
32
- * registry is process-global, so a switch to another site that carried only
33
- * SOME fields forward would leak the previous site's wrapper or CSS into the new
34
- * one — the same clear-semantics `setSiteStyles([])` has.
35
- */
36
- export declare function setHostDiscovery(value: HostDiscovery): void;
37
- export declare function getHostDiscovery(): HostDiscovery;
38
- export declare function useHostDiscovery(): HostDiscovery;
39
- export {};
40
- //# sourceMappingURL=host-discovery.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"host-discovery.d.ts","sourceRoot":"","sources":["../../src/host-discovery.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD;;;;;;;;;;;;GAYG;AAEH,MAAM,WAAW,aAAa;IAC5B,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oFAAoF;IACpF,QAAQ,CAAC,EAAE,YAAY,CAAC;CACzB;AAED,UAAU,cAAc;IACtB,KAAK,EAAE,aAAa,CAAC;IACrB,WAAW,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC,CAAC;CAClD;AAED,OAAO,CAAC,MAAM,CAAC,CAAC;IACd,UAAU,MAAM;QACd,wBAAwB,CAAC,EAAE,cAAc,CAAC;KAC3C;CACF;AAYD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAM3D;AAED,wBAAgB,gBAAgB,IAAI,aAAa,CAEhD;AAED,wBAAgB,gBAAgB,IAAI,aAAa,CAahD"}
@@ -1,39 +0,0 @@
1
- import { useEffect, useState } from 'react';
2
- const getState = () => {
3
- if (typeof window !== 'undefined') {
4
- if (!window.__HOST_DISCOVERY_STATE__) {
5
- window.__HOST_DISCOVERY_STATE__ = { value: {}, subscribers: new Set() };
6
- }
7
- return window.__HOST_DISCOVERY_STATE__;
8
- }
9
- return { value: {}, subscribers: new Set() };
10
- };
11
- /**
12
- * Replace the registered discovery wholesale. Wholesale on purpose: the
13
- * registry is process-global, so a switch to another site that carried only
14
- * SOME fields forward would leak the previous site's wrapper or CSS into the new
15
- * one — the same clear-semantics `setSiteStyles([])` has.
16
- */
17
- export function setHostDiscovery(value) {
18
- const state = getState();
19
- state.value = value;
20
- state.subscribers.forEach((fn) => {
21
- fn(value);
22
- });
23
- }
24
- export function getHostDiscovery() {
25
- return getState().value;
26
- }
27
- export function useHostDiscovery() {
28
- const [value, setValue] = useState(() => getState().value);
29
- useEffect(() => {
30
- const state = getState();
31
- setValue((current) => (state.value === current ? current : state.value));
32
- state.subscribers.add(setValue);
33
- return () => {
34
- state.subscribers.delete(setValue);
35
- };
36
- }, []);
37
- return value;
38
- }
39
- //# sourceMappingURL=host-discovery.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"host-discovery.js","sourceRoot":"","sources":["../../src/host-discovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAmC5C,MAAM,QAAQ,GAAG,GAAmB,EAAE;IACpC,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QAClC,IAAI,CAAC,MAAM,CAAC,wBAAwB,EAAE,CAAC;YACrC,MAAM,CAAC,wBAAwB,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,WAAW,EAAE,IAAI,GAAG,EAAE,EAAE,CAAC;QAC1E,CAAC;QACD,OAAO,MAAM,CAAC,wBAAwB,CAAC;IACzC,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,WAAW,EAAE,IAAI,GAAG,EAAE,EAAE,CAAC;AAC/C,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAoB;IACnD,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;IACzB,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC;IACpB,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE;QAC/B,EAAE,CAAC,KAAK,CAAC,CAAC;IACZ,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,OAAO,QAAQ,EAAE,CAAC,KAAK,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,CAAC;IAE3D,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;QACzB,QAAQ,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;QACzE,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAChC,OAAO,GAAG,EAAE;YACV,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACrC,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -1,77 +0,0 @@
1
- import { useEffect, useState } from 'react';
2
- import type { HostWrappers } from './site-styles.js';
3
-
4
- /**
5
- * Registered style-discovery results, written by a host app that embeds the
6
- * editor and read by the MDX editor.
7
- *
8
- * The astro-cms dev server discovers the same facts at runtime
9
- * (`/api/styles`, `/api/content-wrapper`, the computed-style probe); those
10
- * mechanisms need a Vite graph and a same-origin page, which an editor served
11
- * from another origin does not have. A host app that learns the same facts
12
- * some other way writes them into this registry — the editor's consumption
13
- * chain then treats them as the same tier, one layer below live discovery.
14
- *
15
- * astro-cms never writes this, so the chain simply skips it there.
16
- */
17
-
18
- export interface HostDiscovery {
19
- /** The discovery route's collected CSS. */
20
- routeCss?: string;
21
- /** The discovery route's content-wrapper shape, same contract as the endpoint's. */
22
- wrappers?: HostWrappers;
23
- }
24
-
25
- interface DiscoveryState {
26
- value: HostDiscovery;
27
- subscribers: Set<(value: HostDiscovery) => void>;
28
- }
29
-
30
- declare global {
31
- interface Window {
32
- __HOST_DISCOVERY_STATE__?: DiscoveryState;
33
- }
34
- }
35
-
36
- const getState = (): DiscoveryState => {
37
- if (typeof window !== 'undefined') {
38
- if (!window.__HOST_DISCOVERY_STATE__) {
39
- window.__HOST_DISCOVERY_STATE__ = { value: {}, subscribers: new Set() };
40
- }
41
- return window.__HOST_DISCOVERY_STATE__;
42
- }
43
- return { value: {}, subscribers: new Set() };
44
- };
45
-
46
- /**
47
- * Replace the registered discovery wholesale. Wholesale on purpose: the
48
- * registry is process-global, so a switch to another site that carried only
49
- * SOME fields forward would leak the previous site's wrapper or CSS into the new
50
- * one — the same clear-semantics `setSiteStyles([])` has.
51
- */
52
- export function setHostDiscovery(value: HostDiscovery): void {
53
- const state = getState();
54
- state.value = value;
55
- state.subscribers.forEach((fn) => {
56
- fn(value);
57
- });
58
- }
59
-
60
- export function getHostDiscovery(): HostDiscovery {
61
- return getState().value;
62
- }
63
-
64
- export function useHostDiscovery(): HostDiscovery {
65
- const [value, setValue] = useState(() => getState().value);
66
-
67
- useEffect(() => {
68
- const state = getState();
69
- setValue((current) => (state.value === current ? current : state.value));
70
- state.subscribers.add(setValue);
71
- return () => {
72
- state.subscribers.delete(setValue);
73
- };
74
- }, []);
75
-
76
- return value;
77
- }