@weaverse/hydrogen 1.0.36 → 1.0.37
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.d.ts +4 -2
- package/dist/index.js +683 -11
- package/dist/index.mjs +681 -13
- package/package.json +2 -3
package/dist/index.mjs
CHANGED
|
@@ -20,7 +20,6 @@ var createWeaverseHydrogenContext = ({ weaverseData }, components) => {
|
|
|
20
20
|
...config,
|
|
21
21
|
data: pageData,
|
|
22
22
|
pageId: pageData?.id,
|
|
23
|
-
isDesignMode: true,
|
|
24
23
|
platformType: "shopify-hydrogen"
|
|
25
24
|
});
|
|
26
25
|
Object.entries(components).forEach(([key, component]) => {
|
|
@@ -35,8 +34,670 @@ var createWeaverseHydrogenContext = ({ weaverseData }, components) => {
|
|
|
35
34
|
return weaverse;
|
|
36
35
|
};
|
|
37
36
|
|
|
37
|
+
// ../../node_modules/@stitches/core/dist/index.mjs
|
|
38
|
+
var t = "colors";
|
|
39
|
+
var n = "sizes";
|
|
40
|
+
var r = "space";
|
|
41
|
+
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" };
|
|
42
|
+
var o = (e, t2) => "function" == typeof t2 ? { "()": Function.prototype.toString.call(t2) } : t2;
|
|
43
|
+
var l = () => {
|
|
44
|
+
const e = /* @__PURE__ */ Object.create(null);
|
|
45
|
+
return (t2, n2, ...r2) => {
|
|
46
|
+
const i2 = ((e2) => JSON.stringify(e2, o))(t2);
|
|
47
|
+
return i2 in e ? e[i2] : e[i2] = n2(t2, ...r2);
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
var s = Symbol.for("sxs.internal");
|
|
51
|
+
var a = (e, t2) => Object.defineProperties(e, Object.getOwnPropertyDescriptors(t2));
|
|
52
|
+
var c = (e) => {
|
|
53
|
+
for (const t2 in e)
|
|
54
|
+
return true;
|
|
55
|
+
return false;
|
|
56
|
+
};
|
|
57
|
+
var { hasOwnProperty: d } = Object.prototype;
|
|
58
|
+
var g = (e) => e.includes("-") ? e : e.replace(/[A-Z]/g, (e2) => "-" + e2.toLowerCase());
|
|
59
|
+
var p = /\s+(?![^()]*\))/;
|
|
60
|
+
var u = (e) => (t2) => e(..."string" == typeof t2 ? String(t2).split(p) : [t2]);
|
|
61
|
+
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 })) };
|
|
62
|
+
var f = /([\d.]+)([^]*)/;
|
|
63
|
+
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;
|
|
64
|
+
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);
|
|
65
|
+
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 };
|
|
66
|
+
var k = (e) => e ? e + "-" : "";
|
|
67
|
+
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") + ")" : ""));
|
|
68
|
+
var B = /\s*,\s*(?![^()]*\))/;
|
|
69
|
+
var $ = Object.prototype.toString;
|
|
70
|
+
var x = (e, t2, n2, r2, i2) => {
|
|
71
|
+
let o2, l2, s2;
|
|
72
|
+
const a2 = (e2, t3, n3) => {
|
|
73
|
+
let c2, d2;
|
|
74
|
+
const p2 = (e3) => {
|
|
75
|
+
for (c2 in e3) {
|
|
76
|
+
const x2 = 64 === c2.charCodeAt(0), z2 = x2 && Array.isArray(e3[c2]) ? e3[c2] : [e3[c2]];
|
|
77
|
+
for (d2 of z2) {
|
|
78
|
+
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);
|
|
79
|
+
if (e4 in r2.utils && !z3) {
|
|
80
|
+
const t4 = r2.utils[e4];
|
|
81
|
+
if (t4 !== l2) {
|
|
82
|
+
l2 = t4, p2(t4(d2)), l2 = null;
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
} else if (e4 in h) {
|
|
86
|
+
const t4 = h[e4];
|
|
87
|
+
if (t4 !== s2) {
|
|
88
|
+
s2 = t4, p2(t4(d2)), s2 = null;
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
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) => {
|
|
93
|
+
const l3 = f.test(t4), s3 = 0.0625 * (l3 ? -1 : 1), [a3, c3] = l3 ? [r3, t4] : [t4, r3];
|
|
94
|
+
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) : "") + ")";
|
|
95
|
+
})), z3) {
|
|
96
|
+
const e5 = x2 ? n3.concat(c2) : [...n3], r3 = x2 ? [...t3] : m(t3, c2.split(B));
|
|
97
|
+
void 0 !== o2 && i2(I(...o2)), o2 = void 0, a2(d2, r3, e5);
|
|
98
|
+
} else
|
|
99
|
+
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}`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
var u2, S2;
|
|
103
|
+
};
|
|
104
|
+
p2(e2), void 0 !== o2 && i2(I(...o2)), o2 = void 0;
|
|
105
|
+
};
|
|
106
|
+
a2(e, t2, n2);
|
|
107
|
+
};
|
|
108
|
+
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("}")}`;
|
|
109
|
+
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 };
|
|
110
|
+
var z = (e) => String.fromCharCode(e + (e > 25 ? 39 : 97));
|
|
111
|
+
var W = (e) => ((e2) => {
|
|
112
|
+
let t2, n2 = "";
|
|
113
|
+
for (t2 = Math.abs(e2); t2 > 52; t2 = t2 / 52 | 0)
|
|
114
|
+
n2 = z(t2 % 52) + n2;
|
|
115
|
+
return z(t2 % 52) + n2;
|
|
116
|
+
})(((e2, t2) => {
|
|
117
|
+
let n2 = t2.length;
|
|
118
|
+
for (; n2; )
|
|
119
|
+
e2 = 33 * e2 ^ t2.charCodeAt(--n2);
|
|
120
|
+
return e2;
|
|
121
|
+
})(5381, JSON.stringify(e)) >>> 0);
|
|
122
|
+
var j = ["themed", "global", "styled", "onevar", "resonevar", "allvar", "inline"];
|
|
123
|
+
var E = (e) => {
|
|
124
|
+
if (e.href && !e.href.startsWith(location.origin))
|
|
125
|
+
return false;
|
|
126
|
+
try {
|
|
127
|
+
return !!e.cssRules;
|
|
128
|
+
} catch (e2) {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
var T = (e) => {
|
|
133
|
+
let t2;
|
|
134
|
+
const n2 = () => {
|
|
135
|
+
const { cssRules: e2 } = t2.sheet;
|
|
136
|
+
return [].map.call(e2, (n3, r3) => {
|
|
137
|
+
const { cssText: i2 } = n3;
|
|
138
|
+
let o2 = "";
|
|
139
|
+
if (i2.startsWith("--sxs"))
|
|
140
|
+
return "";
|
|
141
|
+
if (e2[r3 - 1] && (o2 = e2[r3 - 1].cssText).startsWith("--sxs")) {
|
|
142
|
+
if (!n3.cssRules.length)
|
|
143
|
+
return "";
|
|
144
|
+
for (const e3 in t2.rules)
|
|
145
|
+
if (t2.rules[e3].group === n3)
|
|
146
|
+
return `--sxs{--sxs:${[...t2.rules[e3].cache].join(" ")}}${i2}`;
|
|
147
|
+
return n3.cssRules.length ? `${o2}${i2}` : "";
|
|
148
|
+
}
|
|
149
|
+
return i2;
|
|
150
|
+
}).join("");
|
|
151
|
+
}, r2 = () => {
|
|
152
|
+
if (t2) {
|
|
153
|
+
const { rules: e2, sheet: n3 } = t2;
|
|
154
|
+
if (!n3.deleteRule) {
|
|
155
|
+
for (; 3 === Object(Object(n3.cssRules)[0]).type; )
|
|
156
|
+
n3.cssRules.splice(0, 1);
|
|
157
|
+
n3.cssRules = [];
|
|
158
|
+
}
|
|
159
|
+
for (const t3 in e2)
|
|
160
|
+
delete e2[t3];
|
|
161
|
+
}
|
|
162
|
+
const i2 = Object(e).styleSheets || [];
|
|
163
|
+
for (const e2 of i2)
|
|
164
|
+
if (E(e2)) {
|
|
165
|
+
for (let i3 = 0, o3 = e2.cssRules; o3[i3]; ++i3) {
|
|
166
|
+
const l3 = Object(o3[i3]);
|
|
167
|
+
if (1 !== l3.type)
|
|
168
|
+
continue;
|
|
169
|
+
const s2 = Object(o3[i3 + 1]);
|
|
170
|
+
if (4 !== s2.type)
|
|
171
|
+
continue;
|
|
172
|
+
++i3;
|
|
173
|
+
const { cssText: a2 } = l3;
|
|
174
|
+
if (!a2.startsWith("--sxs"))
|
|
175
|
+
continue;
|
|
176
|
+
const c2 = a2.slice(14, -3).trim().split(/\s+/), d2 = j[c2[0]];
|
|
177
|
+
d2 && (t2 || (t2 = { sheet: e2, reset: r2, rules: {}, toString: n2 }), t2.rules[d2] = { group: s2, index: i3, cache: new Set(c2) });
|
|
178
|
+
}
|
|
179
|
+
if (t2)
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
if (!t2) {
|
|
183
|
+
const i3 = (e2, t3) => ({ type: t3, cssRules: [], insertRule(e3, t4) {
|
|
184
|
+
this.cssRules.splice(t4, 0, i3(e3, { import: 3, undefined: 1 }[(e3.toLowerCase().match(/^@([a-z]+)/) || [])[1]] || 4));
|
|
185
|
+
}, get cssText() {
|
|
186
|
+
return "@media{}" === e2 ? `@media{${[].map.call(this.cssRules, (e3) => e3.cssText).join("")}}` : e2;
|
|
187
|
+
} });
|
|
188
|
+
t2 = { sheet: e ? (e.head || e).appendChild(document.createElement("style")).sheet : i3("", "text/css"), rules: {}, reset: r2, toString: n2 };
|
|
189
|
+
}
|
|
190
|
+
const { sheet: o2, rules: l2 } = t2;
|
|
191
|
+
for (let e2 = j.length - 1; e2 >= 0; --e2) {
|
|
192
|
+
const t3 = j[e2];
|
|
193
|
+
if (!l2[t3]) {
|
|
194
|
+
const n3 = j[e2 + 1], r3 = l2[n3] ? l2[n3].index : o2.cssRules.length;
|
|
195
|
+
o2.insertRule("@media{}", r3), o2.insertRule(`--sxs{--sxs:${e2}}`, r3), l2[t3] = { group: o2.cssRules[r3 + 1], index: r3, cache: /* @__PURE__ */ new Set([e2]) };
|
|
196
|
+
}
|
|
197
|
+
v(l2[t3]);
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
return r2(), t2;
|
|
201
|
+
};
|
|
202
|
+
var v = (e) => {
|
|
203
|
+
const t2 = e.group;
|
|
204
|
+
let n2 = t2.cssRules.length;
|
|
205
|
+
e.apply = (e2) => {
|
|
206
|
+
try {
|
|
207
|
+
t2.insertRule(e2, n2), ++n2;
|
|
208
|
+
} catch (e3) {
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
};
|
|
212
|
+
var M = Symbol();
|
|
213
|
+
var w = l();
|
|
214
|
+
var C = (e, t2) => w(e, () => (...n2) => {
|
|
215
|
+
let r2 = { type: null, composers: /* @__PURE__ */ new Set() };
|
|
216
|
+
for (const t3 of n2)
|
|
217
|
+
if (null != t3)
|
|
218
|
+
if (t3[s]) {
|
|
219
|
+
null == r2.type && (r2.type = t3[s].type);
|
|
220
|
+
for (const e2 of t3[s].composers)
|
|
221
|
+
r2.composers.add(e2);
|
|
222
|
+
} else
|
|
223
|
+
t3.constructor !== Object || t3.$$typeof ? null == r2.type && (r2.type = t3) : r2.composers.add(P(t3, e));
|
|
224
|
+
return null == r2.type && (r2.type = "span"), r2.composers.size || r2.composers.add(["PJLV", {}, [], [], {}, []]), L(e, r2, t2);
|
|
225
|
+
});
|
|
226
|
+
var P = ({ variants: e, compoundVariants: t2, defaultVariants: n2, ...r2 }, i2) => {
|
|
227
|
+
const o2 = `${k(i2.prefix)}c-${W(r2)}`, l2 = [], s2 = [], a2 = /* @__PURE__ */ Object.create(null), g2 = [];
|
|
228
|
+
for (const e2 in n2)
|
|
229
|
+
a2[e2] = String(n2[e2]);
|
|
230
|
+
if ("object" == typeof e && e)
|
|
231
|
+
for (const t3 in e) {
|
|
232
|
+
p2 = a2, u2 = t3, d.call(p2, u2) || (a2[t3] = "undefined");
|
|
233
|
+
const n3 = e[t3];
|
|
234
|
+
for (const e2 in n3) {
|
|
235
|
+
const r3 = { [t3]: String(e2) };
|
|
236
|
+
"undefined" === String(e2) && g2.push(t3);
|
|
237
|
+
const i3 = n3[e2], o3 = [r3, i3, !c(i3)];
|
|
238
|
+
l2.push(o3);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
var p2, u2;
|
|
242
|
+
if ("object" == typeof t2 && t2)
|
|
243
|
+
for (const e2 of t2) {
|
|
244
|
+
let { css: t3, ...n3 } = e2;
|
|
245
|
+
t3 = "object" == typeof t3 && t3 || {};
|
|
246
|
+
for (const e3 in n3)
|
|
247
|
+
n3[e3] = String(n3[e3]);
|
|
248
|
+
const r3 = [n3, t3, !c(t3)];
|
|
249
|
+
s2.push(r3);
|
|
250
|
+
}
|
|
251
|
+
return [o2, r2, l2, s2, a2, g2];
|
|
252
|
+
};
|
|
253
|
+
var L = (e, t2, n2) => {
|
|
254
|
+
const [r2, i2, o2, l2] = O(t2.composers), c2 = "function" == typeof t2.type || t2.type.$$typeof ? ((e2) => {
|
|
255
|
+
function t3() {
|
|
256
|
+
for (let n3 = 0; n3 < t3[M].length; n3++) {
|
|
257
|
+
const [r3, i3] = t3[M][n3];
|
|
258
|
+
e2.rules[r3].apply(i3);
|
|
259
|
+
}
|
|
260
|
+
return t3[M] = [], null;
|
|
261
|
+
}
|
|
262
|
+
return t3[M] = [], t3.rules = {}, j.forEach((e3) => t3.rules[e3] = { apply: (n3) => t3[M].push([e3, n3]) }), t3;
|
|
263
|
+
})(n2) : null, d2 = (c2 || n2).rules, g2 = `.${r2}${i2.length > 1 ? `:where(.${i2.slice(1).join(".")})` : ""}`, p2 = (s2) => {
|
|
264
|
+
s2 = "object" == typeof s2 && s2 || D;
|
|
265
|
+
const { css: a2, ...p3 } = s2, u2 = {};
|
|
266
|
+
for (const e2 in o2)
|
|
267
|
+
if (delete p3[e2], e2 in s2) {
|
|
268
|
+
let t3 = s2[e2];
|
|
269
|
+
"object" == typeof t3 && t3 ? u2[e2] = { "@initial": o2[e2], ...t3 } : (t3 = String(t3), u2[e2] = "undefined" !== t3 || l2.has(e2) ? t3 : o2[e2]);
|
|
270
|
+
} else
|
|
271
|
+
u2[e2] = o2[e2];
|
|
272
|
+
const h2 = /* @__PURE__ */ new Set([...i2]);
|
|
273
|
+
for (const [r3, i3, o3, l3] of t2.composers) {
|
|
274
|
+
n2.rules.styled.cache.has(r3) || (n2.rules.styled.cache.add(r3), x(i3, [`.${r3}`], [], e, (e2) => {
|
|
275
|
+
d2.styled.apply(e2);
|
|
276
|
+
}));
|
|
277
|
+
const t3 = A(o3, u2, e.media), s3 = A(l3, u2, e.media, true);
|
|
278
|
+
for (const i4 of t3)
|
|
279
|
+
if (void 0 !== i4)
|
|
280
|
+
for (const [t4, o4, l4] of i4) {
|
|
281
|
+
const i5 = `${r3}-${W(o4)}-${t4}`;
|
|
282
|
+
h2.add(i5);
|
|
283
|
+
const s4 = (l4 ? n2.rules.resonevar : n2.rules.onevar).cache, a3 = l4 ? d2.resonevar : d2.onevar;
|
|
284
|
+
s4.has(i5) || (s4.add(i5), x(o4, [`.${i5}`], [], e, (e2) => {
|
|
285
|
+
a3.apply(e2);
|
|
286
|
+
}));
|
|
287
|
+
}
|
|
288
|
+
for (const t4 of s3)
|
|
289
|
+
if (void 0 !== t4)
|
|
290
|
+
for (const [i4, o4] of t4) {
|
|
291
|
+
const t5 = `${r3}-${W(o4)}-${i4}`;
|
|
292
|
+
h2.add(t5), n2.rules.allvar.cache.has(t5) || (n2.rules.allvar.cache.add(t5), x(o4, [`.${t5}`], [], e, (e2) => {
|
|
293
|
+
d2.allvar.apply(e2);
|
|
294
|
+
}));
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
if ("object" == typeof a2 && a2) {
|
|
298
|
+
const t3 = `${r2}-i${W(a2)}-css`;
|
|
299
|
+
h2.add(t3), n2.rules.inline.cache.has(t3) || (n2.rules.inline.cache.add(t3), x(a2, [`.${t3}`], [], e, (e2) => {
|
|
300
|
+
d2.inline.apply(e2);
|
|
301
|
+
}));
|
|
302
|
+
}
|
|
303
|
+
for (const e2 of String(s2.className || "").trim().split(/\s+/))
|
|
304
|
+
e2 && h2.add(e2);
|
|
305
|
+
const f2 = p3.className = [...h2].join(" ");
|
|
306
|
+
return { type: t2.type, className: f2, selector: g2, props: p3, toString: () => f2, deferredInjector: c2 };
|
|
307
|
+
};
|
|
308
|
+
return a(p2, { className: r2, selector: g2, [s]: t2, toString: () => (n2.rules.styled.cache.has(r2) || p2(), r2) });
|
|
309
|
+
};
|
|
310
|
+
var O = (e) => {
|
|
311
|
+
let t2 = "";
|
|
312
|
+
const n2 = [], r2 = {}, i2 = [];
|
|
313
|
+
for (const [o2, , , , l2, s2] of e) {
|
|
314
|
+
"" === t2 && (t2 = o2), n2.push(o2), i2.push(...s2);
|
|
315
|
+
for (const e2 in l2) {
|
|
316
|
+
const t3 = l2[e2];
|
|
317
|
+
(void 0 === r2[e2] || "undefined" !== t3 || s2.includes(t3)) && (r2[e2] = t3);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
return [t2, n2, r2, new Set(i2)];
|
|
321
|
+
};
|
|
322
|
+
var A = (e, t2, n2, r2) => {
|
|
323
|
+
const i2 = [];
|
|
324
|
+
e:
|
|
325
|
+
for (let [o2, l2, s2] of e) {
|
|
326
|
+
if (s2)
|
|
327
|
+
continue;
|
|
328
|
+
let e2, a2 = 0, c2 = false;
|
|
329
|
+
for (e2 in o2) {
|
|
330
|
+
const r3 = o2[e2];
|
|
331
|
+
let i3 = t2[e2];
|
|
332
|
+
if (i3 !== r3) {
|
|
333
|
+
if ("object" != typeof i3 || !i3)
|
|
334
|
+
continue e;
|
|
335
|
+
{
|
|
336
|
+
let e3, t3, o3 = 0;
|
|
337
|
+
for (const l3 in i3) {
|
|
338
|
+
if (r3 === String(i3[l3])) {
|
|
339
|
+
if ("@initial" !== l3) {
|
|
340
|
+
const e4 = l3.slice(1);
|
|
341
|
+
(t3 = t3 || []).push(e4 in n2 ? n2[e4] : l3.replace(/^@media ?/, "")), c2 = true;
|
|
342
|
+
}
|
|
343
|
+
a2 += o3, e3 = true;
|
|
344
|
+
}
|
|
345
|
+
++o3;
|
|
346
|
+
}
|
|
347
|
+
if (t3 && t3.length && (l2 = { ["@media " + t3.join(", ")]: l2 }), !e3)
|
|
348
|
+
continue e;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
(i2[a2] = i2[a2] || []).push([r2 ? "cv" : `${e2}-${o2[e2]}`, l2, c2]);
|
|
353
|
+
}
|
|
354
|
+
return i2;
|
|
355
|
+
};
|
|
356
|
+
var D = {};
|
|
357
|
+
var H = l();
|
|
358
|
+
var N = (e, t2) => H(e, () => (...n2) => {
|
|
359
|
+
const r2 = () => {
|
|
360
|
+
for (let r3 of n2) {
|
|
361
|
+
r3 = "object" == typeof r3 && r3 || {};
|
|
362
|
+
let n3 = W(r3);
|
|
363
|
+
if (!t2.rules.global.cache.has(n3)) {
|
|
364
|
+
if (t2.rules.global.cache.add(n3), "@import" in r3) {
|
|
365
|
+
let e2 = [].indexOf.call(t2.sheet.cssRules, t2.rules.themed.group) - 1;
|
|
366
|
+
for (let n4 of [].concat(r3["@import"]))
|
|
367
|
+
n4 = n4.includes('"') || n4.includes("'") ? n4 : `"${n4}"`, t2.sheet.insertRule(`@import ${n4};`, e2++);
|
|
368
|
+
delete r3["@import"];
|
|
369
|
+
}
|
|
370
|
+
x(r3, [], [], e, (e2) => {
|
|
371
|
+
t2.rules.global.apply(e2);
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
return "";
|
|
376
|
+
};
|
|
377
|
+
return a(r2, { toString: r2 });
|
|
378
|
+
});
|
|
379
|
+
var V = l();
|
|
380
|
+
var G = (e, t2) => V(e, () => (n2) => {
|
|
381
|
+
const r2 = `${k(e.prefix)}k-${W(n2)}`, i2 = () => {
|
|
382
|
+
if (!t2.rules.global.cache.has(r2)) {
|
|
383
|
+
t2.rules.global.cache.add(r2);
|
|
384
|
+
const i3 = [];
|
|
385
|
+
x(n2, [], [], e, (e2) => i3.push(e2));
|
|
386
|
+
const o2 = `@keyframes ${r2}{${i3.join("")}}`;
|
|
387
|
+
t2.rules.global.apply(o2);
|
|
388
|
+
}
|
|
389
|
+
return r2;
|
|
390
|
+
};
|
|
391
|
+
return a(i2, { get name() {
|
|
392
|
+
return i2();
|
|
393
|
+
}, toString: i2 });
|
|
394
|
+
});
|
|
395
|
+
var F = class {
|
|
396
|
+
constructor(e, t2, n2, r2) {
|
|
397
|
+
this.token = null == e ? "" : String(e), this.value = null == t2 ? "" : String(t2), this.scale = null == n2 ? "" : String(n2), this.prefix = null == r2 ? "" : String(r2);
|
|
398
|
+
}
|
|
399
|
+
get computedValue() {
|
|
400
|
+
return "var(" + this.variable + ")";
|
|
401
|
+
}
|
|
402
|
+
get variable() {
|
|
403
|
+
return "--" + k(this.prefix) + k(this.scale) + this.token;
|
|
404
|
+
}
|
|
405
|
+
toString() {
|
|
406
|
+
return this.computedValue;
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
var J = l();
|
|
410
|
+
var U = (e, t2) => J(e, () => (n2, r2) => {
|
|
411
|
+
r2 = "object" == typeof n2 && n2 || Object(r2);
|
|
412
|
+
const i2 = `.${n2 = (n2 = "string" == typeof n2 ? n2 : "") || `${k(e.prefix)}t-${W(r2)}`}`, o2 = {}, l2 = [];
|
|
413
|
+
for (const t3 in r2) {
|
|
414
|
+
o2[t3] = {};
|
|
415
|
+
for (const n3 in r2[t3]) {
|
|
416
|
+
const i3 = `--${k(e.prefix)}${t3}-${n3}`, s3 = y(String(r2[t3][n3]), e.prefix, t3);
|
|
417
|
+
o2[t3][n3] = new F(n3, s3, t3, e.prefix), l2.push(`${i3}:${s3}`);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
const s2 = () => {
|
|
421
|
+
if (l2.length && !t2.rules.themed.cache.has(n2)) {
|
|
422
|
+
t2.rules.themed.cache.add(n2);
|
|
423
|
+
const i3 = `${r2 === e.theme ? ":root," : ""}.${n2}{${l2.join(";")}}`;
|
|
424
|
+
t2.rules.themed.apply(i3);
|
|
425
|
+
}
|
|
426
|
+
return n2;
|
|
427
|
+
};
|
|
428
|
+
return { ...o2, get className() {
|
|
429
|
+
return s2();
|
|
430
|
+
}, selector: i2, toString: s2 };
|
|
431
|
+
});
|
|
432
|
+
var Z = l();
|
|
433
|
+
var X = (e) => {
|
|
434
|
+
let t2 = false;
|
|
435
|
+
const n2 = Z(e, (e2) => {
|
|
436
|
+
t2 = true;
|
|
437
|
+
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() {
|
|
438
|
+
a2.reset(), c2.theme.toString();
|
|
439
|
+
}, theme: {}, sheet: a2, config: s2, prefix: n3, getCssText: a2.toString, toString: a2.toString };
|
|
440
|
+
return String(c2.theme = c2.createTheme(l2)), c2;
|
|
441
|
+
});
|
|
442
|
+
return t2 || n2.reset(), n2;
|
|
443
|
+
};
|
|
444
|
+
|
|
445
|
+
// ../core/dist/index.mjs
|
|
446
|
+
var loadScript = (src) => {
|
|
447
|
+
return new Promise((resolve, reject) => {
|
|
448
|
+
let script = document.createElement("script");
|
|
449
|
+
script.src = src;
|
|
450
|
+
script.onload = resolve;
|
|
451
|
+
script.onerror = reject;
|
|
452
|
+
script.defer = true;
|
|
453
|
+
document.body.appendChild(script);
|
|
454
|
+
});
|
|
455
|
+
};
|
|
456
|
+
var isReactNative = typeof navigator === "object" && navigator.product === "ReactNative";
|
|
457
|
+
var isBrowser2 = typeof window !== "undefined" && !isReactNative;
|
|
458
|
+
var isIframe = isBrowser2 && window.top !== window.self;
|
|
459
|
+
function merge(target, source) {
|
|
460
|
+
let t2 = { ...target || {} };
|
|
461
|
+
for (let key of Object.keys(source)) {
|
|
462
|
+
if (source[key] instanceof Object && !Array.isArray(source[key])) {
|
|
463
|
+
Object.assign(source[key], merge(t2[key], source[key]));
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
Object.assign(t2 || {}, source);
|
|
467
|
+
return t2;
|
|
468
|
+
}
|
|
469
|
+
var stitchesUtils = {
|
|
470
|
+
// Abbreviated margin properties
|
|
471
|
+
m: (value) => ({
|
|
472
|
+
margin: value
|
|
473
|
+
}),
|
|
474
|
+
mt: (value) => ({
|
|
475
|
+
marginTop: value
|
|
476
|
+
}),
|
|
477
|
+
mr: (value) => ({
|
|
478
|
+
marginRight: value
|
|
479
|
+
}),
|
|
480
|
+
mb: (value) => ({
|
|
481
|
+
marginBottom: value
|
|
482
|
+
}),
|
|
483
|
+
ml: (value) => ({
|
|
484
|
+
marginLeft: value
|
|
485
|
+
}),
|
|
486
|
+
mx: (value) => ({
|
|
487
|
+
marginLeft: value,
|
|
488
|
+
marginRight: value
|
|
489
|
+
}),
|
|
490
|
+
my: (value) => ({
|
|
491
|
+
marginTop: value,
|
|
492
|
+
marginBottom: value
|
|
493
|
+
}),
|
|
494
|
+
// A property for applying width/height together
|
|
495
|
+
size: (value) => ({
|
|
496
|
+
width: value,
|
|
497
|
+
height: value
|
|
498
|
+
}),
|
|
499
|
+
// Abbreviated padding properties
|
|
500
|
+
px: (value) => ({
|
|
501
|
+
paddingLeft: value,
|
|
502
|
+
paddingRight: value
|
|
503
|
+
}),
|
|
504
|
+
py: (value) => ({
|
|
505
|
+
paddingTop: value,
|
|
506
|
+
paddingBottom: value
|
|
507
|
+
})
|
|
508
|
+
};
|
|
509
|
+
var WeaverseItemStore = class {
|
|
510
|
+
constructor(itemData, weaverse) {
|
|
511
|
+
this.listeners = /* @__PURE__ */ new Set();
|
|
512
|
+
this.ref = {
|
|
513
|
+
current: null
|
|
514
|
+
};
|
|
515
|
+
this.stitchesClass = "";
|
|
516
|
+
this._data = { id: "", type: "" };
|
|
517
|
+
this.setData = (data) => {
|
|
518
|
+
this.data = Object.assign(this.data, data);
|
|
519
|
+
this.triggerUpdate();
|
|
520
|
+
return this.data;
|
|
521
|
+
};
|
|
522
|
+
this.subscribe = (fn) => {
|
|
523
|
+
this.listeners.add(fn);
|
|
524
|
+
};
|
|
525
|
+
this.unsubscribe = (fn) => {
|
|
526
|
+
this.listeners.delete(fn);
|
|
527
|
+
};
|
|
528
|
+
this.triggerUpdate = () => {
|
|
529
|
+
this.listeners.forEach((fn) => {
|
|
530
|
+
return fn(this.data);
|
|
531
|
+
});
|
|
532
|
+
};
|
|
533
|
+
let { type, id } = itemData;
|
|
534
|
+
this.weaverse = weaverse;
|
|
535
|
+
if (id && type) {
|
|
536
|
+
weaverse.itemInstances.set(id, this);
|
|
537
|
+
this.data = { ...itemData };
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
get _id() {
|
|
541
|
+
return this._data.id;
|
|
542
|
+
}
|
|
543
|
+
get _element() {
|
|
544
|
+
return this.ref.current;
|
|
545
|
+
}
|
|
546
|
+
get _flags() {
|
|
547
|
+
return this.Element?.schema?.flags || {};
|
|
548
|
+
}
|
|
549
|
+
get Element() {
|
|
550
|
+
return this.weaverse.elementInstances.get(this._data.type);
|
|
551
|
+
}
|
|
552
|
+
set data(data) {
|
|
553
|
+
this._data = { ...this.data, ...data };
|
|
554
|
+
}
|
|
555
|
+
get data() {
|
|
556
|
+
let defaultCss = this.Element?.defaultCss || {};
|
|
557
|
+
let currentCss = this._data.css || {};
|
|
558
|
+
let css = merge(defaultCss, currentCss);
|
|
559
|
+
let defaultData = { ...this.Element?.Component?.defaultProps };
|
|
560
|
+
return { ...defaultData, ...this._data, css };
|
|
561
|
+
}
|
|
562
|
+
};
|
|
563
|
+
var Weaverse = class {
|
|
564
|
+
/**
|
|
565
|
+
* constructor
|
|
566
|
+
* @param weaverseHost {string} Weaverse base URL that can provide by user/developer. for local development, use localhost:3000
|
|
567
|
+
* @param projectId {string} Weaverse project key to access project data via API
|
|
568
|
+
* @param data {WeaverseProjectDataType} Weaverse project data, by default, user can provide project data via React Component.
|
|
569
|
+
* @param mediaBreakPoints {object} Pass down custom media query breakpoints or just use the default.
|
|
570
|
+
* @param isDesignMode {boolean} check whether the sdk is isDesignMode or not
|
|
571
|
+
* @param ssrMode {boolean} Use in element to optionally render special HTML for hydration
|
|
572
|
+
* @param elementSchemas {Array<ElementSchema>} List of element schemas
|
|
573
|
+
* @param platformType {PlatformTypeEnum} Check the platform, shopify-section or react-ssr(hydrogen)
|
|
574
|
+
*/
|
|
575
|
+
constructor({
|
|
576
|
+
weaverseHost,
|
|
577
|
+
weaverseVersion,
|
|
578
|
+
projectId,
|
|
579
|
+
data,
|
|
580
|
+
mediaBreakPoints,
|
|
581
|
+
isDesignMode,
|
|
582
|
+
ssrMode,
|
|
583
|
+
elementSchemas,
|
|
584
|
+
platformType,
|
|
585
|
+
pageId
|
|
586
|
+
} = {}) {
|
|
587
|
+
this.elementInstances = /* @__PURE__ */ new Map();
|
|
588
|
+
this.itemInstances = /* @__PURE__ */ new Map();
|
|
589
|
+
this.weaverseHost = "https://studio.weaverse.io";
|
|
590
|
+
this.weaverseVersion = "";
|
|
591
|
+
this.projectId = "";
|
|
592
|
+
this.pageId = "";
|
|
593
|
+
this.data = {
|
|
594
|
+
rootId: "",
|
|
595
|
+
items: [],
|
|
596
|
+
script: { css: "", js: "" }
|
|
597
|
+
};
|
|
598
|
+
this.listeners = /* @__PURE__ */ new Set();
|
|
599
|
+
this.isDesignMode = false;
|
|
600
|
+
this.platformType = "shopify-section";
|
|
601
|
+
this.isPreviewMode = false;
|
|
602
|
+
this.ssrMode = false;
|
|
603
|
+
this.mediaBreakPoints = {
|
|
604
|
+
desktop: "all",
|
|
605
|
+
// max-width need to subtract 0.02px to prevent bug https://getbootstrap.com/docs/5.1/layout/breakpoints/#max-width
|
|
606
|
+
// tablet: "(max-width: 1023.98px)", // to set css for tablet, {'@tablet' : { // css }},
|
|
607
|
+
mobile: "(max-width: 767.98px)"
|
|
608
|
+
};
|
|
609
|
+
this.initStitches = (externalConfig = {}) => {
|
|
610
|
+
this.stitchesInstance = this.stitchesInstance || X({
|
|
611
|
+
prefix: "weaverse",
|
|
612
|
+
media: this.mediaBreakPoints,
|
|
613
|
+
utils: stitchesUtils,
|
|
614
|
+
...externalConfig
|
|
615
|
+
});
|
|
616
|
+
};
|
|
617
|
+
this.init({
|
|
618
|
+
weaverseHost,
|
|
619
|
+
weaverseVersion,
|
|
620
|
+
projectId,
|
|
621
|
+
data,
|
|
622
|
+
platformType,
|
|
623
|
+
mediaBreakPoints,
|
|
624
|
+
isDesignMode,
|
|
625
|
+
ssrMode,
|
|
626
|
+
elementSchemas,
|
|
627
|
+
pageId
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
init({
|
|
631
|
+
weaverseHost,
|
|
632
|
+
weaverseVersion,
|
|
633
|
+
elementSchemas,
|
|
634
|
+
platformType,
|
|
635
|
+
projectId,
|
|
636
|
+
data,
|
|
637
|
+
mediaBreakPoints,
|
|
638
|
+
isDesignMode,
|
|
639
|
+
ssrMode,
|
|
640
|
+
pageId
|
|
641
|
+
} = {}) {
|
|
642
|
+
this.elementSchemas = elementSchemas || this.elementSchemas;
|
|
643
|
+
this.weaverseHost = weaverseHost || this.weaverseHost;
|
|
644
|
+
this.weaverseVersion = weaverseVersion || this.weaverseVersion;
|
|
645
|
+
this.projectId = projectId || this.projectId;
|
|
646
|
+
this.pageId = pageId || this.pageId;
|
|
647
|
+
this.mediaBreakPoints = mediaBreakPoints || this.mediaBreakPoints;
|
|
648
|
+
this.isDesignMode = isDesignMode || this.isDesignMode;
|
|
649
|
+
this.ssrMode = ssrMode || this.ssrMode;
|
|
650
|
+
this.platformType = platformType || this.platformType;
|
|
651
|
+
this.data = data || this.data;
|
|
652
|
+
this.initProjectItemData();
|
|
653
|
+
this.initStitches();
|
|
654
|
+
}
|
|
655
|
+
/**
|
|
656
|
+
* Register the custom React Component to Weaverse, store it into Weaverse.elementInstances
|
|
657
|
+
* @param element {WeaverseElement} custom React Component
|
|
658
|
+
*/
|
|
659
|
+
registerElement(element) {
|
|
660
|
+
if (element?.type) {
|
|
661
|
+
if (!this.elementInstances.has(element.type)) {
|
|
662
|
+
this.elementInstances.set(element?.type, element);
|
|
663
|
+
}
|
|
664
|
+
} else {
|
|
665
|
+
console.error("Weaverse: registerElement: `type` is required");
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
subscribe(fn) {
|
|
669
|
+
this.listeners.add(fn);
|
|
670
|
+
}
|
|
671
|
+
unsubscribe(fn) {
|
|
672
|
+
this.listeners.delete(fn);
|
|
673
|
+
}
|
|
674
|
+
triggerUpdate() {
|
|
675
|
+
this.listeners.forEach((fn) => fn());
|
|
676
|
+
}
|
|
677
|
+
refreshAllItems() {
|
|
678
|
+
this.itemInstances.forEach((item) => {
|
|
679
|
+
item.triggerUpdate();
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
setProjectData(data) {
|
|
683
|
+
this.data = data;
|
|
684
|
+
this.initProjectItemData();
|
|
685
|
+
this.triggerUpdate();
|
|
686
|
+
}
|
|
687
|
+
initProjectItemData() {
|
|
688
|
+
const data = this.data;
|
|
689
|
+
if (data?.items) {
|
|
690
|
+
data.items.forEach((item) => {
|
|
691
|
+
if (!this.itemInstances.get(item.id)) {
|
|
692
|
+
new WeaverseItemStore(item, this);
|
|
693
|
+
}
|
|
694
|
+
});
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
};
|
|
698
|
+
Weaverse.WeaverseItemStore = WeaverseItemStore;
|
|
699
|
+
|
|
38
700
|
// src/utils.ts
|
|
39
|
-
import { isIframe, loadScript } from "@weaverse/core";
|
|
40
701
|
import { useEffect } from "react";
|
|
41
702
|
var useStudio = (weaverseCore) => {
|
|
42
703
|
useEffect(() => {
|
|
@@ -60,10 +721,7 @@ var useStudio = (weaverseCore) => {
|
|
|
60
721
|
};
|
|
61
722
|
|
|
62
723
|
// src/weaverse-loader.ts
|
|
63
|
-
import {
|
|
64
|
-
CacheShort,
|
|
65
|
-
generateCacheControlHeader
|
|
66
|
-
} from "@shopify/hydrogen";
|
|
724
|
+
import { CacheShort, generateCacheControlHeader } from "@shopify/hydrogen";
|
|
67
725
|
function hashKey(queryKey) {
|
|
68
726
|
const rawKeys = Array.isArray(queryKey) ? queryKey : [queryKey];
|
|
69
727
|
let hash = "";
|
|
@@ -82,6 +740,7 @@ function hashKey(queryKey) {
|
|
|
82
740
|
}
|
|
83
741
|
return hash;
|
|
84
742
|
}
|
|
743
|
+
var cacheControl = generateCacheControlHeader(CacheShort());
|
|
85
744
|
var fetchWithServerCache = async ({
|
|
86
745
|
url,
|
|
87
746
|
options = {},
|
|
@@ -93,9 +752,6 @@ var fetchWithServerCache = async ({
|
|
|
93
752
|
const cacheKey = new Request(cacheUrl.toString());
|
|
94
753
|
let response = await storefront.cache.match(cacheKey);
|
|
95
754
|
if (!response) {
|
|
96
|
-
let cacheControl = generateCacheControlHeader({
|
|
97
|
-
...CacheShort()
|
|
98
|
-
});
|
|
99
755
|
response = await fetch(url, {
|
|
100
756
|
...options,
|
|
101
757
|
headers: {
|
|
@@ -107,12 +763,23 @@ var fetchWithServerCache = async ({
|
|
|
107
763
|
}
|
|
108
764
|
return response;
|
|
109
765
|
};
|
|
766
|
+
function getRequestQueries(request) {
|
|
767
|
+
let url = new URL(request.url);
|
|
768
|
+
return Array.from(url.searchParams.entries()).reduce(
|
|
769
|
+
(q, [k2, v2]) => {
|
|
770
|
+
q[k2] = v2 === "true" ? true : v2 === "false" ? false : v2;
|
|
771
|
+
return q;
|
|
772
|
+
},
|
|
773
|
+
{}
|
|
774
|
+
);
|
|
775
|
+
}
|
|
110
776
|
async function weaverseLoader({
|
|
111
777
|
request,
|
|
112
778
|
context: { env, storefront, waitUntil },
|
|
113
779
|
context,
|
|
114
780
|
params
|
|
115
781
|
}, components) {
|
|
782
|
+
let queries = getRequestQueries(request);
|
|
116
783
|
let projectId = env?.WEAVERSE_PROJECT_ID;
|
|
117
784
|
let weaverseHost = env?.WEAVERSE_HOST;
|
|
118
785
|
if (!projectId || !weaverseHost) {
|
|
@@ -121,7 +788,8 @@ async function weaverseLoader({
|
|
|
121
788
|
}
|
|
122
789
|
let config = {
|
|
123
790
|
projectId,
|
|
124
|
-
weaverseHost
|
|
791
|
+
weaverseHost,
|
|
792
|
+
...queries
|
|
125
793
|
};
|
|
126
794
|
try {
|
|
127
795
|
let pageData = await fetchWithServerCache({
|
|
@@ -138,7 +806,7 @@ async function weaverseLoader({
|
|
|
138
806
|
},
|
|
139
807
|
storefront,
|
|
140
808
|
waitUntil
|
|
141
|
-
}).then((
|
|
809
|
+
}).then((r2) => r2.json()).catch((err) => {
|
|
142
810
|
console.log(`\u274C Error fetching page data: ${err?.toString()}`);
|
|
143
811
|
return {};
|
|
144
812
|
});
|
|
@@ -184,11 +852,10 @@ var WeaverseHydrogenRoot = ({
|
|
|
184
852
|
if (!weaverse?.data) {
|
|
185
853
|
return /* @__PURE__ */ React.createElement("div", null, "404");
|
|
186
854
|
}
|
|
187
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
|
|
855
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(WeaverseRoot, { context: weaverse }), weaverse.isDesignMode ? null : /* @__PURE__ */ React.createElement(StitchesStyle, { weaverse }));
|
|
188
856
|
};
|
|
189
857
|
var StitchesStyle = memo(
|
|
190
858
|
({ weaverse }) => {
|
|
191
|
-
console.log("stitches", weaverse.stitchesInstance?.getCssText());
|
|
192
859
|
return /* @__PURE__ */ React.createElement(
|
|
193
860
|
"style",
|
|
194
861
|
{
|
|
@@ -206,6 +873,7 @@ var StitchesStyle = memo(
|
|
|
206
873
|
export {
|
|
207
874
|
WeaverseHydrogenRoot,
|
|
208
875
|
fetchWithServerCache,
|
|
876
|
+
getRequestQueries,
|
|
209
877
|
hashKey,
|
|
210
878
|
useStudio,
|
|
211
879
|
weaverseLoader
|