@almadar/runtime 6.58.0 → 6.59.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.
- package/dist/{OrbitalServerRuntime-Dn9dIwJk.d.ts → OrbitalServerRuntime-PI9Ioxdp.d.ts} +31 -0
- package/dist/OrbitalServerRuntime.d.ts +1 -1
- package/dist/OrbitalServerRuntime.js +44 -2
- package/dist/{chunk-MMVKKLAP.js → chunk-WSNZNXZE.js} +2 -2
- package/dist/index.d.ts +9 -4
- package/dist/index.js +2 -2
- package/package.json +3 -3
|
@@ -974,6 +974,16 @@ interface OrbitalEventRequest {
|
|
|
974
974
|
user?: RawUserClaims;
|
|
975
975
|
/** Per-tab client identity (UUID) — excludes this request's origin from live-broadcast delivery. */
|
|
976
976
|
clientId?: string;
|
|
977
|
+
/**
|
|
978
|
+
* Broadcast-class marker (T6, docs/Almadar_Tick_Loop.md §3a): the name of
|
|
979
|
+
* the tick that emitted this event. Tick-stamped dispatches are
|
|
980
|
+
* latest-state broadcasts — the client fires them without awaiting the
|
|
981
|
+
* response, and the server relays them to OTHER tabs coalesced
|
|
982
|
+
* (newest-per-key) at a snapshot rate instead of 1:1.
|
|
983
|
+
*/
|
|
984
|
+
tick?: string;
|
|
985
|
+
/** Emitting trait for a tick-stamped dispatch — builds the relay's BusEventSource (sourceless emits are dropped client-side). */
|
|
986
|
+
sourceTrait?: string;
|
|
977
987
|
}
|
|
978
988
|
/**
|
|
979
989
|
* One persist-envelope success emit, handed to the live-broadcast sink
|
|
@@ -1072,6 +1082,12 @@ interface LoaderConfig {
|
|
|
1072
1082
|
interface OrbitalServerRuntimeConfig {
|
|
1073
1083
|
/** Enable debug logging */
|
|
1074
1084
|
debug?: boolean;
|
|
1085
|
+
/**
|
|
1086
|
+
* Snapshot cadence (ms) for relaying tick-stamped broadcasts to other
|
|
1087
|
+
* clients — newest-per-(client, orbital, event) wins between flushes
|
|
1088
|
+
* (T6, docs/Almadar_Tick_Loop.md §3a). Default 50 (≈20Hz).
|
|
1089
|
+
*/
|
|
1090
|
+
tickRelayIntervalMs?: number;
|
|
1075
1091
|
/** Custom effect handlers (for integrating with your data layer) */
|
|
1076
1092
|
effectHandlers?: Partial<EffectHandlers>;
|
|
1077
1093
|
/** Persistence adapter for entity data */
|
|
@@ -1162,6 +1178,14 @@ declare class OrbitalServerRuntime {
|
|
|
1162
1178
|
private appThemeKey;
|
|
1163
1179
|
/** Wired by the hosting server (e.g. the playground SSE endpoint) via `setLiveBroadcastSink`. */
|
|
1164
1180
|
private liveBroadcastSink;
|
|
1181
|
+
/**
|
|
1182
|
+
* Tick-broadcast relay (T6): newest pending item per
|
|
1183
|
+
* (originClientId, orbital, event), flushed to the live-broadcast sink on
|
|
1184
|
+
* the `tickRelayIntervalMs` cadence — other tabs get the latest position
|
|
1185
|
+
* at snapshot rate, never 1:1 with emissions.
|
|
1186
|
+
*/
|
|
1187
|
+
private readonly tickRelayPending;
|
|
1188
|
+
private tickRelayTimer;
|
|
1165
1189
|
/**
|
|
1166
1190
|
* Trait name -> resolved `TraitConfig`, computed once per `register()` via
|
|
1167
1191
|
* `buildResolvedTraitConfigs` (`@almadar/core`). An embedded sub-trait's
|
|
@@ -1382,6 +1406,13 @@ declare class OrbitalServerRuntime {
|
|
|
1382
1406
|
setDefaultUser(user: UserContext | undefined): void;
|
|
1383
1407
|
/** The viewer a dev host is currently presenting the app as. */
|
|
1384
1408
|
getDefaultUser(): UserContext | undefined;
|
|
1409
|
+
/**
|
|
1410
|
+
* Queue a tick-stamped dispatch for coalesced snapshot relay (T6). Newest
|
|
1411
|
+
* per (originClientId, orbital, event) wins between flushes — the standard
|
|
1412
|
+
* netcode position-broadcast discipline.
|
|
1413
|
+
*/
|
|
1414
|
+
private queueTickRelay;
|
|
1415
|
+
private flushTickRelay;
|
|
1385
1416
|
/**
|
|
1386
1417
|
* The registered app's declared persona roster: the live rows of its
|
|
1387
1418
|
* `[identity]` entity, mapped onto viewers (`Almadar_LOLO_Identity.md` §4.3).
|
|
@@ -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-
|
|
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-PI9Ioxdp.js';
|
|
3
3
|
import './types-TwQ8Dybu.js';
|
|
4
4
|
import '@almadar/core';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createTickScheduler, EventBus, createUnifiedLoader, MockPersistenceAdapter, InMemoryPersistence, preprocessSchema, normalizeCallSiteConfigToValues, StateMachineManager, parseDurationString, validateEventPayload, formatPayloadValidationError, collectDeclaredConfigDefaults, collectDeclaredEntityDefaults, EffectExecutor } from './chunk-
|
|
2
|
-
export { InMemoryPersistence, collectDeclaredConfigDefaults } from './chunk-
|
|
1
|
+
import { createTickScheduler, EventBus, createUnifiedLoader, MockPersistenceAdapter, InMemoryPersistence, preprocessSchema, normalizeCallSiteConfigToValues, StateMachineManager, parseDurationString, validateEventPayload, formatPayloadValidationError, collectDeclaredConfigDefaults, collectDeclaredEntityDefaults, EffectExecutor } from './chunk-WSNZNXZE.js';
|
|
2
|
+
export { InMemoryPersistence, collectDeclaredConfigDefaults } from './chunk-WSNZNXZE.js';
|
|
3
3
|
import { isValidCronExpression } from './chunk-OU3ITB5S.js';
|
|
4
4
|
import { createContextFromBindings, resolveCallSitePayloadCaptures, applyRowAccess, checkMutationAccess, accessDeniedMessage } from './chunk-ZJ62H3ES.js';
|
|
5
5
|
import './chunk-T4VDAB4C.js';
|
|
@@ -137,6 +137,14 @@ var OrbitalServerRuntime = class {
|
|
|
137
137
|
appThemeKey;
|
|
138
138
|
/** Wired by the hosting server (e.g. the playground SSE endpoint) via `setLiveBroadcastSink`. */
|
|
139
139
|
liveBroadcastSink = null;
|
|
140
|
+
/**
|
|
141
|
+
* Tick-broadcast relay (T6): newest pending item per
|
|
142
|
+
* (originClientId, orbital, event), flushed to the live-broadcast sink on
|
|
143
|
+
* the `tickRelayIntervalMs` cadence — other tabs get the latest position
|
|
144
|
+
* at snapshot rate, never 1:1 with emissions.
|
|
145
|
+
*/
|
|
146
|
+
tickRelayPending = /* @__PURE__ */ new Map();
|
|
147
|
+
tickRelayTimer = null;
|
|
140
148
|
/**
|
|
141
149
|
* Trait name -> resolved `TraitConfig`, computed once per `register()` via
|
|
142
150
|
* `buildResolvedTraitConfigs` (`@almadar/core`). An embedded sub-trait's
|
|
@@ -1047,6 +1055,37 @@ var OrbitalServerRuntime = class {
|
|
|
1047
1055
|
getDefaultUser() {
|
|
1048
1056
|
return this.config.defaultUser;
|
|
1049
1057
|
}
|
|
1058
|
+
/**
|
|
1059
|
+
* Queue a tick-stamped dispatch for coalesced snapshot relay (T6). Newest
|
|
1060
|
+
* per (originClientId, orbital, event) wins between flushes — the standard
|
|
1061
|
+
* netcode position-broadcast discipline.
|
|
1062
|
+
*/
|
|
1063
|
+
queueTickRelay(orbitalName, request) {
|
|
1064
|
+
const key = `${request.clientId ?? ""}:${orbitalName}:${request.event}`;
|
|
1065
|
+
this.tickRelayPending.set(key, {
|
|
1066
|
+
event: request.event,
|
|
1067
|
+
payload: request.payload,
|
|
1068
|
+
source: { orbital: orbitalName, trait: request.sourceTrait, tick: request.tick },
|
|
1069
|
+
originClientId: request.clientId
|
|
1070
|
+
});
|
|
1071
|
+
if (this.tickRelayTimer === null) {
|
|
1072
|
+
const timer = setInterval(() => this.flushTickRelay(), this.config.tickRelayIntervalMs ?? 50);
|
|
1073
|
+
if (typeof timer === "object" && typeof timer.unref === "function") timer.unref();
|
|
1074
|
+
this.tickRelayTimer = timer;
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
flushTickRelay() {
|
|
1078
|
+
if (this.tickRelayPending.size === 0) {
|
|
1079
|
+
if (this.tickRelayTimer !== null) {
|
|
1080
|
+
clearInterval(this.tickRelayTimer);
|
|
1081
|
+
this.tickRelayTimer = null;
|
|
1082
|
+
}
|
|
1083
|
+
return;
|
|
1084
|
+
}
|
|
1085
|
+
const items = Array.from(this.tickRelayPending.values());
|
|
1086
|
+
this.tickRelayPending.clear();
|
|
1087
|
+
for (const item of items) this.liveBroadcastSink?.(item);
|
|
1088
|
+
}
|
|
1050
1089
|
/**
|
|
1051
1090
|
* The registered app's declared persona roster: the live rows of its
|
|
1052
1091
|
* `[identity]` entity, mapped onto viewers (`Almadar_LOLO_Identity.md` §4.3).
|
|
@@ -1252,6 +1291,9 @@ var OrbitalServerRuntime = class {
|
|
|
1252
1291
|
if (effectResults.length > 0) {
|
|
1253
1292
|
response.effectResults = effectResults;
|
|
1254
1293
|
}
|
|
1294
|
+
if (request.tick !== void 0 && this.liveBroadcastSink !== null) {
|
|
1295
|
+
this.queueTickRelay(orbitalName, request);
|
|
1296
|
+
}
|
|
1255
1297
|
return response;
|
|
1256
1298
|
} catch (error) {
|
|
1257
1299
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -234,9 +234,9 @@ var TickScheduler = class {
|
|
|
234
234
|
}
|
|
235
235
|
tick.accumulatedMs += timestamp - tick.lastTimestamp;
|
|
236
236
|
tick.lastTimestamp = timestamp;
|
|
237
|
-
|
|
238
|
-
tick.accumulatedMs -= tick.intervalMs;
|
|
237
|
+
if (tick.accumulatedMs >= tick.intervalMs) {
|
|
239
238
|
tick.onDue();
|
|
239
|
+
tick.accumulatedMs = tick.accumulatedMs % tick.intervalMs;
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
242
|
}
|
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-TwQ8Dybu.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-TwQ8Dybu.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-
|
|
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-
|
|
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-PI9Ioxdp.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-PI9Ioxdp.js';
|
|
5
5
|
import { EvaluationContext, SExpressionEvaluator } from '@almadar/evaluator';
|
|
6
6
|
export { EvaluationContext, createMinimalContext } from '@almadar/evaluator';
|
|
7
7
|
import { RenderBindingMarker, SExpr, TraitConfigObject, EventPayload, PatternConfig, EntityId, EntityField, EntityRow, EntityPersistence, ServiceParams, EntityAccessPolicies, PayloadField, OrbitalDefinition, OrbitalSchema } from '@almadar/core';
|
|
@@ -146,8 +146,13 @@ declare function createUnifiedLoader(options: UnifiedLoaderOptions): UnifiedLoad
|
|
|
146
146
|
* isn't available, e.g. Node/SSR) that walks every registered tick each pass
|
|
147
147
|
* and fires whichever one(s) have crossed their own interval — so ticks due
|
|
148
148
|
* in the same pass commit together instead of on independent, uncoordinated
|
|
149
|
-
* timers.
|
|
150
|
-
* (
|
|
149
|
+
* timers. Each interval tick fires AT MOST ONCE per pass: missed beats are
|
|
150
|
+
* dropped (the phase remainder is kept, so healthy cadence is unchanged),
|
|
151
|
+
* because bursting catch-up firings after a slow pass multiplies the work
|
|
152
|
+
* that made the pass slow — an unbounded accumulator is a spiral-of-death
|
|
153
|
+
* amplifier that pegs the main thread and starves input. Framework-light:
|
|
154
|
+
* no React, usable from `OrbitalServerRuntime` (this package) and from
|
|
155
|
+
* `@almadar/ui`'s `useTraitStateMachine` alike.
|
|
151
156
|
*
|
|
152
157
|
* @packageDocumentation
|
|
153
158
|
*/
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { EffectExecutor } from './chunk-
|
|
2
|
-
export { EffectExecutor, EventBus, HANDLER_MANIFEST, InMemoryPersistence, MockPersistenceAdapter, StateMachineManager, TickScheduler, buildEmitsFromTraits, collectDeclaredConfigDefaults, collectDeclaredEntityDefaults, createInitialTraitState, createMockPersistence, createTestExecutor, createTickScheduler, createUnifiedLoader, findInitialState, findTransition, formatPayloadValidationError, getIsolatedCollectionName, getNamespacedEvent, isBrowser, isElectron, isNamespacedEvent, isNode, isValidDurationString, normalizeCallSiteConfigToValues, normalizeEventKey, parseDurationString, parseNamespacedEvent, preprocessSchema, processEvent, validateEventPayload, validatePayloadShapes } from './chunk-
|
|
1
|
+
import { EffectExecutor } from './chunk-WSNZNXZE.js';
|
|
2
|
+
export { EffectExecutor, EventBus, HANDLER_MANIFEST, InMemoryPersistence, MockPersistenceAdapter, StateMachineManager, TickScheduler, buildEmitsFromTraits, collectDeclaredConfigDefaults, collectDeclaredEntityDefaults, createInitialTraitState, createMockPersistence, createTestExecutor, createTickScheduler, createUnifiedLoader, findInitialState, findTransition, formatPayloadValidationError, getIsolatedCollectionName, getNamespacedEvent, isBrowser, isElectron, isNamespacedEvent, isNode, isValidDurationString, normalizeCallSiteConfigToValues, normalizeEventKey, parseDurationString, parseNamespacedEvent, preprocessSchema, processEvent, validateEventPayload, validatePayloadShapes } from './chunk-WSNZNXZE.js';
|
|
3
3
|
export { cronMatches, cronMinuteKey, isValidCronExpression, parseCron, parseCronField } from './chunk-OU3ITB5S.js';
|
|
4
4
|
import { createContextFromBindings, applyRowAccess, checkMutationAccess, accessDeniedMessage } from './chunk-ZJ62H3ES.js';
|
|
5
5
|
export { CALLSITE_PAYLOAD_PREFIX, applyRowAccess, checkMutationAccess, containsBindings, createContextFromBindings, createMinimalContext, deferEntityBindings, extractBindings, interpolateProps, interpolateValue, resolveCallSitePayloadCaptures } from './chunk-ZJ62H3ES.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@almadar/runtime",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.59.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.
|
|
60
|
+
"@almadar/core": "^10.68.0",
|
|
61
61
|
"@almadar/evaluator": "^2.41.0",
|
|
62
62
|
"@almadar/logger": "^1.11.0",
|
|
63
63
|
"@almadar/server": "^2.37.0",
|
|
64
|
-
"@almadar/std": "^16.
|
|
64
|
+
"@almadar/std": "^16.184.0"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
67
|
"express": "^5.0.0"
|