@a11y-hud/svelte 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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Arthur Vasconcelos
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,75 @@
1
+ # @a11y-hud/svelte
2
+
3
+ Svelte 5 adapter for [a11y-hud](https://github.com/arthurvasconcelos/a11y-hud) — run axe-core accessibility audits in your Svelte app with no DevTools required.
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ pnpm add @a11y-hud/svelte svelte
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### Hook (recommended)
14
+
15
+ Use `useA11yHud` inside any Svelte 5 component. Pass a getter function so that reactive state is read inside the `$effect` that tracks it:
16
+
17
+ ```svelte
18
+ <script lang="ts">
19
+ import { useA11yHud } from "@a11y-hud/svelte";
20
+
21
+ let scopeSection = $state<HTMLDivElement | null>(null);
22
+
23
+ useA11yHud(() => ({
24
+ theme: "dark",
25
+ scope: scopeSection,
26
+ autoScan: true,
27
+ debounce: 300,
28
+ }));
29
+ </script>
30
+
31
+ <div bind:this={scopeSection}>
32
+ <!-- your app content -->
33
+ </div>
34
+ ```
35
+
36
+ The `scope` option accepts `Element | null` (from `bind:this`), consistent with the Vue adapter.
37
+
38
+ ### Component
39
+
40
+ Use the `<A11yHud>` component when you prefer a declarative approach:
41
+
42
+ ```svelte
43
+ <script lang="ts">
44
+ import { A11yHud } from "@a11y-hud/svelte";
45
+
46
+ let scopeSection = $state<HTMLDivElement | null>(null);
47
+ </script>
48
+
49
+ <A11yHud scope={scopeSection} theme="dark" />
50
+
51
+ <div bind:this={scopeSection}>
52
+ <!-- your app content -->
53
+ </div>
54
+ ```
55
+
56
+ ## API
57
+
58
+ ### `useA11yHud(getOptions?: () => UseA11yHudOptions): UseA11yHudReturn`
59
+
60
+ | Option | Type | Description |
61
+ |---|---|---|
62
+ | `theme` | `Theme` | `"light"`, `"dark"`, or `"high-contrast"` |
63
+ | `scope` | `Element \| null` | Restrict scan to a subtree |
64
+ | `autoScan` | `boolean` | Enable/disable automatic scanning (default: `true`) |
65
+ | `debounce` | `number` | Debounce delay in milliseconds |
66
+
67
+ Returns `{ runScan(): Promise<AxeResults>, setTheme(theme: Theme): void }`.
68
+
69
+ ### `<A11yHud>` component
70
+
71
+ Accepts the same options as `UseA11yHudOptions` as props. Renders nothing into the Svelte tree — the `<a11y-hud>` Custom Element is mounted directly on `document.body`.
72
+
73
+ ## License
74
+
75
+ MIT
@@ -0,0 +1,4 @@
1
+ export { default as A11yHud } from './A11yHud.svelte';
2
+ export { useA11yHud } from './hook.svelte.js';
3
+ export type { A11yHudProps, UseA11yHudOptions, UseA11yHudReturn } from './types.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,YAAY,EAAE,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,65 @@
1
+ import "svelte/internal/disclose-version";
2
+ import * as e from "svelte/internal/client";
3
+ import { mount as t } from "a11y-hud";
4
+ import { onDestroy as n, onMount as r } from "svelte";
5
+ //#region src/hook.svelte.ts
6
+ function i(i = () => ({})) {
7
+ let a = e.state(!1), o = null, s = null;
8
+ r(() => {
9
+ let { theme: n, autoScan: r, debounce: c } = i();
10
+ o = t({
11
+ ...n !== void 0 && { theme: n },
12
+ ...r !== void 0 && { autoScan: r },
13
+ ...c !== void 0 && { debounce: c }
14
+ }), s = document.querySelector("a11y-hud"), e.set(a, !0);
15
+ }), n(() => {
16
+ o?.unmount(), o = null, s = null;
17
+ }), e.user_effect(() => {
18
+ if (!e.get(a)) return;
19
+ let { scope: t } = i(), n = s;
20
+ n && (n.scopeElement = t ?? void 0, o?.runScan());
21
+ }), e.user_effect(() => {
22
+ if (e.get(a)) {
23
+ let { theme: e } = i();
24
+ e !== void 0 && o?.setTheme(e);
25
+ }
26
+ }), e.user_effect(() => {
27
+ if (e.get(a)) {
28
+ let e = s;
29
+ if (e) {
30
+ let { autoScan: t } = i();
31
+ t === !1 ? e.removeAttribute("auto-scan") : e.setAttribute("auto-scan", "");
32
+ }
33
+ }
34
+ }), e.user_effect(() => {
35
+ if (e.get(a)) {
36
+ let e = s;
37
+ if (e) {
38
+ let { debounce: t } = i();
39
+ t !== void 0 && e.setAttribute("debounce", String(t));
40
+ }
41
+ }
42
+ });
43
+ function c() {
44
+ return o?.runScan() ?? Promise.resolve(null);
45
+ }
46
+ function l(e) {
47
+ o?.setTheme(e);
48
+ }
49
+ return {
50
+ runScan: c,
51
+ setTheme: l
52
+ };
53
+ }
54
+ //#endregion
55
+ //#region src/A11yHud.svelte
56
+ function a(t, n) {
57
+ e.push(n, !0), i(() => ({
58
+ ...n.theme !== void 0 && { theme: n.theme },
59
+ ...n.scope !== void 0 && { scope: n.scope },
60
+ ...n.autoScan !== void 0 && { autoScan: n.autoScan },
61
+ ...n.debounce !== void 0 && { debounce: n.debounce }
62
+ })), e.pop();
63
+ }
64
+ //#endregion
65
+ export { a as A11yHud, i as useA11yHud };
@@ -0,0 +1,14 @@
1
+ import { AxeResults, Theme } from 'a11y-hud';
2
+ export interface UseA11yHudOptions {
3
+ theme?: Theme;
4
+ scope?: Element | null;
5
+ autoScan?: boolean;
6
+ debounce?: number;
7
+ }
8
+ export type A11yHudProps = UseA11yHudOptions;
9
+ export interface UseA11yHudReturn {
10
+ runScan(): Promise<AxeResults>;
11
+ setTheme(theme: Theme): void;
12
+ }
13
+ export declare function useA11yHud(getOptions?: () => UseA11yHudOptions): UseA11yHudReturn;
14
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAElD,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,YAAY,GAAG,iBAAiB,CAAC;AAE7C,MAAM,WAAW,gBAAgB;IAC/B,OAAO,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC;IAC/B,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CAC9B;AAED,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,UAAU,CAAC,EAAE,MAAM,iBAAiB,GAAG,gBAAgB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,72 @@
1
+ {
2
+ "name": "@a11y-hud/svelte",
3
+ "version": "0.1.0",
4
+ "description": "Svelte adapter for a11y-hud — run axe-core accessibility audits in your Svelte app with no DevTools required.",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./dist/index.d.ts",
9
+ "svelte": "./dist/index.js",
10
+ "import": "./dist/index.js"
11
+ }
12
+ },
13
+ "module": "./dist/index.js",
14
+ "types": "./dist/index.d.ts",
15
+ "files": [
16
+ "dist",
17
+ "LICENSE",
18
+ "README.md"
19
+ ],
20
+ "dependencies": {
21
+ "a11y-hud": "0.1.4"
22
+ },
23
+ "peerDependencies": {
24
+ "svelte": ">=5"
25
+ },
26
+ "devDependencies": {
27
+ "@playwright/test": "^1.49.1",
28
+ "@sveltejs/vite-plugin-svelte": "^7.0.0",
29
+ "@testing-library/svelte": "^5.3.1",
30
+ "@vitest/coverage-v8": "^4.1.5",
31
+ "jsdom": "^29.1.1",
32
+ "svelte": "^5.55.5",
33
+ "svelte-check": "^4.4.7",
34
+ "vite": "^8.0.10",
35
+ "vite-plugin-dts": "^5.0.0",
36
+ "vitest": "^4.1.5"
37
+ },
38
+ "engines": {
39
+ "node": ">=22"
40
+ },
41
+ "license": "MIT",
42
+ "homepage": "https://github.com/arthurvasconcelos/a11y-hud#readme",
43
+ "repository": {
44
+ "type": "git",
45
+ "url": "git+https://github.com/arthurvasconcelos/a11y-hud.git",
46
+ "directory": "packages/svelte"
47
+ },
48
+ "bugs": {
49
+ "url": "https://github.com/arthurvasconcelos/a11y-hud/issues"
50
+ },
51
+ "keywords": [
52
+ "accessibility",
53
+ "a11y",
54
+ "axe",
55
+ "axe-core",
56
+ "wcag",
57
+ "svelte",
58
+ "svelte5",
59
+ "dev-tools",
60
+ "overlay",
61
+ "hud"
62
+ ],
63
+ "scripts": {
64
+ "build": "vite build",
65
+ "dev": "vite build --watch",
66
+ "test": "vitest run",
67
+ "test:watch": "vitest",
68
+ "test:coverage": "vitest run --coverage",
69
+ "test:e2e": "playwright test",
70
+ "typecheck": "svelte-check --tsconfig ./tsconfig.json"
71
+ }
72
+ }