@storyblok/js 6.0.1 → 6.2.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/editable.d.ts +3 -2
- package/dist/storyblok-js.js +1 -1
- package/dist/storyblok-js.mjs +17 -17
- package/package.json +4 -4
package/dist/editable.d.ts
CHANGED
package/dist/storyblok-js.js
CHANGED
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* description: SDK to integrate Storyblok into your project using JavaScript.
|
|
5
5
|
* author: undefined
|
|
6
6
|
*/
|
|
7
|
-
(function(e,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("storyblok-js-client"),require("@storyblok/richtext")):typeof define=="function"&&define.amd?define(["exports","storyblok-js-client","@storyblok/richtext"],l):(e=typeof globalThis<"u"?globalThis:e||self,l(e.storyblok={},e.StoryblokClient,e.StoryblokRichtext))})(this,(function(e,l,u){"use strict";let f=!1;const k=[],p=t=>new Promise((o,s)=>{if(typeof window>"u"){s(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));return}if(window.storyblokRegisterEvent=r=>{if(!window.location.search.includes("_storyblok")){console.warn("You are not in Draft Mode or in the Visual Editor.");return}f?r():k.push(r)},document.getElementById("storyblok-javascript-bridge")){o(void 0);return}const i=document.createElement("script");i.async=!0,i.src=t,i.id="storyblok-javascript-bridge",i.onerror=r=>s(r),i.onload=r=>{k.forEach(d=>d()),f=!0,o(r)},document.getElementsByTagName("head")[0].appendChild(i)}),h=(t={})=>{const{apiOptions:o}=t;if(!o||!o.accessToken){console.error("You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication");return}return{storyblokApi:new l(o)}},S=t=>{if(typeof t!="object"||typeof t._editable
|
|
7
|
+
(function(e,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("storyblok-js-client"),require("@storyblok/richtext")):typeof define=="function"&&define.amd?define(["exports","storyblok-js-client","@storyblok/richtext"],l):(e=typeof globalThis<"u"?globalThis:e||self,l(e.storyblok={},e.StoryblokClient,e.StoryblokRichtext))})(this,(function(e,l,u){"use strict";let f=!1;const k=[],p=t=>new Promise((o,s)=>{if(typeof window>"u"){s(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));return}if(window.storyblokRegisterEvent=r=>{if(!window.location.search.includes("_storyblok")){console.warn("You are not in Draft Mode or in the Visual Editor.");return}f?r():k.push(r)},document.getElementById("storyblok-javascript-bridge")){o(void 0);return}const i=document.createElement("script");i.async=!0,i.src=t,i.id="storyblok-javascript-bridge",i.onerror=r=>s(r),i.onload=r=>{k.forEach(d=>d()),f=!0,o(r)},document.getElementsByTagName("head")[0].appendChild(i)}),h=(t={})=>{const{apiOptions:o}=t;if(!o||!o.accessToken){console.error("You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication");return}return{storyblokApi:new l(o)}},S=t=>{if(typeof t!="object"||typeof t._editable!="string")return{};try{const o=JSON.parse(t._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return o?{"data-blok-c":JSON.stringify(o),"data-blok-uid":`${o.id}-${o.uid}`}:{}}catch{return{}}};let b="https://app.storyblok.com/f/storyblok-v2-latest.js";const w=(t,o,s={})=>{var c;const r=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",d=new URL((c=window.location)==null?void 0:c.href).searchParams.get("_storyblok"),y=d!==null&&+d===t;if(!(!r||!y)){if(!t){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(s).on(["input","published","change"],n=>{var a;n&&(n.action==="input"&&((a=n.story)==null?void 0:a.id)===t?o(n.story):(n.action==="change"||n.action==="published")&&n.storyId===t&&window.location.reload())})})}},m=(t={})=>{var a,g;const{bridge:o,accessToken:s,use:i=[],apiOptions:r={},bridgeUrl:d}=t;r.accessToken=r.accessToken||s;const y={bridge:o,apiOptions:r};let c={};i.forEach(T=>{c={...c,...T(y)}}),d&&(b=d);const n=!(typeof window>"u")&&((g=(a=window.location)==null?void 0:a.search)==null?void 0:g.includes("_storyblok_tk"));return o!==!1&&n&&p(b),c},B=()=>p(b);e.StoryblokClient=l,Object.defineProperty(e,"buildStoryblokImage",{enumerable:!0,get:()=>u.buildStoryblokImage}),Object.defineProperty(e,"renderRichText",{enumerable:!0,get:()=>u.renderRichText}),Object.defineProperty(e,"splitTableRows",{enumerable:!0,get:()=>u.splitTableRows}),e.apiPlugin=h,e.loadStoryblokBridge=B,e.registerStoryblokBridge=w,e.storyblokEditable=S,e.storyblokInit=m,e.useStoryblokBridge=w,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));
|
package/dist/storyblok-js.mjs
CHANGED
|
@@ -8,9 +8,9 @@ import k from "storyblok-js-client";
|
|
|
8
8
|
import { default as R } from "storyblok-js-client";
|
|
9
9
|
import { buildStoryblokImage as _, renderRichText as P, splitTableRows as x } from "@storyblok/richtext";
|
|
10
10
|
let y = !1;
|
|
11
|
-
const p = [], b = (e) => new Promise((o,
|
|
11
|
+
const p = [], b = (e) => new Promise((o, n) => {
|
|
12
12
|
if (typeof window > "u") {
|
|
13
|
-
|
|
13
|
+
n(new Error("Cannot load Storyblok bridge: window is undefined (server-side environment)"));
|
|
14
14
|
return;
|
|
15
15
|
}
|
|
16
16
|
if (window.storyblokRegisterEvent = (t) => {
|
|
@@ -24,7 +24,7 @@ const p = [], b = (e) => new Promise((o, i) => {
|
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
26
|
const r = document.createElement("script");
|
|
27
|
-
r.async = !0, r.src = e, r.id = "storyblok-javascript-bridge", r.onerror = (t) =>
|
|
27
|
+
r.async = !0, r.src = e, r.id = "storyblok-javascript-bridge", r.onerror = (t) => n(t), r.onload = (t) => {
|
|
28
28
|
p.forEach((s) => s()), y = !0, o(t);
|
|
29
29
|
}, document.getElementsByTagName("head")[0].appendChild(r);
|
|
30
30
|
}), h = (e = {}) => {
|
|
@@ -37,7 +37,7 @@ const p = [], b = (e) => new Promise((o, i) => {
|
|
|
37
37
|
}
|
|
38
38
|
return { storyblokApi: new k(o) };
|
|
39
39
|
}, m = (e) => {
|
|
40
|
-
if (typeof e != "object" || typeof e._editable
|
|
40
|
+
if (typeof e != "object" || typeof e._editable != "string")
|
|
41
41
|
return {};
|
|
42
42
|
try {
|
|
43
43
|
const o = JSON.parse(
|
|
@@ -52,9 +52,9 @@ const p = [], b = (e) => new Promise((o, i) => {
|
|
|
52
52
|
}
|
|
53
53
|
};
|
|
54
54
|
let c = "https://app.storyblok.com/f/storyblok-v2-latest.js";
|
|
55
|
-
const S = (e, o,
|
|
56
|
-
var
|
|
57
|
-
const t = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", s = new URL((
|
|
55
|
+
const S = (e, o, n = {}) => {
|
|
56
|
+
var a;
|
|
57
|
+
const t = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", s = new URL((a = window.location) == null ? void 0 : a.href).searchParams.get(
|
|
58
58
|
"_storyblok"
|
|
59
59
|
), l = s !== null && +s === e;
|
|
60
60
|
if (!(!t || !l)) {
|
|
@@ -63,29 +63,29 @@ const S = (e, o, i = {}) => {
|
|
|
63
63
|
return;
|
|
64
64
|
}
|
|
65
65
|
window.storyblokRegisterEvent(() => {
|
|
66
|
-
new window.StoryblokBridge(
|
|
67
|
-
var
|
|
68
|
-
|
|
66
|
+
new window.StoryblokBridge(n).on(["input", "published", "change"], (i) => {
|
|
67
|
+
var d;
|
|
68
|
+
i && (i.action === "input" && ((d = i.story) == null ? void 0 : d.id) === e ? o(i.story) : (i.action === "change" || i.action === "published") && i.storyId === e && window.location.reload());
|
|
69
69
|
});
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
72
|
}, E = (e = {}) => {
|
|
73
|
-
var
|
|
73
|
+
var d, u;
|
|
74
74
|
const {
|
|
75
75
|
bridge: o,
|
|
76
|
-
accessToken:
|
|
76
|
+
accessToken: n,
|
|
77
77
|
use: r = [],
|
|
78
78
|
apiOptions: t = {},
|
|
79
79
|
bridgeUrl: s
|
|
80
80
|
} = e;
|
|
81
|
-
t.accessToken = t.accessToken ||
|
|
81
|
+
t.accessToken = t.accessToken || n;
|
|
82
82
|
const l = { bridge: o, apiOptions: t };
|
|
83
|
-
let
|
|
83
|
+
let a = {};
|
|
84
84
|
r.forEach((w) => {
|
|
85
|
-
|
|
85
|
+
a = { ...a, ...w(l) };
|
|
86
86
|
}), s && (c = s);
|
|
87
|
-
const
|
|
88
|
-
return o !== !1 &&
|
|
87
|
+
const i = !(typeof window > "u") && ((u = (d = window.location) == null ? void 0 : d.search) == null ? void 0 : u.includes("_storyblok_tk"));
|
|
88
|
+
return o !== !1 && i && b(c), a;
|
|
89
89
|
}, v = () => b(c);
|
|
90
90
|
export {
|
|
91
91
|
R as StoryblokClient,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storyblok/js",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "6.0
|
|
4
|
+
"version": "6.2.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "SDK to integrate Storyblok into your project using JavaScript.",
|
|
7
7
|
"license": "MIT",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"dist"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@storyblok/richtext": "5.0
|
|
33
|
-
"storyblok-js-client": "7.
|
|
32
|
+
"@storyblok/richtext": "5.2.0",
|
|
33
|
+
"storyblok-js-client": "7.7.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@tsconfig/recommended": "^1.0.8",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"vite-plugin-dts": "^4.5.3",
|
|
50
50
|
"vite-plugin-qrcode": "^0.2.4",
|
|
51
51
|
"vitest": "^3.1.3",
|
|
52
|
-
"@storyblok/eslint-config": "0.
|
|
52
|
+
"@storyblok/eslint-config": "0.6.0"
|
|
53
53
|
},
|
|
54
54
|
"release": {
|
|
55
55
|
"branches": [
|