@almadar/runtime 3.2.2 → 3.2.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.
- package/dist/{OrbitalServerRuntime-CQsVhY4Y.d.ts → OrbitalServerRuntime-DMRvEfcT.d.ts} +65 -1
- package/dist/OrbitalServerRuntime.d.ts +1 -1
- package/dist/OrbitalServerRuntime.js +15 -6
- package/dist/OrbitalServerRuntime.js.map +1 -1
- package/dist/{chunk-PXASRZKG.js → chunk-JMMXSTWF.js} +3 -3
- package/dist/{chunk-PXASRZKG.js.map → chunk-JMMXSTWF.js.map} +1 -1
- package/dist/index.d.ts +128 -2
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -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
|
|
@@ -706,6 +758,18 @@ interface OrbitalEventResponse {
|
|
|
706
758
|
};
|
|
707
759
|
/** Client-side effects to execute (render-ui, navigate, notify) */
|
|
708
760
|
clientEffects?: Array<unknown>;
|
|
761
|
+
/**
|
|
762
|
+
* Same effects as `clientEffects`, paired with the producing trait name.
|
|
763
|
+
* Consumers that need per-trait attribution (e.g. `<TraitFrame>` resolving
|
|
764
|
+
* `@trait.X` bindings) read from this field; legacy consumers ignore it
|
|
765
|
+
* and continue with the flat `clientEffects` array unchanged.
|
|
766
|
+
*
|
|
767
|
+
* Same length and ordering as `clientEffects`; entries are 1:1 by index.
|
|
768
|
+
*/
|
|
769
|
+
clientEffectsByTrait?: Array<{
|
|
770
|
+
traitName: string;
|
|
771
|
+
effect: unknown[];
|
|
772
|
+
}>;
|
|
709
773
|
/** Results from server-side effects (persist, call-service, set) */
|
|
710
774
|
effectResults?: EffectResult[];
|
|
711
775
|
error?: string;
|
|
@@ -997,4 +1061,4 @@ declare class OrbitalServerRuntime {
|
|
|
997
1061
|
*/
|
|
998
1062
|
declare function createOrbitalServerRuntime(config?: OrbitalServerRuntimeConfig): OrbitalServerRuntime;
|
|
999
1063
|
|
|
1000
|
-
export { type EntitySharingMap as E, type
|
|
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 {
|
|
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-
|
|
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';
|
|
@@ -1177,6 +1177,7 @@ var OrbitalServerRuntime = class {
|
|
|
1177
1177
|
const emittedEvents = [];
|
|
1178
1178
|
const fetchedData = {};
|
|
1179
1179
|
const clientEffects = [];
|
|
1180
|
+
const clientEffectsByTrait = [];
|
|
1180
1181
|
const effectResults = [];
|
|
1181
1182
|
const activeTraits = payload?._activeTraits;
|
|
1182
1183
|
const cleanPayload = payload ? { ...payload } : void 0;
|
|
@@ -1211,7 +1212,8 @@ var OrbitalServerRuntime = class {
|
|
|
1211
1212
|
fetchedData,
|
|
1212
1213
|
clientEffects,
|
|
1213
1214
|
effectResults,
|
|
1214
|
-
user
|
|
1215
|
+
user,
|
|
1216
|
+
clientEffectsByTrait
|
|
1215
1217
|
);
|
|
1216
1218
|
}
|
|
1217
1219
|
}
|
|
@@ -1257,6 +1259,9 @@ var OrbitalServerRuntime = class {
|
|
|
1257
1259
|
if (clientEffects.length > 0) {
|
|
1258
1260
|
response.clientEffects = clientEffects;
|
|
1259
1261
|
}
|
|
1262
|
+
if (clientEffectsByTrait.length > 0) {
|
|
1263
|
+
response.clientEffectsByTrait = clientEffectsByTrait;
|
|
1264
|
+
}
|
|
1260
1265
|
if (effectResults.length > 0) {
|
|
1261
1266
|
response.effectResults = effectResults;
|
|
1262
1267
|
}
|
|
@@ -1265,8 +1270,12 @@ var OrbitalServerRuntime = class {
|
|
|
1265
1270
|
/**
|
|
1266
1271
|
* Execute effects from a transition
|
|
1267
1272
|
*/
|
|
1268
|
-
async executeEffects(registered, traitName, effects, payload, entityData, entityId, emittedEvents, fetchedData, clientEffects, effectResults, user) {
|
|
1273
|
+
async executeEffects(registered, traitName, effects, payload, entityData, entityId, emittedEvents, fetchedData, clientEffects, effectResults, user, clientEffectsByTrait) {
|
|
1269
1274
|
const entityType = registered.entity.name;
|
|
1275
|
+
const pushClientEffect = (effect) => {
|
|
1276
|
+
clientEffects.push(effect);
|
|
1277
|
+
clientEffectsByTrait?.push({ traitName, effect });
|
|
1278
|
+
};
|
|
1270
1279
|
let bindingsRef = null;
|
|
1271
1280
|
let contextRef = null;
|
|
1272
1281
|
const handlers = {
|
|
@@ -1637,16 +1646,16 @@ var OrbitalServerRuntime = class {
|
|
|
1637
1646
|
},
|
|
1638
1647
|
// Client-side effects - collect for forwarding to client
|
|
1639
1648
|
renderUI: (slot, pattern, props, priority) => {
|
|
1640
|
-
|
|
1649
|
+
pushClientEffect(["render-ui", slot, pattern, props, priority]);
|
|
1641
1650
|
},
|
|
1642
1651
|
navigate: (path2, params) => {
|
|
1643
|
-
|
|
1652
|
+
pushClientEffect(["navigate", path2, params]);
|
|
1644
1653
|
},
|
|
1645
1654
|
notify: (message, type) => {
|
|
1646
1655
|
if (this.config.debug) {
|
|
1647
1656
|
console.log(`[OrbitalRuntime] Notification (${type}): ${message}`);
|
|
1648
1657
|
}
|
|
1649
|
-
|
|
1658
|
+
pushClientEffect(["notify", message, { type }]);
|
|
1650
1659
|
},
|
|
1651
1660
|
log: (message, level) => {
|
|
1652
1661
|
const logFn = level === "error" ? console.error : level === "warn" ? console.warn : console.log;
|