attaform 0.30.1 → 0.31.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 (55) hide show
  1. package/dist/abstract.d.mts +5 -5
  2. package/dist/abstract.mjs +4 -4
  3. package/dist/dev/abstract.mjs +4 -4
  4. package/dist/dev/chunks/devtools.mjs +3 -3
  5. package/dist/dev/directive.mjs +1 -1
  6. package/dist/dev/history.mjs +15 -2
  7. package/dist/dev/index.mjs +5 -5
  8. package/dist/dev/runtime/plugins/attaform.mjs +1 -1
  9. package/dist/dev/shared/{attaform-dev.zlvDr0WB.mjs → attaform-dev.04aupFBW.mjs} +3 -2
  10. package/dist/dev/shared/{attaform-dev.DxHdkkPG.mjs → attaform-dev.3uTCYwy8.mjs} +770 -254
  11. package/dist/dev/shared/{attaform-dev.BJK1kqHY.mjs → attaform-dev.BpVGFSFa.mjs} +88 -115
  12. package/dist/dev/shared/{attaform-dev.Chm4D6SJ.mjs → attaform-dev.Bu6wgrA5.mjs} +3 -3
  13. package/dist/dev/shared/{attaform-dev.BMQ3GcgD.mjs → attaform-dev.Cbx0AiQF.mjs} +476 -337
  14. package/dist/dev/shared/attaform-dev.CwYTWyPX.mjs +120 -0
  15. package/dist/dev/shared/{attaform-dev.DuEE4GU1.mjs → attaform-dev.D7lKyM_7.mjs} +4 -4
  16. package/dist/dev/shared/{attaform-dev.CT7MDjPy.mjs → attaform-dev.OceE0X3v.mjs} +154 -229
  17. package/dist/{shared/attaform.DRsANMok.mjs → dev/shared/attaform-dev.PTGM9KE1.mjs} +16 -15
  18. package/dist/{shared/attaform.8mfKZCwH.mjs → dev/shared/attaform-dev.n6n00owJ.mjs} +49 -128
  19. package/dist/dev/zod-v3.mjs +6 -6
  20. package/dist/dev/zod-v4.mjs +6 -6
  21. package/dist/dev/zod.mjs +5 -5
  22. package/dist/directive.d.mts +2 -2
  23. package/dist/directive.mjs +1 -1
  24. package/dist/history.d.mts +1 -1
  25. package/dist/history.mjs +15 -2
  26. package/dist/index.d.mts +16 -55
  27. package/dist/index.mjs +5 -5
  28. package/dist/runtime/components/AttaformDevtoolsPanel.vue +3 -3
  29. package/dist/runtime/plugins/attaform.mjs +1 -1
  30. package/dist/shared/{attaform.CO918TdU.mjs → attaform.B5b-HmhH.mjs} +88 -115
  31. package/dist/shared/{attaform.2FslhB9R.d.mts → attaform.B9PYKlhB.d.mts} +43 -19
  32. package/dist/shared/{attaform.D_f1WgYf.mjs → attaform.BPMOl562.mjs} +458 -319
  33. package/dist/{dev/shared/attaform-dev.CZz4GYZ6.mjs → shared/attaform.BPSqtU7a.mjs} +44 -156
  34. package/dist/shared/{attaform.CdZIEf7_.mjs → attaform.BhtAZysa.mjs} +3 -2
  35. package/dist/shared/{attaform.BcQwgWaq.d.mts → attaform.CYlF4P6X.d.mts} +58 -17
  36. package/dist/shared/{attaform.WiGdIqgx.mjs → attaform.CdA9bfRv.mjs} +3 -3
  37. package/dist/shared/{attaform.BIWicztt.mjs → attaform.DAf4ehIe.mjs} +765 -251
  38. package/dist/shared/{attaform.ZYn2ahzJ.mjs → attaform.DBCbxlyk.mjs} +59 -1
  39. package/dist/shared/{attaform.L0kUn3vL.d.mts → attaform.DZOynI6c.d.mts} +1 -1
  40. package/dist/shared/{attaform.B2iebkPA.mjs → attaform.KEfNRDot.mjs} +4 -4
  41. package/dist/shared/attaform._1Zp3mDG.mjs +96 -0
  42. package/dist/shared/{attaform.Br8EBn5B.d.mts → attaform.i13OEHJF.d.mts} +195 -38
  43. package/dist/{dev/shared/attaform-dev.BUIFcTYf.mjs → shared/attaform.j9xI_ObC.mjs} +16 -15
  44. package/dist/shared/{attaform.D_pt1gOj.mjs → attaform.u6jfHoed.mjs} +154 -229
  45. package/dist/transforms.mjs +1 -1
  46. package/dist/vite.mjs +1 -1
  47. package/dist/zod-v3.d.mts +4 -4
  48. package/dist/zod-v3.mjs +6 -6
  49. package/dist/zod-v4.d.mts +22 -16
  50. package/dist/zod-v4.mjs +6 -6
  51. package/dist/zod.d.mts +4 -4
  52. package/dist/zod.mjs +5 -5
  53. package/package.json +2 -1
  54. package/skills/attaform/SKILL.md +2 -1
  55. package/skills/attaform/references/custom-components.md +4 -0
@@ -1,7 +1,7 @@
1
- import { j as humanize, c as useAbstractForm } from './attaform-dev.DxHdkkPG.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.BUIFcTYf.mjs';
4
- import { c as callConsumerFn } from './attaform-dev.CZz4GYZ6.mjs';
1
+ import { j as humanize, c as useAbstractForm } from './attaform-dev.3uTCYwy8.mjs';
2
+ import { A as AttaformError, e as canonicalizePath, a as InvalidUseFormConfigError } from './attaform-dev.04aupFBW.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.PTGM9KE1.mjs';
4
+ import { d as callConsumerFn } from './attaform-dev.CwYTWyPX.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
- if (kindOf(schema) !== "pipe") return false;
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);
@@ -183,6 +181,9 @@ function getDiscriminatedOptions(schema) {
183
181
  return Array.isArray(options) ? options : [];
184
182
  }
185
183
  function assertZodVersion(schema) {
184
+ assertZodV4Node(schema);
185
+ }
186
+ function assertZodV4Node(schema) {
186
187
  const def = readDef(schema);
187
188
  if (def?.type === void 0) {
188
189
  throw new Error(
@@ -202,60 +203,6 @@ const DESCEND_SINGLE = [
202
203
  ];
203
204
  const DESCEND_RECORD = ["shape", "entries"];
204
205
  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
206
  const CONTAINER_SLOTS = [
260
207
  "shape",
261
208
  "entries",
@@ -267,31 +214,60 @@ const CONTAINER_SLOTS = [
267
214
  "left",
268
215
  "right"
269
216
  ];
270
- function hasContainerOrRootRefine(schema, seen) {
271
- return walkSchemaTree(
272
- schema,
273
- (node) => {
274
- const def = readDef(node);
275
- if (def === void 0) return false;
276
- const slots = def;
277
- if (!CONTAINER_SLOTS.some((key) => slots[key] !== void 0)) return false;
278
- return getChecks(node).length > 0;
279
- },
280
- seen
281
- );
217
+ const capabilityMemo = /* @__PURE__ */ new WeakMap();
218
+ function capabilitiesOf(schema) {
219
+ let capabilities = capabilityMemo.get(schema);
220
+ if (capabilities === void 0) {
221
+ capabilities = scanCapabilities(schema);
222
+ const key = schema;
223
+ if (typeof key === "object" && key !== null) capabilityMemo.set(key, capabilities);
224
+ }
225
+ return capabilities;
226
+ }
227
+ function scanCapabilities(schema) {
228
+ const capabilities = {
229
+ asyncRefine: false,
230
+ asyncTransform: false,
231
+ discriminatedUnion: false,
232
+ containerOrRootRefine: false,
233
+ preprocessOrCoerce: false
234
+ };
235
+ walkCapabilities(schema, capabilities, /* @__PURE__ */ new WeakSet());
236
+ return capabilities;
237
+ }
238
+ function walkCapabilities(node, capabilities, visited) {
239
+ if (typeof node !== "object" || node === null || visited.has(node)) return;
240
+ visited.add(node);
241
+ const def = readDef(node);
242
+ if (def === void 0) return;
243
+ const checks = getChecks(node);
244
+ if (checks.some(isAsyncCheck)) capabilities.asyncRefine = true;
245
+ if (checks.some(isVerdictCheck) && CONTAINER_SLOTS.some((key) => def[key] !== void 0)) {
246
+ capabilities.containerOrRootRefine = true;
247
+ }
248
+ if (typeof def.transform === "function" && def.transform.constructor.name === "AsyncFunction") {
249
+ capabilities.asyncTransform = true;
250
+ }
251
+ if (kindOf(node) === "discriminated-union") capabilities.discriminatedUnion = true;
252
+ if (isCoercePrimitive(node) || isPreprocessNode(node)) capabilities.preprocessOrCoerce = true;
253
+ for (const key of DESCEND_SINGLE) walkCapabilities(def[key], capabilities, visited);
254
+ for (const key of DESCEND_RECORD) {
255
+ for (const sub of Object.values(def[key] ?? {})) walkCapabilities(sub, capabilities, visited);
256
+ }
257
+ for (const key of DESCEND_LIST) {
258
+ for (const sub of def[key] ?? []) walkCapabilities(sub, capabilities, visited);
259
+ }
260
+ if (typeof def.getter === "function") {
261
+ try {
262
+ walkCapabilities(def.getter(), capabilities, visited);
263
+ } catch {
264
+ }
265
+ }
282
266
  }
283
- function containsAsyncTransform(schema, seen) {
284
- return walkSchemaTree(
285
- schema,
286
- (node) => {
287
- const def = readDef(node);
288
- if (def === void 0) return false;
289
- const fn = def.transform;
290
- if (typeof fn !== "function") return false;
291
- return fn.constructor.name === "AsyncFunction";
292
- },
293
- seen
294
- );
267
+ function isVerdictCheck(check) {
268
+ if (typeof check !== "object" || check === null) return true;
269
+ const kind = check._zod?.def?.check;
270
+ return kind !== "describe" && kind !== "meta";
295
271
  }
296
272
  function isAsyncCheck(check) {
297
273
  if (typeof check !== "object" || check === null) return false;
@@ -356,17 +332,14 @@ function zodIssuesToValidationErrors(issues) {
356
332
 
357
333
  const V4_INTROSPECTOR = {
358
334
  kindOf: (schema) => kindOf(schema),
359
- getObjectShape: (schema) => getObjectShape(schema),
335
+ getObjectShape,
360
336
  getTupleItems,
361
- getDiscriminatedOptions: (schema) => getDiscriminatedOptions(schema),
337
+ getDiscriminatedOptions,
362
338
  getDiscriminator,
363
339
  getLiteralValues,
364
340
  isPreprocessNode,
365
341
  isCoercePrimitive,
366
- containsAsyncRefine,
367
- containsAsyncTransform,
368
- containsDiscriminatedUnion,
369
- hasContainerOrRootRefine,
342
+ capabilitiesOf,
370
343
  // Walker accessors (D2 / D3 / D5).
371
344
  getArrayElement: (schema) => {
372
345
  if (kindOf(schema) !== "array") return void 0;
@@ -393,7 +366,7 @@ const V4_INTROSPECTOR = {
393
366
  };
394
367
 
395
368
  function slimPrimitivesOf(schema, maxRecursionDepth) {
396
- return new Set(slimPrimitivesWalk(schema, V4_INTROSPECTOR, maxRecursionDepth));
369
+ return slimPrimitivesWalk(schema, V4_INTROSPECTOR, maxRecursionDepth);
397
370
  }
398
371
 
399
372
  function deriveDefault(schema, useDefault, maxRecursionDepth) {
@@ -525,7 +498,7 @@ function isLeafRequired(schema, depth = 0) {
525
498
  return true;
526
499
  }
527
500
  function zodV4Adapter(rootSchema) {
528
- assertZodVersion(rootSchema);
501
+ assertZodV4Node(rootSchema);
529
502
  assertKeyedRoot(rootSchema);
530
503
  return (_formKey, options) => sharedV4Schemas(
531
504
  rootSchema,
@@ -549,6 +522,7 @@ function buildV4Services() {
549
522
  slimPrimitivesOf: (schema, maxRecursionDepth) => slimPrimitivesOf(schema, maxRecursionDepth),
550
523
  deriveDefault: (schema, useDefault, maxRecursionDepth) => deriveDefault(schema, useDefault, maxRecursionDepth),
551
524
  runGetDefaults: (schema, config, maxRecursionDepth) => runGetDefaultsV4(schema, config, maxRecursionDepth),
525
+ validateSync: (schema, data) => validateSyncV4(schema, data),
552
526
  unwrapStructuralWrappers: (schema) => unwrapStructuralWrappers(schema),
553
527
  unwrapToDiscriminatedUnion: (schema) => unwrapToDiscriminatedUnion(schema),
554
528
  peelAllWrappers: (schema) => peelAllWrappers(schema),
@@ -567,37 +541,35 @@ function buildV4Services() {
567
541
  };
568
542
  }
569
543
  function runGetDefaultsV4(rootSchema, config, maxRecursionDepth) {
570
- const { data } = getDefaultValuesFromZodSchema({
544
+ return getDefaultValuesFromZodSchema({
571
545
  schema: rootSchema,
572
546
  useDefaultSchemaValues: config.useDefaultSchemaValues,
573
547
  constraints: config.constraints,
574
548
  maxRecursionDepth
575
- });
576
- if (containsAsyncTransform(rootSchema) || containsAsyncRefine(rootSchema)) {
577
- return { data, errors: void 0, success: true };
578
- }
549
+ }).data;
550
+ }
551
+ const verdictRan = /* @__PURE__ */ new WeakMap();
552
+ function validateSyncV4(rootSchema, data) {
553
+ const { asyncRefine, asyncTransform } = capabilitiesOf(rootSchema);
554
+ if (asyncRefine || asyncTransform) return [];
579
555
  try {
580
- const parseResult = rootSchema.safeParse(data);
581
- if (parseResult.success) {
582
- return { data, errors: void 0, success: true };
583
- }
584
- return {
585
- data,
586
- errors: zodIssuesToValidationErrors(parseResult.error.issues),
587
- success: false
588
- };
556
+ const jitless = !verdictRan.has(rootSchema);
557
+ if (jitless) verdictRan.set(rootSchema, true);
558
+ const parseResult = rootSchema.safeParse(data, { jitless });
559
+ return parseResult.success ? [] : zodIssuesToValidationErrors(parseResult.error.issues);
589
560
  } catch {
590
- return { data, errors: void 0, success: true };
561
+ return [];
591
562
  }
592
563
  }
593
564
  function buildSubSchemaStubV4(schema, maxRecursionDepth) {
594
565
  return {
595
- needsAsyncValidation: () => containsAsyncRefine(schema),
596
- getDefaultValues: () => ({
597
- data: deriveDefault(schema, true, maxRecursionDepth),
598
- errors: void 0,
599
- success: true
600
- }),
566
+ // Async work of either kind, as the root's `needsAsyncValidation`
567
+ // counts it: the field's `valid` waits for the first async pass.
568
+ needsAsyncValidation: () => {
569
+ const { asyncRefine, asyncTransform } = scanCapabilities(schema);
570
+ return asyncRefine || asyncTransform;
571
+ },
572
+ getDefaultValues: () => deriveDefault(schema, true, maxRecursionDepth),
601
573
  getSchemasAtPath: () => [],
602
574
  validateAtPath: async (data) => {
603
575
  const result = await schema.safeParseAsync(data);
@@ -647,7 +619,8 @@ function resolveFieldMetaAtPath(rootSchema, path, maxRecursionDepth) {
647
619
  };
648
620
  }
649
621
  function readDescription(schema) {
650
- const candidate = schema.description;
622
+ const scope = globalThis;
623
+ const candidate = scope.__zod_globalRegistry?.get(schema)?.description ?? schema.description;
651
624
  return typeof candidate === "string" ? candidate : void 0;
652
625
  }
653
626
 
@@ -1,4 +1,4 @@
1
- import { c as RegistryNotInstalledError, O as OutsideSetupError, g as pathKeyToDotted } from './attaform-dev.zlvDr0WB.mjs';
1
+ import { c as RegistryNotInstalledError, O as OutsideSetupError, g as pathKeyToDotted } from './attaform-dev.04aupFBW.mjs';
2
2
  import { shallowReactive, getCurrentInstance, inject } from 'vue';
3
3
 
4
4
  function detectSSR(options = {}) {
@@ -182,8 +182,8 @@ function renderAttaformState(app) {
182
182
  // The wire shape stays two per-source arrays; the tagged store
183
183
  // splits at the boundary and the client replays each side into
184
184
  // its cell half.
185
- schemaErrors: [...state.errorCells.entries()].filter(([, cell]) => cell.schema.length > 0).map(([key2, cell]) => [key2, cell.schema]),
186
- userErrors: [...state.errorCells.entries()].filter(([, cell]) => cell.user.length > 0).map(([key2, cell]) => [key2, cell.user]),
185
+ schemaErrors: [...state.errorCells().entries()].filter(([, cell]) => cell.schema.length > 0).map(([key2, cell]) => [key2, cell.schema]),
186
+ userErrors: [...state.errorCells().entries()].filter(([, cell]) => cell.user.length > 0).map(([key2, cell]) => [key2, cell.user]),
187
187
  fields: Array.from(state.fields.entries()),
188
188
  ...transientList.length > 0 ? { blankPaths: transientList } : {}
189
189
  }