@akanjs/devkit 3.3.0-rc.4 → 3.3.0-rc.41

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 (252) hide show
  1. package/CHANGELOG.md +628 -0
  2. package/DEV_RUNTIME_KNOBS.md +1 -1
  3. package/README.ko.md +3 -2
  4. package/README.md +3 -3
  5. package/akanApp/akanApp.host.test.ts +1 -1
  6. package/akanApp/akanApp.host.ts +11 -0
  7. package/akanConfig/akanBin.ts +4 -0
  8. package/akanConfig/akanConfig.test.ts +66 -7
  9. package/akanConfig/akanConfig.ts +53 -204
  10. package/akanConfig/akanWorkers.test.ts +39 -0
  11. package/akanConfig/akanWorkers.ts +32 -0
  12. package/akanConfig/desktopServerConfig.ts +96 -0
  13. package/akanConfig/dockerImage.ts +37 -0
  14. package/akanConfig/nativeKeys.ts +52 -0
  15. package/akanConfig/types.ts +1 -0
  16. package/app/appBin.test.ts +63 -0
  17. package/app/appBin.ts +50 -0
  18. package/app/applicationBuildReporter.test.ts +32 -0
  19. package/app/applicationBuildReporter.ts +4 -0
  20. package/app/applicationBuildRunner.test.ts +275 -0
  21. package/app/applicationBuildRunner.ts +133 -6
  22. package/app/dictionarySizes.ts +91 -0
  23. package/app/routeFilesReport.test.ts +59 -0
  24. package/app/routeFilesReport.ts +46 -0
  25. package/app/routeJsBudget.ts +18 -4
  26. package/artifact/implicitRootLayout.test.ts +19 -0
  27. package/artifact/implicitRootLayout.ts +16 -2
  28. package/artifact/implicitRootLayoutRender.test.tsx +4 -1
  29. package/artifact/storeBootstrap.test.ts +28 -0
  30. package/artifact/storeBootstrap.ts +64 -8
  31. package/biome.base.json +6 -4
  32. package/codeAgent/agent/CodeAgent.ts +36 -16
  33. package/codeAgent/agent/CodeAgentAllowed.ts +35 -0
  34. package/codeAgent/agent/CodeAgentCommandLine.ts +372 -0
  35. package/codeAgent/agent/CodeAgentGate.ts +23 -4
  36. package/codeAgent/agent/CodeAgentRpcHost.ts +1 -1
  37. package/codeAgent/agent/codeAgent.test.ts +62 -0
  38. package/codeAgent/agent/codeAgentCommandLine.test.ts +212 -0
  39. package/codeAgent/agent/codeAgentContract.test.ts +117 -5
  40. package/codeAgent/skills/akan-agent/SKILL.md +8 -1
  41. package/codeAgent/skills/akan-code/SKILL.md +38 -3
  42. package/codeAgent/skills/akan-deps/SKILL.md +3 -2
  43. package/codeAgent/skills/akan-err/SKILL.md +13 -8
  44. package/codeAgent/skills/akan-mcp/SKILL.md +1 -1
  45. package/codeAgent/skills/akan-module/SKILL.md +2 -2
  46. package/codeAgent/skills/akan-page/SKILL.md +31 -20
  47. package/codeAgent/skills/akan-query/SKILL.md +13 -20
  48. package/codeAgent/skills/akan-runtime/SKILL.md +20 -0
  49. package/codeAgent/skills/akan-service/SKILL.md +2 -5
  50. package/codeAgent/skills/akan-transport/SKILL.md +5 -14
  51. package/codeAgent/skills/akan-ui/SKILL.md +2 -5
  52. package/context/akanContext.ts +2 -0
  53. package/docs/apiReference.test.ts +9 -0
  54. package/docs/apiReference.ts +14 -0
  55. package/executors/appExecutor.ts +3 -1
  56. package/executors/clientRuntimeKeyOrder.fixture.json +682 -0
  57. package/executors/clientRuntimeKeys.fixture.json +393 -0
  58. package/executors/clientRuntimeKeys.test.ts +1690 -0
  59. package/executors/executors.test.ts +2 -0
  60. package/executors/sysExecutor.ts +70 -4
  61. package/executors/workspaceExecutor.ts +7 -4
  62. package/frontendBuild/allRoutesBuilder.ts +88 -7
  63. package/frontendBuild/autoImportSync.ts +3 -2
  64. package/frontendBuild/buildRouteClient.test.ts +666 -12
  65. package/frontendBuild/clientBuildTypes.ts +26 -0
  66. package/frontendBuild/clientEntriesBundler.ts +49 -1
  67. package/frontendBuild/clientEntryDiscovery.test.ts +308 -1
  68. package/frontendBuild/clientEntryDiscovery.ts +135 -13
  69. package/frontendBuild/clientEntryGroups.test.ts +77 -0
  70. package/frontendBuild/clientEntryGroups.ts +61 -0
  71. package/frontendBuild/csrDevModuleCompiler.test.ts +86 -0
  72. package/frontendBuild/csrDevModuleCompiler.ts +44 -8
  73. package/frontendBuild/csrDevPatcher.ts +33 -7
  74. package/frontendBuild/csrDevTypes.ts +9 -0
  75. package/frontendBuild/devBarrelImports.test.ts +154 -0
  76. package/frontendBuild/devBarrelImports.ts +83 -23
  77. package/frontendBuild/devRegistryBundler.ts +4 -2
  78. package/frontendBuild/devRouteRuntime.test.ts +492 -0
  79. package/frontendBuild/devRouteRuntime.ts +167 -0
  80. package/frontendBuild/dictionaryAssetBuilder.test.ts +324 -0
  81. package/frontendBuild/dictionaryAssetBuilder.ts +165 -16
  82. package/frontendBuild/dictionaryConstants.ts +136 -0
  83. package/frontendBuild/dictionaryPacking.test.ts +142 -0
  84. package/frontendBuild/dictionaryPacking.ts +135 -0
  85. package/frontendBuild/dictionaryRoutes.test.ts +251 -0
  86. package/frontendBuild/dictionaryRoutes.ts +227 -0
  87. package/frontendBuild/pagesBundleBuilder.test.ts +84 -0
  88. package/frontendBuild/pagesBundleBuilder.ts +81 -3
  89. package/frontendBuild/precompressArtifacts.test.ts +22 -0
  90. package/frontendBuild/precompressArtifacts.ts +22 -8
  91. package/frontendBuild/registryMetadataFingerprint.ts +3 -3
  92. package/frontendBuild/renderedEntries.ts +144 -0
  93. package/frontendBuild/routeClientBuilder.ts +405 -43
  94. package/frontendBuild/routeHandoffs.test.ts +155 -0
  95. package/frontendBuild/routeHandoffs.ts +117 -0
  96. package/frontendBuild/routeModulePreloads.test.ts +32 -0
  97. package/frontendBuild/routeModulePreloads.ts +20 -11
  98. package/frontendBuild/routeRuntimeCheck.test.ts +280 -0
  99. package/frontendBuild/routeRuntimeCheck.ts +248 -0
  100. package/frontendBuild/routeRuntimePays.test.ts +143 -0
  101. package/frontendBuild/routeRuntimePays.ts +117 -0
  102. package/frontendBuild/rscServerRendererGuard.test.ts +60 -0
  103. package/frontendBuild/rscServerRendererGuard.ts +68 -0
  104. package/frontendBuild/ssrBaseArtifactBuilder.ts +24 -34
  105. package/frontendBuild/ssrDevBundler.test.ts +150 -1
  106. package/frontendBuild/ssrDevBundler.ts +66 -11
  107. package/frontendBuild/vendorFileImports.test.ts +254 -0
  108. package/frontendBuild/vendorFileImports.ts +163 -0
  109. package/frontendBuild/vendorNarrowing.ts +28 -0
  110. package/frontendBuild/vendorSpecifiers.ts +2 -0
  111. package/incrementalBuilder/buildBatch.proc.ts +9 -9
  112. package/incrementalBuilder/buildBatchProtocol.ts +1 -1
  113. package/incrementalBuilder/builderBoot.ts +5 -5
  114. package/incrementalBuilder/builderGraphPayloads.ts +4 -4
  115. package/incrementalBuilder/builderLanes.ts +2 -2
  116. package/incrementalBuilder/builderWatch.ts +8 -8
  117. package/incrementalBuilder/csrRegistry.ts +4 -4
  118. package/incrementalBuilder/incrementalBuilder.proc.test.ts +79 -0
  119. package/incrementalBuilder/incrementalBuilder.proc.ts +27 -8
  120. package/incrementalBuilder/ssrRegistry.ts +6 -6
  121. package/index.ts +1 -1
  122. package/integration/renderAdmissionSoak.test.ts +99 -0
  123. package/integration/renderAdmissionSoak.ts +609 -0
  124. package/lint/__fixtures__/no-arbitrary-color/every-color-function/bad.tsx +11 -0
  125. package/lint/__fixtures__/no-arbitrary-color/every-color-function/good.tsx +2 -0
  126. package/lint/__fixtures__/no-daisyui-legacy-class/every-class/bad.tsx +34 -0
  127. package/lint/__fixtures__/no-daisyui-legacy-class/every-class/good.tsx +2 -0
  128. package/lint/__fixtures__/no-inline-color/every-color-function/bad.tsx +10 -0
  129. package/lint/__fixtures__/no-inline-color/every-color-function/good.tsx +2 -0
  130. package/lint/__fixtures__/no-raw-palette-class/every-palette/bad.tsx +22 -0
  131. package/lint/__fixtures__/no-raw-palette-class/every-palette/good.tsx +2 -0
  132. package/lint/biomeBase.test.ts +23 -3
  133. package/lint/biomeCheck.test.ts +145 -0
  134. package/lint/biomeCheck.ts +131 -0
  135. package/lint/no-arbitrary-color.grit +5 -0
  136. package/lint/no-conditional-st-hook.grit +5 -1
  137. package/lint/no-daisyui-legacy-class.grit +8 -0
  138. package/lint/no-document-cookie.grit +3 -0
  139. package/lint/no-inline-color.grit +10 -2
  140. package/lint/no-oversized-list-limit.grit +2 -0
  141. package/lint/no-raw-palette-class.grit +7 -0
  142. package/lint/no-unpublished-form-setter.grit +2 -0
  143. package/lint/no-web-only-api-outside-webkit.grit +5 -0
  144. package/lint/no-web-storage.grit +3 -0
  145. package/lint/withheldEnvFile.ts +17 -0
  146. package/mobile/desktopBin.ts +2 -2
  147. package/mobile/desktopServerStage.ts +1 -0
  148. package/mobile/nativeApp.test.ts +7 -5
  149. package/mobile/nativeApp.ts +2 -2
  150. package/mobile/nativeConfig.test.ts +96 -1
  151. package/mobile/nativeConfig.ts +46 -12
  152. package/mobile/serverBundleSecrets.ts +43 -0
  153. package/package.json +15 -169
  154. package/packageExports.test.ts +38 -24
  155. package/quality/dictionaryKeys.test.ts +356 -0
  156. package/quality/dictionaryKeys.ts +488 -0
  157. package/quality/objectImportReport.test.ts +36 -0
  158. package/quality/objectImportReport.ts +105 -0
  159. package/quality/qualityScanner.ts +1 -1
  160. package/quality/routeRuntimeReport.test.ts +91 -0
  161. package/quality/routeRuntimeReport.ts +121 -0
  162. package/quality/runtimeConstantFacts.ts +71 -0
  163. package/quality/runtimeConstantGraph.ts +123 -0
  164. package/quality/runtimeConstantReads.ts +116 -0
  165. package/quality/runtimeImports.test.ts +190 -0
  166. package/quality/runtimeImports.ts +233 -0
  167. package/quality/runtimeKeyNames.ts +46 -0
  168. package/quality/runtimeLexicalScope.ts +132 -0
  169. package/quality/runtimeMarkerReach.test.ts +84 -0
  170. package/quality/runtimeMarkerReach.ts +255 -0
  171. package/quality/runtimeModuleFacts.ts +290 -0
  172. package/quality/runtimeNameTable.test.ts +172 -0
  173. package/quality/runtimeNameTable.ts +477 -0
  174. package/quality/runtimeScopeReport.test.ts +123 -0
  175. package/quality/runtimeScopeReport.ts +167 -0
  176. package/quality/runtimeSliceKey.ts +269 -0
  177. package/quality/runtimeSyntax.ts +133 -0
  178. package/quality/runtimeTable.fixture.ts +189 -0
  179. package/quality/runtimeUse.test.ts +737 -0
  180. package/quality/runtimeUse.ts +696 -0
  181. package/quality/runtimeUseReadable.test.ts +393 -0
  182. package/quality/ssrScanner.test.ts +13 -0
  183. package/quality/ssrScanner.ts +1 -1
  184. package/quality/translatorBindings.ts +187 -0
  185. package/test/secretEnvFixture.ts +134 -0
  186. package/test/testHelpers.ts +11 -0
  187. package/transforms/barrelAnalyzer.ts +26 -4
  188. package/transforms/barrelImportsPlugin.ts +121 -32
  189. package/transforms/exportReach.test.ts +162 -0
  190. package/transforms/exportReach.ts +308 -0
  191. package/transforms/frameworkObjects.fixture.tsx +58 -0
  192. package/transforms/frameworkObjects.test.ts +54 -0
  193. package/transforms/modelReference.test.ts +196 -0
  194. package/transforms/modelReference.ts +39 -0
  195. package/transforms/moduleParts.test.ts +225 -0
  196. package/transforms/moduleParts.ts +418 -0
  197. package/transforms/objectImportEdits.ts +150 -0
  198. package/transforms/objectMemberImports.test.ts +629 -0
  199. package/transforms/objectMemberImports.ts +571 -0
  200. package/transforms/objectMemberLookup.ts +150 -0
  201. package/transforms/objectModule.test.ts +307 -0
  202. package/transforms/objectModule.ts +482 -0
  203. package/transforms/objectModuleAnalyzer.ts +104 -0
  204. package/transforms/partImports.test.ts +76 -0
  205. package/transforms/partImports.ts +110 -0
  206. package/transforms/partModules.test.ts +187 -0
  207. package/transforms/partModules.ts +90 -0
  208. package/transforms/partPurity.ts +124 -0
  209. package/transforms/reactIconImports.test.ts +231 -0
  210. package/transforms/reactIconImports.ts +325 -0
  211. package/transforms/routeConstants.ts +122 -0
  212. package/transforms/routeRuntime.test.ts +835 -0
  213. package/transforms/routeRuntime.ts +703 -0
  214. package/transforms/routeRuntimeEdits.ts +92 -0
  215. package/transforms/routeRuntimeGraph.ts +66 -0
  216. package/transforms/routeRuntimePlan.ts +244 -0
  217. package/transforms/secretEnvDeclaration.test.ts +208 -0
  218. package/transforms/secretEnvDeclaration.ts +213 -0
  219. package/transforms/secretEnvFile.test.ts +117 -0
  220. package/transforms/secretEnvFile.ts +113 -0
  221. package/transforms/secretEnvName.test.ts +54 -0
  222. package/transforms/secretEnvName.ts +29 -0
  223. package/transforms/secretEnvSource.test.ts +148 -0
  224. package/transforms/secretEnvSource.ts +166 -0
  225. package/transforms/serverEnvEvaluationError.ts +11 -0
  226. package/transforms/serverEnvPlugin.test.ts +2 -1
  227. package/transforms/serverEnvPlugin.ts +13 -0
  228. package/transforms/serverEnvProfile.test.ts +115 -2
  229. package/transforms/serverEnvProfile.ts +117 -40
  230. package/transforms/serverEnvSecrets.test.ts +292 -0
  231. package/transforms/signalDescriptors.test.ts +280 -0
  232. package/transforms/signalDescriptors.ts +227 -0
  233. package/transforms/thisFreeExports.ts +87 -0
  234. package/transforms/transforms.test.ts +180 -3
  235. package/transforms/tsconfigPackageResolver.test.ts +1 -0
  236. package/tunnel/createTunnel.test.ts +29 -8
  237. package/tunnel/createTunnel.ts +18 -11
  238. package/typecheck/projectTypecheck.test.ts +29 -0
  239. package/typecheck/typeChecker.test.ts +49 -0
  240. package/typecheck/typeChecker.ts +9 -7
  241. package/typecheck/withheldDiagnostics.ts +41 -0
  242. package/util/fileEditor.ts +1 -0
  243. package/util/selectModel.ts +1 -0
  244. package/workflow/executor.ts +6 -2
  245. package/workflow/index.ts +1 -0
  246. package/workflow/plan.ts +36 -7
  247. package/workflow/types.ts +1 -1
  248. package/workflow/uiTarget.ts +50 -0
  249. package/workspace/getRelatedCnsts.ts +7 -0
  250. package/workspace/scanInfo.test.ts +39 -0
  251. package/workspace/scanInfo.ts +48 -5
  252. package/workspace/workspaceLayout.ts +1 -0
@@ -0,0 +1,144 @@
1
+ import path from "node:path";
2
+ import type { ExportReach, ReachedImport } from "../transforms/exportReach";
3
+ import type { DiscoverOptions, ScannedImport } from "./clientBuildTypes";
4
+
5
+ export interface RenderedFile {
6
+ isClientEntry: boolean;
7
+ imports: ScannedImport[];
8
+ /** Null for a module whose exports cannot be read. */
9
+ reach?: ExportReach | null;
10
+ }
11
+
12
+ export interface RenderedGraph {
13
+ fileOf(file: string): Promise<RenderedFile | null>;
14
+ resolve(specifier: string, fromDir: string): Promise<string | null>;
15
+ /** Bumped when a file changed: an answer computed across a bump is not kept. */
16
+ epoch(): number;
17
+ }
18
+
19
+ interface ExportAsk {
20
+ file: string;
21
+ name: string;
22
+ how: "whole" | "always" | "named" | "starred";
23
+ key: string;
24
+ }
25
+
26
+ interface AskAnswer {
27
+ isEntry: boolean;
28
+ whole: boolean;
29
+ next: ExportAsk[];
30
+ }
31
+
32
+ type ImportsAs = NonNullable<DiscoverOptions["importsAs"]>;
33
+
34
+ interface RenderedWalk {
35
+ serverModules: string[];
36
+ within: string[];
37
+ importsAs?: ImportsAs;
38
+ }
39
+
40
+ /**
41
+ * The client entries a route can render. A server module asked for one export gives only what that export's
42
+ * declaration reaches, and every server module the route evaluates gives what its top-level statements reach.
43
+ */
44
+ export class RenderedEntries {
45
+ #graph: RenderedGraph;
46
+ #answers = new Map<string, AskAnswer>();
47
+ //? Keyed by a walk's `importsAs`: an ask's answer under swapped imports holds only for walks swapping the same ones.
48
+ #swappedAnswers = new WeakMap<ImportsAs, Map<string, AskAnswer>>();
49
+
50
+ constructor(graph: RenderedGraph) {
51
+ this.#graph = graph;
52
+ }
53
+
54
+ forget(): void {
55
+ this.#answers.clear();
56
+ this.#swappedAnswers = new WeakMap();
57
+ }
58
+
59
+ async of(seeds: string[], options: RenderedWalk): Promise<string[]> {
60
+ return [...(await this.asked(seeds, options)).keys()].sort();
61
+ }
62
+
63
+ //* The same entries with the export names the route's server modules ask of each: null where one asks for them all.
64
+ async asked(
65
+ seeds: string[],
66
+ { serverModules, within, importsAs }: RenderedWalk,
67
+ ): Promise<Map<string, string[] | null>> {
68
+ const answers = importsAs ? this.#answersUnder(importsAs) : this.#answers;
69
+ const reachable = new Set(within);
70
+ const entries = new Map<string, string[] | null>();
71
+ const seen = new Set<string>();
72
+ const whole = new Set<string>();
73
+ const queue = seeds.map((seed) => RenderedEntries.#ask(path.resolve(seed), "whole"));
74
+ for (const file of serverModules) queue.push(RenderedEntries.#ask(file, "always"));
75
+ for (const ask of queue) {
76
+ if (seen.has(ask.key) || whole.has(ask.file)) continue;
77
+ seen.add(ask.key);
78
+ const answer = answers.get(ask.key) ?? (await this.#answer(ask, answers, importsAs));
79
+ if (answer.isEntry) {
80
+ if (ask.how === "always" || !reachable.has(ask.file)) continue;
81
+ const names = entries.get(ask.file);
82
+ if (ask.how === "whole") entries.set(ask.file, null);
83
+ else if (names === undefined) entries.set(ask.file, [ask.name]);
84
+ else if (names && !names.includes(ask.name)) names.push(ask.name);
85
+ continue;
86
+ }
87
+ if (answer.whole) whole.add(ask.file);
88
+ for (const next of answer.next) if (!seen.has(next.key) && !whole.has(next.file)) queue.push(next);
89
+ }
90
+ return entries;
91
+ }
92
+
93
+ #answersUnder(importsAs: ImportsAs): Map<string, AskAnswer> {
94
+ const answers = this.#swappedAnswers.get(importsAs) ?? new Map<string, AskAnswer>();
95
+ this.#swappedAnswers.set(importsAs, answers);
96
+ return answers;
97
+ }
98
+
99
+ async #answer(ask: ExportAsk, answers: Map<string, AskAnswer>, importsAs?: ImportsAs): Promise<AskAnswer> {
100
+ const epoch = this.#graph.epoch();
101
+ const answer = await this.#answerOf(ask, importsAs);
102
+ if (epoch === this.#graph.epoch()) answers.set(ask.key, answer);
103
+ return answer;
104
+ }
105
+
106
+ async #answerOf(ask: ExportAsk, importsAs?: ImportsAs): Promise<AskAnswer> {
107
+ const facts = await this.#graph.fileOf(ask.file);
108
+ if (!facts) return { isEntry: false, whole: false, next: [] };
109
+ if (facts.isClientEntry) return { isEntry: true, whole: false, next: [] };
110
+ const reached = RenderedEntries.#reachedBy(ask, facts);
111
+ const swaps = importsAs?.get(ask.file);
112
+ const next: ExportAsk[] = [];
113
+ for (const { specifier, names } of reached.imports) {
114
+ const swapped = swaps?.get(specifier);
115
+ const spec = swapped === undefined ? specifier : swapped;
116
+ if (!spec) continue;
117
+ const resolved = await this.#graph.resolve(spec, path.dirname(ask.file));
118
+ if (!resolved) continue;
119
+ const file = path.resolve(resolved);
120
+ if (names === null) next.push(RenderedEntries.#ask(file, "whole"));
121
+ else for (const name of names) next.push(RenderedEntries.#ask(file, reached.starred ? "starred" : "named", name));
122
+ }
123
+ return { isEntry: false, whole: reached.whole ?? false, next };
124
+ }
125
+
126
+ //? A name asked through `export *` that the target does not hold is another target's, so it reaches nothing here.
127
+ static #reachedBy(
128
+ { name, how }: ExportAsk,
129
+ { reach, imports }: RenderedFile,
130
+ ): { imports: ReachedImport[]; whole?: boolean; starred?: boolean } {
131
+ if (!reach) return { imports: imports.map((imported) => ({ specifier: imported.path, names: null })), whole: true };
132
+ if (how === "whole") return { imports: reach.whole(), whole: true };
133
+ if (how === "always") return { imports: reach.always() };
134
+ const reached = reach.of(name);
135
+ if (reached.known) return { imports: reached.imports };
136
+ if (reached.stars.length > 0)
137
+ return { imports: reached.stars.map((specifier) => ({ specifier, names: [name] })), starred: true };
138
+ return how === "starred" ? { imports: [] } : { imports: reach.whole(), whole: true };
139
+ }
140
+
141
+ static #ask(file: string, how: ExportAsk["how"], name = ""): ExportAsk {
142
+ return { file, name, how, key: `${file}\0${how}\0${name}` };
143
+ }
144
+ }