@mainframework/api-request-worker 1.0.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/dist/index.js ADDED
@@ -0,0 +1,223 @@
1
+ import { useRef, useState, useCallback, useEffect } from 'react';
2
+
3
+ // utils/uniqueId.ts
4
+ let idCounter = 0;
5
+ /**
6
+ * Generates a stable, unique string ID.
7
+ * SSR-safe and works in any environment.
8
+ */
9
+ const uniqueId = () => {
10
+ idCounter += 1;
11
+ return idCounter.toString();
12
+ };
13
+
14
+ const e=e=>"object"==typeof e&&null!==e,t=e=>"function"==typeof e,r=e=>e instanceof Date,n=e=>e instanceof RegExp,o=e=>e instanceof Set,f=e=>e instanceof Map,i=e=>e instanceof String||e instanceof Number||e instanceof Boolean,a=e=>ArrayBuffer.isView(e)&&!(e instanceof DataView),s=e=>Object.getPrototypeOf(e),u=e=>null==e||"object"!=typeof e&&"function"!=typeof e,c=(l,y,p=new WeakMap,b={})=>{if(l===y)return true;if("number"==typeof l&&"number"==typeof y&&Number.isNaN(l)&&Number.isNaN(y))return true;if(b.normalizeBoxedPrimitives&&(i(l)&&(l=l.valueOf()),i(y)&&(y=y.valueOf()),u(l)&&u(y)))return l===y;if(u(l)||u(y))return false;if(t(l)||t(y))return l===y;if(!e(l)||!e(y))return false;let g=p.get(l)??(()=>{const e=new WeakMap;return p.set(l,e),e})();const h=g.get(y);if(void 0!==h)return h;g.set(y,true);const w=s(l),A=s(y);let m;return m=Array.isArray(l)&&Array.isArray(y)?((e,t,r,n)=>{if(e.length!==t.length)return false;for(let o=0;o<e.length;o++){if(n.strictSparseArrays){const r=Object.prototype.hasOwnProperty.call(e,o),n=Object.prototype.hasOwnProperty.call(t,o);if(r!==n)return false;if(!r&&!n)continue}if(!c(e[o],t[o],r,n))return false}return true})(l,y,p,b):!Array.isArray(l)&&!Array.isArray(y)&&(r(l)&&r(y)?((e,t)=>e.getTime()===t.getTime())(l,y):n(l)&&n(y)?((e,t)=>e.source===t.source&&e.flags===t.flags)(l,y):a(l)&&a(y)?((e,t)=>{if(e.constructor!==t.constructor||e.byteLength!==t.byteLength)return false;const r=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),n=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);for(let e=0;e<r.length;e++)if(r[e]!==n[e])return false;return true})(l,y):o(l)&&o(y)?((e,t,r,n)=>{if(e.size!==t.size)return false;const o=Array.from(t),f=new Set;for(const t of e){const e=o.findIndex((e,r)=>!f.has(r)&&t===e);if(-1!==e){f.add(e);continue}let i=false;for(let e=0;e<o.length;e++)if(!f.has(e)&&c(t,o[e],r,n)){f.add(e),i=true;break}if(!i)return false}return true})(l,y,p,b):f(l)&&f(y)?((e,t,r,n)=>{if(e.size!==t.size)return false;const o=Array.from(t),f=new Set;for(const[i,a]of e){if(u(i)){const e=t.get(i);if(void 0===e&&!t.has(i))return false;if(!c(a,e,r,n))return false;continue}let e=false;for(let t=0;t<o.length;t++)if(!f.has(t)){const[s,u]=o[t];if(c(i,s,r,n)&&c(a,u,r,n)){f.add(t),e=true;break}}if(!e)return false}return true})(l,y,p,b):!(!b.allowPrototypeMismatch&&w!==A)&&((e,t,r,n)=>{let o=0;for(const f of Reflect.ownKeys(e)){if(!Object.prototype.hasOwnProperty.call(t,f))return false;if(!c(e[f],t[f],r,n))return false;o++;}return Reflect.ownKeys(t).length===o})(l,y,p,b)),g.set(y,m),m},l=(e,t,r)=>c(e,t,new WeakMap,r);
15
+
16
+ const useCustomCallback = (callback, dependencies) => {
17
+ const refCallback = useRef(callback);
18
+ const refDependencies = useRef(dependencies);
19
+ // Update refs synchronously during render
20
+ if (!dependencies.every((dep, index) => l(dep, refDependencies.current[index]))) {
21
+ refDependencies.current = dependencies;
22
+ refCallback.current = callback;
23
+ }
24
+ // Stable callback, always calls latest callback
25
+ const stableCallback = useRef((...args) => refCallback.current(...args)).current;
26
+ return stableCallback;
27
+ };
28
+
29
+ // useApiWorker.ts
30
+ // ============================================================================
31
+ // MODULE-LEVEL WORKER & QUEUE
32
+ // ============================================================================
33
+ const apiWorker = new Worker(new URL("./api.worker.js", import.meta.url));
34
+ const STALE_ENTRY_MS = 5000;
35
+ const CLEANUP_INTERVAL_MS = 30000;
36
+ const normalizeKey = (key) => key.toLocaleLowerCase();
37
+ const cleanupState = { isDeleting: false, lastRun: 0 };
38
+ const runStaleEntryCleanup = () => {
39
+ const now = Date.now();
40
+ if (cleanupState.isDeleting || now < cleanupState.lastRun + CLEANUP_INTERVAL_MS)
41
+ return;
42
+ cleanupState.isDeleting = true;
43
+ try {
44
+ const keys = Object.keys(responseQueue);
45
+ let i = 0;
46
+ while (i < keys.length) {
47
+ const key = keys[i];
48
+ const entry = responseQueue[key];
49
+ if (entry && entry.data != null && entry.lastActivityAt != null && now - entry.lastActivityAt >= STALE_ENTRY_MS) {
50
+ entry.loading = null;
51
+ entry.data = null;
52
+ entry.meta = null;
53
+ entry.error = null;
54
+ entry.setUpdateTrigger = null;
55
+ entry.requestId = null;
56
+ }
57
+ i++;
58
+ }
59
+ }
60
+ finally {
61
+ cleanupState.isDeleting = false;
62
+ cleanupState.lastRun = now;
63
+ }
64
+ };
65
+ const responseQueue = {};
66
+ const streamAccumulators = {};
67
+ const updater = (n) => n + 1;
68
+ const findEntry = (cacheName, hookId) => cacheName
69
+ ? responseQueue[normalizeKey(cacheName)]
70
+ : hookId
71
+ ? (Object.values(responseQueue).find((e) => e.hookId === hookId) ?? null)
72
+ : null;
73
+ const finalizeEntry = (entry) => {
74
+ entry.requestId = null;
75
+ entry.setUpdateTrigger?.(updater);
76
+ };
77
+ // Worker always sends error ({ message: string }). Entry is found by cacheName or hookId.
78
+ // Stream responses: start → chunk(s) → end; we accumulate chunks then set data = new Blob(chunks) on end.
79
+ apiWorker.onmessage = (event) => {
80
+ const msg = event.data;
81
+ const cacheName = msg.cacheName;
82
+ const hookId = msg.hookId;
83
+ const error = msg.error;
84
+ const key = cacheName ? normalizeKey(cacheName) : "";
85
+ if ("stream" in msg && msg.stream) {
86
+ const entry = findEntry(cacheName, hookId);
87
+ if (!entry)
88
+ return;
89
+ switch (msg.stream) {
90
+ case "start":
91
+ streamAccumulators[key] = { chunks: [], meta: msg.meta ?? null };
92
+ return;
93
+ case "resume":
94
+ if (!streamAccumulators[key])
95
+ streamAccumulators[key] = { chunks: [], meta: msg.meta ?? null };
96
+ else if (msg.meta)
97
+ streamAccumulators[key].meta = msg.meta;
98
+ return;
99
+ case "chunk": {
100
+ const acc = streamAccumulators[key];
101
+ if (acc && msg.data)
102
+ acc.chunks.push(msg.data);
103
+ return;
104
+ }
105
+ case "end": {
106
+ const acc = streamAccumulators[key];
107
+ delete streamAccumulators[key];
108
+ const errMsg = error?.message ?? "";
109
+ if (errMsg !== "") {
110
+ entry.error = errMsg;
111
+ }
112
+ else if (acc) {
113
+ entry.data = new Blob(acc.chunks, acc.meta?.contentType ? { type: acc.meta.contentType } : undefined);
114
+ entry.meta = acc.meta ?? null;
115
+ entry.error = null;
116
+ entry.lastActivityAt = Date.now();
117
+ }
118
+ entry.loading = false;
119
+ finalizeEntry(entry);
120
+ return;
121
+ }
122
+ }
123
+ }
124
+ const entry = findEntry(cacheName, hookId);
125
+ if (!entry)
126
+ return;
127
+ const message = error?.message ?? "";
128
+ if (message !== "") {
129
+ entry.error = message;
130
+ entry.loading = false;
131
+ }
132
+ else {
133
+ entry.data = msg.data ?? null;
134
+ entry.meta = msg.meta ?? null;
135
+ entry.lastActivityAt = Date.now();
136
+ entry.error = null;
137
+ entry.loading = false;
138
+ }
139
+ finalizeEntry(entry);
140
+ };
141
+ const useApiWorker = (config) => {
142
+ const { cacheName, request: requestConfig, data: configData, runMode = "auto", enabled = true } = config;
143
+ const hookIdRef = useRef("");
144
+ const queueKey = normalizeKey(cacheName);
145
+ const hasExecutedRef = useRef(false);
146
+ const [, setUpdateTrigger] = useState(0);
147
+ let storeEntry = responseQueue[queueKey];
148
+ if (!storeEntry) {
149
+ const hookId = uniqueId();
150
+ storeEntry = responseQueue[queueKey] = {
151
+ hookId,
152
+ cacheName,
153
+ data: null,
154
+ loading: false,
155
+ error: null,
156
+ setUpdateTrigger: () => { },
157
+ requestId: null,
158
+ meta: null,
159
+ lastActivityAt: null,
160
+ };
161
+ hookIdRef.current = hookId;
162
+ }
163
+ else {
164
+ hookIdRef.current = storeEntry.hookId;
165
+ storeEntry.lastActivityAt = Date.now();
166
+ }
167
+ storeEntry.setUpdateTrigger = setUpdateTrigger;
168
+ const hookId = hookIdRef.current;
169
+ const deleteCache = useCallback(() => {
170
+ if (cacheName) {
171
+ apiWorker.postMessage({
172
+ dataRequest: { type: "delete", cacheName, hookId: hookIdRef.current },
173
+ });
174
+ }
175
+ }, [cacheName]);
176
+ useEffect(() => {
177
+ runStaleEntryCleanup();
178
+ });
179
+ const doRequest = useCallback(() => {
180
+ const entry = responseQueue[queueKey];
181
+ if (!entry || entry.loading)
182
+ return;
183
+ entry.loading = true;
184
+ entry.error = null;
185
+ entry.lastActivityAt = Date.now();
186
+ entry.setUpdateTrigger?.(updater);
187
+ if (requestConfig) {
188
+ const requestId = uniqueId();
189
+ entry.requestId = requestId;
190
+ const request = requestConfig.responseType?.toLowerCase() === "stream" && requestConfig.retries === undefined
191
+ ? { ...requestConfig, retries: 3 }
192
+ : requestConfig;
193
+ apiWorker.postMessage({
194
+ dataRequest: { type: "set", cacheName, hookId, requestId, payload: configData, request },
195
+ });
196
+ }
197
+ else {
198
+ apiWorker.postMessage({ dataRequest: { type: "get", cacheName, hookId } });
199
+ }
200
+ hasExecutedRef.current = true;
201
+ }, [queueKey, cacheName, hookId, requestConfig, configData]);
202
+ const makeRequest = useCustomCallback(() => {
203
+ if (!enabled || (runMode === "once" && hasExecutedRef.current))
204
+ return;
205
+ doRequest();
206
+ }, [enabled, runMode, doRequest]);
207
+ const hasAlreadyRunOnce = runMode === "once" && hasExecutedRef.current;
208
+ const shouldRun = (runMode === "auto" || runMode === "once") && enabled && (requestConfig || cacheName);
209
+ if (shouldRun && !hasAlreadyRunOnce && !storeEntry.loading) {
210
+ doRequest();
211
+ }
212
+ return {
213
+ data: storeEntry?.data ?? null,
214
+ meta: storeEntry?.meta ?? null,
215
+ loading: storeEntry?.loading ?? false,
216
+ error: storeEntry?.error ?? null,
217
+ refetch: makeRequest,
218
+ deleteCache,
219
+ };
220
+ };
221
+
222
+ export { useApiWorker };
223
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/shared/utils/uniqueId.ts","../node_modules/@mainframework/is-deep-equal/dist/index.mjs","../src/shared/hooks/useCustomCallback.ts","../src/shared/hooks/useApiWorker.ts"],"sourcesContent":["// utils/uniqueId.ts\r\nlet idCounter = 0;\r\n\r\n/**\r\n * Generates a stable, unique string ID.\r\n * SSR-safe and works in any environment.\r\n */\r\nexport const uniqueId = (): string => {\r\n idCounter += 1;\r\n return idCounter.toString();\r\n};\r\n","const e=e=>\"object\"==typeof e&&null!==e,t=e=>\"function\"==typeof e,r=e=>e instanceof Date,n=e=>e instanceof RegExp,o=e=>e instanceof Set,f=e=>e instanceof Map,i=e=>e instanceof String||e instanceof Number||e instanceof Boolean,a=e=>ArrayBuffer.isView(e)&&!(e instanceof DataView),s=e=>Object.getPrototypeOf(e),u=e=>null==e||\"object\"!=typeof e&&\"function\"!=typeof e,c=(l,y,p=new WeakMap,b={})=>{if(l===y)return!0;if(\"number\"==typeof l&&\"number\"==typeof y&&Number.isNaN(l)&&Number.isNaN(y))return!0;if(b.normalizeBoxedPrimitives&&(i(l)&&(l=l.valueOf()),i(y)&&(y=y.valueOf()),u(l)&&u(y)))return l===y;if(u(l)||u(y))return!1;if(t(l)||t(y))return l===y;if(!e(l)||!e(y))return!1;let g=p.get(l)??(()=>{const e=new WeakMap;return p.set(l,e),e})();const h=g.get(y);if(void 0!==h)return h;g.set(y,!0);const w=s(l),A=s(y);let m;return m=Array.isArray(l)&&Array.isArray(y)?((e,t,r,n)=>{if(e.length!==t.length)return!1;for(let o=0;o<e.length;o++){if(n.strictSparseArrays){const r=Object.prototype.hasOwnProperty.call(e,o),n=Object.prototype.hasOwnProperty.call(t,o);if(r!==n)return!1;if(!r&&!n)continue}if(!c(e[o],t[o],r,n))return!1}return!0})(l,y,p,b):!Array.isArray(l)&&!Array.isArray(y)&&(r(l)&&r(y)?((e,t)=>e.getTime()===t.getTime())(l,y):n(l)&&n(y)?((e,t)=>e.source===t.source&&e.flags===t.flags)(l,y):a(l)&&a(y)?((e,t)=>{if(e.constructor!==t.constructor||e.byteLength!==t.byteLength)return!1;const r=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),n=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);for(let e=0;e<r.length;e++)if(r[e]!==n[e])return!1;return!0})(l,y):o(l)&&o(y)?((e,t,r,n)=>{if(e.size!==t.size)return!1;const o=Array.from(t),f=new Set;for(const t of e){const e=o.findIndex((e,r)=>!f.has(r)&&t===e);if(-1!==e){f.add(e);continue}let i=!1;for(let e=0;e<o.length;e++)if(!f.has(e)&&c(t,o[e],r,n)){f.add(e),i=!0;break}if(!i)return!1}return!0})(l,y,p,b):f(l)&&f(y)?((e,t,r,n)=>{if(e.size!==t.size)return!1;const o=Array.from(t),f=new Set;for(const[i,a]of e){if(u(i)){const e=t.get(i);if(void 0===e&&!t.has(i))return!1;if(!c(a,e,r,n))return!1;continue}let e=!1;for(let t=0;t<o.length;t++)if(!f.has(t)){const[s,u]=o[t];if(c(i,s,r,n)&&c(a,u,r,n)){f.add(t),e=!0;break}}if(!e)return!1}return!0})(l,y,p,b):!(!b.allowPrototypeMismatch&&w!==A)&&((e,t,r,n)=>{let o=0;for(const f of Reflect.ownKeys(e)){if(!Object.prototype.hasOwnProperty.call(t,f))return!1;if(!c(e[f],t[f],r,n))return!1;o++}return Reflect.ownKeys(t).length===o})(l,y,p,b)),g.set(y,m),m},l=(e,t,r)=>c(e,t,new WeakMap,r);export{l as isEqual};\n//# sourceMappingURL=index.mjs.map\n","\"use client\";\r\nimport { useRef } from \"react\";\r\nimport { isEqual } from \"@mainframework/is-deep-equal\";\r\n\r\nexport const useCustomCallback = <T extends (...args: unknown[]) => unknown>(\r\n callback: T,\r\n dependencies: unknown[],\r\n): T => {\r\n const refCallback = useRef<T>(callback);\r\n const refDependencies = useRef<unknown[]>(dependencies);\r\n\r\n // Update refs synchronously during render\r\n if (!dependencies.every((dep, index) => isEqual(dep, refDependencies.current[index]))) {\r\n refDependencies.current = dependencies;\r\n refCallback.current = callback;\r\n }\r\n\r\n // Stable callback, always calls latest callback\r\n const stableCallback = useRef(\r\n (...args: Parameters<T>): ReturnType<T> => refCallback.current(...args) as ReturnType<T>,\r\n ).current;\r\n\r\n return stableCallback as T;\r\n};\r\n","// useApiWorker.ts\r\nimport { useRef, useState, useCallback, useEffect } from \"react\";\r\nimport { uniqueId } from \"../utils/uniqueId\";\r\nimport type {\r\n BinaryResponseMeta,\r\n DataRequest,\r\n QueueEntry,\r\n UseApiWorkerConfig,\r\n UseApiWorkerReturn,\r\n WorkerMessagePayload,\r\n} from \"../types/types\";\r\n\r\ntype StreamAccumulator = { chunks: ArrayBuffer[]; meta: BinaryResponseMeta | null };\r\nimport { useCustomCallback } from \"./useCustomCallback\";\r\n\r\n// ============================================================================\r\n// MODULE-LEVEL WORKER & QUEUE\r\n// ============================================================================\r\n\r\nconst apiWorker = new Worker(new URL(\"../workers/api/api.worker\", import.meta.url));\r\n\r\nconst STALE_ENTRY_MS = 5000;\r\nconst CLEANUP_INTERVAL_MS = 30000;\r\n\r\nconst normalizeKey = (key: string) => key.toLocaleLowerCase();\r\n\r\nconst cleanupState = { isDeleting: false, lastRun: 0 };\r\n\r\nconst runStaleEntryCleanup = (): void => {\r\n const now = Date.now();\r\n if (cleanupState.isDeleting || now < cleanupState.lastRun + CLEANUP_INTERVAL_MS) return;\r\n cleanupState.isDeleting = true;\r\n try {\r\n const keys = Object.keys(responseQueue);\r\n let i = 0;\r\n while (i < keys.length) {\r\n const key = keys[i] as string;\r\n const entry = responseQueue[key];\r\n if (entry && entry.data != null && entry.lastActivityAt != null && now - entry.lastActivityAt >= STALE_ENTRY_MS) {\r\n entry.loading = null;\r\n entry.data = null;\r\n entry.meta = null;\r\n entry.error = null;\r\n entry.setUpdateTrigger = null;\r\n entry.requestId = null;\r\n }\r\n i++;\r\n }\r\n } finally {\r\n cleanupState.isDeleting = false;\r\n cleanupState.lastRun = now;\r\n }\r\n};\r\n\r\nconst responseQueue: Record<string, QueueEntry<unknown>> = {};\r\n\r\nconst streamAccumulators: Record<string, StreamAccumulator> = {};\r\n\r\nconst updater = (n: number) => n + 1;\r\n\r\nconst findEntry = (cacheName: string | undefined, hookId: string | undefined) =>\r\n cacheName\r\n ? responseQueue[normalizeKey(cacheName)]\r\n : hookId\r\n ? (Object.values(responseQueue).find((e) => e.hookId === hookId) ?? null)\r\n : null;\r\n\r\nconst finalizeEntry = (entry: QueueEntry<unknown>): void => {\r\n entry.requestId = null;\r\n entry.setUpdateTrigger?.(updater);\r\n};\r\n\r\n// Worker always sends error ({ message: string }). Entry is found by cacheName or hookId.\r\n// Stream responses: start → chunk(s) → end; we accumulate chunks then set data = new Blob(chunks) on end.\r\napiWorker.onmessage = (event: MessageEvent<WorkerMessagePayload>) => {\r\n const msg = event.data;\r\n const cacheName = msg.cacheName;\r\n const hookId = msg.hookId;\r\n const error = msg.error;\r\n const key = cacheName ? normalizeKey(cacheName) : \"\";\r\n\r\n if (\"stream\" in msg && msg.stream) {\r\n const entry = findEntry(cacheName, hookId);\r\n if (!entry) return;\r\n switch (msg.stream) {\r\n case \"start\":\r\n streamAccumulators[key] = { chunks: [], meta: msg.meta ?? null };\r\n return;\r\n case \"resume\":\r\n if (!streamAccumulators[key]) streamAccumulators[key] = { chunks: [], meta: msg.meta ?? null };\r\n else if (msg.meta) streamAccumulators[key].meta = msg.meta;\r\n return;\r\n case \"chunk\": {\r\n const acc = streamAccumulators[key];\r\n if (acc && msg.data) acc.chunks.push(msg.data);\r\n return;\r\n }\r\n case \"end\": {\r\n const acc = streamAccumulators[key];\r\n delete streamAccumulators[key];\r\n const errMsg = error?.message ?? \"\";\r\n if (errMsg !== \"\") {\r\n entry.error = errMsg;\r\n } else if (acc) {\r\n entry.data = new Blob(acc.chunks, acc.meta?.contentType ? { type: acc.meta.contentType } : undefined);\r\n entry.meta = acc.meta ?? null;\r\n entry.error = null;\r\n entry.lastActivityAt = Date.now();\r\n }\r\n entry.loading = false;\r\n finalizeEntry(entry);\r\n return;\r\n }\r\n }\r\n }\r\n\r\n const entry = findEntry(cacheName, hookId);\r\n if (!entry) return;\r\n\r\n const message = error?.message ?? \"\";\r\n if (message !== \"\") {\r\n entry.error = message;\r\n entry.loading = false;\r\n } else {\r\n entry.data = msg.data ?? null;\r\n entry.meta = msg.meta ?? null;\r\n entry.lastActivityAt = Date.now();\r\n entry.error = null;\r\n entry.loading = false;\r\n }\r\n finalizeEntry(entry);\r\n};\r\n\r\n// ============================================================================\r\n// HOOK\r\n// ============================================================================\r\n\r\nexport type { RequestConfig, UseApiWorkerConfig, UseApiWorkerReturn } from \"../types/types\";\r\n\r\nexport const useApiWorker = <T>(config: UseApiWorkerConfig): UseApiWorkerReturn<T> => {\r\n const { cacheName, request: requestConfig, data: configData, runMode = \"auto\", enabled = true } = config;\r\n\r\n const hookIdRef = useRef<string>(\"\");\r\n const queueKey = normalizeKey(cacheName);\r\n\r\n const hasExecutedRef = useRef(false);\r\n const [, setUpdateTrigger] = useState(0);\r\n\r\n let storeEntry = responseQueue[queueKey];\r\n\r\n if (!storeEntry) {\r\n const hookId = uniqueId();\r\n storeEntry = responseQueue[queueKey] = {\r\n hookId,\r\n cacheName,\r\n data: null,\r\n loading: false,\r\n error: null,\r\n setUpdateTrigger: () => {},\r\n requestId: null,\r\n meta: null,\r\n lastActivityAt: null,\r\n };\r\n hookIdRef.current = hookId;\r\n } else {\r\n hookIdRef.current = storeEntry.hookId;\r\n storeEntry.lastActivityAt = Date.now();\r\n }\r\n storeEntry.setUpdateTrigger = setUpdateTrigger;\r\n\r\n const hookId = hookIdRef.current;\r\n\r\n const deleteCache = useCallback(() => {\r\n if (cacheName) {\r\n apiWorker.postMessage({\r\n dataRequest: { type: \"delete\", cacheName, hookId: hookIdRef.current },\r\n });\r\n }\r\n }, [cacheName]);\r\n\r\n useEffect(() => {\r\n runStaleEntryCleanup();\r\n });\r\n\r\n const doRequest = useCallback(() => {\r\n const entry = responseQueue[queueKey];\r\n if (!entry || entry.loading) return;\r\n entry.loading = true;\r\n entry.error = null;\r\n entry.lastActivityAt = Date.now();\r\n entry.setUpdateTrigger?.(updater);\r\n if (requestConfig) {\r\n const requestId = uniqueId();\r\n entry.requestId = requestId;\r\n const request =\r\n requestConfig.responseType?.toLowerCase() === \"stream\" && requestConfig.retries === undefined\r\n ? { ...requestConfig, retries: 3 }\r\n : requestConfig;\r\n apiWorker.postMessage({\r\n dataRequest: { type: \"set\", cacheName, hookId, requestId, payload: configData, request },\r\n });\r\n } else {\r\n apiWorker.postMessage({ dataRequest: { type: \"get\", cacheName, hookId } as DataRequest<unknown> });\r\n }\r\n hasExecutedRef.current = true;\r\n }, [queueKey, cacheName, hookId, requestConfig, configData]);\r\n\r\n const makeRequest = useCustomCallback(() => {\r\n if (!enabled || (runMode === \"once\" && hasExecutedRef.current)) return;\r\n doRequest();\r\n }, [enabled, runMode, doRequest]);\r\n\r\n const hasAlreadyRunOnce = runMode === \"once\" && hasExecutedRef.current;\r\n const shouldRun = (runMode === \"auto\" || runMode === \"once\") && enabled && (requestConfig || cacheName);\r\n if (shouldRun && !hasAlreadyRunOnce && !storeEntry.loading) {\r\n doRequest();\r\n }\r\n\r\n return {\r\n data: (storeEntry?.data as T) ?? null,\r\n meta: storeEntry?.meta ?? null,\r\n loading: storeEntry?.loading ?? false,\r\n error: storeEntry?.error ?? null,\r\n refetch: makeRequest,\r\n deleteCache,\r\n };\r\n};\r\n"],"names":["isEqual"],"mappings":";;AAAA;AACA,IAAI,SAAS,GAAG,CAAC;AAEjB;;;AAGG;AACI,MAAM,QAAQ,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K,EAAE,SAAS,EAAE,MAAM,EAA0B,EAAE,CAAC;QACpG;AACA,QAAA,cAAc,CAAC,OAAO,GAAG,IAAI;AAC/B,IAAA,CAAC,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,UAAU,CAAC,CAAC;AAE5D,IAAA,MAAM,WAAW,GAAG,iBAAiB,CAAC,MAAK;QACzC,IAAI,CAAC,OAAO,KAAK,OAAO,KAAK,MAAM,IAAI,cAAc,CAAC,OAAO,CAAC;YAAE;AAChE,QAAA,SAAS,EAAE;IACb,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;IAEjC,MAAM,iBAAiB,GAAG,OAAO,KAAK,MAAM,IAAI,cAAc,CAAC,OAAO;AACtE,IAAA,MAAM,SAAS,GAAG,CAAC,OAAO,KAAK,MAAM,IAAI,OAAO,KAAK,MAAM,KAAK,OAAO,KAAK,aAAa,IAAI,SAAS,CAAC;IACvG,IAAI,SAAS,IAAI,CAAC,iBAAiB,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE;AAC1D,QAAA,SAAS,EAAE;IACb;IAEA,OAAO;AACL,QAAA,IAAI,EAAG,UAAU,EAAE,IAAU,IAAI,IAAI;AACrC,QAAA,IAAI,EAAE,UAAU,EAAE,IAAI,IAAI,IAAI;AAC9B,QAAA,OAAO,EAAE,UAAU,EAAE,OAAO,IAAI,KAAK;AACrC,QAAA,KAAK,EAAE,UAAU,EAAE,KAAK,IAAI,IAAI;AAChC,QAAA,OAAO,EAAE,WAAW;QACpB,WAAW;KACZ;AACH;;;;","x_google_ignoreList":[1]}
@@ -0,0 +1,4 @@
1
+ import type { UseApiWorkerConfig, UseApiWorkerReturn } from "../types/types";
2
+ export type { RequestConfig, UseApiWorkerConfig, UseApiWorkerReturn } from "../types/types";
3
+ export declare const useApiWorker: <T>(config: UseApiWorkerConfig) => UseApiWorkerReturn<T>;
4
+ //# sourceMappingURL=useApiWorker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useApiWorker.d.ts","sourceRoot":"","sources":["../../../src/shared/hooks/useApiWorker.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAIV,kBAAkB,EAClB,kBAAkB,EAEnB,MAAM,gBAAgB,CAAC;AA+HxB,YAAY,EAAE,aAAa,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAE5F,eAAO,MAAM,YAAY,GAAI,CAAC,EAAE,QAAQ,kBAAkB,KAAG,kBAAkB,CAAC,CAAC,CAuFhF,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const useCustomCallback: <T extends (...args: unknown[]) => unknown>(callback: T, dependencies: unknown[]) => T;
2
+ //# sourceMappingURL=useCustomCallback.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCustomCallback.d.ts","sourceRoot":"","sources":["../../../src/shared/hooks/useCustomCallback.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,iBAAiB,GAAI,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,EACzE,UAAU,CAAC,EACX,cAAc,OAAO,EAAE,KACtB,CAgBF,CAAC"}
@@ -0,0 +1,168 @@
1
+ import type { Dispatch, SetStateAction } from "react";
2
+ /** When "binary" or "stream", in-flight dedupe is skipped so we always run the request and return real response (no stale). */
3
+ export type ResponseType = "json" | "binary" | "stream";
4
+ export interface RequestConfig {
5
+ url: string;
6
+ method: "GET" | "get" | "POST" | "post" | "PATCH" | "patch" | "DELETE" | "delete";
7
+ mode?: "cors" | "no-cors" | "navigate" | "same-origin";
8
+ headers?: Record<string, string>;
9
+ credentials?: "include" | "same-origin" | "omit";
10
+ /** Omit or "json": allow in-flight dedupe. "binary" or "stream": no early return, always process request. */
11
+ responseType?: ResponseType;
12
+ /** Abort request after this many milliseconds. */
13
+ timeoutMs?: number;
14
+ /** FormData field name for File/Blob parts. Default "Files". */
15
+ formDataFileFieldName?: string;
16
+ /** FormData key for the root payload when building multipart form data. Passed to the worker in dataRequest.request. */
17
+ formDataKey?: string;
18
+ /** For responseType "stream": number of retries on connection loss (default 3). Capped at 5 in the worker. */
19
+ retries?: number;
20
+ }
21
+ export type RunMode = "auto" | "manual" | "once";
22
+ export interface UseApiWorkerConfig {
23
+ cacheName: string;
24
+ request?: RequestConfig;
25
+ data?: unknown;
26
+ runMode?: RunMode;
27
+ enabled?: boolean;
28
+ }
29
+ export type WorkerDataRequestType = "get" | "set" | "delete" | "cancel";
30
+ export type WorkerApiRequest = RequestConfig;
31
+ export interface DataRequest<T = unknown> {
32
+ hookId?: string;
33
+ cacheName?: string;
34
+ type: WorkerDataRequestType;
35
+ payload?: T;
36
+ request?: WorkerApiRequest;
37
+ /** Required for cancel, optional for set (enables cancellation). */
38
+ requestId?: string | null;
39
+ }
40
+ export interface BinaryResponseMeta {
41
+ contentType?: string;
42
+ contentDisposition: string | null;
43
+ }
44
+ /** Type-only: binary parse results use Symbol.for("WorkerApiBinary"). Value lives in api.worker. */
45
+ declare const BINARY_MARKER: unique symbol;
46
+ export type BinaryParseResult = {
47
+ [BINARY_MARKER]: true;
48
+ data: ArrayBuffer;
49
+ contentType: string;
50
+ } & Pick<BinaryResponseMeta, "contentDisposition">;
51
+ /** Worker always sends this shape; no error = { message: "" }. */
52
+ export interface WorkerErrorPayload {
53
+ message: string;
54
+ }
55
+ export interface QueueEntry<T> {
56
+ hookId: string;
57
+ cacheName: string;
58
+ loading: boolean | null;
59
+ data: T | null;
60
+ meta: BinaryResponseMeta | null;
61
+ error: string | null;
62
+ setUpdateTrigger: Dispatch<SetStateAction<number>> | null;
63
+ requestId: string | null;
64
+ lastActivityAt: number | null;
65
+ }
66
+ export interface UseApiWorkerReturn<T> {
67
+ data: T | null;
68
+ meta: BinaryResponseMeta | null;
69
+ loading: boolean;
70
+ error: string | null;
71
+ refetch: () => void;
72
+ deleteCache: () => void;
73
+ }
74
+ export type AbortControllers = Map<string, AbortController>;
75
+ /**
76
+ * Worker response messages. Use in client onmessage handler:
77
+ * - data + meta: binary response (data is ArrayBuffer). Reconstruct: new Blob([data], { type: meta?.contentType })
78
+ * - data only: JSON/text response
79
+ * - stream: "start" | "chunk" | "end" — client handles chunk sequence then finalizes
80
+ * - error: error response with message and code
81
+ */
82
+ export type WorkerResponseMessage = {
83
+ cacheName: string;
84
+ data: unknown;
85
+ error: WorkerErrorPayload;
86
+ } | {
87
+ cacheName: string;
88
+ data: ArrayBuffer;
89
+ meta: BinaryResponseMeta;
90
+ error: WorkerErrorPayload;
91
+ } | {
92
+ cacheName: string;
93
+ error: WorkerErrorPayload;
94
+ } | {
95
+ cacheName: string;
96
+ stream: "start";
97
+ meta: BinaryResponseMeta | null;
98
+ hookId?: string;
99
+ httpStatus?: number;
100
+ error: WorkerErrorPayload;
101
+ } | {
102
+ cacheName: string;
103
+ stream: "resume";
104
+ meta: BinaryResponseMeta | null;
105
+ hookId?: string;
106
+ httpStatus?: number;
107
+ error: WorkerErrorPayload;
108
+ } | {
109
+ cacheName: string;
110
+ stream: "chunk";
111
+ data: ArrayBuffer;
112
+ hookId?: string;
113
+ error: WorkerErrorPayload;
114
+ } | {
115
+ cacheName: string;
116
+ stream: "end";
117
+ hookId?: string;
118
+ error: WorkerErrorPayload;
119
+ };
120
+ /**
121
+ * Payload shape for worker postMessage. Use for client onmessage:
122
+ * MessageEvent<WorkerMessagePayload>. The worker always sends error (same shape: { message: string }).
123
+ * No error = { message: "" }. With error = { message: "..." }.
124
+ * When stream is present, client receives start → chunk(s) → end; cancel via existing requestId/cancel.
125
+ */
126
+ export type WorkerMessagePayload = {
127
+ cacheName?: string;
128
+ data?: unknown;
129
+ meta?: BinaryResponseMeta;
130
+ error: WorkerErrorPayload;
131
+ hookId?: string;
132
+ httpStatus?: number;
133
+ } | {
134
+ cacheName: string;
135
+ stream: "start";
136
+ meta: BinaryResponseMeta | null;
137
+ hookId?: string;
138
+ httpStatus?: number;
139
+ error: WorkerErrorPayload;
140
+ } | {
141
+ cacheName: string;
142
+ stream: "resume";
143
+ meta: BinaryResponseMeta | null;
144
+ hookId?: string;
145
+ httpStatus?: number;
146
+ error: WorkerErrorPayload;
147
+ } | {
148
+ cacheName: string;
149
+ stream: "chunk";
150
+ data: ArrayBuffer;
151
+ hookId?: string;
152
+ error: WorkerErrorPayload;
153
+ } | {
154
+ cacheName: string;
155
+ stream: "end";
156
+ hookId?: string;
157
+ error: WorkerErrorPayload;
158
+ };
159
+ export interface StackArray {
160
+ key: string;
161
+ value: unknown;
162
+ }
163
+ export type ContentType = "application/json" | "application/xml" | "application/x-www-form-urlencoded" | "application/pdf" | "application/zip" | "application/gzip" | "application/octet-stream" | "application/javascript" | "application/ld+json" | "application/vnd.api+json" | "application/vnd.ms-excel" | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" | "application/vnd.openxmlformats-officedocument.wordprocessingml.document" | "application/vnd.openxmlformats-officedocument.presentationml.presentation" | "text/plain" | "text/html" | "text/css" | "text/csv" | "text/javascript" | "text/xml" | "image/jpeg" | "image/png" | "image/gif" | "image/svg+xml" | "image/webp" | "image/bmp" | "image/tiff" | "image/x-icon" | "image/avif" | "audio/mpeg" | "audio/ogg" | "audio/wav" | "audio/webm" | "audio/aac" | "audio/midi" | "video/mp4" | "video/mpeg" | "video/webm" | "video/ogg" | "video/quicktime" | "video/x-msvideo" | "multipart/form-data" | "multipart/mixed" | "multipart/alternative" | "font/woff" | "font/woff2" | "font/ttf" | "font/otf";
164
+ export type WorkerMessageData = {
165
+ dataRequest?: DataRequest<unknown>;
166
+ };
167
+ export {};
168
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/shared/types/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAEtD,+HAA+H;AAC/H,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,QAAQ,GAAG,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,GACjB,kBAAkB,GAClB,0BAA0B,GAC1B,wBAAwB,GACxB,qBAAqB,GACrB,0BAA0B,GAC1B,0BAA0B,GAC1B,mEAAmE,GACnE,yEAAyE,GACzE,2EAA2E,GAE3E,YAAY,GACZ,WAAW,GACX,UAAU,GACV,UAAU,GACV,iBAAiB,GACjB,UAAU,GAEV,YAAY,GACZ,WAAW,GACX,WAAW,GACX,eAAe,GACf,YAAY,GACZ,WAAW,GACX,YAAY,GACZ,cAAc,GACd,YAAY,GAEZ,YAAY,GACZ,WAAW,GACX,WAAW,GACX,YAAY,GACZ,WAAW,GACX,YAAY,GAEZ,WAAW,GACX,YAAY,GACZ,YAAY,GACZ,WAAW,GACX,iBAAiB,GACjB,iBAAiB,GAEjB,qBAAqB,GACrB,iBAAiB,GACjB,uBAAuB,GAEvB,WAAW,GACX,YAAY,GACZ,UAAU,GACV,UAAU,CAAC;AAEf,MAAM,MAAM,iBAAiB,GAAG;IAAE,WAAW,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAA;CAAE,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Generates a stable, unique string ID.
3
+ * SSR-safe and works in any environment.
4
+ */
5
+ export declare const uniqueId: () => string;
6
+ //# sourceMappingURL=uniqueId.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uniqueId.d.ts","sourceRoot":"","sources":["../../../src/shared/utils/uniqueId.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,eAAO,MAAM,QAAQ,QAAO,MAG3B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const BINARY_MARKER: unique symbol;
2
+ //# sourceMappingURL=api.worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.worker.d.ts","sourceRoot":"","sources":["../../../../src/shared/workers/api/api.worker.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,aAAa,eAAgC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,94 @@
1
+ {
2
+ "name": "@mainframework/api-request-worker",
3
+ "version": "1.0.0",
4
+ "description": "Offloads API requests and application state to a Web Worker to keep the UI thread fast.",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.js",
11
+ "default": "./dist/index.js"
12
+ }
13
+ },
14
+ "types": "./dist/index.d.ts",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/TerrySlack/mainframework-apiworker.git"
18
+ },
19
+ "bugs": {
20
+ "url": "https://github.com/TerrySlack/mainframework-apiworker/issues"
21
+ },
22
+ "homepage": "https://github.com/TerrySlack/mainframework-apiworkere",
23
+ "scripts": {
24
+ "husky-setup": "npx husky init",
25
+ "husky": "husky",
26
+ "prepare": "husky",
27
+ "clean": "rimraf dist tsconfig.build.tsbuildinfo",
28
+ "lint-staged": "lint-staged",
29
+ "prebuild": "yarn husky && yarn clean",
30
+ "build": "yarn prebuild && rollup -c && tsc -p tsconfig.build.json --listEmittedFiles",
31
+ "test": "jest -c jestconfig.json --runInBand",
32
+ "test:watch": "jest -c jestconfig.json --watchAll --runInBand",
33
+ "test:coverage": "jest -c jestconfig.json --coverage --runInBand",
34
+ "tscheck": "tsc"
35
+ },
36
+ "lint-staged": {
37
+ "*.{js,jsx,ts,tsx}": [
38
+ "eslint --max-warnings=0 --no-warn-ignored"
39
+ ],
40
+ "*.{js,jsx,ts,tsx,json,css,md}": [
41
+ "prettier --write"
42
+ ]
43
+ },
44
+ "peerDependencies": {
45
+ "react": ">=19"
46
+ },
47
+ "peerDependenciesMeta": {
48
+ "react": {
49
+ "optional": false
50
+ }
51
+ },
52
+ "files": [
53
+ "dist",
54
+ "LICENSE",
55
+ "README.md"
56
+ ],
57
+ "keywords": [
58
+ "react",
59
+ "typescript",
60
+ "webworker",
61
+ "store"
62
+ ],
63
+ "author": "Terry Slack",
64
+ "license": "MIT",
65
+ "devDependencies": {
66
+ "@eslint/js": "^10.0.1",
67
+ "@mainframework/is-deep-equal": "^1.0.9",
68
+ "@rollup/plugin-node-resolve": "^16.0.3",
69
+ "@rollup/plugin-replace": "^6.0.3",
70
+ "@rollup/plugin-typescript": "^12.3.0",
71
+ "@testing-library/dom": "^10.4.1",
72
+ "@testing-library/react": "^16.3.2",
73
+ "@types/jest": "^30.0.0",
74
+ "@types/react": "^19.2.14",
75
+ "@typescript-eslint/eslint-plugin": "^8.55.0",
76
+ "@typescript-eslint/parser": "^8.55.0",
77
+ "eslint": "10.0.0",
78
+ "eslint-plugin-react": "^7.37.5",
79
+ "eslint-plugin-react-hooks": "^7.0.1",
80
+ "globals": "^17.3.0",
81
+ "husky": "^9.1.7",
82
+ "jest": "^30.2.0",
83
+ "jest-environment-jsdom": "^30.2.0",
84
+ "lint-staged": "^16.2.7",
85
+ "prettier": "^3.8.1",
86
+ "react": "^19.2.4",
87
+ "react-dom": "^19.2.4",
88
+ "rimraf": "^6.1.2",
89
+ "rollup": "^4.57.1",
90
+ "ts-jest": "^29.4.6",
91
+ "typescript": "^5.9.3",
92
+ "typescript-eslint": "^8.55.0"
93
+ }
94
+ }