@akanjs/devkit 3.3.0-rc.5 → 3.3.0-rc.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +650 -0
- package/DEV_RUNTIME_KNOBS.md +1 -1
- package/README.ko.md +3 -2
- package/README.md +3 -3
- package/akanApp/akanApp.host.test.ts +1 -1
- package/akanApp/akanApp.host.ts +11 -0
- package/akanConfig/akanBin.ts +4 -0
- package/akanConfig/akanConfig.test.ts +70 -10
- package/akanConfig/akanConfig.ts +57 -206
- package/akanConfig/akanWorkers.test.ts +39 -0
- package/akanConfig/akanWorkers.ts +32 -0
- package/akanConfig/desktopServerConfig.ts +96 -0
- package/akanConfig/dockerImage.ts +39 -0
- package/akanConfig/nativeKeys.ts +52 -0
- package/akanConfig/types.ts +1 -0
- package/app/appBin.test.ts +63 -0
- package/app/appBin.ts +50 -0
- package/app/applicationBuildReporter.test.ts +49 -0
- package/app/applicationBuildReporter.ts +5 -0
- package/app/applicationBuildRunner.test.ts +275 -0
- package/app/applicationBuildRunner.ts +149 -12
- package/app/dictionarySizes.ts +91 -0
- package/app/routeFilesReport.test.ts +59 -0
- package/app/routeFilesReport.ts +46 -0
- package/app/routeJsBudget.ts +18 -4
- package/artifact/implicitRootLayout.test.ts +19 -0
- package/artifact/implicitRootLayout.ts +16 -2
- package/artifact/implicitRootLayoutRender.test.tsx +4 -1
- package/artifact/storeBootstrap.test.ts +28 -0
- package/artifact/storeBootstrap.ts +64 -8
- package/biome.base.json +6 -2
- package/codeAgent/agent/CodeAgent.ts +36 -16
- package/codeAgent/agent/CodeAgentAllowed.ts +35 -0
- package/codeAgent/agent/CodeAgentCommandLine.ts +372 -0
- package/codeAgent/agent/CodeAgentGate.ts +23 -4
- package/codeAgent/agent/CodeAgentRpcHost.ts +1 -1
- package/codeAgent/agent/codeAgent.test.ts +62 -0
- package/codeAgent/agent/codeAgentCommandLine.test.ts +212 -0
- package/codeAgent/agent/codeAgentContract.test.ts +117 -5
- package/codeAgent/skills/akan-agent/SKILL.md +8 -1
- package/codeAgent/skills/akan-code/SKILL.md +38 -3
- package/codeAgent/skills/akan-deps/SKILL.md +3 -2
- package/codeAgent/skills/akan-err/SKILL.md +13 -8
- package/codeAgent/skills/akan-mcp/SKILL.md +1 -1
- package/codeAgent/skills/akan-module/SKILL.md +2 -2
- package/codeAgent/skills/akan-page/SKILL.md +34 -26
- package/codeAgent/skills/akan-query/SKILL.md +13 -20
- package/codeAgent/skills/akan-runtime/SKILL.md +20 -0
- package/codeAgent/skills/akan-service/SKILL.md +10 -11
- package/codeAgent/skills/akan-transport/SKILL.md +5 -14
- package/codeAgent/skills/akan-ui/SKILL.md +2 -5
- package/context/akanContext.ts +2 -0
- package/csrE2e/devHmrLatency.e2e.test.ts +1 -1
- package/docs/apiReference.test.ts +9 -0
- package/docs/apiReference.ts +14 -0
- package/executors/appExecutor.ts +3 -1
- package/executors/clientRuntimeKeyOrder.fixture.json +682 -0
- package/executors/clientRuntimeKeys.fixture.json +393 -0
- package/executors/clientRuntimeKeys.test.ts +1690 -0
- package/executors/executor.ts +12 -4
- package/executors/executors.test.ts +2 -0
- package/executors/sysExecutor.ts +70 -4
- package/executors/workspaceExecutor.ts +7 -4
- package/frontendBuild/allRoutesBuilder.ts +99 -7
- package/frontendBuild/autoImportSync.ts +3 -2
- package/frontendBuild/buildRouteClient.test.ts +686 -13
- package/frontendBuild/clientBuildTypes.ts +26 -0
- package/frontendBuild/clientEntriesBundler.ts +49 -1
- package/frontendBuild/clientEntryDiscovery.test.ts +308 -1
- package/frontendBuild/clientEntryDiscovery.ts +136 -14
- package/frontendBuild/clientEntryGroups.test.ts +77 -0
- package/frontendBuild/clientEntryGroups.ts +61 -0
- package/frontendBuild/csrDevArtifactWriter.ts +2 -2
- package/frontendBuild/csrDevModuleCompiler.test.ts +86 -0
- package/frontendBuild/csrDevModuleCompiler.ts +44 -8
- package/frontendBuild/csrDevPatcher.test.ts +1 -1
- package/frontendBuild/csrDevPatcher.ts +33 -7
- package/frontendBuild/csrDevTypes.ts +9 -0
- package/frontendBuild/devBarrelImports.test.ts +154 -0
- package/frontendBuild/devBarrelImports.ts +83 -23
- package/frontendBuild/devRegistryBundler.ts +4 -2
- package/frontendBuild/devRouteRuntime.test.ts +492 -0
- package/frontendBuild/devRouteRuntime.ts +167 -0
- package/frontendBuild/dictionaryAssetBuilder.test.ts +329 -0
- package/frontendBuild/dictionaryAssetBuilder.ts +165 -16
- package/frontendBuild/dictionaryConstants.ts +136 -0
- package/frontendBuild/dictionaryPacking.test.ts +142 -0
- package/frontendBuild/dictionaryPacking.ts +135 -0
- package/frontendBuild/dictionaryRoutes.test.ts +251 -0
- package/frontendBuild/dictionaryRoutes.ts +227 -0
- package/frontendBuild/pagesBundleBuilder.test.ts +84 -0
- package/frontendBuild/pagesBundleBuilder.ts +81 -3
- package/frontendBuild/precompressArtifacts.test.ts +22 -0
- package/frontendBuild/precompressArtifacts.ts +22 -8
- package/frontendBuild/registryMetadataFingerprint.ts +3 -3
- package/frontendBuild/renderedEntries.ts +144 -0
- package/frontendBuild/routeClientBuilder.ts +407 -43
- package/frontendBuild/routeHandoffs.test.ts +155 -0
- package/frontendBuild/routeHandoffs.ts +117 -0
- package/frontendBuild/routeModulePreloads.test.ts +32 -0
- package/frontendBuild/routeModulePreloads.ts +20 -11
- package/frontendBuild/routeRuntimeCheck.test.ts +280 -0
- package/frontendBuild/routeRuntimeCheck.ts +248 -0
- package/frontendBuild/routeRuntimePays.test.ts +143 -0
- package/frontendBuild/routeRuntimePays.ts +117 -0
- package/frontendBuild/rscServerRendererGuard.test.ts +60 -0
- package/frontendBuild/rscServerRendererGuard.ts +68 -0
- package/frontendBuild/ssrBaseArtifactBuilder.ts +24 -34
- package/frontendBuild/ssrDevBundler.test.ts +150 -1
- package/frontendBuild/ssrDevBundler.ts +66 -11
- package/frontendBuild/vendorFileImports.test.ts +254 -0
- package/frontendBuild/vendorFileImports.ts +163 -0
- package/frontendBuild/vendorNarrowing.ts +28 -0
- package/frontendBuild/vendorSpecifiers.ts +2 -0
- package/incrementalBuilder/buildBatch.proc.ts +9 -9
- package/incrementalBuilder/buildBatchProtocol.ts +1 -1
- package/incrementalBuilder/builderBoot.ts +5 -5
- package/incrementalBuilder/builderGraphPayloads.ts +4 -4
- package/incrementalBuilder/builderLanes.ts +2 -2
- package/incrementalBuilder/builderWatch.ts +8 -8
- package/incrementalBuilder/csrRegistry.ts +4 -4
- package/incrementalBuilder/incrementalBuilder.proc.test.ts +79 -0
- package/incrementalBuilder/incrementalBuilder.proc.ts +27 -8
- package/incrementalBuilder/ssrRegistry.ts +6 -6
- package/index.ts +1 -1
- package/integration/renderAdmissionSoak.test.ts +99 -0
- package/integration/renderAdmissionSoak.ts +609 -0
- package/lint/__fixtures__/no-arbitrary-color/every-color-function/bad.tsx +11 -0
- package/lint/__fixtures__/no-arbitrary-color/every-color-function/good.tsx +2 -0
- package/lint/__fixtures__/no-daisyui-legacy-class/every-class/bad.tsx +34 -0
- package/lint/__fixtures__/no-daisyui-legacy-class/every-class/good.tsx +2 -0
- package/lint/__fixtures__/no-inline-color/every-color-function/bad.tsx +10 -0
- package/lint/__fixtures__/no-inline-color/every-color-function/good.tsx +2 -0
- package/lint/__fixtures__/no-raw-palette-class/every-palette/bad.tsx +22 -0
- package/lint/__fixtures__/no-raw-palette-class/every-palette/good.tsx +2 -0
- package/lint/biomeBase.test.ts +21 -2
- package/lint/biomeBase.ts +1 -1
- package/lint/biomeCheck.test.ts +162 -0
- package/lint/biomeCheck.ts +131 -0
- package/lint/linter.test.ts +16 -11
- package/lint/no-arbitrary-color.grit +5 -0
- package/lint/no-conditional-st-hook.grit +5 -1
- package/lint/no-daisyui-legacy-class.grit +8 -0
- package/lint/no-document-cookie.grit +3 -0
- package/lint/no-inline-color.grit +10 -2
- package/lint/no-oversized-list-limit.grit +2 -0
- package/lint/no-raw-palette-class.grit +7 -0
- package/lint/no-unpublished-form-setter.grit +2 -0
- package/lint/no-web-only-api-outside-webkit.grit +5 -0
- package/lint/no-web-storage.grit +3 -0
- package/lint/withheldEnvFile.ts +17 -0
- package/mobile/desktopBin.ts +2 -2
- package/mobile/desktopServerStage.test.ts +9 -2
- package/mobile/desktopServerStage.ts +1 -0
- package/mobile/nativeApp.test.ts +7 -5
- package/mobile/nativeApp.ts +2 -2
- package/mobile/nativeConfig.test.ts +96 -1
- package/mobile/nativeConfig.ts +46 -12
- package/mobile/nativePublicEnv.ts +1 -1
- package/mobile/serverBundleSecrets.ts +43 -0
- package/package.json +15 -169
- package/packageExports.test.ts +38 -24
- package/quality/dictionaryKeys.test.ts +356 -0
- package/quality/dictionaryKeys.ts +488 -0
- package/quality/objectImportReport.test.ts +36 -0
- package/quality/objectImportReport.ts +105 -0
- package/quality/qualityScanner.ts +1 -1
- package/quality/routeRuntimeReport.test.ts +91 -0
- package/quality/routeRuntimeReport.ts +121 -0
- package/quality/runtimeConstantFacts.ts +71 -0
- package/quality/runtimeConstantGraph.ts +123 -0
- package/quality/runtimeConstantReads.ts +116 -0
- package/quality/runtimeImports.test.ts +190 -0
- package/quality/runtimeImports.ts +233 -0
- package/quality/runtimeKeyNames.ts +46 -0
- package/quality/runtimeLexicalScope.ts +132 -0
- package/quality/runtimeMarkerReach.test.ts +84 -0
- package/quality/runtimeMarkerReach.ts +255 -0
- package/quality/runtimeModuleFacts.ts +290 -0
- package/quality/runtimeNameTable.test.ts +172 -0
- package/quality/runtimeNameTable.ts +477 -0
- package/quality/runtimeScopeReport.test.ts +123 -0
- package/quality/runtimeScopeReport.ts +167 -0
- package/quality/runtimeSliceKey.ts +269 -0
- package/quality/runtimeSyntax.ts +133 -0
- package/quality/runtimeTable.fixture.ts +189 -0
- package/quality/runtimeUse.test.ts +737 -0
- package/quality/runtimeUse.ts +696 -0
- package/quality/runtimeUseReadable.test.ts +393 -0
- package/quality/ssrScanner.test.ts +13 -0
- package/quality/ssrScanner.ts +1 -1
- package/quality/translatorBindings.ts +187 -0
- package/test/secretEnvFixture.ts +134 -0
- package/test/testHelpers.ts +11 -0
- package/transforms/barrelAnalyzer.ts +26 -4
- package/transforms/barrelImportsPlugin.ts +121 -32
- package/transforms/exportReach.test.ts +162 -0
- package/transforms/exportReach.ts +308 -0
- package/transforms/frameworkObjects.fixture.tsx +58 -0
- package/transforms/frameworkObjects.test.ts +54 -0
- package/transforms/modelReference.test.ts +196 -0
- package/transforms/modelReference.ts +39 -0
- package/transforms/moduleParts.test.ts +225 -0
- package/transforms/moduleParts.ts +418 -0
- package/transforms/objectImportEdits.ts +150 -0
- package/transforms/objectMemberImports.test.ts +633 -0
- package/transforms/objectMemberImports.ts +571 -0
- package/transforms/objectMemberLookup.ts +150 -0
- package/transforms/objectModule.test.ts +307 -0
- package/transforms/objectModule.ts +482 -0
- package/transforms/objectModuleAnalyzer.ts +104 -0
- package/transforms/partImports.test.ts +76 -0
- package/transforms/partImports.ts +110 -0
- package/transforms/partModules.test.ts +187 -0
- package/transforms/partModules.ts +90 -0
- package/transforms/partPurity.ts +124 -0
- package/transforms/reactIconImports.test.ts +231 -0
- package/transforms/reactIconImports.ts +325 -0
- package/transforms/routeConstants.ts +122 -0
- package/transforms/routeRuntime.test.ts +835 -0
- package/transforms/routeRuntime.ts +703 -0
- package/transforms/routeRuntimeEdits.ts +92 -0
- package/transforms/routeRuntimeGraph.ts +66 -0
- package/transforms/routeRuntimePlan.ts +244 -0
- package/transforms/secretEnvDeclaration.test.ts +208 -0
- package/transforms/secretEnvDeclaration.ts +213 -0
- package/transforms/secretEnvFile.test.ts +117 -0
- package/transforms/secretEnvFile.ts +113 -0
- package/transforms/secretEnvName.test.ts +54 -0
- package/transforms/secretEnvName.ts +29 -0
- package/transforms/secretEnvSource.test.ts +148 -0
- package/transforms/secretEnvSource.ts +166 -0
- package/transforms/serverEnvEvaluationError.ts +11 -0
- package/transforms/serverEnvPlugin.test.ts +2 -1
- package/transforms/serverEnvPlugin.ts +13 -0
- package/transforms/serverEnvProfile.test.ts +115 -2
- package/transforms/serverEnvProfile.ts +117 -40
- package/transforms/serverEnvSecrets.test.ts +292 -0
- package/transforms/signalDescriptors.test.ts +280 -0
- package/transforms/signalDescriptors.ts +227 -0
- package/transforms/thisFreeExports.ts +87 -0
- package/transforms/transforms.test.ts +180 -3
- package/transforms/tsconfigPackageResolver.test.ts +1 -0
- package/tunnel/createTunnel.test.ts +29 -8
- package/tunnel/createTunnel.ts +18 -11
- package/typecheck/projectTypecheck.test.ts +29 -0
- package/typecheck/typeChecker.test.ts +49 -0
- package/typecheck/typeChecker.ts +9 -7
- package/typecheck/withheldDiagnostics.ts +41 -0
- package/util/fileEditor.ts +1 -0
- package/util/selectModel.ts +1 -0
- package/workflow/executor.ts +6 -2
- package/workflow/index.ts +1 -0
- package/workflow/plan.ts +36 -7
- package/workflow/types.ts +1 -1
- package/workflow/uiTarget.ts +50 -0
- package/workspace/getRelatedCnsts.ts +7 -0
- package/workspace/scanInfo.test.ts +39 -0
- package/workspace/scanInfo.ts +48 -5
- package/workspace/slicePlanner.ts +1 -1
- package/workspace/workspaceLayout.ts +1 -0
package/executors/executor.ts
CHANGED
|
@@ -149,20 +149,28 @@ export class Executor {
|
|
|
149
149
|
const readPath = this.getPath(dirPath);
|
|
150
150
|
try {
|
|
151
151
|
const glob = new Bun.Glob("*");
|
|
152
|
-
return Array.from(glob.scanSync({ cwd: readPath, onlyFiles: false })).sort()
|
|
152
|
+
return Array.from(glob.scanSync({ cwd: readPath, onlyFiles: false })).sort((a, b) =>
|
|
153
|
+
a < b ? -1 : a > b ? 1 : 0,
|
|
154
|
+
);
|
|
153
155
|
} catch {
|
|
154
156
|
return [];
|
|
155
157
|
}
|
|
156
158
|
}
|
|
157
159
|
async getAllFiles(pattern = "**/*", { cwd }: { cwd?: string } = {}): Promise<string[]> {
|
|
158
160
|
const glob = new Bun.Glob(pattern);
|
|
159
|
-
return Array.from(glob.scanSync({ cwd: cwd ?? this.cwdPath, onlyFiles: true })).sort()
|
|
161
|
+
return Array.from(glob.scanSync({ cwd: cwd ?? this.cwdPath, onlyFiles: true })).sort((a, b) =>
|
|
162
|
+
a < b ? -1 : a > b ? 1 : 0,
|
|
163
|
+
);
|
|
160
164
|
}
|
|
161
165
|
async getFilesAndDirs(dirPath: string): Promise<{ files: string[]; dirs: string[] }> {
|
|
162
166
|
const fullDirPath = this.getPath(dirPath);
|
|
163
167
|
const glob = new Bun.Glob("*");
|
|
164
|
-
const files = Array.from(glob.scanSync({ cwd: fullDirPath, onlyFiles: true })).sort()
|
|
165
|
-
|
|
168
|
+
const files = Array.from(glob.scanSync({ cwd: fullDirPath, onlyFiles: true })).sort((a, b) =>
|
|
169
|
+
a < b ? -1 : a > b ? 1 : 0,
|
|
170
|
+
);
|
|
171
|
+
const allEntries = Array.from(glob.scanSync({ cwd: fullDirPath, onlyFiles: false })).sort((a, b) =>
|
|
172
|
+
a < b ? -1 : a > b ? 1 : 0,
|
|
173
|
+
);
|
|
166
174
|
const dirs = allEntries.filter((entry) => !files.includes(entry));
|
|
167
175
|
return { files, dirs };
|
|
168
176
|
}
|
|
@@ -4,6 +4,7 @@ import { lstat, mkdir, readFile, readlink, rm, stat, utimes, writeFile } from "n
|
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { AkanAppConfig } from "../akanConfig";
|
|
6
6
|
import { DevGeneratedIndexSync } from "../frontendBuild/devGeneratedIndexSync";
|
|
7
|
+
import { RouteRuntimeReport } from "../quality/routeRuntimeReport";
|
|
7
8
|
import {
|
|
8
9
|
createTempApp,
|
|
9
10
|
createTempLib,
|
|
@@ -629,6 +630,7 @@ describe("Workspace and app executor environment contracts", () => {
|
|
|
629
630
|
"cache/cssCandidates.json",
|
|
630
631
|
"cache/fontCache.json",
|
|
631
632
|
"cache/fonts/Assistant-400-normal-abc.woff2",
|
|
633
|
+
path.relative(".akan", RouteRuntimeReport.file),
|
|
632
634
|
];
|
|
633
635
|
const removed = [
|
|
634
636
|
"artifact/client/app.js",
|
package/executors/sysExecutor.ts
CHANGED
|
@@ -90,6 +90,68 @@ export class SysExecutor extends Executor {
|
|
|
90
90
|
);
|
|
91
91
|
return written;
|
|
92
92
|
}
|
|
93
|
+
//? `synced` is the app or lib whose sync this is: a lib's files are written by the sync of each app mounting it.
|
|
94
|
+
async #syncClientPieces(scanInfo: AppInfo | LibInfo, synced: SysExecutor): Promise<FileContent[]> {
|
|
95
|
+
const pieceDir = "lib/__client";
|
|
96
|
+
const modulesOf = (info: AppInfo | LibInfo): string[] => [
|
|
97
|
+
...[...info.getLibInfos().values()].flatMap(modulesOf),
|
|
98
|
+
...info.getDatabaseModules(),
|
|
99
|
+
...info.getServiceModules(),
|
|
100
|
+
];
|
|
101
|
+
const scope = `${this.type}s/${this.name}`;
|
|
102
|
+
const scopesOf = (info: AppInfo | LibInfo, own: string): string[] => [
|
|
103
|
+
...[...info.getLibInfos().values()].flatMap((libInfo) => scopesOf(libInfo, `libs/${libInfo.name}`)),
|
|
104
|
+
own,
|
|
105
|
+
];
|
|
106
|
+
const { RuntimeNameTable } = await import("../quality/runtimeNameTable");
|
|
107
|
+
const { RuntimeConstantGraph } = await import("../quality/runtimeConstantGraph");
|
|
108
|
+
const table = await RuntimeNameTable.readScopes(this.workspace.workspaceRoot, [
|
|
109
|
+
...new Set(scopesOf(scanInfo, scope)),
|
|
110
|
+
]).catch((error: unknown) => {
|
|
111
|
+
if (synced.type === "app")
|
|
112
|
+
this.logger.warn(
|
|
113
|
+
`[client-runtime] The modules of ${scope} could not be read (${error instanceof Error ? error.message : String(error)}), so no store file under ${scope}/${pieceDir} loads the upload module's descriptors first, and a page naming only that store has no upload action. Run \`akan sync ${this.name}\` again once that is fixed.`,
|
|
114
|
+
);
|
|
115
|
+
return null;
|
|
116
|
+
});
|
|
117
|
+
const constants = table ? RuntimeConstantGraph.ofDisk(this.workspace.workspaceRoot, table) : null;
|
|
118
|
+
const written = (
|
|
119
|
+
await Promise.all([
|
|
120
|
+
this._applyTemplate({ basePath: pieceDir, template: "clientPiece/scope", scanInfo }),
|
|
121
|
+
...[...new Set(modulesOf(scanInfo))].map((model) =>
|
|
122
|
+
this._applyTemplate({
|
|
123
|
+
basePath: pieceDir,
|
|
124
|
+
template: "clientPiece/module",
|
|
125
|
+
scanInfo,
|
|
126
|
+
dict: {
|
|
127
|
+
model,
|
|
128
|
+
Model: capitalize(model),
|
|
129
|
+
descriptorsFirst: (table?.dependenciesOf(scope, model) ?? []).map(({ module }) => module).join(","),
|
|
130
|
+
},
|
|
131
|
+
options: {
|
|
132
|
+
constants: constants?.fetchNeedsOf(model) ?? undefined,
|
|
133
|
+
registration: constants?.modelOf(model) ?? undefined,
|
|
134
|
+
},
|
|
135
|
+
}),
|
|
136
|
+
),
|
|
137
|
+
...(constants
|
|
138
|
+
? [...scanInfo.getDatabaseModules(), ...scanInfo.getScalarModules()].map((model) =>
|
|
139
|
+
this._applyTemplate({
|
|
140
|
+
basePath: pieceDir,
|
|
141
|
+
template: "clientPiece/constant",
|
|
142
|
+
scanInfo,
|
|
143
|
+
dict: { model, Model: capitalize(model) },
|
|
144
|
+
options: constants.piecesBefore({ scope, module: model }),
|
|
145
|
+
}),
|
|
146
|
+
)
|
|
147
|
+
: []),
|
|
148
|
+
])
|
|
149
|
+
).flat();
|
|
150
|
+
const kept = new Set(written.map(({ filePath }) => path.basename(filePath)));
|
|
151
|
+
const stale = (await this.readdir(pieceDir)).filter((file) => !kept.has(file));
|
|
152
|
+
await Promise.all(stale.map((file) => this.remove(`${pieceDir}/${file}`)));
|
|
153
|
+
return written;
|
|
154
|
+
}
|
|
93
155
|
#getScanTemplateTasks(scanInfo: AppInfo | LibInfo): (Promise<FileContent[]> | null)[] {
|
|
94
156
|
return [
|
|
95
157
|
this.#seedEnvFiles(),
|
|
@@ -133,16 +195,20 @@ export class SysExecutor extends Executor {
|
|
|
133
195
|
: await LibInfo.fromExecutor(this as unknown as LibExecutor, {
|
|
134
196
|
refresh,
|
|
135
197
|
});
|
|
198
|
+
scanInfo.orderLibDeps();
|
|
136
199
|
//* Locked: `writeLib` rewrites dependency-lib barrels that other dev servers regenerate and watch too.
|
|
137
200
|
if (write)
|
|
138
201
|
await CodegenLock.run(this.workspace.workspaceRoot, `scan:${this.name}`, async () => {
|
|
139
202
|
await Promise.all(this.#getScanTemplateTasks(scanInfo));
|
|
140
203
|
await this.writeJson(`akan.${this.type}.json`, scanInfo.getScanResult());
|
|
141
204
|
await this.#updateDependencies(scanInfo);
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
205
|
+
const libInfos = writeLib ? [...scanInfo.getLibInfos().values()] : [];
|
|
206
|
+
await Promise.all(libInfos.flatMap((libInfo) => libInfo.exec.#getScanTemplateTasks(libInfo)));
|
|
207
|
+
//? A piece is shaped by each scope's generated `lib/cnst.ts`, which a new checkout has only once the above ran.
|
|
208
|
+
await Promise.all([
|
|
209
|
+
this.#syncClientPieces(scanInfo, this),
|
|
210
|
+
...libInfos.map((libInfo) => libInfo.exec.#syncClientPieces(libInfo, this)),
|
|
211
|
+
]);
|
|
146
212
|
await this.syncAgentsIndex(scanInfo);
|
|
147
213
|
});
|
|
148
214
|
this.#scanInfo = scanInfo;
|
|
@@ -8,12 +8,15 @@ import type { BaseDevEnv, TsConfigJson } from "../workspace/types";
|
|
|
8
8
|
import { Executor, execEmoji } from "./executor";
|
|
9
9
|
import { SysExecutor } from "./sysExecutor";
|
|
10
10
|
|
|
11
|
-
//? As Bun's
|
|
11
|
+
//? As Bun's .env loader reads it (1.4.4), which fills process.env too: `#` ends an unquoted value mid-word, `\$` is `$`.
|
|
12
12
|
const parseEnvValue = (value: string) => {
|
|
13
13
|
const [, quote, inner] = value.match(/^(["'`])((?:\\.|(?!\1)[^\\])*)\1/) ?? [];
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
const text = !quote
|
|
15
|
+
? value.replace(/#.*/, "").trim()
|
|
16
|
+
: quote !== '"'
|
|
17
|
+
? inner
|
|
18
|
+
: inner.replace(/\\(.)/g, (pair, char: string) => (char === "n" ? "\n" : char === "r" ? "\r" : pair));
|
|
19
|
+
return text.replaceAll("\\$", "$");
|
|
17
20
|
};
|
|
18
21
|
|
|
19
22
|
export const parseEnvFile = (envPath: string): Record<string, string> => {
|
|
@@ -7,10 +7,20 @@ import {
|
|
|
7
7
|
resolveSsrPageEntriesForApp,
|
|
8
8
|
} from "../artifact/implicitRootLayout";
|
|
9
9
|
import { computeRouteSeedIndex, type RouteSeedIndex } from "../artifact/routeSeedIndex";
|
|
10
|
+
import { StoreBootstrap } from "../artifact/storeBootstrap";
|
|
10
11
|
import type { App } from "../commandDecorators";
|
|
11
|
-
import
|
|
12
|
+
import {
|
|
13
|
+
type RouteRuntimeBuildReport,
|
|
14
|
+
type RouteRuntimeDictionaryFallback,
|
|
15
|
+
RouteRuntimeReport,
|
|
16
|
+
} from "../quality/routeRuntimeReport";
|
|
17
|
+
import { ModelReference } from "../transforms/modelReference";
|
|
18
|
+
import { RouteRuntime } from "../transforms/routeRuntime";
|
|
19
|
+
import type { AskedExports, ClientEntryDiscovery } from "./clientBuildTypes";
|
|
12
20
|
import { GraphClientEntryDiscovery } from "./clientEntryDiscovery";
|
|
21
|
+
import { DictionaryRoutes } from "./dictionaryRoutes";
|
|
13
22
|
import { type BuildRouteClientResult, RouteClientBuilder } from "./routeClientBuilder";
|
|
23
|
+
import { RouteHandoffs } from "./routeHandoffs";
|
|
14
24
|
import { RouteModulePreloads, type RuntimeChunks } from "./routeModulePreloads";
|
|
15
25
|
import { RoutesManifestArtifactSerializer } from "./routesManifestArtifactSerializer";
|
|
16
26
|
|
|
@@ -18,6 +28,9 @@ export interface BuildAllRoutesResult {
|
|
|
18
28
|
manifest: RoutesManifest;
|
|
19
29
|
manifestPath: string;
|
|
20
30
|
seedIndex: RouteSeedIndex;
|
|
31
|
+
/** A production build: the dictionary groups each route can show; a route left out loads every group. */
|
|
32
|
+
dictionaryRoutes?: Map<string, string[]>;
|
|
33
|
+
runtimeReport?: RouteRuntimeBuildReport;
|
|
21
34
|
}
|
|
22
35
|
|
|
23
36
|
export class AllRoutesBuilder {
|
|
@@ -32,6 +45,9 @@ export class AllRoutesBuilder {
|
|
|
32
45
|
#knownSet = new Set<string>();
|
|
33
46
|
#routeIds: string[] = [];
|
|
34
47
|
#ssrEntriesByRoute = new Map<string, string[]>();
|
|
48
|
+
#entriesByRoute = new Map<string, string[]>();
|
|
49
|
+
#askedByRoute = new Map<string, AskedExports>();
|
|
50
|
+
#serverModulesByRoute = new Map<string, string[]>();
|
|
35
51
|
#externalsByChunkUrl: Record<string, string[]> = {};
|
|
36
52
|
#discovery: ClientEntryDiscovery | null = null;
|
|
37
53
|
|
|
@@ -46,9 +62,12 @@ export class AllRoutesBuilder {
|
|
|
46
62
|
const pageEntries = await resolveSsrPageEntriesForApp(this.#app, pageKeys);
|
|
47
63
|
const seedIndex = computeRouteSeedIndex(pageEntries);
|
|
48
64
|
this.#app.verbose(`[build-all] discovered ${seedIndex.entries.length} routes`);
|
|
49
|
-
const discovery = await GraphClientEntryDiscovery.create(this.#app);
|
|
65
|
+
const discovery = await GraphClientEntryDiscovery.create(this.#app, { byExport: this.#command === "build" });
|
|
50
66
|
this.#discovery = discovery;
|
|
51
|
-
const importsAs = await this.#ssrImportsAs(discovery, pageEntries);
|
|
67
|
+
const { importsAs, rendering } = await this.#ssrImportsAs(discovery, pageEntries);
|
|
68
|
+
const handoffs = await this.#readHandoffs();
|
|
69
|
+
const dictionary = this.#command === "build";
|
|
70
|
+
const unread = new Map<string, string[]>();
|
|
52
71
|
|
|
53
72
|
// Every route's entries go into one Bun.build: chunk splitting only dedupes within a single build.
|
|
54
73
|
const allEntries = new Set<string>();
|
|
@@ -56,13 +75,34 @@ export class AllRoutesBuilder {
|
|
|
56
75
|
const seeds = Array.from(new Set([...seedIndex.globalLayoutFiles, ...entry.seeds]));
|
|
57
76
|
const routeEntries = await discovery.discover(seeds);
|
|
58
77
|
for (const discovered of routeEntries) allEntries.add(discovered);
|
|
59
|
-
|
|
78
|
+
const serverModules = dictionary ? await discovery.serverModules(seeds, { importsAs }) : undefined;
|
|
79
|
+
const asked = await discovery.discoverAsked(seeds, { importsAs, serverModules });
|
|
80
|
+
const ssrEntries = [...asked.keys()].sort();
|
|
81
|
+
this.#askedByRoute.set(entry.routeId, asked);
|
|
82
|
+
if (serverModules) this.#serverModulesByRoute.set(entry.routeId, serverModules);
|
|
83
|
+
const handed = handoffs
|
|
84
|
+
? await handoffs.read(await discovery.serverModules(seeds, { importsAs: rendering }))
|
|
85
|
+
: undefined;
|
|
86
|
+
const loaded = [...new Set([...ssrEntries, ...(handed?.referenceFiles ?? [])])].sort();
|
|
87
|
+
this.#ssrEntriesByRoute.set(entry.routeId, loaded);
|
|
88
|
+
const besidesReferences = handed ? routeEntries.filter((file) => !ModelReference.isFile(file)) : routeEntries;
|
|
89
|
+
this.#entriesByRoute.set(entry.routeId, [...new Set([...besidesReferences, ...loaded])]);
|
|
90
|
+
if (handed?.unread) {
|
|
91
|
+
const pinned = `${handed.unread.file} (${handed.unread.why})`;
|
|
92
|
+
unread.set(pinned, [...(unread.get(pinned) ?? []), entry.routeId]);
|
|
93
|
+
}
|
|
60
94
|
this.#routeIds.push(entry.routeId);
|
|
61
95
|
}
|
|
96
|
+
for (const [pinned, routeIds] of unread)
|
|
97
|
+
this.#app.logger.warn(
|
|
98
|
+
`[client-runtime] ${routeIds.length} route(s) count every model's runtime in the route table: what ${pinned} hands to client components cannot be read. Routes: ${routeIds.join(", ")}`,
|
|
99
|
+
);
|
|
62
100
|
this.#app.verbose(`[build-all] ${allEntries.size} client entries across ${this.#routeIds.length} routes`);
|
|
63
101
|
|
|
64
102
|
const delta = await this.#buildEntries([...allEntries]);
|
|
65
103
|
this.#mergeDelta(delta);
|
|
104
|
+
const dictionaryRoutes =
|
|
105
|
+
dictionary && delta.clientGraph ? await this.#readDictionaryRoutes(delta.clientGraph) : null;
|
|
66
106
|
this.#merged.knownEntries = Array.from(this.#knownSet);
|
|
67
107
|
this.#externalsByChunkUrl = delta.externalsByChunkUrl ?? {};
|
|
68
108
|
|
|
@@ -75,24 +115,73 @@ export class AllRoutesBuilder {
|
|
|
75
115
|
`[build-all] wrote ${manifestPath} routes=${this.#routeIds.length} entries=${this.#merged.knownEntries.length}`,
|
|
76
116
|
);
|
|
77
117
|
|
|
78
|
-
return {
|
|
118
|
+
return {
|
|
119
|
+
manifest,
|
|
120
|
+
manifestPath,
|
|
121
|
+
seedIndex,
|
|
122
|
+
...(dictionaryRoutes ? { dictionaryRoutes } : {}),
|
|
123
|
+
...(delta.runtimeReport ? { runtimeReport: delta.runtimeReport } : {}),
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
async #readDictionaryRoutes(importsByModule: NonNullable<BuildRouteClientResult["clientGraph"]>) {
|
|
128
|
+
const { workspaceRoot } = this.#app.workspace;
|
|
129
|
+
const reader = await DictionaryRoutes.forApp(workspaceRoot, `apps/${this.#app.name}`, { importsByModule });
|
|
130
|
+
const groupsByRoute = new Map<string, string[]>();
|
|
131
|
+
const whole = new Map<string, RouteRuntimeDictionaryFallback>();
|
|
132
|
+
for (const routeId of this.#routeIds) {
|
|
133
|
+
const entries = this.#entriesByRoute.get(routeId) ?? [];
|
|
134
|
+
const read = reader.read({ entries, serverModules: this.#serverModulesByRoute.get(routeId) });
|
|
135
|
+
if (!read.whole) groupsByRoute.set(routeId, read.groups);
|
|
136
|
+
else {
|
|
137
|
+
const pinned = DictionaryRoutes.pinned(read.whole);
|
|
138
|
+
const known = whole.get(pinned) ?? { ...read.whole, routes: [] };
|
|
139
|
+
whole.set(pinned, { ...known, routes: [...known.routes, routeId] });
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
for (const [pinned, { routes, line: key }] of whole) {
|
|
143
|
+
const line = `[dictionary] ${routes.length} route(s) load the whole page dictionary: ${pinned}. Routes: ${routes.join(", ")}`;
|
|
144
|
+
if (key !== undefined) this.#app.logger.warn(line);
|
|
145
|
+
else this.#app.verbose(line);
|
|
146
|
+
}
|
|
147
|
+
await RouteRuntimeReport.addDictionary(this.#app.cwdPath, [...whole.values()]);
|
|
148
|
+
return groupsByRoute;
|
|
79
149
|
}
|
|
80
150
|
|
|
81
151
|
async #ssrImportsAs(discovery: GraphClientEntryDiscovery, pageEntries: PageEntry[]) {
|
|
82
152
|
const { specifier, ssrShell, importsNoSsrPageRenders } = ROOT_LAYOUT_SYSTEM;
|
|
83
153
|
const importsAs = new Map<string, ReadonlyMap<string, string | null>>();
|
|
84
|
-
|
|
154
|
+
//? The root layout registers every model's reference; a route loads only those its own server modules hand over.
|
|
155
|
+
const toShell = new Map<string, string | null>([
|
|
156
|
+
[specifier, ssrShell],
|
|
157
|
+
[ModelReference.registrySpecifier(this.#app.name), null],
|
|
158
|
+
]);
|
|
85
159
|
for (const { key, moduleAbsPath } of pageEntries)
|
|
86
160
|
if (isImplicitRootLayoutKey(key)) importsAs.set(path.resolve(moduleAbsPath), toShell);
|
|
87
161
|
const system = await discovery.resolveImport(specifier, this.#app.cwdPath);
|
|
88
162
|
if (system) importsAs.set(system, new Map(importsNoSsrPageRenders.map((spec) => [spec, null])));
|
|
89
|
-
|
|
163
|
+
//? The root layout also imports every store so the server holds them; no route's own render runs through one.
|
|
164
|
+
const stores = StoreBootstrap.serverSpecifiers(this.#app.name).map((spec) => [spec, null] as const);
|
|
165
|
+
const rendering = new Map(importsAs);
|
|
166
|
+
for (const { key, moduleAbsPath } of pageEntries)
|
|
167
|
+
if (isImplicitRootLayoutKey(key)) rendering.set(path.resolve(moduleAbsPath), new Map([...toShell, ...stores]));
|
|
168
|
+
return { importsAs, rendering };
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
async #readHandoffs(): Promise<RouteHandoffs | null> {
|
|
172
|
+
if (this.#command !== "build" || (await StoreBootstrap.scopeOf(this.#app)) !== "page") return null;
|
|
173
|
+
const { workspaceRoot } = this.#app.workspace;
|
|
174
|
+
const scope = `apps/${this.#app.name}`;
|
|
175
|
+
const runtime = await RouteRuntime.read(workspaceRoot, scope).catch(() => null);
|
|
176
|
+
if (!runtime) return null;
|
|
177
|
+
return new RouteHandoffs(workspaceRoot, runtime, await ModelReference.filesOf(workspaceRoot, scope));
|
|
90
178
|
}
|
|
91
179
|
|
|
92
180
|
async writeModulePreloads(runtimeChunks: RuntimeChunks): Promise<RouteModulePreloads> {
|
|
93
181
|
const preloads = new RouteModulePreloads({
|
|
94
182
|
runtimeChunks,
|
|
95
183
|
entriesByRoute: this.#ssrEntriesByRoute,
|
|
184
|
+
askedByRoute: this.#askedByRoute,
|
|
96
185
|
clientManifest: this.#merged.clientManifest,
|
|
97
186
|
externalsByChunkUrl: this.#externalsByChunkUrl,
|
|
98
187
|
workspaceRoot: this.#app.workspace.workspaceRoot,
|
|
@@ -133,6 +222,9 @@ export class AllRoutesBuilder {
|
|
|
133
222
|
knownEntries: this.#knownSet,
|
|
134
223
|
discovery: this.#discovery,
|
|
135
224
|
command: this.#command,
|
|
225
|
+
entriesByRoute: this.#entriesByRoute,
|
|
226
|
+
sizedEntriesByRoute: this.#ssrEntriesByRoute,
|
|
227
|
+
askedByRoute: this.#askedByRoute,
|
|
136
228
|
}).build();
|
|
137
229
|
this.#app.verbose(`[build-all] bundled ${delta.newEntries.length} entries (${Date.now() - started}ms)`);
|
|
138
230
|
return delta;
|
|
@@ -232,8 +232,9 @@ export class AutoImportSync {
|
|
|
232
232
|
const parts = rel.split(path.sep).filter(Boolean);
|
|
233
233
|
const [scope, project, facet] = parts;
|
|
234
234
|
if ((scope !== "apps" && scope !== "libs") || !project || !facet) return null;
|
|
235
|
-
//* `lib/__lib/`
|
|
236
|
-
|
|
235
|
+
//* `lib/__lib/` and `lib/__client/` are rewritten by every `akan sync`, so an edit there is discarded;
|
|
236
|
+
//* `lib/__scalar/` is real source.
|
|
237
|
+
if (facet === "lib" && (parts[3] === "__lib" || parts[3] === "__client")) return null;
|
|
237
238
|
const role = roleFor(facet, base);
|
|
238
239
|
if (!role) return null;
|
|
239
240
|
|