@storyblok/astro 4.0.5 → 4.1.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/storyblok-astro.js +15 -17
- package/dist/storyblok-astro.mjs +948 -336
- package/dist/types/components/FallbackComponent.d.ts +1 -2
- package/dist/types/components/RichTextRenderer.d.ts +1 -2
- package/dist/types/components/StoryblokComponent.d.ts +1 -2
- package/dist/types/index.d.ts +8 -5
- package/dist/types/live-preview/handleStoryblokMessage.d.ts +1 -0
- package/dist/types/live-preview/middleware.d.ts +1 -0
- package/dist/types/types.d.ts +1 -1
- package/dist/types/utils/generateFinalBridgeObject.d.ts +3 -0
- package/dist/types/utils/parseAstCode.d.ts +1 -0
- package/dist/types/vite-plugins/vite-plugin-storyblok-bridge.d.ts +2 -0
- package/dist/types/vite-plugins/vite-plugin-storyblok-components.d.ts +1 -2
- package/dist/types/vite-plugins/vite-plugin-storyblok-init.d.ts +2 -3
- package/dist/types/vite-plugins/vite-plugin-storyblok-options.d.ts +1 -2
- package/live-preview/handleStoryblokMessage.ts +94 -0
- package/live-preview/middleware.ts +11 -0
- package/package.json +13 -4
- package/utils/generateFinalBridgeObject.ts +32 -0
- package/utils/parseAstCode.ts +41 -0
- package/vite-plugins/vite-plugin-storyblok-bridge.ts +69 -0
- package/vite-plugins/vite-plugin-storyblok-components.ts +124 -0
- package/vite-plugins/vite-plugin-storyblok-init.ts +33 -0
- package/vite-plugins/vite-plugin-storyblok-options.ts +20 -0
package/dist/storyblok-astro.mjs
CHANGED
|
@@ -1,90 +1,90 @@
|
|
|
1
|
-
function
|
|
2
|
-
const
|
|
1
|
+
function Sr(o, e, r) {
|
|
2
|
+
const s = "virtual:storyblok-init", i = "\0" + s;
|
|
3
3
|
return {
|
|
4
4
|
name: "vite-plugin-storyblok-init",
|
|
5
|
-
async resolveId(
|
|
6
|
-
if (
|
|
7
|
-
return
|
|
5
|
+
async resolveId(l) {
|
|
6
|
+
if (l === s)
|
|
7
|
+
return i;
|
|
8
8
|
},
|
|
9
|
-
async load(
|
|
10
|
-
if (
|
|
9
|
+
async load(l) {
|
|
10
|
+
if (l === i)
|
|
11
11
|
return `
|
|
12
12
|
import { storyblokInit, apiPlugin } from "@storyblok/js";
|
|
13
13
|
const { storyblokApi } = storyblokInit({
|
|
14
|
-
accessToken: "${
|
|
15
|
-
use: ${
|
|
16
|
-
apiOptions: ${JSON.stringify(
|
|
14
|
+
accessToken: "${o}",
|
|
15
|
+
use: ${e ? "[]" : "[apiPlugin]"},
|
|
16
|
+
apiOptions: ${JSON.stringify(r)},
|
|
17
17
|
});
|
|
18
18
|
export const storyblokApiInstance = storyblokApi;
|
|
19
19
|
`;
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
const
|
|
24
|
-
let
|
|
25
|
-
for (let
|
|
26
|
-
const
|
|
27
|
-
|
|
23
|
+
const Cr = /[\p{Lu}]/u, $r = /[\p{Ll}]/u, zt = /^[\p{Lu}](?![\p{Lu}])/gu, Gt = /([\p{Alpha}\p{N}_]|$)/u, ft = /[_.\- ]+/, jr = new RegExp("^" + ft.source), Lt = new RegExp(ft.source + Gt.source, "gu"), Dt = new RegExp("\\d+" + Gt.source, "gu"), xr = (o, e, r, s) => {
|
|
24
|
+
let i = !1, l = !1, u = !1, h = !1;
|
|
25
|
+
for (let d = 0; d < o.length; d++) {
|
|
26
|
+
const g = o[d];
|
|
27
|
+
h = d > 2 ? o[d - 3] === "-" : !0, i && Cr.test(g) ? (o = o.slice(0, d) + "-" + o.slice(d), i = !1, u = l, l = !0, d++) : l && u && $r.test(g) && (!h || s) ? (o = o.slice(0, d - 1) + "-" + o.slice(d - 1), u = l, l = !1, i = !0) : (i = e(g) === g && r(g) !== g, u = l, l = r(g) === g && e(g) !== g);
|
|
28
28
|
}
|
|
29
|
-
return
|
|
30
|
-
},
|
|
31
|
-
function
|
|
32
|
-
if (!(typeof
|
|
29
|
+
return o;
|
|
30
|
+
}, Er = (o, e) => (zt.lastIndex = 0, o.replaceAll(zt, (r) => e(r))), Rr = (o, e) => (Lt.lastIndex = 0, Dt.lastIndex = 0, o.replaceAll(Dt, (r, s, i) => ["_", "-"].includes(o.charAt(i + r.length)) ? r : e(r)).replaceAll(Lt, (r, s) => e(s)));
|
|
31
|
+
function Ut(o, e) {
|
|
32
|
+
if (!(typeof o == "string" || Array.isArray(o)))
|
|
33
33
|
throw new TypeError("Expected the input to be `string | string[]`");
|
|
34
|
-
if (
|
|
34
|
+
if (e = {
|
|
35
35
|
pascalCase: !1,
|
|
36
36
|
preserveConsecutiveUppercase: !1,
|
|
37
|
-
...
|
|
38
|
-
}, Array.isArray(
|
|
37
|
+
...e
|
|
38
|
+
}, Array.isArray(o) ? o = o.map((l) => l.trim()).filter((l) => l.length).join("-") : o = o.trim(), o.length === 0)
|
|
39
39
|
return "";
|
|
40
|
-
const
|
|
41
|
-
return
|
|
40
|
+
const r = e.locale === !1 ? (l) => l.toLowerCase() : (l) => l.toLocaleLowerCase(e.locale), s = e.locale === !1 ? (l) => l.toUpperCase() : (l) => l.toLocaleUpperCase(e.locale);
|
|
41
|
+
return o.length === 1 ? ft.test(o) ? "" : e.pascalCase ? s(o) : r(o) : (o !== r(o) && (o = xr(o, r, s, e.preserveConsecutiveUppercase)), o = o.replace(jr, ""), o = e.preserveConsecutiveUppercase ? Er(o, r) : r(o), e.pascalCase && (o = s(o.charAt(0)) + o.slice(1)), Rr(o, s));
|
|
42
42
|
}
|
|
43
|
-
function
|
|
44
|
-
const
|
|
43
|
+
function Mr(o, e, r, s) {
|
|
44
|
+
const i = "virtual:storyblok-components", l = "\0" + i;
|
|
45
45
|
return {
|
|
46
46
|
name: "vite-plugin-storyblok-components",
|
|
47
|
-
async resolveId(
|
|
48
|
-
if (
|
|
49
|
-
return
|
|
47
|
+
async resolveId(u) {
|
|
48
|
+
if (u === i)
|
|
49
|
+
return l;
|
|
50
50
|
},
|
|
51
|
-
async load(
|
|
52
|
-
if (
|
|
53
|
-
const
|
|
54
|
-
for await (const [
|
|
55
|
-
const
|
|
56
|
-
"/" +
|
|
51
|
+
async load(u) {
|
|
52
|
+
if (u === l) {
|
|
53
|
+
const h = [], d = [];
|
|
54
|
+
for await (const [v, T] of Object.entries(e)) {
|
|
55
|
+
const w = await this.resolve(
|
|
56
|
+
"/" + o + "/" + T + ".astro"
|
|
57
57
|
);
|
|
58
|
-
if (
|
|
59
|
-
|
|
60
|
-
else if (
|
|
61
|
-
|
|
58
|
+
if (w)
|
|
59
|
+
h.push(`import ${Ut(v)} from "${w.id}"`);
|
|
60
|
+
else if (r)
|
|
61
|
+
d.push(v);
|
|
62
62
|
else
|
|
63
63
|
throw new Error(
|
|
64
|
-
`Component could not be found for blok "${
|
|
64
|
+
`Component could not be found for blok "${v}"! Does "${"/" + o + "/" + T}.astro" exist?`
|
|
65
65
|
);
|
|
66
66
|
}
|
|
67
|
-
let
|
|
68
|
-
if (
|
|
69
|
-
if (
|
|
70
|
-
const
|
|
71
|
-
"/" +
|
|
67
|
+
let g = "";
|
|
68
|
+
if (r)
|
|
69
|
+
if (g = ",FallbackComponent", s) {
|
|
70
|
+
const v = await this.resolve(
|
|
71
|
+
"/" + o + "/" + s + ".astro"
|
|
72
72
|
);
|
|
73
|
-
if (!
|
|
73
|
+
if (!v)
|
|
74
74
|
throw new Error(
|
|
75
|
-
`Custom fallback component could not be found. Does "${"/" +
|
|
75
|
+
`Custom fallback component could not be found. Does "${"/" + o + "/" + s}.astro" exist?`
|
|
76
76
|
);
|
|
77
|
-
|
|
78
|
-
`import FallbackComponent from "${
|
|
77
|
+
h.push(
|
|
78
|
+
`import FallbackComponent from "${v.id}"`
|
|
79
79
|
);
|
|
80
80
|
} else
|
|
81
|
-
|
|
81
|
+
h.push(
|
|
82
82
|
"import FallbackComponent from '@storyblok/astro/FallbackComponent.astro'"
|
|
83
83
|
);
|
|
84
|
-
if (Object.values(
|
|
85
|
-
return `${
|
|
86
|
-
if (
|
|
87
|
-
return `${
|
|
84
|
+
if (Object.values(e).length)
|
|
85
|
+
return `${h.join(";")};export default {${Object.keys(e).filter((v) => !d.includes(v)).map((v) => Ut(v)).join(",")}${g}}`;
|
|
86
|
+
if (r)
|
|
87
|
+
return `${h[0]}; export default {${g.replace(",", "")}}`;
|
|
88
88
|
throw new Error(
|
|
89
89
|
`Currently, no Storyblok components are registered in astro.config.mjs.
|
|
90
90
|
Please register your components or enable the fallback component.
|
|
@@ -94,54 +94,615 @@ Detailed information can be found here: https://github.com/storyblok/storyblok-a
|
|
|
94
94
|
}
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
|
-
function
|
|
98
|
-
const
|
|
97
|
+
function Pr(o) {
|
|
98
|
+
const e = "virtual:storyblok-options", r = "\0" + e;
|
|
99
99
|
return {
|
|
100
100
|
name: "vite-plugin-storyblok-options",
|
|
101
|
-
async resolveId(
|
|
102
|
-
if (
|
|
103
|
-
return
|
|
101
|
+
async resolveId(s) {
|
|
102
|
+
if (s === e)
|
|
103
|
+
return r;
|
|
104
|
+
},
|
|
105
|
+
async load(s) {
|
|
106
|
+
if (s === r)
|
|
107
|
+
return `export default ${JSON.stringify(o)}`;
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
var Z = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
112
|
+
function Nr(o) {
|
|
113
|
+
return o && o.__esModule && Object.prototype.hasOwnProperty.call(o, "default") ? o.default : o;
|
|
114
|
+
}
|
|
115
|
+
var Q = { exports: {} };
|
|
116
|
+
Q.exports;
|
|
117
|
+
(function(o, e) {
|
|
118
|
+
var r = 200, s = "__lodash_hash_undefined__", i = 800, l = 16, u = 9007199254740991, h = "[object Arguments]", d = "[object Array]", g = "[object AsyncFunction]", v = "[object Boolean]", T = "[object Date]", w = "[object Error]", E = "[object Function]", A = "[object GeneratorFunction]", P = "[object Map]", B = "[object Number]", Jt = "[object Null]", pt = "[object Object]", Kt = "[object Proxy]", Wt = "[object RegExp]", Yt = "[object Set]", Xt = "[object String]", Zt = "[object Undefined]", Qt = "[object WeakMap]", Vt = "[object ArrayBuffer]", te = "[object DataView]", ee = "[object Float32Array]", re = "[object Float64Array]", ne = "[object Int8Array]", oe = "[object Int16Array]", ae = "[object Int32Array]", se = "[object Uint8Array]", ie = "[object Uint8ClampedArray]", le = "[object Uint16Array]", ce = "[object Uint32Array]", ue = /[\\^$.*+?()[\]{}|]/g, fe = /^\[object .+?Constructor\]$/, pe = /^(?:0|[1-9]\d*)$/, b = {};
|
|
119
|
+
b[ee] = b[re] = b[ne] = b[oe] = b[ae] = b[se] = b[ie] = b[le] = b[ce] = !0, b[h] = b[d] = b[Vt] = b[v] = b[te] = b[T] = b[w] = b[E] = b[P] = b[B] = b[pt] = b[Wt] = b[Yt] = b[Xt] = b[Qt] = !1;
|
|
120
|
+
var dt = typeof Z == "object" && Z && Z.Object === Object && Z, de = typeof self == "object" && self && self.Object === Object && self, N = dt || de || Function("return this")(), gt = e && !e.nodeType && e, z = gt && !0 && o && !o.nodeType && o, ht = z && z.exports === gt, V = ht && dt.process, yt = function() {
|
|
121
|
+
try {
|
|
122
|
+
var t = z && z.require && z.require("util").types;
|
|
123
|
+
return t || V && V.binding && V.binding("util");
|
|
124
|
+
} catch {
|
|
125
|
+
}
|
|
126
|
+
}(), bt = yt && yt.isTypedArray;
|
|
127
|
+
function ge(t, n, a) {
|
|
128
|
+
switch (a.length) {
|
|
129
|
+
case 0:
|
|
130
|
+
return t.call(n);
|
|
131
|
+
case 1:
|
|
132
|
+
return t.call(n, a[0]);
|
|
133
|
+
case 2:
|
|
134
|
+
return t.call(n, a[0], a[1]);
|
|
135
|
+
case 3:
|
|
136
|
+
return t.call(n, a[0], a[1], a[2]);
|
|
137
|
+
}
|
|
138
|
+
return t.apply(n, a);
|
|
139
|
+
}
|
|
140
|
+
function he(t, n) {
|
|
141
|
+
for (var a = -1, c = Array(t); ++a < t; )
|
|
142
|
+
c[a] = n(a);
|
|
143
|
+
return c;
|
|
144
|
+
}
|
|
145
|
+
function ye(t) {
|
|
146
|
+
return function(n) {
|
|
147
|
+
return t(n);
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
function be(t, n) {
|
|
151
|
+
return t == null ? void 0 : t[n];
|
|
152
|
+
}
|
|
153
|
+
function me(t, n) {
|
|
154
|
+
return function(a) {
|
|
155
|
+
return t(n(a));
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
var _e = Array.prototype, ve = Function.prototype, H = Object.prototype, tt = N["__core-js_shared__"], q = ve.toString, S = H.hasOwnProperty, mt = function() {
|
|
159
|
+
var t = /[^.]+$/.exec(tt && tt.keys && tt.keys.IE_PROTO || "");
|
|
160
|
+
return t ? "Symbol(src)_1." + t : "";
|
|
161
|
+
}(), _t = H.toString, Te = q.call(Object), we = RegExp(
|
|
162
|
+
"^" + q.call(S).replace(ue, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
|
|
163
|
+
), G = ht ? N.Buffer : void 0, vt = N.Symbol, Tt = N.Uint8Array, wt = G ? G.allocUnsafe : void 0, At = me(Object.getPrototypeOf, Object), It = Object.create, Ae = H.propertyIsEnumerable, Ie = _e.splice, $ = vt ? vt.toStringTag : void 0, J = function() {
|
|
164
|
+
try {
|
|
165
|
+
var t = nt(Object, "defineProperty");
|
|
166
|
+
return t({}, "", {}), t;
|
|
167
|
+
} catch {
|
|
168
|
+
}
|
|
169
|
+
}(), ke = G ? G.isBuffer : void 0, kt = Math.max, Oe = Date.now, Ot = nt(N, "Map"), L = nt(Object, "create"), Se = /* @__PURE__ */ function() {
|
|
170
|
+
function t() {
|
|
171
|
+
}
|
|
172
|
+
return function(n) {
|
|
173
|
+
if (!x(n))
|
|
174
|
+
return {};
|
|
175
|
+
if (It)
|
|
176
|
+
return It(n);
|
|
177
|
+
t.prototype = n;
|
|
178
|
+
var a = new t();
|
|
179
|
+
return t.prototype = void 0, a;
|
|
180
|
+
};
|
|
181
|
+
}();
|
|
182
|
+
function j(t) {
|
|
183
|
+
var n = -1, a = t == null ? 0 : t.length;
|
|
184
|
+
for (this.clear(); ++n < a; ) {
|
|
185
|
+
var c = t[n];
|
|
186
|
+
this.set(c[0], c[1]);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
function Ce() {
|
|
190
|
+
this.__data__ = L ? L(null) : {}, this.size = 0;
|
|
191
|
+
}
|
|
192
|
+
function $e(t) {
|
|
193
|
+
var n = this.has(t) && delete this.__data__[t];
|
|
194
|
+
return this.size -= n ? 1 : 0, n;
|
|
195
|
+
}
|
|
196
|
+
function je(t) {
|
|
197
|
+
var n = this.__data__;
|
|
198
|
+
if (L) {
|
|
199
|
+
var a = n[t];
|
|
200
|
+
return a === s ? void 0 : a;
|
|
201
|
+
}
|
|
202
|
+
return S.call(n, t) ? n[t] : void 0;
|
|
203
|
+
}
|
|
204
|
+
function xe(t) {
|
|
205
|
+
var n = this.__data__;
|
|
206
|
+
return L ? n[t] !== void 0 : S.call(n, t);
|
|
207
|
+
}
|
|
208
|
+
function Ee(t, n) {
|
|
209
|
+
var a = this.__data__;
|
|
210
|
+
return this.size += this.has(t) ? 0 : 1, a[t] = L && n === void 0 ? s : n, this;
|
|
211
|
+
}
|
|
212
|
+
j.prototype.clear = Ce, j.prototype.delete = $e, j.prototype.get = je, j.prototype.has = xe, j.prototype.set = Ee;
|
|
213
|
+
function C(t) {
|
|
214
|
+
var n = -1, a = t == null ? 0 : t.length;
|
|
215
|
+
for (this.clear(); ++n < a; ) {
|
|
216
|
+
var c = t[n];
|
|
217
|
+
this.set(c[0], c[1]);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
function Re() {
|
|
221
|
+
this.__data__ = [], this.size = 0;
|
|
222
|
+
}
|
|
223
|
+
function Me(t) {
|
|
224
|
+
var n = this.__data__, a = K(n, t);
|
|
225
|
+
if (a < 0)
|
|
226
|
+
return !1;
|
|
227
|
+
var c = n.length - 1;
|
|
228
|
+
return a == c ? n.pop() : Ie.call(n, a, 1), --this.size, !0;
|
|
229
|
+
}
|
|
230
|
+
function Pe(t) {
|
|
231
|
+
var n = this.__data__, a = K(n, t);
|
|
232
|
+
return a < 0 ? void 0 : n[a][1];
|
|
233
|
+
}
|
|
234
|
+
function Ne(t) {
|
|
235
|
+
return K(this.__data__, t) > -1;
|
|
236
|
+
}
|
|
237
|
+
function ze(t, n) {
|
|
238
|
+
var a = this.__data__, c = K(a, t);
|
|
239
|
+
return c < 0 ? (++this.size, a.push([t, n])) : a[c][1] = n, this;
|
|
240
|
+
}
|
|
241
|
+
C.prototype.clear = Re, C.prototype.delete = Me, C.prototype.get = Pe, C.prototype.has = Ne, C.prototype.set = ze;
|
|
242
|
+
function R(t) {
|
|
243
|
+
var n = -1, a = t == null ? 0 : t.length;
|
|
244
|
+
for (this.clear(); ++n < a; ) {
|
|
245
|
+
var c = t[n];
|
|
246
|
+
this.set(c[0], c[1]);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
function Le() {
|
|
250
|
+
this.size = 0, this.__data__ = {
|
|
251
|
+
hash: new j(),
|
|
252
|
+
map: new (Ot || C)(),
|
|
253
|
+
string: new j()
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
function De(t) {
|
|
257
|
+
var n = Y(this, t).delete(t);
|
|
258
|
+
return this.size -= n ? 1 : 0, n;
|
|
259
|
+
}
|
|
260
|
+
function Ue(t) {
|
|
261
|
+
return Y(this, t).get(t);
|
|
262
|
+
}
|
|
263
|
+
function Fe(t) {
|
|
264
|
+
return Y(this, t).has(t);
|
|
265
|
+
}
|
|
266
|
+
function Be(t, n) {
|
|
267
|
+
var a = Y(this, t), c = a.size;
|
|
268
|
+
return a.set(t, n), this.size += a.size == c ? 0 : 1, this;
|
|
269
|
+
}
|
|
270
|
+
R.prototype.clear = Le, R.prototype.delete = De, R.prototype.get = Ue, R.prototype.has = Fe, R.prototype.set = Be;
|
|
271
|
+
function M(t) {
|
|
272
|
+
var n = this.__data__ = new C(t);
|
|
273
|
+
this.size = n.size;
|
|
274
|
+
}
|
|
275
|
+
function He() {
|
|
276
|
+
this.__data__ = new C(), this.size = 0;
|
|
277
|
+
}
|
|
278
|
+
function qe(t) {
|
|
279
|
+
var n = this.__data__, a = n.delete(t);
|
|
280
|
+
return this.size = n.size, a;
|
|
281
|
+
}
|
|
282
|
+
function Ge(t) {
|
|
283
|
+
return this.__data__.get(t);
|
|
284
|
+
}
|
|
285
|
+
function Je(t) {
|
|
286
|
+
return this.__data__.has(t);
|
|
287
|
+
}
|
|
288
|
+
function Ke(t, n) {
|
|
289
|
+
var a = this.__data__;
|
|
290
|
+
if (a instanceof C) {
|
|
291
|
+
var c = a.__data__;
|
|
292
|
+
if (!Ot || c.length < r - 1)
|
|
293
|
+
return c.push([t, n]), this.size = ++a.size, this;
|
|
294
|
+
a = this.__data__ = new R(c);
|
|
295
|
+
}
|
|
296
|
+
return a.set(t, n), this.size = a.size, this;
|
|
297
|
+
}
|
|
298
|
+
M.prototype.clear = He, M.prototype.delete = qe, M.prototype.get = Ge, M.prototype.has = Je, M.prototype.set = Ke;
|
|
299
|
+
function We(t, n) {
|
|
300
|
+
var a = st(t), c = !a && at(t), p = !a && !c && xt(t), y = !a && !c && !p && Rt(t), m = a || c || p || y, f = m ? he(t.length, String) : [], _ = f.length;
|
|
301
|
+
for (var k in t)
|
|
302
|
+
(n || S.call(t, k)) && !(m && // Safari 9 has enumerable `arguments.length` in strict mode.
|
|
303
|
+
(k == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
|
|
304
|
+
p && (k == "offset" || k == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
|
|
305
|
+
y && (k == "buffer" || k == "byteLength" || k == "byteOffset") || // Skip index properties.
|
|
306
|
+
$t(k, _))) && f.push(k);
|
|
307
|
+
return f;
|
|
308
|
+
}
|
|
309
|
+
function et(t, n, a) {
|
|
310
|
+
(a !== void 0 && !X(t[n], a) || a === void 0 && !(n in t)) && rt(t, n, a);
|
|
311
|
+
}
|
|
312
|
+
function Ye(t, n, a) {
|
|
313
|
+
var c = t[n];
|
|
314
|
+
(!(S.call(t, n) && X(c, a)) || a === void 0 && !(n in t)) && rt(t, n, a);
|
|
315
|
+
}
|
|
316
|
+
function K(t, n) {
|
|
317
|
+
for (var a = t.length; a--; )
|
|
318
|
+
if (X(t[a][0], n))
|
|
319
|
+
return a;
|
|
320
|
+
return -1;
|
|
321
|
+
}
|
|
322
|
+
function rt(t, n, a) {
|
|
323
|
+
n == "__proto__" && J ? J(t, n, {
|
|
324
|
+
configurable: !0,
|
|
325
|
+
enumerable: !0,
|
|
326
|
+
value: a,
|
|
327
|
+
writable: !0
|
|
328
|
+
}) : t[n] = a;
|
|
329
|
+
}
|
|
330
|
+
var Xe = cr();
|
|
331
|
+
function W(t) {
|
|
332
|
+
return t == null ? t === void 0 ? Zt : Jt : $ && $ in Object(t) ? ur(t) : yr(t);
|
|
333
|
+
}
|
|
334
|
+
function St(t) {
|
|
335
|
+
return D(t) && W(t) == h;
|
|
336
|
+
}
|
|
337
|
+
function Ze(t) {
|
|
338
|
+
if (!x(t) || gr(t))
|
|
339
|
+
return !1;
|
|
340
|
+
var n = lt(t) ? we : fe;
|
|
341
|
+
return n.test(vr(t));
|
|
342
|
+
}
|
|
343
|
+
function Qe(t) {
|
|
344
|
+
return D(t) && Et(t.length) && !!b[W(t)];
|
|
345
|
+
}
|
|
346
|
+
function Ve(t) {
|
|
347
|
+
if (!x(t))
|
|
348
|
+
return hr(t);
|
|
349
|
+
var n = jt(t), a = [];
|
|
350
|
+
for (var c in t)
|
|
351
|
+
c == "constructor" && (n || !S.call(t, c)) || a.push(c);
|
|
352
|
+
return a;
|
|
353
|
+
}
|
|
354
|
+
function Ct(t, n, a, c, p) {
|
|
355
|
+
t !== n && Xe(n, function(y, m) {
|
|
356
|
+
if (p || (p = new M()), x(y))
|
|
357
|
+
tr(t, n, m, a, Ct, c, p);
|
|
358
|
+
else {
|
|
359
|
+
var f = c ? c(ot(t, m), y, m + "", t, n, p) : void 0;
|
|
360
|
+
f === void 0 && (f = y), et(t, m, f);
|
|
361
|
+
}
|
|
362
|
+
}, Mt);
|
|
363
|
+
}
|
|
364
|
+
function tr(t, n, a, c, p, y, m) {
|
|
365
|
+
var f = ot(t, a), _ = ot(n, a), k = m.get(_);
|
|
366
|
+
if (k) {
|
|
367
|
+
et(t, a, k);
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
var I = y ? y(f, _, a + "", t, n, m) : void 0, U = I === void 0;
|
|
371
|
+
if (U) {
|
|
372
|
+
var ct = st(_), ut = !ct && xt(_), Nt = !ct && !ut && Rt(_);
|
|
373
|
+
I = _, ct || ut || Nt ? st(f) ? I = f : Tr(f) ? I = sr(f) : ut ? (U = !1, I = nr(_, !0)) : Nt ? (U = !1, I = ar(_, !0)) : I = [] : wr(_) || at(_) ? (I = f, at(f) ? I = Ar(f) : (!x(f) || lt(f)) && (I = fr(_))) : U = !1;
|
|
374
|
+
}
|
|
375
|
+
U && (m.set(_, I), p(I, _, c, y, m), m.delete(_)), et(t, a, I);
|
|
376
|
+
}
|
|
377
|
+
function er(t, n) {
|
|
378
|
+
return mr(br(t, n, Pt), t + "");
|
|
379
|
+
}
|
|
380
|
+
var rr = J ? function(t, n) {
|
|
381
|
+
return J(t, "toString", {
|
|
382
|
+
configurable: !0,
|
|
383
|
+
enumerable: !1,
|
|
384
|
+
value: kr(n),
|
|
385
|
+
writable: !0
|
|
386
|
+
});
|
|
387
|
+
} : Pt;
|
|
388
|
+
function nr(t, n) {
|
|
389
|
+
if (n)
|
|
390
|
+
return t.slice();
|
|
391
|
+
var a = t.length, c = wt ? wt(a) : new t.constructor(a);
|
|
392
|
+
return t.copy(c), c;
|
|
393
|
+
}
|
|
394
|
+
function or(t) {
|
|
395
|
+
var n = new t.constructor(t.byteLength);
|
|
396
|
+
return new Tt(n).set(new Tt(t)), n;
|
|
397
|
+
}
|
|
398
|
+
function ar(t, n) {
|
|
399
|
+
var a = n ? or(t.buffer) : t.buffer;
|
|
400
|
+
return new t.constructor(a, t.byteOffset, t.length);
|
|
401
|
+
}
|
|
402
|
+
function sr(t, n) {
|
|
403
|
+
var a = -1, c = t.length;
|
|
404
|
+
for (n || (n = Array(c)); ++a < c; )
|
|
405
|
+
n[a] = t[a];
|
|
406
|
+
return n;
|
|
407
|
+
}
|
|
408
|
+
function ir(t, n, a, c) {
|
|
409
|
+
var p = !a;
|
|
410
|
+
a || (a = {});
|
|
411
|
+
for (var y = -1, m = n.length; ++y < m; ) {
|
|
412
|
+
var f = n[y], _ = c ? c(a[f], t[f], f, a, t) : void 0;
|
|
413
|
+
_ === void 0 && (_ = t[f]), p ? rt(a, f, _) : Ye(a, f, _);
|
|
414
|
+
}
|
|
415
|
+
return a;
|
|
416
|
+
}
|
|
417
|
+
function lr(t) {
|
|
418
|
+
return er(function(n, a) {
|
|
419
|
+
var c = -1, p = a.length, y = p > 1 ? a[p - 1] : void 0, m = p > 2 ? a[2] : void 0;
|
|
420
|
+
for (y = t.length > 3 && typeof y == "function" ? (p--, y) : void 0, m && pr(a[0], a[1], m) && (y = p < 3 ? void 0 : y, p = 1), n = Object(n); ++c < p; ) {
|
|
421
|
+
var f = a[c];
|
|
422
|
+
f && t(n, f, c, y);
|
|
423
|
+
}
|
|
424
|
+
return n;
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
function cr(t) {
|
|
428
|
+
return function(n, a, c) {
|
|
429
|
+
for (var p = -1, y = Object(n), m = c(n), f = m.length; f--; ) {
|
|
430
|
+
var _ = m[t ? f : ++p];
|
|
431
|
+
if (a(y[_], _, y) === !1)
|
|
432
|
+
break;
|
|
433
|
+
}
|
|
434
|
+
return n;
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
function Y(t, n) {
|
|
438
|
+
var a = t.__data__;
|
|
439
|
+
return dr(n) ? a[typeof n == "string" ? "string" : "hash"] : a.map;
|
|
440
|
+
}
|
|
441
|
+
function nt(t, n) {
|
|
442
|
+
var a = be(t, n);
|
|
443
|
+
return Ze(a) ? a : void 0;
|
|
444
|
+
}
|
|
445
|
+
function ur(t) {
|
|
446
|
+
var n = S.call(t, $), a = t[$];
|
|
447
|
+
try {
|
|
448
|
+
t[$] = void 0;
|
|
449
|
+
var c = !0;
|
|
450
|
+
} catch {
|
|
451
|
+
}
|
|
452
|
+
var p = _t.call(t);
|
|
453
|
+
return c && (n ? t[$] = a : delete t[$]), p;
|
|
454
|
+
}
|
|
455
|
+
function fr(t) {
|
|
456
|
+
return typeof t.constructor == "function" && !jt(t) ? Se(At(t)) : {};
|
|
457
|
+
}
|
|
458
|
+
function $t(t, n) {
|
|
459
|
+
var a = typeof t;
|
|
460
|
+
return n = n ?? u, !!n && (a == "number" || a != "symbol" && pe.test(t)) && t > -1 && t % 1 == 0 && t < n;
|
|
461
|
+
}
|
|
462
|
+
function pr(t, n, a) {
|
|
463
|
+
if (!x(a))
|
|
464
|
+
return !1;
|
|
465
|
+
var c = typeof n;
|
|
466
|
+
return (c == "number" ? it(a) && $t(n, a.length) : c == "string" && n in a) ? X(a[n], t) : !1;
|
|
467
|
+
}
|
|
468
|
+
function dr(t) {
|
|
469
|
+
var n = typeof t;
|
|
470
|
+
return n == "string" || n == "number" || n == "symbol" || n == "boolean" ? t !== "__proto__" : t === null;
|
|
471
|
+
}
|
|
472
|
+
function gr(t) {
|
|
473
|
+
return !!mt && mt in t;
|
|
474
|
+
}
|
|
475
|
+
function jt(t) {
|
|
476
|
+
var n = t && t.constructor, a = typeof n == "function" && n.prototype || H;
|
|
477
|
+
return t === a;
|
|
478
|
+
}
|
|
479
|
+
function hr(t) {
|
|
480
|
+
var n = [];
|
|
481
|
+
if (t != null)
|
|
482
|
+
for (var a in Object(t))
|
|
483
|
+
n.push(a);
|
|
484
|
+
return n;
|
|
485
|
+
}
|
|
486
|
+
function yr(t) {
|
|
487
|
+
return _t.call(t);
|
|
488
|
+
}
|
|
489
|
+
function br(t, n, a) {
|
|
490
|
+
return n = kt(n === void 0 ? t.length - 1 : n, 0), function() {
|
|
491
|
+
for (var c = arguments, p = -1, y = kt(c.length - n, 0), m = Array(y); ++p < y; )
|
|
492
|
+
m[p] = c[n + p];
|
|
493
|
+
p = -1;
|
|
494
|
+
for (var f = Array(n + 1); ++p < n; )
|
|
495
|
+
f[p] = c[p];
|
|
496
|
+
return f[n] = a(m), ge(t, this, f);
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
function ot(t, n) {
|
|
500
|
+
if (!(n === "constructor" && typeof t[n] == "function") && n != "__proto__")
|
|
501
|
+
return t[n];
|
|
502
|
+
}
|
|
503
|
+
var mr = _r(rr);
|
|
504
|
+
function _r(t) {
|
|
505
|
+
var n = 0, a = 0;
|
|
506
|
+
return function() {
|
|
507
|
+
var c = Oe(), p = l - (c - a);
|
|
508
|
+
if (a = c, p > 0) {
|
|
509
|
+
if (++n >= i)
|
|
510
|
+
return arguments[0];
|
|
511
|
+
} else
|
|
512
|
+
n = 0;
|
|
513
|
+
return t.apply(void 0, arguments);
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
function vr(t) {
|
|
517
|
+
if (t != null) {
|
|
518
|
+
try {
|
|
519
|
+
return q.call(t);
|
|
520
|
+
} catch {
|
|
521
|
+
}
|
|
522
|
+
try {
|
|
523
|
+
return t + "";
|
|
524
|
+
} catch {
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
return "";
|
|
528
|
+
}
|
|
529
|
+
function X(t, n) {
|
|
530
|
+
return t === n || t !== t && n !== n;
|
|
531
|
+
}
|
|
532
|
+
var at = St(/* @__PURE__ */ function() {
|
|
533
|
+
return arguments;
|
|
534
|
+
}()) ? St : function(t) {
|
|
535
|
+
return D(t) && S.call(t, "callee") && !Ae.call(t, "callee");
|
|
536
|
+
}, st = Array.isArray;
|
|
537
|
+
function it(t) {
|
|
538
|
+
return t != null && Et(t.length) && !lt(t);
|
|
539
|
+
}
|
|
540
|
+
function Tr(t) {
|
|
541
|
+
return D(t) && it(t);
|
|
542
|
+
}
|
|
543
|
+
var xt = ke || Or;
|
|
544
|
+
function lt(t) {
|
|
545
|
+
if (!x(t))
|
|
546
|
+
return !1;
|
|
547
|
+
var n = W(t);
|
|
548
|
+
return n == E || n == A || n == g || n == Kt;
|
|
549
|
+
}
|
|
550
|
+
function Et(t) {
|
|
551
|
+
return typeof t == "number" && t > -1 && t % 1 == 0 && t <= u;
|
|
552
|
+
}
|
|
553
|
+
function x(t) {
|
|
554
|
+
var n = typeof t;
|
|
555
|
+
return t != null && (n == "object" || n == "function");
|
|
556
|
+
}
|
|
557
|
+
function D(t) {
|
|
558
|
+
return t != null && typeof t == "object";
|
|
559
|
+
}
|
|
560
|
+
function wr(t) {
|
|
561
|
+
if (!D(t) || W(t) != pt)
|
|
562
|
+
return !1;
|
|
563
|
+
var n = At(t);
|
|
564
|
+
if (n === null)
|
|
565
|
+
return !0;
|
|
566
|
+
var a = S.call(n, "constructor") && n.constructor;
|
|
567
|
+
return typeof a == "function" && a instanceof a && q.call(a) == Te;
|
|
568
|
+
}
|
|
569
|
+
var Rt = bt ? ye(bt) : Qe;
|
|
570
|
+
function Ar(t) {
|
|
571
|
+
return ir(t, Mt(t));
|
|
572
|
+
}
|
|
573
|
+
function Mt(t) {
|
|
574
|
+
return it(t) ? We(t, !0) : Ve(t);
|
|
575
|
+
}
|
|
576
|
+
var Ir = lr(function(t, n, a, c) {
|
|
577
|
+
Ct(t, n, a, c);
|
|
578
|
+
});
|
|
579
|
+
function kr(t) {
|
|
580
|
+
return function() {
|
|
581
|
+
return t;
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
function Pt(t) {
|
|
585
|
+
return t;
|
|
586
|
+
}
|
|
587
|
+
function Or() {
|
|
588
|
+
return !1;
|
|
589
|
+
}
|
|
590
|
+
o.exports = Ir;
|
|
591
|
+
})(Q, Q.exports);
|
|
592
|
+
var zr = Q.exports;
|
|
593
|
+
const Lr = /* @__PURE__ */ Nr(zr);
|
|
594
|
+
function Dr(o) {
|
|
595
|
+
let e;
|
|
596
|
+
function r(s, i) {
|
|
597
|
+
var l, u, h, d, g, v, T;
|
|
598
|
+
if ((i == null ? void 0 : i.type) === "AwaitExpression" && ((u = (l = i == null ? void 0 : i.argument) == null ? void 0 : l.callee) == null ? void 0 : u.name) === "useStoryblok") {
|
|
599
|
+
const w = (h = i == null ? void 0 : i.argument) == null ? void 0 : h.arguments;
|
|
600
|
+
((d = w[1]) == null ? void 0 : d.type) === "ObjectExpression" && (e = {
|
|
601
|
+
...e,
|
|
602
|
+
apiOptions: Ft((g = w[1]) == null ? void 0 : g.properties)
|
|
603
|
+
}), ((v = w[2]) == null ? void 0 : v.type) === "ObjectExpression" && (e = {
|
|
604
|
+
...e,
|
|
605
|
+
bridgeOptions: Ft((T = w[2]) == null ? void 0 : T.properties)
|
|
606
|
+
});
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
return Lr({}, o, r), e;
|
|
610
|
+
}
|
|
611
|
+
function Ft(o) {
|
|
612
|
+
return o.reduce((e, { key: r, value: s }) => {
|
|
613
|
+
const { type: i } = s;
|
|
614
|
+
return e[r.name] = i === "Literal" ? s.value : i === "ArrayExpression" ? s.elements.map((l) => l.value) : s.value, e;
|
|
615
|
+
}, {});
|
|
616
|
+
}
|
|
617
|
+
function Ur(o) {
|
|
618
|
+
let e = {
|
|
619
|
+
resolveRelations: []
|
|
620
|
+
};
|
|
621
|
+
function r(s) {
|
|
622
|
+
s && (Array.isArray(s) ? e.resolveRelations.push(...s) : e.resolveRelations.push(s));
|
|
623
|
+
}
|
|
624
|
+
for (const s of o)
|
|
625
|
+
if (s.options) {
|
|
626
|
+
const { apiOptions: i, bridgeOptions: l } = s.options;
|
|
627
|
+
if (r(i == null ? void 0 : i.resolve_relations), l) {
|
|
628
|
+
const { resolveRelations: u, ...h } = l;
|
|
629
|
+
r(u), Object.assign(e, h);
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
return e.resolveRelations = [...new Set(e.resolveRelations)], e;
|
|
633
|
+
}
|
|
634
|
+
let F = [];
|
|
635
|
+
function Fr() {
|
|
636
|
+
let o = [];
|
|
637
|
+
const e = "virtual:storyblok-bridge", r = "\0" + e;
|
|
638
|
+
let s = null, i = null;
|
|
639
|
+
return {
|
|
640
|
+
name: "vite-plugin-storyblok-bridge",
|
|
641
|
+
async resolveId(l) {
|
|
642
|
+
if (l === e)
|
|
643
|
+
return r;
|
|
644
|
+
},
|
|
645
|
+
async transform(l, u) {
|
|
646
|
+
var T;
|
|
647
|
+
if (u.includes("node_modules") && !u.includes("/pages/") || !l.includes("useStoryblok") || !((T = this.getModuleInfo(u).meta) != null && T.astro))
|
|
648
|
+
return;
|
|
649
|
+
const [, ...d] = u.split("src/pages/"), g = d.join("/").replace(".astro", ""), v = Dr(this.parse(l));
|
|
650
|
+
F.length && (o = F.filter((w) => w.url !== g)), o.push({
|
|
651
|
+
url: g,
|
|
652
|
+
options: v
|
|
653
|
+
}), s && (i && clearTimeout(i), i = setTimeout(() => {
|
|
654
|
+
Br(F, o) || (F.length !== 0 && (s.restart(), console.info("Updating bridge options...")), F = [...o]);
|
|
655
|
+
}, 1e3));
|
|
104
656
|
},
|
|
105
|
-
async load(
|
|
106
|
-
if (
|
|
107
|
-
return `export
|
|
657
|
+
async load(l) {
|
|
658
|
+
if (l === r)
|
|
659
|
+
return `export const bridgeOptions = ${JSON.stringify(Ur(o))}`;
|
|
660
|
+
},
|
|
661
|
+
configureServer(l) {
|
|
662
|
+
s = l;
|
|
108
663
|
}
|
|
109
664
|
};
|
|
110
665
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
666
|
+
function Br(o = [], e = []) {
|
|
667
|
+
return e.every(({ url: r, options: s }) => {
|
|
668
|
+
const i = o.find((l) => (l == null ? void 0 : l.url) === r);
|
|
669
|
+
return i && JSON.stringify(s) === JSON.stringify(i.options);
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
let Bt = !1;
|
|
673
|
+
const Ht = [], Hr = (o) => new Promise((e, r) => {
|
|
674
|
+
if (typeof window > "u" || (window.storyblokRegisterEvent = (i) => {
|
|
114
675
|
if (window.location === window.parent.location) {
|
|
115
676
|
console.warn("You are not in Draft Mode or in the Visual Editor.");
|
|
116
677
|
return;
|
|
117
678
|
}
|
|
118
|
-
|
|
679
|
+
Bt ? i() : Ht.push(i);
|
|
119
680
|
}, document.getElementById("storyblok-javascript-bridge")))
|
|
120
681
|
return;
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}, document.getElementsByTagName("head")[0].appendChild(
|
|
682
|
+
const s = document.createElement("script");
|
|
683
|
+
s.async = !0, s.src = o, s.id = "storyblok-javascript-bridge", s.onerror = (i) => r(i), s.onload = (i) => {
|
|
684
|
+
Ht.forEach((l) => l()), Bt = !0, e(i);
|
|
685
|
+
}, document.getElementsByTagName("head")[0].appendChild(s);
|
|
125
686
|
});
|
|
126
|
-
var
|
|
127
|
-
class
|
|
687
|
+
var qr = Object.defineProperty, Gr = (o, e, r) => e in o ? qr(o, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : o[e] = r, O = (o, e, r) => (Gr(o, typeof e != "symbol" ? e + "" : e, r), r);
|
|
688
|
+
class Jr {
|
|
128
689
|
constructor() {
|
|
129
|
-
|
|
130
|
-
...
|
|
131
|
-
per_page:
|
|
132
|
-
page:
|
|
133
|
-
})),
|
|
134
|
-
const
|
|
135
|
-
return this.arrayFrom(
|
|
136
|
-
}),
|
|
137
|
-
const
|
|
690
|
+
O(this, "isCDNUrl", (e = "") => e.indexOf("/cdn/") > -1), O(this, "getOptionsPage", (e, r = 25, s = 1) => ({
|
|
691
|
+
...e,
|
|
692
|
+
per_page: r,
|
|
693
|
+
page: s
|
|
694
|
+
})), O(this, "delay", (e) => new Promise((r) => setTimeout(r, e))), O(this, "arrayFrom", (e = 0, r) => [...Array(e)].map(r)), O(this, "range", (e = 0, r = e) => {
|
|
695
|
+
const s = Math.abs(r - e) || 0, i = e < r ? 1 : -1;
|
|
696
|
+
return this.arrayFrom(s, (l, u) => u * i + e);
|
|
697
|
+
}), O(this, "asyncMap", async (e, r) => Promise.all(e.map(r))), O(this, "flatMap", (e = [], r) => e.map(r).reduce((s, i) => [...s, ...i], [])), O(this, "escapeHTML", function(e) {
|
|
698
|
+
const r = {
|
|
138
699
|
"&": "&",
|
|
139
700
|
"<": "<",
|
|
140
701
|
">": ">",
|
|
141
702
|
'"': """,
|
|
142
703
|
"'": "'"
|
|
143
|
-
},
|
|
144
|
-
return
|
|
704
|
+
}, s = /[&<>"']/g, i = RegExp(s.source);
|
|
705
|
+
return e && i.test(e) ? e.replace(s, (l) => r[l]) : e;
|
|
145
706
|
});
|
|
146
707
|
}
|
|
147
708
|
/**
|
|
@@ -151,223 +712,223 @@ class z {
|
|
|
151
712
|
* @param {Boolean} isArray
|
|
152
713
|
* @return {String} Stringified object
|
|
153
714
|
*/
|
|
154
|
-
stringify(
|
|
155
|
-
const
|
|
156
|
-
for (const
|
|
157
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
715
|
+
stringify(e, r, s) {
|
|
716
|
+
const i = [];
|
|
717
|
+
for (const l in e) {
|
|
718
|
+
if (!Object.prototype.hasOwnProperty.call(e, l))
|
|
158
719
|
continue;
|
|
159
|
-
const
|
|
160
|
-
let
|
|
161
|
-
typeof
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
Array.isArray(
|
|
165
|
-
) :
|
|
720
|
+
const u = e[l], h = s ? "" : encodeURIComponent(l);
|
|
721
|
+
let d;
|
|
722
|
+
typeof u == "object" ? d = this.stringify(
|
|
723
|
+
u,
|
|
724
|
+
r ? r + encodeURIComponent("[" + h + "]") : h,
|
|
725
|
+
Array.isArray(u)
|
|
726
|
+
) : d = (r ? r + encodeURIComponent("[" + h + "]") : h) + "=" + encodeURIComponent(u), i.push(d);
|
|
166
727
|
}
|
|
167
|
-
return
|
|
728
|
+
return i.join("&");
|
|
168
729
|
}
|
|
169
730
|
/**
|
|
170
731
|
* @method getRegionURL
|
|
171
732
|
* @param {String} regionCode region code, could be eu, us, cn, ap or ca
|
|
172
733
|
* @return {String} The base URL of the region
|
|
173
734
|
*/
|
|
174
|
-
getRegionURL(
|
|
175
|
-
const
|
|
176
|
-
switch (
|
|
735
|
+
getRegionURL(e) {
|
|
736
|
+
const r = "api.storyblok.com", s = "api-us.storyblok.com", i = "app.storyblokchina.cn", l = "api-ap.storyblok.com", u = "api-ca.storyblok.com";
|
|
737
|
+
switch (e) {
|
|
177
738
|
case "us":
|
|
178
|
-
return o;
|
|
179
|
-
case "cn":
|
|
180
739
|
return s;
|
|
740
|
+
case "cn":
|
|
741
|
+
return i;
|
|
181
742
|
case "ap":
|
|
182
|
-
return
|
|
743
|
+
return l;
|
|
183
744
|
case "ca":
|
|
184
|
-
return
|
|
745
|
+
return u;
|
|
185
746
|
default:
|
|
186
|
-
return
|
|
747
|
+
return r;
|
|
187
748
|
}
|
|
188
749
|
}
|
|
189
750
|
}
|
|
190
|
-
const
|
|
191
|
-
const
|
|
192
|
-
for (const
|
|
193
|
-
const
|
|
194
|
-
|
|
195
|
-
}
|
|
196
|
-
return
|
|
197
|
-
},
|
|
751
|
+
const Kr = function(o, e) {
|
|
752
|
+
const r = {};
|
|
753
|
+
for (const s in o) {
|
|
754
|
+
const i = o[s];
|
|
755
|
+
e.indexOf(s) > -1 && i !== null && (r[s] = i);
|
|
756
|
+
}
|
|
757
|
+
return r;
|
|
758
|
+
}, Wr = (o) => o === "email", Yr = () => ({
|
|
198
759
|
singleTag: "hr"
|
|
199
|
-
}),
|
|
760
|
+
}), Xr = () => ({
|
|
200
761
|
tag: "blockquote"
|
|
201
|
-
}),
|
|
762
|
+
}), Zr = () => ({
|
|
202
763
|
tag: "ul"
|
|
203
|
-
}),
|
|
764
|
+
}), Qr = (o) => ({
|
|
204
765
|
tag: [
|
|
205
766
|
"pre",
|
|
206
767
|
{
|
|
207
768
|
tag: "code",
|
|
208
|
-
attrs:
|
|
769
|
+
attrs: o.attrs
|
|
209
770
|
}
|
|
210
771
|
]
|
|
211
|
-
}),
|
|
772
|
+
}), Vr = () => ({
|
|
212
773
|
singleTag: "br"
|
|
213
|
-
}),
|
|
214
|
-
tag: `h${
|
|
215
|
-
}),
|
|
774
|
+
}), tn = (o) => ({
|
|
775
|
+
tag: `h${o.attrs.level}`
|
|
776
|
+
}), en = (o) => ({
|
|
216
777
|
singleTag: [
|
|
217
778
|
{
|
|
218
779
|
tag: "img",
|
|
219
|
-
attrs:
|
|
780
|
+
attrs: Kr(o.attrs, ["src", "alt", "title"])
|
|
220
781
|
}
|
|
221
782
|
]
|
|
222
|
-
}),
|
|
783
|
+
}), rn = () => ({
|
|
223
784
|
tag: "li"
|
|
224
|
-
}),
|
|
785
|
+
}), nn = () => ({
|
|
225
786
|
tag: "ol"
|
|
226
|
-
}),
|
|
787
|
+
}), on = () => ({
|
|
227
788
|
tag: "p"
|
|
228
|
-
}),
|
|
789
|
+
}), an = (o) => ({
|
|
229
790
|
tag: [
|
|
230
791
|
{
|
|
231
792
|
tag: "span",
|
|
232
793
|
attrs: {
|
|
233
794
|
"data-type": "emoji",
|
|
234
|
-
"data-name":
|
|
235
|
-
emoji:
|
|
795
|
+
"data-name": o.attrs.name,
|
|
796
|
+
emoji: o.attrs.emoji
|
|
236
797
|
}
|
|
237
798
|
}
|
|
238
799
|
]
|
|
239
|
-
}),
|
|
800
|
+
}), sn = () => ({
|
|
240
801
|
tag: "b"
|
|
241
|
-
}),
|
|
802
|
+
}), ln = () => ({
|
|
242
803
|
tag: "s"
|
|
243
|
-
}),
|
|
804
|
+
}), cn = () => ({
|
|
244
805
|
tag: "u"
|
|
245
|
-
}),
|
|
806
|
+
}), un = () => ({
|
|
246
807
|
tag: "strong"
|
|
247
|
-
}),
|
|
808
|
+
}), fn = () => ({
|
|
248
809
|
tag: "code"
|
|
249
|
-
}),
|
|
810
|
+
}), pn = () => ({
|
|
250
811
|
tag: "i"
|
|
251
|
-
}),
|
|
252
|
-
if (!
|
|
812
|
+
}), dn = (o) => {
|
|
813
|
+
if (!o.attrs)
|
|
253
814
|
return {
|
|
254
815
|
tag: ""
|
|
255
816
|
};
|
|
256
|
-
const
|
|
257
|
-
if (delete
|
|
258
|
-
for (const
|
|
259
|
-
|
|
260
|
-
delete
|
|
817
|
+
const e = new Jr().escapeHTML, r = { ...o.attrs }, { linktype: s = "url" } = o.attrs;
|
|
818
|
+
if (delete r.linktype, r.href && (r.href = e(o.attrs.href || "")), Wr(s) && (r.href = `mailto:${r.href}`), r.anchor && (r.href = `${r.href}#${r.anchor}`, delete r.anchor), r.custom) {
|
|
819
|
+
for (const i in r.custom)
|
|
820
|
+
r[i] = r.custom[i];
|
|
821
|
+
delete r.custom;
|
|
261
822
|
}
|
|
262
823
|
return {
|
|
263
824
|
tag: [
|
|
264
825
|
{
|
|
265
826
|
tag: "a",
|
|
266
|
-
attrs:
|
|
827
|
+
attrs: r
|
|
267
828
|
}
|
|
268
829
|
]
|
|
269
830
|
};
|
|
270
|
-
},
|
|
831
|
+
}, gn = (o) => ({
|
|
271
832
|
tag: [
|
|
272
833
|
{
|
|
273
834
|
tag: "span",
|
|
274
|
-
attrs:
|
|
835
|
+
attrs: o.attrs
|
|
275
836
|
}
|
|
276
837
|
]
|
|
277
|
-
}),
|
|
838
|
+
}), hn = () => ({
|
|
278
839
|
tag: "sub"
|
|
279
|
-
}),
|
|
840
|
+
}), yn = () => ({
|
|
280
841
|
tag: "sup"
|
|
281
|
-
}),
|
|
842
|
+
}), bn = (o) => ({
|
|
282
843
|
tag: [
|
|
283
844
|
{
|
|
284
845
|
tag: "span",
|
|
285
|
-
attrs:
|
|
846
|
+
attrs: o.attrs
|
|
286
847
|
}
|
|
287
848
|
]
|
|
288
|
-
}),
|
|
289
|
-
var
|
|
290
|
-
return (
|
|
849
|
+
}), mn = (o) => {
|
|
850
|
+
var e;
|
|
851
|
+
return (e = o.attrs) != null && e.color ? {
|
|
291
852
|
tag: [
|
|
292
853
|
{
|
|
293
854
|
tag: "span",
|
|
294
855
|
attrs: {
|
|
295
|
-
style: `background-color:${
|
|
856
|
+
style: `background-color:${o.attrs.color};`
|
|
296
857
|
}
|
|
297
858
|
}
|
|
298
859
|
]
|
|
299
860
|
} : {
|
|
300
861
|
tag: ""
|
|
301
862
|
};
|
|
302
|
-
},
|
|
303
|
-
var
|
|
304
|
-
return (
|
|
863
|
+
}, _n = (o) => {
|
|
864
|
+
var e;
|
|
865
|
+
return (e = o.attrs) != null && e.color ? {
|
|
305
866
|
tag: [
|
|
306
867
|
{
|
|
307
868
|
tag: "span",
|
|
308
869
|
attrs: {
|
|
309
|
-
style: `color:${
|
|
870
|
+
style: `color:${o.attrs.color}`
|
|
310
871
|
}
|
|
311
872
|
}
|
|
312
873
|
]
|
|
313
874
|
} : {
|
|
314
875
|
tag: ""
|
|
315
876
|
};
|
|
316
|
-
},
|
|
877
|
+
}, vn = {
|
|
317
878
|
nodes: {
|
|
318
|
-
horizontal_rule:
|
|
319
|
-
blockquote:
|
|
320
|
-
bullet_list:
|
|
321
|
-
code_block:
|
|
322
|
-
hard_break:
|
|
323
|
-
heading:
|
|
324
|
-
image:
|
|
325
|
-
list_item:
|
|
326
|
-
ordered_list:
|
|
327
|
-
paragraph:
|
|
328
|
-
emoji:
|
|
879
|
+
horizontal_rule: Yr,
|
|
880
|
+
blockquote: Xr,
|
|
881
|
+
bullet_list: Zr,
|
|
882
|
+
code_block: Qr,
|
|
883
|
+
hard_break: Vr,
|
|
884
|
+
heading: tn,
|
|
885
|
+
image: en,
|
|
886
|
+
list_item: rn,
|
|
887
|
+
ordered_list: nn,
|
|
888
|
+
paragraph: on,
|
|
889
|
+
emoji: an
|
|
329
890
|
},
|
|
330
891
|
marks: {
|
|
331
|
-
bold:
|
|
332
|
-
strike:
|
|
333
|
-
underline:
|
|
334
|
-
strong:
|
|
335
|
-
code:
|
|
336
|
-
italic:
|
|
337
|
-
link:
|
|
338
|
-
styled:
|
|
339
|
-
subscript:
|
|
340
|
-
superscript:
|
|
341
|
-
anchor:
|
|
342
|
-
highlight:
|
|
343
|
-
textStyle:
|
|
344
|
-
}
|
|
345
|
-
},
|
|
346
|
-
const
|
|
892
|
+
bold: sn,
|
|
893
|
+
strike: ln,
|
|
894
|
+
underline: cn,
|
|
895
|
+
strong: un,
|
|
896
|
+
code: fn,
|
|
897
|
+
italic: pn,
|
|
898
|
+
link: dn,
|
|
899
|
+
styled: gn,
|
|
900
|
+
subscript: hn,
|
|
901
|
+
superscript: yn,
|
|
902
|
+
anchor: bn,
|
|
903
|
+
highlight: mn,
|
|
904
|
+
textStyle: _n
|
|
905
|
+
}
|
|
906
|
+
}, Tn = function(o) {
|
|
907
|
+
const e = {
|
|
347
908
|
"&": "&",
|
|
348
909
|
"<": "<",
|
|
349
910
|
">": ">",
|
|
350
911
|
'"': """,
|
|
351
912
|
"'": "'"
|
|
352
|
-
},
|
|
353
|
-
return
|
|
913
|
+
}, r = /[&<>"']/g, s = RegExp(r.source);
|
|
914
|
+
return o && s.test(o) ? o.replace(r, (i) => e[i]) : o;
|
|
354
915
|
};
|
|
355
|
-
class
|
|
356
|
-
constructor(
|
|
357
|
-
|
|
358
|
-
}
|
|
359
|
-
addNode(
|
|
360
|
-
this.nodes[
|
|
361
|
-
}
|
|
362
|
-
addMark(
|
|
363
|
-
this.marks[
|
|
364
|
-
}
|
|
365
|
-
render(
|
|
366
|
-
if (
|
|
367
|
-
let
|
|
368
|
-
return
|
|
369
|
-
|
|
370
|
-
}),
|
|
916
|
+
class wn {
|
|
917
|
+
constructor(e) {
|
|
918
|
+
O(this, "marks"), O(this, "nodes"), e || (e = vn), this.marks = e.marks || [], this.nodes = e.nodes || [];
|
|
919
|
+
}
|
|
920
|
+
addNode(e, r) {
|
|
921
|
+
this.nodes[e] = r;
|
|
922
|
+
}
|
|
923
|
+
addMark(e, r) {
|
|
924
|
+
this.marks[e] = r;
|
|
925
|
+
}
|
|
926
|
+
render(e, r = { optimizeImages: !1 }) {
|
|
927
|
+
if (e && e.content && Array.isArray(e.content)) {
|
|
928
|
+
let s = "";
|
|
929
|
+
return e.content.forEach((i) => {
|
|
930
|
+
s += this.renderNode(i);
|
|
931
|
+
}), r.optimizeImages ? this.optimizeImages(s, r.optimizeImages) : s;
|
|
371
932
|
}
|
|
372
933
|
return console.warn(
|
|
373
934
|
`The render method must receive an Object with a "content" field.
|
|
@@ -396,222 +957,273 @@ class fe {
|
|
|
396
957
|
}`
|
|
397
958
|
), "";
|
|
398
959
|
}
|
|
399
|
-
optimizeImages(
|
|
400
|
-
let
|
|
401
|
-
typeof
|
|
402
|
-
const
|
|
403
|
-
return
|
|
960
|
+
optimizeImages(e, r) {
|
|
961
|
+
let s = 0, i = 0, l = "", u = "";
|
|
962
|
+
typeof r != "boolean" && (typeof r.width == "number" && r.width > 0 && (l += `width="${r.width}" `, s = r.width), typeof r.height == "number" && r.height > 0 && (l += `height="${r.height}" `, i = r.height), (r.loading === "lazy" || r.loading === "eager") && (l += `loading="${r.loading}" `), typeof r.class == "string" && r.class.length > 0 && (l += `class="${r.class}" `), r.filters && (typeof r.filters.blur == "number" && r.filters.blur >= 0 && r.filters.blur <= 100 && (u += `:blur(${r.filters.blur})`), typeof r.filters.brightness == "number" && r.filters.brightness >= -100 && r.filters.brightness <= 100 && (u += `:brightness(${r.filters.brightness})`), r.filters.fill && (r.filters.fill.match(/[0-9A-Fa-f]{6}/g) || r.filters.fill === "transparent") && (u += `:fill(${r.filters.fill})`), r.filters.format && ["webp", "png", "jpeg"].includes(r.filters.format) && (u += `:format(${r.filters.format})`), typeof r.filters.grayscale == "boolean" && r.filters.grayscale && (u += ":grayscale()"), typeof r.filters.quality == "number" && r.filters.quality >= 0 && r.filters.quality <= 100 && (u += `:quality(${r.filters.quality})`), r.filters.rotate && [90, 180, 270].includes(r.filters.rotate) && (u += `:rotate(${r.filters.rotate})`), u.length > 0 && (u = "/filters" + u))), l.length > 0 && (e = e.replace(/<img/g, `<img ${l.trim()}`));
|
|
963
|
+
const h = s > 0 || i > 0 || u.length > 0 ? `${s}x${i}${u}` : "";
|
|
964
|
+
return e = e.replace(
|
|
404
965
|
/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g,
|
|
405
|
-
`a.storyblok.com/f/$1/$2.$3/m/${
|
|
406
|
-
), typeof
|
|
407
|
-
var
|
|
408
|
-
const
|
|
966
|
+
`a.storyblok.com/f/$1/$2.$3/m/${h}`
|
|
967
|
+
), typeof r != "boolean" && (r.sizes || r.srcset) && (e = e.replace(/<img.*?src=["|'](.*?)["|']/g, (d) => {
|
|
968
|
+
var g, v;
|
|
969
|
+
const T = d.match(
|
|
409
970
|
/a.storyblok.com\/f\/(\d+)\/([^.]+)\.(gif|jpg|jpeg|png|tif|tiff|bmp)/g
|
|
410
971
|
);
|
|
411
|
-
if (
|
|
412
|
-
const
|
|
413
|
-
srcset: (
|
|
414
|
-
if (typeof
|
|
415
|
-
return `//${
|
|
416
|
-
if (typeof
|
|
417
|
-
let
|
|
418
|
-
return typeof
|
|
972
|
+
if (T && T.length > 0) {
|
|
973
|
+
const w = {
|
|
974
|
+
srcset: (g = r.srcset) == null ? void 0 : g.map((A) => {
|
|
975
|
+
if (typeof A == "number")
|
|
976
|
+
return `//${T}/m/${A}x0${u} ${A}w`;
|
|
977
|
+
if (typeof A == "object" && A.length === 2) {
|
|
978
|
+
let P = 0, B = 0;
|
|
979
|
+
return typeof A[0] == "number" && (P = A[0]), typeof A[1] == "number" && (B = A[1]), `//${T}/m/${P}x${B}${u} ${P}w`;
|
|
419
980
|
}
|
|
420
981
|
}).join(", "),
|
|
421
|
-
sizes: (
|
|
982
|
+
sizes: (v = r.sizes) == null ? void 0 : v.map((A) => A).join(", ")
|
|
422
983
|
};
|
|
423
|
-
let
|
|
424
|
-
return
|
|
984
|
+
let E = "";
|
|
985
|
+
return w.srcset && (E += `srcset="${w.srcset}" `), w.sizes && (E += `sizes="${w.sizes}" `), d.replace(/<img/g, `<img ${E.trim()}`);
|
|
425
986
|
}
|
|
426
|
-
return
|
|
427
|
-
})),
|
|
428
|
-
}
|
|
429
|
-
renderNode(
|
|
430
|
-
const
|
|
431
|
-
|
|
432
|
-
const
|
|
433
|
-
|
|
987
|
+
return d;
|
|
988
|
+
})), e;
|
|
989
|
+
}
|
|
990
|
+
renderNode(e) {
|
|
991
|
+
const r = [];
|
|
992
|
+
e.marks && e.marks.forEach((i) => {
|
|
993
|
+
const l = this.getMatchingMark(i);
|
|
994
|
+
l && l.tag !== "" && r.push(this.renderOpeningTag(l.tag));
|
|
434
995
|
});
|
|
435
|
-
const
|
|
436
|
-
return
|
|
437
|
-
|
|
438
|
-
}) :
|
|
439
|
-
const
|
|
440
|
-
|
|
441
|
-
}),
|
|
442
|
-
}
|
|
443
|
-
renderTag(
|
|
444
|
-
return
|
|
445
|
-
if (
|
|
446
|
-
return `<${
|
|
996
|
+
const s = this.getMatchingNode(e);
|
|
997
|
+
return s && s.tag && r.push(this.renderOpeningTag(s.tag)), e.content ? e.content.forEach((i) => {
|
|
998
|
+
r.push(this.renderNode(i));
|
|
999
|
+
}) : e.text ? r.push(Tn(e.text)) : s && s.singleTag ? r.push(this.renderTag(s.singleTag, " /")) : s && s.html ? r.push(s.html) : e.type === "emoji" && r.push(this.renderEmoji(e)), s && s.tag && r.push(this.renderClosingTag(s.tag)), e.marks && e.marks.slice(0).reverse().forEach((i) => {
|
|
1000
|
+
const l = this.getMatchingMark(i);
|
|
1001
|
+
l && l.tag !== "" && r.push(this.renderClosingTag(l.tag));
|
|
1002
|
+
}), r.join("");
|
|
1003
|
+
}
|
|
1004
|
+
renderTag(e, r) {
|
|
1005
|
+
return e.constructor === String ? `<${e}${r}>` : e.map((s) => {
|
|
1006
|
+
if (s.constructor === String)
|
|
1007
|
+
return `<${s}${r}>`;
|
|
447
1008
|
{
|
|
448
|
-
let
|
|
449
|
-
if (
|
|
450
|
-
for (const
|
|
451
|
-
const
|
|
452
|
-
|
|
1009
|
+
let i = `<${s.tag}`;
|
|
1010
|
+
if (s.attrs)
|
|
1011
|
+
for (const l in s.attrs) {
|
|
1012
|
+
const u = s.attrs[l];
|
|
1013
|
+
u !== null && (i += ` ${l}="${u}"`);
|
|
453
1014
|
}
|
|
454
|
-
return `${
|
|
1015
|
+
return `${i}${r}>`;
|
|
455
1016
|
}
|
|
456
1017
|
}).join("");
|
|
457
1018
|
}
|
|
458
|
-
renderOpeningTag(
|
|
459
|
-
return this.renderTag(
|
|
1019
|
+
renderOpeningTag(e) {
|
|
1020
|
+
return this.renderTag(e, "");
|
|
460
1021
|
}
|
|
461
|
-
renderClosingTag(
|
|
462
|
-
return
|
|
1022
|
+
renderClosingTag(e) {
|
|
1023
|
+
return e.constructor === String ? `</${e}>` : e.slice(0).reverse().map((r) => r.constructor === String ? `</${r}>` : `</${r.tag}>`).join("");
|
|
463
1024
|
}
|
|
464
|
-
getMatchingNode(
|
|
465
|
-
const
|
|
466
|
-
if (typeof
|
|
467
|
-
return e
|
|
1025
|
+
getMatchingNode(e) {
|
|
1026
|
+
const r = this.nodes[e.type];
|
|
1027
|
+
if (typeof r == "function")
|
|
1028
|
+
return r(e);
|
|
468
1029
|
}
|
|
469
|
-
getMatchingMark(
|
|
470
|
-
const
|
|
471
|
-
if (typeof
|
|
472
|
-
return e
|
|
1030
|
+
getMatchingMark(e) {
|
|
1031
|
+
const r = this.marks[e.type];
|
|
1032
|
+
if (typeof r == "function")
|
|
1033
|
+
return r(e);
|
|
473
1034
|
}
|
|
474
|
-
renderEmoji(
|
|
475
|
-
if (
|
|
476
|
-
return
|
|
477
|
-
const
|
|
1035
|
+
renderEmoji(e) {
|
|
1036
|
+
if (e.attrs.emoji)
|
|
1037
|
+
return e.attrs.emoji;
|
|
1038
|
+
const r = [
|
|
478
1039
|
{
|
|
479
1040
|
tag: "img",
|
|
480
1041
|
attrs: {
|
|
481
|
-
src:
|
|
1042
|
+
src: e.attrs.fallbackImage,
|
|
482
1043
|
draggable: "false",
|
|
483
1044
|
loading: "lazy",
|
|
484
1045
|
align: "absmiddle"
|
|
485
1046
|
}
|
|
486
1047
|
}
|
|
487
1048
|
];
|
|
488
|
-
return this.renderTag(
|
|
1049
|
+
return this.renderTag(r, " /");
|
|
489
1050
|
}
|
|
490
1051
|
}
|
|
491
|
-
const
|
|
492
|
-
if (typeof
|
|
1052
|
+
const jn = (o) => {
|
|
1053
|
+
if (typeof o != "object" || typeof o._editable > "u")
|
|
493
1054
|
return {};
|
|
494
1055
|
try {
|
|
495
|
-
const
|
|
496
|
-
|
|
1056
|
+
const e = JSON.parse(
|
|
1057
|
+
o._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, "")
|
|
497
1058
|
);
|
|
498
|
-
return
|
|
499
|
-
"data-blok-c": JSON.stringify(
|
|
500
|
-
"data-blok-uid":
|
|
1059
|
+
return e ? {
|
|
1060
|
+
"data-blok-c": JSON.stringify(e),
|
|
1061
|
+
"data-blok-uid": e.id + "-" + e.uid
|
|
501
1062
|
} : {};
|
|
502
1063
|
} catch {
|
|
503
1064
|
return {};
|
|
504
1065
|
}
|
|
505
1066
|
};
|
|
506
|
-
let
|
|
507
|
-
const
|
|
508
|
-
|
|
509
|
-
let
|
|
510
|
-
return
|
|
511
|
-
|
|
1067
|
+
let An, In = "https://app.storyblok.com/f/storyblok-v2-latest.js";
|
|
1068
|
+
const kn = (o, e) => {
|
|
1069
|
+
o.addNode("blok", (r) => {
|
|
1070
|
+
let s = "";
|
|
1071
|
+
return r.attrs.body.forEach((i) => {
|
|
1072
|
+
s += e(i.component, i);
|
|
512
1073
|
}), {
|
|
513
|
-
html:
|
|
1074
|
+
html: s
|
|
514
1075
|
};
|
|
515
1076
|
});
|
|
516
|
-
},
|
|
517
|
-
let
|
|
518
|
-
if (!
|
|
1077
|
+
}, On = (o) => !o || !(o != null && o.content.some((e) => e.content || e.type === "blok" || e.type === "horizontal_rule")), Sn = (o, e, r) => {
|
|
1078
|
+
let s = r || An;
|
|
1079
|
+
if (!s) {
|
|
519
1080
|
console.error(
|
|
520
1081
|
"Please initialize the Storyblok SDK before calling the renderRichText function"
|
|
521
1082
|
);
|
|
522
1083
|
return;
|
|
523
1084
|
}
|
|
524
|
-
return
|
|
525
|
-
},
|
|
526
|
-
|
|
1085
|
+
return On(o) ? "" : (e && (s = new wn(e.schema), e.resolver && kn(s, e.resolver)), s.render(o));
|
|
1086
|
+
}, xn = () => Hr(In);
|
|
1087
|
+
let qt;
|
|
1088
|
+
async function En(o) {
|
|
1089
|
+
var s;
|
|
1090
|
+
const { action: e, story: r } = o || {};
|
|
1091
|
+
if (e === "input" && r) {
|
|
1092
|
+
const i = async () => {
|
|
1093
|
+
const u = performance.now(), h = await $n(r), d = performance.now();
|
|
1094
|
+
console.log(`getNewHTMLBody took ${d - u} milliseconds.`);
|
|
1095
|
+
const g = document.body;
|
|
1096
|
+
if (h.outerHTML === g.outerHTML)
|
|
1097
|
+
return;
|
|
1098
|
+
const v = document.querySelector('[data-blok-focused="true"]');
|
|
1099
|
+
Cn(g, h, v);
|
|
1100
|
+
const T = performance.now();
|
|
1101
|
+
console.log(`updateDOMWithNewBody took ${T - d} milliseconds.`), console.log(`total time took ${T - u} milliseconds.`);
|
|
1102
|
+
};
|
|
1103
|
+
clearTimeout(qt), qt = setTimeout(i, 1500);
|
|
1104
|
+
}
|
|
1105
|
+
["published", "change"].includes((s = o == null ? void 0 : o.data) == null ? void 0 : s.action) && location.reload();
|
|
1106
|
+
}
|
|
1107
|
+
function Cn(o, e, r) {
|
|
1108
|
+
if (r) {
|
|
1109
|
+
const s = r.getAttribute("data-blok-uid"), i = e.querySelector(
|
|
1110
|
+
`[data-blok-uid="${s}"]`
|
|
1111
|
+
);
|
|
1112
|
+
i && (i.setAttribute("data-blok-focused", "true"), console.log("Doing partial replace"), r.replaceWith(i));
|
|
1113
|
+
} else
|
|
1114
|
+
console.log("Doing full replace"), o.replaceWith(e);
|
|
1115
|
+
}
|
|
1116
|
+
async function $n(o) {
|
|
1117
|
+
const r = await (await fetch(location.href, {
|
|
1118
|
+
method: "POST",
|
|
1119
|
+
body: JSON.stringify({
|
|
1120
|
+
...o,
|
|
1121
|
+
is_storyblok_preview: !0
|
|
1122
|
+
}),
|
|
1123
|
+
headers: {
|
|
1124
|
+
"Content-Type": "application/json"
|
|
1125
|
+
}
|
|
1126
|
+
})).text();
|
|
1127
|
+
return new DOMParser().parseFromString(r, "text/html").body;
|
|
1128
|
+
}
|
|
1129
|
+
function Rn() {
|
|
527
1130
|
return globalThis.storyblokApiInstance || console.error("storyblokApiInstance has not been initialized correctly"), globalThis.storyblokApiInstance;
|
|
528
1131
|
}
|
|
529
|
-
function
|
|
530
|
-
|
|
531
|
-
|
|
1132
|
+
async function Mn(o, e = {}, r = {}, s) {
|
|
1133
|
+
globalThis.storyblokApiInstance || console.error("storyblokApiInstance has not been initialized correctly");
|
|
1134
|
+
let i = null;
|
|
1135
|
+
if (s && s.locals._storyblok_preview_data)
|
|
1136
|
+
i = s.locals._storyblok_preview_data;
|
|
1137
|
+
else {
|
|
1138
|
+
const { data: l } = await globalThis.storyblokApiInstance.get(
|
|
1139
|
+
o,
|
|
1140
|
+
e,
|
|
1141
|
+
r
|
|
1142
|
+
);
|
|
1143
|
+
i = l.story;
|
|
1144
|
+
}
|
|
1145
|
+
return i;
|
|
1146
|
+
}
|
|
1147
|
+
function Pn(o, e) {
|
|
1148
|
+
const r = globalThis.storyblokApiInstance.richTextResolver;
|
|
1149
|
+
if (!r) {
|
|
532
1150
|
console.error(
|
|
533
1151
|
"Please initialize the Storyblok SDK before calling the renderRichText function"
|
|
534
1152
|
);
|
|
535
1153
|
return;
|
|
536
1154
|
}
|
|
537
|
-
return
|
|
1155
|
+
return Sn(o, e, r);
|
|
538
1156
|
}
|
|
539
|
-
function
|
|
540
|
-
const
|
|
1157
|
+
function Nn(o) {
|
|
1158
|
+
const e = {
|
|
541
1159
|
useCustomApi: !1,
|
|
542
1160
|
bridge: !0,
|
|
543
1161
|
componentsDir: "src",
|
|
544
1162
|
enableFallbackComponent: !1,
|
|
545
|
-
...
|
|
1163
|
+
...o
|
|
546
1164
|
};
|
|
547
1165
|
return {
|
|
548
1166
|
name: "@storyblok/astro",
|
|
549
1167
|
hooks: {
|
|
550
1168
|
"astro:config:setup": ({
|
|
551
|
-
injectScript:
|
|
552
|
-
updateConfig:
|
|
553
|
-
addDevToolbarApp:
|
|
1169
|
+
injectScript: r,
|
|
1170
|
+
updateConfig: s,
|
|
1171
|
+
addDevToolbarApp: i,
|
|
1172
|
+
addMiddleware: l
|
|
554
1173
|
}) => {
|
|
555
|
-
|
|
1174
|
+
s({
|
|
556
1175
|
vite: {
|
|
557
1176
|
plugins: [
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
1177
|
+
Sr(
|
|
1178
|
+
e.accessToken,
|
|
1179
|
+
e.useCustomApi,
|
|
1180
|
+
e.apiOptions
|
|
562
1181
|
),
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
1182
|
+
Mr(
|
|
1183
|
+
e.componentsDir,
|
|
1184
|
+
e.components,
|
|
1185
|
+
e.enableFallbackComponent,
|
|
1186
|
+
e.customFallbackComponent
|
|
568
1187
|
),
|
|
569
|
-
|
|
1188
|
+
Pr(e),
|
|
1189
|
+
Fr()
|
|
570
1190
|
]
|
|
571
1191
|
}
|
|
572
|
-
}),
|
|
1192
|
+
}), r(
|
|
573
1193
|
"page-ssr",
|
|
574
1194
|
`
|
|
575
1195
|
import { storyblokApiInstance } from "virtual:storyblok-init";
|
|
576
1196
|
globalThis.storyblokApiInstance = storyblokApiInstance;
|
|
577
1197
|
`
|
|
578
|
-
),
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
n
|
|
584
|
-
)});`;
|
|
585
|
-
} else
|
|
586
|
-
a = "const storyblokInstance = new StoryblokBridge()";
|
|
587
|
-
e(
|
|
588
|
-
"page",
|
|
589
|
-
`
|
|
590
|
-
import { loadStoryblokBridge } from "@storyblok/astro";
|
|
1198
|
+
), e.bridge && (r(
|
|
1199
|
+
"page",
|
|
1200
|
+
`
|
|
1201
|
+
import { loadStoryblokBridge, handleStoryblokMessage } from "@storyblok/astro";
|
|
1202
|
+
import { bridgeOptions } from "virtual:storyblok-bridge";
|
|
591
1203
|
loadStoryblokBridge().then(() => {
|
|
592
1204
|
const { StoryblokBridge, location } = window;
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
location.reload(true);
|
|
598
|
-
}
|
|
599
|
-
});
|
|
1205
|
+
if(bridgeOptions){
|
|
1206
|
+
const storyblokInstance = new StoryblokBridge(bridgeOptions);
|
|
1207
|
+
storyblokInstance.on(["published", "change","input"], handleStoryblokMessage);
|
|
1208
|
+
};
|
|
600
1209
|
});
|
|
601
1210
|
`
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
1211
|
+
), l({
|
|
1212
|
+
entrypoint: "@storyblok/astro/middleware.ts",
|
|
1213
|
+
order: "pre"
|
|
1214
|
+
})), i("@storyblok/astro/toolbarApp.ts");
|
|
605
1215
|
}
|
|
606
1216
|
}
|
|
607
1217
|
};
|
|
608
1218
|
}
|
|
609
1219
|
export {
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
1220
|
+
wn as RichTextResolver,
|
|
1221
|
+
vn as RichTextSchema,
|
|
1222
|
+
Nn as default,
|
|
1223
|
+
En as handleStoryblokMessage,
|
|
1224
|
+
xn as loadStoryblokBridge,
|
|
1225
|
+
Pn as renderRichText,
|
|
1226
|
+
jn as storyblokEditable,
|
|
1227
|
+
Mn as useStoryblok,
|
|
1228
|
+
Rn as useStoryblokApi
|
|
617
1229
|
};
|