@hairy/react-lib 1.47.0 → 1.50.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/{LICENSE.md → LICENSE} +21 -21
- package/README.md +258 -36
- package/dist/index.cjs +412 -769
- package/dist/index.d.cts +258 -0
- package/dist/index.d.mts +258 -0
- package/dist/index.mjs +447 -0
- package/package.json +26 -21
- package/dist/index.d.ts +0 -374
- package/dist/index.global.js +0 -1550
- package/dist/index.js +0 -790
package/dist/index.global.js
DELETED
|
@@ -1,1550 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var LibReact = (() => {
|
|
3
|
-
var __create = Object.create;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
10
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
11
|
-
};
|
|
12
|
-
var __export = (target, all) => {
|
|
13
|
-
for (var name in all)
|
|
14
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
15
|
-
};
|
|
16
|
-
var __copyProps = (to, from, except, desc) => {
|
|
17
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
-
for (let key of __getOwnPropNames(from))
|
|
19
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
20
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
|
-
}
|
|
22
|
-
return to;
|
|
23
|
-
};
|
|
24
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
25
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
30
|
-
mod
|
|
31
|
-
));
|
|
32
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
33
|
-
|
|
34
|
-
// globals:react
|
|
35
|
-
var require_react = __commonJS({
|
|
36
|
-
"globals:react"(exports, module) {
|
|
37
|
-
"use strict";
|
|
38
|
-
module.exports = React;
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
// src/index.ts
|
|
43
|
-
var index_exports = {};
|
|
44
|
-
__export(index_exports, {
|
|
45
|
-
Case: () => Case,
|
|
46
|
-
Default: () => Default,
|
|
47
|
-
Else: () => Else,
|
|
48
|
-
If: () => If,
|
|
49
|
-
Injector: () => Injector,
|
|
50
|
-
Switch: () => Switch,
|
|
51
|
-
Then: () => Then,
|
|
52
|
-
Trigger: () => Trigger,
|
|
53
|
-
Unless: () => Unless,
|
|
54
|
-
cls: () => cls,
|
|
55
|
-
defienAsyncStore: () => defienAsyncStore,
|
|
56
|
-
defineStore: () => defineStore,
|
|
57
|
-
defineStoreAsync: () => defineStoreAsync,
|
|
58
|
-
proxyWithPersistant: () => proxyWithPersistant,
|
|
59
|
-
track: () => track,
|
|
60
|
-
tryUseCallback: () => tryUseCallback,
|
|
61
|
-
tryUseEffect: () => tryUseEffect,
|
|
62
|
-
tryUseInsertionEffect: () => tryUseInsertionEffect,
|
|
63
|
-
tryUseReducer: () => tryUseReducer,
|
|
64
|
-
tryUseRef: () => tryUseRef,
|
|
65
|
-
tryUseState: () => tryUseState,
|
|
66
|
-
tryUseUpdate: () => tryUseUpdate,
|
|
67
|
-
useAsyncCallback: () => useAsyncCallback,
|
|
68
|
-
useAsyncState: () => useAsyncState,
|
|
69
|
-
useDebounce: () => useDebounce,
|
|
70
|
-
useEventBus: () => useEventBus,
|
|
71
|
-
useFetchRequestIntercept: () => useFetchRequestIntercept,
|
|
72
|
-
useFetchResponseIntercept: () => useFetchResponseIntercept,
|
|
73
|
-
useMounted: () => useMounted,
|
|
74
|
-
useOffsetPagination: () => useOffsetPagination,
|
|
75
|
-
useStatus: () => useStatus,
|
|
76
|
-
useStore: () => useStore,
|
|
77
|
-
useUpdate: () => useUpdate,
|
|
78
|
-
useWatch: () => useWatch,
|
|
79
|
-
useWhenever: () => useWhenever,
|
|
80
|
-
wrapper: () => wrapper
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
// src/utils/cls.ts
|
|
84
|
-
var hasOwn = {}.hasOwnProperty;
|
|
85
|
-
function cls(...args) {
|
|
86
|
-
let classes = "";
|
|
87
|
-
for (let i = 0; i < args.length; i++) {
|
|
88
|
-
const arg = args[i];
|
|
89
|
-
if (arg)
|
|
90
|
-
classes = cls.append(classes, cls.parse(arg));
|
|
91
|
-
}
|
|
92
|
-
return classes;
|
|
93
|
-
}
|
|
94
|
-
cls.parse = function(arg) {
|
|
95
|
-
if (typeof arg === "string")
|
|
96
|
-
return arg;
|
|
97
|
-
if (typeof arg !== "object")
|
|
98
|
-
return "";
|
|
99
|
-
if (Array.isArray(arg))
|
|
100
|
-
return cls.apply(null, arg);
|
|
101
|
-
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes("[native code]"))
|
|
102
|
-
return cls.toString();
|
|
103
|
-
let classes = "";
|
|
104
|
-
for (const key in arg) {
|
|
105
|
-
if (hasOwn.call(arg, key) && arg[key])
|
|
106
|
-
classes = cls.append(classes, key);
|
|
107
|
-
}
|
|
108
|
-
return classes;
|
|
109
|
-
};
|
|
110
|
-
cls.append = function(value, newClass) {
|
|
111
|
-
if (!newClass)
|
|
112
|
-
return value;
|
|
113
|
-
return value ? `${value} ${newClass}` : newClass;
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_freeGlobal.js
|
|
117
|
-
var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
|
|
118
|
-
var freeGlobal_default = freeGlobal;
|
|
119
|
-
|
|
120
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_root.js
|
|
121
|
-
var freeSelf = typeof self == "object" && self && self.Object === Object && self;
|
|
122
|
-
var root = freeGlobal_default || freeSelf || Function("return this")();
|
|
123
|
-
var root_default = root;
|
|
124
|
-
|
|
125
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Symbol.js
|
|
126
|
-
var Symbol2 = root_default.Symbol;
|
|
127
|
-
var Symbol_default = Symbol2;
|
|
128
|
-
|
|
129
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getRawTag.js
|
|
130
|
-
var objectProto = Object.prototype;
|
|
131
|
-
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
132
|
-
var nativeObjectToString = objectProto.toString;
|
|
133
|
-
var symToStringTag = Symbol_default ? Symbol_default.toStringTag : void 0;
|
|
134
|
-
function getRawTag(value) {
|
|
135
|
-
var isOwn = hasOwnProperty.call(value, symToStringTag), tag = value[symToStringTag];
|
|
136
|
-
try {
|
|
137
|
-
value[symToStringTag] = void 0;
|
|
138
|
-
var unmasked = true;
|
|
139
|
-
} catch (e) {
|
|
140
|
-
}
|
|
141
|
-
var result = nativeObjectToString.call(value);
|
|
142
|
-
if (unmasked) {
|
|
143
|
-
if (isOwn) {
|
|
144
|
-
value[symToStringTag] = tag;
|
|
145
|
-
} else {
|
|
146
|
-
delete value[symToStringTag];
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
return result;
|
|
150
|
-
}
|
|
151
|
-
var getRawTag_default = getRawTag;
|
|
152
|
-
|
|
153
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_objectToString.js
|
|
154
|
-
var objectProto2 = Object.prototype;
|
|
155
|
-
var nativeObjectToString2 = objectProto2.toString;
|
|
156
|
-
function objectToString(value) {
|
|
157
|
-
return nativeObjectToString2.call(value);
|
|
158
|
-
}
|
|
159
|
-
var objectToString_default = objectToString;
|
|
160
|
-
|
|
161
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseGetTag.js
|
|
162
|
-
var nullTag = "[object Null]";
|
|
163
|
-
var undefinedTag = "[object Undefined]";
|
|
164
|
-
var symToStringTag2 = Symbol_default ? Symbol_default.toStringTag : void 0;
|
|
165
|
-
function baseGetTag(value) {
|
|
166
|
-
if (value == null) {
|
|
167
|
-
return value === void 0 ? undefinedTag : nullTag;
|
|
168
|
-
}
|
|
169
|
-
return symToStringTag2 && symToStringTag2 in Object(value) ? getRawTag_default(value) : objectToString_default(value);
|
|
170
|
-
}
|
|
171
|
-
var baseGetTag_default = baseGetTag;
|
|
172
|
-
|
|
173
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isObject.js
|
|
174
|
-
function isObject(value) {
|
|
175
|
-
var type = typeof value;
|
|
176
|
-
return value != null && (type == "object" || type == "function");
|
|
177
|
-
}
|
|
178
|
-
var isObject_default = isObject;
|
|
179
|
-
|
|
180
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isFunction.js
|
|
181
|
-
var asyncTag = "[object AsyncFunction]";
|
|
182
|
-
var funcTag = "[object Function]";
|
|
183
|
-
var genTag = "[object GeneratorFunction]";
|
|
184
|
-
var proxyTag = "[object Proxy]";
|
|
185
|
-
function isFunction(value) {
|
|
186
|
-
if (!isObject_default(value)) {
|
|
187
|
-
return false;
|
|
188
|
-
}
|
|
189
|
-
var tag = baseGetTag_default(value);
|
|
190
|
-
return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
|
|
191
|
-
}
|
|
192
|
-
var isFunction_default = isFunction;
|
|
193
|
-
|
|
194
|
-
// ../util-core/src/util/noop.ts
|
|
195
|
-
var noop = () => {
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
// ../util-core/src/util/deferred.ts
|
|
199
|
-
var Deferred = class extends Promise {
|
|
200
|
-
resolve;
|
|
201
|
-
reject;
|
|
202
|
-
constructor(executor = noop) {
|
|
203
|
-
let _resolve, _reject;
|
|
204
|
-
super((resolve_, reject_) => {
|
|
205
|
-
_resolve = resolve_;
|
|
206
|
-
_reject = reject_;
|
|
207
|
-
return executor(resolve_, reject_);
|
|
208
|
-
});
|
|
209
|
-
this.resolve = (value) => {
|
|
210
|
-
_resolve(value);
|
|
211
|
-
return this;
|
|
212
|
-
};
|
|
213
|
-
this.reject = (reason) => {
|
|
214
|
-
_reject(reason);
|
|
215
|
-
return this;
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
// ../util-core/src/util/json.ts
|
|
221
|
-
function tryParseJson(text) {
|
|
222
|
-
try {
|
|
223
|
-
return JSON.parse(text || "");
|
|
224
|
-
} catch {
|
|
225
|
-
return void 0;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
// ../../node_modules/.pnpm/proxy-compare@3.0.1/node_modules/proxy-compare/dist/index.js
|
|
230
|
-
var TRACK_MEMO_SYMBOL = Symbol();
|
|
231
|
-
var GET_ORIGINAL_SYMBOL = Symbol();
|
|
232
|
-
var AFFECTED_PROPERTY = "a";
|
|
233
|
-
var IS_TARGET_COPIED_PROPERTY = "f";
|
|
234
|
-
var PROXY_PROPERTY = "p";
|
|
235
|
-
var PROXY_CACHE_PROPERTY = "c";
|
|
236
|
-
var TARGET_CACHE_PROPERTY = "t";
|
|
237
|
-
var HAS_KEY_PROPERTY = "h";
|
|
238
|
-
var ALL_OWN_KEYS_PROPERTY = "w";
|
|
239
|
-
var HAS_OWN_KEY_PROPERTY = "o";
|
|
240
|
-
var KEYS_PROPERTY = "k";
|
|
241
|
-
var newProxy = (target, handler) => new Proxy(target, handler);
|
|
242
|
-
var getProto = Object.getPrototypeOf;
|
|
243
|
-
var objectsToTrack = /* @__PURE__ */ new WeakMap();
|
|
244
|
-
var isObjectToTrack = (obj) => obj && (objectsToTrack.has(obj) ? objectsToTrack.get(obj) : getProto(obj) === Object.prototype || getProto(obj) === Array.prototype);
|
|
245
|
-
var isObject2 = (x) => typeof x === "object" && x !== null;
|
|
246
|
-
var needsToCopyTargetObject = (obj) => Object.values(Object.getOwnPropertyDescriptors(obj)).some((descriptor) => !descriptor.configurable && !descriptor.writable);
|
|
247
|
-
var copyTargetObject = (obj) => {
|
|
248
|
-
if (Array.isArray(obj)) {
|
|
249
|
-
return Array.from(obj);
|
|
250
|
-
}
|
|
251
|
-
const descriptors = Object.getOwnPropertyDescriptors(obj);
|
|
252
|
-
Object.values(descriptors).forEach((desc) => {
|
|
253
|
-
desc.configurable = true;
|
|
254
|
-
});
|
|
255
|
-
return Object.create(getProto(obj), descriptors);
|
|
256
|
-
};
|
|
257
|
-
var createProxyHandler = (origObj, isTargetCopied) => {
|
|
258
|
-
const state = {
|
|
259
|
-
[IS_TARGET_COPIED_PROPERTY]: isTargetCopied
|
|
260
|
-
};
|
|
261
|
-
let trackObject = false;
|
|
262
|
-
const recordUsage = (type, key) => {
|
|
263
|
-
if (!trackObject) {
|
|
264
|
-
let used = state[AFFECTED_PROPERTY].get(origObj);
|
|
265
|
-
if (!used) {
|
|
266
|
-
used = {};
|
|
267
|
-
state[AFFECTED_PROPERTY].set(origObj, used);
|
|
268
|
-
}
|
|
269
|
-
if (type === ALL_OWN_KEYS_PROPERTY) {
|
|
270
|
-
used[ALL_OWN_KEYS_PROPERTY] = true;
|
|
271
|
-
} else {
|
|
272
|
-
let set = used[type];
|
|
273
|
-
if (!set) {
|
|
274
|
-
set = /* @__PURE__ */ new Set();
|
|
275
|
-
used[type] = set;
|
|
276
|
-
}
|
|
277
|
-
set.add(key);
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
};
|
|
281
|
-
const recordObjectAsUsed = () => {
|
|
282
|
-
trackObject = true;
|
|
283
|
-
state[AFFECTED_PROPERTY].delete(origObj);
|
|
284
|
-
};
|
|
285
|
-
const handler = {
|
|
286
|
-
get(target, key) {
|
|
287
|
-
if (key === GET_ORIGINAL_SYMBOL) {
|
|
288
|
-
return origObj;
|
|
289
|
-
}
|
|
290
|
-
recordUsage(KEYS_PROPERTY, key);
|
|
291
|
-
return createProxy(Reflect.get(target, key), state[AFFECTED_PROPERTY], state[PROXY_CACHE_PROPERTY], state[TARGET_CACHE_PROPERTY]);
|
|
292
|
-
},
|
|
293
|
-
has(target, key) {
|
|
294
|
-
if (key === TRACK_MEMO_SYMBOL) {
|
|
295
|
-
recordObjectAsUsed();
|
|
296
|
-
return true;
|
|
297
|
-
}
|
|
298
|
-
recordUsage(HAS_KEY_PROPERTY, key);
|
|
299
|
-
return Reflect.has(target, key);
|
|
300
|
-
},
|
|
301
|
-
getOwnPropertyDescriptor(target, key) {
|
|
302
|
-
recordUsage(HAS_OWN_KEY_PROPERTY, key);
|
|
303
|
-
return Reflect.getOwnPropertyDescriptor(target, key);
|
|
304
|
-
},
|
|
305
|
-
ownKeys(target) {
|
|
306
|
-
recordUsage(ALL_OWN_KEYS_PROPERTY);
|
|
307
|
-
return Reflect.ownKeys(target);
|
|
308
|
-
}
|
|
309
|
-
};
|
|
310
|
-
if (isTargetCopied) {
|
|
311
|
-
handler.set = handler.deleteProperty = () => false;
|
|
312
|
-
}
|
|
313
|
-
return [handler, state];
|
|
314
|
-
};
|
|
315
|
-
var getOriginalObject = (obj) => (
|
|
316
|
-
// unwrap proxy
|
|
317
|
-
obj[GET_ORIGINAL_SYMBOL] || // otherwise
|
|
318
|
-
obj
|
|
319
|
-
);
|
|
320
|
-
var createProxy = (obj, affected, proxyCache2, targetCache2) => {
|
|
321
|
-
if (!isObjectToTrack(obj))
|
|
322
|
-
return obj;
|
|
323
|
-
let targetAndCopied = targetCache2 && targetCache2.get(obj);
|
|
324
|
-
if (!targetAndCopied) {
|
|
325
|
-
const target2 = getOriginalObject(obj);
|
|
326
|
-
if (needsToCopyTargetObject(target2)) {
|
|
327
|
-
targetAndCopied = [target2, copyTargetObject(target2)];
|
|
328
|
-
} else {
|
|
329
|
-
targetAndCopied = [target2];
|
|
330
|
-
}
|
|
331
|
-
targetCache2 === null || targetCache2 === void 0 ? void 0 : targetCache2.set(obj, targetAndCopied);
|
|
332
|
-
}
|
|
333
|
-
const [target, copiedTarget] = targetAndCopied;
|
|
334
|
-
let handlerAndState = proxyCache2 && proxyCache2.get(target);
|
|
335
|
-
if (!handlerAndState || handlerAndState[1][IS_TARGET_COPIED_PROPERTY] !== !!copiedTarget) {
|
|
336
|
-
handlerAndState = createProxyHandler(target, !!copiedTarget);
|
|
337
|
-
handlerAndState[1][PROXY_PROPERTY] = newProxy(copiedTarget || target, handlerAndState[0]);
|
|
338
|
-
if (proxyCache2) {
|
|
339
|
-
proxyCache2.set(target, handlerAndState);
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
handlerAndState[1][AFFECTED_PROPERTY] = affected;
|
|
343
|
-
handlerAndState[1][PROXY_CACHE_PROPERTY] = proxyCache2;
|
|
344
|
-
handlerAndState[1][TARGET_CACHE_PROPERTY] = targetCache2;
|
|
345
|
-
return handlerAndState[1][PROXY_PROPERTY];
|
|
346
|
-
};
|
|
347
|
-
var isAllOwnKeysChanged = (prevObj, nextObj) => {
|
|
348
|
-
const prevKeys = Reflect.ownKeys(prevObj);
|
|
349
|
-
const nextKeys = Reflect.ownKeys(nextObj);
|
|
350
|
-
return prevKeys.length !== nextKeys.length || prevKeys.some((k, i) => k !== nextKeys[i]);
|
|
351
|
-
};
|
|
352
|
-
var isChanged = (prevObj, nextObj, affected, cache, isEqual = Object.is) => {
|
|
353
|
-
if (isEqual(prevObj, nextObj)) {
|
|
354
|
-
return false;
|
|
355
|
-
}
|
|
356
|
-
if (!isObject2(prevObj) || !isObject2(nextObj))
|
|
357
|
-
return true;
|
|
358
|
-
const used = affected.get(getOriginalObject(prevObj));
|
|
359
|
-
if (!used)
|
|
360
|
-
return true;
|
|
361
|
-
if (cache) {
|
|
362
|
-
const hit = cache.get(prevObj);
|
|
363
|
-
if (hit === nextObj) {
|
|
364
|
-
return false;
|
|
365
|
-
}
|
|
366
|
-
cache.set(prevObj, nextObj);
|
|
367
|
-
}
|
|
368
|
-
let changed = null;
|
|
369
|
-
for (const key of used[HAS_KEY_PROPERTY] || []) {
|
|
370
|
-
changed = Reflect.has(prevObj, key) !== Reflect.has(nextObj, key);
|
|
371
|
-
if (changed)
|
|
372
|
-
return changed;
|
|
373
|
-
}
|
|
374
|
-
if (used[ALL_OWN_KEYS_PROPERTY] === true) {
|
|
375
|
-
changed = isAllOwnKeysChanged(prevObj, nextObj);
|
|
376
|
-
if (changed)
|
|
377
|
-
return changed;
|
|
378
|
-
} else {
|
|
379
|
-
for (const key of used[HAS_OWN_KEY_PROPERTY] || []) {
|
|
380
|
-
const hasPrev = !!Reflect.getOwnPropertyDescriptor(prevObj, key);
|
|
381
|
-
const hasNext = !!Reflect.getOwnPropertyDescriptor(nextObj, key);
|
|
382
|
-
changed = hasPrev !== hasNext;
|
|
383
|
-
if (changed)
|
|
384
|
-
return changed;
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
for (const key of used[KEYS_PROPERTY] || []) {
|
|
388
|
-
changed = isChanged(prevObj[key], nextObj[key], affected, cache, isEqual);
|
|
389
|
-
if (changed)
|
|
390
|
-
return changed;
|
|
391
|
-
}
|
|
392
|
-
if (changed === null)
|
|
393
|
-
throw new Error("invalid used");
|
|
394
|
-
return changed;
|
|
395
|
-
};
|
|
396
|
-
var getUntracked = (obj) => {
|
|
397
|
-
if (isObjectToTrack(obj)) {
|
|
398
|
-
return obj[GET_ORIGINAL_SYMBOL] || null;
|
|
399
|
-
}
|
|
400
|
-
return null;
|
|
401
|
-
};
|
|
402
|
-
var markToTrack = (obj, mark = true) => {
|
|
403
|
-
objectsToTrack.set(obj, mark);
|
|
404
|
-
};
|
|
405
|
-
var affectedToPathList = (obj, affected, onlyWithValues) => {
|
|
406
|
-
const list = [];
|
|
407
|
-
const seen = /* @__PURE__ */ new WeakSet();
|
|
408
|
-
const walk = (x, path) => {
|
|
409
|
-
var _a, _b, _c;
|
|
410
|
-
if (seen.has(x)) {
|
|
411
|
-
return;
|
|
412
|
-
}
|
|
413
|
-
if (isObject2(x)) {
|
|
414
|
-
seen.add(x);
|
|
415
|
-
}
|
|
416
|
-
const used = isObject2(x) && affected.get(getOriginalObject(x));
|
|
417
|
-
if (used) {
|
|
418
|
-
(_a = used[HAS_KEY_PROPERTY]) === null || _a === void 0 ? void 0 : _a.forEach((key) => {
|
|
419
|
-
const segment = `:has(${String(key)})`;
|
|
420
|
-
list.push(path ? [...path, segment] : [segment]);
|
|
421
|
-
});
|
|
422
|
-
if (used[ALL_OWN_KEYS_PROPERTY] === true) {
|
|
423
|
-
const segment = ":ownKeys";
|
|
424
|
-
list.push(path ? [...path, segment] : [segment]);
|
|
425
|
-
} else {
|
|
426
|
-
(_b = used[HAS_OWN_KEY_PROPERTY]) === null || _b === void 0 ? void 0 : _b.forEach((key) => {
|
|
427
|
-
const segment = `:hasOwn(${String(key)})`;
|
|
428
|
-
list.push(path ? [...path, segment] : [segment]);
|
|
429
|
-
});
|
|
430
|
-
}
|
|
431
|
-
(_c = used[KEYS_PROPERTY]) === null || _c === void 0 ? void 0 : _c.forEach((key) => {
|
|
432
|
-
if (!onlyWithValues || "value" in (Object.getOwnPropertyDescriptor(x, key) || {})) {
|
|
433
|
-
walk(x[key], path ? [...path, key] : [key]);
|
|
434
|
-
}
|
|
435
|
-
});
|
|
436
|
-
} else if (path) {
|
|
437
|
-
list.push(path);
|
|
438
|
-
}
|
|
439
|
-
};
|
|
440
|
-
walk(obj);
|
|
441
|
-
return list;
|
|
442
|
-
};
|
|
443
|
-
|
|
444
|
-
// ../../node_modules/.pnpm/valtio@2.1.4_@types+react@19.1.6_react@19.1.0/node_modules/valtio/esm/vanilla.mjs
|
|
445
|
-
var import_meta = {};
|
|
446
|
-
var isObject3 = (x) => typeof x === "object" && x !== null;
|
|
447
|
-
var canProxyDefault = (x) => isObject3(x) && !refSet.has(x) && (Array.isArray(x) || !(Symbol.iterator in x)) && !(x instanceof WeakMap) && !(x instanceof WeakSet) && !(x instanceof Error) && !(x instanceof Number) && !(x instanceof Date) && !(x instanceof String) && !(x instanceof RegExp) && !(x instanceof ArrayBuffer) && !(x instanceof Promise);
|
|
448
|
-
var createSnapshotDefault = (target, version) => {
|
|
449
|
-
const cache = snapCache.get(target);
|
|
450
|
-
if ((cache == null ? void 0 : cache[0]) === version) {
|
|
451
|
-
return cache[1];
|
|
452
|
-
}
|
|
453
|
-
const snap = Array.isArray(target) ? [] : Object.create(Object.getPrototypeOf(target));
|
|
454
|
-
markToTrack(snap, true);
|
|
455
|
-
snapCache.set(target, [version, snap]);
|
|
456
|
-
Reflect.ownKeys(target).forEach((key) => {
|
|
457
|
-
if (Object.getOwnPropertyDescriptor(snap, key)) {
|
|
458
|
-
return;
|
|
459
|
-
}
|
|
460
|
-
const value = Reflect.get(target, key);
|
|
461
|
-
const { enumerable } = Reflect.getOwnPropertyDescriptor(
|
|
462
|
-
target,
|
|
463
|
-
key
|
|
464
|
-
);
|
|
465
|
-
const desc = {
|
|
466
|
-
value,
|
|
467
|
-
enumerable,
|
|
468
|
-
// This is intentional to avoid copying with proxy-compare.
|
|
469
|
-
// It's still non-writable, so it avoids assigning a value.
|
|
470
|
-
configurable: true
|
|
471
|
-
};
|
|
472
|
-
if (refSet.has(value)) {
|
|
473
|
-
markToTrack(value, false);
|
|
474
|
-
} else if (proxyStateMap.has(value)) {
|
|
475
|
-
const [target2, ensureVersion] = proxyStateMap.get(
|
|
476
|
-
value
|
|
477
|
-
);
|
|
478
|
-
desc.value = createSnapshotDefault(target2, ensureVersion());
|
|
479
|
-
}
|
|
480
|
-
Object.defineProperty(snap, key, desc);
|
|
481
|
-
});
|
|
482
|
-
return Object.preventExtensions(snap);
|
|
483
|
-
};
|
|
484
|
-
var createHandlerDefault = (isInitializing, addPropListener, removePropListener, notifyUpdate) => ({
|
|
485
|
-
deleteProperty(target, prop) {
|
|
486
|
-
const prevValue = Reflect.get(target, prop);
|
|
487
|
-
removePropListener(prop);
|
|
488
|
-
const deleted = Reflect.deleteProperty(target, prop);
|
|
489
|
-
if (deleted) {
|
|
490
|
-
notifyUpdate(["delete", [prop], prevValue]);
|
|
491
|
-
}
|
|
492
|
-
return deleted;
|
|
493
|
-
},
|
|
494
|
-
set(target, prop, value, receiver) {
|
|
495
|
-
const hasPrevValue = !isInitializing() && Reflect.has(target, prop);
|
|
496
|
-
const prevValue = Reflect.get(target, prop, receiver);
|
|
497
|
-
if (hasPrevValue && (objectIs(prevValue, value) || proxyCache.has(value) && objectIs(prevValue, proxyCache.get(value)))) {
|
|
498
|
-
return true;
|
|
499
|
-
}
|
|
500
|
-
removePropListener(prop);
|
|
501
|
-
if (isObject3(value)) {
|
|
502
|
-
value = getUntracked(value) || value;
|
|
503
|
-
}
|
|
504
|
-
const nextValue = !proxyStateMap.has(value) && canProxy(value) ? proxy(value) : value;
|
|
505
|
-
addPropListener(prop, nextValue);
|
|
506
|
-
Reflect.set(target, prop, nextValue, receiver);
|
|
507
|
-
notifyUpdate(["set", [prop], value, prevValue]);
|
|
508
|
-
return true;
|
|
509
|
-
}
|
|
510
|
-
});
|
|
511
|
-
var proxyStateMap = /* @__PURE__ */ new WeakMap();
|
|
512
|
-
var refSet = /* @__PURE__ */ new WeakSet();
|
|
513
|
-
var snapCache = /* @__PURE__ */ new WeakMap();
|
|
514
|
-
var versionHolder = [1, 1];
|
|
515
|
-
var proxyCache = /* @__PURE__ */ new WeakMap();
|
|
516
|
-
var objectIs = Object.is;
|
|
517
|
-
var newProxy2 = (target, handler) => new Proxy(target, handler);
|
|
518
|
-
var canProxy = canProxyDefault;
|
|
519
|
-
var createSnapshot = createSnapshotDefault;
|
|
520
|
-
var createHandler = createHandlerDefault;
|
|
521
|
-
function proxy(baseObject = {}) {
|
|
522
|
-
if (!isObject3(baseObject)) {
|
|
523
|
-
throw new Error("object required");
|
|
524
|
-
}
|
|
525
|
-
const found = proxyCache.get(baseObject);
|
|
526
|
-
if (found) {
|
|
527
|
-
return found;
|
|
528
|
-
}
|
|
529
|
-
let version = versionHolder[0];
|
|
530
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
531
|
-
const notifyUpdate = (op, nextVersion = ++versionHolder[0]) => {
|
|
532
|
-
if (version !== nextVersion) {
|
|
533
|
-
version = nextVersion;
|
|
534
|
-
listeners.forEach((listener) => listener(op, nextVersion));
|
|
535
|
-
}
|
|
536
|
-
};
|
|
537
|
-
let checkVersion = versionHolder[1];
|
|
538
|
-
const ensureVersion = (nextCheckVersion = ++versionHolder[1]) => {
|
|
539
|
-
if (checkVersion !== nextCheckVersion && !listeners.size) {
|
|
540
|
-
checkVersion = nextCheckVersion;
|
|
541
|
-
propProxyStates.forEach(([propProxyState]) => {
|
|
542
|
-
const propVersion = propProxyState[1](nextCheckVersion);
|
|
543
|
-
if (propVersion > version) {
|
|
544
|
-
version = propVersion;
|
|
545
|
-
}
|
|
546
|
-
});
|
|
547
|
-
}
|
|
548
|
-
return version;
|
|
549
|
-
};
|
|
550
|
-
const createPropListener = (prop) => (op, nextVersion) => {
|
|
551
|
-
const newOp = [...op];
|
|
552
|
-
newOp[1] = [prop, ...newOp[1]];
|
|
553
|
-
notifyUpdate(newOp, nextVersion);
|
|
554
|
-
};
|
|
555
|
-
const propProxyStates = /* @__PURE__ */ new Map();
|
|
556
|
-
const addPropListener = (prop, propValue) => {
|
|
557
|
-
const propProxyState = !refSet.has(propValue) && proxyStateMap.get(propValue);
|
|
558
|
-
if (propProxyState) {
|
|
559
|
-
if ((import_meta.env ? import_meta.env.MODE : void 0) !== "production" && propProxyStates.has(prop)) {
|
|
560
|
-
throw new Error("prop listener already exists");
|
|
561
|
-
}
|
|
562
|
-
if (listeners.size) {
|
|
563
|
-
const remove = propProxyState[2](createPropListener(prop));
|
|
564
|
-
propProxyStates.set(prop, [propProxyState, remove]);
|
|
565
|
-
} else {
|
|
566
|
-
propProxyStates.set(prop, [propProxyState]);
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
};
|
|
570
|
-
const removePropListener = (prop) => {
|
|
571
|
-
var _a;
|
|
572
|
-
const entry = propProxyStates.get(prop);
|
|
573
|
-
if (entry) {
|
|
574
|
-
propProxyStates.delete(prop);
|
|
575
|
-
(_a = entry[1]) == null ? void 0 : _a.call(entry);
|
|
576
|
-
}
|
|
577
|
-
};
|
|
578
|
-
const addListener = (listener) => {
|
|
579
|
-
listeners.add(listener);
|
|
580
|
-
if (listeners.size === 1) {
|
|
581
|
-
propProxyStates.forEach(([propProxyState, prevRemove], prop) => {
|
|
582
|
-
if ((import_meta.env ? import_meta.env.MODE : void 0) !== "production" && prevRemove) {
|
|
583
|
-
throw new Error("remove already exists");
|
|
584
|
-
}
|
|
585
|
-
const remove = propProxyState[2](createPropListener(prop));
|
|
586
|
-
propProxyStates.set(prop, [propProxyState, remove]);
|
|
587
|
-
});
|
|
588
|
-
}
|
|
589
|
-
const removeListener = () => {
|
|
590
|
-
listeners.delete(listener);
|
|
591
|
-
if (listeners.size === 0) {
|
|
592
|
-
propProxyStates.forEach(([propProxyState, remove], prop) => {
|
|
593
|
-
if (remove) {
|
|
594
|
-
remove();
|
|
595
|
-
propProxyStates.set(prop, [propProxyState]);
|
|
596
|
-
}
|
|
597
|
-
});
|
|
598
|
-
}
|
|
599
|
-
};
|
|
600
|
-
return removeListener;
|
|
601
|
-
};
|
|
602
|
-
let initializing = true;
|
|
603
|
-
const handler = createHandler(
|
|
604
|
-
() => initializing,
|
|
605
|
-
addPropListener,
|
|
606
|
-
removePropListener,
|
|
607
|
-
notifyUpdate
|
|
608
|
-
);
|
|
609
|
-
const proxyObject = newProxy2(baseObject, handler);
|
|
610
|
-
proxyCache.set(baseObject, proxyObject);
|
|
611
|
-
const proxyState = [baseObject, ensureVersion, addListener];
|
|
612
|
-
proxyStateMap.set(proxyObject, proxyState);
|
|
613
|
-
Reflect.ownKeys(baseObject).forEach((key) => {
|
|
614
|
-
const desc = Object.getOwnPropertyDescriptor(
|
|
615
|
-
baseObject,
|
|
616
|
-
key
|
|
617
|
-
);
|
|
618
|
-
if ("value" in desc && desc.writable) {
|
|
619
|
-
proxyObject[key] = baseObject[key];
|
|
620
|
-
}
|
|
621
|
-
});
|
|
622
|
-
initializing = false;
|
|
623
|
-
return proxyObject;
|
|
624
|
-
}
|
|
625
|
-
function subscribe(proxyObject, callback, notifyInSync) {
|
|
626
|
-
const proxyState = proxyStateMap.get(proxyObject);
|
|
627
|
-
if ((import_meta.env ? import_meta.env.MODE : void 0) !== "production" && !proxyState) {
|
|
628
|
-
console.warn("Please use proxy object");
|
|
629
|
-
}
|
|
630
|
-
let promise;
|
|
631
|
-
const ops = [];
|
|
632
|
-
const addListener = proxyState[2];
|
|
633
|
-
let isListenerActive = false;
|
|
634
|
-
const listener = (op) => {
|
|
635
|
-
ops.push(op);
|
|
636
|
-
if (notifyInSync) {
|
|
637
|
-
callback(ops.splice(0));
|
|
638
|
-
return;
|
|
639
|
-
}
|
|
640
|
-
if (!promise) {
|
|
641
|
-
promise = Promise.resolve().then(() => {
|
|
642
|
-
promise = void 0;
|
|
643
|
-
if (isListenerActive) {
|
|
644
|
-
callback(ops.splice(0));
|
|
645
|
-
}
|
|
646
|
-
});
|
|
647
|
-
}
|
|
648
|
-
};
|
|
649
|
-
const removeListener = addListener(listener);
|
|
650
|
-
isListenerActive = true;
|
|
651
|
-
return () => {
|
|
652
|
-
isListenerActive = false;
|
|
653
|
-
removeListener();
|
|
654
|
-
};
|
|
655
|
-
}
|
|
656
|
-
function snapshot(proxyObject) {
|
|
657
|
-
const proxyState = proxyStateMap.get(proxyObject);
|
|
658
|
-
if ((import_meta.env ? import_meta.env.MODE : void 0) !== "production" && !proxyState) {
|
|
659
|
-
console.warn("Please use proxy object");
|
|
660
|
-
}
|
|
661
|
-
const [target, ensureVersion] = proxyState;
|
|
662
|
-
return createSnapshot(target, ensureVersion());
|
|
663
|
-
}
|
|
664
|
-
function ref(obj) {
|
|
665
|
-
refSet.add(obj);
|
|
666
|
-
return obj;
|
|
667
|
-
}
|
|
668
|
-
function unstable_getInternalStates() {
|
|
669
|
-
return {
|
|
670
|
-
proxyStateMap,
|
|
671
|
-
refSet,
|
|
672
|
-
snapCache,
|
|
673
|
-
versionHolder,
|
|
674
|
-
proxyCache
|
|
675
|
-
};
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
// ../../node_modules/.pnpm/valtio@2.1.4_@types+react@19.1.6_react@19.1.0/node_modules/valtio/esm/react.mjs
|
|
679
|
-
var import_react = __toESM(require_react(), 1);
|
|
680
|
-
var import_meta2 = {};
|
|
681
|
-
var useAffectedDebugValue = (state, affected) => {
|
|
682
|
-
const pathList = (0, import_react.useRef)(void 0);
|
|
683
|
-
(0, import_react.useEffect)(() => {
|
|
684
|
-
pathList.current = affectedToPathList(state, affected, true);
|
|
685
|
-
});
|
|
686
|
-
(0, import_react.useDebugValue)(pathList.current);
|
|
687
|
-
};
|
|
688
|
-
var condUseAffectedDebugValue = useAffectedDebugValue;
|
|
689
|
-
var targetCache = /* @__PURE__ */ new WeakMap();
|
|
690
|
-
function useSnapshot(proxyObject, options) {
|
|
691
|
-
const notifyInSync = options == null ? void 0 : options.sync;
|
|
692
|
-
const affected = (0, import_react.useMemo)(
|
|
693
|
-
() => proxyObject && /* @__PURE__ */ new WeakMap(),
|
|
694
|
-
[proxyObject]
|
|
695
|
-
);
|
|
696
|
-
const lastSnapshot = (0, import_react.useRef)(void 0);
|
|
697
|
-
let inRender = true;
|
|
698
|
-
const currSnapshot = (0, import_react.useSyncExternalStore)(
|
|
699
|
-
(0, import_react.useCallback)(
|
|
700
|
-
(callback) => {
|
|
701
|
-
const unsub = subscribe(proxyObject, callback, notifyInSync);
|
|
702
|
-
callback();
|
|
703
|
-
return unsub;
|
|
704
|
-
},
|
|
705
|
-
[proxyObject, notifyInSync]
|
|
706
|
-
),
|
|
707
|
-
() => {
|
|
708
|
-
const nextSnapshot = snapshot(proxyObject);
|
|
709
|
-
try {
|
|
710
|
-
if (!inRender && lastSnapshot.current && !isChanged(
|
|
711
|
-
lastSnapshot.current,
|
|
712
|
-
nextSnapshot,
|
|
713
|
-
affected,
|
|
714
|
-
/* @__PURE__ */ new WeakMap()
|
|
715
|
-
)) {
|
|
716
|
-
return lastSnapshot.current;
|
|
717
|
-
}
|
|
718
|
-
} catch (e) {
|
|
719
|
-
}
|
|
720
|
-
return nextSnapshot;
|
|
721
|
-
},
|
|
722
|
-
() => snapshot(proxyObject)
|
|
723
|
-
);
|
|
724
|
-
inRender = false;
|
|
725
|
-
(0, import_react.useLayoutEffect)(() => {
|
|
726
|
-
lastSnapshot.current = currSnapshot;
|
|
727
|
-
});
|
|
728
|
-
if ((import_meta2.env ? import_meta2.env.MODE : void 0) !== "production") {
|
|
729
|
-
condUseAffectedDebugValue(currSnapshot, affected);
|
|
730
|
-
}
|
|
731
|
-
const proxyCache2 = (0, import_react.useMemo)(() => /* @__PURE__ */ new WeakMap(), []);
|
|
732
|
-
return createProxy(currSnapshot, affected, proxyCache2, targetCache);
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
// src/utils/track.ts
|
|
736
|
-
function track(fn, ...args) {
|
|
737
|
-
const deferred = ref(new Deferred());
|
|
738
|
-
const exposer = { fn, args, deferred, id: ++Trigger.id };
|
|
739
|
-
Trigger.tasks.set(exposer.id, exposer);
|
|
740
|
-
deferred.then(() => Trigger.tasks.delete(exposer.id));
|
|
741
|
-
return deferred;
|
|
742
|
-
}
|
|
743
|
-
|
|
744
|
-
// src/utils/wrapper.ts
|
|
745
|
-
var import_react2 = __toESM(require_react(), 1);
|
|
746
|
-
function wrapper(asChild, props, children) {
|
|
747
|
-
return asChild ? (0, import_react2.createElement)(asChild, props, children) : children;
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
// src/components/condition/Case.ts
|
|
751
|
-
function Case(props) {
|
|
752
|
-
const { cond, children, tag, as: asChild, ...attrs } = props;
|
|
753
|
-
return wrapper(tag || asChild, attrs, children);
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
// src/components/condition/Default.ts
|
|
757
|
-
function Default(props) {
|
|
758
|
-
const { children, tag, as: asChild, ...attrs } = props;
|
|
759
|
-
return wrapper(tag || asChild, attrs, children);
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
// src/components/condition/If.ts
|
|
763
|
-
var import_react3 = __toESM(require_react(), 1);
|
|
764
|
-
|
|
765
|
-
// src/components/condition/Then.ts
|
|
766
|
-
function Then(props) {
|
|
767
|
-
const { children, cond, else: _else, then, tag, as: asChild, ...attrs } = props;
|
|
768
|
-
return Object.keys(props).includes("cond") ? wrapper(If, props, children) : wrapper(tag || asChild, attrs, children);
|
|
769
|
-
}
|
|
770
|
-
|
|
771
|
-
// src/components/condition/If.ts
|
|
772
|
-
function If(props) {
|
|
773
|
-
const { then, cond, else: _else, children = props.then, tag, as: asChild, ...attrs } = props;
|
|
774
|
-
const elements = import_react3.Children.toArray(children);
|
|
775
|
-
const thenChild = elements.find((c) => c.type === Then);
|
|
776
|
-
const elseChild = elements.find((c) => c.type === Else);
|
|
777
|
-
const child = thenChild || elseChild ? cond ? thenChild : elseChild : cond ? children : _else;
|
|
778
|
-
return wrapper(tag || asChild, attrs, child);
|
|
779
|
-
}
|
|
780
|
-
|
|
781
|
-
// src/components/condition/Else.ts
|
|
782
|
-
function Else(props) {
|
|
783
|
-
const { children, tag, as: asChild, ...attrs } = props;
|
|
784
|
-
return Object.keys(props).includes("cond") ? wrapper(If, props, children) : wrapper(tag || asChild, attrs, children);
|
|
785
|
-
}
|
|
786
|
-
|
|
787
|
-
// src/components/condition/Switch.ts
|
|
788
|
-
var import_react4 = __toESM(require_react(), 1);
|
|
789
|
-
function Switch(props) {
|
|
790
|
-
const isUseValue = props.value !== void 0;
|
|
791
|
-
let matchingCase;
|
|
792
|
-
let defaultCase;
|
|
793
|
-
import_react4.Children.forEach(props.children, (child) => {
|
|
794
|
-
if (!(0, import_react4.isValidElement)(child) || matchingCase)
|
|
795
|
-
return;
|
|
796
|
-
if (child.type === Case) {
|
|
797
|
-
const cond = child?.props?.cond;
|
|
798
|
-
if (isUseValue ? props.value === cond : cond) {
|
|
799
|
-
matchingCase = child;
|
|
800
|
-
return;
|
|
801
|
-
}
|
|
802
|
-
}
|
|
803
|
-
if (!defaultCase && child.type === Default)
|
|
804
|
-
defaultCase = child;
|
|
805
|
-
});
|
|
806
|
-
return matchingCase ?? defaultCase ?? null;
|
|
807
|
-
}
|
|
808
|
-
|
|
809
|
-
// src/components/condition/Unless.ts
|
|
810
|
-
var import_react5 = __toESM(require_react(), 1);
|
|
811
|
-
function Unless(props) {
|
|
812
|
-
const { cond, then, else: _else, tag, as: asChild, children = props.then, ...attrs } = props;
|
|
813
|
-
const elements = import_react5.Children.toArray(children);
|
|
814
|
-
const thenChild = elements.find((c) => c.type === Then);
|
|
815
|
-
const elseChild = elements.find((c) => c.type === Else);
|
|
816
|
-
const child = thenChild || elseChild ? !cond ? elseChild : thenChild : !cond ? children : _else;
|
|
817
|
-
return wrapper(tag || asChild, attrs, child);
|
|
818
|
-
}
|
|
819
|
-
|
|
820
|
-
// src/components/utils/Injector.ts
|
|
821
|
-
var import_react6 = __toESM(require_react(), 1);
|
|
822
|
-
function Injector(props) {
|
|
823
|
-
const installs = (0, import_react6.useMemo)(
|
|
824
|
-
() => props.install.map(repack).reverse(),
|
|
825
|
-
[props.install]
|
|
826
|
-
);
|
|
827
|
-
return installs.reduce(
|
|
828
|
-
(child, { component: Component, props: props2 }) => (0, import_react6.createElement)(Component, props2, child),
|
|
829
|
-
props.children
|
|
830
|
-
);
|
|
831
|
-
}
|
|
832
|
-
function repack(c) {
|
|
833
|
-
return c.component ? c : { component: c };
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
// src/components/utils/Trigger.ts
|
|
837
|
-
var import_react7 = __toESM(require_react(), 1);
|
|
838
|
-
|
|
839
|
-
// ../../node_modules/.pnpm/valtio@2.1.4_@types+react@19.1.6_react@19.1.0/node_modules/valtio/esm/vanilla/utils.mjs
|
|
840
|
-
var currentCleanups;
|
|
841
|
-
function watch(callback, options) {
|
|
842
|
-
let alive = true;
|
|
843
|
-
const cleanups = /* @__PURE__ */ new Set();
|
|
844
|
-
const subscriptions = /* @__PURE__ */ new Map();
|
|
845
|
-
const cleanup = () => {
|
|
846
|
-
if (alive) {
|
|
847
|
-
alive = false;
|
|
848
|
-
cleanups.forEach((clean) => clean());
|
|
849
|
-
cleanups.clear();
|
|
850
|
-
subscriptions.forEach((unsubscribe) => unsubscribe());
|
|
851
|
-
subscriptions.clear();
|
|
852
|
-
}
|
|
853
|
-
};
|
|
854
|
-
const revalidate = async () => {
|
|
855
|
-
if (!alive) {
|
|
856
|
-
return;
|
|
857
|
-
}
|
|
858
|
-
cleanups.forEach((clean) => clean());
|
|
859
|
-
cleanups.clear();
|
|
860
|
-
const proxiesToSubscribe = /* @__PURE__ */ new Set();
|
|
861
|
-
const parent = currentCleanups;
|
|
862
|
-
currentCleanups = cleanups;
|
|
863
|
-
try {
|
|
864
|
-
const promiseOrPossibleCleanup = callback((proxyObject) => {
|
|
865
|
-
proxiesToSubscribe.add(proxyObject);
|
|
866
|
-
if (alive && !subscriptions.has(proxyObject)) {
|
|
867
|
-
const unsubscribe = subscribe(proxyObject, revalidate, options == null ? void 0 : options.sync);
|
|
868
|
-
subscriptions.set(proxyObject, unsubscribe);
|
|
869
|
-
}
|
|
870
|
-
return proxyObject;
|
|
871
|
-
});
|
|
872
|
-
const couldBeCleanup = promiseOrPossibleCleanup && promiseOrPossibleCleanup instanceof Promise ? await promiseOrPossibleCleanup : promiseOrPossibleCleanup;
|
|
873
|
-
if (couldBeCleanup) {
|
|
874
|
-
if (alive) {
|
|
875
|
-
cleanups.add(couldBeCleanup);
|
|
876
|
-
} else {
|
|
877
|
-
cleanup();
|
|
878
|
-
}
|
|
879
|
-
}
|
|
880
|
-
} finally {
|
|
881
|
-
currentCleanups = parent;
|
|
882
|
-
}
|
|
883
|
-
subscriptions.forEach((unsubscribe, proxyObject) => {
|
|
884
|
-
if (!proxiesToSubscribe.has(proxyObject)) {
|
|
885
|
-
subscriptions.delete(proxyObject);
|
|
886
|
-
unsubscribe();
|
|
887
|
-
}
|
|
888
|
-
});
|
|
889
|
-
};
|
|
890
|
-
if (currentCleanups) {
|
|
891
|
-
currentCleanups.add(cleanup);
|
|
892
|
-
}
|
|
893
|
-
revalidate();
|
|
894
|
-
return cleanup;
|
|
895
|
-
}
|
|
896
|
-
var DEVTOOLS = Symbol();
|
|
897
|
-
var { proxyStateMap: proxyStateMap$1, snapCache: snapCache$1 } = unstable_getInternalStates();
|
|
898
|
-
var isProxy$1 = (x) => proxyStateMap$1.has(x);
|
|
899
|
-
function proxyMap(entries) {
|
|
900
|
-
const initialData = [];
|
|
901
|
-
let initialIndex = 0;
|
|
902
|
-
const indexMap = /* @__PURE__ */ new Map();
|
|
903
|
-
const snapMapCache = /* @__PURE__ */ new WeakMap();
|
|
904
|
-
const registerSnapMap = () => {
|
|
905
|
-
const cache = snapCache$1.get(vObject);
|
|
906
|
-
const latestSnap = cache == null ? void 0 : cache[1];
|
|
907
|
-
if (latestSnap && !snapMapCache.has(latestSnap)) {
|
|
908
|
-
const clonedMap = new Map(indexMap);
|
|
909
|
-
snapMapCache.set(latestSnap, clonedMap);
|
|
910
|
-
}
|
|
911
|
-
};
|
|
912
|
-
const getMapForThis = (x) => snapMapCache.get(x) || indexMap;
|
|
913
|
-
if (entries) {
|
|
914
|
-
if (typeof entries[Symbol.iterator] !== "function") {
|
|
915
|
-
throw new TypeError(
|
|
916
|
-
"proxyMap:\n initial state must be iterable\n tip: structure should be [[key, value]]"
|
|
917
|
-
);
|
|
918
|
-
}
|
|
919
|
-
for (const [key, value] of entries) {
|
|
920
|
-
indexMap.set(key, initialIndex);
|
|
921
|
-
initialData[initialIndex++] = value;
|
|
922
|
-
}
|
|
923
|
-
}
|
|
924
|
-
const vObject = {
|
|
925
|
-
data: initialData,
|
|
926
|
-
index: initialIndex,
|
|
927
|
-
epoch: 0,
|
|
928
|
-
get size() {
|
|
929
|
-
if (!isProxy$1(this)) {
|
|
930
|
-
registerSnapMap();
|
|
931
|
-
}
|
|
932
|
-
const map = getMapForThis(this);
|
|
933
|
-
return map.size;
|
|
934
|
-
},
|
|
935
|
-
get(key) {
|
|
936
|
-
const map = getMapForThis(this);
|
|
937
|
-
const index = map.get(key);
|
|
938
|
-
if (index === void 0) {
|
|
939
|
-
this.epoch;
|
|
940
|
-
return void 0;
|
|
941
|
-
}
|
|
942
|
-
return this.data[index];
|
|
943
|
-
},
|
|
944
|
-
has(key) {
|
|
945
|
-
const map = getMapForThis(this);
|
|
946
|
-
this.epoch;
|
|
947
|
-
return map.has(key);
|
|
948
|
-
},
|
|
949
|
-
set(key, value) {
|
|
950
|
-
if (!isProxy$1(this)) {
|
|
951
|
-
throw new Error("Cannot perform mutations on a snapshot");
|
|
952
|
-
}
|
|
953
|
-
const index = indexMap.get(key);
|
|
954
|
-
if (index === void 0) {
|
|
955
|
-
indexMap.set(key, this.index);
|
|
956
|
-
this.data[this.index++] = value;
|
|
957
|
-
} else {
|
|
958
|
-
this.data[index] = value;
|
|
959
|
-
}
|
|
960
|
-
this.epoch++;
|
|
961
|
-
return this;
|
|
962
|
-
},
|
|
963
|
-
delete(key) {
|
|
964
|
-
if (!isProxy$1(this)) {
|
|
965
|
-
throw new Error("Cannot perform mutations on a snapshot");
|
|
966
|
-
}
|
|
967
|
-
const index = indexMap.get(key);
|
|
968
|
-
if (index === void 0) {
|
|
969
|
-
return false;
|
|
970
|
-
}
|
|
971
|
-
delete this.data[index];
|
|
972
|
-
indexMap.delete(key);
|
|
973
|
-
this.epoch++;
|
|
974
|
-
return true;
|
|
975
|
-
},
|
|
976
|
-
clear() {
|
|
977
|
-
if (!isProxy$1(this)) {
|
|
978
|
-
throw new Error("Cannot perform mutations on a snapshot");
|
|
979
|
-
}
|
|
980
|
-
this.data.length = 0;
|
|
981
|
-
this.index = 0;
|
|
982
|
-
this.epoch++;
|
|
983
|
-
indexMap.clear();
|
|
984
|
-
},
|
|
985
|
-
forEach(cb) {
|
|
986
|
-
this.epoch;
|
|
987
|
-
const map = getMapForThis(this);
|
|
988
|
-
map.forEach((index, key) => {
|
|
989
|
-
cb(this.data[index], key, this);
|
|
990
|
-
});
|
|
991
|
-
},
|
|
992
|
-
*entries() {
|
|
993
|
-
this.epoch;
|
|
994
|
-
const map = getMapForThis(this);
|
|
995
|
-
for (const [key, index] of map) {
|
|
996
|
-
yield [key, this.data[index]];
|
|
997
|
-
}
|
|
998
|
-
},
|
|
999
|
-
*keys() {
|
|
1000
|
-
this.epoch;
|
|
1001
|
-
const map = getMapForThis(this);
|
|
1002
|
-
for (const key of map.keys()) {
|
|
1003
|
-
yield key;
|
|
1004
|
-
}
|
|
1005
|
-
},
|
|
1006
|
-
*values() {
|
|
1007
|
-
this.epoch;
|
|
1008
|
-
const map = getMapForThis(this);
|
|
1009
|
-
for (const index of map.values()) {
|
|
1010
|
-
yield this.data[index];
|
|
1011
|
-
}
|
|
1012
|
-
},
|
|
1013
|
-
[Symbol.iterator]() {
|
|
1014
|
-
return this.entries();
|
|
1015
|
-
},
|
|
1016
|
-
get [Symbol.toStringTag]() {
|
|
1017
|
-
return "Map";
|
|
1018
|
-
},
|
|
1019
|
-
toJSON() {
|
|
1020
|
-
return new Map(this.entries());
|
|
1021
|
-
}
|
|
1022
|
-
};
|
|
1023
|
-
const proxiedObject = proxy(vObject);
|
|
1024
|
-
Object.defineProperties(proxiedObject, {
|
|
1025
|
-
size: { enumerable: false },
|
|
1026
|
-
index: { enumerable: false },
|
|
1027
|
-
epoch: { enumerable: false },
|
|
1028
|
-
data: { enumerable: false },
|
|
1029
|
-
toJSON: { enumerable: false }
|
|
1030
|
-
});
|
|
1031
|
-
Object.seal(proxiedObject);
|
|
1032
|
-
return proxiedObject;
|
|
1033
|
-
}
|
|
1034
|
-
var { proxyStateMap: proxyStateMap2, snapCache: snapCache2 } = unstable_getInternalStates();
|
|
1035
|
-
|
|
1036
|
-
// src/components/utils/Trigger.ts
|
|
1037
|
-
var pendingTasks = proxyMap();
|
|
1038
|
-
function createTracker(exposer) {
|
|
1039
|
-
const Component = () => {
|
|
1040
|
-
try {
|
|
1041
|
-
exposer.deferred.resolve(exposer.fn(...exposer.args));
|
|
1042
|
-
} catch (error) {
|
|
1043
|
-
exposer.deferred.reject(error);
|
|
1044
|
-
}
|
|
1045
|
-
return null;
|
|
1046
|
-
};
|
|
1047
|
-
Component.key = exposer.id;
|
|
1048
|
-
return Component;
|
|
1049
|
-
}
|
|
1050
|
-
function renderTracker(Tracker) {
|
|
1051
|
-
return (0, import_react7.createElement)(Tracker, { key: Tracker.key });
|
|
1052
|
-
}
|
|
1053
|
-
function Trigger() {
|
|
1054
|
-
const values = [...useSnapshot(pendingTasks).values()];
|
|
1055
|
-
return values.map(createTracker).map(renderTracker);
|
|
1056
|
-
}
|
|
1057
|
-
Trigger.id = 0;
|
|
1058
|
-
Trigger.tasks = pendingTasks;
|
|
1059
|
-
|
|
1060
|
-
// src/hooks/tryUseCallback.ts
|
|
1061
|
-
var import_react8 = __toESM(require_react(), 1);
|
|
1062
|
-
var tryUseCallback = (callback, deps) => {
|
|
1063
|
-
try {
|
|
1064
|
-
return (0, import_react8.useCallback)(callback, deps);
|
|
1065
|
-
} catch {
|
|
1066
|
-
return callback;
|
|
1067
|
-
}
|
|
1068
|
-
};
|
|
1069
|
-
|
|
1070
|
-
// src/hooks/tryUseEffect.ts
|
|
1071
|
-
var import_react9 = __toESM(require_react(), 1);
|
|
1072
|
-
var tryUseEffect = (effect, deps) => {
|
|
1073
|
-
try {
|
|
1074
|
-
(0, import_react9.useEffect)(effect, deps);
|
|
1075
|
-
} catch {
|
|
1076
|
-
}
|
|
1077
|
-
};
|
|
1078
|
-
|
|
1079
|
-
// src/hooks/tryUseInsertionEffect.ts
|
|
1080
|
-
var import_react10 = __toESM(require_react(), 1);
|
|
1081
|
-
var tryUseInsertionEffect = (callback, deps) => {
|
|
1082
|
-
try {
|
|
1083
|
-
(0, import_react10.useInsertionEffect)(callback, deps);
|
|
1084
|
-
} catch {
|
|
1085
|
-
}
|
|
1086
|
-
};
|
|
1087
|
-
|
|
1088
|
-
// src/hooks/tryUseReducer.ts
|
|
1089
|
-
var import_react11 = __toESM(require_react(), 1);
|
|
1090
|
-
var tryUseReducer = (reducer, initializerArg, initializer) => {
|
|
1091
|
-
try {
|
|
1092
|
-
return (0, import_react11.useReducer)(reducer, initializerArg, initializer);
|
|
1093
|
-
} catch {
|
|
1094
|
-
return [initializerArg, () => {
|
|
1095
|
-
}];
|
|
1096
|
-
}
|
|
1097
|
-
};
|
|
1098
|
-
|
|
1099
|
-
// src/hooks/tryUseRef.ts
|
|
1100
|
-
var import_react12 = __toESM(require_react(), 1);
|
|
1101
|
-
var tryUseRef = (initialValue) => {
|
|
1102
|
-
try {
|
|
1103
|
-
return (0, import_react12.useRef)(initialValue);
|
|
1104
|
-
} catch {
|
|
1105
|
-
return { current: initialValue };
|
|
1106
|
-
}
|
|
1107
|
-
};
|
|
1108
|
-
|
|
1109
|
-
// src/hooks/tryUseState.ts
|
|
1110
|
-
var import_react13 = __toESM(require_react(), 1);
|
|
1111
|
-
var tryUseState = (initialState) => {
|
|
1112
|
-
try {
|
|
1113
|
-
return (0, import_react13.useState)(initialState);
|
|
1114
|
-
} catch {
|
|
1115
|
-
return [isFunction_default(initialState) ? initialState() : initialState, noop];
|
|
1116
|
-
}
|
|
1117
|
-
};
|
|
1118
|
-
|
|
1119
|
-
// src/hooks/useUpdate.ts
|
|
1120
|
-
var updateReducer = (num) => (num + 1) % 1e6;
|
|
1121
|
-
function useUpdate() {
|
|
1122
|
-
const [, update] = tryUseReducer(updateReducer, 0);
|
|
1123
|
-
return update;
|
|
1124
|
-
}
|
|
1125
|
-
|
|
1126
|
-
// src/hooks/tryUseUpdate.ts
|
|
1127
|
-
function tryUseUpdate() {
|
|
1128
|
-
try {
|
|
1129
|
-
return useUpdate();
|
|
1130
|
-
} catch {
|
|
1131
|
-
return () => {
|
|
1132
|
-
};
|
|
1133
|
-
}
|
|
1134
|
-
}
|
|
1135
|
-
|
|
1136
|
-
// src/hooks/useAsyncCallback.ts
|
|
1137
|
-
var import_react14 = __toESM(require_react(), 1);
|
|
1138
|
-
function useAsyncCallback(fun) {
|
|
1139
|
-
const [state, set] = (0, import_react14.useState)({ loading: false });
|
|
1140
|
-
async function refetch(...args) {
|
|
1141
|
-
set({ loading: true });
|
|
1142
|
-
return fun(...args).then((value) => {
|
|
1143
|
-
set({ loading: false });
|
|
1144
|
-
return value;
|
|
1145
|
-
}).catch((err) => {
|
|
1146
|
-
set({ loading: false, error: err });
|
|
1147
|
-
return Promise.reject(err);
|
|
1148
|
-
});
|
|
1149
|
-
}
|
|
1150
|
-
return [state.loading, refetch, state.error];
|
|
1151
|
-
}
|
|
1152
|
-
|
|
1153
|
-
// src/hooks/useAsyncState.ts
|
|
1154
|
-
var import_react15 = __toESM(require_react(), 1);
|
|
1155
|
-
function useAsyncState(fun, deps = [], options) {
|
|
1156
|
-
const [value, set] = (0, import_react15.useState)(options?.initial);
|
|
1157
|
-
const [loading, refetch, error] = useAsyncCallback(async (...args) => fun(...args).then(set));
|
|
1158
|
-
(0, import_react15.useEffect)(
|
|
1159
|
-
() => {
|
|
1160
|
-
refetch();
|
|
1161
|
-
},
|
|
1162
|
-
deps
|
|
1163
|
-
);
|
|
1164
|
-
return [{ value, loading, error }, refetch];
|
|
1165
|
-
}
|
|
1166
|
-
|
|
1167
|
-
// src/hooks/useDebounce.ts
|
|
1168
|
-
var import_react16 = __toESM(require_react(), 1);
|
|
1169
|
-
function useDebounce(value, delay) {
|
|
1170
|
-
const [debouncedValue, setDebouncedValue] = (0, import_react16.useState)(value);
|
|
1171
|
-
(0, import_react16.useEffect)(() => {
|
|
1172
|
-
const handler = setTimeout(() => setDebouncedValue(value), delay);
|
|
1173
|
-
return () => clearTimeout(handler);
|
|
1174
|
-
}, [value, delay]);
|
|
1175
|
-
return debouncedValue;
|
|
1176
|
-
}
|
|
1177
|
-
|
|
1178
|
-
// ../../node_modules/.pnpm/mitt@3.0.1/node_modules/mitt/dist/mitt.mjs
|
|
1179
|
-
function mitt_default(n) {
|
|
1180
|
-
return { all: n = n || /* @__PURE__ */ new Map(), on: function(t, e) {
|
|
1181
|
-
var i = n.get(t);
|
|
1182
|
-
i ? i.push(e) : n.set(t, [e]);
|
|
1183
|
-
}, off: function(t, e) {
|
|
1184
|
-
var i = n.get(t);
|
|
1185
|
-
i && (e ? i.splice(i.indexOf(e) >>> 0, 1) : n.set(t, []));
|
|
1186
|
-
}, emit: function(t, e) {
|
|
1187
|
-
var i = n.get(t);
|
|
1188
|
-
i && i.slice().map(function(n2) {
|
|
1189
|
-
n2(e);
|
|
1190
|
-
}), (i = n.get("*")) && i.slice().map(function(n2) {
|
|
1191
|
-
n2(t, e);
|
|
1192
|
-
});
|
|
1193
|
-
} };
|
|
1194
|
-
}
|
|
1195
|
-
|
|
1196
|
-
// src/hooks/useEventBus.ts
|
|
1197
|
-
var import_react17 = __toESM(require_react(), 1);
|
|
1198
|
-
var emitter = mitt_default();
|
|
1199
|
-
function useEventBus(key) {
|
|
1200
|
-
const onRef = (0, import_react17.useRef)(void 0);
|
|
1201
|
-
function on(listener) {
|
|
1202
|
-
emitter.on(key, listener);
|
|
1203
|
-
onRef.current = listener;
|
|
1204
|
-
(0, import_react17.useEffect)(() => {
|
|
1205
|
-
if (!onRef.current)
|
|
1206
|
-
return;
|
|
1207
|
-
emitter.off(key, onRef.current);
|
|
1208
|
-
emitter.on(key, listener);
|
|
1209
|
-
onRef.current = listener;
|
|
1210
|
-
return () => emitter.off(key, listener);
|
|
1211
|
-
}, [listener]);
|
|
1212
|
-
}
|
|
1213
|
-
function emit(event) {
|
|
1214
|
-
emitter.emit(key, event);
|
|
1215
|
-
}
|
|
1216
|
-
function off(listener) {
|
|
1217
|
-
emitter.off(key, listener);
|
|
1218
|
-
}
|
|
1219
|
-
return {
|
|
1220
|
-
on,
|
|
1221
|
-
emit,
|
|
1222
|
-
off
|
|
1223
|
-
};
|
|
1224
|
-
}
|
|
1225
|
-
|
|
1226
|
-
// ../../node_modules/.pnpm/react-use@17.6.0_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/react-use/esm/useEffectOnce.js
|
|
1227
|
-
var import_react18 = __toESM(require_react());
|
|
1228
|
-
var useEffectOnce = function(effect) {
|
|
1229
|
-
(0, import_react18.useEffect)(effect, []);
|
|
1230
|
-
};
|
|
1231
|
-
var useEffectOnce_default = useEffectOnce;
|
|
1232
|
-
|
|
1233
|
-
// ../../node_modules/.pnpm/react-use@17.6.0_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/react-use/esm/useMount.js
|
|
1234
|
-
var useMount = function(fn) {
|
|
1235
|
-
useEffectOnce_default(function() {
|
|
1236
|
-
fn();
|
|
1237
|
-
});
|
|
1238
|
-
};
|
|
1239
|
-
var useMount_default = useMount;
|
|
1240
|
-
|
|
1241
|
-
// src/hooks/useFetchIntercept.ts
|
|
1242
|
-
function useFetchResponseIntercept(intercept) {
|
|
1243
|
-
useMount_default(() => fetchResponseIntercept(intercept));
|
|
1244
|
-
}
|
|
1245
|
-
function useFetchRequestIntercept(intercept) {
|
|
1246
|
-
useMount_default(() => fetchRequestIntercept(intercept));
|
|
1247
|
-
}
|
|
1248
|
-
function fetchResponseIntercept(intercept) {
|
|
1249
|
-
const { fetch: originalFetch } = window;
|
|
1250
|
-
window.fetch = async (...args) => {
|
|
1251
|
-
const [resource, config] = args;
|
|
1252
|
-
const response = await originalFetch(resource, config);
|
|
1253
|
-
return intercept(response, config);
|
|
1254
|
-
};
|
|
1255
|
-
}
|
|
1256
|
-
function fetchRequestIntercept(intercept) {
|
|
1257
|
-
const { fetch: originalFetch } = window;
|
|
1258
|
-
window.fetch = async (...args) => {
|
|
1259
|
-
const [resource, config] = args;
|
|
1260
|
-
return intercept(originalFetch, resource, config);
|
|
1261
|
-
};
|
|
1262
|
-
}
|
|
1263
|
-
|
|
1264
|
-
// src/hooks/useMounted.ts
|
|
1265
|
-
var import_react19 = __toESM(require_react(), 1);
|
|
1266
|
-
function useMounted() {
|
|
1267
|
-
const [mounted, setMounted] = (0, import_react19.useState)(false);
|
|
1268
|
-
(0, import_react19.useEffect)(() => setMounted(true), []);
|
|
1269
|
-
return mounted;
|
|
1270
|
-
}
|
|
1271
|
-
|
|
1272
|
-
// src/hooks/useOffsetPagination.ts
|
|
1273
|
-
var import_react22 = __toESM(require_react(), 1);
|
|
1274
|
-
|
|
1275
|
-
// src/hooks/useWatch.ts
|
|
1276
|
-
var import_react21 = __toESM(require_react(), 1);
|
|
1277
|
-
|
|
1278
|
-
// src/hooks/usePrevious.ts
|
|
1279
|
-
var import_react20 = __toESM(require_react(), 1);
|
|
1280
|
-
function usePrevious(value) {
|
|
1281
|
-
const ref2 = (0, import_react20.useRef)(void 0);
|
|
1282
|
-
(0, import_react20.useEffect)(() => {
|
|
1283
|
-
ref2.current = value;
|
|
1284
|
-
});
|
|
1285
|
-
return ref2.current;
|
|
1286
|
-
}
|
|
1287
|
-
|
|
1288
|
-
// src/hooks/useWatch.ts
|
|
1289
|
-
function useWatch(source, callback, options = {}) {
|
|
1290
|
-
const firstUpdate = (0, import_react21.useRef)(false);
|
|
1291
|
-
const then = (0, import_react21.useRef)(void 0);
|
|
1292
|
-
const oldValue = usePrevious(source);
|
|
1293
|
-
const deps = (0, import_react21.useMemo)(
|
|
1294
|
-
() => Array.isArray(source) ? source : [source],
|
|
1295
|
-
[source]
|
|
1296
|
-
);
|
|
1297
|
-
(0, import_react21.useEffect)(() => {
|
|
1298
|
-
if (!firstUpdate.current)
|
|
1299
|
-
recordFirst();
|
|
1300
|
-
else
|
|
1301
|
-
callback(source, oldValue);
|
|
1302
|
-
}, deps);
|
|
1303
|
-
async function recordFirst() {
|
|
1304
|
-
if (then.current)
|
|
1305
|
-
return;
|
|
1306
|
-
then.current = Promise.resolve(source);
|
|
1307
|
-
then.current.then(() => firstUpdate.current = true);
|
|
1308
|
-
if (options.immediate)
|
|
1309
|
-
then.current.then((value) => callback(value, oldValue));
|
|
1310
|
-
}
|
|
1311
|
-
}
|
|
1312
|
-
|
|
1313
|
-
// src/hooks/useOffsetPagination.ts
|
|
1314
|
-
function useOffsetPagination(options) {
|
|
1315
|
-
const [page, setPage] = (0, import_react22.useState)(options.page || 1);
|
|
1316
|
-
const [pageSize, setPageSize] = (0, import_react22.useState)(options.pageSize || 10);
|
|
1317
|
-
const total = options.total || 0;
|
|
1318
|
-
const pageCount = (0, import_react22.useMemo)(() => Math.max(1, Math.ceil(total / pageSize)), [total, pageSize]);
|
|
1319
|
-
const isFirstPage = (0, import_react22.useMemo)(() => page === 1, [page]);
|
|
1320
|
-
const isLastPage = (0, import_react22.useMemo)(() => page === pageCount, [page, pageCount]);
|
|
1321
|
-
function next() {
|
|
1322
|
-
setPage((page2) => Math.min(pageCount, page2 + 1));
|
|
1323
|
-
}
|
|
1324
|
-
function prev() {
|
|
1325
|
-
setPage((page2) => Math.max(1, page2 - 1));
|
|
1326
|
-
}
|
|
1327
|
-
function pageChange(page2) {
|
|
1328
|
-
setPage(() => Math.max(1, Math.min(page2, pageCount)));
|
|
1329
|
-
}
|
|
1330
|
-
function pageSizeChange(limit) {
|
|
1331
|
-
setPageSize(limit);
|
|
1332
|
-
pageChange(1);
|
|
1333
|
-
}
|
|
1334
|
-
const pagination = {
|
|
1335
|
-
next,
|
|
1336
|
-
prev,
|
|
1337
|
-
page,
|
|
1338
|
-
pageSize,
|
|
1339
|
-
isFirstPage,
|
|
1340
|
-
pageSizeChange,
|
|
1341
|
-
pageChange,
|
|
1342
|
-
isLastPage,
|
|
1343
|
-
pageCount,
|
|
1344
|
-
total
|
|
1345
|
-
};
|
|
1346
|
-
useWatch(page, () => options.onChange?.(pagination));
|
|
1347
|
-
useWatch(pageSize, () => options.onPageSizeChange?.(pagination));
|
|
1348
|
-
useWatch(pageCount, () => options.onPageCountChange?.(pagination));
|
|
1349
|
-
return pagination;
|
|
1350
|
-
}
|
|
1351
|
-
|
|
1352
|
-
// src/hooks/useWhenever.ts
|
|
1353
|
-
function useWhenever(source, cb, options) {
|
|
1354
|
-
useWatch(source, (value, oldValue) => value && cb(value, oldValue), options);
|
|
1355
|
-
}
|
|
1356
|
-
|
|
1357
|
-
// src/storage/defineStore.ts
|
|
1358
|
-
var import_react23 = __toESM(require_react(), 1);
|
|
1359
|
-
|
|
1360
|
-
// src/storage/persistant.ts
|
|
1361
|
-
function proxyWithPersistant(keyOrOptions, initialObject) {
|
|
1362
|
-
let options;
|
|
1363
|
-
if (typeof keyOrOptions === "string") {
|
|
1364
|
-
options = { id: keyOrOptions };
|
|
1365
|
-
} else {
|
|
1366
|
-
options = { ...keyOrOptions };
|
|
1367
|
-
}
|
|
1368
|
-
const storage = options.storage || (typeof localStorage !== "undefined" ? localStorage : void 0);
|
|
1369
|
-
typeof keyOrOptions === "string" && (keyOrOptions = { id: keyOrOptions });
|
|
1370
|
-
const state = proxy(tryParseJson(storage?.getItem(options.id)) || initialObject);
|
|
1371
|
-
subscribe(state, () => {
|
|
1372
|
-
const pick = options.pick || Object.keys(state);
|
|
1373
|
-
const statePick = {};
|
|
1374
|
-
for (const key of pick)
|
|
1375
|
-
statePick[key] = state[key];
|
|
1376
|
-
storage?.setItem(options.id, JSON.stringify(statePick));
|
|
1377
|
-
});
|
|
1378
|
-
return state;
|
|
1379
|
-
}
|
|
1380
|
-
|
|
1381
|
-
// src/storage/utils/index.ts
|
|
1382
|
-
function track2(action, status) {
|
|
1383
|
-
let loadings = 0;
|
|
1384
|
-
const tracking = () => loadings++ === 0 && (status.loading = true);
|
|
1385
|
-
const done = () => !--loadings && (status.loading = false);
|
|
1386
|
-
const fulfilled = (value) => {
|
|
1387
|
-
status.finished = true;
|
|
1388
|
-
done();
|
|
1389
|
-
return value;
|
|
1390
|
-
};
|
|
1391
|
-
const rejected = (error) => {
|
|
1392
|
-
status.error = error;
|
|
1393
|
-
done();
|
|
1394
|
-
throw error;
|
|
1395
|
-
};
|
|
1396
|
-
return function(...args) {
|
|
1397
|
-
tracking();
|
|
1398
|
-
try {
|
|
1399
|
-
const value = action(...args);
|
|
1400
|
-
return value instanceof Promise ? value.then(fulfilled, rejected) : fulfilled(value);
|
|
1401
|
-
} catch (error) {
|
|
1402
|
-
rejected(error);
|
|
1403
|
-
}
|
|
1404
|
-
};
|
|
1405
|
-
}
|
|
1406
|
-
|
|
1407
|
-
// src/storage/defineStore.ts
|
|
1408
|
-
function defineStore(store, options = {}) {
|
|
1409
|
-
const state = typeof store.state === "function" ? store.state() : store.state;
|
|
1410
|
-
const getters = store.getters || {};
|
|
1411
|
-
const actions = store.actions || {};
|
|
1412
|
-
const status = {};
|
|
1413
|
-
status.finished = false;
|
|
1414
|
-
status.loading = false;
|
|
1415
|
-
status.error = null;
|
|
1416
|
-
const $status = proxy(status);
|
|
1417
|
-
const $state = options.persist ? proxyWithPersistant(options.persist, state) : proxy(state);
|
|
1418
|
-
const $actions = {};
|
|
1419
|
-
const $getters = {};
|
|
1420
|
-
setupActions($state, actions, $actions, $status);
|
|
1421
|
-
setupGetters(state, $state, getters, $getters);
|
|
1422
|
-
setupStatus($actions, $status);
|
|
1423
|
-
function $subscribe(listener) {
|
|
1424
|
-
return subscribe($state, () => listener($state));
|
|
1425
|
-
}
|
|
1426
|
-
$subscribe.status = function(listener) {
|
|
1427
|
-
return subscribe($status, () => listener($status));
|
|
1428
|
-
};
|
|
1429
|
-
function $patch(patch) {
|
|
1430
|
-
if (typeof patch === "function")
|
|
1431
|
-
patch($state);
|
|
1432
|
-
else
|
|
1433
|
-
Object.assign($state, patch);
|
|
1434
|
-
}
|
|
1435
|
-
function $signal(fn) {
|
|
1436
|
-
return (0, import_react23.createElement)(() => fn(useSnapshot($state)));
|
|
1437
|
-
}
|
|
1438
|
-
$signal.status = function(fn) {
|
|
1439
|
-
return (0, import_react23.createElement)(() => fn(useSnapshot($status)));
|
|
1440
|
-
};
|
|
1441
|
-
return {
|
|
1442
|
-
$subscribe,
|
|
1443
|
-
$patch,
|
|
1444
|
-
$state,
|
|
1445
|
-
$status,
|
|
1446
|
-
$actions,
|
|
1447
|
-
$getters,
|
|
1448
|
-
$signal,
|
|
1449
|
-
...$actions
|
|
1450
|
-
};
|
|
1451
|
-
}
|
|
1452
|
-
function setupActions($state, actions, $actions, $status) {
|
|
1453
|
-
for (const key in actions) {
|
|
1454
|
-
$status[key] = { finished: false, loading: false, error: null };
|
|
1455
|
-
$actions[key] = track2(actions[key].bind($state), $status[key]);
|
|
1456
|
-
Object.defineProperty($state, key, {
|
|
1457
|
-
get: () => $actions[key]
|
|
1458
|
-
});
|
|
1459
|
-
}
|
|
1460
|
-
}
|
|
1461
|
-
function setupGetters(state, $state, getters, $getters) {
|
|
1462
|
-
for (const key in getters) {
|
|
1463
|
-
Object.defineProperty(state, key, {
|
|
1464
|
-
get: () => getters[key].call($state),
|
|
1465
|
-
enumerable: true
|
|
1466
|
-
});
|
|
1467
|
-
Object.defineProperty($getters, key, {
|
|
1468
|
-
get: () => state[key],
|
|
1469
|
-
enumerable: true
|
|
1470
|
-
});
|
|
1471
|
-
}
|
|
1472
|
-
}
|
|
1473
|
-
function setupStatus($actions, $status) {
|
|
1474
|
-
Object.defineProperty($status, "loading", {
|
|
1475
|
-
get: () => Object.keys($actions).some((key) => $status[key].loading),
|
|
1476
|
-
enumerable: true
|
|
1477
|
-
});
|
|
1478
|
-
Object.defineProperty($status, "finished", {
|
|
1479
|
-
get: () => Object.keys($actions).every((key) => $status[key].finished),
|
|
1480
|
-
enumerable: true
|
|
1481
|
-
});
|
|
1482
|
-
Object.defineProperty($status, "error", {
|
|
1483
|
-
get: () => Object.keys($actions).find((key) => $status[key].error),
|
|
1484
|
-
enumerable: true
|
|
1485
|
-
});
|
|
1486
|
-
}
|
|
1487
|
-
|
|
1488
|
-
// src/storage/defineStoreAsync.ts
|
|
1489
|
-
function defineStoreAsync(fetch, options = {}) {
|
|
1490
|
-
let persist;
|
|
1491
|
-
if (typeof options.persist === "string") {
|
|
1492
|
-
persist = { id: options.persist, pick: ["value"] };
|
|
1493
|
-
}
|
|
1494
|
-
if (typeof options.persist === "object") {
|
|
1495
|
-
persist = { ...options.persist, pick: ["value"] };
|
|
1496
|
-
}
|
|
1497
|
-
const store = defineStore(
|
|
1498
|
-
{
|
|
1499
|
-
state: () => ({
|
|
1500
|
-
value: options.initial,
|
|
1501
|
-
error: void 0,
|
|
1502
|
-
loading: false,
|
|
1503
|
-
finished: false
|
|
1504
|
-
}),
|
|
1505
|
-
actions: {
|
|
1506
|
-
async refetch(...args) {
|
|
1507
|
-
return this.value = await fetch(...args);
|
|
1508
|
-
},
|
|
1509
|
-
reset(value) {
|
|
1510
|
-
this.value = value || options.initial;
|
|
1511
|
-
}
|
|
1512
|
-
}
|
|
1513
|
-
},
|
|
1514
|
-
{ persist }
|
|
1515
|
-
);
|
|
1516
|
-
watch((get) => {
|
|
1517
|
-
const status = get(store.$status.refetch);
|
|
1518
|
-
store.$state.error = status.error;
|
|
1519
|
-
store.$state.loading = status.loading;
|
|
1520
|
-
store.$state.finished = status.finished;
|
|
1521
|
-
});
|
|
1522
|
-
options.immediate && store.refetch();
|
|
1523
|
-
return store;
|
|
1524
|
-
}
|
|
1525
|
-
var defienAsyncStore = defineStoreAsync;
|
|
1526
|
-
|
|
1527
|
-
// src/storage/useStatus.tsx
|
|
1528
|
-
function useStatus(store) {
|
|
1529
|
-
return useSnapshot(store.$status);
|
|
1530
|
-
}
|
|
1531
|
-
|
|
1532
|
-
// src/storage/useStore.ts
|
|
1533
|
-
function useStore(store) {
|
|
1534
|
-
return useSnapshot(store.$state);
|
|
1535
|
-
}
|
|
1536
|
-
return __toCommonJS(index_exports);
|
|
1537
|
-
})();
|
|
1538
|
-
/*! Bundled license information:
|
|
1539
|
-
|
|
1540
|
-
lodash-es/lodash.js:
|
|
1541
|
-
(**
|
|
1542
|
-
* @license
|
|
1543
|
-
* Lodash (Custom Build) <https://lodash.com/>
|
|
1544
|
-
* Build: `lodash modularize exports="es" -o ./`
|
|
1545
|
-
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
|
1546
|
-
* Released under MIT license <https://lodash.com/license>
|
|
1547
|
-
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
1548
|
-
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
1549
|
-
*)
|
|
1550
|
-
*/
|