@wix/himalaya-cli 0.1767.0 → 0.1769.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/app-config.d.ts +4 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/dev-server/src/app-module.d.ts +7 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/dev-server/src/builder.d.ts +9 -0
- 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/sdui.mjs +1 -0
- package/dist/browser-plane/assets.json +5 -5
- package/dist/browser-plane/preview-deferred/{cba469735852da3b19235ce6d163f0e0bb4fd2e751c0042493147e4d9c143d92.bin → 7977d7340513225ef7609b9983b621e2b48c10deb7427e059e595d2fc66f7983.bin} +1 -1
- package/dist/browser-plane/sw.js +8 -8
- package/dist/cli.mjs +234 -89
- package/dist/preview-assets.generated.bin +0 -0
- package/guides/capabilities.md +6 -4
- package/guides/component-reference.json +1 -1
- package/guides/component-reference.md +4 -0
- package/guides/himi-json-output.md +19 -7
- package/guides/one-app-to-himi-app.md +19 -9
- package/guides/qa-builds.md +73 -84
- package/package.json +2 -2
- package/templates/beauty-salon/l10n/ar.json +45 -0
- package/templates/beauty-salon/l10n/cs.json +45 -0
- package/templates/beauty-salon/l10n/da.json +45 -0
- package/templates/beauty-salon/l10n/de.json +45 -0
- package/templates/beauty-salon/l10n/el.json +45 -0
- package/templates/beauty-salon/l10n/en.json +1 -1
- package/templates/beauty-salon/l10n/es.json +45 -0
- package/templates/beauty-salon/l10n/fi.json +45 -0
- package/templates/beauty-salon/l10n/fr.json +45 -0
- package/templates/beauty-salon/l10n/he.json +36 -0
- package/templates/beauty-salon/l10n/hu.json +45 -0
- package/templates/beauty-salon/l10n/id.json +45 -0
- package/templates/beauty-salon/l10n/it.json +45 -0
- package/templates/beauty-salon/l10n/ja.json +45 -0
- package/templates/beauty-salon/l10n/ko.json +45 -0
- package/templates/beauty-salon/l10n/lt.json +45 -0
- package/templates/beauty-salon/l10n/nl.json +45 -0
- package/templates/beauty-salon/l10n/no.json +45 -0
- package/templates/beauty-salon/l10n/pl.json +45 -0
- package/templates/beauty-salon/l10n/pt.json +45 -0
- package/templates/beauty-salon/l10n/ru.json +45 -0
- package/templates/beauty-salon/l10n/sv.json +45 -0
- package/templates/beauty-salon/l10n/th.json +45 -0
- package/templates/beauty-salon/l10n/tr.json +45 -0
- package/templates/beauty-salon/l10n/uk.json +45 -0
- package/templates/beauty-salon/l10n/vi.json +45 -0
- package/templates/beauty-salon/l10n/zh.json +45 -0
- package/templates/beauty-salon/tier5-src/_shared/branded-lite-hosted.ts +1 -0
- package/templates/beauty-salon/tier5-src/_shared/business-chat-transport.ts +20 -4
- package/templates/beauty-salon/tier5-src/_shared/engine-intl.ts +6 -0
- package/templates/beauty-salon/tier5-src/_shared/program-fields.ts +16 -0
- package/templates/beauty-salon/tier5-src/_shared/program-standing.ts +67 -0
- package/templates/beauty-salon/tier5-src/himi-booking-time/index.ts +56 -12
- package/templates/beauty-salon/tier5-src/himi-branded-lite-home/index.ts +5 -0
- package/templates/beauty-salon-owner/tier5-src/_shared/engine-intl.ts +6 -0
- package/templates/branded-lite/config.ts +11 -1
- package/templates/branded-lite/dev/index.ts +1088 -86
- package/templates/branded-lite/himalaya.content.json +3 -0
- package/templates/branded-lite/l10n/ar.json +259 -0
- package/templates/branded-lite/l10n/cs.json +259 -0
- package/templates/branded-lite/l10n/da.json +259 -0
- package/templates/branded-lite/l10n/de.json +259 -0
- package/templates/branded-lite/l10n/el.json +259 -0
- package/templates/branded-lite/l10n/en.json +65 -2
- package/templates/branded-lite/l10n/es.json +259 -0
- package/templates/branded-lite/l10n/fi.json +259 -0
- package/templates/branded-lite/l10n/fr.json +259 -0
- package/templates/branded-lite/l10n/he.json +209 -0
- package/templates/branded-lite/l10n/hu.json +259 -0
- package/templates/branded-lite/l10n/id.json +259 -0
- package/templates/branded-lite/l10n/it.json +259 -0
- package/templates/branded-lite/l10n/ja.json +259 -0
- package/templates/branded-lite/l10n/ko.json +259 -0
- package/templates/branded-lite/l10n/lt.json +259 -0
- package/templates/branded-lite/l10n/nl.json +259 -0
- package/templates/branded-lite/l10n/no.json +259 -0
- package/templates/branded-lite/l10n/pl.json +259 -0
- package/templates/branded-lite/l10n/pt.json +259 -0
- package/templates/branded-lite/l10n/ru.json +259 -0
- package/templates/branded-lite/l10n/sv.json +259 -0
- package/templates/branded-lite/l10n/th.json +259 -0
- package/templates/branded-lite/l10n/tr.json +259 -0
- package/templates/branded-lite/l10n/uk.json +259 -0
- package/templates/branded-lite/l10n/vi.json +259 -0
- package/templates/branded-lite/l10n/zh.json +259 -0
- package/templates/branded-lite/recipes/programs-card.json +2 -2
- package/templates/branded-lite/recipes/programs-carousel.json +2 -2
- package/templates/branded-lite/recipes/programs-participant-carousel.json +2 -2
- package/templates/branded-lite/tier5-src/_shared/branded-lite-hosted.ts +1 -0
- package/templates/branded-lite/tier5-src/_shared/business-chat-transport.ts +20 -4
- package/templates/branded-lite/tier5-src/_shared/engine-intl.ts +6 -0
- package/templates/branded-lite/tier5-src/_shared/inbox-rooms.ts +101 -11
- package/templates/branded-lite/tier5-src/_shared/inbox-search.ts +119 -0
- package/templates/branded-lite/tier5-src/_shared/member-inbox-transport.ts +64 -0
- package/templates/branded-lite/tier5-src/_shared/member-thread-rows.ts +233 -0
- package/templates/branded-lite/tier5-src/_shared/program-standing.ts +21 -0
- package/templates/branded-lite/tier5-src/_shared/programs-section.ts +8 -4
- package/templates/branded-lite/tier5-src/business-chat/index.ts +73 -22
- package/templates/branded-lite/tier5-src/himi-booking-time/index.ts +56 -12
- package/templates/branded-lite/tier5-src/himi-branded-lite-home/index.ts +5 -0
- package/templates/branded-lite/tier5-src/himi-branded-lite-inbox/index.ts +777 -54
- package/templates/branded-lite/tier5-src/himi-branded-lite-member-programs/index.ts +23 -7
- package/templates/branded-lite/tier5-src/himi-branded-lite-program/index.ts +17 -3
- package/templates/branded-lite/tier5-src/himi-branded-lite-program-participant/index.ts +336 -0
- package/templates/branded-lite/tier5-src/himi-branded-lite-program-participant/model.ts +206 -0
- package/templates/branded-lite/tier5-src/wix-spaces-chat-thread/index.ts +426 -143
- package/templates/branded-lite/tier5-src/wix-spaces-new-message/index.ts +4 -2
- package/templates/brandy/tier5-src/_shared/branded-lite-hosted.ts +1 -0
- package/templates/brandy/tier5-src/_shared/business-chat-message-model.ts +177 -0
- package/templates/brandy/tier5-src/_shared/business-chat-transport.ts +164 -0
- package/templates/brandy/tier5-src/_shared/engine-intl.ts +6 -0
- package/templates/brandy/tier5-src/_shared/inbox-rooms.ts +101 -11
- package/templates/brandy/tier5-src/_shared/inbox-search.ts +119 -0
- package/templates/brandy/tier5-src/_shared/member-inbox-transport.ts +64 -0
- package/templates/brandy/tier5-src/_shared/member-thread-rows.ts +233 -0
- package/templates/brandy/tier5-src/himi-branded-lite-inbox/index.ts +777 -54
- package/templates/brandy/tier5-src/wix-spaces-chat-thread/index.ts +426 -143
- package/templates/community-club/l10n/ar.json +30 -0
- package/templates/community-club/l10n/cs.json +30 -0
- package/templates/community-club/l10n/da.json +30 -0
- package/templates/community-club/l10n/de.json +30 -0
- package/templates/community-club/l10n/el.json +30 -0
- package/templates/community-club/l10n/en.json +2 -2
- package/templates/community-club/l10n/es.json +30 -0
- package/templates/community-club/l10n/fi.json +30 -0
- package/templates/community-club/l10n/fr.json +30 -0
- package/templates/community-club/l10n/he.json +24 -0
- package/templates/community-club/l10n/hu.json +30 -0
- package/templates/community-club/l10n/id.json +30 -0
- package/templates/community-club/l10n/it.json +30 -0
- package/templates/community-club/l10n/ja.json +30 -0
- package/templates/community-club/l10n/ko.json +30 -0
- package/templates/community-club/l10n/lt.json +30 -0
- package/templates/community-club/l10n/nl.json +30 -0
- package/templates/community-club/l10n/no.json +30 -0
- package/templates/community-club/l10n/pl.json +30 -0
- package/templates/community-club/l10n/pt.json +30 -0
- package/templates/community-club/l10n/ru.json +30 -0
- package/templates/community-club/l10n/sv.json +30 -0
- package/templates/community-club/l10n/th.json +30 -0
- package/templates/community-club/l10n/tr.json +30 -0
- package/templates/community-club/l10n/uk.json +30 -0
- package/templates/community-club/l10n/vi.json +30 -0
- package/templates/community-club/l10n/zh.json +30 -0
- package/templates/community-club/tier5-src/_shared/branded-lite-hosted.ts +1 -0
- package/templates/community-club/tier5-src/_shared/engine-intl.ts +6 -0
- package/templates/community-club/tier5-src/_shared/program-fields.ts +16 -0
- package/templates/community-club/tier5-src/_shared/program-standing.ts +67 -0
- package/templates/community-club/tier5-src/himi-branded-lite-home/index.ts +5 -0
- package/templates/community-club-owner/tier5-src/_shared/engine-intl.ts +6 -0
- package/templates/conference/tier5-src/_shared/branded-lite-hosted.ts +1 -0
- package/templates/conference/tier5-src/_shared/business-chat-transport.ts +20 -4
- package/templates/conference/tier5-src/_shared/chat-live.ts +242 -0
- package/templates/conference/tier5-src/_shared/engine-intl.ts +6 -0
- package/templates/conference/tier5-src/_shared/inbox-rooms.ts +101 -11
- package/templates/conference/tier5-src/business-chat/index.ts +73 -22
- package/templates/events-meetups/l10n/ar.json +30 -0
- package/templates/events-meetups/l10n/cs.json +30 -0
- package/templates/events-meetups/l10n/da.json +30 -0
- package/templates/events-meetups/l10n/de.json +30 -0
- package/templates/events-meetups/l10n/el.json +30 -0
- package/templates/events-meetups/l10n/en.json +1 -1
- package/templates/events-meetups/l10n/es.json +30 -0
- package/templates/events-meetups/l10n/fi.json +30 -0
- package/templates/events-meetups/l10n/fr.json +30 -0
- package/templates/events-meetups/l10n/he.json +24 -0
- package/templates/events-meetups/l10n/hu.json +30 -0
- package/templates/events-meetups/l10n/id.json +30 -0
- package/templates/events-meetups/l10n/it.json +30 -0
- package/templates/events-meetups/l10n/ja.json +30 -0
- package/templates/events-meetups/l10n/ko.json +30 -0
- package/templates/events-meetups/l10n/lt.json +30 -0
- package/templates/events-meetups/l10n/nl.json +30 -0
- package/templates/events-meetups/l10n/no.json +30 -0
- package/templates/events-meetups/l10n/pl.json +30 -0
- package/templates/events-meetups/l10n/pt.json +30 -0
- package/templates/events-meetups/l10n/ru.json +30 -0
- package/templates/events-meetups/l10n/sv.json +30 -0
- package/templates/events-meetups/l10n/th.json +30 -0
- package/templates/events-meetups/l10n/tr.json +30 -0
- package/templates/events-meetups/l10n/uk.json +30 -0
- package/templates/events-meetups/l10n/vi.json +30 -0
- package/templates/events-meetups/l10n/zh.json +30 -0
- package/templates/events-meetups/tier5-src/_shared/branded-lite-hosted.ts +1 -0
- package/templates/events-meetups/tier5-src/_shared/engine-intl.ts +6 -0
- package/templates/events-meetups/tier5-src/_shared/program-fields.ts +16 -0
- package/templates/events-meetups/tier5-src/_shared/program-standing.ts +67 -0
- package/templates/events-meetups/tier5-src/himi-branded-lite-home/index.ts +5 -0
- package/templates/events-meetups-owner/tier5-src/_shared/engine-intl.ts +6 -0
- package/templates/fitness-gym/tier5-src/_shared/branded-lite-hosted.ts +1 -0
- package/templates/fitness-gym/tier5-src/_shared/business-chat-transport.ts +20 -4
- package/templates/fitness-gym/tier5-src/_shared/chat-live.ts +242 -0
- package/templates/fitness-gym/tier5-src/_shared/engine-intl.ts +6 -0
- package/templates/fitness-gym/tier5-src/_shared/inbox-rooms.ts +101 -11
- package/templates/fitness-gym/tier5-src/_shared/program-standing.ts +21 -0
- package/templates/fitness-gym/tier5-src/business-chat/index.ts +73 -22
- package/templates/fitness-gym/tier5-src/himi-booking-time/index.ts +56 -12
- package/templates/fitness-gym/tier5-src/himi-branded-lite-member-programs/index.ts +23 -7
- package/templates/fitness-gym/tier5-src/himi-branded-lite-program/index.ts +17 -3
- package/templates/gym-fitness/l10n/ar.json +45 -0
- package/templates/gym-fitness/l10n/cs.json +45 -0
- package/templates/gym-fitness/l10n/da.json +45 -0
- package/templates/gym-fitness/l10n/de.json +45 -0
- package/templates/gym-fitness/l10n/el.json +45 -0
- package/templates/gym-fitness/l10n/en.json +1 -1
- package/templates/gym-fitness/l10n/es.json +45 -0
- package/templates/gym-fitness/l10n/fi.json +45 -0
- package/templates/gym-fitness/l10n/fr.json +45 -0
- package/templates/gym-fitness/l10n/he.json +36 -0
- package/templates/gym-fitness/l10n/hu.json +45 -0
- package/templates/gym-fitness/l10n/id.json +45 -0
- package/templates/gym-fitness/l10n/it.json +45 -0
- package/templates/gym-fitness/l10n/ja.json +45 -0
- package/templates/gym-fitness/l10n/ko.json +45 -0
- package/templates/gym-fitness/l10n/lt.json +45 -0
- package/templates/gym-fitness/l10n/nl.json +45 -0
- package/templates/gym-fitness/l10n/no.json +45 -0
- package/templates/gym-fitness/l10n/pl.json +45 -0
- package/templates/gym-fitness/l10n/pt.json +45 -0
- package/templates/gym-fitness/l10n/ru.json +45 -0
- package/templates/gym-fitness/l10n/sv.json +45 -0
- package/templates/gym-fitness/l10n/th.json +45 -0
- package/templates/gym-fitness/l10n/tr.json +45 -0
- package/templates/gym-fitness/l10n/uk.json +45 -0
- package/templates/gym-fitness/l10n/vi.json +45 -0
- package/templates/gym-fitness/l10n/zh.json +45 -0
- package/templates/gym-fitness/tier5-src/_shared/branded-lite-hosted.ts +1 -0
- package/templates/gym-fitness/tier5-src/_shared/business-chat-transport.ts +20 -4
- package/templates/gym-fitness/tier5-src/_shared/engine-intl.ts +6 -0
- package/templates/gym-fitness/tier5-src/_shared/program-fields.ts +16 -0
- package/templates/gym-fitness/tier5-src/_shared/program-standing.ts +67 -0
- package/templates/gym-fitness/tier5-src/himi-booking-time/index.ts +56 -12
- package/templates/gym-fitness/tier5-src/himi-branded-lite-home/index.ts +5 -0
- package/templates/gym-fitness-owner/tier5-src/_shared/engine-intl.ts +6 -0
- package/templates/medical-services/tier5-src/_shared/branded-lite-hosted.ts +1 -0
- package/templates/medical-services/tier5-src/_shared/business-chat-transport.ts +20 -4
- package/templates/medical-services/tier5-src/_shared/chat-live.ts +242 -0
- package/templates/medical-services/tier5-src/_shared/engine-intl.ts +6 -0
- package/templates/medical-services/tier5-src/_shared/inbox-rooms.ts +101 -11
- package/templates/medical-services/tier5-src/business-chat/index.ts +73 -22
- package/templates/medical-services/tier5-src/himi-booking-time/index.ts +56 -12
- package/templates/nonprofit-cause/l10n/ar.json +30 -0
- package/templates/nonprofit-cause/l10n/cs.json +30 -0
- package/templates/nonprofit-cause/l10n/da.json +30 -0
- package/templates/nonprofit-cause/l10n/de.json +30 -0
- package/templates/nonprofit-cause/l10n/el.json +30 -0
- package/templates/nonprofit-cause/l10n/en.json +1 -1
- package/templates/nonprofit-cause/l10n/es.json +30 -0
- package/templates/nonprofit-cause/l10n/fi.json +30 -0
- package/templates/nonprofit-cause/l10n/fr.json +30 -0
- package/templates/nonprofit-cause/l10n/he.json +24 -0
- package/templates/nonprofit-cause/l10n/hu.json +30 -0
- package/templates/nonprofit-cause/l10n/id.json +30 -0
- package/templates/nonprofit-cause/l10n/it.json +30 -0
- package/templates/nonprofit-cause/l10n/ja.json +30 -0
- package/templates/nonprofit-cause/l10n/ko.json +30 -0
- package/templates/nonprofit-cause/l10n/lt.json +30 -0
- package/templates/nonprofit-cause/l10n/nl.json +30 -0
- package/templates/nonprofit-cause/l10n/no.json +30 -0
- package/templates/nonprofit-cause/l10n/pl.json +30 -0
- package/templates/nonprofit-cause/l10n/pt.json +30 -0
- package/templates/nonprofit-cause/l10n/ru.json +30 -0
- package/templates/nonprofit-cause/l10n/sv.json +30 -0
- package/templates/nonprofit-cause/l10n/th.json +30 -0
- package/templates/nonprofit-cause/l10n/tr.json +30 -0
- package/templates/nonprofit-cause/l10n/uk.json +30 -0
- package/templates/nonprofit-cause/l10n/vi.json +30 -0
- package/templates/nonprofit-cause/l10n/zh.json +30 -0
- package/templates/nonprofit-cause/tier5-src/_shared/branded-lite-hosted.ts +1 -0
- package/templates/nonprofit-cause/tier5-src/_shared/engine-intl.ts +6 -0
- package/templates/nonprofit-cause/tier5-src/_shared/program-fields.ts +16 -0
- package/templates/nonprofit-cause/tier5-src/_shared/program-standing.ts +67 -0
- package/templates/nonprofit-cause/tier5-src/himi-branded-lite-home/index.ts +5 -0
- package/templates/nonprofit-cause-owner/tier5-src/_shared/engine-intl.ts +6 -0
- package/templates/owner-lite/tier5-src/_shared/engine-intl.ts +6 -0
- package/templates/personal-fitness-trainer/dev/index.ts +2 -1
- package/templates/personal-fitness-trainer/tier5-src/_shared/branded-lite-hosted.ts +1 -0
- package/templates/personal-fitness-trainer/tier5-src/_shared/business-chat-transport.ts +20 -4
- package/templates/personal-fitness-trainer/tier5-src/_shared/chat-live.ts +242 -0
- package/templates/personal-fitness-trainer/tier5-src/_shared/engine-intl.ts +6 -0
- package/templates/personal-fitness-trainer/tier5-src/_shared/inbox-rooms.ts +101 -11
- package/templates/personal-fitness-trainer/tier5-src/business-chat/index.ts +73 -22
- package/templates/personal-fitness-trainer/tier5-src/himi-booking-time/index.ts +56 -12
- package/templates/podcast-creator/l10n/ar.json +35 -0
- package/templates/podcast-creator/l10n/cs.json +35 -0
- package/templates/podcast-creator/l10n/da.json +35 -0
- package/templates/podcast-creator/l10n/de.json +35 -0
- package/templates/podcast-creator/l10n/el.json +35 -0
- package/templates/podcast-creator/l10n/en.json +1 -1
- package/templates/podcast-creator/l10n/es.json +35 -0
- package/templates/podcast-creator/l10n/fi.json +35 -0
- package/templates/podcast-creator/l10n/fr.json +35 -0
- package/templates/podcast-creator/l10n/he.json +28 -0
- package/templates/podcast-creator/l10n/hu.json +35 -0
- package/templates/podcast-creator/l10n/id.json +35 -0
- package/templates/podcast-creator/l10n/it.json +35 -0
- package/templates/podcast-creator/l10n/ja.json +35 -0
- package/templates/podcast-creator/l10n/ko.json +35 -0
- package/templates/podcast-creator/l10n/lt.json +35 -0
- package/templates/podcast-creator/l10n/nl.json +35 -0
- package/templates/podcast-creator/l10n/no.json +35 -0
- package/templates/podcast-creator/l10n/pl.json +35 -0
- package/templates/podcast-creator/l10n/pt.json +35 -0
- package/templates/podcast-creator/l10n/ru.json +35 -0
- package/templates/podcast-creator/l10n/sv.json +35 -0
- package/templates/podcast-creator/l10n/th.json +35 -0
- package/templates/podcast-creator/l10n/tr.json +35 -0
- package/templates/podcast-creator/l10n/uk.json +35 -0
- package/templates/podcast-creator/l10n/vi.json +35 -0
- package/templates/podcast-creator/l10n/zh.json +35 -0
- package/templates/podcast-creator/tier5-src/_shared/branded-lite-hosted.ts +1 -0
- package/templates/podcast-creator/tier5-src/_shared/engine-intl.ts +6 -0
- package/templates/podcast-creator/tier5-src/_shared/program-fields.ts +16 -0
- package/templates/podcast-creator/tier5-src/_shared/program-standing.ts +67 -0
- package/templates/podcast-creator/tier5-src/himi-branded-lite-home/index.ts +5 -0
- package/templates/podcast-creator-owner/tier5-src/_shared/engine-intl.ts +6 -0
- package/templates/portfolio-creative/l10n/ar.json +35 -0
- package/templates/portfolio-creative/l10n/cs.json +35 -0
- package/templates/portfolio-creative/l10n/da.json +35 -0
- package/templates/portfolio-creative/l10n/de.json +35 -0
- package/templates/portfolio-creative/l10n/el.json +35 -0
- package/templates/portfolio-creative/l10n/en.json +1 -1
- package/templates/portfolio-creative/l10n/es.json +35 -0
- package/templates/portfolio-creative/l10n/fi.json +35 -0
- package/templates/portfolio-creative/l10n/fr.json +35 -0
- package/templates/portfolio-creative/l10n/he.json +28 -0
- package/templates/portfolio-creative/l10n/hu.json +35 -0
- package/templates/portfolio-creative/l10n/id.json +35 -0
- package/templates/portfolio-creative/l10n/it.json +35 -0
- package/templates/portfolio-creative/l10n/ja.json +35 -0
- package/templates/portfolio-creative/l10n/ko.json +35 -0
- package/templates/portfolio-creative/l10n/lt.json +35 -0
- package/templates/portfolio-creative/l10n/nl.json +35 -0
- package/templates/portfolio-creative/l10n/no.json +35 -0
- package/templates/portfolio-creative/l10n/pl.json +35 -0
- package/templates/portfolio-creative/l10n/pt.json +35 -0
- package/templates/portfolio-creative/l10n/ru.json +35 -0
- package/templates/portfolio-creative/l10n/sv.json +35 -0
- package/templates/portfolio-creative/l10n/th.json +35 -0
- package/templates/portfolio-creative/l10n/tr.json +35 -0
- package/templates/portfolio-creative/l10n/uk.json +35 -0
- package/templates/portfolio-creative/l10n/vi.json +35 -0
- package/templates/portfolio-creative/l10n/zh.json +35 -0
- package/templates/portfolio-creative/tier5-src/_shared/branded-lite-hosted.ts +1 -0
- package/templates/portfolio-creative/tier5-src/_shared/engine-intl.ts +6 -0
- package/templates/portfolio-creative/tier5-src/_shared/program-fields.ts +16 -0
- package/templates/portfolio-creative/tier5-src/_shared/program-standing.ts +67 -0
- package/templates/portfolio-creative/tier5-src/himi-branded-lite-home/index.ts +5 -0
- package/templates/portfolio-creative-owner/tier5-src/_shared/engine-intl.ts +6 -0
- package/templates/restaurant/l10n/ar.json +35 -0
- package/templates/restaurant/l10n/cs.json +35 -0
- package/templates/restaurant/l10n/da.json +35 -0
- package/templates/restaurant/l10n/de.json +35 -0
- package/templates/restaurant/l10n/el.json +35 -0
- package/templates/restaurant/l10n/en.json +1 -1
- package/templates/restaurant/l10n/es.json +35 -0
- package/templates/restaurant/l10n/fi.json +35 -0
- package/templates/restaurant/l10n/fr.json +35 -0
- package/templates/restaurant/l10n/he.json +28 -0
- package/templates/restaurant/l10n/hu.json +35 -0
- package/templates/restaurant/l10n/id.json +35 -0
- package/templates/restaurant/l10n/it.json +35 -0
- package/templates/restaurant/l10n/ja.json +35 -0
- package/templates/restaurant/l10n/ko.json +35 -0
- package/templates/restaurant/l10n/lt.json +35 -0
- package/templates/restaurant/l10n/nl.json +35 -0
- package/templates/restaurant/l10n/no.json +35 -0
- package/templates/restaurant/l10n/pl.json +35 -0
- package/templates/restaurant/l10n/pt.json +35 -0
- package/templates/restaurant/l10n/ru.json +35 -0
- package/templates/restaurant/l10n/sv.json +35 -0
- package/templates/restaurant/l10n/th.json +35 -0
- package/templates/restaurant/l10n/tr.json +35 -0
- package/templates/restaurant/l10n/uk.json +35 -0
- package/templates/restaurant/l10n/vi.json +35 -0
- package/templates/restaurant/l10n/zh.json +35 -0
- package/templates/restaurant/tier5-src/_shared/branded-lite-hosted.ts +1 -0
- package/templates/restaurant/tier5-src/_shared/engine-intl.ts +6 -0
- package/templates/restaurant/tier5-src/_shared/program-fields.ts +16 -0
- package/templates/restaurant/tier5-src/_shared/program-standing.ts +67 -0
- package/templates/restaurant/tier5-src/himi-branded-lite-home/index.ts +5 -0
- package/templates/restaurant-owner/tier5-src/_shared/engine-intl.ts +6 -0
- package/templates/retail-store/l10n/ar.json +35 -0
- package/templates/retail-store/l10n/cs.json +35 -0
- package/templates/retail-store/l10n/da.json +35 -0
- package/templates/retail-store/l10n/de.json +35 -0
- package/templates/retail-store/l10n/el.json +35 -0
- package/templates/retail-store/l10n/en.json +1 -1
- package/templates/retail-store/l10n/es.json +35 -0
- package/templates/retail-store/l10n/fi.json +35 -0
- package/templates/retail-store/l10n/fr.json +35 -0
- package/templates/retail-store/l10n/he.json +28 -0
- package/templates/retail-store/l10n/hu.json +35 -0
- package/templates/retail-store/l10n/id.json +35 -0
- package/templates/retail-store/l10n/it.json +35 -0
- package/templates/retail-store/l10n/ja.json +35 -0
- package/templates/retail-store/l10n/ko.json +35 -0
- package/templates/retail-store/l10n/lt.json +35 -0
- package/templates/retail-store/l10n/nl.json +35 -0
- package/templates/retail-store/l10n/no.json +35 -0
- package/templates/retail-store/l10n/pl.json +35 -0
- package/templates/retail-store/l10n/pt.json +35 -0
- package/templates/retail-store/l10n/ru.json +35 -0
- package/templates/retail-store/l10n/sv.json +35 -0
- package/templates/retail-store/l10n/th.json +35 -0
- package/templates/retail-store/l10n/tr.json +35 -0
- package/templates/retail-store/l10n/uk.json +35 -0
- package/templates/retail-store/l10n/vi.json +35 -0
- package/templates/retail-store/l10n/zh.json +35 -0
- package/templates/retail-store/tier5-src/_shared/branded-lite-hosted.ts +1 -0
- package/templates/retail-store/tier5-src/_shared/engine-intl.ts +6 -0
- package/templates/retail-store/tier5-src/_shared/program-fields.ts +16 -0
- package/templates/retail-store/tier5-src/_shared/program-standing.ts +67 -0
- package/templates/retail-store/tier5-src/himi-branded-lite-home/index.ts +5 -0
- package/templates/retail-store-owner/tier5-src/_shared/engine-intl.ts +6 -0
- package/templates/salon-spa/tier5-src/_shared/branded-lite-hosted.ts +1 -0
- package/templates/salon-spa/tier5-src/_shared/business-chat-transport.ts +20 -4
- package/templates/salon-spa/tier5-src/_shared/chat-live.ts +242 -0
- package/templates/salon-spa/tier5-src/_shared/engine-intl.ts +6 -0
- package/templates/salon-spa/tier5-src/_shared/inbox-rooms.ts +101 -11
- package/templates/salon-spa/tier5-src/business-chat/index.ts +73 -22
- package/templates/salon-spa/tier5-src/himi-booking-time/index.ts +56 -12
- package/templates/wholesale-store/tier5-src/_shared/branded-lite-hosted.ts +1 -0
- package/templates/wholesale-store/tier5-src/_shared/business-chat-transport.ts +20 -4
- package/templates/wholesale-store/tier5-src/_shared/chat-live.ts +242 -0
- package/templates/wholesale-store/tier5-src/_shared/engine-intl.ts +6 -0
- package/templates/wholesale-store/tier5-src/_shared/inbox-rooms.ts +101 -11
- package/templates/wholesale-store/tier5-src/business-chat/index.ts +73 -22
- package/templates/yoga-studio/config.ts +9 -0
- package/templates/yoga-studio/dev/index.ts +1134 -133
- package/templates/yoga-studio/himalaya.content.json +3 -0
- package/templates/yoga-studio/l10n/ar.json +150 -0
- package/templates/yoga-studio/l10n/cs.json +150 -0
- package/templates/yoga-studio/l10n/da.json +150 -0
- package/templates/yoga-studio/l10n/de.json +150 -0
- package/templates/yoga-studio/l10n/el.json +150 -0
- package/templates/yoga-studio/l10n/en.json +70 -1
- package/templates/yoga-studio/l10n/es.json +150 -0
- package/templates/yoga-studio/l10n/fi.json +150 -0
- package/templates/yoga-studio/l10n/fr.json +150 -0
- package/templates/yoga-studio/l10n/he.json +122 -0
- package/templates/yoga-studio/l10n/hu.json +150 -0
- package/templates/yoga-studio/l10n/id.json +150 -0
- package/templates/yoga-studio/l10n/it.json +150 -0
- package/templates/yoga-studio/l10n/ja.json +150 -0
- package/templates/yoga-studio/l10n/ko.json +150 -0
- package/templates/yoga-studio/l10n/lt.json +150 -0
- package/templates/yoga-studio/l10n/nl.json +150 -0
- package/templates/yoga-studio/l10n/no.json +150 -0
- package/templates/yoga-studio/l10n/pl.json +150 -0
- package/templates/yoga-studio/l10n/pt.json +150 -0
- package/templates/yoga-studio/l10n/ru.json +150 -0
- package/templates/yoga-studio/l10n/sv.json +150 -0
- package/templates/yoga-studio/l10n/th.json +150 -0
- package/templates/yoga-studio/l10n/tr.json +150 -0
- package/templates/yoga-studio/l10n/uk.json +150 -0
- package/templates/yoga-studio/l10n/vi.json +150 -0
- package/templates/yoga-studio/l10n/zh.json +150 -0
- package/templates/yoga-studio/tier5-src/_shared/branded-lite-hosted.ts +1 -0
- package/templates/yoga-studio/tier5-src/_shared/business-chat-transport.ts +20 -4
- package/templates/yoga-studio/tier5-src/_shared/engine-intl.ts +6 -0
- package/templates/yoga-studio/tier5-src/_shared/program-fields.ts +16 -0
- package/templates/yoga-studio/tier5-src/_shared/program-standing.ts +21 -0
- package/templates/yoga-studio/tier5-src/himi-booking-time/index.ts +56 -12
- package/templates/yoga-studio/tier5-src/himi-branded-lite-home/index.ts +5 -0
- package/templates/yoga-studio/tier5-src/himi-branded-lite-member-programs/index.ts +23 -7
- package/templates/yoga-studio/tier5-src/himi-branded-lite-program/index.ts +17 -3
- package/templates/yoga-studio/tier5-src/himi-branded-lite-program-participant/index.ts +336 -0
- package/templates/yoga-studio/tier5-src/himi-branded-lite-program-participant/model.ts +206 -0
- package/templates/yoga-studio-owner/tier5-src/_shared/engine-intl.ts +6 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// The member's Inbox rows: every chatroom the member-role chat list returns, business and member alike.
|
|
2
2
|
// Pure, so the worker and its tests share one classification of what a room is.
|
|
3
|
+
import { calendarDay, formatClock, formatMonthDay, formatWeekdayShort } from "./engine-intl.js";
|
|
3
4
|
|
|
4
5
|
type RecordValue = Record<string, unknown>;
|
|
5
6
|
const object = (value: unknown): RecordValue =>
|
|
@@ -15,6 +16,8 @@ export function isBusinessRoom(value: unknown): boolean {
|
|
|
15
16
|
Object.keys(object(room.businessContext)).length > 0;
|
|
16
17
|
}
|
|
17
18
|
|
|
19
|
+
export const BUSINESS_SCREEN = "himi_business_chat";
|
|
20
|
+
|
|
18
21
|
export interface InboxRow {
|
|
19
22
|
id: string;
|
|
20
23
|
title: string;
|
|
@@ -24,14 +27,78 @@ export interface InboxRow {
|
|
|
24
27
|
/** `chatroom` makes the thread use `id` as the room instead of resolving it as a member id. */
|
|
25
28
|
kind: "chatroom" | "";
|
|
26
29
|
photo: string;
|
|
30
|
+
/** No photo: the screen draws the initial instead (`!photo`, kept with the photo by completeRow). */
|
|
31
|
+
noPhoto: boolean;
|
|
27
32
|
initial: string;
|
|
33
|
+
/** Has unread messages, or the member marked it unread. */
|
|
28
34
|
unread: boolean;
|
|
35
|
+
/** "●" when unread, else "". Kept for the screens that bind the glyph. */
|
|
29
36
|
unreadDot: string;
|
|
37
|
+
/** The server's unread count; 0 when none, or when the member marked a room unread (the count is then unknown). */
|
|
38
|
+
unreadCount: number;
|
|
39
|
+
/** The count as text: "" for 0 or unknown, "99+" above 99. */
|
|
40
|
+
unreadText: string;
|
|
41
|
+
/** hiddenWhen gates in both polarities: a count badge when the count is known, a plain dot when the room is
|
|
42
|
+
* unread but the count is not. */
|
|
43
|
+
showCount: boolean; hideCount: boolean; showDot: boolean; hideDot: boolean;
|
|
44
|
+
/** Last activity: the time today, "Yesterday", the weekday within the last six calendar days (as chat lists show it,
|
|
45
|
+
* not the calendar week), else the day. "" when unknown. */
|
|
46
|
+
dateLabel: string;
|
|
47
|
+
isArchived: boolean;
|
|
48
|
+
/** Only a private room can be deleted by a member (the Wix app's rule). */
|
|
49
|
+
isPrivate: boolean;
|
|
50
|
+
/** Swipe-action gates (hiddenWhen hides on TRUE). */
|
|
51
|
+
hideArchive: boolean; hideUnarchive: boolean; hideDelete: boolean; hideMarkRead: boolean; hideMarkUnread: boolean;
|
|
30
52
|
/** Sort key only; not bound to the screen. */
|
|
31
53
|
at: number;
|
|
32
54
|
}
|
|
33
55
|
|
|
34
56
|
const text = (value: unknown): string => (typeof value === "string" ? value.trim() : "");
|
|
57
|
+
const MAX_COUNT = 99;
|
|
58
|
+
|
|
59
|
+
/** "" for 0 or an unknown count, "99+" above 99. */
|
|
60
|
+
export const unreadCountText = (count: number): string => (count > MAX_COUNT ? `${MAX_COUNT}+` : count > 0 ? String(count) : "");
|
|
61
|
+
|
|
62
|
+
/** Everything that follows from a row's base fields. The one place a flag is derived, so a row that changes
|
|
63
|
+
* (marked read, archived) can never carry a flag that disagrees with its base fields. */
|
|
64
|
+
export type RowBase = Pick<InboxRow, "id" | "title" | "subtitle" | "screenId" | "kind" | "photo" | "initial" | "unread" | "unreadCount" | "dateLabel" | "isArchived" | "isPrivate" | "at">;
|
|
65
|
+
export function completeRow(base: RowBase): InboxRow {
|
|
66
|
+
const unreadText = unreadCountText(base.unreadCount);
|
|
67
|
+
const showCount = base.unread && unreadText !== "";
|
|
68
|
+
const showDot = base.unread && !showCount;
|
|
69
|
+
return {
|
|
70
|
+
...base,
|
|
71
|
+
noPhoto: !base.photo,
|
|
72
|
+
unreadDot: base.unread ? "●" : "",
|
|
73
|
+
unreadText,
|
|
74
|
+
showCount, hideCount: !showCount, showDot, hideDot: !showDot,
|
|
75
|
+
hideArchive: base.isArchived, hideUnarchive: !base.isArchived,
|
|
76
|
+
hideDelete: !base.isPrivate,
|
|
77
|
+
hideMarkRead: !base.unread, hideMarkUnread: base.unread,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** A row's read state changed: `count` is the server's count (0 = unknown or none). */
|
|
82
|
+
export function withUnread(row: InboxRow, unread: boolean, count: number): InboxRow {
|
|
83
|
+
const { id, title, subtitle, screenId, kind, photo, initial, dateLabel, isArchived, isPrivate, at } = row;
|
|
84
|
+
return completeRow({ id, title, subtitle, screenId, kind, photo, initial, dateLabel, isArchived, isPrivate, at, unread, unreadCount: unread ? count : 0 });
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Last-activity label in the device's zone: today → the time, yesterday → [yesterday] (the caller passes the localised
|
|
88
|
+
* word), within the last six calendar days → the weekday, otherwise the day. "" for an unknown time. Days are calendar
|
|
89
|
+
* days (local midnight to midnight), never 24-hour spans, so one day never gets two label formats and DST cannot shift them. */
|
|
90
|
+
export function dateLabel(at: number, yesterday: string, now: number = Date.now()): string {
|
|
91
|
+
if (!Number.isFinite(at) || at <= 0) return "";
|
|
92
|
+
const date = new Date(at);
|
|
93
|
+
const day = calendarDay(date);
|
|
94
|
+
if (day === calendarDay(new Date(now))) return formatClock(date);
|
|
95
|
+
const today = new Date(now);
|
|
96
|
+
// Noon of the previous calendar day: a 23- or 25-hour day around DST cannot move it to another day.
|
|
97
|
+
if (day === calendarDay(new Date(today.getFullYear(), today.getMonth(), today.getDate() - 1, 12))) return yesterday;
|
|
98
|
+
const sixDaysBack = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 6).getTime();
|
|
99
|
+
if (at >= sixDaysBack && at <= now) return formatWeekdayShort(date);
|
|
100
|
+
return formatMonthDay(date);
|
|
101
|
+
}
|
|
35
102
|
|
|
36
103
|
function titleOf(room: RecordValue, business: boolean): string {
|
|
37
104
|
const display = text(object(room.displayData).name);
|
|
@@ -39,30 +106,53 @@ function titleOf(room: RecordValue, business: boolean): string {
|
|
|
39
106
|
return display;
|
|
40
107
|
}
|
|
41
108
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
109
|
+
export interface InboxRowsOptions {
|
|
110
|
+
/** `inbox` (default): archived rooms are dropped. `archive`: the list is the archive, every room is kept and marked
|
|
111
|
+
* archived. `all`: search results, kept as they are. */
|
|
112
|
+
scope?: "inbox" | "archive" | "all";
|
|
113
|
+
/** The localised word for yesterday; "Yesterday" when absent. */
|
|
114
|
+
yesterday?: string;
|
|
115
|
+
now?: number;
|
|
116
|
+
/** Rooms the server lists as unread (`unreadChatroomIds`): a room the member marked unread has no count, only this. */
|
|
117
|
+
unreadIds?: ReadonlySet<string>;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** Newest conversation first; rooms without an id are dropped, and so are archived rooms in the inbox. `fallbackTitle`
|
|
121
|
+
* names a room that carries no name (the caller passes the localised word, not a hard-coded English one). */
|
|
122
|
+
export function inboxRows(rooms: unknown[], fallbackTitle: string, options: InboxRowsOptions = {}): InboxRow[] {
|
|
123
|
+
const { scope = "inbox", yesterday = "Yesterday", now, unreadIds } = options;
|
|
45
124
|
const rows: InboxRow[] = [];
|
|
46
125
|
for (const value of rooms) {
|
|
47
126
|
const room = object(value);
|
|
48
127
|
const id = text(room.id);
|
|
49
|
-
if (!id
|
|
128
|
+
if (!id) continue;
|
|
129
|
+
if (scope === "inbox" && room.isArchived === true) continue;
|
|
50
130
|
const business = isBusinessRoom(room);
|
|
51
131
|
const title = titleOf(room, business) || fallbackTitle;
|
|
52
132
|
const last = object(room.lastMessage);
|
|
53
|
-
const
|
|
54
|
-
|
|
133
|
+
const count = typeof room.unreadCount === "number" && Number.isFinite(room.unreadCount) && room.unreadCount > 0 ? Math.floor(room.unreadCount) : 0;
|
|
134
|
+
const at = typeof last.createdAt === "number" ? last.createdAt : typeof room.createdAt === "number" ? room.createdAt : 0;
|
|
135
|
+
rows.push(completeRow({
|
|
55
136
|
id,
|
|
56
137
|
title,
|
|
57
138
|
subtitle: text(last.summary),
|
|
58
|
-
screenId: business ?
|
|
139
|
+
screenId: business ? BUSINESS_SCREEN : "himi_chat_thread",
|
|
59
140
|
kind: business ? "" : "chatroom",
|
|
60
141
|
photo: text(object(object(room.displayData).image).url),
|
|
61
142
|
initial: (title[0] ?? "#").toUpperCase(),
|
|
62
|
-
unread,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
143
|
+
unread: count > 0 || unreadIds?.has(id) === true,
|
|
144
|
+
unreadCount: count,
|
|
145
|
+
dateLabel: dateLabel(at, yesterday, now),
|
|
146
|
+
isArchived: scope === "archive" || room.isArchived === true,
|
|
147
|
+
isPrivate: room.isPrivate === true,
|
|
148
|
+
at,
|
|
149
|
+
}));
|
|
66
150
|
}
|
|
67
151
|
return rows.sort((a, b) => b.at - a.at);
|
|
68
152
|
}
|
|
153
|
+
|
|
154
|
+
/** The newest message sequence a room's list entry carries, when it carries one (marking a room read needs it). */
|
|
155
|
+
export function lastSequenceOf(value: unknown): number | undefined {
|
|
156
|
+
const sequence = object(object(value).lastMessage).sequence;
|
|
157
|
+
return typeof sequence === "number" && Number.isSafeInteger(sequence) && sequence >= 0 ? sequence : undefined;
|
|
158
|
+
}
|
|
@@ -44,3 +44,24 @@ export const STATUS: Record<Exclude<Standing, "none">, { key: string; fallback:
|
|
|
44
44
|
approved: { key: "memberPrograms.status.approved", fallback: "Request approved", icon: "checkmark", color: "success" },
|
|
45
45
|
invited: { key: "memberPrograms.status.invited", fallback: "Invited", icon: "mail", color: "accentPrimary" },
|
|
46
46
|
};
|
|
47
|
+
|
|
48
|
+
/** The participant page (`himi_program_participant`): what a member in the program opens instead of the sales page. */
|
|
49
|
+
export const PARTICIPANT_SCREEN = "himi_program_participant";
|
|
50
|
+
|
|
51
|
+
/** Standings that open the participant page: the member is in the program, or stayed in it to its end.
|
|
52
|
+
* A paused (suspended) member and everyone else open the program page, which owns joining and paying. */
|
|
53
|
+
export const PARTICIPANT_STANDINGS: ReadonlySet<Standing> = new Set<Standing>(["joined", "completed", "finished"]);
|
|
54
|
+
|
|
55
|
+
/** Whether the member is in the program: an actual participation (an admitted application alone is
|
|
56
|
+
* not one: the participant page reads the participation), not paused, with a standing that opens the
|
|
57
|
+
* participant page. Pass the participation the standing was read from. */
|
|
58
|
+
export function inProgram(standing: Standing, participant: WixParticipant | undefined): boolean {
|
|
59
|
+
return !!participant && PARTICIPANT_STANDINGS.has(standing)
|
|
60
|
+
&& String(participant.enrollmentStatus ?? "").toUpperCase() !== "SUSPENDED";
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** The screen a program row opens. `participantScreen` is the host's participant page; "" (a host
|
|
64
|
+
* without one) keeps every row on `programScreen`. */
|
|
65
|
+
export function programScreenFor(memberInProgram: boolean, programScreen: string, participantScreen: string): string {
|
|
66
|
+
return participantScreen && memberInProgram ? participantScreen : programScreen;
|
|
67
|
+
}
|
|
@@ -10,6 +10,8 @@ import { businessInAppRoute, type BusinessArticleAction, dispatchBusinessSuggest
|
|
|
10
10
|
import { listMessages, streamMessages } from '@himalaya/wix-ai-site-chat';
|
|
11
11
|
import { smartChatHistory } from '../_shared/business-chat-history.js';
|
|
12
12
|
import { hostSiteFromInput } from '../_shared/branded-lite-hosted.js';
|
|
13
|
+
import { CHAT_LIVE_POLL_ID, livePollDirective } from '../_shared/chat-live.js';
|
|
14
|
+
import type { PollDirective, PollStopDirective } from '@himalaya/state';
|
|
13
15
|
import { productImage, searchStoreProducts } from '../_shared/himi-store.js';
|
|
14
16
|
import { queryServices } from '@himalaya/wix-bookings';
|
|
15
17
|
import { logBi, logChatSendError } from '../_shared/wix-bi.js';
|
|
@@ -26,8 +28,19 @@ type BusinessMessageRow = Pick<MessageRow,'id'|'sender'|'when'|'createdDate'|'mi
|
|
|
26
28
|
/** Confirmed local delivery, retained until the authoritative history returns it. */
|
|
27
29
|
acceptedIntent?:PendingIntent;
|
|
28
30
|
};
|
|
31
|
+
/** Integration contract for a screen that binds this worker (the design is the screen's; these fields are the data).
|
|
32
|
+
* Visitor chat is opt-in: the screen's init passes `visitorChat:"1"`, else a signed-out user is a guest.
|
|
33
|
+
* - phase: 'loading'|'ready'|'error'|'guest'. isGuest/notGuest: the sign-in prompt state (signed out, no visitor chat, or a lost session).
|
|
34
|
+
* - visitor/notVisitor: a signed-out visitor chatting with Smart Chat (no room, no realtime, re-read every 4 s). A visitor
|
|
35
|
+
* still has phase 'ready', so the composer shows; hide it only on isGuest. Signing in closes into a member chat on `load`.
|
|
36
|
+
* - sendEnabled/sendDisabled: the Send button state for the member and the visitor alike.
|
|
37
|
+
* - messages: the rows. quickReplies: the visitor options (hasQuickReplies/noQuickReplies).
|
|
38
|
+
* - liveLabel: the realtime status text; blank for a visitor, who has no realtime. */
|
|
29
39
|
type State = {
|
|
30
40
|
phase:'loading'|'ready'|'error'|'guest'; error:string; notice:string; member:boolean;
|
|
41
|
+
/** Signed out, chatting with Smart Chat as a site visitor: no member room, no realtime, a 4 s re-read instead. */
|
|
42
|
+
visitor:boolean; notVisitor:boolean;
|
|
43
|
+
_poll?:PollDirective|PollStopDirective;
|
|
31
44
|
roomId:string; principal:string; scope:string; messages:BusinessMessageRow[]; draft:string; busy:boolean;
|
|
32
45
|
historySource:'members'|'smart-chat'; historyRevision:number; smartChatEmpty:boolean;
|
|
33
46
|
/** Actual row namespace, independent of the transport followed after acceptance. */
|
|
@@ -54,9 +67,19 @@ function initialsOf(name:string):string{
|
|
|
54
67
|
const words=name.trim().split(/\s+/).filter(Boolean);
|
|
55
68
|
return (words.length>1?`${first(words[0]!)}${first(words[words.length-1]!)}`:first(words[0]??'')).toUpperCase();
|
|
56
69
|
}
|
|
57
|
-
const initial:State={hostedName,businessName:hostedName,businessInitials:initialsOf(hostedName),hasHostedName:!!hostedName,noHostedName:!hostedName,phase:'loading',error:'',notice:'',member:false,roomId:'',principal:'',scope:'',messages:[],draft:'',busy:false,historySource:'members',historyRevision:0,smartChatEmpty:false,transcriptSource:'members',
|
|
70
|
+
const initial:State={hostedName,businessName:hostedName,businessInitials:initialsOf(hostedName),hasHostedName:!!hostedName,noHostedName:!hostedName,phase:'loading',error:'',notice:'',member:false,visitor:false,notVisitor:true,roomId:'',principal:'',scope:'',messages:[],draft:'',busy:false,historySource:'members',historyRevision:0,smartChatEmpty:false,transcriptSource:'members',
|
|
58
71
|
liveState:'unavailable',liveReason:'',realtimeEventCount:0,lastRealtimeEventType:'',liveLabel:'',hasActiveRoom:false,noActiveRoom:true,isGuest:false,notGuest:true,realtimeDiagnostic:'',pendingIntent:null,scrollAnchor:'',scrollSend:0,usedSuggestionIds:[],visitorOptions:null,quickReplies:[],hasQuickReplies:false,noQuickReplies:true,noError:true,noNotice:true,noMessages:true,hasMessages:false,noEmpty:true,notLoading:false,sendDisabled:true,sendEnabled:false,noLive:true,loadingHidden:false,errorText:'',loadFailure:''};
|
|
59
72
|
let currentIdentity:ChatIdentity|null=null;
|
|
73
|
+
/** A visitor has no member principal: this one stands in, so a refresh started for the visitor is dropped once someone signs in. */
|
|
74
|
+
const VISITOR='visitor';
|
|
75
|
+
let visitorMode=false;
|
|
76
|
+
/** Visitor chat is opt-in: only a screen that passes `visitorChat:"1"` to init lets a signed-out visitor chat. Any other
|
|
77
|
+
* screen keeps the member-only chat, where signed out means the sign-in prompt. A retry passes no param: it keeps. */
|
|
78
|
+
let visitorChatOn=false;
|
|
79
|
+
/** Who the in-flight work belongs to: the member, the visitor, or no one. */
|
|
80
|
+
function currentPrincipal():string{return currentIdentity?(currentIdentity.userId||currentIdentity.email):visitorMode?VISITOR:'';}
|
|
81
|
+
/** A Smart Chat read or send, fenced for whoever is chatting now. */
|
|
82
|
+
function smartChatGuard<T>(run:()=>Promise<T>):Promise<T>{return visitorMode?chat.visitorFence(run):chat.fence(me(),run);}
|
|
60
83
|
let subscriptionId='';
|
|
61
84
|
let initFlight=false;
|
|
62
85
|
let suggestionFlight=false;
|
|
@@ -87,7 +110,7 @@ async function loadSmartChatMessages():Promise<unknown[]>{
|
|
|
87
110
|
const incomplete=()=>Object.assign(new Error('smart_chat_history_incomplete'),{code:'smart_chat_history_incomplete'});
|
|
88
111
|
for(let page=0;page<20;page++){
|
|
89
112
|
let response:Awaited<ReturnType<typeof listMessages>>;
|
|
90
|
-
try{response=await
|
|
113
|
+
try{response=await smartChatGuard(()=>listMessages({cursorPaging:{limit:100,...(cursor?{cursor}:{})}}));}
|
|
91
114
|
catch(error){
|
|
92
115
|
if(/member_sign_in_required|MemberAccessChanged|\b401\b/i.test(String(error))||(page>0&&/\b403\b/.test(String(error))))throw Object.assign(new Error('member_sign_in_required'),{code:'smart_chat_history_incomplete'});
|
|
93
116
|
// Only an explicit unavailable feature permits the legacy fallback. A timeout or
|
|
@@ -110,7 +133,7 @@ async function loadSmartChatMessages():Promise<unknown[]>{
|
|
|
110
133
|
async function sendBusinessVisitorOption(options:BusinessVisitorOptions|null|undefined,label:string):Promise<boolean>{
|
|
111
134
|
const request=businessVisitorOptionRequest(options,label,newBusinessSelectionId());
|
|
112
135
|
if(!request)return false;
|
|
113
|
-
await
|
|
136
|
+
await smartChatGuard(()=>streamMessages(request));
|
|
114
137
|
return true;
|
|
115
138
|
}
|
|
116
139
|
function liveDescription(state:string,reason:string):string{return businessRealtimeStatusLabel(state,reason);}
|
|
@@ -141,11 +164,11 @@ function selectedOptionVisible(aiMessages:unknown[],messages:BusinessMessageRow[
|
|
|
141
164
|
messages.some(row=>row.id===`smart-chat:${message.id}`&&row.mine&&row.bodyText.trim()===intent.text.trim());
|
|
142
165
|
});
|
|
143
166
|
}
|
|
144
|
-
function shape(s:State):State{const used=new Set(s.usedSuggestionIds);const messages=s.messages.map(row=>({...row,noSuggestions:s.phase!=='ready'||!(row.suggestions||[]).length,suggestions:(row.suggestions||[]).map(button=>used.has(button.id)?{...button,enabled:false,disabled:true}:button)}));const quickReplies=(s.quickReplies||[]).map(button=>used.has(button.id)?{...button,enabled:false,disabled:true}:button);const quickEnabled=s.phase==='ready'&&quickReplies.some(button=>button.enabled);return {...s,messages,quickReplies,hasQuickReplies:quickEnabled,noQuickReplies:!quickEnabled,scrollAnchor:messages[messages.length-1]?.scrollAnchor||'',liveLabel:liveDescription(s.liveState,s.liveReason),hasActiveRoom:!!s.roomId,noActiveRoom:!s.roomId,hasHostedName:!!s.hostedName,noHostedName:!s.hostedName,isGuest:s.phase==='guest',notGuest:s.phase!=='guest',realtimeDiagnostic:`state=${s.liveState}; reason=${s.liveReason||'none'}; events=${s.realtimeEventCount}; lastType=${/^(message|messagesent)$/i.test(s.lastRealtimeEventType)?s.lastRealtimeEventType:'none'}`,errorText:s.error,loadingHidden:s.phase!=='loading'||!!s.error,noError:!s.error,noNotice:!s.notice,noMessages:!messages.length,hasMessages:!!messages.length,noEmpty:s.phase!=='ready'||!!messages.length,
|
|
167
|
+
function shape(s:State):State{const used=new Set(s.usedSuggestionIds);const messages=s.messages.map(row=>({...row,noSuggestions:s.phase!=='ready'||!(row.suggestions||[]).length,suggestions:(row.suggestions||[]).map(button=>used.has(button.id)?{...button,enabled:false,disabled:true}:button)}));const quickReplies=(s.quickReplies||[]).map(button=>used.has(button.id)?{...button,enabled:false,disabled:true}:button);const quickEnabled=s.phase==='ready'&&quickReplies.some(button=>button.enabled);return {...s,messages,quickReplies,hasQuickReplies:quickEnabled,noQuickReplies:!quickEnabled,scrollAnchor:messages[messages.length-1]?.scrollAnchor||'',liveLabel:s.visitor?'':liveDescription(s.liveState,s.liveReason),hasActiveRoom:!!s.roomId,noActiveRoom:!s.roomId,hasHostedName:!!s.hostedName,noHostedName:!s.hostedName,isGuest:s.phase==='guest',notVisitor:!s.visitor,notGuest:s.phase!=='guest',realtimeDiagnostic:`state=${s.liveState}; reason=${s.liveReason||'none'}; events=${s.realtimeEventCount}; lastType=${/^(message|messagesent)$/i.test(s.lastRealtimeEventType)?s.lastRealtimeEventType:'none'}`,errorText:s.error,loadingHidden:s.phase!=='loading'||!!s.error,noError:!s.error,noNotice:!s.notice,noMessages:!messages.length,hasMessages:!!messages.length,noEmpty:s.phase!=='ready'||!!messages.length,
|
|
145
168
|
notLoading:s.phase!=='loading',sendDisabled:!canSend(s,s.draft),sendEnabled:canSend(s,s.draft),noLive:!s.roomId||s.liveState==='connected'};}
|
|
146
169
|
/** Smart Chat resolves the conversation from the member identity, including the first message.
|
|
147
170
|
* History must finish loading before Send is offered so delivery has a reliable anchor. */
|
|
148
|
-
function canSend(s:State,draft:string):boolean{return !!s.member&&s.phase==='ready'&&!s.busy&&!!draft.trim()&&!s.pendingIntent;}
|
|
171
|
+
function canSend(s:State,draft:string):boolean{return (!!s.member||!!s.visitor)&&s.phase==='ready'&&!s.busy&&!!draft.trim()&&!s.pendingIntent;}
|
|
149
172
|
function safeLoadFailure(error:unknown):string{
|
|
150
173
|
const name=error instanceof Error?error.name:'UnknownError';
|
|
151
174
|
const code=(error as {code?:unknown}|null)?.code;
|
|
@@ -249,12 +272,14 @@ function slimRow(row:Record<string,unknown>):BusinessMessageRow{
|
|
|
249
272
|
return pick('id','sender','when','createdDate','mine','senderAvatar','senderName','senderInitials','senderBadge','imageUrl','imageDescription','noImage','bodyText','bodyMarkdown','suggestions','articleActions','couponCode','noCoupon','notMine','isCard','notCard','noSuggestions','noActions','cardTitle','cardDetail','noCardText','dayLabel','dayHidden','startsDay','scrollAnchor') as unknown as BusinessMessageRow;
|
|
250
273
|
}
|
|
251
274
|
async function presentMessages(existing:MessageRow[],raw:unknown[],memberId?:string,participantId=businessParticipantId||'smart-chat:visitor'):Promise<BusinessMessageRow[]>{
|
|
252
|
-
|
|
275
|
+
// A private attachment's download URL is member-only: a visitor's row keeps the part without one.
|
|
276
|
+
const identity=visitorMode?null:me();const presentationEpoch=epoch;
|
|
253
277
|
const rows=chronologicalMessages(existing,raw,memberId) as MessageRow[];
|
|
254
278
|
const prepared=await Promise.all(rows.map(async row=>{
|
|
255
279
|
const parts=await Promise.all(row.parts.map(async part=>{
|
|
256
280
|
if(part.kind!=='image'&&part.kind!=='file'&&part.kind!=='audio'&&part.kind!=='video')return part;
|
|
257
281
|
if(part.mediaProvider==='WixMediaPrivate'&&part.mediaId){
|
|
282
|
+
if(!identity)return {...part,url:''};
|
|
258
283
|
try{return {...part,url:await privateAttachmentUrl(part,identity,presentationEpoch)};}catch{return {...part,url:''};}
|
|
259
284
|
}
|
|
260
285
|
return part;
|
|
@@ -296,8 +321,9 @@ function safeError(error:unknown,operation:'load'|'send'|'init'):string{
|
|
|
296
321
|
}
|
|
297
322
|
async function endSubscription():Promise<void>{const id=subscriptionId;subscriptionId='';if(id)try{await unsubscribeRealtime({subscriptionId:id});}catch{}}
|
|
298
323
|
function clearPrivate(s:State,phase:'guest'|'error'='guest'):State{
|
|
324
|
+
const wasVisitor=visitorMode;visitorMode=false;
|
|
299
325
|
attachmentUrls.clear();seenSelections.clear();productImages.clear();productImageLookups.clear();serviceIds.clear();serviceIdLookups.clear();currentIdentity=null;businessParticipantId='';epoch++;void endSubscription();
|
|
300
|
-
return shape({...initial,phase,error:phase==='guest'?businessChatCopy('signInPrompt'):s.error});
|
|
326
|
+
return shape({...initial,phase,error:phase==='guest'?businessChatCopy('signInPrompt'):s.error,...(wasVisitor?{_poll:{id:CHAT_LIVE_POLL_ID,stop:true as const}}:{})});
|
|
301
327
|
}
|
|
302
328
|
let refreshTail:Promise<unknown>=Promise.resolve();
|
|
303
329
|
/** One refresh runs at a time. A caller that needs the data (init, a send) waits for the one in flight and
|
|
@@ -314,7 +340,7 @@ async function loadHistory(s:State,wait=false):Promise<State|undefined>{
|
|
|
314
340
|
async function refreshHistory(s:State):Promise<State|undefined>{
|
|
315
341
|
refreshFlight=true;const startEpoch=epoch;const roomId=s.roomId;const principal=s.principal;const participantId=businessParticipantId||'smart-chat:visitor';const startDraftRevision=draftRevision;
|
|
316
342
|
// A refresh that outlived its member or session says nothing: returning a state would overwrite the new one.
|
|
317
|
-
const stale=()=>startEpoch!==epoch||(
|
|
343
|
+
const stale=()=>startEpoch!==epoch||currentPrincipal()!==principal;
|
|
318
344
|
try{
|
|
319
345
|
loadStage='history_request';
|
|
320
346
|
// The Members room and Smart Chat may be different conversations. Read Smart Chat's
|
|
@@ -416,12 +442,12 @@ type SendResult={id:string;outcome:'sent'|'rejected'|'unconfirmed'|'signed_out';
|
|
|
416
442
|
/** Posts one message and reports how it ended; never throws. The caller already showed the message. The call lasts
|
|
417
443
|
* until the AI has answered: history usually shows the stored copy first, which replaces the placeholder, while Send
|
|
418
444
|
* stays held until this settles (the site's widget also waits for the answer). */
|
|
419
|
-
async function deliver(pending:BusinessChatIntent,draft:string):Promise<void>{
|
|
445
|
+
async function deliver(pending:BusinessChatIntent,draft:string,visitor=false):Promise<void>{
|
|
420
446
|
const sendEpoch=epoch;
|
|
421
447
|
let result:SendResult={id:pending.id,outcome:'sent',draft};
|
|
422
448
|
try{
|
|
423
449
|
await Promise.resolve();// the action that started this has returned its state by now
|
|
424
|
-
result.storedId=await chat.sendMessage(me(),pending.text);
|
|
450
|
+
result.storedId=await (visitor?chat.sendVisitorMessage(pending.text):chat.sendMessage(me(),pending.text));
|
|
425
451
|
}catch(error){
|
|
426
452
|
const lost=/member_sign_in_required|MemberAccessChanged|\b401\b|\b403\b/i.test(String(error));
|
|
427
453
|
result={id:pending.id,draft,error,outcome:lost?'signed_out':businessChatSendRejected(error)?'rejected':'unconfirmed'};
|
|
@@ -465,7 +491,8 @@ const svc=defineService<State,Record<string,(s:State,a?:unknown)=>State|undefine
|
|
|
465
491
|
// A host runs `load` when the screen shows again, also when a sign-in modal over it closes.
|
|
466
492
|
// Only a guest loads again: a member's chat is already live. No args: init keeps the site
|
|
467
493
|
// and name the screen gave first.
|
|
468
|
-
|
|
494
|
+
// A visitor loads again too: the sign-in modal over the chat closing is how a visitor becomes a member.
|
|
495
|
+
load:async (s):Promise<State|undefined>=>s.phase==='guest'||s.visitor?svc.init():undefined,
|
|
469
496
|
init:async(s,a)=>{
|
|
470
497
|
// Keep $t: keys as values: renderers translate bound worker copy in the active locale.
|
|
471
498
|
const copy=Object.fromEntries(Object.keys(BUSINESS_CHAT_COPY).map(key=>[`businessChat.${key}`,param(a,`businessChat.${key}`)]).filter(([,text])=>!!text));
|
|
@@ -473,6 +500,7 @@ const svc=defineService<State,Record<string,(s:State,a?:unknown)=>State|undefine
|
|
|
473
500
|
if(initFlight)return s;initFlight=true;eventDuringInit=false;statusDuringInit=null;
|
|
474
501
|
// A retry passes no site: the one the screen gave first stays. A site the screen passes, even an empty one (a
|
|
475
502
|
// business with no site), replaces it, so an earlier business's links are not routed to this one's screens.
|
|
503
|
+
if(hasParam(a,'visitorChat'))visitorChatOn=param(a,'visitorChat')==='1';
|
|
476
504
|
if(hasParam(a,'siteUrl')){ownSiteUrl=param(a,'siteUrl');ownScreens.product=param(a,'productScreen');ownScreens.service=param(a,'serviceScreen');}
|
|
477
505
|
// A retry passes no name: the one the screen gave first stays. Under `displayName`, a copy key, so a template
|
|
478
506
|
// sweep that renames the business renames it here too and the initials follow.
|
|
@@ -518,10 +546,21 @@ const svc=defineService<State,Record<string,(s:State,a?:unknown)=>State|undefine
|
|
|
518
546
|
loadStage='room_selection';
|
|
519
547
|
const identity=await getCurrentMember();
|
|
520
548
|
if(myEpoch!==epoch)return undefined;
|
|
521
|
-
if(!identity.authenticated)
|
|
549
|
+
if(!identity.authenticated){
|
|
550
|
+
if(!visitorChatOn)throw new Error('member_sign_in_required');
|
|
551
|
+
// Signed out: chat with Smart Chat as a site visitor, as on the website. No member room and no realtime
|
|
552
|
+
// (both are member-only), so the transcript is re-read every 4 s while the screen is open.
|
|
553
|
+
if(oldPrincipal&&oldPrincipal!==VISITOR){s=signed(clearPrivate(s,'guest'));myEpoch=epoch;reset=true;}
|
|
554
|
+
currentIdentity=null;visitorMode=true;businessParticipantId='';
|
|
555
|
+
s=shape({...s,phase:'loading',member:false,visitor:true,principal:VISITOR,scope:'',roomId:'',error:'',notice:''});
|
|
556
|
+
const loaded=await loadLatest(s,true);
|
|
557
|
+
if(!loaded||myEpoch!==epoch)return undefined;
|
|
558
|
+
return shape({...keepTyped(loaded),_poll:livePollDirective('businessChat.refresh')});
|
|
559
|
+
}
|
|
522
560
|
if(oldPrincipal&&(oldPrincipal!==(identity.userId||identity.email)||s.scope!==identity.scope)){s=signed(clearPrivate(s,'guest'));myEpoch=epoch;reset=true;}
|
|
523
561
|
currentIdentity=identity;
|
|
524
|
-
|
|
562
|
+
visitorMode=false;
|
|
563
|
+
s=shape({...s,phase:'loading',member:true,visitor:false,principal:identity.userId||identity.email,scope:identity.scope,error:'',notice:''});
|
|
525
564
|
const existingRoom=await resolveExistingBusinessRoom(myEpoch,signedBy);
|
|
526
565
|
if(myEpoch!==epoch)return undefined;
|
|
527
566
|
const live=readServiceState();
|
|
@@ -563,8 +602,9 @@ const svc=defineService<State,Record<string,(s:State,a?:unknown)=>State|undefine
|
|
|
563
602
|
// business (biLogger.service.ts:226-258, origin 'native' from biLogger.utils.ts). RN has no contact id here either.
|
|
564
603
|
// It is logged on the Send tap, before the network call, on purpose: RN calls engageSendMessageClick synchronously
|
|
565
604
|
// before sendMessageService.sendMessage, so a send the server then refuses has logged 510 and also logs 1604 (deliver).
|
|
566
|
-
|
|
567
|
-
|
|
605
|
+
// A signed-out visitor is not a member: the member-to-business event is not theirs to log.
|
|
606
|
+
if(!s.visitor)logBi({evid:510,src:5,endpoint:'',params:{origin:'native',is_member:true,chatRoomType:'member to business',activity_type:'',appName:'',expand_mode:false,textLength:text.length,is_demo:false}});
|
|
607
|
+
void deliver(pending,s.draft,!!s.visitor);
|
|
568
608
|
return shape({...s,draft:'',pendingIntent:pending,messages:[...s.messages,pendingRow(pending)],error:'',notice:'',scrollSend:s.scrollSend+1});
|
|
569
609
|
},
|
|
570
610
|
settleSend:async(s,a)=>{
|
|
@@ -625,8 +665,9 @@ const svc=defineService<State,Record<string,(s:State,a?:unknown)=>State|undefine
|
|
|
625
665
|
if(!loaded)return undefined;
|
|
626
666
|
resolved=loaded;
|
|
627
667
|
resolved=latestResolved();
|
|
628
|
-
// Creating a conversation is a consequence of the accepted send, never of opening chat.
|
|
629
|
-
|
|
668
|
+
// Creating a conversation is a consequence of the accepted send, never of opening chat. A visitor has no
|
|
669
|
+
// Members room to find: Smart Chat is their whole conversation.
|
|
670
|
+
if(!resolved.roomId&&!resolved.visitor){
|
|
630
671
|
const room=await resolveExistingBusinessRoom(sendEpoch,s.businessName);
|
|
631
672
|
if(sendEpoch!==epoch)return undefined;
|
|
632
673
|
const latest=latestResolved();
|
|
@@ -658,16 +699,16 @@ const svc=defineService<State,Record<string,(s:State,a?:unknown)=>State|undefine
|
|
|
658
699
|
}catch{return shape({...withLiveDraft(accepted),notice:businessChatCopy('suggestionSent')});}
|
|
659
700
|
},
|
|
660
701
|
sendSuggestion:(s,a)=>{
|
|
661
|
-
if(suggestionFlight
|
|
702
|
+
if(suggestionFlight||(!s.member&&!s.visitor)||s.phase!=='ready'||!!s.pendingIntent)return s;
|
|
662
703
|
const id=param(a,'id');
|
|
663
704
|
if(!id||s.usedSuggestionIds.includes(id))return s;
|
|
664
705
|
const rows=[{suggestions:s.quickReplies} as {suggestions?:BusinessSuggestion[]},...s.messages];
|
|
665
706
|
const suggestion=findBusinessSuggestion(rows,id);
|
|
666
707
|
// A first conversation has no room yet: only an AI option can start it.
|
|
667
708
|
if(!suggestion||!s.roomId&&suggestion.kind!=='visitor_option')return s;
|
|
668
|
-
const currentPrincipal
|
|
669
|
-
if(!s.principal||s.principal!==
|
|
670
|
-
const session:SuggestionSession={member:s.member,roomId:s.roomId,principal:s.principal,currentPrincipal,scope:s.scope,currentScope:currentIdentity?.scope||''};
|
|
709
|
+
const principalNow=currentPrincipal();
|
|
710
|
+
if(!s.principal||s.principal!==principalNow||s.scope!==(currentIdentity?.scope??''))return s;
|
|
711
|
+
const session:SuggestionSession={member:s.member||s.visitor,roomId:s.roomId,principal:s.principal,currentPrincipal:principalNow,scope:s.scope,currentScope:currentIdentity?.scope||''};
|
|
671
712
|
suggestionFlight=true;
|
|
672
713
|
if(suggestion.kind!=='visitor_option'){
|
|
673
714
|
void deliverButtonSuggestion(id,rows,session).finally(()=>{suggestionFlight=false;});
|
|
@@ -712,7 +753,17 @@ const svc=defineService<State,Record<string,(s:State,a?:unknown)=>State|undefine
|
|
|
712
753
|
}
|
|
713
754
|
catch(error){if(startEpoch!==epoch)return undefined;const lost=/member_sign_in_required|MemberAccessChanged|\b401\b|\b403\b/i.test(String(error));return lost?clearPrivate(next,'guest'):shape({...withLiveDraft(next),error:safeError(error,'load'),loadFailure:typeof (error as {businessLoadFailure?:unknown})?.businessLoadFailure==='string'?(error as {businessLoadFailure:string}).businessLoadFailure:safeLoadFailure(error)});}
|
|
714
755
|
},
|
|
715
|
-
|
|
756
|
+
// The visitor's 4 s re-read. A member is live through realtime and never polls; a tick that finds someone
|
|
757
|
+
// signed in meanwhile hands over to init, which moves the chat to the member.
|
|
758
|
+
refresh:async (s):Promise<State|undefined>=>{
|
|
759
|
+
if(!s.visitor||s.phase!=='ready')return undefined;
|
|
760
|
+
const startEpoch=epoch;
|
|
761
|
+
try{return await loadLatest(s);}catch(error){
|
|
762
|
+
if(startEpoch!==epoch)return undefined;
|
|
763
|
+
return /member_sign_in_required|MemberAccessChanged/i.test(String(error))?svc.init():undefined;
|
|
764
|
+
}
|
|
765
|
+
},
|
|
766
|
+
dispose:async s=>{epoch++;visitorMode=false;attachmentUrls.clear();seenSelections.clear();productImages.clear();productImageLookups.clear();serviceIds.clear();serviceIdLookups.clear();currentIdentity=null;businessParticipantId='';await endSubscription();return shape({...initial,phase:'guest'});},
|
|
716
767
|
}
|
|
717
768
|
});
|
|
718
769
|
readServiceState=()=>svc.getState();
|
|
@@ -7,7 +7,7 @@ import { defineService as registerService, navigate } from "@himalaya/state";
|
|
|
7
7
|
// instant range, not a calendar day.
|
|
8
8
|
import { addDays as addLocalDays, dayKey, dayLabel, timeLabel, toDate } from "@himalaya/time";
|
|
9
9
|
import { dispatch } from "@himalaya/dispatch";
|
|
10
|
-
import { bookSchedule, bookSlot, getService, queryServiceAvailability, registerToWaitlist, type WixBookingSlotFull, type WixSelectedPaymentOption, type WixService } from "@himalaya/wix-bookings";
|
|
10
|
+
import { bookSchedule, bookSlot, cancelBookingAsMember, getService, queryServiceAvailability, registerToWaitlist, type WixBookingSlotFull, type WixSelectedPaymentOption, type WixService } from "@himalaya/wix-bookings";
|
|
11
11
|
import { createCheckout, createOrder } from "@himalaya/wix-ecom";
|
|
12
12
|
import { createRedirectSession } from "@himalaya/wix-redirects";
|
|
13
13
|
import { isPaymentSetupFailure, payCashierOrder } from "@himalaya/checkout";
|
|
@@ -19,7 +19,7 @@ import { stashCopy, copyParam, copyPlural, copyTemplate } from "../_shared/himi-
|
|
|
19
19
|
import { upsert as dbUpsert, remove as dbRemove, enqueue as dbEnqueue, type DbEntity } from "@himalaya/local-db";
|
|
20
20
|
import { locationChoice, readSharedLocationResult, writeSharedLocation } from "../_shared/booking-location.js";
|
|
21
21
|
import { memberScreenOpener } from "../_shared/member-screen.js";
|
|
22
|
-
import { isBridgeUnavailable } from "../_shared/owner-load-error.js";
|
|
22
|
+
import { isBridgeUnavailable, writeMayHaveLanded } from "../_shared/owner-load-error.js";
|
|
23
23
|
import { emitHostEvent, hostEventInstant } from "../_shared/host-events.js";
|
|
24
24
|
import { availabilityBeyond, courseReadWindows, courseSessionsAvailability, courseWindowOpen, slotIdAt } from "../_shared/himi-bookings.js";
|
|
25
25
|
import { wixMediaUrl, WIX_DETAIL_IMAGE, WIX_LIST_IMAGE } from "@himalaya/wix-media";
|
|
@@ -940,11 +940,17 @@ async function nextWindowWithTimes(serviceId: string, from: Date, now: Date, inc
|
|
|
940
940
|
return undefined;
|
|
941
941
|
}
|
|
942
942
|
|
|
943
|
-
/**
|
|
944
|
-
|
|
945
|
-
|
|
943
|
+
/** The answer to a free booking whose order may have been placed although its reply was lost. */
|
|
944
|
+
function freeBookingUncertainMessage(): string {
|
|
945
|
+
return copyParam("time.freeBookingUncertain", "We couldn't check if your booking is confirmed. See My Bookings before you book again.");
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
/** After a booking went through (or its checkout opened, or its order may have, either of which
|
|
949
|
+
* already holds a booking), the time is no longer bookable here: it shows greyed and is no longer
|
|
950
|
+
* selected, so another tap on it cannot send a second booking or charge. */
|
|
946
951
|
function afterBooking(result: S, slotId: string): S {
|
|
947
|
-
const booked = !!result.successMessage || result.message ===
|
|
952
|
+
const booked = !!result.successMessage || result.message === freeBookingUncertainMessage()
|
|
953
|
+
|| result.message === copyParam("time.checkoutOpened", "Complete your payment in the checkout to confirm this booking.");
|
|
948
954
|
if (!booked || !slotId || result.isCourse) return result;
|
|
949
955
|
allRows = allRows.map((row) => row.id === slotId ? { ...row, selectable: false, notSelectable: true } : row);
|
|
950
956
|
slotsById.delete(slotId);
|
|
@@ -1668,7 +1674,7 @@ async function bookSelectedIn(s: S): Promise<S> {
|
|
|
1668
1674
|
: copyParam("time.checkoutFailed", "Checkout could not start. Pick another time or try again.") });
|
|
1669
1675
|
}
|
|
1670
1676
|
}
|
|
1671
|
-
// FREE appointment/class —
|
|
1677
|
+
// FREE appointment/class — bookSlot, then a zero-total order that confirms it (offline-safe below).
|
|
1672
1678
|
// getMyData/signedInEmail carry their own fallbacks (never throw), so the
|
|
1673
1679
|
// booker identity is resolved up front — needed for both the optimistic
|
|
1674
1680
|
// cache row and the offline replay params.
|
|
@@ -1686,12 +1692,29 @@ async function bookSelectedIn(s: S): Promise<S> {
|
|
|
1686
1692
|
});
|
|
1687
1693
|
if (!offlineWritesEnabled) await cachePut(localRow(localId));
|
|
1688
1694
|
const pending = derive({ ...s, bookingInFlight: true, message: "", successMessage: "" });
|
|
1695
|
+
// Set once Wix has the booking: from then on a failure is the order's, never a reason to
|
|
1696
|
+
// queue the booking again.
|
|
1697
|
+
let created: Awaited<ReturnType<typeof bookSlot>> | undefined;
|
|
1698
|
+
// Set once the order is sent: a failure from then on may still have confirmed the booking.
|
|
1699
|
+
let ordering = false;
|
|
1689
1700
|
try {
|
|
1690
|
-
|
|
1691
|
-
// Reconcile the optimistic local id with the server-assigned booking id.
|
|
1701
|
+
created = await bookSlot(slot!, name.first, name.last, email);
|
|
1692
1702
|
const realId = created.booking?.id;
|
|
1693
|
-
if (
|
|
1694
|
-
|
|
1703
|
+
if (!realId) throw new Error("booking not created");
|
|
1704
|
+
// Create Booking leaves a booking CREATED: it holds no place and the business never sees
|
|
1705
|
+
// it. Wix confirms a booking when its eCommerce order is placed, so a free one goes through
|
|
1706
|
+
// the same checkout → order as a paid one; its order totals zero, so nothing is charged.
|
|
1707
|
+
// A site with no payment method refuses even a zero-total order (428
|
|
1708
|
+
// SITE_NOT_ACCEPTING_PAYMENTS), and a visitor or member has no other way to confirm.
|
|
1709
|
+
const checkoutId = (await createCheckout([
|
|
1710
|
+
{ quantity: 1, catalogReference: { appId: WIX_BOOKINGS_APP_ID, catalogItemId: realId } },
|
|
1711
|
+
])).checkout?.id;
|
|
1712
|
+
if (!checkoutId) throw new Error("checkout not created");
|
|
1713
|
+
ordering = true;
|
|
1714
|
+
await createOrder(checkoutId);
|
|
1715
|
+
// Reconcile the optimistic local id with the server-assigned booking id.
|
|
1716
|
+
if (offlineWritesEnabled) await cachePut(localRow(realId));
|
|
1717
|
+
else if (realId !== localId) { await cacheDrop(localId); await cachePut(localRow(realId)); }
|
|
1695
1718
|
await reportBooked(created.booking);
|
|
1696
1719
|
return derive({
|
|
1697
1720
|
...pending,
|
|
@@ -1700,7 +1723,11 @@ async function bookSelectedIn(s: S): Promise<S> {
|
|
|
1700
1723
|
message: "",
|
|
1701
1724
|
});
|
|
1702
1725
|
} catch (e) {
|
|
1703
|
-
|
|
1726
|
+
// Create Booking or the order may have reached Wix although the reply was lost (a gateway
|
|
1727
|
+
// status, a reset). Replaying it could book twice; withdrawing or "failed" could cancel a
|
|
1728
|
+
// real booking or invite a second one. Only a request that never left is queued.
|
|
1729
|
+
const mayHaveLanded = (ordering || !created) && writeMayHaveLanded(e);
|
|
1730
|
+
if (!created && !mayHaveLanded && !offlineWritesEnabled && isBridgeUnavailable(e)) {
|
|
1704
1731
|
// Offline / no bridge: the optimistic cache row already shows in My
|
|
1705
1732
|
// Bookings; queue the booking to replay (WriteQueue, idempotent) when
|
|
1706
1733
|
// connectivity returns.
|
|
@@ -1719,6 +1746,23 @@ async function bookSelectedIn(s: S): Promise<S> {
|
|
|
1719
1746
|
message: "",
|
|
1720
1747
|
});
|
|
1721
1748
|
}
|
|
1749
|
+
if (!offlineWritesEnabled) await cacheDrop(localId);
|
|
1750
|
+
if (mayHaveLanded) {
|
|
1751
|
+
// My Bookings reads the booking's real status from Wix.
|
|
1752
|
+
return derive({ ...s, bookingInFlight: false,
|
|
1753
|
+
message: freeBookingUncertainMessage() });
|
|
1754
|
+
}
|
|
1755
|
+
const booking = created?.booking;
|
|
1756
|
+
if (booking?.id) {
|
|
1757
|
+
// Wix has an unconfirmed booking the business cannot see. Withdraw it, so My Bookings
|
|
1758
|
+
// does not keep a booking that never happened; a failed withdrawal leaves it there,
|
|
1759
|
+
// tagged Not confirmed.
|
|
1760
|
+
if (booking.revision) await cancelBookingAsMember(booking.id, booking.revision, false).catch(() => undefined);
|
|
1761
|
+
if (isPaymentSetupFailure(e)) {
|
|
1762
|
+
return derive({ ...s, bookingInFlight: false,
|
|
1763
|
+
message: copyParam("time.freeBookingUnconfirmed", "The business can't confirm bookings in the app right now. Contact the business to book.") });
|
|
1764
|
+
}
|
|
1765
|
+
}
|
|
1722
1766
|
return derive({ ...s, bookingInFlight: false, message: s.isCourse
|
|
1723
1767
|
? copyParam("time.courseBookFailed", "Course booking failed. Try again.")
|
|
1724
1768
|
: copyParam("time.bookFailed", "Booking failed. Pick another time or try again.") });
|