@storyblok/react 4.5.2 → 4.5.3
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/storyblok-js.js +1 -1
- package/dist/storyblok-js.mjs +4 -1
- package/package.json +2 -2
package/dist/storyblok-js.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let B=!1;const z=[],G=n=>new Promise((e,t)=>{if(typeof window>"u"||(window.storyblokRegisterEvent=s=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}B?s():z.push(s)},document.getElementById("storyblok-javascript-bridge")))return;const r=document.createElement("script");r.async=!0,r.src=n,r.id="storyblok-javascript-bridge",r.onerror=s=>t(s),r.onload=s=>{z.forEach(o=>o()),B=!0,e(s)},document.getElementsByTagName("head")[0].appendChild(r)});var oe=Object.defineProperty,ie=(n,e,t)=>e in n?oe(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,g=(n,e,t)=>ie(n,typeof e!="symbol"?e+"":e,t);class ae extends Error{constructor(e){super(e),this.name="AbortError"}}function le(n,e,t){if(!Number.isFinite(e))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(t))throw new TypeError("Expected `interval` to be a finite number");const r=[];let s=[],o=0,i=!1;const l=async()=>{o++;const h=r.shift();if(h)try{const p=await n(...h.args);h.resolve(p)}catch(p){h.reject(p)}const d=setTimeout(()=>{o--,r.length>0&&l(),s=s.filter(p=>p!==d)},t);s.includes(d)||s.push(d)},a=(...h)=>i?Promise.reject(new Error("Throttled function is already aborted and not accepting new promises")):new Promise((d,p)=>{r.push({resolve:d,reject:p,args:h}),o<e&&l()});return a.abort=()=>{i=!0,s.forEach(clearTimeout),s=[],r.forEach(h=>h.reject(()=>new ae("Throttle function aborted"))),r.length=0},a}class C{constructor(){g(this,"isCDNUrl",(e="")=>e.includes("/cdn/")),g(this,"getOptionsPage",(e,t=25,r=1)=>({...e,per_page:t,page:r})),g(this,"delay",e=>new Promise(t=>setTimeout(t,e))),g(this,"arrayFrom",(e=0,t)=>Array.from({length:e},t)),g(this,"range",(e=0,t=e)=>{const r=Math.abs(t-e)||0,s=e<t?1:-1;return this.arrayFrom(r,(o,i)=>i*s+e)}),g(this,"asyncMap",async(e,t)=>Promise.all(e.map(t))),g(this,"flatMap",(e=[],t)=>e.map(t).reduce((r,s)=>[...r,...s],[])),g(this,"escapeHTML",function(e){const t={"&":"&","<":"<",">":">",'"':""","'":"'"},r=/[&<>"']/g,s=new RegExp(r.source);return e&&s.test(e)?e.replace(r,o=>t[o]):e})}stringify(e,t,r){const s=[];for(const o in e){if(!Object.prototype.hasOwnProperty.call(e,o))continue;const i=e[o]
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let B=!1;const z=[],G=n=>new Promise((e,t)=>{if(typeof window>"u"||(window.storyblokRegisterEvent=s=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}B?s():z.push(s)},document.getElementById("storyblok-javascript-bridge")))return;const r=document.createElement("script");r.async=!0,r.src=n,r.id="storyblok-javascript-bridge",r.onerror=s=>t(s),r.onload=s=>{z.forEach(o=>o()),B=!0,e(s)},document.getElementsByTagName("head")[0].appendChild(r)});var oe=Object.defineProperty,ie=(n,e,t)=>e in n?oe(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,g=(n,e,t)=>ie(n,typeof e!="symbol"?e+"":e,t);class ae extends Error{constructor(e){super(e),this.name="AbortError"}}function le(n,e,t){if(!Number.isFinite(e))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(t))throw new TypeError("Expected `interval` to be a finite number");const r=[];let s=[],o=0,i=!1;const l=async()=>{o++;const h=r.shift();if(h)try{const p=await n(...h.args);h.resolve(p)}catch(p){h.reject(p)}const d=setTimeout(()=>{o--,r.length>0&&l(),s=s.filter(p=>p!==d)},t);s.includes(d)||s.push(d)},a=(...h)=>i?Promise.reject(new Error("Throttled function is already aborted and not accepting new promises")):new Promise((d,p)=>{r.push({resolve:d,reject:p,args:h}),o<e&&l()});return a.abort=()=>{i=!0,s.forEach(clearTimeout),s=[],r.forEach(h=>h.reject(()=>new ae("Throttle function aborted"))),r.length=0},a}class C{constructor(){g(this,"isCDNUrl",(e="")=>e.includes("/cdn/")),g(this,"getOptionsPage",(e,t=25,r=1)=>({...e,per_page:t,page:r})),g(this,"delay",e=>new Promise(t=>setTimeout(t,e))),g(this,"arrayFrom",(e=0,t)=>Array.from({length:e},t)),g(this,"range",(e=0,t=e)=>{const r=Math.abs(t-e)||0,s=e<t?1:-1;return this.arrayFrom(r,(o,i)=>i*s+e)}),g(this,"asyncMap",async(e,t)=>Promise.all(e.map(t))),g(this,"flatMap",(e=[],t)=>e.map(t).reduce((r,s)=>[...r,...s],[])),g(this,"escapeHTML",function(e){const t={"&":"&","<":"<",">":">",'"':""","'":"'"},r=/[&<>"']/g,s=new RegExp(r.source);return e&&s.test(e)?e.replace(r,o=>t[o]):e})}stringify(e,t,r){const s=[];for(const o in e){if(!Object.prototype.hasOwnProperty.call(e,o))continue;const i=e[o];if(i==null)continue;const l=r?"":encodeURIComponent(o);let a;typeof i=="object"?a=this.stringify(i,t?t+encodeURIComponent(`[${l}]`):l,Array.isArray(i)):a=`${t?t+encodeURIComponent(`[${l}]`):l}=${encodeURIComponent(i)}`,s.push(a)}return s.join("&")}getRegionURL(e){const t="api.storyblok.com",r="api-us.storyblok.com",s="app.storyblokchina.cn",o="api-ap.storyblok.com",i="api-ca.storyblok.com";switch(e){case"us":return r;case"cn":return s;case"ap":return o;case"ca":return i;default:return t}}}const ce=function(n,e){const t={};for(const r in n){const s=n[r];e.includes(r)&&s!==null&&(t[r]=s)}return t},he=n=>n==="email",ue=()=>({singleTag:"hr"}),de=()=>({tag:"blockquote"}),pe=()=>({tag:"ul"}),ge=n=>({tag:["pre",{tag:"code",attrs:n.attrs}]}),fe=()=>({singleTag:"br"}),me=n=>({tag:`h${n.attrs.level}`}),ye=n=>({singleTag:[{tag:"img",attrs:ce(n.attrs,["src","alt","title"])}]}),be=()=>({tag:"li"}),ke=()=>({tag:"ol"}),$e=()=>({tag:"p"}),ve=n=>({tag:[{tag:"span",attrs:{"data-type":"emoji","data-name":n.attrs.name,emoji:n.attrs.emoji}}]}),we=()=>({tag:"b"}),Te=()=>({tag:"s"}),Re=()=>({tag:"u"}),_e=()=>({tag:"strong"}),Ee=()=>({tag:"code"}),Se=()=>({tag:"i"}),je=n=>{if(!n.attrs)return{tag:""};const e=new C().escapeHTML,t={...n.attrs},{linktype:r="url"}=n.attrs;if(delete t.linktype,t.href&&(t.href=e(n.attrs.href||"")),he(r)&&(t.href=`mailto:${t.href}`),t.anchor&&(t.href=`${t.href}#${t.anchor}`,delete t.anchor),t.custom){for(const s in t.custom)t[s]=t.custom[s];delete t.custom}return{tag:[{tag:"a",attrs:t}]}},Ie=n=>({tag:[{tag:"span",attrs:n.attrs}]}),Ae=()=>({tag:"sub"}),Oe=()=>({tag:"sup"}),xe=n=>({tag:[{tag:"span",attrs:n.attrs}]}),Le=n=>{var e;return(e=n.attrs)!=null&&e.color?{tag:[{tag:"span",attrs:{style:`background-color:${n.attrs.color};`}}]}:{tag:""}},Ce=n=>{var e;return(e=n.attrs)!=null&&e.color?{tag:[{tag:"span",attrs:{style:`color:${n.attrs.color}`}}]}:{tag:""}},V={nodes:{horizontal_rule:ue,blockquote:de,bullet_list:pe,code_block:ge,hard_break:fe,heading:me,image:ye,list_item:be,ordered_list:ke,paragraph:$e,emoji:ve},marks:{bold:we,strike:Te,underline:Re,strong:_e,code:Ee,italic:Se,link:je,styled:Ie,subscript:Ae,superscript:Oe,anchor:xe,highlight:Le,textStyle:Ce}},Pe=function(n){const e={"&":"&","<":"<",">":">",'"':""","'":"'"},t=/[&<>"']/g,r=new RegExp(t.source);return n&&r.test(n)?n.replace(t,s=>e[s]):n};let D=!1;class A{constructor(e){g(this,"marks"),g(this,"nodes"),e||(e=V),this.marks=e.marks||[],this.nodes=e.nodes||[]}addNode(e,t){this.nodes[e]=t}addMark(e,t){this.marks[e]=t}render(e,t={optimizeImages:!1},r=!0){if(!D&&r&&(console.warn("Warning ⚠️: The RichTextResolver class is deprecated and will be removed in the next major release. Please use the `@storyblok/richtext` package instead. https://github.com/storyblok/richtext/"),D=!0),e&&e.content&&Array.isArray(e.content)){let s="";return e.content.forEach(o=>{s+=this.renderNode(o)}),t.optimizeImages?this.optimizeImages(s,t.optimizeImages):s}return console.warn(`The render method must receive an Object with a "content" field.
|
|
2
2
|
The "content" field must be an array of nodes as the type ISbRichtext.
|
|
3
3
|
ISbRichtext:
|
|
4
4
|
content?: ISbRichtext[]
|
package/dist/storyblok-js.mjs
CHANGED
|
@@ -89,7 +89,10 @@ class L {
|
|
|
89
89
|
for (const o in e) {
|
|
90
90
|
if (!Object.prototype.hasOwnProperty.call(e, o))
|
|
91
91
|
continue;
|
|
92
|
-
const a = e[o]
|
|
92
|
+
const a = e[o];
|
|
93
|
+
if (a == null)
|
|
94
|
+
continue;
|
|
95
|
+
const l = r ? "" : encodeURIComponent(o);
|
|
93
96
|
let i;
|
|
94
97
|
typeof a == "object" ? i = this.stringify(
|
|
95
98
|
a,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storyblok/react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.5.
|
|
4
|
+
"version": "4.5.3",
|
|
5
5
|
"private": false,
|
|
6
6
|
"packageManager": "pnpm@10.2.0",
|
|
7
7
|
"description": "SDK to integrate Storyblok into your project using React.",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"react-dom": "^17 || ^18 || ^19"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@storyblok/js": "3.3.
|
|
62
|
+
"@storyblok/js": "3.3.1"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@babel/core": "^7.26.7",
|