@velastack/patterns 0.3.1 → 0.3.2

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 (144) hide show
  1. package/README.md +32 -2
  2. package/dist/chunks/_layout-B7ujvjnA.js +55 -0
  3. package/dist/chunks/_layout-B7ujvjnA.js.map +1 -0
  4. package/dist/chunks/{collections-CgdvZXmh.js → collections-UPqYto13.js} +2 -2
  5. package/dist/chunks/{collections-CgdvZXmh.js.map → collections-UPqYto13.js.map} +1 -1
  6. package/dist/chunks/{compose-handle-Cg9jnCsS.js → compose-handle-B-CkDcQD.js} +23 -23
  7. package/dist/chunks/{compose-handle-Cg9jnCsS.js.map → compose-handle-B-CkDcQD.js.map} +1 -1
  8. package/dist/chunks/config-target-Bln26FJe.js +164 -0
  9. package/dist/chunks/config-target-Bln26FJe.js.map +1 -0
  10. package/dist/chunks/errors-DR3gF_7a.js +18 -0
  11. package/dist/chunks/errors-DR3gF_7a.js.map +1 -0
  12. package/dist/chunks/{generate-DRA63W0r.js → generate-6snrlnpA.js} +2 -2
  13. package/dist/chunks/{generate-DRA63W0r.js.map → generate-6snrlnpA.js.map} +1 -1
  14. package/dist/chunks/{generate-BkQ1xMDp.js → generate-C6xi5S5L.js} +4 -4
  15. package/dist/chunks/{generate-BkQ1xMDp.js.map → generate-C6xi5S5L.js.map} +1 -1
  16. package/dist/chunks/{generate-tOkjJFUf.js → generate-CyuY2Ci7.js} +4 -3
  17. package/dist/chunks/generate-CyuY2Ci7.js.map +1 -0
  18. package/dist/chunks/{generate-iQP31-m1.js → generate-DHgKgHb7.js} +4 -4
  19. package/dist/chunks/{generate-iQP31-m1.js.map → generate-DHgKgHb7.js.map} +1 -1
  20. package/dist/chunks/{generate-_LvrYK6i.js → generate-jsB_oO0b.js} +4 -4
  21. package/dist/chunks/{generate-_LvrYK6i.js.map → generate-jsB_oO0b.js.map} +1 -1
  22. package/dist/chunks/{generate.runtime-DAmYsIvF.js → generate.runtime-9R2AUKLS.js} +5 -5
  23. package/dist/chunks/{generate.runtime-DAmYsIvF.js.map → generate.runtime-9R2AUKLS.js.map} +1 -1
  24. package/dist/chunks/generate.runtime-B3yX6kl2.js +87 -0
  25. package/dist/chunks/generate.runtime-B3yX6kl2.js.map +1 -0
  26. package/dist/chunks/{generate.runtime-BKo-Nidn.js → generate.runtime-B7wkyj-8.js} +6 -6
  27. package/dist/chunks/{generate.runtime-BKo-Nidn.js.map → generate.runtime-B7wkyj-8.js.map} +1 -1
  28. package/dist/chunks/generate.runtime-BHf8p_3K.js +94 -0
  29. package/dist/chunks/generate.runtime-BHf8p_3K.js.map +1 -0
  30. package/dist/chunks/{generate.runtime-BbIN0tUZ.js → generate.runtime-BSFIwX58.js} +67 -66
  31. package/dist/chunks/generate.runtime-BSFIwX58.js.map +1 -0
  32. package/dist/chunks/{generate.runtime-BnWE4qsu.js → generate.runtime-Bb9CCwQm.js} +55 -54
  33. package/dist/chunks/generate.runtime-Bb9CCwQm.js.map +1 -0
  34. package/dist/chunks/{generate.runtime-D8vgh5MH.js → generate.runtime-BjciAjq7.js} +156 -76
  35. package/dist/chunks/generate.runtime-BjciAjq7.js.map +1 -0
  36. package/dist/chunks/{generate.runtime-BwhGDnGu.js → generate.runtime-BpTpRBdH.js} +151 -150
  37. package/dist/chunks/generate.runtime-BpTpRBdH.js.map +1 -0
  38. package/dist/chunks/{generate.runtime-D0icLb5j.js → generate.runtime-Brf08fMW.js} +11 -10
  39. package/dist/chunks/{generate.runtime-D0icLb5j.js.map → generate.runtime-Brf08fMW.js.map} +1 -1
  40. package/dist/chunks/{generate.runtime-S5RIgbQx.js → generate.runtime-C6DfW_NO.js} +98 -92
  41. package/dist/chunks/generate.runtime-C6DfW_NO.js.map +1 -0
  42. package/dist/chunks/{generate.runtime-DhkaXTq3.js → generate.runtime-C9fSqy6a.js} +61 -59
  43. package/dist/chunks/generate.runtime-C9fSqy6a.js.map +1 -0
  44. package/dist/chunks/{generate.runtime-CRYjWJRe.js → generate.runtime-CawvLUoV.js} +89 -88
  45. package/dist/chunks/generate.runtime-CawvLUoV.js.map +1 -0
  46. package/dist/chunks/{generate.runtime-DNaQxed-.js → generate.runtime-CzS7PuPN.js} +84 -83
  47. package/dist/chunks/generate.runtime-CzS7PuPN.js.map +1 -0
  48. package/dist/chunks/{generate.runtime-B0hhtyAL.js → generate.runtime-D1NZPV6C.js} +27 -26
  49. package/dist/chunks/generate.runtime-D1NZPV6C.js.map +1 -0
  50. package/dist/chunks/generate.runtime-D3baqo6a.js +111 -0
  51. package/dist/chunks/generate.runtime-D3baqo6a.js.map +1 -0
  52. package/dist/chunks/{generate.runtime-DSqkXvps.js → generate.runtime-D47djbeG.js} +15 -14
  53. package/dist/chunks/{generate.runtime-DSqkXvps.js.map → generate.runtime-D47djbeG.js.map} +1 -1
  54. package/dist/chunks/generate.runtime-D72UBiwD.js +313 -0
  55. package/dist/chunks/generate.runtime-D72UBiwD.js.map +1 -0
  56. package/dist/chunks/{generate.runtime-CcuAXuV2.js → generate.runtime-DDPoXmqN.js} +15 -14
  57. package/dist/chunks/{generate.runtime-CcuAXuV2.js.map → generate.runtime-DDPoXmqN.js.map} +1 -1
  58. package/dist/chunks/{generate.runtime-acRmiU7e.js → generate.runtime-DEnn0HKw.js} +9 -8
  59. package/dist/chunks/{generate.runtime-acRmiU7e.js.map → generate.runtime-DEnn0HKw.js.map} +1 -1
  60. package/dist/chunks/{generate.runtime-wA1G3tQ4.js → generate.runtime-DHXkw2gf.js} +38 -37
  61. package/dist/chunks/generate.runtime-DHXkw2gf.js.map +1 -0
  62. package/dist/chunks/{generate.runtime-DOuufRLr.js → generate.runtime-DIuCrH6l.js} +82 -81
  63. package/dist/chunks/generate.runtime-DIuCrH6l.js.map +1 -0
  64. package/dist/chunks/generate.runtime-DOB4U-Sa.js +57 -0
  65. package/dist/chunks/generate.runtime-DOB4U-Sa.js.map +1 -0
  66. package/dist/chunks/generate.runtime-DPAy7Cav.js +328 -0
  67. package/dist/chunks/generate.runtime-DPAy7Cav.js.map +1 -0
  68. package/dist/chunks/{generate.runtime-BORbegw_.js → generate.runtime-D_ZqiYt-.js} +123 -122
  69. package/dist/chunks/generate.runtime-D_ZqiYt-.js.map +1 -0
  70. package/dist/chunks/{generate.runtime-B49wetSx.js → generate.runtime-Dm7g_WTN.js} +43 -42
  71. package/dist/chunks/generate.runtime-Dm7g_WTN.js.map +1 -0
  72. package/dist/chunks/{generate.runtime-DoZdSh9W.js → generate.runtime-HE9rzfXz.js} +58 -57
  73. package/dist/chunks/generate.runtime-HE9rzfXz.js.map +1 -0
  74. package/dist/chunks/{generate.runtime-flFRYzpi.js → generate.runtime-ejrt1o6M.js} +62 -61
  75. package/dist/chunks/generate.runtime-ejrt1o6M.js.map +1 -0
  76. package/dist/chunks/generate.runtime-l6I-St2R.js +94 -0
  77. package/dist/chunks/generate.runtime-l6I-St2R.js.map +1 -0
  78. package/dist/chunks/modify-file-DGe7MJu_.js +46 -0
  79. package/dist/chunks/modify-file-DGe7MJu_.js.map +1 -0
  80. package/dist/chunks/{modify-svelte-config-remote-CDKs_Qi0.js → modify-svelte-config-remote-BUU_EaDf.js} +2 -2
  81. package/dist/chunks/{modify-svelte-config-remote-CDKs_Qi0.js.map → modify-svelte-config-remote-BUU_EaDf.js.map} +1 -1
  82. package/dist/chunks/{providers-DO9kMyzB.js → providers-BL9vJP_9.js} +2 -2
  83. package/dist/chunks/{providers-DO9kMyzB.js.map → providers-BL9vJP_9.js.map} +1 -1
  84. package/dist/chunks/{shared-BwHQM-a9.js → shared-DkGfltvn.js} +2 -2
  85. package/dist/chunks/{shared-BwHQM-a9.js.map → shared-DkGfltvn.js.map} +1 -1
  86. package/dist/chunks/{test-setup-B2hd8I-s.js → test-setup-DHEFKEHE.js} +23 -10
  87. package/dist/chunks/test-setup-DHEFKEHE.js.map +1 -0
  88. package/dist/chunks/ts-morph-helpers-CeduA--o.js +253 -0
  89. package/dist/chunks/ts-morph-helpers-CeduA--o.js.map +1 -0
  90. package/dist/chunks/{ui-B4Tuit-7.js → ui-B3-B3sE2.js} +3 -3
  91. package/dist/chunks/{ui-B4Tuit-7.js.map → ui-B3-B3sE2.js.map} +1 -1
  92. package/dist/chunks/{ui-jhXrsw4T.js → ui-DD4NltyN.js} +2 -2
  93. package/dist/chunks/{ui-jhXrsw4T.js.map → ui-DD4NltyN.js.map} +1 -1
  94. package/dist/chunks/unmodify-load-jfdcVZ_a.js +81 -0
  95. package/dist/chunks/unmodify-load-jfdcVZ_a.js.map +1 -0
  96. package/dist/chunks/write-result-DRwceOV3.js +452 -0
  97. package/dist/chunks/write-result-DRwceOV3.js.map +1 -0
  98. package/dist/index.d.ts +34 -0
  99. package/dist/index.js +1918 -1901
  100. package/dist/index.js.map +1 -1
  101. package/package.json +1 -1
  102. package/dist/chunks/_layout-DqH4lA_r.js +0 -47
  103. package/dist/chunks/_layout-DqH4lA_r.js.map +0 -1
  104. package/dist/chunks/config-target-Co-ij8p3.js +0 -163
  105. package/dist/chunks/config-target-Co-ij8p3.js.map +0 -1
  106. package/dist/chunks/errors-D6gyegUK.js +0 -14
  107. package/dist/chunks/errors-D6gyegUK.js.map +0 -1
  108. package/dist/chunks/generate-tOkjJFUf.js.map +0 -1
  109. package/dist/chunks/generate.runtime-B0hhtyAL.js.map +0 -1
  110. package/dist/chunks/generate.runtime-B49wetSx.js.map +0 -1
  111. package/dist/chunks/generate.runtime-B7LRx-BU.js +0 -86
  112. package/dist/chunks/generate.runtime-B7LRx-BU.js.map +0 -1
  113. package/dist/chunks/generate.runtime-BORbegw_.js.map +0 -1
  114. package/dist/chunks/generate.runtime-BbIN0tUZ.js.map +0 -1
  115. package/dist/chunks/generate.runtime-BnWE4qsu.js.map +0 -1
  116. package/dist/chunks/generate.runtime-BwhGDnGu.js.map +0 -1
  117. package/dist/chunks/generate.runtime-CCg2Pjcv.js +0 -257
  118. package/dist/chunks/generate.runtime-CCg2Pjcv.js.map +0 -1
  119. package/dist/chunks/generate.runtime-CRYjWJRe.js.map +0 -1
  120. package/dist/chunks/generate.runtime-D2e_KRj0.js +0 -56
  121. package/dist/chunks/generate.runtime-D2e_KRj0.js.map +0 -1
  122. package/dist/chunks/generate.runtime-D44gjxRA.js +0 -332
  123. package/dist/chunks/generate.runtime-D44gjxRA.js.map +0 -1
  124. package/dist/chunks/generate.runtime-D8vgh5MH.js.map +0 -1
  125. package/dist/chunks/generate.runtime-DNaQxed-.js.map +0 -1
  126. package/dist/chunks/generate.runtime-DOuufRLr.js.map +0 -1
  127. package/dist/chunks/generate.runtime-DhkaXTq3.js.map +0 -1
  128. package/dist/chunks/generate.runtime-DoZdSh9W.js.map +0 -1
  129. package/dist/chunks/generate.runtime-S5RIgbQx.js.map +0 -1
  130. package/dist/chunks/generate.runtime-WmSMWL15.js +0 -82
  131. package/dist/chunks/generate.runtime-WmSMWL15.js.map +0 -1
  132. package/dist/chunks/generate.runtime-flFRYzpi.js.map +0 -1
  133. package/dist/chunks/generate.runtime-gtpOuLNO.js +0 -110
  134. package/dist/chunks/generate.runtime-gtpOuLNO.js.map +0 -1
  135. package/dist/chunks/generate.runtime-kLxeDGnS.js +0 -93
  136. package/dist/chunks/generate.runtime-kLxeDGnS.js.map +0 -1
  137. package/dist/chunks/generate.runtime-wA1G3tQ4.js.map +0 -1
  138. package/dist/chunks/modify-file-GQD6uNgI.js +0 -254
  139. package/dist/chunks/modify-file-GQD6uNgI.js.map +0 -1
  140. package/dist/chunks/test-setup-B2hd8I-s.js.map +0 -1
  141. package/dist/chunks/unmodify-load-W1ePZQHr.js +0 -80
  142. package/dist/chunks/unmodify-load-W1ePZQHr.js.map +0 -1
  143. package/dist/chunks/write-result-DewHCNhM.js +0 -451
  144. package/dist/chunks/write-result-DewHCNhM.js.map +0 -1
@@ -1,29 +1,30 @@
1
1
  import { n as e } from "./logger-CQONztPm.js";
2
- import { t } from "./shared-BwHQM-a9.js";
3
- import { c as n, h as r, modifyOutcomeToFile as i, n as a, u as o } from "./modify-file-GQD6uNgI.js";
4
- import { t as s } from "./svelte-file-B3RfgVdt.js";
5
- import { t as c } from "./unmodify-load-W1ePZQHr.js";
6
- import l from "node:fs";
7
- import u from "node:path";
8
- import { SyntaxKind as d } from "ts-morph";
2
+ import { t } from "./shared-DkGfltvn.js";
3
+ import { _ as n, f as r, n as i, o as a, u as o } from "./ts-morph-helpers-CeduA--o.js";
4
+ import { modifyOutcomeToFile as s } from "./modify-file-DGe7MJu_.js";
5
+ import { t as c } from "./svelte-file-B3RfgVdt.js";
6
+ import { t as l } from "./unmodify-load-jfdcVZ_a.js";
7
+ import u from "node:fs";
8
+ import d from "node:path";
9
+ import { SyntaxKind as f } from "ts-morph";
9
10
  //#region src/patterns/disable/teams/modifies/modify-nav-user.ts
10
- function f(e) {
11
- if (!l.existsSync(e)) return {
11
+ function p(e) {
12
+ if (!u.existsSync(e)) return {
12
13
  status: "success",
13
14
  changed: !1
14
15
  };
15
- let t = l.readFileSync(e, "utf8");
16
+ let t = u.readFileSync(e, "utf8");
16
17
  if (!t.includes("/teams")) return {
17
18
  status: "success",
18
19
  changed: !1
19
20
  };
20
- let n = new s(t), r = !1, i = (e) => {
21
- r || e((e) => {
22
- let t = o(e, "Teams", "@lucide/svelte/icons/users");
23
- return t.wasRemoved && (r = !0), t.source;
21
+ let n = new c(t), i = !1, a = (e) => {
22
+ i || e((e) => {
23
+ let t = r(e, "Teams", "@lucide/svelte/icons/users");
24
+ return t.wasRemoved && (i = !0), t.source;
24
25
  });
25
26
  };
26
- return i((e) => n.modifyModuleScript(e)), r || i((e) => n.modifyScript(e)), r ? (l.writeFileSync(e, n.toString(), "utf8"), {
27
+ return a((e) => n.modifyModuleScript(e)), i || a((e) => n.modifyScript(e)), i ? (u.writeFileSync(e, n.toString(), "utf8"), {
27
28
  status: "success",
28
29
  changed: !0
29
30
  }) : {
@@ -33,8 +34,8 @@ function f(e) {
33
34
  }
34
35
  //#endregion
35
36
  //#region src/patterns/disable/teams/modifies/+layout.server.ts
36
- function p(e) {
37
- return c(e, {
37
+ function m(e) {
38
+ return l(e, {
38
39
  variables: ["team", "teams"],
39
40
  dependsKeys: ["app:team"],
40
41
  returnProps: ["team", "teams"]
@@ -42,12 +43,12 @@ function p(e) {
42
43
  }
43
44
  //#endregion
44
45
  //#region src/patterns/disable/teams/modifies/modify-app-layout.ts
45
- function m(e) {
46
- if (!l.existsSync(e)) return {
46
+ function h(e) {
47
+ if (!u.existsSync(e)) return {
47
48
  status: "success",
48
49
  changed: !1
49
50
  };
50
- let t = s.fromPath(e);
51
+ let t = c.fromPath(e);
51
52
  return !t.hasElement("AppSidebar") || (t.removeAttribute("AppSidebar", "team"), t.removeAttribute("AppSidebar", "teams"), !t.hasChanged()) ? {
52
53
  status: "success",
53
54
  changed: !1
@@ -58,73 +59,73 @@ function m(e) {
58
59
  }
59
60
  //#endregion
60
61
  //#region src/patterns/disable/teams/modifies/modify-app-sidebar.ts
61
- var h = "<Sidebar.Header>\n <Sidebar.Menu>\n <Sidebar.MenuItem>\n <Sidebar.MenuButton size=\"lg\">\n {#snippet child({ props })}\n <a href=\"/dashboard\" {...props}>\n <div\n class=\"bg-sidebar-accent text-sidebar-primary-foreground flex aspect-square size-8 items-center justify-center rounded-lg\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-6\" />\n </div>\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{site.name}</span>\n </div>\n </a>\n {/snippet}\n </Sidebar.MenuButton>\n </Sidebar.MenuItem>\n </Sidebar.Menu>\n </Sidebar.Header>", g = "{meta.appName}", _ = [
62
+ var g = "<Sidebar.Header>\n <Sidebar.Menu>\n <Sidebar.MenuItem>\n <Sidebar.MenuButton size=\"lg\">\n {#snippet child({ props })}\n <a href=\"/dashboard\" {...props}>\n <div\n class=\"bg-sidebar-accent text-sidebar-primary-foreground flex aspect-square size-8 items-center justify-center rounded-lg\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-6\" />\n </div>\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{site.name}</span>\n </div>\n </a>\n {/snippet}\n </Sidebar.MenuButton>\n </Sidebar.MenuItem>\n </Sidebar.Menu>\n </Sidebar.Header>", _ = "{meta.appName}", v = [
62
63
  ["TeamSwitcher", "$lib/components/team-switcher.svelte"],
63
64
  ["ChevronsUpDownIcon", "@lucide/svelte/icons/chevrons-up-down"],
64
65
  ["Avatar", "$lib/components/ui/avatar"]
65
- ], v = ["team", "teams"];
66
- function y(e) {
66
+ ], y = ["team", "teams"];
67
+ function b(e) {
67
68
  return e.replace(/<script[\s\S]*?<\/script>/g, "");
68
69
  }
69
- function b(e, t) {
70
- let { source: i } = r(e, (e) => {
70
+ function x(e, t) {
71
+ let { source: r } = n(e, (e) => {
71
72
  for (let t of e.getVariableDeclarations()) {
72
73
  let e = t.getInitializer();
73
74
  if (!e || e.getText() !== "$props()") continue;
74
75
  let n = t.getNameNode();
75
- if (n.getKind() !== d.ObjectBindingPattern) continue;
76
+ if (n.getKind() !== f.ObjectBindingPattern) continue;
76
77
  let r = t.getTypeNode();
77
- if (r?.getKind() === d.IntersectionType) for (let e of r.asKindOrThrow(d.IntersectionType).getTypeNodes()) {
78
- if (e.getKind() !== d.TypeLiteral) continue;
79
- let t = e.asKindOrThrow(d.TypeLiteral), n = t.getProperties().length;
80
- for (let e of v) t.getProperty(e)?.remove();
78
+ if (r?.getKind() === f.IntersectionType) for (let e of r.asKindOrThrow(f.IntersectionType).getTypeNodes()) {
79
+ if (e.getKind() !== f.TypeLiteral) continue;
80
+ let t = e.asKindOrThrow(f.TypeLiteral), n = t.getProperties().length;
81
+ for (let e of y) t.getProperty(e)?.remove();
81
82
  if (t.getProperties().length !== n) {
82
83
  let e = t.getProperties().map((e) => e.getText().replace(/[;,]\s*$/, ""));
83
84
  t.replaceWithText(`{ ${e.join("; ")} }`);
84
85
  }
85
86
  }
86
- let i = n.asKindOrThrow(d.ObjectBindingPattern), a = i.getElements(), o = a.filter((e) => !v.includes(e.getName())).map((e) => e.getText());
87
+ let i = n.asKindOrThrow(f.ObjectBindingPattern), a = i.getElements(), o = a.filter((e) => !y.includes(e.getName())).map((e) => e.getText());
87
88
  o.length !== a.length && i.replaceWithText(`{ ${o.join(", ")} }`);
88
89
  }
89
- for (let [r, i] of _) RegExp(`\\b${r}\\b`).test(t) || n(e, i);
90
- e.formatText(), a(e);
90
+ for (let [n, r] of v) RegExp(`\\b${n}\\b`).test(t) || o(e, r);
91
+ a(e), i(e);
91
92
  });
92
- return i;
93
+ return r;
93
94
  }
94
- function x(e) {
95
- if (!l.existsSync(e)) return {
95
+ function S(e) {
96
+ if (!u.existsSync(e)) return {
96
97
  status: "success",
97
98
  changed: !1
98
99
  };
99
- let t = s.fromPath(e);
100
+ let t = c.fromPath(e);
100
101
  if (!t.hasElement("TeamSwitcher")) return {
101
102
  status: "success",
102
103
  changed: !1
103
104
  };
104
- t.replaceElement("Sidebar.Header", t.toString().includes(g) ? h.replace("{site.name}", g) : h);
105
- let n = y(t.toString());
106
- return t.modifyScript((e) => b(e, n)), t.writeTo(e), {
105
+ t.replaceElement("Sidebar.Header", t.toString().includes(_) ? g.replace("{site.name}", _) : g);
106
+ let n = b(t.toString());
107
+ return t.modifyScript((e) => x(e, n)), t.writeTo(e), {
107
108
  status: "success",
108
109
  changed: t.hasChanged()
109
110
  };
110
111
  }
111
112
  //#endregion
112
113
  //#region src/patterns/disable/teams/generate.runtime.ts
113
- async function S(n) {
114
- let r = e(n), a = [], o = (e) => {
115
- e && a.push(e);
114
+ async function C(n) {
115
+ let r = e(n), i = [], a = (e) => {
116
+ e && i.push(e);
116
117
  };
117
118
  r.info("Reverting nav-user.svelte");
118
- let s = [u.join(n.root, "src", "lib", "components", "nav-user.svelte")], c = s.find((e) => l.existsSync(e)) ?? s[0];
119
- o(i(c, f(c))), r.info("Reverting (app) +layout.server.ts");
120
- let d = u.join(n.root, "src", "routes", "(app)", "+layout.server.ts");
121
- o(i(d, p(d))), r.info("Reverting (app) +layout.svelte");
122
- let h = u.join(n.root, "src", "routes", "(app)", "+layout.svelte");
123
- o(i(h, m(h))), r.info("Reverting app-sidebar.svelte");
124
- let g = u.join(n.root, "src", "lib", "components", "app-sidebar.svelte");
125
- return o(i(g, x(g))), {
119
+ let o = [d.join(n.root, "src", "lib", "components", "nav-user.svelte")], c = o.find((e) => u.existsSync(e)) ?? o[0];
120
+ a(s(c, p(c))), r.info("Reverting (app) +layout.server.ts");
121
+ let l = d.join(n.root, "src", "routes", "(app)", "+layout.server.ts");
122
+ a(s(l, m(l))), r.info("Reverting (app) +layout.svelte");
123
+ let f = d.join(n.root, "src", "routes", "(app)", "+layout.svelte");
124
+ a(s(f, h(f))), r.info("Reverting app-sidebar.svelte");
125
+ let g = d.join(n.root, "src", "lib", "components", "app-sidebar.svelte");
126
+ return a(s(g, S(g))), {
126
127
  creates: [],
127
- modifies: a,
128
+ modifies: i,
128
129
  deletes: [],
129
130
  components: [],
130
131
  packages: [],
@@ -140,6 +141,6 @@ async function S(n) {
140
141
  };
141
142
  }
142
143
  //#endregion
143
- export { S as generate };
144
+ export { C as generate };
144
145
 
145
- //# sourceMappingURL=generate.runtime-BnWE4qsu.js.map
146
+ //# sourceMappingURL=generate.runtime-Bb9CCwQm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.runtime-Bb9CCwQm.js","names":[],"sources":["../../src/patterns/disable/teams/modifies/modify-nav-user.ts","../../src/patterns/disable/teams/modifies/+layout.server.ts","../../src/patterns/disable/teams/modifies/modify-app-layout.ts","../../src/patterns/disable/teams/modifies/modify-app-sidebar.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 type { ModifyOutcome } from \"../../../../core/types\";\nimport { removeFromLoad } from \"../../../../runtime/unmodify-load\";\n\n/** Take the team loader back out of the (app) layout's load. */\nexport function unmodifyLayoutServer(layoutServerPath: string): ModifyOutcome {\n return removeFromLoad(layoutServerPath, {\n variables: [\"team\", \"teams\"],\n dependsKeys: [\"app:team\"],\n returnProps: [\"team\", \"teams\"],\n });\n}\n","import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\n/** Drop the team props enable-teams passed to <AppSidebar>. */\nexport function unmodifyAppLayoutSvelte(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n if (!file.hasElement(\"AppSidebar\")) {\n return { status: \"success\", changed: false };\n }\n\n file.removeAttribute(\"AppSidebar\", \"team\");\n file.removeAttribute(\"AppSidebar\", \"teams\");\n if (!file.hasChanged()) {\n return { status: \"success\", changed: false };\n }\n\n file.writeTo(layoutPath);\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport { SyntaxKind } from \"ts-morph\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureBlankLineAfterImports,\n removeImportByModuleSpecifier,\n withInMemoryScript,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\n/** The header enable-auth ships, which the team switcher replaced. */\nconst ORIGINAL_HEADER = `<Sidebar.Header>\n\t\t<Sidebar.Menu>\n\t\t\t<Sidebar.MenuItem>\n\t\t\t\t<Sidebar.MenuButton size=\"lg\">\n\t\t\t\t\t{#snippet child({ props })}\n\t\t\t\t\t\t<a href=\"/dashboard\" {...props}>\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tclass=\"bg-sidebar-accent text-sidebar-primary-foreground flex aspect-square size-8 items-center justify-center rounded-lg\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<img src={favicon} alt=\"logo\" class=\"size-6\" />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<div class=\"grid flex-1 text-left text-sm leading-tight\">\n\t\t\t\t\t\t\t\t<span class=\"truncate font-medium\">{site.name}</span>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</a>\n\t\t\t\t\t{/snippet}\n\t\t\t\t</Sidebar.MenuButton>\n\t\t\t</Sidebar.MenuItem>\n\t\t</Sidebar.Menu>\n\t</Sidebar.Header>`;\n\n/**\n * A sidebar from before `$lib/site` names the app with a `meta` prop; the\n * header goes back to whichever the team switcher's fallback used.\n */\nconst LEGACY_NAME = \"{meta.appName}\";\n\n/** Imports enable-teams added, dropped once the markup no longer uses them. */\nconst TEAM_IMPORTS: [name: string, moduleSpecifier: string][] = [\n [\"TeamSwitcher\", \"$lib/components/team-switcher.svelte\"],\n [\"ChevronsUpDownIcon\", \"@lucide/svelte/icons/chevrons-up-down\"],\n [\"Avatar\", \"$lib/components/ui/avatar\"],\n];\n\nconst TEAM_PROPS = [\"team\", \"teams\"];\n\nfunction markupOf(source: string): string {\n return source.replace(/<script[\\s\\S]*?<\\/script>/g, \"\");\n}\n\nfunction revertAppSidebarScript(source: string, markup: string): string {\n const { source: out } = withInMemoryScript(source, (sf) => {\n for (const decl of sf.getVariableDeclarations()) {\n const init = decl.getInitializer();\n if (!init || init.getText() !== \"$props()\") continue;\n\n const nameNode = decl.getNameNode();\n if (nameNode.getKind() !== SyntaxKind.ObjectBindingPattern) continue;\n\n // Type first: rewriting the binding pattern shifts what follows.\n const typeNode = decl.getTypeNode();\n if (typeNode?.getKind() === SyntaxKind.IntersectionType) {\n for (const member of typeNode\n .asKindOrThrow(SyntaxKind.IntersectionType)\n .getTypeNodes()) {\n if (member.getKind() !== SyntaxKind.TypeLiteral) continue;\n const literal = member.asKindOrThrow(SyntaxKind.TypeLiteral);\n const before = literal.getProperties().length;\n for (const name of TEAM_PROPS) {\n literal.getProperty(name)?.remove();\n }\n if (literal.getProperties().length !== before) {\n // Collapse to one line, as enable-auth writes it; prettier keeps\n // whichever shape it finds.\n const remaining = literal\n .getProperties()\n .map((p) => p.getText().replace(/[;,]\\s*$/, \"\"));\n literal.replaceWithText(`{ ${remaining.join(\"; \")} }`);\n }\n }\n }\n\n const pattern = nameNode.asKindOrThrow(SyntaxKind.ObjectBindingPattern);\n const elements = pattern.getElements();\n const kept = elements\n .filter((el) => !TEAM_PROPS.includes(el.getName()))\n .map((el) => el.getText());\n if (kept.length !== elements.length) {\n pattern.replaceWithText(`{ ${kept.join(\", \")} }`);\n }\n }\n\n for (const [name, moduleSpecifier] of TEAM_IMPORTS) {\n if (!new RegExp(`\\\\b${name}\\\\b`).test(markup)) {\n removeImportByModuleSpecifier(sf, moduleSpecifier);\n }\n }\n formatLikeSource(sf);\n ensureBlankLineAfterImports(sf);\n });\n return out;\n}\n\n/** Put the plain app-name header back in place of the team switcher. */\nexport function unmodifyAppSidebar(appSidebarPath: string): ModifyOutcome {\n if (!fs.existsSync(appSidebarPath)) {\n return { status: \"success\", changed: false };\n }\n\n const file = SvelteFile.fromPath(appSidebarPath);\n if (!file.hasElement(\"TeamSwitcher\")) {\n return { status: \"success\", changed: false };\n }\n\n file.replaceElement(\n \"Sidebar.Header\",\n file.toString().includes(LEGACY_NAME)\n ? ORIGINAL_HEADER.replace(\"{site.name}\", LEGACY_NAME)\n : ORIGINAL_HEADER,\n );\n const markup = markupOf(file.toString());\n file.modifyScript((source) => revertAppSidebarScript(source, markup));\n file.writeTo(appSidebarPath);\n return { status: \"success\", changed: file.hasChanged() };\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 { unmodifyLayoutServer } from \"./modifies/+layout.server\";\nimport { unmodifyAppLayoutSvelte } from \"./modifies/modify-app-layout\";\nimport { unmodifyAppSidebar } from \"./modifies/modify-app-sidebar\";\nimport { planDropsForCollections } from \"../../destroy/shared\";\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(\"Reverting (app) +layout.server.ts\");\n const layoutServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"+layout.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n layoutServerPath,\n unmodifyLayoutServer(layoutServerPath),\n ),\n );\n\n logger.info(\"Reverting (app) +layout.svelte\");\n const appLayoutPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"+layout.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(appLayoutPath, unmodifyAppLayoutSvelte(appLayoutPath)),\n );\n\n logger.info(\"Reverting app-sidebar.svelte\");\n const appSidebarPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"app-sidebar.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(appSidebarPath, unmodifyAppSidebar(appSidebarPath)),\n );\n\n const collectionDrops = await planDropsForCollections(\n // team_users is a view over teams, so it has to go first or PocketBase\n // refuses to drop teams (\"existing reference in team_users\").\n [\n \"team_users\",\n \"team_invite_links\",\n \"team_invites\",\n \"team_memberships\",\n \"teams\",\n ],\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":"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"}
@@ -1,11 +1,12 @@
1
1
  import { t as e } from "./dedent-Gq6Krl4n.js";
2
- import { t } from "./ui-jhXrsw4T.js";
2
+ import { t } from "./ui-DD4NltyN.js";
3
3
  import { n } from "./logger-CQONztPm.js";
4
- import { h as r, i, modifyOutcomeToFile as a, r as o } from "./modify-file-GQD6uNgI.js";
5
- import { t as s } from "./svelte-file-B3RfgVdt.js";
6
- import { t as c } from "./compose-handle-Cg9jnCsS.js";
7
- import { a as l, i as u, r as d, t as f } from "./config-target-Co-ij8p3.js";
8
- import { n as p } from "./_layout-DqH4lA_r.js";
4
+ import { _ as r, i, o as a, r as o } from "./ts-morph-helpers-CeduA--o.js";
5
+ import { modifyOutcomeToFile as s } from "./modify-file-DGe7MJu_.js";
6
+ import { t as c } from "./svelte-file-B3RfgVdt.js";
7
+ import { t as l } from "./compose-handle-B-CkDcQD.js";
8
+ import { a as u, i as d, r as f, t as p } from "./config-target-Bln26FJe.js";
9
+ import { n as ee } from "./_layout-B7ujvjnA.js";
9
10
  import m from "node:fs";
10
11
  import h from "node:path";
11
12
  import { Project as g, QuoteKind as _, SyntaxKind as v } from "ts-morph";
@@ -41,11 +42,11 @@ function x(e) {
41
42
  namedImports: ["wuchale"],
42
43
  moduleSpecifier: "wuchale/vite"
43
44
  }), n = !0);
44
- let i = t.getDescendantsOfKind(v.CallExpression).find((e) => e.getExpression().getText() === "defineConfig")?.getArguments()?.[0], a = i?.getKind() === v.ObjectLiteralExpression ? i : null;
45
- if (!a) r = !0;
45
+ let i = t.getDescendantsOfKind(v.CallExpression).find((e) => e.getExpression().getText() === "defineConfig")?.getArguments()?.[0], o = i?.getKind() === v.ObjectLiteralExpression ? i : null;
46
+ if (!o) r = !0;
46
47
  else {
47
- let e = a.getProperty("plugins");
48
- if (!e) a.addPropertyAssignment({
48
+ let e = o.getProperty("plugins");
49
+ if (!e) o.addPropertyAssignment({
49
50
  name: "plugins",
50
51
  initializer: "[wuchale()]"
51
52
  }), n = !0;
@@ -60,7 +61,7 @@ function x(e) {
60
61
  }
61
62
  }
62
63
  }
63
- return n && (t.formatText(), t.saveSync()), r ? {
64
+ return n && (a(t), t.saveSync()), r ? {
64
65
  status: "failed",
65
66
  message: y
66
67
  } : {
@@ -87,13 +88,13 @@ var S = [
87
88
  "});"
88
89
  ].join("\n");
89
90
  function w(e) {
90
- return u(e, {
91
+ return d(e, {
91
92
  notFound: C,
92
93
  failed: S
93
94
  }, (e) => {
94
95
  let t = e.kitContainer();
95
96
  if (!t) return !1;
96
- let n = d(t, "alias", "{}");
97
+ let n = f(t, "alias", "{}");
97
98
  if (!n) return !1;
98
99
  let r = n.getProperty("$locales");
99
100
  return r ? r.getKind() === v.PropertyAssignment && (r.getInitializer()?.getText()?.replace(/['"`]/g, "") !== "src/locales" && r.setInitializer("'src/locales'"), !0) : (n.addPropertyAssignment({
@@ -172,17 +173,17 @@ function k(t) {
172
173
  let r = new g({
173
174
  compilerOptions: { allowJs: !0 },
174
175
  manipulationSettings: { quoteKind: _.Single }
175
- }).addSourceFileAtPath(t), a = c(r, { expression: T });
176
- if (a.status === "unsupported" || !a.statement) return {
176
+ }).addSourceFileAtPath(t), o = l(r, { expression: T });
177
+ if (o.status === "unsupported" || !o.statement) return {
177
178
  status: "failed",
178
179
  message: E
179
180
  };
180
- let o = a.statement;
181
+ let s = o.statement;
181
182
  i(r, "wuchale/load-utils/server", "runWithLocale"), i(r, "wuchale/load-utils/server", "loadLocales"), i(r, "$locales/main.url", "getLocale"), i(r, "$locales/data", "locales"), O(r, "$locales/main.loader.server.svelte.js", "main"), O(r, "$locales/js.loader.server.js", "js");
182
- let s = e`
183
+ let c = e`
183
184
  loadLocales(main.key, main.loadCount, main.loadCatalog, locales);
184
185
  loadLocales(js.key, js.loadCount, js.loadCatalog, locales);
185
- `, l = e`
186
+ `, u = e`
186
187
  const ${T} = async ({ event, resolve }: any) => {
187
188
  const locale = getLocale(event.url);
188
189
  return await runWithLocale(locale, () =>
@@ -193,18 +194,95 @@ function k(t) {
193
194
  );
194
195
  };
195
196
  `;
196
- return r.insertText(o.getStart(!0), `${s}\n\n${l}\n\n`), r.formatText(), r.saveSync(), {
197
+ return r.insertText(s.getStart(!0), `${c}\n\n${u}\n\n`), a(r), r.saveSync(), {
198
+ status: "success",
199
+ changed: !0
200
+ };
201
+ }
202
+ //#endregion
203
+ //#region src/patterns/enable/i18n/modifies/hooks.ts
204
+ var A = e`
205
+ const rerouteDeLocalize = (url: string) => {
206
+ const [upath, locale] = deLocalizeDefault(url, locales);
207
+ const { path } = matchUrl(upath, locale);
208
+ return path ?? url;
209
+ };
210
+ `, j = e`
211
+ import { deLocalizeDefault } from 'wuchale/url';
212
+ import { matchUrl } from '$locales/main.url';
213
+ import { locales } from '$locales/data';
214
+
215
+ const rerouteDeLocalize = (url: string) => {
216
+ const [upath, locale] = deLocalizeDefault(url, locales);
217
+ const { path } = matchUrl(upath, locale);
218
+ return path ?? url;
219
+ };
220
+
221
+ export const reroute = ({ url }) => rerouteDeLocalize(url.pathname);
222
+ `, M = e`
223
+ Compose your existing reroute in src/hooks.ts with the wuchale de-localizer:
224
+
225
+ import { deLocalizeDefault } from 'wuchale/url';
226
+ import { matchUrl } from '$locales/main.url';
227
+ import { locales } from '$locales/data';
228
+
229
+ const rerouteDeLocalize = (url: string) => {
230
+ const [upath, locale] = deLocalizeDefault(url, locales);
231
+ const { path } = matchUrl(upath, locale);
232
+ return path ?? url;
233
+ };
234
+
235
+ export const reroute = ({ url }) => rerouteDeLocalize(existingReroute(url.pathname));
236
+ `, N = /^\(\s*\{\s*url\s*\}\s*\)\s*=>\s*negotiateReroute\(\s*url\.pathname\s*\)$/;
237
+ function te(e) {
238
+ return e.getFunction("reroute") ? !0 : e.getExportDeclarations().some((e) => e.getNamedExports().some((e) => (e.getAliasNode()?.getText() ?? e.getName()) === "reroute"));
239
+ }
240
+ function P(e) {
241
+ i(e, "wuchale/url", "deLocalizeDefault"), i(e, "$locales/main.url", "matchUrl"), i(e, "$locales/data", "locales");
242
+ }
243
+ function F(e) {
244
+ if (!m.existsSync(e)) return m.mkdirSync(h.dirname(e), { recursive: !0 }), m.writeFileSync(e, j + "\n"), {
245
+ status: "success",
246
+ changed: !0
247
+ };
248
+ if (m.readFileSync(e, "utf8").includes("rerouteDeLocalize")) return {
249
+ status: "success",
250
+ changed: !1
251
+ };
252
+ let t = new g({
253
+ compilerOptions: { allowJs: !0 },
254
+ manipulationSettings: { quoteKind: _.Single }
255
+ }).addSourceFileAtPath(e), n = t.getVariableDeclaration("reroute");
256
+ if (!n) return te(t) ? {
257
+ status: "failed",
258
+ message: M
259
+ } : (P(t), t.addStatements(`\n${A}\n\nexport const reroute = ({ url }) => rerouteDeLocalize(url.pathname);\n`), a(t), t.saveSync(), {
260
+ status: "success",
261
+ changed: !0
262
+ });
263
+ if (!n.getFirstAncestorByKind(v.VariableStatement)?.hasExportKeyword()) return {
264
+ status: "failed",
265
+ message: M
266
+ };
267
+ let r = n.getInitializer();
268
+ if (!r || !N.test(r.getText())) return {
269
+ status: "failed",
270
+ message: M
271
+ };
272
+ P(t), n.setInitializer("({ url }) => rerouteDeLocalize(negotiateReroute(url.pathname))");
273
+ let i = t.getVariableStatements().find((e) => e.getDeclarations().some((e) => e.getName() === "reroute"));
274
+ return t.insertText(i.getStart(!0), `${A}\n\n`), a(t), t.saveSync(), {
197
275
  status: "success",
198
276
  changed: !0
199
277
  };
200
278
  }
201
279
  //#endregion
202
280
  //#region src/patterns/enable/i18n/modifies/app-html.ts
203
- var A = [
281
+ var I = [
204
282
  "Add the sveltekit lang placeholder to the <html> tag:",
205
283
  "",
206
284
  "<html lang=\"%sveltekit.lang%\">"
207
- ].join("\n"), j = [
285
+ ].join("\n"), L = [
208
286
  "Create src/app.html with a lang placeholder:",
209
287
  "",
210
288
  "<!doctype html>",
@@ -218,10 +296,10 @@ var A = [
218
296
  " </body>",
219
297
  "</html>"
220
298
  ].join("\n");
221
- function M(e) {
299
+ function R(e) {
222
300
  if (!m.existsSync(e)) return {
223
301
  status: "not-found",
224
- message: j
302
+ message: L
225
303
  };
226
304
  let t = m.readFileSync(e, "utf8");
227
305
  if (t.includes("lang=\"%sveltekit.lang%\"") || t.includes("lang='%sveltekit.lang%'")) return {
@@ -231,7 +309,7 @@ function M(e) {
231
309
  let n = t.replace(/<html(\s[^>]*?)?>/i, (e) => /\slang\s*=/i.test(e) ? e.replace(/\slang\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/i, " lang=\"%sveltekit.lang%\"") : e.replace(/<html/i, "<html lang=\"%sveltekit.lang%\""));
232
310
  return n === t ? {
233
311
  status: "failed",
234
- message: A
312
+ message: I
235
313
  } : (m.writeFileSync(e, n), {
236
314
  status: "success",
237
315
  changed: !0
@@ -239,16 +317,16 @@ function M(e) {
239
317
  }
240
318
  //#endregion
241
319
  //#region src/patterns/enable/i18n/modifies/gitignore.ts
242
- var N = [
320
+ var z = [
243
321
  "Create a .gitignore with the wuchale cache ignored:",
244
322
  "",
245
323
  "# Wuchale",
246
324
  "src/locales/.wuchale"
247
325
  ].join("\n");
248
- function P(t) {
326
+ function B(t) {
249
327
  if (!m.existsSync(t)) return {
250
328
  status: "not-found",
251
- message: N
329
+ message: z
252
330
  };
253
331
  let n = m.readFileSync(t, "utf8");
254
332
  if (n.includes("src/locales/.wuchale")) return {
@@ -266,48 +344,48 @@ function P(t) {
266
344
  }
267
345
  //#endregion
268
346
  //#region src/patterns/enable/i18n/modifies/root-layout.svelte.ts
269
- var F = "<Navbar.Item>\n <LanguageSelect />\n </Navbar.Item>\n ", I = "<LanguageSelect />", L = e`
347
+ var V = "<Navbar.Item>\n <LanguageSelect />\n </Navbar.Item>\n ", H = "<LanguageSelect />", U = e`
270
348
  import LanguageSelect from '$lib/components/language-select.svelte';
271
- `, R = [
349
+ `, W = [
272
350
  "Add the language select inside your <Navbar.List> in the root layout.",
273
351
  "",
274
352
  "Import to add to the <script> tag:",
275
353
  "",
276
- L,
354
+ U,
277
355
  "",
278
356
  "Markup to add at the end of <Navbar.List>:",
279
- F
280
- ].join("\n"), z = [
357
+ V
358
+ ].join("\n"), G = [
281
359
  "Create a root layout that includes a language select inside <Navbar.List>.",
282
360
  "",
283
361
  "Import for the <script> tag:",
284
362
  "",
285
- L,
363
+ U,
286
364
  "",
287
365
  "Markup at the end of <Navbar.List>:",
288
- F
289
- ].join("\n"), B = [
366
+ V
367
+ ].join("\n"), K = [
290
368
  "Add the language select to your root layout.",
291
369
  "",
292
370
  "Import to add to the <script> tag:",
293
371
  "",
294
- L,
372
+ U,
295
373
  "",
296
374
  "Markup to add wherever it should render, e.g. above {@render children()}:",
297
375
  "",
298
- I
299
- ].join("\n"), V = [
376
+ H
377
+ ].join("\n"), q = [
300
378
  "Create a root layout that includes the language select.",
301
379
  "",
302
380
  "Import for the <script> tag:",
303
381
  "",
304
- L,
382
+ U,
305
383
  "",
306
384
  "Markup above {@render children()}:",
307
385
  "",
308
- I
386
+ H
309
387
  ].join("\n");
310
- function H(e) {
388
+ function J(e) {
311
389
  e.modifyScript((e) => {
312
390
  let { source: t } = r(e, (e) => {
313
391
  o(e, [{
@@ -318,45 +396,45 @@ function H(e) {
318
396
  return t;
319
397
  });
320
398
  }
321
- function U(e, t = "shadcn") {
399
+ function Y(e, t = "shadcn") {
322
400
  let n = t === "plain";
323
401
  if (!m.existsSync(e)) return {
324
402
  status: "not-found",
325
- message: n ? V : z
403
+ message: n ? q : G
326
404
  };
327
- let r = s.fromPath(e);
405
+ let r = c.fromPath(e);
328
406
  return r.hasElement("LanguageSelect") ? {
329
407
  status: "success",
330
408
  changed: !1
331
- } : n ? !r.getScript() || !r.insertBeforeChildren(I) ? {
409
+ } : n ? !r.getScript() || !r.insertBeforeChildren(H) ? {
332
410
  status: "failed",
333
- message: B
334
- } : (H(r), r.writeTo(e), {
411
+ message: K
412
+ } : (J(r), r.writeTo(e), {
335
413
  status: "success",
336
414
  changed: r.hasChanged()
337
- }) : r.hasElement("Navbar.List") ? (H(r), r.insertBeforeClosingTag("Navbar.List", F), r.writeTo(e), {
415
+ }) : r.hasElement("Navbar.List") ? (J(r), r.insertBeforeClosingTag("Navbar.List", V), r.writeTo(e), {
338
416
  status: "success",
339
417
  changed: r.hasChanged()
340
418
  }) : {
341
419
  status: "failed",
342
- message: R
420
+ message: W
343
421
  };
344
422
  }
345
423
  //#endregion
346
424
  //#region src/patterns/enable/i18n/welcome-catalog.ts
347
- var W = "src/routes/+page.svelte", G = "src/locales/es.po", K = ["<h1>Welcome to SvelteKit</h1>", "<p>Visit <a href=\"https://svelte.dev/docs/kit\">svelte.dev/docs/kit</a> to read the documentation</p>"].join("\n"), q = [{
348
- reference: W,
425
+ var X = "src/routes/+page.svelte", Z = "src/locales/es.po", ne = ["<h1>Welcome to SvelteKit</h1>", "<p>Visit <a href=\"https://svelte.dev/docs/kit\">svelte.dev/docs/kit</a> to read the documentation</p>"].join("\n"), Q = [{
426
+ reference: X,
349
427
  msgid: "Welcome to SvelteKit",
350
428
  msgstr: "Bienvenido a SvelteKit"
351
429
  }, {
352
- reference: W,
430
+ reference: X,
353
431
  msgid: "Visit <0>svelte.dev/docs/kit</0> to read the documentation",
354
432
  msgstr: "Visita <0>svelte.dev/docs/kit</0> para leer la documentación"
355
- }], J = {
433
+ }], re = {
356
434
  reference: "src/lib/components/language-select.svelte",
357
435
  msgid: "Language",
358
436
  msgstr: "Idioma"
359
- }, Y = [
437
+ }, ie = [
360
438
  "msgid \"\"",
361
439
  "msgstr \"\"",
362
440
  "\"Source-Language: en\\n\"",
@@ -366,14 +444,14 @@ var W = "src/routes/+page.svelte", G = "src/locales/es.po", K = ["<h1>Welcome to
366
444
  "\"Content-Transfer-Encoding: 8bit\\n\"",
367
445
  "\"Plural-Forms: nplurals=3\\n\"",
368
446
  "\"X-Plurals-Order: one, many, other\\n\""
369
- ].join("\n"), X = (e) => e.replace(/\s+/g, "");
370
- function Z(e, t) {
371
- if (m.existsSync(h.join(e, G))) return null;
372
- let n = h.join(e, W);
373
- return !m.existsSync(n) || X(m.readFileSync(n, "utf8")) !== X(K) ? null : {
374
- path: G,
447
+ ].join("\n"), $ = (e) => e.replace(/\s+/g, "");
448
+ function ae(e, t) {
449
+ if (m.existsSync(h.join(e, Z))) return null;
450
+ let n = h.join(e, X);
451
+ return !m.existsSync(n) || $(m.readFileSync(n, "utf8")) !== $(ne) ? null : {
452
+ path: Z,
375
453
  language: "text",
376
- content: [Y, ...(t === "plain" ? [...q, J] : q).map((e) => [
454
+ content: [ie, ...(t === "plain" ? [...Q, re] : Q).map((e) => [
377
455
  `#: ${e.reference}`,
378
456
  `msgid "${e.msgid}"`,
379
457
  `msgstr "${e.msgstr}"`
@@ -383,31 +461,33 @@ function Z(e, t) {
383
461
  }
384
462
  //#endregion
385
463
  //#region src/patterns/enable/i18n/generate.runtime.ts
386
- async function Q(e) {
387
- let r = n(e), i = [], o = (e) => {
464
+ async function oe(e) {
465
+ let r = n(e), i = [], a = (e) => {
388
466
  e && i.push(e);
389
467
  };
390
468
  r.info("Modifying vite.config");
391
- let s = l(e.root, f) ?? h.join(e.root, f[0]);
392
- o(a(s, x(s))), r.info("Modifying config for i18n alias");
469
+ let o = u(e.root, p) ?? h.join(e.root, p[0]);
470
+ a(s(o, x(o))), r.info("Modifying config for i18n alias");
393
471
  let c = w(e.root);
394
- o(a(c.filePath, c.outcome)), r.info("Modifying hooks.server.ts");
395
- let u = h.join(e.root, "src", "hooks.server.ts");
396
- o(a(u, k(u))), r.info("Modifying app.html");
397
- let d = h.join(e.root, "src", "app.html");
398
- o(a(d, M(d))), r.info("Modifying root +layout.ts");
472
+ a(s(c.filePath, c.outcome)), r.info("Modifying hooks.server.ts");
473
+ let l = h.join(e.root, "src", "hooks.server.ts");
474
+ a(s(l, k(l))), r.info("Modifying hooks.ts");
475
+ let d = h.join(e.root, "src", "hooks.ts");
476
+ a(s(d, F(d))), r.info("Modifying app.html");
477
+ let f = h.join(e.root, "src", "app.html");
478
+ a(s(f, R(f))), r.info("Modifying root +layout.ts");
399
479
  let g = h.join(e.root, "src", "routes", "+layout.ts");
400
- o(a(g, p(g))), r.info("Modifying root layout language select");
480
+ a(s(g, ee(g))), r.info("Modifying root layout language select");
401
481
  let _ = [
402
482
  h.join(e.root, "src", "routes", "(public)", "root-layout.svelte"),
403
483
  h.join(e.root, "src", "routes", "root-layout.svelte"),
404
484
  h.join(e.root, "src", "routes", "(public)", "+layout.svelte"),
405
485
  h.join(e.root, "src", "routes", "+layout.svelte")
406
486
  ], v = t(e), y = _.find((e) => m.existsSync(e)) ?? (v === "plain" ? _[3] : _[0]);
407
- o(a(y, U(y, v))), r.info("Updating .gitignore");
487
+ a(s(y, Y(y, v))), r.info("Updating .gitignore");
408
488
  let b = h.join(e.root, ".gitignore");
409
- o(a(b, P(b)));
410
- let S = Z(e.root, v);
489
+ a(s(b, B(b)));
490
+ let S = ae(e.root, v);
411
491
  return S && r.info("Translating the welcome page into Spanish"), {
412
492
  creates: S ? [S] : [],
413
493
  modifies: i,
@@ -420,6 +500,6 @@ async function Q(e) {
420
500
  };
421
501
  }
422
502
  //#endregion
423
- export { Q as generate };
503
+ export { oe as generate };
424
504
 
425
- //# sourceMappingURL=generate.runtime-D8vgh5MH.js.map
505
+ //# sourceMappingURL=generate.runtime-BjciAjq7.js.map