@almadar/ui 4.30.0 → 4.31.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.
@@ -49005,7 +49005,7 @@ init_logger();
49005
49005
 
49006
49006
  // runtime/createClientEffectHandlers.ts
49007
49007
  function createClientEffectHandlers(options) {
49008
- const { eventBus, slotSetter, navigate, notify } = options;
49008
+ const { eventBus, slotSetter, navigate, notify, callService } = options;
49009
49009
  return {
49010
49010
  emit: (event, payload) => {
49011
49011
  const prefixedEvent = event.startsWith("UI:") ? event : `UI:${event}`;
@@ -49017,9 +49017,24 @@ function createClientEffectHandlers(options) {
49017
49017
  set: () => {
49018
49018
  console.warn("[ClientEffectHandlers] set is server-side only, ignored on client");
49019
49019
  },
49020
- callService: async () => {
49021
- console.warn("[ClientEffectHandlers] callService is server-side only, ignored on client");
49022
- return {};
49020
+ callService: async (service, action, params) => {
49021
+ if (callService) return callService(service, action, params);
49022
+ const mockId = `mock_${service}_${action}_${Math.random().toString(36).slice(2, 10)}`;
49023
+ const paramsEcho = {};
49024
+ if (params) {
49025
+ for (const [k, v] of Object.entries(params)) {
49026
+ if (v !== void 0 && (typeof v === "string" || typeof v === "number" || typeof v === "boolean" || v === null || v instanceof Date)) {
49027
+ paramsEcho[k] = v;
49028
+ }
49029
+ }
49030
+ }
49031
+ return {
49032
+ id: mockId,
49033
+ clientSecret: `secret_${mockId}`,
49034
+ success: true,
49035
+ status: "succeeded",
49036
+ ...paramsEcho
49037
+ };
49023
49038
  },
49024
49039
  renderUI: (slot, pattern, props) => {
49025
49040
  if (pattern === null) {
@@ -49402,7 +49417,8 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
49402
49417
  }
49403
49418
  },
49404
49419
  navigate: optionsRef.current?.navigate,
49405
- notify: optionsRef.current?.notify
49420
+ notify: optionsRef.current?.notify,
49421
+ callService: optionsRef.current?.callService
49406
49422
  });
49407
49423
  const persistence = optionsRef.current?.persistence;
49408
49424
  let handlers = clientHandlers;
package/dist/avl/index.js CHANGED
@@ -48959,7 +48959,7 @@ init_logger();
48959
48959
 
48960
48960
  // runtime/createClientEffectHandlers.ts
48961
48961
  function createClientEffectHandlers(options) {
48962
- const { eventBus, slotSetter, navigate, notify } = options;
48962
+ const { eventBus, slotSetter, navigate, notify, callService } = options;
48963
48963
  return {
48964
48964
  emit: (event, payload) => {
48965
48965
  const prefixedEvent = event.startsWith("UI:") ? event : `UI:${event}`;
@@ -48971,9 +48971,24 @@ function createClientEffectHandlers(options) {
48971
48971
  set: () => {
48972
48972
  console.warn("[ClientEffectHandlers] set is server-side only, ignored on client");
48973
48973
  },
48974
- callService: async () => {
48975
- console.warn("[ClientEffectHandlers] callService is server-side only, ignored on client");
48976
- return {};
48974
+ callService: async (service, action, params) => {
48975
+ if (callService) return callService(service, action, params);
48976
+ const mockId = `mock_${service}_${action}_${Math.random().toString(36).slice(2, 10)}`;
48977
+ const paramsEcho = {};
48978
+ if (params) {
48979
+ for (const [k, v] of Object.entries(params)) {
48980
+ if (v !== void 0 && (typeof v === "string" || typeof v === "number" || typeof v === "boolean" || v === null || v instanceof Date)) {
48981
+ paramsEcho[k] = v;
48982
+ }
48983
+ }
48984
+ }
48985
+ return {
48986
+ id: mockId,
48987
+ clientSecret: `secret_${mockId}`,
48988
+ success: true,
48989
+ status: "succeeded",
48990
+ ...paramsEcho
48991
+ };
48977
48992
  },
48978
48993
  renderUI: (slot, pattern, props) => {
48979
48994
  if (pattern === null) {
@@ -49356,7 +49371,8 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
49356
49371
  }
49357
49372
  },
49358
49373
  navigate: optionsRef.current?.navigate,
49359
- notify: optionsRef.current?.notify
49374
+ notify: optionsRef.current?.notify,
49375
+ callService: optionsRef.current?.callService
49360
49376
  });
49361
49377
  const persistence = optionsRef.current?.persistence;
49362
49378
  let handlers = clientHandlers;
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * @packageDocumentation
7
7
  */
8
- import type { EventPayload } from '@almadar/core';
8
+ import type { EventPayload, ServiceParams } from '@almadar/core';
9
9
  import type { EffectHandlers } from '@almadar/runtime';
10
10
  export interface ClientEventBus {
11
11
  emit: (type: string, payload?: EventPayload) => void;
@@ -19,5 +19,13 @@ export interface CreateClientEffectHandlersOptions {
19
19
  slotSetter: SlotSetter;
20
20
  navigate?: (path: string, params?: Record<string, unknown>) => void;
21
21
  notify?: (message: string, type: 'success' | 'error' | 'warning' | 'info') => void;
22
+ /**
23
+ * Optional consumer-supplied call-service handler. When set, it runs
24
+ * instead of the default mock fallback — use to wire the playground
25
+ * to real backends. When omitted, `callService` returns a synthetic
26
+ * mock result so service-atom chains advance end-to-end in offline /
27
+ * standalone-preview mode (see OrbitalServerRuntime's mock parallel).
28
+ */
29
+ callService?: (service: string, action: string, params?: ServiceParams) => Promise<unknown>;
22
30
  }
23
31
  export declare function createClientEffectHandlers(options: CreateClientEffectHandlersOptions): EffectHandlers;
@@ -35397,7 +35397,7 @@ init_logger();
35397
35397
 
35398
35398
  // runtime/createClientEffectHandlers.ts
35399
35399
  function createClientEffectHandlers(options) {
35400
- const { eventBus, slotSetter, navigate, notify } = options;
35400
+ const { eventBus, slotSetter, navigate, notify, callService } = options;
35401
35401
  return {
35402
35402
  emit: (event, payload) => {
35403
35403
  const prefixedEvent = event.startsWith("UI:") ? event : `UI:${event}`;
@@ -35409,9 +35409,24 @@ function createClientEffectHandlers(options) {
35409
35409
  set: () => {
35410
35410
  console.warn("[ClientEffectHandlers] set is server-side only, ignored on client");
35411
35411
  },
35412
- callService: async () => {
35413
- console.warn("[ClientEffectHandlers] callService is server-side only, ignored on client");
35414
- return {};
35412
+ callService: async (service, action, params) => {
35413
+ if (callService) return callService(service, action, params);
35414
+ const mockId = `mock_${service}_${action}_${Math.random().toString(36).slice(2, 10)}`;
35415
+ const paramsEcho = {};
35416
+ if (params) {
35417
+ for (const [k, v] of Object.entries(params)) {
35418
+ if (v !== void 0 && (typeof v === "string" || typeof v === "number" || typeof v === "boolean" || v === null || v instanceof Date)) {
35419
+ paramsEcho[k] = v;
35420
+ }
35421
+ }
35422
+ }
35423
+ return {
35424
+ id: mockId,
35425
+ clientSecret: `secret_${mockId}`,
35426
+ success: true,
35427
+ status: "succeeded",
35428
+ ...paramsEcho
35429
+ };
35415
35430
  },
35416
35431
  renderUI: (slot, pattern, props) => {
35417
35432
  if (pattern === null) {
@@ -35905,7 +35920,8 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
35905
35920
  }
35906
35921
  },
35907
35922
  navigate: optionsRef.current?.navigate,
35908
- notify: optionsRef.current?.notify
35923
+ notify: optionsRef.current?.notify,
35924
+ callService: optionsRef.current?.callService
35909
35925
  });
35910
35926
  const persistence = optionsRef.current?.persistence;
35911
35927
  let handlers = clientHandlers;
@@ -35352,7 +35352,7 @@ init_logger();
35352
35352
 
35353
35353
  // runtime/createClientEffectHandlers.ts
35354
35354
  function createClientEffectHandlers(options) {
35355
- const { eventBus, slotSetter, navigate, notify } = options;
35355
+ const { eventBus, slotSetter, navigate, notify, callService } = options;
35356
35356
  return {
35357
35357
  emit: (event, payload) => {
35358
35358
  const prefixedEvent = event.startsWith("UI:") ? event : `UI:${event}`;
@@ -35364,9 +35364,24 @@ function createClientEffectHandlers(options) {
35364
35364
  set: () => {
35365
35365
  console.warn("[ClientEffectHandlers] set is server-side only, ignored on client");
35366
35366
  },
35367
- callService: async () => {
35368
- console.warn("[ClientEffectHandlers] callService is server-side only, ignored on client");
35369
- return {};
35367
+ callService: async (service, action, params) => {
35368
+ if (callService) return callService(service, action, params);
35369
+ const mockId = `mock_${service}_${action}_${Math.random().toString(36).slice(2, 10)}`;
35370
+ const paramsEcho = {};
35371
+ if (params) {
35372
+ for (const [k, v] of Object.entries(params)) {
35373
+ if (v !== void 0 && (typeof v === "string" || typeof v === "number" || typeof v === "boolean" || v === null || v instanceof Date)) {
35374
+ paramsEcho[k] = v;
35375
+ }
35376
+ }
35377
+ }
35378
+ return {
35379
+ id: mockId,
35380
+ clientSecret: `secret_${mockId}`,
35381
+ success: true,
35382
+ status: "succeeded",
35383
+ ...paramsEcho
35384
+ };
35370
35385
  },
35371
35386
  renderUI: (slot, pattern, props) => {
35372
35387
  if (pattern === null) {
@@ -35860,7 +35875,8 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
35860
35875
  }
35861
35876
  },
35862
35877
  navigate: optionsRef.current?.navigate,
35863
- notify: optionsRef.current?.notify
35878
+ notify: optionsRef.current?.notify,
35879
+ callService: optionsRef.current?.callService
35864
35880
  });
35865
35881
  const persistence = optionsRef.current?.persistence;
35866
35882
  let handlers = clientHandlers;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almadar/ui",
3
- "version": "4.30.0",
3
+ "version": "4.31.0",
4
4
  "description": "React UI components, hooks, and providers for Almadar",
5
5
  "type": "module",
6
6
  "sideEffects": [