@bagelink/blox 1.15.553 → 1.15.555
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/dist/createBloxApp.d.ts.map +1 -1
- package/dist/index.cjs +9 -4
- package/dist/index.mjs +9 -4
- package/dist/ssg/createSSREntry.d.ts +9 -0
- package/dist/ssg/createSSREntry.d.ts.map +1 -1
- package/dist/ssg/index.cjs +36 -3
- package/dist/ssg/index.mjs +36 -3
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createBloxApp.d.ts","sourceRoot":"","sources":["../src/createBloxApp.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,YAAY,EAAE,MAAM,QAAQ,CAAA;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAYhD,MAAM,WAAW,oBAAoB;IACpC,oCAAoC;IACpC,aAAa,EAAE,SAAS,CAAA;IACxB,2BAA2B;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd;;;;;OAKG;IACH,OAAO,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;IACpD,4EAA4E;IAC5E,WAAW,EAAE,MAAM,CAAA;IACnB,kCAAkC;IAClC,KAAK,EAAE,MAAM,CAAA;IACb,yCAAyC;IACzC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,kDAAkD;IAClD,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC3B,oCAAoC;IACpC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,8DAA8D;IAC9D,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IACxB;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,CAAC,I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,CAAC,EAAE,MAAM,GAAG,gBAAgB,CAAA;CACrC;AAED,6CAA6C;AAC7C,MAAM,WAAW,gBAAgB;IAChC,gGAAgG;IAChG,MAAM,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,wEAAwE;IACxE,OAAO,CAAC,EAAE,MAAM,CAAA;CAChB;AAID;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI,CAoCvE;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,CAyK1E"}
|
package/dist/index.cjs
CHANGED
|
@@ -268,18 +268,23 @@ function createBloxApp(options) {
|
|
|
268
268
|
return first && supportedLocales.includes(first) ? first : locale;
|
|
269
269
|
};
|
|
270
270
|
router.beforeEach((to, from) => {
|
|
271
|
+
var _a2;
|
|
272
|
+
const browserPath = typeof window !== "undefined" ? `${window.location.pathname}${window.location.search}${window.location.hash}` : "/";
|
|
273
|
+
const toPath = typeof (to == null ? void 0 : to.path) === "string" ? to.path : browserPath;
|
|
274
|
+
const toFullPath = typeof (to == null ? void 0 : to.fullPath) === "string" ? to.fullPath : toPath;
|
|
275
|
+
const fromPath = typeof (from == null ? void 0 : from.path) === "string" ? from.path : "";
|
|
271
276
|
const switched = routes.consumePendingLocaleSwitch();
|
|
272
277
|
if (switched != null) {
|
|
273
278
|
routes.setActiveLocale(switched);
|
|
274
279
|
return true;
|
|
275
280
|
}
|
|
276
|
-
const intended =
|
|
277
|
-
const normalized = strategy.normalize(
|
|
278
|
-
if (normalized && normalized !==
|
|
281
|
+
const intended = fromPath && ((_a2 = from == null ? void 0 : from.matched) == null ? void 0 : _a2.length) ? localeOf(fromPath) : localeOf(toPath);
|
|
282
|
+
const normalized = strategy.normalize(toFullPath, intended);
|
|
283
|
+
if (normalized && normalized !== toFullPath) {
|
|
279
284
|
routes.setActiveLocale(localeOf(normalized));
|
|
280
285
|
return normalized;
|
|
281
286
|
}
|
|
282
|
-
routes.setActiveLocale(localeOf(
|
|
287
|
+
routes.setActiveLocale(localeOf(toPath));
|
|
283
288
|
return true;
|
|
284
289
|
});
|
|
285
290
|
const initialPath = typeof window !== "undefined" && ((_a = window.location) == null ? void 0 : _a.pathname) ? window.location.pathname : router.currentRoute.value.path;
|
package/dist/index.mjs
CHANGED
|
@@ -267,18 +267,23 @@ function createBloxApp(options) {
|
|
|
267
267
|
return first && supportedLocales.includes(first) ? first : locale;
|
|
268
268
|
};
|
|
269
269
|
router.beforeEach((to, from) => {
|
|
270
|
+
var _a2;
|
|
271
|
+
const browserPath = typeof window !== "undefined" ? `${window.location.pathname}${window.location.search}${window.location.hash}` : "/";
|
|
272
|
+
const toPath = typeof (to == null ? void 0 : to.path) === "string" ? to.path : browserPath;
|
|
273
|
+
const toFullPath = typeof (to == null ? void 0 : to.fullPath) === "string" ? to.fullPath : toPath;
|
|
274
|
+
const fromPath = typeof (from == null ? void 0 : from.path) === "string" ? from.path : "";
|
|
270
275
|
const switched = consumePendingLocaleSwitch();
|
|
271
276
|
if (switched != null) {
|
|
272
277
|
setActiveLocale(switched);
|
|
273
278
|
return true;
|
|
274
279
|
}
|
|
275
|
-
const intended =
|
|
276
|
-
const normalized = strategy.normalize(
|
|
277
|
-
if (normalized && normalized !==
|
|
280
|
+
const intended = fromPath && ((_a2 = from == null ? void 0 : from.matched) == null ? void 0 : _a2.length) ? localeOf(fromPath) : localeOf(toPath);
|
|
281
|
+
const normalized = strategy.normalize(toFullPath, intended);
|
|
282
|
+
if (normalized && normalized !== toFullPath) {
|
|
278
283
|
setActiveLocale(localeOf(normalized));
|
|
279
284
|
return normalized;
|
|
280
285
|
}
|
|
281
|
-
setActiveLocale(localeOf(
|
|
286
|
+
setActiveLocale(localeOf(toPath));
|
|
282
287
|
return true;
|
|
283
288
|
});
|
|
284
289
|
const initialPath = typeof window !== "undefined" && ((_a = window.location) == null ? void 0 : _a.pathname) ? window.location.pathname : router.currentRoute.value.path;
|
|
@@ -57,8 +57,17 @@ export interface BloxSSREntry {
|
|
|
57
57
|
}
|
|
58
58
|
interface PublishedPage {
|
|
59
59
|
slug?: string;
|
|
60
|
+
data_bindings?: Record<string, {
|
|
61
|
+
adapter?: string;
|
|
62
|
+
collection?: string;
|
|
63
|
+
bind_by?: string;
|
|
64
|
+
}>;
|
|
60
65
|
}
|
|
61
66
|
export declare function matchPublishedPage(pages: PublishedPage[], slug: string, allowTemplates?: boolean): PublishedPage | null;
|
|
67
|
+
export declare function resolvePublishedPage(pages: PublishedPage[], slug: string, locale: string, resolver?: CreateBloxSSREntryOptions['collectionResolver']): Promise<{
|
|
68
|
+
page: PublishedPage;
|
|
69
|
+
contexts: Record<string, Record<string, unknown> | null>;
|
|
70
|
+
} | null>;
|
|
62
71
|
/**
|
|
63
72
|
* Factory that produces the `{ render }` export for `main.server.ts`.
|
|
64
73
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSSREntry.d.ts","sourceRoot":"","sources":["../../src/ssg/createSSREntry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AACzC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,KAAK,EAAE,aAAa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B,IAAI,EAAE,MAAM,EACZ,cAAc,UAAQ,GACpB,aAAa,GAAG,IAAI,CAUtB;AAaD,wBAAsB,oBAAoB,CACzC,KAAK,EAAE,aAAa,EAAE,EACtB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,QAAQ,CAAC,EAAE,yBAAyB,CAAC,oBAAoB,CAAC,GACxD,OAAO,CAAC;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC,CAAA;CAAE,GAAG,IAAI,CAAC,CAoBnG;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,yBAAyB,GAAG,YAAY,CA2NnF"}
|
package/dist/ssg/index.cjs
CHANGED
|
@@ -138,6 +138,38 @@ function matchPublishedPage(pages, slug, allowTemplates = false) {
|
|
|
138
138
|
}
|
|
139
139
|
return null;
|
|
140
140
|
}
|
|
141
|
+
function templateParams(template, slug) {
|
|
142
|
+
const names = [];
|
|
143
|
+
const pattern = template.replace(/:([a-z_]+)/g, (_match, name) => {
|
|
144
|
+
names.push(name);
|
|
145
|
+
return "([^/]+)";
|
|
146
|
+
});
|
|
147
|
+
const match = slug.match(new RegExp(`^${pattern}$`));
|
|
148
|
+
if (!match) return null;
|
|
149
|
+
return Object.fromEntries(names.map((name, index) => [name, match[index + 1]]));
|
|
150
|
+
}
|
|
151
|
+
async function resolvePublishedPage(pages, slug, locale, resolver) {
|
|
152
|
+
var _a;
|
|
153
|
+
const page = matchPublishedPage(pages, slug, true);
|
|
154
|
+
if (!page) return null;
|
|
155
|
+
const params = ((_a = page.slug) == null ? void 0 : _a.includes(":")) ? templateParams(page.slug, slug) : {};
|
|
156
|
+
const contexts = {};
|
|
157
|
+
if (params && resolver) {
|
|
158
|
+
for (const [name, binding] of Object.entries(page.data_bindings ?? {})) {
|
|
159
|
+
if (binding.adapter !== "datastore" || !binding.collection || !binding.bind_by) continue;
|
|
160
|
+
const value = params[binding.bind_by];
|
|
161
|
+
if (!value) continue;
|
|
162
|
+
const escaped = value.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
|
163
|
+
const items = await resolver(binding.collection, {
|
|
164
|
+
locale,
|
|
165
|
+
q: `${binding.bind_by} eq "${escaped}"`,
|
|
166
|
+
limit: 1
|
|
167
|
+
});
|
|
168
|
+
contexts[name] = items[0] ?? null;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return { page, contexts };
|
|
172
|
+
}
|
|
141
173
|
function createBloxSSREntry(options) {
|
|
142
174
|
var _a;
|
|
143
175
|
const {
|
|
@@ -199,12 +231,13 @@ function createBloxSSREntry(options) {
|
|
|
199
231
|
publishedBundleCache.set(cacheKey, pending);
|
|
200
232
|
}
|
|
201
233
|
const bundle = await pending;
|
|
202
|
-
const
|
|
234
|
+
const resolved = await resolvePublishedPage(
|
|
203
235
|
bundle.pages,
|
|
204
236
|
slug,
|
|
205
|
-
|
|
237
|
+
pageLocale,
|
|
238
|
+
options.resolvePublishedPaths ? options.collectionResolver : void 0
|
|
206
239
|
);
|
|
207
|
-
return
|
|
240
|
+
return resolved ? { ...resolved, warnings: [] } : null;
|
|
208
241
|
}
|
|
209
242
|
const url = `${apiBase}/blox/websites/${websiteId}/resolve-path?path=${encodeURIComponent(slug)}&locale=${pageLocale}`;
|
|
210
243
|
return llmArtifacts.bloxBuildJson(url, {}, options.buildRequest);
|
package/dist/ssg/index.mjs
CHANGED
|
@@ -116,6 +116,38 @@ function matchPublishedPage(pages, slug, allowTemplates = false) {
|
|
|
116
116
|
}
|
|
117
117
|
return null;
|
|
118
118
|
}
|
|
119
|
+
function templateParams(template, slug) {
|
|
120
|
+
const names = [];
|
|
121
|
+
const pattern = template.replace(/:([a-z_]+)/g, (_match, name) => {
|
|
122
|
+
names.push(name);
|
|
123
|
+
return "([^/]+)";
|
|
124
|
+
});
|
|
125
|
+
const match = slug.match(new RegExp(`^${pattern}$`));
|
|
126
|
+
if (!match) return null;
|
|
127
|
+
return Object.fromEntries(names.map((name, index) => [name, match[index + 1]]));
|
|
128
|
+
}
|
|
129
|
+
async function resolvePublishedPage(pages, slug, locale, resolver) {
|
|
130
|
+
var _a;
|
|
131
|
+
const page = matchPublishedPage(pages, slug, true);
|
|
132
|
+
if (!page) return null;
|
|
133
|
+
const params = ((_a = page.slug) == null ? void 0 : _a.includes(":")) ? templateParams(page.slug, slug) : {};
|
|
134
|
+
const contexts = {};
|
|
135
|
+
if (params && resolver) {
|
|
136
|
+
for (const [name, binding] of Object.entries(page.data_bindings ?? {})) {
|
|
137
|
+
if (binding.adapter !== "datastore" || !binding.collection || !binding.bind_by) continue;
|
|
138
|
+
const value = params[binding.bind_by];
|
|
139
|
+
if (!value) continue;
|
|
140
|
+
const escaped = value.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
|
141
|
+
const items = await resolver(binding.collection, {
|
|
142
|
+
locale,
|
|
143
|
+
q: `${binding.bind_by} eq "${escaped}"`,
|
|
144
|
+
limit: 1
|
|
145
|
+
});
|
|
146
|
+
contexts[name] = items[0] ?? null;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return { page, contexts };
|
|
150
|
+
}
|
|
119
151
|
function createBloxSSREntry(options) {
|
|
120
152
|
var _a;
|
|
121
153
|
const {
|
|
@@ -177,12 +209,13 @@ function createBloxSSREntry(options) {
|
|
|
177
209
|
publishedBundleCache.set(cacheKey, pending);
|
|
178
210
|
}
|
|
179
211
|
const bundle = await pending;
|
|
180
|
-
const
|
|
212
|
+
const resolved = await resolvePublishedPage(
|
|
181
213
|
bundle.pages,
|
|
182
214
|
slug,
|
|
183
|
-
|
|
215
|
+
pageLocale,
|
|
216
|
+
options.resolvePublishedPaths ? options.collectionResolver : void 0
|
|
184
217
|
);
|
|
185
|
-
return
|
|
218
|
+
return resolved ? { ...resolved, warnings: [] } : null;
|
|
186
219
|
}
|
|
187
220
|
const url = `${apiBase}/blox/websites/${websiteId}/resolve-path?path=${encodeURIComponent(slug)}&locale=${pageLocale}`;
|
|
188
221
|
return bloxBuildJson(url, {}, options.buildRequest);
|
package/package.json
CHANGED