ontrackd 0.0.1 → 0.11.1
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/LICENSE +14 -0
- package/README.md +133 -2
- package/dist/cli/build.d.ts +1 -0
- package/dist/cli/build.js +172 -0
- package/dist/cli/build.js.map +1 -0
- package/dist/cli/cloud.d.ts +20 -0
- package/dist/cli/cloud.js +395 -0
- package/dist/cli/cloud.js.map +1 -0
- package/dist/cli/feedback.d.ts +4 -0
- package/dist/cli/feedback.js +90 -0
- package/dist/cli/feedback.js.map +1 -0
- package/dist/cli/hugo.d.ts +1 -0
- package/dist/cli/hugo.js +396 -0
- package/dist/cli/hugo.js.map +1 -0
- package/dist/cli/init.d.ts +8 -0
- package/dist/cli/init.js +346 -0
- package/dist/cli/init.js.map +1 -0
- package/dist/cli/invite.d.ts +2 -0
- package/dist/cli/invite.js +65 -0
- package/dist/cli/invite.js.map +1 -0
- package/dist/cli/link.d.ts +20 -0
- package/dist/cli/link.js +287 -0
- package/dist/cli/link.js.map +1 -0
- package/dist/cli/pull.d.ts +31 -0
- package/dist/cli/pull.js +273 -0
- package/dist/cli/pull.js.map +1 -0
- package/dist/cli/push.d.ts +9 -0
- package/dist/cli/push.js +57 -0
- package/dist/cli/push.js.map +1 -0
- package/dist/cli/remote.d.ts +1 -0
- package/dist/cli/remote.js +114 -0
- package/dist/cli/remote.js.map +1 -0
- package/dist/cli/serve.d.ts +1 -0
- package/dist/cli/serve.js +178 -0
- package/dist/cli/serve.js.map +1 -0
- package/dist/cli/sidecar.d.ts +9 -0
- package/dist/cli/sidecar.js +23 -0
- package/dist/cli/sidecar.js.map +1 -0
- package/dist/core/anchorId.d.ts +42 -0
- package/dist/core/anchorId.js +50 -0
- package/dist/core/anchorId.js.map +1 -0
- package/dist/core/apiKind.d.ts +42 -0
- package/dist/core/apiKind.js +83 -0
- package/dist/core/apiKind.js.map +1 -0
- package/dist/core/astroAnchors.d.ts +39 -0
- package/dist/core/astroAnchors.js +217 -0
- package/dist/core/astroAnchors.js.map +1 -0
- package/dist/core/attachmentTypes.d.ts +74 -0
- package/dist/core/attachmentTypes.js +199 -0
- package/dist/core/attachmentTypes.js.map +1 -0
- package/dist/core/elementHints.d.ts +40 -0
- package/dist/core/elementHints.js +116 -0
- package/dist/core/elementHints.js.map +1 -0
- package/dist/core/exportTaskDoc.d.ts +81 -0
- package/dist/core/exportTaskDoc.js +828 -0
- package/dist/core/exportTaskDoc.js.map +1 -0
- package/dist/core/feedbackTypes.d.ts +241 -0
- package/dist/core/feedbackTypes.js +2 -0
- package/dist/core/feedbackTypes.js.map +1 -0
- package/dist/core/fingerprint.d.ts +12 -0
- package/dist/core/fingerprint.js +24 -0
- package/dist/core/fingerprint.js.map +1 -0
- package/dist/core/htmlAnchors.d.ts +18 -0
- package/dist/core/htmlAnchors.js +157 -0
- package/dist/core/htmlAnchors.js.map +1 -0
- package/dist/core/imageSniff.d.ts +7 -0
- package/dist/core/imageSniff.js +12 -0
- package/dist/core/imageSniff.js.map +1 -0
- package/dist/core/ordering.d.ts +16 -0
- package/dist/core/ordering.js +10 -0
- package/dist/core/ordering.js.map +1 -0
- package/dist/core/oxcAst.d.ts +39 -0
- package/dist/core/oxcAst.js +147 -0
- package/dist/core/oxcAst.js.map +1 -0
- package/dist/core/pageUrl.d.ts +10 -0
- package/dist/core/pageUrl.js +27 -0
- package/dist/core/pageUrl.js.map +1 -0
- package/dist/core/participants.d.ts +14 -0
- package/dist/core/participants.js +38 -0
- package/dist/core/participants.js.map +1 -0
- package/dist/core/ports.d.ts +86 -0
- package/dist/core/ports.js +2 -0
- package/dist/core/ports.js.map +1 -0
- package/dist/core/projectSecret.d.ts +9 -0
- package/dist/core/projectSecret.js +57 -0
- package/dist/core/projectSecret.js.map +1 -0
- package/dist/core/recipe.d.ts +117 -0
- package/dist/core/recipe.js +181 -0
- package/dist/core/recipe.js.map +1 -0
- package/dist/core/recordingSummary.d.ts +12 -0
- package/dist/core/recordingSummary.js +150 -0
- package/dist/core/recordingSummary.js.map +1 -0
- package/dist/core/resolveAnchors.d.ts +70 -0
- package/dist/core/resolveAnchors.js +101 -0
- package/dist/core/resolveAnchors.js.map +1 -0
- package/dist/core/scriptImport.d.ts +10 -0
- package/dist/core/scriptImport.js +18 -0
- package/dist/core/scriptImport.js.map +1 -0
- package/dist/core/sourceAnchors.d.ts +62 -0
- package/dist/core/sourceAnchors.js +82 -0
- package/dist/core/sourceAnchors.js.map +1 -0
- package/dist/core/sourceContext.d.ts +62 -0
- package/dist/core/sourceContext.js +182 -0
- package/dist/core/sourceContext.js.map +1 -0
- package/dist/core/sourcePath.d.ts +2 -0
- package/dist/core/sourcePath.js +11 -0
- package/dist/core/sourcePath.js.map +1 -0
- package/dist/core/staleness.d.ts +118 -0
- package/dist/core/staleness.js +155 -0
- package/dist/core/staleness.js.map +1 -0
- package/dist/core/styleOrigin.d.ts +98 -0
- package/dist/core/styleOrigin.js +142 -0
- package/dist/core/styleOrigin.js.map +1 -0
- package/dist/core/svelteAnchors.d.ts +18 -0
- package/dist/core/svelteAnchors.js +125 -0
- package/dist/core/svelteAnchors.js.map +1 -0
- package/dist/core/taskFiles.d.ts +31 -0
- package/dist/core/taskFiles.js +55 -0
- package/dist/core/taskFiles.js.map +1 -0
- package/dist/core/untrusted.d.ts +57 -0
- package/dist/core/untrusted.js +268 -0
- package/dist/core/untrusted.js.map +1 -0
- package/dist/core/vueAnchors.d.ts +21 -0
- package/dist/core/vueAnchors.js +130 -0
- package/dist/core/vueAnchors.js.map +1 -0
- package/dist/expo/app/Avatar.d.ts +6 -0
- package/dist/expo/app/Avatar.js +12 -0
- package/dist/expo/app/Avatar.js.map +1 -0
- package/dist/expo/app/Bars.d.ts +9 -0
- package/dist/expo/app/Bars.js +38 -0
- package/dist/expo/app/Bars.js.map +1 -0
- package/dist/expo/app/CommentThreadSheet.d.ts +35 -0
- package/dist/expo/app/CommentThreadSheet.js +200 -0
- package/dist/expo/app/CommentThreadSheet.js.map +1 -0
- package/dist/expo/app/CommentsSheet.d.ts +22 -0
- package/dist/expo/app/CommentsSheet.js +76 -0
- package/dist/expo/app/CommentsSheet.js.map +1 -0
- package/dist/expo/app/Files.d.ts +16 -0
- package/dist/expo/app/Files.js +62 -0
- package/dist/expo/app/Files.js.map +1 -0
- package/dist/expo/app/Highlight.d.ts +5 -0
- package/dist/expo/app/Highlight.js +12 -0
- package/dist/expo/app/Highlight.js.map +1 -0
- package/dist/expo/app/Icon.d.ts +9 -0
- package/dist/expo/app/Icon.js +22 -0
- package/dist/expo/app/Icon.js.map +1 -0
- package/dist/expo/app/MarkerPins.d.ts +10 -0
- package/dist/expo/app/MarkerPins.js +70 -0
- package/dist/expo/app/MarkerPins.js.map +1 -0
- package/dist/expo/app/Provider.d.ts +13 -0
- package/dist/expo/app/Provider.js +597 -0
- package/dist/expo/app/Provider.js.map +1 -0
- package/dist/expo/app/Sheet.d.ts +53 -0
- package/dist/expo/app/Sheet.js +106 -0
- package/dist/expo/app/Sheet.js.map +1 -0
- package/dist/expo/app/Toolbar.d.ts +26 -0
- package/dist/expo/app/Toolbar.js +71 -0
- package/dist/expo/app/Toolbar.js.map +1 -0
- package/dist/expo/app/adapter.d.ts +55 -0
- package/dist/expo/app/adapter.js +145 -0
- package/dist/expo/app/adapter.js.map +1 -0
- package/dist/expo/app/api.d.ts +68 -0
- package/dist/expo/app/api.js +86 -0
- package/dist/expo/app/api.js.map +1 -0
- package/dist/expo/app/assets/attach.png +0 -0
- package/dist/expo/app/assets/close.png +0 -0
- package/dist/expo/app/assets/comment.png +0 -0
- package/dist/expo/app/assets/edit.png +0 -0
- package/dist/expo/app/assets/file.png +0 -0
- package/dist/expo/app/assets/narrow.png +0 -0
- package/dist/expo/app/assets/panel.png +0 -0
- package/dist/expo/app/assets/pins.png +0 -0
- package/dist/expo/app/assets/pinsOff.png +0 -0
- package/dist/expo/app/assets/remove.png +0 -0
- package/dist/expo/app/assets/reopen.png +0 -0
- package/dist/expo/app/assets/resolve.png +0 -0
- package/dist/expo/app/assets/send.png +0 -0
- package/dist/expo/app/assets/widen.png +0 -0
- package/dist/expo/app/attachments.d.ts +93 -0
- package/dist/expo/app/attachments.js +181 -0
- package/dist/expo/app/attachments.js.map +1 -0
- package/dist/expo/app/cloudApi.d.ts +63 -0
- package/dist/expo/app/cloudApi.js +330 -0
- package/dist/expo/app/cloudApi.js.map +1 -0
- package/dist/expo/app/cloudAuth.d.ts +20 -0
- package/dist/expo/app/cloudAuth.js +71 -0
- package/dist/expo/app/cloudAuth.js.map +1 -0
- package/dist/expo/app/cloudHttp.d.ts +20 -0
- package/dist/expo/app/cloudHttp.js +46 -0
- package/dist/expo/app/cloudHttp.js.map +1 -0
- package/dist/expo/app/cloudSession.d.ts +30 -0
- package/dist/expo/app/cloudSession.js +72 -0
- package/dist/expo/app/cloudSession.js.map +1 -0
- package/dist/expo/app/comments.d.ts +20 -0
- package/dist/expo/app/comments.js +131 -0
- package/dist/expo/app/comments.js.map +1 -0
- package/dist/expo/app/devMenuNone.d.ts +5 -0
- package/dist/expo/app/devMenuNone.js +3 -0
- package/dist/expo/app/devMenuNone.js.map +1 -0
- package/dist/expo/app/devServerNone.d.ts +4 -0
- package/dist/expo/app/devServerNone.js +4 -0
- package/dist/expo/app/devServerNone.js.map +1 -0
- package/dist/expo/app/embeddedConfig.d.ts +1 -0
- package/dist/expo/app/embeddedConfig.js +12 -0
- package/dist/expo/app/embeddedConfig.js.map +1 -0
- package/dist/expo/app/embeddedConfigCloud.d.ts +2 -0
- package/dist/expo/app/embeddedConfigCloud.js +8 -0
- package/dist/expo/app/embeddedConfigCloud.js.map +1 -0
- package/dist/expo/app/embeddedConfigNone.d.ts +2 -0
- package/dist/expo/app/embeddedConfigNone.js +3 -0
- package/dist/expo/app/embeddedConfigNone.js.map +1 -0
- package/dist/expo/app/expo.d.ts +4 -0
- package/dist/expo/app/expo.js +35 -0
- package/dist/expo/app/expo.js.map +1 -0
- package/dist/expo/app/expoGo.d.ts +4 -0
- package/dist/expo/app/expoGo.js +33 -0
- package/dist/expo/app/expoGo.js.map +1 -0
- package/dist/expo/app/expoPickers.d.ts +11 -0
- package/dist/expo/app/expoPickers.js +91 -0
- package/dist/expo/app/expoPickers.js.map +1 -0
- package/dist/expo/app/expoRandom.d.ts +6 -0
- package/dist/expo/app/expoRandom.js +21 -0
- package/dist/expo/app/expoRandom.js.map +1 -0
- package/dist/expo/app/idle.d.ts +4 -0
- package/dist/expo/app/idle.js +7 -0
- package/dist/expo/app/idle.js.map +1 -0
- package/dist/expo/app/index.d.ts +3 -0
- package/dist/expo/app/index.js +3 -0
- package/dist/expo/app/index.js.map +1 -0
- package/dist/expo/app/interactions.d.ts +38 -0
- package/dist/expo/app/interactions.js +40 -0
- package/dist/expo/app/interactions.js.map +1 -0
- package/dist/expo/app/markers.d.ts +28 -0
- package/dist/expo/app/markers.js +187 -0
- package/dist/expo/app/markers.js.map +1 -0
- package/dist/expo/app/movedAnchors.d.ts +46 -0
- package/dist/expo/app/movedAnchors.js +39 -0
- package/dist/expo/app/movedAnchors.js.map +1 -0
- package/dist/expo/app/native.d.ts +12 -0
- package/dist/expo/app/native.js +78 -0
- package/dist/expo/app/native.js.map +1 -0
- package/dist/expo/app/panel.d.ts +27 -0
- package/dist/expo/app/panel.js +37 -0
- package/dist/expo/app/panel.js.map +1 -0
- package/dist/expo/app/payload.d.ts +43 -0
- package/dist/expo/app/payload.js +22 -0
- package/dist/expo/app/payload.js.map +1 -0
- package/dist/expo/app/pick.d.ts +14 -0
- package/dist/expo/app/pick.js +124 -0
- package/dist/expo/app/pick.js.map +1 -0
- package/dist/expo/app/pickerNone.d.ts +1 -0
- package/dist/expo/app/pickerNone.js +2 -0
- package/dist/expo/app/pickerNone.js.map +1 -0
- package/dist/expo/app/placement.d.ts +53 -0
- package/dist/expo/app/placement.js +100 -0
- package/dist/expo/app/placement.js.map +1 -0
- package/dist/expo/app/random.d.ts +13 -0
- package/dist/expo/app/random.js +56 -0
- package/dist/expo/app/random.js.map +1 -0
- package/dist/expo/app/reactNative.d.ts +2 -0
- package/dist/expo/app/reactNative.js +3 -0
- package/dist/expo/app/reactNative.js.map +1 -0
- package/dist/expo/app/runtimeConfig.d.ts +30 -0
- package/dist/expo/app/runtimeConfig.js +104 -0
- package/dist/expo/app/runtimeConfig.js.map +1 -0
- package/dist/expo/app/sheetMotion.d.ts +22 -0
- package/dist/expo/app/sheetMotion.js +39 -0
- package/dist/expo/app/sheetMotion.js.map +1 -0
- package/dist/expo/app/signIn.d.ts +32 -0
- package/dist/expo/app/signIn.js +28 -0
- package/dist/expo/app/signIn.js.map +1 -0
- package/dist/expo/app/state.d.ts +45 -0
- package/dist/expo/app/state.js +32 -0
- package/dist/expo/app/state.js.map +1 -0
- package/dist/expo/app/theme.d.ts +15 -0
- package/dist/expo/app/theme.js +9 -0
- package/dist/expo/app/theme.js.map +1 -0
- package/dist/expo/app/types.d.ts +87 -0
- package/dist/expo/app/types.js +2 -0
- package/dist/expo/app/types.js.map +1 -0
- package/dist/expo/app/useCloudReviewer.d.ts +75 -0
- package/dist/expo/app/useCloudReviewer.js +211 -0
- package/dist/expo/app/useCloudReviewer.js.map +1 -0
- package/dist/expo/app/useComments.d.ts +64 -0
- package/dist/expo/app/useComments.js +156 -0
- package/dist/expo/app/useComments.js.map +1 -0
- package/dist/expo/app/useUploads.d.ts +32 -0
- package/dist/expo/app/useUploads.js +106 -0
- package/dist/expo/app/useUploads.js.map +1 -0
- package/dist/expo/expoGoMetro.cjs +83 -0
- package/dist/expo/expoMetro.cjs +86 -0
- package/dist/expo/metro.cjs +304 -0
- package/dist/expo/metroBuild.d.ts +22 -0
- package/dist/expo/metroBuild.js +169 -0
- package/dist/expo/metroBuild.js.map +1 -0
- package/dist/expo/middleware.d.ts +11 -0
- package/dist/expo/middleware.js +26 -0
- package/dist/expo/middleware.js.map +1 -0
- package/dist/expo/mode.d.ts +20 -0
- package/dist/expo/mode.js +37 -0
- package/dist/expo/mode.js.map +1 -0
- package/dist/expo/publicConfig.d.ts +37 -0
- package/dist/expo/publicConfig.js +87 -0
- package/dist/expo/publicConfig.js.map +1 -0
- package/dist/expo/transform.d.ts +22 -0
- package/dist/expo/transform.js +38 -0
- package/dist/expo/transform.js.map +1 -0
- package/dist/expo/transformer.cjs +73 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/integration/apiRoutes.d.ts +2 -0
- package/dist/integration/apiRoutes.js +3 -0
- package/dist/integration/apiRoutes.js.map +1 -0
- package/dist/integration/buildCredentials.d.ts +12 -0
- package/dist/integration/buildCredentials.js +97 -0
- package/dist/integration/buildCredentials.js.map +1 -0
- package/dist/integration/buildSession.d.ts +8 -0
- package/dist/integration/buildSession.js +96 -0
- package/dist/integration/buildSession.js.map +1 -0
- package/dist/integration/bundleCheck.d.ts +43 -0
- package/dist/integration/bundleCheck.js +111 -0
- package/dist/integration/bundleCheck.js.map +1 -0
- package/dist/integration/commentPull.d.ts +134 -0
- package/dist/integration/commentPull.js +260 -0
- package/dist/integration/commentPull.js.map +1 -0
- package/dist/integration/configuredApi.d.ts +7 -0
- package/dist/integration/configuredApi.js +24 -0
- package/dist/integration/configuredApi.js.map +1 -0
- package/dist/integration/devCloud.d.ts +27 -0
- package/dist/integration/devCloud.js +56 -0
- package/dist/integration/devCloud.js.map +1 -0
- package/dist/integration/devReviewLinks.d.ts +2 -0
- package/dist/integration/devReviewLinks.js +10 -0
- package/dist/integration/devReviewLinks.js.map +1 -0
- package/dist/integration/gitBranch.d.ts +19 -0
- package/dist/integration/gitBranch.js +56 -0
- package/dist/integration/gitBranch.js.map +1 -0
- package/dist/integration/importPlan.d.ts +19 -0
- package/dist/integration/importPlan.js +90 -0
- package/dist/integration/importPlan.js.map +1 -0
- package/dist/integration/index.d.ts +14 -0
- package/dist/integration/index.js +13 -0
- package/dist/integration/index.js.map +1 -0
- package/dist/integration/manifest.d.ts +120 -0
- package/dist/integration/manifest.js +147 -0
- package/dist/integration/manifest.js.map +1 -0
- package/dist/integration/manifestParts.d.ts +29 -0
- package/dist/integration/manifestParts.js +65 -0
- package/dist/integration/manifestParts.js.map +1 -0
- package/dist/integration/manifestSink.d.ts +75 -0
- package/dist/integration/manifestSink.js +157 -0
- package/dist/integration/manifestSink.js.map +1 -0
- package/dist/integration/manifestUpload.d.ts +64 -0
- package/dist/integration/manifestUpload.js +177 -0
- package/dist/integration/manifestUpload.js.map +1 -0
- package/dist/integration/middleware.d.ts +55 -0
- package/dist/integration/middleware.js +379 -0
- package/dist/integration/middleware.js.map +1 -0
- package/dist/integration/nextStyles.d.ts +4 -0
- package/dist/integration/nextStyles.js +121 -0
- package/dist/integration/nextStyles.js.map +1 -0
- package/dist/integration/requestGuards.d.ts +71 -0
- package/dist/integration/requestGuards.js +255 -0
- package/dist/integration/requestGuards.js.map +1 -0
- package/dist/integration/sharedBuild.d.ts +71 -0
- package/dist/integration/sharedBuild.js +105 -0
- package/dist/integration/sharedBuild.js.map +1 -0
- package/dist/integration/sharedInject.d.ts +88 -0
- package/dist/integration/sharedInject.js +164 -0
- package/dist/integration/sharedInject.js.map +1 -0
- package/dist/integration/sidecarProcess.d.ts +26 -0
- package/dist/integration/sidecarProcess.js +137 -0
- package/dist/integration/sidecarProcess.js.map +1 -0
- package/dist/integration/styleCollector.d.ts +49 -0
- package/dist/integration/styleCollector.js +220 -0
- package/dist/integration/styleCollector.js.map +1 -0
- package/dist/integration/transform.d.ts +24 -0
- package/dist/integration/transform.js +36 -0
- package/dist/integration/transform.js.map +1 -0
- package/dist/integration/tunnelClient.d.ts +44 -0
- package/dist/integration/tunnelClient.js +148 -0
- package/dist/integration/tunnelClient.js.map +1 -0
- package/dist/integration/tunnelProtocol.d.ts +152 -0
- package/dist/integration/tunnelProtocol.js +110 -0
- package/dist/integration/tunnelProtocol.js.map +1 -0
- package/dist/mcp/cli.d.ts +2 -0
- package/dist/mcp/cli.js +327 -0
- package/dist/mcp/cli.js.map +1 -0
- package/dist/mcp/cloudRefresh.d.ts +36 -0
- package/dist/mcp/cloudRefresh.js +52 -0
- package/dist/mcp/cloudRefresh.js.map +1 -0
- package/dist/mcp/context.d.ts +7 -0
- package/dist/mcp/context.js +18 -0
- package/dist/mcp/context.js.map +1 -0
- package/dist/mcp/files.d.ts +66 -0
- package/dist/mcp/files.js +157 -0
- package/dist/mcp/files.js.map +1 -0
- package/dist/mcp/search.d.ts +3 -0
- package/dist/mcp/search.js +9 -0
- package/dist/mcp/search.js.map +1 -0
- package/dist/mcp/server.d.ts +50 -0
- package/dist/mcp/server.js +555 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/overlay/anchors.d.ts +130 -0
- package/dist/overlay/anchors.js +365 -0
- package/dist/overlay/anchors.js.map +1 -0
- package/dist/overlay/api.d.ts +150 -0
- package/dist/overlay/api.js +259 -0
- package/dist/overlay/api.js.map +1 -0
- package/dist/overlay/attachments.d.ts +60 -0
- package/dist/overlay/attachments.js +163 -0
- package/dist/overlay/attachments.js.map +1 -0
- package/dist/overlay/browser.d.ts +1 -0
- package/dist/overlay/browser.js +203 -0
- package/dist/overlay/browser.js.map +1 -0
- package/dist/overlay/chip.d.ts +27 -0
- package/dist/overlay/chip.js +31 -0
- package/dist/overlay/chip.js.map +1 -0
- package/dist/overlay/compact.d.ts +11 -0
- package/dist/overlay/compact.js +21 -0
- package/dist/overlay/compact.js.map +1 -0
- package/dist/overlay/cssScope.d.ts +46 -0
- package/dist/overlay/cssScope.js +180 -0
- package/dist/overlay/cssScope.js.map +1 -0
- package/dist/overlay/cursor.d.ts +2 -0
- package/dist/overlay/cursor.js +68 -0
- package/dist/overlay/cursor.js.map +1 -0
- package/dist/overlay/devBrowser.d.ts +1 -0
- package/dist/overlay/devBrowser.js +18 -0
- package/dist/overlay/devBrowser.js.map +1 -0
- package/dist/overlay/devReview.d.ts +4 -0
- package/dist/overlay/devReview.js +18 -0
- package/dist/overlay/devReview.js.map +1 -0
- package/dist/overlay/directReviewer.d.ts +149 -0
- package/dist/overlay/directReviewer.js +448 -0
- package/dist/overlay/directReviewer.js.map +1 -0
- package/dist/overlay/elementDescription.d.ts +10 -0
- package/dist/overlay/elementDescription.js +251 -0
- package/dist/overlay/elementDescription.js.map +1 -0
- package/dist/overlay/icons.d.ts +8 -0
- package/dist/overlay/icons.js +36 -0
- package/dist/overlay/icons.js.map +1 -0
- package/dist/overlay/identity.d.ts +48 -0
- package/dist/overlay/identity.js +125 -0
- package/dist/overlay/identity.js.map +1 -0
- package/dist/overlay/localMachine.d.ts +23 -0
- package/dist/overlay/localMachine.js +40 -0
- package/dist/overlay/localMachine.js.map +1 -0
- package/dist/overlay/magicLink.d.ts +10 -0
- package/dist/overlay/magicLink.js +87 -0
- package/dist/overlay/magicLink.js.map +1 -0
- package/dist/overlay/modern-screenshot.js +1676 -0
- package/dist/overlay/movedAnchors.d.ts +30 -0
- package/dist/overlay/movedAnchors.js +128 -0
- package/dist/overlay/movedAnchors.js.map +1 -0
- package/dist/overlay/notificationGroups.d.ts +2 -0
- package/dist/overlay/notificationGroups.js +41 -0
- package/dist/overlay/notificationGroups.js.map +1 -0
- package/dist/overlay/permissions.d.ts +10 -0
- package/dist/overlay/permissions.js +9 -0
- package/dist/overlay/permissions.js.map +1 -0
- package/dist/overlay/pinGroups.d.ts +16 -0
- package/dist/overlay/pinGroups.js +17 -0
- package/dist/overlay/pinGroups.js.map +1 -0
- package/dist/overlay/presence.d.ts +50 -0
- package/dist/overlay/presence.js +258 -0
- package/dist/overlay/presence.js.map +1 -0
- package/dist/overlay/projectChannel.d.ts +11 -0
- package/dist/overlay/projectChannel.js +111 -0
- package/dist/overlay/projectChannel.js.map +1 -0
- package/dist/overlay/recorder.d.ts +56 -0
- package/dist/overlay/recorder.js +130 -0
- package/dist/overlay/recorder.js.map +1 -0
- package/dist/overlay/reviewMode.d.ts +21 -0
- package/dist/overlay/reviewMode.js +59 -0
- package/dist/overlay/reviewMode.js.map +1 -0
- package/dist/overlay/reviewerAuth.d.ts +131 -0
- package/dist/overlay/reviewerAuth.js +279 -0
- package/dist/overlay/reviewerAuth.js.map +1 -0
- package/dist/overlay/route.d.ts +18 -0
- package/dist/overlay/route.js +56 -0
- package/dist/overlay/route.js.map +1 -0
- package/dist/overlay/rrweb-record.js +63 -0
- package/dist/overlay/runtime.d.ts +1 -0
- package/dist/overlay/runtime.js +4857 -0
- package/dist/overlay/runtime.js.map +1 -0
- package/dist/overlay/session.d.ts +32 -0
- package/dist/overlay/session.js +76 -0
- package/dist/overlay/session.js.map +1 -0
- package/dist/overlay/sharedMode.d.ts +38 -0
- package/dist/overlay/sharedMode.js +37 -0
- package/dist/overlay/sharedMode.js.map +1 -0
- package/dist/overlay/sheet.d.ts +73 -0
- package/dist/overlay/sheet.js +278 -0
- package/dist/overlay/sheet.js.map +1 -0
- package/dist/overlay/snapshot.d.ts +26 -0
- package/dist/overlay/snapshot.js +185 -0
- package/dist/overlay/snapshot.js.map +1 -0
- package/dist/overlay/state.d.ts +63 -0
- package/dist/overlay/state.js +241 -0
- package/dist/overlay/state.js.map +1 -0
- package/dist/overlay/steps.d.ts +22 -0
- package/dist/overlay/steps.js +34 -0
- package/dist/overlay/steps.js.map +1 -0
- package/dist/overlay/styles.d.ts +7 -0
- package/dist/overlay/styles.js +1449 -0
- package/dist/overlay/styles.js.map +1 -0
- package/dist/overlay/trace.d.ts +19 -0
- package/dist/overlay/trace.js +29 -0
- package/dist/overlay/trace.js.map +1 -0
- package/dist/overlay/upload.d.ts +35 -0
- package/dist/overlay/upload.js +99 -0
- package/dist/overlay/upload.js.map +1 -0
- package/dist/plugin/astro.d.ts +31 -0
- package/dist/plugin/astro.js +22 -0
- package/dist/plugin/astro.js.map +1 -0
- package/dist/plugin/eleventy.d.ts +44 -0
- package/dist/plugin/eleventy.js +186 -0
- package/dist/plugin/eleventy.js.map +1 -0
- package/dist/plugin/next-loader.cjs +11 -0
- package/dist/plugin/next.d.ts +29 -0
- package/dist/plugin/next.js +176 -0
- package/dist/plugin/next.js.map +1 -0
- package/dist/plugin/nextOverlay.d.ts +2 -0
- package/dist/plugin/nextOverlay.js +22 -0
- package/dist/plugin/nextOverlay.js.map +1 -0
- package/dist/plugin/nextTransform.d.ts +19 -0
- package/dist/plugin/nextTransform.js +29 -0
- package/dist/plugin/nextTransform.js.map +1 -0
- package/dist/plugin/rsbuild.d.ts +25 -0
- package/dist/plugin/rsbuild.js +56 -0
- package/dist/plugin/rsbuild.js.map +1 -0
- package/dist/plugin/vite.d.ts +40 -0
- package/dist/plugin/vite.js +585 -0
- package/dist/plugin/vite.js.map +1 -0
- package/dist/plugin/webpack.d.ts +69 -0
- package/dist/plugin/webpack.js +192 -0
- package/dist/plugin/webpack.js.map +1 -0
- package/dist/remote/account.d.ts +41 -0
- package/dist/remote/account.js +177 -0
- package/dist/remote/account.js.map +1 -0
- package/dist/remote/base64url.d.ts +14 -0
- package/dist/remote/base64url.js +71 -0
- package/dist/remote/base64url.js.map +1 -0
- package/dist/remote/branchLabel.d.ts +12 -0
- package/dist/remote/branchLabel.js +20 -0
- package/dist/remote/branchLabel.js.map +1 -0
- package/dist/remote/client.d.ts +340 -0
- package/dist/remote/client.js +424 -0
- package/dist/remote/client.js.map +1 -0
- package/dist/remote/cloudApi.d.ts +72 -0
- package/dist/remote/cloudApi.js +72 -0
- package/dist/remote/cloudApi.js.map +1 -0
- package/dist/remote/codec.d.ts +54 -0
- package/dist/remote/codec.js +62 -0
- package/dist/remote/codec.js.map +1 -0
- package/dist/remote/config.d.ts +30 -0
- package/dist/remote/config.js +112 -0
- package/dist/remote/config.js.map +1 -0
- package/dist/remote/content-schema.d.ts +428 -0
- package/dist/remote/content-schema.js +209 -0
- package/dist/remote/content-schema.js.map +1 -0
- package/dist/remote/content.d.ts +44 -0
- package/dist/remote/content.js +75 -0
- package/dist/remote/content.js.map +1 -0
- package/dist/remote/envelope.d.ts +76 -0
- package/dist/remote/envelope.js +109 -0
- package/dist/remote/envelope.js.map +1 -0
- package/dist/remote/errors.d.ts +55 -0
- package/dist/remote/errors.js +63 -0
- package/dist/remote/errors.js.map +1 -0
- package/dist/remote/ids.d.ts +8 -0
- package/dist/remote/ids.js +25 -0
- package/dist/remote/ids.js.map +1 -0
- package/dist/remote/index.d.ts +7 -0
- package/dist/remote/index.js +8 -0
- package/dist/remote/index.js.map +1 -0
- package/dist/remote/keys.d.ts +62 -0
- package/dist/remote/keys.js +162 -0
- package/dist/remote/keys.js.map +1 -0
- package/dist/remote/localAnchors.d.ts +4 -0
- package/dist/remote/localAnchors.js +23 -0
- package/dist/remote/localAnchors.js.map +1 -0
- package/dist/remote/mapping.d.ts +11 -0
- package/dist/remote/mapping.js +22 -0
- package/dist/remote/mapping.js.map +1 -0
- package/dist/remote/presence.d.ts +63 -0
- package/dist/remote/presence.js +143 -0
- package/dist/remote/presence.js.map +1 -0
- package/dist/remote/realtime.d.ts +142 -0
- package/dist/remote/realtime.js +326 -0
- package/dist/remote/realtime.js.map +1 -0
- package/dist/remote/store.d.ts +183 -0
- package/dist/remote/store.js +907 -0
- package/dist/remote/store.js.map +1 -0
- package/dist/remote/sync.d.ts +113 -0
- package/dist/remote/sync.js +370 -0
- package/dist/remote/sync.js.map +1 -0
- package/dist/remote/types.d.ts +99 -0
- package/dist/remote/types.js +6 -0
- package/dist/remote/types.js.map +1 -0
- package/dist/setup/agents.d.ts +23 -0
- package/dist/setup/agents.js +80 -0
- package/dist/setup/agents.js.map +1 -0
- package/dist/setup/configure.d.ts +27 -0
- package/dist/setup/configure.js +201 -0
- package/dist/setup/configure.js.map +1 -0
- package/dist/setup/connect.d.ts +60 -0
- package/dist/setup/connect.js +244 -0
- package/dist/setup/connect.js.map +1 -0
- package/dist/setup/detect.d.ts +67 -0
- package/dist/setup/detect.js +168 -0
- package/dist/setup/detect.js.map +1 -0
- package/dist/setup/frameworks.d.ts +41 -0
- package/dist/setup/frameworks.js +81 -0
- package/dist/setup/frameworks.js.map +1 -0
- package/dist/sidecar/cli.d.ts +1 -0
- package/dist/sidecar/cli.js +70 -0
- package/dist/sidecar/cli.js.map +1 -0
- package/dist/sidecar/cloudSync.d.ts +33 -0
- package/dist/sidecar/cloudSync.js +139 -0
- package/dist/sidecar/cloudSync.js.map +1 -0
- package/dist/sidecar/commentFiles.d.ts +59 -0
- package/dist/sidecar/commentFiles.js +217 -0
- package/dist/sidecar/commentFiles.js.map +1 -0
- package/dist/sidecar/cssAttribution.d.ts +26 -0
- package/dist/sidecar/cssAttribution.js +114 -0
- package/dist/sidecar/cssAttribution.js.map +1 -0
- package/dist/sidecar/exportTasks.d.ts +38 -0
- package/dist/sidecar/exportTasks.js +249 -0
- package/dist/sidecar/exportTasks.js.map +1 -0
- package/dist/sidecar/http.d.ts +20 -0
- package/dist/sidecar/http.js +904 -0
- package/dist/sidecar/http.js.map +1 -0
- package/dist/sidecar/inviteTarget.d.ts +4 -0
- package/dist/sidecar/inviteTarget.js +32 -0
- package/dist/sidecar/inviteTarget.js.map +1 -0
- package/dist/sidecar/presence.d.ts +4 -0
- package/dist/sidecar/presence.js +92 -0
- package/dist/sidecar/presence.js.map +1 -0
- package/dist/storage/cliSession.d.ts +8 -0
- package/dist/storage/cliSession.js +41 -0
- package/dist/storage/cliSession.js.map +1 -0
- package/dist/storage/devStyleMap.d.ts +12 -0
- package/dist/storage/devStyleMap.js +31 -0
- package/dist/storage/devStyleMap.js.map +1 -0
- package/dist/storage/fileCache.d.ts +34 -0
- package/dist/storage/fileCache.js +122 -0
- package/dist/storage/fileCache.js.map +1 -0
- package/dist/storage/localAttachments.d.ts +82 -0
- package/dist/storage/localAttachments.js +276 -0
- package/dist/storage/localAttachments.js.map +1 -0
- package/dist/storage/localComments.d.ts +31 -0
- package/dist/storage/localComments.js +159 -0
- package/dist/storage/localComments.js.map +1 -0
- package/dist/storage/localCredentials.d.ts +74 -0
- package/dist/storage/localCredentials.js +210 -0
- package/dist/storage/localCredentials.js.map +1 -0
- package/dist/storage/localParticipants.d.ts +33 -0
- package/dist/storage/localParticipants.js +110 -0
- package/dist/storage/localParticipants.js.map +1 -0
- package/dist/storage/localRecipe.d.ts +22 -0
- package/dist/storage/localRecipe.js +46 -0
- package/dist/storage/localRecipe.js.map +1 -0
- package/dist/storage/localScreenshots.d.ts +23 -0
- package/dist/storage/localScreenshots.js +55 -0
- package/dist/storage/localScreenshots.js.map +1 -0
- package/dist/storage/localSource.d.ts +31 -0
- package/dist/storage/localSource.js +175 -0
- package/dist/storage/localSource.js.map +1 -0
- package/dist/storage/pulledComments.d.ts +81 -0
- package/dist/storage/pulledComments.js +107 -0
- package/dist/storage/pulledComments.js.map +1 -0
- package/dist/storage/remoteRecipe.d.ts +7 -0
- package/dist/storage/remoteRecipe.js +85 -0
- package/dist/storage/remoteRecipe.js.map +1 -0
- package/dist/storage/savedRemote.d.ts +2 -0
- package/dist/storage/savedRemote.js +22 -0
- package/dist/storage/savedRemote.js.map +1 -0
- package/dist/storage/sidecarAccess.d.ts +7 -0
- package/dist/storage/sidecarAccess.js +68 -0
- package/dist/storage/sidecarAccess.js.map +1 -0
- package/package.json +306 -4
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { appendFileSync, readFileSync, existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { spawnSync } from 'node:child_process';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { projectIdFromSecret } from '../core/projectSecret.js';
|
|
6
|
+
import { writePrivateJson } from '../remote/config.js';
|
|
7
|
+
export const credentialsFile = 'credentials.json';
|
|
8
|
+
export function credentialsPath(projectRoot) {
|
|
9
|
+
return path.join(projectRoot, '.feedback', credentialsFile);
|
|
10
|
+
}
|
|
11
|
+
export async function readCredentials(projectRoot) {
|
|
12
|
+
const raw = await readFile(credentialsPath(projectRoot), 'utf8').catch(() => null);
|
|
13
|
+
if (raw === null) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
try {
|
|
17
|
+
const parsed = JSON.parse(raw);
|
|
18
|
+
if (typeof parsed.projectId !== 'string' || typeof parsed.secret !== 'string') {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
projectId: parsed.projectId,
|
|
23
|
+
secret: parsed.secret,
|
|
24
|
+
cloudOrigin: typeof parsed.cloudOrigin === 'string' ? parsed.cloudOrigin : null,
|
|
25
|
+
fetchedAt: typeof parsed.fetchedAt === 'string' ? parsed.fetchedAt : new Date().toISOString(),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export async function writeCredentials(projectRoot, credentials) {
|
|
33
|
+
const target = credentialsPath(projectRoot);
|
|
34
|
+
// Ignored before it exists, so there is no moment a `git add -A` could pick it up.
|
|
35
|
+
ensureGitignored(projectRoot);
|
|
36
|
+
// 0600: this is a key. The directory is gitignored, which stops it being committed and does
|
|
37
|
+
// nothing about anyone already on the machine. Replaced atomically, which also repairs the
|
|
38
|
+
// mode of an older file and replaces rather than follows a planted link.
|
|
39
|
+
await writePrivateJson(target, credentials);
|
|
40
|
+
return target;
|
|
41
|
+
}
|
|
42
|
+
/** The env files read, in the order frameworks give them precedence: the local one wins. */
|
|
43
|
+
export const projectEnvFiles = ['.env.local', '.env'];
|
|
44
|
+
/**
|
|
45
|
+
* The package's own variables (`FEEDBACK_*`) from the project's env files.
|
|
46
|
+
*
|
|
47
|
+
* The secret is all a project needs, and the natural place for a developer to keep it is next to
|
|
48
|
+
* the app's other variables. But the processes that need it are often not started by the app: an
|
|
49
|
+
* agent spawns the MCP server with its own environment, and `feedback pull` runs from a shell. So
|
|
50
|
+
* the files are read here rather than trusted to be loaded. Only `FEEDBACK_*` keys are taken, so
|
|
51
|
+
* nothing else in someone's `.env` passes through this package.
|
|
52
|
+
*
|
|
53
|
+
* Deliberately small: `KEY=value`, an optional `export `, single or double quotes, and `#`
|
|
54
|
+
* comments. No interpolation or multi-line values; a secret needs neither.
|
|
55
|
+
*/
|
|
56
|
+
export async function readProjectEnv(projectRoot) {
|
|
57
|
+
const found = {};
|
|
58
|
+
// Lowest precedence first, so a later file overwrites an earlier one.
|
|
59
|
+
for (const name of [...projectEnvFiles].reverse()) {
|
|
60
|
+
const text = await readFile(path.join(projectRoot, name), 'utf8').catch(() => null);
|
|
61
|
+
if (text === null)
|
|
62
|
+
continue;
|
|
63
|
+
for (const line of text.split(/\r?\n/)) {
|
|
64
|
+
const match = /^\s*(?:export\s+)?(FEEDBACK_[A-Z0-9_]+)\s*=\s*(.*)$/.exec(line);
|
|
65
|
+
if (!match)
|
|
66
|
+
continue;
|
|
67
|
+
const raw = match[2].trim();
|
|
68
|
+
const quoted = /^(['"])(.*)\1/.exec(raw);
|
|
69
|
+
found[match[1]] = quoted ? quoted[2] : raw.replace(/\s+#.*$/, '').trim();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return found;
|
|
73
|
+
}
|
|
74
|
+
/** `env` over the project's env files: a variable really set wins, as it would in the app. */
|
|
75
|
+
export async function withProjectEnv(projectRoot, env = process.env) {
|
|
76
|
+
const fromFiles = await readProjectEnv(projectRoot);
|
|
77
|
+
const merged = { ...fromFiles };
|
|
78
|
+
for (const [key, value] of Object.entries(env))
|
|
79
|
+
if (value !== undefined && value !== '')
|
|
80
|
+
merged[key] = value;
|
|
81
|
+
return merged;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Where the CLI, the sidecar and the MCP server get the project secret: the environment, then the
|
|
85
|
+
* project's env files (`.env.local`, `.env`), then the cache `feedback link` writes.
|
|
86
|
+
*
|
|
87
|
+
* The secret carries the project id, so it is the only thing to set. CI has no link step and no
|
|
88
|
+
* cached file, so the variable is the only route there; preferring it also gives a way to point a
|
|
89
|
+
* machine at a different project without editing a file.
|
|
90
|
+
*/
|
|
91
|
+
export async function resolveSecret(projectRoot, env = process.env) {
|
|
92
|
+
const fromEnv = idAndSecret(env);
|
|
93
|
+
if (fromEnv)
|
|
94
|
+
return { ...fromEnv, source: 'env' };
|
|
95
|
+
// An id set explicitly in the environment still names the project of a secret from a file.
|
|
96
|
+
const explicitId = env.FEEDBACK_PROJECT_ID?.trim();
|
|
97
|
+
const fromFiles = idAndSecret({ ...await readProjectEnv(projectRoot), ...(explicitId ? { FEEDBACK_PROJECT_ID: explicitId } : {}) });
|
|
98
|
+
if (fromFiles)
|
|
99
|
+
return { ...fromFiles, source: 'env-file' };
|
|
100
|
+
const cached = await readCredentials(projectRoot);
|
|
101
|
+
if (cached) {
|
|
102
|
+
return { projectId: cached.projectId, secret: cached.secret, source: 'file' };
|
|
103
|
+
}
|
|
104
|
+
const secret = env.FEEDBACK_SECRET?.trim() || undefined;
|
|
105
|
+
return { projectId: env.FEEDBACK_PROJECT_ID?.trim() || undefined, secret, source: 'none' };
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* The id comes from the secret unless one is given explicitly. Explicit still wins, so a secret
|
|
109
|
+
* minted before the id travelled inside keeps working with both variables set.
|
|
110
|
+
*/
|
|
111
|
+
function idAndSecret(env) {
|
|
112
|
+
const secret = env.FEEDBACK_SECRET?.trim();
|
|
113
|
+
if (!secret)
|
|
114
|
+
return null;
|
|
115
|
+
const projectId = env.FEEDBACK_PROJECT_ID?.trim() || projectIdFromSecret(secret) || undefined;
|
|
116
|
+
return projectId ? { projectId, secret } : null;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Makes sure the credentials file cannot be committed.
|
|
120
|
+
*
|
|
121
|
+
* Returns what it did, so a caller can say so rather than editing a developer's `.gitignore`
|
|
122
|
+
* silently. Does nothing when an existing rule already covers the file - appending a
|
|
123
|
+
* redundant line to someone's config is a small rudeness that adds up. A project with no
|
|
124
|
+
* `.gitignore` gets one: a secret is never left committable for want of the file.
|
|
125
|
+
*
|
|
126
|
+
* Necessary and not sufficient: the cloud is the source of truth precisely because a
|
|
127
|
+
* gitignored file can still be copied, backed up, or read by anything on the machine.
|
|
128
|
+
*/
|
|
129
|
+
export function ensureGitignored(projectRoot) {
|
|
130
|
+
const gitignore = path.join(projectRoot, '.gitignore');
|
|
131
|
+
if (!existsSync(gitignore)) {
|
|
132
|
+
mkdirSync(projectRoot, { recursive: true });
|
|
133
|
+
writeFileSync(gitignore, `# feedback: the cached project secret\n.feedback/${credentialsFile}\n`, 'utf8');
|
|
134
|
+
return 'added';
|
|
135
|
+
}
|
|
136
|
+
const contents = readFileSync(gitignore, 'utf8');
|
|
137
|
+
const lines = contents.split('\n').map((line) => line.trim());
|
|
138
|
+
const covered = lines.some((line) => line === '.feedback'
|
|
139
|
+
|| line === '.feedback/'
|
|
140
|
+
|| line === `.feedback/${credentialsFile}`
|
|
141
|
+
|| line === `/.feedback/${credentialsFile}`);
|
|
142
|
+
if (covered) {
|
|
143
|
+
return 'already-covered';
|
|
144
|
+
}
|
|
145
|
+
appendFileSync(gitignore, `${contents.endsWith('\n') ? '' : '\n'}\n# feedback: the cached project secret\n.feedback/${credentialsFile}\n`, 'utf8');
|
|
146
|
+
return 'added';
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* `ensureGitignored` for any file of the app (`.env.local`, `.feedback/connect.json`): makes sure
|
|
150
|
+
* git will not pick it up, and says what it did.
|
|
151
|
+
*
|
|
152
|
+
* Git itself answers when it can (`git check-ignore`), so a rule in a parent directory or a global
|
|
153
|
+
* excludes file counts, as it does for git. Without git, the app's own `.gitignore` is read, with the
|
|
154
|
+
* glob forms people write for these files (`.env*`, `*.local`, `.feedback/`) and later `!` rules
|
|
155
|
+
* undoing earlier ones. Appends only when nothing covers the file; creates the `.gitignore` if there
|
|
156
|
+
* is none.
|
|
157
|
+
*/
|
|
158
|
+
export function ensureIgnored(projectRoot, file, comment) {
|
|
159
|
+
const checked = spawnSync('git', ['check-ignore', '-q', '--', file], { cwd: projectRoot, stdio: 'ignore' });
|
|
160
|
+
if (checked.status === 0)
|
|
161
|
+
return 'already-covered';
|
|
162
|
+
const gitignore = path.join(projectRoot, '.gitignore');
|
|
163
|
+
const contents = existsSync(gitignore) ? readFileSync(gitignore, 'utf8') : null;
|
|
164
|
+
if (contents !== null && checked.status !== 1 && gitignoreCovers(contents, file))
|
|
165
|
+
return 'already-covered';
|
|
166
|
+
const block = `# ${comment}\n${file}\n`;
|
|
167
|
+
if (contents === null) {
|
|
168
|
+
mkdirSync(projectRoot, { recursive: true });
|
|
169
|
+
writeFileSync(gitignore, block, 'utf8');
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
appendFileSync(gitignore, `${contents.endsWith('\n') || contents === '' ? '' : '\n'}\n${block}`, 'utf8');
|
|
173
|
+
}
|
|
174
|
+
return 'added';
|
|
175
|
+
}
|
|
176
|
+
/** Whether the rules of one `.gitignore` (at the app's root) ignore `file`, a slash-separated path. */
|
|
177
|
+
export function gitignoreCovers(contents, file) {
|
|
178
|
+
let ignored = false;
|
|
179
|
+
for (const rawLine of contents.split(/\r?\n/)) {
|
|
180
|
+
const line = rawLine.trim();
|
|
181
|
+
if (!line || line.startsWith('#'))
|
|
182
|
+
continue;
|
|
183
|
+
const negated = line.startsWith('!');
|
|
184
|
+
if (gitignorePatternMatches(negated ? line.slice(1) : line, file))
|
|
185
|
+
ignored = !negated;
|
|
186
|
+
}
|
|
187
|
+
return ignored;
|
|
188
|
+
}
|
|
189
|
+
function gitignorePatternMatches(pattern, file) {
|
|
190
|
+
const directoryOnly = pattern.endsWith('/');
|
|
191
|
+
// A slash at the start or in the middle ties the pattern to the .gitignore's directory.
|
|
192
|
+
const anchored = pattern.replace(/\/+$/, '').includes('/');
|
|
193
|
+
const body = pattern.replace(/^\/+|\/+$/g, '');
|
|
194
|
+
if (!body)
|
|
195
|
+
return false;
|
|
196
|
+
const source = body.split(/(\*\*|\*|\?)/).map((part) => part === '**' ? '.*' : part === '*' ? '[^/]*' : part === '?' ? '[^/]'
|
|
197
|
+
: part.replace(/[.+^${}()|[\]\\]/g, '\\$&')).join('');
|
|
198
|
+
const regex = new RegExp(`^${source}$`);
|
|
199
|
+
const parts = file.split('/');
|
|
200
|
+
// A pattern names the file itself or one of the directories it is in (directory-only: those).
|
|
201
|
+
for (let index = 0; index < parts.length; index += 1) {
|
|
202
|
+
if (directoryOnly && index === parts.length - 1)
|
|
203
|
+
break;
|
|
204
|
+
const candidate = anchored ? parts.slice(0, index + 1).join('/') : parts[index];
|
|
205
|
+
if (regex.test(candidate))
|
|
206
|
+
return true;
|
|
207
|
+
}
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
210
|
+
//# sourceMappingURL=localCredentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localCredentials.js","sourceRoot":"","sources":["../../src/storage/localCredentials.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7F,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAkBvD,MAAM,CAAC,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAElD,MAAM,UAAU,eAAe,CAAC,WAAmB;IACjD,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,EAAE,eAAe,CAAC,CAAC;AAC9D,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,WAAmB;IACvD,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,eAAe,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IACnF,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CAAC;QACH,MAAM,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C,OAAO,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACxD,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,CAAC;IACxC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC9B,8FAA8F;IAC9F,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QACrD,IAAI,aAAa,IAAI,KAAK,KAAK,KAAK,CAAC,MAAM,GAAG,CAAC;YAAE,MAAM;QACvD,MAAM,SAAS,GAAG,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAE,CAAC;QACjF,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC;YAAE,OAAO,IAAI,CAAC;IACzC,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type Participant } from '../core/participants.js';
|
|
2
|
+
import type { IdentifyOutcome, ParticipantStore } from '../core/ports.js';
|
|
3
|
+
/**
|
|
4
|
+
* Remembers who has joined a review.
|
|
5
|
+
*
|
|
6
|
+
* Identity is the participant id the browser stores, which is reliable for the same
|
|
7
|
+
* browser. The IP is only a secondary hint for recognising someone who comes back from a
|
|
8
|
+
* new browser or a cleared profile, and is deliberately treated as such: shared networks
|
|
9
|
+
* and NAT mean several people can present the same address, so a match offers a name to
|
|
10
|
+
* confirm rather than assuming one.
|
|
11
|
+
*/
|
|
12
|
+
export declare class LocalParticipantStore implements ParticipantStore {
|
|
13
|
+
private readonly filePath;
|
|
14
|
+
private queue;
|
|
15
|
+
constructor(projectRoot: string);
|
|
16
|
+
private mutate;
|
|
17
|
+
list(): Promise<Participant[]>;
|
|
18
|
+
/** Looks up a participant by id, falling back to a recent match on the same address. */
|
|
19
|
+
identify(id: string | null, ip: string | null): Promise<IdentifyOutcome>;
|
|
20
|
+
/** Creates or updates a participant, and stamps where they were last seen. */
|
|
21
|
+
save(input: {
|
|
22
|
+
id: string;
|
|
23
|
+
name: string;
|
|
24
|
+
ip: string | null;
|
|
25
|
+
}): Promise<Participant>;
|
|
26
|
+
private read;
|
|
27
|
+
private write;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The client address, honouring the proxy headers a tunnel adds. Without this every
|
|
31
|
+
* remote participant looks like 127.0.0.1, because the tunnel client is what connects.
|
|
32
|
+
*/
|
|
33
|
+
export declare function clientIpFrom(headers: Record<string, string | string[] | undefined>, socketAddress?: string): string | null;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { mkdir, readFile, rename, writeFile } from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { colorForId } from '../core/participants.js';
|
|
4
|
+
/**
|
|
5
|
+
* Remembers who has joined a review.
|
|
6
|
+
*
|
|
7
|
+
* Identity is the participant id the browser stores, which is reliable for the same
|
|
8
|
+
* browser. The IP is only a secondary hint for recognising someone who comes back from a
|
|
9
|
+
* new browser or a cleared profile, and is deliberately treated as such: shared networks
|
|
10
|
+
* and NAT mean several people can present the same address, so a match offers a name to
|
|
11
|
+
* confirm rather than assuming one.
|
|
12
|
+
*/
|
|
13
|
+
export class LocalParticipantStore {
|
|
14
|
+
filePath;
|
|
15
|
+
queue = Promise.resolve();
|
|
16
|
+
constructor(projectRoot) {
|
|
17
|
+
this.filePath = path.join(projectRoot, '.feedback', 'participants.json');
|
|
18
|
+
}
|
|
19
|
+
mutate(operation) {
|
|
20
|
+
const result = this.queue.then(operation, operation);
|
|
21
|
+
this.queue = result.catch(() => undefined);
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
async list() {
|
|
25
|
+
return (await this.read()).participants;
|
|
26
|
+
}
|
|
27
|
+
/** Looks up a participant by id, falling back to a recent match on the same address. */
|
|
28
|
+
async identify(id, ip) {
|
|
29
|
+
const { participants } = await this.read();
|
|
30
|
+
if (id) {
|
|
31
|
+
const exact = participants.find((participant) => participant.id === id);
|
|
32
|
+
if (exact) {
|
|
33
|
+
return { participant: exact, matchedBy: 'id' };
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (ip) {
|
|
37
|
+
const recent = participants
|
|
38
|
+
.filter((participant) => participant.lastIp === ip)
|
|
39
|
+
.sort((left, right) => right.lastSeen.localeCompare(left.lastSeen))[0];
|
|
40
|
+
if (recent) {
|
|
41
|
+
return { participant: recent, matchedBy: 'ip' };
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return { participant: null, matchedBy: 'none' };
|
|
45
|
+
}
|
|
46
|
+
/** Creates or updates a participant, and stamps where they were last seen. */
|
|
47
|
+
save(input) {
|
|
48
|
+
return this.mutate(async () => {
|
|
49
|
+
const data = await this.read();
|
|
50
|
+
const existing = data.participants.find((participant) => participant.id === input.id);
|
|
51
|
+
const now = new Date().toISOString();
|
|
52
|
+
if (existing) {
|
|
53
|
+
existing.name = input.name;
|
|
54
|
+
existing.lastIp = input.ip;
|
|
55
|
+
existing.lastSeen = now;
|
|
56
|
+
await this.write(data);
|
|
57
|
+
return existing;
|
|
58
|
+
}
|
|
59
|
+
const participant = {
|
|
60
|
+
id: input.id,
|
|
61
|
+
name: input.name,
|
|
62
|
+
color: colorForId(input.id),
|
|
63
|
+
lastIp: input.ip,
|
|
64
|
+
lastSeen: now,
|
|
65
|
+
};
|
|
66
|
+
data.participants.push(participant);
|
|
67
|
+
await this.write(data);
|
|
68
|
+
return participant;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
async read() {
|
|
72
|
+
try {
|
|
73
|
+
const raw = JSON.parse(await readFile(this.filePath, 'utf8'));
|
|
74
|
+
if (!raw || typeof raw !== 'object' || !('participants' in raw) || !Array.isArray(raw.participants)) {
|
|
75
|
+
return { version: 1, participants: [] };
|
|
76
|
+
}
|
|
77
|
+
return { version: 1, participants: raw.participants };
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
if (error && typeof error === 'object' && 'code' in error && error.code === 'ENOENT') {
|
|
81
|
+
return { version: 1, participants: [] };
|
|
82
|
+
}
|
|
83
|
+
throw error;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
async write(data) {
|
|
87
|
+
await mkdir(path.dirname(this.filePath), { recursive: true });
|
|
88
|
+
const tempPath = `${this.filePath}.${process.pid}.${Date.now()}.tmp`;
|
|
89
|
+
// 0600: reviewers' words and names are nobody else's on this machine to read.
|
|
90
|
+
await writeFile(tempPath, `${JSON.stringify(data, null, 2)}\n`, { mode: 0o600 });
|
|
91
|
+
await rename(tempPath, this.filePath);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* The client address, honouring the proxy headers a tunnel adds. Without this every
|
|
96
|
+
* remote participant looks like 127.0.0.1, because the tunnel client is what connects.
|
|
97
|
+
*/
|
|
98
|
+
export function clientIpFrom(headers, socketAddress) {
|
|
99
|
+
const forwarded = headers['x-forwarded-for'];
|
|
100
|
+
const first = Array.isArray(forwarded) ? forwarded[0] : forwarded;
|
|
101
|
+
if (first) {
|
|
102
|
+
return first.split(',')[0].trim() || null;
|
|
103
|
+
}
|
|
104
|
+
const real = headers['cf-connecting-ip'] ?? headers['x-real-ip'];
|
|
105
|
+
if (typeof real === 'string' && real) {
|
|
106
|
+
return real;
|
|
107
|
+
}
|
|
108
|
+
return socketAddress ?? null;
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=localParticipants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localParticipants.js","sourceRoot":"","sources":["../../src/storage/localParticipants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EA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,GAAG,IAAI,CAAC,QAAQ,IAAI,OAAO,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC;QACrE,8EAA8E;QAC9E,MAAM,SAAS,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QACjF,MAAM,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IACxC,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,OAAsD,EAAE,aAAsB;IACzG,MAAM,SAAS,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC7C,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAClE,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,IAAI,CAAC;IAC5C,CAAC;IAED,MAAM,IAAI,GAAG,OAAO,CAAC,kBAAkB,CAAC,IAAI,OAAO,CAAC,WAAW,CAAC,CAAC;IACjE,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,EAAE,CAAC;QACrC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,aAAa,IAAI,IAAI,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type Recipe } from '../core/recipe.js';
|
|
2
|
+
/**
|
|
3
|
+
* The recipe this machine last downloaded.
|
|
4
|
+
*
|
|
5
|
+
* Cached on disk so an export never depends on the network. The cache is
|
|
6
|
+
* an upgrade over what the package shipped with; it is not a requirement, and every path out of
|
|
7
|
+
* here has somewhere to land.
|
|
8
|
+
*/
|
|
9
|
+
export declare function recipePath(projectRoot: string): string;
|
|
10
|
+
export declare function writeRecipe(projectRoot: string, recipe: unknown): Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* The recipe to render with, and where it came from.
|
|
13
|
+
*
|
|
14
|
+
* Never throws and never returns nothing. A missing file, unreadable JSON, a recipe that fails
|
|
15
|
+
* validation and a recipe older than the bundled one all resolve to the bundled one, with a
|
|
16
|
+
* reason the caller can report.
|
|
17
|
+
*/
|
|
18
|
+
export declare function loadRecipe(projectRoot: string, env?: NodeJS.ProcessEnv, fetchImpl?: typeof fetch, now?: () => number): Promise<{
|
|
19
|
+
recipe: Recipe;
|
|
20
|
+
source: 'cloud' | 'bundled';
|
|
21
|
+
reason?: string;
|
|
22
|
+
}>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { resolveRecipe } from '../core/recipe.js';
|
|
4
|
+
import { loadRemoteRecipe } from './remoteRecipe.js';
|
|
5
|
+
import { readSavedRemote } from './savedRemote.js';
|
|
6
|
+
/**
|
|
7
|
+
* The recipe this machine last downloaded.
|
|
8
|
+
*
|
|
9
|
+
* Cached on disk so an export never depends on the network. The cache is
|
|
10
|
+
* an upgrade over what the package shipped with; it is not a requirement, and every path out of
|
|
11
|
+
* here has somewhere to land.
|
|
12
|
+
*/
|
|
13
|
+
export function recipePath(projectRoot) {
|
|
14
|
+
return path.join(projectRoot, '.feedback', 'recipe.json');
|
|
15
|
+
}
|
|
16
|
+
export async function writeRecipe(projectRoot, recipe) {
|
|
17
|
+
const target = recipePath(projectRoot);
|
|
18
|
+
await mkdir(path.dirname(target), { recursive: true });
|
|
19
|
+
await writeFile(target, `${JSON.stringify(recipe, null, 2)}\n`, 'utf8');
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The recipe to render with, and where it came from.
|
|
23
|
+
*
|
|
24
|
+
* Never throws and never returns nothing. A missing file, unreadable JSON, a recipe that fails
|
|
25
|
+
* validation and a recipe older than the bundled one all resolve to the bundled one, with a
|
|
26
|
+
* reason the caller can report.
|
|
27
|
+
*/
|
|
28
|
+
export async function loadRecipe(projectRoot, env = process.env, fetchImpl = fetch, now = Date.now) {
|
|
29
|
+
const raw = await readFile(recipePath(projectRoot), 'utf8').catch(() => null);
|
|
30
|
+
let legacy = resolveRecipe(null);
|
|
31
|
+
try {
|
|
32
|
+
if (raw !== null)
|
|
33
|
+
legacy = resolveRecipe(JSON.parse(raw));
|
|
34
|
+
}
|
|
35
|
+
catch { /* Invalid legacy JSON leaves the bundled fallback. */ }
|
|
36
|
+
const saved = env.FEEDBACK_API_URL?.trim() ? null : await readSavedRemote(projectRoot);
|
|
37
|
+
const apiUrl = env.FEEDBACK_API_URL?.trim()
|
|
38
|
+
|| (typeof saved?.apiUrl === 'string' ? saved.apiUrl.trim() : '');
|
|
39
|
+
if (apiUrl) {
|
|
40
|
+
const remote = await loadRemoteRecipe(projectRoot, apiUrl, fetchImpl, now);
|
|
41
|
+
if (remote.source === 'cloud' && remote.recipe.version >= legacy.recipe.version)
|
|
42
|
+
return remote;
|
|
43
|
+
}
|
|
44
|
+
return legacy;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=localRecipe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localRecipe.js","sourceRoot":"","sources":["../../src/storage/localRecipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAe,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,WAAm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AAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACpE,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC;QAC3E,IAAI,MAAM,CAAC,MAAM,KAAK,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO;YAAE,OAAO,MAAM,CAAC;IACjG,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pictures of commented elements, on this machine: `.feedback/screenshots/<comment id>.<ext>`.
|
|
3
|
+
*
|
|
4
|
+
* Beside the comments rather than inside them, so the store stays small text and the picture is
|
|
5
|
+
* a file an agent can open by path - which is what the work order gives it.
|
|
6
|
+
*/
|
|
7
|
+
export declare const maxLocalScreenshotBytes: number;
|
|
8
|
+
export declare function saveLocalScreenshot(root: string, commentId: string, bytes: Uint8Array, meta: {
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
incomplete: string[];
|
|
12
|
+
}): Promise<{
|
|
13
|
+
status: number;
|
|
14
|
+
error?: string;
|
|
15
|
+
path?: string;
|
|
16
|
+
}>;
|
|
17
|
+
/** The picture's path relative to the project, when this comment has one. */
|
|
18
|
+
export declare function localScreenshotPath(root: string, commentId: string): Promise<string | null>;
|
|
19
|
+
export declare function localScreenshotMeta(root: string, commentId: string): Promise<{
|
|
20
|
+
incomplete: string[];
|
|
21
|
+
} | null>;
|
|
22
|
+
/** With its comment: a picture of a deleted comment is a record of nothing. */
|
|
23
|
+
export declare function removeLocalScreenshot(root: string, commentId: string): Promise<void>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { mkdir, readdir, readFile, rm, writeFile } from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { screenshotExtension, sniffImage } from '../core/imageSniff.js';
|
|
4
|
+
/**
|
|
5
|
+
* Pictures of commented elements, on this machine: `.feedback/screenshots/<comment id>.<ext>`.
|
|
6
|
+
*
|
|
7
|
+
* Beside the comments rather than inside them, so the store stays small text and the picture is
|
|
8
|
+
* a file an agent can open by path - which is what the work order gives it.
|
|
9
|
+
*/
|
|
10
|
+
export const maxLocalScreenshotBytes = 500 * 1024;
|
|
11
|
+
const directory = (root) => path.join(root, '.feedback', 'screenshots');
|
|
12
|
+
const safeId = /^[\w-]{1,64}$/;
|
|
13
|
+
export async function saveLocalScreenshot(root, commentId, bytes, meta) {
|
|
14
|
+
if (!safeId.test(commentId))
|
|
15
|
+
return { status: 400, error: 'not a comment id' };
|
|
16
|
+
if (bytes.length === 0 || bytes.length > maxLocalScreenshotBytes)
|
|
17
|
+
return { status: 413, error: 'too large, or empty' };
|
|
18
|
+
const mime = sniffImage(bytes);
|
|
19
|
+
if (!mime)
|
|
20
|
+
return { status: 415, error: 'a screenshot is a WebP, PNG or JPEG image' };
|
|
21
|
+
if (await localScreenshotPath(root, commentId))
|
|
22
|
+
return { status: 409, error: 'this comment already has its picture' };
|
|
23
|
+
await mkdir(directory(root), { recursive: true });
|
|
24
|
+
const file = path.join(directory(root), `${commentId}.${screenshotExtension[mime]}`);
|
|
25
|
+
await writeFile(file, bytes, { flag: 'wx' });
|
|
26
|
+
await writeFile(path.join(directory(root), `${commentId}.json`), JSON.stringify({ mime, ...meta }), 'utf8');
|
|
27
|
+
return { status: 201, path: path.relative(root, file).split(path.sep).join('/') };
|
|
28
|
+
}
|
|
29
|
+
/** The picture's path relative to the project, when this comment has one. */
|
|
30
|
+
export async function localScreenshotPath(root, commentId) {
|
|
31
|
+
if (!safeId.test(commentId))
|
|
32
|
+
return null;
|
|
33
|
+
const names = await readdir(directory(root)).catch(() => []);
|
|
34
|
+
const name = names.find((entry) => entry.startsWith(`${commentId}.`) && !entry.endsWith('.json'));
|
|
35
|
+
return name ? `.feedback/screenshots/${name}` : null;
|
|
36
|
+
}
|
|
37
|
+
export async function localScreenshotMeta(root, commentId) {
|
|
38
|
+
if (!safeId.test(commentId))
|
|
39
|
+
return null;
|
|
40
|
+
try {
|
|
41
|
+
return JSON.parse(await readFile(path.join(directory(root), `${commentId}.json`), 'utf8'));
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/** With its comment: a picture of a deleted comment is a record of nothing. */
|
|
48
|
+
export async function removeLocalScreenshot(root, commentId) {
|
|
49
|
+
if (!safeId.test(commentId))
|
|
50
|
+
return;
|
|
51
|
+
const names = await readdir(directory(root)).catch(() => []);
|
|
52
|
+
await Promise.all(names.filter((name) => name.startsWith(`${commentId}.`))
|
|
53
|
+
.map((name) => rm(path.join(directory(root), name), { force: true })));
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=localScreenshots.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localScreenshots.js","sourceRoot":"","sources":["../../src/storage/localScreenshots.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAExE;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,GAAG,IAAI,CAAC;AAClD,MAAM,SAAS,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC;AAChF,MAAM,MAAM,GAAG,eAAe,CAAC;AAE/B,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,IAAY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KAAK,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,EAAc,CAAC,CAAC;IACzE,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,SAAS,GAAG,CAAC,CAAC;SACvE,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AAC3E,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { DirectoryEntry, SourceReader } from '../core/ports.js';
|
|
2
|
+
export declare class LocalSourceReader implements SourceReader {
|
|
3
|
+
readonly projectRoot: string;
|
|
4
|
+
readonly workspaceRoot: string;
|
|
5
|
+
/** Resolved once per root: a root may itself sit under a link, as /tmp does on macOS. */
|
|
6
|
+
private realRoots;
|
|
7
|
+
constructor(projectRoot: string);
|
|
8
|
+
readFile(relativePath: string): Promise<string | null>;
|
|
9
|
+
isFile(relativePath: string): Promise<boolean>;
|
|
10
|
+
listDirectory(relativePath: string): Promise<DirectoryEntry[]>;
|
|
11
|
+
writeArtefact(relativePath: string, contents: string): Promise<void>;
|
|
12
|
+
/** Reads beneath the workspace root. Local, export-time, never behind an HTTP route. */
|
|
13
|
+
readWorkspaceFile(relativePath: string): Promise<string | null>;
|
|
14
|
+
listWorkspaceDirectory(relativePath: string): Promise<DirectoryEntry[]>;
|
|
15
|
+
private realRootOf;
|
|
16
|
+
/**
|
|
17
|
+
* Resolves a project-relative path, or null if it leaves the project by any route.
|
|
18
|
+
*
|
|
19
|
+
* Returns the lexical path rather than the real one, so callers still see paths under
|
|
20
|
+
* the root they asked about; the real path is used for the check alone.
|
|
21
|
+
*/
|
|
22
|
+
private resolveInside;
|
|
23
|
+
/**
|
|
24
|
+
* Real path of the target, or of the closest ancestor that exists.
|
|
25
|
+
*
|
|
26
|
+
* A file being written does not exist yet, so the link check has to apply to the
|
|
27
|
+
* directory it will land in. Returns null when nothing along the path exists.
|
|
28
|
+
*/
|
|
29
|
+
private realPathOfNearestExisting;
|
|
30
|
+
private contains;
|
|
31
|
+
}
|