@almadar/runtime 5.8.1 → 5.8.3

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,7 @@
1
+ import * as _almadar_core from '@almadar/core';
2
+ import { EventPayload, EntityRow, OrbitalSchema, Orbital, Trait, PatternConfig, ResolvedPatternProps, SExpr, BusEventSource, OrbitalDefinition, Entity, TraitConfig, TraitTick } from '@almadar/core';
1
3
  import { Router } from 'express';
2
4
  import { I as IEventBus, g as RuntimeEvent, f as EventListener, U as Unsubscribe, T as TraitDefinition, R as RuntimeConfig, i as TransitionObserver, C as ConfigContext, h as TraitState, j as TransitionResult, E as EvaluationContextExtensions, a as EffectHandlers } from './types-ByLpy6yj.js';
3
- import { EventPayload, EntityRow, OrbitalSchema, Orbital, Trait, PatternConfig, ResolvedPatternProps, SExpr, BusEventSource, OrbitalDefinition, Entity, TraitConfig, TraitTick } from '@almadar/core';
4
5
  import { P as PersistenceAdapter } from './PersistenceAdapter-B6dQCbbU.js';
5
6
 
6
7
  /**
@@ -657,41 +658,6 @@ declare function parseNamespacedEvent(eventName: string): {
657
658
  event: string;
658
659
  };
659
660
 
660
- /**
661
- * OrbitalServerRuntime - Dynamic Server-Side Orbital Execution
662
- *
663
- * This runtime takes an OrbitalSchema and dynamically:
664
- * 1. Registers all orbitals and their traits
665
- * 2. Creates Express routes for trait communication
666
- * 3. Executes state machines server-side
667
- * 4. Handles cross-orbital event propagation
668
- *
669
- * This is the "interpreted" mode - no compilation needed.
670
- * The compiler generates equivalent static code for production.
671
- *
672
- * @example
673
- * ```typescript
674
- * import { OrbitalServerRuntime } from '@kflow-builder/shared/runtime';
675
- * import express from 'express';
676
- *
677
- * const app = express();
678
- * const runtime = new OrbitalServerRuntime();
679
- *
680
- * // Register schema (can be loaded from file, API, etc.)
681
- * runtime.register(orbitalSchema);
682
- *
683
- * // Mount orbital routes
684
- * app.use('/api/orbitals', runtime.router());
685
- *
686
- * // Client can now:
687
- * // POST /api/orbitals/:orbital/events - Send event to orbital
688
- * // GET /api/orbitals/:orbital/state - Get current state
689
- * // GET /api/orbitals - List registered orbitals
690
- * ```
691
- *
692
- * @packageDocumentation
693
- */
694
-
695
661
  /**
696
662
  * Client-side effect tuple shipped in `OrbitalEventResponse.clientEffects`.
697
663
  * Restricted to the three effect kinds the client knows how to apply to the
@@ -889,6 +855,49 @@ interface OrbitalServerRuntimeConfig {
889
855
  contextExtensions?: EvaluationContextExtensions;
890
856
  }
891
857
 
858
+ /**
859
+ * Check whether a schema needs preprocessing (has `uses` declarations or
860
+ * un-inlined cross-orbital trait references).
861
+ *
862
+ * Cross-orbital refs are trait entries like
863
+ * `{ ref: "Modal.traits.ModalRecordModal", ... }` with no inline
864
+ * `stateMachine`. If these aren't resolved before `register()` runs, the
865
+ * trait binder produces an empty state machine and all interactions
866
+ * targeting the trait are silently dropped.
867
+ */
868
+ /**
869
+ * Walk a trait's DECLARED config schema (`{ icon: { type, default }, ... }`)
870
+ * and collect a flat `{ icon: <default>, ... }` map of just the default
871
+ * values. Used to seed the `@config.X` binding context with the atom's
872
+ * own declared defaults before any call-site override is applied. Mirrors
873
+ * the compiled path's `DEFAULT_<TRAIT>_CONFIG` constant emitted by
874
+ * backend.rs's Solution-1 plumbing.
875
+ *
876
+ * Returns `undefined` when the trait has no config schema or none of its
877
+ * fields declare a default — keeps the caller's existing fast-path.
878
+ */
879
+ /**
880
+ * Structural shape that both `@almadar/core`'s `Trait` and
881
+ * `ResolvedTrait` satisfy: a `config?` map keyed by field name whose
882
+ * values either carry a `default` (the declared-schema form loaded
883
+ * from `.orb`) or are bare values (the runtime-resolved form).
884
+ *
885
+ * Widening to a structural parameter lets callers from the resolved
886
+ * side (e.g., `@almadar/ui`'s `useTraitStateMachine`) pass their own
887
+ * `ResolvedTrait` without an `as unknown as` cast.
888
+ */
889
+ /**
890
+ * Read the `default` from each field of a trait's declared
891
+ * `config { }` schema and return the flat `{ key: default, ... }`
892
+ * map. Used to seed `@config.X` binding context with the atom's
893
+ * own declared defaults before any call-site override is applied.
894
+ *
895
+ * Mirrors the compiled path's `DEFAULT_<TRAIT>_CONFIG` constant
896
+ * emitted by `backend.rs` Solution-1.
897
+ */
898
+ declare function collectDeclaredConfigDefaults(trait: {
899
+ config?: _almadar_core.DeclaredTraitConfig;
900
+ } | undefined): TraitConfig | undefined;
892
901
  declare class OrbitalServerRuntime {
893
902
  protected orbitals: Map<string, RegisteredOrbital>;
894
903
  private eventBus;
@@ -1126,4 +1135,4 @@ declare class OrbitalServerRuntime {
1126
1135
  */
1127
1136
  declare function createOrbitalServerRuntime(config?: OrbitalServerRuntimeConfig): OrbitalServerRuntime;
1128
1137
 
1129
- export { type ClientNavigateTuple as A, type ClientNotifyTuple as B, type ClientEffectTuple as C, type ClientRenderUITuple as D, type EntitySharingMap as E, type EffectResult as F, type LoaderConfig as G, OrbitalServerRuntime as H, type ImportChainLike as I, type RuntimeTraitTick as J, createOrbitalServerRuntime as K, type LoadResult as L, type OrbitalEventRequest as O, type PreprocessOptions as P, type RegisteredOrbital as R, type SchemaLoader as S, type UnifiedLoaderOptions as U, type LoadedSchema as a, type LoadedOrbital as b, EventBus as c, type EventNamespaceMap as d, type OrbitalEventResponse as e, type OrbitalServerRuntimeConfig as f, type PreprocessResult as g, type PreprocessedSchema as h, type ProcessEventOptions as i, type RuntimeOrbital as j, type RuntimeOrbitalSchema as k, type RuntimeTrait as l, StateMachineManager as m, createInitialTraitState as n, findInitialState as o, findTransition as p, getIsolatedCollectionName as q, getNamespacedEvent as r, isBrowser as s, isElectron as t, isNamespacedEvent as u, isNode as v, normalizeEventKey as w, parseNamespacedEvent as x, preprocessSchema as y, processEvent as z };
1138
+ export { processEvent as A, type ClientNavigateTuple as B, type ClientEffectTuple as C, type ClientNotifyTuple as D, type EntitySharingMap as E, type ClientRenderUITuple as F, type EffectResult as G, type LoaderConfig as H, type ImportChainLike as I, OrbitalServerRuntime as J, type RuntimeTraitTick as K, type LoadResult as L, createOrbitalServerRuntime as M, type OrbitalEventRequest as O, type PreprocessOptions as P, type RegisteredOrbital as R, type SchemaLoader as S, type UnifiedLoaderOptions as U, type LoadedSchema as a, type LoadedOrbital as b, EventBus as c, type EventNamespaceMap as d, type OrbitalEventResponse as e, type OrbitalServerRuntimeConfig as f, type PreprocessResult as g, type PreprocessedSchema as h, type ProcessEventOptions as i, type RuntimeOrbital as j, type RuntimeOrbitalSchema as k, type RuntimeTrait as l, StateMachineManager as m, collectDeclaredConfigDefaults as n, createInitialTraitState as o, findInitialState as p, findTransition as q, getIsolatedCollectionName as r, getNamespacedEvent as s, isBrowser as t, isElectron as u, isNamespacedEvent as v, isNode as w, normalizeEventKey as x, parseNamespacedEvent as y, preprocessSchema as z };
@@ -1,5 +1,5 @@
1
+ import '@almadar/core';
1
2
  import 'express';
2
- export { C as ClientEffectTuple, A as ClientNavigateTuple, B as ClientNotifyTuple, D as ClientRenderUITuple, F as EffectResult, G as LoaderConfig, O as OrbitalEventRequest, e as OrbitalEventResponse, H as OrbitalServerRuntime, f as OrbitalServerRuntimeConfig, R as RegisteredOrbital, j as RuntimeOrbital, k as RuntimeOrbitalSchema, l as RuntimeTrait, J as RuntimeTraitTick, K as createOrbitalServerRuntime } from './OrbitalServerRuntime-BP5sz5Bn.js';
3
+ export { C as ClientEffectTuple, B as ClientNavigateTuple, D as ClientNotifyTuple, F as ClientRenderUITuple, G as EffectResult, H as LoaderConfig, O as OrbitalEventRequest, e as OrbitalEventResponse, J as OrbitalServerRuntime, f as OrbitalServerRuntimeConfig, R as RegisteredOrbital, j as RuntimeOrbital, k as RuntimeOrbitalSchema, l as RuntimeTrait, K as RuntimeTraitTick, n as collectDeclaredConfigDefaults, M as createOrbitalServerRuntime } from './OrbitalServerRuntime-Bv8y7nIu.js';
3
4
  import './types-ByLpy6yj.js';
4
- import '@almadar/core';
5
5
  export { I as InMemoryPersistence, P as PersistenceAdapter } from './PersistenceAdapter-B6dQCbbU.js';