@cyberart-io/engine 0.0.4 → 0.0.5
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/README.md +41 -18
- package/dist/headless.d.ts +497 -67
- package/dist/headless.js +1 -1
- package/dist/index.d.ts +470 -7
- package/dist/index.js +1 -1
- package/docs/asset-resolver.md +4 -4
- package/docs/browser-harness.md +126 -0
- package/docs/capability-manifest.md +18 -7
- package/docs/compositor.md +103 -0
- package/docs/deterministic-mode.md +1 -1
- package/docs/events.md +75 -13
- package/docs/headless-harness.md +44 -14
- package/docs/presentation-adapter.md +8 -8
- package/docs/presentation-cue.md +2 -2
- package/docs/replay-inspector.md +88 -0
- package/docs/runtime-group.md +9 -7
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -48,7 +48,7 @@ type TokenData = {
|
|
|
48
48
|
*
|
|
49
49
|
* A full 64-hex hash (optional `0x`) is returned unchanged aside from a
|
|
50
50
|
* lowercase `0x` prefix — this is the kaleidoscope / Art Blocks path.
|
|
51
|
-
* Any other seed (including the
|
|
51
|
+
* Any other seed (including the numeric example `42`) is mixed into
|
|
52
52
|
* a 64-hex hash so `Random` always sees the same shape.
|
|
53
53
|
*/
|
|
54
54
|
declare function canonicalizeSeed(seed: string | number): string;
|
|
@@ -256,8 +256,8 @@ type NormalizeResult = NormalizeSuccess | NormalizeFailure;
|
|
|
256
256
|
/**
|
|
257
257
|
* `kind` on the input wins. Otherwise persistence types are intents, then
|
|
258
258
|
* the first dotted segment that is `intent` | `state` | `diagnostic`.
|
|
259
|
-
* `
|
|
260
|
-
* is not one); put the kind in the name, e.g. `
|
|
259
|
+
* `host.presentation.*` does not infer a kind (the presentation segment
|
|
260
|
+
* is not one); put the kind in the name, e.g. `host.presentation.intent.*`.
|
|
261
261
|
*/
|
|
262
262
|
declare function inferEventKind(input: EventInput): EventKind | undefined;
|
|
263
263
|
declare function matchEventPattern(pattern: string, type: string): boolean;
|
|
@@ -815,15 +815,49 @@ type EventRouterOptions = {
|
|
|
815
815
|
maxHops?: number;
|
|
816
816
|
maxCorrelationPerTurn?: number;
|
|
817
817
|
maxIndex?: number;
|
|
818
|
+
/** Bound on the decision trace (oldest dropped). Default 256. */
|
|
819
|
+
maxDecisions?: number;
|
|
818
820
|
};
|
|
819
821
|
type PublishExtras = {
|
|
820
822
|
cause?: EventEnvelope;
|
|
821
823
|
};
|
|
824
|
+
type RouterParticipantInspect = {
|
|
825
|
+
id: string;
|
|
826
|
+
emit: string[];
|
|
827
|
+
subscribe: string[];
|
|
828
|
+
authoritative: boolean;
|
|
829
|
+
};
|
|
830
|
+
type RouterDecisionOutcome = 'accepted' | 'rejected' | 'duplicate';
|
|
831
|
+
type RouterDecisionReason = RejectionReason | 'duplicate';
|
|
832
|
+
type RouterDecision = {
|
|
833
|
+
outcome: RouterDecisionOutcome;
|
|
834
|
+
reason?: RouterDecisionReason;
|
|
835
|
+
detail?: string;
|
|
836
|
+
source: string;
|
|
837
|
+
type: string;
|
|
838
|
+
kind?: EventKind;
|
|
839
|
+
envelopeId?: string;
|
|
840
|
+
priorEnvelopeId?: string;
|
|
841
|
+
target?: string;
|
|
842
|
+
deliveredTo: string[];
|
|
843
|
+
hops?: number;
|
|
844
|
+
seq?: number;
|
|
845
|
+
correlationId?: string;
|
|
846
|
+
causationId?: string;
|
|
847
|
+
idempotencyKey?: string;
|
|
848
|
+
schemaVersion?: number;
|
|
849
|
+
payload?: unknown;
|
|
850
|
+
turn: number;
|
|
851
|
+
time: number;
|
|
852
|
+
};
|
|
822
853
|
type EventRouter = {
|
|
823
854
|
attach(id: string, channel: HostChannel, options?: AttachOptions): void;
|
|
824
855
|
detach(id: string): void;
|
|
825
856
|
publish(event: EventInput, extras?: PublishExtras): EventEnvelope | undefined;
|
|
826
857
|
subscribe(patterns: string[], listener: (event: EventEnvelope) => void): () => void;
|
|
858
|
+
subscribeDecision(listener: (decision: RouterDecision) => void): () => void;
|
|
859
|
+
inspectParticipants(): RouterParticipantInspect[];
|
|
860
|
+
inspectDecisions(): RouterDecision[];
|
|
827
861
|
turn(): void;
|
|
828
862
|
};
|
|
829
863
|
declare function createEventRouter(options?: EventRouterOptions): EventRouter;
|
|
@@ -836,7 +870,7 @@ declare function createEventRouter(options?: EventRouterOptions): EventRouter;
|
|
|
836
870
|
* One contract definition drives TypeScript payload types, runtime
|
|
837
871
|
* validation, router permission checks, and machine-readable manifests.
|
|
838
872
|
* Kind must appear as a dotted segment of `type` so names like
|
|
839
|
-
* `
|
|
873
|
+
* `host.presentation.cue.started` fail at definition time instead of
|
|
840
874
|
* silently inferring a bogus kind.
|
|
841
875
|
*/
|
|
842
876
|
|
|
@@ -931,7 +965,7 @@ declare function createContractRegistry(contracts: EventContract[]): ContractReg
|
|
|
931
965
|
*
|
|
932
966
|
* Versioned presentation-adapter contract. Hosts own canonical state and
|
|
933
967
|
* push a render model; Cyberart presents it and emits interaction intents.
|
|
934
|
-
*
|
|
968
|
+
* Host domain concepts stay in the host.
|
|
935
969
|
*/
|
|
936
970
|
|
|
937
971
|
declare const PRESENTATION_ADAPTER_VERSION: 1;
|
|
@@ -946,7 +980,7 @@ declare const PRESENTATION_PHASES: readonly ["loading", "ready", "error", "unsup
|
|
|
946
980
|
type PresentationPhase = (typeof PRESENTATION_PHASES)[number];
|
|
947
981
|
/**
|
|
948
982
|
* Recommended router `subscribe` for a presentation cart. Intent type names
|
|
949
|
-
* are host-owned (`
|
|
983
|
+
* are host-owned (`host.intent.*`); do not put domain objects in `target`.
|
|
950
984
|
*/
|
|
951
985
|
declare const PRESENTATION_SUBSCRIBE_PATTERNS: readonly ["presentation.state.*", "cyberart.diagnostic.rejected"];
|
|
952
986
|
declare const INVALID_PRESENTATION_MODEL_MESSAGE = "Presentation adapter: model is invalid or not JSON-serializable";
|
|
@@ -1137,6 +1171,10 @@ declare const CAPABILITY_ASSET_KINDS: readonly ["image", "audio", "font", "sprit
|
|
|
1137
1171
|
type CapabilityAssetKind = (typeof CAPABILITY_ASSET_KINDS)[number];
|
|
1138
1172
|
declare const CAPABILITY_INTEGRATIONS: readonly ["tone", "midi"];
|
|
1139
1173
|
type CapabilityIntegration = (typeof CAPABILITY_INTEGRATIONS)[number];
|
|
1174
|
+
declare const CAPABILITY_BLEND_MODES: readonly ["source-over", "screen"];
|
|
1175
|
+
type CapabilityBlendMode = (typeof CAPABILITY_BLEND_MODES)[number];
|
|
1176
|
+
declare const CAPABILITY_CLEAR_POLICIES: readonly ["transparent", "opaque"];
|
|
1177
|
+
type CapabilityClearPolicy = (typeof CAPABILITY_CLEAR_POLICIES)[number];
|
|
1140
1178
|
type CapabilityDiagnostic = {
|
|
1141
1179
|
code: string;
|
|
1142
1180
|
detail: string;
|
|
@@ -1159,6 +1197,16 @@ type CapabilityPermissions = {
|
|
|
1159
1197
|
subscribe: string[];
|
|
1160
1198
|
authoritative?: boolean;
|
|
1161
1199
|
};
|
|
1200
|
+
/** Optional surface requirements. Omitted on existing manifests. */
|
|
1201
|
+
type CapabilitySurfaceRequirements = {
|
|
1202
|
+
alpha?: boolean;
|
|
1203
|
+
clearPolicy?: CapabilityClearPolicy;
|
|
1204
|
+
};
|
|
1205
|
+
/** Optional compositor/layer requirements. Omitted on existing manifests. */
|
|
1206
|
+
type CapabilityLayerRequirements = {
|
|
1207
|
+
compositor?: boolean;
|
|
1208
|
+
blend?: CapabilityBlendMode[];
|
|
1209
|
+
};
|
|
1162
1210
|
type CapabilityManifest = {
|
|
1163
1211
|
version: typeof CAPABILITY_MANIFEST_VERSION;
|
|
1164
1212
|
id: string;
|
|
@@ -1170,6 +1218,8 @@ type CapabilityManifest = {
|
|
|
1170
1218
|
emittedEvents: string[];
|
|
1171
1219
|
permissions: CapabilityPermissions;
|
|
1172
1220
|
integrations: CapabilityIntegration[];
|
|
1221
|
+
surface?: CapabilitySurfaceRequirements;
|
|
1222
|
+
layers?: CapabilityLayerRequirements;
|
|
1173
1223
|
};
|
|
1174
1224
|
type CapabilityManifestInput = {
|
|
1175
1225
|
version?: number;
|
|
@@ -1182,6 +1232,8 @@ type CapabilityManifestInput = {
|
|
|
1182
1232
|
emittedEvents: string[];
|
|
1183
1233
|
permissions: CapabilityPermissions;
|
|
1184
1234
|
integrations: CapabilityIntegration[];
|
|
1235
|
+
surface?: CapabilitySurfaceRequirements;
|
|
1236
|
+
layers?: CapabilityLayerRequirements;
|
|
1185
1237
|
};
|
|
1186
1238
|
type HostCapabilities = {
|
|
1187
1239
|
contractVersion: number;
|
|
@@ -1190,6 +1242,10 @@ type HostCapabilities = {
|
|
|
1190
1242
|
managers?: CapabilityManager[];
|
|
1191
1243
|
emit?: string[];
|
|
1192
1244
|
subscribe?: string[];
|
|
1245
|
+
surface?: CapabilitySurfaceRequirements & {
|
|
1246
|
+
clearPolicy?: CapabilityClearPolicy | CapabilityClearPolicy[];
|
|
1247
|
+
};
|
|
1248
|
+
layers?: CapabilityLayerRequirements;
|
|
1193
1249
|
};
|
|
1194
1250
|
type DefineCapabilityManifestResult = {
|
|
1195
1251
|
ok: true;
|
|
@@ -1440,6 +1496,8 @@ type CreateRuntimeGroupOptions = {
|
|
|
1440
1496
|
now?: () => number;
|
|
1441
1497
|
/** Extra router options. Group injects shared `createId` / `now` unless set here. */
|
|
1442
1498
|
router?: EventRouterOptions;
|
|
1499
|
+
/** Bound on the accepted-event trace (oldest dropped). Default 1024. */
|
|
1500
|
+
maxTrace?: number;
|
|
1443
1501
|
};
|
|
1444
1502
|
type RuntimeGroupParticipantInspect = {
|
|
1445
1503
|
state: unknown;
|
|
@@ -1447,6 +1505,9 @@ type RuntimeGroupParticipantInspect = {
|
|
|
1447
1505
|
errors: RuntimeGroupFrameError[];
|
|
1448
1506
|
kind: RuntimeGroupKind;
|
|
1449
1507
|
clock: ClockSnapshot;
|
|
1508
|
+
emit: string[];
|
|
1509
|
+
subscribe: string[];
|
|
1510
|
+
authoritative: boolean;
|
|
1450
1511
|
};
|
|
1451
1512
|
type RuntimeGroupDiagnostics = {
|
|
1452
1513
|
paused: boolean;
|
|
@@ -1477,11 +1538,413 @@ type RuntimeGroup = {
|
|
|
1477
1538
|
pause(): void;
|
|
1478
1539
|
resume(): void;
|
|
1479
1540
|
reset(): void;
|
|
1541
|
+
/** Shared viewport. Sets each container and canvas buffer size. Does not clear sibling pixels on detach. */
|
|
1542
|
+
resize(width: number, height: number): void;
|
|
1543
|
+
/** Tear down one participant without destroying the group or blanking siblings. */
|
|
1544
|
+
detach(id: string): void;
|
|
1480
1545
|
dispatch(participantId: string, event: HostEvent): void;
|
|
1481
1546
|
publish(event: EventInput, extras?: PublishExtras): EventEnvelope | undefined;
|
|
1547
|
+
inspectParticipants(): Array<RouterParticipantInspect & {
|
|
1548
|
+
kind: RuntimeGroupKind;
|
|
1549
|
+
}>;
|
|
1482
1550
|
inspect(): Promise<RuntimeGroupInspect>;
|
|
1483
1551
|
destroy(): void;
|
|
1484
1552
|
};
|
|
1485
1553
|
declare function createRuntimeGroup(options: CreateRuntimeGroupOptions): RuntimeGroup;
|
|
1486
1554
|
|
|
1487
|
-
|
|
1555
|
+
declare const REPLAY_INSPECTOR_SCHEMA_VERSION: 1;
|
|
1556
|
+
declare const DEFAULT_MAX_INSPECTOR_RECORDS = 512;
|
|
1557
|
+
declare const REDACTED_VALUE = "[REDACTED]";
|
|
1558
|
+
type ReplayTraceFilter = {
|
|
1559
|
+
types?: string[];
|
|
1560
|
+
sources?: string[];
|
|
1561
|
+
outcomes?: RouterDecisionOutcome[];
|
|
1562
|
+
correlationId?: string;
|
|
1563
|
+
};
|
|
1564
|
+
type CreateReplayInspectorOptions = {
|
|
1565
|
+
redactedKeys?: string[];
|
|
1566
|
+
maxRecords?: number;
|
|
1567
|
+
/** Optional contracts so records can include payload schema version. */
|
|
1568
|
+
registry?: Pick<ContractRegistry, 'get'>;
|
|
1569
|
+
};
|
|
1570
|
+
type InspectorRecord = {
|
|
1571
|
+
index: number;
|
|
1572
|
+
turn: number;
|
|
1573
|
+
time: number;
|
|
1574
|
+
outcome: RouterDecisionOutcome;
|
|
1575
|
+
reason?: RouterDecisionReason;
|
|
1576
|
+
detail?: string;
|
|
1577
|
+
source: string;
|
|
1578
|
+
target?: string;
|
|
1579
|
+
type: string;
|
|
1580
|
+
kind?: EventKind;
|
|
1581
|
+
envelopeId?: string;
|
|
1582
|
+
priorEnvelopeId?: string;
|
|
1583
|
+
correlationId?: string;
|
|
1584
|
+
causationId?: string;
|
|
1585
|
+
hops?: number;
|
|
1586
|
+
seq?: number;
|
|
1587
|
+
idempotencyKey?: string;
|
|
1588
|
+
schemaVersion?: number;
|
|
1589
|
+
payloadSchemaVersion?: number;
|
|
1590
|
+
deliveredTo: string[];
|
|
1591
|
+
payload?: unknown;
|
|
1592
|
+
};
|
|
1593
|
+
type CausationTreeNode = {
|
|
1594
|
+
envelopeId?: string;
|
|
1595
|
+
type: string;
|
|
1596
|
+
source: string;
|
|
1597
|
+
outcome: RouterDecisionOutcome;
|
|
1598
|
+
reason?: RouterDecisionReason;
|
|
1599
|
+
children: CausationTreeNode[];
|
|
1600
|
+
};
|
|
1601
|
+
type ReplayParticipantSummary = {
|
|
1602
|
+
id: string;
|
|
1603
|
+
kind?: RuntimeGroupKind;
|
|
1604
|
+
emit: string[];
|
|
1605
|
+
subscribe: string[];
|
|
1606
|
+
authoritative: boolean;
|
|
1607
|
+
seed?: string;
|
|
1608
|
+
clock?: ClockSnapshot;
|
|
1609
|
+
state?: unknown;
|
|
1610
|
+
errorCount: number;
|
|
1611
|
+
lastError?: string;
|
|
1612
|
+
};
|
|
1613
|
+
type ReplayInspectorReport = {
|
|
1614
|
+
schemaVersion: typeof REPLAY_INSPECTOR_SCHEMA_VERSION;
|
|
1615
|
+
participants: ReplayParticipantSummary[];
|
|
1616
|
+
records: InspectorRecord[];
|
|
1617
|
+
trees: CausationTreeNode[];
|
|
1618
|
+
dropped: number;
|
|
1619
|
+
};
|
|
1620
|
+
type ReplayTapeAction = {
|
|
1621
|
+
kind: 'publish';
|
|
1622
|
+
event: EventInput;
|
|
1623
|
+
extras?: PublishExtras;
|
|
1624
|
+
} | {
|
|
1625
|
+
kind: 'dispatch';
|
|
1626
|
+
participantId: string;
|
|
1627
|
+
event: HostEvent;
|
|
1628
|
+
} | {
|
|
1629
|
+
kind: 'step';
|
|
1630
|
+
frames: number;
|
|
1631
|
+
} | {
|
|
1632
|
+
kind: 'asset';
|
|
1633
|
+
participantId: string;
|
|
1634
|
+
event: HostEvent;
|
|
1635
|
+
};
|
|
1636
|
+
type ReplayInspectorExport = {
|
|
1637
|
+
schemaVersion: typeof REPLAY_INSPECTOR_SCHEMA_VERSION;
|
|
1638
|
+
origin: number;
|
|
1639
|
+
redactedKeys: string[];
|
|
1640
|
+
participants: ReplayParticipantSummary[];
|
|
1641
|
+
tape: ReplayTapeAction[];
|
|
1642
|
+
records: InspectorRecord[];
|
|
1643
|
+
snapshots: Record<string, unknown>;
|
|
1644
|
+
};
|
|
1645
|
+
type ReplayCompareResult = {
|
|
1646
|
+
ok: true;
|
|
1647
|
+
} | {
|
|
1648
|
+
ok: false;
|
|
1649
|
+
detail: string;
|
|
1650
|
+
};
|
|
1651
|
+
type BoundReplaySession = {
|
|
1652
|
+
publish(event: EventInput, extras?: PublishExtras): EventEnvelope | undefined;
|
|
1653
|
+
dispatch(participantId: string, event: HostEvent): void;
|
|
1654
|
+
step(frames?: number): Promise<void>;
|
|
1655
|
+
report(): Promise<ReplayInspectorReport>;
|
|
1656
|
+
exportTrace(filter?: ReplayTraceFilter): Promise<ReplayInspectorExport>;
|
|
1657
|
+
unbind(): void;
|
|
1658
|
+
};
|
|
1659
|
+
type ReplayInspector = {
|
|
1660
|
+
watchRouter(router: EventRouter): () => void;
|
|
1661
|
+
bind(group: RuntimeGroup): BoundReplaySession;
|
|
1662
|
+
importTrace(exported: ReplayInspectorExport | string): void;
|
|
1663
|
+
exportTrace(filter?: ReplayTraceFilter): ReplayInspectorExport;
|
|
1664
|
+
report(filter?: ReplayTraceFilter): ReplayInspectorReport;
|
|
1665
|
+
causationTree(correlationId?: string): CausationTreeNode[];
|
|
1666
|
+
records(): InspectorRecord[];
|
|
1667
|
+
reset(): void;
|
|
1668
|
+
destroy(): void;
|
|
1669
|
+
};
|
|
1670
|
+
declare function compareReplayTraces(expected: InspectorRecord[], actual: InspectorRecord[]): ReplayCompareResult;
|
|
1671
|
+
declare function createReplayInspector(options?: CreateReplayInspectorOptions): ReplayInspector;
|
|
1672
|
+
declare function replayExportedTrace(exported: ReplayInspectorExport, group: RuntimeGroup, options?: CreateReplayInspectorOptions): Promise<{
|
|
1673
|
+
inspector: ReplayInspector;
|
|
1674
|
+
report: ReplayInspectorReport;
|
|
1675
|
+
}>;
|
|
1676
|
+
|
|
1677
|
+
declare const COMPOSITOR_BLEND_MODES: readonly ["source-over", "screen"];
|
|
1678
|
+
type CompositorBlendMode = (typeof COMPOSITOR_BLEND_MODES)[number];
|
|
1679
|
+
declare const COMPOSITOR_CLEAR_POLICIES: readonly ["transparent", "opaque"];
|
|
1680
|
+
type CompositorClearPolicy = (typeof COMPOSITOR_CLEAR_POLICIES)[number];
|
|
1681
|
+
type CompositorPointerEvents = 'auto' | 'none';
|
|
1682
|
+
type CompositorClip = {
|
|
1683
|
+
x: number;
|
|
1684
|
+
y: number;
|
|
1685
|
+
width: number;
|
|
1686
|
+
height: number;
|
|
1687
|
+
};
|
|
1688
|
+
type CompositorLayerConfig = {
|
|
1689
|
+
id: string;
|
|
1690
|
+
order: number;
|
|
1691
|
+
visible?: boolean;
|
|
1692
|
+
opacity?: number;
|
|
1693
|
+
blend?: CompositorBlendMode;
|
|
1694
|
+
clip?: CompositorClip;
|
|
1695
|
+
pointerEvents?: CompositorPointerEvents;
|
|
1696
|
+
clearPolicy?: CompositorClearPolicy;
|
|
1697
|
+
};
|
|
1698
|
+
type CompositorLayerInspect = {
|
|
1699
|
+
id: string;
|
|
1700
|
+
order: number;
|
|
1701
|
+
visible: boolean;
|
|
1702
|
+
opacity: number;
|
|
1703
|
+
blend: CompositorBlendMode;
|
|
1704
|
+
clip: CompositorClip | null;
|
|
1705
|
+
pointerEvents: CompositorPointerEvents;
|
|
1706
|
+
clearPolicy: CompositorClearPolicy;
|
|
1707
|
+
};
|
|
1708
|
+
type CompositorHostOptions = {
|
|
1709
|
+
/** Back-layer pixels. Scaled nearest-neighbor to the compositor viewport. */
|
|
1710
|
+
image?: ImageData;
|
|
1711
|
+
/** Opaque CSS `#rgb` / `#rrggbb` fill when `image` is omitted. */
|
|
1712
|
+
color?: string;
|
|
1713
|
+
};
|
|
1714
|
+
type CreateCompositorOptions = {
|
|
1715
|
+
group: RuntimeGroup;
|
|
1716
|
+
layers: CompositorLayerConfig[];
|
|
1717
|
+
width?: number;
|
|
1718
|
+
height?: number;
|
|
1719
|
+
dpr?: number;
|
|
1720
|
+
host?: CompositorHostOptions;
|
|
1721
|
+
/**
|
|
1722
|
+
* Host surface clear. Default `transparent` — never fill black.
|
|
1723
|
+
* Per-layer `clearPolicy: 'transparent'` knocks out RGB 0,0,0 backing
|
|
1724
|
+
* pixels so opaque cart canvases can stack over a host image.
|
|
1725
|
+
*/
|
|
1726
|
+
clearPolicy?: CompositorClearPolicy;
|
|
1727
|
+
/**
|
|
1728
|
+
* When true (default), compose into a compositor-owned canvas.
|
|
1729
|
+
* When false, require `target` and draw there.
|
|
1730
|
+
*/
|
|
1731
|
+
offscreen?: boolean;
|
|
1732
|
+
target?: HTMLCanvasElement;
|
|
1733
|
+
};
|
|
1734
|
+
type ComposedFrame = {
|
|
1735
|
+
imageData: ImageData;
|
|
1736
|
+
pngDataUrl: string;
|
|
1737
|
+
width: number;
|
|
1738
|
+
height: number;
|
|
1739
|
+
declaredOrder: CompositorLayerInspect[];
|
|
1740
|
+
};
|
|
1741
|
+
type CompositorInspect = {
|
|
1742
|
+
viewport: {
|
|
1743
|
+
width: number;
|
|
1744
|
+
height: number;
|
|
1745
|
+
dpr: number;
|
|
1746
|
+
};
|
|
1747
|
+
clearPolicy: CompositorClearPolicy;
|
|
1748
|
+
layers: CompositorLayerInspect[];
|
|
1749
|
+
declaredOrder: string[];
|
|
1750
|
+
};
|
|
1751
|
+
type Compositor = {
|
|
1752
|
+
readonly canvas: HTMLCanvasElement;
|
|
1753
|
+
readonly width: number;
|
|
1754
|
+
readonly height: number;
|
|
1755
|
+
readonly dpr: number;
|
|
1756
|
+
compose(): ImageData;
|
|
1757
|
+
captureComposedFrame(): ComposedFrame;
|
|
1758
|
+
/**
|
|
1759
|
+
* Shared CSS viewport. Updates group canvas buffer size (`width * dpr`).
|
|
1760
|
+
* Layer order/blend survive. Carts that cache layout from `DimensionContext`
|
|
1761
|
+
* need `group.reset()` (or remount) so they rebuild at the new size.
|
|
1762
|
+
*/
|
|
1763
|
+
resize(width: number, height: number, dpr?: number): void;
|
|
1764
|
+
setLayer(id: string, patch: Partial<Omit<CompositorLayerConfig, 'id'>>): void;
|
|
1765
|
+
layer(id: string): CompositorLayerInspect;
|
|
1766
|
+
layers(): CompositorLayerInspect[];
|
|
1767
|
+
pointerTarget(x: number, y: number): string | undefined;
|
|
1768
|
+
unmountLayer(id: string): void;
|
|
1769
|
+
inspect(): CompositorInspect;
|
|
1770
|
+
destroy(): void;
|
|
1771
|
+
};
|
|
1772
|
+
declare function createCompositor(options: CreateCompositorOptions): Compositor;
|
|
1773
|
+
|
|
1774
|
+
/**
|
|
1775
|
+
* Copyright (c) 2026 Aaron Boyarsky
|
|
1776
|
+
* SPDX-License-Identifier: LicenseRef-CyberArt-Engine
|
|
1777
|
+
* See packages/engine/LICENSE
|
|
1778
|
+
*
|
|
1779
|
+
* Opt-in DOM/browser host harness. Mounts a caller-supplied host into a
|
|
1780
|
+
* viewport, optionally wires a runtime group and compositor, and dispatches
|
|
1781
|
+
* pointer/keyboard through layout coordinates. Does not import Node built-ins
|
|
1782
|
+
* and does not encode host-product event types or fixtures.
|
|
1783
|
+
*/
|
|
1784
|
+
|
|
1785
|
+
declare const DEFAULT_BROWSER_VIEWPORT: {
|
|
1786
|
+
readonly width: 320;
|
|
1787
|
+
readonly height: 180;
|
|
1788
|
+
readonly deviceScaleFactor: 1;
|
|
1789
|
+
};
|
|
1790
|
+
type BrowserInputModality = 'pointer' | 'keyboard' | 'touch';
|
|
1791
|
+
type BrowserViewport = {
|
|
1792
|
+
width: number;
|
|
1793
|
+
height: number;
|
|
1794
|
+
deviceScaleFactor?: number;
|
|
1795
|
+
};
|
|
1796
|
+
type BrowserHarnessAction = {
|
|
1797
|
+
type: 'viewport';
|
|
1798
|
+
width: number;
|
|
1799
|
+
height: number;
|
|
1800
|
+
dpr: number;
|
|
1801
|
+
} | {
|
|
1802
|
+
type: 'click';
|
|
1803
|
+
x: number;
|
|
1804
|
+
y: number;
|
|
1805
|
+
selector?: string;
|
|
1806
|
+
} | {
|
|
1807
|
+
type: 'key';
|
|
1808
|
+
key: string;
|
|
1809
|
+
} | {
|
|
1810
|
+
type: 'step';
|
|
1811
|
+
frames: number;
|
|
1812
|
+
} | {
|
|
1813
|
+
type: 'advance';
|
|
1814
|
+
ms: number;
|
|
1815
|
+
} | {
|
|
1816
|
+
type: 'reducedMotion';
|
|
1817
|
+
value: boolean;
|
|
1818
|
+
} | {
|
|
1819
|
+
type: 'inputModality';
|
|
1820
|
+
value: BrowserInputModality;
|
|
1821
|
+
};
|
|
1822
|
+
type BrowserHarnessScreenshot = {
|
|
1823
|
+
imageData: ImageData | null;
|
|
1824
|
+
pngDataUrl: string | null;
|
|
1825
|
+
html: string;
|
|
1826
|
+
declaredOrder: string[];
|
|
1827
|
+
};
|
|
1828
|
+
type BrowserA11ySnapshot = {
|
|
1829
|
+
focus: {
|
|
1830
|
+
tag: string;
|
|
1831
|
+
id: string;
|
|
1832
|
+
role: string | null;
|
|
1833
|
+
name: string;
|
|
1834
|
+
};
|
|
1835
|
+
live: string;
|
|
1836
|
+
html: string;
|
|
1837
|
+
};
|
|
1838
|
+
type BrowserReproductionMetadata = {
|
|
1839
|
+
seed: string;
|
|
1840
|
+
viewport: {
|
|
1841
|
+
width: number;
|
|
1842
|
+
height: number;
|
|
1843
|
+
dpr: number;
|
|
1844
|
+
};
|
|
1845
|
+
reducedMotion: boolean;
|
|
1846
|
+
inputModality: BrowserInputModality;
|
|
1847
|
+
actions: BrowserHarnessAction[];
|
|
1848
|
+
};
|
|
1849
|
+
type BrowserCompositorConfig = Omit<CreateCompositorOptions, 'group' | 'width' | 'height' | 'dpr'>;
|
|
1850
|
+
type BrowserHarnessMountContext = {
|
|
1851
|
+
root: HTMLElement;
|
|
1852
|
+
layout: PresentationLayout;
|
|
1853
|
+
reducedMotion: boolean;
|
|
1854
|
+
inputModality: BrowserInputModality;
|
|
1855
|
+
placeRegion(id: string, element: HTMLElement): PixelRect | undefined;
|
|
1856
|
+
};
|
|
1857
|
+
type BrowserHarnessRuntimeContext = BrowserHarnessMountContext & {
|
|
1858
|
+
group: RuntimeGroup | undefined;
|
|
1859
|
+
compositor: Compositor | undefined;
|
|
1860
|
+
publish(event: EventInput): EventEnvelope | undefined;
|
|
1861
|
+
};
|
|
1862
|
+
type BrowserHostSession = {
|
|
1863
|
+
participants?: RuntimeGroupParticipantConfig[];
|
|
1864
|
+
compositor?: BrowserCompositorConfig;
|
|
1865
|
+
hostState?: () => unknown;
|
|
1866
|
+
ready?: (ctx: BrowserHarnessRuntimeContext) => void;
|
|
1867
|
+
relayout?: (ctx: BrowserHarnessRuntimeContext) => void;
|
|
1868
|
+
destroy?: () => void;
|
|
1869
|
+
};
|
|
1870
|
+
type CreateBrowserHarnessOptions = {
|
|
1871
|
+
seed?: string;
|
|
1872
|
+
viewport?: BrowserViewport;
|
|
1873
|
+
reducedMotion?: boolean;
|
|
1874
|
+
inputModality?: BrowserInputModality;
|
|
1875
|
+
origin?: number;
|
|
1876
|
+
createId?: () => string;
|
|
1877
|
+
geometry?: GeometryDocument;
|
|
1878
|
+
contentWidth?: number;
|
|
1879
|
+
contentHeight?: number;
|
|
1880
|
+
fit?: PresentationFitMode;
|
|
1881
|
+
mount?: (ctx: BrowserHarnessMountContext) => BrowserHostSession | void;
|
|
1882
|
+
};
|
|
1883
|
+
type BrowserHarnessInspect = {
|
|
1884
|
+
host: unknown;
|
|
1885
|
+
layout: PresentationLayout;
|
|
1886
|
+
events: EventEnvelope[];
|
|
1887
|
+
participantEvents: Record<string, HostEvent[]>;
|
|
1888
|
+
state: Record<string, unknown>;
|
|
1889
|
+
focus: BrowserA11ySnapshot['focus'];
|
|
1890
|
+
scrollTop: number;
|
|
1891
|
+
clock: {
|
|
1892
|
+
framesElapsed: number;
|
|
1893
|
+
};
|
|
1894
|
+
};
|
|
1895
|
+
type BrowserHarness = {
|
|
1896
|
+
readonly root: HTMLElement;
|
|
1897
|
+
readonly group: RuntimeGroup | undefined;
|
|
1898
|
+
readonly compositor: Compositor | undefined;
|
|
1899
|
+
readonly layout: PresentationLayout;
|
|
1900
|
+
readonly events: readonly EventEnvelope[];
|
|
1901
|
+
goto(url?: string): void;
|
|
1902
|
+
setViewport(width: number, height: number, dpr?: number): void;
|
|
1903
|
+
setReducedMotion(value: boolean): void;
|
|
1904
|
+
setInputModality(value: BrowserInputModality): void;
|
|
1905
|
+
click(selectorOrX: string | number, y?: number): void;
|
|
1906
|
+
key(key: string): void;
|
|
1907
|
+
focus(selector: string): void;
|
|
1908
|
+
step(frames?: number): Promise<void>;
|
|
1909
|
+
advance(ms: number): Promise<void>;
|
|
1910
|
+
screenshot(): BrowserHarnessScreenshot;
|
|
1911
|
+
accessibilitySnapshot(): BrowserA11ySnapshot;
|
|
1912
|
+
inspect(): Promise<BrowserHarnessInspect>;
|
|
1913
|
+
reproduction(): BrowserReproductionMetadata;
|
|
1914
|
+
captureComposedFrame(): ComposedFrame;
|
|
1915
|
+
destroy(): void;
|
|
1916
|
+
};
|
|
1917
|
+
declare function createBrowserHarness(options?: CreateBrowserHarnessOptions): BrowserHarness;
|
|
1918
|
+
|
|
1919
|
+
/**
|
|
1920
|
+
* Copyright (c) 2026 Aaron Boyarsky
|
|
1921
|
+
* SPDX-License-Identifier: LicenseRef-CyberArt-Engine
|
|
1922
|
+
* See packages/engine/LICENSE
|
|
1923
|
+
*
|
|
1924
|
+
* Playwright-shaped adapter over `createBrowserHarness`. Same method names as
|
|
1925
|
+
* a Playwright `Page` (`goto`, `setViewportSize`, `click`, `screenshot`) so CI
|
|
1926
|
+
* can swap engines later without `@playwright/test` as an engine dependency.
|
|
1927
|
+
*/
|
|
1928
|
+
|
|
1929
|
+
type PlaywrightCompatibleViewport = {
|
|
1930
|
+
width: number;
|
|
1931
|
+
height: number;
|
|
1932
|
+
deviceScaleFactor?: number;
|
|
1933
|
+
};
|
|
1934
|
+
type PlaywrightCompatibleAdapter = {
|
|
1935
|
+
goto(url?: string): Promise<void>;
|
|
1936
|
+
setViewportSize(viewport: PlaywrightCompatibleViewport): Promise<void>;
|
|
1937
|
+
click(selector: string): Promise<void>;
|
|
1938
|
+
screenshot(): Promise<BrowserHarnessScreenshot>;
|
|
1939
|
+
keyboard: {
|
|
1940
|
+
press(key: string): Promise<void>;
|
|
1941
|
+
};
|
|
1942
|
+
locator(selector: string): {
|
|
1943
|
+
click(): Promise<void>;
|
|
1944
|
+
focus(): Promise<void>;
|
|
1945
|
+
};
|
|
1946
|
+
close(): Promise<void>;
|
|
1947
|
+
};
|
|
1948
|
+
declare function createPlaywrightCompatibleAdapter(harness: BrowserHarness): PlaywrightCompatibleAdapter;
|
|
1949
|
+
|
|
1950
|
+
export { ANCHOR_ORIGINS, ASSET_FAILED_EVENT, ASSET_FAILURE_CODES, ASSET_KINDS, ASSET_READY_EVENT, type AnchorOrigin, type AnimationCart, type AnimationTiming, type AppliedAction, type AssetCorsMode, type AssetDeclaration, type AssetFailure, type AssetFailureCode, type AssetItemStatus, type AssetKind, type AssetPreloadSnapshot, type AssetPreloader, type AssetProvenance, type AssetResolveRequest, type AssetResolver, type AssetRuntimeOptions, type AttachOptions, type AttachPresentationAdapterOptions, type AudioLibraryId, type AudioLibrarySpec, type BoundReplaySession, type BrowserA11ySnapshot, type BrowserCompositorConfig, type BrowserHarness, type BrowserHarnessAction, type BrowserHarnessInspect, type BrowserHarnessMountContext, type BrowserHarnessRuntimeContext, type BrowserHarnessScreenshot, type BrowserHostSession, type BrowserInputModality, type BrowserReproductionMetadata, type BrowserViewport, CAPABILITY_ASSET_KINDS, CAPABILITY_BLEND_MODES, CAPABILITY_CLEAR_POLICIES, CAPABILITY_INTEGRATIONS, CAPABILITY_MANAGERS, CAPABILITY_MANIFEST_VERSION, CAPABILITY_PHASES, COMPOSITOR_BLEND_MODES, COMPOSITOR_CLEAR_POLICIES, COORDINATE_SPACES, CUE_CANCELLED_EVENT, CUE_COMPLETED_EVENT, CUE_LIFECYCLE_EVENTS, CUE_REPLACED_EVENT, CUE_STARTED_EVENT, CYBERART_CANVAS_ATTR, type CapabilityAssetDeclarationSummary, type CapabilityAssetKind, type CapabilityAssetSummary, type CapabilityBlendMode, type CapabilityClearPolicy, type CapabilityDiagnostic, type CapabilityIntegration, type CapabilityLayerRequirements, type CapabilityManager, type CapabilityManifest, type CapabilityManifestInput, type CapabilityPermissions, type CapabilityPhase, type CapabilityRuntime, type CapabilitySurfaceRequirements, type CartHandle, type CartSnapshot, type CartStateBundle, type CartStateHotkeyOptions, type CartStateMessageHandler, type CartStatePersister, type CausationTreeNode, type Clock, type ClockSnapshot, type ComposedFrame, type Compositor, type CompositorBlendMode, type CompositorClearPolicy, type CompositorClip, type CompositorHostOptions, type CompositorInspect, type CompositorLayerConfig, type CompositorLayerInspect, type CompositorPointerEvents, type ContractDiagnostic, type ContractFieldType, type ContractRegistry, type CoordinateSpace, type CreateAssetPreloaderOptions, type CreateBrowserHarnessOptions, type CreateCompositorOptions, type CreatePresentationLayoutInput, type CreatePresentationTimelineOptions, type CreateReplayInspectorOptions, type CreateRuntimeGroupOptions, type CreateRuntimeOptions, type CueDuplicatePolicy, type CueEasing, type CueLifecycleEvent, type CueLifecycleType, type CuePhase, type CueReducedMotionPolicy, type CueRepeatPolicy, type CueSpec, type CueTimelineSnapshot, type CueView, type CyberArtRuntime, DEFAULT_BROWSER_VIEWPORT, DEFAULT_GROUP_HEIGHT, DEFAULT_GROUP_WIDTH, DEFAULT_MAX_HOPS, DEFAULT_MAX_INSPECTOR_RECORDS, type DebugDrawCall, type DefineCapabilityManifestResult, type DefineContractResult, type DeterministicRuntimeOptions, type DimensionContext, EVENT_ENVELOPE_VERSION, type EventContract, type EventContractManifest, type EventEnvelope, type EventInput, type EventKind, type EventRouter, type EventRouterOptions, type FixtureAssetCatalog, type FixtureAssetRecord, type FrameErrorInfo, GEOMETRY_CONTRACT_VERSION, type GeometryAnchor, type GeometryDebugContext, type GeometryDiagnostic, type GeometryDocument, type GeometryHitbox, type GeometryPadding, type GeometrySafeArea, type GeometryValidation, type HostCapabilities, HostChannel, type HostEvent, type HostEventListener, type HostedAssetResolverOptions, INVALID_PRESENTATION_MODEL_MESSAGE, type ImportCartStateExtras, IncompatibleCartStateError, type InferredPayload, type InspectorRecord, KeyboardManager, type LandmarkRegisterResult, type LandmarkRegistry, type MountOptions, type MountPresentationAdapterOptions, type NormalizeContext, type NormalizeResult, type NormalizedPoint, type NormalizedPolygon, type NormalizedRect, PRESENTATION_ADAPTER_VERSION, PRESENTATION_MODEL_EVENT, PRESENTATION_PHASES, PRESENTATION_SUBSCRIBE_PATTERNS, PRESENTATION_UNSUPPORTED_EVENT, type PayloadFieldSpec, type PayloadSchema, type PayloadValidation, type PixelPoint, type PixelRect, type PlayCueResult, type PlaywrightCompatibleAdapter, type PlaywrightCompatibleViewport, type PointerClick, PointerManager, type PointerSpace, type PresentationAdapter, type PresentationAdapterTarget, type PresentationCartState, type PresentationFitMode, type PresentationLayout, type PresentationModel, type PresentationPhase, type PresentationRegion, type PresentationTimeline, type PresentationView, type PublishExtras, REDACTED_VALUE, REJECTED_EVENT_TYPE, REPLAY_INSPECTOR_SCHEMA_VERSION, ROUND_TRIP_TOLERANCE, ROUND_TRIP_TOLERANCE_CANVAS_PX, Random, type RandomState, type RejectionPayload, type RejectionReason, type ReplayCompareResult, type ReplayInspector, type ReplayInspectorExport, type ReplayInspectorReport, type ReplayMetadata, type ReplayParticipantSummary, type ReplayTapeAction, type ReplayTraceFilter, type ResolvedAsset, type RouterDecision, type RouterDecisionOutcome, type RouterDecisionReason, type RouterParticipantInspect, type RuntimeGroup, type RuntimeGroupCapability, type RuntimeGroupDiagnostics, type RuntimeGroupFrameError, type RuntimeGroupInspect, type RuntimeGroupKind, type RuntimeGroupParticipantConfig, type RuntimeGroupParticipantHandle, type RuntimeGroupParticipantInspect, SILENT_ASSET_FALLBACK_REF, type SchemaCompatibility, type ScriptedAction, type TokenData, type ValidateCapabilityManifestResult, type ValidateResult, type VirtualClock, applyCueEasing, assetStatusEvent, assetToNormalized, attachCartStatePersistence, attachPresentationAdapter, canonicalizeSeed, canvasToCss, canvasToNormalized, toJSON as capabilityManifestToJSON, comparePayloadSchemas, compareReplayTraces, createAssetFailure, createAssetPreloader, createBrowserHarness, createCompositor, createContractRegistry, createEventRouter, createFixtureAssetResolver, createHostedAssetResolver, createLandmarkRegistry, createPlaywrightCompatibleAdapter, createPresentationLayout, createPresentationModelEvent, createPresentationTimeline, createReferencePresentationCart, createReplayInspector, createRuntime, createRuntimeGroup, createVirtualClock, createWallClock, cssToCanvas, cssToNormalized, defineCapabilityManifest, defineDiagnostic, defineIntent, defineStateEvent, deriveAttachOptions, describeReplayMismatch, drawGeometryDebug, familyPatternForType, inferEventKind, isAssetFailure, isAssetFailureCode, isAssetKind, isCueLifecycleType, isPresentationModel, isPresentationPhase, kindSegmentInType, matchEventPattern, mountPresentationAdapter, normalizeEvent, normalizedToAsset, normalizedToCanvas, normalizedToCss, parseCapabilityManifest, parseGeometry, pointFromOrigin, pointerToRegion, rectToCanvas, rectToCss, regionToViewport, registerCartStateHotkeys, replayExportedTrace, resolveRuntimeSeed, rewriteHostedAssetRef, serializeGeometry, validateCapabilityManifest, validateGeometry, verifyAttachOptions };
|