tracked-instance 1.0.12 → 1.0.14

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/README.md CHANGED
@@ -187,7 +187,7 @@ console.log(items.value[0].meta.isValidName.value) // false
187
187
  ```
188
188
 
189
189
  ### Real-world example
190
- [Try on playground](https://play.vuejs.org/#eNp9VcFu1DAQ/ZUhl81K2+QAp9W2orQ90ENBLZwIBzfx7rrrOJHtbLda5RsQSAhxob+BhMTH8AP0ExjbSdZJu+xlbc945s2b58k2OC7LaF3RYBrMVCpZqUFRXZVHiWB5WUgNW0nnNcxlkcMIHUc7Q6XoScE5TTUrROuiJUlXNDtgQmkiUuOfiLTAHWyZOmVS302AZNkEmKa5moCkebGm5h8TT4AXJDslmtRwCL0E4dhEas3hh60gOZ3C6BzzjeoJdPtiKfp7Oqo/2ssOhqC37xWVF2jGHFhdOBp5ZkXW9GRJxIIqNIdjODyCbSKgQxZa4NGa8IpGOSlDe2D9zCJqK48ydHZuY4xfJ2IWO4qRXNygb8mJprgDmF1XWhd4DPibZkyRa06zwyR41pCWBM72MuUsXaHBw+lsNg7Aw/2X33CFRkgbqwkfu/h+rl0oS30SHP35/uvvz09wabb9G0sJsUWN64ytjxpQU9huoVlDXc9iY/PcHKLjLDOkm3bKqTuaMVFW2q0B1gd5kVGOSLzetAUD6LuSok3TDYJ0hwaMjTMsBZUVNp33YtVjU92PrxaKgdGvzodd8TZ02x+ENy8kxrZ9Rt2KjG7G+OcUjJFboDPO0JnNbdusFNSlVXfmZOC5Dino07BPR5GpbEfMHnJ8gp4kyT250BWCoB7uv33GrpvDHjG9632kvSIv6G1boO/V5euXY9WGr9nz9bIB+Cr0UDwGZhM7CQ5woBa7nsSctR2N+08utr02y6ZLrqFWop4ObFOdAoy9a3w0Z1xTic/fvf1htw2zLYoO456e+oCH3XpKSTiZ5oQro6iWLhyU1zgKBzx15TfV9jgIJoGb5Qc4xqIbVQj8DNhZh1mtAdWNBLtQKLLBbDfGJFhqXappHFeiXC2itMjjx34mAlZYY0atcM7O2WKQD++VjFP5pjTDvp+XcF7cntszLSs6ac/TJU1XT5zfqI2D9tZoTa4RQGfTRC7MsDPms6sL+2w6I76/ijdl7TGiLAteGYzO7VUlMoTt+Vm0ry19TCzeqbONpkK1RRmglg3rnwT4ST35T+k7uM+jFx2L9T/LBo48)
190
+ [Try on playground](https://play.vuejs.org/#eNp9VcFy0zAQ/ZWtL3ZnUvsAp5BmKG0P9FCYFk6Yg2sriRpZ9khymk7G38DADMNwob/BDDN8DD9AP4GVZDuym3BJLO1q973dp9XGOynLcFURb+xNZCpoqUASVZXTmNO8LISCjSCzGmaiyMFHR39rqCQ5LRgjqaIFb12USNIlyY4olyrhqfaPeVrgCjZUnlGh7keQZNkIqCK5HIEgebEi+h8Tj4AVSXaWqKSGY+glCA51pNYcfNjwJCdj8C8wn1+PoFsXC95fE7/+aA5bGJzcvZdEXKIZcyC7wPcds0xW5HSR8DmRaA4O4XgKm5hDhyzQC7Dww1XCKmI3AMIZZYqIQJv0sQP9EVJ5ZShm1hlTNd55UgbG1+Swvk3VwgwTOf74U8d8EtkWYXNwgf4lSxTBFcDkplKqwG0deZxRmdwwkh3H3kFT9Niztpcpo+kSDQ5PazNxAB4fvvyGazRC2lh1+MjGd3NtQ5nWxd70z/dff39+giu97J9YCIgMavzO6GragBrDZgPNN9T1JNI2x80iOsky3TQtBzG2WxPKy0q1lVwd5UVGGCJxetsSBlD3JUGbImsEaTc1GBNnSAWVGTTKcWLVhy8GsvF9zffHVwNOA+vzdYlUrE3WdgwBzwqB2Uz38SbwjKwP8c+KCiO30CeMojOdmUbuEJPjOixKvzD71BVqrttS7SmXW7KdZbOXOLBEENTjw7fPqAO92StM73gfaY/kJblrCbpeXb4+HaM/nA+Or5MNwNWlg+IpMJPYinKAA9XZ9SRitO1o1L+Ekem1/my6ZBtqROvowDTVKsCMirbx7fwIqJ0IT0fHtt0dxj09dQEPu7VLSajpWcKkVlRbLhy9NzhcB3Xq6DdsezXwRp59HY5wuIW3suD4sJjpiVmNAdWNBbahUGSD10IbY2+hVCnHUVTxcjkP0yKPnvrpCMiwxoxK4uSe0fkgH54rKSPiTamfj37ehLHi7sLsKVGRUbufLki63LF/K9cW2lutNbFCAJ1NJWKux582n19fmmvTGfH+VayhtceIsixYpTFat1cVzxC242fQvjblo3z+Tp6vFeGyJaWBmmoY/9jDR/r0P9S3cJ+Fz7sq1v8AiAKmmg==)
191
191
  ```vue
192
192
  <script setup>
193
193
  import {ref} from 'vue'
@@ -200,7 +200,11 @@ console.log(items.value[0].meta.isValidName.value) // false
200
200
  const newUserName = ref('')
201
201
 
202
202
  const saveChanges = () => {
203
- loadData(items.value.map((item) => item.instance.data.value))
203
+ loadData(
204
+ items.value
205
+ .filter(item => !item.isRemoved.value)
206
+ .map((item) => item.instance.data.value)
207
+ )
204
208
  }
205
209
  </script>
206
210
 
@@ -222,7 +226,7 @@ console.log(items.value[0].meta.isValidName.value) // false
222
226
  v-model="newUserName"
223
227
  type="text"
224
228
  />
225
- <button @click="add({name: newUserName})">➕ Add user</button>
229
+ <button @click="add({name: newUserName}); newUserName = ''">➕ Add user</button>
226
230
  </div>
227
231
 
228
232
  <ul>
package/dist/index.mjs CHANGED
@@ -186,6 +186,41 @@ function getNative(object, key) {
186
186
  }
187
187
  var getNative_default = getNative;
188
188
 
189
+ // node_modules/lodash-es/_WeakMap.js
190
+ var WeakMap = getNative_default(root_default, "WeakMap");
191
+ var WeakMap_default = WeakMap;
192
+
193
+ // node_modules/lodash-es/_baseCreate.js
194
+ var objectCreate = Object.create;
195
+ var baseCreate = /* @__PURE__ */ function() {
196
+ function object() {
197
+ }
198
+ return function(proto) {
199
+ if (!isObject_default(proto)) {
200
+ return {};
201
+ }
202
+ if (objectCreate) {
203
+ return objectCreate(proto);
204
+ }
205
+ object.prototype = proto;
206
+ var result = new object();
207
+ object.prototype = void 0;
208
+ return result;
209
+ };
210
+ }();
211
+ var baseCreate_default = baseCreate;
212
+
213
+ // node_modules/lodash-es/_copyArray.js
214
+ function copyArray(source, array) {
215
+ var index = -1, length = source.length;
216
+ array || (array = Array(length));
217
+ while (++index < length) {
218
+ array[index] = source[index];
219
+ }
220
+ return array;
221
+ }
222
+ var copyArray_default = copyArray;
223
+
189
224
  // node_modules/lodash-es/_defineProperty.js
190
225
  var defineProperty = function() {
191
226
  try {
@@ -197,6 +232,18 @@ var defineProperty = function() {
197
232
  }();
198
233
  var defineProperty_default = defineProperty;
199
234
 
235
+ // node_modules/lodash-es/_arrayEach.js
236
+ function arrayEach(array, iteratee) {
237
+ var index = -1, length = array == null ? 0 : array.length;
238
+ while (++index < length) {
239
+ if (iteratee(array[index], index, array) === false) {
240
+ break;
241
+ }
242
+ }
243
+ return array;
244
+ }
245
+ var arrayEach_default = arrayEach;
246
+
200
247
  // node_modules/lodash-es/_isIndex.js
201
248
  var MAX_SAFE_INTEGER = 9007199254740991;
202
249
  var reIsUint = /^(?:0|[1-9]\d*)$/;
@@ -239,6 +286,27 @@ function assignValue(object, key, value) {
239
286
  }
240
287
  var assignValue_default = assignValue;
241
288
 
289
+ // node_modules/lodash-es/_copyObject.js
290
+ function copyObject(source, props, object, customizer) {
291
+ var isNew = !object;
292
+ object || (object = {});
293
+ var index = -1, length = props.length;
294
+ while (++index < length) {
295
+ var key = props[index];
296
+ var newValue = customizer ? customizer(object[key], source[key], key, object, source) : void 0;
297
+ if (newValue === void 0) {
298
+ newValue = source[key];
299
+ }
300
+ if (isNew) {
301
+ baseAssignValue_default(object, key, newValue);
302
+ } else {
303
+ assignValue_default(object, key, newValue);
304
+ }
305
+ }
306
+ return object;
307
+ }
308
+ var copyObject_default = copyObject;
309
+
242
310
  // node_modules/lodash-es/isLength.js
243
311
  var MAX_SAFE_INTEGER2 = 9007199254740991;
244
312
  function isLength(value) {
@@ -246,6 +314,30 @@ function isLength(value) {
246
314
  }
247
315
  var isLength_default = isLength;
248
316
 
317
+ // node_modules/lodash-es/isArrayLike.js
318
+ function isArrayLike(value) {
319
+ return value != null && isLength_default(value.length) && !isFunction_default(value);
320
+ }
321
+ var isArrayLike_default = isArrayLike;
322
+
323
+ // node_modules/lodash-es/_isPrototype.js
324
+ var objectProto5 = Object.prototype;
325
+ function isPrototype(value) {
326
+ var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto5;
327
+ return value === proto;
328
+ }
329
+ var isPrototype_default = isPrototype;
330
+
331
+ // node_modules/lodash-es/_baseTimes.js
332
+ function baseTimes(n, iteratee) {
333
+ var index = -1, result = Array(n);
334
+ while (++index < n) {
335
+ result[index] = iteratee(index);
336
+ }
337
+ return result;
338
+ }
339
+ var baseTimes_default = baseTimes;
340
+
249
341
  // node_modules/lodash-es/_baseIsArguments.js
250
342
  var argsTag = "[object Arguments]";
251
343
  function baseIsArguments(value) {
@@ -254,9 +346,9 @@ function baseIsArguments(value) {
254
346
  var baseIsArguments_default = baseIsArguments;
255
347
 
256
348
  // node_modules/lodash-es/isArguments.js
257
- var objectProto5 = Object.prototype;
258
- var hasOwnProperty4 = objectProto5.hasOwnProperty;
259
- var propertyIsEnumerable = objectProto5.propertyIsEnumerable;
349
+ var objectProto6 = Object.prototype;
350
+ var hasOwnProperty4 = objectProto6.hasOwnProperty;
351
+ var propertyIsEnumerable = objectProto6.propertyIsEnumerable;
260
352
  var isArguments = baseIsArguments_default(/* @__PURE__ */ function() {
261
353
  return arguments;
262
354
  }()) ? baseIsArguments_default : function(value) {
@@ -264,6 +356,172 @@ var isArguments = baseIsArguments_default(/* @__PURE__ */ function() {
264
356
  };
265
357
  var isArguments_default = isArguments;
266
358
 
359
+ // node_modules/lodash-es/stubFalse.js
360
+ function stubFalse() {
361
+ return false;
362
+ }
363
+ var stubFalse_default = stubFalse;
364
+
365
+ // node_modules/lodash-es/isBuffer.js
366
+ var freeExports = typeof exports == "object" && exports && !exports.nodeType && exports;
367
+ var freeModule = freeExports && typeof module == "object" && module && !module.nodeType && module;
368
+ var moduleExports = freeModule && freeModule.exports === freeExports;
369
+ var Buffer = moduleExports ? root_default.Buffer : void 0;
370
+ var nativeIsBuffer = Buffer ? Buffer.isBuffer : void 0;
371
+ var isBuffer = nativeIsBuffer || stubFalse_default;
372
+ var isBuffer_default = isBuffer;
373
+
374
+ // node_modules/lodash-es/_baseIsTypedArray.js
375
+ var argsTag2 = "[object Arguments]";
376
+ var arrayTag = "[object Array]";
377
+ var boolTag = "[object Boolean]";
378
+ var dateTag = "[object Date]";
379
+ var errorTag = "[object Error]";
380
+ var funcTag2 = "[object Function]";
381
+ var mapTag = "[object Map]";
382
+ var numberTag = "[object Number]";
383
+ var objectTag = "[object Object]";
384
+ var regexpTag = "[object RegExp]";
385
+ var setTag = "[object Set]";
386
+ var stringTag = "[object String]";
387
+ var weakMapTag = "[object WeakMap]";
388
+ var arrayBufferTag = "[object ArrayBuffer]";
389
+ var dataViewTag = "[object DataView]";
390
+ var float32Tag = "[object Float32Array]";
391
+ var float64Tag = "[object Float64Array]";
392
+ var int8Tag = "[object Int8Array]";
393
+ var int16Tag = "[object Int16Array]";
394
+ var int32Tag = "[object Int32Array]";
395
+ var uint8Tag = "[object Uint8Array]";
396
+ var uint8ClampedTag = "[object Uint8ClampedArray]";
397
+ var uint16Tag = "[object Uint16Array]";
398
+ var uint32Tag = "[object Uint32Array]";
399
+ var typedArrayTags = {};
400
+ typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true;
401
+ typedArrayTags[argsTag2] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag2] = typedArrayTags[mapTag] = typedArrayTags[numberTag] = typedArrayTags[objectTag] = typedArrayTags[regexpTag] = typedArrayTags[setTag] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;
402
+ function baseIsTypedArray(value) {
403
+ return isObjectLike_default(value) && isLength_default(value.length) && !!typedArrayTags[baseGetTag_default(value)];
404
+ }
405
+ var baseIsTypedArray_default = baseIsTypedArray;
406
+
407
+ // node_modules/lodash-es/_baseUnary.js
408
+ function baseUnary(func) {
409
+ return function(value) {
410
+ return func(value);
411
+ };
412
+ }
413
+ var baseUnary_default = baseUnary;
414
+
415
+ // node_modules/lodash-es/_nodeUtil.js
416
+ var freeExports2 = typeof exports == "object" && exports && !exports.nodeType && exports;
417
+ var freeModule2 = freeExports2 && typeof module == "object" && module && !module.nodeType && module;
418
+ var moduleExports2 = freeModule2 && freeModule2.exports === freeExports2;
419
+ var freeProcess = moduleExports2 && freeGlobal_default.process;
420
+ var nodeUtil = function() {
421
+ try {
422
+ var types = freeModule2 && freeModule2.require && freeModule2.require("util").types;
423
+ if (types) {
424
+ return types;
425
+ }
426
+ return freeProcess && freeProcess.binding && freeProcess.binding("util");
427
+ } catch (e) {
428
+ }
429
+ }();
430
+ var nodeUtil_default = nodeUtil;
431
+
432
+ // node_modules/lodash-es/isTypedArray.js
433
+ var nodeIsTypedArray = nodeUtil_default && nodeUtil_default.isTypedArray;
434
+ var isTypedArray = nodeIsTypedArray ? baseUnary_default(nodeIsTypedArray) : baseIsTypedArray_default;
435
+ var isTypedArray_default = isTypedArray;
436
+
437
+ // node_modules/lodash-es/_arrayLikeKeys.js
438
+ var objectProto7 = Object.prototype;
439
+ var hasOwnProperty5 = objectProto7.hasOwnProperty;
440
+ function arrayLikeKeys(value, inherited) {
441
+ var isArr = isArray_default(value), isArg = !isArr && isArguments_default(value), isBuff = !isArr && !isArg && isBuffer_default(value), isType = !isArr && !isArg && !isBuff && isTypedArray_default(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes_default(value.length, String) : [], length = result.length;
442
+ for (var key in value) {
443
+ if ((inherited || hasOwnProperty5.call(value, key)) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode.
444
+ (key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
445
+ isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
446
+ isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties.
447
+ isIndex_default(key, length)))) {
448
+ result.push(key);
449
+ }
450
+ }
451
+ return result;
452
+ }
453
+ var arrayLikeKeys_default = arrayLikeKeys;
454
+
455
+ // node_modules/lodash-es/_overArg.js
456
+ function overArg(func, transform) {
457
+ return function(arg) {
458
+ return func(transform(arg));
459
+ };
460
+ }
461
+ var overArg_default = overArg;
462
+
463
+ // node_modules/lodash-es/_nativeKeys.js
464
+ var nativeKeys = overArg_default(Object.keys, Object);
465
+ var nativeKeys_default = nativeKeys;
466
+
467
+ // node_modules/lodash-es/_baseKeys.js
468
+ var objectProto8 = Object.prototype;
469
+ var hasOwnProperty6 = objectProto8.hasOwnProperty;
470
+ function baseKeys(object) {
471
+ if (!isPrototype_default(object)) {
472
+ return nativeKeys_default(object);
473
+ }
474
+ var result = [];
475
+ for (var key in Object(object)) {
476
+ if (hasOwnProperty6.call(object, key) && key != "constructor") {
477
+ result.push(key);
478
+ }
479
+ }
480
+ return result;
481
+ }
482
+ var baseKeys_default = baseKeys;
483
+
484
+ // node_modules/lodash-es/keys.js
485
+ function keys(object) {
486
+ return isArrayLike_default(object) ? arrayLikeKeys_default(object) : baseKeys_default(object);
487
+ }
488
+ var keys_default = keys;
489
+
490
+ // node_modules/lodash-es/_nativeKeysIn.js
491
+ function nativeKeysIn(object) {
492
+ var result = [];
493
+ if (object != null) {
494
+ for (var key in Object(object)) {
495
+ result.push(key);
496
+ }
497
+ }
498
+ return result;
499
+ }
500
+ var nativeKeysIn_default = nativeKeysIn;
501
+
502
+ // node_modules/lodash-es/_baseKeysIn.js
503
+ var objectProto9 = Object.prototype;
504
+ var hasOwnProperty7 = objectProto9.hasOwnProperty;
505
+ function baseKeysIn(object) {
506
+ if (!isObject_default(object)) {
507
+ return nativeKeysIn_default(object);
508
+ }
509
+ var isProto = isPrototype_default(object), result = [];
510
+ for (var key in object) {
511
+ if (!(key == "constructor" && (isProto || !hasOwnProperty7.call(object, key)))) {
512
+ result.push(key);
513
+ }
514
+ }
515
+ return result;
516
+ }
517
+ var baseKeysIn_default = baseKeysIn;
518
+
519
+ // node_modules/lodash-es/keysIn.js
520
+ function keysIn(object) {
521
+ return isArrayLike_default(object) ? arrayLikeKeys_default(object, true) : baseKeysIn_default(object);
522
+ }
523
+ var keysIn_default = keysIn;
524
+
267
525
  // node_modules/lodash-es/_isKey.js
268
526
  var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/;
269
527
  var reIsPlainProp = /^\w*$/;
@@ -300,24 +558,24 @@ var hashDelete_default = hashDelete;
300
558
 
301
559
  // node_modules/lodash-es/_hashGet.js
302
560
  var HASH_UNDEFINED = "__lodash_hash_undefined__";
303
- var objectProto6 = Object.prototype;
304
- var hasOwnProperty5 = objectProto6.hasOwnProperty;
561
+ var objectProto10 = Object.prototype;
562
+ var hasOwnProperty8 = objectProto10.hasOwnProperty;
305
563
  function hashGet(key) {
306
564
  var data = this.__data__;
307
565
  if (nativeCreate_default) {
308
566
  var result = data[key];
309
567
  return result === HASH_UNDEFINED ? void 0 : result;
310
568
  }
311
- return hasOwnProperty5.call(data, key) ? data[key] : void 0;
569
+ return hasOwnProperty8.call(data, key) ? data[key] : void 0;
312
570
  }
313
571
  var hashGet_default = hashGet;
314
572
 
315
573
  // node_modules/lodash-es/_hashHas.js
316
- var objectProto7 = Object.prototype;
317
- var hasOwnProperty6 = objectProto7.hasOwnProperty;
574
+ var objectProto11 = Object.prototype;
575
+ var hasOwnProperty9 = objectProto11.hasOwnProperty;
318
576
  function hashHas(key) {
319
577
  var data = this.__data__;
320
- return nativeCreate_default ? data[key] !== void 0 : hasOwnProperty6.call(data, key);
578
+ return nativeCreate_default ? data[key] !== void 0 : hasOwnProperty9.call(data, key);
321
579
  }
322
580
  var hashHas_default = hashHas;
323
581
 
@@ -595,6 +853,20 @@ function get(object, path, defaultValue) {
595
853
  }
596
854
  var get_default = get;
597
855
 
856
+ // node_modules/lodash-es/_arrayPush.js
857
+ function arrayPush(array, values) {
858
+ var index = -1, length = values.length, offset = array.length;
859
+ while (++index < length) {
860
+ array[offset + index] = values[index];
861
+ }
862
+ return array;
863
+ }
864
+ var arrayPush_default = arrayPush;
865
+
866
+ // node_modules/lodash-es/_getPrototype.js
867
+ var getPrototype = overArg_default(Object.getPrototypeOf, Object);
868
+ var getPrototype_default = getPrototype;
869
+
598
870
  // node_modules/lodash-es/_baseSlice.js
599
871
  function baseSlice(array, start, end) {
600
872
  var index = -1, length = array.length;
@@ -615,6 +887,460 @@ function baseSlice(array, start, end) {
615
887
  }
616
888
  var baseSlice_default = baseSlice;
617
889
 
890
+ // node_modules/lodash-es/_stackClear.js
891
+ function stackClear() {
892
+ this.__data__ = new ListCache_default();
893
+ this.size = 0;
894
+ }
895
+ var stackClear_default = stackClear;
896
+
897
+ // node_modules/lodash-es/_stackDelete.js
898
+ function stackDelete(key) {
899
+ var data = this.__data__, result = data["delete"](key);
900
+ this.size = data.size;
901
+ return result;
902
+ }
903
+ var stackDelete_default = stackDelete;
904
+
905
+ // node_modules/lodash-es/_stackGet.js
906
+ function stackGet(key) {
907
+ return this.__data__.get(key);
908
+ }
909
+ var stackGet_default = stackGet;
910
+
911
+ // node_modules/lodash-es/_stackHas.js
912
+ function stackHas(key) {
913
+ return this.__data__.has(key);
914
+ }
915
+ var stackHas_default = stackHas;
916
+
917
+ // node_modules/lodash-es/_stackSet.js
918
+ var LARGE_ARRAY_SIZE = 200;
919
+ function stackSet(key, value) {
920
+ var data = this.__data__;
921
+ if (data instanceof ListCache_default) {
922
+ var pairs = data.__data__;
923
+ if (!Map_default || pairs.length < LARGE_ARRAY_SIZE - 1) {
924
+ pairs.push([key, value]);
925
+ this.size = ++data.size;
926
+ return this;
927
+ }
928
+ data = this.__data__ = new MapCache_default(pairs);
929
+ }
930
+ data.set(key, value);
931
+ this.size = data.size;
932
+ return this;
933
+ }
934
+ var stackSet_default = stackSet;
935
+
936
+ // node_modules/lodash-es/_Stack.js
937
+ function Stack(entries) {
938
+ var data = this.__data__ = new ListCache_default(entries);
939
+ this.size = data.size;
940
+ }
941
+ Stack.prototype.clear = stackClear_default;
942
+ Stack.prototype["delete"] = stackDelete_default;
943
+ Stack.prototype.get = stackGet_default;
944
+ Stack.prototype.has = stackHas_default;
945
+ Stack.prototype.set = stackSet_default;
946
+ var Stack_default = Stack;
947
+
948
+ // node_modules/lodash-es/_baseAssign.js
949
+ function baseAssign(object, source) {
950
+ return object && copyObject_default(source, keys_default(source), object);
951
+ }
952
+ var baseAssign_default = baseAssign;
953
+
954
+ // node_modules/lodash-es/_baseAssignIn.js
955
+ function baseAssignIn(object, source) {
956
+ return object && copyObject_default(source, keysIn_default(source), object);
957
+ }
958
+ var baseAssignIn_default = baseAssignIn;
959
+
960
+ // node_modules/lodash-es/_cloneBuffer.js
961
+ var freeExports3 = typeof exports == "object" && exports && !exports.nodeType && exports;
962
+ var freeModule3 = freeExports3 && typeof module == "object" && module && !module.nodeType && module;
963
+ var moduleExports3 = freeModule3 && freeModule3.exports === freeExports3;
964
+ var Buffer2 = moduleExports3 ? root_default.Buffer : void 0;
965
+ var allocUnsafe = Buffer2 ? Buffer2.allocUnsafe : void 0;
966
+ function cloneBuffer(buffer, isDeep) {
967
+ if (isDeep) {
968
+ return buffer.slice();
969
+ }
970
+ var length = buffer.length, result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
971
+ buffer.copy(result);
972
+ return result;
973
+ }
974
+ var cloneBuffer_default = cloneBuffer;
975
+
976
+ // node_modules/lodash-es/_arrayFilter.js
977
+ function arrayFilter(array, predicate) {
978
+ var index = -1, length = array == null ? 0 : array.length, resIndex = 0, result = [];
979
+ while (++index < length) {
980
+ var value = array[index];
981
+ if (predicate(value, index, array)) {
982
+ result[resIndex++] = value;
983
+ }
984
+ }
985
+ return result;
986
+ }
987
+ var arrayFilter_default = arrayFilter;
988
+
989
+ // node_modules/lodash-es/stubArray.js
990
+ function stubArray() {
991
+ return [];
992
+ }
993
+ var stubArray_default = stubArray;
994
+
995
+ // node_modules/lodash-es/_getSymbols.js
996
+ var objectProto12 = Object.prototype;
997
+ var propertyIsEnumerable2 = objectProto12.propertyIsEnumerable;
998
+ var nativeGetSymbols = Object.getOwnPropertySymbols;
999
+ var getSymbols = !nativeGetSymbols ? stubArray_default : function(object) {
1000
+ if (object == null) {
1001
+ return [];
1002
+ }
1003
+ object = Object(object);
1004
+ return arrayFilter_default(nativeGetSymbols(object), function(symbol) {
1005
+ return propertyIsEnumerable2.call(object, symbol);
1006
+ });
1007
+ };
1008
+ var getSymbols_default = getSymbols;
1009
+
1010
+ // node_modules/lodash-es/_copySymbols.js
1011
+ function copySymbols(source, object) {
1012
+ return copyObject_default(source, getSymbols_default(source), object);
1013
+ }
1014
+ var copySymbols_default = copySymbols;
1015
+
1016
+ // node_modules/lodash-es/_getSymbolsIn.js
1017
+ var nativeGetSymbols2 = Object.getOwnPropertySymbols;
1018
+ var getSymbolsIn = !nativeGetSymbols2 ? stubArray_default : function(object) {
1019
+ var result = [];
1020
+ while (object) {
1021
+ arrayPush_default(result, getSymbols_default(object));
1022
+ object = getPrototype_default(object);
1023
+ }
1024
+ return result;
1025
+ };
1026
+ var getSymbolsIn_default = getSymbolsIn;
1027
+
1028
+ // node_modules/lodash-es/_copySymbolsIn.js
1029
+ function copySymbolsIn(source, object) {
1030
+ return copyObject_default(source, getSymbolsIn_default(source), object);
1031
+ }
1032
+ var copySymbolsIn_default = copySymbolsIn;
1033
+
1034
+ // node_modules/lodash-es/_baseGetAllKeys.js
1035
+ function baseGetAllKeys(object, keysFunc, symbolsFunc) {
1036
+ var result = keysFunc(object);
1037
+ return isArray_default(object) ? result : arrayPush_default(result, symbolsFunc(object));
1038
+ }
1039
+ var baseGetAllKeys_default = baseGetAllKeys;
1040
+
1041
+ // node_modules/lodash-es/_getAllKeys.js
1042
+ function getAllKeys(object) {
1043
+ return baseGetAllKeys_default(object, keys_default, getSymbols_default);
1044
+ }
1045
+ var getAllKeys_default = getAllKeys;
1046
+
1047
+ // node_modules/lodash-es/_getAllKeysIn.js
1048
+ function getAllKeysIn(object) {
1049
+ return baseGetAllKeys_default(object, keysIn_default, getSymbolsIn_default);
1050
+ }
1051
+ var getAllKeysIn_default = getAllKeysIn;
1052
+
1053
+ // node_modules/lodash-es/_DataView.js
1054
+ var DataView = getNative_default(root_default, "DataView");
1055
+ var DataView_default = DataView;
1056
+
1057
+ // node_modules/lodash-es/_Promise.js
1058
+ var Promise2 = getNative_default(root_default, "Promise");
1059
+ var Promise_default = Promise2;
1060
+
1061
+ // node_modules/lodash-es/_Set.js
1062
+ var Set2 = getNative_default(root_default, "Set");
1063
+ var Set_default = Set2;
1064
+
1065
+ // node_modules/lodash-es/_getTag.js
1066
+ var mapTag2 = "[object Map]";
1067
+ var objectTag2 = "[object Object]";
1068
+ var promiseTag = "[object Promise]";
1069
+ var setTag2 = "[object Set]";
1070
+ var weakMapTag2 = "[object WeakMap]";
1071
+ var dataViewTag2 = "[object DataView]";
1072
+ var dataViewCtorString = toSource_default(DataView_default);
1073
+ var mapCtorString = toSource_default(Map_default);
1074
+ var promiseCtorString = toSource_default(Promise_default);
1075
+ var setCtorString = toSource_default(Set_default);
1076
+ var weakMapCtorString = toSource_default(WeakMap_default);
1077
+ var getTag = baseGetTag_default;
1078
+ if (DataView_default && getTag(new DataView_default(new ArrayBuffer(1))) != dataViewTag2 || Map_default && getTag(new Map_default()) != mapTag2 || Promise_default && getTag(Promise_default.resolve()) != promiseTag || Set_default && getTag(new Set_default()) != setTag2 || WeakMap_default && getTag(new WeakMap_default()) != weakMapTag2) {
1079
+ getTag = function(value) {
1080
+ var result = baseGetTag_default(value), Ctor = result == objectTag2 ? value.constructor : void 0, ctorString = Ctor ? toSource_default(Ctor) : "";
1081
+ if (ctorString) {
1082
+ switch (ctorString) {
1083
+ case dataViewCtorString:
1084
+ return dataViewTag2;
1085
+ case mapCtorString:
1086
+ return mapTag2;
1087
+ case promiseCtorString:
1088
+ return promiseTag;
1089
+ case setCtorString:
1090
+ return setTag2;
1091
+ case weakMapCtorString:
1092
+ return weakMapTag2;
1093
+ }
1094
+ }
1095
+ return result;
1096
+ };
1097
+ }
1098
+ var getTag_default = getTag;
1099
+
1100
+ // node_modules/lodash-es/_initCloneArray.js
1101
+ var objectProto13 = Object.prototype;
1102
+ var hasOwnProperty10 = objectProto13.hasOwnProperty;
1103
+ function initCloneArray(array) {
1104
+ var length = array.length, result = new array.constructor(length);
1105
+ if (length && typeof array[0] == "string" && hasOwnProperty10.call(array, "index")) {
1106
+ result.index = array.index;
1107
+ result.input = array.input;
1108
+ }
1109
+ return result;
1110
+ }
1111
+ var initCloneArray_default = initCloneArray;
1112
+
1113
+ // node_modules/lodash-es/_Uint8Array.js
1114
+ var Uint8Array = root_default.Uint8Array;
1115
+ var Uint8Array_default = Uint8Array;
1116
+
1117
+ // node_modules/lodash-es/_cloneArrayBuffer.js
1118
+ function cloneArrayBuffer(arrayBuffer) {
1119
+ var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
1120
+ new Uint8Array_default(result).set(new Uint8Array_default(arrayBuffer));
1121
+ return result;
1122
+ }
1123
+ var cloneArrayBuffer_default = cloneArrayBuffer;
1124
+
1125
+ // node_modules/lodash-es/_cloneDataView.js
1126
+ function cloneDataView(dataView, isDeep) {
1127
+ var buffer = isDeep ? cloneArrayBuffer_default(dataView.buffer) : dataView.buffer;
1128
+ return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
1129
+ }
1130
+ var cloneDataView_default = cloneDataView;
1131
+
1132
+ // node_modules/lodash-es/_cloneRegExp.js
1133
+ var reFlags = /\w*$/;
1134
+ function cloneRegExp(regexp) {
1135
+ var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
1136
+ result.lastIndex = regexp.lastIndex;
1137
+ return result;
1138
+ }
1139
+ var cloneRegExp_default = cloneRegExp;
1140
+
1141
+ // node_modules/lodash-es/_cloneSymbol.js
1142
+ var symbolProto2 = Symbol_default ? Symbol_default.prototype : void 0;
1143
+ var symbolValueOf = symbolProto2 ? symbolProto2.valueOf : void 0;
1144
+ function cloneSymbol(symbol) {
1145
+ return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
1146
+ }
1147
+ var cloneSymbol_default = cloneSymbol;
1148
+
1149
+ // node_modules/lodash-es/_cloneTypedArray.js
1150
+ function cloneTypedArray(typedArray, isDeep) {
1151
+ var buffer = isDeep ? cloneArrayBuffer_default(typedArray.buffer) : typedArray.buffer;
1152
+ return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
1153
+ }
1154
+ var cloneTypedArray_default = cloneTypedArray;
1155
+
1156
+ // node_modules/lodash-es/_initCloneByTag.js
1157
+ var boolTag2 = "[object Boolean]";
1158
+ var dateTag2 = "[object Date]";
1159
+ var mapTag3 = "[object Map]";
1160
+ var numberTag2 = "[object Number]";
1161
+ var regexpTag2 = "[object RegExp]";
1162
+ var setTag3 = "[object Set]";
1163
+ var stringTag2 = "[object String]";
1164
+ var symbolTag2 = "[object Symbol]";
1165
+ var arrayBufferTag2 = "[object ArrayBuffer]";
1166
+ var dataViewTag3 = "[object DataView]";
1167
+ var float32Tag2 = "[object Float32Array]";
1168
+ var float64Tag2 = "[object Float64Array]";
1169
+ var int8Tag2 = "[object Int8Array]";
1170
+ var int16Tag2 = "[object Int16Array]";
1171
+ var int32Tag2 = "[object Int32Array]";
1172
+ var uint8Tag2 = "[object Uint8Array]";
1173
+ var uint8ClampedTag2 = "[object Uint8ClampedArray]";
1174
+ var uint16Tag2 = "[object Uint16Array]";
1175
+ var uint32Tag2 = "[object Uint32Array]";
1176
+ function initCloneByTag(object, tag, isDeep) {
1177
+ var Ctor = object.constructor;
1178
+ switch (tag) {
1179
+ case arrayBufferTag2:
1180
+ return cloneArrayBuffer_default(object);
1181
+ case boolTag2:
1182
+ case dateTag2:
1183
+ return new Ctor(+object);
1184
+ case dataViewTag3:
1185
+ return cloneDataView_default(object, isDeep);
1186
+ case float32Tag2:
1187
+ case float64Tag2:
1188
+ case int8Tag2:
1189
+ case int16Tag2:
1190
+ case int32Tag2:
1191
+ case uint8Tag2:
1192
+ case uint8ClampedTag2:
1193
+ case uint16Tag2:
1194
+ case uint32Tag2:
1195
+ return cloneTypedArray_default(object, isDeep);
1196
+ case mapTag3:
1197
+ return new Ctor();
1198
+ case numberTag2:
1199
+ case stringTag2:
1200
+ return new Ctor(object);
1201
+ case regexpTag2:
1202
+ return cloneRegExp_default(object);
1203
+ case setTag3:
1204
+ return new Ctor();
1205
+ case symbolTag2:
1206
+ return cloneSymbol_default(object);
1207
+ }
1208
+ }
1209
+ var initCloneByTag_default = initCloneByTag;
1210
+
1211
+ // node_modules/lodash-es/_initCloneObject.js
1212
+ function initCloneObject(object) {
1213
+ return typeof object.constructor == "function" && !isPrototype_default(object) ? baseCreate_default(getPrototype_default(object)) : {};
1214
+ }
1215
+ var initCloneObject_default = initCloneObject;
1216
+
1217
+ // node_modules/lodash-es/_baseIsMap.js
1218
+ var mapTag4 = "[object Map]";
1219
+ function baseIsMap(value) {
1220
+ return isObjectLike_default(value) && getTag_default(value) == mapTag4;
1221
+ }
1222
+ var baseIsMap_default = baseIsMap;
1223
+
1224
+ // node_modules/lodash-es/isMap.js
1225
+ var nodeIsMap = nodeUtil_default && nodeUtil_default.isMap;
1226
+ var isMap = nodeIsMap ? baseUnary_default(nodeIsMap) : baseIsMap_default;
1227
+ var isMap_default = isMap;
1228
+
1229
+ // node_modules/lodash-es/_baseIsSet.js
1230
+ var setTag4 = "[object Set]";
1231
+ function baseIsSet(value) {
1232
+ return isObjectLike_default(value) && getTag_default(value) == setTag4;
1233
+ }
1234
+ var baseIsSet_default = baseIsSet;
1235
+
1236
+ // node_modules/lodash-es/isSet.js
1237
+ var nodeIsSet = nodeUtil_default && nodeUtil_default.isSet;
1238
+ var isSet = nodeIsSet ? baseUnary_default(nodeIsSet) : baseIsSet_default;
1239
+ var isSet_default = isSet;
1240
+
1241
+ // node_modules/lodash-es/_baseClone.js
1242
+ var CLONE_DEEP_FLAG = 1;
1243
+ var CLONE_FLAT_FLAG = 2;
1244
+ var CLONE_SYMBOLS_FLAG = 4;
1245
+ var argsTag3 = "[object Arguments]";
1246
+ var arrayTag2 = "[object Array]";
1247
+ var boolTag3 = "[object Boolean]";
1248
+ var dateTag3 = "[object Date]";
1249
+ var errorTag2 = "[object Error]";
1250
+ var funcTag3 = "[object Function]";
1251
+ var genTag2 = "[object GeneratorFunction]";
1252
+ var mapTag5 = "[object Map]";
1253
+ var numberTag3 = "[object Number]";
1254
+ var objectTag3 = "[object Object]";
1255
+ var regexpTag3 = "[object RegExp]";
1256
+ var setTag5 = "[object Set]";
1257
+ var stringTag3 = "[object String]";
1258
+ var symbolTag3 = "[object Symbol]";
1259
+ var weakMapTag3 = "[object WeakMap]";
1260
+ var arrayBufferTag3 = "[object ArrayBuffer]";
1261
+ var dataViewTag4 = "[object DataView]";
1262
+ var float32Tag3 = "[object Float32Array]";
1263
+ var float64Tag3 = "[object Float64Array]";
1264
+ var int8Tag3 = "[object Int8Array]";
1265
+ var int16Tag3 = "[object Int16Array]";
1266
+ var int32Tag3 = "[object Int32Array]";
1267
+ var uint8Tag3 = "[object Uint8Array]";
1268
+ var uint8ClampedTag3 = "[object Uint8ClampedArray]";
1269
+ var uint16Tag3 = "[object Uint16Array]";
1270
+ var uint32Tag3 = "[object Uint32Array]";
1271
+ var cloneableTags = {};
1272
+ cloneableTags[argsTag3] = cloneableTags[arrayTag2] = cloneableTags[arrayBufferTag3] = cloneableTags[dataViewTag4] = cloneableTags[boolTag3] = cloneableTags[dateTag3] = cloneableTags[float32Tag3] = cloneableTags[float64Tag3] = cloneableTags[int8Tag3] = cloneableTags[int16Tag3] = cloneableTags[int32Tag3] = cloneableTags[mapTag5] = cloneableTags[numberTag3] = cloneableTags[objectTag3] = cloneableTags[regexpTag3] = cloneableTags[setTag5] = cloneableTags[stringTag3] = cloneableTags[symbolTag3] = cloneableTags[uint8Tag3] = cloneableTags[uint8ClampedTag3] = cloneableTags[uint16Tag3] = cloneableTags[uint32Tag3] = true;
1273
+ cloneableTags[errorTag2] = cloneableTags[funcTag3] = cloneableTags[weakMapTag3] = false;
1274
+ function baseClone(value, bitmask, customizer, key, object, stack) {
1275
+ var result, isDeep = bitmask & CLONE_DEEP_FLAG, isFlat = bitmask & CLONE_FLAT_FLAG, isFull = bitmask & CLONE_SYMBOLS_FLAG;
1276
+ if (customizer) {
1277
+ result = object ? customizer(value, key, object, stack) : customizer(value);
1278
+ }
1279
+ if (result !== void 0) {
1280
+ return result;
1281
+ }
1282
+ if (!isObject_default(value)) {
1283
+ return value;
1284
+ }
1285
+ var isArr = isArray_default(value);
1286
+ if (isArr) {
1287
+ result = initCloneArray_default(value);
1288
+ if (!isDeep) {
1289
+ return copyArray_default(value, result);
1290
+ }
1291
+ } else {
1292
+ var tag = getTag_default(value), isFunc = tag == funcTag3 || tag == genTag2;
1293
+ if (isBuffer_default(value)) {
1294
+ return cloneBuffer_default(value, isDeep);
1295
+ }
1296
+ if (tag == objectTag3 || tag == argsTag3 || isFunc && !object) {
1297
+ result = isFlat || isFunc ? {} : initCloneObject_default(value);
1298
+ if (!isDeep) {
1299
+ return isFlat ? copySymbolsIn_default(value, baseAssignIn_default(result, value)) : copySymbols_default(value, baseAssign_default(result, value));
1300
+ }
1301
+ } else {
1302
+ if (!cloneableTags[tag]) {
1303
+ return object ? value : {};
1304
+ }
1305
+ result = initCloneByTag_default(value, tag, isDeep);
1306
+ }
1307
+ }
1308
+ stack || (stack = new Stack_default());
1309
+ var stacked = stack.get(value);
1310
+ if (stacked) {
1311
+ return stacked;
1312
+ }
1313
+ stack.set(value, result);
1314
+ if (isSet_default(value)) {
1315
+ value.forEach(function(subValue) {
1316
+ result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
1317
+ });
1318
+ } else if (isMap_default(value)) {
1319
+ value.forEach(function(subValue, key2) {
1320
+ result.set(key2, baseClone(subValue, bitmask, customizer, key2, value, stack));
1321
+ });
1322
+ }
1323
+ var keysFunc = isFull ? isFlat ? getAllKeysIn_default : getAllKeys_default : isFlat ? keysIn_default : keys_default;
1324
+ var props = isArr ? void 0 : keysFunc(value);
1325
+ arrayEach_default(props || value, function(subValue, key2) {
1326
+ if (props) {
1327
+ key2 = subValue;
1328
+ subValue = value[key2];
1329
+ }
1330
+ assignValue_default(result, key2, baseClone(subValue, bitmask, customizer, key2, value, stack));
1331
+ });
1332
+ return result;
1333
+ }
1334
+ var baseClone_default = baseClone;
1335
+
1336
+ // node_modules/lodash-es/cloneDeep.js
1337
+ var CLONE_DEEP_FLAG2 = 1;
1338
+ var CLONE_SYMBOLS_FLAG2 = 4;
1339
+ function cloneDeep(value) {
1340
+ return baseClone_default(value, CLONE_DEEP_FLAG2 | CLONE_SYMBOLS_FLAG2);
1341
+ }
1342
+ var cloneDeep_default = cloneDeep;
1343
+
618
1344
  // node_modules/lodash-es/_hasPath.js
619
1345
  function hasPath(object, path, hasFunc) {
620
1346
  path = castPath_default(path, object);
@@ -642,10 +1368,10 @@ function last(array) {
642
1368
  var last_default = last;
643
1369
 
644
1370
  // node_modules/lodash-es/_baseHas.js
645
- var objectProto8 = Object.prototype;
646
- var hasOwnProperty7 = objectProto8.hasOwnProperty;
1371
+ var objectProto14 = Object.prototype;
1372
+ var hasOwnProperty11 = objectProto14.hasOwnProperty;
647
1373
  function baseHas(object, key) {
648
- return object != null && hasOwnProperty7.call(object, key);
1374
+ return object != null && hasOwnProperty11.call(object, key);
649
1375
  }
650
1376
  var baseHas_default = baseHas;
651
1377
 
@@ -708,7 +1434,10 @@ function unset(object, path) {
708
1434
  var unset_default = unset;
709
1435
 
710
1436
  // src/tracked-instance.ts
711
- import { computed, customRef } from "vue";
1437
+ import { computed } from "vue";
1438
+
1439
+ // src/utils.ts
1440
+ import { customRef } from "vue";
712
1441
  var isObject2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && !(value instanceof Date) && !(value instanceof File) && !(value instanceof Map) && !(value instanceof Set);
713
1442
  var isEmpty = (value) => Object.keys(value).length === 0;
714
1443
  var iterateObject = function* (source, params = {}) {
@@ -765,6 +1494,8 @@ var createNestedRef = (source, handler) => customRef((track, trigger) => {
765
1494
  }
766
1495
  };
767
1496
  });
1497
+
1498
+ // src/tracked-instance.ts
768
1499
  var ArrayInOriginalData = class {
769
1500
  length;
770
1501
  constructor(length) {
@@ -810,8 +1541,8 @@ var snapshotValueToOriginalData = (originalData, path, value) => {
810
1541
  keysSet.add(key);
811
1542
  }
812
1543
  }
813
- const keys = Array.from(keysSet).filter((key) => !Object.keys(value).includes(key));
814
- for (const key of keys) {
1544
+ const keys2 = Array.from(keysSet).filter((key) => !Object.keys(value).includes(key));
1545
+ for (const key of keys2) {
815
1546
  snapshotValueToOriginalData(
816
1547
  originalData,
817
1548
  path.concat({ target: oldValue2 || value, property: key }),
@@ -845,7 +1576,7 @@ var snapshotValueToOriginalData = (originalData, path, value) => {
845
1576
  }
846
1577
  }
847
1578
  };
848
- var useTrackedInstance = (initialData) => {
1579
+ function useTrackedInstance(initialData) {
849
1580
  const _originalData = createNestedRef({}, (path) => ({
850
1581
  deleteProperty(target, property) {
851
1582
  const result = Reflect.deleteProperty(target, property);
@@ -885,7 +1616,7 @@ var useTrackedInstance = (initialData) => {
885
1616
  } else {
886
1617
  snapshotValueToOriginalData(_originalData.value, path, value);
887
1618
  }
888
- return Reflect.set(target, property, value, receiver);
1619
+ return Reflect.set(target, property, cloneDeep_default(value), receiver);
889
1620
  },
890
1621
  deleteProperty(target, property) {
891
1622
  setOriginalDataValue(_originalData.value, parentThree.concat({ target, property }));
@@ -941,23 +1672,26 @@ var useTrackedInstance = (initialData) => {
941
1672
  loadData,
942
1673
  reset
943
1674
  };
944
- };
1675
+ }
945
1676
 
946
1677
  // src/collection.ts
947
- import { computed as computed2, shallowRef, triggerRef, ref } from "vue";
948
- var useCollection = (createItemMeta = () => ({})) => {
1678
+ import { computed as computed2, ref, shallowRef, triggerRef } from "vue";
1679
+ var useCollection = (createItemMeta = () => void 0) => {
949
1680
  const items = shallowRef([]);
950
1681
  const isDirty = computed2(
951
1682
  () => items.value.some(({ instance, isRemoved, isNew }) => instance.isDirty.value || isNew.value || isRemoved.value)
952
1683
  );
953
- const add = (item, index = items.value.length) => {
1684
+ const createItem = (item, isNew) => {
954
1685
  const instance = useTrackedInstance(item);
955
- const newItem = {
1686
+ return {
956
1687
  isRemoved: ref(false),
957
- isNew: ref(true),
1688
+ isNew: ref(isNew),
958
1689
  instance,
959
1690
  meta: createItemMeta(instance)
960
1691
  };
1692
+ };
1693
+ const add = (item, index = items.value.length) => {
1694
+ const newItem = createItem(item, true);
961
1695
  items.value.splice(index, 0, newItem);
962
1696
  triggerRef(items);
963
1697
  return newItem;
@@ -972,15 +1706,7 @@ var useCollection = (createItemMeta = () => ({})) => {
972
1706
  }
973
1707
  };
974
1708
  const loadData = (loadedItems) => {
975
- items.value = loadedItems.map((item) => {
976
- const instance = useTrackedInstance(item);
977
- return {
978
- isNew: ref(false),
979
- isRemoved: ref(false),
980
- instance,
981
- meta: createItemMeta(instance)
982
- };
983
- });
1709
+ items.value = loadedItems.map((item) => createItem(item, false));
984
1710
  triggerRef(items);
985
1711
  };
986
1712
  const reset = () => {
@@ -1,17 +1,17 @@
1
- import { ShallowRef, ComputedRef, Ref } from 'vue';
1
+ import { ComputedRef, Ref, ShallowRef } from 'vue';
2
2
  import { TrackedInstance } from './tracked-instance';
3
- export interface CollectionItem<Item extends Record<string, any>, Meta = Record<string, any>> {
3
+ export interface CollectionItem<Item, Meta> {
4
4
  instance: TrackedInstance<Item>;
5
5
  meta: Meta;
6
6
  isRemoved: Ref<boolean>;
7
7
  isNew: Ref<boolean>;
8
8
  }
9
- export interface Collection<Item extends Record<string, any>, Meta = Record<string, any>> {
9
+ export interface Collection<Item, Meta> {
10
10
  items: ShallowRef<CollectionItem<Item, Meta>[]>;
11
11
  isDirty: ComputedRef<boolean>;
12
- add: (item: Partial<Item>, afterIndex?: number) => CollectionItem<Item, Meta>;
12
+ add: (item: Item, afterIndex?: number) => CollectionItem<Item, Meta>;
13
13
  remove: (index: number, isHardRemove?: boolean) => void;
14
14
  loadData: (items: Item[]) => void;
15
15
  reset: () => void;
16
16
  }
17
- export declare const useCollection: <Item extends Record<string, any>, Meta = Record<string, any>>(createItemMeta?: (instance: TrackedInstance<Item>) => Meta) => Collection<Item, Meta>;
17
+ export declare const useCollection: <Item = any, Meta = any>(createItemMeta?: (instance: TrackedInstance<Item>) => Meta) => Collection<Item, Meta>;
@@ -1,13 +1,11 @@
1
1
  import { Ref } from 'vue';
2
- type DeepPartial<T> = T extends object ? {
3
- [P in keyof T]?: DeepPartial<T[P]>;
4
- } : T;
5
- export interface TrackedInstance<Data extends Record<string, any>> {
2
+ import { DeepPartial } from './utils';
3
+ export interface TrackedInstance<Data> {
6
4
  data: Ref<Data>;
7
5
  isDirty: Ref<boolean>;
8
6
  changedData: Ref<DeepPartial<Data>>;
9
- loadData: (newData: DeepPartial<Data>) => void;
7
+ loadData: (newData: Data) => void;
10
8
  reset: () => void;
11
9
  }
12
- export declare const useTrackedInstance: <Data extends Record<string, any>>(initialData: Partial<Data>) => TrackedInstance<Data>;
13
- export {};
10
+ export declare function useTrackedInstance<Data = any>(): TrackedInstance<Data | undefined>;
11
+ export declare function useTrackedInstance<Data>(value: Data): TrackedInstance<Data>;
@@ -0,0 +1,15 @@
1
+ export type DeepPartial<T> = T extends object ? {
2
+ [P in keyof T]?: DeepPartial<T[P]>;
3
+ } : T;
4
+ export interface NestedProxyPathItem {
5
+ target: Record<string, any>;
6
+ property: string;
7
+ receiver?: Record<string, any>;
8
+ }
9
+ export declare const isObject: (value: unknown) => boolean;
10
+ export declare const isEmpty: (value: object) => boolean;
11
+ export declare const iterateObject: (source: Record<string, any>, params?: {
12
+ goDeepCondition?: ((path: string[], value: any) => boolean) | undefined;
13
+ includeParent?: boolean | undefined;
14
+ }) => Generator<[string[], any], void, unknown>;
15
+ export declare const createNestedRef: <Source extends Record<string, any>>(source: Source, handler: <InnerSource extends Record<string, any>>(path: NestedProxyPathItem[]) => ProxyHandler<InnerSource>) => import("vue").Ref<Source>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tracked-instance",
3
- "version": "1.0.12",
3
+ "version": "1.0.14",
4
4
  "description": "Build large forms and track all changes",
5
5
  "type": "module",
6
6
  "scripts": {