yummies 7.11.0 → 7.13.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.
Files changed (159) hide show
  1. package/README.md +5 -87
  2. package/async.cjs +179 -48
  3. package/async.cjs.map +1 -1
  4. package/async.d.ts +125 -7
  5. package/async.js +180 -54
  6. package/async.js.map +1 -1
  7. package/chunk-CVq3Gv4J.cjs +50 -0
  8. package/chunk-YKewjYmz.js +37 -0
  9. package/common.cjs +48 -8
  10. package/common.cjs.map +1 -1
  11. package/common.d.ts +53 -2
  12. package/common.js +49 -11
  13. package/common.js.map +1 -1
  14. package/complex.cjs +275 -128
  15. package/complex.cjs.map +1 -1
  16. package/complex.d.ts +66 -0
  17. package/complex.js +275 -133
  18. package/complex.js.map +1 -1
  19. package/cookie.cjs +17 -7
  20. package/cookie.cjs.map +1 -1
  21. package/cookie.d.ts +26 -0
  22. package/cookie.js +18 -9
  23. package/cookie.js.map +1 -1
  24. package/css.cjs +163 -39
  25. package/css.cjs.map +1 -1
  26. package/css.d.ts +115 -6
  27. package/css.js +159 -41
  28. package/css.js.map +1 -1
  29. package/data.cjs +90 -55
  30. package/data.cjs.map +1 -1
  31. package/data.d.ts +50 -0
  32. package/data.js +91 -61
  33. package/data.js.map +1 -1
  34. package/date-time.cjs +594 -412
  35. package/date-time.cjs.map +1 -1
  36. package/date-time.d.ts +105 -0
  37. package/date-time.js +591 -421
  38. package/date-time.js.map +1 -1
  39. package/device.cjs +65 -23
  40. package/device.cjs.map +1 -1
  41. package/device.d.ts +49 -0
  42. package/device.js +66 -31
  43. package/device.js.map +1 -1
  44. package/encodings.cjs +275 -266
  45. package/encodings.cjs.map +1 -1
  46. package/encodings.d.ts +25 -0
  47. package/encodings.js +276 -268
  48. package/encodings.js.map +1 -1
  49. package/errors.cjs +36 -18
  50. package/errors.cjs.map +1 -1
  51. package/errors.d.ts +17 -0
  52. package/errors.js +35 -19
  53. package/errors.js.map +1 -1
  54. package/file.cjs +58 -24
  55. package/file.cjs.map +1 -1
  56. package/file.d.ts +32 -0
  57. package/file.js +59 -27
  58. package/file.js.map +1 -1
  59. package/format.cjs +125 -83
  60. package/format.cjs.map +1 -1
  61. package/format.d.ts +18 -0
  62. package/format.js +118 -82
  63. package/format.js.map +1 -1
  64. package/html.cjs +242 -137
  65. package/html.cjs.map +1 -1
  66. package/html.d.ts +81 -0
  67. package/html.js +239 -150
  68. package/html.js.map +1 -1
  69. package/id.cjs +90 -17
  70. package/id.cjs.map +1 -1
  71. package/id.d.ts +16 -0
  72. package/id.js +89 -24
  73. package/id.js.map +1 -1
  74. package/imports.cjs +57 -29
  75. package/imports.cjs.map +1 -1
  76. package/imports.d.ts +24 -0
  77. package/imports.js +56 -31
  78. package/imports.js.map +1 -1
  79. package/math.cjs +32 -6
  80. package/math.cjs.map +1 -1
  81. package/math.d.ts +33 -0
  82. package/math.js +33 -10
  83. package/math.js.map +1 -1
  84. package/media.cjs +291 -84
  85. package/media.cjs.map +1 -1
  86. package/media.d.ts +204 -2
  87. package/media.js +290 -93
  88. package/media.js.map +1 -1
  89. package/mobx.cjs +449 -193
  90. package/mobx.cjs.map +1 -1
  91. package/mobx.d.ts +108 -0
  92. package/mobx.js +447 -200
  93. package/mobx.js.map +1 -1
  94. package/ms.cjs +37 -10
  95. package/ms.cjs.map +1 -1
  96. package/ms.d.ts +16 -0
  97. package/ms.js +38 -13
  98. package/ms.js.map +1 -1
  99. package/number.cjs +29 -7
  100. package/number.cjs.map +1 -1
  101. package/number.d.ts +16 -0
  102. package/number.js +30 -9
  103. package/number.js.map +1 -1
  104. package/package.json +11 -3
  105. package/parser.cjs +117 -64
  106. package/parser.cjs.map +1 -1
  107. package/parser.d.ts +17 -0
  108. package/parser.js +111 -64
  109. package/parser.js.map +1 -1
  110. package/price.cjs +24 -18
  111. package/price.cjs.map +1 -1
  112. package/price.d.ts +24 -0
  113. package/price.js +25 -20
  114. package/price.js.map +1 -1
  115. package/random.cjs +95 -13
  116. package/random.cjs.map +1 -1
  117. package/random.d.ts +80 -0
  118. package/random.js +96 -22
  119. package/random.js.map +1 -1
  120. package/react.cjs +673 -214
  121. package/react.cjs.map +1 -1
  122. package/react.d.ts +21 -0
  123. package/react.js +674 -239
  124. package/react.js.map +1 -1
  125. package/sound.cjs +30 -9
  126. package/sound.cjs.map +1 -1
  127. package/sound.d.ts +16 -0
  128. package/sound.js +31 -11
  129. package/sound.js.map +1 -1
  130. package/storage.cjs +49 -50
  131. package/storage.cjs.map +1 -1
  132. package/storage.d.ts +24 -0
  133. package/storage.js +50 -53
  134. package/storage.js.map +1 -1
  135. package/text.cjs +67 -34
  136. package/text.cjs.map +1 -1
  137. package/text.d.ts +16 -0
  138. package/text.js +68 -37
  139. package/text.js.map +1 -1
  140. package/type-guard.cjs +292 -72
  141. package/type-guard.cjs.map +1 -1
  142. package/type-guard.d.ts +18 -0
  143. package/type-guard.js +288 -73
  144. package/type-guard.js.map +1 -1
  145. package/types.cjs +0 -2
  146. package/types.d.ts +41 -0
  147. package/types.global.cjs +0 -2
  148. package/types.global.d.ts +41 -0
  149. package/types.global.js +0 -2
  150. package/types.js +0 -2
  151. package/vibrate.cjs +47 -6
  152. package/vibrate.cjs.map +1 -1
  153. package/vibrate.d.ts +39 -1
  154. package/vibrate.js +48 -8
  155. package/vibrate.js.map +1 -1
  156. package/types.cjs.map +0 -1
  157. package/types.global.cjs.map +0 -1
  158. package/types.global.js.map +0 -1
  159. package/types.js.map +0 -1
package/mobx.cjs CHANGED
@@ -1,202 +1,457 @@
1
- "use strict";
2
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const mobx = require("mobx");
4
- const typeGuard = require("yummies/type-guard");
5
- const applyObservable = (context, annotationsArray, useDecorators) => {
6
- if (useDecorators) {
7
- annotationsArray.forEach(([annotation, ...fields]) => {
8
- fields.forEach((field) => {
9
- annotation(context, field);
10
- });
11
- });
12
- mobx.makeObservable(context);
13
- } else {
14
- const annotationsObject = {};
15
- annotationsArray.forEach(([annotation, ...fields]) => {
16
- fields.forEach((field) => {
17
- annotationsObject[field] = annotation;
18
- });
19
- });
20
- mobx.makeObservable(context, annotationsObject);
21
- }
2
+ require("./chunk-CVq3Gv4J.cjs");
3
+ let yummies_type_guard = require("yummies/type-guard");
4
+ let mobx = require("mobx");
5
+ //#region src/mobx/apply-observable.ts
6
+ /**
7
+ * ---header-docs-section---
8
+ * # yummies/mobx
9
+ *
10
+ * ## Description
11
+ *
12
+ * Compact **MobX `makeObservable`** wiring from tuple lists of annotations and keys. Reduces boilerplate
13
+ * when many fields share `observable`, `action`, or `computed` decorators and you want one call site
14
+ * instead of sprawling annotation maps across large stores.
15
+ *
16
+ * ## Usage
17
+ *
18
+ * ```ts
19
+ * import { applyObservable } from "yummies/mobx";
20
+ * ```
21
+ */
22
+ /**
23
+ * Applies a compact list of MobX annotations to an object using either
24
+ * decorator-style invocation or the annotation map form accepted by `makeObservable`.
25
+ *
26
+ * @template T Target object type.
27
+ * @param context Object that should become observable.
28
+ * @param annotationsArray Tuples of annotation followed by annotated field names.
29
+ * @param useDecorators Enables decorator-style application before calling `makeObservable`.
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * applyObservable(store, [[observable, 'items'], [action, 'setItems']]);
34
+ * ```
35
+ *
36
+ * @example
37
+ * ```ts
38
+ * applyObservable(viewModel, [[computed, 'fullName']], true);
39
+ * ```
40
+ */
41
+ var applyObservable = (context, annotationsArray, useDecorators) => {
42
+ if (useDecorators) {
43
+ annotationsArray.forEach(([annotation, ...fields]) => {
44
+ fields.forEach((field) => {
45
+ annotation(context, field);
46
+ });
47
+ });
48
+ (0, mobx.makeObservable)(context);
49
+ } else {
50
+ const annotationsObject = {};
51
+ annotationsArray.forEach(([annotation, ...fields]) => {
52
+ fields.forEach((field) => {
53
+ annotationsObject[field] = annotation;
54
+ });
55
+ });
56
+ (0, mobx.makeObservable)(context, annotationsObject);
57
+ }
22
58
  };
23
- const createEnhancedAtom = (name, onBecomeObservedHandler, onBecomeUnobservedHandler, meta) => {
24
- const atom = mobx.createAtom(
25
- name,
26
- onBecomeObservedHandler && (() => onBecomeObservedHandler(atom)),
27
- onBecomeUnobservedHandler && (() => onBecomeUnobservedHandler(atom))
28
- );
29
- atom.meta = meta ?? {};
30
- atom.reportChanged = atom.reportChanged.bind(atom);
31
- atom.reportObserved = atom.reportObserved.bind(atom);
32
- return atom;
59
+ //#endregion
60
+ //#region src/mobx/create-enhanced-atom.ts
61
+ /**
62
+ * ---header-docs-section---
63
+ * # yummies/mobx
64
+ *
65
+ * ## Description
66
+ *
67
+ * **`createAtom` wrapper** that attaches arbitrary metadata and keeps MobX’s observed/unobserved
68
+ * hooks in one place. Useful for custom reactive primitives, async resources, or debugging atoms
69
+ * where the stock API is too bare.
70
+ *
71
+ * ## Usage
72
+ *
73
+ * ```ts
74
+ * import { createEnhancedAtom } from "yummies/mobx";
75
+ * ```
76
+ */
77
+ /**
78
+ * Creates a MobX atom extended with metadata and bound reporting methods.
79
+ *
80
+ * @template TMeta Metadata object stored on the atom.
81
+ * @param name Atom name used by MobX for debugging.
82
+ * @param onBecomeObservedHandler Callback fired when the atom becomes observed.
83
+ * @param onBecomeUnobservedHandler Callback fired when the atom is no longer observed.
84
+ * @param meta Optional metadata attached to the atom.
85
+ * @returns Atom instance with `meta`, `reportChanged` and `reportObserved`.
86
+ *
87
+ * @example
88
+ * ```ts
89
+ * const atom = createEnhancedAtom('user-status');
90
+ * atom.reportChanged();
91
+ * ```
92
+ *
93
+ * @example
94
+ * ```ts
95
+ * const atom = createEnhancedAtom('cache', undefined, undefined, { scope: 'users' });
96
+ * atom.meta.scope;
97
+ * ```
98
+ */
99
+ var createEnhancedAtom = (name, onBecomeObservedHandler, onBecomeUnobservedHandler, meta) => {
100
+ const atom = (0, mobx.createAtom)(name, onBecomeObservedHandler && (() => onBecomeObservedHandler(atom)), onBecomeUnobservedHandler && (() => onBecomeUnobservedHandler(atom)));
101
+ atom.meta = meta ?? {};
102
+ atom.reportChanged = atom.reportChanged.bind(atom);
103
+ atom.reportObserved = atom.reportObserved.bind(atom);
104
+ return atom;
33
105
  };
34
- const createRef = (cfg) => {
35
- let lastValue;
36
- const comparer = cfg?.comparer ?? mobx.comparer.default;
37
- const setValue = (value) => {
38
- const nextValue = value ?? null;
39
- if (comparer(ref.current, nextValue)) {
40
- return;
41
- }
42
- mobx.runInAction(() => {
43
- const prevLastValue = lastValue;
44
- lastValue = ref.current ?? void 0;
45
- ref.current = nextValue;
46
- let isNextValueIgnored = false;
47
- ref.listeners.forEach((listener) => {
48
- const listenerResult = listener(ref.current, lastValue);
49
- if (listenerResult === false) {
50
- isNextValueIgnored = true;
51
- }
52
- });
53
- if (isNextValueIgnored) {
54
- lastValue = prevLastValue;
55
- ref.current = lastValue ?? null;
56
- } else if (ref.current === null && lastValue !== void 0) {
57
- lastValue = void 0;
58
- }
59
- });
60
- };
61
- const ref = setValue;
62
- ref.set = setValue;
63
- ref.listeners = new Set(cfg?.onChange ? [cfg.onChange] : []);
64
- if (cfg?.onSet || cfg?.onUnset) {
65
- ref.listeners.add((value, prevValue) => {
66
- if (value) {
67
- cfg.onSet?.(value, prevValue);
68
- } else {
69
- cfg.onUnset?.(prevValue);
70
- }
71
- });
72
- }
73
- ref.current = cfg?.initial ?? null;
74
- ref.meta = cfg?.meta ?? {};
75
- mobx.makeObservable(ref, {
76
- current: mobx.observable.ref,
77
- meta: mobx.observable
78
- });
79
- return ref;
106
+ //#endregion
107
+ //#region src/mobx/create-ref.ts
108
+ /**
109
+ * ---header-docs-section---
110
+ * # yummies/mobx
111
+ *
112
+ * ## Description
113
+ *
114
+ * **Observable ref** pattern for MobX: boxed mutable references with change listeners, metadata,
115
+ * and optional custom equality. Bridges React-style ref holders and MobX reactivity when a single
116
+ * mutable cell must notify dependents without replacing the whole parent object graph.
117
+ *
118
+ * ## Usage
119
+ *
120
+ * ```ts
121
+ * import { createRef } from "yummies/mobx";
122
+ * ```
123
+ */
124
+ /**
125
+ * Creates a MobX-aware ref that behaves like a callback ref and exposes
126
+ * observable `current` and `meta` fields.
127
+ *
128
+ * @template T Referenced value type.
129
+ * @template TMeta Additional observable metadata stored on the ref.
130
+ * @param cfg Optional callbacks, initial value and comparer configuration.
131
+ * @returns Observable ref function object.
132
+ *
133
+ * @example
134
+ * ```ts
135
+ * const inputRef = createRef<HTMLInputElement>();
136
+ * inputRef.set(document.createElement('input'));
137
+ * ```
138
+ *
139
+ * @example
140
+ * ```ts
141
+ * const ref = createRef<number>();
142
+ * ref(3);
143
+ * ref.current; // 3
144
+ * ```
145
+ *
146
+ * @example
147
+ * ```ts
148
+ * const nodeRef = createRef({
149
+ * onUnset: () => console.log('detached'),
150
+ * meta: { mounted: false },
151
+ * });
152
+ * ```
153
+ */
154
+ var createRef = (cfg) => {
155
+ let lastValue;
156
+ const comparer = cfg?.comparer ?? mobx.comparer.default;
157
+ const setValue = (value) => {
158
+ const nextValue = value ?? null;
159
+ if (comparer(ref.current, nextValue)) return;
160
+ (0, mobx.runInAction)(() => {
161
+ const prevLastValue = lastValue;
162
+ lastValue = ref.current ?? void 0;
163
+ ref.current = nextValue;
164
+ let isNextValueIgnored = false;
165
+ ref.listeners.forEach((listener) => {
166
+ if (listener(ref.current, lastValue) === false) isNextValueIgnored = true;
167
+ });
168
+ if (isNextValueIgnored) {
169
+ lastValue = prevLastValue;
170
+ ref.current = lastValue ?? null;
171
+ } else if (ref.current === null && lastValue !== void 0) lastValue = void 0;
172
+ });
173
+ };
174
+ const ref = setValue;
175
+ ref.set = setValue;
176
+ ref.listeners = new Set(cfg?.onChange ? [cfg.onChange] : []);
177
+ if (cfg?.onSet || cfg?.onUnset) ref.listeners.add((value, prevValue) => {
178
+ if (value) cfg.onSet?.(value, prevValue);
179
+ else cfg.onUnset?.(prevValue);
180
+ });
181
+ ref.current = cfg?.initial ?? null;
182
+ ref.meta = cfg?.meta ?? {};
183
+ (0, mobx.makeObservable)(ref, {
184
+ current: mobx.observable.ref,
185
+ meta: mobx.observable
186
+ });
187
+ return ref;
80
188
  };
81
- const isRef = (value) => {
82
- return typeof value === "function" && "current" in value;
189
+ /**
190
+ * Checks whether the provided value is a ref created by `createRef`.
191
+ *
192
+ * @template T Referenced value type.
193
+ * @template TMeta Ref metadata type.
194
+ * @param value Value to inspect.
195
+ * @returns `true` when the value is a ref-like function with `current`.
196
+ *
197
+ * @example
198
+ * ```ts
199
+ * const ref = createRef<number>();
200
+ * isRef(ref); // true
201
+ * ```
202
+ *
203
+ * @example
204
+ * ```ts
205
+ * isRef({ current: 1 }); // false
206
+ * ```
207
+ */
208
+ var isRef = (value) => {
209
+ return typeof value === "function" && "current" in value;
83
210
  };
84
- const toRef = (value, cfg) => {
85
- return isRef(value) ? value : createRef({ initial: value, ...cfg });
211
+ /**
212
+ * Normalizes a plain value or an existing ref into a `Ref` instance.
213
+ *
214
+ * @template T Referenced value type.
215
+ * @template TMeta Ref metadata type.
216
+ * @param value Existing ref or initial plain value.
217
+ * @param cfg Optional ref configuration applied when a new ref is created.
218
+ * @returns Existing ref or a newly created ref initialized with `value`.
219
+ *
220
+ * @example
221
+ * ```ts
222
+ * const ref = toRef(document.body);
223
+ * ref.current === document.body;
224
+ * ```
225
+ *
226
+ * @example
227
+ * ```ts
228
+ * const existingRef = createRef<number>();
229
+ * const sameRef = toRef(existingRef);
230
+ * ```
231
+ */
232
+ var toRef = (value, cfg) => {
233
+ return isRef(value) ? value : createRef({
234
+ initial: value,
235
+ ...cfg
236
+ });
86
237
  };
87
- class DeepObservableStruct {
88
- data;
89
- constructor(data) {
90
- this.data = data;
91
- mobx.makeObservable(this, {
92
- data: mobx.observable.deep,
93
- set: mobx.action
94
- });
95
- }
96
- set(newData) {
97
- const stack = Object.keys(this.data).map((key) => [
98
- key,
99
- this.data,
100
- newData
101
- ]);
102
- let currentIndex = 0;
103
- let stackLength = stack.length;
104
- while (currentIndex < stackLength) {
105
- const [key, currObservableData, newData2] = stack[currentIndex];
106
- const newValue = newData2[key];
107
- const currValue = currObservableData[key];
108
- currentIndex++;
109
- if (key in newData2) {
110
- if (typeGuard.typeGuard.isObject(newValue) && typeGuard.typeGuard.isObject(currValue)) {
111
- const newValueKeys = Object.keys(newValue);
112
- Object.keys(currValue).forEach((childKey) => {
113
- if (!(childKey in newValue)) {
114
- delete currObservableData[key][childKey];
115
- }
116
- });
117
- newValueKeys.forEach((childKey) => {
118
- const length = stack.push([
119
- childKey,
120
- currObservableData[key],
121
- newValue
122
- ]);
123
- stackLength = length;
124
- });
125
- } else if (newValue !== currValue) {
126
- currObservableData[key] = newValue;
127
- }
128
- } else {
129
- delete currObservableData[key];
130
- }
131
- }
132
- Object.keys(newData).forEach((newDataKey) => {
133
- if (!this.data[newDataKey]) {
134
- this.data[newDataKey] = newData[newDataKey];
135
- }
136
- });
137
- }
138
- }
139
- const getMobxAdministration = (context) => context[mobx.$mobx];
140
- const lazyObserve = ({
141
- context,
142
- property,
143
- onStart,
144
- onEnd,
145
- endDelay = false
146
- }) => {
147
- let timeoutId;
148
- let metaData;
149
- const observingProps = /* @__PURE__ */ new Set();
150
- const properties = Array.isArray(property) ? property : [property];
151
- const cleanup = () => {
152
- observingProps.clear();
153
- if (endDelay === false) {
154
- onEnd?.(metaData, cleanup);
155
- metaData = void 0;
156
- return;
157
- }
158
- if (timeoutId) {
159
- clearTimeout(timeoutId);
160
- timeoutId = void 0;
161
- }
162
- timeoutId = setTimeout(() => {
163
- onEnd?.(metaData, cleanup);
164
- timeoutId = void 0;
165
- metaData = void 0;
166
- }, endDelay);
167
- };
168
- const start = (property2) => {
169
- const isAlreadyObserving = observingProps.size > 0;
170
- observingProps.add(property2);
171
- if (isAlreadyObserving) {
172
- return;
173
- }
174
- if (timeoutId) {
175
- clearTimeout(timeoutId);
176
- timeoutId = void 0;
177
- }
178
- metaData = onStart?.();
179
- };
180
- const stop = (property2) => {
181
- const isAlreadyNotObserving = !observingProps.size;
182
- observingProps.delete(property2);
183
- const isObserving = observingProps.size > 0;
184
- if (isAlreadyNotObserving || isObserving) {
185
- return;
186
- }
187
- cleanup();
188
- };
189
- properties.forEach((property2) => {
190
- if (context) {
191
- mobx.onBecomeObserved(context, property2, () => start(property2));
192
- mobx.onBecomeUnobserved(context, property2, () => stop(property2));
193
- } else {
194
- mobx.onBecomeObserved(property2, () => start(property2));
195
- mobx.onBecomeUnobserved(property2, () => stop(property2));
196
- }
197
- });
198
- return cleanup;
238
+ //#endregion
239
+ //#region src/mobx/deep-observable-struct.ts
240
+ /**
241
+ * ---header-docs-section---
242
+ * # yummies/mobx
243
+ *
244
+ * ## Description
245
+ *
246
+ * **Deep observable object** with structural `set` patches that reuse nested observables when keys
247
+ * overlap. Helps store trees (forms, filters, entities) under MobX without wholesale replacement
248
+ * and without manual `observable.map` wiring for every level.
249
+ *
250
+ * ## Usage
251
+ *
252
+ * ```ts
253
+ * import { DeepObservableStruct } from "yummies/mobx";
254
+ * ```
255
+ */
256
+ /**
257
+ * Wraps a plain object into a deeply observable structure and allows
258
+ * patch-like updates while preserving nested observable references where possible.
259
+ *
260
+ * @template TData Observable object shape.
261
+ *
262
+ * @example
263
+ * ```ts
264
+ * const state = new DeepObservableStruct({ user: { name: 'Ann' } });
265
+ * state.set({ user: { name: 'Bob' } });
266
+ * ```
267
+ *
268
+ * @example
269
+ * ```ts
270
+ * const state = new DeepObservableStruct({ filters: { active: true } });
271
+ * state.set({ filters: { active: false, archived: true } });
272
+ * ```
273
+ */
274
+ var DeepObservableStruct = class {
275
+ data;
276
+ constructor(data) {
277
+ this.data = data;
278
+ (0, mobx.makeObservable)(this, {
279
+ data: mobx.observable.deep,
280
+ set: mobx.action
281
+ });
282
+ }
283
+ set(newData) {
284
+ const stack = Object.keys(this.data).map((key) => [
285
+ key,
286
+ this.data,
287
+ newData
288
+ ]);
289
+ let currentIndex = 0;
290
+ let stackLength = stack.length;
291
+ while (currentIndex < stackLength) {
292
+ const [key, currObservableData, newData] = stack[currentIndex];
293
+ const newValue = newData[key];
294
+ const currValue = currObservableData[key];
295
+ currentIndex++;
296
+ if (key in newData) {
297
+ if (yummies_type_guard.typeGuard.isObject(newValue) && yummies_type_guard.typeGuard.isObject(currValue)) {
298
+ const newValueKeys = Object.keys(newValue);
299
+ Object.keys(currValue).forEach((childKey) => {
300
+ if (!(childKey in newValue)) delete currObservableData[key][childKey];
301
+ });
302
+ newValueKeys.forEach((childKey) => {
303
+ stackLength = stack.push([
304
+ childKey,
305
+ currObservableData[key],
306
+ newValue
307
+ ]);
308
+ });
309
+ } else if (newValue !== currValue) currObservableData[key] = newValue;
310
+ } else delete currObservableData[key];
311
+ }
312
+ Object.keys(newData).forEach((newDataKey) => {
313
+ if (!this.data[newDataKey]) this.data[newDataKey] = newData[newDataKey];
314
+ });
315
+ }
199
316
  };
317
+ //#endregion
318
+ //#region src/mobx/get-mobx-administration.ts
319
+ /**
320
+ * ---header-docs-section---
321
+ * # yummies/mobx
322
+ *
323
+ * ## Description
324
+ *
325
+ * Typed access to MobX **internal administration** (`$mobx`) for advanced tooling, migration scripts,
326
+ * or introspection. Prefer public MobX APIs in application code; reach for this when you must align
327
+ * with library internals or patch behavior at the administration layer.
328
+ *
329
+ * ## Usage
330
+ *
331
+ * ```ts
332
+ * import { getMobxAdministration } from "yummies/mobx";
333
+ * ```
334
+ */
335
+ /**
336
+ * Returns the internal MobX administration object associated with an observable target.
337
+ *
338
+ * @param context Observable object instance.
339
+ * @returns MobX administration internals stored under `$mobx`.
340
+ *
341
+ * @example
342
+ * ```ts
343
+ * const admin = getMobxAdministration(store);
344
+ * admin.name_;
345
+ * ```
346
+ *
347
+ * @example
348
+ * ```ts
349
+ * const values = getMobxAdministration(formState).values_;
350
+ * ```
351
+ */
352
+ var getMobxAdministration = (context) => context[mobx.$mobx];
353
+ //#endregion
354
+ //#region src/mobx/lazy-observe.ts
355
+ /**
356
+ * ---header-docs-section---
357
+ * # yummies/mobx
358
+ *
359
+ * ## Description
360
+ *
361
+ * **Lazy subscriptions** tied to MobX observation: start work when the first reaction observes
362
+ * tracked keys, stop when nothing listens anymore (optionally after a delay). Ideal for polling,
363
+ * WebSocket feeds, or expensive caches that should idle when the UI is not mounted.
364
+ *
365
+ * ## Usage
366
+ *
367
+ * ```ts
368
+ * import { lazyObserve } from "yummies/mobx";
369
+ * ```
370
+ */
371
+ /**
372
+ * Starts side effects only while one or more MobX observables are being observed.
373
+ *
374
+ * When the first property becomes observed, `onStart` is called. When all tracked
375
+ * properties become unobserved, `onEnd` is called with the value returned by
376
+ * `onStart`. Cleanup can be delayed via `endDelay`.
377
+ *
378
+ * It uses MobX `onBecomeObserved` and `onBecomeUnobserved` hooks to perform
379
+ * lazy subscription management.
380
+ *
381
+ * @template TMetaData Data returned from `onStart` and forwarded to `onEnd`.
382
+ * @param config Configuration for tracked properties and lifecycle callbacks.
383
+ * @returns Cleanup function that clears the tracked state and runs `onEnd`.
384
+ *
385
+ * @example
386
+ * ```ts
387
+ * const stop = lazyObserve({
388
+ * context: store,
389
+ * property: 'items',
390
+ * onStart: () => api.subscribe(),
391
+ * onEnd: (subscription) => subscription.unsubscribe(),
392
+ * });
393
+ * ```
394
+ *
395
+ * @example
396
+ * ```ts
397
+ * lazyObserve({
398
+ * property: [boxA, boxB],
399
+ * onStart: () => console.log('observed'),
400
+ * endDelay: 300,
401
+ * });
402
+ * ```
403
+ */
404
+ var lazyObserve = ({ context, property, onStart, onEnd, endDelay = false }) => {
405
+ let timeoutId;
406
+ let metaData;
407
+ const observingProps = /* @__PURE__ */ new Set();
408
+ const properties = Array.isArray(property) ? property : [property];
409
+ const cleanup = () => {
410
+ observingProps.clear();
411
+ if (endDelay === false) {
412
+ onEnd?.(metaData, cleanup);
413
+ metaData = void 0;
414
+ return;
415
+ }
416
+ if (timeoutId) {
417
+ clearTimeout(timeoutId);
418
+ timeoutId = void 0;
419
+ }
420
+ timeoutId = setTimeout(() => {
421
+ onEnd?.(metaData, cleanup);
422
+ timeoutId = void 0;
423
+ metaData = void 0;
424
+ }, endDelay);
425
+ };
426
+ const start = (property) => {
427
+ const isAlreadyObserving = observingProps.size > 0;
428
+ observingProps.add(property);
429
+ if (isAlreadyObserving) return;
430
+ if (timeoutId) {
431
+ clearTimeout(timeoutId);
432
+ timeoutId = void 0;
433
+ }
434
+ metaData = onStart?.();
435
+ };
436
+ const stop = (property) => {
437
+ const isAlreadyNotObserving = !observingProps.size;
438
+ observingProps.delete(property);
439
+ const isObserving = observingProps.size > 0;
440
+ if (isAlreadyNotObserving || isObserving) return;
441
+ cleanup();
442
+ };
443
+ properties.forEach((property) => {
444
+ if (context) {
445
+ (0, mobx.onBecomeObserved)(context, property, () => start(property));
446
+ (0, mobx.onBecomeUnobserved)(context, property, () => stop(property));
447
+ } else {
448
+ (0, mobx.onBecomeObserved)(property, () => start(property));
449
+ (0, mobx.onBecomeUnobserved)(property, () => stop(property));
450
+ }
451
+ });
452
+ return cleanup;
453
+ };
454
+ //#endregion
200
455
  exports.DeepObservableStruct = DeepObservableStruct;
201
456
  exports.applyObservable = applyObservable;
202
457
  exports.createEnhancedAtom = createEnhancedAtom;
@@ -205,4 +460,5 @@ exports.getMobxAdministration = getMobxAdministration;
205
460
  exports.isRef = isRef;
206
461
  exports.lazyObserve = lazyObserve;
207
462
  exports.toRef = toRef;
208
- //# sourceMappingURL=mobx.cjs.map
463
+
464
+ //# sourceMappingURL=mobx.cjs.map