@bagelink/blox 1.12.22 → 1.12.23

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 (59) hide show
  1. package/dist/CmsPageView.vue.d.ts.map +1 -1
  2. package/dist/PreviewApp-C2T03Jm9.cjs +4 -0
  3. package/dist/PreviewApp-CmThrLvv.js +4 -0
  4. package/dist/PreviewApp.vue.d.ts.map +1 -1
  5. package/dist/PreviewApp.vue_vue_type_style_index_0_lang-B0N5QbfS.js +157 -0
  6. package/dist/PreviewApp.vue_vue_type_style_index_0_lang-BTuE4GmT.cjs +156 -0
  7. package/dist/api/index.d.ts.map +1 -1
  8. package/dist/bridge.d.ts +1 -0
  9. package/dist/bridge.d.ts.map +1 -1
  10. package/dist/core-C3Iu5qa2.js +460 -0
  11. package/dist/core-_fnHoEZN.cjs +459 -0
  12. package/dist/core.d.ts.map +1 -1
  13. package/dist/createBloxApp.d.ts +107 -0
  14. package/dist/createBloxApp.d.ts.map +1 -0
  15. package/dist/defineBlock.d.ts +2 -0
  16. package/dist/defineBlock.d.ts.map +1 -1
  17. package/dist/index.cjs +79 -585
  18. package/dist/index.d.ts +2 -0
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.mjs +78 -583
  21. package/dist/{prerender-6jE_obPj.cjs → prerender-Bi7YtzSp.cjs} +246 -6
  22. package/dist/prerender-D3Q4jKXm.js +522 -0
  23. package/dist/schema.d.ts +2 -0
  24. package/dist/schema.d.ts.map +1 -1
  25. package/dist/ssg/cli.cjs +48 -5
  26. package/dist/ssg/cli.mjs +48 -5
  27. package/dist/ssg/client.cjs +50 -3
  28. package/dist/ssg/client.d.ts +2 -1
  29. package/dist/ssg/client.d.ts.map +1 -1
  30. package/dist/ssg/client.mjs +49 -2
  31. package/dist/ssg/cms-routes.d.ts +21 -4
  32. package/dist/ssg/cms-routes.d.ts.map +1 -1
  33. package/dist/ssg/collection-cache.d.ts +53 -0
  34. package/dist/ssg/collection-cache.d.ts.map +1 -0
  35. package/dist/ssg/constants.d.ts +4 -0
  36. package/dist/ssg/constants.d.ts.map +1 -1
  37. package/dist/ssg/createSSREntry.d.ts +73 -0
  38. package/dist/ssg/createSSREntry.d.ts.map +1 -0
  39. package/dist/ssg/index.cjs +138 -6
  40. package/dist/ssg/index.d.ts +10 -3
  41. package/dist/ssg/index.d.ts.map +1 -1
  42. package/dist/ssg/index.mjs +124 -12
  43. package/dist/ssg/prerender.d.ts +19 -1
  44. package/dist/ssg/prerender.d.ts.map +1 -1
  45. package/dist/ssg/render-resolved-page.d.ts +13 -3
  46. package/dist/ssg/render-resolved-page.d.ts.map +1 -1
  47. package/dist/ssg/seo.d.ts +66 -0
  48. package/dist/ssg/seo.d.ts.map +1 -0
  49. package/dist/style.css +20 -0
  50. package/dist/vite-plugin.cjs +142 -3
  51. package/dist/vite-plugin.d.ts +22 -21
  52. package/dist/vite-plugin.d.ts.map +1 -1
  53. package/dist/vite-plugin.mjs +142 -3
  54. package/package.json +4 -1
  55. package/dist/PreviewApp-BZNzZkit.js +0 -4
  56. package/dist/PreviewApp-C1WvJWI4.cjs +0 -4
  57. package/dist/constants-BIbQhd3z.js +0 -4
  58. package/dist/constants-fZvybj0k.cjs +0 -3
  59. package/dist/prerender-DYmDaqcz.js +0 -282
@@ -0,0 +1,459 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
+ const ssg_client = require("./ssg/client.cjs");
6
+ const vue = require("vue");
7
+ const vueRouter = require("vue-router");
8
+ const vue$1 = require("@bagelink/vue");
9
+ const BASE = "/api";
10
+ let _websiteName = "";
11
+ let _store = "";
12
+ let _websiteId = null;
13
+ function configureApi(websiteName, store) {
14
+ _websiteName = websiteName;
15
+ _store = store;
16
+ _websiteId = null;
17
+ }
18
+ async function request(path, { locale: locale2, params, ...opts } = {}) {
19
+ const url = new URL(`${BASE}${path}`, window.location.origin);
20
+ if (locale2) url.searchParams.set("locale", locale2);
21
+ if (params) {
22
+ for (const [k, v] of Object.entries(params)) url.searchParams.set(k, String(v));
23
+ }
24
+ const res = await fetch(url.toString(), opts);
25
+ if (!res.ok) throw new Error(`API ${res.status}: ${path}`);
26
+ if (res.status === 204) return null;
27
+ return res.json();
28
+ }
29
+ async function getWebsiteId() {
30
+ if (_websiteId) return _websiteId;
31
+ if (typeof window !== "undefined") {
32
+ const embedded = window[ssg_client.BLOX_WEBSITE_ID_WINDOW_KEY];
33
+ if (typeof embedded === "string" && embedded !== "") {
34
+ _websiteId = embedded;
35
+ return _websiteId;
36
+ }
37
+ }
38
+ const websites = await request("/cms/websites");
39
+ const website = websites.find((w) => w.name === _websiteName);
40
+ if (!website) throw new Error(`Website "${_websiteName}" not found. Run: npm run seed`);
41
+ _websiteId = website.id;
42
+ return _websiteId;
43
+ }
44
+ async function resolvePath(path, locale2) {
45
+ const websiteId = await getWebsiteId();
46
+ return request(`/cms/websites/${websiteId}/resolve-path`, {
47
+ locale: locale2,
48
+ params: { path }
49
+ });
50
+ }
51
+ async function listItems(collection, { locale: locale2, q, offset = 0, limit = 100 } = {}) {
52
+ return request(`/datastore/${_store}/collections/${collection}`, {
53
+ locale: locale2,
54
+ params: { ...q ? { q } : {}, offset, limit }
55
+ });
56
+ }
57
+ const locale = vue.ref(localStorage.getItem("blox:locale") || "en");
58
+ const currentAlternates = vue.ref({});
59
+ function useLocale() {
60
+ const dir = vue.computed(() => locale.value === "he" || locale.value === "ar" ? "rtl" : "ltr");
61
+ function setLocale(l) {
62
+ locale.value = l;
63
+ localStorage.setItem("blox:locale", l);
64
+ document.documentElement.lang = l;
65
+ document.documentElement.dir = dir.value;
66
+ try {
67
+ const i18n = vue$1.getI18n();
68
+ if (i18n == null ? void 0 : i18n.global) i18n.global.locale.value = l;
69
+ } catch {
70
+ }
71
+ }
72
+ function setAlternates(alternates) {
73
+ currentAlternates.value = alternates;
74
+ }
75
+ return { locale, dir, setLocale, currentAlternates, setAlternates };
76
+ }
77
+ const BLOX_REGISTRY_KEY = Symbol("blox:registry");
78
+ const BLOX_CONFIG_KEY = Symbol("blox:config");
79
+ const BLOX_LOCALE_STRATEGY_KEY = Symbol("blox:locale-strategy");
80
+ const PageRenderer = vue.defineComponent({
81
+ name: "PageRenderer",
82
+ props: {
83
+ blocks: {
84
+ type: Array,
85
+ default: () => []
86
+ }
87
+ },
88
+ setup(props) {
89
+ const registry = vue.inject(BLOX_REGISTRY_KEY, {});
90
+ return () => vue.h(
91
+ "div",
92
+ props.blocks.flatMap((block, i) => {
93
+ const definition = registry[block.type];
94
+ if (!definition) return [];
95
+ const props2 = { ...definition.schema.defaults, ...block.props };
96
+ return [vue.h(definition.component, { key: i, ...props2 })];
97
+ })
98
+ );
99
+ }
100
+ });
101
+ const _hoisted_1 = {
102
+ key: 0,
103
+ class: "blox-loading"
104
+ };
105
+ const _hoisted_2 = {
106
+ key: 1,
107
+ class: "blox-not-found"
108
+ };
109
+ const _hoisted_3 = {
110
+ key: 2,
111
+ class: "blox-error color-red"
112
+ };
113
+ const _hoisted_4 = {
114
+ key: 0,
115
+ class: "blox-nav-progress"
116
+ };
117
+ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
118
+ __name: "CmsPageView",
119
+ setup(__props) {
120
+ const route = vueRouter.useRoute();
121
+ const router = vueRouter.useRouter();
122
+ const { locale: locale2, setLocale, setAlternates } = useLocale();
123
+ const strategy = vue.inject(BLOX_LOCALE_STRATEGY_KEY, null);
124
+ const blocks = vue.ref([]);
125
+ const contexts = vue.ref({});
126
+ vue.provide("contexts", contexts);
127
+ const notFound = vue.ref(false);
128
+ const error = vue.ref(null);
129
+ const initialLoading = vue.ref(true);
130
+ const navigating = vue.ref(false);
131
+ function tryHydrateFromState(path) {
132
+ var _a, _b;
133
+ const win = typeof window !== "undefined" ? window : typeof globalThis !== "undefined" ? globalThis : void 0;
134
+ if (!win) return false;
135
+ const state = win[ssg_client.BLOX_STATE_WINDOW_KEY];
136
+ if (!state || typeof state !== "object") return false;
137
+ const entry = state[path];
138
+ if (!entry) return false;
139
+ blocks.value = ((_b = (_a = entry.page) == null ? void 0 : _a.content) == null ? void 0 : _b.blocks) ?? [];
140
+ contexts.value = entry.contexts ?? {};
141
+ setAlternates(entry.alternates ?? {});
142
+ return true;
143
+ }
144
+ function updateDocumentTitle(resolved) {
145
+ if (typeof document === "undefined") return;
146
+ const { page } = resolved;
147
+ const ctx = resolved.contexts ? Object.values(resolved.contexts).find((c) => c != null) : null;
148
+ const ctxTitle = ctx && typeof ctx.title === "string" ? ctx.title : null;
149
+ const title = page.meta_title || ctxTitle || page.title;
150
+ if (title) document.title = title;
151
+ }
152
+ const initialSlug = (() => {
153
+ var _a;
154
+ if (strategy) {
155
+ const hostname = typeof window !== "undefined" ? ((_a = window.location) == null ? void 0 : _a.hostname) ?? "" : "";
156
+ return strategy.detect(hostname, route.path).slug;
157
+ }
158
+ return route.path || "/";
159
+ })();
160
+ const ssrHydrated = tryHydrateFromState(initialSlug);
161
+ if (ssrHydrated) initialLoading.value = false;
162
+ async function load() {
163
+ var _a;
164
+ notFound.value = false;
165
+ error.value = null;
166
+ const { locale: urlLocale, slug } = strategy ? strategy.detect(typeof window !== "undefined" ? window.location.hostname : "", route.path) : { locale: locale2.value, slug: route.path || "/" };
167
+ if (urlLocale !== locale2.value) setLocale(urlLocale);
168
+ if (tryHydrateFromState(slug)) {
169
+ initialLoading.value = false;
170
+ return;
171
+ }
172
+ navigating.value = true;
173
+ try {
174
+ const resolved = await resolvePath(slug, urlLocale);
175
+ blocks.value = ((_a = resolved.page.content) == null ? void 0 : _a.blocks) ?? [];
176
+ contexts.value = resolved.contexts ?? {};
177
+ setAlternates(resolved.alternates ?? {});
178
+ updateDocumentTitle(resolved);
179
+ } catch (e) {
180
+ const msg = e instanceof Error ? e.message : String(e);
181
+ if (msg.includes("404")) {
182
+ const home = strategy ? strategy.toPath("/") : "/";
183
+ router.replace(home);
184
+ } else {
185
+ error.value = msg;
186
+ }
187
+ } finally {
188
+ initialLoading.value = false;
189
+ navigating.value = false;
190
+ }
191
+ }
192
+ if (!ssrHydrated) {
193
+ load();
194
+ }
195
+ vue.watch(() => route.path, load);
196
+ return (_ctx, _cache) => {
197
+ const _component_RouterLink = vue.resolveComponent("RouterLink");
198
+ return vue.openBlock(), vue.createElementBlock("div", null, [
199
+ initialLoading.value && blocks.value.length === 0 ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1, " Loading… ")) : notFound.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_2, [
200
+ _cache[0] || (_cache[0] = vue.createElementVNode("h2", null, "404", -1)),
201
+ vue.createElementVNode("p", null, vue.toDisplayString(vue.unref(locale2) === "he" ? "הדף לא נמצא" : "Page not found"), 1),
202
+ vue.createVNode(_component_RouterLink, { to: "/" }, {
203
+ default: vue.withCtx(() => [
204
+ vue.createTextVNode(vue.toDisplayString(vue.unref(locale2) === "he" ? "חזרה הביתה" : "Go home"), 1)
205
+ ]),
206
+ _: 1
207
+ })
208
+ ])) : error.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_3, vue.toDisplayString(error.value), 1)) : (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 3 }, [
209
+ navigating.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_4)) : vue.createCommentVNode("", true),
210
+ vue.createVNode(vue.unref(PageRenderer), { blocks: blocks.value }, null, 8, ["blocks"])
211
+ ], 64))
212
+ ]);
213
+ };
214
+ }
215
+ });
216
+ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
217
+ __name: "LocaleRouterLink",
218
+ props: {
219
+ to: {},
220
+ replace: { type: Boolean },
221
+ activeClass: {},
222
+ exactActiveClass: {},
223
+ ariaCurrentValue: {}
224
+ },
225
+ setup(__props) {
226
+ const props = __props;
227
+ const strategy = vue.inject(BLOX_LOCALE_STRATEGY_KEY, null);
228
+ const localizedTo = vue.computed(() => {
229
+ if (!strategy || typeof props.to !== "string") return props.to;
230
+ return strategy.toPath(props.to);
231
+ });
232
+ return (_ctx, _cache) => {
233
+ return vue.openBlock(), vue.createBlock(vue.unref(vueRouter.RouterLink), vue.normalizeProps(vue.guardReactiveProps({ ...props, to: localizedTo.value })), {
234
+ default: vue.withCtx(() => [
235
+ vue.renderSlot(_ctx.$slots, "default")
236
+ ]),
237
+ _: 3
238
+ }, 16);
239
+ };
240
+ }
241
+ });
242
+ function createPathStrategy(options) {
243
+ const { defaultLocale, supportedLocales } = options;
244
+ let _currentLocale = defaultLocale;
245
+ return {
246
+ get locales() {
247
+ return supportedLocales;
248
+ },
249
+ get currentLocale() {
250
+ return _currentLocale;
251
+ },
252
+ detect(_hostname, path) {
253
+ const segments = path.replace(/^\//, "").split("/");
254
+ const first = segments[0];
255
+ if (supportedLocales.includes(first)) {
256
+ _currentLocale = first;
257
+ return {
258
+ locale: first,
259
+ slug: `/${segments.slice(1).join("/")}` || "/"
260
+ };
261
+ }
262
+ _currentLocale = defaultLocale;
263
+ return { locale: defaultLocale, slug: path || "/" };
264
+ },
265
+ toPath(slug) {
266
+ if (_currentLocale === defaultLocale) return slug || "/";
267
+ const s = slug || "/";
268
+ return s === "/" ? `/${_currentLocale}` : `/${_currentLocale}${s}`;
269
+ },
270
+ switchTo(locale2, slug, router) {
271
+ const s = slug || "/";
272
+ const target = locale2 === defaultLocale ? s : s === "/" ? `/${locale2}` : `/${locale2}${s}`;
273
+ router.push(target);
274
+ }
275
+ };
276
+ }
277
+ function createDomainStrategy(options) {
278
+ const { localeDomains } = options;
279
+ const locales = Object.keys(localeDomains);
280
+ const _currentLocale = locales.find((l) => localeDomains[l] === window.location.hostname) ?? locales[0] ?? "en";
281
+ return {
282
+ get locales() {
283
+ return locales;
284
+ },
285
+ get currentLocale() {
286
+ return _currentLocale;
287
+ },
288
+ detect(_hostname, path) {
289
+ return { locale: _currentLocale, slug: path || "/" };
290
+ },
291
+ toPath(slug) {
292
+ return slug || "/";
293
+ },
294
+ switchTo(locale2, slug, _router) {
295
+ const domain = localeDomains[locale2];
296
+ if (!domain) return;
297
+ if (locale2 === _currentLocale) {
298
+ _router.push(slug || "/");
299
+ return;
300
+ }
301
+ const { protocol } = window.location;
302
+ const s = slug || "/";
303
+ window.location.href = `${protocol}//${domain}${s}`;
304
+ }
305
+ };
306
+ }
307
+ function createLocaleStrategy(options) {
308
+ if (options.localeStrategy === "domain" && options.localeDomains) {
309
+ return createDomainStrategy({ localeDomains: options.localeDomains });
310
+ }
311
+ return createPathStrategy({
312
+ defaultLocale: options.defaultLocale ?? "en",
313
+ supportedLocales: options.supportedLocales ?? []
314
+ });
315
+ }
316
+ function applyDefaultsToFields(schema, defaults) {
317
+ var _a;
318
+ if (!schema || !defaults) return;
319
+ for (const [key, value] of Object.entries(defaults)) {
320
+ const field = (_a = schema._fields) == null ? void 0 : _a[key];
321
+ if (field && field._config.default === void 0) {
322
+ field._config.default = value;
323
+ }
324
+ }
325
+ }
326
+ class BloxInstance {
327
+ constructor(options) {
328
+ __publicField(this, "_registry", {});
329
+ __publicField(this, "_routeRegistered", false);
330
+ __publicField(this, "_config");
331
+ __publicField(this, "_strategy");
332
+ this._config = {
333
+ defaultLocale: (options == null ? void 0 : options.defaultLocale) ?? "en",
334
+ supportedLocales: (options == null ? void 0 : options.supportedLocales) ?? []
335
+ };
336
+ this._strategy = createLocaleStrategy(options ?? {});
337
+ }
338
+ registerModules(modules) {
339
+ const list = Array.isArray(modules) ? modules : Object.values(modules);
340
+ for (const mod of list) {
341
+ if (!(mod == null ? void 0 : mod.default)) continue;
342
+ for (const [key, value] of Object.entries(mod)) {
343
+ if (key === "default") continue;
344
+ if (value && typeof value === "object" && "label" in value) {
345
+ const meta = value;
346
+ applyDefaultsToFields(meta.schema, meta.defaults);
347
+ this._registry[meta.name ?? key] = {
348
+ component: mod.default,
349
+ schema: {
350
+ label: meta.label,
351
+ description: meta.description,
352
+ icon: meta.icon,
353
+ fields: meta.schema,
354
+ defaults: meta.defaults,
355
+ dataSource: meta.dataSource
356
+ }
357
+ };
358
+ break;
359
+ }
360
+ }
361
+ }
362
+ return this;
363
+ }
364
+ registerComponents(components) {
365
+ for (const [key, value] of Object.entries(components)) {
366
+ if (!value || typeof value !== "object" && typeof value !== "function") continue;
367
+ if (isBlockDefinition(value)) {
368
+ this._registry[key] = value;
369
+ } else if (value.__blox) {
370
+ const meta = value.__blox;
371
+ applyDefaultsToFields(meta.schema, meta.defaults);
372
+ this._registry[meta.name ?? key] = {
373
+ component: value,
374
+ schema: {
375
+ label: meta.label,
376
+ description: meta.description,
377
+ icon: meta.icon,
378
+ fields: meta.schema,
379
+ defaults: meta.defaults,
380
+ dataSource: meta.dataSource
381
+ }
382
+ };
383
+ }
384
+ }
385
+ return this;
386
+ }
387
+ registerRoutes(router) {
388
+ if (this._routeRegistered) return this;
389
+ if (this._config.supportedLocales.length > 0) {
390
+ const { defaultLocale } = this._config;
391
+ router.beforeEach((to) => {
392
+ const segments = to.path.replace(/^\//, "").split("/");
393
+ if (segments[0] === defaultLocale) {
394
+ const rest = segments.slice(1).join("/");
395
+ return { path: `/${rest}`, replace: true };
396
+ }
397
+ });
398
+ }
399
+ router.addRoute({
400
+ path: "/_blox_preview",
401
+ component: () => Promise.resolve().then(() => require("./PreviewApp-C2T03Jm9.cjs")),
402
+ beforeEnter: () => window.parent !== window ? true : "/"
403
+ });
404
+ router.addRoute({ path: "/:pathMatch(.*)*", component: _sfc_main$1 });
405
+ this._routeRegistered = true;
406
+ return this;
407
+ }
408
+ install(app, options) {
409
+ if (options) {
410
+ this._config = {
411
+ defaultLocale: options.defaultLocale ?? this._config.defaultLocale,
412
+ supportedLocales: options.supportedLocales ?? this._config.supportedLocales
413
+ };
414
+ this._strategy = createLocaleStrategy({
415
+ ...options,
416
+ defaultLocale: this._config.defaultLocale,
417
+ supportedLocales: this._config.supportedLocales
418
+ });
419
+ }
420
+ if (options == null ? void 0 : options.modules) this.registerModules(options.modules);
421
+ if (options == null ? void 0 : options.components) this.registerComponents(options.components);
422
+ if (options == null ? void 0 : options.router) this.registerRoutes(options.router);
423
+ if ((options == null ? void 0 : options.websiteName) || (options == null ? void 0 : options.store)) {
424
+ configureApi(options.websiteName ?? "", options.store ?? "");
425
+ }
426
+ if (options == null ? void 0 : options.defaultLocale) {
427
+ const { setLocale } = useLocale();
428
+ if (!localStorage.getItem("blox:locale")) setLocale(options.defaultLocale);
429
+ }
430
+ app.provide(BLOX_REGISTRY_KEY, this._registry);
431
+ app.provide(BLOX_CONFIG_KEY, this._config);
432
+ app.provide(BLOX_LOCALE_STRATEGY_KEY, this._strategy);
433
+ app.component("RouterLink", _sfc_main);
434
+ }
435
+ }
436
+ function isBlockDefinition(value) {
437
+ return typeof value === "object" && "component" in value && "schema" in value;
438
+ }
439
+ function createBlox(options) {
440
+ const instance = new BloxInstance(options);
441
+ if ((options == null ? void 0 : options.websiteName) || (options == null ? void 0 : options.store)) {
442
+ configureApi(options.websiteName ?? "", options.store ?? "");
443
+ }
444
+ if (options == null ? void 0 : options.modules) instance.registerModules(options.modules);
445
+ if (options == null ? void 0 : options.components) instance.registerComponents(options.components);
446
+ if (options == null ? void 0 : options.router) instance.registerRoutes(options.router);
447
+ return instance;
448
+ }
449
+ exports.BLOX_CONFIG_KEY = BLOX_CONFIG_KEY;
450
+ exports.BLOX_LOCALE_STRATEGY_KEY = BLOX_LOCALE_STRATEGY_KEY;
451
+ exports.BLOX_REGISTRY_KEY = BLOX_REGISTRY_KEY;
452
+ exports.BloxInstance = BloxInstance;
453
+ exports.PageRenderer = PageRenderer;
454
+ exports._sfc_main = _sfc_main$1;
455
+ exports.configureApi = configureApi;
456
+ exports.createBlox = createBlox;
457
+ exports.listItems = listItems;
458
+ exports.resolvePath = resolvePath;
459
+ exports.useLocale = useLocale;
@@ -1 +1 @@
1
- {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"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AAC,MAAM,EAAE,aAAa,CAAC,GAAG,IAAI;IAyBnE,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAyBpC,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,IAAI;CAgC9C;AAMD,wBAAgB,UAAU,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,YAAY,CAS9D"}
@@ -0,0 +1,107 @@
1
+ import { App, Component, Plugin } from 'vue';
2
+ import { Router } from 'vue-router';
3
+ import { BloxInstance } from './core';
4
+ import { BlockModule } from './defineBlock';
5
+ export interface CreateBloxAppOptions {
6
+ /** Root Vue component (App.vue). */
7
+ rootComponent: Component;
8
+ /** Vue Router instance. */
9
+ router: Router;
10
+ /**
11
+ * Block SFC modules. Accepts:
12
+ * - `import.meta.glob('./components/blocks/*.vue', { eager: true })` result (recommended)
13
+ * - An array of `import * as X from './X.vue'` modules
14
+ * - A barrel `import * as blox from './blox'` object
15
+ */
16
+ modules: BlockModule[] | Record<string, BlockModule>;
17
+ /** CMS website name (must match the `name` field on the Website record). */
18
+ websiteName: string;
19
+ /** Datastore store identifier. */
20
+ store: string;
21
+ /** Default locale code. @default 'en' */
22
+ locale?: string;
23
+ /** All supported locale codes. @default ['en'] */
24
+ supportedLocales?: string[];
25
+ /** API base URL. @default '/api' */
26
+ apiBaseURL?: string;
27
+ /** Mount target — CSS selector or Element. @default '#app' */
28
+ mount?: string | Element;
29
+ /**
30
+ * Callback to create the shared API instance.
31
+ * Receives `{ baseURL }` and should call your project's `createApi()`
32
+ * and return `{ axios }` for collection cache interceptor installation.
33
+ *
34
+ * If omitted, no project-level API is configured (the Blox internal
35
+ * fetch-based API still works via `configureApi`).
36
+ */
37
+ createApi?: (opts: {
38
+ baseURL: string;
39
+ }) => {
40
+ axios?: AxiosLike;
41
+ };
42
+ /**
43
+ * Vue plugins to install on the app.
44
+ * Typically `[BagelVue, ModalPlugin]` from `@bagelink/vue`.
45
+ */
46
+ plugins?: Array<Plugin | [Plugin, ...unknown[]]>;
47
+ /**
48
+ * Global components to register.
49
+ * Typically `{ RouterWrapper }` from `@bagelink/vue`.
50
+ */
51
+ globalComponents?: Record<string, Component>;
52
+ /**
53
+ * Extra setup to run after the app is created but before mount.
54
+ * Receives the Vue app instance.
55
+ */
56
+ setup?: (app: App) => void;
57
+ }
58
+ /** Minimal axios shape for interceptor installation. */
59
+ interface AxiosLike {
60
+ interceptors: {
61
+ request: {
62
+ use: (fn: (config: any) => any) => void;
63
+ };
64
+ };
65
+ }
66
+ export interface BloxAppResult {
67
+ app: App;
68
+ router: Router;
69
+ blox: BloxInstance;
70
+ }
71
+ /**
72
+ * One-liner factory to create and mount a Blox marketing/preview site.
73
+ *
74
+ * Handles the full ceremony:
75
+ * 1. Install SSG state cache (fetch interceptor for `__BLOX_STATE__`)
76
+ * 2. Configure project API + install collection cache (axios interceptor)
77
+ * 3. Create Vue app, Pinia, Blox, plugins
78
+ * 4. Mount after router is ready
79
+ *
80
+ * @example
81
+ * ```ts
82
+ * import { createBloxApp } from '@bagelink/blox'
83
+ * import { BagelVue, ModalPlugin, RouterWrapper } from '@bagelink/vue'
84
+ * import App from './App.vue'
85
+ * import router from './router'
86
+ * import { createApi, axios } from '@shared/api'
87
+ *
88
+ * import '@bagelink/vue/dist/style.css'
89
+ * import '@bagelink/blox/dist/style.css'
90
+ *
91
+ * const blocks = import.meta.glob('./components/blocks/*.vue', { eager: true })
92
+ *
93
+ * createBloxApp({
94
+ * rootComponent: App,
95
+ * router,
96
+ * modules: Object.values(blocks),
97
+ * websiteName: 'cylogic',
98
+ * store: 'cylogic',
99
+ * createApi: ({ baseURL }) => { createApi({ baseURL }); return { axios } },
100
+ * plugins: [ModalPlugin, BagelVue],
101
+ * globalComponents: { RouterWrapper },
102
+ * })
103
+ * ```
104
+ */
105
+ export declare function createBloxApp(options: CreateBloxAppOptions): BloxAppResult;
106
+ export {};
107
+ //# sourceMappingURL=createBloxApp.d.ts.map
@@ -0,0 +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E,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAAA;CAC1B;AAED,wDAAwD;AACxD,UAAU,SAAS;IAClB,YAAY,EAAE;QACb,OAAO,EAAE;YAER,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,GAAG,KAAK,IAAI,CAAA;SACvC,CAAA;KACD,CAAA;CACD;AAED,MAAM,WAAW,aAAa;IAC7B,GAAG,EAAE,GAAG,CAAA;IACR,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,YAAY,CAAA;CAClB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,aAAa,CA8E1E"}
@@ -11,6 +11,8 @@ export interface BlockMeta {
11
11
  /** Default prop values. Merged with block props at render time so blocks show content before editing. */
12
12
  defaults?: Record<string, unknown>;
13
13
  description?: string;
14
+ /** Set to true when this block fetches its own data from a datastore collection. Used by the editor to show a hint when both schema fields and data source are present. */
15
+ dataSource?: boolean;
14
16
  }
15
17
  /** A Vue SFC module that has `export const <name> = defineBlock(...)` in its `<script setup>`. */
16
18
  export interface BlockModule {
@@ -1 +1 @@
1
- {"version":3,"file":"defineBlock.d.ts","sourceRoot":"","sources":["../src/defineBlock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAErD,MAAM,WAAW,SAAS;IACzB,kGAAkG;IAClG,IAAI,EAAE,MAAM,CAAA;IACZ,6DAA6D;IAC7D,KAAK,EAAE,MAAM,CAAA;IACb,0BAA0B;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,sFAAsF;IACtF,MAAM,CAAC,EAAE,gBAAgB,CAAA;IACzB,yGAAyG;IACzG,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAClC,WAAW,CAAC,EAAE,MAAM,CAAA;CACpB;AA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