@storyblok/js 3.3.0 → 3.3.1

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.
@@ -4,7 +4,7 @@
4
4
  * description: SDK to integrate Storyblok into your project using JavaScript.
5
5
  * author: undefined
6
6
  */
7
- (function($,I){typeof exports=="object"&&typeof module<"u"?I(exports):typeof define=="function"&&define.amd?define(["exports"],I):($=typeof globalThis<"u"?globalThis:$||self,I($.storyblok={}))})(this,function($){"use strict";let I=!1;const D=[],q=i=>new Promise((e,t)=>{if(typeof window>"u"||(window.storyblokRegisterEvent=r=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}I?r():D.push(r)},document.getElementById("storyblok-javascript-bridge")))return;const s=document.createElement("script");s.async=!0,s.src=i,s.id="storyblok-javascript-bridge",s.onerror=r=>t(r),s.onload=r=>{D.forEach(n=>n()),I=!0,e(r)},document.getElementsByTagName("head")[0].appendChild(s)});var X=Object.defineProperty,Q=(i,e,t)=>e in i?X(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,g=(i,e,t)=>Q(i,typeof e!="symbol"?e+"":e,t);class Z extends Error{constructor(e){super(e),this.name="AbortError"}}function ee(i,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 s=[];let r=[],n=0,o=!1;const l=async()=>{n++;const h=s.shift();if(h)try{const p=await i(...h.args);h.resolve(p)}catch(p){h.reject(p)}const u=setTimeout(()=>{n--,s.length>0&&l(),r=r.filter(p=>p!==u)},t);r.includes(u)||r.push(u)},a=(...h)=>o?Promise.reject(new Error("Throttled function is already aborted and not accepting new promises")):new Promise((u,p)=>{s.push({resolve:u,reject:p,args:h}),n<e&&l()});return a.abort=()=>{o=!0,r.forEach(clearTimeout),r=[],s.forEach(h=>h.reject(()=>new Z("Throttle function aborted"))),s.length=0},a}class x{constructor(){g(this,"isCDNUrl",(e="")=>e.includes("/cdn/")),g(this,"getOptionsPage",(e,t=25,s=1)=>({...e,per_page:t,page:s})),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 s=Math.abs(t-e)||0,r=e<t?1:-1;return this.arrayFrom(s,(n,o)=>o*r+e)}),g(this,"asyncMap",async(e,t)=>Promise.all(e.map(t))),g(this,"flatMap",(e=[],t)=>e.map(t).reduce((s,r)=>[...s,...r],[])),g(this,"escapeHTML",function(e){const t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},s=/[&<>"']/g,r=new RegExp(s.source);return e&&r.test(e)?e.replace(s,n=>t[n]):e})}stringify(e,t,s){const r=[];for(const n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;const o=e[n],l=s?"":encodeURIComponent(n);let a;typeof o=="object"?a=this.stringify(o,t?t+encodeURIComponent(`[${l}]`):l,Array.isArray(o)):a=`${t?t+encodeURIComponent(`[${l}]`):l}=${encodeURIComponent(o)}`,r.push(a)}return r.join("&")}getRegionURL(e){const t="api.storyblok.com",s="api-us.storyblok.com",r="app.storyblokchina.cn",n="api-ap.storyblok.com",o="api-ca.storyblok.com";switch(e){case"us":return s;case"cn":return r;case"ap":return n;case"ca":return o;default:return t}}}const te=function(i,e){const t={};for(const s in i){const r=i[s];e.includes(s)&&r!==null&&(t[s]=r)}return t},se=i=>i==="email",re=()=>({singleTag:"hr"}),ie=()=>({tag:"blockquote"}),ne=()=>({tag:"ul"}),oe=i=>({tag:["pre",{tag:"code",attrs:i.attrs}]}),ae=()=>({singleTag:"br"}),le=i=>({tag:`h${i.attrs.level}`}),ce=i=>({singleTag:[{tag:"img",attrs:te(i.attrs,["src","alt","title"])}]}),he=()=>({tag:"li"}),ue=()=>({tag:"ol"}),de=()=>({tag:"p"}),pe=i=>({tag:[{tag:"span",attrs:{"data-type":"emoji","data-name":i.attrs.name,emoji:i.attrs.emoji}}]}),ge=()=>({tag:"b"}),fe=()=>({tag:"s"}),me=()=>({tag:"u"}),ye=()=>({tag:"strong"}),be=()=>({tag:"code"}),ke=()=>({tag:"i"}),$e=i=>{if(!i.attrs)return{tag:""};const e=new x().escapeHTML,t={...i.attrs},{linktype:s="url"}=i.attrs;if(delete t.linktype,t.href&&(t.href=e(i.attrs.href||"")),se(s)&&(t.href=`mailto:${t.href}`),t.anchor&&(t.href=`${t.href}#${t.anchor}`,delete t.anchor),t.custom){for(const r in t.custom)t[r]=t.custom[r];delete t.custom}return{tag:[{tag:"a",attrs:t}]}},ve=i=>({tag:[{tag:"span",attrs:i.attrs}]}),Te=()=>({tag:"sub"}),we=()=>({tag:"sup"}),Re=i=>({tag:[{tag:"span",attrs:i.attrs}]}),Ee=i=>{var e;return(e=i.attrs)!=null&&e.color?{tag:[{tag:"span",attrs:{style:`background-color:${i.attrs.color};`}}]}:{tag:""}},_e=i=>{var e;return(e=i.attrs)!=null&&e.color?{tag:[{tag:"span",attrs:{style:`color:${i.attrs.color}`}}]}:{tag:""}},F={nodes:{horizontal_rule:re,blockquote:ie,bullet_list:ne,code_block:oe,hard_break:ae,heading:le,image:ce,list_item:he,ordered_list:ue,paragraph:de,emoji:pe},marks:{bold:ge,strike:fe,underline:me,strong:ye,code:be,italic:ke,link:$e,styled:ve,subscript:Te,superscript:we,anchor:Re,highlight:Ee,textStyle:_e}},Se=function(i){const e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},t=/[&<>"']/g,s=new RegExp(t.source);return i&&s.test(i)?i.replace(t,r=>e[r]):i};let G=!1;class A{constructor(e){g(this,"marks"),g(this,"nodes"),e||(e=F),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},s=!0){if(!G&&s&&(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/"),G=!0),e&&e.content&&Array.isArray(e.content)){let r="";return e.content.forEach(n=>{r+=this.renderNode(n)}),t.optimizeImages?this.optimizeImages(r,t.optimizeImages):r}return console.warn(`The render method must receive an Object with a "content" field.
7
+ (function($,I){typeof exports=="object"&&typeof module<"u"?I(exports):typeof define=="function"&&define.amd?define(["exports"],I):($=typeof globalThis<"u"?globalThis:$||self,I($.storyblok={}))})(this,function($){"use strict";let I=!1;const D=[],q=i=>new Promise((e,t)=>{if(typeof window>"u"||(window.storyblokRegisterEvent=r=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}I?r():D.push(r)},document.getElementById("storyblok-javascript-bridge")))return;const s=document.createElement("script");s.async=!0,s.src=i,s.id="storyblok-javascript-bridge",s.onerror=r=>t(r),s.onload=r=>{D.forEach(n=>n()),I=!0,e(r)},document.getElementsByTagName("head")[0].appendChild(s)});var X=Object.defineProperty,Q=(i,e,t)=>e in i?X(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,g=(i,e,t)=>Q(i,typeof e!="symbol"?e+"":e,t);class Z extends Error{constructor(e){super(e),this.name="AbortError"}}function ee(i,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 s=[];let r=[],n=0,o=!1;const l=async()=>{n++;const h=s.shift();if(h)try{const p=await i(...h.args);h.resolve(p)}catch(p){h.reject(p)}const u=setTimeout(()=>{n--,s.length>0&&l(),r=r.filter(p=>p!==u)},t);r.includes(u)||r.push(u)},a=(...h)=>o?Promise.reject(new Error("Throttled function is already aborted and not accepting new promises")):new Promise((u,p)=>{s.push({resolve:u,reject:p,args:h}),n<e&&l()});return a.abort=()=>{o=!0,r.forEach(clearTimeout),r=[],s.forEach(h=>h.reject(()=>new Z("Throttle function aborted"))),s.length=0},a}class x{constructor(){g(this,"isCDNUrl",(e="")=>e.includes("/cdn/")),g(this,"getOptionsPage",(e,t=25,s=1)=>({...e,per_page:t,page:s})),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 s=Math.abs(t-e)||0,r=e<t?1:-1;return this.arrayFrom(s,(n,o)=>o*r+e)}),g(this,"asyncMap",async(e,t)=>Promise.all(e.map(t))),g(this,"flatMap",(e=[],t)=>e.map(t).reduce((s,r)=>[...s,...r],[])),g(this,"escapeHTML",function(e){const t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},s=/[&<>"']/g,r=new RegExp(s.source);return e&&r.test(e)?e.replace(s,n=>t[n]):e})}stringify(e,t,s){const r=[];for(const n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;const o=e[n];if(o==null)continue;const l=s?"":encodeURIComponent(n);let a;typeof o=="object"?a=this.stringify(o,t?t+encodeURIComponent(`[${l}]`):l,Array.isArray(o)):a=`${t?t+encodeURIComponent(`[${l}]`):l}=${encodeURIComponent(o)}`,r.push(a)}return r.join("&")}getRegionURL(e){const t="api.storyblok.com",s="api-us.storyblok.com",r="app.storyblokchina.cn",n="api-ap.storyblok.com",o="api-ca.storyblok.com";switch(e){case"us":return s;case"cn":return r;case"ap":return n;case"ca":return o;default:return t}}}const te=function(i,e){const t={};for(const s in i){const r=i[s];e.includes(s)&&r!==null&&(t[s]=r)}return t},se=i=>i==="email",re=()=>({singleTag:"hr"}),ie=()=>({tag:"blockquote"}),ne=()=>({tag:"ul"}),oe=i=>({tag:["pre",{tag:"code",attrs:i.attrs}]}),ae=()=>({singleTag:"br"}),le=i=>({tag:`h${i.attrs.level}`}),ce=i=>({singleTag:[{tag:"img",attrs:te(i.attrs,["src","alt","title"])}]}),he=()=>({tag:"li"}),ue=()=>({tag:"ol"}),de=()=>({tag:"p"}),pe=i=>({tag:[{tag:"span",attrs:{"data-type":"emoji","data-name":i.attrs.name,emoji:i.attrs.emoji}}]}),ge=()=>({tag:"b"}),fe=()=>({tag:"s"}),me=()=>({tag:"u"}),ye=()=>({tag:"strong"}),be=()=>({tag:"code"}),ke=()=>({tag:"i"}),$e=i=>{if(!i.attrs)return{tag:""};const e=new x().escapeHTML,t={...i.attrs},{linktype:s="url"}=i.attrs;if(delete t.linktype,t.href&&(t.href=e(i.attrs.href||"")),se(s)&&(t.href=`mailto:${t.href}`),t.anchor&&(t.href=`${t.href}#${t.anchor}`,delete t.anchor),t.custom){for(const r in t.custom)t[r]=t.custom[r];delete t.custom}return{tag:[{tag:"a",attrs:t}]}},ve=i=>({tag:[{tag:"span",attrs:i.attrs}]}),Te=()=>({tag:"sub"}),we=()=>({tag:"sup"}),Re=i=>({tag:[{tag:"span",attrs:i.attrs}]}),Ee=i=>{var e;return(e=i.attrs)!=null&&e.color?{tag:[{tag:"span",attrs:{style:`background-color:${i.attrs.color};`}}]}:{tag:""}},_e=i=>{var e;return(e=i.attrs)!=null&&e.color?{tag:[{tag:"span",attrs:{style:`color:${i.attrs.color}`}}]}:{tag:""}},F={nodes:{horizontal_rule:re,blockquote:ie,bullet_list:ne,code_block:oe,hard_break:ae,heading:le,image:ce,list_item:he,ordered_list:ue,paragraph:de,emoji:pe},marks:{bold:ge,strike:fe,underline:me,strong:ye,code:be,italic:ke,link:$e,styled:ve,subscript:Te,superscript:we,anchor:Re,highlight:Ee,textStyle:_e}},Se=function(i){const e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},t=/[&<>"']/g,s=new RegExp(t.source);return i&&s.test(i)?i.replace(t,r=>e[r]):i};let G=!1;class A{constructor(e){g(this,"marks"),g(this,"nodes"),e||(e=F),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},s=!0){if(!G&&s&&(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/"),G=!0),e&&e.content&&Array.isArray(e.content)){let r="";return e.content.forEach(n=>{r+=this.renderNode(n)}),t.optimizeImages?this.optimizeImages(r,t.optimizeImages):r}return console.warn(`The render method must receive an Object with a "content" field.
8
8
  The "content" field must be an array of nodes as the type ISbRichtext.
9
9
  ISbRichtext:
10
10
  content?: ISbRichtext[]
@@ -95,7 +95,10 @@ class L {
95
95
  for (const o in e) {
96
96
  if (!Object.prototype.hasOwnProperty.call(e, o))
97
97
  continue;
98
- const n = e[o], l = s ? "" : encodeURIComponent(o);
98
+ const n = e[o];
99
+ if (n == null)
100
+ continue;
101
+ const l = s ? "" : encodeURIComponent(o);
99
102
  let a;
100
103
  typeof n == "object" ? a = this.stringify(
101
104
  n,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@storyblok/js",
3
3
  "type": "module",
4
- "version": "3.3.0",
4
+ "version": "3.3.1",
5
5
  "private": false,
6
6
  "packageManager": "pnpm@10.2.0",
7
7
  "description": "SDK to integrate Storyblok into your project using JavaScript.",
@@ -39,11 +39,12 @@
39
39
  "lint": "eslint .",
40
40
  "lint:fix": "eslint . --fix",
41
41
  "cy:run": "cypress run",
42
- "cy:open": "cypress open"
42
+ "cy:open": "cypress open",
43
+ "check-licenses": "node scripts/license-checker.mjs"
43
44
  },
44
45
  "dependencies": {
45
46
  "@storyblok/richtext": "3.1.0",
46
- "storyblok-js-client": "6.10.10"
47
+ "storyblok-js-client": "6.10.11"
47
48
  },
48
49
  "devDependencies": {
49
50
  "@commitlint/cli": "^19.7.1",
@@ -51,12 +52,13 @@
51
52
  "@storyblok/eslint-config": "^0.3.0",
52
53
  "@tsconfig/recommended": "^1.0.8",
53
54
  "@types/node": "^22.13.1",
54
- "@vitest/ui": "3.0.8",
55
+ "@vitest/ui": "3.0.9",
55
56
  "cypress": "^13.17.0",
56
57
  "eslint": "^9.19.0",
57
58
  "eslint-plugin-cypress": "^4.1.0",
58
59
  "jsdom": "^26.0.0",
59
60
  "kolorist": "^1.8.0",
61
+ "license-checker": "^25.0.1",
60
62
  "pathe": "^2.0.2",
61
63
  "simple-git-hooks": "^2.11.1",
62
64
  "start-server-and-test": "^2.0.10",