@cmssy/next 8.0.4 → 9.0.0
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/middleware.cjs +1 -6
- package/dist/middleware.d.cts +2 -3
- package/dist/middleware.d.ts +2 -3
- package/dist/middleware.js +1 -6
- package/dist/server.cjs +9 -27
- package/dist/server.js +10 -28
- package/package.json +3 -3
package/dist/middleware.cjs
CHANGED
|
@@ -77,16 +77,11 @@ function createCmssyProxy(config, options = {}) {
|
|
|
77
77
|
var cmssyProxyMatcher = ["/((?!_next/|api/|.*\\..*).*)"];
|
|
78
78
|
async function resolveLocaleFromPathname(config, pathname) {
|
|
79
79
|
const segments = pathname.split("/").filter(Boolean);
|
|
80
|
-
const
|
|
81
|
-
const fetched = config.defaultLocale && hasStaticLocales ? null : await react.resolveSiteLocales({
|
|
80
|
+
const siteLocales = await react.resolveSiteLocales({
|
|
82
81
|
apiUrl: config.apiUrl,
|
|
83
82
|
org: config.org,
|
|
84
83
|
workspaceSlug: config.workspaceSlug
|
|
85
84
|
});
|
|
86
|
-
const siteLocales = {
|
|
87
|
-
defaultLocale: config.defaultLocale ?? fetched.defaultLocale,
|
|
88
|
-
locales: hasStaticLocales ? config.enabledLocales : fetched.locales
|
|
89
|
-
};
|
|
90
85
|
return react.splitLocaleFromPath(segments, siteLocales).locale;
|
|
91
86
|
}
|
|
92
87
|
function createCmssyLocaleMiddleware(config) {
|
package/dist/middleware.d.cts
CHANGED
|
@@ -73,9 +73,8 @@ declare function createCmssyEditMiddleware(config: {
|
|
|
73
73
|
}): (request: NextRequest) => Promise<NextResponse>;
|
|
74
74
|
|
|
75
75
|
/**
|
|
76
|
-
* Resolves the active locale from a pathname's leading segment
|
|
77
|
-
*
|
|
78
|
-
* network); otherwise fetches the workspace locales (cached).
|
|
76
|
+
* Resolves the active locale from a pathname's leading segment, against the
|
|
77
|
+
* workspace locales (fetched, cached 60s).
|
|
79
78
|
*/
|
|
80
79
|
declare function resolveLocaleFromPathname(config: CmssyConfig, pathname: string): Promise<string>;
|
|
81
80
|
/**
|
package/dist/middleware.d.ts
CHANGED
|
@@ -73,9 +73,8 @@ declare function createCmssyEditMiddleware(config: {
|
|
|
73
73
|
}): (request: NextRequest) => Promise<NextResponse>;
|
|
74
74
|
|
|
75
75
|
/**
|
|
76
|
-
* Resolves the active locale from a pathname's leading segment
|
|
77
|
-
*
|
|
78
|
-
* network); otherwise fetches the workspace locales (cached).
|
|
76
|
+
* Resolves the active locale from a pathname's leading segment, against the
|
|
77
|
+
* workspace locales (fetched, cached 60s).
|
|
79
78
|
*/
|
|
80
79
|
declare function resolveLocaleFromPathname(config: CmssyConfig, pathname: string): Promise<string>;
|
|
81
80
|
/**
|
package/dist/middleware.js
CHANGED
|
@@ -76,16 +76,11 @@ function createCmssyProxy(config, options = {}) {
|
|
|
76
76
|
var cmssyProxyMatcher = ["/((?!_next/|api/|.*\\..*).*)"];
|
|
77
77
|
async function resolveLocaleFromPathname(config, pathname) {
|
|
78
78
|
const segments = pathname.split("/").filter(Boolean);
|
|
79
|
-
const
|
|
80
|
-
const fetched = config.defaultLocale && hasStaticLocales ? null : await resolveSiteLocales({
|
|
79
|
+
const siteLocales = await resolveSiteLocales({
|
|
81
80
|
apiUrl: config.apiUrl,
|
|
82
81
|
org: config.org,
|
|
83
82
|
workspaceSlug: config.workspaceSlug
|
|
84
83
|
});
|
|
85
|
-
const siteLocales = {
|
|
86
|
-
defaultLocale: config.defaultLocale ?? fetched.defaultLocale,
|
|
87
|
-
locales: hasStaticLocales ? config.enabledLocales : fetched.locales
|
|
88
|
-
};
|
|
89
84
|
return splitLocaleFromPath(segments, siteLocales).locale;
|
|
90
85
|
}
|
|
91
86
|
function createCmssyLocaleMiddleware(config) {
|
package/dist/server.cjs
CHANGED
|
@@ -80,17 +80,12 @@ function buildCmssyPageRenderer(config, blocks, options, editRoute) {
|
|
|
80
80
|
const devAllowed = core.isDevelopment() && Boolean(config.devToken?.trim());
|
|
81
81
|
let locale;
|
|
82
82
|
let pagePath = path;
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
const siteLocales = await react.resolveSiteLocales(clientConfig);
|
|
84
|
+
const { defaultLocale, locales: enabledLocales } = siteLocales;
|
|
85
85
|
if (config.resolveLocale) {
|
|
86
|
-
defaultLocale = config.defaultLocale ?? (await react.resolveSiteLocales(clientConfig)).defaultLocale;
|
|
87
86
|
locale = await config.resolveLocale();
|
|
88
87
|
} else {
|
|
89
|
-
const
|
|
90
|
-
defaultLocale = config.defaultLocale ?? siteLocales.defaultLocale;
|
|
91
|
-
const locales = config.enabledLocales ?? siteLocales.locales;
|
|
92
|
-
enabledLocales = locales;
|
|
93
|
-
const split = react.splitLocaleFromPath(path, { defaultLocale, locales });
|
|
88
|
+
const split = react.splitLocaleFromPath(path, siteLocales);
|
|
94
89
|
locale = split.locale;
|
|
95
90
|
pagePath = split.path;
|
|
96
91
|
}
|
|
@@ -119,7 +114,7 @@ function buildCmssyPageRenderer(config, blocks, options, editRoute) {
|
|
|
119
114
|
const localeContext = {
|
|
120
115
|
current: locale,
|
|
121
116
|
default: defaultLocale,
|
|
122
|
-
enabled: enabledLocales
|
|
117
|
+
enabled: enabledLocales
|
|
123
118
|
};
|
|
124
119
|
if (editorActive && Editor) {
|
|
125
120
|
const bridgeOrigin = resolveBridgeOrigin(config.editorOrigin);
|
|
@@ -236,18 +231,8 @@ function createCmssyNotFound(config, blocks, options) {
|
|
|
236
231
|
if (!notFoundPageId) return fallback;
|
|
237
232
|
const page = await react.fetchPageById(clientConfig, notFoundPageId);
|
|
238
233
|
if (!page || page.blocks.length === 0) return fallback;
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
let enabledLocales = config.enabledLocales;
|
|
242
|
-
if (config.resolveLocale) {
|
|
243
|
-
defaultLocale = config.defaultLocale ?? "en";
|
|
244
|
-
locale = await config.resolveLocale();
|
|
245
|
-
} else {
|
|
246
|
-
const siteLocales = await react.resolveSiteLocales(clientConfig);
|
|
247
|
-
defaultLocale = config.defaultLocale ?? siteLocales.defaultLocale;
|
|
248
|
-
enabledLocales = config.enabledLocales ?? siteLocales.locales;
|
|
249
|
-
locale = defaultLocale;
|
|
250
|
-
}
|
|
234
|
+
const { defaultLocale, locales: enabledLocales } = await react.resolveSiteLocales(clientConfig);
|
|
235
|
+
const locale = config.resolveLocale ? await config.resolveLocale() : defaultLocale;
|
|
251
236
|
const resolvedForms = await react.resolveForms(
|
|
252
237
|
clientConfig,
|
|
253
238
|
page.blocks,
|
|
@@ -258,7 +243,7 @@ function createCmssyNotFound(config, blocks, options) {
|
|
|
258
243
|
const localeContext = {
|
|
259
244
|
current: locale,
|
|
260
245
|
default: defaultLocale,
|
|
261
|
-
enabled: enabledLocales
|
|
246
|
+
enabled: enabledLocales
|
|
262
247
|
};
|
|
263
248
|
return /* @__PURE__ */ jsxRuntime.jsx(client.CmssyLocaleProvider, { value: localeContext, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
264
249
|
react.CmssyServerPage,
|
|
@@ -391,10 +376,7 @@ async function buildCmssyMetadata(config, path, options = {}) {
|
|
|
391
376
|
react.fetchSiteConfig(clientConfig).catch(() => null),
|
|
392
377
|
resolveSeoBaseUrl(config, options.baseUrl)
|
|
393
378
|
]);
|
|
394
|
-
const { defaultLocale, locales: enabledLocales } = core.
|
|
395
|
-
config,
|
|
396
|
-
siteConfig
|
|
397
|
-
);
|
|
379
|
+
const { defaultLocale, locales: enabledLocales } = core.localesFromSiteConfig(siteConfig);
|
|
398
380
|
const segments = Array.isArray(path) ? path : path ? path.split("/").filter(Boolean) : void 0;
|
|
399
381
|
const fromPath = react.splitLocaleFromPath(segments, {
|
|
400
382
|
defaultLocale,
|
|
@@ -489,7 +471,7 @@ function createCmssySitemap(config, options = {}) {
|
|
|
489
471
|
}
|
|
490
472
|
const notFoundPageId = siteConfig?.notFoundPageId ?? null;
|
|
491
473
|
const baseUrl = await resolveSeoBaseUrl(config, options.baseUrl);
|
|
492
|
-
const { defaultLocale, locales } = core.
|
|
474
|
+
const { defaultLocale, locales } = core.localesFromSiteConfig(siteConfig);
|
|
493
475
|
const excluded = new Set((options.excludeSlugs ?? []).map(core.normalizeSlug));
|
|
494
476
|
const languagesFor = (slug) => locales.length > 1 ? {
|
|
495
477
|
languages: {
|
package/dist/server.js
CHANGED
|
@@ -3,7 +3,7 @@ import { draftMode, headers, cookies } from 'next/headers';
|
|
|
3
3
|
import { notFound, redirect } from 'next/navigation';
|
|
4
4
|
import { createCmssyClient, resolveSiteLocales, splitLocaleFromPath, fetchPage, resolveForms, resolveBlockData, CmssyServerPage, fetchSiteConfig, fetchPageById, fetchLayouts, resolveLayoutBlockData, CmssyServerLayout, normalizeSlug, fetchPageMeta, fetchPages } from '@cmssy/react';
|
|
5
5
|
import { CmssyLocaleProvider } from '@cmssy/react/client';
|
|
6
|
-
import { isDevelopment, resolveEditorOrigin, toCspOrigin, CMSSY_EDIT_HEADER, localeForPath, CMSSY_LOCALE_HEADER, resolveSiteLocales as resolveSiteLocales$1,
|
|
6
|
+
import { isDevelopment, resolveEditorOrigin, toCspOrigin, CMSSY_EDIT_HEADER, localeForPath, CMSSY_LOCALE_HEADER, resolveSiteLocales as resolveSiteLocales$1, localesFromSiteConfig, localizedPath, normalizeSlug as normalizeSlug$1, assertAuthConfig, backendProduct, backendCheckout, backendMergeCart, backendSetShippingMethod, backendRemoveDiscount, backendApplyDiscount, backendClearCart, backendRemoveItem, backendUpdateItem, backendAddToCart, backendGetCart, backendMyOrder, backendMyOrders, cmssySecretsMatch, fetchProducts as fetchProducts$1, fetchProduct as fetchProduct$1, backendSignIn, toSessionPayload, backendRegister, backendSignOut, isAccessExpired, backendSignOutEverywhere, backendForgotPassword, backendResetPassword, backendVerifyEmail, CMSSY_SESSION_COOKIE, openSession, CMSSY_EDIT_QUERY_PARAM, CMSSY_SECRET_QUERY_PARAM, sealSession, sessionCookieOptions, backendRefresh } from '@cmssy/core';
|
|
7
7
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
8
8
|
|
|
9
9
|
// src/server.ts
|
|
@@ -78,17 +78,12 @@ function buildCmssyPageRenderer(config, blocks, options, editRoute) {
|
|
|
78
78
|
const devAllowed = isDevelopment() && Boolean(config.devToken?.trim());
|
|
79
79
|
let locale;
|
|
80
80
|
let pagePath = path;
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
const siteLocales = await resolveSiteLocales(clientConfig);
|
|
82
|
+
const { defaultLocale, locales: enabledLocales } = siteLocales;
|
|
83
83
|
if (config.resolveLocale) {
|
|
84
|
-
defaultLocale = config.defaultLocale ?? (await resolveSiteLocales(clientConfig)).defaultLocale;
|
|
85
84
|
locale = await config.resolveLocale();
|
|
86
85
|
} else {
|
|
87
|
-
const
|
|
88
|
-
defaultLocale = config.defaultLocale ?? siteLocales.defaultLocale;
|
|
89
|
-
const locales = config.enabledLocales ?? siteLocales.locales;
|
|
90
|
-
enabledLocales = locales;
|
|
91
|
-
const split = splitLocaleFromPath(path, { defaultLocale, locales });
|
|
86
|
+
const split = splitLocaleFromPath(path, siteLocales);
|
|
92
87
|
locale = split.locale;
|
|
93
88
|
pagePath = split.path;
|
|
94
89
|
}
|
|
@@ -117,7 +112,7 @@ function buildCmssyPageRenderer(config, blocks, options, editRoute) {
|
|
|
117
112
|
const localeContext = {
|
|
118
113
|
current: locale,
|
|
119
114
|
default: defaultLocale,
|
|
120
|
-
enabled: enabledLocales
|
|
115
|
+
enabled: enabledLocales
|
|
121
116
|
};
|
|
122
117
|
if (editorActive && Editor) {
|
|
123
118
|
const bridgeOrigin = resolveBridgeOrigin(config.editorOrigin);
|
|
@@ -234,18 +229,8 @@ function createCmssyNotFound(config, blocks, options) {
|
|
|
234
229
|
if (!notFoundPageId) return fallback;
|
|
235
230
|
const page = await fetchPageById(clientConfig, notFoundPageId);
|
|
236
231
|
if (!page || page.blocks.length === 0) return fallback;
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
let enabledLocales = config.enabledLocales;
|
|
240
|
-
if (config.resolveLocale) {
|
|
241
|
-
defaultLocale = config.defaultLocale ?? "en";
|
|
242
|
-
locale = await config.resolveLocale();
|
|
243
|
-
} else {
|
|
244
|
-
const siteLocales = await resolveSiteLocales(clientConfig);
|
|
245
|
-
defaultLocale = config.defaultLocale ?? siteLocales.defaultLocale;
|
|
246
|
-
enabledLocales = config.enabledLocales ?? siteLocales.locales;
|
|
247
|
-
locale = defaultLocale;
|
|
248
|
-
}
|
|
232
|
+
const { defaultLocale, locales: enabledLocales } = await resolveSiteLocales(clientConfig);
|
|
233
|
+
const locale = config.resolveLocale ? await config.resolveLocale() : defaultLocale;
|
|
249
234
|
const resolvedForms = await resolveForms(
|
|
250
235
|
clientConfig,
|
|
251
236
|
page.blocks,
|
|
@@ -256,7 +241,7 @@ function createCmssyNotFound(config, blocks, options) {
|
|
|
256
241
|
const localeContext = {
|
|
257
242
|
current: locale,
|
|
258
243
|
default: defaultLocale,
|
|
259
|
-
enabled: enabledLocales
|
|
244
|
+
enabled: enabledLocales
|
|
260
245
|
};
|
|
261
246
|
return /* @__PURE__ */ jsx(CmssyLocaleProvider, { value: localeContext, children: /* @__PURE__ */ jsx(
|
|
262
247
|
CmssyServerPage,
|
|
@@ -389,10 +374,7 @@ async function buildCmssyMetadata(config, path, options = {}) {
|
|
|
389
374
|
fetchSiteConfig(clientConfig).catch(() => null),
|
|
390
375
|
resolveSeoBaseUrl(config, options.baseUrl)
|
|
391
376
|
]);
|
|
392
|
-
const { defaultLocale, locales: enabledLocales } =
|
|
393
|
-
config,
|
|
394
|
-
siteConfig
|
|
395
|
-
);
|
|
377
|
+
const { defaultLocale, locales: enabledLocales } = localesFromSiteConfig(siteConfig);
|
|
396
378
|
const segments = Array.isArray(path) ? path : path ? path.split("/").filter(Boolean) : void 0;
|
|
397
379
|
const fromPath = splitLocaleFromPath(segments, {
|
|
398
380
|
defaultLocale,
|
|
@@ -487,7 +469,7 @@ function createCmssySitemap(config, options = {}) {
|
|
|
487
469
|
}
|
|
488
470
|
const notFoundPageId = siteConfig?.notFoundPageId ?? null;
|
|
489
471
|
const baseUrl = await resolveSeoBaseUrl(config, options.baseUrl);
|
|
490
|
-
const { defaultLocale, locales } =
|
|
472
|
+
const { defaultLocale, locales } = localesFromSiteConfig(siteConfig);
|
|
491
473
|
const excluded = new Set((options.excludeSlugs ?? []).map(normalizeSlug$1));
|
|
492
474
|
const languagesFor = (slug) => locales.length > 1 ? {
|
|
493
475
|
languages: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cmssy/next",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0",
|
|
4
4
|
"description": "Next.js App Router bindings for cmssy headless sites (createCmssyPage + draft preview)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cmssy",
|
|
@@ -70,12 +70,12 @@
|
|
|
70
70
|
"tsup": "^8.3.0",
|
|
71
71
|
"typescript": "^5.6.0",
|
|
72
72
|
"vitest": "^2.1.0",
|
|
73
|
-
"@cmssy/react": "
|
|
73
|
+
"@cmssy/react": "9.0.0"
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
76
76
|
"@cmssy/types": "0.28.0",
|
|
77
77
|
"server-only": "^0.0.1",
|
|
78
|
-
"@cmssy/core": "
|
|
78
|
+
"@cmssy/core": "9.0.0"
|
|
79
79
|
},
|
|
80
80
|
"scripts": {
|
|
81
81
|
"build": "tsup",
|