@ctrl/dom 0.0.0-stage → 0.1.0
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-DWP2w3IQ.js +47516 -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 +153 -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 +3910 -0
- package/dist/user-event/index.js +3885 -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 +50 -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 +177 -3
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Element, Node } from '../../dom-types.js';
|
|
2
|
+
import { type PointerCoords } from '../../event/index.js';
|
|
3
|
+
import { MouseButton } from './buttons.js';
|
|
4
|
+
export interface pointerKey {
|
|
5
|
+
/** Name of the pointer key */
|
|
6
|
+
name: string;
|
|
7
|
+
/** Type of the pointer device */
|
|
8
|
+
pointerType: 'mouse' | 'pen' | 'touch';
|
|
9
|
+
/** Type of button */
|
|
10
|
+
button?: MouseButton;
|
|
11
|
+
}
|
|
12
|
+
export interface PointerPosition {
|
|
13
|
+
target?: Element;
|
|
14
|
+
coords?: PointerCoords;
|
|
15
|
+
caret?: CaretPosition;
|
|
16
|
+
}
|
|
17
|
+
export interface CaretPosition {
|
|
18
|
+
node?: Node;
|
|
19
|
+
offset?: number;
|
|
20
|
+
}
|
|
21
|
+
export declare function isDifferentPointerPosition(positionA: PointerPosition, positionB: PointerPosition): boolean;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Element, HTMLElement } from '../dom-types.js';
|
|
2
|
+
import { type Instance } from '../setup/index.js';
|
|
3
|
+
export declare function selectOptions(this: Instance, select: Element, values: HTMLElement | HTMLElement[] | string[] | string): Promise<void>;
|
|
4
|
+
export declare function deselectOptions(this: Instance, select: Element, values: HTMLElement | HTMLElement[] | string[] | string): Promise<void>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Element } from '../dom-types.js';
|
|
2
|
+
import { type Instance } from '../setup/index.js';
|
|
3
|
+
import { type Options } from '../options.js';
|
|
4
|
+
export interface typeOptions {
|
|
5
|
+
skipClick?: Options['skipClick'];
|
|
6
|
+
skipAutoClose?: Options['skipAutoClose'];
|
|
7
|
+
initialSelectionStart?: number;
|
|
8
|
+
initialSelectionEnd?: number;
|
|
9
|
+
}
|
|
10
|
+
export declare function type(this: Instance, element: Element, text: string, { skipClick, skipAutoClose, initialSelectionStart, initialSelectionEnd, }?: typeOptions): Promise<void>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { EventInit, File, HTMLElement } from '../dom-types.js';
|
|
2
|
+
import { type Instance } from '../setup/index.js';
|
|
3
|
+
export interface uploadInit {
|
|
4
|
+
changeInit?: EventInit;
|
|
5
|
+
}
|
|
6
|
+
export declare function upload(this: Instance, element: HTMLElement, fileOrFiles: File | File[]): Promise<void>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Element, HTMLButtonElement, HTMLInputElement } from '../../dom-types.js';
|
|
2
|
+
declare const clickableInputTypes: {
|
|
3
|
+
readonly button: 'button';
|
|
4
|
+
readonly color: 'color';
|
|
5
|
+
readonly file: 'file';
|
|
6
|
+
readonly image: 'image';
|
|
7
|
+
readonly reset: 'reset';
|
|
8
|
+
readonly submit: 'submit';
|
|
9
|
+
readonly checkbox: 'checkbox';
|
|
10
|
+
readonly radio: 'radio';
|
|
11
|
+
};
|
|
12
|
+
type clickableInputTypes = keyof typeof clickableInputTypes;
|
|
13
|
+
export type ClickableInputOrButton = HTMLButtonElement | (HTMLInputElement & {
|
|
14
|
+
type: clickableInputTypes;
|
|
15
|
+
});
|
|
16
|
+
export declare function isClickableInput(element: Element): element is ClickableInputOrButton;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Blob, ClipboardItem, DataTransfer, Document, Window } from '../../dom-types.js';
|
|
2
|
+
export declare function createClipboardItem(window: Window, ...blobs: Array<Blob | string>): ClipboardItem;
|
|
3
|
+
type ClipboardStubControlInstance = {
|
|
4
|
+
resetClipboardStub: () => void;
|
|
5
|
+
detachClipboardStub: () => void;
|
|
6
|
+
};
|
|
7
|
+
export declare function attachClipboardStubToView(window: Window): ClipboardStubControlInstance;
|
|
8
|
+
export declare function resetClipboardStubOnView(window: Window): void;
|
|
9
|
+
export declare function detachClipboardStubFromView(window: Window): void;
|
|
10
|
+
export declare function readDataTransferFromClipboard(document: Document): Promise<DataTransfer>;
|
|
11
|
+
export declare function writeDataTransferToClipboard(document: Document, clipboardData: DataTransfer): Promise<void>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { DataTransfer, DataTransferItem, File, Window } from '../../dom-types.js';
|
|
2
|
+
export declare function createDataTransfer(window: Window, files?: File[]): DataTransfer;
|
|
3
|
+
export declare function getBlobFromDataTransferItem(window: Window, item: DataTransferItem): Promise<import("../../dom-types.js").Blob>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Element, HTMLElement, Node } from '../../dom-types.js';
|
|
2
|
+
export declare function isContentEditable(element: Element): element is HTMLElement & {
|
|
3
|
+
contenteditable: 'true';
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* If a node is a contenteditable or inside one, return that element.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getContentEditable(node: Node): Element | null;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Element, HTMLInputElement, HTMLTextAreaElement } from '../../dom-types.js';
|
|
2
|
+
import { isContentEditable } from './isContentEditable.js';
|
|
3
|
+
type GuardedType<T> = T extends ((x: any) => x is infer R) ? R : never;
|
|
4
|
+
export declare function isEditable(element: Element): element is GuardedType<typeof isContentEditable> | (EditableInputOrTextarea & {
|
|
5
|
+
readOnly: false;
|
|
6
|
+
});
|
|
7
|
+
declare const editableInputTypes: {
|
|
8
|
+
readonly text: 'text';
|
|
9
|
+
readonly date: 'date';
|
|
10
|
+
readonly 'datetime-local': 'datetime-local';
|
|
11
|
+
readonly email: 'email';
|
|
12
|
+
readonly month: 'month';
|
|
13
|
+
readonly number: 'number';
|
|
14
|
+
readonly password: 'password';
|
|
15
|
+
readonly search: 'search';
|
|
16
|
+
readonly tel: 'tel';
|
|
17
|
+
readonly time: 'time';
|
|
18
|
+
readonly url: 'url';
|
|
19
|
+
readonly week: 'week';
|
|
20
|
+
};
|
|
21
|
+
type editableInputTypes = keyof typeof editableInputTypes;
|
|
22
|
+
export type EditableInputOrTextarea = HTMLTextAreaElement | (HTMLInputElement & {
|
|
23
|
+
type: editableInputTypes;
|
|
24
|
+
});
|
|
25
|
+
export declare function isEditableInputOrTextArea(element: Element): element is EditableInputOrTextarea;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Element, HTMLInputElement, HTMLTextAreaElement } from '../../dom-types.js';
|
|
2
|
+
declare const maxLengthSupportedTypes: {
|
|
3
|
+
readonly email: 'email';
|
|
4
|
+
readonly password: 'password';
|
|
5
|
+
readonly search: 'search';
|
|
6
|
+
readonly telephone: 'telephone';
|
|
7
|
+
readonly text: 'text';
|
|
8
|
+
readonly url: 'url';
|
|
9
|
+
};
|
|
10
|
+
type maxLengthSupportedTypes = keyof typeof maxLengthSupportedTypes;
|
|
11
|
+
type ElementWithMaxLengthSupport = HTMLTextAreaElement | (HTMLInputElement & {
|
|
12
|
+
type: maxLengthSupportedTypes;
|
|
13
|
+
});
|
|
14
|
+
export declare function getMaxLength(element: ElementWithMaxLengthSupport): number | undefined;
|
|
15
|
+
export declare function supportsMaxLength(element: Element): element is ElementWithMaxLengthSupport;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FileList, HTMLInputElement } from '../../dom-types.js';
|
|
2
|
+
declare const fakeFiles: unique symbol;
|
|
3
|
+
type FakeFilesInput = HTMLInputElement & {
|
|
4
|
+
[fakeFiles]?: {
|
|
5
|
+
restore: () => void;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export declare function setFiles(el: FakeFilesInput & {
|
|
9
|
+
type: 'file';
|
|
10
|
+
}, files: FileList): void;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Node } from '../../dom-types.js';
|
|
2
|
+
import { type ClickableInputOrButton } from '../click/isClickableInput.js';
|
|
3
|
+
import { type EditableInputOrTextarea } from '../edit/isEditable.js';
|
|
4
|
+
/**
|
|
5
|
+
* Determine if the element has its own selection implementation
|
|
6
|
+
* and does not interact with the Document Selection API.
|
|
7
|
+
*/
|
|
8
|
+
export declare function hasOwnSelection(node: Node): node is EditableInputOrTextarea;
|
|
9
|
+
export declare function hasNoSelection(node: Node): node is ClickableInputOrButton;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const FOCUSABLE_SELECTOR: string;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export * from './click/isClickableInput.js';
|
|
2
|
+
export * from './dataTransfer/Blob.js';
|
|
3
|
+
export * from './dataTransfer/DataTransfer.js';
|
|
4
|
+
export * from './dataTransfer/FileList.js';
|
|
5
|
+
export * from './dataTransfer/Clipboard.js';
|
|
6
|
+
export * from './edit/timeValue.js';
|
|
7
|
+
export * from './edit/isContentEditable.js';
|
|
8
|
+
export * from './edit/isEditable.js';
|
|
9
|
+
export * from './edit/maxLength.js';
|
|
10
|
+
export * from './edit/setFiles.js';
|
|
11
|
+
export * from './focus/cursor.js';
|
|
12
|
+
export * from './focus/getActiveElement.js';
|
|
13
|
+
export * from './focus/getTabDestination.js';
|
|
14
|
+
export * from './focus/isFocusable.js';
|
|
15
|
+
export * from './focus/selection.js';
|
|
16
|
+
export * from './focus/selector.js';
|
|
17
|
+
export * from './keyDef/readNextDescriptor.js';
|
|
18
|
+
export * from './misc/cloneEvent.js';
|
|
19
|
+
export * from './misc/findClosest.js';
|
|
20
|
+
export * from './misc/getDocumentFromNode.js';
|
|
21
|
+
export * from './misc/getTreeDiff.js';
|
|
22
|
+
export * from './misc/getWindow.js';
|
|
23
|
+
export * from './misc/isDescendantOrSelf.js';
|
|
24
|
+
export * from './misc/isElementType.js';
|
|
25
|
+
export * from './misc/isVisible.js';
|
|
26
|
+
export * from './misc/isDisabled.js';
|
|
27
|
+
export * from './misc/level.js';
|
|
28
|
+
export * from './misc/wait.js';
|
|
29
|
+
export * from './pointer/cssPointerEvents.js';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
type Context = 'pointer' | 'keyboard';
|
|
2
|
+
/**
|
|
3
|
+
* Read the next key definition from user input
|
|
4
|
+
*
|
|
5
|
+
* Describe key per `{descriptor}` or `[descriptor]`.
|
|
6
|
+
* Everything else will be interpreted as a single character as descriptor - e.g. `a`.
|
|
7
|
+
* Brackets `{` and `[` can be escaped by doubling - e.g. `foo[[bar` translates to `foo[bar`.
|
|
8
|
+
* A previously pressed key can be released per `{/descriptor}`.
|
|
9
|
+
* Keeping the key pressed can be written as `{descriptor>}`.
|
|
10
|
+
* When keeping the key pressed you can choose how long the key is pressed `{descriptor>3}`.
|
|
11
|
+
* You can then release the key per `{descriptor>3/}` or keep it pressed and continue with the next key.
|
|
12
|
+
*/
|
|
13
|
+
export declare function readNextDescriptor(text: string, context: Context): {
|
|
14
|
+
type: string;
|
|
15
|
+
consumedLength: number;
|
|
16
|
+
descriptor: string;
|
|
17
|
+
releasePrevious: boolean;
|
|
18
|
+
repeat: number;
|
|
19
|
+
releaseSelf: boolean | undefined;
|
|
20
|
+
};
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Element, HTMLElementTagNameMap } from '../../dom-types.js';
|
|
2
|
+
type tag = keyof HTMLElementTagNameMap;
|
|
3
|
+
export declare function isElementType<T extends tag, P extends {
|
|
4
|
+
[k: string]: unknown;
|
|
5
|
+
} | undefined = undefined>(element: Element, tag: T | T[], props?: P): element is P extends undefined ? HTMLElementTagNameMap[T] : HTMLElementTagNameMap[T] & P;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Instance } from '../../setup/index.js';
|
|
2
|
+
export declare const ApiLevel: {
|
|
3
|
+
readonly Trigger: 2;
|
|
4
|
+
readonly Call: 1;
|
|
5
|
+
};
|
|
6
|
+
export type ApiLevel = (typeof ApiLevel)[keyof typeof ApiLevel];
|
|
7
|
+
export type LevelRefs = Record<ApiLevel, object | undefined>;
|
|
8
|
+
export declare function setLevelRef(instance: Instance, level: ApiLevel): void;
|
|
9
|
+
export declare function getLevelRef(instance: Instance, level: ApiLevel): object | undefined;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type Instance } from '../../setup/index.js';
|
|
2
|
+
export declare function defaultAdvanceTimers(): Promise<void>;
|
|
3
|
+
export declare function wait(config: Instance['config']): Promise<[void, void]> | undefined;
|
|
4
|
+
/** Start of an API call: re-install the observers if something replaced the timer globals. */
|
|
5
|
+
export declare function markTimers(config: Instance['config']): void;
|
|
6
|
+
export declare function yieldBetweenActions(config: Instance['config']): Promise<void>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Element } from '../../dom-types.js';
|
|
2
|
+
import { type Instance } from '../../setup/index.js';
|
|
3
|
+
export declare function hasPointerEvents(instance: Instance, element: Element): boolean;
|
|
4
|
+
export declare function assertPointerEvents(instance: Instance, element: Element): void;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { afterEach, beforeEach } from "vitest";
|
|
2
|
+
import { appendToErrorMessage, captureFailureSnapshot, envDebugFormat, formatFailureSnapshot, resetFailureSnapshot } from "@ctrl/dom/testing-library/agent";
|
|
3
|
+
|
|
4
|
+
// src/failure-snapshot.ts
|
|
5
|
+
if (envDebugFormat() !== null) installFailureSnapshots();
|
|
6
|
+
function currentDocument() {
|
|
7
|
+
return typeof document === "undefined" ? void 0 : document;
|
|
8
|
+
}
|
|
9
|
+
function installFailureSnapshots() {
|
|
10
|
+
let state = null;
|
|
11
|
+
let captured = null;
|
|
12
|
+
const capture = () => {
|
|
13
|
+
if (captured === null && state?.result?.state === "fail") captured = captureFailureSnapshot(currentDocument());
|
|
14
|
+
};
|
|
15
|
+
beforeEach((context) => {
|
|
16
|
+
state = context.task;
|
|
17
|
+
captured = null;
|
|
18
|
+
resetFailureSnapshot(currentDocument());
|
|
19
|
+
context.onTestFailed(() => {
|
|
20
|
+
capture();
|
|
21
|
+
const snapshot = captured;
|
|
22
|
+
captured = null;
|
|
23
|
+
state = null;
|
|
24
|
+
const error = context.task.result?.errors?.[0];
|
|
25
|
+
if (snapshot === null || error === void 0) return;
|
|
26
|
+
appendToErrorMessage(error, formatFailureSnapshot(snapshot, typeof error.message === "string" ? error.message : ""));
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
afterEach(capture);
|
|
30
|
+
const global = globalThis;
|
|
31
|
+
const original = global.afterEach;
|
|
32
|
+
if (typeof original === "function") global.afterEach = function afterEach(fn, timeout) {
|
|
33
|
+
if (typeof fn !== "function" || fn.length !== 0) return original.call(this, fn, timeout);
|
|
34
|
+
const hook = fn;
|
|
35
|
+
return original.call(this, function() {
|
|
36
|
+
capture();
|
|
37
|
+
return hook.apply(this, arguments);
|
|
38
|
+
}, timeout);
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export { };
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { enableCompileCache } from "node:module";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { constants, createContext } from "node:vm";
|
|
4
|
+
|
|
5
|
+
// src/index.ts
|
|
6
|
+
let dom = null;
|
|
7
|
+
let internal = null;
|
|
8
|
+
/**
|
|
9
|
+
* Imports the DOM on the worker's first setup. Every Vitest worker pays this import
|
|
10
|
+
* (jsdom-startup README: isolated forks start a fresh worker per file), so with `compileCache`
|
|
11
|
+
* Node's on-disk compile cache is enabled first: it keeps V8 code (and stripped TypeScript) for
|
|
12
|
+
* the bundles across workers. Once on, it stays on for every module the worker loads after it,
|
|
13
|
+
* which only pays off for large files: deserializing hundreds of tiny ones (aria-query's roles,
|
|
14
|
+
* stock user-event) is slower than compiling them (comparison/: +6% wall time over 100 files with
|
|
15
|
+
* stock Testing Library, -11% with @ctrl/dom's).
|
|
16
|
+
*/
|
|
17
|
+
async function load(options) {
|
|
18
|
+
if (dom !== null) return;
|
|
19
|
+
if (compileCache(options)) enableCompileCache?.();
|
|
20
|
+
[dom, internal] = await Promise.all([import("../dom/index.js"), import("../dom/internal.js")]);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The global key under which the environment publishes the DOM modules it loaded (the same one
|
|
24
|
+
* @ctrl/dom-jest-environment uses). In VM pools Vitest evaluates a test file's modules inside the vm
|
|
25
|
+
* context, so an import of @ctrl/dom from test code (or from our Testing Library bundles) would
|
|
26
|
+
* otherwise evaluate a second DOM: its classes fail `instanceof` against the installed globals and
|
|
27
|
+
* every file pays for the evaluation. Published `@ctrl/dom` and `@ctrl/dom/internal` resolve to
|
|
28
|
+
* bridges that return these objects (scripts/release.ts, writeBridges).
|
|
29
|
+
*/
|
|
30
|
+
const DOM_MODULES = Symbol.for("ctrl-dom.dom.modules");
|
|
31
|
+
function publishModules(global) {
|
|
32
|
+
Object.defineProperty(global, DOM_MODULES, {
|
|
33
|
+
value: {
|
|
34
|
+
dom,
|
|
35
|
+
internal
|
|
36
|
+
},
|
|
37
|
+
configurable: true,
|
|
38
|
+
enumerable: false,
|
|
39
|
+
writable: false
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Exceptions nobody handled (listener exceptions, reportError(), React's uncaught errors) go to
|
|
44
|
+
* the worker as `uncaughtException`, which Vitest reports as an unhandled error that fails the
|
|
45
|
+
* run — what Vitest's jsdom environment does with its window "error" listener.
|
|
46
|
+
* https://html.spec.whatwg.org/#report-an-exception
|
|
47
|
+
*/
|
|
48
|
+
function reportToHost(error) {
|
|
49
|
+
process.emit("uncaughtException", error, "uncaughtException");
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* jsdom's "Not implemented" diagnostics (navigation, window.alert, form submission, ...; only
|
|
53
|
+
* under the jsdom profiles, @ctrl/dom window/not-implemented.ts), forwarded as under Vitest's
|
|
54
|
+
* jsdom environment, whose JSDOM gets jsdom's default virtual console: `console.error(e.stack,
|
|
55
|
+
* e.detail)` on the test's console.
|
|
56
|
+
*/
|
|
57
|
+
function forwardNotImplemented(global) {
|
|
58
|
+
return (error) => (global.console ?? console).error(error.stack, error.detail);
|
|
59
|
+
}
|
|
60
|
+
/** Same default URL as Vitest's jsdom and happy-dom environments. */
|
|
61
|
+
const DEFAULT_URL = "http://localhost:3000/";
|
|
62
|
+
/** The environment by path, as the ctrlDom() plugin configures it. */
|
|
63
|
+
const SELF = fileURLToPath(import.meta.url);
|
|
64
|
+
/** This environment's options out of Vitest's `environmentOptions` (see the header). */
|
|
65
|
+
function ownOptions(options) {
|
|
66
|
+
return options?.["ctrl-dom"] ?? options?.ctrlDom ?? options?.[SELF] ?? {};
|
|
67
|
+
}
|
|
68
|
+
function windowOptions(options) {
|
|
69
|
+
const { timeSkip: _timeSkip, compileCache: _compileCache, ...rest } = ownOptions(options);
|
|
70
|
+
return {
|
|
71
|
+
...rest,
|
|
72
|
+
compat: rest.compat ?? "jsdom-30",
|
|
73
|
+
url: rest.url ?? DEFAULT_URL
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function timeSkip(options) {
|
|
77
|
+
const env = process.env.CTRL_DOM_TIME_SKIP;
|
|
78
|
+
if (env === "1") return true;
|
|
79
|
+
if (env === "0") return false;
|
|
80
|
+
return ownOptions(options).timeSkip !== false;
|
|
81
|
+
}
|
|
82
|
+
function compileCache(options) {
|
|
83
|
+
const env = process.env.CTRL_DOM_COMPILE_CACHE;
|
|
84
|
+
if (env === "1") return true;
|
|
85
|
+
if (env === "0") return false;
|
|
86
|
+
return ownOptions(options).compileCache === true;
|
|
87
|
+
}
|
|
88
|
+
const VM_HOST_GLOBALS = [
|
|
89
|
+
"setTimeout",
|
|
90
|
+
"clearTimeout",
|
|
91
|
+
"setInterval",
|
|
92
|
+
"clearInterval",
|
|
93
|
+
"queueMicrotask",
|
|
94
|
+
"structuredClone",
|
|
95
|
+
"atob",
|
|
96
|
+
"btoa",
|
|
97
|
+
"fetch",
|
|
98
|
+
"crypto",
|
|
99
|
+
"performance",
|
|
100
|
+
"URL",
|
|
101
|
+
"URLSearchParams",
|
|
102
|
+
"AbortController",
|
|
103
|
+
"AbortSignal",
|
|
104
|
+
"Blob",
|
|
105
|
+
"File",
|
|
106
|
+
"TextEncoder",
|
|
107
|
+
"TextDecoder",
|
|
108
|
+
"ReadableStream",
|
|
109
|
+
"WritableStream",
|
|
110
|
+
"TransformStream",
|
|
111
|
+
"Headers",
|
|
112
|
+
"Request",
|
|
113
|
+
"Response",
|
|
114
|
+
"FormData",
|
|
115
|
+
"BroadcastChannel",
|
|
116
|
+
"MessageChannel",
|
|
117
|
+
"MessagePort",
|
|
118
|
+
"WebSocket",
|
|
119
|
+
"DOMException",
|
|
120
|
+
"Buffer"
|
|
121
|
+
];
|
|
122
|
+
const environment = {
|
|
123
|
+
name: "ctrl-dom",
|
|
124
|
+
viteEnvironment: "client",
|
|
125
|
+
prewarmModules: false,
|
|
126
|
+
async setup(global, options) {
|
|
127
|
+
await load(options);
|
|
128
|
+
const { createWindow, installGlobals } = dom;
|
|
129
|
+
const { setUncaughtExceptionHandler, setNotImplementedHandler, installClock, VirtualClock, subscribeTestFailures } = internal;
|
|
130
|
+
const window = createWindow(windowOptions(options));
|
|
131
|
+
const uninstall = installGlobals(window, global);
|
|
132
|
+
publishModules(global);
|
|
133
|
+
const clock = installClock(new VirtualClock({ skip: timeSkip(options) }), global);
|
|
134
|
+
setUncaughtExceptionHandler(reportToHost);
|
|
135
|
+
setNotImplementedHandler(forwardNotImplemented(global));
|
|
136
|
+
const unsubscribeFailures = subscribeTestFailures(() => window.document);
|
|
137
|
+
return { teardown() {
|
|
138
|
+
unsubscribeFailures();
|
|
139
|
+
setUncaughtExceptionHandler(null);
|
|
140
|
+
setNotImplementedHandler(null);
|
|
141
|
+
clock.uninstall();
|
|
142
|
+
window.close();
|
|
143
|
+
uninstall();
|
|
144
|
+
delete global[DOM_MODULES];
|
|
145
|
+
} };
|
|
146
|
+
},
|
|
147
|
+
async setupVM(options) {
|
|
148
|
+
await load(options);
|
|
149
|
+
const { createWindow, installGlobals } = dom;
|
|
150
|
+
const { setUncaughtExceptionHandler, setNotImplementedHandler, captureInterfaceBaseline, guardInterfaceDefinitions, restoreInterfaces, installClock, VirtualClock, subscribeTestFailures } = internal;
|
|
151
|
+
const window = createWindow(windowOptions(options));
|
|
152
|
+
const context = createContext(constants.DONT_CONTEXTIFY);
|
|
153
|
+
const host = globalThis;
|
|
154
|
+
for (const name of VM_HOST_GLOBALS) if (host[name] !== void 0) Object.defineProperty(context, name, {
|
|
155
|
+
value: host[name],
|
|
156
|
+
writable: true,
|
|
157
|
+
enumerable: false,
|
|
158
|
+
configurable: true
|
|
159
|
+
});
|
|
160
|
+
captureInterfaceBaseline();
|
|
161
|
+
const uninstall = installGlobals(window, context);
|
|
162
|
+
publishModules(context);
|
|
163
|
+
const clock = installClock(new VirtualClock({ skip: timeSkip(options) }), context);
|
|
164
|
+
guardInterfaceDefinitions(context);
|
|
165
|
+
setUncaughtExceptionHandler(reportToHost);
|
|
166
|
+
setNotImplementedHandler(forwardNotImplemented(context));
|
|
167
|
+
const unsubscribeFailures = subscribeTestFailures(() => window.document);
|
|
168
|
+
return {
|
|
169
|
+
getVmContext() {
|
|
170
|
+
return context;
|
|
171
|
+
},
|
|
172
|
+
teardown() {
|
|
173
|
+
unsubscribeFailures();
|
|
174
|
+
setUncaughtExceptionHandler(null);
|
|
175
|
+
setNotImplementedHandler(null);
|
|
176
|
+
clock.clock.dispose();
|
|
177
|
+
window.close();
|
|
178
|
+
uninstall();
|
|
179
|
+
restoreInterfaces();
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
export { environment as default };
|