@hairy/react-lib-composition 1.47.0 → 1.49.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 CHANGED
@@ -1,487 +1,566 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- Fragment: () => import_react9.Fragment,
24
- TransitionGroup: () => TransitionGroup,
25
- computed: () => computed,
26
- customRef: () => customRef,
27
- defineComponent: () => defineComponent,
28
- effectScope: () => effectScope,
29
- getCurrentInstance: () => getCurrentInstance,
30
- getCurrentScope: () => getCurrentScope,
31
- h: () => import_react9.createElement,
32
- hasInjectionContext: () => hasInjectionContext,
33
- inject: () => inject,
34
- isProxy: () => import_reactivity8.isProxy,
35
- isReactive: () => import_reactivity8.isReactive,
36
- isReadonly: () => import_reactivity8.isReadonly,
37
- isRef: () => import_reactivity8.isRef,
38
- isShallow: () => import_reactivity8.isShallow,
39
- markRaw: () => import_reactivity8.markRaw,
40
- nextTick: () => nextTick,
41
- onBeforeMount: () => onBeforeMount,
42
- onBeforeUnmount: () => onBeforeUnmount,
43
- onBeforeUpdate: () => onBeforeUpdate,
44
- onMounted: () => onMounted,
45
- onScopeDispose: () => onScopeDispose,
46
- onUnmounted: () => onUnmounted,
47
- onUpdated: () => onUpdated,
48
- provide: () => provide,
49
- reactive: () => reactive,
50
- reactivity: () => reactivity,
51
- readonly: () => readonly,
52
- ref: () => ref,
53
- shallowReactive: () => shallowReactive,
54
- shallowReadonly: () => shallowReadonly,
55
- shallowRef: () => shallowRef,
56
- toRaw: () => import_reactivity8.toRaw,
57
- toReactive: () => import_reactivity8.toReactive,
58
- toReadonly: () => import_reactivity8.toReadonly,
59
- toRef: () => import_reactivity8.toRef,
60
- toRefs: () => import_reactivity8.toRefs,
61
- toValue: () => import_reactivity8.toValue,
62
- unref: () => import_reactivity8.unref,
63
- watch: () => watch,
64
- watchEffect: () => watchEffect,
65
- withEffectScope: () => withEffectScope
66
- });
67
- module.exports = __toCommonJS(index_exports);
68
-
69
- // ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_freeGlobal.js
70
- var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
71
- var freeGlobal_default = freeGlobal;
72
-
73
- // ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_root.js
74
- var freeSelf = typeof self == "object" && self && self.Object === Object && self;
75
- var root = freeGlobal_default || freeSelf || Function("return this")();
76
- var root_default = root;
77
-
78
- // ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Symbol.js
79
- var Symbol2 = root_default.Symbol;
80
- var Symbol_default = Symbol2;
81
-
82
- // ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getRawTag.js
83
- var objectProto = Object.prototype;
84
- var hasOwnProperty = objectProto.hasOwnProperty;
85
- var nativeObjectToString = objectProto.toString;
86
- var symToStringTag = Symbol_default ? Symbol_default.toStringTag : void 0;
87
- function getRawTag(value) {
88
- var isOwn = hasOwnProperty.call(value, symToStringTag), tag = value[symToStringTag];
89
- try {
90
- value[symToStringTag] = void 0;
91
- var unmasked = true;
92
- } catch (e) {
93
- }
94
- var result = nativeObjectToString.call(value);
95
- if (unmasked) {
96
- if (isOwn) {
97
- value[symToStringTag] = tag;
98
- } else {
99
- delete value[symToStringTag];
100
- }
101
- }
102
- return result;
103
- }
104
- var getRawTag_default = getRawTag;
105
-
106
- // ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_objectToString.js
107
- var objectProto2 = Object.prototype;
108
- var nativeObjectToString2 = objectProto2.toString;
109
- function objectToString(value) {
110
- return nativeObjectToString2.call(value);
111
- }
112
- var objectToString_default = objectToString;
113
-
114
- // ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseGetTag.js
115
- var nullTag = "[object Null]";
116
- var undefinedTag = "[object Undefined]";
117
- var symToStringTag2 = Symbol_default ? Symbol_default.toStringTag : void 0;
118
- function baseGetTag(value) {
119
- if (value == null) {
120
- return value === void 0 ? undefinedTag : nullTag;
121
- }
122
- return symToStringTag2 && symToStringTag2 in Object(value) ? getRawTag_default(value) : objectToString_default(value);
123
- }
124
- var baseGetTag_default = baseGetTag;
125
-
126
- // ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isObject.js
127
- function isObject(value) {
128
- var type = typeof value;
129
- return value != null && (type == "object" || type == "function");
130
- }
131
- var isObject_default = isObject;
132
-
133
- // ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isFunction.js
134
- var asyncTag = "[object AsyncFunction]";
135
- var funcTag = "[object Function]";
136
- var genTag = "[object GeneratorFunction]";
137
- var proxyTag = "[object Proxy]";
138
- function isFunction(value) {
139
- if (!isObject_default(value)) {
140
- return false;
141
- }
142
- var tag = baseGetTag_default(value);
143
- return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
144
- }
145
- var isFunction_default = isFunction;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ let _hairy_utils = require("@hairy/utils");
3
+ let react = require("react");
4
+ let _vue_reactivity = require("@vue/reactivity");
146
5
 
147
- // ../util-core/src/util/noop.ts
148
- var noop = () => {
149
- };
150
-
151
- // ../lib-react/src/hooks/tryUseCallback.ts
152
- var import_react = require("react");
153
- var tryUseCallback = (callback, deps) => {
154
- try {
155
- return (0, import_react.useCallback)(callback, deps);
156
- } catch {
157
- return callback;
158
- }
6
+ //#region ../lib-react/src/hooks/tryUseCallback.ts
7
+ const tryUseCallback = (callback, deps) => {
8
+ try {
9
+ return (0, react.useCallback)(callback, deps);
10
+ } catch {
11
+ return callback;
12
+ }
159
13
  };
160
14
 
161
- // ../lib-react/src/hooks/tryUseEffect.ts
162
- var import_react2 = require("react");
163
- var tryUseEffect = (effect, deps) => {
164
- try {
165
- (0, import_react2.useEffect)(effect, deps);
166
- } catch {
167
- }
15
+ //#endregion
16
+ //#region ../lib-react/src/hooks/tryUseEffect.ts
17
+ const tryUseEffect = (effect, deps) => {
18
+ try {
19
+ (0, react.useEffect)(effect, deps);
20
+ } catch {}
168
21
  };
169
22
 
170
- // ../lib-react/src/hooks/tryUseInsertionEffect.ts
171
- var import_react3 = require("react");
172
- var tryUseInsertionEffect = (callback, deps) => {
173
- try {
174
- (0, import_react3.useInsertionEffect)(callback, deps);
175
- } catch {
176
- }
23
+ //#endregion
24
+ //#region ../lib-react/src/hooks/tryUseInsertionEffect.ts
25
+ const tryUseInsertionEffect = (callback, deps) => {
26
+ try {
27
+ (0, react.useInsertionEffect)(callback, deps);
28
+ } catch {}
177
29
  };
178
30
 
179
- // ../lib-react/src/hooks/tryUseReducer.ts
180
- var import_react4 = require("react");
181
- var tryUseReducer = (reducer, initializerArg, initializer) => {
182
- try {
183
- return (0, import_react4.useReducer)(reducer, initializerArg, initializer);
184
- } catch {
185
- return [initializerArg, () => {
186
- }];
187
- }
31
+ //#endregion
32
+ //#region ../lib-react/src/hooks/tryUseReducer.ts
33
+ const tryUseReducer = (reducer, initializerArg, initializer) => {
34
+ try {
35
+ return (0, react.useReducer)(reducer, initializerArg, initializer);
36
+ } catch {
37
+ return [initializerArg, () => {}];
38
+ }
188
39
  };
189
40
 
190
- // ../lib-react/src/hooks/tryUseRef.ts
191
- var import_react5 = require("react");
192
- var tryUseRef = (initialValue) => {
193
- try {
194
- return (0, import_react5.useRef)(initialValue);
195
- } catch {
196
- return { current: initialValue };
197
- }
41
+ //#endregion
42
+ //#region ../lib-react/src/hooks/tryUseRef.ts
43
+ const tryUseRef = (initialValue) => {
44
+ try {
45
+ return (0, react.useRef)(initialValue);
46
+ } catch {
47
+ return { current: initialValue };
48
+ }
198
49
  };
199
50
 
200
- // ../lib-react/src/hooks/tryUseState.ts
201
- var import_react6 = require("react");
202
- var tryUseState = (initialState) => {
203
- try {
204
- return (0, import_react6.useState)(initialState);
205
- } catch {
206
- return [isFunction_default(initialState) ? initialState() : initialState, noop];
207
- }
51
+ //#endregion
52
+ //#region ../lib-react/src/hooks/tryUseState.ts
53
+ const tryUseState = (initialState) => {
54
+ try {
55
+ return (0, react.useState)(initialState);
56
+ } catch {
57
+ return [(0, _hairy_utils.isFunction)(initialState) ? initialState() : initialState, _hairy_utils.noop];
58
+ }
208
59
  };
209
60
 
210
- // ../lib-react/src/hooks/useUpdate.ts
211
- var updateReducer = (num) => (num + 1) % 1e6;
61
+ //#endregion
62
+ //#region ../lib-react/src/hooks/useUpdate.ts
63
+ const updateReducer = (num) => (num + 1) % 1e6;
212
64
  function useUpdate() {
213
- const [, update] = tryUseReducer(updateReducer, 0);
214
- return update;
65
+ const [, update] = tryUseReducer(updateReducer, 0);
66
+ return update;
215
67
  }
216
68
 
217
- // ../lib-react/src/hooks/tryUseUpdate.ts
69
+ //#endregion
70
+ //#region ../lib-react/src/hooks/tryUseUpdate.ts
218
71
  function tryUseUpdate() {
219
- try {
220
- return useUpdate();
221
- } catch {
222
- return () => {
223
- };
224
- }
72
+ try {
73
+ return useUpdate();
74
+ } catch {
75
+ return () => {};
76
+ }
225
77
  }
226
78
 
227
- // src/computed.ts
228
- var import_reactivity2 = require("@vue/reactivity");
229
-
230
- // src/watch.ts
231
- var import_reactivity = require("@vue/reactivity");
232
-
233
- // src/lifecycle.ts
79
+ //#endregion
80
+ //#region src/lifecycle.ts
81
+ /**
82
+ * The function is called right after the component is mounted.
83
+ *
84
+ * @param fn
85
+ * @see {@link https://react.dev/reference/react/Component#componentdidmount React `componentDidMount()`}
86
+ */
234
87
  function onMounted(fn) {
235
- tryUseEffect(() => {
236
- fn();
237
- }, []);
88
+ tryUseEffect(() => {
89
+ fn();
90
+ }, []);
238
91
  }
239
92
  function onBeforeMount(fn) {
240
- const isMounted = tryUseRef(false);
241
- if (!isMounted.current) {
242
- fn();
243
- isMounted.current = true;
244
- }
93
+ const isMounted = tryUseRef(false);
94
+ if (!isMounted.current) {
95
+ fn();
96
+ isMounted.current = true;
97
+ }
245
98
  }
99
+ /**
100
+ * The function is called right before the component is unmounted.
101
+ *
102
+ * @param fn
103
+ * @see {@link https://react.dev/reference/react/Component#componentwillunmount React `componentWillUnmount()`}
104
+ */
246
105
  function onBeforeUnmount(fn) {
247
- tryUseEffect(() => {
248
- return () => {
249
- fn();
250
- };
251
- }, []);
106
+ tryUseEffect(() => {
107
+ return () => {
108
+ fn();
109
+ };
110
+ }, []);
252
111
  }
253
112
  function onUnmounted(fn) {
254
- onBeforeUnmount(() => setTimeout(fn, 0));
113
+ onBeforeUnmount(() => setTimeout(fn, 0));
255
114
  }
115
+ /**
116
+ * The function is called immediately after the component is re-rendered with updated props or state.
117
+ * This method is not invoked during the initial render.
118
+ *
119
+ * @param fn
120
+ * @see {@link https://react.dev/reference/react/Component#componentdidupdate React `componentDidUpdate()`}
121
+ */
256
122
  function onUpdated(fn) {
257
- const isMounted = tryUseRef(false);
258
- tryUseEffect(() => {
259
- isMounted.current ? fn() : isMounted.current = true;
260
- });
123
+ const isMounted = tryUseRef(false);
124
+ tryUseEffect(() => {
125
+ isMounted.current ? fn() : isMounted.current = true;
126
+ });
261
127
  }
262
128
  function onBeforeUpdate(fn) {
263
- tryUseInsertionEffect(fn);
129
+ tryUseInsertionEffect(fn);
264
130
  }
265
131
 
266
- // src/watch.ts
132
+ //#endregion
133
+ //#region src/watch.ts
267
134
  function watch(source, callback, options = {}) {
268
- const handle = tryUseRef(void 0);
269
- const cancel = tryUseCallback(() => {
270
- if (!handle.current)
271
- return;
272
- handle.current();
273
- handle.current = void 0;
274
- }, []);
275
- const create = tryUseCallback(() => {
276
- handle.current && cancel();
277
- handle.current = (0, import_reactivity.watch)(
278
- source,
279
- callback,
280
- {
281
- ...options,
282
- scheduler: (job) => job()
283
- }
284
- );
285
- cancel.pause = handle.current.pause;
286
- cancel.resume = handle.current.resume;
287
- cancel.stop = handle.current.stop;
288
- }, []);
289
- !handle.current && create();
290
- onMounted(create);
291
- onBeforeUnmount(cancel);
292
- return cancel;
135
+ const handle = tryUseRef(void 0);
136
+ const cancel = tryUseCallback(() => {
137
+ if (!handle.current) return;
138
+ handle.current();
139
+ handle.current = void 0;
140
+ }, []);
141
+ const create = tryUseCallback(() => {
142
+ handle.current && cancel();
143
+ handle.current = (0, _vue_reactivity.watch)(source, callback, {
144
+ ...options,
145
+ scheduler: (job) => job()
146
+ });
147
+ cancel.pause = handle.current.pause;
148
+ cancel.resume = handle.current.resume;
149
+ cancel.stop = handle.current.stop;
150
+ }, []);
151
+ !handle.current && create();
152
+ onMounted(create);
153
+ onBeforeUnmount(cancel);
154
+ return cancel;
293
155
  }
294
156
 
295
- // src/computed.ts
157
+ //#endregion
158
+ //#region src/computed.ts
296
159
  function computed(arg1, arg2) {
297
- const [ref2] = tryUseState(() => (0, import_reactivity2.computed)(arg1, arg2));
298
- watch(ref2, tryUseUpdate());
299
- return ref2;
160
+ const [ref] = tryUseState(() => (0, _vue_reactivity.computed)(arg1, arg2));
161
+ watch(ref, tryUseUpdate());
162
+ return ref;
300
163
  }
301
164
 
302
- // src/effectScope.ts
303
- var import_reactivity3 = require("@vue/reactivity");
304
- var import_react7 = require("react");
305
- var activeEffectScope;
165
+ //#endregion
166
+ //#region src/effectScope.ts
167
+ let activeEffectScope;
306
168
  function createVueEffectScope(...args) {
307
- const scope = (0, import_reactivity3.effectScope)(...args);
308
- Reflect.set(scope, "parent", activeEffectScope);
309
- if (!args[0] && activeEffectScope) {
310
- const scopes = activeEffectScope.scopes || (activeEffectScope.scopes = []);
311
- Reflect.set(scope, "index", scopes.push(scope) - 1);
312
- }
313
- return scope;
169
+ const scope = (0, _vue_reactivity.effectScope)(...args);
170
+ Reflect.set(scope, "parent", activeEffectScope);
171
+ if (!args[0] && activeEffectScope) {
172
+ const scopes = activeEffectScope.scopes || (activeEffectScope.scopes = []);
173
+ Reflect.set(scope, "index", scopes.push(scope) - 1);
174
+ }
175
+ return scope;
314
176
  }
177
+ /**
178
+ * Creates an effect scope object which can capture the reactive effects (i.e.
179
+ * computed and watchers) created within it so that these effects can be
180
+ * disposed together. For detailed use cases of this API, please consult its
181
+ * corresponding {@link https://github.com/vuejs/rfcs/blob/master/active-rfcs/0041-reactivity-effect-scope.md | RFC}.
182
+ *
183
+ * @param detached - Can be used to create a "detached" effect scope.
184
+ * @see {@link https://vuejs.org/api/reactivity-advanced.html#effectscope Vue `effectScope()`}
185
+ */
315
186
  function effectScope(...args) {
316
- const hasRun = tryUseRef(false);
317
- const [scope] = tryUseState(() => createVueEffectScope(...args));
318
- const originalRunRef = tryUseRef(scope.run);
319
- const runFn = tryUseCallback((fn) => {
320
- if (!hasRun.current) {
321
- hasRun.current = true;
322
- return originalRunRef.current.bind(scope)(fn);
323
- } else {
324
- return void 0;
325
- }
326
- }, []);
327
- scope.run = runFn;
328
- return scope;
187
+ const hasRun = tryUseRef(false);
188
+ const [scope] = tryUseState(() => createVueEffectScope(...args));
189
+ const originalRunRef = tryUseRef(scope.run);
190
+ scope.run = tryUseCallback((fn) => {
191
+ if (!hasRun.current) {
192
+ hasRun.current = true;
193
+ return originalRunRef.current.bind(scope)(fn);
194
+ } else return;
195
+ }, []);
196
+ return scope;
329
197
  }
330
198
  function withEffectScope(fn, detached) {
331
- let currentEffectScope;
332
- return (...props) => {
333
- const scope = effectScope(detached);
334
- const element = (0, import_react7.createElement)(fn, ...props);
335
- onBeforeMount(() => {
336
- currentEffectScope = activeEffectScope;
337
- activeEffectScope = scope;
338
- });
339
- onMounted(() => activeEffectScope = currentEffectScope);
340
- onUnmounted(() => scope.stop());
341
- return element;
342
- };
199
+ let currentEffectScope;
200
+ return ((...props) => {
201
+ const scope = effectScope(detached);
202
+ const element = (0, react.createElement)(fn, ...props);
203
+ onBeforeMount(() => {
204
+ currentEffectScope = activeEffectScope;
205
+ activeEffectScope = scope;
206
+ });
207
+ onMounted(() => activeEffectScope = currentEffectScope);
208
+ onUnmounted(() => scope.stop());
209
+ return element;
210
+ });
343
211
  }
212
+ /**
213
+ * Returns the current active effect scope if there is one.
214
+ *
215
+ * @see {@link https://vuejs.org/api/reactivity-advanced.html#getcurrentscope}
216
+ */
344
217
  function getCurrentScope() {
345
- const [effectScope2] = tryUseState(() => activeEffectScope || (0, import_reactivity3.getCurrentScope)());
346
- return effectScope2;
218
+ const [effectScope] = tryUseState(() => activeEffectScope || (0, _vue_reactivity.getCurrentScope)());
219
+ return effectScope;
347
220
  }
221
+ /**
222
+ * Registers a dispose callback on the current active effect scope. The
223
+ * callback will be invoked when the associated effect scope is stopped.
224
+ *
225
+ * @param fn - The callback function to attach to the scope's cleanup.
226
+ * @see {@link https://vuejs.org/api/reactivity-advanced.html#onscopedispose}
227
+ */
348
228
  function onScopeDispose(fn, _failSilently = false) {
349
- if (activeEffectScope)
350
- Reflect.get(activeEffectScope, "cleanups")?.push(fn);
229
+ if (activeEffectScope) Reflect.get(activeEffectScope, "cleanups")?.push(fn);
351
230
  }
352
231
 
353
- // src/reactive.ts
354
- var import_reactivity4 = require("@vue/reactivity");
355
- var import_react8 = require("react");
232
+ //#endregion
233
+ //#region src/reactive.ts
356
234
  function reactive(target) {
357
- const [value] = (0, import_react8.useState)(() => (0, import_reactivity4.reactive)(target));
358
- watch(value, tryUseUpdate());
359
- return value;
235
+ const [value] = (0, react.useState)(() => (0, _vue_reactivity.reactive)(target));
236
+ watch(value, tryUseUpdate());
237
+ return value;
360
238
  }
239
+ /**
240
+ * Shallow version of {@link reactive()}.
241
+ *
242
+ * Unlike {@link reactive()}, there is no deep conversion: only root-level
243
+ * properties are reactive for a shallow reactive object. Property values are
244
+ * stored and exposed as-is - this also means properties with ref values will
245
+ * not be automatically unwrapped.
246
+ *
247
+ * @param target - The source object.
248
+ * @see {@link https://vuejs.org/api/reactivity-advanced.html#shallowreactive Vue `shallowReactive()`}
249
+ *
250
+ * @example
251
+ * ```js
252
+ * const state = shallowReactive({
253
+ * foo: 1,
254
+ * nested: {
255
+ * bar: 2
256
+ * }
257
+ * })
258
+ *
259
+ * // mutating state's own properties is reactive
260
+ * state.foo++
261
+ *
262
+ * // ...but does not convert nested objects
263
+ * isReactive(state.nested) // false
264
+ *
265
+ * // NOT reactive
266
+ * state.nested.bar++
267
+ * ```
268
+ */
361
269
  function shallowReactive(target) {
362
- const [value] = (0, import_react8.useState)(() => (0, import_reactivity4.shallowReactive)(target));
363
- watch(value, tryUseUpdate());
364
- return value;
270
+ const [value] = (0, react.useState)(() => (0, _vue_reactivity.shallowReactive)(target));
271
+ watch(value, tryUseUpdate());
272
+ return value;
365
273
  }
366
274
 
367
- // src/reactivity.ts
275
+ //#endregion
276
+ //#region src/reactivity.ts
277
+ /**
278
+ * Converts some of the 'raw Vue' data, which is not already wrapped in a hook,
279
+ * into reactive hook data to ensure proper reactivity within the component.
280
+ *
281
+ * @param getter - A function that returns the data to be deeply watched.
282
+ * @example
283
+ * ```tsx
284
+ * import React from 'react'
285
+ * import { ref, reactivity } from 'veact'
286
+ *
287
+ * const countRef = ref(0)
288
+ *
289
+ * export const Component: React.FC = () => {
290
+ * // Convert to a reactivity hook
291
+ * const count = reactivity(() => countRef)
292
+ * const increment = () => {
293
+ * count.value++
294
+ * }
295
+ *
296
+ * return (
297
+ * <div>
298
+ * <span>{count.value}</span>
299
+ * <button onClick={increment}>Increment</button>
300
+ * </div>
301
+ * )
302
+ * }
303
+ * ```
304
+ */
368
305
  function reactivity(getter) {
369
- watch(() => getter(), tryUseUpdate(), { deep: true });
370
- return getter();
306
+ watch(() => getter(), tryUseUpdate(), { deep: true });
307
+ return getter();
371
308
  }
372
309
 
373
- // src/readonly.ts
374
- var import_reactivity5 = require("@vue/reactivity");
310
+ //#endregion
311
+ //#region src/readonly.ts
312
+ /**
313
+ * Takes an object (reactive or plain) or a ref and returns a readonly proxy to
314
+ * the original.
315
+ *
316
+ * A readonly proxy is deep: any nested property accessed will be readonly as
317
+ * well. It also has the same ref-unwrapping behavior as {@link reactive()},
318
+ * except the unwrapped values will also be made readonly.
319
+ *
320
+ * @param target - The source object.
321
+ * @see {@link https://vuejs.org/api/reactivity-core.html#readonly Vue `readonly()`}
322
+ *
323
+ * @example
324
+ * ```js
325
+ * const original = reactive({ count: 0 })
326
+ * const copy = readonly(original)
327
+ *
328
+ * useWatchEffect(() => {
329
+ * // works for reactivity tracking
330
+ * console.log(copy.count)
331
+ * })
332
+ *
333
+ * // mutating original will trigger watchers relying on the copy
334
+ * original.count++
335
+ *
336
+ * // mutating the copy will fail and result in a warning
337
+ * copy.count++ // warning!
338
+ * ```
339
+ */
375
340
  function readonly(target) {
376
- const [value] = tryUseState(() => (0, import_reactivity5.readonly)(target));
377
- watch(value, tryUseUpdate());
378
- return value;
341
+ const [value] = tryUseState(() => (0, _vue_reactivity.readonly)(target));
342
+ watch(value, tryUseUpdate());
343
+ return value;
379
344
  }
345
+ /**
346
+ * Shallow version of {@link readonly()}.
347
+ *
348
+ * Unlike {@link readonly()}, there is no deep conversion: only root-level
349
+ * properties are made readonly. Property values are stored and exposed as-is -
350
+ * this also means properties with ref values will not be automatically
351
+ * unwrapped.
352
+ *
353
+ * @param target - The source object.
354
+ * @see {@link https://vuejs.org/api/reactivity-advanced.html#shallowreadonly Vue `shallowReadonly()`}
355
+ *
356
+ * @example
357
+ * ```js
358
+ * const state = shallowReadonly({
359
+ * foo: 1,
360
+ * nested: {
361
+ * bar: 2
362
+ * }
363
+ * })
364
+ *
365
+ * // mutating state's own properties will fail
366
+ * state.foo++
367
+ *
368
+ * // ...but works on nested objects
369
+ * isReadonly(state.nested) // false
370
+ *
371
+ * // works
372
+ * state.nested.bar++
373
+ * ```
374
+ */
380
375
  function shallowReadonly(target) {
381
- const [value] = tryUseState(() => (0, import_reactivity5.shallowReadonly)(target));
382
- watch(value, tryUseUpdate());
383
- return value;
376
+ const [value] = tryUseState(() => (0, _vue_reactivity.shallowReadonly)(target));
377
+ watch(value, tryUseUpdate());
378
+ return value;
384
379
  }
385
380
 
386
- // src/ref.ts
387
- var import_reactivity6 = require("@vue/reactivity");
381
+ //#endregion
382
+ //#region src/ref.ts
388
383
  function ref(initValue) {
389
- const [ref2] = tryUseState(() => {
390
- const r = (0, import_reactivity6.ref)(initValue);
391
- Object.defineProperty(r, "current", { set: (value) => r.value = value });
392
- return r;
393
- });
394
- watch(ref2, tryUseUpdate(), { deep: true });
395
- return ref2;
384
+ const [ref] = tryUseState(() => {
385
+ const r = (0, _vue_reactivity.ref)(initValue);
386
+ Object.defineProperty(r, "current", { set: (value) => r.value = value });
387
+ return r;
388
+ });
389
+ watch(ref, tryUseUpdate(), { deep: true });
390
+ return ref;
396
391
  }
392
+ /**
393
+ * Creates a customized ref with explicit control over its dependency tracking
394
+ * and updates triggering.
395
+ *
396
+ * @param factory - The function that receives the `track` and `trigger` callbacks.
397
+ * @see {@link https://vuejs.org/api/reactivity-advanced.html#customref Vue `customRef()`}
398
+ */
397
399
  function customRef(factory) {
398
- const [ref2] = tryUseState(() => (0, import_reactivity6.customRef)(factory));
399
- watch(ref2, tryUseUpdate());
400
- return ref2;
400
+ const [ref] = tryUseState(() => (0, _vue_reactivity.customRef)(factory));
401
+ watch(ref, tryUseUpdate());
402
+ return ref;
401
403
  }
402
404
  function shallowRef(initValue) {
403
- const [ref2] = tryUseState(() => (0, import_reactivity6.shallowRef)(initValue));
404
- watch(ref2, tryUseUpdate());
405
- return ref2;
405
+ const [ref] = tryUseState(() => (0, _vue_reactivity.shallowRef)(initValue));
406
+ watch(ref, tryUseUpdate());
407
+ return ref;
406
408
  }
407
409
 
408
- // src/watchEffect.ts
409
- var import_reactivity7 = require("@vue/reactivity");
410
+ //#endregion
411
+ //#region src/watchEffect.ts
412
+ /**
413
+ * Runs a function immediately while reactively tracking its dependencies and re-runs it whenever the dependencies are changed.
414
+ *
415
+ * @param effect - The effect function to run.
416
+ * @param options - An optional options object that can be used to adjust the effect's flush timing or to debug the effect's dependencies; the `flush` option is not supported compared to Vue (3.5.0).
417
+ * @see {@link https://vuejs.org/api/reactivity-core.html#watcheffect Vue `watchEffect()`}
418
+ *
419
+ * @example
420
+ * ```js
421
+ * const count = useRef(0)
422
+ * watchEffect(() => console.log(count.value))
423
+ * // -> logs 0
424
+ *
425
+ * count.value++
426
+ * // -> logs 1
427
+ * ```
428
+ */
410
429
  function watchEffect(effect, options = {}) {
411
- const [watchHandle] = tryUseState(() => (0, import_reactivity7.watch)(effect, null, {
412
- ...options,
413
- scheduler: (job) => job()
414
- }));
415
- onBeforeUnmount(() => watchHandle.stop());
416
- return watchHandle;
430
+ const [watchHandle] = tryUseState(() => (0, _vue_reactivity.watch)(effect, null, {
431
+ ...options,
432
+ scheduler: (job) => job()
433
+ }));
434
+ onBeforeUnmount(() => watchHandle.stop());
435
+ return watchHandle;
417
436
  }
418
437
 
419
- // src/index.ts
420
- var import_reactivity8 = require("@vue/reactivity");
421
- var import_react9 = require("react");
422
- var getCurrentInstance = noop;
423
- var hasInjectionContext = noop;
424
- var inject = noop;
425
- var provide = noop;
426
- var nextTick = noop;
427
- var defineComponent = noop;
428
- var TransitionGroup = noop;
429
- // Annotate the CommonJS export names for ESM import in node:
430
- 0 && (module.exports = {
431
- Fragment,
432
- TransitionGroup,
433
- computed,
434
- customRef,
435
- defineComponent,
436
- effectScope,
437
- getCurrentInstance,
438
- getCurrentScope,
439
- h,
440
- hasInjectionContext,
441
- inject,
442
- isProxy,
443
- isReactive,
444
- isReadonly,
445
- isRef,
446
- isShallow,
447
- markRaw,
448
- nextTick,
449
- onBeforeMount,
450
- onBeforeUnmount,
451
- onBeforeUpdate,
452
- onMounted,
453
- onScopeDispose,
454
- onUnmounted,
455
- onUpdated,
456
- provide,
457
- reactive,
458
- reactivity,
459
- readonly,
460
- ref,
461
- shallowReactive,
462
- shallowReadonly,
463
- shallowRef,
464
- toRaw,
465
- toReactive,
466
- toReadonly,
467
- toRef,
468
- toRefs,
469
- toValue,
470
- unref,
471
- watch,
472
- watchEffect,
473
- withEffectScope
474
- });
475
- /*! Bundled license information:
438
+ //#endregion
439
+ //#region src/index.ts
440
+ const getCurrentInstance = _hairy_utils.noop;
441
+ const hasInjectionContext = _hairy_utils.noop;
442
+ const inject = _hairy_utils.noop;
443
+ const provide = _hairy_utils.noop;
444
+ const nextTick = _hairy_utils.noop;
445
+ const defineComponent = _hairy_utils.noop;
446
+ const TransitionGroup = _hairy_utils.noop;
476
447
 
477
- lodash-es/lodash.js:
478
- (**
479
- * @license
480
- * Lodash (Custom Build) <https://lodash.com/>
481
- * Build: `lodash modularize exports="es" -o ./`
482
- * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
483
- * Released under MIT license <https://lodash.com/license>
484
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
485
- * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
486
- *)
487
- */
448
+ //#endregion
449
+ Object.defineProperty(exports, 'Fragment', {
450
+ enumerable: true,
451
+ get: function () {
452
+ return react.Fragment;
453
+ }
454
+ });
455
+ exports.TransitionGroup = TransitionGroup;
456
+ exports.computed = computed;
457
+ exports.customRef = customRef;
458
+ exports.defineComponent = defineComponent;
459
+ exports.effectScope = effectScope;
460
+ exports.getCurrentInstance = getCurrentInstance;
461
+ exports.getCurrentScope = getCurrentScope;
462
+ Object.defineProperty(exports, 'h', {
463
+ enumerable: true,
464
+ get: function () {
465
+ return react.createElement;
466
+ }
467
+ });
468
+ exports.hasInjectionContext = hasInjectionContext;
469
+ exports.inject = inject;
470
+ Object.defineProperty(exports, 'isProxy', {
471
+ enumerable: true,
472
+ get: function () {
473
+ return _vue_reactivity.isProxy;
474
+ }
475
+ });
476
+ Object.defineProperty(exports, 'isReactive', {
477
+ enumerable: true,
478
+ get: function () {
479
+ return _vue_reactivity.isReactive;
480
+ }
481
+ });
482
+ Object.defineProperty(exports, 'isReadonly', {
483
+ enumerable: true,
484
+ get: function () {
485
+ return _vue_reactivity.isReadonly;
486
+ }
487
+ });
488
+ Object.defineProperty(exports, 'isRef', {
489
+ enumerable: true,
490
+ get: function () {
491
+ return _vue_reactivity.isRef;
492
+ }
493
+ });
494
+ Object.defineProperty(exports, 'isShallow', {
495
+ enumerable: true,
496
+ get: function () {
497
+ return _vue_reactivity.isShallow;
498
+ }
499
+ });
500
+ Object.defineProperty(exports, 'markRaw', {
501
+ enumerable: true,
502
+ get: function () {
503
+ return _vue_reactivity.markRaw;
504
+ }
505
+ });
506
+ exports.nextTick = nextTick;
507
+ exports.onBeforeMount = onBeforeMount;
508
+ exports.onBeforeUnmount = onBeforeUnmount;
509
+ exports.onBeforeUpdate = onBeforeUpdate;
510
+ exports.onMounted = onMounted;
511
+ exports.onScopeDispose = onScopeDispose;
512
+ exports.onUnmounted = onUnmounted;
513
+ exports.onUpdated = onUpdated;
514
+ exports.provide = provide;
515
+ exports.reactive = reactive;
516
+ exports.reactivity = reactivity;
517
+ exports.readonly = readonly;
518
+ exports.ref = ref;
519
+ exports.shallowReactive = shallowReactive;
520
+ exports.shallowReadonly = shallowReadonly;
521
+ exports.shallowRef = shallowRef;
522
+ Object.defineProperty(exports, 'toRaw', {
523
+ enumerable: true,
524
+ get: function () {
525
+ return _vue_reactivity.toRaw;
526
+ }
527
+ });
528
+ Object.defineProperty(exports, 'toReactive', {
529
+ enumerable: true,
530
+ get: function () {
531
+ return _vue_reactivity.toReactive;
532
+ }
533
+ });
534
+ Object.defineProperty(exports, 'toReadonly', {
535
+ enumerable: true,
536
+ get: function () {
537
+ return _vue_reactivity.toReadonly;
538
+ }
539
+ });
540
+ Object.defineProperty(exports, 'toRef', {
541
+ enumerable: true,
542
+ get: function () {
543
+ return _vue_reactivity.toRef;
544
+ }
545
+ });
546
+ Object.defineProperty(exports, 'toRefs', {
547
+ enumerable: true,
548
+ get: function () {
549
+ return _vue_reactivity.toRefs;
550
+ }
551
+ });
552
+ Object.defineProperty(exports, 'toValue', {
553
+ enumerable: true,
554
+ get: function () {
555
+ return _vue_reactivity.toValue;
556
+ }
557
+ });
558
+ Object.defineProperty(exports, 'unref', {
559
+ enumerable: true,
560
+ get: function () {
561
+ return _vue_reactivity.unref;
562
+ }
563
+ });
564
+ exports.watch = watch;
565
+ exports.watchEffect = watchEffect;
566
+ exports.withEffectScope = withEffectScope;