@hairy/react-lib 1.23.0 → 1.25.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 +121 -54
- package/dist/index.d.ts +48 -2
- package/dist/index.global.js +617 -413
- package/dist/index.js +88 -23
- package/package.json +2 -2
package/dist/index.global.js
CHANGED
|
@@ -81,12 +81,14 @@ var LibReact = (() => {
|
|
|
81
81
|
Switch: () => Switch,
|
|
82
82
|
Then: () => Then,
|
|
83
83
|
Trans: () => Trans,
|
|
84
|
+
Trigger: () => Trigger,
|
|
84
85
|
Unless: () => Unless,
|
|
85
86
|
cls: () => cls,
|
|
86
87
|
defineAsyncStore: () => defineAsyncStore,
|
|
87
88
|
defineStore: () => defineStore,
|
|
88
89
|
proxyWithPersistant: () => proxyWithPersistant,
|
|
89
|
-
ref: () =>
|
|
90
|
+
ref: () => ref2,
|
|
91
|
+
track: () => track,
|
|
90
92
|
useAsyncCallback: () => useAsyncCallback,
|
|
91
93
|
useAsyncState: () => useAsyncState,
|
|
92
94
|
useDebounce: () => useDebounce,
|
|
@@ -134,358 +136,39 @@ var LibReact = (() => {
|
|
|
134
136
|
return value ? `${value} ${newClass}` : newClass;
|
|
135
137
|
};
|
|
136
138
|
|
|
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
|
-
}
|
|
366
|
-
|
|
367
|
-
// ../../node_modules/.pnpm/mitt@3.0.1/node_modules/mitt/dist/mitt.mjs
|
|
368
|
-
function mitt_default(n2) {
|
|
369
|
-
return { all: n2 = n2 || /* @__PURE__ */ new Map(), on: function(t2, e2) {
|
|
370
|
-
var i2 = n2.get(t2);
|
|
371
|
-
i2 ? i2.push(e2) : n2.set(t2, [e2]);
|
|
372
|
-
}, off: function(t2, e2) {
|
|
373
|
-
var i2 = n2.get(t2);
|
|
374
|
-
i2 && (e2 ? i2.splice(i2.indexOf(e2) >>> 0, 1) : n2.set(t2, []));
|
|
375
|
-
}, emit: function(t2, e2) {
|
|
376
|
-
var i2 = n2.get(t2);
|
|
377
|
-
i2 && i2.slice().map(function(n3) {
|
|
378
|
-
n3(e2);
|
|
379
|
-
}), (i2 = n2.get("*")) && i2.slice().map(function(n3) {
|
|
380
|
-
n3(t2, e2);
|
|
381
|
-
});
|
|
382
|
-
} };
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
// src/hooks/useEventBus.ts
|
|
386
|
-
var import_react11 = __toESM(require_react(), 1);
|
|
387
|
-
var emitter = mitt_default();
|
|
388
|
-
function useEventBus(key) {
|
|
389
|
-
const onRef = (0, import_react11.useRef)();
|
|
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);
|
|
407
|
-
}
|
|
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
|
-
};
|
|
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
|
-
}
|
|
139
|
+
// ../util-core/src/util/noop.ts
|
|
140
|
+
var noop = () => {
|
|
141
|
+
};
|
|
460
142
|
|
|
461
|
-
// src/
|
|
462
|
-
var
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
() =>
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
return;
|
|
479
|
-
|
|
480
|
-
then.current.then(() => firstUpdate.current = true);
|
|
481
|
-
if (options.immediate)
|
|
482
|
-
then.current.then((value) => callback(value));
|
|
143
|
+
// ../util-core/src/util/deferred.ts
|
|
144
|
+
var Deferred = class extends Promise {
|
|
145
|
+
resolve;
|
|
146
|
+
reject;
|
|
147
|
+
constructor(executor = noop) {
|
|
148
|
+
let _resolve, _reject;
|
|
149
|
+
super((resolve_, reject_) => {
|
|
150
|
+
_resolve = resolve_;
|
|
151
|
+
_reject = reject_;
|
|
152
|
+
return executor(resolve_, reject_);
|
|
153
|
+
});
|
|
154
|
+
this.resolve = (value) => {
|
|
155
|
+
_resolve(value);
|
|
156
|
+
return this;
|
|
157
|
+
};
|
|
158
|
+
this.reject = (reason) => {
|
|
159
|
+
_reject(reason);
|
|
160
|
+
return this;
|
|
161
|
+
};
|
|
483
162
|
}
|
|
484
|
-
}
|
|
163
|
+
};
|
|
485
164
|
|
|
486
|
-
// src/
|
|
487
|
-
function
|
|
488
|
-
|
|
165
|
+
// ../util-core/src/util/json.ts
|
|
166
|
+
function jsonTryParse(text) {
|
|
167
|
+
try {
|
|
168
|
+
return JSON.parse(text || "");
|
|
169
|
+
} catch {
|
|
170
|
+
return void 0;
|
|
171
|
+
}
|
|
489
172
|
}
|
|
490
173
|
|
|
491
174
|
// ../../node_modules/.pnpm/proxy-compare@3.0.1/node_modules/proxy-compare/dist/index.js
|
|
@@ -923,6 +606,10 @@ var LibReact = (() => {
|
|
|
923
606
|
const [target, ensureVersion] = proxyState;
|
|
924
607
|
return createSnapshot(target, ensureVersion());
|
|
925
608
|
}
|
|
609
|
+
function ref(obj) {
|
|
610
|
+
refSet.add(obj);
|
|
611
|
+
return obj;
|
|
612
|
+
}
|
|
926
613
|
function unstable_getInternalStates() {
|
|
927
614
|
return {
|
|
928
615
|
proxyStateMap,
|
|
@@ -933,6 +620,247 @@ var LibReact = (() => {
|
|
|
933
620
|
};
|
|
934
621
|
}
|
|
935
622
|
|
|
623
|
+
// ../../node_modules/.pnpm/valtio@2.1.4_@types+react@18.3.18_react@18.3.1/node_modules/valtio/esm/react.mjs
|
|
624
|
+
var import_react = __toESM(require_react(), 1);
|
|
625
|
+
var import_meta2 = {};
|
|
626
|
+
var useAffectedDebugValue = (state, affected) => {
|
|
627
|
+
const pathList = (0, import_react.useRef)(void 0);
|
|
628
|
+
(0, import_react.useEffect)(() => {
|
|
629
|
+
pathList.current = affectedToPathList(state, affected, true);
|
|
630
|
+
});
|
|
631
|
+
(0, import_react.useDebugValue)(pathList.current);
|
|
632
|
+
};
|
|
633
|
+
var condUseAffectedDebugValue = useAffectedDebugValue;
|
|
634
|
+
var targetCache = /* @__PURE__ */ new WeakMap();
|
|
635
|
+
function useSnapshot(proxyObject, options) {
|
|
636
|
+
const notifyInSync = options == null ? void 0 : options.sync;
|
|
637
|
+
const affected = (0, import_react.useMemo)(
|
|
638
|
+
() => proxyObject && /* @__PURE__ */ new WeakMap(),
|
|
639
|
+
[proxyObject]
|
|
640
|
+
);
|
|
641
|
+
const lastSnapshot = (0, import_react.useRef)(void 0);
|
|
642
|
+
let inRender = true;
|
|
643
|
+
const currSnapshot = (0, import_react.useSyncExternalStore)(
|
|
644
|
+
(0, import_react.useCallback)(
|
|
645
|
+
(callback) => {
|
|
646
|
+
const unsub = subscribe(proxyObject, callback, notifyInSync);
|
|
647
|
+
callback();
|
|
648
|
+
return unsub;
|
|
649
|
+
},
|
|
650
|
+
[proxyObject, notifyInSync]
|
|
651
|
+
),
|
|
652
|
+
() => {
|
|
653
|
+
const nextSnapshot = snapshot(proxyObject);
|
|
654
|
+
try {
|
|
655
|
+
if (!inRender && lastSnapshot.current && !isChanged(
|
|
656
|
+
lastSnapshot.current,
|
|
657
|
+
nextSnapshot,
|
|
658
|
+
affected,
|
|
659
|
+
/* @__PURE__ */ new WeakMap()
|
|
660
|
+
)) {
|
|
661
|
+
return lastSnapshot.current;
|
|
662
|
+
}
|
|
663
|
+
} catch (e2) {
|
|
664
|
+
}
|
|
665
|
+
return nextSnapshot;
|
|
666
|
+
},
|
|
667
|
+
() => snapshot(proxyObject)
|
|
668
|
+
);
|
|
669
|
+
inRender = false;
|
|
670
|
+
(0, import_react.useLayoutEffect)(() => {
|
|
671
|
+
lastSnapshot.current = currSnapshot;
|
|
672
|
+
});
|
|
673
|
+
if ((import_meta2.env ? import_meta2.env.MODE : void 0) !== "production") {
|
|
674
|
+
condUseAffectedDebugValue(currSnapshot, affected);
|
|
675
|
+
}
|
|
676
|
+
const proxyCache2 = (0, import_react.useMemo)(() => /* @__PURE__ */ new WeakMap(), []);
|
|
677
|
+
return createProxy(currSnapshot, affected, proxyCache2, targetCache);
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
// src/utils/track.ts
|
|
681
|
+
function track(fn, ...args) {
|
|
682
|
+
const deferred = ref(new Deferred());
|
|
683
|
+
const exposer = { fn, args, deferred, id: ++Trigger.id };
|
|
684
|
+
Trigger.tasks.set(exposer.id, exposer);
|
|
685
|
+
deferred.then(() => Trigger.tasks.delete(exposer.id));
|
|
686
|
+
return deferred;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
// src/utils/wrapper.ts
|
|
690
|
+
var import_react2 = __toESM(require_react(), 1);
|
|
691
|
+
function wrapper(tag, props, children) {
|
|
692
|
+
return tag ? (0, import_react2.createElement)(tag, props, children) : children;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
// src/components/condition/Case.ts
|
|
696
|
+
function Case(props) {
|
|
697
|
+
const { cond, children, tag, ...attrs } = props;
|
|
698
|
+
return wrapper(tag, attrs, children);
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
// src/components/condition/Default.ts
|
|
702
|
+
function Default(props) {
|
|
703
|
+
const { children, tag, ...attrs } = props;
|
|
704
|
+
return wrapper(tag, attrs, children);
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
// src/components/condition/If.ts
|
|
708
|
+
var import_react3 = __toESM(require_react(), 1);
|
|
709
|
+
|
|
710
|
+
// src/components/condition/Then.ts
|
|
711
|
+
function Then(props) {
|
|
712
|
+
const { children, cond, else: _else, then, tag, ...attrs } = props;
|
|
713
|
+
return Object.keys(props).includes("cond") ? wrapper(If, props, children) : wrapper(tag, attrs, children);
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
// src/components/condition/If.ts
|
|
717
|
+
function If(props) {
|
|
718
|
+
const { then, cond, else: _else, children = props.then, tag, ...attrs } = props;
|
|
719
|
+
const elements = import_react3.Children.toArray(children);
|
|
720
|
+
const thenChild = elements.find((c2) => c2.type === Then);
|
|
721
|
+
const elseChild = elements.find((c2) => c2.type === Else);
|
|
722
|
+
const child = thenChild || elseChild ? cond ? thenChild : elseChild : cond ? children : _else;
|
|
723
|
+
return wrapper(tag, attrs, child);
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
// src/components/condition/Else.ts
|
|
727
|
+
function Else(props) {
|
|
728
|
+
const { children, tag, ...attrs } = props;
|
|
729
|
+
return Object.keys(props).includes("cond") ? wrapper(If, props, children) : wrapper(tag, attrs, children);
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
// src/components/condition/Switch.ts
|
|
733
|
+
var import_react4 = __toESM(require_react(), 1);
|
|
734
|
+
function Switch(props) {
|
|
735
|
+
const isUseValue = props.value !== void 0;
|
|
736
|
+
let matchingCase;
|
|
737
|
+
let defaultCase;
|
|
738
|
+
import_react4.Children.forEach(props.children, (child) => {
|
|
739
|
+
if (!(0, import_react4.isValidElement)(child) || matchingCase)
|
|
740
|
+
return;
|
|
741
|
+
if (child.type === Case) {
|
|
742
|
+
const cond = child.props.cond;
|
|
743
|
+
if (isUseValue ? props.value === cond : cond) {
|
|
744
|
+
matchingCase = child;
|
|
745
|
+
return;
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
if (!defaultCase && child.type === Default)
|
|
749
|
+
defaultCase = child;
|
|
750
|
+
});
|
|
751
|
+
return matchingCase ?? defaultCase ?? null;
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
// src/components/condition/Unless.ts
|
|
755
|
+
var import_react5 = __toESM(require_react(), 1);
|
|
756
|
+
function Unless(props) {
|
|
757
|
+
const { cond, then, else: _else, tag, children = props.then, ...attrs } = props;
|
|
758
|
+
const elements = import_react5.Children.toArray(children);
|
|
759
|
+
const thenChild = elements.find((c2) => c2.type === Then);
|
|
760
|
+
const elseChild = elements.find((c2) => c2.type === Else);
|
|
761
|
+
const child = thenChild || elseChild ? !cond ? elseChild : thenChild : !cond ? children : _else;
|
|
762
|
+
return wrapper(tag, attrs, child);
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
// src/components/utils/Injector.ts
|
|
766
|
+
var import_react6 = __toESM(require_react(), 1);
|
|
767
|
+
function Injector(props) {
|
|
768
|
+
const installs = (0, import_react6.useMemo)(
|
|
769
|
+
() => props.install.map(repack).reverse(),
|
|
770
|
+
[props.install]
|
|
771
|
+
);
|
|
772
|
+
return installs.reduce(
|
|
773
|
+
(child, { component: Component, props: props2 }) => (0, import_react6.createElement)(Component, props2, child),
|
|
774
|
+
props.children
|
|
775
|
+
);
|
|
776
|
+
}
|
|
777
|
+
function repack(c2) {
|
|
778
|
+
return c2.component ? c2 : { component: c2 };
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
// ../../node_modules/.pnpm/html-parse-stringify@3.0.1/node_modules/html-parse-stringify/dist/html-parse-stringify.module.js
|
|
782
|
+
var import_void_elements = __toESM(require_void_elements());
|
|
783
|
+
var t = /\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;
|
|
784
|
+
function n(n2) {
|
|
785
|
+
var r2 = { type: "tag", name: "", voidElement: false, attrs: {}, children: [] }, i2 = n2.match(/<\/?([^\s]+?)[/\s>]/);
|
|
786
|
+
if (i2 && (r2.name = i2[1], (import_void_elements.default[i2[1]] || "/" === n2.charAt(n2.length - 2)) && (r2.voidElement = true), r2.name.startsWith("!--"))) {
|
|
787
|
+
var s2 = n2.indexOf("-->");
|
|
788
|
+
return { type: "comment", comment: -1 !== s2 ? n2.slice(4, s2) : "" };
|
|
789
|
+
}
|
|
790
|
+
for (var a2 = new RegExp(t), c2 = null; null !== (c2 = a2.exec(n2)); ) if (c2[0].trim()) if (c2[1]) {
|
|
791
|
+
var o = c2[1].trim(), l = [o, ""];
|
|
792
|
+
o.indexOf("=") > -1 && (l = o.split("=")), r2.attrs[l[0]] = l[1], a2.lastIndex--;
|
|
793
|
+
} else c2[2] && (r2.attrs[c2[2]] = c2[3].trim().substring(1, c2[3].length - 1));
|
|
794
|
+
return r2;
|
|
795
|
+
}
|
|
796
|
+
var r = /<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g;
|
|
797
|
+
var i = /^\s*$/;
|
|
798
|
+
var s = /* @__PURE__ */ Object.create(null);
|
|
799
|
+
function a(e2, t2) {
|
|
800
|
+
switch (t2.type) {
|
|
801
|
+
case "text":
|
|
802
|
+
return e2 + t2.content;
|
|
803
|
+
case "tag":
|
|
804
|
+
return e2 += "<" + t2.name + (t2.attrs ? function(e3) {
|
|
805
|
+
var t3 = [];
|
|
806
|
+
for (var n2 in e3) t3.push(n2 + '="' + e3[n2] + '"');
|
|
807
|
+
return t3.length ? " " + t3.join(" ") : "";
|
|
808
|
+
}(t2.attrs) : "") + (t2.voidElement ? "/>" : ">"), t2.voidElement ? e2 : e2 + t2.children.reduce(a, "") + "</" + t2.name + ">";
|
|
809
|
+
case "comment":
|
|
810
|
+
return e2 + "<!--" + t2.comment + "-->";
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
var c = { parse: function(e2, t2) {
|
|
814
|
+
t2 || (t2 = {}), t2.components || (t2.components = s);
|
|
815
|
+
var a2, c2 = [], o = [], l = -1, m = false;
|
|
816
|
+
if (0 !== e2.indexOf("<")) {
|
|
817
|
+
var u = e2.indexOf("<");
|
|
818
|
+
c2.push({ type: "text", content: -1 === u ? e2 : e2.substring(0, u) });
|
|
819
|
+
}
|
|
820
|
+
return e2.replace(r, function(r2, s2) {
|
|
821
|
+
if (m) {
|
|
822
|
+
if (r2 !== "</" + a2.name + ">") return;
|
|
823
|
+
m = false;
|
|
824
|
+
}
|
|
825
|
+
var u2, f = "/" !== r2.charAt(1), h = r2.startsWith("<!--"), p = s2 + r2.length, d = e2.charAt(p);
|
|
826
|
+
if (h) {
|
|
827
|
+
var v = n(r2);
|
|
828
|
+
return l < 0 ? (c2.push(v), c2) : ((u2 = o[l]).children.push(v), c2);
|
|
829
|
+
}
|
|
830
|
+
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)) {
|
|
831
|
+
u2 = -1 === l ? c2 : o[l].children;
|
|
832
|
+
var x = e2.indexOf("<", p), g = e2.slice(p, -1 === x ? void 0 : x);
|
|
833
|
+
i.test(g) && (g = " "), (x > -1 && l + u2.length >= 0 || " " !== g) && u2.push({ type: "text", content: g });
|
|
834
|
+
}
|
|
835
|
+
}), c2;
|
|
836
|
+
}, stringify: function(e2) {
|
|
837
|
+
return e2.reduce(function(e3, t2) {
|
|
838
|
+
return e3 + a("", t2);
|
|
839
|
+
}, "");
|
|
840
|
+
} };
|
|
841
|
+
var html_parse_stringify_module_default = c;
|
|
842
|
+
|
|
843
|
+
// src/components/utils/Trans.ts
|
|
844
|
+
var import_react7 = __toESM(require_react(), 1);
|
|
845
|
+
var import_react_i18next = __toESM(require_react_i18next(), 1);
|
|
846
|
+
function Trans({ i18nKey, ...additionalProps }) {
|
|
847
|
+
const translation = (0, import_react_i18next.useTranslation)().t(i18nKey, additionalProps);
|
|
848
|
+
return renderNodes(html_parse_stringify_module_default.parse(translation), additionalProps);
|
|
849
|
+
}
|
|
850
|
+
function renderNodes(tokens, values) {
|
|
851
|
+
let index = 0;
|
|
852
|
+
return tokens.map((token) => {
|
|
853
|
+
if (token.type === "text")
|
|
854
|
+
return token.content;
|
|
855
|
+
index++;
|
|
856
|
+
const props = { ...token.attrs, key: index };
|
|
857
|
+
return token.voidElement ? values[token.name] ? (0, import_react7.createElement)("span", { key: index }, values[token.name]) : (0, import_react7.createElement)(token.name, props) : (0, import_react7.createElement)(token.name, props, renderNodes(token.children, {}));
|
|
858
|
+
});
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
// src/components/utils/Trigger.ts
|
|
862
|
+
var import_react8 = __toESM(require_react(), 1);
|
|
863
|
+
|
|
936
864
|
// ../../node_modules/.pnpm/valtio@2.1.4_@types+react@18.3.18_react@18.3.1/node_modules/valtio/esm/vanilla/utils.mjs
|
|
937
865
|
var currentCleanups;
|
|
938
866
|
function watch(callback, options) {
|
|
@@ -992,77 +920,353 @@ var LibReact = (() => {
|
|
|
992
920
|
}
|
|
993
921
|
var DEVTOOLS = Symbol();
|
|
994
922
|
var { proxyStateMap: proxyStateMap$1, snapCache: snapCache$1 } = unstable_getInternalStates();
|
|
923
|
+
var isProxy$1 = (x) => proxyStateMap$1.has(x);
|
|
924
|
+
function proxyMap(entries) {
|
|
925
|
+
const initialData = [];
|
|
926
|
+
let initialIndex = 0;
|
|
927
|
+
const indexMap = /* @__PURE__ */ new Map();
|
|
928
|
+
const snapMapCache = /* @__PURE__ */ new WeakMap();
|
|
929
|
+
const registerSnapMap = () => {
|
|
930
|
+
const cache = snapCache$1.get(vObject);
|
|
931
|
+
const latestSnap = cache == null ? void 0 : cache[1];
|
|
932
|
+
if (latestSnap && !snapMapCache.has(latestSnap)) {
|
|
933
|
+
const clonedMap = new Map(indexMap);
|
|
934
|
+
snapMapCache.set(latestSnap, clonedMap);
|
|
935
|
+
}
|
|
936
|
+
};
|
|
937
|
+
const getMapForThis = (x) => snapMapCache.get(x) || indexMap;
|
|
938
|
+
if (entries) {
|
|
939
|
+
if (typeof entries[Symbol.iterator] !== "function") {
|
|
940
|
+
throw new TypeError(
|
|
941
|
+
"proxyMap:\n initial state must be iterable\n tip: structure should be [[key, value]]"
|
|
942
|
+
);
|
|
943
|
+
}
|
|
944
|
+
for (const [key, value] of entries) {
|
|
945
|
+
indexMap.set(key, initialIndex);
|
|
946
|
+
initialData[initialIndex++] = value;
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
const vObject = {
|
|
950
|
+
data: initialData,
|
|
951
|
+
index: initialIndex,
|
|
952
|
+
epoch: 0,
|
|
953
|
+
get size() {
|
|
954
|
+
if (!isProxy$1(this)) {
|
|
955
|
+
registerSnapMap();
|
|
956
|
+
}
|
|
957
|
+
const map = getMapForThis(this);
|
|
958
|
+
return map.size;
|
|
959
|
+
},
|
|
960
|
+
get(key) {
|
|
961
|
+
const map = getMapForThis(this);
|
|
962
|
+
const index = map.get(key);
|
|
963
|
+
if (index === void 0) {
|
|
964
|
+
this.epoch;
|
|
965
|
+
return void 0;
|
|
966
|
+
}
|
|
967
|
+
return this.data[index];
|
|
968
|
+
},
|
|
969
|
+
has(key) {
|
|
970
|
+
const map = getMapForThis(this);
|
|
971
|
+
this.epoch;
|
|
972
|
+
return map.has(key);
|
|
973
|
+
},
|
|
974
|
+
set(key, value) {
|
|
975
|
+
if (!isProxy$1(this)) {
|
|
976
|
+
throw new Error("Cannot perform mutations on a snapshot");
|
|
977
|
+
}
|
|
978
|
+
const index = indexMap.get(key);
|
|
979
|
+
if (index === void 0) {
|
|
980
|
+
indexMap.set(key, this.index);
|
|
981
|
+
this.data[this.index++] = value;
|
|
982
|
+
} else {
|
|
983
|
+
this.data[index] = value;
|
|
984
|
+
}
|
|
985
|
+
this.epoch++;
|
|
986
|
+
return this;
|
|
987
|
+
},
|
|
988
|
+
delete(key) {
|
|
989
|
+
if (!isProxy$1(this)) {
|
|
990
|
+
throw new Error("Cannot perform mutations on a snapshot");
|
|
991
|
+
}
|
|
992
|
+
const index = indexMap.get(key);
|
|
993
|
+
if (index === void 0) {
|
|
994
|
+
return false;
|
|
995
|
+
}
|
|
996
|
+
delete this.data[index];
|
|
997
|
+
indexMap.delete(key);
|
|
998
|
+
this.epoch++;
|
|
999
|
+
return true;
|
|
1000
|
+
},
|
|
1001
|
+
clear() {
|
|
1002
|
+
if (!isProxy$1(this)) {
|
|
1003
|
+
throw new Error("Cannot perform mutations on a snapshot");
|
|
1004
|
+
}
|
|
1005
|
+
this.data.length = 0;
|
|
1006
|
+
this.index = 0;
|
|
1007
|
+
this.epoch++;
|
|
1008
|
+
indexMap.clear();
|
|
1009
|
+
},
|
|
1010
|
+
forEach(cb) {
|
|
1011
|
+
this.epoch;
|
|
1012
|
+
const map = getMapForThis(this);
|
|
1013
|
+
map.forEach((index, key) => {
|
|
1014
|
+
cb(this.data[index], key, this);
|
|
1015
|
+
});
|
|
1016
|
+
},
|
|
1017
|
+
*entries() {
|
|
1018
|
+
this.epoch;
|
|
1019
|
+
const map = getMapForThis(this);
|
|
1020
|
+
for (const [key, index] of map) {
|
|
1021
|
+
yield [key, this.data[index]];
|
|
1022
|
+
}
|
|
1023
|
+
},
|
|
1024
|
+
*keys() {
|
|
1025
|
+
this.epoch;
|
|
1026
|
+
const map = getMapForThis(this);
|
|
1027
|
+
for (const key of map.keys()) {
|
|
1028
|
+
yield key;
|
|
1029
|
+
}
|
|
1030
|
+
},
|
|
1031
|
+
*values() {
|
|
1032
|
+
this.epoch;
|
|
1033
|
+
const map = getMapForThis(this);
|
|
1034
|
+
for (const index of map.values()) {
|
|
1035
|
+
yield this.data[index];
|
|
1036
|
+
}
|
|
1037
|
+
},
|
|
1038
|
+
[Symbol.iterator]() {
|
|
1039
|
+
return this.entries();
|
|
1040
|
+
},
|
|
1041
|
+
get [Symbol.toStringTag]() {
|
|
1042
|
+
return "Map";
|
|
1043
|
+
},
|
|
1044
|
+
toJSON() {
|
|
1045
|
+
return new Map(this.entries());
|
|
1046
|
+
}
|
|
1047
|
+
};
|
|
1048
|
+
const proxiedObject = proxy(vObject);
|
|
1049
|
+
Object.defineProperties(proxiedObject, {
|
|
1050
|
+
size: { enumerable: false },
|
|
1051
|
+
index: { enumerable: false },
|
|
1052
|
+
epoch: { enumerable: false },
|
|
1053
|
+
data: { enumerable: false },
|
|
1054
|
+
toJSON: { enumerable: false }
|
|
1055
|
+
});
|
|
1056
|
+
Object.seal(proxiedObject);
|
|
1057
|
+
return proxiedObject;
|
|
1058
|
+
}
|
|
995
1059
|
var { proxyStateMap: proxyStateMap2, snapCache: snapCache2 } = unstable_getInternalStates();
|
|
996
1060
|
|
|
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
|
-
)
|
|
1061
|
+
// src/components/utils/Trigger.ts
|
|
1062
|
+
var pendingTasks = proxyMap();
|
|
1063
|
+
function createTracker(exposer) {
|
|
1064
|
+
const Component = () => {
|
|
1065
|
+
try {
|
|
1066
|
+
exposer.deferred.resolve(exposer.fn(...exposer.args));
|
|
1067
|
+
} catch (error) {
|
|
1068
|
+
exposer.deferred.reject(error);
|
|
1069
|
+
}
|
|
1070
|
+
return null;
|
|
1071
|
+
};
|
|
1072
|
+
Component.key = exposer.id;
|
|
1073
|
+
return Component;
|
|
1074
|
+
}
|
|
1075
|
+
function renderTracker(Tracker) {
|
|
1076
|
+
return (0, import_react8.createElement)(Tracker, { key: Tracker.key });
|
|
1077
|
+
}
|
|
1078
|
+
function Trigger() {
|
|
1079
|
+
const values = [...useSnapshot(pendingTasks).values()];
|
|
1080
|
+
return values.map(createTracker).map(renderTracker);
|
|
1081
|
+
}
|
|
1082
|
+
Trigger.id = 0;
|
|
1083
|
+
Trigger.tasks = pendingTasks;
|
|
1084
|
+
|
|
1085
|
+
// src/hooks/ref.ts
|
|
1086
|
+
var import_react9 = __toESM(require_react(), 1);
|
|
1087
|
+
function ref2(value) {
|
|
1088
|
+
function define(value2) {
|
|
1089
|
+
if (typeof value2 === "function")
|
|
1090
|
+
return (prev) => define(value2(prev.value));
|
|
1091
|
+
return Object.defineProperty({}, "value", {
|
|
1092
|
+
set: (action) => set(define(action)),
|
|
1093
|
+
get: () => value2,
|
|
1094
|
+
enumerable: true
|
|
1095
|
+
});
|
|
1096
|
+
}
|
|
1097
|
+
const [ref3, set] = (0, import_react9.useState)(define(value));
|
|
1098
|
+
return ref3;
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
// src/hooks/useAsyncCallback.ts
|
|
1102
|
+
var import_react10 = __toESM(require_react(), 1);
|
|
1103
|
+
function useAsyncCallback(fun) {
|
|
1104
|
+
const [state, set] = (0, import_react10.useState)({ loading: false });
|
|
1105
|
+
async function execute(...args) {
|
|
1106
|
+
set({ loading: true });
|
|
1107
|
+
return fun(...args).then((value) => {
|
|
1108
|
+
set({ loading: false });
|
|
1109
|
+
return value;
|
|
1110
|
+
}).catch((err) => {
|
|
1111
|
+
set({ loading: false, error: err });
|
|
1112
|
+
return Promise.reject(err);
|
|
1113
|
+
});
|
|
1114
|
+
}
|
|
1115
|
+
return [state.loading, execute, state.error];
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
// src/hooks/useAsyncState.ts
|
|
1119
|
+
var import_react11 = __toESM(require_react(), 1);
|
|
1120
|
+
function useAsyncState(fun, deps = [], options) {
|
|
1121
|
+
const [value, set] = (0, import_react11.useState)(options?.initial);
|
|
1122
|
+
const [loading, execute, error] = useAsyncCallback(async (...args) => fun(...args).then(set));
|
|
1123
|
+
(0, import_react11.useEffect)(
|
|
1026
1124
|
() => {
|
|
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;
|
|
1125
|
+
execute();
|
|
1040
1126
|
},
|
|
1041
|
-
|
|
1127
|
+
deps
|
|
1042
1128
|
);
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1129
|
+
return [{ value, loading, error }, execute];
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
// src/hooks/useDebounce.ts
|
|
1133
|
+
var import_react12 = __toESM(require_react(), 1);
|
|
1134
|
+
function useDebounce(value, delay) {
|
|
1135
|
+
const [debouncedValue, setDebouncedValue] = (0, import_react12.useState)(value);
|
|
1136
|
+
(0, import_react12.useEffect)(() => {
|
|
1137
|
+
const handler = setTimeout(() => setDebouncedValue(value), delay);
|
|
1138
|
+
return () => clearTimeout(handler);
|
|
1139
|
+
}, [value, delay]);
|
|
1140
|
+
return debouncedValue;
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
// ../../node_modules/.pnpm/mitt@3.0.1/node_modules/mitt/dist/mitt.mjs
|
|
1144
|
+
function mitt_default(n2) {
|
|
1145
|
+
return { all: n2 = n2 || /* @__PURE__ */ new Map(), on: function(t2, e2) {
|
|
1146
|
+
var i2 = n2.get(t2);
|
|
1147
|
+
i2 ? i2.push(e2) : n2.set(t2, [e2]);
|
|
1148
|
+
}, off: function(t2, e2) {
|
|
1149
|
+
var i2 = n2.get(t2);
|
|
1150
|
+
i2 && (e2 ? i2.splice(i2.indexOf(e2) >>> 0, 1) : n2.set(t2, []));
|
|
1151
|
+
}, emit: function(t2, e2) {
|
|
1152
|
+
var i2 = n2.get(t2);
|
|
1153
|
+
i2 && i2.slice().map(function(n3) {
|
|
1154
|
+
n3(e2);
|
|
1155
|
+
}), (i2 = n2.get("*")) && i2.slice().map(function(n3) {
|
|
1156
|
+
n3(t2, e2);
|
|
1157
|
+
});
|
|
1158
|
+
} };
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
// src/hooks/useEventBus.ts
|
|
1162
|
+
var import_react13 = __toESM(require_react(), 1);
|
|
1163
|
+
var emitter = mitt_default();
|
|
1164
|
+
function useEventBus(key) {
|
|
1165
|
+
const onRef = (0, import_react13.useRef)();
|
|
1166
|
+
function on(listener) {
|
|
1167
|
+
emitter.on(key, listener);
|
|
1168
|
+
onRef.current = listener;
|
|
1169
|
+
(0, import_react13.useEffect)(() => {
|
|
1170
|
+
if (!onRef.current)
|
|
1171
|
+
return;
|
|
1172
|
+
emitter.off(key, onRef.current);
|
|
1173
|
+
emitter.on(key, listener);
|
|
1174
|
+
onRef.current = listener;
|
|
1175
|
+
return () => emitter.off(key, listener);
|
|
1176
|
+
}, [listener]);
|
|
1049
1177
|
}
|
|
1050
|
-
|
|
1051
|
-
|
|
1178
|
+
function emit(event) {
|
|
1179
|
+
emitter.emit(key, event);
|
|
1180
|
+
}
|
|
1181
|
+
function off(listener) {
|
|
1182
|
+
emitter.off(key, listener);
|
|
1183
|
+
}
|
|
1184
|
+
return {
|
|
1185
|
+
on,
|
|
1186
|
+
emit,
|
|
1187
|
+
off
|
|
1188
|
+
};
|
|
1052
1189
|
}
|
|
1053
1190
|
|
|
1054
|
-
//
|
|
1055
|
-
var
|
|
1191
|
+
// ../../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
|
|
1192
|
+
var import_react14 = __toESM(require_react());
|
|
1193
|
+
var useEffectOnce = function(effect) {
|
|
1194
|
+
(0, import_react14.useEffect)(effect, []);
|
|
1195
|
+
};
|
|
1196
|
+
var useEffectOnce_default = useEffectOnce;
|
|
1056
1197
|
|
|
1057
|
-
//
|
|
1058
|
-
function
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
}
|
|
1062
|
-
|
|
1198
|
+
// ../../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
|
|
1199
|
+
var useMount = function(fn) {
|
|
1200
|
+
useEffectOnce_default(function() {
|
|
1201
|
+
fn();
|
|
1202
|
+
});
|
|
1203
|
+
};
|
|
1204
|
+
var useMount_default = useMount;
|
|
1205
|
+
|
|
1206
|
+
// src/hooks/useFetchIntercept.ts
|
|
1207
|
+
function useFetchResponseIntercept(intercept) {
|
|
1208
|
+
useMount_default(() => fetchResponseIntercept(intercept));
|
|
1209
|
+
}
|
|
1210
|
+
function useFetchRequestIntercept(intercept) {
|
|
1211
|
+
useMount_default(() => fetchRequestIntercept(intercept));
|
|
1212
|
+
}
|
|
1213
|
+
function fetchResponseIntercept(intercept) {
|
|
1214
|
+
const { fetch: originalFetch } = window;
|
|
1215
|
+
window.fetch = async (...args) => {
|
|
1216
|
+
const [resource, config] = args;
|
|
1217
|
+
const response = await originalFetch(resource, config);
|
|
1218
|
+
return intercept(response);
|
|
1219
|
+
};
|
|
1220
|
+
}
|
|
1221
|
+
function fetchRequestIntercept(intercept) {
|
|
1222
|
+
const { fetch: originalFetch } = window;
|
|
1223
|
+
window.fetch = async (...args) => {
|
|
1224
|
+
const [resource, config] = args;
|
|
1225
|
+
return intercept(originalFetch, resource, config);
|
|
1226
|
+
};
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
// src/hooks/useMounted.ts
|
|
1230
|
+
var import_react15 = __toESM(require_react(), 1);
|
|
1231
|
+
function useMounted() {
|
|
1232
|
+
const [mounted, setMounted] = (0, import_react15.useState)(false);
|
|
1233
|
+
(0, import_react15.useEffect)(() => setMounted(true), []);
|
|
1234
|
+
return mounted;
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
// src/hooks/useWatch.ts
|
|
1238
|
+
var import_react16 = __toESM(require_react(), 1);
|
|
1239
|
+
function useWatch(source, callback, options = {}) {
|
|
1240
|
+
const firstUpdate = (0, import_react16.useRef)(false);
|
|
1241
|
+
const then = (0, import_react16.useRef)();
|
|
1242
|
+
const deps = (0, import_react16.useMemo)(
|
|
1243
|
+
() => Array.isArray(source) ? source : [source],
|
|
1244
|
+
[source]
|
|
1245
|
+
);
|
|
1246
|
+
(0, import_react16.useEffect)(() => {
|
|
1247
|
+
if (!firstUpdate.current)
|
|
1248
|
+
recordFirst();
|
|
1249
|
+
else
|
|
1250
|
+
callback(source);
|
|
1251
|
+
}, deps);
|
|
1252
|
+
async function recordFirst() {
|
|
1253
|
+
if (then.current)
|
|
1254
|
+
return;
|
|
1255
|
+
then.current = Promise.resolve(source);
|
|
1256
|
+
then.current.then(() => firstUpdate.current = true);
|
|
1257
|
+
if (options.immediate)
|
|
1258
|
+
then.current.then((value) => callback(value));
|
|
1063
1259
|
}
|
|
1064
1260
|
}
|
|
1065
1261
|
|
|
1262
|
+
// src/hooks/useWhenever.ts
|
|
1263
|
+
function useWhenever(source, cb, options) {
|
|
1264
|
+
useWatch(source, () => source && cb(source), options);
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
// src/storage/defineStore.ts
|
|
1268
|
+
var import_react17 = __toESM(require_react(), 1);
|
|
1269
|
+
|
|
1066
1270
|
// src/storage/persistant.ts
|
|
1067
1271
|
function proxyWithPersistant(keyOrOptions, initialObject) {
|
|
1068
1272
|
let options;
|
|
@@ -1113,10 +1317,10 @@ var LibReact = (() => {
|
|
|
1113
1317
|
Object.assign($state, patch);
|
|
1114
1318
|
}
|
|
1115
1319
|
function $signal(fn) {
|
|
1116
|
-
return (0,
|
|
1320
|
+
return (0, import_react17.createElement)(() => fn(useSnapshot($state)));
|
|
1117
1321
|
}
|
|
1118
1322
|
$signal.status = function(fn) {
|
|
1119
|
-
return (0,
|
|
1323
|
+
return (0, import_react17.createElement)(() => fn(useSnapshot($status)));
|
|
1120
1324
|
};
|
|
1121
1325
|
return {
|
|
1122
1326
|
$subscribe,
|
|
@@ -1129,7 +1333,7 @@ var LibReact = (() => {
|
|
|
1129
1333
|
...$actions
|
|
1130
1334
|
};
|
|
1131
1335
|
}
|
|
1132
|
-
function
|
|
1336
|
+
function track2(action, status) {
|
|
1133
1337
|
let loadings = 0;
|
|
1134
1338
|
const tracking = () => loadings++ === 0 && (status.loading = true);
|
|
1135
1339
|
const done = () => !--loadings && (status.loading = false);
|
|
@@ -1156,7 +1360,7 @@ var LibReact = (() => {
|
|
|
1156
1360
|
function setupActions($state, actions, $actions, $status) {
|
|
1157
1361
|
for (const key in actions) {
|
|
1158
1362
|
$status[key] = { finished: false, loading: false, error: null };
|
|
1159
|
-
$actions[key] =
|
|
1363
|
+
$actions[key] = track2(actions[key].bind($state), $status[key]);
|
|
1160
1364
|
}
|
|
1161
1365
|
}
|
|
1162
1366
|
function setupGetters(state, $state, getters, $getters) {
|