attaform 0.27.5 → 0.28.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 -4
- package/dist/abstract.mjs +4 -3
- package/dist/chunks/fingerprint.mjs +0 -1
- package/dist/chunks/fingerprint2.mjs +1 -2
- package/dist/dev/abstract.mjs +4 -0
- package/dist/{chunks → dev/chunks}/dev-key-collision-warnings.mjs +0 -1
- package/dist/{chunks → dev/chunks}/devtools.mjs +5 -6
- package/dist/{chunks/fingerprint.cjs → dev/chunks/fingerprint.mjs} +7 -10
- package/dist/{chunks/fingerprint2.cjs → dev/chunks/fingerprint2.mjs} +32 -35
- package/dist/dev/directive.mjs +1 -0
- package/dist/dev/history.mjs +89 -0
- package/dist/dev/index.mjs +5 -0
- package/dist/dev/runtime/plugins/attaform.mjs +40 -0
- package/dist/{shared/attaform.f2zyNh5d.cjs → dev/shared/attaform-dev.6qxD-Yqo.mjs} +187 -43
- package/dist/{shared/attaform.CQN9R62B.cjs → dev/shared/attaform-dev.BJGA_UOS.mjs} +1 -4
- package/dist/{shared/attaform.Dc1mx48r.mjs → dev/shared/attaform-dev.BR8u0YOZ.mjs} +6 -7
- package/dist/dev/shared/attaform-dev.BXE2cr0L.mjs +220 -0
- package/dist/dev/shared/attaform-dev.By4PRjt0.mjs +248 -0
- package/dist/{shared/attaform.Cg_8gFQ7.mjs → dev/shared/attaform-dev.D2I8e_Mm.mjs} +132 -568
- package/dist/dev/shared/attaform-dev.Dr2YzS5B.mjs +197 -0
- package/dist/{shared/attaform.nMaz2C5P.mjs → dev/shared/attaform-dev.P7cseiEG.mjs} +178 -397
- package/dist/{shared/attaform.BypWgXRB.mjs → dev/shared/attaform-dev.WmuhD_CZ.mjs} +3955 -5029
- package/dist/{shared/attaform.Dkjh_F30.mjs → dev/shared/attaform-dev.oYrkP9dj.mjs} +160 -508
- package/dist/dev/zod-v3.mjs +17 -0
- package/dist/dev/zod-v4.mjs +16 -0
- package/dist/dev/zod.mjs +5 -0
- package/dist/directive.d.mts +20 -0
- package/dist/directive.mjs +1 -0
- package/dist/esbuild.mjs +0 -1
- package/dist/history.d.mts +59 -0
- package/dist/history.mjs +89 -0
- package/dist/index.d.mts +11 -5
- package/dist/index.mjs +5 -4
- package/dist/nuxt.d.mts +1 -1
- package/dist/nuxt.mjs +5 -2
- package/dist/rollup.mjs +0 -1
- package/dist/rspack.d.mts +6 -1
- package/dist/rspack.mjs +0 -1
- package/dist/runtime/components/AttaformDevtoolsPanel.vue +9 -8
- package/dist/runtime/plugins/attaform.mjs +1 -2
- package/dist/shared/{attaform.CIBMfxg9.d.ts → attaform.B4VkS43-.d.mts} +2 -2
- package/dist/shared/{attaform.Cg1rUfcF.cjs → attaform.B8k8JrmK.mjs} +3778 -5297
- package/dist/shared/attaform.BJGA_UOS.mjs +0 -1
- package/dist/shared/{attaform.CTiZ9Rrv.mjs → attaform.C09fpdLS.mjs} +172 -16
- package/dist/shared/{attaform.Bh8A6YAc.cjs → attaform.CJP3RkGa.mjs} +141 -590
- package/dist/shared/{attaform.CzL2CZ8U.d.ts → attaform.Cgu-hdSb.d.mts} +328 -78
- package/dist/shared/attaform.Cs2Rbdlo.mjs +0 -1
- package/dist/shared/{attaform.DcFDQVpa.d.ts → attaform.D5V4tZWq.d.mts} +79 -179
- package/dist/shared/{attaform.CF-EnyJn.cjs → attaform.D6DCnnQu.mjs} +11 -16
- package/dist/shared/attaform.DhnPb6nK.mjs +0 -1
- package/dist/shared/attaform.Dq4vWxuG.mjs +197 -0
- package/dist/shared/attaform.JfSWdEcb.d.mts +44 -0
- package/dist/shared/attaform.KvlEedlF.mjs +0 -1
- package/dist/shared/{attaform.Crv0RNiz.cjs → attaform.NLmerepI.mjs} +175 -557
- package/dist/shared/attaform.h0i6LijT.mjs +242 -0
- package/dist/shared/{attaform.Biytrv0-.cjs → attaform.uLbun31C.mjs} +204 -544
- package/dist/shared/attaform.v0fQtWyA.mjs +0 -1
- package/dist/shared/attaform.wfY8XFvm.mjs +197 -0
- package/dist/transforms.mjs +0 -1
- package/dist/vite.d.mts +17 -5
- package/dist/vite.mjs +24 -2
- package/dist/webpack.d.mts +6 -1
- package/dist/webpack.mjs +0 -1
- package/dist/zod-v3.d.mts +11 -6
- package/dist/zod-v3.mjs +17 -4
- package/dist/zod-v4.d.mts +12 -6
- package/dist/zod-v4.mjs +16 -4
- package/dist/zod.d.mts +4 -3
- package/dist/zod.mjs +5 -4
- package/package.json +23 -8
- package/skills/attaform/SKILL.md +2 -1
- package/dist/abstract.cjs +0 -48
- package/dist/abstract.cjs.map +0 -1
- package/dist/abstract.d.cts +0 -42
- package/dist/abstract.d.ts +0 -42
- package/dist/abstract.mjs.map +0 -1
- package/dist/chunks/dev-key-collision-warnings.cjs +0 -25
- package/dist/chunks/dev-key-collision-warnings.cjs.map +0 -1
- package/dist/chunks/dev-key-collision-warnings.mjs.map +0 -1
- package/dist/chunks/devtools.cjs +0 -157
- package/dist/chunks/devtools.cjs.map +0 -1
- package/dist/chunks/devtools.mjs.map +0 -1
- package/dist/chunks/fingerprint.cjs.map +0 -1
- package/dist/chunks/fingerprint.mjs.map +0 -1
- package/dist/chunks/fingerprint2.cjs.map +0 -1
- package/dist/chunks/fingerprint2.mjs.map +0 -1
- package/dist/esbuild.cjs +0 -28
- package/dist/esbuild.cjs.map +0 -1
- package/dist/esbuild.d.cts +0 -56
- package/dist/esbuild.d.ts +0 -56
- package/dist/esbuild.mjs.map +0 -1
- package/dist/index.cjs +0 -51
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -249
- package/dist/index.d.ts +0 -249
- package/dist/index.mjs.map +0 -1
- package/dist/nuxt.cjs +0 -84
- package/dist/nuxt.cjs.map +0 -1
- package/dist/nuxt.d.cts +0 -66
- package/dist/nuxt.d.ts +0 -66
- package/dist/nuxt.mjs.map +0 -1
- package/dist/rollup.cjs +0 -24
- package/dist/rollup.cjs.map +0 -1
- package/dist/rollup.d.cts +0 -35
- package/dist/rollup.d.ts +0 -35
- package/dist/rollup.mjs.map +0 -1
- package/dist/rspack.cjs +0 -10
- package/dist/rspack.cjs.map +0 -1
- package/dist/rspack.d.cts +0 -40
- package/dist/rspack.d.ts +0 -40
- package/dist/rspack.mjs.map +0 -1
- package/dist/runtime/components/AttaformDevtoolsPanel.vue.d.ts +0 -7
- package/dist/runtime/components/DevtoolsValueTree.vue.d.ts +0 -35
- package/dist/runtime/plugins/attaform.cjs +0 -43
- package/dist/runtime/plugins/attaform.cjs.map +0 -1
- package/dist/runtime/plugins/attaform.d.cts +0 -5
- package/dist/runtime/plugins/attaform.d.ts +0 -5
- package/dist/runtime/plugins/attaform.mjs.map +0 -1
- package/dist/shared/attaform.B3abZaCV.d.cts +0 -2484
- package/dist/shared/attaform.BJGA_UOS.mjs.map +0 -1
- package/dist/shared/attaform.Bh8A6YAc.cjs.map +0 -1
- package/dist/shared/attaform.Biytrv0-.cjs.map +0 -1
- package/dist/shared/attaform.Bn0IzhD_.cjs +0 -800
- package/dist/shared/attaform.Bn0IzhD_.cjs.map +0 -1
- package/dist/shared/attaform.BypWgXRB.mjs.map +0 -1
- package/dist/shared/attaform.C9fPTxjB.d.cts +0 -41
- package/dist/shared/attaform.C9fPTxjB.d.ts +0 -41
- package/dist/shared/attaform.CF-EnyJn.cjs.map +0 -1
- package/dist/shared/attaform.CJ1Z9Mz4.d.mts +0 -2484
- package/dist/shared/attaform.CQN9R62B.cjs.map +0 -1
- package/dist/shared/attaform.CTiZ9Rrv.mjs.map +0 -1
- package/dist/shared/attaform.Cg1rUfcF.cjs.map +0 -1
- package/dist/shared/attaform.Cg_8gFQ7.mjs.map +0 -1
- package/dist/shared/attaform.Crv0RNiz.cjs.map +0 -1
- package/dist/shared/attaform.Cs2Rbdlo.mjs.map +0 -1
- package/dist/shared/attaform.CzL2CZ8U.d.cts +0 -4713
- package/dist/shared/attaform.CzL2CZ8U.d.mts +0 -4713
- package/dist/shared/attaform.DRUT703x.d.cts +0 -56
- package/dist/shared/attaform.DRUT703x.d.ts +0 -56
- package/dist/shared/attaform.DYwyM5Cp.d.cts +0 -232
- package/dist/shared/attaform.Dc1mx48r.mjs.map +0 -1
- package/dist/shared/attaform.DhnPb6nK.mjs.map +0 -1
- package/dist/shared/attaform.Dkjh_F30.mjs.map +0 -1
- package/dist/shared/attaform.DoQm_Vkd.cjs +0 -58
- package/dist/shared/attaform.DoQm_Vkd.cjs.map +0 -1
- package/dist/shared/attaform.DrHOqB-d.d.mts +0 -232
- package/dist/shared/attaform.KvlEedlF.mjs.map +0 -1
- package/dist/shared/attaform.RaTzp1WF.cjs +0 -26
- package/dist/shared/attaform.RaTzp1WF.cjs.map +0 -1
- package/dist/shared/attaform.f2zyNh5d.cjs.map +0 -1
- package/dist/shared/attaform.nMaz2C5P.mjs.map +0 -1
- package/dist/shared/attaform.v0fQtWyA.mjs.map +0 -1
- package/dist/shared/attaform.yUrz7C2z.cjs +0 -29
- package/dist/shared/attaform.yUrz7C2z.cjs.map +0 -1
- package/dist/transforms.cjs +0 -12
- package/dist/transforms.cjs.map +0 -1
- package/dist/transforms.d.cts +0 -73
- package/dist/transforms.d.ts +0 -73
- package/dist/transforms.mjs.map +0 -1
- package/dist/vite.cjs +0 -363
- package/dist/vite.cjs.map +0 -1
- package/dist/vite.d.cts +0 -133
- package/dist/vite.d.ts +0 -133
- package/dist/vite.mjs.map +0 -1
- package/dist/webpack.cjs +0 -10
- package/dist/webpack.cjs.map +0 -1
- package/dist/webpack.d.cts +0 -37
- package/dist/webpack.d.ts +0 -37
- package/dist/webpack.mjs.map +0 -1
- package/dist/zod-v3.cjs +0 -53
- package/dist/zod-v3.cjs.map +0 -1
- package/dist/zod-v3.d.cts +0 -246
- package/dist/zod-v3.d.ts +0 -246
- package/dist/zod-v3.mjs.map +0 -1
- package/dist/zod-v4.cjs +0 -55
- package/dist/zod-v4.cjs.map +0 -1
- package/dist/zod-v4.d.cts +0 -172
- package/dist/zod-v4.d.ts +0 -172
- package/dist/zod-v4.mjs.map +0 -1
- package/dist/zod.cjs +0 -51
- package/dist/zod.cjs.map +0 -1
- package/dist/zod.d.cts +0 -7
- package/dist/zod.d.ts +0 -7
- package/dist/zod.mjs.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fingerprint2.mjs","sources":["../../src/runtime/adapters/zod-v4/fingerprint.ts"],"sourcesContent":["import type { z } from 'zod'\nimport { canonicalStringify } from '../../core/canonical-stringify'\nimport {\n getArrayElement,\n getCatchDefault,\n getChecks,\n getDefaultValue,\n getDiscriminatedOptions,\n getDiscriminator,\n getEnumValues,\n getIntersectionLeft,\n getIntersectionRight,\n getLiteralValues,\n getObjectShape,\n getRecordKeyType,\n getRecordValueType,\n getSetValueType,\n getTupleItems,\n getUnionOptions,\n kindOf,\n unwrapInner,\n unwrapLazy,\n unwrapPipe,\n} from './introspect'\n\n/**\n * Compute a structural fingerprint for a Zod v4 schema.\n *\n * The returned string is:\n * - **Deterministic** for any pair of schemas with the same shape,\n * regardless of whether they were constructed by the same\n * `z.object({...})` call or two identical ones in different files.\n * - **Key-order-insensitive** for `z.object` — shape entries are\n * sorted before serialisation, so `{a, b}` and `{b, a}` produce\n * the same fingerprint.\n * - **Order-insensitive for `z.union`** — option fingerprints are\n * sorted before they're folded in, because union membership has\n * no semantic order.\n * - **Idempotent** — two fingerprint calls on the same schema\n * reference return identical strings, even when the schema\n * contains non-deterministic metadata (e.g. `.default(() => new\n * Date())`). Factories of any kind collapse to an opaque\n * `fn:*` sentinel for this reason (see `defaultValueRepr`).\n *\n * **Known false negatives** — situations where two semantically\n * different schemas hash the same:\n * - `.refine(fn1)` and `.refine(fn2)`: function bodies aren't\n * hashable in a way that survives minification / different closure\n * captures, so every refinement collapses via the generic `fn:*`\n * sentinel. The warning this powers is a best-effort footgun\n * catcher, not a soundness guarantee — two forms whose only\n * difference is refinement logic will look identical here.\n * - `.transform(fn)`: same reason.\n * - `.default(() => x)` where the factory is non-deterministic:\n * collapses to `fn:*` (idempotence requirement — we can't hash a\n * fresh Date on every call).\n * - `z.custom()` — no structural information to introspect; renders\n * as `custom:*`.\n *\n * **Caching is per-call, not module-global.** A WeakMap cache\n * scoped to the starting schema would break correctness under\n * cycles: the `<cyclic>` sentinel's meaning is relative to the\n * call's starting node, so a cached mid-traversal result from one\n * call is wrong for a different call. Cheapest correct design is\n * \"fresh cache per top-level call.\" A 50-field nested schema\n * fingerprints in microseconds, and the library calls `fingerprint`\n * at most twice per shared-key collision (existing + incoming) —\n * not a hot path.\n */\n\nconst cyclicSentinel = '<cyclic>'\n\nexport function fingerprintZodSchema(schema: z.ZodType): string {\n const cache = new WeakMap<z.ZodType, string>()\n const inProgress = new WeakSet<z.ZodType>()\n return visit(schema, cache, inProgress)\n}\n\nfunction visit(\n schema: z.ZodType,\n cache: WeakMap<z.ZodType, string>,\n inProgress: WeakSet<z.ZodType>\n): string {\n const cached = cache.get(schema)\n if (cached !== undefined) return cached\n if (inProgress.has(schema)) return cyclicSentinel\n inProgress.add(schema)\n try {\n const computed = computeFingerprint(schema, cache, inProgress)\n cache.set(schema, computed)\n return computed\n } finally {\n inProgress.delete(schema)\n }\n}\n\nfunction computeFingerprint(\n schema: z.ZodType,\n cache: WeakMap<z.ZodType, string>,\n inProgress: WeakSet<z.ZodType>\n): string {\n const kind = kindOf(schema)\n const recurse = (child: z.ZodType): string => visit(child, cache, inProgress)\n switch (kind) {\n // Kind-only leaves: no further structure to descend into.\n case 'boolean':\n case 'null':\n case 'undefined':\n case 'any':\n case 'unknown':\n case 'nan':\n case 'void':\n case 'never':\n return kind\n\n // Leaves with checks (min/max/email/regex/...). Checks are\n // canonicalised and sorted so `.min(3).max(10)` and `.max(10).min(3)`\n // produce identical fingerprints.\n case 'string':\n case 'number':\n case 'bigint':\n case 'date':\n return `${kind}${formatChecks(schema)}`\n\n case 'literal': {\n // `z.literal(['a', 'b'])` accepts either — the value set has\n // no semantic order, so canonical-sort before hashing so\n // `['a','b']` and `['b','a']` match. `z.literal` accepts\n // string / number / boolean / null / undefined / bigint /\n // symbol — sort by canonicalised string form to get a total\n // order across those types.\n const values = [...getLiteralValues(schema)].sort((a, b) => {\n const as = canonicalStringify(a)\n const bs = canonicalStringify(b)\n return as < bs ? -1 : as > bs ? 1 : 0\n })\n return `literal:${canonicalStringify(values)}`\n }\n\n case 'enum':\n // Enum values have no semantic order — sort before folding.\n return `enum:${canonicalStringify([...getEnumValues(schema)].sort((a, b) => compare(a, b)))}`\n\n case 'object': {\n const shape = getObjectShape(schema as z.ZodObject)\n const sortedEntries = Object.entries(shape)\n .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))\n .map(([k, v]) => `${JSON.stringify(k)}:${recurse(v)}`)\n return `object{${sortedEntries.join(',')}}${formatChecks(schema)}`\n }\n\n case 'array':\n return `array[${recurse(getArrayElement(schema as z.ZodArray))}]${formatChecks(schema)}`\n\n case 'set':\n return `set<${recurse(getSetValueType(schema))}>${formatChecks(schema)}`\n\n case 'tuple':\n return `tuple[${getTupleItems(schema).map(recurse).join(',')}]`\n\n case 'record':\n return `record<${recurse(getRecordKeyType(schema))},${recurse(getRecordValueType(schema))}>`\n\n case 'union': {\n // Union membership has no order; sort option fingerprints.\n const options = getUnionOptions(schema).map(recurse).sort()\n return `union(${options.join('|')})`\n }\n\n case 'discriminated-union': {\n const disc = getDiscriminator(schema) ?? '?'\n const options = getDiscriminatedOptions(schema).map(recurse).sort()\n return `dunion[${JSON.stringify(disc)}](${options.join('|')})`\n }\n\n case 'optional': {\n const inner = unwrapInner(schema)\n return inner === undefined ? 'optional(?)' : `optional(${recurse(inner)})`\n }\n\n case 'nullable': {\n const inner = unwrapInner(schema)\n return inner === undefined ? 'nullable(?)' : `nullable(${recurse(inner)})`\n }\n\n case 'default': {\n const inner = unwrapInner(schema)\n return `default[${stableValueRepr(getDefaultValue, schema)}](${inner === undefined ? '?' : recurse(inner)})`\n }\n\n case 'readonly': {\n const inner = unwrapInner(schema)\n return inner === undefined ? 'readonly(?)' : `readonly(${recurse(inner)})`\n }\n\n case 'pipe': {\n const inner = unwrapPipe(schema)\n return inner === undefined ? 'pipe(?)' : `pipe(${recurse(inner)})`\n }\n\n case 'catch': {\n const inner = unwrapInner(schema)\n return `catch[${stableValueRepr(getCatchDefault, schema)}](${inner === undefined ? '?' : recurse(inner)})`\n }\n\n case 'lazy': {\n // `z.lazy(() => other)` — fingerprint the dereferenced inner.\n // The `inProgress` WeakSet catches real cycles (a schema that\n // references itself through lazy) and returns `cyclicSentinel`\n // for any recursive encounter.\n const inner = unwrapLazy(schema)\n return inner === undefined ? 'lazy(?)' : `lazy(${recurse(inner)})`\n }\n\n case 'intersection': {\n const left = getIntersectionLeft(schema)\n const right = getIntersectionRight(schema)\n const leftFp = left === undefined ? '?' : recurse(left as z.ZodType)\n const rightFp = right === undefined ? '?' : recurse(right as z.ZodType)\n // Intersection members have no semantic order; sort both legs.\n const parts = [leftFp, rightFp].sort()\n return `intersection(${parts.join('&')})`\n }\n\n // Structural shape isn't observable for these. Bucket them into\n // kind-only fingerprints — a schema-mismatch warning can't do\n // better than \"both are `custom`\" here, but that still catches\n // `object` vs `custom` mismatches. `map` / `symbol` / `function`\n // are rejected at adapter construction; kept here for exhaustive\n // switch safety when `fingerprintSchema` is called from tooling.\n case 'promise':\n case 'custom':\n case 'template-literal':\n case 'transform':\n case 'file':\n case 'map':\n case 'symbol':\n case 'function':\n return `${kind}:*`\n\n default: {\n // Exhaustiveness guard — if ZodKind grows a new variant we'll\n // fall through here and get a typecheck-visible warning via\n // the unreachable assignment.\n const _: never = kind\n return `unknown:${String(_)}`\n }\n }\n}\n\n/**\n * Render a default/catch value for the fingerprint. Detects\n * non-deterministic factories (`.default(() => new Date())`) by\n * reading the value twice and comparing — zod v4's getter invokes\n * the factory fresh on each access, so two consecutive reads of a\n * factory-backed default produce distinct objects for any\n * heap-allocated return type. Object.is matches for primitive\n * returns (even from factories) and for literal defaults; in both\n * cases we emit the canonical representation. Without this the\n * fingerprint is non-idempotent for schemas like\n * `.default(() => new Date())`.\n */\nfunction stableValueRepr(get: (s: z.ZodType) => unknown, schema: z.ZodType): string {\n const first = get(schema)\n const second = get(schema)\n if (!Object.is(first, second) || typeof first === 'function') return 'fn:*'\n return canonicalStringify(first)\n}\n\n/**\n * Serialise a check array to a stable string. Checks are sorted by\n * their canonical form so order-of-chain doesn't matter — the zod\n * runtime already collapses `.min(3).max(10)` and `.max(10).min(3)`\n * to the same behaviour, and the fingerprint should match.\n */\nfunction formatChecks(schema: z.ZodType): string {\n const checks = getChecks(schema)\n if (checks.length === 0) return ''\n const parts = checks.map((c) => serializeCheck(c)).sort()\n return `[${parts.join(';')}]`\n}\n\n/**\n * Zod v4 checks are instances of `$ZodCheck` — their state lives on\n * `_zod.def` (kind discriminator + kind-specific args), not on the\n * object's own enumerable properties. A plain `Object.entries`\n * serialise would see an empty object and collapse every check to\n * the same fingerprint — `.min(3)` and `.min(8)` would look\n * identical. Reach into `_zod.def` when it's present; fall back to\n * generic canonicalisation for anything that isn't shaped like a\n * v4 check (custom adapters may pass their own shapes here).\n */\nfunction serializeCheck(check: unknown): string {\n if (check !== null && typeof check === 'object') {\n const def = (check as { _zod?: { def?: unknown } })._zod?.def\n if (def !== undefined) return canonicalStringify(def)\n }\n return canonicalStringify(check)\n}\n\n/** Strict-mode sort comparator that handles mixed string/number enums. */\nfunction compare(a: string | number, b: string | number): number {\n const as = String(a)\n const bs = String(b)\n return as < bs ? -1 : as > bs ? 1 : 0\n}\n"],"names":[],"mappings":";;;AAsEA,MAAM,cAAA,GAAiB,UAAA;AAEhB,SAAS,qBAAqB,MAAA,EAA2B;AAC9D,EAAA,MAAM,KAAA,uBAAY,OAAA,EAA2B;AAC7C,EAAA,MAAM,UAAA,uBAAiB,OAAA,EAAmB;AAC1C,EAAA,OAAO,KAAA,CAAM,MAAA,EAAQ,KAAA,EAAO,UAAU,CAAA;AACxC;AAEA,SAAS,KAAA,CACP,MAAA,EACA,KAAA,EACA,UAAA,EACQ;AACR,EAAA,MAA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odAlias = options.resolveZodAlias !== false;
|
|
7
|
-
const warnState = { warned: false };
|
|
8
|
-
return {
|
|
9
|
-
name: "attaform",
|
|
10
|
-
setup(build) {
|
|
11
|
-
const root = build.initialOptions.absWorkingDir ?? options.root ?? process.cwd();
|
|
12
|
-
const target = detectZodMajor.resolveZodAliasTarget(root, "attaform/esbuild", resolveZodAlias, warnState);
|
|
13
|
-
if (target === null) return;
|
|
14
|
-
build.onResolve({ filter: detectZodMajor.REWRITABLE_ZOD_SPECIFIER_FILTER }, async (args) => {
|
|
15
|
-
const result = await build.resolve(target, {
|
|
16
|
-
kind: args.kind,
|
|
17
|
-
importer: args.importer,
|
|
18
|
-
resolveDir: args.resolveDir
|
|
19
|
-
});
|
|
20
|
-
if (result.errors.length > 0) return { errors: result.errors };
|
|
21
|
-
return { path: result.path, external: result.external, namespace: result.namespace };
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
exports.attaform = attaform;
|
|
28
|
-
//# sourceMappingURL=esbuild.cjs.map
|
package/dist/esbuild.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"esbuild.cjs","sources":["../src/esbuild.ts"],"sourcesContent":["/**\n * `attaform/esbuild` — esbuild plugin that rewrites `attaform` and\n * `attaform/zod` imports to the single matching adapter subpath\n * (`attaform/zod-v3` or `attaform/zod-v4`) at build time, based on the\n * consumer's installed Zod major. Without it, esbuild ships both adapters\n * because those entries import both for runtime dispatch.\n *\n * Usage:\n *\n * // build.mjs\n * import { build } from 'esbuild'\n * import { attaform } from 'attaform/esbuild'\n *\n * await build({\n * entryPoints: ['src/main.ts'],\n * bundle: true,\n * plugins: [attaform()],\n * })\n *\n * This plugin only does the adapter rewrite. The Vue SFC `v-register`\n * transforms that `attaform/vite` wires (load-bearing for SSR initial\n * render) are `@vitejs/plugin-vue`-specific and do not transfer; a\n * non-Vite consumer that needs them wires `attaform/transforms` into\n * their Vue compiler separately.\n *\n * Zero-dep: the plugin imports nothing from `esbuild` (the bundler injects\n * its plugin API at the consumer's build); the structural types below are\n * all it needs to compile.\n */\nimport { resolveZodAliasTarget, REWRITABLE_ZOD_SPECIFIER_FILTER } from './core/detect-zod-major'\n\n/** Options for the esbuild `attaform()` plugin. */\nexport interface AttaformEsbuildPluginOptions {\n /**\n * Rewrite `attaform` and `attaform/zod` imports at build time to the\n * matching adapter subpath. Default `true`. Set to `false` to keep the\n * runtime-dispatch unified entry (ships both adapters).\n */\n resolveZodAlias?: boolean\n /**\n * Project root to resolve the installed Zod from. Defaults to the\n * build's `absWorkingDir`, falling back to `process.cwd()`. Set this\n * when the build runs from a directory other than the project that owns\n * the Zod dependency.\n */\n root?: string\n}\n\ninterface EsbuildOnResolveArgs {\n path: string\n importer: string\n resolveDir: string\n kind: string\n}\ninterface EsbuildResolveResult {\n path: string\n external: boolean\n namespace: string\n errors: unknown[]\n}\ninterface EsbuildOnResolveResult {\n path?: string\n external?: boolean\n namespace?: string\n errors?: unknown[]\n}\ninterface EsbuildPluginBuild {\n initialOptions: { absWorkingDir?: string }\n onResolve(\n options: { filter: RegExp },\n callback: (args: EsbuildOnResolveArgs) => Promise<EsbuildOnResolveResult>\n ): void\n resolve(\n path: string,\n options: { kind: string; importer?: string; resolveDir?: string }\n ): Promise<EsbuildResolveResult>\n}\n\n/** The structural shape esbuild requires of the plugin. */\nexport interface AttaformEsbuildPlugin {\n name: string\n setup(build: EsbuildPluginBuild): void\n}\n\nexport function attaform(options: AttaformEsbuildPluginOptions = {}): AttaformEsbuildPlugin {\n const resolveZodAlias = options.resolveZodAlias !== false\n const warnState = { warned: false }\n return {\n name: 'attaform',\n setup(build) {\n const root = build.initialOptions.absWorkingDir ?? options.root ?? process.cwd()\n const target = resolveZodAliasTarget(root, 'attaform/esbuild', resolveZodAlias, warnState)\n // Nothing to rewrite (opt-out, or unclassifiable version): leave the\n // unified entry in place and register no hook.\n if (target === null) return\n build.onResolve({ filter: REWRITABLE_ZOD_SPECIFIER_FILTER }, async (args) => {\n // Re-resolve the rewritten specifier so esbuild returns a real\n // path. Both matched specifiers (bare `attaform` and\n // `attaform/zod`) rewrite to the same detected adapter; the filter\n // is anchored so resolving `attaform/zod-v4` does not re-enter\n // this callback.\n const result = await build.resolve(target, {\n kind: args.kind,\n importer: args.importer,\n resolveDir: args.resolveDir,\n })\n if (result.errors.length > 0) return { errors: result.errors }\n return { path: result.path, external: result.external, namespace: result.namespace }\n })\n },\n }\n}\n"],"names":["resolveZodAliasTarget","REWRITABLE_ZOD_SPECIFIER_FILTER"],"mappings":";;;;AAoFO,SAAS,QAAA,CAAS,OAAA,GAAwC,EAAC,EAA0B;AAC1F,EAAA,MAAM,eAAA,GAAkB,QAAQ,eAAA,KAAoB,KAAA;AACpD,EAAA,MAAM,SAAA,GAAY,EAAE,MAAA,EAAQ,KAAA,EAAM;AAClC,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,UAAA;AAAA,IACN,MAAM,KAAA,EAAO;AACX,MAAA,MAAM,OAAO,KAAA,CAAM,cAAA,CAAe,iBAAiB,OAAA,CAAQ,IAAA,IAAQ,QAAQ,GAAA,EAAI;AAC/E,MAAA,MAAM,MAAA,GAASA,oCAAA,CAAsB,IAAA,EAAM,kBAAA,EAAoB,iBAAiB,SAAS,CAAA;AAGzF,MAAA,IAAI,WAAW,IAAA,EAAM;AACrB,MAAA,KAAA,CAAM,UAAU,EAAE,MAAA,EAAQC,8CAAA,EAAgC,EAAG,OAAO,IAAA,KAAS;AAM3E,QAAA,MAAM,MAAA,GAAS,MAAM,KAAA,CAAM,OAAA,CAAQ,MAAA,EAAQ;AAAA,UACzC,MAAM,IAAA,CAAK,IAAA;AAAA,UACX,UAAU,IAAA,CAAK,QAAA;AAAA,UACf,YAAY,IAAA,CAAK;AAAA,SAClB,CAAA;AACD,QAAA,IAAI,MAAA,CAAO,OAAO,MAAA,GAAS,CAAA,SAAU,EAAE,MAAA,EAAQ,OAAO,MAAA,EAAO;AAC7D,QAAA,OAAO,EAAE,MAAM,MAAA,CAAO,IAAA,EAAM,UAAU,MAAA,CAAO,QAAA,EAAU,SAAA,EAAW,MAAA,CAAO,SAAA,EAAU;AAAA,MACrF,CAAC,CAAA;AAAA,IACH;AAAA,GACF;AACF;;;;"}
|
package/dist/esbuild.d.cts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/** Options for the esbuild `attaform()` plugin. */
|
|
2
|
-
interface AttaformEsbuildPluginOptions {
|
|
3
|
-
/**
|
|
4
|
-
* Rewrite `attaform` and `attaform/zod` imports at build time to the
|
|
5
|
-
* matching adapter subpath. Default `true`. Set to `false` to keep the
|
|
6
|
-
* runtime-dispatch unified entry (ships both adapters).
|
|
7
|
-
*/
|
|
8
|
-
resolveZodAlias?: boolean;
|
|
9
|
-
/**
|
|
10
|
-
* Project root to resolve the installed Zod from. Defaults to the
|
|
11
|
-
* build's `absWorkingDir`, falling back to `process.cwd()`. Set this
|
|
12
|
-
* when the build runs from a directory other than the project that owns
|
|
13
|
-
* the Zod dependency.
|
|
14
|
-
*/
|
|
15
|
-
root?: string;
|
|
16
|
-
}
|
|
17
|
-
interface EsbuildOnResolveArgs {
|
|
18
|
-
path: string;
|
|
19
|
-
importer: string;
|
|
20
|
-
resolveDir: string;
|
|
21
|
-
kind: string;
|
|
22
|
-
}
|
|
23
|
-
interface EsbuildResolveResult {
|
|
24
|
-
path: string;
|
|
25
|
-
external: boolean;
|
|
26
|
-
namespace: string;
|
|
27
|
-
errors: unknown[];
|
|
28
|
-
}
|
|
29
|
-
interface EsbuildOnResolveResult {
|
|
30
|
-
path?: string;
|
|
31
|
-
external?: boolean;
|
|
32
|
-
namespace?: string;
|
|
33
|
-
errors?: unknown[];
|
|
34
|
-
}
|
|
35
|
-
interface EsbuildPluginBuild {
|
|
36
|
-
initialOptions: {
|
|
37
|
-
absWorkingDir?: string;
|
|
38
|
-
};
|
|
39
|
-
onResolve(options: {
|
|
40
|
-
filter: RegExp;
|
|
41
|
-
}, callback: (args: EsbuildOnResolveArgs) => Promise<EsbuildOnResolveResult>): void;
|
|
42
|
-
resolve(path: string, options: {
|
|
43
|
-
kind: string;
|
|
44
|
-
importer?: string;
|
|
45
|
-
resolveDir?: string;
|
|
46
|
-
}): Promise<EsbuildResolveResult>;
|
|
47
|
-
}
|
|
48
|
-
/** The structural shape esbuild requires of the plugin. */
|
|
49
|
-
interface AttaformEsbuildPlugin {
|
|
50
|
-
name: string;
|
|
51
|
-
setup(build: EsbuildPluginBuild): void;
|
|
52
|
-
}
|
|
53
|
-
declare function attaform(options?: AttaformEsbuildPluginOptions): AttaformEsbuildPlugin;
|
|
54
|
-
|
|
55
|
-
export { attaform };
|
|
56
|
-
export type { AttaformEsbuildPlugin, AttaformEsbuildPluginOptions };
|
package/dist/esbuild.d.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/** Options for the esbuild `attaform()` plugin. */
|
|
2
|
-
interface AttaformEsbuildPluginOptions {
|
|
3
|
-
/**
|
|
4
|
-
* Rewrite `attaform` and `attaform/zod` imports at build time to the
|
|
5
|
-
* matching adapter subpath. Default `true`. Set to `false` to keep the
|
|
6
|
-
* runtime-dispatch unified entry (ships both adapters).
|
|
7
|
-
*/
|
|
8
|
-
resolveZodAlias?: boolean;
|
|
9
|
-
/**
|
|
10
|
-
* Project root to resolve the installed Zod from. Defaults to the
|
|
11
|
-
* build's `absWorkingDir`, falling back to `process.cwd()`. Set this
|
|
12
|
-
* when the build runs from a directory other than the project that owns
|
|
13
|
-
* the Zod dependency.
|
|
14
|
-
*/
|
|
15
|
-
root?: string;
|
|
16
|
-
}
|
|
17
|
-
interface EsbuildOnResolveArgs {
|
|
18
|
-
path: string;
|
|
19
|
-
importer: string;
|
|
20
|
-
resolveDir: string;
|
|
21
|
-
kind: string;
|
|
22
|
-
}
|
|
23
|
-
interface EsbuildResolveResult {
|
|
24
|
-
path: string;
|
|
25
|
-
external: boolean;
|
|
26
|
-
namespace: string;
|
|
27
|
-
errors: unknown[];
|
|
28
|
-
}
|
|
29
|
-
interface EsbuildOnResolveResult {
|
|
30
|
-
path?: string;
|
|
31
|
-
external?: boolean;
|
|
32
|
-
namespace?: string;
|
|
33
|
-
errors?: unknown[];
|
|
34
|
-
}
|
|
35
|
-
interface EsbuildPluginBuild {
|
|
36
|
-
initialOptions: {
|
|
37
|
-
absWorkingDir?: string;
|
|
38
|
-
};
|
|
39
|
-
onResolve(options: {
|
|
40
|
-
filter: RegExp;
|
|
41
|
-
}, callback: (args: EsbuildOnResolveArgs) => Promise<EsbuildOnResolveResult>): void;
|
|
42
|
-
resolve(path: string, options: {
|
|
43
|
-
kind: string;
|
|
44
|
-
importer?: string;
|
|
45
|
-
resolveDir?: string;
|
|
46
|
-
}): Promise<EsbuildResolveResult>;
|
|
47
|
-
}
|
|
48
|
-
/** The structural shape esbuild requires of the plugin. */
|
|
49
|
-
interface AttaformEsbuildPlugin {
|
|
50
|
-
name: string;
|
|
51
|
-
setup(build: EsbuildPluginBuild): void;
|
|
52
|
-
}
|
|
53
|
-
declare function attaform(options?: AttaformEsbuildPluginOptions): AttaformEsbuildPlugin;
|
|
54
|
-
|
|
55
|
-
export { attaform };
|
|
56
|
-
export type { AttaformEsbuildPlugin, AttaformEsbuildPluginOptions };
|
package/dist/esbuild.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"esbuild.mjs","sources":["../src/esbuild.ts"],"sourcesContent":["/**\n * `attaform/esbuild` — esbuild plugin that rewrites `attaform` and\n * `attaform/zod` imports to the single matching adapter subpath\n * (`attaform/zod-v3` or `attaform/zod-v4`) at build time, based on the\n * consumer's installed Zod major. Without it, esbuild ships both adapters\n * because those entries import both for runtime dispatch.\n *\n * Usage:\n *\n * // build.mjs\n * import { build } from 'esbuild'\n * import { attaform } from 'attaform/esbuild'\n *\n * await build({\n * entryPoints: ['src/main.ts'],\n * bundle: true,\n * plugins: [attaform()],\n * })\n *\n * This plugin only does the adapter rewrite. The Vue SFC `v-register`\n * transforms that `attaform/vite` wires (load-bearing for SSR initial\n * render) are `@vitejs/plugin-vue`-specific and do not transfer; a\n * non-Vite consumer that needs them wires `attaform/transforms` into\n * their Vue compiler separately.\n *\n * Zero-dep: the plugin imports nothing from `esbuild` (the bundler injects\n * its plugin API at the consumer's build); the structural types below are\n * all it needs to compile.\n */\nimport { resolveZodAliasTarget, REWRITABLE_ZOD_SPECIFIER_FILTER } from './core/detect-zod-major'\n\n/** Options for the esbuild `attaform()` plugin. */\nexport interface AttaformEsbuildPluginOptions {\n /**\n * Rewrite `attaform` and `attaform/zod` imports at build time to the\n * matching adapter subpath. Default `true`. Set to `false` to keep the\n * runtime-dispatch unified entry (ships both adapters).\n */\n resolveZodAlias?: boolean\n /**\n * Project root to resolve the installed Zod from. Defaults to the\n * build's `absWorkingDir`, falling back to `process.cwd()`. Set this\n * when the build runs from a directory other than the project that owns\n * the Zod dependency.\n */\n root?: string\n}\n\ninterface EsbuildOnResolveArgs {\n path: string\n importer: string\n resolveDir: string\n kind: string\n}\ninterface EsbuildResolveResult {\n path: string\n external: boolean\n namespace: string\n errors: unknown[]\n}\ninterface EsbuildOnResolveResult {\n path?: string\n external?: boolean\n namespace?: string\n errors?: unknown[]\n}\ninterface EsbuildPluginBuild {\n initialOptions: { absWorkingDir?: string }\n onResolve(\n options: { filter: RegExp },\n callback: (args: EsbuildOnResolveArgs) => Promise<EsbuildOnResolveResult>\n ): void\n resolve(\n path: string,\n options: { kind: string; importer?: string; resolveDir?: string }\n ): Promise<EsbuildResolveResult>\n}\n\n/** The structural shape esbuild requires of the plugin. */\nexport interface AttaformEsbuildPlugin {\n name: string\n setup(build: EsbuildPluginBuild): void\n}\n\nexport function attaform(options: AttaformEsbuildPluginOptions = {}): AttaformEsbuildPlugin {\n const resolveZodAlias = options.resolveZodAlias !== false\n const warnState = { warned: false }\n return {\n name: 'attaform',\n setup(build) {\n const root = build.initialOptions.absWorkingDir ?? options.root ?? process.cwd()\n const target = resolveZodAliasTarget(root, 'attaform/esbuild', resolveZodAlias, warnState)\n // Nothing to rewrite (opt-out, or unclassifiable version): leave the\n // unified entry in place and register no hook.\n if (target === null) return\n build.onResolve({ filter: REWRITABLE_ZOD_SPECIFIER_FILTER }, async (args) => {\n // Re-resolve the rewritten specifier so esbuild returns a real\n // path. Both matched specifiers (bare `attaform` and\n // `attaform/zod`) rewrite to the same detected adapter; the filter\n // is anchored so resolving `attaform/zod-v4` does not re-enter\n // this callback.\n const result = await build.resolve(target, {\n kind: args.kind,\n importer: args.importer,\n resolveDir: args.resolveDir,\n })\n if (result.errors.length > 0) return { errors: result.errors }\n return { path: result.path, external: result.external, namespace: result.namespace }\n })\n },\n }\n}\n"],"names":[],"mappings":";;AAoFO,SAAS,QAAA,CAAS,OAAA,GAAwC,EAAC,EAA0B;AAC1F,EAAA,MAAM,eAAA,GAAkB,QAAQ,eAAA,KAAoB,KAAA;AACpD,EAAA,MAAM,SAAA,GAAY,EAAE,MAAA,EAAQ,KAAA,EAAM;AAClC,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,UAAA;AAAA,IACN,MAAM,KAAA,EAAO;AACX,MAAA,MAAM,OAAO,KAAA,CAAM,cAAA,CAAe,iBAAiB,OAAA,CAAQ,IAAA,IAAQ,QAAQ,GAAA,EAAI;AAC/E,MAAA,MAAM,MAAA,GAAS,qBAAA,CAAsB,IAAA,EAAM,kBAAA,EAAoB,iBAAiB,SAAS,CAAA;AAGzF,MAAA,IAAI,WAAW,IAAA,EAAM;AACrB,MAAA,KAAA,CAAM,UAAU,EAAE,MAAA,EAAQ,+BAAA,EAAgC,EAAG,OAAO,IAAA,KAAS;AAM3E,QAAA,MAAM,MAAA,GAAS,MAAM,KAAA,CAAM,OAAA,CAAQ,MAAA,EAAQ;AAAA,UACzC,MAAM,IAAA,CAAK,IAAA;AAAA,UACX,UAAU,IAAA,CAAK,QAAA;AAAA,UACf,YAAY,IAAA,CAAK;AAAA,SAClB,CAAA;AACD,QAAA,IAAI,MAAA,CAAO,OAAO,MAAA,GAAS,CAAA,SAAU,EAAE,MAAA,EAAQ,OAAO,MAAA,EAAO;AAC7D,QAAA,OAAO,EAAE,MAAM,MAAA,CAAO,IAAA,EAAM,UAAU,MAAA,CAAO,QAAA,EAAU,SAAA,EAAW,MAAA,CAAO,SAAA,EAAU;AAAA,MACrF,CAAC,CAAA;AAAA,IACH;AAAA,GACF;AACF;;;;"}
|
package/dist/index.cjs
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const devtoolsShared = require('./shared/attaform.Biytrv0-.cjs');
|
|
4
|
-
const serializeScript = require('./shared/attaform.Cg1rUfcF.cjs');
|
|
5
|
-
const fieldMeta = require('./shared/attaform.CF-EnyJn.cjs');
|
|
6
|
-
const registerProtocol = require('./shared/attaform.yUrz7C2z.cjs');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
exports.AttaformError = devtoolsShared.AttaformError;
|
|
11
|
-
exports.DEVTOOLS_WINDOW_KEY = devtoolsShared.DEVTOOLS_WINDOW_KEY;
|
|
12
|
-
exports.InvalidPathError = devtoolsShared.InvalidPathError;
|
|
13
|
-
exports.InvalidUseFormConfigError = devtoolsShared.InvalidUseFormConfigError;
|
|
14
|
-
exports.OutsideSetupError = devtoolsShared.OutsideSetupError;
|
|
15
|
-
exports.ROOT_PATH = devtoolsShared.ROOT_PATH;
|
|
16
|
-
exports.ROOT_PATH_KEY = devtoolsShared.ROOT_PATH_KEY;
|
|
17
|
-
exports.RegistryNotInstalledError = devtoolsShared.RegistryNotInstalledError;
|
|
18
|
-
exports.ReservedFormKeyError = devtoolsShared.ReservedFormKeyError;
|
|
19
|
-
exports.SubmitErrorHandlerError = devtoolsShared.SubmitErrorHandlerError;
|
|
20
|
-
exports.assignKey = devtoolsShared.assignKey;
|
|
21
|
-
exports.canonicalizePath = devtoolsShared.canonicalizePath;
|
|
22
|
-
exports.createAttaform = devtoolsShared.createAttaform;
|
|
23
|
-
exports.createRegistry = devtoolsShared.createRegistry;
|
|
24
|
-
exports.getRegistryFromApp = devtoolsShared.getRegistryFromApp;
|
|
25
|
-
exports.hydrateAttaformState = devtoolsShared.hydrateAttaformState;
|
|
26
|
-
exports.isPathPrefix = devtoolsShared.isPathPrefix;
|
|
27
|
-
exports.kAttaformRegistry = devtoolsShared.kAttaformRegistry;
|
|
28
|
-
exports.parseDottedPath = devtoolsShared.parseDottedPath;
|
|
29
|
-
exports.renderAttaformState = devtoolsShared.renderAttaformState;
|
|
30
|
-
exports.useRegistry = devtoolsShared.useRegistry;
|
|
31
|
-
exports.vRegister = devtoolsShared.vRegister;
|
|
32
|
-
exports.AttaformErrorCode = serializeScript.AttaformErrorCode;
|
|
33
|
-
exports.DEFAULT_TIMINGS = serializeScript.DEFAULT_TIMINGS;
|
|
34
|
-
exports.defaultCoercionRules = serializeScript.defaultCoercionRules;
|
|
35
|
-
exports.defaultDisplayState = serializeScript.defaultDisplayState;
|
|
36
|
-
exports.defineCoercion = serializeScript.defineCoercion;
|
|
37
|
-
exports.escapeForInlineScript = serializeScript.escapeForInlineScript;
|
|
38
|
-
exports.gate = serializeScript.gate;
|
|
39
|
-
exports.injectForm = serializeScript.injectForm;
|
|
40
|
-
exports.injectWizard = serializeScript.injectWizard;
|
|
41
|
-
exports.isUnset = serializeScript.isUnset;
|
|
42
|
-
exports.lazy = serializeScript.lazy;
|
|
43
|
-
exports.makeDefaultDisplayState = serializeScript.makeDefaultDisplayState;
|
|
44
|
-
exports.unset = serializeScript.unset;
|
|
45
|
-
exports.useRegister = serializeScript.useRegister;
|
|
46
|
-
exports.useWizard = serializeScript.useWizard;
|
|
47
|
-
exports.fieldMeta = fieldMeta.fieldMeta;
|
|
48
|
-
exports.useForm = fieldMeta.useForm;
|
|
49
|
-
exports.withMeta = fieldMeta.withMeta;
|
|
50
|
-
exports.isRegisterValue = registerProtocol.isRegisterValue;
|
|
51
|
-
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.d.cts
DELETED
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
export { a as AnyForm, b as AttaformDevtoolsBridge, c as AttaformError, d as AttaformErrorCode, e as AttaformPluginOptions, A as AttaformRegistry, C as CompiledStep, D as DEFAULT_TIMINGS, f as DEVTOOLS_WINDOW_KEY, g as DisplayTimings, F as FormStatus, h as FormStatusSeed, G as GateMarker, I as InjectWizardInput, i as InvalidPathError, j as InvalidUseFormConfigError, L as LazyMarker, O as OutsideSetupError, R as RegistryNotInstalledError, k as ReservedFormKeyError, S as SerializedAttaformState, l as SerializedFormData, m as StepSlot, n as SubmitErrorHandlerError, U as UseRegisterReturn, o as UseWizardReturnType, W as WizardAggregateError, p as WizardCtx, q as WizardCtxForm, r as WizardOnError, s as WizardOnSubmit, t as WizardOptions, u as WizardPersistFn, v as WizardRestoreFn, w as WizardRestoreState, x as WizardStatusesProxy, y as WizardSubmitContext, z as assignKey, B as createAttaform, E as createRegistry, H as defaultCoercionRules, J as defaultDisplayState, K as defineCoercion, M as escapeForInlineScript, N as gate, P as getRegistryFromApp, Q as hydrateAttaformState, T as injectForm, V as injectWizard, X as isRegisterValue, Y as kAttaformRegistry, Z as lazy, _ as makeDefaultDisplayState, $ as renderAttaformState, a0 as useRegister, a1 as useRegistry, a2 as useWizard, a3 as vRegister } from './shared/attaform.B3abZaCV.cjs';
|
|
2
|
-
import { G as GenericForm, F as FormKey, U as UseFormConfiguration, A as AbstractSchema, aq as AcceptableDefaults, ae as ValidateOnConfig, a as UseFormReturnType, D as DefaultValuesInput, o as FieldMetaPayload } from './shared/attaform.CzL2CZ8U.cjs';
|
|
3
|
-
export { b as ArrayItem, c as ArrayPath, d as AttaformDefaults, C as CoercionEntry, e as CoercionRegistry, f as CoercionResult, g as CustomDirectiveRegisterAssignerFn, h as DeepPartial, i as DefaultValuesResponse, j as DefaultValuesShape, k as DisplayCtx, l as DisplayMachine, m as DisplayState, E as ErrorInput, n as ErrorsProxyShape, p as FieldState, q as FieldStateMap, r as FieldStateMapEntry, s as FlatPath, t as FormErrorRecord, u as FormErrorsSurface, v as FormMeta, w as GetDisplayState, H as HandleSubmit, x as HistoryConfig, I as IsTuple, y as IsUnion, J as JoinSegments, z as Json, K as KeyofUnion, L as LiftedValueShape, M as MetaTrackerValue, N as NestedReadType, B as NestedType, O as OnError, P as OnInvalidSubmitPolicy, Q as OnSubmit, R as PartialFlatPath, S as Path, T as PathKey, V as PendingValidationStatus, W as Primitive, X as ROOT_PATH, Y as ROOT_PATH_KEY, Z as ReactiveValidationStatus, _ as RegisterDirective, $ as RegisterFlatPath, a0 as RegisterOptions, a1 as RegisterSelectModifier, a2 as RegisterTextModifier, a3 as RegisterTransform, a4 as RegisterValue, a5 as Segment, a6 as SetValueCallback, a7 as SetValuePayload, a8 as SettledValidationStatus, a9 as SlimPrimitiveKind, aa as SlimRuntimeOf, ab as SubmitHandler, ac as Unset, ad as ValidateOn, af as ValidationError, ag as ValidationResponse, ah as ValidationResponseWithoutValue, ai as ValueOfUnion, aj as WriteMeta, ak as WriteShape, al as canonicalizePath, am as isPathPrefix, an as isUnset, ao as parseDottedPath, ap as unset } from './shared/attaform.CzL2CZ8U.cjs';
|
|
4
|
-
import { S as SupportedRootSchema, b as StorageShape } from './shared/attaform.DYwyM5Cp.cjs';
|
|
5
|
-
export { P as PathInput, a as PathOutput } from './shared/attaform.DYwyM5Cp.cjs';
|
|
6
|
-
import { S as SupportedRootSchema$1, U as UnwrapZodRoot, a as StorageShape$1 } from './shared/attaform.DRUT703x.cjs';
|
|
7
|
-
import { z } from 'zod';
|
|
8
|
-
import 'vue';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Type-level Zod-major discriminator for the unified `attaform/zod`
|
|
12
|
-
* entry. The runtime dispatch (`use-form.ts`'s impl) already routes on
|
|
13
|
-
* the schema's shape via `isZodV4SchemaShape`; this is the type-level
|
|
14
|
-
* mirror so the overloads and projection helpers discriminate the same
|
|
15
|
-
* way.
|
|
16
|
-
*
|
|
17
|
-
* Why a structural marker instead of `z.ZodObject`: the unified entry's
|
|
18
|
-
* overloads constrain on `z.ZodObject`, but the published `.d.mts`
|
|
19
|
-
* resolves `z` against whichever single Zod major the consumer
|
|
20
|
-
* installed. In a v3-only install `z.ZodObject` is v3's `ZodObject`
|
|
21
|
-
* (and, lacking its required type arguments, degrades to an `any`-like
|
|
22
|
-
* error type under `skipLibCheck`), so a v3 schema satisfies the v4
|
|
23
|
-
* overload's constraint and binds it — collapsing the read slot to
|
|
24
|
-
* `never`. A Zod v4 schema carries the `_zod` internals brand; a v3
|
|
25
|
-
* schema never does.
|
|
26
|
-
* Intersecting a v4-only constraint or conditional branch with this
|
|
27
|
-
* marker keeps it unreachable for a v3 schema regardless of how `zod`
|
|
28
|
-
* resolves, so v3 schemas fall through to the v3 overload.
|
|
29
|
-
*
|
|
30
|
-
* Distinct from `core/zod-shape.ts`'s runtime `ZodV4Shape` (which reads
|
|
31
|
-
* the public `def` getter): at the type level the stable v4 brand is
|
|
32
|
-
* `_zod.def`, the same internals `StorageShape` (v4) already reads.
|
|
33
|
-
*
|
|
34
|
-
* Pairing requirement: a v4 overload/branch must constrain on
|
|
35
|
-
* `z.ZodObject<z.ZodRawShape> & ZodV4Internals`, NOT bare
|
|
36
|
-
* `z.ZodObject & ZodV4Internals`. In a v3-only install `z.ZodObject`
|
|
37
|
-
* with no type argument is `ZodObject<T, ...>` missing its required
|
|
38
|
-
* arguments — an error type that behaves like `any` under
|
|
39
|
-
* `skipLibCheck`, so `any & ZodV4Internals` collapses back to `any` and
|
|
40
|
-
* the marker stops excluding v3 schemas. Supplying `z.ZodRawShape`
|
|
41
|
-
* keeps it a concrete object type in both majors, so the intersection
|
|
42
|
-
* stays meaningful.
|
|
43
|
-
*/
|
|
44
|
-
type ZodV4Internals = {
|
|
45
|
-
_zod: {
|
|
46
|
-
def: unknown;
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Per-major projection helpers shared by the unified `attaform/zod`
|
|
52
|
-
* entry. Each maps an arbitrary Zod v4 OR v3 object schema to the
|
|
53
|
-
* `GenericForm`-shaped input / output / storage-read projections the
|
|
54
|
-
* form types are parameterised over. The constraint on each alias scopes
|
|
55
|
-
* `S` to one Zod major, so the projection is a direct read with no
|
|
56
|
-
* dispatch in the type body.
|
|
57
|
-
*
|
|
58
|
-
* Hoisted out of `types-unified.ts` and `use-form.ts` so the two entry
|
|
59
|
-
* points share one definition. Internal — consumer code never reaches
|
|
60
|
-
* for these; the overloaded `useForm` already gives full inference at
|
|
61
|
-
* call sites.
|
|
62
|
-
*/
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* The schema's own input type, exactly as a consumer would reference it
|
|
66
|
-
* (`z.input<S>`) — NOT routed through `GenericForm` / `UnwrapZodRoot`. This
|
|
67
|
-
* is the reflexive escape arm `AcceptableDefaults` adds to the
|
|
68
|
-
* `defaultValues` slot so a generic form wrapper forwarding `z.input<S>`
|
|
69
|
-
* type-checks under a free `S` (#422). It must stay syntactically identical
|
|
70
|
-
* to what the wrapper forwards: wrapping it in a conditional makes it a
|
|
71
|
-
* deferred conditional that no longer matches the forwarded value under a
|
|
72
|
-
* generic. Wrong-major schemas can't actually bind the slot — they are
|
|
73
|
-
* rejected at the overload's `schema` constraint — so the raw input never
|
|
74
|
-
* widens the slot for the wrong major.
|
|
75
|
-
*/
|
|
76
|
-
type V4SchemaInput<S extends SupportedRootSchema> = z.input<S>;
|
|
77
|
-
type V3SchemaInput<S extends SupportedRootSchema$1> = z.input<S>;
|
|
78
|
-
type V4FormOf<S extends SupportedRootSchema> = z.input<S> extends GenericForm ? z.input<S> : never;
|
|
79
|
-
type V4OutOf<S extends SupportedRootSchema> = z.output<S> extends GenericForm ? z.output<S> : never;
|
|
80
|
-
type V4ReadOf<S extends SupportedRootSchema> = StorageShape<S> extends GenericForm ? StorageShape<S> : never;
|
|
81
|
-
type V3FormOf<S extends SupportedRootSchema$1> = z.input<UnwrapZodRoot<S>> extends GenericForm ? z.input<UnwrapZodRoot<S>> : never;
|
|
82
|
-
type V3OutOf<S extends SupportedRootSchema$1> = z.output<UnwrapZodRoot<S>> extends GenericForm ? z.output<UnwrapZodRoot<S>> : never;
|
|
83
|
-
type V3ReadOf<S extends SupportedRootSchema$1> = StorageShape$1<UnwrapZodRoot<S>> extends GenericForm ? StorageShape$1<UnwrapZodRoot<S>> : never;
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Create a form bound to a Zod v4 schema.
|
|
87
|
-
*
|
|
88
|
-
* ```ts
|
|
89
|
-
* import { useForm } from 'attaform/zod'
|
|
90
|
-
* import { z } from 'zod'
|
|
91
|
-
*
|
|
92
|
-
* const form = useForm({
|
|
93
|
-
* schema: z.object({
|
|
94
|
-
* username: z.string().min(2, 'At least 2 characters'),
|
|
95
|
-
* password: z.string().min(8, 'At least 8 characters'),
|
|
96
|
-
* }),
|
|
97
|
-
* })
|
|
98
|
-
* ```
|
|
99
|
-
*
|
|
100
|
-
* The constraint intersects `ZodV4Internals` (the v4-only `_zod`
|
|
101
|
-
* brand) so a v3 schema can't bind this overload even when `z`
|
|
102
|
-
* resolves to v3 in a single-major consumer install; v3 schemas fall
|
|
103
|
-
* through to the v3 overload below. See `types-zod-major.ts`.
|
|
104
|
-
*/
|
|
105
|
-
declare function useForm<Schema extends SupportedRootSchema & ZodV4Internals, K extends FormKey = FormKey>(configuration: Omit<UseFormConfiguration<V4FormOf<Schema>, V4OutOf<Schema>, AbstractSchema<V4FormOf<Schema>, V4OutOf<Schema>>, never, K>, 'schema' | 'validateOn' | 'debounceMs' | 'defaultValues'> & {
|
|
106
|
-
schema: Schema;
|
|
107
|
-
defaultValues?: AcceptableDefaults<V4FormOf<Schema>, V4SchemaInput<Schema>>;
|
|
108
|
-
} & ValidateOnConfig): UseFormReturnType<V4FormOf<Schema>, V4OutOf<Schema>, V4ReadOf<Schema>, K>;
|
|
109
|
-
/**
|
|
110
|
-
* Create a form bound to a Zod v3 schema.
|
|
111
|
-
*
|
|
112
|
-
* ```ts
|
|
113
|
-
* import { useForm } from 'attaform/zod'
|
|
114
|
-
* import { z } from 'zod-v3'
|
|
115
|
-
*
|
|
116
|
-
* const form = useForm({
|
|
117
|
-
* schema: z.object({
|
|
118
|
-
* username: z.string().min(2, 'At least 2 characters'),
|
|
119
|
-
* password: z.string().min(8, 'At least 8 characters'),
|
|
120
|
-
* }),
|
|
121
|
-
* })
|
|
122
|
-
* ```
|
|
123
|
-
*
|
|
124
|
-
* v3 schemas match this overload; v4 schemas hit the v4 overload
|
|
125
|
-
* above first and never reach here.
|
|
126
|
-
*/
|
|
127
|
-
declare function useForm<Schema extends SupportedRootSchema$1, K extends FormKey = FormKey>(configuration: Omit<UseFormConfiguration<V3FormOf<Schema>, V3OutOf<Schema>, AbstractSchema<V3FormOf<Schema>, V3OutOf<Schema>>, never, K>, 'schema' | 'validateOn' | 'debounceMs' | 'defaultValues'> & {
|
|
128
|
-
schema: Schema;
|
|
129
|
-
defaultValues?: AcceptableDefaults<V3FormOf<Schema>, V3SchemaInput<Schema>>;
|
|
130
|
-
} & ValidateOnConfig): UseFormReturnType<V3FormOf<Schema>, V3OutOf<Schema>, V3ReadOf<Schema>, K>;
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Type-level helpers for the unified `attaform/zod` entry. These give
|
|
134
|
-
* tests and other type-query call sites a deterministic projection
|
|
135
|
-
* over an arbitrary v4 OR v3 schema, sidestepping the brittle
|
|
136
|
-
* instantiation-expression resolution rules TypeScript applies to
|
|
137
|
-
* overloaded functions (`typeof useForm<X>` can pick the wrong
|
|
138
|
-
* overload or the impl signature, depending on whether the type
|
|
139
|
-
* argument is a concrete schema, a generic, or a constraint).
|
|
140
|
-
*
|
|
141
|
-
* The helpers dispatch ONCE per use site via a binary conditional —
|
|
142
|
-
* no stacking, no amplification across the return type. Equivalent
|
|
143
|
-
* to writing `ReturnType<typeof useForm<S>>` but cache-stable across
|
|
144
|
-
* call patterns.
|
|
145
|
-
*
|
|
146
|
-
* Per `inference-first DX`, these helpers are test- and
|
|
147
|
-
* internal-facing. Consumer code shouldn't reach for them — the
|
|
148
|
-
* overloaded `useForm` already gives full inference at call sites.
|
|
149
|
-
*/
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Direct V4 projection — no major-dispatch. Use when the schema's
|
|
153
|
-
* Zod major is known statically (typical for V4 generic helpers like
|
|
154
|
-
* `function setup<S extends z.ZodObject>(s: S)`). TS simplifies the
|
|
155
|
-
* helper cleanly under generic constraints because no conditional
|
|
156
|
-
* is present.
|
|
157
|
-
*/
|
|
158
|
-
type UseFormReturnV4<Schema extends z.ZodObject, K extends FormKey = FormKey> = UseFormReturnType<V4FormOf<Schema>, V4OutOf<Schema>, V4ReadOf<Schema>, K>;
|
|
159
|
-
/**
|
|
160
|
-
* Direct V4 configuration projection. Mirrors `UseFormReturnV4`.
|
|
161
|
-
*/
|
|
162
|
-
type UseFormConfigV4<Schema extends z.ZodObject, K extends FormKey = FormKey> = Omit<UseFormConfiguration<V4FormOf<Schema>, V4OutOf<Schema>, AbstractSchema<V4FormOf<Schema>, V4OutOf<Schema>>, DefaultValuesInput<V4FormOf<Schema>>, K>, 'schema' | 'validateOn' | 'debounceMs'> & {
|
|
163
|
-
schema: Schema;
|
|
164
|
-
} & ValidateOnConfig;
|
|
165
|
-
/**
|
|
166
|
-
* Direct V3 projection — no major-dispatch. Use when the schema's
|
|
167
|
-
* Zod major is known statically.
|
|
168
|
-
*/
|
|
169
|
-
type UseFormReturnV3<Schema extends z.ZodObject<z.ZodRawShape>, K extends FormKey = FormKey> = UseFormReturnType<V3FormOf<Schema>, V3OutOf<Schema>, V3ReadOf<Schema>, K>;
|
|
170
|
-
/**
|
|
171
|
-
* Direct V3 configuration projection. Mirrors `UseFormReturnV3`.
|
|
172
|
-
*/
|
|
173
|
-
type UseFormConfigV3<Schema extends z.ZodObject<z.ZodRawShape>, K extends FormKey = FormKey> = Omit<UseFormConfiguration<V3FormOf<Schema>, V3OutOf<Schema>, AbstractSchema<V3FormOf<Schema>, V3OutOf<Schema>>, DefaultValuesInput<V3FormOf<Schema>>, K>, 'schema' | 'validateOn' | 'debounceMs'> & {
|
|
174
|
-
schema: Schema;
|
|
175
|
-
} & ValidateOnConfig;
|
|
176
|
-
/**
|
|
177
|
-
* The return shape of `useForm` for a given Zod schema. Dispatches
|
|
178
|
-
* once on the schema's major version and projects to the matching
|
|
179
|
-
* adapter's `Form` / `Out` / `Read` slots. The dispatch matches the
|
|
180
|
-
* full `SupportedRootSchema` per major, so an object, record, or
|
|
181
|
-
* discriminated-union root all resolve here exactly as the runtime
|
|
182
|
-
* `useForm` overloads accept them.
|
|
183
|
-
*
|
|
184
|
-
* Replaces `ReturnType<typeof useForm<Schema, K>>` in test code with
|
|
185
|
-
* concrete schemas. For generic helpers (`<S extends z.ZodObject>`),
|
|
186
|
-
* use `UseFormReturnV4<S>` directly — TS doesn't simplify
|
|
187
|
-
* conditional types under generic constraints, so the dispatch in
|
|
188
|
-
* this helper stays deferred and TS can't prove return-type
|
|
189
|
-
* compatibility.
|
|
190
|
-
*/
|
|
191
|
-
type UseFormReturn<Schema, K extends FormKey = FormKey> = Schema extends SupportedRootSchema & ZodV4Internals ? UseFormReturnType<V4FormOf<Schema>, V4OutOf<Schema>, V4ReadOf<Schema>, K> : Schema extends SupportedRootSchema$1 ? UseFormReturnType<V3FormOf<Schema>, V3OutOf<Schema>, V3ReadOf<Schema>, K> : never;
|
|
192
|
-
/**
|
|
193
|
-
* The configuration parameter shape of `useForm` for a given Zod
|
|
194
|
-
* schema. Mirrors `UseFormReturn`'s dispatch — replaces
|
|
195
|
-
* `Parameters<typeof useForm<Schema, K>>[0]` in test code.
|
|
196
|
-
*/
|
|
197
|
-
type UseFormConfig<Schema, K extends FormKey = FormKey> = Schema extends SupportedRootSchema & ZodV4Internals ? Omit<UseFormConfiguration<V4FormOf<Schema>, V4OutOf<Schema>, AbstractSchema<V4FormOf<Schema>, V4OutOf<Schema>>, DefaultValuesInput<V4FormOf<Schema>>, K>, 'schema' | 'validateOn' | 'debounceMs'> & {
|
|
198
|
-
schema: Schema;
|
|
199
|
-
} & ValidateOnConfig : Schema extends SupportedRootSchema$1 ? Omit<UseFormConfiguration<V3FormOf<Schema>, V3OutOf<Schema>, AbstractSchema<V3FormOf<Schema>, V3OutOf<Schema>>, DefaultValuesInput<V3FormOf<Schema>>, K>, 'schema' | 'validateOn' | 'debounceMs'> & {
|
|
200
|
-
schema: Schema;
|
|
201
|
-
} & ValidateOnConfig : never;
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* Field-metadata write/read API for the unified `attaform/zod` entry.
|
|
205
|
-
*
|
|
206
|
-
* Storage is shared with both adapters via `field-meta-store` — a
|
|
207
|
-
* payload written here is visible to whichever adapter the unified
|
|
208
|
-
* `useForm` dispatches to at runtime, regardless of Zod major. No
|
|
209
|
-
* `zod` runtime import; the type-only `import type` is erased at
|
|
210
|
-
* build, so `attaform/zod` carries no `z.registry` reference even
|
|
211
|
-
* when consumed by a Zod 3 project without the Vite plugin alias.
|
|
212
|
-
*
|
|
213
|
-
* The native v4 chain `schema.register(fieldMeta, payload)` continues
|
|
214
|
-
* to work — Zod 4's `.register()` only calls `.add(this, payload)`
|
|
215
|
-
* structurally, satisfied by the shared store.
|
|
216
|
-
*/
|
|
217
|
-
|
|
218
|
-
type ZodFieldMetaRegistry = ReturnType<typeof z.registry<FieldMetaPayload>>;
|
|
219
|
-
/**
|
|
220
|
-
* The shared registry every Attaform-aware Zod schema can register
|
|
221
|
-
* field metadata against, regardless of major. Same instance the v3
|
|
222
|
-
* and v4 adapter entries expose — write in one place, read from
|
|
223
|
-
* any.
|
|
224
|
-
*
|
|
225
|
-
* Cast to Zod 4's `$ZodRegistry<FieldMetaPayload>` so the native
|
|
226
|
-
* `schema.register(fieldMeta, payload)` chain type-checks for v4
|
|
227
|
-
* users; the runtime call only needs `.add` structurally, which the
|
|
228
|
-
* shared store provides.
|
|
229
|
-
*/
|
|
230
|
-
declare const fieldMeta: ZodFieldMetaRegistry;
|
|
231
|
-
/**
|
|
232
|
-
* Attach `payload` to `schema` in the shared registry and return a
|
|
233
|
-
* clone of `schema` so each call gets its own identity (the registry
|
|
234
|
-
* keys on schema reference, so cloning prevents last-write-wins
|
|
235
|
-
* collisions for sub-schemas reused at multiple paths).
|
|
236
|
-
*
|
|
237
|
-
* Works on both Zod 3 and Zod 4 schemas — branches on the runtime
|
|
238
|
-
* shape of the schema:
|
|
239
|
-
* - Zod 4 schemas expose a public `.clone()` method; we call it.
|
|
240
|
-
* - Zod 3 schemas don't, so we reconstruct via
|
|
241
|
-
* `new schema.constructor(schema._def)`.
|
|
242
|
-
*
|
|
243
|
-
* Both forms produce a fresh schema with the same effective
|
|
244
|
-
* structure, so the registry slot is unique to this call site.
|
|
245
|
-
*/
|
|
246
|
-
declare function withMeta<S>(schema: S, payload: FieldMetaPayload): S;
|
|
247
|
-
|
|
248
|
-
export { DefaultValuesInput, FieldMetaPayload, FormKey, GenericForm, UseFormConfiguration, UseFormReturnType, ValidateOnConfig, fieldMeta, useForm, withMeta };
|
|
249
|
-
export type { UseFormConfig, UseFormConfigV3, UseFormConfigV4, UseFormReturn, UseFormReturnV3, UseFormReturnV4 };
|