@almadar/runtime 5.11.2 → 6.0.1
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-B-8J_5e9.d.ts → OrbitalServerRuntime-D0ciuYXu.d.ts} +6 -10
- package/dist/OrbitalServerRuntime.d.ts +1 -1
- package/dist/OrbitalServerRuntime.js +1 -1
- package/dist/{chunk-NPMVEFV6.js → chunk-KQBM5UQ2.js} +17 -96
- package/dist/chunk-KQBM5UQ2.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -22
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-NPMVEFV6.js.map +0 -1
|
@@ -714,16 +714,12 @@ interface RegisteredOrbital {
|
|
|
714
714
|
manager: StateMachineManager;
|
|
715
715
|
entityData: Map<string, EntityRow>;
|
|
716
716
|
/**
|
|
717
|
-
*
|
|
718
|
-
*
|
|
719
|
-
*
|
|
720
|
-
*
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
* lazily from `persistence.list()` when a collection-scope binding is
|
|
724
|
-
* first read with no cache entry.
|
|
725
|
-
*/
|
|
726
|
-
dataCache: Map<string, EntityRow | EntityRow[]>;
|
|
717
|
+
* Per-trait scalar state set by `(set @entity.X Y)`. Mirrors compiled's
|
|
718
|
+
* `state.fields`. The trait's `@entity` binding resolves from this map
|
|
719
|
+
* during effect interpolation. Initial empty; mutated only by the `set`
|
|
720
|
+
* effect handler. No implicit seeding from persistence.
|
|
721
|
+
*/
|
|
722
|
+
traitFieldStates: Map<string, EntityRow>;
|
|
727
723
|
}
|
|
728
724
|
/**
|
|
729
725
|
* Event sent from client to server
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import '@almadar/core';
|
|
2
2
|
import 'express';
|
|
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-
|
|
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-D0ciuYXu.js';
|
|
4
4
|
import './types-cuy5gd29.js';
|
|
5
5
|
export { I as InMemoryPersistence, P as PersistenceAdapter } from './PersistenceAdapter-B6dQCbbU.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { InMemoryPersistence, OrbitalServerRuntime, collectDeclaredConfigDefaults, createOrbitalServerRuntime } from './chunk-
|
|
1
|
+
export { InMemoryPersistence, OrbitalServerRuntime, collectDeclaredConfigDefaults, createOrbitalServerRuntime } from './chunk-KQBM5UQ2.js';
|
|
2
2
|
import './chunk-PZ5AY32C.js';
|
|
3
3
|
//# sourceMappingURL=OrbitalServerRuntime.js.map
|
|
4
4
|
//# sourceMappingURL=OrbitalServerRuntime.js.map
|
|
@@ -3999,7 +3999,7 @@ var OrbitalServerRuntime = class {
|
|
|
3999
3999
|
configByTrait,
|
|
4000
4000
|
manager,
|
|
4001
4001
|
entityData: /* @__PURE__ */ new Map(),
|
|
4002
|
-
|
|
4002
|
+
traitFieldStates: /* @__PURE__ */ new Map()
|
|
4003
4003
|
});
|
|
4004
4004
|
if (entity?.name && entity.instances && Array.isArray(entity.instances)) {
|
|
4005
4005
|
const instances = entity.instances;
|
|
@@ -4418,14 +4418,6 @@ var OrbitalServerRuntime = class {
|
|
|
4418
4418
|
if (stored) {
|
|
4419
4419
|
entityData = stored;
|
|
4420
4420
|
}
|
|
4421
|
-
} else if (registered.entity?.name) {
|
|
4422
|
-
try {
|
|
4423
|
-
const all = await this.persistence.list(registered.entity.name);
|
|
4424
|
-
if (Array.isArray(all) && all.length > 0 && all[0]) {
|
|
4425
|
-
entityData = all[0];
|
|
4426
|
-
}
|
|
4427
|
-
} catch {
|
|
4428
|
-
}
|
|
4429
4421
|
}
|
|
4430
4422
|
const results = registered.manager.sendEvent(event, cleanPayload, entityData);
|
|
4431
4423
|
const filteredResults = activeTraits && activeTraits.length > 0 ? results.filter(({ traitName }) => activeTraits.includes(traitName)) : results;
|
|
@@ -4507,26 +4499,18 @@ var OrbitalServerRuntime = class {
|
|
|
4507
4499
|
});
|
|
4508
4500
|
},
|
|
4509
4501
|
set: async (targetId, field, value) => {
|
|
4510
|
-
|
|
4511
|
-
if (
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
effectResults.push({
|
|
4515
|
-
effect: "set",
|
|
4516
|
-
entityType,
|
|
4517
|
-
data: { id, field, value },
|
|
4518
|
-
success: true
|
|
4519
|
-
});
|
|
4520
|
-
} catch (err) {
|
|
4521
|
-
effectResults.push({
|
|
4522
|
-
effect: "set",
|
|
4523
|
-
entityType,
|
|
4524
|
-
data: { id, field, value },
|
|
4525
|
-
success: false,
|
|
4526
|
-
error: err instanceof Error ? err.message : String(err)
|
|
4527
|
-
});
|
|
4528
|
-
}
|
|
4502
|
+
let fieldState = registered.traitFieldStates.get(traitName);
|
|
4503
|
+
if (!fieldState) {
|
|
4504
|
+
fieldState = {};
|
|
4505
|
+
registered.traitFieldStates.set(traitName, fieldState);
|
|
4529
4506
|
}
|
|
4507
|
+
fieldState[field] = value;
|
|
4508
|
+
effectResults.push({
|
|
4509
|
+
effect: "set",
|
|
4510
|
+
entityType,
|
|
4511
|
+
data: { id: targetId || entityId || "", field, value },
|
|
4512
|
+
success: true
|
|
4513
|
+
});
|
|
4530
4514
|
},
|
|
4531
4515
|
persist: async (action, targetEntityType, data) => {
|
|
4532
4516
|
if (action === "batch") {
|
|
@@ -4752,34 +4736,6 @@ var OrbitalServerRuntime = class {
|
|
|
4752
4736
|
fetchedData[fetchEntityType] = entities;
|
|
4753
4737
|
result = entities;
|
|
4754
4738
|
}
|
|
4755
|
-
if (result) {
|
|
4756
|
-
const records = Array.isArray(result) ? result : [result];
|
|
4757
|
-
if (records.length > 0) {
|
|
4758
|
-
const merged = Object.assign(
|
|
4759
|
-
[...records],
|
|
4760
|
-
records[0]
|
|
4761
|
-
);
|
|
4762
|
-
if (bindingsRef) {
|
|
4763
|
-
bindingsRef[fetchEntityType] = merged;
|
|
4764
|
-
if (fetchEntityType === entityType) {
|
|
4765
|
-
bindingsRef.entity = merged;
|
|
4766
|
-
}
|
|
4767
|
-
}
|
|
4768
|
-
registered.dataCache.set(fetchEntityType, merged);
|
|
4769
|
-
} else {
|
|
4770
|
-
const emptyCollection = Object.assign(
|
|
4771
|
-
[],
|
|
4772
|
-
{}
|
|
4773
|
-
);
|
|
4774
|
-
if (bindingsRef) {
|
|
4775
|
-
bindingsRef[fetchEntityType] = emptyCollection;
|
|
4776
|
-
if (fetchEntityType === entityType) {
|
|
4777
|
-
bindingsRef.entity = emptyCollection;
|
|
4778
|
-
}
|
|
4779
|
-
}
|
|
4780
|
-
registered.dataCache.set(fetchEntityType, emptyCollection);
|
|
4781
|
-
}
|
|
4782
|
-
}
|
|
4783
4739
|
return result === null ? null : { rows: result, total };
|
|
4784
4740
|
} catch (error) {
|
|
4785
4741
|
console.error(`[OrbitalRuntime] Fetch error for ${fetchEntityType}:`, error);
|
|
@@ -4812,16 +4768,6 @@ var OrbitalServerRuntime = class {
|
|
|
4812
4768
|
result = entities;
|
|
4813
4769
|
total = entities.length;
|
|
4814
4770
|
}
|
|
4815
|
-
if (bindingsRef && result) {
|
|
4816
|
-
const records = Array.isArray(result) ? result : [result];
|
|
4817
|
-
if (records.length > 0) {
|
|
4818
|
-
const merged = Object.assign([...records], records[0]);
|
|
4819
|
-
bindingsRef[derefEntityType] = merged;
|
|
4820
|
-
if (derefEntityType === entityType) {
|
|
4821
|
-
bindingsRef.entity = merged;
|
|
4822
|
-
}
|
|
4823
|
-
}
|
|
4824
|
-
}
|
|
4825
4771
|
effectResults.push({
|
|
4826
4772
|
effect: "deref",
|
|
4827
4773
|
entityType: derefEntityType,
|
|
@@ -4978,34 +4924,9 @@ var OrbitalServerRuntime = class {
|
|
|
4978
4924
|
if (declaredDefaults || callSiteOverride) {
|
|
4979
4925
|
bindings.config = { ...declaredDefaults ?? {}, ...callSiteOverride ?? {} };
|
|
4980
4926
|
}
|
|
4981
|
-
const
|
|
4982
|
-
if (
|
|
4983
|
-
|
|
4984
|
-
if (cached !== void 0) {
|
|
4985
|
-
bindings.entity = cached;
|
|
4986
|
-
} else {
|
|
4987
|
-
try {
|
|
4988
|
-
const all = await this.persistence.list(traitLinkedEntity);
|
|
4989
|
-
if (Array.isArray(all) && all.length > 0) {
|
|
4990
|
-
const merged = Object.assign(
|
|
4991
|
-
[...all],
|
|
4992
|
-
all[0]
|
|
4993
|
-
);
|
|
4994
|
-
bindings.entity = merged;
|
|
4995
|
-
registered.dataCache.set(traitLinkedEntity, merged);
|
|
4996
|
-
}
|
|
4997
|
-
} catch {
|
|
4998
|
-
}
|
|
4999
|
-
}
|
|
5000
|
-
}
|
|
5001
|
-
if (traitDef?.scope === "instance" && traitLinkedEntity && traitLinkedEntity !== entityType && !entityId) {
|
|
5002
|
-
try {
|
|
5003
|
-
const all = await this.persistence.list(traitLinkedEntity);
|
|
5004
|
-
if (Array.isArray(all) && all.length > 0 && all[0]) {
|
|
5005
|
-
bindings.entity = all[0];
|
|
5006
|
-
}
|
|
5007
|
-
} catch {
|
|
5008
|
-
}
|
|
4927
|
+
const traitFieldState = registered.traitFieldStates.get(traitName);
|
|
4928
|
+
if (traitFieldState) {
|
|
4929
|
+
bindings.entity = traitFieldState;
|
|
5009
4930
|
}
|
|
5010
4931
|
if (entityType) {
|
|
5011
4932
|
bindings[entityType] = bindings.entity ?? entityData;
|
|
@@ -5421,5 +5342,5 @@ function buildMatcher(src, listenerOrbital) {
|
|
|
5421
5342
|
}
|
|
5422
5343
|
|
|
5423
5344
|
export { EffectExecutor, EventBus, HANDLER_MANIFEST, InMemoryPersistence, MockPersistenceAdapter, OrbitalServerRuntime, StateMachineManager, buildEmitsFromTraits, collectDeclaredConfigDefaults, containsBindings, createContextFromBindings, createInitialTraitState, createLogger, createMockPersistence, createOrbitalServerRuntime, createTestExecutor, createUnifiedLoader, extractBindings, findInitialState, findTransition, formatPayloadValidationError, getIsolatedCollectionName, getNamespacedEvent, interpolateProps, interpolateValue, isBrowser, isElectron, isNamespacedEvent, isNode, normalizeEventKey, parseNamespacedEvent, preprocessSchema, processEvent, validateEventPayload, validatePayloadShapes };
|
|
5424
|
-
//# sourceMappingURL=chunk-
|
|
5425
|
-
//# sourceMappingURL=chunk-
|
|
5345
|
+
//# sourceMappingURL=chunk-KQBM5UQ2.js.map
|
|
5346
|
+
//# sourceMappingURL=chunk-KQBM5UQ2.js.map
|