attaform 0.20.0 → 0.20.1

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 (30) hide show
  1. package/README.md +3 -0
  2. package/dist/index.cjs +1 -1
  3. package/dist/index.mjs +2 -2
  4. package/dist/shared/{attaform.jgzuNZVC.cjs → attaform.BCBxTyMC.cjs} +3 -3
  5. package/dist/shared/{attaform.jgzuNZVC.cjs.map → attaform.BCBxTyMC.cjs.map} +1 -1
  6. package/dist/shared/{attaform.CKFbKFb6.mjs → attaform.BqZuwLTK.mjs} +94 -49
  7. package/dist/shared/attaform.BqZuwLTK.mjs.map +1 -0
  8. package/dist/shared/{attaform.CIn4bMsD.cjs → attaform.BrrXNmfK.cjs} +3 -3
  9. package/dist/shared/{attaform.CIn4bMsD.cjs.map → attaform.BrrXNmfK.cjs.map} +1 -1
  10. package/dist/shared/{attaform.DvA-CJJW.mjs → attaform.D6CwqkPx.mjs} +3 -3
  11. package/dist/shared/{attaform.DvA-CJJW.mjs.map → attaform.D6CwqkPx.mjs.map} +1 -1
  12. package/dist/shared/{attaform.Dmb6itxC.cjs → attaform.DHRWn-cu.cjs} +13 -9
  13. package/dist/shared/attaform.DHRWn-cu.cjs.map +1 -0
  14. package/dist/shared/{attaform.DL4CQ-oW.cjs → attaform.DLnE5bZa.cjs} +95 -48
  15. package/dist/shared/attaform.DLnE5bZa.cjs.map +1 -0
  16. package/dist/shared/{attaform.DEBvCjeH.mjs → attaform.iWo9soNX.mjs} +3 -3
  17. package/dist/shared/{attaform.DEBvCjeH.mjs.map → attaform.iWo9soNX.mjs.map} +1 -1
  18. package/dist/shared/{attaform.BWgAFnsj.mjs → attaform.tVkmQh5w.mjs} +13 -9
  19. package/dist/shared/attaform.tVkmQh5w.mjs.map +1 -0
  20. package/dist/zod-v3.cjs +2 -2
  21. package/dist/zod-v3.mjs +2 -2
  22. package/dist/zod-v4.cjs +2 -2
  23. package/dist/zod-v4.mjs +2 -2
  24. package/dist/zod.cjs +4 -4
  25. package/dist/zod.mjs +4 -4
  26. package/package.json +2 -1
  27. package/dist/shared/attaform.BWgAFnsj.mjs.map +0 -1
  28. package/dist/shared/attaform.CKFbKFb6.mjs.map +0 -1
  29. package/dist/shared/attaform.DL4CQ-oW.cjs.map +0 -1
  30. package/dist/shared/attaform.Dmb6itxC.cjs.map +0 -1
@@ -3,6 +3,29 @@
3
3
  const vue = require('vue');
4
4
  const paths = require('./attaform.BPy-4qRx.cjs');
5
5
 
6
+ function safeAssign(target, key, value) {
7
+ if (key === "__proto__") {
8
+ Object.defineProperty(target, key, {
9
+ value,
10
+ writable: true,
11
+ enumerable: true,
12
+ configurable: true
13
+ });
14
+ return;
15
+ }
16
+ target[key] = value;
17
+ }
18
+ function safeOwnRead(target, key) {
19
+ if (key === "__proto__") {
20
+ const desc = Object.getOwnPropertyDescriptor(target, "__proto__");
21
+ return desc?.value;
22
+ }
23
+ return target[key];
24
+ }
25
+ function safeOwnHas(target, key) {
26
+ return Object.prototype.hasOwnProperty.call(target, key);
27
+ }
28
+
6
29
  const NOT_FOUND = Symbol("NOT_FOUND");
7
30
  function descendStep(value, segment) {
8
31
  if (value === null || value === void 0) return NOT_FOUND;
@@ -64,8 +87,8 @@ function setAtPathOffset(root, path, value, offset) {
64
87
  arr[head] = setAtPathOffset(arr[head], path, value, nextOffset);
65
88
  return arr;
66
89
  }
67
- const rec = isPlainRecord(root) ? Object.assign(/* @__PURE__ */ Object.create(null), root) : /* @__PURE__ */ Object.create(null);
68
- rec[head] = setAtPathOffset(rec[head], path, value, nextOffset);
90
+ const rec = isPlainRecord(root) ? { ...root } : {};
91
+ safeAssign(rec, head, setAtPathOffset(safeOwnRead(rec, head), path, value, nextOffset));
69
92
  return rec;
70
93
  }
71
94
  function deleteAtPath(root, path) {
@@ -94,9 +117,9 @@ function deleteAtPathOffset(root, path, offset) {
94
117
  delete rec2[head];
95
118
  return rec2;
96
119
  }
97
- if (!(head in root)) return root;
120
+ if (!safeOwnHas(root, head)) return root;
98
121
  const rec = { ...root };
99
- rec[head] = deleteAtPathOffset(rec[head], path, nextOffset);
122
+ safeAssign(rec, head, deleteAtPathOffset(safeOwnRead(rec, head), path, nextOffset));
100
123
  return rec;
101
124
  }
102
125
  function resolveArrayShape(schema, scratch) {
@@ -165,27 +188,27 @@ function mergeStructuralImpl(schema, scratch, consumer, defaultValue) {
165
188
  return consumer;
166
189
  }
167
190
  let mutated = false;
168
- const out = Object.assign(/* @__PURE__ */ Object.create(null), consumer);
191
+ const out = { ...consumer };
169
192
  for (const key of Object.keys(defaultValue)) {
170
- if (!(key in consumer)) {
171
- const defAtKey = defaultValue[key];
193
+ if (!safeOwnHas(consumer, key)) {
194
+ const defAtKey = safeOwnRead(defaultValue, key);
172
195
  scratch.push(key);
173
196
  const filled = mergeStructuralImpl(schema, scratch, void 0, defAtKey);
174
197
  scratch.pop();
175
198
  if (filled !== void 0) {
176
- out[key] = filled;
199
+ safeAssign(out, key, filled);
177
200
  mutated = true;
178
201
  }
179
202
  }
180
203
  }
181
204
  for (const key of Object.keys(consumer)) {
182
- const cVal = consumer[key];
205
+ const cVal = safeOwnRead(consumer, key);
183
206
  if (cVal === void 0) continue;
184
207
  scratch.push(key);
185
- const merged = mergeStructuralImpl(schema, scratch, cVal, defaultValue[key]);
208
+ const merged = mergeStructuralImpl(schema, scratch, cVal, safeOwnRead(defaultValue, key));
186
209
  scratch.pop();
187
210
  if (merged !== cVal) {
188
- out[key] = merged;
211
+ safeAssign(out, key, merged);
189
212
  mutated = true;
190
213
  }
191
214
  }
@@ -379,7 +402,8 @@ function applyChangedKeys(target, source) {
379
402
  }
380
403
  for (const k of changedFirstSegments) {
381
404
  if (typeof k === "symbol") continue;
382
- t[String(k)] = s[String(k)];
405
+ const key = String(k);
406
+ safeAssign(t, key, safeOwnRead(s, key));
383
407
  }
384
408
  }
385
409
  return true;
@@ -429,9 +453,9 @@ function structuralSnapshot(value) {
429
453
  return out2;
430
454
  }
431
455
  const src = value;
432
- const out = /* @__PURE__ */ Object.create(null);
456
+ const out = {};
433
457
  for (const k of Object.keys(src)) {
434
- out[k] = structuralSnapshot(src[k]);
458
+ safeAssign(out, k, structuralSnapshot(safeOwnRead(src, k)));
435
459
  }
436
460
  return out;
437
461
  }
@@ -1095,7 +1119,7 @@ function errorAwareContainerKeys(state, segments) {
1095
1119
  }
1096
1120
  function materializeErrors(state, containerSegments) {
1097
1121
  const liveContainer = getAtPath(state.form.value, containerSegments);
1098
- const tree = Array.isArray(liveContainer) ? [] : /* @__PURE__ */ Object.create(null);
1122
+ const tree = Array.isArray(liveContainer) ? [] : {};
1099
1123
  const collect = (store, applyActivePathFilter) => {
1100
1124
  entries: for (const [pathKey, errors] of store) {
1101
1125
  if (errors.length === 0) continue;
@@ -1143,18 +1167,18 @@ function placeAt(tree, path, errors) {
1143
1167
  const nextSeg = path[i + 1];
1144
1168
  const key = typeof seg === "number" ? String(seg) : seg;
1145
1169
  const cursorRecord2 = cursor;
1146
- let child = cursorRecord2[key];
1170
+ let child = safeOwnRead(cursorRecord2, key);
1147
1171
  if (child === null || child === void 0 || typeof child !== "object") {
1148
- child = typeof nextSeg === "number" ? [] : /* @__PURE__ */ Object.create(null);
1149
- cursorRecord2[key] = child;
1172
+ child = typeof nextSeg === "number" ? [] : {};
1173
+ safeAssign(cursorRecord2, key, child);
1150
1174
  }
1151
1175
  cursor = child;
1152
1176
  }
1153
1177
  const lastSeg = path[path.length - 1];
1154
1178
  const lastKey = typeof lastSeg === "number" ? String(lastSeg) : lastSeg;
1155
1179
  const cursorRecord = cursor;
1156
- const existing = cursorRecord[lastKey];
1157
- cursorRecord[lastKey] = Array.isArray(existing) ? [...existing, ...errors] : errors;
1180
+ const existing = safeOwnRead(cursorRecord, lastKey);
1181
+ safeAssign(cursorRecord, lastKey, Array.isArray(existing) ? [...existing, ...errors] : errors);
1158
1182
  }
1159
1183
 
1160
1184
  function buildFieldArrayApi(state) {
@@ -1550,10 +1574,10 @@ function stripUnacknowledgedSensitiveLeaves(form, optedInPaths, isSensitivePath)
1550
1574
  if (value === null || typeof value !== "object") return value;
1551
1575
  if (Array.isArray(value)) return value.map((item, i) => walk([...path, i], item));
1552
1576
  if (!isPlainRecord(value)) return value;
1553
- const out = /* @__PURE__ */ Object.create(null);
1577
+ const out = {};
1554
1578
  for (const key of Object.keys(value)) {
1555
1579
  const walked = walk([...path, key], value[key]);
1556
- if (walked !== void 0) out[key] = walked;
1580
+ if (walked !== void 0) safeAssign(out, key, walked);
1557
1581
  }
1558
1582
  return out;
1559
1583
  };
@@ -1585,10 +1609,19 @@ function mergeDeep(target, source, path, schema) {
1585
1609
  if (sourceDisc !== void 0) {
1586
1610
  const variantDefault = du.getVariantDefault(sourceDisc);
1587
1611
  if (isPlainRecord(variantDefault)) {
1588
- const out2 = Object.assign(/* @__PURE__ */ Object.create(null), variantDefault);
1612
+ const out2 = { ...variantDefault };
1589
1613
  for (const key of Object.keys(sourceRecord)) {
1590
- if (!(key in variantDefault) && key !== du.discriminatorKey) continue;
1591
- out2[key] = mergeDeep(out2[key], sourceRecord[key], [...path, key], schema);
1614
+ if (!safeOwnHas(variantDefault, key) && key !== du.discriminatorKey) continue;
1615
+ safeAssign(
1616
+ out2,
1617
+ key,
1618
+ mergeDeep(
1619
+ safeOwnRead(out2, key),
1620
+ safeOwnRead(sourceRecord, key),
1621
+ [...path, key],
1622
+ schema
1623
+ )
1624
+ );
1592
1625
  }
1593
1626
  return out2;
1594
1627
  }
@@ -1597,9 +1630,18 @@ function mergeDeep(target, source, path, schema) {
1597
1630
  }
1598
1631
  }
1599
1632
  const mergeTarget = target;
1600
- const out = isPlainRecord(mergeTarget) ? Object.assign(/* @__PURE__ */ Object.create(null), mergeTarget) : /* @__PURE__ */ Object.create(null);
1633
+ const out = isPlainRecord(mergeTarget) ? { ...mergeTarget } : {};
1601
1634
  for (const key of Object.keys(source)) {
1602
- out[key] = mergeDeep(out[key], source[key], [...path, key], schema);
1635
+ safeAssign(
1636
+ out,
1637
+ key,
1638
+ mergeDeep(
1639
+ safeOwnRead(out, key),
1640
+ safeOwnRead(source, key),
1641
+ [...path, key],
1642
+ schema
1643
+ )
1644
+ );
1603
1645
  }
1604
1646
  return out;
1605
1647
  }
@@ -2383,17 +2425,17 @@ function walk(input, segments, schema, paths) {
2383
2425
  if (slim !== null && slim !== void 0 && typeof slim === "object" && !Array.isArray(slim) && !(slim instanceof Date) && !(slim instanceof RegExp) && !(slim instanceof Map) && !(slim instanceof Set)) {
2384
2426
  for (const k of Object.keys(slim)) allKeys.add(k);
2385
2427
  }
2386
- const out = /* @__PURE__ */ Object.create(null);
2428
+ const out = {};
2387
2429
  let mutated = allKeys.size !== inputKeys.length;
2388
2430
  for (const key of allKeys) {
2389
2431
  const orig = input[key];
2390
2432
  if (orig === void 0 && inputKeysSet.has(key)) {
2391
- out[key] = void 0;
2433
+ safeAssign(out, key, void 0);
2392
2434
  mutated = true;
2393
2435
  continue;
2394
2436
  }
2395
2437
  const walked = walk(orig, [...segments, key], schema, paths);
2396
- out[key] = walked;
2438
+ safeAssign(out, key, walked);
2397
2439
  if (walked !== orig) mutated = true;
2398
2440
  }
2399
2441
  return mutated ? out : input;
@@ -2412,9 +2454,13 @@ function walkUnspecified(slim, segments, paths$1) {
2412
2454
  }
2413
2455
  if (Array.isArray(slim)) return slim;
2414
2456
  if (slim !== null && typeof slim === "object") {
2415
- const out = /* @__PURE__ */ Object.create(null);
2457
+ const out = {};
2416
2458
  for (const key of Object.keys(slim)) {
2417
- out[key] = walkUnspecified(slim[key], [...segments, key], paths$1);
2459
+ safeAssign(
2460
+ out,
2461
+ key,
2462
+ walkUnspecified(slim[key], [...segments, key], paths$1)
2463
+ );
2418
2464
  }
2419
2465
  return out;
2420
2466
  }
@@ -2445,11 +2491,11 @@ function substitute(input, segments, schema, paths) {
2445
2491
  }
2446
2492
  if (typeof input === "object") {
2447
2493
  let mutated = false;
2448
- const out = /* @__PURE__ */ Object.create(null);
2494
+ const out = {};
2449
2495
  for (const key of Object.keys(input)) {
2450
2496
  const orig = input[key];
2451
2497
  const walked = substitute(orig, [...segments, key], schema, paths);
2452
- out[key] = walked;
2498
+ safeAssign(out, key, walked);
2453
2499
  if (walked !== orig) mutated = true;
2454
2500
  }
2455
2501
  return mutated ? out : input;
@@ -3059,9 +3105,9 @@ function buildFormApi(state, formInstanceId, options = {}) {
3059
3105
  if (value === null || typeof value !== "object" || Array.isArray(value)) {
3060
3106
  return EMPTY_FIELD_RECORD;
3061
3107
  }
3062
- const out = /* @__PURE__ */ Object.create(null);
3108
+ const out = {};
3063
3109
  for (const key of Object.keys(value)) {
3064
- out[key] = callTerminal(`${path}.${key}`);
3110
+ safeAssign(out, key, callTerminal(`${path}.${key}`));
3065
3111
  }
3066
3112
  return Object.freeze(out);
3067
3113
  }
@@ -3183,14 +3229,14 @@ function walkDuStubs(schema, value, path, warned) {
3183
3229
  );
3184
3230
  }
3185
3231
  }
3186
- const stub = /* @__PURE__ */ Object.create(null);
3187
- stub[du.discriminatorKey] = discValue;
3232
+ const stub = {};
3233
+ safeAssign(stub, du.discriminatorKey, discValue);
3188
3234
  return stub;
3189
3235
  }
3190
3236
  }
3191
- const out = /* @__PURE__ */ Object.create(null);
3237
+ const out = {};
3192
3238
  for (const k of Object.keys(rec)) {
3193
- out[k] = walkDuStubs(schema, rec[k], [...path, k], warned);
3239
+ safeAssign(out, k, walkDuStubs(schema, rec[k], [...path, k], warned));
3194
3240
  }
3195
3241
  return out;
3196
3242
  }
@@ -3273,8 +3319,8 @@ function cloneVariantSnapshot(value) {
3273
3319
  return out2;
3274
3320
  }
3275
3321
  const src = raw;
3276
- const out = /* @__PURE__ */ Object.create(null);
3277
- for (const k of Object.keys(src)) out[k] = cloneVariantSnapshot(src[k]);
3322
+ const out = {};
3323
+ for (const k of Object.keys(src)) safeAssign(out, k, cloneVariantSnapshot(src[k]));
3278
3324
  return out;
3279
3325
  }
3280
3326
 
@@ -5197,9 +5243,8 @@ function wirePersistence(state, config) {
5197
5243
  if (isDisposed()) return;
5198
5244
  const raw = await adapter.getItem(key);
5199
5245
  const existing = readPersistedPayload(raw);
5200
- const baseForm = existing?.data.form ?? /* @__PURE__ */ Object.create(null);
5201
5246
  const value = getAtPath(vue.toRaw(state.form.value), path);
5202
- const nextForm = setAtPath(baseForm, path, value);
5247
+ const nextForm = setAtPath(existing?.data.form ?? {}, path, value);
5203
5248
  const { key: pathKey } = paths.canonicalizePath(path);
5204
5249
  const transientSet = new Set(
5205
5250
  (existing?.data.blankPaths ?? []).filter(
@@ -5391,15 +5436,15 @@ function stripSensitivePathsDeep(value, pathSoFar, isSensitivePath) {
5391
5436
  }
5392
5437
  const proto = Object.getPrototypeOf(value);
5393
5438
  if (proto !== Object.prototype && proto !== null) return value;
5394
- const out = /* @__PURE__ */ Object.create(null);
5439
+ const out = {};
5395
5440
  const src = value;
5396
5441
  for (const key of Object.keys(src)) {
5397
5442
  const childPath = [...pathSoFar, key];
5398
5443
  if (isSensitivePath(childPath)) {
5399
- out[key] = void 0;
5444
+ safeAssign(out, key, void 0);
5400
5445
  continue;
5401
5446
  }
5402
- out[key] = stripSensitivePathsDeep(src[key], childPath, isSensitivePath);
5447
+ safeAssign(out, key, stripSensitivePathsDeep(src[key], childPath, isSensitivePath));
5403
5448
  }
5404
5449
  return out;
5405
5450
  }
@@ -7171,9 +7216,11 @@ exports.isPlainRecord = isPlainRecord;
7171
7216
  exports.isUnset = isUnset;
7172
7217
  exports.lazy = lazy;
7173
7218
  exports.normalizeNumericOption = normalizeNumericOption;
7219
+ exports.safeAssign = safeAssign;
7220
+ exports.safeOwnRead = safeOwnRead;
7174
7221
  exports.setAtPath = setAtPath;
7175
7222
  exports.slimKindOf = slimKindOf;
7176
7223
  exports.unset = unset;
7177
7224
  exports.useAbstractForm = useAbstractForm;
7178
7225
  exports.useWizard = useWizard;
7179
- //# sourceMappingURL=attaform.DL4CQ-oW.cjs.map
7226
+ //# sourceMappingURL=attaform.DLnE5bZa.cjs.map