@weaverse/hydrogen 1.0.61 → 1.0.62
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/index.js +12 -660
- package/dist/index.mjs +3 -651
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -38,656 +38,8 @@ function createWeaverseInstance(weaverseData, components) {
|
|
|
38
38
|
return weaverse;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
// ../../node_modules/@stitches/core/dist/index.mjs
|
|
42
|
-
var t = "colors";
|
|
43
|
-
var n = "sizes";
|
|
44
|
-
var r = "space";
|
|
45
|
-
var i = { gap: r, gridGap: r, columnGap: r, gridColumnGap: r, rowGap: r, gridRowGap: r, inset: r, insetBlock: r, insetBlockEnd: r, insetBlockStart: r, insetInline: r, insetInlineEnd: r, insetInlineStart: r, margin: r, marginTop: r, marginRight: r, marginBottom: r, marginLeft: r, marginBlock: r, marginBlockEnd: r, marginBlockStart: r, marginInline: r, marginInlineEnd: r, marginInlineStart: r, padding: r, paddingTop: r, paddingRight: r, paddingBottom: r, paddingLeft: r, paddingBlock: r, paddingBlockEnd: r, paddingBlockStart: r, paddingInline: r, paddingInlineEnd: r, paddingInlineStart: r, top: r, right: r, bottom: r, left: r, scrollMargin: r, scrollMarginTop: r, scrollMarginRight: r, scrollMarginBottom: r, scrollMarginLeft: r, scrollMarginX: r, scrollMarginY: r, scrollMarginBlock: r, scrollMarginBlockEnd: r, scrollMarginBlockStart: r, scrollMarginInline: r, scrollMarginInlineEnd: r, scrollMarginInlineStart: r, scrollPadding: r, scrollPaddingTop: r, scrollPaddingRight: r, scrollPaddingBottom: r, scrollPaddingLeft: r, scrollPaddingX: r, scrollPaddingY: r, scrollPaddingBlock: r, scrollPaddingBlockEnd: r, scrollPaddingBlockStart: r, scrollPaddingInline: r, scrollPaddingInlineEnd: r, scrollPaddingInlineStart: r, fontSize: "fontSizes", background: t, backgroundColor: t, backgroundImage: t, borderImage: t, border: t, borderBlock: t, borderBlockEnd: t, borderBlockStart: t, borderBottom: t, borderBottomColor: t, borderColor: t, borderInline: t, borderInlineEnd: t, borderInlineStart: t, borderLeft: t, borderLeftColor: t, borderRight: t, borderRightColor: t, borderTop: t, borderTopColor: t, caretColor: t, color: t, columnRuleColor: t, fill: t, outline: t, outlineColor: t, stroke: t, textDecorationColor: t, fontFamily: "fonts", fontWeight: "fontWeights", lineHeight: "lineHeights", letterSpacing: "letterSpacings", blockSize: n, minBlockSize: n, maxBlockSize: n, inlineSize: n, minInlineSize: n, maxInlineSize: n, width: n, minWidth: n, maxWidth: n, height: n, minHeight: n, maxHeight: n, flexBasis: n, gridTemplateColumns: n, gridTemplateRows: n, borderWidth: "borderWidths", borderTopWidth: "borderWidths", borderRightWidth: "borderWidths", borderBottomWidth: "borderWidths", borderLeftWidth: "borderWidths", borderStyle: "borderStyles", borderTopStyle: "borderStyles", borderRightStyle: "borderStyles", borderBottomStyle: "borderStyles", borderLeftStyle: "borderStyles", borderRadius: "radii", borderTopLeftRadius: "radii", borderTopRightRadius: "radii", borderBottomRightRadius: "radii", borderBottomLeftRadius: "radii", boxShadow: "shadows", textShadow: "shadows", transition: "transitions", zIndex: "zIndices" };
|
|
46
|
-
var o = (e, t2) => "function" == typeof t2 ? { "()": Function.prototype.toString.call(t2) } : t2;
|
|
47
|
-
var l = () => {
|
|
48
|
-
const e = /* @__PURE__ */ Object.create(null);
|
|
49
|
-
return (t2, n2, ...r2) => {
|
|
50
|
-
const i2 = ((e2) => JSON.stringify(e2, o))(t2);
|
|
51
|
-
return i2 in e ? e[i2] : e[i2] = n2(t2, ...r2);
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
|
-
var s = Symbol.for("sxs.internal");
|
|
55
|
-
var a = (e, t2) => Object.defineProperties(e, Object.getOwnPropertyDescriptors(t2));
|
|
56
|
-
var c = (e) => {
|
|
57
|
-
for (const t2 in e)
|
|
58
|
-
return true;
|
|
59
|
-
return false;
|
|
60
|
-
};
|
|
61
|
-
var { hasOwnProperty: d } = Object.prototype;
|
|
62
|
-
var g = (e) => e.includes("-") ? e : e.replace(/[A-Z]/g, (e2) => "-" + e2.toLowerCase());
|
|
63
|
-
var p = /\s+(?![^()]*\))/;
|
|
64
|
-
var u = (e) => (t2) => e(..."string" == typeof t2 ? String(t2).split(p) : [t2]);
|
|
65
|
-
var h = { appearance: (e) => ({ WebkitAppearance: e, appearance: e }), backfaceVisibility: (e) => ({ WebkitBackfaceVisibility: e, backfaceVisibility: e }), backdropFilter: (e) => ({ WebkitBackdropFilter: e, backdropFilter: e }), backgroundClip: (e) => ({ WebkitBackgroundClip: e, backgroundClip: e }), boxDecorationBreak: (e) => ({ WebkitBoxDecorationBreak: e, boxDecorationBreak: e }), clipPath: (e) => ({ WebkitClipPath: e, clipPath: e }), content: (e) => ({ content: e.includes('"') || e.includes("'") || /^([A-Za-z]+\([^]*|[^]*-quote|inherit|initial|none|normal|revert|unset)$/.test(e) ? e : `"${e}"` }), hyphens: (e) => ({ WebkitHyphens: e, hyphens: e }), maskImage: (e) => ({ WebkitMaskImage: e, maskImage: e }), maskSize: (e) => ({ WebkitMaskSize: e, maskSize: e }), tabSize: (e) => ({ MozTabSize: e, tabSize: e }), textSizeAdjust: (e) => ({ WebkitTextSizeAdjust: e, textSizeAdjust: e }), userSelect: (e) => ({ WebkitUserSelect: e, userSelect: e }), marginBlock: u((e, t2) => ({ marginBlockStart: e, marginBlockEnd: t2 || e })), marginInline: u((e, t2) => ({ marginInlineStart: e, marginInlineEnd: t2 || e })), maxSize: u((e, t2) => ({ maxBlockSize: e, maxInlineSize: t2 || e })), minSize: u((e, t2) => ({ minBlockSize: e, minInlineSize: t2 || e })), paddingBlock: u((e, t2) => ({ paddingBlockStart: e, paddingBlockEnd: t2 || e })), paddingInline: u((e, t2) => ({ paddingInlineStart: e, paddingInlineEnd: t2 || e })) };
|
|
66
|
-
var f = /([\d.]+)([^]*)/;
|
|
67
|
-
var m = (e, t2) => e.length ? e.reduce((e2, n2) => (e2.push(...t2.map((e3) => e3.includes("&") ? e3.replace(/&/g, /[ +>|~]/.test(n2) && /&.*&/.test(e3) ? `:is(${n2})` : n2) : n2 + " " + e3)), e2), []) : t2;
|
|
68
|
-
var b = (e, t2) => e in S && "string" == typeof t2 ? t2.replace(/^((?:[^]*[^\w-])?)(fit-content|stretch)((?:[^\w-][^]*)?)$/, (t3, n2, r2, i2) => n2 + ("stretch" === r2 ? `-moz-available${i2};${g(e)}:${n2}-webkit-fill-available` : `-moz-fit-content${i2};${g(e)}:${n2}fit-content`) + i2) : String(t2);
|
|
69
|
-
var S = { blockSize: 1, height: 1, inlineSize: 1, maxBlockSize: 1, maxHeight: 1, maxInlineSize: 1, maxWidth: 1, minBlockSize: 1, minHeight: 1, minInlineSize: 1, minWidth: 1, width: 1 };
|
|
70
|
-
var k = (e) => e ? e + "-" : "";
|
|
71
|
-
var y = (e, t2, n2) => e.replace(/([+-])?((?:\d+(?:\.\d*)?|\.\d+)(?:[Ee][+-]?\d+)?)?(\$|--)([$\w-]+)/g, (e2, r2, i2, o2, l2) => "$" == o2 == !!i2 ? e2 : (r2 || "--" == o2 ? "calc(" : "") + "var(--" + ("$" === o2 ? k(t2) + (l2.includes("$") ? "" : k(n2)) + l2.replace(/\$/g, "-") : l2) + ")" + (r2 || "--" == o2 ? "*" + (r2 || "") + (i2 || "1") + ")" : ""));
|
|
72
|
-
var B = /\s*,\s*(?![^()]*\))/;
|
|
73
|
-
var $ = Object.prototype.toString;
|
|
74
|
-
var x = (e, t2, n2, r2, i2) => {
|
|
75
|
-
let o2, l2, s2;
|
|
76
|
-
const a2 = (e2, t3, n3) => {
|
|
77
|
-
let c2, d2;
|
|
78
|
-
const p2 = (e3) => {
|
|
79
|
-
for (c2 in e3) {
|
|
80
|
-
const x2 = 64 === c2.charCodeAt(0), z2 = x2 && Array.isArray(e3[c2]) ? e3[c2] : [e3[c2]];
|
|
81
|
-
for (d2 of z2) {
|
|
82
|
-
const e4 = /[A-Z]/.test(S2 = c2) ? S2 : S2.replace(/-[^]/g, (e5) => e5[1].toUpperCase()), z3 = "object" == typeof d2 && d2 && d2.toString === $ && (!r2.utils[e4] || !t3.length);
|
|
83
|
-
if (e4 in r2.utils && !z3) {
|
|
84
|
-
const t4 = r2.utils[e4];
|
|
85
|
-
if (t4 !== l2) {
|
|
86
|
-
l2 = t4, p2(t4(d2)), l2 = null;
|
|
87
|
-
continue;
|
|
88
|
-
}
|
|
89
|
-
} else if (e4 in h) {
|
|
90
|
-
const t4 = h[e4];
|
|
91
|
-
if (t4 !== s2) {
|
|
92
|
-
s2 = t4, p2(t4(d2)), s2 = null;
|
|
93
|
-
continue;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
if (x2 && (u2 = c2.slice(1) in r2.media ? "@media " + r2.media[c2.slice(1)] : c2, c2 = u2.replace(/\(\s*([\w-]+)\s*(=|<|<=|>|>=)\s*([\w-]+)\s*(?:(<|<=|>|>=)\s*([\w-]+)\s*)?\)/g, (e5, t4, n4, r3, i3, o3) => {
|
|
97
|
-
const l3 = f.test(t4), s3 = 0.0625 * (l3 ? -1 : 1), [a3, c3] = l3 ? [r3, t4] : [t4, r3];
|
|
98
|
-
return "(" + ("=" === n4[0] ? "" : ">" === n4[0] === l3 ? "max-" : "min-") + a3 + ":" + ("=" !== n4[0] && 1 === n4.length ? c3.replace(f, (e6, t5, r4) => Number(t5) + s3 * (">" === n4 ? 1 : -1) + r4) : c3) + (i3 ? ") and (" + (">" === i3[0] ? "min-" : "max-") + a3 + ":" + (1 === i3.length ? o3.replace(f, (e6, t5, n5) => Number(t5) + s3 * (">" === i3 ? -1 : 1) + n5) : o3) : "") + ")";
|
|
99
|
-
})), z3) {
|
|
100
|
-
const e5 = x2 ? n3.concat(c2) : [...n3], r3 = x2 ? [...t3] : m(t3, c2.split(B));
|
|
101
|
-
void 0 !== o2 && i2(I(...o2)), o2 = void 0, a2(d2, r3, e5);
|
|
102
|
-
} else
|
|
103
|
-
void 0 === o2 && (o2 = [[], t3, n3]), c2 = x2 || 36 !== c2.charCodeAt(0) ? c2 : `--${k(r2.prefix)}${c2.slice(1).replace(/\$/g, "-")}`, d2 = z3 ? d2 : "number" == typeof d2 ? d2 && e4 in R ? String(d2) + "px" : String(d2) : y(b(e4, null == d2 ? "" : d2), r2.prefix, r2.themeMap[e4]), o2[0].push(`${x2 ? `${c2} ` : `${g(c2)}:`}${d2}`);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
var u2, S2;
|
|
107
|
-
};
|
|
108
|
-
p2(e2), void 0 !== o2 && i2(I(...o2)), o2 = void 0;
|
|
109
|
-
};
|
|
110
|
-
a2(e, t2, n2);
|
|
111
|
-
};
|
|
112
|
-
var I = (e, t2, n2) => `${n2.map((e2) => `${e2}{`).join("")}${t2.length ? `${t2.join(",")}{` : ""}${e.join(";")}${t2.length ? "}" : ""}${Array(n2.length ? n2.length + 1 : 0).join("}")}`;
|
|
113
|
-
var R = { animationDelay: 1, animationDuration: 1, backgroundSize: 1, blockSize: 1, border: 1, borderBlock: 1, borderBlockEnd: 1, borderBlockEndWidth: 1, borderBlockStart: 1, borderBlockStartWidth: 1, borderBlockWidth: 1, borderBottom: 1, borderBottomLeftRadius: 1, borderBottomRightRadius: 1, borderBottomWidth: 1, borderEndEndRadius: 1, borderEndStartRadius: 1, borderInlineEnd: 1, borderInlineEndWidth: 1, borderInlineStart: 1, borderInlineStartWidth: 1, borderInlineWidth: 1, borderLeft: 1, borderLeftWidth: 1, borderRadius: 1, borderRight: 1, borderRightWidth: 1, borderSpacing: 1, borderStartEndRadius: 1, borderStartStartRadius: 1, borderTop: 1, borderTopLeftRadius: 1, borderTopRightRadius: 1, borderTopWidth: 1, borderWidth: 1, bottom: 1, columnGap: 1, columnRule: 1, columnRuleWidth: 1, columnWidth: 1, containIntrinsicSize: 1, flexBasis: 1, fontSize: 1, gap: 1, gridAutoColumns: 1, gridAutoRows: 1, gridTemplateColumns: 1, gridTemplateRows: 1, height: 1, inlineSize: 1, inset: 1, insetBlock: 1, insetBlockEnd: 1, insetBlockStart: 1, insetInline: 1, insetInlineEnd: 1, insetInlineStart: 1, left: 1, letterSpacing: 1, margin: 1, marginBlock: 1, marginBlockEnd: 1, marginBlockStart: 1, marginBottom: 1, marginInline: 1, marginInlineEnd: 1, marginInlineStart: 1, marginLeft: 1, marginRight: 1, marginTop: 1, maxBlockSize: 1, maxHeight: 1, maxInlineSize: 1, maxWidth: 1, minBlockSize: 1, minHeight: 1, minInlineSize: 1, minWidth: 1, offsetDistance: 1, offsetRotate: 1, outline: 1, outlineOffset: 1, outlineWidth: 1, overflowClipMargin: 1, padding: 1, paddingBlock: 1, paddingBlockEnd: 1, paddingBlockStart: 1, paddingBottom: 1, paddingInline: 1, paddingInlineEnd: 1, paddingInlineStart: 1, paddingLeft: 1, paddingRight: 1, paddingTop: 1, perspective: 1, right: 1, rowGap: 1, scrollMargin: 1, scrollMarginBlock: 1, scrollMarginBlockEnd: 1, scrollMarginBlockStart: 1, scrollMarginBottom: 1, scrollMarginInline: 1, scrollMarginInlineEnd: 1, scrollMarginInlineStart: 1, scrollMarginLeft: 1, scrollMarginRight: 1, scrollMarginTop: 1, scrollPadding: 1, scrollPaddingBlock: 1, scrollPaddingBlockEnd: 1, scrollPaddingBlockStart: 1, scrollPaddingBottom: 1, scrollPaddingInline: 1, scrollPaddingInlineEnd: 1, scrollPaddingInlineStart: 1, scrollPaddingLeft: 1, scrollPaddingRight: 1, scrollPaddingTop: 1, shapeMargin: 1, textDecoration: 1, textDecorationThickness: 1, textIndent: 1, textUnderlineOffset: 1, top: 1, transitionDelay: 1, transitionDuration: 1, verticalAlign: 1, width: 1, wordSpacing: 1 };
|
|
114
|
-
var z = (e) => String.fromCharCode(e + (e > 25 ? 39 : 97));
|
|
115
|
-
var W = (e) => ((e2) => {
|
|
116
|
-
let t2, n2 = "";
|
|
117
|
-
for (t2 = Math.abs(e2); t2 > 52; t2 = t2 / 52 | 0)
|
|
118
|
-
n2 = z(t2 % 52) + n2;
|
|
119
|
-
return z(t2 % 52) + n2;
|
|
120
|
-
})(((e2, t2) => {
|
|
121
|
-
let n2 = t2.length;
|
|
122
|
-
for (; n2; )
|
|
123
|
-
e2 = 33 * e2 ^ t2.charCodeAt(--n2);
|
|
124
|
-
return e2;
|
|
125
|
-
})(5381, JSON.stringify(e)) >>> 0);
|
|
126
|
-
var j = ["themed", "global", "styled", "onevar", "resonevar", "allvar", "inline"];
|
|
127
|
-
var E = (e) => {
|
|
128
|
-
if (e.href && !e.href.startsWith(location.origin))
|
|
129
|
-
return false;
|
|
130
|
-
try {
|
|
131
|
-
return !!e.cssRules;
|
|
132
|
-
} catch (e2) {
|
|
133
|
-
return false;
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
var T = (e) => {
|
|
137
|
-
let t2;
|
|
138
|
-
const n2 = () => {
|
|
139
|
-
const { cssRules: e2 } = t2.sheet;
|
|
140
|
-
return [].map.call(e2, (n3, r3) => {
|
|
141
|
-
const { cssText: i2 } = n3;
|
|
142
|
-
let o2 = "";
|
|
143
|
-
if (i2.startsWith("--sxs"))
|
|
144
|
-
return "";
|
|
145
|
-
if (e2[r3 - 1] && (o2 = e2[r3 - 1].cssText).startsWith("--sxs")) {
|
|
146
|
-
if (!n3.cssRules.length)
|
|
147
|
-
return "";
|
|
148
|
-
for (const e3 in t2.rules)
|
|
149
|
-
if (t2.rules[e3].group === n3)
|
|
150
|
-
return `--sxs{--sxs:${[...t2.rules[e3].cache].join(" ")}}${i2}`;
|
|
151
|
-
return n3.cssRules.length ? `${o2}${i2}` : "";
|
|
152
|
-
}
|
|
153
|
-
return i2;
|
|
154
|
-
}).join("");
|
|
155
|
-
}, r2 = () => {
|
|
156
|
-
if (t2) {
|
|
157
|
-
const { rules: e2, sheet: n3 } = t2;
|
|
158
|
-
if (!n3.deleteRule) {
|
|
159
|
-
for (; 3 === Object(Object(n3.cssRules)[0]).type; )
|
|
160
|
-
n3.cssRules.splice(0, 1);
|
|
161
|
-
n3.cssRules = [];
|
|
162
|
-
}
|
|
163
|
-
for (const t3 in e2)
|
|
164
|
-
delete e2[t3];
|
|
165
|
-
}
|
|
166
|
-
const i2 = Object(e).styleSheets || [];
|
|
167
|
-
for (const e2 of i2)
|
|
168
|
-
if (E(e2)) {
|
|
169
|
-
for (let i3 = 0, o3 = e2.cssRules; o3[i3]; ++i3) {
|
|
170
|
-
const l3 = Object(o3[i3]);
|
|
171
|
-
if (1 !== l3.type)
|
|
172
|
-
continue;
|
|
173
|
-
const s2 = Object(o3[i3 + 1]);
|
|
174
|
-
if (4 !== s2.type)
|
|
175
|
-
continue;
|
|
176
|
-
++i3;
|
|
177
|
-
const { cssText: a2 } = l3;
|
|
178
|
-
if (!a2.startsWith("--sxs"))
|
|
179
|
-
continue;
|
|
180
|
-
const c2 = a2.slice(14, -3).trim().split(/\s+/), d2 = j[c2[0]];
|
|
181
|
-
d2 && (t2 || (t2 = { sheet: e2, reset: r2, rules: {}, toString: n2 }), t2.rules[d2] = { group: s2, index: i3, cache: new Set(c2) });
|
|
182
|
-
}
|
|
183
|
-
if (t2)
|
|
184
|
-
break;
|
|
185
|
-
}
|
|
186
|
-
if (!t2) {
|
|
187
|
-
const i3 = (e2, t3) => ({ type: t3, cssRules: [], insertRule(e3, t4) {
|
|
188
|
-
this.cssRules.splice(t4, 0, i3(e3, { import: 3, undefined: 1 }[(e3.toLowerCase().match(/^@([a-z]+)/) || [])[1]] || 4));
|
|
189
|
-
}, get cssText() {
|
|
190
|
-
return "@media{}" === e2 ? `@media{${[].map.call(this.cssRules, (e3) => e3.cssText).join("")}}` : e2;
|
|
191
|
-
} });
|
|
192
|
-
t2 = { sheet: e ? (e.head || e).appendChild(document.createElement("style")).sheet : i3("", "text/css"), rules: {}, reset: r2, toString: n2 };
|
|
193
|
-
}
|
|
194
|
-
const { sheet: o2, rules: l2 } = t2;
|
|
195
|
-
for (let e2 = j.length - 1; e2 >= 0; --e2) {
|
|
196
|
-
const t3 = j[e2];
|
|
197
|
-
if (!l2[t3]) {
|
|
198
|
-
const n3 = j[e2 + 1], r3 = l2[n3] ? l2[n3].index : o2.cssRules.length;
|
|
199
|
-
o2.insertRule("@media{}", r3), o2.insertRule(`--sxs{--sxs:${e2}}`, r3), l2[t3] = { group: o2.cssRules[r3 + 1], index: r3, cache: /* @__PURE__ */ new Set([e2]) };
|
|
200
|
-
}
|
|
201
|
-
v(l2[t3]);
|
|
202
|
-
}
|
|
203
|
-
};
|
|
204
|
-
return r2(), t2;
|
|
205
|
-
};
|
|
206
|
-
var v = (e) => {
|
|
207
|
-
const t2 = e.group;
|
|
208
|
-
let n2 = t2.cssRules.length;
|
|
209
|
-
e.apply = (e2) => {
|
|
210
|
-
try {
|
|
211
|
-
t2.insertRule(e2, n2), ++n2;
|
|
212
|
-
} catch (e3) {
|
|
213
|
-
}
|
|
214
|
-
};
|
|
215
|
-
};
|
|
216
|
-
var M = Symbol();
|
|
217
|
-
var w = l();
|
|
218
|
-
var C = (e, t2) => w(e, () => (...n2) => {
|
|
219
|
-
let r2 = { type: null, composers: /* @__PURE__ */ new Set() };
|
|
220
|
-
for (const t3 of n2)
|
|
221
|
-
if (null != t3)
|
|
222
|
-
if (t3[s]) {
|
|
223
|
-
null == r2.type && (r2.type = t3[s].type);
|
|
224
|
-
for (const e2 of t3[s].composers)
|
|
225
|
-
r2.composers.add(e2);
|
|
226
|
-
} else
|
|
227
|
-
t3.constructor !== Object || t3.$$typeof ? null == r2.type && (r2.type = t3) : r2.composers.add(P(t3, e));
|
|
228
|
-
return null == r2.type && (r2.type = "span"), r2.composers.size || r2.composers.add(["PJLV", {}, [], [], {}, []]), L(e, r2, t2);
|
|
229
|
-
});
|
|
230
|
-
var P = ({ variants: e, compoundVariants: t2, defaultVariants: n2, ...r2 }, i2) => {
|
|
231
|
-
const o2 = `${k(i2.prefix)}c-${W(r2)}`, l2 = [], s2 = [], a2 = /* @__PURE__ */ Object.create(null), g2 = [];
|
|
232
|
-
for (const e2 in n2)
|
|
233
|
-
a2[e2] = String(n2[e2]);
|
|
234
|
-
if ("object" == typeof e && e)
|
|
235
|
-
for (const t3 in e) {
|
|
236
|
-
p2 = a2, u2 = t3, d.call(p2, u2) || (a2[t3] = "undefined");
|
|
237
|
-
const n3 = e[t3];
|
|
238
|
-
for (const e2 in n3) {
|
|
239
|
-
const r3 = { [t3]: String(e2) };
|
|
240
|
-
"undefined" === String(e2) && g2.push(t3);
|
|
241
|
-
const i3 = n3[e2], o3 = [r3, i3, !c(i3)];
|
|
242
|
-
l2.push(o3);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
var p2, u2;
|
|
246
|
-
if ("object" == typeof t2 && t2)
|
|
247
|
-
for (const e2 of t2) {
|
|
248
|
-
let { css: t3, ...n3 } = e2;
|
|
249
|
-
t3 = "object" == typeof t3 && t3 || {};
|
|
250
|
-
for (const e3 in n3)
|
|
251
|
-
n3[e3] = String(n3[e3]);
|
|
252
|
-
const r3 = [n3, t3, !c(t3)];
|
|
253
|
-
s2.push(r3);
|
|
254
|
-
}
|
|
255
|
-
return [o2, r2, l2, s2, a2, g2];
|
|
256
|
-
};
|
|
257
|
-
var L = (e, t2, n2) => {
|
|
258
|
-
const [r2, i2, o2, l2] = O(t2.composers), c2 = "function" == typeof t2.type || t2.type.$$typeof ? ((e2) => {
|
|
259
|
-
function t3() {
|
|
260
|
-
for (let n3 = 0; n3 < t3[M].length; n3++) {
|
|
261
|
-
const [r3, i3] = t3[M][n3];
|
|
262
|
-
e2.rules[r3].apply(i3);
|
|
263
|
-
}
|
|
264
|
-
return t3[M] = [], null;
|
|
265
|
-
}
|
|
266
|
-
return t3[M] = [], t3.rules = {}, j.forEach((e3) => t3.rules[e3] = { apply: (n3) => t3[M].push([e3, n3]) }), t3;
|
|
267
|
-
})(n2) : null, d2 = (c2 || n2).rules, g2 = `.${r2}${i2.length > 1 ? `:where(.${i2.slice(1).join(".")})` : ""}`, p2 = (s2) => {
|
|
268
|
-
s2 = "object" == typeof s2 && s2 || D;
|
|
269
|
-
const { css: a2, ...p3 } = s2, u2 = {};
|
|
270
|
-
for (const e2 in o2)
|
|
271
|
-
if (delete p3[e2], e2 in s2) {
|
|
272
|
-
let t3 = s2[e2];
|
|
273
|
-
"object" == typeof t3 && t3 ? u2[e2] = { "@initial": o2[e2], ...t3 } : (t3 = String(t3), u2[e2] = "undefined" !== t3 || l2.has(e2) ? t3 : o2[e2]);
|
|
274
|
-
} else
|
|
275
|
-
u2[e2] = o2[e2];
|
|
276
|
-
const h2 = /* @__PURE__ */ new Set([...i2]);
|
|
277
|
-
for (const [r3, i3, o3, l3] of t2.composers) {
|
|
278
|
-
n2.rules.styled.cache.has(r3) || (n2.rules.styled.cache.add(r3), x(i3, [`.${r3}`], [], e, (e2) => {
|
|
279
|
-
d2.styled.apply(e2);
|
|
280
|
-
}));
|
|
281
|
-
const t3 = A(o3, u2, e.media), s3 = A(l3, u2, e.media, true);
|
|
282
|
-
for (const i4 of t3)
|
|
283
|
-
if (void 0 !== i4)
|
|
284
|
-
for (const [t4, o4, l4] of i4) {
|
|
285
|
-
const i5 = `${r3}-${W(o4)}-${t4}`;
|
|
286
|
-
h2.add(i5);
|
|
287
|
-
const s4 = (l4 ? n2.rules.resonevar : n2.rules.onevar).cache, a3 = l4 ? d2.resonevar : d2.onevar;
|
|
288
|
-
s4.has(i5) || (s4.add(i5), x(o4, [`.${i5}`], [], e, (e2) => {
|
|
289
|
-
a3.apply(e2);
|
|
290
|
-
}));
|
|
291
|
-
}
|
|
292
|
-
for (const t4 of s3)
|
|
293
|
-
if (void 0 !== t4)
|
|
294
|
-
for (const [i4, o4] of t4) {
|
|
295
|
-
const t5 = `${r3}-${W(o4)}-${i4}`;
|
|
296
|
-
h2.add(t5), n2.rules.allvar.cache.has(t5) || (n2.rules.allvar.cache.add(t5), x(o4, [`.${t5}`], [], e, (e2) => {
|
|
297
|
-
d2.allvar.apply(e2);
|
|
298
|
-
}));
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
if ("object" == typeof a2 && a2) {
|
|
302
|
-
const t3 = `${r2}-i${W(a2)}-css`;
|
|
303
|
-
h2.add(t3), n2.rules.inline.cache.has(t3) || (n2.rules.inline.cache.add(t3), x(a2, [`.${t3}`], [], e, (e2) => {
|
|
304
|
-
d2.inline.apply(e2);
|
|
305
|
-
}));
|
|
306
|
-
}
|
|
307
|
-
for (const e2 of String(s2.className || "").trim().split(/\s+/))
|
|
308
|
-
e2 && h2.add(e2);
|
|
309
|
-
const f2 = p3.className = [...h2].join(" ");
|
|
310
|
-
return { type: t2.type, className: f2, selector: g2, props: p3, toString: () => f2, deferredInjector: c2 };
|
|
311
|
-
};
|
|
312
|
-
return a(p2, { className: r2, selector: g2, [s]: t2, toString: () => (n2.rules.styled.cache.has(r2) || p2(), r2) });
|
|
313
|
-
};
|
|
314
|
-
var O = (e) => {
|
|
315
|
-
let t2 = "";
|
|
316
|
-
const n2 = [], r2 = {}, i2 = [];
|
|
317
|
-
for (const [o2, , , , l2, s2] of e) {
|
|
318
|
-
"" === t2 && (t2 = o2), n2.push(o2), i2.push(...s2);
|
|
319
|
-
for (const e2 in l2) {
|
|
320
|
-
const t3 = l2[e2];
|
|
321
|
-
(void 0 === r2[e2] || "undefined" !== t3 || s2.includes(t3)) && (r2[e2] = t3);
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
return [t2, n2, r2, new Set(i2)];
|
|
325
|
-
};
|
|
326
|
-
var A = (e, t2, n2, r2) => {
|
|
327
|
-
const i2 = [];
|
|
328
|
-
e:
|
|
329
|
-
for (let [o2, l2, s2] of e) {
|
|
330
|
-
if (s2)
|
|
331
|
-
continue;
|
|
332
|
-
let e2, a2 = 0, c2 = false;
|
|
333
|
-
for (e2 in o2) {
|
|
334
|
-
const r3 = o2[e2];
|
|
335
|
-
let i3 = t2[e2];
|
|
336
|
-
if (i3 !== r3) {
|
|
337
|
-
if ("object" != typeof i3 || !i3)
|
|
338
|
-
continue e;
|
|
339
|
-
{
|
|
340
|
-
let e3, t3, o3 = 0;
|
|
341
|
-
for (const l3 in i3) {
|
|
342
|
-
if (r3 === String(i3[l3])) {
|
|
343
|
-
if ("@initial" !== l3) {
|
|
344
|
-
const e4 = l3.slice(1);
|
|
345
|
-
(t3 = t3 || []).push(e4 in n2 ? n2[e4] : l3.replace(/^@media ?/, "")), c2 = true;
|
|
346
|
-
}
|
|
347
|
-
a2 += o3, e3 = true;
|
|
348
|
-
}
|
|
349
|
-
++o3;
|
|
350
|
-
}
|
|
351
|
-
if (t3 && t3.length && (l2 = { ["@media " + t3.join(", ")]: l2 }), !e3)
|
|
352
|
-
continue e;
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
(i2[a2] = i2[a2] || []).push([r2 ? "cv" : `${e2}-${o2[e2]}`, l2, c2]);
|
|
357
|
-
}
|
|
358
|
-
return i2;
|
|
359
|
-
};
|
|
360
|
-
var D = {};
|
|
361
|
-
var H = l();
|
|
362
|
-
var N = (e, t2) => H(e, () => (...n2) => {
|
|
363
|
-
const r2 = () => {
|
|
364
|
-
for (let r3 of n2) {
|
|
365
|
-
r3 = "object" == typeof r3 && r3 || {};
|
|
366
|
-
let n3 = W(r3);
|
|
367
|
-
if (!t2.rules.global.cache.has(n3)) {
|
|
368
|
-
if (t2.rules.global.cache.add(n3), "@import" in r3) {
|
|
369
|
-
let e2 = [].indexOf.call(t2.sheet.cssRules, t2.rules.themed.group) - 1;
|
|
370
|
-
for (let n4 of [].concat(r3["@import"]))
|
|
371
|
-
n4 = n4.includes('"') || n4.includes("'") ? n4 : `"${n4}"`, t2.sheet.insertRule(`@import ${n4};`, e2++);
|
|
372
|
-
delete r3["@import"];
|
|
373
|
-
}
|
|
374
|
-
x(r3, [], [], e, (e2) => {
|
|
375
|
-
t2.rules.global.apply(e2);
|
|
376
|
-
});
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
return "";
|
|
380
|
-
};
|
|
381
|
-
return a(r2, { toString: r2 });
|
|
382
|
-
});
|
|
383
|
-
var V = l();
|
|
384
|
-
var G = (e, t2) => V(e, () => (n2) => {
|
|
385
|
-
const r2 = `${k(e.prefix)}k-${W(n2)}`, i2 = () => {
|
|
386
|
-
if (!t2.rules.global.cache.has(r2)) {
|
|
387
|
-
t2.rules.global.cache.add(r2);
|
|
388
|
-
const i3 = [];
|
|
389
|
-
x(n2, [], [], e, (e2) => i3.push(e2));
|
|
390
|
-
const o2 = `@keyframes ${r2}{${i3.join("")}}`;
|
|
391
|
-
t2.rules.global.apply(o2);
|
|
392
|
-
}
|
|
393
|
-
return r2;
|
|
394
|
-
};
|
|
395
|
-
return a(i2, { get name() {
|
|
396
|
-
return i2();
|
|
397
|
-
}, toString: i2 });
|
|
398
|
-
});
|
|
399
|
-
var F = class {
|
|
400
|
-
constructor(e, t2, n2, r2) {
|
|
401
|
-
this.token = null == e ? "" : String(e), this.value = null == t2 ? "" : String(t2), this.scale = null == n2 ? "" : String(n2), this.prefix = null == r2 ? "" : String(r2);
|
|
402
|
-
}
|
|
403
|
-
get computedValue() {
|
|
404
|
-
return "var(" + this.variable + ")";
|
|
405
|
-
}
|
|
406
|
-
get variable() {
|
|
407
|
-
return "--" + k(this.prefix) + k(this.scale) + this.token;
|
|
408
|
-
}
|
|
409
|
-
toString() {
|
|
410
|
-
return this.computedValue;
|
|
411
|
-
}
|
|
412
|
-
};
|
|
413
|
-
var J = l();
|
|
414
|
-
var U = (e, t2) => J(e, () => (n2, r2) => {
|
|
415
|
-
r2 = "object" == typeof n2 && n2 || Object(r2);
|
|
416
|
-
const i2 = `.${n2 = (n2 = "string" == typeof n2 ? n2 : "") || `${k(e.prefix)}t-${W(r2)}`}`, o2 = {}, l2 = [];
|
|
417
|
-
for (const t3 in r2) {
|
|
418
|
-
o2[t3] = {};
|
|
419
|
-
for (const n3 in r2[t3]) {
|
|
420
|
-
const i3 = `--${k(e.prefix)}${t3}-${n3}`, s3 = y(String(r2[t3][n3]), e.prefix, t3);
|
|
421
|
-
o2[t3][n3] = new F(n3, s3, t3, e.prefix), l2.push(`${i3}:${s3}`);
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
const s2 = () => {
|
|
425
|
-
if (l2.length && !t2.rules.themed.cache.has(n2)) {
|
|
426
|
-
t2.rules.themed.cache.add(n2);
|
|
427
|
-
const i3 = `${r2 === e.theme ? ":root," : ""}.${n2}{${l2.join(";")}}`;
|
|
428
|
-
t2.rules.themed.apply(i3);
|
|
429
|
-
}
|
|
430
|
-
return n2;
|
|
431
|
-
};
|
|
432
|
-
return { ...o2, get className() {
|
|
433
|
-
return s2();
|
|
434
|
-
}, selector: i2, toString: s2 };
|
|
435
|
-
});
|
|
436
|
-
var Z = l();
|
|
437
|
-
var X = (e) => {
|
|
438
|
-
let t2 = false;
|
|
439
|
-
const n2 = Z(e, (e2) => {
|
|
440
|
-
t2 = true;
|
|
441
|
-
const n3 = "prefix" in (e2 = "object" == typeof e2 && e2 || {}) ? String(e2.prefix) : "", r2 = "object" == typeof e2.media && e2.media || {}, o2 = "object" == typeof e2.root ? e2.root || null : globalThis.document || null, l2 = "object" == typeof e2.theme && e2.theme || {}, s2 = { prefix: n3, media: r2, theme: l2, themeMap: "object" == typeof e2.themeMap && e2.themeMap || { ...i }, utils: "object" == typeof e2.utils && e2.utils || {} }, a2 = T(o2), c2 = { css: C(s2, a2), globalCss: N(s2, a2), keyframes: G(s2, a2), createTheme: U(s2, a2), reset() {
|
|
442
|
-
a2.reset(), c2.theme.toString();
|
|
443
|
-
}, theme: {}, sheet: a2, config: s2, prefix: n3, getCssText: a2.toString, toString: a2.toString };
|
|
444
|
-
return String(c2.theme = c2.createTheme(l2)), c2;
|
|
445
|
-
});
|
|
446
|
-
return t2 || n2.reset(), n2;
|
|
447
|
-
};
|
|
448
|
-
|
|
449
|
-
// ../core/dist/index.mjs
|
|
450
|
-
var loadScript = (src) => {
|
|
451
|
-
return new Promise((resolve, reject) => {
|
|
452
|
-
let script = document.createElement("script");
|
|
453
|
-
script.src = src;
|
|
454
|
-
script.onload = resolve;
|
|
455
|
-
script.onerror = reject;
|
|
456
|
-
script.defer = true;
|
|
457
|
-
document.body.appendChild(script);
|
|
458
|
-
});
|
|
459
|
-
};
|
|
460
|
-
var isReactNative = typeof navigator === "object" && navigator.product === "ReactNative";
|
|
461
|
-
var isBrowser2 = typeof window !== "undefined" && !isReactNative;
|
|
462
|
-
var isIframe = isBrowser2 && window.top !== window.self;
|
|
463
|
-
function merge(target, source) {
|
|
464
|
-
let t2 = { ...target || {} };
|
|
465
|
-
for (let key of Object.keys(source)) {
|
|
466
|
-
if (source[key] instanceof Object && !Array.isArray(source[key])) {
|
|
467
|
-
Object.assign(source[key], merge(t2[key], source[key]));
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
Object.assign(t2 || {}, source);
|
|
471
|
-
return t2;
|
|
472
|
-
}
|
|
473
|
-
function getItemDefaultData(item) {
|
|
474
|
-
let platformType = item.weaverse.platformType;
|
|
475
|
-
if (platformType === "shopify-section") {
|
|
476
|
-
return { ...item.Element?.Component?.defaultProps };
|
|
477
|
-
}
|
|
478
|
-
let groups = item.Element?.schema?.inspector;
|
|
479
|
-
let inputs = groups?.flatMap((group) => group.inputs);
|
|
480
|
-
return inputs?.reduce((a2, { defaultValue, name }) => {
|
|
481
|
-
if (name && defaultValue !== null && defaultValue !== void 0) {
|
|
482
|
-
a2[name] = defaultValue;
|
|
483
|
-
}
|
|
484
|
-
return a2;
|
|
485
|
-
}, {});
|
|
486
|
-
}
|
|
487
|
-
var stitchesUtils = {
|
|
488
|
-
// Abbreviated margin properties
|
|
489
|
-
m: (value) => ({
|
|
490
|
-
margin: value
|
|
491
|
-
}),
|
|
492
|
-
mt: (value) => ({
|
|
493
|
-
marginTop: value
|
|
494
|
-
}),
|
|
495
|
-
mr: (value) => ({
|
|
496
|
-
marginRight: value
|
|
497
|
-
}),
|
|
498
|
-
mb: (value) => ({
|
|
499
|
-
marginBottom: value
|
|
500
|
-
}),
|
|
501
|
-
ml: (value) => ({
|
|
502
|
-
marginLeft: value
|
|
503
|
-
}),
|
|
504
|
-
mx: (value) => ({
|
|
505
|
-
marginLeft: value,
|
|
506
|
-
marginRight: value
|
|
507
|
-
}),
|
|
508
|
-
my: (value) => ({
|
|
509
|
-
marginTop: value,
|
|
510
|
-
marginBottom: value
|
|
511
|
-
}),
|
|
512
|
-
// A property for applying width/height together
|
|
513
|
-
size: (value) => ({
|
|
514
|
-
width: value,
|
|
515
|
-
height: value
|
|
516
|
-
}),
|
|
517
|
-
// Abbreviated padding properties
|
|
518
|
-
px: (value) => ({
|
|
519
|
-
paddingLeft: value,
|
|
520
|
-
paddingRight: value
|
|
521
|
-
}),
|
|
522
|
-
py: (value) => ({
|
|
523
|
-
paddingTop: value,
|
|
524
|
-
paddingBottom: value
|
|
525
|
-
})
|
|
526
|
-
};
|
|
527
|
-
var WeaverseItemStore = class {
|
|
528
|
-
constructor(itemData, weaverse) {
|
|
529
|
-
this.listeners = /* @__PURE__ */ new Set();
|
|
530
|
-
this.ref = { current: null };
|
|
531
|
-
this.stitchesClass = "";
|
|
532
|
-
this._store = { id: "", type: "" };
|
|
533
|
-
this.setData = (update) => {
|
|
534
|
-
this.data = Object.assign(this.data, update);
|
|
535
|
-
this.triggerUpdate();
|
|
536
|
-
return this.data;
|
|
537
|
-
};
|
|
538
|
-
this.subscribe = (fn) => {
|
|
539
|
-
this.listeners.add(fn);
|
|
540
|
-
};
|
|
541
|
-
this.unsubscribe = (fn) => {
|
|
542
|
-
this.listeners.delete(fn);
|
|
543
|
-
};
|
|
544
|
-
this.triggerUpdate = () => {
|
|
545
|
-
this.listeners.forEach((fn) => {
|
|
546
|
-
return fn(this.data);
|
|
547
|
-
});
|
|
548
|
-
};
|
|
549
|
-
let { type, id } = itemData;
|
|
550
|
-
this.weaverse = weaverse;
|
|
551
|
-
if (id && type) {
|
|
552
|
-
weaverse.itemInstances.set(id, this);
|
|
553
|
-
if (weaverse.platformType === "shopify-hydrogen") {
|
|
554
|
-
let { data, ...rest } = itemData;
|
|
555
|
-
this._store = { ...data, ...rest };
|
|
556
|
-
} else {
|
|
557
|
-
this._store = { ...itemData };
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
get _id() {
|
|
562
|
-
return this._store.id;
|
|
563
|
-
}
|
|
564
|
-
get _element() {
|
|
565
|
-
return this.ref.current;
|
|
566
|
-
}
|
|
567
|
-
get _flags() {
|
|
568
|
-
return this.Element?.schema?.flags || {};
|
|
569
|
-
}
|
|
570
|
-
get Element() {
|
|
571
|
-
return this.weaverse.elementInstances.get(this._store.type);
|
|
572
|
-
}
|
|
573
|
-
set data(update) {
|
|
574
|
-
this._store = { ...this.data, ...update };
|
|
575
|
-
}
|
|
576
|
-
get data() {
|
|
577
|
-
let defaultData = getItemDefaultData(this);
|
|
578
|
-
let defaultCss = this.Element?.defaultCss || {};
|
|
579
|
-
let currentCss = this._store.css || {};
|
|
580
|
-
let css = merge(defaultCss, currentCss);
|
|
581
|
-
let extraData = this.Element?.extraData;
|
|
582
|
-
return { ...defaultData, ...extraData, ...this._store, css };
|
|
583
|
-
}
|
|
584
|
-
};
|
|
585
|
-
var Weaverse2 = class {
|
|
586
|
-
/**
|
|
587
|
-
* constructor
|
|
588
|
-
* @param weaverseHost {string} Weaverse base URL that can provide by user/developer. for local development, use localhost:3000
|
|
589
|
-
* @param projectId {string} Weaverse project key to access project data via API
|
|
590
|
-
* @param data {WeaverseProjectDataType} Weaverse project data, by default, user can provide project data via React Component.
|
|
591
|
-
* @param mediaBreakPoints {object} Pass down custom media query breakpoints or just use the default.
|
|
592
|
-
* @param isDesignMode {boolean} check whether the sdk is isDesignMode or not
|
|
593
|
-
* @param ssrMode {boolean} Use in element to optionally render special HTML for hydration
|
|
594
|
-
* @param elementSchemas {Array<ElementSchema>} List of element schemas
|
|
595
|
-
* @param platformType {PlatformTypeEnum} Check the platform, shopify-section or react-ssr(hydrogen)
|
|
596
|
-
*/
|
|
597
|
-
constructor(params = {}) {
|
|
598
|
-
this.elementInstances = /* @__PURE__ */ new Map();
|
|
599
|
-
this.itemInstances = /* @__PURE__ */ new Map();
|
|
600
|
-
this.weaverseHost = "https://weaverse.io";
|
|
601
|
-
this.weaverseVersion = "";
|
|
602
|
-
this.projectId = "";
|
|
603
|
-
this.pageId = "";
|
|
604
|
-
this.internal = {};
|
|
605
|
-
this.data = {
|
|
606
|
-
rootId: "",
|
|
607
|
-
items: [],
|
|
608
|
-
script: { css: "", js: "" }
|
|
609
|
-
};
|
|
610
|
-
this.listeners = /* @__PURE__ */ new Set();
|
|
611
|
-
this.isDesignMode = false;
|
|
612
|
-
this.platformType = "shopify-section";
|
|
613
|
-
this.isPreviewMode = false;
|
|
614
|
-
this.ssrMode = false;
|
|
615
|
-
this.elementSchemas = [];
|
|
616
|
-
this.mediaBreakPoints = {
|
|
617
|
-
desktop: "all",
|
|
618
|
-
// max-width need to subtract 0.02px to prevent bug https://getbootstrap.com/docs/5.1/layout/breakpoints/#max-width
|
|
619
|
-
// tablet: "(max-width: 1023.98px)", // to set css for tablet, {'@tablet' : { // css }},
|
|
620
|
-
mobile: "(max-width: 767.98px)"
|
|
621
|
-
};
|
|
622
|
-
this.initStitches = (externalConfig = {}) => {
|
|
623
|
-
this.stitchesInstance = this.stitchesInstance || X({
|
|
624
|
-
prefix: "weaverse",
|
|
625
|
-
media: this.mediaBreakPoints,
|
|
626
|
-
utils: stitchesUtils,
|
|
627
|
-
...externalConfig
|
|
628
|
-
});
|
|
629
|
-
};
|
|
630
|
-
Object.entries(params).forEach(([k2, v2]) => {
|
|
631
|
-
let key = k2;
|
|
632
|
-
this[key] = v2 || this[key];
|
|
633
|
-
});
|
|
634
|
-
this.initProject();
|
|
635
|
-
this.initStitches();
|
|
636
|
-
}
|
|
637
|
-
/**
|
|
638
|
-
* Register the custom React Component to Weaverse, store it into Weaverse.elementInstances
|
|
639
|
-
* @param element {WeaverseElement} custom React Component
|
|
640
|
-
*/
|
|
641
|
-
registerElement(element) {
|
|
642
|
-
if (element?.type) {
|
|
643
|
-
if (!this.elementInstances.has(element.type)) {
|
|
644
|
-
this.elementInstances.set(element?.type, element);
|
|
645
|
-
}
|
|
646
|
-
} else {
|
|
647
|
-
console.error("Weaverse: registerElement: `type` is required");
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
|
-
subscribe(fn) {
|
|
651
|
-
this.listeners.add(fn);
|
|
652
|
-
}
|
|
653
|
-
unsubscribe(fn) {
|
|
654
|
-
this.listeners.delete(fn);
|
|
655
|
-
}
|
|
656
|
-
triggerUpdate() {
|
|
657
|
-
this.listeners.forEach((fn) => fn());
|
|
658
|
-
}
|
|
659
|
-
refreshAllItems() {
|
|
660
|
-
this.itemInstances.forEach((item) => {
|
|
661
|
-
item.triggerUpdate();
|
|
662
|
-
});
|
|
663
|
-
}
|
|
664
|
-
/**
|
|
665
|
-
* When applying new template,
|
|
666
|
-
* we need to reset the project data and re-initialize the project item data
|
|
667
|
-
* @param data {WeaverseProjectDataType}
|
|
668
|
-
*/
|
|
669
|
-
setProjectData(data) {
|
|
670
|
-
this.data = data;
|
|
671
|
-
this.initProject();
|
|
672
|
-
this.triggerUpdate();
|
|
673
|
-
}
|
|
674
|
-
/**
|
|
675
|
-
* Create new WeaverseItemStore instance for each item in project data
|
|
676
|
-
*/
|
|
677
|
-
initProject() {
|
|
678
|
-
const data = this.data;
|
|
679
|
-
if (data?.items) {
|
|
680
|
-
data.items.forEach((item) => {
|
|
681
|
-
if (!this.itemInstances.get(item.id)) {
|
|
682
|
-
return new WeaverseItemStore(item, this);
|
|
683
|
-
}
|
|
684
|
-
});
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
};
|
|
688
|
-
Weaverse2.WeaverseItemStore = WeaverseItemStore;
|
|
689
|
-
|
|
690
41
|
// src/hooks/use-studio.ts
|
|
42
|
+
import { isIframe, loadScript } from "@weaverse/react";
|
|
691
43
|
import { useEffect } from "react";
|
|
692
44
|
function useStudio(weaverse, themeSchema, navigate) {
|
|
693
45
|
useEffect(() => {
|
|
@@ -761,8 +113,8 @@ function hashKey(queryKey) {
|
|
|
761
113
|
function getRequestQueries(request) {
|
|
762
114
|
let url = new URL(request.url);
|
|
763
115
|
return Array.from(url.searchParams.entries()).reduce(
|
|
764
|
-
(q, [
|
|
765
|
-
q[
|
|
116
|
+
(q, [k, v]) => {
|
|
117
|
+
q[k] = v === "true" ? true : v === "false" ? false : v;
|
|
766
118
|
return q;
|
|
767
119
|
},
|
|
768
120
|
{}
|