@akanjs/devkit 3.2.0-rc.3 → 3.2.0-rc.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +367 -11
- package/DEV_RUNTIME_KNOBS.md +4 -3
- package/README.ko.md +3 -2
- package/README.md +4 -2
- package/akanApp/BackendImportGraph.test.ts +1 -1
- package/akanApp/akanApp.host.test.ts +257 -1
- package/akanApp/akanApp.host.ts +146 -1223
- package/akanApp/akanApp.host.wiring.test.ts +727 -0
- package/akanApp/builderGap.ts +68 -0
- package/akanApp/builderRequestRelay.test.ts +93 -0
- package/akanApp/builderRequestRelay.ts +100 -0
- package/akanApp/builderRssRecycler.ts +182 -0
- package/akanApp/devBackend.ts +392 -0
- package/akanApp/devBuildStatusBoard.ts +128 -0
- package/akanApp/devBuilder.ts +196 -0
- package/akanApp/devHostPolicy.test.ts +11 -11
- package/akanApp/devHostPolicy.ts +2 -4
- package/akanApp/devIdleSuspend.test.ts +221 -0
- package/akanApp/devIdleSuspend.ts +192 -0
- package/akanApp/devIdleSuspend.watcher.test.ts +120 -0
- package/akanApp/devRecycler.test.ts +66 -0
- package/akanApp/devRecycler.ts +305 -0
- package/akanApp/processRss.ts +61 -0
- package/akanConfig/akanConfig.test.ts +24 -1
- package/akanConfig/akanConfig.ts +10 -10
- package/akanConfig/akanWorkspaceConfig.ts +1 -1
- package/akanConfig/productionLockfile.ts +1 -1
- package/apiReport/apiDeclarationPrinter.ts +120 -0
- package/apiReport/apiReport.test.ts +526 -0
- package/apiReport/apiReport.ts +232 -0
- package/apiReport/apiReportDiff.ts +160 -0
- package/apiReport/apiReportPolicy.ts +65 -0
- package/apiReport/apiTargets.ts +311 -0
- package/apiReport/changesetBump.ts +19 -0
- package/{applicationBuildReporter.test.ts → app/applicationBuildReporter.test.ts} +21 -0
- package/{applicationBuildReporter.ts → app/applicationBuildReporter.ts} +10 -49
- package/{applicationBuildRunner.test.ts → app/applicationBuildRunner.test.ts} +74 -7
- package/{applicationBuildRunner.ts → app/applicationBuildRunner.ts} +20 -15
- package/{applicationTestPreload.ts → app/applicationTestPreload.ts} +1 -1
- package/{routeJsBudget.test.ts → app/routeJsBudget.test.ts} +48 -12
- package/{routeJsBudget.ts → app/routeJsBudget.ts} +90 -27
- package/{routeSourceValidator.test.ts → app/routeSourceValidator.test.ts} +17 -0
- package/{routeSourceValidator.ts → app/routeSourceValidator.ts} +5 -1
- package/artifact/implicitRootLayout.test.ts +71 -3
- package/artifact/implicitRootLayout.ts +21 -4
- package/artifact/implicitRootLayoutRender.test.tsx +297 -0
- package/biome.base.json +2 -1
- package/cloud/cloudApi.test.ts +1 -1
- package/cloud/configLock.test.ts +1 -1
- package/cloud/globalConfig.test.ts +1 -1
- package/cloud/globalConfig.ts +1 -1
- package/cloud/updatePackUpload.test.ts +1 -1
- package/codeAgent/agent/AkanCodeEnv.ts +1 -1
- package/codeAgent/agent/akanCodePaths.ts +1 -1
- package/codeAgent/agent/akanSystemPrompt.ts +1 -1
- package/codeAgent/agent/codeAgent.test.ts +1 -1
- package/codeAgent/skills/akan-debug/SKILL.md +10 -3
- package/codeAgent/skills/akan-err/SKILL.md +7 -0
- package/codeAgent/skills/akan-mcp/SKILL.md +14 -2
- package/codeAgent/skills/akan-scaffold/SKILL.md +2 -2
- package/codeAgent/skills/akan-transport/SKILL.md +2 -0
- package/codeAgent/skills/akan-validate/SKILL.md +1 -0
- package/codeAgent/tools/AkanCli.ts +1 -1
- package/codeAgent/tools/AkanToolPack.ts +1 -1
- package/codeAgent/tools/McpClient.ts +28 -6
- package/codeAgent/tools/McpToolPack.ts +1 -1
- package/codeAgent/tools/akanCodePlugins.test.ts +14 -2
- package/commandDecorators/argMeta.ts +4 -0
- package/commandDecorators/cliError.ts +72 -0
- package/commandDecorators/command.ts +165 -91
- package/commandDecorators/commandBuilder.ts +1 -1
- package/commandDecorators/commandDecorators.test.ts +191 -16
- package/commandDecorators/exitCodeError.ts +6 -7
- package/commandDecorators/index.ts +1 -0
- package/commandDecorators/targetMeta.ts +1 -0
- package/commandDecorators/workspaceVersionCheck.test.ts +1 -1
- package/commandDecorators/workspaceVersionCheck.ts +1 -1
- package/context/akanContext.ts +576 -0
- package/context/akanContextInspection.ts +296 -0
- package/{akanMcpContract.test.ts → context/akanMcpContract.test.ts} +1 -1
- package/{akanMcpContract.ts → context/akanMcpContract.ts} +32 -262
- package/context/akanMcpToolError.ts +16 -0
- package/context/doctor/agentGuideCheck.ts +81 -0
- package/context/doctor/configLeftoverCheck.ts +35 -0
- package/context/doctor/doctorFindings.ts +70 -0
- package/context/doctor/generatedFreshness.ts +56 -0
- package/context/doctor/moduleShapeCheck.ts +88 -0
- package/context/doctor/recipeDuplicateCheck.ts +39 -0
- package/context/doctor/recipeIndexCheck.ts +87 -0
- package/context/doctor/rootShapeCheck.ts +55 -0
- package/context/doctor/workflowScope.ts +97 -0
- package/{constantFieldNames.test.ts → context/moduleFieldNames.test.ts} +24 -2
- package/context/moduleFieldNames.ts +25 -0
- package/{recipeScanner.test.ts → context/recipeScanner.test.ts} +1 -1
- package/context/safeRead.ts +9 -0
- package/csrE2e/csrE2eHarness.fixture.ts +1 -1
- package/devkitUtils.test.ts +39 -5
- package/{apiReference.test.ts → docs/apiReference.test.ts} +4 -4
- package/{apiReference.ts → docs/apiReference.ts} +2 -2
- package/docs/errorCodeReference.test.ts +282 -0
- package/docs/errorCodeReference.ts +71 -0
- package/docs/errorCodeScan.ts +551 -0
- package/{frameworkGraph.test.ts → docs/frameworkGraph.test.ts} +1 -1
- package/executors/appExecutor.ts +448 -0
- package/executors/commandExecutionError.ts +53 -0
- package/executors/executor.ts +527 -0
- package/{executors.linkFallback.test.ts → executors/executors.linkFallback.test.ts} +1 -1
- package/{executors.test.ts → executors/executors.test.ts} +76 -15
- package/executors/index.ts +8 -0
- package/executors/libExecutor.ts +23 -0
- package/executors/moduleExecutor.ts +18 -0
- package/executors/pkgExecutor.ts +129 -0
- package/executors/sysExecutor.ts +301 -0
- package/executors/workspaceExecutor.ts +277 -0
- package/frontendBuild/allRoutesBuilder.test.ts +17 -5
- package/frontendBuild/allRoutesBuilder.ts +24 -6
- package/frontendBuild/autoImportSync.test.ts +1 -1
- package/frontendBuild/autoImportSync.ts +1 -1
- package/frontendBuild/buildRouteClient.test.ts +1 -1
- package/frontendBuild/bundleDefine.ts +2 -0
- package/frontendBuild/clientBuildTypes.ts +5 -2
- package/frontendBuild/clientEntriesBundler.test.ts +1 -1
- package/frontendBuild/clientEntryDiscovery.test.ts +28 -0
- package/frontendBuild/clientEntryDiscovery.ts +25 -6
- package/frontendBuild/csrArtifactBuilder.test.ts +1 -1
- package/frontendBuild/csrDevArtifactWriter.ts +1 -1
- package/frontendBuild/cssCompiler.test.ts +1 -1
- package/frontendBuild/devGeneratedIndexSync.test.ts +1 -1
- package/frontendBuild/devGeneratedIndexSync.ts +7 -38
- package/frontendBuild/dictionaryAssetBuilder.test.ts +1 -1
- package/frontendBuild/fontOptimizer.test.ts +1 -1
- package/frontendBuild/fontPruner.test.ts +1 -1
- package/frontendBuild/frontendBuild.test.ts +3 -3
- package/frontendBuild/hmrWatcher.stop.test.ts +63 -0
- package/frontendBuild/hmrWatcher.test.ts +1 -1
- package/frontendBuild/hmrWatcher.ts +22 -1
- package/frontendBuild/mcpAppViewBuilder.test.ts +1 -1
- package/frontendBuild/mcpAppViewBuilder.ts +1 -1
- package/frontendBuild/nativeCore.test.ts +148 -0
- package/frontendBuild/optionalPeers.test.ts +36 -8
- package/frontendBuild/pagesBundleBuilder.test.ts +2 -3
- package/frontendBuild/pagesBundleBuilder.ts +1 -1
- package/frontendBuild/precompressArtifacts.test.ts +1 -1
- package/frontendBuild/precompressArtifacts.ts +1 -1
- package/frontendBuild/serverGraphFile.ts +1 -1
- package/frontendBuild/sourceMtimeIndex.test.ts +1 -1
- package/frontendBuild/ssrBaseArtifactBuilder.test.ts +26 -0
- package/frontendBuild/ssrBaseArtifactBuilder.ts +23 -19
- package/frontendBuild/ssrDevBundler.test.ts +1 -1
- package/frontendBuild/vendorImportScanner.test.ts +25 -4
- package/frontendBuild/vendorImportScanner.ts +25 -10
- package/frontendBuild/vendorNarrowing.test.ts +1 -1
- package/frontendBuild/watchRootResolver.test.ts +1 -1
- package/{agentAssets.test.ts → guideline/agentAssets.test.ts} +1 -1
- package/{agentAssets.ts → guideline/agentAssets.ts} +2 -2
- package/{agentsIndex.test.ts → guideline/agentsIndex.test.ts} +2 -2
- package/{agentsIndex.ts → guideline/agentsIndex.ts} +13 -10
- package/{conventionSet.test.ts → guideline/conventionSet.test.ts} +7 -4
- package/{conventionSet.ts → guideline/conventionSet.ts} +1 -1
- package/{prompter.ts → guideline/prompter.ts} +2 -3
- package/incrementalBuilder/buildBatch.proc.ts +14 -4
- package/incrementalBuilder/buildBatchProtocol.ts +2 -0
- package/incrementalBuilder/buildBatchRunner.test.ts +108 -1
- package/incrementalBuilder/buildBatchRunner.ts +17 -4
- package/incrementalBuilder/builderBoot.ts +106 -0
- package/incrementalBuilder/builderBuildStatus.ts +23 -0
- package/incrementalBuilder/builderChannel.test.ts +1 -1
- package/incrementalBuilder/builderChannel.ts +11 -0
- package/incrementalBuilder/builderGraphPayloads.ts +3 -3
- package/incrementalBuilder/builderLanes.ts +157 -0
- package/incrementalBuilder/builderWatch.ts +213 -0
- package/incrementalBuilder/csrRegistry.ts +234 -0
- package/incrementalBuilder/incrementalBuilder.host.test.ts +30 -1
- package/incrementalBuilder/incrementalBuilder.host.ts +10 -22
- package/incrementalBuilder/incrementalBuilder.proc.test.ts +93 -2
- package/incrementalBuilder/incrementalBuilder.proc.ts +81 -823
- package/incrementalBuilder/ssrRegistry.ts +278 -0
- package/index.ts +22 -22
- package/integration/devStability.integration.test.ts +62 -56
- package/integration/devStabilityHarness.test.ts +1 -1
- package/lint/__fixtures__/no-import-common-err/bad.tsx +13 -0
- package/lint/__fixtures__/no-import-common-err/good.tsx +12 -0
- package/{biomeBase.test.ts → lint/biomeBase.test.ts} +1 -1
- package/lint/gritRules.test.ts +1 -1
- package/{linter.test.ts → lint/linter.test.ts} +1 -1
- package/lint/no-import-common-err.grit +31 -0
- package/lint/no-init-fetch-in-client.grit +1 -1
- package/lint/no-web-only-api-outside-webkit.grit +3 -3
- package/mobile/desktopBin.test.ts +1 -1
- package/mobile/desktopRelease.test.ts +1 -1
- package/mobile/desktopServerStage.test.ts +2 -2
- package/mobile/desktopServerStage.ts +1 -1
- package/mobile/nativeApi.test.ts +1 -1
- package/mobile/nativeApp.test.ts +1 -1
- package/mobile/nativeConfig.test.ts +1 -1
- package/mobile/nativePluginFolders.test.ts +1 -1
- package/mobile/nativePublicEnv.test.ts +1 -1
- package/mobile/nativeWebDir.test.ts +1 -1
- package/mobile/serverBundleSecrets.test.ts +1 -1
- package/mobile/tarWriter.test.ts +1 -1
- package/mobile/updatePackFolder.test.ts +1 -1
- package/package.json +167 -3
- package/packageExports.test.ts +20 -2
- package/piDependencyPins.test.ts +1 -1
- package/pipeline/PipelineDefinition.ts +1 -1
- package/platformTest/IdleWatchedProcess.test.ts +1 -1
- package/platformTest/PlatformTestRun.test.ts +1 -1
- package/platformTest/TestSnapshot.test.ts +1 -1
- package/preview/PreviewView.ts +32 -13
- package/preview/previewView.test.ts +33 -3
- package/{abstractDoc.test.ts → quality/abstractDoc.test.ts} +2 -2
- package/{abstractDoc.ts → quality/abstractDoc.ts} +1 -1
- package/quality/bareErrorScanner.ts +126 -0
- package/{maintainabilityBaseline.test.ts → quality/maintainabilityBaseline.test.ts} +73 -0
- package/{maintainabilityBaseline.ts → quality/maintainabilityBaseline.ts} +97 -9
- package/{maintainabilityContract.test.ts → quality/maintainabilityContract.test.ts} +383 -2
- package/{maintainabilityContract.ts → quality/maintainabilityContract.ts} +151 -29
- package/{maintainabilityExceptionScanner.test.ts → quality/maintainabilityExceptionScanner.test.ts} +15 -1
- package/{maintainabilityExceptionScanner.ts → quality/maintainabilityExceptionScanner.ts} +5 -1
- package/{maintainabilityLimits.ts → quality/maintainabilityLimits.ts} +12 -0
- package/{maintainabilityReport.ts → quality/maintainabilityReport.ts} +20 -3
- package/{qualityScanner.test.ts → quality/qualityScanner.test.ts} +1 -1
- package/{qualityScanner.ts → quality/qualityScanner.ts} +8 -8
- package/{storeAccessScanner.ts → quality/storeAccessScanner.ts} +15 -2
- package/{subspace.test.ts → subspace/subspace.test.ts} +25 -4
- package/{subspace.ts → subspace/subspace.ts} +5 -5
- package/{subspaceClone.ts → subspace/subspaceClone.ts} +8 -8
- package/{subspaceConfig.ts → subspace/subspaceConfig.ts} +5 -1
- package/{testHelpers.ts → test/testHelpers.ts} +37 -1
- package/transforms/barrelAnalyzer.ts +31 -10
- package/transforms/browserDirnamePlugin.test.ts +1 -1
- package/transforms/externalizeFrameworkPlugin.test.ts +1 -1
- package/transforms/mcpAppPageTrimmer.test.ts +1 -1
- package/transforms/pureLazyMarker.test.ts +1 -1
- package/transforms/serverEnvPlugin.test.ts +1 -1
- package/transforms/serverEnvProfile.test.ts +1 -1
- package/transforms/sideEffectImportOrder.test.ts +1 -1
- package/transforms/transforms.test.ts +52 -2
- package/transforms/tsconfigPackageResolver.test.ts +1 -1
- package/{createTunnel.test.ts → tunnel/createTunnel.test.ts} +1 -1
- package/{createTunnel.ts → tunnel/createTunnel.ts} +2 -2
- package/{sshHostKeys.ts → tunnel/sshHostKeys.ts} +2 -2
- package/typecheck/projectTypecheck.test.ts +1 -1
- package/typecheck/projectTypecheck.ts +6 -2
- package/{typeChecker.test.ts → typecheck/typeChecker.test.ts} +1 -1
- package/{typeChecker.ts → typecheck/typeChecker.ts} +1 -1
- package/typecheck/typecheck.proc.ts +4 -3
- package/typecheck/typecheckFailure.ts +7 -2
- package/util/errorReport.ts +66 -0
- package/{jsonFormatter.test.ts → util/jsonFormatter.test.ts} +1 -1
- package/workflow/artifacts.ts +8 -7
- package/workflow/constantSource.ts +187 -0
- package/workflow/dictionarySource.ts +184 -0
- package/workflow/executor.ts +6 -9
- package/workflow/fieldExpression.ts +153 -0
- package/workflow/fieldLabel.ts +61 -0
- package/workflow/fieldOrder.ts +117 -0
- package/workflow/fieldType.ts +93 -0
- package/workflow/guardCatalog.test.ts +1 -1
- package/workflow/index.ts +1 -0
- package/workflow/keyRename.ts +1 -1
- package/workflow/moduleIndex.test.ts +2 -2
- package/workflow/moduleIndex.ts +2 -2
- package/workflow/modulePaths.ts +27 -0
- package/workflow/mutationScaffold.ts +7 -15
- package/workflow/mutationSource.ts +2 -1
- package/workflow/plainName.ts +16 -3
- package/workflow/plan.ts +14 -2
- package/workflow/primitiveReport.ts +78 -0
- package/workflow/rolloutGate.test.ts +1 -1
- package/workflow/rolloutGate.ts +1 -1
- package/workflow/serviceSource.ts +33 -0
- package/workflow/signalSource.ts +96 -0
- package/workflow/source.ts +50 -1105
- package/workflow/sourceAst.ts +30 -0
- package/workflow/sourceImports.ts +105 -0
- package/workflow/sourceText.ts +13 -0
- package/workflow/templateSource.ts +30 -0
- package/workflow/testSource.ts +31 -0
- package/workflow/types.ts +1 -1
- package/workflow/uiPolicy.ts +1 -1
- package/{appSelectionMemory.ts → workspace/appSelectionMemory.ts} +1 -1
- package/{codegenLock.test.ts → workspace/codegenLock.test.ts} +1 -1
- package/{dependencyScanner.test.ts → workspace/dependencyScanner.test.ts} +1 -1
- package/{dependencyScanner.ts → workspace/dependencyScanner.ts} +2 -2
- package/{envSeed.test.ts → workspace/envSeed.test.ts} +2 -2
- package/{envSeed.ts → workspace/envSeed.ts} +1 -1
- package/{libSource.test.ts → workspace/libSource.test.ts} +2 -2
- package/{libSource.ts → workspace/libSource.ts} +1 -1
- package/{scanInfo.ts → workspace/scanInfo.ts} +21 -10
- package/{slicePlanner.test.ts → workspace/slicePlanner.test.ts} +2 -2
- package/{slicePlanner.ts → workspace/slicePlanner.ts} +1 -1
- package/{workspaceGraph.test.ts → workspace/workspaceGraph.test.ts} +1 -1
- package/{workspaceGraph.ts → workspace/workspaceGraph.ts} +1 -1
- package/{workspaceLayout.test.ts → workspace/workspaceLayout.test.ts} +1 -1
- package/{workspaceLayout.ts → workspace/workspaceLayout.ts} +3 -1
- package/akanContext.ts +0 -1084
- package/constantFieldNames.ts +0 -18
- package/executors.ts +0 -1749
- /package/{recipeScanner.ts → context/recipeScanner.ts} +0 -0
- /package/{declarationReader.ts → docs/declarationReader.ts} +0 -0
- /package/{frameworkGraph.ts → docs/frameworkGraph.ts} +0 -0
- /package/{biomeBase.ts → lint/biomeBase.ts} +0 -0
- /package/{linter.ts → lint/linter.ts} +0 -0
- /package/{commentDensityScanner.test.ts → quality/commentDensityScanner.test.ts} +0 -0
- /package/{commentDensityScanner.ts → quality/commentDensityScanner.ts} +0 -0
- /package/{componentSizeScanner.test.ts → quality/componentSizeScanner.test.ts} +0 -0
- /package/{componentSizeScanner.ts → quality/componentSizeScanner.ts} +0 -0
- /package/{componentWriteChainScanner.test.ts → quality/componentWriteChainScanner.test.ts} +0 -0
- /package/{componentWriteChainScanner.ts → quality/componentWriteChainScanner.ts} +0 -0
- /package/{deprecatedCommentScanner.test.ts → quality/deprecatedCommentScanner.test.ts} +0 -0
- /package/{deprecatedCommentScanner.ts → quality/deprecatedCommentScanner.ts} +0 -0
- /package/{endpointReach.test.ts → quality/endpointReach.test.ts} +0 -0
- /package/{endpointReach.ts → quality/endpointReach.ts} +0 -0
- /package/{formSetterScanner.test.ts → quality/formSetterScanner.test.ts} +0 -0
- /package/{formSetterScanner.ts → quality/formSetterScanner.ts} +0 -0
- /package/{kindBranchScanner.test.ts → quality/kindBranchScanner.test.ts} +0 -0
- /package/{kindBranchScanner.ts → quality/kindBranchScanner.ts} +0 -0
- /package/{maintainabilityReport.test.ts → quality/maintainabilityReport.test.ts} +0 -0
- /package/{renderMutationScanner.test.ts → quality/renderMutationScanner.test.ts} +0 -0
- /package/{renderMutationScanner.ts → quality/renderMutationScanner.ts} +0 -0
- /package/{serviceLoopCallScanner.test.ts → quality/serviceLoopCallScanner.test.ts} +0 -0
- /package/{serviceLoopCallScanner.ts → quality/serviceLoopCallScanner.ts} +0 -0
- /package/{signalMutationIndex.test.ts → quality/signalMutationIndex.test.ts} +0 -0
- /package/{signalMutationIndex.ts → quality/signalMutationIndex.ts} +0 -0
- /package/{sourceComments.test.ts → quality/sourceComments.test.ts} +0 -0
- /package/{sourceComments.ts → quality/sourceComments.ts} +0 -0
- /package/{ssrScanner.test.ts → quality/ssrScanner.test.ts} +0 -0
- /package/{ssrScanner.ts → quality/ssrScanner.ts} +0 -0
- /package/{storeAccessScanner.test.ts → quality/storeAccessScanner.test.ts} +0 -0
- /package/{storeSource.ts → quality/storeSource.ts} +0 -0
- /package/{storeWriteScanner.test.ts → quality/storeWriteScanner.test.ts} +0 -0
- /package/{storeWriteScanner.ts → quality/storeWriteScanner.ts} +0 -0
- /package/{structureScanner.test.ts → quality/structureScanner.test.ts} +0 -0
- /package/{structureScanner.ts → quality/structureScanner.ts} +0 -0
- /package/{testOnlyExportScanner.test.ts → quality/testOnlyExportScanner.test.ts} +0 -0
- /package/{testOnlyExportScanner.ts → quality/testOnlyExportScanner.ts} +0 -0
- /package/{writePath.test.ts → quality/writePath.test.ts} +0 -0
- /package/{writePath.ts → quality/writePath.ts} +0 -0
- /package/{writePlacementScanner.test.ts → quality/writePlacementScanner.test.ts} +0 -0
- /package/{writePlacementScanner.ts → quality/writePlacementScanner.ts} +0 -0
- /package/{writingActionIndex.test.ts → quality/writingActionIndex.test.ts} +0 -0
- /package/{writingActionIndex.ts → quality/writingActionIndex.ts} +0 -0
- /package/{subspaceReport.ts → subspace/subspaceReport.ts} +0 -0
- /package/{sshTunnel.ts → tunnel/sshTunnel.ts} +0 -0
- /package/{fileEditor.ts → util/fileEditor.ts} +0 -0
- /package/{fileSys.test.ts → util/fileSys.test.ts} +0 -0
- /package/{fileSys.ts → util/fileSys.ts} +0 -0
- /package/{jsonFormatter.ts → util/jsonFormatter.ts} +0 -0
- /package/{selectModel.ts → util/selectModel.ts} +0 -0
- /package/{semver.test.ts → util/semver.test.ts} +0 -0
- /package/{semver.ts → util/semver.ts} +0 -0
- /package/{shellOnlyEnv.test.ts → util/shellOnlyEnv.test.ts} +0 -0
- /package/{shellOnlyEnv.ts → util/shellOnlyEnv.ts} +0 -0
- /package/{spinner.test.ts → util/spinner.test.ts} +0 -0
- /package/{spinner.ts → util/spinner.ts} +0 -0
- /package/{stripAnsi.ts → util/stripAnsi.ts} +0 -0
- /package/{codegenLock.ts → workspace/codegenLock.ts} +0 -0
- /package/{getRelatedCnsts.ts → workspace/getRelatedCnsts.ts} +0 -0
- /package/{gitRevision.test.ts → workspace/gitRevision.test.ts} +0 -0
- /package/{gitRevision.ts → workspace/gitRevision.ts} +0 -0
- /package/{manifestDependencies.ts → workspace/manifestDependencies.ts} +0 -0
- /package/{packageExportsMap.ts → workspace/packageExportsMap.ts} +0 -0
- /package/{repoIdentity.ts → workspace/repoIdentity.ts} +0 -0
- /package/{types.ts → workspace/types.ts} +0 -0
|
@@ -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(
|
|
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
|
|
120
|
-
|
|
121
|
-
|
|
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()
|
|
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, {
|
|
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
|
-
|
|
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
|
-
|
|
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, {
|
|
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, {
|
|
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
|
|
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
|
+
});
|
|
@@ -153,25 +153,10 @@ export class SsrBaseArtifactBuilder {
|
|
|
153
153
|
const rscClientUrl = clientBundle.entryUrlsByAbsPath.get(rscClientEntry) ?? "";
|
|
154
154
|
const rscRuntimeSsrManifest = {
|
|
155
155
|
moduleLoading: null,
|
|
156
|
-
moduleMap:
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
if (
|
|
161
|
-
!ssrOutput ||
|
|
162
|
-
key !== `${clientBundle.clientReferenceIdByAbsPath.get(rscSegmentOutletEntry)}#${row.name}`
|
|
163
|
-
) {
|
|
164
|
-
return null;
|
|
165
|
-
}
|
|
166
|
-
return [
|
|
167
|
-
row.id,
|
|
168
|
-
{ [row.name]: { id: ssrOutput, chunks: [ssrOutput, ssrOutput], name: row.name, async: true } },
|
|
169
|
-
];
|
|
170
|
-
})
|
|
171
|
-
.filter(
|
|
172
|
-
(entry): entry is [string, Record<string, { id: string; chunks: string[]; name: string; async: true }>] =>
|
|
173
|
-
Boolean(entry),
|
|
174
|
-
),
|
|
156
|
+
moduleMap: SsrBaseArtifactBuilder.outletModuleMap(
|
|
157
|
+
clientBundle.manifest,
|
|
158
|
+
clientBundle.clientReferenceIdByAbsPath.get(rscSegmentOutletEntry),
|
|
159
|
+
ssrBundle.entryOutputAbsByAbsPath.get(rscSegmentOutletEntry),
|
|
175
160
|
),
|
|
176
161
|
};
|
|
177
162
|
const vendorMap = Object.fromEntries(
|
|
@@ -190,6 +175,25 @@ export class SsrBaseArtifactBuilder {
|
|
|
190
175
|
},
|
|
191
176
|
};
|
|
192
177
|
}
|
|
178
|
+
|
|
179
|
+
/** Every export of the outlet module shares one client id, so each joins that id's row instead of replacing it. */
|
|
180
|
+
static outletModuleMap(
|
|
181
|
+
manifest: NonNullable<BaseBuildArtifact["rscRuntimeClientManifest"]>,
|
|
182
|
+
outletReferenceId: string | undefined,
|
|
183
|
+
ssrOutput: string | undefined,
|
|
184
|
+
) {
|
|
185
|
+
const moduleMap: Record<string, Record<string, { id: string; chunks: string[]; name: string; async: true }>> = {};
|
|
186
|
+
if (!ssrOutput || !outletReferenceId) return moduleMap;
|
|
187
|
+
for (const [key, row] of Object.entries(manifest)) {
|
|
188
|
+
if (key !== `${outletReferenceId}#${row.name}`) continue;
|
|
189
|
+
moduleMap[row.id] = {
|
|
190
|
+
...moduleMap[row.id],
|
|
191
|
+
[row.name]: { id: ssrOutput, chunks: [ssrOutput, ssrOutput], name: row.name, async: true },
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
return moduleMap;
|
|
195
|
+
}
|
|
196
|
+
|
|
193
197
|
async #resolveAkanServerPath() {
|
|
194
198
|
const candidates: string[] = [];
|
|
195
199
|
try {
|
|
@@ -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 { SsrDevBundler } from "./ssrDevBundler";
|
|
5
5
|
|
|
6
6
|
const makeTempRoot = tempDirs("akan-ssr-dev-bundler-");
|