@akanjs/devkit 2.2.0-rc.2 → 2.2.0-rc.4

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.
@@ -73,5 +73,9 @@ describe("resolveSsrPageEntries", () => {
73
73
  const generatedSource = await Bun.file(groupedRoot?.moduleAbsPath ?? "").text();
74
74
  expect(generatedSource).toContain("<System.Provider");
75
75
  expect(generatedSource).toContain("theme={userLayout.theme ?? inheritedLayout.theme}");
76
+ expect(generatedSource).toContain("const getActiveLocaleDictionary =");
77
+ expect(generatedSource).toContain('await import("@apps/demo/lib/dict")');
78
+ expect(generatedSource).toContain("dictionary={getActiveLocaleDictionary ? getActiveLocaleDictionary(params.lang) : undefined}");
79
+ expect(generatedSource).not.toContain("// export default function GeneratedLayout");
76
80
  });
77
81
  });
@@ -135,8 +135,69 @@ async function writeGeneratedRootLayoutFile(opts: {
135
135
  ? `import UserLayout, * as userLayout from ${JSON.stringify(sourceSpecifier)};\n`
136
136
  : "const UserLayout = ({ children }) => children;\nconst userLayout = {};\n";
137
137
  const source = opts.includeSystemProvider
138
- ? `import type { LayoutProps, PageProps } from "akanjs/client";\nimport { loadFonts } from "akanjs/client";\nimport { System } from "akanjs/ui";\nimport { env } from "@apps/${opts.appName}/env/env.client";\n${clientImport}${inheritedImport}${userImport}\n// SSR builds (target=bun) load the full dictionary server-side and pass only the active locale to the client.\n// CSR builds (target=browser) fold this branch to undefined, so the macro-seeded dictionary is used and the\n// server-only dict module (which pulls @libs/*/server) is dead-code-eliminated out of the browser bundle.\nconst getActiveLocaleDictionary =\n process.env.AKAN_PUBLIC_RENDER_ENV === "ssr" ? (await import("@apps/${opts.appName}/lib/dict")).getDictionary : undefined;\nconst userFonts = userLayout.fonts ?? inheritedLayout.fonts ?? [];\nconst defaultFonts = userFonts.filter((font) => font.default);\nif (defaultFonts.length > 1) throw new Error("[route-convention] only one default font is allowed per root layout");\nconst defaultFont = defaultFonts[0];\nconst defaultFontClassName = defaultFont ? (defaultFont.className ?? \`font-\${defaultFont.name}\`) : undefined;\n\nexport async function generateHead(props: PageProps) {\n if (userLayout.generateHead) return userLayout.generateHead(props);\n if (userLayout.head !== undefined) return userLayout.head;\n if (inheritedLayout.generateHead) return inheritedLayout.generateHead(props);\n return inheritedLayout.head;\n}\n\nexport const NotFound = userLayout.NotFound ?? inheritedLayout.NotFound;\nexport const Error = userLayout.Error ?? inheritedLayout.Error;\n\nexport default function GeneratedLayout({ children, params, searchParams }: LayoutProps) {\n return (\n <System.Provider\n of={GeneratedLayout as never}\n appName=${JSON.stringify(opts.appName)}\n ${prefix ? `prefix=${JSON.stringify(prefix)}\n ` : ""}params={params}\n manifest={userLayout.manifest ?? inheritedLayout.manifest}\n env={env}\n theme={userLayout.theme ?? inheritedLayout.theme}\n fonts={loadFonts(userFonts)}\n className={defaultFontClassName}\n gaTrackingId={userLayout.gaTrackingId ?? inheritedLayout.gaTrackingId}\n layoutStyle={userLayout.layoutStyle ?? inheritedLayout.layoutStyle}\n reconnect={userLayout.reconnect ?? inheritedLayout.reconnect ?? false}\n dictionary={getActiveLocaleDictionary ? getActiveLocaleDictionary(params.lang) : undefined}\n >\n <UserLayout params={params} searchParams={searchParams}>{children}</UserLayout>\n </System.Provider>\n );\n}\n`
139
- : `import type { LayoutProps, PageProps } from "akanjs/client";\n${inheritedImport}${userImport}\nexport async function generateHead(props: PageProps) {\n if (userLayout.generateHead) return userLayout.generateHead(props);\n if (userLayout.head !== undefined) return userLayout.head;\n if (inheritedLayout.generateHead) return inheritedLayout.generateHead(props);\n return inheritedLayout.head;\n}\n\nexport const NotFound = userLayout.NotFound ?? inheritedLayout.NotFound;\nexport const Error = userLayout.Error ?? inheritedLayout.Error;\n\nexport default function GeneratedLayout({ children, params, searchParams }: LayoutProps) {\n return <UserLayout params={params} searchParams={searchParams}>{children}</UserLayout>;\n}\n`;
138
+ ? `import type { LayoutProps, PageProps } from "akanjs/client";
139
+ import { loadFonts } from "akanjs/client";
140
+ import { System } from "akanjs/ui";
141
+ import { env } from "@apps/${opts.appName}/env/env.client";
142
+ ${clientImport}${inheritedImport}${userImport}
143
+ // SSR builds (target=bun) load the full dictionary server-side and pass only the active locale to the client.
144
+ // CSR builds (target=browser) fold this branch to undefined, so the macro-seeded dictionary is used and the
145
+ // server-only dict module (which pulls @libs/*/server) is dead-code-eliminated out of the browser bundle.
146
+ const getActiveLocaleDictionary =
147
+ process.env.AKAN_PUBLIC_RENDER_ENV === "ssr" ? (await import("@apps/${opts.appName}/lib/dict")).getDictionary : undefined;
148
+ const userFonts = userLayout.fonts ?? inheritedLayout.fonts ?? [];
149
+ const defaultFonts = userFonts.filter((font) => font.default);
150
+ if (defaultFonts.length > 1) throw new Error("[route-convention] only one default font is allowed per root layout");
151
+ const defaultFont = defaultFonts[0];
152
+ const defaultFontClassName = defaultFont ? (defaultFont.className ?? \`font-\${defaultFont.name}\`) : undefined;
153
+
154
+ export async function generateHead(props: PageProps) {
155
+ if (userLayout.generateHead) return userLayout.generateHead(props);
156
+ if (userLayout.head !== undefined) return userLayout.head;
157
+ if (inheritedLayout.generateHead) return inheritedLayout.generateHead(props);
158
+ return inheritedLayout.head;
159
+ }
160
+
161
+ export const NotFound = userLayout.NotFound ?? inheritedLayout.NotFound;
162
+ export const Error = userLayout.Error ?? inheritedLayout.Error;
163
+
164
+ export default function GeneratedLayout({ children, params, searchParams }: LayoutProps) {
165
+ return (
166
+ <System.Provider
167
+ of={GeneratedLayout as never}
168
+ appName=${JSON.stringify(opts.appName)}
169
+ ${prefix ? `prefix=${JSON.stringify(prefix)}\n ` : ""}params={params}
170
+ manifest={userLayout.manifest ?? inheritedLayout.manifest}
171
+ env={env}
172
+ theme={userLayout.theme ?? inheritedLayout.theme}
173
+ fonts={loadFonts(userFonts)}
174
+ className={defaultFontClassName}
175
+ gaTrackingId={userLayout.gaTrackingId ?? inheritedLayout.gaTrackingId}
176
+ layoutStyle={userLayout.layoutStyle ?? inheritedLayout.layoutStyle}
177
+ reconnect={userLayout.reconnect ?? inheritedLayout.reconnect ?? false}
178
+ dictionary={getActiveLocaleDictionary ? getActiveLocaleDictionary(params.lang) : undefined}
179
+ >
180
+ <UserLayout params={params} searchParams={searchParams}>{children}</UserLayout>
181
+ </System.Provider>
182
+ );
183
+ }
184
+ `
185
+ : `import type { LayoutProps, PageProps } from "akanjs/client";
186
+ ${inheritedImport}${userImport}
187
+ export async function generateHead(props: PageProps) {
188
+ if (userLayout.generateHead) return userLayout.generateHead(props);
189
+ if (userLayout.head !== undefined) return userLayout.head;
190
+ if (inheritedLayout.generateHead) return inheritedLayout.generateHead(props);
191
+ return inheritedLayout.head;
192
+ }
193
+
194
+ export const NotFound = userLayout.NotFound ?? inheritedLayout.NotFound;
195
+ export const Error = userLayout.Error ?? inheritedLayout.Error;
196
+
197
+ export default function GeneratedLayout({ children, params, searchParams }: LayoutProps) {
198
+ return <UserLayout params={params} searchParams={searchParams}>{children}</UserLayout>;
199
+ }
200
+ `;
140
201
  await Bun.write(absPath, source);
141
202
  return absPath;
142
203
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akanjs/devkit",
3
- "version": "2.2.0-rc.2",
3
+ "version": "2.2.0-rc.4",
4
4
  "sourceType": "module",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -32,7 +32,7 @@
32
32
  "@langchain/openai": "^1.4.6",
33
33
  "@tailwindcss/node": "^4.3.0",
34
34
  "@trapezedev/project": "^7.1.4",
35
- "akanjs": "2.2.0-rc.2",
35
+ "akanjs": "2.2.0-rc.4",
36
36
  "chalk": "^5.6.2",
37
37
  "commander": "^14.0.3",
38
38
  "daisyui": "^5.5.20",