@dreamboard-games/sdk 0.2.1-alpha.1 → 0.3.0-alpha.1
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/dist/{HandView-ncJIVLhN.d.ts → HandView-PYDmehVD.d.ts} +1 -1
- package/dist/{ResourceCounter-CTREyF73.d.ts → ResourceCounter-BTXklCEZ.d.ts} +1 -1
- package/dist/{ThemeProvider-BBMVT3KG.d.ts → ThemeProvider-DvMl17Ny.d.ts} +1 -1
- package/dist/{chunk-NKCRKGR2.js → chunk-3RQEICD3.js} +2 -2
- package/dist/{chunk-ZABVH7AO.js → chunk-ADYH6PVT.js} +1336 -1363
- package/dist/chunk-ADYH6PVT.js.map +1 -0
- package/dist/{chunk-PEI3FIL2.js → chunk-P7VMTJ5D.js} +2 -2
- package/dist/{chunk-PEI3FIL2.js.map → chunk-P7VMTJ5D.js.map} +1 -1
- package/dist/{chunk-WG4JQL3S.js → chunk-QZ6X4B5P.js} +1177 -1109
- package/dist/chunk-QZ6X4B5P.js.map +1 -0
- package/dist/{chunk-MZNVHMJ5.js → chunk-TXXLS3OI.js} +405 -309
- package/dist/chunk-TXXLS3OI.js.map +1 -0
- package/dist/{chunk-FDNZTDD6.js → chunk-W6SGFWXH.js} +48 -44
- package/dist/chunk-W6SGFWXH.js.map +1 -0
- package/dist/{chunk-MKXPVOUT.js → chunk-Y2AFYBMB.js} +48 -4
- package/dist/chunk-Y2AFYBMB.js.map +1 -0
- package/dist/{index-BwqPQtBu.d.ts → codegen.d.ts} +57 -565
- package/dist/{infrastructure/workspace-codegen.js → codegen.js} +3 -3
- package/dist/{components-BoiVSYqx.d.ts → components-DaIqi9QM.d.ts} +48 -37
- package/dist/{hex-board-view-1iAyJRFn.d.ts → hex-board-view-UCUjMALd.d.ts} +2 -2
- package/dist/{infrastructure/reducer-bundle-abi.d.ts → index.d-BGqVifr_.d.ts} +289 -10
- package/dist/index.js +1 -1
- package/dist/package-set.d.ts +2 -2
- package/dist/package-set.js +1 -1
- package/dist/primitive-props-BNHDkgd7.d.ts +16 -0
- package/dist/reducer-contract.d.ts +3 -0
- package/dist/{infrastructure/reducer-bundle-abi.js → reducer-contract.js} +4 -4
- package/dist/reducer.d.ts +185 -179
- package/dist/reducer.js +1363 -1372
- package/dist/reducer.js.map +1 -1
- package/dist/runtime/primitives.d.ts +9 -9
- package/dist/runtime/primitives.js +7 -7
- package/dist/runtime/runtime-api.d.ts +2 -0
- package/dist/runtime/runtime-api.js +1 -0
- package/dist/runtime/workspace-contract.d.ts +62 -17
- package/dist/runtime/workspace-contract.js +5 -6
- package/dist/{runtime-api-CPLm_XDG.d.ts → runtime-api-tGL3ArsB.d.ts} +103 -4
- package/dist/runtime.d.ts +11 -57
- package/dist/runtime.js +487 -8
- package/dist/runtime.js.map +1 -1
- package/dist/testing.d.ts +4 -4
- package/dist/testing.js.map +1 -1
- package/dist/types.d.ts +1531 -85
- package/dist/types.js +1 -3
- package/dist/types.js.map +1 -1
- package/dist/ui/components.d.ts +7 -8
- package/dist/ui/components.js +1 -1
- package/dist/ui/defaults.d.ts +1 -1
- package/dist/ui/{types/player-state.d.ts → player-state.d.ts} +2 -2
- package/dist/{ui-contract-rzKBwOLC.d.ts → ui-contract-SctM4ibF.d.ts} +155 -150
- package/dist/ui.d.ts +10 -11
- package/dist/ui.js +2 -2
- package/package.json +30 -75
- package/dist/bundle-CDd5FKeD.d.ts +0 -283
- package/dist/cards-Sl3b40Mv.d.ts +0 -13
- package/dist/chunk-326PGVAA.js +0 -34
- package/dist/chunk-326PGVAA.js.map +0 -1
- package/dist/chunk-FDNZTDD6.js.map +0 -1
- package/dist/chunk-I46YJSOD.js +0 -1
- package/dist/chunk-MKXPVOUT.js.map +0 -1
- package/dist/chunk-MZNVHMJ5.js.map +0 -1
- package/dist/chunk-T52J5RMF.js +0 -1
- package/dist/chunk-WG4JQL3S.js.map +0 -1
- package/dist/chunk-XV6D3ET4.js +0 -485
- package/dist/chunk-XV6D3ET4.js.map +0 -1
- package/dist/chunk-ZABVH7AO.js.map +0 -1
- package/dist/generated/runtime/primitives.d.ts +0 -13
- package/dist/generated/runtime/primitives.js +0 -181
- package/dist/generated/runtime/primitives.js.map +0 -1
- package/dist/generated/runtime-api.d.ts +0 -3
- package/dist/generated/runtime-api.js +0 -2
- package/dist/generated/runtime.d.ts +0 -15
- package/dist/generated/runtime.js +0 -19
- package/dist/generated/runtime.js.map +0 -1
- package/dist/generated/workspace-contract.d.ts +0 -15
- package/dist/generated/workspace-contract.js +0 -15
- package/dist/generated/workspace-contract.js.map +0 -1
- package/dist/infrastructure/reducer-bundle-abi.js.map +0 -1
- package/dist/infrastructure/workspace-codegen.d.ts +0 -53
- package/dist/infrastructure/workspace-codegen.js.map +0 -1
- package/dist/manifest-contract-BNHVGFtU.d.ts +0 -9
- package/dist/primitive-props-DpKs-GCr.d.ts +0 -11
- package/dist/runtime/types/runtime-api.d.ts +0 -1
- package/dist/runtime/types/runtime-api.js +0 -2
- package/dist/runtime/types/runtime-api.js.map +0 -1
- package/dist/runtime-api-3dshj6kK.d.ts +0 -101
- package/dist/slots-1GPGihk8.d.ts +0 -8
- package/src/browser-interaction/attributes.ts +0 -211
- package/src/browser-interaction/canonical.ts +0 -77
- package/src/browser-interaction/constants.ts +0 -77
- package/src/browser-interaction/effects.ts +0 -176
- package/src/browser-interaction/index.ts +0 -111
- package/src/browser-interaction/normalize.ts +0 -997
- package/src/browser-interaction/registry.ts +0 -70
- package/src/browser-interaction/resolve.ts +0 -596
- package/src/browser-interaction/schemas.ts +0 -152
- package/src/browser-interaction/types.ts +0 -304
- package/src/browser-interaction.ts +0 -1
- package/src/generated/reducer-contract/builders.ts +0 -90
- package/src/generated/reducer-contract/version.ts +0 -9
- package/src/generated/reducer-contract/wire.ts +0 -100
- package/src/generated/reducer-contract/zod.ts +0 -103
- package/src/generated/runtime/primitives.ts +0 -2
- package/src/generated/runtime-api.ts +0 -5
- package/src/generated/runtime.ts +0 -35
- package/src/generated/workspace-contract.ts +0 -2
- package/src/index.ts +0 -7
- package/src/infrastructure/reducer-bundle-abi.ts +0 -8
- package/src/infrastructure/reducer-contract/bundle.ts +0 -37
- package/src/infrastructure/workspace-codegen/hex-geometry.ts +0 -69
- package/src/infrastructure/workspace-codegen/index.ts +0 -64
- package/src/infrastructure/workspace-codegen/manifest-contract.ts +0 -6632
- package/src/infrastructure/workspace-codegen/manifest-validation.ts +0 -795
- package/src/infrastructure/workspace-codegen/ownership.ts +0 -131
- package/src/infrastructure/workspace-codegen/preset-card-sets.ts +0 -169
- package/src/infrastructure/workspace-codegen/seeds.ts +0 -1705
- package/src/infrastructure/workspace-codegen.ts +0 -1
- package/src/package-set.ts +0 -19
- package/src/reducer/authoring/contract.ts +0 -157
- package/src/reducer/authoring/effect.ts +0 -224
- package/src/reducer/authoring/game.ts +0 -23
- package/src/reducer/authoring/interaction.ts +0 -98
- package/src/reducer/authoring/phase.ts +0 -300
- package/src/reducer/authoring/types.ts +0 -70
- package/src/reducer/authoring/validation.ts +0 -382
- package/src/reducer/authoring/view-stage.ts +0 -68
- package/src/reducer/authoring.ts +0 -29
- package/src/reducer/bundle/ingress-bundle.ts +0 -491
- package/src/reducer/bundle/trusted/engine-instruction-resolver.ts +0 -254
- package/src/reducer/bundle/trusted/flow-instruction-resolver.ts +0 -73
- package/src/reducer/bundle/trusted/instruction-runner.ts +0 -414
- package/src/reducer/bundle/trusted/interaction-authorization.ts +0 -137
- package/src/reducer/bundle/trusted/interaction-collectors.ts +0 -859
- package/src/reducer/bundle/trusted/interaction-decision.ts +0 -747
- package/src/reducer/bundle/trusted/interaction-resolver.ts +0 -95
- package/src/reducer/bundle/trusted/interaction-types.ts +0 -174
- package/src/reducer/bundle/trusted/lifecycle-runner.ts +0 -427
- package/src/reducer/bundle/trusted/projection-builder.ts +0 -680
- package/src/reducer/bundle/trusted/projection-context.ts +0 -39
- package/src/reducer/bundle/trusted/rng-sampler.ts +0 -150
- package/src/reducer/bundle/trusted/runtime-registry.ts +0 -120
- package/src/reducer/bundle/trusted/runtime-scope.ts +0 -336
- package/src/reducer/bundle/trusted/simultaneous-player.ts +0 -97
- package/src/reducer/bundle/trusted/stage-resolver.ts +0 -87
- package/src/reducer/bundle/trusted/static-projection.ts +0 -116
- package/src/reducer/bundle/trusted/trusted-runtime-args.ts +0 -97
- package/src/reducer/bundle/trusted/trusted-runtime-result.ts +0 -39
- package/src/reducer/bundle/trusted/trusted-setup-profiles.ts +0 -43
- package/src/reducer/bundle/trusted/trusted-state-codec.ts +0 -48
- package/src/reducer/bundle/trusted-bundle.ts +0 -97
- package/src/reducer/bundle/types.ts +0 -171
- package/src/reducer/bundle.ts +0 -2
- package/src/reducer/client-param-schemas.ts +0 -57
- package/src/reducer/compose.ts +0 -34
- package/src/reducer/core/runtime-input.ts +0 -30
- package/src/reducer/core/runtime-instruction.ts +0 -59
- package/src/reducer/core/types.ts +0 -62
- package/src/reducer/definition-index.ts +0 -277
- package/src/reducer/derived.ts +0 -106
- package/src/reducer/effects.ts +0 -92
- package/src/reducer/engine/runtime-instruction-engine.ts +0 -155
- package/src/reducer/ingress/decode-runtime-input.ts +0 -7
- package/src/reducer/ingress/decode-session-state.ts +0 -9
- package/src/reducer/ingress/encode-session-state.ts +0 -6
- package/src/reducer/ingress/input-codec.ts +0 -18
- package/src/reducer/ingress/phase-schemas.ts +0 -62
- package/src/reducer/ingress/raw-types.ts +0 -107
- package/src/reducer/ingress/runtime-codec.ts +0 -14
- package/src/reducer/ingress/runtime-payload.ts +0 -13
- package/src/reducer/ingress/session-codec.ts +0 -392
- package/src/reducer/ingress/types.ts +0 -6
- package/src/reducer/inputs/boardInput.ts +0 -217
- package/src/reducer/inputs/boardTarget.ts +0 -190
- package/src/reducer/inputs/cardInput.ts +0 -86
- package/src/reducer/inputs/cardTarget.ts +0 -101
- package/src/reducer/inputs/choiceTarget.ts +0 -104
- package/src/reducer/inputs/defineInputs.ts +0 -71
- package/src/reducer/inputs/formInput.ts +0 -809
- package/src/reducer/inputs/many.ts +0 -120
- package/src/reducer/inputs/promptInput.ts +0 -87
- package/src/reducer/inputs/rngInput.ts +0 -58
- package/src/reducer/inputs/targetRule.ts +0 -123
- package/src/reducer/inputs.ts +0 -41
- package/src/reducer/model/definition.ts +0 -1072
- package/src/reducer/model/extract.ts +0 -745
- package/src/reducer/model/manifest.ts +0 -570
- package/src/reducer/model/queries.ts +0 -641
- package/src/reducer/model/runtime.ts +0 -264
- package/src/reducer/model/spec.ts +0 -1386
- package/src/reducer/model/table.ts +0 -260
- package/src/reducer/model.ts +0 -7
- package/src/reducer/ops.ts +0 -1034
- package/src/reducer/parse-utils.ts +0 -28
- package/src/reducer/per-player.ts +0 -422
- package/src/reducer/rng.ts +0 -69
- package/src/reducer/schema-helpers.ts +0 -185
- package/src/reducer/setup-bootstrap-helpers.ts +0 -171
- package/src/reducer/setup-bootstrap.ts +0 -481
- package/src/reducer/table-ops.ts +0 -2671
- package/src/reducer/table-queries.ts +0 -372
- package/src/reducer/transaction.ts +0 -120
- package/src/reducer.ts +0 -314
- package/src/runtime/primitives.ts +0 -1
- package/src/runtime/types/runtime-api.ts +0 -1
- package/src/runtime/workspace-contract.ts +0 -32
- package/src/runtime-internal/components/InteractionForm.tsx +0 -1647
- package/src/runtime-internal/components/PluginRuntime.tsx +0 -105
- package/src/runtime-internal/components/board/target-layer.ts +0 -72
- package/src/runtime-internal/context/ClientParamSchemaContext.tsx +0 -44
- package/src/runtime-internal/context/InteractionDraftContext.tsx +0 -279
- package/src/runtime-internal/context/PluginSessionContext.tsx +0 -47
- package/src/runtime-internal/context/PluginStateContext.tsx +0 -303
- package/src/runtime-internal/context/RuntimeContext.tsx +0 -96
- package/src/runtime-internal/defaults/components.tsx +0 -409
- package/src/runtime-internal/defaults/index.ts +0 -11
- package/src/runtime-internal/errors/ValidationError.ts +0 -29
- package/src/runtime-internal/hooks/useActivePlayers.ts +0 -33
- package/src/runtime-internal/hooks/useBoardInteractions.ts +0 -727
- package/src/runtime-internal/hooks/useGameSelector.ts +0 -105
- package/src/runtime-internal/hooks/useGameView.ts +0 -9
- package/src/runtime-internal/hooks/useInteractionByKey.ts +0 -354
- package/src/runtime-internal/hooks/useInteractionHandle.ts +0 -438
- package/src/runtime-internal/hooks/useIsMyTurn.ts +0 -20
- package/src/runtime-internal/hooks/useLobby.ts +0 -76
- package/src/runtime-internal/hooks/useMe.ts +0 -48
- package/src/runtime-internal/hooks/usePlayerInfo.ts +0 -28
- package/src/runtime-internal/hooks/usePlayerTurnOrder.ts +0 -23
- package/src/runtime-internal/hooks/usePluginRuntime.ts +0 -147
- package/src/runtime-internal/hooks/useSeatInbox.ts +0 -61
- package/src/runtime-internal/hooks/useSimultaneousPhase.ts +0 -10
- package/src/runtime-internal/index.ts +0 -42
- package/src/runtime-internal/internal.ts +0 -43
- package/src/runtime-internal/plugin-styles.css +0 -250
- package/src/runtime-internal/primitives/board.tsx +0 -530
- package/src/runtime-internal/primitives/dialog-lifecycle.ts +0 -58
- package/src/runtime-internal/primitives/dice.tsx +0 -79
- package/src/runtime-internal/primitives/game-ui-provider.tsx +0 -35
- package/src/runtime-internal/primitives/game.tsx +0 -387
- package/src/runtime-internal/primitives/hand-intent-adapter.ts +0 -147
- package/src/runtime-internal/primitives/hand-surface.tsx +0 -594
- package/src/runtime-internal/primitives/index.ts +0 -196
- package/src/runtime-internal/primitives/interaction-form-binding.tsx +0 -56
- package/src/runtime-internal/primitives/interaction-submit.ts +0 -90
- package/src/runtime-internal/primitives/interaction.tsx +0 -1146
- package/src/runtime-internal/primitives/phase.tsx +0 -43
- package/src/runtime-internal/primitives/player-roster.tsx +0 -302
- package/src/runtime-internal/primitives/primitive-props.tsx +0 -101
- package/src/runtime-internal/primitives/prompt.tsx +0 -255
- package/src/runtime-internal/primitives/ui.tsx +0 -60
- package/src/runtime-internal/primitives/zone.tsx +0 -791
- package/src/runtime-internal/reducer.ts +0 -30
- package/src/runtime-internal/runtime/createPluginRuntimeAPI.ts +0 -605
- package/src/runtime-internal/types/plugin-state.ts +0 -514
- package/src/runtime-internal/types/reducer-state.ts +0 -24
- package/src/runtime-internal/types/runtime-api.ts +0 -114
- package/src/runtime-internal/ui-contract.ts +0 -519
- package/src/runtime-internal/utils/browser-interaction-effects.ts +0 -240
- package/src/runtime-internal/utils/card-intent-adapter.ts +0 -546
- package/src/runtime-internal/utils/interaction-draft-digest.ts +0 -252
- package/src/runtime-internal/utils/interaction-inputs.ts +0 -492
- package/src/runtime-internal/utils/interaction-labels.ts +0 -23
- package/src/runtime-internal/utils/interaction-router.ts +0 -273
- package/src/runtime-internal/utils/interaction-status.ts +0 -74
- package/src/runtime-internal/utils/semantic-projection-digest.ts +0 -407
- package/src/runtime-internal/workspace-contract.ts +0 -1170
- package/src/runtime.ts +0 -34
- package/src/testing/create-expect-api.ts +0 -352
- package/src/testing/create-test-runtime.ts +0 -381
- package/src/testing/definitions.ts +0 -127
- package/src/testing/index.ts +0 -3
- package/src/testing.ts +0 -1
- package/src/type-stubs/manifest-contract.d.ts +0 -42
- package/src/type-stubs/manifest-contract.js +0 -72
- package/src/type-stubs/ui-contract.d.ts +0 -5
- package/src/type-stubs/ui-contract.js +0 -1
- package/src/types/authoring-card-properties.type-test.ts +0 -266
- package/src/types/authoring.ts +0 -1282
- package/src/types/cards.ts +0 -19
- package/src/types/contracts.ts +0 -1550
- package/src/types/generated-helpers.ts +0 -35
- package/src/types/index.ts +0 -147
- package/src/types/slots.ts +0 -11
- package/src/types.ts +0 -1
- package/src/ui/components/ActionButton.tsx +0 -97
- package/src/ui/components/ActionPanel.tsx +0 -315
- package/src/ui/components/Card.tsx +0 -378
- package/src/ui/components/CardDragSurface.tsx +0 -1076
- package/src/ui/components/ChromeSuppressionContext.tsx +0 -70
- package/src/ui/components/CostDisplay.tsx +0 -145
- package/src/ui/components/DiceRoller.tsx +0 -581
- package/src/ui/components/Drawer.tsx +0 -180
- package/src/ui/components/ErrorBoundary.tsx +0 -275
- package/src/ui/components/GameEndDisplay.tsx +0 -398
- package/src/ui/components/GameSkeleton.tsx +0 -260
- package/src/ui/components/Hand.tsx +0 -468
- package/src/ui/components/HandDock.tsx +0 -299
- package/src/ui/components/HandView.tsx +0 -441
- package/src/ui/components/MobileHandTray.tsx +0 -381
- package/src/ui/components/MoreActions.tsx +0 -143
- package/src/ui/components/PhaseIndicator.tsx +0 -341
- package/src/ui/components/PlayArea.tsx +0 -146
- package/src/ui/components/PrimaryActionButton.tsx +0 -336
- package/src/ui/components/PrimaryButton.tsx +0 -45
- package/src/ui/components/ResourceCounter.tsx +0 -270
- package/src/ui/components/StagingZone.tsx +0 -134
- package/src/ui/components/ThemedButton.tsx +0 -113
- package/src/ui/components/Toast.tsx +0 -264
- package/src/ui/components/board/HexGrid.tsx +0 -1297
- package/src/ui/components/board/NetworkGraph.tsx +0 -476
- package/src/ui/components/board/SlotSystem.tsx +0 -388
- package/src/ui/components/board/SquareGrid.tsx +0 -1165
- package/src/ui/components/board/TrackBoard.tsx +0 -496
- package/src/ui/components/board/ZoneMap.tsx +0 -448
- package/src/ui/components/board/hex-board-view.ts +0 -123
- package/src/ui/components/board/index.ts +0 -142
- package/src/ui/components/board/interaction-accessibility.ts +0 -21
- package/src/ui/components/board/target-layer.ts +0 -67
- package/src/ui/components/card-render-content.type-test.ts +0 -27
- package/src/ui/components/hand-layout-math.ts +0 -163
- package/src/ui/components/hand-pointer-engine.ts +0 -413
- package/src/ui/components/index.ts +0 -245
- package/src/ui/components.ts +0 -1
- package/src/ui/defaults/components.tsx +0 -106
- package/src/ui/defaults/index.ts +0 -8
- package/src/ui/defaults.ts +0 -1
- package/src/ui/errors/ValidationError.ts +0 -29
- package/src/ui/helpers/cards.ts +0 -19
- package/src/ui/helpers/track-board.ts +0 -211
- package/src/ui/hooks/useBoardTopology.ts +0 -316
- package/src/ui/hooks/useCards.ts +0 -10
- package/src/ui/hooks/useHandCardPointer.ts +0 -381
- package/src/ui/hooks/useHandLayout.ts +0 -378
- package/src/ui/hooks/useHandPresentation.ts +0 -121
- package/src/ui/hooks/useHexBoard.ts +0 -74
- package/src/ui/hooks/useHexGrid.ts +0 -185
- package/src/ui/hooks/useIsMobile.ts +0 -35
- package/src/ui/hooks/usePanZoom.ts +0 -278
- package/src/ui/hooks/useSquareBoard.ts +0 -124
- package/src/ui/hooks/useSquareGrid.ts +0 -328
- package/src/ui/index.ts +0 -98
- package/src/ui/internal/ui/alert.tsx +0 -51
- package/src/ui/internal/ui/button.tsx +0 -58
- package/src/ui/internal/ui/dialog.tsx +0 -134
- package/src/ui/internal/ui/input.tsx +0 -21
- package/src/ui/internal/ui/label.tsx +0 -21
- package/src/ui/internal/ui/select.tsx +0 -129
- package/src/ui/internal/ui/tooltip.tsx +0 -54
- package/src/ui/internal/ui/utils.ts +0 -5
- package/src/ui/plugin-styles.css +0 -250
- package/src/ui/primitives/dialog-lifecycle.ts +0 -58
- package/src/ui/primitives/dice.tsx +0 -79
- package/src/ui/primitives/primitive-props.tsx +0 -101
- package/src/ui/theme/ThemeProvider.tsx +0 -252
- package/src/ui/theme/board.ts +0 -61
- package/src/ui/theme/css-vars.ts +0 -105
- package/src/ui/theme/derive.ts +0 -240
- package/src/ui/theme/index.ts +0 -61
- package/src/ui/theme/presets/arcade.ts +0 -261
- package/src/ui/theme/presets/studio.ts +0 -261
- package/src/ui/theme/presets/tabletop.ts +0 -266
- package/src/ui/theme/tokens.ts +0 -392
- package/src/ui/types/hex-color.ts +0 -20
- package/src/ui/types/player-state.ts +0 -463
- package/src/ui/types/tiled-board.ts +0 -785
- package/src/ui/types/visual-state.ts +0 -137
- package/src/ui.ts +0 -1
- /package/dist/{chunk-NKCRKGR2.js.map → chunk-3RQEICD3.js.map} +0 -0
- /package/dist/{chunk-I46YJSOD.js.map → codegen.js.map} +0 -0
- /package/dist/{chunk-T52J5RMF.js.map → reducer-contract.js.map} +0 -0
- /package/dist/{generated → runtime}/runtime-api.js.map +0 -0
- /package/dist/ui/{types/player-state.js → player-state.js} +0 -0
- /package/dist/ui/{types/player-state.js.map → player-state.js.map} +0 -0
|
@@ -1,997 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BROWSER_INTERACTION_ACTUATOR_KINDS,
|
|
3
|
-
BROWSER_INTERACTION_ATTRIBUTES,
|
|
4
|
-
BROWSER_INTERACTION_CANDIDATE_STATES,
|
|
5
|
-
BROWSER_INTERACTION_READINESS_VALUES,
|
|
6
|
-
DREAMBOARD_BROWSER_INTERACTION_PROTOCOL_NAME,
|
|
7
|
-
DREAMBOARD_BROWSER_INTERACTION_PROTOCOL_VERSION,
|
|
8
|
-
GAMEPLAY_BROWSER_INTERACTION_SURFACE,
|
|
9
|
-
} from "./constants.js";
|
|
10
|
-
import {
|
|
11
|
-
decodeCanonicalCandidateValue,
|
|
12
|
-
encodeCanonicalCandidateValue,
|
|
13
|
-
} from "./canonical.js";
|
|
14
|
-
import {
|
|
15
|
-
browserInteractionEffectPatternMatches,
|
|
16
|
-
decodeBrowserInteractionEffect,
|
|
17
|
-
decodeBrowserInteractionEffectPattern,
|
|
18
|
-
encodeBrowserInteractionEffect,
|
|
19
|
-
encodeBrowserInteractionEffectPattern,
|
|
20
|
-
} from "./effects.js";
|
|
21
|
-
import { createBrowserInteractionActuatorKey } from "./attributes.js";
|
|
22
|
-
import { defaultBrowserInteractionRegistry } from "./registry.js";
|
|
23
|
-
import type {
|
|
24
|
-
BrowserInteractionActuator,
|
|
25
|
-
BrowserInteractionActuatorKind,
|
|
26
|
-
BrowserInteractionCandidateState,
|
|
27
|
-
BrowserInteractionDiagnostic,
|
|
28
|
-
BrowserInteractionEffectPattern,
|
|
29
|
-
BrowserInteractionEntity,
|
|
30
|
-
BrowserInteractionRawRecord,
|
|
31
|
-
BrowserInteractionReadiness,
|
|
32
|
-
BrowserInteractionRegistry,
|
|
33
|
-
BrowserInteractionSemanticSurfaceSnapshot,
|
|
34
|
-
BrowserInteractionSnapshot,
|
|
35
|
-
BrowserInteractionSurfaceEffect,
|
|
36
|
-
BrowserInteractionSurface,
|
|
37
|
-
BrowserInteractionSurfaceSnapshot,
|
|
38
|
-
} from "./types.js";
|
|
39
|
-
|
|
40
|
-
interface PendingInteraction {
|
|
41
|
-
interactionKey: string;
|
|
42
|
-
interactionId: string;
|
|
43
|
-
descriptorDigest?: string;
|
|
44
|
-
draftDigest?: string;
|
|
45
|
-
readiness: BrowserInteractionReadiness;
|
|
46
|
-
rootSeen: boolean;
|
|
47
|
-
actuators: BrowserInteractionActuator[];
|
|
48
|
-
diagnostics: BrowserInteractionDiagnostic[];
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
interface PendingSemanticSurface {
|
|
52
|
-
kind: "semantic";
|
|
53
|
-
surface: BrowserInteractionSurface;
|
|
54
|
-
scopeId: string;
|
|
55
|
-
interactions: Map<string, PendingInteraction>;
|
|
56
|
-
diagnostics: BrowserInteractionDiagnostic[];
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
interface PendingUnknownSurface {
|
|
60
|
-
kind: "unknown";
|
|
61
|
-
surface: BrowserInteractionSurface;
|
|
62
|
-
scopeId: string;
|
|
63
|
-
diagnostics: BrowserInteractionDiagnostic[];
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
type PendingSurface = PendingSemanticSurface | PendingUnknownSurface;
|
|
67
|
-
|
|
68
|
-
export interface NormalizeBrowserInteractionRecordsOptions {
|
|
69
|
-
readonly registry?: BrowserInteractionRegistry;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export function normalizeBrowserInteractionRecords(
|
|
73
|
-
records: readonly BrowserInteractionRawRecord[],
|
|
74
|
-
options: NormalizeBrowserInteractionRecordsOptions = {},
|
|
75
|
-
): BrowserInteractionSnapshot {
|
|
76
|
-
const registry = options.registry ?? defaultBrowserInteractionRegistry;
|
|
77
|
-
const diagnostics: BrowserInteractionDiagnostic[] = [];
|
|
78
|
-
const surfaces = new Map<string, PendingSurface>();
|
|
79
|
-
|
|
80
|
-
const getSurface = (
|
|
81
|
-
surface: string,
|
|
82
|
-
scopeId: string,
|
|
83
|
-
): PendingSurface | null => {
|
|
84
|
-
const registered = registry.surfaces.get(surface);
|
|
85
|
-
const key = `${surface}\0${scopeId}`;
|
|
86
|
-
const existing = surfaces.get(key);
|
|
87
|
-
if (existing) return existing;
|
|
88
|
-
if (!registered) {
|
|
89
|
-
const diagnostic = diagnosticFor({
|
|
90
|
-
code: "unknown-surface",
|
|
91
|
-
message: `Unknown browser interaction surface '${surface}'.`,
|
|
92
|
-
surface,
|
|
93
|
-
scopeId,
|
|
94
|
-
});
|
|
95
|
-
diagnostics.push(diagnostic);
|
|
96
|
-
const pending: PendingUnknownSurface = {
|
|
97
|
-
kind: "unknown",
|
|
98
|
-
surface,
|
|
99
|
-
scopeId,
|
|
100
|
-
diagnostics: [diagnostic],
|
|
101
|
-
};
|
|
102
|
-
surfaces.set(key, pending);
|
|
103
|
-
return pending;
|
|
104
|
-
}
|
|
105
|
-
const pending: PendingSemanticSurface = {
|
|
106
|
-
kind: "semantic",
|
|
107
|
-
surface,
|
|
108
|
-
scopeId,
|
|
109
|
-
interactions: new Map(),
|
|
110
|
-
diagnostics: [],
|
|
111
|
-
};
|
|
112
|
-
surfaces.set(key, pending);
|
|
113
|
-
return pending;
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
for (const record of records) {
|
|
117
|
-
const attributes = record.attributes;
|
|
118
|
-
const protocol = text(attributes, BROWSER_INTERACTION_ATTRIBUTES.protocol);
|
|
119
|
-
const surface = text(attributes, BROWSER_INTERACTION_ATTRIBUTES.surface);
|
|
120
|
-
const scopeId = text(attributes, BROWSER_INTERACTION_ATTRIBUTES.scope);
|
|
121
|
-
const role = text(attributes, BROWSER_INTERACTION_ATTRIBUTES.role);
|
|
122
|
-
|
|
123
|
-
if (protocol !== DREAMBOARD_BROWSER_INTERACTION_PROTOCOL_VERSION) {
|
|
124
|
-
diagnostics.push(
|
|
125
|
-
diagnosticFor({
|
|
126
|
-
code: "invalid-protocol",
|
|
127
|
-
message: `Expected browser interaction protocol ${DREAMBOARD_BROWSER_INTERACTION_PROTOCOL_VERSION}.`,
|
|
128
|
-
surface,
|
|
129
|
-
scopeId,
|
|
130
|
-
}),
|
|
131
|
-
);
|
|
132
|
-
continue;
|
|
133
|
-
}
|
|
134
|
-
if (
|
|
135
|
-
!surface ||
|
|
136
|
-
!scopeId ||
|
|
137
|
-
(role !== "interaction" && role !== "actuator")
|
|
138
|
-
) {
|
|
139
|
-
diagnostics.push(
|
|
140
|
-
diagnosticFor({
|
|
141
|
-
code: "invalid-record",
|
|
142
|
-
message:
|
|
143
|
-
"Browser interaction records require protocol, surface, scope and role.",
|
|
144
|
-
surface,
|
|
145
|
-
scopeId,
|
|
146
|
-
}),
|
|
147
|
-
);
|
|
148
|
-
continue;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
const pendingSurface = getSurface(surface, scopeId);
|
|
152
|
-
if (!pendingSurface || pendingSurface.kind !== "semantic") {
|
|
153
|
-
continue;
|
|
154
|
-
}
|
|
155
|
-
const interactionKey = text(
|
|
156
|
-
attributes,
|
|
157
|
-
BROWSER_INTERACTION_ATTRIBUTES.interactionKey,
|
|
158
|
-
);
|
|
159
|
-
const interactionId = text(
|
|
160
|
-
attributes,
|
|
161
|
-
BROWSER_INTERACTION_ATTRIBUTES.interactionId,
|
|
162
|
-
);
|
|
163
|
-
if (!interactionKey || !interactionId) {
|
|
164
|
-
pushSurfaceDiagnostic(
|
|
165
|
-
pendingSurface,
|
|
166
|
-
diagnostics,
|
|
167
|
-
diagnosticFor({
|
|
168
|
-
code: "invalid-record",
|
|
169
|
-
message:
|
|
170
|
-
"Browser interaction records require interaction key and id.",
|
|
171
|
-
surface,
|
|
172
|
-
scopeId,
|
|
173
|
-
}),
|
|
174
|
-
);
|
|
175
|
-
continue;
|
|
176
|
-
}
|
|
177
|
-
const interaction = getInteraction(
|
|
178
|
-
pendingSurface,
|
|
179
|
-
interactionKey,
|
|
180
|
-
interactionId,
|
|
181
|
-
);
|
|
182
|
-
|
|
183
|
-
if (role === "interaction") {
|
|
184
|
-
interaction.rootSeen = true;
|
|
185
|
-
interaction.descriptorDigest = optionalText(
|
|
186
|
-
attributes,
|
|
187
|
-
BROWSER_INTERACTION_ATTRIBUTES.descriptorDigest,
|
|
188
|
-
);
|
|
189
|
-
interaction.draftDigest = optionalText(
|
|
190
|
-
attributes,
|
|
191
|
-
BROWSER_INTERACTION_ATTRIBUTES.draftDigest,
|
|
192
|
-
);
|
|
193
|
-
interaction.readiness = parseReadiness(
|
|
194
|
-
text(attributes, BROWSER_INTERACTION_ATTRIBUTES.readiness),
|
|
195
|
-
);
|
|
196
|
-
continue;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
const actuator = parseGameplayActuator(attributes, {
|
|
200
|
-
surface,
|
|
201
|
-
scopeId,
|
|
202
|
-
interactionKey,
|
|
203
|
-
interactionId,
|
|
204
|
-
});
|
|
205
|
-
if (actuator.diagnostics.length > 0) {
|
|
206
|
-
interaction.diagnostics.push(...actuator.diagnostics);
|
|
207
|
-
diagnostics.push(...actuator.diagnostics);
|
|
208
|
-
}
|
|
209
|
-
const registered = registry.surfaces.get(surface);
|
|
210
|
-
if (registered && !registered.intents.includes(actuator.intent)) {
|
|
211
|
-
const diagnostic = diagnosticFor({
|
|
212
|
-
code: "unknown-intent",
|
|
213
|
-
message: `Unknown browser interaction intent '${actuator.intent}' for surface '${surface}'.`,
|
|
214
|
-
surface,
|
|
215
|
-
scopeId,
|
|
216
|
-
interactionKey,
|
|
217
|
-
intent: actuator.intent,
|
|
218
|
-
actuatorId: actuator.actuatorId,
|
|
219
|
-
});
|
|
220
|
-
interaction.diagnostics.push(diagnostic);
|
|
221
|
-
diagnostics.push(diagnostic);
|
|
222
|
-
}
|
|
223
|
-
if (registered?.effectKinds) {
|
|
224
|
-
for (const effect of actuator.semanticEffects) {
|
|
225
|
-
if (!registered.effectKinds.includes(effect.kind)) {
|
|
226
|
-
const diagnostic = diagnosticFor({
|
|
227
|
-
code: "unknown-surface-effect",
|
|
228
|
-
message: `Unknown browser interaction effect '${effect.kind}' for surface '${surface}'.`,
|
|
229
|
-
surface,
|
|
230
|
-
scopeId,
|
|
231
|
-
interactionKey,
|
|
232
|
-
intent: actuator.intent,
|
|
233
|
-
actuatorId: actuator.actuatorId,
|
|
234
|
-
});
|
|
235
|
-
interaction.diagnostics.push(diagnostic);
|
|
236
|
-
diagnostics.push(diagnostic);
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
for (const pattern of [
|
|
240
|
-
...actuator.acceptedEffectPatterns,
|
|
241
|
-
...actuator.preparationPatterns,
|
|
242
|
-
]) {
|
|
243
|
-
const effectKind =
|
|
244
|
-
pattern.kind === "exact" ? pattern.effect.kind : pattern.effectKind;
|
|
245
|
-
if (!registered.effectKinds.includes(effectKind)) {
|
|
246
|
-
const diagnostic = diagnosticFor({
|
|
247
|
-
code: "unknown-surface-effect",
|
|
248
|
-
message: `Unknown browser interaction effect '${effectKind}' for surface '${surface}'.`,
|
|
249
|
-
surface,
|
|
250
|
-
scopeId,
|
|
251
|
-
interactionKey,
|
|
252
|
-
intent: actuator.intent,
|
|
253
|
-
actuatorId: actuator.actuatorId,
|
|
254
|
-
});
|
|
255
|
-
interaction.diagnostics.push(diagnostic);
|
|
256
|
-
diagnostics.push(diagnostic);
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
interaction.actuators.push(actuator);
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
for (const surface of surfaces.values()) {
|
|
264
|
-
if (surface.kind !== "semantic") continue;
|
|
265
|
-
for (const interaction of surface.interactions.values()) {
|
|
266
|
-
if (interaction.rootSeen || interaction.actuators.length === 0) continue;
|
|
267
|
-
const diagnostic = diagnosticFor({
|
|
268
|
-
code: "orphan-actuator",
|
|
269
|
-
message:
|
|
270
|
-
"Browser interaction actuators require a rendered semantic root.",
|
|
271
|
-
surface: surface.surface,
|
|
272
|
-
scopeId: surface.scopeId,
|
|
273
|
-
interactionKey: interaction.interactionKey,
|
|
274
|
-
});
|
|
275
|
-
interaction.diagnostics.push(diagnostic);
|
|
276
|
-
diagnostics.push(diagnostic);
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
const snapshot: BrowserInteractionSnapshot = {
|
|
281
|
-
protocol: {
|
|
282
|
-
name: DREAMBOARD_BROWSER_INTERACTION_PROTOCOL_NAME,
|
|
283
|
-
version: DREAMBOARD_BROWSER_INTERACTION_PROTOCOL_VERSION,
|
|
284
|
-
},
|
|
285
|
-
surfaces: [...surfaces.values()].map(finalizeSurface).sort(compareSurface),
|
|
286
|
-
diagnostics: [],
|
|
287
|
-
};
|
|
288
|
-
const validationDiagnostics = validateBrowserInteractionSnapshot(snapshot);
|
|
289
|
-
return {
|
|
290
|
-
...snapshot,
|
|
291
|
-
diagnostics: [...diagnostics, ...validationDiagnostics].sort(
|
|
292
|
-
compareDiagnostic,
|
|
293
|
-
),
|
|
294
|
-
};
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
export function validateBrowserInteractionSnapshot(
|
|
298
|
-
snapshot: BrowserInteractionSnapshot,
|
|
299
|
-
): readonly BrowserInteractionDiagnostic[] {
|
|
300
|
-
const diagnostics: BrowserInteractionDiagnostic[] = [];
|
|
301
|
-
for (const surface of snapshot.surfaces) {
|
|
302
|
-
if (!isSemanticSurfaceSnapshot(surface)) continue;
|
|
303
|
-
for (const interaction of surface.interactions) {
|
|
304
|
-
const enabledByKey = new Map<string, BrowserInteractionActuator[]>();
|
|
305
|
-
for (const actuator of interaction.actuators) {
|
|
306
|
-
if (!actuator.enabled) continue;
|
|
307
|
-
const key = actuatorIdentityKey({
|
|
308
|
-
surface: surface.surface,
|
|
309
|
-
scopeId: surface.scopeId,
|
|
310
|
-
interactionKey: interaction.interactionKey,
|
|
311
|
-
actuator,
|
|
312
|
-
});
|
|
313
|
-
const group = enabledByKey.get(key) ?? [];
|
|
314
|
-
group.push(actuator);
|
|
315
|
-
enabledByKey.set(key, group);
|
|
316
|
-
}
|
|
317
|
-
for (const [key, actuators] of enabledByKey) {
|
|
318
|
-
if (actuators.length > 1) {
|
|
319
|
-
diagnostics.push(
|
|
320
|
-
diagnosticFor({
|
|
321
|
-
code: "duplicate-enabled-actuator",
|
|
322
|
-
message: `Duplicate enabled actuator for '${key}'.`,
|
|
323
|
-
surface: surface.surface,
|
|
324
|
-
scopeId: surface.scopeId,
|
|
325
|
-
interactionKey: interaction.interactionKey,
|
|
326
|
-
intent: actuators[0]?.intent,
|
|
327
|
-
actuatorId: actuators[0]?.actuatorId,
|
|
328
|
-
}),
|
|
329
|
-
);
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
diagnostics.push(
|
|
333
|
-
...diagnosticsForPreparationCycles(surface, interaction),
|
|
334
|
-
...diagnosticsForPreparationPatternAmbiguity(surface, interaction),
|
|
335
|
-
...diagnosticsForInvalidAcceptedPatterns(surface, interaction),
|
|
336
|
-
...diagnosticsForGameplayEffectCompatibility(surface, interaction),
|
|
337
|
-
);
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
return diagnostics.sort(compareDiagnostic);
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
function diagnosticsForInvalidAcceptedPatterns(
|
|
344
|
-
surface: BrowserInteractionSemanticSurfaceSnapshot,
|
|
345
|
-
interaction: BrowserInteractionEntity,
|
|
346
|
-
): BrowserInteractionDiagnostic[] {
|
|
347
|
-
const diagnostics: BrowserInteractionDiagnostic[] = [];
|
|
348
|
-
for (const actuator of interaction.actuators) {
|
|
349
|
-
for (const pattern of actuator.acceptedEffectPatterns) {
|
|
350
|
-
if (
|
|
351
|
-
pattern.kind === "match" &&
|
|
352
|
-
Object.keys(pattern.fields ?? {}).length === 0 &&
|
|
353
|
-
pattern.scalar === undefined
|
|
354
|
-
) {
|
|
355
|
-
diagnostics.push(
|
|
356
|
-
diagnosticFor({
|
|
357
|
-
code: "invalid-effect-pattern",
|
|
358
|
-
message:
|
|
359
|
-
"Accepted-effect match patterns must be bounded by fields or scalar constraints.",
|
|
360
|
-
surface: surface.surface,
|
|
361
|
-
scopeId: surface.scopeId,
|
|
362
|
-
interactionKey: interaction.interactionKey,
|
|
363
|
-
intent: actuator.intent,
|
|
364
|
-
actuatorId: actuator.actuatorId,
|
|
365
|
-
}),
|
|
366
|
-
);
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
return diagnostics;
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
function diagnosticsForGameplayEffectCompatibility(
|
|
374
|
-
surface: BrowserInteractionSemanticSurfaceSnapshot,
|
|
375
|
-
interaction: BrowserInteractionEntity,
|
|
376
|
-
): BrowserInteractionDiagnostic[] {
|
|
377
|
-
if (surface.surface !== GAMEPLAY_BROWSER_INTERACTION_SURFACE) return [];
|
|
378
|
-
const diagnostics: BrowserInteractionDiagnostic[] = [];
|
|
379
|
-
for (const actuator of interaction.actuators) {
|
|
380
|
-
for (const effect of actuator.semanticEffects) {
|
|
381
|
-
if (!gameplayIntentCanPerformEffect(actuator.intent, effect.kind)) {
|
|
382
|
-
diagnostics.push(
|
|
383
|
-
diagnosticFor({
|
|
384
|
-
code: "effect-intent-incompatibility",
|
|
385
|
-
message:
|
|
386
|
-
"Gameplay browser interaction intent is incompatible with its semantic effect.",
|
|
387
|
-
surface: surface.surface,
|
|
388
|
-
scopeId: surface.scopeId,
|
|
389
|
-
interactionKey: interaction.interactionKey,
|
|
390
|
-
intent: actuator.intent,
|
|
391
|
-
actuatorId: actuator.actuatorId,
|
|
392
|
-
}),
|
|
393
|
-
);
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
return diagnostics;
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
function gameplayIntentCanPerformEffect(intent: string, effectKind: string) {
|
|
401
|
-
switch (effectKind) {
|
|
402
|
-
case "setCandidate":
|
|
403
|
-
return intent === "select" || intent === "toggle";
|
|
404
|
-
case "adjustResource":
|
|
405
|
-
return intent === "increment" || intent === "decrement";
|
|
406
|
-
case "setScalar":
|
|
407
|
-
return (
|
|
408
|
-
intent === "fill" || intent === "increment" || intent === "decrement"
|
|
409
|
-
);
|
|
410
|
-
case "commit":
|
|
411
|
-
return intent === "submit" || intent === "invoke";
|
|
412
|
-
case "invoke":
|
|
413
|
-
return intent === "invoke" || intent === "select" || intent === "toggle";
|
|
414
|
-
default:
|
|
415
|
-
return true;
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
function parseGameplayActuator(
|
|
420
|
-
attributes: Readonly<Record<string, string | boolean | null | undefined>>,
|
|
421
|
-
context: {
|
|
422
|
-
surface: string;
|
|
423
|
-
scopeId: string;
|
|
424
|
-
interactionKey: string;
|
|
425
|
-
interactionId: string;
|
|
426
|
-
},
|
|
427
|
-
): BrowserInteractionActuator {
|
|
428
|
-
const diagnostics: BrowserInteractionDiagnostic[] = [];
|
|
429
|
-
const intent = text(attributes, BROWSER_INTERACTION_ATTRIBUTES.intent);
|
|
430
|
-
const actuatorKind = parseActuatorKind(
|
|
431
|
-
text(attributes, BROWSER_INTERACTION_ATTRIBUTES.actuatorKind),
|
|
432
|
-
);
|
|
433
|
-
const inputKey = optionalText(
|
|
434
|
-
attributes,
|
|
435
|
-
BROWSER_INTERACTION_ATTRIBUTES.inputKey,
|
|
436
|
-
);
|
|
437
|
-
const candidate = parseCandidate(
|
|
438
|
-
attributes,
|
|
439
|
-
BROWSER_INTERACTION_ATTRIBUTES.candidateValue,
|
|
440
|
-
context,
|
|
441
|
-
intent,
|
|
442
|
-
diagnostics,
|
|
443
|
-
);
|
|
444
|
-
const candidateState = parseCandidateState(
|
|
445
|
-
optionalText(attributes, BROWSER_INTERACTION_ATTRIBUTES.candidateState),
|
|
446
|
-
);
|
|
447
|
-
const explicitId = optionalText(
|
|
448
|
-
attributes,
|
|
449
|
-
BROWSER_INTERACTION_ATTRIBUTES.actuatorId,
|
|
450
|
-
);
|
|
451
|
-
const enabled = parseEnabled(
|
|
452
|
-
attributes[BROWSER_INTERACTION_ATTRIBUTES.enabled],
|
|
453
|
-
);
|
|
454
|
-
const actuatorId =
|
|
455
|
-
explicitId ??
|
|
456
|
-
createBrowserInteractionActuatorKey({
|
|
457
|
-
surface: context.surface,
|
|
458
|
-
scopeId: context.scopeId,
|
|
459
|
-
interactionKey: context.interactionKey,
|
|
460
|
-
intent,
|
|
461
|
-
inputKey,
|
|
462
|
-
candidateValueKey: candidate?.candidateValueKey,
|
|
463
|
-
actuatorKind,
|
|
464
|
-
});
|
|
465
|
-
const preparesIntent = optionalText(
|
|
466
|
-
attributes,
|
|
467
|
-
BROWSER_INTERACTION_ATTRIBUTES.preparesIntent,
|
|
468
|
-
);
|
|
469
|
-
const preparesCandidate = parseCandidate(
|
|
470
|
-
attributes,
|
|
471
|
-
BROWSER_INTERACTION_ATTRIBUTES.preparesCandidateValue,
|
|
472
|
-
context,
|
|
473
|
-
preparesIntent ?? intent,
|
|
474
|
-
diagnostics,
|
|
475
|
-
);
|
|
476
|
-
const prepares =
|
|
477
|
-
preparesIntent === undefined
|
|
478
|
-
? undefined
|
|
479
|
-
: {
|
|
480
|
-
intent: preparesIntent,
|
|
481
|
-
inputKey: optionalText(
|
|
482
|
-
attributes,
|
|
483
|
-
BROWSER_INTERACTION_ATTRIBUTES.preparesInputKey,
|
|
484
|
-
),
|
|
485
|
-
candidateValue: preparesCandidate?.candidateValue,
|
|
486
|
-
candidateValueKey: preparesCandidate?.candidateValueKey,
|
|
487
|
-
actuatorKind: parseOptionalActuatorKind(
|
|
488
|
-
optionalText(
|
|
489
|
-
attributes,
|
|
490
|
-
BROWSER_INTERACTION_ATTRIBUTES.preparesActuatorKind,
|
|
491
|
-
),
|
|
492
|
-
),
|
|
493
|
-
};
|
|
494
|
-
const semanticEffects = parseEffectList(
|
|
495
|
-
attributes,
|
|
496
|
-
BROWSER_INTERACTION_ATTRIBUTES.semanticEffects,
|
|
497
|
-
context,
|
|
498
|
-
intent,
|
|
499
|
-
diagnostics,
|
|
500
|
-
);
|
|
501
|
-
const acceptedEffectPatterns = parseEffectPatternList(
|
|
502
|
-
attributes,
|
|
503
|
-
BROWSER_INTERACTION_ATTRIBUTES.acceptedEffectPatterns,
|
|
504
|
-
context,
|
|
505
|
-
intent,
|
|
506
|
-
diagnostics,
|
|
507
|
-
);
|
|
508
|
-
const preparationPatterns = parseEffectPatternList(
|
|
509
|
-
attributes,
|
|
510
|
-
BROWSER_INTERACTION_ATTRIBUTES.preparationPatterns,
|
|
511
|
-
context,
|
|
512
|
-
intent,
|
|
513
|
-
diagnostics,
|
|
514
|
-
);
|
|
515
|
-
|
|
516
|
-
if (!intent) {
|
|
517
|
-
diagnostics.push(
|
|
518
|
-
diagnosticFor({
|
|
519
|
-
code: "invalid-record",
|
|
520
|
-
message: "Browser interaction actuator records require an intent.",
|
|
521
|
-
...context,
|
|
522
|
-
}),
|
|
523
|
-
);
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
return {
|
|
527
|
-
actuatorId,
|
|
528
|
-
intent,
|
|
529
|
-
descriptorDigest: optionalText(
|
|
530
|
-
attributes,
|
|
531
|
-
BROWSER_INTERACTION_ATTRIBUTES.descriptorDigest,
|
|
532
|
-
),
|
|
533
|
-
draftDigest: optionalText(
|
|
534
|
-
attributes,
|
|
535
|
-
BROWSER_INTERACTION_ATTRIBUTES.draftDigest,
|
|
536
|
-
),
|
|
537
|
-
inputKey,
|
|
538
|
-
candidateValue: candidate?.candidateValue,
|
|
539
|
-
candidateValueKey: candidate?.candidateValueKey,
|
|
540
|
-
candidateState,
|
|
541
|
-
enabled,
|
|
542
|
-
actuatorKind,
|
|
543
|
-
semanticEffects,
|
|
544
|
-
acceptedEffectPatterns,
|
|
545
|
-
preparationPatterns,
|
|
546
|
-
prepares,
|
|
547
|
-
diagnostics: diagnostics.sort(compareDiagnostic),
|
|
548
|
-
};
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
function parseEffectList(
|
|
552
|
-
attributes: Readonly<Record<string, string | boolean | null | undefined>>,
|
|
553
|
-
attribute: string,
|
|
554
|
-
context: {
|
|
555
|
-
surface: string;
|
|
556
|
-
scopeId: string;
|
|
557
|
-
interactionKey: string;
|
|
558
|
-
},
|
|
559
|
-
intent: string,
|
|
560
|
-
diagnostics: BrowserInteractionDiagnostic[],
|
|
561
|
-
): BrowserInteractionSurfaceEffect[] {
|
|
562
|
-
const encodedList = optionalText(attributes, attribute);
|
|
563
|
-
if (encodedList === undefined) return [];
|
|
564
|
-
try {
|
|
565
|
-
const raw = JSON.parse(encodedList) as unknown;
|
|
566
|
-
if (!Array.isArray(raw) || raw.some((item) => typeof item !== "string")) {
|
|
567
|
-
throw new Error("Expected encoded effect array.");
|
|
568
|
-
}
|
|
569
|
-
return raw
|
|
570
|
-
.map((encoded) => decodeBrowserInteractionEffect(encoded))
|
|
571
|
-
.sort((a, b) =>
|
|
572
|
-
encodeBrowserInteractionEffect(a).localeCompare(
|
|
573
|
-
encodeBrowserInteractionEffect(b),
|
|
574
|
-
),
|
|
575
|
-
);
|
|
576
|
-
} catch {
|
|
577
|
-
diagnostics.push(
|
|
578
|
-
diagnosticFor({
|
|
579
|
-
code: "invalid-effect-payload",
|
|
580
|
-
message: "Invalid browser interaction semantic effect payload.",
|
|
581
|
-
...context,
|
|
582
|
-
intent,
|
|
583
|
-
}),
|
|
584
|
-
);
|
|
585
|
-
return [];
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
function parseEffectPatternList(
|
|
590
|
-
attributes: Readonly<Record<string, string | boolean | null | undefined>>,
|
|
591
|
-
attribute: string,
|
|
592
|
-
context: {
|
|
593
|
-
surface: string;
|
|
594
|
-
scopeId: string;
|
|
595
|
-
interactionKey: string;
|
|
596
|
-
},
|
|
597
|
-
intent: string,
|
|
598
|
-
diagnostics: BrowserInteractionDiagnostic[],
|
|
599
|
-
): BrowserInteractionEffectPattern[] {
|
|
600
|
-
const encodedList = optionalText(attributes, attribute);
|
|
601
|
-
if (encodedList === undefined) return [];
|
|
602
|
-
try {
|
|
603
|
-
const raw = JSON.parse(encodedList) as unknown;
|
|
604
|
-
if (!Array.isArray(raw) || raw.some((item) => typeof item !== "string")) {
|
|
605
|
-
throw new Error("Expected encoded effect pattern array.");
|
|
606
|
-
}
|
|
607
|
-
return raw
|
|
608
|
-
.map((encoded) => decodeBrowserInteractionEffectPattern(encoded))
|
|
609
|
-
.sort((a, b) =>
|
|
610
|
-
encodeBrowserInteractionEffectPattern(a).localeCompare(
|
|
611
|
-
encodeBrowserInteractionEffectPattern(b),
|
|
612
|
-
),
|
|
613
|
-
);
|
|
614
|
-
} catch {
|
|
615
|
-
diagnostics.push(
|
|
616
|
-
diagnosticFor({
|
|
617
|
-
code: "invalid-effect-pattern",
|
|
618
|
-
message: "Invalid browser interaction semantic effect pattern.",
|
|
619
|
-
...context,
|
|
620
|
-
intent,
|
|
621
|
-
}),
|
|
622
|
-
);
|
|
623
|
-
return [];
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
function parseCandidate(
|
|
628
|
-
attributes: Readonly<Record<string, string | boolean | null | undefined>>,
|
|
629
|
-
attribute: string,
|
|
630
|
-
context: {
|
|
631
|
-
surface: string;
|
|
632
|
-
scopeId: string;
|
|
633
|
-
interactionKey: string;
|
|
634
|
-
},
|
|
635
|
-
intent: string,
|
|
636
|
-
diagnostics: BrowserInteractionDiagnostic[],
|
|
637
|
-
) {
|
|
638
|
-
const encoded = optionalText(attributes, attribute);
|
|
639
|
-
if (encoded === undefined) return undefined;
|
|
640
|
-
try {
|
|
641
|
-
const candidateValue = decodeCanonicalCandidateValue(encoded);
|
|
642
|
-
return {
|
|
643
|
-
candidateValue,
|
|
644
|
-
candidateValueKey: encodeCanonicalCandidateValue(candidateValue),
|
|
645
|
-
};
|
|
646
|
-
} catch {
|
|
647
|
-
diagnostics.push(
|
|
648
|
-
diagnosticFor({
|
|
649
|
-
code: "invalid-candidate",
|
|
650
|
-
message: `Invalid canonical browser interaction candidate '${encoded}'.`,
|
|
651
|
-
...context,
|
|
652
|
-
intent,
|
|
653
|
-
}),
|
|
654
|
-
);
|
|
655
|
-
return undefined;
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
|
|
659
|
-
function getInteraction(
|
|
660
|
-
surface: PendingSemanticSurface,
|
|
661
|
-
interactionKey: string,
|
|
662
|
-
interactionId: string,
|
|
663
|
-
): PendingInteraction {
|
|
664
|
-
const existing = surface.interactions.get(interactionKey);
|
|
665
|
-
if (existing) return existing;
|
|
666
|
-
const next: PendingInteraction = {
|
|
667
|
-
interactionKey,
|
|
668
|
-
interactionId,
|
|
669
|
-
readiness: "ready",
|
|
670
|
-
rootSeen: false,
|
|
671
|
-
actuators: [],
|
|
672
|
-
diagnostics: [],
|
|
673
|
-
};
|
|
674
|
-
surface.interactions.set(interactionKey, next);
|
|
675
|
-
return next;
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
function finalizeSurface(
|
|
679
|
-
surface: PendingSurface,
|
|
680
|
-
): BrowserInteractionSurfaceSnapshot {
|
|
681
|
-
if (surface.kind !== "semantic") {
|
|
682
|
-
return {
|
|
683
|
-
surface: surface.surface,
|
|
684
|
-
scopeId: surface.scopeId,
|
|
685
|
-
diagnostics: surface.diagnostics.sort(compareDiagnostic),
|
|
686
|
-
};
|
|
687
|
-
}
|
|
688
|
-
const interactions: BrowserInteractionEntity[] = [
|
|
689
|
-
...surface.interactions.values(),
|
|
690
|
-
]
|
|
691
|
-
.map((interaction) => ({
|
|
692
|
-
interactionKey: interaction.interactionKey,
|
|
693
|
-
interactionId: interaction.interactionId,
|
|
694
|
-
descriptorDigest: interaction.descriptorDigest,
|
|
695
|
-
draftDigest: interaction.draftDigest,
|
|
696
|
-
readiness: interaction.readiness,
|
|
697
|
-
actuators: interaction.actuators.sort(compareActuator),
|
|
698
|
-
diagnostics: interaction.diagnostics.sort(compareDiagnostic),
|
|
699
|
-
}))
|
|
700
|
-
.sort((a, b) => a.interactionKey.localeCompare(b.interactionKey));
|
|
701
|
-
return {
|
|
702
|
-
surface: surface.surface,
|
|
703
|
-
scopeId: surface.scopeId,
|
|
704
|
-
interactions,
|
|
705
|
-
diagnostics: surface.diagnostics.sort(compareDiagnostic),
|
|
706
|
-
};
|
|
707
|
-
}
|
|
708
|
-
|
|
709
|
-
function diagnosticsForPreparationCycles(
|
|
710
|
-
surface: BrowserInteractionSemanticSurfaceSnapshot,
|
|
711
|
-
interaction: BrowserInteractionEntity,
|
|
712
|
-
): BrowserInteractionDiagnostic[] {
|
|
713
|
-
const diagnostics: BrowserInteractionDiagnostic[] = [];
|
|
714
|
-
diagnostics.push(
|
|
715
|
-
...diagnosticsForEffectPreparationCycles(surface, interaction),
|
|
716
|
-
);
|
|
717
|
-
const actuators = new Map<string, BrowserInteractionActuator>();
|
|
718
|
-
for (const actuator of interaction.actuators) {
|
|
719
|
-
actuators.set(
|
|
720
|
-
actuatorIdentityKey({
|
|
721
|
-
surface: surface.surface,
|
|
722
|
-
scopeId: surface.scopeId,
|
|
723
|
-
interactionKey: interaction.interactionKey,
|
|
724
|
-
actuator,
|
|
725
|
-
}),
|
|
726
|
-
actuator,
|
|
727
|
-
);
|
|
728
|
-
}
|
|
729
|
-
for (const actuator of interaction.actuators) {
|
|
730
|
-
const visited = new Set<string>();
|
|
731
|
-
let current: BrowserInteractionActuator | undefined = actuator;
|
|
732
|
-
while (current?.prepares) {
|
|
733
|
-
const key = actuatorIdentityKey({
|
|
734
|
-
surface: surface.surface,
|
|
735
|
-
scopeId: surface.scopeId,
|
|
736
|
-
interactionKey: interaction.interactionKey,
|
|
737
|
-
actuator: current,
|
|
738
|
-
});
|
|
739
|
-
if (visited.has(key)) {
|
|
740
|
-
diagnostics.push(
|
|
741
|
-
diagnosticFor({
|
|
742
|
-
code: "preparation-cycle",
|
|
743
|
-
message: `Preparation cycle detected for actuator '${current.actuatorId}'.`,
|
|
744
|
-
surface: surface.surface,
|
|
745
|
-
scopeId: surface.scopeId,
|
|
746
|
-
interactionKey: interaction.interactionKey,
|
|
747
|
-
intent: current.intent,
|
|
748
|
-
actuatorId: current.actuatorId,
|
|
749
|
-
}),
|
|
750
|
-
);
|
|
751
|
-
break;
|
|
752
|
-
}
|
|
753
|
-
visited.add(key);
|
|
754
|
-
current = actuators.get(
|
|
755
|
-
targetIdentityKey({
|
|
756
|
-
surface: surface.surface,
|
|
757
|
-
scopeId: surface.scopeId,
|
|
758
|
-
interactionKey: interaction.interactionKey,
|
|
759
|
-
target: current.prepares,
|
|
760
|
-
}),
|
|
761
|
-
);
|
|
762
|
-
}
|
|
763
|
-
}
|
|
764
|
-
return diagnostics;
|
|
765
|
-
}
|
|
766
|
-
|
|
767
|
-
function diagnosticsForEffectPreparationCycles(
|
|
768
|
-
surface: BrowserInteractionSemanticSurfaceSnapshot,
|
|
769
|
-
interaction: BrowserInteractionEntity,
|
|
770
|
-
): BrowserInteractionDiagnostic[] {
|
|
771
|
-
const diagnostics: BrowserInteractionDiagnostic[] = [];
|
|
772
|
-
const actuatorKeys = new Map<BrowserInteractionActuator, string>();
|
|
773
|
-
interaction.actuators.forEach((actuator, index) => {
|
|
774
|
-
actuatorKeys.set(actuator, `${actuator.actuatorId}\0${index}`);
|
|
775
|
-
});
|
|
776
|
-
for (const actuator of interaction.actuators) {
|
|
777
|
-
const visited = new Set<string>();
|
|
778
|
-
let current: BrowserInteractionActuator | undefined = actuator;
|
|
779
|
-
while (current) {
|
|
780
|
-
const key = actuatorKeys.get(current);
|
|
781
|
-
if (!key) break;
|
|
782
|
-
if (visited.has(key)) {
|
|
783
|
-
diagnostics.push(
|
|
784
|
-
diagnosticFor({
|
|
785
|
-
code: "preparation-cycle",
|
|
786
|
-
message: `Semantic preparation cycle detected for actuator '${current.actuatorId}'.`,
|
|
787
|
-
surface: surface.surface,
|
|
788
|
-
scopeId: surface.scopeId,
|
|
789
|
-
interactionKey: interaction.interactionKey,
|
|
790
|
-
intent: current.intent,
|
|
791
|
-
actuatorId: current.actuatorId,
|
|
792
|
-
}),
|
|
793
|
-
);
|
|
794
|
-
break;
|
|
795
|
-
}
|
|
796
|
-
visited.add(key);
|
|
797
|
-
current = interaction.actuators.find((candidate) =>
|
|
798
|
-
current?.preparationPatterns.some((pattern) =>
|
|
799
|
-
candidate.semanticEffects.some((effect) =>
|
|
800
|
-
browserInteractionEffectPatternMatches(pattern, effect),
|
|
801
|
-
),
|
|
802
|
-
),
|
|
803
|
-
);
|
|
804
|
-
}
|
|
805
|
-
}
|
|
806
|
-
return diagnostics;
|
|
807
|
-
}
|
|
808
|
-
|
|
809
|
-
function diagnosticsForPreparationPatternAmbiguity(
|
|
810
|
-
surface: BrowserInteractionSemanticSurfaceSnapshot,
|
|
811
|
-
interaction: BrowserInteractionEntity,
|
|
812
|
-
): BrowserInteractionDiagnostic[] {
|
|
813
|
-
const diagnostics: BrowserInteractionDiagnostic[] = [];
|
|
814
|
-
for (const target of interaction.actuators) {
|
|
815
|
-
for (const effect of target.semanticEffects) {
|
|
816
|
-
const matches = interaction.actuators.filter((actuator) =>
|
|
817
|
-
actuator.preparationPatterns.some((pattern) =>
|
|
818
|
-
browserInteractionEffectPatternMatches(pattern, effect),
|
|
819
|
-
),
|
|
820
|
-
);
|
|
821
|
-
const uniqueActuatorIds = new Set(
|
|
822
|
-
matches.map((match) => match.actuatorId),
|
|
823
|
-
);
|
|
824
|
-
if (uniqueActuatorIds.size > 1) {
|
|
825
|
-
diagnostics.push(
|
|
826
|
-
diagnosticFor({
|
|
827
|
-
code: "ambiguous-preparation-pattern",
|
|
828
|
-
message:
|
|
829
|
-
"Multiple preparation patterns can prepare the same semantic effect.",
|
|
830
|
-
surface: surface.surface,
|
|
831
|
-
scopeId: surface.scopeId,
|
|
832
|
-
interactionKey: interaction.interactionKey,
|
|
833
|
-
intent: target.intent,
|
|
834
|
-
actuatorId: target.actuatorId,
|
|
835
|
-
}),
|
|
836
|
-
);
|
|
837
|
-
}
|
|
838
|
-
}
|
|
839
|
-
}
|
|
840
|
-
return diagnostics;
|
|
841
|
-
}
|
|
842
|
-
|
|
843
|
-
export function actuatorIdentityKey(input: {
|
|
844
|
-
readonly surface: string;
|
|
845
|
-
readonly scopeId: string;
|
|
846
|
-
readonly interactionKey: string;
|
|
847
|
-
readonly actuator: Pick<
|
|
848
|
-
BrowserInteractionActuator,
|
|
849
|
-
"intent" | "inputKey" | "candidateValueKey" | "actuatorKind"
|
|
850
|
-
>;
|
|
851
|
-
}): string {
|
|
852
|
-
return createBrowserInteractionActuatorKey({
|
|
853
|
-
surface: input.surface,
|
|
854
|
-
scopeId: input.scopeId,
|
|
855
|
-
interactionKey: input.interactionKey,
|
|
856
|
-
intent: input.actuator.intent,
|
|
857
|
-
inputKey: input.actuator.inputKey,
|
|
858
|
-
candidateValueKey: input.actuator.candidateValueKey,
|
|
859
|
-
actuatorKind: input.actuator.actuatorKind,
|
|
860
|
-
});
|
|
861
|
-
}
|
|
862
|
-
|
|
863
|
-
export function isGameplaySurfaceSnapshot(
|
|
864
|
-
surface: BrowserInteractionSurfaceSnapshot,
|
|
865
|
-
): surface is BrowserInteractionSemanticSurfaceSnapshot<
|
|
866
|
-
typeof GAMEPLAY_BROWSER_INTERACTION_SURFACE
|
|
867
|
-
> {
|
|
868
|
-
return surface.surface === GAMEPLAY_BROWSER_INTERACTION_SURFACE;
|
|
869
|
-
}
|
|
870
|
-
|
|
871
|
-
export function isSemanticSurfaceSnapshot(
|
|
872
|
-
surface: BrowserInteractionSurfaceSnapshot,
|
|
873
|
-
): surface is BrowserInteractionSemanticSurfaceSnapshot {
|
|
874
|
-
return "interactions" in surface;
|
|
875
|
-
}
|
|
876
|
-
|
|
877
|
-
export function targetIdentityKey(input: {
|
|
878
|
-
readonly surface: string;
|
|
879
|
-
readonly scopeId: string;
|
|
880
|
-
readonly interactionKey: string;
|
|
881
|
-
readonly target: {
|
|
882
|
-
readonly intent: string;
|
|
883
|
-
readonly inputKey?: string;
|
|
884
|
-
readonly candidateValueKey?: string;
|
|
885
|
-
readonly actuatorKind?: BrowserInteractionActuatorKind;
|
|
886
|
-
};
|
|
887
|
-
}): string {
|
|
888
|
-
return createBrowserInteractionActuatorKey({
|
|
889
|
-
surface: input.surface,
|
|
890
|
-
scopeId: input.scopeId,
|
|
891
|
-
interactionKey: input.interactionKey,
|
|
892
|
-
intent: input.target.intent,
|
|
893
|
-
inputKey: input.target.inputKey,
|
|
894
|
-
candidateValueKey: input.target.candidateValueKey,
|
|
895
|
-
actuatorKind: input.target.actuatorKind ?? "click",
|
|
896
|
-
});
|
|
897
|
-
}
|
|
898
|
-
|
|
899
|
-
function pushSurfaceDiagnostic(
|
|
900
|
-
surface: PendingSemanticSurface,
|
|
901
|
-
all: BrowserInteractionDiagnostic[],
|
|
902
|
-
diagnostic: BrowserInteractionDiagnostic,
|
|
903
|
-
) {
|
|
904
|
-
surface.diagnostics.push(diagnostic);
|
|
905
|
-
all.push(diagnostic);
|
|
906
|
-
}
|
|
907
|
-
|
|
908
|
-
function diagnosticFor(
|
|
909
|
-
input: Omit<BrowserInteractionDiagnostic, "severity">,
|
|
910
|
-
): BrowserInteractionDiagnostic {
|
|
911
|
-
return { severity: "error", ...input };
|
|
912
|
-
}
|
|
913
|
-
|
|
914
|
-
function text(
|
|
915
|
-
attributes: Readonly<Record<string, string | boolean | null | undefined>>,
|
|
916
|
-
key: string,
|
|
917
|
-
): string {
|
|
918
|
-
const value = attributes[key];
|
|
919
|
-
if (typeof value === "boolean") return value ? "true" : "false";
|
|
920
|
-
return value ?? "";
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
function optionalText(
|
|
924
|
-
attributes: Readonly<Record<string, string | boolean | null | undefined>>,
|
|
925
|
-
key: string,
|
|
926
|
-
): string | undefined {
|
|
927
|
-
const value = text(attributes, key);
|
|
928
|
-
return value === "" ? undefined : value;
|
|
929
|
-
}
|
|
930
|
-
|
|
931
|
-
function parseReadiness(value: string): BrowserInteractionReadiness {
|
|
932
|
-
return BROWSER_INTERACTION_READINESS_VALUES.includes(
|
|
933
|
-
value as BrowserInteractionReadiness,
|
|
934
|
-
)
|
|
935
|
-
? (value as BrowserInteractionReadiness)
|
|
936
|
-
: "blocked";
|
|
937
|
-
}
|
|
938
|
-
|
|
939
|
-
function parseCandidateState(
|
|
940
|
-
value: string | undefined,
|
|
941
|
-
): BrowserInteractionCandidateState | undefined {
|
|
942
|
-
return BROWSER_INTERACTION_CANDIDATE_STATES.includes(
|
|
943
|
-
value as BrowserInteractionCandidateState,
|
|
944
|
-
)
|
|
945
|
-
? (value as BrowserInteractionCandidateState)
|
|
946
|
-
: undefined;
|
|
947
|
-
}
|
|
948
|
-
|
|
949
|
-
function parseActuatorKind(value: string): BrowserInteractionActuatorKind {
|
|
950
|
-
return parseOptionalActuatorKind(value) ?? "click";
|
|
951
|
-
}
|
|
952
|
-
|
|
953
|
-
function parseOptionalActuatorKind(
|
|
954
|
-
value: string | undefined,
|
|
955
|
-
): BrowserInteractionActuatorKind | undefined {
|
|
956
|
-
return BROWSER_INTERACTION_ACTUATOR_KINDS.includes(
|
|
957
|
-
value as BrowserInteractionActuatorKind,
|
|
958
|
-
)
|
|
959
|
-
? (value as BrowserInteractionActuatorKind)
|
|
960
|
-
: undefined;
|
|
961
|
-
}
|
|
962
|
-
|
|
963
|
-
function parseEnabled(value: string | boolean | null | undefined): boolean {
|
|
964
|
-
if (value === false || value === "false") return false;
|
|
965
|
-
return true;
|
|
966
|
-
}
|
|
967
|
-
|
|
968
|
-
function compareSurface(
|
|
969
|
-
a: BrowserInteractionSurfaceSnapshot,
|
|
970
|
-
b: BrowserInteractionSurfaceSnapshot,
|
|
971
|
-
): number {
|
|
972
|
-
return (
|
|
973
|
-
a.surface.localeCompare(b.surface) || a.scopeId.localeCompare(b.scopeId)
|
|
974
|
-
);
|
|
975
|
-
}
|
|
976
|
-
|
|
977
|
-
function compareActuator(
|
|
978
|
-
a: BrowserInteractionActuator,
|
|
979
|
-
b: BrowserInteractionActuator,
|
|
980
|
-
): number {
|
|
981
|
-
return a.actuatorId.localeCompare(b.actuatorId);
|
|
982
|
-
}
|
|
983
|
-
|
|
984
|
-
function compareDiagnostic(
|
|
985
|
-
a: BrowserInteractionDiagnostic,
|
|
986
|
-
b: BrowserInteractionDiagnostic,
|
|
987
|
-
): number {
|
|
988
|
-
return (
|
|
989
|
-
a.code.localeCompare(b.code) ||
|
|
990
|
-
(a.surface ?? "").localeCompare(b.surface ?? "") ||
|
|
991
|
-
(a.scopeId ?? "").localeCompare(b.scopeId ?? "") ||
|
|
992
|
-
(a.interactionKey ?? "").localeCompare(b.interactionKey ?? "") ||
|
|
993
|
-
(a.intent ?? "").localeCompare(b.intent ?? "") ||
|
|
994
|
-
(a.actuatorId ?? "").localeCompare(b.actuatorId ?? "") ||
|
|
995
|
-
a.message.localeCompare(b.message)
|
|
996
|
-
);
|
|
997
|
-
}
|