@almadar/ui 4.44.1 → 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.
@@ -217,7 +217,7 @@ var init_useEventBus = __esm({
217
217
  try {
218
218
  handler(event);
219
219
  } catch (error) {
220
- console.error(`[EventBus] Error in listener for '${type}':`, error);
220
+ log.error("Error in listener", { type, error: error instanceof Error ? error : String(error) });
221
221
  }
222
222
  });
223
223
  }
@@ -225,7 +225,7 @@ var init_useEventBus = __esm({
225
225
  try {
226
226
  handler(event);
227
227
  } catch (error) {
228
- console.error(`[EventBus] Error in onAny listener for '${type}':`, error);
228
+ log.error("Error in onAny listener", { type, error: error instanceof Error ? error : String(error) });
229
229
  }
230
230
  });
231
231
  },
@@ -4228,6 +4228,7 @@ var BUILT_IN_THEMES, ThemeContext;
4228
4228
  var init_ThemeContext = __esm({
4229
4229
  "context/ThemeContext.tsx"() {
4230
4230
  "use client";
4231
+ logger.createLogger("almadar:ui:theme");
4231
4232
  BUILT_IN_THEMES = [
4232
4233
  {
4233
4234
  name: "wireframe",
@@ -7729,6 +7730,7 @@ function getAllPages(schema) {
7729
7730
  var init_navigation = __esm({
7730
7731
  "renderer/navigation.tsx"() {
7731
7732
  "use client";
7733
+ logger.createLogger("almadar:ui:navigation");
7732
7734
  React135.createContext(null);
7733
7735
  }
7734
7736
  });
@@ -10206,7 +10208,7 @@ function recordTransition(trace) {
10206
10208
  ...trace,
10207
10209
  id: `t-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`
10208
10210
  };
10209
- log2.debug("transition:recorded", { trait: trace.traitName, from: trace.from, to: trace.to, event: trace.event, effectCount: trace.effects.length });
10211
+ log5.debug("transition:recorded", { trait: trace.traitName, from: trace.from, to: trace.to, event: trace.event, effectCount: trace.effects.length });
10210
10212
  getState().transitions.push(entry);
10211
10213
  if (getState().transitions.length > MAX_TRANSITIONS) {
10212
10214
  getState().transitions.shift();
@@ -10305,7 +10307,7 @@ function getTraitSnapshots() {
10305
10307
  try {
10306
10308
  snapshots.push(getter());
10307
10309
  } catch (err) {
10308
- log2.error("traitSnapshot getter failed", { trait: traitName, err: String(err) });
10310
+ log5.error("traitSnapshot getter failed", { trait: traitName, err: String(err) });
10309
10311
  }
10310
10312
  }
10311
10313
  return snapshots;
@@ -10389,10 +10391,10 @@ function updateAssetStatus(url, status) {
10389
10391
  window.__orbitalVerification.assetStatus[url] = status;
10390
10392
  }
10391
10393
  }
10392
- var log2, MAX_TRANSITIONS;
10394
+ var log5, MAX_TRANSITIONS;
10393
10395
  var init_verificationRegistry = __esm({
10394
10396
  "lib/verificationRegistry.ts"() {
10395
- log2 = logger.createLogger("almadar:bridge");
10397
+ log5 = logger.createLogger("almadar:bridge");
10396
10398
  MAX_TRANSITIONS = 500;
10397
10399
  exposeOnWindow();
10398
10400
  }
@@ -12420,7 +12422,7 @@ var init_avl_elk_layout = __esm({
12420
12422
  elk = new ELK__default.default();
12421
12423
  }
12422
12424
  });
12423
- var SWIM_GUTTER, CENTER_W, BehaviorView;
12425
+ var log6, SWIM_GUTTER, CENTER_W, BehaviorView;
12424
12426
  var init_BehaviorView = __esm({
12425
12427
  "components/molecules/avl/BehaviorView.tsx"() {
12426
12428
  "use client";
@@ -12429,6 +12431,7 @@ var init_BehaviorView = __esm({
12429
12431
  init_AvlSwimLane();
12430
12432
  init_types();
12431
12433
  init_avl_elk_layout();
12434
+ log6 = logger.createLogger("almadar:ui:avl:behavior-view");
12432
12435
  SWIM_GUTTER = 120;
12433
12436
  CENTER_W = 360;
12434
12437
  BehaviorView = ({ data }) => {
@@ -12438,7 +12441,7 @@ var init_BehaviorView = __esm({
12438
12441
  const dataKey = React135.useMemo(() => JSON.stringify(traitData), [traitData]);
12439
12442
  React135.useEffect(() => {
12440
12443
  if (!traitData) return;
12441
- computeTraitLayout(traitData).then(setLayout).catch(console.error);
12444
+ computeTraitLayout(traitData).then(setLayout).catch((err) => log6.error("compute-trait-layout-failed", { error: err instanceof Error ? err : String(err) }));
12442
12445
  }, [dataKey]);
12443
12446
  if (!traitData) {
12444
12447
  return /* @__PURE__ */ jsxRuntime.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" });
@@ -12783,7 +12786,7 @@ function computeFoldRegions(code) {
12783
12786
  }
12784
12787
  return regions.sort((a, b) => a.start - b.start);
12785
12788
  }
12786
- var orbStyleOverrides, orbStyle, loloStyleOverrides, loloStyle, LINE_PROPS_FN, HIDDEN_LINE_NUMBERS, CodeBlock;
12789
+ var orbStyleOverrides, orbStyle, loloStyleOverrides, loloStyle, log7, LINE_PROPS_FN, HIDDEN_LINE_NUMBERS, CodeBlock;
12787
12790
  var init_CodeBlock = __esm({
12788
12791
  "components/molecules/markdown/CodeBlock.tsx"() {
12789
12792
  init_Box();
@@ -12860,6 +12863,7 @@ var init_CodeBlock = __esm({
12860
12863
  "lolo-op-async": { color: syntax.ORB_COLORS.dark.async }
12861
12864
  };
12862
12865
  loloStyle = { ...dark__default.default, ...loloStyleOverrides };
12866
+ log7 = logger.createLogger("almadar:ui:markdown-code");
12863
12867
  LINE_PROPS_FN = (n) => ({ "data-line": String(n - 1) });
12864
12868
  HIDDEN_LINE_NUMBERS = { display: "none" };
12865
12869
  CodeBlock = React135__namespace.default.memo(
@@ -13058,7 +13062,7 @@ var init_CodeBlock = __esm({
13058
13062
  eventBus.emit("UI:COPY_CODE", { language, success: true });
13059
13063
  setTimeout(() => setCopied(false), 2e3);
13060
13064
  } catch (err) {
13061
- console.error("Failed to copy code:", err);
13065
+ log7.error("Failed to copy code", { error: err instanceof Error ? err : String(err) });
13062
13066
  eventBus.emit("UI:COPY_CODE", { language, success: false });
13063
13067
  }
13064
13068
  };
@@ -16570,13 +16574,14 @@ function useSafeEventBus2() {
16570
16574
  } };
16571
16575
  }
16572
16576
  }
16573
- var ButtonGroup;
16577
+ var log8, ButtonGroup;
16574
16578
  var init_ButtonGroup = __esm({
16575
16579
  "components/molecules/ButtonGroup.tsx"() {
16576
16580
  "use client";
16577
16581
  init_cn();
16578
16582
  init_atoms();
16579
16583
  init_useEventBus();
16584
+ log8 = logger.createLogger("almadar:ui:button-group");
16580
16585
  ButtonGroup = ({
16581
16586
  children,
16582
16587
  primary,
@@ -16649,7 +16654,7 @@ var init_ButtonGroup = __esm({
16649
16654
  {
16650
16655
  variant: "ghost",
16651
16656
  onClick: () => {
16652
- console.log(`Filter clicked: ${filter.field}`);
16657
+ log8.debug("Filter clicked", { field: filter.field });
16653
16658
  },
16654
16659
  children: filter.label
16655
16660
  },
@@ -22521,31 +22526,56 @@ var init_InputGroup = __esm({
22521
22526
  InputGroup.displayName = "InputGroup";
22522
22527
  }
22523
22528
  });
22524
-
22525
- // lib/debug.ts
22529
+ function gateEnabled(level, ns = NAMESPACE) {
22530
+ return logger.isLogLevelEnabled(level, ns);
22531
+ }
22526
22532
  function isDebugEnabled() {
22527
- if (DEBUG_ENABLED) return true;
22528
- return typeof window !== "undefined" && window.__ALMADAR_DEBUG_VERIFY__ === true;
22533
+ return gateEnabled("DEBUG");
22529
22534
  }
22530
22535
  function debug(...args) {
22531
- if (isDebugEnabled()) {
22532
- console.log("[DEBUG]", ...args);
22536
+ if (!gateEnabled("DEBUG")) return;
22537
+ const [first, ...rest] = args;
22538
+ const message = typeof first === "string" ? first : "<debug>";
22539
+ if (rest.length === 0 && typeof first === "string") {
22540
+ log9.debug(message);
22541
+ } else {
22542
+ log9.debug(message, { args: rest.length > 0 ? formatArgs(rest) : formatArgs([first]) });
22533
22543
  }
22534
22544
  }
22535
22545
  function debugGroup(label) {
22536
- if (isDebugEnabled()) {
22537
- console.group(`[DEBUG] ${label}`);
22538
- }
22546
+ if (gateEnabled("DEBUG")) console.group(`[${NAMESPACE}] ${label}`);
22539
22547
  }
22540
22548
  function debugGroupEnd() {
22541
- if (isDebugEnabled()) {
22542
- console.groupEnd();
22549
+ if (gateEnabled("DEBUG")) console.groupEnd();
22550
+ }
22551
+ function formatArgs(values) {
22552
+ if (values.length === 1) return toLogMetaValue(values[0]);
22553
+ return values.map(toLogMetaValue);
22554
+ }
22555
+ function toLogMetaValue(v) {
22556
+ if (v === null || v === void 0) return v;
22557
+ if (v instanceof Error) return v;
22558
+ const t = typeof v;
22559
+ if (t === "string" || t === "number" || t === "boolean") return v;
22560
+ if (Array.isArray(v)) return v.map(toLogMetaValue);
22561
+ if (t === "object") {
22562
+ const out = {};
22563
+ for (const [k, val] of Object.entries(v)) {
22564
+ out[k] = toLogMetaValue(val);
22565
+ }
22566
+ return out;
22543
22567
  }
22568
+ return String(v);
22544
22569
  }
22545
- var DEBUG_ENABLED;
22570
+ var NAMESPACE, log9;
22546
22571
  var init_debug = __esm({
22547
22572
  "lib/debug.ts"() {
22548
- DEBUG_ENABLED = typeof window !== "undefined" && (localStorage.getItem("debug") === "true" || process.env.NODE_ENV === "development");
22573
+ NAMESPACE = "almadar:ui:debug";
22574
+ log9 = logger.createLogger(NAMESPACE);
22575
+ logger.createLogger("almadar:ui:debug:input");
22576
+ logger.createLogger("almadar:ui:debug:collision");
22577
+ logger.createLogger("almadar:ui:debug:physics");
22578
+ logger.createLogger("almadar:ui:debug:game-state");
22549
22579
  }
22550
22580
  });
22551
22581
  var isRelationsDebugEnabled, RelationSelect;
@@ -38783,7 +38813,7 @@ function getAllEvents(traits2) {
38783
38813
  }
38784
38814
  function EventDispatcherTab({ traits: traits2, schema }) {
38785
38815
  const eventBus = useEventBus();
38786
- const [log3, setLog] = React135__namespace.useState([]);
38816
+ const [log11, setLog] = React135__namespace.useState([]);
38787
38817
  const prevStatesRef = React135__namespace.useRef(/* @__PURE__ */ new Map());
38788
38818
  React135__namespace.useEffect(() => {
38789
38819
  for (const trait of traits2) {
@@ -38847,9 +38877,9 @@ function EventDispatcherTab({ traits: traits2, schema }) {
38847
38877
  /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "small", weight: "medium", className: "text-gray-500 mb-1", children: "Other Events (not available from current state)" }),
38848
38878
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap gap-1", children: unavailableEvents.map((event) => /* @__PURE__ */ jsxRuntime.jsx(Badge, { variant: "default", size: "sm", className: "opacity-50", children: event }, event)) })
38849
38879
  ] }),
38850
- log3.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
38880
+ log11.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
38851
38881
  /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "small", weight: "medium", className: "text-gray-500 mb-1", children: "Recent Transitions" }),
38852
- /* @__PURE__ */ jsxRuntime.jsx(Stack, { gap: "xs", children: log3.map((entry, i) => /* @__PURE__ */ jsxRuntime.jsxs(Typography, { variant: "small", className: "font-mono text-xs", children: [
38882
+ /* @__PURE__ */ jsxRuntime.jsx(Stack, { gap: "xs", children: log11.map((entry, i) => /* @__PURE__ */ jsxRuntime.jsxs(Typography, { variant: "small", className: "font-mono text-xs", children: [
38853
38883
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-purple-400", children: entry.traitName }),
38854
38884
  " ",
38855
38885
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-gray-500", children: entry.from }),
@@ -44397,8 +44427,7 @@ var init_UISlotRenderer = __esm({
44397
44427
 
44398
44428
  // hooks/index.ts
44399
44429
  init_useEventBus();
44400
-
44401
- // runtime/createClientEffectHandlers.ts
44430
+ var log2 = logger.createLogger("almadar:ui:effects:client-handlers");
44402
44431
  function createClientEffectHandlers(options) {
44403
44432
  const { eventBus, slotSetter, navigate, notify, callService } = options;
44404
44433
  return {
@@ -44407,10 +44436,10 @@ function createClientEffectHandlers(options) {
44407
44436
  eventBus.emit(prefixedEvent, payload);
44408
44437
  },
44409
44438
  persist: async () => {
44410
- console.warn("[ClientEffectHandlers] persist is server-side only, ignored on client");
44439
+ log2.warn("persist is server-side only, ignored on client");
44411
44440
  },
44412
44441
  set: () => {
44413
- console.warn("[ClientEffectHandlers] set is server-side only, ignored on client");
44442
+ log2.warn("set is server-side only, ignored on client");
44414
44443
  },
44415
44444
  callService: async (service, action, params) => {
44416
44445
  if (callService) return callService(service, action, params);
@@ -44439,10 +44468,10 @@ function createClientEffectHandlers(options) {
44439
44468
  slotSetter.addPattern(slot, pattern, props);
44440
44469
  },
44441
44470
  navigate: navigate ?? ((path) => {
44442
- console.warn("[ClientEffectHandlers] No navigate handler, ignoring:", path);
44471
+ log2.warn("No navigate handler, ignoring", { path });
44443
44472
  }),
44444
44473
  notify: notify ?? ((msg, type) => {
44445
- console.log(`[ClientEffectHandlers] notify (${type}):`, msg);
44474
+ log2.debug("notify", { type, message: msg });
44446
44475
  })
44447
44476
  };
44448
44477
  }
@@ -44745,10 +44774,9 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
44745
44774
  });
44746
44775
  snapshotUnregs.push(unreg);
44747
44776
  }
44748
- console.log(
44749
- "[TraitStateMachine] Reset states for page navigation:",
44750
- Array.from(newManager.getAllStates().keys()).join(", ")
44751
- );
44777
+ stateLog.debug("reset-states-for-nav", () => ({
44778
+ traits: Array.from(newManager.getAllStates().keys()).join(", ")
44779
+ }));
44752
44780
  return () => {
44753
44781
  for (const unreg of snapshotUnregs) unreg();
44754
44782
  };
@@ -44835,9 +44863,9 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
44835
44863
  const normalizedEvent = normalizeEventKey(eventKey);
44836
44864
  const bindings = traitBindingsRef.current;
44837
44865
  const currentManager = managerRef.current;
44838
- console.log("[TraitStateMachine] Processing event:", normalizedEvent, "payload:", payload);
44839
44866
  crossTraitLog.debug("processEvent:enter", () => ({
44840
44867
  event: normalizedEvent,
44868
+ payload: JSON.stringify(payload ?? null),
44841
44869
  traitCount: bindings.length,
44842
44870
  traitNames: bindings.map((b) => b.trait.name).join(","),
44843
44871
  orbitalsByTrait: JSON.stringify(orbitalsByTrait ?? null)
@@ -44896,18 +44924,13 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
44896
44924
  }
44897
44925
  }
44898
44926
  if (result.executed && result.effects.length > 0) {
44899
- console.log(
44900
- "[TraitStateMachine] Executing",
44901
- result.effects.length,
44902
- "effects for",
44927
+ stateLog.debug("executing-effects", () => ({
44928
+ effectCount: result.effects.length,
44903
44929
  traitName,
44904
- "| linkedEntity:",
44905
- binding.linkedEntity,
44906
- "| transition:",
44907
- `${result.previousState} -> ${result.newState}`,
44908
- "| effects:",
44909
- JSON.stringify(result.effects)
44910
- );
44930
+ linkedEntity: binding.linkedEntity,
44931
+ transition: `${result.previousState} -> ${result.newState}`,
44932
+ effects: JSON.stringify(result.effects)
44933
+ }));
44911
44934
  const linkedEntity = binding.linkedEntity || "";
44912
44935
  const entityId = payload?.entityId;
44913
44936
  const pendingSlots = /* @__PURE__ */ new Map();
@@ -45053,30 +45076,25 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
45053
45076
  }
45054
45077
  } else if (!result.executed) {
45055
45078
  if (result.guardResult === false) {
45056
- console.log(
45057
- "[TraitStateMachine] Guard blocked transition:",
45079
+ stateLog.debug("guard-blocked-transition", {
45058
45080
  traitName,
45059
- result.previousState,
45060
- "->",
45061
- result.transition?.to
45062
- );
45081
+ from: result.previousState,
45082
+ to: result.transition?.to
45083
+ });
45063
45084
  } else if (!result.transition) {
45064
45085
  if (core.isCircuitEvent(normalizedEvent)) {
45065
- console.warn(
45066
- `[CLOSED CIRCUIT VIOLATION] Trait "${traitName}" in state "${traitState.currentState}" received event "${normalizedEvent}" but has no transition to handle it.
45067
- This is likely a schema issue. To fix, add a transition:
45068
- { from: "${traitState.currentState}", to: "<target_state>", event: "${normalizedEvent}", effects: [...] }
45069
- Or ensure the previous action (that opened this UI) properly transitions back before emitting this event.`
45070
- );
45086
+ stateLog.warn("closed-circuit-violation", {
45087
+ traitName,
45088
+ currentState: traitState.currentState,
45089
+ event: normalizedEvent,
45090
+ 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.`
45091
+ });
45071
45092
  } else {
45072
- console.log(
45073
- "[TraitStateMachine] No transition for",
45093
+ stateLog.debug("no-transition", {
45074
45094
  traitName,
45075
- "from state:",
45076
- traitState.currentState,
45077
- "on event:",
45078
- normalizedEvent
45079
- );
45095
+ from: traitState.currentState,
45096
+ event: normalizedEvent
45097
+ });
45080
45098
  }
45081
45099
  }
45082
45100
  }
@@ -45184,7 +45202,7 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
45184
45202
  allEvents.add(transition.event);
45185
45203
  }
45186
45204
  }
45187
- console.log("[TraitStateMachine] Subscribing to events:", Array.from(allEvents));
45205
+ stateLog.debug("subscribing-to-events", () => ({ events: Array.from(allEvents) }));
45188
45206
  const unsubscribes = [];
45189
45207
  const subscribedBusKeys = /* @__PURE__ */ new Set();
45190
45208
  for (const binding of traitBindings) {
@@ -45319,7 +45337,11 @@ function useResolvedSchema(schema, pageName) {
45319
45337
  };
45320
45338
  }
45321
45339
  const page = core.getPage(ir, pageName);
45322
- console.log("[useResolvedSchema] Resolved page:", page?.name, "| path:", page?.path, "| traits:", page?.traits.length);
45340
+ resolvedSchemaLog.debug("Resolved page", () => ({
45341
+ name: page?.name,
45342
+ path: page?.path,
45343
+ traits: page?.traits.length
45344
+ }));
45323
45345
  const traits2 = page?.traits || [];
45324
45346
  const entities = /* @__PURE__ */ new Map();
45325
45347
  if (page) {
@@ -45346,6 +45368,7 @@ function clearSchemaCache() {
45346
45368
 
45347
45369
  // runtime/index.ts
45348
45370
  init_EntitySchemaContext();
45371
+ var log10 = logger.createLogger("almadar:ui:trait-provider");
45349
45372
  var TraitContext = React135.createContext(null);
45350
45373
  function TraitProvider({
45351
45374
  traits: traitBindings,
@@ -45362,7 +45385,11 @@ function TraitProvider({
45362
45385
  currentState: stateName,
45363
45386
  availableEvents: trait.transitions.filter((t) => t.from === stateName).map((t) => t.event),
45364
45387
  dispatch: (eventKey, payload) => {
45365
- console.log(`[TraitProvider] Dispatch to ${trait.name}: ${eventKey}`, payload);
45388
+ log10.debug("Dispatch", () => ({
45389
+ trait: trait.name,
45390
+ event: eventKey,
45391
+ payloadKeys: payload ? Object.keys(payload) : []
45392
+ }));
45366
45393
  },
45367
45394
  canDispatch: (eventKey) => {
45368
45395
  return trait.transitions.some(
@@ -45490,6 +45517,7 @@ init_EntitySchemaContext();
45490
45517
  // runtime/ServerBridge.tsx
45491
45518
  init_useEventBus();
45492
45519
  var xOrbitalLog = logger.createLogger("almadar:runtime:cross-orbital");
45520
+ var serverBridgeLog = logger.createLogger("almadar:ui:server-bridge");
45493
45521
  function createHttpTransport(serverUrl) {
45494
45522
  return {
45495
45523
  register: async (schema) => {
@@ -45502,7 +45530,7 @@ function createHttpTransport(serverUrl) {
45502
45530
  const result = await res.json();
45503
45531
  return !!result.success;
45504
45532
  } catch (err) {
45505
- console.error("[ServerBridge] Registration failed:", err);
45533
+ serverBridgeLog.error("Registration failed", { error: err instanceof Error ? err : String(err) });
45506
45534
  return false;
45507
45535
  }
45508
45536
  },