@wix/himalaya-cli 0.1723.0 → 0.1725.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.
Files changed (84) hide show
  1. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/dev-server/src/app-config.d.ts +1 -0
  2. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/dev-server/src/app-module.d.ts +2 -0
  3. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/godot/src/index.d.ts +3 -0
  4. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/iap/src/attendance-classifier.d.ts +1 -1
  5. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/iap/src/wix-payments-contract.d.ts +9 -43
  6. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/location/src/index.d.ts +5 -3
  7. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/on-device-ai/src/index.d.ts +19 -7
  8. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/sdk-types/src/capabilities.generated.d.ts +1 -1
  9. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/define-app.d.ts +10 -0
  10. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/index.d.ts +2 -0
  11. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/preview-surfaces.d.ts +24 -0
  12. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/site-web-sdk.d.ts +37 -0
  13. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/site-web-sdk.generated.d.ts +1 -0
  14. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/wrapped-app-link.d.ts +13 -0
  15. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/checkout-source.d.ts +5 -3
  16. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/iap-order-backend.d.ts +0 -2
  17. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/iap-verticals/attendance.d.ts +2 -8
  18. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/iap-verticals/index.d.ts +4 -13
  19. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/iap-verticals/videos.d.ts +31 -1
  20. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/index.d.ts +1 -1
  21. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/audio-record.mjs +1 -1
  22. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/calendar.mjs +1 -1
  23. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/calls.mjs +1 -1
  24. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/contacts.mjs +1 -1
  25. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/core.mjs +175 -1
  26. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/iap-checkout.mjs +127 -509
  27. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/iap.mjs +5 -26
  28. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/location.mjs +1 -1
  29. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/motion.mjs +1 -1
  30. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/on-device-ai.mjs +49 -3
  31. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/photos.mjs +1 -1
  32. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/screens.mjs +150 -644
  33. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/sdk-types.mjs +1 -1
  34. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/sdui.mjs +1 -0
  35. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/tasks.mjs +1 -1
  36. package/dist/browser-plane/assets.json +7 -7
  37. package/dist/browser-plane/package-reader.js +4 -4
  38. package/dist/browser-plane/preview-deferred/{74e5b76ecf38392d7eb3f9a9512d60a0675de85d411c9c56293e123152b3f70b.bin → 49dfd582c5a8fb38ceabd1c544343d87fd478063c04f90c4e7a4ed5ee774f1eb.bin} +1 -1
  39. package/dist/browser-plane/sw.js +9 -9
  40. package/dist/browser-plane/t5-frame.html +16 -0
  41. package/dist/browser-plane/t5-worker-frame.html +16 -0
  42. package/dist/cli.mjs +3039 -1831
  43. package/dist/preview-assets.generated.bin +0 -0
  44. package/guides/capabilities.md +2 -2
  45. package/guides/headless-loop.md +2 -1
  46. package/guides/himi-json-output.md +6 -2
  47. package/guides/iap-products.md +2 -2
  48. package/guides/iap-screen-adoption.md +5 -5
  49. package/guides/sdk-reference.json +47 -82
  50. package/guides/skill.md +1 -1
  51. package/guides/testing-himi-apps.md +4 -3
  52. package/guides/web-page-sdk-reference.md +1 -1
  53. package/guides/webview-page-sdk.md +14 -0
  54. package/guides/wix-business-context.md +24 -0
  55. package/guides/wix-site-to-himi-app.md +2 -1
  56. package/package.json +2 -2
  57. package/templates/beauty-salon/tier5-src/himi-store-account/index.ts +2 -2
  58. package/templates/beauty-salon/tier5-src/himi-store-product/index.ts +5 -8
  59. package/templates/branded-lite/dev/index.ts +35 -0
  60. package/templates/branded-lite/tier5-src/himi-branded-lite-video/index.ts +82 -12
  61. package/templates/branded-lite/tier5-src/himi-store-account/index.ts +2 -2
  62. package/templates/branded-lite/tier5-src/himi-store-product/index.ts +5 -8
  63. package/templates/brandy/README.md +13 -0
  64. package/templates/brandy/config.ts +15 -1
  65. package/templates/brandy/dev/index.ts +10 -7
  66. package/templates/community-club/tier5-src/himi-store-account/index.ts +2 -2
  67. package/templates/conference/tier5-src/himi-store-account/index.ts +2 -2
  68. package/templates/events-meetups/tier5-src/himi-store-account/index.ts +2 -2
  69. package/templates/gym-fitness/tier5-src/himi-store-account/index.ts +2 -2
  70. package/templates/gym-fitness/tier5-src/himi-store-product/index.ts +5 -8
  71. package/templates/nonprofit-cause/tier5-src/himi-store-account/index.ts +2 -2
  72. package/templates/podcast-creator/tier5-src/himi-store-account/index.ts +2 -2
  73. package/templates/portfolio-creative/tier5-src/himi-store-account/index.ts +2 -2
  74. package/templates/portfolio-creative/tier5-src/himi-store-product/index.ts +5 -8
  75. package/templates/restaurant/tier5-src/himi-store-account/index.ts +2 -2
  76. package/templates/retail-store/tier5-src/himi-store-account/index.ts +2 -2
  77. package/templates/retail-store/tier5-src/himi-store-product/index.ts +5 -8
  78. package/templates/salon-spa/tier5-src/himi-store-account/index.ts +2 -2
  79. package/templates/wholesale-store/tier5-src/himi-store-account/index.ts +2 -2
  80. package/templates/wholesale-store/tier5-src/himi-store-product/index.ts +5 -8
  81. package/templates/yoga-studio/tier5-src/himi-store-account/index.ts +2 -2
  82. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/iap-verticals/attendance-orders.d.ts +0 -10
  83. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/iap-verticals/online-programs-orders.d.ts +0 -2
  84. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/iap-verticals/pricing-plans-orders.d.ts +0 -2
@@ -1,11 +1,12 @@
1
1
  // App Store prices come from the shared IAP catalog layer (@himalaya/iap): a video with a one-time Sale
2
- // price, in a channel that does not require a subscription, is priced as `wixVideo` under its id. Prices
3
- // only: buying a video stays off (VIDEOS_APPLE_SALES_ENABLED), so the screen says so instead of a Buy.
2
+ // price, in a channel that does not require a subscription, is priced as `wixVideo` under its id. Buying
3
+ // goes through the shared checkout (`wixVideoOrders`) and only once VIDEOS_APPLE_SALES_ENABLED is on;
4
+ // until then the checkout is not composed at all and the screen says buying is not available yet.
4
5
  import { descriptionBody } from "../_shared/rich-body.js";
5
6
  import { defineService } from "@himalaya/state";
6
7
  import { iapPriceFields, wixVideoItem, type IapCatalogItem } from "@himalaya/iap";
7
- import { createIapCommerce } from "@himalaya/iap-checkout";
8
- import { iapPriceCopy, resetUnhydratedKeysOnOlderRuntime } from "../_shared/iap-worker.js";
8
+ import { createIapCommerce, videosAppleSalesEnabled, wixVideoOrders, type IapPurchaseFields } from "@himalaya/iap-checkout";
9
+ import { iapPriceCopy, iapPurchaseCopy, resetUnhydratedKeysOnOlderRuntime } from "../_shared/iap-worker.js";
9
10
  import { LOADING, loaded, loadFailed, needsSignIn, type LoadFlags } from "../_shared/branded-load-state.js";
10
11
  import { copyParam, stashCopy } from "../_shared/himi-copy.js";
11
12
  import {
@@ -21,6 +22,8 @@ interface S extends LoadFlags {
21
22
  playbackState: "loading" | "ready" | "processing" | "denied" | "unavailable" | "error";
22
23
  /** This run's App Store price of the video, its loading/unavailable label, or "". */
23
24
  priceText: string; priceNote: string; purchaseNote: string; hidePriceRetry: boolean;
25
+ /** The shared checkout's Buy (`commerce.purchaseFields`): shown only on the App Store route. */
26
+ buyHidden: boolean; buyLabel: string; buyDisabled: boolean; buyNote: string;
24
27
  }
25
28
  const COPY = { prefix: "video", empty: "No videos in this channel yet.", error: "Videos couldn't be loaded.", signIn: "Sign in to watch videos.", sample: () => [] };
26
29
  function input(key: string): string {
@@ -29,17 +32,28 @@ function input(key: string): string {
29
32
  }
30
33
  let generation = 0;
31
34
  const initial: S = { ...LOADING, id: "", channelId: "", title: "", description: "", videos: [], items: [], hidePlayer: true, hideNotFound: true, noEntity: false, hideRefresh: false, emptyText: "", message: "", playbackState: "loading",
32
- priceText: "", priceNote: "", purchaseNote: "", hidePriceRetry: true };
35
+ priceText: "", priceNote: "", purchaseNote: "", hidePriceRetry: true, buyHidden: true, buyLabel: "", buyDisabled: true, buyNote: "" };
33
36
 
34
37
  // ── App Store prices ─────
35
38
  // One writer: `load` keeps what it read in `shown` and the priced items here; every repaint goes
36
39
  // through the synchronous `publish`, which reads the latest content and prices together.
37
- const commerce = createIapCommerce({ onChange: () => { void svc.publish(); } });
40
+ /** Read once: the checkout is composed for the whole visit or not at all. */
41
+ const SELLS_THROUGH_APPLE = videosAppleSalesEnabled();
42
+ const commerce = createIapCommerce({ adapters: SELLS_THROUGH_APPLE ? [wixVideoOrders] : [], onChange: () => { void svc.publish(); } });
38
43
  const pricing = commerce.pricing;
39
44
  let shown: S = { ...initial };
40
45
  /** The item the detail prices: a locked video sold once. Rows carry their own. */
41
46
  let detailItem: IapCatalogItem | undefined;
42
47
  let rowItems: Array<IapCatalogItem | undefined> = [];
48
+ let commerceStarted = false;
49
+ /** The bought video `load` re-reads so the player replaces Buy. Only a read that failed, or that Video
50
+ * still denied while its grant catches up, runs again: after ACCESS_RELOAD_RETRY_MS, on the next repaint,
51
+ * at most ACCESS_RELOAD_ATTEMPTS times. Any other answer (the player, processing, unavailable) is final. */
52
+ let accessReload = { id: "", at: 0, attempts: 0, settled: false };
53
+ const ACCESS_RELOAD_RETRY_MS = 10_000;
54
+ const ACCESS_RELOAD_ATTEMPTS = 5;
55
+ const NOT_APPLE: IapPurchaseFields = { appleRoute: false, accessReady: false, buyLabel: "", buyDisabled: true, buyBusy: false, buyNote: "" };
56
+ const NO_BUY = { buyHidden: true, buyLabel: "", buyDisabled: true, buyNote: "" };
43
57
 
44
58
  async function priceContent(): Promise<void> {
45
59
  const items = [...(detailItem ? [detailItem] : []), ...rowItems.flatMap((item) => item ?? [])];
@@ -47,29 +61,83 @@ async function priceContent(): Promise<void> {
47
61
  void svc.publish();
48
62
  }
49
63
 
64
+ /** Every projection re-arms the checkout's poll, so it steps between cadences on any screen. */
50
65
  function priced(state: S): S {
66
+ // A read after access that did not play the video leaves no priced item, so the retry is checked here.
67
+ if (accessReload.id && !accessReload.settled && accessReload.id === state.id) reloadOnceForAccess(state.id);
68
+ return { ...projected(state), ...withPoll() } as S;
69
+ }
70
+
71
+ function projected(state: S): S {
51
72
  const copy = iapPriceCopy("video");
52
73
  const videos = state.videos.map((row, i) => ({ ...row, priceLine: rowItems[i] ? iapPriceFields(pricing.view(rowItems[i]!.reference), copy).priceText : "" }));
53
- if (!detailItem) return { ...state, videos, priceText: "", priceNote: "", purchaseNote: "", hidePriceRetry: true };
74
+ if (!detailItem) return { ...state, videos, priceText: "", priceNote: "", purchaseNote: "", hidePriceRetry: true, ...NO_BUY };
54
75
  const view = pricing.view(detailItem.reference);
55
- if (view.route === "disabled") return { ...state, videos, priceText: "", priceNote: "", purchaseNote: "", hidePriceRetry: true };
76
+ if (view.route === "disabled") return { ...state, videos, priceText: "", priceNote: "", purchaseNote: "", hidePriceRetry: true, ...NO_BUY };
56
77
  const fields = iapPriceFields(view, copy);
57
- return { ...state, videos, priceText: fields.priceText, priceNote: fields.priceNote, purchaseNote: fields.actionNote,
78
+ const purchase = SELLS_THROUGH_APPLE ? commerce.purchaseFields(detailItem.reference, iapPurchaseCopy("video")) : NOT_APPLE;
79
+ if (purchase.accessReady) reloadOnceForAccess(state.id);
80
+ // No access for this video now (another member, or a new sale): its next grant reloads again.
81
+ else if (accessReload.id === state.id) accessReload = { id: "", at: 0, attempts: 0, settled: false };
82
+ return { ...state, videos, priceText: fields.priceText, priceNote: fields.priceNote,
83
+ // On the App Store route Buy and its own note replace "not available yet".
84
+ purchaseNote: purchase.appleRoute ? "" : fields.actionNote,
58
85
  // An incomplete host scope (a failed app-identity read) reads as non-retryable; Retry re-reads it.
59
- hidePriceRetry: fields.hidePriceRetry && commerce.scopeComplete() };
86
+ hidePriceRetry: fields.hidePriceRetry && commerce.scopeComplete(),
87
+ buyHidden: !purchase.appleRoute || purchase.accessReady, buyLabel: purchase.buyLabel, buyDisabled: purchase.buyDisabled, buyNote: purchase.buyNote };
88
+ }
89
+
90
+ /** A purchase being tracked polls faster; the directive is re-armed only when its interval changes. */
91
+ function withPoll(): { _poll?: unknown } {
92
+ const poll = SELLS_THROUGH_APPLE ? commerce.pollDirective("himiBrandedVideo.iapPoll") : undefined;
93
+ return poll ? { _poll: poll } : {};
94
+ }
95
+
96
+ /** Video says the member's purchase is ACTIVE: read the video again so the player replaces Buy. */
97
+ function reloadOnceForAccess(id: string): void {
98
+ if (!id) return;
99
+ const now = Date.now();
100
+ const same = accessReload.id === id;
101
+ if (same && (accessReload.settled || now - accessReload.at < ACCESS_RELOAD_RETRY_MS)) return;
102
+ const attempts = same ? accessReload.attempts + 1 : 1;
103
+ accessReload = { id, at: now, attempts, settled: attempts >= ACCESS_RELOAD_ATTEMPTS };
104
+ void svc.load();
105
+ }
106
+
107
+ /** First entry recovers held purchases; every later load (a return to the screen) reconciles. */
108
+ async function resumeCommerce(): Promise<void> {
109
+ if (!SELLS_THROUGH_APPLE) return;
110
+ const first = !commerceStarted;
111
+ commerceStarted = true;
112
+ await (first ? commerce.start() : commerce.reconcile());
113
+ void svc.publish();
114
+ }
115
+
116
+ /** The App Store sale of the locked video on screen, only through the shared checkout. */
117
+ async function buy(): Promise<undefined> {
118
+ const item = detailItem;
119
+ if (!SELLS_THROUGH_APPLE || !item) return undefined;
120
+ await commerce.buy({ reference: item.reference });
121
+ void svc.publish();
122
+ return undefined;
60
123
  }
61
124
  function unavailable(s: S, kind: S["playbackState"], message: string): S {
62
125
  return { ...s, ...loaded("videos", [], { ...COPY, empty: "" }), items: [], hidePlayer: true, hideNotFound: kind !== "unavailable", noEntity: kind === "unavailable", hideRefresh: kind === "unavailable", emptyText: "", message, playbackState: kind };
63
126
  }
64
- type Actions = { reset: (s: S) => S; publish: (s: S) => S; refreshPrice: (s: S) => Promise<undefined>; start: (s: S) => S; load: (s: S, arg?: unknown) => Promise<undefined> };
127
+ type Actions = {
128
+ reset: (s: S) => S; publish: (s: S) => S; refreshPrice: (s: S) => Promise<undefined>; start: (s: S) => S; load: (s: S, arg?: unknown) => Promise<undefined>;
129
+ buy: (s: S) => Promise<undefined>; iapPoll: (s: S) => Promise<undefined>;
130
+ };
65
131
  const svc = defineService<S, Actions>("himiBrandedVideo", {
66
132
  state: initial,
67
133
  notHydrated: Object.keys(initial) as (keyof S & string)[],
68
134
  actions: {
69
135
  reset: () => { shown = { ...initial }; detailItem = undefined; rowItems = []; return { ...initial }; },
70
136
  publish: () => priced(shown),
71
- start: () => ({ ...priced(shown), _poll: pricing.pollDirective("himiBrandedVideo.refreshPrice") } as S),
137
+ start: () => (SELLS_THROUGH_APPLE ? priced(shown) : { ...priced(shown), _poll: pricing.pollDirective("himiBrandedVideo.refreshPrice") } as S),
72
138
  refreshPrice: async () => { await priceContent(); return undefined; },
139
+ buy,
140
+ iapPoll: async () => { await commerce.poll(); void svc.publish(); return undefined; },
73
141
  load: async (_s, arg) => {
74
142
  stashCopy(arg);
75
143
  const request = ++generation;
@@ -130,11 +198,13 @@ const svc = defineService<S, Actions>("himiBrandedVideo", {
130
198
  { ...next, ...loadFailed("videos", error, COPY), playbackState: "error", items: [], hidePlayer: true };
131
199
  }
132
200
  if (request !== generation) return undefined;
201
+ if (accessReload.id === next.id && next.playbackState !== "error" && next.playbackState !== "denied") accessReload.settled = true;
133
202
  shown = next;
134
203
  detailItem = nextDetail;
135
204
  rowItems = nextRows;
136
205
  void svc.publish();
137
206
  void priceContent();
207
+ void resumeCommerce();
138
208
  return undefined;
139
209
  },
140
210
  },
@@ -17,7 +17,7 @@ import { stashCopy, copyParam, copyTemplate } from "../_shared/himi-copy.js";
17
17
  import { signInPageStyle, signInSheetStyle } from "../_shared/sign-in-sheet.js";
18
18
  import { memberAccountRoutes } from "../_shared/member-account-routes.js";
19
19
  import { CONTINUATION_BUDGET_MS, memberScreenTarget, within } from "../_shared/member-screen.js";
20
- import { createIapCommerce, onlineProgramOrders, pricingPlanOrders, storesAppleSalesEnabled, storesProductOrders } from "@himalaya/iap-checkout";
20
+ import { createIapCommerce, onlineProgramOrders, pricingPlanOrders, storesProductOrders } from "@himalaya/iap-checkout";
21
21
  import { IAP_RESTORE_KEYS, NO_IAP_RESTORE, createIapRestore, resetUnhydratedKeysOnOlderRuntime, type IapRestoreFields } from "../_shared/iap-worker.js";
22
22
 
23
23
  interface AuthRouteInput {
@@ -615,7 +615,7 @@ interface S extends IapRestoreFields {
615
615
  // row shows once purchasing is ready on this host (a bound iOS binary with managed StoreKit), to a
616
616
  // guest too: the restore itself asks them to sign in.
617
617
  const commerce = createIapCommerce({
618
- adapters: [onlineProgramOrders, pricingPlanOrders, ...(storesAppleSalesEnabled() ? [storesProductOrders] : [])],
618
+ adapters: [onlineProgramOrders, pricingPlanOrders, storesProductOrders],
619
619
  onChange: () => { void svc.restorePublish(); },
620
620
  });
621
621
  const restore = createIapRestore(commerce, { prefix: "storeAccount", repaint: () => { void svc.restorePublish(); } });
@@ -3,7 +3,7 @@ import { withOnlineWrites, offlineWritesEnabled, offlineWriteMessage } from "../
3
3
  import { defineService as registerState } from "@himalaya/state";
4
4
  // Tier-5 bundle: himi-store — product detail.
5
5
  import { withIapPresentation } from "../_shared/iap-presentation.js";
6
- import { storesAppleSalesEnabled, storesProductOrders, type IapCommerce, type IapPurchaseFields } from "@himalaya/iap-checkout";
6
+ import { storesProductOrders, type IapCommerce, type IapPurchaseFields } from "@himalaya/iap-checkout";
7
7
  import { iapPriceCopy, iapPurchaseCopy } from "../_shared/iap-worker.js";
8
8
  import { share as shareSheet } from "@himalaya/share";
9
9
  import { addToCurrentCart, getCurrentCart } from "@himalaya/wix-ecom";
@@ -451,10 +451,8 @@ function derive(s: S): S {
451
451
  // read answering late — must not replace the badge the add set (#3468 review).
452
452
  let cartBadgeEpoch = 0;
453
453
 
454
- // A digital product with no options sells through the App Store once the platform sells Wix Stores
455
- // items there (`storesAppleSalesEnabled`): wix-iap StartItemPayment places and charges its order.
456
- // Until then, and for any other product, an App Store route only blocks the regular checkout.
457
- const SELLS_THROUGH_APPLE = storesAppleSalesEnabled();
454
+ // A digital product with no options sells through the App Store: wix-iap StartItemPayment places and
455
+ // charges its order. For any other product, an App Store route only blocks the regular checkout.
458
456
  const WIX_STORES_APP = "215238eb-22a5-4c36-9e7b-e7c08025e04e";
459
457
  const NOT_APPLE: IapPurchaseFields = { appleRoute: false, accessReady: false, buyLabel: "", buyDisabled: true, buyBusy: false, buyNote: "" };
460
458
 
@@ -462,7 +460,7 @@ let productPricing: IapCommerce;
462
460
  let checkoutEntered = false;
463
461
  const registerProduct = withIapPresentation<S>({
464
462
  register: withOnlineWrites(registerState, ["beginAdd", "addToCart", "buy"], { derive, messageFields: action => action === "buy" ? ["buyNote"] : ["cartHint"] }),
465
- adapters: SELLS_THROUGH_APPLE ? [storesProductOrders] : [],
463
+ adapters: [storesProductOrders],
466
464
  onCreate: commerce => { productPricing = commerce; }, prefix: "product",
467
465
  transientKeys: ["optionValidationTarget", "optionValidationRequest", "opt1ScrollRequest", "opt2ScrollRequest", "opt3ScrollRequest", "galleryIndex", "price", "optionsIncomplete", "cartHint", "cartHidden", "buyHidden", "buyLabel", "buyDisabled", "buyNote", "purchasedNote", "addedSheetPresented", "shareHint"], contentActions: ["load", "readChanged"], concurrentPublishActions: ["buy"],
468
466
  items: state => inputId() ? [{ reference: { kind: "storesProduct", id: inputId() }, commerceDisplayPrice: state.price }] : [],
@@ -513,7 +511,7 @@ const defineService = withReadLifecycle(registerProduct, "load", {
513
511
  function applePurchase(state: S): IapPurchaseFields {
514
512
  const id = inputId();
515
513
  const loaded = !!id && lastLoadedId === id;
516
- const sellable = SELLS_THROUGH_APPLE && loaded && lastProduct?.productType?.toLowerCase() === "digital" && !state.optionsUnknown && state.optionGroups.length === 0;
514
+ const sellable = loaded && lastProduct?.productType?.toLowerCase() === "digital" && !state.optionsUnknown && state.optionGroups.length === 0;
517
515
  const copy = iapPurchaseCopy("product");
518
516
  const fields = sellable ? productPricing.purchaseFields({ kind: "storesProduct", id }, copy) : NOT_APPLE;
519
517
  return fields.appleRoute ? fields : NOT_APPLE;
@@ -521,7 +519,6 @@ function applePurchase(state: S): IapPurchaseFields {
521
519
 
522
520
  /** On every entry: the first starts the checkout (recovering held purchases), later ones reconcile. */
523
521
  function enterCheckout(): void {
524
- if (!SELLS_THROUGH_APPLE) return;
525
522
  void (checkoutEntered ? productPricing.reconcile() : productPricing.start());
526
523
  checkoutEntered = true;
527
524
  }
@@ -51,6 +51,19 @@ To review the map first, leave out `--apply`: the block is then only written to
51
51
  `config.ts` validates the block whenever the app loads, so an `http` origin, a duplicate id or a map
52
52
  with no tab fails `himi validate`, `himi render` and `himi push` rather than shipping.
53
53
 
54
+ ## Let your pages call the phone
55
+
56
+ A `webSdk` block in `provisioning.json` lets your site's pages call native features through the
57
+ web page SDK (`himi docs webview-page-sdk`):
58
+
59
+ ```json
60
+ "webSdk": { "capabilities": ["haptic", "share"] }
61
+ ```
62
+
63
+ `himi build` generates the worker that answers those calls, and `dev/index.ts` attaches it to every
64
+ page (`withSiteWebSdk`); `config.ts` adds the capabilities to the app, with any `permissionCopy`
65
+ wording for the ones that ask the user. Leave the block out and the pages call nothing native.
66
+
54
67
  ## Loop
55
68
 
56
69
  ```bash
@@ -14,7 +14,9 @@ import {
14
14
  siteNavKind,
15
15
  siteSidebar,
16
16
  siteNavConfig,
17
+ siteWebSdkCompanion,
17
18
  type SiteShellConfig,
19
+ type SiteWebSdk,
18
20
  } from "@himalaya/core";
19
21
  import { ConsoleTelemetrySink } from "@himalaya/telemetry-console";
20
22
  import provisioning from "./provisioning.json" with { type: "json" };
@@ -31,6 +33,16 @@ if (nav.tabs[0]?.screenId !== "site_home") {
31
33
  throw new Error('provisioning.json: the "home" page must be the first tab — list it first in site.pages');
32
34
  }
33
35
 
36
+ /** The native capabilities your website's pages may call (`webSdk` in provisioning.json), e.g.
37
+ * `{ "capabilities": ["haptic", "share"] }`. `himi build` generates the worker that answers those
38
+ * calls, and dev/index.ts attaches it to every page. Absent: the pages call nothing native. */
39
+ export const webSdk = (provisioning as { webSdk?: SiteWebSdk & { permissionCopy?: Record<string, string> } }).webSdk;
40
+ // What the pages' worker declares: the page channel (`webview`), the enabled capabilities and
41
+ // anything their SDKs call besides them (`iap` also calls `wix_api`), taken from the worker's own
42
+ // declaration so the app grants exactly that. `push` and `base44` are listed by the app already.
43
+ const pageCapabilities = (siteWebSdkCompanion(webSdk)?.declaredCapabilities ?? [])
44
+ .filter((id) => id !== "push" && id !== "base44");
45
+
34
46
  /** A Base44 site's app (`base44` in provisioning.json, or `bindings.base44`): members sign in on the
35
47
  * native Account screen, and the app carries the session into the website's pages. Absent for a
36
48
  * Wix site, which stays visitor-only. */
@@ -99,7 +111,9 @@ export default defineApp({
99
111
  },
100
112
  // `push` lets the app ask for notification permission and show the Notifications screen.
101
113
  // `base44` (a Base44 site only) lets the Account screen sign members in to your Base44 app.
102
- capabilities: ["push", ...(base44 ? ["base44"] : [])],
114
+ // Then whatever `webSdk` lets your pages call, with its permission wording.
115
+ capabilities: ["push", ...(base44 ? ["base44"] : []), ...pageCapabilities],
116
+ permissionCopy: webSdk?.permissionCopy,
103
117
  // The Base44 app the native sign-in and the website pages' session talk to (none for a Wix site).
104
118
  base44: base44Config,
105
119
  // Ask for notification permission on the first launch. Tapped notifications that carry one of
@@ -1,8 +1,9 @@
1
1
  // Your app's screens. Each one is a page of your website — a WebView screen built from the
2
2
  // `site` block of ../provisioning.json — so this file holds no screen of its own. Change the
3
- // pages by changing that block, never this file.
4
- import { siteScreens } from "@himalaya/core";
5
- import config, { base44, BASE44_ACCOUNT_SCREEN_ID, site } from "../config.js";
3
+ // pages by changing that block, never this file. When provisioning.json enables page
4
+ // capabilities (`webSdk`), every page gets the worker that answers them (`withSiteWebSdk`).
5
+ import { siteScreens, withSiteWebSdk } from "@himalaya/core";
6
+ import config, { base44, BASE44_ACCOUNT_SCREEN_ID, site, webSdk } from "../config.js";
6
7
 
7
8
  const SCREENS = siteScreens(site);
8
9
 
@@ -857,10 +858,11 @@ export default {
857
858
  config,
858
859
  homeScreenId: "site_home",
859
860
  screens: {
860
- // A fresh copy per build: descriptors are pure functions of the site block. A JSON round
861
- // trip, not structuredClone: `himi test` builds screens in the contained realm, which withholds it.
861
+ // A fresh copy per build: descriptors are pure functions of the site block (withSiteWebSdk
862
+ // copies, and attaches the page worker when `webSdk` enables capabilities). A JSON round trip,
863
+ // not structuredClone: `himi test` builds screens in the contained realm, which withholds it.
862
864
  exact: {
863
- ...Object.fromEntries(Object.keys(SCREENS).map((id) => [id, () => JSON.parse(JSON.stringify(SCREENS[id]))])),
865
+ ...Object.fromEntries(Object.keys(SCREENS).map((id) => [id, (ctx: Parameters<typeof withSiteWebSdk>[1]) => withSiteWebSdk(SCREENS[id]!, ctx, webSdk)])),
864
866
  himi_notification_settings: () => JSON.parse(JSON.stringify(NOTIFICATIONS)),
865
867
  ...Object.fromEntries(Object.entries(ACCOUNT).map(([id, screen]) => [id, () => JSON.parse(JSON.stringify(screen))])),
866
868
  },
@@ -869,6 +871,7 @@ export default {
869
871
  actions: [],
870
872
  createStore: () => ({}),
871
873
  // Every page is seeded, so the whole tab bar and drawer work on a cold offline start (each
872
- // WebView then shows its own offline state until the network returns).
874
+ // WebView then shows its own offline state until the network returns). The seed copy carries no
875
+ // page worker: the built worker's integrity is only known when the app is served.
873
876
  seed: { screens: { ...SCREENS, himi_notification_settings: NOTIFICATIONS_SEED, ...ACCOUNT }, data: {} },
874
877
  };
@@ -17,7 +17,7 @@ import { stashCopy, copyParam, copyTemplate } from "../_shared/himi-copy.js";
17
17
  import { signInPageStyle, signInSheetStyle } from "../_shared/sign-in-sheet.js";
18
18
  import { memberAccountRoutes } from "../_shared/member-account-routes.js";
19
19
  import { CONTINUATION_BUDGET_MS, memberScreenTarget, within } from "../_shared/member-screen.js";
20
- import { createIapCommerce, onlineProgramOrders, pricingPlanOrders, storesAppleSalesEnabled, storesProductOrders } from "@himalaya/iap-checkout";
20
+ import { createIapCommerce, onlineProgramOrders, pricingPlanOrders, storesProductOrders } from "@himalaya/iap-checkout";
21
21
  import { IAP_RESTORE_KEYS, NO_IAP_RESTORE, createIapRestore, resetUnhydratedKeysOnOlderRuntime, type IapRestoreFields } from "../_shared/iap-worker.js";
22
22
 
23
23
  interface AuthRouteInput {
@@ -615,7 +615,7 @@ interface S extends IapRestoreFields {
615
615
  // row shows once purchasing is ready on this host (a bound iOS binary with managed StoreKit), to a
616
616
  // guest too: the restore itself asks them to sign in.
617
617
  const commerce = createIapCommerce({
618
- adapters: [onlineProgramOrders, pricingPlanOrders, ...(storesAppleSalesEnabled() ? [storesProductOrders] : [])],
618
+ adapters: [onlineProgramOrders, pricingPlanOrders, storesProductOrders],
619
619
  onChange: () => { void svc.restorePublish(); },
620
620
  });
621
621
  const restore = createIapRestore(commerce, { prefix: "storeAccount", repaint: () => { void svc.restorePublish(); } });
@@ -17,7 +17,7 @@ import { stashCopy, copyParam, copyTemplate } from "../_shared/himi-copy.js";
17
17
  import { signInPageStyle, signInSheetStyle } from "../_shared/sign-in-sheet.js";
18
18
  import { memberAccountRoutes } from "../_shared/member-account-routes.js";
19
19
  import { CONTINUATION_BUDGET_MS, memberScreenTarget, within } from "../_shared/member-screen.js";
20
- import { createIapCommerce, onlineProgramOrders, pricingPlanOrders, storesAppleSalesEnabled, storesProductOrders } from "@himalaya/iap-checkout";
20
+ import { createIapCommerce, onlineProgramOrders, pricingPlanOrders, storesProductOrders } from "@himalaya/iap-checkout";
21
21
  import { IAP_RESTORE_KEYS, NO_IAP_RESTORE, createIapRestore, resetUnhydratedKeysOnOlderRuntime, type IapRestoreFields } from "../_shared/iap-worker.js";
22
22
 
23
23
  interface AuthRouteInput {
@@ -615,7 +615,7 @@ interface S extends IapRestoreFields {
615
615
  // row shows once purchasing is ready on this host (a bound iOS binary with managed StoreKit), to a
616
616
  // guest too: the restore itself asks them to sign in.
617
617
  const commerce = createIapCommerce({
618
- adapters: [onlineProgramOrders, pricingPlanOrders, ...(storesAppleSalesEnabled() ? [storesProductOrders] : [])],
618
+ adapters: [onlineProgramOrders, pricingPlanOrders, storesProductOrders],
619
619
  onChange: () => { void svc.restorePublish(); },
620
620
  });
621
621
  const restore = createIapRestore(commerce, { prefix: "storeAccount", repaint: () => { void svc.restorePublish(); } });
@@ -17,7 +17,7 @@ import { stashCopy, copyParam, copyTemplate } from "../_shared/himi-copy.js";
17
17
  import { signInPageStyle, signInSheetStyle } from "../_shared/sign-in-sheet.js";
18
18
  import { memberAccountRoutes } from "../_shared/member-account-routes.js";
19
19
  import { CONTINUATION_BUDGET_MS, memberScreenTarget, within } from "../_shared/member-screen.js";
20
- import { createIapCommerce, onlineProgramOrders, pricingPlanOrders, storesAppleSalesEnabled, storesProductOrders } from "@himalaya/iap-checkout";
20
+ import { createIapCommerce, onlineProgramOrders, pricingPlanOrders, storesProductOrders } from "@himalaya/iap-checkout";
21
21
  import { IAP_RESTORE_KEYS, NO_IAP_RESTORE, createIapRestore, resetUnhydratedKeysOnOlderRuntime, type IapRestoreFields } from "../_shared/iap-worker.js";
22
22
 
23
23
  interface AuthRouteInput {
@@ -615,7 +615,7 @@ interface S extends IapRestoreFields {
615
615
  // row shows once purchasing is ready on this host (a bound iOS binary with managed StoreKit), to a
616
616
  // guest too: the restore itself asks them to sign in.
617
617
  const commerce = createIapCommerce({
618
- adapters: [onlineProgramOrders, pricingPlanOrders, ...(storesAppleSalesEnabled() ? [storesProductOrders] : [])],
618
+ adapters: [onlineProgramOrders, pricingPlanOrders, storesProductOrders],
619
619
  onChange: () => { void svc.restorePublish(); },
620
620
  });
621
621
  const restore = createIapRestore(commerce, { prefix: "storeAccount", repaint: () => { void svc.restorePublish(); } });
@@ -17,7 +17,7 @@ import { stashCopy, copyParam, copyTemplate } from "../_shared/himi-copy.js";
17
17
  import { signInPageStyle, signInSheetStyle } from "../_shared/sign-in-sheet.js";
18
18
  import { memberAccountRoutes } from "../_shared/member-account-routes.js";
19
19
  import { CONTINUATION_BUDGET_MS, memberScreenTarget, within } from "../_shared/member-screen.js";
20
- import { createIapCommerce, onlineProgramOrders, pricingPlanOrders, storesAppleSalesEnabled, storesProductOrders } from "@himalaya/iap-checkout";
20
+ import { createIapCommerce, onlineProgramOrders, pricingPlanOrders, storesProductOrders } from "@himalaya/iap-checkout";
21
21
  import { IAP_RESTORE_KEYS, NO_IAP_RESTORE, createIapRestore, resetUnhydratedKeysOnOlderRuntime, type IapRestoreFields } from "../_shared/iap-worker.js";
22
22
 
23
23
  interface AuthRouteInput {
@@ -615,7 +615,7 @@ interface S extends IapRestoreFields {
615
615
  // row shows once purchasing is ready on this host (a bound iOS binary with managed StoreKit), to a
616
616
  // guest too: the restore itself asks them to sign in.
617
617
  const commerce = createIapCommerce({
618
- adapters: [onlineProgramOrders, pricingPlanOrders, ...(storesAppleSalesEnabled() ? [storesProductOrders] : [])],
618
+ adapters: [onlineProgramOrders, pricingPlanOrders, storesProductOrders],
619
619
  onChange: () => { void svc.restorePublish(); },
620
620
  });
621
621
  const restore = createIapRestore(commerce, { prefix: "storeAccount", repaint: () => { void svc.restorePublish(); } });
@@ -2,7 +2,7 @@ import { withOnlineWrites, offlineWritesEnabled, offlineWriteMessage } from "../
2
2
  import { defineService as registerState } from "@himalaya/state";
3
3
  // Tier-5 bundle: himi-store — product detail.
4
4
  import { withIapPresentation } from "../_shared/iap-presentation.js";
5
- import { storesAppleSalesEnabled, storesProductOrders, type IapCommerce, type IapPurchaseFields } from "@himalaya/iap-checkout";
5
+ import { storesProductOrders, type IapCommerce, type IapPurchaseFields } from "@himalaya/iap-checkout";
6
6
  import { iapPriceCopy, iapPurchaseCopy } from "../_shared/iap-worker.js";
7
7
  import { share as shareSheet } from "@himalaya/share";
8
8
  import { addToCurrentCart, getCurrentCart } from "@himalaya/wix-ecom";
@@ -466,10 +466,8 @@ function derive(s: S): S {
466
466
  // read answering late — must not replace the badge the add set (#3468 review).
467
467
  let cartBadgeEpoch = 0;
468
468
 
469
- // A digital product with no options sells through the App Store once the platform sells Wix Stores
470
- // items there (`storesAppleSalesEnabled`): wix-iap StartItemPayment places and charges its order.
471
- // Until then, and for any other product, an App Store route only blocks the regular checkout.
472
- const SELLS_THROUGH_APPLE = storesAppleSalesEnabled();
469
+ // A digital product with no options sells through the App Store: wix-iap StartItemPayment places and
470
+ // charges its order. For any other product, an App Store route only blocks the regular checkout.
473
471
  const WIX_STORES_APP = "215238eb-22a5-4c36-9e7b-e7c08025e04e";
474
472
  const NOT_APPLE: IapPurchaseFields = { appleRoute: false, accessReady: false, buyLabel: "", buyDisabled: true, buyBusy: false, buyNote: "" };
475
473
 
@@ -477,7 +475,7 @@ let productPricing: IapCommerce;
477
475
  let checkoutEntered = false;
478
476
  const defineService = withIapPresentation<S>({
479
477
  register: withOnlineWrites(registerState, ["beginAdd", "addToCart", "buy"], { derive, messageFields: action => action === "buy" ? ["buyNote"] : ["cartHint"] }),
480
- adapters: SELLS_THROUGH_APPLE ? [storesProductOrders] : [],
478
+ adapters: [storesProductOrders],
481
479
  onCreate: commerce => { productPricing = commerce; }, prefix: "product",
482
480
  transientKeys: ["optionValidationTarget", "optionValidationRequest", "opt1ScrollRequest", "opt2ScrollRequest", "opt3ScrollRequest", "galleryIndex", "price", "optionsIncomplete", "cartHint", "cartHidden", "buyHidden", "buyLabel", "buyDisabled", "buyNote", "purchasedNote", "addedSheetPresented", "shareHint"], contentActions: ["load", "paintCached"], concurrentPublishActions: ["buy"],
483
481
  items: state => inputId() ? [{ reference: { kind: "storesProduct", id: inputId() }, commerceDisplayPrice: state.price }] : [],
@@ -508,7 +506,7 @@ const defineService = withIapPresentation<S>({
508
506
  function applePurchase(state: S): IapPurchaseFields {
509
507
  const id = inputId();
510
508
  const loaded = !!id && lastLoadedId === id;
511
- const sellable = SELLS_THROUGH_APPLE && loaded && lastProduct?.productType?.toLowerCase() === "digital" && !state.optionsUnknown && state.optionGroups.length === 0;
509
+ const sellable = loaded && lastProduct?.productType?.toLowerCase() === "digital" && !state.optionsUnknown && state.optionGroups.length === 0;
512
510
  const copy = iapPurchaseCopy("product");
513
511
  const fields = sellable ? productPricing.purchaseFields({ kind: "storesProduct", id }, copy) : NOT_APPLE;
514
512
  return fields.appleRoute ? fields : NOT_APPLE;
@@ -516,7 +514,6 @@ function applePurchase(state: S): IapPurchaseFields {
516
514
 
517
515
  /** On every entry: the first starts the checkout (recovering held purchases), later ones reconcile. */
518
516
  function enterCheckout(): void {
519
- if (!SELLS_THROUGH_APPLE) return;
520
517
  void (checkoutEntered ? productPricing.reconcile() : productPricing.start());
521
518
  checkoutEntered = true;
522
519
  }
@@ -17,7 +17,7 @@ import { stashCopy, copyParam, copyTemplate } from "../_shared/himi-copy.js";
17
17
  import { signInPageStyle, signInSheetStyle } from "../_shared/sign-in-sheet.js";
18
18
  import { memberAccountRoutes } from "../_shared/member-account-routes.js";
19
19
  import { CONTINUATION_BUDGET_MS, memberScreenTarget, within } from "../_shared/member-screen.js";
20
- import { createIapCommerce, onlineProgramOrders, pricingPlanOrders, storesAppleSalesEnabled, storesProductOrders } from "@himalaya/iap-checkout";
20
+ import { createIapCommerce, onlineProgramOrders, pricingPlanOrders, storesProductOrders } from "@himalaya/iap-checkout";
21
21
  import { IAP_RESTORE_KEYS, NO_IAP_RESTORE, createIapRestore, resetUnhydratedKeysOnOlderRuntime, type IapRestoreFields } from "../_shared/iap-worker.js";
22
22
 
23
23
  interface AuthRouteInput {
@@ -615,7 +615,7 @@ interface S extends IapRestoreFields {
615
615
  // row shows once purchasing is ready on this host (a bound iOS binary with managed StoreKit), to a
616
616
  // guest too: the restore itself asks them to sign in.
617
617
  const commerce = createIapCommerce({
618
- adapters: [onlineProgramOrders, pricingPlanOrders, ...(storesAppleSalesEnabled() ? [storesProductOrders] : [])],
618
+ adapters: [onlineProgramOrders, pricingPlanOrders, storesProductOrders],
619
619
  onChange: () => { void svc.restorePublish(); },
620
620
  });
621
621
  const restore = createIapRestore(commerce, { prefix: "storeAccount", repaint: () => { void svc.restorePublish(); } });
@@ -17,7 +17,7 @@ import { stashCopy, copyParam, copyTemplate } from "../_shared/himi-copy.js";
17
17
  import { signInPageStyle, signInSheetStyle } from "../_shared/sign-in-sheet.js";
18
18
  import { memberAccountRoutes } from "../_shared/member-account-routes.js";
19
19
  import { CONTINUATION_BUDGET_MS, memberScreenTarget, within } from "../_shared/member-screen.js";
20
- import { createIapCommerce, onlineProgramOrders, pricingPlanOrders, storesAppleSalesEnabled, storesProductOrders } from "@himalaya/iap-checkout";
20
+ import { createIapCommerce, onlineProgramOrders, pricingPlanOrders, storesProductOrders } from "@himalaya/iap-checkout";
21
21
  import { IAP_RESTORE_KEYS, NO_IAP_RESTORE, createIapRestore, resetUnhydratedKeysOnOlderRuntime, type IapRestoreFields } from "../_shared/iap-worker.js";
22
22
 
23
23
  interface AuthRouteInput {
@@ -615,7 +615,7 @@ interface S extends IapRestoreFields {
615
615
  // row shows once purchasing is ready on this host (a bound iOS binary with managed StoreKit), to a
616
616
  // guest too: the restore itself asks them to sign in.
617
617
  const commerce = createIapCommerce({
618
- adapters: [onlineProgramOrders, pricingPlanOrders, ...(storesAppleSalesEnabled() ? [storesProductOrders] : [])],
618
+ adapters: [onlineProgramOrders, pricingPlanOrders, storesProductOrders],
619
619
  onChange: () => { void svc.restorePublish(); },
620
620
  });
621
621
  const restore = createIapRestore(commerce, { prefix: "storeAccount", repaint: () => { void svc.restorePublish(); } });
@@ -17,7 +17,7 @@ import { stashCopy, copyParam, copyTemplate } from "../_shared/himi-copy.js";
17
17
  import { signInPageStyle, signInSheetStyle } from "../_shared/sign-in-sheet.js";
18
18
  import { memberAccountRoutes } from "../_shared/member-account-routes.js";
19
19
  import { CONTINUATION_BUDGET_MS, memberScreenTarget, within } from "../_shared/member-screen.js";
20
- import { createIapCommerce, onlineProgramOrders, pricingPlanOrders, storesAppleSalesEnabled, storesProductOrders } from "@himalaya/iap-checkout";
20
+ import { createIapCommerce, onlineProgramOrders, pricingPlanOrders, storesProductOrders } from "@himalaya/iap-checkout";
21
21
  import { IAP_RESTORE_KEYS, NO_IAP_RESTORE, createIapRestore, resetUnhydratedKeysOnOlderRuntime, type IapRestoreFields } from "../_shared/iap-worker.js";
22
22
 
23
23
  interface AuthRouteInput {
@@ -615,7 +615,7 @@ interface S extends IapRestoreFields {
615
615
  // row shows once purchasing is ready on this host (a bound iOS binary with managed StoreKit), to a
616
616
  // guest too: the restore itself asks them to sign in.
617
617
  const commerce = createIapCommerce({
618
- adapters: [onlineProgramOrders, pricingPlanOrders, ...(storesAppleSalesEnabled() ? [storesProductOrders] : [])],
618
+ adapters: [onlineProgramOrders, pricingPlanOrders, storesProductOrders],
619
619
  onChange: () => { void svc.restorePublish(); },
620
620
  });
621
621
  const restore = createIapRestore(commerce, { prefix: "storeAccount", repaint: () => { void svc.restorePublish(); } });
@@ -2,7 +2,7 @@ import { withOnlineWrites, offlineWritesEnabled, offlineWriteMessage } from "../
2
2
  import { defineService as registerState } from "@himalaya/state";
3
3
  // Tier-5 bundle: himi-store — product detail.
4
4
  import { withIapPresentation } from "../_shared/iap-presentation.js";
5
- import { storesAppleSalesEnabled, storesProductOrders, type IapCommerce, type IapPurchaseFields } from "@himalaya/iap-checkout";
5
+ import { storesProductOrders, type IapCommerce, type IapPurchaseFields } from "@himalaya/iap-checkout";
6
6
  import { iapPriceCopy, iapPurchaseCopy } from "../_shared/iap-worker.js";
7
7
  import { share as shareSheet } from "@himalaya/share";
8
8
  import { addToCurrentCart, getCurrentCart } from "@himalaya/wix-ecom";
@@ -466,10 +466,8 @@ function derive(s: S): S {
466
466
  // read answering late — must not replace the badge the add set (#3468 review).
467
467
  let cartBadgeEpoch = 0;
468
468
 
469
- // A digital product with no options sells through the App Store once the platform sells Wix Stores
470
- // items there (`storesAppleSalesEnabled`): wix-iap StartItemPayment places and charges its order.
471
- // Until then, and for any other product, an App Store route only blocks the regular checkout.
472
- const SELLS_THROUGH_APPLE = storesAppleSalesEnabled();
469
+ // A digital product with no options sells through the App Store: wix-iap StartItemPayment places and
470
+ // charges its order. For any other product, an App Store route only blocks the regular checkout.
473
471
  const WIX_STORES_APP = "215238eb-22a5-4c36-9e7b-e7c08025e04e";
474
472
  const NOT_APPLE: IapPurchaseFields = { appleRoute: false, accessReady: false, buyLabel: "", buyDisabled: true, buyBusy: false, buyNote: "" };
475
473
 
@@ -477,7 +475,7 @@ let productPricing: IapCommerce;
477
475
  let checkoutEntered = false;
478
476
  const defineService = withIapPresentation<S>({
479
477
  register: withOnlineWrites(registerState, ["beginAdd", "addToCart", "buy"], { derive, messageFields: action => action === "buy" ? ["buyNote"] : ["cartHint"] }),
480
- adapters: SELLS_THROUGH_APPLE ? [storesProductOrders] : [],
478
+ adapters: [storesProductOrders],
481
479
  onCreate: commerce => { productPricing = commerce; }, prefix: "product",
482
480
  transientKeys: ["optionValidationTarget", "optionValidationRequest", "opt1ScrollRequest", "opt2ScrollRequest", "opt3ScrollRequest", "galleryIndex", "price", "optionsIncomplete", "cartHint", "cartHidden", "buyHidden", "buyLabel", "buyDisabled", "buyNote", "purchasedNote", "addedSheetPresented", "shareHint"], contentActions: ["load", "paintCached"], concurrentPublishActions: ["buy"],
483
481
  items: state => inputId() ? [{ reference: { kind: "storesProduct", id: inputId() }, commerceDisplayPrice: state.price }] : [],
@@ -508,7 +506,7 @@ const defineService = withIapPresentation<S>({
508
506
  function applePurchase(state: S): IapPurchaseFields {
509
507
  const id = inputId();
510
508
  const loaded = !!id && lastLoadedId === id;
511
- const sellable = SELLS_THROUGH_APPLE && loaded && lastProduct?.productType?.toLowerCase() === "digital" && !state.optionsUnknown && state.optionGroups.length === 0;
509
+ const sellable = loaded && lastProduct?.productType?.toLowerCase() === "digital" && !state.optionsUnknown && state.optionGroups.length === 0;
512
510
  const copy = iapPurchaseCopy("product");
513
511
  const fields = sellable ? productPricing.purchaseFields({ kind: "storesProduct", id }, copy) : NOT_APPLE;
514
512
  return fields.appleRoute ? fields : NOT_APPLE;
@@ -516,7 +514,6 @@ function applePurchase(state: S): IapPurchaseFields {
516
514
 
517
515
  /** On every entry: the first starts the checkout (recovering held purchases), later ones reconcile. */
518
516
  function enterCheckout(): void {
519
- if (!SELLS_THROUGH_APPLE) return;
520
517
  void (checkoutEntered ? productPricing.reconcile() : productPricing.start());
521
518
  checkoutEntered = true;
522
519
  }
@@ -17,7 +17,7 @@ import { stashCopy, copyParam, copyTemplate } from "../_shared/himi-copy.js";
17
17
  import { signInPageStyle, signInSheetStyle } from "../_shared/sign-in-sheet.js";
18
18
  import { memberAccountRoutes } from "../_shared/member-account-routes.js";
19
19
  import { CONTINUATION_BUDGET_MS, memberScreenTarget, within } from "../_shared/member-screen.js";
20
- import { createIapCommerce, onlineProgramOrders, pricingPlanOrders, storesAppleSalesEnabled, storesProductOrders } from "@himalaya/iap-checkout";
20
+ import { createIapCommerce, onlineProgramOrders, pricingPlanOrders, storesProductOrders } from "@himalaya/iap-checkout";
21
21
  import { IAP_RESTORE_KEYS, NO_IAP_RESTORE, createIapRestore, resetUnhydratedKeysOnOlderRuntime, type IapRestoreFields } from "../_shared/iap-worker.js";
22
22
 
23
23
  interface AuthRouteInput {
@@ -615,7 +615,7 @@ interface S extends IapRestoreFields {
615
615
  // row shows once purchasing is ready on this host (a bound iOS binary with managed StoreKit), to a
616
616
  // guest too: the restore itself asks them to sign in.
617
617
  const commerce = createIapCommerce({
618
- adapters: [onlineProgramOrders, pricingPlanOrders, ...(storesAppleSalesEnabled() ? [storesProductOrders] : [])],
618
+ adapters: [onlineProgramOrders, pricingPlanOrders, storesProductOrders],
619
619
  onChange: () => { void svc.restorePublish(); },
620
620
  });
621
621
  const restore = createIapRestore(commerce, { prefix: "storeAccount", repaint: () => { void svc.restorePublish(); } });
@@ -17,7 +17,7 @@ import { stashCopy, copyParam, copyTemplate } from "../_shared/himi-copy.js";
17
17
  import { signInPageStyle, signInSheetStyle } from "../_shared/sign-in-sheet.js";
18
18
  import { memberAccountRoutes } from "../_shared/member-account-routes.js";
19
19
  import { CONTINUATION_BUDGET_MS, memberScreenTarget, within } from "../_shared/member-screen.js";
20
- import { createIapCommerce, onlineProgramOrders, pricingPlanOrders, storesAppleSalesEnabled, storesProductOrders } from "@himalaya/iap-checkout";
20
+ import { createIapCommerce, onlineProgramOrders, pricingPlanOrders, storesProductOrders } from "@himalaya/iap-checkout";
21
21
  import { IAP_RESTORE_KEYS, NO_IAP_RESTORE, createIapRestore, resetUnhydratedKeysOnOlderRuntime, type IapRestoreFields } from "../_shared/iap-worker.js";
22
22
 
23
23
  interface AuthRouteInput {
@@ -615,7 +615,7 @@ interface S extends IapRestoreFields {
615
615
  // row shows once purchasing is ready on this host (a bound iOS binary with managed StoreKit), to a
616
616
  // guest too: the restore itself asks them to sign in.
617
617
  const commerce = createIapCommerce({
618
- adapters: [onlineProgramOrders, pricingPlanOrders, ...(storesAppleSalesEnabled() ? [storesProductOrders] : [])],
618
+ adapters: [onlineProgramOrders, pricingPlanOrders, storesProductOrders],
619
619
  onChange: () => { void svc.restorePublish(); },
620
620
  });
621
621
  const restore = createIapRestore(commerce, { prefix: "storeAccount", repaint: () => { void svc.restorePublish(); } });