@bagelink/blox 1.15.585 → 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
|
@@ -1,17 +1,18 @@
|
|
|
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 {
|
|
5
|
-
import {
|
|
6
|
-
import { r as resolvePageTitle, s as siteNameFromContexts, a as preserveCurrentSiteSuffix } from "./pageTitle-BOTMH-D8.js";
|
|
4
|
+
import { createPinia } from "pinia";
|
|
5
|
+
import { getCurrentInstance, inject, computed, ref, defineComponent, onMounted, unref, openBlock, createBlock, Teleport, createElementBlock, createElementVNode, createCommentVNode, h, provide, watch, resolveComponent, toDisplayString, createVNode, withCtx, createTextVNode, Fragment, shallowRef, onServerPrefetch, toValue, markRaw, resolveDynamicComponent } from "vue";
|
|
7
6
|
import { BLOX_WEBSITE_ID_WINDOW_KEY, BLOX_STATE_WINDOW_KEY } from "./ssg/client.mjs";
|
|
7
|
+
import { useRoute, useRouter } from "vue-router";
|
|
8
8
|
import { getI18n } from "@bagelink/vue";
|
|
9
|
+
import { r as resolvePageTitle, s as siteNameFromContexts, a as preserveCurrentSiteSuffix } from "./pageTitle-BOTMH-D8.js";
|
|
9
10
|
let BASE = "/api";
|
|
10
11
|
let _websiteName = "";
|
|
11
12
|
let _store = "";
|
|
12
13
|
let _websiteId = null;
|
|
13
14
|
let _origin = "";
|
|
14
|
-
|
|
15
|
+
const BLOX_API_KEY = Symbol("blox:api");
|
|
15
16
|
function configureApi(websiteName, store) {
|
|
16
17
|
_websiteName = websiteName;
|
|
17
18
|
_store = store;
|
|
@@ -26,8 +27,102 @@ function setApiOrigin(base) {
|
|
|
26
27
|
} catch {
|
|
27
28
|
}
|
|
28
29
|
}
|
|
29
|
-
function
|
|
30
|
-
|
|
30
|
+
function apiBase(base = "/api", origin = "") {
|
|
31
|
+
if (!origin) return { base, origin };
|
|
32
|
+
try {
|
|
33
|
+
const url = new URL(origin);
|
|
34
|
+
return {
|
|
35
|
+
origin: url.origin,
|
|
36
|
+
base: url.pathname && url.pathname !== "/" ? url.pathname.replace(/\/$/, "") : ""
|
|
37
|
+
};
|
|
38
|
+
} catch {
|
|
39
|
+
return { base, origin: "" };
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function createBloxApi(options) {
|
|
43
|
+
const configured = apiBase("/api", options.origin);
|
|
44
|
+
let websiteId = null;
|
|
45
|
+
async function scopedRequest(path, { locale: locale2, params, ...opts } = {}) {
|
|
46
|
+
const origin = configured.origin || (typeof window !== "undefined" ? window.location.origin : "");
|
|
47
|
+
const url = new URL(`${configured.base}${path}`, origin || void 0);
|
|
48
|
+
if (locale2) url.searchParams.set("locale", locale2);
|
|
49
|
+
if (params) {
|
|
50
|
+
for (const [key, value] of Object.entries(params)) url.searchParams.set(key, String(value));
|
|
51
|
+
}
|
|
52
|
+
const response = await fetch(url.toString(), opts);
|
|
53
|
+
if (!response.ok) throw new Error(`API ${response.status}: ${path}`);
|
|
54
|
+
if (response.status === 204) return null;
|
|
55
|
+
return response.json();
|
|
56
|
+
}
|
|
57
|
+
function getWebsiteIdSync2() {
|
|
58
|
+
if (websiteId) return websiteId;
|
|
59
|
+
if (typeof window === "undefined") return null;
|
|
60
|
+
const embedded = window[BLOX_WEBSITE_ID_WINDOW_KEY];
|
|
61
|
+
return typeof embedded === "string" && embedded !== "" ? embedded : null;
|
|
62
|
+
}
|
|
63
|
+
async function getWebsiteId2() {
|
|
64
|
+
const existing = getWebsiteIdSync2();
|
|
65
|
+
if (existing) {
|
|
66
|
+
websiteId = existing;
|
|
67
|
+
return existing;
|
|
68
|
+
}
|
|
69
|
+
try {
|
|
70
|
+
const website = await scopedRequest(
|
|
71
|
+
`/blox/sites/${encodeURIComponent(options.websiteName)}`
|
|
72
|
+
);
|
|
73
|
+
websiteId = website.id;
|
|
74
|
+
return website.id;
|
|
75
|
+
} catch {
|
|
76
|
+
throw new Error(`Website "${options.websiteName}" not found. Run: npm run seed`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
async function listItems2(collection, { locale: locale2, q, offset = 0, limit = 100 } = {}) {
|
|
80
|
+
if (options.collectionResolver) {
|
|
81
|
+
return await options.collectionResolver(collection, {
|
|
82
|
+
locale: locale2,
|
|
83
|
+
q,
|
|
84
|
+
offset,
|
|
85
|
+
limit
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
return scopedRequest(`/datastore/${options.store}/collections/${collection}`, {
|
|
89
|
+
locale: locale2,
|
|
90
|
+
params: { ...q ? { q } : {}, offset, limit }
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
getWebsiteIdSync: getWebsiteIdSync2,
|
|
95
|
+
getWebsiteId: getWebsiteId2,
|
|
96
|
+
resolvePath: async (path, locale2) => {
|
|
97
|
+
const id = await getWebsiteId2();
|
|
98
|
+
return scopedRequest(`/blox/websites/${id}/resolve-path`, {
|
|
99
|
+
locale: locale2,
|
|
100
|
+
params: { path }
|
|
101
|
+
});
|
|
102
|
+
},
|
|
103
|
+
listItems: listItems2,
|
|
104
|
+
getItemBySlug: async (collection, slug, locale2) => {
|
|
105
|
+
const result = await listItems2(collection, { locale: locale2, limit: 1e3 });
|
|
106
|
+
const items = Array.isArray(result) ? result : (result == null ? void 0 : result.items) ?? [];
|
|
107
|
+
return items.find((item) => String((item == null ? void 0 : item.slug) ?? "") === slug) ?? null;
|
|
108
|
+
},
|
|
109
|
+
getItemById: async (collection, id, locale2) => {
|
|
110
|
+
const result = await listItems2(collection, { locale: locale2, limit: 1e3 });
|
|
111
|
+
const items = Array.isArray(result) ? result : (result == null ? void 0 : result.items) ?? [];
|
|
112
|
+
return items.find((item) => {
|
|
113
|
+
const record = item;
|
|
114
|
+
return String((record == null ? void 0 : record.id) ?? (record == null ? void 0 : record._id) ?? "") === id;
|
|
115
|
+
}) ?? null;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
function provideBloxApi(app, options) {
|
|
120
|
+
const client = createBloxApi(options);
|
|
121
|
+
app.provide(BLOX_API_KEY, client);
|
|
122
|
+
return client;
|
|
123
|
+
}
|
|
124
|
+
function useBloxApi() {
|
|
125
|
+
return getCurrentInstance() ? inject(BLOX_API_KEY, null) : null;
|
|
31
126
|
}
|
|
32
127
|
async function request(path, { locale: locale2, params, ...opts } = {}) {
|
|
33
128
|
const origin = _origin || (typeof window !== "undefined" ? window.location.origin : "");
|
|
@@ -77,27 +172,28 @@ async function resolvePath(path, locale2) {
|
|
|
77
172
|
});
|
|
78
173
|
}
|
|
79
174
|
async function listItems(collection, { locale: locale2, q, offset = 0, limit = 100 } = {}) {
|
|
80
|
-
if (_collectionResolver) {
|
|
81
|
-
return await _collectionResolver(collection, { locale: locale2, q, offset, limit });
|
|
82
|
-
}
|
|
83
175
|
return request(`/datastore/${_store}/collections/${collection}`, {
|
|
84
176
|
locale: locale2,
|
|
85
177
|
params: { ...q ? { q } : {}, offset, limit }
|
|
86
178
|
});
|
|
87
179
|
}
|
|
88
180
|
async function getItemBySlug(collection, slug, locale2) {
|
|
89
|
-
const res = await
|
|
181
|
+
const res = await listItemsFromActiveApi(collection, { locale: locale2, limit: 1e3 });
|
|
90
182
|
const items = Array.isArray(res) ? res : (res == null ? void 0 : res.items) ?? [];
|
|
91
183
|
return items.find((item) => String((item == null ? void 0 : item.slug) ?? "") === slug) ?? null;
|
|
92
184
|
}
|
|
93
185
|
async function getItemById(collection, id, locale2) {
|
|
94
|
-
const res = await
|
|
186
|
+
const res = await listItemsFromActiveApi(collection, { locale: locale2, limit: 1e3 });
|
|
95
187
|
const items = Array.isArray(res) ? res : (res == null ? void 0 : res.items) ?? [];
|
|
96
188
|
return items.find((item) => {
|
|
97
189
|
const record = item;
|
|
98
190
|
return String((record == null ? void 0 : record.id) ?? (record == null ? void 0 : record._id) ?? "") === id;
|
|
99
191
|
}) ?? null;
|
|
100
192
|
}
|
|
193
|
+
function listItemsFromActiveApi(collection, options = {}) {
|
|
194
|
+
var _a;
|
|
195
|
+
return ((_a = useBloxApi()) == null ? void 0 : _a.listItems(collection, options)) ?? listItems(collection, options);
|
|
196
|
+
}
|
|
101
197
|
const BLOX_REGISTRY_KEY = Symbol("blox:registry");
|
|
102
198
|
const BLOX_CONFIG_KEY = Symbol("blox:config");
|
|
103
199
|
const BLOX_LOCALE_STRATEGY_KEY = Symbol("blox:locale-strategy");
|
|
@@ -201,8 +297,24 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
201
297
|
const _hasStorage = typeof localStorage !== "undefined";
|
|
202
298
|
const locale = ref((_hasStorage ? localStorage.getItem("blox:locale") : null) || "en");
|
|
203
299
|
const currentAlternates = ref({});
|
|
204
|
-
|
|
205
|
-
|
|
300
|
+
const BLOX_LOCALE_KEY = Symbol("blox:locale");
|
|
301
|
+
function provideBloxLocale(app, initialLocale) {
|
|
302
|
+
const state = {
|
|
303
|
+
locale: ref(initialLocale),
|
|
304
|
+
currentAlternates: ref({})
|
|
305
|
+
};
|
|
306
|
+
app.provide(BLOX_LOCALE_KEY, state);
|
|
307
|
+
return state;
|
|
308
|
+
}
|
|
309
|
+
function localeState() {
|
|
310
|
+
if (getCurrentInstance()) {
|
|
311
|
+
const state = inject(BLOX_LOCALE_KEY, null);
|
|
312
|
+
if (state) return state;
|
|
313
|
+
}
|
|
314
|
+
return { locale, currentAlternates };
|
|
315
|
+
}
|
|
316
|
+
function setActiveLocale(l, state = localeState()) {
|
|
317
|
+
state.locale.value = l;
|
|
206
318
|
try {
|
|
207
319
|
const i18n = getI18n();
|
|
208
320
|
if (i18n == null ? void 0 : i18n.global) i18n.global.locale.value = l;
|
|
@@ -210,9 +322,10 @@ function setActiveLocale(l) {
|
|
|
210
322
|
}
|
|
211
323
|
}
|
|
212
324
|
function useLocale() {
|
|
213
|
-
const
|
|
325
|
+
const state = localeState();
|
|
326
|
+
const dir = computed(() => state.locale.value === "he" || state.locale.value === "ar" ? "rtl" : "ltr");
|
|
214
327
|
function setLocale(l) {
|
|
215
|
-
locale.value = l;
|
|
328
|
+
state.locale.value = l;
|
|
216
329
|
if (typeof localStorage !== "undefined") localStorage.setItem("blox:locale", l);
|
|
217
330
|
if (typeof document !== "undefined") {
|
|
218
331
|
document.documentElement.lang = l;
|
|
@@ -225,9 +338,15 @@ function useLocale() {
|
|
|
225
338
|
}
|
|
226
339
|
}
|
|
227
340
|
function setAlternates(alternates) {
|
|
228
|
-
currentAlternates.value = alternates;
|
|
341
|
+
state.currentAlternates.value = alternates;
|
|
229
342
|
}
|
|
230
|
-
return {
|
|
343
|
+
return {
|
|
344
|
+
locale: state.locale,
|
|
345
|
+
dir,
|
|
346
|
+
setLocale,
|
|
347
|
+
currentAlternates: state.currentAlternates,
|
|
348
|
+
setAlternates
|
|
349
|
+
};
|
|
231
350
|
}
|
|
232
351
|
function pathExcluded(path, patterns) {
|
|
233
352
|
if (!(patterns == null ? void 0 : patterns.length)) return false;
|
|
@@ -360,12 +479,13 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
360
479
|
const { locale: locale2, setLocale, setAlternates } = useLocale();
|
|
361
480
|
const strategy = inject(BLOX_LOCALE_STRATEGY_KEY, null);
|
|
362
481
|
const ssrRouteState = inject(BLOX_SSR_ROUTE_STATE_KEY, null);
|
|
482
|
+
const api = useBloxApi();
|
|
363
483
|
const blocks = ref([]);
|
|
364
484
|
const contexts = ref({});
|
|
365
485
|
provide("contexts", contexts);
|
|
366
486
|
const adminConfig = inject(BLOX_ADMIN_CONFIG_KEY, null);
|
|
367
487
|
const currentPageId = ref(null);
|
|
368
|
-
const websiteId = ref(getWebsiteIdSync());
|
|
488
|
+
const websiteId = ref((api == null ? void 0 : api.getWebsiteIdSync()) ?? getWebsiteIdSync());
|
|
369
489
|
const notFound = ref(false);
|
|
370
490
|
const error = ref(null);
|
|
371
491
|
const initialLoading = ref(true);
|
|
@@ -445,7 +565,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
445
565
|
}
|
|
446
566
|
navigating.value = true;
|
|
447
567
|
try {
|
|
448
|
-
const resolved = await resolvePath(slug, urlLocale);
|
|
568
|
+
const resolved = await ((api == null ? void 0 : api.resolvePath(slug, urlLocale)) ?? resolvePath(slug, urlLocale));
|
|
449
569
|
blocks.value = ((_a = resolved.page.content) == null ? void 0 : _a.blocks) ?? [];
|
|
450
570
|
contexts.value = resolved.contexts ?? {};
|
|
451
571
|
currentPageId.value = resolved.page.id ?? null;
|
|
@@ -470,7 +590,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
470
590
|
watch(currentRoutePath, load);
|
|
471
591
|
onMounted(() => {
|
|
472
592
|
if (adminConfig && !websiteId.value) {
|
|
473
|
-
getWebsiteId().then((id) => {
|
|
593
|
+
((api == null ? void 0 : api.getWebsiteId()) ?? getWebsiteId()).then((id) => {
|
|
474
594
|
websiteId.value = id;
|
|
475
595
|
}).catch(() => {
|
|
476
596
|
});
|
|
@@ -517,7 +637,6 @@ function provideBloxData(app, opts = {}) {
|
|
|
517
637
|
seoSources: []
|
|
518
638
|
};
|
|
519
639
|
app.provide(BLOX_DATA_KEY, registry2);
|
|
520
|
-
globalThis.__BLOX_DATA_REGISTRY__ = registry2;
|
|
521
640
|
return registry2;
|
|
522
641
|
}
|
|
523
642
|
function readPayload() {
|
|
@@ -533,7 +652,7 @@ function getRegistry() {
|
|
|
533
652
|
const injected = inject(BLOX_DATA_KEY, null);
|
|
534
653
|
if (injected) return injected;
|
|
535
654
|
}
|
|
536
|
-
return
|
|
655
|
+
return null;
|
|
537
656
|
}
|
|
538
657
|
function getRegistryData() {
|
|
539
658
|
return getRegistry();
|
|
@@ -839,6 +958,8 @@ function createLocaleStrategy(options) {
|
|
|
839
958
|
supportedLocales: options.supportedLocales ?? []
|
|
840
959
|
});
|
|
841
960
|
}
|
|
961
|
+
const BLOX_PREVIEW_ROUTE_NAME = "blox:preview";
|
|
962
|
+
const BLOX_CMS_ROUTE_NAME = "blox:cms";
|
|
842
963
|
function applyDefaultsToFields(schema, defaults) {
|
|
843
964
|
var _a;
|
|
844
965
|
if (!schema || !defaults) return;
|
|
@@ -943,12 +1064,22 @@ class BloxInstance {
|
|
|
943
1064
|
}
|
|
944
1065
|
});
|
|
945
1066
|
}
|
|
946
|
-
router.
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
1067
|
+
if (!router.hasRoute(BLOX_PREVIEW_ROUTE_NAME)) {
|
|
1068
|
+
router.addRoute({
|
|
1069
|
+
path: "/_blox_preview",
|
|
1070
|
+
name: BLOX_PREVIEW_ROUTE_NAME,
|
|
1071
|
+
component: () => import("./PreviewApp-BagepqPk.js"),
|
|
1072
|
+
beforeEnter: () => typeof window === "undefined" || window.parent !== window ? true : "/"
|
|
1073
|
+
});
|
|
1074
|
+
}
|
|
1075
|
+
if (!router.hasRoute(BLOX_CMS_ROUTE_NAME)) {
|
|
1076
|
+
router.addRoute({
|
|
1077
|
+
path: "/:pathMatch(.*)*",
|
|
1078
|
+
name: BLOX_CMS_ROUTE_NAME,
|
|
1079
|
+
component: _sfc_main$2,
|
|
1080
|
+
meta: { navigation: "document" }
|
|
1081
|
+
});
|
|
1082
|
+
}
|
|
952
1083
|
this._routeRegistered = true;
|
|
953
1084
|
return this;
|
|
954
1085
|
}
|
|
@@ -1049,7 +1180,7 @@ function useContentItem(collectionArg, slugArg) {
|
|
|
1049
1180
|
const c = coll();
|
|
1050
1181
|
const s = slg();
|
|
1051
1182
|
if (!c || !s) return null;
|
|
1052
|
-
const res = await
|
|
1183
|
+
const res = await listItemsFromActiveApi(c, { locale: loc(), limit: 1e3 });
|
|
1053
1184
|
const items = Array.isArray(res) ? res : (res == null ? void 0 : res.items) ?? [];
|
|
1054
1185
|
return items.find((it) => String((it == null ? void 0 : it.slug) ?? "") === s) ?? null;
|
|
1055
1186
|
},
|
|
@@ -1166,8 +1297,8 @@ function generateContentRoutes(supportedLocales, defaultLocale) {
|
|
|
1166
1297
|
}
|
|
1167
1298
|
return records;
|
|
1168
1299
|
}
|
|
1169
|
-
function installLocaleAwareResolve(router, strategy) {
|
|
1170
|
-
const
|
|
1300
|
+
function installLocaleAwareResolve(router, strategy, activeLocaleRef) {
|
|
1301
|
+
const locale2 = activeLocaleRef ?? useLocale().locale;
|
|
1171
1302
|
const supported = strategy.locales;
|
|
1172
1303
|
const defaultLocale = strategy.defaultLocale;
|
|
1173
1304
|
const activeLocale = () => String(locale2.value || "").slice(0, 2).toLowerCase() || defaultLocale;
|
|
@@ -1189,7 +1320,7 @@ function installLocaleAwareResolve(router, strategy) {
|
|
|
1189
1320
|
return originalResolve(to, currentLocation);
|
|
1190
1321
|
};
|
|
1191
1322
|
}
|
|
1192
|
-
function installContentFallback(router, supportedLocales, defaultLocale) {
|
|
1323
|
+
function installContentFallback(router, supportedLocales, defaultLocale, api) {
|
|
1193
1324
|
const localeOf = (path) => {
|
|
1194
1325
|
const first = path.replace(/^\//, "").split("/")[0];
|
|
1195
1326
|
return first && supportedLocales.includes(first) ? first : defaultLocale;
|
|
@@ -1208,11 +1339,15 @@ function installContentFallback(router, supportedLocales, defaultLocale) {
|
|
|
1208
1339
|
}
|
|
1209
1340
|
let here;
|
|
1210
1341
|
try {
|
|
1211
|
-
here = await getItemBySlug(
|
|
1342
|
+
here = await ((api == null ? void 0 : api.getItemBySlug(
|
|
1212
1343
|
registration.collection,
|
|
1213
1344
|
slug,
|
|
1214
1345
|
urlLocale
|
|
1215
|
-
)
|
|
1346
|
+
)) ?? getItemBySlug(
|
|
1347
|
+
registration.collection,
|
|
1348
|
+
slug,
|
|
1349
|
+
urlLocale
|
|
1350
|
+
));
|
|
1216
1351
|
} catch {
|
|
1217
1352
|
return true;
|
|
1218
1353
|
}
|
|
@@ -1221,11 +1356,15 @@ function installContentFallback(router, supportedLocales, defaultLocale) {
|
|
|
1221
1356
|
if (sourceLocale === urlLocale) continue;
|
|
1222
1357
|
let source;
|
|
1223
1358
|
try {
|
|
1224
|
-
source = await getItemBySlug(
|
|
1359
|
+
source = await ((api == null ? void 0 : api.getItemBySlug(
|
|
1360
|
+
registration.collection,
|
|
1361
|
+
slug,
|
|
1362
|
+
sourceLocale
|
|
1363
|
+
)) ?? getItemBySlug(
|
|
1225
1364
|
registration.collection,
|
|
1226
1365
|
slug,
|
|
1227
1366
|
sourceLocale
|
|
1228
|
-
);
|
|
1367
|
+
));
|
|
1229
1368
|
} catch {
|
|
1230
1369
|
return true;
|
|
1231
1370
|
}
|
|
@@ -1233,11 +1372,15 @@ function installContentFallback(router, supportedLocales, defaultLocale) {
|
|
|
1233
1372
|
if (!id) continue;
|
|
1234
1373
|
let target;
|
|
1235
1374
|
try {
|
|
1236
|
-
target = await getItemById(
|
|
1375
|
+
target = await ((api == null ? void 0 : api.getItemById(
|
|
1376
|
+
registration.collection,
|
|
1377
|
+
id,
|
|
1378
|
+
urlLocale
|
|
1379
|
+
)) ?? getItemById(
|
|
1237
1380
|
registration.collection,
|
|
1238
1381
|
id,
|
|
1239
1382
|
urlLocale
|
|
1240
|
-
);
|
|
1383
|
+
));
|
|
1241
1384
|
} catch {
|
|
1242
1385
|
return true;
|
|
1243
1386
|
}
|
|
@@ -1255,59 +1398,114 @@ function hasEmbeddedContentItem(collection, slug, locale2) {
|
|
|
1255
1398
|
if (!payload || typeof payload !== "object" || Array.isArray(payload)) return false;
|
|
1256
1399
|
return `content:${collection}:${slug}:${locale2}` in payload;
|
|
1257
1400
|
}
|
|
1401
|
+
function installBloxRuntime(options) {
|
|
1402
|
+
const {
|
|
1403
|
+
app,
|
|
1404
|
+
router,
|
|
1405
|
+
modules,
|
|
1406
|
+
websiteName,
|
|
1407
|
+
store,
|
|
1408
|
+
locale: locale2,
|
|
1409
|
+
supportedLocales,
|
|
1410
|
+
plugins = [],
|
|
1411
|
+
globalComponents = {},
|
|
1412
|
+
setup,
|
|
1413
|
+
adminEdit,
|
|
1414
|
+
contentFallback = false,
|
|
1415
|
+
api,
|
|
1416
|
+
localeState: localeState2
|
|
1417
|
+
} = options;
|
|
1418
|
+
const blox = createBlox({
|
|
1419
|
+
modules,
|
|
1420
|
+
websiteName,
|
|
1421
|
+
store,
|
|
1422
|
+
defaultLocale: locale2,
|
|
1423
|
+
supportedLocales,
|
|
1424
|
+
router,
|
|
1425
|
+
adminEdit
|
|
1426
|
+
});
|
|
1427
|
+
const pinia = createPinia();
|
|
1428
|
+
pinia.use(({ store: piniaStore }) => {
|
|
1429
|
+
piniaStore.router = markRaw(router);
|
|
1430
|
+
});
|
|
1431
|
+
app.use(pinia);
|
|
1432
|
+
app.use(router);
|
|
1433
|
+
blox.install(app, {});
|
|
1434
|
+
for (const record of generateContentRoutes(supportedLocales, locale2)) {
|
|
1435
|
+
if (!router.hasRoute(record.name)) router.addRoute(record);
|
|
1436
|
+
}
|
|
1437
|
+
if (contentFallback) installContentFallback(router, supportedLocales, locale2, api);
|
|
1438
|
+
installLocaleAwareResolve(router, blox.strategy, localeState2.locale);
|
|
1439
|
+
for (const plugin of plugins) {
|
|
1440
|
+
if (Array.isArray(plugin)) {
|
|
1441
|
+
const [vuePlugin, ...args] = plugin;
|
|
1442
|
+
app.use(vuePlugin, ...args);
|
|
1443
|
+
} else {
|
|
1444
|
+
app.use(plugin);
|
|
1445
|
+
}
|
|
1446
|
+
}
|
|
1447
|
+
for (const [name, component] of Object.entries(globalComponents)) {
|
|
1448
|
+
app.component(name, component);
|
|
1449
|
+
}
|
|
1450
|
+
setup == null ? void 0 : setup(app);
|
|
1451
|
+
return blox;
|
|
1452
|
+
}
|
|
1258
1453
|
export {
|
|
1259
|
-
|
|
1260
|
-
|
|
1454
|
+
toInternalPath as $,
|
|
1455
|
+
BloxInstance as A,
|
|
1261
1456
|
BLOX_DATA_WINDOW_KEY as B,
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
_sfc_main
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1457
|
+
_sfc_main$2 as C,
|
|
1458
|
+
_sfc_main$1 as D,
|
|
1459
|
+
_sfc_main as E,
|
|
1460
|
+
applyLayoutChrome as F,
|
|
1461
|
+
classifyLink as G,
|
|
1462
|
+
configureApi as H,
|
|
1463
|
+
contentRoutes as I,
|
|
1464
|
+
createBlox as J,
|
|
1465
|
+
createBloxApi as K,
|
|
1271
1466
|
defineContent as L,
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1467
|
+
generateContentRoutes as M,
|
|
1468
|
+
getContentRouteByCollection as N,
|
|
1469
|
+
getWebsiteId as O,
|
|
1275
1470
|
PageRenderer as P,
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1471
|
+
getWebsiteIdSync as Q,
|
|
1472
|
+
installContentFallback as R,
|
|
1473
|
+
isAbsoluteExternal as S,
|
|
1474
|
+
isSoloContentPage as T,
|
|
1475
|
+
isSpecialScheme as U,
|
|
1476
|
+
listItems as V,
|
|
1477
|
+
normalizeTo as W,
|
|
1478
|
+
provideContentItem as X,
|
|
1479
|
+
resolvePath as Y,
|
|
1480
|
+
setApiOrigin as Z,
|
|
1286
1481
|
_sfc_main$3 as _,
|
|
1287
|
-
|
|
1288
|
-
|
|
1482
|
+
collectBloxSeo as a,
|
|
1483
|
+
useBloxEdit as a0,
|
|
1484
|
+
useContentItem as a1,
|
|
1485
|
+
useData as a2,
|
|
1486
|
+
provideBloxApi as b,
|
|
1289
1487
|
collectBloxData as c,
|
|
1290
|
-
|
|
1488
|
+
provideBloxLocale as d,
|
|
1291
1489
|
BLOX_SSR_ROUTE_STATE_KEY as e,
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1490
|
+
BLOX_REGISTRY_KEY as f,
|
|
1491
|
+
BLOX_RUNTIME_KEY as g,
|
|
1492
|
+
BLOX_LOCALE_STRATEGY_KEY as h,
|
|
1493
|
+
installBloxRuntime as i,
|
|
1494
|
+
useBloxApi as j,
|
|
1495
|
+
useSeo as k,
|
|
1496
|
+
getRegistryData as l,
|
|
1497
|
+
getItemBySlug as m,
|
|
1300
1498
|
normalizeLink as n,
|
|
1301
|
-
|
|
1499
|
+
getItemById as o,
|
|
1302
1500
|
provideBloxData as p,
|
|
1303
|
-
|
|
1501
|
+
getContentRoute as q,
|
|
1304
1502
|
resolveBlockProps as r,
|
|
1305
|
-
|
|
1306
|
-
|
|
1503
|
+
setActiveLocale as s,
|
|
1504
|
+
installSmartLinks as t,
|
|
1307
1505
|
useLocale as u,
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1506
|
+
consumePendingLocaleSwitch as v,
|
|
1507
|
+
BLOX_ADMIN_CONFIG_KEY as w,
|
|
1508
|
+
BLOX_CONFIG_KEY as x,
|
|
1509
|
+
BLOX_DATA_KEY as y,
|
|
1510
|
+
BLOX_LAYOUT_KEY as z
|
|
1313
1511
|
};
|