@karan4/frostjs 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,64 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunk4YG4GVLNcjs = require('./chunk-4YG4GVLN.cjs');
4
+
5
+ // src/network.ts
6
+ function showRequest(value) {
7
+ if (value && typeof value === "object" && "target" in value) {
8
+ const { target, ...options } = value;
9
+ return _chunk4YG4GVLNcjs.show.call(void 0, target, options);
10
+ }
11
+ return _chunk4YG4GVLNcjs.show.call(void 0, value);
12
+ }
13
+ function installFetch(host = globalThis) {
14
+ const original = host.fetch;
15
+ let installed = true;
16
+ const wrapped = function(input, init) {
17
+ if (!installed || !init || !("frost" in init)) return original.call(this, input, init);
18
+ const { frost, ...clean } = init;
19
+ const done = showRequest(frost);
20
+ try {
21
+ return original.call(this, input, clean).finally(done);
22
+ } catch (error) {
23
+ done();
24
+ throw error;
25
+ }
26
+ };
27
+ host.fetch = wrapped;
28
+ return () => {
29
+ installed = false;
30
+ if (host.fetch === wrapped) host.fetch = original;
31
+ };
32
+ }
33
+ function installXHR(XHR = globalThis.XMLHttpRequest) {
34
+ const proto = XHR.prototype;
35
+ const original = proto.send;
36
+ const events = ["load", "error", "abort", "timeout", "loadend"];
37
+ let installed = true;
38
+ const wrapped = function(body) {
39
+ if (!installed || !("frost" in this)) return original.call(this, body);
40
+ const done = showRequest(this.frost);
41
+ const finish = () => {
42
+ for (const type of events) this.removeEventListener(type, finish);
43
+ done();
44
+ };
45
+ for (const type of events) this.addEventListener(type, finish);
46
+ try {
47
+ original.call(this, body);
48
+ } catch (error) {
49
+ finish();
50
+ throw error;
51
+ }
52
+ };
53
+ proto.send = wrapped;
54
+ return () => {
55
+ installed = false;
56
+ if (proto.send === wrapped) proto.send = original;
57
+ };
58
+ }
59
+
60
+
61
+
62
+
63
+
64
+ exports.showRequest = showRequest; exports.installFetch = installFetch; exports.installXHR = installXHR;
@@ -0,0 +1,64 @@
1
+ import {
2
+ show
3
+ } from "./chunk-M4BLR4QM.js";
4
+
5
+ // src/network.ts
6
+ function showRequest(value) {
7
+ if (value && typeof value === "object" && "target" in value) {
8
+ const { target, ...options } = value;
9
+ return show(target, options);
10
+ }
11
+ return show(value);
12
+ }
13
+ function installFetch(host = globalThis) {
14
+ const original = host.fetch;
15
+ let installed = true;
16
+ const wrapped = function(input, init) {
17
+ if (!installed || !init || !("frost" in init)) return original.call(this, input, init);
18
+ const { frost, ...clean } = init;
19
+ const done = showRequest(frost);
20
+ try {
21
+ return original.call(this, input, clean).finally(done);
22
+ } catch (error) {
23
+ done();
24
+ throw error;
25
+ }
26
+ };
27
+ host.fetch = wrapped;
28
+ return () => {
29
+ installed = false;
30
+ if (host.fetch === wrapped) host.fetch = original;
31
+ };
32
+ }
33
+ function installXHR(XHR = globalThis.XMLHttpRequest) {
34
+ const proto = XHR.prototype;
35
+ const original = proto.send;
36
+ const events = ["load", "error", "abort", "timeout", "loadend"];
37
+ let installed = true;
38
+ const wrapped = function(body) {
39
+ if (!installed || !("frost" in this)) return original.call(this, body);
40
+ const done = showRequest(this.frost);
41
+ const finish = () => {
42
+ for (const type of events) this.removeEventListener(type, finish);
43
+ done();
44
+ };
45
+ for (const type of events) this.addEventListener(type, finish);
46
+ try {
47
+ original.call(this, body);
48
+ } catch (error) {
49
+ finish();
50
+ throw error;
51
+ }
52
+ };
53
+ proto.send = wrapped;
54
+ return () => {
55
+ installed = false;
56
+ if (proto.send === wrapped) proto.send = original;
57
+ };
58
+ }
59
+
60
+ export {
61
+ showRequest,
62
+ installFetch,
63
+ installXHR
64
+ };
@@ -0,0 +1,273 @@
1
+ // src/target.ts
2
+ function resolveTarget(target) {
3
+ if (typeof document === "undefined") return;
4
+ if (target === document || target === "body") {
5
+ return document.body ?? void 0;
6
+ }
7
+ const seen = /* @__PURE__ */ new Set();
8
+ while (target != null) {
9
+ if (typeof target === "string") {
10
+ try {
11
+ if (target.startsWith("xpath:")) {
12
+ target = document.evaluate(target.slice(6), document, null, 9, null).singleNodeValue;
13
+ } else {
14
+ target = document.querySelector(target);
15
+ }
16
+ } catch {
17
+ return;
18
+ }
19
+ continue;
20
+ }
21
+ if (typeof target !== "object" || seen.has(target)) return;
22
+ if ("nodeType" in target) {
23
+ if (target.nodeType === 9) return target.body ?? void 0;
24
+ const el = target;
25
+ const HTML = el.ownerDocument?.defaultView?.HTMLElement;
26
+ if (HTML && el instanceof HTML) return el;
27
+ return;
28
+ }
29
+ seen.add(target);
30
+ if ("nativeElement" in target) target = target.nativeElement;
31
+ else if ("current" in target) target = target.current;
32
+ else if ("$el" in target) target = target.$el;
33
+ else if ("value" in target) target = target.value;
34
+ else return;
35
+ }
36
+ }
37
+
38
+ // src/style.css?inline
39
+ var style_default = '.frost {\n --frost-unit: 2.25rem;\n --frost-solid: #f5f7ff;\n --frost-tint: rgb(245 247 255 / 65%);\n position: absolute;\n inset: 0;\n border-radius: inherit;\n z-index: var(--frost-z-index, 1000);\n display: flex;\n align-items: center;\n justify-content: center;\n flex-direction: column;\n gap: 0.75rem;\n background: var(--frost-backdrop, var(--frost-solid));\n color: var(--frost-color, #3431a6);\n font: 600 0.875rem/1.4 system-ui, sans-serif;\n cursor: progress;\n}\n.frost--page { position: fixed; touch-action: none; }\n.frost--small { --frost-unit: 1.5rem; }\n.frost--large { --frost-unit: 3.25rem; }\n.frost__indicator {\n box-sizing: border-box;\n display: block;\n width: var(--frost-unit);\n height: var(--frost-unit);\n}\n.frost__indicator--spinner {\n border: 0.2rem solid;\n border-right-color: transparent;\n border-radius: 50%;\n animation: frost-spin 0.8s linear infinite;\n}\n.frost__indicator--dots {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: calc(var(--frost-unit) / 6);\n}\n.frost__indicator--dots > span {\n flex: 0 0 25%;\n aspect-ratio: 1;\n border-radius: 50%;\n background: currentColor;\n animation: frost-pulse 0.9s ease-in-out infinite alternate;\n}\n.frost__indicator--dots > span:nth-child(2) { animation-delay: 0.15s; }\n.frost__indicator--dots > span:nth-child(3) { animation-delay: 0.3s; }\n.frost__indicator--bar {\n width: calc(var(--frost-unit) * 2.5);\n height: 0.35rem;\n overflow: hidden;\n border-radius: 1rem;\n background: color-mix(in srgb, currentColor 18%, transparent);\n}\n.frost__indicator--bar::before {\n content: "";\n display: block;\n height: 100%;\n width: 45%;\n border-radius: inherit;\n background: currentColor;\n animation: frost-slide 0.95s ease-in-out infinite alternate;\n}\n.frost__indicator--pulse {\n border-radius: 50%;\n background: currentColor;\n animation: frost-pulse 0.85s ease-in-out infinite alternate;\n}\n.frost__indicator--material-circular {\n animation: frost-spin 1.5s linear infinite;\n}\n.frost__indicator--material-circular > svg {\n display: block;\n width: 100%;\n height: 100%;\n}\n.frost__indicator--material-circular circle {\n fill: none;\n stroke: currentColor;\n stroke-width: 4;\n stroke-linecap: round;\n stroke-dasharray: 28 72;\n animation: frost-arc 1.5s ease-in-out infinite;\n}\n.frost__indicator--material-linear {\n position: absolute;\n inset: 0 0 auto;\n width: auto;\n height: calc(var(--frost-unit) / 8);\n overflow: hidden;\n background: color-mix(in srgb, currentColor 18%, transparent);\n}\n.frost__indicator--material-linear::before,\n.frost__indicator--material-linear::after {\n content: "";\n position: absolute;\n inset-block: 0;\n left: 0;\n width: 42%;\n border-radius: 999px;\n background: currentColor;\n animation: frost-sweep 1.9s cubic-bezier(0.4, 0, 0.2, 1) infinite;\n}\n.frost__indicator--material-linear::after {\n width: 24%;\n animation-delay: 0.65s;\n}\n.frost__indicator--skeleton {\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n width: min(75%, calc(var(--frost-unit) * 4));\n}\n.frost__indicator--skeleton > span {\n position: relative;\n height: 22%;\n overflow: hidden;\n border-radius: 999px;\n background: color-mix(in srgb, currentColor 16%, transparent);\n}\n.frost__indicator--skeleton > span:last-child { width: 62%; }\n.frost__indicator--skeleton > span::after {\n content: "";\n position: absolute;\n inset: 0;\n background: linear-gradient(90deg, transparent, color-mix(in srgb, currentColor 22%, transparent), transparent);\n animation: frost-shimmer 1.45s ease-in-out infinite;\n}\n@keyframes frost-spin { to { transform: rotate(1turn); } }\n@keyframes frost-pulse { from { opacity: 0.4; transform: scale(0.65); } }\n@keyframes frost-slide { to { transform: translateX(122%); } }\n@keyframes frost-arc {\n from { stroke-dasharray: 5 95; stroke-dashoffset: 0; }\n 50% { stroke-dasharray: 72 28; stroke-dashoffset: -18; }\n to { stroke-dasharray: 5 95; stroke-dashoffset: -100; }\n}\n@keyframes frost-sweep {\n from { left: 0; transform: translateX(-100%) scaleX(0.55); }\n 45% { transform: translateX(0) scaleX(1); }\n 85%, to { left: 100%; transform: translateX(0) scaleX(0.55); }\n}\n@keyframes frost-shimmer {\n from { transform: translateX(-100%); }\n to { transform: translateX(100%); }\n}\n@supports (color: light-dark(#000, #fff)) {\n .frost {\n --frost-solid: light-dark(#f5f7ff, #151627);\n --frost-tint: light-dark(rgb(245 247 255 / 65%), rgb(21 22 39 / 66%));\n color: var(--frost-color, light-dark(#3431a6, #c5c3ff));\n }\n}\n@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {\n .frost {\n background: var(--frost-backdrop, var(--frost-tint));\n -webkit-backdrop-filter: blur(var(--frost-blur, 8px));\n backdrop-filter: blur(var(--frost-blur, 8px));\n }\n}\n@media (prefers-reduced-motion: reduce) {\n .frost__indicator,\n .frost__indicator > span,\n .frost__indicator::before,\n .frost__indicator::after,\n .frost__indicator--material-circular circle { animation: none; }\n .frost__indicator--material-linear::before { left: 29%; }\n .frost__indicator--material-linear::after,\n .frost__indicator--skeleton > span::after { display: none; }\n}\n';
40
+
41
+ // src/core.ts
42
+ var active = /* @__PURE__ */ new WeakMap();
43
+ var styles = /* @__PURE__ */ new WeakSet();
44
+ var defaults = {};
45
+ var noop = () => {
46
+ };
47
+ function configure(options) {
48
+ defaults = { ...defaults, ...options };
49
+ }
50
+ function visible(el) {
51
+ const view = el.ownerDocument.defaultView;
52
+ let { left, top, right, bottom } = el.getBoundingClientRect();
53
+ left = Math.max(0, left);
54
+ top = Math.max(0, top);
55
+ right = Math.min(view.innerWidth, right);
56
+ bottom = Math.min(view.innerHeight, bottom);
57
+ for (let parent = el.parentElement; parent; parent = parent.parentElement) {
58
+ const style = view.getComputedStyle(parent);
59
+ const rect = parent.getBoundingClientRect();
60
+ if (/auto|scroll|hidden|clip/.test(style.overflowX || style.overflow)) {
61
+ left = Math.max(left, rect.left);
62
+ right = Math.min(right, rect.right);
63
+ }
64
+ if (/auto|scroll|hidden|clip/.test(style.overflowY || style.overflow)) {
65
+ top = Math.max(top, rect.top);
66
+ bottom = Math.min(bottom, rect.bottom);
67
+ }
68
+ }
69
+ return right > left && bottom > top;
70
+ }
71
+ function createIndicator(doc, theme) {
72
+ const indicator = doc.createElement("span");
73
+ indicator.className = "frost__indicator frost__indicator--" + theme;
74
+ indicator.setAttribute("aria-hidden", "true");
75
+ if (theme === "material-circular") {
76
+ const svgNamespace = "http://www.w3.org/2000/svg";
77
+ const svg = doc.createElementNS(svgNamespace, "svg");
78
+ svg.setAttribute("viewBox", "0 0 48 48");
79
+ const arc = doc.createElementNS(svgNamespace, "circle");
80
+ arc.setAttribute("cx", "24");
81
+ arc.setAttribute("cy", "24");
82
+ arc.setAttribute("r", "20");
83
+ arc.setAttribute("pathLength", "100");
84
+ svg.append(arc);
85
+ indicator.append(svg);
86
+ } else if (theme === "dots" || theme === "skeleton") {
87
+ for (let i = 0; i < 3; i++) indicator.append(doc.createElement("span"));
88
+ }
89
+ return indicator;
90
+ }
91
+ function mount(el, options) {
92
+ const doc = el.ownerDocument;
93
+ const fullPage = el === doc.body || el === doc.documentElement;
94
+ const overlay = doc.createElement("div");
95
+ overlay.className = [
96
+ "frost",
97
+ fullPage && "frost--page",
98
+ "frost--" + (options.size ?? "medium"),
99
+ options.className
100
+ ].filter(Boolean).join(" ");
101
+ overlay.setAttribute("role", "status");
102
+ overlay.setAttribute("aria-label", options.label ?? (options.text || "Loading"));
103
+ const custom = options.render?.(el);
104
+ if (typeof custom === "string") overlay.innerHTML = custom;
105
+ else if (custom) overlay.append(custom);
106
+ else {
107
+ overlay.append(createIndicator(doc, options.theme ?? "material-circular"));
108
+ if (options.text) {
109
+ const text = doc.createElement("span");
110
+ text.textContent = options.text;
111
+ overlay.append(text);
112
+ }
113
+ }
114
+ const root = el.getRootNode();
115
+ const styleHost = "host" in root ? root : doc.head;
116
+ if (options.injectStyles !== false && !styles.has(styleHost)) {
117
+ const style = doc.createElement("style");
118
+ if (options.nonce !== void 0) style.nonce = options.nonce;
119
+ style.textContent = style_default;
120
+ styleHost.append(style);
121
+ styles.add(styleHost);
122
+ }
123
+ const restore = [];
124
+ const hadStyle = el.hasAttribute("style");
125
+ function setStyle(name, value) {
126
+ const old = el.style.getPropertyValue(name);
127
+ const priority = el.style.getPropertyPriority(name);
128
+ restore.unshift(() => {
129
+ if (old) el.style.setProperty(name, old, priority);
130
+ else el.style.removeProperty(name);
131
+ });
132
+ el.style.setProperty(name, value);
133
+ }
134
+ if (!fullPage) {
135
+ const position = doc.defaultView?.getComputedStyle(el).position;
136
+ if (!position || position === "static") setStyle("position", "relative");
137
+ if (options.minHeight !== void 0) {
138
+ const value = options.minHeight;
139
+ setStyle("min-height", typeof value === "number" ? value + "px" : value);
140
+ }
141
+ }
142
+ const focused = root.activeElement;
143
+ const busy = el.getAttribute("aria-busy");
144
+ el.setAttribute("aria-busy", "true");
145
+ const inert = /* @__PURE__ */ new Map();
146
+ const block = (child) => {
147
+ if (child === overlay || inert.has(child)) return;
148
+ inert.set(child, child.getAttribute("inert"));
149
+ child.setAttribute("inert", "");
150
+ };
151
+ for (const child of el.children) block(child);
152
+ const observer = new doc.defaultView.MutationObserver((records) => {
153
+ for (const record of records) {
154
+ for (const node of record.removedNodes) {
155
+ const child = node;
156
+ if (child.parentNode !== el && inert.has(child)) restoreInert(child);
157
+ }
158
+ for (const node of record.addedNodes) {
159
+ if (node.nodeType === 1 && node.parentNode === el) block(node);
160
+ }
161
+ }
162
+ });
163
+ function restoreInert(child) {
164
+ const original = inert.get(child);
165
+ if (original == null) child.removeAttribute("inert");
166
+ else child.setAttribute("inert", original);
167
+ inert.delete(child);
168
+ }
169
+ observer.observe(el, { childList: true });
170
+ el.append(overlay);
171
+ const place = () => {
172
+ const { scrollTop: top, scrollLeft: left } = el;
173
+ overlay.style.inset = top || left ? `${top}px ${-left}px ${-top}px ${left}px` : "";
174
+ };
175
+ if (!fullPage) {
176
+ place();
177
+ el.addEventListener("scroll", place, { passive: true });
178
+ if (options.minHeight === void 0 && overlay.firstElementChild) {
179
+ const first = overlay.firstElementChild.getBoundingClientRect();
180
+ const last = overlay.lastElementChild.getBoundingClientRect();
181
+ const needed = Math.ceil(last.bottom - first.top) + 16;
182
+ if (needed > 16 && needed > el.clientHeight) setStyle("min-height", needed + "px");
183
+ }
184
+ }
185
+ if (!fullPage && options.scrollIntoView && !visible(el)) {
186
+ el.scrollIntoView?.({ block: "nearest", inline: "nearest" });
187
+ }
188
+ return () => {
189
+ observer.disconnect();
190
+ el.removeEventListener("scroll", place);
191
+ overlay.remove();
192
+ for (const child of inert.keys()) restoreInert(child);
193
+ if (busy === null) el.removeAttribute("aria-busy");
194
+ else el.setAttribute("aria-busy", busy);
195
+ for (const fn of restore) fn();
196
+ if (!hadStyle && !el.style.length) el.removeAttribute("style");
197
+ const current = root.activeElement;
198
+ if (focused instanceof doc.defaultView.HTMLElement && focused !== el && el.contains(focused) && (!current || current === doc.body)) {
199
+ focused.focus({ preventScroll: true });
200
+ }
201
+ };
202
+ }
203
+ function clearElement(el, state) {
204
+ if (active.get(el) !== state) return;
205
+ active.delete(el);
206
+ clearTimeout(state.delay);
207
+ clearTimeout(state.removal);
208
+ for (const ticket of state.tickets) clearTimeout(ticket.timer);
209
+ state.cleanup?.();
210
+ }
211
+ function release(el, state, ticket) {
212
+ if (active.get(el) !== state || !state.tickets.delete(ticket)) return;
213
+ clearTimeout(ticket.timer);
214
+ if (state.tickets.size) return;
215
+ const remaining = state.shownAt === void 0 ? 0 : (state.options.minDuration ?? 0) - (Date.now() - state.shownAt);
216
+ if (remaining > 0) state.removal = setTimeout(() => clearElement(el, state), remaining);
217
+ else clearElement(el, state);
218
+ }
219
+ function show(target, options) {
220
+ const el = resolveTarget(target);
221
+ if (!el) return noop;
222
+ const opts = { ...defaults, ...options };
223
+ let state = active.get(el);
224
+ const first = !state;
225
+ state ??= { tickets: /* @__PURE__ */ new Set(), options: opts };
226
+ active.set(el, state);
227
+ clearTimeout(state.removal);
228
+ const ticket = {};
229
+ state.tickets.add(ticket);
230
+ const entry = state;
231
+ const done = () => release(el, entry, ticket);
232
+ if (opts.timeout && opts.timeout > 0) ticket.timer = setTimeout(done, opts.timeout);
233
+ if (first) {
234
+ const start = () => {
235
+ if (active.get(el) !== entry) return;
236
+ try {
237
+ entry.cleanup = mount(el, opts);
238
+ } catch (error) {
239
+ clearElement(el, entry);
240
+ throw error;
241
+ }
242
+ entry.shownAt = Date.now();
243
+ };
244
+ if (opts.delay && opts.delay > 0) entry.delay = setTimeout(start, opts.delay);
245
+ else start();
246
+ }
247
+ return done;
248
+ }
249
+ function hide(target) {
250
+ const el = resolveTarget(target);
251
+ const state = el && active.get(el);
252
+ const ticket = state?.tickets.values().next().value;
253
+ if (el && state && ticket) release(el, state, ticket);
254
+ }
255
+ function clear(target) {
256
+ const el = resolveTarget(target);
257
+ const state = el && active.get(el);
258
+ if (el && state) clearElement(el, state);
259
+ }
260
+ function mask(target, promise, options) {
261
+ const done = show(target, options);
262
+ void promise.then(done, done);
263
+ return promise;
264
+ }
265
+
266
+ export {
267
+ resolveTarget,
268
+ configure,
269
+ show,
270
+ hide,
271
+ clear,
272
+ mask
273
+ };
@@ -0,0 +1,36 @@
1
+ type Target = HTMLElement | Document | string | null | undefined | {
2
+ readonly nativeElement: Target;
3
+ } | {
4
+ readonly current: Target;
5
+ } | {
6
+ readonly value: Target;
7
+ } | {
8
+ readonly $el: Target;
9
+ };
10
+ declare function resolveTarget(target: Target): HTMLElement | undefined;
11
+
12
+ type Theme = 'material-circular' | 'material-linear' | 'skeleton' | 'spinner' | 'dots' | 'bar' | 'pulse';
13
+ type Size = 'small' | 'medium' | 'large';
14
+ interface Options {
15
+ delay?: number;
16
+ minDuration?: number;
17
+ scrollIntoView?: boolean;
18
+ text?: string;
19
+ label?: string;
20
+ size?: Size;
21
+ minHeight?: number | string;
22
+ theme?: Theme;
23
+ render?: (target: HTMLElement) => HTMLElement | string;
24
+ className?: string;
25
+ timeout?: number;
26
+ nonce?: string;
27
+ injectStyles?: boolean;
28
+ }
29
+ declare function configure(options: Options): void;
30
+ declare function show(target: Target, options?: Options): () => void;
31
+ declare function hide(target: Target): void;
32
+ declare function clear(target: Target): void;
33
+ declare function mask<P extends PromiseLike<unknown>>(target: Target, promise: P, options?: Options): P;
34
+
35
+ export { configure as b, clear as c, hide as h, mask as m, resolveTarget as r, show as s };
36
+ export type { Options as O, Size as S, Target as T, Theme as a };
@@ -0,0 +1,36 @@
1
+ type Target = HTMLElement | Document | string | null | undefined | {
2
+ readonly nativeElement: Target;
3
+ } | {
4
+ readonly current: Target;
5
+ } | {
6
+ readonly value: Target;
7
+ } | {
8
+ readonly $el: Target;
9
+ };
10
+ declare function resolveTarget(target: Target): HTMLElement | undefined;
11
+
12
+ type Theme = 'material-circular' | 'material-linear' | 'skeleton' | 'spinner' | 'dots' | 'bar' | 'pulse';
13
+ type Size = 'small' | 'medium' | 'large';
14
+ interface Options {
15
+ delay?: number;
16
+ minDuration?: number;
17
+ scrollIntoView?: boolean;
18
+ text?: string;
19
+ label?: string;
20
+ size?: Size;
21
+ minHeight?: number | string;
22
+ theme?: Theme;
23
+ render?: (target: HTMLElement) => HTMLElement | string;
24
+ className?: string;
25
+ timeout?: number;
26
+ nonce?: string;
27
+ injectStyles?: boolean;
28
+ }
29
+ declare function configure(options: Options): void;
30
+ declare function show(target: Target, options?: Options): () => void;
31
+ declare function hide(target: Target): void;
32
+ declare function clear(target: Target): void;
33
+ declare function mask<P extends PromiseLike<unknown>>(target: Target, promise: P, options?: Options): P;
34
+
35
+ export { configure as b, clear as c, hide as h, mask as m, resolveTarget as r, show as s };
36
+ export type { Options as O, Size as S, Target as T, Theme as a };
package/dist/index.cjs ADDED
@@ -0,0 +1,47 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+ var _chunkBQNHIAZGcjs = require('./chunk-BQNHIAZG.cjs');
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+ var _chunk4YG4GVLNcjs = require('./chunk-4YG4GVLN.cjs');
14
+
15
+ // src/axios.ts
16
+ function installAxios(client, getAdapter) {
17
+ const request = client.interceptors.request.use((config) => {
18
+ if (!("frost" in config)) return config;
19
+ const metadata = config;
20
+ const target = metadata.frost;
21
+ delete metadata.frost;
22
+ const selected = config.adapter;
23
+ config.adapter = (dispatchConfig) => {
24
+ const adapter = getAdapter(selected, dispatchConfig);
25
+ const done = _chunkBQNHIAZGcjs.showRequest.call(void 0, target);
26
+ try {
27
+ return Promise.resolve(adapter(dispatchConfig)).finally(done);
28
+ } catch (error) {
29
+ done();
30
+ throw error;
31
+ }
32
+ };
33
+ return config;
34
+ });
35
+ return () => client.interceptors.request.eject(request);
36
+ }
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+ exports.clear = _chunk4YG4GVLNcjs.clear; exports.configure = _chunk4YG4GVLNcjs.configure; exports.hide = _chunk4YG4GVLNcjs.hide; exports.installAxios = installAxios; exports.installFetch = _chunkBQNHIAZGcjs.installFetch; exports.installXHR = _chunkBQNHIAZGcjs.installXHR; exports.mask = _chunk4YG4GVLNcjs.mask; exports.resolveTarget = _chunk4YG4GVLNcjs.resolveTarget; exports.show = _chunk4YG4GVLNcjs.show;
@@ -0,0 +1,16 @@
1
+ export { O as Options, S as Size, T as Target, a as Theme, c as clear, b as configure, h as hide, m as mask, r as resolveTarget, s as show } from './core-BfyKRh3F.cjs';
2
+ export { R as RequestMask, i as installFetch, a as installXHR } from './network-Dgm73vcC.cjs';
3
+
4
+ type Interceptors<T> = {
5
+ use(fulfilled: (value: T) => T): number;
6
+ eject(id: number): void;
7
+ };
8
+ declare function installAxios<C extends {
9
+ adapter?: unknown;
10
+ }>(client: {
11
+ interceptors: {
12
+ request: Interceptors<C>;
13
+ };
14
+ }, getAdapter: (adapter: C['adapter'], config: C) => (config: C) => PromiseLike<unknown>): () => void;
15
+
16
+ export { installAxios };
@@ -0,0 +1,16 @@
1
+ export { O as Options, S as Size, T as Target, a as Theme, c as clear, b as configure, h as hide, m as mask, r as resolveTarget, s as show } from './core-BfyKRh3F.js';
2
+ export { R as RequestMask, i as installFetch, a as installXHR } from './network-Bm_3Ah3R.js';
3
+
4
+ type Interceptors<T> = {
5
+ use(fulfilled: (value: T) => T): number;
6
+ eject(id: number): void;
7
+ };
8
+ declare function installAxios<C extends {
9
+ adapter?: unknown;
10
+ }>(client: {
11
+ interceptors: {
12
+ request: Interceptors<C>;
13
+ };
14
+ }, getAdapter: (adapter: C['adapter'], config: C) => (config: C) => PromiseLike<unknown>): () => void;
15
+
16
+ export { installAxios };
package/dist/index.js ADDED
@@ -0,0 +1,47 @@
1
+ import {
2
+ installFetch,
3
+ installXHR,
4
+ showRequest
5
+ } from "./chunk-LUZ2RD2S.js";
6
+ import {
7
+ clear,
8
+ configure,
9
+ hide,
10
+ mask,
11
+ resolveTarget,
12
+ show
13
+ } from "./chunk-M4BLR4QM.js";
14
+
15
+ // src/axios.ts
16
+ function installAxios(client, getAdapter) {
17
+ const request = client.interceptors.request.use((config) => {
18
+ if (!("frost" in config)) return config;
19
+ const metadata = config;
20
+ const target = metadata.frost;
21
+ delete metadata.frost;
22
+ const selected = config.adapter;
23
+ config.adapter = (dispatchConfig) => {
24
+ const adapter = getAdapter(selected, dispatchConfig);
25
+ const done = showRequest(target);
26
+ try {
27
+ return Promise.resolve(adapter(dispatchConfig)).finally(done);
28
+ } catch (error) {
29
+ done();
30
+ throw error;
31
+ }
32
+ };
33
+ return config;
34
+ });
35
+ return () => client.interceptors.request.eject(request);
36
+ }
37
+ export {
38
+ clear,
39
+ configure,
40
+ hide,
41
+ installAxios,
42
+ installFetch,
43
+ installXHR,
44
+ mask,
45
+ resolveTarget,
46
+ show
47
+ };
@@ -0,0 +1,18 @@
1
+ import { T as Target, O as Options } from './core-BfyKRh3F.js';
2
+
3
+ type RequestMask = Target | (Options & {
4
+ target: Target;
5
+ });
6
+ declare global {
7
+ interface RequestInit {
8
+ frost?: RequestMask;
9
+ }
10
+ interface XMLHttpRequest {
11
+ frost?: RequestMask;
12
+ }
13
+ }
14
+ declare function installFetch(host?: Pick<typeof globalThis, 'fetch'>): () => void;
15
+ declare function installXHR(XHR?: typeof XMLHttpRequest): () => void;
16
+
17
+ export { installXHR as a, installFetch as i };
18
+ export type { RequestMask as R };
@@ -0,0 +1,18 @@
1
+ import { T as Target, O as Options } from './core-BfyKRh3F.cjs';
2
+
3
+ type RequestMask = Target | (Options & {
4
+ target: Target;
5
+ });
6
+ declare global {
7
+ interface RequestInit {
8
+ frost?: RequestMask;
9
+ }
10
+ interface XMLHttpRequest {
11
+ frost?: RequestMask;
12
+ }
13
+ }
14
+ declare function installFetch(host?: Pick<typeof globalThis, 'fetch'>): () => void;
15
+ declare function installXHR(XHR?: typeof XMLHttpRequest): () => void;
16
+
17
+ export { installXHR as a, installFetch as i };
18
+ export type { RequestMask as R };
package/dist/react.cjs ADDED
@@ -0,0 +1,22 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunk4YG4GVLNcjs = require('./chunk-4YG4GVLN.cjs');
4
+
5
+ // src/react.ts
6
+ var _react = require('react');
7
+ function useFrost(target, loading, options) {
8
+ const latest = _react.useRef.call(void 0, options);
9
+ latest.current = options;
10
+ _react.useEffect.call(void 0, () => {
11
+ if (loading) return _chunk4YG4GVLNcjs.show.call(void 0, target, latest.current);
12
+ }, [target, loading]);
13
+ }
14
+ function Frost({ loading, options, ...props }) {
15
+ const ref = _react.useRef.call(void 0, null);
16
+ useFrost(ref, loading, options);
17
+ return _react.createElement.call(void 0, "div", { ...props, ref });
18
+ }
19
+
20
+
21
+
22
+ exports.Frost = Frost; exports.useFrost = useFrost;