@prismicio/react 3.5.0 → 3.5.1-canary.3b9e40e

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/README.md CHANGED
@@ -90,8 +90,8 @@ limitations under the License.
90
90
  [npm-version-href]: https://npmjs.com/package/@prismicio/react
91
91
  [npm-downloads-src]: https://img.shields.io/npm/dm/@prismicio/react.svg
92
92
  [npm-downloads-href]: https://npmjs.com/package/@prismicio/react
93
- [github-actions-ci-src]: https://github.com/prismicio/prismic-react/workflows/ci/badge.svg
94
- [github-actions-ci-href]: https://github.com/prismicio/prismic-react/actions?query=workflow%3Aci
93
+ [github-actions-ci-src]: https://github.com/prismicio/prismic-react/actions/workflows/validate.yml/badge.svg
94
+ [github-actions-ci-href]: https://github.com/prismicio/prismic-react/actions/workflows/validate.yml
95
95
  [codecov-src]: https://img.shields.io/codecov/c/github/prismicio/prismic-react.svg
96
96
  [codecov-href]: https://codecov.io/gh/prismicio/prismic-react
97
97
  [conventional-commits-src]: https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg
@@ -15,19 +15,20 @@ function CommentMarker(props) {
15
15
  const id = useId();
16
16
  const isClient = useIsClient();
17
17
  const anchorRef = useRef(null);
18
+ const anchorValue = `__prismic_react_internal_comment_anchor_${id}__`;
18
19
  useLayoutEffect(() => {
19
20
  let anchor = anchorRef.current;
20
21
  if (!anchor?.isConnected) {
21
- anchor = findTextNode(id);
22
+ anchor = findTextNode(anchorValue);
22
23
  if (!anchor) return;
23
- anchor.data = "";
24
24
  anchorRef.current = anchor;
25
25
  }
26
+ if (anchor.data !== "") anchor.data = "";
26
27
  const comment = document.createComment(value);
27
28
  anchor.after(comment);
28
29
  return () => comment.remove();
29
30
  });
30
- return isClient ? id : null;
31
+ return isClient ? anchorValue : null;
31
32
  }
32
33
  function useIsClient() {
33
34
  return useSyncExternalStore(subscribe, getClientSnapshot, getServerSnapshot);
@@ -1 +1 @@
1
- {"version":3,"file":"SliceBoundary.js","names":[],"sources":["../src/SliceBoundary.tsx"],"sourcesContent":["\"use client\"\n\nimport { type ReactNode, useId, useLayoutEffect, useRef, useSyncExternalStore } from \"react\"\n\ntype SliceBoundaryProps = {\n\tchildren: ReactNode\n\tsliceId: string\n}\n\nexport function SliceBoundary(props: SliceBoundaryProps): ReactNode {\n\tconst { children, sliceId } = props\n\n\treturn (\n\t\t<>\n\t\t\t<CommentMarker value={`prismic-slice-start:${sliceId}`} />\n\t\t\t{children}\n\t\t\t<CommentMarker value={`prismic-slice-end:${sliceId}`} />\n\t\t</>\n\t)\n}\n\ntype CommentMarkerProps = {\n\tvalue: string\n}\n\nfunction CommentMarker(props: CommentMarkerProps) {\n\tconst { value } = props\n\tconst id = useId()\n\tconst isClient = useIsClient()\n\tconst anchorRef = useRef<Text>(null)\n\n\tuseLayoutEffect(() => {\n\t\tlet anchor = anchorRef.current\n\n\t\tif (!anchor?.isConnected) {\n\t\t\tanchor = findTextNode(id)\n\t\t\tif (!anchor) return\n\n\t\t\tanchor.data = \"\"\n\t\t\tanchorRef.current = anchor\n\t\t}\n\n\t\tconst comment = document.createComment(value)\n\t\tanchor.after(comment)\n\n\t\treturn () => comment.remove()\n\t})\n\n\treturn isClient ? id : null\n}\n\nfunction useIsClient() {\n\treturn useSyncExternalStore(subscribe, getClientSnapshot, getServerSnapshot)\n}\n\nfunction subscribe() {\n\treturn () => {}\n}\n\nfunction getClientSnapshot() {\n\treturn true\n}\n\nfunction getServerSnapshot() {\n\treturn false\n}\n\nfunction findTextNode(value: string) {\n\tconst walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT)\n\n\twhile (walker.nextNode()) {\n\t\tconst node = walker.currentNode\n\t\tif (node instanceof Text && node.data === value) return node\n\t}\n\n\treturn null\n}\n"],"mappings":";;;;AASA,SAAgB,cAAc,OAAsC;CACnE,MAAM,EAAE,UAAU,YAAY;CAE9B,OACC,qBAAA,YAAA,EAAA,UAAA;EACC,oBAAC,eAAD,EAAe,OAAO,uBAAuB,UAAY,CAAA;EACxD;EACD,oBAAC,eAAD,EAAe,OAAO,qBAAqB,UAAY,CAAA;CACtD,EAAA,CAAA;AAEJ;AAMA,SAAS,cAAc,OAA2B;CACjD,MAAM,EAAE,UAAU;CAClB,MAAM,KAAK,MAAM;CACjB,MAAM,WAAW,YAAY;CAC7B,MAAM,YAAY,OAAa,IAAI;CAEnC,sBAAsB;EACrB,IAAI,SAAS,UAAU;EAEvB,IAAI,CAAC,QAAQ,aAAa;GACzB,SAAS,aAAa,EAAE;GACxB,IAAI,CAAC,QAAQ;GAEb,OAAO,OAAO;GACd,UAAU,UAAU;EACrB;EAEA,MAAM,UAAU,SAAS,cAAc,KAAK;EAC5C,OAAO,MAAM,OAAO;EAEpB,aAAa,QAAQ,OAAO;CAC7B,CAAC;CAED,OAAO,WAAW,KAAK;AACxB;AAEA,SAAS,cAAc;CACtB,OAAO,qBAAqB,WAAW,mBAAmB,iBAAiB;AAC5E;AAEA,SAAS,YAAY;CACpB,aAAa,CAAC;AACf;AAEA,SAAS,oBAAoB;CAC5B,OAAO;AACR;AAEA,SAAS,oBAAoB;CAC5B,OAAO;AACR;AAEA,SAAS,aAAa,OAAe;CACpC,MAAM,SAAS,SAAS,iBAAiB,SAAS,MAAM,WAAW,SAAS;CAE5E,OAAO,OAAO,SAAS,GAAG;EACzB,MAAM,OAAO,OAAO;EACpB,IAAI,gBAAgB,QAAQ,KAAK,SAAS,OAAO,OAAO;CACzD;CAEA,OAAO;AACR"}
1
+ {"version":3,"file":"SliceBoundary.js","names":[],"sources":["../src/SliceBoundary.tsx"],"sourcesContent":["\"use client\"\n\nimport { type ReactNode, useId, useLayoutEffect, useRef, useSyncExternalStore } from \"react\"\n\ntype SliceBoundaryProps = {\n\tchildren: ReactNode\n\tsliceId: string\n}\n\nexport function SliceBoundary(props: SliceBoundaryProps): ReactNode {\n\tconst { children, sliceId } = props\n\n\treturn (\n\t\t<>\n\t\t\t<CommentMarker value={`prismic-slice-start:${sliceId}`} />\n\t\t\t{children}\n\t\t\t<CommentMarker value={`prismic-slice-end:${sliceId}`} />\n\t\t</>\n\t)\n}\n\ntype CommentMarkerProps = {\n\tvalue: string\n}\n\nfunction CommentMarker(props: CommentMarkerProps) {\n\tconst { value } = props\n\tconst id = useId()\n\tconst isClient = useIsClient()\n\tconst anchorRef = useRef<Text>(null)\n\tconst anchorValue = `__prismic_react_internal_comment_anchor_${id}__`\n\n\tuseLayoutEffect(() => {\n\t\tlet anchor = anchorRef.current\n\n\t\tif (!anchor?.isConnected) {\n\t\t\tanchor = findTextNode(anchorValue)\n\t\t\tif (!anchor) return\n\t\t\tanchorRef.current = anchor\n\t\t}\n\n\t\t// React restores the text when a hidden Suspense or Activity subtree is shown again.\n\t\tif (anchor.data !== \"\") anchor.data = \"\"\n\n\t\tconst comment = document.createComment(value)\n\t\tanchor.after(comment)\n\n\t\treturn () => comment.remove()\n\t})\n\n\treturn isClient ? anchorValue : null\n}\n\nfunction useIsClient() {\n\treturn useSyncExternalStore(subscribe, getClientSnapshot, getServerSnapshot)\n}\n\nfunction subscribe() {\n\treturn () => {}\n}\n\nfunction getClientSnapshot() {\n\treturn true\n}\n\nfunction getServerSnapshot() {\n\treturn false\n}\n\nfunction findTextNode(value: string) {\n\tconst walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT)\n\n\twhile (walker.nextNode()) {\n\t\tconst node = walker.currentNode\n\t\tif (node instanceof Text && node.data === value) return node\n\t}\n\n\treturn null\n}\n"],"mappings":";;;;AASA,SAAgB,cAAc,OAAsC;CACnE,MAAM,EAAE,UAAU,YAAY;CAE9B,OACC,qBAAA,YAAA,EAAA,UAAA;EACC,oBAAC,eAAD,EAAe,OAAO,uBAAuB,UAAY,CAAA;EACxD;EACD,oBAAC,eAAD,EAAe,OAAO,qBAAqB,UAAY,CAAA;CACtD,EAAA,CAAA;AAEJ;AAMA,SAAS,cAAc,OAA2B;CACjD,MAAM,EAAE,UAAU;CAClB,MAAM,KAAK,MAAM;CACjB,MAAM,WAAW,YAAY;CAC7B,MAAM,YAAY,OAAa,IAAI;CACnC,MAAM,cAAc,2CAA2C,GAAG;CAElE,sBAAsB;EACrB,IAAI,SAAS,UAAU;EAEvB,IAAI,CAAC,QAAQ,aAAa;GACzB,SAAS,aAAa,WAAW;GACjC,IAAI,CAAC,QAAQ;GACb,UAAU,UAAU;EACrB;EAGA,IAAI,OAAO,SAAS,IAAI,OAAO,OAAO;EAEtC,MAAM,UAAU,SAAS,cAAc,KAAK;EAC5C,OAAO,MAAM,OAAO;EAEpB,aAAa,QAAQ,OAAO;CAC7B,CAAC;CAED,OAAO,WAAW,cAAc;AACjC;AAEA,SAAS,cAAc;CACtB,OAAO,qBAAqB,WAAW,mBAAmB,iBAAiB;AAC5E;AAEA,SAAS,YAAY;CACpB,aAAa,CAAC;AACf;AAEA,SAAS,oBAAoB;CAC5B,OAAO;AACR;AAEA,SAAS,oBAAoB;CAC5B,OAAO;AACR;AAEA,SAAS,aAAa,OAAe;CACpC,MAAM,SAAS,SAAS,iBAAiB,SAAS,MAAM,WAAW,SAAS;CAE5E,OAAO,OAAO,SAAS,GAAG;EACzB,MAAM,OAAO,OAAO;EACpB,IAAI,gBAAgB,QAAQ,KAAK,SAAS,OAAO,OAAO;CACzD;CAEA,OAAO;AACR"}
package/dist/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "3.5.0";
2
+ var version = "3.5.1-canary.3b9e40e";
3
3
  //#endregion
4
4
  export { version };
5
5
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismicio/react",
3
- "version": "3.5.0",
3
+ "version": "3.5.1-canary.3b9e40e",
4
4
  "description": "React components and hooks to fetch and present Prismic content",
5
5
  "keywords": [
6
6
  "prismic",
@@ -58,7 +58,7 @@
58
58
  "@prismicio/types-internal": "^3.17.2",
59
59
  "@types/react": "^19.3.0",
60
60
  "@types/react-dom": "^19.3.0",
61
- "dotenv": "^18.0.2",
61
+ "dotenv": "^18.0.4",
62
62
  "oxfmt": "^0.70.0",
63
63
  "oxlint": "^1.85.0",
64
64
  "playwright": "^1.63.0",
@@ -28,25 +28,27 @@ function CommentMarker(props: CommentMarkerProps) {
28
28
  const id = useId()
29
29
  const isClient = useIsClient()
30
30
  const anchorRef = useRef<Text>(null)
31
+ const anchorValue = `__prismic_react_internal_comment_anchor_${id}__`
31
32
 
32
33
  useLayoutEffect(() => {
33
34
  let anchor = anchorRef.current
34
35
 
35
36
  if (!anchor?.isConnected) {
36
- anchor = findTextNode(id)
37
+ anchor = findTextNode(anchorValue)
37
38
  if (!anchor) return
38
-
39
- anchor.data = ""
40
39
  anchorRef.current = anchor
41
40
  }
42
41
 
42
+ // React restores the text when a hidden Suspense or Activity subtree is shown again.
43
+ if (anchor.data !== "") anchor.data = ""
44
+
43
45
  const comment = document.createComment(value)
44
46
  anchor.after(comment)
45
47
 
46
48
  return () => comment.remove()
47
49
  })
48
50
 
49
- return isClient ? id : null
51
+ return isClient ? anchorValue : null
50
52
  }
51
53
 
52
54
  function useIsClient() {