preact-missing-hooks 4.6.0 → 4.8.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/Readme.md +84 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +1 -1
- package/dist/index.modern.mjs.map +1 -1
- package/dist/index.module.js +1 -1
- package/dist/index.module.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/react.js +270 -0
- package/dist/useDeviceData.d.ts +82 -0
- package/dist/usePoll.d.ts +47 -0
- package/docs/README.md +2 -0
- package/docs/main.js +66 -0
- package/llm.package.json +57 -72
- package/llm.package.txt +21 -19
- package/package.json +15 -3
- package/scripts/ensure-microbundle-patch.cjs +46 -0
- package/src/index.ts +2 -0
- package/src/useDeviceData.ts +285 -0
- package/src/usePoll.ts +110 -0
- package/tests/useDeviceData.test.tsx +213 -0
- package/tests/usePoll.test.tsx +110 -0
package/llm.package.json
CHANGED
|
@@ -1,151 +1,134 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "preact-missing-hooks",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.6.0",
|
|
4
4
|
"description": "A lightweight, extendable collection of missing React-like hooks for Preact — plus fresh, powerful new ones designed specifically for modern Preact apps.",
|
|
5
5
|
"exports": {
|
|
6
6
|
"useTransition": {
|
|
7
7
|
"type": "function",
|
|
8
|
-
"description": "
|
|
8
|
+
"description": "React hook that provides a transition state to coordinate updates that may be delayed, allowing components to render fallback UI while waiting.",
|
|
9
9
|
"hook": true,
|
|
10
|
-
"params": "
|
|
11
|
-
"returns": "
|
|
12
|
-
"example": "const [isPending, startTransition] = useTransition(); startTransition(() => { /* heavy work */ });"
|
|
10
|
+
"params": "config?: { timeoutMs?: number }",
|
|
11
|
+
"returns": "[isPending: boolean, startTransition: (callback: () => void) => void]"
|
|
13
12
|
},
|
|
14
13
|
"useMutationObserver": {
|
|
15
14
|
"type": "function",
|
|
16
|
-
"description": "
|
|
15
|
+
"description": "React hook that observes DOM mutations on a target element, invoking a callback when mutations occur.",
|
|
17
16
|
"hook": true,
|
|
18
|
-
"params": "target: Element, callback: (mutations: MutationRecord[]) => void, options?: MutationObserverInit"
|
|
19
|
-
"returns": "void",
|
|
20
|
-
"example": "useMutationObserver(ref.current, (m) => console.log(m), { childList: true });"
|
|
17
|
+
"params": "target: Element | null, callback: (mutations: MutationRecord[]) => void, options?: MutationObserverInit"
|
|
21
18
|
},
|
|
22
19
|
"useEventBus": {
|
|
23
20
|
"type": "function",
|
|
24
|
-
"description": "
|
|
21
|
+
"description": "React hook that provides access to a shared event bus for pub/sub communication between components.",
|
|
25
22
|
"hook": true,
|
|
26
23
|
"params": "none",
|
|
27
|
-
"returns": "{ emit: (
|
|
28
|
-
"example": "const { emit, on } = useEventBus(); on('update', (d) => console.log(d)); emit('update', { foo: 'bar' });"
|
|
24
|
+
"returns": "{ emit: (event: string, data?: any) => void, on: (event: string, handler: (data?: any) => void) => void, off: (event: string, handler: (data?: any) => void) => void }"
|
|
29
25
|
},
|
|
30
26
|
"useWrappedChildren": {
|
|
31
27
|
"type": "function",
|
|
32
|
-
"description": "
|
|
28
|
+
"description": "React hook that wraps child components with additional props or context, useful for injecting shared data.",
|
|
33
29
|
"hook": true,
|
|
34
|
-
"params": "children: ReactNode,
|
|
35
|
-
"returns": "ReactNode"
|
|
36
|
-
"example": "const wrapped = useWrappedChildren(children, (c) => <div className='wrapper'>{c}</div>);"
|
|
30
|
+
"params": "children: ReactNode, wrapperProps?: object",
|
|
31
|
+
"returns": "ReactNode"
|
|
37
32
|
},
|
|
38
33
|
"usePreferredTheme": {
|
|
39
34
|
"type": "function",
|
|
40
|
-
"description": "
|
|
35
|
+
"description": "React hook that detects and returns the user's preferred color scheme (light/dark) from system or media query.",
|
|
41
36
|
"hook": true,
|
|
42
37
|
"params": "none",
|
|
43
|
-
"returns": "'light' | 'dark' | 'no-preference'"
|
|
44
|
-
"example": "const theme = usePreferredTheme();"
|
|
38
|
+
"returns": "'light' | 'dark' | 'no-preference'"
|
|
45
39
|
},
|
|
46
40
|
"useNetworkState": {
|
|
47
41
|
"type": "function",
|
|
48
|
-
"description": "
|
|
42
|
+
"description": "React hook that returns the current network connection status (online/offline) and connectivity details.",
|
|
49
43
|
"hook": true,
|
|
50
44
|
"params": "none",
|
|
51
|
-
"returns": "{ online: boolean,
|
|
52
|
-
"example": "const { online, networkType } = useNetworkState();"
|
|
45
|
+
"returns": "{ online: boolean, since?: Date, type?: string, effectiveType?: string, downlink?: number, rtt?: number }"
|
|
53
46
|
},
|
|
54
47
|
"useClipboard": {
|
|
55
48
|
"type": "function",
|
|
56
|
-
"description": "
|
|
49
|
+
"description": "React hook that provides access to the system clipboard for reading and writing text content.",
|
|
57
50
|
"hook": true,
|
|
58
51
|
"params": "none",
|
|
59
|
-
"returns": "{
|
|
60
|
-
"example": "const { write } = useClipboard(); write('hello');"
|
|
52
|
+
"returns": "{ text: string | null, write: (text: string) => Promise<void> }"
|
|
61
53
|
},
|
|
62
54
|
"useRageClick": {
|
|
63
55
|
"type": "function",
|
|
64
|
-
"description": "
|
|
56
|
+
"description": "React hook that detects rapid repeated clicks on an element, useful for triggering special actions or preventing accidental triggers.",
|
|
65
57
|
"hook": true,
|
|
66
|
-
"params": "
|
|
67
|
-
"returns": "void"
|
|
68
|
-
"example": "useRageClick(() => retry(), { count: 3, delay: 500 });"
|
|
58
|
+
"params": "onClick: (event: MouseEvent) => void, threshold?: number",
|
|
59
|
+
"returns": "void"
|
|
69
60
|
},
|
|
70
61
|
"useThreadedWorker": {
|
|
71
62
|
"type": "function",
|
|
72
|
-
"description": "Creates a
|
|
63
|
+
"description": "Creates a Web Worker from a script or function and provides a thread-safe interface to run tasks in parallel. Ideal for CPU-intensive operations that should not block the UI thread.",
|
|
73
64
|
"hook": true,
|
|
74
|
-
"params": "
|
|
75
|
-
"returns": "
|
|
65
|
+
"params": "workerSource: string | Function, options?: { autoTerminate?: boolean }",
|
|
66
|
+
"returns": "{ run: (data: any) => Promise<any>, terminate: () => void }",
|
|
76
67
|
"sideEffect": false,
|
|
77
|
-
"example": "const
|
|
68
|
+
"example": "const { run, terminate } = useThreadedWorker(workerScript); run({ data }).then(result => console.log(result));"
|
|
78
69
|
},
|
|
79
70
|
"useIndexedDB": {
|
|
80
71
|
"type": "function",
|
|
81
|
-
"description": "Provides a
|
|
72
|
+
"description": "Provides a reactive interface to IndexedDB for storing and retrieving structured data in the browser. Useful for offline-first apps or caching large datasets beyond localStorage limits.",
|
|
82
73
|
"hook": true,
|
|
83
|
-
"params": "storeName: string, options?: { version?: number
|
|
84
|
-
"returns": "{ get
|
|
74
|
+
"params": "dbName: string, storeName: string, options?: { version?: number }",
|
|
75
|
+
"returns": "{ get: (key: string) => Promise<any>, set: (key: string, value: any) => Promise<void>, delete: (key: string) => Promise<void>, clear: () => Promise<void> }",
|
|
85
76
|
"sideEffect": false,
|
|
86
|
-
"example": "const { get, set } = useIndexedDB('
|
|
77
|
+
"example": "const { get, set } = useIndexedDB('myApp', 'users'); set('user1', userData); const user = await get('user1');"
|
|
87
78
|
},
|
|
88
79
|
"useWebRTCIP": {
|
|
89
80
|
"type": "function",
|
|
90
|
-
"description": "Detects
|
|
81
|
+
"description": "Detects the local IP address of the client using WebRTC without establishing a peer connection. Helpful for network-aware applications or WebRTC debugging.",
|
|
91
82
|
"hook": true,
|
|
92
|
-
"params": "
|
|
93
|
-
"returns": "
|
|
83
|
+
"params": "none",
|
|
84
|
+
"returns": "Promise<string[]>",
|
|
94
85
|
"sideEffect": false,
|
|
95
|
-
"example": "const
|
|
86
|
+
"example": "const ips = await useWebRTCIP(); console.log('Local IPs:', ips);"
|
|
96
87
|
},
|
|
97
88
|
"useWasmCompute": {
|
|
98
89
|
"type": "function",
|
|
99
|
-
"description": "Loads and
|
|
90
|
+
"description": "Loads and runs WebAssembly modules for high-performance computations in the browser. Best for heavy numeric processing or cryptographic operations where JavaScript is too slow.",
|
|
100
91
|
"hook": true,
|
|
101
|
-
"params": "
|
|
102
|
-
"returns": "
|
|
92
|
+
"params": "wasmModule: ArrayBuffer | string, importObject?: object",
|
|
93
|
+
"returns": "{ run: (method: string, ...args: any[]) => any, free: () => void }",
|
|
103
94
|
"sideEffect": false,
|
|
104
|
-
"example": "const
|
|
95
|
+
"example": "const { run } = useWasmCompute(wasmBytes); const result = run('computeHash', input);"
|
|
105
96
|
},
|
|
106
97
|
"useWorkerNotifications": {
|
|
107
98
|
"type": "function",
|
|
108
|
-
"description": "
|
|
109
|
-
"hook": true,
|
|
110
|
-
"params": "workerUrl: string, notificationOptions?: NotificationOptions",
|
|
111
|
-
"returns": "{ postMessage, onNotification, requestPermission }",
|
|
112
|
-
"sideEffect": false,
|
|
113
|
-
"example": "const { postMessage } = useWorkerNotifications('/worker.js'); postMessage({ type: 'start' });"
|
|
114
|
-
},
|
|
115
|
-
"useLLMMetadata": {
|
|
116
|
-
"type": "function",
|
|
117
|
-
"description": "Extracts and processes metadata from LLVM bitcode or compiled modules. Useful for analyzing compiled code structure, retrieving function signatures, and understanding module dependencies in development tools.",
|
|
99
|
+
"description": "Registers a service worker and manages push notifications with permission handling. Useful for real-time updates or background messaging in progressive web apps.",
|
|
118
100
|
"hook": true,
|
|
119
|
-
"params": "
|
|
120
|
-
"returns": "{
|
|
101
|
+
"params": "swUrl: string, options?: { permission?: 'default' | 'granted' | 'denied' }",
|
|
102
|
+
"returns": "{ subscribe: () => Promise<boolean>, unsubscribe: () => Promise<void>, isSubscribed: boolean }",
|
|
121
103
|
"sideEffect": false,
|
|
122
|
-
"example": "const {
|
|
104
|
+
"example": "const { subscribe } = useWorkerNotifications('/sw.js'); await subscribe();"
|
|
123
105
|
},
|
|
124
106
|
"useRefPrint": {
|
|
125
107
|
"type": "function",
|
|
126
|
-
"description": "Provides a
|
|
108
|
+
"description": "Provides a reference to a DOM element and a method to print its contents. Useful for printing specific sections of a page without affecting the entire document.",
|
|
127
109
|
"hook": true,
|
|
128
|
-
"params": "
|
|
129
|
-
"returns": "{ print
|
|
110
|
+
"params": "none",
|
|
111
|
+
"returns": "{ ref: React.RefObject<any>, print: () => void }",
|
|
130
112
|
"sideEffect": false,
|
|
131
|
-
"example": "const { print } = useRefPrint(
|
|
113
|
+
"example": "const { ref, print } = useRefPrint(); return <div ref={ref}>Content to print</div>;"
|
|
132
114
|
},
|
|
133
115
|
"useRBAC": {
|
|
134
116
|
"type": "function",
|
|
135
|
-
"description": "
|
|
117
|
+
"description": "Manages role-based access control by checking user permissions against defined roles. Ideal for securing components or routes based on user authorization levels.",
|
|
136
118
|
"hook": true,
|
|
137
|
-
"params": "
|
|
138
|
-
"returns": "{
|
|
119
|
+
"params": "userRoles: string[], permissions: { [role: string]: string[] }",
|
|
120
|
+
"returns": "{ hasPermission: (action: string) => boolean, roles: string[] }",
|
|
139
121
|
"sideEffect": false,
|
|
140
|
-
"example": "const {
|
|
122
|
+
"example": "const { hasPermission } = useRBAC(user.roles, permissionMap); if (hasPermission('edit')) { /* show edit button */ }"
|
|
141
123
|
},
|
|
142
124
|
"usePrefetch": {
|
|
143
125
|
"type": "function",
|
|
144
|
-
"description": "
|
|
126
|
+
"description": "Prefetches resources like scripts, styles, or API data to improve perceived performance. Best for predictive loading when user is likely to navigate to a specific route.",
|
|
145
127
|
"hook": true,
|
|
146
|
-
"params": "
|
|
147
|
-
"returns": "
|
|
148
|
-
"
|
|
128
|
+
"params": "resources: string[] | { [key: string]: string }",
|
|
129
|
+
"returns": "{ loading: boolean, error: Error | null }",
|
|
130
|
+
"sideEffect": false,
|
|
131
|
+
"example": "const { loading } = usePrefetch(['/api/data', '/static/style.css']); if (loading) { /* show spinner */ }"
|
|
149
132
|
}
|
|
150
133
|
},
|
|
151
134
|
"hooks": [
|
|
@@ -162,7 +145,6 @@
|
|
|
162
145
|
"useWebRTCIP",
|
|
163
146
|
"useWasmCompute",
|
|
164
147
|
"useWorkerNotifications",
|
|
165
|
-
"useLLMMetadata",
|
|
166
148
|
"useRefPrint",
|
|
167
149
|
"useRBAC",
|
|
168
150
|
"usePrefetch"
|
|
@@ -174,7 +156,10 @@
|
|
|
174
156
|
"generatedBy": "hayagriva-llm@1.2.0",
|
|
175
157
|
"mode": "ai",
|
|
176
158
|
"summary": "Preact-Missing-Hooks is a lightweight, extendable collection of missing React-like hooks for Preact — plus fresh, powerful new ones designed specifically for modern Preact apps. It bridges the gap between Preact and React's hook ecosystem while adding innovative hooks for advanced web features like WebRTC, WebAssembly, IndexedDB, and more.",
|
|
177
|
-
"sideEffects": [
|
|
159
|
+
"sideEffects": [
|
|
160
|
+
"reads process.env",
|
|
161
|
+
"modifies DOM"
|
|
162
|
+
],
|
|
178
163
|
"keywords": [
|
|
179
164
|
"preact",
|
|
180
165
|
"hooks",
|
package/llm.package.txt
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Package: preact-missing-hooks
|
|
2
|
-
Version: 4.
|
|
2
|
+
Version: 4.6.0
|
|
3
3
|
|
|
4
4
|
Description:
|
|
5
5
|
A lightweight, extendable collection of missing React-like hooks for Preact — plus fresh, powerful new ones designed specifically for modern Preact apps.
|
|
@@ -33,6 +33,10 @@ Use cases:
|
|
|
33
33
|
- Tracking worker notifications and task execution in real-time
|
|
34
34
|
- Retrieving local WebRTC IP addresses for signaling or diagnostics
|
|
35
35
|
|
|
36
|
+
Side effects:
|
|
37
|
+
- reads process.env
|
|
38
|
+
- modifies DOM
|
|
39
|
+
|
|
36
40
|
Keywords:
|
|
37
41
|
preact, hooks, react-hooks, useTransition, useMutationObserver, useEventBus, useWrappedChildren, usePreferredTheme, useNetworkState, useClipboard, useRageClick, useThreadedWorker, useIndexedDB, useWebRTCIP, useWasmCompute, useWorkerNotifications, useLLMMetadata, useRefPrint, useRBAC, usePrefetch, typescript, modern-web, web-development, frontend, ui-components
|
|
38
42
|
|
|
@@ -44,23 +48,22 @@ Related packages:
|
|
|
44
48
|
preact, react, react-hooks, preact/hooks, preact/compat
|
|
45
49
|
|
|
46
50
|
Exports:
|
|
47
|
-
- useClipboard (Hook) :
|
|
48
|
-
- useEventBus (Hook) :
|
|
49
|
-
- useIndexedDB (Hook) : Provides a
|
|
50
|
-
-
|
|
51
|
-
-
|
|
52
|
-
-
|
|
53
|
-
-
|
|
54
|
-
-
|
|
55
|
-
-
|
|
56
|
-
-
|
|
57
|
-
-
|
|
58
|
-
-
|
|
59
|
-
-
|
|
60
|
-
-
|
|
61
|
-
-
|
|
62
|
-
-
|
|
63
|
-
- useWrappedChildren (Hook) : Hook that wraps child components or elements with additional logic or styling, returning a wrapped version of the children. Useful for injecting context, props, or wrappers without altering the original structure. — params: children: ReactNode, wrapper: (child: ReactNode) => ReactNode — returns: ReactNode — e.g. const wrapped = useWrappedChildren(children, (c) => <div className='wrapper'>{c}</div>);
|
|
51
|
+
- useClipboard (Hook) : React hook that provides access to the system clipboard for reading and writing text content. — params: none — returns: { text: string | null, write: (text: string) => Promise<void> }
|
|
52
|
+
- useEventBus (Hook) : React hook that provides access to a shared event bus for pub/sub communication between components. — params: none — returns: { emit: (event: string, data?: any) => void, on: (event: string, handler: (data?: any) => void) => void, off: (event: string, handler: (data?: any) => void) => void }
|
|
53
|
+
- useIndexedDB (Hook) : Provides a reactive interface to IndexedDB for storing and retrieving structured data in the browser. Useful for offline-first apps or caching large datasets beyond localStorage limits. — params: dbName: string, storeName: string, options?: { version?: number } — returns: { get: (key: string) => Promise<any>, set: (key: string, value: any) => Promise<void>, delete: (key: string) => Promise<void>, clear: () => Promise<void> } — e.g. const { get, set } = useIndexedDB('myApp', 'users'); set('user1', userData); const user = await get('user1');
|
|
54
|
+
- useMutationObserver (Hook) : React hook that observes DOM mutations on a target element, invoking a callback when mutations occur. — params: target: Element | null, callback: (mutations: MutationRecord[]) => void, options?: MutationObserverInit
|
|
55
|
+
- useNetworkState (Hook) : React hook that returns the current network connection status (online/offline) and connectivity details. — params: none — returns: { online: boolean, since?: Date, type?: string, effectiveType?: string, downlink?: number, rtt?: number }
|
|
56
|
+
- usePreferredTheme (Hook) : React hook that detects and returns the user's preferred color scheme (light/dark) from system or media query. — params: none — returns: 'light' | 'dark' | 'no-preference'
|
|
57
|
+
- usePrefetch (Hook) : Prefetches resources like scripts, styles, or API data to improve perceived performance. Best for predictive loading when user is likely to navigate to a specific route. — params: resources: string[] | { [key: string]: string } — returns: { loading: boolean, error: Error | null } — e.g. const { loading } = usePrefetch(['/api/data', '/static/style.css']); if (loading) { /* show spinner */ }
|
|
58
|
+
- useRageClick (Hook) : React hook that detects rapid repeated clicks on an element, useful for triggering special actions or preventing accidental triggers. — params: onClick: (event: MouseEvent) => void, threshold?: number — returns: void
|
|
59
|
+
- useRBAC (Hook) : Manages role-based access control by checking user permissions against defined roles. Ideal for securing components or routes based on user authorization levels. — params: userRoles: string[], permissions: { [role: string]: string[] } — returns: { hasPermission: (action: string) => boolean, roles: string[] } — e.g. const { hasPermission } = useRBAC(user.roles, permissionMap); if (hasPermission('edit')) { /* show edit button */ }
|
|
60
|
+
- useRefPrint (Hook) : Provides a reference to a DOM element and a method to print its contents. Useful for printing specific sections of a page without affecting the entire document. — params: none — returns: { ref: React.RefObject<any>, print: () => void } — e.g. const { ref, print } = useRefPrint(); return <div ref={ref}>Content to print</div>;
|
|
61
|
+
- useThreadedWorker (Hook) : Creates a Web Worker from a script or function and provides a thread-safe interface to run tasks in parallel. Ideal for CPU-intensive operations that should not block the UI thread. — params: workerSource: string | Function, options?: { autoTerminate?: boolean } — returns: { run: (data: any) => Promise<any>, terminate: () => void } — e.g. const { run, terminate } = useThreadedWorker(workerScript); run({ data }).then(result => console.log(result));
|
|
62
|
+
- useTransition (Hook) : React hook that provides a transition state to coordinate updates that may be delayed, allowing components to render fallback UI while waiting. — params: config?: { timeoutMs?: number } — returns: [isPending: boolean, startTransition: (callback: () => void) => void]
|
|
63
|
+
- useWasmCompute (Hook) : Loads and runs WebAssembly modules for high-performance computations in the browser. Best for heavy numeric processing or cryptographic operations where JavaScript is too slow. — params: wasmModule: ArrayBuffer | string, importObject?: object — returns: { run: (method: string, ...args: any[]) => any, free: () => void } — e.g. const { run } = useWasmCompute(wasmBytes); const result = run('computeHash', input);
|
|
64
|
+
- useWebRTCIP (Hook) : Detects the local IP address of the client using WebRTC without establishing a peer connection. Helpful for network-aware applications or WebRTC debugging. — params: none — returns: Promise<string[]> — e.g. const ips = await useWebRTCIP(); console.log('Local IPs:', ips);
|
|
65
|
+
- useWorkerNotifications (Hook) : Registers a service worker and manages push notifications with permission handling. Useful for real-time updates or background messaging in progressive web apps. — params: swUrl: string, options?: { permission?: 'default' | 'granted' | 'denied' } — returns: { subscribe: () => Promise<boolean>, unsubscribe: () => Promise<void>, isSubscribed: boolean } — e.g. const { subscribe } = useWorkerNotifications('/sw.js'); await subscribe();
|
|
66
|
+
- useWrappedChildren (Hook) : React hook that wraps child components with additional props or context, useful for injecting shared data. — params: children: ReactNode, wrapperProps?: object — returns: ReactNode
|
|
64
67
|
|
|
65
68
|
Hooks:
|
|
66
69
|
- useTransition
|
|
@@ -76,7 +79,6 @@ Hooks:
|
|
|
76
79
|
- useWebRTCIP
|
|
77
80
|
- useWasmCompute
|
|
78
81
|
- useWorkerNotifications
|
|
79
|
-
- useLLMMetadata
|
|
80
82
|
- useRefPrint
|
|
81
83
|
- useRBAC
|
|
82
84
|
- usePrefetch
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "preact-missing-hooks",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.8.0",
|
|
4
4
|
"description": "A lightweight, extendable collection of missing React-like hooks for Preact — plus fresh, powerful new ones designed specifically for modern Preact apps.",
|
|
5
5
|
"author": "Prakhar Dubey",
|
|
6
6
|
"license": "MIT",
|
|
@@ -97,6 +97,16 @@
|
|
|
97
97
|
"import": "./dist/usePrefetch.module.js",
|
|
98
98
|
"require": "./dist/usePrefetch.js"
|
|
99
99
|
},
|
|
100
|
+
"./usePoll": {
|
|
101
|
+
"types": "./dist/usePoll.d.ts",
|
|
102
|
+
"import": "./dist/usePoll.module.js",
|
|
103
|
+
"require": "./dist/usePoll.js"
|
|
104
|
+
},
|
|
105
|
+
"./useDeviceData": {
|
|
106
|
+
"types": "./dist/useDeviceData.d.ts",
|
|
107
|
+
"import": "./dist/useDeviceData.module.js",
|
|
108
|
+
"require": "./dist/useDeviceData.js"
|
|
109
|
+
},
|
|
100
110
|
"./react": {
|
|
101
111
|
"types": "./dist/index.d.ts",
|
|
102
112
|
"import": "./dist/react.module.js",
|
|
@@ -104,7 +114,7 @@
|
|
|
104
114
|
}
|
|
105
115
|
},
|
|
106
116
|
"scripts": {
|
|
107
|
-
"build": "microbundle --alias react=preact/compat && npm run build:react && node scripts/generate-entry.cjs",
|
|
117
|
+
"build": "node scripts/ensure-microbundle-patch.cjs && microbundle --alias react=preact/compat && npm run build:react && node scripts/generate-entry.cjs",
|
|
108
118
|
"llm:generate": "hayagriva-llm generate --mode ai --include-src --verbose",
|
|
109
119
|
"build:react": "rollup -c scripts/rollup.react.config.cjs",
|
|
110
120
|
"dev": "microbundle watch",
|
|
@@ -117,7 +127,7 @@
|
|
|
117
127
|
"lint": "eslint src",
|
|
118
128
|
"format": "prettier --write \"src/**/*.{ts,tsx,json,md}\"",
|
|
119
129
|
"format:check": "prettier --check \"src/**/*.{ts,tsx,json,md}\"",
|
|
120
|
-
"prepare": "husky",
|
|
130
|
+
"prepare": "husky && node scripts/ensure-microbundle-patch.cjs",
|
|
121
131
|
"clean:cache": "node -e \"try{require('fs').rmSync('node_modules/.cache',{recursive:true,force:true});console.log('Cache cleared');}catch(e){}\"",
|
|
122
132
|
"size": "npm run clean:cache && npm run build && size-limit"
|
|
123
133
|
},
|
|
@@ -150,6 +160,8 @@
|
|
|
150
160
|
"useNetworkState",
|
|
151
161
|
"useClipboard",
|
|
152
162
|
"usePrefetch",
|
|
163
|
+
"usePoll",
|
|
164
|
+
"useDeviceData",
|
|
153
165
|
"useRageClick",
|
|
154
166
|
"rage click",
|
|
155
167
|
"sentry",
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Patches microbundle to pass clean: true to rollup-plugin-typescript2.
|
|
3
|
+
* In rpt2, "clean" disables the RollingCache (noCache), avoiding EPERM rename
|
|
4
|
+
* failures on Windows during UMD/CJS/ESM builds.
|
|
5
|
+
*/
|
|
6
|
+
const fs = require("fs");
|
|
7
|
+
const path = require("path");
|
|
8
|
+
|
|
9
|
+
const cliPath = path.join(
|
|
10
|
+
__dirname,
|
|
11
|
+
"..",
|
|
12
|
+
"node_modules",
|
|
13
|
+
"microbundle",
|
|
14
|
+
"dist",
|
|
15
|
+
"cli.js",
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
if (!fs.existsSync(cliPath)) {
|
|
19
|
+
console.warn(
|
|
20
|
+
"ensure-microbundle-patch: microbundle not installed, skipping patch",
|
|
21
|
+
);
|
|
22
|
+
process.exit(0);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const src = fs.readFileSync(cliPath, "utf8");
|
|
26
|
+
const marker = "clean: true,";
|
|
27
|
+
|
|
28
|
+
if (src.includes(marker)) {
|
|
29
|
+
process.exit(0);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const needle =
|
|
33
|
+
"(useTypescript || emitDeclaration) && typescript__default['default']({";
|
|
34
|
+
const replacement = `${needle} clean: true,`;
|
|
35
|
+
|
|
36
|
+
if (!src.includes(needle)) {
|
|
37
|
+
console.error(
|
|
38
|
+
"ensure-microbundle-patch: microbundle cli.js format changed; update the patch script",
|
|
39
|
+
);
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
fs.writeFileSync(cliPath, src.replace(needle, replacement), "utf8");
|
|
44
|
+
console.log(
|
|
45
|
+
"Patched microbundle (rollup-plugin-typescript2 clean:true for Windows EPERM)",
|
|
46
|
+
);
|