attaform 0.26.0 → 0.27.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.
- package/README.md +21 -11
- package/bin/attaform.mjs +125 -0
- package/dist/abstract.cjs +47 -0
- package/dist/abstract.cjs.map +1 -0
- package/dist/abstract.d.cts +42 -0
- package/dist/abstract.d.mts +42 -0
- package/dist/abstract.d.ts +42 -0
- package/dist/abstract.mjs +4 -0
- package/dist/abstract.mjs.map +1 -0
- package/dist/chunks/devtools.cjs +2 -2
- package/dist/chunks/devtools.cjs.map +1 -1
- package/dist/chunks/devtools.mjs +1 -1
- package/dist/chunks/fingerprint2.cjs +1 -1
- package/dist/chunks/fingerprint2.mjs +1 -1
- package/dist/esbuild.cjs +2 -2
- package/dist/esbuild.cjs.map +1 -1
- package/dist/esbuild.d.cts +3 -3
- package/dist/esbuild.d.mts +3 -3
- package/dist/esbuild.d.ts +3 -3
- package/dist/esbuild.mjs +2 -2
- package/dist/esbuild.mjs.map +1 -1
- package/dist/index.cjs +41 -56
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +194 -282
- package/dist/index.d.mts +194 -282
- package/dist/index.d.ts +194 -282
- package/dist/index.mjs +4 -25
- package/dist/index.mjs.map +1 -1
- package/dist/nuxt.cjs +3 -1
- package/dist/nuxt.cjs.map +1 -1
- package/dist/nuxt.d.cts +17 -4
- package/dist/nuxt.d.mts +17 -4
- package/dist/nuxt.d.ts +17 -4
- package/dist/nuxt.mjs +4 -2
- package/dist/nuxt.mjs.map +1 -1
- package/dist/rollup.cjs +2 -2
- package/dist/rollup.cjs.map +1 -1
- package/dist/rollup.d.cts +3 -3
- package/dist/rollup.d.mts +3 -3
- package/dist/rollup.d.ts +3 -3
- package/dist/rollup.mjs +2 -2
- package/dist/rollup.mjs.map +1 -1
- package/dist/rspack.cjs +1 -1
- package/dist/rspack.d.cts +1 -1
- package/dist/rspack.d.mts +1 -1
- package/dist/rspack.d.ts +1 -1
- package/dist/rspack.mjs +1 -1
- package/dist/runtime/plugins/attaform.cjs +4 -5
- package/dist/runtime/plugins/attaform.cjs.map +1 -1
- package/dist/runtime/plugins/attaform.mjs +1 -2
- package/dist/runtime/plugins/attaform.mjs.map +1 -1
- package/dist/shared/{attaform.BRzKBj2g.cjs → attaform.8tFZu1Ub.cjs} +2 -2
- package/dist/shared/{attaform.BRzKBj2g.cjs.map → attaform.8tFZu1Ub.cjs.map} +1 -1
- package/dist/shared/{attaform.k9V0py0s.mjs → attaform.BERt5YMU.mjs} +2 -2
- package/dist/shared/{attaform.k9V0py0s.mjs.map → attaform.BERt5YMU.mjs.map} +1 -1
- package/dist/shared/{attaform.DSOIz08n.mjs → attaform.BceJrhQ7.mjs} +5 -5
- package/dist/shared/{attaform.DSOIz08n.mjs.map → attaform.BceJrhQ7.mjs.map} +1 -1
- package/dist/shared/{attaform.DBNjHgNj.d.cts → attaform.C3WnCDXz.d.cts} +11 -9
- package/dist/shared/{attaform.DBNjHgNj.d.mts → attaform.C3WnCDXz.d.mts} +11 -9
- package/dist/shared/{attaform.DBNjHgNj.d.ts → attaform.C3WnCDXz.d.ts} +11 -9
- package/dist/shared/{attaform.DuzQYscR.d.mts → attaform.C9fPTxjB.d.cts} +5 -5
- package/dist/shared/{attaform.DuzQYscR.d.ts → attaform.C9fPTxjB.d.mts} +5 -5
- package/dist/shared/{attaform.DuzQYscR.d.cts → attaform.C9fPTxjB.d.ts} +5 -5
- package/dist/shared/{attaform.Be5otUVw.d.ts → attaform.CC_y1_Ej.d.ts} +33 -33
- package/dist/shared/{attaform.ceYeVkjn.d.ts → attaform.CEXUlUkc.d.ts} +1579 -1192
- package/dist/shared/{attaform.tZ0YKisf.cjs → attaform.C__F01CE.cjs} +15 -15
- package/dist/shared/{attaform.tZ0YKisf.cjs.map → attaform.C__F01CE.cjs.map} +1 -1
- package/dist/shared/{attaform.BPl-ECRT.cjs → attaform.Co5LNRnv.cjs} +162 -129
- package/dist/shared/attaform.Co5LNRnv.cjs.map +1 -0
- package/dist/shared/{attaform.B71rfNL5.d.mts → attaform.CpXHK60W.d.cts} +33 -33
- package/dist/shared/{attaform.BFfY7HRI.d.cts → attaform.CvVYOvZF.d.mts} +33 -33
- package/dist/shared/{attaform.BoYqnIPI.mjs → attaform.CyQxTOdX.mjs} +55 -36
- package/dist/shared/attaform.CyQxTOdX.mjs.map +1 -0
- package/dist/shared/{attaform.CEY_WLRJ.d.mts → attaform.D99pd7JG.d.cts} +1579 -1192
- package/dist/shared/{attaform.CXVmZtFq.mjs → attaform.DDAmSFnl.mjs} +4 -4
- package/dist/shared/{attaform.CXVmZtFq.mjs.map → attaform.DDAmSFnl.mjs.map} +1 -1
- package/dist/shared/{attaform.Du9RZp8m.cjs → attaform.DQT7_-FO.cjs} +272 -252
- package/dist/shared/attaform.DQT7_-FO.cjs.map +1 -0
- package/dist/shared/{attaform.DGhIix5D.mjs → attaform.Da8EdI2t.mjs} +160 -129
- package/dist/shared/attaform.Da8EdI2t.mjs.map +1 -0
- package/dist/shared/{attaform.Cs0UZ7q6.cjs → attaform.DhVgG2jh.cjs} +16 -16
- package/dist/shared/{attaform.Cs0UZ7q6.cjs.map → attaform.DhVgG2jh.cjs.map} +1 -1
- package/dist/shared/{attaform.sHkHv_98.mjs → attaform.DhnPb6nK.mjs} +6 -3
- package/dist/shared/attaform.DhnPb6nK.mjs.map +1 -0
- package/dist/shared/attaform.DkD0DR7R.mjs +42 -0
- package/dist/shared/attaform.DkD0DR7R.mjs.map +1 -0
- package/dist/shared/{attaform.CSXDW2tO.mjs → attaform.DlSu08F5.mjs} +4 -4
- package/dist/shared/{attaform.CSXDW2tO.mjs.map → attaform.DlSu08F5.mjs.map} +1 -1
- package/dist/shared/{attaform.LEWUFqUw.cjs → attaform.DoQm_Vkd.cjs} +7 -3
- package/dist/shared/attaform.DoQm_Vkd.cjs.map +1 -0
- package/dist/shared/{attaform.BQflyVOL.cjs → attaform.Drsi43GG.cjs} +19 -19
- package/dist/shared/{attaform.BQflyVOL.cjs.map → attaform.Drsi43GG.cjs.map} +1 -1
- package/dist/shared/attaform.K6Thc6By.cjs +46 -0
- package/dist/shared/attaform.K6Thc6By.cjs.map +1 -0
- package/dist/shared/{attaform.Vp2-CWZB.mjs → attaform.KvlEedlF.mjs} +3 -3
- package/dist/shared/{attaform.Vp2-CWZB.mjs.map → attaform.KvlEedlF.mjs.map} +1 -1
- package/dist/shared/{attaform.BRGIpZo4.cjs → attaform.RaTzp1WF.cjs} +3 -3
- package/dist/shared/attaform.RaTzp1WF.cjs.map +1 -0
- package/dist/shared/{attaform.MgaYKlPP.d.cts → attaform.kBkYlKP_.d.mts} +1579 -1192
- package/dist/shared/{attaform.C3Doa9Pt.mjs → attaform.v0fQtWyA.mjs} +3 -3
- package/dist/shared/attaform.v0fQtWyA.mjs.map +1 -0
- package/dist/shared/{attaform.ZXZ6dH72.cjs → attaform.yUrz7C2z.cjs} +3 -3
- package/dist/shared/{attaform.ZXZ6dH72.cjs.map → attaform.yUrz7C2z.cjs.map} +1 -1
- package/dist/transforms.cjs +1 -1
- package/dist/transforms.mjs +1 -1
- package/dist/vite.cjs +21 -3
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.d.cts +70 -17
- package/dist/vite.d.mts +70 -17
- package/dist/vite.d.ts +70 -17
- package/dist/vite.mjs +20 -4
- package/dist/vite.mjs.map +1 -1
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.d.cts +1 -1
- package/dist/webpack.d.mts +1 -1
- package/dist/webpack.d.ts +1 -1
- package/dist/webpack.mjs +1 -1
- package/dist/zod-v3.cjs +41 -10
- package/dist/zod-v3.cjs.map +1 -1
- package/dist/zod-v3.d.cts +5 -5
- package/dist/zod-v3.d.mts +5 -5
- package/dist/zod-v3.d.ts +5 -5
- package/dist/zod-v3.mjs +4 -2
- package/dist/zod-v3.mjs.map +1 -1
- package/dist/zod-v4.cjs +41 -10
- package/dist/zod-v4.cjs.map +1 -1
- package/dist/zod-v4.d.cts +7 -7
- package/dist/zod-v4.d.mts +7 -7
- package/dist/zod-v4.d.ts +7 -7
- package/dist/zod-v4.mjs +4 -2
- package/dist/zod-v4.mjs.map +1 -1
- package/dist/zod.cjs +44 -49
- package/dist/zod.cjs.map +1 -1
- package/dist/zod.d.cts +6 -248
- package/dist/zod.d.mts +6 -248
- package/dist/zod.d.ts +6 -248
- package/dist/zod.mjs +4 -42
- package/dist/zod.mjs.map +1 -1
- package/package.json +12 -2
- package/skills/attaform/SKILL.md +128 -0
- package/skills/attaform/references/custom-components.md +72 -0
- package/skills/attaform/references/errors.md +62 -0
- package/skills/attaform/references/ssr.md +26 -0
- package/skills/attaform/references/validation.md +40 -0
- package/skills/attaform/references/wizards.md +104 -0
- package/dist/shared/attaform.55hFR_cl.d.ts +0 -97
- package/dist/shared/attaform.BPl-ECRT.cjs.map +0 -1
- package/dist/shared/attaform.BRGIpZo4.cjs.map +0 -1
- package/dist/shared/attaform.BoYqnIPI.mjs.map +0 -1
- package/dist/shared/attaform.C3Doa9Pt.mjs.map +0 -1
- package/dist/shared/attaform.D51IwDtP.cjs +0 -39
- package/dist/shared/attaform.D51IwDtP.cjs.map +0 -1
- package/dist/shared/attaform.DGhIix5D.mjs.map +0 -1
- package/dist/shared/attaform.DJRz_bzM.d.cts +0 -97
- package/dist/shared/attaform.Du9RZp8m.cjs.map +0 -1
- package/dist/shared/attaform.JPsaqjLl.d.mts +0 -97
- package/dist/shared/attaform.LEWUFqUw.cjs.map +0 -1
- package/dist/shared/attaform.NqYEzRcM.mjs +0 -35
- package/dist/shared/attaform.NqYEzRcM.mjs.map +0 -1
- package/dist/shared/attaform.sHkHv_98.mjs.map +0 -1
- package/dist/shared/{attaform.DdjDqTah.d.ts → attaform.DRUT703x.d.cts} +14 -14
- package/dist/shared/{attaform.DdjDqTah.d.cts → attaform.DRUT703x.d.mts} +14 -14
- package/dist/shared/{attaform.DdjDqTah.d.mts → attaform.DRUT703x.d.ts} +14 -14
package/README.md
CHANGED
|
@@ -24,36 +24,44 @@ A type-safe, schema-driven form library for Vue 3 and Nuxt with first-class Zod
|
|
|
24
24
|
npm install attaform zod
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
+
<!-- @generated-start:quick-start -->
|
|
28
|
+
|
|
27
29
|
```vue
|
|
28
30
|
<script setup lang="ts">
|
|
31
|
+
import { useForm } from 'attaform'
|
|
29
32
|
import { z } from 'zod'
|
|
30
|
-
import { useForm } from 'attaform/zod' // auto-detects your Zod major
|
|
31
33
|
|
|
32
34
|
const schema = z.object({
|
|
33
|
-
|
|
35
|
+
email: z.email('Enter a valid email'),
|
|
34
36
|
password: z.string().min(8, 'At least 8 characters'),
|
|
35
37
|
})
|
|
36
38
|
|
|
37
39
|
const form = useForm({ schema })
|
|
38
40
|
|
|
39
41
|
const onSubmit = form.handleSubmit(async (values) => {
|
|
40
|
-
await fetch('/api/
|
|
42
|
+
await fetch('/api/sign-in', { method: 'POST', body: JSON.stringify(values) })
|
|
41
43
|
})
|
|
42
44
|
</script>
|
|
43
45
|
|
|
44
46
|
<template>
|
|
45
|
-
<form @submit
|
|
46
|
-
<
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
<form @submit="onSubmit">
|
|
48
|
+
<label>
|
|
49
|
+
Email
|
|
50
|
+
<input v-register="form.register('email')" autocomplete="email" />
|
|
51
|
+
<em v-if="form.fields.email.showErrors">{{ form.fields.email.firstError?.message }}</em>
|
|
52
|
+
</label>
|
|
53
|
+
<label>
|
|
54
|
+
Password
|
|
55
|
+
<input v-register="form.register('password')" type="password" autocomplete="off" />
|
|
56
|
+
<em v-if="form.fields.password.showErrors">{{ form.fields.password.firstError?.message }}</em>
|
|
57
|
+
</label>
|
|
58
|
+
<button :disabled="form.meta.submitting" type="submit">Sign in</button>
|
|
53
59
|
</form>
|
|
54
60
|
</template>
|
|
55
61
|
```
|
|
56
62
|
|
|
63
|
+
<!-- @generated-end:quick-start -->
|
|
64
|
+
|
|
57
65
|
Hand the schema to `useForm`, bind each input with `v-register`, and Attaform owns the values, the coercion, the live errors, and the typed submit payload. That is the whole loop.
|
|
58
66
|
|
|
59
67
|
**[Full walkthrough →](https://attaform.dev/docs/getting-started/quick-start)** Setting up Nuxt, Vite, or bare Vue? See the [installation guide](https://attaform.dev/docs/getting-started/installation).
|
|
@@ -65,6 +73,7 @@ Hand the schema to `useForm`, bind each input with `v-register`, and Attaform ow
|
|
|
65
73
|
- **`useWizard` for multistep.** Compose forms into a flow with shared navigation, per-step validation, state retained across steps, and deep-link restore. [useWizard →](https://attaform.dev/docs/multistep/use-wizard)
|
|
66
74
|
- **SSR-native.** Server-rendered HTML matches the hydrated client with no flash. Auto-wired in Nuxt, one Vite plugin for bare Vue. [SSR in Nuxt →](https://attaform.dev/docs/server-and-ssr/ssr-nuxt)
|
|
67
75
|
- **DevTools built in.** Inspect every form on the page, walk its history, and edit values live. No probes to install. [DevTools panel →](https://attaform.dev/docs/devtools-and-debugging/devtools-panel)
|
|
76
|
+
- **Built for AI-assisted coding.** Ships an `llms.txt` index, a full-text docs dump, and an installable Agent Skill (`npx attaform skill`), so your coding assistant writes idiomatic Attaform the first time. [AI agents →](https://attaform.dev/docs/reference/ai-agents)
|
|
68
77
|
- **Secure by construction.** Zero runtime dependencies (no supply-chain surface), prototype-pollution-safe deep writes, and Attaform never throws into your app. [Security policy →](./SECURITY.md)
|
|
69
78
|
|
|
70
79
|
## Documentation
|
|
@@ -76,6 +85,7 @@ Full docs live at **[attaform.dev](https://attaform.dev)**.
|
|
|
76
85
|
- [Entry points](https://attaform.dev/docs/reference/entry-points): every public export, grouped by subpath.
|
|
77
86
|
- [Performance](https://attaform.dev/docs/server-and-ssr/performance): how it scales, when to worry.
|
|
78
87
|
- [Troubleshooting](https://attaform.dev/docs/devtools-and-debugging/troubleshooting): common gotchas and fixes.
|
|
88
|
+
- [AI agents](https://attaform.dev/docs/reference/ai-agents): `llms.txt`, the full-text docs dump, and an installable skill for coding assistants.
|
|
79
89
|
- [Changelog](./CHANGELOG.md): full release history.
|
|
80
90
|
|
|
81
91
|
## Status
|
package/bin/attaform.mjs
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Attaform CLI.
|
|
4
|
+
*
|
|
5
|
+
* `attaform skill [dir]` copies the bundled Agent Skill (which ships in
|
|
6
|
+
* the package under `skills/attaform/`) into a project so an AI
|
|
7
|
+
* assistant loads it while working on a form. The skill moves in
|
|
8
|
+
* lockstep with the installed Attaform version: run through `npx` in a
|
|
9
|
+
* project that already has Attaform and it copies that version's skill.
|
|
10
|
+
*
|
|
11
|
+
* With no `[dir]`, it places the skill next to whichever assistants the
|
|
12
|
+
* project already uses (`.claude/`, `.cursor/`, `.codex/`, `.agents/`)
|
|
13
|
+
* and falls back to the vendor-neutral `.agents/skills/` when none is
|
|
14
|
+
* present. `SKILL.md` is one portable format, so a single copy is read
|
|
15
|
+
* natively by Claude Code, Cursor, Codex, OpenCode, and the rest.
|
|
16
|
+
*
|
|
17
|
+
* Zero dependencies (Node built-ins only), so it ships verbatim with no
|
|
18
|
+
* build step.
|
|
19
|
+
*/
|
|
20
|
+
import { cpSync, existsSync, readdirSync } from 'node:fs'
|
|
21
|
+
import { relative, resolve } from 'node:path'
|
|
22
|
+
import { fileURLToPath } from 'node:url'
|
|
23
|
+
|
|
24
|
+
// The skill directory bundled in the package, resolved relative to this
|
|
25
|
+
// file (`bin/attaform.mjs` -> `skills/attaform/`). It ships via the
|
|
26
|
+
// package.json `files` entry, so it is present in both the git checkout
|
|
27
|
+
// and the installed package.
|
|
28
|
+
const SKILL_SOURCE = fileURLToPath(new URL('../skills/attaform/', import.meta.url))
|
|
29
|
+
|
|
30
|
+
// The vendor-neutral skills directory: read by OpenCode, Cursor, Cline,
|
|
31
|
+
// and others, and the destination when a project has not committed to a
|
|
32
|
+
// single assistant yet.
|
|
33
|
+
const NEUTRAL_SKILLS_DIR = '.agents/skills'
|
|
34
|
+
|
|
35
|
+
// Marker directory an assistant creates -> the skills directory it reads.
|
|
36
|
+
// `SKILL.md` is one portable format, so the same files drop into each.
|
|
37
|
+
// Detection is intentionally narrow: only paths a project would not have
|
|
38
|
+
// for another reason (unlike `.github/`, which nearly every repo carries).
|
|
39
|
+
const ASSISTANT_SKILL_DIRS = [
|
|
40
|
+
{ marker: '.claude', skillsDir: '.claude/skills' },
|
|
41
|
+
{ marker: '.cursor', skillsDir: '.cursor/skills' },
|
|
42
|
+
{ marker: '.codex', skillsDir: '.codex/skills' },
|
|
43
|
+
{ marker: '.agents', skillsDir: NEUTRAL_SKILLS_DIR },
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
function usage() {
|
|
47
|
+
console.log(
|
|
48
|
+
[
|
|
49
|
+
'Usage: attaform skill [dir]',
|
|
50
|
+
'',
|
|
51
|
+
" Copy Attaform's Agent Skill into your project so an AI assistant",
|
|
52
|
+
' loads it while working on a form.',
|
|
53
|
+
'',
|
|
54
|
+
' With no [dir], the skill lands next to each assistant the project',
|
|
55
|
+
' already uses (.claude, .cursor, .codex, .agents), or',
|
|
56
|
+
` ${NEUTRAL_SKILLS_DIR}/ when none is present.`,
|
|
57
|
+
'',
|
|
58
|
+
' [dir] Skills directory to install into, e.g. attaform skill .cursor/skills',
|
|
59
|
+
].join('\n')
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function countFiles(dir) {
|
|
64
|
+
let total = 0
|
|
65
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
66
|
+
total += entry.isDirectory() ? countFiles(resolve(dir, entry.name)) : 1
|
|
67
|
+
}
|
|
68
|
+
return total
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// The skills directories to install into. An explicit arg wins verbatim.
|
|
72
|
+
// Otherwise place next to each assistant the project already uses, and
|
|
73
|
+
// fall back to the vendor-neutral directory when none is detected.
|
|
74
|
+
function resolveTargets(dirArg) {
|
|
75
|
+
if (dirArg !== undefined) return { dirs: [dirArg], detected: true }
|
|
76
|
+
|
|
77
|
+
const dirs = ASSISTANT_SKILL_DIRS.filter(({ marker }) =>
|
|
78
|
+
existsSync(resolve(process.cwd(), marker))
|
|
79
|
+
).map(({ skillsDir }) => skillsDir)
|
|
80
|
+
|
|
81
|
+
return dirs.length > 0
|
|
82
|
+
? { dirs, detected: true }
|
|
83
|
+
: { dirs: [NEUTRAL_SKILLS_DIR], detected: false }
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function installSkill(skillsDir) {
|
|
87
|
+
const dest = resolve(skillsDir, 'attaform')
|
|
88
|
+
const existed = existsSync(dest)
|
|
89
|
+
cpSync(SKILL_SOURCE, dest, { recursive: true })
|
|
90
|
+
|
|
91
|
+
const where = relative(process.cwd(), dest) || dest
|
|
92
|
+
const count = countFiles(dest)
|
|
93
|
+
console.log(
|
|
94
|
+
`${existed ? 'Updated' : 'Installed'} the Attaform skill (${count} file${count === 1 ? '' : 's'}) at ${where}/`
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const [command, dirArg] = process.argv.slice(2)
|
|
99
|
+
|
|
100
|
+
if (command === undefined || command === '-h' || command === '--help' || command === 'help') {
|
|
101
|
+
usage()
|
|
102
|
+
process.exit(0)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (command !== 'skill') {
|
|
106
|
+
console.error(`attaform: unknown command "${command}"\n`)
|
|
107
|
+
usage()
|
|
108
|
+
process.exit(1)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
try {
|
|
112
|
+
const { dirs, detected } = resolveTargets(dirArg)
|
|
113
|
+
for (const dir of dirs) installSkill(dir)
|
|
114
|
+
if (!detected) {
|
|
115
|
+
console.log(
|
|
116
|
+
`No assistant directory found, so the skill went to the vendor-neutral ${NEUTRAL_SKILLS_DIR}/. Pass a path (e.g. attaform skill .claude/skills) to target a specific assistant.`
|
|
117
|
+
)
|
|
118
|
+
}
|
|
119
|
+
console.log('Your assistant will load it while it works on a form in this project.')
|
|
120
|
+
} catch (error) {
|
|
121
|
+
console.error(
|
|
122
|
+
`attaform: could not install the skill: ${error instanceof Error ? error.message : String(error)}`
|
|
123
|
+
)
|
|
124
|
+
process.exit(1)
|
|
125
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const serializeScript = require('./shared/attaform.DQT7_-FO.cjs');
|
|
4
|
+
const devtoolsShared = require('./shared/attaform.Co5LNRnv.cjs');
|
|
5
|
+
const registerProtocol = require('./shared/attaform.yUrz7C2z.cjs');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
exports.AttaformErrorCode = serializeScript.AttaformErrorCode;
|
|
10
|
+
exports.DEFAULT_TIMINGS = serializeScript.DEFAULT_TIMINGS;
|
|
11
|
+
exports.defaultCoercionRules = serializeScript.defaultCoercionRules;
|
|
12
|
+
exports.defaultDisplayState = serializeScript.defaultDisplayState;
|
|
13
|
+
exports.defineCoercion = serializeScript.defineCoercion;
|
|
14
|
+
exports.escapeForInlineScript = serializeScript.escapeForInlineScript;
|
|
15
|
+
exports.injectForm = serializeScript.injectForm;
|
|
16
|
+
exports.injectWizard = serializeScript.injectWizard;
|
|
17
|
+
exports.isUnset = serializeScript.isUnset;
|
|
18
|
+
exports.lazy = serializeScript.lazy;
|
|
19
|
+
exports.makeDefaultDisplayState = serializeScript.makeDefaultDisplayState;
|
|
20
|
+
exports.unset = serializeScript.unset;
|
|
21
|
+
exports.useAbstractForm = serializeScript.useAbstractForm;
|
|
22
|
+
exports.useRegister = serializeScript.useRegister;
|
|
23
|
+
exports.useWizard = serializeScript.useWizard;
|
|
24
|
+
exports.AttaformError = devtoolsShared.AttaformError;
|
|
25
|
+
exports.DEVTOOLS_WINDOW_KEY = devtoolsShared.DEVTOOLS_WINDOW_KEY;
|
|
26
|
+
exports.InvalidPathError = devtoolsShared.InvalidPathError;
|
|
27
|
+
exports.InvalidUseFormConfigError = devtoolsShared.InvalidUseFormConfigError;
|
|
28
|
+
exports.OutsideSetupError = devtoolsShared.OutsideSetupError;
|
|
29
|
+
exports.ROOT_PATH = devtoolsShared.ROOT_PATH;
|
|
30
|
+
exports.ROOT_PATH_KEY = devtoolsShared.ROOT_PATH_KEY;
|
|
31
|
+
exports.RegistryNotInstalledError = devtoolsShared.RegistryNotInstalledError;
|
|
32
|
+
exports.ReservedFormKeyError = devtoolsShared.ReservedFormKeyError;
|
|
33
|
+
exports.SubmitErrorHandlerError = devtoolsShared.SubmitErrorHandlerError;
|
|
34
|
+
exports.assignKey = devtoolsShared.assignKey;
|
|
35
|
+
exports.canonicalizePath = devtoolsShared.canonicalizePath;
|
|
36
|
+
exports.createAttaform = devtoolsShared.createAttaform;
|
|
37
|
+
exports.createRegistry = devtoolsShared.createRegistry;
|
|
38
|
+
exports.getRegistryFromApp = devtoolsShared.getRegistryFromApp;
|
|
39
|
+
exports.hydrateAttaformState = devtoolsShared.hydrateAttaformState;
|
|
40
|
+
exports.isPathPrefix = devtoolsShared.isPathPrefix;
|
|
41
|
+
exports.kAttaformRegistry = devtoolsShared.kAttaformRegistry;
|
|
42
|
+
exports.parseDottedPath = devtoolsShared.parseDottedPath;
|
|
43
|
+
exports.renderAttaformState = devtoolsShared.renderAttaformState;
|
|
44
|
+
exports.useRegistry = devtoolsShared.useRegistry;
|
|
45
|
+
exports.vRegister = devtoolsShared.vRegister;
|
|
46
|
+
exports.isRegisterValue = registerProtocol.isRegisterValue;
|
|
47
|
+
//# sourceMappingURL=abstract.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abstract.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { A as AttaformRegistry } from './shared/attaform.D99pd7JG.cjs';
|
|
2
|
+
export { a as AnyForm, b as AttaformDevtoolsBridge, c as AttaformError, d as AttaformErrorCode, e as AttaformPluginOptions, C as CompiledStep, D as DEFAULT_TIMINGS, f as DEVTOOLS_WINDOW_KEY, g as DisplayTimings, F as FormStatus, I as InjectWizardInput, h as InvalidPathError, i as InvalidUseFormConfigError, L as LazyMarker, O as OutsideSetupError, R as RegistryNotInstalledError, j as ReservedFormKeyError, S as SerializedAttaformState, k as SerializedFormData, l as StepSlot, m as SubmitErrorHandlerError, U as UseRegisterReturn, n as UseWizardReturnType, W as WizardAggregateError, o as WizardCtx, p as WizardCtxForm, q as WizardOnError, r as WizardOnSubmit, s as WizardOptions, t as WizardPersistFn, u as WizardRestoreFn, v as WizardRestoreState, w as WizardStatusesProxy, x as WizardSubmitContext, y as assignKey, z as createAttaform, B as createRegistry, E as defaultCoercionRules, G as defaultDisplayState, H as defineCoercion, J as escapeForInlineScript, K as getRegistryFromApp, M as hydrateAttaformState, N as injectForm, P as injectWizard, Q as isRegisterValue, T as kAttaformRegistry, V as lazy, X as makeDefaultDisplayState, Y as renderAttaformState, Z as useRegister, _ as useRegistry, $ as useWizard, a0 as vRegister } from './shared/attaform.D99pd7JG.cjs';
|
|
3
|
+
import { G as GenericForm, F as FormKey, U as UseFormConfiguration, A as AbstractSchema, D as DefaultValuesInput, a as UseFormReturnType } from './shared/attaform.C3WnCDXz.cjs';
|
|
4
|
+
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, o as FieldMetaPayload, 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, ae as ValidateOnConfig, 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.C3WnCDXz.cjs';
|
|
5
|
+
import 'vue';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Schema-agnostic `useForm`. Accepts any object that implements
|
|
9
|
+
* `AbstractSchema` — useful when integrating a custom schema
|
|
10
|
+
* adapter or a third-party validation library.
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { useForm } from 'attaform'
|
|
14
|
+
*
|
|
15
|
+
* const form = useForm({
|
|
16
|
+
* schema: myCustomAdapter,
|
|
17
|
+
* defaultValues: { name: '' },
|
|
18
|
+
* })
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* Most consumers prefer a typed entry point that wraps the underlying
|
|
22
|
+
* library's schema with the matching adapter automatically; see the
|
|
23
|
+
* subpath documentation for the available adapters.
|
|
24
|
+
*
|
|
25
|
+
* Returns the same form API as the typed entry points; see
|
|
26
|
+
* `UseFormReturnType` for the full surface.
|
|
27
|
+
*/
|
|
28
|
+
declare function useAbstractForm<Form extends GenericForm, GetValueFormType extends GenericForm = Form, ReadForm extends GenericForm = Form, K extends FormKey = FormKey>(configuration: UseFormConfiguration<Form, GetValueFormType, AbstractSchema<Form, GetValueFormType>, DefaultValuesInput<Form>, K>,
|
|
29
|
+
/**
|
|
30
|
+
* Internal escape hatch for callers that already hold a registry
|
|
31
|
+
* reference and need to construct a form outside Vue's setup context
|
|
32
|
+
* (e.g. the wizard's lazy noop builder, which runs inside a
|
|
33
|
+
* `computed` re-eval). Passing this skips the strict `useRegistry()`
|
|
34
|
+
* call; everything else (FormStore allocation, registry presence,
|
|
35
|
+
* consumer ref-counting via `onScopeDispose`) goes through the same
|
|
36
|
+
* path eager calls follow. Not part of the public surface.
|
|
37
|
+
*/
|
|
38
|
+
options?: {
|
|
39
|
+
readonly registry?: AttaformRegistry;
|
|
40
|
+
}): UseFormReturnType<Form, GetValueFormType, ReadForm, K>;
|
|
41
|
+
|
|
42
|
+
export { AbstractSchema, AttaformRegistry, DefaultValuesInput, FormKey, GenericForm, UseFormConfiguration, UseFormReturnType, useAbstractForm };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { A as AttaformRegistry } from './shared/attaform.kBkYlKP_.mjs';
|
|
2
|
+
export { a as AnyForm, b as AttaformDevtoolsBridge, c as AttaformError, d as AttaformErrorCode, e as AttaformPluginOptions, C as CompiledStep, D as DEFAULT_TIMINGS, f as DEVTOOLS_WINDOW_KEY, g as DisplayTimings, F as FormStatus, I as InjectWizardInput, h as InvalidPathError, i as InvalidUseFormConfigError, L as LazyMarker, O as OutsideSetupError, R as RegistryNotInstalledError, j as ReservedFormKeyError, S as SerializedAttaformState, k as SerializedFormData, l as StepSlot, m as SubmitErrorHandlerError, U as UseRegisterReturn, n as UseWizardReturnType, W as WizardAggregateError, o as WizardCtx, p as WizardCtxForm, q as WizardOnError, r as WizardOnSubmit, s as WizardOptions, t as WizardPersistFn, u as WizardRestoreFn, v as WizardRestoreState, w as WizardStatusesProxy, x as WizardSubmitContext, y as assignKey, z as createAttaform, B as createRegistry, E as defaultCoercionRules, G as defaultDisplayState, H as defineCoercion, J as escapeForInlineScript, K as getRegistryFromApp, M as hydrateAttaformState, N as injectForm, P as injectWizard, Q as isRegisterValue, T as kAttaformRegistry, V as lazy, X as makeDefaultDisplayState, Y as renderAttaformState, Z as useRegister, _ as useRegistry, $ as useWizard, a0 as vRegister } from './shared/attaform.kBkYlKP_.mjs';
|
|
3
|
+
import { G as GenericForm, F as FormKey, U as UseFormConfiguration, A as AbstractSchema, D as DefaultValuesInput, a as UseFormReturnType } from './shared/attaform.C3WnCDXz.mjs';
|
|
4
|
+
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, o as FieldMetaPayload, 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, ae as ValidateOnConfig, 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.C3WnCDXz.mjs';
|
|
5
|
+
import 'vue';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Schema-agnostic `useForm`. Accepts any object that implements
|
|
9
|
+
* `AbstractSchema` — useful when integrating a custom schema
|
|
10
|
+
* adapter or a third-party validation library.
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { useForm } from 'attaform'
|
|
14
|
+
*
|
|
15
|
+
* const form = useForm({
|
|
16
|
+
* schema: myCustomAdapter,
|
|
17
|
+
* defaultValues: { name: '' },
|
|
18
|
+
* })
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* Most consumers prefer a typed entry point that wraps the underlying
|
|
22
|
+
* library's schema with the matching adapter automatically; see the
|
|
23
|
+
* subpath documentation for the available adapters.
|
|
24
|
+
*
|
|
25
|
+
* Returns the same form API as the typed entry points; see
|
|
26
|
+
* `UseFormReturnType` for the full surface.
|
|
27
|
+
*/
|
|
28
|
+
declare function useAbstractForm<Form extends GenericForm, GetValueFormType extends GenericForm = Form, ReadForm extends GenericForm = Form, K extends FormKey = FormKey>(configuration: UseFormConfiguration<Form, GetValueFormType, AbstractSchema<Form, GetValueFormType>, DefaultValuesInput<Form>, K>,
|
|
29
|
+
/**
|
|
30
|
+
* Internal escape hatch for callers that already hold a registry
|
|
31
|
+
* reference and need to construct a form outside Vue's setup context
|
|
32
|
+
* (e.g. the wizard's lazy noop builder, which runs inside a
|
|
33
|
+
* `computed` re-eval). Passing this skips the strict `useRegistry()`
|
|
34
|
+
* call; everything else (FormStore allocation, registry presence,
|
|
35
|
+
* consumer ref-counting via `onScopeDispose`) goes through the same
|
|
36
|
+
* path eager calls follow. Not part of the public surface.
|
|
37
|
+
*/
|
|
38
|
+
options?: {
|
|
39
|
+
readonly registry?: AttaformRegistry;
|
|
40
|
+
}): UseFormReturnType<Form, GetValueFormType, ReadForm, K>;
|
|
41
|
+
|
|
42
|
+
export { AbstractSchema, AttaformRegistry, DefaultValuesInput, FormKey, GenericForm, UseFormConfiguration, UseFormReturnType, useAbstractForm };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { A as AttaformRegistry } from './shared/attaform.CEXUlUkc.js';
|
|
2
|
+
export { a as AnyForm, b as AttaformDevtoolsBridge, c as AttaformError, d as AttaformErrorCode, e as AttaformPluginOptions, C as CompiledStep, D as DEFAULT_TIMINGS, f as DEVTOOLS_WINDOW_KEY, g as DisplayTimings, F as FormStatus, I as InjectWizardInput, h as InvalidPathError, i as InvalidUseFormConfigError, L as LazyMarker, O as OutsideSetupError, R as RegistryNotInstalledError, j as ReservedFormKeyError, S as SerializedAttaformState, k as SerializedFormData, l as StepSlot, m as SubmitErrorHandlerError, U as UseRegisterReturn, n as UseWizardReturnType, W as WizardAggregateError, o as WizardCtx, p as WizardCtxForm, q as WizardOnError, r as WizardOnSubmit, s as WizardOptions, t as WizardPersistFn, u as WizardRestoreFn, v as WizardRestoreState, w as WizardStatusesProxy, x as WizardSubmitContext, y as assignKey, z as createAttaform, B as createRegistry, E as defaultCoercionRules, G as defaultDisplayState, H as defineCoercion, J as escapeForInlineScript, K as getRegistryFromApp, M as hydrateAttaformState, N as injectForm, P as injectWizard, Q as isRegisterValue, T as kAttaformRegistry, V as lazy, X as makeDefaultDisplayState, Y as renderAttaformState, Z as useRegister, _ as useRegistry, $ as useWizard, a0 as vRegister } from './shared/attaform.CEXUlUkc.js';
|
|
3
|
+
import { G as GenericForm, F as FormKey, U as UseFormConfiguration, A as AbstractSchema, D as DefaultValuesInput, a as UseFormReturnType } from './shared/attaform.C3WnCDXz.js';
|
|
4
|
+
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, o as FieldMetaPayload, 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, ae as ValidateOnConfig, 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.C3WnCDXz.js';
|
|
5
|
+
import 'vue';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Schema-agnostic `useForm`. Accepts any object that implements
|
|
9
|
+
* `AbstractSchema` — useful when integrating a custom schema
|
|
10
|
+
* adapter or a third-party validation library.
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { useForm } from 'attaform'
|
|
14
|
+
*
|
|
15
|
+
* const form = useForm({
|
|
16
|
+
* schema: myCustomAdapter,
|
|
17
|
+
* defaultValues: { name: '' },
|
|
18
|
+
* })
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* Most consumers prefer a typed entry point that wraps the underlying
|
|
22
|
+
* library's schema with the matching adapter automatically; see the
|
|
23
|
+
* subpath documentation for the available adapters.
|
|
24
|
+
*
|
|
25
|
+
* Returns the same form API as the typed entry points; see
|
|
26
|
+
* `UseFormReturnType` for the full surface.
|
|
27
|
+
*/
|
|
28
|
+
declare function useAbstractForm<Form extends GenericForm, GetValueFormType extends GenericForm = Form, ReadForm extends GenericForm = Form, K extends FormKey = FormKey>(configuration: UseFormConfiguration<Form, GetValueFormType, AbstractSchema<Form, GetValueFormType>, DefaultValuesInput<Form>, K>,
|
|
29
|
+
/**
|
|
30
|
+
* Internal escape hatch for callers that already hold a registry
|
|
31
|
+
* reference and need to construct a form outside Vue's setup context
|
|
32
|
+
* (e.g. the wizard's lazy noop builder, which runs inside a
|
|
33
|
+
* `computed` re-eval). Passing this skips the strict `useRegistry()`
|
|
34
|
+
* call; everything else (FormStore allocation, registry presence,
|
|
35
|
+
* consumer ref-counting via `onScopeDispose`) goes through the same
|
|
36
|
+
* path eager calls follow. Not part of the public surface.
|
|
37
|
+
*/
|
|
38
|
+
options?: {
|
|
39
|
+
readonly registry?: AttaformRegistry;
|
|
40
|
+
}): UseFormReturnType<Form, GetValueFormType, ReadForm, K>;
|
|
41
|
+
|
|
42
|
+
export { AbstractSchema, AttaformRegistry, DefaultValuesInput, FormKey, GenericForm, UseFormConfiguration, UseFormReturnType, useAbstractForm };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { A as AttaformErrorCode, D as DEFAULT_TIMINGS, d as defaultCoercionRules, a as defaultDisplayState, b as defineCoercion, e as escapeForInlineScript, i as injectForm, c as injectWizard, f as isUnset, l as lazy, m as makeDefaultDisplayState, u as unset, g as useAbstractForm, h as useRegister, j as useWizard } from './shared/attaform.CyQxTOdX.mjs';
|
|
2
|
+
export { A as AttaformError, D as DEVTOOLS_WINDOW_KEY, I as InvalidPathError, a as InvalidUseFormConfigError, O as OutsideSetupError, R as ROOT_PATH, b as ROOT_PATH_KEY, c as RegistryNotInstalledError, d as ReservedFormKeyError, S as SubmitErrorHandlerError, e as assignKey, f as canonicalizePath, g as createAttaform, h as createRegistry, i as getRegistryFromApp, j as hydrateAttaformState, k as isPathPrefix, l as kAttaformRegistry, p as parseDottedPath, r as renderAttaformState, u as useRegistry, v as vRegister } from './shared/attaform.Da8EdI2t.mjs';
|
|
3
|
+
export { i as isRegisterValue } from './shared/attaform.KvlEedlF.mjs';
|
|
4
|
+
//# sourceMappingURL=abstract.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abstract.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
package/dist/chunks/devtools.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const devtoolsShared = require('../shared/attaform.Co5LNRnv.cjs');
|
|
4
4
|
|
|
5
5
|
const INSPECTOR_ID = "attaform";
|
|
6
6
|
const TIMELINE_LAYER_ID = "attaform:events";
|
|
@@ -145,7 +145,7 @@ function wire(api, app, registry) {
|
|
|
145
145
|
const section = payload.path[0];
|
|
146
146
|
if (section !== "Form value") return;
|
|
147
147
|
const segments = payload.path.slice(2);
|
|
148
|
-
const { segments: canonicalPath } =
|
|
148
|
+
const { segments: canonicalPath } = devtoolsShared.canonicalizePath(segments);
|
|
149
149
|
state.setValueAtPath(canonicalPath, payload.state.value);
|
|
150
150
|
refreshState();
|
|
151
151
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devtools.cjs","sources":["../../src/runtime/core/devtools.ts"],"sourcesContent":["import type { App } from 'vue'\nimport type { FormStore } from './create-form-store'\nimport type { AttaformRegistry } from './registry'\nimport type { GenericForm } from '../types/types-core'\nimport type { FormKey } from '../types/types-api'\nimport { canonicalizePath } from './paths'\n\n/**\n * Vue DevTools plugin wiring for attaform. Lazy-imported by\n * `createAttaform` under dev-mode guards so the production\n * bundle tree-shakes it out entirely.\n *\n * Registers:\n * - An inspector (per-app) that lists every registered form, with\n * nodes for form value / errors / aggregates / history.\n * - A timeline layer that emits events on submit start/success/\n * failure, reset, undo, redo, and form mutations.\n * - State editing — modifying a leaf inside the inspector tree\n * pushes through `state.setValueAtPath`, mutating the form.\n *\n * Tolerant of missing `@vue/devtools-api` — the peer dep is marked\n * optional. If the import fails, `setupAttaformDevtools` silently\n * no-ops so production builds / users without DevTools installed\n * don't see errors.\n */\n\nconst INSPECTOR_ID = 'attaform'\nconst TIMELINE_LAYER_ID = 'attaform:events'\n\ntype UnsafeDevtoolsApi = {\n addInspector(opts: { id: string; label: string; icon?: string; app: App }): void\n addTimelineLayer(opts: { id: string; label: string; color: number }): void\n sendInspectorTree(inspectorId: string): void\n sendInspectorState(inspectorId: string): void\n addTimelineEvent(payload: {\n layerId: string\n event: {\n time: number\n title: string\n subtitle?: string\n data?: Record<string, unknown>\n groupId?: string | number\n }\n }): void\n on: {\n getInspectorTree(\n handler: (payload: {\n inspectorId: string\n filter: string\n rootNodes: Array<{ id: string; label: string; tags?: unknown[] }>\n }) => void\n ): void\n getInspectorState(\n handler: (payload: {\n inspectorId: string\n nodeId: string\n state: Record<string, Array<{ key: string; value: unknown; editable?: boolean }>>\n }) => void\n ): void\n editInspectorState(\n handler: (payload: {\n inspectorId: string\n nodeId: string\n path: string[]\n state: { value: unknown; newKey?: string | null; remove?: boolean }\n }) => void\n ): void\n }\n}\n\ntype SetupDevtoolsPluginFn = (\n descriptor: {\n id: string\n label: string\n packageName?: string\n homepage?: string\n componentStateTypes?: string[]\n app: App\n },\n setup: (api: UnsafeDevtoolsApi) => void\n) => void\n\n/**\n * Install the DevTools plugin for the given Vue app + registry. Safe\n * to call in production — if `@vue/devtools-api` isn't installed, the\n * dynamic import fails and we log nothing. Returns `true` when\n * DevTools was wired successfully, `false` otherwise — useful for\n * tests.\n */\nexport async function setupAttaformDevtools(\n app: App,\n registry: AttaformRegistry\n): Promise<boolean> {\n let mod: { setupDevtoolsPlugin?: SetupDevtoolsPluginFn }\n try {\n mod = (await import('@vue/devtools-api')) as {\n setupDevtoolsPlugin?: SetupDevtoolsPluginFn\n }\n } catch {\n // Peer dep not installed — silently skip. Production builds pass\n // `{ devtools: false }` explicitly, but this catch covers the\n // \"dev without the peer dep\" case without a noisy warning.\n return false\n }\n const setupDevtoolsPlugin = mod.setupDevtoolsPlugin\n if (typeof setupDevtoolsPlugin !== 'function') return false\n\n setupDevtoolsPlugin(\n {\n id: INSPECTOR_ID,\n label: 'Attaform',\n packageName: 'attaform',\n homepage: 'https://github.com/attaform/Attaform',\n app,\n componentStateTypes: ['Attaform form'],\n },\n (api) => wire(api, app, registry)\n )\n return true\n}\n\nfunction wire(api: UnsafeDevtoolsApi, app: App, registry: AttaformRegistry): void {\n // Per-form subscriber bookkeeping — we keep the unsubscribers so\n // the registry's eviction path can detach them when a form is\n // disposed. Using a Map keyed by FormKey mirrors the registry.\n const subscriberUnsubs = new Map<FormKey, () => void>()\n\n api.addInspector({ id: INSPECTOR_ID, label: 'Attaform', app })\n api.addTimelineLayer({ id: TIMELINE_LAYER_ID, label: 'Attaform', color: 0x5b8def })\n\n function refreshTree(): void {\n api.sendInspectorTree(INSPECTOR_ID)\n }\n\n function refreshState(): void {\n api.sendInspectorState(INSPECTOR_ID)\n }\n\n function subscribeForm(state: FormStore<GenericForm>): void {\n if (subscriberUnsubs.has(state.formKey)) return\n const unsubChange = state.onFormChange(() => {\n refreshState()\n api.addTimelineEvent({\n layerId: TIMELINE_LAYER_ID,\n event: {\n time: Date.now(),\n title: 'form.change',\n subtitle: state.formKey,\n // Devtools is dev-only — emit raw values. Consumers worried\n // about screen-share leaks should close the panel before\n // sharing, same as they would for the browser DevTools\n // console.\n data: { form: state.form.value as Record<string, unknown> },\n },\n })\n })\n const unsubSubmit = state.onSubmitSuccess(() => {\n api.addTimelineEvent({\n layerId: TIMELINE_LAYER_ID,\n event: {\n time: Date.now(),\n title: 'submit.success',\n subtitle: state.formKey,\n data: { form: state.form.value as Record<string, unknown> },\n },\n })\n })\n const unsubReset = state.onReset(() => {\n refreshState()\n api.addTimelineEvent({\n layerId: TIMELINE_LAYER_ID,\n event: {\n time: Date.now(),\n title: 'reset',\n subtitle: state.formKey,\n },\n })\n })\n subscriberUnsubs.set(state.formKey, () => {\n unsubChange()\n unsubSubmit()\n unsubReset()\n })\n }\n\n // Subscribe all currently-registered forms + register as they're\n // added. The registry's `forms` Map is shallowReactive — we poll\n // once per render on refresh; for live change detection, each\n // useForm call that adds a new form triggers a tree/state refresh\n // via the form's own onFormChange emission on the first\n // applyFormReplacement.\n function syncForms(): void {\n for (const [, state] of registry.forms) {\n subscribeForm(state)\n }\n // Drop subscribers for forms that were evicted.\n for (const [formKey, unsub] of subscriberUnsubs) {\n if (!registry.forms.has(formKey)) {\n unsub()\n subscriberUnsubs.delete(formKey)\n }\n }\n }\n\n api.on.getInspectorTree((payload) => {\n if (payload.inspectorId !== INSPECTOR_ID) return\n syncForms()\n payload.rootNodes = [...registry.forms.keys()].map((key) => ({\n id: `form:${key}`,\n label: key,\n tags: [],\n }))\n })\n\n api.on.getInspectorState((payload) => {\n if (payload.inspectorId !== INSPECTOR_ID) return\n if (!payload.nodeId.startsWith('form:')) return\n const formKey = payload.nodeId.slice('form:'.length)\n const state = registry.forms.get(formKey)\n if (state === undefined) return\n // Devtools is dev-only — render raw values for everything,\n // including sensitive-named paths. Consumers concerned about\n // screen-share leaks should close the panel before sharing.\n payload.state['Form value'] = [\n {\n key: 'form',\n value: state.form.value,\n editable: true,\n },\n ]\n // Schema-driven and user-injected errors land in separate inspector\n // sections so devs can see the source distinction at a glance — a\n // user-injected entry surviving a successful submit, or a schema\n // entry that should have cleared after a value fix, are immediately\n // visible without cross-referencing call sites.\n payload.state['Schema Errors'] = [\n ...[...state.schemaErrors.entries()].map(([k, v]) => ({\n key: String(k),\n value: v as unknown,\n })),\n ]\n payload.state['User Errors'] = [\n ...[...state.userErrors.entries()].map(([k, v]) => ({\n key: String(k),\n value: v as unknown,\n })),\n ]\n payload.state['Aggregates'] = [\n { key: 'submitting', value: state.submitting.value },\n { key: 'submissionAttempts', value: state.submissionAttempts.value },\n { key: 'departAttempts', value: state.departAttempts.value },\n { key: 'submitError', value: state.submitError.value },\n { key: 'activeValidations', value: state.activeValidations.value },\n ]\n })\n\n api.on.editInspectorState((payload) => {\n if (payload.inspectorId !== INSPECTOR_ID) return\n if (!payload.nodeId.startsWith('form:')) return\n const formKey = payload.nodeId.slice('form:'.length)\n const state = registry.forms.get(formKey)\n if (state === undefined) return\n // payload.path is `['Form value', 'form', ...pathSegments]` — the\n // first two segments are the inspector section + key, the rest is\n // the target form path the user edited. Pass the segment array\n // directly to `canonicalizePath`: join('.') would collapse a\n // literal-dot field key (`{\"user.email\": ...}`) into two segments,\n // writing to the wrong leaf.\n if (payload.path.length < 3) return\n const section = payload.path[0]\n if (section !== 'Form value') return\n const segments = payload.path.slice(2)\n const { segments: canonicalPath } = canonicalizePath(segments)\n state.setValueAtPath(canonicalPath, payload.state.value)\n refreshState()\n })\n\n // Initial sync so existing forms show up.\n syncForms()\n refreshTree()\n}\n"],"names":["canonicalizePath"],"mappings":";;;;AA0BA,MAAM,YAAA,GAAe,UAAA;AACrB,MAAM,iBAAA,GAAoB,iBAAA;AA8D1B,eAAsB,qBAAA,CACpB,KACA,QAAA,EACkB;AAClB,EAAA,IAAI,GAAA;AACJ,EAAA,IAAI;AACF,IAAA,GAAA,GAAO,MAAM,OAAO,mBAAmB,CAAA;AAAA,EAGzC,CAAA,CAAA,MAAQ;AAIN,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,MAAM,sBAAsB,GAAA,CAAI,mBAAA;AAChC,EAAA,IAAI,OAAO,mBAAA,KAAwB,UAAA,EAAY,OAAO,KAAA;AAEtD,EAAA,mBAAA;AAAA,IACE;AAAA,MACE,EAAA,EAAI,YAAA;AAAA,MACJ,KAAA,EAAO,UAAA;AAAA,MACP,WAAA,EAAa,UAAA;AAAA,MACb,QAAA,EAAU,sCAAA;AAAA,MACV,GAAA;AAAA,MACA,mBAAA,EAAqB,CAAC,eA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AAQ,IAAA,CAAK,MAAA,GAAS,CAAA,EAAG;AAC7B,IAAA,MAAM,OAAA,GAAU,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA;AAC9B,IAAA,IAAI,YAAY,YAAA,EAAc;AAC9B,IAAA,MAAM,QAAA,GAAW,OAAA,CAAQ,IAAA,CAAK,KAAA,CAAM,CAAC,CAAA;AACrC,IAAA,MAAM,EAAE,QAAA,EAAU,aAAA,EAAc,GAAIA,uBAAiB,QAAQ,CAAA;AAC7D,IAAA,KAAA,CAAM,cAAA,CAAe,aAAA,EAAe,OAAA,CAAQ,KAAA,CAAM,KAAK,CAAA;AACvD,IAAA,YAAA,EAAa;AAAA,EACf,CAAC,CAAA;AAGD,EAAA,SAAA,EAAU;AACV,EAAA,WAAA,EAAY;AACd;;;;"}
|
|
1
|
+
{"version":3,"file":"devtools.cjs","sources":["../../src/runtime/core/devtools.ts"],"sourcesContent":["import type { App } from 'vue'\nimport type { FormStore } from './create-form-store'\nimport type { AttaformRegistry } from './registry'\nimport type { GenericForm } from '../types/types-core'\nimport type { FormKey } from '../types/types-api'\nimport { canonicalizePath } from './paths'\n\n/**\n * Vue DevTools plugin wiring for attaform. Lazy-imported by\n * `createAttaform` under dev-mode guards so the production\n * bundle tree-shakes it out entirely.\n *\n * Registers:\n * - An inspector (per-app) that lists every registered form, with\n * nodes for form value / errors / aggregates / history.\n * - A timeline layer that emits events on submit start/success/\n * failure, reset, undo, redo, and form mutations.\n * - State editing — modifying a leaf inside the inspector tree\n * pushes through `state.setValueAtPath`, mutating the form.\n *\n * Tolerant of missing `@vue/devtools-api` — the peer dep is marked\n * optional. If the import fails, `setupAttaformDevtools` silently\n * no-ops so production builds / users without DevTools installed\n * don't see errors.\n */\n\nconst INSPECTOR_ID = 'attaform'\nconst TIMELINE_LAYER_ID = 'attaform:events'\n\ntype UnsafeDevtoolsApi = {\n addInspector(opts: { id: string; label: string; icon?: string; app: App }): void\n addTimelineLayer(opts: { id: string; label: string; color: number }): void\n sendInspectorTree(inspectorId: string): void\n sendInspectorState(inspectorId: string): void\n addTimelineEvent(payload: {\n layerId: string\n event: {\n time: number\n title: string\n subtitle?: string\n data?: Record<string, unknown>\n groupId?: string | number\n }\n }): void\n on: {\n getInspectorTree(\n handler: (payload: {\n inspectorId: string\n filter: string\n rootNodes: Array<{ id: string; label: string; tags?: unknown[] }>\n }) => void\n ): void\n getInspectorState(\n handler: (payload: {\n inspectorId: string\n nodeId: string\n state: Record<string, Array<{ key: string; value: unknown; editable?: boolean }>>\n }) => void\n ): void\n editInspectorState(\n handler: (payload: {\n inspectorId: string\n nodeId: string\n path: string[]\n state: { value: unknown; newKey?: string | null; remove?: boolean }\n }) => void\n ): void\n }\n}\n\ntype SetupDevtoolsPluginFn = (\n descriptor: {\n id: string\n label: string\n packageName?: string\n homepage?: string\n componentStateTypes?: string[]\n app: App\n },\n setup: (api: UnsafeDevtoolsApi) => void\n) => void\n\n/**\n * Install the DevTools plugin for the given Vue app + registry. Safe\n * to call in production — if `@vue/devtools-api` isn't installed, the\n * dynamic import fails and we log nothing. Returns `true` when\n * DevTools was wired successfully, `false` otherwise — useful for\n * tests.\n */\nexport async function setupAttaformDevtools(\n app: App,\n registry: AttaformRegistry\n): Promise<boolean> {\n let mod: { setupDevtoolsPlugin?: SetupDevtoolsPluginFn }\n try {\n mod = (await import('@vue/devtools-api')) as {\n setupDevtoolsPlugin?: SetupDevtoolsPluginFn\n }\n } catch {\n // Peer dep not installed — silently skip. Production builds pass\n // `{ devtools: false }` explicitly, but this catch covers the\n // \"dev without the peer dep\" case without a noisy warning.\n return false\n }\n const setupDevtoolsPlugin = mod.setupDevtoolsPlugin\n if (typeof setupDevtoolsPlugin !== 'function') return false\n\n setupDevtoolsPlugin(\n {\n id: INSPECTOR_ID,\n label: 'Attaform',\n packageName: 'attaform',\n homepage: 'https://github.com/attaform/Attaform',\n app,\n componentStateTypes: ['Attaform form'],\n },\n (api) => wire(api, app, registry)\n )\n return true\n}\n\nfunction wire(api: UnsafeDevtoolsApi, app: App, registry: AttaformRegistry): void {\n // Per-form subscriber bookkeeping — we keep the unsubscribers so\n // the registry's eviction path can detach them when a form is\n // disposed. Using a Map keyed by FormKey mirrors the registry.\n const subscriberUnsubs = new Map<FormKey, () => void>()\n\n api.addInspector({ id: INSPECTOR_ID, label: 'Attaform', app })\n api.addTimelineLayer({ id: TIMELINE_LAYER_ID, label: 'Attaform', color: 0x5b8def })\n\n function refreshTree(): void {\n api.sendInspectorTree(INSPECTOR_ID)\n }\n\n function refreshState(): void {\n api.sendInspectorState(INSPECTOR_ID)\n }\n\n function subscribeForm(state: FormStore<GenericForm>): void {\n if (subscriberUnsubs.has(state.formKey)) return\n const unsubChange = state.onFormChange(() => {\n refreshState()\n api.addTimelineEvent({\n layerId: TIMELINE_LAYER_ID,\n event: {\n time: Date.now(),\n title: 'form.change',\n subtitle: state.formKey,\n // Devtools is dev-only — emit raw values. Consumers worried\n // about screen-share leaks should close the panel before\n // sharing, same as they would for the browser DevTools\n // console.\n data: { form: state.form.value as Record<string, unknown> },\n },\n })\n })\n const unsubSubmit = state.onSubmitSuccess(() => {\n api.addTimelineEvent({\n layerId: TIMELINE_LAYER_ID,\n event: {\n time: Date.now(),\n title: 'submit.success',\n subtitle: state.formKey,\n data: { form: state.form.value as Record<string, unknown> },\n },\n })\n })\n const unsubReset = state.onReset(() => {\n refreshState()\n api.addTimelineEvent({\n layerId: TIMELINE_LAYER_ID,\n event: {\n time: Date.now(),\n title: 'reset',\n subtitle: state.formKey,\n },\n })\n })\n subscriberUnsubs.set(state.formKey, () => {\n unsubChange()\n unsubSubmit()\n unsubReset()\n })\n }\n\n // Subscribe all currently-registered forms + register as they're\n // added. The registry's `forms` Map is shallowReactive — we poll\n // once per render on refresh; for live change detection, each\n // useForm call that adds a new form triggers a tree/state refresh\n // via the form's own onFormChange emission on the first\n // applyFormReplacement.\n function syncForms(): void {\n for (const [, state] of registry.forms) {\n subscribeForm(state)\n }\n // Drop subscribers for forms that were evicted.\n for (const [formKey, unsub] of subscriberUnsubs) {\n if (!registry.forms.has(formKey)) {\n unsub()\n subscriberUnsubs.delete(formKey)\n }\n }\n }\n\n api.on.getInspectorTree((payload) => {\n if (payload.inspectorId !== INSPECTOR_ID) return\n syncForms()\n payload.rootNodes = [...registry.forms.keys()].map((key) => ({\n id: `form:${key}`,\n label: key,\n tags: [],\n }))\n })\n\n api.on.getInspectorState((payload) => {\n if (payload.inspectorId !== INSPECTOR_ID) return\n if (!payload.nodeId.startsWith('form:')) return\n const formKey = payload.nodeId.slice('form:'.length)\n const state = registry.forms.get(formKey)\n if (state === undefined) return\n // Devtools is dev-only — render raw values for everything,\n // including sensitive-named paths. Consumers concerned about\n // screen-share leaks should close the panel before sharing.\n payload.state['Form value'] = [\n {\n key: 'form',\n value: state.form.value,\n editable: true,\n },\n ]\n // Schema-driven and user-injected errors land in separate inspector\n // sections so devs can see the source distinction at a glance — a\n // user-injected entry surviving a successful submit, or a schema\n // entry that should have cleared after a value fix, are immediately\n // visible without cross-referencing call sites.\n payload.state['Schema Errors'] = [\n ...[...state.schemaErrors.entries()].map(([k, v]) => ({\n key: String(k),\n value: v as unknown,\n })),\n ]\n payload.state['User Errors'] = [\n ...[...state.userErrors.entries()].map(([k, v]) => ({\n key: String(k),\n value: v as unknown,\n })),\n ]\n payload.state['Aggregates'] = [\n { key: 'submitting', value: state.submitting.value },\n { key: 'submissionAttempts', value: state.submissionAttempts.value },\n { key: 'departAttempts', value: state.departAttempts.value },\n { key: 'submitError', value: state.submitError.value },\n { key: 'activeValidations', value: state.activeValidations.value },\n ]\n })\n\n api.on.editInspectorState((payload) => {\n if (payload.inspectorId !== INSPECTOR_ID) return\n if (!payload.nodeId.startsWith('form:')) return\n const formKey = payload.nodeId.slice('form:'.length)\n const state = registry.forms.get(formKey)\n if (state === undefined) return\n // payload.path is `['Form value', 'form', ...pathSegments]` — the\n // first two segments are the inspector section + key, the rest is\n // the target form path the user edited. Pass the segment array\n // directly to `canonicalizePath`: join('.') would collapse a\n // literal-dot field key (`{\"user.email\": ...}`) into two segments,\n // writing to the wrong leaf.\n if (payload.path.length < 3) return\n const section = payload.path[0]\n if (section !== 'Form value') return\n const segments = payload.path.slice(2)\n const { segments: canonicalPath } = canonicalizePath(segments)\n state.setValueAtPath(canonicalPath, payload.state.value)\n refreshState()\n })\n\n // Initial sync so existing forms show up.\n syncForms()\n refreshTree()\n}\n"],"names":["canonicalizePath"],"mappings":";;;;AA0BA,MAAM,YAAA,GAAe,UAAA;AACrB,MAAM,iBAAA,GAAoB,iBAAA;AA8D1B,eAAsB,qBAAA,CACpB,KACA,QAAA,EACkB;AAClB,EAAA,IAAI,GAAA;AACJ,EAAA,IAAI;AACF,IAAA,GAAA,GAAO,MAAM,OAAO,mBAAmB,CAAA;AAAA,EAGzC,CAAA,CAAA,MAAQ;AAIN,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,MAAM,sBAAsB,GAAA,CAAI,mBAAA;AAChC,EAAA,IAAI,OAAO,mBAAA,KAAwB,UAAA,EAAY,OAAO,KAAA;AAEtD,EAAA,mBAAA;AAAA,IACE;AAAA,MACE,EAAA,EAAI,YAAA;AAAA,MACJ,KAAA,EAAO,UAAA;AAAA,MACP,WAAA,EAAa,UAAA;AAAA,MACb,QAAA,EAAU,sCAAA;AAAA,MACV,GAAA;AAAA,MACA,mBAAA,EAAqB,CAAC,eAAe;AAAA,KACvC;AAAA,IACA,CAAC,GAAA,KAAQ,IAAA,CAAK,GAAA,EAAK,KAAK,QAAQ;AAAA,GAClC;AACA,EAAA,OAAO,IAAA;AACT;AAEA,SAAS,IAAA,CAAK,GAAA,EAAwB,GAAA,EAAU,QAAA,EAAkC;AAIhF,EAAA,MAAM,gBAAA,uBAAuB,GAAA,EAAyB;AAEtD,EAAA,GAAA,CAAI,aAAa,EAAE,EAAA,EAAI,cAAc,KAAA,EAAO,UAAA,EAAY,KAAK,CAAA;AAC7D,EAAA,GAAA,CAAI,gBAAA,CAAiB,EAAE,EAAA,EAAI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AAK,CAAA;AACvD,IAAA,YAAA,EAAa;AAAA,EACf,CAAC,CAAA;AAGD,EAAA,SAAA,EAAU;AACV,EAAA,WAAA,EAAY;AACd;;;;"}
|
package/dist/chunks/devtools.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const canonicalStringify = require('../shared/attaform.CQN9R62B.cjs');
|
|
4
|
-
const index = require('../shared/attaform.
|
|
4
|
+
const index = require('../shared/attaform.C__F01CE.cjs');
|
|
5
5
|
|
|
6
6
|
const cyclicSentinel = "<cyclic>";
|
|
7
7
|
function fingerprintZodSchema(schema) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { c as canonicalStringify } from '../shared/attaform.BJGA_UOS.mjs';
|
|
2
|
-
import { k as kindOf, g as getIntersectionLeft, b as getIntersectionRight, c as unwrapLazy, d as unwrapInner, e as unwrapPipe, h as getDiscriminator, i as getDiscriminatedOptions, j as getUnionOptions, l as getRecordKeyType, m as getRecordValueType, n as getTupleItems, o as getSetValueType, p as getArrayElement, q as getObjectShape, r as getEnumValues, s as getLiteralValues, t as getChecks, v as getCatchDefault, x as getDefaultValue } from '../shared/attaform.
|
|
2
|
+
import { k as kindOf, g as getIntersectionLeft, b as getIntersectionRight, c as unwrapLazy, d as unwrapInner, e as unwrapPipe, h as getDiscriminator, i as getDiscriminatedOptions, j as getUnionOptions, l as getRecordKeyType, m as getRecordValueType, n as getTupleItems, o as getSetValueType, p as getArrayElement, q as getObjectShape, r as getEnumValues, s as getLiteralValues, t as getChecks, v as getCatchDefault, x as getDefaultValue } from '../shared/attaform.BceJrhQ7.mjs';
|
|
3
3
|
|
|
4
4
|
const cyclicSentinel = "<cyclic>";
|
|
5
5
|
function fingerprintZodSchema(schema) {
|
package/dist/esbuild.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const detectZodMajor = require('./shared/attaform.
|
|
3
|
+
const detectZodMajor = require('./shared/attaform.DoQm_Vkd.cjs');
|
|
4
4
|
|
|
5
5
|
function attaform(options = {}) {
|
|
6
6
|
const resolveZodAlias = options.resolveZodAlias !== false;
|
|
@@ -11,7 +11,7 @@ function attaform(options = {}) {
|
|
|
11
11
|
const root = build.initialOptions.absWorkingDir ?? options.root ?? process.cwd();
|
|
12
12
|
const target = detectZodMajor.resolveZodAliasTarget(root, "attaform/esbuild", resolveZodAlias, warnState);
|
|
13
13
|
if (target === null) return;
|
|
14
|
-
build.onResolve({ filter:
|
|
14
|
+
build.onResolve({ filter: detectZodMajor.REWRITABLE_ZOD_SPECIFIER_FILTER }, async (args) => {
|
|
15
15
|
const result = await build.resolve(target, {
|
|
16
16
|
kind: args.kind,
|
|
17
17
|
importer: args.importer,
|
package/dist/esbuild.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"esbuild.cjs","sources":["../src/esbuild.ts"],"sourcesContent":["/**\n * `attaform/esbuild` — esbuild plugin that rewrites `attaform
|
|
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
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/** Options for the esbuild `attaform()` plugin. */
|
|
2
2
|
interface AttaformEsbuildPluginOptions {
|
|
3
3
|
/**
|
|
4
|
-
* Rewrite `attaform/zod` imports at build time to the
|
|
5
|
-
* subpath. Default `true`. Set to `false` to keep the
|
|
6
|
-
* unified entry (ships both adapters).
|
|
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
7
|
*/
|
|
8
8
|
resolveZodAlias?: boolean;
|
|
9
9
|
/**
|
package/dist/esbuild.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/** Options for the esbuild `attaform()` plugin. */
|
|
2
2
|
interface AttaformEsbuildPluginOptions {
|
|
3
3
|
/**
|
|
4
|
-
* Rewrite `attaform/zod` imports at build time to the
|
|
5
|
-
* subpath. Default `true`. Set to `false` to keep the
|
|
6
|
-
* unified entry (ships both adapters).
|
|
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
7
|
*/
|
|
8
8
|
resolveZodAlias?: boolean;
|
|
9
9
|
/**
|
package/dist/esbuild.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/** Options for the esbuild `attaform()` plugin. */
|
|
2
2
|
interface AttaformEsbuildPluginOptions {
|
|
3
3
|
/**
|
|
4
|
-
* Rewrite `attaform/zod` imports at build time to the
|
|
5
|
-
* subpath. Default `true`. Set to `false` to keep the
|
|
6
|
-
* unified entry (ships both adapters).
|
|
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
7
|
*/
|
|
8
8
|
resolveZodAlias?: boolean;
|
|
9
9
|
/**
|
package/dist/esbuild.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as resolveZodAliasTarget } from './shared/attaform.
|
|
1
|
+
import { r as resolveZodAliasTarget, R as REWRITABLE_ZOD_SPECIFIER_FILTER } from './shared/attaform.DhnPb6nK.mjs';
|
|
2
2
|
|
|
3
3
|
function attaform(options = {}) {
|
|
4
4
|
const resolveZodAlias = options.resolveZodAlias !== false;
|
|
@@ -9,7 +9,7 @@ function attaform(options = {}) {
|
|
|
9
9
|
const root = build.initialOptions.absWorkingDir ?? options.root ?? process.cwd();
|
|
10
10
|
const target = resolveZodAliasTarget(root, "attaform/esbuild", resolveZodAlias, warnState);
|
|
11
11
|
if (target === null) return;
|
|
12
|
-
build.onResolve({ filter:
|
|
12
|
+
build.onResolve({ filter: REWRITABLE_ZOD_SPECIFIER_FILTER }, async (args) => {
|
|
13
13
|
const result = await build.resolve(target, {
|
|
14
14
|
kind: args.kind,
|
|
15
15
|
importer: args.importer,
|