@hairy/react-lib-composition 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 +377 -36
- package/dist/index.cjs +493 -414
- package/dist/{index.d.ts → index.d.cts} +28 -32
- package/dist/index.d.mts +344 -0
- package/dist/index.mjs +448 -0
- package/package.json +19 -20
- package/dist/index.global.js +0 -5252
- package/dist/index.js +0 -435
package/dist/index.js
DELETED
|
@@ -1,435 +0,0 @@
|
|
|
1
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_freeGlobal.js
|
|
2
|
-
var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
|
|
3
|
-
var freeGlobal_default = freeGlobal;
|
|
4
|
-
|
|
5
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_root.js
|
|
6
|
-
var freeSelf = typeof self == "object" && self && self.Object === Object && self;
|
|
7
|
-
var root = freeGlobal_default || freeSelf || Function("return this")();
|
|
8
|
-
var root_default = root;
|
|
9
|
-
|
|
10
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Symbol.js
|
|
11
|
-
var Symbol = root_default.Symbol;
|
|
12
|
-
var Symbol_default = Symbol;
|
|
13
|
-
|
|
14
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getRawTag.js
|
|
15
|
-
var objectProto = Object.prototype;
|
|
16
|
-
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
17
|
-
var nativeObjectToString = objectProto.toString;
|
|
18
|
-
var symToStringTag = Symbol_default ? Symbol_default.toStringTag : void 0;
|
|
19
|
-
function getRawTag(value) {
|
|
20
|
-
var isOwn = hasOwnProperty.call(value, symToStringTag), tag = value[symToStringTag];
|
|
21
|
-
try {
|
|
22
|
-
value[symToStringTag] = void 0;
|
|
23
|
-
var unmasked = true;
|
|
24
|
-
} catch (e) {
|
|
25
|
-
}
|
|
26
|
-
var result = nativeObjectToString.call(value);
|
|
27
|
-
if (unmasked) {
|
|
28
|
-
if (isOwn) {
|
|
29
|
-
value[symToStringTag] = tag;
|
|
30
|
-
} else {
|
|
31
|
-
delete value[symToStringTag];
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return result;
|
|
35
|
-
}
|
|
36
|
-
var getRawTag_default = getRawTag;
|
|
37
|
-
|
|
38
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_objectToString.js
|
|
39
|
-
var objectProto2 = Object.prototype;
|
|
40
|
-
var nativeObjectToString2 = objectProto2.toString;
|
|
41
|
-
function objectToString(value) {
|
|
42
|
-
return nativeObjectToString2.call(value);
|
|
43
|
-
}
|
|
44
|
-
var objectToString_default = objectToString;
|
|
45
|
-
|
|
46
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseGetTag.js
|
|
47
|
-
var nullTag = "[object Null]";
|
|
48
|
-
var undefinedTag = "[object Undefined]";
|
|
49
|
-
var symToStringTag2 = Symbol_default ? Symbol_default.toStringTag : void 0;
|
|
50
|
-
function baseGetTag(value) {
|
|
51
|
-
if (value == null) {
|
|
52
|
-
return value === void 0 ? undefinedTag : nullTag;
|
|
53
|
-
}
|
|
54
|
-
return symToStringTag2 && symToStringTag2 in Object(value) ? getRawTag_default(value) : objectToString_default(value);
|
|
55
|
-
}
|
|
56
|
-
var baseGetTag_default = baseGetTag;
|
|
57
|
-
|
|
58
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isObject.js
|
|
59
|
-
function isObject(value) {
|
|
60
|
-
var type = typeof value;
|
|
61
|
-
return value != null && (type == "object" || type == "function");
|
|
62
|
-
}
|
|
63
|
-
var isObject_default = isObject;
|
|
64
|
-
|
|
65
|
-
// ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isFunction.js
|
|
66
|
-
var asyncTag = "[object AsyncFunction]";
|
|
67
|
-
var funcTag = "[object Function]";
|
|
68
|
-
var genTag = "[object GeneratorFunction]";
|
|
69
|
-
var proxyTag = "[object Proxy]";
|
|
70
|
-
function isFunction(value) {
|
|
71
|
-
if (!isObject_default(value)) {
|
|
72
|
-
return false;
|
|
73
|
-
}
|
|
74
|
-
var tag = baseGetTag_default(value);
|
|
75
|
-
return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
|
|
76
|
-
}
|
|
77
|
-
var isFunction_default = isFunction;
|
|
78
|
-
|
|
79
|
-
// ../util-core/src/util/noop.ts
|
|
80
|
-
var noop = () => {
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
// ../lib-react/src/hooks/tryUseCallback.ts
|
|
84
|
-
import { useCallback } from "react";
|
|
85
|
-
var tryUseCallback = (callback, deps) => {
|
|
86
|
-
try {
|
|
87
|
-
return useCallback(callback, deps);
|
|
88
|
-
} catch {
|
|
89
|
-
return callback;
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
// ../lib-react/src/hooks/tryUseEffect.ts
|
|
94
|
-
import { useEffect } from "react";
|
|
95
|
-
var tryUseEffect = (effect, deps) => {
|
|
96
|
-
try {
|
|
97
|
-
useEffect(effect, deps);
|
|
98
|
-
} catch {
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
// ../lib-react/src/hooks/tryUseInsertionEffect.ts
|
|
103
|
-
import { useInsertionEffect } from "react";
|
|
104
|
-
var tryUseInsertionEffect = (callback, deps) => {
|
|
105
|
-
try {
|
|
106
|
-
useInsertionEffect(callback, deps);
|
|
107
|
-
} catch {
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
// ../lib-react/src/hooks/tryUseReducer.ts
|
|
112
|
-
import { useReducer } from "react";
|
|
113
|
-
var tryUseReducer = (reducer, initializerArg, initializer) => {
|
|
114
|
-
try {
|
|
115
|
-
return useReducer(reducer, initializerArg, initializer);
|
|
116
|
-
} catch {
|
|
117
|
-
return [initializerArg, () => {
|
|
118
|
-
}];
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
// ../lib-react/src/hooks/tryUseRef.ts
|
|
123
|
-
import { useRef } from "react";
|
|
124
|
-
var tryUseRef = (initialValue) => {
|
|
125
|
-
try {
|
|
126
|
-
return useRef(initialValue);
|
|
127
|
-
} catch {
|
|
128
|
-
return { current: initialValue };
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
// ../lib-react/src/hooks/tryUseState.ts
|
|
133
|
-
import { useState } from "react";
|
|
134
|
-
var tryUseState = (initialState) => {
|
|
135
|
-
try {
|
|
136
|
-
return useState(initialState);
|
|
137
|
-
} catch {
|
|
138
|
-
return [isFunction_default(initialState) ? initialState() : initialState, noop];
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
// ../lib-react/src/hooks/useUpdate.ts
|
|
143
|
-
var updateReducer = (num) => (num + 1) % 1e6;
|
|
144
|
-
function useUpdate() {
|
|
145
|
-
const [, update] = tryUseReducer(updateReducer, 0);
|
|
146
|
-
return update;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// ../lib-react/src/hooks/tryUseUpdate.ts
|
|
150
|
-
function tryUseUpdate() {
|
|
151
|
-
try {
|
|
152
|
-
return useUpdate();
|
|
153
|
-
} catch {
|
|
154
|
-
return () => {
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// src/computed.ts
|
|
160
|
-
import { computed as vueComputed } from "@vue/reactivity";
|
|
161
|
-
|
|
162
|
-
// src/watch.ts
|
|
163
|
-
import { watch as vueWatch } from "@vue/reactivity";
|
|
164
|
-
|
|
165
|
-
// src/lifecycle.ts
|
|
166
|
-
function onMounted(fn) {
|
|
167
|
-
tryUseEffect(() => {
|
|
168
|
-
fn();
|
|
169
|
-
}, []);
|
|
170
|
-
}
|
|
171
|
-
function onBeforeMount(fn) {
|
|
172
|
-
const isMounted = tryUseRef(false);
|
|
173
|
-
if (!isMounted.current) {
|
|
174
|
-
fn();
|
|
175
|
-
isMounted.current = true;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
function onBeforeUnmount(fn) {
|
|
179
|
-
tryUseEffect(() => {
|
|
180
|
-
return () => {
|
|
181
|
-
fn();
|
|
182
|
-
};
|
|
183
|
-
}, []);
|
|
184
|
-
}
|
|
185
|
-
function onUnmounted(fn) {
|
|
186
|
-
onBeforeUnmount(() => setTimeout(fn, 0));
|
|
187
|
-
}
|
|
188
|
-
function onUpdated(fn) {
|
|
189
|
-
const isMounted = tryUseRef(false);
|
|
190
|
-
tryUseEffect(() => {
|
|
191
|
-
isMounted.current ? fn() : isMounted.current = true;
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
function onBeforeUpdate(fn) {
|
|
195
|
-
tryUseInsertionEffect(fn);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
// src/watch.ts
|
|
199
|
-
function watch(source, callback, options = {}) {
|
|
200
|
-
const handle = tryUseRef(void 0);
|
|
201
|
-
const cancel = tryUseCallback(() => {
|
|
202
|
-
if (!handle.current)
|
|
203
|
-
return;
|
|
204
|
-
handle.current();
|
|
205
|
-
handle.current = void 0;
|
|
206
|
-
}, []);
|
|
207
|
-
const create = tryUseCallback(() => {
|
|
208
|
-
handle.current && cancel();
|
|
209
|
-
handle.current = vueWatch(
|
|
210
|
-
source,
|
|
211
|
-
callback,
|
|
212
|
-
{
|
|
213
|
-
...options,
|
|
214
|
-
scheduler: (job) => job()
|
|
215
|
-
}
|
|
216
|
-
);
|
|
217
|
-
cancel.pause = handle.current.pause;
|
|
218
|
-
cancel.resume = handle.current.resume;
|
|
219
|
-
cancel.stop = handle.current.stop;
|
|
220
|
-
}, []);
|
|
221
|
-
!handle.current && create();
|
|
222
|
-
onMounted(create);
|
|
223
|
-
onBeforeUnmount(cancel);
|
|
224
|
-
return cancel;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
// src/computed.ts
|
|
228
|
-
function computed(arg1, arg2) {
|
|
229
|
-
const [ref2] = tryUseState(() => vueComputed(arg1, arg2));
|
|
230
|
-
watch(ref2, tryUseUpdate());
|
|
231
|
-
return ref2;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
// src/effectScope.ts
|
|
235
|
-
import { getCurrentScope as getVueCurrentScope, effectScope as vueEffectScope } from "@vue/reactivity";
|
|
236
|
-
import { createElement } from "react";
|
|
237
|
-
var activeEffectScope;
|
|
238
|
-
function createVueEffectScope(...args) {
|
|
239
|
-
const scope = vueEffectScope(...args);
|
|
240
|
-
Reflect.set(scope, "parent", activeEffectScope);
|
|
241
|
-
if (!args[0] && activeEffectScope) {
|
|
242
|
-
const scopes = activeEffectScope.scopes || (activeEffectScope.scopes = []);
|
|
243
|
-
Reflect.set(scope, "index", scopes.push(scope) - 1);
|
|
244
|
-
}
|
|
245
|
-
return scope;
|
|
246
|
-
}
|
|
247
|
-
function effectScope(...args) {
|
|
248
|
-
const hasRun = tryUseRef(false);
|
|
249
|
-
const [scope] = tryUseState(() => createVueEffectScope(...args));
|
|
250
|
-
const originalRunRef = tryUseRef(scope.run);
|
|
251
|
-
const runFn = tryUseCallback((fn) => {
|
|
252
|
-
if (!hasRun.current) {
|
|
253
|
-
hasRun.current = true;
|
|
254
|
-
return originalRunRef.current.bind(scope)(fn);
|
|
255
|
-
} else {
|
|
256
|
-
return void 0;
|
|
257
|
-
}
|
|
258
|
-
}, []);
|
|
259
|
-
scope.run = runFn;
|
|
260
|
-
return scope;
|
|
261
|
-
}
|
|
262
|
-
function withEffectScope(fn, detached) {
|
|
263
|
-
let currentEffectScope;
|
|
264
|
-
return (...props) => {
|
|
265
|
-
const scope = effectScope(detached);
|
|
266
|
-
const element = createElement(fn, ...props);
|
|
267
|
-
onBeforeMount(() => {
|
|
268
|
-
currentEffectScope = activeEffectScope;
|
|
269
|
-
activeEffectScope = scope;
|
|
270
|
-
});
|
|
271
|
-
onMounted(() => activeEffectScope = currentEffectScope);
|
|
272
|
-
onUnmounted(() => scope.stop());
|
|
273
|
-
return element;
|
|
274
|
-
};
|
|
275
|
-
}
|
|
276
|
-
function getCurrentScope() {
|
|
277
|
-
const [effectScope2] = tryUseState(() => activeEffectScope || getVueCurrentScope());
|
|
278
|
-
return effectScope2;
|
|
279
|
-
}
|
|
280
|
-
function onScopeDispose(fn, _failSilently = false) {
|
|
281
|
-
if (activeEffectScope)
|
|
282
|
-
Reflect.get(activeEffectScope, "cleanups")?.push(fn);
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
// src/reactive.ts
|
|
286
|
-
import { reactive as vueReactive, shallowReactive as vueShallowReactive } from "@vue/reactivity";
|
|
287
|
-
import { useState as useReactState } from "react";
|
|
288
|
-
function reactive(target) {
|
|
289
|
-
const [value] = useReactState(() => vueReactive(target));
|
|
290
|
-
watch(value, tryUseUpdate());
|
|
291
|
-
return value;
|
|
292
|
-
}
|
|
293
|
-
function shallowReactive(target) {
|
|
294
|
-
const [value] = useReactState(() => vueShallowReactive(target));
|
|
295
|
-
watch(value, tryUseUpdate());
|
|
296
|
-
return value;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
// src/reactivity.ts
|
|
300
|
-
function reactivity(getter) {
|
|
301
|
-
watch(() => getter(), tryUseUpdate(), { deep: true });
|
|
302
|
-
return getter();
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
// src/readonly.ts
|
|
306
|
-
import { readonly as vueReadonly, shallowReadonly as vueShallowReadonly } from "@vue/reactivity";
|
|
307
|
-
function readonly(target) {
|
|
308
|
-
const [value] = tryUseState(() => vueReadonly(target));
|
|
309
|
-
watch(value, tryUseUpdate());
|
|
310
|
-
return value;
|
|
311
|
-
}
|
|
312
|
-
function shallowReadonly(target) {
|
|
313
|
-
const [value] = tryUseState(() => vueShallowReadonly(target));
|
|
314
|
-
watch(value, tryUseUpdate());
|
|
315
|
-
return value;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
// src/ref.ts
|
|
319
|
-
import { customRef as vueCustomRef, ref as vueRef, shallowRef as vueShallowRef } from "@vue/reactivity";
|
|
320
|
-
function ref(initValue) {
|
|
321
|
-
const [ref2] = tryUseState(() => {
|
|
322
|
-
const r = vueRef(initValue);
|
|
323
|
-
Object.defineProperty(r, "current", { set: (value) => r.value = value });
|
|
324
|
-
return r;
|
|
325
|
-
});
|
|
326
|
-
watch(ref2, tryUseUpdate(), { deep: true });
|
|
327
|
-
return ref2;
|
|
328
|
-
}
|
|
329
|
-
function customRef(factory) {
|
|
330
|
-
const [ref2] = tryUseState(() => vueCustomRef(factory));
|
|
331
|
-
watch(ref2, tryUseUpdate());
|
|
332
|
-
return ref2;
|
|
333
|
-
}
|
|
334
|
-
function shallowRef(initValue) {
|
|
335
|
-
const [ref2] = tryUseState(() => vueShallowRef(initValue));
|
|
336
|
-
watch(ref2, tryUseUpdate());
|
|
337
|
-
return ref2;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
// src/watchEffect.ts
|
|
341
|
-
import { watch as vueWatch2 } from "@vue/reactivity";
|
|
342
|
-
function watchEffect(effect, options = {}) {
|
|
343
|
-
const [watchHandle] = tryUseState(() => vueWatch2(effect, null, {
|
|
344
|
-
...options,
|
|
345
|
-
scheduler: (job) => job()
|
|
346
|
-
}));
|
|
347
|
-
onBeforeUnmount(() => watchHandle.stop());
|
|
348
|
-
return watchHandle;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
// src/index.ts
|
|
352
|
-
import {
|
|
353
|
-
isProxy,
|
|
354
|
-
isReactive,
|
|
355
|
-
isReadonly,
|
|
356
|
-
isRef,
|
|
357
|
-
isShallow,
|
|
358
|
-
markRaw,
|
|
359
|
-
toRaw,
|
|
360
|
-
toReactive,
|
|
361
|
-
toReadonly,
|
|
362
|
-
toRef,
|
|
363
|
-
toRefs,
|
|
364
|
-
toValue,
|
|
365
|
-
unref
|
|
366
|
-
} from "@vue/reactivity";
|
|
367
|
-
import {
|
|
368
|
-
Fragment,
|
|
369
|
-
createElement as createElement2
|
|
370
|
-
} from "react";
|
|
371
|
-
var getCurrentInstance = noop;
|
|
372
|
-
var hasInjectionContext = noop;
|
|
373
|
-
var inject = noop;
|
|
374
|
-
var provide = noop;
|
|
375
|
-
var nextTick = noop;
|
|
376
|
-
var defineComponent = noop;
|
|
377
|
-
var TransitionGroup = noop;
|
|
378
|
-
export {
|
|
379
|
-
Fragment,
|
|
380
|
-
TransitionGroup,
|
|
381
|
-
computed,
|
|
382
|
-
customRef,
|
|
383
|
-
defineComponent,
|
|
384
|
-
effectScope,
|
|
385
|
-
getCurrentInstance,
|
|
386
|
-
getCurrentScope,
|
|
387
|
-
createElement2 as h,
|
|
388
|
-
hasInjectionContext,
|
|
389
|
-
inject,
|
|
390
|
-
isProxy,
|
|
391
|
-
isReactive,
|
|
392
|
-
isReadonly,
|
|
393
|
-
isRef,
|
|
394
|
-
isShallow,
|
|
395
|
-
markRaw,
|
|
396
|
-
nextTick,
|
|
397
|
-
onBeforeMount,
|
|
398
|
-
onBeforeUnmount,
|
|
399
|
-
onBeforeUpdate,
|
|
400
|
-
onMounted,
|
|
401
|
-
onScopeDispose,
|
|
402
|
-
onUnmounted,
|
|
403
|
-
onUpdated,
|
|
404
|
-
provide,
|
|
405
|
-
reactive,
|
|
406
|
-
reactivity,
|
|
407
|
-
readonly,
|
|
408
|
-
ref,
|
|
409
|
-
shallowReactive,
|
|
410
|
-
shallowReadonly,
|
|
411
|
-
shallowRef,
|
|
412
|
-
toRaw,
|
|
413
|
-
toReactive,
|
|
414
|
-
toReadonly,
|
|
415
|
-
toRef,
|
|
416
|
-
toRefs,
|
|
417
|
-
toValue,
|
|
418
|
-
unref,
|
|
419
|
-
watch,
|
|
420
|
-
watchEffect,
|
|
421
|
-
withEffectScope
|
|
422
|
-
};
|
|
423
|
-
/*! Bundled license information:
|
|
424
|
-
|
|
425
|
-
lodash-es/lodash.js:
|
|
426
|
-
(**
|
|
427
|
-
* @license
|
|
428
|
-
* Lodash (Custom Build) <https://lodash.com/>
|
|
429
|
-
* Build: `lodash modularize exports="es" -o ./`
|
|
430
|
-
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
|
431
|
-
* Released under MIT license <https://lodash.com/license>
|
|
432
|
-
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
433
|
-
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
434
|
-
*)
|
|
435
|
-
*/
|