@almadar/ui 2.61.1 → 3.1.2

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 (48) hide show
  1. package/dist/avl/index.cjs +1344 -1507
  2. package/dist/avl/index.css +7 -2
  3. package/dist/avl/index.js +268 -431
  4. package/dist/components/index.cjs +40 -38
  5. package/dist/components/index.css +7 -2
  6. package/dist/components/index.js +41 -39
  7. package/dist/components/organisms/DataTable.d.ts +3 -2
  8. package/dist/components/organisms/JazariStateMachine.d.ts +10 -37
  9. package/dist/components/organisms/MasterDetail.d.ts +4 -3
  10. package/dist/components/organisms/MediaGallery.d.ts +3 -2
  11. package/dist/components/organisms/Sidebar.d.ts +7 -2
  12. package/dist/components/organisms/StateMachineView.d.ts +7 -2
  13. package/dist/components/organisms/Table.d.ts +2 -1
  14. package/dist/components/organisms/Timeline.d.ts +15 -2
  15. package/dist/components/organisms/book/BookChapterView.d.ts +3 -2
  16. package/dist/components/organisms/book/BookCoverPage.d.ts +3 -3
  17. package/dist/components/organisms/book/BookNavBar.d.ts +3 -3
  18. package/dist/components/organisms/book/BookTableOfContents.d.ts +3 -2
  19. package/dist/components/organisms/book/BookViewer.d.ts +2 -2
  20. package/dist/components/organisms/book/types.d.ts +9 -4
  21. package/dist/components/organisms/game/WorldMapBoard.d.ts +9 -3
  22. package/dist/components/organisms/game/three/index.cjs +8 -4
  23. package/dist/components/organisms/game/three/index.js +8 -4
  24. package/dist/components/organisms/marketing-types.d.ts +22 -12
  25. package/dist/components/organisms/types.d.ts +24 -12
  26. package/dist/components/templates/types.d.ts +7 -2
  27. package/dist/docs/index.cjs +6 -2
  28. package/dist/docs/index.d.cts +1 -1
  29. package/dist/docs/index.js +6 -2
  30. package/dist/hooks/event-bus-types.d.ts +19 -27
  31. package/dist/hooks/index.cjs +13 -6
  32. package/dist/hooks/index.d.ts +1 -1
  33. package/dist/hooks/index.js +13 -6
  34. package/dist/hooks/useEventBus.d.ts +3 -3
  35. package/dist/lib/index.cjs +5 -2
  36. package/dist/lib/index.js +5 -2
  37. package/dist/lib/verificationRegistry.d.ts +3 -5
  38. package/dist/marketing/index.cjs +6 -2
  39. package/dist/marketing/index.js +6 -2
  40. package/dist/providers/index.cjs +997 -1168
  41. package/dist/providers/index.css +7 -2
  42. package/dist/providers/index.d.ts +0 -2
  43. package/dist/providers/index.js +241 -406
  44. package/dist/runtime/index.cjs +47 -70
  45. package/dist/runtime/index.css +7 -2
  46. package/dist/runtime/index.js +48 -71
  47. package/package.json +4 -4
  48. package/dist/providers/EntityStoreProvider.d.ts +0 -63
@@ -8,9 +8,10 @@
8
8
  * - Emits: UI:BOOK_NAVIGATE { chapterId }
9
9
  */
10
10
  import React from 'react';
11
- import type { EntityDisplayProps } from '../types';
12
11
  import type { BookPart } from './types';
13
- export interface BookTableOfContentsProps extends EntityDisplayProps<BookPart> {
12
+ export interface BookTableOfContentsProps {
13
+ /** Additional CSS classes */
14
+ className?: string;
14
15
  parts: BookPart[];
15
16
  currentChapterId?: string;
16
17
  direction?: 'rtl' | 'ltr';
@@ -18,8 +18,8 @@
18
18
  */
19
19
  import React from 'react';
20
20
  import type { EntityDisplayProps } from '../types';
21
- import type { BookData, BookFieldMap } from './types';
22
- export interface BookViewerProps extends EntityDisplayProps<BookData | Record<string, unknown>> {
21
+ import type { BookFieldMap } from './types';
22
+ export interface BookViewerProps extends EntityDisplayProps {
23
23
  /** Initial page index (default: 0 = cover) */
24
24
  initialPage?: number;
25
25
  /** Field name translation map — a BookFieldMap object or locale key ("ar") */
@@ -1,10 +1,15 @@
1
1
  /**
2
2
  * BookViewer shared types
3
3
  *
4
- * Field names are canonical English. When entity data arrives from a
5
- * schema with non-English field names (e.g. Arabic .orb), a field map
6
- * translates them before passing to BookViewer. See `mapBookData()`.
4
+ * `BookData` / `BookPart` / `BookChapter` are rendering-layer content-model
5
+ * types: they carry a typed `OrbitalSchema` (via `@almadar/core`) for the
6
+ * embedded orbital-diagram feature, which is richer than `FieldValue` and
7
+ * therefore cannot satisfy `EntityRow`'s primitive-field constraint. The
8
+ * BookViewer organism's prop surface IS `EntityRow` — raw schema data bound
9
+ * from `@payload.data`; `mapBookData()` normalises those records (English or
10
+ * localised) into the typed `BookData` representation at render time.
7
11
  */
12
+ import type { OrbitalSchema } from '@almadar/core';
8
13
  export interface BookData {
9
14
  title: string;
10
15
  subtitle?: string;
@@ -21,7 +26,7 @@ export interface BookChapter {
21
26
  id: string;
22
27
  title: string;
23
28
  content: string;
24
- orbitalSchema?: unknown;
29
+ orbitalSchema?: OrbitalSchema;
25
30
  }
26
31
  /**
27
32
  * Maps raw entity field names to canonical BookData field names.
@@ -19,7 +19,6 @@
19
19
  * @packageDocumentation
20
20
  */
21
21
  import React from 'react';
22
- import type { EntityDisplayProps } from '../types';
23
22
  import type { IsometricFeature } from './types/isometric';
24
23
  import type { ResolvedFrame } from './types/spriteAnimation';
25
24
  /** A hero on the world map */
@@ -102,7 +101,15 @@ export interface WorldMapEntity {
102
101
  * Emits: UI:FEATURE_ENTER
103
102
  * Emits: UI:TILE_CLICK
104
103
  */
105
- export interface WorldMapBoardProps extends EntityDisplayProps<WorldMapEntity> {
104
+ export interface WorldMapBoardProps {
105
+ /** Additional CSS classes */
106
+ className?: string;
107
+ /** Loading state indicator */
108
+ isLoading?: boolean;
109
+ /** Error state */
110
+ error?: Error | null;
111
+ /** World map entity data */
112
+ entity?: WorldMapEntity | readonly WorldMapEntity[];
106
113
  /** Canvas render scale */
107
114
  scale?: number;
108
115
  /** Unit draw-size multiplier */
@@ -147,7 +154,6 @@ export interface WorldMapBoardProps extends EntityDisplayProps<WorldMapEntity> {
147
154
  enableCamera?: boolean;
148
155
  effectSpriteUrls?: string[];
149
156
  resolveUnitFrame?: (unitId: string) => ResolvedFrame | null;
150
- className?: string;
151
157
  }
152
158
  export declare function WorldMapBoard({ entity, isLoading, scale, unitScale, allowMoveAllHeroes, isInRange, heroSelectEvent, heroMoveEvent, battleEncounterEvent, featureEnterEvent, tileClickEvent, header, sidePanel, overlay, footer, onHeroSelect, onHeroMove, onBattleEncounter, onFeatureEnter, diamondTopY, enableCamera, effectSpriteUrls, resolveUnitFrame, className, }: WorldMapBoardProps): React.JSX.Element;
153
159
  export declare namespace WorldMapBoard {
@@ -1436,11 +1436,15 @@ function getGlobalEventBus() {
1436
1436
  var fallbackListeners = /* @__PURE__ */ new Map();
1437
1437
  var fallbackAnyListeners = /* @__PURE__ */ new Set();
1438
1438
  var fallbackEventBus = {
1439
- emit: (type, payload) => {
1439
+ emit: (type, payload, source) => {
1440
1440
  const event = {
1441
1441
  type,
1442
+ // Narrow at the bus boundary: public emit accepts an opaque object so
1443
+ // generic UI emit sites don't require casts; the envelope stores the
1444
+ // payload as EventPayload which listeners consume directly.
1442
1445
  payload,
1443
- timestamp: Date.now()
1446
+ timestamp: Date.now(),
1447
+ source
1444
1448
  };
1445
1449
  const handlers = fallbackListeners.get(type);
1446
1450
  log.debug("emit", { type, payloadKeys: payload ? Object.keys(payload).length : 0, listenerCount: (handlers?.size ?? 0) + fallbackAnyListeners.size });
@@ -1503,8 +1507,8 @@ function useEventBus() {
1503
1507
  function useEmitEvent() {
1504
1508
  const eventBus = useEventBus();
1505
1509
  return React21.useCallback(
1506
- (type, payload) => {
1507
- eventBus.emit(type, payload);
1510
+ (type, payload, source) => {
1511
+ eventBus.emit(type, payload, source);
1508
1512
  },
1509
1513
  [eventBus]
1510
1514
  );
@@ -1412,11 +1412,15 @@ function getGlobalEventBus() {
1412
1412
  var fallbackListeners = /* @__PURE__ */ new Map();
1413
1413
  var fallbackAnyListeners = /* @__PURE__ */ new Set();
1414
1414
  var fallbackEventBus = {
1415
- emit: (type, payload) => {
1415
+ emit: (type, payload, source) => {
1416
1416
  const event = {
1417
1417
  type,
1418
+ // Narrow at the bus boundary: public emit accepts an opaque object so
1419
+ // generic UI emit sites don't require casts; the envelope stores the
1420
+ // payload as EventPayload which listeners consume directly.
1418
1421
  payload,
1419
- timestamp: Date.now()
1422
+ timestamp: Date.now(),
1423
+ source
1420
1424
  };
1421
1425
  const handlers = fallbackListeners.get(type);
1422
1426
  log.debug("emit", { type, payloadKeys: payload ? Object.keys(payload).length : 0, listenerCount: (handlers?.size ?? 0) + fallbackAnyListeners.size });
@@ -1479,8 +1483,8 @@ function useEventBus() {
1479
1483
  function useEmitEvent() {
1480
1484
  const eventBus = useEventBus();
1481
1485
  return useCallback(
1482
- (type, payload) => {
1483
- eventBus.emit(type, payload);
1486
+ (type, payload, source) => {
1487
+ eventBus.emit(type, payload, source);
1484
1488
  },
1485
1489
  [eventBus]
1486
1490
  );
@@ -1,21 +1,31 @@
1
1
  /**
2
2
  * Marketing Entity Types
3
3
  *
4
- * Shared entity interfaces for marketing/landing-page organisms.
5
- * These types define the data shapes consumed by HeroOrganism,
6
- * FeatureGridOrganism, PricingOrganism, StatsOrganism,
7
- * StepFlowOrganism, ShowcaseOrganism, TeamOrganism, and CaseStudyOrganism.
4
+ * Shared entity interfaces for marketing/landing-page organisms (HeroOrganism,
5
+ * FeatureGridOrganism, PricingOrganism, StatsOrganism, StepFlowOrganism,
6
+ * ShowcaseOrganism, TeamOrganism, CaseStudyOrganism).
7
+ *
8
+ * Every marketing entity extends `@almadar/core`'s `EntityRow` so the
9
+ * canonical runtime entity shape lives in core. Marketing data is pure
10
+ * JSON-serialisable content (strings, numbers, nested records) with no
11
+ * React nodes or callbacks, so the `EntityRow` index signature is satisfied
12
+ * structurally. Nested `MarketingAction` / `MarketingImage` carry explicit
13
+ * `[key: string]: FieldValue | undefined` signatures so they fit the
14
+ * `{ [key: string]: FieldValue }` branch of `FieldValue`.
8
15
  */
16
+ import type { EntityRow, FieldValue } from '@almadar/core';
9
17
  export interface MarketingAction {
18
+ [key: string]: FieldValue | undefined;
10
19
  label: string;
11
20
  href: string;
12
21
  variant?: 'primary' | 'secondary' | 'ghost';
13
22
  }
14
23
  export interface MarketingImage {
24
+ [key: string]: FieldValue | undefined;
15
25
  src: string;
16
26
  alt: string;
17
27
  }
18
- export interface HeroEntity {
28
+ export interface HeroEntity extends EntityRow {
19
29
  id: string;
20
30
  tag?: string;
21
31
  title: string;
@@ -28,7 +38,7 @@ export interface HeroEntity {
28
38
  imagePosition?: 'below' | 'right' | 'background';
29
39
  background?: 'dark' | 'gradient' | 'subtle';
30
40
  }
31
- export interface FeatureEntity {
41
+ export interface FeatureEntity extends EntityRow {
32
42
  id: string;
33
43
  icon?: string;
34
44
  title: string;
@@ -36,7 +46,7 @@ export interface FeatureEntity {
36
46
  href?: string;
37
47
  linkLabel?: string;
38
48
  }
39
- export interface PricingPlanEntity {
49
+ export interface PricingPlanEntity extends EntityRow {
40
50
  id: string;
41
51
  name: string;
42
52
  price: string;
@@ -47,19 +57,19 @@ export interface PricingPlanEntity {
47
57
  highlighted?: boolean;
48
58
  badge?: string;
49
59
  }
50
- export interface StatEntity {
60
+ export interface StatEntity extends EntityRow {
51
61
  id: string;
52
62
  value: string;
53
63
  label: string;
54
64
  }
55
- export interface StepEntity {
65
+ export interface StepEntity extends EntityRow {
56
66
  id: string;
57
67
  number?: number;
58
68
  title: string;
59
69
  description: string;
60
70
  icon?: string;
61
71
  }
62
- export interface ShowcaseEntity {
72
+ export interface ShowcaseEntity extends EntityRow {
63
73
  id: string;
64
74
  title: string;
65
75
  description?: string;
@@ -68,7 +78,7 @@ export interface ShowcaseEntity {
68
78
  badge?: string;
69
79
  accentColor?: string;
70
80
  }
71
- export interface TeamMemberEntity {
81
+ export interface TeamMemberEntity extends EntityRow {
72
82
  id: string;
73
83
  name: string;
74
84
  nameAr?: string;
@@ -76,7 +86,7 @@ export interface TeamMemberEntity {
76
86
  bio: string;
77
87
  avatar?: string;
78
88
  }
79
- export interface CaseStudyEntity {
89
+ export interface CaseStudyEntity extends EntityRow {
80
90
  id: string;
81
91
  title: string;
82
92
  description: string;
@@ -7,6 +7,7 @@
7
7
  * Exception: Form manages local `formData` state for field input tracking.
8
8
  * This is the ONE allowed exception — documented here.
9
9
  */
10
+ import type { EntityRow } from '@almadar/core';
10
11
  export declare const EntityDisplayEvents: {
11
12
  readonly SORT: "SORT";
12
13
  readonly PAGINATE: "PAGINATE";
@@ -35,21 +36,32 @@ export interface FilterPayload {
35
36
  export interface SelectPayload {
36
37
  ids: (string | number)[];
37
38
  }
38
- export interface EntityDisplayProps<T = unknown> {
39
+ export interface EntityDisplayProps<T extends EntityRow = EntityRow> {
39
40
  /**
40
- * Entity data or a legacy entity-name string.
41
+ * Pre-resolved entity data, typed against `@almadar/core`'s `EntityRow`
42
+ * (`{ id?: string } & Record<string, FieldValue>`) so the single source of
43
+ * truth for runtime entity shape lives in core. Consumers narrow via the
44
+ * generic parameter; the constraint guarantees every organism receives
45
+ * something with an optional `id` and a Record of `FieldValue` fields.
41
46
  *
42
- * Accepts three shapes today; the string branch is deprecated:
43
- * - `readonly T[]`: pre-resolved array for list patterns (authoring
44
- * pattern: `entity: @payload.data` from the calling trait).
45
- * - `T`: pre-resolved single record for detail patterns.
46
- * - `string`: legacy entity-type name resolved by the renderer via
47
- * `useEntityRef`. Emits a dev-mode deprecation warning. Removal
48
- * scheduled for Phase 6 of docs/Almadar_Entity_V2_Plan.md when the
49
- * entity store itself is deleted; the prop shape will collapse to
50
- * `readonly T[] | T | undefined`.
47
+ * Two shapes accepted:
48
+ * - `readonly T[]`: array for list patterns (authoring: `entity: @payload.data`
49
+ * on the calling trait after a `fetch … { emit: { success } }` listener).
50
+ * - `T`: single record for detail patterns.
51
+ *
52
+ * The legacy `string` (entity-name) branch was removed in V2 Phase 6. The
53
+ * EntityStore resolver is gone; components now receive pre-resolved data via
54
+ * the event bus.
55
+ *
56
+ * NOTE: Several legacy organisms (HeroOrganism, TeamOrganism, CaseStudyOrganism,
57
+ * MediaGallery, PricingOrganism, ShowcaseOrganism, StatsOrganism, Sidebar,
58
+ * Timeline, StepFlowOrganism, FeatureGridOrganism, book/*, WorldMapBoard,
59
+ * StateMachineView, JazariStateMachine, MasterDetail, DataTable, Table) define
60
+ * local entity types (HeroEntity, TeamMemberEntity, …) that don't formally
61
+ * extend `EntityRow`. They surface `EntityDisplayProps<T>` constraint errors.
62
+ * Tracked as a Phase 7 follow-up in `docs/Almadar_Entity_V2_Plan.md` §10.
51
63
  */
52
- entity?: string | T | readonly T[];
64
+ entity?: T | readonly T[];
53
65
  /** Additional CSS classes */
54
66
  className?: string;
55
67
  /** Loading state indicator */
@@ -15,8 +15,13 @@ export interface TemplateProps<E extends {
15
15
  } = {
16
16
  id: string;
17
17
  }> {
18
- /** Entity data — single object, array from compiler, or string entity name */
19
- entity?: string | E | readonly E[];
18
+ /**
19
+ * Entity data single object or array (pre-resolved by the compiler
20
+ * from `@payload.data` on the calling trait). The legacy `string`
21
+ * entity-name branch was removed in V2 Phase 6 along with the
22
+ * EntityStore resolver.
23
+ */
24
+ entity?: E | readonly E[];
20
25
  /** External styling override */
21
26
  className?: string;
22
27
  }
@@ -2570,11 +2570,15 @@ function getGlobalEventBus() {
2570
2570
  var fallbackListeners = /* @__PURE__ */ new Map();
2571
2571
  var fallbackAnyListeners = /* @__PURE__ */ new Set();
2572
2572
  var fallbackEventBus = {
2573
- emit: (type, payload) => {
2573
+ emit: (type, payload, source) => {
2574
2574
  const event = {
2575
2575
  type,
2576
+ // Narrow at the bus boundary: public emit accepts an opaque object so
2577
+ // generic UI emit sites don't require casts; the envelope stores the
2578
+ // payload as EventPayload which listeners consume directly.
2576
2579
  payload,
2577
- timestamp: Date.now()
2580
+ timestamp: Date.now(),
2581
+ source
2578
2582
  };
2579
2583
  const handlers = fallbackListeners.get(type);
2580
2584
  log.debug("emit", { type, payloadKeys: payload ? Object.keys(payload).length : 0, listenerCount: (handlers?.size ?? 0) + fallbackAnyListeners.size });
@@ -295,7 +295,7 @@ interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "
295
295
  /** onChange handler - accepts events from input, select, or textarea */
296
296
  onChange?: React.ChangeEventHandler<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>;
297
297
  }
298
- declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>>;
298
+ declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement>>;
299
299
 
300
300
  /**
301
301
  * DocSidebar Molecule Component
@@ -2546,11 +2546,15 @@ function getGlobalEventBus() {
2546
2546
  var fallbackListeners = /* @__PURE__ */ new Map();
2547
2547
  var fallbackAnyListeners = /* @__PURE__ */ new Set();
2548
2548
  var fallbackEventBus = {
2549
- emit: (type, payload) => {
2549
+ emit: (type, payload, source) => {
2550
2550
  const event = {
2551
2551
  type,
2552
+ // Narrow at the bus boundary: public emit accepts an opaque object so
2553
+ // generic UI emit sites don't require casts; the envelope stores the
2554
+ // payload as EventPayload which listeners consume directly.
2552
2555
  payload,
2553
- timestamp: Date.now()
2556
+ timestamp: Date.now(),
2557
+ source
2554
2558
  };
2555
2559
  const handlers = fallbackListeners.get(type);
2556
2560
  log.debug("emit", { type, payloadKeys: payload ? Object.keys(payload).length : 0, listenerCount: (handlers?.size ?? 0) + fallbackAnyListeners.size });
@@ -1,42 +1,34 @@
1
1
  /**
2
2
  * Event Bus Types
3
3
  *
4
- * Type definitions for the page event bus system.
4
+ * Re-exports from @almadar/core so every package agrees on the same
5
+ * bus event envelope. @almadar/ui no longer owns its own KFlowEvent —
6
+ * that type was folded into core's BusEvent.
5
7
  *
6
8
  * @packageDocumentation
7
9
  */
8
- /**
9
- * A KFlow event that can be emitted on the event bus.
10
- */
11
- export interface KFlowEvent {
12
- /** Event type identifier (e.g., 'TASK_COMPLETED', 'VALIDATION_SUCCESS') */
13
- type: string;
14
- /** Optional payload data */
15
- payload?: Record<string, unknown>;
16
- /** Timestamp when the event was emitted */
17
- timestamp: number;
18
- /** Source trait or component that emitted the event */
19
- source?: string;
20
- }
21
- /**
22
- * Event listener callback function.
23
- */
24
- export type EventListener = (event: KFlowEvent) => void;
25
- /**
26
- * Function to unsubscribe from events.
27
- */
28
- export type Unsubscribe = () => void;
10
+ import type { BusEvent, BusEventSource, BusEventListener, Unsubscribe } from "@almadar/core";
11
+ export type { BusEvent, BusEventSource, Unsubscribe };
12
+ export type EventListener = BusEventListener;
29
13
  /**
30
14
  * Event bus context type.
15
+ *
16
+ * `emit` accepts `Record<string, unknown>` on its public surface so
17
+ * generic UI components (DataGrid, SortableList, ...) can pass
18
+ * consumer-defined row data without a cast at every emit site. The
19
+ * envelope stored in `BusEvent.payload` is narrowed to `EventPayload`
20
+ * inside the bus implementation — listeners always receive the typed
21
+ * shape.
31
22
  */
32
23
  export interface EventBusContextType {
33
24
  /**
34
25
  * Emit an event to all listeners.
35
26
  *
36
27
  * @param type - Event type identifier
37
- * @param payload - Optional payload data
28
+ * @param payload - Optional payload data (object-shaped)
29
+ * @param source - Optional origin info (orbital/trait/...)
38
30
  */
39
- emit: (type: string, payload?: Record<string, unknown>) => void;
31
+ emit: (type: string, payload?: Record<string, unknown>, source?: BusEventSource) => void;
40
32
  /**
41
33
  * Subscribe to an event type.
42
34
  *
@@ -44,7 +36,7 @@ export interface EventBusContextType {
44
36
  * @param listener - Callback function
45
37
  * @returns Unsubscribe function
46
38
  */
47
- on: (type: string, listener: EventListener) => Unsubscribe;
39
+ on: (type: string, listener: BusEventListener) => Unsubscribe;
48
40
  /**
49
41
  * Subscribe to an event type, but only fire once.
50
42
  *
@@ -52,7 +44,7 @@ export interface EventBusContextType {
52
44
  * @param listener - Callback function
53
45
  * @returns Unsubscribe function
54
46
  */
55
- once: (type: string, listener: EventListener) => Unsubscribe;
47
+ once: (type: string, listener: BusEventListener) => Unsubscribe;
56
48
  /**
57
49
  * Check if there are any listeners for an event type.
58
50
  *
@@ -67,5 +59,5 @@ export interface EventBusContextType {
67
59
  * @param listener - Callback function invoked for every emitted event
68
60
  * @returns Unsubscribe function
69
61
  */
70
- onAny?: (listener: EventListener) => Unsubscribe;
62
+ onAny?: (listener: BusEventListener) => Unsubscribe;
71
63
  }
@@ -8,6 +8,9 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
8
 
9
9
  var React__default = /*#__PURE__*/_interopDefault(React);
10
10
 
11
+ var __defProp = Object.defineProperty;
12
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
11
14
  function useOrbitalHistory(options) {
12
15
  const { appId, authToken, userId, onHistoryChange, onRevertSuccess } = options;
13
16
  const getHeaders2 = React.useCallback(() => {
@@ -932,11 +935,15 @@ function getGlobalEventBus() {
932
935
  var fallbackListeners = /* @__PURE__ */ new Map();
933
936
  var fallbackAnyListeners = /* @__PURE__ */ new Set();
934
937
  var fallbackEventBus = {
935
- emit: (type, payload) => {
938
+ emit: (type, payload, source) => {
936
939
  const event = {
937
940
  type,
941
+ // Narrow at the bus boundary: public emit accepts an opaque object so
942
+ // generic UI emit sites don't require casts; the envelope stores the
943
+ // payload as EventPayload which listeners consume directly.
938
944
  payload,
939
- timestamp: Date.now()
945
+ timestamp: Date.now(),
946
+ source
940
947
  };
941
948
  const handlers = fallbackListeners.get(type);
942
949
  log.debug("emit", { type, payloadKeys: payload ? Object.keys(payload).length : 0, listenerCount: (handlers?.size ?? 0) + fallbackAnyListeners.size });
@@ -1013,8 +1020,8 @@ function useEventListener(event, handler) {
1013
1020
  function useEmitEvent() {
1014
1021
  const eventBus = useEventBus();
1015
1022
  return React.useCallback(
1016
- (type, payload) => {
1017
- eventBus.emit(type, payload);
1023
+ (type, payload, source) => {
1024
+ eventBus.emit(type, payload, source);
1018
1025
  },
1019
1026
  [eventBus]
1020
1027
  );
@@ -1585,8 +1592,8 @@ var API_BASE_URL = typeof process !== "undefined" && process.env?.VITE_API_URL ?
1585
1592
  var ApiError = class extends Error {
1586
1593
  constructor(status, statusText, message) {
1587
1594
  super(message || `API Error: ${status} ${statusText}`);
1588
- this.status = status;
1589
- this.statusText = statusText;
1595
+ __publicField(this, "status", status);
1596
+ __publicField(this, "statusText", statusText);
1590
1597
  this.name = "ApiError";
1591
1598
  }
1592
1599
  };
@@ -11,7 +11,7 @@ export { useAgentChat } from './useAgentChat';
11
11
  export { useValidation } from './useValidation';
12
12
  export { useDeepAgentGeneration } from './useDeepAgentGeneration';
13
13
  export { useEventBus, useEventListener, useEmitEvent } from './useEventBus';
14
- export type { KFlowEvent, EventListener, Unsubscribe, EventBusContextType } from './event-bus-types';
14
+ export type { BusEvent, BusEventSource, EventListener, Unsubscribe, EventBusContextType, } from './event-bus-types';
15
15
  export { useUISlotManager, DEFAULT_SLOTS, type UISlot, type SlotAnimation, type SlotContent, type RenderUIConfig, type SlotChangeCallback, type UISlotManager, } from './useUISlots';
16
16
  export { useUIEvents, useSelectedEntity } from './useUIEvents';
17
17
  export { useEntityList, useEntityDetail, useEntity, useEntityListSuspense, useEntitySuspense, entityDataKeys, EntityDataProvider, useEntityDataAdapter, type EntityDataAdapter, type EntityDataRecord, type UseEntityListOptions, type UseEntityListResult, type UseEntityDetailResult, } from './useEntityData';
@@ -2,6 +2,9 @@ import React, { createContext, useCallback, useState, useEffect, useMemo, useCon
2
2
  import { EventBusContext, SelectionContext } from '@almadar/ui/providers';
3
3
  import { useQueryClient, useMutation, useQuery } from '@tanstack/react-query';
4
4
 
5
+ var __defProp = Object.defineProperty;
6
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
8
  function useOrbitalHistory(options) {
6
9
  const { appId, authToken, userId, onHistoryChange, onRevertSuccess } = options;
7
10
  const getHeaders2 = useCallback(() => {
@@ -926,11 +929,15 @@ function getGlobalEventBus() {
926
929
  var fallbackListeners = /* @__PURE__ */ new Map();
927
930
  var fallbackAnyListeners = /* @__PURE__ */ new Set();
928
931
  var fallbackEventBus = {
929
- emit: (type, payload) => {
932
+ emit: (type, payload, source) => {
930
933
  const event = {
931
934
  type,
935
+ // Narrow at the bus boundary: public emit accepts an opaque object so
936
+ // generic UI emit sites don't require casts; the envelope stores the
937
+ // payload as EventPayload which listeners consume directly.
932
938
  payload,
933
- timestamp: Date.now()
939
+ timestamp: Date.now(),
940
+ source
934
941
  };
935
942
  const handlers = fallbackListeners.get(type);
936
943
  log.debug("emit", { type, payloadKeys: payload ? Object.keys(payload).length : 0, listenerCount: (handlers?.size ?? 0) + fallbackAnyListeners.size });
@@ -1007,8 +1014,8 @@ function useEventListener(event, handler) {
1007
1014
  function useEmitEvent() {
1008
1015
  const eventBus = useEventBus();
1009
1016
  return useCallback(
1010
- (type, payload) => {
1011
- eventBus.emit(type, payload);
1017
+ (type, payload, source) => {
1018
+ eventBus.emit(type, payload, source);
1012
1019
  },
1013
1020
  [eventBus]
1014
1021
  );
@@ -1579,8 +1586,8 @@ var API_BASE_URL = typeof process !== "undefined" && process.env?.VITE_API_URL ?
1579
1586
  var ApiError = class extends Error {
1580
1587
  constructor(status, statusText, message) {
1581
1588
  super(message || `API Error: ${status} ${statusText}`);
1582
- this.status = status;
1583
- this.statusText = statusText;
1589
+ __publicField(this, "status", status);
1590
+ __publicField(this, "statusText", statusText);
1584
1591
  this.name = "ApiError";
1585
1592
  }
1586
1593
  };
@@ -1,5 +1,5 @@
1
- import type { KFlowEvent, EventListener, Unsubscribe, EventBusContextType } from './event-bus-types';
2
- export type { KFlowEvent, EventListener, Unsubscribe, EventBusContextType };
1
+ import type { BusEvent, BusEventSource, EventListener, Unsubscribe, EventBusContextType } from './event-bus-types';
2
+ export type { BusEvent, BusEventSource, EventListener, Unsubscribe, EventBusContextType };
3
3
  declare global {
4
4
  interface Window {
5
5
  __kflowEventBus?: EventBusContextType | null;
@@ -92,5 +92,5 @@ export declare const useEventSubscription: typeof useEventListener;
92
92
  * };
93
93
  * ```
94
94
  */
95
- export declare function useEmitEvent(): (type: string, payload?: Record<string, unknown>) => void;
95
+ export declare function useEmitEvent(): (type: string, payload?: Record<string, unknown>, source?: BusEventSource) => void;
96
96
  export default useEventBus;
@@ -3,6 +3,9 @@
3
3
  var clsx = require('clsx');
4
4
  var tailwindMerge = require('tailwind-merge');
5
5
 
6
+ var __defProp = Object.defineProperty;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
6
9
  function cn(...inputs) {
7
10
  return tailwindMerge.twMerge(clsx.clsx(inputs));
8
11
  }
@@ -12,8 +15,8 @@ var API_BASE_URL = typeof process !== "undefined" && process.env?.VITE_API_URL ?
12
15
  var ApiError = class extends Error {
13
16
  constructor(status, statusText, message) {
14
17
  super(message || `API Error: ${status} ${statusText}`);
15
- this.status = status;
16
- this.statusText = statusText;
18
+ __publicField(this, "status", status);
19
+ __publicField(this, "statusText", statusText);
17
20
  this.name = "ApiError";
18
21
  }
19
22
  };
package/dist/lib/index.js CHANGED
@@ -1,6 +1,9 @@
1
1
  import { clsx } from 'clsx';
2
2
  import { twMerge } from 'tailwind-merge';
3
3
 
4
+ var __defProp = Object.defineProperty;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
7
  function cn(...inputs) {
5
8
  return twMerge(clsx(inputs));
6
9
  }
@@ -10,8 +13,8 @@ var API_BASE_URL = typeof process !== "undefined" && process.env?.VITE_API_URL ?
10
13
  var ApiError = class extends Error {
11
14
  constructor(status, statusText, message) {
12
15
  super(message || `API Error: ${status} ${statusText}`);
13
- this.status = status;
14
- this.statusText = statusText;
16
+ __publicField(this, "status", status);
17
+ __publicField(this, "statusText", statusText);
15
18
  this.name = "ApiError";
16
19
  }
17
20
  };
@@ -9,6 +9,7 @@
9
9
  *
10
10
  * @packageDocumentation
11
11
  */
12
+ import type { BusEvent, EventPayload } from '@almadar/core';
12
13
  export type CheckStatus = "pass" | "fail" | "pending" | "warn";
13
14
  export interface VerificationCheck {
14
15
  id: string;
@@ -91,7 +92,7 @@ export type AssetLoadStatus = "loaded" | "failed" | "pending";
91
92
  /** Event bus log entry for verification */
92
93
  export interface EventLogEntry {
93
94
  type: string;
94
- payload?: Record<string, unknown>;
95
+ payload?: EventPayload;
95
96
  timestamp: number;
96
97
  }
97
98
  /** Exposed on window for Playwright to query */
@@ -132,10 +133,7 @@ export declare function waitForTransition(event: string, timeoutMs?: number): Pr
132
133
  */
133
134
  export declare function bindEventBus(eventBus: {
134
135
  emit: (type: string, payload?: Record<string, unknown>) => void;
135
- onAny?: (listener: (event: {
136
- type: string;
137
- payload?: Record<string, unknown>;
138
- }) => void) => () => void;
136
+ onAny?: (listener: (event: BusEvent) => void) => () => void;
139
137
  }): void;
140
138
  /**
141
139
  * Bind a trait state getter so automation can query current states.