@wix/himalaya-cli 0.1945.0 → 0.1947.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/motion.mjs +1 -0
- package/dist/browser-plane/assets.json +5 -5
- package/dist/browser-plane/preview-deferred/{e113c7cdcf8f56ad861b2564505fab2a1975c7a995f92d2f999f9c4ce1a09a40.bin → da958a2a47eef7082c7892c1cc755a58bbeefcb4b617b47fde87f1ce567b3e64.bin} +1 -1
- package/dist/browser-plane/sw.js +7 -7
- package/dist/cli.mjs +811 -283
- package/dist/preview-assets.generated.bin +0 -0
- package/guides/himi-json-output.md +7 -0
- package/guides/himi-test.md +31 -0
- package/package.json +2 -2
- package/templates/bare-fashion/tier5-src/_shared/engine-intl.ts +65 -0
- package/templates/beauty-salon/dev/index.ts +1 -0
- package/templates/beauty-salon/tier5-src/_shared/engine-intl.ts +65 -0
- package/templates/beauty-salon/tier5-src/_shared/weekly-goal.ts +28 -12
- package/templates/beauty-salon/tier5-src/himi-booking-bookings/index.ts +7 -2
- package/templates/beauty-salon/tier5-src/himi-branded-lite-home/index.ts +8 -8
- package/templates/beauty-salon-owner/tier5-src/_shared/engine-intl.ts +65 -0
- package/templates/branded-lite/dev/index.ts +4 -2
- package/templates/branded-lite/l10n/ar.json +5 -5
- package/templates/branded-lite/l10n/cs.json +5 -5
- package/templates/branded-lite/l10n/da.json +5 -5
- package/templates/branded-lite/l10n/de.json +5 -5
- package/templates/branded-lite/l10n/el.json +5 -5
- package/templates/branded-lite/l10n/es.json +5 -5
- package/templates/branded-lite/l10n/fi.json +5 -5
- package/templates/branded-lite/l10n/fr.json +5 -5
- package/templates/branded-lite/l10n/he.json +4 -4
- package/templates/branded-lite/l10n/hu.json +5 -5
- package/templates/branded-lite/l10n/id.json +5 -5
- package/templates/branded-lite/l10n/it.json +5 -5
- package/templates/branded-lite/l10n/ja.json +5 -5
- package/templates/branded-lite/l10n/ko.json +5 -5
- package/templates/branded-lite/l10n/lt.json +5 -5
- package/templates/branded-lite/l10n/nl.json +5 -5
- package/templates/branded-lite/l10n/no.json +5 -5
- package/templates/branded-lite/l10n/pl.json +5 -5
- package/templates/branded-lite/l10n/pt.json +5 -5
- package/templates/branded-lite/l10n/ru.json +5 -5
- package/templates/branded-lite/l10n/sv.json +5 -5
- package/templates/branded-lite/l10n/th.json +5 -5
- package/templates/branded-lite/l10n/tr.json +5 -5
- package/templates/branded-lite/l10n/uk.json +5 -5
- package/templates/branded-lite/l10n/vi.json +5 -5
- package/templates/branded-lite/l10n/zh.json +5 -5
- package/templates/branded-lite/tier5-src/_shared/engine-intl.ts +65 -0
- package/templates/branded-lite/tier5-src/_shared/performance-tracker-section.ts +24 -16
- package/templates/branded-lite/tier5-src/_shared/performance-tracker-weeks.ts +27 -20
- package/templates/branded-lite/tier5-src/_shared/weekly-goal.ts +28 -12
- package/templates/branded-lite/tier5-src/himi-booking-bookings/index.ts +7 -2
- package/templates/branded-lite/tier5-src/himi-branded-lite-home/index.ts +8 -8
- package/templates/brandy/tier5-src/_shared/engine-intl.ts +65 -0
- package/templates/community-club/dev/index.ts +1 -0
- package/templates/community-club/tier5-src/_shared/engine-intl.ts +65 -0
- package/templates/community-club/tier5-src/_shared/weekly-goal.ts +28 -12
- package/templates/community-club/tier5-src/himi-branded-lite-home/index.ts +8 -8
- package/templates/community-club-owner/tier5-src/_shared/engine-intl.ts +65 -0
- package/templates/conference/tier5-src/_shared/engine-intl.ts +65 -0
- package/templates/events-meetups/dev/index.ts +1 -0
- package/templates/events-meetups/tier5-src/_shared/engine-intl.ts +65 -0
- package/templates/events-meetups/tier5-src/_shared/weekly-goal.ts +28 -12
- package/templates/events-meetups/tier5-src/himi-branded-lite-home/index.ts +8 -8
- package/templates/events-meetups-owner/tier5-src/_shared/engine-intl.ts +65 -0
- package/templates/fitness-gym/tier5-src/_shared/engine-intl.ts +65 -0
- package/templates/fitness-gym/tier5-src/_shared/weekly-goal.ts +28 -12
- package/templates/fitness-gym/tier5-src/himi-booking-bookings/index.ts +7 -2
- package/templates/fitness-gym/tier5-src/himi-fitcoach-home/index.ts +3 -2
- package/templates/gym-fitness/dev/index.ts +3 -1
- package/templates/gym-fitness/tier5-src/_shared/engine-intl.ts +65 -0
- package/templates/gym-fitness/tier5-src/_shared/weekly-goal.ts +28 -12
- package/templates/gym-fitness/tier5-src/himi-booking-bookings/index.ts +7 -2
- package/templates/gym-fitness/tier5-src/himi-branded-lite-home/index.ts +8 -8
- package/templates/gym-fitness-owner/tier5-src/_shared/engine-intl.ts +65 -0
- package/templates/medical-services/tier5-src/_shared/engine-intl.ts +65 -0
- package/templates/medical-services/tier5-src/_shared/weekly-goal.ts +28 -12
- package/templates/medical-services/tier5-src/himi-booking-bookings/index.ts +7 -2
- package/templates/nonprofit-cause/dev/index.ts +1 -0
- package/templates/nonprofit-cause/tier5-src/_shared/engine-intl.ts +65 -0
- package/templates/nonprofit-cause/tier5-src/_shared/weekly-goal.ts +28 -12
- package/templates/nonprofit-cause/tier5-src/himi-branded-lite-home/index.ts +8 -8
- package/templates/nonprofit-cause-owner/tier5-src/_shared/engine-intl.ts +65 -0
- package/templates/owner-lite/tier5-src/_shared/engine-intl.ts +65 -0
- package/templates/personal-fitness-trainer/tier5-src/_shared/engine-intl.ts +65 -0
- package/templates/personal-fitness-trainer/tier5-src/_shared/weekly-goal.ts +28 -12
- package/templates/personal-fitness-trainer/tier5-src/himi-booking-bookings/index.ts +7 -2
- package/templates/podcast-creator/dev/index.ts +1 -0
- package/templates/podcast-creator/tier5-src/_shared/engine-intl.ts +65 -0
- package/templates/podcast-creator/tier5-src/_shared/weekly-goal.ts +28 -12
- package/templates/podcast-creator/tier5-src/himi-branded-lite-home/index.ts +8 -8
- package/templates/podcast-creator-owner/tier5-src/_shared/engine-intl.ts +65 -0
- package/templates/portfolio-creative/dev/index.ts +1 -0
- package/templates/portfolio-creative/tier5-src/_shared/engine-intl.ts +65 -0
- package/templates/portfolio-creative/tier5-src/_shared/weekly-goal.ts +28 -12
- package/templates/portfolio-creative/tier5-src/himi-branded-lite-home/index.ts +8 -8
- package/templates/portfolio-creative-owner/tier5-src/_shared/engine-intl.ts +65 -0
- package/templates/professional-services/tier5-src/_shared/engine-intl.ts +65 -0
- package/templates/professional-services/tier5-src/_shared/weekly-goal.ts +28 -12
- package/templates/professional-services/tier5-src/himi-booking-bookings/index.ts +7 -2
- package/templates/restaurant/dev/index.ts +1 -0
- package/templates/restaurant/tier5-src/_shared/engine-intl.ts +65 -0
- package/templates/restaurant/tier5-src/_shared/weekly-goal.ts +28 -12
- package/templates/restaurant/tier5-src/himi-branded-lite-home/index.ts +8 -8
- package/templates/restaurant-owner/tier5-src/_shared/engine-intl.ts +65 -0
- package/templates/retail-store/dev/index.ts +1 -0
- package/templates/retail-store/tier5-src/_shared/engine-intl.ts +65 -0
- package/templates/retail-store/tier5-src/_shared/weekly-goal.ts +28 -12
- package/templates/retail-store/tier5-src/himi-branded-lite-home/index.ts +8 -8
- package/templates/retail-store-owner/tier5-src/_shared/engine-intl.ts +65 -0
- package/templates/salon-spa/tier5-src/_shared/engine-intl.ts +65 -0
- package/templates/salon-spa/tier5-src/_shared/weekly-goal.ts +28 -12
- package/templates/salon-spa/tier5-src/himi-booking-bookings/index.ts +7 -2
- package/templates/wholesale-store/tier5-src/_shared/engine-intl.ts +65 -0
- package/templates/yoga-studio/dev/index.ts +3 -1
- package/templates/yoga-studio/tier5-src/_shared/engine-intl.ts +65 -0
- package/templates/yoga-studio/tier5-src/_shared/weekly-goal.ts +28 -12
- package/templates/yoga-studio/tier5-src/himi-booking-bookings/index.ts +7 -2
- package/templates/yoga-studio/tier5-src/himi-branded-lite-home/index.ts +8 -8
- package/templates/yoga-studio-owner/tier5-src/_shared/engine-intl.ts +65 -0
|
Binary file
|
|
@@ -1351,3 +1351,10 @@ and its HTTP `status`; the CLI `code` is one of:
|
|
|
1351
1351
|
| `refused` | A rule refused it (another 4xx): the package name, another app holding the site's store app, the app linked to another site, a Containers app (its store ids are the Containers editor's), no saved package name; `serverError` says which. |
|
|
1352
1352
|
| `control_unreachable` | The publishing service could not be reached. |
|
|
1353
1353
|
| `request_failed` | Any other failure (5xx); `status` and `serverError` say which. |
|
|
1354
|
+
|
|
1355
|
+
## `gate_screen_not_served`
|
|
1356
|
+
|
|
1357
|
+
Emitted (JSON on stderr, `{ ok: false, code, error, platform }`) by `prepare:customer`, `install:sim`'s member-CAPTCHA
|
|
1358
|
+
preparation and the `himi dist` re-bake when the baked `auth.gateScreenId` names no screen of the seed being packaged, or
|
|
1359
|
+
when no screen ids could be read to check it. Nothing is written to `auth.json`. The ids come from the seed this run built
|
|
1360
|
+
(`--seed-dir`), never a stale `<dest>/seed`. Fix the gate id or the seed. Exit 1 (`bake-auth.ts` itself exits 3).
|
package/guides/himi-test.md
CHANGED
|
@@ -304,6 +304,10 @@ Only **unambiguous** defects, so a green run stays worth trusting:
|
|
|
304
304
|
| `nav-target-absent` | error | A `himi.open` has no authored `screenId` in params/args (for example `{ screen: "detail", input: { id } }`). Use `{ screenId: "detail", id }`. Targetless back/dismiss/alert/snackbar presentations and dynamic targets are allowed. |
|
|
305
305
|
| `nav-target-missing` | **warning** | A `himi.open` whose target is neither a baked screen, nor one of the app's declared `linkableScreens`, nor an instance of one (`course_detail_c1` under the base `course_detail`) — the tap opens nothing. Only judged when the caller supplies the app's exact linkable set; an absent set means no opinion, never a guess. A target still carrying an **unresolved** `$` token is dropped before it becomes an edge and is never judged — but one that RESOLVED to a concrete id is judged, which is the point: `$item.detailScreenId` resolving to `course_detail_c1` against the first row is exactly the case the instance rule exists for. |
|
|
306
306
|
| `poll-action-missing` | error | A `_poll` directive every host will silently ignore — an action the bundle never declares, a malformed `action`, a missing `id`, or a non-positive `intervalMs`. Each ends the same way: a screen that never refreshes, with nothing saying why. Nothing in the descriptor names the polled action, so no static check can see it. (A merely too-small interval is legal — the host clamps it.) |
|
|
307
|
+
| `poll-stop-extra-fields` | **warning** | A `_poll` stop — `{ id, stop: true }` — that also sets `intervalMs`, `action` or `immediate`. Every host ignores the extras, so it works, but it usually means a start that never ran or a stop pasted from one. Checked on screen workers and app services alike. |
|
|
308
|
+
| `app-binding-unresolved` | error | A `$app:<svc>.<path>` a descriptor (or the app config) binds that the **booted app bundle's state** does not hold — a service it does not define, or a first path segment absent after `onLaunch`. Same depth and severity as `binding-unresolved` for `$service:`. See *App services*. |
|
|
309
|
+
| `app-action-unresolved` | error | An `app.<svc>.<action>` id (descriptor, chrome, push route, `observer_action`) naming a service or action the app bundle does not declare. The tap does nothing on device. |
|
|
310
|
+
| `app-nav-without-gesture` | error | A `_nav` returned from an **ambient** invocation of the app bundle — a `_poll` / `_stream` tick, any hook except an unresolved `onPushOpened`, a push receipt, or an `app.dispatch` from a screen worker. The host drops it (`no_user_gesture`), so nothing navigates. A `_nav` from a tap is fine. |
|
|
307
311
|
| `no-request-issued` | **warning** | A worker that uses the Wix transport but never fetches — "the screen loaded with sample data." A warning: a conditional or tap-triggered fetch is legitimate. |
|
|
308
312
|
| `native-decode-failed` | error | Under `--native`, the real Swift/Kotlin decoder rejected the baked descriptor bytes (the oracle decodes strictly, so an unknown enum value or malformed child is reported here even though production decoding degrades it to a fallback or an `unknown` placeholder) — or the release's `tokens.json`, reported with `screen: "tokens.json"`: both natives decode it in one strict pass, so a single fractional `typography.*.size` or a `motions.*.duration` written in seconds drops the whole theme. A token finding fails the run but never counts as a failed screen. |
|
|
309
313
|
| `token-type-invalid` | error | The package's tokens file holds a value a native `Int` field rejects — `typography.<k>.size` or `.weight`, `motions.<k>.duration` (milliseconds: `0.3` → `300`), or a `spacing` / `radius` entry — in the base document or any `idiom.<overlay>`. Both natives decode tokens.json in one strict pass, so one such value drops the WHOLE theme (iOS "Theme unavailable"; Android default palette and fonts) while the web preview looks right. Reported with `screen: "tokens.json"`, never counted as a failed screen; `himi validate` reports the same finding. |
|
|
@@ -377,6 +381,33 @@ a check that merely never fires.
|
|
|
377
381
|
> `poll-action-missing` finding on a *computed* `action` as suspect until you've confirmed
|
|
378
382
|
> the crawl fed the same input the screen gets on device.
|
|
379
383
|
|
|
384
|
+
## App services — the app-level bundle as one more crawl target
|
|
385
|
+
|
|
386
|
+
When `config.ts` declares an app-level worker (`app.logicBundle`, or its alias `navigation.navLogicBundle`),
|
|
387
|
+
`himi test` boots it **once**, in the same hermetic sandbox (fake net / fake services seams), hydrating from an
|
|
388
|
+
empty snapshot, and runs `onLaunch`. It then exercises the app services the way it exercises a screen worker:
|
|
389
|
+
|
|
390
|
+
| Step | What it does | Finding |
|
|
391
|
+
|------|--------------|---------|
|
|
392
|
+
| `$app:` | Resolves every `$app:<svc>.<path>` in the descriptors and the app config against the booted state. | `app-binding-unresolved` |
|
|
393
|
+
| `app.*` | Dispatches every `app.<svc>.<action>` id the descriptors, chrome, push routes and `observer_action` declare — plus every `app.dispatch("<svc>.<action>")` a screen worker calls — from a fresh boot, with the descriptor's own params as fixture args. | `app-action-unresolved`; a throw is `worker-threw`, source-mapped to the `tier5-src` line |
|
|
394
|
+
| Hooks | `onLaunch`, `onIdentityChange({ signedIn: true, userId })`, `onIdentityChange({ signedIn: false })`, `onForeground`, `onBackground`, `onPushOpened({ link, payload, resolved: false })`, each to every service that declares it, in declaration order. | — |
|
|
395
|
+
| Origin | Every dispatch carries an origin from the origin rules: a tap, a snackbar/alert button and an unresolved `onPushOpened` are **gesture**; ticks, the other hooks, push receipts and `app.dispatch` are **ambient**. A `_nav` returned from an ambient one is reported with the invocation and the `tier5-src` line. | `app-nav-without-gesture` |
|
|
396
|
+
| Polls | A `_poll` an app service arms (at boot or from any invocation) is ticked once, as ambient, so a `_nav` in the polled action is seen; a stop with extra fields is reported. | `poll-stop-extra-fields` |
|
|
397
|
+
|
|
398
|
+
App-service findings with no screen of their own (a hook, a tick, a chrome action) carry `screen: "(app services)"`.
|
|
399
|
+
The report's `appServices` block lists the services booted, the bindings checked, the `app.*` dispatches run and
|
|
400
|
+
the hooks with the services each reached. The gap ledger (kind `unverifiable`, key `unverifiable|app-services|<surface>`)
|
|
401
|
+
names what the crawl could **not** reach: `onPushOpened` is dispatched with a synthetic payload and never with
|
|
402
|
+
`resolved: true` (a real notification tap and the host's route resolution); `onIdentityChange` does not rebind the
|
|
403
|
+
worker's `wixApi` to a member session or re-key its persisted snapshot; an `app.*` param bound to a row or to screen
|
|
404
|
+
state is dispatched without it. Prove those on a device.
|
|
405
|
+
|
|
406
|
+
The matching static lint is `tier5-names-app-service` (`himi validate`, the live preview's diagnostics and the release
|
|
407
|
+
build share it): a descriptor `tier5.<svc>.<action>` whose `<svc>` the app bundle defines gets a suggestion to use
|
|
408
|
+
`app.<svc>.<action>` — **only** in an app whose oldest served binary already supports app services (`appServicesAllowed`);
|
|
409
|
+
an older binary has no `app.*` route, so nothing is reported there.
|
|
410
|
+
|
|
380
411
|
## Where the data comes from
|
|
381
412
|
|
|
382
413
|
Real data makes the success path run — that is where data-shape bugs hide. The crawl
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/himalaya-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1947.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": [
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
"artifactId": "himalaya-cli"
|
|
83
83
|
}
|
|
84
84
|
},
|
|
85
|
-
"falconPackageHash": "
|
|
85
|
+
"falconPackageHash": "b476298e6f7807fe2bff304116a435ae3f747b419dc41ec6457d995d"
|
|
86
86
|
}
|
|
@@ -27,6 +27,21 @@ export function hasIntl(): boolean {
|
|
|
27
27
|
return typeof Intl !== "undefined";
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
/** ECMA-402's first day of the week for `locale` (1 = Monday … 7 = Sunday), or undefined where this engine has no
|
|
31
|
+
* `Intl.Locale` week info (QuickJS has no `Intl`; older JSC / V8 / Hermes have no week info). Callers keep a CLDR table for
|
|
32
|
+
* that case, so every engine starts the same week (`weekly-goal.ts` `firstWeekdayOf`). */
|
|
33
|
+
export function intlFirstDayOfWeek(locale: string): number | undefined {
|
|
34
|
+
try {
|
|
35
|
+
// The guard form `worker-globals:check` reads as guarded: the `Intl` use sits inside the `typeof` test's block.
|
|
36
|
+
if (typeof Intl !== "undefined" && typeof Intl.Locale === "function") {
|
|
37
|
+
const loc = new Intl.Locale(locale) as Intl.Locale & { getWeekInfo?: () => { firstDay?: number }; weekInfo?: { firstDay?: number } };
|
|
38
|
+
const firstDay = (typeof loc.getWeekInfo === "function" ? loc.getWeekInfo() : loc.weekInfo)?.firstDay;
|
|
39
|
+
if (typeof firstDay === "number" && Number.isInteger(firstDay) && firstDay >= 1 && firstDay <= 7) return firstDay;
|
|
40
|
+
}
|
|
41
|
+
} catch { /* a malformed tag */ }
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
|
|
30
45
|
/** The device's IANA time zone, or "UTC" where this engine has no ECMA-402 or no zone data. */
|
|
31
46
|
export function deviceTimeZone(): string {
|
|
32
47
|
try {
|
|
@@ -536,3 +551,53 @@ export function formatTimeZoneLabel(date: Date, timeZone: string, locale = "en")
|
|
|
536
551
|
}
|
|
537
552
|
return "";
|
|
538
553
|
}
|
|
554
|
+
|
|
555
|
+
// ── The first day of the week ──────────────────────────────────────────────────────────────────────────────────────────────
|
|
556
|
+
// 0 = Sunday … 6 = Saturday, for the app language: the one rule every weekly count and every week a screen shows uses
|
|
557
|
+
// (`weekly-goal.ts`, the performance tracker, the Agenda's descriptor, the one-app generator). CLDR week data: Sunday for "en" /
|
|
558
|
+
// "en-US", Monday for "en-GB" or "de", Saturday for "ar-EG". ECMA-402 week info where the engine has it (`intlFirstDayOfWeek`),
|
|
559
|
+
// a CLDR table where it has not, so iOS, Android, web and a build host agree. It lives here rather than in its own file because
|
|
560
|
+
// every generated template already ships this module, and the public catalog's manifest lists each template file.
|
|
561
|
+
|
|
562
|
+
/** 0 = Sunday … 6 = Saturday, as `Date.prototype.getDay`. */
|
|
563
|
+
export type Weekday = 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
564
|
+
export const MONDAY: Weekday = 1;
|
|
565
|
+
|
|
566
|
+
// CLDR `weekData.firstDay` (supplemental data), by region: every region not listed starts on Monday.
|
|
567
|
+
const SUNDAY_REGIONS = new Set("AG AS BD BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP PA PE PH PK PR PT PY SA SG SV TH TT TW UM US VE VI WS YE ZA ZW".split(" "));
|
|
568
|
+
const SATURDAY_REGIONS = new Set("AE AF BH DJ DZ EG IQ IR JO KW LY OM QA SD SY".split(" "));
|
|
569
|
+
const FRIDAY_REGIONS = new Set(["MV"]);
|
|
570
|
+
// The region CLDR's likely subtags give a bare language, for the languages whose region does not start on Monday.
|
|
571
|
+
const LIKELY_REGION: Record<string, string> = {
|
|
572
|
+
en: "US", he: "IL", iw: "IL", ar: "EG", pt: "BR", ja: "JP", zh: "CN", ko: "KR", hi: "IN", bn: "BD", th: "TH", id: "ID",
|
|
573
|
+
fa: "IR", ur: "PK", my: "MM", km: "KH", lo: "LA", ne: "NP", am: "ET", mr: "IN", ta: "IN", te: "IN", gu: "IN", kn: "IN",
|
|
574
|
+
ml: "IN", pa: "IN", fil: "PH", tl: "PH", zu: "ZA", dz: "BT", dv: "MV", ps: "AF",
|
|
575
|
+
};
|
|
576
|
+
|
|
577
|
+
/** The region of a language tag ("en-GB" → "GB", "zh-Hant-TW" → "TW"), else its language's likely region, else "". */
|
|
578
|
+
function regionOf(locale: string): string {
|
|
579
|
+
const parts = locale.split(/[-_]/);
|
|
580
|
+
const region = parts.slice(1).find((p) => /^(?:[A-Za-z]{2}|\d{3})$/.test(p));
|
|
581
|
+
if (region) return region.toUpperCase();
|
|
582
|
+
// A script with no region: Traditional Chinese is Taiwan's.
|
|
583
|
+
if (parts[0]?.toLowerCase() === "zh" && parts.some((p) => p.toLowerCase() === "hant")) return "TW";
|
|
584
|
+
return LIKELY_REGION[(parts[0] ?? "").toLowerCase()] ?? "";
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
/** The first day of the week for `locale` (the app language by default). */
|
|
588
|
+
export function firstWeekdayOf(locale: string = appLocale()): Weekday {
|
|
589
|
+
// ECMA-402 numbers the days 1 = Monday … 7 = Sunday. A malformed tag or an engine without week info: the CLDR table below.
|
|
590
|
+
const firstDay = intlFirstDayOfWeek(locale);
|
|
591
|
+
if (firstDay !== undefined) return (firstDay % 7) as Weekday;
|
|
592
|
+
const region = regionOf(locale);
|
|
593
|
+
if (SUNDAY_REGIONS.has(region)) return 0;
|
|
594
|
+
if (SATURDAY_REGIONS.has(region)) return 6;
|
|
595
|
+
if (FRIDAY_REGIONS.has(region)) return 5;
|
|
596
|
+
return MONDAY;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
/** A screen's `firstWeekday` param (0..6, or its text) when it pins one, else the app language's first day. */
|
|
600
|
+
export function resolveFirstWeekday(raw?: unknown, locale: string = appLocale()): Weekday {
|
|
601
|
+
const n = typeof raw === "number" ? raw : typeof raw === "string" && raw.trim() !== "" ? Number(raw) : NaN;
|
|
602
|
+
return Number.isInteger(n) && n >= 0 && n <= 6 ? (n as Weekday) : firstWeekdayOf(locale);
|
|
603
|
+
}
|
|
@@ -2921,6 +2921,7 @@ const SCREENS = runtimeSetting({
|
|
|
2921
2921
|
"verticals": "[\"store\",\"bookings\",\"plans\",\"blog\"]",
|
|
2922
2922
|
"homeModules": "[{\"id\":\"member_progress\",\"label\":\"This week's schedule\",\"dataSource\":\"member.bookings.schedule\",\"emptyWhen\":[\"hideMemberProgress\"]},{\"id\":\"up_next\",\"label\":\"Up next\",\"dataSource\":\"member.bookings\",\"emptyWhen\":[\"hideNextBooking\",\"hidePersonalError\"]},{\"id\":\"saved\",\"label\":\"Saved on this device\",\"dataSource\":\"device.saved_items\",\"emptyWhen\":[\"noSavedContent\"]},{\"id\":\"section_0\",\"label\":\"Discover 1\",\"dataSource\":\"salonLuxe.section0\",\"emptyWhen\":[\"hideHeroImage\"]},{\"id\":\"section_1\",\"label\":\"__HIMI_APP_NAME__\",\"dataSource\":\"salonLuxe.section1\"}]",
|
|
2923
2923
|
"ownerDefaultLayout": "salonLuxe",
|
|
2924
|
+
"firstWeekday": "0",
|
|
2924
2925
|
"copy": "{\"home.bookVisitCta\":\"Book a visit\",\"home.featuredTitle\":\"Salon picks\",\"home.profileBody\":\"Sign in for orders, bookings, memberships and saved posts.\",\"home.stylistsCaption\":\"Meet your stylists\",\"home.treatmentsSubtitle\":\"Book your favorite in a couple of taps.\",\"home.treatmentsTitle\":\"Signature treatments\"}"
|
|
2925
2926
|
}
|
|
2926
2927
|
}
|
|
@@ -27,6 +27,21 @@ export function hasIntl(): boolean {
|
|
|
27
27
|
return typeof Intl !== "undefined";
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
/** ECMA-402's first day of the week for `locale` (1 = Monday … 7 = Sunday), or undefined where this engine has no
|
|
31
|
+
* `Intl.Locale` week info (QuickJS has no `Intl`; older JSC / V8 / Hermes have no week info). Callers keep a CLDR table for
|
|
32
|
+
* that case, so every engine starts the same week (`weekly-goal.ts` `firstWeekdayOf`). */
|
|
33
|
+
export function intlFirstDayOfWeek(locale: string): number | undefined {
|
|
34
|
+
try {
|
|
35
|
+
// The guard form `worker-globals:check` reads as guarded: the `Intl` use sits inside the `typeof` test's block.
|
|
36
|
+
if (typeof Intl !== "undefined" && typeof Intl.Locale === "function") {
|
|
37
|
+
const loc = new Intl.Locale(locale) as Intl.Locale & { getWeekInfo?: () => { firstDay?: number }; weekInfo?: { firstDay?: number } };
|
|
38
|
+
const firstDay = (typeof loc.getWeekInfo === "function" ? loc.getWeekInfo() : loc.weekInfo)?.firstDay;
|
|
39
|
+
if (typeof firstDay === "number" && Number.isInteger(firstDay) && firstDay >= 1 && firstDay <= 7) return firstDay;
|
|
40
|
+
}
|
|
41
|
+
} catch { /* a malformed tag */ }
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
|
|
30
45
|
/** The device's IANA time zone, or "UTC" where this engine has no ECMA-402 or no zone data. */
|
|
31
46
|
export function deviceTimeZone(): string {
|
|
32
47
|
try {
|
|
@@ -536,3 +551,53 @@ export function formatTimeZoneLabel(date: Date, timeZone: string, locale = "en")
|
|
|
536
551
|
}
|
|
537
552
|
return "";
|
|
538
553
|
}
|
|
554
|
+
|
|
555
|
+
// ── The first day of the week ──────────────────────────────────────────────────────────────────────────────────────────────
|
|
556
|
+
// 0 = Sunday … 6 = Saturday, for the app language: the one rule every weekly count and every week a screen shows uses
|
|
557
|
+
// (`weekly-goal.ts`, the performance tracker, the Agenda's descriptor, the one-app generator). CLDR week data: Sunday for "en" /
|
|
558
|
+
// "en-US", Monday for "en-GB" or "de", Saturday for "ar-EG". ECMA-402 week info where the engine has it (`intlFirstDayOfWeek`),
|
|
559
|
+
// a CLDR table where it has not, so iOS, Android, web and a build host agree. It lives here rather than in its own file because
|
|
560
|
+
// every generated template already ships this module, and the public catalog's manifest lists each template file.
|
|
561
|
+
|
|
562
|
+
/** 0 = Sunday … 6 = Saturday, as `Date.prototype.getDay`. */
|
|
563
|
+
export type Weekday = 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
564
|
+
export const MONDAY: Weekday = 1;
|
|
565
|
+
|
|
566
|
+
// CLDR `weekData.firstDay` (supplemental data), by region: every region not listed starts on Monday.
|
|
567
|
+
const SUNDAY_REGIONS = new Set("AG AS BD BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP PA PE PH PK PR PT PY SA SG SV TH TT TW UM US VE VI WS YE ZA ZW".split(" "));
|
|
568
|
+
const SATURDAY_REGIONS = new Set("AE AF BH DJ DZ EG IQ IR JO KW LY OM QA SD SY".split(" "));
|
|
569
|
+
const FRIDAY_REGIONS = new Set(["MV"]);
|
|
570
|
+
// The region CLDR's likely subtags give a bare language, for the languages whose region does not start on Monday.
|
|
571
|
+
const LIKELY_REGION: Record<string, string> = {
|
|
572
|
+
en: "US", he: "IL", iw: "IL", ar: "EG", pt: "BR", ja: "JP", zh: "CN", ko: "KR", hi: "IN", bn: "BD", th: "TH", id: "ID",
|
|
573
|
+
fa: "IR", ur: "PK", my: "MM", km: "KH", lo: "LA", ne: "NP", am: "ET", mr: "IN", ta: "IN", te: "IN", gu: "IN", kn: "IN",
|
|
574
|
+
ml: "IN", pa: "IN", fil: "PH", tl: "PH", zu: "ZA", dz: "BT", dv: "MV", ps: "AF",
|
|
575
|
+
};
|
|
576
|
+
|
|
577
|
+
/** The region of a language tag ("en-GB" → "GB", "zh-Hant-TW" → "TW"), else its language's likely region, else "". */
|
|
578
|
+
function regionOf(locale: string): string {
|
|
579
|
+
const parts = locale.split(/[-_]/);
|
|
580
|
+
const region = parts.slice(1).find((p) => /^(?:[A-Za-z]{2}|\d{3})$/.test(p));
|
|
581
|
+
if (region) return region.toUpperCase();
|
|
582
|
+
// A script with no region: Traditional Chinese is Taiwan's.
|
|
583
|
+
if (parts[0]?.toLowerCase() === "zh" && parts.some((p) => p.toLowerCase() === "hant")) return "TW";
|
|
584
|
+
return LIKELY_REGION[(parts[0] ?? "").toLowerCase()] ?? "";
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
/** The first day of the week for `locale` (the app language by default). */
|
|
588
|
+
export function firstWeekdayOf(locale: string = appLocale()): Weekday {
|
|
589
|
+
// ECMA-402 numbers the days 1 = Monday … 7 = Sunday. A malformed tag or an engine without week info: the CLDR table below.
|
|
590
|
+
const firstDay = intlFirstDayOfWeek(locale);
|
|
591
|
+
if (firstDay !== undefined) return (firstDay % 7) as Weekday;
|
|
592
|
+
const region = regionOf(locale);
|
|
593
|
+
if (SUNDAY_REGIONS.has(region)) return 0;
|
|
594
|
+
if (SATURDAY_REGIONS.has(region)) return 6;
|
|
595
|
+
if (FRIDAY_REGIONS.has(region)) return 5;
|
|
596
|
+
return MONDAY;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
/** A screen's `firstWeekday` param (0..6, or its text) when it pins one, else the app language's first day. */
|
|
600
|
+
export function resolveFirstWeekday(raw?: unknown, locale: string = appLocale()): Weekday {
|
|
601
|
+
const n = typeof raw === "number" ? raw : typeof raw === "string" && raw.trim() !== "" ? Number(raw) : NaN;
|
|
602
|
+
return Number.isInteger(n) && n >= 0 && n <= 6 ? (n as Weekday) : firstWeekdayOf(locale);
|
|
603
|
+
}
|
|
@@ -3,19 +3,28 @@
|
|
|
3
3
|
// card (himi-booking-bookings), so the two can never count differently.
|
|
4
4
|
//
|
|
5
5
|
// WHAT COUNTS as a session toward the goal: a CONFIRMED booking whose start falls in the CURRENT
|
|
6
|
-
// calendar week (
|
|
6
|
+
// calendar week (its first day 00:00 local → now) and is already in the past. An allow-list, not a
|
|
7
7
|
// deny-list: CREATED (checkout never completed), PENDING / PENDING_APPROVAL / PENDING_CHECKOUT,
|
|
8
8
|
// WAITING_LIST, CANCELED and DECLINED — and any status Wix adds later — do not count. That is
|
|
9
9
|
// "booked and it happened", not verified
|
|
10
10
|
// attendance: the member-scoped queryBookings row carries no attendance/check-in field (the Wix
|
|
11
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.
|
|
12
|
+
// count — they have not happened yet. So every count here is of HELD sessions, never of attendance:
|
|
13
|
+
// a label that shows one must not say "attended".
|
|
14
|
+
//
|
|
15
|
+
// THE WEEK starts on the first day of the app language's region (CLDR week data: Sunday for "en" /
|
|
16
|
+
// "en-US", Monday for "en-GB" or "de", Saturday for "ar-EG"), as the migrated source starts it. A
|
|
17
|
+
// screen may pin another day with a `firstWeekday` onAppear param (0 = Sunday … 6 = Saturday).
|
|
18
|
+
// `firstWeekdayOf` reads ECMA-402 week info where the engine has it and a CLDR table where it has
|
|
19
|
+
// not, so iOS, Android and web agree on the same week.
|
|
13
20
|
//
|
|
14
21
|
// DETERMINISM: nothing here runs at worker boot; every clock read is an argument. PURE (no network,
|
|
15
22
|
// no bridge) so the rules are unit-tested directly; the read lives with its caller.
|
|
16
23
|
|
|
17
24
|
import type { MemberBookingRow } from "./member-bookings.js";
|
|
18
25
|
import { copyParam, copyTemplate } from "./himi-copy.js";
|
|
26
|
+
import type { Weekday } from "./engine-intl.js";
|
|
27
|
+
export { MONDAY, firstWeekdayOf, resolveFirstWeekday, type Weekday } from "./engine-intl.js";
|
|
19
28
|
|
|
20
29
|
export const MAX_WEEKLY_SESSION_GOAL = 21;
|
|
21
30
|
|
|
@@ -32,27 +41,33 @@ export function parseWeeklyGoal(raw: unknown): number {
|
|
|
32
41
|
return Number.isInteger(n) && n >= 1 ? Math.min(n, MAX_WEEKLY_SESSION_GOAL) : 0;
|
|
33
42
|
}
|
|
34
43
|
|
|
35
|
-
/**
|
|
36
|
-
export function weekStartMs(now: number): number {
|
|
44
|
+
/** 00:00 local of the first day (`firstWeekday`) of `now`'s week, epoch ms. */
|
|
45
|
+
export function weekStartMs(now: number, firstWeekday: Weekday): number {
|
|
37
46
|
const d = new Date(now);
|
|
38
47
|
d.setHours(0, 0, 0, 0);
|
|
39
|
-
d.setDate(d.getDate() - ((d.getDay() +
|
|
48
|
+
d.setDate(d.getDate() - ((d.getDay() - firstWeekday + 7) % 7));
|
|
40
49
|
return d.getTime();
|
|
41
50
|
}
|
|
42
51
|
|
|
43
|
-
/** Is `row` a session that was booked and already held at `now`? The one rule every count here uses.
|
|
52
|
+
/** Is `row` a session that was booked and already held at `now`? The one rule every count here uses.
|
|
53
|
+
* Held, not attended: the member's booking row carries no check-in. */
|
|
44
54
|
export function isHeldSession(row: MemberBookingRow, now: number): boolean {
|
|
45
55
|
const start = Date.parse(row.start);
|
|
46
56
|
return Number.isFinite(start) && start < now && COUNTS_AS_SESSION.test((row.status || "").trim().toUpperCase());
|
|
47
57
|
}
|
|
48
58
|
|
|
59
|
+
/** The key one booking counts under: a booking read twice (two pages, a retry) counts once. */
|
|
60
|
+
export function sessionKey(row: MemberBookingRow): string {
|
|
61
|
+
return row.id || `${row.start}|${row.title}`;
|
|
62
|
+
}
|
|
63
|
+
|
|
49
64
|
/** Sessions toward the goal among `rows` — see the file header for what counts. */
|
|
50
|
-
export function weeklySessionsDone(rows: readonly MemberBookingRow[], now: number): number {
|
|
51
|
-
const from = weekStartMs(now);
|
|
65
|
+
export function weeklySessionsDone(rows: readonly MemberBookingRow[], now: number, firstWeekday: Weekday): number {
|
|
66
|
+
const from = weekStartMs(now, firstWeekday);
|
|
52
67
|
const seen = new Set<string>();
|
|
53
68
|
for (const row of rows) {
|
|
54
69
|
if (Date.parse(row.start) < from || !isHeldSession(row, now)) continue;
|
|
55
|
-
seen.add(row
|
|
70
|
+
seen.add(sessionKey(row));
|
|
56
71
|
}
|
|
57
72
|
return seen.size;
|
|
58
73
|
}
|
|
@@ -64,14 +79,15 @@ export interface BookingsPage {
|
|
|
64
79
|
|
|
65
80
|
/** Sessions toward the goal from PAST bookings read newest-first: `first` is the first page, and
|
|
66
81
|
* `next(cursor)` reads more only while the oldest row so far is still inside this week (a page of
|
|
67
|
-
* 50 almost always reaches back before
|
|
82
|
+
* 50 almost always reaches back before the week's first day). Bounded to MAX_WEEKLY_PAGES reads; a failing
|
|
68
83
|
* read rejects, so the caller hides the count rather than under-counting. */
|
|
69
84
|
export async function weeklySessionsFromPages(
|
|
70
85
|
first: BookingsPage,
|
|
71
86
|
next: (cursor: string) => Promise<BookingsPage>,
|
|
72
87
|
now: number,
|
|
88
|
+
firstWeekday: Weekday,
|
|
73
89
|
): Promise<number> {
|
|
74
|
-
const from = weekStartMs(now);
|
|
90
|
+
const from = weekStartMs(now, firstWeekday);
|
|
75
91
|
const rows = [...first.items];
|
|
76
92
|
let page = first;
|
|
77
93
|
for (let read = 1; read < MAX_WEEKLY_PAGES && page.nextCursor; read++) {
|
|
@@ -80,7 +96,7 @@ export async function weeklySessionsFromPages(
|
|
|
80
96
|
page = await next(page.nextCursor);
|
|
81
97
|
rows.push(...page.items);
|
|
82
98
|
}
|
|
83
|
-
return weeklySessionsDone(rows, now);
|
|
99
|
+
return weeklySessionsDone(rows, now, firstWeekday);
|
|
84
100
|
}
|
|
85
101
|
|
|
86
102
|
export interface WeeklyGoalProgress {
|
|
@@ -10,7 +10,7 @@ import { memberAccess, assertMemberAccess, memberAccessChanged, memberAccessDeni
|
|
|
10
10
|
import { fetchMemberBookings, CANCELLED_STATUSES, UNCONFIRMED_STATUSES, type MemberBookingRow } from "../_shared/member-bookings.js";
|
|
11
11
|
import { emitHostEvent } from "../_shared/host-events.js";
|
|
12
12
|
import { formatClock, formatClockRange, formatDateMedium, formatMonthDay, formatWeekdayMonthDay, formatWeekdayMonthDayLong } from "../_shared/engine-intl.js";
|
|
13
|
-
import { parseWeeklyGoal, weeklyGoalProgress, weeklySessionsFromPages } from "../_shared/weekly-goal.js";
|
|
13
|
+
import { parseWeeklyGoal, resolveFirstWeekday, weeklyGoalProgress, weeklySessionsFromPages } from "../_shared/weekly-goal.js";
|
|
14
14
|
|
|
15
15
|
// My Bookings: Upcoming / Past / Canceled tabs over the member's own bookings, a booking sheet with
|
|
16
16
|
// the details and the actions (add to calendar, directions, Book Again, Cancel Booking with a
|
|
@@ -50,6 +50,9 @@ let consumedBookingId = "";
|
|
|
50
50
|
// count comes from a dedicated read of this week's PAST bookings on each first-page fetch, NOT
|
|
51
51
|
// from `rows` (those follow the list's tab — Upcoming by default — and would read 0).
|
|
52
52
|
let weeklyGoal = 0;
|
|
53
|
+
/** The onAppear `firstWeekday` param when the screen pins one; absent, the week starts on the app
|
|
54
|
+
* language's first day (`resolveFirstWeekday`), the rule every weekly count shares. */
|
|
55
|
+
let firstWeekdayParam: unknown;
|
|
53
56
|
/** The count of the page that APPLIED — set in `apply`, never by a fetch, so a superseded fetch
|
|
54
57
|
* (another member, a refresh) cannot overwrite it: it travels in that page's metadata and is
|
|
55
58
|
* dropped with it. */
|
|
@@ -66,7 +69,7 @@ async function fetchWeeklySessionsDone(member: MemberAccess, now: number): Promi
|
|
|
66
69
|
try {
|
|
67
70
|
const nowIso = new Date(now).toISOString();
|
|
68
71
|
const read = (cursor: string) => fetchMemberBookings({ query: "", filter: "value:Past", sort: "za", savedIds: [] }, cursor, nowIso, member);
|
|
69
|
-
return await weeklySessionsFromPages(await read(""), read, now);
|
|
72
|
+
return await weeklySessionsFromPages(await read(""), read, now, resolveFirstWeekday(firstWeekdayParam));
|
|
70
73
|
} catch {
|
|
71
74
|
return null;
|
|
72
75
|
}
|
|
@@ -304,6 +307,8 @@ const svc = defineBackendCollection<S, MemberBookingRow>("himiBookingBookings",
|
|
|
304
307
|
readResultSnackbar(arg);
|
|
305
308
|
const goal = parseWeeklyGoal((arg as Record<string, unknown> | undefined)?.weeklyGoal);
|
|
306
309
|
if (goal) weeklyGoal = goal;
|
|
310
|
+
const pinnedWeekday = (arg as Record<string, unknown> | undefined)?.firstWeekday;
|
|
311
|
+
if (pinnedWeekday !== undefined) firstWeekdayParam = pinnedWeekday;
|
|
307
312
|
// A deep link (the home "next booking", the place summary) names a booking: open its sheet once
|
|
308
313
|
// its row is on the first page. `date` alone does nothing now (there is no day view).
|
|
309
314
|
const linked = runtime()?.input?.bookingId;
|
|
@@ -30,7 +30,7 @@ import { cleanTitle, initials } from "../_shared/himi-text.js";
|
|
|
30
30
|
import { LAYOUT_KEY, type LayoutId, recommendLayout, resolveLayout } from "../_shared/himi-layouts.js";
|
|
31
31
|
import { copyParam, copyTemplate, stashCopy } from "../_shared/himi-copy.js";
|
|
32
32
|
import { groupMemberCount } from "../_shared/group-member-count.js";
|
|
33
|
-
import { parseWeeklyGoal, weeklyGoalProgress, weeklySessionsFromPages } from "../_shared/weekly-goal.js";
|
|
33
|
+
import { parseWeeklyGoal, resolveFirstWeekday, weekStartMs, weeklyGoalProgress, weeklySessionsFromPages, type Weekday } from "../_shared/weekly-goal.js";
|
|
34
34
|
import { isBridgeUnavailable } from "../_shared/owner-load-error.js";
|
|
35
35
|
import { formatDateMedium } from "../_shared/engine-intl.js";
|
|
36
36
|
import { listSavedProducts, type SavedProduct } from "../_shared/himi-store-saved.js";
|
|
@@ -1316,11 +1316,9 @@ async function refreshPublic(state: State, arg?: unknown): Promise<State | undef
|
|
|
1316
1316
|
|
|
1317
1317
|
let personalGeneration = 0;
|
|
1318
1318
|
let shopCategoryActivation = 0;
|
|
1319
|
-
function memberSchedule(rows: MemberBookingRow[], now
|
|
1320
|
-
|
|
1321
|
-
const
|
|
1322
|
-
weekStart.setDate(weekStart.getDate() - day);
|
|
1323
|
-
weekStart.setHours(0, 0, 0, 0);
|
|
1319
|
+
function memberSchedule(rows: MemberBookingRow[], now: Date, firstWeekday: Weekday): { label: string; fraction: number } {
|
|
1320
|
+
// The same week as the weekly-goal Gauge beside it (`weekly-goal.ts`).
|
|
1321
|
+
const weekStart = new Date(weekStartMs(now.getTime(), firstWeekday));
|
|
1324
1322
|
const weekEnd = new Date(weekStart);
|
|
1325
1323
|
weekEnd.setDate(weekEnd.getDate() + 7);
|
|
1326
1324
|
const current = rows.filter((row) => {
|
|
@@ -1344,6 +1342,8 @@ async function refreshPersonal(generation: number, arg?: unknown): Promise<void>
|
|
|
1344
1342
|
const weeklyGoal = parseWeeklyGoal(paramValue(arg, "weeklyGoal"));
|
|
1345
1343
|
if (member.email && parseVerticals(arg).includes("bookings")) {
|
|
1346
1344
|
const now = new Date();
|
|
1345
|
+
// The week starts on the screen's `firstWeekday` (the app's language, set by the descriptor), else the worker's language.
|
|
1346
|
+
const firstWeekday = resolveFirstWeekday(typeof arg === "string" ? undefined : paramValue(arg, "firstWeekday"));
|
|
1347
1347
|
const [upcoming, past] = await Promise.allSettled([
|
|
1348
1348
|
fetchMemberBookings({ query: "", filter: "value:Upcoming", sort: "default", savedIds: [] }, "", now.toISOString(), member),
|
|
1349
1349
|
fetchMemberBookings({ query: "", filter: "value:Past", sort: "za", savedIds: [] }, "", now.toISOString(), member),
|
|
@@ -1357,7 +1357,7 @@ async function refreshPersonal(generation: number, arg?: unknown): Promise<void>
|
|
|
1357
1357
|
if (upcoming.status === "fulfilled" && past.status === "fulfilled") {
|
|
1358
1358
|
// A schedule total needs both halves. Hide it rather than under-counting
|
|
1359
1359
|
// when either query failed.
|
|
1360
|
-
progress = memberSchedule([...upcoming.value.items, ...past.value.items], now);
|
|
1360
|
+
progress = memberSchedule([...upcoming.value.items, ...past.value.items], now, firstWeekday);
|
|
1361
1361
|
}
|
|
1362
1362
|
if (weeklyGoal > 0 && past.status === "fulfilled") {
|
|
1363
1363
|
// The goal counts sessions that already HAPPENED this week (_shared/weekly-goal.ts). A
|
|
@@ -1367,7 +1367,7 @@ async function refreshPersonal(generation: number, arg?: unknown): Promise<void>
|
|
|
1367
1367
|
try {
|
|
1368
1368
|
const readPast = (cursor: string) =>
|
|
1369
1369
|
fetchMemberBookings({ query: "", filter: "value:Past", sort: "za", savedIds: [] }, cursor, now.toISOString(), member);
|
|
1370
|
-
const goal = weeklyGoalProgress(await weeklySessionsFromPages(past.value, readPast, now.getTime()), weeklyGoal);
|
|
1370
|
+
const goal = weeklyGoalProgress(await weeklySessionsFromPages(past.value, readPast, now.getTime(), firstWeekday), weeklyGoal);
|
|
1371
1371
|
weekly = { count: goal.done, fraction: goal.fraction, label: goal.label };
|
|
1372
1372
|
} catch {
|
|
1373
1373
|
weekly = null;
|
|
@@ -27,6 +27,21 @@ export function hasIntl(): boolean {
|
|
|
27
27
|
return typeof Intl !== "undefined";
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
/** ECMA-402's first day of the week for `locale` (1 = Monday … 7 = Sunday), or undefined where this engine has no
|
|
31
|
+
* `Intl.Locale` week info (QuickJS has no `Intl`; older JSC / V8 / Hermes have no week info). Callers keep a CLDR table for
|
|
32
|
+
* that case, so every engine starts the same week (`weekly-goal.ts` `firstWeekdayOf`). */
|
|
33
|
+
export function intlFirstDayOfWeek(locale: string): number | undefined {
|
|
34
|
+
try {
|
|
35
|
+
// The guard form `worker-globals:check` reads as guarded: the `Intl` use sits inside the `typeof` test's block.
|
|
36
|
+
if (typeof Intl !== "undefined" && typeof Intl.Locale === "function") {
|
|
37
|
+
const loc = new Intl.Locale(locale) as Intl.Locale & { getWeekInfo?: () => { firstDay?: number }; weekInfo?: { firstDay?: number } };
|
|
38
|
+
const firstDay = (typeof loc.getWeekInfo === "function" ? loc.getWeekInfo() : loc.weekInfo)?.firstDay;
|
|
39
|
+
if (typeof firstDay === "number" && Number.isInteger(firstDay) && firstDay >= 1 && firstDay <= 7) return firstDay;
|
|
40
|
+
}
|
|
41
|
+
} catch { /* a malformed tag */ }
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
|
|
30
45
|
/** The device's IANA time zone, or "UTC" where this engine has no ECMA-402 or no zone data. */
|
|
31
46
|
export function deviceTimeZone(): string {
|
|
32
47
|
try {
|
|
@@ -536,3 +551,53 @@ export function formatTimeZoneLabel(date: Date, timeZone: string, locale = "en")
|
|
|
536
551
|
}
|
|
537
552
|
return "";
|
|
538
553
|
}
|
|
554
|
+
|
|
555
|
+
// ── The first day of the week ──────────────────────────────────────────────────────────────────────────────────────────────
|
|
556
|
+
// 0 = Sunday … 6 = Saturday, for the app language: the one rule every weekly count and every week a screen shows uses
|
|
557
|
+
// (`weekly-goal.ts`, the performance tracker, the Agenda's descriptor, the one-app generator). CLDR week data: Sunday for "en" /
|
|
558
|
+
// "en-US", Monday for "en-GB" or "de", Saturday for "ar-EG". ECMA-402 week info where the engine has it (`intlFirstDayOfWeek`),
|
|
559
|
+
// a CLDR table where it has not, so iOS, Android, web and a build host agree. It lives here rather than in its own file because
|
|
560
|
+
// every generated template already ships this module, and the public catalog's manifest lists each template file.
|
|
561
|
+
|
|
562
|
+
/** 0 = Sunday … 6 = Saturday, as `Date.prototype.getDay`. */
|
|
563
|
+
export type Weekday = 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
564
|
+
export const MONDAY: Weekday = 1;
|
|
565
|
+
|
|
566
|
+
// CLDR `weekData.firstDay` (supplemental data), by region: every region not listed starts on Monday.
|
|
567
|
+
const SUNDAY_REGIONS = new Set("AG AS BD BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP PA PE PH PK PR PT PY SA SG SV TH TT TW UM US VE VI WS YE ZA ZW".split(" "));
|
|
568
|
+
const SATURDAY_REGIONS = new Set("AE AF BH DJ DZ EG IQ IR JO KW LY OM QA SD SY".split(" "));
|
|
569
|
+
const FRIDAY_REGIONS = new Set(["MV"]);
|
|
570
|
+
// The region CLDR's likely subtags give a bare language, for the languages whose region does not start on Monday.
|
|
571
|
+
const LIKELY_REGION: Record<string, string> = {
|
|
572
|
+
en: "US", he: "IL", iw: "IL", ar: "EG", pt: "BR", ja: "JP", zh: "CN", ko: "KR", hi: "IN", bn: "BD", th: "TH", id: "ID",
|
|
573
|
+
fa: "IR", ur: "PK", my: "MM", km: "KH", lo: "LA", ne: "NP", am: "ET", mr: "IN", ta: "IN", te: "IN", gu: "IN", kn: "IN",
|
|
574
|
+
ml: "IN", pa: "IN", fil: "PH", tl: "PH", zu: "ZA", dz: "BT", dv: "MV", ps: "AF",
|
|
575
|
+
};
|
|
576
|
+
|
|
577
|
+
/** The region of a language tag ("en-GB" → "GB", "zh-Hant-TW" → "TW"), else its language's likely region, else "". */
|
|
578
|
+
function regionOf(locale: string): string {
|
|
579
|
+
const parts = locale.split(/[-_]/);
|
|
580
|
+
const region = parts.slice(1).find((p) => /^(?:[A-Za-z]{2}|\d{3})$/.test(p));
|
|
581
|
+
if (region) return region.toUpperCase();
|
|
582
|
+
// A script with no region: Traditional Chinese is Taiwan's.
|
|
583
|
+
if (parts[0]?.toLowerCase() === "zh" && parts.some((p) => p.toLowerCase() === "hant")) return "TW";
|
|
584
|
+
return LIKELY_REGION[(parts[0] ?? "").toLowerCase()] ?? "";
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
/** The first day of the week for `locale` (the app language by default). */
|
|
588
|
+
export function firstWeekdayOf(locale: string = appLocale()): Weekday {
|
|
589
|
+
// ECMA-402 numbers the days 1 = Monday … 7 = Sunday. A malformed tag or an engine without week info: the CLDR table below.
|
|
590
|
+
const firstDay = intlFirstDayOfWeek(locale);
|
|
591
|
+
if (firstDay !== undefined) return (firstDay % 7) as Weekday;
|
|
592
|
+
const region = regionOf(locale);
|
|
593
|
+
if (SUNDAY_REGIONS.has(region)) return 0;
|
|
594
|
+
if (SATURDAY_REGIONS.has(region)) return 6;
|
|
595
|
+
if (FRIDAY_REGIONS.has(region)) return 5;
|
|
596
|
+
return MONDAY;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
/** A screen's `firstWeekday` param (0..6, or its text) when it pins one, else the app language's first day. */
|
|
600
|
+
export function resolveFirstWeekday(raw?: unknown, locale: string = appLocale()): Weekday {
|
|
601
|
+
const n = typeof raw === "number" ? raw : typeof raw === "string" && raw.trim() !== "" ? Number(raw) : NaN;
|
|
602
|
+
return Number.isInteger(n) && n >= 0 && n <= 6 ? (n as Weekday) : firstWeekdayOf(locale);
|
|
603
|
+
}
|
|
@@ -4016,7 +4016,8 @@ const SCREENS = runtimeSetting({
|
|
|
4016
4016
|
"homeModules": "[{\"id\":\"member_progress\",\"label\":\"This week's schedule\",\"dataSource\":\"member.bookings.schedule\",\"emptyWhen\":[\"hideMemberProgress\"]},{\"id\":\"up_next\",\"label\":\"Up next\",\"dataSource\":\"member.bookings\",\"emptyWhen\":[\"hideNextBooking\",\"hidePersonalError\"]},{\"id\":\"saved\",\"label\":\"Saved on this device\",\"dataSource\":\"device.saved_items\",\"emptyWhen\":[\"noSavedContent\"]},{\"id\":\"section_0\",\"label\":\"Discover 1\",\"dataSource\":\"classic.section0\",\"emptyWhen\":[\"hideFeaturedSkeleton\"]},{\"id\":\"section_1\",\"label\":\"Featured products\",\"dataSource\":\"classic.section1\"}]",
|
|
4017
4017
|
"ownerDefaultLayout": "",
|
|
4018
4018
|
"videoCaption": "overlay",
|
|
4019
|
-
"weeklyGoal": "2"
|
|
4019
|
+
"weeklyGoal": "2",
|
|
4020
|
+
"firstWeekday": "0"
|
|
4020
4021
|
}
|
|
4021
4022
|
}
|
|
4022
4023
|
}
|
|
@@ -31302,7 +31303,8 @@ const SCREENS = runtimeSetting({
|
|
|
31302
31303
|
"onAppear": {
|
|
31303
31304
|
"actionId": "tier5.himiBookingBookings.load",
|
|
31304
31305
|
"params": {
|
|
31305
|
-
"weeklyGoal": "2"
|
|
31306
|
+
"weeklyGoal": "2",
|
|
31307
|
+
"firstWeekday": "0"
|
|
31306
31308
|
}
|
|
31307
31309
|
}
|
|
31308
31310
|
}
|
|
@@ -9642,6 +9642,11 @@
|
|
|
9642
9642
|
"translation": "{n, plural, zero {# منشور} one {منشور واحد} two {منشوران} few {# منشورات} many {# منشورًا} other {# منشور}}",
|
|
9643
9643
|
"origin": "machine"
|
|
9644
9644
|
},
|
|
9645
|
+
"h_970730811681": {
|
|
9646
|
+
"source": "All-time sessions",
|
|
9647
|
+
"translation": "إجمالي الجلسات",
|
|
9648
|
+
"origin": "machine"
|
|
9649
|
+
},
|
|
9645
9650
|
"h_f69bc32d3fe3": {
|
|
9646
9651
|
"source": "Back to Galleries",
|
|
9647
9652
|
"translation": "العودة إلى المعارض",
|
|
@@ -9947,11 +9952,6 @@
|
|
|
9947
9952
|
"translation": "{n, plural, one {أسبوع حققت فيه هدفي} other {أسابيع حققت فيها هدفي}}",
|
|
9948
9953
|
"origin": "machine"
|
|
9949
9954
|
},
|
|
9950
|
-
"h_0d27866cd8c7": {
|
|
9951
|
-
"source": "{n, plural, one {Session attended in total} other {Sessions attended in total}}",
|
|
9952
|
-
"translation": "{n, plural, one {جلسة حضرتها إجمالًا} other {جلسات حضرتها إجمالًا}}",
|
|
9953
|
-
"origin": "machine"
|
|
9954
|
-
},
|
|
9955
9955
|
"h_617d49f47351": {
|
|
9956
9956
|
"source": "We sent a reset link to {email}. Check your inbox.",
|
|
9957
9957
|
"translation": "أرسلنا رابط إعادة التعيين إلى {email}. تحقّق من بريدك الوارد.",
|
|
@@ -9642,6 +9642,11 @@
|
|
|
9642
9642
|
"translation": "{n, plural, one {# příspěvek} few {# příspěvky} many {# příspěvku} other {# příspěvků}}",
|
|
9643
9643
|
"origin": "machine"
|
|
9644
9644
|
},
|
|
9645
|
+
"h_970730811681": {
|
|
9646
|
+
"source": "All-time sessions",
|
|
9647
|
+
"translation": "Lekce celkem",
|
|
9648
|
+
"origin": "machine"
|
|
9649
|
+
},
|
|
9645
9650
|
"h_f69bc32d3fe3": {
|
|
9646
9651
|
"source": "Back to Galleries",
|
|
9647
9652
|
"translation": "Zpět na galerie",
|
|
@@ -9947,11 +9952,6 @@
|
|
|
9947
9952
|
"translation": "{n, plural, one {Týden splnění cíle} few {Týdny splnění cíle} other {Týdnů splnění cíle}}",
|
|
9948
9953
|
"origin": "machine"
|
|
9949
9954
|
},
|
|
9950
|
-
"h_0d27866cd8c7": {
|
|
9951
|
-
"source": "{n, plural, one {Session attended in total} other {Sessions attended in total}}",
|
|
9952
|
-
"translation": "{n, plural, one {Navštívená lekce celkem} few {Navštívené lekce celkem} other {Navštívených lekcí celkem}}",
|
|
9953
|
-
"origin": "machine"
|
|
9954
|
-
},
|
|
9955
9955
|
"h_617d49f47351": {
|
|
9956
9956
|
"source": "We sent a reset link to {email}. Check your inbox.",
|
|
9957
9957
|
"translation": "Odkaz pro obnovení jsme poslali na {email}. Zkontrolujte svou doručenou poštu.",
|
|
@@ -9642,6 +9642,11 @@
|
|
|
9642
9642
|
"translation": "{n, plural, one {# opslag} other {# opslag}}",
|
|
9643
9643
|
"origin": "machine"
|
|
9644
9644
|
},
|
|
9645
|
+
"h_970730811681": {
|
|
9646
|
+
"source": "All-time sessions",
|
|
9647
|
+
"translation": "Sessioner i alt",
|
|
9648
|
+
"origin": "machine"
|
|
9649
|
+
},
|
|
9645
9650
|
"h_f69bc32d3fe3": {
|
|
9646
9651
|
"source": "Back to Galleries",
|
|
9647
9652
|
"translation": "Tilbage til gallerier",
|
|
@@ -9947,11 +9952,6 @@
|
|
|
9947
9952
|
"translation": "{n, plural, one {Uge hvor jeg nåede mit mål} other {Uger hvor jeg nåede mit mål}}",
|
|
9948
9953
|
"origin": "machine"
|
|
9949
9954
|
},
|
|
9950
|
-
"h_0d27866cd8c7": {
|
|
9951
|
-
"source": "{n, plural, one {Session attended in total} other {Sessions attended in total}}",
|
|
9952
|
-
"translation": "{n, plural, one {Session deltaget i alt} other {Sessioner deltaget i alt}}",
|
|
9953
|
-
"origin": "machine"
|
|
9954
|
-
},
|
|
9955
9955
|
"h_617d49f47351": {
|
|
9956
9956
|
"source": "We sent a reset link to {email}. Check your inbox.",
|
|
9957
9957
|
"translation": "Vi har sendt et nulstillingslink til {email}. Tjek din indbakke.",
|