attaform 0.28.0 → 0.30.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/abstract.d.mts +5 -5
- package/dist/abstract.mjs +4 -4
- package/dist/dev/abstract.mjs +4 -4
- package/dist/dev/chunks/dev-key-collision-warnings.mjs +47 -8
- package/dist/dev/chunks/devtools.mjs +1 -1
- package/dist/dev/directive.mjs +1 -1
- package/dist/dev/history.mjs +1 -2
- package/dist/dev/index.mjs +5 -5
- package/dist/dev/runtime/plugins/attaform.mjs +3 -3
- package/dist/dev/shared/{attaform-dev.oYrkP9dj.mjs → attaform-dev.BK6Ge2qR.mjs} +80 -341
- package/dist/dev/shared/{attaform-dev.Dr2YzS5B.mjs → attaform-dev.BQc5QV3Y.mjs} +11 -19
- package/dist/dev/shared/{attaform-dev.BR8u0YOZ.mjs → attaform-dev.BcNtyOmf.mjs} +4 -4
- package/dist/{shared/attaform.h0i6LijT.mjs → dev/shared/attaform-dev.BcYT6tFh.mjs} +152 -20
- package/dist/dev/shared/{attaform-dev.6qxD-Yqo.mjs → attaform-dev.BisFstxh.mjs} +227 -88
- package/dist/dev/shared/{attaform-dev.WmuhD_CZ.mjs → attaform-dev.CQ2rJiAX.mjs} +833 -656
- package/dist/dev/shared/{attaform-dev.P7cseiEG.mjs → attaform-dev.D6CLvaQT.mjs} +20 -11
- package/dist/dev/shared/{attaform-dev.D2I8e_Mm.mjs → attaform-dev.DTrHonpc.mjs} +225 -238
- package/dist/dev/shared/{attaform-dev.BXE2cr0L.mjs → attaform-dev.DUZckyV8.mjs} +1 -3
- package/dist/dev/zod-v3.mjs +6 -6
- package/dist/dev/zod-v4.mjs +6 -6
- package/dist/dev/zod.mjs +5 -5
- package/dist/directive.d.mts +2 -2
- package/dist/directive.mjs +1 -1
- package/dist/history.d.mts +1 -1
- package/dist/history.mjs +1 -2
- package/dist/index.d.mts +9 -7
- package/dist/index.mjs +5 -5
- package/dist/nuxt.d.mts +11 -20
- package/dist/nuxt.mjs +0 -1
- package/dist/runtime/plugins/attaform.mjs +3 -3
- package/dist/shared/{attaform.uLbun31C.mjs → attaform.B3resMQ1.mjs} +19 -11
- package/dist/shared/{attaform.Cs2Rbdlo.mjs → attaform.BK0cgu2K.mjs} +123 -139
- package/dist/{dev/shared/attaform-dev.By4PRjt0.mjs → shared/attaform.BRDDQeHV.mjs} +136 -26
- package/dist/shared/{attaform.NLmerepI.mjs → attaform.BXneBxEj.mjs} +71 -334
- package/dist/shared/{attaform.D6DCnnQu.mjs → attaform.ByWP6kSx.mjs} +4 -4
- package/dist/shared/{attaform.CJP3RkGa.mjs → attaform.CJ8DpRGj.mjs} +223 -238
- package/dist/shared/{attaform.C09fpdLS.mjs → attaform.CUfrMK7t.mjs} +227 -88
- package/dist/shared/{attaform.wfY8XFvm.mjs → attaform.CdZIEf7_.mjs} +11 -19
- package/dist/shared/{attaform.JfSWdEcb.d.mts → attaform.Clz0ArIi.d.mts} +1 -1
- package/dist/shared/{attaform.B8k8JrmK.mjs → attaform.DNJOWjQw.mjs} +826 -612
- package/dist/shared/{attaform.B4VkS43-.d.mts → attaform.Rc9u4Vfw.d.mts} +1 -1
- package/dist/shared/{attaform.D5V4tZWq.d.mts → attaform.UGyOK83T.d.mts} +200 -218
- package/dist/shared/{attaform.Dq4vWxuG.mjs → attaform.WiGdIqgx.mjs} +1 -3
- package/dist/shared/{attaform.Cgu-hdSb.d.mts → attaform.bKLzMU0o.d.mts} +321 -523
- package/dist/transforms.d.mts +0 -22
- package/dist/transforms.mjs +1 -1
- package/dist/vite.d.mts +13 -4
- package/dist/vite.mjs +8 -2
- package/dist/zod-v3.d.mts +6 -4
- package/dist/zod-v3.mjs +6 -6
- package/dist/zod-v4.d.mts +18 -31
- package/dist/zod-v4.mjs +6 -6
- package/dist/zod.d.mts +4 -4
- package/dist/zod.mjs +5 -5
- package/package.json +19 -15
- package/skills/attaform/SKILL.md +6 -3
- package/skills/attaform/references/custom-components.md +8 -3
- package/skills/attaform/references/errors.md +8 -3
- package/skills/attaform/references/saving.md +77 -0
- package/skills/attaform/references/wizards.md +10 -8
- package/dist/chunks/fingerprint.mjs +0 -183
- package/dist/chunks/fingerprint2.mjs +0 -159
- package/dist/dev/chunks/fingerprint.mjs +0 -183
- package/dist/dev/chunks/fingerprint2.mjs +0 -159
- package/dist/dev/shared/attaform-dev.BJGA_UOS.mjs +0 -36
- package/dist/shared/attaform.BJGA_UOS.mjs +0 -36
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { f as pathsEqual, i as isPathPrefix } from './attaform.
|
|
1
|
+
import { m as mapSegmentKeys, f as pathsEqual, i as isPathPrefix } from './attaform-dev.BQc5QV3Y.mjs';
|
|
2
2
|
|
|
3
3
|
const DEFAULT_FIELD_VALIDATION_DEBOUNCE_MS = 0;
|
|
4
4
|
const DEFAULT_HISTORY_MAX_SNAPSHOTS = 128;
|
|
@@ -7,9 +7,13 @@ const ANONYMOUS_FORM_KEY_PREFIX = `${RESERVED_KEY_PREFIX}anon:`;
|
|
|
7
7
|
const ANONYMOUS_WIZARD_KEY_PREFIX = `${RESERVED_KEY_PREFIX}anon-wizard:`;
|
|
8
8
|
const DEFAULT_MAX_RECURSION_DEPTH = 64;
|
|
9
9
|
function normalizeNumericOption(config) {
|
|
10
|
-
const { value, source,
|
|
11
|
-
if (
|
|
12
|
-
|
|
10
|
+
const { value, source, min, defaultValue } = config;
|
|
11
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
12
|
+
{
|
|
13
|
+
console.warn(
|
|
14
|
+
`[attaform] ${source} must be a non-negative finite integer; got ${String(value)}. Falling back to ${String(defaultValue)}.`
|
|
15
|
+
);
|
|
16
|
+
}
|
|
13
17
|
return defaultValue;
|
|
14
18
|
}
|
|
15
19
|
return Math.max(min, Math.floor(value));
|
|
@@ -22,6 +26,60 @@ function pickDefined(bag) {
|
|
|
22
26
|
return out;
|
|
23
27
|
}
|
|
24
28
|
|
|
29
|
+
const reported = /* @__PURE__ */ new Set() ;
|
|
30
|
+
function report(site, err) {
|
|
31
|
+
if (reported === null || reported.has(site)) return;
|
|
32
|
+
reported.add(site);
|
|
33
|
+
const advice = site === "default-factory" ? "a `.default(() => ...)` factory threw. Attaform used `undefined` for that field's initial value." : site === "catch-factory" ? "a `.catch(() => ...)` fallback threw. Attaform used `undefined` for that value." : "a `z.lazy(() => ...)` factory threw. Attaform stopped descending at that node, so paths below it will not resolve.";
|
|
34
|
+
console.error(
|
|
35
|
+
`[attaform] ${advice} A function inside your schema must not throw; wrap your own try/catch if the failure is recoverable. Original error:`,
|
|
36
|
+
err
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
function callConsumerSchemaFn(fn, fallback, site) {
|
|
40
|
+
try {
|
|
41
|
+
return fn();
|
|
42
|
+
} catch (err) {
|
|
43
|
+
report(site, err);
|
|
44
|
+
return fallback;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function readConsumerProp(obj, key) {
|
|
48
|
+
try {
|
|
49
|
+
return obj[key];
|
|
50
|
+
} catch {
|
|
51
|
+
return void 0;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function consumerKeys(obj) {
|
|
55
|
+
try {
|
|
56
|
+
return Object.keys(obj);
|
|
57
|
+
} catch {
|
|
58
|
+
return [];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function readConsumerIndex(arr, i) {
|
|
62
|
+
try {
|
|
63
|
+
return arr[i];
|
|
64
|
+
} catch {
|
|
65
|
+
return void 0;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function consumerSymbolKeys(obj) {
|
|
69
|
+
try {
|
|
70
|
+
return Object.getOwnPropertySymbols(obj);
|
|
71
|
+
} catch {
|
|
72
|
+
return [];
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function consumerHas(obj, key) {
|
|
76
|
+
try {
|
|
77
|
+
return key in obj;
|
|
78
|
+
} catch {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
25
83
|
function safeAssign(target, key, value) {
|
|
26
84
|
if (key === "__proto__") {
|
|
27
85
|
Object.defineProperty(target, key, {
|
|
@@ -34,24 +92,50 @@ function safeAssign(target, key, value) {
|
|
|
34
92
|
}
|
|
35
93
|
target[key] = value;
|
|
36
94
|
}
|
|
95
|
+
const SHADOWED_KEYS = new Set(Object.getOwnPropertyNames(Object.prototype));
|
|
37
96
|
function isShadowedKey(key) {
|
|
38
|
-
return key
|
|
97
|
+
return SHADOWED_KEYS.has(key);
|
|
39
98
|
}
|
|
40
99
|
function safeOwnRead(target, key) {
|
|
41
100
|
if (isShadowedKey(key)) {
|
|
42
101
|
const desc = Object.getOwnPropertyDescriptor(target, key);
|
|
43
102
|
if (desc === void 0) return void 0;
|
|
44
|
-
return "value" in desc ? desc.value : target
|
|
103
|
+
return "value" in desc ? desc.value : readConsumerProp(target, key);
|
|
45
104
|
}
|
|
46
|
-
return target
|
|
105
|
+
return readConsumerProp(target, key);
|
|
47
106
|
}
|
|
48
107
|
function safeOwnHas(target, key) {
|
|
49
|
-
|
|
108
|
+
try {
|
|
109
|
+
return Object.prototype.hasOwnProperty.call(target, key);
|
|
110
|
+
} catch {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function spreadConsumerRecord(src) {
|
|
115
|
+
try {
|
|
116
|
+
return { ...src };
|
|
117
|
+
} catch {
|
|
118
|
+
const out = {};
|
|
119
|
+
for (const key of Object.keys(src)) {
|
|
120
|
+
safeAssign(out, key, readConsumerProp(src, key));
|
|
121
|
+
}
|
|
122
|
+
return out;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function copyConsumerArray(src) {
|
|
126
|
+
try {
|
|
127
|
+
return src.slice();
|
|
128
|
+
} catch {
|
|
129
|
+
const out = new Array(src.length);
|
|
130
|
+
for (let i = 0; i < src.length; i++) out[i] = readConsumerIndex(src, i);
|
|
131
|
+
return out;
|
|
132
|
+
}
|
|
50
133
|
}
|
|
51
134
|
|
|
52
135
|
function isDescendable(value) {
|
|
53
136
|
if (value === null || typeof value !== "object") return false;
|
|
54
137
|
if (Array.isArray(value)) return true;
|
|
138
|
+
if (value instanceof Map) return mapSegmentKeys(value) !== null;
|
|
55
139
|
const proto = Object.getPrototypeOf(value);
|
|
56
140
|
return proto === null || proto === Object.prototype;
|
|
57
141
|
}
|
|
@@ -77,6 +161,16 @@ function diffAndApply(oldValue, newValue, prefix, visit) {
|
|
|
77
161
|
return;
|
|
78
162
|
}
|
|
79
163
|
if (oldIsDescendable && newIsDescendable) {
|
|
164
|
+
const oldIsMap = oldValue instanceof Map;
|
|
165
|
+
const newIsMap = newValue instanceof Map;
|
|
166
|
+
if (oldIsMap && newIsMap) {
|
|
167
|
+
diffMapsLockstep(oldValue, newValue, prefix, visit);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
if (oldIsMap !== newIsMap) {
|
|
171
|
+
visit({ kind: "changed", path: prefix, oldValue, newValue });
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
80
174
|
const oldIsArray = Array.isArray(oldValue);
|
|
81
175
|
const newIsArray = Array.isArray(newValue);
|
|
82
176
|
if (oldIsArray && newIsArray) {
|
|
@@ -116,46 +210,79 @@ function diffAndApply(oldValue, newValue, prefix, visit) {
|
|
|
116
210
|
function walkNewDescendable(newValue, prefix, visit) {
|
|
117
211
|
if (Array.isArray(newValue)) {
|
|
118
212
|
for (let i = 0; i < newValue.length; i++) {
|
|
119
|
-
diffAndApply(void 0, newValue
|
|
213
|
+
diffAndApply(void 0, readConsumerIndex(newValue, i), appendSegment(prefix, i), visit);
|
|
214
|
+
}
|
|
215
|
+
} else if (newValue instanceof Map) {
|
|
216
|
+
for (const [key, entry] of newValue) {
|
|
217
|
+
diffAndApply(void 0, entry, appendSegment(prefix, key), visit);
|
|
120
218
|
}
|
|
121
219
|
} else {
|
|
122
220
|
const rec = newValue;
|
|
123
|
-
for (const k of
|
|
124
|
-
diffAndApply(void 0, rec
|
|
221
|
+
for (const k of consumerKeys(rec)) {
|
|
222
|
+
diffAndApply(void 0, readConsumerProp(rec, k), appendSegment(prefix, k), visit);
|
|
125
223
|
}
|
|
126
224
|
}
|
|
127
225
|
}
|
|
128
226
|
function walkOldDescendable(oldValue, prefix, visit) {
|
|
129
227
|
if (Array.isArray(oldValue)) {
|
|
130
228
|
for (let i = 0; i < oldValue.length; i++) {
|
|
131
|
-
diffAndApply(oldValue
|
|
229
|
+
diffAndApply(readConsumerIndex(oldValue, i), void 0, appendSegment(prefix, i), visit);
|
|
230
|
+
}
|
|
231
|
+
} else if (oldValue instanceof Map) {
|
|
232
|
+
for (const [key, entry] of oldValue) {
|
|
233
|
+
diffAndApply(entry, void 0, appendSegment(prefix, key), visit);
|
|
132
234
|
}
|
|
133
235
|
} else {
|
|
134
236
|
const rec = oldValue;
|
|
135
|
-
for (const k of
|
|
136
|
-
diffAndApply(rec
|
|
237
|
+
for (const k of consumerKeys(rec)) {
|
|
238
|
+
diffAndApply(readConsumerProp(rec, k), void 0, appendSegment(prefix, k), visit);
|
|
137
239
|
}
|
|
138
240
|
}
|
|
139
241
|
}
|
|
242
|
+
function diffMapsLockstep(oldMap, newMap, prefix, visit) {
|
|
243
|
+
for (const [key, entry] of newMap) {
|
|
244
|
+
diffAndApply(oldMap.get(key), entry, appendSegment(prefix, key), visit);
|
|
245
|
+
}
|
|
246
|
+
for (const [key, entry] of oldMap) {
|
|
247
|
+
if (newMap.has(key)) continue;
|
|
248
|
+
diffAndApply(entry, void 0, appendSegment(prefix, key), visit);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
140
251
|
function diffArraysLockstep(oldArr, newArr, prefix, visit) {
|
|
141
252
|
const max = Math.max(oldArr.length, newArr.length);
|
|
142
253
|
for (let i = 0; i < max; i++) {
|
|
143
|
-
diffAndApply(
|
|
254
|
+
diffAndApply(
|
|
255
|
+
readConsumerIndex(oldArr, i),
|
|
256
|
+
readConsumerIndex(newArr, i),
|
|
257
|
+
appendSegment(prefix, i),
|
|
258
|
+
visit
|
|
259
|
+
);
|
|
144
260
|
}
|
|
145
261
|
}
|
|
146
262
|
function diffObjectsLockstep(oldRec, newRec, prefix, visit) {
|
|
147
263
|
const seen = /* @__PURE__ */ new Set();
|
|
148
|
-
for (const k of
|
|
264
|
+
for (const k of consumerKeys(oldRec)) {
|
|
149
265
|
seen.add(k);
|
|
150
|
-
diffAndApply(
|
|
266
|
+
diffAndApply(
|
|
267
|
+
readConsumerProp(oldRec, k),
|
|
268
|
+
readConsumerProp(newRec, k),
|
|
269
|
+
appendSegment(prefix, k),
|
|
270
|
+
visit
|
|
271
|
+
);
|
|
151
272
|
}
|
|
152
|
-
for (const k of
|
|
273
|
+
for (const k of consumerKeys(newRec)) {
|
|
153
274
|
if (seen.has(k)) continue;
|
|
154
|
-
diffAndApply(
|
|
275
|
+
diffAndApply(
|
|
276
|
+
readConsumerProp(oldRec, k),
|
|
277
|
+
readConsumerProp(newRec, k),
|
|
278
|
+
appendSegment(prefix, k),
|
|
279
|
+
visit
|
|
280
|
+
);
|
|
155
281
|
}
|
|
156
282
|
}
|
|
157
283
|
function applyChangedKeys(target, source, arrayOpPath, currentPath, patches) {
|
|
158
284
|
if (!isDescendable(target) || !isDescendable(source)) return false;
|
|
285
|
+
if (target instanceof Map || source instanceof Map) return false;
|
|
159
286
|
const targetIsArray = Array.isArray(target);
|
|
160
287
|
const sourceIsArray = Array.isArray(source);
|
|
161
288
|
if (targetIsArray !== sourceIsArray) return false;
|
|
@@ -224,6 +351,11 @@ function applyChangedKeys(target, source, arrayOpPath, currentPath, patches) {
|
|
|
224
351
|
}
|
|
225
352
|
function structuralSnapshot(value) {
|
|
226
353
|
if (!isDescendable(value)) return value;
|
|
354
|
+
if (value instanceof Map) {
|
|
355
|
+
const out2 = /* @__PURE__ */ new Map();
|
|
356
|
+
for (const [k, v] of value) out2.set(k, structuralSnapshot(v));
|
|
357
|
+
return out2;
|
|
358
|
+
}
|
|
227
359
|
if (Array.isArray(value)) {
|
|
228
360
|
const out2 = new Array(value.length);
|
|
229
361
|
for (let i = 0; i < value.length; i++) {
|
|
@@ -239,4 +371,4 @@ function structuralSnapshot(value) {
|
|
|
239
371
|
return out;
|
|
240
372
|
}
|
|
241
373
|
|
|
242
|
-
export { ANONYMOUS_FORM_KEY_PREFIX as A, DEFAULT_HISTORY_MAX_SNAPSHOTS as D, RESERVED_KEY_PREFIX as R, safeOwnRead as a, safeAssign as b,
|
|
374
|
+
export { ANONYMOUS_FORM_KEY_PREFIX as A, DEFAULT_HISTORY_MAX_SNAPSHOTS as D, RESERVED_KEY_PREFIX as R, safeOwnRead as a, safeAssign as b, callConsumerSchemaFn as c, safeOwnHas as d, consumerHas as e, spreadConsumerRecord as f, copyConsumerArray as g, consumerKeys as h, isShadowedKey as i, readConsumerProp as j, diffAndApply as k, DEFAULT_FIELD_VALIDATION_DEBOUNCE_MS as l, consumerSymbolKeys as m, normalizeNumericOption as n, applyChangedKeys as o, pickDefined as p, DEFAULT_MAX_RECURSION_DEPTH as q, readConsumerIndex as r, structuralSnapshot as s, ANONYMOUS_WIZARD_KEY_PREFIX as t };
|