@bagelink/blox 1.15.587 → 1.15.591
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.
- package/README.md +48 -22
- package/dist/CmsPageView.vue.d.ts.map +1 -1
- package/dist/{PreviewApp-D208UMZs.js → PreviewApp-BagepqPk.js} +1 -1
- package/dist/{PreviewApp-DNMYw1AS.cjs → PreviewApp-HVipxMQ3.cjs} +1 -1
- package/dist/{PreviewApp.vue_vue_type_style_index_0_lang-Dm0SmjEr.cjs → PreviewApp.vue_vue_type_style_index_0_lang-C6e-tDzD.cjs} +6 -6
- package/dist/{PreviewApp.vue_vue_type_style_index_0_lang-l6QisbG-.js → PreviewApp.vue_vue_type_style_index_0_lang-Dl3bKQTA.js} +1 -1
- package/dist/api/index.d.ts +24 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/{routes-DDiQDksF.js → appRuntime-B6yWkH3M.js} +280 -82
- package/dist/{routes-DOcek9fP.cjs → appRuntime-D1Z3fX-G.cjs} +237 -39
- package/dist/appRuntime.d.ts +26 -0
- package/dist/appRuntime.d.ts.map +1 -0
- package/dist/composables/useLocale.d.ts +10 -3
- package/dist/composables/useLocale.d.ts.map +1 -1
- package/dist/content/routes.d.ts +4 -2
- package/dist/content/routes.d.ts.map +1 -1
- package/dist/content/useContentSeo.d.ts.map +1 -1
- package/dist/core.d.ts +2 -0
- package/dist/core.d.ts.map +1 -1
- package/dist/createBloxApp.d.ts +9 -19
- package/dist/createBloxApp.d.ts.map +1 -1
- package/dist/data/useData.d.ts.map +1 -1
- package/dist/index.cjs +91 -111
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +64 -84
- package/dist/{shard-runner-Bc4gTl71.js → shard-runner-DauYjwvg.js} +2 -2
- package/dist/{shard-runner-ZAwqteYY.cjs → shard-runner-xIPqGX-Q.cjs} +2 -2
- package/dist/ssg/cli.cjs +2 -4
- package/dist/ssg/cli.mjs +2 -4
- package/dist/ssg/client.cjs +0 -73
- package/dist/ssg/client.d.ts +1 -3
- package/dist/ssg/client.d.ts.map +1 -1
- package/dist/ssg/client.mjs +1 -74
- package/dist/ssg/constants.d.ts +0 -4
- package/dist/ssg/constants.d.ts.map +1 -1
- package/dist/ssg/createSSREntry.d.ts.map +1 -1
- package/dist/ssg/index.cjs +26 -47
- package/dist/ssg/index.d.ts +1 -3
- package/dist/ssg/index.d.ts.map +1 -1
- package/dist/ssg/index.mjs +24 -45
- package/dist/ssg/prerender.d.ts +1 -5
- package/dist/ssg/prerender.d.ts.map +1 -1
- package/dist/ssg/render-resolved-page.d.ts +0 -2
- package/dist/ssg/render-resolved-page.d.ts.map +1 -1
- package/dist/{validate-output-DRCseorw.js → validate-output-B56PuxEM.js} +0 -2
- package/dist/{validate-output-DlHgDBoV.cjs → validate-output-CRfMSrpx.cjs} +0 -2
- package/dist/vite-plugin.cjs +3 -64
- package/dist/vite-plugin.d.ts +0 -8
- package/dist/vite-plugin.d.ts.map +1 -1
- package/dist/vite-plugin.mjs +3 -64
- package/package.json +1 -1
- package/dist/ssg/collection-cache.d.ts +0 -53
- package/dist/ssg/collection-cache.d.ts.map +0 -1
- package/dist/ssg/state-cache.d.ts +0 -21
- package/dist/ssg/state-cache.d.ts.map +0 -1
|
@@ -2,17 +2,18 @@
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
4
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
const pinia = require("pinia");
|
|
5
6
|
const vue = require("vue");
|
|
6
|
-
const vueRouter = require("vue-router");
|
|
7
|
-
const pageTitle = require("./pageTitle-nIl1cDfD.cjs");
|
|
8
7
|
const ssg_client = require("./ssg/client.cjs");
|
|
8
|
+
const vueRouter = require("vue-router");
|
|
9
9
|
const vue$1 = require("@bagelink/vue");
|
|
10
|
+
const pageTitle = require("./pageTitle-nIl1cDfD.cjs");
|
|
10
11
|
let BASE = "/api";
|
|
11
12
|
let _websiteName = "";
|
|
12
13
|
let _store = "";
|
|
13
14
|
let _websiteId = null;
|
|
14
15
|
let _origin = "";
|
|
15
|
-
|
|
16
|
+
const BLOX_API_KEY = Symbol("blox:api");
|
|
16
17
|
function configureApi(websiteName, store) {
|
|
17
18
|
_websiteName = websiteName;
|
|
18
19
|
_store = store;
|
|
@@ -27,8 +28,102 @@ function setApiOrigin(base) {
|
|
|
27
28
|
} catch {
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
|
-
function
|
|
31
|
-
|
|
31
|
+
function apiBase(base = "/api", origin = "") {
|
|
32
|
+
if (!origin) return { base, origin };
|
|
33
|
+
try {
|
|
34
|
+
const url = new URL(origin);
|
|
35
|
+
return {
|
|
36
|
+
origin: url.origin,
|
|
37
|
+
base: url.pathname && url.pathname !== "/" ? url.pathname.replace(/\/$/, "") : ""
|
|
38
|
+
};
|
|
39
|
+
} catch {
|
|
40
|
+
return { base, origin: "" };
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function createBloxApi(options) {
|
|
44
|
+
const configured = apiBase("/api", options.origin);
|
|
45
|
+
let websiteId = null;
|
|
46
|
+
async function scopedRequest(path, { locale: locale2, params, ...opts } = {}) {
|
|
47
|
+
const origin = configured.origin || (typeof window !== "undefined" ? window.location.origin : "");
|
|
48
|
+
const url = new URL(`${configured.base}${path}`, origin || void 0);
|
|
49
|
+
if (locale2) url.searchParams.set("locale", locale2);
|
|
50
|
+
if (params) {
|
|
51
|
+
for (const [key, value] of Object.entries(params)) url.searchParams.set(key, String(value));
|
|
52
|
+
}
|
|
53
|
+
const response = await fetch(url.toString(), opts);
|
|
54
|
+
if (!response.ok) throw new Error(`API ${response.status}: ${path}`);
|
|
55
|
+
if (response.status === 204) return null;
|
|
56
|
+
return response.json();
|
|
57
|
+
}
|
|
58
|
+
function getWebsiteIdSync2() {
|
|
59
|
+
if (websiteId) return websiteId;
|
|
60
|
+
if (typeof window === "undefined") return null;
|
|
61
|
+
const embedded = window[ssg_client.BLOX_WEBSITE_ID_WINDOW_KEY];
|
|
62
|
+
return typeof embedded === "string" && embedded !== "" ? embedded : null;
|
|
63
|
+
}
|
|
64
|
+
async function getWebsiteId2() {
|
|
65
|
+
const existing = getWebsiteIdSync2();
|
|
66
|
+
if (existing) {
|
|
67
|
+
websiteId = existing;
|
|
68
|
+
return existing;
|
|
69
|
+
}
|
|
70
|
+
try {
|
|
71
|
+
const website = await scopedRequest(
|
|
72
|
+
`/blox/sites/${encodeURIComponent(options.websiteName)}`
|
|
73
|
+
);
|
|
74
|
+
websiteId = website.id;
|
|
75
|
+
return website.id;
|
|
76
|
+
} catch {
|
|
77
|
+
throw new Error(`Website "${options.websiteName}" not found. Run: npm run seed`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
async function listItems2(collection, { locale: locale2, q, offset = 0, limit = 100 } = {}) {
|
|
81
|
+
if (options.collectionResolver) {
|
|
82
|
+
return await options.collectionResolver(collection, {
|
|
83
|
+
locale: locale2,
|
|
84
|
+
q,
|
|
85
|
+
offset,
|
|
86
|
+
limit
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
return scopedRequest(`/datastore/${options.store}/collections/${collection}`, {
|
|
90
|
+
locale: locale2,
|
|
91
|
+
params: { ...q ? { q } : {}, offset, limit }
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
getWebsiteIdSync: getWebsiteIdSync2,
|
|
96
|
+
getWebsiteId: getWebsiteId2,
|
|
97
|
+
resolvePath: async (path, locale2) => {
|
|
98
|
+
const id = await getWebsiteId2();
|
|
99
|
+
return scopedRequest(`/blox/websites/${id}/resolve-path`, {
|
|
100
|
+
locale: locale2,
|
|
101
|
+
params: { path }
|
|
102
|
+
});
|
|
103
|
+
},
|
|
104
|
+
listItems: listItems2,
|
|
105
|
+
getItemBySlug: async (collection, slug, locale2) => {
|
|
106
|
+
const result = await listItems2(collection, { locale: locale2, limit: 1e3 });
|
|
107
|
+
const items = Array.isArray(result) ? result : (result == null ? void 0 : result.items) ?? [];
|
|
108
|
+
return items.find((item) => String((item == null ? void 0 : item.slug) ?? "") === slug) ?? null;
|
|
109
|
+
},
|
|
110
|
+
getItemById: async (collection, id, locale2) => {
|
|
111
|
+
const result = await listItems2(collection, { locale: locale2, limit: 1e3 });
|
|
112
|
+
const items = Array.isArray(result) ? result : (result == null ? void 0 : result.items) ?? [];
|
|
113
|
+
return items.find((item) => {
|
|
114
|
+
const record = item;
|
|
115
|
+
return String((record == null ? void 0 : record.id) ?? (record == null ? void 0 : record._id) ?? "") === id;
|
|
116
|
+
}) ?? null;
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function provideBloxApi(app, options) {
|
|
121
|
+
const client = createBloxApi(options);
|
|
122
|
+
app.provide(BLOX_API_KEY, client);
|
|
123
|
+
return client;
|
|
124
|
+
}
|
|
125
|
+
function useBloxApi() {
|
|
126
|
+
return vue.getCurrentInstance() ? vue.inject(BLOX_API_KEY, null) : null;
|
|
32
127
|
}
|
|
33
128
|
async function request(path, { locale: locale2, params, ...opts } = {}) {
|
|
34
129
|
const origin = _origin || (typeof window !== "undefined" ? window.location.origin : "");
|
|
@@ -78,27 +173,28 @@ async function resolvePath(path, locale2) {
|
|
|
78
173
|
});
|
|
79
174
|
}
|
|
80
175
|
async function listItems(collection, { locale: locale2, q, offset = 0, limit = 100 } = {}) {
|
|
81
|
-
if (_collectionResolver) {
|
|
82
|
-
return await _collectionResolver(collection, { locale: locale2, q, offset, limit });
|
|
83
|
-
}
|
|
84
176
|
return request(`/datastore/${_store}/collections/${collection}`, {
|
|
85
177
|
locale: locale2,
|
|
86
178
|
params: { ...q ? { q } : {}, offset, limit }
|
|
87
179
|
});
|
|
88
180
|
}
|
|
89
181
|
async function getItemBySlug(collection, slug, locale2) {
|
|
90
|
-
const res = await
|
|
182
|
+
const res = await listItemsFromActiveApi(collection, { locale: locale2, limit: 1e3 });
|
|
91
183
|
const items = Array.isArray(res) ? res : (res == null ? void 0 : res.items) ?? [];
|
|
92
184
|
return items.find((item) => String((item == null ? void 0 : item.slug) ?? "") === slug) ?? null;
|
|
93
185
|
}
|
|
94
186
|
async function getItemById(collection, id, locale2) {
|
|
95
|
-
const res = await
|
|
187
|
+
const res = await listItemsFromActiveApi(collection, { locale: locale2, limit: 1e3 });
|
|
96
188
|
const items = Array.isArray(res) ? res : (res == null ? void 0 : res.items) ?? [];
|
|
97
189
|
return items.find((item) => {
|
|
98
190
|
const record = item;
|
|
99
191
|
return String((record == null ? void 0 : record.id) ?? (record == null ? void 0 : record._id) ?? "") === id;
|
|
100
192
|
}) ?? null;
|
|
101
193
|
}
|
|
194
|
+
function listItemsFromActiveApi(collection, options = {}) {
|
|
195
|
+
var _a;
|
|
196
|
+
return ((_a = useBloxApi()) == null ? void 0 : _a.listItems(collection, options)) ?? listItems(collection, options);
|
|
197
|
+
}
|
|
102
198
|
const BLOX_REGISTRY_KEY = Symbol("blox:registry");
|
|
103
199
|
const BLOX_CONFIG_KEY = Symbol("blox:config");
|
|
104
200
|
const BLOX_LOCALE_STRATEGY_KEY = Symbol("blox:locale-strategy");
|
|
@@ -202,8 +298,24 @@ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
|
|
|
202
298
|
const _hasStorage = typeof localStorage !== "undefined";
|
|
203
299
|
const locale = vue.ref((_hasStorage ? localStorage.getItem("blox:locale") : null) || "en");
|
|
204
300
|
const currentAlternates = vue.ref({});
|
|
205
|
-
|
|
206
|
-
|
|
301
|
+
const BLOX_LOCALE_KEY = Symbol("blox:locale");
|
|
302
|
+
function provideBloxLocale(app, initialLocale) {
|
|
303
|
+
const state = {
|
|
304
|
+
locale: vue.ref(initialLocale),
|
|
305
|
+
currentAlternates: vue.ref({})
|
|
306
|
+
};
|
|
307
|
+
app.provide(BLOX_LOCALE_KEY, state);
|
|
308
|
+
return state;
|
|
309
|
+
}
|
|
310
|
+
function localeState() {
|
|
311
|
+
if (vue.getCurrentInstance()) {
|
|
312
|
+
const state = vue.inject(BLOX_LOCALE_KEY, null);
|
|
313
|
+
if (state) return state;
|
|
314
|
+
}
|
|
315
|
+
return { locale, currentAlternates };
|
|
316
|
+
}
|
|
317
|
+
function setActiveLocale(l, state = localeState()) {
|
|
318
|
+
state.locale.value = l;
|
|
207
319
|
try {
|
|
208
320
|
const i18n = vue$1.getI18n();
|
|
209
321
|
if (i18n == null ? void 0 : i18n.global) i18n.global.locale.value = l;
|
|
@@ -211,9 +323,10 @@ function setActiveLocale(l) {
|
|
|
211
323
|
}
|
|
212
324
|
}
|
|
213
325
|
function useLocale() {
|
|
214
|
-
const
|
|
326
|
+
const state = localeState();
|
|
327
|
+
const dir = vue.computed(() => state.locale.value === "he" || state.locale.value === "ar" ? "rtl" : "ltr");
|
|
215
328
|
function setLocale(l) {
|
|
216
|
-
locale.value = l;
|
|
329
|
+
state.locale.value = l;
|
|
217
330
|
if (typeof localStorage !== "undefined") localStorage.setItem("blox:locale", l);
|
|
218
331
|
if (typeof document !== "undefined") {
|
|
219
332
|
document.documentElement.lang = l;
|
|
@@ -226,9 +339,15 @@ function useLocale() {
|
|
|
226
339
|
}
|
|
227
340
|
}
|
|
228
341
|
function setAlternates(alternates) {
|
|
229
|
-
currentAlternates.value = alternates;
|
|
342
|
+
state.currentAlternates.value = alternates;
|
|
230
343
|
}
|
|
231
|
-
return {
|
|
344
|
+
return {
|
|
345
|
+
locale: state.locale,
|
|
346
|
+
dir,
|
|
347
|
+
setLocale,
|
|
348
|
+
currentAlternates: state.currentAlternates,
|
|
349
|
+
setAlternates
|
|
350
|
+
};
|
|
232
351
|
}
|
|
233
352
|
function pathExcluded(path, patterns) {
|
|
234
353
|
if (!(patterns == null ? void 0 : patterns.length)) return false;
|
|
@@ -361,12 +480,13 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
|
|
|
361
480
|
const { locale: locale2, setLocale, setAlternates } = useLocale();
|
|
362
481
|
const strategy = vue.inject(BLOX_LOCALE_STRATEGY_KEY, null);
|
|
363
482
|
const ssrRouteState = vue.inject(BLOX_SSR_ROUTE_STATE_KEY, null);
|
|
483
|
+
const api = useBloxApi();
|
|
364
484
|
const blocks = vue.ref([]);
|
|
365
485
|
const contexts = vue.ref({});
|
|
366
486
|
vue.provide("contexts", contexts);
|
|
367
487
|
const adminConfig = vue.inject(BLOX_ADMIN_CONFIG_KEY, null);
|
|
368
488
|
const currentPageId = vue.ref(null);
|
|
369
|
-
const websiteId = vue.ref(getWebsiteIdSync());
|
|
489
|
+
const websiteId = vue.ref((api == null ? void 0 : api.getWebsiteIdSync()) ?? getWebsiteIdSync());
|
|
370
490
|
const notFound = vue.ref(false);
|
|
371
491
|
const error = vue.ref(null);
|
|
372
492
|
const initialLoading = vue.ref(true);
|
|
@@ -446,7 +566,7 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
|
|
|
446
566
|
}
|
|
447
567
|
navigating.value = true;
|
|
448
568
|
try {
|
|
449
|
-
const resolved = await resolvePath(slug, urlLocale);
|
|
569
|
+
const resolved = await ((api == null ? void 0 : api.resolvePath(slug, urlLocale)) ?? resolvePath(slug, urlLocale));
|
|
450
570
|
blocks.value = ((_a = resolved.page.content) == null ? void 0 : _a.blocks) ?? [];
|
|
451
571
|
contexts.value = resolved.contexts ?? {};
|
|
452
572
|
currentPageId.value = resolved.page.id ?? null;
|
|
@@ -471,7 +591,7 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
|
|
|
471
591
|
vue.watch(currentRoutePath, load);
|
|
472
592
|
vue.onMounted(() => {
|
|
473
593
|
if (adminConfig && !websiteId.value) {
|
|
474
|
-
getWebsiteId().then((id) => {
|
|
594
|
+
((api == null ? void 0 : api.getWebsiteId()) ?? getWebsiteId()).then((id) => {
|
|
475
595
|
websiteId.value = id;
|
|
476
596
|
}).catch(() => {
|
|
477
597
|
});
|
|
@@ -518,7 +638,6 @@ function provideBloxData(app, opts = {}) {
|
|
|
518
638
|
seoSources: []
|
|
519
639
|
};
|
|
520
640
|
app.provide(BLOX_DATA_KEY, registry2);
|
|
521
|
-
globalThis.__BLOX_DATA_REGISTRY__ = registry2;
|
|
522
641
|
return registry2;
|
|
523
642
|
}
|
|
524
643
|
function readPayload() {
|
|
@@ -534,7 +653,7 @@ function getRegistry() {
|
|
|
534
653
|
const injected = vue.inject(BLOX_DATA_KEY, null);
|
|
535
654
|
if (injected) return injected;
|
|
536
655
|
}
|
|
537
|
-
return
|
|
656
|
+
return null;
|
|
538
657
|
}
|
|
539
658
|
function getRegistryData() {
|
|
540
659
|
return getRegistry();
|
|
@@ -840,6 +959,8 @@ function createLocaleStrategy(options) {
|
|
|
840
959
|
supportedLocales: options.supportedLocales ?? []
|
|
841
960
|
});
|
|
842
961
|
}
|
|
962
|
+
const BLOX_PREVIEW_ROUTE_NAME = "blox:preview";
|
|
963
|
+
const BLOX_CMS_ROUTE_NAME = "blox:cms";
|
|
843
964
|
function applyDefaultsToFields(schema, defaults) {
|
|
844
965
|
var _a;
|
|
845
966
|
if (!schema || !defaults) return;
|
|
@@ -944,12 +1065,22 @@ class BloxInstance {
|
|
|
944
1065
|
}
|
|
945
1066
|
});
|
|
946
1067
|
}
|
|
947
|
-
router.
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
1068
|
+
if (!router.hasRoute(BLOX_PREVIEW_ROUTE_NAME)) {
|
|
1069
|
+
router.addRoute({
|
|
1070
|
+
path: "/_blox_preview",
|
|
1071
|
+
name: BLOX_PREVIEW_ROUTE_NAME,
|
|
1072
|
+
component: () => Promise.resolve().then(() => require("./PreviewApp-HVipxMQ3.cjs")),
|
|
1073
|
+
beforeEnter: () => typeof window === "undefined" || window.parent !== window ? true : "/"
|
|
1074
|
+
});
|
|
1075
|
+
}
|
|
1076
|
+
if (!router.hasRoute(BLOX_CMS_ROUTE_NAME)) {
|
|
1077
|
+
router.addRoute({
|
|
1078
|
+
path: "/:pathMatch(.*)*",
|
|
1079
|
+
name: BLOX_CMS_ROUTE_NAME,
|
|
1080
|
+
component: _sfc_main$2,
|
|
1081
|
+
meta: { navigation: "document" }
|
|
1082
|
+
});
|
|
1083
|
+
}
|
|
953
1084
|
this._routeRegistered = true;
|
|
954
1085
|
return this;
|
|
955
1086
|
}
|
|
@@ -1050,7 +1181,7 @@ function useContentItem(collectionArg, slugArg) {
|
|
|
1050
1181
|
const c = coll();
|
|
1051
1182
|
const s = slg();
|
|
1052
1183
|
if (!c || !s) return null;
|
|
1053
|
-
const res = await
|
|
1184
|
+
const res = await listItemsFromActiveApi(c, { locale: loc(), limit: 1e3 });
|
|
1054
1185
|
const items = Array.isArray(res) ? res : (res == null ? void 0 : res.items) ?? [];
|
|
1055
1186
|
return items.find((it) => String((it == null ? void 0 : it.slug) ?? "") === s) ?? null;
|
|
1056
1187
|
},
|
|
@@ -1167,8 +1298,8 @@ function generateContentRoutes(supportedLocales, defaultLocale) {
|
|
|
1167
1298
|
}
|
|
1168
1299
|
return records;
|
|
1169
1300
|
}
|
|
1170
|
-
function installLocaleAwareResolve(router, strategy) {
|
|
1171
|
-
const
|
|
1301
|
+
function installLocaleAwareResolve(router, strategy, activeLocaleRef) {
|
|
1302
|
+
const locale2 = activeLocaleRef ?? useLocale().locale;
|
|
1172
1303
|
const supported = strategy.locales;
|
|
1173
1304
|
const defaultLocale = strategy.defaultLocale;
|
|
1174
1305
|
const activeLocale = () => String(locale2.value || "").slice(0, 2).toLowerCase() || defaultLocale;
|
|
@@ -1190,7 +1321,7 @@ function installLocaleAwareResolve(router, strategy) {
|
|
|
1190
1321
|
return originalResolve(to, currentLocation);
|
|
1191
1322
|
};
|
|
1192
1323
|
}
|
|
1193
|
-
function installContentFallback(router, supportedLocales, defaultLocale) {
|
|
1324
|
+
function installContentFallback(router, supportedLocales, defaultLocale, api) {
|
|
1194
1325
|
const localeOf = (path) => {
|
|
1195
1326
|
const first = path.replace(/^\//, "").split("/")[0];
|
|
1196
1327
|
return first && supportedLocales.includes(first) ? first : defaultLocale;
|
|
@@ -1209,11 +1340,15 @@ function installContentFallback(router, supportedLocales, defaultLocale) {
|
|
|
1209
1340
|
}
|
|
1210
1341
|
let here;
|
|
1211
1342
|
try {
|
|
1212
|
-
here = await getItemBySlug(
|
|
1343
|
+
here = await ((api == null ? void 0 : api.getItemBySlug(
|
|
1213
1344
|
registration.collection,
|
|
1214
1345
|
slug,
|
|
1215
1346
|
urlLocale
|
|
1216
|
-
)
|
|
1347
|
+
)) ?? getItemBySlug(
|
|
1348
|
+
registration.collection,
|
|
1349
|
+
slug,
|
|
1350
|
+
urlLocale
|
|
1351
|
+
));
|
|
1217
1352
|
} catch {
|
|
1218
1353
|
return true;
|
|
1219
1354
|
}
|
|
@@ -1222,11 +1357,15 @@ function installContentFallback(router, supportedLocales, defaultLocale) {
|
|
|
1222
1357
|
if (sourceLocale === urlLocale) continue;
|
|
1223
1358
|
let source;
|
|
1224
1359
|
try {
|
|
1225
|
-
source = await getItemBySlug(
|
|
1360
|
+
source = await ((api == null ? void 0 : api.getItemBySlug(
|
|
1361
|
+
registration.collection,
|
|
1362
|
+
slug,
|
|
1363
|
+
sourceLocale
|
|
1364
|
+
)) ?? getItemBySlug(
|
|
1226
1365
|
registration.collection,
|
|
1227
1366
|
slug,
|
|
1228
1367
|
sourceLocale
|
|
1229
|
-
);
|
|
1368
|
+
));
|
|
1230
1369
|
} catch {
|
|
1231
1370
|
return true;
|
|
1232
1371
|
}
|
|
@@ -1234,11 +1373,15 @@ function installContentFallback(router, supportedLocales, defaultLocale) {
|
|
|
1234
1373
|
if (!id) continue;
|
|
1235
1374
|
let target;
|
|
1236
1375
|
try {
|
|
1237
|
-
target = await getItemById(
|
|
1376
|
+
target = await ((api == null ? void 0 : api.getItemById(
|
|
1377
|
+
registration.collection,
|
|
1378
|
+
id,
|
|
1379
|
+
urlLocale
|
|
1380
|
+
)) ?? getItemById(
|
|
1238
1381
|
registration.collection,
|
|
1239
1382
|
id,
|
|
1240
1383
|
urlLocale
|
|
1241
|
-
);
|
|
1384
|
+
));
|
|
1242
1385
|
} catch {
|
|
1243
1386
|
return true;
|
|
1244
1387
|
}
|
|
@@ -1256,6 +1399,58 @@ function hasEmbeddedContentItem(collection, slug, locale2) {
|
|
|
1256
1399
|
if (!payload || typeof payload !== "object" || Array.isArray(payload)) return false;
|
|
1257
1400
|
return `content:${collection}:${slug}:${locale2}` in payload;
|
|
1258
1401
|
}
|
|
1402
|
+
function installBloxRuntime(options) {
|
|
1403
|
+
const {
|
|
1404
|
+
app,
|
|
1405
|
+
router,
|
|
1406
|
+
modules,
|
|
1407
|
+
websiteName,
|
|
1408
|
+
store,
|
|
1409
|
+
locale: locale2,
|
|
1410
|
+
supportedLocales,
|
|
1411
|
+
plugins = [],
|
|
1412
|
+
globalComponents = {},
|
|
1413
|
+
setup,
|
|
1414
|
+
adminEdit,
|
|
1415
|
+
contentFallback = false,
|
|
1416
|
+
api,
|
|
1417
|
+
localeState: localeState2
|
|
1418
|
+
} = options;
|
|
1419
|
+
const blox = createBlox({
|
|
1420
|
+
modules,
|
|
1421
|
+
websiteName,
|
|
1422
|
+
store,
|
|
1423
|
+
defaultLocale: locale2,
|
|
1424
|
+
supportedLocales,
|
|
1425
|
+
router,
|
|
1426
|
+
adminEdit
|
|
1427
|
+
});
|
|
1428
|
+
const pinia$1 = pinia.createPinia();
|
|
1429
|
+
pinia$1.use(({ store: piniaStore }) => {
|
|
1430
|
+
piniaStore.router = vue.markRaw(router);
|
|
1431
|
+
});
|
|
1432
|
+
app.use(pinia$1);
|
|
1433
|
+
app.use(router);
|
|
1434
|
+
blox.install(app, {});
|
|
1435
|
+
for (const record of generateContentRoutes(supportedLocales, locale2)) {
|
|
1436
|
+
if (!router.hasRoute(record.name)) router.addRoute(record);
|
|
1437
|
+
}
|
|
1438
|
+
if (contentFallback) installContentFallback(router, supportedLocales, locale2, api);
|
|
1439
|
+
installLocaleAwareResolve(router, blox.strategy, localeState2.locale);
|
|
1440
|
+
for (const plugin of plugins) {
|
|
1441
|
+
if (Array.isArray(plugin)) {
|
|
1442
|
+
const [vuePlugin, ...args] = plugin;
|
|
1443
|
+
app.use(vuePlugin, ...args);
|
|
1444
|
+
} else {
|
|
1445
|
+
app.use(plugin);
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1448
|
+
for (const [name, component] of Object.entries(globalComponents)) {
|
|
1449
|
+
app.component(name, component);
|
|
1450
|
+
}
|
|
1451
|
+
setup == null ? void 0 : setup(app);
|
|
1452
|
+
return blox;
|
|
1453
|
+
}
|
|
1259
1454
|
exports.BLOX_ADMIN_CONFIG_KEY = BLOX_ADMIN_CONFIG_KEY;
|
|
1260
1455
|
exports.BLOX_CONFIG_KEY = BLOX_CONFIG_KEY;
|
|
1261
1456
|
exports.BLOX_DATA_KEY = BLOX_DATA_KEY;
|
|
@@ -1279,6 +1474,7 @@ exports.configureApi = configureApi;
|
|
|
1279
1474
|
exports.consumePendingLocaleSwitch = consumePendingLocaleSwitch;
|
|
1280
1475
|
exports.contentRoutes = contentRoutes;
|
|
1281
1476
|
exports.createBlox = createBlox;
|
|
1477
|
+
exports.createBloxApi = createBloxApi;
|
|
1282
1478
|
exports.defineContent = defineContent;
|
|
1283
1479
|
exports.generateContentRoutes = generateContentRoutes;
|
|
1284
1480
|
exports.getContentRoute = getContentRoute;
|
|
@@ -1288,8 +1484,8 @@ exports.getItemBySlug = getItemBySlug;
|
|
|
1288
1484
|
exports.getRegistryData = getRegistryData;
|
|
1289
1485
|
exports.getWebsiteId = getWebsiteId;
|
|
1290
1486
|
exports.getWebsiteIdSync = getWebsiteIdSync;
|
|
1487
|
+
exports.installBloxRuntime = installBloxRuntime;
|
|
1291
1488
|
exports.installContentFallback = installContentFallback;
|
|
1292
|
-
exports.installLocaleAwareResolve = installLocaleAwareResolve;
|
|
1293
1489
|
exports.installSmartLinks = installSmartLinks;
|
|
1294
1490
|
exports.isAbsoluteExternal = isAbsoluteExternal;
|
|
1295
1491
|
exports.isSoloContentPage = isSoloContentPage;
|
|
@@ -1297,14 +1493,16 @@ exports.isSpecialScheme = isSpecialScheme;
|
|
|
1297
1493
|
exports.listItems = listItems;
|
|
1298
1494
|
exports.normalizeLink = normalizeLink;
|
|
1299
1495
|
exports.normalizeTo = normalizeTo;
|
|
1496
|
+
exports.provideBloxApi = provideBloxApi;
|
|
1300
1497
|
exports.provideBloxData = provideBloxData;
|
|
1498
|
+
exports.provideBloxLocale = provideBloxLocale;
|
|
1301
1499
|
exports.provideContentItem = provideContentItem;
|
|
1302
1500
|
exports.resolveBlockProps = resolveBlockProps;
|
|
1303
1501
|
exports.resolvePath = resolvePath;
|
|
1304
1502
|
exports.setActiveLocale = setActiveLocale;
|
|
1305
1503
|
exports.setApiOrigin = setApiOrigin;
|
|
1306
|
-
exports.setCollectionResolver = setCollectionResolver;
|
|
1307
1504
|
exports.toInternalPath = toInternalPath;
|
|
1505
|
+
exports.useBloxApi = useBloxApi;
|
|
1308
1506
|
exports.useBloxEdit = useBloxEdit;
|
|
1309
1507
|
exports.useContentItem = useContentItem;
|
|
1310
1508
|
exports.useData = useData;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { App, Component, Plugin } from 'vue';
|
|
2
|
+
import { Router } from 'vue-router';
|
|
3
|
+
import { BloxAdminConfig } from './symbols';
|
|
4
|
+
import { BlockModule } from './defineBlock';
|
|
5
|
+
import { BloxApiClient } from './api';
|
|
6
|
+
import { BloxLocaleState } from './composables/useLocale';
|
|
7
|
+
import { BloxInstance } from './core';
|
|
8
|
+
export interface InstallBloxRuntimeOptions {
|
|
9
|
+
app: App;
|
|
10
|
+
router: Router;
|
|
11
|
+
modules: BlockModule[] | Record<string, BlockModule>;
|
|
12
|
+
websiteName: string;
|
|
13
|
+
store: string;
|
|
14
|
+
locale: string;
|
|
15
|
+
supportedLocales: string[];
|
|
16
|
+
plugins?: Array<Plugin | [Plugin, ...unknown[]]>;
|
|
17
|
+
globalComponents?: Record<string, Component>;
|
|
18
|
+
setup?: (app: App) => void;
|
|
19
|
+
adminEdit?: BloxAdminConfig;
|
|
20
|
+
contentFallback?: boolean;
|
|
21
|
+
api: BloxApiClient;
|
|
22
|
+
localeState: BloxLocaleState;
|
|
23
|
+
}
|
|
24
|
+
/** Install the shared Vue/Pinia/router/Blox lifecycle in one deterministic order. */
|
|
25
|
+
export declare function installBloxRuntime(options: InstallBloxRuntimeOptions): BloxInstance;
|
|
26
|
+
//# sourceMappingURL=appRuntime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"appRuntime.d.ts","sourceRoot":"","sources":["../src/appRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,KAAK,CAAA;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAC1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAG9D,OAAO,EAAc,KAAK,YAAY,EAAE,MAAM,QAAQ,CAAA;AAGtD,MAAM,WAAW,yBAAyB;IACzC,GAAG,EAAE,GAAG,CAAA;IACR,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;IACpD,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,gBAAgB,EAAE,MAAM,EAAE,CAAA;IAC1B,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,MAAM,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC,CAAA;IAChD,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IAC5C,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAAA;IAC1B,SAAS,CAAC,EAAE,eAAe,CAAA;IAC3B,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,GAAG,EAAE,aAAa,CAAA;IAClB,WAAW,EAAE,eAAe,CAAA;CAC5B;AAED,qFAAqF;AACrF,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,yBAAyB,GAAG,YAAY,CAsDnF"}
|
|
@@ -1,16 +1,23 @@
|
|
|
1
|
+
import { App, InjectionKey, Ref } from 'vue';
|
|
1
2
|
export type Locale = string;
|
|
3
|
+
export interface BloxLocaleState {
|
|
4
|
+
locale: Ref<Locale>;
|
|
5
|
+
currentAlternates: Ref<Record<string, string>>;
|
|
6
|
+
}
|
|
7
|
+
export declare const BLOX_LOCALE_KEY: InjectionKey<BloxLocaleState>;
|
|
8
|
+
export declare function provideBloxLocale(app: App, initialLocale: Locale): BloxLocaleState;
|
|
2
9
|
/**
|
|
3
10
|
* Set the active locale ref directly, without touching `localStorage`/`document`.
|
|
4
11
|
* Used by the SSG entry to align `useLocale()` with the URL-detected render
|
|
5
12
|
* locale for app-router pages (which don't pass through `CmsPageView`). Keeps
|
|
6
13
|
* `@bagelink/vue` i18n in sync when present.
|
|
7
14
|
*/
|
|
8
|
-
export declare function setActiveLocale(l: Locale): void;
|
|
15
|
+
export declare function setActiveLocale(l: Locale, state?: BloxLocaleState): void;
|
|
9
16
|
export declare function useLocale(): {
|
|
10
|
-
locale:
|
|
17
|
+
locale: Ref<string, string>;
|
|
11
18
|
dir: import('vue').ComputedRef<"ltr" | "rtl">;
|
|
12
19
|
setLocale: (l: Locale) => void;
|
|
13
|
-
currentAlternates:
|
|
20
|
+
currentAlternates: Ref<Record<string, string>, Record<string, string>>;
|
|
14
21
|
setAlternates: (alternates: Record<string, string>) => void;
|
|
15
22
|
};
|
|
16
23
|
//# sourceMappingURL=useLocale.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocale.d.ts","sourceRoot":"","sources":["../../src/composables/useLocale.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useLocale.d.ts","sourceRoot":"","sources":["../../src/composables/useLocale.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAGjD,MAAM,MAAM,MAAM,GAAG,MAAM,CAAA;AAW3B,MAAM,WAAW,eAAe;IAC/B,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IACnB,iBAAiB,EAAE,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CAC9C;AAED,eAAO,MAAM,eAAe,EAAE,YAAY,CAAC,eAAe,CAAyB,CAAA;AAEnF,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,GAAG,EAAE,aAAa,EAAE,MAAM,GAAG,eAAe,CAOlF;AAUD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,GAAE,eAA+B,GAAG,IAAI,CAQvF;AAED,wBAAgB,SAAS;;;mBAIF,MAAM;;gCAgBO,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;EAWzD"}
|
package/dist/content/routes.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
1
2
|
import { RouteRecordRaw, Router } from 'vue-router';
|
|
2
3
|
import { LocaleStrategy } from '../localeStrategy';
|
|
4
|
+
import { BloxApiClient } from '../api';
|
|
3
5
|
/**
|
|
4
6
|
* Generate vue-router route records for every registered content route.
|
|
5
7
|
*
|
|
@@ -34,7 +36,7 @@ export declare function generateContentRoutes(supportedLocales: string[], defaul
|
|
|
34
36
|
* Raw `<a href>` in CMS/editor content is handled at click-time by
|
|
35
37
|
* `installSmartLinks` (client) — orthogonal to this.
|
|
36
38
|
*/
|
|
37
|
-
export declare function installLocaleAwareResolve(router: Router, strategy: LocaleStrategy): void;
|
|
39
|
+
export declare function installLocaleAwareResolve(router: Router, strategy: LocaleStrategy, activeLocaleRef?: Ref<string>): void;
|
|
38
40
|
/**
|
|
39
41
|
* Cross-locale fallback for content detail routes.
|
|
40
42
|
*
|
|
@@ -43,5 +45,5 @@ export declare function installLocaleAwareResolve(router: Router, strategy: Loca
|
|
|
43
45
|
* Unknown entities fall back to the requested locale's home instead of leaving
|
|
44
46
|
* a detail URL that renders an empty site shell.
|
|
45
47
|
*/
|
|
46
|
-
export declare function installContentFallback(router: Router, supportedLocales: string[], defaultLocale: string): void;
|
|
48
|
+
export declare function installContentFallback(router: Router, supportedLocales: string[], defaultLocale: string, api?: BloxApiClient): void;
|
|
47
49
|
//# sourceMappingURL=routes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/content/routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/content/routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAC9B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AAQ3C;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CACpC,gBAAgB,EAAE,MAAM,EAAE,EAC1B,aAAa,EAAE,MAAM,GACnB,cAAc,EAAE,CA4BlB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,yBAAyB,CACxC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,cAAc,EACxB,eAAe,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GAC3B,IAAI,CA4BN;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACrC,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,MAAM,EAAE,EAC1B,aAAa,EAAE,MAAM,EACrB,GAAG,CAAC,EAAE,aAAa,GACjB,IAAI,CAmFN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useContentSeo.d.ts","sourceRoot":"","sources":["../../src/content/useContentSeo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,KAAK,CAAA;AAI3C,OAAO,EAA2B,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAG3E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAG7C,KAAK,QAAQ,GAAG,IAAI,CAAC,WAAW,EAAE,YAAY,CAAC,CAAA;AAE/C;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,CAC5B,IAAI,EAAE,gBAAgB,CAAC,WAAW,GAAG,IAAI,CAAC,EAC1C,IAAI,EAAE,MAAM,QAAQ,GAAG,IAAI,GAAG,SAAS,GACrC,IAAI,
|
|
1
|
+
{"version":3,"file":"useContentSeo.d.ts","sourceRoot":"","sources":["../../src/content/useContentSeo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,KAAK,CAAA;AAI3C,OAAO,EAA2B,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAG3E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAG7C,KAAK,QAAQ,GAAG,IAAI,CAAC,WAAW,EAAE,YAAY,CAAC,CAAA;AAE/C;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,CAC5B,IAAI,EAAE,gBAAgB,CAAC,WAAW,GAAG,IAAI,CAAC,EAC1C,IAAI,EAAE,MAAM,QAAQ,GAAG,IAAI,GAAG,SAAS,GACrC,IAAI,CA0DN"}
|
package/dist/core.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ import { BlockModule } from './defineBlock';
|
|
|
4
4
|
import { LocaleStrategy, StrategyOptions } from './localeStrategy';
|
|
5
5
|
import { BlockComponent, BlockDefinition } from './schema';
|
|
6
6
|
import { BloxAdminConfig } from './symbols';
|
|
7
|
+
export declare const BLOX_PREVIEW_ROUTE_NAME = "blox:preview";
|
|
8
|
+
export declare const BLOX_CMS_ROUTE_NAME = "blox:cms";
|
|
7
9
|
/** Either a full `{ component, schema }` definition or a self-defining component (used `defineBlock()`). */
|
|
8
10
|
export type BloxComponent = BlockDefinition | BlockComponent;
|
|
9
11
|
export interface BloxOptions extends StrategyOptions {
|
package/dist/core.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAa,MAAM,KAAK,CAAA;AACzC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,KAAK,EAAa,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AACvE,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAc,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAa,MAAM,KAAK,CAAA;AACzC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,KAAK,EAAa,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AACvE,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAc,MAAM,WAAW,CAAA;AAO5D,eAAO,MAAM,uBAAuB,iBAAiB,CAAA;AACrD,eAAO,MAAM,mBAAmB,aAAa,CAAA;AAa7C,4GAA4G;AAC5G,MAAM,MAAM,aAAa,GAAG,eAAe,GAAG,cAAc,CAAA;AAE5D,MAAM,WAAW,WAAY,SAAQ,eAAe;IACnD,qIAAqI;IACrI,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;IAC1C;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;IACrD,uEAAuE;IACvE,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,4EAA4E;IAC5E,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,kCAAkC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,gFAAgF;IAChF,SAAS,CAAC,EAAE,eAAe,CAAA;CAC3B;AAED,qBAAa,YAAY;IACxB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAsC;IAChE,OAAO,CAAC,gBAAgB,CAAQ;IAChC,OAAO,CAAC,OAAO,CAAY;IAC3B,OAAO,CAAC,SAAS,CAAgB;IACjC,OAAO,CAAC,UAAU,CAAC,CAAiB;gBAExB,OAAO,CAAC,EAAE,WAAW;IASjC,uEAAuE;IACvE,IAAI,QAAQ,IAAI,cAAc,CAE7B;IAED,eAAe,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,IAAI;IAiC3E,kBAAkB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,GAAG,IAAI;IA8BnE,+EAA+E;IAC/E,WAAW,IAAI,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC;IAI9C,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IA0CpC,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,IAAI;CAoC9C;AAMD,wBAAgB,UAAU,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,YAAY,CAS9D"}
|
package/dist/createBloxApp.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { App, Component, Plugin } from 'vue';
|
|
2
2
|
import { Router } from 'vue-router';
|
|
3
|
-
import { BloxInstance } from './core';
|
|
3
|
+
import { BloxOptions, BloxInstance } from './core';
|
|
4
4
|
import { BlockModule } from './defineBlock';
|
|
5
5
|
export interface CreateBloxAppOptions {
|
|
6
6
|
/** Root Vue component (App.vue). */
|
|
@@ -27,18 +27,15 @@ export interface CreateBloxAppOptions {
|
|
|
27
27
|
/** Mount target — CSS selector or Element. @default '#app' */
|
|
28
28
|
mount?: string | Element;
|
|
29
29
|
/**
|
|
30
|
-
* Callback to
|
|
31
|
-
* Receives `{ baseURL }` and should call your project's `createApi()
|
|
32
|
-
* and return `{ axios }` for collection cache interceptor installation.
|
|
30
|
+
* Callback to configure the shared project API instance.
|
|
31
|
+
* Receives `{ baseURL }` and should call your project's `createApi()`.
|
|
33
32
|
*
|
|
34
33
|
* If omitted, no project-level API is configured (the Blox internal
|
|
35
34
|
* fetch-based API still works via `configureApi`).
|
|
36
35
|
*/
|
|
37
36
|
createApi?: (opts: {
|
|
38
37
|
baseURL: string;
|
|
39
|
-
}) =>
|
|
40
|
-
axios?: AxiosLike;
|
|
41
|
-
};
|
|
38
|
+
}) => unknown;
|
|
42
39
|
/**
|
|
43
40
|
* Vue plugins to install on the app.
|
|
44
41
|
* Typically `[BagelVue]` from `@bagelink/vue`.
|
|
@@ -69,6 +66,8 @@ export interface CreateBloxAppOptions {
|
|
|
69
66
|
plausible?: string | PlausibleOptions;
|
|
70
67
|
/** CMS navigation mode. Marketing sites should use `document`. @default 'spa' */
|
|
71
68
|
navigation?: 'document' | 'spa';
|
|
69
|
+
/** Opt-in admin "edit this page" button configuration. */
|
|
70
|
+
adminEdit?: BloxOptions['adminEdit'];
|
|
72
71
|
}
|
|
73
72
|
/** Plausible Analytics injection options. */
|
|
74
73
|
export interface PlausibleOptions {
|
|
@@ -87,14 +86,6 @@ export interface PlausibleOptions {
|
|
|
87
86
|
* No-ops during SSR or if a script for the same domain already exists.
|
|
88
87
|
*/
|
|
89
88
|
export declare function injectPlausible(config: string | PlausibleOptions): void;
|
|
90
|
-
/** Minimal axios shape for interceptor installation. */
|
|
91
|
-
interface AxiosLike {
|
|
92
|
-
interceptors: {
|
|
93
|
-
request: {
|
|
94
|
-
use: (fn: (config: any) => any) => void;
|
|
95
|
-
};
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
89
|
export interface BloxAppResult {
|
|
99
90
|
app: App;
|
|
100
91
|
router: Router;
|
|
@@ -104,9 +95,9 @@ export interface BloxAppResult {
|
|
|
104
95
|
* One-liner factory to create and mount a Blox marketing/preview site.
|
|
105
96
|
*
|
|
106
97
|
* Handles the full ceremony:
|
|
107
|
-
* 1.
|
|
108
|
-
* 2.
|
|
109
|
-
* 3.
|
|
98
|
+
* 1. Configure project API
|
|
99
|
+
* 2. Create Vue app, Pinia, Blox, plugins
|
|
100
|
+
* 3. Hydrate when prerendered state is present
|
|
110
101
|
* 4. Mount after router is ready
|
|
111
102
|
*
|
|
112
103
|
* @example
|
|
@@ -135,5 +126,4 @@ export interface BloxAppResult {
|
|
|
135
126
|
* ```
|
|
136
127
|
*/
|
|
137
128
|
export declare function createBloxApp(options: CreateBloxAppOptions): BloxAppResult;
|
|
138
|
-
export {};
|
|
139
129
|
//# sourceMappingURL=createBloxApp.d.ts.map
|