@develemit/web-hooks 0.0.0-stage → 0.2.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.
Files changed (73) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/LICENSE +21 -0
  3. package/README.md +249 -2
  4. package/dist/auto-grow.cjs +60 -0
  5. package/dist/auto-grow.d.cts +14 -0
  6. package/dist/auto-grow.d.ts +14 -0
  7. package/dist/auto-grow.js +9 -0
  8. package/dist/chunk-3CACI4OQ.js +68 -0
  9. package/dist/chunk-3UGRXQIA.js +39 -0
  10. package/dist/chunk-5CA5RIMH.js +34 -0
  11. package/dist/chunk-5KIH2XLV.js +136 -0
  12. package/dist/chunk-6KCRVSLS.js +80 -0
  13. package/dist/chunk-DNU57XEJ.js +82 -0
  14. package/dist/chunk-IWQDAJEP.js +69 -0
  15. package/dist/chunk-LZKAGDER.js +22 -0
  16. package/dist/chunk-NKLEB5TR.js +98 -0
  17. package/dist/chunk-OZ4PU4E3.js +115 -0
  18. package/dist/chunk-S4YKMGQE.js +23 -0
  19. package/dist/chunk-UPVNSGIK.js +72 -0
  20. package/dist/chunk-UZADAINO.js +61 -0
  21. package/dist/clipboard.cjs +94 -0
  22. package/dist/clipboard.d.cts +17 -0
  23. package/dist/clipboard.d.ts +17 -0
  24. package/dist/clipboard.js +9 -0
  25. package/dist/debounce.cjs +96 -0
  26. package/dist/debounce.d.cts +21 -0
  27. package/dist/debounce.d.ts +21 -0
  28. package/dist/debounce.js +11 -0
  29. package/dist/drawer-swipe.cjs +149 -0
  30. package/dist/drawer-swipe.d.cts +26 -0
  31. package/dist/drawer-swipe.d.ts +26 -0
  32. package/dist/drawer-swipe.js +25 -0
  33. package/dist/escape.cjs +48 -0
  34. package/dist/escape.d.cts +3 -0
  35. package/dist/escape.d.ts +3 -0
  36. package/dist/escape.js +7 -0
  37. package/dist/focus-trap.cjs +110 -0
  38. package/dist/focus-trap.d.cts +17 -0
  39. package/dist/focus-trap.d.ts +17 -0
  40. package/dist/focus-trap.js +13 -0
  41. package/dist/hotkey.cjs +127 -0
  42. package/dist/hotkey.d.cts +31 -0
  43. package/dist/hotkey.d.ts +31 -0
  44. package/dist/hotkey.js +15 -0
  45. package/dist/index.cjs +918 -0
  46. package/dist/index.d.cts +14 -0
  47. package/dist/index.d.ts +14 -0
  48. package/dist/index.js +115 -0
  49. package/dist/media-query.cjs +90 -0
  50. package/dist/media-query.d.cts +12 -0
  51. package/dist/media-query.d.ts +12 -0
  52. package/dist/media-query.js +15 -0
  53. package/dist/outside-press.cjs +66 -0
  54. package/dist/outside-press.d.cts +15 -0
  55. package/dist/outside-press.d.ts +15 -0
  56. package/dist/outside-press.js +11 -0
  57. package/dist/scroll-lock.cjs +107 -0
  58. package/dist/scroll-lock.d.cts +8 -0
  59. package/dist/scroll-lock.d.ts +8 -0
  60. package/dist/scroll-lock.js +11 -0
  61. package/dist/storage-state.cjs +161 -0
  62. package/dist/storage-state.d.cts +14 -0
  63. package/dist/storage-state.d.ts +14 -0
  64. package/dist/storage-state.js +7 -0
  65. package/dist/unsaved-guard.cjs +48 -0
  66. package/dist/unsaved-guard.d.cts +5 -0
  67. package/dist/unsaved-guard.d.ts +5 -0
  68. package/dist/unsaved-guard.js +9 -0
  69. package/dist/visibility-polling.cjs +98 -0
  70. package/dist/visibility-polling.d.cts +14 -0
  71. package/dist/visibility-polling.d.ts +14 -0
  72. package/dist/visibility-polling.js +9 -0
  73. package/package.json +126 -3
@@ -0,0 +1,161 @@
1
+ "use client";
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/storage-state/index.ts
22
+ var storage_state_exports = {};
23
+ __export(storage_state_exports, {
24
+ useStorageState: () => useStorageState
25
+ });
26
+ module.exports = __toCommonJS(storage_state_exports);
27
+
28
+ // src/storage-state/use-storage-state.ts
29
+ var import_react = require("react");
30
+
31
+ // src/storage-state/storage-store.ts
32
+ function getStorage(kind) {
33
+ try {
34
+ if (typeof window === "undefined") return null;
35
+ return kind === "session" ? window.sessionStorage : window.localStorage;
36
+ } catch {
37
+ return null;
38
+ }
39
+ }
40
+ function readRaw(storage, key) {
41
+ try {
42
+ return storage ? storage.getItem(key) : null;
43
+ } catch {
44
+ return null;
45
+ }
46
+ }
47
+ function writeRaw(storage, key, value) {
48
+ try {
49
+ if (!storage) return false;
50
+ storage.setItem(key, value);
51
+ return true;
52
+ } catch {
53
+ return false;
54
+ }
55
+ }
56
+ function removeRaw(storage, key) {
57
+ try {
58
+ if (!storage) return false;
59
+ storage.removeItem(key);
60
+ return true;
61
+ } catch {
62
+ return false;
63
+ }
64
+ }
65
+ function parseOr(raw, parse, fallback) {
66
+ if (raw === null) return fallback;
67
+ try {
68
+ return parse(raw);
69
+ } catch {
70
+ return fallback;
71
+ }
72
+ }
73
+ var slot = (kind, key) => `${kind}\0${key}`;
74
+ var memory = /* @__PURE__ */ new Map();
75
+ var listeners = /* @__PURE__ */ new Map();
76
+ function readCurrent(kind, key) {
77
+ const held = memory.get(slot(kind, key));
78
+ if (held !== void 0) return held;
79
+ return readRaw(getStorage(kind), key);
80
+ }
81
+ function notify(id) {
82
+ for (const listener of [...listeners.get(id) ?? []]) listener();
83
+ }
84
+ function writeCurrent(kind, key, raw) {
85
+ const id = slot(kind, key);
86
+ if (writeRaw(getStorage(kind), key, raw)) memory.delete(id);
87
+ else memory.set(id, raw);
88
+ notify(id);
89
+ }
90
+ function removeCurrent(kind, key) {
91
+ const id = slot(kind, key);
92
+ if (removeRaw(getStorage(kind), key)) memory.delete(id);
93
+ else memory.set(id, null);
94
+ notify(id);
95
+ }
96
+ function onStorageEvent(event) {
97
+ const kinds = [];
98
+ if (!event.storageArea || event.storageArea === getStorage("local")) kinds.push("local");
99
+ if (!event.storageArea || event.storageArea === getStorage("session")) kinds.push("session");
100
+ for (const id of [...listeners.keys()]) {
101
+ const [kind, key] = id.split("\0");
102
+ if (!kinds.includes(kind)) continue;
103
+ if (event.key !== null && event.key !== key) continue;
104
+ memory.delete(id);
105
+ notify(id);
106
+ }
107
+ }
108
+ function subscribeToKey(kind, key, listener) {
109
+ const id = slot(kind, key);
110
+ const wasEmpty = listeners.size === 0;
111
+ let set = listeners.get(id);
112
+ if (!set) listeners.set(id, set = /* @__PURE__ */ new Set());
113
+ set.add(listener);
114
+ if (wasEmpty) window.addEventListener("storage", onStorageEvent);
115
+ return () => {
116
+ const current = listeners.get(id);
117
+ current?.delete(listener);
118
+ if (current?.size === 0) listeners.delete(id);
119
+ if (listeners.size === 0) window.removeEventListener("storage", onStorageEvent);
120
+ };
121
+ }
122
+
123
+ // src/storage-state/use-storage-state.ts
124
+ function useStorageState(key, defaultValue, options = {}) {
125
+ const kind = options.storage ?? "local";
126
+ const serialize = options.serialize ?? JSON.stringify;
127
+ const parse = options.parse ?? JSON.parse;
128
+ const latest = (0, import_react.useRef)({ serialize, parse, defaultValue });
129
+ (0, import_react.useEffect)(() => {
130
+ latest.current = { serialize, parse, defaultValue };
131
+ });
132
+ const cache = (0, import_react.useRef)(null);
133
+ const subscribe = (0, import_react.useCallback)((onChange) => subscribeToKey(kind, key, onChange), [kind, key]);
134
+ const getSnapshot = (0, import_react.useCallback)(() => {
135
+ const raw = readCurrent(kind, key);
136
+ const hit = cache.current;
137
+ if (hit && hit.kind === kind && hit.key === key && hit.raw === raw && hit.parse === parse) return hit.value;
138
+ const value2 = parseOr(raw, parse, defaultValue);
139
+ cache.current = { kind, key, raw, parse, value: value2 };
140
+ return value2;
141
+ }, [kind, key, parse, defaultValue]);
142
+ const getServerSnapshot = (0, import_react.useCallback)(() => defaultValue, [defaultValue]);
143
+ const value = (0, import_react.useSyncExternalStore)(subscribe, getSnapshot, getServerSnapshot);
144
+ const set = (0, import_react.useCallback)(
145
+ (next) => {
146
+ const { serialize: encode, parse: decode, defaultValue: fallback } = latest.current;
147
+ try {
148
+ const resolved = typeof next === "function" ? next(parseOr(readCurrent(kind, key), decode, fallback)) : next;
149
+ writeCurrent(kind, key, encode(resolved));
150
+ } catch {
151
+ }
152
+ },
153
+ [kind, key]
154
+ );
155
+ const remove = (0, import_react.useCallback)(() => removeCurrent(kind, key), [kind, key]);
156
+ return [value, set, remove];
157
+ }
158
+ // Annotate the CommonJS export names for ESM import in node:
159
+ 0 && (module.exports = {
160
+ useStorageState
161
+ });
@@ -0,0 +1,14 @@
1
+ type StorageKind = 'local' | 'session';
2
+
3
+ interface UseStorageStateOptions<T> {
4
+ /** `'local'` (default) or `'session'`. */
5
+ storage?: StorageKind;
6
+ /** Default `JSON.stringify`. */
7
+ serialize?: (value: T) => string;
8
+ /** Default `JSON.parse`. A throw returns `defaultValue`. */
9
+ parse?: (raw: string) => T;
10
+ }
11
+ type StorageStateSetter<T> = (next: T | ((prev: T) => T)) => void;
12
+ declare function useStorageState<T>(key: string, defaultValue: T, options?: UseStorageStateOptions<T>): readonly [T, StorageStateSetter<T>, () => void];
13
+
14
+ export { type StorageKind, type StorageStateSetter, type UseStorageStateOptions, useStorageState };
@@ -0,0 +1,14 @@
1
+ type StorageKind = 'local' | 'session';
2
+
3
+ interface UseStorageStateOptions<T> {
4
+ /** `'local'` (default) or `'session'`. */
5
+ storage?: StorageKind;
6
+ /** Default `JSON.stringify`. */
7
+ serialize?: (value: T) => string;
8
+ /** Default `JSON.parse`. A throw returns `defaultValue`. */
9
+ parse?: (raw: string) => T;
10
+ }
11
+ type StorageStateSetter<T> = (next: T | ((prev: T) => T)) => void;
12
+ declare function useStorageState<T>(key: string, defaultValue: T, options?: UseStorageStateOptions<T>): readonly [T, StorageStateSetter<T>, () => void];
13
+
14
+ export { type StorageKind, type StorageStateSetter, type UseStorageStateOptions, useStorageState };
@@ -0,0 +1,7 @@
1
+ "use client";
2
+ import {
3
+ useStorageState
4
+ } from "./chunk-5KIH2XLV.js";
5
+ export {
6
+ useStorageState
7
+ };
@@ -0,0 +1,48 @@
1
+ "use client";
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/unsaved-guard/index.ts
22
+ var unsaved_guard_exports = {};
23
+ __export(unsaved_guard_exports, {
24
+ handleBeforeUnload: () => handleBeforeUnload,
25
+ useUnsavedChangesGuard: () => useUnsavedChangesGuard
26
+ });
27
+ module.exports = __toCommonJS(unsaved_guard_exports);
28
+
29
+ // src/unsaved-guard/handle-before-unload.ts
30
+ function handleBeforeUnload(event) {
31
+ event.preventDefault();
32
+ event.returnValue = "";
33
+ }
34
+
35
+ // src/unsaved-guard/use-unsaved-changes-guard.ts
36
+ var import_react = require("react");
37
+ function useUnsavedChangesGuard(dirty) {
38
+ (0, import_react.useEffect)(() => {
39
+ if (!dirty) return;
40
+ window.addEventListener("beforeunload", handleBeforeUnload);
41
+ return () => window.removeEventListener("beforeunload", handleBeforeUnload);
42
+ }, [dirty]);
43
+ }
44
+ // Annotate the CommonJS export names for ESM import in node:
45
+ 0 && (module.exports = {
46
+ handleBeforeUnload,
47
+ useUnsavedChangesGuard
48
+ });
@@ -0,0 +1,5 @@
1
+ declare function handleBeforeUnload(event: BeforeUnloadEvent): void;
2
+
3
+ declare function useUnsavedChangesGuard(dirty: boolean): void;
4
+
5
+ export { handleBeforeUnload, useUnsavedChangesGuard };
@@ -0,0 +1,5 @@
1
+ declare function handleBeforeUnload(event: BeforeUnloadEvent): void;
2
+
3
+ declare function useUnsavedChangesGuard(dirty: boolean): void;
4
+
5
+ export { handleBeforeUnload, useUnsavedChangesGuard };
@@ -0,0 +1,9 @@
1
+ "use client";
2
+ import {
3
+ handleBeforeUnload,
4
+ useUnsavedChangesGuard
5
+ } from "./chunk-LZKAGDER.js";
6
+ export {
7
+ handleBeforeUnload,
8
+ useUnsavedChangesGuard
9
+ };
@@ -0,0 +1,98 @@
1
+ "use client";
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/visibility-polling/index.ts
22
+ var visibility_polling_exports = {};
23
+ __export(visibility_polling_exports, {
24
+ nextDelay: () => nextDelay,
25
+ useVisibilityPolling: () => useVisibilityPolling
26
+ });
27
+ module.exports = __toCommonJS(visibility_polling_exports);
28
+
29
+ // src/visibility-polling/schedule.ts
30
+ function nextDelay(intervalMs, jitter, random) {
31
+ const fraction = Math.min(1, Math.max(0, jitter));
32
+ return intervalMs + random() * fraction * intervalMs;
33
+ }
34
+
35
+ // src/visibility-polling/use-visibility-polling.ts
36
+ var import_react = require("react");
37
+ var isHidden = () => document.visibilityState === "hidden";
38
+ function useVisibilityPolling(fn, intervalMs, { enabled = true, immediate = true, jitter = 0, runOnVisible = true } = {}) {
39
+ const fnRef = (0, import_react.useRef)(fn);
40
+ const optionsRef = (0, import_react.useRef)({ immediate, jitter, runOnVisible });
41
+ (0, import_react.useEffect)(() => {
42
+ fnRef.current = fn;
43
+ optionsRef.current = { immediate, jitter, runOnVisible };
44
+ });
45
+ const runningRef = (0, import_react.useRef)(false);
46
+ const scheduleRef = (0, import_react.useRef)(null);
47
+ (0, import_react.useEffect)(() => {
48
+ if (!enabled) return;
49
+ let active = true;
50
+ let timer = null;
51
+ function clearTimer() {
52
+ if (timer !== null) clearTimeout(timer);
53
+ timer = null;
54
+ }
55
+ function schedule() {
56
+ clearTimer();
57
+ if (!active || isHidden()) return;
58
+ timer = setTimeout(run, nextDelay(intervalMs, optionsRef.current.jitter, Math.random));
59
+ }
60
+ async function run() {
61
+ timer = null;
62
+ if (!active || runningRef.current || isHidden()) return;
63
+ runningRef.current = true;
64
+ try {
65
+ await fnRef.current();
66
+ } catch {
67
+ } finally {
68
+ runningRef.current = false;
69
+ }
70
+ scheduleRef.current?.();
71
+ }
72
+ function onVisibilityChange() {
73
+ if (isHidden()) {
74
+ clearTimer();
75
+ } else if (optionsRef.current.runOnVisible) {
76
+ clearTimer();
77
+ void run();
78
+ } else if (!runningRef.current) {
79
+ schedule();
80
+ }
81
+ }
82
+ scheduleRef.current = schedule;
83
+ if (optionsRef.current.immediate && !isHidden()) void run();
84
+ else schedule();
85
+ document.addEventListener("visibilitychange", onVisibilityChange);
86
+ return () => {
87
+ active = false;
88
+ scheduleRef.current = null;
89
+ clearTimer();
90
+ document.removeEventListener("visibilitychange", onVisibilityChange);
91
+ };
92
+ }, [enabled, intervalMs]);
93
+ }
94
+ // Annotate the CommonJS export names for ESM import in node:
95
+ 0 && (module.exports = {
96
+ nextDelay,
97
+ useVisibilityPolling
98
+ });
@@ -0,0 +1,14 @@
1
+ declare function nextDelay(intervalMs: number, jitter: number, random: () => number): number;
2
+
3
+ interface UseVisibilityPollingOptions {
4
+ enabled?: boolean;
5
+ /** Run once on mount (when visible) before the first interval. */
6
+ immediate?: boolean;
7
+ /** 0–1 fraction of the interval added at random to each delay. */
8
+ jitter?: number;
9
+ /** Run once as soon as the page becomes visible again. */
10
+ runOnVisible?: boolean;
11
+ }
12
+ declare function useVisibilityPolling(fn: () => unknown, intervalMs: number, { enabled, immediate, jitter, runOnVisible }?: UseVisibilityPollingOptions): void;
13
+
14
+ export { type UseVisibilityPollingOptions, nextDelay, useVisibilityPolling };
@@ -0,0 +1,14 @@
1
+ declare function nextDelay(intervalMs: number, jitter: number, random: () => number): number;
2
+
3
+ interface UseVisibilityPollingOptions {
4
+ enabled?: boolean;
5
+ /** Run once on mount (when visible) before the first interval. */
6
+ immediate?: boolean;
7
+ /** 0–1 fraction of the interval added at random to each delay. */
8
+ jitter?: number;
9
+ /** Run once as soon as the page becomes visible again. */
10
+ runOnVisible?: boolean;
11
+ }
12
+ declare function useVisibilityPolling(fn: () => unknown, intervalMs: number, { enabled, immediate, jitter, runOnVisible }?: UseVisibilityPollingOptions): void;
13
+
14
+ export { type UseVisibilityPollingOptions, nextDelay, useVisibilityPolling };
@@ -0,0 +1,9 @@
1
+ "use client";
2
+ import {
3
+ nextDelay,
4
+ useVisibilityPolling
5
+ } from "./chunk-UPVNSGIK.js";
6
+ export {
7
+ nextDelay,
8
+ useVisibilityPolling
9
+ };
package/package.json CHANGED
@@ -1,6 +1,129 @@
1
1
  {
2
2
  "name": "@develemit/web-hooks",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.2.0",
4
+ "description": "Shared React behavior hooks for develemit web apps: drawer swipe, focus trap, escape key and clipboard.",
5
+ "license": "MIT",
6
+ "author": "Emit Dutcher",
7
+ "type": "module",
8
+ "sideEffects": false,
9
+ "engines": {
10
+ "node": ">=20"
11
+ },
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.js",
16
+ "require": "./dist/index.cjs"
17
+ },
18
+ "./drawer-swipe": {
19
+ "types": "./dist/drawer-swipe.d.ts",
20
+ "import": "./dist/drawer-swipe.js",
21
+ "require": "./dist/drawer-swipe.cjs"
22
+ },
23
+ "./focus-trap": {
24
+ "types": "./dist/focus-trap.d.ts",
25
+ "import": "./dist/focus-trap.js",
26
+ "require": "./dist/focus-trap.cjs"
27
+ },
28
+ "./escape": {
29
+ "types": "./dist/escape.d.ts",
30
+ "import": "./dist/escape.js",
31
+ "require": "./dist/escape.cjs"
32
+ },
33
+ "./clipboard": {
34
+ "types": "./dist/clipboard.d.ts",
35
+ "import": "./dist/clipboard.js",
36
+ "require": "./dist/clipboard.cjs"
37
+ },
38
+ "./scroll-lock": {
39
+ "types": "./dist/scroll-lock.d.ts",
40
+ "import": "./dist/scroll-lock.js",
41
+ "require": "./dist/scroll-lock.cjs"
42
+ },
43
+ "./media-query": {
44
+ "types": "./dist/media-query.d.ts",
45
+ "import": "./dist/media-query.js",
46
+ "require": "./dist/media-query.cjs"
47
+ },
48
+ "./outside-press": {
49
+ "types": "./dist/outside-press.d.ts",
50
+ "import": "./dist/outside-press.js",
51
+ "require": "./dist/outside-press.cjs"
52
+ },
53
+ "./visibility-polling": {
54
+ "types": "./dist/visibility-polling.d.ts",
55
+ "import": "./dist/visibility-polling.js",
56
+ "require": "./dist/visibility-polling.cjs"
57
+ },
58
+ "./debounce": {
59
+ "types": "./dist/debounce.d.ts",
60
+ "import": "./dist/debounce.js",
61
+ "require": "./dist/debounce.cjs"
62
+ },
63
+ "./storage-state": {
64
+ "types": "./dist/storage-state.d.ts",
65
+ "import": "./dist/storage-state.js",
66
+ "require": "./dist/storage-state.cjs"
67
+ },
68
+ "./unsaved-guard": {
69
+ "types": "./dist/unsaved-guard.d.ts",
70
+ "import": "./dist/unsaved-guard.js",
71
+ "require": "./dist/unsaved-guard.cjs"
72
+ },
73
+ "./hotkey": {
74
+ "types": "./dist/hotkey.d.ts",
75
+ "import": "./dist/hotkey.js",
76
+ "require": "./dist/hotkey.cjs"
77
+ },
78
+ "./auto-grow": {
79
+ "types": "./dist/auto-grow.d.ts",
80
+ "import": "./dist/auto-grow.js",
81
+ "require": "./dist/auto-grow.cjs"
82
+ }
83
+ },
84
+ "main": "./dist/index.cjs",
85
+ "module": "./dist/index.js",
86
+ "types": "./dist/index.d.ts",
87
+ "files": [
88
+ "dist",
89
+ "LICENSE",
90
+ "CHANGELOG.md"
91
+ ],
92
+ "publishConfig": {
93
+ "access": "public"
94
+ },
95
+ "peerDependencies": {
96
+ "react": "^18.0.0 || ^19.0.0"
97
+ },
98
+ "devDependencies": {
99
+ "@eslint/js": "^9.0.0",
100
+ "@testing-library/react": "^16.0.0",
101
+ "@types/react": "^19.0.0",
102
+ "@types/react-18": "npm:@types/react@^18.3.31",
103
+ "@types/react-dom": "^19.0.0",
104
+ "@vitest/browser": "3.2.7",
105
+ "eslint": "^9.0.0",
106
+ "jsdom": "^26.0.0",
107
+ "playwright": "1.64.0",
108
+ "react": "^19.0.0",
109
+ "react-18": "npm:react@^18.3.1",
110
+ "react-dom": "^19.0.0",
111
+ "react-dom-18": "npm:react-dom@^18.3.1",
112
+ "testing-library-react-18": "npm:@testing-library/react@16.2.0",
113
+ "tsup": "^8.5.1",
114
+ "typescript": "^5.9.0",
115
+ "typescript-eslint": "^8.0.0",
116
+ "vitest": "^3.0.0"
117
+ },
118
+ "scripts": {
119
+ "typecheck": "tsc --noEmit",
120
+ "lint": "eslint .",
121
+ "test": "vitest run",
122
+ "build": "rm -rf dist && tsup",
123
+ "check": "pnpm typecheck && pnpm lint && pnpm test && pnpm build",
124
+ "release": "pnpm check && pnpm publish --access public",
125
+ "release:dry": "pnpm publish --access public --dry-run",
126
+ "test:unit": "vitest run --project jsdom-react19 --project jsdom-react18",
127
+ "test:browser": "vitest run --project browser-webkit"
128
+ }
6
129
  }