@ctrl/dom 0.3.9 → 0.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -105
- package/dist/aria/_chunks/{aria-query.generated-BivoZ-ec.js → aria-query.generated-BG-n1PE9.js} +2 -2
- package/dist/aria/_chunks/{aria-query.generated-CeGmXXFh.cjs → aria-query.generated-BqD80bJk.cjs} +1 -1
- package/dist/aria/index.cjs +1 -1
- package/dist/aria/index.js +1 -1
- package/dist/aria/internal.cjs +1 -1
- package/dist/aria/internal.js +1 -1
- package/dist/aria/types/forms.d.ts +0 -2
- package/dist/bridge/internal.js +1 -1
- package/dist/dom/_chunks/src-B3vkUXY6.js +50 -0
- package/dist/dom/index.js +1 -1
- package/dist/dom/internal.js +1 -1
- package/dist/dom/types/collections/NodeList.d.ts +2 -0
- package/dist/dom/types/css/cascade.d.ts +5 -6
- package/dist/dom/types/css/media.d.ts +0 -2
- package/dist/dom/types/css/parser.d.ts +0 -2
- package/dist/dom/types/css/properties.d.ts +0 -2
- package/dist/dom/types/css/shorthands.d.ts +0 -2
- package/dist/dom/types/css/style-deps.d.ts +18 -4
- package/dist/dom/types/css/stylesheets.d.ts +14 -18
- package/dist/dom/types/css/values.d.ts +0 -1
- package/dist/dom/types/events/DataTransfer.d.ts +3 -2
- package/dist/dom/types/events/handler-names.d.ts +4 -0
- package/dist/dom/types/events/handlers.d.ts +1 -5
- package/dist/dom/types/events/listeners.d.ts +10 -7
- package/dist/dom/types/html/events.d.ts +14 -8
- package/dist/dom/types/html/focus.d.ts +0 -2
- package/dist/dom/types/html/forms/HTMLOptionElement.d.ts +8 -0
- package/dist/dom/types/html/forms/HTMLSelectElement.d.ts +20 -3
- package/dist/dom/types/html/forms/collections.d.ts +14 -2
- package/dist/dom/types/html/forms/control-state.d.ts +5 -0
- package/dist/dom/types/html/forms/face.d.ts +1 -2
- package/dist/dom/types/html/forms/form-associated.d.ts +4 -2
- package/dist/dom/types/html/forms/index.d.ts +1 -2
- package/dist/dom/types/html/forms/microsyntaxes.d.ts +0 -3
- package/dist/dom/types/html/forms/state.d.ts +0 -1
- package/dist/dom/types/html/reflect.d.ts +0 -4
- package/dist/dom/types/html/resources.d.ts +0 -2
- package/dist/dom/types/html/shared.d.ts +0 -2
- package/dist/dom/types/html/template.d.ts +0 -3
- package/dist/dom/types/html/top-layer.d.ts +26 -3
- package/dist/dom/types/keys.d.ts +19 -1
- package/dist/dom/types/nodes/Document.d.ts +11 -3
- package/dist/dom/types/nodes/attributes.d.ts +3 -0
- package/dist/dom/types/nodes/traverse.d.ts +10 -4
- package/dist/dom/types/observers/MutationObserver.d.ts +5 -5
- package/dist/dom/types/observers/MutationRecord.d.ts +2 -1
- package/dist/dom/types/observers/queue.d.ts +19 -20
- package/dist/dom/types/parser/index.d.ts +1 -1
- package/dist/dom/types/parser/tokenizer.d.ts +0 -2
- package/dist/dom/types/selectors/compile.d.ts +2 -2
- package/dist/dom/types/selectors/index.d.ts +2 -6
- package/dist/dom/types/selectors/internal.d.ts +3 -6
- package/dist/dom/types/selectors/parser.d.ts +0 -5
- package/dist/dom/types/selectors/state.d.ts +0 -5
- package/dist/dom/types/serializer/index.d.ts +0 -2
- package/dist/dom/types/traversal/Range.d.ts +1 -3
- package/dist/dom/types/traversal/live.d.ts +8 -4
- package/dist/dom/types/{events/convert.d.ts → webidl-convert.d.ts} +0 -2
- package/dist/dom/types/window/FileReader.d.ts +6 -2
- package/dist/dom/types/window/Storage.d.ts +16 -5
- package/dist/dom/types/window/Window.d.ts +2 -2
- package/dist/dom/types/window/clock.d.ts +21 -14
- package/dist/dom/types/window/devtools-console.d.ts +2 -0
- package/dist/dom/types/window/shared-accessors.d.ts +9 -0
- package/dist/dom/types/window/timers.d.ts +10 -6
- package/dist/jest-dom/_chunks/matchers-DGsBvtWC.js +1 -1
- package/dist/react/_chunks/pure-0apusBJy.cjs +1 -0
- package/dist/react/_chunks/pure-CRYsLxrp.js +1 -0
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.js +1 -1
- package/dist/react/pure.cjs +1 -1
- package/dist/react/pure.js +1 -1
- package/dist/react/types/config.d.ts +3 -1
- package/dist/react/types/fire-event.d.ts +1 -1
- package/dist/react/types/pure.d.ts +2 -2
- package/dist/testing-library/_chunks/aria-snapshot-diff-BSXxnyqJ.js +1 -1
- package/dist/testing-library/agent.js +1 -1
- package/dist/testing-library/index.js +1 -1
- package/dist/user-event/index.cjs +16 -16
- package/dist/user-event/index.js +16 -16
- package/dist/user-event/types/ctrl-dom.d.ts +0 -13
- package/dist/user-event/types/event/selection/selectBoundaries.d.ts +2 -0
- package/dist/user-event/types/pointer/index.d.ts +1 -1
- package/dist/user-event/types/pointer/parseKeyDef.d.ts +2 -5
- package/dist/user-event/types/setup/dtl.d.ts +0 -2
- package/dist/user-event/types/system/index.d.ts +2 -1
- package/dist/user-event/types/system/keyboard.d.ts +1 -1
- package/dist/user-event/types/system/pointer/device.d.ts +5 -4
- package/dist/user-event/types/utility/upload.d.ts +1 -4
- package/dist/user-event/types/utils/keyDef/readNextDescriptor.d.ts +1 -1
- package/dist/vitest-environment/failure-snapshot.js +1 -1
- package/dist/vitest-environment/plugin.js +1 -1
- package/dist/vitest-environment/types/warm-forks.d.ts +0 -7
- package/package.json +2 -3
- package/dist/dom/_chunks/src-DqpTBH8Z.js +0 -50
- package/dist/react/_chunks/pure-C0lYKcec.js +0 -1
- package/dist/react/_chunks/pure-xBh9btvi.cjs +0 -1
- package/dist/react/types/dtl.d.ts +0 -1
|
@@ -8,7 +8,7 @@ import { Location } from "./Location.js";
|
|
|
8
8
|
import { History } from "./History.js";
|
|
9
9
|
import { Navigator } from "./Navigator.js";
|
|
10
10
|
import { Screen, VisualViewport } from "./Screen.js";
|
|
11
|
-
import { type StorageShed, type Storage } from "./Storage.js";
|
|
11
|
+
import { type StorageShed, type Storage, StoragePeer } from "./Storage.js";
|
|
12
12
|
import { MediaQueryList } from "./media.js";
|
|
13
13
|
import { CookieJar } from "./cookies.js";
|
|
14
14
|
import "./document.js";
|
|
@@ -136,7 +136,7 @@ export declare class Window extends EventTarget {
|
|
|
136
136
|
readonly visualViewport?: VisualViewport;
|
|
137
137
|
[$localStorage]: Storage | null;
|
|
138
138
|
[$sessionStorage]: Storage | null;
|
|
139
|
-
[$shed]:
|
|
139
|
+
[$shed]: StoragePeer | null;
|
|
140
140
|
[$customElements]: unknown;
|
|
141
141
|
[$cookieJar]: CookieJar | null;
|
|
142
142
|
/** MediaQueryLists with change listeners (https://drafts.csswg.org/cssom-view/#evaluate-media-queries-and-report-changes). */
|
|
@@ -12,32 +12,35 @@ declare class TimerRecord {
|
|
|
12
12
|
ref: boolean;
|
|
13
13
|
/** Index in the heap, -1 when not scheduled (fired one-shot, cleared, real-time track). */
|
|
14
14
|
index: number;
|
|
15
|
-
|
|
15
|
+
clock: VirtualClock;
|
|
16
|
+
handle: VirtualTimeout;
|
|
16
17
|
/** Real host timer while on the real-time track (unref'd while skipping), else null. */
|
|
17
18
|
real: ReturnType<typeof setTimeout> | null;
|
|
18
19
|
/** realNow() at which `real` fires. */
|
|
19
20
|
realDue: number;
|
|
20
|
-
/**
|
|
21
|
-
cleared: boolean;
|
|
22
|
-
/**
|
|
23
|
-
* The async context setTimeout was called in (https://nodejs.org/api/async_context.html):
|
|
24
|
-
* Node runs a timer's callback in it, while this clock fires from its own host timer or driver.
|
|
25
|
-
* An AsyncResource, as Node's own Timeout is: ~0.015 µs to capture, 30x less than
|
|
26
|
-
* AsyncLocalStorage.snapshot()'s bound closure.
|
|
27
|
-
*/
|
|
21
|
+
/** The async context in which this timer was scheduled. */
|
|
28
22
|
context: AsyncResource;
|
|
29
|
-
constructor(id: number, due: number, seq: number, delay: number, repeat: boolean, callback: Callback, args: unknown[]);
|
|
23
|
+
constructor(clock: VirtualClock, id: number, due: number, seq: number, delay: number, repeat: boolean, callback: Callback, args: unknown[]);
|
|
24
|
+
invoke(): void;
|
|
25
|
+
}
|
|
26
|
+
/** Only completed one-shots need records outside the clock's active timer map. */
|
|
27
|
+
declare class FiredTimers {
|
|
28
|
+
records: WeakMap<VirtualTimeout, TimerRecord> | null;
|
|
30
29
|
}
|
|
30
|
+
declare const timerRecord: unique symbol;
|
|
31
|
+
declare const timerFired: unique symbol;
|
|
32
|
+
declare const timerCleared: unique symbol;
|
|
31
33
|
/** The handle setTimeout/setInterval return: Node's Timeout API surface. */
|
|
32
34
|
export declare class VirtualTimeout {
|
|
33
35
|
#private;
|
|
34
|
-
constructor(
|
|
36
|
+
constructor(_clock: VirtualClock, record: TimerRecord);
|
|
37
|
+
get [timerRecord](): TimerRecord | undefined;
|
|
38
|
+
[timerFired](record: TimerRecord, fired: FiredTimers): void;
|
|
39
|
+
[timerCleared](): void;
|
|
35
40
|
ref(): this;
|
|
36
41
|
unref(): this;
|
|
37
42
|
hasRef(): boolean;
|
|
38
|
-
/** Node's flag for a one-shot that ran or any cleared timer (window/timers.ts sweeps on it). */
|
|
39
43
|
get _destroyed(): boolean;
|
|
40
|
-
/** Restart the timer with its original delay from now. */
|
|
41
44
|
refresh(): this;
|
|
42
45
|
close(): this;
|
|
43
46
|
[Symbol.toPrimitive](): number;
|
|
@@ -52,13 +55,14 @@ export interface VirtualClockOptions {
|
|
|
52
55
|
* skips. One clock per window/test file; dispose() drops every pending timer.
|
|
53
56
|
*/
|
|
54
57
|
export declare class VirtualClock {
|
|
58
|
+
private fired;
|
|
55
59
|
/** ms added to real time by skipping. */
|
|
56
60
|
skipped: number;
|
|
57
61
|
/** Date.now() - performance.now() when the clock was created (epoch of now() = 0). */
|
|
58
62
|
epochOffset: number;
|
|
59
63
|
skip: boolean;
|
|
60
64
|
heap: TimerRecord[];
|
|
61
|
-
|
|
65
|
+
private indexed;
|
|
62
66
|
nextId: number;
|
|
63
67
|
seq: number;
|
|
64
68
|
refCount: number;
|
|
@@ -98,6 +102,8 @@ export declare class VirtualClock {
|
|
|
98
102
|
* animation frame runs after as many hops as it would in real time.
|
|
99
103
|
*/
|
|
100
104
|
schedule(callback: Callback, delay: unknown, args: unknown[], repeat: boolean): VirtualTimeout;
|
|
105
|
+
/** Most callers keep the handle. Build the numeric index when it or an off-heap timer needs it. */
|
|
106
|
+
get byId(): Map<number, TimerRecord>;
|
|
101
107
|
/** clearTimeout/clearInterval: a VirtualTimeout or its numeric id. Returns false for foreign handles. */
|
|
102
108
|
clear(handle: unknown): boolean;
|
|
103
109
|
/**
|
|
@@ -112,6 +118,7 @@ export declare class VirtualClock {
|
|
|
112
118
|
toRealTrack(record: TimerRecord, delay: number): void;
|
|
113
119
|
toVirtualTrack(record: TimerRecord): void;
|
|
114
120
|
fireReal(record: TimerRecord): void;
|
|
121
|
+
private complete;
|
|
115
122
|
_refresh(record: TimerRecord): void;
|
|
116
123
|
/** Drop every pending timer; the clock goes on (a test file ended in a worker the next one shares). */
|
|
117
124
|
clearAll(): void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** The descriptor to define for `key` on `o`: `desc`, or a shared pair standing for it. */
|
|
2
|
+
export declare function sharedAccessor(o: unknown, key: PropertyKey, desc: PropertyDescriptor): PropertyDescriptor;
|
|
3
|
+
/**
|
|
4
|
+
* Wrap `Object.defineProperty` of the realm whose `Object` is `O` (see the top of this file).
|
|
5
|
+
* Returns the undo; nested calls for one realm share the wrapper.
|
|
6
|
+
*/
|
|
7
|
+
export declare function shareAccessors(O: ObjectConstructor): () => void;
|
|
8
|
+
/** `O.defineProperty` without this file's wrapper, for a wrapper that calls `sharedAccessor` itself. */
|
|
9
|
+
export declare function unsharedDefineProperty(O: ObjectConstructor): ObjectConstructor["defineProperty"];
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import type { Window } from "./Window.js";
|
|
2
2
|
type ClearFunction = (handle: never) => void;
|
|
3
|
-
|
|
3
|
+
type TimerCallback = (this: unknown, ...args: unknown[]) => unknown;
|
|
4
|
+
interface PendingTimer extends TimerCallback {
|
|
5
|
+
callback: TimerCallback | null;
|
|
6
|
+
clear: ClearFunction | null;
|
|
7
|
+
handle: unknown;
|
|
8
|
+
}
|
|
4
9
|
export declare class TimerList {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
10
|
+
readonly timers: Set<WeakRef<PendingTimer>>;
|
|
11
|
+
readonly collected: FinalizationRegistry<WeakRef<PendingTimer>>;
|
|
12
|
+
/** Host extensions that accept a non-function handler have no callback to track weakly. */
|
|
13
|
+
other: Map<unknown, ClearFunction> | null;
|
|
8
14
|
}
|
|
9
|
-
/** Remember `handle` (created by a host whose clear function is `clear`) on `window`. */
|
|
10
|
-
export declare function trackTimer(window: Window, handle: unknown, clear: ClearFunction): void;
|
|
11
15
|
/** close(): clear every timer still pending on `window`. */
|
|
12
16
|
export declare function clearTimers(window: Window): void;
|
|
13
17
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createRequire as e}from"node:module";import{prettyDOM as t,queries as n}from"
|
|
1
|
+
import{createRequire as e}from"node:module";import{prettyDOM as t,queries as n}from"../../testing-library/index.js";import{daa06 as r,getImplicitAriaRolesJestDom as i,roles as a}from"../../aria/index.js";import{$impl as o,ELEMENT_NODE as s,F_HTML as c,asciiLowercase as l,computedValue as u,getAttribute as p,getComputedStyleOverride as ee}from"../../bridge/internal.js";import{AriaTemplateError as m,matchAriaSnapshot as h}from"../../testing-library/agent.js";var g=Object.defineProperty,__name=(e,t)=>g(e,`name`,{value:t,configurable:!0}),__exportAll=(e,t)=>{let n={};for(var r in e)g(n,r,{get:e[r],enumerable:!0});return t||g(n,Symbol.toStringTag,{value:`Module`}),n},GenericTypeError=class extends Error{constructor(e,t,n,r){super(),Error.captureStackTrace&&Error.captureStackTrace(this,n);let i=``;try{i=r.utils.printWithType(`Received`,t,r.utils.printReceived)}catch{}this.message=[r.utils.matcherHint(`${r.isNot?`.not`:``}.${n.name}`,`received`,``),``,`${r.utils.RECEIVED_COLOR(`received`)} value must ${e}.`,i].join(`
|
|
2
2
|
`)}},HtmlElementTypeError=class extends GenericTypeError{constructor(e,t,n){super(`be an HTMLElement or an SVGElement`,e,t,n)}},NodeTypeError=class extends GenericTypeError{constructor(e,t,n){super(`be a Node`,e,t,n)}};function checkHasWindow(e,t,n,r){if(!e||!e.ownerDocument||!e.ownerDocument.defaultView)throw new t(e,n,r)}function checkNode(e,t,n){if(checkHasWindow(e,NodeTypeError,t,n),!(e instanceof e.ownerDocument.defaultView.Node))throw new NodeTypeError(e,t,n)}function checkHtmlElement(e,t,n){checkHasWindow(e,HtmlElementTypeError,t,n);let r=e.ownerDocument.defaultView;if(!(e instanceof r.HTMLElement)&&!(e instanceof r.SVGElement))throw new HtmlElementTypeError(e,t,n)}var InvalidCSSError=class extends Error{constructor(e,t,n){super(),Error.captureStackTrace&&Error.captureStackTrace(this,t),this.message=[e.message,``,n.utils.RECEIVED_COLOR(`Failing css:`),n.utils.RECEIVED_COLOR(`${e.css}`)].join(`
|
|
3
3
|
`)}};let _=null;function parseCSS(t,n,r){_??=e(import.meta.url)(`@adobe/css-tools`).parse;let i=_(`selector { ${t} }`,{silent:!0}).stylesheet;if(i.parsingErrors&&i.parsingErrors.length>0){let{reason:e,line:a}=i.parsingErrors[0];throw new InvalidCSSError({css:t,message:`Syntax error parsing expected css: ${e} on line: ${a}`},n,r)}let a={},o=i.rules[0].declarations;for(let e=0;e<o.length;e++){let t=o[e];t.type===`declaration`&&(a[t.property]=t.value)}return a}function display(e,t){return typeof t==`string`?t:e.utils.stringify(t)}function getMessage(e,t,n,r,i,a){return[`${t}\n`,`${n}:\n${e.utils.EXPECTED_COLOR(redent(display(e,r),2))}`,`${i}:\n${e.utils.RECEIVED_COLOR(redent(display(e,a),2))}`].join(`
|
|
4
4
|
`)}function matches(e,t){return t instanceof RegExp?t.test(e):e.includes(String(t))}function deprecate(e,t){console.warn(`Warning: ${e} has been deprecated and will be removed in future updates.`,t)}function normalize(e){return e.replace(/\s+/g,` `).trim()}function getTag(e){return e.tagName&&e.tagName.toLowerCase()}function getSelectValue({multiple:e,options:t}){let n=[];for(let e=0;e<t.length;e++)t[e].selected&&n.push(t[e]);if(e)return n.map(e=>e.value);if(n.length!==0)return n[0].value}function getInputValue(e){switch(e.type){case`number`:return e.value===``?null:Number(e.value);case`checkbox`:return e.checked;default:return e.value}}const v=[`meter`,`progressbar`,`slider`,`spinbutton`];function getAccessibleValue(e){if(v.includes(e.getAttribute(`role`)))return Number(e.getAttribute(`aria-valuenow`))}function getSingleElementValue(e){if(e)switch(e.tagName.toLowerCase()){case`input`:return getInputValue(e);case`select`:return getSelectValue(e);default:return e.value??getAccessibleValue(e)}}function toSentence(e,{wordConnector:t=`, `,lastWordConnector:n=` and `}={}){return[e.slice(0,-1).join(t),e[e.length-1]].join(e.length>1?n:``)}function compareAsSet(e,t){if(Array.isArray(e)&&Array.isArray(t)){let n=new Set(t);return[...new Set(e)].every(e=>n.has(e))}return e===t}function redent(e,t){let n=e.match(/^[ \t]*(?=\S)/gm),r=0;n&&(r=n.reduce((e,t)=>Math.min(e,t.length),1/0));let i=r>0?e.replace(RegExp(`^[ \\t]{${r}}`,`gm`),``):e;return t===0?i:i.replace(/^(?!\s*$)/gm,` `.repeat(t))}const y=process.env,b=process.argv,x=!(y.NO_COLOR||b.includes(`--no-color`))&&(!!y.FORCE_COLOR||b.includes(`--color`)||process.platform===`win32`||process.stdout?.isTTY&&y.TERM!==`dumb`||!!y.CI);function picoRed(e){if(!x)return String(e);let t=`\x1B[31m`,n=`\x1B[39m`,r=``+e,i=r.indexOf(n,5);if(i===-1)return t+r+n;let a=``,o=0;do a+=r.substring(o,i)+t,o=i+5,i=r.indexOf(n,o);while(i!==-1);return t+a+r.substring(o)+n}const S=[`alt text`,`display value`,`label text`,`placeholder text`,`role`,`test ID`,`text`,`title`];function toPascalCase(e){return e.split(` `).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(``)}function createQueryMatcher(e,r){let i=toPascalCase(r),a=`toContain${e}By${i}`,o=n[`queryAllBy${i}`];function queryMatcher(n,...i){checkHtmlElement(n,queryMatcher,this);let s=o(n,...i);return{message:()=>{let n=this.isNot?`not to`:`to`,o=this.utils.matcherHint(`${this.isNot?`.not`:``}.${a}`,`element`,r,{secondArgument:i[1]===void 0?void 0:this.utils.printExpected(i[1])}),c=[getMessage(this,o,`Expected element ${n} contain ${e.toLowerCase()} descendant by ${r}`,i[0],`Received`,s.length)],l=s.map(e=>t(e)).filter(e=>typeof e==`string`);return l.length&&c.push(`Here are the matching elements:`,...l),c.join(`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.defineProperty,t=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,r=Object.getPrototypeOf,i=Object.prototype.hasOwnProperty,__exportAll=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r},__copyProps=(r,a,o,s)=>{if(a&&typeof a==`object`||typeof a==`function`)for(var c=n(a),l=0,u=c.length,d;l<u;l++)d=c[l],!i.call(r,d)&&d!==o&&e(r,d,{get:(e=>a[e]).bind(null,d),enumerable:!(s=t(a,d))||s.enumerable});return r},__reExport=(e,t,n)=>(__copyProps(e,t,`default`),n&&__copyProps(n,t,`default`)),__toESM=(t,n,a)=>(a=t==null?{}:{__proto__:r(t)},__copyProps(n||!t||!t.__esModule||!i.call(t,`default`)?e(a,`default`,{value:t,enumerable:!0}):a,t));let a=require("react");a=__toESM(a,1);let o=require("@ctrl/dom/testing-library"),s=require("@ctrl/dom/internal"),c=require("react-dom/client");c=__toESM(c,1);let l={reactStrictMode:!1,releaseSuspendedWork:!0};function releaseSuspendedWorkEnabled(){return l.releaseSuspendedWork}function reactStrictModeEnabled(){return l.reactStrictMode}function getConfig(){return{...(0,o.getConfig)(),...l}}function configure(e){typeof e==`function`&&(e=e(getConfig()));let{reactStrictMode:t,releaseSuspendedWork:n,...r}=e;(0,o.configure)(r),l={...l,reactStrictMode:t,releaseSuspendedWork:n??l.releaseSuspendedWork}}const u=a.act;function setReactActEnvironment(e){globalThis.IS_REACT_ACT_ENVIRONMENT=e}function getIsReactActEnvironment(){return globalThis.IS_REACT_ACT_ENVIRONMENT}const d=a.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,f=/* @__PURE__ */ new Set;function flushReleasingSuspendedWork(e){let t=!1,n=0;try{for(;n<e.length;n++){let r=e[n];for(;r!==null;)if(d.didUsePromise=!1,r=r(!1),r!==null&&d.didUsePromise){t=!0;break}}e.length=0}catch(t){e.splice(0,n+1),d.thrownErrors.unshift(t)}if(t)for(let e of f){let t=e._internalRoot,n=t?.callbackNode;n!=null&&n.callback===void 0&&(t.callbackNode=null,t.callbackPriority=0)}if(d.thrownErrors.length>0)return d.thrownErrors.splice(0)}function isThenable(e){return typeof e==`object`&&!!e&&typeof e.then==`function`}function withGlobalActEnvironment(e){return t=>{let n=getIsReactActEnvironment();setReactActEnvironment(!0);try{let r=!1,i=e(()=>{let e=t();return isThenable(e)&&(r=!0),e});if(r){let e=i;return{then:(t,r)=>{e.then(e=>{setReactActEnvironment(n),t(e)},e=>{setReactActEnvironment(n),r(e)})}}}return setReactActEnvironment(n),i}catch(e){throw setReactActEnvironment(n),e}}}const p=withGlobalActEnvironment(u);function actReleasingSuspendedWork(e){let t=getIsReactActEnvironment();setReactActEnvironment(!0);let n;try{if(d.actQueue!==null||!releaseSuspendedWorkEnabled()){u(e);return}u(()=>{let t=d.actQueue;e(),n=flushReleasingSuspendedWork(t)})}catch(e){if(n===void 0)throw e;n.push(e)}finally{setReactActEnvironment(t)}if(n!==void 0){if(n.length===1)throw n[0];if(n.length>1)throw AggregateError(n)}}const fireEvent=((...e)=>(0,o.fireEvent)(...e)),m=fireEvent,h=o.fireEvent;for(let e of Object.keys(o.fireEvent))m[e]=(...t)=>h[e](...t);const g=m.mouseEnter,_=m.mouseLeave;m.mouseEnter=(...e)=>(g(...e),m.mouseOver(...e)),m.mouseLeave=(...e)=>(_(...e),m.mouseOut(...e));const v=m.pointerEnter,y=m.pointerLeave;m.pointerEnter=(...e)=>(v(...e),m.pointerOver(...e)),m.pointerLeave=(...e)=>(y(...e),m.pointerOut(...e));const b=m.select;m.select=(e,t)=>{b(e,t),e.focus(),m.keyUp(e,t)};const x=m.blur,S=m.focus;m.blur=(...e)=>(m.focusOut(...e),x(...e)),m.focus=(...e)=>(m.focusIn(...e),S(...e));function advanceFakeTimersIfEnabled(){if(typeof jest<`u`&&jest!==null){(setTimeout._isMockFunction===!0||Object.prototype.hasOwnProperty.call(setTimeout,`clock`))&&jest.advanceTimersByTime(0);return}let e=setTimeout.clock;typeof e?.tick==`function`&&e.tick(0)}function drainWithTimer(e){setTimeout(()=>{e()},0),advanceFakeTimersIfEnabled()}async function finishAsyncWrapper(e,t){try{let t=await e;return await new Promise(e=>{(0,s.canSkipZeroDelayWait)(globalThis)?(0,s.loopTurn)(()=>(0,s.skipZeroDelayWait)(globalThis)?e():drainWithTimer(e)):drainWithTimer(e)}),t}finally{setReactActEnvironment(t)}}let C=!1;(0,o.configure)({unstable_advanceTimersWrapper:e=>p(e),asyncWrapper:e=>{let t=getIsReactActEnvironment();setReactActEnvironment(!1);try{return finishAsyncWrapper(e(),t)}catch(e){return setReactActEnvironment(t),Promise.reject(e)}},eventWrapper:e=>{if(C)return e();C=!0;try{let t;return actReleasingSuspendedWork(()=>{t=e()}),t}finally{C=!1}}});const w=/* @__PURE__ */ new WeakMap,T=[],E=/* @__PURE__ */ new WeakMap,D=/* @__PURE__ */ new WeakMap;function strictModeIfNeeded(e,t){return t??reactStrictModeEnabled()?a.createElement(a.StrictMode,null,e):e}function wrapUiIfNeeded(e,t){return t?a.createElement(t,null,e):e}function createConcurrentRoot(e,{hydrate:t,onCaughtError:n,onRecoverableError:r,ui:i,wrapper:a,reactStrictMode:o}){let s;if(t)try{actReleasingSuspendedWork(()=>{s=c.hydrateRoot(e,strictModeIfNeeded(wrapUiIfNeeded(i,a),o),{onCaughtError:n,onRecoverableError:r}),f.add(s)})}catch(e){throw f.delete(s),e}else s=c.createRoot(e,{onCaughtError:n,onRecoverableError:r}),f.add(s);return wrapRoot(s,t)}function wrapRoot(e,t){return{hydrate(){if(!t)throw Error("Attempted to hydrate a non-hydrateable root. This is a bug in `@testing-library/react`.")},render(t){e.render(t)},unmount(){try{e.unmount()}finally{f.delete(e)}}}}const O=/* @__PURE__ */ new WeakMap;function resultTemplateFor(e){let t=O.get(e);return t===void 0&&(t={container:void 0,baseElement:void 0,debug:void 0,unmount:void 0,rerender:void 0,asFragment:void 0,...(0,o.getQueriesForElement)(e)},O.set(e,t)),t}function actRender(e,t,n,r,i){actReleasingSuspendedWork(()=>{n?t.hydrate():t.render(strictModeIfNeeded(wrapUiIfNeeded(e,r),i))})}function renderRoot(e,{baseElement:t,container:n,hydrate:r,queries:i,root:a,wrapper:c,reactStrictMode:l}){actRender(e,a,r,c,l);let debug=(e=t,n,r)=>Array.isArray(e)?e.forEach(e=>console.log((0,o.prettyDOM)(e,n,r))):console.log((0,o.prettyDOM)(e,n,r)),unmount=()=>{p(()=>{a.unmount()})},rerender=e=>{let rerender=()=>actRender(e,a,!1,c,l);(0,s.tracing)()?(0,s.traceSync)(`react.rerender`,`rerender(${describeElement(e)})`,rerender):rerender()},asFragment=()=>{if(typeof document.createRange==`function`)return document.createRange().createContextualFragment(n.innerHTML);let e=document.createElement(`template`);return e.innerHTML=n.innerHTML,e.content};if(i!==void 0)return{container:n,baseElement:t,debug,unmount,rerender,asFragment,...(0,o.getQueriesForElement)(t,i)};let u={...resultTemplateFor(t)};return u.container=n,u.baseElement=t,u.debug=debug,u.unmount=unmount,u.rerender=rerender,u.asFragment=asFragment,u}function legacyRootError(e){let t=/* @__PURE__ */ Error("`legacyRoot: true` is not supported in this version of React. If your app runs React 19 or later, you should remove this flag. If your app runs React 18 or earlier, visit https://react.dev/blog/2022/03/08/react-18-upgrade-guide for upgrade instructions.");return Error.captureStackTrace(t,e),t}function render(e,t){return(0,s.tracing)()?(0,s.traceSync)(`react.render`,`render(${describeElement(e)})`,()=>renderUntraced(e,t)):renderUntraced(e,t)}function describeElement(e){if(!a.isValidElement(e))return typeof e==`string`?JSON.stringify(e):String(e);let t=e;for(let e=0;e<10;e++){let e=isWrapper(t)?wrappedElement(t):null;if(e===null)break;t=e}return describeTree(t,0)}function describeTree(e,t){let n=componentName(e.type)||`Component`;if(typeof e.type!=`string`)return`<${n} />`;let r=e.props.children;if(r==null||r===!1)return`<${n} />`;let i=onlyElement(r);return i!==null&&t<2?`<${n}>${describeTree(i,t+1)}</${n}>`:`<${n}>…</${n}>`}function componentName(e){if(typeof e==`string`)return e;if(typeof e==`symbol`)return e.description?.replace(/^react\./,``)??``;let t=e;return(t?.displayName??t?.name??t?.render?.name??t?.type?.name??``).replace(/\$\d+$/,``)}const k=/(?:Providers?|Context|Router|Wrapper|Fragment|StrictMode|Suspense|Profiler)$/;function isWrapper(e){if(typeof e.type==`symbol`)return!0;let t=componentName(e.type);return k.test(t)||t===``&&onlyElement(e.props.children)!==null}function wrappedElement(e){let t=e.props;return onlyElement(t.children)??firstRouteElement(t.router?.routes)}function firstRouteElement(e){for(let t of e??[]){let e=onlyElement(t.element);if(e!==null&&componentName(e.type)!==`Outlet`)return e;let n=firstRouteElement(t.children);if(n!==null)return n}return null}function onlyElement(e){if(a.isValidElement(e))return e;if(!Array.isArray(e))return null;let t=e.filter(e=>a.isValidElement(e));return t.length===1?t[0]:null}function renderUntraced(e,{container:t,baseElement:n=t,legacyRoot:r=!1,onCaughtError:i,onUncaughtError:a,onRecoverableError:o,queries:c,hydrate:l=!1,wrapper:u,reactStrictMode:d}={}){if(a!==void 0)throw Error("onUncaughtError is not supported. The `render` call will already throw on uncaught errors.");if(r)throw legacyRootError(render);n||=document.body;let f=!1;if(!t){let e=E.get(document);for(;e?.length&&!t;)t=e.pop().deref();f=!t,t=n.appendChild(t??document.createElement(`div`))}let p=w.get(t);return p===void 0&&(p=createConcurrentRoot(t,{hydrate:l,onCaughtError:i,onRecoverableError:o,ui:e,wrapper:u,reactStrictMode:d}),f&&D.set(t,{listeners:(0,s.listenerCount)(t),keys:Object.keys(t).length}),w.set(t,p),T.push(new WeakRef(t))),renderRoot(e,{container:t,baseElement:n,queries:c,hydrate:l,wrapper:u,root:p,reactStrictMode:d})}function cleanup(){let e;for(let t of T){let n=t.deref();if(n===void 0)continue;let r=w.get(n);if(r!==void 0){try{p(()=>r.unmount())}catch(t){(e??=[]).push(t),D.delete(n)}try{removeContainer(n,t)}catch(t){(e??=[]).push(t)}w.delete(n)}}if(T.length=0,e!==void 0)throw e.length===1?e[0]:AggregateError(e,`React cleanup failed`)}function removeContainer(e,t){if(e.parentNode!==document.body)return;document.body.removeChild(e);let n=D.get(e);if(n!==void 0&&(e.onclick=null,(0,s.reusableElement)(e,n.listeners)&&Object.keys(e).length===n.keys)){let e=E.get(document);e===void 0&&E.set(document,e=[]),e.length<8&&e.push(t)}}(0,s.registerTestHooks)(`react`,{fileEnd(){try{cleanup()}finally{dropHoistedResources()}}});function dropHoistedResources(){for(let e of Object.keys(document)){if(!e.startsWith(`__reactResources$`))continue;let t=document[e];for(let e of[t?.hoistableStyles,t?.hoistableScripts])if(e instanceof Map)for(let t of e.values()){let e=t?.instance??t;typeof e?.remove==`function`&&e.remove()}delete document[e]}}function renderHook(e,t={}){let{initialProps:n,...r}=t;if(r.legacyRoot)throw legacyRootError(renderHook);let i=a.createRef();function TestComponent({renderCallbackProps:t}){let n=e(t);return a.useEffect(()=>{i.current=n}),null}let{rerender:o,unmount:s}=render(a.createElement(TestComponent,{renderCallbackProps:n}),r);function rerender(e){return o(a.createElement(TestComponent,{renderCallbackProps:e}))}return{result:i,rerender,unmount:s}}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return configure}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return __reExport}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return fireEvent}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return getConfig}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return render}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return getIsReactActEnvironment}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return renderHook}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return setReactActEnvironment}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return cleanup}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return __exportAll}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as e from"react";import{configure as t,fireEvent as n,getConfig as r,getQueriesForElement as i,prettyDOM as a}from"../../testing-library/index.js";import{canSkipZeroDelayWait as o,listenerCount as s,loopTurn as c,registerTestHooks as l,reusableElement as u,skipZeroDelayWait as d,traceSync as f,tracing as p}from"../../bridge/internal.js";import*as m from"react-dom/client";var h=Object.defineProperty,__name=(e,t)=>h(e,`name`,{value:t,configurable:!0}),g=Object.getOwnPropertyDescriptor,_=Object.getOwnPropertyNames,v=Object.prototype.hasOwnProperty,__exportAll=(e,t)=>{let n={};for(var r in e)h(n,r,{get:e[r],enumerable:!0});return t||h(n,Symbol.toStringTag,{value:`Module`}),n},__copyProps=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=_(t),a=0,o=i.length,s;a<o;a++)s=i[a],!v.call(e,s)&&s!==n&&h(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=g(t,s))||r.enumerable});return e},__reExport=(e,t,n)=>(__copyProps(e,t,`default`),n&&__copyProps(n,t,`default`));let y={reactStrictMode:!1,releaseSuspendedWork:!0};function releaseSuspendedWorkEnabled(){return y.releaseSuspendedWork}function reactStrictModeEnabled(){return y.reactStrictMode}function getConfig$1(){return{...r(),...y}}__name(getConfig$1,`getConfig`);function configure$1(e){typeof e==`function`&&(e=e(getConfig$1()));let{reactStrictMode:n,releaseSuspendedWork:r,...i}=e;t(i),y={...y,reactStrictMode:n,releaseSuspendedWork:r??y.releaseSuspendedWork}}__name(configure$1,`configure`);const b=e.act;function setReactActEnvironment(e){globalThis.IS_REACT_ACT_ENVIRONMENT=e}function getIsReactActEnvironment(){return globalThis.IS_REACT_ACT_ENVIRONMENT}const x=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,S=/* @__PURE__ */ new Set;function flushReleasingSuspendedWork(e){let t=!1,n=0;try{for(;n<e.length;n++){let r=e[n];for(;r!==null;)if(x.didUsePromise=!1,r=r(!1),r!==null&&x.didUsePromise){t=!0;break}}e.length=0}catch(t){e.splice(0,n+1),x.thrownErrors.unshift(t)}if(t)for(let e of S){let t=e._internalRoot,n=t?.callbackNode;n!=null&&n.callback===void 0&&(t.callbackNode=null,t.callbackPriority=0)}if(x.thrownErrors.length>0)return x.thrownErrors.splice(0)}function isThenable(e){return typeof e==`object`&&!!e&&typeof e.then==`function`}function withGlobalActEnvironment(e){return t=>{let n=getIsReactActEnvironment();setReactActEnvironment(!0);try{let r=!1,i=e(()=>{let e=t();return isThenable(e)&&(r=!0),e});if(r){let e=i;return{then:(t,r)=>{e.then(e=>{setReactActEnvironment(n),t(e)},e=>{setReactActEnvironment(n),r(e)})}}}return setReactActEnvironment(n),i}catch(e){throw setReactActEnvironment(n),e}}}const C=withGlobalActEnvironment(b);function actReleasingSuspendedWork(e){let t=getIsReactActEnvironment();setReactActEnvironment(!0);let n;try{if(x.actQueue!==null||!releaseSuspendedWorkEnabled()){b(e);return}b(()=>{let t=x.actQueue;e(),n=flushReleasingSuspendedWork(t)})}catch(e){if(n===void 0)throw e;n.push(e)}finally{setReactActEnvironment(t)}if(n!==void 0){if(n.length===1)throw n[0];if(n.length>1)throw AggregateError(n)}}const w=/* @__PURE__ */ __name(((...e)=>n(...e)),`fireEvent`),T=w,E=n;for(let e of Object.keys(n))T[e]=(...t)=>E[e](...t);const D=T.mouseEnter,O=T.mouseLeave;T.mouseEnter=(...e)=>(D(...e),T.mouseOver(...e)),T.mouseLeave=(...e)=>(O(...e),T.mouseOut(...e));const k=T.pointerEnter,A=T.pointerLeave;T.pointerEnter=(...e)=>(k(...e),T.pointerOver(...e)),T.pointerLeave=(...e)=>(A(...e),T.pointerOut(...e));const j=T.select;T.select=(e,t)=>{j(e,t),e.focus(),T.keyUp(e,t)};const M=T.blur,N=T.focus;T.blur=(...e)=>(T.focusOut(...e),M(...e)),T.focus=(...e)=>(T.focusIn(...e),N(...e));function advanceFakeTimersIfEnabled(){if(typeof jest<`u`&&jest!==null){(setTimeout._isMockFunction===!0||Object.prototype.hasOwnProperty.call(setTimeout,`clock`))&&jest.advanceTimersByTime(0);return}let e=setTimeout.clock;typeof e?.tick==`function`&&e.tick(0)}function drainWithTimer(e){setTimeout(()=>{e()},0),advanceFakeTimersIfEnabled()}async function finishAsyncWrapper(e,t){try{let t=await e;return await new Promise(e=>{o(globalThis)?c(()=>d(globalThis)?e():drainWithTimer(e)):drainWithTimer(e)}),t}finally{setReactActEnvironment(t)}}let P=!1;t({unstable_advanceTimersWrapper:e=>C(e),asyncWrapper:e=>{let t=getIsReactActEnvironment();setReactActEnvironment(!1);try{return finishAsyncWrapper(e(),t)}catch(e){return setReactActEnvironment(t),Promise.reject(e)}},eventWrapper:e=>{if(P)return e();P=!0;try{let t;return actReleasingSuspendedWork(()=>{t=e()}),t}finally{P=!1}}});const F=/* @__PURE__ */ new WeakMap,I=[],L=/* @__PURE__ */ new WeakMap,R=/* @__PURE__ */ new WeakMap;function strictModeIfNeeded(t,n){return n??reactStrictModeEnabled()?e.createElement(e.StrictMode,null,t):t}function wrapUiIfNeeded(t,n){return n?e.createElement(n,null,t):t}function createConcurrentRoot(e,{hydrate:t,onCaughtError:n,onRecoverableError:r,ui:i,wrapper:a,reactStrictMode:o}){let s;if(t)try{actReleasingSuspendedWork(()=>{s=m.hydrateRoot(e,strictModeIfNeeded(wrapUiIfNeeded(i,a),o),{onCaughtError:n,onRecoverableError:r}),S.add(s)})}catch(e){throw S.delete(s),e}else s=m.createRoot(e,{onCaughtError:n,onRecoverableError:r}),S.add(s);return wrapRoot(s,t)}function wrapRoot(e,t){return{hydrate(){if(!t)throw Error("Attempted to hydrate a non-hydrateable root. This is a bug in `@testing-library/react`.")},render(t){e.render(t)},unmount(){try{e.unmount()}finally{S.delete(e)}}}}const z=/* @__PURE__ */ new WeakMap;function resultTemplateFor(e){let t=z.get(e);return t===void 0&&(t={container:void 0,baseElement:void 0,debug:void 0,unmount:void 0,rerender:void 0,asFragment:void 0,...i(e)},z.set(e,t)),t}function actRender(e,t,n,r,i){actReleasingSuspendedWork(()=>{n?t.hydrate():t.render(strictModeIfNeeded(wrapUiIfNeeded(e,r),i))})}function renderRoot(e,{baseElement:t,container:n,hydrate:r,queries:o,root:s,wrapper:c,reactStrictMode:l}){actRender(e,s,r,c,l);let debug=(e=t,n,r)=>Array.isArray(e)?e.forEach(e=>console.log(a(e,n,r))):console.log(a(e,n,r)),unmount=()=>{C(()=>{s.unmount()})},rerender=e=>{let rerender=()=>actRender(e,s,!1,c,l);p()?f(`react.rerender`,`rerender(${describeElement(e)})`,rerender):rerender()},asFragment=()=>{if(typeof document.createRange==`function`)return document.createRange().createContextualFragment(n.innerHTML);let e=document.createElement(`template`);return e.innerHTML=n.innerHTML,e.content};if(o!==void 0)return{container:n,baseElement:t,debug,unmount,rerender,asFragment,...i(t,o)};let u={...resultTemplateFor(t)};return u.container=n,u.baseElement=t,u.debug=debug,u.unmount=unmount,u.rerender=rerender,u.asFragment=asFragment,u}function legacyRootError(e){let t=/* @__PURE__ */ Error("`legacyRoot: true` is not supported in this version of React. If your app runs React 19 or later, you should remove this flag. If your app runs React 18 or earlier, visit https://react.dev/blog/2022/03/08/react-18-upgrade-guide for upgrade instructions.");return Error.captureStackTrace(t,e),t}function render(e,t){return p()?f(`react.render`,`render(${describeElement(e)})`,()=>renderUntraced(e,t)):renderUntraced(e,t)}function describeElement(t){if(!e.isValidElement(t))return typeof t==`string`?JSON.stringify(t):String(t);let n=t;for(let e=0;e<10;e++){let e=isWrapper(n)?wrappedElement(n):null;if(e===null)break;n=e}return describeTree(n,0)}function describeTree(e,t){let n=componentName(e.type)||`Component`;if(typeof e.type!=`string`)return`<${n} />`;let r=e.props.children;if(r==null||r===!1)return`<${n} />`;let i=onlyElement(r);return i!==null&&t<2?`<${n}>${describeTree(i,t+1)}</${n}>`:`<${n}>…</${n}>`}function componentName(e){if(typeof e==`string`)return e;if(typeof e==`symbol`)return e.description?.replace(/^react\./,``)??``;let t=e;return(t?.displayName??t?.name??t?.render?.name??t?.type?.name??``).replace(/\$\d+$/,``)}const B=/(?:Providers?|Context|Router|Wrapper|Fragment|StrictMode|Suspense|Profiler)$/;function isWrapper(e){if(typeof e.type==`symbol`)return!0;let t=componentName(e.type);return B.test(t)||t===``&&onlyElement(e.props.children)!==null}function wrappedElement(e){let t=e.props;return onlyElement(t.children)??firstRouteElement(t.router?.routes)}function firstRouteElement(e){for(let t of e??[]){let e=onlyElement(t.element);if(e!==null&&componentName(e.type)!==`Outlet`)return e;let n=firstRouteElement(t.children);if(n!==null)return n}return null}function onlyElement(t){if(e.isValidElement(t))return t;if(!Array.isArray(t))return null;let n=t.filter(t=>e.isValidElement(t));return n.length===1?n[0]:null}function renderUntraced(e,{container:t,baseElement:n=t,legacyRoot:r=!1,onCaughtError:i,onUncaughtError:a,onRecoverableError:o,queries:c,hydrate:l=!1,wrapper:u,reactStrictMode:d}={}){if(a!==void 0)throw Error("onUncaughtError is not supported. The `render` call will already throw on uncaught errors.");if(r)throw legacyRootError(render);n||=document.body;let f=!1;if(!t){let e=L.get(document);for(;e?.length&&!t;)t=e.pop().deref();f=!t,t=n.appendChild(t??document.createElement(`div`))}let p=F.get(t);return p===void 0&&(p=createConcurrentRoot(t,{hydrate:l,onCaughtError:i,onRecoverableError:o,ui:e,wrapper:u,reactStrictMode:d}),f&&R.set(t,{listeners:s(t),keys:Object.keys(t).length}),F.set(t,p),I.push(new WeakRef(t))),renderRoot(e,{container:t,baseElement:n,queries:c,hydrate:l,wrapper:u,root:p,reactStrictMode:d})}function cleanup(){let e;for(let t of I){let n=t.deref();if(n===void 0)continue;let r=F.get(n);if(r!==void 0){try{C(()=>r.unmount())}catch(t){(e??=[]).push(t),R.delete(n)}try{removeContainer(n,t)}catch(t){(e??=[]).push(t)}F.delete(n)}}if(I.length=0,e!==void 0)throw e.length===1?e[0]:AggregateError(e,`React cleanup failed`)}function removeContainer(e,t){if(e.parentNode!==document.body)return;document.body.removeChild(e);let n=R.get(e);if(n!==void 0&&(e.onclick=null,u(e,n.listeners)&&Object.keys(e).length===n.keys)){let e=L.get(document);e===void 0&&L.set(document,e=[]),e.length<8&&e.push(t)}}l(`react`,{fileEnd(){try{cleanup()}finally{dropHoistedResources()}}});function dropHoistedResources(){for(let e of Object.keys(document)){if(!e.startsWith(`__reactResources$`))continue;let t=document[e];for(let e of[t?.hoistableStyles,t?.hoistableScripts])if(e instanceof Map)for(let t of e.values()){let e=t?.instance??t;typeof e?.remove==`function`&&e.remove()}delete document[e]}}function renderHook(t,n={}){let{initialProps:r,...i}=n;if(i.legacyRoot)throw legacyRootError(renderHook);let a=e.createRef();function TestComponent({renderCallbackProps:n}){let r=t(n);return e.useEffect(()=>{a.current=r}),null}let{rerender:o,unmount:s}=render(e.createElement(TestComponent,{renderCallbackProps:r}),i);function rerender(t){return o(e.createElement(TestComponent,{renderCallbackProps:t}))}return{result:a,rerender,unmount:s}}export{C as a,configure$1 as c,__reExport as d,w as i,getConfig$1 as l,render as n,getIsReactActEnvironment as o,renderHook as r,setReactActEnvironment as s,cleanup as t,__exportAll as u};
|
package/dist/react/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./_chunks/pure-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./_chunks/pure-0apusBJy.cjs");let t=require("@ctrl/dom/internal");if((typeof process>`u`||!process.env?.RTL_SKIP_AUTO_CLEANUP)&&(typeof afterEach==`function`?(afterEach(()=>{e.t()}),(0,t.registerTestHooks)(`react`,{afterEach:e.t})):typeof teardown==`function`&&teardown(()=>{e.t()}),typeof beforeAll==`function`&&typeof afterAll==`function`)){let n=e.o(),enterActEnvironment=()=>{n=e.o(),e.s(!0)},leaveActEnvironment=()=>{e.s(n)};beforeAll(enterActEnvironment),afterAll(leaveActEnvironment),(0,t.registerTestHooks)(`react`,{beforeAll:enterActEnvironment,afterAll:leaveActEnvironment})}exports.act=e.a,exports.cleanup=e.t,exports.configure=e.c,exports.fireEvent=e.i,exports.getConfig=e.l,exports.render=e.n,exports.renderHook=e.r;var n=require("@ctrl/dom/testing-library");Object.keys(n).forEach(function(e){e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:function(){return n[e]}})});
|
package/dist/react/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,c as t,
|
|
1
|
+
import{a as e,c as t,i as n,l as r,n as i,o as a,r as o,s,t as c}from"./_chunks/pure-CRYsLxrp.js";import{registerTestHooks as l}from"../bridge/internal.js";export*from"../testing-library/index.js";if((typeof process>`u`||!process.env?.RTL_SKIP_AUTO_CLEANUP)&&(typeof afterEach==`function`?(afterEach(()=>{c()}),l(`react`,{afterEach:c})):typeof teardown==`function`&&teardown(()=>{c()}),typeof beforeAll==`function`&&typeof afterAll==`function`)){let e=a(),enterActEnvironment=()=>{e=a(),s(!0)},leaveActEnvironment=()=>{s(e)};beforeAll(enterActEnvironment),afterAll(leaveActEnvironment),l(`react`,{beforeAll:enterActEnvironment,afterAll:leaveActEnvironment})}export{e as act,c as cleanup,t as configure,n as fireEvent,r as getConfig,i as render,o as renderHook};
|
package/dist/react/pure.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./_chunks/pure-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./_chunks/pure-0apusBJy.cjs");exports.act=e.a,exports.cleanup=e.t,exports.configure=e.c,exports.fireEvent=e.i,exports.getConfig=e.l,exports.render=e.n,exports.renderHook=e.r;var t=require("@ctrl/dom/testing-library");Object.keys(t).forEach(function(e){e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})});
|
package/dist/react/pure.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export{a as act,t as cleanup,c as configure,i as fireEvent,l as getConfig,n as render,r as renderHook}from"./_chunks/pure-CRYsLxrp.js";export*from"../testing-library/index.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Config as ConfigDTL } from "
|
|
1
|
+
import { type Config as ConfigDTL } from "@ctrl/dom/testing-library";
|
|
2
2
|
export interface Config extends ConfigDTL {
|
|
3
3
|
reactStrictMode: boolean;
|
|
4
4
|
/**
|
|
@@ -14,5 +14,7 @@ export interface ConfigFn {
|
|
|
14
14
|
}
|
|
15
15
|
/** `releaseSuspendedWork` without building the merged config (read on every RTL act). */
|
|
16
16
|
export declare function releaseSuspendedWorkEnabled(): boolean;
|
|
17
|
+
/** `reactStrictMode`, likewise (read on every render and rerender). */
|
|
18
|
+
export declare function reactStrictModeEnabled(): boolean | undefined;
|
|
17
19
|
export declare function getConfig(): Config;
|
|
18
20
|
export declare function configure(newConfig: ConfigFn | Partial<Config>): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import * as ReactDOMClient from "react-dom/client";
|
|
3
|
-
import { type BoundFunction, type PrettyDOMOptions, type Queries, type prettyFormat, type queries } from "
|
|
3
|
+
import { type BoundFunction, type PrettyDOMOptions, type Queries, type prettyFormat, type queries } from "@ctrl/dom/testing-library";
|
|
4
4
|
import act from "./act-compat.js";
|
|
5
5
|
import { fireEvent } from "./fire-event.js";
|
|
6
6
|
import { getConfig, configure, type Config, type ConfigFn } from "./config.js";
|
|
@@ -132,5 +132,5 @@ export declare function cleanup(): void;
|
|
|
132
132
|
* component yourself.
|
|
133
133
|
*/
|
|
134
134
|
export declare function renderHook<Result, Props, Q extends Queries = typeof queries, Container extends RendererableContainer | HydrateableContainer = DOMElement, BaseElement extends RendererableContainer | HydrateableContainer = Container>(renderCallback: (initialProps: Props) => Result, options?: RenderHookOptions<Props, Q, Container, BaseElement> | undefined): RenderHookResult<Result, Props>;
|
|
135
|
-
export * from "
|
|
135
|
+
export * from "@ctrl/dom/testing-library";
|
|
136
136
|
export { act, fireEvent, getConfig, configure, type Config, type ConfigFn };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createRequire as e}from"node:module";import{$impl as t,COMMENT_NODE as n,DOCUMENT_FRAGMENT_NODE as r,DOCUMENT_NODE as i,ELEMENT_NODE as a,HTML_NS as o,SVG_NS as s,T as c,TEXT_NODE as l,ariaAttr as u,attr as d,matches as f,serializeNode as p,setFailureSnapshot as m}from"
|
|
1
|
+
import{createRequire as e}from"node:module";import{$impl as t,COMMENT_NODE as n,DOCUMENT_FRAGMENT_NODE as r,DOCUMENT_NODE as i,ELEMENT_NODE as a,HTML_NS as o,SVG_NS as s,T as c,TEXT_NODE as l,ariaAttr as u,attr as d,matches as f,serializeNode as p,setFailureSnapshot as m}from"../../bridge/internal.js";import{ariaCheckedState as h,ariaPressedState as g,computeAccessibleNameImpl as _,computeAriaBusy as v,computeAriaCurrent as y,computeAriaExpanded as b,computeAriaSelected as x,computeHeadingLevel as ee,isDisabledImpl as te,isDisplayInline as ne,isDisplayNone as S,isInaccessibleImpl as C,isSubtreeInaccessibleImpl as w,isVisibilityHidden as T,tlRole as E}from"../../aria/internal.js";import{readFileSync as D}from"node:fs";import{roleSupportsProp as O}from"../../aria/index.js";var k=Object.defineProperty,__name=(e,t)=>k(e,`name`,{value:t,configurable:!0});const A=new URL(`./`,import.meta.url).pathname;let j=null;const M=process.env,N=process.argv,P=!(M.NO_COLOR||N.includes(`--no-color`))&&(!!M.FORCE_COLOR||N.includes(`--color`)||process.platform===`win32`||process.stdout?.isTTY&&M.TERM!==`dumb`||!!M.CI);function dim(e){return P?`\x1b[2m${e}\x1b[22m`:e}function getCodeFrame(t){j??=e(import.meta.url)(`@babel/code-frame`).codeFrameColumns;let n=t.indexOf(`(`)+1,r=t.indexOf(`)`),i=t.slice(n,r),a=i.split(`:`),[o,s,c]=[a[0],parseInt(a[1],10),parseInt(a[2],10)],l=``;try{l=D(o,`utf-8`)}catch{return``}let u=j(l,{start:{line:s,column:c-1}},{highlightCode:!0,linesBelow:0});return`${dim(i)}\n${u}\n`}function getUserCodeFrame(){return getCodeFrame((/* @__PURE__ */ Error()).stack.split(`
|
|
2
2
|
`).slice(1).find(e=>!e.includes(`node_modules/`)&&!e.includes(A)))}function jestFakeTimersAreEnabled(){if(typeof jest<`u`&&jest!==null)return setTimeout._isMockFunction===!0||Object.hasOwn(setTimeout,`clock`);let e=setTimeout.clock;return e!=null&&typeof e.tick==`function`}function advanceFakeTimersByTime(e){if(typeof jest<`u`&&jest!==null){jest.advanceTimersByTime(e);return}let t=globalThis.vi;t!=null&&typeof t.advanceTimersByTime==`function`&&typeof t.isFakeTimers==`function`&&t.isFakeTimers()?t.advanceTimersByTime(e):setTimeout.clock.tick(e)}function getDocument(){if(typeof window>`u`)throw Error(`Could not find default container`);return window.document}function getWindowFromNode(e){if(e.defaultView)return e.defaultView;if(e.ownerDocument&&e.ownerDocument.defaultView)return e.ownerDocument.defaultView;if(e.window)return e.window;throw e.ownerDocument&&e.ownerDocument.defaultView===null?Error(`It looks like the window object is not available for the provided node.`):e.then instanceof Function?Error("It looks like you passed a Promise object instead of a DOM node. Did you do something like `fireEvent.click(screen.findBy...` when you meant to use a `getBy` query `fireEvent.click(screen.getBy...`, or await the findBy query `fireEvent.click(await screen.findBy...`?"):Array.isArray(e)?Error("It looks like you passed an Array instead of a DOM node. Did you do something like `fireEvent.click(screen.getAllBy...` when you meant to use a `getBy` query `fireEvent.click(screen.getBy...`?"):typeof e.debug==`function`&&typeof e.logTestingPlaygroundURL==`function`?Error("It looks like you passed a `screen` object. Did you do something like `fireEvent.click(screen, ...` when you meant to use a query, e.g. `fireEvent.click(screen.getBy..., `?"):Error(`The given node is not an Element, the node type is: ${typeof e}.`)}function checkContainerType(e){if(!e||typeof e.querySelector!=`function`||typeof e.querySelectorAll!=`function`)throw TypeError(`Expected container to be an Element, a Document or a DocumentFragment but got ${getTypeName(e)}.`)}function getTypeName(e){return typeof e==`object`?e===null?`null`:e.constructor.name:typeof e}function implOf(e){let n=e[t];if(n===void 0)throw TypeError(`@ctrl/dom/testing-library requires nodes created by @ctrl/dom.`);return n}function matchesSelector(e,t){return e.type===a&&f(e,t)}function envDebugFormat(){let e=typeof process<`u`?process.env?.CTRL_DOM_DEBUG:void 0;if(e===void 0||e===``)return null;let t=String(e).trim().toLowerCase();return t===`aria`?`aria`:t===`compact`||t===`html`?`compact`:null}function containerLabel(e){let n=e?.[t];return n===void 0?`the container`:n.type===9?`the document`:describeElement(n)}function agentErrorContext(e,t,n){return t===`aria`?`Accessibility snapshot of ${containerLabel(e)} (CTRL_DOM_DEBUG=aria):\n${ariaSnapshot(e,{maxLines:envMaxLines()??100})}`:`DOM of ${containerLabel(e)} without class/style/SVG internals (CTRL_DOM_DEBUG=compact):\n${n(e,void 0,{format:`compact`})}`}function agentElementSummary(e){return ariaSnapshot(e,{maxLines:12})}function envMaxLines(){let e=typeof process<`u`?process.env?.CTRL_DOM_DEBUG_LINES:void 0,t=e?Number(e):NaN;return t>0?t:void 0}function ariaSnapshot(e,t={}){let{header:n,lines:r,empty:i}=ariaSnapshotLines(e,t);return i===null?n+budgetLines(r,t.maxLines??envMaxLines()??200).join(`
|
|
3
3
|
`):n+i}m(e=>ariaSnapshot(e,{maxLines:2e3}));function buildTree(e,t){let n=rootImpl(e),r=new SnapshotContext(n,t),i=[],o=``;return!r.includeHidden&&n.type===a&&C(n)&&(o=`# hidden from the accessibility tree: ${hiddenReason(n)}\n`,r.includeHidden=!0,r.forceHidden=!0),n.type===a&&n!==bodyOf(n)?r.visitElement(n,i,r.forceHidden):r.visitChildren(n,i,!1,!1),finishChildren(i,null),{root:n,ctx:r,children:i,header:o}}function ariaSnapshotTree(e,t={}){return buildTree(e,t).children}function ariaSnapshotLines(e,t={}){let{root:n,ctx:r,children:i,header:a}=buildTree(e,t),o=[];r.renderList(i,``,o);let s=o.length>0?null:r.sawHidden?`# no accessible content (hidden elements exist: pass { hidden: true })`:`# no accessible content`;return n===bodyOf(n)&&envDebugFormat()!==null&&recordBodySnapshot(n.doc,s??o.join(`
|
|
4
4
|
`)),{header:a,lines:o,empty:s}}function budgetLines(e,t){if(e.length<=t)return e;let n=e.length-t,r=e.slice(0,t);return r.push(`# … ${n} more line${n===1?``:`s`} (raise maxLines or CTRL_DOM_DEBUG_LINES)`),r}const F=Symbol.for(`ctrl-dom.agent.lastBodySnapshot`);function recordBodySnapshot(e,t){e!=null&&Object.defineProperty(e,F,{value:t,configurable:!0,writable:!0,enumerable:!1})}function lastBodySnapshot(e){return e?.[F]}function resetBodySnapshot(e){e!=null&&Object.hasOwn(e,F)&&delete e[F]}function rootImpl(e){let n=e??getDocument().body,r=n?.[t];if(r===void 0)throw TypeError(`Expected an element, document or fragment but got ${n===null?`null`:typeof n}`);if(r.type===i||r.tag===c.html&&r.ns===o){let e=r.doc?.body;return e?e[t]:r}return r}function bodyOf(e){let n=e.doc?.body;return n?n[t]:null}function normalizeSpace(e){return e.replace(/[\t\n\f\r ]+/g,` `)}function truncate(e,t){return e.length>t?e.slice(0,Math.max(1,t-1))+`…`:e}function quote(e){return JSON.stringify(e)}const I=/^$|^[\s\-?:,[\]{}#&*!|>'"%@`]|[\s]$|:$|: | #|^(true|false|null|yes|no|on|off|~)$|^[-+]?(\d+\.?\d*|\.\d+)(e[-+]?\d+)?$/i;function yamlValue(e){return I.test(e)?quote(e):e}function nodeKey(e,t){let n=e.role;e.name!==``&&(n+=` `+quote(truncate(e.name,t)));for(let t=0;t<e.props.length;t++)n+=` `+e.props[t];return n}function describeElement(e){let t=e.name;if(e.id!==``)return`<${t} id="${e.id}">`;let n=d(e,`data-testid`);return n===null?`<${t}>`:`<${t} data-testid="${n}">`}function hiddenReason(e){let t=hiddenChainReason(e);return t===``?T(e)?`visibility: hidden on ${describeElement(e)}`:``:t}function hiddenChainReason(e){for(let t=e;t!==null&&t.type===a;t=t.parent){if(t.ns===o&&d(t,`hidden`)!==null)return`hidden attribute on ${describeElement(t)}`;if(u(t,`aria-hidden`)===`true`)return`aria-hidden="true" on ${describeElement(t)}`;if(S(t))return`display: none on ${describeElement(t)}`}return``}const L=/* @__PURE__ */ new Set([``,`generic`,`none`,`presentation`]);function isSkippedTag(e){if(e.ns!==o)return!1;switch(e.tag){case c.script:case c.style:case c.template:case c.noscript:case c.head:return!0}return!1}function nodeProps(e,t,n,r){let i=[];if(O(t,`aria-checked`)){let t=h(e);t===!0?i.push(`[checked]`):t===`mixed`&&i.push(`[checked=mixed]`)}te(e)&&i.push(`[disabled]`);let a=b(e);a===!0?i.push(`[expanded]`):a===!1&&i.push(`[expanded=false]`),n&&i.push(`[active]`);let o=t===`heading`?ee(e):levelAttr(e);o!==void 0&&i.push(`[level=${o}]`);let s=g(e);s===!0?i.push(`[pressed]`):s===`mixed`?i.push(`[pressed=mixed]`):s===!1&&i.push(`[pressed=false]`),x(e)===!0&&i.push(`[selected]`);let c=y(e);return c===!0?i.push(`[current]`):typeof c==`string`&&c!==``&&i.push(`[current=${c}]`),v(e)&&i.push(`[busy]`),r&&i.push(`[hidden]`),i}function levelAttr(e){let t=u(e,`aria-level`),n=t===null?NaN:Number(t);return n>0?n:void 0}const R=/* @__PURE__ */ new Set([`textbox`,`searchbox`,`combobox`,`spinbutton`,`slider`,`progressbar`,`meter`,`scrollbar`,`separator`]);function nodeValue(e,t){if(!R.has(t))return null;let n=u(e,`aria-valuetext`);if(n!==null)return n;let r=u(e,`aria-valuenow`);if(r!==null)return r;if(e.ns!==o)return null;if(e.tag===c.input||e.tag===c.textarea){let t=String(e.node.value??``);return t===``?null:t}return null}var SnapshotContext=class{includeHidden;forceHidden=!1;sawHidden=!1;maxText;collapseAfter;urls;active;constructor(e,n){this.includeHidden=n.hidden===!0,this.maxText=n.maxTextLength??100,this.collapseAfter=n.collapseAfter??5,this.urls=n.urls===!0;let r=e.doc?.activeElement,i=r?r[t]??null:null;this.active=i!==null&&i===bodyOf(e)?null:i}visitChildren(e,t,n,i){for(let o=e.first;o!==null;o=o.next)o.type===l?i||appendText(t,o.data):o.type===a?this.visitElement(o,t,n):o.type===r&&this.visitChildren(o,t,n,i)}visitElement(e,t,n){if(isSkippedTag(e))return;let r=n;if(!r&&w(e)){if(this.sawHidden=!0,!this.includeHidden)return;r=!0}let i=r;if(!r&&T(e)){if(this.sawHidden=!0,!this.includeHidden){this.visitChildren(e,t,!1,!0);return}i=!0}let a=E(e);if(L.has(a)){let n=!ne(e);n&&appendBreak(t),this.visitChildren(e,t,r,!1),n&&appendBreak(t);return}let s={role:a,name:normalizeSpace(_(e,void 0,5)).trim(),props:nodeProps(e,a,e===this.active,i&&this.includeHidden),value:nodeValue(e,a),url:null,children:[],element:e};this.urls&&a===`link`&&(s.url=d(e,`href`)),(e.ns!==o||e.tag!==c.textarea)&&this.visitChildren(e,s.children,r,!1),finishChildren(s.children,s.name),t.push(s)}renderList(e,t,n){for(let r=0;r<e.length;r++){let i=e[r];if(typeof i==`string`){n.push(`${t}- text: ${yamlValue(truncate(i,this.maxText))}`);continue}let a=1;for(;r+a<e.length&&typeof e[r+a]!=`string`&&e[r+a].role===i.role;)a++;if(a>this.collapseAfter+1){for(let i=0;i<this.collapseAfter;i++)this.renderNode(e[r+i],t,n);n.push(`${t}- ${i.role} … (+${a-this.collapseAfter} more)`),r+=a-1}else this.renderNode(i,t,n)}}renderNode(e,t,n){let r=nodeKey(e,this.maxText),i=e.children;if(e.url===null&&(i.length===0||i.length===1&&typeof i[0]==`string`&&e.value===null)){let a=e.value??(i.length===1?i[0]:null);n.push(a===null?`${t}- ${r}`:`${t}- ${r}: ${yamlValue(truncate(a,this.maxText))}`);return}n.push(e.value===null?`${t}- ${r}:`:`${t}- ${r}: ${yamlValue(truncate(e.value,this.maxText))}`);let a=t+` `;e.url!==null&&n.push(`${a}- /url: ${yamlValue(e.url)}`),this.renderList(i,a,n)}};function appendText(e,t){if(t===``)return;let n=e.length-1;n>=0&&typeof e[n]==`string`&&e[n]!==`\0`?e[n]=e[n]+t:e.push(t)}function appendBreak(e){let t=e.length-1;t>=0&&typeof e[t]==`string`&&e[t]!==`\0`&&e.push(`\0`)}function finishChildren(e,t){let n=0;for(let t=0;t<e.length;t++){let r=e[t];typeof r==`string`&&(r===`\0`||(r=normalizeSpace(r).trim(),r===``))||(e[n++]=r)}e.length=n,e.length>0&&typeof e[0]==`string`&&e[0]===t&&e.splice(0,1),n=0;for(let t=0;t<e.length;t++){let r=e[t];(typeof r!=`string`||!labels(e[t-1],r)&&!labels(e[t+1],r))&&(e[n++]=r)}e.length=n}const z=/* @__PURE__ */ new Set([`textbox`,`searchbox`,`combobox`,`listbox`,`checkbox`,`radio`,`switch`,`slider`,`spinbutton`,`meter`,`progressbar`]);function labels(e,t){return e!==void 0&&typeof e!=`string`&&e.name===t&&z.has(e.role)}let B=null;function loadPrettyFormat(t){if(B!==null)return B;try{return B=e(import.meta.url)(`pretty-format`)}catch(e){throw Error(`${t} needs pretty-format, which @ctrl/dom does not install: add pretty-format@27 to the project's devDependencies.`,{cause:e})}}const V=`The prettyFormat export`,H=Object.defineProperties({},{format:{enumerable:!0,get:()=>loadPrettyFormat(V).format},default:{enumerable:!0,get:()=>loadPrettyFormat(V).default},plugins:{enumerable:!0,get:()=>loadPrettyFormat(V).plugins},DEFAULT_OPTIONS:{enumerable:!0,get:()=>loadPrettyFormat(V).DEFAULT_OPTIONS}}),shouldHighlight=()=>{if(typeof process>`u`)return!1;let e;try{let t=process.env?.COLORS;t&&(e=JSON.parse(t))}catch{}return typeof e==`boolean`?e:process.versions!==void 0&&process.versions.node!==void 0};function filterCommentsAndDefaultIgnoreTagsTags(e){return e.nodeType!==n&&(e.nodeType!==a||!e.matches(getConfig().defaultIgnore))}const U={open:``,close:``},W={comment:U,content:U,prop:U,tag:U,value:U},G={reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29],black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39],gray:[90,39],grey:[90,39],bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49],bgGray:[100,49],bgGrey:[100,49]},K={comment:`gray`,content:`reset`,prop:`yellow`,tag:`cyan`,value:`green`};function highlightColors(e){let t={};for(let n of Object.keys(K)){let r=e!==void 0&&e[n]!==void 0?e[n]:K[n],i=typeof r==`string`&&Object.hasOwn(G,r)?G[r]:void 0;if(i===void 0)throw Error(`pretty-format: Option "theme" has a key "${n}" whose value "${r}" is undefined in ansi-styles.`);t[n]={open:`\u001b[${i[0]}m`,close:`\u001b[${i[1]}m`}}return t}const q=highlightColors(void 0),J=/* @__PURE__ */ new Set([`callToJSON`,`compareKeys`,`escapeRegex`,`escapeString`,`highlight`,`indent`,`maxDepth`,`min`,`plugins`,`printBasicPrototype`,`printFunctionName`,`theme`]),Y=Symbol(`delegate`),X=/^((HTML|SVG)\w*)?Element$/,Z=/* @__PURE__ */ new WeakMap;function isCustomElement(e){let{tagName:t}=e;return!!(typeof t==`string`&&t.includes(`-`)||typeof e.hasAttribute==`function`&&e.hasAttribute(`is`))}function pluginHandles(e){let t=e.node,i=t.constructor,o=i?.name;switch(e.type){case a:{if(!o&&!isCustomElement(t))return!1;if(typeof i!=`function`)return X.test(o)||isCustomElement(t);let e=Z.get(i);return e===void 0&&Z.set(i,e=X.test(o)),e||isCustomElement(t)}case l:return o===`Text`;case n:return o===`Comment`;case r:return o===`DocumentFragment`}return!1}function escapeHTML(e){return e.indexOf(`<`)===-1&&e.indexOf(`>`)===-1?e:e.replace(/</g,`<`).replace(/>/g,`>`)}function printString(e,t){return t.escapeString?`"`+e.replace(/"|\\/g,`\\$&`)+`"`:`"`+e+`"`}function keepChild(e,t){return t.filterNode===null?e.type===n?!1:e.type===a?t.scriptStyleIgnore?e.name!==`script`&&e.name!==`style`:!matchesSelector(e,t.defaultIgnore):!0:!!t.filterNode(e.node)}function tagNameLower(e){return e.node.tagName.toLowerCase()}function printProps(e,t,n){let r=e.attrs;if(r===null||r.length===0)return``;let i=[],a=/* @__PURE__ */ new Map;for(let n=0;n<r.length;n++)t.compact&&isNoiseAttribute(e,r[n].name)||(i.push(r[n].name),a.set(r[n].name,r[n].value));i.sort();let o=t.colors,s=``;for(let e=0;e<i.length;e++){let r=i[e];s+=t.spacingInner+n+o.prop.open+r+o.prop.close+`=`+o.value.open+printString(a.get(r),t)+o.value.close}return s}function isNoiseAttribute(e,t){return t===`class`||t===`style`||e.ns===s&&t!==`role`&&t!==`id`&&!t.startsWith(`aria-`)&&!t.startsWith(`data-`)}function printChildren(e,t,n,r){if(t.compact&&e.ns===s&&e.name===`svg`)return``;let i=``;for(let a=e.first;a!==null;a=a.next)keepChild(a,t)&&(t.compact&&a.type===l&&a.data.trim()===``||(i+=t.spacingOuter+n+printNode(a,t,n,r)));return i}function printElement(e,t,n,r,i){let a=r.colors.tag;return a.open+`<`+e+(t&&a.close+t+r.spacingOuter+i+a.open)+(n?`>`+a.close+n+r.spacingOuter+i+a.open+`</`+e:(t&&!r.min?``:` `)+`/`)+`>`+a.close}function printNode(e,t,i,a){if(!pluginHandles(e))throw Y;if(e.type===l){let n=t.compact&&e.data.length>200?e.data.slice(0,199)+`…`:e.data;return t.colors.content.open+escapeHTML(n)+t.colors.content.close}if(e.type===n){let n=t.colors.comment;return n.open+`<!--`+escapeHTML(e.data)+`-->`+n.close}let o=e.type===r?`DocumentFragment`:tagNameLower(e),s=t.colors.tag;if(++a>t.maxDepth)return s.open+`<`+o+s.close+` …`+s.open+` />`+s.close;let c=i+t.indent;return printElement(o,e.type===r?``:printProps(e,t,c),printChildren(e,t,c,a),t,i)}function printForeignNode(e,t,i,a,o){if(!foreignHandles(e))throw Y;if(e.nodeType===l)return t.colors.content.open+escapeHTML(e.data)+t.colors.content.close;if(e.nodeType===n)return t.colors.comment.open+`<!--`+escapeHTML(e.data)+`-->`+t.colors.comment.close;let s=e.nodeType===r,c=s?`DocumentFragment`:e.tagName.toLowerCase(),u=t.colors.tag;if(++o>t.maxDepth)return u.open+`<`+c+u.close+` …`+u.open+` />`+u.close;let d=a+t.indent,f=``;if(!s){let n=Array.from(e.attributes);n.sort((e,t)=>e.name<t.name?-1:+(e.name>t.name));for(let{name:e,value:r}of n)f+=t.spacingInner+d+t.colors.prop.open+e+t.colors.prop.close+`=`+t.colors.value.open+printString(r,t)+t.colors.value.close}let p=``,m=e.childNodes||e.children;for(let e=0;e<m.length;e++)i(m[e])&&(p+=t.spacingOuter+d+printForeignNode(m[e],t,i,d,o));return printElement(c,f,p,t,a)}function foreignHandles(e){let t=e?.constructor?.name;if(!t&&!isCustomElement(e))return!1;switch(e.nodeType){case a:return X.test(t)||isCustomElement(e);case l:return t===`Text`;case n:return t===`Comment`;case r:return t===`DocumentFragment`}return!1}function makePrintConfig(e,t){for(let t of Object.keys(e))if(!J.has(t))throw Error(`pretty-format: Unknown option "${t}".`);if(e.min&&e.indent!==void 0&&e.indent!==0)throw Error(`pretty-format: Options "min" and "indent" cannot be used together.`);if(e.theme!==void 0){if(e.theme===null)throw Error(`pretty-format: Option "theme" must not be null.`);if(typeof e.theme!=`object`)throw Error(`pretty-format: Option "theme" must be of type "object" but instead received "${typeof e.theme}".`)}if(e.plugins!==void 0)return null;let n=!!e.min,r=e.indent===void 0?2:e.indent,i=getConfig().defaultIgnore;return{colors:e.highlight?e.theme===void 0?q:highlightColors(e.theme):W,escapeString:e.escapeString===void 0||e.escapeString,indent:n?``:Array(r+1).join(` `),maxDepth:e.maxDepth===void 0?1/0:e.maxDepth,min:n,spacingInner:n?` `:`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{S as e,b as t,d as n,f as r,g as i,l as a,m as o,n as s,s as c,t as l,u,w as d,x as f,y as p}from"./_chunks/aria-snapshot-diff-BSXxnyqJ.js";import{$impl as m}from"
|
|
1
|
+
import{S as e,b as t,d as n,f as r,g as i,l as a,m as o,n as s,s as c,t as l,u,w as d,x as f,y as p}from"./_chunks/aria-snapshot-diff-BSXxnyqJ.js";import{$impl as m}from"../bridge/internal.js";import{roleSupportsProp as h}from"../aria/index.js";var AriaTemplateError=class extends Error{constructor(e,t,n,r=-1){super(`${e} (template line ${t+1}):\n\n${n}${r>=0?`\n${` `.repeat(r)}^`:``}`),this.name=`AriaTemplateError`}};function normalizeWhitespace(e){return e.replace(/[]/g,``).replace(/[\r\n\s\t]+/g,` `).trim()}function textValue(e){let t=null;if(e.length>1&&e.startsWith(`/`)&&e.endsWith(`/`))try{t=new RegExp(e.slice(1,-1))}catch{t=null}return{raw:e,normalized:normalizeWhitespace(e),regex:t}}const g=/* @__PURE__ */ new Set([`disabled`,`expanded`,`active`,`selected`,`busy`,`hidden`]);function parseAriaTemplate(e){let t=e.split(/\r?\n/),n=1/0;for(let e=0;e<t.length;e++){let r=t[e],i=r.trim();if(i===``||i.startsWith(`#`))continue;let a=r.length-r.trimStart().length;if(r.slice(0,a).includes(` `))throw new AriaTemplateError(`Tabs cannot be used for indentation`,e,r);a<n&&(n=a)}let r={kind:`role`,role:`fragment`,name:null,attrs:[],url:null,mode:null,children:[]};if(n===1/0)throw new AriaTemplateError(`The aria snapshot template is empty`,0,e);let i=[{indent:-1,node:r,line:-1}];for(let e=0;e<t.length;e++){let r=t[e],a=r.trim();if(a===``||a.startsWith(`#`))continue;let o=r.length-r.trimStart().length-n;if(a!==`-`&&!a.startsWith(`- `))throw new AriaTemplateError(`Aria snapshot must be a YAML sequence, elements starting with "-"`,e,r,o+n);for(;i[i.length-1].indent>=o;)i.pop();let s=i[i.length-1];if(s.node===null)throw new AriaTemplateError(`"- text:" on line ${s.line+1} cannot have children`,e,r,o+n);let c=a.slice(2).trimStart(),l=r.length-c.length,u=parseItem(c,s.node,e,r,l);u!==void 0&&i.push({indent:o,node:u,line:e})}return r.children.length===1&&(r.mode===null||r.mode===`contain`)&&r.url===null?r.children[0]:r}function parseItem(e,t,n,r,i){let fail=(e,t)=>{throw new AriaTemplateError(e,n,r,i+t)};if(e===``&&fail(`Empty sequence item`,0),e.startsWith(`/`)){let n=e.indexOf(`:`);n<0&&fail("Property should be written `/name: value`",e.length);let r=e.slice(1,n).trim(),i=parseScalar(e.slice(n+1),fail,n+1);r===`children`?(i!==`contain`&&i!==`equal`&&i!==`deep-equal`&&fail(`Value of "/children" should be "contain", "equal" or "deep-equal"`,n+1),t.mode=i):r===`url`&&(t.url=textValue(i));return}let a,o=null;try{if(e[0]===`"`||e[0]===`'`){let[n,r]=readQuoted(e,0,fail),i=e.slice(r).trimStart();if(i!==``&&i[0]!==`:`&&fail(`Unexpected input after the quoted key`,r),i!==``&&(o=i.slice(1)),n===`text`&&o!==null)return textItem(t,o,fail,e.length-o.length);a=new KeyParser(n).parse(!1)}else{if(/^text:(\s|$)/.test(e))return textItem(t,e.slice(5),fail,5);let n=new KeyParser(e);a=n.parse(!0),n.pos<e.length&&(o=e.slice(n.pos+1))}}catch(t){throw t instanceof KeyError&&fail(t.message,e[0]===`"`||e[0]===`'`?0:t.pos),t}return o!==null&&o.trim()!==``&&a.children.push({kind:`text`,text:textValue(parseScalar(o,fail,e.length-o.length))}),t.children.push(a),a}function textItem(e,t,n,r){return e.children.push({kind:`text`,text:textValue(parseScalar(t,n,r))}),null}function parseScalar(e,t,n){let r=e.length-e.trimStart().length,i=e.trim();if(i[0]===`"`||i[0]===`'`){let[e,a]=readQuoted(i,0,(e,i)=>t(e,n+r+i)),o=i.slice(a).trim();return o!==``&&!o.startsWith(`#`)&&t(`Unexpected input after the quoted value`,n+r+a),e}(i===`|`||i===`>`||i.startsWith(`|`)||i.startsWith(`>`))&&t(`Block scalars are not supported in aria snapshot templates`,n+r);let a=i.search(/\s#/);return a>=0?i.slice(0,a).trim():i}function readQuoted(e,t,n){let r=e[t],i=``;for(let n=t+1;n<e.length;n++){let t=e[n];if(r===`'`){if(t===`'`){if(e[n+1]===`'`){i+=`'`,n++;continue}return[i,n+1]}i+=t}else{if(t===`"`)return[i,n+1];if(t===`\\`){let t=e[++n];t===`n`?i+=`
|
|
2
2
|
`:t===`t`?i+=` `:t===`u`?(i+=String.fromCharCode(parseInt(e.slice(n+1,n+5),16)),n+=4):i+=t??``}else i+=t}}return n(`Unterminated string`,e.length)}var KeyError=class extends Error{pos;constructor(e,t){super(e),this.pos=t}},KeyParser=class{pos=0;input;constructor(e){this.input=e}peek(){return this.input[this.pos]??``}eof(){return this.pos>=this.input.length}skipWhitespace(){for(;!this.eof()&&/\s/.test(this.peek());)this.pos++}atColon(){return this.peek()===`:`&&(this.pos+1>=this.input.length||/\s/.test(this.input[this.pos+1]))}readIdentifier(e){if(this.eof())throw new KeyError(`Unexpected end of input when expecting ${e}`,this.pos);let t=this.pos;for(;!this.eof()&&/[a-zA-Z]/.test(this.peek());)this.pos++;if(this.pos===t)throw new KeyError(`Expected ${e}`,this.pos);return this.input.slice(t,this.pos)}readString(){let e=``;for(;!this.eof();){let t=this.input[this.pos++];if(t===`\\`){let t=this.input[this.pos++]??``;t===`n`?e+=`
|
|
3
3
|
`:t===`t`?e+=` `:t===`u`?(e+=String.fromCharCode(parseInt(this.input.slice(this.pos,this.pos+4),16)),this.pos+=4):e+=t}else if(t===`"`)return e;else e+=t}throw new KeyError(`Unterminated string`,this.pos)}readRegex(){let e=this.pos,t=``,n=!1,r=!1;for(;!this.eof();){let i=this.input[this.pos++];if(n)t+=i,n=!1;else if(i===`\\`)n=!0,t+=i;else if(i===`/`&&!r)try{return new RegExp(t)}catch(t){throw new KeyError(`Invalid regular expression: ${t.message}`,e)}else i===`[`?(r=!0,t+=i):i===`]`&&r?(t+=i,r=!1):t+=i}throw new KeyError(`Unterminated regex`,this.pos)}parse(e){this.skipWhitespace();let t=this.readIdentifier(`role`);this.skipWhitespace();let n=null;this.peek()===`"`?(this.pos++,n=normalizeWhitespace(this.readString())):this.peek()===`/`&&(this.pos++,n=this.readRegex());let r={kind:`role`,role:t,name:n===``?null:n,attrs:[],url:null,mode:null,children:[]};for(;this.skipWhitespace(),this.peek()===`[`;){this.pos++,this.skipWhitespace();let e=this.pos,t=this.readIdentifier(`attribute`);this.skipWhitespace();let n=``;if(this.peek()===`=`)for(this.pos++,this.skipWhitespace();this.peek()!==`]`&&!/\s/.test(this.peek())&&!this.eof();)n+=this.input[this.pos++];if(this.skipWhitespace(),this.peek()!==`]`)throw new KeyError(`Expected ]`,this.pos);this.pos++,r.attrs.push([t,checkAttribute(t,n||`true`,e)])}if(this.skipWhitespace(),e&&this.atColon())return r;if(!this.eof())throw new KeyError(e?`Unexpected input (a key ends with ":" and a space)`:`Unexpected input`,this.pos);return r}};function checkAttribute(e,t,n){if(e===`checked`||e===`pressed`){if(t!==`true`&&t!==`false`&&t!==`mixed`)throw new KeyError(`Value of "${e}" attribute must be a boolean or "mixed"`,n);return t}if(g.has(e)){if(t!==`true`&&t!==`false`)throw new KeyError(`Value of "${e}" attribute must be a boolean`,n);return t}if(e===`level`){if(Number.isNaN(Number(t)))throw new KeyError(`Value of "level" attribute must be a number`,n);return String(Number(t))}if(e===`current`)return t;throw new KeyError(`Unsupported attribute [${e}]`,n)}function toMatchNode(e){let t=[];e.value!==null&&e.value!==``&&t.push(normalizeWhitespace(e.value));for(let n=0;n<e.children.length;n++){let r=e.children[n];t.push(typeof r==`string`?normalizeWhitespace(r):toMatchNode(r))}let n=/* @__PURE__ */ new Map;for(let t=0;t<e.props.length;t++){let r=e.props[t].slice(1,-1),i=r.indexOf(`=`);i<0?n.set(r,`true`):n.set(r.slice(0,i),r.slice(i+1))}return{role:e.role,name:normalizeWhitespace(e.name),states:n,url:e.url,children:t,props:e.props}}function stateOf(e,t){let n=e.states.get(t);if(n!==void 0)return n;switch(t){case`checked`:return h(e.role,`aria-checked`)?`false`:void 0;case`disabled`:case`selected`:case`active`:case`busy`:case`hidden`:case`current`:return`false`}}function attrsMatch(e,t){for(let n=0;n<t.attrs.length;n++){let[r,i]=t.attrs[n],a=stateOf(e,r);if(r===`current`&&i===`true`){if(a===void 0||a===`false`)return!1}else if(a!==i)return!1}return!0}function matchesName(e,t){return t===null?!0:e===``?!1:typeof t==`string`?e===t:t.test(e)}function matchesText(e,t){return t===null||t.normalized===``?!0:e?e===t.normalized||e===t.raw||t.regex!==null&&t.regex.test(e):!1}function headerMatches(e,t){return(t.role===`fragment`||t.role===e.role)&&attrsMatch(e,t)&&matchesName(e.name,t.name)&&matchesText(e.url,t.url)}function matchesNode(e,t,n){return typeof e==`string`?t.kind===`text`&&matchesText(e,t.text):t.kind!==`role`||!headerMatches(e,t)?!1:t.mode===`contain`?containsList(e.children,t.children):t.mode===`equal`?listEqual(e.children,t.children,!1):t.mode===`deep-equal`||n?listEqual(e.children,t.children,!0):containsList(e.children,t.children)}function listEqual(e,t,n){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(!matchesNode(e[r],t[r],n))return!1;return!0}function containsList(e,t){if(t.length>e.length)return!1;let n=0;for(let r=0;r<t.length;r++){for(;n<e.length&&!matchesNode(e[n],t[r],!1);)n++;if(n===e.length)return!1;n++}return!0}function matchesDeep(e,t){if(matchesNode(e,t,!1))return!0;if(typeof e==`string`)return!1;for(let n=0;n<e.children.length;n++)if(matchesDeep(e.children[n],t))return!0;return!1}function textRepr(t){return t.regex===null?e(t.normalized):t.raw}function templateKey(e){let t=e.role;typeof e.name==`string`?t+=` `+p(e.name):e.name!==null&&(t+=` /${e.name.source}/`);for(let n=0;n<e.attrs.length;n++)t+=e.attrs[n][1]===`true`?` [${e.attrs[n][0]}]`:` [${e.attrs[n][0]}=${e.attrs[n][1]}]`;return t}function receivedKey(e){let t=e.role;e.name!==``&&(t+=` `+p(f(e.name,100)));for(let n=0;n<e.props.length;n++)t+=` `+e.props[n];return t}function isInline(e){return e.url===null&&e.mode===null&&e.children.length===1&&e.children[0].kind===`text`}function renderTemplate(e,t,n){if(e.kind===`text`){n.push(`${t}- text: ${textRepr(e.text)}`);return}let r=templateKey(e);if(isInline(e)){n.push(`${t}- ${r}: ${textRepr(e.children[0].text)}`);return}if(e.children.length===0&&e.url===null&&e.mode===null){n.push(`${t}- ${r}`);return}n.push(`${t}- ${r}:`);let i=t+` `;e.url!==null&&n.push(`${i}- /url: ${textRepr(e.url)}`),e.mode!==null&&n.push(`${i}- /children: ${e.mode}`);for(let t=0;t<e.children.length;t++)renderTemplate(e.children[t],i,n)}var Scorer=class{memo=/* @__PURE__ */ new Map;score(e,t){if(e.kind===`text`)return typeof t==`string`?matchesText(t,e.text)?3:1:0;if(typeof t==`string`||e.role!==`fragment`&&e.role!==t.role)return 0;let n=this.memo.get(e);n===void 0&&this.memo.set(e,n=/* @__PURE__ */ new Map);let r=n.get(t);if(r!==void 0)return r;let i=2;return i+=e.name===null?1:matchesName(t.name,e.name)?2:0,attrsMatch(t,e)&&(i+=1),e.url!==null&&matchesText(t.url,e.url)&&(i+=1),i+=this.scoreList(e.children,t.children),n.set(t,i),i}scoreList(e,t){let n=this.align(e,t),r=0;for(let t=0;t<e.length;t++)n[t]!==null&&(r+=this.score(e[t],n[t]));return r}align(e,t){let n=[],r=0;for(let i=0;i<e.length;i++){let a=-1,o=0;for(let n=r;n<t.length;n++){let r=this.score(e[i],t[n]);r>o&&(a=n,o=r)}a<0?n.push(null):(n.push(t[a]),r=a+1)}return n}project(t,n,r,i){if(t.kind===`text`){let a=n;i.push(`${r}- text: ${matchesText(a,t.text)?textRepr(t.text):e(f(a,100))}`);return}let a=n,o=headerMatches(a,t)?templateKey(t):receivedKey(a),s=this.align(t.children,a.children);if(isInline(t)){let n=s[0],a=t.children[0].text;i.push(n===null?`${r}- ${o}`:`${r}- ${o}: ${matchesText(n,a)?textRepr(a):e(f(n,100))}`);return}if(t.children.length===0&&t.url===null&&t.mode===null){i.push(`${r}- ${o}`);return}i.push(`${r}- ${o}:`);let c=r+` `;t.url!==null&&i.push(`${c}- /url: ${matchesText(a.url,t.url)?textRepr(t.url):e(a.url??``)}`),t.mode!==null&&i.push(`${c}- /children: ${t.mode}`);for(let e=0;e<t.children.length;e++)s[e]!==null&&this.project(t.children[e],s[e],c,i)}};function forEachNode(e,t){t(e);for(let n=0;n<e.children.length;n++){let r=e.children[n];typeof r==`string`?t(r):forEachNode(r,t)}}function closestLines(e,t){let n=new Scorer,r=[];if(t.kind===`role`&&t.role===`fragment`){let i=null,a=0;if(forEachNode(e,e=>{if(typeof e==`string`)return;let r=n.scoreList(t.children,e.children);r>a&&(i=e,a=r)}),i!==null){let e=n.align(t.children,i.children);for(let i=0;i<t.children.length;i++)e[i]!==null&&n.project(t.children[i],e[i],``,r)}return r}let i=null,a=0;return forEachNode(e,e=>{let r=n.score(t,e);r>a&&(i=e,a=r)}),i!==null&&n.project(t,i,``,r),r}function pairChanges(e){let t=[];for(let n=0;n<e.length;){if(e[n].kind===`=`){t.push(e[n++]);continue}let r=n;for(;r<e.length&&e[r].kind===`-`;)r++;let i=r;for(;i<e.length&&e[i].kind===`+`;)i++;if(r-n===i-r)for(let i=0;i<r-n;i++)t.push(e[n+i],e[r+i]);else for(let r=n;r<i;r++)t.push(e[r]);n=i}return t}function matchAriaSnapshot(e,t){let r=parseAriaTemplate(t),i=n(e,{urls:!0}),c=[];for(let e=0;e<i.length;e++){let t=i[e];c.push(typeof t==`string`?normalizeWhitespace(t):toMatchNode(t))}let l={role:`fragment`,name:``,states:/* @__PURE__ */ new Map,url:null,children:c,props:[]},u=matchesDeep(l,r),expectedLines=()=>{let e=[];if(r.kind===`role`&&r.role===`fragment`){r.mode!==null&&e.push(`- /children: ${r.mode}`);for(let t=0;t<r.children.length;t++)renderTemplate(r.children[t],``,e)}else renderTemplate(r,``,e);return e};return{pass:u,expected:()=>expectedLines().join(`
|
|
4
4
|
`),diff:()=>pairChanges(s(expectedLines(),closestLines(l,r))),received:()=>a(e,{collapseAfter:1/0,maxLines:o()??100})}}function resetFailureSnapshot(e){t(e)}function captureFailureSnapshot(e){let t=d(),n=e?.body;if(t===null||n==null||n[m]===void 0)return null;if(t===`compact`){let e=c(n,void 0,{format:`compact`});return{format:t,text:String(e),full:``,previous:void 0}}let a=i(e),{lines:s,empty:l}=u(n),f=l??s.join(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{A as e,C as t,D as n,E as r,M as i,O as a,T as o,_ as s,a as c,c as l,h as u,i as d,j as f,k as p,l as m,o as h,p as g,r as _,s as v,t as y,v as b,w as x,x as S,y as C}from"./_chunks/aria-snapshot-diff-BSXxnyqJ.js";import{$impl as w,ELEMENT_NODE as T,F_HTML as ee,HTML_NS as E,T as D,TEXT_NODE as O,ariaAttr as k,asciiLowercase as A,attr as j,describeCall as M,describeNode as te,getComputedStyleOverride as ne,indexedDescendantById as re,nextInTree as N,prefixFlag as ie,tracePromise as ae,traceSync as oe,tracing as P}from"
|
|
1
|
+
import{A as e,C as t,D as n,E as r,M as i,O as a,T as o,_ as s,a as c,c as l,h as u,i as d,j as f,k as p,l as m,o as h,p as g,r as _,s as v,t as y,v as b,w as x,x as S,y as C}from"./_chunks/aria-snapshot-diff-BSXxnyqJ.js";import{$impl as w,ELEMENT_NODE as T,F_HTML as ee,HTML_NS as E,T as D,TEXT_NODE as O,ariaAttr as k,asciiLowercase as A,attr as j,describeCall as M,describeNode as te,getComputedStyleOverride as ne,indexedDescendantById as re,nextInTree as N,prefixFlag as ie,tracePromise as ae,traceSync as oe,tracing as P}from"../bridge/internal.js";import{computeAccessibleDescriptionImpl as se,computeAccessibleNameImpl as F,implicitRole as ce,isInaccessibleImpl as I,isInaccessibleWithStyle as le,isLabelable as ue,isSubtreeInaccessibleImpl as de,isVisibilityHidden as fe,labelMapForTree as pe,labelsOf as me,tlRole as L,tlRoleMatcher as he,tlRoleMatches as ge}from"../aria/internal.js";import{roleSupportsProp as _e}from"../aria/index.js";import{AsyncLocalStorage as ve}from"node:async_hooks";const R=/* @__PURE__ */ new Set([`button`,`input`,`meter`,`output`,`progress`,`select`,`textarea`]);function isLabelledNodeName(e){return e.prefix===null&&R.has(e.tag===0?A(e.name):e.name)}function buildIdMap(e){let t=/* @__PURE__ */ new Map;for(let n=e.first;n!==null;n=N(n,e))n.type===T&&n.id!==``&&!t.has(n.id)&&t.set(n.id,n);return t}var LabelContext=class{container;containerIds;sameTree;labelMap;constructor(e,t=!1){this.container=e,this.containerIds=null,this.sameTree=t,this.labelMap=null}labelsOf(e){return this.sameTree?(this.labelMap??=pe(this.container)).get(e)??z:me(e)??z}byIdInContainer(e){if(e===``)return null;if(this.containerIds===null){let t=re(this.container,e);if(t!==void 0)return t;this.containerIds=buildIdMap(this.container)}return this.containerIds.get(e)??null}};const z=[];function getTextContent(e){let t=``;for(let n=e.first;n!==null;n=n.next)n.type===O?t+=n.data:n.first===null||n.type===T&&isLabelledNodeName(n)||(t+=getTextContent(n));return t}function getLabelContentImpl(e){if(e.tag===D.label&&e.ns===E)return getTextContent(e);let t=e.node;return t.value||t.textContent}function labelledFormControl(e,t){for(let n=e.first;n!==null;n=N(n,e))if(n.type===T&&R.has(n.name)&&(t===`*`||o(n,t)))return n}function getLabelsImpl(e,t,n=`*`){let r=k(t,`aria-labelledby`);return r?r.split(` `).map(t=>{let n=e.byIdInContainer(t);return n?{content:getLabelContentImpl(n),formControl:null}:{content:``,formControl:null}}):e.labelsOf(t).map(e=>({content:getLabelContentImpl(e),formControl:labelledFormControl(e,n)}))}function assertNotNullOrUndefined(e){if(e==null)throw Error(`It looks like ${e} was passed instead of a matcher. Did you do something like getByText(${e})?`)}function fuzzyMatches(e,t,n,r){if(typeof e!=`string`)return!1;assertNotNullOrUndefined(n);let i=r(e);return typeof n==`string`||typeof n==`number`?i.toLowerCase().includes(n.toString().toLowerCase()):typeof n==`function`?n(i,t):matchRegExp(n,i)}function matches$1(e,t,n,r){if(typeof e!=`string`)return!1;assertNotNullOrUndefined(n);let i=r(e);return n instanceof Function?n(i,t):n instanceof RegExp?matchRegExp(n,i):i===String(n)}i(matches$1,`matches`);function isRegExpWhitespace(e){return e<=32?e===32||e>=9&&e<=13:e<160?!1:e===160||e===5760||e>=8192&&e<=8202||e===8232||e===8233||e===8239||e===8287||e===12288||e===65279}function changedByNormalizing(e,t,n){let r=e.length-1,i=!1;for(let a=0;a<=r;a++){let o=e.charCodeAt(a),s=isRegExpWhitespace(o);if(s&&(t&&(a===0||a===r)||n&&(i||o!==32)))return!0;i=s}return!1}const ye=/\s+/g;function getDefaultNormalizer({trim:e=!0,collapseWhitespace:t=!0}={}){return n=>{if(!changedByNormalizing(n,e,t))return n;let r=n;return r=e?r.trim():r,r=t?r.replace(ye,` `):r,r}}const B=getDefaultNormalizer();function textMatcher(e,t,n){if(!e)return(e,r)=>fuzzyMatches(e,r,t,n);if(n===B&&isPlainRegExp(t)){let e;return n=>typeof n==`string`?n.length===0?e??=t.test(``):t.test(B(n)):!1}if(n!==B||typeof t!=`string`&&typeof t!=`number`)return(e,r)=>matches$1(e,r,t,n);let r=String(t);if(changedByNormalizing(r,!0,!0))return()=>!1;let i=r.length,a=r.charCodeAt(0),o=r.charCodeAt(i-1);return e=>{if(typeof e!=`string`||e.length<i)return!1;if(i!==0){let t=e.charCodeAt(0);if(t!==a&&!isRegExpWhitespace(t))return!1;let n=e.charCodeAt(e.length-1);if(n!==o&&!isRegExpWhitespace(n))return!1}return B(e)===r}}function makeNormalizer({trim:e,collapseWhitespace:t,normalizer:n}){if(!n)return e===void 0&&t===void 0?B:getDefaultNormalizer({trim:e,collapseWhitespace:t});if(e!==void 0||t!==void 0)throw Error(`trim and collapseWhitespace are not supported with a normalizer. If you want to use the default trim and collapseWhitespace logic in your normalizer, use "getDefaultNormalizer({trim, collapseWhitespace})" and compose that into your normalizer`);return n}const be=RegExp.prototype.exec;function isPlainRegExp(e){return e instanceof RegExp&&!e.global&&!e.sticky&&Object.getPrototypeOf(e)===RegExp.prototype&&!Object.hasOwn(e,`exec`)&&!Object.hasOwn(e,`test`)&&RegExp.prototype.exec===be&&RegExp.prototype.test===xe}const xe=RegExp.prototype.test;function matchRegExp(e,t){let n=e.test(t);return e.global&&e.lastIndex!==0&&(console.warn(`To match all elements we had to reset the lastIndex of the RegExp because the global flag is enabled. We encourage to remove the global flag from the RegExp.`),e.lastIndex=0),n}function isButtonLikeInput(e){if(e.tag!==D.input||e.ns!==E)return!1;let t=j(e,`type`);if(t===null)return!1;let n=A(t);return n===`submit`||n===`button`||n===`reset`}function getNodeTextImpl(e){if(isButtonLikeInput(e))return e.node.value;let t=``;for(let n=e.first;n!==null;n=n.next)n.type===O&&(t+=n.data);return t}function getNodeText(t){let n=e(t);return n.type===T?getNodeTextImpl(n):t.matches(`input[type=submit], input[type=button], input[type=reset]`)}const Se={computedStyleSupportsPseudoElements:!0};function styleOverride(e){return ne(e)}function nameOptions(e,t){return t===null?e?Se:void 0:{computedStyleSupportsPseudoElements:e,getComputedStyle:t}}const V={implicitRole(e){let t=ce(e);return t===``?null:t},roleMatcher:he,roleSupportsProp(e,t){return typeof e==`string`&&_e(e,t)},computeAccessibleName(e,t,n){return F(e,nameOptions(t,n),5)},computeAccessibleDescription(e,t,n){return se(e,nameOptions(t,n),5)},isInaccessible:I,isInaccessibleWithStyle:le,isSubtreeInaccessible:de};function parentElement(e){let t=e.parent;return t!==null&&t.type===T?t:null}function isInaccessibleImpl$1(e){return V.isInaccessible(e)}i(isInaccessibleImpl$1,`isInaccessibleImpl`);function isInaccessibleChecked(e){let t=styleOverride(e);return t===null?V.isInaccessible(e):V.isInaccessibleWithStyle(e,t,null)}function isInaccessible(t,n={}){let r=e(t),i=n.isSubtreeInaccessible,a=styleOverride(r);if(i===void 0)return a===null?isInaccessibleImpl$1(r):V.isInaccessibleWithStyle(r,a,null);if(a===null?fe(r):a(t).visibility===`hidden`)return!0;for(let e=r;e!==null;e=parentElement(e))if(i(e.node))return!0;return!1}function getImplicitAriaRolesImpl(e){let t=V.implicitRole(e);return t===null?[]:[t]}function getRoles(t,{hidden:n=!1}={}){let r=e(t),i={},a=n===!1?styleOverride(r):null,o=a===null?null:/* @__PURE__ */ new Map,visit=e=>{if(n!==!1||(a===null?isInaccessibleImpl$1(e):V.isInaccessibleWithStyle(e,a,o))===!1){let t=j(e,`role`),n=t===null?getImplicitAriaRolesImpl(e):t.split(` `).slice(0,1);for(let t of n){let n=i[t];Array.isArray(n)?n.push(e.node):i[t]=[e.node]}}for(let t=e.first;t!==null;t=t.next)t.type===T&&visit(t)};return visit(r),i}const Ce={format:`pretty`};function prettyRoles(t,{hidden:n,includeDescription:r}){let i=getRoles(t,{hidden:n}),a=d().computedStyleSupportsPseudoElements,o=styleOverride(e(t));return Object.entries(i).filter(([e])=>e!==`generic`).map(([t,n])=>{let i=`-`.repeat(50);return`${t}:\n\n${n.map(t=>{let n=e(t),i=`Name "${V.computeAccessibleName(n,a,o)}":\n`,s=v(t.cloneNode(!1),void 0,Ce);return r?`${i}${`Description "${V.computeAccessibleDescription(n,a,o)}":\n`}${s}`:`${i}${s}`}).join(`
|
|
2
2
|
|
|
3
3
|
`)}\n\n${i}`}).join(`
|
|
4
4
|
`)}const logRoles=(e,{hidden:t=!1}={})=>console.log(prettyRoles(e,{hidden:t}));function checkBooleanAttribute(e,t){let n=j(e,t);if(n===`true`)return!0;if(n===`false`)return!1}function computeAriaSelected$1(e){return e.tag===D.option&&e.ns===E?e.node.selected:checkBooleanAttribute(e,`aria-selected`)}i(computeAriaSelected$1,`computeAriaSelected`);function computeAriaBusy$1(e){return k(e,`aria-busy`)===`true`}i(computeAriaBusy$1,`computeAriaBusy`);function computeAriaChecked(e){let t=e.node;if(!(`indeterminate`in t&&t.indeterminate))return`checked`in t?t.checked:checkBooleanAttribute(e,`aria-checked`)}function computeAriaPressed(e){return checkBooleanAttribute(e,`aria-pressed`)}function computeAriaCurrent$1(e){return checkBooleanAttribute(e,`aria-current`)??k(e,`aria-current`)??!1}i(computeAriaCurrent$1,`computeAriaCurrent`);function computeAriaExpanded$1(e){return checkBooleanAttribute(e,`aria-expanded`)}i(computeAriaExpanded$1,`computeAriaExpanded`);function computeHeadingLevelImpl(e){let t=k(e,`aria-level`),n=t&&Number(t);if(n)return n;if(e.ns===E)switch(e.tag){case D.h1:return 1;case D.h2:return 2;case D.h3:return 3;case D.h4:return 4;case D.h5:return 5;case D.h6:return 6}}function computeAriaValueNow(e){let t=k(e,`aria-valuenow`);return t===null?void 0:+t}function computeAriaValueMax(e){let t=k(e,`aria-valuemax`);return t===null?void 0:+t}function computeAriaValueMin(e){let t=k(e,`aria-valuemin`);return t===null?void 0:+t}function computeAriaValueText(e){let t=k(e,`aria-valuetext`);return t===null?void 0:t}const H=getDefaultNormalizer();function escapeRegExp(e){return e.replace(/[.*+\-?^${}()|[\]\\]/g,`\\$&`)}function getRegExpMatcher(e){return new RegExp(escapeRegExp(e.toLowerCase()),`i`)}function makeSuggestion(t,n,r,{variant:i,name:a}){let o=``,s={},c=[[`Role`,`TestId`].includes(t)?r:getRegExpMatcher(r)];a&&(s.name=getRegExpMatcher(a)),t===`Role`&&isInaccessibleChecked(e(n))&&(s.hidden=!0,o=`Element is inaccessible. This means that the element and all its children are invisible to screen readers.
|