@wix/himalaya-cli 0.1256.0 → 0.1258.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 (74) hide show
  1. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/dev-server/src/builder.d.ts +2 -0
  2. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/motion/src/index.d.ts +45 -5
  3. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/sdk-types/src/capabilities.generated.d.ts +1 -1
  4. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/audio-record.mjs +1 -1
  5. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/calendar.mjs +1 -1
  6. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/calls.mjs +1 -1
  7. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/contacts.mjs +1 -1
  8. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/location.mjs +1 -1
  9. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/motion.mjs +18 -2
  10. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/photos.mjs +1 -1
  11. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/sdk-types.mjs +1 -1
  12. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/tasks.mjs +1 -1
  13. package/dist/cli.mjs +649 -65
  14. package/dist/preview-assets.generated.bin +0 -0
  15. package/guides/base44-app-to-himi-app.md +41 -5
  16. package/guides/component-reference.json +0 -84
  17. package/guides/component-reference.md +2 -23
  18. package/guides/sdk-reference.json +15 -3
  19. package/package.json +2 -2
  20. package/templates/beauty-salon/tier5-src/_shared/collection-service.ts +7 -0
  21. package/templates/beauty-salon/tier5-src/_shared/weekly-goal.ts +107 -0
  22. package/templates/beauty-salon/tier5-src/himi-booking-bookings/index.ts +41 -4
  23. package/templates/beauty-salon/tier5-src/himi-branded-lite-home/index.ts +31 -7
  24. package/templates/beauty-salon-owner/tier5-src/_shared/collection-service.ts +7 -0
  25. package/templates/branded-lite/config.ts +14 -1
  26. package/templates/branded-lite/dev/index.ts +845 -2
  27. package/templates/branded-lite/tier5-src/_shared/collection-service.ts +7 -0
  28. package/templates/branded-lite/tier5-src/_shared/weekly-goal.ts +107 -0
  29. package/templates/branded-lite/tier5-src/himi-booking-bookings/index.ts +41 -4
  30. package/templates/branded-lite/tier5-src/himi-branded-lite-home/index.ts +31 -7
  31. package/templates/branded-lite/tier5-src/himi-branded-lite-steps/index.ts +524 -0
  32. package/templates/community-club/tier5-src/_shared/collection-service.ts +7 -0
  33. package/templates/community-club/tier5-src/_shared/weekly-goal.ts +107 -0
  34. package/templates/community-club/tier5-src/himi-branded-lite-home/index.ts +31 -7
  35. package/templates/community-club-owner/tier5-src/_shared/collection-service.ts +7 -0
  36. package/templates/events-meetups/tier5-src/_shared/collection-service.ts +7 -0
  37. package/templates/events-meetups/tier5-src/_shared/weekly-goal.ts +107 -0
  38. package/templates/events-meetups/tier5-src/himi-branded-lite-home/index.ts +31 -7
  39. package/templates/events-meetups-owner/tier5-src/_shared/collection-service.ts +7 -0
  40. package/templates/gym-fitness/config.ts +14 -1
  41. package/templates/gym-fitness/dev/index.ts +844 -1
  42. package/templates/gym-fitness/tier5-src/_shared/collection-service.ts +7 -0
  43. package/templates/gym-fitness/tier5-src/_shared/weekly-goal.ts +107 -0
  44. package/templates/gym-fitness/tier5-src/himi-booking-bookings/index.ts +41 -4
  45. package/templates/gym-fitness/tier5-src/himi-branded-lite-home/index.ts +31 -7
  46. package/templates/gym-fitness/tier5-src/himi-branded-lite-steps/index.ts +524 -0
  47. package/templates/gym-fitness-owner/tier5-src/_shared/collection-service.ts +7 -0
  48. package/templates/nonprofit-cause/tier5-src/_shared/collection-service.ts +7 -0
  49. package/templates/nonprofit-cause/tier5-src/_shared/weekly-goal.ts +107 -0
  50. package/templates/nonprofit-cause/tier5-src/himi-branded-lite-home/index.ts +31 -7
  51. package/templates/nonprofit-cause-owner/tier5-src/_shared/collection-service.ts +7 -0
  52. package/templates/owner-lite/tier5-src/_shared/collection-service.ts +7 -0
  53. package/templates/podcast-creator/tier5-src/_shared/collection-service.ts +7 -0
  54. package/templates/podcast-creator/tier5-src/_shared/weekly-goal.ts +107 -0
  55. package/templates/podcast-creator/tier5-src/himi-branded-lite-home/index.ts +31 -7
  56. package/templates/podcast-creator-owner/tier5-src/_shared/collection-service.ts +7 -0
  57. package/templates/portfolio-creative/tier5-src/_shared/collection-service.ts +7 -0
  58. package/templates/portfolio-creative/tier5-src/_shared/weekly-goal.ts +107 -0
  59. package/templates/portfolio-creative/tier5-src/himi-branded-lite-home/index.ts +31 -7
  60. package/templates/portfolio-creative-owner/tier5-src/_shared/collection-service.ts +7 -0
  61. package/templates/restaurant/tier5-src/_shared/collection-service.ts +7 -0
  62. package/templates/restaurant/tier5-src/_shared/weekly-goal.ts +107 -0
  63. package/templates/restaurant/tier5-src/himi-branded-lite-home/index.ts +31 -7
  64. package/templates/restaurant-owner/tier5-src/_shared/collection-service.ts +7 -0
  65. package/templates/retail-store/tier5-src/_shared/collection-service.ts +7 -0
  66. package/templates/retail-store/tier5-src/_shared/weekly-goal.ts +107 -0
  67. package/templates/retail-store/tier5-src/himi-branded-lite-home/index.ts +31 -7
  68. package/templates/retail-store-owner/tier5-src/_shared/collection-service.ts +7 -0
  69. package/templates/yoga-studio/dev/index.ts +90 -1
  70. package/templates/yoga-studio/tier5-src/_shared/collection-service.ts +7 -0
  71. package/templates/yoga-studio/tier5-src/_shared/weekly-goal.ts +107 -0
  72. package/templates/yoga-studio/tier5-src/himi-booking-bookings/index.ts +41 -4
  73. package/templates/yoga-studio/tier5-src/himi-branded-lite-home/index.ts +31 -7
  74. package/templates/yoga-studio-owner/tier5-src/_shared/collection-service.ts +7 -0
Binary file
@@ -51,7 +51,7 @@ The parts of the book this procedure uses:
51
51
  ## 2. Scaffold from the starter
52
52
 
53
53
  ```bash
54
- himi init my-app --template base44-starter --base44-app-id <id>
54
+ himi init my-app --template base44-starter --base44-app-id <id> --base44-app-url https://your-tenant.base44.app
55
55
  cd my-app
56
56
  ```
57
57
 
@@ -176,17 +176,53 @@ Google sign-in follows the hosted browser flow used by Branded Lite: Himi opens
176
176
  as `from_url`. Base44 returns an access token to that HTTPS URL. The native shell accepts only a
177
177
  callback from the configured tenant host, verifies the token with `auth.me()`, and stores it in
178
178
  the Keychain / Keystore. The worker receives only the verified user. iOS 17.4 and later use
179
- `ASWebAuthenticationSession`'s HTTPS callback; iOS 16–17.3 and Android return through an
180
- associated Universal Link / App Link from the external browser.
179
+ `ASWebAuthenticationSession`'s HTTPS callback; iOS 16–17.3 return through an associated
180
+ Universal Link. Android uses `AuthTabIntent`, as Branded Lite does, with automatic Custom Tabs
181
+ fallback. The fallback returns through a verified App Link.
181
182
 
182
183
  Set `provisioning.native.appLinkHost` to the published Base44 tenant hostname. That host must
183
- serve `/.well-known/apple-app-site-association` for the built iOS bundle id and the `/` callback
184
- path, and `/.well-known/assetlinks.json` for the Android package and signing certificate. The
184
+ serve `/.well-known/apple-app-site-association` with `webcredentials.apps` containing the signed
185
+ iOS application identifier (`<App ID prefix>.<bundle ID>`) and `applinks.details` allowing the `/`
186
+ callback for that same identifier. The native shell declares both `webcredentials` and `applinks`.
187
+ Serve `/.well-known/assetlinks.json` with `delegate_permission/common.handle_all_urls` for the
188
+ Android package and the SHA-256 fingerprint of the certificate that signs that binary. The
185
189
  Android App Link filter is limited to `/`, so links to other tenant paths continue to open in the
186
190
  browser. The sample's `localhost` value is a placeholder and cannot complete Google sign-in. Base44's mobile app uses a
187
191
  separate platform-account token exchange; its Google client id and endpoint do not sign users
188
192
  into customer apps.
189
193
 
194
+ For an off-repo content package, `himi init --base44-app-url` writes `appLinkHosts` in `config.ts`;
195
+ `himi push` carries it into the release and `himi dist --shell base44` bakes it as
196
+ `provisioning.native.appLinkHost`. For an existing package, set
197
+ `appLinkHosts: ["your-tenant.base44.app"]` at the top level of `defineApp`. A native rebuild is
198
+ required when changing the tenant binding; an OTA update does not change the native auth identity.
199
+
200
+ The Base44 tenant must authorize the identities Himi actually signs. A Branded Lite build's
201
+ bundle ID or signing certificate does not authorize a different Himi binary. Check before testing:
202
+
203
+ The official Base44 CLI can manage the tenant's Google provider. In a linked Base44 project,
204
+ run `npx base44 auth pull` and inspect `base44/auth/`. If Google is disabled, run
205
+ `npx base44 auth social-login google enable`, review the local configuration, then
206
+ `npx base44 auth push`. Pull first so the push preserves the other authentication settings.
207
+ The default Google provider does not need a custom Google client ID or secret. These commands
208
+ configure the provider; they do not publish native domain associations. Base44 CLI v0.1.32
209
+ has no command for those associations, so arrange their publication through Base44 before
210
+ testing the signed native app.
211
+
212
+ ```bash
213
+ himi base44 auth-check --url https://your-tenant.base44.app \
214
+ --ios-app-id <APP_ID_PREFIX.bundle.id> \
215
+ --android-package <package.name> --android-sha256 <AA:BB:...>
216
+ ```
217
+
218
+ This read-only command reports each missing association and prints the required document entries.
219
+ Base44 must publish them on the tenant domain; merge with existing entries so other binaries retain
220
+ their associations. No owner token, Google client secret, or service-role key belongs in a shipped
221
+ app. A successful domain check is configuration evidence; the end-to-end check is Google sign-in
222
+ on the signed native app, a successful `auth.me()`, an authenticated entity read, persistence after
223
+ relaunch, and sign-out clearing the session. Also close the browser mid-login and confirm the
224
+ Account screen leaves its loading state. Test the older-iOS / older-browser fallback separately.
225
+
190
226
  The token never reaches the worker. Native code keeps it (Keychain / encrypted prefs), so the
191
227
  session survives a relaunch, and `auth.status()` reports it on the next boot.
192
228
 
@@ -4,12 +4,7 @@
4
4
  "bindingGrammar": "$service:<service>.<path> (worker state) · $item.<field> (list row) · $flag:<key> (feature flag) · $env:<key> (client environment — #1056). Bindings resolve in the text/value props marked 'binding-aware' below — INCLUDING Modifiers token refs — but only `background` and `border.color`, which are the two whose token a binding actually fills: a worker can drive per-item theming (e.g. a game board's per-square color), not just text. `shadow` is NOT binding-aware on any renderer, and a gradient is driven by its own `backgroundGradientPath` prop resolving to a gradient token NAME, not by a binding inside a token ref — so `shadow: { token: \"$item.x\" }` and `backgroundGradient: { token: \"$item.x\" }` keep the sentinel and silently lose the per-item styling. Colour slots split by LEVEL, not by component: inside modifiers a colour is a TokenRef OBJECT ({ token: \"…\" }), inside props it is a bare TokenName STRING — there is no modifiers.color or modifiers.tint (see the 'Token slots' section in component-reference.md). A few input props render the LITERAL and are NOT binding-aware — notably SearchField.placeholder and Chip.label; SearchField.value is live and binding-aware like other content props. Bindings also CANNOT target strict-enum fields (style, size, alignment, severity, presentation, contentMode, …) — those fail at render, not validation. $env: is client-resolved (no worker) and valid in modifiers.hiddenPath and FragmentSlot.casePath ONLY — keys reduceMotion/colorScheme/sizeClass/isRTL, e.g. hiddenPath:\"$env:reduceMotion\" or hiddenPath:\"$env:colorScheme==light\", casePath:\"$env:colorScheme\"; unknown key fails open (shown / defaultCase).",
5
5
  "componentCount": 86,
6
6
  "notImplementedComponents": [
7
- "Text",
8
- "Carousel",
9
- "CollapsingHeader",
10
- "Banner",
11
7
  "Snackbar",
12
- "WebView",
13
8
  "Slider",
14
9
  "SelectionControl",
15
10
  "ActivityIndicator",
@@ -18,7 +13,6 @@
18
13
  "Popover",
19
14
  "ChipsInput",
20
15
  "OtpInput",
21
- "Map",
22
16
  "Video",
23
17
  "PdfView",
24
18
  "MediaPlayer",
@@ -107,17 +101,6 @@
107
101
  "bindings": [
108
102
  "text"
109
103
  ],
110
- "notImplemented": {
111
- "props": [
112
- "textDirection",
113
- "animateReveal"
114
- ],
115
- "platforms": [
116
- "web"
117
- ],
118
- "severity": "styling",
119
- "note": "`textDirection` sets no `dir`. `animateReveal` does not animate."
120
- },
121
104
  "propsSource": "export type TextProps = TextContent & {\n style?: TokenName;\n /** Foreground color token (default \"textPrimary\"). */\n color?: TokenName;\n /** Tail-truncate after N lines (absent = unlimited). */\n maxLines?: number;\n /** Lever D — a live time value (countdown/relative) the OS ticks with no refresh.\n * When present it OVERRIDES `text`. Widget-safe render only. */\n timeRef?: WidgetTimeRef;\n /** Render `text` as a constrained Markdown subset. */\n markdown?: boolean;\n /** Capability enrichments. */\n textAlign?: \"leading\" | \"center\" | \"trailing\" | \"justify\";\n /** Base writing direction. \"auto\" (or \"rtl\") makes a bidi paragraph resolve +\n * align by its own strong-directional content (Hebrew/Arabic → right-aligned,\n * RTL layout), matching per-message direction in chat bubbles. Absent/\"ltr\" =\n * the current left-to-right behavior. Both renderers honor it (parity). */\n textDirection?: \"auto\" | \"ltr\" | \"rtl\";\n decoration?: \"underline\" | \"strikethrough\";\n /** EXTRA SPACE BETWEEN LINES, in points/px — added ON TOP of the line height the `style`\n * token already sets. It is NOT a multiple: `lineSpacing: 6` means six points of extra\n * leading, not six times the font size, and every renderer agrees on that. To\n * change the line height as a ratio of the font size, set the typography token's `line`\n * instead; that is where a body style's 1.4/1.7 lives. Absent/0 = the token's own line\n * height, which is the right answer for almost every screen. */\n lineSpacing?: number;\n /** Per-item gate (usually an `$item.` field pre-substituted per row): when it\n * resolves empty, the text collapses to zero size instead of taking layout. */\n collapseWhenEmpty?: boolean;\n /** Motion grammar (Batch 1, item 4) — count-up tween for a numeric value on\n * change; non-numeric values render instantly. Gated by reduced motion. */\n animateValue?: boolean;\n /** Motion grammar — reveal the (post-substitution literal) text word-by-word,\n * once per distinct content, like a chat assistant \"typing\" its reply. Each\n * content animates a single time (progress is remembered), so list re-renders\n * and scrolls don't restart it. Gated by reduced motion (snaps to full).\n * Both renderers honor it (parity). Default nil/false. */\n animateReveal?: boolean;\n};"
122
105
  },
123
106
  {
@@ -499,17 +482,6 @@
499
482
  "bindings": [
500
483
  "itemsPath"
501
484
  ],
502
- "notImplemented": {
503
- "props": [
504
- "autoplayIntervalMs"
505
- ],
506
- "platforms": [
507
- "android",
508
- "web"
509
- ],
510
- "severity": "styling",
511
- "note": "No autoplay."
512
- },
513
485
  "propsSource": "export interface CarouselProps {\n items: Component[];\n currentIndex?: number;\n onChange?: Action;\n autoplayIntervalMs?: number;\n /** `$service:` binding → a live array to render as slides (overrides `items`). */\n itemsPath?: string;\n}"
514
486
  },
515
487
  {
@@ -531,30 +503,6 @@
531
503
  "category": "Navigation primitives",
532
504
  "propsType": "CollapsingHeaderProps",
533
505
  "bindings": [],
534
- "notImplemented": [
535
- {
536
- "props": [
537
- "imageAsset",
538
- "collapsedHeight",
539
- "parallaxFactor"
540
- ],
541
- "platforms": [
542
- "web"
543
- ],
544
- "severity": "styling",
545
- "note": "A static hero: `imageAsset`, `collapsedHeight` and `parallaxFactor` are inert (only `imageUrl` is read)."
546
- },
547
- {
548
- "props": [
549
- "imageAsset"
550
- ],
551
- "platforms": [
552
- "android"
553
- ],
554
- "severity": "styling",
555
- "note": "`imageAsset` (a baked asset name) is not resolved — only `imageUrl` paints the hero."
556
- }
557
- ],
558
506
  "propsSource": "export interface CollapsingHeaderProps {\n /** Hero image URL (`$service:`-resolvable upstream). */\n imageUrl?: string;\n /** Bundle asset fallback. */\n imageAsset?: string;\n /** Required; scales & fades with collapse. */\n title: string;\n subtitle?: string;\n /** Initial height in points (default 280). */\n expandedHeight?: number;\n /** Final height when fully scrolled (default 64). */\n collapsedHeight?: number;\n /** Body content that scrolls under the header. */\n children?: Component[];\n /** 0.0 = static, 1.0 = full parallax (default 0.5). */\n parallaxFactor?: number;\n}"
559
507
  },
560
508
  {
@@ -574,16 +522,6 @@
574
522
  "title",
575
523
  "message"
576
524
  ],
577
- "notImplemented": {
578
- "props": [
579
- "dismissible"
580
- ],
581
- "platforms": [
582
- "web"
583
- ],
584
- "severity": "styling",
585
- "note": "No dismiss control."
586
- },
587
525
  "propsSource": "export interface BannerProps {\n severity: Severity;\n /** Banner headline — binding-aware (\"$item.\"/\"$service:\") on web, iOS and Android. */\n title: string;\n /** Banner body — binding-aware (\"$item.\"/\"$service:\") on web, iOS and Android. */\n message?: string;\n action?: Action;\n dismissible?: boolean;\n /** #1059 — action label; overridable for localized hosts. Default \"Take action\". */\n actionLabel?: string;\n}"
588
526
  },
589
527
  {
@@ -624,17 +562,6 @@
624
562
  "category": "Embeddable WebView (web-in-SDUI)",
625
563
  "propsType": "WebViewProps",
626
564
  "bindings": [],
627
- "notImplemented": {
628
- "props": [
629
- "scrollEnabled",
630
- "config"
631
- ],
632
- "platforms": [
633
- "web"
634
- ],
635
- "severity": "styling",
636
- "note": "The iframe always scrolls. `config` (the native WebView options: cookies, bridge, zoom…) is not applied to the iframe."
637
- },
638
565
  "propsSource": "export interface WebViewProps {\n url?: string;\n /** Inline HTML to load instead of `url` (mutually exclusive). */\n inlineHtml?: string;\n /** Fixed height in points/dp; set this OR `aspectRatio`. */\n height?: number;\n /** width:height ratio; used when `height` is unset. */\n aspectRatio?: number;\n /** Keep the WebView's own scrolling (default false). */\n scrollEnabled?: boolean;\n config?: WebViewConfig;\n capabilitiesRequired?: string[];\n}"
639
566
  },
640
567
  {
@@ -1252,17 +1179,6 @@
1252
1179
  "cameraPath",
1253
1180
  "shapesPath"
1254
1181
  ],
1255
- "notImplemented": {
1256
- "props": [
1257
- "followUserLocation"
1258
- ],
1259
- "platforms": [
1260
- "android",
1261
- "web"
1262
- ],
1263
- "severity": "styling",
1264
- "note": "`followUserLocation` does not track."
1265
- },
1266
1182
  "propsSource": "export interface MapProps {\n latitude?: number;\n longitude?: number;\n zoom?: number;\n markers?: MapMarker[];\n /** `$service:` binding → a live markers array (overrides `markers`). */\n markersPath?: string;\n height?: number;\n interactive?: boolean;\n /**\n * Polyline waypoints — a recorded GPS track, or a delivery route. Drawn in order, so\n * pass the fixes chronologically (`@himalaya/location`'s `watch()` yields them that way).\n */\n route?: MapMarker[];\n /**\n * How a `route` is drawn. Default `\"tile\"` — the polyline over REAL map tiles, which is\n * what a track/navigation screen wants. `\"schematic\"` keeps the normalized,\n * projection-free mini-map (no tile fetch, so no flicker) that suits a small\n * delivery/route CARD. Strict enum: a `$service:` binding here fails at render time,\n * not validation.\n */\n routeMode?: \"tile\" | \"schematic\";\n /** Draw the live device-position dot. Silently inert without location permission. */\n showUserLocation?: boolean;\n /** Keep the camera following the user. Implies `showUserLocation`. */\n followUserLocation?: boolean;\n /** Frame the viewport to `markers` ∪ `route` instead of `latitude`/`longitude` + `zoom`. */\n fitToContent?: boolean;\n /**\n * Imagery style: `\"standard\"` (default) | `\"satellite\"` | `\"hybrid\"` (satellite + labels).\n * Strict enum — a `$service:` binding here fails at render, not validation.\n *\n * HONORED ON THE MAPKIT SURFACES (iOS + macOS). MapKit ships first-party satellite/hybrid\n * imagery (MKMapType), and the tile-route arm has a macOS representable, so a Mac gets it too. The Android + web tile arms draw OSM raster tiles, and OSM has no satellite\n * layer — serving one would mean bundling a third-party imagery provider with its own\n * attribution terms and usage limits, which is an app's licensing decision rather than the\n * platform's. Those arms normalize the value and keep drawing standard tiles.\n *\n * For satellite/topo on EVERY surface, use the app-scoped `TrailMap` component\n * and point its `styleUrl` at a vector style you have rights to.\n */\n mapStyle?: \"standard\" | \"satellite\" | \"hybrid\";\n /**\n * Tap on the map surface. The event payload is merged into the Action's `args` — exactly\n * like Slider/SelectionControl merge `value` — so a Tier-5 reducer reads\n * `{latitude, longitude}` with no new dispatch contract.\n *\n * Honored on the TILE arms, which have real geography. The schematic mini-map draws a\n * normalized, projection-free polyline with no meaningful coordinate to report, so it\n * fires `onMarkerTap` only. `interactive` governs pan/zoom, not taps: a deliberately\n * non-interactive map still reports them.\n */\n onMapTap?: Action;\n /**\n * Tap on a marker. `args`: `{index, label?, latitude, longitude}`, where `index` is into\n * the RESOLVED marker array (`markersPath` when bound, else `markers`) so the worker can\n * look the item back up in its own state. `label` is OMITTED for an unlabeled pin rather\n * than sent as `\"\"`. A tap that landed on a pin is a marker tap only — never also a map tap.\n */\n onMarkerTap?: Action;\n /**\n * Camera settled after a pan/zoom — fired on gesture END, never per frame.\n * `args`: `{latitude, longitude, zoom, north, south, east, west}`, so a worker can fetch\n * \"trails in view\" without re-deriving the viewport. Programmatic camera moves\n * (e.g. a `fitToContent` re-frame) do NOT fire it, or a worker that refetches on region\n * change would loop against its own camera.\n */\n onRegionChange?: Action;\n /**\n * `$service:` binding → a live route array (overrides `route`), mirroring `markersPath`.\n * Without it a growing recorded track had to re-push the whole descriptor for every fix;\n * with it the polyline follows worker state. Defaults to the TILE arm, not the schematic\n * one — a bound route is a recorded track, which is why the binding exists.\n */\n routePath?: string;\n /**\n * `$service:` binding → `{latitude, longitude, zoom}`: the camera, driven by the WORKER.\n *\n * `latitude`/`longitude`/`zoom` are numbers, so a `$service:` sentinel cannot go in them —\n * which meant a worker could not move the camera at all (\"fly to this search result\" was\n * inexpressible without re-pushing the descriptor).\n *\n * Precedence: a resolved `cameraPath` wins, then `fitToContent`, then the static\n * `latitude`/`longitude`/`zoom`. A NEW value also overrides the user's own pan; an unchanged\n * one leaves it alone. Applying it is programmatic, so it never echoes back through\n * `onRegionChange`. Partial objects are honored — `{zoom}` re-zooms in place.\n */\n cameraPath?: string;\n /** Overlays beyond the single `route`: lines, polygons, circles. */\n shapes?: MapShape[];\n /** `$service:` binding → a live shapes array (overrides `shapes`). */\n shapesPath?: string;\n /**\n * Tap on a drawn shape. `args`: `{id?, index, kind}`. Hit-tested before the surface and after\n * markers — a pin on top of a polygon belongs to the pin.\n */\n onShapeTap?: Action;\n /** App-supplied basemap tiles. Absent ⇒ each arm's default (OSM raster, or Apple's imagery). */\n tileSource?: MapTileSource;\n}"
1267
1183
  },
1268
1184
  {
@@ -118,20 +118,14 @@ See also **[Modifiers](#modifiers)** (the `modifiers` block) and **[Actions](#ac
118
118
 
119
119
  These props are accepted by the schema and pass validation, but the named platform's renderer never reads them — they silently do nothing (no warning, no log). Prefer a prop NOT listed here, or drive the behaviour from a worker.
120
120
 
121
- **Scope: 20 of 86 components, all of them web / android / ios-only** — every other component/platform pair reads every prop it decodes. The list splits in two, and the halves mean different things:
121
+ **Scope: 14 of 86 components, all of them ios / android / web-only** — every other component/platform pair reads every prop it decodes. The list splits in two, and the halves mean different things:
122
122
 
123
123
  - **`category` (7: `Menu`, `Tooltip`, `Popover`, `ChipsInput`, `OtpInput`, `MediaPlayer`, `TimeGrid`)** — the prop changes the component's *kind*. These genuinely are **not implemented**: an overlay renders always-visible inline, so the component does not do the job its name implies. Check the row's note for a working alternative.
124
- - **`styling` (13: `Text`, `Carousel`, `CollapsingHeader`, `Banner`, `Snackbar`, `WebView`, `Slider`, `SelectionControl`, `ActivityIndicator`, `Map`, `Video`, `PdfView`, `Agenda`)** — the component itself **works**; only the listed prop is inert. `Slider` on iOS is a working slider whose `debounceMs` does not throttle — not a broken `Slider`. Use the component; just do not depend on that one prop.
124
+ - **`styling` (7: `Snackbar`, `Slider`, `SelectionControl`, `ActivityIndicator`, `Video`, `PdfView`, `Agenda`)** — the component itself **works**; only the listed prop is inert. `Slider` on iOS is a working slider whose `debounceMs` does not throttle — not a broken `Slider`. Use the component; just do not depend on that one prop.
125
125
 
126
126
  | Component | Unread props | Platform | Kind | Note |
127
127
  |---|---|---|---|---|
128
- | `Text` | `textDirection`, `animateReveal` | web | styling | `textDirection` sets no `dir`. `animateReveal` does not animate. |
129
- | `Carousel` | `autoplayIntervalMs` | android, web | styling | No autoplay. |
130
- | `CollapsingHeader` | `imageAsset`, `collapsedHeight`, `parallaxFactor` | web | styling | A static hero: `imageAsset`, `collapsedHeight` and `parallaxFactor` are inert (only `imageUrl` is read). |
131
- | `CollapsingHeader` | `imageAsset` | android | styling | `imageAsset` (a baked asset name) is not resolved — only `imageUrl` paints the hero. |
132
- | `Banner` | `dismissible` | web | styling | No dismiss control. |
133
128
  | `Snackbar` | `durationMs` | ios, android, web | styling | The Snackbar component renders inline, so `durationMs` does nothing (the `snackbar` presentation verb is the working toast). |
134
- | `WebView` | `scrollEnabled`, `config` | web | styling | The iframe always scrolls. `config` (the native WebView options: cookies, bridge, zoom…) is not applied to the iframe. |
135
129
  | `Slider` | `debounceMs` | ios, web | styling | `debounceMs` does not throttle onChange. |
136
130
  | `SelectionControl` | `groupId` | android, web | styling | Radios sharing a `groupId` are not mutually exclusive. |
137
131
  | `ActivityIndicator` | `ring` | ios, android, web | styling | The `ring` style is never selected (determinate vs indeterminate follows `value`). |
@@ -141,7 +135,6 @@ These props are accepted by the schema and pass validation, but the named platfo
141
135
  | `Popover` | `edge` | ios | category | The bubble is drawn in flow under its anchor; `edge` placement is not implemented. |
142
136
  | `ChipsInput` | `onAdd` | ios, android, web | category | `onAdd` never dispatches. |
143
137
  | `OtpInput` | `onComplete`, `onChange` | ios, android, web | category | Neither `onChange` nor `onComplete` dispatches. |
144
- | `Map` | `followUserLocation` | android, web | styling | `followUserLocation` does not track. |
145
138
  | `Video` | `poster` | ios | styling | `poster` is not shown. |
146
139
  | `PdfView` | `showPageControls`, `startPage` | android | styling | No page controls. `startPage` is ignored. |
147
140
  | `PdfView` | `showPageControls`, `zoomable`, `allowShare` | web | styling | No page controls. The browser PDF viewer ignores `zoomable` and `allowShare`. |
@@ -456,8 +449,6 @@ export type TextProps = TextContent & {
456
449
  };
457
450
  ```
458
451
 
459
- > ⚠️ **Implemented, but these props are inert on web:** `textDirection`, `animateReveal` — `textDirection` sets no `dir`. `animateReveal` does not animate.
460
-
461
452
  #### Image
462
453
 
463
454
  ```ts
@@ -1012,8 +1003,6 @@ export interface CarouselProps {
1012
1003
  }
1013
1004
  ```
1014
1005
 
1015
- > ⚠️ **Implemented, but these props are inert on android, web:** `autoplayIntervalMs` — No autoplay.
1016
-
1017
1006
  #### Pager
1018
1007
 
1019
1008
  ```ts
@@ -1057,10 +1046,6 @@ export interface CollapsingHeaderProps {
1057
1046
  }
1058
1047
  ```
1059
1048
 
1060
- > ⚠️ **Implemented, but these props are inert on web:** `imageAsset`, `collapsedHeight`, `parallaxFactor` — A static hero: `imageAsset`, `collapsedHeight` and `parallaxFactor` are inert (only `imageUrl` is read).
1061
-
1062
- > ⚠️ **Implemented, but these props are inert on android:** `imageAsset` — `imageAsset` (a baked asset name) is not resolved — only `imageUrl` paints the hero.
1063
-
1064
1049
  #### AvatarStrip
1065
1050
 
1066
1051
  ```ts
@@ -1107,8 +1092,6 @@ export interface BannerProps {
1107
1092
  }
1108
1093
  ```
1109
1094
 
1110
- > ⚠️ **Implemented, but these props are inert on web:** `dismissible` — No dismiss control.
1111
-
1112
1095
  #### Snackbar
1113
1096
 
1114
1097
  ```ts
@@ -1176,8 +1159,6 @@ export interface WebViewProps {
1176
1159
  }
1177
1160
  ```
1178
1161
 
1179
- > ⚠️ **Implemented, but these props are inert on web:** `scrollEnabled`, `config` — The iframe always scrolls. `config` (the native WebView options: cookies, bridge, zoom…) is not applied to the iframe.
1180
-
1181
1162
  ### Controls & cells
1182
1163
 
1183
1164
  #### ListItem
@@ -1987,8 +1968,6 @@ export interface MapProps {
1987
1968
  }
1988
1969
  ```
1989
1970
 
1990
- > ⚠️ **Implemented, but these props are inert on android, web:** `followUserLocation` — `followUserLocation` does not track.
1991
-
1992
1971
  #### Video
1993
1972
 
1994
1973
  ```ts
@@ -2690,17 +2690,23 @@
2690
2690
  "jsdoc": "/** Which sensor a watch streams. */",
2691
2691
  "decl": "export type MotionSensor = \"steps\" | \"altitude\" | \"heading\";"
2692
2692
  },
2693
+ {
2694
+ "name": "StepHistoryStatus",
2695
+ "kind": "type",
2696
+ "jsdoc": "/**\n * Whether `getStepCount` can answer a PAST window right now, and if not, what would fix it.\n *\n * available it can — \"steps today\" is a real daily total.\n * needs_permission `requestPermission()` (or `openStepHistorySetup()`) would unlock it.\n * needs_setup a system component is missing or out of date — on Android, Google Play\n * services. `openStepHistorySetup()` takes the user to update it.\n * denied the user refused; only the system Settings app can undo that.\n * unsupported this device / build cannot answer a past window: web, macOS, a device\n * with no pedometer, an Android app that links no step store, or a phone\n * without Google Play services. Count live through `watch()` instead.\n */",
2697
+ "decl": "export type StepHistoryStatus = \"available\" | \"needs_permission\" | \"needs_setup\" | \"denied\" | \"unsupported\";"
2698
+ },
2693
2699
  {
2694
2700
  "name": "MotionAvailability",
2695
2701
  "kind": "interface",
2696
2702
  "jsdoc": "/** What this device can actually do. Never assume — a barometer is common but not universal. */",
2697
- "decl": "export interface MotionAvailability {\n /** Pedometer / step counter present (and, on Android, the runtime permission held). */\n steps: boolean;\n /** Barometer present. False on simulators and low-end hardware. */\n altimeter: boolean;\n /** Magnetometer / compass present. */\n heading: boolean;\n}"
2703
+ "decl": "export interface MotionAvailability {\n /** Pedometer / step counter present (and, on Android, the runtime permission held). */\n steps: boolean;\n /** Barometer present. False on simulators and low-end hardware. */\n altimeter: boolean;\n /** Magnetometer / compass present. */\n heading: boolean;\n /** Whether `getStepCount` can answer a past window — see {@link StepHistoryStatus}. An\n * unknown or absent value reads as \"unsupported\", never as \"available\". */\n stepHistory: StepHistoryStatus;\n}"
2698
2704
  },
2699
2705
  {
2700
2706
  "name": "StepSample",
2701
2707
  "kind": "interface",
2702
2708
  "jsdoc": "",
2703
- "decl": "export interface StepSample {\n /** Steps in the sampled window (a DELTA, not a lifetime total). */\n steps: number;\n /** Steps per second, when the platform reports it. */\n cadence?: number;\n /** Distance the platform estimated for those steps, meters. */\n distanceM?: number;\n /** Floors climbed, when the platform reports it (iOS CMPedometer only). */\n floorsAscended?: number;\n timestamp: number; // epoch ms\n}"
2709
+ "decl": "export interface StepSample {\n /** Steps in the sampled window (a DELTA, not a lifetime total). */\n steps: number;\n /** Steps per second, when the platform reports it. */\n cadence?: number;\n /** Distance the platform estimated for those steps, meters. */\n distanceM?: number;\n /** Floors climbed, when the platform reports it (iOS CMPedometer only). */\n floorsAscended?: number;\n /** Android only: the step counter's RUNNING total since the last device restart. The first\n * sample of a stream carries it with `steps: 0`, so a bundle that saves it (with\n * `bootTimeMs`) can add the steps taken while it was not listening — same boot ⇒ the counter\n * is continuous. Absent on iOS (use `getStepCount` there) and web. */\n stepsSinceBoot?: number;\n /** Android only: when that restart was, epoch ms. A different value means the counter reset. */\n bootTimeMs?: number;\n timestamp: number; // epoch ms\n}"
2704
2710
  },
2705
2711
  {
2706
2712
  "name": "AltitudeSample",
@@ -2738,10 +2744,16 @@
2738
2744
  "jsdoc": "/**\n * Which sensors this device has. Cheap, and worth calling before you render a stats tile:\n * an elevation-gain readout on a device with no barometer should say so, not show 0 m.\n */",
2739
2745
  "decl": "export async function availability(): Promise<MotionAvailability>;"
2740
2746
  },
2747
+ {
2748
+ "name": "openStepHistorySetup",
2749
+ "kind": "function",
2750
+ "jsdoc": "/**\n * Take the user to whatever would make `stepHistory` \"available\": on Android, update Google Play\n * services (`needs_setup`) or grant step access (`needs_permission`). Resolves\n * once the user is back in the app, with whether anything was opened. Call `availability()`\n * again afterwards — opening the store is not the same as installing.\n *\n * iOS, macOS and web have nothing to open and resolve false: iOS step history is CoreMotion's,\n * unlocked by `requestPermission()`. Raise this only from a user gesture — it leaves the app.\n */",
2751
+ "decl": "export async function openStepHistorySetup(): Promise<boolean>;"
2752
+ },
2741
2753
  {
2742
2754
  "name": "getStepCount",
2743
2755
  "kind": "function",
2744
- "jsdoc": "/**\n * Steps between two epoch-ms instants — HISTORICAL, so it can answer \"how many steps today\"\n * even though the app was not running. Backed by CoreMotion's stored pedometer data (iOS,\n * ~7 days).\n *\n * **ANDROID ALWAYS RETURNS NULL.** The platform step counter exposes only a cumulative total\n * since boot with no timestamps, so a past window is genuinely unanswerable without Health\n * Connect (which would be a new dependency). On Android, accumulate live through\n * `watch({ sensor: \"steps\" })` instead.\n *\n * Returns null when unavailable / not permitted, and 0 for a genuinely still window — the\n * distinction matters, so don't collapse it with `?? 0` before you have branched on it, or a\n * device that cannot answer will render a confident, wrong \"0 steps\".\n */",
2756
+ "jsdoc": "/**\n * Steps between two epoch-ms instants — HISTORICAL, so it can answer \"how many steps today\"\n * even though the app was not running. Backed by CoreMotion's stored pedometer data (iOS,\n * ~7 days) and, on Android, by an opt-in step store.\n *\n * **ANDROID ANSWERS FROM A STEP STORE, NEVER FROM THE APP ITSELF.** The platform step counter\n * exposes only a cumulative total since boot with no dates, and an app the user is not using\n * receives no sensor events, so it cannot keep its own midnight baseline. A store that records on\n * its own fills that, and with several the larger answer wins:\n * - Google's Recording API (Play services records the steps, ~10 days on the device, no\n * account), in an app that links the opt-in `:core-runtime-step-recording` module — its\n * history starts at the first grant, so the first day is partial.\n * Health Connect is not a motion store: read it through `@himalaya/health` (the `health`\n * capability), which the runtime gates per bundle.\n * `availability().stepHistory` says whether one can answer. Otherwise this returns null;\n * accumulate live through `watch({ sensor: \"steps\" })` instead.\n *\n * Returns null when unavailable / not permitted, and 0 for a genuinely still window — the\n * distinction matters, so don't collapse it with `?? 0` before you have branched on it, or a\n * device that cannot answer will render a confident, wrong \"0 steps\".\n */",
2745
2757
  "decl": "export async function getStepCount(fromMs: number, toMs: number): Promise<number | null>;"
2746
2758
  },
2747
2759
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/himalaya-cli",
3
- "version": "0.1256.0",
3
+ "version": "0.1258.0",
4
4
  "type": "module",
5
5
  "description": "himi — the Himalaya authoring CLI. Build a Tier-5 content package on your own machine, push it to the production serve as a draft, preview it on web + Himi Player, and read worker logs back — the remote dev loop. Wraps @himalaya/serve-cli for transport.",
6
6
  "keywords": [
@@ -67,5 +67,5 @@
67
67
  "artifactId": "himalaya-cli"
68
68
  }
69
69
  },
70
- "falconPackageHash": "0a61083a5bb94ca82c70ea46da08d19312ed5cf412c3c19c714238de"
70
+ "falconPackageHash": "2c568d80b29808cc5341e7e8b25045dfb1cfc031e17488b48cc4c0e5"
71
71
  }
@@ -11,6 +11,8 @@ export interface CollectionSaving {
11
11
  type State = Record<string, unknown>;
12
12
  interface BackendCollection {
13
13
  restorePagesOnLoad?: boolean;
14
+ /** Sees the load action's argument (the screen's onAppear params) BEFORE the query runs. */
15
+ onLoad?(arg: unknown): void;
14
16
  controller: ReturnType<typeof createCollectionQuery<CollectionRow>>;
15
17
  apply(state: State, page: CollectionQueryState<CollectionRow>): State;
16
18
  }
@@ -294,6 +296,7 @@ export function decorateCollection(name: string, def: { state: State; actions?:
294
296
  actions.collectionDataChanged = s => derive(backend.apply(s, backend.controller.getState()));
295
297
  actions.load = (_s, arg) => {
296
298
  stashCopy(arg); syncSaved(); applyNavigationCriteria(arg, _s);
299
+ backend.onLoad?.(arg);
297
300
  return backend.controller.query(criteria(), backend.restorePagesOnLoad).then(() => undefined);
298
301
  };
299
302
  actions.refresh = (_s, arg) => {
@@ -320,6 +323,9 @@ export function decorateCollection(name: string, def: { state: State; actions?:
320
323
  export function defineBackendCollection<S extends object, Row extends object>(name: string, options: {
321
324
  /** Revalidate already opened pages on navigation return; explicit refresh resets. */
322
325
  restorePagesOnLoad?: boolean;
326
+ /** The load action's argument (onAppear params beyond `copy`), before the query runs — for a
327
+ * domain setting that rides the descriptor, e.g. My Bookings' `weeklyGoal`. */
328
+ onLoad?(arg: unknown): void;
323
329
  state: S;
324
330
  source: CollectionQuerySource<Row>;
325
331
  apply(state: S, page: CollectionQueryState<Row>): S;
@@ -330,6 +336,7 @@ export function defineBackendCollection<S extends object, Row extends object>(na
330
336
  const controller = createCollectionQuery(options.source, () => { publish?.(); });
331
337
  const definition = decorateCollection(name, { state: options.state as State, actions: options.actions as Record<string, Reducer> | undefined }, options.saving, {
332
338
  restorePagesOnLoad: options.restorePagesOnLoad,
339
+ onLoad: options.onLoad,
333
340
  controller: controller as unknown as BackendCollection['controller'],
334
341
  apply: (state, page) => options.apply(state as S, page as unknown as CollectionQueryState<Row>) as State,
335
342
  });
@@ -0,0 +1,107 @@
1
+ // The weekly session goal (`provisioning.goals.weeklySessions`) over a member's own bookings —
2
+ // shared by the home weekly-goal Gauge (himi-branded-lite-home) and the My Bookings "This week"
3
+ // card (himi-booking-bookings), so the two can never count differently.
4
+ //
5
+ // WHAT COUNTS as a session toward the goal: a CONFIRMED booking whose start falls in the CURRENT
6
+ // calendar week (Monday 00:00 local → now) and is already in the past. An allow-list, not a
7
+ // deny-list: CREATED (checkout never completed), PENDING / PENDING_APPROVAL / PENDING_CHECKOUT,
8
+ // WAITING_LIST, CANCELED and DECLINED — and any status Wix adds later — do not count. That is
9
+ // "booked and it happened", not verified
10
+ // attendance: the member-scoped queryBookings row carries no attendance/check-in field (the Wix
11
+ // Attendance API is owner-scoped), so a no-show still counts. Future bookings this week do not
12
+ // count — they have not happened yet.
13
+ //
14
+ // DETERMINISM: nothing here runs at worker boot; every clock read is an argument. PURE (no network,
15
+ // no bridge) so the rules are unit-tested directly; the read lives with its caller.
16
+
17
+ import type { MemberBookingRow } from "./member-bookings.js";
18
+ import { copyParam, copyTemplate } from "./himi-copy.js";
19
+
20
+ export const MAX_WEEKLY_SESSION_GOAL = 21;
21
+
22
+ /** The one status that means the session was booked and held (as memberBookingRow normalizes
23
+ * it: upper-case, `_` → space). */
24
+ const COUNTS_AS_SESSION = /^CONFIRMED$/;
25
+
26
+ /** At most this many pages of past bookings are read for one week's count. */
27
+ export const MAX_WEEKLY_PAGES = 4;
28
+
29
+ /** The onAppear `weeklyGoal` param → a goal in [1, 21], or 0 = no goal provisioned. */
30
+ export function parseWeeklyGoal(raw: unknown): number {
31
+ const n = typeof raw === "number" ? raw : typeof raw === "string" && raw.trim() !== "" ? Number(raw) : NaN;
32
+ return Number.isInteger(n) && n >= 1 ? Math.min(n, MAX_WEEKLY_SESSION_GOAL) : 0;
33
+ }
34
+
35
+ /** Monday 00:00 local of `now`'s week, epoch ms. */
36
+ export function weekStartMs(now: number): number {
37
+ const d = new Date(now);
38
+ d.setHours(0, 0, 0, 0);
39
+ d.setDate(d.getDate() - ((d.getDay() + 6) % 7));
40
+ return d.getTime();
41
+ }
42
+
43
+ /** Sessions toward the goal among `rows` — see the file header for what counts. */
44
+ export function weeklySessionsDone(rows: readonly MemberBookingRow[], now: number): number {
45
+ const from = weekStartMs(now);
46
+ const seen = new Set<string>();
47
+ for (const row of rows) {
48
+ const start = Date.parse(row.start);
49
+ if (!Number.isFinite(start) || start < from || start >= now) continue;
50
+ if (!COUNTS_AS_SESSION.test((row.status || "").trim().toUpperCase())) continue;
51
+ seen.add(row.id || `${row.start}|${row.title}`);
52
+ }
53
+ return seen.size;
54
+ }
55
+
56
+ export interface BookingsPage {
57
+ items: MemberBookingRow[];
58
+ nextCursor?: string;
59
+ }
60
+
61
+ /** Sessions toward the goal from PAST bookings read newest-first: `first` is the first page, and
62
+ * `next(cursor)` reads more only while the oldest row so far is still inside this week (a page of
63
+ * 50 almost always reaches back before Monday). Bounded to MAX_WEEKLY_PAGES reads; a failing
64
+ * read rejects, so the caller hides the count rather than under-counting. */
65
+ export async function weeklySessionsFromPages(
66
+ first: BookingsPage,
67
+ next: (cursor: string) => Promise<BookingsPage>,
68
+ now: number,
69
+ ): Promise<number> {
70
+ const from = weekStartMs(now);
71
+ const rows = [...first.items];
72
+ let page = first;
73
+ for (let read = 1; read < MAX_WEEKLY_PAGES && page.nextCursor; read++) {
74
+ const oldest = page.items[page.items.length - 1];
75
+ if (oldest && Date.parse(oldest.start) < from) break;
76
+ page = await next(page.nextCursor);
77
+ rows.push(...page.items);
78
+ }
79
+ return weeklySessionsDone(rows, now);
80
+ }
81
+
82
+ export interface WeeklyGoalProgress {
83
+ done: number;
84
+ goal: number;
85
+ /** 0..1 — the Gauge / ProgressBar fill. */
86
+ fraction: number;
87
+ met: boolean;
88
+ /** "1 of 2 sessions this week" */
89
+ label: string;
90
+ /** "1 more to reach your weekly goal" / "Weekly goal reached. Great consistency." */
91
+ remainingLabel: string;
92
+ }
93
+
94
+ export function weeklyGoalProgress(done: number, goal: number): WeeklyGoalProgress {
95
+ const safeGoal = Math.max(1, goal);
96
+ const met = done >= safeGoal;
97
+ return {
98
+ done,
99
+ goal: safeGoal,
100
+ fraction: Math.min(done / safeGoal, 1),
101
+ met,
102
+ label: copyTemplate("weeklyGoal.progress", "{done} of {goal} sessions this week", { done, goal: safeGoal }),
103
+ remainingLabel: met
104
+ ? copyParam("weeklyGoal.met", "Weekly goal reached. Great consistency.")
105
+ : copyTemplate("weeklyGoal.remaining", "{count} more to reach your weekly goal", { count: safeGoal - done }),
106
+ };
107
+ }
@@ -6,6 +6,7 @@ import { memberAccess, assertMemberAccess, memberAccessChanged, memberAccessDeni
6
6
  import { fetchMemberBookings, type MemberBookingRow } from "../_shared/member-bookings.js";
7
7
  import { dayKey, dayLabel } from "@himalaya/time";
8
8
  import { localPreferences } from "../_shared/local-preferences.js";
9
+ import { parseWeeklyGoal, weeklyGoalProgress, weeklySessionsFromPages } from "../_shared/weekly-goal.js";
9
10
 
10
11
  const input = (globalThis as { himalaya?: { input?: Record<string, unknown> } }).himalaya?.input;
11
12
  const validDate = (value: unknown): value is string => typeof value === "string" && /^\d{4}-\d{2}-\d{2}$/.test(value) && dayKey(new Date(`${value}T12:00:00`)) === value;
@@ -21,6 +22,26 @@ let pageMember: MemberAccess | undefined;
21
22
  let queryNow = ""; // set by the first-page fetch, never at boot (see selectedDate)
22
23
  let cancelTarget: { row: MemberBookingRow; member: MemberAccess } | undefined;
23
24
  let cancelling = false;
25
+ // The weekly session goal (`provisioning.goals.weeklySessions`), from the onAppear `weeklyGoal`
26
+ // param — 0 when the app provisions none, which keeps the "This week" card hidden for good. The
27
+ // count comes from a dedicated read of this week's PAST bookings on each first-page fetch, NOT
28
+ // from `rows` (those follow the list's filter — Upcoming by default — and would read 0).
29
+ let weeklyGoal = 0;
30
+ /** The count of the page that APPLIED — set in `apply`, never by a fetch, so a superseded fetch
31
+ * (another member, a refresh) cannot overwrite it: it travels in that page's metadata and is
32
+ * dropped with it. */
33
+ let weeklyDone: number | null = null;
34
+ /** This week's sessions from the PAST bookings, newest first (paged only while still inside this
35
+ * week). null when a read fails, so the card hides rather than claiming "0 of N". */
36
+ async function fetchWeeklySessionsDone(member: MemberAccess, now: number): Promise<number | null> {
37
+ try {
38
+ const nowIso = new Date(now).toISOString();
39
+ const read = (cursor: string) => fetchMemberBookings({ query: "", filter: "value:Past", sort: "za", savedIds: [] }, cursor, nowIso, member);
40
+ return await weeklySessionsFromPages(await read(""), read, now);
41
+ } catch {
42
+ return null;
43
+ }
44
+ }
24
45
  interface S {
25
46
  status: "loading" | "ready" | "error"; rows: MemberBookingRow[]; isMember: boolean; identityLine: string;
26
47
  emptyText: string; isLoading: boolean; notLoading: boolean; errored: boolean; notErrored: boolean; noEmpty: boolean;
@@ -28,6 +49,7 @@ interface S {
28
49
  scheduleMode: string; selectedDate: string; dayRows: MemberBookingRow[]; dayHeading: string;
29
50
  hideAgenda: boolean; hideCalendar: boolean; hideMonth: boolean; hideSchedule: boolean;
30
51
  dayEmptyText: string; decorations: Array<{ date: string; dotCount: number; dotColorToken: string }>;
52
+ weeklyLabel: string; weeklyRemainingLabel: string; weeklyPct: number; weeklyMet: boolean; hideTracker: boolean;
31
53
  nextCursor?: string; complete?: boolean; loadingMore?: boolean; pageError?: boolean; total?: number;
32
54
  }
33
55
  function derive(s: S): S {
@@ -36,7 +58,12 @@ function derive(s: S): S {
36
58
  const dayRows = selectedDate ? s.rows.filter(row => row.day === selectedDate) : [];
37
59
  const counts = new Map<string, number>();
38
60
  for (const row of s.rows) if (row.day) counts.set(row.day, (counts.get(row.day) ?? 0) + 1);
39
- return { ...s, scheduleMode: mode, selectedDate, dayRows, dayHeading: selectedDate ? dayLabel(selectedDate) : "", hideSchedule,
61
+ // Member-only, and only once this week's count was actually read (a failed read hides the card
62
+ // rather than claiming "0 of N").
63
+ const weekly = weeklyGoal > 0 && !hideSchedule && weeklyDone !== null ? weeklyGoalProgress(weeklyDone, weeklyGoal) : null;
64
+ return { ...s, scheduleMode: mode,
65
+ weeklyLabel: weekly?.label ?? "", weeklyRemainingLabel: weekly?.remainingLabel ?? "", weeklyPct: weekly?.fraction ?? 0,
66
+ weeklyMet: weekly?.met ?? false, hideTracker: !weekly, selectedDate, dayRows, dayHeading: selectedDate ? dayLabel(selectedDate) : "", hideSchedule,
40
67
  hideAgenda: hideSchedule || mode !== "agenda", hideCalendar: hideSchedule || mode === "agenda", hideMonth: mode !== "month",
41
68
  decorations: [...counts].map(([date, n]) => ({ date, dotCount: Math.min(n, 3), dotColorToken: "accentPrimary" })),
42
69
  dayEmptyText: dayRows.length ? "" : s.complete ? copyParam("bookings.emptyDay", "No bookings on this day.") : copyParam("bookings.emptyLoadedDay", "No bookings on this day in loaded results. Load more to check later pages."),
@@ -46,7 +73,12 @@ const svc = defineBackendCollection<S, MemberBookingRow>("himiBookingBookings",
46
73
  restorePagesOnLoad: true,
47
74
  state: derive({ status: "loading", rows: [], isMember: false, identityLine: "", emptyText: "", isLoading: true, notLoading: false,
48
75
  errored: false, notErrored: true, noEmpty: true, actionMessage: "", cancelPresented: false, cancelTitle: "",
49
- scheduleMode: mode, selectedDate, dayRows: [], dayHeading: "", hideAgenda: true, hideCalendar: true, hideMonth: true, hideSchedule: true, dayEmptyText: "", decorations: [] }),
76
+ scheduleMode: mode, selectedDate, dayRows: [], dayHeading: "", hideAgenda: true, hideCalendar: true, hideMonth: true, hideSchedule: true, dayEmptyText: "", decorations: [],
77
+ weeklyLabel: "", weeklyRemainingLabel: "", weeklyPct: 0, weeklyMet: false, hideTracker: true }),
78
+ onLoad(arg) {
79
+ const goal = parseWeeklyGoal((arg as Record<string, unknown> | undefined)?.weeklyGoal);
80
+ if (goal) weeklyGoal = goal;
81
+ },
50
82
  source: {
51
83
  id: row => row.id,
52
84
  clearOnError: memberAccessDenied,
@@ -55,12 +87,17 @@ const svc = defineBackendCollection<S, MemberBookingRow>("himiBookingBookings",
55
87
  const member = await memberAccess();
56
88
  if (cursor && (!pageMember || pageMember.email !== member.email || pageMember.scope !== member.scope)) throw memberAccessChanged();
57
89
  if (!cursor || !queryNow) queryNow = new Date().toISOString();
58
- return fetchMemberBookings(criteria, cursor, queryNow, member);
90
+ const page = await fetchMemberBookings(criteria, cursor, queryNow, member);
91
+ if (cursor) return page;
92
+ const weekly = weeklyGoal > 0 && member.email ? await fetchWeeklySessionsDone(member, Date.now()) : null;
93
+ return { ...page, metadata: { ...page.metadata, weeklyDone: weekly } };
59
94
  },
60
95
  },
61
96
  apply(s, page) {
62
97
  const member = { email: String(page.metadata?.email ?? ""), scope: String(page.metadata?.scope ?? "") };
63
- if (page.status === "loading" || !member.email) { pageMember = undefined; cancelTarget = undefined; }
98
+ if (page.status === "loading" || !member.email) { pageMember = undefined; cancelTarget = undefined; weeklyDone = null; }
99
+ const weekly = page.metadata?.weeklyDone;
100
+ if (page.status === "ready" && !page.loadingMore && (typeof weekly === "number" || weekly === null)) weeklyDone = weekly;
64
101
  if (page.status === "ready" && !page.loadingMore && !page.pageError) pageMember = member;
65
102
  const loading = page.status === "loading", errored = page.status === "error";
66
103
  return derive({ ...s, status: loading ? "loading" : errored ? "error" : "ready", rows: page.items, isMember: !!member.email,