@cmssy/react 19.34.1 → 19.35.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/index.cjs CHANGED
@@ -415,6 +415,7 @@ async function resolveCmssyLayoutSlot(config, options) {
415
415
  retry,
416
416
  fetch: fetchImpl,
417
417
  layoutStore,
418
+ readByLayoutKey = false,
418
419
  onTransientLayoutFailure = "throw"
419
420
  } = options;
420
421
  const requestOptions = {
@@ -432,11 +433,26 @@ async function resolveCmssyLayoutSlot(config, options) {
432
433
  try {
433
434
  groups = await internal.readThroughLayoutStore(
434
435
  layoutStore,
435
- internal.layoutStoreKey(config, page.slug, previewSecret),
436
- () => internal.fetchLayouts(config, page.slug, {
437
- previewSecret,
438
- ...requestOptions
439
- })
436
+ internal.layoutStoreKey(config, { pageSlug: page.slug, previewSecret }),
437
+ async () => {
438
+ if (editMode || preview || !readByLayoutKey) {
439
+ return internal.fetchLayouts(config, page.slug, {
440
+ previewSecret,
441
+ ...requestOptions
442
+ });
443
+ }
444
+ const layoutKey = await internal.fetchLayoutKey(
445
+ config,
446
+ page.slug,
447
+ requestOptions
448
+ );
449
+ if (!layoutKey) return [];
450
+ return internal.readThroughLayoutStore(
451
+ layoutStore,
452
+ internal.layoutStoreKey(config, { layoutKey }),
453
+ () => internal.fetchLayoutsByKey(config, layoutKey, requestOptions)
454
+ );
455
+ }
440
456
  );
441
457
  } catch (error) {
442
458
  if (onTransientLayoutFailure !== "degrade" || !core.isTransientRequestError(error)) {
package/dist/index.d.cts CHANGED
@@ -37,6 +37,7 @@ interface ResolveCmssyLayoutSlotBase {
37
37
  retry?: RetryOption;
38
38
  fetch?: FetchLike;
39
39
  layoutStore?: CmssyLayoutStore;
40
+ readByLayoutKey?: boolean;
40
41
  onTransientLayoutFailure?: "throw" | "degrade";
41
42
  }
42
43
  type CmssyLayoutSlotLocaleSource = {
package/dist/index.d.ts CHANGED
@@ -37,6 +37,7 @@ interface ResolveCmssyLayoutSlotBase {
37
37
  retry?: RetryOption;
38
38
  fetch?: FetchLike;
39
39
  layoutStore?: CmssyLayoutStore;
40
+ readByLayoutKey?: boolean;
40
41
  onTransientLayoutFailure?: "throw" | "degrade";
41
42
  }
42
43
  type CmssyLayoutSlotLocaleSource = {
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { blocksToSchemas, isTransientRequestError, resolveEditorOrigin, verifyCmssyEditToken, CMSSY_EDIT_TOKEN_HEADER } from '@cmssy/core';
2
2
  export { CmssyRequestError, FieldType, MediaType, PROTOCOL_VERSION, createCmssyClient, defineCmssyLayout, evaluateFieldConditionGroup, fields, graphqlRequest, isFormFieldRequired, isFormFieldVisible, isProtocolCompatible, mediaAlt, mediaDuration, mediaType, mediaTypeValues, mediaUrl, mediaUrls, normalizeOrigin, parseEditorMessage, postToEditor, typedOperation, visibleFormFields } from '@cmssy/core';
3
- import { unreachableShowWhenTargets, buildBlockContext, readThroughLayoutStore, layoutStoreKey, fetchLayouts, normalizeBlockContent, asBucket, layoutRegionIds, fetchPage, resolveSiteLocales as resolveSiteLocales$1, getBlockContentForLanguage, resolveRelationContent } from '@cmssy/core/internal';
3
+ import { unreachableShowWhenTargets, buildBlockContext, readThroughLayoutStore, layoutStoreKey, fetchLayouts, fetchLayoutKey, fetchLayoutsByKey, normalizeBlockContent, asBucket, layoutRegionIds, fetchPage, resolveSiteLocales as resolveSiteLocales$1, getBlockContentForLanguage, resolveRelationContent } from '@cmssy/core/internal';
4
4
  export { buildBlockContext } from '@cmssy/core/internal';
5
5
  import { createElement } from 'react';
6
6
  import { BlockErrorBoundary } from '@cmssy/react/block-error-boundary';
@@ -415,6 +415,7 @@ async function resolveCmssyLayoutSlot(config, options) {
415
415
  retry,
416
416
  fetch: fetchImpl,
417
417
  layoutStore,
418
+ readByLayoutKey = false,
418
419
  onTransientLayoutFailure = "throw"
419
420
  } = options;
420
421
  const requestOptions = {
@@ -432,11 +433,26 @@ async function resolveCmssyLayoutSlot(config, options) {
432
433
  try {
433
434
  groups = await readThroughLayoutStore(
434
435
  layoutStore,
435
- layoutStoreKey(config, page.slug, previewSecret),
436
- () => fetchLayouts(config, page.slug, {
437
- previewSecret,
438
- ...requestOptions
439
- })
436
+ layoutStoreKey(config, { pageSlug: page.slug, previewSecret }),
437
+ async () => {
438
+ if (editMode || preview || !readByLayoutKey) {
439
+ return fetchLayouts(config, page.slug, {
440
+ previewSecret,
441
+ ...requestOptions
442
+ });
443
+ }
444
+ const layoutKey = await fetchLayoutKey(
445
+ config,
446
+ page.slug,
447
+ requestOptions
448
+ );
449
+ if (!layoutKey) return [];
450
+ return readThroughLayoutStore(
451
+ layoutStore,
452
+ layoutStoreKey(config, { layoutKey }),
453
+ () => fetchLayoutsByKey(config, layoutKey, requestOptions)
454
+ );
455
+ }
440
456
  );
441
457
  } catch (error) {
442
458
  if (onTransientLayoutFailure !== "degrade" || !isTransientRequestError(error)) {
package/dist/spa.cjs CHANGED
@@ -212,6 +212,7 @@ async function resolveCmssyLayoutSlot(config, options) {
212
212
  retry,
213
213
  fetch: fetchImpl,
214
214
  layoutStore,
215
+ readByLayoutKey = false,
215
216
  onTransientLayoutFailure = "throw"
216
217
  } = options;
217
218
  const requestOptions = {
@@ -229,11 +230,26 @@ async function resolveCmssyLayoutSlot(config, options) {
229
230
  try {
230
231
  groups = await internal.readThroughLayoutStore(
231
232
  layoutStore,
232
- internal.layoutStoreKey(config, page.slug, previewSecret),
233
- () => internal.fetchLayouts(config, page.slug, {
234
- previewSecret,
235
- ...requestOptions
236
- })
233
+ internal.layoutStoreKey(config, { pageSlug: page.slug, previewSecret }),
234
+ async () => {
235
+ if (editMode || preview || !readByLayoutKey) {
236
+ return internal.fetchLayouts(config, page.slug, {
237
+ previewSecret,
238
+ ...requestOptions
239
+ });
240
+ }
241
+ const layoutKey = await internal.fetchLayoutKey(
242
+ config,
243
+ page.slug,
244
+ requestOptions
245
+ );
246
+ if (!layoutKey) return [];
247
+ return internal.readThroughLayoutStore(
248
+ layoutStore,
249
+ internal.layoutStoreKey(config, { layoutKey }),
250
+ () => internal.fetchLayoutsByKey(config, layoutKey, requestOptions)
251
+ );
252
+ }
237
253
  );
238
254
  } catch (error) {
239
255
  if (onTransientLayoutFailure !== "degrade" || !core.isTransientRequestError(error)) {
package/dist/spa.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { useMemo, useState, useRef, useEffect, useCallback, createElement } from 'react';
3
- import { layoutRegionIds, fetchPage, buildBlockContext, readThroughLayoutStore, layoutStoreKey, fetchLayouts, normalizeBlockContent, asBucket, getBlockContentForLanguage, resolveRelationContent } from '@cmssy/core/internal';
3
+ import { layoutRegionIds, fetchPage, buildBlockContext, readThroughLayoutStore, layoutStoreKey, fetchLayouts, fetchLayoutKey, fetchLayoutsByKey, normalizeBlockContent, asBucket, getBlockContentForLanguage, resolveRelationContent } from '@cmssy/core/internal';
4
4
  import { isTransientRequestError, resolveEditorOrigin, blocksToSchemas } from '@cmssy/core';
5
5
  import { resolveSiteLocales, splitLocaleFromPath } from '@cmssy/core/internal/locale';
6
6
  import { BlockErrorBoundary } from '@cmssy/react/block-error-boundary';
@@ -210,6 +210,7 @@ async function resolveCmssyLayoutSlot(config, options) {
210
210
  retry,
211
211
  fetch: fetchImpl,
212
212
  layoutStore,
213
+ readByLayoutKey = false,
213
214
  onTransientLayoutFailure = "throw"
214
215
  } = options;
215
216
  const requestOptions = {
@@ -227,11 +228,26 @@ async function resolveCmssyLayoutSlot(config, options) {
227
228
  try {
228
229
  groups = await readThroughLayoutStore(
229
230
  layoutStore,
230
- layoutStoreKey(config, page.slug, previewSecret),
231
- () => fetchLayouts(config, page.slug, {
232
- previewSecret,
233
- ...requestOptions
234
- })
231
+ layoutStoreKey(config, { pageSlug: page.slug, previewSecret }),
232
+ async () => {
233
+ if (editMode || preview || !readByLayoutKey) {
234
+ return fetchLayouts(config, page.slug, {
235
+ previewSecret,
236
+ ...requestOptions
237
+ });
238
+ }
239
+ const layoutKey = await fetchLayoutKey(
240
+ config,
241
+ page.slug,
242
+ requestOptions
243
+ );
244
+ if (!layoutKey) return [];
245
+ return readThroughLayoutStore(
246
+ layoutStore,
247
+ layoutStoreKey(config, { layoutKey }),
248
+ () => fetchLayoutsByKey(config, layoutKey, requestOptions)
249
+ );
250
+ }
235
251
  );
236
252
  } catch (error) {
237
253
  if (onTransientLayoutFailure !== "degrade" || !isTransientRequestError(error)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmssy/react",
3
- "version": "19.34.1",
3
+ "version": "19.35.0",
4
4
  "engines": {
5
5
  "node": ">=20"
6
6
  },
@@ -110,7 +110,7 @@
110
110
  },
111
111
  "dependencies": {
112
112
  "@cmssy/types": "0.77.0",
113
- "@cmssy/core": "19.34.1"
113
+ "@cmssy/core": "19.35.0"
114
114
  },
115
115
  "scripts": {
116
116
  "build": "tsup",