@velastack/patterns 0.2.5 → 0.2.7

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 (88) hide show
  1. package/dist/chunks/_layout-D0OmzCu1.js +47 -0
  2. package/dist/chunks/_layout-D0OmzCu1.js.map +1 -0
  3. package/dist/chunks/{collections-B-yQ1qt6.js → collections-B3lAtPlQ.js} +2 -2
  4. package/dist/chunks/{collections-B-yQ1qt6.js.map → collections-B3lAtPlQ.js.map} +1 -1
  5. package/dist/chunks/{generate-BoEG6Rb-.js → generate-Va1sxVPG.js} +2 -2
  6. package/dist/chunks/{generate-BoEG6Rb-.js.map → generate-Va1sxVPG.js.map} +1 -1
  7. package/dist/chunks/{generate-BCBS08AS.js → generate-tOkjJFUf.js} +2 -2
  8. package/dist/chunks/{generate-BCBS08AS.js.map → generate-tOkjJFUf.js.map} +1 -1
  9. package/dist/chunks/{generate.runtime-_VsM0zBS.js → generate.runtime-4Iplvp8f.js} +6 -6
  10. package/dist/chunks/{generate.runtime-_VsM0zBS.js.map → generate.runtime-4Iplvp8f.js.map} +1 -1
  11. package/dist/chunks/{generate.runtime-ByASCDoo.js → generate.runtime-B9gdCz4t.js} +3 -3
  12. package/dist/chunks/{generate.runtime-ByASCDoo.js.map → generate.runtime-B9gdCz4t.js.map} +1 -1
  13. package/dist/chunks/{generate.runtime-CIuSkWtY.js → generate.runtime-BKb9thdE.js} +91 -131
  14. package/dist/chunks/generate.runtime-BKb9thdE.js.map +1 -0
  15. package/dist/chunks/generate.runtime-BdTCMGGB.js +65 -0
  16. package/dist/chunks/generate.runtime-BdTCMGGB.js.map +1 -0
  17. package/dist/chunks/{generate.runtime-CRgw-aja.js → generate.runtime-BjULAL3h.js} +47 -46
  18. package/dist/chunks/generate.runtime-BjULAL3h.js.map +1 -0
  19. package/dist/chunks/{generate.runtime-C6qZUlN-.js → generate.runtime-BlQ1vx8j.js} +6 -6
  20. package/dist/chunks/{generate.runtime-C6qZUlN-.js.map → generate.runtime-BlQ1vx8j.js.map} +1 -1
  21. package/dist/chunks/{generate.runtime-CghBFVEf.js → generate.runtime-BltGUllM.js} +6 -6
  22. package/dist/chunks/{generate.runtime-CghBFVEf.js.map → generate.runtime-BltGUllM.js.map} +1 -1
  23. package/dist/chunks/{generate.runtime-CwaPHcYP.js → generate.runtime-BsuyMwoj.js} +6 -6
  24. package/dist/chunks/{generate.runtime-CwaPHcYP.js.map → generate.runtime-BsuyMwoj.js.map} +1 -1
  25. package/dist/chunks/{generate.runtime-PjMBpjkG.js → generate.runtime-C-Val7lP.js} +5 -5
  26. package/dist/chunks/{generate.runtime-PjMBpjkG.js.map → generate.runtime-C-Val7lP.js.map} +1 -1
  27. package/dist/chunks/generate.runtime-CGkVUKvz.js +106 -0
  28. package/dist/chunks/generate.runtime-CGkVUKvz.js.map +1 -0
  29. package/dist/chunks/{generate.runtime-BBOWWrZv.js → generate.runtime-CXXwLatT.js} +5 -5
  30. package/dist/chunks/{generate.runtime-BBOWWrZv.js.map → generate.runtime-CXXwLatT.js.map} +1 -1
  31. package/dist/chunks/{generate.runtime-CrrAzNZS.js → generate.runtime-DCvLLO7w.js} +5 -5
  32. package/dist/chunks/{generate.runtime-CrrAzNZS.js.map → generate.runtime-DCvLLO7w.js.map} +1 -1
  33. package/dist/chunks/{generate.runtime-WwZt9Mu5.js → generate.runtime-DKJaYtVZ.js} +7 -7
  34. package/dist/chunks/{generate.runtime-WwZt9Mu5.js.map → generate.runtime-DKJaYtVZ.js.map} +1 -1
  35. package/dist/chunks/generate.runtime-DWeiewRj.js +145 -0
  36. package/dist/chunks/generate.runtime-DWeiewRj.js.map +1 -0
  37. package/dist/chunks/{generate.runtime-CUtOhlNA.js → generate.runtime-DaPNrIyg.js} +3 -3
  38. package/dist/chunks/{generate.runtime-CUtOhlNA.js.map → generate.runtime-DaPNrIyg.js.map} +1 -1
  39. package/dist/chunks/generate.runtime-Dc98DCsh.js +256 -0
  40. package/dist/chunks/generate.runtime-Dc98DCsh.js.map +1 -0
  41. package/dist/chunks/{generate.runtime-DercL_qN.js → generate.runtime-FMYR64DL.js} +5 -5
  42. package/dist/chunks/{generate.runtime-DercL_qN.js.map → generate.runtime-FMYR64DL.js.map} +1 -1
  43. package/dist/chunks/{generate.runtime-Biy8wuHU.js → generate.runtime-QmFJI7G1.js} +13 -13
  44. package/dist/chunks/{generate.runtime-Biy8wuHU.js.map → generate.runtime-QmFJI7G1.js.map} +1 -1
  45. package/dist/chunks/{generate.runtime-Dlokr7A0.js → generate.runtime-SQhCLSah.js} +2 -2
  46. package/dist/chunks/{generate.runtime-Dlokr7A0.js.map → generate.runtime-SQhCLSah.js.map} +1 -1
  47. package/dist/chunks/{generate.runtime-UIN_TkYo.js → generate.runtime-Wssys8A0.js} +6 -6
  48. package/dist/chunks/{generate.runtime-UIN_TkYo.js.map → generate.runtime-Wssys8A0.js.map} +1 -1
  49. package/dist/chunks/{generate.runtime-nyMB57Tf.js → generate.runtime-fSDNxfGG.js} +2 -2
  50. package/dist/chunks/{generate.runtime-nyMB57Tf.js.map → generate.runtime-fSDNxfGG.js.map} +1 -1
  51. package/dist/chunks/{generate.runtime-XpQGIrOx.js → generate.runtime-kH6XaWQz.js} +6 -6
  52. package/dist/chunks/{generate.runtime-XpQGIrOx.js.map → generate.runtime-kH6XaWQz.js.map} +1 -1
  53. package/dist/chunks/{generate.runtime-C6RhVu5K.js → generate.runtime-lqPPXQyS.js} +6 -6
  54. package/dist/chunks/{generate.runtime-C6RhVu5K.js.map → generate.runtime-lqPPXQyS.js.map} +1 -1
  55. package/dist/chunks/{generate.runtime-JWURZXj-.js → generate.runtime-tAbxWeq-.js} +7 -7
  56. package/dist/chunks/{generate.runtime-JWURZXj-.js.map → generate.runtime-tAbxWeq-.js.map} +1 -1
  57. package/dist/chunks/{modify-file-Dgd_PzRG.js → modify-file-Cgu_WeFk.js} +2 -2
  58. package/dist/chunks/{modify-file-Dgd_PzRG.js.map → modify-file-Cgu_WeFk.js.map} +1 -1
  59. package/dist/chunks/{shared-cFKFtcgw.js → shared--_BWnGsc.js} +3 -3
  60. package/dist/chunks/{shared-cFKFtcgw.js.map → shared--_BWnGsc.js.map} +1 -1
  61. package/dist/chunks/{test-setup-BBb4kcoO.js → test-setup-DjbhQYZC.js} +49 -58
  62. package/dist/chunks/test-setup-DjbhQYZC.js.map +1 -0
  63. package/dist/chunks/{ts-morph-helpers-7qF9S2k7.js → ts-morph-helpers-Bf5iuQW8.js} +28 -12
  64. package/dist/chunks/ts-morph-helpers-Bf5iuQW8.js.map +1 -0
  65. package/dist/chunks/{ui-X12f0xKA.js → ui-BsG60gQg.js} +2 -2
  66. package/dist/chunks/{ui-X12f0xKA.js.map → ui-BsG60gQg.js.map} +1 -1
  67. package/dist/chunks/unmodify-load-W1ePZQHr.js +80 -0
  68. package/dist/chunks/unmodify-load-W1ePZQHr.js.map +1 -0
  69. package/dist/chunks/{util-Bq_Mh6IQ.js → util-BLYliuUK.js} +2 -2
  70. package/dist/chunks/{util-Bq_Mh6IQ.js.map → util-BLYliuUK.js.map} +1 -1
  71. package/dist/chunks/write-result-BN7Ff0rF.js +451 -0
  72. package/dist/chunks/write-result-BN7Ff0rF.js.map +1 -0
  73. package/dist/index.d.ts +77 -7
  74. package/dist/index.js +630 -542
  75. package/dist/index.js.map +1 -1
  76. package/package.json +1 -1
  77. package/dist/chunks/generate.runtime-ArKscTs9.js +0 -65
  78. package/dist/chunks/generate.runtime-ArKscTs9.js.map +0 -1
  79. package/dist/chunks/generate.runtime-BpvwX9CL.js +0 -28
  80. package/dist/chunks/generate.runtime-BpvwX9CL.js.map +0 -1
  81. package/dist/chunks/generate.runtime-BtL9FPuW.js +0 -60
  82. package/dist/chunks/generate.runtime-BtL9FPuW.js.map +0 -1
  83. package/dist/chunks/generate.runtime-CIuSkWtY.js.map +0 -1
  84. package/dist/chunks/generate.runtime-CRgw-aja.js.map +0 -1
  85. package/dist/chunks/test-setup-BBb4kcoO.js.map +0 -1
  86. package/dist/chunks/ts-morph-helpers-7qF9S2k7.js.map +0 -1
  87. package/dist/chunks/write-result-DgFUKxhP.js +0 -445
  88. package/dist/chunks/write-result-DgFUKxhP.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velastack/patterns",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
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,65 +0,0 @@
1
- import { n as e } from "./logger-CQONztPm.js";
2
- import { modifyOutcomeToFile as t } from "./modify-file-Dgd_PzRG.js";
3
- import n from "node:path";
4
- import r from "node:fs";
5
- //#region src/patterns/disable/i18n/modifies/gitignore.ts
6
- function i(e) {
7
- if (!r.existsSync(e)) return {
8
- status: "success",
9
- changed: !1
10
- };
11
- let t = r.readFileSync(e, "utf8");
12
- if (!t.includes("src/locales/.wuchale")) return {
13
- status: "success",
14
- changed: !1
15
- };
16
- let n = t.split("\n"), i = [];
17
- for (let e = 0; e < n.length; e++) {
18
- let t = n[e];
19
- if (t === "# Wuchale") {
20
- let t = e + 1, r = !1;
21
- for (; t < n.length && n[t].trim() !== "";) n[t] === "src/locales/.wuchale" && (r = !0), t++;
22
- if (r) {
23
- e = t;
24
- continue;
25
- }
26
- }
27
- t !== "src/locales/.wuchale" && i.push(t);
28
- }
29
- let a = i.join("\n");
30
- return a = a.replace(/\n{3,}/g, "\n\n"), a === t ? {
31
- status: "success",
32
- changed: !1
33
- } : (r.writeFileSync(e, a), {
34
- status: "success",
35
- changed: !0
36
- });
37
- }
38
- //#endregion
39
- //#region src/patterns/disable/i18n/generate.runtime.ts
40
- var a = [
41
- "vite.config, svelte.config, hooks.server, app.html, and +layout.ts must be reverted manually.",
42
- "The i18n integration touches these files in ways that are not safely reversible by tooling.",
43
- "See the enable-i18n modifies for the blocks to remove."
44
- ].join(" ");
45
- async function o(r) {
46
- let o = e(r), s = [], c = (e) => {
47
- e && s.push(e);
48
- };
49
- o.info("Reverting .gitignore");
50
- let l = n.join(r.root, ".gitignore");
51
- return c(t(l, i(l))), o.info(a), {
52
- creates: [],
53
- modifies: s,
54
- deletes: [],
55
- components: [],
56
- packages: [],
57
- collections: [],
58
- collectionPatches: [],
59
- collectionDrops: []
60
- };
61
- }
62
- //#endregion
63
- export { o as generate };
64
-
65
- //# sourceMappingURL=generate.runtime-ArKscTs9.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generate.runtime-ArKscTs9.js","names":[],"sources":["../../src/patterns/disable/i18n/modifies/gitignore.ts","../../src/patterns/disable/i18n/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyGitignore(gitignorePath: string): ModifyOutcome {\n if (!fs.existsSync(gitignorePath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(gitignorePath, \"utf8\");\n if (!original.includes(\"src/locales/.wuchale\")) {\n return { status: \"success\", changed: false };\n }\n\n const lines = original.split(\"\\n\");\n const out: string[] = [];\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n if (line === \"# Wuchale\") {\n let j = i + 1;\n let hasWuchale = false;\n while (j < lines.length && lines[j].trim() !== \"\") {\n if (lines[j] === \"src/locales/.wuchale\") {\n hasWuchale = true;\n }\n j++;\n }\n if (hasWuchale) {\n i = j;\n continue;\n }\n }\n if (line === \"src/locales/.wuchale\") continue;\n out.push(line);\n }\n\n let updated = out.join(\"\\n\");\n updated = updated.replace(/\\n{3,}/g, \"\\n\\n\");\n\n if (updated === original) {\n return { status: \"success\", changed: false };\n }\n\n fs.writeFileSync(gitignorePath, updated);\n return { status: \"success\", changed: true };\n}\n","import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { unmodifyGitignore } from \"./modifies/gitignore\";\n\nconst MANUAL_REMEDIATION = [\n \"vite.config, svelte.config, hooks.server, app.html, and +layout.ts must be reverted manually.\",\n \"The i18n integration touches these files in ways that are not safely reversible by tooling.\",\n \"See the enable-i18n modifies for the blocks to remove.\",\n].join(\" \");\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Reverting .gitignore\");\n const gitignorePath = path.join(options.root, \".gitignore\");\n pushResult(\n modifyOutcomeToFile(gitignorePath, unmodifyGitignore(gitignorePath)),\n );\n\n logger.info(MANUAL_REMEDIATION);\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;AAGA,SAAgB,EAAkB,GAAsC;CACtE,IAAI,CAAC,EAAG,WAAW,CAAa,GAC9B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAM,IAAW,EAAG,aAAa,GAAe,MAAM;CACtD,IAAI,CAAC,EAAS,SAAS,sBAAsB,GAC3C,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAM,IAAQ,EAAS,MAAM,IAAI,GAC3B,IAAgB,CAAC;CACvB,KAAK,IAAI,IAAI,GAAG,IAAI,EAAM,QAAQ,KAAK;EACrC,IAAM,IAAO,EAAM;EACnB,IAAI,MAAS,aAAa;GACxB,IAAI,IAAI,IAAI,GACR,IAAa;GACjB,OAAO,IAAI,EAAM,UAAU,EAAM,EAAE,CAAC,KAAK,MAAM,KAI7C,AAHI,EAAM,OAAO,2BACf,IAAa,KAEf;GAEF,IAAI,GAAY;IACd,IAAI;IACJ;GACF;EACF;EACI,MAAS,0BACb,EAAI,KAAK,CAAI;CACf;CAEA,IAAI,IAAU,EAAI,KAAK,IAAI;CAQ3B,OAPA,IAAU,EAAQ,QAAQ,WAAW,MAAM,GAEvC,MAAY,IACP;EAAE,QAAQ;EAAW,SAAS;CAAM,KAG7C,EAAG,cAAc,GAAe,CAAO,GAChC;EAAE,QAAQ;EAAW,SAAS;CAAK;AAC5C;;;ACtCA,IAAM,IAAqB;CACzB;CACA;CACA;AACF,CAAC,CAAC,KAAK,GAAG;AAEV,eAAsB,EAAS,GAAkB;CAC/C,IAAM,IAAS,EAAU,CAAO,GAC1B,IAAmB,CAAC,GACpB,KAAc,MAAsB;EACxC,AAAI,KAAM,EAAS,KAAK,CAAI;CAC9B;CAEA,EAAO,KAAK,sBAAsB;CAClC,IAAM,IAAgB,EAAK,KAAK,EAAQ,MAAM,YAAY;CAO1D,OANA,EACE,EAAoB,GAAe,EAAkB,CAAa,CAAC,CACrE,GAEA,EAAO,KAAK,CAAkB,GAEvB;EACL,SAAS,CAAC;EACV;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
@@ -1,28 +0,0 @@
1
- import { n as e } from "./logger-CQONztPm.js";
2
- import { modifyOutcomeToFile as t } from "./modify-file-Dgd_PzRG.js";
3
- import { i as n, n as r, o as i } from "./test-setup-BBb4kcoO.js";
4
- import a from "node:path";
5
- //#region src/patterns/disable/backend/generate.runtime.ts
6
- async function o(o) {
7
- let s = e(o), c = [];
8
- s.info("Reverting adapter config");
9
- let l = i(o.root), u = t(l.filePath, l.outcome);
10
- u && c.push(u), s.info("Reverting .gitignore");
11
- let d = a.join(o.root, ".gitignore"), f = t(d, n(d));
12
- f && c.push(f), s.info("Reverting test/setup.ts");
13
- let p = a.join(o.root, "test", "setup.ts"), m = t(p, r(p));
14
- return m && c.push(m), {
15
- creates: [],
16
- modifies: c,
17
- deletes: [],
18
- components: [],
19
- packages: [],
20
- collections: [],
21
- collectionPatches: [],
22
- collectionDrops: []
23
- };
24
- }
25
- //#endregion
26
- export { o as generate };
27
-
28
- //# sourceMappingURL=generate.runtime-BpvwX9CL.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generate.runtime-BpvwX9CL.js","names":[],"sources":["../../src/patterns/disable/backend/generate.runtime.ts"],"sourcesContent":["import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { unmodifySvelteConfig } from \"../../enable/backend/modifies/svelte-config\";\nimport { unmodifyGitignore } from \"../../enable/backend/modifies/gitignore\";\nimport { unmodifyTestSetup } from \"../../enable/backend/modifies/test-setup\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n\n logger.info(\"Reverting adapter config\");\n const revert = unmodifySvelteConfig(options.root);\n const svelteConfigFile = modifyOutcomeToFile(revert.filePath, revert.outcome);\n if (svelteConfigFile) modifies.push(svelteConfigFile);\n\n logger.info(\"Reverting .gitignore\");\n const gitignorePath = path.join(options.root, \".gitignore\");\n const gitignoreFile = modifyOutcomeToFile(\n gitignorePath,\n unmodifyGitignore(gitignorePath),\n );\n if (gitignoreFile) modifies.push(gitignoreFile);\n\n logger.info(\"Reverting test/setup.ts\");\n const testSetupPath = path.join(options.root, \"test\", \"setup.ts\");\n const testSetupFile = modifyOutcomeToFile(\n testSetupPath,\n unmodifyTestSetup(testSetupPath),\n );\n if (testSetupFile) modifies.push(testSetupFile);\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;AAQA,eAAsB,EAAS,GAAkB;CAC/C,IAAM,IAAS,EAAU,CAAO,GAC1B,IAAmB,CAAC;CAE1B,EAAO,KAAK,0BAA0B;CACtC,IAAM,IAAS,EAAqB,EAAQ,IAAI,GAC1C,IAAmB,EAAoB,EAAO,UAAU,EAAO,OAAO;CAG5E,AAFI,KAAkB,EAAS,KAAK,CAAgB,GAEpD,EAAO,KAAK,sBAAsB;CAClC,IAAM,IAAgB,EAAK,KAAK,EAAQ,MAAM,YAAY,GACpD,IAAgB,EACpB,GACA,EAAkB,CAAa,CACjC;CAGA,AAFI,KAAe,EAAS,KAAK,CAAa,GAE9C,EAAO,KAAK,yBAAyB;CACrC,IAAM,IAAgB,EAAK,KAAK,EAAQ,MAAM,QAAQ,UAAU,GAC1D,IAAgB,EACpB,GACA,EAAkB,CAAa,CACjC;CAGA,OAFI,KAAe,EAAS,KAAK,CAAa,GAEvC;EACL,SAAS,CAAC;EACV;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
@@ -1,60 +0,0 @@
1
- import { n as e } from "./logger-CQONztPm.js";
2
- import { t } from "./shared-cFKFtcgw.js";
3
- import { modifyOutcomeToFile as n } from "./modify-file-Dgd_PzRG.js";
4
- import { i as r, o as i } from "./ts-morph-helpers-7qF9S2k7.js";
5
- import a from "node:path";
6
- import o from "node:fs";
7
- //#region src/patterns/disable/teams/modifies/modify-nav-user.ts
8
- function s(e) {
9
- if (!o.existsSync(e)) return {
10
- status: "success",
11
- changed: !1
12
- };
13
- let t = o.readFileSync(e, "utf8");
14
- if (!t.includes("/teams")) return {
15
- status: "success",
16
- changed: !1
17
- };
18
- let n = new i(t), a = !1, s = (e) => {
19
- a || e((e) => {
20
- let t = r(e, "Teams", "@lucide/svelte/icons/users");
21
- return t.wasRemoved && (a = !0), t.source;
22
- });
23
- };
24
- return s((e) => n.modifyModuleScript(e)), a || s((e) => n.modifyScript(e)), a ? (o.writeFileSync(e, n.toString(), "utf8"), {
25
- status: "success",
26
- changed: !0
27
- }) : {
28
- status: "success",
29
- changed: !1
30
- };
31
- }
32
- //#endregion
33
- //#region src/patterns/disable/teams/generate.runtime.ts
34
- var c = ["app-sidebar, +layout.server.ts (teams loader), and app-layout.svelte (AppSidebar team props) must be reverted manually.", "These edits are substantial and are not safely reversed by tooling."].join(" ");
35
- async function l(r) {
36
- let i = e(r), l = [], u = (e) => {
37
- e && l.push(e);
38
- };
39
- i.info("Reverting nav-user.svelte");
40
- let d = [a.join(r.root, "src", "lib", "components", "nav-user.svelte")], f = d.find((e) => o.existsSync(e)) ?? d[0];
41
- return u(n(f, s(f))), i.info(c), {
42
- creates: [],
43
- modifies: l,
44
- deletes: [],
45
- components: [],
46
- packages: [],
47
- collections: [],
48
- collectionPatches: [],
49
- collectionDrops: await t([
50
- "team_invite_links",
51
- "team_invites",
52
- "team_memberships",
53
- "teams"
54
- ], r)
55
- };
56
- }
57
- //#endregion
58
- export { l as generate };
59
-
60
- //# sourceMappingURL=generate.runtime-BtL9FPuW.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generate.runtime-BtL9FPuW.js","names":[],"sources":["../../src/patterns/disable/teams/modifies/modify-nav-user.ts","../../src/patterns/disable/teams/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { removeNavItemFromScript } from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyNavUser(navUserPath: string): ModifyOutcome {\n if (!fs.existsSync(navUserPath)) {\n return { status: \"success\", changed: false };\n }\n\n const source = fs.readFileSync(navUserPath, \"utf8\");\n if (!source.includes(\"/teams\")) {\n return { status: \"success\", changed: false };\n }\n\n const file = new SvelteFile(source);\n let wasRemoved = false;\n\n const tryRemove = (run: (fn: (s: string) => string) => boolean) => {\n if (wasRemoved) return;\n run((src) => {\n const result = removeNavItemFromScript(\n src,\n \"Teams\",\n \"@lucide/svelte/icons/users\",\n );\n if (result.wasRemoved) wasRemoved = true;\n return result.source;\n });\n };\n\n tryRemove((fn) => file.modifyModuleScript(fn));\n if (!wasRemoved) tryRemove((fn) => file.modifyScript(fn));\n\n if (!wasRemoved) {\n return { status: \"success\", changed: false };\n }\n\n fs.writeFileSync(navUserPath, file.toString(), \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import path from \"node:path\";\nimport fs from \"node:fs\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { unmodifyNavUser } from \"./modifies/modify-nav-user\";\nimport { planDropsForCollections } from \"../../destroy/shared\";\n\nconst MANUAL_REMEDIATION = [\n \"app-sidebar, +layout.server.ts (teams loader), and app-layout.svelte (AppSidebar team props) must be reverted manually.\",\n \"These edits are substantial and are not safely reversed by tooling.\",\n].join(\" \");\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Reverting nav-user.svelte\");\n const navUserCandidates = [\n path.join(options.root, \"src\", \"lib\", \"components\", \"nav-user.svelte\"),\n ];\n const navUserPath =\n navUserCandidates.find((p) => fs.existsSync(p)) ?? navUserCandidates[0];\n pushResult(modifyOutcomeToFile(navUserPath, unmodifyNavUser(navUserPath)));\n\n logger.info(MANUAL_REMEDIATION);\n\n const collectionDrops = await planDropsForCollections(\n [\"team_invite_links\", \"team_invites\", \"team_memberships\", \"teams\"],\n options,\n );\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops,\n } satisfies Result;\n}\n"],"mappings":";;;;;;;AAKA,SAAgB,EAAgB,GAAoC;CAClE,IAAI,CAAC,EAAG,WAAW,CAAW,GAC5B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAM,IAAS,EAAG,aAAa,GAAa,MAAM;CAClD,IAAI,CAAC,EAAO,SAAS,QAAQ,GAC3B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAM,IAAO,IAAI,EAAW,CAAM,GAC9B,IAAa,IAEX,KAAa,MAAgD;EAC7D,KACJ,GAAK,MAAQ;GACX,IAAM,IAAS,EACb,GACA,SACA,4BACF;GAEA,OADI,EAAO,eAAY,IAAa,KAC7B,EAAO;EAChB,CAAC;CACH;CAUA,OARA,GAAW,MAAO,EAAK,mBAAmB,CAAE,CAAC,GACxC,KAAY,GAAW,MAAO,EAAK,aAAa,CAAE,CAAC,GAEnD,KAIL,EAAG,cAAc,GAAa,EAAK,SAAS,GAAG,MAAM,GAC9C;EAAE,QAAQ;EAAW,SAAS;CAAK,KAJjC;EAAE,QAAQ;EAAW,SAAS;CAAM;AAK/C;;;AChCA,IAAM,IAAqB,CACzB,2HACA,qEACF,CAAC,CAAC,KAAK,GAAG;AAEV,eAAsB,EAAS,GAAkB;CAC/C,IAAM,IAAS,EAAU,CAAO,GAC1B,IAAmB,CAAC,GACpB,KAAc,MAAsB;EACxC,AAAI,KAAM,EAAS,KAAK,CAAI;CAC9B;CAEA,EAAO,KAAK,2BAA2B;CACvC,IAAM,IAAoB,CACxB,EAAK,KAAK,EAAQ,MAAM,OAAO,OAAO,cAAc,iBAAiB,CACvE,GACM,IACJ,EAAkB,MAAM,MAAM,EAAG,WAAW,CAAC,CAAC,KAAK,EAAkB;CAUvE,OATA,EAAW,EAAoB,GAAa,EAAgB,CAAW,CAAC,CAAC,GAEzE,EAAO,KAAK,CAAkB,GAOvB;EACL,SAAS,CAAC;EACV;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAA,MAb4B,EAC5B;GAAC;GAAqB;GAAgB;GAAoB;EAAO,GACjE,CACF;CAWA;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"generate.runtime-CIuSkWtY.js","names":[],"sources":["../../src/patterns/enable/i18n/modifies/vite-config.ts","../../src/patterns/enable/i18n/modifies/svelte-config.ts","../../src/patterns/enable/i18n/modifies/hooks.server.ts","../../src/patterns/enable/i18n/modifies/app-html.ts","../../src/patterns/enable/i18n/modifies/gitignore.ts","../../src/patterns/enable/i18n/modifies/+layout.ts","../../src/patterns/enable/i18n/modifies/root-layout.svelte.ts","../../src/patterns/enable/i18n/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { Project, QuoteKind, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst FAILURE_HINT = [\n \"Add the wuchale plugin to your Vite config:\",\n \"\",\n \"import { wuchale } from 'wuchale/vite';\",\n \"\",\n \"export default defineConfig({\",\n \" plugins: [wuchale(), /* ...existing plugins */],\",\n \"});\",\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create a Vite config with the wuchale plugin:\",\n \"\",\n \"import { defineConfig } from 'vite';\",\n \"import { wuchale } from 'wuchale/vite';\",\n \"\",\n \"export default defineConfig({\",\n \" plugins: [wuchale()],\",\n \"});\",\n].join(\"\\n\");\n\nexport function modifyViteConfig(viteConfigPath: string): ModifyOutcome {\n if (!fs.existsSync(viteConfigPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(viteConfigPath);\n\n let changed = false;\n let failed = false;\n\n const hasImport = sourceFile\n .getImportDeclarations()\n .some((d) => d.getModuleSpecifierValue() === \"wuchale/vite\");\n\n if (!hasImport) {\n sourceFile.insertImportDeclaration(0, {\n namedImports: [\"wuchale\"],\n moduleSpecifier: \"wuchale/vite\",\n });\n changed = true;\n }\n\n const defineConfigCall = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"defineConfig\");\n\n const configArg = defineConfigCall?.getArguments()?.[0];\n const configObj =\n configArg?.getKind() === SyntaxKind.ObjectLiteralExpression\n ? (configArg as import(\"ts-morph\").ObjectLiteralExpression)\n : null;\n\n if (!configObj) {\n failed = true;\n } else {\n const pluginsProp = configObj.getProperty(\"plugins\");\n if (!pluginsProp) {\n configObj.addPropertyAssignment({\n name: \"plugins\",\n initializer: \"[wuchale()]\",\n });\n changed = true;\n } else if (pluginsProp.getKind() !== SyntaxKind.PropertyAssignment) {\n failed = true;\n } else {\n const pluginsInit = (\n pluginsProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n\n if (!pluginsInit) {\n (pluginsProp as import(\"ts-morph\").PropertyAssignment).setInitializer(\n \"[wuchale()]\",\n );\n changed = true;\n } else if (pluginsInit.getKind() !== SyntaxKind.ArrayLiteralExpression) {\n failed = true;\n } else {\n const arr = pluginsInit as import(\"ts-morph\").ArrayLiteralExpression;\n const hasWuchale = arr\n .getElements()\n .some((el) => el.getText().replace(/\\s/g, \"\") === \"wuchale()\");\n\n if (!hasWuchale) {\n arr.insertElement(0, \"wuchale()\");\n changed = true;\n }\n }\n }\n }\n\n if (changed) {\n sourceFile.formatText();\n sourceFile.saveSync();\n }\n\n if (failed) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n return { status: \"success\", changed };\n}\n","import { SyntaxKind, type PropertyAssignment } from \"ts-morph\";\nimport {\n getOrCreateObjectLiteralProperty,\n modifyConfig,\n type ConfigModifyResult,\n} from \"../../../../runtime/config-target\";\n\nconst FAILURE_HINT = [\n \"Add the $locales alias to your config (sveltekit() arg in vite.config, or svelte.config):\",\n \"\",\n \"alias: {\",\n \" $locales: 'src/locales',\",\n \"},\",\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Add the $locales alias by passing config to the sveltekit() plugin in vite.config.ts:\",\n \"\",\n \"import { sveltekit } from '@sveltejs/kit/vite';\",\n \"import { defineConfig } from 'vite';\",\n \"\",\n \"export default defineConfig({\",\n \" plugins: [sveltekit({ alias: { $locales: 'src/locales' } })],\",\n \"});\",\n].join(\"\\n\");\n\n/** Ensure the `$locales` alias points at `src/locales`. */\nexport function modifySvelteConfig(root: string): ConfigModifyResult {\n return modifyConfig(\n root,\n { notFound: NOT_FOUND_HINT, failed: FAILURE_HINT },\n (target) => {\n const kit = target.kitContainer();\n if (!kit) return false;\n const aliasObj = getOrCreateObjectLiteralProperty(kit, \"alias\", \"{}\");\n if (!aliasObj) return false;\n\n const existing = aliasObj.getProperty(\"$locales\");\n if (!existing) {\n aliasObj.addPropertyAssignment({\n name: \"$locales\",\n initializer: \"'src/locales'\",\n });\n return true;\n }\n if (existing.getKind() !== SyntaxKind.PropertyAssignment) return false;\n\n const init = (existing as PropertyAssignment).getInitializer();\n const current = init?.getText()?.replace(/['\"`]/g, \"\");\n if (current !== \"src/locales\") {\n (existing as PropertyAssignment).setInitializer(\"'src/locales'\");\n }\n return true;\n },\n );\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst FAILURE_HINT = dedent`\n Wrap your exported handle with the wuchale i18n handler:\n\n import { sequence } from '@sveltejs/kit/hooks';\n import { runWithLocale, loadLocales } from 'wuchale/load-utils/server';\n import { getLocale } from '$locales/main.url';\n import { locales } from '$locales/data';\n import * as main from '$locales/main.loader.server.svelte.js';\n import * as js from '$locales/js.loader.server.js';\n\n loadLocales(main.key, main.loadCount, main.loadCatalog, locales);\n loadLocales(js.key, js.loadCount, js.loadCatalog, locales);\n\n const handleWuchale = async ({ event, resolve }: any) => {\n const locale = getLocale(event.url);\n return await runWithLocale(locale, () =>\n resolve(event, {\n transformPageChunk: ({ html }: { html: string }) =>\n html.replace('%sveltekit.lang%', locale),\n }),\n );\n };\n\n export const handle = sequence(handleWuchale, /* your existing handle */);\n`;\n\nconst NOT_FOUND_HINT = dedent`\n Create src/hooks.server.ts with an i18n handle:\n\n import { sequence } from '@sveltejs/kit/hooks';\n import { runWithLocale, loadLocales } from 'wuchale/load-utils/server';\n import { getLocale } from '$locales/main.url';\n import { locales } from '$locales/data';\n import * as main from '$locales/main.loader.server.svelte.js';\n import * as js from '$locales/js.loader.server.js';\n\n loadLocales(main.key, main.loadCount, main.loadCatalog, locales);\n loadLocales(js.key, js.loadCount, js.loadCatalog, locales);\n\n const handleWuchale = async ({ event, resolve }: any) => {\n const locale = getLocale(event.url);\n return await runWithLocale(locale, () =>\n resolve(event, {\n transformPageChunk: ({ html }: { html: string }) =>\n html.replace('%sveltekit.lang%', locale),\n }),\n );\n };\n\n export const handle = handleWuchale;\n`;\n\nfunction ensureNamedImport(\n sourceFile: import(\"ts-morph\").SourceFile,\n moduleSpecifier: string,\n name: string,\n) {\n const existing = sourceFile\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === moduleSpecifier);\n if (existing) {\n const has = existing.getNamedImports().some((ni) => ni.getName() === name);\n if (!has) existing.addNamedImport(name);\n return;\n }\n sourceFile.addImportDeclaration({ namedImports: [name], moduleSpecifier });\n}\n\nfunction ensureNamespaceImport(\n sourceFile: import(\"ts-morph\").SourceFile,\n moduleSpecifier: string,\n ns: string,\n) {\n const existing = sourceFile\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === moduleSpecifier);\n if (existing) return;\n sourceFile.addImportDeclaration({ namespaceImport: ns, moduleSpecifier });\n}\n\nexport function modifyHooksServerI18n(hooksServerPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const original = fs.readFileSync(hooksServerPath, \"utf8\");\n if (original.includes(\"runWithLocale\") || original.includes(\"loadLocales(\")) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n const handleDecl = sourceFile.getVariableDeclaration(\"handle\");\n if (!handleDecl) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const handleStmt = handleDecl.getFirstAncestorByKind(\n SyntaxKind.VariableStatement,\n );\n if (!handleStmt?.hasExportKeyword()) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n ensureNamedImport(sourceFile, \"@sveltejs/kit/hooks\", \"sequence\");\n ensureNamedImport(sourceFile, \"wuchale/load-utils/server\", \"runWithLocale\");\n ensureNamedImport(sourceFile, \"wuchale/load-utils/server\", \"loadLocales\");\n ensureNamedImport(sourceFile, \"$locales/main.url\", \"getLocale\");\n ensureNamedImport(sourceFile, \"$locales/data\", \"locales\");\n ensureNamespaceImport(\n sourceFile,\n \"$locales/main.loader.server.svelte.js\",\n \"main\",\n );\n ensureNamespaceImport(sourceFile, \"$locales/js.loader.server.js\", \"js\");\n\n const statements = sourceFile.getStatements();\n const handleStmtIndex = statements.findIndex((s) => s === handleStmt);\n const i18nHandleName = \"handleWuchale\";\n\n const startupSnippet = dedent`\n loadLocales(main.key, main.loadCount, main.loadCatalog, locales);\n loadLocales(js.key, js.loadCount, js.loadCatalog, locales);\n `;\n\n const i18nHandleSnippet = dedent`\n const ${i18nHandleName} = async ({ event, resolve }: any) => {\n const locale = getLocale(event.url);\n return await runWithLocale(locale, () =>\n resolve(event, {\n transformPageChunk: ({ html }: { html: string }) =>\n html.replace('%sveltekit.lang%', locale)\n })\n );\n };\n `;\n\n if (handleStmtIndex >= 0) {\n sourceFile.insertStatements(\n handleStmtIndex,\n `\\n${startupSnippet}\\n\\n${i18nHandleSnippet}\\n`,\n );\n } else {\n sourceFile.addStatements(`\\n${startupSnippet}\\n\\n${i18nHandleSnippet}\\n`);\n }\n\n const init = handleDecl.getInitializer();\n if (!init) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const initText = init.getText();\n if (initText.includes(i18nHandleName) || initText.includes(\"runWithLocale\")) {\n return { status: \"success\", changed: false };\n }\n\n handleDecl.setInitializer(`sequence(${i18nHandleName}, ${initText})`);\n sourceFile.formatText();\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst FAILURE_HINT = [\n \"Add the sveltekit lang placeholder to the <html> tag:\",\n \"\",\n '<html lang=\"%sveltekit.lang%\">',\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create src/app.html with a lang placeholder:\",\n \"\",\n \"<!doctype html>\",\n '<html lang=\"%sveltekit.lang%\">',\n \" <head>\",\n ' <meta charset=\"utf-8\" />',\n \" %sveltekit.head%\",\n \" </head>\",\n ' <body data-sveltekit-preload-data=\"hover\">',\n ' <div style=\"display: contents\">%sveltekit.body%</div>',\n \" </body>\",\n \"</html>\",\n].join(\"\\n\");\n\nexport function modifyAppHtml(appHtmlPath: string): ModifyOutcome {\n if (!fs.existsSync(appHtmlPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const original = fs.readFileSync(appHtmlPath, \"utf8\");\n if (\n original.includes('lang=\"%sveltekit.lang%\"') ||\n original.includes(\"lang='%sveltekit.lang%'\")\n ) {\n return { status: \"success\", changed: false };\n }\n\n const updated = original.replace(/<html(\\s[^>]*?)?>/i, (match) => {\n if (/lang\\s*=/.test(match)) {\n return match;\n }\n return match.replace(/<html/i, '<html lang=\"%sveltekit.lang%\"');\n });\n\n if (updated === original) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n fs.writeFileSync(appHtmlPath, updated);\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst NOT_FOUND_HINT = [\n \"Create a .gitignore with the wuchale cache ignored:\",\n \"\",\n \"# Wuchale\",\n \"src/locales/.wuchale\",\n].join(\"\\n\");\n\nexport function modifyGitignore(gitignorePath: string): ModifyOutcome {\n if (!fs.existsSync(gitignorePath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const original = fs.readFileSync(gitignorePath, \"utf8\");\n if (original.includes(\"src/locales/.wuchale\")) {\n return { status: \"success\", changed: false };\n }\n\n const block = dedent`\n # Wuchale\n src/locales/.wuchale\n `;\n\n const needsNewline = original.length > 0 && !original.endsWith(\"\\n\");\n const updated = original + (needsNewline ? \"\\n\" : \"\") + \"\\n\" + block + \"\\n\";\n fs.writeFileSync(gitignorePath, updated);\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport dedent from \"dedent\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst LOAD_SNIPPET = dedent`\n import { browser } from '$app/environment';\n import { loadLocale } from 'wuchale/load-utils';\n\n import { getLocale } from '$locales/main.url';\n import '$locales/main.loader.svelte';\n import '$locales/js.loader';\n\n export const load = async ({ url, data }) => {\n const locale = getLocale(url);\n\n if (browser) {\n await loadLocale(locale);\n }\n\n return data;\n };\n`;\n\nconst FAILURE_HINT = [\n \"Merge the wuchale loader into your existing load function in +layout.ts:\",\n \"\",\n LOAD_SNIPPET,\n].join(\"\\n\");\n\nexport function ensureRootLayoutI18n(layoutPath: string): ModifyOutcome {\n if (fs.existsSync(layoutPath)) {\n const existing = fs.readFileSync(layoutPath, \"utf8\");\n if (existing.includes(\"loadLocale\") || existing.includes(\"translateUrl\")) {\n return { status: \"success\", changed: false };\n }\n\n if (/\\bexport\\s+(const|function)\\s+load\\b/.test(existing)) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n }\n\n fs.mkdirSync(path.dirname(layoutPath), { recursive: true });\n fs.writeFileSync(layoutPath, LOAD_SNIPPET + \"\\n\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureImports,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst LANGUAGE_SELECT_SNIPPET = `<Navbar.Item>\n\t\t\t\t<LanguageSelect />\n\t\t\t</Navbar.Item>\n\t\t\t`;\n\nconst IMPORT_SNIPPET = dedent`\n import LanguageSelect from '$lib/components/language-select.svelte';\n`;\n\nconst FAILURE_HINT = [\n \"Add the language select inside your <Navbar.List> in the root layout.\",\n \"\",\n \"Import to add to the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add at the end of <Navbar.List>:\",\n LANGUAGE_SELECT_SNIPPET,\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create a root layout that includes a language select inside <Navbar.List>.\",\n \"\",\n \"Import for the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup at the end of <Navbar.List>:\",\n LANGUAGE_SELECT_SNIPPET,\n].join(\"\\n\");\n\nexport function modifyRootLayoutLanguageSelect(\n layoutPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n if (!file.hasElement(\"Navbar.List\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n if (file.hasElement(\"LanguageSelect\")) {\n return { status: \"success\", changed: false };\n }\n\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n ensureImports(sf, [\n {\n defaultImport: \"LanguageSelect\",\n moduleSpecifier: \"$lib/components/language-select.svelte\",\n },\n ]);\n });\n return out;\n });\n\n file.insertBeforeClosingTag(\"Navbar.List\", LANGUAGE_SELECT_SNIPPET);\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport {\n probeFirstExisting,\n VITE_CONFIG_CANDIDATES,\n} from \"../../../runtime/config-target\";\nimport { modifyViteConfig } from \"./modifies/vite-config\";\nimport { modifySvelteConfig } from \"./modifies/svelte-config\";\nimport { modifyHooksServerI18n } from \"./modifies/hooks.server\";\nimport { modifyAppHtml } from \"./modifies/app-html\";\nimport { modifyGitignore } from \"./modifies/gitignore\";\nimport { ensureRootLayoutI18n } from \"./modifies/+layout\";\nimport { modifyRootLayoutLanguageSelect } from \"./modifies/root-layout.svelte\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Modifying vite.config\");\n const viteConfigPath =\n probeFirstExisting(options.root, VITE_CONFIG_CANDIDATES) ??\n path.join(options.root, VITE_CONFIG_CANDIDATES[0]);\n pushResult(\n modifyOutcomeToFile(viteConfigPath, modifyViteConfig(viteConfigPath)),\n );\n\n logger.info(\"Modifying config for i18n alias\");\n const alias = modifySvelteConfig(options.root);\n pushResult(modifyOutcomeToFile(alias.filePath, alias.outcome));\n\n logger.info(\"Modifying hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n pushResult(\n modifyOutcomeToFile(\n hooksServerPath,\n modifyHooksServerI18n(hooksServerPath),\n ),\n );\n\n logger.info(\"Modifying app.html\");\n const appHtmlPath = path.join(options.root, \"src\", \"app.html\");\n pushResult(modifyOutcomeToFile(appHtmlPath, modifyAppHtml(appHtmlPath)));\n\n logger.info(\"Modifying root +layout.ts\");\n const layoutPath = path.join(options.root, \"src\", \"routes\", \"+layout.ts\");\n pushResult(modifyOutcomeToFile(layoutPath, ensureRootLayoutI18n(layoutPath)));\n\n logger.info(\"Modifying root layout language select\");\n const rootLayoutCandidates = [\n path.join(options.root, \"src\", \"routes\", \"(public)\", \"root-layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"root-layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"(public)\", \"+layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"+layout.svelte\"),\n ];\n const rootLayoutPath =\n rootLayoutCandidates.find((p) => fs.existsSync(p)) ??\n rootLayoutCandidates[0];\n pushResult(\n modifyOutcomeToFile(\n rootLayoutPath,\n modifyRootLayoutLanguageSelect(rootLayoutPath),\n ),\n );\n\n logger.info(\"Updating .gitignore\");\n const gitignorePath = path.join(options.root, \".gitignore\");\n pushResult(\n modifyOutcomeToFile(gitignorePath, modifyGitignore(gitignorePath)),\n );\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;AAIA,IAAM,IAAe;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,IAAI,GAEL,IAAiB;CACrB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,IAAI;AAEX,SAAgB,EAAiB,GAAuC;CACtE,IAAI,CAAC,EAAG,WAAW,CAAc,GAC/B,OAAO;EAAE,QAAQ;EAAa,SAAS;CAAe;CAOxD,IAAM,IAAa,IAJC,EAAQ;EAC1B,iBAAiB,EAAE,SAAS,GAAK;EACjC,sBAAsB,EAAE,WAAW,EAAU,OAAO;CACtD,CACmB,CAAA,CAAQ,oBAAoB,CAAc,GAEzD,IAAU,IACV,IAAS;CAMb,AAJkB,EACf,sBAAsB,CAAC,CACvB,MAAM,MAAM,EAAE,wBAAwB,MAAM,cAE1C,MACH,EAAW,wBAAwB,GAAG;EACpC,cAAc,CAAC,SAAS;EACxB,iBAAiB;CACnB,CAAC,GACD,IAAU;CAOZ,IAAM,IAJmB,EACtB,qBAAqB,EAAW,cAAc,CAAC,CAC/C,MAAM,MAAO,EAAG,cAAc,CAAC,CAAC,QAAQ,MAAM,cAE/B,CAAA,EAAkB,aAAa,CAAC,GAAG,IAC/C,IACJ,GAAW,QAAQ,MAAM,EAAW,0BAC/B,IACD;CAEN,IAAI,CAAC,GACH,IAAS;MACJ;EACL,IAAM,IAAc,EAAU,YAAY,SAAS;EACnD,IAAI,CAAC,GAKH,AAJA,EAAU,sBAAsB;GAC9B,MAAM;GACN,aAAa;EACf,CAAC,GACD,IAAU;OACL,IAAI,EAAY,QAAQ,MAAM,EAAW,oBAC9C,IAAS;OACJ;GACL,IAAM,IACJ,EACA,eAAe;GAEjB,IAAI,CAAC,GAIH,AAHA,EAAuD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,GAEA,EAAO,KAAK,oBAAoB;CAChC,IAAM,IAAc,EAAK,KAAK,EAAQ,MAAM,OAAO,UAAU;CAG7D,AAFA,EAAW,EAAoB,GAAa,EAAc,CAAW,CAAC,CAAC,GAEvE,EAAO,KAAK,2BAA2B;CACvC,IAAM,IAAa,EAAK,KAAK,EAAQ,MAAM,OAAO,UAAU,YAAY;CAGxE,AAFA,EAAW,EAAoB,GAAY,EAAqB,CAAU,CAAC,CAAC,GAE5E,EAAO,KAAK,uCAAuC;CACnD,IAAM,IAAuB;EAC3B,EAAK,KAAK,EAAQ,MAAM,OAAO,UAAU,YAAY,oBAAoB;EACzE,EAAK,KAAK,EAAQ,MAAM,OAAO,UAAU,oBAAoB;EAC7D,EAAK,KAAK,EAAQ,MAAM,OAAO,UAAU,YAAY,gBAAgB;EACrE,EAAK,KAAK,EAAQ,MAAM,OAAO,UAAU,gBAAgB;CAC3D,GACM,IACJ,EAAqB,MAAM,MAAM,EAAG,WAAW,CAAC,CAAC,KACjD,EAAqB;CAQvB,AAPA,EACE,EACE,GACA,EAA+B,CAAc,CAC/C,CACF,GAEA,EAAO,KAAK,qBAAqB;CACjC,IAAM,IAAgB,EAAK,KAAK,EAAQ,MAAM,YAAY;CAK1D,OAJA,EACE,EAAoB,GAAe,EAAgB,CAAa,CAAC,CACnE,GAEO;EACL,SAAS,CAAC;EACV;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"generate.runtime-CRgw-aja.js","names":[],"sources":["../../src/patterns/disable/content-negotiation/modifies/hooks.server.ts","../../src/patterns/disable/content-negotiation/modifies/hooks.ts","../../src/patterns/disable/content-negotiation/modifies/root-layout.svelte.ts","../../src/patterns/disable/content-negotiation/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { Project, QuoteKind, SyntaxKind, type SourceFile } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nfunction removeNegotiateImport(sourceFile: SourceFile): boolean {\n const decl = sourceFile\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === \"$lib/negotiate\");\n if (!decl) return false;\n\n const named = decl.getNamedImports().find((ni) => {\n return (\n ni.getName() === \"handle\" &&\n ni.getAliasNode()?.getText() === \"handleNegotiate\"\n );\n });\n\n if (!named) return false;\n\n if (decl.getNamedImports().length === 1 && !decl.getDefaultImport()) {\n decl.remove();\n } else {\n named.remove();\n }\n return true;\n}\n\nfunction removeSequenceImportIfUnused(sourceFile: SourceFile): void {\n const decl = sourceFile\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === \"@sveltejs/kit/hooks\");\n if (!decl) return;\n\n const stillReferenced = sourceFile\n .getDescendantsOfKind(SyntaxKind.Identifier)\n .some((id) => {\n if (id.getText() !== \"sequence\") return false;\n const parent = id.getParent();\n const kind = parent?.getKind();\n return (\n kind !== SyntaxKind.ImportSpecifier && kind !== SyntaxKind.ImportClause\n );\n });\n\n if (stillReferenced) return;\n\n const named = decl\n .getNamedImports()\n .find((ni) => ni.getName() === \"sequence\");\n if (!named) return;\n\n if (decl.getNamedImports().length === 1 && !decl.getDefaultImport()) {\n decl.remove();\n } else {\n named.remove();\n }\n}\n\nexport function unmodifyHooksServerNegotiate(\n hooksServerPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(hooksServerPath, \"utf8\");\n if (!original.includes(\"handleNegotiate\")) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n const handleDecl = sourceFile.getVariableDeclaration(\"handle\");\n if (!handleDecl) {\n removeNegotiateImport(sourceFile);\n removeSequenceImportIfUnused(sourceFile);\n sourceFile.formatText();\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== original,\n };\n }\n\n const init = handleDecl.getInitializer();\n if (init?.getKind() === SyntaxKind.CallExpression) {\n const call = init.asKindOrThrow(SyntaxKind.CallExpression);\n if (call.getExpression().getText() === \"sequence\") {\n const args = call.getArguments();\n const idx = args.findIndex((arg) => arg.getText() === \"handleNegotiate\");\n if (idx >= 0) {\n if (args.length === 2) {\n const keepText = args[idx === 0 ? 1 : 0].getText();\n handleDecl.setInitializer(keepText);\n } else {\n call.removeArgument(idx);\n }\n }\n }\n }\n\n removeNegotiateImport(sourceFile);\n removeSequenceImportIfUnused(sourceFile);\n sourceFile.formatText();\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== original,\n };\n}\n","import fs from \"node:fs\";\nimport { Project, QuoteKind, SyntaxKind, type SourceFile } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nfunction removeNegotiateImport(sourceFile: SourceFile): boolean {\n const decl = sourceFile\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === \"$lib/negotiate\");\n if (!decl) return false;\n\n const named = decl.getNamedImports().find((ni) => {\n return (\n ni.getName() === \"reroute\" &&\n ni.getAliasNode()?.getText() === \"negotiateReroute\"\n );\n });\n if (!named) return false;\n\n if (decl.getNamedImports().length === 1 && !decl.getDefaultImport()) {\n decl.remove();\n } else {\n named.remove();\n }\n return true;\n}\n\nfunction isMeaningfullyEmpty(sourceFile: SourceFile): boolean {\n return sourceFile\n .getStatements()\n .every((s) => s.getKind() === SyntaxKind.EmptyStatement);\n}\n\nexport function unmodifyHooksNegotiate(hooksPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(hooksPath, \"utf8\");\n if (!original.includes(\"negotiateReroute\")) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(hooksPath);\n\n const rerouteDecl = sourceFile.getVariableDeclaration(\"reroute\");\n const init = rerouteDecl?.getInitializer();\n const initText = init?.getText() ?? \"\";\n\n const hasI18nHelper = sourceFile\n .getVariableDeclarations()\n .some((d) => d.getName() === \"rerouteDeLocalize\");\n\n if (\n rerouteDecl &&\n hasI18nHelper &&\n initText.includes(\"rerouteDeLocalize\") &&\n initText.includes(\"negotiateReroute\")\n ) {\n rerouteDecl.setInitializer(\"({ url }) => rerouteDeLocalize(url.pathname)\");\n } else if (rerouteDecl && initText.includes(\"negotiateReroute\")) {\n const stmt = rerouteDecl.getFirstAncestorByKind(\n SyntaxKind.VariableStatement,\n );\n stmt?.remove();\n }\n\n removeNegotiateImport(sourceFile);\n\n if (isMeaningfullyEmpty(sourceFile)) {\n fs.rmSync(hooksPath, { force: true });\n return { status: \"success\", changed: true };\n }\n\n sourceFile.formatText();\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== original,\n };\n}\n","import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n removeImportByModuleSpecifier,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyRootLayoutNegotiate(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n const hasElement = file.hasElement(\"Negotiate\");\n\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n removeImportByModuleSpecifier(sf, \"$lib/negotiate\");\n });\n return out;\n });\n\n if (hasElement) {\n file.removeElement(\"Negotiate\");\n }\n\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { unmodifyHooksServerNegotiate } from \"./modifies/hooks.server\";\nimport { unmodifyHooksNegotiate } from \"./modifies/hooks\";\nimport { unmodifyRootLayoutNegotiate } from \"./modifies/root-layout.svelte\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Reverting hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n pushResult(\n modifyOutcomeToFile(\n hooksServerPath,\n unmodifyHooksServerNegotiate(hooksServerPath),\n ),\n );\n\n logger.info(\"Reverting hooks.ts\");\n const hooksPath = path.join(options.root, \"src\", \"hooks.ts\");\n pushResult(modifyOutcomeToFile(hooksPath, unmodifyHooksNegotiate(hooksPath)));\n\n logger.info(\"Reverting src/routes/+layout.svelte\");\n const rootLayoutPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(\n rootLayoutPath,\n unmodifyRootLayoutNegotiate(rootLayoutPath),\n ),\n );\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;AAIA,SAAS,EAAsB,GAAiC;CAC9D,IAAM,IAAO,EACV,sBAAsB,CAAC,CACvB,MAAM,MAAM,EAAE,wBAAwB,MAAM,gBAAgB;CAC/D,IAAI,CAAC,GAAM,OAAO;CAElB,IAAM,IAAQ,EAAK,gBAAgB,CAAC,CAAC,MAAM,MAEvC,EAAG,QAAQ,MAAM,YACjB,EAAG,aAAa,CAAC,EAAE,QAAQ,MAAM,iBAEpC;CASD,OAPK,KAED,EAAK,gBAAgB,CAAC,CAAC,WAAW,KAAK,CAAC,EAAK,iBAAiB,IAChE,EAAK,OAAO,IAEZ,EAAM,OAAO,GA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xC,AAAI,KAAM,EAAS,KAAK,CAAI;CAC9B;CAEA,EAAO,KAAK,2BAA2B;CACvC,IAAM,IAAkB,EAAK,KAAK,EAAQ,MAAM,OAAO,iBAAiB;CAQxE,AAPA,EACE,EACE,GACA,EAA6B,CAAe,CAC9C,CACF,GAEA,EAAO,KAAK,oBAAoB;CAChC,IAAM,IAAY,EAAK,KAAK,EAAQ,MAAM,OAAO,UAAU;CAG3D,AAFA,EAAW,EAAoB,GAAW,EAAuB,CAAS,CAAC,CAAC,GAE5E,EAAO,KAAK,qCAAqC;CACjD,IAAM,IAAiB,EAAK,KAC1B,EAAQ,MACR,OACA,UACA,gBACF;CAQA,OAPA,EACE,EACE,GACA,EAA4B,CAAc,CAC5C,CACF,GAEO;EACL,SAAS,CAAC;EACV;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"test-setup-BBb4kcoO.js","names":[],"sources":["../../src/patterns/enable/backend/modifies/svelte-config.ts","../../src/patterns/enable/backend/modifies/gitignore.ts","../../src/patterns/enable/backend/modifies/test-setup.ts"],"sourcesContent":["import dedent from \"dedent\";\nimport { SyntaxKind } from \"ts-morph\";\nimport {\n resolveConfigTarget,\n saveTarget,\n type ConfigModifyResult,\n type ConfigTarget,\n} from \"../../../../runtime/config-target\";\n\nconst ADAPTER_NODE = \"@sveltejs/adapter-node\";\nconst ADAPTER_STATIC = \"@sveltejs/adapter-static\";\nconst ADAPTER_AUTO = \"@sveltejs/adapter-auto\";\n\nconst FAILURE_HINT = dedent`\n Switch the SvelteKit adapter to ${ADAPTER_NODE}:\n\n import adapter from '${ADAPTER_NODE}';\n\n // ...\n adapter: adapter()\n`;\n\nconst NOT_FOUND_HINT = dedent`\n Configure ${ADAPTER_NODE} via the sveltekit() plugin in vite.config.ts.\n`;\n\n/**\n * The adapters this pattern moves between. adapter-auto is included because\n * that is what `sv create` ships, and a project that never chose is one the\n * backend is free to decide for.\n */\nfunction findAdapterImport(sourceFile: ConfigTarget[\"sourceFile\"]) {\n return sourceFile\n .getImportDeclarations()\n .find((decl) =>\n [ADAPTER_STATIC, ADAPTER_AUTO, ADAPTER_NODE].includes(\n decl.getModuleSpecifierValue(),\n ),\n );\n}\n\nfunction adapterCalls(sourceFile: ConfigTarget[\"sourceFile\"]) {\n return sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .filter((ce) => ce.getExpression().getText() === \"adapter\");\n}\n\n/**\n * Switch the adapter to `@sveltejs/adapter-node` and drop its arguments, in\n * whichever file holds the adapter import + `adapter()` call (vite.config when\n * the project uses inline config, else svelte.config). A project with a\n * backend is served from a Node process, which is what `vela deploy` runs.\n * Operates on the import and call expression directly, so it never needs the\n * config object.\n */\nexport function modifySvelteConfig(root: string): ConfigModifyResult {\n const res = resolveConfigTarget(root, {\n notFound: NOT_FOUND_HINT,\n failed: FAILURE_HINT,\n });\n if (res.status !== \"resolved\") {\n return {\n filePath: res.filePath,\n outcome: { status: res.status, message: res.message },\n };\n }\n const { target } = res;\n const adapterImport = findAdapterImport(target.sourceFile);\n if (!adapterImport) {\n return {\n filePath: target.filePath,\n outcome: { status: \"failed\", message: FAILURE_HINT },\n };\n }\n\n if (adapterImport.getModuleSpecifierValue() !== ADAPTER_NODE) {\n adapterImport.setModuleSpecifier(ADAPTER_NODE);\n }\n\n for (const call of adapterCalls(target.sourceFile)) {\n const args = call.getArguments();\n for (let i = args.length - 1; i >= 0; i--) {\n call.removeArgument(i);\n }\n }\n\n return { filePath: target.filePath, outcome: saveTarget(target) };\n}\n\n/**\n * Reverse of {@link modifySvelteConfig}: switch back to\n * `@sveltejs/adapter-static` and restore the `{ fallback: '200.html' }` arg.\n * Lenient — if no config or no adapter import is found, it's a no-op success.\n */\nexport function unmodifySvelteConfig(root: string): ConfigModifyResult {\n const res = resolveConfigTarget(root, {\n notFound: NOT_FOUND_HINT,\n failed: FAILURE_HINT,\n });\n if (res.status !== \"resolved\") {\n // Nothing to revert — treat missing/unparseable config as a no-op.\n return {\n filePath: res.filePath,\n outcome: { status: \"success\", changed: false },\n };\n }\n const { target } = res;\n const adapterImport = findAdapterImport(target.sourceFile);\n if (!adapterImport) {\n return {\n filePath: target.filePath,\n outcome: { status: \"success\", changed: false },\n };\n }\n\n if (adapterImport.getModuleSpecifierValue() !== ADAPTER_STATIC) {\n adapterImport.setModuleSpecifier(ADAPTER_STATIC);\n }\n\n for (const call of adapterCalls(target.sourceFile)) {\n if (call.getArguments().length === 0) {\n call.addArgument(\"{ fallback: '200.html' }\");\n }\n }\n\n return { filePath: target.filePath, outcome: saveTarget(target) };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst POCKETBASE_BLOCK = `# PocketBase\n/data/*\n!/data/fixtures\n!/data/seeds\n!/data/hooks\n`;\n\nconst NOT_FOUND_HINT = dedent`\n Create a .gitignore at the project root with the PocketBase block:\n\n # PocketBase\n /data/*\n !/data/fixtures\n !/data/seeds\n !/data/hooks\n`;\n\nexport function modifyGitignore(gitignorePath: string): ModifyOutcome {\n if (!fs.existsSync(gitignorePath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const original = fs.readFileSync(gitignorePath, \"utf8\");\n\n if (original.includes(\"# PocketBase\") && original.includes(\"/data/*\")) {\n return { status: \"success\", changed: false };\n }\n\n const separator = original.endsWith(\"\\n\") ? \"\\n\" : \"\\n\\n\";\n const next = original + separator + POCKETBASE_BLOCK;\n fs.writeFileSync(gitignorePath, next, \"utf8\");\n\n return { status: \"success\", changed: true };\n}\n\nexport function unmodifyGitignore(gitignorePath: string): ModifyOutcome {\n if (!fs.existsSync(gitignorePath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(gitignorePath, \"utf8\");\n\n if (!original.includes(\"# PocketBase\")) {\n return { status: \"success\", changed: false };\n }\n\n const withBlockRemoved = original.replace(\n /\\n*# PocketBase\\n\\/data\\/\\*\\n!\\/data\\/fixtures\\n!\\/data\\/seeds\\n!\\/data\\/hooks\\n?/,\n \"\\n\",\n );\n\n const cleaned = withBlockRemoved.replace(/\\n{3,}$/, \"\\n\");\n\n if (cleaned === original) {\n return { status: \"success\", changed: false };\n }\n\n fs.writeFileSync(gitignorePath, cleaned, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\n// Source of truth: velastack-cli/templates/minimal/test/setup.ts\nconst WITH_BACKEND = `import { beforeEach, afterEach, beforeAll } from 'vitest';\nimport supertest, { type Agent } from 'supertest';\nimport PocketBase from 'pocketbase-sveltekit';\nimport type { TestContext } from '@velastack/pocketbase/testing';\n\nconst admin = new PocketBase(process.env.POCKETBASE_URL!) as App.Locals['admin'];\nconst pb = new PocketBase(process.env.POCKETBASE_URL!) as App.Locals['pb'];\n\nconst testUserPassword = 'password';\n\nasync function authenticateUser(agent: Agent, user: { email: string }) {\n\\tawait agent.post('/login').type('form').send({\n\\t\\ttype: 'password',\n\\t\\temail: user.email,\n\\t\\tpassword: testUserPassword\n\\t});\n}\n\nbeforeAll(async () => {\n\\tawait admin\n\\t\\t// @ts-ignore\n\\t\\t.collection('_superusers')\n\\t\\t.authWithPassword(\n\\t\\t\\tprocess.env.POCKETBASE_SUPERUSER_EMAIL!,\n\\t\\t\\tprocess.env.POCKETBASE_SUPERUSER_PASSWORD!\n\\t\\t);\n});\n\nbeforeEach(async (context: TestContext) => {\n\\tcontext.request = supertest(process.env.VITE_TEST_URL!);\n\\tcontext.agent = supertest.agent(process.env.VITE_TEST_URL!) as TestContext['agent'];\n\\tcontext.admin = admin;\n\\tcontext.pb = pb;\n\\tcontext.user = await context.admin.collection('users').create({\n\\t\\temail: \\`test-\\${Math.random().toString(36).slice(2)}@example.com\\`,\n\\t\\tpassword: testUserPassword,\n\\t\\tpasswordConfirm: testUserPassword\n\\t});\n\\tcontext.agent.authenticateUser = () => authenticateUser(context.agent, context.user);\n\\tawait context.pb.collection('users').authWithPassword(context.user.email, testUserPassword);\n});\n\nafterEach(async (context: TestContext) => {\n\\tawait context.pb.authStore.clear();\n\\tawait context.admin.collection('users').delete(context.user.id);\n});\n`;\n\n// Source of truth: velastack-cli/templates/static/test/setup.ts\nconst WITHOUT_BACKEND = `import { beforeEach } from 'vitest';\nimport supertest from 'supertest';\n\nbeforeEach(async (context: any) => {\n\\tcontext.request = supertest(process.env.VITE_TEST_URL!);\n\\tcontext.agent = supertest.agent(process.env.VITE_TEST_URL!);\n});\n`;\n\nconst NOT_FOUND_HINT = dedent`\n Create test/setup.ts. The default minimal-template setup wires supertest:\n\n import { beforeEach } from 'vitest';\n import supertest from 'supertest';\n\n beforeEach(async (context: any) => {\n context.request = supertest(process.env.VITE_TEST_URL!);\n context.agent = supertest.agent(process.env.VITE_TEST_URL!);\n });\n`;\n\nexport function modifyTestSetup(testSetupPath: string): ModifyOutcome {\n if (!fs.existsSync(testSetupPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const original = fs.readFileSync(testSetupPath, \"utf8\");\n if (original === WITH_BACKEND) {\n return { status: \"success\", changed: false };\n }\n\n fs.writeFileSync(testSetupPath, WITH_BACKEND, \"utf8\");\n return { status: \"success\", changed: true };\n}\n\nexport function unmodifyTestSetup(testSetupPath: string): ModifyOutcome {\n if (!fs.existsSync(testSetupPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(testSetupPath, \"utf8\");\n if (original === WITHOUT_BACKEND) {\n return { status: \"success\", changed: false };\n }\n\n fs.writeFileSync(testSetupPath, WITHOUT_BACKEND, \"utf8\");\n return { status: \"success\", changed: true };\n}\n"],"mappings":";;;;;AASA,IAAM,IAAe,0BACf,IAAiB,4BACjB,IAAe,0BAEf,IAAe,CAAM;oCACS,EAAa;;yBAExB,EAAa;;;;GAMhC,IAA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DA,IAAM,IAAe,6mDAiDf,IAAkB,qPASlB,IAAiB,CAAM;;;;;;;;;;;AAY7B,SAAgB,EAAgB,GAAsC;CAWpE,OAVK,EAAG,WAAW,CAAa,IAIf,EAAG,aAAa,GAAe,MAC5C,MAAa,IACR;EAAE,QAAQ;EAAW,SAAS;CAAM,KAG7C,EAAG,cAAc,GAAe,GAAc,MAAM,GAC7C;EAAE,QAAQ;EAAW,SAAS;CAAK,KATjC;EAAE,QAAQ;EAAa,SAAS;CAAe;AAU1D;AAEA,SAAgB,EAAkB,GAAsC;CAWtE,OAVI,CAAC,EAAG,WAAW,CAAa,KAIf,EAAG,aAAa,GAAe,MAC5C,MAAa,IACR;EAAE,QAAQ;EAAW,SAAS;CAAM,KAG7C,EAAG,cAAc,GAAe,GAAiB,MAAM,GAChD;EAAE,QAAQ;EAAW,SAAS;CAAK;AAC5C"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ts-morph-helpers-7qF9S2k7.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 * Insert markup so it renders before the layout's children — i.e. ahead of\n * the top-level `{@render children()}` (or legacy `<slot />`). The markup\n * lands on its own line directly after the preceding sibling, so\n *\n * <Toaster />\n *\n * {@render children?.()}\n *\n * becomes `<Toaster />\\n<AdminBar />\\n\\n{@render children?.()}`. When the\n * render tag is the first node the markup goes immediately before it.\n * Returns false (and changes nothing) if no such tag exists.\n */\n insertBeforeChildren(content: string): boolean {\n const nodes: SvelteNode[] = (this.ast as any).fragment?.nodes ?? [];\n const index = nodes.findIndex(\n (node) =>\n node.type === \"RenderTag\" ||\n node.type === \"SlotElement\" ||\n (node.type === \"RegularElement\" && node.name === \"slot\"),\n );\n if (index === -1) return false;\n\n const trimmed = content.trim();\n for (let i = index - 1; i >= 0; i--) {\n const prev = nodes[i]!;\n if (prev.type === \"Text\" && prev.data.trim() === \"\") continue;\n this.s.appendLeft(prev.end as number, `\\n${trimmed}`);\n return true;\n }\n this.s.appendLeft(nodes[index]!.start as number, `${trimmed}\\n\\n`);\n return true;\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,G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