@almadar/runtime 4.2.3 → 4.2.7

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,6 +1,6 @@
1
1
  import { Router } from 'express';
2
- import { I as IEventBus, g as RuntimeEvent, f as EventListener, U as Unsubscribe, T as TraitDefinition, R as RuntimeConfig, i as TransitionObserver, h as TraitState, j as TransitionResult, E as EvaluationContextExtensions, a as EffectHandlers } from './types-CVSBlnzV.js';
3
- import { EventPayload, EntityRow, OrbitalSchema, Orbital, Trait, OrbitalDefinition, Entity, TraitTick } from '@almadar/core';
2
+ import { I as IEventBus, g as RuntimeEvent, f as EventListener, U as Unsubscribe, T as TraitDefinition, R as RuntimeConfig, i as TransitionObserver, h as TraitState, j as TransitionResult, E as EvaluationContextExtensions, a as EffectHandlers } from './types-BxxO5BCJ.js';
3
+ import { EventPayload, EntityRow, OrbitalSchema, Orbital, Trait, OrbitalDefinition, Entity, TraitConfig, TraitTick } from '@almadar/core';
4
4
 
5
5
  /**
6
6
  * EventBus - Platform-Agnostic Pub/Sub Implementation
@@ -723,6 +723,14 @@ interface RegisteredOrbital {
723
723
  entity: Entity;
724
724
  /** Resolved inline traits (string refs filtered out) */
725
725
  traits: Trait[];
726
+ /**
727
+ * Call-site `config: { ... }` attached to each trait ref, keyed by trait
728
+ * name. Used to populate the `@config.X` binding when running that trait's
729
+ * effects. Preserved from the preprocessed schema's trait-ref wrapper
730
+ * (`{ ref, config, linkedEntity, _resolved }`) before the wrapper is
731
+ * unwrapped to its inline form.
732
+ */
733
+ configByTrait: Map<string, TraitConfig>;
726
734
  manager: StateMachineManager;
727
735
  entityData: Map<string, EntityRow>;
728
736
  }
@@ -1,4 +1,4 @@
1
1
  import 'express';
2
- export { B as EffectResult, C as LoaderConfig, D as LocalPersistenceAdapter, O as OrbitalEventRequest, e as OrbitalEventResponse, F as OrbitalServerRuntime, f as OrbitalServerRuntimeConfig, P as PersistenceAdapter, R as RegisteredOrbital, k as RuntimeOrbital, l as RuntimeOrbitalSchema, m as RuntimeTrait, G as RuntimeTraitTick, H as createOrbitalServerRuntime } from './OrbitalServerRuntime-CFMJku6Q.js';
3
- import './types-CVSBlnzV.js';
2
+ export { B as EffectResult, C as LoaderConfig, D as LocalPersistenceAdapter, O as OrbitalEventRequest, e as OrbitalEventResponse, F as OrbitalServerRuntime, f as OrbitalServerRuntimeConfig, P as PersistenceAdapter, R as RegisteredOrbital, k as RuntimeOrbital, l as RuntimeOrbitalSchema, m as RuntimeTrait, G as RuntimeTraitTick, H as createOrbitalServerRuntime } from './OrbitalServerRuntime-FxB6n8uS.js';
3
+ import './types-BxxO5BCJ.js';
4
4
  import '@almadar/core';
@@ -1,4 +1,4 @@
1
- import { EventBus, createUnifiedLoader, preprocessSchema, StateMachineManager, createContextFromBindings, EffectExecutor } from './chunk-Z72NLOSF.js';
1
+ import { EventBus, createUnifiedLoader, preprocessSchema, StateMachineManager, createContextFromBindings, EffectExecutor } from './chunk-ZIDFSYMT.js';
2
2
  import './chunk-PZ5AY32C.js';
3
3
  import { Router } from 'express';
4
4
  import * as fs from 'fs';
@@ -997,9 +997,15 @@ var OrbitalServerRuntime = class {
997
997
  * Register a single orbital
998
998
  */
999
999
  async registerOrbitalAsync(orbital) {
1000
+ const configByTrait = /* @__PURE__ */ new Map();
1000
1001
  const unwrapped = (orbital.traits || []).map((t) => {
1001
1002
  if (t && typeof t === "object" && "ref" in t && "_resolved" in t) {
1002
- return t._resolved;
1003
+ const wrapper = t;
1004
+ const inner = wrapper._resolved;
1005
+ if (wrapper.config && inner?.name) {
1006
+ configByTrait.set(inner.name, wrapper.config);
1007
+ }
1008
+ return inner;
1003
1009
  }
1004
1010
  return t;
1005
1011
  });
@@ -1037,6 +1043,7 @@ var OrbitalServerRuntime = class {
1037
1043
  schema: orbital,
1038
1044
  entity,
1039
1045
  traits: inlineTraits,
1046
+ configByTrait,
1040
1047
  manager,
1041
1048
  entityData: /* @__PURE__ */ new Map()
1042
1049
  });
@@ -1805,6 +1812,10 @@ var OrbitalServerRuntime = class {
1805
1812
  user
1806
1813
  // @user bindings from Firebase auth
1807
1814
  };
1815
+ const traitConfig = registered.configByTrait.get(traitName);
1816
+ if (traitConfig) {
1817
+ bindings.config = traitConfig;
1818
+ }
1808
1819
  if (entityType) {
1809
1820
  bindings[entityType] = entityData;
1810
1821
  }