@almadar/ui 5.113.0 → 5.115.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.
@@ -1,5 +1,5 @@
1
1
  import * as _almadar_core from '@almadar/core';
2
- import { EventPayload, ServiceParams, ResolvedTraitBinding, ResolvedPage, ResolvedEntity, ResolvedTrait, ResolvedIR, OrbitalSchema, PatternConfig, FieldValue, EventSource, SExpr, EventPayloadValue, EntityRow, EntityData } from '@almadar/core';
2
+ import { EventPayload, ServiceParams, ResolvedTraitBinding, ResolvedPage, ResolvedEntity, ResolvedTrait, ResolvedIR, OrbitalSchema, PatternConfig, FieldValue, EventSource, SExpr, EntityRow, EntityData } from '@almadar/core';
3
3
  export { ResolvedEntity, ResolvedIR, ResolvedPage, ResolvedTrait, ResolvedTraitBinding } from '@almadar/core';
4
4
  import * as _almadar_runtime from '@almadar/runtime';
5
5
  import { TraitState, EffectHandlers } from '@almadar/runtime';
@@ -7,10 +7,12 @@ import '../useEventBus-Ckr4wqW3.cjs';
7
7
  import { c as useUISlots } from '../UISlotContext-D8_SoDsD.cjs';
8
8
  import { f as ServerBridgeTransport } from '../TraitProvider-YkK6tXDw.cjs';
9
9
  export { E as EntitySchemaContextValue, a as EntitySchemaProvider, b as EntitySchemaProviderProps, c as ServerBridgeContextValue, d as ServerBridgeProvider, g as ServerClientEffect, T as TraitContext, i as TraitContextValue, j as TraitInstance, k as TraitProvider, l as TraitProviderProps, u as useEntitySchema, m as useEntitySchemaOptional, n as useServerBridge, o as useTrait, p as useTraitContext } from '../TraitProvider-YkK6tXDw.cjs';
10
- import { PatternCallbackArg } from '@almadar/core/patterns';
10
+ import { PerfEntry } from '@almadar/runtime/ui';
11
+ export { PERF_NAMESPACE, PerfEntry, PreparedPreviewSchema, adjustSchemaForMockData, buildMockData, clearPerf, perfEnd, perfStart, perfTime, prepareSchemaForPreview, wrapCallbackForEvent } from '@almadar/runtime/ui';
11
12
  import React__default, { ProfilerOnRenderCallback } from 'react';
12
13
  import '../event-bus-types-Bl78kokd.cjs';
13
14
  import '../useUISlots-BesZYMks.cjs';
15
+ import '@almadar/core/patterns';
14
16
 
15
17
  interface TraitStateMachineResult {
16
18
  /** Current state for each trait */
@@ -145,21 +147,6 @@ interface SlotSource extends EventSource {
145
147
  traitDefinition: ResolvedTrait;
146
148
  }
147
149
 
148
- /**
149
- * Build the runtime wrapper that turns a string-typed callback prop
150
- * (e.g. `onTabChange: "TAB_CHANGED"`) into a function the component can
151
- * invoke. The wrapper consumes the component's positional callback args
152
- * by name and dispatches an OBJECT payload `{ argName: value, ... }` so
153
- * the bus carries the trait's declared event payload, not a raw
154
- * positional spread. Mirrors the codegen wrapper in
155
- * `orbital-shell-typescript/src/codegen/pattern.rs` (C2 compiled path).
156
- *
157
- * Single-sourcing this logic across runtime and codegen (shared shape,
158
- * not shared code — codegen emits string source) is what keeps the two
159
- * paths from silently diverging on payload shape.
160
- */
161
- declare function wrapCallbackForEvent(qualifiedEvent: string, callbackArgs: PatternCallbackArg[] | undefined, emit: (eventKey: string, payload?: EventPayload) => void): (...args: EventPayloadValue[]) => void;
162
-
163
150
  /**
164
151
  * Client Effect Handlers Factory
165
152
  *
@@ -307,7 +294,7 @@ declare namespace OrbPreview {
307
294
  interface BrowserPlaygroundProps {
308
295
  /** OrbitalSchema to render. */
309
296
  schema: OrbitalSchema;
310
- /** Persistence mode for the in-process runtime. Default: 'mock' (Faker-seeded MockPersistenceAdapter). */
297
+ /** Persistence mode for the in-process runtime. Default: 'mock' (seeded MockPersistenceAdapter). */
311
298
  mode?: 'mock';
312
299
  /** Initial page path to render (forwarded to OrbPreview). */
313
300
  initialPagePath?: string;
@@ -318,109 +305,21 @@ interface BrowserPlaygroundProps {
318
305
  }
319
306
  declare function BrowserPlayground({ schema, mode, initialPagePath, height, className, }: BrowserPlaygroundProps): React__default.ReactElement;
320
307
 
321
- /**
322
- * prepareSchemaForPreview
323
- *
324
- * Single source of truth for the "give an Orbital schema a runnable preview"
325
- * pipeline. Used by both:
326
- * * `<OrbPreview autoMock />` (the docs / MDX path)
327
- * * `PlaygroundContent` (the interactive playground)
328
- *
329
- * Type signature in `@almadar/core` terms:
330
- *
331
- * buildMockData : OrbitalSchema → EntityData
332
- * adjustSchemaForMockData: (OrbitalSchema, EntityData) → OrbitalSchema
333
- * prepareSchemaForPreview: OrbitalSchema → { schema: OrbitalSchema, mockData: EntityData }
334
- *
335
- * Steps:
336
- * 1. `buildMockData` — for each orbital, generate (or pick up from
337
- * `entity.instances`) `EntityRow[]` for that entity.
338
- * 2. `adjustSchemaForMockData` — flip two-state INIT machines so the data
339
- * state is initial (e.g. `empty -> hasItems` becomes `hasItems` initial).
340
- *
341
- * @packageDocumentation
342
- */
343
-
344
- /**
345
- * Build mock entity rows (`EntityData`) for every orbital in the schema.
346
- *
347
- * For each orbital's entity:
348
- * * If the entity has an `instances` array (from the schema author),
349
- * use it as-is.
350
- * * Otherwise generate 10 synthetic `EntityRow`s from the field
351
- * definitions via `generateEntityRow`.
352
- *
353
- * @public
354
- */
355
- declare function buildMockData(schema: OrbitalSchema): EntityData;
356
- /**
357
- * When mock data exists for a trait's linked entity, swap the state
358
- * machine's initial state to the state that also handles INIT (the "data
359
- * state"). This makes previews land directly in the populated UI.
360
- *
361
- * Behavior is per-trait:
362
- * * Inline traits with two-state INIT patterns are rewritten.
363
- * * String / object trait refs are left untouched (the resolver handles them).
364
- * * Single-state INIT machines are left untouched.
365
- *
366
- * @public
367
- */
368
- declare function adjustSchemaForMockData(schema: OrbitalSchema, mockData: EntityData): OrbitalSchema;
369
- /**
370
- * Result of `prepareSchemaForPreview`.
371
- *
372
- * @public
373
- */
374
- interface PreparedPreviewSchema {
375
- /** Schema with state machines flipped so data states are initial. */
376
- schema: OrbitalSchema;
377
- /** Mock entity rows keyed by entity name — pass to `OrbPreview.mockData`. */
378
- mockData: EntityData;
379
- }
380
- /**
381
- * Run the full preview prep pipeline on a schema.
382
- *
383
- * Accepts either an already-parsed `OrbitalSchema` or a JSON string.
384
- * Returns `{ schema, mockData }` ready to feed `<OrbPreview>`.
385
- *
386
- * Functional signature:
387
- * `OrbitalSchema | string → { schema: OrbitalSchema, mockData: EntityData }`
388
- *
389
- * @public
390
- */
391
- declare function prepareSchemaForPreview(input: OrbitalSchema | string): PreparedPreviewSchema;
392
-
393
308
  /**
394
309
  * @almadar/ui/runtime — perf instrumentation
395
310
  *
396
- * Ring buffer of timing events for the canvas render path, plus mark/measure
397
- * helpers and a React.Profiler onRender callback. All gated behind
398
- * `createLogger('almadar:perf:canvas')` so production (LOG_LEVEL >= WARN)
399
- * skips both `performance.*` calls and the ring write.
311
+ * React-specific consumption layer on top of the renderer-agnostic perf ring
312
+ * now living in `@almadar/runtime/ui/perf`. Re-exports the framework-free
313
+ * timing primitives and adds `useSyncExternalStore` / `React.Profiler` hooks.
400
314
  */
401
315
 
402
- declare const PERF_NAMESPACE = "almadar:perf:canvas";
403
- interface PerfEntry {
404
- readonly name: string;
405
- readonly durationMs: number;
406
- readonly ts: number;
407
- readonly detail?: Readonly<Record<string, unknown>>;
408
- }
409
316
  /**
410
- * Start a phase. Returns an opaque token; pass to {@link perfEnd}.
411
- * Returns -1 when the namespace is gated off, so call sites pay only one comparison.
317
+ * React hook: returns the current perf ring snapshot, re-renders on push.
412
318
  */
413
- declare function perfStart(name: string): number;
414
- declare function perfEnd(name: string, startToken: number, detail?: Record<string, unknown>): void;
415
- /** Synchronous wrapper that times a fn end-to-end. */
416
- declare function perfTime<T>(name: string, fn: () => T, detail?: Record<string, unknown>): T;
319
+ declare function usePerfBuffer(): readonly PerfEntry[];
417
320
  /**
418
321
  * React.Profiler `onRender` callback. Records `actualDuration` per commit.
419
- * Phase is `"mount" | "update" | "nested-update"`.
420
322
  */
421
323
  declare const profilerOnRender: ProfilerOnRenderCallback;
422
- /** React hook: returns the current ring snapshot, re-renders on push. */
423
- declare function usePerfBuffer(): readonly PerfEntry[];
424
- declare function clearPerf(): void;
425
324
 
426
- export { BrowserPlayground, type BrowserPlaygroundProps, type ClientEventBus, type CreateClientEffectHandlersOptions, OrbPreview, type OrbPreviewProps, PERF_NAMESPACE, type PerfEntry, type PreparedPreviewSchema, type ResolvedSchemaResult, ServerBridgeTransport, type SlotPatternEntry, type SlotSetter, type SlotSource, type TraitStateMachineResult, type UseTraitStateMachineOptions, adjustSchemaForMockData, buildMockData, clearPerf, clearSchemaCache, createClientEffectHandlers, perfEnd, perfStart, perfTime, prepareSchemaForPreview, profilerOnRender, usePerfBuffer, useResolvedSchema, useTraitStateMachine, wrapCallbackForEvent };
325
+ export { BrowserPlayground, type BrowserPlaygroundProps, type ClientEventBus, type CreateClientEffectHandlersOptions, OrbPreview, type OrbPreviewProps, type ResolvedSchemaResult, ServerBridgeTransport, type SlotPatternEntry, type SlotSetter, type SlotSource, type TraitStateMachineResult, type UseTraitStateMachineOptions, clearSchemaCache, createClientEffectHandlers, profilerOnRender, usePerfBuffer, useResolvedSchema, useTraitStateMachine };
@@ -1,5 +1,5 @@
1
1
  import * as _almadar_core from '@almadar/core';
2
- import { EventPayload, ServiceParams, ResolvedTraitBinding, ResolvedPage, ResolvedEntity, ResolvedTrait, ResolvedIR, OrbitalSchema, PatternConfig, FieldValue, EventSource, SExpr, EventPayloadValue, EntityRow, EntityData } from '@almadar/core';
2
+ import { EventPayload, ServiceParams, ResolvedTraitBinding, ResolvedPage, ResolvedEntity, ResolvedTrait, ResolvedIR, OrbitalSchema, PatternConfig, FieldValue, EventSource, SExpr, EntityRow, EntityData } from '@almadar/core';
3
3
  export { ResolvedEntity, ResolvedIR, ResolvedPage, ResolvedTrait, ResolvedTraitBinding } from '@almadar/core';
4
4
  import * as _almadar_runtime from '@almadar/runtime';
5
5
  import { TraitState, EffectHandlers } from '@almadar/runtime';
@@ -7,10 +7,12 @@ import '../useEventBus-CQWyAWpK.js';
7
7
  import { c as useUISlots } from '../UISlotContext-C1FsU9GB.js';
8
8
  import { f as ServerBridgeTransport } from '../TraitProvider-YkK6tXDw.js';
9
9
  export { E as EntitySchemaContextValue, a as EntitySchemaProvider, b as EntitySchemaProviderProps, c as ServerBridgeContextValue, d as ServerBridgeProvider, g as ServerClientEffect, T as TraitContext, i as TraitContextValue, j as TraitInstance, k as TraitProvider, l as TraitProviderProps, u as useEntitySchema, m as useEntitySchemaOptional, n as useServerBridge, o as useTrait, p as useTraitContext } from '../TraitProvider-YkK6tXDw.js';
10
- import { PatternCallbackArg } from '@almadar/core/patterns';
10
+ import { PerfEntry } from '@almadar/runtime/ui';
11
+ export { PERF_NAMESPACE, PerfEntry, PreparedPreviewSchema, adjustSchemaForMockData, buildMockData, clearPerf, perfEnd, perfStart, perfTime, prepareSchemaForPreview, wrapCallbackForEvent } from '@almadar/runtime/ui';
11
12
  import React__default, { ProfilerOnRenderCallback } from 'react';
12
13
  import '../event-bus-types-Bl78kokd.js';
13
14
  import '../useUISlots-BesZYMks.js';
15
+ import '@almadar/core/patterns';
14
16
 
15
17
  interface TraitStateMachineResult {
16
18
  /** Current state for each trait */
@@ -145,21 +147,6 @@ interface SlotSource extends EventSource {
145
147
  traitDefinition: ResolvedTrait;
146
148
  }
147
149
 
148
- /**
149
- * Build the runtime wrapper that turns a string-typed callback prop
150
- * (e.g. `onTabChange: "TAB_CHANGED"`) into a function the component can
151
- * invoke. The wrapper consumes the component's positional callback args
152
- * by name and dispatches an OBJECT payload `{ argName: value, ... }` so
153
- * the bus carries the trait's declared event payload, not a raw
154
- * positional spread. Mirrors the codegen wrapper in
155
- * `orbital-shell-typescript/src/codegen/pattern.rs` (C2 compiled path).
156
- *
157
- * Single-sourcing this logic across runtime and codegen (shared shape,
158
- * not shared code — codegen emits string source) is what keeps the two
159
- * paths from silently diverging on payload shape.
160
- */
161
- declare function wrapCallbackForEvent(qualifiedEvent: string, callbackArgs: PatternCallbackArg[] | undefined, emit: (eventKey: string, payload?: EventPayload) => void): (...args: EventPayloadValue[]) => void;
162
-
163
150
  /**
164
151
  * Client Effect Handlers Factory
165
152
  *
@@ -307,7 +294,7 @@ declare namespace OrbPreview {
307
294
  interface BrowserPlaygroundProps {
308
295
  /** OrbitalSchema to render. */
309
296
  schema: OrbitalSchema;
310
- /** Persistence mode for the in-process runtime. Default: 'mock' (Faker-seeded MockPersistenceAdapter). */
297
+ /** Persistence mode for the in-process runtime. Default: 'mock' (seeded MockPersistenceAdapter). */
311
298
  mode?: 'mock';
312
299
  /** Initial page path to render (forwarded to OrbPreview). */
313
300
  initialPagePath?: string;
@@ -318,109 +305,21 @@ interface BrowserPlaygroundProps {
318
305
  }
319
306
  declare function BrowserPlayground({ schema, mode, initialPagePath, height, className, }: BrowserPlaygroundProps): React__default.ReactElement;
320
307
 
321
- /**
322
- * prepareSchemaForPreview
323
- *
324
- * Single source of truth for the "give an Orbital schema a runnable preview"
325
- * pipeline. Used by both:
326
- * * `<OrbPreview autoMock />` (the docs / MDX path)
327
- * * `PlaygroundContent` (the interactive playground)
328
- *
329
- * Type signature in `@almadar/core` terms:
330
- *
331
- * buildMockData : OrbitalSchema → EntityData
332
- * adjustSchemaForMockData: (OrbitalSchema, EntityData) → OrbitalSchema
333
- * prepareSchemaForPreview: OrbitalSchema → { schema: OrbitalSchema, mockData: EntityData }
334
- *
335
- * Steps:
336
- * 1. `buildMockData` — for each orbital, generate (or pick up from
337
- * `entity.instances`) `EntityRow[]` for that entity.
338
- * 2. `adjustSchemaForMockData` — flip two-state INIT machines so the data
339
- * state is initial (e.g. `empty -> hasItems` becomes `hasItems` initial).
340
- *
341
- * @packageDocumentation
342
- */
343
-
344
- /**
345
- * Build mock entity rows (`EntityData`) for every orbital in the schema.
346
- *
347
- * For each orbital's entity:
348
- * * If the entity has an `instances` array (from the schema author),
349
- * use it as-is.
350
- * * Otherwise generate 10 synthetic `EntityRow`s from the field
351
- * definitions via `generateEntityRow`.
352
- *
353
- * @public
354
- */
355
- declare function buildMockData(schema: OrbitalSchema): EntityData;
356
- /**
357
- * When mock data exists for a trait's linked entity, swap the state
358
- * machine's initial state to the state that also handles INIT (the "data
359
- * state"). This makes previews land directly in the populated UI.
360
- *
361
- * Behavior is per-trait:
362
- * * Inline traits with two-state INIT patterns are rewritten.
363
- * * String / object trait refs are left untouched (the resolver handles them).
364
- * * Single-state INIT machines are left untouched.
365
- *
366
- * @public
367
- */
368
- declare function adjustSchemaForMockData(schema: OrbitalSchema, mockData: EntityData): OrbitalSchema;
369
- /**
370
- * Result of `prepareSchemaForPreview`.
371
- *
372
- * @public
373
- */
374
- interface PreparedPreviewSchema {
375
- /** Schema with state machines flipped so data states are initial. */
376
- schema: OrbitalSchema;
377
- /** Mock entity rows keyed by entity name — pass to `OrbPreview.mockData`. */
378
- mockData: EntityData;
379
- }
380
- /**
381
- * Run the full preview prep pipeline on a schema.
382
- *
383
- * Accepts either an already-parsed `OrbitalSchema` or a JSON string.
384
- * Returns `{ schema, mockData }` ready to feed `<OrbPreview>`.
385
- *
386
- * Functional signature:
387
- * `OrbitalSchema | string → { schema: OrbitalSchema, mockData: EntityData }`
388
- *
389
- * @public
390
- */
391
- declare function prepareSchemaForPreview(input: OrbitalSchema | string): PreparedPreviewSchema;
392
-
393
308
  /**
394
309
  * @almadar/ui/runtime — perf instrumentation
395
310
  *
396
- * Ring buffer of timing events for the canvas render path, plus mark/measure
397
- * helpers and a React.Profiler onRender callback. All gated behind
398
- * `createLogger('almadar:perf:canvas')` so production (LOG_LEVEL >= WARN)
399
- * skips both `performance.*` calls and the ring write.
311
+ * React-specific consumption layer on top of the renderer-agnostic perf ring
312
+ * now living in `@almadar/runtime/ui/perf`. Re-exports the framework-free
313
+ * timing primitives and adds `useSyncExternalStore` / `React.Profiler` hooks.
400
314
  */
401
315
 
402
- declare const PERF_NAMESPACE = "almadar:perf:canvas";
403
- interface PerfEntry {
404
- readonly name: string;
405
- readonly durationMs: number;
406
- readonly ts: number;
407
- readonly detail?: Readonly<Record<string, unknown>>;
408
- }
409
316
  /**
410
- * Start a phase. Returns an opaque token; pass to {@link perfEnd}.
411
- * Returns -1 when the namespace is gated off, so call sites pay only one comparison.
317
+ * React hook: returns the current perf ring snapshot, re-renders on push.
412
318
  */
413
- declare function perfStart(name: string): number;
414
- declare function perfEnd(name: string, startToken: number, detail?: Record<string, unknown>): void;
415
- /** Synchronous wrapper that times a fn end-to-end. */
416
- declare function perfTime<T>(name: string, fn: () => T, detail?: Record<string, unknown>): T;
319
+ declare function usePerfBuffer(): readonly PerfEntry[];
417
320
  /**
418
321
  * React.Profiler `onRender` callback. Records `actualDuration` per commit.
419
- * Phase is `"mount" | "update" | "nested-update"`.
420
322
  */
421
323
  declare const profilerOnRender: ProfilerOnRenderCallback;
422
- /** React hook: returns the current ring snapshot, re-renders on push. */
423
- declare function usePerfBuffer(): readonly PerfEntry[];
424
- declare function clearPerf(): void;
425
324
 
426
- export { BrowserPlayground, type BrowserPlaygroundProps, type ClientEventBus, type CreateClientEffectHandlersOptions, OrbPreview, type OrbPreviewProps, PERF_NAMESPACE, type PerfEntry, type PreparedPreviewSchema, type ResolvedSchemaResult, ServerBridgeTransport, type SlotPatternEntry, type SlotSetter, type SlotSource, type TraitStateMachineResult, type UseTraitStateMachineOptions, adjustSchemaForMockData, buildMockData, clearPerf, clearSchemaCache, createClientEffectHandlers, perfEnd, perfStart, perfTime, prepareSchemaForPreview, profilerOnRender, usePerfBuffer, useResolvedSchema, useTraitStateMachine, wrapCallbackForEvent };
325
+ export { BrowserPlayground, type BrowserPlaygroundProps, type ClientEventBus, type CreateClientEffectHandlersOptions, OrbPreview, type OrbPreviewProps, type ResolvedSchemaResult, ServerBridgeTransport, type SlotPatternEntry, type SlotSetter, type SlotSource, type TraitStateMachineResult, type UseTraitStateMachineOptions, clearSchemaCache, createClientEffectHandlers, profilerOnRender, usePerfBuffer, useResolvedSchema, useTraitStateMachine };