@almadar/runtime 6.9.2 → 6.9.4

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,6 @@
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';
3
1
  import { Router } from 'express';
4
- import { I as IEventBus, g as RuntimeEvent, e as EventListener, U as Unsubscribe, T as TraitDefinition, R as RuntimeConfig, i as TransitionObserver, C as ConfigContext, h as TraitState, j as TransitionResult, d as EvaluationContextExtensions, b as EffectHandlers } from './types-CjvQG_33.js';
2
+ 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-cuy5gd29.js';
3
+ import { EventPayload, EntityRow, DeclaredTraitConfig, TraitConfig, OrbitalSchema, Orbital, Trait, PatternConfig, ResolvedPatternProps, SExpr, BusEventSource, OrbitalDefinition, Entity, TraitTick } from '@almadar/core';
5
4
  import { P as PersistenceAdapter } from './PersistenceAdapter-B6dQCbbU.js';
6
5
 
7
6
  /**
@@ -310,6 +309,23 @@ declare class StateMachineManager {
310
309
  resetAll(): void;
311
310
  }
312
311
 
312
+ /**
313
+ * Pure config-default extraction — kept OUT of `OrbitalServerRuntime.ts` so the
314
+ * package index can re-export it without dragging that module's node-only
315
+ * imports (`module`/`createRequire`, the external loader) into a browser bundle.
316
+ * This file has zero node dependencies (types only, from `@almadar/core`).
317
+ */
318
+
319
+ /**
320
+ * Walk a trait's declared `config { }` schema and return the flat
321
+ * `{ key: default, ... }` map. Seeds `@config.X` binding context with the
322
+ * atom's own declared defaults before any call-site override is applied.
323
+ * Mirrors the compiled path's `DEFAULT_<TRAIT>_CONFIG` constant (backend.rs).
324
+ */
325
+ declare function collectDeclaredConfigDefaults(trait: {
326
+ config?: DeclaredTraitConfig;
327
+ } | undefined): TraitConfig | undefined;
328
+
313
329
  /**
314
330
  * External Orbital Loader
315
331
  *
@@ -674,6 +690,41 @@ declare function parseNamespacedEvent(eventName: string): {
674
690
  event: string;
675
691
  };
676
692
 
693
+ /**
694
+ * OrbitalServerRuntime - Dynamic Server-Side Orbital Execution
695
+ *
696
+ * This runtime takes an OrbitalSchema and dynamically:
697
+ * 1. Registers all orbitals and their traits
698
+ * 2. Creates Express routes for trait communication
699
+ * 3. Executes state machines server-side
700
+ * 4. Handles cross-orbital event propagation
701
+ *
702
+ * This is the "interpreted" mode - no compilation needed.
703
+ * The compiler generates equivalent static code for production.
704
+ *
705
+ * @example
706
+ * ```typescript
707
+ * import { OrbitalServerRuntime } from '@kflow-builder/shared/runtime';
708
+ * import express from 'express';
709
+ *
710
+ * const app = express();
711
+ * const runtime = new OrbitalServerRuntime();
712
+ *
713
+ * // Register schema (can be loaded from file, API, etc.)
714
+ * runtime.register(orbitalSchema);
715
+ *
716
+ * // Mount orbital routes
717
+ * app.use('/api/orbitals', runtime.router());
718
+ *
719
+ * // Client can now:
720
+ * // POST /api/orbitals/:orbital/events - Send event to orbital
721
+ * // GET /api/orbitals/:orbital/state - Get current state
722
+ * // GET /api/orbitals - List registered orbitals
723
+ * ```
724
+ *
725
+ * @packageDocumentation
726
+ */
727
+
677
728
  /**
678
729
  * Client-side effect tuple shipped in `OrbitalEventResponse.clientEffects`.
679
730
  * Restricted to the three effect kinds the client knows how to apply to the
@@ -878,49 +929,6 @@ interface OrbitalServerRuntimeConfig {
878
929
  contextExtensions?: EvaluationContextExtensions;
879
930
  }
880
931
 
881
- /**
882
- * Check whether a schema needs preprocessing (has `uses` declarations or
883
- * un-inlined cross-orbital trait references).
884
- *
885
- * Cross-orbital refs are trait entries like
886
- * `{ ref: "Modal.traits.ModalRecordModal", ... }` with no inline
887
- * `stateMachine`. If these aren't resolved before `register()` runs, the
888
- * trait binder produces an empty state machine and all interactions
889
- * targeting the trait are silently dropped.
890
- */
891
- /**
892
- * Walk a trait's DECLARED config schema (`{ icon: { type, default }, ... }`)
893
- * and collect a flat `{ icon: <default>, ... }` map of just the default
894
- * values. Used to seed the `@config.X` binding context with the atom's
895
- * own declared defaults before any call-site override is applied. Mirrors
896
- * the compiled path's `DEFAULT_<TRAIT>_CONFIG` constant emitted by
897
- * backend.rs's Solution-1 plumbing.
898
- *
899
- * Returns `undefined` when the trait has no config schema or none of its
900
- * fields declare a default — keeps the caller's existing fast-path.
901
- */
902
- /**
903
- * Structural shape that both `@almadar/core`'s `Trait` and
904
- * `ResolvedTrait` satisfy: a `config?` map keyed by field name whose
905
- * values either carry a `default` (the declared-schema form loaded
906
- * from `.orb`) or are bare values (the runtime-resolved form).
907
- *
908
- * Widening to a structural parameter lets callers from the resolved
909
- * side (e.g., `@almadar/ui`'s `useTraitStateMachine`) pass their own
910
- * `ResolvedTrait` without an `as unknown as` cast.
911
- */
912
- /**
913
- * Read the `default` from each field of a trait's declared
914
- * `config { }` schema and return the flat `{ key: default, ... }`
915
- * map. Used to seed `@config.X` binding context with the atom's
916
- * own declared defaults before any call-site override is applied.
917
- *
918
- * Mirrors the compiled path's `DEFAULT_<TRAIT>_CONFIG` constant
919
- * emitted by `backend.rs` Solution-1.
920
- */
921
- declare function collectDeclaredConfigDefaults(trait: {
922
- config?: _almadar_core.DeclaredTraitConfig;
923
- } | undefined): TraitConfig | undefined;
924
932
  declare class OrbitalServerRuntime {
925
933
  protected orbitals: Map<string, RegisteredOrbital>;
926
934
  private eventBus;
@@ -1158,4 +1166,4 @@ declare class OrbitalServerRuntime {
1158
1166
  */
1159
1167
  declare function createOrbitalServerRuntime(config?: OrbitalServerRuntimeConfig): OrbitalServerRuntime;
1160
1168
 
1161
- export { getNamespacedEvent as A, isBrowser as B, type ClientEffectTuple as C, isElectron as D, type EffectResult as E, isNamespacedEvent as F, isNode as G, normalizeEventKey as H, type ImportChainLike as I, parseNamespacedEvent as J, preprocessSchema as K, type LoadResult as L, processEvent as M, type OrbitalEventRequest as O, type PreprocessOptions as P, type RegisteredOrbital as R, type SchemaLoader as S, type UnifiedLoaderOptions as U, type ClientNavigateTuple as a, type ClientNotifyTuple as b, type ClientRenderUITuple as c, type EntitySharingMap as d, EventBus as e, type EventNamespaceMap as f, type LoadedOrbital as g, type LoadedSchema as h, type LoaderConfig as i, type OrbitalEventResponse as j, OrbitalServerRuntime as k, type OrbitalServerRuntimeConfig as l, type PreprocessResult as m, type PreprocessedSchema as n, type ProcessEventOptions as o, type RuntimeOrbital as p, type RuntimeOrbitalSchema as q, type RuntimeTrait as r, type RuntimeTraitTick as s, StateMachineManager as t, collectDeclaredConfigDefaults as u, createInitialTraitState as v, createOrbitalServerRuntime as w, findInitialState as x, findTransition as y, getIsolatedCollectionName as z };
1169
+ 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';
2
1
  import 'express';
3
- export { C as ClientEffectTuple, a as ClientNavigateTuple, b as ClientNotifyTuple, c as ClientRenderUITuple, E as EffectResult, i as LoaderConfig, O as OrbitalEventRequest, j as OrbitalEventResponse, k as OrbitalServerRuntime, l as OrbitalServerRuntimeConfig, R as RegisteredOrbital, p as RuntimeOrbital, q as RuntimeOrbitalSchema, r as RuntimeTrait, s as RuntimeTraitTick, u as collectDeclaredConfigDefaults, w as createOrbitalServerRuntime } from './OrbitalServerRuntime-CzUrdroI.js';
4
- import './types-CjvQG_33.js';
2
+ 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-BNRZpSZm.js';
3
+ import './types-cuy5gd29.js';
4
+ import '@almadar/core';
5
5
  export { I as InMemoryPersistence, P as PersistenceAdapter } from './PersistenceAdapter-B6dQCbbU.js';