@cmssy/react 16.7.1 → 16.8.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/client.cjs CHANGED
@@ -650,6 +650,7 @@ var DEBOUNCE_MS = 300;
650
650
  function useBlockLoaderData({
651
651
  enabled,
652
652
  url = CMSSY_BLOCK_DATA_PATH,
653
+ token,
653
654
  blocks,
654
655
  locale,
655
656
  defaultLocale,
@@ -677,7 +678,10 @@ function useBlockLoaderData({
677
678
  try {
678
679
  const response = await fetch(url, {
679
680
  method: "POST",
680
- headers: { "content-type": "application/json" },
681
+ headers: {
682
+ "content-type": "application/json",
683
+ ...token ? { [core.CMSSY_EDIT_TOKEN_HEADER]: token } : {}
684
+ },
681
685
  body: request,
682
686
  signal: controller.signal
683
687
  });
@@ -705,7 +709,7 @@ function useBlockLoaderData({
705
709
  clearTimeout(timer);
706
710
  controller.abort();
707
711
  };
708
- }, [request, url, blocks.length]);
712
+ }, [request, url, token, blocks.length]);
709
713
  return data;
710
714
  }
711
715
 
@@ -984,6 +988,7 @@ function EditableBlocks({
984
988
  const liveData = useBlockLoaderData({
985
989
  enabled: loaderBlocks.length > 0,
986
990
  ...edit.blockDataUrl ? { url: edit.blockDataUrl } : {},
991
+ ...edit.blockDataToken ? { token: edit.blockDataToken } : {},
987
992
  blocks: loaderBlocks,
988
993
  locale,
989
994
  defaultLocale,
package/dist/client.d.cts CHANGED
@@ -9,6 +9,7 @@ interface EditBridgeConfig {
9
9
  blockMeta?: Record<string, BlockMeta>;
10
10
  layoutRegions?: readonly LayoutRegion[] | undefined;
11
11
  blockDataUrl?: string;
12
+ blockDataToken?: string;
12
13
  }
13
14
  type PatchMap = Partial<Record<string, Record<string, unknown>>>;
14
15
  interface InsertedBlock {
package/dist/client.d.ts CHANGED
@@ -9,6 +9,7 @@ interface EditBridgeConfig {
9
9
  blockMeta?: Record<string, BlockMeta>;
10
10
  layoutRegions?: readonly LayoutRegion[] | undefined;
11
11
  blockDataUrl?: string;
12
+ blockDataToken?: string;
12
13
  }
13
14
  type PatchMap = Partial<Record<string, Record<string, unknown>>>;
14
15
  interface InsertedBlock {
package/dist/client.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { useState, useRef, useEffect, useMemo, createElement } from 'react';
3
- import { blocksToMeta, blocksToSchemas, postToEditor, layoutRegionsToBridge, PROTOCOL_VERSION, parseEditorMessage } from '@cmssy/core';
3
+ import { blocksToMeta, blocksToSchemas, postToEditor, layoutRegionsToBridge, PROTOCOL_VERSION, parseEditorMessage, CMSSY_EDIT_TOKEN_HEADER } from '@cmssy/core';
4
4
  import { resolveInitialTarget, buildBlockContext, getBlockContentForLanguage, normalizeBlockContent, asBucket } from '@cmssy/core/internal';
5
5
  import { BlockErrorBoundary } from '@cmssy/react/block-error-boundary';
6
6
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
@@ -648,6 +648,7 @@ var DEBOUNCE_MS = 300;
648
648
  function useBlockLoaderData({
649
649
  enabled,
650
650
  url = CMSSY_BLOCK_DATA_PATH,
651
+ token,
651
652
  blocks,
652
653
  locale,
653
654
  defaultLocale,
@@ -675,7 +676,10 @@ function useBlockLoaderData({
675
676
  try {
676
677
  const response = await fetch(url, {
677
678
  method: "POST",
678
- headers: { "content-type": "application/json" },
679
+ headers: {
680
+ "content-type": "application/json",
681
+ ...token ? { [CMSSY_EDIT_TOKEN_HEADER]: token } : {}
682
+ },
679
683
  body: request,
680
684
  signal: controller.signal
681
685
  });
@@ -703,7 +707,7 @@ function useBlockLoaderData({
703
707
  clearTimeout(timer);
704
708
  controller.abort();
705
709
  };
706
- }, [request, url, blocks.length]);
710
+ }, [request, url, token, blocks.length]);
707
711
  return data;
708
712
  }
709
713
 
@@ -982,6 +986,7 @@ function EditableBlocks({
982
986
  const liveData = useBlockLoaderData({
983
987
  enabled: loaderBlocks.length > 0,
984
988
  ...edit.blockDataUrl ? { url: edit.blockDataUrl } : {},
989
+ ...edit.blockDataToken ? { token: edit.blockDataToken } : {},
985
990
  blocks: loaderBlocks,
986
991
  locale,
987
992
  defaultLocale,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmssy/react",
3
- "version": "16.7.1",
3
+ "version": "16.8.0",
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.49.0",
100
- "@cmssy/core": "16.7.1"
100
+ "@cmssy/core": "16.8.0"
101
101
  },
102
102
  "scripts": {
103
103
  "build": "tsup",