@storyblok/svelte 2.4.9 → 2.4.10
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/{StoryblokComponent.svelte → dist/StoryblokComponent.svelte} +3 -2
- package/dist/StoryblokComponent.svelte.d.ts +18 -0
- package/dist/index.js +53 -0
- package/dist/types.js +1 -0
- package/package.json +18 -18
- package/dist/main.d.ts +0 -11
- package/dist/storyblok-svelte.js +0 -10
- package/dist/storyblok-svelte.mjs +0 -1007
- package/dist/vite.config.d.ts +0 -2
- package/index.ts +0 -81
- package/types.ts +0 -35
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { SbBlokData } from "@storyblok/js";
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
[x: string]: any;
|
|
6
|
+
blok: SbBlokData;
|
|
7
|
+
};
|
|
8
|
+
events: {
|
|
9
|
+
[evt: string]: CustomEvent<any>;
|
|
10
|
+
};
|
|
11
|
+
slots: {};
|
|
12
|
+
};
|
|
13
|
+
export type StoryblokComponentProps = typeof __propDef.props;
|
|
14
|
+
export type StoryblokComponentEvents = typeof __propDef.events;
|
|
15
|
+
export type StoryblokComponentSlots = typeof __propDef.slots;
|
|
16
|
+
export default class StoryblokComponent extends SvelteComponentTyped<StoryblokComponentProps, StoryblokComponentEvents, StoryblokComponentSlots> {
|
|
17
|
+
}
|
|
18
|
+
export {};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { storyblokEditable as sbEdit, storyblokInit as sbInit, } from "@storyblok/js";
|
|
2
|
+
export { useStoryblokBridge, apiPlugin, renderRichText, RichTextSchema, } from "@storyblok/js";
|
|
3
|
+
export const storyblokEditable = (node, value) => {
|
|
4
|
+
const updateDom = (value) => {
|
|
5
|
+
const options = sbEdit(value);
|
|
6
|
+
if (options["data-blok-c"]) {
|
|
7
|
+
node.setAttribute("data-blok-c", options["data-blok-c"]);
|
|
8
|
+
node.setAttribute("data-blok-uid", options["data-blok-uid"]);
|
|
9
|
+
node.classList.add("storyblok__outline");
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
updateDom(value); // when is mounted
|
|
13
|
+
return {
|
|
14
|
+
update(newValue) {
|
|
15
|
+
// when value changes
|
|
16
|
+
updateDom(newValue);
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
let storyblokApiInstance = null;
|
|
21
|
+
export const useStoryblokApi = () => {
|
|
22
|
+
if (!storyblokApiInstance) {
|
|
23
|
+
console.log(`You can't use getStoryblokApi if you're not loading apiPlugin.`);
|
|
24
|
+
}
|
|
25
|
+
return storyblokApiInstance;
|
|
26
|
+
};
|
|
27
|
+
export { useStoryblokApi as getStoryblokApi };
|
|
28
|
+
let componentsMap = null;
|
|
29
|
+
export const storyblokInit = (options) => {
|
|
30
|
+
const { storyblokApi } = sbInit(options);
|
|
31
|
+
storyblokApiInstance = storyblokApi;
|
|
32
|
+
componentsMap = options.components || {};
|
|
33
|
+
};
|
|
34
|
+
export const getComponent = (componentName) => {
|
|
35
|
+
let component = null;
|
|
36
|
+
component =
|
|
37
|
+
typeof componentsMap === "function"
|
|
38
|
+
? componentsMap()[componentName]
|
|
39
|
+
: componentsMap[componentName];
|
|
40
|
+
if (!component) {
|
|
41
|
+
console.error(`You didn't load the ${componentName} component. Please load it in storyblokInit. For example:
|
|
42
|
+
storyblokInit({
|
|
43
|
+
accessToken: "<your-token>",
|
|
44
|
+
components: {
|
|
45
|
+
"teaser": Teaser
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
`);
|
|
49
|
+
}
|
|
50
|
+
return component;
|
|
51
|
+
};
|
|
52
|
+
export * from "./types";
|
|
53
|
+
export { default as StoryblokComponent } from "./StoryblokComponent.svelte";
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { apiPlugin } from "@storyblok/js";
|
package/package.json
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storyblok/svelte",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Storyblok SDK to connect Storyblok with Svelte",
|
|
6
|
-
"main": "./dist/
|
|
7
|
-
"module": "./dist/
|
|
8
|
-
"svelte": "index.
|
|
9
|
-
"types": "./dist/
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"svelte": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
10
|
"files": [
|
|
11
11
|
"dist",
|
|
12
|
-
"
|
|
13
|
-
"types.ts",
|
|
14
|
-
"StoryblokComponent.svelte"
|
|
12
|
+
"README.md"
|
|
15
13
|
],
|
|
16
14
|
"exports": {
|
|
17
15
|
".": {
|
|
18
|
-
"import": "./dist/
|
|
19
|
-
"require": "./dist/
|
|
16
|
+
"import": "./dist/index.js",
|
|
17
|
+
"require": "./dist/index.js"
|
|
20
18
|
}
|
|
21
19
|
},
|
|
22
20
|
"scripts": {
|
|
23
|
-
"dev": "
|
|
24
|
-
"build": "
|
|
21
|
+
"dev": "svelte-package -i pkg --watch",
|
|
22
|
+
"build": "svelte-package -i pkg",
|
|
25
23
|
"test": "npm run test:unit && npm run test:e2e",
|
|
26
24
|
"test:unit": "jest __tests__",
|
|
27
|
-
"prepublishOnly": "npm run build && cp ../README.md
|
|
25
|
+
"prepublishOnly": "npm run build && cp ../README.md ."
|
|
28
26
|
},
|
|
29
27
|
"dependencies": {
|
|
30
|
-
"@storyblok/js": "^2.1.
|
|
28
|
+
"@storyblok/js": "^2.1.0",
|
|
29
|
+
"svelte": "^3.0.0"
|
|
31
30
|
},
|
|
32
31
|
"devDependencies": {
|
|
33
|
-
"@babel/core": "^7.21.
|
|
32
|
+
"@babel/core": "^7.21.0",
|
|
33
|
+
"@sveltejs/package": "^2.0.2",
|
|
34
34
|
"@tsconfig/svelte": "^3.0.0",
|
|
35
|
-
"babel-jest": "^
|
|
35
|
+
"babel-jest": "^29",
|
|
36
36
|
"eslint-plugin-jest": "^27.2.0",
|
|
37
37
|
"jest": "^29.5.0",
|
|
38
|
-
"svelte-preprocess": "^5.0.
|
|
39
|
-
"typescript": "^
|
|
38
|
+
"svelte-preprocess": "^5.0.1",
|
|
39
|
+
"typescript": "^5.0.0",
|
|
40
40
|
"vite": "^4.1.4"
|
|
41
41
|
},
|
|
42
42
|
"eslintConfig": {
|
package/dist/main.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { SbBlokData } from './index'
|
|
2
|
-
import { SvelteComponentTyped} from 'svelte'
|
|
3
|
-
|
|
4
|
-
export * from "./index"
|
|
5
|
-
|
|
6
|
-
interface StoryblokComponentProps {
|
|
7
|
-
blok: SbBlokData;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export declare class StoryblokComponent extends SvelteComponentTyped<StoryblokComponentProps> {
|
|
11
|
-
}
|
package/dist/storyblok-svelte.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
(function(d,g){typeof exports=="object"&&typeof module<"u"?g(exports):typeof define=="function"&&define.amd?define(["exports"],g):(d=typeof globalThis<"u"?globalThis:d||self,g(d.storyblokSvelte={}))})(this,function(d){"use strict";let g=!1;const U=[],ne=s=>new Promise((e,t)=>{if(typeof window>"u"||(window.storyblokRegisterEvent=n=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}g?n():U.push(n)},document.getElementById("storyblok-javascript-bridge")))return;const r=document.createElement("script");r.async=!0,r.src=s,r.id="storyblok-javascript-bridge",r.onerror=n=>t(n),r.onload=n=>{U.forEach(o=>o()),g=!0,e(n)},document.getElementsByTagName("head")[0].appendChild(r)});var oe=Object.defineProperty,ie=(s,e,t)=>e in s?oe(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,u=(s,e,t)=>(ie(s,typeof e!="symbol"?e+"":e,t),t);function H(s){return!(s!==s||s===1/0||s===-1/0)}function ae(s,e,t){if(!H(e))throw new TypeError("Expected `limit` to be a finite number");if(!H(t))throw new TypeError("Expected `interval` to be a finite number");const r=[];let n=[],o=0;const i=function(){o++;const c=setTimeout(function(){o--,r.length>0&&i(),n=n.filter(function(h){return h!==c})},t);n.indexOf(c)<0&&n.push(c);const l=r.shift();l.resolve(s.apply(l.self,l.args))},a=function(...c){const l=this;return new Promise(function(h,f){r.push({resolve:h,reject:f,args:c,self:l}),o<e&&i()})};return a.abort=function(){n.forEach(clearTimeout),n=[],r.forEach(function(c){c.reject(function(){Error.call(this,"Throttled function aborted"),this.name="AbortError"})}),r.length=0},a}const ce=function(s,e){const t={};for(const r in s){const n=s[r];e.indexOf(r)>-1&&n!==null&&(t[r]=n)}return t},le=s=>s==="email",ue=()=>({singleTag:"hr"}),he=()=>({tag:"blockquote"}),de=()=>({tag:"ul"}),fe=s=>({tag:["pre",{tag:"code",attrs:s.attrs}]}),pe=()=>({singleTag:"br"}),ge=s=>({tag:`h${s.attrs.level}`}),me=s=>({singleTag:[{tag:"img",attrs:ce(s.attrs,["src","alt","title"])}]}),ye=()=>({tag:"li"}),ke=()=>({tag:"ol"}),_e=()=>({tag:"p"}),be=()=>({tag:"b"}),ve=()=>({tag:"strike"}),we=()=>({tag:"u"}),$e=()=>({tag:"strong"}),Te=()=>({tag:"code"}),Re=()=>({tag:"i"}),Pe=s=>{const e={...s.attrs},{linktype:t="url"}=s.attrs;return le(t)&&(e.href=`mailto:${e.href}`),e.anchor&&(e.href=`${e.href}#${e.anchor}`,delete e.anchor),{tag:[{tag:"a",attrs:e}]}},je=s=>({tag:[{tag:"span",attrs:s.attrs}]}),q={nodes:{horizontal_rule:ue,blockquote:he,bullet_list:de,code_block:fe,hard_break:pe,heading:ge,image:me,list_item:ye,ordered_list:ke,paragraph:_e},marks:{bold:be,strike:ve,underline:we,strong:$e,code:Te,italic:Re,link:Pe,styled:je}},xe=function(s){const e={"&":"&","<":"<",">":">",'"':""","'":"'"},t=/[&<>"']/g,r=RegExp(t.source);return s&&r.test(s)?s.replace(t,n=>e[n]):s};class ${constructor(e){u(this,"marks"),u(this,"nodes"),e||(e=q),this.marks=e.marks||[],this.nodes=e.nodes||[]}addNode(e,t){this.nodes[e]=t}addMark(e,t){this.marks[e]=t}render(e){if(e&&e.content&&Array.isArray(e.content)){let t="";return e.content.forEach(r=>{t+=this.renderNode(r)}),t}return console.warn("The render method must receive an object with a content field, which is an array"),""}renderNode(e){const t=[];e.marks&&e.marks.forEach(n=>{const o=this.getMatchingMark(n);o&&t.push(this.renderOpeningTag(o.tag))});const r=this.getMatchingNode(e);return r&&r.tag&&t.push(this.renderOpeningTag(r.tag)),e.content?e.content.forEach(n=>{t.push(this.renderNode(n))}):e.text?t.push(xe(e.text)):r&&r.singleTag?t.push(this.renderTag(r.singleTag," /")):r&&r.html&&t.push(r.html),r&&r.tag&&t.push(this.renderClosingTag(r.tag)),e.marks&&e.marks.slice(0).reverse().forEach(n=>{const o=this.getMatchingMark(n);o&&t.push(this.renderClosingTag(o.tag))}),t.join("")}renderTag(e,t){return e.constructor===String?`<${e}${t}>`:e.map(r=>{if(r.constructor===String)return`<${r}${t}>`;{let n=`<${r.tag}`;if(r.attrs)for(const o in r.attrs){const i=r.attrs[o];i!==null&&(n+=` ${o}="${i}"`)}return`${n}${t}>`}}).join("")}renderOpeningTag(e){return this.renderTag(e,"")}renderClosingTag(e){return e.constructor===String?`</${e}>`:e.slice(0).reverse().map(t=>t.constructor===String?`</${t}>`:`</${t.tag}>`).join("")}getMatchingNode(e){const t=this.nodes[e.type];if(typeof t=="function")return t(e)}getMatchingMark(e){const t=this.marks[e.type];if(typeof t=="function")return t(e)}}class D{constructor(){u(this,"isCDNUrl",(e="")=>e.indexOf("/cdn/")>-1),u(this,"getOptionsPage",(e,t=25,r=1)=>({...e,per_page:t,page:r})),u(this,"delay",e=>new Promise(t=>setTimeout(t,e))),u(this,"arrayFrom",(e=0,t)=>[...Array(e)].map(t)),u(this,"range",(e=0,t=e)=>{const r=Math.abs(t-e)||0,n=e<t?1:-1;return this.arrayFrom(r,(o,i)=>i*n+e)}),u(this,"asyncMap",async(e,t)=>Promise.all(e.map(t))),u(this,"flatMap",(e=[],t)=>e.map(t).reduce((r,n)=>[...r,...n],[]))}stringify(e,t,r){const n=[];for(const o in e){if(!Object.prototype.hasOwnProperty.call(e,o))continue;const i=e[o],a=r?"":encodeURIComponent(o);let c;typeof i=="object"?c=this.stringify(i,t?t+encodeURIComponent("["+a+"]"):a,Array.isArray(i)):c=(t?t+encodeURIComponent("["+a+"]"):a)+"="+encodeURIComponent(i),n.push(c)}return n.join("&")}}class Ee{constructor(e){u(this,"baseURL"),u(this,"timeout"),u(this,"headers"),u(this,"responseInterceptor"),u(this,"fetch"),u(this,"ejectInterceptor"),u(this,"url"),u(this,"parameters"),this.baseURL=e.baseURL,this.headers=e.headers||[],this.timeout=e!=null&&e.timeout?e.timeout*1e3:0,this.responseInterceptor=e.responseInterceptor,this.fetch=(...t)=>e.fetch?e.fetch(...t):fetch(...t),this.ejectInterceptor=!1,this.url="",this.parameters={}}get(e,t){return this.url=e,this.parameters=t,this._methodHandler("get")}post(e,t){return this.url=e,this.parameters=t,this._methodHandler("post")}put(e,t){return this.url=e,this.parameters=t,this._methodHandler("put")}delete(e,t){return this.url=e,this.parameters=t,this._methodHandler("delete")}async _responseHandler(e){const t=[],r={data:{},headers:{},status:0,statusText:""};e.status!==204&&await e.json().then(n=>{r.data=n});for(const n of e.headers.entries())t[n[0]]=n[1];return r.headers={...t},r.status=e.status,r.statusText=e.statusText,r}async _methodHandler(e){let t=`${this.baseURL}${this.url}`,r=null;if(e==="get"){const c=new D;t=`${this.baseURL}${this.url}?${c.stringify(this.parameters)}`}else r=JSON.stringify(this.parameters);const n=new URL(t),o=new AbortController,{signal:i}=o;let a;this.timeout&&(a=setTimeout(()=>o.abort(),this.timeout));try{const c=await this.fetch(`${n}`,{method:e,headers:this.headers,body:r,signal:i});this.timeout&&clearTimeout(a);const l=await this._responseHandler(c);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(l)):this._statusHandler(l)}catch(c){return{message:c}}}eject(){this.ejectInterceptor=!0}_statusHandler(e){const t=/20[0-6]/g;return new Promise((r,n)=>{if(t.test(`${e.status}`))return r(e);const o={message:new Error(e.statusText),status:e.status,response:e.data.error||e.data.slug};n(o)})}}let T={};const m={};class Se{constructor(e,t){if(u(this,"client"),u(this,"maxRetries"),u(this,"throttle"),u(this,"accessToken"),u(this,"cache"),u(this,"helpers"),u(this,"relations"),u(this,"links"),u(this,"richTextResolver"),u(this,"resolveNestedRelations"),!t){const o=e.region?`-${e.region}`:"",i=e.https===!1?"http":"https";e.oauthToken?t=`${i}://api${o}.storyblok.com/v1`:t=`${i}://api${o}.storyblok.com/v2`}const r=new Headers;r.set("Content-Type","application/json"),r.set("Accept","application/json"),r.forEach((o,i)=>{e.headers&&e.headers[i]&&r.set(i,e.headers[i])});let n=5;e.oauthToken&&(r.set("Authorization",e.oauthToken),n=3),e.rateLimit&&(n=e.rateLimit),e.richTextSchema?this.richTextResolver=new $(e.richTextSchema):this.richTextResolver=new $,e.componentResolver&&this.setComponentResolver(e.componentResolver),this.maxRetries=e.maxRetries,this.throttle=ae(this.throttledRequest,n,1e3),this.accessToken=e.accessToken||"",this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.helpers=new D,this.resolveNestedRelations=!1,this.client=new Ee({baseURL:t,timeout:e.timeout||0,headers:r,responseInterceptor:e.responseInterceptor,fetch:e.fetch})}setComponentResolver(e){this.richTextResolver.addNode("blok",t=>{let r="";return t.attrs.body.forEach(n=>{r+=e(n.component,n)}),{html:r}})}parseParams(e){return e.version||(e.version="published"),e.token||(e.token=this.getToken()),e.cv||(e.cv=m[e.token]),Array.isArray(e.resolve_relations)&&(e.resolve_relations=e.resolve_relations.join(",")),e}factoryParamOptions(e,t){return this.helpers.isCDNUrl(e)?this.parseParams(t):t}makeRequest(e,t,r,n){const o=this.factoryParamOptions(e,this.helpers.getOptionsPage(t,r,n));return this.cacheResponse(e,o)}get(e,t){t||(t={});const r=`/${e}`,n=this.factoryParamOptions(r,t);return this.cacheResponse(r,n)}async getAll(e,t,r){const n=(t==null?void 0:t.per_page)||25,o=`/${e}`,i=o.split("/"),a=r||i[i.length-1],c=1,l=await this.makeRequest(o,t,n,c),h=l.total?Math.ceil(l.total/n):1,f=await this.helpers.asyncMap(this.helpers.range(c,h),b=>this.makeRequest(o,t,n,b+1));return this.helpers.flatMap([l,...f],b=>Object.values(b.data[a]))}post(e,t){const r=`/${e}`;return Promise.resolve(this.throttle("post",r,t))}put(e,t){const r=`/${e}`;return Promise.resolve(this.throttle("put",r,t))}delete(e,t){const r=`/${e}`;return Promise.resolve(this.throttle("delete",r,t))}getStories(e){return this.get("cdn/stories",e)}getStory(e,t){return this.get(`cdn/stories/${e}`,t)}getToken(){return this.accessToken}ejectInterceptor(){this.client.eject()}_cleanCopy(e){return JSON.parse(JSON.stringify(e))}_insertLinks(e,t){const r=e[t];r&&r.fieldtype=="multilink"&&r.linktype=="story"&&typeof r.id=="string"&&this.links[r.id]?r.story=this._cleanCopy(this.links[r.id]):r&&r.linktype==="story"&&typeof r.uuid=="string"&&this.links[r.uuid]&&(r.story=this._cleanCopy(this.links[r.uuid]))}_insertRelations(e,t,r){if(r.indexOf(`${e.component}.${t}`)>-1){if(typeof e[t]=="string")this.relations[e[t]]&&(e[t]=this._cleanCopy(this.relations[e[t]]));else if(e[t]&&e[t].constructor===Array){const n=[];e[t].forEach(o=>{this.relations[o]&&n.push(this._cleanCopy(this.relations[o]))}),e[t]=n}}}iterateTree(e,t){const r=n=>{if(n!=null){if(n.constructor===Array)for(let o=0;o<n.length;o++)r(n[o]);else if(n.constructor===Object){if(n._stopResolving)return;for(const o in n)(n.component&&n._uid||n.type==="link")&&(this._insertRelations(n,o,t),this._insertLinks(n,o)),r(n[o])}}};r(e.content)}async resolveLinks(e,t){let r=[];if(e.link_uuids){const n=e.link_uuids.length,o=[],i=50;for(let a=0;a<n;a+=i){const c=Math.min(n,a+i);o.push(e.link_uuids.slice(a,c))}for(let a=0;a<o.length;a++)(await this.getStories({per_page:i,language:t.language,version:t.version,by_uuids:o[a].join(",")})).data.stories.forEach(c=>{r.push(c)})}else r=e.links;r.forEach(n=>{this.links[n.uuid]={...n,_stopResolving:!0}})}async resolveRelations(e,t){let r=[];if(e.rel_uuids){const n=e.rel_uuids.length,o=[],i=50;for(let a=0;a<n;a+=i){const c=Math.min(n,a+i);o.push(e.rel_uuids.slice(a,c))}for(let a=0;a<o.length;a++)(await this.getStories({per_page:i,language:t.language,version:t.version,by_uuids:o[a].join(",")})).data.stories.forEach(c=>{r.push(c)})}else r=e.rels;r&&r.length>0&&r.forEach(n=>{this.relations[n.uuid]={...n,_stopResolving:!0}})}async resolveStories(e,t){var r,n;let o=[];if(typeof t.resolve_relations<"u"&&t.resolve_relations.length>0&&(typeof t.resolve_relations=="string"&&(o=t.resolve_relations.split(",")),await this.resolveRelations(e,t)),t.resolve_links&&["1","story","url"].indexOf(t.resolve_links)>-1&&((r=e.links)!=null&&r.length||(n=e.link_uuids)!=null&&n.length)&&await this.resolveLinks(e,t),this.resolveNestedRelations)for(const i in this.relations)this.iterateTree(this.relations[i],o);e.story?this.iterateTree(e.story,o):e.stories.forEach(i=>{this.iterateTree(i,o)})}async cacheResponse(e,t,r){const n=this.helpers.stringify({url:e,params:t}),o=this.cacheProvider();if(this.cache.clear==="auto"&&t.version==="draft"&&await this.flushCache(),t.version==="published"&&e!="/cdn/spaces/me"){const i=await o.get(n);if(i)return Promise.resolve(i)}return new Promise((i,a)=>{try{(async()=>{var c;try{const l=await this.throttle("get",e,t);let h={data:l.data,headers:l.headers};return(c=l.headers)!=null&&c["per-page"]&&(h=Object.assign({},h,{perPage:l.headers["per-page"]?parseInt(l.headers["per-page"]):0,total:l.headers["per-page"]?parseInt(l.headers.total):0})),l.status!=200?a(l):((h.data.story||h.data.stories)&&await this.resolveStories(h.data,t),t.version==="published"&&e!="/cdn/spaces/me"&&await o.set(n,h),h.data.cv&&t.token&&(t.version=="draft"&&m[t.token]!=h.data.cv&&await this.flushCache(),m[t.token]=h.data.cv),i(h))}catch(l){return a(l)}})()}catch{}})}throttledRequest(e,t,r){return this.client[e](t,r)}cacheVersions(){return m}cacheVersion(){return m[this.accessToken]}setCacheVersion(e){this.accessToken&&(m[this.accessToken]=e)}cacheProvider(){switch(this.cache.type){case"memory":return{get(e){return Promise.resolve(T[e])},getAll(){return Promise.resolve(T)},set(e,t){return T[e]=t,Promise.resolve(void 0)},flush(){return T={},Promise.resolve(void 0)}};case"custom":if(this.cache.custom)return this.cache.custom;default:return{get(){return Promise.resolve(void 0)},getAll(){return Promise.resolve(void 0)},set(){return Promise.resolve(void 0)},flush(){return Promise.resolve(void 0)}}}}async flushCache(){return await this.cacheProvider().flush(),this}}const Oe=(s={})=>{const{apiOptions:e}=s;if(!e.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 Se(e)}},Ce=s=>{if(typeof s!="object"||typeof s._editable>"u")return{};const e=JSON.parse(s._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return{"data-blok-c":JSON.stringify(e),"data-blok-uid":e.id+"-"+e.uid}};let j;const Ie="https://app.storyblok.com/f/storyblok-v2-latest.js",Ae=(s,e,t={})=>{var r;const n=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",o=+new URL((r=window.location)==null?void 0:r.href).searchParams.get("_storyblok")===s;if(!(!n||!o)){if(!s){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(t).on(["input","published","change"],i=>{i.action==="input"&&i.story.id===s?e(i.story):(i.action==="change"||i.action==="published")&&i.storyId===s&&window.location.reload()})})}},Ne=(s={})=>{var e,t;const{bridge:r,accessToken:n,use:o=[],apiOptions:i={},richText:a={}}=s;i.accessToken=i.accessToken||n;const c={bridge:r,apiOptions:i};let l={};o.forEach(f=>{l={...l,...f(c)}});const h=!(typeof window>"u")&&((t=(e=window.location)==null?void 0:e.search)==null?void 0:t.includes("_storyblok_tk"));return r!==!1&&h&&ne(Ie),j=new $(a.schema),a.resolver&&B(j,a.resolver),l},B=(s,e)=>{s.addNode("blok",t=>{let r="";return t.attrs.body.forEach(n=>{r+=e(n.component,n)}),{html:r}})},Me=(s,e,t)=>{let r=t||j;if(!r){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return s===""?"":s?(e&&(r=new $(e.schema),e.resolver&&B(r,e.resolver)),r.render(s)):(console.warn(`${s} is not a valid Richtext object. This might be because the value of the richtext field is empty.
|
|
2
|
-
|
|
3
|
-
For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`),"")};function x(){}function E(s,e){for(const t in e)s[t]=e[t];return s}function J(s){return s()}function F(){return Object.create(null)}function v(s){s.forEach(J)}function V(s){return typeof s=="function"}function Le(s,e){return s!=s?e==e:s!==e||s&&typeof s=="object"||typeof s=="function"}function Ue(s){return Object.keys(s).length===0}function He(s){const e={};for(const t in s)t[0]!=="$"&&(e[t]=s[t]);return e}function Y(s,e){const t={};e=new Set(e);for(const r in s)!e.has(r)&&r[0]!=="$"&&(t[r]=s[r]);return t}function qe(s,e,t){s.insertBefore(e,t||null)}function z(s){s.parentNode&&s.parentNode.removeChild(s)}function De(s){return document.createTextNode(s)}function Be(){return De("")}function Je(s){return Array.from(s.childNodes)}function K(s,e){return new s(e)}let S;function w(s){S=s}const y=[],G=[];let k=[];const Q=[],Fe=Promise.resolve();let O=!1;function Ve(){O||(O=!0,Fe.then(W))}function C(s){k.push(s)}const I=new Set;let _=0;function W(){if(_!==0)return;const s=S;do{try{for(;_<y.length;){const e=y[_];_++,w(e),Ye(e.$$)}}catch(e){throw y.length=0,_=0,e}for(w(null),y.length=0,_=0;G.length;)G.pop()();for(let e=0;e<k.length;e+=1){const t=k[e];I.has(t)||(I.add(t),t())}k.length=0}while(y.length);for(;Q.length;)Q.pop()();O=!1,I.clear(),w(s)}function Ye(s){if(s.fragment!==null){s.update(),v(s.before_update);const e=s.dirty;s.dirty=[-1],s.fragment&&s.fragment.p(s.ctx,e),s.after_update.forEach(C)}}function ze(s){const e=[],t=[];k.forEach(r=>s.indexOf(r)===-1?e.push(r):t.push(r)),t.forEach(r=>r()),k=e}const R=new Set;let p;function Ke(){p={r:0,c:[],p}}function Ge(){p.r||v(p.c),p=p.p}function A(s,e){s&&s.i&&(R.delete(s),s.i(e))}function X(s,e,t,r){if(s&&s.o){if(R.has(s))return;R.add(s),p.c.push(()=>{R.delete(s),r&&(t&&s.d(1),r())}),s.o(e)}else r&&r()}function Qe(s,e){const t={},r={},n={$$scope:1};let o=s.length;for(;o--;){const i=s[o],a=e[o];if(a){for(const c in i)c in a||(r[c]=1);for(const c in a)n[c]||(t[c]=a[c],n[c]=1);s[o]=a}else for(const c in i)n[c]=1}for(const i in r)i in t||(t[i]=void 0);return t}function We(s){return typeof s=="object"&&s!==null?s:{}}function Z(s){s&&s.c()}function N(s,e,t,r){const{fragment:n,after_update:o}=s.$$;n&&n.m(e,t),r||C(()=>{const i=s.$$.on_mount.map(J).filter(V);s.$$.on_destroy?s.$$.on_destroy.push(...i):v(i),s.$$.on_mount=[]}),o.forEach(C)}function M(s,e){const t=s.$$;t.fragment!==null&&(ze(t.after_update),v(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function Xe(s,e){s.$$.dirty[0]===-1&&(y.push(s),Ve(),s.$$.dirty.fill(0)),s.$$.dirty[e/31|0]|=1<<e%31}function Ze(s,e,t,r,n,o,i,a=[-1]){const c=S;w(s);const l=s.$$={fragment:null,ctx:[],props:o,update:x,not_equal:n,bound:F(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(c?c.$$.context:[])),callbacks:F(),dirty:a,skip_bound:!1,root:e.target||c.$$.root};i&&i(l.root);let h=!1;if(l.ctx=t?t(s,e.props||{},(f,b,...se)=>{const re=se.length?se[0]:b;return l.ctx&&n(l.ctx[f],l.ctx[f]=re)&&(!l.skip_bound&&l.bound[f]&&l.bound[f](re),h&&Xe(s,f)),b}):[],l.update(),h=!0,v(l.before_update),l.fragment=r?r(l.ctx):!1,e.target){if(e.hydrate){const f=Je(e.target);l.fragment&&l.fragment.l(f),f.forEach(z)}else l.fragment&&l.fragment.c();e.intro&&A(s.$$.fragment),N(s,e.target,e.anchor,e.customElement),W()}w(c)}class et{$destroy(){M(this,1),this.$destroy=x}$on(e,t){if(!V(t))return x;const r=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return r.push(t),()=>{const n=r.indexOf(t);n!==-1&&r.splice(n,1)}}$set(e){this.$$set&&!Ue(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}function tt(s){let e,t,r;const n=[{blok:s[0]},s[2]];var o=s[1];function i(a){let c={};for(let l=0;l<n.length;l+=1)c=E(c,n[l]);return{props:c}}return o&&(e=K(o,i())),{c(){e&&Z(e.$$.fragment),t=Be()},m(a,c){e&&N(e,a,c),qe(a,t,c),r=!0},p(a,[c]){const l=c&5?Qe(n,[c&1&&{blok:a[0]},c&4&&We(a[2])]):{};if(c&2&&o!==(o=a[1])){if(e){Ke();const h=e;X(h.$$.fragment,1,0,()=>{M(h,1)}),Ge()}o?(e=K(o,i()),Z(e.$$.fragment),A(e.$$.fragment,1),N(e,t.parentNode,t)):e=null}else o&&e.$set(l)},i(a){r||(e&&A(e.$$.fragment,a),r=!0)},o(a){e&&X(e.$$.fragment,a),r=!1},d(a){a&&z(t),e&&M(e,a)}}}function st(s,e,t){const r=["blok"];let n=Y(e,r),o,{blok:i}=e;return i?o=te(i.component):console.error("Please provide a 'blok' property to the StoryblokComponent"),s.$$set=a=>{e=E(E({},e),He(a)),t(2,n=Y(e,r)),"blok"in a&&t(0,i=a.blok)},[i,o,n]}class rt extends et{constructor(e){super(),Ze(this,e,st,tt,Le,{blok:0})}}const nt=(s,e)=>{const t=r=>{const n=Ce(r);n["data-blok-c"]&&(s.setAttribute("data-blok-c",n["data-blok-c"]),s.setAttribute("data-blok-uid",n["data-blok-uid"]),s.classList.add("storyblok__outline"))};return t(e),{update(r){t(r)}}};let L=null;const ee=()=>(L||console.log("You can't use getStoryblokApi if you're not loading apiPlugin."),L);let P=null;const ot=s=>{const{storyblokApi:e}=Ne(s);L=e,P=s.components||{}},te=s=>{let e=null;return e=typeof P=="function"?P()[s]:P[s],e||console.error(`You didn't load the ${s} component. Please load it in storyblokInit. For example:
|
|
4
|
-
storyblokInit({
|
|
5
|
-
accessToken: "<your-token>",
|
|
6
|
-
components: {
|
|
7
|
-
"teaser": Teaser
|
|
8
|
-
}
|
|
9
|
-
})
|
|
10
|
-
`),e};d.RichTextSchema=q,d.StoryblokComponent=rt,d.apiPlugin=Oe,d.getComponent=te,d.getStoryblokApi=ee,d.renderRichText=Me,d.storyblokEditable=nt,d.storyblokInit=ot,d.useStoryblokApi=ee,d.useStoryblokBridge=Ae,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -1,1007 +0,0 @@
|
|
|
1
|
-
let U = !1;
|
|
2
|
-
const H = [], ee = (s) => new Promise((e, t) => {
|
|
3
|
-
if (typeof window > "u" || (window.storyblokRegisterEvent = (n) => {
|
|
4
|
-
if (window.location === window.parent.location) {
|
|
5
|
-
console.warn("You are not in Draft Mode or in the Visual Editor.");
|
|
6
|
-
return;
|
|
7
|
-
}
|
|
8
|
-
U ? n() : H.push(n);
|
|
9
|
-
}, document.getElementById("storyblok-javascript-bridge")))
|
|
10
|
-
return;
|
|
11
|
-
const r = document.createElement("script");
|
|
12
|
-
r.async = !0, r.src = s, r.id = "storyblok-javascript-bridge", r.onerror = (n) => t(n), r.onload = (n) => {
|
|
13
|
-
H.forEach((o) => o()), U = !0, e(n);
|
|
14
|
-
}, document.getElementsByTagName("head")[0].appendChild(r);
|
|
15
|
-
});
|
|
16
|
-
var te = Object.defineProperty, se = (s, e, t) => e in s ? te(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t, h = (s, e, t) => (se(s, typeof e != "symbol" ? e + "" : e, t), t);
|
|
17
|
-
function q(s) {
|
|
18
|
-
return !(s !== s || s === 1 / 0 || s === -1 / 0);
|
|
19
|
-
}
|
|
20
|
-
function re(s, e, t) {
|
|
21
|
-
if (!q(e))
|
|
22
|
-
throw new TypeError("Expected `limit` to be a finite number");
|
|
23
|
-
if (!q(t))
|
|
24
|
-
throw new TypeError("Expected `interval` to be a finite number");
|
|
25
|
-
const r = [];
|
|
26
|
-
let n = [], o = 0;
|
|
27
|
-
const i = function() {
|
|
28
|
-
o++;
|
|
29
|
-
const c = setTimeout(function() {
|
|
30
|
-
o--, r.length > 0 && i(), n = n.filter(function(u) {
|
|
31
|
-
return u !== c;
|
|
32
|
-
});
|
|
33
|
-
}, t);
|
|
34
|
-
n.indexOf(c) < 0 && n.push(c);
|
|
35
|
-
const l = r.shift();
|
|
36
|
-
l.resolve(s.apply(l.self, l.args));
|
|
37
|
-
}, a = function(...c) {
|
|
38
|
-
const l = this;
|
|
39
|
-
return new Promise(function(u, d) {
|
|
40
|
-
r.push({
|
|
41
|
-
resolve: u,
|
|
42
|
-
reject: d,
|
|
43
|
-
args: c,
|
|
44
|
-
self: l
|
|
45
|
-
}), o < e && i();
|
|
46
|
-
});
|
|
47
|
-
};
|
|
48
|
-
return a.abort = function() {
|
|
49
|
-
n.forEach(clearTimeout), n = [], r.forEach(function(c) {
|
|
50
|
-
c.reject(function() {
|
|
51
|
-
Error.call(this, "Throttled function aborted"), this.name = "AbortError";
|
|
52
|
-
});
|
|
53
|
-
}), r.length = 0;
|
|
54
|
-
}, a;
|
|
55
|
-
}
|
|
56
|
-
const ne = function(s, e) {
|
|
57
|
-
const t = {};
|
|
58
|
-
for (const r in s) {
|
|
59
|
-
const n = s[r];
|
|
60
|
-
e.indexOf(r) > -1 && n !== null && (t[r] = n);
|
|
61
|
-
}
|
|
62
|
-
return t;
|
|
63
|
-
}, oe = (s) => s === "email", ie = () => ({
|
|
64
|
-
singleTag: "hr"
|
|
65
|
-
}), ae = () => ({
|
|
66
|
-
tag: "blockquote"
|
|
67
|
-
}), ce = () => ({
|
|
68
|
-
tag: "ul"
|
|
69
|
-
}), le = (s) => ({
|
|
70
|
-
tag: [
|
|
71
|
-
"pre",
|
|
72
|
-
{
|
|
73
|
-
tag: "code",
|
|
74
|
-
attrs: s.attrs
|
|
75
|
-
}
|
|
76
|
-
]
|
|
77
|
-
}), he = () => ({
|
|
78
|
-
singleTag: "br"
|
|
79
|
-
}), ue = (s) => ({
|
|
80
|
-
tag: `h${s.attrs.level}`
|
|
81
|
-
}), de = (s) => ({
|
|
82
|
-
singleTag: [
|
|
83
|
-
{
|
|
84
|
-
tag: "img",
|
|
85
|
-
attrs: ne(s.attrs, ["src", "alt", "title"])
|
|
86
|
-
}
|
|
87
|
-
]
|
|
88
|
-
}), fe = () => ({
|
|
89
|
-
tag: "li"
|
|
90
|
-
}), pe = () => ({
|
|
91
|
-
tag: "ol"
|
|
92
|
-
}), ge = () => ({
|
|
93
|
-
tag: "p"
|
|
94
|
-
}), me = () => ({
|
|
95
|
-
tag: "b"
|
|
96
|
-
}), ye = () => ({
|
|
97
|
-
tag: "strike"
|
|
98
|
-
}), ke = () => ({
|
|
99
|
-
tag: "u"
|
|
100
|
-
}), _e = () => ({
|
|
101
|
-
tag: "strong"
|
|
102
|
-
}), be = () => ({
|
|
103
|
-
tag: "code"
|
|
104
|
-
}), ve = () => ({
|
|
105
|
-
tag: "i"
|
|
106
|
-
}), we = (s) => {
|
|
107
|
-
const e = { ...s.attrs }, { linktype: t = "url" } = s.attrs;
|
|
108
|
-
return oe(t) && (e.href = `mailto:${e.href}`), e.anchor && (e.href = `${e.href}#${e.anchor}`, delete e.anchor), {
|
|
109
|
-
tag: [
|
|
110
|
-
{
|
|
111
|
-
tag: "a",
|
|
112
|
-
attrs: e
|
|
113
|
-
}
|
|
114
|
-
]
|
|
115
|
-
};
|
|
116
|
-
}, $e = (s) => ({
|
|
117
|
-
tag: [
|
|
118
|
-
{
|
|
119
|
-
tag: "span",
|
|
120
|
-
attrs: s.attrs
|
|
121
|
-
}
|
|
122
|
-
]
|
|
123
|
-
}), Te = {
|
|
124
|
-
nodes: {
|
|
125
|
-
horizontal_rule: ie,
|
|
126
|
-
blockquote: ae,
|
|
127
|
-
bullet_list: ce,
|
|
128
|
-
code_block: le,
|
|
129
|
-
hard_break: he,
|
|
130
|
-
heading: ue,
|
|
131
|
-
image: de,
|
|
132
|
-
list_item: fe,
|
|
133
|
-
ordered_list: pe,
|
|
134
|
-
paragraph: ge
|
|
135
|
-
},
|
|
136
|
-
marks: {
|
|
137
|
-
bold: me,
|
|
138
|
-
strike: ye,
|
|
139
|
-
underline: ke,
|
|
140
|
-
strong: _e,
|
|
141
|
-
code: be,
|
|
142
|
-
italic: ve,
|
|
143
|
-
link: we,
|
|
144
|
-
styled: $e
|
|
145
|
-
}
|
|
146
|
-
}, Re = function(s) {
|
|
147
|
-
const e = {
|
|
148
|
-
"&": "&",
|
|
149
|
-
"<": "<",
|
|
150
|
-
">": ">",
|
|
151
|
-
'"': """,
|
|
152
|
-
"'": "'"
|
|
153
|
-
}, t = /[&<>"']/g, r = RegExp(t.source);
|
|
154
|
-
return s && r.test(s) ? s.replace(t, (n) => e[n]) : s;
|
|
155
|
-
};
|
|
156
|
-
class T {
|
|
157
|
-
constructor(e) {
|
|
158
|
-
h(this, "marks"), h(this, "nodes"), e || (e = Te), this.marks = e.marks || [], this.nodes = e.nodes || [];
|
|
159
|
-
}
|
|
160
|
-
addNode(e, t) {
|
|
161
|
-
this.nodes[e] = t;
|
|
162
|
-
}
|
|
163
|
-
addMark(e, t) {
|
|
164
|
-
this.marks[e] = t;
|
|
165
|
-
}
|
|
166
|
-
render(e) {
|
|
167
|
-
if (e && e.content && Array.isArray(e.content)) {
|
|
168
|
-
let t = "";
|
|
169
|
-
return e.content.forEach((r) => {
|
|
170
|
-
t += this.renderNode(r);
|
|
171
|
-
}), t;
|
|
172
|
-
}
|
|
173
|
-
return console.warn(
|
|
174
|
-
"The render method must receive an object with a content field, which is an array"
|
|
175
|
-
), "";
|
|
176
|
-
}
|
|
177
|
-
renderNode(e) {
|
|
178
|
-
const t = [];
|
|
179
|
-
e.marks && e.marks.forEach((n) => {
|
|
180
|
-
const o = this.getMatchingMark(n);
|
|
181
|
-
o && t.push(this.renderOpeningTag(o.tag));
|
|
182
|
-
});
|
|
183
|
-
const r = this.getMatchingNode(e);
|
|
184
|
-
return r && r.tag && t.push(this.renderOpeningTag(r.tag)), e.content ? e.content.forEach((n) => {
|
|
185
|
-
t.push(this.renderNode(n));
|
|
186
|
-
}) : e.text ? t.push(Re(e.text)) : r && r.singleTag ? t.push(this.renderTag(r.singleTag, " /")) : r && r.html && t.push(r.html), r && r.tag && t.push(this.renderClosingTag(r.tag)), e.marks && e.marks.slice(0).reverse().forEach((n) => {
|
|
187
|
-
const o = this.getMatchingMark(n);
|
|
188
|
-
o && t.push(this.renderClosingTag(o.tag));
|
|
189
|
-
}), t.join("");
|
|
190
|
-
}
|
|
191
|
-
renderTag(e, t) {
|
|
192
|
-
return e.constructor === String ? `<${e}${t}>` : e.map((r) => {
|
|
193
|
-
if (r.constructor === String)
|
|
194
|
-
return `<${r}${t}>`;
|
|
195
|
-
{
|
|
196
|
-
let n = `<${r.tag}`;
|
|
197
|
-
if (r.attrs)
|
|
198
|
-
for (const o in r.attrs) {
|
|
199
|
-
const i = r.attrs[o];
|
|
200
|
-
i !== null && (n += ` ${o}="${i}"`);
|
|
201
|
-
}
|
|
202
|
-
return `${n}${t}>`;
|
|
203
|
-
}
|
|
204
|
-
}).join("");
|
|
205
|
-
}
|
|
206
|
-
renderOpeningTag(e) {
|
|
207
|
-
return this.renderTag(e, "");
|
|
208
|
-
}
|
|
209
|
-
renderClosingTag(e) {
|
|
210
|
-
return e.constructor === String ? `</${e}>` : e.slice(0).reverse().map((t) => t.constructor === String ? `</${t}>` : `</${t.tag}>`).join("");
|
|
211
|
-
}
|
|
212
|
-
getMatchingNode(e) {
|
|
213
|
-
const t = this.nodes[e.type];
|
|
214
|
-
if (typeof t == "function")
|
|
215
|
-
return t(e);
|
|
216
|
-
}
|
|
217
|
-
getMatchingMark(e) {
|
|
218
|
-
const t = this.marks[e.type];
|
|
219
|
-
if (typeof t == "function")
|
|
220
|
-
return t(e);
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
class K {
|
|
224
|
-
constructor() {
|
|
225
|
-
h(this, "isCDNUrl", (e = "") => e.indexOf("/cdn/") > -1), h(this, "getOptionsPage", (e, t = 25, r = 1) => ({
|
|
226
|
-
...e,
|
|
227
|
-
per_page: t,
|
|
228
|
-
page: r
|
|
229
|
-
})), h(this, "delay", (e) => new Promise((t) => setTimeout(t, e))), h(this, "arrayFrom", (e = 0, t) => [...Array(e)].map(t)), h(this, "range", (e = 0, t = e) => {
|
|
230
|
-
const r = Math.abs(t - e) || 0, n = e < t ? 1 : -1;
|
|
231
|
-
return this.arrayFrom(r, (o, i) => i * n + e);
|
|
232
|
-
}), h(this, "asyncMap", async (e, t) => Promise.all(e.map(t))), h(this, "flatMap", (e = [], t) => e.map(t).reduce((r, n) => [...r, ...n], []));
|
|
233
|
-
}
|
|
234
|
-
stringify(e, t, r) {
|
|
235
|
-
const n = [];
|
|
236
|
-
for (const o in e) {
|
|
237
|
-
if (!Object.prototype.hasOwnProperty.call(e, o))
|
|
238
|
-
continue;
|
|
239
|
-
const i = e[o], a = r ? "" : encodeURIComponent(o);
|
|
240
|
-
let c;
|
|
241
|
-
typeof i == "object" ? c = this.stringify(
|
|
242
|
-
i,
|
|
243
|
-
t ? t + encodeURIComponent("[" + a + "]") : a,
|
|
244
|
-
Array.isArray(i)
|
|
245
|
-
) : c = (t ? t + encodeURIComponent("[" + a + "]") : a) + "=" + encodeURIComponent(i), n.push(c);
|
|
246
|
-
}
|
|
247
|
-
return n.join("&");
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
class xe {
|
|
251
|
-
constructor(e) {
|
|
252
|
-
h(this, "baseURL"), h(this, "timeout"), h(this, "headers"), h(this, "responseInterceptor"), h(this, "fetch"), h(this, "ejectInterceptor"), h(this, "url"), h(this, "parameters"), this.baseURL = e.baseURL, this.headers = e.headers || [], this.timeout = e != null && e.timeout ? e.timeout * 1e3 : 0, this.responseInterceptor = e.responseInterceptor, this.fetch = (...t) => e.fetch ? e.fetch(...t) : fetch(...t), this.ejectInterceptor = !1, this.url = "", this.parameters = {};
|
|
253
|
-
}
|
|
254
|
-
get(e, t) {
|
|
255
|
-
return this.url = e, this.parameters = t, this._methodHandler("get");
|
|
256
|
-
}
|
|
257
|
-
post(e, t) {
|
|
258
|
-
return this.url = e, this.parameters = t, this._methodHandler("post");
|
|
259
|
-
}
|
|
260
|
-
put(e, t) {
|
|
261
|
-
return this.url = e, this.parameters = t, this._methodHandler("put");
|
|
262
|
-
}
|
|
263
|
-
delete(e, t) {
|
|
264
|
-
return this.url = e, this.parameters = t, this._methodHandler("delete");
|
|
265
|
-
}
|
|
266
|
-
async _responseHandler(e) {
|
|
267
|
-
const t = [], r = {
|
|
268
|
-
data: {},
|
|
269
|
-
headers: {},
|
|
270
|
-
status: 0,
|
|
271
|
-
statusText: ""
|
|
272
|
-
};
|
|
273
|
-
e.status !== 204 && await e.json().then((n) => {
|
|
274
|
-
r.data = n;
|
|
275
|
-
});
|
|
276
|
-
for (const n of e.headers.entries())
|
|
277
|
-
t[n[0]] = n[1];
|
|
278
|
-
return r.headers = { ...t }, r.status = e.status, r.statusText = e.statusText, r;
|
|
279
|
-
}
|
|
280
|
-
async _methodHandler(e) {
|
|
281
|
-
let t = `${this.baseURL}${this.url}`, r = null;
|
|
282
|
-
if (e === "get") {
|
|
283
|
-
const c = new K();
|
|
284
|
-
t = `${this.baseURL}${this.url}?${c.stringify(
|
|
285
|
-
this.parameters
|
|
286
|
-
)}`;
|
|
287
|
-
} else
|
|
288
|
-
r = JSON.stringify(this.parameters);
|
|
289
|
-
const n = new URL(t), o = new AbortController(), { signal: i } = o;
|
|
290
|
-
let a;
|
|
291
|
-
this.timeout && (a = setTimeout(() => o.abort(), this.timeout));
|
|
292
|
-
try {
|
|
293
|
-
const c = await this.fetch(`${n}`, {
|
|
294
|
-
method: e,
|
|
295
|
-
headers: this.headers,
|
|
296
|
-
body: r,
|
|
297
|
-
signal: i
|
|
298
|
-
});
|
|
299
|
-
this.timeout && clearTimeout(a);
|
|
300
|
-
const l = await this._responseHandler(c);
|
|
301
|
-
return this.responseInterceptor && !this.ejectInterceptor ? this._statusHandler(this.responseInterceptor(l)) : this._statusHandler(l);
|
|
302
|
-
} catch (c) {
|
|
303
|
-
return {
|
|
304
|
-
message: c
|
|
305
|
-
};
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
eject() {
|
|
309
|
-
this.ejectInterceptor = !0;
|
|
310
|
-
}
|
|
311
|
-
_statusHandler(e) {
|
|
312
|
-
const t = /20[0-6]/g;
|
|
313
|
-
return new Promise((r, n) => {
|
|
314
|
-
if (t.test(`${e.status}`))
|
|
315
|
-
return r(e);
|
|
316
|
-
const o = {
|
|
317
|
-
message: new Error(e.statusText),
|
|
318
|
-
status: e.status,
|
|
319
|
-
response: e.data.error || e.data.slug
|
|
320
|
-
};
|
|
321
|
-
n(o);
|
|
322
|
-
});
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
let v = {};
|
|
326
|
-
const g = {};
|
|
327
|
-
class Pe {
|
|
328
|
-
constructor(e, t) {
|
|
329
|
-
if (h(this, "client"), h(this, "maxRetries"), h(this, "throttle"), h(this, "accessToken"), h(this, "cache"), h(this, "helpers"), h(this, "relations"), h(this, "links"), h(this, "richTextResolver"), h(this, "resolveNestedRelations"), !t) {
|
|
330
|
-
const o = e.region ? `-${e.region}` : "", i = e.https === !1 ? "http" : "https";
|
|
331
|
-
e.oauthToken ? t = `${i}://api${o}.storyblok.com/v1` : t = `${i}://api${o}.storyblok.com/v2`;
|
|
332
|
-
}
|
|
333
|
-
const r = new Headers();
|
|
334
|
-
r.set("Content-Type", "application/json"), r.set("Accept", "application/json"), r.forEach((o, i) => {
|
|
335
|
-
e.headers && e.headers[i] && r.set(i, e.headers[i]);
|
|
336
|
-
});
|
|
337
|
-
let n = 5;
|
|
338
|
-
e.oauthToken && (r.set("Authorization", e.oauthToken), n = 3), e.rateLimit && (n = e.rateLimit), e.richTextSchema ? this.richTextResolver = new T(e.richTextSchema) : this.richTextResolver = new T(), e.componentResolver && this.setComponentResolver(e.componentResolver), this.maxRetries = e.maxRetries, this.throttle = re(this.throttledRequest, n, 1e3), this.accessToken = e.accessToken || "", this.relations = {}, this.links = {}, this.cache = e.cache || { clear: "manual" }, this.helpers = new K(), this.resolveNestedRelations = !1, this.client = new xe({
|
|
339
|
-
baseURL: t,
|
|
340
|
-
timeout: e.timeout || 0,
|
|
341
|
-
headers: r,
|
|
342
|
-
responseInterceptor: e.responseInterceptor,
|
|
343
|
-
fetch: e.fetch
|
|
344
|
-
});
|
|
345
|
-
}
|
|
346
|
-
setComponentResolver(e) {
|
|
347
|
-
this.richTextResolver.addNode("blok", (t) => {
|
|
348
|
-
let r = "";
|
|
349
|
-
return t.attrs.body.forEach((n) => {
|
|
350
|
-
r += e(n.component, n);
|
|
351
|
-
}), {
|
|
352
|
-
html: r
|
|
353
|
-
};
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
parseParams(e) {
|
|
357
|
-
return e.version || (e.version = "published"), e.token || (e.token = this.getToken()), e.cv || (e.cv = g[e.token]), Array.isArray(e.resolve_relations) && (e.resolve_relations = e.resolve_relations.join(",")), e;
|
|
358
|
-
}
|
|
359
|
-
factoryParamOptions(e, t) {
|
|
360
|
-
return this.helpers.isCDNUrl(e) ? this.parseParams(t) : t;
|
|
361
|
-
}
|
|
362
|
-
makeRequest(e, t, r, n) {
|
|
363
|
-
const o = this.factoryParamOptions(
|
|
364
|
-
e,
|
|
365
|
-
this.helpers.getOptionsPage(t, r, n)
|
|
366
|
-
);
|
|
367
|
-
return this.cacheResponse(e, o);
|
|
368
|
-
}
|
|
369
|
-
get(e, t) {
|
|
370
|
-
t || (t = {});
|
|
371
|
-
const r = `/${e}`, n = this.factoryParamOptions(r, t);
|
|
372
|
-
return this.cacheResponse(r, n);
|
|
373
|
-
}
|
|
374
|
-
async getAll(e, t, r) {
|
|
375
|
-
const n = (t == null ? void 0 : t.per_page) || 25, o = `/${e}`, i = o.split("/"), a = r || i[i.length - 1], c = 1, l = await this.makeRequest(o, t, n, c), u = l.total ? Math.ceil(l.total / n) : 1, d = await this.helpers.asyncMap(
|
|
376
|
-
this.helpers.range(c, u),
|
|
377
|
-
(p) => this.makeRequest(o, t, n, p + 1)
|
|
378
|
-
);
|
|
379
|
-
return this.helpers.flatMap(
|
|
380
|
-
[l, ...d],
|
|
381
|
-
(p) => Object.values(p.data[a])
|
|
382
|
-
);
|
|
383
|
-
}
|
|
384
|
-
post(e, t) {
|
|
385
|
-
const r = `/${e}`;
|
|
386
|
-
return Promise.resolve(this.throttle("post", r, t));
|
|
387
|
-
}
|
|
388
|
-
put(e, t) {
|
|
389
|
-
const r = `/${e}`;
|
|
390
|
-
return Promise.resolve(this.throttle("put", r, t));
|
|
391
|
-
}
|
|
392
|
-
delete(e, t) {
|
|
393
|
-
const r = `/${e}`;
|
|
394
|
-
return Promise.resolve(this.throttle("delete", r, t));
|
|
395
|
-
}
|
|
396
|
-
getStories(e) {
|
|
397
|
-
return this.get("cdn/stories", e);
|
|
398
|
-
}
|
|
399
|
-
getStory(e, t) {
|
|
400
|
-
return this.get(`cdn/stories/${e}`, t);
|
|
401
|
-
}
|
|
402
|
-
getToken() {
|
|
403
|
-
return this.accessToken;
|
|
404
|
-
}
|
|
405
|
-
ejectInterceptor() {
|
|
406
|
-
this.client.eject();
|
|
407
|
-
}
|
|
408
|
-
_cleanCopy(e) {
|
|
409
|
-
return JSON.parse(JSON.stringify(e));
|
|
410
|
-
}
|
|
411
|
-
_insertLinks(e, t) {
|
|
412
|
-
const r = e[t];
|
|
413
|
-
r && r.fieldtype == "multilink" && r.linktype == "story" && typeof r.id == "string" && this.links[r.id] ? r.story = this._cleanCopy(this.links[r.id]) : r && r.linktype === "story" && typeof r.uuid == "string" && this.links[r.uuid] && (r.story = this._cleanCopy(this.links[r.uuid]));
|
|
414
|
-
}
|
|
415
|
-
_insertRelations(e, t, r) {
|
|
416
|
-
if (r.indexOf(`${e.component}.${t}`) > -1) {
|
|
417
|
-
if (typeof e[t] == "string")
|
|
418
|
-
this.relations[e[t]] && (e[t] = this._cleanCopy(this.relations[e[t]]));
|
|
419
|
-
else if (e[t] && e[t].constructor === Array) {
|
|
420
|
-
const n = [];
|
|
421
|
-
e[t].forEach((o) => {
|
|
422
|
-
this.relations[o] && n.push(this._cleanCopy(this.relations[o]));
|
|
423
|
-
}), e[t] = n;
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
iterateTree(e, t) {
|
|
428
|
-
const r = (n) => {
|
|
429
|
-
if (n != null) {
|
|
430
|
-
if (n.constructor === Array)
|
|
431
|
-
for (let o = 0; o < n.length; o++)
|
|
432
|
-
r(n[o]);
|
|
433
|
-
else if (n.constructor === Object) {
|
|
434
|
-
if (n._stopResolving)
|
|
435
|
-
return;
|
|
436
|
-
for (const o in n)
|
|
437
|
-
(n.component && n._uid || n.type === "link") && (this._insertRelations(
|
|
438
|
-
n,
|
|
439
|
-
o,
|
|
440
|
-
t
|
|
441
|
-
), this._insertLinks(n, o)), r(n[o]);
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
};
|
|
445
|
-
r(e.content);
|
|
446
|
-
}
|
|
447
|
-
async resolveLinks(e, t) {
|
|
448
|
-
let r = [];
|
|
449
|
-
if (e.link_uuids) {
|
|
450
|
-
const n = e.link_uuids.length, o = [], i = 50;
|
|
451
|
-
for (let a = 0; a < n; a += i) {
|
|
452
|
-
const c = Math.min(n, a + i);
|
|
453
|
-
o.push(e.link_uuids.slice(a, c));
|
|
454
|
-
}
|
|
455
|
-
for (let a = 0; a < o.length; a++)
|
|
456
|
-
(await this.getStories({
|
|
457
|
-
per_page: i,
|
|
458
|
-
language: t.language,
|
|
459
|
-
version: t.version,
|
|
460
|
-
by_uuids: o[a].join(",")
|
|
461
|
-
})).data.stories.forEach(
|
|
462
|
-
(c) => {
|
|
463
|
-
r.push(c);
|
|
464
|
-
}
|
|
465
|
-
);
|
|
466
|
-
} else
|
|
467
|
-
r = e.links;
|
|
468
|
-
r.forEach((n) => {
|
|
469
|
-
this.links[n.uuid] = { ...n, _stopResolving: !0 };
|
|
470
|
-
});
|
|
471
|
-
}
|
|
472
|
-
async resolveRelations(e, t) {
|
|
473
|
-
let r = [];
|
|
474
|
-
if (e.rel_uuids) {
|
|
475
|
-
const n = e.rel_uuids.length, o = [], i = 50;
|
|
476
|
-
for (let a = 0; a < n; a += i) {
|
|
477
|
-
const c = Math.min(n, a + i);
|
|
478
|
-
o.push(e.rel_uuids.slice(a, c));
|
|
479
|
-
}
|
|
480
|
-
for (let a = 0; a < o.length; a++)
|
|
481
|
-
(await this.getStories({
|
|
482
|
-
per_page: i,
|
|
483
|
-
language: t.language,
|
|
484
|
-
version: t.version,
|
|
485
|
-
by_uuids: o[a].join(",")
|
|
486
|
-
})).data.stories.forEach((c) => {
|
|
487
|
-
r.push(c);
|
|
488
|
-
});
|
|
489
|
-
} else
|
|
490
|
-
r = e.rels;
|
|
491
|
-
r && r.length > 0 && r.forEach((n) => {
|
|
492
|
-
this.relations[n.uuid] = { ...n, _stopResolving: !0 };
|
|
493
|
-
});
|
|
494
|
-
}
|
|
495
|
-
async resolveStories(e, t) {
|
|
496
|
-
var r, n;
|
|
497
|
-
let o = [];
|
|
498
|
-
if (typeof t.resolve_relations < "u" && t.resolve_relations.length > 0 && (typeof t.resolve_relations == "string" && (o = t.resolve_relations.split(",")), await this.resolveRelations(e, t)), t.resolve_links && ["1", "story", "url"].indexOf(t.resolve_links) > -1 && ((r = e.links) != null && r.length || (n = e.link_uuids) != null && n.length) && await this.resolveLinks(e, t), this.resolveNestedRelations)
|
|
499
|
-
for (const i in this.relations)
|
|
500
|
-
this.iterateTree(this.relations[i], o);
|
|
501
|
-
e.story ? this.iterateTree(e.story, o) : e.stories.forEach((i) => {
|
|
502
|
-
this.iterateTree(i, o);
|
|
503
|
-
});
|
|
504
|
-
}
|
|
505
|
-
async cacheResponse(e, t, r) {
|
|
506
|
-
const n = this.helpers.stringify({ url: e, params: t }), o = this.cacheProvider();
|
|
507
|
-
if (this.cache.clear === "auto" && t.version === "draft" && await this.flushCache(), t.version === "published" && e != "/cdn/spaces/me") {
|
|
508
|
-
const i = await o.get(n);
|
|
509
|
-
if (i)
|
|
510
|
-
return Promise.resolve(i);
|
|
511
|
-
}
|
|
512
|
-
return new Promise((i, a) => {
|
|
513
|
-
try {
|
|
514
|
-
(async () => {
|
|
515
|
-
var c;
|
|
516
|
-
try {
|
|
517
|
-
const l = await this.throttle("get", e, t);
|
|
518
|
-
let u = { data: l.data, headers: l.headers };
|
|
519
|
-
return (c = l.headers) != null && c["per-page"] && (u = Object.assign({}, u, {
|
|
520
|
-
perPage: l.headers["per-page"] ? parseInt(l.headers["per-page"]) : 0,
|
|
521
|
-
total: l.headers["per-page"] ? parseInt(l.headers.total) : 0
|
|
522
|
-
})), l.status != 200 ? a(l) : ((u.data.story || u.data.stories) && await this.resolveStories(u.data, t), t.version === "published" && e != "/cdn/spaces/me" && await o.set(n, u), u.data.cv && t.token && (t.version == "draft" && g[t.token] != u.data.cv && await this.flushCache(), g[t.token] = u.data.cv), i(u));
|
|
523
|
-
} catch (l) {
|
|
524
|
-
return a(l);
|
|
525
|
-
}
|
|
526
|
-
})();
|
|
527
|
-
} catch {
|
|
528
|
-
}
|
|
529
|
-
});
|
|
530
|
-
}
|
|
531
|
-
throttledRequest(e, t, r) {
|
|
532
|
-
return this.client[e](t, r);
|
|
533
|
-
}
|
|
534
|
-
cacheVersions() {
|
|
535
|
-
return g;
|
|
536
|
-
}
|
|
537
|
-
cacheVersion() {
|
|
538
|
-
return g[this.accessToken];
|
|
539
|
-
}
|
|
540
|
-
setCacheVersion(e) {
|
|
541
|
-
this.accessToken && (g[this.accessToken] = e);
|
|
542
|
-
}
|
|
543
|
-
cacheProvider() {
|
|
544
|
-
switch (this.cache.type) {
|
|
545
|
-
case "memory":
|
|
546
|
-
return {
|
|
547
|
-
get(e) {
|
|
548
|
-
return Promise.resolve(v[e]);
|
|
549
|
-
},
|
|
550
|
-
getAll() {
|
|
551
|
-
return Promise.resolve(v);
|
|
552
|
-
},
|
|
553
|
-
set(e, t) {
|
|
554
|
-
return v[e] = t, Promise.resolve(void 0);
|
|
555
|
-
},
|
|
556
|
-
flush() {
|
|
557
|
-
return v = {}, Promise.resolve(void 0);
|
|
558
|
-
}
|
|
559
|
-
};
|
|
560
|
-
case "custom":
|
|
561
|
-
if (this.cache.custom)
|
|
562
|
-
return this.cache.custom;
|
|
563
|
-
default:
|
|
564
|
-
return {
|
|
565
|
-
get() {
|
|
566
|
-
return Promise.resolve(void 0);
|
|
567
|
-
},
|
|
568
|
-
getAll() {
|
|
569
|
-
return Promise.resolve(void 0);
|
|
570
|
-
},
|
|
571
|
-
set() {
|
|
572
|
-
return Promise.resolve(void 0);
|
|
573
|
-
},
|
|
574
|
-
flush() {
|
|
575
|
-
return Promise.resolve(void 0);
|
|
576
|
-
}
|
|
577
|
-
};
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
async flushCache() {
|
|
581
|
-
return await this.cacheProvider().flush(), this;
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
const Xe = (s = {}) => {
|
|
585
|
-
const { apiOptions: e } = s;
|
|
586
|
-
if (!e.accessToken) {
|
|
587
|
-
console.error(
|
|
588
|
-
"You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication"
|
|
589
|
-
);
|
|
590
|
-
return;
|
|
591
|
-
}
|
|
592
|
-
return { storyblokApi: new Pe(e) };
|
|
593
|
-
}, Ee = (s) => {
|
|
594
|
-
if (typeof s != "object" || typeof s._editable > "u")
|
|
595
|
-
return {};
|
|
596
|
-
const e = JSON.parse(
|
|
597
|
-
s._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
|
|
598
|
-
);
|
|
599
|
-
return {
|
|
600
|
-
"data-blok-c": JSON.stringify(e),
|
|
601
|
-
"data-blok-uid": e.id + "-" + e.uid
|
|
602
|
-
};
|
|
603
|
-
};
|
|
604
|
-
let x;
|
|
605
|
-
const je = "https://app.storyblok.com/f/storyblok-v2-latest.js", Ze = (s, e, t = {}) => {
|
|
606
|
-
var r;
|
|
607
|
-
const n = !(typeof window > "u") && typeof window.storyblokRegisterEvent < "u", o = +new URL((r = window.location) == null ? void 0 : r.href).searchParams.get(
|
|
608
|
-
"_storyblok"
|
|
609
|
-
) === s;
|
|
610
|
-
if (!(!n || !o)) {
|
|
611
|
-
if (!s) {
|
|
612
|
-
console.warn("Story ID is not defined. Please provide a valid ID.");
|
|
613
|
-
return;
|
|
614
|
-
}
|
|
615
|
-
window.storyblokRegisterEvent(() => {
|
|
616
|
-
new window.StoryblokBridge(t).on(["input", "published", "change"], (i) => {
|
|
617
|
-
i.action === "input" && i.story.id === s ? e(i.story) : (i.action === "change" || i.action === "published") && i.storyId === s && window.location.reload();
|
|
618
|
-
});
|
|
619
|
-
});
|
|
620
|
-
}
|
|
621
|
-
}, Se = (s = {}) => {
|
|
622
|
-
var e, t;
|
|
623
|
-
const {
|
|
624
|
-
bridge: r,
|
|
625
|
-
accessToken: n,
|
|
626
|
-
use: o = [],
|
|
627
|
-
apiOptions: i = {},
|
|
628
|
-
richText: a = {}
|
|
629
|
-
} = s;
|
|
630
|
-
i.accessToken = i.accessToken || n;
|
|
631
|
-
const c = { bridge: r, apiOptions: i };
|
|
632
|
-
let l = {};
|
|
633
|
-
o.forEach((d) => {
|
|
634
|
-
l = { ...l, ...d(c) };
|
|
635
|
-
});
|
|
636
|
-
const u = !(typeof window > "u") && ((t = (e = window.location) == null ? void 0 : e.search) == null ? void 0 : t.includes("_storyblok_tk"));
|
|
637
|
-
return r !== !1 && u && ee(je), x = new T(a.schema), a.resolver && G(x, a.resolver), l;
|
|
638
|
-
}, G = (s, e) => {
|
|
639
|
-
s.addNode("blok", (t) => {
|
|
640
|
-
let r = "";
|
|
641
|
-
return t.attrs.body.forEach((n) => {
|
|
642
|
-
r += e(n.component, n);
|
|
643
|
-
}), {
|
|
644
|
-
html: r
|
|
645
|
-
};
|
|
646
|
-
});
|
|
647
|
-
}, et = (s, e, t) => {
|
|
648
|
-
let r = t || x;
|
|
649
|
-
if (!r) {
|
|
650
|
-
console.error(
|
|
651
|
-
"Please initialize the Storyblok SDK before calling the renderRichText function"
|
|
652
|
-
);
|
|
653
|
-
return;
|
|
654
|
-
}
|
|
655
|
-
return s === "" ? "" : s ? (e && (r = new T(e.schema), e.resolver && G(r, e.resolver)), r.render(s)) : (console.warn(`${s} is not a valid Richtext object. This might be because the value of the richtext field is empty.
|
|
656
|
-
|
|
657
|
-
For more info about the richtext object check https://github.com/storyblok/storyblok-js#rendering-rich-text`), "");
|
|
658
|
-
};
|
|
659
|
-
function P() {
|
|
660
|
-
}
|
|
661
|
-
function E(s, e) {
|
|
662
|
-
for (const t in e)
|
|
663
|
-
s[t] = e[t];
|
|
664
|
-
return s;
|
|
665
|
-
}
|
|
666
|
-
function Q(s) {
|
|
667
|
-
return s();
|
|
668
|
-
}
|
|
669
|
-
function D() {
|
|
670
|
-
return /* @__PURE__ */ Object.create(null);
|
|
671
|
-
}
|
|
672
|
-
function b(s) {
|
|
673
|
-
s.forEach(Q);
|
|
674
|
-
}
|
|
675
|
-
function W(s) {
|
|
676
|
-
return typeof s == "function";
|
|
677
|
-
}
|
|
678
|
-
function Oe(s, e) {
|
|
679
|
-
return s != s ? e == e : s !== e || s && typeof s == "object" || typeof s == "function";
|
|
680
|
-
}
|
|
681
|
-
function Ce(s) {
|
|
682
|
-
return Object.keys(s).length === 0;
|
|
683
|
-
}
|
|
684
|
-
function Ie(s) {
|
|
685
|
-
const e = {};
|
|
686
|
-
for (const t in s)
|
|
687
|
-
t[0] !== "$" && (e[t] = s[t]);
|
|
688
|
-
return e;
|
|
689
|
-
}
|
|
690
|
-
function B(s, e) {
|
|
691
|
-
const t = {};
|
|
692
|
-
e = new Set(e);
|
|
693
|
-
for (const r in s)
|
|
694
|
-
!e.has(r) && r[0] !== "$" && (t[r] = s[r]);
|
|
695
|
-
return t;
|
|
696
|
-
}
|
|
697
|
-
function Ae(s, e, t) {
|
|
698
|
-
s.insertBefore(e, t || null);
|
|
699
|
-
}
|
|
700
|
-
function X(s) {
|
|
701
|
-
s.parentNode && s.parentNode.removeChild(s);
|
|
702
|
-
}
|
|
703
|
-
function Ne(s) {
|
|
704
|
-
return document.createTextNode(s);
|
|
705
|
-
}
|
|
706
|
-
function Me() {
|
|
707
|
-
return Ne("");
|
|
708
|
-
}
|
|
709
|
-
function Le(s) {
|
|
710
|
-
return Array.from(s.childNodes);
|
|
711
|
-
}
|
|
712
|
-
function J(s, e) {
|
|
713
|
-
return new s(e);
|
|
714
|
-
}
|
|
715
|
-
let N;
|
|
716
|
-
function _(s) {
|
|
717
|
-
N = s;
|
|
718
|
-
}
|
|
719
|
-
const y = [], F = [];
|
|
720
|
-
let k = [];
|
|
721
|
-
const V = [], Ue = /* @__PURE__ */ Promise.resolve();
|
|
722
|
-
let j = !1;
|
|
723
|
-
function He() {
|
|
724
|
-
j || (j = !0, Ue.then(Z));
|
|
725
|
-
}
|
|
726
|
-
function S(s) {
|
|
727
|
-
k.push(s);
|
|
728
|
-
}
|
|
729
|
-
const R = /* @__PURE__ */ new Set();
|
|
730
|
-
let m = 0;
|
|
731
|
-
function Z() {
|
|
732
|
-
if (m !== 0)
|
|
733
|
-
return;
|
|
734
|
-
const s = N;
|
|
735
|
-
do {
|
|
736
|
-
try {
|
|
737
|
-
for (; m < y.length; ) {
|
|
738
|
-
const e = y[m];
|
|
739
|
-
m++, _(e), qe(e.$$);
|
|
740
|
-
}
|
|
741
|
-
} catch (e) {
|
|
742
|
-
throw y.length = 0, m = 0, e;
|
|
743
|
-
}
|
|
744
|
-
for (_(null), y.length = 0, m = 0; F.length; )
|
|
745
|
-
F.pop()();
|
|
746
|
-
for (let e = 0; e < k.length; e += 1) {
|
|
747
|
-
const t = k[e];
|
|
748
|
-
R.has(t) || (R.add(t), t());
|
|
749
|
-
}
|
|
750
|
-
k.length = 0;
|
|
751
|
-
} while (y.length);
|
|
752
|
-
for (; V.length; )
|
|
753
|
-
V.pop()();
|
|
754
|
-
j = !1, R.clear(), _(s);
|
|
755
|
-
}
|
|
756
|
-
function qe(s) {
|
|
757
|
-
if (s.fragment !== null) {
|
|
758
|
-
s.update(), b(s.before_update);
|
|
759
|
-
const e = s.dirty;
|
|
760
|
-
s.dirty = [-1], s.fragment && s.fragment.p(s.ctx, e), s.after_update.forEach(S);
|
|
761
|
-
}
|
|
762
|
-
}
|
|
763
|
-
function De(s) {
|
|
764
|
-
const e = [], t = [];
|
|
765
|
-
k.forEach((r) => s.indexOf(r) === -1 ? e.push(r) : t.push(r)), t.forEach((r) => r()), k = e;
|
|
766
|
-
}
|
|
767
|
-
const w = /* @__PURE__ */ new Set();
|
|
768
|
-
let f;
|
|
769
|
-
function Be() {
|
|
770
|
-
f = {
|
|
771
|
-
r: 0,
|
|
772
|
-
c: [],
|
|
773
|
-
p: f
|
|
774
|
-
// parent group
|
|
775
|
-
};
|
|
776
|
-
}
|
|
777
|
-
function Je() {
|
|
778
|
-
f.r || b(f.c), f = f.p;
|
|
779
|
-
}
|
|
780
|
-
function O(s, e) {
|
|
781
|
-
s && s.i && (w.delete(s), s.i(e));
|
|
782
|
-
}
|
|
783
|
-
function Y(s, e, t, r) {
|
|
784
|
-
if (s && s.o) {
|
|
785
|
-
if (w.has(s))
|
|
786
|
-
return;
|
|
787
|
-
w.add(s), f.c.push(() => {
|
|
788
|
-
w.delete(s), r && (t && s.d(1), r());
|
|
789
|
-
}), s.o(e);
|
|
790
|
-
} else
|
|
791
|
-
r && r();
|
|
792
|
-
}
|
|
793
|
-
function Fe(s, e) {
|
|
794
|
-
const t = {}, r = {}, n = { $$scope: 1 };
|
|
795
|
-
let o = s.length;
|
|
796
|
-
for (; o--; ) {
|
|
797
|
-
const i = s[o], a = e[o];
|
|
798
|
-
if (a) {
|
|
799
|
-
for (const c in i)
|
|
800
|
-
c in a || (r[c] = 1);
|
|
801
|
-
for (const c in a)
|
|
802
|
-
n[c] || (t[c] = a[c], n[c] = 1);
|
|
803
|
-
s[o] = a;
|
|
804
|
-
} else
|
|
805
|
-
for (const c in i)
|
|
806
|
-
n[c] = 1;
|
|
807
|
-
}
|
|
808
|
-
for (const i in r)
|
|
809
|
-
i in t || (t[i] = void 0);
|
|
810
|
-
return t;
|
|
811
|
-
}
|
|
812
|
-
function Ve(s) {
|
|
813
|
-
return typeof s == "object" && s !== null ? s : {};
|
|
814
|
-
}
|
|
815
|
-
function z(s) {
|
|
816
|
-
s && s.c();
|
|
817
|
-
}
|
|
818
|
-
function C(s, e, t, r) {
|
|
819
|
-
const { fragment: n, after_update: o } = s.$$;
|
|
820
|
-
n && n.m(e, t), r || S(() => {
|
|
821
|
-
const i = s.$$.on_mount.map(Q).filter(W);
|
|
822
|
-
s.$$.on_destroy ? s.$$.on_destroy.push(...i) : b(i), s.$$.on_mount = [];
|
|
823
|
-
}), o.forEach(S);
|
|
824
|
-
}
|
|
825
|
-
function I(s, e) {
|
|
826
|
-
const t = s.$$;
|
|
827
|
-
t.fragment !== null && (De(t.after_update), b(t.on_destroy), t.fragment && t.fragment.d(e), t.on_destroy = t.fragment = null, t.ctx = []);
|
|
828
|
-
}
|
|
829
|
-
function Ye(s, e) {
|
|
830
|
-
s.$$.dirty[0] === -1 && (y.push(s), He(), s.$$.dirty.fill(0)), s.$$.dirty[e / 31 | 0] |= 1 << e % 31;
|
|
831
|
-
}
|
|
832
|
-
function ze(s, e, t, r, n, o, i, a = [-1]) {
|
|
833
|
-
const c = N;
|
|
834
|
-
_(s);
|
|
835
|
-
const l = s.$$ = {
|
|
836
|
-
fragment: null,
|
|
837
|
-
ctx: [],
|
|
838
|
-
// state
|
|
839
|
-
props: o,
|
|
840
|
-
update: P,
|
|
841
|
-
not_equal: n,
|
|
842
|
-
bound: D(),
|
|
843
|
-
// lifecycle
|
|
844
|
-
on_mount: [],
|
|
845
|
-
on_destroy: [],
|
|
846
|
-
on_disconnect: [],
|
|
847
|
-
before_update: [],
|
|
848
|
-
after_update: [],
|
|
849
|
-
context: new Map(e.context || (c ? c.$$.context : [])),
|
|
850
|
-
// everything else
|
|
851
|
-
callbacks: D(),
|
|
852
|
-
dirty: a,
|
|
853
|
-
skip_bound: !1,
|
|
854
|
-
root: e.target || c.$$.root
|
|
855
|
-
};
|
|
856
|
-
i && i(l.root);
|
|
857
|
-
let u = !1;
|
|
858
|
-
if (l.ctx = t ? t(s, e.props || {}, (d, p, ...M) => {
|
|
859
|
-
const L = M.length ? M[0] : p;
|
|
860
|
-
return l.ctx && n(l.ctx[d], l.ctx[d] = L) && (!l.skip_bound && l.bound[d] && l.bound[d](L), u && Ye(s, d)), p;
|
|
861
|
-
}) : [], l.update(), u = !0, b(l.before_update), l.fragment = r ? r(l.ctx) : !1, e.target) {
|
|
862
|
-
if (e.hydrate) {
|
|
863
|
-
const d = Le(e.target);
|
|
864
|
-
l.fragment && l.fragment.l(d), d.forEach(X);
|
|
865
|
-
} else
|
|
866
|
-
l.fragment && l.fragment.c();
|
|
867
|
-
e.intro && O(s.$$.fragment), C(s, e.target, e.anchor, e.customElement), Z();
|
|
868
|
-
}
|
|
869
|
-
_(c);
|
|
870
|
-
}
|
|
871
|
-
class Ke {
|
|
872
|
-
$destroy() {
|
|
873
|
-
I(this, 1), this.$destroy = P;
|
|
874
|
-
}
|
|
875
|
-
$on(e, t) {
|
|
876
|
-
if (!W(t))
|
|
877
|
-
return P;
|
|
878
|
-
const r = this.$$.callbacks[e] || (this.$$.callbacks[e] = []);
|
|
879
|
-
return r.push(t), () => {
|
|
880
|
-
const n = r.indexOf(t);
|
|
881
|
-
n !== -1 && r.splice(n, 1);
|
|
882
|
-
};
|
|
883
|
-
}
|
|
884
|
-
$set(e) {
|
|
885
|
-
this.$$set && !Ce(e) && (this.$$.skip_bound = !0, this.$$set(e), this.$$.skip_bound = !1);
|
|
886
|
-
}
|
|
887
|
-
}
|
|
888
|
-
function Ge(s) {
|
|
889
|
-
let e, t, r;
|
|
890
|
-
const n = [
|
|
891
|
-
{ blok: (
|
|
892
|
-
/*blok*/
|
|
893
|
-
s[0]
|
|
894
|
-
) },
|
|
895
|
-
/*$$restProps*/
|
|
896
|
-
s[2]
|
|
897
|
-
];
|
|
898
|
-
var o = (
|
|
899
|
-
/*component*/
|
|
900
|
-
s[1]
|
|
901
|
-
);
|
|
902
|
-
function i(a) {
|
|
903
|
-
let c = {};
|
|
904
|
-
for (let l = 0; l < n.length; l += 1)
|
|
905
|
-
c = E(c, n[l]);
|
|
906
|
-
return { props: c };
|
|
907
|
-
}
|
|
908
|
-
return o && (e = J(o, i())), {
|
|
909
|
-
c() {
|
|
910
|
-
e && z(e.$$.fragment), t = Me();
|
|
911
|
-
},
|
|
912
|
-
m(a, c) {
|
|
913
|
-
e && C(e, a, c), Ae(a, t, c), r = !0;
|
|
914
|
-
},
|
|
915
|
-
p(a, [c]) {
|
|
916
|
-
const l = c & /*blok, $$restProps*/
|
|
917
|
-
5 ? Fe(n, [
|
|
918
|
-
c & /*blok*/
|
|
919
|
-
1 && { blok: (
|
|
920
|
-
/*blok*/
|
|
921
|
-
a[0]
|
|
922
|
-
) },
|
|
923
|
-
c & /*$$restProps*/
|
|
924
|
-
4 && Ve(
|
|
925
|
-
/*$$restProps*/
|
|
926
|
-
a[2]
|
|
927
|
-
)
|
|
928
|
-
]) : {};
|
|
929
|
-
if (c & /*component*/
|
|
930
|
-
2 && o !== (o = /*component*/
|
|
931
|
-
a[1])) {
|
|
932
|
-
if (e) {
|
|
933
|
-
Be();
|
|
934
|
-
const u = e;
|
|
935
|
-
Y(u.$$.fragment, 1, 0, () => {
|
|
936
|
-
I(u, 1);
|
|
937
|
-
}), Je();
|
|
938
|
-
}
|
|
939
|
-
o ? (e = J(o, i()), z(e.$$.fragment), O(e.$$.fragment, 1), C(e, t.parentNode, t)) : e = null;
|
|
940
|
-
} else
|
|
941
|
-
o && e.$set(l);
|
|
942
|
-
},
|
|
943
|
-
i(a) {
|
|
944
|
-
r || (e && O(e.$$.fragment, a), r = !0);
|
|
945
|
-
},
|
|
946
|
-
o(a) {
|
|
947
|
-
e && Y(e.$$.fragment, a), r = !1;
|
|
948
|
-
},
|
|
949
|
-
d(a) {
|
|
950
|
-
a && X(t), e && I(e, a);
|
|
951
|
-
}
|
|
952
|
-
};
|
|
953
|
-
}
|
|
954
|
-
function Qe(s, e, t) {
|
|
955
|
-
const r = ["blok"];
|
|
956
|
-
let n = B(e, r), o, { blok: i } = e;
|
|
957
|
-
return i ? o = We(i.component) : console.error("Please provide a 'blok' property to the StoryblokComponent"), s.$$set = (a) => {
|
|
958
|
-
e = E(E({}, e), Ie(a)), t(2, n = B(e, r)), "blok" in a && t(0, i = a.blok);
|
|
959
|
-
}, [i, o, n];
|
|
960
|
-
}
|
|
961
|
-
class tt extends Ke {
|
|
962
|
-
constructor(e) {
|
|
963
|
-
super(), ze(this, e, Qe, Ge, Oe, { blok: 0 });
|
|
964
|
-
}
|
|
965
|
-
}
|
|
966
|
-
const st = (s, e) => {
|
|
967
|
-
const t = (r) => {
|
|
968
|
-
const n = Ee(r);
|
|
969
|
-
n["data-blok-c"] && (s.setAttribute("data-blok-c", n["data-blok-c"]), s.setAttribute("data-blok-uid", n["data-blok-uid"]), s.classList.add("storyblok__outline"));
|
|
970
|
-
};
|
|
971
|
-
return t(e), {
|
|
972
|
-
update(r) {
|
|
973
|
-
t(r);
|
|
974
|
-
}
|
|
975
|
-
};
|
|
976
|
-
};
|
|
977
|
-
let A = null;
|
|
978
|
-
const rt = () => (A || console.log(
|
|
979
|
-
"You can't use getStoryblokApi if you're not loading apiPlugin."
|
|
980
|
-
), A);
|
|
981
|
-
let $ = null;
|
|
982
|
-
const nt = (s) => {
|
|
983
|
-
const { storyblokApi: e } = Se(s);
|
|
984
|
-
A = e, $ = s.components || {};
|
|
985
|
-
}, We = (s) => {
|
|
986
|
-
let e = null;
|
|
987
|
-
return e = typeof $ == "function" ? $()[s] : $[s], e || console.error(`You didn't load the ${s} component. Please load it in storyblokInit. For example:
|
|
988
|
-
storyblokInit({
|
|
989
|
-
accessToken: "<your-token>",
|
|
990
|
-
components: {
|
|
991
|
-
"teaser": Teaser
|
|
992
|
-
}
|
|
993
|
-
})
|
|
994
|
-
`), e;
|
|
995
|
-
};
|
|
996
|
-
export {
|
|
997
|
-
Te as RichTextSchema,
|
|
998
|
-
tt as StoryblokComponent,
|
|
999
|
-
Xe as apiPlugin,
|
|
1000
|
-
We as getComponent,
|
|
1001
|
-
rt as getStoryblokApi,
|
|
1002
|
-
et as renderRichText,
|
|
1003
|
-
st as storyblokEditable,
|
|
1004
|
-
nt as storyblokInit,
|
|
1005
|
-
rt as useStoryblokApi,
|
|
1006
|
-
Ze as useStoryblokBridge
|
|
1007
|
-
};
|
package/dist/vite.config.d.ts
DELETED
package/index.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
storyblokEditable as sbEdit,
|
|
3
|
-
storyblokInit as sbInit,
|
|
4
|
-
} from "@storyblok/js";
|
|
5
|
-
export {
|
|
6
|
-
useStoryblokBridge,
|
|
7
|
-
apiPlugin,
|
|
8
|
-
renderRichText,
|
|
9
|
-
RichTextSchema,
|
|
10
|
-
} from "@storyblok/js";
|
|
11
|
-
|
|
12
|
-
import type {
|
|
13
|
-
SbSvelteSDKOptions,
|
|
14
|
-
SbSvelteComponentsMap,
|
|
15
|
-
StoryblokClient,
|
|
16
|
-
SbBlokData,
|
|
17
|
-
} from "./types";
|
|
18
|
-
|
|
19
|
-
export const storyblokEditable = (node: HTMLElement, value: SbBlokData) => {
|
|
20
|
-
const updateDom = (value: SbBlokData) => {
|
|
21
|
-
const options = sbEdit(value);
|
|
22
|
-
if (options["data-blok-c"]) {
|
|
23
|
-
node.setAttribute("data-blok-c", options["data-blok-c"]);
|
|
24
|
-
node.setAttribute("data-blok-uid", options["data-blok-uid"]);
|
|
25
|
-
node.classList.add("storyblok__outline");
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
updateDom(value); // when is mounted
|
|
30
|
-
|
|
31
|
-
return {
|
|
32
|
-
update(newValue: SbBlokData) {
|
|
33
|
-
// when value changes
|
|
34
|
-
updateDom(newValue);
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
let storyblokApiInstance: StoryblokClient = null;
|
|
40
|
-
export const useStoryblokApi = (): StoryblokClient => {
|
|
41
|
-
if (!storyblokApiInstance) {
|
|
42
|
-
console.log(
|
|
43
|
-
`You can't use getStoryblokApi if you're not loading apiPlugin.`
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
return storyblokApiInstance;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export { useStoryblokApi as getStoryblokApi };
|
|
50
|
-
|
|
51
|
-
let componentsMap: SbSvelteComponentsMap | CallableFunction = null;
|
|
52
|
-
|
|
53
|
-
export const storyblokInit = (options: SbSvelteSDKOptions) => {
|
|
54
|
-
const { storyblokApi } = sbInit(options);
|
|
55
|
-
storyblokApiInstance = storyblokApi;
|
|
56
|
-
componentsMap = options.components || {};
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export const getComponent = (componentName: string) => {
|
|
60
|
-
let component = null;
|
|
61
|
-
component =
|
|
62
|
-
typeof componentsMap === "function"
|
|
63
|
-
? componentsMap()[componentName]
|
|
64
|
-
: componentsMap[componentName];
|
|
65
|
-
|
|
66
|
-
if (!component) {
|
|
67
|
-
console.error(`You didn't load the ${componentName} component. Please load it in storyblokInit. For example:
|
|
68
|
-
storyblokInit({
|
|
69
|
-
accessToken: "<your-token>",
|
|
70
|
-
components: {
|
|
71
|
-
"teaser": Teaser
|
|
72
|
-
}
|
|
73
|
-
})
|
|
74
|
-
`);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return component;
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
export * from "./types";
|
|
81
|
-
export { default as StoryblokComponent } from "./StoryblokComponent.svelte";
|
package/types.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { SbSDKOptions } from "@storyblok/js";
|
|
2
|
-
import type { SvelteComponent } from "svelte";
|
|
3
|
-
|
|
4
|
-
export interface SbSvelteComponentsMap {
|
|
5
|
-
[name: string]: typeof SvelteComponent;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface SbSvelteSDKOptions extends SbSDKOptions {
|
|
9
|
-
components?: SbSvelteComponentsMap | CallableFunction;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export { apiPlugin } from "@storyblok/js";
|
|
13
|
-
|
|
14
|
-
export type {
|
|
15
|
-
ISbAlternateObject,
|
|
16
|
-
ISbRichtext,
|
|
17
|
-
RichTextResolver,
|
|
18
|
-
SbBlokData,
|
|
19
|
-
SbBlokKeyDataTypes,
|
|
20
|
-
SbSDKOptions,
|
|
21
|
-
ISbStories,
|
|
22
|
-
ISbStoriesParams,
|
|
23
|
-
ISbStory,
|
|
24
|
-
ISbStoryData,
|
|
25
|
-
ISbStoryParams,
|
|
26
|
-
StoryblokBridgeConfigV2,
|
|
27
|
-
StoryblokBridgeV2,
|
|
28
|
-
ISbCache,
|
|
29
|
-
StoryblokClient,
|
|
30
|
-
StoryblokComponentType,
|
|
31
|
-
ISbConfig,
|
|
32
|
-
ISbManagmentApiResult,
|
|
33
|
-
ISbResult,
|
|
34
|
-
useStoryblokBridge,
|
|
35
|
-
} from "@storyblok/js";
|