@cmssy/core 6.2.0 → 7.0.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/testing.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  // src/testing/edit-smoke.ts
4
4
  var EDITOR_MARKER = /data-cmssy-editor/;
5
- var SERVER_CHROME = /<header|<footer/;
5
+ var SERVER_LAYOUT_BLOCKS = /<header|<footer/;
6
6
  async function html(url) {
7
7
  const response = await fetch(url, { redirect: "manual" });
8
8
  return { status: response.status, body: await response.text() };
@@ -18,7 +18,7 @@ async function checkCmssyEditMode(options) {
18
18
  if (EDITOR_MARKER.test(publicPage.body)) {
19
19
  failures.push(`public ${path}: the editor is mounted on a public page`);
20
20
  }
21
- const hasServerChrome = SERVER_CHROME.test(publicPage.body);
21
+ const hasServerLayoutBlocks = SERVER_LAYOUT_BLOCKS.test(publicPage.body);
22
22
  const unverified = await html(url(`${path}?cmssyEdit=1`));
23
23
  if (EDITOR_MARKER.test(unverified.body)) {
24
24
  failures.push(
@@ -36,13 +36,14 @@ async function checkCmssyEditMode(options) {
36
36
  `edit ${path}: no editor in the response - is the /cmssy-edit route mounted?`
37
37
  );
38
38
  }
39
- if (hasServerChrome && SERVER_CHROME.test(verified.body)) {
39
+ if (hasServerLayoutBlocks && SERVER_LAYOUT_BLOCKS.test(verified.body)) {
40
40
  failures.push(
41
- `edit ${path}: the chrome is still server-rendered - the header and footer will be selectable but have no fields (is CMSSY_EDIT_HEADER set on the rewrite?)`
41
+ `edit ${path}: the header and footer are still server-rendered - the editor will let you select them but show no fields (is CMSSY_EDIT_HEADER set on the rewrite?)`
42
42
  );
43
43
  }
44
- const { localizedPath, localizedMarker } = options;
45
- if (localizedPath && localizedMarker) {
44
+ const { localizedPath } = options;
45
+ if (localizedPath) {
46
+ const locale = options.localizedLocale ?? localizedPath.split("/").filter(Boolean)[0];
46
47
  const localized = await html(
47
48
  url(
48
49
  `${localizedPath}?cmssyEdit=1&cmssySecret=${encodeURIComponent(secret)}`
@@ -51,9 +52,10 @@ async function checkCmssyEditMode(options) {
51
52
  if (!EDITOR_MARKER.test(localized.body)) {
52
53
  failures.push(`edit ${localizedPath}: no editor in the response`);
53
54
  }
54
- if (!localized.body.includes(localizedMarker)) {
55
+ const served = /<html[^>]*\slang=["']([^"']+)["']/i.exec(localized.body)?.[1];
56
+ if (locale && served !== locale) {
55
57
  failures.push(
56
- `edit ${localizedPath}: "${localizedMarker}" is missing - the preview renders in the default language, not the one the URL asks for`
58
+ `edit ${localizedPath}: the page reports lang="${served ?? "?"}" but the URL asks for "${locale}" - the preview renders in the wrong language`
57
59
  );
58
60
  }
59
61
  }
@@ -8,11 +8,16 @@ interface EditSmokeOptions {
8
8
  /**
9
9
  * The same page under a language prefix, e.g. "/no". Pass it on a site whose
10
10
  * URLs carry the language, and the check also proves the preview renders in
11
- * THAT language rather than the default one.
11
+ * THAT language rather than the default one - by reading `<html lang>`, which
12
+ * is a contract, unlike a word from the page's copy that an editor can change
13
+ * at any time.
12
14
  */
13
15
  localizedPath?: string;
14
- /** A word only the localized page says - "Handlekurv", say. */
15
- localizedMarker?: string;
16
+ /**
17
+ * The language `localizedPath` must render, e.g. "no". Defaults to the first
18
+ * path segment, which IS the language on a prefixed site.
19
+ */
20
+ localizedLocale?: string;
16
21
  }
17
22
  interface EditSmokeResult {
18
23
  ok: boolean;
package/dist/testing.d.ts CHANGED
@@ -8,11 +8,16 @@ interface EditSmokeOptions {
8
8
  /**
9
9
  * The same page under a language prefix, e.g. "/no". Pass it on a site whose
10
10
  * URLs carry the language, and the check also proves the preview renders in
11
- * THAT language rather than the default one.
11
+ * THAT language rather than the default one - by reading `<html lang>`, which
12
+ * is a contract, unlike a word from the page's copy that an editor can change
13
+ * at any time.
12
14
  */
13
15
  localizedPath?: string;
14
- /** A word only the localized page says - "Handlekurv", say. */
15
- localizedMarker?: string;
16
+ /**
17
+ * The language `localizedPath` must render, e.g. "no". Defaults to the first
18
+ * path segment, which IS the language on a prefixed site.
19
+ */
20
+ localizedLocale?: string;
16
21
  }
17
22
  interface EditSmokeResult {
18
23
  ok: boolean;
package/dist/testing.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // src/testing/edit-smoke.ts
2
2
  var EDITOR_MARKER = /data-cmssy-editor/;
3
- var SERVER_CHROME = /<header|<footer/;
3
+ var SERVER_LAYOUT_BLOCKS = /<header|<footer/;
4
4
  async function html(url) {
5
5
  const response = await fetch(url, { redirect: "manual" });
6
6
  return { status: response.status, body: await response.text() };
@@ -16,7 +16,7 @@ async function checkCmssyEditMode(options) {
16
16
  if (EDITOR_MARKER.test(publicPage.body)) {
17
17
  failures.push(`public ${path}: the editor is mounted on a public page`);
18
18
  }
19
- const hasServerChrome = SERVER_CHROME.test(publicPage.body);
19
+ const hasServerLayoutBlocks = SERVER_LAYOUT_BLOCKS.test(publicPage.body);
20
20
  const unverified = await html(url(`${path}?cmssyEdit=1`));
21
21
  if (EDITOR_MARKER.test(unverified.body)) {
22
22
  failures.push(
@@ -34,13 +34,14 @@ async function checkCmssyEditMode(options) {
34
34
  `edit ${path}: no editor in the response - is the /cmssy-edit route mounted?`
35
35
  );
36
36
  }
37
- if (hasServerChrome && SERVER_CHROME.test(verified.body)) {
37
+ if (hasServerLayoutBlocks && SERVER_LAYOUT_BLOCKS.test(verified.body)) {
38
38
  failures.push(
39
- `edit ${path}: the chrome is still server-rendered - the header and footer will be selectable but have no fields (is CMSSY_EDIT_HEADER set on the rewrite?)`
39
+ `edit ${path}: the header and footer are still server-rendered - the editor will let you select them but show no fields (is CMSSY_EDIT_HEADER set on the rewrite?)`
40
40
  );
41
41
  }
42
- const { localizedPath, localizedMarker } = options;
43
- if (localizedPath && localizedMarker) {
42
+ const { localizedPath } = options;
43
+ if (localizedPath) {
44
+ const locale = options.localizedLocale ?? localizedPath.split("/").filter(Boolean)[0];
44
45
  const localized = await html(
45
46
  url(
46
47
  `${localizedPath}?cmssyEdit=1&cmssySecret=${encodeURIComponent(secret)}`
@@ -49,9 +50,10 @@ async function checkCmssyEditMode(options) {
49
50
  if (!EDITOR_MARKER.test(localized.body)) {
50
51
  failures.push(`edit ${localizedPath}: no editor in the response`);
51
52
  }
52
- if (!localized.body.includes(localizedMarker)) {
53
+ const served = /<html[^>]*\slang=["']([^"']+)["']/i.exec(localized.body)?.[1];
54
+ if (locale && served !== locale) {
53
55
  failures.push(
54
- `edit ${localizedPath}: "${localizedMarker}" is missing - the preview renders in the default language, not the one the URL asks for`
56
+ `edit ${localizedPath}: the page reports lang="${served ?? "?"}" but the URL asks for "${locale}" - the preview renders in the wrong language`
55
57
  );
56
58
  }
57
59
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmssy/core",
3
- "version": "6.2.0",
3
+ "version": "7.0.1",
4
4
  "description": "Framework-agnostic cmssy client: content, commerce, config, editor protocol. No React, no Next.",
5
5
  "keywords": [
6
6
  "cmssy",