@platejs/test 0.0.0-stage → 54.0.0-beta.2

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.
@@ -0,0 +1,634 @@
1
+ import { n as defineBrowserFeatureContract, t as createBrowserFeatureContractRegistry } from "../feature-contracts-BhHdrzuI.js";
2
+ //#region src/proof/first-party-browser-contracts.ts
3
+ /** Canonical first-party browser behavior families editor must preserve. */
4
+ const BROWSER_FIRST_PARTY_INTENT_FAMILY_CONTRACTS = [
5
+ {
6
+ assertions: [
7
+ "model selection lands on the next inline void from both sides",
8
+ "DOM selection stays collapsed at the void boundary",
9
+ "focus remains editor-owned",
10
+ "selection movement stays inside the render budget"
11
+ ],
12
+ family: "inline-void-boundary-navigation",
13
+ routes: ["mentions"]
14
+ },
15
+ {
16
+ assertions: [
17
+ "markable inline void visible content keeps mark styling",
18
+ "hidden anchor is owned by the runtime shell",
19
+ "model and DOM selections land on the inline void",
20
+ "selection movement stays inside the render budget"
21
+ ],
22
+ family: "markable-inline-void-formatting",
23
+ routes: ["mentions"]
24
+ },
25
+ {
26
+ assertions: [
27
+ "model and DOM selections enter and leave block voids",
28
+ "visible void content has no hidden-anchor layout gap",
29
+ "focus remains editor-owned",
30
+ "selection movement stays inside the render budget"
31
+ ],
32
+ family: "block-void-navigation",
33
+ routes: ["images", "embeds"]
34
+ },
35
+ {
36
+ assertions: [
37
+ "each pasted HTML image becomes a runtime-owned block void",
38
+ "visible image content is contentEditable=false",
39
+ "hidden spacer is owned by the runtime shell",
40
+ "focus remains editor-owned after paste"
41
+ ],
42
+ family: "paste-html-image-void",
43
+ routes: ["paste-html"]
44
+ },
45
+ {
46
+ assertions: [
47
+ "native controls stay inside a runtime-owned block void",
48
+ "internal input focus remains native-owned",
49
+ "internal input range selection stays visible without becoming editor selection",
50
+ "outer editor selection is preserved while the native control edits",
51
+ "follow-up editor typing records a legal insert-text transition"
52
+ ],
53
+ family: "true-void-native-focus",
54
+ routes: ["editable-voids"]
55
+ },
56
+ {
57
+ assertions: [
58
+ "remote remove nulls local runtime targets",
59
+ "remote move rebases local runtime targets",
60
+ "remote import commit metadata is tagged",
61
+ "follow-up editor typing works after stale target rebase"
62
+ ],
63
+ family: "stale-target-remote-rebase",
64
+ routes: ["images"]
65
+ },
66
+ {
67
+ assertions: [
68
+ "table cell boundary arrows land at offset 0",
69
+ "model and DOM selection agree",
70
+ "focus remains editor-owned",
71
+ "selection movement does not rerender the editable root"
72
+ ],
73
+ family: "table-cell-boundary-navigation",
74
+ routes: ["tables"]
75
+ },
76
+ {
77
+ assertions: [
78
+ "external decoration refresh updates rendered highlights",
79
+ "search input keeps focus ownership",
80
+ "editor root and text nodes stay bounded while element nodes stay out of the render budget"
81
+ ],
82
+ family: "external-decoration-refresh",
83
+ routes: ["search-highlighting"]
84
+ },
85
+ {
86
+ assertions: [
87
+ "app-owned lint diagnostics update external decoration ranges",
88
+ "lint result refresh reports visible projected slices",
89
+ "editor focus and render ownership remain stable"
90
+ ],
91
+ family: "overlay-many-decoration-sources",
92
+ routes: ["linting"]
93
+ },
94
+ {
95
+ assertions: [
96
+ "annotation metadata updates without replacing the anchor",
97
+ "inline annotation payload changes render",
98
+ "annotation sidebar remains attached to the same id"
99
+ ],
100
+ family: "overlay-annotation-metadata-only",
101
+ routes: ["comment-mode"]
102
+ },
103
+ {
104
+ assertions: [
105
+ "annotation anchor rebase keeps inline projection attached",
106
+ "annotation sidebar range follows inserted content",
107
+ "annotation sidebar remains visible after rebase"
108
+ ],
109
+ family: "overlay-annotation-anchor-rebase",
110
+ routes: ["comment-mode", "persistent-annotation-anchors"]
111
+ },
112
+ {
113
+ assertions: [
114
+ "annotation readers wake by annotation id",
115
+ "selection and metadata changes keep annotation visibility coherent",
116
+ "clearing annotations clears dependent readers"
117
+ ],
118
+ family: "overlay-annotation-dirty-id",
119
+ routes: ["comment-mode"]
120
+ },
121
+ {
122
+ assertions: [
123
+ "inline and sidebar annotation projections stay in sync",
124
+ "text edits before an annotation rebase inline projection",
125
+ "clear removes inline and sidebar projections"
126
+ ],
127
+ family: "overlay-mixed-update",
128
+ routes: ["comment-mode"]
129
+ },
130
+ {
131
+ assertions: [
132
+ "real mouse drag creates native and model selections",
133
+ "hovering toolbar becomes visible",
134
+ "focus remains editor-owned",
135
+ "selection movement does not rerender editor nodes"
136
+ ],
137
+ family: "mouse-selection-toolbar",
138
+ routes: ["hovering-toolbar"]
139
+ },
140
+ {
141
+ assertions: [
142
+ "repeated Shift+ArrowDown extends the model focus monotonically",
143
+ "Shift+ArrowUp reverses the recent focus sequence",
144
+ "projected selection uses view markers while native selected text stays empty",
145
+ "native and projected selection do not double-highlight",
146
+ "vertical movement stays inside the hot-path budget"
147
+ ],
148
+ family: "huge-document-projected-vertical-selection",
149
+ routes: ["huge-document"]
150
+ },
151
+ {
152
+ assertions: [
153
+ "virtualized row stacking has no overlap during immediate scrollbar jumps",
154
+ "settled virtualized rows have no gaps or overlaps after scroll repaint",
155
+ "native scrollbar drag buffers mounted rows before React commits the next range",
156
+ "dynamic-height backward scroll stays near the requested offset"
157
+ ],
158
+ family: "huge-document-virtualized-scroll-stability",
159
+ routes: ["huge-document"]
160
+ },
161
+ {
162
+ assertions: [
163
+ "beforeinput target ranges replace browser substitution spans",
164
+ "dirty node maps reject stale target ranges while keeping current node keys",
165
+ "native partial text replacement undo restores text and selection",
166
+ "mouse-drag typed replacement undo restores DOM and model selection"
167
+ ],
168
+ family: "native-beforeinput-target-range-repair",
169
+ routes: ["plaintext"]
170
+ },
171
+ {
172
+ assertions: [
173
+ "paste normalizes multiline content",
174
+ "follow-up typing commits",
175
+ "undo replays the last edit",
176
+ "artifact can replay the generated steps"
177
+ ],
178
+ family: "paste-normalize-undo",
179
+ routes: [
180
+ "richtext",
181
+ "plaintext",
182
+ "forced-layout"
183
+ ]
184
+ },
185
+ {
186
+ assertions: [
187
+ "ProseMirror list slices import without exposing slice metadata",
188
+ "ProseMirror text slices paste only visible text",
189
+ "comment-bounded clipboard HTML imports only the bounded fragment",
190
+ "external table clipboard HTML preserves rows, cells, and cell-local marks"
191
+ ],
192
+ family: "external-clipboard-slice-context",
193
+ routes: ["paste-html"]
194
+ },
195
+ {
196
+ assertions: [
197
+ "composition commits through the browser scenario runner",
198
+ "model text includes the composed text",
199
+ "focus remains editor-owned",
200
+ "artifact can replay the generated steps"
201
+ ],
202
+ family: "selection-repair-ime",
203
+ routes: ["richtext"]
204
+ },
205
+ {
206
+ assertions: [
207
+ "composition commits inside formatted markup without breaking marks",
208
+ "active-mark cursor-wrapper composition creates marked text",
209
+ "composition can replace multiple formatted text nodes once",
210
+ "WebKit compositionend cleanup deletes expanded rich text selections"
211
+ ],
212
+ family: "ime-composition-formatted-boundaries",
213
+ routes: ["richtext"]
214
+ },
215
+ {
216
+ assertions: [
217
+ "rapid consecutive compositions commit in separate rich text blocks",
218
+ "cross-paragraph native composition replaces the selected range once",
219
+ "synthetic composition transport does not mutate React-owned expanded DOM ranges",
220
+ "final model selection lands after the committed composition text"
221
+ ],
222
+ family: "ime-composition-cross-block-repair",
223
+ routes: ["richtext"]
224
+ },
225
+ {
226
+ assertions: [
227
+ "synthetic composition can stay open across app-owned decoration refresh",
228
+ "prop and hook decoration sources refresh while composition remains active",
229
+ "committed composition text survives the decoration restructure",
230
+ "model, DOM caret, and final text agree after compositionend"
231
+ ],
232
+ family: "ime-composition-decoration-refresh",
233
+ routes: ["decorations-async"]
234
+ },
235
+ {
236
+ assertions: [
237
+ "composition next to an inline void inserts into the adjacent text node",
238
+ "inline void structure remains intact",
239
+ "DOM selection remains collapsed after composition",
240
+ "artifact can replay the generated steps"
241
+ ],
242
+ family: "ime-composition-inline-void-boundary",
243
+ routes: ["mentions"]
244
+ },
245
+ {
246
+ assertions: [
247
+ "composition commits text through the browser scenario runner",
248
+ "undo removes the committed composition text as one history unit",
249
+ "model text returns to the pre-composition value",
250
+ "artifact can replay the generated steps"
251
+ ],
252
+ family: "ime-composition-undo",
253
+ routes: ["richtext"]
254
+ }
255
+ ];
256
+ /** Focused parity families that compare the same invariant across routes. */
257
+ const BROWSER_FIRST_PARTY_PARITY_FAMILIES = [
258
+ {
259
+ assertions: ["model selection lands on the next inline void from both sides", "DOM selection stays collapsed at the void boundary"],
260
+ family: "inline-void-boundary-navigation",
261
+ routes: ["mentions"]
262
+ },
263
+ {
264
+ assertions: ["model and DOM selections enter and leave block voids", "visible void content has no hidden-anchor layout gap"],
265
+ family: "block-void-navigation",
266
+ routes: ["images", "embeds"]
267
+ },
268
+ {
269
+ assertions: ["external decoration refresh updates rendered highlights", "search input keeps focus ownership"],
270
+ family: "external-decoration-refresh",
271
+ routes: ["search-highlighting"]
272
+ },
273
+ {
274
+ assertions: ["real mouse drag creates native and model selections", "hovering toolbar becomes visible"],
275
+ family: "mouse-selection-toolbar",
276
+ routes: ["hovering-toolbar"]
277
+ },
278
+ {
279
+ assertions: ["table cell boundary arrows land at offset 0", "model and DOM selection agree"],
280
+ family: "table-cell-boundary-navigation",
281
+ routes: ["tables"]
282
+ }
283
+ ];
284
+ const rowsByFamily = (families) => BROWSER_FIRST_PARTY_INTENT_FAMILY_CONTRACTS.filter((contract) => families.includes(contract.family));
285
+ /** Feature-indexed registry built from the first-party behavior families. */
286
+ const BROWSER_FIRST_PARTY_FEATURE_CONTRACT_REGISTRY = createBrowserFeatureContractRegistry([
287
+ defineBrowserFeatureContract({
288
+ feature: "mentions",
289
+ rows: rowsByFamily(["inline-void-boundary-navigation", "markable-inline-void-formatting"])
290
+ }),
291
+ defineBrowserFeatureContract({
292
+ feature: "media",
293
+ rows: rowsByFamily([
294
+ "block-void-navigation",
295
+ "paste-html-image-void",
296
+ "stale-target-remote-rebase"
297
+ ])
298
+ }),
299
+ defineBrowserFeatureContract({
300
+ feature: "editable-voids",
301
+ rows: rowsByFamily(["true-void-native-focus"])
302
+ }),
303
+ defineBrowserFeatureContract({
304
+ feature: "table",
305
+ rows: rowsByFamily(["table-cell-boundary-navigation"])
306
+ }),
307
+ defineBrowserFeatureContract({
308
+ feature: "external-decorations",
309
+ rows: rowsByFamily(["external-decoration-refresh", "overlay-many-decoration-sources"])
310
+ }),
311
+ defineBrowserFeatureContract({
312
+ feature: "annotations",
313
+ rows: rowsByFamily([
314
+ "overlay-annotation-metadata-only",
315
+ "overlay-annotation-anchor-rebase",
316
+ "overlay-annotation-dirty-id",
317
+ "overlay-mixed-update"
318
+ ])
319
+ }),
320
+ defineBrowserFeatureContract({
321
+ feature: "selection-ui",
322
+ rows: rowsByFamily(["mouse-selection-toolbar"])
323
+ }),
324
+ defineBrowserFeatureContract({
325
+ feature: "core-editing",
326
+ rows: rowsByFamily([
327
+ "huge-document-projected-vertical-selection",
328
+ "huge-document-virtualized-scroll-stability",
329
+ "native-beforeinput-target-range-repair",
330
+ "ime-composition-formatted-boundaries",
331
+ "ime-composition-cross-block-repair",
332
+ "ime-composition-decoration-refresh",
333
+ "external-clipboard-slice-context",
334
+ "paste-normalize-undo",
335
+ "selection-repair-ime",
336
+ "ime-composition-undo"
337
+ ])
338
+ }),
339
+ defineBrowserFeatureContract({
340
+ feature: "inline-void-ime",
341
+ rows: rowsByFamily(["ime-composition-inline-void-boundary"])
342
+ })
343
+ ]);
344
+ /** Assert that first-party behavior and parity contract registries agree. */
345
+ const assertBrowserFirstPartyParityContracts = () => {
346
+ const registry = BROWSER_FIRST_PARTY_FEATURE_CONTRACT_REGISTRY;
347
+ if (registry.rows.length !== BROWSER_FIRST_PARTY_INTENT_FAMILY_CONTRACTS.length) throw new Error("Feature browser contract registry is missing stress rows.");
348
+ for (const contract of BROWSER_FIRST_PARTY_INTENT_FAMILY_CONTRACTS) {
349
+ const row = registry.rowByFamily.get(contract.family);
350
+ if (!row) throw new Error(`Feature browser contract registry is missing "${contract.family}".`);
351
+ if (row.routes.join("\0") !== contract.routes.join("\0")) throw new Error(`Feature browser contract "${contract.family}" has stale routes.`);
352
+ }
353
+ for (const parityFamily of BROWSER_FIRST_PARTY_PARITY_FAMILIES) {
354
+ const row = registry.rowByFamily.get(parityFamily.family);
355
+ if (!row) throw new Error(`First-party parity family "${parityFamily.family}" is not registered.`);
356
+ const routeSet = new Set(row.routes);
357
+ const assertionSet = new Set(row.assertions);
358
+ for (const route of parityFamily.routes) if (!routeSet.has(route)) throw new Error(`First-party parity family "${parityFamily.family}" is missing route "${route}".`);
359
+ for (const assertion of parityFamily.assertions) if (!assertionSet.has(assertion)) throw new Error(`First-party parity family "${parityFamily.family}" is missing assertion "${assertion}".`);
360
+ }
361
+ return {
362
+ intentFamilyCount: BROWSER_FIRST_PARTY_INTENT_FAMILY_CONTRACTS.length,
363
+ parityFamilies: BROWSER_FIRST_PARTY_PARITY_FAMILIES.map((family) => family.family),
364
+ registryRowCount: registry.rows.length
365
+ };
366
+ };
367
+ //#endregion
368
+ //#region src/proof/mobile-transport-proof.ts
369
+ const DIRECT_DEVICE_SUPPORTED_CLAIMS = [
370
+ "device-browser-text-input",
371
+ "device-browser-ime-commit",
372
+ "debug-snapshot"
373
+ ];
374
+ const DIRECT_DEVICE_UNSUPPORTED_CLAIMS = [
375
+ "native-mobile-clipboard",
376
+ "human-soft-keyboard",
377
+ "glide-typing",
378
+ "voice-input"
379
+ ];
380
+ /** Classify the proof strength and claim coverage of a mobile transport. */
381
+ const classifyBrowserMobileTransportProof = (transport) => {
382
+ switch (transport) {
383
+ case "appium-android": return {
384
+ evidenceClass: "automated-direct",
385
+ platform: "android-chrome",
386
+ releaseGateCapable: true,
387
+ supportedClaims: [...DIRECT_DEVICE_SUPPORTED_CLAIMS],
388
+ transport,
389
+ unsupportedClaims: [...DIRECT_DEVICE_UNSUPPORTED_CLAIMS]
390
+ };
391
+ case "appium-ios": return {
392
+ evidenceClass: "automated-direct",
393
+ platform: "ios-safari",
394
+ releaseGateCapable: true,
395
+ supportedClaims: [...DIRECT_DEVICE_SUPPORTED_CLAIMS],
396
+ transport,
397
+ unsupportedClaims: [...DIRECT_DEVICE_UNSUPPORTED_CLAIMS]
398
+ };
399
+ case "agent-browser-ios": return {
400
+ evidenceClass: "automated-proxy",
401
+ platform: "ios-safari",
402
+ releaseGateCapable: false,
403
+ supportedClaims: ["device-browser-text-input", "debug-snapshot"],
404
+ transport,
405
+ unsupportedClaims: [
406
+ "native-mobile-clipboard",
407
+ "device-browser-ime-commit",
408
+ "human-soft-keyboard",
409
+ "glide-typing",
410
+ "voice-input"
411
+ ]
412
+ };
413
+ }
414
+ throw new Error(`Unexpected mobile transport: ${String(transport)}`);
415
+ };
416
+ /** Return the proof capability matrix for every known mobile transport. */
417
+ const getBrowserMobileTransportProofMatrix = () => [
418
+ "appium-android",
419
+ "appium-ios",
420
+ "agent-browser-ios"
421
+ ].map(classifyBrowserMobileTransportProof);
422
+ //#endregion
423
+ //#region src/proof/proof.ts
424
+ const extractAppiumJsonValue = (raw) => {
425
+ const parsed = JSON.parse(raw);
426
+ if (typeof parsed?.value !== "string") throw new Error("Appium execute payload did not return a string value");
427
+ return JSON.parse(parsed.value);
428
+ };
429
+ const isDebugSnapshot = (value) => {
430
+ if (!value || typeof value !== "object") return false;
431
+ const record = value;
432
+ return typeof record.blockTexts === "string" && typeof record.domSelection === "string" && Array.isArray(record.events) && record.events.every((event) => typeof event === "string") && typeof record.editorSelection === "string";
433
+ };
434
+ /** Parse and validate a serialized browser debug snapshot. */
435
+ const parseDebugSnapshot = (raw) => {
436
+ const parsed = JSON.parse(raw);
437
+ if (!isDebugSnapshot(parsed)) throw new Error("Debug snapshot payload is not a recognized snapshot shape");
438
+ return parsed;
439
+ };
440
+ /** Parse raw agent-browser batch JSON output. */
441
+ const parseAgentBrowserBatch = (raw) => {
442
+ const parsed = JSON.parse(raw);
443
+ if (!Array.isArray(parsed)) throw new Error("Agent-browser batch output is not an array");
444
+ return parsed;
445
+ };
446
+ /** Extract the last debug snapshot string from agent-browser batch output. */
447
+ const extractAgentBrowserDebugSnapshot = (raw) => {
448
+ const last = parseAgentBrowserBatch(raw).at(-1);
449
+ const debugText = last?.result?.result;
450
+ if (!last?.success || typeof debugText !== "string") throw new Error("Agent-browser batch did not return a debug snapshot string");
451
+ return parseDebugSnapshot(debugText);
452
+ };
453
+ /** Extract a debug snapshot from an Appium execute response. */
454
+ const extractAppiumDebugSnapshot = (raw) => parseDebugSnapshot(JSON.stringify(extractAppiumJsonValue(raw)));
455
+ /** Evaluate IME input behavior from a browser debug snapshot. */
456
+ const evaluateImeInput = (snapshot, expectedText = "sushi") => {
457
+ const issues = [];
458
+ const expectedSelection = `0.0:${expectedText.length}|0.0:${expectedText.length}`;
459
+ if (snapshot.blockTexts !== expectedText) issues.push(`Expected blockTexts to equal "${expectedText}", got "${snapshot.blockTexts}"`);
460
+ if (snapshot.editorSelection !== expectedSelection) issues.push(`Expected editorSelection to equal "${expectedSelection}", got "${snapshot.editorSelection}"`);
461
+ if (snapshot.placeholderShape !== null) issues.push("Expected placeholderShape to be null after input commit");
462
+ if (!snapshot.events.some((event) => event.includes("beforeinput"))) issues.push("Expected at least one beforeinput event in debug snapshot");
463
+ return {
464
+ issues,
465
+ ok: issues.length === 0,
466
+ snapshot
467
+ };
468
+ };
469
+ /** Evaluate placeholder input behavior from a browser debug snapshot. */
470
+ const evaluatePlaceholderInput = (snapshot, expectedText = "sushi") => evaluateImeInput(snapshot, expectedText);
471
+ //#endregion
472
+ //#region src/proof/raw-mobile-proof.ts
473
+ /** Exact scenario matrix required for raw Android and iOS release proof. */
474
+ const RAW_MOBILE_SCENARIOS = [
475
+ {
476
+ id: "tap",
477
+ updateCount: 0
478
+ },
479
+ {
480
+ id: "double-tap",
481
+ updateCount: 0
482
+ },
483
+ {
484
+ id: "long-press",
485
+ updateCount: 0
486
+ },
487
+ {
488
+ id: "selection-handle-forward",
489
+ updateCount: 0
490
+ },
491
+ {
492
+ id: "selection-handle-backward",
493
+ updateCount: 0
494
+ },
495
+ {
496
+ id: "cross-inline-selection",
497
+ updateCount: 0
498
+ },
499
+ {
500
+ id: "cross-block-text-selection",
501
+ updateCount: 0
502
+ },
503
+ {
504
+ id: "selection-autoscroll",
505
+ updateCount: 0
506
+ },
507
+ {
508
+ id: "swipe-collapsed",
509
+ updateCount: 0
510
+ },
511
+ {
512
+ id: "swipe-expanded",
513
+ updateCount: 0
514
+ },
515
+ {
516
+ id: "inline-void-boundary",
517
+ updateCount: 0
518
+ },
519
+ {
520
+ id: "enter",
521
+ updateCount: 1
522
+ },
523
+ {
524
+ id: "backspace",
525
+ updateCount: 1
526
+ },
527
+ {
528
+ id: "autocapitalization",
529
+ updateCount: 1
530
+ },
531
+ {
532
+ id: "composition-ime",
533
+ updateCount: 1
534
+ },
535
+ {
536
+ id: "native-clipboard",
537
+ updateCount: 1
538
+ }
539
+ ];
540
+ const isSha256 = (value) => /^[\da-f]{64}$/i.test(value);
541
+ const isGitCommit = (value) => /^[\da-f]{40}$/i.test(value);
542
+ const isRecord = (value) => typeof value === "object" && value !== null;
543
+ const validatePointer = (issues, label, pointer) => {
544
+ if (!isRecord(pointer) || typeof pointer.path !== "string" || !pointer.path) issues.push(`${label} is missing an artifact path`);
545
+ if (!isRecord(pointer) || typeof pointer.sha256 !== "string" || !isSha256(pointer.sha256)) issues.push(`${label} is missing a SHA-256 digest`);
546
+ };
547
+ /** Validate a complete direct-Appium Android and iOS raw-device matrix. */
548
+ const validateRawMobileProof = ({ bundle, expectedCommit }) => {
549
+ const issues = [];
550
+ if (!isGitCommit(expectedCommit)) return {
551
+ issues: ["expectedCommit must be a 40-character Git commit"],
552
+ ok: false
553
+ };
554
+ if (!isRecord(bundle) || bundle.schemaVersion !== 1) return {
555
+ issues: ["Raw mobile proof bundle must use schemaVersion 1"],
556
+ ok: false
557
+ };
558
+ if (!Array.isArray(bundle.receipts)) return {
559
+ issues: ["Raw mobile proof bundle must contain a receipts array"],
560
+ ok: false
561
+ };
562
+ const seen = /* @__PURE__ */ new Set();
563
+ for (const [receiptIndex, receipt] of bundle.receipts.entries()) {
564
+ if (!isRecord(receipt)) {
565
+ issues.push(`Raw mobile receipt ${receiptIndex} must be an object`);
566
+ continue;
567
+ }
568
+ const { platform } = receipt;
569
+ const scenarioId = receipt.scenario;
570
+ const label = typeof platform === "string" && typeof scenarioId === "string" ? `${platform}/${scenarioId}` : `receipt ${receiptIndex}`;
571
+ const isSupportedPlatform = platform === "android-chrome" || platform === "ios-safari";
572
+ const expectedTransport = platform === "android-chrome" ? "appium-android" : "appium-ios";
573
+ const expectedBrowser = platform === "android-chrome" ? "Chrome" : "Safari";
574
+ const expectedOs = platform === "android-chrome" ? "Android" : "iOS";
575
+ const scenario = RAW_MOBILE_SCENARIOS.find((candidate) => candidate.id === scenarioId);
576
+ if (seen.has(label)) issues.push(`Duplicate raw mobile receipt ${label}`);
577
+ seen.add(label);
578
+ if (receipt.schemaVersion !== 1) issues.push(`${label} must use receipt schemaVersion 1`);
579
+ if (!isSupportedPlatform || !scenario) issues.push(`${label} has an unsupported platform or scenario`);
580
+ if (!receipt.directAppium || receipt.transport !== expectedTransport) issues.push(`${label} is not direct ${expectedTransport} proof`);
581
+ const { device } = receipt;
582
+ if (!isRecord(device) || device.realDevice !== true || device.osName !== expectedOs || typeof device.name !== "string" || !device.name || typeof device.model !== "string" || !device.model || typeof device.osVersion !== "string" || !device.osVersion) issues.push(`${label} is missing real-device identity`);
583
+ const { browser } = receipt;
584
+ if (!isRecord(browser) || browser.name !== expectedBrowser || typeof browser.version !== "string" || !browser.version) issues.push(`${label} is missing ${expectedBrowser} identity`);
585
+ const { build } = receipt;
586
+ if (!isRecord(build) || typeof build.appUrl !== "string" || !build.appUrl || typeof build.commit !== "string" || !build.commit || typeof receipt.capturedAt !== "string" || !Number.isFinite(Date.parse(receipt.capturedAt))) issues.push(`${label} is missing build or capture identity`);
587
+ else if (build.commit.toLowerCase() !== expectedCommit.toLowerCase()) issues.push(`${label} was captured from commit ${build.commit}; expected ${expectedCommit}`);
588
+ if (typeof receipt.receiptSha256 !== "string" || !isSha256(receipt.receiptSha256)) issues.push(`${label} is missing a receipt SHA-256 digest`);
589
+ if (!Array.isArray(receipt.replay) || receipt.replay.length === 0) issues.push(`${label} is missing replay steps`);
590
+ if (!Array.isArray(receipt.snapshots) || receipt.snapshots.length === 0) issues.push(`${label} is missing semantic snapshots`);
591
+ else {
592
+ receipt.snapshots.forEach((snapshot, index) => {
593
+ const snapshotLabel = `${label} snapshot ${index}`;
594
+ if (!isRecord(snapshot)) {
595
+ issues.push(`${snapshotLabel} must be an object`);
596
+ return;
597
+ }
598
+ if (!Array.isArray(snapshot.eventTrace) || snapshot.eventTrace.length === 0) issues.push(`${snapshotLabel} is missing an event trace`);
599
+ if (snapshot.modelText !== snapshot.domText) issues.push(`${snapshotLabel} model and DOM text diverge`);
600
+ if (snapshot.modelValue === void 0 || snapshot.nativeSelection == null || snapshot.semanticSelection == null) issues.push(`${snapshotLabel} is missing model or selection state`);
601
+ if (typeof snapshot.updateCount !== "number" || !Number.isInteger(snapshot.updateCount) || snapshot.updateCount < 0) issues.push(`${snapshotLabel} has an invalid update count`);
602
+ validatePointer(issues, `${snapshotLabel} screenshot`, snapshot.screenshot);
603
+ });
604
+ const finalSnapshot = receipt.snapshots.at(-1);
605
+ if (scenario && isRecord(finalSnapshot) && typeof finalSnapshot.updateCount === "number" && finalSnapshot.updateCount !== scenario.updateCount) issues.push(`${label} expected ${scenario.updateCount} semantic updates, got ${finalSnapshot.updateCount}`);
606
+ }
607
+ const { artifacts } = receipt;
608
+ validatePointer(issues, `${label} video`, isRecord(artifacts) ? artifacts.video : void 0);
609
+ }
610
+ for (const platform of ["android-chrome", "ios-safari"]) for (const scenario of RAW_MOBILE_SCENARIOS) {
611
+ const key = `${platform}/${scenario.id}`;
612
+ if (!seen.has(key)) issues.push(`Missing raw mobile receipt ${key}`);
613
+ }
614
+ return {
615
+ issues,
616
+ ok: issues.length === 0
617
+ };
618
+ };
619
+ /** Throw when a raw-device receipt bundle is incomplete or non-direct. */
620
+ const assertRawMobileProof = (options) => {
621
+ const result = validateRawMobileProof(options);
622
+ if (!result.ok) throw new Error(`EditorRoot raw mobile proof failed:\n${result.issues.map((issue) => `- ${issue}`).join("\n")}`);
623
+ return result;
624
+ };
625
+ //#endregion
626
+ //#region src/proof/selection.ts
627
+ /** Serialize a proof point as `path:offset`. */
628
+ const serializePoint = (point) => `${point.path.join(".")}:${point.offset}`;
629
+ /** Serialize a proof range as `anchor|focus`. */
630
+ const serializeRange = (range) => `${serializePoint(range.anchor)}|${serializePoint(range.focus)}`;
631
+ /** Return true when a proof range has the same anchor and focus point. */
632
+ const isCollapsed = (range) => range.anchor.offset === range.focus.offset && range.anchor.path.length === range.focus.path.length && range.anchor.path.every((segment, index) => segment === range.focus.path[index]);
633
+ //#endregion
634
+ export { BROWSER_FIRST_PARTY_FEATURE_CONTRACT_REGISTRY, BROWSER_FIRST_PARTY_INTENT_FAMILY_CONTRACTS, BROWSER_FIRST_PARTY_PARITY_FAMILIES, RAW_MOBILE_SCENARIOS, assertBrowserFirstPartyParityContracts, assertRawMobileProof, classifyBrowserMobileTransportProof, createBrowserFeatureContractRegistry, defineBrowserFeatureContract, evaluateImeInput, evaluatePlaceholderInput, extractAgentBrowserDebugSnapshot, extractAppiumDebugSnapshot, getBrowserMobileTransportProofMatrix, isCollapsed, parseAgentBrowserBatch, parseDebugSnapshot, serializePoint, serializeRange, validateRawMobileProof };
@@ -0,0 +1,50 @@
1
+ import { RenderResult } from "@testing-library/react";
2
+ import { BasePluginInput, CreateEditorOptions, Editor, EditorApplicationSchema, EditorContentProps, EditorRootProps, PluginInput, Value } from "platejs/react";
3
+ import React from "react";
4
+ //#region src/react/PlateTest.d.ts
5
+ type EditorTestProps<E extends Editor = Editor> = Omit<EditorRootProps<E>, 'children' | 'editor'> & {
6
+ editableProps?: EditorContentProps & {
7
+ [name: `data-${string}`]: boolean | number | string | undefined;
8
+ };
9
+ editor: E;
10
+ variant?: 'comment' | 'wordProcessor';
11
+ };
12
+ declare function EditorTest<E extends Editor = Editor>({ editableProps, editor, variant, ...props }: EditorTestProps<E>): React.JSX.Element;
13
+ //#endregion
14
+ //#region src/react/createPlateTestEditor.d.ts
15
+ type EditorTestHarnessOptions = {
16
+ componentProps?: Partial<React.ComponentProps<typeof EditorTest>>;
17
+ debug?: boolean;
18
+ };
19
+ type ClipboardDataType = 'image/png' | 'text/html' | 'text/plain';
20
+ type SharedPluginReference = Exclude<PluginInput, readonly unknown[]>;
21
+ type PasteOptions = {
22
+ types?: ClipboardDataType[];
23
+ };
24
+ type EditorTestActions = {
25
+ deleteBackward: () => Promise<void>;
26
+ deleteEntireSoftline: () => Promise<void>;
27
+ deleteForward: () => Promise<void>;
28
+ deleteHardLineBackward: () => Promise<void>;
29
+ deleteHardLineForward: () => Promise<void>;
30
+ deleteSoftLineBackward: () => Promise<void>;
31
+ deleteSoftLineForward: () => Promise<void>;
32
+ deleteWordBackward: () => Promise<void>;
33
+ deleteWordForward: () => Promise<void>;
34
+ paste: (payload: string, options?: PasteOptions) => Promise<void>;
35
+ pressEnter: () => Promise<void>;
36
+ redo: () => Promise<void>;
37
+ rerender: () => void;
38
+ selectAll: () => Promise<void>;
39
+ triggerKeyboardEvent: (hotkey: string) => Promise<void>;
40
+ type: (text: string) => Promise<void>;
41
+ typeSpace: () => Promise<void>;
42
+ undo: () => Promise<void>;
43
+ };
44
+ type EditorTestRenderResult = RenderResult;
45
+ type ReactTestEditor<TPlugins extends readonly SharedPluginReference[] = readonly [], TSchema extends EditorApplicationSchema | undefined = undefined> = Editor<Value, RuntimePluginsFromTuple<TPlugins>, PlatePluginsFromTuple<TPlugins>, TSchema>;
46
+ type PlatePluginsFromTuple<TPlugins extends readonly SharedPluginReference[]> = [TPlugins[number]] extends [BasePluginInput] ? Extract<TPlugins, readonly BasePluginInput[]> : [Extract<TPlugins[number], BasePluginInput>] extends [never] ? readonly [] : number extends TPlugins['length'] ? ReadonlyArray<Extract<TPlugins[number], BasePluginInput>> : TPlugins extends readonly [infer TPlugin, ...infer TRest] ? TPlugin extends BasePluginInput ? readonly [TPlugin, ...PlatePluginsFromTuple<Extract<TRest, readonly SharedPluginReference[]>>] : PlatePluginsFromTuple<Extract<TRest, readonly SharedPluginReference[]>> : readonly [];
47
+ type RuntimePluginsFromTuple<TPlugins extends readonly SharedPluginReference[]> = [TPlugins[number]] extends [BasePluginInput] ? readonly [] : [Extract<TPlugins[number], BasePluginInput>] extends [never] ? TPlugins : number extends TPlugins['length'] ? ReadonlyArray<Exclude<TPlugins[number], BasePluginInput>> : TPlugins extends readonly [infer TPlugin, ...infer TRest] ? TPlugin extends BasePluginInput ? RuntimePluginsFromTuple<Extract<TRest, readonly SharedPluginReference[]>> : TPlugin extends SharedPluginReference ? readonly [TPlugin, ...RuntimePluginsFromTuple<Extract<TRest, readonly SharedPluginReference[]>>] : RuntimePluginsFromTuple<Extract<TRest, readonly SharedPluginReference[]>> : readonly [];
48
+ declare const createTestEditor: <const TPlugins extends readonly SharedPluginReference[] = readonly [], const TSchema extends EditorApplicationSchema | undefined = undefined>(options: CreateEditorOptions<TPlugins, TSchema>, harnessOptions?: EditorTestHarnessOptions) => Promise<[ReactTestEditor<TPlugins, TSchema>, EditorTestActions, EditorTestRenderResult]>;
49
+ //#endregion
50
+ export { EditorTest, EditorTestActions, EditorTestHarnessOptions, EditorTestProps, EditorTestRenderResult, ReactTestEditor, createTestEditor };