wcag-scanner 1.2.62 → 1.2.63

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.
@@ -2,10 +2,9 @@
2
2
  * initWcagOverlay — auto-injects the WCAG Dev Inspector overlay.
3
3
  *
4
4
  * Call this from any file (js / ts / jsx / tsx) in your app entry point.
5
- * It is a no-op outside of development (process.env.NODE_ENV !== 'development').
5
+ * It is a no-op in production builds.
6
6
  *
7
7
  * @example
8
- * // main.ts / index.js / App.tsx — one line is all you need:
9
8
  * import { initWcagOverlay } from 'wcag-scanner/react';
10
9
  * initWcagOverlay();
11
10
  *
@@ -3,88 +3,54 @@
3
3
  * initWcagOverlay — auto-injects the WCAG Dev Inspector overlay.
4
4
  *
5
5
  * Call this from any file (js / ts / jsx / tsx) in your app entry point.
6
- * It is a no-op outside of development (process.env.NODE_ENV !== 'development').
6
+ * It is a no-op in production builds.
7
7
  *
8
8
  * @example
9
- * // main.ts / index.js / App.tsx — one line is all you need:
10
9
  * import { initWcagOverlay } from 'wcag-scanner/react';
11
10
  * initWcagOverlay();
12
11
  *
13
12
  * // With options:
14
13
  * initWcagOverlay({ level: 'AAA', position: 'bottom-left', debounce: 500 });
15
14
  */
16
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
17
- if (k2 === undefined) k2 = k;
18
- var desc = Object.getOwnPropertyDescriptor(m, k);
19
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
20
- desc = { enumerable: true, get: function() { return m[k]; } };
21
- }
22
- Object.defineProperty(o, k2, desc);
23
- }) : (function(o, m, k, k2) {
24
- if (k2 === undefined) k2 = k;
25
- o[k2] = m[k];
26
- }));
27
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
28
- Object.defineProperty(o, "default", { enumerable: true, value: v });
29
- }) : function(o, v) {
30
- o["default"] = v;
31
- });
32
- var __importStar = (this && this.__importStar) || (function () {
33
- var ownKeys = function(o) {
34
- ownKeys = Object.getOwnPropertyNames || function (o) {
35
- var ar = [];
36
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
37
- return ar;
38
- };
39
- return ownKeys(o);
40
- };
41
- return function (mod) {
42
- if (mod && mod.__esModule) return mod;
43
- var result = {};
44
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
45
- __setModuleDefault(result, mod);
46
- return result;
47
- };
48
- })();
15
+ var __importDefault = (this && this.__importDefault) || function (mod) {
16
+ return (mod && mod.__esModule) ? mod : { "default": mod };
17
+ };
49
18
  Object.defineProperty(exports, "__esModule", { value: true });
50
19
  exports.initWcagOverlay = initWcagOverlay;
20
+ const react_1 = __importDefault(require("react"));
21
+ const WcagDevOverlay_1 = require("./WcagDevOverlay");
51
22
  function initWcagOverlay(options = {}) {
52
- // Only run in browser + development
53
- if (typeof window === 'undefined')
23
+ if (typeof window === 'undefined' || typeof document === 'undefined')
54
24
  return;
55
25
  if (typeof process !== 'undefined' && process.env.NODE_ENV === 'production')
56
26
  return;
57
27
  const mount = () => {
58
- // Don't mount twice
59
28
  if (document.querySelector('[data-wcag-overlay-root]'))
60
29
  return;
61
30
  const container = document.createElement('div');
62
31
  container.setAttribute('data-wcag-overlay-root', 'true');
63
32
  document.body.appendChild(container);
64
- // Dynamically import React + ReactDOM to avoid bundling them twice
65
- Promise.all([
66
- Promise.resolve().then(() => __importStar(require('react'))),
67
- Promise.resolve().then(() => __importStar(require('react-dom'))),
68
- Promise.resolve().then(() => __importStar(require('./WcagDevOverlay'))),
69
- ]).then(([React, ReactDOM, { WcagDevOverlay }]) => {
70
- var _a, _b;
71
- const ReactAny = React;
72
- const r = (_a = ReactAny.default) !== null && _a !== void 0 ? _a : ReactAny;
73
- const el = r.createElement(WcagDevOverlay, options);
74
- // Vite/ESM may wrap the module under .default
75
- const rdAny = ReactDOM;
76
- const rd = (_b = rdAny.default) !== null && _b !== void 0 ? _b : rdAny;
77
- // React 18: createRoot
78
- if (rd.createRoot) {
79
- rd.createRoot(container).render(el);
80
- }
81
- else {
82
- // React 17 fallback
83
- rd.render(el, container);
84
- }
85
- }).catch((err) => {
33
+ const el = react_1.default.createElement(WcagDevOverlay_1.WcagDevOverlay, options);
34
+ // React 18+: use createRoot from react-dom/client
35
+ try {
36
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
37
+ const { createRoot } = require('react-dom/client');
38
+ createRoot(container).render(el);
39
+ return;
40
+ }
41
+ catch (_a) {
42
+ // react-dom/client not available — React 17
43
+ }
44
+ // React 17 fallback
45
+ try {
46
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
47
+ const ReactDOM = require('react-dom');
48
+ ReactDOM.render(el, container);
49
+ }
50
+ catch (err) {
86
51
  console.warn('[wcag-scanner] Failed to mount overlay:', err);
87
- });
52
+ document.body.removeChild(container);
53
+ }
88
54
  };
89
55
  if (document.readyState === 'loading') {
90
56
  document.addEventListener('DOMContentLoaded', mount, { once: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wcag-scanner",
3
- "version": "1.2.62",
3
+ "version": "1.2.63",
4
4
  "description": "Scan HTML for WCAG accessibility violations with AI-powered fix suggestions",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",