@hydrateless/auto 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.
@@ -0,0 +1,3 @@
1
+ declare function auto(container?: Document | HTMLElement): Promise<void>;
2
+
3
+ export { auto };
package/dist/index.js ADDED
@@ -0,0 +1,46 @@
1
+ // src/index.ts
2
+ async function auto(container = document) {
3
+ const has = (sel) => !!container.querySelector(sel);
4
+ const pending = [];
5
+ if (has("[data-hl-accordion]")) {
6
+ pending.push(
7
+ import("@hydrateless/enhancers/accordion").then((m) => m.enhanceAccordion(container))
8
+ );
9
+ }
10
+ if (has("[data-hl-tabs]")) {
11
+ pending.push(import("@hydrateless/enhancers/tabs").then((m) => m.enhanceTabs(container)));
12
+ }
13
+ if (has("details[data-hl-disclosure]")) {
14
+ pending.push(
15
+ import("@hydrateless/enhancers/disclosure").then((m) => m.enhanceDisclosure(container))
16
+ );
17
+ }
18
+ if (has("dialog[data-hl-modal], [data-hl-modal-open]")) {
19
+ pending.push(import("@hydrateless/enhancers/modal").then((m) => m.enhanceModal(container)));
20
+ }
21
+ if (has("[data-hl-toc]")) {
22
+ pending.push(import("@hydrateless/enhancers/toc").then((m) => m.enhanceToc(container)));
23
+ }
24
+ if (has("dialog.hydrateless-drawer[data-hl-drawer], [data-hl-drawer-open]")) {
25
+ pending.push(import("@hydrateless/enhancers/drawer").then((m) => m.enhanceDrawer(container)));
26
+ }
27
+ if (has("[popover], [data-hl-popover], [data-hl-popover-open]")) {
28
+ pending.push(import("@hydrateless/enhancers/popover").then((m) => m.enhancePopover(container)));
29
+ }
30
+ if (has("[data-hl-tooltip]")) {
31
+ pending.push(import("@hydrateless/enhancers/tooltip").then((m) => m.enhanceTooltip(container)));
32
+ }
33
+ await Promise.all(pending);
34
+ }
35
+ if (typeof window !== "undefined") {
36
+ if (document.readyState === "loading") {
37
+ window.addEventListener("DOMContentLoaded", () => {
38
+ void auto();
39
+ });
40
+ } else {
41
+ void auto();
42
+ }
43
+ }
44
+ export {
45
+ auto
46
+ };
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@hydrateless/auto",
3
+ "version": "0.1.0",
4
+ "description": "Drop-in auto-initializer for Hydrateless — detects data-hl-* attributes and lazy-loads enhancers.",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/hydrateless/hydrateless.git",
9
+ "directory": "packages/auto"
10
+ },
11
+ "type": "module",
12
+ "files": [
13
+ "dist"
14
+ ],
15
+ "sideEffects": true,
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/index.d.ts",
19
+ "import": "./dist/index.js"
20
+ }
21
+ },
22
+ "scripts": {
23
+ "build": "tsup src/index.ts --dts --format esm --clean",
24
+ "dev": "npm run build -- --watch",
25
+ "typecheck": "tsc -p tsconfig.json --noEmit",
26
+ "lint": "eslint \"src/**/*.ts\""
27
+ },
28
+ "dependencies": {
29
+ "@hydrateless/enhancers": "^0.1.0"
30
+ },
31
+ "publishConfig": {
32
+ "access": "public"
33
+ }
34
+ }