@almadar/runtime 6.52.0 → 6.54.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.
@@ -1152,6 +1152,11 @@ declare class OrbitalServerRuntime {
1152
1152
  private substrateHandlers;
1153
1153
  private substrateHandlersPromise;
1154
1154
  private resolvedSchema;
1155
+ /** App-level theme key from the schema's `theme "<key>"` header — the
1156
+ * `@currentTheme` fallback between an orbital's own `theme` and
1157
+ * `DEFAULT_THEME_KEY`. Set at registration, before the orbital loops
1158
+ * (`resolvedSchema` is assigned only after them). */
1159
+ private appThemeKey;
1155
1160
  /** Wired by the hosting server (e.g. the playground SSE endpoint) via `setLiveBroadcastSink`. */
1156
1161
  private liveBroadcastSink;
1157
1162
  /**
@@ -1,4 +1,4 @@
1
1
  import 'express';
2
- export { F as ClientEffectTuple, G as ClientNavigateTuple, H as ClientNotifyTuple, J as ClientRenderUITuple, K as EffectResult, e as InMemoryPersistence, M as LiveBroadcastItem, N as LoaderConfig, O as OrbitalEventRequest, f as OrbitalEventResponse, Q as OrbitalServerRuntime, g as OrbitalServerRuntimeConfig, P as PersistenceAdapter, R as RegisteredOrbital, l as RuntimeOrbital, m as RuntimeOrbitalSchema, n as RuntimeTrait, T as RuntimeTraitTick, p as collectDeclaredConfigDefaults, V as createOrbitalServerRuntime } from './OrbitalServerRuntime-DRvduqA7.js';
2
+ export { F as ClientEffectTuple, G as ClientNavigateTuple, H as ClientNotifyTuple, J as ClientRenderUITuple, K as EffectResult, e as InMemoryPersistence, M as LiveBroadcastItem, N as LoaderConfig, O as OrbitalEventRequest, f as OrbitalEventResponse, Q as OrbitalServerRuntime, g as OrbitalServerRuntimeConfig, P as PersistenceAdapter, R as RegisteredOrbital, l as RuntimeOrbital, m as RuntimeOrbitalSchema, n as RuntimeTrait, T as RuntimeTraitTick, p as collectDeclaredConfigDefaults, V as createOrbitalServerRuntime } from './OrbitalServerRuntime-Cz5MiWKB.js';
3
3
  import './types-BcPORH_x.js';
4
4
  import '@almadar/core';
@@ -1,7 +1,7 @@
1
- import { createTickScheduler, EventBus, createUnifiedLoader, MockPersistenceAdapter, InMemoryPersistence, preprocessSchema, normalizeCallSiteConfigToValues, StateMachineManager, parseDurationString, validateEventPayload, formatPayloadValidationError, collectDeclaredConfigDefaults, collectDeclaredEntityDefaults, EffectExecutor } from './chunk-EHFQOBQH.js';
2
- export { InMemoryPersistence, collectDeclaredConfigDefaults } from './chunk-EHFQOBQH.js';
1
+ import { createTickScheduler, EventBus, createUnifiedLoader, MockPersistenceAdapter, InMemoryPersistence, preprocessSchema, normalizeCallSiteConfigToValues, StateMachineManager, parseDurationString, validateEventPayload, formatPayloadValidationError, collectDeclaredConfigDefaults, collectDeclaredEntityDefaults, EffectExecutor } from './chunk-DERIA6MO.js';
2
+ export { InMemoryPersistence, collectDeclaredConfigDefaults } from './chunk-DERIA6MO.js';
3
3
  import { isValidCronExpression } from './chunk-OU3ITB5S.js';
4
- import { createContextFromBindings, resolveCallSitePayloadCaptures, applyRowAccess, checkMutationAccess, accessDeniedMessage } from './chunk-ORBJ5YEQ.js';
4
+ import { createContextFromBindings, resolveCallSitePayloadCaptures, applyRowAccess, checkMutationAccess, accessDeniedMessage } from './chunk-ZJ62H3ES.js';
5
5
  import './chunk-T4VDAB4C.js';
6
6
  import './chunk-SCRAHWOC.js';
7
7
  import './chunk-MLKGABMK.js';
@@ -84,17 +84,31 @@ function inlineNavItems(pages) {
84
84
  for (const page of pages) {
85
85
  if (isPageReference(page)) continue;
86
86
  const p = page;
87
- if (typeof p.path === "string" && typeof p.name === "string") {
88
- items.push({ href: p.path, label: p.name });
89
- }
87
+ if (typeof p.path !== "string" || typeof p.name !== "string") continue;
88
+ if (p.path.includes(":")) continue;
89
+ const item = {
90
+ href: p.path,
91
+ // `@label` annotation wins; else derive by stripping a trailing
92
+ // `Page` suffix from `name` (`ContactsPage` → `Contacts`).
93
+ label: p.label ?? deriveNavLabel(p.name)
94
+ };
95
+ if (typeof p.icon === "string") item.icon = p.icon;
96
+ items.push(item);
90
97
  }
91
98
  return items;
92
99
  }
100
+ function deriveNavLabel(name) {
101
+ if (name.endsWith("Page") && name.length > "Page".length) {
102
+ return name.slice(0, -"Page".length);
103
+ }
104
+ return name;
105
+ }
93
106
  function themeDataKey(theme) {
94
107
  if (theme === void 0) return "";
95
108
  if (typeof theme === "string") return theme;
96
109
  return theme.name;
97
110
  }
111
+ var DEFAULT_THEME_KEY = "minimalist-light";
98
112
  var OrbitalServerRuntime = class {
99
113
  orbitals = /* @__PURE__ */ new Map();
100
114
  eventBus;
@@ -115,6 +129,11 @@ var OrbitalServerRuntime = class {
115
129
  substrateHandlers = null;
116
130
  substrateHandlersPromise = null;
117
131
  resolvedSchema = null;
132
+ /** App-level theme key from the schema's `theme "<key>"` header — the
133
+ * `@currentTheme` fallback between an orbital's own `theme` and
134
+ * `DEFAULT_THEME_KEY`. Set at registration, before the orbital loops
135
+ * (`resolvedSchema` is assigned only after them). */
136
+ appThemeKey;
118
137
  /** Wired by the hosting server (e.g. the playground SSE endpoint) via `setLiveBroadcastSink`. */
119
138
  liveBroadcastSink = null;
120
139
  /**
@@ -287,6 +306,7 @@ var OrbitalServerRuntime = class {
287
306
  if (this.config.debug) {
288
307
  registerLog.debug("register:schema", { name: schema.name });
289
308
  }
309
+ this.appThemeKey = themeDataKey(schema.theme) || void 0;
290
310
  if (needsPreprocessing(schema)) {
291
311
  await this.ensureLoader();
292
312
  if (this.loader) {
@@ -353,6 +373,7 @@ var OrbitalServerRuntime = class {
353
373
  if (this.config.debug) {
354
374
  registerLog.debug("register:schema-sync", { name: schema.name });
355
375
  }
376
+ this.appThemeKey = themeDataKey(schema.theme) || void 0;
356
377
  this.applyIdentityOwnerFields(schema);
357
378
  for (const orbital of schema.orbitals) {
358
379
  this.registerOrbital(orbital);
@@ -1715,14 +1736,20 @@ var OrbitalServerRuntime = class {
1715
1736
  ...callSiteOverride ?? {}
1716
1737
  };
1717
1738
  }
1718
- const sigilPages = inlineNavItems(registered.schema.pages);
1739
+ const sigilPages = [];
1740
+ const seenPaths = /* @__PURE__ */ new Set();
1741
+ for (const reg of this.orbitals.values()) {
1742
+ for (const item of inlineNavItems(reg.schema.pages ?? [])) {
1743
+ if (seenPaths.has(item.href)) continue;
1744
+ seenPaths.add(item.href);
1745
+ sigilPages.push(item);
1746
+ }
1747
+ }
1719
1748
  if (sigilPages.length > 0) {
1720
1749
  bindings.pages = sigilPages;
1721
1750
  }
1722
- const sigilTheme = themeDataKey(registered.schema.theme);
1723
- if (sigilTheme) {
1724
- bindings.currentTheme = sigilTheme;
1725
- }
1751
+ const sigilTheme = themeDataKey(registered.schema.theme) || this.appThemeKey || DEFAULT_THEME_KEY;
1752
+ bindings.currentTheme = sigilTheme;
1726
1753
  const entityFieldDefaults = collectDeclaredEntityDefaults(registered.entity);
1727
1754
  const traitFieldState = registered.traitFieldStates.get(this.sharedFieldKey(registered, traitName));
1728
1755
  if (entityFieldDefaults || traitFieldState) {
@@ -1,5 +1,5 @@
1
1
  import { parseCron, cronMinuteKey, cronMatches } from './chunk-OU3ITB5S.js';
2
- import { createContextFromBindings, interpolateValue, deferEntityBindings } from './chunk-ORBJ5YEQ.js';
2
+ import { createContextFromBindings, interpolateValue, deferEntityBindings } from './chunk-ZJ62H3ES.js';
3
3
  import { seedRandom, randomArrayElement, randomInt, shuffleArray, randomPastDate } from './chunk-T4VDAB4C.js';
4
4
  import { collectTraitRefsFromValue, collectTraitRefsFromEffects } from './chunk-SCRAHWOC.js';
5
5
  import { createLogger, setNamespaceLevel } from '@almadar/logger';
@@ -113,6 +113,38 @@ function interpolateValue(value, ctx) {
113
113
  }
114
114
  return value;
115
115
  }
116
+ function resolveConfigLeavesInLambdaBody(node, ctx) {
117
+ if (typeof node === "string") {
118
+ if (!node.startsWith("@config.") || node.includes(" ")) return node;
119
+ const resolved = resolveBinding(node, ctx);
120
+ deferLog.debug("lambda:config-leaf", () => ({
121
+ binding: node,
122
+ resolvedType: typeof resolved,
123
+ selfForward: resolved === node
124
+ }));
125
+ return resolved === node ? void 0 : resolved;
126
+ }
127
+ if (Array.isArray(node)) {
128
+ let changed = false;
129
+ const out = node.map((item) => {
130
+ const next = resolveConfigLeavesInLambdaBody(item, ctx);
131
+ if (next !== item) changed = true;
132
+ return next;
133
+ });
134
+ return changed ? out : node;
135
+ }
136
+ if (node !== null && typeof node === "object" && !(node instanceof Date)) {
137
+ let changed = false;
138
+ const out = {};
139
+ for (const [key, item] of Object.entries(node)) {
140
+ const next = resolveConfigLeavesInLambdaBody(item, ctx);
141
+ if (next !== item) changed = true;
142
+ out[key] = next;
143
+ }
144
+ return changed ? out : node;
145
+ }
146
+ return node;
147
+ }
116
148
  function deferEntityBindings(value, ctx, configHops = 0) {
117
149
  if (typeof value === "string") {
118
150
  if (containsEntityBinding(value) && !containsPayloadBinding(value)) {
@@ -133,7 +165,7 @@ function deferEntityBindings(value, ctx, configHops = 0) {
133
165
  }
134
166
  if (Array.isArray(value)) {
135
167
  if (value.length === 3 && value[0] === "fn" && typeof value[1] === "string") {
136
- return value;
168
+ return resolveConfigLeavesInLambdaBody(value, ctx);
137
169
  }
138
170
  if (isSExpression(value)) {
139
171
  if (containsEntityBinding(value) && !containsPayloadBinding(value)) {
@@ -203,7 +235,7 @@ function interpolateArray(value, ctx) {
203
235
  return value;
204
236
  }
205
237
  if (Array.isArray(value) && value.length === 3 && value[0] === "fn" && typeof value[1] === "string") {
206
- return value;
238
+ return resolveConfigLeavesInLambdaBody(value, ctx);
207
239
  }
208
240
  if (isSExpression(value)) {
209
241
  const result = evaluate(value, ctx);
@@ -1,2 +1,2 @@
1
- export { accessDeniedMessage, applyRowAccess, checkMutationAccess } from './chunk-ORBJ5YEQ.js';
1
+ export { accessDeniedMessage, applyRowAccess, checkMutationAccess } from './chunk-ZJ62H3ES.js';
2
2
  import './chunk-MLKGABMK.js';
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, T as TraitDefinition } from './types-BcPORH_x.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-BcPORH_x.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-DRvduqA7.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-DRvduqA7.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-Cz5MiWKB.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-Cz5MiWKB.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';
@@ -294,18 +294,6 @@ declare function interpolateValue(value: unknown, ctx: EvaluationContext): unkno
294
294
  type DeferredPatternValue = RuntimePatternValue | RenderBindingMarker | SExpr | Date | readonly DeferredPatternValue[] | {
295
295
  readonly [prop: string]: DeferredPatternValue;
296
296
  };
297
- /**
298
- * Carry `@entity`-dependent prop leaves into slot content as
299
- * `RenderBindingMarker`s instead of resolving them at flush time — the
300
- * renderer (`@almadar/ui`'s SlotContentRenderer) evaluates each marker
301
- * against the live entity store on every React render, the same model the
302
- * compiled shell uses. Everything else resolves eagerly through the same
303
- * `interpolateValue` path the non-deferring executor uses:
304
- * - payload-referencing leaves stay eager (`@payload` is event-scoped and
305
- * does not exist at render time);
306
- * - `fn` render lambdas pass through raw (they are already render-time);
307
- * - literal arrays (children lists) and plain objects recurse per item.
308
- */
309
297
  declare function deferEntityBindings(value: SExpr, ctx: EvaluationContext, configHops?: number): DeferredPatternValue;
310
298
  /**
311
299
  * Check if a value contains any binding references.
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
- import { EffectExecutor } from './chunk-EHFQOBQH.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-EHFQOBQH.js';
1
+ import { EffectExecutor } from './chunk-DERIA6MO.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-DERIA6MO.js';
3
3
  export { cronMatches, cronMinuteKey, isValidCronExpression, parseCron, parseCronField } from './chunk-OU3ITB5S.js';
4
- import { createContextFromBindings, applyRowAccess, checkMutationAccess, accessDeniedMessage } from './chunk-ORBJ5YEQ.js';
5
- export { CALLSITE_PAYLOAD_PREFIX, applyRowAccess, checkMutationAccess, containsBindings, createContextFromBindings, createMinimalContext, deferEntityBindings, extractBindings, interpolateProps, interpolateValue, resolveCallSitePayloadCaptures } from './chunk-ORBJ5YEQ.js';
4
+ import { createContextFromBindings, applyRowAccess, checkMutationAccess, accessDeniedMessage } from './chunk-ZJ62H3ES.js';
5
+ export { CALLSITE_PAYLOAD_PREFIX, applyRowAccess, checkMutationAccess, containsBindings, createContextFromBindings, createMinimalContext, deferEntityBindings, extractBindings, interpolateProps, interpolateValue, resolveCallSitePayloadCaptures } from './chunk-ZJ62H3ES.js';
6
6
  import './chunk-T4VDAB4C.js';
7
7
  export { PERF_NAMESPACE, RendererContractViolationError, adjustSchemaForMockData, aggregateSlotContent, assertIsMultiSourceSlotManager, assertIsSlotManager, bindEventBus, bindTraitStateGetter, buildMockData, buildOrbitalsByTrait, clearPerf, createSlotSetter, ensureVerificationApi, getOrbitalVerification, perfEnd, perfStart, perfStore, perfTime, prepareSchemaForPreview, pushPerfEntry, validateSlotContent, wrapCallbackForEvent } from './chunk-FOFLEZRJ.js';
8
8
  export { collectEmbeddedTraits, collectTraitRefsFromResolvedTrait } from './chunk-SCRAHWOC.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almadar/runtime",
3
- "version": "6.52.0",
3
+ "version": "6.54.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.54.0",
61
- "@almadar/evaluator": "^2.40.0",
60
+ "@almadar/core": "^10.61.0",
61
+ "@almadar/evaluator": "^2.41.0",
62
62
  "@almadar/logger": "^1.11.0",
63
63
  "@almadar/server": "^2.34.0",
64
- "@almadar/std": "^16.167.0"
64
+ "@almadar/std": "^16.176.0"
65
65
  },
66
66
  "peerDependencies": {
67
67
  "express": "^5.0.0"