@wix/himalaya-cli 0.1260.0 → 0.1262.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 (70) hide show
  1. package/dist/cli.mjs +36 -22
  2. package/dist/preview-assets.generated.bin +0 -0
  3. package/package.json +2 -2
  4. package/templates/beauty-salon/dev/index.ts +45 -7
  5. package/templates/beauty-salon/tier5-src/_shared/home-service.ts +18 -5
  6. package/templates/beauty-salon-owner/dev/index.ts +45 -7
  7. package/templates/beauty-salon-owner/tier5-src/_shared/home-service.ts +18 -5
  8. package/templates/beauty-salon-owner/tier5-src/himi-owner-lite-product-form/index.ts +21 -7
  9. package/templates/beauty-salon-owner/tier5-src/himi-owner-lite-service-form/index.ts +10 -8
  10. package/templates/branded-lite/dev/index.ts +45 -7
  11. package/templates/branded-lite/tier5-src/_shared/home-service.ts +18 -5
  12. package/templates/community-club/dev/index.ts +45 -7
  13. package/templates/community-club/tier5-src/_shared/home-service.ts +18 -5
  14. package/templates/community-club-owner/dev/index.ts +45 -7
  15. package/templates/community-club-owner/tier5-src/_shared/home-service.ts +18 -5
  16. package/templates/community-club-owner/tier5-src/himi-owner-lite-event-form/index.ts +16 -6
  17. package/templates/community-club-owner/tier5-src/himi-owner-lite-product-form/index.ts +21 -7
  18. package/templates/events-meetups/dev/index.ts +45 -7
  19. package/templates/events-meetups/tier5-src/_shared/home-service.ts +18 -5
  20. package/templates/events-meetups-owner/dev/index.ts +45 -7
  21. package/templates/events-meetups-owner/tier5-src/_shared/home-service.ts +18 -5
  22. package/templates/events-meetups-owner/tier5-src/himi-owner-lite-event-form/index.ts +16 -6
  23. package/templates/gym-fitness/dev/index.ts +45 -7
  24. package/templates/gym-fitness/tier5-src/_shared/home-service.ts +18 -5
  25. package/templates/gym-fitness-owner/dev/index.ts +45 -7
  26. package/templates/gym-fitness-owner/tier5-src/_shared/home-service.ts +18 -5
  27. package/templates/gym-fitness-owner/tier5-src/himi-owner-lite-event-form/index.ts +16 -6
  28. package/templates/gym-fitness-owner/tier5-src/himi-owner-lite-product-form/index.ts +21 -7
  29. package/templates/gym-fitness-owner/tier5-src/himi-owner-lite-service-form/index.ts +10 -8
  30. package/templates/nonprofit-cause/dev/index.ts +45 -7
  31. package/templates/nonprofit-cause/tier5-src/_shared/home-service.ts +18 -5
  32. package/templates/nonprofit-cause-owner/dev/index.ts +45 -7
  33. package/templates/nonprofit-cause-owner/tier5-src/_shared/home-service.ts +18 -5
  34. package/templates/nonprofit-cause-owner/tier5-src/himi-owner-lite-event-form/index.ts +16 -6
  35. package/templates/nonprofit-cause-owner/tier5-src/himi-owner-lite-service-form/index.ts +10 -8
  36. package/templates/owner-lite/dev/index.ts +45 -7
  37. package/templates/owner-lite/tier5-src/_shared/home-service.ts +18 -5
  38. package/templates/owner-lite/tier5-src/himi-owner-lite-event-form/index.ts +16 -6
  39. package/templates/owner-lite/tier5-src/himi-owner-lite-product-form/index.ts +21 -7
  40. package/templates/owner-lite/tier5-src/himi-owner-lite-service-form/index.ts +10 -8
  41. package/templates/podcast-creator/dev/index.ts +45 -7
  42. package/templates/podcast-creator/tier5-src/_shared/home-service.ts +18 -5
  43. package/templates/podcast-creator-owner/dev/index.ts +45 -7
  44. package/templates/podcast-creator-owner/tier5-src/_shared/home-service.ts +18 -5
  45. package/templates/podcast-creator-owner/tier5-src/himi-owner-lite-event-form/index.ts +16 -6
  46. package/templates/podcast-creator-owner/tier5-src/himi-owner-lite-product-form/index.ts +21 -7
  47. package/templates/portfolio-creative/dev/index.ts +45 -7
  48. package/templates/portfolio-creative/tier5-src/_shared/home-service.ts +18 -5
  49. package/templates/portfolio-creative-owner/dev/index.ts +45 -7
  50. package/templates/portfolio-creative-owner/tier5-src/_shared/home-service.ts +18 -5
  51. package/templates/portfolio-creative-owner/tier5-src/himi-owner-lite-product-form/index.ts +21 -7
  52. package/templates/portfolio-creative-owner/tier5-src/himi-owner-lite-service-form/index.ts +10 -8
  53. package/templates/restaurant/dev/index.ts +45 -7
  54. package/templates/restaurant/tier5-src/_shared/home-service.ts +18 -5
  55. package/templates/restaurant-owner/dev/index.ts +45 -7
  56. package/templates/restaurant-owner/tier5-src/_shared/home-service.ts +18 -5
  57. package/templates/restaurant-owner/tier5-src/himi-owner-lite-event-form/index.ts +16 -6
  58. package/templates/restaurant-owner/tier5-src/himi-owner-lite-product-form/index.ts +21 -7
  59. package/templates/restaurant-owner/tier5-src/himi-owner-lite-service-form/index.ts +10 -8
  60. package/templates/retail-store/dev/index.ts +45 -7
  61. package/templates/retail-store/tier5-src/_shared/home-service.ts +18 -5
  62. package/templates/retail-store-owner/dev/index.ts +45 -7
  63. package/templates/retail-store-owner/tier5-src/_shared/home-service.ts +18 -5
  64. package/templates/retail-store-owner/tier5-src/himi-owner-lite-product-form/index.ts +21 -7
  65. package/templates/yoga-studio/dev/index.ts +45 -7
  66. package/templates/yoga-studio/tier5-src/_shared/home-service.ts +18 -5
  67. package/templates/yoga-studio-owner/dev/index.ts +45 -7
  68. package/templates/yoga-studio-owner/tier5-src/_shared/home-service.ts +18 -5
  69. package/templates/yoga-studio-owner/tier5-src/himi-owner-lite-event-form/index.ts +16 -6
  70. package/templates/yoga-studio-owner/tier5-src/himi-owner-lite-service-form/index.ts +10 -8
@@ -2691,6 +2691,9 @@ const SCREENS = runtimeSetting({
2691
2691
  "type": "BottomSheet",
2692
2692
  "props": {
2693
2693
  "presentedPath": "$service:himiBrandedHome.homeModules.presented",
2694
+ "detents": [
2695
+ 0.95
2696
+ ],
2694
2697
  "dismissible": true,
2695
2698
  "showGrabber": true,
2696
2699
  "onDismiss": {
@@ -2792,6 +2795,9 @@ const SCREENS = runtimeSetting({
2792
2795
  }
2793
2796
  }
2794
2797
  }
2798
+ },
2799
+ "modifiers": {
2800
+ "accessibilityLabel": "$item.pinA11yLabel"
2795
2801
  }
2796
2802
  },
2797
2803
  {
@@ -2809,31 +2815,63 @@ const SCREENS = runtimeSetting({
2809
2815
  }
2810
2816
  }
2811
2817
  }
2818
+ },
2819
+ "modifiers": {
2820
+ "accessibilityLabel": "$item.visibilityA11yLabel"
2812
2821
  }
2813
- },
2822
+ }
2823
+ ]
2824
+ }
2825
+ }
2826
+ },
2827
+ {
2828
+ "id": "",
2829
+ "body": {
2830
+ "package": "himalaya",
2831
+ "type": "HStack",
2832
+ "props": {
2833
+ "spacing": 8,
2834
+ "children": [
2814
2835
  {
2815
- "id": "",
2836
+ "id": "btn_tier5_himibrandedhome_homemoveup",
2816
2837
  "body": {
2817
2838
  "package": "himalaya",
2818
- "type": "Spacer",
2819
- "props": {}
2839
+ "type": "Button",
2840
+ "props": {
2841
+ "title": "Move up",
2842
+ "style": "plain",
2843
+ "action": {
2844
+ "actionId": "tier5.himiBrandedHome.homeMoveUp",
2845
+ "params": {
2846
+ "id": "$item.id"
2847
+ }
2848
+ }
2849
+ }
2850
+ },
2851
+ "modifiers": {
2852
+ "accessibilityLabel": "$item.moveUpA11yLabel",
2853
+ "hiddenPath": "$item.isFirst"
2820
2854
  }
2821
2855
  },
2822
2856
  {
2823
- "id": "btn_tier5_himibrandedhome_homemoveup",
2857
+ "id": "btn_tier5_himibrandedhome_homemovedown",
2824
2858
  "body": {
2825
2859
  "package": "himalaya",
2826
2860
  "type": "Button",
2827
2861
  "props": {
2828
- "title": "Move up",
2862
+ "title": "Move down",
2829
2863
  "style": "plain",
2830
2864
  "action": {
2831
- "actionId": "tier5.himiBrandedHome.homeMoveUp",
2865
+ "actionId": "tier5.himiBrandedHome.homeMoveDown",
2832
2866
  "params": {
2833
2867
  "id": "$item.id"
2834
2868
  }
2835
2869
  }
2836
2870
  }
2871
+ },
2872
+ "modifiers": {
2873
+ "accessibilityLabel": "$item.moveDownA11yLabel",
2874
+ "hiddenPath": "$item.isLast"
2837
2875
  }
2838
2876
  }
2839
2877
  ]
@@ -1,6 +1,6 @@
1
1
  import { defineService as register, type ServiceDefinition } from '@himalaya/state';
2
2
  import { normalizeHome, visibleHome, moduleIsEmpty, type HomeModule, type HomePreferences } from './home-modules.js';
3
- import { copyParam, stashCopy } from './himi-copy.js';
3
+ import { copyParam, copyTemplate, stashCopy } from './himi-copy.js';
4
4
  import { localPreferences } from './local-preferences.js';
5
5
  type State = Record<string, unknown>;
6
6
  type Action = (s: State, ...args: unknown[]) => State | undefined | Promise<State | undefined>;
@@ -32,10 +32,22 @@ export function decorateHome(def: { state: State; actions?: Record<string, Actio
32
32
  return { ...s, homeModules: { presented, visible: painted.map(id => ({ id })),
33
33
  persistenceLabel: persisted.available ? copyParam('homeModules.onDevice', 'Saved on this device') : copyParam('homeModules.sessionOnly', 'Choices last for this session'),
34
34
  slots: Object.fromEntries(modules.map((_, i) => [`slot${i}`, order[i] ?? 'empty'])),
35
- choices: prefs.order.map(id => ({ ...modules.find(module => module.id === id),
36
- visibility: prefs.hidden.includes(id) ? copyParam('homeModules.show', 'Show') : copyParam('homeModules.hide', 'Hide'),
37
- pinLabel: prefs.pinned.includes(id) ? copyParam('homeModules.unpin', 'Unpin') : copyParam('homeModules.pin', 'Pin'),
38
- })) } };
35
+ choices: prefs.order.map((id, index) => {
36
+ const module = modules.find(candidate => candidate.id === id);
37
+ const name = module?.label ?? id;
38
+ const isHidden = prefs.hidden.includes(id);
39
+ const isPinned = prefs.pinned.includes(id);
40
+ return { ...module,
41
+ isFirst: index === 0,
42
+ isLast: index === prefs.order.length - 1,
43
+ visibility: isHidden ? copyParam('homeModules.show', 'Show') : copyParam('homeModules.hide', 'Hide'),
44
+ pinLabel: isPinned ? copyParam('homeModules.unpin', 'Unpin') : copyParam('homeModules.pin', 'Pin'),
45
+ visibilityA11yLabel: copyTemplate(isHidden ? 'homeModules.showA11y' : 'homeModules.hideA11y', isHidden ? 'Show {module}' : 'Hide {module}', { module: name }),
46
+ pinA11yLabel: copyTemplate(isPinned ? 'homeModules.unpinA11y' : 'homeModules.pinA11y', isPinned ? 'Unpin {module}' : 'Pin {module}', { module: name }),
47
+ moveUpA11yLabel: copyTemplate('homeModules.moveUpA11y', 'Move {module} up', { module: name }),
48
+ moveDownA11yLabel: copyTemplate('homeModules.moveDownA11y', 'Move {module} down', { module: name }),
49
+ };
50
+ }) } };
39
51
  };
40
52
  const actions: Record<string, Action> = {};
41
53
  for (const [name, action] of Object.entries(def.actions ?? {})) actions[name] = (s, ...args) => {
@@ -72,6 +84,7 @@ export function decorateHome(def: { state: State; actions?: Record<string, Actio
72
84
  actions.homeToggle = change(id => { if (modules.some(m => m.id === id)) prefs.hidden = prefs.hidden.includes(id) ? prefs.hidden.filter(x => x !== id) : [...prefs.hidden, id]; });
73
85
  actions.homePin = change(id => { if (modules.some(m => m.id === id)) { prefs.pinned = prefs.pinned.includes(id) ? prefs.pinned.filter(x => x !== id) : [...prefs.pinned, id]; prefs.hidden = prefs.hidden.filter(x => x !== id); } });
74
86
  actions.homeMoveUp = change(id => { const index = prefs.order.indexOf(id); if (index > 0) [prefs.order[index - 1], prefs.order[index]] = [prefs.order[index], prefs.order[index - 1]]; });
87
+ actions.homeMoveDown = change(id => { const index = prefs.order.indexOf(id); if (index >= 0 && index < prefs.order.length - 1) [prefs.order[index], prefs.order[index + 1]] = [prefs.order[index + 1], prefs.order[index]]; });
75
88
  return { state: derive(def.state), actions };
76
89
  }
77
90
  export const defineService: typeof register = ((name: string, def: ServiceDefinition<unknown>) => register(name, decorateHome(def as unknown as { state: State; actions?: Record<string, Action> }))) as typeof register;
@@ -1725,6 +1725,9 @@ const SCREENS = runtimeSetting({
1725
1725
  "type": "BottomSheet",
1726
1726
  "props": {
1727
1727
  "presentedPath": "$service:himiBrandedHome.homeModules.presented",
1728
+ "detents": [
1729
+ 0.95
1730
+ ],
1728
1731
  "dismissible": true,
1729
1732
  "showGrabber": true,
1730
1733
  "onDismiss": {
@@ -1826,6 +1829,9 @@ const SCREENS = runtimeSetting({
1826
1829
  }
1827
1830
  }
1828
1831
  }
1832
+ },
1833
+ "modifiers": {
1834
+ "accessibilityLabel": "$item.pinA11yLabel"
1829
1835
  }
1830
1836
  },
1831
1837
  {
@@ -1843,31 +1849,63 @@ const SCREENS = runtimeSetting({
1843
1849
  }
1844
1850
  }
1845
1851
  }
1852
+ },
1853
+ "modifiers": {
1854
+ "accessibilityLabel": "$item.visibilityA11yLabel"
1846
1855
  }
1847
- },
1856
+ }
1857
+ ]
1858
+ }
1859
+ }
1860
+ },
1861
+ {
1862
+ "id": "",
1863
+ "body": {
1864
+ "package": "himalaya",
1865
+ "type": "HStack",
1866
+ "props": {
1867
+ "spacing": 8,
1868
+ "children": [
1848
1869
  {
1849
- "id": "",
1870
+ "id": "btn_tier5_himibrandedhome_homemoveup",
1850
1871
  "body": {
1851
1872
  "package": "himalaya",
1852
- "type": "Spacer",
1853
- "props": {}
1873
+ "type": "Button",
1874
+ "props": {
1875
+ "title": "Move up",
1876
+ "style": "plain",
1877
+ "action": {
1878
+ "actionId": "tier5.himiBrandedHome.homeMoveUp",
1879
+ "params": {
1880
+ "id": "$item.id"
1881
+ }
1882
+ }
1883
+ }
1884
+ },
1885
+ "modifiers": {
1886
+ "accessibilityLabel": "$item.moveUpA11yLabel",
1887
+ "hiddenPath": "$item.isFirst"
1854
1888
  }
1855
1889
  },
1856
1890
  {
1857
- "id": "btn_tier5_himibrandedhome_homemoveup",
1891
+ "id": "btn_tier5_himibrandedhome_homemovedown",
1858
1892
  "body": {
1859
1893
  "package": "himalaya",
1860
1894
  "type": "Button",
1861
1895
  "props": {
1862
- "title": "Move up",
1896
+ "title": "Move down",
1863
1897
  "style": "plain",
1864
1898
  "action": {
1865
- "actionId": "tier5.himiBrandedHome.homeMoveUp",
1899
+ "actionId": "tier5.himiBrandedHome.homeMoveDown",
1866
1900
  "params": {
1867
1901
  "id": "$item.id"
1868
1902
  }
1869
1903
  }
1870
1904
  }
1905
+ },
1906
+ "modifiers": {
1907
+ "accessibilityLabel": "$item.moveDownA11yLabel",
1908
+ "hiddenPath": "$item.isLast"
1871
1909
  }
1872
1910
  }
1873
1911
  ]
@@ -1,6 +1,6 @@
1
1
  import { defineService as register, type ServiceDefinition } from '@himalaya/state';
2
2
  import { normalizeHome, visibleHome, moduleIsEmpty, type HomeModule, type HomePreferences } from './home-modules.js';
3
- import { copyParam, stashCopy } from './himi-copy.js';
3
+ import { copyParam, copyTemplate, stashCopy } from './himi-copy.js';
4
4
  import { localPreferences } from './local-preferences.js';
5
5
  type State = Record<string, unknown>;
6
6
  type Action = (s: State, ...args: unknown[]) => State | undefined | Promise<State | undefined>;
@@ -32,10 +32,22 @@ export function decorateHome(def: { state: State; actions?: Record<string, Actio
32
32
  return { ...s, homeModules: { presented, visible: painted.map(id => ({ id })),
33
33
  persistenceLabel: persisted.available ? copyParam('homeModules.onDevice', 'Saved on this device') : copyParam('homeModules.sessionOnly', 'Choices last for this session'),
34
34
  slots: Object.fromEntries(modules.map((_, i) => [`slot${i}`, order[i] ?? 'empty'])),
35
- choices: prefs.order.map(id => ({ ...modules.find(module => module.id === id),
36
- visibility: prefs.hidden.includes(id) ? copyParam('homeModules.show', 'Show') : copyParam('homeModules.hide', 'Hide'),
37
- pinLabel: prefs.pinned.includes(id) ? copyParam('homeModules.unpin', 'Unpin') : copyParam('homeModules.pin', 'Pin'),
38
- })) } };
35
+ choices: prefs.order.map((id, index) => {
36
+ const module = modules.find(candidate => candidate.id === id);
37
+ const name = module?.label ?? id;
38
+ const isHidden = prefs.hidden.includes(id);
39
+ const isPinned = prefs.pinned.includes(id);
40
+ return { ...module,
41
+ isFirst: index === 0,
42
+ isLast: index === prefs.order.length - 1,
43
+ visibility: isHidden ? copyParam('homeModules.show', 'Show') : copyParam('homeModules.hide', 'Hide'),
44
+ pinLabel: isPinned ? copyParam('homeModules.unpin', 'Unpin') : copyParam('homeModules.pin', 'Pin'),
45
+ visibilityA11yLabel: copyTemplate(isHidden ? 'homeModules.showA11y' : 'homeModules.hideA11y', isHidden ? 'Show {module}' : 'Hide {module}', { module: name }),
46
+ pinA11yLabel: copyTemplate(isPinned ? 'homeModules.unpinA11y' : 'homeModules.pinA11y', isPinned ? 'Unpin {module}' : 'Pin {module}', { module: name }),
47
+ moveUpA11yLabel: copyTemplate('homeModules.moveUpA11y', 'Move {module} up', { module: name }),
48
+ moveDownA11yLabel: copyTemplate('homeModules.moveDownA11y', 'Move {module} down', { module: name }),
49
+ };
50
+ }) } };
39
51
  };
40
52
  const actions: Record<string, Action> = {};
41
53
  for (const [name, action] of Object.entries(def.actions ?? {})) actions[name] = (s, ...args) => {
@@ -72,6 +84,7 @@ export function decorateHome(def: { state: State; actions?: Record<string, Actio
72
84
  actions.homeToggle = change(id => { if (modules.some(m => m.id === id)) prefs.hidden = prefs.hidden.includes(id) ? prefs.hidden.filter(x => x !== id) : [...prefs.hidden, id]; });
73
85
  actions.homePin = change(id => { if (modules.some(m => m.id === id)) { prefs.pinned = prefs.pinned.includes(id) ? prefs.pinned.filter(x => x !== id) : [...prefs.pinned, id]; prefs.hidden = prefs.hidden.filter(x => x !== id); } });
74
86
  actions.homeMoveUp = change(id => { const index = prefs.order.indexOf(id); if (index > 0) [prefs.order[index - 1], prefs.order[index]] = [prefs.order[index], prefs.order[index - 1]]; });
87
+ actions.homeMoveDown = change(id => { const index = prefs.order.indexOf(id); if (index >= 0 && index < prefs.order.length - 1) [prefs.order[index], prefs.order[index + 1]] = [prefs.order[index + 1], prefs.order[index]]; });
75
88
  return { state: derive(def.state), actions };
76
89
  }
77
90
  export const defineService: typeof register = ((name: string, def: ServiceDefinition<unknown>) => register(name, decorateHome(def as unknown as { state: State; actions?: Record<string, Action> }))) as typeof register;
@@ -50465,6 +50465,9 @@ const SCREENS = runtimeSetting({
50465
50465
  "type": "BottomSheet",
50466
50466
  "props": {
50467
50467
  "presentedPath": "$service:himiOwnerLiteHome.homeModules.presented",
50468
+ "detents": [
50469
+ 0.95
50470
+ ],
50468
50471
  "dismissible": true,
50469
50472
  "showGrabber": true,
50470
50473
  "onDismiss": {
@@ -50566,6 +50569,9 @@ const SCREENS = runtimeSetting({
50566
50569
  }
50567
50570
  }
50568
50571
  }
50572
+ },
50573
+ "modifiers": {
50574
+ "accessibilityLabel": "$item.pinA11yLabel"
50569
50575
  }
50570
50576
  },
50571
50577
  {
@@ -50583,31 +50589,63 @@ const SCREENS = runtimeSetting({
50583
50589
  }
50584
50590
  }
50585
50591
  }
50592
+ },
50593
+ "modifiers": {
50594
+ "accessibilityLabel": "$item.visibilityA11yLabel"
50586
50595
  }
50587
- },
50596
+ }
50597
+ ]
50598
+ }
50599
+ }
50600
+ },
50601
+ {
50602
+ "id": "",
50603
+ "body": {
50604
+ "package": "himalaya",
50605
+ "type": "HStack",
50606
+ "props": {
50607
+ "spacing": 8,
50608
+ "children": [
50588
50609
  {
50589
- "id": "",
50610
+ "id": "btn_tier5_himiownerlitehome_homemoveup",
50590
50611
  "body": {
50591
50612
  "package": "himalaya",
50592
- "type": "Spacer",
50593
- "props": {}
50613
+ "type": "Button",
50614
+ "props": {
50615
+ "title": "Move up",
50616
+ "style": "plain",
50617
+ "action": {
50618
+ "actionId": "tier5.himiOwnerLiteHome.homeMoveUp",
50619
+ "params": {
50620
+ "id": "$item.id"
50621
+ }
50622
+ }
50623
+ }
50624
+ },
50625
+ "modifiers": {
50626
+ "accessibilityLabel": "$item.moveUpA11yLabel",
50627
+ "hiddenPath": "$item.isFirst"
50594
50628
  }
50595
50629
  },
50596
50630
  {
50597
- "id": "btn_tier5_himiownerlitehome_homemoveup",
50631
+ "id": "btn_tier5_himiownerlitehome_homemovedown",
50598
50632
  "body": {
50599
50633
  "package": "himalaya",
50600
50634
  "type": "Button",
50601
50635
  "props": {
50602
- "title": "Move up",
50636
+ "title": "Move down",
50603
50637
  "style": "plain",
50604
50638
  "action": {
50605
- "actionId": "tier5.himiOwnerLiteHome.homeMoveUp",
50639
+ "actionId": "tier5.himiOwnerLiteHome.homeMoveDown",
50606
50640
  "params": {
50607
50641
  "id": "$item.id"
50608
50642
  }
50609
50643
  }
50610
50644
  }
50645
+ },
50646
+ "modifiers": {
50647
+ "accessibilityLabel": "$item.moveDownA11yLabel",
50648
+ "hiddenPath": "$item.isLast"
50611
50649
  }
50612
50650
  }
50613
50651
  ]
@@ -1,6 +1,6 @@
1
1
  import { defineService as register, type ServiceDefinition } from '@himalaya/state';
2
2
  import { normalizeHome, visibleHome, moduleIsEmpty, type HomeModule, type HomePreferences } from './home-modules.js';
3
- import { copyParam, stashCopy } from './himi-copy.js';
3
+ import { copyParam, copyTemplate, stashCopy } from './himi-copy.js';
4
4
  import { localPreferences } from './local-preferences.js';
5
5
  type State = Record<string, unknown>;
6
6
  type Action = (s: State, ...args: unknown[]) => State | undefined | Promise<State | undefined>;
@@ -32,10 +32,22 @@ export function decorateHome(def: { state: State; actions?: Record<string, Actio
32
32
  return { ...s, homeModules: { presented, visible: painted.map(id => ({ id })),
33
33
  persistenceLabel: persisted.available ? copyParam('homeModules.onDevice', 'Saved on this device') : copyParam('homeModules.sessionOnly', 'Choices last for this session'),
34
34
  slots: Object.fromEntries(modules.map((_, i) => [`slot${i}`, order[i] ?? 'empty'])),
35
- choices: prefs.order.map(id => ({ ...modules.find(module => module.id === id),
36
- visibility: prefs.hidden.includes(id) ? copyParam('homeModules.show', 'Show') : copyParam('homeModules.hide', 'Hide'),
37
- pinLabel: prefs.pinned.includes(id) ? copyParam('homeModules.unpin', 'Unpin') : copyParam('homeModules.pin', 'Pin'),
38
- })) } };
35
+ choices: prefs.order.map((id, index) => {
36
+ const module = modules.find(candidate => candidate.id === id);
37
+ const name = module?.label ?? id;
38
+ const isHidden = prefs.hidden.includes(id);
39
+ const isPinned = prefs.pinned.includes(id);
40
+ return { ...module,
41
+ isFirst: index === 0,
42
+ isLast: index === prefs.order.length - 1,
43
+ visibility: isHidden ? copyParam('homeModules.show', 'Show') : copyParam('homeModules.hide', 'Hide'),
44
+ pinLabel: isPinned ? copyParam('homeModules.unpin', 'Unpin') : copyParam('homeModules.pin', 'Pin'),
45
+ visibilityA11yLabel: copyTemplate(isHidden ? 'homeModules.showA11y' : 'homeModules.hideA11y', isHidden ? 'Show {module}' : 'Hide {module}', { module: name }),
46
+ pinA11yLabel: copyTemplate(isPinned ? 'homeModules.unpinA11y' : 'homeModules.pinA11y', isPinned ? 'Unpin {module}' : 'Pin {module}', { module: name }),
47
+ moveUpA11yLabel: copyTemplate('homeModules.moveUpA11y', 'Move {module} up', { module: name }),
48
+ moveDownA11yLabel: copyTemplate('homeModules.moveDownA11y', 'Move {module} down', { module: name }),
49
+ };
50
+ }) } };
39
51
  };
40
52
  const actions: Record<string, Action> = {};
41
53
  for (const [name, action] of Object.entries(def.actions ?? {})) actions[name] = (s, ...args) => {
@@ -72,6 +84,7 @@ export function decorateHome(def: { state: State; actions?: Record<string, Actio
72
84
  actions.homeToggle = change(id => { if (modules.some(m => m.id === id)) prefs.hidden = prefs.hidden.includes(id) ? prefs.hidden.filter(x => x !== id) : [...prefs.hidden, id]; });
73
85
  actions.homePin = change(id => { if (modules.some(m => m.id === id)) { prefs.pinned = prefs.pinned.includes(id) ? prefs.pinned.filter(x => x !== id) : [...prefs.pinned, id]; prefs.hidden = prefs.hidden.filter(x => x !== id); } });
74
86
  actions.homeMoveUp = change(id => { const index = prefs.order.indexOf(id); if (index > 0) [prefs.order[index - 1], prefs.order[index]] = [prefs.order[index], prefs.order[index - 1]]; });
87
+ actions.homeMoveDown = change(id => { const index = prefs.order.indexOf(id); if (index >= 0 && index < prefs.order.length - 1) [prefs.order[index], prefs.order[index + 1]] = [prefs.order[index + 1], prefs.order[index]]; });
75
88
  return { state: derive(def.state), actions };
76
89
  }
77
90
  export const defineService: typeof register = ((name: string, def: ServiceDefinition<unknown>) => register(name, decorateHome(def as unknown as { state: State; actions?: Record<string, Action> }))) as typeof register;
@@ -268,6 +268,7 @@ const svc = defineService<EventFormState, {
268
268
  submit: async (s, values): Promise<EventFormState> => settleOverLive(svc, s, await (async (): Promise<EventFormState> => {
269
269
  if (isOwnerPreviewDemo() || s.demoNote) return demoRefusal(s);
270
270
  const v = values ?? {};
271
+ const targetId = s.id || (typeof v.id === "string" ? v.id : "");
271
272
  const title = String(v.title ?? s.title).trim();
272
273
  // The description, per record mode. A queue replay boots a FRESH worker and says so with
273
274
  // `descriptionEdited`: this bundle's editor items add the document as `descriptionJson`; the
@@ -299,7 +300,7 @@ const svc = defineService<EventFormState, {
299
300
  }
300
301
  const description = doc ? postBodyText(doc as never) : s.description; // the plain-text mirror
301
302
  if (!title) return shape({ ...s, status: "error", error: copyParam("ownerEventForm.titleRequired", "Title is required"), savedMessage: "" });
302
- if (!s.id) return shape({ ...s, status: "error", error: copyParam("ownerEventForm.errorNoEvent", "No event to edit."), savedMessage: "" });
303
+ if (!targetId) return shape({ ...s, status: "error", error: copyParam("ownerEventForm.errorNoEvent", "No event to edit."), savedMessage: "" });
303
304
 
304
305
  // updateEvent(id, event) wraps the body as { event } internally, so pass the event fields
305
306
  // directly. Only what the owner edited is written, the description always as a Ricos document
@@ -315,22 +316,31 @@ const svc = defineService<EventFormState, {
315
316
  // Plain only when KNOWN plain: a plain row, or a loaded event with no description. Before load
316
317
  // lands nothing is known, so the row stays protected (fail closed).
317
318
  const knownPlain = s.descriptionMode === "plain" || (s.descriptionMode === "editor" && !s.descriptionPending && s.descriptionJson === "");
318
- await cachePut({ id: s.id, name: title, title, description, descriptionProtected: cachedRichVerdict(heldDoc as never, knownPlain), ...(heldJson ? { descriptionJson: heldJson } : {}), when: s.when, location: s.location });
319
+ const cached = replay && !s.id ? await cacheGet(targetId) : null;
320
+ // A queued metadata edit omitted the event body and read-only details. Keep their cached
321
+ // values rather than replacing them with a fresh worker's empty/default state.
322
+ await cachePut({
323
+ ...(cached ?? {}), id: targetId, name: title, title,
324
+ description: doc ? description : String(cached?.description ?? description),
325
+ descriptionProtected: doc ? cachedRichVerdict(heldDoc as never, knownPlain) : String(cached?.descriptionProtected ?? cachedRichVerdict(heldDoc as never, knownPlain)),
326
+ ...(heldJson ? { descriptionJson: heldJson } : {}),
327
+ when: String(cached?.when ?? s.when), location: String(cached?.location ?? s.location),
328
+ });
319
329
  const savedState = (savedMessage: string) => {
320
330
  // An edit typed while this save was in flight stays unsaved work ([rico] #3644).
321
331
  const after = editorAfterSave("description", s as never, liveState(svc), !!doc);
322
332
  return shape({
323
- ...s, mode: "edit", id: s.id, heading: copyParam("ownerEventForm.headingEdit", "Edit event"),
333
+ ...s, mode: "edit", id: targetId, heading: copyParam("ownerEventForm.headingEdit", "Edit event"),
324
334
  title, description, originalDescription: doc ? description : s.originalDescription,
325
335
  ...(docRaw ? { descriptionJson: docRaw } : {}),
326
336
  descriptionDirty: after.dirty, descriptionEdits: after.edits,
327
- status: "saved", savedMessage, savedId: s.id,
337
+ status: "saved", savedMessage, savedId: targetId,
328
338
  ...(after.editedDuringSave ? { status: "idle" as const, savedMessage: "" } : {}),
329
339
  error: tooLarge ? copyParam("ownerEventForm.descriptionTooLarge", "The description is too long to save, so it was left as it was. Your other changes were saved.") : "",
330
340
  });
331
341
  };
332
342
  try {
333
- await updateEvent(s.id, event);
343
+ await updateEvent(targetId, event);
334
344
  return savedState(copyParam("ownerEventForm.savedMessage", "Event saved."));
335
345
  } catch (e) {
336
346
  if (shouldQueueOwnerWrite(e)) {
@@ -342,7 +352,7 @@ const svc = defineService<EventFormState, {
342
352
  // (WriteQueue, idempotent) when connectivity returns. A document rides as `descriptionJson`
343
353
  // with descriptionEdited "false", so a bundle rolled back past this change leaves the
344
354
  // description rather than flattening it to text.
345
- await queueWrite("tier5.himiOwnerLiteEventForm.submit", { id: s.id, title, description,
355
+ await queueWrite("tier5.himiOwnerLiteEventForm.submit", { id: targetId, title, description,
346
356
  ...(docRaw ? { descriptionJson: docRaw, descriptionEdited: "false" } : { descriptionEdited: String(doc !== null) }) });
347
357
  return savedState(copyParam("ownerEventForm.savedOffline", "Saved offline — will sync when you reconnect."));
348
358
  }
@@ -289,6 +289,10 @@ const svc = defineService<ProductFormState, {
289
289
  submit: async (s, values): Promise<ProductFormState> => settleOverLive(svc, s, await (async (): Promise<ProductFormState> => {
290
290
  if (isOwnerPreviewDemo() || s.demoNote) return demoRefusal(s);
291
291
  const v = values ?? {};
292
+ // Queue replay boots a fresh worker without navigation input. Keep a live form's
293
+ // target authoritative, and use the queued mode only for a queued target.
294
+ const targetId = s.id || (typeof v.id === "string" ? v.id : "");
295
+ const mode: Mode = !s.id && targetId && v.mode === "edit" ? "edit" : s.mode;
292
296
  const name = String(v.name ?? s.name).trim();
293
297
  const rawPrice = String(v.price ?? s.price).trim();
294
298
  // "12,50" (comma-decimal keypad) is accepted and written as 12.50.
@@ -340,7 +344,7 @@ const svc = defineService<ProductFormState, {
340
344
  ...(sku ? { sku } : {}),
341
345
  ...(descriptionEdited ? { description } : {}),
342
346
  ...(richDescription ? { richDescription } : {}),
343
- ...(s.mode === "edit" && s.id ? {} : { productType: "physical" }),
347
+ ...(mode === "edit" && targetId ? {} : { productType: "physical" }),
344
348
  };
345
349
  // The document the record now holds, when known: an offline reopen seeds the editor with it.
346
350
  const loadedJson = s.descriptionMode === "editor" && !s.descriptionPending ? s.descriptionJson : "";
@@ -353,7 +357,17 @@ const svc = defineService<ProductFormState, {
353
357
  const descriptionProtected = cachedRichVerdict(heldDoc as never, knownPlain);
354
358
 
355
359
  // Optimistic local write — the list repaints from cache immediately (offline or not).
356
- const localRow = (id: string): DbEntity => ({ id, name, price, sku, description, descriptionProtected, ...(heldJson ? { descriptionJson: heldJson } : {}), visible: visible ? "true" : "false", statusLabel: visible ? "Visible" : "Hidden" });
360
+ // Replay starts with default worker state. An untouched description was omitted from the
361
+ // queued PATCH, so retain its cached mirror/document/verdict when replacing the local row.
362
+ const cached = replay && targetId ? await cacheGet(targetId) : null;
363
+ const keepCachedDescription = cached !== null && !descriptionEdited && richDescription === null;
364
+ const localRow = (id: string): DbEntity => ({
365
+ ...(cached ?? {}), id, name, price, sku,
366
+ description: keepCachedDescription ? String(cached.description ?? "") : description,
367
+ descriptionProtected: keepCachedDescription ? String(cached.descriptionProtected ?? descriptionProtected) : descriptionProtected,
368
+ ...(heldJson ? { descriptionJson: heldJson } : descriptionEdited ? { descriptionJson: "" } : {}),
369
+ visible: visible ? "true" : "false", statusLabel: visible ? "Visible" : "Hidden",
370
+ });
357
371
  const wrote = richDescription !== null;
358
372
  const savedDescription = {
359
373
  description, originalDescription: descriptionEdited || wrote ? description : s.originalDescription,
@@ -365,12 +379,12 @@ const svc = defineService<ProductFormState, {
365
379
  const a = editorAfterSave("description", s as never, liveState(svc), wrote);
366
380
  return { descriptionDirty: a.dirty, descriptionEdits: a.edits, ...(a.editedDuringSave ? { status: "idle" as const, savedMessage: "" } : {}) };
367
381
  };
368
- const localId = s.mode === "edit" && s.id ? s.id : `local-${Date.now()}`;
382
+ const localId = mode === "edit" && targetId ? targetId : `local-${Date.now()}`;
369
383
  await cachePut(localRow(localId));
370
384
  try {
371
- let id = s.id;
372
- if (s.mode === "edit" && s.id) {
373
- await updateProduct(s.id, write as WixProductWrite);
385
+ let id = targetId;
386
+ if (mode === "edit" && targetId) {
387
+ await updateProduct(targetId, write as WixProductWrite);
374
388
  } else {
375
389
  const r = await createProduct(write);
376
390
  id = r.product?.id || localId;
@@ -402,7 +416,7 @@ const svc = defineService<ProductFormState, {
402
416
  // write to replay (WriteQueue, idempotent) when connectivity returns.
403
417
  // A document rides as `descriptionJson` with descriptionEdited "false", so a bundle rolled back
404
418
  // past this change leaves the description rather than flattening it to text.
405
- await queueWrite("tier5.himiOwnerLiteProductForm.submit", { id: s.id, name, price, sku, description, visible: String(visible), mode: s.mode,
419
+ await queueWrite("tier5.himiOwnerLiteProductForm.submit", { id: targetId, name, price, sku, description, visible: String(visible), mode,
406
420
  ...(docRaw ? { descriptionJson: docRaw, descriptionEdited: "false" } : { descriptionEdited: String(descriptionEdited) }) });
407
421
  return shape({
408
422
  ...s, mode: "edit", id: localId, name, price, sku, ...savedDescription,