@akanjs/devkit 3.2.0-rc.2 → 3.2.0-rc.20

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 (365) hide show
  1. package/CHANGELOG.md +315 -11
  2. package/DEV_RUNTIME_KNOBS.md +4 -3
  3. package/README.ko.md +3 -2
  4. package/README.md +4 -2
  5. package/akanApp/BackendImportGraph.test.ts +1 -1
  6. package/akanApp/akanApp.host.test.ts +257 -1
  7. package/akanApp/akanApp.host.ts +146 -1223
  8. package/akanApp/akanApp.host.wiring.test.ts +727 -0
  9. package/akanApp/builderGap.ts +68 -0
  10. package/akanApp/builderRequestRelay.test.ts +93 -0
  11. package/akanApp/builderRequestRelay.ts +100 -0
  12. package/akanApp/builderRssRecycler.ts +182 -0
  13. package/akanApp/devBackend.ts +392 -0
  14. package/akanApp/devBuildStatusBoard.ts +128 -0
  15. package/akanApp/devBuilder.ts +196 -0
  16. package/akanApp/devHostPolicy.test.ts +11 -11
  17. package/akanApp/devHostPolicy.ts +2 -4
  18. package/akanApp/devIdleSuspend.test.ts +221 -0
  19. package/akanApp/devIdleSuspend.ts +192 -0
  20. package/akanApp/devIdleSuspend.watcher.test.ts +120 -0
  21. package/akanApp/devRecycler.test.ts +66 -0
  22. package/akanApp/devRecycler.ts +305 -0
  23. package/akanApp/processRss.ts +61 -0
  24. package/akanConfig/akanConfig.test.ts +24 -1
  25. package/akanConfig/akanConfig.ts +10 -10
  26. package/akanConfig/akanWorkspaceConfig.ts +1 -1
  27. package/akanConfig/productionLockfile.ts +1 -1
  28. package/apiReport/apiDeclarationPrinter.ts +120 -0
  29. package/apiReport/apiReport.test.ts +526 -0
  30. package/apiReport/apiReport.ts +232 -0
  31. package/apiReport/apiReportDiff.ts +160 -0
  32. package/apiReport/apiReportPolicy.ts +65 -0
  33. package/apiReport/apiTargets.ts +311 -0
  34. package/apiReport/changesetBump.ts +19 -0
  35. package/{applicationBuildReporter.test.ts → app/applicationBuildReporter.test.ts} +21 -0
  36. package/{applicationBuildReporter.ts → app/applicationBuildReporter.ts} +10 -49
  37. package/{applicationBuildRunner.test.ts → app/applicationBuildRunner.test.ts} +74 -7
  38. package/{applicationBuildRunner.ts → app/applicationBuildRunner.ts} +20 -15
  39. package/{applicationTestPreload.ts → app/applicationTestPreload.ts} +1 -1
  40. package/{routeJsBudget.test.ts → app/routeJsBudget.test.ts} +48 -12
  41. package/{routeJsBudget.ts → app/routeJsBudget.ts} +90 -27
  42. package/{routeSourceValidator.test.ts → app/routeSourceValidator.test.ts} +17 -0
  43. package/{routeSourceValidator.ts → app/routeSourceValidator.ts} +5 -1
  44. package/artifact/implicitRootLayout.test.ts +71 -3
  45. package/artifact/implicitRootLayout.ts +21 -4
  46. package/artifact/implicitRootLayoutRender.test.tsx +297 -0
  47. package/biome.base.json +2 -1
  48. package/cloud/cloudApi.test.ts +1 -1
  49. package/cloud/configLock.test.ts +1 -1
  50. package/cloud/globalConfig.test.ts +1 -1
  51. package/cloud/globalConfig.ts +1 -1
  52. package/cloud/updatePackUpload.test.ts +1 -1
  53. package/codeAgent/agent/AkanCodeEnv.ts +1 -1
  54. package/codeAgent/agent/akanCodePaths.ts +1 -1
  55. package/codeAgent/agent/akanSystemPrompt.ts +1 -1
  56. package/codeAgent/agent/codeAgent.test.ts +1 -1
  57. package/codeAgent/skills/akan-debug/SKILL.md +10 -3
  58. package/codeAgent/skills/akan-err/SKILL.md +7 -0
  59. package/codeAgent/skills/akan-mcp/SKILL.md +10 -1
  60. package/codeAgent/skills/akan-scaffold/SKILL.md +2 -2
  61. package/codeAgent/skills/akan-transport/SKILL.md +2 -0
  62. package/codeAgent/skills/akan-validate/SKILL.md +1 -0
  63. package/codeAgent/tools/AkanCli.ts +1 -1
  64. package/codeAgent/tools/AkanToolPack.ts +1 -1
  65. package/codeAgent/tools/McpClient.ts +28 -6
  66. package/codeAgent/tools/McpToolPack.ts +1 -1
  67. package/codeAgent/tools/akanCodePlugins.test.ts +14 -2
  68. package/commandDecorators/argMeta.ts +4 -0
  69. package/commandDecorators/cliError.ts +72 -0
  70. package/commandDecorators/command.ts +165 -91
  71. package/commandDecorators/commandBuilder.ts +1 -1
  72. package/commandDecorators/commandDecorators.test.ts +191 -16
  73. package/commandDecorators/exitCodeError.ts +6 -7
  74. package/commandDecorators/index.ts +1 -0
  75. package/commandDecorators/targetMeta.ts +1 -0
  76. package/commandDecorators/workspaceVersionCheck.test.ts +1 -1
  77. package/commandDecorators/workspaceVersionCheck.ts +1 -1
  78. package/context/akanContext.ts +576 -0
  79. package/context/akanContextInspection.ts +296 -0
  80. package/{akanMcpContract.test.ts → context/akanMcpContract.test.ts} +1 -1
  81. package/{akanMcpContract.ts → context/akanMcpContract.ts} +33 -263
  82. package/context/akanMcpToolError.ts +16 -0
  83. package/context/doctor/agentGuideCheck.ts +81 -0
  84. package/context/doctor/configLeftoverCheck.ts +35 -0
  85. package/context/doctor/doctorFindings.ts +70 -0
  86. package/context/doctor/generatedFreshness.ts +56 -0
  87. package/context/doctor/moduleShapeCheck.ts +88 -0
  88. package/context/doctor/recipeDuplicateCheck.ts +39 -0
  89. package/context/doctor/recipeIndexCheck.ts +87 -0
  90. package/context/doctor/rootShapeCheck.ts +55 -0
  91. package/context/doctor/workflowScope.ts +97 -0
  92. package/{constantFieldNames.test.ts → context/moduleFieldNames.test.ts} +24 -2
  93. package/context/moduleFieldNames.ts +25 -0
  94. package/{recipeScanner.test.ts → context/recipeScanner.test.ts} +1 -1
  95. package/context/safeRead.ts +9 -0
  96. package/csrE2e/csrE2eHarness.fixture.ts +1 -1
  97. package/devkitUtils.test.ts +39 -5
  98. package/{apiReference.test.ts → docs/apiReference.test.ts} +4 -4
  99. package/{apiReference.ts → docs/apiReference.ts} +2 -2
  100. package/docs/errorCodeReference.test.ts +282 -0
  101. package/docs/errorCodeReference.ts +71 -0
  102. package/docs/errorCodeScan.ts +551 -0
  103. package/{frameworkGraph.test.ts → docs/frameworkGraph.test.ts} +1 -1
  104. package/executors/appExecutor.ts +448 -0
  105. package/executors/commandExecutionError.ts +53 -0
  106. package/executors/executor.ts +527 -0
  107. package/{executors.linkFallback.test.ts → executors/executors.linkFallback.test.ts} +1 -1
  108. package/{executors.test.ts → executors/executors.test.ts} +76 -15
  109. package/executors/index.ts +8 -0
  110. package/executors/libExecutor.ts +23 -0
  111. package/executors/moduleExecutor.ts +18 -0
  112. package/executors/pkgExecutor.ts +129 -0
  113. package/executors/sysExecutor.ts +301 -0
  114. package/executors/workspaceExecutor.ts +277 -0
  115. package/frontendBuild/allRoutesBuilder.test.ts +17 -5
  116. package/frontendBuild/allRoutesBuilder.ts +24 -6
  117. package/frontendBuild/autoImportSync.test.ts +1 -1
  118. package/frontendBuild/autoImportSync.ts +1 -1
  119. package/frontendBuild/buildRouteClient.test.ts +1 -1
  120. package/frontendBuild/bundleDefine.ts +2 -0
  121. package/frontendBuild/clientBuildTypes.ts +5 -2
  122. package/frontendBuild/clientEntriesBundler.test.ts +1 -1
  123. package/frontendBuild/clientEntryDiscovery.test.ts +58 -0
  124. package/frontendBuild/clientEntryDiscovery.ts +25 -6
  125. package/frontendBuild/csrArtifactBuilder.test.ts +1 -1
  126. package/frontendBuild/csrDevArtifactWriter.ts +1 -1
  127. package/frontendBuild/cssCompiler.test.ts +1 -1
  128. package/frontendBuild/devGeneratedIndexSync.test.ts +1 -1
  129. package/frontendBuild/devGeneratedIndexSync.ts +7 -38
  130. package/frontendBuild/dictionaryAssetBuilder.test.ts +1 -1
  131. package/frontendBuild/fontOptimizer.test.ts +1 -1
  132. package/frontendBuild/fontPruner.test.ts +1 -1
  133. package/frontendBuild/frontendBuild.test.ts +3 -3
  134. package/frontendBuild/hmrWatcher.stop.test.ts +63 -0
  135. package/frontendBuild/hmrWatcher.test.ts +1 -1
  136. package/frontendBuild/hmrWatcher.ts +22 -1
  137. package/frontendBuild/mcpAppViewBuilder.test.ts +1 -1
  138. package/frontendBuild/mcpAppViewBuilder.ts +1 -1
  139. package/frontendBuild/nativeCore.test.ts +148 -0
  140. package/frontendBuild/optionalPeers.test.ts +36 -8
  141. package/frontendBuild/pagesBundleBuilder.test.ts +2 -3
  142. package/frontendBuild/pagesBundleBuilder.ts +1 -1
  143. package/frontendBuild/precompressArtifacts.test.ts +1 -1
  144. package/frontendBuild/precompressArtifacts.ts +1 -1
  145. package/frontendBuild/serverGraphFile.ts +1 -1
  146. package/frontendBuild/sourceMtimeIndex.test.ts +1 -1
  147. package/frontendBuild/ssrBaseArtifactBuilder.test.ts +26 -0
  148. package/frontendBuild/ssrBaseArtifactBuilder.ts +23 -19
  149. package/frontendBuild/ssrDevBundler.test.ts +1 -1
  150. package/frontendBuild/vendorImportScanner.test.ts +25 -4
  151. package/frontendBuild/vendorImportScanner.ts +25 -10
  152. package/frontendBuild/vendorNarrowing.test.ts +1 -1
  153. package/frontendBuild/watchRootResolver.test.ts +1 -1
  154. package/{agentAssets.test.ts → guideline/agentAssets.test.ts} +1 -1
  155. package/{agentAssets.ts → guideline/agentAssets.ts} +2 -2
  156. package/{agentsIndex.test.ts → guideline/agentsIndex.test.ts} +2 -2
  157. package/{agentsIndex.ts → guideline/agentsIndex.ts} +13 -10
  158. package/{conventionSet.test.ts → guideline/conventionSet.test.ts} +7 -4
  159. package/{conventionSet.ts → guideline/conventionSet.ts} +1 -1
  160. package/{prompter.ts → guideline/prompter.ts} +2 -3
  161. package/incrementalBuilder/buildBatch.proc.ts +14 -4
  162. package/incrementalBuilder/buildBatchProtocol.ts +2 -0
  163. package/incrementalBuilder/buildBatchRunner.test.ts +108 -1
  164. package/incrementalBuilder/buildBatchRunner.ts +17 -4
  165. package/incrementalBuilder/builderBoot.ts +106 -0
  166. package/incrementalBuilder/builderBuildStatus.ts +23 -0
  167. package/incrementalBuilder/builderChannel.test.ts +1 -1
  168. package/incrementalBuilder/builderChannel.ts +11 -0
  169. package/incrementalBuilder/builderGraphPayloads.ts +3 -3
  170. package/incrementalBuilder/builderLanes.ts +157 -0
  171. package/incrementalBuilder/builderWatch.ts +213 -0
  172. package/incrementalBuilder/csrRegistry.ts +234 -0
  173. package/incrementalBuilder/incrementalBuilder.host.test.ts +30 -1
  174. package/incrementalBuilder/incrementalBuilder.host.ts +10 -22
  175. package/incrementalBuilder/incrementalBuilder.proc.test.ts +93 -2
  176. package/incrementalBuilder/incrementalBuilder.proc.ts +81 -823
  177. package/incrementalBuilder/ssrRegistry.ts +278 -0
  178. package/index.ts +22 -22
  179. package/integration/devStability.integration.test.ts +62 -56
  180. package/integration/devStabilityHarness.test.ts +1 -1
  181. package/lint/__fixtures__/no-import-common-err/bad.tsx +13 -0
  182. package/lint/__fixtures__/no-import-common-err/good.tsx +12 -0
  183. package/{biomeBase.test.ts → lint/biomeBase.test.ts} +1 -1
  184. package/lint/gritRules.test.ts +1 -1
  185. package/{linter.test.ts → lint/linter.test.ts} +1 -1
  186. package/lint/no-import-common-err.grit +31 -0
  187. package/lint/no-init-fetch-in-client.grit +1 -1
  188. package/lint/no-web-only-api-outside-webkit.grit +3 -3
  189. package/mobile/desktopBin.test.ts +1 -1
  190. package/mobile/desktopRelease.test.ts +1 -1
  191. package/mobile/desktopServerStage.test.ts +2 -2
  192. package/mobile/desktopServerStage.ts +1 -1
  193. package/mobile/nativeApi.test.ts +1 -1
  194. package/mobile/nativeApp.test.ts +1 -1
  195. package/mobile/nativeConfig.test.ts +1 -1
  196. package/mobile/nativePluginFolders.test.ts +1 -1
  197. package/mobile/nativePublicEnv.test.ts +1 -1
  198. package/mobile/nativeWebDir.test.ts +1 -1
  199. package/mobile/serverBundleSecrets.test.ts +1 -1
  200. package/mobile/tarWriter.test.ts +1 -1
  201. package/mobile/updatePackFolder.test.ts +1 -1
  202. package/package.json +167 -3
  203. package/packageExports.test.ts +20 -2
  204. package/piDependencyPins.test.ts +1 -1
  205. package/pipeline/PipelineDefinition.ts +1 -1
  206. package/platformTest/IdleWatchedProcess.test.ts +1 -1
  207. package/platformTest/PlatformTestRun.test.ts +1 -1
  208. package/platformTest/TestSnapshot.test.ts +1 -1
  209. package/preview/PreviewView.ts +32 -11
  210. package/preview/previewView.test.ts +76 -9
  211. package/{abstractDoc.test.ts → quality/abstractDoc.test.ts} +2 -2
  212. package/{abstractDoc.ts → quality/abstractDoc.ts} +1 -1
  213. package/quality/bareErrorScanner.ts +126 -0
  214. package/{maintainabilityBaseline.test.ts → quality/maintainabilityBaseline.test.ts} +73 -0
  215. package/{maintainabilityBaseline.ts → quality/maintainabilityBaseline.ts} +97 -9
  216. package/{maintainabilityContract.test.ts → quality/maintainabilityContract.test.ts} +383 -2
  217. package/{maintainabilityContract.ts → quality/maintainabilityContract.ts} +151 -29
  218. package/{maintainabilityExceptionScanner.test.ts → quality/maintainabilityExceptionScanner.test.ts} +15 -1
  219. package/{maintainabilityExceptionScanner.ts → quality/maintainabilityExceptionScanner.ts} +5 -1
  220. package/{maintainabilityLimits.ts → quality/maintainabilityLimits.ts} +12 -0
  221. package/{maintainabilityReport.ts → quality/maintainabilityReport.ts} +20 -3
  222. package/{qualityScanner.test.ts → quality/qualityScanner.test.ts} +1 -1
  223. package/{qualityScanner.ts → quality/qualityScanner.ts} +8 -8
  224. package/{storeAccessScanner.ts → quality/storeAccessScanner.ts} +15 -2
  225. package/{subspace.test.ts → subspace/subspace.test.ts} +9 -3
  226. package/{subspace.ts → subspace/subspace.ts} +5 -5
  227. package/{subspaceClone.ts → subspace/subspaceClone.ts} +8 -8
  228. package/{subspaceConfig.ts → subspace/subspaceConfig.ts} +5 -1
  229. package/{testHelpers.ts → test/testHelpers.ts} +37 -1
  230. package/transforms/barrelAnalyzer.ts +26 -8
  231. package/transforms/browserDirnamePlugin.test.ts +1 -1
  232. package/transforms/externalizeFrameworkPlugin.test.ts +1 -1
  233. package/transforms/mcpAppPageTrimmer.test.ts +1 -1
  234. package/transforms/pureLazyMarker.test.ts +1 -1
  235. package/transforms/serverEnvPlugin.test.ts +1 -1
  236. package/transforms/serverEnvProfile.test.ts +1 -1
  237. package/transforms/sideEffectImportOrder.test.ts +1 -1
  238. package/transforms/transforms.test.ts +29 -2
  239. package/transforms/tsconfigPackageResolver.test.ts +1 -1
  240. package/{createTunnel.test.ts → tunnel/createTunnel.test.ts} +1 -1
  241. package/{createTunnel.ts → tunnel/createTunnel.ts} +2 -2
  242. package/{sshHostKeys.ts → tunnel/sshHostKeys.ts} +2 -2
  243. package/typecheck/projectTypecheck.test.ts +1 -1
  244. package/typecheck/projectTypecheck.ts +6 -2
  245. package/{typeChecker.test.ts → typecheck/typeChecker.test.ts} +1 -1
  246. package/{typeChecker.ts → typecheck/typeChecker.ts} +1 -1
  247. package/typecheck/typecheck.proc.ts +4 -3
  248. package/typecheck/typecheckFailure.ts +7 -2
  249. package/util/errorReport.ts +66 -0
  250. package/{jsonFormatter.test.ts → util/jsonFormatter.test.ts} +1 -1
  251. package/workflow/artifacts.ts +8 -7
  252. package/workflow/constantSource.ts +187 -0
  253. package/workflow/dictionarySource.ts +184 -0
  254. package/workflow/executor.ts +6 -9
  255. package/workflow/fieldExpression.ts +153 -0
  256. package/workflow/fieldLabel.ts +61 -0
  257. package/workflow/fieldOrder.ts +117 -0
  258. package/workflow/fieldType.ts +93 -0
  259. package/workflow/guardCatalog.test.ts +1 -1
  260. package/workflow/index.ts +2 -0
  261. package/workflow/keyRename.ts +1 -1
  262. package/workflow/moduleIndex.test.ts +2 -2
  263. package/workflow/moduleIndex.ts +2 -2
  264. package/workflow/modulePaths.ts +27 -0
  265. package/workflow/mutationScaffold.ts +7 -15
  266. package/workflow/mutationSource.ts +2 -1
  267. package/workflow/plainName.ts +28 -0
  268. package/workflow/plan.ts +15 -9
  269. package/workflow/primitiveReport.ts +78 -0
  270. package/workflow/rolloutGate.test.ts +1 -1
  271. package/workflow/rolloutGate.ts +1 -1
  272. package/workflow/serviceSource.ts +33 -0
  273. package/workflow/signalSource.ts +96 -0
  274. package/workflow/source.ts +50 -1105
  275. package/workflow/sourceAst.ts +30 -0
  276. package/workflow/sourceImports.ts +105 -0
  277. package/workflow/sourceText.ts +13 -0
  278. package/workflow/templateSource.ts +30 -0
  279. package/workflow/testSource.ts +31 -0
  280. package/workflow/types.ts +1 -1
  281. package/workflow/uiPolicy.ts +1 -1
  282. package/{appSelectionMemory.ts → workspace/appSelectionMemory.ts} +1 -1
  283. package/{codegenLock.test.ts → workspace/codegenLock.test.ts} +1 -1
  284. package/{dependencyScanner.test.ts → workspace/dependencyScanner.test.ts} +1 -1
  285. package/{dependencyScanner.ts → workspace/dependencyScanner.ts} +2 -2
  286. package/{envSeed.test.ts → workspace/envSeed.test.ts} +2 -2
  287. package/{envSeed.ts → workspace/envSeed.ts} +1 -1
  288. package/{libSource.test.ts → workspace/libSource.test.ts} +2 -2
  289. package/{libSource.ts → workspace/libSource.ts} +1 -1
  290. package/{scanInfo.ts → workspace/scanInfo.ts} +21 -10
  291. package/{slicePlanner.test.ts → workspace/slicePlanner.test.ts} +2 -2
  292. package/{slicePlanner.ts → workspace/slicePlanner.ts} +1 -1
  293. package/{workspaceGraph.test.ts → workspace/workspaceGraph.test.ts} +85 -1
  294. package/{workspaceGraph.ts → workspace/workspaceGraph.ts} +41 -6
  295. package/{workspaceLayout.test.ts → workspace/workspaceLayout.test.ts} +1 -1
  296. package/{workspaceLayout.ts → workspace/workspaceLayout.ts} +3 -1
  297. package/akanContext.ts +0 -1084
  298. package/constantFieldNames.ts +0 -18
  299. package/executors.ts +0 -1749
  300. /package/{recipeScanner.ts → context/recipeScanner.ts} +0 -0
  301. /package/{declarationReader.ts → docs/declarationReader.ts} +0 -0
  302. /package/{frameworkGraph.ts → docs/frameworkGraph.ts} +0 -0
  303. /package/{biomeBase.ts → lint/biomeBase.ts} +0 -0
  304. /package/{linter.ts → lint/linter.ts} +0 -0
  305. /package/{commentDensityScanner.test.ts → quality/commentDensityScanner.test.ts} +0 -0
  306. /package/{commentDensityScanner.ts → quality/commentDensityScanner.ts} +0 -0
  307. /package/{componentSizeScanner.test.ts → quality/componentSizeScanner.test.ts} +0 -0
  308. /package/{componentSizeScanner.ts → quality/componentSizeScanner.ts} +0 -0
  309. /package/{componentWriteChainScanner.test.ts → quality/componentWriteChainScanner.test.ts} +0 -0
  310. /package/{componentWriteChainScanner.ts → quality/componentWriteChainScanner.ts} +0 -0
  311. /package/{deprecatedCommentScanner.test.ts → quality/deprecatedCommentScanner.test.ts} +0 -0
  312. /package/{deprecatedCommentScanner.ts → quality/deprecatedCommentScanner.ts} +0 -0
  313. /package/{endpointReach.test.ts → quality/endpointReach.test.ts} +0 -0
  314. /package/{endpointReach.ts → quality/endpointReach.ts} +0 -0
  315. /package/{formSetterScanner.test.ts → quality/formSetterScanner.test.ts} +0 -0
  316. /package/{formSetterScanner.ts → quality/formSetterScanner.ts} +0 -0
  317. /package/{kindBranchScanner.test.ts → quality/kindBranchScanner.test.ts} +0 -0
  318. /package/{kindBranchScanner.ts → quality/kindBranchScanner.ts} +0 -0
  319. /package/{maintainabilityReport.test.ts → quality/maintainabilityReport.test.ts} +0 -0
  320. /package/{renderMutationScanner.test.ts → quality/renderMutationScanner.test.ts} +0 -0
  321. /package/{renderMutationScanner.ts → quality/renderMutationScanner.ts} +0 -0
  322. /package/{serviceLoopCallScanner.test.ts → quality/serviceLoopCallScanner.test.ts} +0 -0
  323. /package/{serviceLoopCallScanner.ts → quality/serviceLoopCallScanner.ts} +0 -0
  324. /package/{signalMutationIndex.test.ts → quality/signalMutationIndex.test.ts} +0 -0
  325. /package/{signalMutationIndex.ts → quality/signalMutationIndex.ts} +0 -0
  326. /package/{sourceComments.test.ts → quality/sourceComments.test.ts} +0 -0
  327. /package/{sourceComments.ts → quality/sourceComments.ts} +0 -0
  328. /package/{ssrScanner.test.ts → quality/ssrScanner.test.ts} +0 -0
  329. /package/{ssrScanner.ts → quality/ssrScanner.ts} +0 -0
  330. /package/{storeAccessScanner.test.ts → quality/storeAccessScanner.test.ts} +0 -0
  331. /package/{storeSource.ts → quality/storeSource.ts} +0 -0
  332. /package/{storeWriteScanner.test.ts → quality/storeWriteScanner.test.ts} +0 -0
  333. /package/{storeWriteScanner.ts → quality/storeWriteScanner.ts} +0 -0
  334. /package/{structureScanner.test.ts → quality/structureScanner.test.ts} +0 -0
  335. /package/{structureScanner.ts → quality/structureScanner.ts} +0 -0
  336. /package/{testOnlyExportScanner.test.ts → quality/testOnlyExportScanner.test.ts} +0 -0
  337. /package/{testOnlyExportScanner.ts → quality/testOnlyExportScanner.ts} +0 -0
  338. /package/{writePath.test.ts → quality/writePath.test.ts} +0 -0
  339. /package/{writePath.ts → quality/writePath.ts} +0 -0
  340. /package/{writePlacementScanner.test.ts → quality/writePlacementScanner.test.ts} +0 -0
  341. /package/{writePlacementScanner.ts → quality/writePlacementScanner.ts} +0 -0
  342. /package/{writingActionIndex.test.ts → quality/writingActionIndex.test.ts} +0 -0
  343. /package/{writingActionIndex.ts → quality/writingActionIndex.ts} +0 -0
  344. /package/{subspaceReport.ts → subspace/subspaceReport.ts} +0 -0
  345. /package/{sshTunnel.ts → tunnel/sshTunnel.ts} +0 -0
  346. /package/{fileEditor.ts → util/fileEditor.ts} +0 -0
  347. /package/{fileSys.test.ts → util/fileSys.test.ts} +0 -0
  348. /package/{fileSys.ts → util/fileSys.ts} +0 -0
  349. /package/{jsonFormatter.ts → util/jsonFormatter.ts} +0 -0
  350. /package/{selectModel.ts → util/selectModel.ts} +0 -0
  351. /package/{semver.test.ts → util/semver.test.ts} +0 -0
  352. /package/{semver.ts → util/semver.ts} +0 -0
  353. /package/{shellOnlyEnv.test.ts → util/shellOnlyEnv.test.ts} +0 -0
  354. /package/{shellOnlyEnv.ts → util/shellOnlyEnv.ts} +0 -0
  355. /package/{spinner.test.ts → util/spinner.test.ts} +0 -0
  356. /package/{spinner.ts → util/spinner.ts} +0 -0
  357. /package/{stripAnsi.ts → util/stripAnsi.ts} +0 -0
  358. /package/{codegenLock.ts → workspace/codegenLock.ts} +0 -0
  359. /package/{getRelatedCnsts.ts → workspace/getRelatedCnsts.ts} +0 -0
  360. /package/{gitRevision.test.ts → workspace/gitRevision.test.ts} +0 -0
  361. /package/{gitRevision.ts → workspace/gitRevision.ts} +0 -0
  362. /package/{manifestDependencies.ts → workspace/manifestDependencies.ts} +0 -0
  363. /package/{packageExportsMap.ts → workspace/packageExportsMap.ts} +0 -0
  364. /package/{repoIdentity.ts → workspace/repoIdentity.ts} +0 -0
  365. /package/{types.ts → workspace/types.ts} +0 -0
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, test } from "bun:test";
2
2
  import path from "node:path";
3
- import { tempDirs, writeText } from "../testHelpers";
3
+ import { tempDirs, writeText } from "../test/testHelpers";
4
4
  import { CsrArtifactBuilder } from "./csrArtifactBuilder";
5
5
 
6
6
  const makeTempRoot = tempDirs("akan-csr-artifact-");
@@ -11,7 +11,7 @@ import {
11
11
  type CsrDevManifest,
12
12
  csrDevModuleFile,
13
13
  } from "akanjs/server/hmr/csrDevManifest";
14
- import { FileSys } from "../fileSys";
14
+ import { FileSys } from "../util/fileSys";
15
15
  import { CsrDevPaths } from "./csrDevPaths";
16
16
  import type { CsrDevCode, CsrDevCompiledModule, CsrDevGraph } from "./csrDevTypes";
17
17
 
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, test } from "bun:test";
2
2
  import path from "node:path";
3
- import { tempDirs, writeText as write } from "../testHelpers";
3
+ import { tempDirs, writeText as write } from "../test/testHelpers";
4
4
  import { CssCompiler, declaredCustomProperties } from "./cssCompiler";
5
5
 
6
6
  const makeTempRoot = tempDirs("akan-css-compiler-");
@@ -1,7 +1,7 @@
1
1
  import { describe, expect, test } from "bun:test";
2
2
  import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
3
3
  import path from "node:path";
4
- import { tempDirs } from "../testHelpers";
4
+ import { tempDirs } from "../test/testHelpers";
5
5
  import { DevGeneratedIndexSync } from "./devGeneratedIndexSync";
6
6
 
7
7
  const makeTempRoot = tempDirs("akan-generated-index-");
@@ -1,13 +1,9 @@
1
1
  import { mkdir, readdir, readFile, rm, stat } from "node:fs/promises";
2
2
  import path from "node:path";
3
- import { capitalize } from "akanjs/common";
4
- import { FileSys } from "../fileSys";
5
-
6
- const BARREL_FACETS = new Set(["common", "srvkit", "ui", "webkit", "plugin"]);
7
- const FACET_SOURCE_FILE_RE = /\.(ts|tsx)$/;
8
- const FACET_EXCLUDED_FILE_RE = /(^index\.tsx?$|\.d\.ts$|\.(test|spec)\.(ts|tsx)$|\.css$|\.scss$|\.sass$)/;
9
- const FACET_PASCAL_CASE_RE = /^[A-Z][A-Za-z0-9]*$/;
10
- const FACET_CAMEL_CASE_RE = /^[a-z][A-Za-z0-9]*$/;
3
+ import { barrelFacetDirs, capitalize, facetBarrelOf } from "akanjs/common";
4
+ import { FileSys } from "../util/fileSys";
5
+
6
+ const BARREL_FACETS = new Set<string>(barrelFacetDirs);
11
7
  const MODULE_UI_TYPES = ["Template", "Unit", "Util", "View", "Zone"] as const;
12
8
  const SERVICE_UI_TYPES = ["Util", "Zone"] as const;
13
9
  const SCALAR_UI_TYPES = ["Template", "Unit"] as const;
@@ -113,22 +109,11 @@ export class DevGeneratedIndexSync {
113
109
  }
114
110
 
115
111
  async #facetContent(dir: string): Promise<string | null> {
116
- const nameCasePattern = path.basename(dir) === "ui" ? FACET_PASCAL_CASE_RE : FACET_CAMEL_CASE_RE;
117
112
  const entries = await readdir(dir, { withFileTypes: true }).catch(() => null);
118
113
  if (!entries) return null;
119
- const exportNames = entries
120
- .flatMap((entry) => {
121
- const name = entry.name;
122
- if (name.startsWith(".")) return [];
123
- if (entry.isDirectory()) return nameCasePattern.test(name) ? [name] : [];
124
- if (!entry.isFile()) return [];
125
- if (!FACET_SOURCE_FILE_RE.test(name) || FACET_EXCLUDED_FILE_RE.test(name)) return [];
126
- const exportName = name.replace(FACET_SOURCE_FILE_RE, "");
127
- return nameCasePattern.test(exportName) ? [exportName] : [];
128
- })
129
- .sort(compareExportNames);
130
- if (exportNames.length === 0) return "export {};\n";
131
- return `${exportNames.map((name) => `export * from "./${name}";`).join("\n")}\n`;
114
+ const files = entries.filter((entry) => entry.isFile()).map((entry) => entry.name);
115
+ const dirs = entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name);
116
+ return facetBarrelOf(path.basename(dir), files, dirs);
132
117
  }
133
118
 
134
119
  async #moduleContent(dir: string): Promise<string | null> {
@@ -154,22 +139,6 @@ export class DevGeneratedIndexSync {
154
139
  }
155
140
  }
156
141
 
157
- //? Biome's organizeImports order, or `akan lint` reorders the barrel: A < a < B < b, a digit before a letter, and a
158
- //? run of digits compared by its length first. The facetIndex template sorts the same way.
159
- const letterRankOf = (char: string) => char.toLowerCase().charCodeAt(0) * 2 + (char === char.toLowerCase() ? 1 : 0);
160
- const digitRunAt = (name: string, idx: number) => /^\d+/.exec(name.slice(idx))?.[0] ?? "";
161
- const compareExportNames = (a: string, b: string) => {
162
- for (let idx = 0; idx < a.length && idx < b.length; ) {
163
- const [runA, runB] = [digitRunAt(a, idx), digitRunAt(b, idx)];
164
- if (runA && runB && runA !== runB) return runA.length - runB.length || (runA < runB ? -1 : 1);
165
- if (runA && runB) idx += runA.length;
166
- else if (runA || runB) return runA ? -1 : 1;
167
- else if (a.charAt(idx) !== b.charAt(idx)) return letterRankOf(a.charAt(idx)) - letterRankOf(b.charAt(idx));
168
- else idx++;
169
- }
170
- return a.length - b.length;
171
- };
172
-
173
142
  const exists = async (file: string) =>
174
143
  stat(file)
175
144
  .then(() => true)
@@ -2,7 +2,7 @@ import { describe, expect, test } from "bun:test";
2
2
  import { mkdir, readdir, writeFile } from "node:fs/promises";
3
3
  import path from "node:path";
4
4
  import type { App } from "../commandDecorators";
5
- import { tempDirs } from "../testHelpers";
5
+ import { tempDirs } from "../test/testHelpers";
6
6
  import { DictionaryAssetBuilder } from "./dictionaryAssetBuilder";
7
7
 
8
8
  const tempRoot = tempDirs("akan-devkit-dict-asset-");
@@ -2,7 +2,7 @@ import { describe, expect, test } from "bun:test";
2
2
  import { mkdir, rm, stat, writeFile } from "node:fs/promises";
3
3
  import path from "node:path";
4
4
  import type { App } from "../commandDecorators";
5
- import { tempDirs } from "../testHelpers";
5
+ import { tempDirs } from "../test/testHelpers";
6
6
  import { FontOptimizer } from "./fontOptimizer";
7
7
 
8
8
  const SOURCE_FONT = path.resolve(import.meta.dir, "../../../../libs/shared/public/fonts/Assistant-Regular.woff2");
@@ -2,7 +2,7 @@ import { describe, expect, test } from "bun:test";
2
2
  import { mkdir, rm, writeFile } from "node:fs/promises";
3
3
  import path from "node:path";
4
4
  import type { App } from "../commandDecorators";
5
- import { tempDirs } from "../testHelpers";
5
+ import { tempDirs } from "../test/testHelpers";
6
6
  import { FontPruner } from "./fontPruner";
7
7
 
8
8
  const tempRoot = tempDirs("akan-devkit-font-prune-");
@@ -3,7 +3,7 @@ import { readFile, rm } from "node:fs/promises";
3
3
  import path from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import type { RoutesManifest } from "akanjs/server";
6
- import { tempDirs, writeText as write } from "../testHelpers";
6
+ import { tempDirs, writeText as write } from "../test/testHelpers";
7
7
  import { CsrArtifactBuilder } from "./csrArtifactBuilder";
8
8
  import { CssCompiler, declaredCustomProperties, isIgnoredNodeModuleSource } from "./cssCompiler";
9
9
  import { CssImportResolver } from "./cssImportResolver";
@@ -123,7 +123,7 @@ describe("PagesBundleBuilder", () => {
123
123
  "",
124
124
  "const dictionary = {};",
125
125
  "const pageProto = makePageProto<typeof dict>(dictionary);",
126
- "const fetchProto = FetchClient.build<typeof signal>(cnst, getSerializedSignal(), { Err: pageProto.Err });",
126
+ "const fetchProto = FetchClient.build<typeof signal>(cnst, getSerializedSignal());",
127
127
  'export const runtime = registerClientRuntime({ ...pageProto, ...fetchProto }, { scope: "app" });',
128
128
  "",
129
129
  ].join("\n");
@@ -132,7 +132,7 @@ describe("PagesBundleBuilder", () => {
132
132
 
133
133
  expect(transformed).toContain('import { fetch as serverFetch } from "./sig";');
134
134
  expect(transformed).toContain(
135
- "const fetchProto = FetchClient.build<typeof signal>(cnst, serverFetch.serializedSignal, { Err: pageProto.Err, base: serverFetch });",
135
+ "const fetchProto = FetchClient.build<typeof signal>(cnst, serverFetch.serializedSignal, { base: serverFetch });",
136
136
  );
137
137
  expect(transformed).not.toContain("getSerializedSignal");
138
138
  expect(transformed).not.toContain('with { type: "macro" }');
@@ -0,0 +1,63 @@
1
+ import { describe, expect, mock, test } from "bun:test";
2
+ import path from "node:path";
3
+ import type { Logger } from "akanjs/common";
4
+ import { heldMtimeIndex, saveUntil, tempDirs, writeText } from "../test/testHelpers";
5
+ import type { ChangeBatch } from "./hmrWatcher";
6
+
7
+ const held = heldMtimeIndex();
8
+ mock.module("./sourceMtimeIndex", () => ({ SourceMtimeIndex: held.SourceMtimeIndex }));
9
+
10
+ const { HmrWatcher } = await import("./hmrWatcher");
11
+
12
+ const logger = {
13
+ verbose: () => undefined,
14
+ info: () => undefined,
15
+ warn: () => undefined,
16
+ error: () => undefined,
17
+ } as unknown as Logger;
18
+ const makeRoot = tempDirs("akan-hmr-watcher-stop-");
19
+ const tick = () => new Promise((resolve) => setTimeout(resolve, 0));
20
+
21
+ describe("HmrWatcher stopped while a scan runs", () => {
22
+ test("hands over no batch, though the scan settles with an edit made while it primed", async () => {
23
+ const root = await makeRoot();
24
+ const source = path.join(root, "lib/a.ts");
25
+ await writeText(source, "export const x = 0;\n");
26
+ const batches: ChangeBatch[] = [];
27
+ const watcher = new HmrWatcher({ roots: [root], logger, onBatch: (batch) => void batches.push(batch) });
28
+ const starting = watcher.start();
29
+ expect(await saveUntil(source, () => held.scans.length > 0)).toBe(true);
30
+ watcher.stop();
31
+ held.primes[0].resolve();
32
+ await starting;
33
+ held.scans[0].resolve([]);
34
+ await new Promise((resolve) => setTimeout(resolve, 0));
35
+ expect(batches).toEqual([]);
36
+ }, 15_000);
37
+
38
+ test("close hands back what the scan it interrupted found, though a later scan settles first", async () => {
39
+ held.primes.length = 0;
40
+ held.scans.length = 0;
41
+ const root = await makeRoot();
42
+ const source = path.join(root, "lib/a.ts");
43
+ const config = path.join(root, "akan.config.ts");
44
+ await writeText(source, "export const x = 0;\n");
45
+ const batches: ChangeBatch[] = [];
46
+ const watcher = new HmrWatcher({ roots: [root], logger, onBatch: (batch) => void batches.push(batch) });
47
+ const starting = watcher.start();
48
+ held.primes[0].resolve();
49
+ await starting;
50
+ expect(await saveUntil(source, () => held.scans.length > 0)).toBe(true);
51
+ const closing = watcher.close();
52
+ const settleLaterScans = async () => {
53
+ await tick();
54
+ for (const scan of held.scans.slice(1)) scan.resolve([]);
55
+ await tick();
56
+ };
57
+ await settleLaterScans();
58
+ held.scans[0].resolve([config]);
59
+ await settleLaterScans();
60
+ expect(await closing).toEqual({ files: [config], kinds: new Set(["config"]) });
61
+ expect(batches).toEqual([]);
62
+ }, 15_000);
63
+ });
@@ -2,7 +2,7 @@ import { afterEach, describe, expect, test } from "bun:test";
2
2
  import { chmod, mkdir, writeFile } from "node:fs/promises";
3
3
  import path from "node:path";
4
4
  import type { Logger } from "akanjs/common";
5
- import { tempDirs } from "../testHelpers";
5
+ import { tempDirs } from "../test/testHelpers";
6
6
  import { type ChangeBatch, HmrWatcher } from "./hmrWatcher";
7
7
 
8
8
  // The real Bun watcher, not a fake: the dropped-event behaviour under test only exists there.
@@ -29,6 +29,7 @@ export class HmrWatcher {
29
29
  readonly #hinted = new Set<string>();
30
30
  readonly #classifier = new HmrChangeClassifier();
31
31
  readonly #index: SourceMtimeIndex;
32
+ readonly #scans = new Set<Promise<void>>();
32
33
  #timer: ReturnType<typeof setTimeout> | null = null;
33
34
  #verifyTimer: ReturnType<typeof setTimeout> | null = null;
34
35
  #windowStartedAt: number | null = null;
@@ -98,6 +99,18 @@ export class HmrWatcher {
98
99
  }
99
100
  }
100
101
 
102
+ //? A scan stop() interrupts keeps its finds unreported, and the scan has already moved their mtime baseline.
103
+ async close(): Promise<ChangeBatch | null> {
104
+ this.stop();
105
+ await Promise.all(this.#scans);
106
+ await this.#mergeDetectedChanges();
107
+ if (this.#pending.size === 0) return null;
108
+ const batch = { files: Array.from(this.#pending.keys()), kinds: new Set(this.#pending.values()) };
109
+ this.#pending.clear();
110
+ this.#hinted.clear();
111
+ return batch;
112
+ }
113
+
101
114
  /** Baseline the batch handler's own writes so the verification scan does not rebuild them a second time. */
102
115
  async absorb(paths: string[]): Promise<void> {
103
116
  if (paths.length === 0) return;
@@ -143,6 +156,8 @@ export class HmrWatcher {
143
156
  try {
144
157
  while (!this.#stopped) {
145
158
  await this.#mergeDetectedChanges();
159
+ //? stop() can land while the scan runs; a batch handed over after it reaches an owner that has moved on.
160
+ if (this.#stopped) break;
146
161
  if (this.#pending.size === 0) {
147
162
  this.#windowStartedAt = null;
148
163
  break;
@@ -167,7 +182,13 @@ export class HmrWatcher {
167
182
  }
168
183
  }
169
184
 
170
- async #mergeDetectedChanges(): Promise<void> {
185
+ #mergeDetectedChanges(): Promise<void> {
186
+ const scan = this.#collectDetectedChanges().finally(() => this.#scans.delete(scan));
187
+ this.#scans.add(scan);
188
+ return scan;
189
+ }
190
+
191
+ async #collectDetectedChanges(): Promise<void> {
171
192
  const detected = await this.#index.collectChanges().catch((err) => {
172
193
  this.#logger.error(`[hmr] mtime scan failed: ${(err as Error).message}`);
173
194
  return [] as string[];
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, test } from "bun:test";
2
2
  import path from "node:path";
3
- import { tempDirs, writeText as write } from "../testHelpers";
3
+ import { tempDirs, writeText as write } from "../test/testHelpers";
4
4
  import { CsrArtifactBuilder } from "./csrArtifactBuilder";
5
5
  import { McpAppViewBuilder } from "./mcpAppViewBuilder";
6
6
 
@@ -115,7 +115,7 @@ export class McpAppViewBuilder {
115
115
 
116
116
  /** Every `.app()` the pages declare, read off their sources without evaluating them. */
117
117
  static async discover(pageEntries: PageEntry[], basePaths: string[]): Promise<McpAppView[]> {
118
- const { RouteSourceValidator } = await import("../routeSourceValidator");
118
+ const { RouteSourceValidator } = await import("../app/routeSourceValidator");
119
119
  const roots = pageEntries.filter((entry) => parseRouteModuleKey(entry.key).isInternalRootLayout);
120
120
  const overrides = pageEntries.filter((entry) => parseRouteModuleKey(entry.key).kind === "overrides");
121
121
  const layoutNodes = new Set(
@@ -0,0 +1,148 @@
1
+ import { describe, expect, test } from "bun:test";
2
+ import { existsSync } from "node:fs";
3
+ import { mkdir, realpath, symlink } from "node:fs/promises";
4
+ import path from "node:path";
5
+ import { tempDirs, writeText as write } from "../test/testHelpers";
6
+ import { createBarrelImportsPlugin } from "../transforms/barrelImportsPlugin";
7
+
8
+ const makeTempRoot = tempDirs("akan-native-core-");
9
+ const akanjsRoot = path.resolve(import.meta.dir, "../../../akanjs");
10
+ const repoRoot = path.resolve(akanjsRoot, "../..");
11
+ const frameworkBarrels = ["akanjs/webkit", "akanjs/common", "akanjs/ui", "akanjs/server"];
12
+ const reactExternals = [
13
+ "react",
14
+ "react-dom",
15
+ "react-dom/client",
16
+ "react/jsx-runtime",
17
+ "react/jsx-dev-runtime",
18
+ "scheduler",
19
+ "react-server-dom-webpack/client.browser",
20
+ ];
21
+ const pageRuntime = [
22
+ path.join(akanjsRoot, "server/rscClient.tsx"),
23
+ path.join(akanjsRoot, "server/rscSegmentOutlet.tsx"),
24
+ path.join(akanjsRoot, "ui/System/Client.tsx"),
25
+ ];
26
+
27
+ interface PageBuild {
28
+ workspaceRoot: string;
29
+ paths: Record<string, string[]>;
30
+ barrelImports: string[];
31
+ entries: string[];
32
+ }
33
+
34
+ const eagerInputsOf = async ({ workspaceRoot, paths, barrelImports, entries }: PageBuild) => {
35
+ const app = {
36
+ name: "demo",
37
+ cwdPath: path.join(workspaceRoot, "apps/demo"),
38
+ workspace: { workspaceRoot },
39
+ getConfig: async () => ({ barrelImports }),
40
+ getTsConfig: async () => ({ compilerOptions: { paths } }),
41
+ };
42
+ const result = await Bun.build({
43
+ entrypoints: entries,
44
+ target: "browser",
45
+ format: "esm",
46
+ splitting: true,
47
+ metafile: true,
48
+ throw: true,
49
+ conditions: ["production"],
50
+ external: reactExternals,
51
+ plugins: [await createBarrelImportsPlugin(app as never)],
52
+ });
53
+ const outputs = result.metafile?.outputs ?? {};
54
+ const eager = new Set<string>();
55
+ const load = (outputPath: string) => {
56
+ if (eager.has(outputPath) || !outputs[outputPath]) return;
57
+ eager.add(outputPath);
58
+ for (const imp of outputs[outputPath].imports) if (imp.kind === "import-statement") load(imp.path);
59
+ };
60
+ //? A dynamically imported module gets an entry chunk of its own too: only the page's entries start the walk.
61
+ for (const [outputPath, output] of Object.entries(outputs))
62
+ if (output.entryPoint && entries.includes(path.resolve(output.entryPoint))) load(outputPath);
63
+ return {
64
+ eager: [...eager].flatMap((outputPath) => Object.keys(outputs[outputPath]?.inputs ?? {})),
65
+ all: Object.keys(result.metafile?.inputs ?? {}),
66
+ };
67
+ };
68
+
69
+ const eagerInputsOfAPage = async (store: string) => {
70
+ //? Real path: Bun names entry points through /private on macOS, where the temp dir is a symlink.
71
+ const root = await realpath(await makeTempRoot());
72
+ await mkdir(path.join(root, "node_modules"), { recursive: true });
73
+ await symlink(akanjsRoot, path.join(root, "node_modules/akanjs"));
74
+ const paths = { "@apps/*": ["./apps/*"] };
75
+ await write(path.join(root, "tsconfig.json"), JSON.stringify({ compilerOptions: { paths } }));
76
+ await write(path.join(root, "apps/demo/lib/st.ts"), store);
77
+ return await eagerInputsOf({
78
+ workspaceRoot: root,
79
+ paths,
80
+ barrelImports: frameworkBarrels,
81
+ entries: [...pageRuntime, path.join(akanjsRoot, "ui/Link/Anchor.tsx"), path.join(root, "apps/demo/lib/st.ts")],
82
+ });
83
+ };
84
+
85
+ const isCore = (input: string) => /native\/packages\/core\//.test(input);
86
+
87
+ //? `akan sync` generates these, which a fresh checkout lacks; CI's sync job sets REQUIRE_SYNCED_LIBS after syncing.
88
+ const syncedLibFiles = [
89
+ ...["shared", "util"].flatMap((lib) =>
90
+ [
91
+ "client.ts",
92
+ "server.ts",
93
+ "index.ts",
94
+ "ui/index.ts",
95
+ "webkit/index.ts",
96
+ "common/index.ts",
97
+ "lib/cnst.ts",
98
+ "lib/st.ts",
99
+ "lib/useClient.ts",
100
+ ].map((file) => `libs/${lib}/${file}`),
101
+ ),
102
+ ...["user", "admin"].map((module) => `libs/shared/lib/${module}/index.ts`),
103
+ ];
104
+ const libsSynced = syncedLibFiles.every((file) => existsSync(path.join(repoRoot, file)));
105
+
106
+ describe("@akanjs/native/core on a web page", () => {
107
+ test("the runtime, the system shell, Link and a store reading the host stay off it", async () => {
108
+ const { eager, all } = await eagerInputsOfAPage(
109
+ 'import { isNativeShell, router } from "akanjs/client";\nimport { store } from "akanjs/store";\nexport const st = { isNativeShell, router, store };\n',
110
+ );
111
+
112
+ expect(eager.filter(isCore)).toEqual([]);
113
+ expect(all.some(isCore)).toBe(true);
114
+ });
115
+
116
+ test("a store importing akanjs/client/native statically puts it on the page", async () => {
117
+ const { eager } = await eagerInputsOfAPage(
118
+ 'import { isNativeShell } from "akanjs/client/native";\nexport const st = { isNativeShell };\n',
119
+ );
120
+
121
+ expect(eager.some(isCore)).toBe(true);
122
+ });
123
+
124
+ test.skipIf(!libsSynced && !process.env.REQUIRE_SYNCED_LIBS)(
125
+ "a page drawing a shared Field and User template, on a store merging shared, stays off it",
126
+ async () => {
127
+ const { eager, all } = await eagerInputsOf({
128
+ workspaceRoot: repoRoot,
129
+ paths: (await Bun.file(path.join(repoRoot, "tsconfig.json")).json()).compilerOptions.paths,
130
+ barrelImports: [
131
+ ...frameworkBarrels,
132
+ ...["shared", "util"].flatMap((lib) =>
133
+ ["ui", "webkit", "common", "client", "server"].map((facet) => `@libs/${lib}/${facet}`),
134
+ ),
135
+ ],
136
+ entries: [
137
+ ...pageRuntime,
138
+ ...["lib/useClient.ts", "lib/st.ts", "ui/Field.tsx", "lib/user/User.Template.tsx"].map((file) =>
139
+ path.join(repoRoot, "libs/shared", file),
140
+ ),
141
+ ],
142
+ });
143
+
144
+ expect(eager.filter(isCore)).toEqual([]);
145
+ expect(all.some(isCore)).toBe(true);
146
+ },
147
+ );
148
+ });
@@ -3,7 +3,7 @@ import { mkdir, symlink } from "node:fs/promises";
3
3
  import path from "node:path";
4
4
  import type { BunPlugin } from "bun";
5
5
  import { resolveSsrPageEntries } from "../artifact/implicitRootLayout";
6
- import { tempDirs, writeText as write } from "../testHelpers";
6
+ import { tempDirs, writeText as write } from "../test/testHelpers";
7
7
  import { CsrArtifactBuilder } from "./csrArtifactBuilder";
8
8
  import { VENDOR_SPECIFIERS } from "./vendorSpecifiers";
9
9
 
@@ -69,19 +69,37 @@ const buildCsr = async (indexPage: string) => {
69
69
  logger: { warn: () => undefined },
70
70
  };
71
71
  const reached: string[] = [];
72
+ const metafiles: Bun.BuildMetafile[] = [];
72
73
  const build = Bun.build;
73
- const recorded = spyOn(Bun, "build").mockImplementation((config) =>
74
- build({ ...config, plugins: [recordOptionalPeers(reached), ...(config.plugins ?? [])] }),
75
- );
74
+ const recorded = spyOn(Bun, "build").mockImplementation(async (config) => {
75
+ const result = await build({
76
+ ...config,
77
+ metafile: true,
78
+ plugins: [recordOptionalPeers(reached), ...(config.plugins ?? [])],
79
+ });
80
+ if (result.metafile) metafiles.push(result.metafile);
81
+ return result;
82
+ });
76
83
 
77
84
  try {
78
85
  await new CsrArtifactBuilder(app as never, "build").build();
79
86
  } finally {
80
87
  recorded.mockRestore();
81
88
  }
82
- return { root, reached };
89
+ return { root, reached, metafiles };
83
90
  };
84
91
 
92
+ const mcpAppPage =
93
+ 'import { page } from "akanjs/client";\nimport { Link } from "akanjs/ui";\n\nexport default page()\n .app("showHome", "Show the home link.", () => <Link href="/">home</Link>)\n .render(() => null);\n';
94
+
95
+ const bytesFrom = (metafiles: Bun.BuildMetafile[], entry: string, input: string) =>
96
+ metafiles
97
+ .flatMap((metafile) => Object.values(metafile.outputs))
98
+ .filter((output) => output.entryPoint?.endsWith(entry))
99
+ .flatMap((output) => Object.entries(output.inputs))
100
+ .filter(([file]) => file.endsWith(input))
101
+ .reduce((sum, [, { bytesInOutput }]) => sum + bytesInOutput, 0);
102
+
85
103
  describe("optional peers of akanjs", () => {
86
104
  test("the generated root layout, the _overrides.tsx wrapper and the runtime entries import none", async () => {
87
105
  const { appDir, pageKeys } = await writeApp("export default function Page() {\n return null;\n}\n");
@@ -122,11 +140,21 @@ describe("optional peers of akanjs", () => {
122
140
  });
123
141
 
124
142
  test("the MCP App view build of a page drawing akanjs/ui components imports none", async () => {
125
- const { root, reached } = await buildCsr(
126
- 'import { page } from "akanjs/client";\nimport { Link } from "akanjs/ui";\n\nexport default page()\n .app("showHome", "Show the home link.", () => <Link href="/">home</Link>)\n .render(() => null);\n',
127
- );
143
+ const { root, reached } = await buildCsr(mcpAppPage);
128
144
 
129
145
  expect(await Bun.file(path.join(root, "dist/apps/demo/mcp-apps/showHome.html")).exists()).toBe(true);
130
146
  expect(reached).toEqual([]);
131
147
  });
132
148
  });
149
+
150
+ describe("the CSR shell and the MCP App view", () => {
151
+ test("leave out the route-level boundary class, which only a server render draws, and keep RenderFailure", async () => {
152
+ const { metafiles } = await buildCsr(mcpAppPage);
153
+
154
+ for (const entry of ["generated/csr/index.html", "generated/mcp-apps/showHome.html"]) {
155
+ expect(bytesFrom(metafiles, entry, "webkit/RenderFailure.tsx")).toBeGreaterThan(0);
156
+ //? What stays of the module is its React import binding; the class alone is several hundred bytes.
157
+ expect(bytesFrom(metafiles, entry, "webkit/RouteLevelBoundary.tsx")).toBeLessThan(40);
158
+ }
159
+ });
160
+ });
@@ -2,11 +2,10 @@ import { describe, expect, test } from "bun:test";
2
2
  import { PagesBundleBuilder } from "./pagesBundleBuilder";
3
3
 
4
4
  const macroImport = `import { getSerializedSignal } from "./sig" with { type: "macro" };`;
5
- const macroFetchProto =
6
- "const fetchProto = FetchClient.build<typeof signal>(cnst, getSerializedSignal(), { Err: pageProto.Err });";
5
+ const macroFetchProto = "const fetchProto = FetchClient.build<typeof signal>(cnst, getSerializedSignal());";
7
6
  const serverImport = `import { fetch as serverFetch } from "./sig";`;
8
7
  const serverFetchProto =
9
- "const fetchProto = FetchClient.build<typeof signal>(cnst, serverFetch.serializedSignal, { Err: pageProto.Err, base: serverFetch });";
8
+ "const fetchProto = FetchClient.build<typeof signal>(cnst, serverFetch.serializedSignal, { base: serverFetch });";
10
9
 
11
10
  const generatedUseClient = (lines: { importLine?: string; fetchProtoLine?: string } = {}) =>
12
11
  [
@@ -196,7 +196,7 @@ export class PagesBundleBuilder {
196
196
  edits.push({
197
197
  start: tokens[fetchProtoAt].start,
198
198
  end: fetchProtoEnd.end,
199
- text: "const fetchProto = FetchClient.build<typeof signal>(cnst, serverFetch.serializedSignal, { Err: pageProto.Err, base: serverFetch });",
199
+ text: "const fetchProto = FetchClient.build<typeof signal>(cnst, serverFetch.serializedSignal, { base: serverFetch });",
200
200
  });
201
201
  let transformed = source;
202
202
  for (const { start, end, text } of edits.sort((a, b) => b.start - a.start))
@@ -3,7 +3,7 @@ import { mkdir, readFile, writeFile } from "node:fs/promises";
3
3
  import path from "node:path";
4
4
  import zlib from "node:zlib";
5
5
  import type { App } from "../commandDecorators";
6
- import { tempDirs } from "../testHelpers";
6
+ import { tempDirs } from "../test/testHelpers";
7
7
  import { precompressArtifacts } from "./precompressArtifacts";
8
8
 
9
9
  const tempRoot = tempDirs("akan-devkit-precompress-");
@@ -22,7 +22,7 @@ export interface PrecompressArtifactsResult {
22
22
  }
23
23
 
24
24
  export async function precompressArtifacts(app: App): Promise<PrecompressArtifactsResult> {
25
- //* WebRouter serves client/, styles/ and dict/ through the same sidecar-aware #fileResponse.
25
+ //* WebRouter serves client/, styles/ and dict/ through the same sidecar-aware WebRouteContext.fileResponse.
26
26
  const artifactDir = path.join(app.dist.cwdPath, ".akan/artifact");
27
27
  const roots = [
28
28
  { root: path.join(artifactDir, "client") },
@@ -1,7 +1,7 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
- import { FileSys } from "../fileSys";
4
3
  import { hasUseClientDirective, scanUseClientExports } from "../transforms/rscUseClientTransform";
4
+ import { FileSys } from "../util/fileSys";
5
5
  import { CsrDevPaths } from "./csrDevPaths";
6
6
 
7
7
  export interface ServerGraph {
@@ -1,7 +1,7 @@
1
1
  import { describe, expect, test } from "bun:test";
2
2
  import { chmod, mkdir, readdir, rm, stat, utimes, writeFile } from "node:fs/promises";
3
3
  import path from "node:path";
4
- import { tempDirs } from "../testHelpers";
4
+ import { tempDirs } from "../test/testHelpers";
5
5
  import { SourceMtimeIndex } from "./sourceMtimeIndex";
6
6
 
7
7
  const seed = async (root: string, rel: string, content = "export const x = 1;\n") => {
@@ -0,0 +1,26 @@
1
+ import { describe, expect, test } from "bun:test";
2
+ import { SsrBaseArtifactBuilder } from "./ssrBaseArtifactBuilder";
3
+
4
+ describe("SsrBaseArtifactBuilder.outletModuleMap", () => {
5
+ const outlet = "pkgs/akanjs/server/rscSegmentOutlet.tsx";
6
+ const ssrOutput = "/dist/client-ssr/rscSegmentOutlet.js";
7
+ const manifest = {
8
+ [`${outlet}#AkanSegmentOutlet`]: { id: "/_akan/client/outlet.js", chunks: [], name: "AkanSegmentOutlet" },
9
+ [`${outlet}#AkanRouteHead`]: { id: "/_akan/client/outlet.js", chunks: [], name: "AkanRouteHead" },
10
+ "pkgs/akanjs/ui/Other.tsx#Other": { id: "/_akan/client/other.js", chunks: [], name: "Other" },
11
+ };
12
+
13
+ test("keeps every export of the outlet module under its one client id, each served by the SSR build", () => {
14
+ expect(SsrBaseArtifactBuilder.outletModuleMap(manifest, outlet, ssrOutput)).toEqual({
15
+ "/_akan/client/outlet.js": {
16
+ AkanSegmentOutlet: { id: ssrOutput, chunks: [ssrOutput, ssrOutput], name: "AkanSegmentOutlet", async: true },
17
+ AkanRouteHead: { id: ssrOutput, chunks: [ssrOutput, ssrOutput], name: "AkanRouteHead", async: true },
18
+ },
19
+ });
20
+ });
21
+
22
+ test("is empty without the outlet's SSR build or client reference", () => {
23
+ expect(SsrBaseArtifactBuilder.outletModuleMap(manifest, outlet, undefined)).toEqual({});
24
+ expect(SsrBaseArtifactBuilder.outletModuleMap(manifest, undefined, ssrOutput)).toEqual({});
25
+ });
26
+ });