@ctrl/dom 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/NOTICE +338 -0
- package/README.md +362 -2
- package/dist/aria/_chunks/roles-list-CYZF-l9K.js +1503 -0
- package/dist/aria/_chunks/roles-list-D4WCyRO_.cjs +1754 -0
- package/dist/aria/index.cjs +232 -0
- package/dist/aria/index.js +198 -0
- package/dist/aria/internal.cjs +69 -0
- package/dist/aria/internal.js +30 -0
- package/dist/aria/types/accname.d.ts +40 -0
- package/dist/aria/types/data/aria-query.d.ts +61 -0
- package/dist/aria/types/data/aria-query.generated.d.ts +2 -0
- package/dist/aria/types/forms.d.ts +25 -0
- package/dist/aria/types/hidden.d.ts +38 -0
- package/dist/aria/types/index.d.ts +46 -0
- package/dist/aria/types/internal.d.ts +15 -0
- package/dist/aria/types/role.d.ts +27 -0
- package/dist/aria/types/roles-list.d.ts +18 -0
- package/dist/aria/types/states.d.ts +29 -0
- package/dist/aria/types/style.d.ts +18 -0
- package/dist/aria/types/tree.d.ts +20 -0
- package/dist/bridge/index.cjs +3 -0
- package/dist/bridge/index.js +4 -0
- package/dist/bridge/internal.cjs +3 -0
- package/dist/bridge/internal.js +4 -0
- package/dist/cli/_chunks/report-DdncYfuJ.js +93 -0
- package/dist/cli/ctrl-dom.js +199 -0
- package/dist/cli/jest-reporter.js +55 -0
- package/dist/cli/vitest-reporter.js +81 -0
- package/dist/dom/_chunks/src-Hv_BAHIV.js +47537 -0
- package/dist/dom/index.js +3 -0
- package/dist/dom/internal.js +434 -0
- package/dist/dom/types/collections/DOMStringMap.d.ts +8 -0
- package/dist/dom/types/collections/DOMTokenList.d.ts +33 -0
- package/dist/dom/types/collections/HTMLCollection.d.ts +62 -0
- package/dist/dom/types/collections/NamedNodeMap.d.ts +22 -0
- package/dist/dom/types/collections/NodeList.d.ts +43 -0
- package/dist/dom/types/collections/indexed.d.ts +8 -0
- package/dist/dom/types/collections/iterator.d.ts +8 -0
- package/dist/dom/types/css/CSS.d.ts +21 -0
- package/dist/dom/types/css/CSSStyleDeclaration.d.ts +57 -0
- package/dist/dom/types/css/cascade.d.ts +159 -0
- package/dist/dom/types/css/colors.d.ts +28 -0
- package/dist/dom/types/css/computed.d.ts +22 -0
- package/dist/dom/types/css/cssom.d.ts +363 -0
- package/dist/dom/types/css/data/properties.d.ts +1 -0
- package/dist/dom/types/css/declarations.d.ts +40 -0
- package/dist/dom/types/css/index.d.ts +5 -0
- package/dist/dom/types/css/inline-count.d.ts +2 -0
- package/dist/dom/types/css/internal.d.ts +11 -0
- package/dist/dom/types/css/layout-mode.d.ts +4 -0
- package/dist/dom/types/css/layout.d.ts +63 -0
- package/dist/dom/types/css/media.d.ts +55 -0
- package/dist/dom/types/css/parser.d.ts +93 -0
- package/dist/dom/types/css/properties.d.ts +28 -0
- package/dist/dom/types/css/resize-observer.d.ts +19 -0
- package/dist/dom/types/css/selector-info.d.ts +13 -0
- package/dist/dom/types/css/shorthands.d.ts +33 -0
- package/dist/dom/types/css/stylesheets.d.ts +93 -0
- package/dist/dom/types/css/supports.d.ts +4 -0
- package/dist/dom/types/css/tokenizer.d.ts +91 -0
- package/dist/dom/types/css/values.d.ts +91 -0
- package/dist/dom/types/css/view.d.ts +44 -0
- package/dist/dom/types/events/DataTransfer.d.ts +62 -0
- package/dist/dom/types/events/Event.d.ts +115 -0
- package/dist/dom/types/events/EventTarget.d.ts +22 -0
- package/dist/dom/types/events/UIEvents.d.ts +308 -0
- package/dist/dom/types/events/activation.d.ts +7 -0
- package/dist/dom/types/events/convert.d.ts +16 -0
- package/dist/dom/types/events/createEvent.d.ts +3 -0
- package/dist/dom/types/events/dispatch.d.ts +39 -0
- package/dist/dom/types/events/events.d.ts +200 -0
- package/dist/dom/types/events/fire.d.ts +21 -0
- package/dist/dom/types/events/handlers.d.ts +14 -0
- package/dist/dom/types/events/listeners.d.ts +32 -0
- package/dist/dom/types/events/report.d.ts +10 -0
- package/dist/dom/types/html/HTMLElement.d.ts +126 -0
- package/dist/dom/types/html/MathMLElement.d.ts +6 -0
- package/dist/dom/types/html/SVGElement.d.ts +145 -0
- package/dist/dom/types/html/anchor.d.ts +16 -0
- package/dist/dom/types/html/aria-reflection.d.ts +14 -0
- package/dist/dom/types/html/collection.d.ts +5 -0
- package/dist/dom/types/html/custom-elements.d.ts +129 -0
- package/dist/dom/types/html/elements.d.ts +202 -0
- package/dist/dom/types/html/events.d.ts +22 -0
- package/dist/dom/types/html/focus.d.ts +63 -0
- package/dist/dom/types/html/forms/FileList.d.ts +1 -0
- package/dist/dom/types/html/forms/FormData.d.ts +7 -0
- package/dist/dom/types/html/forms/HTMLButtonElement.d.ts +36 -0
- package/dist/dom/types/html/forms/HTMLFieldSetElement.d.ts +29 -0
- package/dist/dom/types/html/forms/HTMLFormElement.d.ts +61 -0
- package/dist/dom/types/html/forms/HTMLInputElement.d.ts +204 -0
- package/dist/dom/types/html/forms/HTMLLabelElement.d.ts +15 -0
- package/dist/dom/types/html/forms/HTMLOptionElement.d.ts +61 -0
- package/dist/dom/types/html/forms/HTMLOutputElement.d.ts +74 -0
- package/dist/dom/types/html/forms/HTMLSelectElement.d.ts +96 -0
- package/dist/dom/types/html/forms/HTMLTextAreaElement.d.ts +82 -0
- package/dist/dom/types/html/forms/autofill.d.ts +10 -0
- package/dist/dom/types/html/forms/collections.d.ts +112 -0
- package/dist/dom/types/html/forms/common.d.ts +36 -0
- package/dist/dom/types/html/forms/face.d.ts +59 -0
- package/dist/dom/types/html/forms/form-associated.d.ts +46 -0
- package/dist/dom/types/html/forms/form-submission.d.ts +55 -0
- package/dist/dom/types/html/forms/index.d.ts +17 -0
- package/dist/dom/types/html/forms/input-type.d.ts +50 -0
- package/dist/dom/types/html/forms/microsyntaxes.d.ts +52 -0
- package/dist/dom/types/html/forms/state.d.ts +54 -0
- package/dist/dom/types/html/forms/ui.d.ts +35 -0
- package/dist/dom/types/html/forms/user-validity.d.ts +19 -0
- package/dist/dom/types/html/forms/validation.d.ts +76 -0
- package/dist/dom/types/html/index.d.ts +13 -0
- package/dist/dom/types/html/innerText.d.ts +9 -0
- package/dist/dom/types/html/interactive.d.ts +43 -0
- package/dist/dom/types/html/invokers.d.ts +39 -0
- package/dist/dom/types/html/media.d.ts +86 -0
- package/dist/dom/types/html/reflect.d.ts +67 -0
- package/dist/dom/types/html/registry.d.ts +9 -0
- package/dist/dom/types/html/resources.d.ts +55 -0
- package/dist/dom/types/html/shared.d.ts +22 -0
- package/dist/dom/types/html/slot.d.ts +15 -0
- package/dist/dom/types/html/template.d.ts +18 -0
- package/dist/dom/types/html/top-layer.d.ts +73 -0
- package/dist/dom/types/index.d.ts +50 -0
- package/dist/dom/types/internal.d.ts +61 -0
- package/dist/dom/types/keys.d.ts +209 -0
- package/dist/dom/types/nodes/Attr.d.ts +25 -0
- package/dist/dom/types/nodes/CharacterData.d.ts +35 -0
- package/dist/dom/types/nodes/Document.d.ts +169 -0
- package/dist/dom/types/nodes/DocumentFragment.d.ts +12 -0
- package/dist/dom/types/nodes/DocumentType.d.ts +17 -0
- package/dist/dom/types/nodes/Element.d.ts +142 -0
- package/dist/dom/types/nodes/Node.d.ts +112 -0
- package/dist/dom/types/nodes/NodeImpl.d.ts +90 -0
- package/dist/dom/types/nodes/ShadowRoot.d.ts +43 -0
- package/dist/dom/types/nodes/attr-nodes.d.ts +8 -0
- package/dist/dom/types/nodes/attributes.d.ts +46 -0
- package/dist/dom/types/nodes/cache.d.ts +38 -0
- package/dist/dom/types/nodes/character-data.d.ts +5 -0
- package/dist/dom/types/nodes/clone.d.ts +5 -0
- package/dist/dom/types/nodes/constants.d.ts +52 -0
- package/dist/dom/types/nodes/create.d.ts +42 -0
- package/dist/dom/types/nodes/derived.d.ts +26 -0
- package/dist/dom/types/nodes/inspect.d.ts +2 -0
- package/dist/dom/types/nodes/mixins.d.ts +41 -0
- package/dist/dom/types/nodes/names.d.ts +15 -0
- package/dist/dom/types/nodes/slots.d.ts +38 -0
- package/dist/dom/types/nodes/tags.d.ts +8 -0
- package/dist/dom/types/nodes/traverse.d.ts +21 -0
- package/dist/dom/types/nodes/tree.d.ts +47 -0
- package/dist/dom/types/observers/MutationObserver.d.ts +33 -0
- package/dist/dom/types/observers/MutationRecord.d.ts +17 -0
- package/dist/dom/types/observers/queue.d.ts +45 -0
- package/dist/dom/types/parser/entities-data.d.ts +3 -0
- package/dist/dom/types/parser/entities.d.ts +11 -0
- package/dist/dom/types/parser/index.d.ts +34 -0
- package/dist/dom/types/parser/tags.d.ts +182 -0
- package/dist/dom/types/parser/tokenizer.d.ts +109 -0
- package/dist/dom/types/parser/treebuilder.d.ts +271 -0
- package/dist/dom/types/parser/xml.d.ts +14 -0
- package/dist/dom/types/selectors/compile.d.ts +154 -0
- package/dist/dom/types/selectors/filter.d.ts +21 -0
- package/dist/dom/types/selectors/html-predicates.d.ts +1 -0
- package/dist/dom/types/selectors/index.d.ts +16 -0
- package/dist/dom/types/selectors/internal.d.ts +87 -0
- package/dist/dom/types/selectors/parser.d.ts +310 -0
- package/dist/dom/types/selectors/serialize.d.ts +20 -0
- package/dist/dom/types/selectors/state.d.ts +43 -0
- package/dist/dom/types/serializer/index.d.ts +29 -0
- package/dist/dom/types/trace.d.ts +51 -0
- package/dist/dom/types/traversal/Range.d.ts +113 -0
- package/dist/dom/types/traversal/Selection.d.ts +45 -0
- package/dist/dom/types/traversal/TreeWalker.d.ts +77 -0
- package/dist/dom/types/traversal/live.d.ts +46 -0
- package/dist/dom/types/webidl-runtime.d.ts +18 -0
- package/dist/dom/types/webidl.d.ts +34 -0
- package/dist/dom/types/window/DOMStringList.d.ts +14 -0
- package/dist/dom/types/window/FileList.d.ts +11 -0
- package/dist/dom/types/window/FileReader.d.ts +27 -0
- package/dist/dom/types/window/History.d.ts +43 -0
- package/dist/dom/types/window/Location.d.ts +46 -0
- package/dist/dom/types/window/Navigator.d.ts +79 -0
- package/dist/dom/types/window/Screen.d.ts +27 -0
- package/dist/dom/types/window/Storage.d.ts +28 -0
- package/dist/dom/types/window/Window.d.ts +329 -0
- package/dist/dom/types/window/abort.d.ts +4 -0
- package/dist/dom/types/window/browsing-context.d.ts +12 -0
- package/dist/dom/types/window/clock.d.ts +163 -0
- package/dist/dom/types/window/compat.d.ts +34 -0
- package/dist/dom/types/window/cookies.d.ts +21 -0
- package/dist/dom/types/window/current.d.ts +7 -0
- package/dist/dom/types/window/document.d.ts +19 -0
- package/dist/dom/types/window/events.d.ts +11 -0
- package/dist/dom/types/window/fallbacks.d.ts +20 -0
- package/dist/dom/types/window/geometry.d.ts +133 -0
- package/dist/dom/types/window/globals.d.ts +7 -0
- package/dist/dom/types/window/hooks.d.ts +22 -0
- package/dist/dom/types/window/host-originals.d.ts +9 -0
- package/dist/dom/types/window/interfaces.d.ts +13 -0
- package/dist/dom/types/window/isolation.d.ts +20 -0
- package/dist/dom/types/window/media.d.ts +33 -0
- package/dist/dom/types/window/not-implemented.d.ts +23 -0
- package/dist/dom/types/window/observers.d.ts +42 -0
- package/dist/dom/types/window/origin.d.ts +3 -0
- package/dist/dom/types/window/timers.d.ts +28 -0
- package/dist/dom/types/window/xhr.d.ts +108 -0
- package/dist/jest-dom/_chunks/matchers-CDnnXUfG.js +2211 -0
- package/dist/jest-dom/_chunks/matchers-D988Ducb.cjs +2516 -0
- package/dist/jest-dom/index.cjs +5 -0
- package/dist/jest-dom/index.js +6 -0
- package/dist/jest-dom/jest-globals.cjs +6 -0
- package/dist/jest-dom/jest-globals.js +7 -0
- package/dist/jest-dom/matchers.cjs +53 -0
- package/dist/jest-dom/matchers.js +3 -0
- package/dist/jest-dom/types/bun.d.ts +13 -0
- package/dist/jest-dom/types/index.d.ts +3 -0
- package/dist/jest-dom/types/jest-globals.d.ts +13 -0
- package/dist/jest-dom/types/jest.d.ts +15 -0
- package/dist/jest-dom/types/matchers-standalone.d.ts +32 -0
- package/dist/jest-dom/types/matchers.d.ts +1079 -0
- package/dist/jest-dom/types/package.json +1 -0
- package/dist/jest-dom/types/vitest.d.ts +16 -0
- package/dist/jest-dom/vitest.cjs +6 -0
- package/dist/jest-dom/vitest.js +7 -0
- package/dist/react/_chunks/pure-DZ97z2oT.cjs +498 -0
- package/dist/react/_chunks/pure-PtE2hivW.js +420 -0
- package/dist/react/dont-cleanup-after-each.cjs +3 -0
- package/dist/react/dont-cleanup-after-each.js +4 -0
- package/dist/react/index.cjs +47 -0
- package/dist/react/index.js +35 -0
- package/dist/react/pure.cjs +17 -0
- package/dist/react/pure.js +5 -0
- package/dist/react/types/act-compat.d.ts +6 -0
- package/dist/react/types/config.d.ts +9 -0
- package/dist/react/types/dont-cleanup-after-each.d.ts +1 -0
- package/dist/react/types/dtl.d.ts +1 -0
- package/dist/react/types/fire-event.d.ts +3 -0
- package/dist/react/types/index.d.ts +1 -0
- package/dist/react/types/pure.d.ts +136 -0
- package/dist/register/index.js +11 -0
- package/dist/register/pure.js +147 -0
- package/dist/register/types/index.d.ts +1 -0
- package/dist/register/types/pure.d.ts +36 -0
- package/dist/testing-library/_chunks/aria-snapshot-diff-D7PzpXew.cjs +1170 -0
- package/dist/testing-library/_chunks/aria-snapshot-diff-Q8Wj33K0.js +985 -0
- package/dist/testing-library/agent.cjs +721 -0
- package/dist/testing-library/agent.js +713 -0
- package/dist/testing-library/index.cjs +2469 -0
- package/dist/testing-library/index.js +2390 -0
- package/dist/testing-library/types/agent.d.ts +56 -0
- package/dist/testing-library/types/aria-role.d.ts +99 -0
- package/dist/testing-library/types/aria-snapshot.d.ts +43 -0
- package/dist/testing-library/types/config.d.ts +27 -0
- package/dist/testing-library/types/events.d.ts +118 -0
- package/dist/testing-library/types/get-node-text.d.ts +1 -0
- package/dist/testing-library/types/get-queries-for-element.d.ts +182 -0
- package/dist/testing-library/types/index.d.ts +24 -0
- package/dist/testing-library/types/matches.d.ts +46 -0
- package/dist/testing-library/types/pretty-dom.d.ts +37 -0
- package/dist/testing-library/types/queries.d.ts +315 -0
- package/dist/testing-library/types/query-helpers.d.ts +112 -0
- package/dist/testing-library/types/role-helpers.d.ts +19 -0
- package/dist/testing-library/types/screen.d.ts +30 -0
- package/dist/testing-library/types/suggestions.d.ts +46 -0
- package/dist/testing-library/types/wait-for-element-to-be-removed.d.ts +6 -0
- package/dist/testing-library/types/wait-for.d.ts +12 -0
- package/dist/user-event/index.cjs +3923 -0
- package/dist/user-event/index.js +3898 -0
- package/dist/user-event/types/clipboard/copy.d.ts +2 -0
- package/dist/user-event/types/clipboard/cut.d.ts +2 -0
- package/dist/user-event/types/clipboard/index.d.ts +3 -0
- package/dist/user-event/types/clipboard/paste.d.ts +3 -0
- package/dist/user-event/types/convenience/click.d.ts +5 -0
- package/dist/user-event/types/convenience/hover.d.ts +4 -0
- package/dist/user-event/types/convenience/index.d.ts +3 -0
- package/dist/user-event/types/convenience/tab.d.ts +4 -0
- package/dist/user-event/types/ctrl-dom.d.ts +55 -0
- package/dist/user-event/types/document/UI.d.ts +35 -0
- package/dist/user-event/types/document/copySelection.d.ts +2 -0
- package/dist/user-event/types/document/getValueOrTextContent.d.ts +2 -0
- package/dist/user-event/types/document/index.d.ts +5 -0
- package/dist/user-event/types/document/interceptor.d.ts +20 -0
- package/dist/user-event/types/document/patchFocus.d.ts +7 -0
- package/dist/user-event/types/document/prepareDocument.d.ts +2 -0
- package/dist/user-event/types/document/trackValue.d.ts +13 -0
- package/dist/user-event/types/dom-types.d.ts +56 -0
- package/dist/user-event/types/event/behavior/click.d.ts +1 -0
- package/dist/user-event/types/event/behavior/cut.d.ts +1 -0
- package/dist/user-event/types/event/behavior/index.d.ts +8 -0
- package/dist/user-event/types/event/behavior/keydown.d.ts +1 -0
- package/dist/user-event/types/event/behavior/keypress.d.ts +1 -0
- package/dist/user-event/types/event/behavior/keyup.d.ts +1 -0
- package/dist/user-event/types/event/behavior/paste.d.ts +1 -0
- package/dist/user-event/types/event/behavior/registry.d.ts +9 -0
- package/dist/user-event/types/event/createEvent.d.ts +8 -0
- package/dist/user-event/types/event/dispatchEvent.d.ts +6 -0
- package/dist/user-event/types/event/eventMap.d.ts +265 -0
- package/dist/user-event/types/event/focus.d.ts +6 -0
- package/dist/user-event/types/event/index.d.ts +7 -0
- package/dist/user-event/types/event/input.d.ts +3 -0
- package/dist/user-event/types/event/radio.d.ts +5 -0
- package/dist/user-event/types/event/selection/getInputRange.d.ts +6 -0
- package/dist/user-event/types/event/selection/getTargetTypeAndSelection.d.ts +11 -0
- package/dist/user-event/types/event/selection/index.d.ts +15 -0
- package/dist/user-event/types/event/selection/modifySelection.d.ts +9 -0
- package/dist/user-event/types/event/selection/modifySelectionPerMouse.d.ts +8 -0
- package/dist/user-event/types/event/selection/moveSelection.d.ts +5 -0
- package/dist/user-event/types/event/selection/resolveCaretPosition.d.ts +9 -0
- package/dist/user-event/types/event/selection/selectAll.d.ts +6 -0
- package/dist/user-event/types/event/selection/setSelection.d.ts +11 -0
- package/dist/user-event/types/event/selection/setSelectionPerMouse.d.ts +9 -0
- package/dist/user-event/types/event/selection/setSelectionRange.d.ts +7 -0
- package/dist/user-event/types/event/selection/updateSelectionOnFocus.d.ts +6 -0
- package/dist/user-event/types/event/types.d.ts +21 -0
- package/dist/user-event/types/event/wrapEvent.d.ts +2 -0
- package/dist/user-event/types/index.d.ts +6 -0
- package/dist/user-event/types/keyboard/index.d.ts +3 -0
- package/dist/user-event/types/keyboard/keyMap.d.ts +5 -0
- package/dist/user-event/types/keyboard/parseKeyDef.d.ts +17 -0
- package/dist/user-event/types/options.d.ts +121 -0
- package/dist/user-event/types/pointer/index.d.ts +29 -0
- package/dist/user-event/types/pointer/keyMap.d.ts +2 -0
- package/dist/user-event/types/pointer/parseKeyDef.d.ts +6 -0
- package/dist/user-event/types/setup/api.d.ts +23 -0
- package/dist/user-event/types/setup/directApi.d.ts +25 -0
- package/dist/user-event/types/setup/dtl.d.ts +20 -0
- package/dist/user-event/types/setup/index.d.ts +22 -0
- package/dist/user-event/types/setup/setup.d.ts +45 -0
- package/dist/user-event/types/setup/wrapAsync.d.ts +4 -0
- package/dist/user-event/types/system/index.d.ts +13 -0
- package/dist/user-event/types/system/keyLocation.d.ts +11 -0
- package/dist/user-event/types/system/keyboard.d.ts +46 -0
- package/dist/user-event/types/system/pointer/buttons.d.ts +25 -0
- package/dist/user-event/types/system/pointer/device.d.ts +8 -0
- package/dist/user-event/types/system/pointer/index.d.ts +21 -0
- package/dist/user-event/types/system/pointer/mouse.d.ts +31 -0
- package/dist/user-event/types/system/pointer/pointer.d.ts +32 -0
- package/dist/user-event/types/system/pointer/shared.d.ts +21 -0
- package/dist/user-event/types/utility/clear.d.ts +3 -0
- package/dist/user-event/types/utility/index.d.ts +4 -0
- package/dist/user-event/types/utility/selectOptions.d.ts +4 -0
- package/dist/user-event/types/utility/type.d.ts +10 -0
- package/dist/user-event/types/utility/upload.d.ts +6 -0
- package/dist/user-event/types/utils/click/isClickableInput.d.ts +17 -0
- package/dist/user-event/types/utils/dataTransfer/Blob.d.ts +4 -0
- package/dist/user-event/types/utils/dataTransfer/Clipboard.d.ts +12 -0
- package/dist/user-event/types/utils/dataTransfer/DataTransfer.d.ts +3 -0
- package/dist/user-event/types/utils/dataTransfer/FileList.d.ts +2 -0
- package/dist/user-event/types/utils/edit/isContentEditable.d.ts +8 -0
- package/dist/user-event/types/utils/edit/isEditable.d.ts +26 -0
- package/dist/user-event/types/utils/edit/maxLength.d.ts +16 -0
- package/dist/user-event/types/utils/edit/setFiles.d.ts +11 -0
- package/dist/user-event/types/utils/edit/timeValue.d.ts +5 -0
- package/dist/user-event/types/utils/focus/cursor.d.ts +5 -0
- package/dist/user-event/types/utils/focus/getActiveElement.d.ts +3 -0
- package/dist/user-event/types/utils/focus/getTabDestination.d.ts +2 -0
- package/dist/user-event/types/utils/focus/isFocusable.d.ts +2 -0
- package/dist/user-event/types/utils/focus/selection.d.ts +9 -0
- package/dist/user-event/types/utils/focus/selector.d.ts +1 -0
- package/dist/user-event/types/utils/index.d.ts +29 -0
- package/dist/user-event/types/utils/keyDef/readNextDescriptor.d.ts +21 -0
- package/dist/user-event/types/utils/misc/cloneEvent.d.ts +2 -0
- package/dist/user-event/types/utils/misc/findClosest.d.ts +2 -0
- package/dist/user-event/types/utils/misc/getDocumentFromNode.d.ts +2 -0
- package/dist/user-event/types/utils/misc/getTreeDiff.d.ts +2 -0
- package/dist/user-event/types/utils/misc/getWindow.d.ts +2 -0
- package/dist/user-event/types/utils/misc/isDescendantOrSelf.d.ts +2 -0
- package/dist/user-event/types/utils/misc/isDisabled.d.ts +2 -0
- package/dist/user-event/types/utils/misc/isElementType.d.ts +6 -0
- package/dist/user-event/types/utils/misc/isVisible.d.ts +2 -0
- package/dist/user-event/types/utils/misc/level.d.ts +9 -0
- package/dist/user-event/types/utils/misc/wait.d.ts +6 -0
- package/dist/user-event/types/utils/pointer/cssPointerEvents.d.ts +4 -0
- package/dist/vitest-environment/failure-snapshot.js +42 -0
- package/dist/vitest-environment/index.js +185 -0
- package/dist/vitest-environment/plugin.js +90 -0
- package/dist/vitest-environment/types/failure-snapshot.d.ts +1 -0
- package/dist/vitest-environment/types/index.d.ts +29 -0
- package/dist/vitest-environment/types/plugin.d.ts +33 -0
- package/jest-preset.cjs +17 -0
- package/package.json +178 -4
|
@@ -0,0 +1,721 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_aria_snapshot_diff = require("./_chunks/aria-snapshot-diff-D7PzpXew.cjs");
|
|
3
|
+
let _ctrl_dom_internal = require("@ctrl/dom/internal");
|
|
4
|
+
let _ctrl_dom_aria = require("@ctrl/dom/aria");
|
|
5
|
+
|
|
6
|
+
// src/aria-snapshot-match.ts
|
|
7
|
+
/** A template that is not valid aria snapshot YAML; the message names the line. */
|
|
8
|
+
var AriaTemplateError = class extends Error {
|
|
9
|
+
constructor(message, line, source, column = -1) {
|
|
10
|
+
super(`${message} (template line ${line + 1}):\n\n${source}${column >= 0 ? `\n${" ".repeat(column)}^` : ""}`);
|
|
11
|
+
this.name = "AriaTemplateError";
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
function normalizeWhitespace(text) {
|
|
15
|
+
return text.replace(/[]/g, "").replace(/[\r\n\s\t]+/g, " ").trim();
|
|
16
|
+
}
|
|
17
|
+
function textValue(raw) {
|
|
18
|
+
let regex = null;
|
|
19
|
+
if (raw.length > 1 && raw.startsWith("/") && raw.endsWith("/")) try {
|
|
20
|
+
regex = new RegExp(raw.slice(1, -1));
|
|
21
|
+
} catch {
|
|
22
|
+
regex = null;
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
raw,
|
|
26
|
+
normalized: normalizeWhitespace(raw),
|
|
27
|
+
regex
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const BOOLEAN_ATTRS = /* @__PURE__ */ new Set([
|
|
31
|
+
"disabled",
|
|
32
|
+
"expanded",
|
|
33
|
+
"active",
|
|
34
|
+
"selected",
|
|
35
|
+
"busy",
|
|
36
|
+
"hidden"
|
|
37
|
+
]);
|
|
38
|
+
/**
|
|
39
|
+
* Parses a template: a YAML sequence of `- role "name" [attr]` items, `key: text` values, nested
|
|
40
|
+
* sequences under `key:`, `- text: …` runs and `- /url:` / `- /children:` properties. A common
|
|
41
|
+
* indentation (template literals) is ignored, as are blank lines and `#` comments.
|
|
42
|
+
*/
|
|
43
|
+
function parseAriaTemplate(text) {
|
|
44
|
+
const source = text.split(/\r?\n/);
|
|
45
|
+
let minIndent = Infinity;
|
|
46
|
+
for (let i = 0; i < source.length; i++) {
|
|
47
|
+
const line = source[i];
|
|
48
|
+
const trimmed = line.trim();
|
|
49
|
+
if (trimmed === "" || trimmed.startsWith("#")) continue;
|
|
50
|
+
const indent = line.length - line.trimStart().length;
|
|
51
|
+
if (line.slice(0, indent).includes(" ")) throw new AriaTemplateError("Tabs cannot be used for indentation", i, line);
|
|
52
|
+
if (indent < minIndent) minIndent = indent;
|
|
53
|
+
}
|
|
54
|
+
const fragment = {
|
|
55
|
+
kind: "role",
|
|
56
|
+
role: "fragment",
|
|
57
|
+
name: null,
|
|
58
|
+
attrs: [],
|
|
59
|
+
url: null,
|
|
60
|
+
mode: null,
|
|
61
|
+
children: []
|
|
62
|
+
};
|
|
63
|
+
if (minIndent === Infinity) throw new AriaTemplateError("The aria snapshot template is empty", 0, text);
|
|
64
|
+
const stack = [{
|
|
65
|
+
indent: -1,
|
|
66
|
+
node: fragment,
|
|
67
|
+
line: -1
|
|
68
|
+
}];
|
|
69
|
+
for (let i = 0; i < source.length; i++) {
|
|
70
|
+
const line = source[i];
|
|
71
|
+
const trimmed = line.trim();
|
|
72
|
+
if (trimmed === "" || trimmed.startsWith("#")) continue;
|
|
73
|
+
const indent = line.length - line.trimStart().length - minIndent;
|
|
74
|
+
if (trimmed !== "-" && !trimmed.startsWith("- ")) throw new AriaTemplateError("Aria snapshot must be a YAML sequence, elements starting with \"-\"", i, line, indent + minIndent);
|
|
75
|
+
while (stack[stack.length - 1].indent >= indent) stack.pop();
|
|
76
|
+
const parent = stack[stack.length - 1];
|
|
77
|
+
if (parent.node === null) throw new AriaTemplateError(`"- text:" on line ${parent.line + 1} cannot have children`, i, line, indent + minIndent);
|
|
78
|
+
const item = trimmed.slice(2).trimStart();
|
|
79
|
+
const column = line.length - item.length;
|
|
80
|
+
const child = parseItem(item, parent.node, i, line, column);
|
|
81
|
+
if (child !== void 0) stack.push({
|
|
82
|
+
indent,
|
|
83
|
+
node: child,
|
|
84
|
+
line: i
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
if (fragment.children.length === 1 && (fragment.mode === null || fragment.mode === "contain") && fragment.url === null) return fragment.children[0];
|
|
88
|
+
return fragment;
|
|
89
|
+
}
|
|
90
|
+
/** One sequence item; returns the node that following deeper items nest under (null: a text item). */
|
|
91
|
+
function parseItem(item, parent, lineNo, line, column) {
|
|
92
|
+
const fail = (message, offset) => {
|
|
93
|
+
throw new AriaTemplateError(message, lineNo, line, column + offset);
|
|
94
|
+
};
|
|
95
|
+
if (item === "") fail("Empty sequence item", 0);
|
|
96
|
+
if (item.startsWith("/")) {
|
|
97
|
+
const colon = item.indexOf(":");
|
|
98
|
+
if (colon < 0) fail("Property should be written `/name: value`", item.length);
|
|
99
|
+
const prop = item.slice(1, colon).trim();
|
|
100
|
+
const value = parseScalar(item.slice(colon + 1), fail, colon + 1);
|
|
101
|
+
if (prop === "children") {
|
|
102
|
+
if (value !== "contain" && value !== "equal" && value !== "deep-equal") fail("Value of \"/children\" should be \"contain\", \"equal\" or \"deep-equal\"", colon + 1);
|
|
103
|
+
parent.mode = value;
|
|
104
|
+
} else if (prop === "url") parent.url = textValue(value);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
let node;
|
|
108
|
+
let rest = null;
|
|
109
|
+
try {
|
|
110
|
+
if (item[0] === "\"" || item[0] === "'") {
|
|
111
|
+
const [key, end] = readQuoted(item, 0, fail);
|
|
112
|
+
const after = item.slice(end).trimStart();
|
|
113
|
+
if (after !== "" && after[0] !== ":") fail("Unexpected input after the quoted key", end);
|
|
114
|
+
if (after !== "") rest = after.slice(1);
|
|
115
|
+
if (key === "text" && rest !== null) return textItem(parent, rest, fail, item.length - rest.length);
|
|
116
|
+
node = new KeyParser(key).parse(false);
|
|
117
|
+
} else {
|
|
118
|
+
if (/^text:(\s|$)/.test(item)) return textItem(parent, item.slice(5), fail, 5);
|
|
119
|
+
const parser = new KeyParser(item);
|
|
120
|
+
node = parser.parse(true);
|
|
121
|
+
if (parser.pos < item.length) rest = item.slice(parser.pos + 1);
|
|
122
|
+
}
|
|
123
|
+
} catch (error) {
|
|
124
|
+
if (error instanceof KeyError) fail(error.message, item[0] === "\"" || item[0] === "'" ? 0 : error.pos);
|
|
125
|
+
throw error;
|
|
126
|
+
}
|
|
127
|
+
if (rest !== null && rest.trim() !== "") node.children.push({
|
|
128
|
+
kind: "text",
|
|
129
|
+
text: textValue(parseScalar(rest, fail, item.length - rest.length))
|
|
130
|
+
});
|
|
131
|
+
parent.children.push(node);
|
|
132
|
+
return node;
|
|
133
|
+
}
|
|
134
|
+
function textItem(parent, rest, fail, offset) {
|
|
135
|
+
parent.children.push({
|
|
136
|
+
kind: "text",
|
|
137
|
+
text: textValue(parseScalar(rest, fail, offset))
|
|
138
|
+
});
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
/** A YAML scalar after `key:`: double- or single-quoted, or plain (to a ` #` comment). */
|
|
142
|
+
function parseScalar(text, fail, offset) {
|
|
143
|
+
const lead = text.length - text.trimStart().length;
|
|
144
|
+
const value = text.trim();
|
|
145
|
+
if (value[0] === "\"" || value[0] === "'") {
|
|
146
|
+
const [unquoted, end] = readQuoted(value, 0, (m, o) => fail(m, offset + lead + o));
|
|
147
|
+
const after = value.slice(end).trim();
|
|
148
|
+
if (after !== "" && !after.startsWith("#")) fail("Unexpected input after the quoted value", offset + lead + end);
|
|
149
|
+
return unquoted;
|
|
150
|
+
}
|
|
151
|
+
if (value === "|" || value === ">" || value.startsWith("|") || value.startsWith(">")) fail("Block scalars are not supported in aria snapshot templates", offset + lead);
|
|
152
|
+
const comment = value.search(/\s#/);
|
|
153
|
+
return comment >= 0 ? value.slice(0, comment).trim() : value;
|
|
154
|
+
}
|
|
155
|
+
/** A YAML double-quoted (JSON-like escapes) or single-quoted (`''`) scalar starting at `start`. */
|
|
156
|
+
function readQuoted(text, start, fail) {
|
|
157
|
+
const q = text[start];
|
|
158
|
+
let out = "";
|
|
159
|
+
for (let i = start + 1; i < text.length; i++) {
|
|
160
|
+
const ch = text[i];
|
|
161
|
+
if (q === "'") {
|
|
162
|
+
if (ch === "'") {
|
|
163
|
+
if (text[i + 1] === "'") {
|
|
164
|
+
out += "'";
|
|
165
|
+
i++;
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
return [out, i + 1];
|
|
169
|
+
}
|
|
170
|
+
out += ch;
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
if (ch === "\"") return [out, i + 1];
|
|
174
|
+
if (ch === "\\") {
|
|
175
|
+
const next = text[++i];
|
|
176
|
+
if (next === "n") out += "\n";
|
|
177
|
+
else if (next === "t") out += " ";
|
|
178
|
+
else if (next === "u") {
|
|
179
|
+
out += String.fromCharCode(parseInt(text.slice(i + 1, i + 5), 16));
|
|
180
|
+
i += 4;
|
|
181
|
+
} else out += next ?? "";
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
out += ch;
|
|
185
|
+
}
|
|
186
|
+
return fail("Unterminated string", text.length);
|
|
187
|
+
}
|
|
188
|
+
var KeyError = class extends Error {
|
|
189
|
+
pos;
|
|
190
|
+
constructor(message, pos) {
|
|
191
|
+
super(message);
|
|
192
|
+
this.pos = pos;
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
var KeyParser = class {
|
|
196
|
+
pos = 0;
|
|
197
|
+
input;
|
|
198
|
+
constructor(input) {
|
|
199
|
+
this.input = input;
|
|
200
|
+
}
|
|
201
|
+
peek() {
|
|
202
|
+
return this.input[this.pos] ?? "";
|
|
203
|
+
}
|
|
204
|
+
eof() {
|
|
205
|
+
return this.pos >= this.input.length;
|
|
206
|
+
}
|
|
207
|
+
skipWhitespace() {
|
|
208
|
+
while (!this.eof() && /\s/.test(this.peek())) this.pos++;
|
|
209
|
+
}
|
|
210
|
+
atColon() {
|
|
211
|
+
return this.peek() === ":" && (this.pos + 1 >= this.input.length || /\s/.test(this.input[this.pos + 1]));
|
|
212
|
+
}
|
|
213
|
+
readIdentifier(type) {
|
|
214
|
+
if (this.eof()) throw new KeyError(`Unexpected end of input when expecting ${type}`, this.pos);
|
|
215
|
+
const start = this.pos;
|
|
216
|
+
while (!this.eof() && /[a-zA-Z]/.test(this.peek())) this.pos++;
|
|
217
|
+
if (this.pos === start) throw new KeyError(`Expected ${type}`, this.pos);
|
|
218
|
+
return this.input.slice(start, this.pos);
|
|
219
|
+
}
|
|
220
|
+
readString() {
|
|
221
|
+
let result = "";
|
|
222
|
+
while (!this.eof()) {
|
|
223
|
+
const ch = this.input[this.pos++];
|
|
224
|
+
if (ch === "\\") {
|
|
225
|
+
const next = this.input[this.pos++] ?? "";
|
|
226
|
+
if (next === "n") result += "\n";
|
|
227
|
+
else if (next === "t") result += " ";
|
|
228
|
+
else if (next === "u") {
|
|
229
|
+
result += String.fromCharCode(parseInt(this.input.slice(this.pos, this.pos + 4), 16));
|
|
230
|
+
this.pos += 4;
|
|
231
|
+
} else result += next;
|
|
232
|
+
} else if (ch === "\"") return result;
|
|
233
|
+
else result += ch;
|
|
234
|
+
}
|
|
235
|
+
throw new KeyError("Unterminated string", this.pos);
|
|
236
|
+
}
|
|
237
|
+
readRegex() {
|
|
238
|
+
const start = this.pos;
|
|
239
|
+
let result = "";
|
|
240
|
+
let escaped = false;
|
|
241
|
+
let insideClass = false;
|
|
242
|
+
while (!this.eof()) {
|
|
243
|
+
const ch = this.input[this.pos++];
|
|
244
|
+
if (escaped) {
|
|
245
|
+
result += ch;
|
|
246
|
+
escaped = false;
|
|
247
|
+
} else if (ch === "\\") {
|
|
248
|
+
escaped = true;
|
|
249
|
+
result += ch;
|
|
250
|
+
} else if (ch === "/" && !insideClass) try {
|
|
251
|
+
return new RegExp(result);
|
|
252
|
+
} catch (error) {
|
|
253
|
+
throw new KeyError(`Invalid regular expression: ${error.message}`, start);
|
|
254
|
+
}
|
|
255
|
+
else if (ch === "[") {
|
|
256
|
+
insideClass = true;
|
|
257
|
+
result += ch;
|
|
258
|
+
} else if (ch === "]" && insideClass) {
|
|
259
|
+
result += ch;
|
|
260
|
+
insideClass = false;
|
|
261
|
+
} else result += ch;
|
|
262
|
+
}
|
|
263
|
+
throw new KeyError("Unterminated regex", this.pos);
|
|
264
|
+
}
|
|
265
|
+
parse(stopAtColon) {
|
|
266
|
+
this.skipWhitespace();
|
|
267
|
+
const role = this.readIdentifier("role");
|
|
268
|
+
this.skipWhitespace();
|
|
269
|
+
let name = null;
|
|
270
|
+
if (this.peek() === "\"") {
|
|
271
|
+
this.pos++;
|
|
272
|
+
name = normalizeWhitespace(this.readString());
|
|
273
|
+
} else if (this.peek() === "/") {
|
|
274
|
+
this.pos++;
|
|
275
|
+
name = this.readRegex();
|
|
276
|
+
}
|
|
277
|
+
const node = {
|
|
278
|
+
kind: "role",
|
|
279
|
+
role,
|
|
280
|
+
name: name === "" ? null : name,
|
|
281
|
+
attrs: [],
|
|
282
|
+
url: null,
|
|
283
|
+
mode: null,
|
|
284
|
+
children: []
|
|
285
|
+
};
|
|
286
|
+
for (;;) {
|
|
287
|
+
this.skipWhitespace();
|
|
288
|
+
if (this.peek() !== "[") break;
|
|
289
|
+
this.pos++;
|
|
290
|
+
this.skipWhitespace();
|
|
291
|
+
const errorPos = this.pos;
|
|
292
|
+
const attr = this.readIdentifier("attribute");
|
|
293
|
+
this.skipWhitespace();
|
|
294
|
+
let value = "";
|
|
295
|
+
if (this.peek() === "=") {
|
|
296
|
+
this.pos++;
|
|
297
|
+
this.skipWhitespace();
|
|
298
|
+
while (this.peek() !== "]" && !/\s/.test(this.peek()) && !this.eof()) value += this.input[this.pos++];
|
|
299
|
+
}
|
|
300
|
+
this.skipWhitespace();
|
|
301
|
+
if (this.peek() !== "]") throw new KeyError("Expected ]", this.pos);
|
|
302
|
+
this.pos++;
|
|
303
|
+
node.attrs.push([attr, checkAttribute(attr, value || "true", errorPos)]);
|
|
304
|
+
}
|
|
305
|
+
this.skipWhitespace();
|
|
306
|
+
if (stopAtColon && this.atColon()) return node;
|
|
307
|
+
if (!this.eof()) throw new KeyError(stopAtColon ? "Unexpected input (a key ends with \":\" and a space)" : "Unexpected input", this.pos);
|
|
308
|
+
return node;
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
/** Playwright's `_applyAttribute` checks, plus our snapshot's `current`, `busy` and `hidden`. */
|
|
312
|
+
function checkAttribute(attr, value, pos) {
|
|
313
|
+
if (attr === "checked" || attr === "pressed") {
|
|
314
|
+
if (value !== "true" && value !== "false" && value !== "mixed") throw new KeyError(`Value of "${attr}" attribute must be a boolean or "mixed"`, pos);
|
|
315
|
+
return value;
|
|
316
|
+
}
|
|
317
|
+
if (BOOLEAN_ATTRS.has(attr)) {
|
|
318
|
+
if (value !== "true" && value !== "false") throw new KeyError(`Value of "${attr}" attribute must be a boolean`, pos);
|
|
319
|
+
return value;
|
|
320
|
+
}
|
|
321
|
+
if (attr === "level") {
|
|
322
|
+
if (Number.isNaN(Number(value))) throw new KeyError("Value of \"level\" attribute must be a number", pos);
|
|
323
|
+
return String(Number(value));
|
|
324
|
+
}
|
|
325
|
+
if (attr === "current") return value;
|
|
326
|
+
throw new KeyError(`Unsupported attribute [${attr}]`, pos);
|
|
327
|
+
}
|
|
328
|
+
function toMatchNode(node) {
|
|
329
|
+
const children = [];
|
|
330
|
+
if (node.value !== null && node.value !== "") children.push(normalizeWhitespace(node.value));
|
|
331
|
+
for (let i = 0; i < node.children.length; i++) {
|
|
332
|
+
const c = node.children[i];
|
|
333
|
+
children.push(typeof c === "string" ? normalizeWhitespace(c) : toMatchNode(c));
|
|
334
|
+
}
|
|
335
|
+
const states = /* @__PURE__ */ new Map();
|
|
336
|
+
for (let i = 0; i < node.props.length; i++) {
|
|
337
|
+
const prop = node.props[i].slice(1, -1);
|
|
338
|
+
const eq = prop.indexOf("=");
|
|
339
|
+
if (eq < 0) states.set(prop, "true");
|
|
340
|
+
else states.set(prop.slice(0, eq), prop.slice(eq + 1));
|
|
341
|
+
}
|
|
342
|
+
return {
|
|
343
|
+
role: node.role,
|
|
344
|
+
name: normalizeWhitespace(node.name),
|
|
345
|
+
states,
|
|
346
|
+
url: node.url,
|
|
347
|
+
children,
|
|
348
|
+
props: node.props
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
/** A state's value when the snapshot omits it: what the omission means for that role. */
|
|
352
|
+
function stateOf(node, attr) {
|
|
353
|
+
const value = node.states.get(attr);
|
|
354
|
+
if (value !== void 0) return value;
|
|
355
|
+
switch (attr) {
|
|
356
|
+
case "checked": return (0, _ctrl_dom_aria.roleSupportsProp)(node.role, "aria-checked") ? "false" : void 0;
|
|
357
|
+
case "disabled":
|
|
358
|
+
case "selected":
|
|
359
|
+
case "active":
|
|
360
|
+
case "busy":
|
|
361
|
+
case "hidden":
|
|
362
|
+
case "current": return "false";
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
function attrsMatch(node, t) {
|
|
366
|
+
for (let i = 0; i < t.attrs.length; i++) {
|
|
367
|
+
const [attr, expected] = t.attrs[i];
|
|
368
|
+
const actual = stateOf(node, attr);
|
|
369
|
+
if (attr === "current" && expected === "true") {
|
|
370
|
+
if (actual === void 0 || actual === "false") return false;
|
|
371
|
+
} else if (actual !== expected) return false;
|
|
372
|
+
}
|
|
373
|
+
return true;
|
|
374
|
+
}
|
|
375
|
+
function matchesName(name, template) {
|
|
376
|
+
if (template === null) return true;
|
|
377
|
+
if (name === "") return false;
|
|
378
|
+
if (typeof template === "string") return name === template;
|
|
379
|
+
return template.test(name);
|
|
380
|
+
}
|
|
381
|
+
function matchesText(text, template) {
|
|
382
|
+
if (template === null || template.normalized === "") return true;
|
|
383
|
+
if (!text) return false;
|
|
384
|
+
if (text === template.normalized || text === template.raw) return true;
|
|
385
|
+
return template.regex !== null && template.regex.test(text);
|
|
386
|
+
}
|
|
387
|
+
function headerMatches(node, t) {
|
|
388
|
+
return (t.role === "fragment" || t.role === node.role) && attrsMatch(node, t) && matchesName(node.name, t.name) && matchesText(node.url, t.url);
|
|
389
|
+
}
|
|
390
|
+
function matchesNode(node, t, deepEqual) {
|
|
391
|
+
if (typeof node === "string") return t.kind === "text" && matchesText(node, t.text);
|
|
392
|
+
if (t.kind !== "role" || !headerMatches(node, t)) return false;
|
|
393
|
+
if (t.mode === "contain") return containsList(node.children, t.children);
|
|
394
|
+
if (t.mode === "equal") return listEqual(node.children, t.children, false);
|
|
395
|
+
if (t.mode === "deep-equal" || deepEqual) return listEqual(node.children, t.children, true);
|
|
396
|
+
return containsList(node.children, t.children);
|
|
397
|
+
}
|
|
398
|
+
function listEqual(children, templates, deepEqual) {
|
|
399
|
+
if (templates.length !== children.length) return false;
|
|
400
|
+
for (let i = 0; i < templates.length; i++) if (!matchesNode(children[i], templates[i], deepEqual)) return false;
|
|
401
|
+
return true;
|
|
402
|
+
}
|
|
403
|
+
function containsList(children, templates) {
|
|
404
|
+
if (templates.length > children.length) return false;
|
|
405
|
+
let c = 0;
|
|
406
|
+
for (let i = 0; i < templates.length; i++) {
|
|
407
|
+
while (c < children.length && !matchesNode(children[c], templates[i], false)) c++;
|
|
408
|
+
if (c === children.length) return false;
|
|
409
|
+
c++;
|
|
410
|
+
}
|
|
411
|
+
return true;
|
|
412
|
+
}
|
|
413
|
+
function matchesDeep(node, t) {
|
|
414
|
+
if (matchesNode(node, t, false)) return true;
|
|
415
|
+
if (typeof node === "string") return false;
|
|
416
|
+
for (let i = 0; i < node.children.length; i++) if (matchesDeep(node.children[i], t)) return true;
|
|
417
|
+
return false;
|
|
418
|
+
}
|
|
419
|
+
const MAX_TEXT = 100;
|
|
420
|
+
function textRepr(value) {
|
|
421
|
+
return value.regex !== null ? value.raw : require_aria_snapshot_diff.yamlValue(value.normalized);
|
|
422
|
+
}
|
|
423
|
+
function templateKey(t) {
|
|
424
|
+
let key = t.role;
|
|
425
|
+
if (typeof t.name === "string") key += " " + require_aria_snapshot_diff.quote(t.name);
|
|
426
|
+
else if (t.name !== null) key += ` /${t.name.source}/`;
|
|
427
|
+
for (let i = 0; i < t.attrs.length; i++) key += t.attrs[i][1] === "true" ? ` [${t.attrs[i][0]}]` : ` [${t.attrs[i][0]}=${t.attrs[i][1]}]`;
|
|
428
|
+
return key;
|
|
429
|
+
}
|
|
430
|
+
function receivedKey(node) {
|
|
431
|
+
let key = node.role;
|
|
432
|
+
if (node.name !== "") key += " " + require_aria_snapshot_diff.quote(require_aria_snapshot_diff.truncate(node.name, MAX_TEXT));
|
|
433
|
+
for (let i = 0; i < node.props.length; i++) key += " " + node.props[i];
|
|
434
|
+
return key;
|
|
435
|
+
}
|
|
436
|
+
function isInline(t) {
|
|
437
|
+
return t.url === null && t.mode === null && t.children.length === 1 && t.children[0].kind === "text";
|
|
438
|
+
}
|
|
439
|
+
/** The template in canonical form, one line per node. */
|
|
440
|
+
function renderTemplate(t, indent, lines) {
|
|
441
|
+
if (t.kind === "text") {
|
|
442
|
+
lines.push(`${indent}- text: ${textRepr(t.text)}`);
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
const key = templateKey(t);
|
|
446
|
+
if (isInline(t)) {
|
|
447
|
+
lines.push(`${indent}- ${key}: ${textRepr(t.children[0].text)}`);
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
if (t.children.length === 0 && t.url === null && t.mode === null) {
|
|
451
|
+
lines.push(`${indent}- ${key}`);
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
lines.push(`${indent}- ${key}:`);
|
|
455
|
+
const inner = indent + " ";
|
|
456
|
+
if (t.url !== null) lines.push(`${inner}- /url: ${textRepr(t.url)}`);
|
|
457
|
+
if (t.mode !== null) lines.push(`${inner}- /children: ${t.mode}`);
|
|
458
|
+
for (let i = 0; i < t.children.length; i++) renderTemplate(t.children[i], inner, lines);
|
|
459
|
+
}
|
|
460
|
+
/** Scores how well tree nodes fit template nodes, to pick what a failing template is compared with. */
|
|
461
|
+
var Scorer = class {
|
|
462
|
+
memo = /* @__PURE__ */ new Map();
|
|
463
|
+
score(t, node) {
|
|
464
|
+
if (t.kind === "text") return typeof node === "string" ? matchesText(node, t.text) ? 3 : 1 : 0;
|
|
465
|
+
if (typeof node === "string" || t.role !== "fragment" && t.role !== node.role) return 0;
|
|
466
|
+
let byNode = this.memo.get(t);
|
|
467
|
+
if (byNode === void 0) this.memo.set(t, byNode = /* @__PURE__ */ new Map());
|
|
468
|
+
const cached = byNode.get(node);
|
|
469
|
+
if (cached !== void 0) return cached;
|
|
470
|
+
let score = 2;
|
|
471
|
+
score += t.name === null ? 1 : matchesName(node.name, t.name) ? 2 : 0;
|
|
472
|
+
if (attrsMatch(node, t)) score += 1;
|
|
473
|
+
if (t.url !== null && matchesText(node.url, t.url)) score += 1;
|
|
474
|
+
score += this.scoreList(t.children, node.children);
|
|
475
|
+
byNode.set(node, score);
|
|
476
|
+
return score;
|
|
477
|
+
}
|
|
478
|
+
scoreList(templates, children) {
|
|
479
|
+
const aligned = this.align(templates, children);
|
|
480
|
+
let score = 0;
|
|
481
|
+
for (let i = 0; i < templates.length; i++) if (aligned[i] !== null) score += this.score(templates[i], aligned[i]);
|
|
482
|
+
return score;
|
|
483
|
+
}
|
|
484
|
+
/** For each template, in order, the best-scoring child after the previous one's (or null). */
|
|
485
|
+
align(templates, children) {
|
|
486
|
+
const out = [];
|
|
487
|
+
let from = 0;
|
|
488
|
+
for (let i = 0; i < templates.length; i++) {
|
|
489
|
+
let best = -1;
|
|
490
|
+
let bestScore = 0;
|
|
491
|
+
for (let j = from; j < children.length; j++) {
|
|
492
|
+
const s = this.score(templates[i], children[j]);
|
|
493
|
+
if (s > bestScore) {
|
|
494
|
+
best = j;
|
|
495
|
+
bestScore = s;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
if (best < 0) out.push(null);
|
|
499
|
+
else {
|
|
500
|
+
out.push(children[best]);
|
|
501
|
+
from = best + 1;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
return out;
|
|
505
|
+
}
|
|
506
|
+
/** The tree node rendered in the template's shape: matching parts print as the template does. */
|
|
507
|
+
project(t, node, indent, lines) {
|
|
508
|
+
if (t.kind === "text") {
|
|
509
|
+
const text = node;
|
|
510
|
+
lines.push(`${indent}- text: ${matchesText(text, t.text) ? textRepr(t.text) : require_aria_snapshot_diff.yamlValue(require_aria_snapshot_diff.truncate(text, MAX_TEXT))}`);
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
513
|
+
const n = node;
|
|
514
|
+
const key = headerMatches(n, t) ? templateKey(t) : receivedKey(n);
|
|
515
|
+
const aligned = this.align(t.children, n.children);
|
|
516
|
+
if (isInline(t)) {
|
|
517
|
+
const text = aligned[0];
|
|
518
|
+
const tt = t.children[0].text;
|
|
519
|
+
lines.push(text === null ? `${indent}- ${key}` : `${indent}- ${key}: ${matchesText(text, tt) ? textRepr(tt) : require_aria_snapshot_diff.yamlValue(require_aria_snapshot_diff.truncate(text, MAX_TEXT))}`);
|
|
520
|
+
return;
|
|
521
|
+
}
|
|
522
|
+
if (t.children.length === 0 && t.url === null && t.mode === null) {
|
|
523
|
+
lines.push(`${indent}- ${key}`);
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
lines.push(`${indent}- ${key}:`);
|
|
527
|
+
const inner = indent + " ";
|
|
528
|
+
if (t.url !== null) lines.push(`${inner}- /url: ${matchesText(n.url, t.url) ? textRepr(t.url) : require_aria_snapshot_diff.yamlValue(n.url ?? "")}`);
|
|
529
|
+
if (t.mode !== null) lines.push(`${inner}- /children: ${t.mode}`);
|
|
530
|
+
for (let i = 0; i < t.children.length; i++) if (aligned[i] !== null) this.project(t.children[i], aligned[i], inner, lines);
|
|
531
|
+
}
|
|
532
|
+
};
|
|
533
|
+
function forEachNode(node, visit) {
|
|
534
|
+
visit(node);
|
|
535
|
+
for (let i = 0; i < node.children.length; i++) {
|
|
536
|
+
const c = node.children[i];
|
|
537
|
+
if (typeof c === "string") visit(c);
|
|
538
|
+
else forEachNode(c, visit);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
/** The closest part of the tree to `t`, projected onto its shape. */
|
|
542
|
+
function closestLines(root, t) {
|
|
543
|
+
const scorer = new Scorer();
|
|
544
|
+
const lines = [];
|
|
545
|
+
if (t.kind === "role" && t.role === "fragment") {
|
|
546
|
+
let best = null;
|
|
547
|
+
let bestScore = 0;
|
|
548
|
+
forEachNode(root, (node) => {
|
|
549
|
+
if (typeof node === "string") return;
|
|
550
|
+
const s = scorer.scoreList(t.children, node.children);
|
|
551
|
+
if (s > bestScore) {
|
|
552
|
+
best = node;
|
|
553
|
+
bestScore = s;
|
|
554
|
+
}
|
|
555
|
+
});
|
|
556
|
+
if (best !== null) {
|
|
557
|
+
const aligned = scorer.align(t.children, best.children);
|
|
558
|
+
for (let i = 0; i < t.children.length; i++) if (aligned[i] !== null) scorer.project(t.children[i], aligned[i], "", lines);
|
|
559
|
+
}
|
|
560
|
+
return lines;
|
|
561
|
+
}
|
|
562
|
+
let best = null;
|
|
563
|
+
let bestScore = 0;
|
|
564
|
+
forEachNode(root, (node) => {
|
|
565
|
+
const s = scorer.score(t, node);
|
|
566
|
+
if (s > bestScore) {
|
|
567
|
+
best = node;
|
|
568
|
+
bestScore = s;
|
|
569
|
+
}
|
|
570
|
+
});
|
|
571
|
+
if (best !== null) scorer.project(t, best, "", lines);
|
|
572
|
+
return lines;
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* A run of N removed lines followed by N added ones becomes N `-`/`+` pairs: the projection has
|
|
576
|
+
* the template's shape, so the i-th removed and added lines are the same template node.
|
|
577
|
+
*/
|
|
578
|
+
function pairChanges(ops) {
|
|
579
|
+
const out = [];
|
|
580
|
+
for (let i = 0; i < ops.length;) {
|
|
581
|
+
if (ops[i].kind === "=") {
|
|
582
|
+
out.push(ops[i++]);
|
|
583
|
+
continue;
|
|
584
|
+
}
|
|
585
|
+
let r = i;
|
|
586
|
+
while (r < ops.length && ops[r].kind === "-") r++;
|
|
587
|
+
let a = r;
|
|
588
|
+
while (a < ops.length && ops[a].kind === "+") a++;
|
|
589
|
+
if (r - i === a - r) for (let k = 0; k < r - i; k++) out.push(ops[i + k], ops[r + k]);
|
|
590
|
+
else for (let k = i; k < a; k++) out.push(ops[k]);
|
|
591
|
+
i = a;
|
|
592
|
+
}
|
|
593
|
+
return out;
|
|
594
|
+
}
|
|
595
|
+
/** Line budget for the received snapshot in a failure message. */
|
|
596
|
+
const RECEIVED_MAX_LINES = 100;
|
|
597
|
+
/**
|
|
598
|
+
* Matches the accessibility tree of `container` (an element prints itself, a body, document or
|
|
599
|
+
* fragment its children) against an aria snapshot template, with Playwright's partial matching.
|
|
600
|
+
* Throws AriaTemplateError for an invalid template.
|
|
601
|
+
*/
|
|
602
|
+
function matchAriaSnapshot(container, template) {
|
|
603
|
+
const t = parseAriaTemplate(template);
|
|
604
|
+
const tree = require_aria_snapshot_diff.ariaSnapshotTree(container, { urls: true });
|
|
605
|
+
const children = [];
|
|
606
|
+
for (let i = 0; i < tree.length; i++) {
|
|
607
|
+
const c = tree[i];
|
|
608
|
+
children.push(typeof c === "string" ? normalizeWhitespace(c) : toMatchNode(c));
|
|
609
|
+
}
|
|
610
|
+
const root = {
|
|
611
|
+
role: "fragment",
|
|
612
|
+
name: "",
|
|
613
|
+
states: /* @__PURE__ */ new Map(),
|
|
614
|
+
url: null,
|
|
615
|
+
children,
|
|
616
|
+
props: []
|
|
617
|
+
};
|
|
618
|
+
const pass = matchesDeep(root, t);
|
|
619
|
+
const expectedLines = () => {
|
|
620
|
+
const lines = [];
|
|
621
|
+
if (t.kind === "role" && t.role === "fragment") {
|
|
622
|
+
if (t.mode !== null) lines.push(`- /children: ${t.mode}`);
|
|
623
|
+
for (let i = 0; i < t.children.length; i++) renderTemplate(t.children[i], "", lines);
|
|
624
|
+
} else renderTemplate(t, "", lines);
|
|
625
|
+
return lines;
|
|
626
|
+
};
|
|
627
|
+
return {
|
|
628
|
+
pass,
|
|
629
|
+
expected: () => expectedLines().join("\n"),
|
|
630
|
+
diff: () => pairChanges(require_aria_snapshot_diff.diffLines(expectedLines(), closestLines(root, t))),
|
|
631
|
+
received: () => require_aria_snapshot_diff.ariaSnapshot(container, {
|
|
632
|
+
collapseAfter: Infinity,
|
|
633
|
+
maxLines: require_aria_snapshot_diff.envMaxLines() ?? RECEIVED_MAX_LINES
|
|
634
|
+
})
|
|
635
|
+
};
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
// src/agent.ts
|
|
639
|
+
/** Line budget for "what changed" in a failure report. */
|
|
640
|
+
const CHANGES_MAX_LINES = 40;
|
|
641
|
+
/** Forget the previous snapshot: call when a test starts. */
|
|
642
|
+
function resetFailureSnapshot(document) {
|
|
643
|
+
require_aria_snapshot_diff.resetBodySnapshot(document);
|
|
644
|
+
}
|
|
645
|
+
/** Snapshot `document.body` for a failure report; null when `CTRL_DOM_DEBUG` is unset or there is no body. */
|
|
646
|
+
function captureFailureSnapshot(document) {
|
|
647
|
+
const format = require_aria_snapshot_diff.envDebugFormat();
|
|
648
|
+
const body = document?.body;
|
|
649
|
+
if (format === null || body == null || body[_ctrl_dom_internal.$impl] === void 0) return null;
|
|
650
|
+
if (format === "compact") {
|
|
651
|
+
const html = require_aria_snapshot_diff.prettyDOM(body, void 0, { format: "compact" });
|
|
652
|
+
return {
|
|
653
|
+
format,
|
|
654
|
+
text: String(html),
|
|
655
|
+
full: "",
|
|
656
|
+
previous: void 0
|
|
657
|
+
};
|
|
658
|
+
}
|
|
659
|
+
const previous = require_aria_snapshot_diff.lastBodySnapshot(document);
|
|
660
|
+
const { lines, empty } = require_aria_snapshot_diff.ariaSnapshotLines(body);
|
|
661
|
+
const full = empty ?? lines.join("\n");
|
|
662
|
+
return {
|
|
663
|
+
format,
|
|
664
|
+
text: empty ?? require_aria_snapshot_diff.budgetLines(lines, require_aria_snapshot_diff.envMaxLines() ?? 100).join("\n"),
|
|
665
|
+
full,
|
|
666
|
+
previous
|
|
667
|
+
};
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* The report appended to a failing test's error. A snapshot the error message already contains
|
|
671
|
+
* (a failed query under `CTRL_DOM_DEBUG=aria` prints one) is not repeated.
|
|
672
|
+
*/
|
|
673
|
+
function formatFailureSnapshot(snapshot, errorMessage) {
|
|
674
|
+
if (snapshot.format === "compact") return `DOM of <body> when the test failed (CTRL_DOM_DEBUG=compact):\n${snapshot.text}`;
|
|
675
|
+
if (errorMessage.includes(snapshot.text)) return "Accessibility snapshot of <body> when the test failed: the same as above.";
|
|
676
|
+
let report = `Accessibility snapshot of <body> when the test failed (CTRL_DOM_DEBUG=aria):\n${snapshot.text}`;
|
|
677
|
+
if (snapshot.previous !== void 0) {
|
|
678
|
+
if (snapshot.previous === snapshot.full) report += "\n\nUnchanged since the previous snapshot in this test.";
|
|
679
|
+
else report += `\n\nChanges since the previous snapshot in this test:\n${require_aria_snapshot_diff.budgetLines(require_aria_snapshot_diff.diffAriaSnapshots(snapshot.previous, snapshot.full).split("\n"), CHANGES_MAX_LINES).join("\n")}`;
|
|
680
|
+
}
|
|
681
|
+
return report;
|
|
682
|
+
}
|
|
683
|
+
/**
|
|
684
|
+
* Append `text` to an error's message (and to its `stack`, which V8 formats with the message
|
|
685
|
+
* once read). Works on Error objects and on the plain serialized errors test runners keep.
|
|
686
|
+
*/
|
|
687
|
+
function appendToErrorMessage(error, text) {
|
|
688
|
+
if (error === null || typeof error !== "object") return false;
|
|
689
|
+
const e = error;
|
|
690
|
+
const message = typeof e.message === "string" ? e.message : "";
|
|
691
|
+
let stack;
|
|
692
|
+
try {
|
|
693
|
+
stack = e.stack;
|
|
694
|
+
} catch {
|
|
695
|
+
stack = void 0;
|
|
696
|
+
}
|
|
697
|
+
const next = message === "" ? text : `${message}\n\n${text}`;
|
|
698
|
+
try {
|
|
699
|
+
e.message = next;
|
|
700
|
+
if (typeof stack === "string") {
|
|
701
|
+
const at = message === "" ? -1 : stack.indexOf(message);
|
|
702
|
+
if (at >= 0) e.stack = stack.slice(0, at) + next + stack.slice(at + message.length);
|
|
703
|
+
else {
|
|
704
|
+
const eol = stack.indexOf("\n");
|
|
705
|
+
e.stack = eol < 0 ? `${stack}\n\n${text}` : `${stack.slice(0, eol)}\n\n${text}${stack.slice(eol)}`;
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
} catch {
|
|
709
|
+
return false;
|
|
710
|
+
}
|
|
711
|
+
return true;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
exports.AriaTemplateError = AriaTemplateError;
|
|
715
|
+
exports.appendToErrorMessage = appendToErrorMessage;
|
|
716
|
+
exports.captureFailureSnapshot = captureFailureSnapshot;
|
|
717
|
+
exports.envDebugFormat = require_aria_snapshot_diff.envDebugFormat;
|
|
718
|
+
exports.formatFailureSnapshot = formatFailureSnapshot;
|
|
719
|
+
exports.matchAriaSnapshot = matchAriaSnapshot;
|
|
720
|
+
exports.parseAriaTemplate = parseAriaTemplate;
|
|
721
|
+
exports.resetFailureSnapshot = resetFailureSnapshot;
|