@wix/himalaya-cli 0.1851.0 → 0.1853.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/dev-server/src/builder.d.ts +5 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/schema.d.ts +13 -3
- package/dist/browser-plane/assets.json +5 -5
- package/dist/browser-plane/preview-deferred/{166f7ee733ea8d0fe7bba8b796232efd4f5413e22af4a8aeee20cae1069b2fd6.bin → fb500748f6c4768468f2e7f985aa67c38633077c7a98caaa6b500c7b00eea8e9.bin} +1 -1
- package/dist/browser-plane/sw.js +7 -7
- package/dist/cli.mjs +10136 -9601
- package/dist/preview-assets.generated.bin +0 -0
- package/guides/component-index.md +1 -1
- package/guides/component-reference.json +2 -2
- package/guides/component-reference.md +8 -1
- package/guides/designing-himi-screens.md +5 -1
- package/guides/himi-json-output.md +13 -3
- package/guides/one-app-section-mappings.md +1 -1
- package/guides/one-app-to-himi-app.md +60 -10
- package/guides/sdk-reference.json +2 -2
- package/package.json +2 -2
- package/template-icons/bare-fashion.png +0 -0
- package/templates/bare-fashion/README.md +52 -0
- package/templates/bare-fashion/config.ts +474 -0
- package/templates/bare-fashion/dev/index.ts +16526 -0
- package/templates/bare-fashion/himalaya.content.json +70 -0
- package/templates/bare-fashion/himalaya.template.json +18 -0
- package/templates/bare-fashion/icon.png +0 -0
- package/templates/bare-fashion/platforms.json +3 -0
- package/templates/bare-fashion/tier5-src/_shared/app-locale.ts +70 -0
- package/templates/bare-fashion/tier5-src/_shared/bare-fashion-address-book.ts +116 -0
- package/templates/bare-fashion/tier5-src/_shared/bare-fashion-address-countries.ts +261 -0
- package/templates/bare-fashion/tier5-src/_shared/bare-fashion-bag-count.ts +24 -0
- package/templates/bare-fashion/tier5-src/_shared/bare-fashion-categories.ts +48 -0
- package/templates/bare-fashion/tier5-src/_shared/bare-fashion-facets.ts +265 -0
- package/templates/bare-fashion/tier5-src/_shared/bare-fashion-load-error.ts +38 -0
- package/templates/bare-fashion/tier5-src/_shared/bare-fashion-product-card.ts +136 -0
- package/templates/bare-fashion/tier5-src/_shared/bare-fashion-store-options.ts +129 -0
- package/templates/bare-fashion/tier5-src/_shared/branded-lite-hosted.ts +282 -0
- package/templates/bare-fashion/tier5-src/_shared/collection-contract.ts +228 -0
- package/templates/bare-fashion/tier5-src/_shared/collection-query.ts +201 -0
- package/templates/bare-fashion/tier5-src/_shared/collection-service.ts +429 -0
- package/templates/bare-fashion/tier5-src/_shared/engine-intl.ts +529 -0
- package/templates/bare-fashion/tier5-src/_shared/himi-account.ts +209 -0
- package/templates/bare-fashion/tier5-src/_shared/himi-copy.ts +123 -0
- package/templates/bare-fashion/tier5-src/_shared/himi-layouts.ts +142 -0
- package/templates/bare-fashion/tier5-src/_shared/himi-store-categories.ts +108 -0
- package/templates/bare-fashion/tier5-src/_shared/himi-store-saved.ts +57 -0
- package/templates/bare-fashion/tier5-src/_shared/himi-store.ts +7 -0
- package/templates/bare-fashion/tier5-src/_shared/himi-text.ts +24 -0
- package/templates/bare-fashion/tier5-src/_shared/hosted-checkout.ts +70 -0
- package/templates/bare-fashion/tier5-src/_shared/live-session.ts +172 -0
- package/templates/bare-fashion/tier5-src/_shared/local-preferences.ts +38 -0
- package/templates/bare-fashion/tier5-src/_shared/member-access.ts +63 -0
- package/templates/bare-fashion/tier5-src/_shared/member-avatar.ts +76 -0
- package/templates/bare-fashion/tier5-src/_shared/member-orders.ts +8 -0
- package/templates/bare-fashion/tier5-src/_shared/online-actions.ts +76 -0
- package/templates/bare-fashion/tier5-src/_shared/owner-load-error.ts +348 -0
- package/templates/bare-fashion/tier5-src/himi-bare-fashion-account/index.ts +127 -0
- package/templates/bare-fashion/tier5-src/himi-bare-fashion-address-form/index.ts +367 -0
- package/templates/bare-fashion/tier5-src/himi-bare-fashion-addresses/index.ts +202 -0
- package/templates/bare-fashion/tier5-src/himi-bare-fashion-appearance/index.ts +73 -0
- package/templates/bare-fashion/tier5-src/himi-bare-fashion-cart/index.ts +540 -0
- package/templates/bare-fashion/tier5-src/himi-bare-fashion-collection/index.ts +111 -0
- package/templates/bare-fashion/tier5-src/himi-bare-fashion-home/index.ts +241 -0
- package/templates/bare-fashion/tier5-src/himi-bare-fashion-nav/index.ts +56 -0
- package/templates/bare-fashion/tier5-src/himi-bare-fashion-order/index.ts +437 -0
- package/templates/bare-fashion/tier5-src/himi-bare-fashion-product/index.ts +650 -0
- package/templates/bare-fashion/tier5-src/himi-bare-fashion-products/index.ts +142 -0
- package/templates/bare-fashion/tier5-src/himi-bare-fashion-saved/index.ts +45 -0
- package/templates/bare-fashion/tier5-src/himi-bare-fashion-search/index.ts +199 -0
- package/templates/bare-fashion/tier5-src/himi-bare-fashion-shop/index.ts +79 -0
- package/templates/bare-fashion/tier5-src/himi-bare-fashion-sign-in/index.ts +269 -0
- package/templates/bare-fashion/tier5-src/himi-bare-fashion-wallet/index.ts +224 -0
- package/templates/bare-fashion/tier5-src/himi-branded-lite-info/index.ts +209 -0
- package/templates/bare-fashion/tier5-src/himi-branded-lite-orders/index.ts +327 -0
- package/templates/bare-fashion/tier5-src/wix-spaces-collections/index.ts +48 -0
- package/templates/bare-fashion/tier5-src/wix-spaces-delete-account/index.ts +59 -0
- package/templates/bare-fashion/tier5-src/wix-spaces-view-profile/index.ts +119 -0
- package/templates/bare-fashion/tokens.json +348 -0
- package/templates/beauty-salon/dev/index.ts +223 -0
- package/templates/beauty-salon/l10n/ar.json +6 -0
- package/templates/beauty-salon/l10n/cs.json +6 -0
- package/templates/beauty-salon/l10n/da.json +6 -0
- package/templates/beauty-salon/l10n/de.json +6 -0
- package/templates/beauty-salon/l10n/el.json +6 -0
- package/templates/beauty-salon/l10n/en.json +9 -2
- package/templates/beauty-salon/l10n/es.json +6 -0
- package/templates/beauty-salon/l10n/fi.json +6 -0
- package/templates/beauty-salon/l10n/fr.json +6 -0
- package/templates/beauty-salon/l10n/he.json +5 -0
- package/templates/beauty-salon/l10n/hu.json +6 -0
- package/templates/beauty-salon/l10n/id.json +6 -0
- package/templates/beauty-salon/l10n/it.json +6 -0
- package/templates/beauty-salon/l10n/ja.json +6 -0
- package/templates/beauty-salon/l10n/ko.json +6 -0
- package/templates/beauty-salon/l10n/lt.json +6 -0
- package/templates/beauty-salon/l10n/nl.json +6 -0
- package/templates/beauty-salon/l10n/no.json +6 -0
- package/templates/beauty-salon/l10n/pl.json +6 -0
- package/templates/beauty-salon/l10n/pt.json +6 -0
- package/templates/beauty-salon/l10n/ru.json +6 -0
- package/templates/beauty-salon/l10n/sv.json +6 -0
- package/templates/beauty-salon/l10n/th.json +6 -0
- package/templates/beauty-salon/l10n/tr.json +6 -0
- package/templates/beauty-salon/l10n/uk.json +6 -0
- package/templates/beauty-salon/l10n/vi.json +6 -0
- package/templates/beauty-salon/l10n/zh.json +6 -0
- package/templates/beauty-salon/tier5-src/_shared/collection-query.ts +8 -0
- package/templates/beauty-salon/tier5-src/_shared/collection-service.ts +7 -1
- package/templates/beauty-salon/tier5-src/_shared/lifecycle.ts +15 -0
- package/templates/beauty-salon/tier5-src/_shared/nav-member-avatar.ts +92 -0
- package/templates/beauty-salon/tier5-src/himi-branded-lite-nav/index.ts +15 -6
- package/templates/beauty-salon/tier5-src/himi-store-account/index.ts +26 -1
- package/templates/beauty-salon-owner/tier5-src/_shared/collection-query.ts +8 -0
- package/templates/beauty-salon-owner/tier5-src/_shared/collection-service.ts +7 -1
- package/templates/branded-lite/dev/index.ts +2167 -0
- package/templates/branded-lite/l10n/ar.json +6 -0
- package/templates/branded-lite/l10n/cs.json +6 -0
- package/templates/branded-lite/l10n/da.json +6 -0
- package/templates/branded-lite/l10n/de.json +6 -0
- package/templates/branded-lite/l10n/el.json +6 -0
- package/templates/branded-lite/l10n/en.json +12 -5
- package/templates/branded-lite/l10n/es.json +6 -0
- package/templates/branded-lite/l10n/fi.json +6 -0
- package/templates/branded-lite/l10n/fr.json +6 -0
- package/templates/branded-lite/l10n/he.json +5 -0
- package/templates/branded-lite/l10n/hu.json +6 -0
- package/templates/branded-lite/l10n/id.json +6 -0
- package/templates/branded-lite/l10n/it.json +6 -0
- package/templates/branded-lite/l10n/ja.json +6 -0
- package/templates/branded-lite/l10n/ko.json +6 -0
- package/templates/branded-lite/l10n/lt.json +6 -0
- package/templates/branded-lite/l10n/nl.json +6 -0
- package/templates/branded-lite/l10n/no.json +6 -0
- package/templates/branded-lite/l10n/pl.json +6 -0
- package/templates/branded-lite/l10n/pt.json +6 -0
- package/templates/branded-lite/l10n/ru.json +6 -0
- package/templates/branded-lite/l10n/sv.json +6 -0
- package/templates/branded-lite/l10n/th.json +6 -0
- package/templates/branded-lite/l10n/tr.json +6 -0
- package/templates/branded-lite/l10n/uk.json +6 -0
- package/templates/branded-lite/l10n/vi.json +6 -0
- package/templates/branded-lite/l10n/zh.json +6 -0
- package/templates/branded-lite/recipes/upcoming-bookings.json +118 -6
- package/templates/branded-lite/tier5-src/_shared/access-gates.ts +0 -13
- package/templates/branded-lite/tier5-src/_shared/collection-query-legacy.ts +7 -0
- package/templates/branded-lite/tier5-src/_shared/collection-query.ts +7 -0
- package/templates/branded-lite/tier5-src/_shared/collection-service.ts +7 -1
- package/templates/branded-lite/tier5-src/_shared/events-inline-options.ts +55 -3
- package/templates/branded-lite/tier5-src/_shared/events-inline.ts +5 -3
- package/templates/branded-lite/tier5-src/_shared/guest-sign-in.ts +36 -0
- package/templates/branded-lite/tier5-src/_shared/lifecycle.ts +15 -0
- package/templates/branded-lite/tier5-src/_shared/nav-member-avatar.ts +92 -0
- package/templates/branded-lite/tier5-src/_shared/upcoming-bookings-section.ts +15 -4
- package/templates/branded-lite/tier5-src/himi-branded-lite-access-nav/index.ts +14 -9
- package/templates/branded-lite/tier5-src/himi-branded-lite-inbox/index.ts +6 -1
- package/templates/branded-lite/tier5-src/himi-branded-lite-nav/index.ts +15 -6
- package/templates/branded-lite/tier5-src/himi-branded-lite-notifications/index.ts +8 -1
- package/templates/branded-lite/tier5-src/himi-events-list/index.ts +17 -0
- package/templates/branded-lite/tier5-src/himi-store-account/index.ts +26 -1
- package/templates/brandy/tier5-src/_shared/collection-query-legacy.ts +7 -0
- package/templates/brandy/tier5-src/_shared/collection-query.ts +7 -0
- package/templates/brandy/tier5-src/_shared/collection-service.ts +7 -1
- package/templates/brandy/tier5-src/_shared/guest-sign-in.ts +36 -0
- package/templates/brandy/tier5-src/himi-branded-lite-inbox/index.ts +6 -1
- package/templates/brandy/tier5-src/himi-branded-lite-notifications/index.ts +8 -1
- package/templates/brandy/tier5-src/himi-store-account/index.ts +26 -1
- package/templates/community-club/dev/index.ts +223 -0
- package/templates/community-club/l10n/ar.json +6 -0
- package/templates/community-club/l10n/cs.json +6 -0
- package/templates/community-club/l10n/da.json +6 -0
- package/templates/community-club/l10n/de.json +6 -0
- package/templates/community-club/l10n/el.json +6 -0
- package/templates/community-club/l10n/en.json +9 -2
- package/templates/community-club/l10n/es.json +6 -0
- package/templates/community-club/l10n/fi.json +6 -0
- package/templates/community-club/l10n/fr.json +6 -0
- package/templates/community-club/l10n/he.json +5 -0
- package/templates/community-club/l10n/hu.json +6 -0
- package/templates/community-club/l10n/id.json +6 -0
- package/templates/community-club/l10n/it.json +6 -0
- package/templates/community-club/l10n/ja.json +6 -0
- package/templates/community-club/l10n/ko.json +6 -0
- package/templates/community-club/l10n/lt.json +6 -0
- package/templates/community-club/l10n/nl.json +6 -0
- package/templates/community-club/l10n/no.json +6 -0
- package/templates/community-club/l10n/pl.json +6 -0
- package/templates/community-club/l10n/pt.json +6 -0
- package/templates/community-club/l10n/ru.json +6 -0
- package/templates/community-club/l10n/sv.json +6 -0
- package/templates/community-club/l10n/th.json +6 -0
- package/templates/community-club/l10n/tr.json +6 -0
- package/templates/community-club/l10n/uk.json +6 -0
- package/templates/community-club/l10n/vi.json +6 -0
- package/templates/community-club/l10n/zh.json +6 -0
- package/templates/community-club/tier5-src/_shared/collection-query.ts +8 -0
- package/templates/community-club/tier5-src/_shared/collection-service.ts +7 -1
- package/templates/community-club/tier5-src/_shared/events-inline-options.ts +77 -0
- package/templates/community-club/tier5-src/himi-events-list/index.ts +17 -0
- package/templates/community-club/tier5-src/himi-store-account/index.ts +26 -1
- package/templates/community-club-owner/tier5-src/_shared/collection-query.ts +8 -0
- package/templates/community-club-owner/tier5-src/_shared/collection-service.ts +7 -1
- package/templates/conference/tier5-src/_shared/collection-query.ts +8 -0
- package/templates/conference/tier5-src/_shared/collection-service.ts +7 -1
- package/templates/conference/tier5-src/_shared/events-inline-options.ts +77 -0
- package/templates/conference/tier5-src/himi-events-list/index.ts +17 -0
- package/templates/conference/tier5-src/himi-store-account/index.ts +26 -1
- package/templates/events-meetups/dev/index.ts +142 -0
- package/templates/events-meetups/l10n/ar.json +6 -0
- package/templates/events-meetups/l10n/cs.json +6 -0
- package/templates/events-meetups/l10n/da.json +6 -0
- package/templates/events-meetups/l10n/de.json +6 -0
- package/templates/events-meetups/l10n/el.json +6 -0
- package/templates/events-meetups/l10n/en.json +8 -1
- package/templates/events-meetups/l10n/es.json +6 -0
- package/templates/events-meetups/l10n/fi.json +6 -0
- package/templates/events-meetups/l10n/fr.json +6 -0
- package/templates/events-meetups/l10n/he.json +5 -0
- package/templates/events-meetups/l10n/hu.json +6 -0
- package/templates/events-meetups/l10n/id.json +6 -0
- package/templates/events-meetups/l10n/it.json +6 -0
- package/templates/events-meetups/l10n/ja.json +6 -0
- package/templates/events-meetups/l10n/ko.json +6 -0
- package/templates/events-meetups/l10n/lt.json +6 -0
- package/templates/events-meetups/l10n/nl.json +6 -0
- package/templates/events-meetups/l10n/no.json +6 -0
- package/templates/events-meetups/l10n/pl.json +6 -0
- package/templates/events-meetups/l10n/pt.json +6 -0
- package/templates/events-meetups/l10n/ru.json +6 -0
- package/templates/events-meetups/l10n/sv.json +6 -0
- package/templates/events-meetups/l10n/th.json +6 -0
- package/templates/events-meetups/l10n/tr.json +6 -0
- package/templates/events-meetups/l10n/uk.json +6 -0
- package/templates/events-meetups/l10n/vi.json +6 -0
- package/templates/events-meetups/l10n/zh.json +6 -0
- package/templates/events-meetups/tier5-src/_shared/collection-query.ts +8 -0
- package/templates/events-meetups/tier5-src/_shared/collection-service.ts +7 -1
- package/templates/events-meetups/tier5-src/_shared/events-inline-options.ts +77 -0
- package/templates/events-meetups/tier5-src/himi-events-list/index.ts +17 -0
- package/templates/events-meetups/tier5-src/himi-store-account/index.ts +26 -1
- package/templates/events-meetups-owner/tier5-src/_shared/collection-query.ts +8 -0
- package/templates/events-meetups-owner/tier5-src/_shared/collection-service.ts +7 -1
- package/templates/fitness-gym/tier5-src/_shared/collection-query.ts +8 -0
- package/templates/fitness-gym/tier5-src/_shared/collection-service.ts +7 -1
- package/templates/fitness-gym/tier5-src/_shared/guest-sign-in.ts +36 -0
- package/templates/fitness-gym/tier5-src/himi-branded-lite-notifications/index.ts +8 -1
- package/templates/fitness-gym/tier5-src/himi-store-account/index.ts +26 -1
- package/templates/gym-fitness/dev/index.ts +385 -0
- package/templates/gym-fitness/l10n/ar.json +6 -0
- package/templates/gym-fitness/l10n/cs.json +6 -0
- package/templates/gym-fitness/l10n/da.json +6 -0
- package/templates/gym-fitness/l10n/de.json +6 -0
- package/templates/gym-fitness/l10n/el.json +6 -0
- package/templates/gym-fitness/l10n/en.json +9 -2
- package/templates/gym-fitness/l10n/es.json +6 -0
- package/templates/gym-fitness/l10n/fi.json +6 -0
- package/templates/gym-fitness/l10n/fr.json +6 -0
- package/templates/gym-fitness/l10n/he.json +5 -0
- package/templates/gym-fitness/l10n/hu.json +6 -0
- package/templates/gym-fitness/l10n/id.json +6 -0
- package/templates/gym-fitness/l10n/it.json +6 -0
- package/templates/gym-fitness/l10n/ja.json +6 -0
- package/templates/gym-fitness/l10n/ko.json +6 -0
- package/templates/gym-fitness/l10n/lt.json +6 -0
- package/templates/gym-fitness/l10n/nl.json +6 -0
- package/templates/gym-fitness/l10n/no.json +6 -0
- package/templates/gym-fitness/l10n/pl.json +6 -0
- package/templates/gym-fitness/l10n/pt.json +6 -0
- package/templates/gym-fitness/l10n/ru.json +6 -0
- package/templates/gym-fitness/l10n/sv.json +6 -0
- package/templates/gym-fitness/l10n/th.json +6 -0
- package/templates/gym-fitness/l10n/tr.json +6 -0
- package/templates/gym-fitness/l10n/uk.json +6 -0
- package/templates/gym-fitness/l10n/vi.json +6 -0
- package/templates/gym-fitness/l10n/zh.json +6 -0
- package/templates/gym-fitness/tier5-src/_shared/collection-query.ts +8 -0
- package/templates/gym-fitness/tier5-src/_shared/collection-service.ts +7 -1
- package/templates/gym-fitness/tier5-src/_shared/events-inline-options.ts +77 -0
- package/templates/gym-fitness/tier5-src/_shared/lifecycle.ts +15 -0
- package/templates/gym-fitness/tier5-src/_shared/nav-member-avatar.ts +92 -0
- package/templates/gym-fitness/tier5-src/himi-branded-lite-nav/index.ts +15 -6
- package/templates/gym-fitness/tier5-src/himi-events-list/index.ts +17 -0
- package/templates/gym-fitness/tier5-src/himi-store-account/index.ts +26 -1
- package/templates/gym-fitness-owner/tier5-src/_shared/collection-query.ts +8 -0
- package/templates/gym-fitness-owner/tier5-src/_shared/collection-service.ts +7 -1
- package/templates/medical-services/tier5-src/_shared/collection-query.ts +8 -0
- package/templates/medical-services/tier5-src/_shared/collection-service.ts +7 -1
- package/templates/medical-services/tier5-src/_shared/guest-sign-in.ts +36 -0
- package/templates/medical-services/tier5-src/himi-branded-lite-notifications/index.ts +8 -1
- package/templates/medical-services/tier5-src/himi-store-account/index.ts +26 -1
- package/templates/nonprofit-cause/dev/index.ts +223 -0
- package/templates/nonprofit-cause/l10n/ar.json +6 -0
- package/templates/nonprofit-cause/l10n/cs.json +6 -0
- package/templates/nonprofit-cause/l10n/da.json +6 -0
- package/templates/nonprofit-cause/l10n/de.json +6 -0
- package/templates/nonprofit-cause/l10n/el.json +6 -0
- package/templates/nonprofit-cause/l10n/en.json +8 -1
- package/templates/nonprofit-cause/l10n/es.json +6 -0
- package/templates/nonprofit-cause/l10n/fi.json +6 -0
- package/templates/nonprofit-cause/l10n/fr.json +6 -0
- package/templates/nonprofit-cause/l10n/he.json +5 -0
- package/templates/nonprofit-cause/l10n/hu.json +6 -0
- package/templates/nonprofit-cause/l10n/id.json +6 -0
- package/templates/nonprofit-cause/l10n/it.json +6 -0
- package/templates/nonprofit-cause/l10n/ja.json +6 -0
- package/templates/nonprofit-cause/l10n/ko.json +6 -0
- package/templates/nonprofit-cause/l10n/lt.json +6 -0
- package/templates/nonprofit-cause/l10n/nl.json +6 -0
- package/templates/nonprofit-cause/l10n/no.json +6 -0
- package/templates/nonprofit-cause/l10n/pl.json +6 -0
- package/templates/nonprofit-cause/l10n/pt.json +6 -0
- package/templates/nonprofit-cause/l10n/ru.json +6 -0
- package/templates/nonprofit-cause/l10n/sv.json +6 -0
- package/templates/nonprofit-cause/l10n/th.json +6 -0
- package/templates/nonprofit-cause/l10n/tr.json +6 -0
- package/templates/nonprofit-cause/l10n/uk.json +6 -0
- package/templates/nonprofit-cause/l10n/vi.json +6 -0
- package/templates/nonprofit-cause/l10n/zh.json +6 -0
- package/templates/nonprofit-cause/tier5-src/_shared/collection-query.ts +8 -0
- package/templates/nonprofit-cause/tier5-src/_shared/collection-service.ts +7 -1
- package/templates/nonprofit-cause/tier5-src/_shared/events-inline-options.ts +77 -0
- package/templates/nonprofit-cause/tier5-src/himi-events-list/index.ts +17 -0
- package/templates/nonprofit-cause/tier5-src/himi-store-account/index.ts +26 -1
- package/templates/nonprofit-cause-owner/tier5-src/_shared/collection-query.ts +8 -0
- package/templates/nonprofit-cause-owner/tier5-src/_shared/collection-service.ts +7 -1
- package/templates/owner-lite/tier5-src/_shared/collection-query.ts +8 -0
- package/templates/owner-lite/tier5-src/_shared/collection-service.ts +7 -1
- package/templates/personal-fitness-trainer/tier5-src/_shared/collection-query.ts +8 -0
- package/templates/personal-fitness-trainer/tier5-src/_shared/collection-service.ts +7 -1
- package/templates/personal-fitness-trainer/tier5-src/himi-store-account/index.ts +26 -1
- package/templates/podcast-creator/dev/index.ts +223 -0
- package/templates/podcast-creator/l10n/ar.json +6 -0
- package/templates/podcast-creator/l10n/cs.json +6 -0
- package/templates/podcast-creator/l10n/da.json +6 -0
- package/templates/podcast-creator/l10n/de.json +6 -0
- package/templates/podcast-creator/l10n/el.json +6 -0
- package/templates/podcast-creator/l10n/en.json +8 -1
- package/templates/podcast-creator/l10n/es.json +6 -0
- package/templates/podcast-creator/l10n/fi.json +6 -0
- package/templates/podcast-creator/l10n/fr.json +6 -0
- package/templates/podcast-creator/l10n/he.json +5 -0
- package/templates/podcast-creator/l10n/hu.json +6 -0
- package/templates/podcast-creator/l10n/id.json +6 -0
- package/templates/podcast-creator/l10n/it.json +6 -0
- package/templates/podcast-creator/l10n/ja.json +6 -0
- package/templates/podcast-creator/l10n/ko.json +6 -0
- package/templates/podcast-creator/l10n/lt.json +6 -0
- package/templates/podcast-creator/l10n/nl.json +6 -0
- package/templates/podcast-creator/l10n/no.json +6 -0
- package/templates/podcast-creator/l10n/pl.json +6 -0
- package/templates/podcast-creator/l10n/pt.json +6 -0
- package/templates/podcast-creator/l10n/ru.json +6 -0
- package/templates/podcast-creator/l10n/sv.json +6 -0
- package/templates/podcast-creator/l10n/th.json +6 -0
- package/templates/podcast-creator/l10n/tr.json +6 -0
- package/templates/podcast-creator/l10n/uk.json +6 -0
- package/templates/podcast-creator/l10n/vi.json +6 -0
- package/templates/podcast-creator/l10n/zh.json +6 -0
- package/templates/podcast-creator/tier5-src/_shared/collection-query.ts +8 -0
- package/templates/podcast-creator/tier5-src/_shared/collection-service.ts +7 -1
- package/templates/podcast-creator/tier5-src/_shared/events-inline-options.ts +77 -0
- package/templates/podcast-creator/tier5-src/himi-events-list/index.ts +17 -0
- package/templates/podcast-creator/tier5-src/himi-store-account/index.ts +26 -1
- package/templates/podcast-creator-owner/tier5-src/_shared/collection-query.ts +8 -0
- package/templates/podcast-creator-owner/tier5-src/_shared/collection-service.ts +7 -1
- package/templates/portfolio-creative/dev/index.ts +142 -0
- package/templates/portfolio-creative/l10n/ar.json +6 -0
- package/templates/portfolio-creative/l10n/cs.json +6 -0
- package/templates/portfolio-creative/l10n/da.json +6 -0
- package/templates/portfolio-creative/l10n/de.json +6 -0
- package/templates/portfolio-creative/l10n/el.json +6 -0
- package/templates/portfolio-creative/l10n/en.json +8 -1
- package/templates/portfolio-creative/l10n/es.json +6 -0
- package/templates/portfolio-creative/l10n/fi.json +6 -0
- package/templates/portfolio-creative/l10n/fr.json +6 -0
- package/templates/portfolio-creative/l10n/he.json +5 -0
- package/templates/portfolio-creative/l10n/hu.json +6 -0
- package/templates/portfolio-creative/l10n/id.json +6 -0
- package/templates/portfolio-creative/l10n/it.json +6 -0
- package/templates/portfolio-creative/l10n/ja.json +6 -0
- package/templates/portfolio-creative/l10n/ko.json +6 -0
- package/templates/portfolio-creative/l10n/lt.json +6 -0
- package/templates/portfolio-creative/l10n/nl.json +6 -0
- package/templates/portfolio-creative/l10n/no.json +6 -0
- package/templates/portfolio-creative/l10n/pl.json +6 -0
- package/templates/portfolio-creative/l10n/pt.json +6 -0
- package/templates/portfolio-creative/l10n/ru.json +6 -0
- package/templates/portfolio-creative/l10n/sv.json +6 -0
- package/templates/portfolio-creative/l10n/th.json +6 -0
- package/templates/portfolio-creative/l10n/tr.json +6 -0
- package/templates/portfolio-creative/l10n/uk.json +6 -0
- package/templates/portfolio-creative/l10n/vi.json +6 -0
- package/templates/portfolio-creative/l10n/zh.json +6 -0
- package/templates/portfolio-creative/tier5-src/_shared/collection-query.ts +8 -0
- package/templates/portfolio-creative/tier5-src/_shared/collection-service.ts +7 -1
- package/templates/portfolio-creative/tier5-src/_shared/events-inline-options.ts +77 -0
- package/templates/portfolio-creative/tier5-src/himi-events-list/index.ts +17 -0
- package/templates/portfolio-creative/tier5-src/himi-store-account/index.ts +26 -1
- package/templates/portfolio-creative-owner/tier5-src/_shared/collection-query.ts +8 -0
- package/templates/portfolio-creative-owner/tier5-src/_shared/collection-service.ts +7 -1
- package/templates/restaurant/dev/index.ts +142 -0
- package/templates/restaurant/l10n/ar.json +6 -0
- package/templates/restaurant/l10n/cs.json +6 -0
- package/templates/restaurant/l10n/da.json +6 -0
- package/templates/restaurant/l10n/de.json +6 -0
- package/templates/restaurant/l10n/el.json +6 -0
- package/templates/restaurant/l10n/en.json +9 -2
- package/templates/restaurant/l10n/es.json +6 -0
- package/templates/restaurant/l10n/fi.json +6 -0
- package/templates/restaurant/l10n/fr.json +6 -0
- package/templates/restaurant/l10n/he.json +5 -0
- package/templates/restaurant/l10n/hu.json +6 -0
- package/templates/restaurant/l10n/id.json +6 -0
- package/templates/restaurant/l10n/it.json +6 -0
- package/templates/restaurant/l10n/ja.json +6 -0
- package/templates/restaurant/l10n/ko.json +6 -0
- package/templates/restaurant/l10n/lt.json +6 -0
- package/templates/restaurant/l10n/nl.json +6 -0
- package/templates/restaurant/l10n/no.json +6 -0
- package/templates/restaurant/l10n/pl.json +6 -0
- package/templates/restaurant/l10n/pt.json +6 -0
- package/templates/restaurant/l10n/ru.json +6 -0
- package/templates/restaurant/l10n/sv.json +6 -0
- package/templates/restaurant/l10n/th.json +6 -0
- package/templates/restaurant/l10n/tr.json +6 -0
- package/templates/restaurant/l10n/uk.json +6 -0
- package/templates/restaurant/l10n/vi.json +6 -0
- package/templates/restaurant/l10n/zh.json +6 -0
- package/templates/restaurant/tier5-src/_shared/collection-query.ts +8 -0
- package/templates/restaurant/tier5-src/_shared/collection-service.ts +7 -1
- package/templates/restaurant/tier5-src/_shared/events-inline-options.ts +77 -0
- package/templates/restaurant/tier5-src/himi-events-list/index.ts +17 -0
- package/templates/restaurant/tier5-src/himi-store-account/index.ts +26 -1
- package/templates/restaurant-owner/tier5-src/_shared/collection-query.ts +8 -0
- package/templates/restaurant-owner/tier5-src/_shared/collection-service.ts +7 -1
- package/templates/retail-store/dev/index.ts +142 -0
- package/templates/retail-store/l10n/ar.json +6 -0
- package/templates/retail-store/l10n/cs.json +6 -0
- package/templates/retail-store/l10n/da.json +6 -0
- package/templates/retail-store/l10n/de.json +6 -0
- package/templates/retail-store/l10n/el.json +6 -0
- package/templates/retail-store/l10n/en.json +8 -1
- package/templates/retail-store/l10n/es.json +6 -0
- package/templates/retail-store/l10n/fi.json +6 -0
- package/templates/retail-store/l10n/fr.json +6 -0
- package/templates/retail-store/l10n/he.json +5 -0
- package/templates/retail-store/l10n/hu.json +6 -0
- package/templates/retail-store/l10n/id.json +6 -0
- package/templates/retail-store/l10n/it.json +6 -0
- package/templates/retail-store/l10n/ja.json +6 -0
- package/templates/retail-store/l10n/ko.json +6 -0
- package/templates/retail-store/l10n/lt.json +6 -0
- package/templates/retail-store/l10n/nl.json +6 -0
- package/templates/retail-store/l10n/no.json +6 -0
- package/templates/retail-store/l10n/pl.json +6 -0
- package/templates/retail-store/l10n/pt.json +6 -0
- package/templates/retail-store/l10n/ru.json +6 -0
- package/templates/retail-store/l10n/sv.json +6 -0
- package/templates/retail-store/l10n/th.json +6 -0
- package/templates/retail-store/l10n/tr.json +6 -0
- package/templates/retail-store/l10n/uk.json +6 -0
- package/templates/retail-store/l10n/vi.json +6 -0
- package/templates/retail-store/l10n/zh.json +6 -0
- package/templates/retail-store/tier5-src/_shared/collection-query-legacy.ts +7 -0
- package/templates/retail-store/tier5-src/_shared/collection-query.ts +7 -0
- package/templates/retail-store/tier5-src/_shared/collection-service.ts +7 -1
- package/templates/retail-store/tier5-src/himi-store-account/index.ts +26 -1
- package/templates/retail-store-owner/tier5-src/_shared/collection-query.ts +8 -0
- package/templates/retail-store-owner/tier5-src/_shared/collection-service.ts +7 -1
- package/templates/salon-spa/tier5-src/_shared/collection-query.ts +8 -0
- package/templates/salon-spa/tier5-src/_shared/collection-service.ts +7 -1
- package/templates/salon-spa/tier5-src/himi-store-account/index.ts +26 -1
- package/templates/wholesale-store/tier5-src/_shared/collection-query-legacy.ts +7 -0
- package/templates/wholesale-store/tier5-src/_shared/collection-query.ts +7 -0
- package/templates/wholesale-store/tier5-src/_shared/collection-service.ts +7 -1
- package/templates/wholesale-store/tier5-src/himi-store-account/index.ts +26 -1
- package/templates/yoga-studio/dev/index.ts +304 -0
- package/templates/yoga-studio/l10n/ar.json +6 -0
- package/templates/yoga-studio/l10n/cs.json +6 -0
- package/templates/yoga-studio/l10n/da.json +6 -0
- package/templates/yoga-studio/l10n/de.json +6 -0
- package/templates/yoga-studio/l10n/el.json +6 -0
- package/templates/yoga-studio/l10n/en.json +10 -3
- package/templates/yoga-studio/l10n/es.json +6 -0
- package/templates/yoga-studio/l10n/fi.json +6 -0
- package/templates/yoga-studio/l10n/fr.json +6 -0
- package/templates/yoga-studio/l10n/he.json +5 -0
- package/templates/yoga-studio/l10n/hu.json +6 -0
- package/templates/yoga-studio/l10n/id.json +6 -0
- package/templates/yoga-studio/l10n/it.json +6 -0
- package/templates/yoga-studio/l10n/ja.json +6 -0
- package/templates/yoga-studio/l10n/ko.json +6 -0
- package/templates/yoga-studio/l10n/lt.json +6 -0
- package/templates/yoga-studio/l10n/nl.json +6 -0
- package/templates/yoga-studio/l10n/no.json +6 -0
- package/templates/yoga-studio/l10n/pl.json +6 -0
- package/templates/yoga-studio/l10n/pt.json +6 -0
- package/templates/yoga-studio/l10n/ru.json +6 -0
- package/templates/yoga-studio/l10n/sv.json +6 -0
- package/templates/yoga-studio/l10n/th.json +6 -0
- package/templates/yoga-studio/l10n/tr.json +6 -0
- package/templates/yoga-studio/l10n/uk.json +6 -0
- package/templates/yoga-studio/l10n/vi.json +6 -0
- package/templates/yoga-studio/l10n/zh.json +6 -0
- package/templates/yoga-studio/tier5-src/_shared/collection-query.ts +8 -0
- package/templates/yoga-studio/tier5-src/_shared/collection-service.ts +7 -1
- package/templates/yoga-studio/tier5-src/_shared/events-inline-options.ts +77 -0
- package/templates/yoga-studio/tier5-src/_shared/lifecycle.ts +15 -0
- package/templates/yoga-studio/tier5-src/_shared/nav-member-avatar.ts +92 -0
- package/templates/yoga-studio/tier5-src/himi-branded-lite-nav/index.ts +15 -6
- package/templates/yoga-studio/tier5-src/himi-events-list/index.ts +17 -0
- package/templates/yoga-studio/tier5-src/himi-store-account/index.ts +26 -1
- package/templates/yoga-studio-owner/tier5-src/_shared/collection-query.ts +8 -0
- package/templates/yoga-studio-owner/tier5-src/_shared/collection-service.ts +7 -1
|
@@ -0,0 +1,650 @@
|
|
|
1
|
+
// Tier-5 bundle: himi-store — product detail.
|
|
2
|
+
import { defineService, navigate } from "@himalaya/state";
|
|
3
|
+
import { share as shareSheet } from "@himalaya/share";
|
|
4
|
+
import { addToCurrentCart, getCurrentCart } from "@himalaya/wix-ecom";
|
|
5
|
+
import { get, upsert, enqueue, type DbEntity } from "@himalaya/local-db";
|
|
6
|
+
import { getStoreProduct, plainText, productImage, productPrice, wixMediaUrl, productGallery as sdkProductGallery, WIX_DETAIL_IMAGE, type StoreProduct } from "../_shared/himi-store.js";
|
|
7
|
+
import { cleanTitle } from "../_shared/himi-text.js";
|
|
8
|
+
import { stashCopy, copyParam, copyTemplate } from "../_shared/himi-copy.js";
|
|
9
|
+
import { isBridgeUnavailable } from "../_shared/owner-load-error.js";
|
|
10
|
+
import { isProductSaved, toggleSavedProduct } from "../_shared/himi-store-saved.js";
|
|
11
|
+
import { productOptions, defaultChoice, cartOptionsPayload, selectionSummary, type StoreOption } from "../_shared/bare-fashion-store-options.js";
|
|
12
|
+
import { publishBagCount } from "../_shared/bare-fashion-bag-count.js";
|
|
13
|
+
import { errorFlags, errorKindOf, type ErrorKind } from "../_shared/bare-fashion-load-error.js";
|
|
14
|
+
|
|
15
|
+
// Offline-first (data-offline): the detail is a public READ-THROUGH — when the live
|
|
16
|
+
// product fetch fails (offline) fall back to the last-synced row the catalog cached
|
|
17
|
+
// under the `products` entity. `addToCart` is WRITE-BEHIND against the `cart` entity —
|
|
18
|
+
// the line is cached OPTIMISTICALLY, then the Wix write is attempted; if it can't
|
|
19
|
+
// reach the bridge/network the add is ENQUEUED for replay on reconnect. Every local-db
|
|
20
|
+
// call is wrapped so a build without the `local_database` grant behaves exactly as
|
|
21
|
+
// before (online-only, no cache/queue).
|
|
22
|
+
const PRODUCTS_ENTITY = "products";
|
|
23
|
+
const CART_ENTITY = "cart";
|
|
24
|
+
/** The cached product row, or `ok: false` when the cache cannot be read (no `local_database`
|
|
25
|
+
* grant → online-only). */
|
|
26
|
+
async function readCachedProduct(id: string): Promise<{ ok: true; row: DbEntity | null } | { ok: false }> {
|
|
27
|
+
try { return { ok: true, row: await get(PRODUCTS_ENTITY, id) }; } catch { return { ok: false }; }
|
|
28
|
+
}
|
|
29
|
+
/** Keep the product a visitor opened, so it opens again offline (the summary the fallback shows). */
|
|
30
|
+
async function cacheProduct(row: DbEntity): Promise<void> { try { await upsert(PRODUCTS_ENTITY, row); } catch { /* capability not granted */ } }
|
|
31
|
+
async function cartPut(row: DbEntity): Promise<void> { try { await upsert(CART_ENTITY, row); } catch { /* capability not granted */ } }
|
|
32
|
+
async function queueWrite(actionId: string, params: Record<string, string>): Promise<void> { try { await enqueue(actionId, params); } catch { /* capability not granted */ } }
|
|
33
|
+
|
|
34
|
+
// Add to cart runs in two steps on one host `_poll` (a worker has no timer):
|
|
35
|
+
// 1. The tap (`addToCart`) sets `adding` — the spinner paints — marks the add
|
|
36
|
+
// pending and arms the poll with `immediate`. The host fires that first tick
|
|
37
|
+
// only AFTER it has committed the tap's state, so the write never races it.
|
|
38
|
+
// (Re-entering the service from inside the tap reducer did race: the second
|
|
39
|
+
// action read the pre-tap state, stood down, and the spinner never cleared.)
|
|
40
|
+
// 2. `tick` runs the pending write, then opens the "Item added to bag" drawer.
|
|
41
|
+
// Later ticks close the drawer once DRAWER_MS has passed. `_poll` has no stop
|
|
42
|
+
// form, so idle ticks are cheap no-ops (`undefined`); ticks never stack, so a
|
|
43
|
+
// slow write is not re-entered.
|
|
44
|
+
// Both latches live at module scope, not in state: restored state must never
|
|
45
|
+
// replay an add or re-open a drawer from a previous visit.
|
|
46
|
+
const DRAWER_MS = 4000;
|
|
47
|
+
// The share Snackbar hides itself SHARE_HINT_MS after it shows; the same tick checks the clock.
|
|
48
|
+
const SHARE_HINT_MS = 3000;
|
|
49
|
+
let shareHintUntil = 0;
|
|
50
|
+
const TICK_POLL = { id: "himi-product-add", intervalMs: 1000, action: "bareFashionProduct.tick" };
|
|
51
|
+
let pendingAdd = false;
|
|
52
|
+
let drawerUntil = 0;
|
|
53
|
+
|
|
54
|
+
/** Live cart size (sum of line-item quantities), or `ok: false` when the cart cannot be read. */
|
|
55
|
+
async function cartItemCount(): Promise<{ ok: true; count: number } | { ok: false }> {
|
|
56
|
+
try {
|
|
57
|
+
const cart = await getCurrentCart();
|
|
58
|
+
return { ok: true, count: (cart.lineItems ?? []).reduce((n, li) => n + (li.quantity ?? 1), 0) };
|
|
59
|
+
} catch {
|
|
60
|
+
return { ok: false };
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** The live bag size, also published for the tab bar's Bag badge. An unreadable cart never fails
|
|
65
|
+
* the screen and never overwrites the badge's stored count with a 0. */
|
|
66
|
+
async function publishedCartCount(): Promise<number> {
|
|
67
|
+
const live = await cartItemCount();
|
|
68
|
+
if (!live.ok) return 0;
|
|
69
|
+
await publishBagCount(live.count);
|
|
70
|
+
return live.count;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
interface GalleryItem {
|
|
74
|
+
url: string;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Picker option wire shape. `swatch` is the colour chip; `disabled` keeps a
|
|
78
|
+
* sold-out choice listed but not choosable. */
|
|
79
|
+
interface PickerChoice {
|
|
80
|
+
id: string;
|
|
81
|
+
label: string;
|
|
82
|
+
swatch?: string;
|
|
83
|
+
disabled?: boolean;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
interface S {
|
|
87
|
+
status: "loading" | "ready" | "error";
|
|
88
|
+
name: string;
|
|
89
|
+
price: string;
|
|
90
|
+
/** Pre-sale price, shown struck through. "" when the product is not discounted.
|
|
91
|
+
* Without this the detail screen showed the LIST price (e.g. €68.00) while the
|
|
92
|
+
* home grid showed the markdown (€40.00) for the same product. */
|
|
93
|
+
wasPrice: string;
|
|
94
|
+
onSale: boolean;
|
|
95
|
+
notOnSale: boolean;
|
|
96
|
+
description: string;
|
|
97
|
+
sku: string;
|
|
98
|
+
refundExpanded: boolean;
|
|
99
|
+
shippingExpanded: boolean;
|
|
100
|
+
refundCollapsed: boolean;
|
|
101
|
+
shippingCollapsed: boolean;
|
|
102
|
+
image: string;
|
|
103
|
+
/** FULL media gallery (media.items[] with the main image first) — the detail
|
|
104
|
+
* screen renders a Carousel over it when 2+ images exist. */
|
|
105
|
+
gallery: GalleryItem[];
|
|
106
|
+
hasGallery: boolean;
|
|
107
|
+
noGallery: boolean;
|
|
108
|
+
initial: string;
|
|
109
|
+
/** Share payload — the product page URL when the payload carries one. */
|
|
110
|
+
shareUrl: string;
|
|
111
|
+
/** Floating Snackbar text for the share action; "" hides it. */
|
|
112
|
+
shareHint: string;
|
|
113
|
+
cartHint: string;
|
|
114
|
+
cartCount: number;
|
|
115
|
+
emptyText: string;
|
|
116
|
+
isLoading: boolean;
|
|
117
|
+
notLoading: boolean;
|
|
118
|
+
isErrored: boolean;
|
|
119
|
+
notErrored: boolean;
|
|
120
|
+
/** Why the last load failed: the error state shows the offline or the server variant. */
|
|
121
|
+
errorKind?: ErrorKind;
|
|
122
|
+
hideOfflineError?: boolean;
|
|
123
|
+
hideServerError?: boolean;
|
|
124
|
+
noEmpty: boolean;
|
|
125
|
+
hasImage: boolean;
|
|
126
|
+
noImage: boolean;
|
|
127
|
+
/** The initial-letter tile shows only for a loaded product with no image, never under the error state. */
|
|
128
|
+
hidePlaceholder?: boolean;
|
|
129
|
+
/** True when the single hero image should render (an image exists but there is
|
|
130
|
+
* no multi-image gallery to carousel). */
|
|
131
|
+
hasSingleImage: boolean;
|
|
132
|
+
noSingleImage: boolean;
|
|
133
|
+
/** Quantity picked via the on-screen stepper (default 1) — addToCart adds
|
|
134
|
+
* exactly this many, not a hardcoded 1. */
|
|
135
|
+
quantity: number;
|
|
136
|
+
/** Wix Stores option groups on this product (colour, size, …). Empty for a
|
|
137
|
+
* product the owner sells without options — the whole block then hides. */
|
|
138
|
+
options: StoreOption[];
|
|
139
|
+
/** Picked choice per option group, parallel to `options` ("" = not picked). */
|
|
140
|
+
selected: string[];
|
|
141
|
+
hasOptions: boolean;
|
|
142
|
+
noOptions: boolean;
|
|
143
|
+
/** Three flattened option slots. The descriptor is static, so it cannot loop
|
|
144
|
+
* over an unknown number of groups; three covers every Wix Stores product
|
|
145
|
+
* (the catalog caps options at three). */
|
|
146
|
+
/** Set when Add to bag is tapped with a choice missing; each empty field then shows its error. */
|
|
147
|
+
showOptionErrors: boolean;
|
|
148
|
+
/** Picker fields per option group: the display name (also the field's accessible
|
|
149
|
+
* name), its choices, the picked id, the "Colour:" label, the "Choose Size"
|
|
150
|
+
* placeholder and the error line. */
|
|
151
|
+
opt1Name: string; opt1Choices: PickerChoice[]; opt1Selected: string; opt1Hidden: boolean;
|
|
152
|
+
opt1Label: string; opt1Placeholder: string; opt1Error: string; opt1NoError: boolean; opt1HasError: boolean;
|
|
153
|
+
opt2Name: string; opt2Choices: PickerChoice[]; opt2Selected: string; opt2Hidden: boolean;
|
|
154
|
+
opt2Label: string; opt2Placeholder: string; opt2Error: string; opt2NoError: boolean; opt2HasError: boolean;
|
|
155
|
+
opt3Name: string; opt3Choices: PickerChoice[]; opt3Selected: string; opt3Hidden: boolean;
|
|
156
|
+
opt3Label: string; opt3Placeholder: string; opt3Error: string; opt3NoError: boolean; opt3HasError: boolean;
|
|
157
|
+
/** "Choose COLOR" while a required choice is missing, else the picked summary. */
|
|
158
|
+
optionsHint: string;
|
|
159
|
+
/** True until every option group has a choice — disables Add to cart. */
|
|
160
|
+
addDisabled: boolean;
|
|
161
|
+
saved: boolean;
|
|
162
|
+
notSaved: boolean;
|
|
163
|
+
/** Sticky Add to bag bar: hidden until the product is ready, and while the drawer is open. */
|
|
164
|
+
hideBar: boolean;
|
|
165
|
+
saveLabel: string;
|
|
166
|
+
saveHint: string;
|
|
167
|
+
/** Banner visibility: hide the persistent-hint Banner while its message is "". */
|
|
168
|
+
hideCartHint: boolean;
|
|
169
|
+
hideSaveHint: boolean;
|
|
170
|
+
hideShareHint: boolean;
|
|
171
|
+
/** True while the add-to-cart write is in flight — swaps in the spinner button. */
|
|
172
|
+
adding: boolean;
|
|
173
|
+
notAdding: boolean;
|
|
174
|
+
/** "Item added to bag" drawer: open flag plus a snapshot of the line just added,
|
|
175
|
+
* so a later option change on the screen does not rewrite what the drawer shows. */
|
|
176
|
+
drawerOpen: boolean;
|
|
177
|
+
drawerHidden: boolean;
|
|
178
|
+
drawerName: string;
|
|
179
|
+
drawerPrice: string;
|
|
180
|
+
drawerDetail: string;
|
|
181
|
+
drawerImage: string;
|
|
182
|
+
drawerHasImage: boolean;
|
|
183
|
+
drawerNoImage: boolean;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function inputId(): string {
|
|
187
|
+
// WS-C — `himalaya.input.id` is the PRIMARY contract: hosts thread the row's
|
|
188
|
+
// `id` nav param (himi.open { screenId: "himi_product", id }) into worker input.
|
|
189
|
+
// The screenId-slice below is #570 back-compat for pre-params releases with
|
|
190
|
+
// baked `himi_product_<id>` screenIds — do not author against this.
|
|
191
|
+
const input = (globalThis as { himalaya?: { input?: { id?: string; screenId?: string } } }).himalaya?.input;
|
|
192
|
+
if (input?.id) return input.id;
|
|
193
|
+
return input?.screenId?.startsWith("himi_product_") ? input.screenId.slice("himi_product_".length) : "";
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/** Every usable image URL in the product's media payload (main first, deduped). */
|
|
197
|
+
export function productGallery(p: StoreProduct): GalleryItem[] {
|
|
198
|
+
const urls: string[] = [];
|
|
199
|
+
const push = (url?: string) => {
|
|
200
|
+
const trimmed = (url ?? "").trim();
|
|
201
|
+
if (trimmed && !urls.includes(trimmed)) urls.push(trimmed);
|
|
202
|
+
};
|
|
203
|
+
// Detail budget, not the list budget: this gallery is a full-bleed hero. Every
|
|
204
|
+
// entry goes through the same CDN transform — the primary AND the extra media
|
|
205
|
+
// items, which would otherwise stay untouched 4000px originals.
|
|
206
|
+
push(productImage(p, WIX_DETAIL_IMAGE));
|
|
207
|
+
// The SDK helper reads BOTH gallery layouts — V1 `media.items` and Catalog V3
|
|
208
|
+
// `media.itemsInfo.items`. This loop used to walk `media.items` itself, which is
|
|
209
|
+
// the V1 spelling only, so a V3 product with a ten-image gallery rendered as one
|
|
210
|
+
// image no matter what the read asked for. One reader, not a private copy per
|
|
211
|
+
// worker — that is how the two layouts drifted apart in the first place.
|
|
212
|
+
for (const url of sdkProductGallery(p, WIX_DETAIL_IMAGE)) push(url);
|
|
213
|
+
return urls.map((url) => ({ url }));
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** The product's public page URL when the payload carries one ("" otherwise) —
|
|
217
|
+
* probed off the RAW payload so a site-specific URL never gets baked into the
|
|
218
|
+
* descriptor (templates stay site-neutral; text-only share is the fallback). */
|
|
219
|
+
function productShareUrl(p: StoreProduct): string {
|
|
220
|
+
const raw = p as unknown as {
|
|
221
|
+
url?: unknown;
|
|
222
|
+
productPageUrl?: { base?: string; path?: string } | string;
|
|
223
|
+
};
|
|
224
|
+
if (typeof raw.url === "string" && /^https?:\/\//i.test(raw.url)) return raw.url;
|
|
225
|
+
const page = raw.productPageUrl;
|
|
226
|
+
if (typeof page === "string" && /^https?:\/\//i.test(page)) return page;
|
|
227
|
+
if (page && typeof page === "object" && typeof page.base === "string" && page.base) {
|
|
228
|
+
const path = typeof page.path === "string" ? page.path : "";
|
|
229
|
+
return `${page.base.replace(/\/$/, "")}${path && !path.startsWith("/") ? "/" : ""}${path}`;
|
|
230
|
+
}
|
|
231
|
+
return "";
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function argValue(arg: unknown, key: string): string {
|
|
235
|
+
if (arg && typeof arg === "object") {
|
|
236
|
+
const value = (arg as Record<string, unknown>)[key];
|
|
237
|
+
if (typeof value === "string") return value;
|
|
238
|
+
if (typeof value === "number" && Number.isFinite(value)) return String(value);
|
|
239
|
+
}
|
|
240
|
+
return typeof arg === "string" ? arg : "";
|
|
241
|
+
}
|
|
242
|
+
/** Quantity from a stepper onChange arg: positive integer, clamped 1–99. */
|
|
243
|
+
function parseQuantity(raw: string): number | undefined {
|
|
244
|
+
const n = Math.floor(Number(raw));
|
|
245
|
+
if (!Number.isFinite(n) || n < 1) return undefined;
|
|
246
|
+
return Math.min(n, 99);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/** V1 carries the markdown on price.discountedPrice; the SDK's declared type covers
|
|
250
|
+
* neither that nor the V3 shape, so read defensively and degrade to "not on sale". */
|
|
251
|
+
interface PriceBag {
|
|
252
|
+
price?: number;
|
|
253
|
+
discountedPrice?: number;
|
|
254
|
+
currency?: string;
|
|
255
|
+
formatted?: { price?: string; discountedPrice?: string };
|
|
256
|
+
}
|
|
257
|
+
function salePrices(p: StoreProduct): { price: string; wasPrice: string } {
|
|
258
|
+
const raw = p as unknown as { price?: PriceBag; priceData?: PriceBag };
|
|
259
|
+
const bag = raw.price ?? raw.priceData ?? {};
|
|
260
|
+
const list = bag.price;
|
|
261
|
+
const sale = bag.discountedPrice;
|
|
262
|
+
const discounted = typeof list === "number" && typeof sale === "number" && sale < list;
|
|
263
|
+
if (!discounted) return { price: productPrice(p), wasPrice: "" };
|
|
264
|
+
return {
|
|
265
|
+
price: bag.formatted?.discountedPrice ?? productPrice(p),
|
|
266
|
+
wasPrice: bag.formatted?.price ?? "",
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/** Picker options for one option group. A colour choice carries its swatch. An
|
|
271
|
+
* out-of-stock choice stays listed but disabled, instead of vanishing and leaving
|
|
272
|
+
* the shopper to wonder what happened to it. */
|
|
273
|
+
function pickerChoices(option?: StoreOption): PickerChoice[] {
|
|
274
|
+
if (!option) return [];
|
|
275
|
+
return option.choices.map((c) => ({
|
|
276
|
+
id: c.id,
|
|
277
|
+
label: c.label,
|
|
278
|
+
...(option.kind === "color" && c.hex ? { swatch: c.hex } : {}),
|
|
279
|
+
...(c.inStock ? {} : { disabled: true }),
|
|
280
|
+
}));
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/** Catalog option names often arrive in capitals ("COLOR"); show them in sentence case. */
|
|
284
|
+
function optionDisplayName(name: string): string {
|
|
285
|
+
return name === name.toUpperCase() ? name.charAt(0) + name.slice(1).toLowerCase() : name;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/** Picker field for option group `n` (1-based in the field names). */
|
|
289
|
+
function optionField(n: 1 | 2 | 3, option: StoreOption | undefined, selectedId: string, showErrors: boolean): Record<string, unknown> {
|
|
290
|
+
const name = option ? optionDisplayName(option.name) : "";
|
|
291
|
+
const picked = option?.choices.find((c) => c.id === selectedId);
|
|
292
|
+
const error = showErrors && option && !picked
|
|
293
|
+
? copyTemplate("product.optionRequired", "Choose a {option}", { option: name.toLowerCase() })
|
|
294
|
+
: "";
|
|
295
|
+
return {
|
|
296
|
+
[`opt${n}Name`]: name,
|
|
297
|
+
[`opt${n}Choices`]: pickerChoices(option),
|
|
298
|
+
[`opt${n}Selected`]: selectedId,
|
|
299
|
+
[`opt${n}Hidden`]: !option,
|
|
300
|
+
[`opt${n}Error`]: error,
|
|
301
|
+
[`opt${n}NoError`]: !error,
|
|
302
|
+
[`opt${n}HasError`]: !!error,
|
|
303
|
+
[`opt${n}Label`]: name ? copyTemplate("product.optionLabel", "{option}:", { option: name }) : "",
|
|
304
|
+
[`opt${n}Placeholder`]: name ? copyTemplate("product.optionPlaceholder", "Choose {option}", { option: name }) : "",
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/** The prompt above the chips: what is still missing, or what is picked. */
|
|
309
|
+
function optionsHint(options: StoreOption[], selected: string[]): string {
|
|
310
|
+
const missing = options.filter((_, i) => !selected[i]).map((o) => o.name);
|
|
311
|
+
if (missing.length) return copyTemplate("product.optionsChoose", "Choose {options}", { options: missing.join(", ") });
|
|
312
|
+
const summary = selectionSummary(options, selected);
|
|
313
|
+
return summary ? copyTemplate("product.optionsPicked", "Selected: {summary}", { summary }) : "";
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
function derive(s: S): S {
|
|
317
|
+
const empty = s.status === "ready" && !s.name;
|
|
318
|
+
const hasGallery = s.gallery.length > 1;
|
|
319
|
+
const hasSingleImage = !!s.image && !hasGallery;
|
|
320
|
+
const options = s.options ?? [];
|
|
321
|
+
const selected = s.selected ?? [];
|
|
322
|
+
// A product with no options must add to the cart exactly as it did before —
|
|
323
|
+
// the gate only applies to groups the catalog actually declares.
|
|
324
|
+
const incomplete = options.some((_, i) => !selected[i]);
|
|
325
|
+
return {
|
|
326
|
+
...s,
|
|
327
|
+
refundCollapsed: !s.refundExpanded,
|
|
328
|
+
shippingCollapsed: !s.shippingExpanded,
|
|
329
|
+
hasOptions: options.length > 0,
|
|
330
|
+
noOptions: options.length === 0,
|
|
331
|
+
optionsHint: optionsHint(options, selected),
|
|
332
|
+
...optionField(1, options[0], selected[0] ?? "", s.showOptionErrors),
|
|
333
|
+
...optionField(2, options[1], selected[1] ?? "", s.showOptionErrors),
|
|
334
|
+
...optionField(3, options[2], selected[2] ?? "", s.showOptionErrors),
|
|
335
|
+
addDisabled: incomplete,
|
|
336
|
+
notSaved: !s.saved,
|
|
337
|
+
hideBar: s.status !== "ready" || empty || s.drawerOpen,
|
|
338
|
+
saveLabel: s.saved ? copyParam("product.saved", "Saved") : copyParam("product.save", "Add to wishlist"),
|
|
339
|
+
isLoading: s.status === "loading",
|
|
340
|
+
notLoading: s.status !== "loading",
|
|
341
|
+
isErrored: s.status === "error",
|
|
342
|
+
notErrored: s.status !== "error",
|
|
343
|
+
...errorFlags(s.status, s.errorKind),
|
|
344
|
+
noEmpty: s.status === "loading" || s.status === "error" || !empty,
|
|
345
|
+
hasImage: !!s.image,
|
|
346
|
+
noImage: !s.image,
|
|
347
|
+
hidePlaceholder: !!s.image || s.status !== "ready",
|
|
348
|
+
hasGallery,
|
|
349
|
+
noGallery: !hasGallery,
|
|
350
|
+
hasSingleImage,
|
|
351
|
+
noSingleImage: !hasSingleImage,
|
|
352
|
+
onSale: !!s.wasPrice,
|
|
353
|
+
notOnSale: !s.wasPrice,
|
|
354
|
+
hideCartHint: !s.cartHint,
|
|
355
|
+
hideSaveHint: !s.saveHint,
|
|
356
|
+
hideShareHint: !s.shareHint,
|
|
357
|
+
notAdding: !s.adding,
|
|
358
|
+
drawerHidden: !s.drawerOpen,
|
|
359
|
+
drawerHasImage: !!s.drawerImage,
|
|
360
|
+
drawerNoImage: !s.drawerImage,
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/** What the drawer shows under the name: the picked options and the quantity. */
|
|
365
|
+
function drawerDetail(s: S, quantity: number): string {
|
|
366
|
+
const parts = s.options.map((o, i) => {
|
|
367
|
+
const choice = o.choices.find((c) => c.id === s.selected[i]);
|
|
368
|
+
return choice ? `${o.name}: ${choice.label}` : "";
|
|
369
|
+
}).filter(Boolean);
|
|
370
|
+
if (quantity > 1) parts.push(copyTemplate("product.drawerQty", "Qty: {qty}", { qty: String(quantity) }));
|
|
371
|
+
return parts.join("\n");
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/** Apply a Picker `onChange` (`{ selectedId }`) to one option group. A sold-out
|
|
375
|
+
* choice is never accepted, even if a host dispatches it. */
|
|
376
|
+
function pickOption(s: S, index: number, arg: unknown): S {
|
|
377
|
+
if (!s.options[index]) return s;
|
|
378
|
+
const id = argValue(arg, "selectedId");
|
|
379
|
+
const choice = s.options[index].choices.some((c) => c.id === id && c.inStock) ? id : "";
|
|
380
|
+
const selected = s.options.map((_, i) => (i === index ? choice : s.selected[i] ?? ""));
|
|
381
|
+
// Picking a choice clears a stale "choose a size first" hint.
|
|
382
|
+
return derive({ ...s, selected, cartHint: "" });
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/** The add-to-cart write. Every path clears `adding`, so the spinner always ends. */
|
|
386
|
+
async function commitAdd(s: S): Promise<S> {
|
|
387
|
+
const id = inputId();
|
|
388
|
+
if (!id) return derive({ ...s, adding: false });
|
|
389
|
+
const quantity = s.quantity > 0 ? s.quantity : 1;
|
|
390
|
+
const picked = cartOptionsPayload(s.options, s.selected);
|
|
391
|
+
const summary = selectionSummary(s.options, s.selected);
|
|
392
|
+
try {
|
|
393
|
+
// Optimistic local cart line — the cart repaints from cache immediately (offline or not).
|
|
394
|
+
const line: DbEntity = { id: `line-${id}${summary ? `-${summary}` : ""}`, productId: id, name: s.name || "product", title: s.name || "product", subtitle: summary ? `${summary} \u00b7 Qty ${quantity}` : `Qty ${quantity}`, quantity, quantityLabel: String(quantity) };
|
|
395
|
+
await cartPut(line);
|
|
396
|
+
await addToCurrentCart(id, quantity, picked);
|
|
397
|
+
drawerUntil = Date.now() + DRAWER_MS;
|
|
398
|
+
return derive({
|
|
399
|
+
...s,
|
|
400
|
+
adding: false,
|
|
401
|
+
cartHint: "",
|
|
402
|
+
cartCount: await publishedCartCount(),
|
|
403
|
+
drawerOpen: true,
|
|
404
|
+
drawerName: s.name || "product",
|
|
405
|
+
drawerPrice: s.price,
|
|
406
|
+
drawerDetail: drawerDetail(s, quantity),
|
|
407
|
+
drawerImage: s.gallery[0]?.url || s.image,
|
|
408
|
+
});
|
|
409
|
+
} catch (e) {
|
|
410
|
+
if (isBridgeUnavailable(e)) {
|
|
411
|
+
// Offline / no bridge: the optimistic cache line already shows; queue the
|
|
412
|
+
// add to replay (WriteQueue, idempotent) when connectivity returns.
|
|
413
|
+
await queueWrite("tier5.bareFashionProduct.addToCart", summary ? { id, options: summary } : { id });
|
|
414
|
+
return derive({ ...s, adding: false, cartHint: copyTemplate("product.cartHintQueued", "Added {name} to your bag. Will sync when you reconnect.", { name: s.name || "product" }) });
|
|
415
|
+
}
|
|
416
|
+
return derive({ ...s, adding: false, cartHint: copyParam("product.cartHintFailed", "Could not add to bag. Try again.") });
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
const svc = defineService<S, {
|
|
421
|
+
load: (s: S, arg?: unknown) => Promise<S>;
|
|
422
|
+
setQuantity: (s: S, arg?: unknown) => S;
|
|
423
|
+
selectOption1: (s: S, arg?: unknown) => S;
|
|
424
|
+
selectOption2: (s: S, arg?: unknown) => S;
|
|
425
|
+
selectOption3: (s: S, arg?: unknown) => S;
|
|
426
|
+
addToCart: (s: S) => S | undefined;
|
|
427
|
+
tick: (s: S) => Promise<S | undefined>;
|
|
428
|
+
closeDrawer: (s: S) => S;
|
|
429
|
+
viewBag: (s: S) => S;
|
|
430
|
+
share: (s: S) => Promise<S>;
|
|
431
|
+
toggleSave: (s: S) => Promise<S>;
|
|
432
|
+
toggleRefund: (s: S) => S;
|
|
433
|
+
toggleShipping: (s: S) => S;
|
|
434
|
+
}>("bareFashionProduct", {
|
|
435
|
+
state: derive({
|
|
436
|
+
status: "loading",
|
|
437
|
+
name: "",
|
|
438
|
+
price: "",
|
|
439
|
+
wasPrice: "",
|
|
440
|
+
onSale: false,
|
|
441
|
+
notOnSale: true,
|
|
442
|
+
description: "",
|
|
443
|
+
sku: "",
|
|
444
|
+
refundExpanded: false,
|
|
445
|
+
shippingExpanded: false,
|
|
446
|
+
refundCollapsed: true,
|
|
447
|
+
shippingCollapsed: true,
|
|
448
|
+
image: "",
|
|
449
|
+
gallery: [],
|
|
450
|
+
hasGallery: false,
|
|
451
|
+
noGallery: true,
|
|
452
|
+
initial: "",
|
|
453
|
+
shareUrl: "",
|
|
454
|
+
shareHint: "",
|
|
455
|
+
cartHint: "",
|
|
456
|
+
cartCount: 0,
|
|
457
|
+
emptyText: "",
|
|
458
|
+
isLoading: true,
|
|
459
|
+
notLoading: false,
|
|
460
|
+
isErrored: false,
|
|
461
|
+
notErrored: true,
|
|
462
|
+
noEmpty: true,
|
|
463
|
+
hasImage: false,
|
|
464
|
+
noImage: true,
|
|
465
|
+
hasSingleImage: false,
|
|
466
|
+
noSingleImage: true,
|
|
467
|
+
quantity: 1,
|
|
468
|
+
options: [],
|
|
469
|
+
selected: [],
|
|
470
|
+
hasOptions: false,
|
|
471
|
+
noOptions: true,
|
|
472
|
+
showOptionErrors: false,
|
|
473
|
+
opt1Name: "", opt1Choices: [], opt1Selected: "", opt1Hidden: true,
|
|
474
|
+
opt1Label: "", opt1Placeholder: "", opt1Error: "", opt1NoError: true, opt1HasError: false,
|
|
475
|
+
opt2Name: "", opt2Choices: [], opt2Selected: "", opt2Hidden: true,
|
|
476
|
+
opt2Label: "", opt2Placeholder: "", opt2Error: "", opt2NoError: true, opt2HasError: false,
|
|
477
|
+
opt3Name: "", opt3Choices: [], opt3Selected: "", opt3Hidden: true,
|
|
478
|
+
opt3Label: "", opt3Placeholder: "", opt3Error: "", opt3NoError: true, opt3HasError: false,
|
|
479
|
+
optionsHint: "",
|
|
480
|
+
addDisabled: false,
|
|
481
|
+
saved: false,
|
|
482
|
+
notSaved: true,
|
|
483
|
+
hideBar: true,
|
|
484
|
+
saveLabel: "",
|
|
485
|
+
saveHint: "",
|
|
486
|
+
hideCartHint: true,
|
|
487
|
+
hideSaveHint: true,
|
|
488
|
+
hideShareHint: true,
|
|
489
|
+
adding: false,
|
|
490
|
+
notAdding: true,
|
|
491
|
+
drawerOpen: false,
|
|
492
|
+
drawerHidden: true,
|
|
493
|
+
drawerName: "",
|
|
494
|
+
drawerPrice: "",
|
|
495
|
+
drawerDetail: "",
|
|
496
|
+
drawerImage: "",
|
|
497
|
+
drawerHasImage: false,
|
|
498
|
+
drawerNoImage: true,
|
|
499
|
+
}),
|
|
500
|
+
actions: {
|
|
501
|
+
toggleRefund: (s) => derive({ ...s, refundExpanded: !s.refundExpanded }),
|
|
502
|
+
toggleShipping: (s) => derive({ ...s, shippingExpanded: !s.shippingExpanded }),
|
|
503
|
+
load: async (s, arg) => {
|
|
504
|
+
stashCopy(arg);
|
|
505
|
+
const id = inputId();
|
|
506
|
+
// Storage problems must not prevent browsing or buying a product.
|
|
507
|
+
let saved = false;
|
|
508
|
+
try { saved = isProductSaved(id); } catch { /* save action reports a retryable error */ }
|
|
509
|
+
// A fresh entry never inherits a drawer or a spinner from a previous visit.
|
|
510
|
+
pendingAdd = false;
|
|
511
|
+
drawerUntil = 0;
|
|
512
|
+
s = { ...s, saved, saveHint: "", shareHint: "", adding: false, drawerOpen: false, showOptionErrors: false, refundExpanded: false, shippingExpanded: false };
|
|
513
|
+
// A fresh navigation into the product resets any quantity left over
|
|
514
|
+
// from a previous visit to the same worker instance.
|
|
515
|
+
if (!id) return derive({ ...s, status: "ready", quantity: 1, wasPrice: "", options: [], selected: [], emptyText: copyParam("product.notFoundText", "Product not found.") });
|
|
516
|
+
try {
|
|
517
|
+
// VARIANT_OPTION_CHOICE_NAMES is a Catalog V3 read field: without it the
|
|
518
|
+
// V3 payload comes back with no option choices at all. V1 always carries
|
|
519
|
+
// `productOptions`, and the SDK ignores unknown extras on that path.
|
|
520
|
+
const r = await getStoreProduct(id, ["VARIANT_OPTION_CHOICE_NAMES"]);
|
|
521
|
+
const p = (r.product ?? (r as unknown as StoreProduct)) as StoreProduct;
|
|
522
|
+
const name = cleanTitle(p.name) || "Product";
|
|
523
|
+
const image = productImage(p, WIX_DETAIL_IMAGE);
|
|
524
|
+
// Only the first three groups get a slot in the descriptor; Wix Stores
|
|
525
|
+
// caps a product at three options, so nothing is dropped in practice.
|
|
526
|
+
const options = productOptions(p).slice(0, 3);
|
|
527
|
+
await cacheProduct({ id, name, subtitle: salePrices(p).price, image, sku: String((p as unknown as { sku?: unknown }).sku ?? "").trim(), initial: (name[0] || "#").toUpperCase() });
|
|
528
|
+
return derive({
|
|
529
|
+
...s,
|
|
530
|
+
status: "ready",
|
|
531
|
+
options,
|
|
532
|
+
selected: options.map(defaultChoice),
|
|
533
|
+
name,
|
|
534
|
+
price: salePrices(p).price,
|
|
535
|
+
wasPrice: salePrices(p).wasPrice,
|
|
536
|
+
description: plainText(p.plainDescription || p.description),
|
|
537
|
+
sku: String((p as unknown as { sku?: unknown }).sku ?? "").trim(),
|
|
538
|
+
image,
|
|
539
|
+
gallery: productGallery(p),
|
|
540
|
+
initial: (name[0] || "#").toUpperCase(),
|
|
541
|
+
shareUrl: productShareUrl(p),
|
|
542
|
+
cartHint: "",
|
|
543
|
+
cartCount: await publishedCartCount(),
|
|
544
|
+
emptyText: "",
|
|
545
|
+
quantity: 1,
|
|
546
|
+
});
|
|
547
|
+
} catch (e) {
|
|
548
|
+
// Offline: fall back to the last-synced cached product row before the error state.
|
|
549
|
+
const cache = await readCachedProduct(id);
|
|
550
|
+
const cached = cache.ok ? cache.row : null;
|
|
551
|
+
if (cached) {
|
|
552
|
+
const name = String(cached.name ?? "") || "Product";
|
|
553
|
+
const image = String(cached.image ?? "");
|
|
554
|
+
return derive({
|
|
555
|
+
...s,
|
|
556
|
+
status: "ready",
|
|
557
|
+
// The offline cache holds list rows, which carry no options. Adding
|
|
558
|
+
// an optioned product offline is therefore not offered.
|
|
559
|
+
options: [],
|
|
560
|
+
selected: [],
|
|
561
|
+
name,
|
|
562
|
+
price: String(cached.subtitle ?? ""),
|
|
563
|
+
wasPrice: "",
|
|
564
|
+
description: "",
|
|
565
|
+
sku: String(cached.sku ?? "").trim(),
|
|
566
|
+
image,
|
|
567
|
+
initial: String(cached.initial ?? "") || (name[0] || "#").toUpperCase(),
|
|
568
|
+
cartHint: "",
|
|
569
|
+
cartCount: await publishedCartCount(),
|
|
570
|
+
emptyText: "",
|
|
571
|
+
quantity: 1,
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
return derive({ ...s, status: "error", errorKind: errorKindOf(e), options: [], selected: [], emptyText: copyParam("product.errorText", "Product could not load.") });
|
|
575
|
+
}
|
|
576
|
+
},
|
|
577
|
+
// The stepper fires onChange with { value } on every tap; clamp 1–99 and
|
|
578
|
+
// ignore unparsable/garbage args instead of silently zeroing the quantity.
|
|
579
|
+
setQuantity: (s, arg) => {
|
|
580
|
+
const quantity = parseQuantity(argValue(arg, "value"));
|
|
581
|
+
return quantity ? derive({ ...s, quantity }) : s;
|
|
582
|
+
},
|
|
583
|
+
// Each option Picker reports `{ selectedId }` for its own group.
|
|
584
|
+
selectOption1: (s, arg) => pickOption(s, 0, arg),
|
|
585
|
+
selectOption2: (s, arg) => pickOption(s, 1, arg),
|
|
586
|
+
selectOption3: (s, arg) => pickOption(s, 2, arg),
|
|
587
|
+
// Tap handler: validate, show the spinner, and hand the write to `tick`.
|
|
588
|
+
addToCart: (s) => {
|
|
589
|
+
if (s.adding) return undefined; // a second tap while the write is in flight
|
|
590
|
+
const id = inputId();
|
|
591
|
+
if (!id) return derive({ ...s, cartHint: copyParam("product.cartHintNoProduct", "No product to add.") });
|
|
592
|
+
// A product with options must not reach the cart half-chosen: Wix would
|
|
593
|
+
// either reject the line or silently create one the shopper did not pick.
|
|
594
|
+
const missing = s.options.filter((_, i) => !s.selected[i]).map((o) => o.name);
|
|
595
|
+
if (missing.length) {
|
|
596
|
+
// Each empty field shows its own error ("Choose a size.") instead of a banner.
|
|
597
|
+
return derive({ ...s, showOptionErrors: true, cartHint: "" });
|
|
598
|
+
}
|
|
599
|
+
pendingAdd = true;
|
|
600
|
+
drawerUntil = 0;
|
|
601
|
+
return { ...derive({ ...s, adding: true, drawerOpen: false, cartHint: "" }), _poll: { ...TICK_POLL, immediate: true } } as S;
|
|
602
|
+
},
|
|
603
|
+
tick: async (s) => {
|
|
604
|
+
if (pendingAdd) {
|
|
605
|
+
pendingAdd = false;
|
|
606
|
+
return commitAdd(s);
|
|
607
|
+
}
|
|
608
|
+
// A spinner with no write behind it (e.g. a torn-down worker) must not stick.
|
|
609
|
+
if (s.adding) return derive({ ...s, adding: false });
|
|
610
|
+
if (s.shareHint && Date.now() >= shareHintUntil) return derive({ ...s, shareHint: "" });
|
|
611
|
+
if (!s.drawerOpen || Date.now() < drawerUntil) return undefined;
|
|
612
|
+
drawerUntil = 0;
|
|
613
|
+
return derive({ ...s, drawerOpen: false });
|
|
614
|
+
},
|
|
615
|
+
closeDrawer: (s) => {
|
|
616
|
+
drawerUntil = 0;
|
|
617
|
+
return derive({ ...s, drawerOpen: false });
|
|
618
|
+
},
|
|
619
|
+
viewBag: (s) => {
|
|
620
|
+
drawerUntil = 0;
|
|
621
|
+
return navigate(derive({ ...s, drawerOpen: false }), { screenId: "himi_cart" });
|
|
622
|
+
},
|
|
623
|
+
toggleSave: async (s) => {
|
|
624
|
+
if (s.status !== "ready" || !s.name || !inputId()) return s;
|
|
625
|
+
let saved: boolean;
|
|
626
|
+
try {
|
|
627
|
+
saved = toggleSavedProduct({ id: inputId(), name: s.name, price: s.price, image: s.image, swatches: (s.options.find((o) => o.kind === "color")?.choices ?? []).map((c) => c.hex).filter(Boolean) });
|
|
628
|
+
} catch {
|
|
629
|
+
return derive({ ...s, saveHint: copyParam("product.saveError", "Could not save this change. Try again.") });
|
|
630
|
+
}
|
|
631
|
+
return derive({ ...s, saved, saveHint: saved
|
|
632
|
+
? copyParam("product.saveSuccess", "Added to your wishlist.")
|
|
633
|
+
: copyParam("product.saveRemoved", "Removed from your wishlist.") });
|
|
634
|
+
},
|
|
635
|
+
share: async (s) => {
|
|
636
|
+
if (!s.name) return s;
|
|
637
|
+
try {
|
|
638
|
+
await shareSheet({ subject: s.name, text: s.name, ...(s.shareUrl ? { url: s.shareUrl } : {}) });
|
|
639
|
+
return s;
|
|
640
|
+
} catch {
|
|
641
|
+
// Web preview has no share sheet; a real iOS or Android device does. Say so positively.
|
|
642
|
+
shareHintUntil = Date.now() + SHARE_HINT_MS;
|
|
643
|
+
return { ...derive({ ...s, shareHint: copyParam("product.shareUnavailable", "Share sheet will open on iOS and Android devices.") }), _poll: { ...TICK_POLL, immediate: true } } as S;
|
|
644
|
+
}
|
|
645
|
+
},
|
|
646
|
+
},
|
|
647
|
+
});
|
|
648
|
+
|
|
649
|
+
svc.load();
|
|
650
|
+
export { svc };
|