voodoojs 0.4.6

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 (54) hide show
  1. package/README.md +77 -0
  2. package/dist/chunk-234ZLC6W.js +401 -0
  3. package/dist/chunk-4HQEOXTK.js +10271 -0
  4. package/dist/chunk-5777LJVW.js +64 -0
  5. package/dist/chunk-5CKGDARU.js +1845 -0
  6. package/dist/chunk-A2UOVQBP.js +82 -0
  7. package/dist/chunk-E27NRARW.js +16 -0
  8. package/dist/chunk-JZIYRIY6.js +1196 -0
  9. package/dist/chunk-NNU6WOOU.js +641 -0
  10. package/dist/chunk-PQZEVFVZ.js +448 -0
  11. package/dist/chunk-RJUNPXQF.js +946 -0
  12. package/dist/chunk-U76IRJKH.js +72 -0
  13. package/dist/essential.cjs +13889 -0
  14. package/dist/essential.d.cts +24 -0
  15. package/dist/essential.d.ts +24 -0
  16. package/dist/essential.js +51 -0
  17. package/dist/gpu.cjs +2008 -0
  18. package/dist/gpu.d.cts +68 -0
  19. package/dist/gpu.d.ts +68 -0
  20. package/dist/gpu.js +273 -0
  21. package/dist/http.cjs +467 -0
  22. package/dist/http.d.cts +148 -0
  23. package/dist/http.d.ts +148 -0
  24. package/dist/http.js +7 -0
  25. package/dist/index-CaLD-0oh.d.cts +608 -0
  26. package/dist/index-CaLD-0oh.d.ts +608 -0
  27. package/dist/index-DTllqUtj.d.cts +261 -0
  28. package/dist/index-DTllqUtj.d.ts +261 -0
  29. package/dist/index.cjs +23063 -0
  30. package/dist/index.d.cts +1603 -0
  31. package/dist/index.d.ts +1603 -0
  32. package/dist/index.js +6924 -0
  33. package/dist/query-CKJ4oSpG.d.cts +1595 -0
  34. package/dist/query-DQFRmu3u.d.ts +1595 -0
  35. package/dist/reactivity.cjs +676 -0
  36. package/dist/reactivity.d.cts +188 -0
  37. package/dist/reactivity.d.ts +188 -0
  38. package/dist/reactivity.js +4 -0
  39. package/dist/socket.cjs +2685 -0
  40. package/dist/socket.d.cts +167 -0
  41. package/dist/socket.d.ts +167 -0
  42. package/dist/socket.js +238 -0
  43. package/dist/style-XEUAGGJK.js +5 -0
  44. package/dist/utils.cjs +397 -0
  45. package/dist/utils.d.cts +111 -0
  46. package/dist/utils.d.ts +111 -0
  47. package/dist/utils.js +4 -0
  48. package/dist/voodoo.core.js +8213 -0
  49. package/dist/voodoo.core.min.js +146 -0
  50. package/dist/voodoo.full.js +21193 -0
  51. package/dist/voodoo.full.min.js +1784 -0
  52. package/dist/voodoo.js +14185 -0
  53. package/dist/voodoo.min.js +420 -0
  54. package/package.json +127 -0
package/dist/http.d.ts ADDED
@@ -0,0 +1,148 @@
1
+ import { parseDuration } from './utils.js';
2
+
3
+ /**
4
+ * @module http
5
+ *
6
+ * HTTP client built on `fetch`, with Axios ergonomics and no dependencies.
7
+ * Supports interceptors, timeout, retry with progressive backoff, response
8
+ * caching, cancellation, upload progress, and offline queue.
9
+ *
10
+ * Automatic retry only applies to `GET`, `HEAD`, and `OPTIONS`. For methods
11
+ * that change state, it requires explicit opt-in. See {@link podeRepetir}.
12
+ *
13
+ * ```ts
14
+ * const users = await V.http.get<User[]>('/api/users')
15
+ * await V.http.post('/api/users', { name: 'Ana' })
16
+ * ```
17
+ */
18
+
19
+ type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS';
20
+ interface RequestConfig {
21
+ url: string;
22
+ method?: HttpMethod;
23
+ /** Body. Objects become JSON, `FormData` is sent as-is. */
24
+ body?: unknown;
25
+ /** Query parameters added to the URL. */
26
+ params?: Record<string, string | number | boolean | null | undefined>;
27
+ headers?: Record<string, string>;
28
+ /** Milliseconds before aborting. `0` disables timeout. */
29
+ timeout?: number;
30
+ /**
31
+ * Extra attempts on network failure or 5xx errors.
32
+ *
33
+ * Works alone only for `GET`, `HEAD`, and `OPTIONS`. For other methods,
34
+ * retry must be enabled with `retryUnsafe` or an `Idempotency-Key` header.
35
+ * See {@link podeRepetir}.
36
+ */
37
+ retry?: number;
38
+ /** Wait between attempts, doubled each round. */
39
+ retryDelay?: number;
40
+ /**
41
+ * Enables `retry` on state-changing methods (`POST`, `PATCH`, `PUT`,
42
+ * `DELETE`). Use only when the server handles repetition safely, either
43
+ * because the operation is naturally idempotent or it is deduplicated by a
44
+ * key. Sending `Idempotency-Key` has the same effect.
45
+ */
46
+ retryUnsafe?: boolean;
47
+ /** Response cache duration in ms. GET only. */
48
+ cache?: number;
49
+ signal?: AbortSignal;
50
+ credentials?: RequestCredentials;
51
+ /** Expected type. `auto` decides by response header. */
52
+ responseType?: 'auto' | 'json' | 'text' | 'blob' | 'arrayBuffer' | 'formData';
53
+ /** Download progress callback when the server reports size. */
54
+ onProgress?: (loaded: number, total: number) => void;
55
+ /** Queue the request when browser is offline and resend later. */
56
+ offlineQueue?: boolean;
57
+ }
58
+ interface HttpResponse<T = unknown> {
59
+ data: T;
60
+ status: number;
61
+ statusText: string;
62
+ headers: Headers;
63
+ ok: boolean;
64
+ /** Original response for advanced cases. */
65
+ raw: Response;
66
+ config: RequestConfig;
67
+ }
68
+ declare class HttpError<T = unknown> extends Error {
69
+ readonly response?: HttpResponse<T> | undefined;
70
+ readonly config?: RequestConfig | undefined;
71
+ readonly cause?: unknown | undefined;
72
+ constructor(message: string, response?: HttpResponse<T> | undefined, config?: RequestConfig | undefined, cause?: unknown | undefined);
73
+ get status(): number;
74
+ /** `true` when error is network, timeout, or cancellation. */
75
+ get isNetworkError(): boolean;
76
+ }
77
+ type RequestInterceptor = (config: RequestConfig) => RequestConfig | Promise<RequestConfig>;
78
+ type ResponseInterceptor = (response: HttpResponse) => HttpResponse | Promise<HttpResponse>;
79
+ type ErrorInterceptor = (error: HttpError) => unknown;
80
+ interface HttpDefaults {
81
+ baseURL: string;
82
+ headers: Record<string, string>;
83
+ timeout: number;
84
+ retry: number;
85
+ retryDelay: number;
86
+ credentials: RequestCredentials;
87
+ /** Meta tag name read to send CSRF token automatically. */
88
+ csrfMeta: string;
89
+ /** Header used to send CSRF token. */
90
+ csrfHeader: string;
91
+ }
92
+ /** Clears entire cache or only entries matching the pattern. */
93
+ declare function clearCache(pattern?: string | RegExp): void;
94
+ /** Resends everything queued while the browser was offline. */
95
+ declare function flushOfflineQueue(): Promise<number>;
96
+ /**
97
+ * Executes a request through the entire pipeline: interceptors, timeout, retry,
98
+ * cache, and error handling.
99
+ */
100
+ declare function request<T = unknown>(input: RequestConfig): Promise<HttpResponse<T>>;
101
+ type ShortcutOptions = Omit<RequestConfig, 'url' | 'method' | 'body'>;
102
+ declare const http: {
103
+ defaults: HttpDefaults;
104
+ get<T = unknown>(url: string, options?: ShortcutOptions): Promise<T>;
105
+ post<T = unknown>(url: string, body?: unknown, options?: ShortcutOptions): Promise<T>;
106
+ put<T = unknown>(url: string, body?: unknown, options?: ShortcutOptions): Promise<T>;
107
+ patch<T = unknown>(url: string, body?: unknown, options?: ShortcutOptions): Promise<T>;
108
+ delete<T = unknown>(url: string, options?: ShortcutOptions): Promise<T>;
109
+ head(url: string, options?: ShortcutOptions): Promise<unknown>;
110
+ /** Full request with status and headers. */
111
+ request: typeof request;
112
+ /** Upload files with real progress using XMLHttpRequest. */
113
+ upload<T = unknown>(url: string, data: FormData, options?: {
114
+ method?: "POST" | "PUT" | "PATCH";
115
+ headers?: Record<string, string>;
116
+ onProgress?: (percent: number, loaded: number, total: number) => void;
117
+ signal?: AbortSignal;
118
+ }): Promise<T>;
119
+ /** Server-Sent Events with automatic reconnection by the browser. */
120
+ sse(url: string, handlers?: {
121
+ message?: (data: unknown, event: MessageEvent) => void;
122
+ error?: (e: Event) => void;
123
+ }): EventSource;
124
+ /** Read a streaming response line by line (NDJSON). */
125
+ stream(url: string, onLine: (line: string) => void, options?: ShortcutOptions): Promise<void>;
126
+ interceptors: {
127
+ request: {
128
+ use(fn: RequestInterceptor): () => void;
129
+ };
130
+ response: {
131
+ use(fn: ResponseInterceptor): () => void;
132
+ };
133
+ error: {
134
+ use(fn: ErrorInterceptor): () => void;
135
+ };
136
+ };
137
+ /** Set headers sent on every request. */
138
+ setHeader(name: string, value: string | null): void;
139
+ /** Shortcut for token-based authentication. */
140
+ setToken(token: string | null, scheme?: string): void;
141
+ setBaseURL(url: string): void;
142
+ clearCache: typeof clearCache;
143
+ flushOfflineQueue: typeof flushOfflineQueue;
144
+ parseDuration: typeof parseDuration;
145
+ };
146
+ type Http = typeof http;
147
+
148
+ export { type ErrorInterceptor, type Http, type HttpDefaults, HttpError, type HttpMethod, type HttpResponse, type RequestConfig, type RequestInterceptor, type ResponseInterceptor, clearCache, flushOfflineQueue, http, request };
package/dist/http.js ADDED
@@ -0,0 +1,7 @@
1
+ export { HttpError, clearCache, flushOfflineQueue, http, request } from './chunk-PQZEVFVZ.js';
2
+ import './chunk-A2UOVQBP.js';
3
+ import './chunk-234ZLC6W.js';
4
+ import './chunk-5777LJVW.js';
5
+ import './chunk-E27NRARW.js';
6
+ //# sourceMappingURL=http.js.map
7
+ //# sourceMappingURL=http.js.map