@almadar/runtime 3.2.3 → 3.2.5

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.
@@ -386,6 +386,46 @@ type LoadResult<T> = {
386
386
  success: false;
387
387
  error: string;
388
388
  };
389
+ /**
390
+ * Base options for all loaders.
391
+ */
392
+ interface BaseLoaderOptions {
393
+ /** Base path/URL for resolving relative imports */
394
+ basePath: string;
395
+ /** Standard library root path/URL */
396
+ stdLibPath?: string;
397
+ /** Scoped package roots (e.g., { "@game-lib": "/path/to/lib" }) */
398
+ scopedPaths?: Record<string, string>;
399
+ }
400
+ /**
401
+ * Options for file system loading.
402
+ */
403
+ interface FileSystemLoaderOptions extends BaseLoaderOptions {
404
+ /** Whether to allow paths outside basePath (security) */
405
+ allowOutsideBasePath?: boolean;
406
+ }
407
+ /**
408
+ * Options for HTTP loading.
409
+ */
410
+ interface HttpLoaderOptions extends BaseLoaderOptions {
411
+ /** Default fetch options */
412
+ fetchOptions?: RequestInit;
413
+ /** Request timeout in milliseconds */
414
+ timeout?: number;
415
+ /** Whether to use credentials (cookies, auth headers) */
416
+ credentials?: RequestCredentials;
417
+ }
418
+ /**
419
+ * Combined options for unified loader.
420
+ */
421
+ interface UnifiedLoaderOptions extends BaseLoaderOptions {
422
+ /** File system specific options */
423
+ fileSystem?: Omit<FileSystemLoaderOptions, keyof BaseLoaderOptions>;
424
+ /** HTTP specific options */
425
+ http?: Omit<HttpLoaderOptions, keyof BaseLoaderOptions>;
426
+ /** Force a specific loader type */
427
+ forceLoader?: "filesystem" | "http";
428
+ }
389
429
  /**
390
430
  * Abstract interface for schema loaders.
391
431
  *
@@ -463,6 +503,18 @@ interface ImportChainLike {
463
503
  */
464
504
  clone(): ImportChainLike;
465
505
  }
506
+ /**
507
+ * Detect if running in Electron.
508
+ */
509
+ declare function isElectron(): boolean;
510
+ /**
511
+ * Detect if running in browser (not Electron).
512
+ */
513
+ declare function isBrowser(): boolean;
514
+ /**
515
+ * Detect if running in Node.js (not browser).
516
+ */
517
+ declare function isNode(): boolean;
466
518
 
467
519
  /**
468
520
  * Reference Resolver
@@ -1009,4 +1061,4 @@ declare class OrbitalServerRuntime {
1009
1061
  */
1010
1062
  declare function createOrbitalServerRuntime(config?: OrbitalServerRuntimeConfig): OrbitalServerRuntime;
1011
1063
 
1012
- export { type EntitySharingMap as E, type LoaderConfig as L, type OrbitalEventRequest as O, type PersistenceAdapter as P, type RegisteredOrbital as R, StateMachineManager as S, EventBus as a, type EventNamespaceMap as b, type OrbitalEventResponse as c, type OrbitalServerRuntimeConfig as d, type PreprocessOptions as e, type PreprocessResult as f, type PreprocessedSchema as g, type ProcessEventOptions as h, type RuntimeOrbital as i, type RuntimeOrbitalSchema as j, type RuntimeTrait as k, createInitialTraitState as l, findInitialState as m, findTransition as n, getIsolatedCollectionName as o, getNamespacedEvent as p, isNamespacedEvent as q, normalizeEventKey as r, parseNamespacedEvent as s, preprocessSchema as t, processEvent as u, type EffectResult as v, LocalPersistenceAdapter as w, OrbitalServerRuntime as x, type RuntimeTraitTick as y, createOrbitalServerRuntime as z };
1064
+ export { processEvent as A, type EffectResult as B, type LoaderConfig as C, LocalPersistenceAdapter as D, type EntitySharingMap as E, OrbitalServerRuntime as F, type RuntimeTraitTick as G, createOrbitalServerRuntime as H, type ImportChainLike as I, type LoadResult as L, type OrbitalEventRequest as O, type PersistenceAdapter 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 PreprocessOptions as g, type PreprocessResult as h, type PreprocessedSchema as i, type ProcessEventOptions as j, type RuntimeOrbital as k, type RuntimeOrbitalSchema as l, type RuntimeTrait as m, StateMachineManager 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,4 +1,4 @@
1
1
  import 'express';
2
- export { v as EffectResult, L as LoaderConfig, w as LocalPersistenceAdapter, O as OrbitalEventRequest, c as OrbitalEventResponse, x as OrbitalServerRuntime, d as OrbitalServerRuntimeConfig, P as PersistenceAdapter, R as RegisteredOrbital, i as RuntimeOrbital, j as RuntimeOrbitalSchema, k as RuntimeTrait, y as RuntimeTraitTick, z as createOrbitalServerRuntime } from './OrbitalServerRuntime-RHykAuqO.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-DMRvEfcT.js';
3
3
  import './types-B8OfRFfV.js';
4
4
  import '@almadar/core';
@@ -1,4 +1,4 @@
1
- import { EventBus, createUnifiedLoader, preprocessSchema, StateMachineManager, createContextFromBindings, EffectExecutor } from './chunk-PXASRZKG.js';
1
+ import { EventBus, createUnifiedLoader, preprocessSchema, StateMachineManager, createContextFromBindings, EffectExecutor } from './chunk-JMMXSTWF.js';
2
2
  import './chunk-PZ5AY32C.js';
3
3
  import { Router } from 'express';
4
4
  import * as fs from 'fs';
@@ -847,7 +847,13 @@ var OrbitalServerRuntime = class {
847
847
  * Register a single orbital
848
848
  */
849
849
  async registerOrbitalAsync(orbital) {
850
- const inlineTraits = (orbital.traits || []).filter(isInlineTrait);
850
+ const unwrapped = (orbital.traits || []).map((t) => {
851
+ if (t && typeof t === "object" && "ref" in t && "_resolved" in t) {
852
+ return t._resolved;
853
+ }
854
+ return t;
855
+ });
856
+ const inlineTraits = unwrapped.filter(isInlineTrait);
851
857
  const traitDefs = inlineTraits.map((t) => {
852
858
  const sm = t.stateMachine;
853
859
  const states = sm?.states || [];