@almadar/runtime 6.70.0 → 6.71.0

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.
@@ -1362,6 +1362,32 @@ declare class OrbitalServerRuntime {
1362
1362
  * Register a single orbital (sync wrapper for backward compatibility)
1363
1363
  */
1364
1364
  private registerOrbital;
1365
+ /**
1366
+ * The id of the SOURCE event a `listens {}` entry names, derived from the
1367
+ * emitting trait's own declared `emits[]` contract rather than trusted
1368
+ * from `listener.eventId` alone.
1369
+ *
1370
+ * `TraitEventListener.eventId` is "optional until the Phase-7 flip" (see
1371
+ * `@almadar/core`'s `trait.ts`) — the compose/resolve pipeline stamps a
1372
+ * V4 ledger id onto every `emits[]` entry (the emitter's own contract)
1373
+ * well before it stamps the matching id onto every `listens[]` entry that
1374
+ * names that event (source-qualified `Trait.EVENT -> X` listens compiled
1375
+ * from `uses`-resolved atoms carry `triggersId` for their OWN triggered
1376
+ * event but no `eventId` for the event they're listening to). The emit
1377
+ * handler (`executeEffects`'s `emit` closure below) always looks up and
1378
+ * stamps `emittingTrait.emits[].eventId` when present, so during that
1379
+ * transitional window the emit side routes under an id-qualified bus key
1380
+ * while the listen side — reading only its own possibly-absent
1381
+ * `eventId` — subscribes under the bare name, and the two never meet.
1382
+ *
1383
+ * Fix: derive the SAME id the emitter will stamp by resolving the
1384
+ * listener's declared `source` (trait/orbital, name or id) to the actual
1385
+ * registered trait and reading ITS `emits[]` contract for `listener.event`
1386
+ * — the single canonical place an event's id lives. `kind: "any"` sources
1387
+ * are left alone (no single emitter to resolve against; bare-name routing
1388
+ * is already the correct, safe default there).
1389
+ */
1390
+ private resolveSourceEmitEventId;
1365
1391
  /**
1366
1392
  * Set up event listeners for cross-orbital communication
1367
1393
  */
@@ -1,4 +1,4 @@
1
1
  import 'express';
2
- export { F as ClientEffectTuple, G as ClientNavigateBackTuple, H as ClientNavigateTuple, J as ClientNotifyTuple, K as ClientRenderUITuple, M as EffectResult, e as InMemoryPersistence, N as LiveBroadcastItem, Q as LoaderConfig, O as OrbitalEventRequest, f as OrbitalEventResponse, T as OrbitalServerRuntime, g as OrbitalServerRuntimeConfig, P as PersistenceAdapter, R as RegisteredOrbital, l as RuntimeOrbital, m as RuntimeOrbitalSchema, n as RuntimeTrait, V as RuntimeTraitTick, p as collectDeclaredConfigDefaults, W as createOrbitalServerRuntime } from './OrbitalServerRuntime-ut1b36Nv.js';
2
+ export { F as ClientEffectTuple, G as ClientNavigateBackTuple, H as ClientNavigateTuple, J as ClientNotifyTuple, K as ClientRenderUITuple, M as EffectResult, e as InMemoryPersistence, N as LiveBroadcastItem, Q as LoaderConfig, O as OrbitalEventRequest, f as OrbitalEventResponse, T as OrbitalServerRuntime, g as OrbitalServerRuntimeConfig, P as PersistenceAdapter, R as RegisteredOrbital, l as RuntimeOrbital, m as RuntimeOrbitalSchema, n as RuntimeTrait, V as RuntimeTraitTick, p as collectDeclaredConfigDefaults, W as createOrbitalServerRuntime } from './OrbitalServerRuntime-DnDJhpLS.js';
3
3
  import './types-BaD_ox7e.js';
4
4
  import '@almadar/core';
@@ -760,6 +760,40 @@ var OrbitalServerRuntime = class {
760
760
  });
761
761
  });
762
762
  }
763
+ /**
764
+ * The id of the SOURCE event a `listens {}` entry names, derived from the
765
+ * emitting trait's own declared `emits[]` contract rather than trusted
766
+ * from `listener.eventId` alone.
767
+ *
768
+ * `TraitEventListener.eventId` is "optional until the Phase-7 flip" (see
769
+ * `@almadar/core`'s `trait.ts`) — the compose/resolve pipeline stamps a
770
+ * V4 ledger id onto every `emits[]` entry (the emitter's own contract)
771
+ * well before it stamps the matching id onto every `listens[]` entry that
772
+ * names that event (source-qualified `Trait.EVENT -> X` listens compiled
773
+ * from `uses`-resolved atoms carry `triggersId` for their OWN triggered
774
+ * event but no `eventId` for the event they're listening to). The emit
775
+ * handler (`executeEffects`'s `emit` closure below) always looks up and
776
+ * stamps `emittingTrait.emits[].eventId` when present, so during that
777
+ * transitional window the emit side routes under an id-qualified bus key
778
+ * while the listen side — reading only its own possibly-absent
779
+ * `eventId` — subscribes under the bare name, and the two never meet.
780
+ *
781
+ * Fix: derive the SAME id the emitter will stamp by resolving the
782
+ * listener's declared `source` (trait/orbital, name or id) to the actual
783
+ * registered trait and reading ITS `emits[]` contract for `listener.event`
784
+ * — the single canonical place an event's id lives. `kind: "any"` sources
785
+ * are left alone (no single emitter to resolve against; bare-name routing
786
+ * is already the correct, safe default there).
787
+ */
788
+ resolveSourceEmitEventId(source, event, listenerOrbital) {
789
+ if (!source || source.kind === "any") return void 0;
790
+ const ownerOrbitalName = source.kind === "orbital" ? source.orbital : listenerOrbital;
791
+ const owner = this.orbitals.get(ownerOrbitalName);
792
+ if (!owner) return void 0;
793
+ const sourceTrait = source.traitId !== void 0 ? owner.traits.find((t) => t.id === source.traitId) : owner.traits.find((t) => t.name === source.trait);
794
+ if (!sourceTrait) return void 0;
795
+ return sourceTrait.emits?.find((e) => e.event === event)?.eventId;
796
+ }
763
797
  /**
764
798
  * Set up event listeners for cross-orbital communication
765
799
  */
@@ -773,7 +807,8 @@ var OrbitalServerRuntime = class {
773
807
  if (!trait.listens) continue;
774
808
  for (const listener of trait.listens) {
775
809
  const { bareEvent, matcher } = parseListenSource(listener, orbitalName);
776
- const routeKey = eventRouteKey(bareEvent, listener.eventId);
810
+ const effectiveEventId = listener.eventId ?? this.resolveSourceEmitEventId(listener.source, bareEvent, orbitalName);
811
+ const routeKey = eventRouteKey(bareEvent, effectiveEventId);
777
812
  const cleanup = this.eventBus.on(routeKey, async (event) => {
778
813
  if (!matcher(event.source)) return;
779
814
  if (event.source?.originClientId !== void 0) {
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { g as RuntimePatternValue, B as BindingContext, f as EvaluationContextExtensions, P as PatternProps, E as EffectHandlers, h as EffectContext, i as ExecutionEnvironment, j as EffectResult, S as ServiceCallContext, T as TraitDefinition } from './types-BaD_ox7e.js';
2
2
  export { k as BrowserFileMeta, l as BrowserFilePickerOptions, m as BrowserGeolocationOptions, n as BrowserGeolocationPosition, C as ConfigContext, o as Effect, a as EventListener, H as HANDLER_MANIFEST, I as IEventBus, b as RuntimeConfig, R as RuntimeEvent, d as TraitState, c as TransitionObserver, e as TransitionResult, U as Unsubscribe } from './types-BaD_ox7e.js';
3
- import { U as UnifiedLoaderOptions, S as SchemaLoader, I as ImportChainLike, L as LoadResult, a as LoadedSchema, b as LoadedOrbital, P as PersistenceAdapter } from './OrbitalServerRuntime-ut1b36Nv.js';
4
- export { E as EntitySharingMap, c as EventBus, d as EventNamespaceMap, e as InMemoryPersistence, O as OrbitalEventRequest, f as OrbitalEventResponse, g as OrbitalServerRuntimeConfig, h as PreprocessOptions, i as PreprocessResult, j as PreprocessedSchema, k as ProcessEventOptions, R as RegisteredOrbital, l as RuntimeOrbital, m as RuntimeOrbitalSchema, n as RuntimeTrait, o as StateMachineManager, p as collectDeclaredConfigDefaults, q as collectDeclaredEntityDefaults, r as createInitialTraitState, s as findInitialState, t as findTransition, u as getIsolatedCollectionName, v as getNamespacedEvent, w as isBrowser, x as isElectron, y as isNamespacedEvent, z as isNode, A as normalizeEventKey, B as parseNamespacedEvent, C as preprocessSchema, D as processEvent } from './OrbitalServerRuntime-ut1b36Nv.js';
3
+ import { U as UnifiedLoaderOptions, S as SchemaLoader, I as ImportChainLike, L as LoadResult, a as LoadedSchema, b as LoadedOrbital, P as PersistenceAdapter } from './OrbitalServerRuntime-DnDJhpLS.js';
4
+ export { E as EntitySharingMap, c as EventBus, d as EventNamespaceMap, e as InMemoryPersistence, O as OrbitalEventRequest, f as OrbitalEventResponse, g as OrbitalServerRuntimeConfig, h as PreprocessOptions, i as PreprocessResult, j as PreprocessedSchema, k as ProcessEventOptions, R as RegisteredOrbital, l as RuntimeOrbital, m as RuntimeOrbitalSchema, n as RuntimeTrait, o as StateMachineManager, p as collectDeclaredConfigDefaults, q as collectDeclaredEntityDefaults, r as createInitialTraitState, s as findInitialState, t as findTransition, u as getIsolatedCollectionName, v as getNamespacedEvent, w as isBrowser, x as isElectron, y as isNamespacedEvent, z as isNode, A as normalizeEventKey, B as parseNamespacedEvent, C as preprocessSchema, D as processEvent } from './OrbitalServerRuntime-DnDJhpLS.js';
5
5
  import { EvaluationContext, SExpressionEvaluator } from '@almadar/evaluator';
6
6
  export { EvaluationContext, createMinimalContext } from '@almadar/evaluator';
7
7
  import { RenderBindingMarker, SExpr, RuntimeValue, TraitConfigObject, EventPayload, PatternConfig, EntityId, EntityField, EntityRow, EntityPersistence, ServiceParams, EntityAccessPolicies, PayloadField, OrbitalDefinition, OrbitalSchema } from '@almadar/core';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almadar/runtime",
3
- "version": "6.70.0",
3
+ "version": "6.71.0",
4
4
  "description": "Interpreted runtime for Almadar orbital applications (OrbitalServerRuntime)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -57,11 +57,11 @@
57
57
  "access": "public"
58
58
  },
59
59
  "dependencies": {
60
- "@almadar/core": "^10.83.0",
60
+ "@almadar/core": "^10.84.0",
61
61
  "@almadar/evaluator": "^2.44.0",
62
62
  "@almadar/logger": "^1.12.0",
63
63
  "@almadar/server": "^2.39.0",
64
- "@almadar/std": "^16.203.0"
64
+ "@almadar/std": "^16.204.0"
65
65
  },
66
66
  "peerDependencies": {
67
67
  "express": "^5.0.0"