@wix/himalaya-cli 0.1287.0 → 0.1289.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 (83) hide show
  1. package/dist/cli.mjs +36 -29
  2. package/dist/preview-assets.generated.bin +0 -0
  3. package/guides/cms-collections.md +2 -2
  4. package/guides/creating-wix-sites.md +10 -5
  5. package/guides/getting-started.md +7 -3
  6. package/guides/headless-business-to-himi-app.md +1 -1
  7. package/guides/headless-loop.md +21 -4
  8. package/guides/himi-mcp.md +4 -1
  9. package/guides/himi-skill.md +7 -3
  10. package/guides/push-cli-onboarding.md +11 -2
  11. package/guides/qa-builds.md +1 -0
  12. package/guides/wix-business-context.md +1 -1
  13. package/guides/wix-site-http-functions.md +2 -2
  14. package/guides/wix-site-to-himi-app.md +4 -3
  15. package/package.json +2 -2
  16. package/templates/beauty-salon/README.md +1 -0
  17. package/templates/beauty-salon/dev/index.ts +83 -478
  18. package/templates/beauty-salon/tier5-src/_shared/himi-layouts.ts +13 -34
  19. package/templates/beauty-salon/tier5-src/himi-branded-lite-appearance/index.ts +58 -77
  20. package/templates/beauty-salon/tier5-src/himi-branded-lite-home/index.ts +1 -17
  21. package/templates/beauty-salon-owner/README.md +1 -0
  22. package/templates/branded-lite/README.md +1 -0
  23. package/templates/branded-lite/dev/index.ts +83 -479
  24. package/templates/branded-lite/tier5-src/_shared/himi-layouts.ts +13 -34
  25. package/templates/branded-lite/tier5-src/himi-branded-lite-appearance/index.ts +58 -77
  26. package/templates/branded-lite/tier5-src/himi-branded-lite-home/index.ts +1 -17
  27. package/templates/community-club/README.md +1 -0
  28. package/templates/community-club/dev/index.ts +83 -479
  29. package/templates/community-club/tier5-src/_shared/himi-layouts.ts +13 -34
  30. package/templates/community-club/tier5-src/himi-branded-lite-appearance/index.ts +58 -77
  31. package/templates/community-club/tier5-src/himi-branded-lite-home/index.ts +1 -17
  32. package/templates/community-club-owner/README.md +1 -0
  33. package/templates/events-meetups/README.md +1 -0
  34. package/templates/events-meetups/dev/index.ts +83 -479
  35. package/templates/events-meetups/tier5-src/_shared/himi-layouts.ts +13 -34
  36. package/templates/events-meetups/tier5-src/himi-branded-lite-appearance/index.ts +58 -77
  37. package/templates/events-meetups/tier5-src/himi-branded-lite-home/index.ts +1 -17
  38. package/templates/events-meetups-owner/README.md +1 -0
  39. package/templates/gym-fitness/README.md +1 -0
  40. package/templates/gym-fitness/dev/index.ts +83 -478
  41. package/templates/gym-fitness/tier5-src/_shared/himi-layouts.ts +13 -34
  42. package/templates/gym-fitness/tier5-src/himi-branded-lite-appearance/index.ts +58 -77
  43. package/templates/gym-fitness/tier5-src/himi-branded-lite-home/index.ts +1 -17
  44. package/templates/gym-fitness-owner/README.md +1 -0
  45. package/templates/himi-chat/README.md +1 -0
  46. package/templates/nonprofit-cause/README.md +1 -0
  47. package/templates/nonprofit-cause/dev/index.ts +83 -479
  48. package/templates/nonprofit-cause/tier5-src/_shared/himi-layouts.ts +13 -34
  49. package/templates/nonprofit-cause/tier5-src/himi-branded-lite-appearance/index.ts +58 -77
  50. package/templates/nonprofit-cause/tier5-src/himi-branded-lite-home/index.ts +1 -17
  51. package/templates/nonprofit-cause-owner/README.md +1 -0
  52. package/templates/owner-lite/README.md +1 -0
  53. package/templates/podcast-creator/README.md +1 -0
  54. package/templates/podcast-creator/dev/index.ts +83 -479
  55. package/templates/podcast-creator/tier5-src/_shared/himi-layouts.ts +13 -34
  56. package/templates/podcast-creator/tier5-src/himi-branded-lite-appearance/index.ts +58 -77
  57. package/templates/podcast-creator/tier5-src/himi-branded-lite-home/index.ts +1 -17
  58. package/templates/podcast-creator-owner/README.md +1 -0
  59. package/templates/portfolio-creative/README.md +1 -0
  60. package/templates/portfolio-creative/dev/index.ts +83 -478
  61. package/templates/portfolio-creative/tier5-src/_shared/himi-layouts.ts +13 -34
  62. package/templates/portfolio-creative/tier5-src/himi-branded-lite-appearance/index.ts +58 -77
  63. package/templates/portfolio-creative/tier5-src/himi-branded-lite-home/index.ts +1 -17
  64. package/templates/portfolio-creative-owner/README.md +1 -0
  65. package/templates/restaurant/README.md +1 -0
  66. package/templates/restaurant/dev/index.ts +83 -478
  67. package/templates/restaurant/tier5-src/_shared/himi-layouts.ts +13 -34
  68. package/templates/restaurant/tier5-src/himi-branded-lite-appearance/index.ts +58 -77
  69. package/templates/restaurant/tier5-src/himi-branded-lite-home/index.ts +1 -17
  70. package/templates/restaurant-owner/README.md +1 -0
  71. package/templates/retail-store/README.md +1 -0
  72. package/templates/retail-store/dev/index.ts +83 -478
  73. package/templates/retail-store/tier5-src/_shared/himi-layouts.ts +13 -34
  74. package/templates/retail-store/tier5-src/himi-branded-lite-appearance/index.ts +58 -77
  75. package/templates/retail-store/tier5-src/himi-branded-lite-home/index.ts +1 -17
  76. package/templates/retail-store-owner/README.md +1 -0
  77. package/templates/surface-showcase/README.md +1 -0
  78. package/templates/yoga-studio/README.md +1 -0
  79. package/templates/yoga-studio/dev/index.ts +83 -478
  80. package/templates/yoga-studio/tier5-src/_shared/himi-layouts.ts +13 -34
  81. package/templates/yoga-studio/tier5-src/himi-branded-lite-appearance/index.ts +58 -77
  82. package/templates/yoga-studio/tier5-src/himi-branded-lite-home/index.ts +1 -17
  83. package/templates/yoga-studio-owner/README.md +1 -0
@@ -104,44 +104,23 @@ export function resolveLayout(input: {
104
104
  }
105
105
 
106
106
  // ---------------------------------------------------------------------------
107
- // Accent axis (Phase 3, scoped OTA). SDUI style modifiers (theme/material/
108
- // density) are static literals a worker can't rebind, but a node's fill *is*
109
- // bindable via `backgroundColorPath`. So accent recolors the bindable accent
110
- // surfaces (avatars / monograms / initials placeholders) live from worker state,
111
- // while the brand token stays the fallback. Not a full token-system swap.
107
+ // App color theme. The Appearance screen lets the member pin the app to light or
108
+ // dark, or follow the device ("system"). The worker hands the choice to the host
109
+ // through the `theme.set` action, and the host applies it to the whole app (native
110
+ // chrome and SDUI tokens alike) — a worker cannot rebind tokens itself.
112
111
  // ---------------------------------------------------------------------------
113
- export type AccentId = "brand" | "amber" | "terracotta" | "sage" | "plum" | "ocean";
112
+ export type ThemeId = "system" | "light" | "dark";
114
113
 
115
- /** Swatch order in the Appearance picker. `brand` = the app's own brand color. */
116
- export const ACCENT_IDS: readonly AccentId[] = ["brand", "amber", "terracotta", "sage", "plum", "ocean"];
117
- export const DEFAULT_ACCENT: AccentId = "brand";
114
+ /** Radio order on the Appearance screen. */
115
+ export const THEME_IDS: readonly ThemeId[] = ["system", "light", "dark"];
116
+ export const DEFAULT_THEME: ThemeId = "system";
118
117
 
119
- /** Storage key both workers agree on for the persisted accent choice. */
120
- export const ACCENT_KEY = "himi.brandedLite.homeAccent";
118
+ /** Worker-side mirror of the choice, so the radios show it even where no host
119
+ * answers `theme.get` (an older binary). */
120
+ export const THEME_KEY = "himi.brandedLite.colorTheme";
121
121
 
122
- /** Curated, opt-in accent palette. `brand.hex` is empty — it resolves to the
123
- * app's brand color at runtime (so the default never overrides white-label). */
124
- export const ACCENT_META: Record<AccentId, { label: string; hex: string }> = {
125
- brand: { label: "Brand", hex: "" },
126
- amber: { label: "Amber", hex: "#C6872E" },
127
- terracotta: { label: "Terracotta", hex: "#C1552F" },
128
- sage: { label: "Sage", hex: "#6E8B5E" },
129
- plum: { label: "Plum", hex: "#8A5476" },
130
- ocean: { label: "Ocean", hex: "#3B6E8C" },
131
- };
132
-
133
- export function isAccentId(x: unknown): x is AccentId {
134
- return typeof x === "string" && (ACCENT_IDS as readonly string[]).includes(x);
135
- }
136
-
137
- /** Resolve an accent id to its curated hex, or "" for `brand` and any unknown value.
138
- * "" is deliberate: a bound `backgroundColorPath` that resolves empty keeps the surface's
139
- * own `accentPrimary` token on every renderer, and that token IS the brand — after a
140
- * `site analyze --apply` and after a hand edit of tokens.json alike. A brand colour copied
141
- * into the descriptor instead (the old `brandAccent` param) went stale on the second path:
142
- * the Home pill kept the template's blue after a rebrand. */
143
- export function accentColor(id: string): string {
144
- return isAccentId(id) ? ACCENT_META[id].hex : "";
122
+ export function isThemeId(x: unknown): x is ThemeId {
123
+ return typeof x === "string" && (THEME_IDS as readonly string[]).includes(x);
145
124
  }
146
125
 
147
126
  /** Content-derived default: booking intent > deep catalog > editorial (blog-forward) > balanced.
@@ -1,51 +1,44 @@
1
1
  import { defineService } from "@himalaya/state";
2
- import {
3
- ACCENT_IDS,
4
- ACCENT_KEY,
5
- ACCENT_META,
6
- DEFAULT_ACCENT,
7
- isAccentId,
8
- } from "../_shared/himi-layouts.js";
2
+ import { dispatch } from "@himalaya/dispatch";
3
+ import { DEFAULT_THEME, THEME_IDS, THEME_KEY, isThemeId, type ThemeId } from "../_shared/himi-layouts.js";
9
4
 
10
- // The in-app Appearance configurator worker (accent-only). Owns the *pending*
11
- // accent selection and the per-swatch hex fields the picker binds; Apply persists
12
- // the accent under a shared key the home worker re-reads on launch. Pure storage
13
- // seam — no network, no declared capability.
5
+ // The in-app Appearance worker: the app color theme (System default / Light / Dark).
6
+ // A tap applies the choice at once. The worker cannot repaint the app itself — tokens
7
+ // and native chrome belong to the host — so it hands the choice to the host through the
8
+ // `theme.set` host action (iOS, Android and the web host register it), the same seam
9
+ // App language uses for `locale.set`. No declared capability: a host action is not one.
14
10
  //
15
- // Home-layout switching (RFC 0045: the layout picker + live preview + per-preset
16
- // FragmentSlot) was dropped — the home layout is now fixed per app (the
17
- // provisioned `appearance.homeLayout`). Only accent tinting remains configurable.
11
+ // The choice is also mirrored in worker storage, so the radios show it on a host that
12
+ // does not answer `theme.get` (an older binary). On such a host the selection is kept,
13
+ // but the app does not change colour until the binary is updated.
14
+ //
15
+ // It replaced an accent-colour picker (six swatches that tinted a few brand surfaces),
16
+ // which did not suit every brand. The home worker no longer reads an accent.
18
17
 
19
18
  interface State {
20
- /** The pending accent id (persisted on Apply, re-read by the home worker). */
21
- pendingAccent: string;
22
- // Per-accent swatch colors. backgroundColorPath resolves `$service:` paths but NOT
23
- // per-row `$item.` fields, so each static swatch binds its own flat field.
24
- // `accentHex_brand` is "" on purpose: the swatch keeps its own accentPrimary token,
25
- // which is the brand (see accentColor in _shared/himi-layouts.ts).
26
- accentHex_brand: string;
27
- accentHex_amber: string;
28
- accentHex_terracotta: string;
29
- accentHex_sage: string;
30
- accentHex_plum: string;
31
- accentHex_ocean: string;
32
- // Per-accent selection flags for the radio group (`selected_<id>`) and the
33
- // check mark on the swatch (`notSelected_<id>`, hiddenWhen hides on TRUE). Flat
34
- // fields for the same reason as the hex ones: the swatches are static nodes.
35
- [flag: `selected_${string}` | `notSelected_${string}`]: boolean | string;
19
+ /** The applied theme id. */
20
+ theme: string;
21
+ // Per-option flags for the radio group. Flat fields: the three rows are static nodes,
22
+ // and a `$service:` path cannot index a map by `$item.`.
23
+ [flag: `selected_${string}`]: boolean | string;
36
24
  }
37
25
 
38
26
  interface StorageLike {
39
27
  getItem(k: string): string | null;
40
28
  setItem(k: string, v: string): void;
41
- removeItem?(k: string): void;
42
29
  }
43
30
  function storage(): StorageLike | undefined {
44
31
  const host = globalThis as { himalaya?: { storage?: StorageLike }; localStorage?: StorageLike };
45
32
  return host.himalaya?.storage ?? host.localStorage;
46
33
  }
47
- function stored(key: string): string | null {
48
- try { return storage()?.getItem(key) ?? null; } catch { return null; }
34
+ function storedTheme(): ThemeId {
35
+ try {
36
+ const s = storage()?.getItem(THEME_KEY) ?? null;
37
+ return isThemeId(s) ? s : DEFAULT_THEME;
38
+ } catch { return DEFAULT_THEME; }
39
+ }
40
+ function remember(theme: ThemeId): void {
41
+ try { storage()?.setItem(THEME_KEY, theme); } catch { /* best-effort: the host holds the real choice */ }
49
42
  }
50
43
  function paramValue(arg: unknown, key: string): string {
51
44
  if (typeof arg === "string") return arg;
@@ -53,59 +46,47 @@ function paramValue(arg: unknown, key: string): string {
53
46
  return typeof result === "string" ? result : "";
54
47
  }
55
48
 
56
- function build(pendingAccent: string): State {
49
+ function build(theme: ThemeId): State {
57
50
  const flags: Record<string, boolean> = {};
58
- for (const id of ACCENT_IDS) {
59
- flags[`selected_${id}`] = id === pendingAccent;
60
- flags[`notSelected_${id}`] = id !== pendingAccent;
61
- }
62
- return {
63
- ...flags,
64
- pendingAccent,
65
- accentHex_brand: "",
66
- accentHex_amber: ACCENT_META.amber.hex,
67
- accentHex_terracotta: ACCENT_META.terracotta.hex,
68
- accentHex_sage: ACCENT_META.sage.hex,
69
- accentHex_plum: ACCENT_META.plum.hex,
70
- accentHex_ocean: ACCENT_META.ocean.hex,
71
- };
51
+ for (const id of THEME_IDS) flags[`selected_${id}`] = id === theme;
52
+ return { ...flags, theme };
72
53
  }
73
54
 
74
- function initialAccent(): string {
75
- const s = stored(ACCENT_KEY);
76
- return isAccentId(s) ? s : DEFAULT_ACCENT;
77
- }
55
+ // Invalidates async host reads/writes as soon as a newer member choice is made.
56
+ let choiceRevision = 0;
78
57
 
79
58
  const svc = defineService<State, {
80
- sync: (state: State, arg?: unknown) => State;
81
- selectAccent: (state: State, arg?: unknown) => State;
82
- apply: (state: State) => State;
83
- reset: (state: State) => State;
59
+ sync: (state: State, arg?: unknown) => Promise<State>;
60
+ selectTheme: (state: State, arg?: unknown) => Promise<State>;
84
61
  }>("himiBrandedAppearance", {
85
- state: build(initialAccent()),
62
+ state: build(storedTheme()),
86
63
  actions: {
87
- // onAppear: re-read the persisted accent so the swatches reflect reality. An older
88
- // descriptor may still pass a `brandAccent`; it is not used (the Brand swatch is the token).
89
- sync: () => build(initialAccent()),
90
- // Tapping an accent swatch marks it pending (persisted on Apply).
91
- selectAccent: (state, arg) => {
92
- const id = paramValue(arg, "id");
93
- if (!isAccentId(id)) return state;
94
- return build(id);
95
- },
96
- // Apply: persist the accent; the home worker re-reads it on launch.
97
- apply: (state) => {
98
- try { storage()?.setItem(ACCENT_KEY, state.pendingAccent); } catch { /* best-effort */ }
99
- return build(state.pendingAccent);
64
+ // onAppear: the host is the source of truth (the member may have changed the theme
65
+ // on another screen instance, or the host restored it at launch). Fall back to the
66
+ // mirrored value where the host has no `theme.get`.
67
+ sync: async () => {
68
+ // A delayed onAppear read must not undo a choice made while it was in flight.
69
+ const choiceAtStart = choiceRevision;
70
+ try {
71
+ const payload = (await dispatch("theme.get")) as { scheme?: unknown } | null;
72
+ if (choiceAtStart !== choiceRevision) return build(storedTheme());
73
+ if (isThemeId(payload?.scheme)) {
74
+ remember(payload.scheme);
75
+ return build(payload.scheme);
76
+ }
77
+ } catch { /* no host handler (older binary): keep the mirrored choice */ }
78
+ return build(storedTheme());
100
79
  },
101
- // Reset: clear the override, reverting to the brand accent.
102
- reset: (state) => {
80
+ // A tap on a radio applies that theme to the whole app at once.
81
+ selectTheme: async (state, arg) => {
82
+ const id = paramValue(arg, "id");
83
+ if (!isThemeId(id)) return state;
84
+ const revision = ++choiceRevision;
85
+ remember(id);
103
86
  try {
104
- const store = storage();
105
- if (store?.removeItem) store.removeItem(ACCENT_KEY);
106
- else store?.setItem(ACCENT_KEY, "");
107
- } catch { /* best-effort */ }
108
- return build(DEFAULT_ACCENT);
87
+ await dispatch("theme.set", { scheme: id });
88
+ } catch { /* no host handler (older binary): the selection is kept, the app keeps its colours */ }
89
+ return revision === choiceRevision ? build(id) : build(storedTheme());
109
90
  },
110
91
  },
111
92
  });
@@ -12,7 +12,7 @@ import { imageFirstDish, menuCategories as shapeMenuCategories, visibleDishCards
12
12
  import { productImage, productPrice, queryStoreProducts, type StoreProduct } from "../_shared/himi-store.js";
13
13
  import { formatServicePrice } from "../_shared/wix-service-price.js";
14
14
  import { cleanTitle, initials } from "../_shared/himi-text.js";
15
- import { accentColor as resolveAccentColor, ACCENT_KEY, LAYOUT_KEY, type LayoutId, recommendLayout, resolveLayout } from "../_shared/himi-layouts.js";
15
+ import { LAYOUT_KEY, type LayoutId, recommendLayout, resolveLayout } from "../_shared/himi-layouts.js";
16
16
  import { copyParam, copyTemplate, stashCopy } from "../_shared/himi-copy.js";
17
17
  import { parseWeeklyGoal, weeklyGoalProgress, weeklySessionsFromPages } from "../_shared/weekly-goal.js";
18
18
  import { isBridgeUnavailable } from "../_shared/owner-load-error.js";
@@ -235,9 +235,6 @@ interface State {
235
235
  * Plain string, never a proto enum — a `$service:` casePath decodes it as a
236
236
  * JSON string and unknown values fall through to the shipped defaultCase. */
237
237
  effectiveLayout: string;
238
- /** Resolved accent color (hex) for the bindable accent surfaces
239
- * (backgroundColorPath). User accent (storage) → brand color fallback. */
240
- accentColor: string;
241
238
  /** First-run onboarding card — hidden forever once dismissed (storage-flag).
242
239
  * hiddenWhen binds this, so the name reads in the HIDE direction. */
243
240
  onboardingHidden: boolean;
@@ -336,15 +333,6 @@ function onboardingSeen(): boolean {
336
333
  function storedLayout(): string | null {
337
334
  try { return storage()?.getItem(LAYOUT_KEY) ?? null; } catch { return null; }
338
335
  }
339
- function storedAccent(): string {
340
- try { return storage()?.getItem(ACCENT_KEY) ?? ""; } catch { return ""; }
341
- }
342
- // The member's chosen accent (storage), else "" — the surface keeps its accentPrimary token,
343
- // which is the brand. An older descriptor's `brandAccent` param is ignored: it was a copy of
344
- // the brand that a hand edit of tokens.json left behind.
345
- function resolveAccent(_arg?: unknown): string {
346
- return resolveAccentColor(storedAccent());
347
- }
348
336
 
349
337
  // onAppear param reader (the himi-branded-lite-cms pattern): the descriptor
350
338
  // injects `verticals` (+ `ownerDefaultLayout` in Phase 2) as onAppear params.
@@ -894,7 +882,6 @@ function baseState(): State {
894
882
  welcome: neutralWelcome(),
895
883
  refreshedAt: "",
896
884
  effectiveLayout: resolveEffectiveLayout(undefined, 0),
897
- accentColor: resolveAccent(undefined),
898
885
  onboardingHidden: onboardingSeen(),
899
886
  // derive() recomputes this from onboardingHidden, but State requires it and this
900
887
  // literal is a full State by contract — every other derived flag above is passed
@@ -992,7 +979,6 @@ async function refreshPublic(state: State, arg?: unknown): Promise<State | undef
992
979
  ...saved,
993
980
  onboardingHidden,
994
981
  effectiveLayout: resolveEffectiveLayout(arg, 0),
995
- accentColor: resolveAccent(arg),
996
982
  });
997
983
  }
998
984
  try {
@@ -1017,7 +1003,6 @@ async function refreshPublic(state: State, arg?: unknown): Promise<State | undef
1017
1003
  ...saved,
1018
1004
  onboardingHidden,
1019
1005
  effectiveLayout: resolveEffectiveLayout(arg, products.length),
1020
- accentColor: resolveAccent(arg),
1021
1006
  });
1022
1007
  } catch (e) {
1023
1008
  if (gen !== refreshGen) return undefined;
@@ -1044,7 +1029,6 @@ async function refreshPublic(state: State, arg?: unknown): Promise<State | undef
1044
1029
  ...saved,
1045
1030
  onboardingHidden,
1046
1031
  effectiveLayout: resolveEffectiveLayout(arg, keptProducts.length),
1047
- accentColor: resolveAccent(arg),
1048
1032
  });
1049
1033
  }
1050
1034
  }
@@ -14,6 +14,7 @@ identity and navigation in `config.ts`, look and feel in `tokens.json`.
14
14
  himi render <screenId> --tree # render a screen right here, no device needed
15
15
  himi test # exercise every action your screens declare
16
16
  himi login --browser --target wix # sign in with your Wix account (once)
17
+ # no browser? export WIX_API_KEY, then himi login --wix --target wix
17
18
  himi push --draft # publish a DRAFT release + get preview links
18
19
 
19
20
  Build, validate, render and test run entirely on your machine. Only `login` and
@@ -32,6 +32,7 @@ An unset feed shows a setup message instead of another publisher's episodes:
32
32
  himi render <screenId> --tree # render a screen right here, no device needed
33
33
  himi test # exercise every action your screens declare
34
34
  himi login --browser --target wix # sign in with your Wix account (once)
35
+ # no browser? export WIX_API_KEY, then himi login --wix --target wix
35
36
  himi push --draft # publish a DRAFT release + get preview links
36
37
 
37
38
  Build, validate, render and test run entirely on your machine. Only `login` and