@wix/himalaya-cli 0.1642.0 → 0.1644.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 (118) hide show
  1. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/schema.d.ts +6 -0
  2. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/validator.d.ts +3 -0
  3. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/core.mjs +3 -1
  4. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/sdui.mjs +3 -1
  5. package/dist/browser-plane/assets.json +5 -5
  6. package/dist/browser-plane/preview-deferred/{3361f61ce6b490c8b7b252658ea67f733d88c6e9f95906d0e31eea4827141df3.bin → 155f61519885c85d61a39fa595197071a3ca07680da56055ccb1dcff2e709cd1.bin} +1 -1
  7. package/dist/browser-plane/sw.js +6 -6
  8. package/dist/cli.mjs +358 -144
  9. package/dist/preview-assets.generated.bin +0 -0
  10. package/guides/component-reference.json +1 -1
  11. package/guides/component-reference.md +6 -0
  12. package/guides/designing-himi-screens.md +18 -0
  13. package/guides/offline-reading.md +1 -1
  14. package/guides/recipe-four-state.md +17 -0
  15. package/guides/release-notes.md +21 -0
  16. package/guides/sdk-reference.json +1 -1
  17. package/package.json +2 -2
  18. package/template-icons/conference.png +0 -0
  19. package/templates/beauty-salon/tier5-src/_shared/iap-presentation.ts +5 -2
  20. package/templates/beauty-salon/tier5-src/himi-store-product/index.ts +6 -3
  21. package/templates/branded-lite/dev/index.ts +152 -88
  22. package/templates/branded-lite/l10n/en.json +1 -1
  23. package/templates/branded-lite/tier5-src/_shared/featured-event.ts +63 -0
  24. package/templates/branded-lite/tier5-src/_shared/iap-presentation.ts +5 -2
  25. package/templates/branded-lite/tier5-src/himi-events-detail/index.ts +93 -11
  26. package/templates/branded-lite/tier5-src/himi-store-product/index.ts +7 -3
  27. package/templates/community-club/dev/index.ts +152 -88
  28. package/templates/community-club/tier5-src/_shared/featured-event.ts +63 -0
  29. package/templates/community-club/tier5-src/_shared/iap-presentation.ts +5 -2
  30. package/templates/community-club/tier5-src/himi-events-detail/index.ts +93 -11
  31. package/templates/conference/README.md +53 -0
  32. package/templates/conference/config.ts +321 -0
  33. package/templates/conference/dev/index.ts +17252 -0
  34. package/templates/conference/himalaya.content.json +46 -0
  35. package/templates/conference/himalaya.template.json +15 -0
  36. package/templates/conference/icon.png +0 -0
  37. package/templates/conference/platforms.json +1 -0
  38. package/templates/conference/tier5-src/_shared/agenda-stars.ts +64 -0
  39. package/templates/conference/tier5-src/_shared/app-locale.ts +61 -0
  40. package/templates/conference/tier5-src/_shared/branded-lite-hosted.ts +279 -0
  41. package/templates/conference/tier5-src/_shared/branded-load-state.ts +109 -0
  42. package/templates/conference/tier5-src/_shared/business-chat-copy.ts +40 -0
  43. package/templates/conference/tier5-src/_shared/business-chat-history.ts +51 -0
  44. package/templates/conference/tier5-src/_shared/business-chat-message-model.ts +177 -0
  45. package/templates/conference/tier5-src/_shared/business-chat-model.ts +56 -0
  46. package/templates/conference/tier5-src/_shared/business-chat-presenter.ts +576 -0
  47. package/templates/conference/tier5-src/_shared/business-chat-transport.ts +148 -0
  48. package/templates/conference/tier5-src/_shared/collection-contract.ts +229 -0
  49. package/templates/conference/tier5-src/_shared/collection-query.ts +193 -0
  50. package/templates/conference/tier5-src/_shared/collection-service.ts +400 -0
  51. package/templates/conference/tier5-src/_shared/engine-intl.ts +508 -0
  52. package/templates/conference/tier5-src/_shared/event-agenda.ts +122 -0
  53. package/templates/conference/tier5-src/_shared/event-registration.ts +86 -0
  54. package/templates/conference/tier5-src/_shared/featured-event.ts +63 -0
  55. package/templates/conference/tier5-src/_shared/himi-account.ts +164 -0
  56. package/templates/conference/tier5-src/_shared/himi-copy.ts +89 -0
  57. package/templates/conference/tier5-src/_shared/himi-events.ts +65 -0
  58. package/templates/conference/tier5-src/_shared/himi-store.ts +7 -0
  59. package/templates/conference/tier5-src/_shared/hosted-checkout.ts +70 -0
  60. package/templates/conference/tier5-src/_shared/iap-attendance-form.ts +106 -0
  61. package/templates/conference/tier5-src/_shared/iap-attendance-purchase.ts +211 -0
  62. package/templates/conference/tier5-src/_shared/iap-attendance.ts +38 -0
  63. package/templates/conference/tier5-src/_shared/iap-worker.ts +125 -0
  64. package/templates/conference/tier5-src/_shared/inbox-rooms.ts +68 -0
  65. package/templates/conference/tier5-src/_shared/local-preferences.ts +38 -0
  66. package/templates/conference/tier5-src/_shared/member-access.ts +52 -0
  67. package/templates/conference/tier5-src/_shared/member-account-routes.ts +52 -0
  68. package/templates/conference/tier5-src/_shared/member-read.ts +52 -0
  69. package/templates/conference/tier5-src/_shared/member-screen.ts +99 -0
  70. package/templates/conference/tier5-src/_shared/offset-page.ts +10 -0
  71. package/templates/conference/tier5-src/_shared/online-actions.ts +76 -0
  72. package/templates/conference/tier5-src/_shared/owner-load-error.ts +348 -0
  73. package/templates/conference/tier5-src/_shared/payment-setup.ts +6 -0
  74. package/templates/conference/tier5-src/_shared/rich-body.ts +78 -0
  75. package/templates/conference/tier5-src/_shared/rich-content-link.ts +34 -0
  76. package/templates/conference/tier5-src/_shared/sign-in-sheet.ts +18 -0
  77. package/templates/conference/tier5-src/business-chat/index.ts +724 -0
  78. package/templates/conference/tier5-src/himi-conference-agenda/index.ts +183 -0
  79. package/templates/conference/tier5-src/himi-conference-home/index.ts +389 -0
  80. package/templates/conference/tier5-src/himi-events-account/index.ts +219 -0
  81. package/templates/conference/tier5-src/himi-events-detail/index.ts +1304 -0
  82. package/templates/conference/tier5-src/himi-events-list/index.ts +124 -0
  83. package/templates/conference/tier5-src/himi-events-my-events/index.ts +225 -0
  84. package/templates/conference/tier5-src/himi-events-rsvp/index.ts +230 -0
  85. package/templates/conference/tier5-src/himi-store-account/index.ts +998 -0
  86. package/templates/conference/tokens.json +365 -0
  87. package/templates/events-meetups/dev/index.ts +152 -88
  88. package/templates/events-meetups/tier5-src/_shared/featured-event.ts +63 -0
  89. package/templates/events-meetups/tier5-src/_shared/iap-presentation.ts +5 -2
  90. package/templates/events-meetups/tier5-src/himi-events-detail/index.ts +93 -11
  91. package/templates/gym-fitness/dev/index.ts +152 -88
  92. package/templates/gym-fitness/tier5-src/_shared/featured-event.ts +63 -0
  93. package/templates/gym-fitness/tier5-src/_shared/iap-presentation.ts +5 -2
  94. package/templates/gym-fitness/tier5-src/himi-events-detail/index.ts +93 -11
  95. package/templates/gym-fitness/tier5-src/himi-store-product/index.ts +6 -3
  96. package/templates/nonprofit-cause/dev/index.ts +152 -88
  97. package/templates/nonprofit-cause/tier5-src/_shared/featured-event.ts +63 -0
  98. package/templates/nonprofit-cause/tier5-src/_shared/iap-presentation.ts +5 -2
  99. package/templates/nonprofit-cause/tier5-src/himi-events-detail/index.ts +93 -11
  100. package/templates/podcast-creator/dev/index.ts +152 -88
  101. package/templates/podcast-creator/tier5-src/_shared/featured-event.ts +63 -0
  102. package/templates/podcast-creator/tier5-src/_shared/iap-presentation.ts +5 -2
  103. package/templates/podcast-creator/tier5-src/himi-events-detail/index.ts +93 -11
  104. package/templates/portfolio-creative/dev/index.ts +152 -88
  105. package/templates/portfolio-creative/tier5-src/_shared/featured-event.ts +63 -0
  106. package/templates/portfolio-creative/tier5-src/_shared/iap-presentation.ts +5 -2
  107. package/templates/portfolio-creative/tier5-src/himi-events-detail/index.ts +93 -11
  108. package/templates/portfolio-creative/tier5-src/himi-store-product/index.ts +6 -3
  109. package/templates/restaurant/dev/index.ts +152 -88
  110. package/templates/restaurant/tier5-src/_shared/featured-event.ts +63 -0
  111. package/templates/restaurant/tier5-src/_shared/iap-presentation.ts +5 -2
  112. package/templates/restaurant/tier5-src/himi-events-detail/index.ts +93 -11
  113. package/templates/retail-store/tier5-src/_shared/iap-presentation.ts +5 -2
  114. package/templates/retail-store/tier5-src/himi-store-product/index.ts +7 -3
  115. package/templates/yoga-studio/dev/index.ts +152 -88
  116. package/templates/yoga-studio/tier5-src/_shared/featured-event.ts +63 -0
  117. package/templates/yoga-studio/tier5-src/_shared/iap-presentation.ts +5 -2
  118. package/templates/yoga-studio/tier5-src/himi-events-detail/index.ts +93 -11
@@ -481,16 +481,19 @@ const defineService = withIapPresentation<S>({
481
481
  onCreate: commerce => { productPricing = commerce; }, prefix: "product",
482
482
  transientKeys: ["optionValidationTarget", "optionValidationRequest", "opt1ScrollRequest", "opt2ScrollRequest", "opt3ScrollRequest", "galleryIndex", "price", "optionsIncomplete", "cartHint", "cartHidden", "buyHidden", "buyLabel", "buyDisabled", "buyNote", "purchasedNote", "addedSheetPresented", "shareHint"], contentActions: ["load", "paintCached"], concurrentPublishActions: ["buy"],
483
483
  items: state => inputId() ? [{ reference: { kind: "storesProduct", id: inputId() }, commerceDisplayPrice: state.price }] : [],
484
- present: (state, price, allowed) => {
484
+ present: (state, price, allowed, _appleIapOrResolving, resolving) => {
485
485
  const purchase = applePurchase(state);
486
486
  const unavailable = iapPriceCopy("product").purchaseUnavailable;
487
- const blocked = lastProduct?.productType?.toLowerCase() === "digital" || (!state.optionsUnknown && !allowed(inputId()));
487
+ // A guard still resolving is loading, not a refusal (the core worker's rule, #5451): no
488
+ // "Purchasing is not available yet." until a final route blocks the purchase.
489
+ const pending = !state.optionsUnknown && resolving(inputId());
490
+ const blocked = lastProduct?.productType?.toLowerCase() === "digital" || (!state.optionsUnknown && !pending && !allowed(inputId()));
488
491
  const cartHint = state.cartHint === offlineWriteMessage ? state.cartHint
489
492
  : !purchase.appleRoute && blocked ? unavailable : state.cartHint === unavailable ? "" : state.cartHint;
490
493
  const productState = derive(state);
491
494
  return {
492
495
  ...state, price: price(inputId()), ...(purchase.appleRoute ? { wasPrice: "", wasPriceEmpty: false, notOnSale: true } : {}), optionsIncomplete: productState.optionsIncomplete || !allowed(inputId()) || lastProduct?.productType?.toLowerCase() === "digital",
493
- cartHint, noCartHint: !cartHint || state.added, addDisabled: productState.addDisabled || blocked,
496
+ cartHint, noCartHint: !cartHint || state.added, addDisabled: productState.addDisabled || blocked || pending,
494
497
  cartHidden: purchase.appleRoute,
495
498
  buyHidden: !purchase.appleRoute || purchase.accessReady, buyLabel: purchase.buyLabel, buyDisabled: purchase.buyDisabled,
496
499
  buyNote: state.buyNote === offlineWriteMessage ? state.buyNote : purchase.buyNote,
@@ -17185,6 +17185,7 @@ const SCREENS = runtimeSetting({
17185
17185
  "type": "HStack",
17186
17186
  "props": {
17187
17187
  "spacing": 10,
17188
+ "alignment": "center",
17188
17189
  "children": [
17189
17190
  {
17190
17191
  "id": "",
@@ -17198,7 +17199,8 @@ const SCREENS = runtimeSetting({
17198
17199
  }
17199
17200
  },
17200
17201
  "modifiers": {
17201
- "accessibilityRole": "decorative"
17202
+ "accessibilityRole": "decorative",
17203
+ "hiddenPath": "$service:himiMyEvents.signInRequired"
17202
17204
  }
17203
17205
  },
17204
17206
  {
@@ -17210,6 +17212,39 @@ const SCREENS = runtimeSetting({
17210
17212
  "text": "Something did not load.",
17211
17213
  "style": "bodyEmphasis"
17212
17214
  }
17215
+ },
17216
+ "modifiers": {
17217
+ "hiddenPath": "$service:himiMyEvents.signInRequired"
17218
+ }
17219
+ },
17220
+ {
17221
+ "id": "",
17222
+ "body": {
17223
+ "package": "himalaya",
17224
+ "type": "Icon",
17225
+ "props": {
17226
+ "name": "person",
17227
+ "size": 18,
17228
+ "tint": "textSecondary"
17229
+ }
17230
+ },
17231
+ "modifiers": {
17232
+ "accessibilityRole": "decorative",
17233
+ "hiddenPath": "$service:himiMyEvents.noSignIn"
17234
+ }
17235
+ },
17236
+ {
17237
+ "id": "",
17238
+ "body": {
17239
+ "package": "himalaya",
17240
+ "type": "Text",
17241
+ "props": {
17242
+ "text": "Sign in to see your events.",
17243
+ "style": "bodyEmphasis"
17244
+ }
17245
+ },
17246
+ "modifiers": {
17247
+ "hiddenPath": "$service:himiMyEvents.noSignIn"
17213
17248
  }
17214
17249
  }
17215
17250
  ]
@@ -24463,12 +24498,19 @@ const TEMPLATED: { pattern: string; display: string; liveSeed?: LiveSeed; static
24463
24498
  }
24464
24499
  },
24465
24500
  {
24466
- "id": "",
24501
+ "id": "himi_event.full_schedule",
24467
24502
  "body": {
24468
24503
  "package": "himalaya",
24469
24504
  "type": "DisclosureGroup",
24470
24505
  "props": {
24471
24506
  "title": "See Full Schedule",
24507
+ "expandedPath": "$service:himiEventDetail.fullScheduleOpen",
24508
+ "onToggle": {
24509
+ "actionId": "tier5.himiEventDetail.toggleDisclosure",
24510
+ "params": {
24511
+ "id": "fullSchedule"
24512
+ }
24513
+ },
24472
24514
  "content": [
24473
24515
  {
24474
24516
  "id": "",
@@ -24654,12 +24696,19 @@ const TEMPLATED: { pattern: string; display: string; liveSeed?: LiveSeed; static
24654
24696
  }
24655
24697
  },
24656
24698
  {
24657
- "id": "",
24699
+ "id": "himi_event.all_dates",
24658
24700
  "body": {
24659
24701
  "package": "himalaya",
24660
24702
  "type": "DisclosureGroup",
24661
24703
  "props": {
24662
24704
  "title": "See All Dates",
24705
+ "expandedPath": "$service:himiEventDetail.allDatesOpen",
24706
+ "onToggle": {
24707
+ "actionId": "tier5.himiEventDetail.toggleDisclosure",
24708
+ "params": {
24709
+ "id": "allDates"
24710
+ }
24711
+ },
24663
24712
  "content": [
24664
24713
  {
24665
24714
  "id": "",
@@ -24755,6 +24804,13 @@ const TEMPLATED: { pattern: string; display: string; liveSeed?: LiveSeed; static
24755
24804
  "type": "DisclosureGroup",
24756
24805
  "props": {
24757
24806
  "title": "Policies",
24807
+ "expandedPath": "$service:himiEventDetail.policiesOpen",
24808
+ "onToggle": {
24809
+ "actionId": "tier5.himiEventDetail.toggleDisclosure",
24810
+ "params": {
24811
+ "id": "policies"
24812
+ }
24813
+ },
24758
24814
  "content": [
24759
24815
  {
24760
24816
  "id": "",
@@ -24903,8 +24959,7 @@ const TEMPLATED: { pattern: string; display: string; liveSeed?: LiveSeed; static
24903
24959
  "props": {
24904
24960
  "presentedPath": "$service:himiEventDetail.ticketSheetOpen",
24905
24961
  "detents": [
24906
- 0.48,
24907
- 0.9
24962
+ 0.62
24908
24963
  ],
24909
24964
  "showGrabber": true,
24910
24965
  "dismissible": true,
@@ -24974,6 +25029,89 @@ const TEMPLATED: { pattern: string; display: string; liveSeed?: LiveSeed; static
24974
25029
  }
24975
25030
  }
24976
25031
  },
25032
+ {
25033
+ "id": "himi_event.ticket_summary",
25034
+ "body": {
25035
+ "package": "himalaya",
25036
+ "type": "VStack",
25037
+ "props": {
25038
+ "spacing": 8,
25039
+ "children": [
25040
+ {
25041
+ "id": "",
25042
+ "body": {
25043
+ "package": "himalaya",
25044
+ "type": "Text",
25045
+ "props": {
25046
+ "text": "$service:himiEventDetail.ticketCountLabel",
25047
+ "style": "caption",
25048
+ "color": "textSecondary"
25049
+ }
25050
+ }
25051
+ },
25052
+ {
25053
+ "id": "",
25054
+ "body": {
25055
+ "package": "himalaya",
25056
+ "type": "HStack",
25057
+ "props": {
25058
+ "spacing": 12,
25059
+ "alignment": "center",
25060
+ "children": [
25061
+ {
25062
+ "id": "",
25063
+ "body": {
25064
+ "package": "himalaya",
25065
+ "type": "Text",
25066
+ "props": {
25067
+ "text": "$service:himiEventDetail.ticketTotal",
25068
+ "style": "title3",
25069
+ "monospacedDigits": true
25070
+ }
25071
+ }
25072
+ },
25073
+ {
25074
+ "id": "",
25075
+ "body": {
25076
+ "package": "himalaya",
25077
+ "type": "Spacer",
25078
+ "props": {}
25079
+ }
25080
+ },
25081
+ {
25082
+ "id": "himi_event.checkout",
25083
+ "body": {
25084
+ "package": "himalaya",
25085
+ "type": "Button",
25086
+ "props": {
25087
+ "title": "Checkout",
25088
+ "style": "primary",
25089
+ "disabledPath": "$service:himiEventDetail.checkoutDisabled",
25090
+ "action": {
25091
+ "actionId": "tier5.himiEventDetail.checkout"
25092
+ }
25093
+ }
25094
+ }
25095
+ }
25096
+ ]
25097
+ }
25098
+ }
25099
+ },
25100
+ {
25101
+ "id": "",
25102
+ "body": {
25103
+ "package": "himalaya",
25104
+ "type": "Divider",
25105
+ "props": {}
25106
+ }
25107
+ }
25108
+ ]
25109
+ }
25110
+ },
25111
+ "modifiers": {
25112
+ "hiddenPath": "$service:himiEventDetail.regularTicketsHidden"
25113
+ }
25114
+ },
24977
25115
  {
24978
25116
  "id": "",
24979
25117
  "body": {
@@ -25073,12 +25211,20 @@ const TEMPLATED: { pattern: string; display: string; liveSeed?: LiveSeed; static
25073
25211
  }
25074
25212
  },
25075
25213
  {
25076
- "id": "",
25214
+ "id": "himi_event.ticket_terms",
25077
25215
  "body": {
25078
25216
  "package": "himalaya",
25079
25217
  "type": "DisclosureGroup",
25080
25218
  "props": {
25081
25219
  "title": "Ticket terms",
25220
+ "expandedPath": "$item.termsOpen",
25221
+ "onToggle": {
25222
+ "actionId": "tier5.himiEventDetail.toggleDisclosure",
25223
+ "params": {
25224
+ "id": "terms",
25225
+ "tier": "$item.id"
25226
+ }
25227
+ },
25082
25228
  "content": [
25083
25229
  {
25084
25230
  "id": "",
@@ -25593,88 +25739,6 @@ const TEMPLATED: { pattern: string; display: string; liveSeed?: LiveSeed; static
25593
25739
  "modifiers": {
25594
25740
  "hiddenPath": "$service:himiEventDetail.iapBuyHidden"
25595
25741
  }
25596
- },
25597
- {
25598
- "id": "",
25599
- "body": {
25600
- "package": "himalaya",
25601
- "type": "VStack",
25602
- "props": {
25603
- "spacing": 8,
25604
- "children": [
25605
- {
25606
- "id": "",
25607
- "body": {
25608
- "package": "himalaya",
25609
- "type": "Divider",
25610
- "props": {}
25611
- }
25612
- },
25613
- {
25614
- "id": "",
25615
- "body": {
25616
- "package": "himalaya",
25617
- "type": "Text",
25618
- "props": {
25619
- "text": "$service:himiEventDetail.ticketCountLabel",
25620
- "style": "caption",
25621
- "color": "textSecondary"
25622
- }
25623
- }
25624
- },
25625
- {
25626
- "id": "",
25627
- "body": {
25628
- "package": "himalaya",
25629
- "type": "HStack",
25630
- "props": {
25631
- "spacing": 12,
25632
- "children": [
25633
- {
25634
- "id": "",
25635
- "body": {
25636
- "package": "himalaya",
25637
- "type": "Text",
25638
- "props": {
25639
- "text": "$service:himiEventDetail.ticketTotal",
25640
- "style": "title3",
25641
- "monospacedDigits": true
25642
- }
25643
- }
25644
- },
25645
- {
25646
- "id": "",
25647
- "body": {
25648
- "package": "himalaya",
25649
- "type": "Spacer",
25650
- "props": {}
25651
- }
25652
- },
25653
- {
25654
- "id": "btn_tier5_himieventdetail_checkout",
25655
- "body": {
25656
- "package": "himalaya",
25657
- "type": "Button",
25658
- "props": {
25659
- "title": "Checkout",
25660
- "style": "primary",
25661
- "disabledPath": "$service:himiEventDetail.checkoutDisabled",
25662
- "action": {
25663
- "actionId": "tier5.himiEventDetail.checkout"
25664
- }
25665
- }
25666
- }
25667
- }
25668
- ]
25669
- }
25670
- }
25671
- }
25672
- ]
25673
- }
25674
- },
25675
- "modifiers": {
25676
- "hiddenPath": "$service:himiEventDetail.regularTicketsHidden"
25677
- }
25678
25742
  }
25679
25743
  ]
25680
25744
  }
@@ -0,0 +1,63 @@
1
+ // The site's featured event: the one on now, else the next one to start. A conference app is
2
+ // about one event at a time — its Home hero, its Tickets tab and its Agenda all show this one —
3
+ // and a site with several events reaches the rest from the events list.
4
+ //
5
+ // Read from the visitor-readable Events v3 query. "None" (no live or upcoming event) is a real
6
+ // answer, distinct from a failed read: the caller shows an empty state for the first and an
7
+ // error with Retry for the second, never a sample event.
8
+ import { queryEvents, startDateOf, endDateOf, type WixEvent, type WixEventFieldset } from "@himalaya/wix-events";
9
+
10
+ export type FeaturedEventRead = { ok: true; event: WixEvent | null } | { ok: false; event: null };
11
+
12
+ // Only live and upcoming events, earliest first, filtered and sorted by Wix (verified on a visitor
13
+ // token, 2026-11-10): the featured one is on the first page however many events the site has. The
14
+ // pick below still checks each row, and pages on (to Wix's own total) only while no page has
15
+ // produced an event to feature — never a fixed page cap that could miss one.
16
+ const FEATURED_QUERY = {
17
+ filter: { status: { $in: ["UPCOMING", "STARTED"] } },
18
+ sort: [{ fieldName: "dateAndTimeSettings.startDate", order: "ASC" }],
19
+ };
20
+ const PAGE = 50;
21
+
22
+ const millis = (iso: string | undefined): number => {
23
+ const ms = iso ? Date.parse(iso) : NaN;
24
+ return Number.isNaN(ms) ? NaN : ms;
25
+ };
26
+
27
+ /** The event to feature among `events` at `now`: a published event that has not ended — the one
28
+ * that started first when several run now, else the next to start. A draft, a canceled event
29
+ * and an ended one are never featured; an event with no date is featured only when no dated one
30
+ * qualifies (its date is "to be announced"). */
31
+ export function pickFeaturedEvent(events: WixEvent[], now: number): WixEvent | null {
32
+ const eligible = events.filter((e) => {
33
+ const status = String(e.eventStatus ?? (e as { status?: string }).status ?? "").toUpperCase();
34
+ if (status === "DRAFT" || status === "CANCELED" || status === "ENDED") return false;
35
+ const end = millis(endDateOf(e)), start = millis(startDateOf(e));
36
+ const last = Number.isNaN(end) ? start : end;
37
+ return Number.isNaN(last) || last >= now;
38
+ });
39
+ const dated = eligible.filter((e) => !Number.isNaN(millis(startDateOf(e))));
40
+ if (dated.length) return dated.slice().sort((a, b) => millis(startDateOf(a)) - millis(startDateOf(b)))[0];
41
+ return eligible[0] ?? null;
42
+ }
43
+
44
+ /** Read the site's live and upcoming events and pick the featured one. */
45
+ export async function readFeaturedEvent(fields: WixEventFieldset[] = ["DETAILS", "REGISTRATION"], now: number = Date.now()): Promise<FeaturedEventRead> {
46
+ const events: WixEvent[] = [];
47
+ try {
48
+ for (let offset = 0; ; offset += PAGE) {
49
+ const res = await queryEvents({ limit: PAGE, offset, fields, query: FEATURED_QUERY as never });
50
+ const page = (res.events ?? []).filter((e) => !!e.id);
51
+ events.push(...page);
52
+ const total = Number((res as { pagingMetadata?: { total?: unknown } }).pagingMetadata?.total);
53
+ const done = page.length < PAGE || (Number.isFinite(total) && offset + PAGE >= total);
54
+ // A dated pick is final (a later page starts later); an undated one is not — a dated event
55
+ // may still follow, and a dated event is always featured before a "to be announced" one.
56
+ const pick = pickFeaturedEvent(events, now);
57
+ if (done || (pick && !Number.isNaN(millis(startDateOf(pick))))) break;
58
+ }
59
+ } catch {
60
+ return { ok: false, event: null };
61
+ }
62
+ return { ok: true, event: pickFeaturedEvent(events, now) };
63
+ }
@@ -11,7 +11,9 @@ export function withIapPresentation<S extends object>(options: {
11
11
  onCreate?(commerce: IapCommerce): void;
12
12
  onContent?(state: S): void;
13
13
  items(state: S): IapCatalogItem[];
14
- present(state: S, price: (id: string, commercePrice?: string) => string, allowed: (id: string) => boolean, appleIapOrResolving: (id: string) => boolean): S;
14
+ /** `resolving` is true while the checkout guard has no answer yet (a cold boot, a refresh): a
15
+ * screen reads it as loading, never as "not allowed". */
16
+ present(state: S, price: (id: string, commercePrice?: string) => string, allowed: (id: string) => boolean, appleIapOrResolving: (id: string) => boolean, resolving: (id: string) => boolean): S;
15
17
  contentActions: string[];
16
18
  /** Defaults to load/refresh/retry; mutations can explicitly request fresh mapping. */
17
19
  forcePriceRefreshActions?: string[];
@@ -74,11 +76,12 @@ export function withIapPresentation<S extends object>(options: {
74
76
  return view.route === "disabled" || view.route === "regular" ? commercePrice ?? item.commerceDisplayPrice ?? "" : iapPriceFields(view, iapPriceCopy(options.prefix)).priceText;
75
77
  };
76
78
  const allowed = (id: string) => commerce.pricing.checkoutGuard({ kind: "storesProduct", id }).allowed;
79
+ const resolving = (id: string) => commerce.pricing.checkoutGuard({ kind: "storesProduct", id }).route === "resolving";
77
80
  const appleIapOrResolving = (id: string) => ["appleIap", "resolving", "unavailable"].includes(presentationView(id).route);
78
81
  // Re-evaluate the cadence first. A checkout can enter/leave due work while a prior
79
82
  // projection is waiting to retry; a fresh directive supersedes the retained one.
80
83
  const poll = commerce.pollDirective(`${name}.iapPoll`) ?? retainedPoll;
81
- return { ...options.present(state, price, allowed, appleIapOrResolving), ...(poll ? { _poll: poll } : {}) };
84
+ return { ...options.present(state, price, allowed, appleIapOrResolving, resolving), ...(poll ? { _poll: poll } : {}) };
82
85
  };
83
86
  const mergeConcurrent = (before: S, next: S, current: S): S => {
84
87
  if (current === before) return next;