@juo/blocks 1.20.0 → 2.0.0-alpha.10

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 (152) hide show
  1. package/dist/{ExtensionRoot-DfpvN94s.js → ExtensionRoot-CG9dH98z.js} +24 -6
  2. package/dist/block-BjJztStr.js +993 -0
  3. package/dist/{block-dVP4Rqgz.js → block-DnhzyZ1H.js} +29 -3
  4. package/dist/block.d.ts +56 -0
  5. package/dist/block.d.ts.map +1 -1
  6. package/dist/{bridge-4Eq-G73Z.js → bridge-Bss7Xq3D.js} +39 -31
  7. package/dist/core.js +1620 -333
  8. package/dist/css-runtime-CjZl0K48.js +755 -0
  9. package/dist/devtools/hook.d.ts +0 -5
  10. package/dist/devtools/hook.d.ts.map +1 -1
  11. package/dist/devtools/index.d.ts +0 -1
  12. package/dist/devtools/index.d.ts.map +1 -1
  13. package/dist/devtools/protocol.d.ts +15 -1
  14. package/dist/devtools/protocol.d.ts.map +1 -1
  15. package/dist/devtools.js +42 -9
  16. package/dist/editor/bridge.d.ts +7 -7
  17. package/dist/editor/bridge.d.ts.map +1 -1
  18. package/dist/editor/components.d.ts.map +1 -1
  19. package/dist/editor/main.d.ts +2 -1
  20. package/dist/editor/main.d.ts.map +1 -1
  21. package/dist/editor/messages.d.ts +13 -2
  22. package/dist/editor/messages.d.ts.map +1 -1
  23. package/dist/editor/overlays.d.ts +14 -0
  24. package/dist/editor/overlays.d.ts.map +1 -0
  25. package/dist/editor/overlays.test.d.ts +2 -0
  26. package/dist/editor/overlays.test.d.ts.map +1 -0
  27. package/dist/editor.js +47 -33
  28. package/dist/{gridstack-adapter-BZWybRw1.js → gridstack-adapter-C1Q8gbsH.js} +2 -2
  29. package/dist/main.d.ts +3 -1
  30. package/dist/main.d.ts.map +1 -1
  31. package/dist/{morph-DHn3ol8M.js → morph-LwttdRML.js} +1 -1
  32. package/dist/overlay-wrapper.d.ts +69 -0
  33. package/dist/overlay-wrapper.d.ts.map +1 -0
  34. package/dist/overlay-wrapper.test.d.ts +2 -0
  35. package/dist/overlay-wrapper.test.d.ts.map +1 -0
  36. package/dist/overlays/OverlayService.d.ts +34 -0
  37. package/dist/overlays/OverlayService.d.ts.map +1 -0
  38. package/dist/overlays/OverlayService.test.d.ts +2 -0
  39. package/dist/overlays/OverlayService.test.d.ts.map +1 -0
  40. package/dist/preact/block.d.ts.map +1 -1
  41. package/dist/preact/context.d.ts.map +1 -1
  42. package/dist/preact/context.test.d.ts +2 -0
  43. package/dist/preact/context.test.d.ts.map +1 -0
  44. package/dist/preact/signals.d.ts +19 -0
  45. package/dist/preact/signals.d.ts.map +1 -1
  46. package/dist/preact/useContextSubscription.test.d.ts +2 -0
  47. package/dist/preact/useContextSubscription.test.d.ts.map +1 -0
  48. package/dist/preact.js +33 -7
  49. package/dist/{project-gridstack-C2cSYRMx.js → project-gridstack-CRZ_7HoT.js} +1 -1
  50. package/dist/react/block.d.ts.map +1 -1
  51. package/dist/react/context.d.ts.map +1 -1
  52. package/dist/react/context.test.d.ts +2 -0
  53. package/dist/react/context.test.d.ts.map +1 -0
  54. package/dist/react/signals.d.ts +19 -0
  55. package/dist/react/signals.d.ts.map +1 -1
  56. package/dist/react/useContextSubscription.test.d.ts +2 -0
  57. package/dist/react/useContextSubscription.test.d.ts.map +1 -0
  58. package/dist/react.js +40 -8
  59. package/dist/services/customer/adapter.d.ts +14 -1
  60. package/dist/services/customer/adapter.d.ts.map +1 -1
  61. package/dist/services/customer/adapter.test.d.ts +2 -0
  62. package/dist/services/customer/adapter.test.d.ts.map +1 -0
  63. package/dist/services/customer/customerService.d.ts.map +1 -1
  64. package/dist/services/customer/customerService.test.d.ts +2 -0
  65. package/dist/services/customer/customerService.test.d.ts.map +1 -0
  66. package/dist/services/customer/index.d.ts +2 -2
  67. package/dist/services/customer/index.d.ts.map +1 -1
  68. package/dist/services/customer/types.d.ts +29 -0
  69. package/dist/services/customer/types.d.ts.map +1 -1
  70. package/dist/services/index.d.ts +1 -1
  71. package/dist/services/index.d.ts.map +1 -1
  72. package/dist/services/login/adapter.d.ts +0 -10
  73. package/dist/services/login/adapter.d.ts.map +1 -1
  74. package/dist/services/login/index.d.ts +3 -3
  75. package/dist/services/login/index.d.ts.map +1 -1
  76. package/dist/services/login/loginService.d.ts +13 -1
  77. package/dist/services/login/loginService.d.ts.map +1 -1
  78. package/dist/services/login/refreshLock.d.ts +28 -0
  79. package/dist/services/login/refreshLock.d.ts.map +1 -0
  80. package/dist/services/login/refreshLock.test.d.ts +2 -0
  81. package/dist/services/login/refreshLock.test.d.ts.map +1 -0
  82. package/dist/services/order/adapter.d.ts +17 -6
  83. package/dist/services/order/adapter.d.ts.map +1 -1
  84. package/dist/services/order/adapter.test.d.ts +2 -0
  85. package/dist/services/order/adapter.test.d.ts.map +1 -0
  86. package/dist/services/order/index.d.ts +3 -4
  87. package/dist/services/order/index.d.ts.map +1 -1
  88. package/dist/services/order/orderService.d.ts +2 -3
  89. package/dist/services/order/orderService.d.ts.map +1 -1
  90. package/dist/services/order/orderService.test.d.ts +2 -0
  91. package/dist/services/order/orderService.test.d.ts.map +1 -0
  92. package/dist/services/order/types.d.ts +103 -14
  93. package/dist/services/order/types.d.ts.map +1 -1
  94. package/dist/services/product/adapter.d.ts +42 -0
  95. package/dist/services/product/adapter.d.ts.map +1 -1
  96. package/dist/services/product/index.d.ts +1 -1
  97. package/dist/services/product/index.d.ts.map +1 -1
  98. package/dist/services/settings/types.d.ts +15 -0
  99. package/dist/services/settings/types.d.ts.map +1 -1
  100. package/dist/services/subscription/adapter.d.ts +48 -7
  101. package/dist/services/subscription/adapter.d.ts.map +1 -1
  102. package/dist/services/subscription/index.d.ts +3 -1
  103. package/dist/services/subscription/index.d.ts.map +1 -1
  104. package/dist/services/subscription/instantOrderErrors.d.ts +11 -0
  105. package/dist/services/subscription/instantOrderErrors.d.ts.map +1 -1
  106. package/dist/services/subscription/lineRemoval.d.ts +56 -0
  107. package/dist/services/subscription/lineRemoval.d.ts.map +1 -0
  108. package/dist/services/subscription/lineRemoval.test.d.ts +2 -0
  109. package/dist/services/subscription/lineRemoval.test.d.ts.map +1 -0
  110. package/dist/services/subscription/paymentInstrument.d.ts +119 -0
  111. package/dist/services/subscription/paymentInstrument.d.ts.map +1 -0
  112. package/dist/services/subscription/paymentInstrument.test.d.ts +2 -0
  113. package/dist/services/subscription/paymentInstrument.test.d.ts.map +1 -0
  114. package/dist/services/subscription/store.d.ts.map +1 -1
  115. package/dist/services/subscription/subscriptionService.d.ts.map +1 -1
  116. package/dist/services/subscription/types.d.ts +265 -34
  117. package/dist/services/subscription/types.d.ts.map +1 -1
  118. package/dist/shared/context.d.ts +10 -3
  119. package/dist/shared/context.d.ts.map +1 -1
  120. package/dist/shared/touchSignals.d.ts +17 -0
  121. package/dist/shared/touchSignals.d.ts.map +1 -0
  122. package/dist/shared/touchSignals.test.d.ts +2 -0
  123. package/dist/shared/touchSignals.test.d.ts.map +1 -0
  124. package/dist/theme-state.d.ts +2 -1
  125. package/dist/theme-state.d.ts.map +1 -1
  126. package/dist/theme-state.params.test.d.ts +2 -0
  127. package/dist/theme-state.params.test.d.ts.map +1 -0
  128. package/dist/theme-state.translations.test.d.ts +2 -0
  129. package/dist/theme-state.translations.test.d.ts.map +1 -0
  130. package/dist/vue/block.d.ts.map +1 -1
  131. package/dist/vue.js +16 -13
  132. package/dist/web-components/ExtensionRoot.d.ts +1 -0
  133. package/dist/web-components/ExtensionRoot.d.ts.map +1 -1
  134. package/dist/web-components-editor.js +6 -5
  135. package/dist/web-components-runtime.js +3 -2
  136. package/package.json +1 -1
  137. package/dist/css-runtime-DTiXcYSs.js +0 -1576
  138. package/dist/devtools/instrumentation.d.ts +0 -47
  139. package/dist/devtools/instrumentation.d.ts.map +0 -1
  140. package/dist/index-JSv6UH_o.js +0 -169
  141. package/dist/services/login/errors.d.ts +0 -21
  142. package/dist/services/login/errors.d.ts.map +0 -1
  143. package/dist/services/orders/adapter.d.ts +0 -10
  144. package/dist/services/orders/adapter.d.ts.map +0 -1
  145. package/dist/services/orders/index.d.ts +0 -4
  146. package/dist/services/orders/index.d.ts.map +0 -1
  147. package/dist/services/orders/ordersService.d.ts +0 -6
  148. package/dist/services/orders/ordersService.d.ts.map +0 -1
  149. package/dist/services/orders/ordersService.test.d.ts +0 -2
  150. package/dist/services/orders/ordersService.test.d.ts.map +0 -1
  151. package/dist/services/orders/types.d.ts +0 -60
  152. package/dist/services/orders/types.d.ts.map +0 -1
@@ -0,0 +1,34 @@
1
+ import { ReadonlySignal } from '@preact/signals-core';
2
+ import { BlockDefinition } from '../block';
3
+ import { ThemeState } from '../theme-state';
4
+ import { OverlayLayout } from '../overlay-wrapper';
5
+ import { OverlayRegistryEntry } from '../editor/overlays';
6
+ export type { OverlayRegistryEntry };
7
+ export interface OverlayState {
8
+ name: string;
9
+ layout: OverlayLayout;
10
+ canAbort: boolean;
11
+ }
12
+ export interface OverlayService {
13
+ /** Editor registry: the flat, global overlay list for the editor dropdown. */
14
+ getEditableOverlays(): Record<string, OverlayRegistryEntry>;
15
+ /** Open an overlay surface (full `overlay:<id>` name), optionally parameterized. */
16
+ open(name: string, params?: Record<string, unknown>): void;
17
+ /** Close the current overlay surface. */
18
+ close(): void;
19
+ /** The overlay currently showing, or null (incl. when a workflow overlay is up). */
20
+ current: ReadonlySignal<OverlayState | null>;
21
+ }
22
+ export declare const OverlayServiceContext: {
23
+ __context__: OverlayService;
24
+ };
25
+ /**
26
+ * Owns non-workflow overlay state over the shared `themeState.overlay` surface.
27
+ * Symmetric to `WorkflowService`; never invoked on the workflow path. `current`
28
+ * filters to `overlay:` roots so workflow roots (which share the surface) read
29
+ * as null.
30
+ */
31
+ export declare function createOverlayService(themeState: ThemeState, options?: {
32
+ getBlocks?: () => BlockDefinition[];
33
+ }): OverlayService;
34
+ //# sourceMappingURL=OverlayService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OverlayService.d.ts","sourceRoot":"","sources":["../../src/overlays/OverlayService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAErE,OAAO,EAAoB,KAAK,eAAe,EAAE,MAAM,UAAU,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,oBAAoB,CAAC;AAE5B,YAAY,EAAE,oBAAoB,EAAE,CAAC;AAIrC,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,aAAa,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,cAAc;IAC7B,8EAA8E;IAC9E,mBAAmB,IAAI,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;IAC5D,oFAAoF;IACpF,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC3D,yCAAyC;IACzC,KAAK,IAAI,IAAI,CAAC;IACd,oFAAoF;IACpF,OAAO,EAAE,cAAc,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;CAC9C;AAED,eAAO,MAAM,qBAAqB;;CACiB,CAAC;AAEpD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,UAAU,EACtB,OAAO,GAAE;IAAE,SAAS,CAAC,EAAE,MAAM,eAAe,EAAE,CAAA;CAAO,GACpD,cAAc,CAiChB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=OverlayService.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OverlayService.test.d.ts","sourceRoot":"","sources":["../../src/overlays/OverlayService.test.ts"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../../src/preact/block.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAqC,KAAK,aAAa,EAAE,MAAM,QAAQ,CAAC;AAE/E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AA0BjD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,GAAG,GAAG,EAC1C,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,GAC1B,CAAC,KAAK,EAAE,aAAa,KAAK,WAAW,CAuCvC;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,GAAG,GAAG,EAC5C,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,EAC3B,EAAE,UAAiB,EAAE,GAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAO,GACnD,CAAC,KAAK,EAAE,aAAa,KAAK,WAAW,CAoEvC"}
1
+ {"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../../src/preact/block.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAqC,KAAK,aAAa,EAAE,MAAM,QAAQ,CAAC;AAE/E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AA8BjD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,GAAG,GAAG,EAC1C,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,GAC1B,CAAC,KAAK,EAAE,aAAa,KAAK,WAAW,CAkDvC;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,GAAG,GAAG,EAC5C,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,EAC3B,EAAE,UAAiB,EAAE,GAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAO,GACnD,CAAC,KAAK,EAAE,aAAa,KAAK,WAAW,CAoEvC"}
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/preact/context.ts"],"names":[],"mappings":"AASA,OAAO,EAAK,KAAK,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AACnD,OAAO,EACL,WAAW,EAGX,cAAc,EACf,MAAM,aAAa,CAAC;AAErB,OAAO,EAAe,KAAK,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAI3D;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,iBAAiB,CAAA;CAAE;;;GAiB5E;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,cAAc,EACxD,OAAO,EAAE,CAAC,EACV,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,GACnB,IAAI,CAON;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,cAAc,EACjD,OAAO,EAAE,CAAC,GACT,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAOtB;AAED,wBAAgB,UAAU,IAAI,MAAM,GAAG,IAAI,CAU1C;AAED,YAAY,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC"}
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/preact/context.ts"],"names":[],"mappings":"AASA,OAAO,EAAK,KAAK,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AACnD,OAAO,EACL,WAAW,EAGX,cAAc,EACf,MAAM,aAAa,CAAC;AAErB,OAAO,EAAe,KAAK,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAI3D;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,iBAAiB,CAAA;CAAE;;;GAiB5E;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,cAAc,EACxD,OAAO,EAAE,CAAC,EACV,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,GACnB,IAAI,CAON;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,cAAc,EACjD,OAAO,EAAE,CAAC,GACT,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAUtB;AAED,wBAAgB,UAAU,IAAI,MAAM,GAAG,IAAI,CAU1C;AAED,YAAY,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=context.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.test.d.ts","sourceRoot":"","sources":["../../src/preact/context.test.ts"],"names":[],"mappings":""}
@@ -20,4 +20,23 @@ export declare function toState<T extends object>(signal: Signal<T> | (() => T))
20
20
  * @returns The current value of the signal
21
21
  */
22
22
  export declare function useSignal<T>(signal: Signal<T> | (() => T)): T;
23
+ /**
24
+ * Subscribes the component to every signal reachable from `target` (see
25
+ * `touchSignals`) and rerenders it on any change. This is the single,
26
+ * coarse-grained subscription behind `useContext` — it keeps method
27
+ * reads like `settings.get(...)` reactive without any hooks inside the
28
+ * wrapContext proxy. Only signals reachable from the context object are
29
+ * covered — objects returned by service methods (e.g. a SubscriptionList)
30
+ * carry their own signals and are not subscribed.
31
+ *
32
+ * The effect body runs once synchronously when wired inside useEffect. On
33
+ * the first wiring it bumps the version unconditionally — so a signal
34
+ * change that lands between mount render and subscription is never lost
35
+ * (at the cost of one extra post-mount render). Rewires caused by a
36
+ * `target` identity change are silent: the outgoing effect stays live until
37
+ * the synchronous swap, so an unstable target degrades to subscription
38
+ * churn instead of an infinite rerender loop. (A signal reachable only
39
+ * from the new target changing before the swap is not caught.)
40
+ */
41
+ export declare function useContextSubscription(target: unknown): void;
23
42
  //# sourceMappingURL=signals.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"signals.d.ts","sourceRoot":"","sources":["../../src/preact/signals.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAU,MAAM,EAAE,MAAM,aAAa,CAAC;AAI7C;;;;;GAKG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,MAAM,EACtC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAC5B,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC,CAkCzB;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CA8B7D"}
1
+ {"version":3,"file":"signals.d.ts","sourceRoot":"","sources":["../../src/preact/signals.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAU,MAAM,EAAE,MAAM,aAAa,CAAC;AAK7C;;;;;GAKG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,MAAM,EACtC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAC5B,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC,CAkCzB;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CA8B7D;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAiB5D"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=useContextSubscription.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useContextSubscription.test.d.ts","sourceRoot":"","sources":["../../src/preact/useContextSubscription.test.ts"],"names":[],"mappings":""}
package/dist/preact.js CHANGED
@@ -3,11 +3,12 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
4
  import { effect, injectContext, provideContext, createCeRenderer, attachEmptyTracking } from "@juo/blocks";
5
5
  import { useState, useRef, useEffect, useContext as useContext$1, useMemo } from "preact/hooks";
6
- import { g as getSignalValue, s as setSignalValue, w as wrapContext, c as createSlotChildren } from "./block-dVP4Rqgz.js";
7
- import { t } from "./block-dVP4Rqgz.js";
6
+ import { g as getSignalValue, t as touchSignals, s as setSignalValue, w as wrapContext, c as createSlotChildren } from "./block-DnhzyZ1H.js";
7
+ import { a } from "./block-DnhzyZ1H.js";
8
8
  import { createContext, h, render } from "preact";
9
- import { g as getInstrumentation } from "./index-JSv6UH_o.js";
10
- import { a as createEditorBridge } from "./bridge-4Eq-G73Z.js";
9
+ import { getHook } from "./devtools.js";
10
+ import { _ as __recordDevtoolsPropSetter, a as applyDevtoolsPropOverride } from "./block-BjJztStr.js";
11
+ import { a as createEditorBridge } from "./bridge-Bss7Xq3D.js";
11
12
  function toState(signal) {
12
13
  const [value, setValue] = useState(() => getSignalValue(signal));
13
14
  const disposeRef = useRef(null);
@@ -55,6 +56,23 @@ function useSignal(signal) {
55
56
  }, [signal]);
56
57
  return value;
57
58
  }
59
+ function useContextSubscription(target) {
60
+ const [, setVersion] = useState(0);
61
+ const everWiredRef = useRef(false);
62
+ useEffect(() => {
63
+ const isRewire = everWiredRef.current;
64
+ everWiredRef.current = true;
65
+ let initialRun = true;
66
+ return effect(() => {
67
+ touchSignals(target);
68
+ if (initialRun) {
69
+ initialRun = false;
70
+ if (isRewire) return;
71
+ }
72
+ setVersion((v) => v + 1);
73
+ });
74
+ }, [target]);
75
+ }
58
76
  const ContextProviderContext = createContext(null);
59
77
  function ContextProvider({ children }) {
60
78
  const [rootElement, setRootElement] = useState(null);
@@ -84,7 +102,9 @@ function useContext(context) {
84
102
  if (root == null) {
85
103
  throw new Error("ContextProvider not available");
86
104
  }
87
- return wrapContext(injectContext(root, context), toState);
105
+ const ctx = injectContext(root, context);
106
+ useContextSubscription(ctx);
107
+ return wrapContext(ctx);
88
108
  }
89
109
  function useBlockId() {
90
110
  const root = useContext$1(ContextProviderContext);
@@ -134,7 +154,12 @@ function createPreactRenderer(component) {
134
154
  wrapper
135
155
  );
136
156
  };
137
- renderTree(getInstrumentation().bindLiveProps(block, renderTree));
157
+ if (getHook()) {
158
+ __recordDevtoolsPropSetter(block.id, () => {
159
+ renderTree(applyDevtoolsPropOverride(block.id, block.props));
160
+ });
161
+ }
162
+ renderTree(applyDevtoolsPropOverride(block.id, block.props));
138
163
  attachEmptyTracking(wrapper);
139
164
  return wrapper;
140
165
  };
@@ -226,11 +251,12 @@ export {
226
251
  ContextProvider,
227
252
  createPreactCeRenderer,
228
253
  createPreactRenderer,
229
- t as toSignal,
254
+ a as toSignal,
230
255
  toState,
231
256
  useBlockId,
232
257
  useBridge,
233
258
  useContext,
259
+ useContextSubscription,
234
260
  useProvideContext,
235
261
  useSignal
236
262
  };
@@ -1,4 +1,4 @@
1
- import { r as resolveLayout } from "./css-runtime-DTiXcYSs.js";
1
+ import { r as resolveLayout } from "./css-runtime-CjZl0K48.js";
2
2
  const MIN_BLOCK_ROWS = 2;
3
3
  const MIN_BLOCK_PX = 200;
4
4
  function resolveActiveBreakpoint(doc, containerWidthPx) {
@@ -1 +1 @@
1
- {"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../../src/react/block.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAwBjD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,GAAG,GAAG,EACzC,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,GAChC,CAAC,KAAK,EAAE,aAAa,KAAK,WAAW,CAuCvC;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,GAAG,GAAG,EAC3C,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,EACjC,EAAE,UAAiB,EAAE,GAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAO,GACnD,CAAC,KAAK,EAAE,aAAa,KAAK,WAAW,CAyEvC"}
1
+ {"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../../src/react/block.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AA4BjD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,GAAG,GAAG,EACzC,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,GAChC,CAAC,KAAK,EAAE,aAAa,KAAK,WAAW,CAkDvC;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,GAAG,GAAG,EAC3C,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,EACjC,EAAE,UAAiB,EAAE,GAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAO,GACnD,CAAC,KAAK,EAAE,aAAa,KAAK,WAAW,CAyEvC"}
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/react/context.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,EAKZ,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,OAAO,EACL,WAAW,EAGX,cAAc,EACf,MAAM,aAAa,CAAC;AAErB,OAAO,EAAe,KAAK,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAI3D;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,EAAE,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{};
2
+ //# sourceMappingURL=context.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.test.d.ts","sourceRoot":"","sources":["../../src/react/context.test.ts"],"names":[],"mappings":""}
@@ -20,4 +20,23 @@ export declare function toState<T extends object>(signal: Signal<T> | (() => T))
20
20
  * @returns The current value of the signal
21
21
  */
22
22
  export declare function useSignal<T>(signal: Signal<T> | (() => T)): T;
23
+ /**
24
+ * Subscribes the component to every signal reachable from `target` (see
25
+ * `touchSignals`) and rerenders it on any change. This is the single,
26
+ * coarse-grained subscription behind `useContext` — it keeps method
27
+ * reads like `settings.get(...)` reactive without any hooks inside the
28
+ * wrapContext proxy. Only signals reachable from the context object are
29
+ * covered — objects returned by service methods (e.g. a SubscriptionList)
30
+ * carry their own signals and are not subscribed.
31
+ *
32
+ * The effect body runs once synchronously when the store subscription is
33
+ * wired. On the first wiring it bumps the version unconditionally — so a
34
+ * signal change that lands between mount render and subscription is never
35
+ * lost (at the cost of one extra post-mount render). Rewires caused by a
36
+ * `target` identity change are silent: the outgoing effect stays live until
37
+ * the synchronous swap, so an unstable target degrades to subscription
38
+ * churn instead of an infinite rerender loop. (A signal reachable only
39
+ * from the new target changing before the swap is not caught.)
40
+ */
41
+ export declare function useContextSubscription(target: unknown): void;
23
42
  //# sourceMappingURL=signals.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"signals.d.ts","sourceRoot":"","sources":["../../src/react/signals.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAU,MAAM,EAAE,MAAM,aAAa,CAAC;AAI7C;;;;;GAKG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,MAAM,EACtC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAC5B,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC,CAkBzB;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAY7D"}
1
+ {"version":3,"file":"signals.d.ts","sourceRoot":"","sources":["../../src/react/signals.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAU,MAAM,EAAE,MAAM,aAAa,CAAC;AAK7C;;;;;GAKG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,MAAM,EACtC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAC5B,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC,CAkBzB;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAY7D;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAyB5D"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=useContextSubscription.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useContextSubscription.test.d.ts","sourceRoot":"","sources":["../../src/react/useContextSubscription.test.ts"],"names":[],"mappings":""}
package/dist/react.js CHANGED
@@ -2,12 +2,13 @@ var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
4
  import { effect, injectContext, provideContext, createCeRenderer, attachEmptyTracking } from "@juo/blocks";
5
- import React, { useSyncExternalStore, createContext, useState, useContext as useContext$1, useMemo, useRef, useEffect } from "react";
6
- import { g as getSignalValue, s as setSignalValue, w as wrapContext, c as createSlotChildren } from "./block-dVP4Rqgz.js";
7
- import { t } from "./block-dVP4Rqgz.js";
5
+ import React, { useSyncExternalStore, useRef, useCallback, createContext, useState, useContext as useContext$1, useMemo, useEffect } from "react";
6
+ import { t as touchSignals, g as getSignalValue, s as setSignalValue, w as wrapContext, c as createSlotChildren } from "./block-DnhzyZ1H.js";
7
+ import { a } from "./block-DnhzyZ1H.js";
8
8
  import { createRoot } from "react-dom/client";
9
- import { g as getInstrumentation } from "./index-JSv6UH_o.js";
10
- import { a as createEditorBridge } from "./bridge-4Eq-G73Z.js";
9
+ import { getHook } from "./devtools.js";
10
+ import { _ as __recordDevtoolsPropSetter, a as applyDevtoolsPropOverride } from "./block-BjJztStr.js";
11
+ import { a as createEditorBridge } from "./bridge-Bss7Xq3D.js";
11
12
  function toState(signal) {
12
13
  const subscribe = (callback) => {
13
14
  const dispose = effect(() => {
@@ -34,6 +35,29 @@ function useSignal(signal) {
34
35
  const getSnapshot = () => getSignalValue(signal);
35
36
  return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
36
37
  }
38
+ function useContextSubscription(target) {
39
+ const versionRef = useRef(0);
40
+ const everWiredRef = useRef(false);
41
+ const subscribe = useCallback(
42
+ (notify) => {
43
+ const isRewire = everWiredRef.current;
44
+ everWiredRef.current = true;
45
+ let initialRun = true;
46
+ return effect(() => {
47
+ touchSignals(target);
48
+ if (initialRun) {
49
+ initialRun = false;
50
+ if (isRewire) return;
51
+ }
52
+ versionRef.current++;
53
+ notify();
54
+ });
55
+ },
56
+ [target]
57
+ );
58
+ const getVersion = () => versionRef.current;
59
+ useSyncExternalStore(subscribe, getVersion, getVersion);
60
+ }
37
61
  const ContextProviderContext = createContext(null);
38
62
  function ContextProvider({ children }) {
39
63
  const [rootElement, setRootElement] = useState(null);
@@ -68,7 +92,9 @@ function useContext(context) {
68
92
  if (root == null) {
69
93
  throw new Error("ContextProvider not available");
70
94
  }
71
- return wrapContext(injectContext(root, context), toState);
95
+ const ctx = injectContext(root, context);
96
+ useContextSubscription(ctx);
97
+ return wrapContext(ctx);
72
98
  }
73
99
  function useBlockId() {
74
100
  const root = useContext$1(ContextProviderContext);
@@ -116,7 +142,12 @@ function createReactRenderer(component) {
116
142
  })
117
143
  );
118
144
  };
119
- renderTree(getInstrumentation().bindLiveProps(block, renderTree));
145
+ if (getHook()) {
146
+ __recordDevtoolsPropSetter(block.id, () => {
147
+ renderTree(applyDevtoolsPropOverride(block.id, block.props));
148
+ });
149
+ }
150
+ renderTree(applyDevtoolsPropOverride(block.id, block.props));
120
151
  attachEmptyTracking(wrapper);
121
152
  return wrapper;
122
153
  };
@@ -201,11 +232,12 @@ export {
201
232
  ContextProvider,
202
233
  createReactCeRenderer,
203
234
  createReactRenderer,
204
- t as toSignal,
235
+ a as toSignal,
205
236
  toState,
206
237
  useBlockId,
207
238
  useBridge,
208
239
  useContext,
240
+ useContextSubscription,
209
241
  useProvideContext,
210
242
  useSignal
211
243
  };
@@ -1,8 +1,21 @@
1
- import { Customer } from './types';
1
+ import { Customer, CreatePaymentMethodParams, CreatePaymentMethodOutcome } from './types';
2
2
  import { ApiFetcher, Result } from '../../utils';
3
3
  export interface CustomerAdapter {
4
4
  getCurrent(): Promise<Result<Customer | null>>;
5
+ createPaymentMethod(params: CreatePaymentMethodParams): Promise<Result<CreatePaymentMethodOutcome>>;
6
+ updateAttributes(attributes: Record<string, string>): Promise<Result<Customer>>;
5
7
  }
6
8
  export declare function createMockCustomerAdapter(): CustomerAdapter;
9
+ export type V1CustomerBody = {
10
+ id: string;
11
+ displayName: string;
12
+ email?: string | null;
13
+ customAttributes: {
14
+ key: string;
15
+ value: string;
16
+ }[];
17
+ };
18
+ /** Maps a `GET/PATCH /customer/v1/customer` response body to the blocks `Customer`. */
19
+ export declare function fromV1Customer(body: V1CustomerBody): Customer;
7
20
  export declare function createApiCustomerAdapter(fetcher: ApiFetcher): CustomerAdapter;
8
21
  //# sourceMappingURL=adapter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../src/services/customer/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAEtD,MAAM,WAAW,eAAe;IAC9B,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC;CAChD;AAED,wBAAgB,yBAAyB,IAAI,eAAe,CAO3D;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,UAAU,GAAG,eAAe,CAyB7E"}
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../src/services/customer/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,yBAAyB,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAC/F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGtD,MAAM,WAAW,eAAe;IAC9B,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC;IAC/C,mBAAmB,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,MAAM,CAAC,0BAA0B,CAAC,CAAC,CAAC;IACpG,gBAAgB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;CACjF;AAED,wBAAgB,yBAAyB,IAAI,eAAe,CAkC3D;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,gBAAgB,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CACpD,CAAC;AAEF,uFAAuF;AACvF,wBAAgB,cAAc,CAAC,IAAI,EAAE,cAAc,GAAG,QAAQ,CAS7D;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,UAAU,GAAG,eAAe,CAkE7E"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=adapter.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.test.d.ts","sourceRoot":"","sources":["../../../src/services/customer/adapter.test.ts"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"customerService.d.ts","sourceRoot":"","sources":["../../../src/services/customer/customerService.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,KAAK,EAAY,eAAe,EAAE,MAAM,SAAS,CAAC;AAEzD,KAAK,4BAA4B,GAAG;IAClC,OAAO,EAAE,eAAe,CAAC;IACzB;;;;OAIG;IACH,mBAAmB,EAAE,MAAM,MAAM,CAAC;CACnC,CAAC;AAEF,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,4BAA4B,GACpC,eAAe,CAajB;AAED,eAAO,MAAM,sBAAsB;;CACkB,CAAC"}
1
+ {"version":3,"file":"customerService.d.ts","sourceRoot":"","sources":["../../../src/services/customer/customerService.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,KAAK,EAAY,eAAe,EAAE,MAAM,SAAS,CAAC;AAEzD,KAAK,4BAA4B,GAAG;IAClC,OAAO,EAAE,eAAe,CAAC;IACzB;;;;OAIG;IACH,mBAAmB,EAAE,MAAM,MAAM,CAAC;CACnC,CAAC;AAEF,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,4BAA4B,GACpC,eAAe,CA0BjB;AAED,eAAO,MAAM,sBAAsB;;CACkB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=customerService.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customerService.test.d.ts","sourceRoot":"","sources":["../../../src/services/customer/customerService.test.ts"],"names":[],"mappings":""}
@@ -1,4 +1,4 @@
1
- export { type CustomerService, type Customer } from './types';
1
+ export { type CustomerService, type Customer, type CreatePaymentMethodParams, type CreatePaymentMethodOutcome } from './types';
2
2
  export { createCustomerService, CustomerServiceContext, } from './customerService';
3
- export { type CustomerAdapter, createMockCustomerAdapter, createApiCustomerAdapter, } from './adapter';
3
+ export { type CustomerAdapter, type V1CustomerBody, createMockCustomerAdapter, createApiCustomerAdapter, fromV1Customer, } from './adapter';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/customer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,KAAK,eAAe,EACpB,yBAAyB,EACzB,wBAAwB,GACzB,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/customer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,QAAQ,EAAE,KAAK,yBAAyB,EAAE,KAAK,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAC/H,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,yBAAyB,EACzB,wBAAwB,EACxB,cAAc,GACf,MAAM,WAAW,CAAC"}
@@ -1,15 +1,44 @@
1
1
  import { Signal } from '@preact/signals-core';
2
2
  import { Result } from '../../utils';
3
+ import { SubscriptionPaymentInstrument } from '../subscription/paymentInstrument';
3
4
  /** Signed-in customer identity for blocks such as Header (name / email display). */
4
5
  export type Customer = {
5
6
  id: string;
6
7
  name: string;
7
8
  email?: string;
8
9
  metadata?: Record<string, unknown>;
10
+ /** Customer-visible custom attributes (e.g. `date_of_birth`), keyed by attribute key. */
11
+ attributes?: Record<string, string>;
12
+ };
13
+ export type CreatePaymentMethodParams = {
14
+ provider: "shopify";
15
+ } | {
16
+ provider: "mollie" | "stripe";
17
+ returnUrl: string;
18
+ };
19
+ export type CreatePaymentMethodOutcome = {
20
+ kind: "email_sent";
21
+ paymentMethodId: string;
22
+ instrument?: SubscriptionPaymentInstrument;
23
+ } | {
24
+ kind: "redirect";
25
+ redirectUrl: string;
9
26
  };
10
27
  export type CustomerService = {
11
28
  current: Signal<Customer | null>;
12
29
  getCurrent(): Promise<Result<Customer | null>>;
30
+ createPaymentMethod(params: CreatePaymentMethodParams): Promise<Result<CreatePaymentMethodOutcome>>;
31
+ /**
32
+ * Sets the given customer-visible custom attributes, merged with the attributes already known
33
+ * on `current` — other blocks' attributes are preserved, so no block needs to know about every
34
+ * other attribute key in use. Internal (`_`-prefixed) and reserved keys are preserved
35
+ * server-side and rejected with a Failure when written. Updates `current` with the returned
36
+ * customer on success.
37
+ *
38
+ * Note: the underlying adapter/API call REPLACES the entire visible attribute set (there is no
39
+ * per-key clear); this merge happens in `createCustomerService`, not in the adapter.
40
+ */
41
+ updateAttributes(attributes: Record<string, string>): Promise<Result<Customer>>;
13
42
  accountOrdersUrl: Signal<string>;
14
43
  };
15
44
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/services/customer/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO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0B,GAClC;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,eAAe,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,6BAA6B,CAAA;CAAE,GAC3F;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9C,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;IACjC,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC;IAC/C,mBAAmB,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,MAAM,CAAC,0BAA0B,CAAC,CAAC,CAAC;IACpG;;;;;;;;;OASG;IACH,gBAAgB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;IAChF,gBAAgB,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;CAClC,CAAC"}
@@ -1,6 +1,6 @@
1
1
  export * from './customer';
2
2
  export * from './login';
3
- export * from './orders';
3
+ export * from './order';
4
4
  export * from './product';
5
5
  export * from './router';
6
6
  export * from './schedules';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC"}
@@ -1,5 +1,4 @@
1
1
  import { ApiFetcher, Result } from '../../utils';
2
- import { AuthenticationError } from './errors';
3
2
  export type AuthTokens = {
4
3
  access_token: string;
5
4
  refresh_token: string;
@@ -24,15 +23,6 @@ export interface LoginAdapter {
24
23
  shop: string;
25
24
  }): string;
26
25
  }
27
- /**
28
- * Turn a `403` body from the auth endpoints into an `AuthenticationError`, or
29
- * `undefined` when the body says nothing we recognise.
30
- *
31
- * Every failure is identified by the backend's `code`. Nothing here reads the
32
- * auth provider's `error_description` prose: that sentence is a vendor detail,
33
- * and translating it to a code is the backend's job.
34
- */
35
- export declare function authenticationErrorFromBody(data: unknown): AuthenticationError | undefined;
36
26
  export declare function createMockLoginAdapter(opts?: {
37
27
  appUrl?: string;
38
28
  }): LoginAdapter;
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../src/services/login/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAA6B,MAAM,UAAU,CAAC;AAE1E,MAAM,MAAM,UAAU,GAAG;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,WAAW,YAAY;IAC3B,iBAAiB,CAAC,MAAM,EAAE;QACxB,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;KACd,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IAE1B,YAAY,CACV,MAAM,EACF;QAAE,KAAK,EAAE,MAAM,CAAC;QA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KAAE,GAC/B;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAChB;QAAE,YAAY,EAAE,MAAM,CAAA;KAAE,GAC3B,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;IAE/B,eAAe,CAAC,MAAM,EAAE;QACtB,UAAU,EAAE,UAAU,GAAG,eAAe,CAAC;QACzC,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;KACd,GAAG,MAAM,CAAC;CACZ;AAED,wBAAgB,sBAAsB,CACpC,IAAI,GAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAO,GAC7B,YAAY,CAwBd;AAED,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,UAAU,EACnB,IAAI,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC3C,YAAY,CAoId"}
@@ -20,7 +20,7 @@ type LoginService = {
20
20
  export declare const LoginServiceContext: {
21
21
  __context__: LoginService;
22
22
  };
23
- export { loginService, createLoginService, type LoginServiceDependencies, type ErrorFormatter, } from './loginService';
24
- export { AuthenticationError, AuthenticationErrorReason } from './errors';
25
- export { type LoginAdapter, type AuthTokens, authenticationErrorFromBody, createApiLoginAdapter, createMockLoginAdapter, } from './adapter';
23
+ export { loginService, createLoginService, type LoginServiceDependencies, type ErrorFormatter, AuthenticationError, AuthenticationErrorReason, } from './loginService';
24
+ export { REFRESH_LOCK_NAME, withRefreshLock } from './refreshLock';
25
+ export { type LoginAdapter, type AuthTokens, createApiLoginAdapter, createMockLoginAdapter, } from './adapter';
26
26
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/login/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAE,MAAM,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;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,cAAc,EACnB,mBAAmB,EACnB,yBAAyB,GAC1B,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEnE,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,WAAW,CAAC"}
@@ -1,6 +1,18 @@
1
1
  import { Signal } from '@preact/signals-core';
2
2
  import { LoginAdapter } from './adapter';
3
- import { AuthenticationError, AuthenticationErrorReason } from './errors';
3
+ export declare enum AuthenticationErrorReason {
4
+ Expired = "expired",
5
+ IncorrectCode = "wrong-code",
6
+ TooManyTries = "too-many-tries",
7
+ NoEmail = "no-email",
8
+ Unknown = "unknown",
9
+ Missing = "missing"
10
+ }
11
+ export declare class AuthenticationError extends Error {
12
+ reason: AuthenticationErrorReason;
13
+ data: Record<string, unknown>;
14
+ constructor(reason: AuthenticationErrorReason, data?: Record<string, unknown>);
15
+ }
4
16
  interface RouterService {
5
17
  push(options: {
6
18
  path: string;
@@ -1 +1 @@
1
- {"version":3,"file":"loginService.d.ts","sourceRoot":"","sources":["../../../src/services/login/loginService.ts"],"names":[],"mappings":"AAEA,OAAO,EAA4B,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAKxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAE9C,OAAO,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAE1E,UAAU,aAAa;IACrB,IAAI,CAAC,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,GAAG,IAAI,CAAC;IACtE,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED,UAAU,WAAW;IACnB,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IAChC,MAAM,EAAE,MAAM,CAAC;CAChB;AA0BD,MAAM,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,OAAO,GAAG,mBAAmB,KAAK;IACrE,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,yBAAyB,CAAC;CACpC,CAAC;AAEF,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,YAAY,CAAC;IACtB,WAAW,EAAE,cAAc,CAAC;IAC5B,MAAM,EAAE,aAAa,CAAC;IACtB,IAAI,EAAE,WAAW,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACtC;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE;IACjC,WAAW,EAAE,cAAc,CAAC;IAC5B,SAAS,EAAE,MAAM,MAAM,CAAC;IACxB,MAAM,EAAE,aAAa,CAAC;IACtB,IAAI,EAAE;QACJ,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,cAAc,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACtC;;;;;;;;;;;;;;;;EAmBA;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,wBAAwB;;;;;;;;;;;;;;;;EAsNhE"}
1
+ {"version":3,"file":"loginService.d.ts","sourceRoot":"","sources":["../../../src/services/login/loginService.ts"],"names":[],"mappings":"AAEA,OAAO,EAA4B,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAKxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAK9C,oBAAY,yBAAyB;IACnC,OAAO,YAAY;IACnB,aAAa,eAAe;IAC5B,YAAY,mBAAmB;IAC/B,OAAO,aAAa;IACpB,OAAO,YAAY;IACnB,OAAO,YAAY;CACpB;AAED,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,MAAM,EAAE,yBAAyB,CAAC;IAClC,I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BAAkB,CAAC,IAAI,EAAE,wBAAwB;;;;;;;;;;;;;;;;EAoShE"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * The customer refresh token lives in `localStorage`, so every tab on the
3
+ * origin shares a single Auth0 refresh chain — and that chain rotates: Auth0
4
+ * consumes a refresh token on use and rejects it forever after with
5
+ * `invalid_grant`, which the portal reads as a dead session and signs the
6
+ * customer out of every tab. Two tabs refreshing in the same moment is enough
7
+ * to trigger it.
8
+ *
9
+ * Web Locks serialise the refresh across tabs. Everything that rotates the
10
+ * chain has to hold this lock, which includes the deprecated portal auth plugin
11
+ * (`components/customer-portal/src/plugins/auth.ts`) — it is a second,
12
+ * independent refresher living in the same tab as the login service, on the
13
+ * same stored token. The lock is keyed by name, so holding it is what couples
14
+ * the two; they must never diverge on `REFRESH_LOCK_NAME`.
15
+ *
16
+ * Holding the lock is necessary but not sufficient. A tab that waited on it may
17
+ * have watched another tab rotate the chain, so the holder must re-read the
18
+ * stored token instead of trusting the copy it held when it started.
19
+ */
20
+ export declare const REFRESH_LOCK_NAME = "juo:auth:refresh";
21
+ /**
22
+ * How long to wait for another tab before giving up on the lock. A refresh that
23
+ * takes longer than this is already broken; blocking every other tab's session
24
+ * behind it would turn one wedged tab into a portal-wide outage.
25
+ */
26
+ export declare const LOCK_WAIT_TIMEOUT_MS = 10000;
27
+ export declare function withRefreshLock<T>(run: () => Promise<T>): Promise<T>;
28
+ //# sourceMappingURL=refreshLock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refreshLock.d.ts","sourceRoot":"","sources":["../../../src/services/login/refreshLock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,iBAAiB,qBAAqB,CAAC;AAEpD;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,QAAS,CAAC;AAgB3C,wBAAgB,eAAe,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CA6BpE"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=refreshLock.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refreshLock.test.d.ts","sourceRoot":"","sources":["../../../src/services/login/refreshLock.test.ts"],"names":[],"mappings":""}