@metaobjectsdev/codegen-ts 0.7.0-rc.8 → 0.7.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/generator.d.ts +9 -0
- package/dist/generator.d.ts.map +1 -1
- package/dist/generator.js.map +1 -1
- package/dist/generators/docs-data-builder.d.ts +16 -0
- package/dist/generators/docs-data-builder.d.ts.map +1 -0
- package/dist/generators/docs-data-builder.js +381 -0
- package/dist/generators/docs-data-builder.js.map +1 -0
- package/dist/generators/docs-data.d.ts +98 -0
- package/dist/generators/docs-data.d.ts.map +1 -0
- package/dist/generators/docs-data.js +43 -0
- package/dist/generators/docs-data.js.map +1 -0
- package/dist/generators/docs-file.d.ts +8 -0
- package/dist/generators/docs-file.d.ts.map +1 -0
- package/dist/generators/docs-file.js +77 -0
- package/dist/generators/docs-file.js.map +1 -0
- package/dist/generators/index.d.ts +5 -0
- package/dist/generators/index.d.ts.map +1 -1
- package/dist/generators/index.js +4 -0
- package/dist/generators/index.js.map +1 -1
- package/dist/generators/routes-file-hono.d.ts +21 -0
- package/dist/generators/routes-file-hono.d.ts.map +1 -0
- package/dist/generators/routes-file-hono.js +38 -0
- package/dist/generators/routes-file-hono.js.map +1 -0
- package/dist/generators/template-generator.d.ts +41 -0
- package/dist/generators/template-generator.d.ts.map +1 -0
- package/dist/generators/template-generator.js +62 -0
- package/dist/generators/template-generator.js.map +1 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/overwrite-policy.d.ts +39 -2
- package/dist/overwrite-policy.d.ts.map +1 -1
- package/dist/overwrite-policy.js +233 -13
- package/dist/overwrite-policy.js.map +1 -1
- package/dist/render-engine/framework-provider.d.ts +28 -0
- package/dist/render-engine/framework-provider.d.ts.map +1 -0
- package/dist/render-engine/framework-provider.js +104 -0
- package/dist/render-engine/framework-provider.js.map +1 -0
- package/dist/runner.d.ts +15 -1
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +44 -6
- package/dist/runner.js.map +1 -1
- package/dist/templates/docs-file.d.ts +17 -0
- package/dist/templates/docs-file.d.ts.map +1 -0
- package/dist/templates/docs-file.js +37 -0
- package/dist/templates/docs-file.js.map +1 -0
- package/dist/templates/routes-file-hono.d.ts +4 -0
- package/dist/templates/routes-file-hono.d.ts.map +1 -0
- package/dist/templates/routes-file-hono.js +119 -0
- package/dist/templates/routes-file-hono.js.map +1 -0
- package/package.json +6 -5
- package/src/generator.ts +9 -0
- package/src/generators/docs-data-builder.ts +470 -0
- package/src/generators/docs-data.ts +154 -0
- package/src/generators/docs-file.ts +87 -0
- package/src/generators/index.ts +17 -0
- package/src/generators/routes-file-hono.ts +48 -0
- package/src/generators/template-generator.ts +106 -0
- package/src/index.ts +33 -2
- package/src/overwrite-policy.ts +325 -14
- package/src/render-engine/framework-provider.ts +107 -0
- package/src/runner.ts +65 -6
- package/src/templates/docs-file.ts +51 -0
- package/src/templates/routes-file-hono.ts +142 -0
- package/templates/docs/entity-page.md.mustache +54 -0
package/dist/overwrite-policy.js
CHANGED
|
@@ -1,23 +1,243 @@
|
|
|
1
|
-
// Overwrite policy:
|
|
2
|
-
//
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
// Overwrite policy: per-file write decision using three-way merge against a
|
|
2
|
+
// canonical snapshot kept under `.metaobjects/.gen-state/`.
|
|
3
|
+
//
|
|
4
|
+
// Replaces the rc.11 marker-based clobber-or-refuse policy (strategy (a) from
|
|
5
|
+
// spike 002) with strategy (b) — git-merge-file-driven three-way merge. The
|
|
6
|
+
// `@generated` marker becomes purely informational (templates may still emit
|
|
7
|
+
// it for human readers); the policy no longer consults it.
|
|
8
|
+
//
|
|
9
|
+
// Per-file flow:
|
|
10
|
+
//
|
|
11
|
+
// 1. Render fresh content to a tmpfile.
|
|
12
|
+
// 2. If the output doesn't exist → write + copy to .gen-state/.
|
|
13
|
+
// 3. If .gen-state/<relPath> exists → run `git merge-file --diff3` against
|
|
14
|
+
// (current, .gen-state snapshot, fresh tmpfile). Exit 0 → clean merge,
|
|
15
|
+
// advance .gen-state to fresh content. Exit > 0 → leave conflict markers
|
|
16
|
+
// in the output file, do NOT advance .gen-state; status "conflict".
|
|
17
|
+
// 4. If .gen-state/<relPath> is absent but the file exists ("first-time
|
|
18
|
+
// regen on an existing file") → write-if-different against the existing
|
|
19
|
+
// file as the baseline (no merge, no clobber). The `baseline: "fresh"`
|
|
20
|
+
// flag opts into "overwrite from fresh and re-baseline".
|
|
21
|
+
//
|
|
22
|
+
// Integrity (caveat 2 from the spike): we keep a sha-256 of each canonical
|
|
23
|
+
// snapshot at `.gen-state/.hashes.json`. On load, mismatch → fall back to
|
|
24
|
+
// first-time semantics and warn naming the file so the user can investigate.
|
|
25
|
+
import { existsSync, readFileSync, writeFileSync, mkdirSync, copyFileSync, } from "node:fs";
|
|
26
|
+
import { dirname, join, isAbsolute, relative, resolve } from "node:path";
|
|
27
|
+
import { spawnSync } from "node:child_process";
|
|
28
|
+
import { tmpdir } from "node:os";
|
|
29
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
30
|
+
const HASHES_FILE = ".hashes.json";
|
|
31
|
+
function sha256(content) {
|
|
32
|
+
return createHash("sha256").update(content).digest("hex");
|
|
33
|
+
}
|
|
34
|
+
function loadHashes(genStateDir) {
|
|
35
|
+
const f = join(genStateDir, HASHES_FILE);
|
|
36
|
+
if (!existsSync(f))
|
|
37
|
+
return {};
|
|
38
|
+
try {
|
|
39
|
+
const txt = readFileSync(f, "utf-8");
|
|
40
|
+
const parsed = JSON.parse(txt);
|
|
41
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
42
|
+
return parsed;
|
|
43
|
+
}
|
|
44
|
+
return {};
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return {};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function saveHashes(genStateDir, hashes) {
|
|
51
|
+
mkdirSync(genStateDir, { recursive: true });
|
|
52
|
+
writeFileSync(join(genStateDir, HASHES_FILE), JSON.stringify(hashes, null, 2) + "\n");
|
|
53
|
+
}
|
|
54
|
+
function snapshotPath(genStateDir, relPath) {
|
|
55
|
+
// `.hashes.json` is reserved at the top of .gen-state/; relPath must never
|
|
56
|
+
// collide with it. Output paths derived from entity names ("Post.ts" etc.)
|
|
57
|
+
// are JS-identifier-shape so this is a non-issue in practice.
|
|
58
|
+
return join(genStateDir, relPath);
|
|
59
|
+
}
|
|
60
|
+
/** Synchronously copy `src` content into the snapshot at `<genStateDir>/<relPath>`
|
|
61
|
+
* and refresh the hash for `relPath`. */
|
|
62
|
+
function advanceSnapshot(genStateDir, relPath, content) {
|
|
63
|
+
const dest = snapshotPath(genStateDir, relPath);
|
|
64
|
+
mkdirSync(dirname(dest), { recursive: true });
|
|
65
|
+
writeFileSync(dest, content);
|
|
66
|
+
const hashes = loadHashes(genStateDir);
|
|
67
|
+
hashes[relPath] = sha256(content);
|
|
68
|
+
saveHashes(genStateDir, hashes);
|
|
69
|
+
}
|
|
70
|
+
/** Return the snapshot text iff present AND the hash matches; else undefined. */
|
|
71
|
+
function readSnapshotChecked(genStateDir, relPath) {
|
|
72
|
+
const path = snapshotPath(genStateDir, relPath);
|
|
73
|
+
if (!existsSync(path))
|
|
74
|
+
return undefined;
|
|
75
|
+
const text = readFileSync(path, "utf-8");
|
|
76
|
+
const hashes = loadHashes(genStateDir);
|
|
77
|
+
const expected = hashes[relPath];
|
|
78
|
+
if (expected !== undefined && expected !== sha256(text)) {
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
return { text };
|
|
82
|
+
}
|
|
83
|
+
/** Thrown when git is unavailable. Surfaces as a clear CLI error rather than
|
|
84
|
+
* a generic ENOENT halfway through a regen. */
|
|
85
|
+
export class GitMissingError extends Error {
|
|
86
|
+
constructor() {
|
|
87
|
+
super("meta gen: `git` binary not found on PATH. Three-way-merge regen " +
|
|
88
|
+
"requires git (any modern version). Install git and re-run.");
|
|
89
|
+
this.name = "GitMissingError";
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/** Run `git merge-file --diff3 -L<...> <out> <base> <fresh>`. The output is
|
|
93
|
+
* written in-place into `outPath`. Returns the exit code (0 = clean, > 0 =
|
|
94
|
+
* conflicts) and the resulting file contents.
|
|
95
|
+
*
|
|
96
|
+
* The git binary is "git" by default; set `META_GEN_GIT` in the environment
|
|
97
|
+
* to a different path (useful for tests that simulate "git not installed"). */
|
|
98
|
+
function runGitMergeFile(outPath, basePath, freshPath) {
|
|
99
|
+
const gitBin = process.env.META_GEN_GIT ?? "git";
|
|
100
|
+
let res;
|
|
101
|
+
try {
|
|
102
|
+
res = spawnSync(gitBin, [
|
|
103
|
+
"merge-file",
|
|
104
|
+
"--diff3",
|
|
105
|
+
"-L",
|
|
106
|
+
"your edits",
|
|
107
|
+
"-L",
|
|
108
|
+
"last generated",
|
|
109
|
+
"-L",
|
|
110
|
+
"fresh from meta gen",
|
|
111
|
+
outPath,
|
|
112
|
+
basePath,
|
|
113
|
+
freshPath,
|
|
114
|
+
], { encoding: "utf-8" });
|
|
115
|
+
}
|
|
116
|
+
catch (err) {
|
|
117
|
+
const msg = err.message ?? "";
|
|
118
|
+
if (msg.includes("ENOENT"))
|
|
119
|
+
throw new GitMissingError();
|
|
120
|
+
throw err;
|
|
121
|
+
}
|
|
122
|
+
if (res.error) {
|
|
123
|
+
const code = res.error.code;
|
|
124
|
+
if (code === "ENOENT")
|
|
125
|
+
throw new GitMissingError();
|
|
126
|
+
throw res.error;
|
|
127
|
+
}
|
|
128
|
+
// `git merge-file` returns the conflict count (0 = clean, > 0 = conflicts,
|
|
129
|
+
// < 0 = error). Negative is unexpected — surface verbatim.
|
|
130
|
+
const exitCode = res.status ?? 0;
|
|
131
|
+
if (exitCode < 0) {
|
|
132
|
+
throw new Error(`git merge-file failed for ${outPath}: ${res.stderr || res.stdout}`);
|
|
133
|
+
}
|
|
134
|
+
const mergedContent = readFileSync(outPath, "utf-8");
|
|
135
|
+
return { exitCode, stderr: res.stderr ?? "", mergedContent };
|
|
136
|
+
}
|
|
137
|
+
/** Write `content` to a freshly-named tmpfile under the OS tmpdir; return the
|
|
138
|
+
* path. Caller is responsible for cleanup (acceptable for codegen — tmpdir
|
|
139
|
+
* is process-scoped). */
|
|
140
|
+
function writeTmpfile(content) {
|
|
141
|
+
const dir = join(tmpdir(), "meta-gen-merge");
|
|
142
|
+
mkdirSync(dir, { recursive: true });
|
|
143
|
+
const path = join(dir, `${Date.now()}-${randomBytes(6).toString("hex")}.tmp`);
|
|
144
|
+
writeFileSync(path, content);
|
|
145
|
+
return path;
|
|
146
|
+
}
|
|
147
|
+
/** Resolve the snapshot key for a given output path. Falls back to a stable
|
|
148
|
+
* hash-of-path so unit tests that pass arbitrary tmpdir outputs still get a
|
|
149
|
+
* consistent .gen-state key. */
|
|
150
|
+
function defaultOutputRelPath(outputPath) {
|
|
151
|
+
// Use sha256 of the absolute path → hex; lets tests work without supplying
|
|
152
|
+
// an explicit relPath. NOT used by the runner — runGen always passes the
|
|
153
|
+
// real project-relative path.
|
|
154
|
+
return sha256(resolve(outputPath)).slice(0, 32);
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* The main entry point. Backward-compatible with the rc.11 signature: passing
|
|
158
|
+
* a `MergeStrategy` string as the third argument continues to work; passing
|
|
159
|
+
* an options object opts into three-way merge.
|
|
160
|
+
*/
|
|
161
|
+
export function decideAndWrite(path, content, optsOrStrategy = {}) {
|
|
162
|
+
const opts = typeof optsOrStrategy === "string"
|
|
163
|
+
? { strategy: optsOrStrategy }
|
|
164
|
+
: optsOrStrategy;
|
|
165
|
+
const strategy = opts.strategy ?? "overwrite";
|
|
166
|
+
const baseline = opts.baseline ?? "default";
|
|
167
|
+
const genStateDir = opts.genStateDir !== undefined
|
|
168
|
+
? (isAbsolute(opts.genStateDir)
|
|
169
|
+
? opts.genStateDir
|
|
170
|
+
: resolve(opts.genStateDir))
|
|
171
|
+
: join(tmpdir(), "meta-gen-state-fallback");
|
|
172
|
+
const relPath = opts.outputRelPath ?? defaultOutputRelPath(path);
|
|
173
|
+
// 1. First-time write — file doesn't exist.
|
|
8
174
|
if (!existsSync(path)) {
|
|
9
175
|
mkdirSync(dirname(path), { recursive: true });
|
|
10
176
|
writeFileSync(path, content);
|
|
177
|
+
advanceSnapshot(genStateDir, relPath, content);
|
|
11
178
|
return { path, status: "new" };
|
|
12
179
|
}
|
|
13
|
-
const current = readFileSync(path, "utf-8");
|
|
14
|
-
if (!current.includes(GENERATED_HEADER)) {
|
|
15
|
-
return { path, status: "refused" };
|
|
16
|
-
}
|
|
17
180
|
if (strategy === "skip-existing") {
|
|
18
181
|
return { path, status: "skipped" };
|
|
19
182
|
}
|
|
20
|
-
|
|
21
|
-
|
|
183
|
+
// 2. File exists. Load the canonical snapshot if any.
|
|
184
|
+
const snapshot = readSnapshotChecked(genStateDir, relPath);
|
|
185
|
+
// 3. First-time regen on a pre-existing file (no snapshot).
|
|
186
|
+
if (snapshot === undefined) {
|
|
187
|
+
const current = readFileSync(path, "utf-8");
|
|
188
|
+
if (baseline === "fresh") {
|
|
189
|
+
// Opt-in escape hatch: overwrite and seed the snapshot from fresh.
|
|
190
|
+
if (current === content) {
|
|
191
|
+
advanceSnapshot(genStateDir, relPath, content);
|
|
192
|
+
return { path, status: "unchanged" };
|
|
193
|
+
}
|
|
194
|
+
writeFileSync(path, content);
|
|
195
|
+
advanceSnapshot(genStateDir, relPath, content);
|
|
196
|
+
return { path, status: "overwrite" };
|
|
197
|
+
}
|
|
198
|
+
// Default: write-if-different. The EXISTING file is treated as the
|
|
199
|
+
// canonical baseline so subsequent runs do real three-way merges. If
|
|
200
|
+
// fresh output is identical, just seed the snapshot. If different, write
|
|
201
|
+
// the fresh content + seed snapshot — there's no marker policy left to
|
|
202
|
+
// refuse on, but this is the contract documented in the runbook (no
|
|
203
|
+
// marker check; users with hand-written files should never have the
|
|
204
|
+
// codegen output path colliding with them).
|
|
205
|
+
if (current === content) {
|
|
206
|
+
advanceSnapshot(genStateDir, relPath, current);
|
|
207
|
+
return { path, status: "unchanged" };
|
|
208
|
+
}
|
|
209
|
+
writeFileSync(path, content);
|
|
210
|
+
advanceSnapshot(genStateDir, relPath, content);
|
|
211
|
+
return { path, status: "overwrite" };
|
|
212
|
+
}
|
|
213
|
+
// 4. Snapshot exists — real three-way merge.
|
|
214
|
+
const current = readFileSync(path, "utf-8");
|
|
215
|
+
// Fast path: nothing changed.
|
|
216
|
+
if (current === content && snapshot.text === content) {
|
|
217
|
+
return { path, status: "unchanged" };
|
|
218
|
+
}
|
|
219
|
+
const baseTmp = writeTmpfile(snapshot.text);
|
|
220
|
+
const freshTmp = writeTmpfile(content);
|
|
221
|
+
const outcome = runGitMergeFile(path, baseTmp, freshTmp);
|
|
222
|
+
if (outcome.exitCode === 0) {
|
|
223
|
+
// Clean merge — advance the canonical snapshot to fresh.
|
|
224
|
+
advanceSnapshot(genStateDir, relPath, content);
|
|
225
|
+
// Distinguish "user had no changes vs canonical" from "merge integrated
|
|
226
|
+
// edits". The fresh equals snapshot case happened above (fast path) — so
|
|
227
|
+
// if outcome.mergedContent equals fresh we report a plain overwrite,
|
|
228
|
+
// otherwise it's a merge that pulled in user edits.
|
|
229
|
+
if (outcome.mergedContent === content) {
|
|
230
|
+
return { path, status: "overwrite" };
|
|
231
|
+
}
|
|
232
|
+
return { path, status: "merged" };
|
|
233
|
+
}
|
|
234
|
+
// Conflict — do NOT advance the snapshot. The output now contains diff3
|
|
235
|
+
// markers from git merge-file.
|
|
236
|
+
return {
|
|
237
|
+
path,
|
|
238
|
+
status: "conflict",
|
|
239
|
+
conflictHint: "merge conflict — resolve `<<<<<<<` markers and re-run `meta gen` to " +
|
|
240
|
+
"advance the canonical state.",
|
|
241
|
+
};
|
|
22
242
|
}
|
|
23
243
|
//# sourceMappingURL=overwrite-policy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overwrite-policy.js","sourceRoot":"","sources":["../src/overwrite-policy.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"overwrite-policy.js","sourceRoot":"","sources":["../src/overwrite-policy.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,4DAA4D;AAC5D,EAAE;AACF,8EAA8E;AAC9E,4EAA4E;AAC5E,6EAA6E;AAC7E,2DAA2D;AAC3D,EAAE;AACF,iBAAiB;AACjB,EAAE;AACF,0CAA0C;AAC1C,kEAAkE;AAClE,6EAA6E;AAC7E,4EAA4E;AAC5E,8EAA8E;AAC9E,yEAAyE;AACzE,0EAA0E;AAC1E,6EAA6E;AAC7E,4EAA4E;AAC5E,8DAA8D;AAC9D,EAAE;AACF,2EAA2E;AAC3E,0EAA0E;AAC1E,6EAA6E;AAE7E,OAAO,EACL,UAAU,EACV,YAAY,EACZ,aAAa,EACb,SAAS,EACT,YAAY,GACb,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AA+CtD,MAAM,WAAW,GAAG,cAAc,CAAC;AAInC,SAAS,MAAM,CAAC,OAAwB;IACtC,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC5D,CAAC;AAED,SAAS,UAAU,CAAC,WAAmB;IACrC,MAAM,CAAC,GAAG,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;IACzC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;QAAE,OAAO,EAAE,CAAC;I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C,CAAC;IAED,6CAA6C;IAC7C,MAAM,OAAO,GAAG,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAE5C,8BAA8B;IAC9B,IAAI,OAAO,KAAK,OAAO,IAAI,QAAQ,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QACrD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;IACvC,CAAC;IAED,MAAM,OAAO,GAAG,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC5C,MAAM,QAAQ,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;IAEvC,MAAM,OAAO,GAAG,eAAe,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IAEzD,IAAI,OAAO,CAAC,QAAQ,KAAK,CAAC,EAAE,CAAC;QAC3B,yDAAyD;QACzD,eAAe,CAAC,WAAW,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAC/C,wEAAwE;QACxE,yEAAyE;QACzE,qEAAqE;QACrE,oDAAoD;QACpD,IAAI,OAAO,CAAC,aAAa,KAAK,OAAO,EAAE,CAAC;YACtC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;QACvC,CAAC;QACD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;IACpC,CAAC;IAED,wEAAwE;IACxE,+BAA+B;IAC/B,OAAO;QACL,IAAI;QACJ,MAAM,EAAE,UAAU;QAClB,YAAY,EACV,sEAAsE;YACtE,8BAA8B;KACjC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Provider } from "@metaobjectsdev/render";
|
|
2
|
+
/** Provider backed by an arbitrary on-disk template directory. References
|
|
3
|
+
* resolve as `<dir>/<ref>.mustache`. Used by both the framework default
|
|
4
|
+
* and adopter override paths. */
|
|
5
|
+
export declare class FileSystemProvider implements Provider {
|
|
6
|
+
private readonly root;
|
|
7
|
+
constructor(root: string);
|
|
8
|
+
resolve(ref: string): string | undefined;
|
|
9
|
+
}
|
|
10
|
+
/** The framework defaults provider — resolves refs against codegen-ts's own
|
|
11
|
+
* `templates/` directory. */
|
|
12
|
+
export declare const frameworkTemplatesProvider: Provider;
|
|
13
|
+
/** Compose providers: first match wins. Adopters typically chain
|
|
14
|
+
* `[projectProvider, frameworkTemplatesProvider]` so their own templates
|
|
15
|
+
* override the framework defaults. */
|
|
16
|
+
export declare class ProviderChain implements Provider {
|
|
17
|
+
private readonly providers;
|
|
18
|
+
constructor(providers: readonly Provider[]);
|
|
19
|
+
resolve(ref: string): string | undefined;
|
|
20
|
+
}
|
|
21
|
+
/** Build a project-scoped Provider: layers an optional project `templates/`
|
|
22
|
+
* directory over the framework defaults. Returns just the framework provider
|
|
23
|
+
* when `projectRoot` is undefined / its `templates/` dir doesn't exist. */
|
|
24
|
+
export declare function projectProvider(projectRoot?: string): Provider;
|
|
25
|
+
/** Exposed for tests that want to inspect / clear the resolved framework
|
|
26
|
+
* templates directory (don't use outside tests). */
|
|
27
|
+
export declare const __frameworkTemplatesDirForTests: string;
|
|
28
|
+
//# sourceMappingURL=framework-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"framework-provider.d.ts","sourceRoot":"","sources":["../../src/render-engine/framework-provider.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AA6CvD;;kCAEkC;AAClC,qBAAa,kBAAmB,YAAW,QAAQ;IACrC,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,MAAM;IACzC,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;CAKzC;AAED;8BAC8B;AAC9B,eAAO,MAAM,0BAA0B,EAAE,QAExC,CAAC;AAEF;;uCAEuC;AACvC,qBAAa,aAAc,YAAW,QAAQ;IAChC,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAAT,SAAS,EAAE,SAAS,QAAQ,EAAE;IAC3D,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;CAOzC;AAED;;4EAE4E;AAC5E,wBAAgB,eAAe,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,QAAQ,CAQ9D;AAED;qDACqD;AACrD,eAAO,MAAM,+BAA+B,QAA0B,CAAC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// FrameworkTemplateProvider — resolves template refs (e.g. "docs/entity-page.md")
|
|
2
|
+
// against the codegen-ts package's `templates/` directory. Adopters who want
|
|
3
|
+
// to override a framework template create their own `templates/<ref>.mustache`
|
|
4
|
+
// file in their project; `ProviderChain` (below) consults the project first
|
|
5
|
+
// and falls back to the framework defaults.
|
|
6
|
+
//
|
|
7
|
+
// Decision D1 from the template-driven-codegen design — hybrid: framework
|
|
8
|
+
// ships defaults, adopters override by file-system convention.
|
|
9
|
+
//
|
|
10
|
+
// The framework Provider is filesystem-backed so it works identically whether
|
|
11
|
+
// codegen-ts runs from source (bun, dev) or from `dist/` (npm install). The
|
|
12
|
+
// `templates/` directory is included in the published tarball via
|
|
13
|
+
// package.json `files: ["dist", "src", "templates", ...]`.
|
|
14
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
15
|
+
import { join, resolve, dirname } from "node:path";
|
|
16
|
+
import { fileURLToPath } from "node:url";
|
|
17
|
+
/** Canonical shipped template — used to verify a candidate framework
|
|
18
|
+
* templates directory actually contains our defaults. Without this check a
|
|
19
|
+
* hoisted-install layout (pnpm/bun workspaces) can walk up to a CONSUMER
|
|
20
|
+
* package.json and silently return a templates dir that doesn't exist. */
|
|
21
|
+
const CANONICAL_TEMPLATE_REL = "docs/entity-page.md.mustache";
|
|
22
|
+
/** Walk up from `start` until we find a `package.json` whose neighbour
|
|
23
|
+
* `templates/` directory contains our canonical shipped template (i.e., the
|
|
24
|
+
* codegen-ts package root). Works the same way from
|
|
25
|
+
* `src/render-engine/framework-provider.ts` (during dev) and
|
|
26
|
+
* `dist/render-engine/framework-provider.js` (after `npm install`). */
|
|
27
|
+
function findFrameworkTemplatesDir(start) {
|
|
28
|
+
let dir = start;
|
|
29
|
+
while (true) {
|
|
30
|
+
const pkgJson = join(dir, "package.json");
|
|
31
|
+
if (existsSync(pkgJson)) {
|
|
32
|
+
const templatesDir = join(dir, "templates");
|
|
33
|
+
// Assert we landed at the codegen-ts package root, not a consumer's.
|
|
34
|
+
if (existsSync(join(templatesDir, CANONICAL_TEMPLATE_REL))) {
|
|
35
|
+
return templatesDir;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const parent = dirname(dir);
|
|
39
|
+
if (parent === dir)
|
|
40
|
+
break;
|
|
41
|
+
dir = parent;
|
|
42
|
+
}
|
|
43
|
+
throw new Error(`framework templates dir unresolved: walked up from ${start} without finding a package.json ` +
|
|
44
|
+
`whose templates/${CANONICAL_TEMPLATE_REL} exists. This usually means codegen-ts was installed ` +
|
|
45
|
+
`via a hoisted layout (pnpm/bun workspaces) into an unexpected location, or the published ` +
|
|
46
|
+
`tarball is missing the templates/ directory.`);
|
|
47
|
+
}
|
|
48
|
+
// In ESM (CLAUDE.md: "ESM only. No CommonJS."), `import.meta.url` is
|
|
49
|
+
// guaranteed to be a file: URL; no defensive try/catch needed.
|
|
50
|
+
const SELF_DIR = dirname(fileURLToPath(import.meta.url));
|
|
51
|
+
const FRAMEWORK_TEMPLATES_DIR = findFrameworkTemplatesDir(SELF_DIR);
|
|
52
|
+
/** Provider backed by an arbitrary on-disk template directory. References
|
|
53
|
+
* resolve as `<dir>/<ref>.mustache`. Used by both the framework default
|
|
54
|
+
* and adopter override paths. */
|
|
55
|
+
export class FileSystemProvider {
|
|
56
|
+
root;
|
|
57
|
+
constructor(root) {
|
|
58
|
+
this.root = root;
|
|
59
|
+
}
|
|
60
|
+
resolve(ref) {
|
|
61
|
+
const path = join(this.root, `${ref}.mustache`);
|
|
62
|
+
if (!existsSync(path))
|
|
63
|
+
return undefined;
|
|
64
|
+
return readFileSync(path, "utf-8");
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/** The framework defaults provider — resolves refs against codegen-ts's own
|
|
68
|
+
* `templates/` directory. */
|
|
69
|
+
export const frameworkTemplatesProvider = new FileSystemProvider(FRAMEWORK_TEMPLATES_DIR);
|
|
70
|
+
/** Compose providers: first match wins. Adopters typically chain
|
|
71
|
+
* `[projectProvider, frameworkTemplatesProvider]` so their own templates
|
|
72
|
+
* override the framework defaults. */
|
|
73
|
+
export class ProviderChain {
|
|
74
|
+
providers;
|
|
75
|
+
constructor(providers) {
|
|
76
|
+
this.providers = providers;
|
|
77
|
+
}
|
|
78
|
+
resolve(ref) {
|
|
79
|
+
for (const p of this.providers) {
|
|
80
|
+
const text = p.resolve(ref);
|
|
81
|
+
if (text !== undefined)
|
|
82
|
+
return text;
|
|
83
|
+
}
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/** Build a project-scoped Provider: layers an optional project `templates/`
|
|
88
|
+
* directory over the framework defaults. Returns just the framework provider
|
|
89
|
+
* when `projectRoot` is undefined / its `templates/` dir doesn't exist. */
|
|
90
|
+
export function projectProvider(projectRoot) {
|
|
91
|
+
if (projectRoot === undefined)
|
|
92
|
+
return frameworkTemplatesProvider;
|
|
93
|
+
const projTemplates = resolve(projectRoot, "templates");
|
|
94
|
+
if (!existsSync(projTemplates))
|
|
95
|
+
return frameworkTemplatesProvider;
|
|
96
|
+
return new ProviderChain([
|
|
97
|
+
new FileSystemProvider(projTemplates),
|
|
98
|
+
frameworkTemplatesProvider,
|
|
99
|
+
]);
|
|
100
|
+
}
|
|
101
|
+
/** Exposed for tests that want to inspect / clear the resolved framework
|
|
102
|
+
* templates directory (don't use outside tests). */
|
|
103
|
+
export const __frameworkTemplatesDirForTests = FRAMEWORK_TEMPLATES_DIR;
|
|
104
|
+
//# sourceMappingURL=framework-provider.js.map
|
|
@@ -0,0 +1 @@
|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AC,aAAa,CAAC;QAAE,OAAO,0BAA0B,CAAC;IAClE,OAAO,IAAI,aAAa,CAAC;QACvB,IAAI,kBAAkB,CAAC,aAAa,CAAC;QACrC,0BAA0B;KAC3B,CAAC,CAAC;AACL,CAAC;AAED;qDACqD;AACrD,MAAM,CAAC,MAAM,+BAA+B,GAAG,uBAAuB,CAAC"}
|
package/dist/runner.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { MetaData } from "@metaobjectsdev/metadata";
|
|
2
2
|
import type { MetaobjectsGenConfig } from "./metaobjects-config.js";
|
|
3
|
-
import { type WriteResult, type MergeStrategy } from "./overwrite-policy.js";
|
|
3
|
+
import { type WriteResult, type MergeStrategy, type BaselineMode } from "./overwrite-policy.js";
|
|
4
4
|
export interface RunGenOpts {
|
|
5
5
|
config: MetaobjectsGenConfig;
|
|
6
6
|
metadata: MetaData;
|
|
@@ -8,10 +8,24 @@ export interface RunGenOpts {
|
|
|
8
8
|
entityFilter?: string[];
|
|
9
9
|
/** Overwrite strategy passed to decideAndWrite. Defaults to "overwrite". */
|
|
10
10
|
mergeStrategy?: MergeStrategy;
|
|
11
|
+
/** Project root (used to derive the .gen-state/ snapshot directory and to
|
|
12
|
+
* key snapshots by project-relative output path). When omitted, falls back
|
|
13
|
+
* to process.cwd(). */
|
|
14
|
+
projectRoot?: string;
|
|
15
|
+
/** Override the snapshot directory location. Defaults to
|
|
16
|
+
* `<projectRoot>/.metaobjects/.gen-state/`. */
|
|
17
|
+
genStateDir?: string;
|
|
18
|
+
/** First-time-on-existing-file behavior. Defaults to "default" (write-if-
|
|
19
|
+
* different). "fresh" → overwrite and re-baseline (the `--baseline=fresh`
|
|
20
|
+
* CLI flag). */
|
|
21
|
+
baseline?: BaselineMode;
|
|
11
22
|
}
|
|
12
23
|
export interface RunGenResult {
|
|
13
24
|
files: WriteResult[];
|
|
14
25
|
warnings: string[];
|
|
26
|
+
/** Subset of `files` with status "conflict" — surfaced separately so the
|
|
27
|
+
* CLI can print the end-of-run summary. */
|
|
28
|
+
conflicts: WriteResult[];
|
|
15
29
|
}
|
|
16
30
|
export declare function runGen(opts: RunGenOpts): Promise<RunGenResult>;
|
|
17
31
|
//# sourceMappingURL=runner.d.ts.map
|
package/dist/runner.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAc,MAAM,0BAA0B,CAAC;AAGrE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAMpE,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,YAAY,EAClB,MAAM,uBAAuB,CAAC;AAM/B,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,oBAAoB,CAAC;IAC7B,QAAQ,EAAE,QAAQ,CAAC;IACnB,0CAA0C;IAC1C,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,4EAA4E;IAC5E,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B;;4BAEwB;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;oDACgD;IAChD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;qBAEiB;IACjB,QAAQ,CAAC,EAAE,YAAY,CAAC;CACzB;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB;gDAC4C;IAC5C,SAAS,EAAE,WAAW,EAAE,CAAC;CAC1B;AAED,wBAAsB,MAAM,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC,CA0LpE"}
|
package/dist/runner.js
CHANGED
|
@@ -1,16 +1,35 @@
|
|
|
1
|
-
import { join } from "node:path";
|
|
1
|
+
import { join, relative, resolve, isAbsolute } from "node:path";
|
|
2
|
+
import { tmpdir } from "node:os";
|
|
2
3
|
import { MetaRoot } from "@metaobjectsdev/metadata";
|
|
3
4
|
import { normalizeConfig, DEFAULT_TARGET_NAME } from "./metaobjects-config.js";
|
|
4
5
|
import { buildPkMap } from "./pk-resolver.js";
|
|
5
6
|
import { buildRelationMap } from "./relation-resolver.js";
|
|
6
7
|
import { makeRenderContext } from "./render-context.js";
|
|
7
|
-
import { decideAndWrite } from "./overwrite-policy.js";
|
|
8
|
+
import { decideAndWrite, } from "./overwrite-policy.js";
|
|
8
9
|
/** JS-identifier-shape only. Prevents filesystem traversal when metadata comes
|
|
9
10
|
* from untrusted sources (e.g. MCP). Mirrors the guard in legacy generate.ts. */
|
|
10
11
|
const VALID_ENTITY_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
11
12
|
export async function runGen(opts) {
|
|
12
13
|
const warnings = [];
|
|
13
14
|
const strategy = opts.mergeStrategy ?? "overwrite";
|
|
15
|
+
const baseline = opts.baseline ?? "default";
|
|
16
|
+
// When projectRoot is not supplied we DON'T fall back to process.cwd() —
|
|
17
|
+
// that would leak .gen-state/ into whatever directory happens to be cwd
|
|
18
|
+
// (e.g. the package dir during a unit-test run). Instead, fall back to a
|
|
19
|
+
// process-isolated tmpdir, which gives the new-write semantics every call
|
|
20
|
+
// (the snapshot exists only for the current process). The CLI's
|
|
21
|
+
// `genCommand` always passes a real projectRoot, so this fallback only
|
|
22
|
+
// affects programmatic callers (tests, library embedding).
|
|
23
|
+
const projectRoot = opts.projectRoot !== undefined
|
|
24
|
+
? (isAbsolute(opts.projectRoot) ? opts.projectRoot : resolve(opts.projectRoot))
|
|
25
|
+
: undefined;
|
|
26
|
+
const genStateDir = opts.genStateDir !== undefined
|
|
27
|
+
? (isAbsolute(opts.genStateDir)
|
|
28
|
+
? opts.genStateDir
|
|
29
|
+
: resolve(projectRoot ?? process.cwd(), opts.genStateDir))
|
|
30
|
+
: (projectRoot !== undefined
|
|
31
|
+
? join(projectRoot, ".metaobjects", ".gen-state")
|
|
32
|
+
: join(tmpdir(), `meta-gen-state-${process.pid}`));
|
|
14
33
|
// loadMemory now returns MetaRoot; guard here also covers callers that pass a
|
|
15
34
|
// plain MetaData (e.g. test helpers that build trees programmatically).
|
|
16
35
|
if (!(opts.metadata instanceof MetaRoot)) {
|
|
@@ -28,7 +47,7 @@ export async function runGen(opts) {
|
|
|
28
47
|
? "no object children match the provided entityFilter"
|
|
29
48
|
: "root has no object children";
|
|
30
49
|
warnings.push(`No entities to generate — ${reason}.`);
|
|
31
|
-
return { files: [], warnings };
|
|
50
|
+
return { files: [], warnings, conflicts: [] };
|
|
32
51
|
}
|
|
33
52
|
const safeEntities = [];
|
|
34
53
|
for (const entity of filtered) {
|
|
@@ -39,7 +58,7 @@ export async function runGen(opts) {
|
|
|
39
58
|
safeEntities.push(entity);
|
|
40
59
|
}
|
|
41
60
|
if (safeEntities.length === 0) {
|
|
42
|
-
return { files: [], warnings };
|
|
61
|
+
return { files: [], warnings, conflicts: [] };
|
|
43
62
|
}
|
|
44
63
|
// 2. Resolve targets + entity-module target.
|
|
45
64
|
const config = normalizeConfig(opts.config);
|
|
@@ -99,6 +118,7 @@ export async function runGen(opts) {
|
|
|
99
118
|
outputLayout: selfTarget.outputLayout,
|
|
100
119
|
},
|
|
101
120
|
renderContext,
|
|
121
|
+
...(projectRoot !== undefined && { projectRoot }),
|
|
102
122
|
warn: (msg) => warnings.push(`[${generator.name}] ${msg}`),
|
|
103
123
|
};
|
|
104
124
|
let files;
|
|
@@ -122,14 +142,32 @@ export async function runGen(opts) {
|
|
|
122
142
|
}
|
|
123
143
|
// 5. Write phase.
|
|
124
144
|
const writes = [];
|
|
145
|
+
const conflicts = [];
|
|
125
146
|
for (const file of emitted) {
|
|
126
|
-
|
|
147
|
+
// Key the snapshot by project-relative path so multi-target projects keep
|
|
148
|
+
// distinct entries (e.g. `database/Post.ts` vs `web/Post.queries.ts`).
|
|
149
|
+
// Without an explicit projectRoot we let decideAndWrite derive a stable
|
|
150
|
+
// hash-of-path key — fine for ephemeral test runs.
|
|
151
|
+
const policyOpts = {
|
|
152
|
+
strategy,
|
|
153
|
+
genStateDir,
|
|
154
|
+
baseline,
|
|
155
|
+
};
|
|
156
|
+
if (projectRoot !== undefined) {
|
|
157
|
+
policyOpts.outputRelPath = relative(projectRoot, file.fullPath);
|
|
158
|
+
}
|
|
159
|
+
const result = decideAndWrite(file.fullPath, file.content, policyOpts);
|
|
127
160
|
writes.push(result);
|
|
161
|
+
if (result.status === "conflict") {
|
|
162
|
+
conflicts.push(result);
|
|
163
|
+
warnings.push(`Merge conflict in ${file.fullPath}: resolve diff3 markers and re-run ` +
|
|
164
|
+
`'meta gen' to advance the canonical state.`);
|
|
165
|
+
}
|
|
128
166
|
if (result.status === "refused") {
|
|
129
167
|
warnings.push(`Refused to overwrite ${file.fullPath}: file exists without @generated header. ` +
|
|
130
168
|
`Move to a different outDir, delete the file, or add the header to opt in.`);
|
|
131
169
|
}
|
|
132
170
|
}
|
|
133
|
-
return { files: writes, warnings };
|
|
171
|
+
return { files: writes, warnings, conflicts };
|
|
134
172
|
}
|
|
135
173
|
//# sourceMappingURL=runner.js.map
|
package/dist/runner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAGpD,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE/E,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,
|
|
1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C;gBACvE,4CAA4C,CAC7C,CAAC;QACJ,CAAC;QACD,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAChC,QAAQ,CAAC,IAAI,CACX,wBAAwB,IAAI,CAAC,QAAQ,2CAA2C;gBAChF,2EAA2E,CAC5E,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;AAChD,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { MetaObject, MetaRoot } from "@metaobjectsdev/metadata";
|
|
2
|
+
import type { Dialect } from "../column-mapper.js";
|
|
3
|
+
import type { ColumnNamingStrategy } from "../metaobjects-config.js";
|
|
4
|
+
export interface DocsRenderOpts {
|
|
5
|
+
dialect: Dialect;
|
|
6
|
+
columnNamingStrategy?: ColumnNamingStrategy;
|
|
7
|
+
loadedRoot: MetaRoot;
|
|
8
|
+
/** Names of generators present in the pipeline — drives the "Generated code"
|
|
9
|
+
* section. Always includes "entity-file" implicitly. Recognized names:
|
|
10
|
+
* "queries-file", "routes-file", "routes-file-hono". */
|
|
11
|
+
generatorNames?: ReadonlySet<string>;
|
|
12
|
+
}
|
|
13
|
+
/** Backward-compatible entry point: builds the EntityDocData payload and
|
|
14
|
+
* renders it via the framework template. Byte-identical to the hand-coded
|
|
15
|
+
* rc.11 output (gated by `docs-file-conformance.test.ts`). */
|
|
16
|
+
export declare function renderDocsFile(entity: MetaObject, opts: DocsRenderOpts): string;
|
|
17
|
+
//# sourceMappingURL=docs-file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs-file.d.ts","sourceRoot":"","sources":["../../src/templates/docs-file.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAKrE,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IAC5C,UAAU,EAAE,QAAQ,CAAC;IACrB;;6DAEyD;IACzD,cAAc,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CACtC;AAED;;+DAE+D;AAC/D,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,cAAc,GAAG,MAAM,CAiB/E"}
|