@cyberart-io/engine 0.0.3 → 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 +96 -12
- package/dist/headless.d.ts +602 -4
- package/dist/headless.js +1 -1
- package/dist/index.d.ts +835 -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 +95 -0
- package/docs/compositor.md +103 -0
- package/docs/events.md +27 -22
- package/docs/headless-harness.md +46 -16
- package/docs/normalized-geometry.md +88 -0
- package/docs/presentation-adapter.md +10 -10
- package/docs/presentation-cue.md +1 -1
- package/docs/replay-inspector.md +88 -0
- package/docs/runtime-group.md +122 -0
- package/package.json +2 -2
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";
|
|
@@ -1119,4 +1153,798 @@ declare function isCueLifecycleType(value: unknown): value is CueLifecycleType;
|
|
|
1119
1153
|
declare function applyCueEasing(t: number, easing: CueEasing): number;
|
|
1120
1154
|
declare function createPresentationTimeline(options?: CreatePresentationTimelineOptions): PresentationTimeline;
|
|
1121
1155
|
|
|
1122
|
-
|
|
1156
|
+
/**
|
|
1157
|
+
* Copyright (c) 2026 Aaron Boyarsky
|
|
1158
|
+
* SPDX-License-Identifier: LicenseRef-CyberArt-Engine
|
|
1159
|
+
* See packages/engine/LICENSE
|
|
1160
|
+
*
|
|
1161
|
+
* Versioned, JSON-serializable capability manifest for a cart/module.
|
|
1162
|
+
* Definition, parse, and host validation all return structured diagnostics
|
|
1163
|
+
* instead of throwing.
|
|
1164
|
+
*/
|
|
1165
|
+
declare const CAPABILITY_MANIFEST_VERSION: 1;
|
|
1166
|
+
declare const CAPABILITY_PHASES: readonly ["loading", "ready", "error", "unsupported"];
|
|
1167
|
+
type CapabilityPhase = (typeof CAPABILITY_PHASES)[number];
|
|
1168
|
+
declare const CAPABILITY_MANAGERS: readonly ["keyboard", "pointer", "audio", "assets", "hostChannel"];
|
|
1169
|
+
type CapabilityManager = (typeof CAPABILITY_MANAGERS)[number];
|
|
1170
|
+
declare const CAPABILITY_ASSET_KINDS: readonly ["image", "audio", "font", "spritesheet"];
|
|
1171
|
+
type CapabilityAssetKind = (typeof CAPABILITY_ASSET_KINDS)[number];
|
|
1172
|
+
declare const CAPABILITY_INTEGRATIONS: readonly ["tone", "midi"];
|
|
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];
|
|
1178
|
+
type CapabilityDiagnostic = {
|
|
1179
|
+
code: string;
|
|
1180
|
+
detail: string;
|
|
1181
|
+
path?: string;
|
|
1182
|
+
};
|
|
1183
|
+
type CapabilityRuntime = {
|
|
1184
|
+
minContractVersion: number;
|
|
1185
|
+
features: string[];
|
|
1186
|
+
};
|
|
1187
|
+
type CapabilityAssetDeclarationSummary = {
|
|
1188
|
+
id: string;
|
|
1189
|
+
kind: CapabilityAssetKind;
|
|
1190
|
+
};
|
|
1191
|
+
type CapabilityAssetSummary = {
|
|
1192
|
+
kinds: CapabilityAssetKind[];
|
|
1193
|
+
declarations: CapabilityAssetDeclarationSummary[];
|
|
1194
|
+
};
|
|
1195
|
+
type CapabilityPermissions = {
|
|
1196
|
+
emit: string[];
|
|
1197
|
+
subscribe: string[];
|
|
1198
|
+
authoritative?: boolean;
|
|
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
|
+
};
|
|
1210
|
+
type CapabilityManifest = {
|
|
1211
|
+
version: typeof CAPABILITY_MANIFEST_VERSION;
|
|
1212
|
+
id: string;
|
|
1213
|
+
runtime: CapabilityRuntime;
|
|
1214
|
+
phases: CapabilityPhase[];
|
|
1215
|
+
managers: CapabilityManager[];
|
|
1216
|
+
assets: CapabilityAssetSummary;
|
|
1217
|
+
acceptedEvents: string[];
|
|
1218
|
+
emittedEvents: string[];
|
|
1219
|
+
permissions: CapabilityPermissions;
|
|
1220
|
+
integrations: CapabilityIntegration[];
|
|
1221
|
+
surface?: CapabilitySurfaceRequirements;
|
|
1222
|
+
layers?: CapabilityLayerRequirements;
|
|
1223
|
+
};
|
|
1224
|
+
type CapabilityManifestInput = {
|
|
1225
|
+
version?: number;
|
|
1226
|
+
id: string;
|
|
1227
|
+
runtime: CapabilityRuntime;
|
|
1228
|
+
phases: CapabilityPhase[];
|
|
1229
|
+
managers: CapabilityManager[];
|
|
1230
|
+
assets: CapabilityAssetSummary;
|
|
1231
|
+
acceptedEvents: string[];
|
|
1232
|
+
emittedEvents: string[];
|
|
1233
|
+
permissions: CapabilityPermissions;
|
|
1234
|
+
integrations: CapabilityIntegration[];
|
|
1235
|
+
surface?: CapabilitySurfaceRequirements;
|
|
1236
|
+
layers?: CapabilityLayerRequirements;
|
|
1237
|
+
};
|
|
1238
|
+
type HostCapabilities = {
|
|
1239
|
+
contractVersion: number;
|
|
1240
|
+
features: string[];
|
|
1241
|
+
integrations: CapabilityIntegration[];
|
|
1242
|
+
managers?: CapabilityManager[];
|
|
1243
|
+
emit?: string[];
|
|
1244
|
+
subscribe?: string[];
|
|
1245
|
+
surface?: CapabilitySurfaceRequirements & {
|
|
1246
|
+
clearPolicy?: CapabilityClearPolicy | CapabilityClearPolicy[];
|
|
1247
|
+
};
|
|
1248
|
+
layers?: CapabilityLayerRequirements;
|
|
1249
|
+
};
|
|
1250
|
+
type DefineCapabilityManifestResult = {
|
|
1251
|
+
ok: true;
|
|
1252
|
+
manifest: CapabilityManifest;
|
|
1253
|
+
} | {
|
|
1254
|
+
ok: false;
|
|
1255
|
+
errors: CapabilityDiagnostic[];
|
|
1256
|
+
};
|
|
1257
|
+
type ValidateCapabilityManifestResult = {
|
|
1258
|
+
ok: true;
|
|
1259
|
+
} | {
|
|
1260
|
+
ok: false;
|
|
1261
|
+
errors: CapabilityDiagnostic[];
|
|
1262
|
+
};
|
|
1263
|
+
declare function defineCapabilityManifest(input: unknown): DefineCapabilityManifestResult;
|
|
1264
|
+
declare function parseCapabilityManifest(json: string | unknown): DefineCapabilityManifestResult;
|
|
1265
|
+
declare function toJSON(manifest: CapabilityManifest): CapabilityManifest;
|
|
1266
|
+
declare function validateCapabilityManifest(manifest: CapabilityManifest, hostCapabilities: HostCapabilities): ValidateCapabilityManifestResult;
|
|
1267
|
+
|
|
1268
|
+
/**
|
|
1269
|
+
* Copyright (c) 2026 Aaron Boyarsky
|
|
1270
|
+
* SPDX-License-Identifier: LicenseRef-CyberArt-Engine
|
|
1271
|
+
* See packages/engine/LICENSE
|
|
1272
|
+
*
|
|
1273
|
+
* Shared normalized coordinate, anchor, and hit-region contract. Hosts and
|
|
1274
|
+
* adapters may adopt this later; pixel `PresentationRegion` is unchanged.
|
|
1275
|
+
*
|
|
1276
|
+
* Coordinate spaces:
|
|
1277
|
+
* - `normalized` — 0–1 of the **content** box (full intrinsic artwork, not letterbox).
|
|
1278
|
+
* - `asset` — intrinsic content pixels (`contentWidth` × `contentHeight`).
|
|
1279
|
+
* - `css` / `viewport` — layout pixels (`viewportWidth` × `viewportHeight`).
|
|
1280
|
+
* - `canvas` — drawing-buffer pixels (`css * devicePixelRatio`). Pointers match
|
|
1281
|
+
* `PointerManager` / harness `click` when the buffer is the drawing canvas.
|
|
1282
|
+
*
|
|
1283
|
+
* Pointer helpers default to **canvas** space. Pass `{ space: 'css' }` for
|
|
1284
|
+
* layout pixels. Round-trip: `ROUND_TRIP_TOLERANCE` (1e-6 normalized) or
|
|
1285
|
+
* `ROUND_TRIP_TOLERANCE_CANVAS_PX` (0.5 canvas px).
|
|
1286
|
+
*/
|
|
1287
|
+
declare const GEOMETRY_CONTRACT_VERSION: 1;
|
|
1288
|
+
/** Maximum |Δ| in normalized units after canvas/css round-trip. */
|
|
1289
|
+
declare const ROUND_TRIP_TOLERANCE = 0.000001;
|
|
1290
|
+
/** Maximum |Δ| in canvas pixels after normalized round-trip. */
|
|
1291
|
+
declare const ROUND_TRIP_TOLERANCE_CANVAS_PX = 0.5;
|
|
1292
|
+
declare const COORDINATE_SPACES: readonly ["normalized", "asset", "canvas", "css", "viewport"];
|
|
1293
|
+
type CoordinateSpace = (typeof COORDINATE_SPACES)[number];
|
|
1294
|
+
type PointerSpace = 'canvas' | 'css';
|
|
1295
|
+
type PresentationFitMode = 'contain' | 'cover' | 'crop';
|
|
1296
|
+
declare const ANCHOR_ORIGINS: readonly ["center", "top-left", "top-right", "bottom-left", "bottom-right", "top", "bottom", "left", "right"];
|
|
1297
|
+
type AnchorOrigin = (typeof ANCHOR_ORIGINS)[number];
|
|
1298
|
+
type NormalizedPoint = {
|
|
1299
|
+
x: number;
|
|
1300
|
+
y: number;
|
|
1301
|
+
};
|
|
1302
|
+
type NormalizedRect = {
|
|
1303
|
+
x: number;
|
|
1304
|
+
y: number;
|
|
1305
|
+
width: number;
|
|
1306
|
+
height: number;
|
|
1307
|
+
};
|
|
1308
|
+
type NormalizedPolygon = readonly NormalizedPoint[];
|
|
1309
|
+
type PixelPoint = {
|
|
1310
|
+
x: number;
|
|
1311
|
+
y: number;
|
|
1312
|
+
};
|
|
1313
|
+
type PixelRect = {
|
|
1314
|
+
x: number;
|
|
1315
|
+
y: number;
|
|
1316
|
+
width: number;
|
|
1317
|
+
height: number;
|
|
1318
|
+
};
|
|
1319
|
+
type GeometryPadding = {
|
|
1320
|
+
top: number;
|
|
1321
|
+
right: number;
|
|
1322
|
+
bottom: number;
|
|
1323
|
+
left: number;
|
|
1324
|
+
};
|
|
1325
|
+
/** Insets from the content edges in normalized units (0–1). */
|
|
1326
|
+
type GeometrySafeArea = GeometryPadding;
|
|
1327
|
+
type GeometryAnchor = {
|
|
1328
|
+
id: string;
|
|
1329
|
+
point: NormalizedPoint;
|
|
1330
|
+
origin?: AnchorOrigin;
|
|
1331
|
+
};
|
|
1332
|
+
type GeometryHitbox = {
|
|
1333
|
+
id: string;
|
|
1334
|
+
rect?: NormalizedRect;
|
|
1335
|
+
polygon?: NormalizedPolygon;
|
|
1336
|
+
};
|
|
1337
|
+
type GeometryDocument = {
|
|
1338
|
+
version: typeof GEOMETRY_CONTRACT_VERSION;
|
|
1339
|
+
landmarks: GeometryAnchor[];
|
|
1340
|
+
regions: GeometryHitbox[];
|
|
1341
|
+
padding?: GeometryPadding;
|
|
1342
|
+
safeArea?: GeometrySafeArea;
|
|
1343
|
+
};
|
|
1344
|
+
type CreatePresentationLayoutInput = {
|
|
1345
|
+
contentWidth: number;
|
|
1346
|
+
contentHeight: number;
|
|
1347
|
+
viewportWidth: number;
|
|
1348
|
+
viewportHeight: number;
|
|
1349
|
+
mode: PresentationFitMode;
|
|
1350
|
+
/** Canvas buffer pixels per CSS pixel. Default 1. */
|
|
1351
|
+
devicePixelRatio?: number;
|
|
1352
|
+
};
|
|
1353
|
+
type PresentationLayout = {
|
|
1354
|
+
mode: PresentationFitMode;
|
|
1355
|
+
contentWidth: number;
|
|
1356
|
+
contentHeight: number;
|
|
1357
|
+
viewportWidth: number;
|
|
1358
|
+
viewportHeight: number;
|
|
1359
|
+
devicePixelRatio: number;
|
|
1360
|
+
/** Content → CSS pixels. */
|
|
1361
|
+
scale: number;
|
|
1362
|
+
/** Letterbox (positive) or crop (negative) offset of content origin in CSS. */
|
|
1363
|
+
offsetX: number;
|
|
1364
|
+
offsetY: number;
|
|
1365
|
+
canvasWidth: number;
|
|
1366
|
+
canvasHeight: number;
|
|
1367
|
+
/** Visible slice of the content box in normalized space. */
|
|
1368
|
+
visibleNormalizedRect: NormalizedRect;
|
|
1369
|
+
};
|
|
1370
|
+
type GeometryDiagnostic = {
|
|
1371
|
+
code: 'out-of-bounds' | 'overlap' | 'duplicate-id' | 'invalid-shape' | 'version-mismatch';
|
|
1372
|
+
id?: string;
|
|
1373
|
+
detail: string;
|
|
1374
|
+
with?: string;
|
|
1375
|
+
};
|
|
1376
|
+
type GeometryValidation = {
|
|
1377
|
+
ok: boolean;
|
|
1378
|
+
diagnostics: GeometryDiagnostic[];
|
|
1379
|
+
};
|
|
1380
|
+
type LandmarkRegisterResult = {
|
|
1381
|
+
ok: true;
|
|
1382
|
+
landmark: GeometryAnchor;
|
|
1383
|
+
} | {
|
|
1384
|
+
ok: false;
|
|
1385
|
+
error: 'duplicate-id';
|
|
1386
|
+
id: string;
|
|
1387
|
+
};
|
|
1388
|
+
type LandmarkRegistry = {
|
|
1389
|
+
register(landmark: GeometryAnchor): LandmarkRegisterResult;
|
|
1390
|
+
get(id: string): GeometryAnchor | undefined;
|
|
1391
|
+
list(): GeometryAnchor[];
|
|
1392
|
+
};
|
|
1393
|
+
type DebugDrawCall = {
|
|
1394
|
+
method: string;
|
|
1395
|
+
id?: string;
|
|
1396
|
+
args: unknown[];
|
|
1397
|
+
};
|
|
1398
|
+
type GeometryDebugContext = {
|
|
1399
|
+
fillStyle?: string;
|
|
1400
|
+
strokeStyle?: string;
|
|
1401
|
+
font?: string;
|
|
1402
|
+
fillRect?(x: number, y: number, w: number, h: number): void;
|
|
1403
|
+
strokeRect?(x: number, y: number, w: number, h: number): void;
|
|
1404
|
+
fillText?(text: string, x: number, y: number): void;
|
|
1405
|
+
beginPath?(): void;
|
|
1406
|
+
moveTo?(x: number, y: number): void;
|
|
1407
|
+
lineTo?(x: number, y: number): void;
|
|
1408
|
+
closePath?(): void;
|
|
1409
|
+
stroke?(): void;
|
|
1410
|
+
fill?(): void;
|
|
1411
|
+
};
|
|
1412
|
+
declare function pointFromOrigin(origin: AnchorOrigin): NormalizedPoint;
|
|
1413
|
+
declare function createPresentationLayout(input: CreatePresentationLayoutInput): PresentationLayout;
|
|
1414
|
+
declare function normalizedToAsset(point: NormalizedPoint, layout: PresentationLayout): PixelPoint;
|
|
1415
|
+
declare function assetToNormalized(point: PixelPoint, layout: PresentationLayout): NormalizedPoint;
|
|
1416
|
+
declare function normalizedToCss(point: NormalizedPoint, layout: PresentationLayout): PixelPoint;
|
|
1417
|
+
declare function cssToNormalized(point: PixelPoint, layout: PresentationLayout): NormalizedPoint;
|
|
1418
|
+
declare function cssToCanvas(point: PixelPoint, layout: PresentationLayout): PixelPoint;
|
|
1419
|
+
declare function canvasToCss(point: PixelPoint, layout: PresentationLayout): PixelPoint;
|
|
1420
|
+
declare function normalizedToCanvas(point: NormalizedPoint, layout: PresentationLayout): PixelPoint;
|
|
1421
|
+
declare function canvasToNormalized(point: PixelPoint, layout: PresentationLayout): NormalizedPoint;
|
|
1422
|
+
declare function rectToCss(rect: NormalizedRect, layout: PresentationLayout): PixelRect;
|
|
1423
|
+
declare function rectToCanvas(rect: NormalizedRect, layout: PresentationLayout): PixelRect;
|
|
1424
|
+
/**
|
|
1425
|
+
* Pointer is in **canvas** pixels unless `{ space: 'css' }` is passed.
|
|
1426
|
+
* Returns the first region whose rect or polygon contains the point, in
|
|
1427
|
+
* document order.
|
|
1428
|
+
*/
|
|
1429
|
+
declare function pointerToRegion(pointer: PixelPoint, layout: PresentationLayout, doc: GeometryDocument, options?: {
|
|
1430
|
+
space?: PointerSpace;
|
|
1431
|
+
}): GeometryHitbox | undefined;
|
|
1432
|
+
/** Visible CSS (viewport) rectangle for a region; polygons use their AABB. */
|
|
1433
|
+
declare function regionToViewport(region: GeometryHitbox, layout: PresentationLayout): PixelRect | undefined;
|
|
1434
|
+
declare function createLandmarkRegistry(initial?: readonly GeometryAnchor[]): LandmarkRegistry;
|
|
1435
|
+
declare function validateGeometry(doc: GeometryDocument): GeometryValidation;
|
|
1436
|
+
/**
|
|
1437
|
+
* Draws labeled region rects and reports validation failures as extra labels.
|
|
1438
|
+
* Tests may pass a stub that records `fillRect` / `strokeRect` / `fillText`.
|
|
1439
|
+
*/
|
|
1440
|
+
declare function drawGeometryDebug(ctx: GeometryDebugContext, layout: PresentationLayout, doc: GeometryDocument, diagnostics?: readonly GeometryDiagnostic[]): DebugDrawCall[];
|
|
1441
|
+
declare function serializeGeometry(doc: GeometryDocument): string;
|
|
1442
|
+
declare function parseGeometry(json: string): GeometryDocument;
|
|
1443
|
+
|
|
1444
|
+
/**
|
|
1445
|
+
* Copyright (c) 2026 Aaron Boyarsky
|
|
1446
|
+
* SPDX-License-Identifier: LicenseRef-CyberArt-Engine
|
|
1447
|
+
* See packages/engine/LICENSE
|
|
1448
|
+
*
|
|
1449
|
+
* First-class multi-cart runtime group. Creates production `createRuntime`
|
|
1450
|
+
* instances, attaches each mailbox to one shared `createEventRouter`, and
|
|
1451
|
+
* locksteps a deterministic clock. Carts never receive the router object.
|
|
1452
|
+
*/
|
|
1453
|
+
|
|
1454
|
+
declare const DEFAULT_GROUP_WIDTH = 320;
|
|
1455
|
+
declare const DEFAULT_GROUP_HEIGHT = 180;
|
|
1456
|
+
type RuntimeGroupKind = 'render' | 'calculation';
|
|
1457
|
+
/**
|
|
1458
|
+
* Optional capability-shaped attach hints. Explicit participant `emit` /
|
|
1459
|
+
* `subscribe` / `authoritative` win. Do not import the capability manifest
|
|
1460
|
+
* module from this file.
|
|
1461
|
+
*/
|
|
1462
|
+
type RuntimeGroupCapability = {
|
|
1463
|
+
emit?: string[];
|
|
1464
|
+
subscribe?: string[];
|
|
1465
|
+
authoritative?: boolean;
|
|
1466
|
+
};
|
|
1467
|
+
type RuntimeGroupFrameError = {
|
|
1468
|
+
error: unknown;
|
|
1469
|
+
info: FrameErrorInfo;
|
|
1470
|
+
};
|
|
1471
|
+
type RuntimeGroupParticipantConfig<T = unknown> = {
|
|
1472
|
+
id: string;
|
|
1473
|
+
cart: AnimationCart<T>;
|
|
1474
|
+
/** Rendered surface vs calculation cart (still a real `AnimationCart`). */
|
|
1475
|
+
kind?: RuntimeGroupKind;
|
|
1476
|
+
seed?: CreateRuntimeOptions['seed'];
|
|
1477
|
+
container?: HTMLElement;
|
|
1478
|
+
width?: number;
|
|
1479
|
+
height?: number;
|
|
1480
|
+
initialState?: Partial<T>;
|
|
1481
|
+
gameManager?: unknown;
|
|
1482
|
+
onEvent?: HostEventListener;
|
|
1483
|
+
emit?: string[];
|
|
1484
|
+
subscribe?: string[];
|
|
1485
|
+
authoritative?: boolean;
|
|
1486
|
+
capability?: RuntimeGroupCapability;
|
|
1487
|
+
};
|
|
1488
|
+
type CreateRuntimeGroupOptions = {
|
|
1489
|
+
participants: RuntimeGroupParticipantConfig[];
|
|
1490
|
+
/** Shared virtual-clock origin (ms). Default 0. */
|
|
1491
|
+
origin?: number;
|
|
1492
|
+
width?: number;
|
|
1493
|
+
height?: number;
|
|
1494
|
+
validate?: EventRouterOptions['validate'];
|
|
1495
|
+
createId?: () => string;
|
|
1496
|
+
now?: () => number;
|
|
1497
|
+
/** Extra router options. Group injects shared `createId` / `now` unless set here. */
|
|
1498
|
+
router?: EventRouterOptions;
|
|
1499
|
+
/** Bound on the accepted-event trace (oldest dropped). Default 1024. */
|
|
1500
|
+
maxTrace?: number;
|
|
1501
|
+
};
|
|
1502
|
+
type RuntimeGroupParticipantInspect = {
|
|
1503
|
+
state: unknown;
|
|
1504
|
+
events: HostEvent[];
|
|
1505
|
+
errors: RuntimeGroupFrameError[];
|
|
1506
|
+
kind: RuntimeGroupKind;
|
|
1507
|
+
clock: ClockSnapshot;
|
|
1508
|
+
emit: string[];
|
|
1509
|
+
subscribe: string[];
|
|
1510
|
+
authoritative: boolean;
|
|
1511
|
+
};
|
|
1512
|
+
type RuntimeGroupDiagnostics = {
|
|
1513
|
+
paused: boolean;
|
|
1514
|
+
participantIds: string[];
|
|
1515
|
+
clocks: Record<string, ClockSnapshot>;
|
|
1516
|
+
rejections: unknown[];
|
|
1517
|
+
};
|
|
1518
|
+
type RuntimeGroupInspect = {
|
|
1519
|
+
participants: Record<string, RuntimeGroupParticipantInspect>;
|
|
1520
|
+
trace: EventEnvelope[];
|
|
1521
|
+
diagnostics: RuntimeGroupDiagnostics;
|
|
1522
|
+
};
|
|
1523
|
+
type RuntimeGroupParticipantHandle = {
|
|
1524
|
+
readonly id: string;
|
|
1525
|
+
readonly kind: RuntimeGroupKind;
|
|
1526
|
+
readonly runtime: CyberArtRuntime;
|
|
1527
|
+
readonly container: HTMLElement;
|
|
1528
|
+
readonly events: readonly HostEvent[];
|
|
1529
|
+
readonly errors: readonly RuntimeGroupFrameError[];
|
|
1530
|
+
get cart(): CartHandle;
|
|
1531
|
+
};
|
|
1532
|
+
type RuntimeGroup = {
|
|
1533
|
+
readonly router: EventRouter;
|
|
1534
|
+
readonly origin: number;
|
|
1535
|
+
readonly paused: boolean;
|
|
1536
|
+
participant(id: string): RuntimeGroupParticipantHandle;
|
|
1537
|
+
step(frames?: number): Promise<void>;
|
|
1538
|
+
pause(): void;
|
|
1539
|
+
resume(): void;
|
|
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;
|
|
1545
|
+
dispatch(participantId: string, event: HostEvent): void;
|
|
1546
|
+
publish(event: EventInput, extras?: PublishExtras): EventEnvelope | undefined;
|
|
1547
|
+
inspectParticipants(): Array<RouterParticipantInspect & {
|
|
1548
|
+
kind: RuntimeGroupKind;
|
|
1549
|
+
}>;
|
|
1550
|
+
inspect(): Promise<RuntimeGroupInspect>;
|
|
1551
|
+
destroy(): void;
|
|
1552
|
+
};
|
|
1553
|
+
declare function createRuntimeGroup(options: CreateRuntimeGroupOptions): RuntimeGroup;
|
|
1554
|
+
|
|
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 };
|