@cmssy/react 16.0.0 → 16.1.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/client.cjs CHANGED
@@ -44,19 +44,20 @@ var TRANSPARENT = 0.01;
44
44
  var VISIBLE_TEXT_FRACTION = 0.5;
45
45
  var MEDIA = "img,svg,video,canvas,picture,iframe";
46
46
  var UNPAINTED_TEXT = /* @__PURE__ */ new Set(["SCRIPT", "STYLE", "TEMPLATE", "NOSCRIPT"]);
47
- function effectiveOpacity(node) {
48
- let value = 1;
47
+ var NOT_LAID_OUT = { laidOut: false, opacity: 0 };
48
+ function paint(node) {
49
+ let opacity = 1;
49
50
  let current = node;
50
51
  while (current) {
51
52
  const style = getComputedStyle(current);
52
- if (style.display === "none" || style.visibility === "hidden") return 0;
53
+ if (style.display === "none") return NOT_LAID_OUT;
54
+ if (style.visibility === "hidden") opacity = 0;
53
55
  const own = Number.parseFloat(style.opacity);
54
- if (Number.isFinite(own)) value *= own;
55
- if (value <= TRANSPARENT) return 0;
56
+ if (Number.isFinite(own)) opacity *= own;
56
57
  if (current === document.documentElement) break;
57
58
  current = current.parentElement;
58
59
  }
59
- return value;
60
+ return { laidOut: true, opacity: opacity <= TRANSPARENT ? 0 : opacity };
60
61
  }
61
62
  function holdsText(el) {
62
63
  for (const node of el.childNodes) {
@@ -81,15 +82,18 @@ function collectMedia(block) {
81
82
  for (const el of block.querySelectorAll(MEDIA)) media.push(el);
82
83
  return media;
83
84
  }
85
+ function laidOut(elements) {
86
+ return elements.map(paint).filter((state) => state.laidOut);
87
+ }
84
88
  function isBlockPainted(block) {
85
- const copy = collectCopy(block);
89
+ const copy = laidOut(collectCopy(block));
86
90
  if (copy.length > 0) {
87
- const visible2 = copy.filter((el) => effectiveOpacity(el) > TRANSPARENT);
91
+ const visible2 = copy.filter((state) => state.opacity > TRANSPARENT);
88
92
  return visible2.length >= copy.length * VISIBLE_TEXT_FRACTION;
89
93
  }
90
- const media = collectMedia(block);
94
+ const media = laidOut(collectMedia(block));
91
95
  if (media.length === 0) return true;
92
- return media.some((el) => effectiveOpacity(el) > TRANSPARENT);
96
+ return media.some((state) => state.opacity > TRANSPARENT);
93
97
  }
94
98
 
95
99
  // src/bridge/use-invisible-blocks.ts
package/dist/client.js CHANGED
@@ -42,19 +42,20 @@ var TRANSPARENT = 0.01;
42
42
  var VISIBLE_TEXT_FRACTION = 0.5;
43
43
  var MEDIA = "img,svg,video,canvas,picture,iframe";
44
44
  var UNPAINTED_TEXT = /* @__PURE__ */ new Set(["SCRIPT", "STYLE", "TEMPLATE", "NOSCRIPT"]);
45
- function effectiveOpacity(node) {
46
- let value = 1;
45
+ var NOT_LAID_OUT = { laidOut: false, opacity: 0 };
46
+ function paint(node) {
47
+ let opacity = 1;
47
48
  let current = node;
48
49
  while (current) {
49
50
  const style = getComputedStyle(current);
50
- if (style.display === "none" || style.visibility === "hidden") return 0;
51
+ if (style.display === "none") return NOT_LAID_OUT;
52
+ if (style.visibility === "hidden") opacity = 0;
51
53
  const own = Number.parseFloat(style.opacity);
52
- if (Number.isFinite(own)) value *= own;
53
- if (value <= TRANSPARENT) return 0;
54
+ if (Number.isFinite(own)) opacity *= own;
54
55
  if (current === document.documentElement) break;
55
56
  current = current.parentElement;
56
57
  }
57
- return value;
58
+ return { laidOut: true, opacity: opacity <= TRANSPARENT ? 0 : opacity };
58
59
  }
59
60
  function holdsText(el) {
60
61
  for (const node of el.childNodes) {
@@ -79,15 +80,18 @@ function collectMedia(block) {
79
80
  for (const el of block.querySelectorAll(MEDIA)) media.push(el);
80
81
  return media;
81
82
  }
83
+ function laidOut(elements) {
84
+ return elements.map(paint).filter((state) => state.laidOut);
85
+ }
82
86
  function isBlockPainted(block) {
83
- const copy = collectCopy(block);
87
+ const copy = laidOut(collectCopy(block));
84
88
  if (copy.length > 0) {
85
- const visible2 = copy.filter((el) => effectiveOpacity(el) > TRANSPARENT);
89
+ const visible2 = copy.filter((state) => state.opacity > TRANSPARENT);
86
90
  return visible2.length >= copy.length * VISIBLE_TEXT_FRACTION;
87
91
  }
88
- const media = collectMedia(block);
92
+ const media = laidOut(collectMedia(block));
89
93
  if (media.length === 0) return true;
90
- return media.some((el) => effectiveOpacity(el) > TRANSPARENT);
94
+ return media.some((state) => state.opacity > TRANSPARENT);
91
95
  }
92
96
 
93
97
  // src/bridge/use-invisible-blocks.ts
package/dist/index.cjs CHANGED
@@ -396,9 +396,13 @@ async function resolveCmssyLayoutSlot(config, options) {
396
396
  appContext,
397
397
  path,
398
398
  locale: explicitLocale,
399
- retry
399
+ retry,
400
+ fetch: fetchImpl
400
401
  } = options;
401
- const requestOptions = { retry: retry ?? "build" };
402
+ const requestOptions = {
403
+ retry: retry ?? "build",
404
+ ...fetchImpl ? { fetch: fetchImpl } : {}
405
+ };
402
406
  const siteLocales = await locale.resolveSiteLocales(config, requestOptions);
403
407
  const fromPath = path ? locale.splitLocaleFromPath(path, siteLocales) : { locale: siteLocales.defaultLocale, path: [] };
404
408
  const locale$1 = explicitLocale ?? fromPath.locale;
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { CmssyPageData, CmssyClientConfig, CmssyFormDefinition, CmssyBlockAuthContext, CmssyBlockWorkspace, CmssyLayoutGroup, CmssyBlockPage, RetryOption, CmssyConfig, CmssyRegionOf, CmssyRegionSettingsOf, RawBlock, CmssyBlockContext } from '@cmssy/core';
1
+ import { CmssyPageData, CmssyClientConfig, CmssyFormDefinition, CmssyBlockAuthContext, CmssyBlockWorkspace, CmssyLayoutGroup, CmssyBlockPage, RetryOption, FetchLike, CmssyConfig, CmssyRegionOf, CmssyRegionSettingsOf, RawBlock, CmssyBlockContext } from '@cmssy/core';
2
2
  export { AppToEditorMessage, BlockMeta, BlockPropsSchema, BlockRect, BlockSchema, BoundsMessage, BuildBlockContextExtra, ClickMessage, CmssyBlockAuthContext, CmssyBlockContext, CmssyBlockMember, CmssyBlockPage, CmssyBlockWorkspace, CmssyBranding, CmssyClient, CmssyClientConfig, CmssyFormDefinition, CmssyFormField, CmssyFormSettings, CmssyFormSubmitResponse, CmssyLayout, CmssyLayoutGroup, CmssyLocaleContext, CmssyLocalizedValue, CmssyModelDefinition, CmssyModelRecord, CmssyPageData, CmssyPageMeta, CmssyPageSummary, CmssyRecordList, CmssyRegion, CmssyRegionOf, CmssyRegionSettings, CmssyRegionSettingsOf, CmssyRequestError, CmssyRetryMode, CmssySiteConfig, CmssyTypedDocument, EditorToAppMessage, FetchLike, FetchLikeResponse, FetchPageOptions, FieldControl, FieldDefinition, FieldType, GraphqlRequestOptions, InferBlockContent, LayoutRegion, LayoutRegionId, MediaLike, PROTOCOL_VERSION, ParentReadyMessage, PatchMessage, PostTarget, QueryScopedOptions, RawBlock, RawLayoutBlock, ReadyMessage, RetryOption, RetryPolicy, SelectMessage, SubmitFormInput, TypedField, createCmssyClient, defineCmssyLayout, fields, graphqlRequest, isProtocolCompatible, mediaAlt, mediaUrl, mediaUrls, normalizeOrigin, parseEditorMessage, postToEditor } from '@cmssy/core';
3
3
  import { B as BlockDefinition, L as LayoutBlockPage, a as BlockMap } from './internal-server-Bkracpae.cjs';
4
4
  export { b as BlockProps, E as EditorBlockData, R as ResolveBlockDataOptions, c as ResolveLayoutBlockDataOptions, d as buildBlockMap, e as defineBlock, r as resolveEditorBlockData, f as resolveEditorLayoutBlockData } from './internal-server-Bkracpae.cjs';
@@ -32,6 +32,7 @@ interface ResolveCmssyLayoutSlotBase {
32
32
  forms?: Record<string, CmssyFormDefinition>;
33
33
  appContext?: Record<string, unknown>;
34
34
  retry?: RetryOption;
35
+ fetch?: FetchLike;
35
36
  }
36
37
  type CmssyLayoutSlotLocaleSource = {
37
38
  path: string[];
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { CmssyPageData, CmssyClientConfig, CmssyFormDefinition, CmssyBlockAuthContext, CmssyBlockWorkspace, CmssyLayoutGroup, CmssyBlockPage, RetryOption, CmssyConfig, CmssyRegionOf, CmssyRegionSettingsOf, RawBlock, CmssyBlockContext } from '@cmssy/core';
1
+ import { CmssyPageData, CmssyClientConfig, CmssyFormDefinition, CmssyBlockAuthContext, CmssyBlockWorkspace, CmssyLayoutGroup, CmssyBlockPage, RetryOption, FetchLike, CmssyConfig, CmssyRegionOf, CmssyRegionSettingsOf, RawBlock, CmssyBlockContext } from '@cmssy/core';
2
2
  export { AppToEditorMessage, BlockMeta, BlockPropsSchema, BlockRect, BlockSchema, BoundsMessage, BuildBlockContextExtra, ClickMessage, CmssyBlockAuthContext, CmssyBlockContext, CmssyBlockMember, CmssyBlockPage, CmssyBlockWorkspace, CmssyBranding, CmssyClient, CmssyClientConfig, CmssyFormDefinition, CmssyFormField, CmssyFormSettings, CmssyFormSubmitResponse, CmssyLayout, CmssyLayoutGroup, CmssyLocaleContext, CmssyLocalizedValue, CmssyModelDefinition, CmssyModelRecord, CmssyPageData, CmssyPageMeta, CmssyPageSummary, CmssyRecordList, CmssyRegion, CmssyRegionOf, CmssyRegionSettings, CmssyRegionSettingsOf, CmssyRequestError, CmssyRetryMode, CmssySiteConfig, CmssyTypedDocument, EditorToAppMessage, FetchLike, FetchLikeResponse, FetchPageOptions, FieldControl, FieldDefinition, FieldType, GraphqlRequestOptions, InferBlockContent, LayoutRegion, LayoutRegionId, MediaLike, PROTOCOL_VERSION, ParentReadyMessage, PatchMessage, PostTarget, QueryScopedOptions, RawBlock, RawLayoutBlock, ReadyMessage, RetryOption, RetryPolicy, SelectMessage, SubmitFormInput, TypedField, createCmssyClient, defineCmssyLayout, fields, graphqlRequest, isProtocolCompatible, mediaAlt, mediaUrl, mediaUrls, normalizeOrigin, parseEditorMessage, postToEditor } from '@cmssy/core';
3
3
  import { B as BlockDefinition, L as LayoutBlockPage, a as BlockMap } from './internal-server-Bkracpae.js';
4
4
  export { b as BlockProps, E as EditorBlockData, R as ResolveBlockDataOptions, c as ResolveLayoutBlockDataOptions, d as buildBlockMap, e as defineBlock, r as resolveEditorBlockData, f as resolveEditorLayoutBlockData } from './internal-server-Bkracpae.js';
@@ -32,6 +32,7 @@ interface ResolveCmssyLayoutSlotBase {
32
32
  forms?: Record<string, CmssyFormDefinition>;
33
33
  appContext?: Record<string, unknown>;
34
34
  retry?: RetryOption;
35
+ fetch?: FetchLike;
35
36
  }
36
37
  type CmssyLayoutSlotLocaleSource = {
37
38
  path: string[];
package/dist/index.js CHANGED
@@ -396,9 +396,13 @@ async function resolveCmssyLayoutSlot(config, options) {
396
396
  appContext,
397
397
  path,
398
398
  locale: explicitLocale,
399
- retry
399
+ retry,
400
+ fetch: fetchImpl
400
401
  } = options;
401
- const requestOptions = { retry: retry ?? "build" };
402
+ const requestOptions = {
403
+ retry: retry ?? "build",
404
+ ...fetchImpl ? { fetch: fetchImpl } : {}
405
+ };
402
406
  const siteLocales = await resolveSiteLocales(config, requestOptions);
403
407
  const fromPath = path ? splitLocaleFromPath(path, siteLocales) : { locale: siteLocales.defaultLocale, path: [] };
404
408
  const locale = explicitLocale ?? fromPath.locale;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmssy/react",
3
- "version": "16.0.0",
3
+ "version": "16.1.1",
4
4
  "description": "React blocks, renderers, data client and editor bridge for cmssy headless sites",
5
5
  "keywords": [
6
6
  "cmssy",
@@ -97,7 +97,7 @@
97
97
  },
98
98
  "dependencies": {
99
99
  "@cmssy/types": "0.41.0",
100
- "@cmssy/core": "16.0.0"
100
+ "@cmssy/core": "16.1.1"
101
101
  },
102
102
  "scripts": {
103
103
  "build": "tsup",