@wix/himalaya-cli 0.1257.0 → 0.1259.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 (81) hide show
  1. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/motion/src/index.d.ts +45 -5
  2. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/sdk-types/src/capabilities.generated.d.ts +1 -1
  3. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/audio-record.mjs +1 -1
  4. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/calendar.mjs +1 -1
  5. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/calls.mjs +1 -1
  6. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/contacts.mjs +1 -1
  7. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/location.mjs +1 -1
  8. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/motion.mjs +18 -2
  9. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/photos.mjs +1 -1
  10. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/sdk-types.mjs +1 -1
  11. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/tasks.mjs +1 -1
  12. package/dist/cli.mjs +47 -23
  13. package/dist/preview-assets.generated.bin +0 -0
  14. package/guides/sdk-reference.json +15 -3
  15. package/package.json +2 -2
  16. package/templates/beauty-salon/tier5-src/_shared/collection-service.ts +7 -0
  17. package/templates/beauty-salon/tier5-src/_shared/weekly-goal.ts +107 -0
  18. package/templates/beauty-salon/tier5-src/himi-booking-bookings/index.ts +41 -4
  19. package/templates/beauty-salon/tier5-src/himi-branded-lite-home/index.ts +31 -7
  20. package/templates/beauty-salon-owner/dev/index.ts +4 -1
  21. package/templates/beauty-salon-owner/tier5-src/_shared/collection-service.ts +7 -0
  22. package/templates/branded-lite/config.ts +14 -1
  23. package/templates/branded-lite/dev/index.ts +845 -2
  24. package/templates/branded-lite/tier5-src/_shared/collection-service.ts +7 -0
  25. package/templates/branded-lite/tier5-src/_shared/weekly-goal.ts +107 -0
  26. package/templates/branded-lite/tier5-src/himi-booking-bookings/index.ts +41 -4
  27. package/templates/branded-lite/tier5-src/himi-branded-lite-home/index.ts +31 -7
  28. package/templates/branded-lite/tier5-src/himi-branded-lite-steps/index.ts +524 -0
  29. package/templates/community-club/tier5-src/_shared/collection-service.ts +7 -0
  30. package/templates/community-club/tier5-src/_shared/weekly-goal.ts +107 -0
  31. package/templates/community-club/tier5-src/himi-branded-lite-home/index.ts +31 -7
  32. package/templates/community-club-owner/dev/index.ts +4 -1
  33. package/templates/community-club-owner/tier5-src/_shared/collection-service.ts +7 -0
  34. package/templates/events-meetups/tier5-src/_shared/collection-service.ts +7 -0
  35. package/templates/events-meetups/tier5-src/_shared/weekly-goal.ts +107 -0
  36. package/templates/events-meetups/tier5-src/himi-branded-lite-home/index.ts +31 -7
  37. package/templates/events-meetups-owner/dev/index.ts +4 -1
  38. package/templates/events-meetups-owner/tier5-src/_shared/collection-service.ts +7 -0
  39. package/templates/gym-fitness/config.ts +14 -1
  40. package/templates/gym-fitness/dev/index.ts +844 -1
  41. package/templates/gym-fitness/tier5-src/_shared/collection-service.ts +7 -0
  42. package/templates/gym-fitness/tier5-src/_shared/weekly-goal.ts +107 -0
  43. package/templates/gym-fitness/tier5-src/himi-booking-bookings/index.ts +41 -4
  44. package/templates/gym-fitness/tier5-src/himi-branded-lite-home/index.ts +31 -7
  45. package/templates/gym-fitness/tier5-src/himi-branded-lite-steps/index.ts +524 -0
  46. package/templates/gym-fitness-owner/dev/index.ts +4 -1
  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/dev/index.ts +4 -1
  52. package/templates/nonprofit-cause-owner/tier5-src/_shared/collection-service.ts +7 -0
  53. package/templates/owner-lite/dev/index.ts +4 -1
  54. package/templates/owner-lite/tier5-src/_shared/collection-service.ts +7 -0
  55. package/templates/podcast-creator/tier5-src/_shared/collection-service.ts +7 -0
  56. package/templates/podcast-creator/tier5-src/_shared/weekly-goal.ts +107 -0
  57. package/templates/podcast-creator/tier5-src/himi-branded-lite-home/index.ts +31 -7
  58. package/templates/podcast-creator-owner/dev/index.ts +4 -1
  59. package/templates/podcast-creator-owner/tier5-src/_shared/collection-service.ts +7 -0
  60. package/templates/portfolio-creative/tier5-src/_shared/collection-service.ts +7 -0
  61. package/templates/portfolio-creative/tier5-src/_shared/weekly-goal.ts +107 -0
  62. package/templates/portfolio-creative/tier5-src/himi-branded-lite-home/index.ts +31 -7
  63. package/templates/portfolio-creative-owner/dev/index.ts +4 -1
  64. package/templates/portfolio-creative-owner/tier5-src/_shared/collection-service.ts +7 -0
  65. package/templates/restaurant/tier5-src/_shared/collection-service.ts +7 -0
  66. package/templates/restaurant/tier5-src/_shared/weekly-goal.ts +107 -0
  67. package/templates/restaurant/tier5-src/himi-branded-lite-home/index.ts +31 -7
  68. package/templates/restaurant-owner/dev/index.ts +4 -1
  69. package/templates/restaurant-owner/tier5-src/_shared/collection-service.ts +7 -0
  70. package/templates/retail-store/tier5-src/_shared/collection-service.ts +7 -0
  71. package/templates/retail-store/tier5-src/_shared/weekly-goal.ts +107 -0
  72. package/templates/retail-store/tier5-src/himi-branded-lite-home/index.ts +31 -7
  73. package/templates/retail-store-owner/dev/index.ts +4 -1
  74. package/templates/retail-store-owner/tier5-src/_shared/collection-service.ts +7 -0
  75. package/templates/yoga-studio/dev/index.ts +90 -1
  76. package/templates/yoga-studio/tier5-src/_shared/collection-service.ts +7 -0
  77. package/templates/yoga-studio/tier5-src/_shared/weekly-goal.ts +107 -0
  78. package/templates/yoga-studio/tier5-src/himi-booking-bookings/index.ts +41 -4
  79. package/templates/yoga-studio/tier5-src/himi-branded-lite-home/index.ts +31 -7
  80. package/templates/yoga-studio-owner/dev/index.ts +4 -1
  81. package/templates/yoga-studio-owner/tier5-src/_shared/collection-service.ts +7 -0
@@ -2,6 +2,19 @@ import type { PermissionStatus } from "@wix/himalaya/sdk-types";
2
2
  export type { PermissionStatus } from "@wix/himalaya/sdk-types";
3
3
  /** Which sensor a watch streams. */
4
4
  export type MotionSensor = "steps" | "altitude" | "heading";
5
+ /**
6
+ * Whether `getStepCount` can answer a PAST window right now, and if not, what would fix it.
7
+ *
8
+ * available it can — "steps today" is a real daily total.
9
+ * needs_permission `requestPermission()` (or `openStepHistorySetup()`) would unlock it.
10
+ * needs_setup a system component is missing or out of date — on Android, Google Play
11
+ * services. `openStepHistorySetup()` takes the user to update it.
12
+ * denied the user refused; only the system Settings app can undo that.
13
+ * unsupported this device / build cannot answer a past window: web, macOS, a device
14
+ * with no pedometer, an Android app that links no step store, or a phone
15
+ * without Google Play services. Count live through `watch()` instead.
16
+ */
17
+ export type StepHistoryStatus = "available" | "needs_permission" | "needs_setup" | "denied" | "unsupported";
5
18
  /** What this device can actually do. Never assume — a barometer is common but not universal. */
6
19
  export interface MotionAvailability {
7
20
  /** Pedometer / step counter present (and, on Android, the runtime permission held). */
@@ -10,6 +23,9 @@ export interface MotionAvailability {
10
23
  altimeter: boolean;
11
24
  /** Magnetometer / compass present. */
12
25
  heading: boolean;
26
+ /** Whether `getStepCount` can answer a past window — see {@link StepHistoryStatus}. An
27
+ * unknown or absent value reads as "unsupported", never as "available". */
28
+ stepHistory: StepHistoryStatus;
13
29
  }
14
30
  export interface StepSample {
15
31
  /** Steps in the sampled window (a DELTA, not a lifetime total). */
@@ -20,6 +36,13 @@ export interface StepSample {
20
36
  distanceM?: number;
21
37
  /** Floors climbed, when the platform reports it (iOS CMPedometer only). */
22
38
  floorsAscended?: number;
39
+ /** Android only: the step counter's RUNNING total since the last device restart. The first
40
+ * sample of a stream carries it with `steps: 0`, so a bundle that saves it (with
41
+ * `bootTimeMs`) can add the steps taken while it was not listening — same boot ⇒ the counter
42
+ * is continuous. Absent on iOS (use `getStepCount` there) and web. */
43
+ stepsSinceBoot?: number;
44
+ /** Android only: when that restart was, epoch ms. A different value means the counter reset. */
45
+ bootTimeMs?: number;
23
46
  timestamp: number;
24
47
  }
25
48
  export interface AltitudeSample {
@@ -55,15 +78,32 @@ export declare function requestPermission(): Promise<PermissionStatus>;
55
78
  * an elevation-gain readout on a device with no barometer should say so, not show 0 m.
56
79
  */
57
80
  export declare function availability(): Promise<MotionAvailability>;
81
+ /**
82
+ * Take the user to whatever would make `stepHistory` "available": on Android, update Google Play
83
+ * services (`needs_setup`) or grant step access (`needs_permission`). Resolves
84
+ * once the user is back in the app, with whether anything was opened. Call `availability()`
85
+ * again afterwards — opening the store is not the same as installing.
86
+ *
87
+ * iOS, macOS and web have nothing to open and resolve false: iOS step history is CoreMotion's,
88
+ * unlocked by `requestPermission()`. Raise this only from a user gesture — it leaves the app.
89
+ */
90
+ export declare function openStepHistorySetup(): Promise<boolean>;
58
91
  /**
59
92
  * Steps between two epoch-ms instants — HISTORICAL, so it can answer "how many steps today"
60
93
  * even though the app was not running. Backed by CoreMotion's stored pedometer data (iOS,
61
- * ~7 days).
94
+ * ~7 days) and, on Android, by an opt-in step store.
62
95
  *
63
- * **ANDROID ALWAYS RETURNS NULL.** The platform step counter exposes only a cumulative total
64
- * since boot with no timestamps, so a past window is genuinely unanswerable without Health
65
- * Connect (which would be a new dependency). On Android, accumulate live through
66
- * `watch({ sensor: "steps" })` instead.
96
+ * **ANDROID ANSWERS FROM A STEP STORE, NEVER FROM THE APP ITSELF.** The platform step counter
97
+ * exposes only a cumulative total since boot with no dates, and an app the user is not using
98
+ * receives no sensor events, so it cannot keep its own midnight baseline. A store that records on
99
+ * its own fills that, and with several the larger answer wins:
100
+ * - Google's Recording API (Play services records the steps, ~10 days on the device, no
101
+ * account), in an app that links the opt-in `:core-runtime-step-recording` module — its
102
+ * history starts at the first grant, so the first day is partial.
103
+ * Health Connect is not a motion store: read it through `@himalaya/health` (the `health`
104
+ * capability), which the runtime gates per bundle.
105
+ * `availability().stepHistory` says whether one can answer. Otherwise this returns null;
106
+ * accumulate live through `watch({ sensor: "steps" })` instead.
67
107
  *
68
108
  * Returns null when unavailable / not permitted, and 0 for a genuinely still window — the
69
109
  * distinction matters, so don't collapse it with `?? 0` before you have branched on it, or a
@@ -22,7 +22,7 @@ export declare const CAPABILITY_REGISTRY: {
22
22
  readonly local_database: readonly ["availability", "count", "get", "getAll", "purge", "query", "queueDepth", "queueDrain", "queueEnqueue", "remove", "upsert"];
23
23
  readonly location: readonly ["backgroundStart", "backgroundStop", "getCurrent", "getPermissionStatus", "regionAdd", "regionClear", "regionList", "regionNext", "regionRemove", "regionSupport", "requestPermission", "watchNext", "watchStart", "watchStop"];
24
24
  readonly media_playback: readonly ["download", "getCapabilities", "getState", "next", "pause", "pictureInPicture", "play", "presentFullscreen", "previous", "release", "removeDownload", "seek", "seekTo", "setMuted", "setQueue", "setRate", "skip", "status", "stop", "subscribeStatus", "unsubscribeStatus"];
25
- readonly motion: readonly ["availability", "getAltitude", "getHeading", "getPermissionStatus", "getStepCount", "requestPermission", "watchNext", "watchStart", "watchStop"];
25
+ readonly motion: readonly ["availability", "getAltitude", "getHeading", "getPermissionStatus", "getStepCount", "openStepHistorySetup", "requestPermission", "watchNext", "watchStart", "watchStop"];
26
26
  readonly on_device_ai: readonly ["availability", "generateText"];
27
27
  readonly open_url: readonly ["canOpen", "open"];
28
28
  readonly pdf: readonly ["isAvailable", "open"];
@@ -37,7 +37,7 @@ var CAPABILITY_REGISTRY = {
37
37
  "local_database": ["availability", "count", "get", "getAll", "purge", "query", "queueDepth", "queueDrain", "queueEnqueue", "remove", "upsert"],
38
38
  "location": ["backgroundStart", "backgroundStop", "getCurrent", "getPermissionStatus", "regionAdd", "regionClear", "regionList", "regionNext", "regionRemove", "regionSupport", "requestPermission", "watchNext", "watchStart", "watchStop"],
39
39
  "media_playback": ["download", "getCapabilities", "getState", "next", "pause", "pictureInPicture", "play", "presentFullscreen", "previous", "release", "removeDownload", "seek", "seekTo", "setMuted", "setQueue", "setRate", "skip", "status", "stop", "subscribeStatus", "unsubscribeStatus"],
40
- "motion": ["availability", "getAltitude", "getHeading", "getPermissionStatus", "getStepCount", "requestPermission", "watchNext", "watchStart", "watchStop"],
40
+ "motion": ["availability", "getAltitude", "getHeading", "getPermissionStatus", "getStepCount", "openStepHistorySetup", "requestPermission", "watchNext", "watchStart", "watchStop"],
41
41
  "on_device_ai": ["availability", "generateText"],
42
42
  "open_url": ["canOpen", "open"],
43
43
  "pdf": ["isAvailable", "open"],
@@ -37,7 +37,7 @@ var CAPABILITY_REGISTRY = {
37
37
  "local_database": ["availability", "count", "get", "getAll", "purge", "query", "queueDepth", "queueDrain", "queueEnqueue", "remove", "upsert"],
38
38
  "location": ["backgroundStart", "backgroundStop", "getCurrent", "getPermissionStatus", "regionAdd", "regionClear", "regionList", "regionNext", "regionRemove", "regionSupport", "requestPermission", "watchNext", "watchStart", "watchStop"],
39
39
  "media_playback": ["download", "getCapabilities", "getState", "next", "pause", "pictureInPicture", "play", "presentFullscreen", "previous", "release", "removeDownload", "seek", "seekTo", "setMuted", "setQueue", "setRate", "skip", "status", "stop", "subscribeStatus", "unsubscribeStatus"],
40
- "motion": ["availability", "getAltitude", "getHeading", "getPermissionStatus", "getStepCount", "requestPermission", "watchNext", "watchStart", "watchStop"],
40
+ "motion": ["availability", "getAltitude", "getHeading", "getPermissionStatus", "getStepCount", "openStepHistorySetup", "requestPermission", "watchNext", "watchStart", "watchStop"],
41
41
  "on_device_ai": ["availability", "generateText"],
42
42
  "open_url": ["canOpen", "open"],
43
43
  "pdf": ["isAvailable", "open"],
@@ -37,7 +37,7 @@ var CAPABILITY_REGISTRY = {
37
37
  "local_database": ["availability", "count", "get", "getAll", "purge", "query", "queueDepth", "queueDrain", "queueEnqueue", "remove", "upsert"],
38
38
  "location": ["backgroundStart", "backgroundStop", "getCurrent", "getPermissionStatus", "regionAdd", "regionClear", "regionList", "regionNext", "regionRemove", "regionSupport", "requestPermission", "watchNext", "watchStart", "watchStop"],
39
39
  "media_playback": ["download", "getCapabilities", "getState", "next", "pause", "pictureInPicture", "play", "presentFullscreen", "previous", "release", "removeDownload", "seek", "seekTo", "setMuted", "setQueue", "setRate", "skip", "status", "stop", "subscribeStatus", "unsubscribeStatus"],
40
- "motion": ["availability", "getAltitude", "getHeading", "getPermissionStatus", "getStepCount", "requestPermission", "watchNext", "watchStart", "watchStop"],
40
+ "motion": ["availability", "getAltitude", "getHeading", "getPermissionStatus", "getStepCount", "openStepHistorySetup", "requestPermission", "watchNext", "watchStart", "watchStop"],
41
41
  "on_device_ai": ["availability", "generateText"],
42
42
  "open_url": ["canOpen", "open"],
43
43
  "pdf": ["isAvailable", "open"],
@@ -37,7 +37,7 @@ var CAPABILITY_REGISTRY = {
37
37
  "local_database": ["availability", "count", "get", "getAll", "purge", "query", "queueDepth", "queueDrain", "queueEnqueue", "remove", "upsert"],
38
38
  "location": ["backgroundStart", "backgroundStop", "getCurrent", "getPermissionStatus", "regionAdd", "regionClear", "regionList", "regionNext", "regionRemove", "regionSupport", "requestPermission", "watchNext", "watchStart", "watchStop"],
39
39
  "media_playback": ["download", "getCapabilities", "getState", "next", "pause", "pictureInPicture", "play", "presentFullscreen", "previous", "release", "removeDownload", "seek", "seekTo", "setMuted", "setQueue", "setRate", "skip", "status", "stop", "subscribeStatus", "unsubscribeStatus"],
40
- "motion": ["availability", "getAltitude", "getHeading", "getPermissionStatus", "getStepCount", "requestPermission", "watchNext", "watchStart", "watchStop"],
40
+ "motion": ["availability", "getAltitude", "getHeading", "getPermissionStatus", "getStepCount", "openStepHistorySetup", "requestPermission", "watchNext", "watchStart", "watchStop"],
41
41
  "on_device_ai": ["availability", "generateText"],
42
42
  "open_url": ["canOpen", "open"],
43
43
  "pdf": ["isAvailable", "open"],
@@ -37,7 +37,7 @@ var CAPABILITY_REGISTRY = {
37
37
  "local_database": ["availability", "count", "get", "getAll", "purge", "query", "queueDepth", "queueDrain", "queueEnqueue", "remove", "upsert"],
38
38
  "location": ["backgroundStart", "backgroundStop", "getCurrent", "getPermissionStatus", "regionAdd", "regionClear", "regionList", "regionNext", "regionRemove", "regionSupport", "requestPermission", "watchNext", "watchStart", "watchStop"],
39
39
  "media_playback": ["download", "getCapabilities", "getState", "next", "pause", "pictureInPicture", "play", "presentFullscreen", "previous", "release", "removeDownload", "seek", "seekTo", "setMuted", "setQueue", "setRate", "skip", "status", "stop", "subscribeStatus", "unsubscribeStatus"],
40
- "motion": ["availability", "getAltitude", "getHeading", "getPermissionStatus", "getStepCount", "requestPermission", "watchNext", "watchStart", "watchStop"],
40
+ "motion": ["availability", "getAltitude", "getHeading", "getPermissionStatus", "getStepCount", "openStepHistorySetup", "requestPermission", "watchNext", "watchStart", "watchStop"],
41
41
  "on_device_ai": ["availability", "generateText"],
42
42
  "open_url": ["canOpen", "open"],
43
43
  "pdf": ["isAvailable", "open"],
@@ -37,7 +37,7 @@ var CAPABILITY_REGISTRY = {
37
37
  "local_database": ["availability", "count", "get", "getAll", "purge", "query", "queueDepth", "queueDrain", "queueEnqueue", "remove", "upsert"],
38
38
  "location": ["backgroundStart", "backgroundStop", "getCurrent", "getPermissionStatus", "regionAdd", "regionClear", "regionList", "regionNext", "regionRemove", "regionSupport", "requestPermission", "watchNext", "watchStart", "watchStop"],
39
39
  "media_playback": ["download", "getCapabilities", "getState", "next", "pause", "pictureInPicture", "play", "presentFullscreen", "previous", "release", "removeDownload", "seek", "seekTo", "setMuted", "setQueue", "setRate", "skip", "status", "stop", "subscribeStatus", "unsubscribeStatus"],
40
- "motion": ["availability", "getAltitude", "getHeading", "getPermissionStatus", "getStepCount", "requestPermission", "watchNext", "watchStart", "watchStop"],
40
+ "motion": ["availability", "getAltitude", "getHeading", "getPermissionStatus", "getStepCount", "openStepHistorySetup", "requestPermission", "watchNext", "watchStart", "watchStop"],
41
41
  "on_device_ai": ["availability", "generateText"],
42
42
  "open_url": ["canOpen", "open"],
43
43
  "pdf": ["isAvailable", "open"],
@@ -64,6 +64,13 @@ function normalizePermissionStatus(s) {
64
64
  }
65
65
 
66
66
  // ../../core/sdk/motion/src/index.ts
67
+ var STEP_HISTORY_STATUSES = [
68
+ "available",
69
+ "needs_permission",
70
+ "needs_setup",
71
+ "denied",
72
+ "unsupported"
73
+ ];
67
74
  async function getPermissionStatus() {
68
75
  const r = await dispatch("capability.motion.getPermissionStatus");
69
76
  return normalizePermissionStatus(r?.status);
@@ -77,9 +84,17 @@ async function availability() {
77
84
  return {
78
85
  steps: r?.steps === true,
79
86
  altimeter: r?.altimeter === true,
80
- heading: r?.heading === true
87
+ heading: r?.heading === true,
88
+ stepHistory: normalizeStepHistory(r?.stepHistory)
81
89
  };
82
90
  }
91
+ function normalizeStepHistory(raw) {
92
+ return STEP_HISTORY_STATUSES.includes(raw) ? raw : "unsupported";
93
+ }
94
+ async function openStepHistorySetup() {
95
+ const r = await dispatch("capability.motion.openStepHistorySetup");
96
+ return r?.opened === true;
97
+ }
83
98
  async function getStepCount(fromMs, toMs) {
84
99
  const r = await dispatch("capability.motion.getStepCount", { fromMs, toMs });
85
100
  return typeof r?.steps === "number" ? r.steps : null;
@@ -142,6 +157,7 @@ export {
142
157
  getHeading,
143
158
  getPermissionStatus,
144
159
  getStepCount,
160
+ openStepHistorySetup,
145
161
  requestPermission,
146
162
  version,
147
163
  watch
@@ -37,7 +37,7 @@ var CAPABILITY_REGISTRY = {
37
37
  "local_database": ["availability", "count", "get", "getAll", "purge", "query", "queueDepth", "queueDrain", "queueEnqueue", "remove", "upsert"],
38
38
  "location": ["backgroundStart", "backgroundStop", "getCurrent", "getPermissionStatus", "regionAdd", "regionClear", "regionList", "regionNext", "regionRemove", "regionSupport", "requestPermission", "watchNext", "watchStart", "watchStop"],
39
39
  "media_playback": ["download", "getCapabilities", "getState", "next", "pause", "pictureInPicture", "play", "presentFullscreen", "previous", "release", "removeDownload", "seek", "seekTo", "setMuted", "setQueue", "setRate", "skip", "status", "stop", "subscribeStatus", "unsubscribeStatus"],
40
- "motion": ["availability", "getAltitude", "getHeading", "getPermissionStatus", "getStepCount", "requestPermission", "watchNext", "watchStart", "watchStop"],
40
+ "motion": ["availability", "getAltitude", "getHeading", "getPermissionStatus", "getStepCount", "openStepHistorySetup", "requestPermission", "watchNext", "watchStart", "watchStop"],
41
41
  "on_device_ai": ["availability", "generateText"],
42
42
  "open_url": ["canOpen", "open"],
43
43
  "pdf": ["isAvailable", "open"],
@@ -22,7 +22,7 @@ var CAPABILITY_REGISTRY = {
22
22
  "local_database": ["availability", "count", "get", "getAll", "purge", "query", "queueDepth", "queueDrain", "queueEnqueue", "remove", "upsert"],
23
23
  "location": ["backgroundStart", "backgroundStop", "getCurrent", "getPermissionStatus", "regionAdd", "regionClear", "regionList", "regionNext", "regionRemove", "regionSupport", "requestPermission", "watchNext", "watchStart", "watchStop"],
24
24
  "media_playback": ["download", "getCapabilities", "getState", "next", "pause", "pictureInPicture", "play", "presentFullscreen", "previous", "release", "removeDownload", "seek", "seekTo", "setMuted", "setQueue", "setRate", "skip", "status", "stop", "subscribeStatus", "unsubscribeStatus"],
25
- "motion": ["availability", "getAltitude", "getHeading", "getPermissionStatus", "getStepCount", "requestPermission", "watchNext", "watchStart", "watchStop"],
25
+ "motion": ["availability", "getAltitude", "getHeading", "getPermissionStatus", "getStepCount", "openStepHistorySetup", "requestPermission", "watchNext", "watchStart", "watchStop"],
26
26
  "on_device_ai": ["availability", "generateText"],
27
27
  "open_url": ["canOpen", "open"],
28
28
  "pdf": ["isAvailable", "open"],
@@ -37,7 +37,7 @@ var CAPABILITY_REGISTRY = {
37
37
  "local_database": ["availability", "count", "get", "getAll", "purge", "query", "queueDepth", "queueDrain", "queueEnqueue", "remove", "upsert"],
38
38
  "location": ["backgroundStart", "backgroundStop", "getCurrent", "getPermissionStatus", "regionAdd", "regionClear", "regionList", "regionNext", "regionRemove", "regionSupport", "requestPermission", "watchNext", "watchStart", "watchStop"],
39
39
  "media_playback": ["download", "getCapabilities", "getState", "next", "pause", "pictureInPicture", "play", "presentFullscreen", "previous", "release", "removeDownload", "seek", "seekTo", "setMuted", "setQueue", "setRate", "skip", "status", "stop", "subscribeStatus", "unsubscribeStatus"],
40
- "motion": ["availability", "getAltitude", "getHeading", "getPermissionStatus", "getStepCount", "requestPermission", "watchNext", "watchStart", "watchStop"],
40
+ "motion": ["availability", "getAltitude", "getHeading", "getPermissionStatus", "getStepCount", "openStepHistorySetup", "requestPermission", "watchNext", "watchStart", "watchStop"],
41
41
  "on_device_ai": ["availability", "generateText"],
42
42
  "open_url": ["canOpen", "open"],
43
43
  "pdf": ["isAvailable", "open"],
package/dist/cli.mjs CHANGED
@@ -17302,7 +17302,9 @@ var init_native_requirements = __esm({
17302
17302
  "motion: CoreMotion (CMPedometer + CMAltimeter) and Android SensorManager (TYPE_STEP_COUNTER / TYPE_PRESSURE / TYPE_MAGNETIC_FIELD). Sensor reads stay on device unless the app transmits them.",
17303
17303
  "ACTIVITY_RECOGNITION is runtime-granted on Android 10+ and gates ONLY the step counter \u2014 barometer and compass keep working when it is denied, so a denied grant must degrade the steps tile rather than the whole screen.",
17304
17304
  "iOS heading is delivered by CoreLocation, not CoreMotion: an app using `watch({ sensor: 'heading' })` must ALSO declare `location` (and hold that permission) or headings never arrive. This is the single most common motion integration bug.",
17305
- "No barometer exists on the iOS Simulator or most Android emulators. Verify elevation features on real hardware \u2014 `availability().altimeter` is false in a simulator, so a simulator-only test proves nothing about the altitude path."
17305
+ "No barometer exists on the iOS Simulator or most Android emulators. Verify elevation features on real hardware \u2014 `availability().altimeter` is false in a simulator, so a simulator-only test proves nothing about the altitude path.",
17306
+ "Android daily step totals (getStepCount over a past window) come from an opt-in step STORE, never from the app itself: the step counter keeps one total since boot with no dates, and an app the user is not using has an idle uid that receives no sensor events, so no job or alarm can take a midnight reading. The store is Google's Recording API (:core-runtime-step-recording, `StepRecording.install` at boot). Health Connect is deliberately not a motion store \u2014 reading it is the `health` capability, gated per bundle. This row adds no permission beyond ACTIVITY_RECOGNITION, which the Recording API needs.",
17307
+ 'Recording API (:core-runtime-step-recording, opt-in): Google Play services records the step count itself and keeps up to 10 days ON THE DEVICE, with no Google account; the app reads the day\'s total when a screen opens and writes nothing. History starts at the first subscription (the first grant), so the first day is partial. Phones without Google Play services answer `stepHistory: "unsupported"` and fall back to the live count. The Fitness data-safety row above covers it; nothing leaves the device unless the app transmits it.'
17306
17308
  ]
17307
17309
  }
17308
17310
  },
@@ -22857,7 +22859,7 @@ var init_capabilities_generated = __esm({
22857
22859
  "local_database": ["availability", "count", "get", "getAll", "purge", "query", "queueDepth", "queueDrain", "queueEnqueue", "remove", "upsert"],
22858
22860
  "location": ["backgroundStart", "backgroundStop", "getCurrent", "getPermissionStatus", "regionAdd", "regionClear", "regionList", "regionNext", "regionRemove", "regionSupport", "requestPermission", "watchNext", "watchStart", "watchStop"],
22859
22861
  "media_playback": ["download", "getCapabilities", "getState", "next", "pause", "pictureInPicture", "play", "presentFullscreen", "previous", "release", "removeDownload", "seek", "seekTo", "setMuted", "setQueue", "setRate", "skip", "status", "stop", "subscribeStatus", "unsubscribeStatus"],
22860
- "motion": ["availability", "getAltitude", "getHeading", "getPermissionStatus", "getStepCount", "requestPermission", "watchNext", "watchStart", "watchStop"],
22862
+ "motion": ["availability", "getAltitude", "getHeading", "getPermissionStatus", "getStepCount", "openStepHistorySetup", "requestPermission", "watchNext", "watchStart", "watchStop"],
22861
22863
  "on_device_ai": ["availability", "generateText"],
22862
22864
  "open_url": ["canOpen", "open"],
22863
22865
  "pdf": ["isAvailable", "open"],
@@ -22938,8 +22940,8 @@ var init_shell_capabilities_generated = __esm({
22938
22940
  appDir: "apps/himi-branded-lite",
22939
22941
  shared: false,
22940
22942
  extensible: true,
22941
- built: ["app_info", "calendar", "clipboard", "live_activity", "local_database", "media_playback", "open_url", "push", "release_control", "secure_storage", "share", "wix_api", "wix_platform"],
22942
- serves: ["app_info", "calendar", "clipboard", "live_activity", "local_database", "media_playback", "open_url", "push", "release_control", "secure_storage", "share", "wix_api", "wix_platform"]
22943
+ built: ["app_info", "calendar", "clipboard", "live_activity", "local_database", "media_playback", "motion", "open_url", "push", "release_control", "secure_storage", "share", "wix_api", "wix_platform"],
22944
+ serves: ["app_info", "calendar", "clipboard", "live_activity", "local_database", "media_playback", "motion", "open_url", "push", "release_control", "secure_storage", "share", "wix_api", "wix_platform"]
22943
22945
  },
22944
22946
  "brandy": {
22945
22947
  appDir: "apps/himi-brandy",
@@ -144517,23 +144519,23 @@ var init_preview_assets_generated = __esm({
144517
144519
  "../../packages/serve/src/preview-assets.generated.ts"() {
144518
144520
  init_preview_assets_format();
144519
144521
  PREVIEW_ASSET_MANIFEST = [
144520
- { key: "assets/index-2Jy1koGv.js", contentType: "application/javascript; charset=utf-8", offset: 8, length: 1212435, sha256: "6c6c56c9cd68ffb5a1510ec89e31b9cae20faada876179d6c481f0b7971ac213" },
144521
- { key: "assets/pdf.worker.min-BmVo14Nb.mjs", contentType: "application/octet-stream", offset: 1212443, length: 1317034, sha256: "a33cfe728c584fdba4fcc1fd54bcdc2f9f2f13889ddbb5b2bd1d0f8cbe49b84e" },
144522
- { key: "assets/pdfDocument-BBBfQkzv.js", contentType: "application/javascript; charset=utf-8", offset: 2529477, length: 489166, sha256: "8f6a97d134261b0cbc4547594c630f33af757331f25f2e10cff06928741dc198" },
144523
- { key: "fonts/Roboto-LICENSE.txt", contentType: "application/octet-stream", offset: 3018643, length: 4610, sha256: "994062dd7af4186a739de55dd9e151c63b6301f8e2cbafc608d35c2e87da0cd2" },
144524
- { key: "fonts/Roboto-Variable.ttf", contentType: "font/ttf", offset: 3023253, length: 488584, sha256: "d7598e12c5dbef095ff8272cfc55da0250bd07fbdecbac8a530b9b277872a134" },
144525
- { key: "fonts/WixMadeforDisplay-Bold.ttf", contentType: "font/ttf", offset: 3511837, length: 90924, sha256: "ec4c7d63772d980d6e147b2df6215fd2737e4b04cebe0cf7e11dc695fb63cdcf" },
144526
- { key: "fonts/WixMadeforDisplay-ExtraBold.ttf", contentType: "font/ttf", offset: 3602761, length: 90984, sha256: "bf4c16a2774edd38a921edf3099469866cd74c094fd596f3fa4e81f54a04dfaa" },
144527
- { key: "fonts/WixMadeforDisplay-Medium.ttf", contentType: "font/ttf", offset: 3693745, length: 90980, sha256: "368faca44fb9f7207e4af784e94750b1ee59c1098b8689e0f4a918926f244fb5" },
144528
- { key: "fonts/WixMadeforDisplay-Regular.ttf", contentType: "font/ttf", offset: 3784725, length: 90872, sha256: "97ed8f1a6772abe26e3d8af5cecfc4b02faa94497d585b0398b5053b739a70c1" },
144529
- { key: "fonts/WixMadeforDisplay-SemiBold.ttf", contentType: "font/ttf", offset: 3875597, length: 90980, sha256: "642feab8a48ddf6c7a89d7c2a7c0edfa0e6e773f671287e460e222703563191e" },
144530
- { key: "fonts/WixMadeforText-Bold.ttf", contentType: "font/ttf", offset: 3966577, length: 108636, sha256: "37c179b4fefb63ea9637322b84583a2df53aa226c150294eea1675c14b1b8e29" },
144531
- { key: "fonts/WixMadeforText-ExtraBold.ttf", contentType: "font/ttf", offset: 4075213, length: 109084, sha256: "62e2fe4718129f36ecdb0ae4de385bd6b81ecc876146447167c6c140fad699a9" },
144532
- { key: "fonts/WixMadeforText-Medium.ttf", contentType: "font/ttf", offset: 4184297, length: 109048, sha256: "4ecf270136af928612c76fe4ebade91d8156975e5ea4c0cf9225501dd1788e02" },
144533
- { key: "fonts/WixMadeforText-Regular.ttf", contentType: "font/ttf", offset: 4293345, length: 107700, sha256: "dee56f09fd3efc127c1ea95557edc74110c1460a46287da36e0af25efd341ef5" },
144534
- { key: "fonts/WixMadeforText-SemiBold.ttf", contentType: "font/ttf", offset: 4401045, length: 88108, sha256: "dced97a77624bc5f8b1ae65850360908297f4588e09feb6f22792d29dc7e765b" },
144535
- { key: "index.html", contentType: "text/html; charset=utf-8", offset: 4489153, length: 4947, sha256: "f4049083ac15256bb1621032f8b08be8cafcc608afb31472d86df1904237c455" },
144536
- { key: "t5-frame.html", contentType: "text/html; charset=utf-8", offset: 4494100, length: 17344, sha256: "d057298d75e7373e5e2c4d11b7d1bcbea88e03af555ba63d97641c78509c58e4" }
144522
+ { key: "assets/index-BlEeasLL.js", contentType: "application/javascript; charset=utf-8", offset: 8, length: 1213832, sha256: "a8237b1b52ea2668925107beba9e28aa67e9e91905b4a4f798eb0bd8001c1744" },
144523
+ { key: "assets/pdf.worker.min-BmVo14Nb.mjs", contentType: "application/octet-stream", offset: 1213840, length: 1317034, sha256: "a33cfe728c584fdba4fcc1fd54bcdc2f9f2f13889ddbb5b2bd1d0f8cbe49b84e" },
144524
+ { key: "assets/pdfDocument-B42oKMYf.js", contentType: "application/javascript; charset=utf-8", offset: 2530874, length: 489166, sha256: "49018b2728690ad63ea4a93c8bb09b680f6e9f78737df2f3f5a2e894a0d0f440" },
144525
+ { key: "fonts/Roboto-LICENSE.txt", contentType: "application/octet-stream", offset: 3020040, length: 4610, sha256: "994062dd7af4186a739de55dd9e151c63b6301f8e2cbafc608d35c2e87da0cd2" },
144526
+ { key: "fonts/Roboto-Variable.ttf", contentType: "font/ttf", offset: 3024650, length: 488584, sha256: "d7598e12c5dbef095ff8272cfc55da0250bd07fbdecbac8a530b9b277872a134" },
144527
+ { key: "fonts/WixMadeforDisplay-Bold.ttf", contentType: "font/ttf", offset: 3513234, length: 90924, sha256: "ec4c7d63772d980d6e147b2df6215fd2737e4b04cebe0cf7e11dc695fb63cdcf" },
144528
+ { key: "fonts/WixMadeforDisplay-ExtraBold.ttf", contentType: "font/ttf", offset: 3604158, length: 90984, sha256: "bf4c16a2774edd38a921edf3099469866cd74c094fd596f3fa4e81f54a04dfaa" },
144529
+ { key: "fonts/WixMadeforDisplay-Medium.ttf", contentType: "font/ttf", offset: 3695142, length: 90980, sha256: "368faca44fb9f7207e4af784e94750b1ee59c1098b8689e0f4a918926f244fb5" },
144530
+ { key: "fonts/WixMadeforDisplay-Regular.ttf", contentType: "font/ttf", offset: 3786122, length: 90872, sha256: "97ed8f1a6772abe26e3d8af5cecfc4b02faa94497d585b0398b5053b739a70c1" },
144531
+ { key: "fonts/WixMadeforDisplay-SemiBold.ttf", contentType: "font/ttf", offset: 3876994, length: 90980, sha256: "642feab8a48ddf6c7a89d7c2a7c0edfa0e6e773f671287e460e222703563191e" },
144532
+ { key: "fonts/WixMadeforText-Bold.ttf", contentType: "font/ttf", offset: 3967974, length: 108636, sha256: "37c179b4fefb63ea9637322b84583a2df53aa226c150294eea1675c14b1b8e29" },
144533
+ { key: "fonts/WixMadeforText-ExtraBold.ttf", contentType: "font/ttf", offset: 4076610, length: 109084, sha256: "62e2fe4718129f36ecdb0ae4de385bd6b81ecc876146447167c6c140fad699a9" },
144534
+ { key: "fonts/WixMadeforText-Medium.ttf", contentType: "font/ttf", offset: 4185694, length: 109048, sha256: "4ecf270136af928612c76fe4ebade91d8156975e5ea4c0cf9225501dd1788e02" },
144535
+ { key: "fonts/WixMadeforText-Regular.ttf", contentType: "font/ttf", offset: 4294742, length: 107700, sha256: "dee56f09fd3efc127c1ea95557edc74110c1460a46287da36e0af25efd341ef5" },
144536
+ { key: "fonts/WixMadeforText-SemiBold.ttf", contentType: "font/ttf", offset: 4402442, length: 88108, sha256: "dced97a77624bc5f8b1ae65850360908297f4588e09feb6f22792d29dc7e765b" },
144537
+ { key: "index.html", contentType: "text/html; charset=utf-8", offset: 4490550, length: 4947, sha256: "f41341372a0773c0bdbb3711e2f68b136fd110997452bd3829ce91d3200d7d40" },
144538
+ { key: "t5-frame.html", contentType: "text/html; charset=utf-8", offset: 4495497, length: 17344, sha256: "d057298d75e7373e5e2c4d11b7d1bcbea88e03af555ba63d97641c78509c58e4" }
144537
144539
  ];
144538
144540
  }
144539
144541
  });
@@ -157904,7 +157906,8 @@ function mergeCustomerOwned(committed, overlay) {
157904
157906
  "wix",
157905
157907
  "copy",
157906
157908
  "faq",
157907
- "site"
157909
+ "site",
157910
+ "goals"
157908
157911
  ];
157909
157912
  const customer = {};
157910
157913
  for (const key2 of CUSTOMER_OWNED) {
@@ -157924,7 +157927,23 @@ function mergeCustomerOwned(committed, overlay) {
157924
157927
  if (typeof value === "string" && value.trim() === "") delete overlayIdentity[key2];
157925
157928
  }
157926
157929
  if (customer.identity !== void 0) customer.identity = overlayIdentity;
157927
- return deepMerge4(committed, customer);
157930
+ const { goals: _shellGoals, ...shell } = committed;
157931
+ return deepMerge4(shell, customer);
157932
+ }
157933
+ function carryOverGoals(previousOverlayJson, overlay) {
157934
+ if (overlay.goals !== void 0 || !previousOverlayJson) return;
157935
+ try {
157936
+ const previous = JSON.parse(previousOverlayJson);
157937
+ const site = siteKeyOf(overlay);
157938
+ if (previous.goals !== void 0 && site !== "" && siteKeyOf(previous) === site) overlay.goals = previous.goals;
157939
+ } catch {
157940
+ }
157941
+ }
157942
+ function siteKeyOf(overlay) {
157943
+ const siteId = typeof overlay.siteId === "string" ? overlay.siteId.trim() : "";
157944
+ if (siteId) return `id:${siteId}`;
157945
+ const url = overlay.wix?.siteUrl;
157946
+ return typeof url === "string" && url.trim() ? `url:${url.trim().replace(/\/+$/, "").toLowerCase()}` : "";
157928
157947
  }
157929
157948
  function buildMergedContract(options) {
157930
157949
  const { appDir: appDir3, packageDir, overlay } = options;
@@ -159196,6 +159215,11 @@ async function runSiteAnalyze(opts) {
159196
159215
  ];
159197
159216
  }
159198
159217
  }
159218
+ const previousOverlay = resolve55(outDir, "provisioning.overlay.json");
159219
+ carryOverGoals(
159220
+ existsSync72(previousOverlay) ? readFileSync89(previousOverlay, "utf8") : void 0,
159221
+ result.provisioningOverlay
159222
+ );
159199
159223
  const ownerCall = ownerAuth ? ownerTransportFrom(fetchImpl, ownerAuth) : void 0;
159200
159224
  const written = await writeBusinessBook(result, {
159201
159225
  outDir,
Binary file
@@ -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.1257.0",
3
+ "version": "0.1259.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": "3162062044b9060ac9bd3c1ecb31da19697abd05f8feec2b6651eef5"
70
+ "falconPackageHash": "b9cf70c3d15cf4e373ad15bfa2c5de036e90e1c9a065fe0e30d0ce07"
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
+ }