@velastack/patterns 0.2.1 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/chunks/{collections-wIKcIKzY.js → collections-1Z0NCLM-.js} +2 -2
  2. package/dist/chunks/{collections-wIKcIKzY.js.map → collections-1Z0NCLM-.js.map} +1 -1
  3. package/dist/chunks/{generate-vRi-W3rL.js → generate-mchSz-tm.js} +3 -3
  4. package/dist/chunks/{generate-vRi-W3rL.js.map → generate-mchSz-tm.js.map} +1 -1
  5. package/dist/chunks/{generate.runtime-CNrtLDCf.js → generate.runtime-BB-U8d52.js} +3 -3
  6. package/dist/chunks/{generate.runtime-CNrtLDCf.js.map → generate.runtime-BB-U8d52.js.map} +1 -1
  7. package/dist/chunks/{generate.runtime--0bYEUP_.js → generate.runtime-C5TE2jyc.js} +2 -2
  8. package/dist/chunks/{generate.runtime--0bYEUP_.js.map → generate.runtime-C5TE2jyc.js.map} +1 -1
  9. package/dist/chunks/{generate.runtime-CQWygx-F.js → generate.runtime-C7Shwovm.js} +3 -3
  10. package/dist/chunks/{generate.runtime-CQWygx-F.js.map → generate.runtime-C7Shwovm.js.map} +1 -1
  11. package/dist/chunks/{generate.runtime-BlK7yHff.js → generate.runtime-C8Y2mS0B.js} +3 -3
  12. package/dist/chunks/{generate.runtime-BlK7yHff.js.map → generate.runtime-C8Y2mS0B.js.map} +1 -1
  13. package/dist/chunks/{generate.runtime-BX0QcpGg.js → generate.runtime-CL-fRmd9.js} +3 -3
  14. package/dist/chunks/{generate.runtime-BX0QcpGg.js.map → generate.runtime-CL-fRmd9.js.map} +1 -1
  15. package/dist/chunks/{generate.runtime-DpgPAnEd.js → generate.runtime-CRcQrxEJ.js} +6 -6
  16. package/dist/chunks/{generate.runtime-DpgPAnEd.js.map → generate.runtime-CRcQrxEJ.js.map} +1 -1
  17. package/dist/chunks/{generate.runtime-CFwzS666.js → generate.runtime-Cdep21LK.js} +2 -2
  18. package/dist/chunks/{generate.runtime-CFwzS666.js.map → generate.runtime-Cdep21LK.js.map} +1 -1
  19. package/dist/chunks/{generate.runtime-4QI3es6J.js → generate.runtime-CmBcOojv.js} +3 -3
  20. package/dist/chunks/{generate.runtime-4QI3es6J.js.map → generate.runtime-CmBcOojv.js.map} +1 -1
  21. package/dist/chunks/{generate.runtime-BOLZHcGN.js → generate.runtime-CpKaHLG6.js} +2 -2
  22. package/dist/chunks/{generate.runtime-BOLZHcGN.js.map → generate.runtime-CpKaHLG6.js.map} +1 -1
  23. package/dist/chunks/{generate.runtime-CQ0Veyk4.js → generate.runtime-DEPMu4l8.js} +4 -4
  24. package/dist/chunks/{generate.runtime-CQ0Veyk4.js.map → generate.runtime-DEPMu4l8.js.map} +1 -1
  25. package/dist/chunks/{generate.runtime-DOBfTVW3.js → generate.runtime-DJJTAUe-.js} +4 -4
  26. package/dist/chunks/{generate.runtime-DOBfTVW3.js.map → generate.runtime-DJJTAUe-.js.map} +1 -1
  27. package/dist/chunks/{generate.runtime-CFKrhkAA.js → generate.runtime-DZR09ORc.js} +2 -2
  28. package/dist/chunks/{generate.runtime-CFKrhkAA.js.map → generate.runtime-DZR09ORc.js.map} +1 -1
  29. package/dist/chunks/{generate.runtime-Dbhctzy1.js → generate.runtime-De1TeiUr.js} +2 -2
  30. package/dist/chunks/{generate.runtime-Dbhctzy1.js.map → generate.runtime-De1TeiUr.js.map} +1 -1
  31. package/dist/chunks/{generate.runtime-CNwy0UB2.js → generate.runtime-O_XZsZZ0.js} +2 -2
  32. package/dist/chunks/{generate.runtime-CNwy0UB2.js.map → generate.runtime-O_XZsZZ0.js.map} +1 -1
  33. package/dist/chunks/{generate.runtime-CAzHPuHk.js → generate.runtime-QL0UvDUK.js} +3 -3
  34. package/dist/chunks/{generate.runtime-CAzHPuHk.js.map → generate.runtime-QL0UvDUK.js.map} +1 -1
  35. package/dist/chunks/{generate.runtime-C4wcEIc9.js → generate.runtime-mFZIMpFZ.js} +4 -4
  36. package/dist/chunks/{generate.runtime-C4wcEIc9.js.map → generate.runtime-mFZIMpFZ.js.map} +1 -1
  37. package/dist/chunks/{generate.runtime-BmW0th7X.js → generate.runtime-pwEIGBEe.js} +3 -3
  38. package/dist/chunks/{generate.runtime-BmW0th7X.js.map → generate.runtime-pwEIGBEe.js.map} +1 -1
  39. package/dist/chunks/pocketbase-059B1oot.js +228 -0
  40. package/dist/chunks/pocketbase-059B1oot.js.map +1 -0
  41. package/dist/chunks/{shared-BZlvCHX8.js → shared-CaHmNkZE.js} +2 -2
  42. package/dist/chunks/{shared-BZlvCHX8.js.map → shared-CaHmNkZE.js.map} +1 -1
  43. package/dist/chunks/{ts-morph-helpers-Bk82Z2n7.js → ts-morph-helpers-7qF9S2k7.js} +11 -1
  44. package/dist/chunks/ts-morph-helpers-7qF9S2k7.js.map +1 -0
  45. package/dist/chunks/{ui-DZS2SAQg.js → ui-DAtVMiVs.js} +2 -2
  46. package/dist/chunks/{ui-DZS2SAQg.js.map → ui-DAtVMiVs.js.map} +1 -1
  47. package/dist/chunks/{write-result-Cb3r0sCO.js → write-result-BHCOxcsA.js} +2 -2
  48. package/dist/chunks/{write-result-Cb3r0sCO.js.map → write-result-BHCOxcsA.js.map} +1 -1
  49. package/dist/index.js +53 -53
  50. package/dist/index.js.map +1 -1
  51. package/package.json +1 -1
  52. package/dist/chunks/pocketbase-fERkp8b8.js +0 -123
  53. package/dist/chunks/pocketbase-fERkp8b8.js.map +0 -1
  54. package/dist/chunks/ts-morph-helpers-Bk82Z2n7.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velastack/patterns",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Registry of VelaStack patterns: generators and modifications applied to SvelteKit projects by the VelaStack CLI.",
5
5
  "type": "module",
6
6
  "private": false,
@@ -1,123 +0,0 @@
1
- import { i as e, n as t } from "./constants-PBCzh8eY.js";
2
- import n from "node:path";
3
- import { existsSync as r, readFileSync as i, readdirSync as a } from "node:fs";
4
- import o from "pocketbase";
5
- import { detect as s } from "package-manager-detector";
6
- import { resolveCommand as c } from "package-manager-detector/commands";
7
- import l from "cross-spawn";
8
- import u from "node:net";
9
- //#region src/runtime/net.ts
10
- function d() {
11
- return Math.floor(Math.random() * 1e4) + 1e4;
12
- }
13
- function f(e, t, n = 60) {
14
- return new Promise((r, i) => {
15
- let a = 0, o = () => {
16
- a++;
17
- let s = new u.Socket();
18
- s.once("error", () => {
19
- if (s.destroy(), a === n) {
20
- i(/* @__PURE__ */ Error(`Timed out waiting for port ${e} to be available`));
21
- return;
22
- }
23
- setTimeout(o, 500);
24
- }), s.connect(e, t, () => {
25
- s.destroy(), r();
26
- });
27
- };
28
- o();
29
- });
30
- }
31
- function p(e, t = 60) {
32
- return new Promise((n, r) => {
33
- let i = 0, a = async () => {
34
- i++;
35
- try {
36
- if ((await fetch(`${e}/api/health`)).status === 200) {
37
- n();
38
- return;
39
- }
40
- } catch {}
41
- if (i === t) {
42
- r(/* @__PURE__ */ Error(`Timed out waiting for health check at ${e}/api/health`));
43
- return;
44
- }
45
- setTimeout(a, 500);
46
- };
47
- a();
48
- });
49
- }
50
- //#endregion
51
- //#region src/runtime/pocketbase.ts
52
- var m = 1100;
53
- function h() {
54
- return new Promise((e) => setTimeout(e, m));
55
- }
56
- function g(t, r, i) {
57
- let o = `${r}_${t}.js`, s = a(n.join(i.root, e)).filter((e) => e.endsWith(o)).sort().pop();
58
- if (s) return n.join(i.root, e, s);
59
- }
60
- function _(e) {
61
- let t = n.join(e, "node_modules", ".vite", "_pocketbase_metadata.json");
62
- return r(t) ? JSON.parse(i(t, "utf8")) : null;
63
- }
64
- async function v(e, t, n) {
65
- let r = !1;
66
- for (let i = 1; i <= 3; i++) try {
67
- await e.collection("_superusers").authWithPassword(t, n), r = !0;
68
- break;
69
- } catch {
70
- i < 3 && await new Promise((e) => setTimeout(e, 100));
71
- }
72
- if (!r) throw Error("Failed to authenticate with PocketBase. Check your superuser credentials.");
73
- }
74
- async function y(i, a) {
75
- let u = n.join(i, t), m = n.join(i, e), h = "localhost";
76
- if (!r(u)) throw Error("PocketBase data directory does not exist");
77
- let g = _(i);
78
- if (g && g.pocketbaseUrl) {
79
- let e = new o(g.pocketbaseUrl);
80
- await v(e, process.env.POCKETBASE_SUPERUSER_EMAIL, process.env.POCKETBASE_SUPERUSER_PASSWORD), await a(e);
81
- return;
82
- }
83
- let y = d(), x = [
84
- "pocketbase-server",
85
- "serve",
86
- "--dir",
87
- u,
88
- "--migrationsDir",
89
- m,
90
- "--http",
91
- `${h}:${y}`
92
- ], S = (await s({ cwd: i }))?.name ?? "npm", { command: C, args: w } = c(S, "execute", x);
93
- S === "npm" && w.unshift("--yes");
94
- let T = process.platform !== "win32", E = l(C, w, {
95
- cwd: i,
96
- stdio: "ignore",
97
- detached: T
98
- }), D = new Promise((e, t) => {
99
- E.once("exit", (e, n) => {
100
- t(/* @__PURE__ */ Error(`pocketbase-server exited before listening on ${h}:${y} (${n ?? `code ${e}`})`));
101
- }), E.once("error", t);
102
- });
103
- try {
104
- await Promise.race([(async () => {
105
- await f(y, h), await p(`http://${h}:${y}`);
106
- })(), D]);
107
- let e = new o(`http://${h}:${y}`);
108
- await v(e, process.env.POCKETBASE_SUPERUSER_EMAIL, process.env.POCKETBASE_SUPERUSER_PASSWORD), await a(e);
109
- } finally {
110
- b(E, T);
111
- }
112
- }
113
- function b(e, t) {
114
- if (t && e.pid) try {
115
- process.kill(-e.pid, "SIGTERM");
116
- return;
117
- } catch {}
118
- e.kill();
119
- }
120
- //#endregion
121
- export { g as getMigrationFile, h as migrationDelay, y as withPocketbase };
122
-
123
- //# sourceMappingURL=pocketbase-fERkp8b8.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pocketbase-fERkp8b8.js","names":[],"sources":["../../src/runtime/net.ts","../../src/runtime/pocketbase.ts"],"sourcesContent":["import net from \"node:net\";\n\n// Generate a random port\nexport function randomPort() {\n return Math.floor(Math.random() * 10000) + 10000;\n}\n\n// Wait for the port to be available. A cold `npx pocketbase-server` on a CI\n// runner can take well over the five seconds the old default allowed.\nexport function waitForPort(\n port: number,\n host: string,\n maxAttempts = 60,\n): Promise<void> {\n return new Promise((resolve, reject) => {\n let attempts = 0;\n\n const tryConnect = () => {\n attempts++;\n\n const socket = new net.Socket();\n\n const onError = () => {\n socket.destroy();\n\n if (attempts === maxAttempts) {\n reject(\n new Error(`Timed out waiting for port ${port} to be available`),\n );\n return;\n }\n\n setTimeout(tryConnect, 500);\n };\n\n socket.once(\"error\", onError);\n\n socket.connect(port, host, () => {\n socket.destroy();\n resolve();\n });\n };\n\n tryConnect();\n });\n}\n\n// Wait for the health check to be successful\nexport function waitForHealth(url: string, maxAttempts = 60): Promise<void> {\n return new Promise((resolve, reject) => {\n let attempts = 0;\n\n const tryHealth = async () => {\n attempts++;\n\n try {\n const response = await fetch(`${url}/api/health`);\n if (response.status === 200) {\n resolve();\n return;\n }\n } catch {\n // Ignore fetch errors and continue retrying\n }\n\n if (attempts === maxAttempts) {\n reject(\n new Error(`Timed out waiting for health check at ${url}/api/health`),\n );\n return;\n }\n\n setTimeout(tryHealth, 500);\n };\n\n tryHealth();\n });\n}\n","import { existsSync, readdirSync, readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport PocketBase from \"pocketbase\";\nimport { detect } from \"package-manager-detector\";\nimport { resolveCommand } from \"package-manager-detector/commands\";\nimport spawn from \"cross-spawn\";\nimport { randomPort, waitForPort, waitForHealth } from \"./net\";\nimport type { Options } from \"../core/types\";\nimport { DATA_DIR, MIGRATIONS_DIR } from \"../core/constants\";\n\n/**\n * PocketBase names migration files with a 1-second-resolution Unix timestamp\n * (e.g. `1776099881_created_users.js`). Two schema operations issued in the\n * same wall-clock second produce files that sort alphabetically by their\n * action/collection suffix — which reverses the intended order whenever a\n * later migration depends on an earlier one. Wait out the full second between\n * migration-producing calls so the timestamps stay distinct.\n */\nconst MIGRATION_DELAY_MS = 1100;\n\nexport function migrationDelay(): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, MIGRATION_DELAY_MS));\n}\n\nexport function getMigrationFile(\n collectionName: string,\n action: \"created\" | \"deleted\" | \"updated\",\n options: Options,\n): string | undefined {\n const ending = `${action}_${collectionName}.js`;\n\n // find last file with ending in migrations dir\n const migrationFiles = readdirSync(\n path.join(options.root, MIGRATIONS_DIR),\n ).filter((file) => file.endsWith(ending));\n\n const migrationFile = migrationFiles.sort().pop();\n\n if (!migrationFile) {\n return undefined;\n }\n\n return path.join(options.root, MIGRATIONS_DIR, migrationFile);\n}\n\nexport function getPocketbaseMetadata(cwd: string): {\n pocketbaseUrl: string;\n vitePort: number;\n} | null {\n const metadataPath = path.join(\n cwd,\n \"node_modules\",\n \".vite\",\n \"_pocketbase_metadata.json\",\n );\n if (existsSync(metadataPath)) {\n return JSON.parse(readFileSync(metadataPath, \"utf8\"));\n }\n return null;\n}\n\nexport async function authWithRetries(\n pb: PocketBase,\n email: string,\n password: string,\n) {\n // Retry authentication up to 3 times with 100ms backoff\n let authSuccess = false;\n for (let attempt = 1; attempt <= 3; attempt++) {\n try {\n await pb.collection(\"_superusers\").authWithPassword(email, password);\n authSuccess = true;\n break;\n } catch {\n if (attempt < 3) {\n await new Promise((resolve) => setTimeout(resolve, 100));\n }\n }\n }\n\n if (!authSuccess) {\n throw new Error(\n \"Failed to authenticate with PocketBase. Check your superuser credentials.\",\n );\n }\n}\n\nexport async function withPocketbase(\n cwd: string,\n fn: (pb: PocketBase) => Promise<void>,\n) {\n const dir = path.join(cwd, DATA_DIR);\n const migrationsDir = path.join(cwd, MIGRATIONS_DIR);\n const host = \"localhost\";\n\n if (!existsSync(dir)) {\n throw new Error(\"PocketBase data directory does not exist\");\n }\n\n // First check if the server is already running by reading node_modules/.vite/_pocketbase_metadata.json\n const metadata = getPocketbaseMetadata(cwd);\n if (metadata) {\n if (metadata.pocketbaseUrl) {\n const pb = new PocketBase(metadata.pocketbaseUrl);\n await authWithRetries(\n pb,\n process.env.POCKETBASE_SUPERUSER_EMAIL!,\n process.env.POCKETBASE_SUPERUSER_PASSWORD!,\n );\n await fn(pb);\n return;\n }\n }\n\n const port = randomPort();\n const commandArgs = [\n \"pocketbase-server\",\n \"serve\",\n \"--dir\",\n dir,\n \"--migrationsDir\",\n migrationsDir,\n \"--http\",\n `${host}:${port}`,\n ];\n\n const packageManager = (await detect({ cwd }))?.name ?? \"npm\";\n const { command, args } = resolveCommand(\n packageManager,\n \"execute\",\n commandArgs,\n )!;\n\n // adding --yes as the first parameter helps avoiding the \"Need to install the following packages:\" message\n if (packageManager === \"npm\") args.unshift(\"--yes\");\n\n // Start the PocketBase server process. The package manager wrapper (`npx`)\n // spawns the real binary as a grandchild; put the tree in its own process\n // group so it can be killed as a whole, otherwise `pocketbase serve` outlives\n // us and keeps the data directory open.\n const detached = process.platform !== \"win32\";\n const serverProcess = spawn(command, args, {\n cwd,\n stdio: \"ignore\",\n detached,\n });\n\n // A wrapper that dies before the server listens (missing binary, bad\n // arguments) would otherwise only surface as a port timeout a minute later.\n const exited = new Promise<never>((_, reject) => {\n serverProcess.once(\"exit\", (code, signal) => {\n reject(\n new Error(\n `pocketbase-server exited before listening on ${host}:${port} (${signal ?? `code ${code}`})`,\n ),\n );\n });\n serverProcess.once(\"error\", reject);\n });\n\n try {\n // Wait for the server to be ready\n await Promise.race([\n (async () => {\n await waitForPort(port, host);\n await waitForHealth(`http://${host}:${port}`);\n })(),\n exited,\n ]);\n\n const pb = new PocketBase(`http://${host}:${port}`);\n await authWithRetries(\n pb,\n process.env.POCKETBASE_SUPERUSER_EMAIL!,\n process.env.POCKETBASE_SUPERUSER_PASSWORD!,\n );\n await fn(pb);\n } finally {\n // Ensure we always clean up the process tree\n stopProcessTree(serverProcess, detached);\n }\n}\n\nfunction stopProcessTree(\n child: ReturnType<typeof spawn>,\n detached: boolean,\n): void {\n if (detached && child.pid) {\n try {\n process.kill(-child.pid, \"SIGTERM\");\n return;\n } catch {\n // Group already gone or unsupported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OAAO;CAMlD,IAAM,IAAW,QAAQ,aAAa,SAChC,IAAgB,EAAM,GAAS,GAAM;EACzC;EACA,OAAO;EACP;CACF,CAAC,GAIK,IAAS,IAAI,SAAgB,GAAG,MAAW;EAQ/C,AAPA,EAAc,KAAK,SAAS,GAAM,MAAW;GAC3C,EACE,gBAAI,MACF,gDAAgD,EAAK,GAAG,EAAK,IAAI,KAAU,QAAQ,IAAO,EAC5F,CACF;EACF,CAAC,GACD,EAAc,KAAK,SAAS,CAAM;CACpC,CAAC;CAED,IAAI;EAEF,MAAM,QAAQ,KAAK,EAChB,YAAY;GAEX,AADA,MAAM,EAAY,GAAM,CAAI,GAC5B,MAAM,EAAc,UAAU,EAAK,GAAG,GAAM;EAC9C,EAAA,CAAG,GACH,CACF,CAAC;EAED,IAAM,IAAK,IAAI,EAAW,UAAU,EAAK,GAAG,GAAM;EAMlD,AALA,MAAM,EACJ,GACA,QAAQ,IAAI,4BACZ,QAAQ,IAAI,6BACd,GACA,MAAM,EAAG,CAAE;CACb,UAAU;EAER,EAAgB,GAAe,CAAQ;CACzC;AACF;AAEA,SAAS,EACP,GACA,GACM;CACN,IAAI,KAAY,EAAM,KACpB,IAAI;EACF,QAAQ,KAAK,CAAC,EAAM,KAAK,SAAS;EAClC;CACF,QAAQ,CAER;CAEF,EAAM,KAAK;AACb"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ts-morph-helpers-Bk82Z2n7.js","names":[],"sources":["../../src/runtime/svelte-file.ts","../../src/runtime/ts-morph-helpers.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { parse, type AST } from \"svelte/compiler\";\nimport MagicString from \"magic-string\";\n\ntype SvelteAst = AST.Root;\ntype SvelteNode = any;\n\ninterface ScriptBlock {\n content: string;\n start: number;\n end: number;\n}\n\n/**\n * Surgical, AST-aware editing of .svelte files.\n *\n * Parses the source with svelte/compiler to discover precise character offsets,\n * then applies edits via magic-string so untouched regions remain byte-for-byte\n * identical to the original. Script-block contents are exposed as plain strings\n * so callers can hand them to ts-morph.\n */\nexport class SvelteFile {\n private readonly source: string;\n private readonly ast: SvelteAst;\n private readonly s: MagicString;\n\n constructor(source: string) {\n this.source = source;\n this.ast = parse(source, { modern: true });\n this.s = new MagicString(source);\n }\n\n static fromPath(filePath: string): SvelteFile {\n return new SvelteFile(fs.readFileSync(filePath, \"utf8\"));\n }\n\n getScript(): ScriptBlock | null {\n return this.scriptInner((this.ast as any).instance);\n }\n\n getModuleScript(): ScriptBlock | null {\n return this.scriptInner((this.ast as any).module);\n }\n\n private scriptInner(script: SvelteNode | null): ScriptBlock | null {\n if (!script) return null;\n const start = script.content.start as number;\n const end = script.content.end as number;\n return { content: this.source.slice(start, end), start, end };\n }\n\n /**\n * Replace the inner contents of <script>. Use for ts-morph round-trips.\n * Returns true when an edit was made.\n */\n modifyScript(fn: (content: string) => string): boolean {\n return this.modifyScriptBlock(this.getScript(), fn);\n }\n\n modifyModuleScript(fn: (content: string) => string): boolean {\n return this.modifyScriptBlock(this.getModuleScript(), fn);\n }\n\n private modifyScriptBlock(\n block: ScriptBlock | null,\n fn: (content: string) => string,\n ): boolean {\n if (!block) return false;\n const next = fn(block.content);\n if (next === block.content) return false;\n this.s.overwrite(block.start, block.end, next);\n return true;\n }\n\n /** First Component or RegularElement node with the given name. */\n findElement(name: string): SvelteNode | null {\n return findNode(\n (this.ast as any).fragment,\n (node) =>\n (node.type === \"Component\" || node.type === \"RegularElement\") &&\n node.name === name,\n );\n }\n\n hasElement(name: string): boolean {\n return this.findElement(name) !== null;\n }\n\n hasAttribute(componentName: string, attrName: string): boolean {\n const node = this.findElement(componentName);\n if (!node) return false;\n return (node.attributes ?? []).some(\n (attr: SvelteNode) => attr.type === \"Attribute\" && attr.name === attrName,\n );\n }\n\n /**\n * Insert content at the end of <ComponentName>'s children, just before the\n * closing tag. No-op if the element is not found.\n */\n insertBeforeClosingTag(name: string, content: string): boolean {\n const node = this.findElement(name);\n if (!node) return false;\n const closingTag = `</${name}>`;\n const closingPos = this.source.lastIndexOf(closingTag, node.end);\n if (closingPos === -1) return false;\n this.s.appendLeft(closingPos, content);\n return true;\n }\n\n /** Replace the element entirely (start tag through close tag). */\n replaceElement(name: string, newContent: string): boolean {\n const node = this.findElement(name);\n if (!node) return false;\n this.s.overwrite(node.start, node.end, newContent);\n return true;\n }\n\n /** Remove the element (start tag through close tag). */\n removeElement(name: string): boolean {\n return this.replaceElement(name, \"\");\n }\n\n /** Append raw markup to the end of the source file. */\n appendMarkup(content: string): void {\n this.s.append(content);\n }\n\n /**\n * Append attribute text (e.g. \" team={data.team}\") just after the last\n * existing attribute on the element's start tag.\n */\n appendToAttributes(name: string, attrs: string): boolean {\n const node = this.findElement(name);\n if (!node) return false;\n const last = (node.attributes ?? []).at(-1) as SvelteNode | undefined;\n const insertAt = last\n ? (last.end as number)\n : (node.start as number) + `<${name}`.length;\n this.s.appendLeft(insertAt, attrs);\n return true;\n }\n\n /**\n * Remove a named attribute from a component's start tag, including the\n * leading whitespace. No-op if the element or attribute isn't present.\n */\n removeAttribute(name: string, attrName: string): boolean {\n const node = this.findElement(name);\n if (!node) return false;\n const attr = (node.attributes ?? []).find(\n (a: SvelteNode) => a.type === \"Attribute\" && a.name === attrName,\n );\n if (!attr) return false;\n // Extend the removal backwards over the whitespace between the previous\n // token and this attribute so the tag doesn't collapse `<Foo />`.\n let start = attr.start as number;\n while (start > 0 && /\\s/.test(this.source[start - 1]!)) start--;\n this.s.remove(start, attr.end as number);\n return true;\n }\n\n hasChanged(): boolean {\n return this.s.hasChanged();\n }\n\n toString(): string {\n return this.s.toString();\n }\n\n writeTo(filePath: string): void {\n if (this.hasChanged()) {\n fs.writeFileSync(filePath, this.toString(), \"utf8\");\n }\n }\n}\n\nfunction findNode(\n root: unknown,\n predicate: (node: any) => boolean,\n): any | null {\n const seen = new WeakSet<object>();\n function visit(node: unknown): any | null {\n if (!node || typeof node !== \"object\" || seen.has(node as object)) {\n return null;\n }\n seen.add(node as object);\n if (predicate(node as any)) return node;\n for (const key of Object.keys(node as Record<string, unknown>)) {\n if (key === \"parent\") continue;\n const child = (node as Record<string, unknown>)[key];\n if (Array.isArray(child)) {\n for (const item of child) {\n const found = visit(item);\n if (found) return found;\n }\n } else if (\n child &&\n typeof child === \"object\" &&\n \"type\" in (child as object)\n ) {\n const found = visit(child);\n if (found) return found;\n }\n }\n return null;\n }\n return visit(root);\n}\n","import {\n Project,\n QuoteKind,\n SyntaxKind,\n type ImportDeclarationStructure,\n type OptionalKind,\n type SourceFile,\n type StringLiteral,\n} from \"ts-morph\";\n\nexport interface ImportSpec {\n defaultImport?: string;\n namespaceImport?: string;\n namedImports?: string[];\n moduleSpecifier: string;\n}\n\n/**\n * Run a function with an in-memory ts-morph SourceFile and return the resulting\n * source plus whatever the callback returned.\n */\nexport function withInMemoryScript<T>(\n source: string,\n fn: (sf: SourceFile) => T,\n): { source: string; result: T } {\n const project = new Project({\n useInMemoryFileSystem: true,\n skipFileDependencyResolution: true,\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sf = project.createSourceFile(\"script.ts\", source, { overwrite: true });\n const result = fn(sf);\n return { source: sf.getFullText(), result };\n}\n\n/** Add the given imports to the source file, skipping any whose module specifier already exists. */\nexport function ensureImports(sf: SourceFile, imports: ImportSpec[]): void {\n for (const spec of imports) {\n const existing = sf\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === spec.moduleSpecifier);\n if (existing) continue;\n\n const structure: OptionalKind<ImportDeclarationStructure> = {\n moduleSpecifier: spec.moduleSpecifier,\n };\n if (spec.defaultImport) structure.defaultImport = spec.defaultImport;\n if (spec.namespaceImport) structure.namespaceImport = spec.namespaceImport;\n if (spec.namedImports) structure.namedImports = spec.namedImports;\n sf.addImportDeclaration(structure);\n }\n}\n\n/** Remove the import declaration for the given module specifier, if present. */\nexport function removeImportByModuleSpecifier(\n sf: SourceFile,\n moduleSpecifier: string,\n): { wasRemoved: boolean } {\n const decl = sf\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === moduleSpecifier);\n if (!decl) return { wasRemoved: false };\n decl.remove();\n return { wasRemoved: true };\n}\n\n/** Remove a top-level function or variable declaration by name, if present. */\nexport function removeTopLevelStatementByIdentifier(\n sf: SourceFile,\n name: string,\n): { wasRemoved: boolean } {\n const fn = sf.getFunction(name);\n if (fn) {\n fn.remove();\n return { wasRemoved: true };\n }\n const vs = sf\n .getVariableStatements()\n .find((s) => s.getDeclarations().some((d) => d.getName() === name));\n if (vs) {\n vs.remove();\n return { wasRemoved: true };\n }\n return { wasRemoved: false };\n}\n\n/**\n * Add an item to the `data.navUser` array in a Svelte component's script body.\n * Idempotent: if an entry with the same `title` already exists, no-op.\n */\nexport function addNavItemToScript(\n scriptSource: string,\n title: string,\n url: string,\n icon: string,\n iconImportPath: string,\n): { source: string; wasAdded: boolean } {\n const newNavItemSnippet = `\n {\n title: '${title}',\n url: '${url}',\n icon: ${icon}\n }\n `.trim();\n\n const { source, result } = withInMemoryScript(scriptSource, (sf) => {\n const dataDecl = sf\n .getVariableDeclarations()\n .find((d) => d.getName() === \"data\");\n const dataInit = dataDecl?.getInitializer();\n if (\n !dataInit ||\n dataInit.getKind() !== SyntaxKind.ObjectLiteralExpression\n ) {\n return { wasAdded: false };\n }\n\n const obj = dataInit.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n const navProp = obj.getProperty(\"navUser\");\n if (!navProp || navProp.getKind() !== SyntaxKind.PropertyAssignment) {\n return { wasAdded: false };\n }\n\n const init = navProp\n .asKindOrThrow(SyntaxKind.PropertyAssignment)\n .getInitializer();\n if (!init || init.getKind() !== SyntaxKind.ArrayLiteralExpression) {\n return { wasAdded: false };\n }\n\n const arr = init.asKindOrThrow(SyntaxKind.ArrayLiteralExpression);\n const exists = arr.getElements().some((el) => {\n if (el.getKind() !== SyntaxKind.ObjectLiteralExpression) return false;\n const o = el.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n const titleProp = o.getProperty(\"title\");\n if (!titleProp || titleProp.getKind() !== SyntaxKind.PropertyAssignment) {\n return false;\n }\n const value = titleProp\n .asKindOrThrow(SyntaxKind.PropertyAssignment)\n .getInitializer();\n return (\n value?.getKind() === SyntaxKind.StringLiteral &&\n (value as StringLiteral).getLiteralText() === title\n );\n });\n\n if (exists) return { wasAdded: false };\n\n ensureImports(sf, [\n { defaultImport: icon, moduleSpecifier: iconImportPath },\n ]);\n arr.addElement(newNavItemSnippet);\n sf.formatText();\n return { wasAdded: true };\n });\n\n return { source, wasAdded: result.wasAdded };\n}\n\n/**\n * Remove the entry with the given `title` from the `data.navUser` array in a\n * Svelte component's script body. Also removes the icon import if supplied and\n * no other navUser entry references it. Idempotent: no-op if the entry or\n * navUser structure is missing.\n */\nexport function removeNavItemFromScript(\n scriptSource: string,\n title: string,\n iconImportPath?: string,\n): { source: string; wasRemoved: boolean } {\n const { source, result } = withInMemoryScript(scriptSource, (sf) => {\n const dataDecl = sf\n .getVariableDeclarations()\n .find((d) => d.getName() === \"data\");\n const dataInit = dataDecl?.getInitializer();\n if (\n !dataInit ||\n dataInit.getKind() !== SyntaxKind.ObjectLiteralExpression\n ) {\n return { wasRemoved: false };\n }\n\n const obj = dataInit.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n const navProp = obj.getProperty(\"navUser\");\n if (!navProp || navProp.getKind() !== SyntaxKind.PropertyAssignment) {\n return { wasRemoved: false };\n }\n\n const init = navProp\n .asKindOrThrow(SyntaxKind.PropertyAssignment)\n .getInitializer();\n if (!init || init.getKind() !== SyntaxKind.ArrayLiteralExpression) {\n return { wasRemoved: false };\n }\n\n const arr = init.asKindOrThrow(SyntaxKind.ArrayLiteralExpression);\n const elements = arr.getElements();\n const index = elements.findIndex((el) => {\n if (el.getKind() !== SyntaxKind.ObjectLiteralExpression) return false;\n const o = el.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n const titleProp = o.getProperty(\"title\");\n if (!titleProp || titleProp.getKind() !== SyntaxKind.PropertyAssignment) {\n return false;\n }\n const value = titleProp\n .asKindOrThrow(SyntaxKind.PropertyAssignment)\n .getInitializer();\n return (\n value?.getKind() === SyntaxKind.StringLiteral &&\n (value as StringLiteral).getLiteralText() === title\n );\n });\n\n if (index === -1) return { wasRemoved: false };\n\n arr.removeElement(index);\n\n if (iconImportPath) {\n const remainingRefs = arr.getElements().some((el) => {\n if (el.getKind() !== SyntaxKind.ObjectLiteralExpression) return false;\n const o = el.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n const iconProp = o.getProperty(\"icon\");\n if (!iconProp || iconProp.getKind() !== SyntaxKind.PropertyAssignment) {\n return false;\n }\n return (\n iconProp\n .asKindOrThrow(SyntaxKind.PropertyAssignment)\n .getInitializer()\n ?.getText() !== undefined\n );\n });\n const importDecl = sf\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === iconImportPath);\n if (importDecl && !remainingRefs) {\n const importName = importDecl.getDefaultImport()?.getText();\n const stillUsed =\n importName &&\n sf\n .getDescendantsOfKind(SyntaxKind.Identifier)\n .some(\n (id) =>\n id.getText() === importName &&\n id.getParent()?.getKind() !== SyntaxKind.ImportClause &&\n id.getParent()?.getKind() !== SyntaxKind.ImportSpecifier,\n );\n if (!stillUsed) {\n importDecl.remove();\n }\n }\n }\n\n sf.formatText();\n return { wasRemoved: true };\n });\n\n return { source, wasRemoved: result.wasRemoved };\n}\n"],"mappings":";;;;;AAqBA,IAAa,IAAb,MAAa,EAAW;CAKtB,YAAY,GAAgB;EAG1B,AAFA,KAAK,SAAS,GACd,KAAK,MAAM,EAAM,GAAQ,EAAE,QAAQ,GAAK,CAAC,GACzC,KAAK,IAAI,IAAI,EAAY,CAAM;CACjC;CAEA,OAAO,SAAS,GAA8B;EAC5C,OAAO,IAAI,EAAW,EAAG,aAAa,GAAU,MAAM,CAAC;CACzD;CAEA,YAAgC;EAC9B,OAAO,KAAK,YAAa,KAAK,IAAY,QAAQ;CACpD;CAEA,kBAAsC;EACpC,OAAO,KAAK,YAAa,KAAK,IAAY,MAAM;CAClD;CAE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