@wix/himalaya-cli 0.1750.0 → 0.1751.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 +3 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/himi-package.d.ts +478 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/host-compatibility.d.ts +56 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/icon-catalog.generated.d.ts +1 -1
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/schema.d.ts +4 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/site-shell.d.ts +154 -7
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/validator.d.ts +3 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/screens/src/index.d.ts +2 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/screens/src/podcast-service.d.ts +105 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/screens/src/podcast.d.ts +116 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/core.mjs +326 -13
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/screens.mjs +730 -81
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/sdui.mjs +155 -0
- package/dist/browser-plane/assets.json +5 -5
- package/dist/browser-plane/preview-deferred/{b40ea5d0d6251898ff5617139fde8be008dd11e99a70b14c1052093685401700.bin → 21f35a12bd94f4ab97a9a75453c4adcadc438daf024a4b1950d5c356c123bd01.bin} +1 -1
- package/dist/browser-plane/sw.js +7 -7
- package/dist/cli.mjs +34995 -31326
- package/dist/preview-assets.generated.bin +0 -0
- package/guides/component-reference.json +1 -1
- package/guides/component-reference.md +4 -0
- package/guides/designing-himi-screens.md +7 -0
- package/guides/getting-started.md +2 -0
- package/guides/headless-loop.md +1 -1
- package/guides/himi-skill.md +2 -0
- package/guides/index.json +6 -0
- package/guides/qa-builds.md +12 -1
- package/guides/recipe-podcast.md +149 -0
- package/guides/tier-5-add-a-screen.md +16 -2
- package/guides/wix-business-context.md +29 -0
- package/guides/wix-platform-usage.md +7 -2
- package/package.json +10 -10
- package/template-icons/fitness-gym.png +0 -0
- package/templates/beauty-salon/dev/index.ts +1 -1
- package/templates/beauty-salon/l10n/en.json +1 -1
- package/templates/beauty-salon/tier5-src/_shared/program-fields.ts +16 -0
- package/templates/beauty-salon/tier5-src/_shared/programs-section.ts +5 -8
- package/templates/beauty-salon/tier5-src/himi-branded-lite-agenda/index.ts +37 -4
- package/templates/branded-lite/dev/index.ts +101 -1
- package/templates/branded-lite/l10n/en.json +22 -1
- package/templates/branded-lite/l10n/es.json +22 -0
- package/templates/branded-lite/l10n/fr.json +18 -0
- package/templates/branded-lite/l10n/he.json +15 -0
- package/templates/branded-lite/tier5-src/_shared/program-fields.ts +16 -0
- package/templates/branded-lite/tier5-src/_shared/programs-section.ts +5 -8
- package/templates/branded-lite/tier5-src/himi-branded-lite-agenda/index.ts +37 -4
- package/templates/branded-lite/tier5-src/himi-branded-lite-podcasts/index.ts +14 -234
- package/templates/brandy/README.md +33 -0
- package/templates/brandy/config.ts +51 -7
- package/templates/brandy/dev/index.ts +23 -9
- package/templates/community-club/l10n/en.json +1 -1
- package/templates/community-club/tier5-src/_shared/program-fields.ts +16 -0
- package/templates/community-club/tier5-src/_shared/programs-section.ts +5 -8
- package/templates/events-meetups/l10n/en.json +1 -1
- package/templates/events-meetups/tier5-src/_shared/program-fields.ts +16 -0
- package/templates/events-meetups/tier5-src/_shared/programs-section.ts +5 -8
- package/templates/fitness-gym/README.md +53 -0
- package/templates/fitness-gym/config.ts +560 -0
- package/templates/fitness-gym/dev/index.ts +25787 -0
- package/templates/fitness-gym/himalaya.content.json +64 -0
- package/templates/fitness-gym/himalaya.template.json +15 -0
- package/templates/fitness-gym/icon.png +0 -0
- package/templates/fitness-gym/platforms.json +1 -0
- package/templates/fitness-gym/tier5-src/_shared/app-locale.ts +61 -0
- package/templates/fitness-gym/tier5-src/_shared/booking-location.ts +147 -0
- package/templates/fitness-gym/tier5-src/_shared/booking-session.ts +224 -0
- package/templates/fitness-gym/tier5-src/_shared/branded-lite-hosted.ts +280 -0
- package/templates/fitness-gym/tier5-src/_shared/branded-load-state.ts +109 -0
- package/templates/fitness-gym/tier5-src/_shared/business-chat-copy.ts +40 -0
- package/templates/fitness-gym/tier5-src/_shared/business-chat-history.ts +51 -0
- package/templates/fitness-gym/tier5-src/_shared/business-chat-message-model.ts +177 -0
- package/templates/fitness-gym/tier5-src/_shared/business-chat-model.ts +56 -0
- package/templates/fitness-gym/tier5-src/_shared/business-chat-presenter.ts +576 -0
- package/templates/fitness-gym/tier5-src/_shared/business-chat-transport.ts +148 -0
- package/templates/fitness-gym/tier5-src/_shared/collection-contract.ts +228 -0
- package/templates/fitness-gym/tier5-src/_shared/collection-query.ts +193 -0
- package/templates/fitness-gym/tier5-src/_shared/collection-service.ts +400 -0
- package/templates/fitness-gym/tier5-src/_shared/detail-presence.ts +51 -0
- package/templates/fitness-gym/tier5-src/_shared/engine-intl.ts +523 -0
- package/templates/fitness-gym/tier5-src/_shared/himi-account.ts +194 -0
- package/templates/fitness-gym/tier5-src/_shared/himi-booking-saved.ts +88 -0
- package/templates/fitness-gym/tier5-src/_shared/himi-bookings.ts +318 -0
- package/templates/fitness-gym/tier5-src/_shared/himi-copy.ts +116 -0
- package/templates/fitness-gym/tier5-src/_shared/himi-media.ts +29 -0
- package/templates/fitness-gym/tier5-src/_shared/himi-store.ts +7 -0
- package/templates/fitness-gym/tier5-src/_shared/himi-text.ts +24 -0
- package/templates/fitness-gym/tier5-src/_shared/host-events.ts +66 -0
- package/templates/fitness-gym/tier5-src/_shared/hosted-checkout.ts +70 -0
- package/templates/fitness-gym/tier5-src/_shared/iap-attendance-form.ts +106 -0
- package/templates/fitness-gym/tier5-src/_shared/iap-attendance-purchase.ts +216 -0
- package/templates/fitness-gym/tier5-src/_shared/iap-attendance.ts +38 -0
- package/templates/fitness-gym/tier5-src/_shared/iap-worker.ts +127 -0
- package/templates/fitness-gym/tier5-src/_shared/inbox-rooms.ts +68 -0
- package/templates/fitness-gym/tier5-src/_shared/local-preferences.ts +38 -0
- package/templates/fitness-gym/tier5-src/_shared/member-access.ts +63 -0
- package/templates/fitness-gym/tier5-src/_shared/member-account-routes.ts +52 -0
- package/templates/fitness-gym/tier5-src/_shared/member-bookings.ts +107 -0
- package/templates/fitness-gym/tier5-src/_shared/member-screen.ts +99 -0
- package/templates/fitness-gym/tier5-src/_shared/notification-target.ts +141 -0
- package/templates/fitness-gym/tier5-src/_shared/offset-page.ts +10 -0
- package/templates/fitness-gym/tier5-src/_shared/online-actions.ts +76 -0
- package/templates/fitness-gym/tier5-src/_shared/owner-load-error.ts +348 -0
- package/templates/fitness-gym/tier5-src/_shared/payment-setup.ts +6 -0
- package/templates/fitness-gym/tier5-src/_shared/pricing-plan-display.ts +64 -0
- package/templates/fitness-gym/tier5-src/_shared/program-description.ts +11 -0
- package/templates/fitness-gym/tier5-src/_shared/program-fields.ts +16 -0
- package/templates/fitness-gym/tier5-src/_shared/program-standing.ts +46 -0
- package/templates/fitness-gym/tier5-src/_shared/rich-body.ts +78 -0
- package/templates/fitness-gym/tier5-src/_shared/rich-content-link.ts +34 -0
- package/templates/fitness-gym/tier5-src/_shared/sign-in-sheet.ts +18 -0
- package/templates/fitness-gym/tier5-src/_shared/staff-name.ts +18 -0
- package/templates/fitness-gym/tier5-src/_shared/weekly-goal.ts +107 -0
- package/templates/fitness-gym/tier5-src/_shared/wix-bi.ts +85 -0
- package/templates/fitness-gym/tier5-src/_shared/wix-member-links.ts +114 -0
- package/templates/fitness-gym/tier5-src/_shared/wix-service-price.ts +146 -0
- package/templates/fitness-gym/tier5-src/business-chat/index.ts +732 -0
- package/templates/fitness-gym/tier5-src/business-contact/index.ts +6 -0
- package/templates/fitness-gym/tier5-src/himi-booking-account/index.ts +267 -0
- package/templates/fitness-gym/tier5-src/himi-booking-bookings/index.ts +468 -0
- package/templates/fitness-gym/tier5-src/himi-booking-service/index.ts +1190 -0
- package/templates/fitness-gym/tier5-src/himi-booking-services/index.ts +791 -0
- package/templates/fitness-gym/tier5-src/himi-booking-time/index.ts +1729 -0
- package/templates/fitness-gym/tier5-src/himi-branded-lite-agenda/index.ts +988 -0
- package/templates/fitness-gym/tier5-src/himi-branded-lite-member-programs/index.ts +656 -0
- package/templates/fitness-gym/tier5-src/himi-branded-lite-notifications/index.ts +256 -0
- package/templates/fitness-gym/tier5-src/himi-branded-lite-plans/index.ts +495 -0
- package/templates/fitness-gym/tier5-src/himi-branded-lite-program/facts.ts +52 -0
- package/templates/fitness-gym/tier5-src/himi-branded-lite-program/index.ts +845 -0
- package/templates/fitness-gym/tier5-src/himi-fitcoach-goal/index.ts +191 -0
- package/templates/fitness-gym/tier5-src/himi-fitcoach-home/index.ts +619 -0
- package/templates/fitness-gym/tier5-src/himi-store-account/index.ts +1007 -0
- package/templates/fitness-gym/tier5-src/wix-spaces-my-subscriptions/index.ts +84 -0
- package/templates/fitness-gym/tier5-src/wix-spaces-subscription-detail/index.ts +139 -0
- package/templates/fitness-gym/tokens.json +414 -0
- package/templates/gym-fitness/dev/index.ts +1 -1
- package/templates/gym-fitness/l10n/en.json +1 -1
- package/templates/gym-fitness/tier5-src/_shared/program-fields.ts +16 -0
- package/templates/gym-fitness/tier5-src/_shared/programs-section.ts +5 -8
- package/templates/gym-fitness/tier5-src/himi-branded-lite-agenda/index.ts +37 -4
- package/templates/medical-services/dev/index.ts +2 -1
- package/templates/medical-services/tier5-src/himi-booking-account/index.ts +16 -1
- package/templates/nonprofit-cause/l10n/en.json +1 -1
- package/templates/nonprofit-cause/tier5-src/_shared/program-fields.ts +16 -0
- package/templates/nonprofit-cause/tier5-src/_shared/programs-section.ts +5 -8
- package/templates/personal-fitness-trainer/dev/index.ts +2 -2
- package/templates/personal-fitness-trainer/tier5-src/himi-branded-lite-agenda/index.ts +37 -4
- package/templates/podcast-creator/dev/index.ts +100 -0
- package/templates/podcast-creator/l10n/en.json +22 -1
- package/templates/podcast-creator/l10n/es.json +22 -0
- package/templates/podcast-creator/l10n/fr.json +18 -0
- package/templates/podcast-creator/l10n/he.json +15 -0
- package/templates/podcast-creator/tier5-src/_shared/program-fields.ts +16 -0
- package/templates/podcast-creator/tier5-src/_shared/programs-section.ts +5 -8
- package/templates/podcast-creator/tier5-src/himi-branded-lite-podcasts/index.ts +14 -234
- package/templates/portfolio-creative/l10n/en.json +1 -1
- package/templates/portfolio-creative/tier5-src/_shared/program-fields.ts +16 -0
- package/templates/portfolio-creative/tier5-src/_shared/programs-section.ts +5 -8
- package/templates/restaurant/l10n/en.json +1 -1
- package/templates/restaurant/tier5-src/_shared/program-fields.ts +16 -0
- package/templates/restaurant/tier5-src/_shared/programs-section.ts +5 -8
- package/templates/retail-store/l10n/en.json +1 -1
- package/templates/retail-store/tier5-src/_shared/program-fields.ts +16 -0
- package/templates/retail-store/tier5-src/_shared/programs-section.ts +5 -8
- package/templates/salon-spa/dev/index.ts +1 -1
- package/templates/salon-spa/tier5-src/himi-booking-account/index.ts +16 -1
- package/templates/salon-spa/tier5-src/himi-branded-lite-agenda/index.ts +37 -4
- package/templates/yoga-studio/dev/index.ts +1 -1
- package/templates/yoga-studio/l10n/en.json +1 -1
- package/templates/yoga-studio/tier5-src/_shared/program-fields.ts +16 -0
- package/templates/yoga-studio/tier5-src/_shared/programs-section.ts +5 -8
- package/templates/yoga-studio/tier5-src/himi-branded-lite-agenda/index.ts +37 -4
|
@@ -478,8 +478,8 @@ function deeperThan(nodes, depth, max) {
|
|
|
478
478
|
var isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
479
479
|
function ricosToPlainText(doc) {
|
|
480
480
|
const kids = (v) => Array.isArray(v) ? v.filter(isObj) : [];
|
|
481
|
-
const inline = (
|
|
482
|
-
const blocks = (nodes) => nodes.flatMap((
|
|
481
|
+
const inline = (node4) => typeof node4.textData?.text === "string" ? node4.textData.text : kids(node4.nodes).map(inline).join("");
|
|
482
|
+
const blocks = (nodes) => nodes.flatMap((node4) => node4.type === "PARAGRAPH" || node4.type === "HEADING" || node4.type === "TEXT" ? [inline(node4)] : blocks(kids(node4.nodes)));
|
|
483
483
|
return blocks(kids(doc?.nodes)).join("\n\n");
|
|
484
484
|
}
|
|
485
485
|
function plainTextToRicos(text2) {
|
|
@@ -554,29 +554,29 @@ function cleanNodes(nodes, base, depth, ctx, parentType) {
|
|
|
554
554
|
if (!isObj(raw)) continue;
|
|
555
555
|
if (depth > RICH_CONTENT_LIMITS.maxDepth) throw TOO_DEEP;
|
|
556
556
|
const path = base === "" ? String(out.length) : `${base}.${out.length}`;
|
|
557
|
-
const
|
|
558
|
-
if (
|
|
557
|
+
const node4 = cleanNode({ ...raw }, path, depth, ctx, parentType);
|
|
558
|
+
if (node4) out.push(node4);
|
|
559
559
|
}
|
|
560
560
|
return out;
|
|
561
561
|
}
|
|
562
|
-
function cleanNode(
|
|
563
|
-
if (
|
|
564
|
-
const decorations =
|
|
562
|
+
function cleanNode(node4, path, depth, ctx, parentType) {
|
|
563
|
+
if (node4.type === "TEXT") {
|
|
564
|
+
const decorations = node4.textData?.decorations;
|
|
565
565
|
if (Array.isArray(decorations)) {
|
|
566
566
|
const kept = decorations.flatMap((d) => {
|
|
567
567
|
if (!(isObj(d) && d.type === "LINK")) return [d];
|
|
568
568
|
const next = rewriteAt(d, LINK_DECORATION_URL, cleanLink);
|
|
569
569
|
return getAt(next, LINK_DECORATION_URL) === void 0 ? [] : [next];
|
|
570
570
|
});
|
|
571
|
-
|
|
571
|
+
node4.textData = { ...node4.textData, decorations: kept };
|
|
572
572
|
}
|
|
573
|
-
} else if (
|
|
574
|
-
const data = isObj(
|
|
573
|
+
} else if (node4.type === "IMAGE") {
|
|
574
|
+
const data = isObj(node4.imageData) ? node4.imageData : {};
|
|
575
575
|
const url = ricosImageUrl(data, ctx.imageWidth);
|
|
576
576
|
if (!url) return null;
|
|
577
|
-
|
|
578
|
-
} else if (
|
|
579
|
-
const data = isObj(
|
|
577
|
+
node4.imageData = { ...data, image: { ...isObj(data.image) ? data.image : {}, src: { url } } };
|
|
578
|
+
} else if (node4.type === "GALLERY") {
|
|
579
|
+
const data = isObj(node4.galleryData) ? node4.galleryData : {};
|
|
580
580
|
const items = (Array.isArray(data.items) ? data.items : []).flatMap((item) => {
|
|
581
581
|
if (!isObj(item) || !isObj(item.image)) return [];
|
|
582
582
|
const media = isObj(item.image.media) ? item.image.media : {};
|
|
@@ -584,9 +584,9 @@ function cleanNode(node3, path, depth, ctx, parentType) {
|
|
|
584
584
|
return url ? [{ ...item, image: { ...item.image, media: { ...media, src: { url } } } }] : [];
|
|
585
585
|
});
|
|
586
586
|
if (items.length === 0) return null;
|
|
587
|
-
|
|
588
|
-
} else if (
|
|
589
|
-
const data = isObj(
|
|
587
|
+
node4.galleryData = { ...data, items };
|
|
588
|
+
} else if (node4.type === "VIDEO") {
|
|
589
|
+
const data = isObj(node4.videoData) ? { ...node4.videoData } : {};
|
|
590
590
|
const video = isObj(data.video) ? data.video : {};
|
|
591
591
|
const url = ricosVideoUrl(video.src);
|
|
592
592
|
if (!url) return null;
|
|
@@ -594,32 +594,32 @@ function cleanNode(node3, path, depth, ctx, parentType) {
|
|
|
594
594
|
const poster = ricosImageUrl({ image: data.thumbnail }, ctx.tileWidth);
|
|
595
595
|
if (poster) data.thumbnail = { ...data.thumbnail, src: { url: poster } };
|
|
596
596
|
else delete data.thumbnail;
|
|
597
|
-
|
|
598
|
-
} else if (
|
|
599
|
-
|
|
600
|
-
if (getAt(
|
|
601
|
-
} else if (
|
|
602
|
-
|
|
603
|
-
} else if (
|
|
604
|
-
|
|
605
|
-
}
|
|
606
|
-
for (const [field, ...rest] of (typeof
|
|
607
|
-
if (field in
|
|
597
|
+
node4.videoData = data;
|
|
598
|
+
} else if (node4.type === "BUTTON" || node4.type === "LINK_BUTTON") {
|
|
599
|
+
node4.buttonData = rewriteAt(node4.buttonData, BUTTON_URL, cleanLink);
|
|
600
|
+
if (getAt(node4.buttonData, BUTTON_URL) === void 0) return null;
|
|
601
|
+
} else if (node4.type === "HTML") {
|
|
602
|
+
node4.htmlData = rewriteAt(node4.htmlData, ["html"], drop);
|
|
603
|
+
} else if (node4.type === "EMBED") {
|
|
604
|
+
node4.embedData = rewriteAt(node4.embedData, ["oembed", "html"], drop);
|
|
605
|
+
}
|
|
606
|
+
for (const [field, ...rest] of (typeof node4.type === "string" ? LINK_FIELDS[node4.type] : void 0) ?? []) {
|
|
607
|
+
if (field in node4) node4[field] = rewriteAt(node4[field], rest, cleanLink);
|
|
608
608
|
}
|
|
609
609
|
const inBlocks = holdsBlocks(parentType);
|
|
610
|
-
if (
|
|
611
|
-
const own = typeof
|
|
610
|
+
if (node4.type !== "TEXT" || inBlocks) {
|
|
611
|
+
const own = typeof node4.id === "string" ? node4.id : "";
|
|
612
612
|
const usable = own !== "" && !unusableId(own);
|
|
613
|
-
if (inBlocks && !isWrapper(
|
|
613
|
+
if (inBlocks && !isWrapper(node4.type)) {
|
|
614
614
|
if (usable && !ctx.ids.has(own)) ctx.ids.add(own);
|
|
615
|
-
else
|
|
616
|
-
} else if (!usable)
|
|
615
|
+
else node4.id = path;
|
|
616
|
+
} else if (!usable) node4.id = path;
|
|
617
617
|
}
|
|
618
|
-
if (Array.isArray(
|
|
619
|
-
return
|
|
618
|
+
if (Array.isArray(node4.nodes)) node4.nodes = cleanNodes(node4.nodes, path, depth + 1, ctx, typeof node4.type === "string" ? node4.type : "");
|
|
619
|
+
return node4;
|
|
620
620
|
}
|
|
621
621
|
function countNodes(nodes) {
|
|
622
|
-
return nodes.reduce((n,
|
|
622
|
+
return nodes.reduce((n, node4) => isObj(node4) ? n + 1 + (Array.isArray(node4.nodes) ? countNodes(node4.nodes) : 0) : n, 0);
|
|
623
623
|
}
|
|
624
624
|
function canonicalJson(v, depth, max) {
|
|
625
625
|
if (depth > max) throw TOO_DEEP;
|
|
@@ -674,18 +674,18 @@ function normalizeWebsiteLinks(nodes) {
|
|
|
674
674
|
GIF: [["gifData", "original", "gif"]],
|
|
675
675
|
IMAGE: [["imageData", "link", "url"]]
|
|
676
676
|
};
|
|
677
|
-
for (const
|
|
678
|
-
for (const path of linkFields[
|
|
679
|
-
const parent = object(path.slice(0, -1).reduce((value, key2) => object(value)[key2],
|
|
677
|
+
for (const node4 of nodes) {
|
|
678
|
+
for (const path of linkFields[node4.type ?? ""] ?? []) {
|
|
679
|
+
const parent = object(path.slice(0, -1).reduce((value, key2) => object(value)[key2], node4));
|
|
680
680
|
const key = path[path.length - 1];
|
|
681
681
|
const holder = { url: parent[key] };
|
|
682
682
|
normalize(holder);
|
|
683
683
|
if (typeof holder.url === "string") parent[key] = holder.url;
|
|
684
684
|
}
|
|
685
|
-
if (Array.isArray(
|
|
685
|
+
if (Array.isArray(node4.textData?.decorations)) for (const decoration of node4.textData.decorations) {
|
|
686
686
|
if (object(decoration).type === "LINK") normalize(object(object(decoration).linkData).link);
|
|
687
687
|
}
|
|
688
|
-
if (Array.isArray(
|
|
688
|
+
if (Array.isArray(node4.nodes)) changed += normalizeWebsiteLinks(node4.nodes);
|
|
689
689
|
}
|
|
690
690
|
return changed;
|
|
691
691
|
}
|
|
@@ -1118,14 +1118,14 @@ function authFailure(raw, operation = "signIn", translate) {
|
|
|
1118
1118
|
const value = raw && typeof raw === "object" ? raw : {};
|
|
1119
1119
|
const payload = value.payload && typeof value.payload === "object" ? value.payload : value;
|
|
1120
1120
|
const named = payload.code ?? value.code ?? value.kind;
|
|
1121
|
-
const
|
|
1121
|
+
const status2 = value.statusCode ?? value.status;
|
|
1122
1122
|
const application = String(payload.details?.applicationError?.code ?? value.details?.applicationError?.code ?? payload.applicationCode ?? value.applicationCode ?? named ?? "");
|
|
1123
1123
|
let code = codes.has(named) ? named : aliases[named] ?? "unknown";
|
|
1124
1124
|
if (operation === "signIn" && iamCredentialCodes.has(application)) code = "invalid_credentials";
|
|
1125
|
-
else if (
|
|
1126
|
-
else if ([404, 405, 501].includes(
|
|
1127
|
-
else if ([401, 403].includes(
|
|
1128
|
-
else if (
|
|
1125
|
+
else if (status2 === 429) code = "rate_limited";
|
|
1126
|
+
else if ([404, 405, 501].includes(status2)) code = "unavailable";
|
|
1127
|
+
else if ([401, 403].includes(status2) && operation === "signIn") code = "invalid_credentials";
|
|
1128
|
+
else if (status2 === 0 || status2 >= 500 || value.name === "TypeError" || value.name === "TimeoutError") code = "network";
|
|
1129
1129
|
if (operation === "verify" && code === "invalid_credentials") code = "invalid_code";
|
|
1130
1130
|
if (operation === "register" && code === "invalid_credentials") code = "registration_failed";
|
|
1131
1131
|
return { code, reason: authMessage(failureKeys[code], translate) };
|
|
@@ -1159,9 +1159,9 @@ function emailOf(raw) {
|
|
|
1159
1159
|
return typeof email === "string" ? email : "";
|
|
1160
1160
|
}
|
|
1161
1161
|
function reportedOk(raw) {
|
|
1162
|
-
const
|
|
1163
|
-
if (typeof
|
|
1164
|
-
return
|
|
1162
|
+
const status2 = raw?.status;
|
|
1163
|
+
if (typeof status2 !== "string") return true;
|
|
1164
|
+
return status2 === "ok" || status2 === "success";
|
|
1165
1165
|
}
|
|
1166
1166
|
async function authState(opts) {
|
|
1167
1167
|
try {
|
|
@@ -1523,6 +1523,644 @@ function createInviteService(opts) {
|
|
|
1523
1523
|
return svc;
|
|
1524
1524
|
}
|
|
1525
1525
|
|
|
1526
|
+
// ../../stdlib/flows/screens/src/podcast.ts
|
|
1527
|
+
var PODCAST_FEED_ENDPOINT = "https://podcasts.wix.com/api/feed/graphql";
|
|
1528
|
+
var PODCAST_EPISODES_QUERY = `
|
|
1529
|
+
query PodcastEpisodes($url: String!, $limit: Int) {
|
|
1530
|
+
episodes(url: $url, limit: $limit) {
|
|
1531
|
+
id title date duration image descriptionExcerpt(length: 220) playback { url type length }
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
`;
|
|
1535
|
+
var MAX_URL_LENGTH = 2048;
|
|
1536
|
+
var CONTROL = /[\u0000- \u007f]/;
|
|
1537
|
+
function publicHttpHost(raw) {
|
|
1538
|
+
if (!raw || raw.length > MAX_URL_LENGTH || CONTROL.test(raw)) return "";
|
|
1539
|
+
const match = /^https?:\/\/([^/?#]*)/i.exec(raw);
|
|
1540
|
+
const authority = match?.[1] ?? "";
|
|
1541
|
+
if (!authority || authority.includes("@")) return "";
|
|
1542
|
+
const parts = /^([a-z0-9.-]+)(?::([0-9]+))?$/i.exec(authority);
|
|
1543
|
+
if (!parts || parts[2] && (Number(parts[2]) < 1 || Number(parts[2]) > 65535)) return "";
|
|
1544
|
+
const host = parts[1].toLowerCase();
|
|
1545
|
+
if (host.split(".").some((label) => !/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/.test(label))) return "";
|
|
1546
|
+
if (/\d$/.test(host)) {
|
|
1547
|
+
const octets = host.split(".");
|
|
1548
|
+
if (octets.length !== 4 || octets.some((part) => !/^(?:0|[1-9][0-9]{0,2})$/.test(part) || Number(part) > 255)) return "";
|
|
1549
|
+
}
|
|
1550
|
+
return host;
|
|
1551
|
+
}
|
|
1552
|
+
function isPrivateHost(host) {
|
|
1553
|
+
if (host.startsWith("[")) return true;
|
|
1554
|
+
if (host === "localhost" || /\.(?:localhost|local|internal|lan|home|arpa)$/.test(host) || !host.includes(".")) return true;
|
|
1555
|
+
const ip = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec(host);
|
|
1556
|
+
if (!ip) return false;
|
|
1557
|
+
const [a, b] = [Number(ip[1]), Number(ip[2])];
|
|
1558
|
+
return a === 0 || a === 10 || a === 127 || a === 100 && b >= 64 && b <= 127 || a === 169 && b === 254 || a === 172 && b >= 16 && b <= 31 || a === 192 && b === 168 || a >= 224;
|
|
1559
|
+
}
|
|
1560
|
+
function podcastFeedUrl(raw) {
|
|
1561
|
+
const url = typeof raw === "string" ? raw.trim() : "";
|
|
1562
|
+
if (!url) return { ok: false, code: "feed_not_configured" };
|
|
1563
|
+
const host = publicHttpHost(url);
|
|
1564
|
+
return host && !isPrivateHost(host) ? { ok: true, url } : { ok: false, code: "invalid_feed_url" };
|
|
1565
|
+
}
|
|
1566
|
+
function podcastAudioUrl(raw) {
|
|
1567
|
+
const url = typeof raw === "string" ? raw.trim() : "";
|
|
1568
|
+
const host = publicHttpHost(url);
|
|
1569
|
+
return /^https:\/\//i.test(url) && host && !isPrivateHost(host) ? url : "";
|
|
1570
|
+
}
|
|
1571
|
+
function podcastFeedRequest(feedUrl, limit = 40) {
|
|
1572
|
+
return { query: PODCAST_EPISODES_QUERY, variables: { url: feedUrl, limit: Math.max(1, Math.min(100, Math.trunc(limit) || 40)) } };
|
|
1573
|
+
}
|
|
1574
|
+
function podcastDurationMs(value) {
|
|
1575
|
+
const raw = typeof value === "string" ? value.trim() : typeof value === "number" ? String(value) : "";
|
|
1576
|
+
if (/^\d+$/.test(raw)) return Number(raw) * 1e3;
|
|
1577
|
+
const pieces = raw.split(":");
|
|
1578
|
+
if (pieces.length < 2 || pieces.length > 3 || !pieces.every((p) => /^\d+$/.test(p))) return 0;
|
|
1579
|
+
return pieces.map(Number).reduce((total, piece) => total * 60 + piece, 0) * 1e3;
|
|
1580
|
+
}
|
|
1581
|
+
var plain = (value) => typeof value === "string" ? value.replace(/<[^>]*>/g, " ").replace(/ /g, " ").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'").replace(/\s+/g, " ").trim() : "";
|
|
1582
|
+
function mapPodcastFeed(response, describe = plain) {
|
|
1583
|
+
if (!response || typeof response !== "object") return { ok: false, code: "feed_malformed" };
|
|
1584
|
+
const body = response;
|
|
1585
|
+
if (Array.isArray(body.errors) && body.errors.length) return { ok: false, code: "feed_unavailable" };
|
|
1586
|
+
const raw = body.data?.episodes ?? body.episodes;
|
|
1587
|
+
if (!Array.isArray(raw)) return { ok: false, code: "feed_malformed" };
|
|
1588
|
+
const episodes = [];
|
|
1589
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1590
|
+
let unplayable = 0;
|
|
1591
|
+
for (const item of raw) {
|
|
1592
|
+
const audioUrl = podcastAudioUrl(item?.playback?.url);
|
|
1593
|
+
if (!audioUrl) {
|
|
1594
|
+
unplayable++;
|
|
1595
|
+
continue;
|
|
1596
|
+
}
|
|
1597
|
+
const id2 = (typeof item.id === "string" && item.id.trim() ? item.id.trim() : audioUrl).slice(0, 512);
|
|
1598
|
+
if (seen.has(id2)) continue;
|
|
1599
|
+
seen.add(id2);
|
|
1600
|
+
episodes.push({
|
|
1601
|
+
id: id2,
|
|
1602
|
+
title: plain(item.title) || "Episode",
|
|
1603
|
+
date: typeof item.date === "string" ? item.date : "",
|
|
1604
|
+
durationMs: podcastDurationMs(item.duration),
|
|
1605
|
+
image: podcastAudioUrl(item.image),
|
|
1606
|
+
description: describe(item.descriptionExcerpt),
|
|
1607
|
+
audioUrl,
|
|
1608
|
+
mimeType: typeof item.playback?.type === "string" ? item.playback.type : ""
|
|
1609
|
+
});
|
|
1610
|
+
}
|
|
1611
|
+
return { ok: true, episodes, unplayable };
|
|
1612
|
+
}
|
|
1613
|
+
var node2 = (id2, type, props, modifiers) => ({ id: id2, body: { package: "himalaya", type, props }, ...modifiers ? { modifiers } : {} });
|
|
1614
|
+
var PODCAST_SCREEN_CAPABILITIES = ["wix_api", "media_playback"];
|
|
1615
|
+
function podcastFeedSetting(raw) {
|
|
1616
|
+
const configured = podcastFeedUrl(raw);
|
|
1617
|
+
if (!configured.ok && configured.code === "invalid_feed_url") {
|
|
1618
|
+
throw Object.assign(new Error("Podcasts requires a public feed URL without credentials."), { code: configured.code });
|
|
1619
|
+
}
|
|
1620
|
+
return configured.ok ? configured.url : "";
|
|
1621
|
+
}
|
|
1622
|
+
function podcastScreen(opts) {
|
|
1623
|
+
const feedUrl = podcastFeedSetting(opts.feedUrl);
|
|
1624
|
+
const s2 = opts.service ?? "podcast";
|
|
1625
|
+
const id2 = opts.screenId ?? "podcasts";
|
|
1626
|
+
const c = {
|
|
1627
|
+
title: "Episodes",
|
|
1628
|
+
queue: "Add to queue",
|
|
1629
|
+
retry: "Try again",
|
|
1630
|
+
previous: "Previous episode",
|
|
1631
|
+
next: "Next episode",
|
|
1632
|
+
back: "Back 15 seconds",
|
|
1633
|
+
forward: "Forward 30 seconds",
|
|
1634
|
+
seek: "Playback position",
|
|
1635
|
+
...opts.copy
|
|
1636
|
+
};
|
|
1637
|
+
const bind = (field) => `$service:${s2}.${field}`;
|
|
1638
|
+
const act = (action2, params) => ({ actionId: `tier5.${s2}.${action2}`, ...params ? { params } : {} });
|
|
1639
|
+
const text2 = (key, value, style, extra = {}) => node2(`${id2}.${key}`, "Text", { text: value, style, collapseWhenEmpty: true, ...extra });
|
|
1640
|
+
const hiddenWhen = (n, field) => ({ ...n, modifiers: { ...n.modifiers ?? {}, hiddenPath: bind(field) } });
|
|
1641
|
+
const iconButton = (key, icon, label, action2) => node2(`${id2}.${key}`, "Button", { title: label, leadingIcon: icon, iconOnly: true, style: "plain", action: action2 });
|
|
1642
|
+
const row = node2(`${id2}.episode`, "ListItem", {
|
|
1643
|
+
title: "$item.title",
|
|
1644
|
+
subtitle: "$item.subtitle",
|
|
1645
|
+
overline: "$item.progressLabel",
|
|
1646
|
+
leading: node2(`${id2}.episode_art`, "Image", { url: "$item.image", initials: "P", width: 56, height: 56, contentMode: "fill", shape: "rounded", contentDescription: "$item.title" }),
|
|
1647
|
+
trailing: iconButton("episode_queue", "list", c.queue, act("queueEpisode", { id: "$item.id" })),
|
|
1648
|
+
onTap: act("playEpisode", { id: "$item.id" })
|
|
1649
|
+
}, { accessibilityLabel: "$item.title" });
|
|
1650
|
+
const list = node2(`${id2}.episodes`, "LazyList", { itemsPath: bind("episodes"), items: [row], spacing: 0 });
|
|
1651
|
+
const feedStatus = node2(`${id2}.feed_status`, "VStack", { spacing: 8, alignment: "leading", children: [
|
|
1652
|
+
text2("feed_message", bind("emptyText"), "body", { color: "textSecondary" }),
|
|
1653
|
+
hiddenWhen(node2(`${id2}.feed_retry`, "Button", { title: c.retry, style: "secondary", action: act("retryFeed") }), "hideFeedRetry")
|
|
1654
|
+
] });
|
|
1655
|
+
const payload = node2(`${id2}.root`, "VStack", { spacing: 16, alignment: "leading", children: [
|
|
1656
|
+
text2("title", c.title, "title1"),
|
|
1657
|
+
list,
|
|
1658
|
+
feedStatus
|
|
1659
|
+
] }, { padding: { leading: 16, trailing: 16, top: 16, bottom: 24 }, onAppear: act("load", { feedUrl }) });
|
|
1660
|
+
const player = hiddenWhen(node2(`${id2}.player`, "VStack", { spacing: 8, alignment: "leading", children: [
|
|
1661
|
+
text2("now_title", bind("nowTitle"), "body", { maxLines: 1 }),
|
|
1662
|
+
text2("now_subtitle", bind("nowSubtitle"), "caption", { color: "textSecondary", maxLines: 1 }),
|
|
1663
|
+
node2(
|
|
1664
|
+
`${id2}.scrubber`,
|
|
1665
|
+
"Slider",
|
|
1666
|
+
{ value: 0, min: 0, max: 1, step: 1e-3, valuePath: bind("progress"), debounceMs: 250, onChange: act("seek") },
|
|
1667
|
+
{ accessibilityLabel: c.seek, accessibilityValue: bind("progressLabel") }
|
|
1668
|
+
),
|
|
1669
|
+
text2("progress", bind("progressLabel"), "caption", { color: "textSecondary" }),
|
|
1670
|
+
node2(`${id2}.controls`, "HStack", { spacing: 8, children: [
|
|
1671
|
+
iconButton("previous", "skip_previous", c.previous, act("previousEpisode")),
|
|
1672
|
+
iconButton("back", "undo", c.back, act("seekBy", { deltaMs: "-15000" })),
|
|
1673
|
+
node2(`${id2}.toggle`, "Button", { title: bind("playLabel"), leadingIcon: bind("playIcon"), style: "primary", action: act("togglePlay") }),
|
|
1674
|
+
iconButton("forward", "refresh", c.forward, act("seekBy", { deltaMs: "30000" })),
|
|
1675
|
+
iconButton("next", "skip_next", c.next, act("nextEpisode"))
|
|
1676
|
+
] }),
|
|
1677
|
+
hiddenWhen(node2(`${id2}.playback_error`, "VStack", { spacing: 6, alignment: "leading", children: [
|
|
1678
|
+
text2("playback_error_text", bind("playbackErrorText"), "caption", { color: "danger" }),
|
|
1679
|
+
hiddenWhen(node2(`${id2}.playback_retry`, "Button", { title: c.retry, style: "secondary", action: act("retryPlayback") }), "hidePlaybackRetry")
|
|
1680
|
+
] }), "hidePlaybackError")
|
|
1681
|
+
] }, { background: { token: "surfaceSecondary" }, padding: { leading: 16, trailing: 16, top: 10, bottom: 12 } }), "hidePlayer");
|
|
1682
|
+
return {
|
|
1683
|
+
screenId: id2,
|
|
1684
|
+
renderer: "sdui_intent",
|
|
1685
|
+
title: c.title,
|
|
1686
|
+
schemaVersion: 1,
|
|
1687
|
+
cacheControl: { maxAge: 0, staleWhileRevalidate: 0 },
|
|
1688
|
+
logicBundle: { url: opts.bundleUrl, integrity: "", declaredCapabilities: [...PODCAST_SCREEN_CAPABILITIES] },
|
|
1689
|
+
payload,
|
|
1690
|
+
stickyFooter: player
|
|
1691
|
+
};
|
|
1692
|
+
}
|
|
1693
|
+
|
|
1694
|
+
// ../../core/sdk/media-playback/src/index.ts
|
|
1695
|
+
function encodeItem(item) {
|
|
1696
|
+
if (!item?.id || !item?.url) throw new Error("media-playback: queue item id and url are required");
|
|
1697
|
+
return JSON.stringify(item);
|
|
1698
|
+
}
|
|
1699
|
+
function decodeStatus(raw) {
|
|
1700
|
+
return {
|
|
1701
|
+
state: raw?.state ?? "idle",
|
|
1702
|
+
currentItem: raw?.currentItem ?? null,
|
|
1703
|
+
currentIndex: typeof raw?.currentIndex === "number" ? raw.currentIndex : -1,
|
|
1704
|
+
positionMs: typeof raw?.positionMs === "number" ? raw.positionMs : 0,
|
|
1705
|
+
durationMs: typeof raw?.durationMs === "number" ? raw.durationMs : 0,
|
|
1706
|
+
rate: typeof raw?.rate === "number" ? raw.rate : 1,
|
|
1707
|
+
bufferedMs: typeof raw?.bufferedMs === "number" ? raw.bufferedMs : 0,
|
|
1708
|
+
queue: Array.isArray(raw?.queue) ? raw.queue : [],
|
|
1709
|
+
error: raw?.error,
|
|
1710
|
+
...typeof raw?.resumedFromMs === "number" ? { resumedFromMs: raw.resumedFromMs } : {}
|
|
1711
|
+
};
|
|
1712
|
+
}
|
|
1713
|
+
function isSessionRef(value) {
|
|
1714
|
+
return Boolean(value && typeof value === "object" && typeof value.sessionId === "string");
|
|
1715
|
+
}
|
|
1716
|
+
async function setQueue(items, options = {}) {
|
|
1717
|
+
if (!Array.isArray(items)) throw new Error("media-playback.setQueue: items must be an array");
|
|
1718
|
+
const persist = options.persistPosition === true;
|
|
1719
|
+
const r = await dispatch("capability.media_playback.setQueue", {
|
|
1720
|
+
items: JSON.stringify(items),
|
|
1721
|
+
startIndex: String(options.startIndex ?? 0),
|
|
1722
|
+
// With persistPosition, an ABSENT start position is how the host knows to resume from
|
|
1723
|
+
// the saved one — so it is only omitted then. Every other caller sends what it always did.
|
|
1724
|
+
...persist && options.startPositionMs === void 0 ? {} : { startPositionMs: String(options.startPositionMs ?? 0) },
|
|
1725
|
+
autoplay: String(options.autoplay === true),
|
|
1726
|
+
...options.onStatus ? { onStatus: options.onStatus } : {},
|
|
1727
|
+
...encodeSessionOptions(options)
|
|
1728
|
+
});
|
|
1729
|
+
return decodeStatus(r);
|
|
1730
|
+
}
|
|
1731
|
+
function positiveSeconds(value) {
|
|
1732
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 ? Math.round(value) : void 0;
|
|
1733
|
+
}
|
|
1734
|
+
function encodeSessionOptions(options) {
|
|
1735
|
+
const out = {};
|
|
1736
|
+
const forward = positiveSeconds(options.skipIntervals?.forwardSec);
|
|
1737
|
+
const backward = positiveSeconds(options.skipIntervals?.backwardSec);
|
|
1738
|
+
if (forward !== void 0) out.skipForwardSec = String(forward);
|
|
1739
|
+
if (backward !== void 0) out.skipBackwardSec = String(backward);
|
|
1740
|
+
const rates = (options.playbackRates ?? []).filter((r) => typeof r === "number" && Number.isFinite(r)).map((r) => Math.min(3, Math.max(0.5, r)));
|
|
1741
|
+
if (rates.length) out.playbackRates = [...new Set(rates)].sort((a, b) => a - b).join(",");
|
|
1742
|
+
if (options.persistPosition === true) out.persistPosition = "true";
|
|
1743
|
+
if (options.persistPosition === true && options.startPositionIsFallback === true && options.startPositionMs !== void 0) {
|
|
1744
|
+
out.startPositionFallback = "true";
|
|
1745
|
+
}
|
|
1746
|
+
return out;
|
|
1747
|
+
}
|
|
1748
|
+
async function subscribeStatus(handler) {
|
|
1749
|
+
if (!handler.includes(".")) {
|
|
1750
|
+
throw new Error('media-playback.subscribeStatus: handler must be "<service>.<action>"');
|
|
1751
|
+
}
|
|
1752
|
+
await dispatch("capability.media_playback.subscribeStatus", { onStatus: handler });
|
|
1753
|
+
}
|
|
1754
|
+
async function play(target2) {
|
|
1755
|
+
if (isSessionRef(target2)) {
|
|
1756
|
+
await dispatch("capability.media_playback.play", target2);
|
|
1757
|
+
return;
|
|
1758
|
+
}
|
|
1759
|
+
const params = target2 ? { item: encodeItem(target2) } : {};
|
|
1760
|
+
const r = await dispatch("capability.media_playback.play", params);
|
|
1761
|
+
return decodeStatus(r);
|
|
1762
|
+
}
|
|
1763
|
+
async function pause(ref) {
|
|
1764
|
+
if (isSessionRef(ref)) {
|
|
1765
|
+
await dispatch("capability.media_playback.pause", ref);
|
|
1766
|
+
return;
|
|
1767
|
+
}
|
|
1768
|
+
const r = await dispatch("capability.media_playback.pause");
|
|
1769
|
+
return decodeStatus(r);
|
|
1770
|
+
}
|
|
1771
|
+
async function seek(positionMs) {
|
|
1772
|
+
const r = await dispatch("capability.media_playback.seek", { positionMs: String(Math.max(0, Math.trunc(positionMs || 0))) });
|
|
1773
|
+
return decodeStatus(r);
|
|
1774
|
+
}
|
|
1775
|
+
async function skip(delta) {
|
|
1776
|
+
const r = await dispatch("capability.media_playback.skip", { delta: String(Math.trunc(delta || 0)) });
|
|
1777
|
+
return decodeStatus(r);
|
|
1778
|
+
}
|
|
1779
|
+
async function status() {
|
|
1780
|
+
const r = await dispatch("capability.media_playback.status");
|
|
1781
|
+
return decodeStatus(r);
|
|
1782
|
+
}
|
|
1783
|
+
|
|
1784
|
+
// ../../stdlib/flows/screens/src/podcast-service.ts
|
|
1785
|
+
var DEFAULT_MESSAGES = {
|
|
1786
|
+
notConfigured: "No episodes yet \u2014 check back soon.",
|
|
1787
|
+
empty: "No episodes yet \u2014 check back soon.",
|
|
1788
|
+
noPlayable: "No playable episodes are available in this feed.",
|
|
1789
|
+
feedUnavailable: "Podcast episodes could not be loaded. Try again.",
|
|
1790
|
+
invalidFeed: "This podcast feed is not available.",
|
|
1791
|
+
noAudio: "This episode has no audio.",
|
|
1792
|
+
mediaFailed: "This episode could not be played. Try again.",
|
|
1793
|
+
queueEmpty: "Queue is empty",
|
|
1794
|
+
play: "Play",
|
|
1795
|
+
pause: "Pause",
|
|
1796
|
+
queueOne: "{count} episode in queue",
|
|
1797
|
+
queueMany: "{count} episodes in queue",
|
|
1798
|
+
resume: "Continue at {time}"
|
|
1799
|
+
};
|
|
1800
|
+
function memory(initial) {
|
|
1801
|
+
let value = initial;
|
|
1802
|
+
return { read: () => value, write: (next) => {
|
|
1803
|
+
value = next;
|
|
1804
|
+
} };
|
|
1805
|
+
}
|
|
1806
|
+
function clock(ms) {
|
|
1807
|
+
const seconds = Math.max(0, Math.round(ms / 1e3));
|
|
1808
|
+
const hours = Math.floor(seconds / 3600);
|
|
1809
|
+
const minutes = Math.floor(seconds % 3600 / 60);
|
|
1810
|
+
const rest = String(seconds % 60).padStart(2, "0");
|
|
1811
|
+
return hours ? `${hours}:${String(minutes).padStart(2, "0")}:${rest}` : `${minutes}:${rest}`;
|
|
1812
|
+
}
|
|
1813
|
+
function dateLabel(iso) {
|
|
1814
|
+
const parsed = iso ? Date.parse(iso) : NaN;
|
|
1815
|
+
return Number.isFinite(parsed) ? new Date(parsed).toLocaleDateString(void 0, { month: "short", day: "numeric" }) : "";
|
|
1816
|
+
}
|
|
1817
|
+
function toRow(episode) {
|
|
1818
|
+
return {
|
|
1819
|
+
id: episode.id,
|
|
1820
|
+
title: episode.title,
|
|
1821
|
+
subtitle: [dateLabel(episode.date), episode.durationMs ? clock(episode.durationMs) : ""].filter(Boolean).join(" \xB7 "),
|
|
1822
|
+
image: episode.image,
|
|
1823
|
+
description: episode.description,
|
|
1824
|
+
audioUrl: episode.audioUrl,
|
|
1825
|
+
durationMs: episode.durationMs,
|
|
1826
|
+
progressLabel: ""
|
|
1827
|
+
};
|
|
1828
|
+
}
|
|
1829
|
+
var SUPERSEDED_PLAYBACK = { code: "podcast_command_superseded" };
|
|
1830
|
+
var isSupersededPlayback = (error) => !!error && typeof error === "object" && error.code === SUPERSEDED_PLAYBACK.code;
|
|
1831
|
+
var idOf = (arg) => typeof arg === "string" ? arg : String(arg?.id ?? "");
|
|
1832
|
+
var numberOf = (arg, key) => {
|
|
1833
|
+
const raw = typeof arg === "number" || typeof arg === "string" ? arg : arg?.[key];
|
|
1834
|
+
const n = typeof raw === "number" ? raw : Number(raw);
|
|
1835
|
+
return Number.isFinite(n) ? n : NaN;
|
|
1836
|
+
};
|
|
1837
|
+
function createPodcastService(opts = {}) {
|
|
1838
|
+
const name = opts.service ?? "podcast";
|
|
1839
|
+
const statusHandler = `${name}.mediaStatus`;
|
|
1840
|
+
const messages = { ...DEFAULT_MESSAGES, ...opts.messages };
|
|
1841
|
+
const message = (key) => opts.text?.(key, messages[key]) ?? messages[key];
|
|
1842
|
+
const template = (key, values) => message(key).replace(/\{(count|time)\}/g, (_match, name2) => String(values[name2] ?? ""));
|
|
1843
|
+
const limit = opts.limit ?? 40;
|
|
1844
|
+
const queueStore = opts.queue ?? memory([]);
|
|
1845
|
+
const progressStore = opts.progress ?? memory({});
|
|
1846
|
+
const define = opts.defineService ?? defineService;
|
|
1847
|
+
let savedProgress = progressStore.read();
|
|
1848
|
+
let feedUrl = "";
|
|
1849
|
+
let loadGeneration = 0;
|
|
1850
|
+
let commandGeneration = 0;
|
|
1851
|
+
let queueTail = Promise.resolve();
|
|
1852
|
+
let statusRead;
|
|
1853
|
+
let retryPlayer;
|
|
1854
|
+
const readPlayerStatus = () => {
|
|
1855
|
+
if (statusRead?.generation === commandGeneration) return statusRead.promise;
|
|
1856
|
+
const promise = status().catch(() => void 0);
|
|
1857
|
+
statusRead = { generation: commandGeneration, promise };
|
|
1858
|
+
void promise.then(() => {
|
|
1859
|
+
if (statusRead?.promise === promise) statusRead = void 0;
|
|
1860
|
+
});
|
|
1861
|
+
return promise;
|
|
1862
|
+
};
|
|
1863
|
+
const persistProgress = (value) => {
|
|
1864
|
+
savedProgress = value;
|
|
1865
|
+
progressStore.write(value);
|
|
1866
|
+
};
|
|
1867
|
+
const persistQueue = (value) => queueStore.write(value);
|
|
1868
|
+
const queueItems = (rows, ids) => {
|
|
1869
|
+
const byId = new Map(rows.map((row) => [row.id, row]));
|
|
1870
|
+
return ids.flatMap((id2) => {
|
|
1871
|
+
const row = byId.get(id2);
|
|
1872
|
+
return row ? [{ id: row.id, episodeId: row.id, url: row.audioUrl, title: row.title, subtitle: row.subtitle, artworkUrl: row.image || void 0, durationMs: row.durationMs || void 0 }] : [];
|
|
1873
|
+
});
|
|
1874
|
+
};
|
|
1875
|
+
const queueOptions = (startIndex, startPositionMs, autoplay) => ({ startIndex, startPositionMs, autoplay, onStatus: statusHandler, skipIntervals: { backwardSec: 15, forwardSec: 30 } });
|
|
1876
|
+
const derive = (state) => {
|
|
1877
|
+
const now = state.episodes.find((episode) => episode.id === state.nowId);
|
|
1878
|
+
const duration = state.durationMs || now?.durationMs || 0;
|
|
1879
|
+
const position = Math.max(0, Math.min(state.positionMs, duration || state.positionMs));
|
|
1880
|
+
const episodes = state.episodes.map((episode) => {
|
|
1881
|
+
const saved = savedProgress[episode.id] ?? 0;
|
|
1882
|
+
const resumable = saved >= 1e3 && (!episode.durationMs || saved < episode.durationMs - 1e3);
|
|
1883
|
+
return { ...episode, progressLabel: resumable ? template("resume", { time: clock(saved) }) : "" };
|
|
1884
|
+
});
|
|
1885
|
+
return {
|
|
1886
|
+
...state,
|
|
1887
|
+
episodes,
|
|
1888
|
+
queueLabel: state.queue.length ? template(state.queue.length === 1 ? "queueOne" : "queueMany", { count: state.queue.length }) : message("queueEmpty"),
|
|
1889
|
+
nowTitle: now?.title ?? "",
|
|
1890
|
+
nowSubtitle: now?.subtitle ?? "",
|
|
1891
|
+
playLabel: state.isPlaying ? message("pause") : message("play"),
|
|
1892
|
+
playIcon: state.isPlaying ? "pause" : "play",
|
|
1893
|
+
positionMs: position,
|
|
1894
|
+
durationMs: duration,
|
|
1895
|
+
progress: duration > 0 ? Math.min(1, position / duration) : 0,
|
|
1896
|
+
progressLabel: state.nowId ? `${clock(position)} / ${clock(duration)}` : "",
|
|
1897
|
+
hidePlayer: !state.nowId,
|
|
1898
|
+
playbackErrorText: state.playbackError ? message(state.playbackError === "no_audio" ? "noAudio" : "mediaFailed") : "",
|
|
1899
|
+
hidePlaybackError: !state.playbackError,
|
|
1900
|
+
// Retrying cannot add audio to an episode that has none.
|
|
1901
|
+
hidePlaybackRetry: state.playbackError !== "media_failed"
|
|
1902
|
+
};
|
|
1903
|
+
};
|
|
1904
|
+
const feedFailure = (state, code) => derive({
|
|
1905
|
+
...state,
|
|
1906
|
+
status: "error",
|
|
1907
|
+
feedState: "error",
|
|
1908
|
+
feedError: code,
|
|
1909
|
+
episodes: [],
|
|
1910
|
+
unplayableCount: 0,
|
|
1911
|
+
emptyText: code === "invalid_feed_url" ? message("invalidFeed") : message("feedUnavailable"),
|
|
1912
|
+
// A rejected URL fails the same way every time; only a read failure is worth retrying.
|
|
1913
|
+
hideFeedRetry: code === "invalid_feed_url"
|
|
1914
|
+
});
|
|
1915
|
+
const applyStatus = (state, snapshot) => {
|
|
1916
|
+
const id2 = snapshot.currentItem?.episodeId ?? snapshot.currentItem?.id ?? state.nowId;
|
|
1917
|
+
if (id2 && snapshot.currentItem) {
|
|
1918
|
+
const progress = { ...savedProgress };
|
|
1919
|
+
if (snapshot.state === "ended" || snapshot.positionMs < 1e3 || snapshot.durationMs > 0 && snapshot.positionMs >= snapshot.durationMs - 1e3) delete progress[id2];
|
|
1920
|
+
else if (snapshot.positionMs >= 1e3) progress[id2] = snapshot.positionMs;
|
|
1921
|
+
persistProgress(progress);
|
|
1922
|
+
}
|
|
1923
|
+
const episodeIds = new Set(state.episodes.map((episode) => episode.id));
|
|
1924
|
+
const hostQueue = (snapshot.queue ?? []).map((item) => item.episodeId ?? item.id).filter((itemId) => episodeIds.has(itemId));
|
|
1925
|
+
const queue = snapshot.currentItem && hostQueue.includes(id2) ? hostQueue : state.queue;
|
|
1926
|
+
persistQueue(queue);
|
|
1927
|
+
const failed = snapshot.state === "error";
|
|
1928
|
+
return derive({
|
|
1929
|
+
...state,
|
|
1930
|
+
nowId: id2,
|
|
1931
|
+
queue,
|
|
1932
|
+
playbackState: snapshot.state,
|
|
1933
|
+
isPlaying: snapshot.state === "playing",
|
|
1934
|
+
isBuffering: snapshot.state === "buffering" || snapshot.state === "loading",
|
|
1935
|
+
positionMs: snapshot.positionMs,
|
|
1936
|
+
durationMs: snapshot.durationMs || state.durationMs,
|
|
1937
|
+
playbackError: failed ? "media_failed" : state.playbackError === "no_audio" ? state.playbackError : ""
|
|
1938
|
+
});
|
|
1939
|
+
};
|
|
1940
|
+
const runPlayer = (operation) => {
|
|
1941
|
+
const generation = ++commandGeneration;
|
|
1942
|
+
void operation().then((snapshot) => {
|
|
1943
|
+
if (generation !== commandGeneration) return;
|
|
1944
|
+
retryPlayer = void 0;
|
|
1945
|
+
return svc.mediaStatus(snapshot);
|
|
1946
|
+
}).catch((error) => {
|
|
1947
|
+
if (isSupersededPlayback(error) || generation !== commandGeneration) return;
|
|
1948
|
+
retryPlayer = operation;
|
|
1949
|
+
svc.playbackFailed("media_failed");
|
|
1950
|
+
});
|
|
1951
|
+
};
|
|
1952
|
+
const startQueue = (state, ids, startId, autoplay) => {
|
|
1953
|
+
const items = queueItems(state.episodes, ids);
|
|
1954
|
+
const startIndex = Math.max(0, items.findIndex((item) => item.id === startId));
|
|
1955
|
+
runPlayer(() => setQueue(items, queueOptions(startIndex, savedProgress[startId] ?? 0, autoplay)));
|
|
1956
|
+
};
|
|
1957
|
+
const initial = derive({
|
|
1958
|
+
status: "loading",
|
|
1959
|
+
feedState: "loading",
|
|
1960
|
+
feedError: "",
|
|
1961
|
+
emptyText: "",
|
|
1962
|
+
hideFeedRetry: true,
|
|
1963
|
+
episodes: [],
|
|
1964
|
+
unplayableCount: 0,
|
|
1965
|
+
isMock: false,
|
|
1966
|
+
notMock: true,
|
|
1967
|
+
mockBanner: "",
|
|
1968
|
+
queue: queueStore.read(),
|
|
1969
|
+
queueLabel: "",
|
|
1970
|
+
nowId: "",
|
|
1971
|
+
nowTitle: "",
|
|
1972
|
+
nowSubtitle: "",
|
|
1973
|
+
playbackState: "idle",
|
|
1974
|
+
isPlaying: false,
|
|
1975
|
+
isBuffering: false,
|
|
1976
|
+
playLabel: "",
|
|
1977
|
+
playIcon: "play",
|
|
1978
|
+
positionMs: 0,
|
|
1979
|
+
durationMs: 0,
|
|
1980
|
+
progress: 0,
|
|
1981
|
+
progressLabel: "",
|
|
1982
|
+
hidePlayer: true,
|
|
1983
|
+
playbackError: "",
|
|
1984
|
+
playbackErrorText: "",
|
|
1985
|
+
hidePlaybackError: true,
|
|
1986
|
+
hidePlaybackRetry: true
|
|
1987
|
+
});
|
|
1988
|
+
const loadFeed = async (state) => {
|
|
1989
|
+
const generation = ++loadGeneration;
|
|
1990
|
+
const checked = podcastFeedUrl(feedUrl);
|
|
1991
|
+
if (!checked.ok) {
|
|
1992
|
+
if (checked.code === "invalid_feed_url") return feedFailure(state, "invalid_feed_url");
|
|
1993
|
+
return derive({ ...state, status: "ready", feedState: "unconfigured", feedError: "", episodes: [], unplayableCount: 0, emptyText: message("notConfigured"), hideFeedRetry: true });
|
|
1994
|
+
}
|
|
1995
|
+
const api = globalThis.himalaya?.wixApi;
|
|
1996
|
+
if (!api) return feedFailure(state, "transport_unavailable");
|
|
1997
|
+
let response;
|
|
1998
|
+
try {
|
|
1999
|
+
response = await api.call("POST", PODCAST_FEED_ENDPOINT, podcastFeedRequest(checked.url, limit));
|
|
2000
|
+
} catch {
|
|
2001
|
+
return generation === loadGeneration ? feedFailure(svc.getState(), "feed_unavailable") : svc.getState();
|
|
2002
|
+
}
|
|
2003
|
+
if (generation !== loadGeneration) return svc.getState();
|
|
2004
|
+
const mapped = mapPodcastFeed(response, opts.describe);
|
|
2005
|
+
if (!mapped.ok) return feedFailure(svc.getState(), mapped.code);
|
|
2006
|
+
const episodes = mapped.episodes.map(toRow);
|
|
2007
|
+
const queue = queueStore.read().filter((id2) => episodes.some((episode) => episode.id === id2));
|
|
2008
|
+
persistQueue(queue);
|
|
2009
|
+
const commandAtStatus = commandGeneration;
|
|
2010
|
+
let snapshot = await status().catch(() => void 0);
|
|
2011
|
+
if (generation !== loadGeneration) return svc.getState();
|
|
2012
|
+
if (commandAtStatus !== commandGeneration) snapshot = void 0;
|
|
2013
|
+
if (snapshot && !snapshot.currentItem && queue.length) {
|
|
2014
|
+
snapshot = await setQueue(queueItems(episodes, queue), queueOptions(0, savedProgress[queue[0]] ?? 0, false)).catch(() => void 0);
|
|
2015
|
+
}
|
|
2016
|
+
if (generation !== loadGeneration) return svc.getState();
|
|
2017
|
+
const ready = derive({
|
|
2018
|
+
...svc.getState(),
|
|
2019
|
+
status: "ready",
|
|
2020
|
+
feedState: episodes.length ? "ready" : "empty",
|
|
2021
|
+
feedError: "",
|
|
2022
|
+
episodes,
|
|
2023
|
+
unplayableCount: mapped.unplayable,
|
|
2024
|
+
queue: commandAtStatus === commandGeneration ? queue : svc.getState().queue,
|
|
2025
|
+
emptyText: episodes.length ? "" : mapped.unplayable ? message("noPlayable") : message("empty"),
|
|
2026
|
+
hideFeedRetry: true
|
|
2027
|
+
});
|
|
2028
|
+
return snapshot && commandAtStatus === commandGeneration ? applyStatus(ready, snapshot) : ready;
|
|
2029
|
+
};
|
|
2030
|
+
const svc = define(name, {
|
|
2031
|
+
state: initial,
|
|
2032
|
+
actions: {
|
|
2033
|
+
load: async (s2, arg) => {
|
|
2034
|
+
const requested = arg?.feedUrl;
|
|
2035
|
+
feedUrl = typeof requested === "string" ? requested : "";
|
|
2036
|
+
return loadFeed(derive({ ...s2, status: "loading", feedState: "loading", feedError: "", emptyText: "", hideFeedRetry: true }));
|
|
2037
|
+
},
|
|
2038
|
+
// Collection retry and worker refresh retain the configured feed, unlike a new load.
|
|
2039
|
+
refresh: async (s2) => loadFeed(derive({ ...s2, status: "loading", feedState: "loading", feedError: "", emptyText: "", hideFeedRetry: true })),
|
|
2040
|
+
// Retries the read that failed, for the feed the screen asked for.
|
|
2041
|
+
retryFeed: async (s2) => loadFeed(derive({ ...s2, status: "loading", feedState: "loading", feedError: "", emptyText: "", hideFeedRetry: true })),
|
|
2042
|
+
playEpisode: (s2, arg) => {
|
|
2043
|
+
const id2 = idOf(arg);
|
|
2044
|
+
const selected = s2.episodes.find((episode) => episode.id === id2);
|
|
2045
|
+
if (!selected) return s2;
|
|
2046
|
+
if (!selected.audioUrl) return derive({ ...s2, playbackError: "no_audio" });
|
|
2047
|
+
const queue = [id2, ...s2.queue.filter((queued) => queued !== id2)];
|
|
2048
|
+
persistQueue(queue);
|
|
2049
|
+
startQueue(s2, queue, id2, true);
|
|
2050
|
+
return derive({
|
|
2051
|
+
...s2,
|
|
2052
|
+
queue,
|
|
2053
|
+
nowId: id2,
|
|
2054
|
+
isPlaying: false,
|
|
2055
|
+
isBuffering: true,
|
|
2056
|
+
playbackState: "loading",
|
|
2057
|
+
positionMs: savedProgress[id2] ?? 0,
|
|
2058
|
+
durationMs: selected.durationMs,
|
|
2059
|
+
playbackError: ""
|
|
2060
|
+
});
|
|
2061
|
+
},
|
|
2062
|
+
queueEpisode: (_s, arg) => {
|
|
2063
|
+
const task = queueTail.then(async () => {
|
|
2064
|
+
const s2 = svc.getState();
|
|
2065
|
+
const id2 = idOf(arg);
|
|
2066
|
+
const existing = s2.queue;
|
|
2067
|
+
if (!s2.episodes.some((episode) => episode.id === id2) || existing.includes(id2)) return s2;
|
|
2068
|
+
const queue = [...existing, id2];
|
|
2069
|
+
persistQueue(queue);
|
|
2070
|
+
const operation = async () => {
|
|
2071
|
+
const generation = commandGeneration;
|
|
2072
|
+
const snapshot = await status();
|
|
2073
|
+
if (generation !== commandGeneration) throw SUPERSEDED_PLAYBACK;
|
|
2074
|
+
const activeId = snapshot.currentItem?.episodeId ?? snapshot.currentItem?.id ?? s2.nowId;
|
|
2075
|
+
if (!activeId) return snapshot;
|
|
2076
|
+
const next = await setQueue(
|
|
2077
|
+
queueItems(s2.episodes, queue),
|
|
2078
|
+
queueOptions(Math.max(0, queue.indexOf(activeId)), snapshot.positionMs, snapshot.state === "playing")
|
|
2079
|
+
);
|
|
2080
|
+
if (generation !== commandGeneration) throw SUPERSEDED_PLAYBACK;
|
|
2081
|
+
return next;
|
|
2082
|
+
};
|
|
2083
|
+
++commandGeneration;
|
|
2084
|
+
try {
|
|
2085
|
+
const next = await operation();
|
|
2086
|
+
retryPlayer = void 0;
|
|
2087
|
+
return applyStatus(derive({ ...svc.getState(), queue }), next);
|
|
2088
|
+
} catch (error) {
|
|
2089
|
+
if (isSupersededPlayback(error)) {
|
|
2090
|
+
if (JSON.stringify(queueStore.read()) === JSON.stringify(queue)) persistQueue(svc.getState().queue);
|
|
2091
|
+
return svc.getState();
|
|
2092
|
+
}
|
|
2093
|
+
retryPlayer = operation;
|
|
2094
|
+
return derive({ ...svc.getState(), queue, playbackError: "media_failed", isBuffering: false });
|
|
2095
|
+
}
|
|
2096
|
+
});
|
|
2097
|
+
queueTail = task.then(() => {
|
|
2098
|
+
}, () => {
|
|
2099
|
+
});
|
|
2100
|
+
return task;
|
|
2101
|
+
},
|
|
2102
|
+
togglePlay: async (s2) => {
|
|
2103
|
+
if (!s2.nowId) return s2;
|
|
2104
|
+
runPlayer(async () => {
|
|
2105
|
+
const snapshot = await status();
|
|
2106
|
+
if (!snapshot.currentItem) {
|
|
2107
|
+
const ids = s2.queue.includes(s2.nowId) ? s2.queue : [s2.nowId, ...s2.queue];
|
|
2108
|
+
const items = queueItems(s2.episodes, ids);
|
|
2109
|
+
return setQueue(items, queueOptions(Math.max(0, ids.indexOf(s2.nowId)), savedProgress[s2.nowId] ?? 0, true));
|
|
2110
|
+
}
|
|
2111
|
+
return snapshot.state === "playing" || snapshot.state === "buffering" ? pause() : play();
|
|
2112
|
+
});
|
|
2113
|
+
return s2;
|
|
2114
|
+
},
|
|
2115
|
+
seek: (s2, arg) => {
|
|
2116
|
+
if (!s2.nowId) return s2;
|
|
2117
|
+
const raw = numberOf(arg, "value");
|
|
2118
|
+
if (!Number.isFinite(raw)) return s2;
|
|
2119
|
+
const positionMs = Math.max(0, Math.round(raw <= 1 ? raw * s2.durationMs : raw));
|
|
2120
|
+
runPlayer(() => seek(positionMs));
|
|
2121
|
+
return s2;
|
|
2122
|
+
},
|
|
2123
|
+
seekBy: (s2, arg) => {
|
|
2124
|
+
if (!s2.nowId) return s2;
|
|
2125
|
+
const delta = numberOf(arg, "deltaMs");
|
|
2126
|
+
if (!Number.isFinite(delta)) return s2;
|
|
2127
|
+
const positionMs = Math.max(0, Math.min(s2.durationMs || Infinity, s2.positionMs + delta));
|
|
2128
|
+
runPlayer(() => seek(positionMs));
|
|
2129
|
+
return s2;
|
|
2130
|
+
},
|
|
2131
|
+
previousEpisode: (s2) => {
|
|
2132
|
+
if (!s2.nowId) return s2;
|
|
2133
|
+
runPlayer(() => skip(-1));
|
|
2134
|
+
return s2;
|
|
2135
|
+
},
|
|
2136
|
+
nextEpisode: (s2) => {
|
|
2137
|
+
if (!s2.nowId) return s2;
|
|
2138
|
+
runPlayer(() => skip(1));
|
|
2139
|
+
return s2;
|
|
2140
|
+
},
|
|
2141
|
+
// Retry the failed command (or a player-reported episode error). Never opens a browser.
|
|
2142
|
+
retryPlayback: (s2) => {
|
|
2143
|
+
if (s2.playbackError !== "media_failed" || !s2.nowId) return s2;
|
|
2144
|
+
if (retryPlayer) runPlayer(retryPlayer);
|
|
2145
|
+
else startQueue(s2, s2.queue.includes(s2.nowId) ? s2.queue : [s2.nowId, ...s2.queue], s2.nowId, true);
|
|
2146
|
+
return derive({ ...s2, playbackError: "" });
|
|
2147
|
+
},
|
|
2148
|
+
// A rejected control does not prove transport stopped. Only mediaStatus owns it.
|
|
2149
|
+
playbackFailed: (s2, code) => derive({ ...s2, isBuffering: false, playbackError: code ?? "media_failed" }),
|
|
2150
|
+
mediaStatus: async (_s, arg) => {
|
|
2151
|
+
const generation = commandGeneration;
|
|
2152
|
+
const snapshot = arg?.state && arg.currentItem !== void 0 ? arg : await readPlayerStatus();
|
|
2153
|
+
const current = svc.getState();
|
|
2154
|
+
if (generation !== commandGeneration) return current;
|
|
2155
|
+
return snapshot ? applyStatus(current, snapshot) : current;
|
|
2156
|
+
}
|
|
2157
|
+
}
|
|
2158
|
+
});
|
|
2159
|
+
subscribeStatus(statusHandler).catch(() => {
|
|
2160
|
+
});
|
|
2161
|
+
return svc;
|
|
2162
|
+
}
|
|
2163
|
+
|
|
1526
2164
|
// ../../core/sdk/wix-cashier/src/index.ts
|
|
1527
2165
|
function normalizeAvailability(raw) {
|
|
1528
2166
|
switch ((raw ?? "").toLowerCase()) {
|
|
@@ -2845,8 +3483,8 @@ function decodePaymentAnswer(raw, expected) {
|
|
|
2845
3483
|
}
|
|
2846
3484
|
function decodePayment(raw, expected) {
|
|
2847
3485
|
if (!isObject3(raw) || !hasPaymentIds(raw) || !echoes(raw, expected) || !hasValidOptionals(raw)) return null;
|
|
2848
|
-
const
|
|
2849
|
-
return
|
|
3486
|
+
const status2 = ownValue(STATUSES, raw.status);
|
|
3487
|
+
return status2 ? toPayment(raw, status2) : null;
|
|
2850
3488
|
}
|
|
2851
3489
|
function hasPaymentIds(raw) {
|
|
2852
3490
|
return isUUID(raw.id) && isUUID(raw.appId) && isUUID(raw.memberId) && isUUID(raw.wixTransactionId);
|
|
@@ -2857,7 +3495,7 @@ function echoes(raw, expected) {
|
|
|
2857
3495
|
function hasValidOptionals(raw) {
|
|
2858
3496
|
return (raw.appProductId === void 0 || isStoreProductId(raw.appProductId)) && (raw.purchaseTransactionId === void 0 || isUUID(raw.purchaseTransactionId)) && TIMESTAMPS.every((field) => raw[field] === void 0 || isTimestamp(raw[field]));
|
|
2859
3497
|
}
|
|
2860
|
-
function toPayment(raw,
|
|
3498
|
+
function toPayment(raw, status2) {
|
|
2861
3499
|
const optional = {
|
|
2862
3500
|
appProductId: raw.appProductId,
|
|
2863
3501
|
cancelReason: ownValue(CANCEL_REASONS, raw.cancelReason),
|
|
@@ -2868,7 +3506,7 @@ function toPayment(raw, status) {
|
|
|
2868
3506
|
refundedDate: raw.refundedDate
|
|
2869
3507
|
};
|
|
2870
3508
|
const ids = { paymentId: raw.id, appId: raw.appId, memberId: raw.memberId, wixTransactionId: raw.wixTransactionId };
|
|
2871
|
-
return { ...ids, status, ...withoutUndefined(optional) };
|
|
3509
|
+
return { ...ids, status: status2, ...withoutUndefined(optional) };
|
|
2872
3510
|
}
|
|
2873
3511
|
function classifyFailure(error, operation, codes2) {
|
|
2874
3512
|
const message = messageOf(error);
|
|
@@ -3080,8 +3718,8 @@ function isUndecided(result) {
|
|
|
3080
3718
|
return failed.status === "failed" && UNDECIDED.has(failed.kind);
|
|
3081
3719
|
}
|
|
3082
3720
|
function outcomeUnknown(failed) {
|
|
3083
|
-
const
|
|
3084
|
-
return { status: "outcomeUnknown", operation: "startItemPayment", kind: failed.kind, ...
|
|
3721
|
+
const status2 = failed.httpStatus === void 0 ? {} : { httpStatus: failed.httpStatus };
|
|
3722
|
+
return { status: "outcomeUnknown", operation: "startItemPayment", kind: failed.kind, ...status2 };
|
|
3085
3723
|
}
|
|
3086
3724
|
async function read(call, operation) {
|
|
3087
3725
|
try {
|
|
@@ -3367,8 +4005,8 @@ var COMPLETE_PAYMENT_REFUSALS = {
|
|
|
3367
4005
|
APP_NOT_CONFIGURED: "hold",
|
|
3368
4006
|
OWNED_BY_ANOTHER_CUSTOMER: "ownershipConflict"
|
|
3369
4007
|
};
|
|
3370
|
-
function isFinalRefusal(
|
|
3371
|
-
return
|
|
4008
|
+
function isFinalRefusal(status2) {
|
|
4009
|
+
return status2 === "canceling" || status2 === "canceled" || status2 === "refunding" || status2 === "refunded";
|
|
3372
4010
|
}
|
|
3373
4011
|
|
|
3374
4012
|
// ../../stdlib/flows/iap-checkout/src/order-refs.ts
|
|
@@ -4027,12 +4665,12 @@ function createWixOrderBackend(deps) {
|
|
|
4027
4665
|
if (refusal === "hold" || refusal === "rejected") return heldProof(proof, "rejected");
|
|
4028
4666
|
return refusal === "ownershipConflict" ? heldProof(proof, "ownershipConflict") : { status: refusal };
|
|
4029
4667
|
}
|
|
4030
|
-
function heldProof(proof,
|
|
4668
|
+
function heldProof(proof, status2) {
|
|
4031
4669
|
const started = startedRefFor(proof);
|
|
4032
4670
|
const hold = started && { ...started, stage: "held", appleTransactionId: proof.transaction.transactionId, updatedAt: now() };
|
|
4033
4671
|
if (hold && !(isCurrent(proof.session) && proof.member.partition?.put(hold))) return RETRYABLE;
|
|
4034
4672
|
deps.report({ key: started?.key ?? `payment:${proof.transaction.transactionId}`, failure: "paymentHeld" });
|
|
4035
|
-
return { status };
|
|
4673
|
+
return { status: status2 };
|
|
4036
4674
|
}
|
|
4037
4675
|
function startedRefFor(proof) {
|
|
4038
4676
|
const refs = proof.member.partition?.refs() ?? [];
|
|
@@ -5074,9 +5712,9 @@ async function readAccess(verticalRef, port) {
|
|
|
5074
5712
|
return ENDED.has(purchase.status) ? "none" : "unavailable";
|
|
5075
5713
|
}
|
|
5076
5714
|
function dataAt(body, path) {
|
|
5077
|
-
let
|
|
5078
|
-
for (const key of path)
|
|
5079
|
-
return isObject7(
|
|
5715
|
+
let node4 = isObject7(body) && isObject7(body.data) ? body.data : body;
|
|
5716
|
+
for (const key of path) node4 = isObject7(node4) ? node4[key] : void 0;
|
|
5717
|
+
return isObject7(node4) ? node4 : null;
|
|
5080
5718
|
}
|
|
5081
5719
|
var ENDED = /* @__PURE__ */ new Set(["DECLINED", "EXPIRED", "CANCELED", "REFUNDED", "FAILED"]);
|
|
5082
5720
|
var UNPAID = /* @__PURE__ */ new Set(["INITIALIZED", "PENDING"]);
|
|
@@ -5138,14 +5776,14 @@ function createRedirectSession(req = {}, opts) {
|
|
|
5138
5776
|
|
|
5139
5777
|
// ../../stdlib/flows/screens/src/index.ts
|
|
5140
5778
|
var PKG = "himalaya";
|
|
5141
|
-
var
|
|
5779
|
+
var node3 = (id2, type, props) => ({ id: id2, body: { package: PKG, type, props } });
|
|
5142
5780
|
var hideWhen = (n, path) => ({
|
|
5143
5781
|
...n,
|
|
5144
5782
|
modifiers: { ...n.modifiers ?? {}, hiddenPath: path }
|
|
5145
5783
|
});
|
|
5146
|
-
var text = (id2, value, style = "body") =>
|
|
5147
|
-
var vstack = (id2, children, spacing = 12, alignment = "leading") =>
|
|
5148
|
-
var button = (id2, title, action2, style = "primary") =>
|
|
5784
|
+
var text = (id2, value, style = "body") => node3(id2, "Text", { text: value, style });
|
|
5785
|
+
var vstack = (id2, children, spacing = 12, alignment = "leading") => node3(id2, "VStack", { spacing, alignment, children });
|
|
5786
|
+
var button = (id2, title, action2, style = "primary") => node3(id2, "Button", { title, style, fullWidth: true, action: action2 });
|
|
5149
5787
|
var openScreen = (screenId) => ({ actionId: "himi.open", params: { screenId } });
|
|
5150
5788
|
function detailedHeader(opts) {
|
|
5151
5789
|
const id2 = opts.id ?? "detailed_header";
|
|
@@ -5153,7 +5791,7 @@ function detailedHeader(opts) {
|
|
|
5153
5791
|
if (opts.logoUrl || opts.locationLabel) {
|
|
5154
5792
|
const identity = [];
|
|
5155
5793
|
if (opts.logoUrl) {
|
|
5156
|
-
identity.push(
|
|
5794
|
+
identity.push(node3(`${id2}.logo`, "Image", {
|
|
5157
5795
|
url: opts.logoUrl,
|
|
5158
5796
|
width: 56,
|
|
5159
5797
|
height: 56,
|
|
@@ -5164,12 +5802,12 @@ function detailedHeader(opts) {
|
|
|
5164
5802
|
}
|
|
5165
5803
|
if (opts.locationLabel) {
|
|
5166
5804
|
if (opts.locationAction) {
|
|
5167
|
-
identity.push(
|
|
5805
|
+
identity.push(node3(`${id2}.locationGroup`, "HStack", {
|
|
5168
5806
|
spacing: 8,
|
|
5169
5807
|
alignment: "center",
|
|
5170
5808
|
children: [
|
|
5171
5809
|
text(`${id2}.location`, opts.locationLabel, "caption"),
|
|
5172
|
-
|
|
5810
|
+
node3(`${id2}.location.action`, "Button", {
|
|
5173
5811
|
title: opts.locationAction.label,
|
|
5174
5812
|
style: opts.locationAction.style ?? "plain",
|
|
5175
5813
|
fullWidth: false,
|
|
@@ -5181,10 +5819,10 @@ function detailedHeader(opts) {
|
|
|
5181
5819
|
identity.push(text(`${id2}.location`, opts.locationLabel, "caption"));
|
|
5182
5820
|
}
|
|
5183
5821
|
}
|
|
5184
|
-
cardChildren.push(
|
|
5822
|
+
cardChildren.push(node3(`${id2}.identity`, "HStack", { spacing: 12, alignment: "center", children: identity }));
|
|
5185
5823
|
}
|
|
5186
5824
|
if (opts.memberCaption || opts.memberAvatarsPath || opts.memberAvatars?.length) {
|
|
5187
|
-
cardChildren.push(
|
|
5825
|
+
cardChildren.push(node3(`${id2}.members`, "AvatarStrip", {
|
|
5188
5826
|
size: 36,
|
|
5189
5827
|
maxVisible: 5,
|
|
5190
5828
|
...opts.memberCaption ? { caption: opts.memberCaption } : {},
|
|
@@ -5199,7 +5837,7 @@ function detailedHeader(opts) {
|
|
|
5199
5837
|
]) {
|
|
5200
5838
|
if (action2) cardChildren.push(button(`${id2}.${key}`, action2.label, action2.action, action2.style ?? (key === "primary" ? "primary" : "secondary")));
|
|
5201
5839
|
}
|
|
5202
|
-
const card =
|
|
5840
|
+
const card = node3(`${id2}.card`, "VStack", {
|
|
5203
5841
|
spacing: 14,
|
|
5204
5842
|
alignment: "leading",
|
|
5205
5843
|
children: cardChildren
|
|
@@ -5212,7 +5850,7 @@ function detailedHeader(opts) {
|
|
|
5212
5850
|
fillMaxWidth: true
|
|
5213
5851
|
};
|
|
5214
5852
|
const fixed = opts.collapsible === false;
|
|
5215
|
-
return
|
|
5853
|
+
return node3(id2, "CollapsingHeader", {
|
|
5216
5854
|
...opts.imageUrl ? { imageUrl: opts.imageUrl } : {},
|
|
5217
5855
|
title: opts.title,
|
|
5218
5856
|
...opts.subtitle ? { subtitle: opts.subtitle } : {},
|
|
@@ -5238,7 +5876,7 @@ function authScreen(opts) {
|
|
|
5238
5876
|
const screenId = opts.screenId ?? "signin";
|
|
5239
5877
|
const c = opts.copy ?? {};
|
|
5240
5878
|
const withRegister = opts.register !== false;
|
|
5241
|
-
const field = (key, label, action2, extra = {}) =>
|
|
5879
|
+
const field = (key, label, action2, extra = {}) => node3(`${s2}.${key}`, "TextField", {
|
|
5242
5880
|
label,
|
|
5243
5881
|
placeholder: label,
|
|
5244
5882
|
valuePath: `$service:${s2}.${key}`,
|
|
@@ -5258,7 +5896,7 @@ function authScreen(opts) {
|
|
|
5258
5896
|
`$service:${s2}.signedIn`
|
|
5259
5897
|
),
|
|
5260
5898
|
hideWhen(
|
|
5261
|
-
|
|
5899
|
+
node3(`${s2}.submit`, "Button", {
|
|
5262
5900
|
title: `$service:${s2}.submitCta`,
|
|
5263
5901
|
style: "primary",
|
|
5264
5902
|
fullWidth: true,
|
|
@@ -5270,7 +5908,7 @@ function authScreen(opts) {
|
|
|
5270
5908
|
if (withRegister) {
|
|
5271
5909
|
children.push(
|
|
5272
5910
|
hideWhen(
|
|
5273
|
-
|
|
5911
|
+
node3(`${s2}.toggle`, "Button", {
|
|
5274
5912
|
title: `$service:${s2}.switchCta`,
|
|
5275
5913
|
style: "secondary",
|
|
5276
5914
|
fullWidth: true,
|
|
@@ -5290,7 +5928,7 @@ function authScreen(opts) {
|
|
|
5290
5928
|
}
|
|
5291
5929
|
children.push(
|
|
5292
5930
|
hideWhen(
|
|
5293
|
-
|
|
5931
|
+
node3(`${s2}.signout`, "Button", {
|
|
5294
5932
|
title: c.signOutCta ?? "Sign out",
|
|
5295
5933
|
style: "secondary",
|
|
5296
5934
|
fullWidth: true,
|
|
@@ -5628,8 +6266,8 @@ function createCheckoutService(opts = {}) {
|
|
|
5628
6266
|
try {
|
|
5629
6267
|
const res = await createOnlineOrder(id2);
|
|
5630
6268
|
purchaseFlowId = String(res?.purchaseFlowId ?? "");
|
|
5631
|
-
const
|
|
5632
|
-
if (
|
|
6269
|
+
const status2 = String(res?.order?.status ?? "").toUpperCase();
|
|
6270
|
+
if (status2 === GRANTS_ACCESS) {
|
|
5633
6271
|
if (generation !== memberSession.current().generation) return void 0;
|
|
5634
6272
|
offerGeneration = generation;
|
|
5635
6273
|
regularAccess.add(id2);
|
|
@@ -5748,7 +6386,7 @@ function checkoutScreen(opts) {
|
|
|
5748
6386
|
// someone the thing they are currently paying for is the obvious next bug.
|
|
5749
6387
|
hideWhen(text(`${s2}.row_joined`, "$item.joinedLabel", "bodyEmphasis"), "$item.notJoined"),
|
|
5750
6388
|
hideWhen(
|
|
5751
|
-
|
|
6389
|
+
node3(`${s2}.row_join`, "Button", {
|
|
5752
6390
|
title: "$item.cta",
|
|
5753
6391
|
disabledPath: "$item.joinDisabled",
|
|
5754
6392
|
style: "primary",
|
|
@@ -5787,7 +6425,7 @@ function checkoutScreen(opts) {
|
|
|
5787
6425
|
}
|
|
5788
6426
|
children.push(
|
|
5789
6427
|
hideWhen(
|
|
5790
|
-
|
|
6428
|
+
node3(`${s2}.list`, "LazyList", { itemsPath: `$service:${s2}.rows`, spacing: 18, items: [row] }),
|
|
5791
6429
|
`$service:${s2}.noRows`
|
|
5792
6430
|
)
|
|
5793
6431
|
);
|
|
@@ -5800,6 +6438,9 @@ function checkoutScreen(opts) {
|
|
|
5800
6438
|
}
|
|
5801
6439
|
export {
|
|
5802
6440
|
ONE_APP_MEMBER_ONLY_SECTIONS,
|
|
6441
|
+
PODCAST_EPISODES_QUERY,
|
|
6442
|
+
PODCAST_FEED_ENDPOINT,
|
|
6443
|
+
PODCAST_SCREEN_CAPABILITIES,
|
|
5803
6444
|
authScreen,
|
|
5804
6445
|
businessContactLink,
|
|
5805
6446
|
businessContactPoint,
|
|
@@ -5812,6 +6453,7 @@ export {
|
|
|
5812
6453
|
createInviteAvailabilityService,
|
|
5813
6454
|
createInviteService,
|
|
5814
6455
|
createOneAppSectionService,
|
|
6456
|
+
createPodcastService,
|
|
5815
6457
|
decodeOneAppPage,
|
|
5816
6458
|
detailedHeader,
|
|
5817
6459
|
entitlement,
|
|
@@ -5820,9 +6462,16 @@ export {
|
|
|
5820
6462
|
inviteScreen,
|
|
5821
6463
|
isOneAppPageId,
|
|
5822
6464
|
isOneAppSectionVisible,
|
|
6465
|
+
mapPodcastFeed,
|
|
5823
6466
|
oneAppPageContentErrorCode,
|
|
5824
6467
|
oneAppPageSection,
|
|
5825
6468
|
oneAppSection,
|
|
5826
|
-
oneAppSectionVisibility
|
|
6469
|
+
oneAppSectionVisibility,
|
|
6470
|
+
podcastAudioUrl,
|
|
6471
|
+
podcastDurationMs,
|
|
6472
|
+
podcastFeedRequest,
|
|
6473
|
+
podcastFeedSetting,
|
|
6474
|
+
podcastFeedUrl,
|
|
6475
|
+
podcastScreen
|
|
5827
6476
|
};
|
|
5828
6477
|
//# sourceMappingURL=screens.mjs.map
|