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.
- package/dist/react/init.d.ts +1 -2
- package/dist/react/init.js +27 -61
- package/package.json +1 -1
package/dist/react/init.d.ts
CHANGED
|
@@ -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
|
|
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
|
*
|
package/dist/react/init.js
CHANGED
|
@@ -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
|
|
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
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
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
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
//
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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 });
|