@hairy/react-lib 1.24.0 → 1.26.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.cjs +95 -49
- package/dist/index.d.ts +46 -6
- package/dist/index.global.js +537 -445
- package/dist/index.js +84 -39
- package/package.json +2 -2
package/dist/index.global.js
CHANGED
|
@@ -39,37 +39,6 @@ var LibReact = (() => {
|
|
|
39
39
|
}
|
|
40
40
|
});
|
|
41
41
|
|
|
42
|
-
// ../../node_modules/.pnpm/void-elements@3.1.0/node_modules/void-elements/index.js
|
|
43
|
-
var require_void_elements = __commonJS({
|
|
44
|
-
"../../node_modules/.pnpm/void-elements@3.1.0/node_modules/void-elements/index.js"(exports, module) {
|
|
45
|
-
"use strict";
|
|
46
|
-
module.exports = {
|
|
47
|
-
"area": true,
|
|
48
|
-
"base": true,
|
|
49
|
-
"br": true,
|
|
50
|
-
"col": true,
|
|
51
|
-
"embed": true,
|
|
52
|
-
"hr": true,
|
|
53
|
-
"img": true,
|
|
54
|
-
"input": true,
|
|
55
|
-
"link": true,
|
|
56
|
-
"meta": true,
|
|
57
|
-
"param": true,
|
|
58
|
-
"source": true,
|
|
59
|
-
"track": true,
|
|
60
|
-
"wbr": true
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
// globals:react-i18next
|
|
66
|
-
var require_react_i18next = __commonJS({
|
|
67
|
-
"globals:react-i18next"(exports, module) {
|
|
68
|
-
"use strict";
|
|
69
|
-
module.exports = reactI18next;
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
|
|
73
42
|
// src/index.ts
|
|
74
43
|
var index_exports = {};
|
|
75
44
|
__export(index_exports, {
|
|
@@ -80,13 +49,14 @@ var LibReact = (() => {
|
|
|
80
49
|
Injector: () => Injector,
|
|
81
50
|
Switch: () => Switch,
|
|
82
51
|
Then: () => Then,
|
|
83
|
-
|
|
52
|
+
Trigger: () => Trigger,
|
|
84
53
|
Unless: () => Unless,
|
|
85
54
|
cls: () => cls,
|
|
86
55
|
defineAsyncStore: () => defineAsyncStore,
|
|
87
56
|
defineStore: () => defineStore,
|
|
88
57
|
proxyWithPersistant: () => proxyWithPersistant,
|
|
89
|
-
ref: () =>
|
|
58
|
+
ref: () => ref2,
|
|
59
|
+
track: () => track,
|
|
90
60
|
useAsyncCallback: () => useAsyncCallback,
|
|
91
61
|
useAsyncState: () => useAsyncState,
|
|
92
62
|
useDebounce: () => useDebounce,
|
|
@@ -105,8 +75,8 @@ var LibReact = (() => {
|
|
|
105
75
|
var hasOwn = {}.hasOwnProperty;
|
|
106
76
|
function cls(...args) {
|
|
107
77
|
let classes = "";
|
|
108
|
-
for (let
|
|
109
|
-
const arg = args[
|
|
78
|
+
for (let i = 0; i < args.length; i++) {
|
|
79
|
+
const arg = args[i];
|
|
110
80
|
if (arg)
|
|
111
81
|
classes = cls.append(classes, cls.parse(arg));
|
|
112
82
|
}
|
|
@@ -134,360 +104,41 @@ var LibReact = (() => {
|
|
|
134
104
|
return value ? `${value} ${newClass}` : newClass;
|
|
135
105
|
};
|
|
136
106
|
|
|
137
|
-
// src/
|
|
138
|
-
var
|
|
139
|
-
|
|
140
|
-
return tag ? (0, import_react.createElement)(tag, props, children) : children;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// src/components/condition/Case.ts
|
|
144
|
-
function Case(props) {
|
|
145
|
-
const { cond, children, tag, ...attrs } = props;
|
|
146
|
-
return wrapper(tag, attrs, children);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// src/components/condition/Default.ts
|
|
150
|
-
function Default(props) {
|
|
151
|
-
const { children, tag, ...attrs } = props;
|
|
152
|
-
return wrapper(tag, attrs, children);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// src/components/condition/If.ts
|
|
156
|
-
var import_react2 = __toESM(require_react(), 1);
|
|
157
|
-
|
|
158
|
-
// src/components/condition/Then.ts
|
|
159
|
-
function Then(props) {
|
|
160
|
-
const { children, cond, else: _else, then, tag, ...attrs } = props;
|
|
161
|
-
return Object.keys(props).includes("cond") ? wrapper(If, props, children) : wrapper(tag, attrs, children);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
// src/components/condition/If.ts
|
|
165
|
-
function If(props) {
|
|
166
|
-
const { then, cond, else: _else, children = props.then, tag, ...attrs } = props;
|
|
167
|
-
const elements = import_react2.Children.toArray(children);
|
|
168
|
-
const thenChild = elements.find((c2) => c2.type === Then);
|
|
169
|
-
const elseChild = elements.find((c2) => c2.type === Else);
|
|
170
|
-
const child = thenChild || elseChild ? cond ? thenChild : elseChild : cond ? children : _else;
|
|
171
|
-
return wrapper(tag, attrs, child);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
// src/components/condition/Else.ts
|
|
175
|
-
function Else(props) {
|
|
176
|
-
const { children, tag, ...attrs } = props;
|
|
177
|
-
return Object.keys(props).includes("cond") ? wrapper(If, props, children) : wrapper(tag, attrs, children);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
// src/components/condition/Switch.ts
|
|
181
|
-
var import_react3 = __toESM(require_react(), 1);
|
|
182
|
-
function Switch(props) {
|
|
183
|
-
const isUseValue = props.value !== void 0;
|
|
184
|
-
let matchingCase;
|
|
185
|
-
let defaultCase;
|
|
186
|
-
import_react3.Children.forEach(props.children, (child) => {
|
|
187
|
-
if (!(0, import_react3.isValidElement)(child) || matchingCase)
|
|
188
|
-
return;
|
|
189
|
-
if (child.type === Case) {
|
|
190
|
-
const cond = child.props.cond;
|
|
191
|
-
if (isUseValue ? props.value === cond : cond) {
|
|
192
|
-
matchingCase = child;
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
if (!defaultCase && child.type === Default)
|
|
197
|
-
defaultCase = child;
|
|
198
|
-
});
|
|
199
|
-
return matchingCase ?? defaultCase ?? null;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
// src/components/condition/Unless.ts
|
|
203
|
-
var import_react4 = __toESM(require_react(), 1);
|
|
204
|
-
function Unless(props) {
|
|
205
|
-
const { cond, then, else: _else, tag, children = props.then, ...attrs } = props;
|
|
206
|
-
const elements = import_react4.Children.toArray(children);
|
|
207
|
-
const thenChild = elements.find((c2) => c2.type === Then);
|
|
208
|
-
const elseChild = elements.find((c2) => c2.type === Else);
|
|
209
|
-
const child = thenChild || elseChild ? !cond ? elseChild : thenChild : !cond ? children : _else;
|
|
210
|
-
return wrapper(tag, attrs, child);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
// src/components/utils/Injector.ts
|
|
214
|
-
var import_react5 = __toESM(require_react(), 1);
|
|
215
|
-
function Injector(props) {
|
|
216
|
-
const installs = (0, import_react5.useMemo)(
|
|
217
|
-
() => props.install.map(repack).reverse(),
|
|
218
|
-
[props.install]
|
|
219
|
-
);
|
|
220
|
-
return installs.reduce(
|
|
221
|
-
(child, { component: Component, props: props2 }) => (0, import_react5.createElement)(Component, props2, child),
|
|
222
|
-
props.children
|
|
223
|
-
);
|
|
224
|
-
}
|
|
225
|
-
function repack(c2) {
|
|
226
|
-
return c2.component ? c2 : { component: c2 };
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
// ../../node_modules/.pnpm/html-parse-stringify@3.0.1/node_modules/html-parse-stringify/dist/html-parse-stringify.module.js
|
|
230
|
-
var import_void_elements = __toESM(require_void_elements());
|
|
231
|
-
var t = /\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;
|
|
232
|
-
function n(n2) {
|
|
233
|
-
var r2 = { type: "tag", name: "", voidElement: false, attrs: {}, children: [] }, i2 = n2.match(/<\/?([^\s]+?)[/\s>]/);
|
|
234
|
-
if (i2 && (r2.name = i2[1], (import_void_elements.default[i2[1]] || "/" === n2.charAt(n2.length - 2)) && (r2.voidElement = true), r2.name.startsWith("!--"))) {
|
|
235
|
-
var s2 = n2.indexOf("-->");
|
|
236
|
-
return { type: "comment", comment: -1 !== s2 ? n2.slice(4, s2) : "" };
|
|
237
|
-
}
|
|
238
|
-
for (var a2 = new RegExp(t), c2 = null; null !== (c2 = a2.exec(n2)); ) if (c2[0].trim()) if (c2[1]) {
|
|
239
|
-
var o = c2[1].trim(), l = [o, ""];
|
|
240
|
-
o.indexOf("=") > -1 && (l = o.split("=")), r2.attrs[l[0]] = l[1], a2.lastIndex--;
|
|
241
|
-
} else c2[2] && (r2.attrs[c2[2]] = c2[3].trim().substring(1, c2[3].length - 1));
|
|
242
|
-
return r2;
|
|
243
|
-
}
|
|
244
|
-
var r = /<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g;
|
|
245
|
-
var i = /^\s*$/;
|
|
246
|
-
var s = /* @__PURE__ */ Object.create(null);
|
|
247
|
-
function a(e2, t2) {
|
|
248
|
-
switch (t2.type) {
|
|
249
|
-
case "text":
|
|
250
|
-
return e2 + t2.content;
|
|
251
|
-
case "tag":
|
|
252
|
-
return e2 += "<" + t2.name + (t2.attrs ? function(e3) {
|
|
253
|
-
var t3 = [];
|
|
254
|
-
for (var n2 in e3) t3.push(n2 + '="' + e3[n2] + '"');
|
|
255
|
-
return t3.length ? " " + t3.join(" ") : "";
|
|
256
|
-
}(t2.attrs) : "") + (t2.voidElement ? "/>" : ">"), t2.voidElement ? e2 : e2 + t2.children.reduce(a, "") + "</" + t2.name + ">";
|
|
257
|
-
case "comment":
|
|
258
|
-
return e2 + "<!--" + t2.comment + "-->";
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
var c = { parse: function(e2, t2) {
|
|
262
|
-
t2 || (t2 = {}), t2.components || (t2.components = s);
|
|
263
|
-
var a2, c2 = [], o = [], l = -1, m = false;
|
|
264
|
-
if (0 !== e2.indexOf("<")) {
|
|
265
|
-
var u = e2.indexOf("<");
|
|
266
|
-
c2.push({ type: "text", content: -1 === u ? e2 : e2.substring(0, u) });
|
|
267
|
-
}
|
|
268
|
-
return e2.replace(r, function(r2, s2) {
|
|
269
|
-
if (m) {
|
|
270
|
-
if (r2 !== "</" + a2.name + ">") return;
|
|
271
|
-
m = false;
|
|
272
|
-
}
|
|
273
|
-
var u2, f = "/" !== r2.charAt(1), h = r2.startsWith("<!--"), p = s2 + r2.length, d = e2.charAt(p);
|
|
274
|
-
if (h) {
|
|
275
|
-
var v = n(r2);
|
|
276
|
-
return l < 0 ? (c2.push(v), c2) : ((u2 = o[l]).children.push(v), c2);
|
|
277
|
-
}
|
|
278
|
-
if (f && (l++, "tag" === (a2 = n(r2)).type && t2.components[a2.name] && (a2.type = "component", m = true), a2.voidElement || m || !d || "<" === d || a2.children.push({ type: "text", content: e2.slice(p, e2.indexOf("<", p)) }), 0 === l && c2.push(a2), (u2 = o[l - 1]) && u2.children.push(a2), o[l] = a2), (!f || a2.voidElement) && (l > -1 && (a2.voidElement || a2.name === r2.slice(2, -1)) && (l--, a2 = -1 === l ? c2 : o[l]), !m && "<" !== d && d)) {
|
|
279
|
-
u2 = -1 === l ? c2 : o[l].children;
|
|
280
|
-
var x = e2.indexOf("<", p), g = e2.slice(p, -1 === x ? void 0 : x);
|
|
281
|
-
i.test(g) && (g = " "), (x > -1 && l + u2.length >= 0 || " " !== g) && u2.push({ type: "text", content: g });
|
|
282
|
-
}
|
|
283
|
-
}), c2;
|
|
284
|
-
}, stringify: function(e2) {
|
|
285
|
-
return e2.reduce(function(e3, t2) {
|
|
286
|
-
return e3 + a("", t2);
|
|
287
|
-
}, "");
|
|
288
|
-
} };
|
|
289
|
-
var html_parse_stringify_module_default = c;
|
|
290
|
-
|
|
291
|
-
// src/components/utils/Trans.ts
|
|
292
|
-
var import_react6 = __toESM(require_react(), 1);
|
|
293
|
-
var import_react_i18next = __toESM(require_react_i18next(), 1);
|
|
294
|
-
function Trans({ i18nKey, ...additionalProps }) {
|
|
295
|
-
const translation = (0, import_react_i18next.useTranslation)().t(i18nKey, additionalProps);
|
|
296
|
-
return renderNodes(html_parse_stringify_module_default.parse(translation), additionalProps);
|
|
297
|
-
}
|
|
298
|
-
function renderNodes(tokens, values) {
|
|
299
|
-
let index = 0;
|
|
300
|
-
return tokens.map((token) => {
|
|
301
|
-
if (token.type === "text")
|
|
302
|
-
return token.content;
|
|
303
|
-
index++;
|
|
304
|
-
const props = { ...token.attrs, key: index };
|
|
305
|
-
return token.voidElement ? values[token.name] ? (0, import_react6.createElement)("span", { key: index }, values[token.name]) : (0, import_react6.createElement)(token.name, props) : (0, import_react6.createElement)(token.name, props, renderNodes(token.children, {}));
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
// src/hooks/ref.ts
|
|
310
|
-
var import_react7 = __toESM(require_react(), 1);
|
|
311
|
-
function ref(value) {
|
|
312
|
-
function define(value2) {
|
|
313
|
-
if (typeof value2 === "function")
|
|
314
|
-
return (prev) => define(value2(prev.value));
|
|
315
|
-
return Object.defineProperty({}, "value", {
|
|
316
|
-
set: (action) => set(define(action)),
|
|
317
|
-
get: () => value2,
|
|
318
|
-
enumerable: true
|
|
319
|
-
});
|
|
320
|
-
}
|
|
321
|
-
const [ref2, set] = (0, import_react7.useState)(define(value));
|
|
322
|
-
return ref2;
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
// src/hooks/useAsyncCallback.ts
|
|
326
|
-
var import_react8 = __toESM(require_react(), 1);
|
|
327
|
-
function useAsyncCallback(fun) {
|
|
328
|
-
const [state, set] = (0, import_react8.useState)({ loading: false });
|
|
329
|
-
async function execute(...args) {
|
|
330
|
-
set({ loading: true });
|
|
331
|
-
return fun(...args).then((value) => {
|
|
332
|
-
set({ loading: false });
|
|
333
|
-
return value;
|
|
334
|
-
}).catch((err) => {
|
|
335
|
-
set({ loading: false, error: err });
|
|
336
|
-
return Promise.reject(err);
|
|
337
|
-
});
|
|
338
|
-
}
|
|
339
|
-
return [state.loading, execute, state.error];
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
// src/hooks/useAsyncState.ts
|
|
343
|
-
var import_react9 = __toESM(require_react(), 1);
|
|
344
|
-
function useAsyncState(fun, deps = [], options) {
|
|
345
|
-
const [value, set] = (0, import_react9.useState)(options?.initial);
|
|
346
|
-
const [loading, execute, error] = useAsyncCallback(async (...args) => fun(...args).then(set));
|
|
347
|
-
(0, import_react9.useEffect)(
|
|
348
|
-
() => {
|
|
349
|
-
execute();
|
|
350
|
-
},
|
|
351
|
-
deps
|
|
352
|
-
);
|
|
353
|
-
return [{ value, loading, error }, execute];
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
// src/hooks/useDebounce.ts
|
|
357
|
-
var import_react10 = __toESM(require_react(), 1);
|
|
358
|
-
function useDebounce(value, delay) {
|
|
359
|
-
const [debouncedValue, setDebouncedValue] = (0, import_react10.useState)(value);
|
|
360
|
-
(0, import_react10.useEffect)(() => {
|
|
361
|
-
const handler = setTimeout(() => setDebouncedValue(value), delay);
|
|
362
|
-
return () => clearTimeout(handler);
|
|
363
|
-
}, [value, delay]);
|
|
364
|
-
return debouncedValue;
|
|
365
|
-
}
|
|
107
|
+
// ../util-core/src/util/noop.ts
|
|
108
|
+
var noop = () => {
|
|
109
|
+
};
|
|
366
110
|
|
|
367
|
-
//
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
i2 && i2.slice().map(function(n3) {
|
|
378
|
-
n3(e2);
|
|
379
|
-
}), (i2 = n2.get("*")) && i2.slice().map(function(n3) {
|
|
380
|
-
n3(t2, e2);
|
|
111
|
+
// ../util-core/src/util/deferred.ts
|
|
112
|
+
var Deferred = class extends Promise {
|
|
113
|
+
resolve;
|
|
114
|
+
reject;
|
|
115
|
+
constructor(executor = noop) {
|
|
116
|
+
let _resolve, _reject;
|
|
117
|
+
super((resolve_, reject_) => {
|
|
118
|
+
_resolve = resolve_;
|
|
119
|
+
_reject = reject_;
|
|
120
|
+
return executor(resolve_, reject_);
|
|
381
121
|
});
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
function on(listener) {
|
|
391
|
-
emitter.on(key, listener);
|
|
392
|
-
onRef.current = listener;
|
|
393
|
-
(0, import_react11.useEffect)(() => {
|
|
394
|
-
if (!onRef.current)
|
|
395
|
-
return;
|
|
396
|
-
emitter.off(key, onRef.current);
|
|
397
|
-
emitter.on(key, listener);
|
|
398
|
-
onRef.current = listener;
|
|
399
|
-
return () => emitter.off(key, listener);
|
|
400
|
-
}, [listener]);
|
|
401
|
-
}
|
|
402
|
-
function emit(event) {
|
|
403
|
-
emitter.emit(key, event);
|
|
404
|
-
}
|
|
405
|
-
function off(listener) {
|
|
406
|
-
emitter.off(key, listener);
|
|
122
|
+
this.resolve = (value) => {
|
|
123
|
+
_resolve(value);
|
|
124
|
+
return this;
|
|
125
|
+
};
|
|
126
|
+
this.reject = (reason) => {
|
|
127
|
+
_reject(reason);
|
|
128
|
+
return this;
|
|
129
|
+
};
|
|
407
130
|
}
|
|
408
|
-
return {
|
|
409
|
-
on,
|
|
410
|
-
emit,
|
|
411
|
-
off
|
|
412
|
-
};
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
// ../../node_modules/.pnpm/react-use@17.6.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/react-use/esm/useEffectOnce.js
|
|
416
|
-
var import_react12 = __toESM(require_react());
|
|
417
|
-
var useEffectOnce = function(effect) {
|
|
418
|
-
(0, import_react12.useEffect)(effect, []);
|
|
419
|
-
};
|
|
420
|
-
var useEffectOnce_default = useEffectOnce;
|
|
421
|
-
|
|
422
|
-
// ../../node_modules/.pnpm/react-use@17.6.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/react-use/esm/useMount.js
|
|
423
|
-
var useMount = function(fn) {
|
|
424
|
-
useEffectOnce_default(function() {
|
|
425
|
-
fn();
|
|
426
|
-
});
|
|
427
131
|
};
|
|
428
|
-
var useMount_default = useMount;
|
|
429
|
-
|
|
430
|
-
// src/hooks/useFetchIntercept.ts
|
|
431
|
-
function useFetchResponseIntercept(intercept) {
|
|
432
|
-
useMount_default(() => fetchResponseIntercept(intercept));
|
|
433
|
-
}
|
|
434
|
-
function useFetchRequestIntercept(intercept) {
|
|
435
|
-
useMount_default(() => fetchRequestIntercept(intercept));
|
|
436
|
-
}
|
|
437
|
-
function fetchResponseIntercept(intercept) {
|
|
438
|
-
const { fetch: originalFetch } = window;
|
|
439
|
-
window.fetch = async (...args) => {
|
|
440
|
-
const [resource, config] = args;
|
|
441
|
-
const response = await originalFetch(resource, config);
|
|
442
|
-
return intercept(response);
|
|
443
|
-
};
|
|
444
|
-
}
|
|
445
|
-
function fetchRequestIntercept(intercept) {
|
|
446
|
-
const { fetch: originalFetch } = window;
|
|
447
|
-
window.fetch = async (...args) => {
|
|
448
|
-
const [resource, config] = args;
|
|
449
|
-
return intercept(originalFetch, resource, config);
|
|
450
|
-
};
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
// src/hooks/useMounted.ts
|
|
454
|
-
var import_react13 = __toESM(require_react(), 1);
|
|
455
|
-
function useMounted() {
|
|
456
|
-
const [mounted, setMounted] = (0, import_react13.useState)(false);
|
|
457
|
-
(0, import_react13.useEffect)(() => setMounted(true), []);
|
|
458
|
-
return mounted;
|
|
459
|
-
}
|
|
460
132
|
|
|
461
|
-
// src/
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
() => Array.isArray(source) ? source : [source],
|
|
468
|
-
[source]
|
|
469
|
-
);
|
|
470
|
-
(0, import_react14.useEffect)(() => {
|
|
471
|
-
if (!firstUpdate.current)
|
|
472
|
-
recordFirst();
|
|
473
|
-
else
|
|
474
|
-
callback(source);
|
|
475
|
-
}, deps);
|
|
476
|
-
async function recordFirst() {
|
|
477
|
-
if (then.current)
|
|
478
|
-
return;
|
|
479
|
-
then.current = Promise.resolve(source);
|
|
480
|
-
then.current.then(() => firstUpdate.current = true);
|
|
481
|
-
if (options.immediate)
|
|
482
|
-
then.current.then((value) => callback(value));
|
|
133
|
+
// ../util-core/src/util/json.ts
|
|
134
|
+
function jsonTryParse(text) {
|
|
135
|
+
try {
|
|
136
|
+
return JSON.parse(text || "");
|
|
137
|
+
} catch {
|
|
138
|
+
return void 0;
|
|
483
139
|
}
|
|
484
140
|
}
|
|
485
141
|
|
|
486
|
-
// src/hooks/useWhenever.ts
|
|
487
|
-
function useWhenever(source, cb, options) {
|
|
488
|
-
useWatch(source, () => source && cb(source), options);
|
|
489
|
-
}
|
|
490
|
-
|
|
491
142
|
// ../../node_modules/.pnpm/proxy-compare@3.0.1/node_modules/proxy-compare/dist/index.js
|
|
492
143
|
var TRACK_MEMO_SYMBOL = Symbol();
|
|
493
144
|
var GET_ORIGINAL_SYMBOL = Symbol();
|
|
@@ -609,7 +260,7 @@ var LibReact = (() => {
|
|
|
609
260
|
var isAllOwnKeysChanged = (prevObj, nextObj) => {
|
|
610
261
|
const prevKeys = Reflect.ownKeys(prevObj);
|
|
611
262
|
const nextKeys = Reflect.ownKeys(nextObj);
|
|
612
|
-
return prevKeys.length !== nextKeys.length || prevKeys.some((k,
|
|
263
|
+
return prevKeys.length !== nextKeys.length || prevKeys.some((k, i) => k !== nextKeys[i]);
|
|
613
264
|
};
|
|
614
265
|
var isChanged = (prevObj, nextObj, affected, cache, isEqual = Object.is) => {
|
|
615
266
|
if (isEqual(prevObj, nextObj)) {
|
|
@@ -923,6 +574,10 @@ var LibReact = (() => {
|
|
|
923
574
|
const [target, ensureVersion] = proxyState;
|
|
924
575
|
return createSnapshot(target, ensureVersion());
|
|
925
576
|
}
|
|
577
|
+
function ref(obj) {
|
|
578
|
+
refSet.add(obj);
|
|
579
|
+
return obj;
|
|
580
|
+
}
|
|
926
581
|
function unstable_getInternalStates() {
|
|
927
582
|
return {
|
|
928
583
|
proxyStateMap,
|
|
@@ -933,8 +588,169 @@ var LibReact = (() => {
|
|
|
933
588
|
};
|
|
934
589
|
}
|
|
935
590
|
|
|
936
|
-
// ../../node_modules/.pnpm/valtio@2.1.4_@types+react@18.3.18_react@18.3.1/node_modules/valtio/esm/
|
|
937
|
-
var
|
|
591
|
+
// ../../node_modules/.pnpm/valtio@2.1.4_@types+react@18.3.18_react@18.3.1/node_modules/valtio/esm/react.mjs
|
|
592
|
+
var import_react = __toESM(require_react(), 1);
|
|
593
|
+
var import_meta2 = {};
|
|
594
|
+
var useAffectedDebugValue = (state, affected) => {
|
|
595
|
+
const pathList = (0, import_react.useRef)(void 0);
|
|
596
|
+
(0, import_react.useEffect)(() => {
|
|
597
|
+
pathList.current = affectedToPathList(state, affected, true);
|
|
598
|
+
});
|
|
599
|
+
(0, import_react.useDebugValue)(pathList.current);
|
|
600
|
+
};
|
|
601
|
+
var condUseAffectedDebugValue = useAffectedDebugValue;
|
|
602
|
+
var targetCache = /* @__PURE__ */ new WeakMap();
|
|
603
|
+
function useSnapshot(proxyObject, options) {
|
|
604
|
+
const notifyInSync = options == null ? void 0 : options.sync;
|
|
605
|
+
const affected = (0, import_react.useMemo)(
|
|
606
|
+
() => proxyObject && /* @__PURE__ */ new WeakMap(),
|
|
607
|
+
[proxyObject]
|
|
608
|
+
);
|
|
609
|
+
const lastSnapshot = (0, import_react.useRef)(void 0);
|
|
610
|
+
let inRender = true;
|
|
611
|
+
const currSnapshot = (0, import_react.useSyncExternalStore)(
|
|
612
|
+
(0, import_react.useCallback)(
|
|
613
|
+
(callback) => {
|
|
614
|
+
const unsub = subscribe(proxyObject, callback, notifyInSync);
|
|
615
|
+
callback();
|
|
616
|
+
return unsub;
|
|
617
|
+
},
|
|
618
|
+
[proxyObject, notifyInSync]
|
|
619
|
+
),
|
|
620
|
+
() => {
|
|
621
|
+
const nextSnapshot = snapshot(proxyObject);
|
|
622
|
+
try {
|
|
623
|
+
if (!inRender && lastSnapshot.current && !isChanged(
|
|
624
|
+
lastSnapshot.current,
|
|
625
|
+
nextSnapshot,
|
|
626
|
+
affected,
|
|
627
|
+
/* @__PURE__ */ new WeakMap()
|
|
628
|
+
)) {
|
|
629
|
+
return lastSnapshot.current;
|
|
630
|
+
}
|
|
631
|
+
} catch (e) {
|
|
632
|
+
}
|
|
633
|
+
return nextSnapshot;
|
|
634
|
+
},
|
|
635
|
+
() => snapshot(proxyObject)
|
|
636
|
+
);
|
|
637
|
+
inRender = false;
|
|
638
|
+
(0, import_react.useLayoutEffect)(() => {
|
|
639
|
+
lastSnapshot.current = currSnapshot;
|
|
640
|
+
});
|
|
641
|
+
if ((import_meta2.env ? import_meta2.env.MODE : void 0) !== "production") {
|
|
642
|
+
condUseAffectedDebugValue(currSnapshot, affected);
|
|
643
|
+
}
|
|
644
|
+
const proxyCache2 = (0, import_react.useMemo)(() => /* @__PURE__ */ new WeakMap(), []);
|
|
645
|
+
return createProxy(currSnapshot, affected, proxyCache2, targetCache);
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
// src/utils/track.ts
|
|
649
|
+
function track(fn, ...args) {
|
|
650
|
+
const deferred = ref(new Deferred());
|
|
651
|
+
const exposer = { fn, args, deferred, id: ++Trigger.id };
|
|
652
|
+
Trigger.tasks.set(exposer.id, exposer);
|
|
653
|
+
deferred.then(() => Trigger.tasks.delete(exposer.id));
|
|
654
|
+
return deferred;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
// src/utils/wrapper.ts
|
|
658
|
+
var import_react2 = __toESM(require_react(), 1);
|
|
659
|
+
function wrapper(tag, props, children) {
|
|
660
|
+
return tag ? (0, import_react2.createElement)(tag, props, children) : children;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
// src/components/condition/Case.ts
|
|
664
|
+
function Case(props) {
|
|
665
|
+
const { cond, children, tag, ...attrs } = props;
|
|
666
|
+
return wrapper(tag, attrs, children);
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
// src/components/condition/Default.ts
|
|
670
|
+
function Default(props) {
|
|
671
|
+
const { children, tag, ...attrs } = props;
|
|
672
|
+
return wrapper(tag, attrs, children);
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
// src/components/condition/If.ts
|
|
676
|
+
var import_react3 = __toESM(require_react(), 1);
|
|
677
|
+
|
|
678
|
+
// src/components/condition/Then.ts
|
|
679
|
+
function Then(props) {
|
|
680
|
+
const { children, cond, else: _else, then, tag, ...attrs } = props;
|
|
681
|
+
return Object.keys(props).includes("cond") ? wrapper(If, props, children) : wrapper(tag, attrs, children);
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
// src/components/condition/If.ts
|
|
685
|
+
function If(props) {
|
|
686
|
+
const { then, cond, else: _else, children = props.then, tag, ...attrs } = props;
|
|
687
|
+
const elements = import_react3.Children.toArray(children);
|
|
688
|
+
const thenChild = elements.find((c) => c.type === Then);
|
|
689
|
+
const elseChild = elements.find((c) => c.type === Else);
|
|
690
|
+
const child = thenChild || elseChild ? cond ? thenChild : elseChild : cond ? children : _else;
|
|
691
|
+
return wrapper(tag, attrs, child);
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
// src/components/condition/Else.ts
|
|
695
|
+
function Else(props) {
|
|
696
|
+
const { children, tag, ...attrs } = props;
|
|
697
|
+
return Object.keys(props).includes("cond") ? wrapper(If, props, children) : wrapper(tag, attrs, children);
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
// src/components/condition/Switch.ts
|
|
701
|
+
var import_react4 = __toESM(require_react(), 1);
|
|
702
|
+
function Switch(props) {
|
|
703
|
+
const isUseValue = props.value !== void 0;
|
|
704
|
+
let matchingCase;
|
|
705
|
+
let defaultCase;
|
|
706
|
+
import_react4.Children.forEach(props.children, (child) => {
|
|
707
|
+
if (!(0, import_react4.isValidElement)(child) || matchingCase)
|
|
708
|
+
return;
|
|
709
|
+
if (child.type === Case) {
|
|
710
|
+
const cond = child.props.cond;
|
|
711
|
+
if (isUseValue ? props.value === cond : cond) {
|
|
712
|
+
matchingCase = child;
|
|
713
|
+
return;
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
if (!defaultCase && child.type === Default)
|
|
717
|
+
defaultCase = child;
|
|
718
|
+
});
|
|
719
|
+
return matchingCase ?? defaultCase ?? null;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
// src/components/condition/Unless.ts
|
|
723
|
+
var import_react5 = __toESM(require_react(), 1);
|
|
724
|
+
function Unless(props) {
|
|
725
|
+
const { cond, then, else: _else, tag, children = props.then, ...attrs } = props;
|
|
726
|
+
const elements = import_react5.Children.toArray(children);
|
|
727
|
+
const thenChild = elements.find((c) => c.type === Then);
|
|
728
|
+
const elseChild = elements.find((c) => c.type === Else);
|
|
729
|
+
const child = thenChild || elseChild ? !cond ? elseChild : thenChild : !cond ? children : _else;
|
|
730
|
+
return wrapper(tag, attrs, child);
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
// src/components/utils/Injector.ts
|
|
734
|
+
var import_react6 = __toESM(require_react(), 1);
|
|
735
|
+
function Injector(props) {
|
|
736
|
+
const installs = (0, import_react6.useMemo)(
|
|
737
|
+
() => props.install.map(repack).reverse(),
|
|
738
|
+
[props.install]
|
|
739
|
+
);
|
|
740
|
+
return installs.reduce(
|
|
741
|
+
(child, { component: Component, props: props2 }) => (0, import_react6.createElement)(Component, props2, child),
|
|
742
|
+
props.children
|
|
743
|
+
);
|
|
744
|
+
}
|
|
745
|
+
function repack(c) {
|
|
746
|
+
return c.component ? c : { component: c };
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
// src/components/utils/Trigger.ts
|
|
750
|
+
var import_react7 = __toESM(require_react(), 1);
|
|
751
|
+
|
|
752
|
+
// ../../node_modules/.pnpm/valtio@2.1.4_@types+react@18.3.18_react@18.3.1/node_modules/valtio/esm/vanilla/utils.mjs
|
|
753
|
+
var currentCleanups;
|
|
938
754
|
function watch(callback, options) {
|
|
939
755
|
let alive = true;
|
|
940
756
|
const cleanups = /* @__PURE__ */ new Set();
|
|
@@ -992,77 +808,353 @@ var LibReact = (() => {
|
|
|
992
808
|
}
|
|
993
809
|
var DEVTOOLS = Symbol();
|
|
994
810
|
var { proxyStateMap: proxyStateMap$1, snapCache: snapCache$1 } = unstable_getInternalStates();
|
|
811
|
+
var isProxy$1 = (x) => proxyStateMap$1.has(x);
|
|
812
|
+
function proxyMap(entries) {
|
|
813
|
+
const initialData = [];
|
|
814
|
+
let initialIndex = 0;
|
|
815
|
+
const indexMap = /* @__PURE__ */ new Map();
|
|
816
|
+
const snapMapCache = /* @__PURE__ */ new WeakMap();
|
|
817
|
+
const registerSnapMap = () => {
|
|
818
|
+
const cache = snapCache$1.get(vObject);
|
|
819
|
+
const latestSnap = cache == null ? void 0 : cache[1];
|
|
820
|
+
if (latestSnap && !snapMapCache.has(latestSnap)) {
|
|
821
|
+
const clonedMap = new Map(indexMap);
|
|
822
|
+
snapMapCache.set(latestSnap, clonedMap);
|
|
823
|
+
}
|
|
824
|
+
};
|
|
825
|
+
const getMapForThis = (x) => snapMapCache.get(x) || indexMap;
|
|
826
|
+
if (entries) {
|
|
827
|
+
if (typeof entries[Symbol.iterator] !== "function") {
|
|
828
|
+
throw new TypeError(
|
|
829
|
+
"proxyMap:\n initial state must be iterable\n tip: structure should be [[key, value]]"
|
|
830
|
+
);
|
|
831
|
+
}
|
|
832
|
+
for (const [key, value] of entries) {
|
|
833
|
+
indexMap.set(key, initialIndex);
|
|
834
|
+
initialData[initialIndex++] = value;
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
const vObject = {
|
|
838
|
+
data: initialData,
|
|
839
|
+
index: initialIndex,
|
|
840
|
+
epoch: 0,
|
|
841
|
+
get size() {
|
|
842
|
+
if (!isProxy$1(this)) {
|
|
843
|
+
registerSnapMap();
|
|
844
|
+
}
|
|
845
|
+
const map = getMapForThis(this);
|
|
846
|
+
return map.size;
|
|
847
|
+
},
|
|
848
|
+
get(key) {
|
|
849
|
+
const map = getMapForThis(this);
|
|
850
|
+
const index = map.get(key);
|
|
851
|
+
if (index === void 0) {
|
|
852
|
+
this.epoch;
|
|
853
|
+
return void 0;
|
|
854
|
+
}
|
|
855
|
+
return this.data[index];
|
|
856
|
+
},
|
|
857
|
+
has(key) {
|
|
858
|
+
const map = getMapForThis(this);
|
|
859
|
+
this.epoch;
|
|
860
|
+
return map.has(key);
|
|
861
|
+
},
|
|
862
|
+
set(key, value) {
|
|
863
|
+
if (!isProxy$1(this)) {
|
|
864
|
+
throw new Error("Cannot perform mutations on a snapshot");
|
|
865
|
+
}
|
|
866
|
+
const index = indexMap.get(key);
|
|
867
|
+
if (index === void 0) {
|
|
868
|
+
indexMap.set(key, this.index);
|
|
869
|
+
this.data[this.index++] = value;
|
|
870
|
+
} else {
|
|
871
|
+
this.data[index] = value;
|
|
872
|
+
}
|
|
873
|
+
this.epoch++;
|
|
874
|
+
return this;
|
|
875
|
+
},
|
|
876
|
+
delete(key) {
|
|
877
|
+
if (!isProxy$1(this)) {
|
|
878
|
+
throw new Error("Cannot perform mutations on a snapshot");
|
|
879
|
+
}
|
|
880
|
+
const index = indexMap.get(key);
|
|
881
|
+
if (index === void 0) {
|
|
882
|
+
return false;
|
|
883
|
+
}
|
|
884
|
+
delete this.data[index];
|
|
885
|
+
indexMap.delete(key);
|
|
886
|
+
this.epoch++;
|
|
887
|
+
return true;
|
|
888
|
+
},
|
|
889
|
+
clear() {
|
|
890
|
+
if (!isProxy$1(this)) {
|
|
891
|
+
throw new Error("Cannot perform mutations on a snapshot");
|
|
892
|
+
}
|
|
893
|
+
this.data.length = 0;
|
|
894
|
+
this.index = 0;
|
|
895
|
+
this.epoch++;
|
|
896
|
+
indexMap.clear();
|
|
897
|
+
},
|
|
898
|
+
forEach(cb) {
|
|
899
|
+
this.epoch;
|
|
900
|
+
const map = getMapForThis(this);
|
|
901
|
+
map.forEach((index, key) => {
|
|
902
|
+
cb(this.data[index], key, this);
|
|
903
|
+
});
|
|
904
|
+
},
|
|
905
|
+
*entries() {
|
|
906
|
+
this.epoch;
|
|
907
|
+
const map = getMapForThis(this);
|
|
908
|
+
for (const [key, index] of map) {
|
|
909
|
+
yield [key, this.data[index]];
|
|
910
|
+
}
|
|
911
|
+
},
|
|
912
|
+
*keys() {
|
|
913
|
+
this.epoch;
|
|
914
|
+
const map = getMapForThis(this);
|
|
915
|
+
for (const key of map.keys()) {
|
|
916
|
+
yield key;
|
|
917
|
+
}
|
|
918
|
+
},
|
|
919
|
+
*values() {
|
|
920
|
+
this.epoch;
|
|
921
|
+
const map = getMapForThis(this);
|
|
922
|
+
for (const index of map.values()) {
|
|
923
|
+
yield this.data[index];
|
|
924
|
+
}
|
|
925
|
+
},
|
|
926
|
+
[Symbol.iterator]() {
|
|
927
|
+
return this.entries();
|
|
928
|
+
},
|
|
929
|
+
get [Symbol.toStringTag]() {
|
|
930
|
+
return "Map";
|
|
931
|
+
},
|
|
932
|
+
toJSON() {
|
|
933
|
+
return new Map(this.entries());
|
|
934
|
+
}
|
|
935
|
+
};
|
|
936
|
+
const proxiedObject = proxy(vObject);
|
|
937
|
+
Object.defineProperties(proxiedObject, {
|
|
938
|
+
size: { enumerable: false },
|
|
939
|
+
index: { enumerable: false },
|
|
940
|
+
epoch: { enumerable: false },
|
|
941
|
+
data: { enumerable: false },
|
|
942
|
+
toJSON: { enumerable: false }
|
|
943
|
+
});
|
|
944
|
+
Object.seal(proxiedObject);
|
|
945
|
+
return proxiedObject;
|
|
946
|
+
}
|
|
995
947
|
var { proxyStateMap: proxyStateMap2, snapCache: snapCache2 } = unstable_getInternalStates();
|
|
996
948
|
|
|
997
|
-
//
|
|
998
|
-
var
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
const
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
)
|
|
949
|
+
// src/components/utils/Trigger.ts
|
|
950
|
+
var pendingTasks = proxyMap();
|
|
951
|
+
function createTracker(exposer) {
|
|
952
|
+
const Component = () => {
|
|
953
|
+
try {
|
|
954
|
+
exposer.deferred.resolve(exposer.fn(...exposer.args));
|
|
955
|
+
} catch (error) {
|
|
956
|
+
exposer.deferred.reject(error);
|
|
957
|
+
}
|
|
958
|
+
return null;
|
|
959
|
+
};
|
|
960
|
+
Component.key = exposer.id;
|
|
961
|
+
return Component;
|
|
962
|
+
}
|
|
963
|
+
function renderTracker(Tracker) {
|
|
964
|
+
return (0, import_react7.createElement)(Tracker, { key: Tracker.key });
|
|
965
|
+
}
|
|
966
|
+
function Trigger() {
|
|
967
|
+
const values = [...useSnapshot(pendingTasks).values()];
|
|
968
|
+
return values.map(createTracker).map(renderTracker);
|
|
969
|
+
}
|
|
970
|
+
Trigger.id = 0;
|
|
971
|
+
Trigger.tasks = pendingTasks;
|
|
972
|
+
|
|
973
|
+
// src/hooks/ref.ts
|
|
974
|
+
var import_react8 = __toESM(require_react(), 1);
|
|
975
|
+
function ref2(value) {
|
|
976
|
+
function define(value2) {
|
|
977
|
+
if (typeof value2 === "function")
|
|
978
|
+
return (prev) => define(value2(prev.value));
|
|
979
|
+
return Object.defineProperty({}, "value", {
|
|
980
|
+
set: (action) => set(define(action)),
|
|
981
|
+
get: () => value2,
|
|
982
|
+
enumerable: true
|
|
983
|
+
});
|
|
984
|
+
}
|
|
985
|
+
const [ref3, set] = (0, import_react8.useState)(define(value));
|
|
986
|
+
return ref3;
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
// src/hooks/useAsyncCallback.ts
|
|
990
|
+
var import_react9 = __toESM(require_react(), 1);
|
|
991
|
+
function useAsyncCallback(fun) {
|
|
992
|
+
const [state, set] = (0, import_react9.useState)({ loading: false });
|
|
993
|
+
async function execute(...args) {
|
|
994
|
+
set({ loading: true });
|
|
995
|
+
return fun(...args).then((value) => {
|
|
996
|
+
set({ loading: false });
|
|
997
|
+
return value;
|
|
998
|
+
}).catch((err) => {
|
|
999
|
+
set({ loading: false, error: err });
|
|
1000
|
+
return Promise.reject(err);
|
|
1001
|
+
});
|
|
1002
|
+
}
|
|
1003
|
+
return [state.loading, execute, state.error];
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
// src/hooks/useAsyncState.ts
|
|
1007
|
+
var import_react10 = __toESM(require_react(), 1);
|
|
1008
|
+
function useAsyncState(fun, deps = [], options) {
|
|
1009
|
+
const [value, set] = (0, import_react10.useState)(options?.initial);
|
|
1010
|
+
const [loading, execute, error] = useAsyncCallback(async (...args) => fun(...args).then(set));
|
|
1011
|
+
(0, import_react10.useEffect)(
|
|
1026
1012
|
() => {
|
|
1027
|
-
|
|
1028
|
-
try {
|
|
1029
|
-
if (!inRender && lastSnapshot.current && !isChanged(
|
|
1030
|
-
lastSnapshot.current,
|
|
1031
|
-
nextSnapshot,
|
|
1032
|
-
affected,
|
|
1033
|
-
/* @__PURE__ */ new WeakMap()
|
|
1034
|
-
)) {
|
|
1035
|
-
return lastSnapshot.current;
|
|
1036
|
-
}
|
|
1037
|
-
} catch (e2) {
|
|
1038
|
-
}
|
|
1039
|
-
return nextSnapshot;
|
|
1013
|
+
execute();
|
|
1040
1014
|
},
|
|
1041
|
-
|
|
1015
|
+
deps
|
|
1042
1016
|
);
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1017
|
+
return [{ value, loading, error }, execute];
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
// src/hooks/useDebounce.ts
|
|
1021
|
+
var import_react11 = __toESM(require_react(), 1);
|
|
1022
|
+
function useDebounce(value, delay) {
|
|
1023
|
+
const [debouncedValue, setDebouncedValue] = (0, import_react11.useState)(value);
|
|
1024
|
+
(0, import_react11.useEffect)(() => {
|
|
1025
|
+
const handler = setTimeout(() => setDebouncedValue(value), delay);
|
|
1026
|
+
return () => clearTimeout(handler);
|
|
1027
|
+
}, [value, delay]);
|
|
1028
|
+
return debouncedValue;
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
// ../../node_modules/.pnpm/mitt@3.0.1/node_modules/mitt/dist/mitt.mjs
|
|
1032
|
+
function mitt_default(n) {
|
|
1033
|
+
return { all: n = n || /* @__PURE__ */ new Map(), on: function(t, e) {
|
|
1034
|
+
var i = n.get(t);
|
|
1035
|
+
i ? i.push(e) : n.set(t, [e]);
|
|
1036
|
+
}, off: function(t, e) {
|
|
1037
|
+
var i = n.get(t);
|
|
1038
|
+
i && (e ? i.splice(i.indexOf(e) >>> 0, 1) : n.set(t, []));
|
|
1039
|
+
}, emit: function(t, e) {
|
|
1040
|
+
var i = n.get(t);
|
|
1041
|
+
i && i.slice().map(function(n2) {
|
|
1042
|
+
n2(e);
|
|
1043
|
+
}), (i = n.get("*")) && i.slice().map(function(n2) {
|
|
1044
|
+
n2(t, e);
|
|
1045
|
+
});
|
|
1046
|
+
} };
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
// src/hooks/useEventBus.ts
|
|
1050
|
+
var import_react12 = __toESM(require_react(), 1);
|
|
1051
|
+
var emitter = mitt_default();
|
|
1052
|
+
function useEventBus(key) {
|
|
1053
|
+
const onRef = (0, import_react12.useRef)();
|
|
1054
|
+
function on(listener) {
|
|
1055
|
+
emitter.on(key, listener);
|
|
1056
|
+
onRef.current = listener;
|
|
1057
|
+
(0, import_react12.useEffect)(() => {
|
|
1058
|
+
if (!onRef.current)
|
|
1059
|
+
return;
|
|
1060
|
+
emitter.off(key, onRef.current);
|
|
1061
|
+
emitter.on(key, listener);
|
|
1062
|
+
onRef.current = listener;
|
|
1063
|
+
return () => emitter.off(key, listener);
|
|
1064
|
+
}, [listener]);
|
|
1049
1065
|
}
|
|
1050
|
-
|
|
1051
|
-
|
|
1066
|
+
function emit(event) {
|
|
1067
|
+
emitter.emit(key, event);
|
|
1068
|
+
}
|
|
1069
|
+
function off(listener) {
|
|
1070
|
+
emitter.off(key, listener);
|
|
1071
|
+
}
|
|
1072
|
+
return {
|
|
1073
|
+
on,
|
|
1074
|
+
emit,
|
|
1075
|
+
off
|
|
1076
|
+
};
|
|
1052
1077
|
}
|
|
1053
1078
|
|
|
1054
|
-
//
|
|
1055
|
-
var
|
|
1079
|
+
// ../../node_modules/.pnpm/react-use@17.6.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/react-use/esm/useEffectOnce.js
|
|
1080
|
+
var import_react13 = __toESM(require_react());
|
|
1081
|
+
var useEffectOnce = function(effect) {
|
|
1082
|
+
(0, import_react13.useEffect)(effect, []);
|
|
1083
|
+
};
|
|
1084
|
+
var useEffectOnce_default = useEffectOnce;
|
|
1056
1085
|
|
|
1057
|
-
//
|
|
1058
|
-
function
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
}
|
|
1062
|
-
|
|
1086
|
+
// ../../node_modules/.pnpm/react-use@17.6.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/react-use/esm/useMount.js
|
|
1087
|
+
var useMount = function(fn) {
|
|
1088
|
+
useEffectOnce_default(function() {
|
|
1089
|
+
fn();
|
|
1090
|
+
});
|
|
1091
|
+
};
|
|
1092
|
+
var useMount_default = useMount;
|
|
1093
|
+
|
|
1094
|
+
// src/hooks/useFetchIntercept.ts
|
|
1095
|
+
function useFetchResponseIntercept(intercept) {
|
|
1096
|
+
useMount_default(() => fetchResponseIntercept(intercept));
|
|
1097
|
+
}
|
|
1098
|
+
function useFetchRequestIntercept(intercept) {
|
|
1099
|
+
useMount_default(() => fetchRequestIntercept(intercept));
|
|
1100
|
+
}
|
|
1101
|
+
function fetchResponseIntercept(intercept) {
|
|
1102
|
+
const { fetch: originalFetch } = window;
|
|
1103
|
+
window.fetch = async (...args) => {
|
|
1104
|
+
const [resource, config] = args;
|
|
1105
|
+
const response = await originalFetch(resource, config);
|
|
1106
|
+
return intercept(response);
|
|
1107
|
+
};
|
|
1108
|
+
}
|
|
1109
|
+
function fetchRequestIntercept(intercept) {
|
|
1110
|
+
const { fetch: originalFetch } = window;
|
|
1111
|
+
window.fetch = async (...args) => {
|
|
1112
|
+
const [resource, config] = args;
|
|
1113
|
+
return intercept(originalFetch, resource, config);
|
|
1114
|
+
};
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
// src/hooks/useMounted.ts
|
|
1118
|
+
var import_react14 = __toESM(require_react(), 1);
|
|
1119
|
+
function useMounted() {
|
|
1120
|
+
const [mounted, setMounted] = (0, import_react14.useState)(false);
|
|
1121
|
+
(0, import_react14.useEffect)(() => setMounted(true), []);
|
|
1122
|
+
return mounted;
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
// src/hooks/useWatch.ts
|
|
1126
|
+
var import_react15 = __toESM(require_react(), 1);
|
|
1127
|
+
function useWatch(source, callback, options = {}) {
|
|
1128
|
+
const firstUpdate = (0, import_react15.useRef)(false);
|
|
1129
|
+
const then = (0, import_react15.useRef)();
|
|
1130
|
+
const deps = (0, import_react15.useMemo)(
|
|
1131
|
+
() => Array.isArray(source) ? source : [source],
|
|
1132
|
+
[source]
|
|
1133
|
+
);
|
|
1134
|
+
(0, import_react15.useEffect)(() => {
|
|
1135
|
+
if (!firstUpdate.current)
|
|
1136
|
+
recordFirst();
|
|
1137
|
+
else
|
|
1138
|
+
callback(source);
|
|
1139
|
+
}, deps);
|
|
1140
|
+
async function recordFirst() {
|
|
1141
|
+
if (then.current)
|
|
1142
|
+
return;
|
|
1143
|
+
then.current = Promise.resolve(source);
|
|
1144
|
+
then.current.then(() => firstUpdate.current = true);
|
|
1145
|
+
if (options.immediate)
|
|
1146
|
+
then.current.then((value) => callback(value));
|
|
1063
1147
|
}
|
|
1064
1148
|
}
|
|
1065
1149
|
|
|
1150
|
+
// src/hooks/useWhenever.ts
|
|
1151
|
+
function useWhenever(source, cb, options) {
|
|
1152
|
+
useWatch(source, () => source && cb(source), options);
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
// src/storage/defineStore.ts
|
|
1156
|
+
var import_react16 = __toESM(require_react(), 1);
|
|
1157
|
+
|
|
1066
1158
|
// src/storage/persistant.ts
|
|
1067
1159
|
function proxyWithPersistant(keyOrOptions, initialObject) {
|
|
1068
1160
|
let options;
|
|
@@ -1129,7 +1221,7 @@ var LibReact = (() => {
|
|
|
1129
1221
|
...$actions
|
|
1130
1222
|
};
|
|
1131
1223
|
}
|
|
1132
|
-
function
|
|
1224
|
+
function track2(action, status) {
|
|
1133
1225
|
let loadings = 0;
|
|
1134
1226
|
const tracking = () => loadings++ === 0 && (status.loading = true);
|
|
1135
1227
|
const done = () => !--loadings && (status.loading = false);
|
|
@@ -1156,7 +1248,7 @@ var LibReact = (() => {
|
|
|
1156
1248
|
function setupActions($state, actions, $actions, $status) {
|
|
1157
1249
|
for (const key in actions) {
|
|
1158
1250
|
$status[key] = { finished: false, loading: false, error: null };
|
|
1159
|
-
$actions[key] =
|
|
1251
|
+
$actions[key] = track2(actions[key].bind($state), $status[key]);
|
|
1160
1252
|
}
|
|
1161
1253
|
}
|
|
1162
1254
|
function setupGetters(state, $state, getters, $getters) {
|