@cmssy/remix 11.4.2 → 11.5.1
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/index.cjs +17 -0
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +17 -1
- package/dist/testing.cjs +5 -5
- package/dist/testing.d.cts +6 -1
- package/dist/testing.d.ts +6 -1
- package/dist/testing.js +8 -1
- package/package.json +4 -3
package/dist/index.cjs
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var core = require('@cmssy/core');
|
|
4
4
|
var internal = require('@cmssy/core/internal');
|
|
5
5
|
var react = require('@cmssy/react');
|
|
6
|
+
var reactRouter = require('react-router');
|
|
6
7
|
|
|
7
8
|
// src/loader.ts
|
|
8
9
|
function createCmssyLoader(config, options = {}) {
|
|
@@ -88,6 +89,21 @@ function createCmssyHeaders(config) {
|
|
|
88
89
|
return internal.cmssyCspHeaders({ editorOrigin: config.editorOrigin });
|
|
89
90
|
};
|
|
90
91
|
}
|
|
92
|
+
function localeOfMatch(match) {
|
|
93
|
+
for (const result of [match?.loaderData, match?.data]) {
|
|
94
|
+
const locale = result?.locale;
|
|
95
|
+
if (typeof locale === "string" && locale) return locale;
|
|
96
|
+
}
|
|
97
|
+
return void 0;
|
|
98
|
+
}
|
|
99
|
+
function useCmssyLocale() {
|
|
100
|
+
const matches = reactRouter.useMatches();
|
|
101
|
+
for (let i = matches.length - 1; i >= 0; i -= 1) {
|
|
102
|
+
const locale = localeOfMatch(matches[i]);
|
|
103
|
+
if (locale) return locale;
|
|
104
|
+
}
|
|
105
|
+
return void 0;
|
|
106
|
+
}
|
|
91
107
|
|
|
92
108
|
Object.defineProperty(exports, "CMSSY_LOCALE_HEADER", {
|
|
93
109
|
enumerable: true,
|
|
@@ -111,3 +127,4 @@ Object.defineProperty(exports, "localizeHref", {
|
|
|
111
127
|
});
|
|
112
128
|
exports.createCmssyHeaders = createCmssyHeaders;
|
|
113
129
|
exports.createCmssyLoader = createCmssyLoader;
|
|
130
|
+
exports.useCmssyLocale = useCmssyLocale;
|
package/dist/index.d.cts
CHANGED
|
@@ -52,4 +52,6 @@ declare function createCmssyLoader(config: CmssyConfig, options?: CreateCmssyLoa
|
|
|
52
52
|
*/
|
|
53
53
|
declare function createCmssyHeaders(config: CmssyConfig): () => Record<string, string>;
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
declare function useCmssyLocale(): string | undefined;
|
|
56
|
+
|
|
57
|
+
export { type CmssyRouteData, createCmssyHeaders, createCmssyLoader, useCmssyLocale };
|
package/dist/index.d.ts
CHANGED
|
@@ -52,4 +52,6 @@ declare function createCmssyLoader(config: CmssyConfig, options?: CreateCmssyLoa
|
|
|
52
52
|
*/
|
|
53
53
|
declare function createCmssyHeaders(config: CmssyConfig): () => Record<string, string>;
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
declare function useCmssyLocale(): string | undefined;
|
|
56
|
+
|
|
57
|
+
export { type CmssyRouteData, createCmssyHeaders, createCmssyLoader, useCmssyLocale };
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import { isVerifiedEditUrl, CMSSY_EDIT_QUERY_PARAM, CMSSY_SECRET_QUERY_PARAM, re
|
|
|
2
2
|
export { CMSSY_LOCALE_HEADER, createCmssyClient, defineCmssyConfig, isVerifiedEditUrl, localizeHref } from '@cmssy/core';
|
|
3
3
|
import { isDevelopment, resolveSiteLocales, CMSSY_LOCALE_HEADER, fetchPage, cmssyCspHeaders } from '@cmssy/core/internal';
|
|
4
4
|
import { resolveCmssyLayoutSlot } from '@cmssy/react';
|
|
5
|
+
import { useMatches } from 'react-router';
|
|
5
6
|
|
|
6
7
|
// src/loader.ts
|
|
7
8
|
function createCmssyLoader(config, options = {}) {
|
|
@@ -87,5 +88,20 @@ function createCmssyHeaders(config) {
|
|
|
87
88
|
return cmssyCspHeaders({ editorOrigin: config.editorOrigin });
|
|
88
89
|
};
|
|
89
90
|
}
|
|
91
|
+
function localeOfMatch(match) {
|
|
92
|
+
for (const result of [match?.loaderData, match?.data]) {
|
|
93
|
+
const locale = result?.locale;
|
|
94
|
+
if (typeof locale === "string" && locale) return locale;
|
|
95
|
+
}
|
|
96
|
+
return void 0;
|
|
97
|
+
}
|
|
98
|
+
function useCmssyLocale() {
|
|
99
|
+
const matches = useMatches();
|
|
100
|
+
for (let i = matches.length - 1; i >= 0; i -= 1) {
|
|
101
|
+
const locale = localeOfMatch(matches[i]);
|
|
102
|
+
if (locale) return locale;
|
|
103
|
+
}
|
|
104
|
+
return void 0;
|
|
105
|
+
}
|
|
90
106
|
|
|
91
|
-
export { createCmssyHeaders, createCmssyLoader };
|
|
107
|
+
export { createCmssyHeaders, createCmssyLoader, useCmssyLocale };
|
package/dist/testing.cjs
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
var testing = require('@cmssy/core/testing');
|
|
4
4
|
|
|
5
|
+
// src/testing.ts
|
|
6
|
+
function checkCmssyEditMode(options) {
|
|
7
|
+
return testing.checkCmssyEditMode({ ...options, editRoute: options.editRoute ?? false });
|
|
8
|
+
}
|
|
5
9
|
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, "checkCmssyEditMode", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: function () { return testing.checkCmssyEditMode; }
|
|
10
|
-
});
|
|
10
|
+
exports.checkCmssyEditMode = checkCmssyEditMode;
|
package/dist/testing.d.cts
CHANGED
|
@@ -1 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { EditSmokeOptions, EditSmokeResult } from '@cmssy/core/testing';
|
|
2
|
+
export { EditSmokeOptions, EditSmokeResult } from '@cmssy/core/testing';
|
|
3
|
+
|
|
4
|
+
declare function checkCmssyEditMode(options: EditSmokeOptions): Promise<EditSmokeResult>;
|
|
5
|
+
|
|
6
|
+
export { checkCmssyEditMode };
|
package/dist/testing.d.ts
CHANGED
|
@@ -1 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { EditSmokeOptions, EditSmokeResult } from '@cmssy/core/testing';
|
|
2
|
+
export { EditSmokeOptions, EditSmokeResult } from '@cmssy/core/testing';
|
|
3
|
+
|
|
4
|
+
declare function checkCmssyEditMode(options: EditSmokeOptions): Promise<EditSmokeResult>;
|
|
5
|
+
|
|
6
|
+
export { checkCmssyEditMode };
|
package/dist/testing.js
CHANGED
|
@@ -1 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import { checkCmssyEditMode as checkCmssyEditMode$1 } from '@cmssy/core/testing';
|
|
2
|
+
|
|
3
|
+
// src/testing.ts
|
|
4
|
+
function checkCmssyEditMode(options) {
|
|
5
|
+
return checkCmssyEditMode$1({ ...options, editRoute: options.editRoute ?? false });
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export { checkCmssyEditMode };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cmssy/remix",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.5.1",
|
|
4
4
|
"description": "React Router 7 bindings for cmssy headless sites: page loader, framing CSP, sitemap and robots.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cmssy",
|
|
@@ -44,13 +44,14 @@
|
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/node": "^20.0.0",
|
|
47
|
+
"react-router": "^8.2.0",
|
|
47
48
|
"tsup": "^8.3.0",
|
|
48
49
|
"typescript": "^5.6.0",
|
|
49
50
|
"vitest": "^2.1.0",
|
|
50
|
-
"@cmssy/react": "11.
|
|
51
|
+
"@cmssy/react": "11.5.1"
|
|
51
52
|
},
|
|
52
53
|
"dependencies": {
|
|
53
|
-
"@cmssy/core": "11.
|
|
54
|
+
"@cmssy/core": "11.5.1"
|
|
54
55
|
},
|
|
55
56
|
"scripts": {
|
|
56
57
|
"build": "tsup",
|