@bagelink/blox 1.15.174 → 1.15.178

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 (47) hide show
  1. package/dist/{PreviewApp-Dz003khp.cjs → PreviewApp-B8EmNfyH.cjs} +1 -1
  2. package/dist/{PreviewApp-CsC6qej1.js → PreviewApp-DdkAQqw2.js} +1 -1
  3. package/dist/{PreviewApp.vue_vue_type_style_index_0_lang-C1SwhjdY.js → PreviewApp.vue_vue_type_style_index_0_lang-1JKQVLm2.js} +1 -1
  4. package/dist/{PreviewApp.vue_vue_type_style_index_0_lang-BNKK7Vhs.cjs → PreviewApp.vue_vue_type_style_index_0_lang-CPBuld3j.cjs} +1 -1
  5. package/dist/components/BloxRouterView.vue.d.ts +18 -0
  6. package/dist/components/BloxRouterView.vue.d.ts.map +1 -0
  7. package/dist/composables/useData.d.ts +22 -0
  8. package/dist/composables/useData.d.ts.map +1 -0
  9. package/dist/composables/useLocaleNav.d.ts +8 -0
  10. package/dist/composables/useLocaleNav.d.ts.map +1 -1
  11. package/dist/composables/useSeo.d.ts +20 -0
  12. package/dist/composables/useSeo.d.ts.map +1 -0
  13. package/dist/content/ContentDetailHost.vue.d.ts +3 -0
  14. package/dist/content/ContentDetailHost.vue.d.ts.map +1 -0
  15. package/dist/content/defineContent.d.ts +22 -0
  16. package/dist/content/defineContent.d.ts.map +1 -0
  17. package/dist/content/useContentItem.d.ts +6 -0
  18. package/dist/content/useContentItem.d.ts.map +1 -0
  19. package/dist/content/useContentSeo.d.ts +10 -0
  20. package/dist/content/useContentSeo.d.ts.map +1 -0
  21. package/dist/{core-CbOrSpOU.js → core-Bp2bf8e4.js} +187 -33
  22. package/dist/{core-fPjj9xyJ.cjs → core-KRHc4Bob.cjs} +171 -17
  23. package/dist/core.d.ts.map +1 -1
  24. package/dist/index.cjs +121 -4
  25. package/dist/index.d.ts +12 -0
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.mjs +141 -23
  28. package/dist/{prerender-BLECK5o5.cjs → prerender-H72-UrK4.cjs} +11 -11
  29. package/dist/{prerender-CzpA4sYd.js → prerender-NHAqrTm3.js} +11 -11
  30. package/dist/routing/withLocaleRoutes.d.ts +8 -0
  31. package/dist/routing/withLocaleRoutes.d.ts.map +1 -0
  32. package/dist/ssg/cli.cjs +1 -1
  33. package/dist/ssg/cli.mjs +1 -1
  34. package/dist/ssg/client.cjs +4 -0
  35. package/dist/ssg/client.d.ts +1 -1
  36. package/dist/ssg/client.d.ts.map +1 -1
  37. package/dist/ssg/client.mjs +4 -0
  38. package/dist/ssg/constants.d.ts +4 -0
  39. package/dist/ssg/constants.d.ts.map +1 -1
  40. package/dist/ssg/index.cjs +18 -3
  41. package/dist/ssg/index.d.ts +1 -1
  42. package/dist/ssg/index.d.ts.map +1 -1
  43. package/dist/ssg/index.mjs +20 -5
  44. package/dist/ssg/render-resolved-page.d.ts.map +1 -1
  45. package/dist/ssg/seo.d.ts +7 -0
  46. package/dist/ssg/seo.d.ts.map +1 -1
  47. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const PreviewApp_vue_vue_type_style_index_0_lang = require("./PreviewApp.vue_vue_type_style_index_0_lang-BNKK7Vhs.cjs");
3
+ const PreviewApp_vue_vue_type_style_index_0_lang = require("./PreviewApp.vue_vue_type_style_index_0_lang-CPBuld3j.cjs");
4
4
  exports.default = PreviewApp_vue_vue_type_style_index_0_lang._sfc_main;
@@ -1,4 +1,4 @@
1
- import { _ as _sfc_main } from "./PreviewApp.vue_vue_type_style_index_0_lang-C1SwhjdY.js";
1
+ import { _ as _sfc_main } from "./PreviewApp.vue_vue_type_style_index_0_lang-1JKQVLm2.js";
2
2
  export {
3
3
  _sfc_main as default
4
4
  };
@@ -1,5 +1,5 @@
1
1
  import { defineComponent, inject, ref, h, provide, onMounted, onUnmounted, openBlock, createElementBlock, createVNode, unref, nextTick } from "vue";
2
- import { B as BLOX_REGISTRY_KEY, g as globalRefOf, G as GlobalBlockHost, u as useLocale } from "./core-CbOrSpOU.js";
2
+ import { B as BLOX_REGISTRY_KEY, g as globalRefOf, G as GlobalBlockHost, u as useLocale } from "./core-Bp2bf8e4.js";
3
3
  function sendToEditor(msg) {
4
4
  window.parent.postMessage(msg, "*");
5
5
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  const vue = require("vue");
3
- const core = require("./core-fPjj9xyJ.cjs");
3
+ const core = require("./core-KRHc4Bob.cjs");
4
4
  function sendToEditor(msg) {
5
5
  window.parent.postMessage(msg, "*");
6
6
  }
@@ -0,0 +1,18 @@
1
+ declare function __VLS_template(): {
2
+ attrs: Partial<{}>;
3
+ slots: {
4
+ fallback?(_: {}): any;
5
+ };
6
+ refs: {};
7
+ rootEl: any;
8
+ };
9
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
10
+ declare const __VLS_component: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
11
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
12
+ export default _default;
13
+ type __VLS_WithTemplateSlots<T, S> = T & {
14
+ new (): {
15
+ $slots: S;
16
+ };
17
+ };
18
+ //# sourceMappingURL=BloxRouterView.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BloxRouterView.vue.d.ts","sourceRoot":"","sources":["../../src/components/BloxRouterView.vue"],"names":[],"mappings":"AA4BA,iBAAS,cAAc;WAqDT,OAAO,IAA6B;;0BAVnB,GAAG;;;;EAejC;AAOD,KAAK,oBAAoB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAC9D,QAAA,MAAM,eAAe,+QAMnB,CAAC;wBACkB,uBAAuB,CAAC,OAAO,eAAe,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAAnG,wBAAoG;AAEpG,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IACxC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { MaybeRefOrGetter, Ref } from 'vue';
2
+ import { BLOX_DATA_WINDOW_KEY } from '../ssg/constants';
3
+ export { BLOX_DATA_WINDOW_KEY };
4
+ export interface UseDataOptions<T> {
5
+ default?: T | (() => T);
6
+ }
7
+ export interface UseDataResult<T> {
8
+ data: Ref<T>;
9
+ pending: Ref<boolean>;
10
+ error: Ref<Error | null>;
11
+ refresh: () => Promise<void>;
12
+ }
13
+ /**
14
+ * Unified async data loader for Blox marketing apps (Nuxt-like `useAsyncData`).
15
+ *
16
+ * - **SSR/SSG**: `onServerPrefetch` awaits the fetcher; results land in `globalThis.__BLOX_DATA__`
17
+ * and are embedded into the HTML by the SSG renderer.
18
+ * - **Client hydrate**: reads `window.__BLOX_DATA__[key]` synchronously (no refetch).
19
+ * - **SPA**: fetches on cache miss; re-runs when `key` changes.
20
+ */
21
+ export declare function useData<T>(key: MaybeRefOrGetter<string>, handler: () => Promise<T>, opts?: UseDataOptions<T>): UseDataResult<T>;
22
+ //# sourceMappingURL=useData.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useData.d.ts","sourceRoot":"","sources":["../../src/composables/useData.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,gBAAgB,EACrB,KAAK,GAAG,EAKR,MAAM,KAAK,CAAA;AACZ,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAEvD,OAAO,EAAE,oBAAoB,EAAE,CAAA;AAE/B,MAAM,WAAW,cAAc,CAAC,CAAC;IAChC,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAA;CACvB;AAED,MAAM,WAAW,aAAa,CAAC,CAAC;IAC/B,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,CAAA;IACZ,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;IACrB,KAAK,EAAE,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,CAAA;IACxB,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAC5B;AA0BD;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,CAAC,EACxB,GAAG,EAAE,gBAAgB,CAAC,MAAM,CAAC,EAC7B,OAAO,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACzB,IAAI,GAAE,cAAc,CAAC,CAAC,CAAM,GAC1B,aAAa,CAAC,CAAC,CAAC,CAuClB"}
@@ -5,10 +5,18 @@
5
5
  * using `currentAlternates[targetLocale]` when set (e.g. legal pages with
6
6
  * per-locale paths). Falls back to the current URL slug, then home.
7
7
  * - `toPath(slug)` — returns the locale-aware path for any slug.
8
+ * - `availableLocales` — locales this page can switch to (CMS alternates when
9
+ * set; otherwise all strategy locales).
10
+ * - `detect(path)` — strip locale prefix from a path → `{ locale, slug }`.
8
11
  */
9
12
  export declare function useLocaleNav(): {
10
13
  switchLocale: (targetLocale: string) => void;
11
14
  toPath: (slug: string) => string;
12
15
  locale: import('vue').Ref<string, string>;
16
+ availableLocales: import('vue').ComputedRef<string[]>;
17
+ detect: (path: string) => {
18
+ locale: string;
19
+ slug: string;
20
+ };
13
21
  };
14
22
  //# sourceMappingURL=useLocaleNav.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useLocaleNav.d.ts","sourceRoot":"","sources":["../../src/composables/useLocaleNav.ts"],"names":[],"mappings":"AAMA;;;;;;;GAOG;AACH,wBAAgB,YAAY;iCAKS,MAAM;mBAkBpB,MAAM,KAAG,MAAM;;EAQrC"}
1
+ {"version":3,"file":"useLocaleNav.d.ts","sourceRoot":"","sources":["../../src/composables/useLocaleNav.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY;iCAYS,MAAM;mBAkBpB,MAAM,KAAG,MAAM;;;mBAOf,MAAM;;;;EAO5B"}
@@ -0,0 +1,20 @@
1
+ import { MaybeRefOrGetter } from 'vue';
2
+ export interface SeoInput {
3
+ title?: string;
4
+ description?: string;
5
+ image?: string;
6
+ /** Bare default-locale paths per locale code (e.g. `{ en: '/legal/x', es: '/legal/y' }`). */
7
+ alternates?: Record<string, string>;
8
+ }
9
+ export type SeoGetter = MaybeRefOrGetter<SeoInput | null | undefined>;
10
+ /**
11
+ * Declare page SEO from a block / detail view.
12
+ *
13
+ * - **Client**: updates `document.title` + basic meta tags.
14
+ * - **SSR/SSG**: writes `globalThis.__BLOX_PAGE_SEO__` so the prerenderer can
15
+ * embed title/description/og/hreflang into `<head>`.
16
+ */
17
+ export declare function useSeo(getter: SeoGetter): void;
18
+ /** Read the SEO payload written by `useSeo` during the current SSR render. */
19
+ export declare function consumePageSeo(): SeoInput | null;
20
+ //# sourceMappingURL=useSeo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSeo.d.ts","sourceRoot":"","sources":["../../src/composables/useSeo.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,gBAAgB,EAMrB,MAAM,KAAK,CAAA;AAGZ,MAAM,WAAW,QAAQ;IACxB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,6FAA6F;IAC7F,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACnC;AAED,MAAM,MAAM,SAAS,GAAG,gBAAgB,CAAC,QAAQ,GAAG,IAAI,GAAG,SAAS,CAAC,CAAA;AA4CrE;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAuB9C;AAED,8EAA8E;AAC9E,wBAAgB,cAAc,IAAI,QAAQ,GAAG,IAAI,CAKhD"}
@@ -0,0 +1,3 @@
1
+ declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
2
+ export default _default;
3
+ //# sourceMappingURL=ContentDetailHost.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContentDetailHost.vue.d.ts","sourceRoot":"","sources":["../../src/content/ContentDetailHost.vue"],"names":[],"mappings":";AAoIA,wBAKG"}
@@ -0,0 +1,22 @@
1
+ import { Component } from 'vue';
2
+ import { Router } from 'vue-router';
3
+ export interface ContentRouteDef {
4
+ /** Stable vue-router name for default-locale links `{ name, params:{ slug } }`. */
5
+ name: string;
6
+ /** Datastore collection. */
7
+ collection: string;
8
+ /** Bare (default-locale) route pattern with a `:slug` param. */
9
+ route: string;
10
+ /** Optional detail component; falls back to a minimal placeholder. */
11
+ component?: Component;
12
+ }
13
+ /** Register data-powered detail collections (call once at app init, before createBloxApp). */
14
+ export declare function defineContent(defs: ContentRouteDef[]): void;
15
+ /** Snapshot of the content registry (used by prerender helpers / tests). */
16
+ export declare function contentRoutes(): readonly ContentRouteDef[];
17
+ /**
18
+ * Add locale-aware named routes for every `defineContent` entry.
19
+ * Must run **before** the CMS catch-all.
20
+ */
21
+ export declare function registerContentRoutesOnRouter(router: Router, locales: readonly string[], defaultLocale: string): void;
22
+ //# sourceMappingURL=defineContent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defineContent.d.ts","sourceRoot":"","sources":["../../src/content/defineContent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AACpC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAIxC,MAAM,WAAW,eAAe;IAC/B,mFAAmF;IACnF,IAAI,EAAE,MAAM,CAAA;IACZ,4BAA4B;IAC5B,UAAU,EAAE,MAAM,CAAA;IAClB,gEAAgE;IAChE,KAAK,EAAE,MAAM,CAAA;IACb,sEAAsE;IACtE,SAAS,CAAC,EAAE,SAAS,CAAA;CACrB;AAID,8FAA8F;AAC9F,wBAAgB,aAAa,CAAC,IAAI,EAAE,eAAe,EAAE,GAAG,IAAI,CAG3D;AAED,4EAA4E;AAC5E,wBAAgB,aAAa,IAAI,SAAS,eAAe,EAAE,CAE1D;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAC5C,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,aAAa,EAAE,MAAM,GACnB,IAAI,CAeN"}
@@ -0,0 +1,6 @@
1
+ import { InjectionKey, Ref } from 'vue';
2
+ export type ContentItem = Record<string, any>;
3
+ export declare const BLOX_CONTENT_ITEM_KEY: InjectionKey<Ref<ContentItem | null>>;
4
+ /** Active content-route entity (provided by `ContentDetailHost`). */
5
+ export declare function useContentItem<T extends ContentItem = ContentItem>(): Ref<T | null>;
6
+ //# sourceMappingURL=useContentItem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useContentItem.d.ts","sourceRoot":"","sources":["../../src/content/useContentItem.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAG5C,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AAE7C,eAAO,MAAM,qBAAqB,EAAE,YAAY,CAAC,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,CAA+B,CAAA;AAEvG,qEAAqE;AACrE,wBAAgB,cAAc,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,KAAK,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAEnF"}
@@ -0,0 +1,10 @@
1
+ import { Ref } from 'vue';
2
+ import { SeoGetter } from '../composables/useSeo';
3
+ import { ContentItem } from './useContentItem';
4
+ /**
5
+ * `useSeo` plus hreflang alternates from the entity's `available_locales`.
6
+ * Alternate values are the current bare path (locale prefix stripped); SSG
7
+ * head prefixes non-default locales with `/xx`.
8
+ */
9
+ export declare function useContentSeo(item: Ref<ContentItem | null | undefined>, getter: SeoGetter): void;
10
+ //# sourceMappingURL=useContentSeo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useContentSeo.d.ts","sourceRoot":"","sources":["../../src/content/useContentSeo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAG9B,OAAO,EAAU,KAAK,SAAS,EAAiB,MAAM,uBAAuB,CAAA;AAE7E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAEnD;;;;GAIG;AACH,wBAAgB,aAAa,CAC5B,IAAI,EAAE,GAAG,CAAC,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC,EACzC,MAAM,EAAE,SAAS,GACf,IAAI,CAqBN"}
@@ -1,8 +1,8 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import { BLOX_WEBSITE_ID_WINDOW_KEY, BLOX_STATE_WINDOW_KEY } from "./ssg/client.mjs";
5
- import { inject, computed, ref, defineComponent, onMounted, unref, openBlock, createBlock, Teleport, createElementBlock, createElementVNode, createCommentVNode, onUnmounted, watch, h, provide, resolveComponent, createVNode, toDisplayString, withCtx, createTextVNode, Fragment, useAttrs, mergeProps, renderSlot, normalizeProps } from "vue";
4
+ import { BLOX_WEBSITE_ID_WINDOW_KEY, BLOX_STATE_WINDOW_KEY, BLOX_DATA_WINDOW_KEY } from "./ssg/client.mjs";
5
+ import { inject, computed, ref, defineComponent, onMounted, unref, openBlock, createBlock, Teleport, createElementBlock, createElementVNode, createCommentVNode, onUnmounted, watch, h, provide, resolveComponent, createVNode, toDisplayString, withCtx, createTextVNode, Fragment, onServerPrefetch, toValue, useAttrs, mergeProps, renderSlot, normalizeProps, resolveDynamicComponent } from "vue";
6
6
  import { useRoute, useRouter, RouterLink } from "vue-router";
7
7
  import { getI18n, Loading } from "@bagelink/vue";
8
8
  const BASE = "/api";
@@ -115,11 +115,11 @@ function useBloxEdit(configOverride) {
115
115
  }
116
116
  return { config, enabled, showEdit, studioBaseUrl, editUrl, enable, dismiss, init };
117
117
  }
118
- const _hoisted_1$2 = {
118
+ const _hoisted_1$3 = {
119
119
  key: 0,
120
120
  class: "blox-admin-bar"
121
121
  };
122
- const _sfc_main$2 = /* @__PURE__ */ defineComponent({
122
+ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
123
123
  __name: "AdminEditBar",
124
124
  props: {
125
125
  websiteId: {},
@@ -138,7 +138,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
138
138
  key: 0,
139
139
  to: "body"
140
140
  }, [
141
- unref(showEdit) && __props.websiteId && __props.pageId ? (openBlock(), createElementBlock("div", _hoisted_1$2, [
141
+ unref(showEdit) && __props.websiteId && __props.pageId ? (openBlock(), createElementBlock("div", _hoisted_1$3, [
142
142
  createElementVNode("button", {
143
143
  type: "button",
144
144
  class: "blox-admin-btn",
@@ -260,11 +260,11 @@ const PageRenderer = defineComponent({
260
260
  }
261
261
  },
262
262
  setup(props) {
263
- const registry = inject(BLOX_REGISTRY_KEY, {});
263
+ const registry2 = inject(BLOX_REGISTRY_KEY, {});
264
264
  return () => h(
265
265
  "div",
266
266
  props.blocks.flatMap((block, i) => {
267
- const definition = registry[block.type];
267
+ const definition = registry2[block.type];
268
268
  if (!definition) return [];
269
269
  const ref2 = globalRefOf(block);
270
270
  if (ref2) {
@@ -283,7 +283,7 @@ const PageRenderer = defineComponent({
283
283
  );
284
284
  }
285
285
  });
286
- const _hoisted_1$1 = {
286
+ const _hoisted_1$2 = {
287
287
  key: 0,
288
288
  class: "blox-loading flex column h-100vh justify-content-center"
289
289
  };
@@ -299,7 +299,7 @@ const _hoisted_4 = {
299
299
  key: 0,
300
300
  class: "blox-nav-progress"
301
301
  };
302
- const _sfc_main$1 = /* @__PURE__ */ defineComponent({
302
+ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
303
303
  __name: "CmsPageView",
304
304
  setup(__props) {
305
305
  const route = useRoute();
@@ -399,7 +399,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
399
399
  return (_ctx, _cache) => {
400
400
  const _component_RouterLink = resolveComponent("RouterLink");
401
401
  return openBlock(), createElementBlock("div", null, [
402
- initialLoading.value && blocks.value.length === 0 ? (openBlock(), createElementBlock("div", _hoisted_1$1, [
402
+ initialLoading.value && blocks.value.length === 0 ? (openBlock(), createElementBlock("div", _hoisted_1$2, [
403
403
  createVNode(unref(Loading))
404
404
  ])) : notFound.value ? (openBlock(), createElementBlock("div", _hoisted_2$1, [
405
405
  _cache[0] || (_cache[0] = createElementVNode("h2", null, "404", -1)),
@@ -414,7 +414,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
414
414
  navigating.value ? (openBlock(), createElementBlock("div", _hoisted_4)) : createCommentVNode("", true),
415
415
  createVNode(unref(PageRenderer), { blocks: blocks.value }, null, 8, ["blocks"])
416
416
  ], 64)),
417
- unref(adminConfig) ? (openBlock(), createBlock(_sfc_main$2, {
417
+ unref(adminConfig) ? (openBlock(), createBlock(_sfc_main$3, {
418
418
  key: 4,
419
419
  "website-id": websiteId.value,
420
420
  "page-id": currentPageId.value
@@ -509,9 +509,80 @@ function installSmartLinks(router) {
509
509
  document.addEventListener("click", onClick);
510
510
  return () => document.removeEventListener("click", onClick);
511
511
  }
512
- const _hoisted_1 = ["href"];
512
+ function isServer() {
513
+ try {
514
+ if (false) ;
515
+ } catch {
516
+ }
517
+ return typeof window === "undefined";
518
+ }
519
+ function readPayload() {
520
+ const root = typeof window !== "undefined" ? window : globalThis;
521
+ const existing = root[BLOX_DATA_WINDOW_KEY];
522
+ if (existing && typeof existing === "object" && !Array.isArray(existing)) {
523
+ return existing;
524
+ }
525
+ const fresh = {};
526
+ root[BLOX_DATA_WINDOW_KEY] = fresh;
527
+ return fresh;
528
+ }
529
+ function resolveDefault(opts) {
530
+ if (typeof opts.default === "function") return opts.default();
531
+ return opts.default;
532
+ }
533
+ function useData(key, handler, opts = {}) {
534
+ const data = ref(resolveDefault(opts));
535
+ const pending = ref(false);
536
+ const error = ref(null);
537
+ async function refresh() {
538
+ const k = toValue(key);
539
+ pending.value = true;
540
+ error.value = null;
541
+ try {
542
+ const result = await handler();
543
+ data.value = result;
544
+ readPayload()[k] = result;
545
+ } catch (e) {
546
+ error.value = e instanceof Error ? e : new Error(String(e));
547
+ } finally {
548
+ pending.value = false;
549
+ }
550
+ }
551
+ function hydrateFromPayload() {
552
+ const k = toValue(key);
553
+ const payload = readPayload();
554
+ if (!Object.prototype.hasOwnProperty.call(payload, k)) return false;
555
+ data.value = payload[k];
556
+ return true;
557
+ }
558
+ if (isServer()) {
559
+ onServerPrefetch(() => refresh());
560
+ } else if (!hydrateFromPayload()) {
561
+ void refresh();
562
+ }
563
+ watch(() => toValue(key), () => {
564
+ if (!hydrateFromPayload()) void refresh();
565
+ });
566
+ return { data, pending, error, refresh };
567
+ }
568
+ function withLocaleRoutes(path, component, locales, defaultLocale) {
569
+ const normalized = path.startsWith("/") ? path : `/${path}`;
570
+ const others = locales.filter((l) => l && l !== defaultLocale);
571
+ const localePattern = others.join("|");
572
+ const routes = [
573
+ { path: normalized, component }
574
+ ];
575
+ if (localePattern) {
576
+ routes.push({
577
+ path: `/:locale(${localePattern})${normalized}`,
578
+ component
579
+ });
580
+ }
581
+ return routes;
582
+ }
583
+ const _hoisted_1$1 = ["href"];
513
584
  const _hoisted_2 = ["href"];
514
- const _sfc_main = /* @__PURE__ */ defineComponent({
585
+ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
515
586
  ...{ inheritAttrs: false },
516
587
  __name: "LocaleRouterLink",
517
588
  props: {
@@ -546,7 +617,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
546
617
  rel: "noopener noreferrer"
547
618
  }), [
548
619
  renderSlot(_ctx.$slots, "default")
549
- ], 16, _hoisted_1)) : resolved.value.kind === "special" ? (openBlock(), createElementBlock("a", mergeProps({ key: 1 }, unref(attrs), {
620
+ ], 16, _hoisted_1$1)) : resolved.value.kind === "special" ? (openBlock(), createElementBlock("a", mergeProps({ key: 1 }, unref(attrs), {
550
621
  href: resolved.value.href
551
622
  }), [
552
623
  renderSlot(_ctx.$slots, "default")
@@ -559,6 +630,77 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
559
630
  };
560
631
  }
561
632
  });
633
+ const BLOX_CONTENT_ITEM_KEY = Symbol("blox-content-item");
634
+ function useContentItem() {
635
+ return inject(BLOX_CONTENT_ITEM_KEY, null) ?? ref(null);
636
+ }
637
+ const _hoisted_1 = {
638
+ key: 1,
639
+ class: "blox-content-detail"
640
+ };
641
+ const _sfc_main = /* @__PURE__ */ defineComponent({
642
+ __name: "ContentDetailHost",
643
+ setup(__props) {
644
+ const route = useRoute();
645
+ const { locale: locale2 } = useLocale();
646
+ const def = computed(() => route.meta.contentDef);
647
+ const slug = computed(() => String(route.params.slug ?? ""));
648
+ const { data: item } = useData(
649
+ () => {
650
+ var _a;
651
+ return `content:${((_a = def.value) == null ? void 0 : _a.collection) ?? ""}:${slug.value}:${locale2.value}`;
652
+ },
653
+ async () => {
654
+ var _a, _b;
655
+ const collection = (_a = def.value) == null ? void 0 : _a.collection;
656
+ const s = slug.value;
657
+ if (!collection || !s) return null;
658
+ const escaped = s.replace(/"/g, '\\"');
659
+ const page = await listItems(collection, {
660
+ locale: locale2.value,
661
+ q: `slug eq "${escaped}"`,
662
+ limit: 1
663
+ });
664
+ return ((_b = page.items) == null ? void 0 : _b[0]) ?? null;
665
+ },
666
+ { default: null }
667
+ );
668
+ provide(BLOX_CONTENT_ITEM_KEY, item);
669
+ const Detail = computed(() => {
670
+ var _a;
671
+ return (_a = def.value) == null ? void 0 : _a.component;
672
+ });
673
+ return (_ctx, _cache) => {
674
+ return Detail.value ? (openBlock(), createBlock(resolveDynamicComponent(Detail.value), { key: 0 })) : unref(item) ? (openBlock(), createElementBlock("div", _hoisted_1, [
675
+ createElementVNode("pre", null, toDisplayString(unref(item)), 1)
676
+ ])) : createCommentVNode("", true);
677
+ };
678
+ }
679
+ });
680
+ const registry = [];
681
+ function defineContent(defs) {
682
+ registry.length = 0;
683
+ registry.push(...defs);
684
+ }
685
+ function contentRoutes() {
686
+ return registry;
687
+ }
688
+ function registerContentRoutesOnRouter(router, locales, defaultLocale) {
689
+ for (const def of registry) {
690
+ const routes = withLocaleRoutes(def.route, _sfc_main, locales, defaultLocale);
691
+ routes.forEach((r, i) => {
692
+ router.addRoute({
693
+ ...r,
694
+ // Only the default-locale path gets the stable name.
695
+ name: i === 0 ? def.name : void 0,
696
+ meta: {
697
+ ...r.meta ?? {},
698
+ contentDef: def
699
+ }
700
+ });
701
+ });
702
+ }
703
+ }
562
704
  function createPathStrategy(options) {
563
705
  const { defaultLocale, supportedLocales } = options;
564
706
  let _currentLocale = defaultLocale;
@@ -756,10 +898,15 @@ class BloxInstance {
756
898
  }
757
899
  router.addRoute({
758
900
  path: "/_blox_preview",
759
- component: () => import("./PreviewApp-CsC6qej1.js"),
901
+ component: () => import("./PreviewApp-DdkAQqw2.js"),
760
902
  beforeEnter: () => window.parent !== window ? true : "/"
761
903
  });
762
- router.addRoute({ path: "/:pathMatch(.*)*", component: _sfc_main$1 });
904
+ registerContentRoutesOnRouter(
905
+ router,
906
+ this._config.supportedLocales,
907
+ this._config.defaultLocale
908
+ );
909
+ router.addRoute({ path: "/:pathMatch(.*)*", component: _sfc_main$2 });
763
910
  this._routeRegistered = true;
764
911
  return this;
765
912
  }
@@ -790,7 +937,7 @@ class BloxInstance {
790
937
  app.provide(BLOX_CONFIG_KEY, this._config);
791
938
  app.provide(BLOX_LOCALE_STRATEGY_KEY, this._strategy);
792
939
  if (this._adminEdit) app.provide(BLOX_ADMIN_CONFIG_KEY, this._adminEdit);
793
- app._context.components.RouterLink = _sfc_main;
940
+ app._context.components.RouterLink = _sfc_main$1;
794
941
  }
795
942
  }
796
943
  function isBlockDefinition(value) {
@@ -807,31 +954,38 @@ function createBlox(options) {
807
954
  return instance;
808
955
  }
809
956
  export {
957
+ useBloxEdit as A,
810
958
  BLOX_REGISTRY_KEY as B,
959
+ useContentItem as C,
960
+ useData as D,
961
+ withLocaleRoutes as E,
811
962
  GlobalBlockHost as G,
812
963
  PageRenderer as P,
813
- _sfc_main$2 as _,
964
+ _sfc_main$3 as _,
814
965
  BLOX_LOCALE_STRATEGY_KEY as a,
815
966
  BLOX_ADMIN_CONFIG_KEY as b,
816
967
  createBlox as c,
817
968
  BLOX_CONFIG_KEY as d,
818
- BLOX_GLOBAL_RESOLVER_KEY as e,
819
- BloxInstance as f,
969
+ BLOX_CONTENT_ITEM_KEY as e,
970
+ BLOX_GLOBAL_RESOLVER_KEY as f,
820
971
  globalRefOf as g,
821
- _sfc_main$1 as h,
972
+ BloxInstance as h,
822
973
  installSmartLinks as i,
823
- GLOBAL_REF_KEY as j,
824
- classifyLink as k,
825
- configureApi as l,
826
- getWebsiteId as m,
974
+ _sfc_main$2 as j,
975
+ GLOBAL_REF_KEY as k,
976
+ _sfc_main$1 as l,
977
+ classifyLink as m,
827
978
  normalizeLink as n,
828
- getWebsiteIdSync as o,
829
- isAbsoluteExternal as p,
830
- isSpecialScheme as q,
831
- listItems as r,
832
- normalizeTo as s,
833
- resolvePath as t,
979
+ configureApi as o,
980
+ contentRoutes as p,
981
+ defineContent as q,
982
+ getWebsiteId as r,
983
+ getWebsiteIdSync as s,
984
+ isAbsoluteExternal as t,
834
985
  useLocale as u,
835
- toInternalPath as v,
836
- useBloxEdit as w
986
+ isSpecialScheme as v,
987
+ listItems as w,
988
+ normalizeTo as x,
989
+ resolvePath as y,
990
+ toInternalPath as z
837
991
  };