@almadar/ui 4.44.0 → 4.45.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.
@@ -1,7 +1,7 @@
1
1
  import * as React135 from 'react';
2
2
  import React135__default, { createContext, useContext, useMemo, useRef, useEffect, useCallback, Suspense, useState, useLayoutEffect, lazy, useId } from 'react';
3
3
  import { EventBusContext, useTraitScope, OrbitalProvider, TraitScopeProvider, VerificationProvider } from '@almadar/ui/providers';
4
- import { createLogger } from '@almadar/logger';
4
+ import { createLogger, isLogLevelEnabled } from '@almadar/logger';
5
5
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
6
6
  import { clsx } from 'clsx';
7
7
  import { twMerge } from 'tailwind-merge';
@@ -171,7 +171,7 @@ var init_useEventBus = __esm({
171
171
  try {
172
172
  handler(event);
173
173
  } catch (error) {
174
- console.error(`[EventBus] Error in listener for '${type}':`, error);
174
+ log.error("Error in listener", { type, error: error instanceof Error ? error : String(error) });
175
175
  }
176
176
  });
177
177
  }
@@ -179,7 +179,7 @@ var init_useEventBus = __esm({
179
179
  try {
180
180
  handler(event);
181
181
  } catch (error) {
182
- console.error(`[EventBus] Error in onAny listener for '${type}':`, error);
182
+ log.error("Error in onAny listener", { type, error: error instanceof Error ? error : String(error) });
183
183
  }
184
184
  });
185
185
  },
@@ -4182,6 +4182,7 @@ var BUILT_IN_THEMES, ThemeContext;
4182
4182
  var init_ThemeContext = __esm({
4183
4183
  "context/ThemeContext.tsx"() {
4184
4184
  "use client";
4185
+ createLogger("almadar:ui:theme");
4185
4186
  BUILT_IN_THEMES = [
4186
4187
  {
4187
4188
  name: "wireframe",
@@ -7683,6 +7684,7 @@ function getAllPages(schema) {
7683
7684
  var init_navigation = __esm({
7684
7685
  "renderer/navigation.tsx"() {
7685
7686
  "use client";
7687
+ createLogger("almadar:ui:navigation");
7686
7688
  createContext(null);
7687
7689
  }
7688
7690
  });
@@ -10160,7 +10162,7 @@ function recordTransition(trace) {
10160
10162
  ...trace,
10161
10163
  id: `t-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`
10162
10164
  };
10163
- log2.info("transition:recorded", { trait: trace.traitName, from: trace.from, to: trace.to, event: trace.event, effectCount: trace.effects.length });
10165
+ log5.debug("transition:recorded", { trait: trace.traitName, from: trace.from, to: trace.to, event: trace.event, effectCount: trace.effects.length });
10164
10166
  getState().transitions.push(entry);
10165
10167
  if (getState().transitions.length > MAX_TRANSITIONS) {
10166
10168
  getState().transitions.shift();
@@ -10259,7 +10261,7 @@ function getTraitSnapshots() {
10259
10261
  try {
10260
10262
  snapshots.push(getter());
10261
10263
  } catch (err) {
10262
- log2.error("traitSnapshot getter failed", { trait: traitName, err: String(err) });
10264
+ log5.error("traitSnapshot getter failed", { trait: traitName, err: String(err) });
10263
10265
  }
10264
10266
  }
10265
10267
  return snapshots;
@@ -10343,10 +10345,10 @@ function updateAssetStatus(url, status) {
10343
10345
  window.__orbitalVerification.assetStatus[url] = status;
10344
10346
  }
10345
10347
  }
10346
- var log2, MAX_TRANSITIONS;
10348
+ var log5, MAX_TRANSITIONS;
10347
10349
  var init_verificationRegistry = __esm({
10348
10350
  "lib/verificationRegistry.ts"() {
10349
- log2 = createLogger("almadar:bridge");
10351
+ log5 = createLogger("almadar:bridge");
10350
10352
  MAX_TRANSITIONS = 500;
10351
10353
  exposeOnWindow();
10352
10354
  }
@@ -12374,7 +12376,7 @@ var init_avl_elk_layout = __esm({
12374
12376
  elk = new ELK();
12375
12377
  }
12376
12378
  });
12377
- var SWIM_GUTTER, CENTER_W, BehaviorView;
12379
+ var log6, SWIM_GUTTER, CENTER_W, BehaviorView;
12378
12380
  var init_BehaviorView = __esm({
12379
12381
  "components/molecules/avl/BehaviorView.tsx"() {
12380
12382
  "use client";
@@ -12383,6 +12385,7 @@ var init_BehaviorView = __esm({
12383
12385
  init_AvlSwimLane();
12384
12386
  init_types();
12385
12387
  init_avl_elk_layout();
12388
+ log6 = createLogger("almadar:ui:avl:behavior-view");
12386
12389
  SWIM_GUTTER = 120;
12387
12390
  CENTER_W = 360;
12388
12391
  BehaviorView = ({ data }) => {
@@ -12392,7 +12395,7 @@ var init_BehaviorView = __esm({
12392
12395
  const dataKey = useMemo(() => JSON.stringify(traitData), [traitData]);
12393
12396
  useEffect(() => {
12394
12397
  if (!traitData) return;
12395
- computeTraitLayout(traitData).then(setLayout).catch(console.error);
12398
+ computeTraitLayout(traitData).then(setLayout).catch((err) => log6.error("compute-trait-layout-failed", { error: err instanceof Error ? err : String(err) }));
12396
12399
  }, [dataKey]);
12397
12400
  if (!traitData) {
12398
12401
  return /* @__PURE__ */ jsx("div", { className: "rounded-lg border border-[var(--color-border)] bg-[var(--color-card)] p-4 text-center text-[var(--color-muted-foreground)] text-sm", children: "No trait data" });
@@ -12737,7 +12740,7 @@ function computeFoldRegions(code) {
12737
12740
  }
12738
12741
  return regions.sort((a, b) => a.start - b.start);
12739
12742
  }
12740
- var orbStyleOverrides, orbStyle, loloStyleOverrides, loloStyle, LINE_PROPS_FN, HIDDEN_LINE_NUMBERS, CodeBlock;
12743
+ var orbStyleOverrides, orbStyle, loloStyleOverrides, loloStyle, log7, LINE_PROPS_FN, HIDDEN_LINE_NUMBERS, CodeBlock;
12741
12744
  var init_CodeBlock = __esm({
12742
12745
  "components/molecules/markdown/CodeBlock.tsx"() {
12743
12746
  init_Box();
@@ -12814,6 +12817,7 @@ var init_CodeBlock = __esm({
12814
12817
  "lolo-op-async": { color: ORB_COLORS.dark.async }
12815
12818
  };
12816
12819
  loloStyle = { ...dark, ...loloStyleOverrides };
12820
+ log7 = createLogger("almadar:ui:markdown-code");
12817
12821
  LINE_PROPS_FN = (n) => ({ "data-line": String(n - 1) });
12818
12822
  HIDDEN_LINE_NUMBERS = { display: "none" };
12819
12823
  CodeBlock = React135__default.memo(
@@ -13012,7 +13016,7 @@ var init_CodeBlock = __esm({
13012
13016
  eventBus.emit("UI:COPY_CODE", { language, success: true });
13013
13017
  setTimeout(() => setCopied(false), 2e3);
13014
13018
  } catch (err) {
13015
- console.error("Failed to copy code:", err);
13019
+ log7.error("Failed to copy code", { error: err instanceof Error ? err : String(err) });
13016
13020
  eventBus.emit("UI:COPY_CODE", { language, success: false });
13017
13021
  }
13018
13022
  };
@@ -16524,13 +16528,14 @@ function useSafeEventBus2() {
16524
16528
  } };
16525
16529
  }
16526
16530
  }
16527
- var ButtonGroup;
16531
+ var log8, ButtonGroup;
16528
16532
  var init_ButtonGroup = __esm({
16529
16533
  "components/molecules/ButtonGroup.tsx"() {
16530
16534
  "use client";
16531
16535
  init_cn();
16532
16536
  init_atoms();
16533
16537
  init_useEventBus();
16538
+ log8 = createLogger("almadar:ui:button-group");
16534
16539
  ButtonGroup = ({
16535
16540
  children,
16536
16541
  primary,
@@ -16603,7 +16608,7 @@ var init_ButtonGroup = __esm({
16603
16608
  {
16604
16609
  variant: "ghost",
16605
16610
  onClick: () => {
16606
- console.log(`Filter clicked: ${filter.field}`);
16611
+ log8.debug("Filter clicked", { field: filter.field });
16607
16612
  },
16608
16613
  children: filter.label
16609
16614
  },
@@ -22475,31 +22480,56 @@ var init_InputGroup = __esm({
22475
22480
  InputGroup.displayName = "InputGroup";
22476
22481
  }
22477
22482
  });
22478
-
22479
- // lib/debug.ts
22483
+ function gateEnabled(level, ns = NAMESPACE) {
22484
+ return isLogLevelEnabled(level, ns);
22485
+ }
22480
22486
  function isDebugEnabled() {
22481
- if (DEBUG_ENABLED) return true;
22482
- return typeof window !== "undefined" && window.__ALMADAR_DEBUG_VERIFY__ === true;
22487
+ return gateEnabled("DEBUG");
22483
22488
  }
22484
22489
  function debug(...args) {
22485
- if (isDebugEnabled()) {
22486
- console.log("[DEBUG]", ...args);
22490
+ if (!gateEnabled("DEBUG")) return;
22491
+ const [first, ...rest] = args;
22492
+ const message = typeof first === "string" ? first : "<debug>";
22493
+ if (rest.length === 0 && typeof first === "string") {
22494
+ log9.debug(message);
22495
+ } else {
22496
+ log9.debug(message, { args: rest.length > 0 ? formatArgs(rest) : formatArgs([first]) });
22487
22497
  }
22488
22498
  }
22489
22499
  function debugGroup(label) {
22490
- if (isDebugEnabled()) {
22491
- console.group(`[DEBUG] ${label}`);
22492
- }
22500
+ if (gateEnabled("DEBUG")) console.group(`[${NAMESPACE}] ${label}`);
22493
22501
  }
22494
22502
  function debugGroupEnd() {
22495
- if (isDebugEnabled()) {
22496
- console.groupEnd();
22503
+ if (gateEnabled("DEBUG")) console.groupEnd();
22504
+ }
22505
+ function formatArgs(values) {
22506
+ if (values.length === 1) return toLogMetaValue(values[0]);
22507
+ return values.map(toLogMetaValue);
22508
+ }
22509
+ function toLogMetaValue(v) {
22510
+ if (v === null || v === void 0) return v;
22511
+ if (v instanceof Error) return v;
22512
+ const t = typeof v;
22513
+ if (t === "string" || t === "number" || t === "boolean") return v;
22514
+ if (Array.isArray(v)) return v.map(toLogMetaValue);
22515
+ if (t === "object") {
22516
+ const out = {};
22517
+ for (const [k, val] of Object.entries(v)) {
22518
+ out[k] = toLogMetaValue(val);
22519
+ }
22520
+ return out;
22497
22521
  }
22522
+ return String(v);
22498
22523
  }
22499
- var DEBUG_ENABLED;
22524
+ var NAMESPACE, log9;
22500
22525
  var init_debug = __esm({
22501
22526
  "lib/debug.ts"() {
22502
- DEBUG_ENABLED = typeof window !== "undefined" && (localStorage.getItem("debug") === "true" || process.env.NODE_ENV === "development");
22527
+ NAMESPACE = "almadar:ui:debug";
22528
+ log9 = createLogger(NAMESPACE);
22529
+ createLogger("almadar:ui:debug:input");
22530
+ createLogger("almadar:ui:debug:collision");
22531
+ createLogger("almadar:ui:debug:physics");
22532
+ createLogger("almadar:ui:debug:game-state");
22503
22533
  }
22504
22534
  });
22505
22535
  var isRelationsDebugEnabled, RelationSelect;
@@ -38737,7 +38767,7 @@ function getAllEvents(traits2) {
38737
38767
  }
38738
38768
  function EventDispatcherTab({ traits: traits2, schema }) {
38739
38769
  const eventBus = useEventBus();
38740
- const [log3, setLog] = React135.useState([]);
38770
+ const [log11, setLog] = React135.useState([]);
38741
38771
  const prevStatesRef = React135.useRef(/* @__PURE__ */ new Map());
38742
38772
  React135.useEffect(() => {
38743
38773
  for (const trait of traits2) {
@@ -38801,9 +38831,9 @@ function EventDispatcherTab({ traits: traits2, schema }) {
38801
38831
  /* @__PURE__ */ jsx(Typography, { variant: "small", weight: "medium", className: "text-gray-500 mb-1", children: "Other Events (not available from current state)" }),
38802
38832
  /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1", children: unavailableEvents.map((event) => /* @__PURE__ */ jsx(Badge, { variant: "default", size: "sm", className: "opacity-50", children: event }, event)) })
38803
38833
  ] }),
38804
- log3.length > 0 && /* @__PURE__ */ jsxs("div", { children: [
38834
+ log11.length > 0 && /* @__PURE__ */ jsxs("div", { children: [
38805
38835
  /* @__PURE__ */ jsx(Typography, { variant: "small", weight: "medium", className: "text-gray-500 mb-1", children: "Recent Transitions" }),
38806
- /* @__PURE__ */ jsx(Stack, { gap: "xs", children: log3.map((entry, i) => /* @__PURE__ */ jsxs(Typography, { variant: "small", className: "font-mono text-xs", children: [
38836
+ /* @__PURE__ */ jsx(Stack, { gap: "xs", children: log11.map((entry, i) => /* @__PURE__ */ jsxs(Typography, { variant: "small", className: "font-mono text-xs", children: [
38807
38837
  /* @__PURE__ */ jsx("span", { className: "text-purple-400", children: entry.traitName }),
38808
38838
  " ",
38809
38839
  /* @__PURE__ */ jsx("span", { className: "text-gray-500", children: entry.from }),
@@ -43730,7 +43760,7 @@ function MaybeTraitScope({
43730
43760
  const schemaCtx = useEntitySchemaOptional();
43731
43761
  const orbital = sourceTrait !== void 0 && schemaCtx !== null ? schemaCtx.orbitalsByTrait.get(sourceTrait) : void 0;
43732
43762
  const wrap = sourceTrait !== void 0 && orbital !== void 0;
43733
- scopeWrapLog.info("decide", {
43763
+ scopeWrapLog.debug("decide", {
43734
43764
  sourceTrait,
43735
43765
  schemaCtxPresent: schemaCtx !== null,
43736
43766
  orbitalsByTraitSize: schemaCtx?.orbitalsByTrait.size ?? 0,
@@ -44351,8 +44381,7 @@ var init_UISlotRenderer = __esm({
44351
44381
 
44352
44382
  // hooks/index.ts
44353
44383
  init_useEventBus();
44354
-
44355
- // runtime/createClientEffectHandlers.ts
44384
+ var log2 = createLogger("almadar:ui:effects:client-handlers");
44356
44385
  function createClientEffectHandlers(options) {
44357
44386
  const { eventBus, slotSetter, navigate, notify, callService } = options;
44358
44387
  return {
@@ -44361,10 +44390,10 @@ function createClientEffectHandlers(options) {
44361
44390
  eventBus.emit(prefixedEvent, payload);
44362
44391
  },
44363
44392
  persist: async () => {
44364
- console.warn("[ClientEffectHandlers] persist is server-side only, ignored on client");
44393
+ log2.warn("persist is server-side only, ignored on client");
44365
44394
  },
44366
44395
  set: () => {
44367
- console.warn("[ClientEffectHandlers] set is server-side only, ignored on client");
44396
+ log2.warn("set is server-side only, ignored on client");
44368
44397
  },
44369
44398
  callService: async (service, action, params) => {
44370
44399
  if (callService) return callService(service, action, params);
@@ -44393,10 +44422,10 @@ function createClientEffectHandlers(options) {
44393
44422
  slotSetter.addPattern(slot, pattern, props);
44394
44423
  },
44395
44424
  navigate: navigate ?? ((path) => {
44396
- console.warn("[ClientEffectHandlers] No navigate handler, ignoring:", path);
44425
+ log2.warn("No navigate handler, ignoring", { path });
44397
44426
  }),
44398
44427
  notify: notify ?? ((msg, type) => {
44399
- console.log(`[ClientEffectHandlers] notify (${type}):`, msg);
44428
+ log2.debug("notify", { type, message: msg });
44400
44429
  })
44401
44430
  };
44402
44431
  }
@@ -44571,7 +44600,7 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
44571
44600
  const slots = uiSlotsRef.current;
44572
44601
  const embedded = embeddedTraitsRef.current;
44573
44602
  if (patterns.length === 0) {
44574
- flushLog.info("clear", { traitName, slot });
44603
+ flushLog.debug("clear", { traitName, slot });
44575
44604
  slots.clearBySource(slot, traitName);
44576
44605
  return;
44577
44606
  }
@@ -44586,7 +44615,7 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
44586
44615
  const props = convertFnFormLambdasInProps(rawProps);
44587
44616
  const isEmbedded = embedded?.has(traitName) ?? false;
44588
44617
  if (isEmbedded) {
44589
- flushLog.info("embed-route", {
44618
+ flushLog.debug("embed-route", {
44590
44619
  traitName,
44591
44620
  slot,
44592
44621
  patternType: typeof patternType === "string" ? patternType : void 0,
@@ -44600,12 +44629,12 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
44600
44629
  });
44601
44630
  return;
44602
44631
  }
44603
- flushLog.info("slot-render", {
44632
+ flushLog.debug("slot-render", () => ({
44604
44633
  traitName,
44605
44634
  slot,
44606
44635
  patternType: typeof patternType === "string" ? patternType : void 0,
44607
44636
  embedded: Array.from(embedded ?? [])
44608
- });
44637
+ }));
44609
44638
  slots.render({
44610
44639
  target: slot,
44611
44640
  pattern: patternType,
@@ -44699,10 +44728,9 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
44699
44728
  });
44700
44729
  snapshotUnregs.push(unreg);
44701
44730
  }
44702
- console.log(
44703
- "[TraitStateMachine] Reset states for page navigation:",
44704
- Array.from(newManager.getAllStates().keys()).join(", ")
44705
- );
44731
+ stateLog.debug("reset-states-for-nav", () => ({
44732
+ traits: Array.from(newManager.getAllStates().keys()).join(", ")
44733
+ }));
44706
44734
  return () => {
44707
44735
  for (const unreg of snapshotUnregs) unreg();
44708
44736
  };
@@ -44789,13 +44817,13 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
44789
44817
  const normalizedEvent = normalizeEventKey(eventKey);
44790
44818
  const bindings = traitBindingsRef.current;
44791
44819
  const currentManager = managerRef.current;
44792
- console.log("[TraitStateMachine] Processing event:", normalizedEvent, "payload:", payload);
44793
- crossTraitLog.debug("processEvent:enter", {
44820
+ crossTraitLog.debug("processEvent:enter", () => ({
44794
44821
  event: normalizedEvent,
44822
+ payload: JSON.stringify(payload ?? null),
44795
44823
  traitCount: bindings.length,
44796
44824
  traitNames: bindings.map((b) => b.trait.name).join(","),
44797
44825
  orbitalsByTrait: JSON.stringify(orbitalsByTrait ?? null)
44798
- });
44826
+ }));
44799
44827
  const bindingMap = new Map(bindings.map((b) => [b.trait.name, b]));
44800
44828
  const entityByTrait = {};
44801
44829
  for (const [name, fields] of traitFieldStatesRef.current) {
@@ -44850,18 +44878,13 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
44850
44878
  }
44851
44879
  }
44852
44880
  if (result.executed && result.effects.length > 0) {
44853
- console.log(
44854
- "[TraitStateMachine] Executing",
44855
- result.effects.length,
44856
- "effects for",
44881
+ stateLog.debug("executing-effects", () => ({
44882
+ effectCount: result.effects.length,
44857
44883
  traitName,
44858
- "| linkedEntity:",
44859
- binding.linkedEntity,
44860
- "| transition:",
44861
- `${result.previousState} -> ${result.newState}`,
44862
- "| effects:",
44863
- JSON.stringify(result.effects)
44864
- );
44884
+ linkedEntity: binding.linkedEntity,
44885
+ transition: `${result.previousState} -> ${result.newState}`,
44886
+ effects: JSON.stringify(result.effects)
44887
+ }));
44865
44888
  const linkedEntity = binding.linkedEntity || "";
44866
44889
  const entityId = payload?.entityId;
44867
44890
  const pendingSlots = /* @__PURE__ */ new Map();
@@ -44981,7 +45004,7 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
44981
45004
  const executor = new EffectExecutor({ handlers: trackingHandlers, bindings: bindingCtx, context: effectContext });
44982
45005
  try {
44983
45006
  await executor.executeAll(result.effects);
44984
- stateLog.info("transition:render-ui-dispatched", {
45007
+ stateLog.debug("transition:render-ui-dispatched", () => ({
44985
45008
  traitName,
44986
45009
  fromState: result.previousState,
44987
45010
  toState: result.newState,
@@ -44990,7 +45013,7 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
44990
45013
  patternTypes: Array.from(pendingSlots.entries()).map(
44991
45014
  ([slot, patterns]) => `${slot}:[${patterns.map((p2) => p2.pattern?.type ?? "null").join(",")}]`
44992
45015
  ).join(";")
44993
- });
45016
+ }));
44994
45017
  void slotSource;
44995
45018
  for (const [slot, patterns] of pendingSlots) {
44996
45019
  flushSlot(traitName, slot, patterns);
@@ -45007,30 +45030,25 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
45007
45030
  }
45008
45031
  } else if (!result.executed) {
45009
45032
  if (result.guardResult === false) {
45010
- console.log(
45011
- "[TraitStateMachine] Guard blocked transition:",
45033
+ stateLog.debug("guard-blocked-transition", {
45012
45034
  traitName,
45013
- result.previousState,
45014
- "->",
45015
- result.transition?.to
45016
- );
45035
+ from: result.previousState,
45036
+ to: result.transition?.to
45037
+ });
45017
45038
  } else if (!result.transition) {
45018
45039
  if (isCircuitEvent(normalizedEvent)) {
45019
- console.warn(
45020
- `[CLOSED CIRCUIT VIOLATION] Trait "${traitName}" in state "${traitState.currentState}" received event "${normalizedEvent}" but has no transition to handle it.
45021
- This is likely a schema issue. To fix, add a transition:
45022
- { from: "${traitState.currentState}", to: "<target_state>", event: "${normalizedEvent}", effects: [...] }
45023
- Or ensure the previous action (that opened this UI) properly transitions back before emitting this event.`
45024
- );
45040
+ stateLog.warn("closed-circuit-violation", {
45041
+ traitName,
45042
+ currentState: traitState.currentState,
45043
+ event: normalizedEvent,
45044
+ remediation: `Add transition { from: "${traitState.currentState}", to: "<target_state>", event: "${normalizedEvent}", effects: [...] } \u2014 or ensure the previous action (that opened this UI) transitions back before emitting.`
45045
+ });
45025
45046
  } else {
45026
- console.log(
45027
- "[TraitStateMachine] No transition for",
45047
+ stateLog.debug("no-transition", {
45028
45048
  traitName,
45029
- "from state:",
45030
- traitState.currentState,
45031
- "on event:",
45032
- normalizedEvent
45033
- );
45049
+ from: traitState.currentState,
45050
+ event: normalizedEvent
45051
+ });
45034
45052
  }
45035
45053
  }
45036
45054
  }
@@ -45138,7 +45156,7 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
45138
45156
  allEvents.add(transition.event);
45139
45157
  }
45140
45158
  }
45141
- console.log("[TraitStateMachine] Subscribing to events:", Array.from(allEvents));
45159
+ stateLog.debug("subscribing-to-events", () => ({ events: Array.from(allEvents) }));
45142
45160
  const unsubscribes = [];
45143
45161
  const subscribedBusKeys = /* @__PURE__ */ new Set();
45144
45162
  for (const binding of traitBindings) {
@@ -45159,7 +45177,7 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
45159
45177
  crossTraitLog.debug("self:fire-skipped-bridge-echo", { traitName, busKey: selfBusKey, eventKey });
45160
45178
  return;
45161
45179
  }
45162
- crossTraitLog.info("self:fire", { traitName, busKey: selfBusKey, eventKey });
45180
+ crossTraitLog.debug("self:fire", { traitName, busKey: selfBusKey, eventKey });
45163
45181
  enqueueAndDrain(eventKey, event.payload);
45164
45182
  });
45165
45183
  unsubscribes.push(() => {
@@ -45185,7 +45203,7 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
45185
45203
  const busKey = `UI:${sourceOrbital}.${sourceTrait}.${listen.event}`;
45186
45204
  crossTraitLog.debug("listen:subscribed", { busKey, targetTrait: binding.trait.name, sourceOrbital, sourceTrait, listenEvent: listen.event, triggers: listen.triggers });
45187
45205
  const unsub = eventBus.on(busKey, (event) => {
45188
- crossTraitLog.info("listen:fired", { busKey, targetTrait: binding.trait.name, triggers: listen.triggers });
45206
+ crossTraitLog.debug("listen:fired", { busKey, targetTrait: binding.trait.name, triggers: listen.triggers });
45189
45207
  enqueueAndDrain(listen.triggers, event.payload);
45190
45208
  });
45191
45209
  unsubscribes.push(() => {
@@ -45273,7 +45291,11 @@ function useResolvedSchema(schema, pageName) {
45273
45291
  };
45274
45292
  }
45275
45293
  const page = getPage(ir, pageName);
45276
- console.log("[useResolvedSchema] Resolved page:", page?.name, "| path:", page?.path, "| traits:", page?.traits.length);
45294
+ resolvedSchemaLog.debug("Resolved page", () => ({
45295
+ name: page?.name,
45296
+ path: page?.path,
45297
+ traits: page?.traits.length
45298
+ }));
45277
45299
  const traits2 = page?.traits || [];
45278
45300
  const entities = /* @__PURE__ */ new Map();
45279
45301
  if (page) {
@@ -45300,6 +45322,7 @@ function clearSchemaCache() {
45300
45322
 
45301
45323
  // runtime/index.ts
45302
45324
  init_EntitySchemaContext();
45325
+ var log10 = createLogger("almadar:ui:trait-provider");
45303
45326
  var TraitContext = createContext(null);
45304
45327
  function TraitProvider({
45305
45328
  traits: traitBindings,
@@ -45316,7 +45339,11 @@ function TraitProvider({
45316
45339
  currentState: stateName,
45317
45340
  availableEvents: trait.transitions.filter((t) => t.from === stateName).map((t) => t.event),
45318
45341
  dispatch: (eventKey, payload) => {
45319
- console.log(`[TraitProvider] Dispatch to ${trait.name}: ${eventKey}`, payload);
45342
+ log10.debug("Dispatch", () => ({
45343
+ trait: trait.name,
45344
+ event: eventKey,
45345
+ payloadKeys: payload ? Object.keys(payload) : []
45346
+ }));
45320
45347
  },
45321
45348
  canDispatch: (eventKey) => {
45322
45349
  return trait.transitions.some(
@@ -45444,6 +45471,7 @@ init_EntitySchemaContext();
45444
45471
  // runtime/ServerBridge.tsx
45445
45472
  init_useEventBus();
45446
45473
  var xOrbitalLog = createLogger("almadar:runtime:cross-orbital");
45474
+ var serverBridgeLog = createLogger("almadar:ui:server-bridge");
45447
45475
  function createHttpTransport(serverUrl) {
45448
45476
  return {
45449
45477
  register: async (schema) => {
@@ -45456,7 +45484,7 @@ function createHttpTransport(serverUrl) {
45456
45484
  const result = await res.json();
45457
45485
  return !!result.success;
45458
45486
  } catch (err) {
45459
- console.error("[ServerBridge] Registration failed:", err);
45487
+ serverBridgeLog.error("Registration failed", { error: err instanceof Error ? err : String(err) });
45460
45488
  return false;
45461
45489
  }
45462
45490
  },
@@ -45719,7 +45747,7 @@ function applyServerEffects(effects, uiSlots, onNavigate, embeddedTraits) {
45719
45747
  };
45720
45748
  const props = convertFnFormLambdasInProps(rawProps);
45721
45749
  if (isEmbedded) {
45722
- xOrbitalLog2.info("slot:embed-routed", {
45750
+ xOrbitalLog2.debug("slot:embed-routed", {
45723
45751
  sourceTrait,
45724
45752
  slot: eff.slot,
45725
45753
  patternType: typeof patternType === "string" ? patternType : void 0
@@ -45731,7 +45759,7 @@ function applyServerEffects(effects, uiSlots, onNavigate, embeddedTraits) {
45731
45759
  animation: "fade"
45732
45760
  });
45733
45761
  } else {
45734
- xOrbitalLog2.info("slot-write", {
45762
+ xOrbitalLog2.debug("slot-write", {
45735
45763
  slot: eff.slot,
45736
45764
  sourceTrait,
45737
45765
  patternType: typeof patternType === "string" ? patternType : void 0
@@ -45754,12 +45782,12 @@ function TraitInitializer({ traits: traits2, orbitalNames, onNavigate, onLocalFa
45754
45782
  const onEventProcessed = useCallback(async (event, payload, dispatchedOrbitals) => {
45755
45783
  if (!bridge.connected || !orbitalNames?.length) return;
45756
45784
  const targets = dispatchedOrbitals && dispatchedOrbitals.size > 0 ? orbitalNames.filter((n) => dispatchedOrbitals.has(n)) : orbitalNames;
45757
- xOrbitalLog2.info("TraitInitializer:fanout", {
45785
+ xOrbitalLog2.debug("TraitInitializer:fanout", () => ({
45758
45786
  event,
45759
45787
  sentTo: targets,
45760
45788
  skipped: orbitalNames.filter((n) => !targets.includes(n)),
45761
45789
  dispatchedOrbitalsSize: dispatchedOrbitals?.size ?? 0
45762
- });
45790
+ }));
45763
45791
  for (const name of targets) {
45764
45792
  const { effects, meta } = await bridge.sendEvent(name, event, payload);
45765
45793
  recordServerResponse(name, event, meta);
@@ -45772,7 +45800,7 @@ function TraitInitializer({ traits: traits2, orbitalNames, onNavigate, onLocalFa
45772
45800
  useEffect(() => {
45773
45801
  const traitNames = traits2.map((b) => b.trait?.name ?? "").filter(Boolean).sort().join(",");
45774
45802
  if (prevTraitNamesRef.current && prevTraitNamesRef.current !== traitNames) {
45775
- navLog.info("page:trait-set-changed", {
45803
+ navLog.debug("page:trait-set-changed", {
45776
45804
  from: prevTraitNamesRef.current,
45777
45805
  to: traitNames,
45778
45806
  action: "clearAll-slots"
@@ -46039,11 +46067,11 @@ function OrbPreview({
46039
46067
  }, [initialPageName, currentPage]);
46040
46068
  const handleNavigate = useCallback((path) => {
46041
46069
  const match = pages.find(({ page }) => page.path === path);
46042
- navLog.info("handleNavigate", {
46070
+ navLog.debug("handleNavigate", () => ({
46043
46071
  path,
46044
46072
  matched: match?.page.name ?? null,
46045
46073
  availablePaths: pages.map((p2) => p2.page.path)
46046
- });
46074
+ }));
46047
46075
  if (match) {
46048
46076
  setCurrentPage(match.page.name);
46049
46077
  if (typeof window !== "undefined") {
@@ -46065,19 +46093,19 @@ function OrbPreview({
46065
46093
  const el = containerRef.current;
46066
46094
  if (!el) return;
46067
46095
  if (pages.length <= 1) {
46068
- navLog.info("interceptor:skipped", { reason: "single-page schema", pageCount: pages.length });
46096
+ navLog.debug("interceptor:skipped", { reason: "single-page schema", pageCount: pages.length });
46069
46097
  return;
46070
46098
  }
46071
46099
  const handler = (e) => {
46072
46100
  const anchor = e.target.closest("a");
46073
46101
  if (!anchor) return;
46074
46102
  const href = anchor.getAttribute("href") ?? anchor.getAttribute("to") ?? "";
46075
- navLog.info("click:intercepted", {
46103
+ navLog.debug("click:intercepted", {
46076
46104
  href,
46077
46105
  anchorText: anchor.textContent?.trim().slice(0, 40)
46078
46106
  });
46079
46107
  if (!href || href.startsWith("http") || href.startsWith("mailto:") || href.startsWith("#")) {
46080
- navLog.info("click:skipped", { href, reason: "external/empty/hash" });
46108
+ navLog.debug("click:skipped", { href, reason: "external/empty/hash" });
46081
46109
  return;
46082
46110
  }
46083
46111
  e.preventDefault();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almadar/ui",
3
- "version": "4.44.0",
3
+ "version": "4.45.0",
4
4
  "description": "React UI components, hooks, and providers for Almadar",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -131,9 +131,9 @@
131
131
  "dependencies": {
132
132
  "@almadar/core": ">=7.13.0",
133
133
  "@almadar/evaluator": ">=2.9.2",
134
- "@almadar/logger": ">=1.1.0",
134
+ "@almadar/logger": "^1.3.0",
135
135
  "@almadar/patterns": "^2.26.0",
136
- "@almadar/runtime": ">=6.4.0",
136
+ "@almadar/runtime": "^6.4.1",
137
137
  "@almadar/std": ">=6.4.1",
138
138
  "@almadar/syntax": ">=1.3.1",
139
139
  "@xyflow/react": "12.10.1",