@wix/himalaya-cli 0.1780.0 → 0.1782.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/schema.d.ts +4 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/site-shell.d.ts +6 -1
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/validator.d.ts +6 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/core.mjs +11 -4
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/sdui.mjs +3 -1
- package/dist/browser-plane/assets.json +5 -5
- package/dist/browser-plane/preview-deferred/{81b0921a25bdf01f44c9cc524e12b9ae379c49ec12d6238f114bc9f5e82faebf.bin → d71e5b22a5ff1965fd887118ee8b2a74497b48a88f4459c9800569457e1fb547.bin} +1 -1
- package/dist/browser-plane/sw.js +8 -8
- package/dist/cli.mjs +56 -46
- package/dist/preview-assets.generated.bin +0 -0
- package/guides/wix-business-context.md +1 -1
- package/package.json +2 -2
- package/templates/beauty-salon/tier5-src/himi-branded-lite-cart/index.ts +98 -6
- package/templates/branded-lite/tier5-src/himi-branded-lite-cart/index.ts +98 -6
- package/templates/branded-lite/tier5-src/himi-branded-lite-header-badges/index.ts +39 -7
- package/templates/gym-fitness/tier5-src/himi-branded-lite-cart/index.ts +98 -6
- package/templates/portfolio-creative/tier5-src/himi-branded-lite-cart/index.ts +98 -6
- package/templates/retail-store/tier5-src/himi-branded-lite-cart/index.ts +98 -6
- package/templates/wholesale-store/tier5-src/himi-branded-lite-cart/index.ts +98 -6
package/dist/cli.mjs
CHANGED
|
@@ -18464,6 +18464,7 @@ function buttonVariant(style) {
|
|
|
18464
18464
|
var SYSTEM_FONT_FAMILY, TONAL_ELEVATION_ALPHA, BUTTON_SIZES, BUTTON_MIN_HIT_TARGET, nonNegative, nonEmpty2, own2, COLOR_TOKEN_PROPS, TYPOGRAPHY_TOKEN_PROPS, BUTTON_VARIANTS;
|
|
18465
18465
|
var init_tokens = __esm({
|
|
18466
18466
|
"../../core/ts/src/tokens.ts"() {
|
|
18467
|
+
"use strict";
|
|
18467
18468
|
init_define_HHP_CATALOG();
|
|
18468
18469
|
SYSTEM_FONT_FAMILY = "$system";
|
|
18469
18470
|
TONAL_ELEVATION_ALPHA = [0, 0.05, 0.08, 0.11, 0.12, 0.14];
|
|
@@ -19163,7 +19164,9 @@ var init_validator = __esm({
|
|
|
19163
19164
|
hiddenPath: { type: "string" },
|
|
19164
19165
|
labelPath: { type: "string" },
|
|
19165
19166
|
iconPath: { type: "string" },
|
|
19166
|
-
hiddenPathScope: { type: "string" }
|
|
19167
|
+
hiddenPathScope: { type: "string" },
|
|
19168
|
+
// Hidden until hiddenPath first resolves (fail closed): the Brandy cart icon pair.
|
|
19169
|
+
hiddenUntilResolved: { type: "boolean" }
|
|
19167
19170
|
}
|
|
19168
19171
|
},
|
|
19169
19172
|
navBadge: {
|
|
@@ -46863,16 +46866,23 @@ function iconGlyph(name) {
|
|
|
46863
46866
|
return ICON_GLYPHS[key4] ?? "\xB7";
|
|
46864
46867
|
}
|
|
46865
46868
|
function avatarInitials(initials) {
|
|
46869
|
+
return graphemes(initials).slice(0, 2).join("").toUpperCase();
|
|
46870
|
+
}
|
|
46871
|
+
function graphemes(text32) {
|
|
46866
46872
|
const Segmenter = Intl.Segmenter;
|
|
46867
|
-
|
|
46868
|
-
|
|
46873
|
+
return Segmenter ? Array.from(new Segmenter(void 0, { granularity: "grapheme" }).segment(text32), (part5) => part5.segment) : [...text32];
|
|
46874
|
+
}
|
|
46875
|
+
function avatarStripInitialsFontSize(text32, size) {
|
|
46876
|
+
const base2 = Math.max(8, size * 0.35);
|
|
46877
|
+
const characters = Math.max(1, graphemes(text32).length);
|
|
46878
|
+
return Math.min(base2, size * 0.8 / (characters * 0.62));
|
|
46869
46879
|
}
|
|
46870
|
-
function avatarCircle(initials, size, color, fill2 = false, fontFamily = '"Wix Madefor Text", system-ui') {
|
|
46880
|
+
function avatarCircle(initials, size, color, fill2 = false, fontFamily = '"Wix Madefor Text", system-ui', whole = false) {
|
|
46871
46881
|
let h2 = 0;
|
|
46872
46882
|
for (let i2 = 0; i2 < initials.length; i2++) h2 = (h2 * 31 + initials.charCodeAt(i2)) % 360;
|
|
46873
46883
|
const bg = fill2 ? `hsl(${h2}, 55%, 55%)` : color("surfaceTertiary", "#e6e6e6");
|
|
46874
46884
|
const fg = fill2 ? "#fff" : color("textPrimary", "#111");
|
|
46875
|
-
return /* @__PURE__ */ jsx("div", { style: { width: size, height: size, borderRadius: "50%", background: bg, color: fg, display: "grid", placeItems: "center", fontWeight: 700, fontSize: size * 0.36, fontFamily, flex: "none" }, children: avatarInitials(initials) });
|
|
46885
|
+
return /* @__PURE__ */ jsx("div", { style: { width: size, height: size, borderRadius: "50%", background: bg, color: fg, display: "grid", placeItems: "center", fontWeight: 700, fontSize: whole ? avatarStripInitialsFontSize(initials, size) : size * 0.36, fontFamily, flex: "none", ...whole ? { whiteSpace: "nowrap" } : {} }, children: whole ? initials.toUpperCase() : avatarInitials(initials) });
|
|
46876
46886
|
}
|
|
46877
46887
|
var BINDING_SIGIL2, isBinding, isNodeLike, MD_ESCAPE, MD_ESCAPES, mdEsc, MD_INLINE, CODE_STYLE, ICON_GLYPHS, ICON_GLYPH_NAMES;
|
|
46878
46888
|
var init_helpers = __esm({
|
|
@@ -142717,7 +142727,7 @@ var init_renderNode = __esm({
|
|
|
142717
142727
|
const ring = props2.ringGradient ? ctx.gradient(props2.ringGradient) : void 0;
|
|
142718
142728
|
const wrapStyle = ring ? { marginLeft: i2 === 0 ? 0 : -(size - shift), background: ring, padding: 2.5, borderRadius: "50%" } : { marginLeft: i2 === 0 ? 0 : -(size - shift), border: `2px solid ${C2("surfacePrimary", "#fff")}`, borderRadius: "50%" };
|
|
142719
142729
|
const who2 = asText2(a3.initials).trim();
|
|
142720
|
-
const initials = avatarCircle(who2 || "?", size, C2, true, bodyFont(ctx));
|
|
142730
|
+
const initials = avatarCircle(who2 || "?", size, C2, true, bodyFont(ctx), true);
|
|
142721
142731
|
const photo = typeof a3.imageUrl === "string" && a3.imageUrl && !isBinding(a3.imageUrl) ? a3.imageUrl : "";
|
|
142722
142732
|
const circle = photo ? React21.cloneElement(
|
|
142723
142733
|
initials,
|
|
@@ -142729,7 +142739,7 @@ var init_renderNode = __esm({
|
|
|
142729
142739
|
) : initials;
|
|
142730
142740
|
return who2 ? /* @__PURE__ */ jsx14("div", { role: "listitem", style: wrapStyle, children: React21.cloneElement(circle, { role: "img", "aria-label": who2 }) }, i2) : /* @__PURE__ */ jsx14("div", { "aria-hidden": "true", style: wrapStyle, children: circle }, i2);
|
|
142731
142741
|
}),
|
|
142732
|
-
overflow > 0 && /* @__PURE__ */ jsx14("div", { role: "listitem", style: { marginLeft: -(size - shift), width: size, height: size, borderRadius: "50%", border: `2px solid ${C2("surfacePrimary", "#fff")}`, background: C2("surfaceTertiary", "#e6e6e6"), color: C2("textPrimary", "#111"), display: "grid", placeItems: "center", fontSize: size
|
|
142742
|
+
overflow > 0 && /* @__PURE__ */ jsx14("div", { role: "listitem", style: { marginLeft: -(size - shift), width: size, height: size, borderRadius: "50%", border: `2px solid ${C2("surfacePrimary", "#fff")}`, background: C2("surfaceTertiary", "#e6e6e6"), color: C2("textPrimary", "#111"), display: "grid", placeItems: "center", fontSize: avatarStripInitialsFontSize(`+${overflow}`, size), whiteSpace: "nowrap", fontWeight: 700, fontFamily: bodyFont(ctx) }, children: /* @__PURE__ */ jsxs11("span", { role: "img", "aria-label": `${overflow} more`, children: [
|
|
142733
142743
|
"+",
|
|
142734
142744
|
overflow
|
|
142735
142745
|
] }) })
|
|
@@ -251521,52 +251531,52 @@ var init_preview_assets_generated = __esm({
|
|
|
251521
251531
|
init_define_HHP_CATALOG();
|
|
251522
251532
|
init_preview_assets_format();
|
|
251523
251533
|
PREVIEW_ASSET_MANIFEST = [
|
|
251524
|
-
{ key: "assets/DashboardHost-
|
|
251525
|
-
{ key: "assets/DevDrawer-
|
|
251526
|
-
{ key: "assets/IdiomCompare-
|
|
251527
|
-
{ key: "assets/LightboxViewer-
|
|
251528
|
-
{ key: "assets/OfflineReadingBar-
|
|
251529
|
-
{ key: "assets/PhonePreviewControl-
|
|
251530
|
-
{ key: "assets/SchemeCompare-
|
|
251531
|
-
{ key: "assets/WixFrogTelemetrySink-
|
|
251534
|
+
{ key: "assets/DashboardHost-C3c3C5Wj.js", contentType: "application/javascript; charset=utf-8", offset: 8, length: 2985, sha256: "a752556e6982704b9f7a76552093ae30e1c9a3e8df8efe562f04437a260cd016" },
|
|
251535
|
+
{ key: "assets/DevDrawer-FYRtLcMq.js", contentType: "application/javascript; charset=utf-8", offset: 2993, length: 16783, sha256: "4bdc432259ceca5ab07de47ae42cbd1c12537bf6689af3c324095a35cacfee5b" },
|
|
251536
|
+
{ key: "assets/IdiomCompare-BvAAx3oS.js", contentType: "application/javascript; charset=utf-8", offset: 19776, length: 1926, sha256: "9dbc41aae61da5676304b642c5200194d862ebc0daa4c4feb5e4554c6851753f" },
|
|
251537
|
+
{ key: "assets/LightboxViewer-BL9WAJIa.js", contentType: "application/javascript; charset=utf-8", offset: 21702, length: 17382, sha256: "a7183d048e68fad982eb4b3bc24fe35e62c5d5ae340961b3a878293546baa611" },
|
|
251538
|
+
{ key: "assets/OfflineReadingBar-D1xvtG80.js", contentType: "application/javascript; charset=utf-8", offset: 39084, length: 1646, sha256: "d6ce211f528d5a6325ceeaa8f1e36776abead84c05f6264e19be979c64acb122" },
|
|
251539
|
+
{ key: "assets/PhonePreviewControl-Bh78VjMW.js", contentType: "application/javascript; charset=utf-8", offset: 40730, length: 37851, sha256: "bd5aa62b7558b023669269a4c6c59ebf68c98ca2ed420de031f0d61c5511105f" },
|
|
251540
|
+
{ key: "assets/SchemeCompare-ifXQfx6m.js", contentType: "application/javascript; charset=utf-8", offset: 78581, length: 1858, sha256: "0386811aa47dc321c460d706b327e14a638ae45377dfe06dd2b9ba838978825b" },
|
|
251541
|
+
{ key: "assets/WixFrogTelemetrySink-DiQEfEDD.js", contentType: "application/javascript; charset=utf-8", offset: 80439, length: 3515, sha256: "7afe53100fda7776c39d192b37a75d583d16d61680a10dfc7f14e9eaa4476bfd" },
|
|
251532
251542
|
{ key: "assets/calendar-ics-BvfIYWjG.js", contentType: "application/javascript; charset=utf-8", offset: 83954, length: 2192, sha256: "1636167041e9829ceccd3544297b86b8475c38bd2f759c4dbc17c813dc6e9254" },
|
|
251533
251543
|
{ key: "assets/catalog-B4UJpy5D.js", contentType: "application/javascript; charset=utf-8", offset: 86146, length: 35626, sha256: "90111ffcf2d13eff399836acafd1f2b387859440a29dcd4a0afd8370915992cb" },
|
|
251534
|
-
{ key: "assets/catalogFontFaces-
|
|
251544
|
+
{ key: "assets/catalogFontFaces-XN1GWOyI.js", contentType: "application/javascript; charset=utf-8", offset: 121772, length: 1111, sha256: "bb38483a1dbe9b9ee1a1b148bfe2677543b589846a5c4f9146c8f30e079278e3" },
|
|
251535
251545
|
{ key: "assets/contacts-vcard-BcohPQ0m.js", contentType: "application/javascript; charset=utf-8", offset: 122883, length: 2567, sha256: "c4ff75e96cd909bbb9182c5dc78794fcebc65139fbddef2537711d774fb33ad0" },
|
|
251536
|
-
{ key: "assets/files-transfer-
|
|
251546
|
+
{ key: "assets/files-transfer-DKPE-Wx_.js", contentType: "application/javascript; charset=utf-8", offset: 125450, length: 6446, sha256: "b3ef739c909559c8ec98194fa44baf9632ea51152843d8fdb7f1c775e86a58b6" },
|
|
251537
251547
|
{ key: "assets/frogActionMap-CTMe3Bz1.js", contentType: "application/javascript; charset=utf-8", offset: 131896, length: 1172, sha256: "9f1ce4c70a680dfb902949e1f482c7e47500b69c3350cd091b1b51d674032d53" },
|
|
251538
|
-
{ key: "assets/frogApiRules-
|
|
251548
|
+
{ key: "assets/frogApiRules-Dv8zpQXL.js", contentType: "application/javascript; charset=utf-8", offset: 133068, length: 2207, sha256: "4548d2cd2969fac919330000c2638ae3b7914e623c2e2d4966c219a1e6a42454" },
|
|
251539
251549
|
{ key: "assets/frogScreenMap-S_IRnz20.js", contentType: "application/javascript; charset=utf-8", offset: 135275, length: 1067, sha256: "22b2f71e1b06df8f1e79b890d47fe42e983d37865c2cc9be753e4121764c91e1" },
|
|
251540
251550
|
{ key: "assets/glassPreviewBrowser-DONaOehd.js", contentType: "application/javascript; charset=utf-8", offset: 136342, length: 6578, sha256: "4402c4cddd2a564e7466cdf1e12a0e0277c0400b288e1e5eda1d23e797599d31" },
|
|
251541
251551
|
{ key: "assets/image-preparation-Cj4gldm6.js", contentType: "application/javascript; charset=utf-8", offset: 142920, length: 2704, sha256: "32944ea587c2f3b84389b66b50a850437560238f1c8d33b6275973ee04eee865" },
|
|
251542
|
-
{ key: "assets/index-
|
|
251543
|
-
{ key: "assets/jsx-runtime-CdvZGgm7.js", contentType: "application/javascript; charset=utf-8", offset:
|
|
251544
|
-
{ key: "assets/on-device-ml-D5QGvW8P.js", contentType: "application/javascript; charset=utf-8", offset:
|
|
251545
|
-
{ key: "assets/pdf-
|
|
251546
|
-
{ key: "assets/pdf.worker.min-BGnVRhRG.js", contentType: "application/javascript; charset=utf-8", offset:
|
|
251547
|
-
{ key: "assets/pdf.worker.min-BmVo14Nb.mjs", contentType: "application/javascript; charset=utf-8", offset:
|
|
251548
|
-
{ key: "assets/pdfDocument-
|
|
251549
|
-
{ key: "assets/pdfFetch-Cc8i1I1h.js", contentType: "application/javascript; charset=utf-8", offset:
|
|
251550
|
-
{ key: "assets/scrollLinkedRuntime-
|
|
251551
|
-
{ key: "assets/webviewBridgeHost-
|
|
251552
|
-
{ key: "fonts/Roboto-LICENSE.txt", contentType: "application/octet-stream", offset:
|
|
251553
|
-
{ key: "fonts/Roboto-Variable.ttf", contentType: "font/ttf", offset:
|
|
251554
|
-
{ key: "fonts/WixMadeforDisplay-Bold.ttf", contentType: "font/ttf", offset:
|
|
251555
|
-
{ key: "fonts/WixMadeforDisplay-ExtraBold.ttf", contentType: "font/ttf", offset:
|
|
251556
|
-
{ key: "fonts/WixMadeforDisplay-Medium.ttf", contentType: "font/ttf", offset:
|
|
251557
|
-
{ key: "fonts/WixMadeforDisplay-Regular.ttf", contentType: "font/ttf", offset:
|
|
251558
|
-
{ key: "fonts/WixMadeforDisplay-SemiBold.ttf", contentType: "font/ttf", offset:
|
|
251559
|
-
{ key: "fonts/WixMadeforText-Bold.ttf", contentType: "font/ttf", offset:
|
|
251560
|
-
{ key: "fonts/WixMadeforText-ExtraBold.ttf", contentType: "font/ttf", offset:
|
|
251561
|
-
{ key: "fonts/WixMadeforText-Medium.ttf", contentType: "font/ttf", offset:
|
|
251562
|
-
{ key: "fonts/WixMadeforText-Regular.ttf", contentType: "font/ttf", offset:
|
|
251563
|
-
{ key: "fonts/WixMadeforText-SemiBold.ttf", contentType: "font/ttf", offset:
|
|
251564
|
-
{ key: "himi-sw.js", contentType: "application/javascript; charset=utf-8", offset:
|
|
251565
|
-
{ key: "index.html", contentType: "text/html; charset=utf-8", offset:
|
|
251566
|
-
{ key: "ios-glass-preview.css", contentType: "text/css; charset=utf-8", offset:
|
|
251567
|
-
{ key: "kit-tab-bar.css", contentType: "text/css; charset=utf-8", offset:
|
|
251568
|
-
{ key: "t5-frame.html", contentType: "text/html; charset=utf-8", offset:
|
|
251569
|
-
{ key: "t5-worker-frame.html", contentType: "text/html; charset=utf-8", offset:
|
|
251552
|
+
{ key: "assets/index-DHIwzN34.js", contentType: "application/javascript; charset=utf-8", offset: 145624, length: 1602769, sha256: "9a2ad37030f21115b02bd75fcabdb7156f7d36300e0f7b0a4ac6bdb5fd8749e0" },
|
|
251553
|
+
{ key: "assets/jsx-runtime-CdvZGgm7.js", contentType: "application/javascript; charset=utf-8", offset: 1748393, length: 7751, sha256: "42a78b508d0f309f6a4a6efbb8669015211b3c26574c5b0929884c4d9d20b806" },
|
|
251554
|
+
{ key: "assets/on-device-ml-D5QGvW8P.js", contentType: "application/javascript; charset=utf-8", offset: 1756144, length: 10531, sha256: "914ea54d973624e7bc82d1847444f26084ac16d69be3051b4b5938b1e35beced" },
|
|
251555
|
+
{ key: "assets/pdf-D-4TEGX8.js", contentType: "application/javascript; charset=utf-8", offset: 1766675, length: 488215, sha256: "d71e5b22a5ff1965fd887118ee8b2a74497b48a88f4459c9800569457e1fb547" },
|
|
251556
|
+
{ key: "assets/pdf.worker.min-BGnVRhRG.js", contentType: "application/javascript; charset=utf-8", offset: 2254890, length: 90, sha256: "521a0e528916d678d7588b2cddf3dadd3bb959a6d62426382f61c77a82017e35" },
|
|
251557
|
+
{ key: "assets/pdf.worker.min-BmVo14Nb.mjs", contentType: "application/javascript; charset=utf-8", offset: 2254980, length: 1317034, sha256: "a33cfe728c584fdba4fcc1fd54bcdc2f9f2f13889ddbb5b2bd1d0f8cbe49b84e" },
|
|
251558
|
+
{ key: "assets/pdfDocument-j80BYSSD.js", contentType: "application/javascript; charset=utf-8", offset: 3572014, length: 3470, sha256: "00d6d573b70c279ce0fe6f10555797776f71116d039efe0f68517f9605eb304a" },
|
|
251559
|
+
{ key: "assets/pdfFetch-Cc8i1I1h.js", contentType: "application/javascript; charset=utf-8", offset: 3575484, length: 2266, sha256: "1d21ad008921942217c9eac0c35b1713773b9d89c71e3ab4412781f7bb88f463" },
|
|
251560
|
+
{ key: "assets/scrollLinkedRuntime-Vw3BZ_Yi.js", contentType: "application/javascript; charset=utf-8", offset: 3577750, length: 2278, sha256: "202ae82c77f327c1466bccd2cc7787943bc7be1f72b2774ee649882da2c52ffb" },
|
|
251561
|
+
{ key: "assets/webviewBridgeHost-BnAOqyQc.js", contentType: "application/javascript; charset=utf-8", offset: 3580028, length: 9889, sha256: "4afca9515684ce6f900e1c0773ee667ac9a5944a52487da1fa45455e6ce3c69a" },
|
|
251562
|
+
{ key: "fonts/Roboto-LICENSE.txt", contentType: "application/octet-stream", offset: 3589917, length: 4610, sha256: "994062dd7af4186a739de55dd9e151c63b6301f8e2cbafc608d35c2e87da0cd2" },
|
|
251563
|
+
{ key: "fonts/Roboto-Variable.ttf", contentType: "font/ttf", offset: 3594527, length: 488584, sha256: "d7598e12c5dbef095ff8272cfc55da0250bd07fbdecbac8a530b9b277872a134" },
|
|
251564
|
+
{ key: "fonts/WixMadeforDisplay-Bold.ttf", contentType: "font/ttf", offset: 4083111, length: 90924, sha256: "ec4c7d63772d980d6e147b2df6215fd2737e4b04cebe0cf7e11dc695fb63cdcf" },
|
|
251565
|
+
{ key: "fonts/WixMadeforDisplay-ExtraBold.ttf", contentType: "font/ttf", offset: 4174035, length: 90984, sha256: "bf4c16a2774edd38a921edf3099469866cd74c094fd596f3fa4e81f54a04dfaa" },
|
|
251566
|
+
{ key: "fonts/WixMadeforDisplay-Medium.ttf", contentType: "font/ttf", offset: 4265019, length: 90980, sha256: "368faca44fb9f7207e4af784e94750b1ee59c1098b8689e0f4a918926f244fb5" },
|
|
251567
|
+
{ key: "fonts/WixMadeforDisplay-Regular.ttf", contentType: "font/ttf", offset: 4355999, length: 90872, sha256: "97ed8f1a6772abe26e3d8af5cecfc4b02faa94497d585b0398b5053b739a70c1" },
|
|
251568
|
+
{ key: "fonts/WixMadeforDisplay-SemiBold.ttf", contentType: "font/ttf", offset: 4446871, length: 90980, sha256: "642feab8a48ddf6c7a89d7c2a7c0edfa0e6e773f671287e460e222703563191e" },
|
|
251569
|
+
{ key: "fonts/WixMadeforText-Bold.ttf", contentType: "font/ttf", offset: 4537851, length: 108636, sha256: "37c179b4fefb63ea9637322b84583a2df53aa226c150294eea1675c14b1b8e29" },
|
|
251570
|
+
{ key: "fonts/WixMadeforText-ExtraBold.ttf", contentType: "font/ttf", offset: 4646487, length: 109084, sha256: "62e2fe4718129f36ecdb0ae4de385bd6b81ecc876146447167c6c140fad699a9" },
|
|
251571
|
+
{ key: "fonts/WixMadeforText-Medium.ttf", contentType: "font/ttf", offset: 4755571, length: 109048, sha256: "4ecf270136af928612c76fe4ebade91d8156975e5ea4c0cf9225501dd1788e02" },
|
|
251572
|
+
{ key: "fonts/WixMadeforText-Regular.ttf", contentType: "font/ttf", offset: 4864619, length: 107700, sha256: "dee56f09fd3efc127c1ea95557edc74110c1460a46287da36e0af25efd341ef5" },
|
|
251573
|
+
{ key: "fonts/WixMadeforText-SemiBold.ttf", contentType: "font/ttf", offset: 4972319, length: 88108, sha256: "dced97a77624bc5f8b1ae65850360908297f4588e09feb6f22792d29dc7e765b" },
|
|
251574
|
+
{ key: "himi-sw.js", contentType: "application/javascript; charset=utf-8", offset: 5060427, length: 6818, sha256: "835250c3d8004f27c2b67f9b471984351ba6df07b916d97e33b43c691200a18c" },
|
|
251575
|
+
{ key: "index.html", contentType: "text/html; charset=utf-8", offset: 5067245, length: 4924, sha256: "70a9264e71fbf1398e14f28f41d9db5c3ce4fe873f21f21d530849332e470c63" },
|
|
251576
|
+
{ key: "ios-glass-preview.css", contentType: "text/css; charset=utf-8", offset: 5072169, length: 11457, sha256: "6cb2b75264fa5fa2b4d28851878a5eab0712900e8b3a6c2370cc661d6d820805" },
|
|
251577
|
+
{ key: "kit-tab-bar.css", contentType: "text/css; charset=utf-8", offset: 5083626, length: 1171, sha256: "9e2c3a0faaf05d5471badf167a4d3bdf1c4e6dd65c432eea6d254158bfd99585" },
|
|
251578
|
+
{ key: "t5-frame.html", contentType: "text/html; charset=utf-8", offset: 5084797, length: 24303, sha256: "7ee3dbacf4e6da69c1c7085a2423e33e2adaec933cd897fb2ee2391e3277c3ae" },
|
|
251579
|
+
{ key: "t5-worker-frame.html", contentType: "text/html; charset=utf-8", offset: 5109100, length: 24320, sha256: "d24f399a1fcfa7f696a0d96aadbc983d2624b45712dae9a15545f6914dbb9506" }
|
|
251570
251580
|
];
|
|
251571
251581
|
}
|
|
251572
251582
|
});
|
|
Binary file
|
|
@@ -328,7 +328,7 @@ Three optional parts of a site shell's `site` block add or trim native chrome wi
|
|
|
328
328
|
A target that is a tab switches to that tab (`himi.tab`). Any other target opens its screen (`himi.open`), and so does every target under the `drawer` and `single` layouts, which have no tab bar. Under `menuSource: "runtime"`, a site page target is always opened rather than switched to, because the site's own menu may move that page out of the tab bar on a later launch. On the page or native screen an icon opens, the bar leaves that icon out, so tapping it cannot push a second copy of it. A native screen that draws a top bar of its own keeps it as the author wrote it. A `url` with a `.` or `..` path segment is refused.
|
|
329
329
|
- **`nativePages`**: the author's own Tier-5 screens as rows. Each one is a `tab`, `drawer` or `overflow` entry (an `overflow` entry is linkable only). They join the tab bar, drawer and rail with the site's pages, after the page named by `after` (default: after all of them, and never before `home`). Tabs count toward the four-tab limit together with the site's tabs. The WebView keep-alive cap only concerns site tabs, because a native tab keeps no WebView. Every native page is in `linkableScreens`. It is private by default: a link from outside the app (a website link, another app) to `<scheme>://screen/<screenId>` opens it only when the page sets `"public": true`. `"requiresAuth": true` implies public and signs the user in first. It needs a sign-in that gates deep links, which today means a Wix member binding. Any other app refuses it, a Base44 site included, rather than open the screen signed out. A native page that places the built-in Notifications or Account screen stays public unless it sets `"public": false`, which turns off outside links to that screen. A public native page opens on its tab when it has one. Under the `drawer`, `single` and one-tab `auto` layouts, where there is no tab to select, the link pushes it instead. Account deletion (`himi_delete_account`) cannot be placed. An id must differ from every site page's id and must not start with `drawer_`. A `screenId` must not start with `site_`.
|
|
330
330
|
|
|
331
|
-
**Member screens (Brandy, `wix` binding).** A Brandy app, or a `himi init --template brandy` package, whose contract binds a Wix member client (`wix`) also serves Branded Lite's own member screens, with Branded Lite's builders and workers: the activity feed `himi_notifications`, the inbox `himi_inbox`, My Orders `himi_orders` and My Subscriptions `himi_my_subscriptions`. A native page may place any of them, and a `{ screen }` icon may open one that a native page places (an `overflow` page adds no row). The Account screen links to all of them. The screens they open (an order, a thread, a subscription, the sign-in form) are served too but cannot be placed. A visitor-only contract refuses a native page or icon that names a member screen, saying a `wix` binding is missing. Cart and checkout
|
|
331
|
+
**Member screens (Brandy, `wix` binding).** A Brandy app, or a `himi init --template brandy` package, whose contract binds a Wix member client (`wix`) also serves Branded Lite's own member screens, with Branded Lite's builders and workers: the activity feed `himi_notifications`, the inbox `himi_inbox`, My Orders `himi_orders` and My Subscriptions `himi_my_subscriptions`. A native page may place any of them, and a `{ screen }` icon may open one that a native page places (an `overflow` page adds no row). The Account screen links to all of them. The screens they open (an order, a thread, a subscription, the sign-in form) are served too but cannot be placed. A visitor-only contract refuses a native page or icon that names a member screen, saying a `wix` binding is missing. **Cart and checkout, members only:** a native page may place the cart `himi_cart` (it must set `"requiresAuth": true`) and a `{ screen: "himi_cart" }` icon may open it; checkout is the cart's own button, through the Wix cashier. A signed-in member's cart is the website's own cart, so a change on either side shows on the other (the icon's count refreshes at launch, on sign-in or sign-out and when the app returns to the foreground; a website tab on its next load). Signed out, the cart shows a sign-in prompt and reads no cart. A visitor keeps the website's cart: when the site block declares the site's cart page (id `cart`, or path `/cart` or `/cart-page`, an `overflow` page is fine), the icon opens that page for a visitor and the native cart for a member, and the visitor's icon shows no count. A visitor-only contract that names `himi_cart` is refused. The wishlist (`himi_saved_products`) is not served: it lists products saved on native product screens, which a site shell does not have. Inside these screens, a link to a screen a site shell does not serve goes to the website instead: Chat with us opens the site's contact page, Browse the shop and Browse plans open the site's shop and plans pages (a tab is switched to), and each is removed when the site has no such page. Reorder, which fills the native cart, is removed unless the contract places the cart. A sensible default for a member app is Account and Notifications as drawer rows and a bell that opens Notifications:
|
|
332
332
|
|
|
333
333
|
```json
|
|
334
334
|
"nativePages": [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/himalaya-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1782.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "himi — the Himalaya authoring CLI. Build a Tier-5 content package on your own machine, push it to the production serve as a draft, preview it on web + Himi Player, and read worker logs back — the remote dev loop. Wraps @himalaya/serve-cli for transport.",
|
|
6
6
|
"keywords": [
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
"artifactId": "himalaya-cli"
|
|
83
83
|
}
|
|
84
84
|
},
|
|
85
|
-
"falconPackageHash": "
|
|
85
|
+
"falconPackageHash": "b0741e23207d689e0d13d2c1ac0d2d208be5b86cc03877eed0733f2a"
|
|
86
86
|
}
|
|
@@ -12,6 +12,32 @@ import { isPaymentSetupFailure, payCashierOrder } from "@himalaya/checkout";
|
|
|
12
12
|
import { hostedCheckoutOpener, isHostedWorker } from "../_shared/hosted-checkout.js";
|
|
13
13
|
import { formatCurrency } from "../_shared/engine-intl.js";
|
|
14
14
|
import { logBi, wixErrorCode } from "../_shared/wix-bi.js";
|
|
15
|
+
import { hostSessionFromGlobal } from "@himalaya/iap";
|
|
16
|
+
|
|
17
|
+
/** The host's session clock (a signed-out stub on a host without one). */
|
|
18
|
+
const hostSession = hostSessionFromGlobal();
|
|
19
|
+
/** A web host has no session clock (the stub above always reads signed out): it delivers sign-in and sign-out
|
|
20
|
+
* through the reserved `onIdentityChange` action instead. `undefined` until it first does. Each delivery is a new
|
|
21
|
+
* identity, so it also bumps the generation the members-only cart's rows are checked against. */
|
|
22
|
+
let webSignedIn: boolean | undefined;
|
|
23
|
+
let webGeneration = 0;
|
|
24
|
+
const signedInMember = (): boolean => hostSession.current().kind === "member" || webSignedIn === true;
|
|
25
|
+
/** The members-only cart. Known at BOOT when the screen's bundle is the members-only entry
|
|
26
|
+
* (`himi-branded-lite-member-cart`, which sets the flag before this module runs), so even the boot load never
|
|
27
|
+
* reads a signed-out shopper's cart; also set by a load that names `memberOnly`. */
|
|
28
|
+
let memberOnlyCart = (globalThis as { __himiMemberOnlyCart?: boolean }).__himiMemberOnlyCart === true;
|
|
29
|
+
/** The session generation the rows on show were read under. A members-only cart shows rows only for the CURRENT
|
|
30
|
+
* generation: a member switch while a read or write is in flight never lands the previous member's rows. */
|
|
31
|
+
let rowsGeneration = -1;
|
|
32
|
+
const sessionGeneration = (): number => hostSession.current().generation + webGeneration;
|
|
33
|
+
const memberOnlyArg = (arg: unknown): boolean => (arg as { memberOnly?: unknown } | undefined)?.memberOnly === "1";
|
|
34
|
+
/** Where the in-app cashier returns after payment: this app's own scheme. Another content package on this shell
|
|
35
|
+
* (a Brandy site shell registers its contract's scheme) passes its own on load; only `<scheme>://screen/himi_cart`. */
|
|
36
|
+
let cashierReturnUrl = "himalaya-himi-branded-lite://screen/himi_cart";
|
|
37
|
+
function takeReturnUrl(arg: unknown): void {
|
|
38
|
+
const url = (arg as { returnUrl?: unknown } | undefined)?.returnUrl;
|
|
39
|
+
if (typeof url === "string" && /^[a-z][a-z0-9+.-]*:\/\/screen\/himi_cart$/.test(url)) cashierReturnUrl = url;
|
|
40
|
+
}
|
|
15
41
|
|
|
16
42
|
/** Wix Stores appDefId — the vertical that owns a cart/ecom order, and therefore the
|
|
17
43
|
* `appId` its cashier order is paid under. (Same constant Wix's own tooling uses.) */
|
|
@@ -50,6 +76,9 @@ function cachedUnitPrice(total: string, quantity: number): string {
|
|
|
50
76
|
return total.replace(raw, `${grouped}${digits ? decimal + fraction : ""}`);
|
|
51
77
|
}
|
|
52
78
|
async function readCachedItems(): Promise<Row[]> {
|
|
79
|
+
// A members-only cart keeps no on-device copy: the cart entity is app-scoped, so one member's rows would show to
|
|
80
|
+
// the next member offline.
|
|
81
|
+
if (memberOnlyCart) return [];
|
|
53
82
|
try {
|
|
54
83
|
return ((await getAll(ENTITY)) as unknown as Row[]).map(item => {
|
|
55
84
|
const quantity = Math.max(1, Math.floor(Number(item.quantity) || 1));
|
|
@@ -68,6 +97,7 @@ async function readCachedItems(): Promise<Row[]> {
|
|
|
68
97
|
* (one removed elsewhere, or a removal whose answer was lost), so the offline paint never
|
|
69
98
|
* shows a line that is gone. */
|
|
70
99
|
async function writeCachedItems(rows: Row[]): Promise<void> {
|
|
100
|
+
if (memberOnlyCart) return;
|
|
71
101
|
try {
|
|
72
102
|
const keep = new Set(rows.map((r) => r.id));
|
|
73
103
|
for (const old of (await getAll(ENTITY)) as unknown as Row[]) if (!keep.has(old.id)) await dbRemove(ENTITY, old.id);
|
|
@@ -143,6 +173,12 @@ interface State {
|
|
|
143
173
|
hideContent: boolean;
|
|
144
174
|
noEmpty: boolean;
|
|
145
175
|
noItems: boolean;
|
|
176
|
+
/** A site shell serves this cart to MEMBERS only (`memberOnly` on load):
|
|
177
|
+
* a native visitor cart is not the website's visitor cart, so a signed-out shopper sees the sign-in gate
|
|
178
|
+
* (`needsSignIn`) instead of a second, separate cart. Absent in Branded Lite, where the visitor cart is native. */
|
|
179
|
+
memberOnly?: boolean;
|
|
180
|
+
needsSignIn?: boolean;
|
|
181
|
+
noSignIn?: boolean;
|
|
146
182
|
}
|
|
147
183
|
|
|
148
184
|
function itemId(arg: unknown): string {
|
|
@@ -256,6 +292,16 @@ function updateLineItemQuantity(cartId: string, lineItemId: string, quantity: nu
|
|
|
256
292
|
}
|
|
257
293
|
|
|
258
294
|
function derive(state: State): State {
|
|
295
|
+
// Every state a members-only cart commits passes here, a write's result included: a sign-out while a write was
|
|
296
|
+
// in flight (its identity reload dropped as a concurrent action) still lands on the gate, never the member's rows.
|
|
297
|
+
if (memberOnlyCart && !signedInMember()) {
|
|
298
|
+
state = { ...state, memberOnly: true, needsSignIn: true, status: "ready", errorKind: "", items: [], subtotal: "", commerceSubtotal: "", emptyText: "", checkoutHint: "" };
|
|
299
|
+
} else if (memberOnlyCart && rowsGeneration !== sessionGeneration() && state.items.length > 0) {
|
|
300
|
+
// Rows read under another member (a write's result that landed after the switch): hold a loading state, and
|
|
301
|
+
// reload for this member once the write has settled.
|
|
302
|
+
state = { ...state, memberOnly: true, needsSignIn: false, status: "loading", items: [], subtotal: "", commerceSubtotal: "", checkoutHint: "" };
|
|
303
|
+
queueSessionReload();
|
|
304
|
+
}
|
|
259
305
|
let savedIds: Set<string> | null = null;
|
|
260
306
|
try { savedIds = new Set(readSavedProducts().map(row => row.id)); }
|
|
261
307
|
catch { /* saved storage unavailable: retain the saved flags already shown on each row */ }
|
|
@@ -291,6 +337,9 @@ function derive(state: State): State {
|
|
|
291
337
|
noPaidToast: !state.showPaidToast,
|
|
292
338
|
noCoupon: !state.appliedCode,
|
|
293
339
|
subtotalLabel: copyTemplate("cart.subtotalCount", "Subtotal ({count})", { count: itemCount }),
|
|
340
|
+
noSignIn: !state.needsSignIn,
|
|
341
|
+
// Gated: no content, no empty card, no error card, no checkout footer — only the sign-in gate.
|
|
342
|
+
...(state.needsSignIn ? { hideContent: true, noEmpty: true, noItems: true, isErrored: false, notErrored: true, noOfflineError: true, noServerError: true, noCheckoutHint: true } : {}),
|
|
294
343
|
};
|
|
295
344
|
}
|
|
296
345
|
|
|
@@ -387,7 +436,7 @@ import { withExclusiveWrites } from "../_shared/exclusive-writes.js";
|
|
|
387
436
|
let cartPricing: IapCommerce;
|
|
388
437
|
const defineService = withIapPresentation<State>({
|
|
389
438
|
register: withExclusiveWrites<State>(withOnlineWrites(registerState, ["remove", "increment", "decrement", "checkout", "beginPromo", "applyPromo", "removePromo"], { derive, messageFields: action => action.includes("Promo") ? ["promoError"] : ["checkoutHint"] }), ["load", "remove", "increment", "decrement", "checkout", "applyPromo", "removePromo", "save"], {
|
|
390
|
-
prepare: (action, args) => { if (action === "load") stashCopy(args[0]); },
|
|
439
|
+
prepare: (action, args) => { if (action === "load") { stashCopy(args[0]); if (memberOnlyArg(args[0])) memberOnlyCart = true; takeReturnUrl(args[0]); } },
|
|
391
440
|
coalesce: ["load"],
|
|
392
441
|
// Full cart reloads share the transaction, since they also replace rows and
|
|
393
442
|
// reset promo fields. Only setPromo increments the edit revision: beginPromo's internal error reset
|
|
@@ -418,10 +467,36 @@ const svc = defineService<State, {
|
|
|
418
467
|
increment: (state: State, arg?: unknown) => Promise<State>;
|
|
419
468
|
decrement: (state: State, arg?: unknown) => Promise<State>;
|
|
420
469
|
checkout: (state: State) => Promise<State>;
|
|
470
|
+
dropForSession: (state: State) => State;
|
|
471
|
+
onIdentityChange: (state: State, change?: unknown) => State;
|
|
421
472
|
}>("himiStoreCart", {
|
|
422
|
-
state: derive({ status: "loading", errorKind: "", items: [], subtotal: "", subtotalLabel: "", emptyText: "", checkoutHint: "", showPaidToast: false, noPaidToast: true, itemCount: 0, promoCode: "", promoEditRevision: 0, appliedCode: "", appliedLabel: "", couponId: "", promoError: "", promoBusy: false, noPromoError: true, hasCoupon: false, discount: "", noDiscount: true, noCheckoutHint: true, noCoupon: true, isLoading: true, notLoading: false, isErrored: false, notErrored: true, noOfflineError: true, noServerError: true, hideContent: true, noEmpty: true, noItems: true }),
|
|
473
|
+
state: derive({ status: "loading", errorKind: "", items: [], subtotal: "", subtotalLabel: "", emptyText: "", checkoutHint: "", showPaidToast: false, noPaidToast: true, itemCount: 0, promoCode: "", promoEditRevision: 0, appliedCode: "", appliedLabel: "", couponId: "", promoError: "", promoBusy: false, noPromoError: true, hasCoupon: false, discount: "", noDiscount: true, noCheckoutHint: true, noCoupon: true, isLoading: true, notLoading: false, isErrored: false, notErrored: true, noOfflineError: true, noServerError: true, hideContent: true, noEmpty: true, noItems: true, memberOnly: false, needsSignIn: false, noSignIn: true }),
|
|
423
474
|
actions: {
|
|
475
|
+
// Not a write: it runs even while one is in flight, so a member switch clears the previous member's rows AT ONCE.
|
|
476
|
+
dropForSession: (state) => derive(state),
|
|
477
|
+
// The web host's identity hook (see `webSignedIn`): a members-only cart follows it as it follows the native clock.
|
|
478
|
+
onIdentityChange: (state, change) => {
|
|
479
|
+
webSignedIn = (change as { signedIn?: unknown } | undefined)?.signedIn === true;
|
|
480
|
+
webGeneration++;
|
|
481
|
+
if (memberOnlyCart) queueSessionReload();
|
|
482
|
+
return derive(state);
|
|
483
|
+
},
|
|
424
484
|
load: async (state, arg) => {
|
|
485
|
+
// A members-only cart (a site shell) never shows a signed-out shopper's native cart. `prepare` sets the flag
|
|
486
|
+
// before coalescing, so a load already in flight (the boot load) re-checks it before it lands.
|
|
487
|
+
if (memberOnlyArg(arg)) memberOnlyCart = true;
|
|
488
|
+
const gated = (): State => derive({ ...state, memberOnly: true, needsSignIn: true, status: "ready", errorKind: "", items: [], subtotal: "", commerceSubtotal: "", emptyText: "", checkoutHint: "" });
|
|
489
|
+
if (memberOnlyCart && !signedInMember()) return gated();
|
|
490
|
+
if (memberOnlyCart) state = { ...state, memberOnly: true, needsSignIn: false };
|
|
491
|
+
const readUnder = sessionGeneration();
|
|
492
|
+
// This read is for the current member: rows it derives stand until the generation moves on.
|
|
493
|
+
if (memberOnlyCart) rowsGeneration = readUnder;
|
|
494
|
+
const landed = (next: State): State => {
|
|
495
|
+
if (!memberOnlyCart) return next;
|
|
496
|
+
if (!signedInMember()) return gated();
|
|
497
|
+
if (sessionGeneration() !== readUnder) { reloadForSession(); return derive({ ...next, memberOnly: true, needsSignIn: false, status: "loading", items: [] }); }
|
|
498
|
+
return derive({ ...next, memberOnly: true, needsSignIn: false });
|
|
499
|
+
};
|
|
425
500
|
// 1) Instant paint from the on-device cache (offline-safe; empty on first-ever run).
|
|
426
501
|
const cached = await readCachedItems();
|
|
427
502
|
const base = cached.length
|
|
@@ -429,12 +504,12 @@ const svc = defineService<State, {
|
|
|
429
504
|
: state;
|
|
430
505
|
// 2) Revalidate from Wix and refresh the cache.
|
|
431
506
|
try {
|
|
432
|
-
return await refresh(state);
|
|
507
|
+
return landed(await refresh(state));
|
|
433
508
|
} catch (error) {
|
|
434
509
|
// Offline / fetch failure: keep the cached items instead of a blank error state.
|
|
435
|
-
return cached.length
|
|
510
|
+
return landed(cached.length
|
|
436
511
|
? base
|
|
437
|
-
: derive({ ...state, status: "error", errorKind: isOfflineFailure(error) ? "offline" : "server", items: [], subtotal: "", emptyText: copyParam("cart.loadErrorText", "Cart could not load."), checkoutHint: "" });
|
|
512
|
+
: derive({ ...state, status: "error", errorKind: isOfflineFailure(error) ? "offline" : "server", items: [], subtotal: "", emptyText: copyParam("cart.loadErrorText", "Cart could not load."), checkoutHint: "" }));
|
|
438
513
|
}
|
|
439
514
|
},
|
|
440
515
|
setPromo: (state, arg) => derive({ ...state, promoEditRevision: (state.promoEditRevision ?? 0) + 1, promoCode: (typeof arg === "string" ? arg : String((arg as { value?: unknown } | undefined)?.value ?? "")).slice(0, 100), promoError: "" }),
|
|
@@ -587,7 +662,7 @@ const svc = defineService<State, {
|
|
|
587
662
|
cashierUrl: async () => {
|
|
588
663
|
const redirect = await createRedirectSession({
|
|
589
664
|
ecomCheckout: { checkoutId },
|
|
590
|
-
callbacks: { postFlowUrl:
|
|
665
|
+
callbacks: { postFlowUrl: cashierReturnUrl },
|
|
591
666
|
});
|
|
592
667
|
return redirect.redirectSession?.fullUrl;
|
|
593
668
|
},
|
|
@@ -607,5 +682,22 @@ const svc = defineService<State, {
|
|
|
607
682
|
},
|
|
608
683
|
});
|
|
609
684
|
|
|
685
|
+
/** Reload until the rows on show are this session generation's. A load that coalesces into one already in flight
|
|
686
|
+
* (or is dropped behind a write) returns before reading, so try again once it settles (a coalesced call resolves when the load in flight completes); a few tries bound it. */
|
|
687
|
+
/** From `derive`: reload after the commit in progress has settled (a few promise turns later). Once per stale streak. */
|
|
688
|
+
let sessionReloadQueued = false;
|
|
689
|
+
function queueSessionReload(): void {
|
|
690
|
+
if (sessionReloadQueued) return;
|
|
691
|
+
sessionReloadQueued = true;
|
|
692
|
+
void Promise.resolve().then(() => undefined).then(() => undefined).then(() => { sessionReloadQueued = false; reloadForSession(); });
|
|
693
|
+
}
|
|
694
|
+
function reloadForSession(tries = 4): void {
|
|
695
|
+
void Promise.resolve(svc.load()).finally(() => {
|
|
696
|
+
if (tries > 1 && memberOnlyCart && signedInMember() && rowsGeneration !== sessionGeneration()) reloadForSession(tries - 1);
|
|
697
|
+
});
|
|
698
|
+
}
|
|
610
699
|
svc.load();
|
|
700
|
+
// A members-only cart follows the signed-in identity: a sign-in shows the member's cart, a sign-out the gate.
|
|
701
|
+
// The host clock notifies at once on subscribe, which the boot load above already covers.
|
|
702
|
+
hostSession.subscribe(() => { if (memberOnlyCart) { void svc.dropForSession(); reloadForSession(); } });
|
|
611
703
|
export { svc };
|
|
@@ -12,6 +12,32 @@ import { isPaymentSetupFailure, payCashierOrder } from "@himalaya/checkout";
|
|
|
12
12
|
import { hostedCheckoutOpener, isHostedWorker } from "../_shared/hosted-checkout.js";
|
|
13
13
|
import { formatCurrency } from "../_shared/engine-intl.js";
|
|
14
14
|
import { logBi, wixErrorCode } from "../_shared/wix-bi.js";
|
|
15
|
+
import { hostSessionFromGlobal } from "@himalaya/iap";
|
|
16
|
+
|
|
17
|
+
/** The host's session clock (a signed-out stub on a host without one). */
|
|
18
|
+
const hostSession = hostSessionFromGlobal();
|
|
19
|
+
/** A web host has no session clock (the stub above always reads signed out): it delivers sign-in and sign-out
|
|
20
|
+
* through the reserved `onIdentityChange` action instead. `undefined` until it first does. Each delivery is a new
|
|
21
|
+
* identity, so it also bumps the generation the members-only cart's rows are checked against. */
|
|
22
|
+
let webSignedIn: boolean | undefined;
|
|
23
|
+
let webGeneration = 0;
|
|
24
|
+
const signedInMember = (): boolean => hostSession.current().kind === "member" || webSignedIn === true;
|
|
25
|
+
/** The members-only cart. Known at BOOT when the screen's bundle is the members-only entry
|
|
26
|
+
* (`himi-branded-lite-member-cart`, which sets the flag before this module runs), so even the boot load never
|
|
27
|
+
* reads a signed-out shopper's cart; also set by a load that names `memberOnly`. */
|
|
28
|
+
let memberOnlyCart = (globalThis as { __himiMemberOnlyCart?: boolean }).__himiMemberOnlyCart === true;
|
|
29
|
+
/** The session generation the rows on show were read under. A members-only cart shows rows only for the CURRENT
|
|
30
|
+
* generation: a member switch while a read or write is in flight never lands the previous member's rows. */
|
|
31
|
+
let rowsGeneration = -1;
|
|
32
|
+
const sessionGeneration = (): number => hostSession.current().generation + webGeneration;
|
|
33
|
+
const memberOnlyArg = (arg: unknown): boolean => (arg as { memberOnly?: unknown } | undefined)?.memberOnly === "1";
|
|
34
|
+
/** Where the in-app cashier returns after payment: this app's own scheme. Another content package on this shell
|
|
35
|
+
* (a Brandy site shell registers its contract's scheme) passes its own on load; only `<scheme>://screen/himi_cart`. */
|
|
36
|
+
let cashierReturnUrl = "himalaya-himi-branded-lite://screen/himi_cart";
|
|
37
|
+
function takeReturnUrl(arg: unknown): void {
|
|
38
|
+
const url = (arg as { returnUrl?: unknown } | undefined)?.returnUrl;
|
|
39
|
+
if (typeof url === "string" && /^[a-z][a-z0-9+.-]*:\/\/screen\/himi_cart$/.test(url)) cashierReturnUrl = url;
|
|
40
|
+
}
|
|
15
41
|
|
|
16
42
|
/** Wix Stores appDefId — the vertical that owns a cart/ecom order, and therefore the
|
|
17
43
|
* `appId` its cashier order is paid under. (Same constant Wix's own tooling uses.) */
|
|
@@ -50,6 +76,9 @@ function cachedUnitPrice(total: string, quantity: number): string {
|
|
|
50
76
|
return total.replace(raw, `${grouped}${digits ? decimal + fraction : ""}`);
|
|
51
77
|
}
|
|
52
78
|
async function readCachedItems(): Promise<Row[]> {
|
|
79
|
+
// A members-only cart keeps no on-device copy: the cart entity is app-scoped, so one member's rows would show to
|
|
80
|
+
// the next member offline.
|
|
81
|
+
if (memberOnlyCart) return [];
|
|
53
82
|
try {
|
|
54
83
|
return ((await getAll(ENTITY)) as unknown as Row[]).map(item => {
|
|
55
84
|
const quantity = Math.max(1, Math.floor(Number(item.quantity) || 1));
|
|
@@ -68,6 +97,7 @@ async function readCachedItems(): Promise<Row[]> {
|
|
|
68
97
|
* (one removed elsewhere, or a removal whose answer was lost), so the offline paint never
|
|
69
98
|
* shows a line that is gone. */
|
|
70
99
|
async function writeCachedItems(rows: Row[]): Promise<void> {
|
|
100
|
+
if (memberOnlyCart) return;
|
|
71
101
|
try {
|
|
72
102
|
const keep = new Set(rows.map((r) => r.id));
|
|
73
103
|
for (const old of (await getAll(ENTITY)) as unknown as Row[]) if (!keep.has(old.id)) await dbRemove(ENTITY, old.id);
|
|
@@ -143,6 +173,12 @@ interface State {
|
|
|
143
173
|
hideContent: boolean;
|
|
144
174
|
noEmpty: boolean;
|
|
145
175
|
noItems: boolean;
|
|
176
|
+
/** A site shell serves this cart to MEMBERS only (`memberOnly` on load):
|
|
177
|
+
* a native visitor cart is not the website's visitor cart, so a signed-out shopper sees the sign-in gate
|
|
178
|
+
* (`needsSignIn`) instead of a second, separate cart. Absent in Branded Lite, where the visitor cart is native. */
|
|
179
|
+
memberOnly?: boolean;
|
|
180
|
+
needsSignIn?: boolean;
|
|
181
|
+
noSignIn?: boolean;
|
|
146
182
|
}
|
|
147
183
|
|
|
148
184
|
function itemId(arg: unknown): string {
|
|
@@ -256,6 +292,16 @@ function updateLineItemQuantity(cartId: string, lineItemId: string, quantity: nu
|
|
|
256
292
|
}
|
|
257
293
|
|
|
258
294
|
function derive(state: State): State {
|
|
295
|
+
// Every state a members-only cart commits passes here, a write's result included: a sign-out while a write was
|
|
296
|
+
// in flight (its identity reload dropped as a concurrent action) still lands on the gate, never the member's rows.
|
|
297
|
+
if (memberOnlyCart && !signedInMember()) {
|
|
298
|
+
state = { ...state, memberOnly: true, needsSignIn: true, status: "ready", errorKind: "", items: [], subtotal: "", commerceSubtotal: "", emptyText: "", checkoutHint: "" };
|
|
299
|
+
} else if (memberOnlyCart && rowsGeneration !== sessionGeneration() && state.items.length > 0) {
|
|
300
|
+
// Rows read under another member (a write's result that landed after the switch): hold a loading state, and
|
|
301
|
+
// reload for this member once the write has settled.
|
|
302
|
+
state = { ...state, memberOnly: true, needsSignIn: false, status: "loading", items: [], subtotal: "", commerceSubtotal: "", checkoutHint: "" };
|
|
303
|
+
queueSessionReload();
|
|
304
|
+
}
|
|
259
305
|
let savedIds: Set<string> | null = null;
|
|
260
306
|
try { savedIds = new Set(readSavedProducts().map(row => row.id)); }
|
|
261
307
|
catch { /* saved storage unavailable: retain the saved flags already shown on each row */ }
|
|
@@ -291,6 +337,9 @@ function derive(state: State): State {
|
|
|
291
337
|
noPaidToast: !state.showPaidToast,
|
|
292
338
|
noCoupon: !state.appliedCode,
|
|
293
339
|
subtotalLabel: copyTemplate("cart.subtotalCount", "Subtotal ({count})", { count: itemCount }),
|
|
340
|
+
noSignIn: !state.needsSignIn,
|
|
341
|
+
// Gated: no content, no empty card, no error card, no checkout footer — only the sign-in gate.
|
|
342
|
+
...(state.needsSignIn ? { hideContent: true, noEmpty: true, noItems: true, isErrored: false, notErrored: true, noOfflineError: true, noServerError: true, noCheckoutHint: true } : {}),
|
|
294
343
|
};
|
|
295
344
|
}
|
|
296
345
|
|
|
@@ -387,7 +436,7 @@ import { withExclusiveWrites } from "../_shared/exclusive-writes.js";
|
|
|
387
436
|
let cartPricing: IapCommerce;
|
|
388
437
|
const defineService = withIapPresentation<State>({
|
|
389
438
|
register: withExclusiveWrites<State>(withOnlineWrites(registerState, ["remove", "increment", "decrement", "checkout", "beginPromo", "applyPromo", "removePromo"], { derive, messageFields: action => action.includes("Promo") ? ["promoError"] : ["checkoutHint"] }), ["load", "remove", "increment", "decrement", "checkout", "applyPromo", "removePromo", "save"], {
|
|
390
|
-
prepare: (action, args) => { if (action === "load") stashCopy(args[0]); },
|
|
439
|
+
prepare: (action, args) => { if (action === "load") { stashCopy(args[0]); if (memberOnlyArg(args[0])) memberOnlyCart = true; takeReturnUrl(args[0]); } },
|
|
391
440
|
coalesce: ["load"],
|
|
392
441
|
// Full cart reloads share the transaction, since they also replace rows and
|
|
393
442
|
// reset promo fields. Only setPromo increments the edit revision: beginPromo's internal error reset
|
|
@@ -418,10 +467,36 @@ const svc = defineService<State, {
|
|
|
418
467
|
increment: (state: State, arg?: unknown) => Promise<State>;
|
|
419
468
|
decrement: (state: State, arg?: unknown) => Promise<State>;
|
|
420
469
|
checkout: (state: State) => Promise<State>;
|
|
470
|
+
dropForSession: (state: State) => State;
|
|
471
|
+
onIdentityChange: (state: State, change?: unknown) => State;
|
|
421
472
|
}>("himiStoreCart", {
|
|
422
|
-
state: derive({ status: "loading", errorKind: "", items: [], subtotal: "", subtotalLabel: "", emptyText: "", checkoutHint: "", showPaidToast: false, noPaidToast: true, itemCount: 0, promoCode: "", promoEditRevision: 0, appliedCode: "", appliedLabel: "", couponId: "", promoError: "", promoBusy: false, noPromoError: true, hasCoupon: false, discount: "", noDiscount: true, noCheckoutHint: true, noCoupon: true, isLoading: true, notLoading: false, isErrored: false, notErrored: true, noOfflineError: true, noServerError: true, hideContent: true, noEmpty: true, noItems: true }),
|
|
473
|
+
state: derive({ status: "loading", errorKind: "", items: [], subtotal: "", subtotalLabel: "", emptyText: "", checkoutHint: "", showPaidToast: false, noPaidToast: true, itemCount: 0, promoCode: "", promoEditRevision: 0, appliedCode: "", appliedLabel: "", couponId: "", promoError: "", promoBusy: false, noPromoError: true, hasCoupon: false, discount: "", noDiscount: true, noCheckoutHint: true, noCoupon: true, isLoading: true, notLoading: false, isErrored: false, notErrored: true, noOfflineError: true, noServerError: true, hideContent: true, noEmpty: true, noItems: true, memberOnly: false, needsSignIn: false, noSignIn: true }),
|
|
423
474
|
actions: {
|
|
475
|
+
// Not a write: it runs even while one is in flight, so a member switch clears the previous member's rows AT ONCE.
|
|
476
|
+
dropForSession: (state) => derive(state),
|
|
477
|
+
// The web host's identity hook (see `webSignedIn`): a members-only cart follows it as it follows the native clock.
|
|
478
|
+
onIdentityChange: (state, change) => {
|
|
479
|
+
webSignedIn = (change as { signedIn?: unknown } | undefined)?.signedIn === true;
|
|
480
|
+
webGeneration++;
|
|
481
|
+
if (memberOnlyCart) queueSessionReload();
|
|
482
|
+
return derive(state);
|
|
483
|
+
},
|
|
424
484
|
load: async (state, arg) => {
|
|
485
|
+
// A members-only cart (a site shell) never shows a signed-out shopper's native cart. `prepare` sets the flag
|
|
486
|
+
// before coalescing, so a load already in flight (the boot load) re-checks it before it lands.
|
|
487
|
+
if (memberOnlyArg(arg)) memberOnlyCart = true;
|
|
488
|
+
const gated = (): State => derive({ ...state, memberOnly: true, needsSignIn: true, status: "ready", errorKind: "", items: [], subtotal: "", commerceSubtotal: "", emptyText: "", checkoutHint: "" });
|
|
489
|
+
if (memberOnlyCart && !signedInMember()) return gated();
|
|
490
|
+
if (memberOnlyCart) state = { ...state, memberOnly: true, needsSignIn: false };
|
|
491
|
+
const readUnder = sessionGeneration();
|
|
492
|
+
// This read is for the current member: rows it derives stand until the generation moves on.
|
|
493
|
+
if (memberOnlyCart) rowsGeneration = readUnder;
|
|
494
|
+
const landed = (next: State): State => {
|
|
495
|
+
if (!memberOnlyCart) return next;
|
|
496
|
+
if (!signedInMember()) return gated();
|
|
497
|
+
if (sessionGeneration() !== readUnder) { reloadForSession(); return derive({ ...next, memberOnly: true, needsSignIn: false, status: "loading", items: [] }); }
|
|
498
|
+
return derive({ ...next, memberOnly: true, needsSignIn: false });
|
|
499
|
+
};
|
|
425
500
|
// 1) Instant paint from the on-device cache (offline-safe; empty on first-ever run).
|
|
426
501
|
const cached = await readCachedItems();
|
|
427
502
|
const base = cached.length
|
|
@@ -429,12 +504,12 @@ const svc = defineService<State, {
|
|
|
429
504
|
: state;
|
|
430
505
|
// 2) Revalidate from Wix and refresh the cache.
|
|
431
506
|
try {
|
|
432
|
-
return await refresh(state);
|
|
507
|
+
return landed(await refresh(state));
|
|
433
508
|
} catch (error) {
|
|
434
509
|
// Offline / fetch failure: keep the cached items instead of a blank error state.
|
|
435
|
-
return cached.length
|
|
510
|
+
return landed(cached.length
|
|
436
511
|
? base
|
|
437
|
-
: derive({ ...state, status: "error", errorKind: isOfflineFailure(error) ? "offline" : "server", items: [], subtotal: "", emptyText: copyParam("cart.loadErrorText", "Cart could not load."), checkoutHint: "" });
|
|
512
|
+
: derive({ ...state, status: "error", errorKind: isOfflineFailure(error) ? "offline" : "server", items: [], subtotal: "", emptyText: copyParam("cart.loadErrorText", "Cart could not load."), checkoutHint: "" }));
|
|
438
513
|
}
|
|
439
514
|
},
|
|
440
515
|
setPromo: (state, arg) => derive({ ...state, promoEditRevision: (state.promoEditRevision ?? 0) + 1, promoCode: (typeof arg === "string" ? arg : String((arg as { value?: unknown } | undefined)?.value ?? "")).slice(0, 100), promoError: "" }),
|
|
@@ -587,7 +662,7 @@ const svc = defineService<State, {
|
|
|
587
662
|
cashierUrl: async () => {
|
|
588
663
|
const redirect = await createRedirectSession({
|
|
589
664
|
ecomCheckout: { checkoutId },
|
|
590
|
-
callbacks: { postFlowUrl:
|
|
665
|
+
callbacks: { postFlowUrl: cashierReturnUrl },
|
|
591
666
|
});
|
|
592
667
|
return redirect.redirectSession?.fullUrl;
|
|
593
668
|
},
|
|
@@ -607,5 +682,22 @@ const svc = defineService<State, {
|
|
|
607
682
|
},
|
|
608
683
|
});
|
|
609
684
|
|
|
685
|
+
/** Reload until the rows on show are this session generation's. A load that coalesces into one already in flight
|
|
686
|
+
* (or is dropped behind a write) returns before reading, so try again once it settles (a coalesced call resolves when the load in flight completes); a few tries bound it. */
|
|
687
|
+
/** From `derive`: reload after the commit in progress has settled (a few promise turns later). Once per stale streak. */
|
|
688
|
+
let sessionReloadQueued = false;
|
|
689
|
+
function queueSessionReload(): void {
|
|
690
|
+
if (sessionReloadQueued) return;
|
|
691
|
+
sessionReloadQueued = true;
|
|
692
|
+
void Promise.resolve().then(() => undefined).then(() => undefined).then(() => { sessionReloadQueued = false; reloadForSession(); });
|
|
693
|
+
}
|
|
694
|
+
function reloadForSession(tries = 4): void {
|
|
695
|
+
void Promise.resolve(svc.load()).finally(() => {
|
|
696
|
+
if (tries > 1 && memberOnlyCart && signedInMember() && rowsGeneration !== sessionGeneration()) reloadForSession(tries - 1);
|
|
697
|
+
});
|
|
698
|
+
}
|
|
610
699
|
svc.load();
|
|
700
|
+
// A members-only cart follows the signed-in identity: a sign-in shows the member's cart, a sign-out the gate.
|
|
701
|
+
// The host clock notifies at once on subscribe, which the boot load above already covers.
|
|
702
|
+
hostSession.subscribe(() => { if (memberOnlyCart) { void svc.dropForSession(); reloadForSession(); } });
|
|
611
703
|
export { svc };
|