@almadar/ui 3.6.0 → 3.7.1

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.
@@ -4992,6 +4992,9 @@ var init_Button = __esm({
4992
4992
  const resolvedRightIcon = resolveIconProp(rightIconValue, iconSizeStyles[size]);
4993
4993
  const handleClick = (e) => {
4994
4994
  if (action) {
4995
+ if (typeof console !== "undefined") {
4996
+ console.log("[Button.click]", action, "actionPayload=", JSON.stringify(actionPayload));
4997
+ }
4995
4998
  eventBus.emit(`UI:${action}`, actionPayload ?? {});
4996
4999
  }
4997
5000
  onClick?.(e);
@@ -51497,6 +51500,16 @@ function useTraitStateMachine(traitBindings, slotsActions, options) {
51497
51500
  });
51498
51501
  }
51499
51502
  }
51503
+ const LIFECYCLE_EVENTS = /* @__PURE__ */ new Set(["INIT", "LOAD", "$MOUNT", "$UNMOUNT", "$FRAME"]);
51504
+ if (!LIFECYCLE_EVENTS.has(normalizedEvent)) {
51505
+ for (const { traitName, result } of results) {
51506
+ if (!result.executed) continue;
51507
+ eventBus.emit(normalizedEvent, payload, {
51508
+ trait: traitName,
51509
+ fromBridge: true
51510
+ });
51511
+ }
51512
+ }
51500
51513
  if (results.length > 0) {
51501
51514
  setTraitStates(currentManager.getAllStates());
51502
51515
  }
@@ -51556,6 +51569,21 @@ function useTraitStateMachine(traitBindings, slotsActions, options) {
51556
51569
  });
51557
51570
  unsubscribes.push(unsub);
51558
51571
  }
51572
+ for (const binding of traitBindings) {
51573
+ const listens = binding.trait.listens ?? [];
51574
+ for (const listen of listens) {
51575
+ const expectedTrait = listen.source?.trait;
51576
+ const unsub = eventBus.on(listen.event, (event) => {
51577
+ if (expectedTrait) {
51578
+ const emitTrait = event.source?.trait;
51579
+ if (emitTrait !== expectedTrait) return;
51580
+ }
51581
+ console.log("[TraitStateMachine] listens", binding.trait.name, listen.event, "\u2192", listen.triggers, "from", event.source?.trait);
51582
+ enqueueAndDrain(listen.triggers, event.payload);
51583
+ });
51584
+ unsubscribes.push(unsub);
51585
+ }
51586
+ }
51559
51587
  return () => {
51560
51588
  for (const unsub of unsubscribes) {
51561
51589
  unsub();
package/dist/avl/index.js CHANGED
@@ -4946,6 +4946,9 @@ var init_Button = __esm({
4946
4946
  const resolvedRightIcon = resolveIconProp(rightIconValue, iconSizeStyles[size]);
4947
4947
  const handleClick = (e) => {
4948
4948
  if (action) {
4949
+ if (typeof console !== "undefined") {
4950
+ console.log("[Button.click]", action, "actionPayload=", JSON.stringify(actionPayload));
4951
+ }
4949
4952
  eventBus.emit(`UI:${action}`, actionPayload ?? {});
4950
4953
  }
4951
4954
  onClick?.(e);
@@ -51451,6 +51454,16 @@ function useTraitStateMachine(traitBindings, slotsActions, options) {
51451
51454
  });
51452
51455
  }
51453
51456
  }
51457
+ const LIFECYCLE_EVENTS = /* @__PURE__ */ new Set(["INIT", "LOAD", "$MOUNT", "$UNMOUNT", "$FRAME"]);
51458
+ if (!LIFECYCLE_EVENTS.has(normalizedEvent)) {
51459
+ for (const { traitName, result } of results) {
51460
+ if (!result.executed) continue;
51461
+ eventBus.emit(normalizedEvent, payload, {
51462
+ trait: traitName,
51463
+ fromBridge: true
51464
+ });
51465
+ }
51466
+ }
51454
51467
  if (results.length > 0) {
51455
51468
  setTraitStates(currentManager.getAllStates());
51456
51469
  }
@@ -51510,6 +51523,21 @@ function useTraitStateMachine(traitBindings, slotsActions, options) {
51510
51523
  });
51511
51524
  unsubscribes.push(unsub);
51512
51525
  }
51526
+ for (const binding of traitBindings) {
51527
+ const listens = binding.trait.listens ?? [];
51528
+ for (const listen of listens) {
51529
+ const expectedTrait = listen.source?.trait;
51530
+ const unsub = eventBus.on(listen.event, (event) => {
51531
+ if (expectedTrait) {
51532
+ const emitTrait = event.source?.trait;
51533
+ if (emitTrait !== expectedTrait) return;
51534
+ }
51535
+ console.log("[TraitStateMachine] listens", binding.trait.name, listen.event, "\u2192", listen.triggers, "from", event.source?.trait);
51536
+ enqueueAndDrain(listen.triggers, event.payload);
51537
+ });
51538
+ unsubscribes.push(unsub);
51539
+ }
51540
+ }
51513
51541
  return () => {
51514
51542
  for (const unsub of unsubscribes) {
51515
51543
  unsub();
@@ -484,6 +484,9 @@ var init_Button = __esm({
484
484
  const resolvedRightIcon = resolveIconProp(rightIconValue, iconSizeStyles[size]);
485
485
  const handleClick = (e) => {
486
486
  if (action) {
487
+ if (typeof console !== "undefined") {
488
+ console.log("[Button.click]", action, "actionPayload=", JSON.stringify(actionPayload));
489
+ }
487
490
  eventBus.emit(`UI:${action}`, actionPayload ?? {});
488
491
  }
489
492
  onClick?.(e);
@@ -439,6 +439,9 @@ var init_Button = __esm({
439
439
  const resolvedRightIcon = resolveIconProp(rightIconValue, iconSizeStyles[size]);
440
440
  const handleClick = (e) => {
441
441
  if (action) {
442
+ if (typeof console !== "undefined") {
443
+ console.log("[Button.click]", action, "actionPayload=", JSON.stringify(actionPayload));
444
+ }
442
445
  eventBus.emit(`UI:${action}`, actionPayload ?? {});
443
446
  }
444
447
  onClick?.(e);
@@ -3200,6 +3200,9 @@ var Button = React4__default.default.forwardRef(
3200
3200
  const resolvedRightIcon = resolveIconProp(rightIconValue, iconSizeStyles[size]);
3201
3201
  const handleClick = (e) => {
3202
3202
  if (action) {
3203
+ if (typeof console !== "undefined") {
3204
+ console.log("[Button.click]", action, "actionPayload=", JSON.stringify(actionPayload));
3205
+ }
3203
3206
  eventBus.emit(`UI:${action}`, actionPayload ?? {});
3204
3207
  }
3205
3208
  onClick?.(e);
@@ -3176,6 +3176,9 @@ var Button = React4.forwardRef(
3176
3176
  const resolvedRightIcon = resolveIconProp(rightIconValue, iconSizeStyles[size]);
3177
3177
  const handleClick = (e) => {
3178
3178
  if (action) {
3179
+ if (typeof console !== "undefined") {
3180
+ console.log("[Button.click]", action, "actionPayload=", JSON.stringify(actionPayload));
3181
+ }
3179
3182
  eventBus.emit(`UI:${action}`, actionPayload ?? {});
3180
3183
  }
3181
3184
  onClick?.(e);
@@ -3200,6 +3200,9 @@ var Button = React5__default.default.forwardRef(
3200
3200
  const resolvedRightIcon = resolveIconProp(rightIconValue, iconSizeStyles[size]);
3201
3201
  const handleClick = (e) => {
3202
3202
  if (action) {
3203
+ if (typeof console !== "undefined") {
3204
+ console.log("[Button.click]", action, "actionPayload=", JSON.stringify(actionPayload));
3205
+ }
3203
3206
  eventBus.emit(`UI:${action}`, actionPayload ?? {});
3204
3207
  }
3205
3208
  onClick?.(e);
@@ -3176,6 +3176,9 @@ var Button = React5.forwardRef(
3176
3176
  const resolvedRightIcon = resolveIconProp(rightIconValue, iconSizeStyles[size]);
3177
3177
  const handleClick = (e) => {
3178
3178
  if (action) {
3179
+ if (typeof console !== "undefined") {
3180
+ console.log("[Button.click]", action, "actionPayload=", JSON.stringify(actionPayload));
3181
+ }
3179
3182
  eventBus.emit(`UI:${action}`, actionPayload ?? {});
3180
3183
  }
3181
3184
  onClick?.(e);
@@ -1544,6 +1544,9 @@ var init_Button = __esm({
1544
1544
  const resolvedRightIcon = resolveIconProp(rightIconValue, iconSizeStyles[size]);
1545
1545
  const handleClick = (e) => {
1546
1546
  if (action) {
1547
+ if (typeof console !== "undefined") {
1548
+ console.log("[Button.click]", action, "actionPayload=", JSON.stringify(actionPayload));
1549
+ }
1547
1550
  eventBus.emit(`UI:${action}`, actionPayload ?? {});
1548
1551
  }
1549
1552
  onClick?.(e);
@@ -1499,6 +1499,9 @@ var init_Button = __esm({
1499
1499
  const resolvedRightIcon = resolveIconProp(rightIconValue, iconSizeStyles[size]);
1500
1500
  const handleClick = (e) => {
1501
1501
  if (action) {
1502
+ if (typeof console !== "undefined") {
1503
+ console.log("[Button.click]", action, "actionPayload=", JSON.stringify(actionPayload));
1504
+ }
1502
1505
  eventBus.emit(`UI:${action}`, actionPayload ?? {});
1503
1506
  }
1504
1507
  onClick?.(e);
@@ -2087,6 +2087,9 @@ var init_Button = __esm({
2087
2087
  const resolvedRightIcon = resolveIconProp(rightIconValue, iconSizeStyles[size]);
2088
2088
  const handleClick = (e) => {
2089
2089
  if (action) {
2090
+ if (typeof console !== "undefined") {
2091
+ console.log("[Button.click]", action, "actionPayload=", JSON.stringify(actionPayload));
2092
+ }
2090
2093
  eventBus.emit(`UI:${action}`, actionPayload ?? {});
2091
2094
  }
2092
2095
  onClick?.(e);
@@ -38293,6 +38296,16 @@ function useTraitStateMachine(traitBindings, slotsActions, options) {
38293
38296
  });
38294
38297
  }
38295
38298
  }
38299
+ const LIFECYCLE_EVENTS = /* @__PURE__ */ new Set(["INIT", "LOAD", "$MOUNT", "$UNMOUNT", "$FRAME"]);
38300
+ if (!LIFECYCLE_EVENTS.has(normalizedEvent)) {
38301
+ for (const { traitName, result } of results) {
38302
+ if (!result.executed) continue;
38303
+ eventBus.emit(normalizedEvent, payload, {
38304
+ trait: traitName,
38305
+ fromBridge: true
38306
+ });
38307
+ }
38308
+ }
38296
38309
  if (results.length > 0) {
38297
38310
  setTraitStates(currentManager.getAllStates());
38298
38311
  }
@@ -38352,6 +38365,21 @@ function useTraitStateMachine(traitBindings, slotsActions, options) {
38352
38365
  });
38353
38366
  unsubscribes.push(unsub);
38354
38367
  }
38368
+ for (const binding of traitBindings) {
38369
+ const listens = binding.trait.listens ?? [];
38370
+ for (const listen of listens) {
38371
+ const expectedTrait = listen.source?.trait;
38372
+ const unsub = eventBus.on(listen.event, (event) => {
38373
+ if (expectedTrait) {
38374
+ const emitTrait = event.source?.trait;
38375
+ if (emitTrait !== expectedTrait) return;
38376
+ }
38377
+ console.log("[TraitStateMachine] listens", binding.trait.name, listen.event, "\u2192", listen.triggers, "from", event.source?.trait);
38378
+ enqueueAndDrain(listen.triggers, event.payload);
38379
+ });
38380
+ unsubscribes.push(unsub);
38381
+ }
38382
+ }
38355
38383
  return () => {
38356
38384
  for (const unsub of unsubscribes) {
38357
38385
  unsub();
@@ -2042,6 +2042,9 @@ var init_Button = __esm({
2042
2042
  const resolvedRightIcon = resolveIconProp(rightIconValue, iconSizeStyles[size]);
2043
2043
  const handleClick = (e) => {
2044
2044
  if (action) {
2045
+ if (typeof console !== "undefined") {
2046
+ console.log("[Button.click]", action, "actionPayload=", JSON.stringify(actionPayload));
2047
+ }
2045
2048
  eventBus.emit(`UI:${action}`, actionPayload ?? {});
2046
2049
  }
2047
2050
  onClick?.(e);
@@ -38248,6 +38251,16 @@ function useTraitStateMachine(traitBindings, slotsActions, options) {
38248
38251
  });
38249
38252
  }
38250
38253
  }
38254
+ const LIFECYCLE_EVENTS = /* @__PURE__ */ new Set(["INIT", "LOAD", "$MOUNT", "$UNMOUNT", "$FRAME"]);
38255
+ if (!LIFECYCLE_EVENTS.has(normalizedEvent)) {
38256
+ for (const { traitName, result } of results) {
38257
+ if (!result.executed) continue;
38258
+ eventBus.emit(normalizedEvent, payload, {
38259
+ trait: traitName,
38260
+ fromBridge: true
38261
+ });
38262
+ }
38263
+ }
38251
38264
  if (results.length > 0) {
38252
38265
  setTraitStates(currentManager.getAllStates());
38253
38266
  }
@@ -38307,6 +38320,21 @@ function useTraitStateMachine(traitBindings, slotsActions, options) {
38307
38320
  });
38308
38321
  unsubscribes.push(unsub);
38309
38322
  }
38323
+ for (const binding of traitBindings) {
38324
+ const listens = binding.trait.listens ?? [];
38325
+ for (const listen of listens) {
38326
+ const expectedTrait = listen.source?.trait;
38327
+ const unsub = eventBus.on(listen.event, (event) => {
38328
+ if (expectedTrait) {
38329
+ const emitTrait = event.source?.trait;
38330
+ if (emitTrait !== expectedTrait) return;
38331
+ }
38332
+ console.log("[TraitStateMachine] listens", binding.trait.name, listen.event, "\u2192", listen.triggers, "from", event.source?.trait);
38333
+ enqueueAndDrain(listen.triggers, event.payload);
38334
+ });
38335
+ unsubscribes.push(unsub);
38336
+ }
38337
+ }
38310
38338
  return () => {
38311
38339
  for (const unsub of unsubscribes) {
38312
38340
  unsub();
@@ -6,5 +6,32 @@
6
6
  *
7
7
  * @packageDocumentation
8
8
  */
9
- export type { TransitionFrom, ResolvedField, ResolvedEntity, ResolvedEntityBinding, ResolvedTraitState, ResolvedTraitEvent, ResolvedTraitTransition, ResolvedTraitGuard, ResolvedTraitTick, ResolvedTraitListener, ResolvedTraitDataEntity, ResolvedTraitUIBinding, ResolvedTrait, ResolvedTraitBinding, ResolvedPattern, ResolvedSectionEvent, ResolvedSection, ResolvedNavigation, ResolvedPage, ResolvedIR, } from '@almadar/core';
9
+ export type { TransitionFrom, ResolvedField, ResolvedEntity, ResolvedEntityBinding, ResolvedTraitState, ResolvedTraitEvent, ResolvedTraitTransition, ResolvedTraitGuard, ResolvedTraitTick, ResolvedTraitDataEntity, ResolvedTraitUIBinding, ResolvedTrait, ResolvedTraitBinding, ResolvedPattern, ResolvedSectionEvent, ResolvedSection, ResolvedNavigation, ResolvedPage, ResolvedIR, } from '@almadar/core';
10
+ import type { ResolvedTraitListener as CoreResolvedTraitListener } from '@almadar/core';
11
+ /**
12
+ * Listen scope descriptor carried by the resolved orb at runtime.
13
+ *
14
+ * Emitted by the compiler in the `listens[i].source` field of each
15
+ * `ResolvedTraitListener`. Core's type doesn't declare this field yet
16
+ * (@almadar/core 5.7.0) even though the Rust compiler and .lolo parser
17
+ * both populate it. We declare it here in @almadar/ui (the consumer)
18
+ * rather than modify core.
19
+ *
20
+ * - `any`: accept emits from any trait
21
+ * - `trait`: only accept emits whose `BusEvent.source.trait` matches
22
+ * - `orbital`: only accept emits whose `source.orbital[.trait?]` matches
23
+ */
24
+ export interface ListenSource {
25
+ kind?: 'any' | 'trait' | 'orbital';
26
+ trait?: string;
27
+ orbital?: string;
28
+ }
29
+ /**
30
+ * Extended `ResolvedTraitListener` carrying the runtime-only `source`
31
+ * scope descriptor that `@almadar/core`'s type hasn't picked up yet.
32
+ * Intended as a local shim until core publishes a version with `source`.
33
+ */
34
+ export type ResolvedTraitListener = CoreResolvedTraitListener & {
35
+ source?: ListenSource;
36
+ };
10
37
  export { createEmptyResolvedTrait, createEmptyResolvedPage, createResolvedField, inferTsType, isResolvedIR, } from '@almadar/core';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almadar/ui",
3
- "version": "3.6.0",
3
+ "version": "3.7.1",
4
4
  "description": "React UI components, hooks, and providers for Almadar",
5
5
  "type": "module",
6
6
  "main": "./dist/components/index.js",