attaform 0.30.0 → 0.31.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 +15 -21
- package/dist/abstract.mjs +3 -3
- package/dist/dev/abstract.mjs +4 -4
- package/dist/dev/chunks/devtools.mjs +4 -4
- package/dist/dev/directive.mjs +1 -1
- package/dist/dev/history.mjs +2 -2
- package/dist/dev/index.mjs +5 -5
- package/dist/dev/runtime/plugins/attaform.mjs +1 -1
- package/dist/dev/shared/{attaform-dev.DUZckyV8.mjs → attaform-dev.B1q-x9R9.mjs} +4 -4
- package/dist/dev/shared/{attaform-dev.BcYT6tFh.mjs → attaform-dev.CZz4GYZ6.mjs} +21 -9
- package/dist/dev/shared/{attaform-dev.BisFstxh.mjs → attaform-dev.Caibt7sb.mjs} +16 -15
- package/dist/dev/shared/{attaform-dev.DTrHonpc.mjs → attaform-dev.CtyqGia7.mjs} +176 -260
- package/dist/dev/shared/{attaform-dev.BK6Ge2qR.mjs → attaform-dev.DJ3nsWw6.mjs} +86 -122
- package/dist/dev/shared/{attaform-dev.BcNtyOmf.mjs → attaform-dev.DlaT4xGd.mjs} +4 -4
- package/dist/dev/shared/{attaform-dev.D6CLvaQT.mjs → attaform-dev.k5X47GMD.mjs} +520 -395
- package/dist/dev/shared/{attaform-dev.CQ2rJiAX.mjs → attaform-dev.y9x9Vp9F.mjs} +324 -234
- package/dist/dev/shared/{attaform-dev.BQc5QV3Y.mjs → attaform-dev.zlvDr0WB.mjs} +2 -2
- 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 +4 -4
- package/dist/directive.mjs +1 -1
- package/dist/esbuild.d.mts +11 -0
- package/dist/esbuild.mjs +1 -1
- package/dist/history.d.mts +3 -32
- package/dist/history.mjs +2 -2
- package/dist/index.d.mts +67 -70
- package/dist/index.mjs +4 -4
- package/dist/nuxt.d.mts +4 -3
- package/dist/nuxt.mjs +3 -6
- package/dist/rollup.d.mts +11 -0
- package/dist/rollup.mjs +1 -1
- package/dist/rspack.d.mts +19 -11
- package/dist/rspack.mjs +1 -1
- package/dist/runtime/components/AttaformDevtoolsPanel.vue +15 -15
- package/dist/runtime/components/DevtoolsValueTree.vue +2 -2
- package/dist/runtime/plugins/attaform.mjs +1 -1
- package/dist/shared/{attaform.BRDDQeHV.mjs → attaform.8mfKZCwH.mjs} +2 -2
- package/dist/shared/{attaform.DRUT703x.d.mts → attaform.B-Tb62qV.d.mts} +12 -12
- package/dist/shared/{attaform.v0fQtWyA.mjs → attaform.B1rH9ht6.mjs} +1 -1
- package/dist/shared/{attaform.DhnPb6nK.mjs → attaform.BAf3UNn4.mjs} +1 -1
- package/dist/shared/{attaform.BXneBxEj.mjs → attaform.BWUn8Kjy.mjs} +85 -121
- package/dist/shared/{attaform.WiGdIqgx.mjs → attaform.C4shmwyJ.mjs} +2 -2
- package/dist/shared/{attaform.Rc9u4Vfw.d.mts → attaform.CRVe8s82.d.mts} +83 -95
- package/dist/shared/attaform.D9RqPgGu.d.mts +42 -0
- package/dist/shared/attaform.DAo0QBmS.d.mts +2173 -0
- package/dist/shared/{attaform.BK0cgu2K.mjs → attaform.DBCbxlyk.mjs} +62 -4
- package/dist/shared/{attaform.CUfrMK7t.mjs → attaform.DL2nl_QR.mjs} +15 -14
- package/dist/shared/{attaform.DNJOWjQw.mjs → attaform.DNPJPOO7.mjs} +299 -218
- package/dist/shared/attaform.DZnrDrNb.d.mts +4657 -0
- package/dist/shared/{attaform.B3resMQ1.mjs → attaform.DxKQsqFZ.mjs} +496 -371
- package/dist/shared/{attaform.ByWP6kSx.mjs → attaform.L011tHgJ.mjs} +3 -3
- package/dist/shared/{attaform.CJ8DpRGj.mjs → attaform.LUPC-2Qg.mjs} +175 -257
- package/dist/transforms.d.mts +153 -26
- package/dist/transforms.mjs +1 -1
- package/dist/vite.d.mts +29 -52
- package/dist/vite.mjs +3 -3
- package/dist/webpack.d.mts +20 -12
- package/dist/webpack.mjs +1 -1
- package/dist/zod-v3.d.mts +90 -96
- package/dist/zod-v3.mjs +5 -5
- package/dist/zod-v4.d.mts +120 -118
- package/dist/zod-v4.mjs +5 -5
- package/dist/zod.d.mts +5 -5
- package/dist/zod.mjs +4 -4
- package/package.json +7 -6
- package/skills/attaform/SKILL.md +1 -1
- package/skills/attaform/references/custom-components.md +4 -0
- package/dist/shared/attaform.Clz0ArIi.d.mts +0 -44
- package/dist/shared/attaform.UGyOK83T.d.mts +0 -2366
- package/dist/shared/attaform.bKLzMU0o.d.mts +0 -4761
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { j as humanize, c as useAbstractForm } from './attaform-dev.
|
|
2
|
-
import { A as AttaformError, e as canonicalizePath, a as InvalidUseFormConfigError } from './attaform-dev.
|
|
3
|
-
import { s as slimPrimitivesWalk, d as deriveDefaultWalk, m as mergeDeep, f as fixStructuralDefaults, w as walkPathSegments, c as createAbstractSchema, a as createSharedSchemaStore, b as buildFieldMetaPathMap, e as getFieldMetaListForSchema, g as getFieldMetaForSchema } from './attaform-dev.
|
|
4
|
-
import { c as
|
|
1
|
+
import { j as humanize, c as useAbstractForm } from './attaform-dev.y9x9Vp9F.mjs';
|
|
2
|
+
import { A as AttaformError, e as canonicalizePath, a as InvalidUseFormConfigError } from './attaform-dev.zlvDr0WB.mjs';
|
|
3
|
+
import { s as slimPrimitivesWalk, d as deriveDefaultWalk, m as mergeDeep, f as fixStructuralDefaults, w as walkPathSegments, c as createAbstractSchema, a as createSharedSchemaStore, b as buildFieldMetaPathMap, e as getFieldMetaListForSchema, g as getFieldMetaForSchema } from './attaform-dev.Caibt7sb.mjs';
|
|
4
|
+
import { c as callConsumerFn } from './attaform-dev.CZz4GYZ6.mjs';
|
|
5
5
|
|
|
6
6
|
function readDef(schema) {
|
|
7
7
|
if (schema === null || typeof schema !== "object") return void 0;
|
|
@@ -119,9 +119,7 @@ function isCoercePrimitive(schema) {
|
|
|
119
119
|
return readDef(schema)?.coerce === true;
|
|
120
120
|
}
|
|
121
121
|
function isPreprocessNode(schema) {
|
|
122
|
-
|
|
123
|
-
const pipeIn = unwrapPipeIn(schema);
|
|
124
|
-
return pipeIn !== void 0 && kindOf(pipeIn) === "transform";
|
|
122
|
+
return kindOf(schema) === "pipe" && kindOf(readDef(schema)?.in) === "transform";
|
|
125
123
|
}
|
|
126
124
|
function unwrapPipeOut(schema) {
|
|
127
125
|
const def = readDef(schema);
|
|
@@ -131,7 +129,7 @@ function unwrapLazy(schema) {
|
|
|
131
129
|
const def = readDef(schema);
|
|
132
130
|
const getter = def?.getter;
|
|
133
131
|
if (typeof getter !== "function") return void 0;
|
|
134
|
-
return
|
|
132
|
+
return callConsumerFn(() => getter(), void 0, "lazy-getter");
|
|
135
133
|
}
|
|
136
134
|
function getIntersectionLeft(schema) {
|
|
137
135
|
const def = readDef(schema);
|
|
@@ -145,7 +143,7 @@ function getCatchDefault(schema) {
|
|
|
145
143
|
const def = readDef(schema);
|
|
146
144
|
const cv = def?.catchValue;
|
|
147
145
|
if (typeof cv !== "function") return void 0;
|
|
148
|
-
return
|
|
146
|
+
return callConsumerFn(
|
|
149
147
|
() => cv({ error: new Error("atta:default-values"), input: void 0 }),
|
|
150
148
|
void 0,
|
|
151
149
|
"catch-factory"
|
|
@@ -157,7 +155,7 @@ function hasCatchValue(schema) {
|
|
|
157
155
|
}
|
|
158
156
|
function getDefaultValue(schema) {
|
|
159
157
|
const def = readDef(schema);
|
|
160
|
-
return
|
|
158
|
+
return callConsumerFn(() => def?.defaultValue, void 0, "default-factory");
|
|
161
159
|
}
|
|
162
160
|
function getNativeEnumValues(_schema) {
|
|
163
161
|
return void 0;
|
|
@@ -202,60 +200,6 @@ const DESCEND_SINGLE = [
|
|
|
202
200
|
];
|
|
203
201
|
const DESCEND_RECORD = ["shape", "entries"];
|
|
204
202
|
const DESCEND_LIST = ["options", "items"];
|
|
205
|
-
function walkSchemaTree(schema, visit, seen) {
|
|
206
|
-
const visited = seen ?? /* @__PURE__ */ new WeakSet();
|
|
207
|
-
const candidate = schema;
|
|
208
|
-
if (typeof candidate !== "object" || candidate === null) return false;
|
|
209
|
-
if (visited.has(candidate)) return false;
|
|
210
|
-
visited.add(candidate);
|
|
211
|
-
if (visit(schema)) return true;
|
|
212
|
-
const def = readDef(schema);
|
|
213
|
-
if (def === void 0) return false;
|
|
214
|
-
const slots = def;
|
|
215
|
-
for (const key of DESCEND_SINGLE) {
|
|
216
|
-
const child = slots[key];
|
|
217
|
-
if (child !== void 0 && walkSchemaTree(child, visit, visited)) return true;
|
|
218
|
-
}
|
|
219
|
-
for (const key of DESCEND_RECORD) {
|
|
220
|
-
const record = slots[key];
|
|
221
|
-
if (record !== void 0) {
|
|
222
|
-
for (const sub of Object.values(record)) {
|
|
223
|
-
if (walkSchemaTree(sub, visit, visited)) return true;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
for (const key of DESCEND_LIST) {
|
|
228
|
-
const list = slots[key];
|
|
229
|
-
if (list !== void 0) {
|
|
230
|
-
for (const sub of list) {
|
|
231
|
-
if (walkSchemaTree(sub, visit, visited)) return true;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
if (typeof def.getter === "function") {
|
|
236
|
-
try {
|
|
237
|
-
const inner = def.getter();
|
|
238
|
-
if (walkSchemaTree(inner, visit, visited)) return true;
|
|
239
|
-
} catch {
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
return false;
|
|
243
|
-
}
|
|
244
|
-
function containsDiscriminatedUnion(schema, seen) {
|
|
245
|
-
return walkSchemaTree(schema, (node) => kindOf(node) === "discriminated-union", seen);
|
|
246
|
-
}
|
|
247
|
-
function containsAsyncRefine(schema, seen) {
|
|
248
|
-
return walkSchemaTree(
|
|
249
|
-
schema,
|
|
250
|
-
(node) => {
|
|
251
|
-
for (const check of getChecks(node)) {
|
|
252
|
-
if (isAsyncCheck(check)) return true;
|
|
253
|
-
}
|
|
254
|
-
return false;
|
|
255
|
-
},
|
|
256
|
-
seen
|
|
257
|
-
);
|
|
258
|
-
}
|
|
259
203
|
const CONTAINER_SLOTS = [
|
|
260
204
|
"shape",
|
|
261
205
|
"entries",
|
|
@@ -267,31 +211,55 @@ const CONTAINER_SLOTS = [
|
|
|
267
211
|
"left",
|
|
268
212
|
"right"
|
|
269
213
|
];
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
);
|
|
214
|
+
const capabilityMemo = /* @__PURE__ */ new WeakMap();
|
|
215
|
+
function capabilitiesOf(schema) {
|
|
216
|
+
let capabilities = capabilityMemo.get(schema);
|
|
217
|
+
if (capabilities === void 0) {
|
|
218
|
+
capabilities = scanCapabilities(schema);
|
|
219
|
+
const key = schema;
|
|
220
|
+
if (typeof key === "object" && key !== null) capabilityMemo.set(key, capabilities);
|
|
221
|
+
}
|
|
222
|
+
return capabilities;
|
|
223
|
+
}
|
|
224
|
+
function scanCapabilities(schema) {
|
|
225
|
+
const capabilities = {
|
|
226
|
+
asyncRefine: false,
|
|
227
|
+
asyncTransform: false,
|
|
228
|
+
discriminatedUnion: false,
|
|
229
|
+
containerOrRootRefine: false,
|
|
230
|
+
preprocessOrCoerce: false
|
|
231
|
+
};
|
|
232
|
+
walkCapabilities(schema, capabilities, /* @__PURE__ */ new WeakSet());
|
|
233
|
+
return capabilities;
|
|
234
|
+
}
|
|
235
|
+
function walkCapabilities(node, capabilities, visited) {
|
|
236
|
+
if (typeof node !== "object" || node === null || visited.has(node)) return;
|
|
237
|
+
visited.add(node);
|
|
238
|
+
const def = readDef(node);
|
|
239
|
+
if (def === void 0) return;
|
|
240
|
+
const checks = getChecks(node);
|
|
241
|
+
if (checks.some(isAsyncCheck)) capabilities.asyncRefine = true;
|
|
242
|
+
if (checks.length > 0 && CONTAINER_SLOTS.some((key) => def[key] !== void 0)) {
|
|
243
|
+
capabilities.containerOrRootRefine = true;
|
|
244
|
+
}
|
|
245
|
+
if (typeof def.transform === "function" && def.transform.constructor.name === "AsyncFunction") {
|
|
246
|
+
capabilities.asyncTransform = true;
|
|
247
|
+
}
|
|
248
|
+
if (kindOf(node) === "discriminated-union") capabilities.discriminatedUnion = true;
|
|
249
|
+
if (isCoercePrimitive(node) || isPreprocessNode(node)) capabilities.preprocessOrCoerce = true;
|
|
250
|
+
for (const key of DESCEND_SINGLE) walkCapabilities(def[key], capabilities, visited);
|
|
251
|
+
for (const key of DESCEND_RECORD) {
|
|
252
|
+
for (const sub of Object.values(def[key] ?? {})) walkCapabilities(sub, capabilities, visited);
|
|
253
|
+
}
|
|
254
|
+
for (const key of DESCEND_LIST) {
|
|
255
|
+
for (const sub of def[key] ?? []) walkCapabilities(sub, capabilities, visited);
|
|
256
|
+
}
|
|
257
|
+
if (typeof def.getter === "function") {
|
|
258
|
+
try {
|
|
259
|
+
walkCapabilities(def.getter(), capabilities, visited);
|
|
260
|
+
} catch {
|
|
261
|
+
}
|
|
262
|
+
}
|
|
295
263
|
}
|
|
296
264
|
function isAsyncCheck(check) {
|
|
297
265
|
if (typeof check !== "object" || check === null) return false;
|
|
@@ -344,10 +312,10 @@ function zodIssuesToValidationErrors(issues) {
|
|
|
344
312
|
}
|
|
345
313
|
return {
|
|
346
314
|
message: issue.message,
|
|
347
|
-
// Adapter-side paths stay schema-
|
|
348
|
-
//
|
|
349
|
-
//
|
|
350
|
-
//
|
|
315
|
+
// Adapter-side paths stay schema-RELATIVE: the validation pipeline
|
|
316
|
+
// in `core/create-form-store.ts` prepends the parent path to
|
|
317
|
+
// absolutise, then routes form-level entries, those whose absolute
|
|
318
|
+
// path is empty, to the empty-string bucket at storage time.
|
|
351
319
|
path: issue.path.map((seg) => typeof seg === "number" ? seg : String(seg)),
|
|
352
320
|
code
|
|
353
321
|
};
|
|
@@ -363,10 +331,7 @@ const V4_INTROSPECTOR = {
|
|
|
363
331
|
getLiteralValues,
|
|
364
332
|
isPreprocessNode,
|
|
365
333
|
isCoercePrimitive,
|
|
366
|
-
|
|
367
|
-
containsAsyncTransform,
|
|
368
|
-
containsDiscriminatedUnion,
|
|
369
|
-
hasContainerOrRootRefine,
|
|
334
|
+
capabilitiesOf,
|
|
370
335
|
// Walker accessors (D2 / D3 / D5).
|
|
371
336
|
getArrayElement: (schema) => {
|
|
372
337
|
if (kindOf(schema) !== "array") return void 0;
|
|
@@ -393,7 +358,7 @@ const V4_INTROSPECTOR = {
|
|
|
393
358
|
};
|
|
394
359
|
|
|
395
360
|
function slimPrimitivesOf(schema, maxRecursionDepth) {
|
|
396
|
-
return
|
|
361
|
+
return slimPrimitivesWalk(schema, V4_INTROSPECTOR, maxRecursionDepth);
|
|
397
362
|
}
|
|
398
363
|
|
|
399
364
|
function deriveDefault(schema, useDefault, maxRecursionDepth) {
|
|
@@ -542,13 +507,14 @@ const sharedV4Schemas = createSharedSchemaStore();
|
|
|
542
507
|
function buildV4Services() {
|
|
543
508
|
return {
|
|
544
509
|
getNestedSchemasAtPath: (schema, path, maxRecursionDepth) => getNestedZodSchemasAtPath(schema, path, maxRecursionDepth),
|
|
545
|
-
//
|
|
546
|
-
//
|
|
547
|
-
//
|
|
510
|
+
// No pre-strip for the slim-mode walk: the path walker peels every
|
|
511
|
+
// transparent wrapper inline, so the slim and unstripped walks
|
|
512
|
+
// coincide.
|
|
548
513
|
getNestedSchemasInSlimMode: (schema, path, maxRecursionDepth) => getNestedZodSchemasAtPath(schema, path, maxRecursionDepth),
|
|
549
514
|
slimPrimitivesOf: (schema, maxRecursionDepth) => slimPrimitivesOf(schema, maxRecursionDepth),
|
|
550
515
|
deriveDefault: (schema, useDefault, maxRecursionDepth) => deriveDefault(schema, useDefault, maxRecursionDepth),
|
|
551
516
|
runGetDefaults: (schema, config, maxRecursionDepth) => runGetDefaultsV4(schema, config, maxRecursionDepth),
|
|
517
|
+
validateSync: (schema, data) => validateSyncV4(schema, data),
|
|
552
518
|
unwrapStructuralWrappers: (schema) => unwrapStructuralWrappers(schema),
|
|
553
519
|
unwrapToDiscriminatedUnion: (schema) => unwrapToDiscriminatedUnion(schema),
|
|
554
520
|
peelAllWrappers: (schema) => peelAllWrappers(schema),
|
|
@@ -567,37 +533,35 @@ function buildV4Services() {
|
|
|
567
533
|
};
|
|
568
534
|
}
|
|
569
535
|
function runGetDefaultsV4(rootSchema, config, maxRecursionDepth) {
|
|
570
|
-
|
|
536
|
+
return getDefaultValuesFromZodSchema({
|
|
571
537
|
schema: rootSchema,
|
|
572
538
|
useDefaultSchemaValues: config.useDefaultSchemaValues,
|
|
573
539
|
constraints: config.constraints,
|
|
574
540
|
maxRecursionDepth
|
|
575
|
-
});
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
541
|
+
}).data;
|
|
542
|
+
}
|
|
543
|
+
const verdictRan = /* @__PURE__ */ new WeakMap();
|
|
544
|
+
function validateSyncV4(rootSchema, data) {
|
|
545
|
+
const { asyncRefine, asyncTransform } = capabilitiesOf(rootSchema);
|
|
546
|
+
if (asyncRefine || asyncTransform) return [];
|
|
579
547
|
try {
|
|
580
|
-
const
|
|
581
|
-
if (
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
return {
|
|
585
|
-
data,
|
|
586
|
-
errors: zodIssuesToValidationErrors(parseResult.error.issues),
|
|
587
|
-
success: false
|
|
588
|
-
};
|
|
548
|
+
const jitless = !verdictRan.has(rootSchema);
|
|
549
|
+
if (jitless) verdictRan.set(rootSchema, true);
|
|
550
|
+
const parseResult = rootSchema.safeParse(data, { jitless });
|
|
551
|
+
return parseResult.success ? [] : zodIssuesToValidationErrors(parseResult.error.issues);
|
|
589
552
|
} catch {
|
|
590
|
-
return
|
|
553
|
+
return [];
|
|
591
554
|
}
|
|
592
555
|
}
|
|
593
556
|
function buildSubSchemaStubV4(schema, maxRecursionDepth) {
|
|
594
557
|
return {
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
}
|
|
558
|
+
// Async work of either kind, as the root's `needsAsyncValidation`
|
|
559
|
+
// counts it: the field's `valid` waits for the first async pass.
|
|
560
|
+
needsAsyncValidation: () => {
|
|
561
|
+
const { asyncRefine, asyncTransform } = scanCapabilities(schema);
|
|
562
|
+
return asyncRefine || asyncTransform;
|
|
563
|
+
},
|
|
564
|
+
getDefaultValues: () => deriveDefault(schema, true, maxRecursionDepth),
|
|
601
565
|
getSchemasAtPath: () => [],
|
|
602
566
|
validateAtPath: async (data) => {
|
|
603
567
|
const result = await schema.safeParseAsync(data);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a as InvalidUseFormConfigError } from './attaform-dev.
|
|
2
|
-
import { u as useForm$2 } from './attaform-dev.
|
|
3
|
-
import { u as useForm$1 } from './attaform-dev.
|
|
4
|
-
import { i as installingFieldMetaStore, g as getFieldMetaForSchema } from './attaform-dev.
|
|
1
|
+
import { a as InvalidUseFormConfigError } from './attaform-dev.zlvDr0WB.mjs';
|
|
2
|
+
import { u as useForm$2 } from './attaform-dev.CtyqGia7.mjs';
|
|
3
|
+
import { u as useForm$1 } from './attaform-dev.DJ3nsWw6.mjs';
|
|
4
|
+
import { i as installingFieldMetaStore, g as getFieldMetaForSchema } from './attaform-dev.Caibt7sb.mjs';
|
|
5
5
|
|
|
6
6
|
function isZodV4SchemaShape(value) {
|
|
7
7
|
if (typeof value !== "object" || value === null) return false;
|