@almadar/core 10.41.0 → 10.43.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,6 +1,597 @@
1
- import './entity-DfD-iXkn.js';
2
- export { i as ComposeBehaviorsInput, j as ComposeBehaviorsResult, c7 as ComposeConnection, c8 as ComposePage, a6 as EventWiringEntry, aq as LayoutStrategy, c9 as MakeAtomOrbitalOpts, ca as MakeAtomOrbitalTraitOverrides, cb as MakeEntityOpts, cc as MakeLayoutTraitOpts, cd as MakeOrbitalWithUsesOpts, ce as MakePageOpts, cf as MakePageRefOpts, cg as MakePageRefOptsTyped, M as MakeTraitRefOpts, ch as MakeTraitRefOptsTyped, bS as applyEventWiring, ci as applyTraitConfigOverrides, cj as compose, bT as composeBehaviors, ck as connect, bU as detectLayoutStrategy, cl as ensureIdField, cm as extractTrait, cn as makeAtomOrbital, co as makeEntity, cp as makeLayoutTrait, cq as makeOrbital, cr as makeOrbitalWithUses, cs as makePage, ct as makePageRef, cu as makeRenderUI, cv as makeSchema, cw as makeSlot, cx as makeTraitRef, cy as mergeLedgers, cz as mergeOrbitals, cA as pipe, cB as plural, cC as wire } from './builders-CikYSzX6.js';
3
- import './trait-2E6TQw19.js';
4
- import './expression-DpAj1RzP.js';
1
+ import { I as IdentityLedger, A as AnyPatternConfig, U as UISlot, c as Effect, h as RenderBinding, i as RenderUIEffect, d as EntityId, e as Entity, E as EntityField, a as EntityPersistence, f as EntityRow } from './effect-NbTgX2yB.js';
2
+ import { a as OrbitalDefinition, O as OrbitalSchema, U as UseDeclaration, E as EntityRef, P as PageRef, b as Page, c as PageRefObject } from './schema-DdcBBHkb.js';
3
+ import { b as TraitConfig, g as Trait, T as TraitEventListener, h as CallSiteConfig, j as TraitEventContract, d as TraitRef, a as TraitReference } from './trait-DdBiEffx.js';
4
+ import { S as SExpr } from './expression-Yf7qvvOs.js';
5
5
  import 'zod';
6
- import './effect-DSbx6joe.js';
6
+
7
+ /**
8
+ * Event Wiring
9
+ *
10
+ * Applies cross-orbital event wiring to orbital definitions.
11
+ * Adds emits/listens declarations to traits so they can communicate
12
+ * across orbital boundaries.
13
+ *
14
+ * @packageDocumentation
15
+ */
16
+
17
+ /**
18
+ * A single event wiring entry connecting two traits across orbitals.
19
+ */
20
+ interface EventWiringEntry {
21
+ /** Source trait name or orbital name */
22
+ from: string;
23
+ /** Event name (UPPER_SNAKE_CASE) */
24
+ event: string;
25
+ /** Target trait name or orbital name */
26
+ to: string;
27
+ /** Event to trigger on the listener side */
28
+ triggers: string;
29
+ }
30
+ /**
31
+ * Apply event wiring to orbital definitions.
32
+ *
33
+ * For each wiring entry:
34
+ * 1. Find the source trait and add an external emit (if not already present)
35
+ * 2. Find the target trait and add an external listen (if not already present)
36
+ *
37
+ * Returns a new array of orbitals with wiring applied (deep-cloned).
38
+ */
39
+ declare function applyEventWiring(orbitals: OrbitalDefinition[], wiring: EventWiringEntry[]): OrbitalDefinition[];
40
+
41
+ /**
42
+ * Layout Strategy Detection
43
+ *
44
+ * Auto-detects the best layout strategy for a composed application
45
+ * based on the number of orbitals and their event wiring topology.
46
+ *
47
+ * @packageDocumentation
48
+ */
49
+
50
+ /**
51
+ * Layout strategy for the composed application.
52
+ *
53
+ * - 'single': One orbital, one page
54
+ * - 'tabs': 2-4 orbitals with no sequential chain
55
+ * - 'sidebar': 5+ orbitals (navigation-heavy)
56
+ * - 'dashboard': Single page with all orbitals visible
57
+ * - 'wizard-flow': Sequential event chain detected (A -> B -> C)
58
+ */
59
+ type LayoutStrategy = 'sidebar' | 'tabs' | 'dashboard' | 'wizard-flow' | 'single';
60
+ /**
61
+ * Detect the best layout strategy based on orbital count and event wiring.
62
+ *
63
+ * Heuristic:
64
+ * 1. Sequential event chain detected -> 'wizard-flow'
65
+ * 2. 1 orbital -> 'single'
66
+ * 3. 2-4 orbitals -> 'tabs'
67
+ * 4. 5+ orbitals -> 'sidebar'
68
+ */
69
+ declare function detectLayoutStrategy(orbitals: OrbitalDefinition[], eventWiring?: EventWiringEntry[]): LayoutStrategy;
70
+
71
+ /**
72
+ * Compose Behaviors
73
+ *
74
+ * Main entry point for composing multiple orbital definitions into
75
+ * a single OrbitalSchema application. Handles event wiring, layout
76
+ * strategy detection, and page generation.
77
+ *
78
+ * @packageDocumentation
79
+ */
80
+
81
+ /**
82
+ * Union the identity ledgers of the schema-shaped inputs (V4 Phase 6, runtime
83
+ * mirror of the Rust compose ledger merge). Bare OrbitalDefinition inputs and
84
+ * ledger-less schemas contribute nothing (pre-V4 back-compat: no ledger in →
85
+ * no ledger out). Entries are keyed by id; first occurrence in input order wins
86
+ * for a duplicate id — the rows share one identity, so a `curName` divergence
87
+ * across slices resolves deterministically to the earliest input's row. Output
88
+ * entries are sorted by id for stable, order-independent composition.
89
+ */
90
+ declare function mergeLedgers(inputs: (OrbitalDefinition | OrbitalSchema)[]): IdentityLedger | undefined;
91
+ /**
92
+ * Input for composing behaviors into an application.
93
+ */
94
+ interface ComposeBehaviorsInput {
95
+ /** Application name */
96
+ appName: string;
97
+ /** Orbital definitions (or schemas) to compose */
98
+ orbitals: (OrbitalDefinition | OrbitalSchema)[];
99
+ /** Layout strategy override, or 'auto' to detect */
100
+ layoutStrategy?: LayoutStrategy | 'auto';
101
+ /** Cross-orbital event wiring */
102
+ eventWiring?: EventWiringEntry[];
103
+ /** Optional entity name mappings (original -> renamed) */
104
+ entityMappings?: Record<string, string>;
105
+ }
106
+ /**
107
+ * Result of composing behaviors.
108
+ */
109
+ interface ComposeBehaviorsResult {
110
+ /** The composed OrbitalSchema */
111
+ schema: OrbitalSchema;
112
+ /** Layout metadata */
113
+ layout: {
114
+ strategy: LayoutStrategy;
115
+ pageCount: number;
116
+ };
117
+ /** Wiring metadata */
118
+ wiring: {
119
+ connections: number;
120
+ };
121
+ }
122
+ /**
123
+ * Compose multiple orbital definitions into a single application schema.
124
+ *
125
+ * Steps:
126
+ * 1. Apply event wiring (adds emits/listens to traits)
127
+ * 2. Detect or use provided layout strategy
128
+ * 3. Generate pages based on the strategy
129
+ * 4. Build the final OrbitalSchema
130
+ */
131
+ declare function composeBehaviors(input: ComposeBehaviorsInput): ComposeBehaviorsResult;
132
+
133
+ /**
134
+ * Apply trait config overrides to a schema — pure, returns a new schema.
135
+ *
136
+ * Used by config-driven preview surfaces (the playground property inspector and
137
+ * the verify config-sweep) to render a behavior with different `config` values
138
+ * WITHOUT recompiling: the override is written onto the matching trait, then the
139
+ * schema is re-registered and re-rendered.
140
+ *
141
+ * The resolved schema's traits are inlined `Trait`s whose `config` is the
142
+ * DECLARED schema (`{ field: { type, default, ... } }`), so an override patches
143
+ * each field's `default`. A trait that instead carries call-site value config
144
+ * (a `{ ref, config }` reference) gets the values merged directly.
145
+ *
146
+ * @packageDocumentation
147
+ */
148
+
149
+ /**
150
+ * Return a new schema with `config` overrides applied to traits whose identity
151
+ * (`name`, falling back to `ref`) matches a key in `overrides`. Fields not
152
+ * declared on the trait are ignored — overrides never invent config.
153
+ */
154
+ declare function applyTraitConfigOverrides(schema: OrbitalSchema, overrides: Readonly<Record<string, TraitConfig>>): OrbitalSchema;
155
+
156
+ /**
157
+ * Layout-Trait Builders
158
+ *
159
+ * Helpers for constructing the canonical inline LayoutTrait pattern that
160
+ * std layout-shell molecules (`std-filtered-list`, `std-master-detail-layout`,
161
+ * etc.) use to wrap a set of atom trait references in a `(render-ui main)`
162
+ * effect with `@trait.X` slot embeds.
163
+ *
164
+ * The canonical LayoutTrait is stateless: ONE state (`composing`, initial),
165
+ * ONE transition (`INIT` self-loop) carrying two effects — `(fetch Entity
166
+ * {emit: {success, failure}})` and `(render-ui "main" <pattern-tree>)`. Atoms
167
+ * embedded via `@trait.X` slot references react to the bus events the fetch
168
+ * emits; the LayoutTrait owns no further state.
169
+ *
170
+ * Usage from a std layout-shell molecule:
171
+ *
172
+ * ```ts
173
+ * import { makeSlot, makeLayoutTrait } from '@almadar/core/builders';
174
+ *
175
+ * const layout = makeLayoutTrait({
176
+ * name: 'DashboardLayout',
177
+ * linkedEntity: 'Metric',
178
+ * fetchEntity: 'Metric',
179
+ * loadedEvent: 'MetricLoaded',
180
+ * loadFailedEvent: 'MetricLoadFailed',
181
+ * renderUI: {
182
+ * type: 'stack',
183
+ * direction: 'vertical',
184
+ * children: [
185
+ * makeSlot('StatsRow'),
186
+ * makeSlot('ChartsRow'),
187
+ * makeSlot('FeedRow'),
188
+ * ],
189
+ * },
190
+ * });
191
+ * ```
192
+ *
193
+ * @packageDocumentation
194
+ */
195
+
196
+ /**
197
+ * Build a `@trait.<name>` slot reference string. Used as a child entry in a
198
+ * pattern tree to embed another trait's render-ui at that position. The
199
+ * runtime resolves `@trait.X` to the matching trait's render-ui inline.
200
+ *
201
+ * @example makeSlot('FilteredItemSearch') // "@trait.FilteredItemSearch"
202
+ */
203
+ declare function makeSlot(traitName: string): string;
204
+ /**
205
+ * Build a `(render-ui <slot> <root>)` effect tuple. Pattern-typed sugar over
206
+ * the raw `RenderUIEffect` literal so callers don't have to spell out the
207
+ * three-element tuple form.
208
+ *
209
+ * @param slot - Canonical UI slot name (`'main'`, `'header'`, etc. — see UI_SLOTS).
210
+ * @param root - The pattern config for this slot's content, OR a `@`-binding
211
+ * string ({@link RenderBinding}) pointing at a render tree in `config` /
212
+ * `payload` (e.g. `'@config.bodyContent'`). Pass `null` to clear.
213
+ */
214
+ declare function makeRenderUI(slot: UISlot, root: AnyPatternConfig | RenderBinding | null): RenderUIEffect;
215
+ /**
216
+ * Options for {@link makeLayoutTrait}.
217
+ */
218
+ interface MakeLayoutTraitOpts {
219
+ /** Trait name, e.g. `"DashboardGridLayout"`. */
220
+ name: string;
221
+ /** Entity this layout's emits/listens bind to. */
222
+ linkedEntity: string;
223
+ /** Optional human-readable description (carried through to `Trait.description`). */
224
+ description?: string;
225
+ /**
226
+ * Entity name to fetch on INIT. When set, a `(fetch <Entity> {emit:
227
+ * {success, failure}})` effect is prepended to the INIT transition. Omit
228
+ * for purely-presentational layouts that don't load data themselves.
229
+ */
230
+ fetchEntity?: string;
231
+ /**
232
+ * Event name emitted on successful fetch. Required when `fetchEntity` is
233
+ * set; the LayoutTrait declares this event in its `emits` and uses it as
234
+ * the `success` emit-name in the fetch effect.
235
+ * Convention: `"<Entity>Loaded"`.
236
+ */
237
+ loadedEvent?: string;
238
+ /**
239
+ * Event name emitted on fetch failure. Required when `fetchEntity` is
240
+ * set. Convention: `"<Entity>LoadFailed"`.
241
+ */
242
+ loadFailedEvent?: string;
243
+ /**
244
+ * Payload schema for the loaded event. Defaults to `[{ name: "data", type:
245
+ * "[<Entity>]" }]` when `fetchEntity` is set. Provide explicitly when the
246
+ * payload should carry additional fields.
247
+ */
248
+ loadedPayloadSchema?: Array<{
249
+ name: string;
250
+ type: string;
251
+ required?: boolean;
252
+ }>;
253
+ /**
254
+ * The pattern tree for the layout's main slot. Children may include
255
+ * `@trait.X` slot strings (built via {@link makeSlot}) interleaved with
256
+ * inline pattern configs (`{ type: 'stack', ... }`). The shape conforms to
257
+ * `AnyPatternConfig` from `@almadar/patterns`.
258
+ */
259
+ renderUI: AnyPatternConfig;
260
+ /**
261
+ * Override the slot the render-ui effect targets. Defaults to `'main'`.
262
+ * Specify when the layout shell should render into a sub-slot (rare).
263
+ */
264
+ slot?: UISlot;
265
+ /**
266
+ * Additional effects appended to the INIT transition AFTER the fetch +
267
+ * render-ui pair. Most layouts don't need this; provided for advanced
268
+ * cases (analytics emit, persistence seed, etc.).
269
+ */
270
+ extraEffects?: Effect[];
271
+ }
272
+ /**
273
+ * Build the canonical stateless LayoutTrait used by std layout-shell molecules.
274
+ *
275
+ * Result shape:
276
+ * - `category: 'interaction'`, `scope: 'instance'`
277
+ * - `linkedEntity` set per the option
278
+ * - `emits` declares the loaded + loadFailed events when `fetchEntity` is set
279
+ * - One state: `'composing'` (`isInitial: true`)
280
+ * - One transition: `composing → composing` on `INIT`, with effects:
281
+ * - (when `fetchEntity` set) `['fetch', '<Entity>', { emit: { success, failure } }]`
282
+ * - `['render-ui', slot, renderUI]`
283
+ * - …`extraEffects` if provided
284
+ *
285
+ * Atoms whose trait names appear as `@trait.<name>` strings inside `renderUI`
286
+ * get embedded by the runtime when the orbital instantiates. The LayoutTrait
287
+ * itself stays stateless — all reactive behaviour lives in the embedded atoms.
288
+ */
289
+ declare function makeLayoutTrait(opts: MakeLayoutTraitOpts): Trait;
290
+
291
+ /**
292
+ * Orbital Builders
293
+ *
294
+ * Pure functions for constructing and composing Orbitals.
295
+ * No new types. Everything uses existing core types:
296
+ * Entity, Trait, Page, OrbitalDefinition, OrbitalSchema.
297
+ *
298
+ * Three categories:
299
+ * 1. Builders: construct Entity, Page from common params
300
+ * 2. Utilities: ensureIdField, resolveDefaults
301
+ * 3. Composition: connect, compose, pipe
302
+ *
303
+ * @packageDocumentation
304
+ */
305
+
306
+ /**
307
+ * Ensure the fields array has an `id` field. Prepends one if missing.
308
+ */
309
+ declare function ensureIdField(fields?: EntityField[]): EntityField[];
310
+ /**
311
+ * Simple pluralization: append 's'.
312
+ */
313
+ declare function plural(name: string): string;
314
+ interface MakeEntityOpts {
315
+ name: string;
316
+ fields: EntityField[];
317
+ persistence?: EntityPersistence;
318
+ collection?: string;
319
+ /** Pre-authored seed data instances */
320
+ instances?: EntityRow[];
321
+ }
322
+ /**
323
+ * Build an Entity from options. Auto-adds id field, auto-derives collection.
324
+ */
325
+ declare function makeEntity(opts: MakeEntityOpts): Entity;
326
+ interface MakePageOpts {
327
+ name: string;
328
+ path: string;
329
+ traitName: string;
330
+ isInitial?: boolean;
331
+ }
332
+ /**
333
+ * Build a Page that binds to a single trait.
334
+ */
335
+ declare function makePage(opts: MakePageOpts): Page;
336
+ /**
337
+ * Build an OrbitalDefinition from its three components.
338
+ */
339
+ declare function makeOrbital(name: string, entity: Entity, traits: Trait[], pages: Page[]): OrbitalDefinition;
340
+ /**
341
+ * Options for {@link makeTraitRef}.
342
+ */
343
+ interface MakeTraitRefOpts {
344
+ /**
345
+ * Optional registry path disambiguator that pairs with {@link ref}
346
+ * (see {@link TraitReference.from}).
347
+ */
348
+ from?: string;
349
+ /** Trait reference string, e.g. "Browse.traits.BrowseItemBrowse". */
350
+ ref: string;
351
+ /** Rename the inlined trait at the call site. */
352
+ name?: string;
353
+ /** Rebind the trait to a different linkedEntity. */
354
+ linkedEntity?: string;
355
+ /** Dual-carry id sibling of {@link linkedEntity} (V4 identity graph). */
356
+ linkedEntityId?: EntityId;
357
+ /** Per-key rename map, e.g. `{ OPEN: "ADD_ITEM" }`. */
358
+ events?: Record<string, string>;
359
+ /**
360
+ * Entity-field remap, e.g. `{ name: "title", folder: "parentId" }`. Rewrites
361
+ * the inlined trait's canonical `@entity.X` / `@payload.row.X` references to
362
+ * the consumer entity's field names. Mirrors {@link TraitReference.fields}.
363
+ */
364
+ fields?: Record<string, string>;
365
+ /**
366
+ * Per-event SExpression effect replacement. Keys are POST-rename event
367
+ * names. See {@link TraitReference.effects} for the full contract.
368
+ */
369
+ effects?: Record<string, SExpr[]>;
370
+ /** Replace the imported trait's `listens` array entirely. */
371
+ listens?: TraitEventListener[];
372
+ /** Set every emit's scope. */
373
+ emitsScope?: 'internal' | 'external';
374
+ /**
375
+ * Call-site config overrides. Each entry is either a plain wiring value
376
+ * (`TraitConfigValue`) or a fully-annotated re-declaration
377
+ * (`ConfigFieldDeclaration`). Matches {@link TraitReference.config}.
378
+ */
379
+ config?: CallSiteConfig;
380
+ }
381
+ /**
382
+ * Typed-narrowing variant of {@link MakeTraitRefOpts} for callers that know
383
+ * the imported atom's overridable surfaces — its event-key set, listen-key
384
+ * set, and config shape. Generated std factories use this variant so an LLM
385
+ * tool consumer (orbital-agent) sees the closed event-name set and the
386
+ * config field schema instead of the un-narrowed `Record<string, string>` /
387
+ * `TraitConfig` defaults.
388
+ *
389
+ * Type parameters:
390
+ * - `EventKey` — string union of the atom's emit event names. Narrows the
391
+ * `events` rename map's keys to legal originals only.
392
+ * - `ConfigShape` — typed shape of the trait's `config { ... }` block (literal
393
+ * unions intact). Narrows the `config` override to the atom's actual fields.
394
+ * Extends `CallSiteConfig` to allow both plain wiring values and annotated
395
+ * declarations. Existing callers using plain `TraitConfig` shapes are
396
+ * unaffected (TraitConfig ⊆ CallSiteConfig).
397
+ * - `ListenKey` — string union of the atom's listen-key contract. Narrows
398
+ * each listens entry's `event` against the atom's real subscription set.
399
+ *
400
+ * Runtime behavior is unchanged — {@link makeTraitRef} accepts both the
401
+ * narrow and wide forms via the standard structural-typing rules. This is
402
+ * a type-level narrowing only; widening at the call boundary is intentional.
403
+ */
404
+ interface MakeTraitRefOptsTyped<EventKey extends string = string, ConfigShape extends CallSiteConfig = Record<string, never>, ListenKey extends string = string> extends Omit<MakeTraitRefOpts, 'events' | 'effects' | 'listens' | 'config'> {
405
+ /** Per-key rename map, narrowed to the atom's actual event keys. */
406
+ events?: Partial<Record<EventKey, string>>;
407
+ /**
408
+ * Per-event SExpression effect replacement. Keys are POST-rename event
409
+ * names so they're caller-defined (no narrowing here); values stay typed
410
+ * as `SExpr[]`.
411
+ */
412
+ effects?: Partial<Record<string, SExpr[]>>;
413
+ /**
414
+ * Replace the imported trait's `listens` array entirely. Each entry's
415
+ * `event` field is narrowed to {@link ListenKey} where the atom's
416
+ * subscription set is fixed; otherwise this widens to plain string.
417
+ */
418
+ listens?: Array<TraitEventListener & {
419
+ event?: ListenKey;
420
+ }>;
421
+ /** Typed call-site config overrides — narrowed to {@link ConfigShape}. */
422
+ config?: ConfigShape;
423
+ }
424
+ /**
425
+ * Build a {@link TraitReference} from options.
426
+ *
427
+ * Pass-through factory: copies only the fields that are actually provided,
428
+ * so optionals stay absent (no `key: undefined` slots) and the emitted
429
+ * object matches the inliner's expectation that "present = override".
430
+ */
431
+ declare function makeTraitRef(opts: MakeTraitRefOpts): TraitReference;
432
+ /**
433
+ * Options for {@link makePageRef}.
434
+ */
435
+ interface MakePageRefOpts {
436
+ /**
437
+ * Optional registry path disambiguator that pairs with {@link ref}
438
+ * (see {@link PageRefObject.from}).
439
+ */
440
+ from?: string;
441
+ /** Page reference string, e.g. "Browse.pages.BrowseItemPage". */
442
+ ref: string;
443
+ /** URL path override. */
444
+ path?: string;
445
+ /** Rebind the page's primary entity. */
446
+ linkedEntity?: string;
447
+ /** Replace the page's trait list. */
448
+ traits?: TraitRef[];
449
+ }
450
+ /**
451
+ * Typed-narrowing variant of {@link MakePageRefOpts}. Narrows the `traits`
452
+ * override array's entries to the orbital's known trait-name union — so the
453
+ * agent can't pass a trait name that doesn't exist on the page's owning
454
+ * orbital. Generated std page-helpers use this variant to surface the
455
+ * trait set in the tool schema; un-narrowed call sites stay compatible.
456
+ *
457
+ * Type parameter:
458
+ * - `TraitName` — string union of trait names the page may reference.
459
+ */
460
+ interface MakePageRefOptsTyped<TraitName extends string = string> extends Omit<MakePageRefOpts, 'traits'> {
461
+ traits?: Array<{
462
+ ref: TraitName;
463
+ } | TraitRef>;
464
+ }
465
+ /**
466
+ * Build a {@link PageRefObject} from options. Pass-through factory — omits
467
+ * optional keys that are `undefined`.
468
+ */
469
+ declare function makePageRef(opts: MakePageRefOpts): PageRefObject;
470
+ /**
471
+ * Options for {@link makeOrbitalWithUses}.
472
+ */
473
+ interface MakeOrbitalWithUsesOpts {
474
+ /** Orbital name. */
475
+ name: string;
476
+ /**
477
+ * Per-orbital `uses:` header entries (see CLAUDE.md "uses: lives inside
478
+ * the orbital").
479
+ */
480
+ uses: UseDeclaration[];
481
+ /** Entity (inline or reference form). */
482
+ entity: EntityRef;
483
+ /** Trait references. */
484
+ traits: TraitRef[];
485
+ /** Optional page references (omitted entirely when not provided). */
486
+ pages?: PageRef[];
487
+ }
488
+ /**
489
+ * Build an {@link OrbitalDefinition} with the `uses:` header set. Follows
490
+ * the convention that `uses:` lives on the orbital (not the schema).
491
+ *
492
+ * When `pages` is omitted, the result has no `pages` property (matches the
493
+ * existing {@link OrbitalDefinition.pages} optionality in descriptors that
494
+ * carry trait-only atoms).
495
+ */
496
+ declare function makeOrbitalWithUses(opts: MakeOrbitalWithUsesOpts): OrbitalDefinition;
497
+ /**
498
+ * Options for {@link makeAtomOrbital}.
499
+ *
500
+ * Overrides for the single trait reference. Mirrors the {@link MakeTraitRefOpts}
501
+ * subset that is meaningful at the atom-wrapping call site.
502
+ */
503
+ interface MakeAtomOrbitalTraitOverrides {
504
+ name?: string;
505
+ events?: Record<string, string>;
506
+ effects?: Record<string, SExpr[]>;
507
+ listens?: TraitEventListener[];
508
+ emitsScope?: 'internal' | 'external';
509
+ config?: CallSiteConfig;
510
+ }
511
+ /**
512
+ * Options for {@link makeAtomOrbital}.
513
+ */
514
+ interface MakeAtomOrbitalOpts {
515
+ /** Orbital name, e.g. `${entityName}Orbital`. */
516
+ name: string;
517
+ /** Atom registry path, e.g. `std/behaviors/atoms/std-browse`. */
518
+ atomPath: string;
519
+ /** Import alias (PascalCase), e.g. `Browse`. */
520
+ alias: string;
521
+ /** Entity definition to attach to the orbital. */
522
+ entity: Entity;
523
+ /** Trait reference string, e.g. `Browse.traits.BrowseItemBrowse`. */
524
+ traitRef: string;
525
+ /** Optional trait-level overrides applied at the call site. */
526
+ traitOverrides?: MakeAtomOrbitalTraitOverrides;
527
+ /** Optional page reference string, e.g. `Browse.pages.BrowseItemPage`. */
528
+ pageRef?: string;
529
+ /** Optional page-level overrides applied at the call site. */
530
+ pageOverrides?: {
531
+ path?: string;
532
+ };
533
+ }
534
+ /**
535
+ * Build a single-atom {@link OrbitalDefinition}.
536
+ *
537
+ * The common atom shape: one entity + one trait reference + (optionally) one
538
+ * page reference, all under a single `uses:` import. Wraps
539
+ * {@link makeTraitRef}, {@link makePageRef}, and {@link makeOrbitalWithUses}.
540
+ *
541
+ * The trait reference is linkedEntity-bound to `entity.name` by default so
542
+ * that the inliner's entity-substitution pass rewrites every `["ref", X]`
543
+ * and `@X.path` reference inside the atom.
544
+ */
545
+ declare function makeAtomOrbital(opts: MakeAtomOrbitalOpts): OrbitalDefinition;
546
+ /**
547
+ * Wrap one or more OrbitalDefinitions into an OrbitalSchema.
548
+ * Every .orb file should be a full OrbitalSchema — this is the builder for that.
549
+ */
550
+ declare function makeSchema(name: string, ...definitions: OrbitalDefinition[]): OrbitalSchema;
551
+ /**
552
+ * Merge multiple OrbitalDefinitions into one.
553
+ * Collects all traits from all sources into a single orbital with a shared entity.
554
+ * Pure: clones all traits, no mutation.
555
+ */
556
+ declare function mergeOrbitals(name: string, entity: Entity, sources: OrbitalDefinition[], pages: Page[]): OrbitalDefinition;
557
+ /**
558
+ * Wire an intra-orbital event between two traits.
559
+ * Adds emits to the source trait, listens to the target trait.
560
+ * Pure: returns cloned traits, no mutation.
561
+ */
562
+ declare function wire(source: Trait, target: Trait, event: TraitEventContract, triggers: string): [Trait, Trait];
563
+ /**
564
+ * Extract the first trait from an OrbitalDefinition or OrbitalSchema.
565
+ * If given an OrbitalSchema, unwraps to the first orbital inside it.
566
+ */
567
+ declare function extractTrait(input: OrbitalDefinition | OrbitalSchema): Trait;
568
+ /**
569
+ * Wire a cross-orbital event between two orbitals.
570
+ * Adds emits to a's first trait, listens to b's first trait.
571
+ * Pure: returns new orbitals, no mutation.
572
+ */
573
+ declare function connect(a: OrbitalDefinition | OrbitalSchema, b: OrbitalDefinition | OrbitalSchema, event: TraitEventContract, triggers?: string): [OrbitalDefinition, OrbitalDefinition];
574
+ interface ComposeConnection {
575
+ from: string;
576
+ to: string;
577
+ event: TraitEventContract;
578
+ triggers?: string;
579
+ }
580
+ interface ComposePage {
581
+ name: string;
582
+ path: string;
583
+ traits: string[];
584
+ isInitial?: boolean;
585
+ }
586
+ /**
587
+ * Compose multiple orbitals into a single OrbitalSchema (application).
588
+ * Applies connections (cross-orbital event wiring) and page assignments.
589
+ */
590
+ declare function compose(orbitals: (OrbitalDefinition | OrbitalSchema)[], pages: ComposePage[], connections: ComposeConnection[], appName?: string): OrbitalSchema;
591
+ /**
592
+ * Chain orbitals in sequence with automatic event wiring.
593
+ * Sugar over connect + compose: wires events[0] from orbital[0] to orbital[1], etc.
594
+ */
595
+ declare function pipe(orbitals: (OrbitalDefinition | OrbitalSchema)[], events: TraitEventContract[], appName?: string): OrbitalSchema;
596
+
597
+ export { type ComposeBehaviorsInput, type ComposeBehaviorsResult, type ComposeConnection, type ComposePage, type EventWiringEntry, type LayoutStrategy, type MakeAtomOrbitalOpts, type MakeAtomOrbitalTraitOverrides, type MakeEntityOpts, type MakeLayoutTraitOpts, type MakeOrbitalWithUsesOpts, type MakePageOpts, type MakePageRefOpts, type MakePageRefOptsTyped, type MakeTraitRefOpts, type MakeTraitRefOptsTyped, applyEventWiring, applyTraitConfigOverrides, compose, composeBehaviors, connect, detectLayoutStrategy, ensureIdField, extractTrait, makeAtomOrbital, makeEntity, makeLayoutTrait, makeOrbital, makeOrbitalWithUses, makePage, makePageRef, makeRenderUI, makeSchema, makeSlot, makeTraitRef, mergeLedgers, mergeOrbitals, pipe, plural, wire };