@dreamboard-games/sdk 0.2.0 → 0.2.1-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/{ThemeProvider-fy0_QzgO.d.ts → ThemeProvider-BBMVT3KG.d.ts} +1 -1
- package/dist/attributes-BeRyboMS.d.ts +279 -0
- package/dist/browser-interaction.d.ts +708 -0
- package/dist/browser-interaction.js +106 -0
- package/dist/browser-interaction.js.map +1 -0
- package/dist/{bundle-TIZcw8LB.d.ts → bundle-CDd5FKeD.d.ts} +3 -1
- package/dist/{chunk-U5C6BONG.js → chunk-326PGVAA.js} +2 -2
- package/dist/{chunk-VFTAA4WO.js → chunk-MKXPVOUT.js} +4 -2
- package/dist/chunk-MKXPVOUT.js.map +1 -0
- package/dist/{chunk-GKKBPPSW.js → chunk-MZNVHMJ5.js} +4 -4
- package/dist/{chunk-KAELH4KC.js → chunk-NKCRKGR2.js} +2 -2
- package/dist/{chunk-WN74KVNY.js → chunk-PEI3FIL2.js} +2 -2
- package/dist/chunk-PEI3FIL2.js.map +1 -0
- package/dist/chunk-QLG6VEMW.js +1691 -0
- package/dist/chunk-QLG6VEMW.js.map +1 -0
- package/dist/{chunk-WYPQ3GG5.js → chunk-WG4JQL3S.js} +4 -1
- package/dist/{chunk-WYPQ3GG5.js.map → chunk-WG4JQL3S.js.map} +1 -1
- package/dist/{chunk-7YAHLYBR.js → chunk-XV6D3ET4.js} +8 -4
- package/dist/{chunk-7YAHLYBR.js.map → chunk-XV6D3ET4.js.map} +1 -1
- package/dist/{chunk-TDSWKVZ4.js → chunk-ZABVH7AO.js} +1236 -17
- package/dist/chunk-ZABVH7AO.js.map +1 -0
- package/dist/{components-D5ZRE2Hl.d.ts → components-BoiVSYqx.d.ts} +1 -1
- package/dist/generated/runtime/primitives.d.ts +5 -4
- package/dist/generated/runtime/primitives.js +4 -3
- package/dist/generated/runtime-api.d.ts +1 -1
- package/dist/generated/runtime.d.ts +5 -4
- package/dist/generated/runtime.js +7 -6
- package/dist/generated/workspace-contract.d.ts +5 -4
- package/dist/generated/workspace-contract.js +6 -5
- package/dist/{hex-board-view-D_07hO6O.d.ts → hex-board-view-1iAyJRFn.d.ts} +1 -0
- package/dist/index.js +1 -1
- package/dist/infrastructure/reducer-bundle-abi.d.ts +113 -113
- package/dist/infrastructure/reducer-bundle-abi.js +1 -1
- package/dist/package-set.d.ts +2 -2
- package/dist/package-set.js +1 -1
- package/dist/reducer.d.ts +1 -1
- package/dist/reducer.js +305 -12
- package/dist/reducer.js.map +1 -1
- package/dist/runtime/primitives.d.ts +6 -5
- package/dist/runtime/primitives.js +4 -3
- package/dist/runtime/workspace-contract.d.ts +6 -5
- package/dist/runtime/workspace-contract.js +6 -5
- package/dist/{runtime-api-DWxvTr-O.d.ts → runtime-api-CPLm_XDG.d.ts} +6 -0
- package/dist/runtime.d.ts +5 -4
- package/dist/runtime.js +6 -5
- package/dist/testing.d.ts +2 -2
- package/dist/ui/components.d.ts +2 -2
- package/dist/ui/components.js +1 -1
- package/dist/{ui-contract-iQfTtUSL.d.ts → ui-contract-rzKBwOLC.d.ts} +5 -3
- package/dist/ui.d.ts +5 -5
- package/dist/ui.js +2 -2
- package/package.json +15 -9
- package/src/browser-interaction/attributes.ts +211 -0
- package/src/browser-interaction/canonical.ts +77 -0
- package/src/browser-interaction/constants.ts +77 -0
- package/src/browser-interaction/effects.ts +176 -0
- package/src/browser-interaction/index.ts +111 -0
- package/src/browser-interaction/normalize.ts +997 -0
- package/src/browser-interaction/registry.ts +70 -0
- package/src/browser-interaction/resolve.ts +596 -0
- package/src/browser-interaction/schemas.ts +152 -0
- package/src/browser-interaction/types.ts +304 -0
- package/src/browser-interaction.ts +1 -0
- package/src/generated/reducer-contract/wire.ts +1 -1
- package/src/generated/reducer-contract/zod.ts +3 -1
- package/src/package-set.ts +1 -1
- package/src/reducer/bundle/ingress-bundle.ts +1 -1
- package/src/reducer/bundle/trusted/interaction-types.ts +3 -0
- package/src/reducer/bundle/trusted/projection-builder.ts +337 -13
- package/src/reducer/ingress/input-codec.ts +1 -1
- package/src/reducer/ingress/session-codec.ts +1 -1
- package/src/runtime-internal/components/InteractionForm.tsx +345 -7
- package/src/runtime-internal/components/PluginRuntime.tsx +2 -0
- package/src/runtime-internal/components/board/target-layer.ts +2 -0
- package/src/runtime-internal/context/PluginStateContext.tsx +41 -0
- package/src/runtime-internal/hooks/useBoardInteractions.ts +73 -11
- package/src/runtime-internal/primitives/board.tsx +71 -0
- package/src/runtime-internal/primitives/interaction.tsx +160 -1
- package/src/runtime-internal/types/plugin-state.ts +6 -0
- package/src/runtime-internal/utils/browser-interaction-effects.ts +240 -0
- package/src/runtime-internal/utils/interaction-draft-digest.ts +252 -0
- package/src/runtime-internal/utils/semantic-projection-digest.ts +407 -0
- package/src/ui/components/board/HexGrid.tsx +3 -0
- package/src/ui/components/board/target-layer.ts +1 -0
- package/dist/chunk-TDSWKVZ4.js.map +0 -1
- package/dist/chunk-VFTAA4WO.js.map +0 -1
- package/dist/chunk-WN74KVNY.js.map +0 -1
- /package/dist/{chunk-U5C6BONG.js.map → chunk-326PGVAA.js.map} +0 -0
- /package/dist/{chunk-GKKBPPSW.js.map → chunk-MZNVHMJ5.js.map} +0 -0
- /package/dist/{chunk-KAELH4KC.js.map → chunk-NKCRKGR2.js.map} +0 -0
|
@@ -0,0 +1,1691 @@
|
|
|
1
|
+
// src/browser-interaction/constants.ts
|
|
2
|
+
var DREAMBOARD_BROWSER_INTERACTION_PROTOCOL_NAME = "dreamboard-browser-interaction";
|
|
3
|
+
var DREAMBOARD_BROWSER_INTERACTION_PROTOCOL_VERSION = "2.0.0";
|
|
4
|
+
var BROWSER_INTERACTION_ATTRIBUTES = {
|
|
5
|
+
protocol: "data-dreamboard-browser-protocol",
|
|
6
|
+
surface: "data-dreamboard-browser-surface",
|
|
7
|
+
scope: "data-dreamboard-browser-scope",
|
|
8
|
+
role: "data-dreamboard-browser-role",
|
|
9
|
+
intent: "data-dreamboard-browser-intent",
|
|
10
|
+
interactionKey: "data-dreamboard-interaction-key",
|
|
11
|
+
interactionId: "data-dreamboard-interaction-id",
|
|
12
|
+
descriptorDigest: "data-dreamboard-descriptor-digest",
|
|
13
|
+
draftDigest: "data-dreamboard-draft-digest",
|
|
14
|
+
readiness: "data-dreamboard-readiness",
|
|
15
|
+
inputKey: "data-dreamboard-input-key",
|
|
16
|
+
candidateValue: "data-dreamboard-candidate-value",
|
|
17
|
+
candidateState: "data-dreamboard-candidate-state",
|
|
18
|
+
actuatorKind: "data-dreamboard-actuator-kind",
|
|
19
|
+
enabled: "data-dreamboard-actuator-enabled",
|
|
20
|
+
actuatorId: "data-dreamboard-actuator-id",
|
|
21
|
+
semanticEffects: "data-dreamboard-semantic-effects",
|
|
22
|
+
acceptedEffectPatterns: "data-dreamboard-accepted-effect-patterns",
|
|
23
|
+
preparationPatterns: "data-dreamboard-preparation-patterns",
|
|
24
|
+
preparesIntent: "data-dreamboard-prepares-intent",
|
|
25
|
+
preparesInputKey: "data-dreamboard-prepares-input-key",
|
|
26
|
+
preparesCandidateValue: "data-dreamboard-prepares-candidate-value",
|
|
27
|
+
preparesActuatorKind: "data-dreamboard-prepares-actuator-kind",
|
|
28
|
+
diagnostic: "data-dreamboard-browser-diagnostic"
|
|
29
|
+
};
|
|
30
|
+
var BROWSER_INTERACTION_RECORD_ROLES = [
|
|
31
|
+
"interaction",
|
|
32
|
+
"actuator"
|
|
33
|
+
];
|
|
34
|
+
var GAMEPLAY_BROWSER_INTERACTION_SURFACE = "gameplay";
|
|
35
|
+
var GAMEPLAY_BROWSER_INTERACTION_INTENTS = [
|
|
36
|
+
"arm",
|
|
37
|
+
"reveal",
|
|
38
|
+
"invoke",
|
|
39
|
+
"select",
|
|
40
|
+
"toggle",
|
|
41
|
+
"increment",
|
|
42
|
+
"decrement",
|
|
43
|
+
"fill",
|
|
44
|
+
"submit"
|
|
45
|
+
];
|
|
46
|
+
var GAMEPLAY_BROWSER_INTERACTION_EFFECT_KINDS = [
|
|
47
|
+
"setCandidate",
|
|
48
|
+
"adjustResource",
|
|
49
|
+
"setScalar",
|
|
50
|
+
"commit",
|
|
51
|
+
"invoke"
|
|
52
|
+
];
|
|
53
|
+
var BROWSER_INTERACTION_READINESS_VALUES = [
|
|
54
|
+
"ready",
|
|
55
|
+
"blocked",
|
|
56
|
+
"unavailable"
|
|
57
|
+
];
|
|
58
|
+
var BROWSER_INTERACTION_CANDIDATE_STATES = [
|
|
59
|
+
"selected",
|
|
60
|
+
"unselected",
|
|
61
|
+
"mixed"
|
|
62
|
+
];
|
|
63
|
+
var BROWSER_INTERACTION_ACTUATOR_KINDS = [
|
|
64
|
+
"click",
|
|
65
|
+
"fill",
|
|
66
|
+
"keyboard",
|
|
67
|
+
"pointer"
|
|
68
|
+
];
|
|
69
|
+
|
|
70
|
+
// src/browser-interaction/canonical.ts
|
|
71
|
+
function assertCanonicalValue(value) {
|
|
72
|
+
if (value === null) return;
|
|
73
|
+
switch (typeof value) {
|
|
74
|
+
case "boolean":
|
|
75
|
+
case "string":
|
|
76
|
+
return;
|
|
77
|
+
case "number":
|
|
78
|
+
if (Number.isFinite(value)) return;
|
|
79
|
+
break;
|
|
80
|
+
case "object":
|
|
81
|
+
if (Array.isArray(value)) {
|
|
82
|
+
value.forEach(assertCanonicalValue);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (Object.getPrototypeOf(value) !== Object.prototype) break;
|
|
86
|
+
for (const [key, item] of Object.entries(value)) {
|
|
87
|
+
if (item === void 0) {
|
|
88
|
+
throw new Error(
|
|
89
|
+
`Browser interaction candidate '${key}' cannot be undefined.`
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
assertCanonicalValue(item);
|
|
93
|
+
}
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
throw new Error(
|
|
97
|
+
`Browser interaction candidates must be JSON-serializable primitives, arrays or plain objects. Received ${typeof value}.`
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
function canonicalizeValue(value) {
|
|
101
|
+
if (Array.isArray(value)) {
|
|
102
|
+
return value.map(canonicalizeValue);
|
|
103
|
+
}
|
|
104
|
+
if (value && typeof value === "object") {
|
|
105
|
+
const objectValue = value;
|
|
106
|
+
return Object.fromEntries(
|
|
107
|
+
Object.keys(objectValue).sort().map((key) => [key, canonicalizeValue(objectValue[key])])
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
return value;
|
|
111
|
+
}
|
|
112
|
+
function encodeCanonicalCandidateValue(value) {
|
|
113
|
+
assertCanonicalValue(value);
|
|
114
|
+
return JSON.stringify(canonicalizeValue(value));
|
|
115
|
+
}
|
|
116
|
+
function decodeCanonicalCandidateValue(encoded) {
|
|
117
|
+
const parsed = JSON.parse(encoded);
|
|
118
|
+
assertCanonicalValue(parsed);
|
|
119
|
+
return canonicalizeValue(parsed);
|
|
120
|
+
}
|
|
121
|
+
function compareStableJson(a, b) {
|
|
122
|
+
const encodedA = encodeCanonicalCandidateValue(a);
|
|
123
|
+
const encodedB = encodeCanonicalCandidateValue(b);
|
|
124
|
+
return encodedA.localeCompare(encodedB);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// src/browser-interaction/effects.ts
|
|
128
|
+
function encodeBrowserInteractionEffect(effect) {
|
|
129
|
+
return encodeCanonicalCandidateValue(effect);
|
|
130
|
+
}
|
|
131
|
+
function decodeBrowserInteractionEffect(encoded) {
|
|
132
|
+
const decoded = decodeCanonicalCandidateValue(encoded);
|
|
133
|
+
if (!decoded || typeof decoded !== "object" || Array.isArray(decoded)) {
|
|
134
|
+
throw new Error("Browser interaction effect must be a canonical object.");
|
|
135
|
+
}
|
|
136
|
+
const decodedObject = decoded;
|
|
137
|
+
const kind = decodedObject.kind;
|
|
138
|
+
if (typeof kind !== "string" || kind.length === 0) {
|
|
139
|
+
throw new Error("Browser interaction effect requires a string kind.");
|
|
140
|
+
}
|
|
141
|
+
return decodedObject;
|
|
142
|
+
}
|
|
143
|
+
function encodeBrowserInteractionEffectPattern(pattern) {
|
|
144
|
+
return encodeCanonicalCandidateValue(pattern);
|
|
145
|
+
}
|
|
146
|
+
function decodeBrowserInteractionEffectPattern(encoded) {
|
|
147
|
+
const decoded = decodeCanonicalCandidateValue(encoded);
|
|
148
|
+
assertBrowserInteractionEffectPattern(decoded);
|
|
149
|
+
return decoded;
|
|
150
|
+
}
|
|
151
|
+
function browserInteractionEffectPatternMatches(pattern, effect) {
|
|
152
|
+
switch (pattern.kind) {
|
|
153
|
+
case "exact":
|
|
154
|
+
return encodeBrowserInteractionEffect(pattern.effect) === encodeBrowserInteractionEffect(effect);
|
|
155
|
+
case "match": {
|
|
156
|
+
if (effect.kind !== pattern.effectKind) return false;
|
|
157
|
+
for (const [field, expected] of Object.entries(pattern.fields ?? {})) {
|
|
158
|
+
const actual = effect[field];
|
|
159
|
+
if (actual === void 0) return false;
|
|
160
|
+
if (encodeCanonicalCandidateValue(actual) !== encodeCanonicalCandidateValue(expected)) {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
const scalar = pattern.scalar;
|
|
165
|
+
if (scalar) {
|
|
166
|
+
const actual = effect[scalar.field];
|
|
167
|
+
if (typeof actual !== "number" || !Number.isFinite(actual)) {
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
if (scalar.integer === true && !Number.isInteger(actual)) {
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
if (scalar.min !== void 0 && actual < scalar.min) {
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
if (scalar.max !== void 0 && actual > scalar.max) {
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return true;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
function assertBrowserInteractionEffectPattern(value) {
|
|
185
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
186
|
+
throw new Error("Browser interaction effect pattern must be an object.");
|
|
187
|
+
}
|
|
188
|
+
const pattern = value;
|
|
189
|
+
if (pattern.kind === "exact") {
|
|
190
|
+
decodeBrowserInteractionEffect(
|
|
191
|
+
encodeCanonicalCandidateValue(pattern.effect)
|
|
192
|
+
);
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
if (pattern.kind === "match") {
|
|
196
|
+
if (typeof pattern.effectKind !== "string" || pattern.effectKind.length === 0) {
|
|
197
|
+
throw new Error(
|
|
198
|
+
"Browser interaction match pattern requires an effectKind."
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
if (pattern.fields !== void 0) {
|
|
202
|
+
if (!pattern.fields || typeof pattern.fields !== "object" || Array.isArray(pattern.fields)) {
|
|
203
|
+
throw new Error(
|
|
204
|
+
"Browser interaction match pattern fields must be an object."
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
if (pattern.scalar !== void 0) {
|
|
209
|
+
if (!pattern.scalar || typeof pattern.scalar !== "object" || Array.isArray(pattern.scalar) || typeof pattern.scalar.field !== "string" || pattern.scalar.field.length === 0) {
|
|
210
|
+
throw new Error(
|
|
211
|
+
"Browser interaction scalar pattern requires a scalar field."
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
throw new Error("Unknown browser interaction effect pattern kind.");
|
|
218
|
+
}
|
|
219
|
+
function gameplaySetCandidateEffect(input) {
|
|
220
|
+
return { kind: "setCandidate", ...input };
|
|
221
|
+
}
|
|
222
|
+
function gameplayAdjustResourceEffect(input) {
|
|
223
|
+
return { kind: "adjustResource", ...input };
|
|
224
|
+
}
|
|
225
|
+
function gameplaySetScalarEffect(input) {
|
|
226
|
+
return { kind: "setScalar", ...input };
|
|
227
|
+
}
|
|
228
|
+
function gameplayCommitEffect() {
|
|
229
|
+
return { kind: "commit" };
|
|
230
|
+
}
|
|
231
|
+
function gameplayInvokeEffect() {
|
|
232
|
+
return { kind: "invoke" };
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// src/browser-interaction/attributes.ts
|
|
236
|
+
function baseGameplayAttributes(input) {
|
|
237
|
+
return {
|
|
238
|
+
[BROWSER_INTERACTION_ATTRIBUTES.protocol]: DREAMBOARD_BROWSER_INTERACTION_PROTOCOL_VERSION,
|
|
239
|
+
[BROWSER_INTERACTION_ATTRIBUTES.surface]: input.surface,
|
|
240
|
+
[BROWSER_INTERACTION_ATTRIBUTES.scope]: input.scopeId,
|
|
241
|
+
[BROWSER_INTERACTION_ATTRIBUTES.interactionKey]: input.interactionKey,
|
|
242
|
+
[BROWSER_INTERACTION_ATTRIBUTES.interactionId]: input.interactionId
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
function createBrowserInteractionRootAttributes(input) {
|
|
246
|
+
return {
|
|
247
|
+
...baseGameplayAttributes(input),
|
|
248
|
+
[BROWSER_INTERACTION_ATTRIBUTES.role]: "interaction",
|
|
249
|
+
[BROWSER_INTERACTION_ATTRIBUTES.descriptorDigest]: input.descriptorDigest ?? "",
|
|
250
|
+
[BROWSER_INTERACTION_ATTRIBUTES.draftDigest]: input.draftDigest ?? "",
|
|
251
|
+
[BROWSER_INTERACTION_ATTRIBUTES.readiness]: input.readiness
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
function createBrowserInteractionActuatorAttributes(input) {
|
|
255
|
+
const attrs = {
|
|
256
|
+
...baseGameplayAttributes(input),
|
|
257
|
+
[BROWSER_INTERACTION_ATTRIBUTES.role]: "actuator",
|
|
258
|
+
[BROWSER_INTERACTION_ATTRIBUTES.intent]: input.intent,
|
|
259
|
+
[BROWSER_INTERACTION_ATTRIBUTES.actuatorKind]: input.actuatorKind,
|
|
260
|
+
[BROWSER_INTERACTION_ATTRIBUTES.enabled]: input.enabled === false ? "false" : "true"
|
|
261
|
+
};
|
|
262
|
+
if (input.descriptorDigest) {
|
|
263
|
+
attrs[BROWSER_INTERACTION_ATTRIBUTES.descriptorDigest] = input.descriptorDigest;
|
|
264
|
+
}
|
|
265
|
+
if (input.draftDigest) {
|
|
266
|
+
attrs[BROWSER_INTERACTION_ATTRIBUTES.draftDigest] = input.draftDigest;
|
|
267
|
+
}
|
|
268
|
+
if (input.actuatorId) {
|
|
269
|
+
attrs[BROWSER_INTERACTION_ATTRIBUTES.actuatorId] = input.actuatorId;
|
|
270
|
+
}
|
|
271
|
+
if (input.inputKey) {
|
|
272
|
+
attrs[BROWSER_INTERACTION_ATTRIBUTES.inputKey] = input.inputKey;
|
|
273
|
+
}
|
|
274
|
+
if ("candidateValue" in input) {
|
|
275
|
+
attrs[BROWSER_INTERACTION_ATTRIBUTES.candidateValue] = encodeCanonicalCandidateValue(input.candidateValue);
|
|
276
|
+
}
|
|
277
|
+
if (input.candidateState) {
|
|
278
|
+
attrs[BROWSER_INTERACTION_ATTRIBUTES.candidateState] = input.candidateState;
|
|
279
|
+
}
|
|
280
|
+
if (input.semanticEffects && input.semanticEffects.length > 0) {
|
|
281
|
+
attrs[BROWSER_INTERACTION_ATTRIBUTES.semanticEffects] = JSON.stringify(
|
|
282
|
+
input.semanticEffects.map(encodeBrowserInteractionEffect)
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
if (input.acceptedEffectPatterns && input.acceptedEffectPatterns.length > 0) {
|
|
286
|
+
attrs[BROWSER_INTERACTION_ATTRIBUTES.acceptedEffectPatterns] = JSON.stringify(
|
|
287
|
+
input.acceptedEffectPatterns.map(encodeBrowserInteractionEffectPattern)
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
if (input.preparationPatterns && input.preparationPatterns.length > 0) {
|
|
291
|
+
attrs[BROWSER_INTERACTION_ATTRIBUTES.preparationPatterns] = JSON.stringify(
|
|
292
|
+
input.preparationPatterns.map(encodeBrowserInteractionEffectPattern)
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
if (input.prepares) {
|
|
296
|
+
attrs[BROWSER_INTERACTION_ATTRIBUTES.preparesIntent] = input.prepares.intent;
|
|
297
|
+
if (input.prepares.inputKey) {
|
|
298
|
+
attrs[BROWSER_INTERACTION_ATTRIBUTES.preparesInputKey] = input.prepares.inputKey;
|
|
299
|
+
}
|
|
300
|
+
if (input.prepares.candidateValueKey) {
|
|
301
|
+
attrs[BROWSER_INTERACTION_ATTRIBUTES.preparesCandidateValue] = input.prepares.candidateValueKey;
|
|
302
|
+
} else if ("candidateValue" in input.prepares) {
|
|
303
|
+
attrs[BROWSER_INTERACTION_ATTRIBUTES.preparesCandidateValue] = encodeCanonicalCandidateValue(input.prepares.candidateValue);
|
|
304
|
+
}
|
|
305
|
+
if (input.prepares.actuatorKind) {
|
|
306
|
+
attrs[BROWSER_INTERACTION_ATTRIBUTES.preparesActuatorKind] = input.prepares.actuatorKind;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
return attrs;
|
|
310
|
+
}
|
|
311
|
+
function createGameplayInteractionRootAttributes(input) {
|
|
312
|
+
return createBrowserInteractionRootAttributes({
|
|
313
|
+
...input,
|
|
314
|
+
surface: GAMEPLAY_BROWSER_INTERACTION_SURFACE
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
function createGameplayActuatorAttributes(input) {
|
|
318
|
+
return createBrowserInteractionActuatorAttributes({
|
|
319
|
+
...input,
|
|
320
|
+
surface: GAMEPLAY_BROWSER_INTERACTION_SURFACE
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
function createBrowserInteractionActuatorKey(input) {
|
|
324
|
+
return [
|
|
325
|
+
input.surface,
|
|
326
|
+
input.scopeId,
|
|
327
|
+
input.interactionKey,
|
|
328
|
+
input.intent,
|
|
329
|
+
input.inputKey ?? "",
|
|
330
|
+
input.candidateValueKey ?? "",
|
|
331
|
+
input.actuatorKind
|
|
332
|
+
].map((part) => encodeURIComponent(part)).join("|");
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// src/browser-interaction/registry.ts
|
|
336
|
+
function defineBrowserInteractionSurface(definition) {
|
|
337
|
+
const seen = /* @__PURE__ */ new Set();
|
|
338
|
+
for (const intent of definition.intents) {
|
|
339
|
+
if (seen.has(intent)) {
|
|
340
|
+
throw new Error(
|
|
341
|
+
`Browser interaction surface '${definition.surface}' declares duplicate intent '${intent}'.`
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
seen.add(intent);
|
|
345
|
+
}
|
|
346
|
+
return definition;
|
|
347
|
+
}
|
|
348
|
+
var gameplayBrowserInteractionSurface = defineBrowserInteractionSurface({
|
|
349
|
+
surface: GAMEPLAY_BROWSER_INTERACTION_SURFACE,
|
|
350
|
+
intents: GAMEPLAY_BROWSER_INTERACTION_INTENTS,
|
|
351
|
+
effectKinds: GAMEPLAY_BROWSER_INTERACTION_EFFECT_KINDS
|
|
352
|
+
});
|
|
353
|
+
function createBrowserInteractionRegistry(definitions = [
|
|
354
|
+
gameplayBrowserInteractionSurface
|
|
355
|
+
]) {
|
|
356
|
+
const surfaces = /* @__PURE__ */ new Map();
|
|
357
|
+
for (const definition of definitions) {
|
|
358
|
+
const existing = surfaces.get(definition.surface);
|
|
359
|
+
if (existing) {
|
|
360
|
+
const existingIntents = existing.intents.join(",");
|
|
361
|
+
const nextIntents = definition.intents.join(",");
|
|
362
|
+
const existingEffectKinds = (existing.effectKinds ?? []).join(",");
|
|
363
|
+
const nextEffectKinds = (definition.effectKinds ?? []).join(",");
|
|
364
|
+
if (existingIntents !== nextIntents || existingEffectKinds !== nextEffectKinds) {
|
|
365
|
+
throw new Error(
|
|
366
|
+
`Browser interaction surface '${definition.surface}' is already registered with a different intent vocabulary or effect vocabulary.`
|
|
367
|
+
);
|
|
368
|
+
}
|
|
369
|
+
continue;
|
|
370
|
+
}
|
|
371
|
+
surfaces.set(definition.surface, definition);
|
|
372
|
+
}
|
|
373
|
+
return { surfaces };
|
|
374
|
+
}
|
|
375
|
+
var defaultBrowserInteractionRegistry = createBrowserInteractionRegistry();
|
|
376
|
+
|
|
377
|
+
// src/browser-interaction/normalize.ts
|
|
378
|
+
function normalizeBrowserInteractionRecords(records, options = {}) {
|
|
379
|
+
const registry = options.registry ?? defaultBrowserInteractionRegistry;
|
|
380
|
+
const diagnostics = [];
|
|
381
|
+
const surfaces = /* @__PURE__ */ new Map();
|
|
382
|
+
const getSurface = (surface, scopeId) => {
|
|
383
|
+
const registered = registry.surfaces.get(surface);
|
|
384
|
+
const key = `${surface}\0${scopeId}`;
|
|
385
|
+
const existing = surfaces.get(key);
|
|
386
|
+
if (existing) return existing;
|
|
387
|
+
if (!registered) {
|
|
388
|
+
const diagnostic = diagnosticFor({
|
|
389
|
+
code: "unknown-surface",
|
|
390
|
+
message: `Unknown browser interaction surface '${surface}'.`,
|
|
391
|
+
surface,
|
|
392
|
+
scopeId
|
|
393
|
+
});
|
|
394
|
+
diagnostics.push(diagnostic);
|
|
395
|
+
const pending2 = {
|
|
396
|
+
kind: "unknown",
|
|
397
|
+
surface,
|
|
398
|
+
scopeId,
|
|
399
|
+
diagnostics: [diagnostic]
|
|
400
|
+
};
|
|
401
|
+
surfaces.set(key, pending2);
|
|
402
|
+
return pending2;
|
|
403
|
+
}
|
|
404
|
+
const pending = {
|
|
405
|
+
kind: "semantic",
|
|
406
|
+
surface,
|
|
407
|
+
scopeId,
|
|
408
|
+
interactions: /* @__PURE__ */ new Map(),
|
|
409
|
+
diagnostics: []
|
|
410
|
+
};
|
|
411
|
+
surfaces.set(key, pending);
|
|
412
|
+
return pending;
|
|
413
|
+
};
|
|
414
|
+
for (const record of records) {
|
|
415
|
+
const attributes = record.attributes;
|
|
416
|
+
const protocol = text(attributes, BROWSER_INTERACTION_ATTRIBUTES.protocol);
|
|
417
|
+
const surface = text(attributes, BROWSER_INTERACTION_ATTRIBUTES.surface);
|
|
418
|
+
const scopeId = text(attributes, BROWSER_INTERACTION_ATTRIBUTES.scope);
|
|
419
|
+
const role = text(attributes, BROWSER_INTERACTION_ATTRIBUTES.role);
|
|
420
|
+
if (protocol !== DREAMBOARD_BROWSER_INTERACTION_PROTOCOL_VERSION) {
|
|
421
|
+
diagnostics.push(
|
|
422
|
+
diagnosticFor({
|
|
423
|
+
code: "invalid-protocol",
|
|
424
|
+
message: `Expected browser interaction protocol ${DREAMBOARD_BROWSER_INTERACTION_PROTOCOL_VERSION}.`,
|
|
425
|
+
surface,
|
|
426
|
+
scopeId
|
|
427
|
+
})
|
|
428
|
+
);
|
|
429
|
+
continue;
|
|
430
|
+
}
|
|
431
|
+
if (!surface || !scopeId || role !== "interaction" && role !== "actuator") {
|
|
432
|
+
diagnostics.push(
|
|
433
|
+
diagnosticFor({
|
|
434
|
+
code: "invalid-record",
|
|
435
|
+
message: "Browser interaction records require protocol, surface, scope and role.",
|
|
436
|
+
surface,
|
|
437
|
+
scopeId
|
|
438
|
+
})
|
|
439
|
+
);
|
|
440
|
+
continue;
|
|
441
|
+
}
|
|
442
|
+
const pendingSurface = getSurface(surface, scopeId);
|
|
443
|
+
if (!pendingSurface || pendingSurface.kind !== "semantic") {
|
|
444
|
+
continue;
|
|
445
|
+
}
|
|
446
|
+
const interactionKey = text(
|
|
447
|
+
attributes,
|
|
448
|
+
BROWSER_INTERACTION_ATTRIBUTES.interactionKey
|
|
449
|
+
);
|
|
450
|
+
const interactionId = text(
|
|
451
|
+
attributes,
|
|
452
|
+
BROWSER_INTERACTION_ATTRIBUTES.interactionId
|
|
453
|
+
);
|
|
454
|
+
if (!interactionKey || !interactionId) {
|
|
455
|
+
pushSurfaceDiagnostic(
|
|
456
|
+
pendingSurface,
|
|
457
|
+
diagnostics,
|
|
458
|
+
diagnosticFor({
|
|
459
|
+
code: "invalid-record",
|
|
460
|
+
message: "Browser interaction records require interaction key and id.",
|
|
461
|
+
surface,
|
|
462
|
+
scopeId
|
|
463
|
+
})
|
|
464
|
+
);
|
|
465
|
+
continue;
|
|
466
|
+
}
|
|
467
|
+
const interaction = getInteraction(
|
|
468
|
+
pendingSurface,
|
|
469
|
+
interactionKey,
|
|
470
|
+
interactionId
|
|
471
|
+
);
|
|
472
|
+
if (role === "interaction") {
|
|
473
|
+
interaction.rootSeen = true;
|
|
474
|
+
interaction.descriptorDigest = optionalText(
|
|
475
|
+
attributes,
|
|
476
|
+
BROWSER_INTERACTION_ATTRIBUTES.descriptorDigest
|
|
477
|
+
);
|
|
478
|
+
interaction.draftDigest = optionalText(
|
|
479
|
+
attributes,
|
|
480
|
+
BROWSER_INTERACTION_ATTRIBUTES.draftDigest
|
|
481
|
+
);
|
|
482
|
+
interaction.readiness = parseReadiness(
|
|
483
|
+
text(attributes, BROWSER_INTERACTION_ATTRIBUTES.readiness)
|
|
484
|
+
);
|
|
485
|
+
continue;
|
|
486
|
+
}
|
|
487
|
+
const actuator = parseGameplayActuator(attributes, {
|
|
488
|
+
surface,
|
|
489
|
+
scopeId,
|
|
490
|
+
interactionKey,
|
|
491
|
+
interactionId
|
|
492
|
+
});
|
|
493
|
+
if (actuator.diagnostics.length > 0) {
|
|
494
|
+
interaction.diagnostics.push(...actuator.diagnostics);
|
|
495
|
+
diagnostics.push(...actuator.diagnostics);
|
|
496
|
+
}
|
|
497
|
+
const registered = registry.surfaces.get(surface);
|
|
498
|
+
if (registered && !registered.intents.includes(actuator.intent)) {
|
|
499
|
+
const diagnostic = diagnosticFor({
|
|
500
|
+
code: "unknown-intent",
|
|
501
|
+
message: `Unknown browser interaction intent '${actuator.intent}' for surface '${surface}'.`,
|
|
502
|
+
surface,
|
|
503
|
+
scopeId,
|
|
504
|
+
interactionKey,
|
|
505
|
+
intent: actuator.intent,
|
|
506
|
+
actuatorId: actuator.actuatorId
|
|
507
|
+
});
|
|
508
|
+
interaction.diagnostics.push(diagnostic);
|
|
509
|
+
diagnostics.push(diagnostic);
|
|
510
|
+
}
|
|
511
|
+
if (registered?.effectKinds) {
|
|
512
|
+
for (const effect of actuator.semanticEffects) {
|
|
513
|
+
if (!registered.effectKinds.includes(effect.kind)) {
|
|
514
|
+
const diagnostic = diagnosticFor({
|
|
515
|
+
code: "unknown-surface-effect",
|
|
516
|
+
message: `Unknown browser interaction effect '${effect.kind}' for surface '${surface}'.`,
|
|
517
|
+
surface,
|
|
518
|
+
scopeId,
|
|
519
|
+
interactionKey,
|
|
520
|
+
intent: actuator.intent,
|
|
521
|
+
actuatorId: actuator.actuatorId
|
|
522
|
+
});
|
|
523
|
+
interaction.diagnostics.push(diagnostic);
|
|
524
|
+
diagnostics.push(diagnostic);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
for (const pattern of [
|
|
528
|
+
...actuator.acceptedEffectPatterns,
|
|
529
|
+
...actuator.preparationPatterns
|
|
530
|
+
]) {
|
|
531
|
+
const effectKind = pattern.kind === "exact" ? pattern.effect.kind : pattern.effectKind;
|
|
532
|
+
if (!registered.effectKinds.includes(effectKind)) {
|
|
533
|
+
const diagnostic = diagnosticFor({
|
|
534
|
+
code: "unknown-surface-effect",
|
|
535
|
+
message: `Unknown browser interaction effect '${effectKind}' for surface '${surface}'.`,
|
|
536
|
+
surface,
|
|
537
|
+
scopeId,
|
|
538
|
+
interactionKey,
|
|
539
|
+
intent: actuator.intent,
|
|
540
|
+
actuatorId: actuator.actuatorId
|
|
541
|
+
});
|
|
542
|
+
interaction.diagnostics.push(diagnostic);
|
|
543
|
+
diagnostics.push(diagnostic);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
interaction.actuators.push(actuator);
|
|
548
|
+
}
|
|
549
|
+
for (const surface of surfaces.values()) {
|
|
550
|
+
if (surface.kind !== "semantic") continue;
|
|
551
|
+
for (const interaction of surface.interactions.values()) {
|
|
552
|
+
if (interaction.rootSeen || interaction.actuators.length === 0) continue;
|
|
553
|
+
const diagnostic = diagnosticFor({
|
|
554
|
+
code: "orphan-actuator",
|
|
555
|
+
message: "Browser interaction actuators require a rendered semantic root.",
|
|
556
|
+
surface: surface.surface,
|
|
557
|
+
scopeId: surface.scopeId,
|
|
558
|
+
interactionKey: interaction.interactionKey
|
|
559
|
+
});
|
|
560
|
+
interaction.diagnostics.push(diagnostic);
|
|
561
|
+
diagnostics.push(diagnostic);
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
const snapshot = {
|
|
565
|
+
protocol: {
|
|
566
|
+
name: DREAMBOARD_BROWSER_INTERACTION_PROTOCOL_NAME,
|
|
567
|
+
version: DREAMBOARD_BROWSER_INTERACTION_PROTOCOL_VERSION
|
|
568
|
+
},
|
|
569
|
+
surfaces: [...surfaces.values()].map(finalizeSurface).sort(compareSurface),
|
|
570
|
+
diagnostics: []
|
|
571
|
+
};
|
|
572
|
+
const validationDiagnostics = validateBrowserInteractionSnapshot(snapshot);
|
|
573
|
+
return {
|
|
574
|
+
...snapshot,
|
|
575
|
+
diagnostics: [...diagnostics, ...validationDiagnostics].sort(
|
|
576
|
+
compareDiagnostic
|
|
577
|
+
)
|
|
578
|
+
};
|
|
579
|
+
}
|
|
580
|
+
function validateBrowserInteractionSnapshot(snapshot) {
|
|
581
|
+
const diagnostics = [];
|
|
582
|
+
for (const surface of snapshot.surfaces) {
|
|
583
|
+
if (!isSemanticSurfaceSnapshot(surface)) continue;
|
|
584
|
+
for (const interaction of surface.interactions) {
|
|
585
|
+
const enabledByKey = /* @__PURE__ */ new Map();
|
|
586
|
+
for (const actuator of interaction.actuators) {
|
|
587
|
+
if (!actuator.enabled) continue;
|
|
588
|
+
const key = actuatorIdentityKey({
|
|
589
|
+
surface: surface.surface,
|
|
590
|
+
scopeId: surface.scopeId,
|
|
591
|
+
interactionKey: interaction.interactionKey,
|
|
592
|
+
actuator
|
|
593
|
+
});
|
|
594
|
+
const group = enabledByKey.get(key) ?? [];
|
|
595
|
+
group.push(actuator);
|
|
596
|
+
enabledByKey.set(key, group);
|
|
597
|
+
}
|
|
598
|
+
for (const [key, actuators] of enabledByKey) {
|
|
599
|
+
if (actuators.length > 1) {
|
|
600
|
+
diagnostics.push(
|
|
601
|
+
diagnosticFor({
|
|
602
|
+
code: "duplicate-enabled-actuator",
|
|
603
|
+
message: `Duplicate enabled actuator for '${key}'.`,
|
|
604
|
+
surface: surface.surface,
|
|
605
|
+
scopeId: surface.scopeId,
|
|
606
|
+
interactionKey: interaction.interactionKey,
|
|
607
|
+
intent: actuators[0]?.intent,
|
|
608
|
+
actuatorId: actuators[0]?.actuatorId
|
|
609
|
+
})
|
|
610
|
+
);
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
diagnostics.push(
|
|
614
|
+
...diagnosticsForPreparationCycles(surface, interaction),
|
|
615
|
+
...diagnosticsForPreparationPatternAmbiguity(surface, interaction),
|
|
616
|
+
...diagnosticsForInvalidAcceptedPatterns(surface, interaction),
|
|
617
|
+
...diagnosticsForGameplayEffectCompatibility(surface, interaction)
|
|
618
|
+
);
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
return diagnostics.sort(compareDiagnostic);
|
|
622
|
+
}
|
|
623
|
+
function diagnosticsForInvalidAcceptedPatterns(surface, interaction) {
|
|
624
|
+
const diagnostics = [];
|
|
625
|
+
for (const actuator of interaction.actuators) {
|
|
626
|
+
for (const pattern of actuator.acceptedEffectPatterns) {
|
|
627
|
+
if (pattern.kind === "match" && Object.keys(pattern.fields ?? {}).length === 0 && pattern.scalar === void 0) {
|
|
628
|
+
diagnostics.push(
|
|
629
|
+
diagnosticFor({
|
|
630
|
+
code: "invalid-effect-pattern",
|
|
631
|
+
message: "Accepted-effect match patterns must be bounded by fields or scalar constraints.",
|
|
632
|
+
surface: surface.surface,
|
|
633
|
+
scopeId: surface.scopeId,
|
|
634
|
+
interactionKey: interaction.interactionKey,
|
|
635
|
+
intent: actuator.intent,
|
|
636
|
+
actuatorId: actuator.actuatorId
|
|
637
|
+
})
|
|
638
|
+
);
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
return diagnostics;
|
|
643
|
+
}
|
|
644
|
+
function diagnosticsForGameplayEffectCompatibility(surface, interaction) {
|
|
645
|
+
if (surface.surface !== GAMEPLAY_BROWSER_INTERACTION_SURFACE) return [];
|
|
646
|
+
const diagnostics = [];
|
|
647
|
+
for (const actuator of interaction.actuators) {
|
|
648
|
+
for (const effect of actuator.semanticEffects) {
|
|
649
|
+
if (!gameplayIntentCanPerformEffect(actuator.intent, effect.kind)) {
|
|
650
|
+
diagnostics.push(
|
|
651
|
+
diagnosticFor({
|
|
652
|
+
code: "effect-intent-incompatibility",
|
|
653
|
+
message: "Gameplay browser interaction intent is incompatible with its semantic effect.",
|
|
654
|
+
surface: surface.surface,
|
|
655
|
+
scopeId: surface.scopeId,
|
|
656
|
+
interactionKey: interaction.interactionKey,
|
|
657
|
+
intent: actuator.intent,
|
|
658
|
+
actuatorId: actuator.actuatorId
|
|
659
|
+
})
|
|
660
|
+
);
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
return diagnostics;
|
|
665
|
+
}
|
|
666
|
+
function gameplayIntentCanPerformEffect(intent, effectKind) {
|
|
667
|
+
switch (effectKind) {
|
|
668
|
+
case "setCandidate":
|
|
669
|
+
return intent === "select" || intent === "toggle";
|
|
670
|
+
case "adjustResource":
|
|
671
|
+
return intent === "increment" || intent === "decrement";
|
|
672
|
+
case "setScalar":
|
|
673
|
+
return intent === "fill" || intent === "increment" || intent === "decrement";
|
|
674
|
+
case "commit":
|
|
675
|
+
return intent === "submit" || intent === "invoke";
|
|
676
|
+
case "invoke":
|
|
677
|
+
return intent === "invoke" || intent === "select" || intent === "toggle";
|
|
678
|
+
default:
|
|
679
|
+
return true;
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
function parseGameplayActuator(attributes, context) {
|
|
683
|
+
const diagnostics = [];
|
|
684
|
+
const intent = text(attributes, BROWSER_INTERACTION_ATTRIBUTES.intent);
|
|
685
|
+
const actuatorKind = parseActuatorKind(
|
|
686
|
+
text(attributes, BROWSER_INTERACTION_ATTRIBUTES.actuatorKind)
|
|
687
|
+
);
|
|
688
|
+
const inputKey = optionalText(
|
|
689
|
+
attributes,
|
|
690
|
+
BROWSER_INTERACTION_ATTRIBUTES.inputKey
|
|
691
|
+
);
|
|
692
|
+
const candidate = parseCandidate(
|
|
693
|
+
attributes,
|
|
694
|
+
BROWSER_INTERACTION_ATTRIBUTES.candidateValue,
|
|
695
|
+
context,
|
|
696
|
+
intent,
|
|
697
|
+
diagnostics
|
|
698
|
+
);
|
|
699
|
+
const candidateState = parseCandidateState(
|
|
700
|
+
optionalText(attributes, BROWSER_INTERACTION_ATTRIBUTES.candidateState)
|
|
701
|
+
);
|
|
702
|
+
const explicitId = optionalText(
|
|
703
|
+
attributes,
|
|
704
|
+
BROWSER_INTERACTION_ATTRIBUTES.actuatorId
|
|
705
|
+
);
|
|
706
|
+
const enabled = parseEnabled(
|
|
707
|
+
attributes[BROWSER_INTERACTION_ATTRIBUTES.enabled]
|
|
708
|
+
);
|
|
709
|
+
const actuatorId = explicitId ?? createBrowserInteractionActuatorKey({
|
|
710
|
+
surface: context.surface,
|
|
711
|
+
scopeId: context.scopeId,
|
|
712
|
+
interactionKey: context.interactionKey,
|
|
713
|
+
intent,
|
|
714
|
+
inputKey,
|
|
715
|
+
candidateValueKey: candidate?.candidateValueKey,
|
|
716
|
+
actuatorKind
|
|
717
|
+
});
|
|
718
|
+
const preparesIntent = optionalText(
|
|
719
|
+
attributes,
|
|
720
|
+
BROWSER_INTERACTION_ATTRIBUTES.preparesIntent
|
|
721
|
+
);
|
|
722
|
+
const preparesCandidate = parseCandidate(
|
|
723
|
+
attributes,
|
|
724
|
+
BROWSER_INTERACTION_ATTRIBUTES.preparesCandidateValue,
|
|
725
|
+
context,
|
|
726
|
+
preparesIntent ?? intent,
|
|
727
|
+
diagnostics
|
|
728
|
+
);
|
|
729
|
+
const prepares = preparesIntent === void 0 ? void 0 : {
|
|
730
|
+
intent: preparesIntent,
|
|
731
|
+
inputKey: optionalText(
|
|
732
|
+
attributes,
|
|
733
|
+
BROWSER_INTERACTION_ATTRIBUTES.preparesInputKey
|
|
734
|
+
),
|
|
735
|
+
candidateValue: preparesCandidate?.candidateValue,
|
|
736
|
+
candidateValueKey: preparesCandidate?.candidateValueKey,
|
|
737
|
+
actuatorKind: parseOptionalActuatorKind(
|
|
738
|
+
optionalText(
|
|
739
|
+
attributes,
|
|
740
|
+
BROWSER_INTERACTION_ATTRIBUTES.preparesActuatorKind
|
|
741
|
+
)
|
|
742
|
+
)
|
|
743
|
+
};
|
|
744
|
+
const semanticEffects = parseEffectList(
|
|
745
|
+
attributes,
|
|
746
|
+
BROWSER_INTERACTION_ATTRIBUTES.semanticEffects,
|
|
747
|
+
context,
|
|
748
|
+
intent,
|
|
749
|
+
diagnostics
|
|
750
|
+
);
|
|
751
|
+
const acceptedEffectPatterns = parseEffectPatternList(
|
|
752
|
+
attributes,
|
|
753
|
+
BROWSER_INTERACTION_ATTRIBUTES.acceptedEffectPatterns,
|
|
754
|
+
context,
|
|
755
|
+
intent,
|
|
756
|
+
diagnostics
|
|
757
|
+
);
|
|
758
|
+
const preparationPatterns = parseEffectPatternList(
|
|
759
|
+
attributes,
|
|
760
|
+
BROWSER_INTERACTION_ATTRIBUTES.preparationPatterns,
|
|
761
|
+
context,
|
|
762
|
+
intent,
|
|
763
|
+
diagnostics
|
|
764
|
+
);
|
|
765
|
+
if (!intent) {
|
|
766
|
+
diagnostics.push(
|
|
767
|
+
diagnosticFor({
|
|
768
|
+
code: "invalid-record",
|
|
769
|
+
message: "Browser interaction actuator records require an intent.",
|
|
770
|
+
...context
|
|
771
|
+
})
|
|
772
|
+
);
|
|
773
|
+
}
|
|
774
|
+
return {
|
|
775
|
+
actuatorId,
|
|
776
|
+
intent,
|
|
777
|
+
descriptorDigest: optionalText(
|
|
778
|
+
attributes,
|
|
779
|
+
BROWSER_INTERACTION_ATTRIBUTES.descriptorDigest
|
|
780
|
+
),
|
|
781
|
+
draftDigest: optionalText(
|
|
782
|
+
attributes,
|
|
783
|
+
BROWSER_INTERACTION_ATTRIBUTES.draftDigest
|
|
784
|
+
),
|
|
785
|
+
inputKey,
|
|
786
|
+
candidateValue: candidate?.candidateValue,
|
|
787
|
+
candidateValueKey: candidate?.candidateValueKey,
|
|
788
|
+
candidateState,
|
|
789
|
+
enabled,
|
|
790
|
+
actuatorKind,
|
|
791
|
+
semanticEffects,
|
|
792
|
+
acceptedEffectPatterns,
|
|
793
|
+
preparationPatterns,
|
|
794
|
+
prepares,
|
|
795
|
+
diagnostics: diagnostics.sort(compareDiagnostic)
|
|
796
|
+
};
|
|
797
|
+
}
|
|
798
|
+
function parseEffectList(attributes, attribute, context, intent, diagnostics) {
|
|
799
|
+
const encodedList = optionalText(attributes, attribute);
|
|
800
|
+
if (encodedList === void 0) return [];
|
|
801
|
+
try {
|
|
802
|
+
const raw = JSON.parse(encodedList);
|
|
803
|
+
if (!Array.isArray(raw) || raw.some((item) => typeof item !== "string")) {
|
|
804
|
+
throw new Error("Expected encoded effect array.");
|
|
805
|
+
}
|
|
806
|
+
return raw.map((encoded) => decodeBrowserInteractionEffect(encoded)).sort(
|
|
807
|
+
(a, b) => encodeBrowserInteractionEffect(a).localeCompare(
|
|
808
|
+
encodeBrowserInteractionEffect(b)
|
|
809
|
+
)
|
|
810
|
+
);
|
|
811
|
+
} catch {
|
|
812
|
+
diagnostics.push(
|
|
813
|
+
diagnosticFor({
|
|
814
|
+
code: "invalid-effect-payload",
|
|
815
|
+
message: "Invalid browser interaction semantic effect payload.",
|
|
816
|
+
...context,
|
|
817
|
+
intent
|
|
818
|
+
})
|
|
819
|
+
);
|
|
820
|
+
return [];
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
function parseEffectPatternList(attributes, attribute, context, intent, diagnostics) {
|
|
824
|
+
const encodedList = optionalText(attributes, attribute);
|
|
825
|
+
if (encodedList === void 0) return [];
|
|
826
|
+
try {
|
|
827
|
+
const raw = JSON.parse(encodedList);
|
|
828
|
+
if (!Array.isArray(raw) || raw.some((item) => typeof item !== "string")) {
|
|
829
|
+
throw new Error("Expected encoded effect pattern array.");
|
|
830
|
+
}
|
|
831
|
+
return raw.map((encoded) => decodeBrowserInteractionEffectPattern(encoded)).sort(
|
|
832
|
+
(a, b) => encodeBrowserInteractionEffectPattern(a).localeCompare(
|
|
833
|
+
encodeBrowserInteractionEffectPattern(b)
|
|
834
|
+
)
|
|
835
|
+
);
|
|
836
|
+
} catch {
|
|
837
|
+
diagnostics.push(
|
|
838
|
+
diagnosticFor({
|
|
839
|
+
code: "invalid-effect-pattern",
|
|
840
|
+
message: "Invalid browser interaction semantic effect pattern.",
|
|
841
|
+
...context,
|
|
842
|
+
intent
|
|
843
|
+
})
|
|
844
|
+
);
|
|
845
|
+
return [];
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
function parseCandidate(attributes, attribute, context, intent, diagnostics) {
|
|
849
|
+
const encoded = optionalText(attributes, attribute);
|
|
850
|
+
if (encoded === void 0) return void 0;
|
|
851
|
+
try {
|
|
852
|
+
const candidateValue = decodeCanonicalCandidateValue(encoded);
|
|
853
|
+
return {
|
|
854
|
+
candidateValue,
|
|
855
|
+
candidateValueKey: encodeCanonicalCandidateValue(candidateValue)
|
|
856
|
+
};
|
|
857
|
+
} catch {
|
|
858
|
+
diagnostics.push(
|
|
859
|
+
diagnosticFor({
|
|
860
|
+
code: "invalid-candidate",
|
|
861
|
+
message: `Invalid canonical browser interaction candidate '${encoded}'.`,
|
|
862
|
+
...context,
|
|
863
|
+
intent
|
|
864
|
+
})
|
|
865
|
+
);
|
|
866
|
+
return void 0;
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
function getInteraction(surface, interactionKey, interactionId) {
|
|
870
|
+
const existing = surface.interactions.get(interactionKey);
|
|
871
|
+
if (existing) return existing;
|
|
872
|
+
const next = {
|
|
873
|
+
interactionKey,
|
|
874
|
+
interactionId,
|
|
875
|
+
readiness: "ready",
|
|
876
|
+
rootSeen: false,
|
|
877
|
+
actuators: [],
|
|
878
|
+
diagnostics: []
|
|
879
|
+
};
|
|
880
|
+
surface.interactions.set(interactionKey, next);
|
|
881
|
+
return next;
|
|
882
|
+
}
|
|
883
|
+
function finalizeSurface(surface) {
|
|
884
|
+
if (surface.kind !== "semantic") {
|
|
885
|
+
return {
|
|
886
|
+
surface: surface.surface,
|
|
887
|
+
scopeId: surface.scopeId,
|
|
888
|
+
diagnostics: surface.diagnostics.sort(compareDiagnostic)
|
|
889
|
+
};
|
|
890
|
+
}
|
|
891
|
+
const interactions = [
|
|
892
|
+
...surface.interactions.values()
|
|
893
|
+
].map((interaction) => ({
|
|
894
|
+
interactionKey: interaction.interactionKey,
|
|
895
|
+
interactionId: interaction.interactionId,
|
|
896
|
+
descriptorDigest: interaction.descriptorDigest,
|
|
897
|
+
draftDigest: interaction.draftDigest,
|
|
898
|
+
readiness: interaction.readiness,
|
|
899
|
+
actuators: interaction.actuators.sort(compareActuator),
|
|
900
|
+
diagnostics: interaction.diagnostics.sort(compareDiagnostic)
|
|
901
|
+
})).sort((a, b) => a.interactionKey.localeCompare(b.interactionKey));
|
|
902
|
+
return {
|
|
903
|
+
surface: surface.surface,
|
|
904
|
+
scopeId: surface.scopeId,
|
|
905
|
+
interactions,
|
|
906
|
+
diagnostics: surface.diagnostics.sort(compareDiagnostic)
|
|
907
|
+
};
|
|
908
|
+
}
|
|
909
|
+
function diagnosticsForPreparationCycles(surface, interaction) {
|
|
910
|
+
const diagnostics = [];
|
|
911
|
+
diagnostics.push(
|
|
912
|
+
...diagnosticsForEffectPreparationCycles(surface, interaction)
|
|
913
|
+
);
|
|
914
|
+
const actuators = /* @__PURE__ */ new Map();
|
|
915
|
+
for (const actuator of interaction.actuators) {
|
|
916
|
+
actuators.set(
|
|
917
|
+
actuatorIdentityKey({
|
|
918
|
+
surface: surface.surface,
|
|
919
|
+
scopeId: surface.scopeId,
|
|
920
|
+
interactionKey: interaction.interactionKey,
|
|
921
|
+
actuator
|
|
922
|
+
}),
|
|
923
|
+
actuator
|
|
924
|
+
);
|
|
925
|
+
}
|
|
926
|
+
for (const actuator of interaction.actuators) {
|
|
927
|
+
const visited = /* @__PURE__ */ new Set();
|
|
928
|
+
let current = actuator;
|
|
929
|
+
while (current?.prepares) {
|
|
930
|
+
const key = actuatorIdentityKey({
|
|
931
|
+
surface: surface.surface,
|
|
932
|
+
scopeId: surface.scopeId,
|
|
933
|
+
interactionKey: interaction.interactionKey,
|
|
934
|
+
actuator: current
|
|
935
|
+
});
|
|
936
|
+
if (visited.has(key)) {
|
|
937
|
+
diagnostics.push(
|
|
938
|
+
diagnosticFor({
|
|
939
|
+
code: "preparation-cycle",
|
|
940
|
+
message: `Preparation cycle detected for actuator '${current.actuatorId}'.`,
|
|
941
|
+
surface: surface.surface,
|
|
942
|
+
scopeId: surface.scopeId,
|
|
943
|
+
interactionKey: interaction.interactionKey,
|
|
944
|
+
intent: current.intent,
|
|
945
|
+
actuatorId: current.actuatorId
|
|
946
|
+
})
|
|
947
|
+
);
|
|
948
|
+
break;
|
|
949
|
+
}
|
|
950
|
+
visited.add(key);
|
|
951
|
+
current = actuators.get(
|
|
952
|
+
targetIdentityKey({
|
|
953
|
+
surface: surface.surface,
|
|
954
|
+
scopeId: surface.scopeId,
|
|
955
|
+
interactionKey: interaction.interactionKey,
|
|
956
|
+
target: current.prepares
|
|
957
|
+
})
|
|
958
|
+
);
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
return diagnostics;
|
|
962
|
+
}
|
|
963
|
+
function diagnosticsForEffectPreparationCycles(surface, interaction) {
|
|
964
|
+
const diagnostics = [];
|
|
965
|
+
const actuatorKeys = /* @__PURE__ */ new Map();
|
|
966
|
+
interaction.actuators.forEach((actuator, index) => {
|
|
967
|
+
actuatorKeys.set(actuator, `${actuator.actuatorId}\0${index}`);
|
|
968
|
+
});
|
|
969
|
+
for (const actuator of interaction.actuators) {
|
|
970
|
+
const visited = /* @__PURE__ */ new Set();
|
|
971
|
+
let current = actuator;
|
|
972
|
+
while (current) {
|
|
973
|
+
const key = actuatorKeys.get(current);
|
|
974
|
+
if (!key) break;
|
|
975
|
+
if (visited.has(key)) {
|
|
976
|
+
diagnostics.push(
|
|
977
|
+
diagnosticFor({
|
|
978
|
+
code: "preparation-cycle",
|
|
979
|
+
message: `Semantic preparation cycle detected for actuator '${current.actuatorId}'.`,
|
|
980
|
+
surface: surface.surface,
|
|
981
|
+
scopeId: surface.scopeId,
|
|
982
|
+
interactionKey: interaction.interactionKey,
|
|
983
|
+
intent: current.intent,
|
|
984
|
+
actuatorId: current.actuatorId
|
|
985
|
+
})
|
|
986
|
+
);
|
|
987
|
+
break;
|
|
988
|
+
}
|
|
989
|
+
visited.add(key);
|
|
990
|
+
current = interaction.actuators.find(
|
|
991
|
+
(candidate) => current?.preparationPatterns.some(
|
|
992
|
+
(pattern) => candidate.semanticEffects.some(
|
|
993
|
+
(effect) => browserInteractionEffectPatternMatches(pattern, effect)
|
|
994
|
+
)
|
|
995
|
+
)
|
|
996
|
+
);
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
return diagnostics;
|
|
1000
|
+
}
|
|
1001
|
+
function diagnosticsForPreparationPatternAmbiguity(surface, interaction) {
|
|
1002
|
+
const diagnostics = [];
|
|
1003
|
+
for (const target of interaction.actuators) {
|
|
1004
|
+
for (const effect of target.semanticEffects) {
|
|
1005
|
+
const matches = interaction.actuators.filter(
|
|
1006
|
+
(actuator) => actuator.preparationPatterns.some(
|
|
1007
|
+
(pattern) => browserInteractionEffectPatternMatches(pattern, effect)
|
|
1008
|
+
)
|
|
1009
|
+
);
|
|
1010
|
+
const uniqueActuatorIds = new Set(
|
|
1011
|
+
matches.map((match) => match.actuatorId)
|
|
1012
|
+
);
|
|
1013
|
+
if (uniqueActuatorIds.size > 1) {
|
|
1014
|
+
diagnostics.push(
|
|
1015
|
+
diagnosticFor({
|
|
1016
|
+
code: "ambiguous-preparation-pattern",
|
|
1017
|
+
message: "Multiple preparation patterns can prepare the same semantic effect.",
|
|
1018
|
+
surface: surface.surface,
|
|
1019
|
+
scopeId: surface.scopeId,
|
|
1020
|
+
interactionKey: interaction.interactionKey,
|
|
1021
|
+
intent: target.intent,
|
|
1022
|
+
actuatorId: target.actuatorId
|
|
1023
|
+
})
|
|
1024
|
+
);
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
return diagnostics;
|
|
1029
|
+
}
|
|
1030
|
+
function actuatorIdentityKey(input) {
|
|
1031
|
+
return createBrowserInteractionActuatorKey({
|
|
1032
|
+
surface: input.surface,
|
|
1033
|
+
scopeId: input.scopeId,
|
|
1034
|
+
interactionKey: input.interactionKey,
|
|
1035
|
+
intent: input.actuator.intent,
|
|
1036
|
+
inputKey: input.actuator.inputKey,
|
|
1037
|
+
candidateValueKey: input.actuator.candidateValueKey,
|
|
1038
|
+
actuatorKind: input.actuator.actuatorKind
|
|
1039
|
+
});
|
|
1040
|
+
}
|
|
1041
|
+
function isSemanticSurfaceSnapshot(surface) {
|
|
1042
|
+
return "interactions" in surface;
|
|
1043
|
+
}
|
|
1044
|
+
function targetIdentityKey(input) {
|
|
1045
|
+
return createBrowserInteractionActuatorKey({
|
|
1046
|
+
surface: input.surface,
|
|
1047
|
+
scopeId: input.scopeId,
|
|
1048
|
+
interactionKey: input.interactionKey,
|
|
1049
|
+
intent: input.target.intent,
|
|
1050
|
+
inputKey: input.target.inputKey,
|
|
1051
|
+
candidateValueKey: input.target.candidateValueKey,
|
|
1052
|
+
actuatorKind: input.target.actuatorKind ?? "click"
|
|
1053
|
+
});
|
|
1054
|
+
}
|
|
1055
|
+
function pushSurfaceDiagnostic(surface, all, diagnostic) {
|
|
1056
|
+
surface.diagnostics.push(diagnostic);
|
|
1057
|
+
all.push(diagnostic);
|
|
1058
|
+
}
|
|
1059
|
+
function diagnosticFor(input) {
|
|
1060
|
+
return { severity: "error", ...input };
|
|
1061
|
+
}
|
|
1062
|
+
function text(attributes, key) {
|
|
1063
|
+
const value = attributes[key];
|
|
1064
|
+
if (typeof value === "boolean") return value ? "true" : "false";
|
|
1065
|
+
return value ?? "";
|
|
1066
|
+
}
|
|
1067
|
+
function optionalText(attributes, key) {
|
|
1068
|
+
const value = text(attributes, key);
|
|
1069
|
+
return value === "" ? void 0 : value;
|
|
1070
|
+
}
|
|
1071
|
+
function parseReadiness(value) {
|
|
1072
|
+
return BROWSER_INTERACTION_READINESS_VALUES.includes(
|
|
1073
|
+
value
|
|
1074
|
+
) ? value : "blocked";
|
|
1075
|
+
}
|
|
1076
|
+
function parseCandidateState(value) {
|
|
1077
|
+
return BROWSER_INTERACTION_CANDIDATE_STATES.includes(
|
|
1078
|
+
value
|
|
1079
|
+
) ? value : void 0;
|
|
1080
|
+
}
|
|
1081
|
+
function parseActuatorKind(value) {
|
|
1082
|
+
return parseOptionalActuatorKind(value) ?? "click";
|
|
1083
|
+
}
|
|
1084
|
+
function parseOptionalActuatorKind(value) {
|
|
1085
|
+
return BROWSER_INTERACTION_ACTUATOR_KINDS.includes(
|
|
1086
|
+
value
|
|
1087
|
+
) ? value : void 0;
|
|
1088
|
+
}
|
|
1089
|
+
function parseEnabled(value) {
|
|
1090
|
+
if (value === false || value === "false") return false;
|
|
1091
|
+
return true;
|
|
1092
|
+
}
|
|
1093
|
+
function compareSurface(a, b) {
|
|
1094
|
+
return a.surface.localeCompare(b.surface) || a.scopeId.localeCompare(b.scopeId);
|
|
1095
|
+
}
|
|
1096
|
+
function compareActuator(a, b) {
|
|
1097
|
+
return a.actuatorId.localeCompare(b.actuatorId);
|
|
1098
|
+
}
|
|
1099
|
+
function compareDiagnostic(a, b) {
|
|
1100
|
+
return a.code.localeCompare(b.code) || (a.surface ?? "").localeCompare(b.surface ?? "") || (a.scopeId ?? "").localeCompare(b.scopeId ?? "") || (a.interactionKey ?? "").localeCompare(b.interactionKey ?? "") || (a.intent ?? "").localeCompare(b.intent ?? "") || (a.actuatorId ?? "").localeCompare(b.actuatorId ?? "") || a.message.localeCompare(b.message);
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
// src/browser-interaction/resolve.ts
|
|
1104
|
+
function resolveBrowserInteractionIntent(snapshot, request) {
|
|
1105
|
+
const snapshotDiagnostics = [
|
|
1106
|
+
...snapshot.diagnostics,
|
|
1107
|
+
...validateBrowserInteractionSnapshot(snapshot)
|
|
1108
|
+
];
|
|
1109
|
+
if (snapshotDiagnostics.some((diagnostic) => diagnostic.severity === "error")) {
|
|
1110
|
+
return {
|
|
1111
|
+
ok: false,
|
|
1112
|
+
code: "invalid-snapshot",
|
|
1113
|
+
diagnostics: snapshotDiagnostics
|
|
1114
|
+
};
|
|
1115
|
+
}
|
|
1116
|
+
const candidateValueKey = request.candidateValueKey ?? ("candidateValue" in request ? encodeCanonicalCandidateValue(request.candidateValue) : void 0);
|
|
1117
|
+
const surfaces = snapshot.surfaces.filter(
|
|
1118
|
+
(surface) => isSemanticSurfaceSnapshot(surface) && surface.surface === request.surface && (request.scopeId === void 0 || surface.scopeId === request.scopeId)
|
|
1119
|
+
);
|
|
1120
|
+
const matches = surfaces.flatMap(
|
|
1121
|
+
(surface) => surface.interactions.flatMap((interaction) => {
|
|
1122
|
+
if (request.interactionKey !== void 0 && interaction.interactionKey !== request.interactionKey) {
|
|
1123
|
+
return [];
|
|
1124
|
+
}
|
|
1125
|
+
if (request.interactionId !== void 0 && interaction.interactionId !== request.interactionId) {
|
|
1126
|
+
return [];
|
|
1127
|
+
}
|
|
1128
|
+
return interaction.actuators.filter(
|
|
1129
|
+
(actuator) => actuatorMatchesRequest(actuator, request, candidateValueKey)
|
|
1130
|
+
).map((actuator) => ({ surface, interaction, actuator }));
|
|
1131
|
+
})
|
|
1132
|
+
);
|
|
1133
|
+
const enabledMatches = matches.filter((match) => match.actuator.enabled);
|
|
1134
|
+
const actionable = request.allowDisabled === true ? matches : enabledMatches;
|
|
1135
|
+
if (actionable.length === 1) {
|
|
1136
|
+
const match = actionable[0];
|
|
1137
|
+
if (!match) throw new Error("unreachable browser interaction match");
|
|
1138
|
+
return {
|
|
1139
|
+
ok: true,
|
|
1140
|
+
actuator: match.actuator,
|
|
1141
|
+
surface: match.surface.surface,
|
|
1142
|
+
scopeId: match.surface.scopeId,
|
|
1143
|
+
interactionKey: match.interaction.interactionKey,
|
|
1144
|
+
diagnostics: []
|
|
1145
|
+
};
|
|
1146
|
+
}
|
|
1147
|
+
if (actionable.length > 1) {
|
|
1148
|
+
return {
|
|
1149
|
+
ok: false,
|
|
1150
|
+
code: "ambiguous",
|
|
1151
|
+
diagnostics: actionable.map(
|
|
1152
|
+
(match) => diagnosticFor2({
|
|
1153
|
+
code: "ambiguous-actuator",
|
|
1154
|
+
message: "Browser interaction intent resolved to multiple actuators.",
|
|
1155
|
+
surface: match.surface.surface,
|
|
1156
|
+
scopeId: match.surface.scopeId,
|
|
1157
|
+
interactionKey: match.interaction.interactionKey,
|
|
1158
|
+
intent: match.actuator.intent,
|
|
1159
|
+
actuatorId: match.actuator.actuatorId
|
|
1160
|
+
})
|
|
1161
|
+
)
|
|
1162
|
+
};
|
|
1163
|
+
}
|
|
1164
|
+
const preparation = findPreparationChain(
|
|
1165
|
+
surfaces,
|
|
1166
|
+
request,
|
|
1167
|
+
candidateValueKey
|
|
1168
|
+
);
|
|
1169
|
+
if (preparation.length > 0) {
|
|
1170
|
+
return {
|
|
1171
|
+
ok: false,
|
|
1172
|
+
code: "preparation-required",
|
|
1173
|
+
diagnostics: [
|
|
1174
|
+
diagnosticFor2({
|
|
1175
|
+
code: "unavailable-actuator",
|
|
1176
|
+
message: "Requested browser interaction intent requires preparation before its actuator is available.",
|
|
1177
|
+
surface: request.surface,
|
|
1178
|
+
scopeId: request.scopeId,
|
|
1179
|
+
interactionKey: request.interactionKey,
|
|
1180
|
+
intent: request.intent
|
|
1181
|
+
})
|
|
1182
|
+
],
|
|
1183
|
+
preparation
|
|
1184
|
+
};
|
|
1185
|
+
}
|
|
1186
|
+
return {
|
|
1187
|
+
ok: false,
|
|
1188
|
+
code: matches.length > 0 ? "unavailable" : "not-found",
|
|
1189
|
+
diagnostics: [
|
|
1190
|
+
diagnosticFor2({
|
|
1191
|
+
code: "unavailable-actuator",
|
|
1192
|
+
message: matches.length > 0 ? "Browser interaction intent exists but has no enabled actuator." : "Browser interaction intent is not present in the current snapshot.",
|
|
1193
|
+
surface: request.surface,
|
|
1194
|
+
scopeId: request.scopeId,
|
|
1195
|
+
interactionKey: request.interactionKey,
|
|
1196
|
+
intent: request.intent
|
|
1197
|
+
})
|
|
1198
|
+
]
|
|
1199
|
+
};
|
|
1200
|
+
}
|
|
1201
|
+
function resolveBrowserInteractionEffect(snapshot, request) {
|
|
1202
|
+
const snapshotDiagnostics = [
|
|
1203
|
+
...snapshot.diagnostics,
|
|
1204
|
+
...validateBrowserInteractionSnapshot(snapshot)
|
|
1205
|
+
];
|
|
1206
|
+
if (snapshotDiagnostics.some((diagnostic) => diagnostic.severity === "error")) {
|
|
1207
|
+
return {
|
|
1208
|
+
ok: false,
|
|
1209
|
+
code: "invalid-snapshot",
|
|
1210
|
+
diagnostics: snapshotDiagnostics
|
|
1211
|
+
};
|
|
1212
|
+
}
|
|
1213
|
+
const effectDiagnostics = validateEffectRequest(request.effect, request);
|
|
1214
|
+
if (effectDiagnostics.length > 0) {
|
|
1215
|
+
return {
|
|
1216
|
+
ok: false,
|
|
1217
|
+
code: "invalid-effect",
|
|
1218
|
+
diagnostics: effectDiagnostics
|
|
1219
|
+
};
|
|
1220
|
+
}
|
|
1221
|
+
const surfaces = matchingSurfaces(snapshot, request);
|
|
1222
|
+
const matches = collectInteractionMatches(surfaces, request);
|
|
1223
|
+
const exactMatches = matches.filter(
|
|
1224
|
+
(match) => match.actuator.semanticEffects.some(
|
|
1225
|
+
(effect) => encodeBrowserInteractionEffect(effect) === encodeBrowserInteractionEffect(request.effect)
|
|
1226
|
+
)
|
|
1227
|
+
);
|
|
1228
|
+
const enabledExactMatches = exactMatches.filter(
|
|
1229
|
+
(match) => match.actuator.enabled
|
|
1230
|
+
);
|
|
1231
|
+
const actionableExactMatches = request.allowDisabled === true ? exactMatches : enabledExactMatches;
|
|
1232
|
+
if (actionableExactMatches.length === 1) {
|
|
1233
|
+
const match = actionableExactMatches[0];
|
|
1234
|
+
if (!match) throw new Error("unreachable browser effect match");
|
|
1235
|
+
return effectSuccess(match, request.effect, "exact");
|
|
1236
|
+
}
|
|
1237
|
+
if (actionableExactMatches.length > 1) {
|
|
1238
|
+
return effectAmbiguous(
|
|
1239
|
+
actionableExactMatches,
|
|
1240
|
+
"duplicate-enabled-effect-actuator",
|
|
1241
|
+
"Browser interaction effect resolved to multiple exact actuators."
|
|
1242
|
+
);
|
|
1243
|
+
}
|
|
1244
|
+
if (exactMatches.length > 0 && enabledExactMatches.length === 0) {
|
|
1245
|
+
return effectUnavailable(
|
|
1246
|
+
request,
|
|
1247
|
+
"disabled-effect-actuator",
|
|
1248
|
+
"Browser interaction effect exists but has no enabled actuator."
|
|
1249
|
+
);
|
|
1250
|
+
}
|
|
1251
|
+
const acceptedMatches = matches.filter(
|
|
1252
|
+
(match) => match.actuator.acceptedEffectPatterns.some(
|
|
1253
|
+
(pattern) => browserInteractionEffectPatternMatches(pattern, request.effect)
|
|
1254
|
+
)
|
|
1255
|
+
);
|
|
1256
|
+
const enabledAcceptedMatches = acceptedMatches.filter(
|
|
1257
|
+
(match) => match.actuator.enabled
|
|
1258
|
+
);
|
|
1259
|
+
const actionableAcceptedMatches = request.allowDisabled === true ? acceptedMatches : enabledAcceptedMatches;
|
|
1260
|
+
if (actionableAcceptedMatches.length === 1) {
|
|
1261
|
+
const match = actionableAcceptedMatches[0];
|
|
1262
|
+
if (!match) throw new Error("unreachable browser accepted effect match");
|
|
1263
|
+
return effectSuccess(match, request.effect, "accepted-pattern");
|
|
1264
|
+
}
|
|
1265
|
+
if (actionableAcceptedMatches.length > 1) {
|
|
1266
|
+
return effectAmbiguous(
|
|
1267
|
+
actionableAcceptedMatches,
|
|
1268
|
+
"duplicate-accepted-effect-pattern-match",
|
|
1269
|
+
"Browser interaction effect matched multiple accepted-effect patterns."
|
|
1270
|
+
);
|
|
1271
|
+
}
|
|
1272
|
+
if (acceptedMatches.length > 0 && enabledAcceptedMatches.length === 0) {
|
|
1273
|
+
return effectUnavailable(
|
|
1274
|
+
request,
|
|
1275
|
+
"disabled-effect-actuator",
|
|
1276
|
+
"Browser interaction effect pattern exists but has no enabled actuator."
|
|
1277
|
+
);
|
|
1278
|
+
}
|
|
1279
|
+
const preparation = findEffectPreparationChain(surfaces, request);
|
|
1280
|
+
if (preparation.ok) {
|
|
1281
|
+
return {
|
|
1282
|
+
ok: false,
|
|
1283
|
+
code: "preparation-required",
|
|
1284
|
+
diagnostics: [
|
|
1285
|
+
diagnosticFor2({
|
|
1286
|
+
code: "unavailable-actuator",
|
|
1287
|
+
message: "Requested browser interaction effect requires preparation before its actuator is available.",
|
|
1288
|
+
surface: request.surface,
|
|
1289
|
+
scopeId: request.scopeId,
|
|
1290
|
+
interactionKey: request.interactionKey
|
|
1291
|
+
})
|
|
1292
|
+
],
|
|
1293
|
+
preparation: preparation.preparation
|
|
1294
|
+
};
|
|
1295
|
+
}
|
|
1296
|
+
if (preparation.diagnostics.length > 0) {
|
|
1297
|
+
return {
|
|
1298
|
+
ok: false,
|
|
1299
|
+
code: "ambiguous",
|
|
1300
|
+
diagnostics: preparation.diagnostics
|
|
1301
|
+
};
|
|
1302
|
+
}
|
|
1303
|
+
return {
|
|
1304
|
+
ok: false,
|
|
1305
|
+
code: "not-found",
|
|
1306
|
+
diagnostics: [
|
|
1307
|
+
diagnosticFor2({
|
|
1308
|
+
code: "missing-effect",
|
|
1309
|
+
message: "Browser interaction effect is not present in the current snapshot.",
|
|
1310
|
+
surface: request.surface,
|
|
1311
|
+
scopeId: request.scopeId,
|
|
1312
|
+
interactionKey: request.interactionKey
|
|
1313
|
+
})
|
|
1314
|
+
]
|
|
1315
|
+
};
|
|
1316
|
+
}
|
|
1317
|
+
function actuatorMatchesRequest(actuator, request, candidateValueKey) {
|
|
1318
|
+
return actuator.intent === request.intent && (request.inputKey === void 0 || actuator.inputKey === request.inputKey) && (candidateValueKey === void 0 || actuator.candidateValueKey === candidateValueKey) && (request.actuatorKind === void 0 || actuator.actuatorKind === request.actuatorKind);
|
|
1319
|
+
}
|
|
1320
|
+
function findPreparationChain(surfaces, request, candidateValueKey) {
|
|
1321
|
+
const targetRequest = {
|
|
1322
|
+
...request,
|
|
1323
|
+
candidateValueKey
|
|
1324
|
+
};
|
|
1325
|
+
const preparationMatches = surfaces.flatMap(
|
|
1326
|
+
(surface) => surface.interactions.flatMap((interaction) => {
|
|
1327
|
+
if (!interactionMatchesRequest(interaction, request)) return [];
|
|
1328
|
+
return interaction.actuators.filter(
|
|
1329
|
+
(actuator) => actuator.enabled && actuator.prepares && actuator.prepares.intent === targetRequest.intent && (targetRequest.inputKey === void 0 || actuator.prepares.inputKey === targetRequest.inputKey) && (targetRequest.candidateValueKey === void 0 || actuator.prepares.candidateValueKey === targetRequest.candidateValueKey) && (targetRequest.actuatorKind === void 0 || actuator.prepares.actuatorKind === targetRequest.actuatorKind)
|
|
1330
|
+
).map((actuator) => ({ surface, interaction, actuator }));
|
|
1331
|
+
})
|
|
1332
|
+
);
|
|
1333
|
+
if (preparationMatches.length !== 1) return [];
|
|
1334
|
+
const match = preparationMatches[0];
|
|
1335
|
+
if (!match) return [];
|
|
1336
|
+
return expandPreparationChain(
|
|
1337
|
+
match.surface,
|
|
1338
|
+
match.interaction,
|
|
1339
|
+
match.actuator
|
|
1340
|
+
);
|
|
1341
|
+
}
|
|
1342
|
+
function expandPreparationChain(surface, interaction, actuator) {
|
|
1343
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
1344
|
+
for (const candidate of interaction.actuators) {
|
|
1345
|
+
byKey.set(
|
|
1346
|
+
actuatorIdentityKey({
|
|
1347
|
+
surface: surface.surface,
|
|
1348
|
+
scopeId: surface.scopeId,
|
|
1349
|
+
interactionKey: interaction.interactionKey,
|
|
1350
|
+
actuator: candidate
|
|
1351
|
+
}),
|
|
1352
|
+
candidate
|
|
1353
|
+
);
|
|
1354
|
+
}
|
|
1355
|
+
const chain = [];
|
|
1356
|
+
const visited = /* @__PURE__ */ new Set();
|
|
1357
|
+
let current = actuator;
|
|
1358
|
+
while (current) {
|
|
1359
|
+
const key = actuatorIdentityKey({
|
|
1360
|
+
surface: surface.surface,
|
|
1361
|
+
scopeId: surface.scopeId,
|
|
1362
|
+
interactionKey: interaction.interactionKey,
|
|
1363
|
+
actuator: current
|
|
1364
|
+
});
|
|
1365
|
+
if (visited.has(key)) return [];
|
|
1366
|
+
visited.add(key);
|
|
1367
|
+
chain.push(current);
|
|
1368
|
+
current = current.prepares ? byKey.get(
|
|
1369
|
+
targetIdentityKey({
|
|
1370
|
+
surface: surface.surface,
|
|
1371
|
+
scopeId: surface.scopeId,
|
|
1372
|
+
interactionKey: interaction.interactionKey,
|
|
1373
|
+
target: current.prepares
|
|
1374
|
+
})
|
|
1375
|
+
) : void 0;
|
|
1376
|
+
}
|
|
1377
|
+
return chain;
|
|
1378
|
+
}
|
|
1379
|
+
function interactionMatchesRequest(interaction, request) {
|
|
1380
|
+
return (request.interactionKey === void 0 || interaction.interactionKey === request.interactionKey) && (request.interactionId === void 0 || interaction.interactionId === request.interactionId);
|
|
1381
|
+
}
|
|
1382
|
+
function matchingSurfaces(snapshot, request) {
|
|
1383
|
+
return snapshot.surfaces.filter(
|
|
1384
|
+
(surface) => isSemanticSurfaceSnapshot(surface) && surface.surface === request.surface && (request.scopeId === void 0 || surface.scopeId === request.scopeId)
|
|
1385
|
+
);
|
|
1386
|
+
}
|
|
1387
|
+
function collectInteractionMatches(surfaces, request) {
|
|
1388
|
+
return surfaces.flatMap(
|
|
1389
|
+
(surface) => surface.interactions.flatMap((interaction) => {
|
|
1390
|
+
if (request.interactionKey !== void 0 && interaction.interactionKey !== request.interactionKey) {
|
|
1391
|
+
return [];
|
|
1392
|
+
}
|
|
1393
|
+
if (request.interactionId !== void 0 && interaction.interactionId !== request.interactionId) {
|
|
1394
|
+
return [];
|
|
1395
|
+
}
|
|
1396
|
+
return interaction.actuators.map((actuator) => ({
|
|
1397
|
+
surface,
|
|
1398
|
+
interaction,
|
|
1399
|
+
actuator
|
|
1400
|
+
}));
|
|
1401
|
+
})
|
|
1402
|
+
);
|
|
1403
|
+
}
|
|
1404
|
+
function effectSuccess(match, effect, kind) {
|
|
1405
|
+
return {
|
|
1406
|
+
ok: true,
|
|
1407
|
+
actuator: match.actuator,
|
|
1408
|
+
surface: match.surface.surface,
|
|
1409
|
+
scopeId: match.surface.scopeId,
|
|
1410
|
+
interactionKey: match.interaction.interactionKey,
|
|
1411
|
+
match: kind,
|
|
1412
|
+
effect,
|
|
1413
|
+
diagnostics: []
|
|
1414
|
+
};
|
|
1415
|
+
}
|
|
1416
|
+
function effectAmbiguous(matches, code, message) {
|
|
1417
|
+
return {
|
|
1418
|
+
ok: false,
|
|
1419
|
+
code: "ambiguous",
|
|
1420
|
+
diagnostics: matches.map(
|
|
1421
|
+
(match) => diagnosticFor2({
|
|
1422
|
+
code,
|
|
1423
|
+
message,
|
|
1424
|
+
surface: match.surface.surface,
|
|
1425
|
+
scopeId: match.surface.scopeId,
|
|
1426
|
+
interactionKey: match.interaction.interactionKey,
|
|
1427
|
+
intent: match.actuator.intent,
|
|
1428
|
+
actuatorId: match.actuator.actuatorId
|
|
1429
|
+
})
|
|
1430
|
+
)
|
|
1431
|
+
};
|
|
1432
|
+
}
|
|
1433
|
+
function effectUnavailable(request, code, message) {
|
|
1434
|
+
return {
|
|
1435
|
+
ok: false,
|
|
1436
|
+
code: "unavailable",
|
|
1437
|
+
diagnostics: [
|
|
1438
|
+
diagnosticFor2({
|
|
1439
|
+
code,
|
|
1440
|
+
message,
|
|
1441
|
+
surface: request.surface,
|
|
1442
|
+
scopeId: request.scopeId,
|
|
1443
|
+
interactionKey: request.interactionKey
|
|
1444
|
+
})
|
|
1445
|
+
]
|
|
1446
|
+
};
|
|
1447
|
+
}
|
|
1448
|
+
function findEffectPreparationChain(surfaces, request) {
|
|
1449
|
+
const matches = collectInteractionMatches(surfaces, request).filter(
|
|
1450
|
+
(match) => match.actuator.preparationPatterns.some(
|
|
1451
|
+
(pattern) => browserInteractionEffectPatternMatches(pattern, request.effect)
|
|
1452
|
+
)
|
|
1453
|
+
);
|
|
1454
|
+
const enabledMatches = matches.filter((match) => match.actuator.enabled);
|
|
1455
|
+
if (enabledMatches.length === 1) {
|
|
1456
|
+
const match = enabledMatches[0];
|
|
1457
|
+
if (!match) return { ok: false, diagnostics: [] };
|
|
1458
|
+
return { ok: true, preparation: [match.actuator] };
|
|
1459
|
+
}
|
|
1460
|
+
if (enabledMatches.length > 1) {
|
|
1461
|
+
return {
|
|
1462
|
+
ok: false,
|
|
1463
|
+
diagnostics: enabledMatches.map(
|
|
1464
|
+
(match) => diagnosticFor2({
|
|
1465
|
+
code: "ambiguous-preparation-pattern",
|
|
1466
|
+
message: "Browser interaction effect resolved to multiple preparation actuators.",
|
|
1467
|
+
surface: match.surface.surface,
|
|
1468
|
+
scopeId: match.surface.scopeId,
|
|
1469
|
+
interactionKey: match.interaction.interactionKey,
|
|
1470
|
+
intent: match.actuator.intent,
|
|
1471
|
+
actuatorId: match.actuator.actuatorId
|
|
1472
|
+
})
|
|
1473
|
+
)
|
|
1474
|
+
};
|
|
1475
|
+
}
|
|
1476
|
+
return { ok: false, diagnostics: [] };
|
|
1477
|
+
}
|
|
1478
|
+
function validateEffectRequest(effect, request) {
|
|
1479
|
+
if (!effect || typeof effect.kind !== "string" || effect.kind.length === 0) {
|
|
1480
|
+
return [
|
|
1481
|
+
diagnosticFor2({
|
|
1482
|
+
code: "invalid-effect-payload",
|
|
1483
|
+
message: "Browser interaction effect requires a string kind.",
|
|
1484
|
+
surface: request.surface,
|
|
1485
|
+
scopeId: request.scopeId,
|
|
1486
|
+
interactionKey: request.interactionKey
|
|
1487
|
+
})
|
|
1488
|
+
];
|
|
1489
|
+
}
|
|
1490
|
+
if (effect.kind === "setScalar") {
|
|
1491
|
+
const value = effect.value;
|
|
1492
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
1493
|
+
return [
|
|
1494
|
+
diagnosticFor2({
|
|
1495
|
+
code: "invalid-scalar-argument",
|
|
1496
|
+
message: "setScalar browser interaction effects require a finite value.",
|
|
1497
|
+
surface: request.surface,
|
|
1498
|
+
scopeId: request.scopeId,
|
|
1499
|
+
interactionKey: request.interactionKey
|
|
1500
|
+
})
|
|
1501
|
+
];
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
return [];
|
|
1505
|
+
}
|
|
1506
|
+
function diagnosticFor2(input) {
|
|
1507
|
+
return { severity: "error", ...input };
|
|
1508
|
+
}
|
|
1509
|
+
|
|
1510
|
+
// src/browser-interaction/schemas.ts
|
|
1511
|
+
import { z } from "zod";
|
|
1512
|
+
var jsonValueSchema = z.lazy(
|
|
1513
|
+
() => z.union([
|
|
1514
|
+
z.null(),
|
|
1515
|
+
z.boolean(),
|
|
1516
|
+
z.number().finite(),
|
|
1517
|
+
z.string(),
|
|
1518
|
+
z.array(jsonValueSchema),
|
|
1519
|
+
z.record(z.string(), jsonValueSchema)
|
|
1520
|
+
])
|
|
1521
|
+
);
|
|
1522
|
+
var browserInteractionEffectSchema = z.object({
|
|
1523
|
+
kind: z.string().min(1)
|
|
1524
|
+
}).catchall(jsonValueSchema);
|
|
1525
|
+
var browserInteractionEffectPatternSchema = z.union([
|
|
1526
|
+
z.object({
|
|
1527
|
+
kind: z.literal("exact"),
|
|
1528
|
+
effect: browserInteractionEffectSchema
|
|
1529
|
+
}),
|
|
1530
|
+
z.object({
|
|
1531
|
+
kind: z.literal("match"),
|
|
1532
|
+
effectKind: z.string().min(1),
|
|
1533
|
+
fields: z.record(z.string(), jsonValueSchema).optional(),
|
|
1534
|
+
scalar: z.object({
|
|
1535
|
+
field: z.string().min(1),
|
|
1536
|
+
min: z.number().finite().optional(),
|
|
1537
|
+
max: z.number().finite().optional(),
|
|
1538
|
+
integer: z.boolean().optional()
|
|
1539
|
+
}).optional()
|
|
1540
|
+
})
|
|
1541
|
+
]);
|
|
1542
|
+
var gameplaySemanticEffectSchema = z.union([
|
|
1543
|
+
z.object({
|
|
1544
|
+
kind: z.literal("setCandidate"),
|
|
1545
|
+
inputKey: z.string(),
|
|
1546
|
+
candidateValue: jsonValueSchema,
|
|
1547
|
+
beforeSelected: z.boolean(),
|
|
1548
|
+
afterSelected: z.boolean()
|
|
1549
|
+
}),
|
|
1550
|
+
z.object({
|
|
1551
|
+
kind: z.literal("adjustResource"),
|
|
1552
|
+
inputKey: z.string(),
|
|
1553
|
+
resourceKey: jsonValueSchema,
|
|
1554
|
+
delta: z.union([z.literal(-1), z.literal(1)])
|
|
1555
|
+
}),
|
|
1556
|
+
z.object({
|
|
1557
|
+
kind: z.literal("setScalar"),
|
|
1558
|
+
inputKey: z.string(),
|
|
1559
|
+
value: z.number().finite()
|
|
1560
|
+
}),
|
|
1561
|
+
z.object({
|
|
1562
|
+
kind: z.literal("commit")
|
|
1563
|
+
}),
|
|
1564
|
+
z.object({
|
|
1565
|
+
kind: z.literal("invoke")
|
|
1566
|
+
})
|
|
1567
|
+
]);
|
|
1568
|
+
var browserInteractionDiagnosticSchema = z.object({
|
|
1569
|
+
code: z.string(),
|
|
1570
|
+
severity: z.enum(["error", "warning"]),
|
|
1571
|
+
message: z.string(),
|
|
1572
|
+
surface: z.string().optional(),
|
|
1573
|
+
scopeId: z.string().optional(),
|
|
1574
|
+
interactionKey: z.string().optional(),
|
|
1575
|
+
intent: z.string().optional(),
|
|
1576
|
+
actuatorId: z.string().optional()
|
|
1577
|
+
});
|
|
1578
|
+
var browserInteractionActuatorSchema = z.object({
|
|
1579
|
+
actuatorId: z.string(),
|
|
1580
|
+
intent: z.string(),
|
|
1581
|
+
inputKey: z.string().optional(),
|
|
1582
|
+
candidateValue: jsonValueSchema.optional(),
|
|
1583
|
+
candidateValueKey: z.string().optional(),
|
|
1584
|
+
candidateState: z.enum(BROWSER_INTERACTION_CANDIDATE_STATES).optional(),
|
|
1585
|
+
enabled: z.boolean(),
|
|
1586
|
+
actuatorKind: z.enum(BROWSER_INTERACTION_ACTUATOR_KINDS),
|
|
1587
|
+
semanticEffects: z.array(browserInteractionEffectSchema),
|
|
1588
|
+
acceptedEffectPatterns: z.array(browserInteractionEffectPatternSchema),
|
|
1589
|
+
preparationPatterns: z.array(browserInteractionEffectPatternSchema),
|
|
1590
|
+
prepares: z.object({
|
|
1591
|
+
intent: z.string(),
|
|
1592
|
+
inputKey: z.string().optional(),
|
|
1593
|
+
candidateValue: jsonValueSchema.optional(),
|
|
1594
|
+
candidateValueKey: z.string().optional(),
|
|
1595
|
+
actuatorKind: z.enum(BROWSER_INTERACTION_ACTUATOR_KINDS).optional()
|
|
1596
|
+
}).optional(),
|
|
1597
|
+
diagnostics: z.array(browserInteractionDiagnosticSchema)
|
|
1598
|
+
});
|
|
1599
|
+
var browserGameplayInteractionSchema = z.object({
|
|
1600
|
+
interactionKey: z.string(),
|
|
1601
|
+
interactionId: z.string(),
|
|
1602
|
+
descriptorDigest: z.string().optional(),
|
|
1603
|
+
draftDigest: z.string().optional(),
|
|
1604
|
+
readiness: z.enum(BROWSER_INTERACTION_READINESS_VALUES),
|
|
1605
|
+
actuators: z.array(browserInteractionActuatorSchema),
|
|
1606
|
+
diagnostics: z.array(browserInteractionDiagnosticSchema)
|
|
1607
|
+
});
|
|
1608
|
+
var browserGameplaySurfaceSnapshotSchema = z.object({
|
|
1609
|
+
surface: z.literal(GAMEPLAY_BROWSER_INTERACTION_SURFACE),
|
|
1610
|
+
scopeId: z.string(),
|
|
1611
|
+
interactions: z.array(browserGameplayInteractionSchema),
|
|
1612
|
+
diagnostics: z.array(browserInteractionDiagnosticSchema)
|
|
1613
|
+
});
|
|
1614
|
+
var browserSemanticSurfaceSnapshotSchema = z.object({
|
|
1615
|
+
surface: z.string(),
|
|
1616
|
+
scopeId: z.string(),
|
|
1617
|
+
interactions: z.array(browserGameplayInteractionSchema),
|
|
1618
|
+
diagnostics: z.array(browserInteractionDiagnosticSchema)
|
|
1619
|
+
});
|
|
1620
|
+
var browserUnknownSurfaceSnapshotSchema = z.object({
|
|
1621
|
+
surface: z.string(),
|
|
1622
|
+
scopeId: z.string(),
|
|
1623
|
+
diagnostics: z.array(browserInteractionDiagnosticSchema)
|
|
1624
|
+
});
|
|
1625
|
+
var browserInteractionSnapshotSchema = z.object({
|
|
1626
|
+
protocol: z.object({
|
|
1627
|
+
name: z.literal(DREAMBOARD_BROWSER_INTERACTION_PROTOCOL_NAME),
|
|
1628
|
+
version: z.literal(DREAMBOARD_BROWSER_INTERACTION_PROTOCOL_VERSION)
|
|
1629
|
+
}),
|
|
1630
|
+
surfaces: z.array(
|
|
1631
|
+
z.union([
|
|
1632
|
+
browserSemanticSurfaceSnapshotSchema,
|
|
1633
|
+
browserUnknownSurfaceSnapshotSchema
|
|
1634
|
+
])
|
|
1635
|
+
),
|
|
1636
|
+
diagnostics: z.array(browserInteractionDiagnosticSchema)
|
|
1637
|
+
});
|
|
1638
|
+
|
|
1639
|
+
export {
|
|
1640
|
+
DREAMBOARD_BROWSER_INTERACTION_PROTOCOL_NAME,
|
|
1641
|
+
DREAMBOARD_BROWSER_INTERACTION_PROTOCOL_VERSION,
|
|
1642
|
+
BROWSER_INTERACTION_ATTRIBUTES,
|
|
1643
|
+
BROWSER_INTERACTION_RECORD_ROLES,
|
|
1644
|
+
GAMEPLAY_BROWSER_INTERACTION_SURFACE,
|
|
1645
|
+
GAMEPLAY_BROWSER_INTERACTION_INTENTS,
|
|
1646
|
+
GAMEPLAY_BROWSER_INTERACTION_EFFECT_KINDS,
|
|
1647
|
+
BROWSER_INTERACTION_READINESS_VALUES,
|
|
1648
|
+
BROWSER_INTERACTION_CANDIDATE_STATES,
|
|
1649
|
+
BROWSER_INTERACTION_ACTUATOR_KINDS,
|
|
1650
|
+
encodeCanonicalCandidateValue,
|
|
1651
|
+
decodeCanonicalCandidateValue,
|
|
1652
|
+
compareStableJson,
|
|
1653
|
+
encodeBrowserInteractionEffect,
|
|
1654
|
+
decodeBrowserInteractionEffect,
|
|
1655
|
+
encodeBrowserInteractionEffectPattern,
|
|
1656
|
+
decodeBrowserInteractionEffectPattern,
|
|
1657
|
+
browserInteractionEffectPatternMatches,
|
|
1658
|
+
assertBrowserInteractionEffectPattern,
|
|
1659
|
+
gameplaySetCandidateEffect,
|
|
1660
|
+
gameplayAdjustResourceEffect,
|
|
1661
|
+
gameplaySetScalarEffect,
|
|
1662
|
+
gameplayCommitEffect,
|
|
1663
|
+
gameplayInvokeEffect,
|
|
1664
|
+
createBrowserInteractionRootAttributes,
|
|
1665
|
+
createBrowserInteractionActuatorAttributes,
|
|
1666
|
+
createGameplayInteractionRootAttributes,
|
|
1667
|
+
createGameplayActuatorAttributes,
|
|
1668
|
+
createBrowserInteractionActuatorKey,
|
|
1669
|
+
defineBrowserInteractionSurface,
|
|
1670
|
+
gameplayBrowserInteractionSurface,
|
|
1671
|
+
createBrowserInteractionRegistry,
|
|
1672
|
+
defaultBrowserInteractionRegistry,
|
|
1673
|
+
normalizeBrowserInteractionRecords,
|
|
1674
|
+
validateBrowserInteractionSnapshot,
|
|
1675
|
+
actuatorIdentityKey,
|
|
1676
|
+
isSemanticSurfaceSnapshot,
|
|
1677
|
+
targetIdentityKey,
|
|
1678
|
+
resolveBrowserInteractionIntent,
|
|
1679
|
+
resolveBrowserInteractionEffect,
|
|
1680
|
+
browserInteractionEffectSchema,
|
|
1681
|
+
browserInteractionEffectPatternSchema,
|
|
1682
|
+
gameplaySemanticEffectSchema,
|
|
1683
|
+
browserInteractionDiagnosticSchema,
|
|
1684
|
+
browserInteractionActuatorSchema,
|
|
1685
|
+
browserGameplayInteractionSchema,
|
|
1686
|
+
browserGameplaySurfaceSnapshotSchema,
|
|
1687
|
+
browserSemanticSurfaceSnapshotSchema,
|
|
1688
|
+
browserUnknownSurfaceSnapshotSchema,
|
|
1689
|
+
browserInteractionSnapshotSchema
|
|
1690
|
+
};
|
|
1691
|
+
//# sourceMappingURL=chunk-QLG6VEMW.js.map
|