@cmssy/core 11.4.0 → 11.4.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.
@@ -25,7 +25,9 @@ interface CmssyConfig {
25
25
  */
26
26
  devToken?: string;
27
27
  /**
28
- * Origin allowed to frame your app in the editor. Defaults to
28
+ * Origin(s) allowed to frame your app in the editor: one origin, a list, or
29
+ * the comma-separated string an env var carries - all three are accepted, so
30
+ * `process.env.CMSSY_EDITOR_ORIGIN` can be passed through as-is. Defaults to
29
31
  * {@link DEFAULT_CMSSY_EDITOR_ORIGINS}; set it only for self-hosted admins.
30
32
  */
31
33
  editorOrigin?: string | string[];
@@ -25,7 +25,9 @@ interface CmssyConfig {
25
25
  */
26
26
  devToken?: string;
27
27
  /**
28
- * Origin allowed to frame your app in the editor. Defaults to
28
+ * Origin(s) allowed to frame your app in the editor: one origin, a list, or
29
+ * the comma-separated string an env var carries - all three are accepted, so
30
+ * `process.env.CMSSY_EDITOR_ORIGIN` can be passed through as-is. Defaults to
29
31
  * {@link DEFAULT_CMSSY_EDITOR_ORIGINS}; set it only for self-hosted admins.
30
32
  */
31
33
  editorOrigin?: string | string[];
package/dist/index.cjs CHANGED
@@ -7,10 +7,11 @@ var DEFAULT_CMSSY_EDITOR_ORIGINS = [
7
7
  "https://cmssy.io",
8
8
  "https://www.cmssy.io"
9
9
  ];
10
- function parseEditorOriginEnv(raw) {
11
- if (!raw) return void 0;
12
- const parts = raw.split(",").map((o) => o.trim()).filter((o) => o.length > 0);
10
+ function parseEditorOrigin(raw) {
11
+ if (raw === void 0) return void 0;
12
+ const parts = (Array.isArray(raw) ? raw : [raw]).flatMap((entry) => typeof entry === "string" ? entry.split(",") : []).map((origin) => origin.trim()).filter((origin) => origin.length > 0);
13
13
  if (parts.length === 0) return void 0;
14
+ if (Array.isArray(raw)) return parts;
14
15
  return parts.length === 1 ? parts[0] : parts;
15
16
  }
16
17
  function isDevelopment() {
@@ -25,16 +26,18 @@ function rejectWildcardOutsideDevelopment(value) {
25
26
  }
26
27
  }
27
28
  function resolveEditorOrigin(editorOrigin) {
28
- const value = editorOrigin ?? (typeof process !== "undefined" ? parseEditorOriginEnv(process.env.CMSSY_EDITOR_ORIGIN) : void 0);
29
- if (value === void 0) {
29
+ if (editorOrigin !== void 0) {
30
+ const explicit = parseEditorOrigin(editorOrigin);
31
+ if (explicit === void 0) return DEFAULT_CMSSY_EDITOR_ORIGINS;
32
+ rejectWildcardOutsideDevelopment(explicit);
33
+ return explicit;
34
+ }
35
+ const fromEnv = typeof process !== "undefined" ? parseEditorOrigin(process.env.CMSSY_EDITOR_ORIGIN) : void 0;
36
+ if (fromEnv === void 0) {
30
37
  return isDevelopment() ? "*" : DEFAULT_CMSSY_EDITOR_ORIGINS;
31
38
  }
32
- rejectWildcardOutsideDevelopment(value);
33
- if (Array.isArray(value)) {
34
- const cleaned = value.filter((o) => o && o.trim().length > 0);
35
- return cleaned.length > 0 ? cleaned : DEFAULT_CMSSY_EDITOR_ORIGINS;
36
- }
37
- return value.trim().length > 0 ? value : DEFAULT_CMSSY_EDITOR_ORIGINS;
39
+ rejectWildcardOutsideDevelopment(fromEnv);
40
+ return fromEnv;
38
41
  }
39
42
  var REQUIRED_CONFIG_ENV = [
40
43
  ["org", "CMSSY_ORG_SLUG"],
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- export { A as AppToEditorMessage, B as BoundsMessage, C as ClickMessage, a as CmssyClient, b as CmssyConfig, c as CmssyCspOptions, d as CmssyEnvConfig, e as CmssyTypedDocument, D as DEFAULT_CMSSY_EDITOR_ORIGINS, E as EditorToAppMessage, P as PROTOCOL_VERSION, f as ParentReadyMessage, g as PatchMessage, h as PostTarget, Q as QueryScopedOptions, R as ReadyMessage, S as SelectMessage, i as applyCmssyCsp, j as createCmssyClient, k as defineCmssyConfig, l as isProtocolCompatible, n as normalizeOrigin, p as parseEditorMessage, m as postToEditor, r as resolveEditorOrigin } from './csp-Bzrk_BeO.cjs';
1
+ export { A as AppToEditorMessage, B as BoundsMessage, C as ClickMessage, a as CmssyClient, b as CmssyConfig, c as CmssyCspOptions, d as CmssyEnvConfig, e as CmssyTypedDocument, D as DEFAULT_CMSSY_EDITOR_ORIGINS, E as EditorToAppMessage, P as PROTOCOL_VERSION, f as ParentReadyMessage, g as PatchMessage, h as PostTarget, Q as QueryScopedOptions, R as ReadyMessage, S as SelectMessage, i as applyCmssyCsp, j as createCmssyClient, k as defineCmssyConfig, l as isProtocolCompatible, n as normalizeOrigin, p as parseEditorMessage, m as postToEditor, r as resolveEditorOrigin } from './csp-CRixC_wl.cjs';
2
2
  export { C as CMSSY_LOCALE_HEADER, G as GraphqlRequestOptions, g as graphqlRequest, l as localizeHref } from './locale-C7sA46qu.cjs';
3
3
  export { C as CmssyRequestError, D as DEFAULT_CMSSY_API_URL, F as FetchLike, a as FetchLikeResponse, b as FetchPageOptions, R as RetryPolicy } from './content-client-CJQ-nafm.cjs';
4
4
  import * as _cmssy_types from '@cmssy/types';
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { A as AppToEditorMessage, B as BoundsMessage, C as ClickMessage, a as CmssyClient, b as CmssyConfig, c as CmssyCspOptions, d as CmssyEnvConfig, e as CmssyTypedDocument, D as DEFAULT_CMSSY_EDITOR_ORIGINS, E as EditorToAppMessage, P as PROTOCOL_VERSION, f as ParentReadyMessage, g as PatchMessage, h as PostTarget, Q as QueryScopedOptions, R as ReadyMessage, S as SelectMessage, i as applyCmssyCsp, j as createCmssyClient, k as defineCmssyConfig, l as isProtocolCompatible, n as normalizeOrigin, p as parseEditorMessage, m as postToEditor, r as resolveEditorOrigin } from './csp-B7ElkvAp.js';
1
+ export { A as AppToEditorMessage, B as BoundsMessage, C as ClickMessage, a as CmssyClient, b as CmssyConfig, c as CmssyCspOptions, d as CmssyEnvConfig, e as CmssyTypedDocument, D as DEFAULT_CMSSY_EDITOR_ORIGINS, E as EditorToAppMessage, P as PROTOCOL_VERSION, f as ParentReadyMessage, g as PatchMessage, h as PostTarget, Q as QueryScopedOptions, R as ReadyMessage, S as SelectMessage, i as applyCmssyCsp, j as createCmssyClient, k as defineCmssyConfig, l as isProtocolCompatible, n as normalizeOrigin, p as parseEditorMessage, m as postToEditor, r as resolveEditorOrigin } from './csp-DpG1NcSd.js';
2
2
  export { C as CMSSY_LOCALE_HEADER, G as GraphqlRequestOptions, g as graphqlRequest, l as localizeHref } from './locale-Ox_qVlNy.js';
3
3
  export { C as CmssyRequestError, D as DEFAULT_CMSSY_API_URL, F as FetchLike, a as FetchLikeResponse, b as FetchPageOptions, R as RetryPolicy } from './content-client-CJQ-nafm.js';
4
4
  import * as _cmssy_types from '@cmssy/types';
package/dist/index.js CHANGED
@@ -5,10 +5,11 @@ var DEFAULT_CMSSY_EDITOR_ORIGINS = [
5
5
  "https://cmssy.io",
6
6
  "https://www.cmssy.io"
7
7
  ];
8
- function parseEditorOriginEnv(raw) {
9
- if (!raw) return void 0;
10
- const parts = raw.split(",").map((o) => o.trim()).filter((o) => o.length > 0);
8
+ function parseEditorOrigin(raw) {
9
+ if (raw === void 0) return void 0;
10
+ const parts = (Array.isArray(raw) ? raw : [raw]).flatMap((entry) => typeof entry === "string" ? entry.split(",") : []).map((origin) => origin.trim()).filter((origin) => origin.length > 0);
11
11
  if (parts.length === 0) return void 0;
12
+ if (Array.isArray(raw)) return parts;
12
13
  return parts.length === 1 ? parts[0] : parts;
13
14
  }
14
15
  function isDevelopment() {
@@ -23,16 +24,18 @@ function rejectWildcardOutsideDevelopment(value) {
23
24
  }
24
25
  }
25
26
  function resolveEditorOrigin(editorOrigin) {
26
- const value = editorOrigin ?? (typeof process !== "undefined" ? parseEditorOriginEnv(process.env.CMSSY_EDITOR_ORIGIN) : void 0);
27
- if (value === void 0) {
27
+ if (editorOrigin !== void 0) {
28
+ const explicit = parseEditorOrigin(editorOrigin);
29
+ if (explicit === void 0) return DEFAULT_CMSSY_EDITOR_ORIGINS;
30
+ rejectWildcardOutsideDevelopment(explicit);
31
+ return explicit;
32
+ }
33
+ const fromEnv = typeof process !== "undefined" ? parseEditorOrigin(process.env.CMSSY_EDITOR_ORIGIN) : void 0;
34
+ if (fromEnv === void 0) {
28
35
  return isDevelopment() ? "*" : DEFAULT_CMSSY_EDITOR_ORIGINS;
29
36
  }
30
- rejectWildcardOutsideDevelopment(value);
31
- if (Array.isArray(value)) {
32
- const cleaned = value.filter((o) => o && o.trim().length > 0);
33
- return cleaned.length > 0 ? cleaned : DEFAULT_CMSSY_EDITOR_ORIGINS;
34
- }
35
- return value.trim().length > 0 ? value : DEFAULT_CMSSY_EDITOR_ORIGINS;
37
+ rejectWildcardOutsideDevelopment(fromEnv);
38
+ return fromEnv;
36
39
  }
37
40
  var REQUIRED_CONFIG_ENV = [
38
41
  ["org", "CMSSY_ORG_SLUG"],
package/dist/internal.cjs CHANGED
@@ -1059,10 +1059,11 @@ var DEFAULT_CMSSY_EDITOR_ORIGINS = [
1059
1059
  "https://cmssy.io",
1060
1060
  "https://www.cmssy.io"
1061
1061
  ];
1062
- function parseEditorOriginEnv(raw) {
1063
- if (!raw) return void 0;
1064
- const parts = raw.split(",").map((o) => o.trim()).filter((o) => o.length > 0);
1062
+ function parseEditorOrigin(raw) {
1063
+ if (raw === void 0) return void 0;
1064
+ const parts = (Array.isArray(raw) ? raw : [raw]).flatMap((entry) => typeof entry === "string" ? entry.split(",") : []).map((origin) => origin.trim()).filter((origin) => origin.length > 0);
1065
1065
  if (parts.length === 0) return void 0;
1066
+ if (Array.isArray(raw)) return parts;
1066
1067
  return parts.length === 1 ? parts[0] : parts;
1067
1068
  }
1068
1069
  function isDevelopment() {
@@ -1077,16 +1078,18 @@ function rejectWildcardOutsideDevelopment(value) {
1077
1078
  }
1078
1079
  }
1079
1080
  function resolveEditorOrigin(editorOrigin) {
1080
- const value = editorOrigin ?? (typeof process !== "undefined" ? parseEditorOriginEnv(process.env.CMSSY_EDITOR_ORIGIN) : void 0);
1081
- if (value === void 0) {
1082
- return isDevelopment() ? "*" : DEFAULT_CMSSY_EDITOR_ORIGINS;
1081
+ if (editorOrigin !== void 0) {
1082
+ const explicit = parseEditorOrigin(editorOrigin);
1083
+ if (explicit === void 0) return DEFAULT_CMSSY_EDITOR_ORIGINS;
1084
+ rejectWildcardOutsideDevelopment(explicit);
1085
+ return explicit;
1083
1086
  }
1084
- rejectWildcardOutsideDevelopment(value);
1085
- if (Array.isArray(value)) {
1086
- const cleaned = value.filter((o) => o && o.trim().length > 0);
1087
- return cleaned.length > 0 ? cleaned : DEFAULT_CMSSY_EDITOR_ORIGINS;
1087
+ const fromEnv = typeof process !== "undefined" ? parseEditorOrigin(process.env.CMSSY_EDITOR_ORIGIN) : void 0;
1088
+ if (fromEnv === void 0) {
1089
+ return isDevelopment() ? "*" : DEFAULT_CMSSY_EDITOR_ORIGINS;
1088
1090
  }
1089
- return value.trim().length > 0 ? value : DEFAULT_CMSSY_EDITOR_ORIGINS;
1091
+ rejectWildcardOutsideDevelopment(fromEnv);
1092
+ return fromEnv;
1090
1093
  }
1091
1094
 
1092
1095
  // src/csp.ts
@@ -3,8 +3,8 @@ import { CmssyFormDefinition, BuildBlockContextExtra, CmssyBlockContext, CmssyCl
3
3
  export { CmssySiteLocales } from '@cmssy/types';
4
4
  import { G as GraphqlRequestOptions } from './locale-C7sA46qu.cjs';
5
5
  export { C as CMSSY_LOCALE_HEADER, b as buildLocaleSwitchHref, a as localeForPath, c as localeForPathname, l as localizeHref, d as localizeHtmlLinks, s as splitCmssyLocale } from './locale-C7sA46qu.cjs';
6
- import { Q as QueryScopedOptions } from './csp-Bzrk_BeO.cjs';
7
- export { o as cmssyCspHeaders, q as isDevelopment, s as resolveInitialTarget, t as toCspOrigin } from './csp-Bzrk_BeO.cjs';
6
+ import { Q as QueryScopedOptions } from './csp-CRixC_wl.cjs';
7
+ export { o as cmssyCspHeaders, q as isDevelopment, s as resolveInitialTarget, t as toCspOrigin } from './csp-CRixC_wl.cjs';
8
8
  export { localesFromSiteConfig, localizedPath, resolveSiteLocales, splitLocaleFromPath } from './internal/locale.cjs';
9
9
 
10
10
  declare const SITE_CONFIG_QUERY = "query PublicSiteConfig($workspaceSlug: String!) {\n public {\n siteConfig(workspaceSlug: $workspaceSlug) {\n id\n workspaceId\n siteName\n defaultLanguage\n enabledLanguages\n enabledFeatures\n notFoundPageId\n previewUrl\n branding {\n brandName\n logoUrl\n logoDarkUrl\n faviconUrl\n ogImageUrl\n }\n }\n }\n}";
@@ -3,8 +3,8 @@ import { CmssyFormDefinition, BuildBlockContextExtra, CmssyBlockContext, CmssyCl
3
3
  export { CmssySiteLocales } from '@cmssy/types';
4
4
  import { G as GraphqlRequestOptions } from './locale-Ox_qVlNy.js';
5
5
  export { C as CMSSY_LOCALE_HEADER, b as buildLocaleSwitchHref, a as localeForPath, c as localeForPathname, l as localizeHref, d as localizeHtmlLinks, s as splitCmssyLocale } from './locale-Ox_qVlNy.js';
6
- import { Q as QueryScopedOptions } from './csp-B7ElkvAp.js';
7
- export { o as cmssyCspHeaders, q as isDevelopment, s as resolveInitialTarget, t as toCspOrigin } from './csp-B7ElkvAp.js';
6
+ import { Q as QueryScopedOptions } from './csp-DpG1NcSd.js';
7
+ export { o as cmssyCspHeaders, q as isDevelopment, s as resolveInitialTarget, t as toCspOrigin } from './csp-DpG1NcSd.js';
8
8
  export { localesFromSiteConfig, localizedPath, resolveSiteLocales, splitLocaleFromPath } from './internal/locale.js';
9
9
 
10
10
  declare const SITE_CONFIG_QUERY = "query PublicSiteConfig($workspaceSlug: String!) {\n public {\n siteConfig(workspaceSlug: $workspaceSlug) {\n id\n workspaceId\n siteName\n defaultLanguage\n enabledLanguages\n enabledFeatures\n notFoundPageId\n previewUrl\n branding {\n brandName\n logoUrl\n logoDarkUrl\n faviconUrl\n ogImageUrl\n }\n }\n }\n}";
package/dist/internal.js CHANGED
@@ -1057,10 +1057,11 @@ var DEFAULT_CMSSY_EDITOR_ORIGINS = [
1057
1057
  "https://cmssy.io",
1058
1058
  "https://www.cmssy.io"
1059
1059
  ];
1060
- function parseEditorOriginEnv(raw) {
1061
- if (!raw) return void 0;
1062
- const parts = raw.split(",").map((o) => o.trim()).filter((o) => o.length > 0);
1060
+ function parseEditorOrigin(raw) {
1061
+ if (raw === void 0) return void 0;
1062
+ const parts = (Array.isArray(raw) ? raw : [raw]).flatMap((entry) => typeof entry === "string" ? entry.split(",") : []).map((origin) => origin.trim()).filter((origin) => origin.length > 0);
1063
1063
  if (parts.length === 0) return void 0;
1064
+ if (Array.isArray(raw)) return parts;
1064
1065
  return parts.length === 1 ? parts[0] : parts;
1065
1066
  }
1066
1067
  function isDevelopment() {
@@ -1075,16 +1076,18 @@ function rejectWildcardOutsideDevelopment(value) {
1075
1076
  }
1076
1077
  }
1077
1078
  function resolveEditorOrigin(editorOrigin) {
1078
- const value = editorOrigin ?? (typeof process !== "undefined" ? parseEditorOriginEnv(process.env.CMSSY_EDITOR_ORIGIN) : void 0);
1079
- if (value === void 0) {
1080
- return isDevelopment() ? "*" : DEFAULT_CMSSY_EDITOR_ORIGINS;
1079
+ if (editorOrigin !== void 0) {
1080
+ const explicit = parseEditorOrigin(editorOrigin);
1081
+ if (explicit === void 0) return DEFAULT_CMSSY_EDITOR_ORIGINS;
1082
+ rejectWildcardOutsideDevelopment(explicit);
1083
+ return explicit;
1081
1084
  }
1082
- rejectWildcardOutsideDevelopment(value);
1083
- if (Array.isArray(value)) {
1084
- const cleaned = value.filter((o) => o && o.trim().length > 0);
1085
- return cleaned.length > 0 ? cleaned : DEFAULT_CMSSY_EDITOR_ORIGINS;
1085
+ const fromEnv = typeof process !== "undefined" ? parseEditorOrigin(process.env.CMSSY_EDITOR_ORIGIN) : void 0;
1086
+ if (fromEnv === void 0) {
1087
+ return isDevelopment() ? "*" : DEFAULT_CMSSY_EDITOR_ORIGINS;
1086
1088
  }
1087
- return value.trim().length > 0 ? value : DEFAULT_CMSSY_EDITOR_ORIGINS;
1089
+ rejectWildcardOutsideDevelopment(fromEnv);
1090
+ return fromEnv;
1088
1091
  }
1089
1092
 
1090
1093
  // src/csp.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmssy/core",
3
- "version": "11.4.0",
3
+ "version": "11.4.1",
4
4
  "description": "Framework-agnostic cmssy gateway: GraphQL client, block/field system, editor protocol. No React, no Next.",
5
5
  "keywords": [
6
6
  "cmssy",