@storyblok/astro 3.1.0-next.2 → 4.0.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/README.md +2 -0
- package/components/FallbackComponent.astro +2 -2
- package/components/StoryblokComponent.astro +3 -3
- package/dist/storyblok-astro.js +7 -7
- package/dist/storyblok-astro.mjs +17 -9
- package/dist/types/cypress/e2e/index.cy.d.ts +0 -0
- package/dist/types/cypress/plugins/index.d.ts +2 -0
- package/dist/types/cypress/support/commands.d.ts +0 -0
- package/dist/types/cypress/support/e2e.d.ts +1 -0
- package/dist/types/cypress.config.d.ts +2 -0
- package/dist/types/node_modules/camelcase/index.d.ts +102 -0
- package/package.json +9 -9
- package/toolbar-app-storyblok.ts +2 -2
package/README.md
CHANGED
|
@@ -89,6 +89,8 @@ Possible values:
|
|
|
89
89
|
|
|
90
90
|
- `eu` (default): For spaces created in the EU
|
|
91
91
|
- `us`: For spaces created in the US
|
|
92
|
+
- `ca`: For spaces created in Canada
|
|
93
|
+
- `ap`: For spaces created in Australia
|
|
92
94
|
- `cn`: For spaces created in China
|
|
93
95
|
|
|
94
96
|
Full example for a space created in the US:
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import components from "virtual:storyblok-components";
|
|
3
3
|
import options from "virtual:storyblok-options";
|
|
4
4
|
import camelcase from "camelcase";
|
|
5
|
-
import type { SbBlokData } from "
|
|
6
|
-
import type { AstroComponentFactory } from "astro/
|
|
5
|
+
import type { SbBlokData } from "../dist/types";
|
|
6
|
+
import type { AstroComponentFactory } from "astro/runtime/server/index.js";
|
|
7
7
|
|
|
8
|
-
interface Props {
|
|
8
|
+
export interface Props {
|
|
9
9
|
blok: SbBlokData;
|
|
10
10
|
[prop: string]: unknown;
|
|
11
11
|
}
|
package/dist/storyblok-astro.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(g,b){typeof exports=="object"&&typeof module<"u"?b(exports):typeof define=="function"&&define.amd?define(["exports"],b):(g=typeof globalThis<"u"?globalThis:g||self,b(g.storyblokAstro={}))})(this,function(g){"use strict";function b(r,t,e){const o="virtual:storyblok-init",s="\0"+o;return{name:"vite-plugin-storyblok-init",async resolveId(
|
|
1
|
+
(function(g,b){typeof exports=="object"&&typeof module<"u"?b(exports):typeof define=="function"&&define.amd?define(["exports"],b):(g=typeof globalThis<"u"?globalThis:g||self,b(g.storyblokAstro={}))})(this,function(g){"use strict";function b(r,t,e){const o="virtual:storyblok-init",s="\0"+o;return{name:"vite-plugin-storyblok-init",async resolveId(a){if(a===o)return s},async load(a){if(a===s)return`
|
|
2
2
|
import { storyblokInit, apiPlugin } from "@storyblok/js";
|
|
3
3
|
const { storyblokApi } = storyblokInit({
|
|
4
4
|
accessToken: "${r}",
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
apiOptions: ${JSON.stringify(e)},
|
|
7
7
|
});
|
|
8
8
|
export const storyblokApiInstance = storyblokApi;
|
|
9
|
-
`}}}const R=/[\p{Lu}]/u,x=/[\p{Ll}]/u,$=/^[\p{Lu}](?![\p{Lu}])/gu,v=/([\p{Alpha}\p{N}_]|$)/u,m=/[_.\- ]+/,O=new RegExp("^"+m.source),I=new RegExp(m.source+v.source,"gu"),w=new RegExp("\\d+"+v.source,"gu"),M=(r,t,e,o)=>{let s=!1,
|
|
9
|
+
`}}}const R=/[\p{Lu}]/u,x=/[\p{Ll}]/u,$=/^[\p{Lu}](?![\p{Lu}])/gu,v=/([\p{Alpha}\p{N}_]|$)/u,m=/[_.\- ]+/,O=new RegExp("^"+m.source),I=new RegExp(m.source+v.source,"gu"),w=new RegExp("\\d+"+v.source,"gu"),M=(r,t,e,o)=>{let s=!1,a=!1,n=!1,c=!1;for(let i=0;i<r.length;i++){const l=r[i];c=i>2?r[i-3]==="-":!0,s&&R.test(l)?(r=r.slice(0,i)+"-"+r.slice(i),s=!1,n=a,a=!0,i++):a&&n&&x.test(l)&&(!c||o)?(r=r.slice(0,i-1)+"-"+r.slice(i-1),n=a,a=!1,s=!0):(s=t(l)===l&&e(l)!==l,n=a,a=e(l)===l&&t(l)!==l)}return r},N=(r,t)=>($.lastIndex=0,r.replaceAll($,e=>t(e))),P=(r,t)=>(I.lastIndex=0,w.lastIndex=0,r.replaceAll(w,(e,o,s)=>["_","-"].includes(r.charAt(s+e.length))?e:t(e)).replaceAll(I,(e,o)=>t(o)));function A(r,t){if(!(typeof r=="string"||Array.isArray(r)))throw new TypeError("Expected the input to be `string | string[]`");if(t={pascalCase:!1,preserveConsecutiveUppercase:!1,...t},Array.isArray(r)?r=r.map(a=>a.trim()).filter(a=>a.length).join("-"):r=r.trim(),r.length===0)return"";const e=t.locale===!1?a=>a.toLowerCase():a=>a.toLocaleLowerCase(t.locale),o=t.locale===!1?a=>a.toUpperCase():a=>a.toLocaleUpperCase(t.locale);return r.length===1?m.test(r)?"":t.pascalCase?o(r):e(r):(r!==e(r)&&(r=M(r,e,o,t.preserveConsecutiveUppercase)),r=r.replace(O,""),r=t.preserveConsecutiveUppercase?N(r,e):e(r),t.pascalCase&&(r=o(r.charAt(0))+r.slice(1)),P(r,o))}function L(r,t,e,o){const s="virtual:storyblok-components",a="\0"+s;return{name:"vite-plugin-storyblok-components",async resolveId(n){if(n===s)return a},async load(n){if(n===a){const c=[],i=[];for await(const[u,d]of Object.entries(t)){const h=await this.resolve("/"+r+"/"+d+".astro");if(h)c.push(`import ${A(u)} from "${h.id}"`);else if(e)i.push(u);else throw new Error(`Component could not be found for blok "${u}"! Does "${"/"+r+"/"+d}.astro" exist?`)}let l="";if(e)if(l=",FallbackComponent",o){const u=await this.resolve("/"+r+"/"+o+".astro");if(!u)throw new Error(`Custom fallback component could not be found. Does "${"/"+r+"/"+o}.astro" exist?`);c.push(`import FallbackComponent from "${u.id}"`)}else c.push("import FallbackComponent from '@storyblok/astro/FallbackComponent.astro'");if(Object.values(t).length)return`${c.join(";")};export default {${Object.keys(t).filter(u=>!i.includes(u)).map(u=>A(u)).join(",")}${l}}`;if(e)return`${c[0]}; export default {${l.replace(",","")}}`;throw new Error(`Currently, no Storyblok components are registered in astro.config.mjs.
|
|
10
10
|
Please register your components or enable the fallback component.
|
|
11
|
-
Detailed information can be found here: https://github.com/storyblok/storyblok-astro`)}}}}function _(r){const t="virtual:storyblok-options",e="\0"+t;return{name:"vite-plugin-storyblok-options",async resolveId(o){if(o===t)return e},async load(o){if(o===e)return`export default ${JSON.stringify(r)}`}}}let
|
|
11
|
+
Detailed information can be found here: https://github.com/storyblok/storyblok-astro`)}}}}function _(r){const t="virtual:storyblok-options",e="\0"+t;return{name:"vite-plugin-storyblok-options",async resolveId(o){if(o===t)return e},async load(o){if(o===e)return`export default ${JSON.stringify(r)}`}}}let T=!1;const C=[],z=r=>new Promise((t,e)=>{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}T?s():C.push(s)},document.getElementById("storyblok-javascript-bridge")))return;const o=document.createElement("script");o.async=!0,o.src=r,o.id="storyblok-javascript-bridge",o.onerror=s=>e(s),o.onload=s=>{C.forEach(a=>a()),T=!0,t(s)},document.getElementsByTagName("head")[0].appendChild(o)});var U=Object.defineProperty,D=(r,t,e)=>t in r?U(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,p=(r,t,e)=>(D(r,typeof t!="symbol"?t+"":t,e),e);class B{constructor(){p(this,"isCDNUrl",(t="")=>t.indexOf("/cdn/")>-1),p(this,"getOptionsPage",(t,e=25,o=1)=>({...t,per_page:e,page:o})),p(this,"delay",t=>new Promise(e=>setTimeout(e,t))),p(this,"arrayFrom",(t=0,e)=>[...Array(t)].map(e)),p(this,"range",(t=0,e=t)=>{const o=Math.abs(e-t)||0,s=t<e?1:-1;return this.arrayFrom(o,(a,n)=>n*s+t)}),p(this,"asyncMap",async(t,e)=>Promise.all(t.map(e))),p(this,"flatMap",(t=[],e)=>t.map(e).reduce((o,s)=>[...o,...s],[])),p(this,"escapeHTML",function(t){const e={"&":"&","<":"<",">":">",'"':""","'":"'"},o=/[&<>"']/g,s=RegExp(o.source);return t&&s.test(t)?t.replace(o,a=>e[a]):t})}stringify(t,e,o){const s=[];for(const a in t){if(!Object.prototype.hasOwnProperty.call(t,a))continue;const n=t[a],c=o?"":encodeURIComponent(a);let i;typeof n=="object"?i=this.stringify(n,e?e+encodeURIComponent("["+c+"]"):c,Array.isArray(n)):i=(e?e+encodeURIComponent("["+c+"]"):c)+"="+encodeURIComponent(n),s.push(i)}return s.join("&")}getRegionURL(t){const e="api.storyblok.com",o="api-us.storyblok.com",s="app.storyblokchina.cn",a="api-ap.storyblok.com",n="api-ca.storyblok.com";switch(t){case"us":return o;case"cn":return s;case"ap":return a;case"ca":return n;default:return e}}}const q=function(r,t){const e={};for(const o in r){const s=r[o];t.indexOf(o)>-1&&s!==null&&(e[o]=s)}return e},F=r=>r==="email",J=()=>({singleTag:"hr"}),K=()=>({tag:"blockquote"}),V=()=>({tag:"ul"}),H=r=>({tag:["pre",{tag:"code",attrs:r.attrs}]}),G=()=>({singleTag:"br"}),W=r=>({tag:`h${r.attrs.level}`}),Y=r=>({singleTag:[{tag:"img",attrs:q(r.attrs,["src","alt","title"])}]}),Q=()=>({tag:"li"}),X=()=>({tag:"ol"}),Z=()=>({tag:"p"}),ee=r=>({tag:[{tag:"span",attrs:{"data-type":"emoji","data-name":r.attrs.name,emoji:r.attrs.emoji}}]}),te=()=>({tag:"b"}),re=()=>({tag:"s"}),oe=()=>({tag:"u"}),se=()=>({tag:"strong"}),ae=()=>({tag:"code"}),ne=()=>({tag:"i"}),ie=r=>{if(!r.attrs)return{tag:""};const t=new B().escapeHTML,e={...r.attrs},{linktype:o="url"}=r.attrs;if(delete e.linktype,e.href&&(e.href=t(r.attrs.href||"")),F(o)&&(e.href=`mailto:${e.href}`),e.anchor&&(e.href=`${e.href}#${e.anchor}`,delete e.anchor),e.custom){for(const s in e.custom)e[s]=e.custom[s];delete e.custom}return{tag:[{tag:"a",attrs:e}]}},le=r=>({tag:[{tag:"span",attrs:r.attrs}]}),ce=()=>({tag:"sub"}),ue=()=>({tag:"sup"}),ge=r=>({tag:[{tag:"span",attrs:r.attrs}]}),fe=r=>{var t;return(t=r.attrs)!=null&&t.color?{tag:[{tag:"span",attrs:{style:`background-color:${r.attrs.color};`}}]}:{tag:""}},pe=r=>{var t;return(t=r.attrs)!=null&&t.color?{tag:[{tag:"span",attrs:{style:`color:${r.attrs.color}`}}]}:{tag:""}},E={nodes:{horizontal_rule:J,blockquote:K,bullet_list:V,code_block:H,hard_break:G,heading:W,image:Y,list_item:Q,ordered_list:X,paragraph:Z,emoji:ee},marks:{bold:te,strike:re,underline:oe,strong:se,code:ae,italic:ne,link:ie,styled:le,subscript:ce,superscript:ue,anchor:ge,highlight:fe,textStyle:pe}},de=function(r){const t={"&":"&","<":"<",">":">",'"':""","'":"'"},e=/[&<>"']/g,o=RegExp(e.source);return r&&o.test(r)?r.replace(e,s=>t[s]):r};class S{constructor(t){p(this,"marks"),p(this,"nodes"),t||(t=E),this.marks=t.marks||[],this.nodes=t.nodes||[]}addNode(t,e){this.nodes[t]=e}addMark(t,e){this.marks[t]=e}render(t,e={optimizeImages:!1}){if(t&&t.content&&Array.isArray(t.content)){let o="";return t.content.forEach(s=>{o+=this.renderNode(s)}),e.optimizeImages?this.optimizeImages(o,e.optimizeImages):o}return console.warn(`The render method must receive an Object with a "content" field.
|
|
12
12
|
The "content" field must be an array of nodes as the type ISbRichtext.
|
|
13
13
|
ISbRichtext:
|
|
14
14
|
content?: ISbRichtext[]
|
|
@@ -31,14 +31,14 @@ Detailed information can be found here: https://github.com/storyblok/storyblok-a
|
|
|
31
31
|
}
|
|
32
32
|
],
|
|
33
33
|
type: 'doc'
|
|
34
|
-
}`),""}optimizeImages(t,e){let o=0,s=0,
|
|
34
|
+
}`),""}optimizeImages(t,e){let o=0,s=0,a="",n="";typeof e!="boolean"&&(typeof e.width=="number"&&e.width>0&&(a+=`width="${e.width}" `,o=e.width),typeof e.height=="number"&&e.height>0&&(a+=`height="${e.height}" `,s=e.height),(e.loading==="lazy"||e.loading==="eager")&&(a+=`loading="${e.loading}" `),typeof e.class=="string"&&e.class.length>0&&(a+=`class="${e.class}" `),e.filters&&(typeof e.filters.blur=="number"&&e.filters.blur>=0&&e.filters.blur<=100&&(n+=`:blur(${e.filters.blur})`),typeof e.filters.brightness=="number"&&e.filters.brightness>=-100&&e.filters.brightness<=100&&(n+=`:brightness(${e.filters.brightness})`),e.filters.fill&&(e.filters.fill.match(/[0-9A-Fa-f]{6}/g)||e.filters.fill==="transparent")&&(n+=`:fill(${e.filters.fill})`),e.filters.format&&["webp","png","jpeg"].includes(e.filters.format)&&(n+=`:format(${e.filters.format})`),typeof e.filters.grayscale=="boolean"&&e.filters.grayscale&&(n+=":grayscale()"),typeof e.filters.quality=="number"&&e.filters.quality>=0&&e.filters.quality<=100&&(n+=`:quality(${e.filters.quality})`),e.filters.rotate&&[90,180,270].includes(e.filters.rotate)&&(n+=`:rotate(${e.filters.rotate})`),n.length>0&&(n="/filters"+n))),a.length>0&&(t=t.replace(/<img/g,`<img ${a.trim()}`));const c=o>0||s>0||n.length>0?`${o}x${s}${n}`:"";return t=t.replace(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g,`a.storyblok.com/f/$1/$2.$3/m/${c}`),typeof e!="boolean"&&(e.sizes||e.srcset)&&(t=t.replace(/<img.*?src=["|'](.*?)["|']/g,i=>{var l,u;const d=i.match(/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g);if(d&&d.length>0){const h={srcset:(l=e.srcset)==null?void 0:l.map(f=>{if(typeof f=="number")return`//${d}/m/${f}x0${n} ${f}w`;if(typeof f=="object"&&f.length===2){let k=0,j=0;return typeof f[0]=="number"&&(k=f[0]),typeof f[1]=="number"&&(j=f[1]),`//${d}/m/${k}x${j}${n} ${k}w`}}).join(", "),sizes:(u=e.sizes)==null?void 0:u.map(f=>f).join(", ")};let y="";return h.srcset&&(y+=`srcset="${h.srcset}" `),h.sizes&&(y+=`sizes="${h.sizes}" `),i.replace(/<img/g,`<img ${y.trim()}`)}return i})),t}renderNode(t){const e=[];t.marks&&t.marks.forEach(s=>{const a=this.getMatchingMark(s);a&&a.tag!==""&&e.push(this.renderOpeningTag(a.tag))});const o=this.getMatchingNode(t);return o&&o.tag&&e.push(this.renderOpeningTag(o.tag)),t.content?t.content.forEach(s=>{e.push(this.renderNode(s))}):t.text?e.push(de(t.text)):o&&o.singleTag?e.push(this.renderTag(o.singleTag," /")):o&&o.html?e.push(o.html):t.type==="emoji"&&e.push(this.renderEmoji(t)),o&&o.tag&&e.push(this.renderClosingTag(o.tag)),t.marks&&t.marks.slice(0).reverse().forEach(s=>{const a=this.getMatchingMark(s);a&&a.tag!==""&&e.push(this.renderClosingTag(a.tag))}),e.join("")}renderTag(t,e){return t.constructor===String?`<${t}${e}>`:t.map(o=>{if(o.constructor===String)return`<${o}${e}>`;{let s=`<${o.tag}`;if(o.attrs)for(const a in o.attrs){const n=o.attrs[a];n!==null&&(s+=` ${a}="${n}"`)}return`${s}${e}>`}}).join("")}renderOpeningTag(t){return this.renderTag(t,"")}renderClosingTag(t){return t.constructor===String?`</${t}>`:t.slice(0).reverse().map(e=>e.constructor===String?`</${e}>`:`</${e.tag}>`).join("")}getMatchingNode(t){const e=this.nodes[t.type];if(typeof e=="function")return e(t)}getMatchingMark(t){const e=this.marks[t.type];if(typeof e=="function")return e(t)}renderEmoji(t){if(t.attrs.emoji)return t.attrs.emoji;const e=[{tag:"img",attrs:{src:t.attrs.fallbackImage,draggable:"false",loading:"lazy",align:"absmiddle"}}];return this.renderTag(e," /")}}const he=r=>{if(typeof r!="object"||typeof r._editable>"u")return{};const t=JSON.parse(r._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return t?{"data-blok-c":JSON.stringify(t),"data-blok-uid":t.id+"-"+t.uid}:{}};let be,me="https://app.storyblok.com/f/storyblok-v2-latest.js";const ye=(r,t)=>{r.addNode("blok",e=>{let o="";return e.attrs.body.forEach(s=>{o+=t(s.component,s)}),{html:o}})},ke=r=>!r||!(r!=null&&r.content.some(t=>t.content||t.type==="blok"||t.type==="horizontal_rule")),$e=(r,t,e)=>{let o=e||be;if(!o){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return ke(r)?"":(t&&(o=new S(t.schema),t.resolver&&ye(o,t.resolver)),o.render(r))},ve=()=>z(me);function Ie(){return globalThis.storyblokApiInstance||console.error("storyblokApiInstance has not been initialized correctly"),globalThis.storyblokApiInstance}function we(r,t){const e=globalThis.storyblokApiInstance.richTextResolver;if(!e){console.error("Please initialize the Storyblok SDK before calling the renderRichText function");return}return $e(r,t,e)}function Ae(r){const t={useCustomApi:!1,bridge:!0,componentsDir:"src",enableFallbackComponent:!1,...r};return{name:"@storyblok/astro",hooks:{"astro:config:setup":({injectScript:e,updateConfig:o,addDevOverlayPlugin:s})=>{if(o({vite:{plugins:[b(t.accessToken,t.useCustomApi,t.apiOptions),L(t.componentsDir,t.components,t.enableFallbackComponent,t.customFallbackComponent),_(t)]}}),e("page-ssr",`
|
|
35
35
|
import { storyblokApiInstance } from "virtual:storyblok-init";
|
|
36
36
|
globalThis.storyblokApiInstance = storyblokApiInstance;
|
|
37
|
-
`),t.bridge){let
|
|
37
|
+
`),t.bridge){let a="";if(typeof t.bridge=="object"){const n={...t.bridge};a=`const storyblokInstance = new StoryblokBridge(${JSON.stringify(n)});`}else a="const storyblokInstance = new StoryblokBridge()";e("page",`
|
|
38
38
|
import { loadStoryblokBridge } from "@storyblok/astro";
|
|
39
39
|
loadStoryblokBridge().then(() => {
|
|
40
40
|
const { StoryblokBridge, location } = window;
|
|
41
|
-
${
|
|
41
|
+
${a}
|
|
42
42
|
|
|
43
43
|
storyblokInstance.on(["published", "change"], (event) => {
|
|
44
44
|
if (!event.slugChanged) {
|
|
@@ -46,4 +46,4 @@ Detailed information can be found here: https://github.com/storyblok/storyblok-a
|
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
48
|
});
|
|
49
|
-
`)}s("@storyblok/astro/toolbar-app-storyblok.ts")}}}}g.RichTextResolver=S,g.RichTextSchema=E,g.default=
|
|
49
|
+
`)}s("@storyblok/astro/toolbar-app-storyblok.ts")}}}}g.RichTextResolver=S,g.RichTextSchema=E,g.default=Ae,g.loadStoryblokBridge=ve,g.renderRichText=we,g.storyblokEditable=he,g.useStoryblokApi=Ie,Object.defineProperties(g,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/storyblok-astro.mjs
CHANGED
|
@@ -20,7 +20,7 @@ function E(r, t, e) {
|
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
const T = /[\p{Lu}]/u, x = /[\p{Ll}]/u, k = /^[\p{Lu}](?![\p{Lu}])/gu,
|
|
23
|
+
const T = /[\p{Lu}]/u, x = /[\p{Ll}]/u, k = /^[\p{Lu}](?![\p{Lu}])/gu, C = /([\p{Alpha}\p{N}_]|$)/u, m = /[_.\- ]+/, S = new RegExp("^" + m.source), $ = new RegExp(m.source + C.source, "gu"), v = new RegExp("\\d+" + C.source, "gu"), j = (r, t, e, o) => {
|
|
24
24
|
let s = !1, a = !1, n = !1, c = !1;
|
|
25
25
|
for (let l = 0; l < r.length; l++) {
|
|
26
26
|
const i = r[l];
|
|
@@ -38,7 +38,7 @@ function I(r, t) {
|
|
|
38
38
|
}, Array.isArray(r) ? r = r.map((a) => a.trim()).filter((a) => a.length).join("-") : r = r.trim(), r.length === 0)
|
|
39
39
|
return "";
|
|
40
40
|
const e = t.locale === !1 ? (a) => a.toLowerCase() : (a) => a.toLocaleLowerCase(t.locale), o = t.locale === !1 ? (a) => a.toUpperCase() : (a) => a.toLocaleUpperCase(t.locale);
|
|
41
|
-
return r.length === 1 ? m.test(r) ? "" : t.pascalCase ? o(r) : e(r) : (r !== e(r) && (r =
|
|
41
|
+
return r.length === 1 ? m.test(r) ? "" : t.pascalCase ? o(r) : e(r) : (r !== e(r) && (r = j(r, e, o, t.preserveConsecutiveUppercase)), r = r.replace(S, ""), r = t.preserveConsecutiveUppercase ? R(r, e) : e(r), t.pascalCase && (r = o(r.charAt(0)) + r.slice(1)), O(r, o));
|
|
42
42
|
}
|
|
43
43
|
function N(r, t, e, o) {
|
|
44
44
|
const s = "virtual:storyblok-components", a = "\0" + s;
|
|
@@ -109,18 +109,18 @@ function L(r) {
|
|
|
109
109
|
};
|
|
110
110
|
}
|
|
111
111
|
let w = !1;
|
|
112
|
-
const
|
|
112
|
+
const A = [], M = (r) => new Promise((t, e) => {
|
|
113
113
|
if (typeof window > "u" || (window.storyblokRegisterEvent = (s) => {
|
|
114
114
|
if (window.location === window.parent.location) {
|
|
115
115
|
console.warn("You are not in Draft Mode or in the Visual Editor.");
|
|
116
116
|
return;
|
|
117
117
|
}
|
|
118
|
-
w ? s() :
|
|
118
|
+
w ? s() : A.push(s);
|
|
119
119
|
}, document.getElementById("storyblok-javascript-bridge")))
|
|
120
120
|
return;
|
|
121
121
|
const o = document.createElement("script");
|
|
122
122
|
o.async = !0, o.src = r, o.id = "storyblok-javascript-bridge", o.onerror = (s) => e(s), o.onload = (s) => {
|
|
123
|
-
|
|
123
|
+
A.forEach((a) => a()), w = !0, t(s);
|
|
124
124
|
}, document.getElementsByTagName("head")[0].appendChild(o);
|
|
125
125
|
});
|
|
126
126
|
var P = Object.defineProperty, _ = (r, t, e) => t in r ? P(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e, p = (r, t, e) => (_(r, typeof t != "symbol" ? t + "" : t, e), e);
|
|
@@ -168,16 +168,20 @@ class z {
|
|
|
168
168
|
}
|
|
169
169
|
/**
|
|
170
170
|
* @method getRegionURL
|
|
171
|
-
* @param {String} regionCode region code, could be eu, us or
|
|
171
|
+
* @param {String} regionCode region code, could be eu, us, cn, ap or ca
|
|
172
172
|
* @return {String} The base URL of the region
|
|
173
173
|
*/
|
|
174
174
|
getRegionURL(t) {
|
|
175
|
-
const e = "api.storyblok.com", o = "api-us.storyblok.com", s = "app.storyblokchina.cn";
|
|
175
|
+
const e = "api.storyblok.com", o = "api-us.storyblok.com", s = "app.storyblokchina.cn", a = "api-ap.storyblok.com", n = "api-ca.storyblok.com";
|
|
176
176
|
switch (t) {
|
|
177
177
|
case "us":
|
|
178
178
|
return o;
|
|
179
179
|
case "cn":
|
|
180
180
|
return s;
|
|
181
|
+
case "ap":
|
|
182
|
+
return a;
|
|
183
|
+
case "ca":
|
|
184
|
+
return n;
|
|
181
185
|
default:
|
|
182
186
|
return e;
|
|
183
187
|
}
|
|
@@ -235,7 +239,7 @@ const U = function(r, t) {
|
|
|
235
239
|
}), X = () => ({
|
|
236
240
|
tag: "b"
|
|
237
241
|
}), Z = () => ({
|
|
238
|
-
tag: "
|
|
242
|
+
tag: "s"
|
|
239
243
|
}), ee = () => ({
|
|
240
244
|
tag: "u"
|
|
241
245
|
}), te = () => ({
|
|
@@ -245,8 +249,12 @@ const U = function(r, t) {
|
|
|
245
249
|
}), oe = () => ({
|
|
246
250
|
tag: "i"
|
|
247
251
|
}), se = (r) => {
|
|
252
|
+
if (!r.attrs)
|
|
253
|
+
return {
|
|
254
|
+
tag: ""
|
|
255
|
+
};
|
|
248
256
|
const t = new z().escapeHTML, e = { ...r.attrs }, { linktype: o = "url" } = r.attrs;
|
|
249
|
-
if (e.href && (e.href = t(r.attrs.href || "")), D(o) && (e.href = `mailto:${e.href}`), e.anchor && (e.href = `${e.href}#${e.anchor}`, delete e.anchor), e.custom) {
|
|
257
|
+
if (delete e.linktype, e.href && (e.href = t(r.attrs.href || "")), D(o) && (e.href = `mailto:${e.href}`), e.anchor && (e.href = `${e.href}#${e.anchor}`, delete e.anchor), e.custom) {
|
|
250
258
|
for (const s in e.custom)
|
|
251
259
|
e[s] = e.custom[s];
|
|
252
260
|
delete e.custom;
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
export type Options = {
|
|
2
|
+
/**
|
|
3
|
+
Uppercase the first character: `foo-bar` → `FooBar`.
|
|
4
|
+
|
|
5
|
+
@default false
|
|
6
|
+
*/
|
|
7
|
+
readonly pascalCase?: boolean;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
Preserve consecutive uppercase characters: `foo-BAR` → `FooBAR`.
|
|
11
|
+
|
|
12
|
+
@default false
|
|
13
|
+
*/
|
|
14
|
+
readonly preserveConsecutiveUppercase?: boolean;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
The locale parameter indicates the locale to be used to convert to upper/lower case according to any locale-specific case mappings. If multiple locales are given in an array, the best available locale is used.
|
|
18
|
+
|
|
19
|
+
Setting `locale: false` ignores the platform locale and uses the [Unicode Default Case Conversion](https://unicode-org.github.io/icu/userguide/transforms/casemappings.html#simple-single-character-case-mapping) algorithm.
|
|
20
|
+
|
|
21
|
+
Default: The host environment’s current locale.
|
|
22
|
+
|
|
23
|
+
@example
|
|
24
|
+
```
|
|
25
|
+
import camelCase from 'camelcase';
|
|
26
|
+
|
|
27
|
+
camelCase('lorem-ipsum', {locale: 'en-US'});
|
|
28
|
+
//=> 'loremIpsum'
|
|
29
|
+
|
|
30
|
+
camelCase('lorem-ipsum', {locale: 'tr-TR'});
|
|
31
|
+
//=> 'loremİpsum'
|
|
32
|
+
|
|
33
|
+
camelCase('lorem-ipsum', {locale: ['en-US', 'en-GB']});
|
|
34
|
+
//=> 'loremIpsum'
|
|
35
|
+
|
|
36
|
+
camelCase('lorem-ipsum', {locale: ['tr', 'TR', 'tr-TR']});
|
|
37
|
+
//=> 'loremİpsum'
|
|
38
|
+
```
|
|
39
|
+
*/
|
|
40
|
+
readonly locale?: false | string | readonly string[];
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
Convert a dash/dot/underscore/space separated string to camelCase or PascalCase: `foo-bar` → `fooBar`.
|
|
45
|
+
|
|
46
|
+
Correctly handles Unicode strings.
|
|
47
|
+
|
|
48
|
+
@param input - The string to convert to camel case.
|
|
49
|
+
|
|
50
|
+
@example
|
|
51
|
+
```
|
|
52
|
+
import camelCase from 'camelcase';
|
|
53
|
+
|
|
54
|
+
camelCase('foo-bar');
|
|
55
|
+
//=> 'fooBar'
|
|
56
|
+
|
|
57
|
+
camelCase('foo_bar');
|
|
58
|
+
//=> 'fooBar'
|
|
59
|
+
|
|
60
|
+
camelCase('Foo-Bar');
|
|
61
|
+
//=> 'fooBar'
|
|
62
|
+
|
|
63
|
+
camelCase('розовый_пушистый_единорог');
|
|
64
|
+
//=> 'розовыйПушистыйЕдинорог'
|
|
65
|
+
|
|
66
|
+
camelCase('Foo-Bar', {pascalCase: true});
|
|
67
|
+
//=> 'FooBar'
|
|
68
|
+
|
|
69
|
+
camelCase('--foo.bar', {pascalCase: false});
|
|
70
|
+
//=> 'fooBar'
|
|
71
|
+
|
|
72
|
+
camelCase('Foo-BAR', {preserveConsecutiveUppercase: true});
|
|
73
|
+
//=> 'fooBAR'
|
|
74
|
+
|
|
75
|
+
camelCase('fooBAR', {pascalCase: true, preserveConsecutiveUppercase: true});
|
|
76
|
+
//=> 'FooBAR'
|
|
77
|
+
|
|
78
|
+
camelCase('foo bar');
|
|
79
|
+
//=> 'fooBar'
|
|
80
|
+
|
|
81
|
+
console.log(process.argv[3]);
|
|
82
|
+
//=> '--foo-bar'
|
|
83
|
+
camelCase(process.argv[3]);
|
|
84
|
+
//=> 'fooBar'
|
|
85
|
+
|
|
86
|
+
camelCase(['foo', 'bar']);
|
|
87
|
+
//=> 'fooBar'
|
|
88
|
+
|
|
89
|
+
camelCase(['__foo__', '--bar'], {pascalCase: true});
|
|
90
|
+
//=> 'FooBar'
|
|
91
|
+
|
|
92
|
+
camelCase(['foo', 'BAR'], {pascalCase: true, preserveConsecutiveUppercase: true})
|
|
93
|
+
//=> 'FooBAR'
|
|
94
|
+
|
|
95
|
+
camelCase('lorem-ipsum', {locale: 'en-US'});
|
|
96
|
+
//=> 'loremIpsum'
|
|
97
|
+
```
|
|
98
|
+
*/
|
|
99
|
+
export default function camelcase(
|
|
100
|
+
input: string | readonly string[],
|
|
101
|
+
options?: Options
|
|
102
|
+
): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storyblok/astro",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Official Astro integration for the Storyblok Headless CMS",
|
|
5
5
|
"main": "./dist/storyblok-astro.js",
|
|
6
6
|
"module": "./dist/storyblok-astro.mjs",
|
|
@@ -49,23 +49,23 @@
|
|
|
49
49
|
"prepublishOnly": "npm run build && cp ../README.md ./"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@storyblok/js": "^
|
|
52
|
+
"@storyblok/js": "^3.0.0",
|
|
53
53
|
"camelcase": "^8.0.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@cypress/vite-dev-server": "^5.0.6",
|
|
57
57
|
"@rollup/plugin-dynamic-import-vars": "^2.1.2",
|
|
58
|
-
"@types/node": "20.10.
|
|
59
|
-
"astro": "^4.0.
|
|
60
|
-
"cypress": "^13.6.
|
|
61
|
-
"eslint-plugin-cypress": "^2.
|
|
58
|
+
"@types/node": "20.10.4",
|
|
59
|
+
"astro": "^4.0.4",
|
|
60
|
+
"cypress": "^13.6.1",
|
|
61
|
+
"eslint-plugin-cypress": "^2.15.1",
|
|
62
62
|
"start-server-and-test": "^2.0.3",
|
|
63
|
-
"typescript": "5.3.
|
|
64
|
-
"vite": "^5.0.
|
|
63
|
+
"typescript": "5.3.3",
|
|
64
|
+
"vite": "^5.0.8",
|
|
65
65
|
"vite-plugin-dts": "^3.6.4"
|
|
66
66
|
},
|
|
67
67
|
"peerDependencies": {
|
|
68
|
-
"astro": "^4.0.0
|
|
68
|
+
"astro": "^3.0.0 || ^4.0.0"
|
|
69
69
|
},
|
|
70
70
|
"repository": {
|
|
71
71
|
"type": "git",
|
package/toolbar-app-storyblok.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DevToolbarApp, DevOverlayMetadata } from "astro";
|
|
2
2
|
import {
|
|
3
3
|
isDefinedIcon,
|
|
4
4
|
type Icon,
|
|
@@ -182,4 +182,4 @@ export default {
|
|
|
182
182
|
canvas.append(windowComponent);
|
|
183
183
|
}
|
|
184
184
|
},
|
|
185
|
-
} satisfies
|
|
185
|
+
} satisfies DevToolbarApp;
|