@storyblok/react 6.1.3 → 6.1.4
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/core/state.js +1 -1
- package/dist/core/state.mjs +13 -14
- package/dist/core/story-cache.js +1 -0
- package/dist/core/story-cache.mjs +12 -0
- package/dist/rsc/live-edit-update-action.js +1 -1
- package/dist/rsc/live-edit-update-action.mjs +11 -6
- package/dist/rsc/live-editing.js +1 -1
- package/dist/rsc/live-editing.mjs +26 -20
- package/dist/rsc/story.js +1 -1
- package/dist/rsc/story.mjs +17 -16
- package/dist/server/server-story.js +1 -1
- package/dist/server/server-story.mjs +11 -10
- package/package.json +1 -1
package/dist/core/state.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let n=null;const e=new Map;let o=!1,l=null;const c=()=>n,b=t=>{n=t},p=t=>(Object.entries(t).forEach(([s,a])=>{e.set(s,a)}),e),m=t=>e.has(t)?e.get(t):(console.error(`Component ${t} doesn't exist.`),!1),r=()=>o,C=t=>{o=t},k=()=>l,u=t=>{l=t};exports.getComponent=m;exports.getCustomFallbackComponent=k;exports.getEnableFallbackComponent=r;exports.getStoryblokApiInstance=c;exports.setComponents=p;exports.setCustomFallbackComponent=u;exports.setEnableFallbackComponent=C;exports.setStoryblokApiInstance=b;
|
package/dist/core/state.mjs
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
let
|
|
1
|
+
let e = null;
|
|
2
2
|
const n = /* @__PURE__ */ new Map();
|
|
3
|
-
let
|
|
4
|
-
|
|
5
|
-
const c = () => o, r = (t) => {
|
|
6
|
-
o = t;
|
|
7
|
-
}, b = (t) => (Object.entries(t).forEach(([l, a]) => {
|
|
8
|
-
n.set(l, a);
|
|
9
|
-
}), n), p = (t) => n.has(t) ? n.get(t) : (console.error(`Component ${t} doesn't exist.`), !1), C = () => e, m = (t) => {
|
|
3
|
+
let o = !1, s = null;
|
|
4
|
+
const c = () => e, r = (t) => {
|
|
10
5
|
e = t;
|
|
11
|
-
},
|
|
6
|
+
}, p = (t) => (Object.entries(t).forEach(([l, a]) => {
|
|
7
|
+
n.set(l, a);
|
|
8
|
+
}), n), b = (t) => n.has(t) ? n.get(t) : (console.error(`Component ${t} doesn't exist.`), !1), m = () => o, C = (t) => {
|
|
9
|
+
o = t;
|
|
10
|
+
}, k = () => s, u = (t) => {
|
|
12
11
|
s = t;
|
|
13
12
|
};
|
|
14
13
|
export {
|
|
15
|
-
|
|
14
|
+
b as getComponent,
|
|
16
15
|
k as getCustomFallbackComponent,
|
|
17
|
-
|
|
16
|
+
m as getEnableFallbackComponent,
|
|
18
17
|
c as getStoryblokApiInstance,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
p as setComponents,
|
|
19
|
+
u as setCustomFallbackComponent,
|
|
20
|
+
C as setEnableFallbackComponent,
|
|
22
21
|
r as setStoryblokApiInstance
|
|
23
22
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});globalThis.storyCache=globalThis.storyCache||new Map;const a=e=>typeof(e==null?void 0:e.id)!="number"?null:String(e.id),n=e=>{const c=a(e);if(!c)return e;const t=globalThis.storyCache.get(c);return globalThis.storyCache.delete(c),t?{...e,...t}:e};exports.consumeCachedStory=n;exports.getStoryCacheKey=a;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
globalThis.storyCache = globalThis.storyCache || /* @__PURE__ */ new Map();
|
|
2
|
+
const n = (e) => typeof (e == null ? void 0 : e.id) != "number" ? null : String(e.id), h = (e) => {
|
|
3
|
+
const c = n(e);
|
|
4
|
+
if (!c)
|
|
5
|
+
return e;
|
|
6
|
+
const a = globalThis.storyCache.get(c);
|
|
7
|
+
return globalThis.storyCache.delete(c), a ? { ...e, ...a } : e;
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
h as consumeCachedStory,
|
|
11
|
+
n as getStoryCacheKey
|
|
12
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use server";
|
|
2
|
-
"use strict";var
|
|
2
|
+
"use strict";var c=Object.create;var a=Object.defineProperty;var n=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var l=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty;var h=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of d(t))!s.call(e,i)&&i!==r&&a(e,i,{get:()=>t[i],enumerable:!(o=n(t,i))||o.enumerable});return e};var p=(e,t,r)=>(r=e!=null?c(l(e)):{},h(t||!e||!e.__esModule?a(r,"default",{value:e,enumerable:!0}):r,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("../core/story-cache.js");async function y({story:e,pathToRevalidate:t}){var o;if(!e||!t)return console.error("liveEditUpdateAction: story or pathToRevalidate is not provided");const r=v.getStoryCacheKey(e);if(r&&((o=globalThis.storyCache)==null||o.set(r,e)),process.env.NEXT_RUNTIME)try{const{revalidatePath:i}=await import("next/cache");i(t)}catch(i){console.error("liveEditUpdateAction: error while revalidating path",i)}}exports.liveEditUpdateAction=y;
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
"use server";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { getStoryCacheKey as a } from "../core/story-cache.mjs";
|
|
3
|
+
async function n({
|
|
4
|
+
story: e,
|
|
5
|
+
pathToRevalidate: r
|
|
6
|
+
}) {
|
|
7
|
+
var i;
|
|
8
|
+
if (!e || !r)
|
|
5
9
|
return console.error("liveEditUpdateAction: story or pathToRevalidate is not provided");
|
|
6
|
-
|
|
10
|
+
const o = a(e);
|
|
11
|
+
if (o && ((i = globalThis.storyCache) == null || i.set(o, e)), process.env.NEXT_RUNTIME)
|
|
7
12
|
try {
|
|
8
13
|
const { revalidatePath: t } = await import("next/cache");
|
|
9
|
-
t(
|
|
14
|
+
t(r);
|
|
10
15
|
} catch (t) {
|
|
11
16
|
console.error("liveEditUpdateAction: error while revalidating path", t);
|
|
12
17
|
}
|
|
13
18
|
}
|
|
14
19
|
export {
|
|
15
|
-
|
|
20
|
+
n as liveEditUpdateAction
|
|
16
21
|
};
|
package/dist/rsc/live-editing.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";const
|
|
2
|
+
"use strict";const n=require("@storyblok/js"),s=require("react"),d=require("../core/story-cache.js"),c=require("../utils.js"),y=({story:e=null,bridgeOptions:a={}})=>{if(!c.isVisualEditor())return null;const r=typeof(e==null?void 0:e.id)=="number"?e.id:null;return s.useEffect(()=>{r!==null&&(async()=>{c.isBridgeLoaded()||await n.loadStoryblokBridge();const u=async t=>{var o;if(t)try{const{liveEditUpdateAction:i}=await Promise.resolve().then(()=>require("./live-edit-update-action.js"));s.startTransition(()=>{i({story:t,pathToRevalidate:window.location.pathname})})}catch(i){console.warn("Server action not available, caching story locally:",i);const l=d.getStoryCacheKey(t);l&&((o=globalThis.storyCache)==null||o.set(l,t))}};n.registerStoryblokBridge(r,t=>u(t),a)})()},[r,JSON.stringify(a)]),null};module.exports=y;
|
|
@@ -1,30 +1,36 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { loadStoryblokBridge as
|
|
3
|
-
import { useEffect as
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import { loadStoryblokBridge as s, registerStoryblokBridge as c } from "@storyblok/js";
|
|
3
|
+
import { useEffect as d, startTransition as u } from "react";
|
|
4
|
+
import { getStoryCacheKey as f } from "../core/story-cache.mjs";
|
|
5
|
+
import { isVisualEditor as y, isBridgeLoaded as p } from "../utils.mjs";
|
|
6
|
+
const g = ({ story: r = null, bridgeOptions: a = {} }) => {
|
|
7
|
+
if (!y())
|
|
7
8
|
return null;
|
|
8
|
-
const
|
|
9
|
-
return
|
|
10
|
-
(async () => {
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
var
|
|
14
|
-
if (
|
|
9
|
+
const i = typeof (r == null ? void 0 : r.id) == "number" ? r.id : null;
|
|
10
|
+
return d(() => {
|
|
11
|
+
i !== null && (async () => {
|
|
12
|
+
p() || await s();
|
|
13
|
+
const n = async (t) => {
|
|
14
|
+
var e;
|
|
15
|
+
if (t)
|
|
15
16
|
try {
|
|
16
|
-
const { liveEditUpdateAction:
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
const { liveEditUpdateAction: o } = await import("./live-edit-update-action.mjs");
|
|
18
|
+
u(() => {
|
|
19
|
+
o({
|
|
20
|
+
story: t,
|
|
21
|
+
pathToRevalidate: window.location.pathname
|
|
22
|
+
});
|
|
19
23
|
});
|
|
20
|
-
} catch (
|
|
21
|
-
console.warn("Server action not available, caching story locally:",
|
|
24
|
+
} catch (o) {
|
|
25
|
+
console.warn("Server action not available, caching story locally:", o);
|
|
26
|
+
const l = f(t);
|
|
27
|
+
l && ((e = globalThis.storyCache) == null || e.set(l, t));
|
|
22
28
|
}
|
|
23
29
|
};
|
|
24
|
-
|
|
30
|
+
c(i, (t) => n(t), a);
|
|
25
31
|
})();
|
|
26
|
-
}, [
|
|
32
|
+
}, [i, JSON.stringify(a)]), null;
|
|
27
33
|
};
|
|
28
34
|
export {
|
|
29
|
-
|
|
35
|
+
g as default
|
|
30
36
|
};
|
package/dist/rsc/story.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const r=require("react/jsx-runtime"),i=require("react"),s=require("../server/server-component.js"),l=require("./live-editing.js"),
|
|
1
|
+
"use strict";const r=require("react/jsx-runtime"),i=require("react"),s=require("../core/story-cache.js"),u=require("../server/server-component.js"),l=require("./live-editing.js"),a=i.forwardRef(({story:e,bridgeOptions:t,...n},o)=>{if(!e)return console.error("Please provide a 'story' property to the StoryblokServerComponent"),null;if(e=s.consumeCachedStory(e),typeof e.content=="string")try{e.content=JSON.parse(e.content)}catch(c){console.error("An error occurred while trying to parse the story content",c),e.content={}}return r.jsxs(r.Fragment,{children:[r.jsx(u,{ref:o,blok:e.content,...n}),r.jsx(l,{story:e,bridgeOptions:t})]})});module.exports=a;
|
package/dist/rsc/story.mjs
CHANGED
|
@@ -1,28 +1,29 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { jsxs as i, Fragment as m, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as p } from "react";
|
|
3
|
+
import { consumeCachedStory as l } from "../core/story-cache.mjs";
|
|
4
|
+
import f from "../server/server-component.mjs";
|
|
5
|
+
import a from "./live-editing.mjs";
|
|
6
|
+
const b = p(
|
|
7
|
+
({ story: r, bridgeOptions: e, ...t }, n) => {
|
|
8
|
+
if (!r)
|
|
8
9
|
return console.error(
|
|
9
10
|
"Please provide a 'story' property to the StoryblokServerComponent"
|
|
10
11
|
), null;
|
|
11
|
-
if (
|
|
12
|
+
if (r = l(r), typeof r.content == "string")
|
|
12
13
|
try {
|
|
13
|
-
|
|
14
|
-
} catch (
|
|
14
|
+
r.content = JSON.parse(r.content);
|
|
15
|
+
} catch (c) {
|
|
15
16
|
console.error(
|
|
16
17
|
"An error occurred while trying to parse the story content",
|
|
17
|
-
|
|
18
|
-
),
|
|
18
|
+
c
|
|
19
|
+
), r.content = {};
|
|
19
20
|
}
|
|
20
|
-
return /* @__PURE__ */
|
|
21
|
-
/* @__PURE__ */ o(
|
|
22
|
-
/* @__PURE__ */ o(
|
|
21
|
+
return /* @__PURE__ */ i(m, { children: [
|
|
22
|
+
/* @__PURE__ */ o(f, { ref: n, blok: r.content, ...t }),
|
|
23
|
+
/* @__PURE__ */ o(a, { story: r, bridgeOptions: e })
|
|
23
24
|
] });
|
|
24
25
|
}
|
|
25
26
|
);
|
|
26
27
|
export {
|
|
27
|
-
|
|
28
|
+
b as default
|
|
28
29
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const n=require("react/jsx-runtime"),c=require("react"),i=require("./server-component.js"),
|
|
1
|
+
"use strict";const n=require("react/jsx-runtime"),c=require("react"),s=require("../core/story-cache.js"),i=require("./server-component.js"),u=c.forwardRef(({story:e,...r},t)=>{if(!e)return console.error("Please provide a 'story' property to the StoryblokServerStory"),null;if(e=s.consumeCachedStory(e),typeof e.content=="string")try{e.content=JSON.parse(e.content)}catch(o){console.error("An error occurred while trying to parse the story content",o),e.content={}}return n.jsx(i,{ref:t,blok:e.content,...r})});module.exports=u;
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import { forwardRef as c } from "react";
|
|
3
|
+
import { consumeCachedStory as p } from "../core/story-cache.mjs";
|
|
4
|
+
import l from "./server-component.mjs";
|
|
5
|
+
const a = c(
|
|
6
|
+
({ story: r, ...o }, e) => {
|
|
7
|
+
if (!r)
|
|
7
8
|
return console.error(
|
|
8
9
|
"Please provide a 'story' property to the StoryblokServerStory"
|
|
9
10
|
), null;
|
|
10
|
-
if (
|
|
11
|
+
if (r = p(r), typeof r.content == "string")
|
|
11
12
|
try {
|
|
12
|
-
|
|
13
|
+
r.content = JSON.parse(r.content);
|
|
13
14
|
} catch (t) {
|
|
14
15
|
console.error(
|
|
15
16
|
"An error occurred while trying to parse the story content",
|
|
16
17
|
t
|
|
17
|
-
),
|
|
18
|
+
), r.content = {};
|
|
18
19
|
}
|
|
19
|
-
return /* @__PURE__ */ n(
|
|
20
|
+
return /* @__PURE__ */ n(l, { ref: e, blok: r.content, ...o });
|
|
20
21
|
}
|
|
21
22
|
);
|
|
22
23
|
export {
|
|
23
|
-
|
|
24
|
+
a as default
|
|
24
25
|
};
|