@codeyam/codeyam-cli 0.1.0-staging.ad88eeb → 0.1.0-staging.b147f46
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/analyzer-template/.build-info.json +8 -8
- package/analyzer-template/log.txt +3 -3
- package/analyzer-template/package.json +4 -4
- package/analyzer-template/packages/ai/package.json +1 -1
- package/analyzer-template/packages/ai/src/lib/astScopes/methodSemantics.ts +135 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/nodeToSource.ts +19 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/paths.ts +11 -4
- package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +36 -9
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/ParentScopeManager.ts +10 -3
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.ts +16 -6
- package/analyzer-template/packages/analyze/index.ts +4 -1
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.ts +28 -2
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities.ts +5 -36
- package/analyzer-template/packages/analyze/src/lib/files/analyze/findOrCreateEntity.ts +10 -6
- package/analyzer-template/packages/analyze/src/lib/files/analyze/gatherEntityMap.ts +9 -12
- package/analyzer-template/packages/analyze/src/lib/files/analyze/trackEntityCircularDependencies.ts +21 -0
- package/analyzer-template/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.ts +82 -10
- package/analyzer-template/packages/analyze/src/lib/files/analyzeChange.ts +4 -0
- package/analyzer-template/packages/analyze/src/lib/files/analyzeInitial.ts +4 -0
- package/analyzer-template/packages/analyze/src/lib/files/analyzeNextRoute.ts +8 -3
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +239 -58
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +1684 -1462
- package/analyzer-template/packages/aws/package.json +2 -2
- package/analyzer-template/packages/database/package.json +2 -2
- package/analyzer-template/packages/database/src/lib/kysely/tables/editorScenariosTable.ts +82 -0
- package/analyzer-template/packages/database/src/lib/loadAnalysis.ts +19 -15
- package/analyzer-template/packages/database/src/lib/loadEntities.ts +0 -6
- package/analyzer-template/packages/database/src/lib/loadEntity.ts +19 -8
- package/analyzer-template/packages/database/src/lib/updateCommitMetadata.ts +0 -65
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.d.ts +5 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.js +84 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js +0 -6
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntity.d.ts +4 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntity.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntity.js +5 -5
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntity.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js +0 -25
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.d.ts +3 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.js +22 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.js.map +1 -1
- package/analyzer-template/packages/utils/src/lib/fs/rsyncCopy.ts +27 -0
- package/analyzer-template/project/analyzeFileEntities.ts +26 -0
- package/background/src/lib/virtualized/project/analyzeFileEntities.js +22 -0
- package/background/src/lib/virtualized/project/analyzeFileEntities.js.map +1 -1
- package/codeyam-cli/src/cli.js +24 -0
- package/codeyam-cli/src/cli.js.map +1 -1
- package/codeyam-cli/src/commands/__tests__/editor.analyzeImportsArgs.test.js +47 -0
- package/codeyam-cli/src/commands/__tests__/editor.analyzeImportsArgs.test.js.map +1 -0
- package/codeyam-cli/src/commands/__tests__/editor.auditNoAutoAnalysis.test.js +71 -0
- package/codeyam-cli/src/commands/__tests__/editor.auditNoAutoAnalysis.test.js.map +1 -0
- package/codeyam-cli/src/commands/__tests__/editor.isolateArgs.test.js +51 -0
- package/codeyam-cli/src/commands/__tests__/editor.isolateArgs.test.js.map +1 -0
- package/codeyam-cli/src/commands/__tests__/editor.stepDispatch.test.js +56 -0
- package/codeyam-cli/src/commands/__tests__/editor.stepDispatch.test.js.map +1 -0
- package/codeyam-cli/src/commands/__tests__/init.gitignore.test.js +101 -47
- package/codeyam-cli/src/commands/__tests__/init.gitignore.test.js.map +1 -1
- package/codeyam-cli/src/commands/editor.js +3495 -553
- package/codeyam-cli/src/commands/editor.js.map +1 -1
- package/codeyam-cli/src/commands/editorAnalyzeImportsArgs.js +23 -0
- package/codeyam-cli/src/commands/editorAnalyzeImportsArgs.js.map +1 -0
- package/codeyam-cli/src/commands/editorIsolateArgs.js +25 -0
- package/codeyam-cli/src/commands/editorIsolateArgs.js.map +1 -0
- package/codeyam-cli/src/commands/init.js +69 -34
- package/codeyam-cli/src/commands/init.js.map +1 -1
- package/codeyam-cli/src/commands/telemetry.js +37 -0
- package/codeyam-cli/src/commands/telemetry.js.map +1 -0
- package/codeyam-cli/src/data/techStacks.js +2 -7
- package/codeyam-cli/src/data/techStacks.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/analyzerFinalization.test.js +173 -0
- package/codeyam-cli/src/utils/__tests__/analyzerFinalization.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/backgroundServer.test.js +46 -0
- package/codeyam-cli/src/utils/__tests__/backgroundServer.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorApi.test.js +18 -8
- package/codeyam-cli/src/utils/__tests__/editorApi.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/editorAudit.test.js +3380 -1
- package/codeyam-cli/src/utils/__tests__/editorAudit.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/editorBroadcastViewport.test.js +76 -0
- package/codeyam-cli/src/utils/__tests__/editorBroadcastViewport.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorCaptureScenarioSeeding.test.js +137 -0
- package/codeyam-cli/src/utils/__tests__/editorCaptureScenarioSeeding.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorDeleteScenario.test.js +100 -0
- package/codeyam-cli/src/utils/__tests__/editorDeleteScenario.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorDevServer.test.js +27 -2
- package/codeyam-cli/src/utils/__tests__/editorDevServer.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/editorEntityChangeStatus.test.js +76 -3
- package/codeyam-cli/src/utils/__tests__/editorEntityChangeStatus.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/editorEntityHelpers.test.js +381 -0
- package/codeyam-cli/src/utils/__tests__/editorEntityHelpers.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorGuardMiddleware.test.js +67 -0
- package/codeyam-cli/src/utils/__tests__/editorGuardMiddleware.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorLoaderHelpers.test.js +202 -1
- package/codeyam-cli/src/utils/__tests__/editorLoaderHelpers.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/editorMigration.test.js +435 -0
- package/codeyam-cli/src/utils/__tests__/editorMigration.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorPreview.test.js +96 -1
- package/codeyam-cli/src/utils/__tests__/editorPreview.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/editorProxySession.test.js +47 -1
- package/codeyam-cli/src/utils/__tests__/editorProxySession.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/editorScenarioSwitch.test.js +70 -0
- package/codeyam-cli/src/utils/__tests__/editorScenarioSwitch.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/editorScenarios.test.js +1548 -1
- package/codeyam-cli/src/utils/__tests__/editorScenarios.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/editorSeedAdapter.test.js +117 -1
- package/codeyam-cli/src/utils/__tests__/editorSeedAdapter.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/editorSeedAdapterPrismaValidation.test.js +143 -0
- package/codeyam-cli/src/utils/__tests__/editorSeedAdapterPrismaValidation.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorSessionFilter.test.js +66 -0
- package/codeyam-cli/src/utils/__tests__/editorSessionFilter.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorShouldRevalidate.test.js +53 -0
- package/codeyam-cli/src/utils/__tests__/editorShouldRevalidate.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/entityChangeStatus.test.js +395 -11
- package/codeyam-cli/src/utils/__tests__/entityChangeStatus.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/glossaryAdd.test.js +177 -0
- package/codeyam-cli/src/utils/__tests__/glossaryAdd.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/journalCaptureStabilization.test.js +16 -1
- package/codeyam-cli/src/utils/__tests__/journalCaptureStabilization.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/manualEntityAnalysis.test.js +302 -0
- package/codeyam-cli/src/utils/__tests__/manualEntityAnalysis.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/parseRegisterArg.test.js +30 -2
- package/codeyam-cli/src/utils/__tests__/parseRegisterArg.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/registerScenarioResult.test.js +127 -0
- package/codeyam-cli/src/utils/__tests__/registerScenarioResult.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/routePatternMatching.test.js +118 -0
- package/codeyam-cli/src/utils/__tests__/routePatternMatching.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/scenarioCoverage.test.js +284 -0
- package/codeyam-cli/src/utils/__tests__/scenarioCoverage.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/scenariosManifest.test.js +649 -223
- package/codeyam-cli/src/utils/__tests__/scenariosManifest.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/screenshotHash.test.js +84 -0
- package/codeyam-cli/src/utils/__tests__/screenshotHash.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js +1 -0
- package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/telemetry.test.js +159 -0
- package/codeyam-cli/src/utils/__tests__/telemetry.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/testRunner.test.js +217 -0
- package/codeyam-cli/src/utils/__tests__/testRunner.test.js.map +1 -0
- package/codeyam-cli/src/utils/analysisRunner.js +39 -8
- package/codeyam-cli/src/utils/analysisRunner.js.map +1 -1
- package/codeyam-cli/src/utils/analyzer.js +19 -0
- package/codeyam-cli/src/utils/analyzer.js.map +1 -1
- package/codeyam-cli/src/utils/analyzerFinalization.js +100 -0
- package/codeyam-cli/src/utils/analyzerFinalization.js.map +1 -0
- package/codeyam-cli/src/utils/backgroundServer.js +93 -17
- package/codeyam-cli/src/utils/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/utils/database.js +37 -2
- package/codeyam-cli/src/utils/database.js.map +1 -1
- package/codeyam-cli/src/utils/editorApi.js +11 -5
- package/codeyam-cli/src/utils/editorApi.js.map +1 -1
- package/codeyam-cli/src/utils/editorAudit.js +673 -5
- package/codeyam-cli/src/utils/editorAudit.js.map +1 -1
- package/codeyam-cli/src/utils/editorBroadcastViewport.js +26 -0
- package/codeyam-cli/src/utils/editorBroadcastViewport.js.map +1 -0
- package/codeyam-cli/src/utils/editorDeleteScenario.js +67 -0
- package/codeyam-cli/src/utils/editorDeleteScenario.js.map +1 -0
- package/codeyam-cli/src/utils/editorDevServer.js +5 -1
- package/codeyam-cli/src/utils/editorDevServer.js.map +1 -1
- package/codeyam-cli/src/utils/editorEntityChangeStatus.js +13 -7
- package/codeyam-cli/src/utils/editorEntityChangeStatus.js.map +1 -1
- package/codeyam-cli/src/utils/editorEntityHelpers.js +144 -0
- package/codeyam-cli/src/utils/editorEntityHelpers.js.map +1 -0
- package/codeyam-cli/src/utils/editorGuard.js +36 -0
- package/codeyam-cli/src/utils/editorGuard.js.map +1 -0
- package/codeyam-cli/src/utils/editorLoaderHelpers.js +72 -1
- package/codeyam-cli/src/utils/editorLoaderHelpers.js.map +1 -1
- package/codeyam-cli/src/utils/editorMigration.js +224 -0
- package/codeyam-cli/src/utils/editorMigration.js.map +1 -0
- package/codeyam-cli/src/utils/editorPreview.js +33 -0
- package/codeyam-cli/src/utils/editorPreview.js.map +1 -1
- package/codeyam-cli/src/utils/editorRecapture.js +109 -0
- package/codeyam-cli/src/utils/editorRecapture.js.map +1 -0
- package/codeyam-cli/src/utils/editorScenarioSwitch.js +24 -2
- package/codeyam-cli/src/utils/editorScenarioSwitch.js.map +1 -1
- package/codeyam-cli/src/utils/editorScenarios.js +580 -0
- package/codeyam-cli/src/utils/editorScenarios.js.map +1 -1
- package/codeyam-cli/src/utils/editorSeedAdapter.js +295 -6
- package/codeyam-cli/src/utils/editorSeedAdapter.js.map +1 -1
- package/codeyam-cli/src/utils/editorShouldRevalidate.js +21 -0
- package/codeyam-cli/src/utils/editorShouldRevalidate.js.map +1 -0
- package/codeyam-cli/src/utils/entityChangeStatus.js +53 -6
- package/codeyam-cli/src/utils/entityChangeStatus.js.map +1 -1
- package/codeyam-cli/src/utils/entityChangeStatus.server.js +57 -3
- package/codeyam-cli/src/utils/entityChangeStatus.server.js.map +1 -1
- package/codeyam-cli/src/utils/fileWatcher.js +38 -0
- package/codeyam-cli/src/utils/fileWatcher.js.map +1 -1
- package/codeyam-cli/src/utils/glossaryAdd.js +74 -0
- package/codeyam-cli/src/utils/glossaryAdd.js.map +1 -0
- package/codeyam-cli/src/utils/install-skills.js +14 -0
- package/codeyam-cli/src/utils/install-skills.js.map +1 -1
- package/codeyam-cli/src/utils/manualEntityAnalysis.js +196 -0
- package/codeyam-cli/src/utils/manualEntityAnalysis.js.map +1 -0
- package/codeyam-cli/src/utils/parseRegisterArg.js.map +1 -1
- package/codeyam-cli/src/utils/progress.js +2 -2
- package/codeyam-cli/src/utils/progress.js.map +1 -1
- package/codeyam-cli/src/utils/queue/job.js +26 -5
- package/codeyam-cli/src/utils/queue/job.js.map +1 -1
- package/codeyam-cli/src/utils/registerScenarioResult.js +52 -0
- package/codeyam-cli/src/utils/registerScenarioResult.js.map +1 -0
- package/codeyam-cli/src/utils/routePatternMatching.js +129 -0
- package/codeyam-cli/src/utils/routePatternMatching.js.map +1 -0
- package/codeyam-cli/src/utils/scenarioCoverage.js +77 -0
- package/codeyam-cli/src/utils/scenarioCoverage.js.map +1 -0
- package/codeyam-cli/src/utils/scenariosManifest.js +269 -74
- package/codeyam-cli/src/utils/scenariosManifest.js.map +1 -1
- package/codeyam-cli/src/utils/screenshotHash.js +26 -0
- package/codeyam-cli/src/utils/screenshotHash.js.map +1 -0
- package/codeyam-cli/src/utils/serverState.js +30 -0
- package/codeyam-cli/src/utils/serverState.js.map +1 -1
- package/codeyam-cli/src/utils/setupClaudeCodeSettings.js +1 -0
- package/codeyam-cli/src/utils/setupClaudeCodeSettings.js.map +1 -1
- package/codeyam-cli/src/utils/simulationGateMiddleware.js +17 -1
- package/codeyam-cli/src/utils/simulationGateMiddleware.js.map +1 -1
- package/codeyam-cli/src/utils/slugUtils.js +25 -0
- package/codeyam-cli/src/utils/slugUtils.js.map +1 -0
- package/codeyam-cli/src/utils/syncMocksMiddleware.js +2 -2
- package/codeyam-cli/src/utils/syncMocksMiddleware.js.map +1 -1
- package/codeyam-cli/src/utils/telemetry.js +106 -0
- package/codeyam-cli/src/utils/telemetry.js.map +1 -0
- package/codeyam-cli/src/utils/telemetryMiddleware.js +22 -0
- package/codeyam-cli/src/utils/telemetryMiddleware.js.map +1 -0
- package/codeyam-cli/src/utils/testRunner.js +199 -1
- package/codeyam-cli/src/utils/testRunner.js.map +1 -1
- package/codeyam-cli/src/webserver/__tests__/buildPtyEnv.test.js +35 -0
- package/codeyam-cli/src/webserver/__tests__/buildPtyEnv.test.js.map +1 -0
- package/codeyam-cli/src/webserver/__tests__/clientErrors.test.js +107 -0
- package/codeyam-cli/src/webserver/__tests__/clientErrors.test.js.map +1 -0
- package/codeyam-cli/src/webserver/__tests__/editorProxy.test.js +469 -0
- package/codeyam-cli/src/webserver/__tests__/editorProxy.test.js.map +1 -1
- package/codeyam-cli/src/webserver/__tests__/idleDetector.test.js +283 -0
- package/codeyam-cli/src/webserver/__tests__/idleDetector.test.js.map +1 -0
- package/codeyam-cli/src/webserver/__tests__/stripClaudeCommand.test.js +135 -0
- package/codeyam-cli/src/webserver/__tests__/stripClaudeCommand.test.js.map +1 -0
- package/codeyam-cli/src/webserver/app/lib/clientErrors.js +86 -0
- package/codeyam-cli/src/webserver/app/lib/clientErrors.js.map +1 -0
- package/codeyam-cli/src/webserver/app/lib/git.js +3 -2
- package/codeyam-cli/src/webserver/app/lib/git.js.map +1 -1
- package/codeyam-cli/src/webserver/app/types/editor.js +8 -0
- package/codeyam-cli/src/webserver/app/types/editor.js.map +1 -0
- package/codeyam-cli/src/webserver/backgroundServer.js +60 -61
- package/codeyam-cli/src/webserver/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/CopyButton-CLe80MMu.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{EntityItem-BcgbViKV.js → EntityItem-Crt_KN_U.js} +3 -3
- package/codeyam-cli/src/webserver/build/client/assets/EntityTypeBadge-CQgyEGV-.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeIcon-CQIG2qda.js → EntityTypeIcon-CD7lGABo.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/InlineSpinner-CgTNOhnu.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-CKeQT5Ty.js +25 -0
- package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-D3s1MFkb.js +3 -0
- package/codeyam-cli/src/webserver/build/client/assets/{LoadingDots-BU_OAEMP.js → LoadingDots-By5zI316.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{LogViewer-ceAyBX-H.js → LogViewer-CM5zg40N.js} +3 -3
- package/codeyam-cli/src/webserver/build/client/assets/MiniClaudeChat-CQENLSrF.js +36 -0
- package/codeyam-cli/src/webserver/build/client/assets/{ReportIssueModal-BzHcG7SE.js → ReportIssueModal-C2PLkej3.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-DanvyBPb.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{ScenarioViewer-0DY_NKil.js → ScenarioViewer-DUMfcNVK.js} +3 -3
- package/codeyam-cli/src/webserver/build/client/assets/Spinner-D0LgAaSa.js +34 -0
- package/codeyam-cli/src/webserver/build/client/assets/TruncatedFilePath-CK7-NaPZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/ViewportInspectBar-BA_Ry-rs.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{_index-DLxKhri3.js → _index-BAWd-Xjf.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/{activity.(_tab)-BcY3q6nt.js → activity.(_tab)-BOARiB-g.js} +3 -3
- package/codeyam-cli/src/webserver/build/client/assets/{addon-web-links-Duc5hnl7.js → addon-web-links-CHx25PAe.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{agent-transcripts-Bni3iiUj.js → agent-transcripts-Bg3e7q4S.js} +3 -3
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-recapture-stale-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-rename-scenario-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-save-scenario-data-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-save-seed-state-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-scenario-coverage-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-scenario-prompt-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-schema-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-session-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{book-open-BYOypzCa.js → book-open-CL-lMgHh.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{chevron-down-C_Pmso5S.js → chevron-down-GmAjGS9-.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/chunk-JZWAC4HX-BAdwhyCx.js +43 -0
- package/codeyam-cli/src/webserver/build/client/assets/{circle-check-BVMi9VA5.js → circle-check-DFcQkN5j.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{copy-n2FB0_Sw.js → copy-C6iF61Xs.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{createLucideIcon-CC6AbExI.js → createLucideIcon-4ImjHTVC.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/cy-logo-cli-Coe5NhbS.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{cy-logo-cli-CCKUIm0S.svg → cy-logo-cli-DoA97ML3.svg} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/dev.empty-C8y4mmyv.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/editor._tab-Gbk_i5Js.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/editor.entity.(_sha)-DMv5ESGo.js +96 -0
- package/codeyam-cli/src/webserver/build/client/assets/editorPreview-CluPkvXJ.js +41 -0
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-BF4oLwaE.js → entity._sha._-ByHz6rAQ.js} +13 -12
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.dev-CmLO432x.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-Bz9sCUF_.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-DQM8E7L4.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.edit._scenarioId-BMvVHNXU.js → entity._sha_.edit._scenarioId-CAoXLsQr.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/{entry.client-DTvKq3TY.js → entry.client-SuW9syRS.js} +6 -6
- package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-Daa96Fr1.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/files-D-xGrg29.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/git-Bq_fbXP5.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/globals-oyPmV37k.css +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{index-BcvgDzbZ.js → index-Bp1l4hSv.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{index-10oVnAAH.js → index-CWV9XZiG.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{index-yHOVb4rc.js → index-DE3jI_dv.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/jsx-runtime-D_zvdyIk.js +9 -0
- package/codeyam-cli/src/webserver/build/client/assets/labs-B_IX45ih.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{loader-circle-DaAZ_H2w.js → loader-circle-De-7qQ2u.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-1a45e154.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/memory-Cx2xEx7s.js +101 -0
- package/codeyam-cli/src/webserver/build/client/assets/{pause-f5-1lKBt.js → pause-CFxEKL1u.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/root-D2_tktnk.js +80 -0
- package/codeyam-cli/src/webserver/build/client/assets/{search-Di64LWVb.js → search-BdBb5aqc.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/settings-DdE-Untf.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/simulations-DSCdE99u.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{terminal-Br7MOqts.js → terminal-CrplD4b1.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{triangle-alert-BLdiCuG-.js → triangle-alert-DqJ0j69l.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-DhXHbEjP.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{useLastLogLine-C14nCb1q.js → useLastLogLine-BNd5hYuW.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/useReportContext-Cy5Qg_UR.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/useToast-5HR2j9ZE.js +1 -0
- package/codeyam-cli/src/webserver/build/client/sound-test.html +98 -0
- package/codeyam-cli/src/webserver/build/server/assets/analysisRunner-By5slFjw.js +16 -0
- package/codeyam-cli/src/webserver/build/server/assets/index-DXaOwBnm.js +1 -0
- package/codeyam-cli/src/webserver/build/server/assets/init-CLG1LjQM.js +10 -0
- package/codeyam-cli/src/webserver/build/server/assets/progress-CHTtrxFG.js +1 -0
- package/codeyam-cli/src/webserver/build/server/assets/server-build-NZmUqQv6.js +688 -0
- package/codeyam-cli/src/webserver/build/server/index.js +1 -1
- package/codeyam-cli/src/webserver/build-info.json +5 -5
- package/codeyam-cli/src/webserver/editorProxy.js +436 -13
- package/codeyam-cli/src/webserver/editorProxy.js.map +1 -1
- package/codeyam-cli/src/webserver/idleDetector.js +121 -0
- package/codeyam-cli/src/webserver/idleDetector.js.map +1 -0
- package/codeyam-cli/src/webserver/mockStateEvents.js +28 -0
- package/codeyam-cli/src/webserver/mockStateEvents.js.map +1 -0
- package/codeyam-cli/src/webserver/public/sound-test.html +98 -0
- package/codeyam-cli/src/webserver/scripts/journalCapture.ts +53 -0
- package/codeyam-cli/src/webserver/server.js +125 -4
- package/codeyam-cli/src/webserver/server.js.map +1 -1
- package/codeyam-cli/src/webserver/terminalServer.js +288 -43
- package/codeyam-cli/src/webserver/terminalServer.js.map +1 -1
- package/codeyam-cli/templates/__tests__/editor-step-hook.prompt-capture.test.ts +118 -0
- package/codeyam-cli/templates/chrome-extension-react/README.md +46 -0
- package/codeyam-cli/templates/chrome-extension-react/package.json +1 -0
- package/codeyam-cli/templates/chrome-extension-react/vite.config.ts +6 -0
- package/codeyam-cli/templates/codeyam-editor-claude.md +86 -5
- package/codeyam-cli/templates/codeyam-editor-reference.md +216 -0
- package/codeyam-cli/templates/editor-step-hook.py +193 -56
- package/codeyam-cli/templates/expo-react-native/README.md +41 -0
- package/codeyam-cli/templates/expo-react-native/package.json +1 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/DATABASE.md +14 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/README.md +53 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/package.json +2 -1
- package/codeyam-cli/templates/nextjs-prisma-sqlite/seed-adapter.ts +83 -40
- package/codeyam-cli/templates/nextjs-prisma-supabase/README.md +52 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/package.json +2 -1
- package/codeyam-cli/templates/seed-adapters/supabase.ts +282 -0
- package/codeyam-cli/templates/skills/codeyam-dev-mode/SKILL.md +1 -1
- package/codeyam-cli/templates/skills/codeyam-editor/SKILL.md +94 -10
- package/package.json +2 -1
- package/packages/ai/src/lib/astScopes/methodSemantics.js +99 -0
- package/packages/ai/src/lib/astScopes/methodSemantics.js.map +1 -1
- package/packages/ai/src/lib/astScopes/nodeToSource.js +16 -0
- package/packages/ai/src/lib/astScopes/nodeToSource.js.map +1 -1
- package/packages/ai/src/lib/astScopes/paths.js +12 -3
- package/packages/ai/src/lib/astScopes/paths.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +27 -10
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/ParentScopeManager.js +9 -2
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/ParentScopeManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js +14 -4
- package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js.map +1 -1
- package/packages/analyze/index.js +1 -1
- package/packages/analyze/index.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js +16 -2
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.js +6 -26
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js +3 -2
- package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js +9 -7
- package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/trackEntityCircularDependencies.js +14 -0
- package/packages/analyze/src/lib/files/analyze/trackEntityCircularDependencies.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js +44 -11
- package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeChange.js +1 -0
- package/packages/analyze/src/lib/files/analyzeChange.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeInitial.js +1 -0
- package/packages/analyze/src/lib/files/analyzeInitial.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeNextRoute.js +5 -1
- package/packages/analyze/src/lib/files/analyzeNextRoute.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +120 -28
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +1368 -1193
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js.map +1 -1
- package/packages/database/src/lib/kysely/tables/editorScenariosTable.js +84 -0
- package/packages/database/src/lib/kysely/tables/editorScenariosTable.js.map +1 -1
- package/packages/database/src/lib/loadAnalysis.js +1 -1
- package/packages/database/src/lib/loadAnalysis.js.map +1 -1
- package/packages/database/src/lib/loadEntities.js +0 -6
- package/packages/database/src/lib/loadEntities.js.map +1 -1
- package/packages/database/src/lib/loadEntity.js +5 -5
- package/packages/database/src/lib/loadEntity.js.map +1 -1
- package/packages/database/src/lib/updateCommitMetadata.js +0 -25
- package/packages/database/src/lib/updateCommitMetadata.js.map +1 -1
- package/packages/utils/src/lib/fs/rsyncCopy.js +22 -1
- package/packages/utils/src/lib/fs/rsyncCopy.js.map +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/CopyButton-BPXZwM4t.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityTypeBadge-g3saevPb.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/InlineSpinner-Bu6c6aDe.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-DYFW3lDD.js +0 -25
- package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-DLeucoVX.js +0 -3
- package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-BED4B6sP.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/Spinner-Bb5uFQ5V.js +0 -34
- package/codeyam-cli/src/webserver/build/client/assets/TruncatedFilePath-C8OKAR5x.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/ViewportInspectBar-oAf2Kqsf.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/chunk-JZWAC4HX-C4pqxYJB.js +0 -51
- package/codeyam-cli/src/webserver/build/client/assets/cy-logo-cli-DcX-ZS3p.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/dev.empty-Csi0_PMl.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/editor-BuT_Huj0.js +0 -10
- package/codeyam-cli/src/webserver/build/client/assets/editorPreview-B7ztwLut.js +0 -41
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.dev-D5rYBT5x.js +0 -6
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-CF164ouH.js +0 -6
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-p9hhkjJM.js +0 -6
- package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-cPo8LiG3.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/files-BZrlFE1F.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/git-DdZcvjGh.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/globals-BkWJ_UNc.css +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/labs-Zk7ryIM1.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-b0f1372e.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/memory-Bl2rpw8u.js +0 -96
- package/codeyam-cli/src/webserver/build/client/assets/root-B_X8HS1x.js +0 -67
- package/codeyam-cli/src/webserver/build/client/assets/settings-0OrEMU6J.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/simulations-DWT-CvLy.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-CrAK28Bc.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/useReportContext-O-jkvSPx.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/useToast-9FIWuYfK.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/index-CbF6h3dj.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/server-build-DRFwTJqO.js +0 -367
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{aG as Z,aH as _,aw as $,ax as rr,aE as tr,ay as or,aA as ir,aB as pr,aD as mr,aC as ar,aF as sr,az as er}from"./assets/server-build-NZmUqQv6.js";import"react/jsx-runtime";import"node:stream";import"@react-router/node";import"react-router";import"isbot";import"react-dom/server";import"react";import"lucide-react";import"fetch-retry";import"better-sqlite3";import"pg";import"fs";import"path";import"kysely";import"kysely/helpers/sqlite";import"kysely/helpers/postgres";import"typescript";import"fs/promises";import"os";import"prompts";import"chalk";import"crypto";import"child_process";import"url";import"util";import"dotenv";import"events";import"uuid";import"http";import"net";import"ws";import"node-pty";import"openai";import"p-queue";import"p-retry";import"@aws-sdk/client-dynamodb";import"lru-cache";import"pluralize";import"piscina";import"json5";import"@aws-sdk/util-dynamodb";import"v8";import"react-syntax-highlighter";import"react-syntax-highlighter/dist/cjs/styles/prism/index.js";import"node:crypto";import"minimatch";import"react-markdown";import"remark-gfm";import"react-diff-viewer-continued";export{Z as allowedActionOrigins,_ as assets,$ as assetsBuildDirectory,rr as basename,tr as entry,or as future,ir as isSpaMode,pr as prerender,mr as publicPath,ar as routeDiscovery,sr as routes,er as ssr};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"buildTimestamp": "2026-03-
|
|
3
|
-
"buildTime":
|
|
4
|
-
"buildNumber":
|
|
5
|
-
"semanticVersion": "0.1.
|
|
6
|
-
"version": "0.1.
|
|
2
|
+
"buildTimestamp": "2026-03-25T14:06:38.180Z",
|
|
3
|
+
"buildTime": 1774447598180,
|
|
4
|
+
"buildNumber": 1246,
|
|
5
|
+
"semanticVersion": "0.1.1246",
|
|
6
|
+
"version": "0.1.1246 (2026-03-25T14:06)"
|
|
7
7
|
}
|
|
@@ -5,6 +5,7 @@ import path from 'path';
|
|
|
5
5
|
import { getProjectRoot } from "../state.js";
|
|
6
6
|
import { createMockStateManager, } from "../utils/editorMockState.js";
|
|
7
7
|
import { computeEditorPorts } from "../utils/editorDevServer.js";
|
|
8
|
+
import { mockStateEventEmitter } from "./mockStateEvents.js";
|
|
8
9
|
/**
|
|
9
10
|
* Normalize a target URL by stripping trailing slashes for consistency.
|
|
10
11
|
*
|
|
@@ -60,10 +61,128 @@ export async function resolveLoopbackAddress(port) {
|
|
|
60
61
|
}
|
|
61
62
|
// Global key so the proxy survives HMR
|
|
62
63
|
const GLOBAL_KEY = '__codeyam_editor_proxy__';
|
|
64
|
+
// ─── Live Preview Health ─────────────────────────────────────────────
|
|
65
|
+
const PREVIEW_HEALTH_KEY = '__codeyam_preview_health__';
|
|
66
|
+
function getPreviewHealth() {
|
|
67
|
+
return globalThis[PREVIEW_HEALTH_KEY] ?? null;
|
|
68
|
+
}
|
|
69
|
+
function setPreviewHealth(report) {
|
|
70
|
+
globalThis[PREVIEW_HEALTH_KEY] = report;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Get the current live preview health report (read by API endpoint).
|
|
74
|
+
*/
|
|
75
|
+
export function getPreviewHealthReport() {
|
|
76
|
+
return getPreviewHealth();
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Reset preview health state (called when a new HTML page is served).
|
|
80
|
+
*/
|
|
81
|
+
export function resetPreviewHealth() {
|
|
82
|
+
setPreviewHealth(null);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Error-catching script injected into HTML responses.
|
|
86
|
+
* Uses vanilla JS for maximum compatibility.
|
|
87
|
+
*/
|
|
88
|
+
export const PREVIEW_HEALTH_SCRIPT = `<script data-codeyam-health>
|
|
89
|
+
(function() {
|
|
90
|
+
var errors = [];
|
|
91
|
+
var reported = false;
|
|
92
|
+
function report(type, msg, stack) {
|
|
93
|
+
errors.push({ type: type, message: msg, stack: stack, timestamp: Date.now() });
|
|
94
|
+
if (!reported) {
|
|
95
|
+
reported = true;
|
|
96
|
+
setTimeout(function() { flush(); }, 500);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function flush() {
|
|
100
|
+
fetch('/__codeyam__/preview-health', {
|
|
101
|
+
method: 'POST',
|
|
102
|
+
headers: { 'Content-Type': 'application/json' },
|
|
103
|
+
body: JSON.stringify({ errors: errors, url: location.href })
|
|
104
|
+
}).catch(function(){});
|
|
105
|
+
reported = false;
|
|
106
|
+
errors = [];
|
|
107
|
+
}
|
|
108
|
+
window.addEventListener('error', function(e) {
|
|
109
|
+
report('error', e.message, e.error && e.error.stack);
|
|
110
|
+
});
|
|
111
|
+
window.addEventListener('unhandledrejection', function(e) {
|
|
112
|
+
report('unhandledrejection', String(e.reason), e.reason && e.reason.stack);
|
|
113
|
+
});
|
|
114
|
+
var origError = console.error;
|
|
115
|
+
console.error = function() {
|
|
116
|
+
report('console.error', Array.prototype.join.call(arguments, ' '));
|
|
117
|
+
origError.apply(console, arguments);
|
|
118
|
+
};
|
|
119
|
+
window.addEventListener('load', function() {
|
|
120
|
+
setTimeout(function() {
|
|
121
|
+
var hasContent = document.body && document.body.innerText.trim().length > 0;
|
|
122
|
+
fetch('/__codeyam__/preview-health', {
|
|
123
|
+
method: 'POST',
|
|
124
|
+
headers: { 'Content-Type': 'application/json' },
|
|
125
|
+
body: JSON.stringify({
|
|
126
|
+
loaded: true,
|
|
127
|
+
hasContent: hasContent,
|
|
128
|
+
url: location.href,
|
|
129
|
+
errorCount: errors.length
|
|
130
|
+
})
|
|
131
|
+
}).catch(function(){});
|
|
132
|
+
}, 1000);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
// Network-idle detection: notify the parent editor when all initial
|
|
136
|
+
// fetch requests have completed, so it can show the preview after
|
|
137
|
+
// client-side data (API calls) has arrived — not just when the DOM loads.
|
|
138
|
+
var inflight = 0;
|
|
139
|
+
var settled = false;
|
|
140
|
+
var settleTimer = null;
|
|
141
|
+
var origFetch = window.fetch;
|
|
142
|
+
window.fetch = function() {
|
|
143
|
+
if (!settled) inflight++;
|
|
144
|
+
return origFetch.apply(this, arguments).then(function(resp) {
|
|
145
|
+
if (!settled) { inflight--; checkSettle(); }
|
|
146
|
+
return resp;
|
|
147
|
+
}, function(err) {
|
|
148
|
+
if (!settled) { inflight--; checkSettle(); }
|
|
149
|
+
throw err;
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
function checkSettle() {
|
|
153
|
+
if (inflight <= 0 && !settled) {
|
|
154
|
+
clearTimeout(settleTimer);
|
|
155
|
+
// Small delay to allow React to re-render with the fetched data
|
|
156
|
+
settleTimer = setTimeout(function() {
|
|
157
|
+
if (inflight <= 0) {
|
|
158
|
+
settled = true;
|
|
159
|
+
try {
|
|
160
|
+
window.parent.postMessage({ type: 'codeyam-preview-ready' }, '*');
|
|
161
|
+
} catch(e) {}
|
|
162
|
+
}
|
|
163
|
+
}, 100);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
// Fallback: if no fetches happen (static page), settle after load
|
|
167
|
+
window.addEventListener('load', function() {
|
|
168
|
+
setTimeout(function() { checkSettle(); }, 200);
|
|
169
|
+
});
|
|
170
|
+
})();
|
|
171
|
+
</script>`;
|
|
63
172
|
const CACHE_TTL_MS = 500;
|
|
64
173
|
let scenarioCache = { data: null, timestamp: 0 };
|
|
65
174
|
// Session config extracted from the active scenario — drives cookie injection
|
|
66
175
|
let sessionConfig = undefined;
|
|
176
|
+
/** Session cookies from the seed adapter (e.g. Supabase auth tokens). */
|
|
177
|
+
let seedSessionCookies = undefined;
|
|
178
|
+
// localStorage config extracted from the active scenario — drives HTML injection
|
|
179
|
+
let localStorageConfig = null;
|
|
180
|
+
// Active scenario ID — used to gate localStorage seeding (only re-seed on switch)
|
|
181
|
+
let activeScenarioId = null;
|
|
182
|
+
// Prototype ID — used to gate a one-time localStorage.clear() when a new project is scaffolded
|
|
183
|
+
let currentPrototypeId = null;
|
|
184
|
+
// Current scenario type — 'application'/'user' for seed-based, 'component' for mock-based
|
|
185
|
+
let currentScenarioType = null;
|
|
67
186
|
// Max body size to buffer for mock matching (10MB)
|
|
68
187
|
const MAX_BODY_SIZE = 10 * 1024 * 1024;
|
|
69
188
|
function getProxyState() {
|
|
@@ -117,6 +236,8 @@ function readScenarioData() {
|
|
|
117
236
|
const active = JSON.parse(fs.readFileSync(activeScenarioPath, 'utf-8'));
|
|
118
237
|
const scenarioId = active.scenarioId;
|
|
119
238
|
if (!scenarioId) {
|
|
239
|
+
// No active scenario — but may have a prototypeId for localStorage clearing
|
|
240
|
+
currentPrototypeId = active.prototypeId || null;
|
|
120
241
|
scenarioCache = { data: null, timestamp: now };
|
|
121
242
|
return null;
|
|
122
243
|
}
|
|
@@ -129,8 +250,14 @@ function readScenarioData() {
|
|
|
129
250
|
const rawData = JSON.parse(fs.readFileSync(dataFilePath, 'utf-8'));
|
|
130
251
|
// Extract session config for cookie injection
|
|
131
252
|
sessionConfig = rawData.session || null;
|
|
253
|
+
// Extract seed adapter session cookies (e.g. Supabase auth)
|
|
254
|
+
seedSessionCookies = rawData.sessionCookies || undefined;
|
|
255
|
+
// Extract localStorage config for HTML injection
|
|
256
|
+
localStorageConfig = rawData.localStorage || null;
|
|
257
|
+
activeScenarioId = scenarioId;
|
|
132
258
|
// Type-aware: for seed-based scenarios, only serve externalApis via proxy
|
|
133
259
|
const scenarioType = active.type || rawData.type || null;
|
|
260
|
+
currentScenarioType = scenarioType;
|
|
134
261
|
let mockData;
|
|
135
262
|
if ((scenarioType === 'application' || scenarioType === 'user') &&
|
|
136
263
|
rawData.seed) {
|
|
@@ -204,6 +331,9 @@ function forwardBufferedRequest(req, res, targetUrl, bodyBuffer) {
|
|
|
204
331
|
const target = new URL(targetUrl);
|
|
205
332
|
const hostname = stripIPv6Brackets(target.hostname);
|
|
206
333
|
const headers = { ...req.headers, host: `${target.hostname}:${target.port}` };
|
|
334
|
+
// Remove accept-encoding so the dev server returns uncompressed responses.
|
|
335
|
+
// The proxy injects a health script into HTML — this fails on compressed bodies.
|
|
336
|
+
delete headers['accept-encoding'];
|
|
207
337
|
// Update content-length if we have the body buffer
|
|
208
338
|
if (bodyBuffer) {
|
|
209
339
|
headers['content-length'] = String(bodyBuffer.length);
|
|
@@ -222,6 +352,27 @@ function forwardBufferedRequest(req, res, targetUrl, bodyBuffer) {
|
|
|
222
352
|
}
|
|
223
353
|
const headers = { ...proxyRes.headers };
|
|
224
354
|
injectSessionCookie(headers);
|
|
355
|
+
// Check if response is HTML — if so, buffer and inject health script
|
|
356
|
+
const contentType = proxyRes.headers['content-type'] || '';
|
|
357
|
+
if (contentType.includes('text/html')) {
|
|
358
|
+
resetPreviewHealth();
|
|
359
|
+
const chunks = [];
|
|
360
|
+
proxyRes.on('data', (chunk) => chunks.push(chunk));
|
|
361
|
+
proxyRes.on('end', () => {
|
|
362
|
+
const body = Buffer.concat(chunks).toString('utf-8');
|
|
363
|
+
const lsScript = buildLocalStorageScript(localStorageConfig, activeScenarioId || '', currentPrototypeId);
|
|
364
|
+
const injected = injectHealthScript(body, lsScript);
|
|
365
|
+
delete headers['content-length'];
|
|
366
|
+
delete headers['content-encoding'];
|
|
367
|
+
// Prevent browser from caching HTML responses — scenario switches
|
|
368
|
+
// serve different content from the same URL (seed data changes the
|
|
369
|
+
// rendered page but the proxy URL stays the same).
|
|
370
|
+
headers['cache-control'] = 'no-store, must-revalidate';
|
|
371
|
+
res.writeHead(status, headers);
|
|
372
|
+
res.end(injected);
|
|
373
|
+
});
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
225
376
|
res.writeHead(status, headers);
|
|
226
377
|
proxyRes.pipe(res, { end: true });
|
|
227
378
|
});
|
|
@@ -240,17 +391,25 @@ function forwardBufferedRequest(req, res, targetUrl, bodyBuffer) {
|
|
|
240
391
|
}
|
|
241
392
|
}
|
|
242
393
|
/**
|
|
243
|
-
* Forward an HTTP request to the target dev server
|
|
394
|
+
* Forward an HTTP request to the target dev server.
|
|
395
|
+
* For HTML responses: buffers body to inject health-check script.
|
|
396
|
+
* For non-HTML responses: pipes directly (no buffering).
|
|
244
397
|
*/
|
|
245
398
|
function forwardRequest(req, res, targetUrl) {
|
|
246
399
|
const target = new URL(targetUrl);
|
|
247
400
|
const hostname = stripIPv6Brackets(target.hostname);
|
|
401
|
+
// Build headers, stripping accept-encoding so the dev server returns uncompressed
|
|
402
|
+
// responses. The proxy injects a health script into HTML — this fails on compressed bodies.
|
|
403
|
+
const { 'accept-encoding': _ae, ...forwardHeaders } = req.headers;
|
|
248
404
|
const options = {
|
|
249
405
|
hostname,
|
|
250
406
|
port: target.port,
|
|
251
407
|
path: req.url,
|
|
252
408
|
method: req.method,
|
|
253
|
-
headers: {
|
|
409
|
+
headers: {
|
|
410
|
+
...forwardHeaders,
|
|
411
|
+
host: `${target.hostname}:${target.port}`,
|
|
412
|
+
},
|
|
254
413
|
};
|
|
255
414
|
const proxyReq = http.request(options, (proxyRes) => {
|
|
256
415
|
const status = proxyRes.statusCode || 200;
|
|
@@ -259,6 +418,30 @@ function forwardRequest(req, res, targetUrl) {
|
|
|
259
418
|
}
|
|
260
419
|
const headers = { ...proxyRes.headers };
|
|
261
420
|
injectSessionCookie(headers);
|
|
421
|
+
// Check if response is HTML — if so, buffer and inject health script
|
|
422
|
+
const contentType = proxyRes.headers['content-type'] || '';
|
|
423
|
+
if (contentType.includes('text/html')) {
|
|
424
|
+
// Reset health state for new page loads
|
|
425
|
+
resetPreviewHealth();
|
|
426
|
+
const chunks = [];
|
|
427
|
+
proxyRes.on('data', (chunk) => chunks.push(chunk));
|
|
428
|
+
proxyRes.on('end', () => {
|
|
429
|
+
const body = Buffer.concat(chunks).toString('utf-8');
|
|
430
|
+
const lsScript = buildLocalStorageScript(localStorageConfig, activeScenarioId || '', currentPrototypeId);
|
|
431
|
+
const injected = injectHealthScript(body, lsScript);
|
|
432
|
+
// Remove content-length since body size changed; use chunked transfer
|
|
433
|
+
delete headers['content-length'];
|
|
434
|
+
// Remove content-encoding since we're serving uncompressed
|
|
435
|
+
delete headers['content-encoding'];
|
|
436
|
+
// Prevent browser from caching HTML responses — scenario switches
|
|
437
|
+
// serve different content from the same URL (seed data changes the
|
|
438
|
+
// rendered page but the proxy URL stays the same).
|
|
439
|
+
headers['cache-control'] = 'no-store, must-revalidate';
|
|
440
|
+
res.writeHead(status, headers);
|
|
441
|
+
res.end(injected);
|
|
442
|
+
});
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
262
445
|
res.writeHead(status, headers);
|
|
263
446
|
proxyRes.pipe(res, { end: true });
|
|
264
447
|
});
|
|
@@ -278,25 +461,35 @@ function forwardRequest(req, res, targetUrl) {
|
|
|
278
461
|
* When sessionConfig is undefined (no scenario loaded yet), does nothing.
|
|
279
462
|
*/
|
|
280
463
|
function injectSessionCookie(headers) {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
464
|
+
const cookies = [];
|
|
465
|
+
// Dev auth cookie (built-in session-token)
|
|
466
|
+
if (sessionConfig !== undefined) {
|
|
467
|
+
if (sessionConfig?.cookieValue) {
|
|
468
|
+
cookies.push(`session-token=${sessionConfig.cookieValue}; Path=/; SameSite=Lax`);
|
|
469
|
+
}
|
|
470
|
+
else {
|
|
471
|
+
cookies.push(`session-token=; Path=/; Max-Age=0`);
|
|
472
|
+
}
|
|
286
473
|
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
474
|
+
// Seed adapter session cookies (e.g. Supabase auth tokens)
|
|
475
|
+
if (seedSessionCookies && seedSessionCookies.length > 0) {
|
|
476
|
+
for (const sc of seedSessionCookies) {
|
|
477
|
+
const cookiePath = sc.path || '/';
|
|
478
|
+
const sameSite = sc.sameSite || 'Lax';
|
|
479
|
+
cookies.push(`${sc.name}=${sc.value}; Path=${cookiePath}; SameSite=${sameSite}`);
|
|
480
|
+
}
|
|
290
481
|
}
|
|
482
|
+
if (cookies.length === 0)
|
|
483
|
+
return;
|
|
291
484
|
const existing = headers['set-cookie'];
|
|
292
485
|
if (existing) {
|
|
293
486
|
headers['set-cookie'] = [
|
|
294
487
|
...(Array.isArray(existing) ? existing : [existing]),
|
|
295
|
-
|
|
488
|
+
...cookies,
|
|
296
489
|
];
|
|
297
490
|
}
|
|
298
491
|
else {
|
|
299
|
-
headers['set-cookie'] =
|
|
492
|
+
headers['set-cookie'] = cookies;
|
|
300
493
|
}
|
|
301
494
|
}
|
|
302
495
|
/**
|
|
@@ -305,6 +498,214 @@ function injectSessionCookie(headers) {
|
|
|
305
498
|
export function getSessionConfig() {
|
|
306
499
|
return sessionConfig;
|
|
307
500
|
}
|
|
501
|
+
/**
|
|
502
|
+
* Get the current localStorage config (for testing and script generation).
|
|
503
|
+
*/
|
|
504
|
+
export function getLocalStorageConfig() {
|
|
505
|
+
return localStorageConfig;
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* Get the active scenario ID (for testing and script generation).
|
|
509
|
+
*/
|
|
510
|
+
export function getActiveScenarioId() {
|
|
511
|
+
return activeScenarioId;
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* Get the current prototype ID (for testing).
|
|
515
|
+
*/
|
|
516
|
+
export function getCurrentPrototypeId() {
|
|
517
|
+
return currentPrototypeId;
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Simple djb2 hash — fast, deterministic, good enough for cache busting.
|
|
521
|
+
* Not cryptographic — just detects when localStorage config content changes.
|
|
522
|
+
*/
|
|
523
|
+
function simpleHash(str) {
|
|
524
|
+
let hash = 5381;
|
|
525
|
+
for (let i = 0; i < str.length; i++) {
|
|
526
|
+
hash = ((hash << 5) + hash + str.charCodeAt(i)) | 0;
|
|
527
|
+
}
|
|
528
|
+
return (hash >>> 0).toString(36);
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* Build a script tag that seeds localStorage with scenario data on first load.
|
|
532
|
+
* Gated by scenario ID — only seeds when the scenario changes, preserving
|
|
533
|
+
* interactive modifications across page reloads / HMR.
|
|
534
|
+
*
|
|
535
|
+
* Returns empty string if no localStorage config is provided.
|
|
536
|
+
*/
|
|
537
|
+
export function buildLocalStorageScript(localStorageConfig, scenarioId, prototypeId) {
|
|
538
|
+
// null/undefined means no localStorage config at all — clean up keys
|
|
539
|
+
// that were set by a previous scenario so stale filter/sort state
|
|
540
|
+
// doesn't bleed through and hide data in the new scenario.
|
|
541
|
+
if (!localStorageConfig || typeof localStorageConfig !== 'object') {
|
|
542
|
+
// Always clean up previous scenario's keys, gated by scenarioId
|
|
543
|
+
// so it only runs once per switch (not on every HMR reload).
|
|
544
|
+
const guardValue = scenarioId ? `clear:${scenarioId}` : '';
|
|
545
|
+
if (prototypeId) {
|
|
546
|
+
return `<script data-codeyam-ls>
|
|
547
|
+
(function() {
|
|
548
|
+
if (localStorage.getItem('__codeyam_proto__') === ${JSON.stringify(prototypeId)}) return;
|
|
549
|
+
localStorage.clear();
|
|
550
|
+
localStorage.setItem('__codeyam_proto__', ${JSON.stringify(prototypeId)});
|
|
551
|
+
})();
|
|
552
|
+
</script>`;
|
|
553
|
+
}
|
|
554
|
+
if (scenarioId) {
|
|
555
|
+
// No prototypeId but we do have a scenarioId — clean up keys
|
|
556
|
+
// from the previous scenario without doing a full clear.
|
|
557
|
+
return `<script data-codeyam-ls>
|
|
558
|
+
(function() {
|
|
559
|
+
if (localStorage.getItem('__codeyam_ls_sid__') === ${JSON.stringify(guardValue)}) return;
|
|
560
|
+
var prev = JSON.parse(localStorage.getItem('__codeyam_ls_keys__') || '[]');
|
|
561
|
+
for (var i = 0; i < prev.length; i++) localStorage.removeItem(prev[i]);
|
|
562
|
+
localStorage.removeItem('__codeyam_ls_keys__');
|
|
563
|
+
localStorage.setItem('__codeyam_ls_sid__', ${JSON.stringify(guardValue)});
|
|
564
|
+
})();
|
|
565
|
+
</script>`;
|
|
566
|
+
}
|
|
567
|
+
return '';
|
|
568
|
+
}
|
|
569
|
+
// Even an empty object needs a cleanup script — switching from a scenario
|
|
570
|
+
// with localStorage data to one without must clear the previous keys.
|
|
571
|
+
const entries = Object.entries(localStorageConfig);
|
|
572
|
+
const keys = entries.map(([k]) => k);
|
|
573
|
+
// Build setItem calls — stringify non-string values
|
|
574
|
+
const setStatements = entries
|
|
575
|
+
.map(([key, value]) => {
|
|
576
|
+
const serialized = typeof value === 'string' ? value : JSON.stringify(value);
|
|
577
|
+
return `localStorage.setItem(${JSON.stringify(key)}, ${JSON.stringify(serialized)});`;
|
|
578
|
+
})
|
|
579
|
+
.join('\n');
|
|
580
|
+
// Guard value includes a content hash so re-registering a scenario with
|
|
581
|
+
// updated data (same ID, different content) busts the cache. Without this,
|
|
582
|
+
// the browser skips re-seeding because the scenario ID hasn't changed,
|
|
583
|
+
// causing stale data in the live preview while screenshots show fresh data.
|
|
584
|
+
const contentHash = simpleHash(JSON.stringify(localStorageConfig));
|
|
585
|
+
const guardValue = `${scenarioId}:${contentHash}`;
|
|
586
|
+
return (`<script data-codeyam-ls>
|
|
587
|
+
(function() {
|
|
588
|
+
if (localStorage.getItem('__codeyam_ls_sid__') === ${JSON.stringify(guardValue)}) return;
|
|
589
|
+
var prev = JSON.parse(localStorage.getItem('__codeyam_ls_keys__') || '[]');
|
|
590
|
+
for (var i = 0; i < prev.length; i++) localStorage.removeItem(prev[i]);
|
|
591
|
+
${setStatements}
|
|
592
|
+
localStorage.setItem('__codeyam_ls_keys__', ${JSON.stringify(JSON.stringify(keys))});
|
|
593
|
+
localStorage.setItem('__codeyam_ls_sid__', ${JSON.stringify(guardValue)});
|
|
594
|
+
})();
|
|
595
|
+
</script>` + buildLocalStorageWatcherScript());
|
|
596
|
+
}
|
|
597
|
+
/**
|
|
598
|
+
* Build a script that watches for localStorage mutations and notifies the parent
|
|
599
|
+
* frame via postMessage. Also responds to `codeyam-get-localstorage` requests so
|
|
600
|
+
* the editor can read the current localStorage state when saving.
|
|
601
|
+
*/
|
|
602
|
+
function buildLocalStorageWatcherScript() {
|
|
603
|
+
return `<script data-codeyam-ls-watcher>
|
|
604
|
+
(function() {
|
|
605
|
+
if (window.__codeyam_ls_watcher_installed__) return;
|
|
606
|
+
window.__codeyam_ls_watcher_installed__ = true;
|
|
607
|
+
|
|
608
|
+
var origSet = localStorage.setItem.bind(localStorage);
|
|
609
|
+
var origRemove = localStorage.removeItem.bind(localStorage);
|
|
610
|
+
var origClear = localStorage.clear.bind(localStorage);
|
|
611
|
+
window.__codeyam_orig_setItem__ = origSet;
|
|
612
|
+
window.__codeyam_orig_removeItem__ = origRemove;
|
|
613
|
+
window.__codeyam_orig_clear__ = origClear;
|
|
614
|
+
|
|
615
|
+
function isInternal(key) {
|
|
616
|
+
return typeof key === 'string' && key.indexOf('__codeyam_') === 0;
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
localStorage.setItem = function(key, value) {
|
|
620
|
+
origSet(key, value);
|
|
621
|
+
if (!isInternal(key) && window.parent !== window) {
|
|
622
|
+
window.parent.postMessage({ type: 'codeyam-localstorage-changed', action: 'set', key: key }, '*');
|
|
623
|
+
}
|
|
624
|
+
};
|
|
625
|
+
|
|
626
|
+
localStorage.removeItem = function(key) {
|
|
627
|
+
origRemove(key);
|
|
628
|
+
if (!isInternal(key) && window.parent !== window) {
|
|
629
|
+
window.parent.postMessage({ type: 'codeyam-localstorage-changed', action: 'remove', key: key }, '*');
|
|
630
|
+
}
|
|
631
|
+
};
|
|
632
|
+
|
|
633
|
+
localStorage.clear = function() {
|
|
634
|
+
origClear();
|
|
635
|
+
if (window.parent !== window) {
|
|
636
|
+
window.parent.postMessage({ type: 'codeyam-localstorage-changed', action: 'clear' }, '*');
|
|
637
|
+
}
|
|
638
|
+
};
|
|
639
|
+
|
|
640
|
+
window.addEventListener('message', function(event) {
|
|
641
|
+
if (event.data && event.data.type === 'codeyam-get-localstorage') {
|
|
642
|
+
var data = {};
|
|
643
|
+
for (var i = 0; i < localStorage.length; i++) {
|
|
644
|
+
var k = localStorage.key(i);
|
|
645
|
+
if (k && !isInternal(k)) {
|
|
646
|
+
data[k] = localStorage.getItem(k);
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
event.source.postMessage({ type: 'codeyam-localstorage-state', data: data }, '*');
|
|
650
|
+
}
|
|
651
|
+
});
|
|
652
|
+
})();
|
|
653
|
+
</script>`;
|
|
654
|
+
}
|
|
655
|
+
/**
|
|
656
|
+
* Inject the health-check script (and optional localStorage script) into an HTML response body.
|
|
657
|
+
* Inserts before </head> if present, otherwise before </body>, otherwise appends.
|
|
658
|
+
* When a localStorageScript is provided, it's injected BEFORE the health script
|
|
659
|
+
* so localStorage is populated before the app loads.
|
|
660
|
+
*/
|
|
661
|
+
export function injectHealthScript(html, localStorageScript) {
|
|
662
|
+
const scripts = (localStorageScript || '') + PREVIEW_HEALTH_SCRIPT;
|
|
663
|
+
if (html.includes('</head>')) {
|
|
664
|
+
return html.replace('</head>', scripts + '</head>');
|
|
665
|
+
}
|
|
666
|
+
if (html.includes('</body>')) {
|
|
667
|
+
return html.replace('</body>', scripts + '</body>');
|
|
668
|
+
}
|
|
669
|
+
return html + scripts;
|
|
670
|
+
}
|
|
671
|
+
/**
|
|
672
|
+
* Handle POST /__codeyam__/preview-health — store health data in globalThis.
|
|
673
|
+
*/
|
|
674
|
+
function handlePreviewHealthPost(req, res) {
|
|
675
|
+
const chunks = [];
|
|
676
|
+
req.on('data', (chunk) => chunks.push(chunk));
|
|
677
|
+
req.on('end', () => {
|
|
678
|
+
try {
|
|
679
|
+
const body = JSON.parse(Buffer.concat(chunks).toString('utf-8'));
|
|
680
|
+
const current = getPreviewHealth() || {
|
|
681
|
+
errors: [],
|
|
682
|
+
loaded: false,
|
|
683
|
+
hasContent: false,
|
|
684
|
+
url: '',
|
|
685
|
+
lastUpdated: 0,
|
|
686
|
+
};
|
|
687
|
+
if (body.errors && Array.isArray(body.errors)) {
|
|
688
|
+
current.errors = current.errors.concat(body.errors);
|
|
689
|
+
}
|
|
690
|
+
if (body.loaded !== undefined) {
|
|
691
|
+
current.loaded = body.loaded;
|
|
692
|
+
}
|
|
693
|
+
if (body.hasContent !== undefined) {
|
|
694
|
+
current.hasContent = body.hasContent;
|
|
695
|
+
}
|
|
696
|
+
if (body.url) {
|
|
697
|
+
current.url = body.url;
|
|
698
|
+
}
|
|
699
|
+
current.lastUpdated = Date.now();
|
|
700
|
+
setPreviewHealth(current);
|
|
701
|
+
}
|
|
702
|
+
catch {
|
|
703
|
+
// Ignore malformed JSON
|
|
704
|
+
}
|
|
705
|
+
res.writeHead(204);
|
|
706
|
+
res.end();
|
|
707
|
+
});
|
|
708
|
+
}
|
|
308
709
|
/**
|
|
309
710
|
* Handle WebSocket upgrade by piping to the target dev server.
|
|
310
711
|
*/
|
|
@@ -375,7 +776,13 @@ function removeProxyConfig() {
|
|
|
375
776
|
* Supports all HTTP methods (GET, POST, PUT, DELETE, PATCH) with body buffering.
|
|
376
777
|
*/
|
|
377
778
|
export async function startEditorProxy(options) {
|
|
378
|
-
//
|
|
779
|
+
// If proxy is already running, reuse it (prevents second tab from killing first tab's proxy)
|
|
780
|
+
const existing = getProxyState();
|
|
781
|
+
if (existing) {
|
|
782
|
+
console.log(`[editorProxy] Proxy already running on port ${existing.port} → ${existing.targetUrl}`);
|
|
783
|
+
return { port: existing.port };
|
|
784
|
+
}
|
|
785
|
+
// Stop any leftover state (shouldn't happen, but defensive)
|
|
379
786
|
await stopEditorProxy();
|
|
380
787
|
let targetUrl = normalizeTargetUrl(options.targetUrl);
|
|
381
788
|
let port = options.port;
|
|
@@ -415,6 +822,11 @@ export async function startEditorProxy(options) {
|
|
|
415
822
|
res.end();
|
|
416
823
|
return;
|
|
417
824
|
}
|
|
825
|
+
// Intercept preview health reports from the injected script
|
|
826
|
+
if (method === 'POST' && pathname === '/__codeyam__/preview-health') {
|
|
827
|
+
handlePreviewHealthPost(req, res);
|
|
828
|
+
return;
|
|
829
|
+
}
|
|
418
830
|
// Load scenario data (also feeds MockStateManager)
|
|
419
831
|
readScenarioData();
|
|
420
832
|
// For methods that may carry a body, buffer it first
|
|
@@ -446,11 +858,17 @@ export async function startEditorProxy(options) {
|
|
|
446
858
|
'Content-Type': 'application/json',
|
|
447
859
|
'Access-Control-Allow-Origin': '*',
|
|
448
860
|
'X-CodeYam-Proxy': 'scenario-data',
|
|
861
|
+
'Cache-Control': 'no-store',
|
|
449
862
|
});
|
|
450
863
|
res.end(match.body != null ? JSON.stringify(match.body) : '');
|
|
451
864
|
return;
|
|
452
865
|
}
|
|
453
866
|
// No mock match — forward with buffered body
|
|
867
|
+
if ((currentScenarioType === 'application' ||
|
|
868
|
+
currentScenarioType === 'user') &&
|
|
869
|
+
pathname.startsWith('/api/')) {
|
|
870
|
+
mockStateEventEmitter.emitDataMutationForwarded(method, pathname);
|
|
871
|
+
}
|
|
454
872
|
forwardBufferedRequest(req, res, targetUrl, bodyBuffer);
|
|
455
873
|
return;
|
|
456
874
|
}
|
|
@@ -462,6 +880,7 @@ export async function startEditorProxy(options) {
|
|
|
462
880
|
'Content-Type': 'application/json',
|
|
463
881
|
'Access-Control-Allow-Origin': '*',
|
|
464
882
|
'X-CodeYam-Proxy': 'scenario-data',
|
|
883
|
+
'Cache-Control': 'no-store',
|
|
465
884
|
});
|
|
466
885
|
res.end(match.body != null ? JSON.stringify(match.body) : '');
|
|
467
886
|
return;
|
|
@@ -533,6 +952,10 @@ export async function stopEditorProxy() {
|
|
|
533
952
|
export function invalidateScenarioCache() {
|
|
534
953
|
scenarioCache = { data: null, timestamp: 0 };
|
|
535
954
|
sessionConfig = undefined;
|
|
955
|
+
seedSessionCookies = undefined;
|
|
956
|
+
localStorageConfig = null;
|
|
957
|
+
activeScenarioId = null;
|
|
958
|
+
currentPrototypeId = null;
|
|
536
959
|
}
|
|
537
960
|
/**
|
|
538
961
|
* Verify that the proxy can successfully forward a request to the target dev server.
|