@akanjs/devkit 3.3.0-rc.7 → 3.3.0-rc.70

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 (358) hide show
  1. package/DEV_RUNTIME_KNOBS.md +1 -1
  2. package/README.ko.md +10 -3
  3. package/README.md +10 -4
  4. package/akanApp/akanApp.host.test.ts +4 -2
  5. package/akanApp/akanApp.host.ts +26 -2
  6. package/akanApp/akanApp.host.wiring.test.ts +111 -0
  7. package/akanApp/devHostPolicy.ts +5 -0
  8. package/akanApp/devMetadataRestart.ts +93 -0
  9. package/akanApp/devRecycler.test.ts +2 -0
  10. package/akanApp/devRecycler.ts +9 -0
  11. package/akanConfig/akanBin.ts +4 -0
  12. package/akanConfig/akanConfig.test.ts +320 -21
  13. package/akanConfig/akanConfig.ts +113 -272
  14. package/akanConfig/akanPreview.test.ts +28 -0
  15. package/akanConfig/akanPreview.ts +24 -0
  16. package/akanConfig/akanWorkers.test.ts +73 -0
  17. package/akanConfig/akanWorkers.ts +61 -0
  18. package/akanConfig/desktopServerConfig.ts +96 -0
  19. package/akanConfig/dockerImage.ts +229 -0
  20. package/akanConfig/index.ts +3 -0
  21. package/akanConfig/nativeFileSettings.ts +33 -0
  22. package/akanConfig/nativeKeys.ts +52 -0
  23. package/akanConfig/types.ts +4 -0
  24. package/app/appBin.test.ts +63 -0
  25. package/app/appBin.ts +50 -0
  26. package/app/applicationBuildReporter.test.ts +51 -1
  27. package/app/applicationBuildReporter.ts +6 -1
  28. package/app/applicationBuildRunner.test.ts +358 -5
  29. package/app/applicationBuildRunner.ts +221 -31
  30. package/app/clientServerBoundary.test.ts +115 -0
  31. package/app/clientServerBoundary.ts +89 -0
  32. package/app/dictionarySizes.test.ts +40 -0
  33. package/app/dictionarySizes.ts +95 -0
  34. package/app/routeFilesReport.test.ts +59 -0
  35. package/app/routeFilesReport.ts +46 -0
  36. package/app/routeJsBudget.ts +18 -4
  37. package/artifact/implicitRootLayout.test.ts +19 -0
  38. package/artifact/implicitRootLayout.ts +16 -2
  39. package/artifact/implicitRootLayoutRender.test.tsx +4 -1
  40. package/artifact/storeBootstrap.test.ts +28 -0
  41. package/artifact/storeBootstrap.ts +64 -8
  42. package/biome.base.json +7 -5
  43. package/codeAgent/index.ts +1 -34
  44. package/codeAgent/skills/akan-agent/SKILL.md +8 -1
  45. package/codeAgent/skills/akan-code/SKILL.md +38 -3
  46. package/codeAgent/skills/akan-debug/SKILL.md +8 -3
  47. package/codeAgent/skills/akan-deps/SKILL.md +10 -3
  48. package/codeAgent/skills/akan-err/SKILL.md +13 -8
  49. package/codeAgent/skills/akan-mcp/SKILL.md +1 -1
  50. package/codeAgent/skills/akan-module/SKILL.md +2 -2
  51. package/codeAgent/skills/akan-page/SKILL.md +65 -30
  52. package/codeAgent/skills/akan-query/SKILL.md +13 -20
  53. package/codeAgent/skills/akan-runtime/SKILL.md +21 -1
  54. package/codeAgent/skills/akan-service/SKILL.md +21 -20
  55. package/codeAgent/skills/akan-transport/SKILL.md +5 -14
  56. package/codeAgent/skills/akan-ui/SKILL.md +16 -21
  57. package/codeAgent/skills/akan-validate/SKILL.md +8 -2
  58. package/commandDecorators/command.ts +28 -12
  59. package/commandDecorators/commandBuilder.ts +8 -1
  60. package/commandDecorators/commandDecorators.test.ts +70 -3
  61. package/commandDecorators/helpFormatter.ts +14 -12
  62. package/context/akanContext.ts +2 -0
  63. package/csrE2e/devHmrLatency.e2e.test.ts +1 -1
  64. package/csrE2e/ssrRegistry.e2e.test.ts +108 -22
  65. package/docs/apiReference.test.ts +25 -0
  66. package/docs/apiReference.ts +38 -5
  67. package/docs/declarationReader.ts +30 -0
  68. package/executors/appExecutor.ts +26 -12
  69. package/executors/clientRuntimeKeyOrder.fixture.json +682 -0
  70. package/executors/clientRuntimeKeys.fixture.json +393 -0
  71. package/executors/clientRuntimeKeys.test.ts +1690 -0
  72. package/executors/executor.ts +14 -6
  73. package/executors/executors.test.ts +155 -1
  74. package/executors/pkgExecutor.ts +2 -1
  75. package/executors/sysExecutor.ts +112 -8
  76. package/executors/workspaceExecutor.ts +7 -4
  77. package/frontendBuild/allRoutesBuilder.ts +99 -7
  78. package/frontendBuild/autoImportSync.ts +3 -2
  79. package/frontendBuild/buildRouteClient.test.ts +686 -13
  80. package/frontendBuild/clientBuildTypes.ts +26 -0
  81. package/frontendBuild/clientEntriesBundler.ts +49 -1
  82. package/frontendBuild/clientEntryDiscovery.test.ts +308 -1
  83. package/frontendBuild/clientEntryDiscovery.ts +136 -14
  84. package/frontendBuild/clientEntryGroups.test.ts +77 -0
  85. package/frontendBuild/clientEntryGroups.ts +61 -0
  86. package/frontendBuild/csrDevArtifactWriter.ts +2 -2
  87. package/frontendBuild/csrDevModuleCompiler.test.ts +86 -0
  88. package/frontendBuild/csrDevModuleCompiler.ts +44 -8
  89. package/frontendBuild/csrDevPatcher.test.ts +4 -5
  90. package/frontendBuild/csrDevPatcher.ts +37 -11
  91. package/frontendBuild/csrDevTypes.ts +9 -0
  92. package/frontendBuild/devBarrelImports.test.ts +154 -0
  93. package/frontendBuild/devBarrelImports.ts +83 -23
  94. package/frontendBuild/devChangePlanner.ts +0 -1
  95. package/frontendBuild/devRegistryBundler.ts +4 -2
  96. package/frontendBuild/devRouteRuntime.test.ts +492 -0
  97. package/frontendBuild/devRouteRuntime.ts +167 -0
  98. package/frontendBuild/dictionaryAssetBuilder.test.ts +408 -0
  99. package/frontendBuild/dictionaryAssetBuilder.ts +185 -17
  100. package/frontendBuild/dictionaryConstants.ts +136 -0
  101. package/frontendBuild/dictionaryOwnParts.ts +88 -0
  102. package/frontendBuild/dictionaryPackState.ts +131 -0
  103. package/frontendBuild/dictionaryPacking.test.ts +207 -0
  104. package/frontendBuild/dictionaryPacking.ts +160 -0
  105. package/frontendBuild/dictionaryRoutes.test.ts +251 -0
  106. package/frontendBuild/dictionaryRoutes.ts +227 -0
  107. package/frontendBuild/frontendBuild.test.ts +5 -3
  108. package/frontendBuild/pagesBundleBuilder.test.ts +84 -0
  109. package/frontendBuild/pagesBundleBuilder.ts +78 -2
  110. package/frontendBuild/precompressArtifacts.test.ts +22 -0
  111. package/frontendBuild/precompressArtifacts.ts +34 -8
  112. package/frontendBuild/registryMetadataFingerprint.ts +3 -3
  113. package/frontendBuild/renderedEntries.ts +144 -0
  114. package/frontendBuild/routeClientBuilder.ts +407 -43
  115. package/frontendBuild/routeHandoffs.test.ts +155 -0
  116. package/frontendBuild/routeHandoffs.ts +117 -0
  117. package/frontendBuild/routeModulePreloads.test.ts +32 -0
  118. package/frontendBuild/routeModulePreloads.ts +20 -11
  119. package/frontendBuild/routeRuntimeCheck.test.ts +280 -0
  120. package/frontendBuild/routeRuntimeCheck.ts +248 -0
  121. package/frontendBuild/routeRuntimePays.test.ts +143 -0
  122. package/frontendBuild/routeRuntimePays.ts +117 -0
  123. package/frontendBuild/ssrBaseArtifactBuilder.ts +30 -35
  124. package/frontendBuild/ssrDevBundler.test.ts +150 -1
  125. package/frontendBuild/ssrDevBundler.ts +66 -11
  126. package/frontendBuild/vendorFileImports.test.ts +254 -0
  127. package/frontendBuild/vendorFileImports.ts +163 -0
  128. package/frontendBuild/vendorNarrowing.test.ts +47 -3
  129. package/frontendBuild/vendorNarrowing.ts +38 -2
  130. package/frontendBuild/vendorSpecifiers.ts +2 -0
  131. package/guideline/agentAssets.ts +1 -1
  132. package/incrementalBuilder/buildBatch.proc.ts +35 -9
  133. package/incrementalBuilder/buildBatchProtocol.ts +2 -1
  134. package/incrementalBuilder/builderBoot.ts +5 -5
  135. package/incrementalBuilder/builderGraphPayloads.ts +4 -4
  136. package/incrementalBuilder/builderLanes.ts +2 -2
  137. package/incrementalBuilder/builderWatch.ts +19 -9
  138. package/incrementalBuilder/csrRegistry.ts +4 -4
  139. package/incrementalBuilder/incrementalBuilder.proc.test.ts +159 -0
  140. package/incrementalBuilder/incrementalBuilder.proc.ts +38 -10
  141. package/incrementalBuilder/pendingMetadata.test.ts +27 -0
  142. package/incrementalBuilder/pendingMetadata.ts +19 -0
  143. package/incrementalBuilder/ssrRegistry.ts +6 -6
  144. package/index.ts +1 -1
  145. package/integration/devStability.integration.test.ts +46 -21
  146. package/integration/renderAdmissionSoak.test.ts +99 -0
  147. package/integration/renderAdmissionSoak.ts +609 -0
  148. package/lint/__fixtures__/no-arbitrary-color/every-color-function/bad.tsx +11 -0
  149. package/lint/__fixtures__/no-arbitrary-color/every-color-function/good.tsx +2 -0
  150. package/lint/__fixtures__/no-daisyui-legacy-class/every-class/bad.tsx +34 -0
  151. package/lint/__fixtures__/no-daisyui-legacy-class/every-class/good.tsx +2 -0
  152. package/lint/__fixtures__/no-inline-color/every-color-function/bad.tsx +10 -0
  153. package/lint/__fixtures__/no-inline-color/every-color-function/good.tsx +2 -0
  154. package/lint/__fixtures__/no-raw-palette-class/every-palette/bad.tsx +22 -0
  155. package/lint/__fixtures__/no-raw-palette-class/every-palette/good.tsx +2 -0
  156. package/lint/biomeBase.test.ts +50 -3
  157. package/lint/biomeBase.ts +1 -1
  158. package/lint/biomeCheck.test.ts +162 -0
  159. package/lint/biomeCheck.ts +131 -0
  160. package/lint/linter.test.ts +16 -11
  161. package/lint/no-arbitrary-color.grit +5 -0
  162. package/lint/no-conditional-st-hook.grit +5 -1
  163. package/lint/no-daisyui-legacy-class.grit +8 -0
  164. package/lint/no-document-cookie.grit +3 -0
  165. package/lint/no-inline-color.grit +10 -2
  166. package/lint/no-oversized-list-limit.grit +2 -0
  167. package/lint/no-raw-palette-class.grit +7 -0
  168. package/lint/no-unpublished-form-setter.grit +2 -0
  169. package/lint/no-web-only-api-outside-webkit.grit +5 -0
  170. package/lint/no-web-storage.grit +3 -0
  171. package/lint/withheldEnvFile.ts +17 -0
  172. package/mobile/desktopBin.ts +2 -2
  173. package/mobile/desktopServerStage.test.ts +18 -3
  174. package/mobile/desktopServerStage.ts +7 -2
  175. package/mobile/nativeApp.test.ts +7 -5
  176. package/mobile/nativeApp.ts +2 -2
  177. package/mobile/nativeConfig.test.ts +96 -1
  178. package/mobile/nativeConfig.ts +46 -12
  179. package/mobile/nativePublicEnv.ts +1 -1
  180. package/mobile/serverBundleSecrets.ts +43 -0
  181. package/package.json +22 -178
  182. package/packageExports.test.ts +39 -24
  183. package/preview/PreviewView.ts +25 -3
  184. package/quality/dictionaryKeys.test.ts +356 -0
  185. package/quality/dictionaryKeys.ts +488 -0
  186. package/quality/objectImportReport.test.ts +36 -0
  187. package/quality/objectImportReport.ts +105 -0
  188. package/quality/qualityScanner.ts +1 -1
  189. package/quality/routeRuntimeReport.test.ts +91 -0
  190. package/quality/routeRuntimeReport.ts +121 -0
  191. package/quality/runtimeConstantFacts.ts +71 -0
  192. package/quality/runtimeConstantGraph.ts +123 -0
  193. package/quality/runtimeConstantReads.ts +116 -0
  194. package/quality/runtimeImports.test.ts +190 -0
  195. package/quality/runtimeImports.ts +233 -0
  196. package/quality/runtimeKeyNames.ts +46 -0
  197. package/quality/runtimeLexicalScope.ts +132 -0
  198. package/quality/runtimeMarkerReach.test.ts +84 -0
  199. package/quality/runtimeMarkerReach.ts +255 -0
  200. package/quality/runtimeModuleFacts.ts +290 -0
  201. package/quality/runtimeNameTable.test.ts +172 -0
  202. package/quality/runtimeNameTable.ts +477 -0
  203. package/quality/runtimeScopeReport.test.ts +123 -0
  204. package/quality/runtimeScopeReport.ts +167 -0
  205. package/quality/runtimeSliceKey.ts +269 -0
  206. package/quality/runtimeSyntax.ts +133 -0
  207. package/quality/runtimeTable.fixture.ts +189 -0
  208. package/quality/runtimeUse.test.ts +737 -0
  209. package/quality/runtimeUse.ts +696 -0
  210. package/quality/runtimeUseReadable.test.ts +393 -0
  211. package/quality/ssrScanner.test.ts +13 -0
  212. package/quality/ssrScanner.ts +1 -1
  213. package/quality/translatorBindings.ts +187 -0
  214. package/test/fakeTerminal.ts +45 -0
  215. package/test/secretEnvFixture.ts +134 -0
  216. package/test/testHelpers.ts +11 -0
  217. package/transforms/barrelAnalyzer.ts +26 -4
  218. package/transforms/barrelImportsPlugin.ts +121 -32
  219. package/transforms/exportReach.test.ts +162 -0
  220. package/transforms/exportReach.ts +308 -0
  221. package/transforms/frameworkObjects.fixture.tsx +58 -0
  222. package/transforms/frameworkObjects.test.ts +54 -0
  223. package/transforms/modelReference.test.ts +196 -0
  224. package/transforms/modelReference.ts +39 -0
  225. package/transforms/moduleParts.test.ts +225 -0
  226. package/transforms/moduleParts.ts +418 -0
  227. package/transforms/objectImportEdits.ts +150 -0
  228. package/transforms/objectMemberImports.test.ts +633 -0
  229. package/transforms/objectMemberImports.ts +571 -0
  230. package/transforms/objectMemberLookup.ts +150 -0
  231. package/transforms/objectModule.test.ts +307 -0
  232. package/transforms/objectModule.ts +482 -0
  233. package/transforms/objectModuleAnalyzer.ts +104 -0
  234. package/transforms/partImports.test.ts +76 -0
  235. package/transforms/partImports.ts +110 -0
  236. package/transforms/partModules.test.ts +187 -0
  237. package/transforms/partModules.ts +90 -0
  238. package/transforms/partPurity.ts +124 -0
  239. package/transforms/reactIconImports.test.ts +231 -0
  240. package/transforms/reactIconImports.ts +325 -0
  241. package/transforms/routeConstants.ts +122 -0
  242. package/transforms/routeRuntime.test.ts +835 -0
  243. package/transforms/routeRuntime.ts +703 -0
  244. package/transforms/routeRuntimeEdits.ts +92 -0
  245. package/transforms/routeRuntimeGraph.ts +66 -0
  246. package/transforms/routeRuntimePlan.ts +244 -0
  247. package/transforms/secretEnvDeclaration.test.ts +208 -0
  248. package/transforms/secretEnvDeclaration.ts +213 -0
  249. package/transforms/secretEnvFile.test.ts +117 -0
  250. package/transforms/secretEnvFile.ts +113 -0
  251. package/transforms/secretEnvName.test.ts +54 -0
  252. package/transforms/secretEnvName.ts +29 -0
  253. package/transforms/secretEnvSource.test.ts +148 -0
  254. package/transforms/secretEnvSource.ts +166 -0
  255. package/transforms/serverEnvEvaluationError.ts +11 -0
  256. package/transforms/serverEnvPlugin.test.ts +2 -1
  257. package/transforms/serverEnvPlugin.ts +13 -0
  258. package/transforms/serverEnvProfile.test.ts +129 -2
  259. package/transforms/serverEnvProfile.ts +126 -40
  260. package/transforms/serverEnvSecrets.test.ts +292 -0
  261. package/transforms/signalDescriptors.test.ts +280 -0
  262. package/transforms/signalDescriptors.ts +227 -0
  263. package/transforms/thisFreeExports.ts +87 -0
  264. package/transforms/transforms.test.ts +180 -3
  265. package/transforms/tsconfigPackageResolver.test.ts +1 -0
  266. package/tunnel/createTunnel.test.ts +29 -8
  267. package/tunnel/createTunnel.ts +22 -11
  268. package/tunnel/ssh2Module.test.ts +37 -0
  269. package/tunnel/ssh2Module.ts +28 -0
  270. package/tunnel/sshTunnel.ts +4 -2
  271. package/typecheck/projectTypecheck.test.ts +32 -1
  272. package/typecheck/projectTypecheck.ts +3 -3
  273. package/typecheck/typeChecker.test.ts +49 -0
  274. package/typecheck/typeChecker.ts +9 -7
  275. package/typecheck/withheldDiagnostics.ts +41 -0
  276. package/util/devInstallCommand.ts +7 -0
  277. package/util/fileEditor.ts +1 -0
  278. package/util/jsonFormatter.test.ts +13 -9
  279. package/util/selectModel.ts +1 -0
  280. package/workflow/executor.ts +6 -2
  281. package/workflow/index.ts +1 -0
  282. package/workflow/plan.ts +36 -7
  283. package/workflow/types.ts +1 -1
  284. package/workflow/uiTarget.ts +50 -0
  285. package/workspace/envSeed.test.ts +30 -1
  286. package/workspace/envSeed.ts +30 -1
  287. package/workspace/getRelatedCnsts.ts +7 -0
  288. package/workspace/mainCheckout.test.ts +55 -0
  289. package/workspace/mainCheckout.ts +38 -0
  290. package/workspace/scanInfo.test.ts +39 -0
  291. package/workspace/scanInfo.ts +55 -6
  292. package/workspace/slicePlanner.ts +2 -1
  293. package/workspace/workspaceLayout.test.ts +22 -1
  294. package/workspace/workspaceLayout.ts +3 -3
  295. package/CHANGELOG.md +0 -2718
  296. package/codeAgent/agent/AkanCodeCompaction.ts +0 -49
  297. package/codeAgent/agent/AkanCodeServices.ts +0 -122
  298. package/codeAgent/agent/AkanContextFiles.ts +0 -94
  299. package/codeAgent/agent/CodeAgent.ts +0 -606
  300. package/codeAgent/agent/CodeAgentAsks.ts +0 -66
  301. package/codeAgent/agent/CodeAgentEventMapper.ts +0 -225
  302. package/codeAgent/agent/CodeAgentGate.ts +0 -239
  303. package/codeAgent/agent/CodeAgentProxy.ts +0 -83
  304. package/codeAgent/agent/CodeAgentRpcHost.ts +0 -109
  305. package/codeAgent/agent/CodeAgentRpcListener.ts +0 -195
  306. package/codeAgent/agent/CodeAgentStreamPrinter.ts +0 -86
  307. package/codeAgent/agent/CodeAgentSuspended.ts +0 -85
  308. package/codeAgent/agent/CodeAgentUi.ts +0 -47
  309. package/codeAgent/agent/CodeMailbox.ts +0 -148
  310. package/codeAgent/agent/CodeSessionFork.ts +0 -56
  311. package/codeAgent/agent/CodeSessionIndex.ts +0 -78
  312. package/codeAgent/agent/SubagentPool.ts +0 -219
  313. package/codeAgent/agent/WorkspaceTrust.ts +0 -200
  314. package/codeAgent/agent/akanCodeCompaction.test.ts +0 -36
  315. package/codeAgent/agent/akanCodeModel.ts +0 -47
  316. package/codeAgent/agent/akanCodeServices.test.ts +0 -54
  317. package/codeAgent/agent/akanContextFiles.test.ts +0 -116
  318. package/codeAgent/agent/akanSystemPrompt.ts +0 -50
  319. package/codeAgent/agent/codeAgent.test.ts +0 -275
  320. package/codeAgent/agent/codeAgentContract.test.ts +0 -643
  321. package/codeAgent/agent/codeAgentHosts.ts +0 -30
  322. package/codeAgent/agent/codeAgentProxy.test.ts +0 -126
  323. package/codeAgent/agent/codeAgentRpcListener.test.ts +0 -215
  324. package/codeAgent/agent/codeAgentSuspended.test.ts +0 -47
  325. package/codeAgent/agent/codeMailbox.test.ts +0 -76
  326. package/codeAgent/agent/codeSessionFork.test.ts +0 -58
  327. package/codeAgent/agent/codeSessionIndex.test.ts +0 -77
  328. package/codeAgent/agent/consoleToStderr.ts +0 -8
  329. package/codeAgent/agent/jsonLines.ts +0 -29
  330. package/codeAgent/agent/stringArg.ts +0 -5
  331. package/codeAgent/feedback/DevLogFeedback.ts +0 -82
  332. package/codeAgent/feedback/PreviewFeedback.ts +0 -46
  333. package/codeAgent/feedback/TurnFeedback.ts +0 -98
  334. package/codeAgent/feedback/VerifyFeedback.ts +0 -39
  335. package/codeAgent/tools/AkanCli.ts +0 -51
  336. package/codeAgent/tools/AkanCodePlugins.ts +0 -142
  337. package/codeAgent/tools/AkanEditScope.ts +0 -53
  338. package/codeAgent/tools/AkanEnvKeys.ts +0 -50
  339. package/codeAgent/tools/AkanToolPack.ts +0 -86
  340. package/codeAgent/tools/AkanVerifier.ts +0 -30
  341. package/codeAgent/tools/AskToolPack.ts +0 -99
  342. package/codeAgent/tools/DeepSeekWeb.ts +0 -127
  343. package/codeAgent/tools/MailToolPack.ts +0 -76
  344. package/codeAgent/tools/McpClient.ts +0 -209
  345. package/codeAgent/tools/McpOAuth.ts +0 -233
  346. package/codeAgent/tools/McpOAuthLoopback.ts +0 -64
  347. package/codeAgent/tools/McpServerConfig.ts +0 -131
  348. package/codeAgent/tools/McpSignIn.ts +0 -158
  349. package/codeAgent/tools/McpTokenStore.ts +0 -128
  350. package/codeAgent/tools/McpToolPack.ts +0 -206
  351. package/codeAgent/tools/SessionToolPack.ts +0 -91
  352. package/codeAgent/tools/WebToolPack.ts +0 -315
  353. package/codeAgent/tools/akanCodePlugins.test.ts +0 -954
  354. package/codeAgent/tools/askToolPack.test.ts +0 -116
  355. package/codeAgent/tools/deepSeekWeb.test.ts +0 -113
  356. package/codeAgent/tools/mcpOAuth.test.ts +0 -648
  357. package/codeAgent/tools/mcpServerConfig.test.ts +0 -341
  358. package/piDependencyPins.test.ts +0 -45
@@ -0,0 +1,110 @@
1
+ import ts from "typescript";
2
+ import { ModuleParts } from "./moduleParts";
3
+ import { ObjectModule } from "./objectModule";
4
+
5
+ export interface PartImportsOptions {
6
+ resolve: (specifier: string, importer: string) => Promise<string | null>;
7
+ //? Null for a file that stays one module.
8
+ partsOf: (file: string) => Promise<ModuleParts | null>;
9
+ }
10
+
11
+ interface Asked {
12
+ imported: string;
13
+ local: string;
14
+ }
15
+
16
+ interface Statement {
17
+ kind: "import" | "export";
18
+ specifier: string;
19
+ written: string;
20
+ names: Asked[];
21
+ }
22
+
23
+ interface Edit {
24
+ start: number;
25
+ end: number;
26
+ text: string;
27
+ }
28
+
29
+ const FROM = /\bfrom\s*["']/;
30
+
31
+ //* Sends each name an import or re-export asks of a file in parts to the part holding it, so a bundler follows that
32
+ //* part alone. A namespace import, `export *`, a bare import and `import()` keep asking the file, which loads them all.
33
+ export class PartImports {
34
+ readonly #resolve: PartImportsOptions["resolve"];
35
+ readonly #partsOf: PartImportsOptions["partsOf"];
36
+
37
+ constructor({ resolve, partsOf }: PartImportsOptions) {
38
+ this.#resolve = resolve;
39
+ this.#partsOf = partsOf;
40
+ }
41
+
42
+ async rewrite(source: string, importer: string): Promise<string | null> {
43
+ if (!FROM.test(source)) return null;
44
+ const sourceFile = ts.createSourceFile(
45
+ importer,
46
+ source,
47
+ ts.ScriptTarget.Latest,
48
+ true,
49
+ ObjectModule.scriptKindOf(importer),
50
+ );
51
+ const edits: Edit[] = [];
52
+ for (const statement of sourceFile.statements) {
53
+ const asked = PartImports.#askedBy(statement);
54
+ if (!asked) continue;
55
+ const file = await this.#resolve(asked.specifier, importer);
56
+ const parts = file && file !== importer ? await this.#partsOf(file) : null;
57
+ if (!file || !parts) continue;
58
+ const lines = PartImports.#lines(asked, parts, file);
59
+ edits.push({ start: statement.getStart(sourceFile), end: statement.end, text: lines.join("\n") });
60
+ }
61
+ if (edits.length === 0) return null;
62
+ let next = "";
63
+ let cursor = 0;
64
+ for (const { start, end, text } of edits) {
65
+ next += `${source.slice(cursor, start)}${text}`;
66
+ cursor = end;
67
+ }
68
+ return `${next}${source.slice(cursor)}`;
69
+ }
70
+
71
+ static #askedBy(statement: ts.Statement): Statement | null {
72
+ if (!ts.isImportDeclaration(statement) && !ts.isExportDeclaration(statement)) return null;
73
+ const { moduleSpecifier, attributes } = statement;
74
+ if (!moduleSpecifier || !ts.isStringLiteral(moduleSpecifier) || attributes) return null;
75
+ if (ModuleParts.specifier.test(moduleSpecifier.text)) return null;
76
+ const from = { specifier: moduleSpecifier.text, written: moduleSpecifier.getText() };
77
+ const namesOf = (elements: readonly (ts.ImportSpecifier | ts.ExportSpecifier)[]) =>
78
+ elements
79
+ .filter((element) => !element.isTypeOnly)
80
+ .map((element) => ({ imported: (element.propertyName ?? element.name).text, local: element.name.text }));
81
+ if (ts.isExportDeclaration(statement)) {
82
+ const clause = statement.exportClause;
83
+ if (statement.isTypeOnly || !clause || !ts.isNamedExports(clause)) return null;
84
+ const names = namesOf(clause.elements);
85
+ return names.length ? { kind: "export", ...from, names } : null;
86
+ }
87
+ const clause = statement.importClause;
88
+ if (!clause || clause.phaseModifier === ts.SyntaxKind.TypeKeyword) return null;
89
+ const bindings = clause.namedBindings;
90
+ if (bindings && ts.isNamespaceImport(bindings)) return null;
91
+ const names = namesOf(bindings?.elements ?? []);
92
+ if (clause.name) names.unshift({ imported: "default", local: clause.name.text });
93
+ return names.length ? { kind: "import", ...from, names } : null;
94
+ }
95
+
96
+ //? A name the file's parts do not hold stays asked of the file, so the bundler reports it as it did before.
97
+ static #lines({ kind, names, written }: Statement, parts: ModuleParts, file: string): string[] {
98
+ const byTarget = new Map<string, Asked[]>();
99
+ for (const asked of names) {
100
+ const part = parts.partOf(asked.imported);
101
+ if (!part && parts.isType(asked.imported)) continue;
102
+ const target = part ? JSON.stringify(`${file}${ModuleParts.query}${part}`) : written;
103
+ byTarget.set(target, [...(byTarget.get(target) ?? []), asked]);
104
+ }
105
+ return [...byTarget].map(([target, held]) => {
106
+ const list = held.map(({ imported, local }) => (imported === local ? local : `${imported} as ${local}`));
107
+ return `${kind} { ${list.join(", ")} } from ${target};`;
108
+ });
109
+ }
110
+ }
@@ -0,0 +1,187 @@
1
+ import { describe, expect, test } from "bun:test";
2
+ import { realpath } from "node:fs/promises";
3
+ import path from "node:path";
4
+ import { tempDirs, writeText as write } from "../test/testHelpers";
5
+ import { ModuleParts } from "./moduleParts";
6
+ import { PartModules, type PartSource } from "./partModules";
7
+
8
+ const makeTempRoot = tempDirs("akan-part-modules-");
9
+
10
+ describe("PartModules", () => {
11
+ test.each([
12
+ ["apps/demo/ui/Card.tsx", true],
13
+ ["libs/kit/webkit/useThing.ts", true],
14
+ ["apps/demo/lib/memo/Memo.Zone.tsx", true],
15
+ ["apps/demo/page/[lang]/_index.tsx", true],
16
+ ["apps/demo/lib/memo/memo.store.ts", false],
17
+ ["apps/demo/lib/memo/memo.constant.ts", false],
18
+ ["apps/demo/lib/memo/index.ts", false],
19
+ ["apps/demo/ui/index.ts", false],
20
+ ["apps/demo/lib/st.ts", false],
21
+ ["apps/demo/lib/__client/memo.st.ts", false],
22
+ ["apps/demo/client.ts", false],
23
+ ["apps/demo/.akan/generated/entry/Card.tsx", false],
24
+ ["apps/demo/node_modules/pkg/src/a.ts", false],
25
+ ["apps/demo/ui/styles.css", false],
26
+ ["pkgs/akanjs/ui/Button.tsx", false],
27
+ ["node_modules/akanjs/ui/Button.tsx", false],
28
+ ])("%s is taken apart: %p", (file, split) => {
29
+ expect(PartModules.splits("/repo", path.join("/repo", file))).toBe(split);
30
+ });
31
+
32
+ const pair = "/repo/apps/demo/ui/Pair.tsx";
33
+ const host = 'import { A } from "./Pair";\nexport const Host = A;\nexport const Other = 1;\n';
34
+ const sources: Record<string, PartSource> = {
35
+ [pair]: { source: "export const A = () => 1;\nexport const B = () => 2;\n" },
36
+ "/repo/apps/demo/ui/Page.tsx": { source: 'import { A } from "./Pair";\nexport const Page = () => A;\n' },
37
+ "/repo/apps/demo/ui/Host.tsx": { source: host, settled: true },
38
+ "/repo/apps/demo/lib/st.ts": {
39
+ source: 'import { B } from "../ui/Pair";\nexport const st = B;\nexport const b = 1;\n',
40
+ },
41
+ };
42
+ const modules = () => {
43
+ const reads: string[] = [];
44
+ const cache = new Map<string, ModuleParts | null>();
45
+ const made = new PartModules({
46
+ workspaceRoot: "/repo",
47
+ resolve: async (specifier, importer) => path.resolve(path.dirname(importer), `${specifier}.tsx`),
48
+ read: async (file) => {
49
+ reads.push(file);
50
+ return sources[file] ?? null;
51
+ },
52
+ cache,
53
+ });
54
+ return { made, reads, cache };
55
+ };
56
+
57
+ test("a file's path answers with re-exports of its parts, and the path with a part's id with that part", async () => {
58
+ const { made, reads, cache } = modules();
59
+
60
+ expect(await made.load(pair)).toBe(
61
+ `export { A } from "${pair}?akan-part=p0";\nexport { B } from "${pair}?akan-part=p1";\n`,
62
+ );
63
+ expect(await made.load(`${pair}?akan-part=p1`)).toBe("export const B = () => 2;\n");
64
+ expect(reads).toEqual([pair]);
65
+ expect(cache.size).toBe(1);
66
+ expect(PartModules.fileOf(`${pair}?akan-part=p1`)).toBe(pair);
67
+ await expect(made.load(`${pair}?akan-part=p7`)).rejects.toThrow("was asked for a part it does not have: p7");
68
+ });
69
+
70
+ test("a file left whole still asks a file in parts for the part it names", async () => {
71
+ const { made } = modules();
72
+
73
+ expect(await made.load("/repo/apps/demo/ui/Page.tsx")).toBe(
74
+ `import { A } from "${pair}?akan-part=p0";\nexport const Page = () => A;\n`,
75
+ );
76
+ expect(await made.load("/repo/apps/demo/lib/st.ts")).toBe(
77
+ `import { B } from "${pair}?akan-part=p1";\nexport const st = B;\nexport const b = 1;\n`,
78
+ );
79
+ });
80
+
81
+ test("a source handed over as settled is loaded as it is, and a file the bundler reads itself gives nothing", async () => {
82
+ const { made } = modules();
83
+
84
+ expect(await made.load("/repo/apps/demo/ui/Host.tsx")).toBe(host);
85
+ expect(await made.load("/repo/apps/demo/ui/Unknown.tsx")).toBeNull();
86
+ });
87
+
88
+ describe("in a bundle of two entries, each naming one export of the same file", () => {
89
+ const seen = "(globalThis as { __akanPartsSeen?: string[] }).__akanPartsSeen";
90
+ const fixture = async () => {
91
+ const root = await realpath(await makeTempRoot());
92
+ const file = (name: string) => path.join(root, "apps/demo", name);
93
+ for (const name of ["A", "B"])
94
+ await write(
95
+ file(`ui/heavy${name}.ts`),
96
+ `export const heavy${name} = { mark: "heavy-${name.toLowerCase()}-marker" };\n`,
97
+ );
98
+ await write(
99
+ file("ui/Pair.ts"),
100
+ [
101
+ 'import { heavyA } from "./heavyA";',
102
+ 'import { heavyB } from "./heavyB";',
103
+ `const loaded = (${seen} ??= []);`,
104
+ 'loaded.push("pair");',
105
+ "export const A = () => [heavyA.mark, loaded.length];",
106
+ "export const B = () => [heavyB.mark, loaded.length];",
107
+ "",
108
+ ].join("\n"),
109
+ );
110
+ for (const name of ["A", "B"])
111
+ await write(file(`page/${name.toLowerCase()}.ts`), `export { ${name} } from "../ui/Pair";\n`);
112
+ const bundle = async (outdir: string, inParts: boolean) => {
113
+ const made = new PartModules({
114
+ workspaceRoot: root,
115
+ resolve: async (specifier, importer) => Bun.resolveSync(specifier, path.dirname(importer)),
116
+ read: async (source) => ({ source: await Bun.file(source).text() }),
117
+ cache: new Map(),
118
+ });
119
+ const built = await Bun.build({
120
+ entrypoints: [file("page/a.ts"), file("page/b.ts")],
121
+ outdir: path.join(root, outdir),
122
+ splitting: true,
123
+ target: "browser",
124
+ format: "esm",
125
+ plugins: inParts
126
+ ? [
127
+ {
128
+ name: "parts",
129
+ setup(build) {
130
+ build.onResolve({ filter: ModuleParts.specifier }, ({ path: asked }) => ({ path: asked }));
131
+ build.onLoad({ filter: /\.ts(\?akan-part=[\w$]+)?$/ }, async ({ path: request }) => ({
132
+ contents: (await made.load(request)) ?? "",
133
+ loader: "ts",
134
+ }));
135
+ },
136
+ },
137
+ ]
138
+ : [],
139
+ });
140
+ const entryOf = (name: string) =>
141
+ built.outputs.find((output) => output.kind === "entry-point" && path.basename(output.path) === `${name}.js`)
142
+ ?.path ?? "";
143
+ const loadedBy = async (output: string, known = new Set<string>()): Promise<string> => {
144
+ if (known.has(output)) return "";
145
+ known.add(output);
146
+ const text = await Bun.file(output).text();
147
+ const imported = [...text.matchAll(/(?:from|import)\s*["'](\.[^"']+)["']/g)].map(([, specifier]) =>
148
+ path.resolve(path.dirname(output), specifier ?? ""),
149
+ );
150
+ return [text, ...(await Promise.all(imported.map((next) => loadedBy(next, known))))].join("\n");
151
+ };
152
+ return { entryOf, loadedBy };
153
+ };
154
+ return { bundle };
155
+ };
156
+
157
+ test("an entry loads the import of the export it names and not its sibling's, and the file's own statements still run first", async () => {
158
+ const { bundle } = await fixture();
159
+ const { entryOf, loadedBy } = await bundle("out-parts", true);
160
+
161
+ const a = await loadedBy(entryOf("a"));
162
+ const b = await loadedBy(entryOf("b"));
163
+ expect(a).toContain("heavy-a-marker");
164
+ expect(a).not.toContain("heavy-b-marker");
165
+ expect(b).toContain("heavy-b-marker");
166
+ expect(b).not.toContain("heavy-a-marker");
167
+
168
+ const state = globalThis as { __akanPartsSeen?: string[] };
169
+ const loaded: string[] = [];
170
+ state.__akanPartsSeen = loaded;
171
+ const { A } = (await import(entryOf("a"))) as { A: () => unknown[] };
172
+ const { B } = (await import(entryOf("b"))) as { B: () => unknown[] };
173
+ expect(A()).toEqual(["heavy-a-marker", 1]);
174
+ expect(B()).toEqual(["heavy-b-marker", 1]);
175
+ expect(loaded).toEqual(["pair"]);
176
+ });
177
+
178
+ test("left whole, the file is one chunk and each entry loads both imports", async () => {
179
+ const { bundle } = await fixture();
180
+ const { entryOf, loadedBy } = await bundle("out-whole", false);
181
+
182
+ const a = await loadedBy(entryOf("a"));
183
+ expect(a).toContain("heavy-a-marker");
184
+ expect(a).toContain("heavy-b-marker");
185
+ });
186
+ });
187
+ });
@@ -0,0 +1,90 @@
1
+ import path from "node:path";
2
+ import { ModuleParts } from "./moduleParts";
3
+ import { PartImports, type PartImportsOptions } from "./partImports";
4
+
5
+ export interface PartSource {
6
+ source: string;
7
+ //? A source handed over as it is: a macro host, a file another one stands in for, a vendor file.
8
+ settled?: boolean;
9
+ }
10
+
11
+ export interface PartModulesOptions {
12
+ workspaceRoot: string;
13
+ resolve: PartImportsOptions["resolve"];
14
+ //? A file as its bundle loads it, read once per bundle; null for one the bundler loads itself.
15
+ read: (file: string) => Promise<PartSource | null>;
16
+ //? Parts by file and source text, shared by the bundles of one build: most files read the same in each.
17
+ cache: Map<string, ModuleParts | null>;
18
+ }
19
+
20
+ interface Loaded extends PartSource {
21
+ parts: ModuleParts | null;
22
+ }
23
+
24
+ const CONVENTION_FILE = /\.(?:constant|dictionary|document|service|signal|store)\.ts$/;
25
+ const SOURCE_FILE = /\.tsx?$/;
26
+
27
+ //* What a bundle loads for a workspace file taken apart: the file's path answers with re-exports of its parts, and
28
+ //* the path with a part's id answers with that part.
29
+ export class PartModules {
30
+ readonly #options: PartModulesOptions;
31
+ readonly #imports: PartImports;
32
+ readonly #loaded = new Map<string, Promise<Loaded | null>>();
33
+
34
+ constructor(options: PartModulesOptions) {
35
+ this.#options = options;
36
+ this.#imports = new PartImports({
37
+ resolve: options.resolve,
38
+ partsOf: async (file) => (this.#splits(file) ? ((await this.#loadedOf(file))?.parts ?? null) : null),
39
+ });
40
+ }
41
+
42
+ #splits(file: string): boolean {
43
+ return PartModules.splits(this.#options.workspaceRoot, file);
44
+ }
45
+
46
+ static fileOf(request: string): string {
47
+ return request.replace(ModuleParts.specifier, "");
48
+ }
49
+
50
+ //? Generated barrels, runtime pieces and convention files stay whole: other build steps read them by path.
51
+ static splits(workspaceRoot: string, file: string): boolean {
52
+ const [kind, , ...rest] = path.relative(workspaceRoot, file).split(path.sep);
53
+ if (kind !== "apps" && kind !== "libs") return false;
54
+ if (rest.length < 2 || rest.includes("node_modules") || rest.includes(".akan")) return false;
55
+ if (rest[0] === "lib" && (rest.length < 3 || rest[1] === "__client")) return false;
56
+ const base = rest[rest.length - 1] ?? "";
57
+ return SOURCE_FILE.test(base) && !CONVENTION_FILE.test(base) && !/^index\.tsx?$/.test(base);
58
+ }
59
+
60
+ async load(request: string): Promise<string | null> {
61
+ const file = PartModules.fileOf(request);
62
+ const id = request.match(ModuleParts.specifier)?.[1];
63
+ const loaded = await this.#loadedOf(file);
64
+ if (!loaded) return null;
65
+ if (loaded.settled) return loaded.source;
66
+ const text = id ? loaded.parts?.sourceOf(id, file) : (loaded.parts?.facade(file) ?? loaded.source);
67
+ if (typeof text !== "string") throw new Error(`[akan] ${file} was asked for a part it does not have: ${id}`);
68
+ return (await this.#imports.rewrite(text, file)) ?? text;
69
+ }
70
+
71
+ #loadedOf(file: string): Promise<Loaded | null> {
72
+ const known = this.#loaded.get(file);
73
+ if (known) return known;
74
+ const loaded = this.#options.read(file).then((read) => {
75
+ if (!read) return null;
76
+ return { ...read, parts: read.settled || !this.#splits(file) ? null : this.#partsOf(file, read.source) };
77
+ });
78
+ this.#loaded.set(file, loaded);
79
+ return loaded;
80
+ }
81
+
82
+ #partsOf(file: string, source: string): ModuleParts | null {
83
+ const key = `${file}\n${Bun.hash(source).toString(36)}`;
84
+ const known = this.#options.cache.get(key);
85
+ if (known !== undefined) return known;
86
+ const parts = ModuleParts.read(source, file);
87
+ this.#options.cache.set(key, parts);
88
+ return parts;
89
+ }
90
+ }
@@ -0,0 +1,124 @@
1
+ import ts from "typescript";
2
+
3
+ const REACT_WRAPPERS = new Set(["memo", "forwardRef", "lazy", "createContext"]);
4
+ const FRESH_COLLECTIONS = new Set(["Map", "Set", "WeakMap", "WeakSet"]);
5
+
6
+ //* Whether evaluating an expression only builds a value: a module holding nothing else can load later than its
7
+ //* neighbours, or not at all, and no other module can tell. A call is unknown unless React's own wrappers make it.
8
+ export class PartPurity {
9
+ readonly #reactNames = new Set<string>();
10
+ readonly #reactObjects = new Set<string>();
11
+
12
+ note(statement: ts.ImportDeclaration) {
13
+ const clause = statement.importClause;
14
+ if (!clause || !ts.isStringLiteral(statement.moduleSpecifier) || statement.moduleSpecifier.text !== "react") return;
15
+ if (clause.name) this.#reactObjects.add(clause.name.text);
16
+ const bindings = clause.namedBindings;
17
+ if (!bindings) return;
18
+ if (ts.isNamespaceImport(bindings)) this.#reactObjects.add(bindings.name.text);
19
+ else
20
+ for (const element of bindings.elements)
21
+ if (REACT_WRAPPERS.has((element.propertyName ?? element.name).text)) this.#reactNames.add(element.name.text);
22
+ }
23
+
24
+ of(node: ts.Expression): boolean {
25
+ if (ts.isLiteralExpression(node) || ts.isIdentifier(node)) return true;
26
+ if (ts.isArrowFunction(node) || ts.isFunctionExpression(node)) return true;
27
+ switch (node.kind) {
28
+ case ts.SyntaxKind.TrueKeyword:
29
+ case ts.SyntaxKind.FalseKeyword:
30
+ case ts.SyntaxKind.NullKeyword:
31
+ return true;
32
+ }
33
+ if (ts.isClassExpression(node)) return this.ofClass(node);
34
+ if (
35
+ ts.isParenthesizedExpression(node) ||
36
+ ts.isAsExpression(node) ||
37
+ ts.isSatisfiesExpression(node) ||
38
+ ts.isNonNullExpression(node) ||
39
+ ts.isTypeAssertionExpression(node) ||
40
+ ts.isTypeOfExpression(node) ||
41
+ ts.isVoidExpression(node) ||
42
+ ts.isPropertyAccessExpression(node)
43
+ )
44
+ return this.of(node.expression);
45
+ if (ts.isElementAccessExpression(node)) return this.of(node.expression) && this.of(node.argumentExpression);
46
+ if (ts.isTemplateExpression(node)) return node.templateSpans.every((span) => this.of(span.expression));
47
+ if (ts.isPrefixUnaryExpression(node))
48
+ return (
49
+ node.operator !== ts.SyntaxKind.PlusPlusToken &&
50
+ node.operator !== ts.SyntaxKind.MinusMinusToken &&
51
+ this.of(node.operand)
52
+ );
53
+ if (ts.isBinaryExpression(node))
54
+ return !PartPurity.#assigns(node.operatorToken.kind) && this.of(node.left) && this.of(node.right);
55
+ if (ts.isConditionalExpression(node))
56
+ return this.of(node.condition) && this.of(node.whenTrue) && this.of(node.whenFalse);
57
+ if (ts.isArrayLiteralExpression(node))
58
+ return node.elements.every(
59
+ (element) =>
60
+ ts.isOmittedExpression(element) || this.of(ts.isSpreadElement(element) ? element.expression : element),
61
+ );
62
+ if (ts.isObjectLiteralExpression(node)) return node.properties.every((property) => this.#ofProperty(property));
63
+ if (ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node) || ts.isJsxFragment(node)) return this.#ofJsx(node);
64
+ if (ts.isCallExpression(node))
65
+ return this.#wraps(node.expression) && node.arguments.every((argument) => this.of(argument));
66
+ if (ts.isNewExpression(node))
67
+ return (
68
+ ts.isIdentifier(node.expression) &&
69
+ FRESH_COLLECTIONS.has(node.expression.text) &&
70
+ (node.arguments ?? []).every((argument) => this.of(argument))
71
+ );
72
+ return false;
73
+ }
74
+
75
+ ofClass(node: ts.ClassLikeDeclaration): boolean {
76
+ if (ts.canHaveDecorators(node) && ts.getDecorators(node)?.length) return false;
77
+ for (const clause of node.heritageClauses ?? [])
78
+ if (clause.token === ts.SyntaxKind.ExtendsKeyword && !clause.types.every((type) => this.of(type.expression)))
79
+ return false;
80
+ return node.members.every((member) => {
81
+ if (ts.isClassStaticBlockDeclaration(member)) return false;
82
+ if (ts.canHaveDecorators(member) && ts.getDecorators(member)?.length) return false;
83
+ if (member.name && ts.isComputedPropertyName(member.name) && !this.of(member.name.expression)) return false;
84
+ if (!ts.isPropertyDeclaration(member) || !member.initializer) return true;
85
+ const isStatic = (ts.getModifiers(member) ?? []).some(({ kind }) => kind === ts.SyntaxKind.StaticKeyword);
86
+ return !isStatic || this.of(member.initializer);
87
+ });
88
+ }
89
+
90
+ #ofProperty(property: ts.ObjectLiteralElementLike): boolean {
91
+ if (property.name && ts.isComputedPropertyName(property.name) && !this.of(property.name.expression)) return false;
92
+ if (ts.isPropertyAssignment(property)) return this.of(property.initializer);
93
+ if (ts.isSpreadAssignment(property)) return this.of(property.expression);
94
+ return true;
95
+ }
96
+
97
+ #ofJsx(node: ts.JsxElement | ts.JsxSelfClosingElement | ts.JsxFragment): boolean {
98
+ const opening = ts.isJsxElement(node) ? node.openingElement : ts.isJsxSelfClosingElement(node) ? node : null;
99
+ const attributes = opening?.attributes.properties ?? [];
100
+ const ofValue = (value: ts.JsxAttributeValue | ts.JsxChild | undefined): boolean => {
101
+ if (!value || ts.isStringLiteral(value) || ts.isJsxText(value)) return true;
102
+ if (ts.isJsxExpression(value)) return !value.expression || this.of(value.expression);
103
+ return this.#ofJsx(value);
104
+ };
105
+ const held = attributes.every((attribute) =>
106
+ ts.isJsxSpreadAttribute(attribute) ? this.of(attribute.expression) : ofValue(attribute.initializer),
107
+ );
108
+ return held && (ts.isJsxSelfClosingElement(node) || node.children.every(ofValue));
109
+ }
110
+
111
+ #wraps(callee: ts.Expression): boolean {
112
+ if (ts.isIdentifier(callee)) return this.#reactNames.has(callee.text);
113
+ return (
114
+ ts.isPropertyAccessExpression(callee) &&
115
+ ts.isIdentifier(callee.expression) &&
116
+ this.#reactObjects.has(callee.expression.text) &&
117
+ REACT_WRAPPERS.has(callee.name.text)
118
+ );
119
+ }
120
+
121
+ static #assigns(kind: ts.SyntaxKind): boolean {
122
+ return kind >= ts.SyntaxKind.FirstAssignment && kind <= ts.SyntaxKind.LastAssignment;
123
+ }
124
+ }