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,907 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { ApiError, FeedbackClient, ProjectKey, SessionSync, SessionWatcher, newId, newIdempotencyKey } from './index.js';
|
|
3
|
+
import { isCloudConfig, readJsonFile, writePrivateJson } from './config.js';
|
|
4
|
+
import { carriesContent, envelopeCodec, plaintextCodec } from './codec.js';
|
|
5
|
+
import { AccountAuth } from './account.js';
|
|
6
|
+
import { listCloudMembers } from './cloudApi.js';
|
|
7
|
+
import { pageUrl } from '../core/pageUrl.js';
|
|
8
|
+
import { sniffImage } from '../core/imageSniff.js';
|
|
9
|
+
import { MAX_ATTACHMENT_BYTES } from '../core/attachmentTypes.js';
|
|
10
|
+
import { readCapped } from '../integration/commentPull.js';
|
|
11
|
+
import { resolveLocalAnchors } from './localAnchors.js';
|
|
12
|
+
import { commentContent, localContent, replyContent } from './mapping.js';
|
|
13
|
+
import { servableSource } from '../integration/requestGuards.js';
|
|
14
|
+
import { detectBranchAsync } from '../integration/gitBranch.js';
|
|
15
|
+
import { branchLabel } from './branchLabel.js';
|
|
16
|
+
/** A Cloud entity's own files, as the API sent them (the overlay checks them again before drawing). */
|
|
17
|
+
const filesOf = (entity) => {
|
|
18
|
+
const value = entity.attachments;
|
|
19
|
+
return Array.isArray(value) ? value : [];
|
|
20
|
+
};
|
|
21
|
+
const unknownAnchor = { file: '', line: 0, column: 0, componentName: null, domPath: '', textSnippet: null };
|
|
22
|
+
/** One sidecar owns this atomic outbox + cursor + optimistic view. Local-only stores are untouched. */
|
|
23
|
+
export class RemoteCommentStore {
|
|
24
|
+
config;
|
|
25
|
+
state;
|
|
26
|
+
source;
|
|
27
|
+
codec;
|
|
28
|
+
apiKind = 'v0';
|
|
29
|
+
api;
|
|
30
|
+
sync;
|
|
31
|
+
watcher;
|
|
32
|
+
presenceCleanup;
|
|
33
|
+
serial = Promise.resolve();
|
|
34
|
+
timer;
|
|
35
|
+
signInWatch;
|
|
36
|
+
sending;
|
|
37
|
+
stopped = false;
|
|
38
|
+
started = false;
|
|
39
|
+
attempt = 0;
|
|
40
|
+
unreadable = new Set();
|
|
41
|
+
file;
|
|
42
|
+
participantNames = new Map();
|
|
43
|
+
seenAuthors = new Set();
|
|
44
|
+
identitiesRefreshedAt = 0;
|
|
45
|
+
now;
|
|
46
|
+
constructor(config, state, root, source, keys, codec, options) {
|
|
47
|
+
this.config = config;
|
|
48
|
+
this.state = state;
|
|
49
|
+
this.source = source;
|
|
50
|
+
this.codec = codec;
|
|
51
|
+
this.file = path.join(root, '.feedback', 'remote-sync.json');
|
|
52
|
+
this.api = new FeedbackClient({ baseUrl: config.apiUrl, product: 'feedback-sidecar', fetch: options.fetch,
|
|
53
|
+
retry: { maxAttempts: 1 }, timeoutMs: 5000 }).project(config.projectId, keys);
|
|
54
|
+
const readApi = new FeedbackClient({ baseUrl: config.apiUrl, product: 'feedback-sidecar', fetch: options.fetch,
|
|
55
|
+
retry: { maxAttempts: 3 }, timeoutMs: 5000 }).project(config.projectId, keys);
|
|
56
|
+
this.sync = new SessionSync({ api: readApi, sessionId: config.sessionId, revision: state.revision, entities: state });
|
|
57
|
+
const catchUp = () => { void this.catchUp().catch(() => { }); };
|
|
58
|
+
this.watcher = new SessionWatcher({ api: this.api, sessionId: config.sessionId,
|
|
59
|
+
onReady: () => { this.sync.resume(); catchUp(); }, onChanged: catchUp, onPoll: catchUp,
|
|
60
|
+
onClosed: () => { void this.lock(async () => { this.state.error = 'session_closed'; await this.save(); }); },
|
|
61
|
+
onStopped: ({ reason, error }) => {
|
|
62
|
+
if (reason !== 'stopped')
|
|
63
|
+
void this.lock(async () => {
|
|
64
|
+
// A Cloud sidecar that is signed out (or signed in as another account) says so, not just "ticket rejected".
|
|
65
|
+
this.state.error = error instanceof ApiError && ['signed_out', 'account_mismatch'].includes(error.code) ? error.code : reason;
|
|
66
|
+
await this.save();
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
this.retryDelayMs = options.retryDelayMs ?? 1000;
|
|
71
|
+
this.now = options.now ?? Date.now;
|
|
72
|
+
}
|
|
73
|
+
retryDelayMs;
|
|
74
|
+
static async open(root, config, source, options = {}) {
|
|
75
|
+
const previous = await readJsonFile(path.join(root, '.feedback', 'remote-sync.json'));
|
|
76
|
+
const cloud = isCloudConfig(config);
|
|
77
|
+
if (previous && (previous.projectId !== config.projectId || previous.sessionId !== config.sessionId || previous.apiUrl !== config.apiUrl)) {
|
|
78
|
+
throw new Error('Remote feedback state belongs to another API/project/session; preserve it before relinking');
|
|
79
|
+
}
|
|
80
|
+
// A Standalone journal holds sealed envelopes, a Cloud one plaintext written as one account.
|
|
81
|
+
if (previous && (previous.plan === 'cloud') !== cloud) {
|
|
82
|
+
throw new Error(`Remote feedback state belongs to a ${previous.plan === 'cloud' ? 'Cloud' : 'Standalone'} project, but this project is configured for ${cloud ? 'Cloud' : 'Standalone'}; preserve it before relinking`);
|
|
83
|
+
}
|
|
84
|
+
if (previous && cloud && previous.accountId !== config.accountId) {
|
|
85
|
+
throw new Error('Remote feedback state was written by another Cloud account; preserve it before relinking');
|
|
86
|
+
}
|
|
87
|
+
const state = previous ?? { version: 1, projectId: config.projectId, sessionId: config.sessionId,
|
|
88
|
+
apiUrl: config.apiUrl, revision: 0, comments: [], replies: [], tombstones: [], ids: {}, queue: [],
|
|
89
|
+
...(cloud ? { plan: 'cloud', accountId: config.accountId, authors: {} } : {}) };
|
|
90
|
+
// Upgrade old journals: prepared envelopes already carry every optimistic content field.
|
|
91
|
+
// Keep only timestamps from the old plaintext cache, then remove it even with pending work.
|
|
92
|
+
const legacy = state.local;
|
|
93
|
+
for (const op of state.queue) {
|
|
94
|
+
const localId = Object.keys(state.ids).find((id) => state.ids[id] === (op.commentId ?? op.id));
|
|
95
|
+
const comment = legacy?.find((c) => c.id === localId);
|
|
96
|
+
const entity = op.commentId ? comment?.replies.find((r) => state.ids[r.id] === op.id) : comment;
|
|
97
|
+
op.createdAt ??= entity?.createdAt;
|
|
98
|
+
op.editedAt ??= entity?.editedAt;
|
|
99
|
+
}
|
|
100
|
+
delete state.local;
|
|
101
|
+
let store;
|
|
102
|
+
if (cloud)
|
|
103
|
+
store = new RemoteCommentStore(config, state, root, source, new AccountAuth(config.apiUrl, config.accountId, options.env), plaintextCodec, options);
|
|
104
|
+
else {
|
|
105
|
+
const keys = await ProjectKey.parsePortable(config.portableKey).key.derive();
|
|
106
|
+
store = new RemoteCommentStore(config, state, root, source, keys, envelopeCodec(keys), options);
|
|
107
|
+
}
|
|
108
|
+
// Import legacy local data once. Atomic checkpoint means restarts never duplicate it.
|
|
109
|
+
if (!previous) {
|
|
110
|
+
const legacy = await readJsonFile(path.join(root, '.feedback', 'comments.json'));
|
|
111
|
+
for (const comment of legacy?.comments ?? []) {
|
|
112
|
+
await store.enqueueComment(comment);
|
|
113
|
+
for (const reply of comment.replies)
|
|
114
|
+
await store.enqueueReply(comment.id, reply);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
await store.save();
|
|
118
|
+
return store;
|
|
119
|
+
}
|
|
120
|
+
start() {
|
|
121
|
+
if (this.started)
|
|
122
|
+
return;
|
|
123
|
+
this.started = true;
|
|
124
|
+
void this.watcher.start();
|
|
125
|
+
this.schedule(0);
|
|
126
|
+
const auth = this.api.keys;
|
|
127
|
+
if (auth instanceof AccountAuth) {
|
|
128
|
+
// Signing in again (or as the right account) resumes a Cloud sidecar without a restart.
|
|
129
|
+
let stamp = auth.stamp();
|
|
130
|
+
this.signInWatch = setInterval(() => {
|
|
131
|
+
const next = auth.stamp();
|
|
132
|
+
if (next === stamp)
|
|
133
|
+
return;
|
|
134
|
+
stamp = next;
|
|
135
|
+
if (auth.record())
|
|
136
|
+
void this.retry().catch(() => { });
|
|
137
|
+
}, 2000);
|
|
138
|
+
this.signInWatch.unref();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
async close() {
|
|
142
|
+
this.presenceCleanup?.();
|
|
143
|
+
clearInterval(this.signInWatch);
|
|
144
|
+
this.stopped = true;
|
|
145
|
+
clearTimeout(this.timer);
|
|
146
|
+
await this.watcher.stop();
|
|
147
|
+
await this.sending;
|
|
148
|
+
await this.serial;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Cloud: the element screenshot the overlay sent for a comment written here. It
|
|
152
|
+
* goes to the API once the comment itself is acknowledged, because the API takes it only from the
|
|
153
|
+
* comment's author, once, within minutes of posting. Best effort: the local copy is what the MCP
|
|
154
|
+
* and the work order use, and a refusal changes nothing else. Returns whether it was stored.
|
|
155
|
+
*/
|
|
156
|
+
async uploadScreenshot(localId, image, options = {}) {
|
|
157
|
+
if (!isCloudConfig(this.config) || !(image.width >= 1 && image.width <= 10000 && image.height >= 1 && image.height <= 10000))
|
|
158
|
+
return false;
|
|
159
|
+
const remoteId = /^cmt_[0-7][0-9a-hjkmnp-tv-z]{25}$/.test(localId) ? localId : this.state.ids[localId];
|
|
160
|
+
if (!remoteId)
|
|
161
|
+
return false;
|
|
162
|
+
const deadline = this.now() + (options.waitMs ?? 60_000);
|
|
163
|
+
for (;;) {
|
|
164
|
+
if (this.stopped)
|
|
165
|
+
return false;
|
|
166
|
+
const queued = this.state.queue.some((op) => op.id === remoteId && op.method === 'POST');
|
|
167
|
+
if (!queued && this.sync.snapshot().comments.some((comment) => comment.id === remoteId))
|
|
168
|
+
break;
|
|
169
|
+
if (this.now() >= deadline)
|
|
170
|
+
return false;
|
|
171
|
+
await new Promise((resolve) => setTimeout(resolve, options.pollMs ?? 500));
|
|
172
|
+
}
|
|
173
|
+
const query = new URLSearchParams({ width: String(Math.round(image.width)), height: String(Math.round(image.height)) });
|
|
174
|
+
for (const note of image.incomplete.slice(0, 5))
|
|
175
|
+
if (note)
|
|
176
|
+
query.append('incomplete', note.slice(0, 120));
|
|
177
|
+
const path = `/v0/projects/${encodeURIComponent(this.config.projectId)}/sessions/${encodeURIComponent(this.config.sessionId)}/comments/${encodeURIComponent(remoteId)}/screenshot?${query}`;
|
|
178
|
+
try {
|
|
179
|
+
const response = await this.api.client.fetch(`${this.api.client.baseUrl}${path}`, {
|
|
180
|
+
method: 'PUT', body: new Blob([new Uint8Array(image.bytes)], { type: image.mime }), redirect: 'error', signal: AbortSignal.timeout(15_000),
|
|
181
|
+
headers: { authorization: this.api.keys.authorizationHeader(), 'content-type': image.mime, 'feedback-client': this.api.client.userAgent },
|
|
182
|
+
});
|
|
183
|
+
await response.body?.cancel();
|
|
184
|
+
return response.ok;
|
|
185
|
+
}
|
|
186
|
+
catch {
|
|
187
|
+
return false;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
/** Files go to a Cloud session only: Standalone content is end-to-end encrypted, and there is no encrypted file endpoint. */
|
|
191
|
+
get attachmentsAvailable() { return isCloudConfig(this.config); }
|
|
192
|
+
sessionUrl(rest) {
|
|
193
|
+
return `${this.api.client.baseUrl}/v0/projects/${encodeURIComponent(this.config.projectId)}/sessions/${encodeURIComponent(this.config.sessionId)}${rest}`;
|
|
194
|
+
}
|
|
195
|
+
fileHeaders() { return { authorization: this.api.keys.authorizationHeader(), 'feedback-client': this.api.client.userAgent }; }
|
|
196
|
+
/**
|
|
197
|
+
* A file for a message being written, straight to Cloud (contract section 18): the message's queued
|
|
198
|
+
* create claims it by id. The API's answer is passed on as it is, refusals included.
|
|
199
|
+
*/
|
|
200
|
+
async uploadAttachment(name, bytes) {
|
|
201
|
+
if (!this.attachmentsAvailable)
|
|
202
|
+
return { status: 403, body: { error: 'Files cannot be attached to an end-to-end encrypted review', reason: 'attachments_unavailable' } };
|
|
203
|
+
try {
|
|
204
|
+
const response = await this.api.client.fetch(this.sessionUrl(`/uploads?name=${encodeURIComponent(name)}`), {
|
|
205
|
+
method: 'POST', body: new Blob([new Uint8Array(bytes)]), redirect: 'error', signal: AbortSignal.timeout(60_000),
|
|
206
|
+
headers: { ...this.fileHeaders(), 'content-type': 'application/octet-stream' },
|
|
207
|
+
});
|
|
208
|
+
return { status: response.status, body: await response.json().catch(() => null) };
|
|
209
|
+
}
|
|
210
|
+
catch {
|
|
211
|
+
return { status: 502, body: { error: 'Cloud did not take the file', reason: 'attachment_upload_failed' } };
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
/** A pending file taken out of the composer. */
|
|
215
|
+
async removeUpload(id) {
|
|
216
|
+
if (!this.attachmentsAvailable || !/^att_[0-7][0-9a-hjkmnp-tv-z]{25}$/.test(id))
|
|
217
|
+
return false;
|
|
218
|
+
try {
|
|
219
|
+
const response = await this.api.client.fetch(this.sessionUrl(`/uploads/${encodeURIComponent(id)}`), {
|
|
220
|
+
method: 'DELETE', redirect: 'error', signal: AbortSignal.timeout(15_000), headers: this.fileHeaders()
|
|
221
|
+
});
|
|
222
|
+
await response.body?.cancel();
|
|
223
|
+
return response.status === 204;
|
|
224
|
+
}
|
|
225
|
+
catch {
|
|
226
|
+
return false;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
/** A sent file of a comment shown here (its replies' included), from Cloud. Null when that comment does not carry it. */
|
|
230
|
+
async attachmentBytes(localCommentId, attachmentId) {
|
|
231
|
+
if (!this.attachmentsAvailable)
|
|
232
|
+
return null;
|
|
233
|
+
const comment = (await this.list()).find((entry) => entry.id === localCommentId);
|
|
234
|
+
const attachment = [...(comment?.attachments ?? []), ...(comment?.replies.flatMap((reply) => reply.attachments ?? []) ?? [])]
|
|
235
|
+
.find((file) => file.id === attachmentId);
|
|
236
|
+
if (!attachment)
|
|
237
|
+
return null;
|
|
238
|
+
try {
|
|
239
|
+
const response = await this.api.client.fetch(this.sessionUrl(`/attachments/${encodeURIComponent(attachmentId)}`), {
|
|
240
|
+
redirect: 'error', signal: AbortSignal.timeout(60_000), headers: this.fileHeaders()
|
|
241
|
+
});
|
|
242
|
+
if (!response.ok) {
|
|
243
|
+
await response.body?.cancel();
|
|
244
|
+
return null;
|
|
245
|
+
}
|
|
246
|
+
const bytes = await readCapped(response, MAX_ATTACHMENT_BYTES);
|
|
247
|
+
return bytes ? { bytes, attachment } : null;
|
|
248
|
+
}
|
|
249
|
+
catch {
|
|
250
|
+
return null;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Cloud: a comment's element screenshot, for the agent (the session's screenshot route, contract
|
|
255
|
+
* section 18). Null when it has none, or Cloud does not answer: the task is still worked on.
|
|
256
|
+
*/
|
|
257
|
+
async screenshotBytes(localCommentId) {
|
|
258
|
+
if (!this.attachmentsAvailable)
|
|
259
|
+
return null;
|
|
260
|
+
const remoteId = /^cmt_[0-7][0-9a-hjkmnp-tv-z]{25}$/.test(localCommentId) ? localCommentId : this.state.ids[localCommentId];
|
|
261
|
+
if (!remoteId)
|
|
262
|
+
return null;
|
|
263
|
+
try {
|
|
264
|
+
const response = await this.api.client.fetch(this.sessionUrl(`/comments/${encodeURIComponent(remoteId)}/screenshot`), {
|
|
265
|
+
redirect: 'error', signal: AbortSignal.timeout(30_000), headers: this.fileHeaders()
|
|
266
|
+
});
|
|
267
|
+
if (!response.ok) {
|
|
268
|
+
await response.body?.cancel();
|
|
269
|
+
return null;
|
|
270
|
+
}
|
|
271
|
+
// Never more than the largest file Cloud takes: a deployment's screenshot limit is below it.
|
|
272
|
+
const bytes = await readCapped(response, MAX_ATTACHMENT_BYTES);
|
|
273
|
+
const mime = bytes ? sniffImage(bytes) : null;
|
|
274
|
+
return bytes && mime ? { bytes, mime } : null;
|
|
275
|
+
}
|
|
276
|
+
catch {
|
|
277
|
+
return null;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
status() {
|
|
281
|
+
const blocked = this.queueEntries().find((op) => op.reason);
|
|
282
|
+
return { pending: this.state.queue.length, revision: this.sync.localRevision, connected: this.watcher.connected,
|
|
283
|
+
error: blocked?.reason ?? this.state.error ?? null, blocked: blocked ?? null };
|
|
284
|
+
}
|
|
285
|
+
lock(operation) {
|
|
286
|
+
const next = this.serial.then(operation, operation);
|
|
287
|
+
this.serial = next.catch(() => { });
|
|
288
|
+
return next;
|
|
289
|
+
}
|
|
290
|
+
async save() {
|
|
291
|
+
Object.assign(this.state, this.sync.snapshot(), { tombstones: this.sync.tombstones(), revision: this.sync.localRevision });
|
|
292
|
+
this.state.queue = this.state.queue.filter((op) => op.method !== 'DELETE' || !this.state.tombstones.some((t) => t.id === op.id || t.id === op.commentId));
|
|
293
|
+
for (const op of this.state.queue)
|
|
294
|
+
if (this.state.tombstones.some((t) => t.id === op.id || t.id === op.commentId)) {
|
|
295
|
+
op.blocked = 'deleted_remote_entity';
|
|
296
|
+
op.blockedBy = 'operation';
|
|
297
|
+
delete op.retryNotBefore;
|
|
298
|
+
}
|
|
299
|
+
await writePrivateJson(this.file, this.state);
|
|
300
|
+
}
|
|
301
|
+
id(local, prefix) {
|
|
302
|
+
if (new RegExp(`^${prefix}_[0-7][0-9a-hjkmnp-tv-z]{25}$`).test(local))
|
|
303
|
+
return local;
|
|
304
|
+
return this.state.ids[local] ??= newId(prefix);
|
|
305
|
+
}
|
|
306
|
+
localId(remote) { return Object.keys(this.state.ids).find((id) => this.state.ids[id] === remote) ?? remote; }
|
|
307
|
+
/** Cloud writes are the account's own (the server enforces it); Standalone maps each local participant to a `ptc_` ID. */
|
|
308
|
+
actor(id) { return isCloudConfig(this.config) ? this.config.accountId : this.id(id || 'local-participant', 'ptc'); }
|
|
309
|
+
/** The local participant shown as an entity's author: on Cloud, whoever wrote it here. */
|
|
310
|
+
localAuthor(entityId, authorId) { return this.state.authors?.[entityId] ?? this.localId(authorId); }
|
|
311
|
+
where(id, commentId) {
|
|
312
|
+
return { projectId: this.config.projectId, sessionId: this.config.sessionId, commentId: commentId ?? id, ...(commentId ? { replyId: id } : {}) };
|
|
313
|
+
}
|
|
314
|
+
blockedReason(op, memo = new Map()) {
|
|
315
|
+
if (op.blocked)
|
|
316
|
+
return op.blocked;
|
|
317
|
+
if (memo.has(op.idempotencyKey))
|
|
318
|
+
return memo.get(op.idempotencyKey);
|
|
319
|
+
const at = this.state.queue.indexOf(op);
|
|
320
|
+
const predecessors = this.state.queue.slice(0, at).filter((prior) => prior.id === op.id || prior.id === op.commentId || prior.commentId === op.id || prior.idempotencyKey === op.dependsOn);
|
|
321
|
+
const reason = predecessors.some((prior) => this.blockedReason(prior, memo)) ? 'blocked_dependency' : null;
|
|
322
|
+
memo.set(op.idempotencyKey, reason);
|
|
323
|
+
return reason;
|
|
324
|
+
}
|
|
325
|
+
queueEntries() {
|
|
326
|
+
const memo = new Map();
|
|
327
|
+
return this.state.queue.map((op) => ({ id: op.idempotencyKey, entityId: op.id, method: op.method, reason: this.blockedReason(op, memo) }));
|
|
328
|
+
}
|
|
329
|
+
discard(queuedId) {
|
|
330
|
+
return this.mutate(async () => {
|
|
331
|
+
const op = this.state.queue.find((op) => op.idempotencyKey === queuedId);
|
|
332
|
+
if (!op)
|
|
333
|
+
throw new Error('Queue operation not found');
|
|
334
|
+
if (!this.blockedReason(op))
|
|
335
|
+
throw new Error('Only blocked operations can be discarded; an in-flight write may already be committed');
|
|
336
|
+
const discarded = new Set([queuedId]);
|
|
337
|
+
for (const queued of this.state.queue) {
|
|
338
|
+
if ((queued.dependsOn && discarded.has(queued.dependsOn)) || (op.method === 'POST' && queued.commentId === op.id))
|
|
339
|
+
discarded.add(queued.idempotencyKey);
|
|
340
|
+
}
|
|
341
|
+
this.state.queue = this.state.queue.filter((queued) => !discarded.has(queued.idempotencyKey));
|
|
342
|
+
delete this.state.error;
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
async rebase(queuedId) {
|
|
346
|
+
await this.catchUp();
|
|
347
|
+
return this.mutate(async () => {
|
|
348
|
+
const op = this.state.queue.find((op) => op.idempotencyKey === queuedId);
|
|
349
|
+
if (!op)
|
|
350
|
+
throw new Error('Queue operation not found');
|
|
351
|
+
if (!op.blocked || (op.dependsOn && this.state.queue.some((prior) => prior.idempotencyKey === op.dependsOn)))
|
|
352
|
+
throw new Error('Rebase a blocked head before its dependent operations');
|
|
353
|
+
if (op.method === 'POST')
|
|
354
|
+
throw new Error('A rejected create must be discarded and recreated');
|
|
355
|
+
const entity = (op.commentId ? this.sync.snapshot().replies : this.sync.snapshot().comments).find((e) => e.id === op.id);
|
|
356
|
+
if (!entity)
|
|
357
|
+
throw new Error('Remote entity was deleted; discard this operation');
|
|
358
|
+
if (carriesContent(op.body)) {
|
|
359
|
+
const intent = await this.pendingContent(op);
|
|
360
|
+
const latest = await this.codec.open(entity);
|
|
361
|
+
Object.assign(op.body, await this.codec.seal(this.where(op.id, op.commentId), this.shareable({ ...latest, body: intent.body })));
|
|
362
|
+
}
|
|
363
|
+
const previous = op.idempotencyKey;
|
|
364
|
+
op.idempotencyKey = newIdempotencyKey();
|
|
365
|
+
op.body.baseRevision = entity.revision;
|
|
366
|
+
op.ready = true;
|
|
367
|
+
delete op.blocked;
|
|
368
|
+
delete op.blockedBy;
|
|
369
|
+
delete op.retryNotBefore;
|
|
370
|
+
delete op.dependsOn;
|
|
371
|
+
for (const queued of this.state.queue)
|
|
372
|
+
if (queued.dependsOn === previous)
|
|
373
|
+
queued.dependsOn = op.idempotencyKey;
|
|
374
|
+
delete this.state.error;
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
pendingContent(op) {
|
|
378
|
+
return this.codec.openBody(this.where(op.id, op.commentId), op.body);
|
|
379
|
+
}
|
|
380
|
+
resource(id, commentId) {
|
|
381
|
+
const base = `/v0/projects/${this.config.projectId}/sessions/${this.config.sessionId}/comments`;
|
|
382
|
+
return commentId ? `${base}/${commentId}/replies/${id}` : `${base}/${id}`;
|
|
383
|
+
}
|
|
384
|
+
list() { return this.lock(() => this.view()); }
|
|
385
|
+
/** The server's display name for a participant, when the participant list has confirmed one. */
|
|
386
|
+
participantName(id) { return this.participantNames.get(id); }
|
|
387
|
+
/**
|
|
388
|
+
* Who wrote an entity, as shown. A sealed `authorName` is whatever its author chose; the server's
|
|
389
|
+
* participant list (or this sidecar having written it) is what confirms a name. Anything else is
|
|
390
|
+
* shown with the sealed name, marked unverified.
|
|
391
|
+
*/
|
|
392
|
+
authorOf(authorId, sealed) {
|
|
393
|
+
// On Cloud this account writes for every local participant; their own names are what they chose here.
|
|
394
|
+
if (isCloudConfig(this.config) && authorId === this.config.accountId)
|
|
395
|
+
return { author: sealed };
|
|
396
|
+
const confirmed = this.participantNames.get(authorId);
|
|
397
|
+
if (confirmed !== undefined)
|
|
398
|
+
return { author: confirmed };
|
|
399
|
+
return Object.values(this.state.ids).includes(authorId) ? { author: sealed } : { author: sealed, authorUnverified: true };
|
|
400
|
+
}
|
|
401
|
+
async view() {
|
|
402
|
+
const { comments, replies } = this.sync.snapshot();
|
|
403
|
+
const result = [];
|
|
404
|
+
const sealed = this.codec.plan === 'cloud' ? '' : ' encrypted';
|
|
405
|
+
for (const entity of comments) {
|
|
406
|
+
let content;
|
|
407
|
+
try {
|
|
408
|
+
content = localContent(await this.codec.open(entity));
|
|
409
|
+
this.unreadable.delete(entity.id);
|
|
410
|
+
}
|
|
411
|
+
catch {
|
|
412
|
+
this.unreadable.add(entity.id);
|
|
413
|
+
content = { body: `Unreadable${sealed} comment`, author: 'Unknown', anchor: unknownAnchor, context: { route: '/', viewport: { w: 0, h: 0 } } };
|
|
414
|
+
}
|
|
415
|
+
const children = [];
|
|
416
|
+
for (const reply of replies.filter((r) => r.commentId === entity.id)) {
|
|
417
|
+
let fields;
|
|
418
|
+
try {
|
|
419
|
+
fields = localContent(await this.codec.open(reply));
|
|
420
|
+
this.unreadable.delete(reply.id);
|
|
421
|
+
}
|
|
422
|
+
catch {
|
|
423
|
+
this.unreadable.add(reply.id);
|
|
424
|
+
fields = { body: `Unreadable${sealed} reply`, author: 'Unknown', anchor: unknownAnchor };
|
|
425
|
+
}
|
|
426
|
+
children.push({ ...fields, ...this.authorOf(reply.authorId, fields.author), id: this.localId(reply.id), createdAt: reply.createdAt, editedAt: reply.editedAt, authorId: this.localAuthor(reply.id, reply.authorId), anchor: fields.anchor ?? unknownAnchor, attachments: filesOf(reply) });
|
|
427
|
+
}
|
|
428
|
+
result.push({ ...content, ...this.authorOf(entity.authorId, content.author), id: this.localId(entity.id), createdAt: entity.createdAt, editedAt: entity.editedAt,
|
|
429
|
+
authorId: this.localAuthor(entity.id, entity.authorId), status: entity.status, replies: children, attachments: filesOf(entity),
|
|
430
|
+
// Cloud: the server's branch label; content never carries one.
|
|
431
|
+
...(typeof entity.branch === 'string' ? { branch: entity.branch } : {}) });
|
|
432
|
+
}
|
|
433
|
+
// Apply optimistic operations by field, so a pending reply cannot hide a remote status/edit.
|
|
434
|
+
// Tombstones dominate even unsent work, which remains in the queue for explicit reconciliation.
|
|
435
|
+
const blocked = new Map();
|
|
436
|
+
for (const op of this.state.queue) {
|
|
437
|
+
if (this.blockedReason(op, blocked))
|
|
438
|
+
continue;
|
|
439
|
+
if (this.sync.tombstones().some((t) => t.id === op.id || t.id === op.commentId))
|
|
440
|
+
continue;
|
|
441
|
+
const id = this.localId(op.id), parentId = this.localId(op.commentId ?? op.id);
|
|
442
|
+
const at = result.findIndex((c) => c.id === parentId);
|
|
443
|
+
if (op.method === 'DELETE') {
|
|
444
|
+
if (at >= 0) {
|
|
445
|
+
if (op.commentId)
|
|
446
|
+
result[at].replies = result[at].replies.filter((r) => r.id !== id);
|
|
447
|
+
else
|
|
448
|
+
result.splice(at, 1);
|
|
449
|
+
}
|
|
450
|
+
continue;
|
|
451
|
+
}
|
|
452
|
+
if (op.method === 'POST' && !op.commentId) {
|
|
453
|
+
if (at < 0)
|
|
454
|
+
result.push({ ...localContent(await this.pendingContent(op)), id,
|
|
455
|
+
createdAt: op.createdAt ?? '', authorId: this.localAuthor(op.id, op.body.authorId), status: op.body.status, replies: [],
|
|
456
|
+
...(typeof op.body.branch === 'string' ? { branch: op.body.branch } : {}) });
|
|
457
|
+
continue;
|
|
458
|
+
}
|
|
459
|
+
if (at < 0)
|
|
460
|
+
continue;
|
|
461
|
+
const comment = result[at];
|
|
462
|
+
if (op.commentId) {
|
|
463
|
+
const index = comment.replies.findIndex((r) => r.id === id);
|
|
464
|
+
if (op.method === 'POST' && index < 0)
|
|
465
|
+
comment.replies.push({ ...localContent(await this.pendingContent(op)), id,
|
|
466
|
+
createdAt: op.createdAt ?? '', authorId: this.localAuthor(op.id, op.body.authorId) });
|
|
467
|
+
if (op.method === 'PATCH' && index >= 0 && carriesContent(op.body)) {
|
|
468
|
+
Object.assign(comment.replies[index], localContent(await this.pendingContent(op)), { editedAt: op.editedAt });
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
else {
|
|
472
|
+
if (carriesContent(op.body)) {
|
|
473
|
+
Object.assign(comment, localContent(await this.pendingContent(op)), { editedAt: op.editedAt });
|
|
474
|
+
}
|
|
475
|
+
if (op.body.status)
|
|
476
|
+
comment.status = op.body.status;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
return Promise.all(result.map((comment) => resolveLocalAnchors(comment, this.source)));
|
|
480
|
+
}
|
|
481
|
+
/** Whether shared content may carry source lines: always on Standalone (sealed), opt-out on Cloud. */
|
|
482
|
+
get sourceExcerpts() { return !(isCloudConfig(this.config) && this.config.sourceExcerpts === false); }
|
|
483
|
+
/**
|
|
484
|
+
* Content as it may leave this machine. This is the last hop, so it does not trust the overlay:
|
|
485
|
+
* no source excerpt when they are turned off, and `context.url` normalised again (on Cloud,
|
|
486
|
+
* where the server reads it, without the query).
|
|
487
|
+
*/
|
|
488
|
+
shareable(content) {
|
|
489
|
+
let out = content;
|
|
490
|
+
if (!this.sourceExcerpts && 'source' in out) {
|
|
491
|
+
const { source: _source, ...rest } = out;
|
|
492
|
+
out = rest;
|
|
493
|
+
}
|
|
494
|
+
if (out.context && typeof out.context === 'object' && 'url' in out.context) {
|
|
495
|
+
out = { ...out, context: { ...out.context, url: pageUrl(out.context.url, { query: !isCloudConfig(this.config) }) } };
|
|
496
|
+
}
|
|
497
|
+
return out;
|
|
498
|
+
}
|
|
499
|
+
async withSource(comment) {
|
|
500
|
+
if (!this.sourceExcerpts)
|
|
501
|
+
return comment;
|
|
502
|
+
const { file, line } = comment.anchor;
|
|
503
|
+
// The excerpt is sealed and shared with every participant: only a file `/__fb/source` could
|
|
504
|
+
// serve, by name and by real path (an in-root link to .env is refused), whatever the anchor claims.
|
|
505
|
+
if (line < 1 || 'source' in comment || !(await servableSource(this.source.projectRoot, file)))
|
|
506
|
+
return comment;
|
|
507
|
+
const text = await this.source.readFile(file);
|
|
508
|
+
if (text === null)
|
|
509
|
+
return comment;
|
|
510
|
+
const lines = text.split(/\r?\n/), startLine = Math.max(1, line - 5), endLine = Math.min(lines.length, line + 5);
|
|
511
|
+
if (endLine < startLine)
|
|
512
|
+
return comment;
|
|
513
|
+
return { ...comment, source: { file, startLine, endLine, excerpt: [...lines.slice(startLine - 1, endLine).join('\n')].length <= 20000 ? lines.slice(startLine - 1, endLine).join('\n') : null } };
|
|
514
|
+
}
|
|
515
|
+
async enqueueComment(comment, attachmentIds = []) {
|
|
516
|
+
const local = this.shareable(await this.withSource(comment));
|
|
517
|
+
const id = this.id(local.id, 'cmt');
|
|
518
|
+
const sealed = await this.codec.seal(this.where(id), commentContent(local));
|
|
519
|
+
this.noteAuthor(id, local.authorId);
|
|
520
|
+
// Cloud: the comment is labelled with the Git branch checked out now, read
|
|
521
|
+
// afresh for every comment so a branch switched while the dev server runs is the one recorded;
|
|
522
|
+
// `default` without Git or on a detached HEAD. Standalone content stays sealed, with no label.
|
|
523
|
+
const branch = isCloudConfig(this.config) ? { branch: branchLabel(await detectBranchAsync(this.source.projectRoot)) } : {};
|
|
524
|
+
this.state.queue.push({ id, method: 'POST', path: this.resource(id).replace(`/${id}`, ''), ready: true,
|
|
525
|
+
createdAt: local.createdAt,
|
|
526
|
+
idempotencyKey: newIdempotencyKey(), body: { id, authorId: this.actor(local.authorId), status: local.status, ...sealed, ...branch, ...(attachmentIds.length ? { attachmentIds } : {}) } });
|
|
527
|
+
return local;
|
|
528
|
+
}
|
|
529
|
+
noteAuthor(id, localAuthor) {
|
|
530
|
+
if (this.state.plan === 'cloud')
|
|
531
|
+
(this.state.authors ??= {})[id] = localAuthor || 'local-participant';
|
|
532
|
+
}
|
|
533
|
+
async enqueueReply(commentId, reply, attachmentIds = []) {
|
|
534
|
+
const id = this.id(reply.id, 'rpl'), parent = this.id(commentId, 'cmt');
|
|
535
|
+
const sealed = await this.codec.seal(this.where(id, parent), replyContent(reply));
|
|
536
|
+
this.noteAuthor(id, reply.authorId);
|
|
537
|
+
this.state.queue.push({ id, commentId: parent, method: 'POST', path: this.resource(id, parent).replace(`/${id}`, ''), ready: true,
|
|
538
|
+
createdAt: reply.createdAt,
|
|
539
|
+
dependsOn: this.state.queue.find((op) => op.id === parent && op.method === 'POST')?.idempotencyKey,
|
|
540
|
+
idempotencyKey: newIdempotencyKey(), body: { id, authorId: this.actor(reply.authorId), ...sealed, ...(attachmentIds.length ? { attachmentIds } : {}) } });
|
|
541
|
+
}
|
|
542
|
+
enqueueMutation(operation) {
|
|
543
|
+
const entity = (operation.commentId ? this.sync.snapshot().replies : this.sync.snapshot().comments).find((e) => e.id === operation.id);
|
|
544
|
+
const previous = [...this.state.queue].reverse().find((op) => op.id === operation.id);
|
|
545
|
+
if (previous)
|
|
546
|
+
operation.dependsOn = previous.idempotencyKey;
|
|
547
|
+
else if (entity) {
|
|
548
|
+
operation.body.baseRevision = entity.revision;
|
|
549
|
+
operation.ready = true;
|
|
550
|
+
}
|
|
551
|
+
this.state.queue.push(operation);
|
|
552
|
+
}
|
|
553
|
+
acknowledgeDependency(operation, revision) {
|
|
554
|
+
for (const queued of this.state.queue)
|
|
555
|
+
if (queued.dependsOn === operation.idempotencyKey) {
|
|
556
|
+
if (queued.method !== 'POST')
|
|
557
|
+
queued.body.baseRevision = revision;
|
|
558
|
+
queued.ready = true;
|
|
559
|
+
delete queued.dependsOn;
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
mutate(operation) {
|
|
563
|
+
return this.lock(async () => {
|
|
564
|
+
// Roll back in memory if validation/persistence fails, so a failed save never appears successful later.
|
|
565
|
+
const before = structuredClone(this.state);
|
|
566
|
+
try {
|
|
567
|
+
const result = await operation();
|
|
568
|
+
await this.save();
|
|
569
|
+
this.schedule(0);
|
|
570
|
+
return result;
|
|
571
|
+
}
|
|
572
|
+
catch (error) {
|
|
573
|
+
this.state = before;
|
|
574
|
+
throw error;
|
|
575
|
+
}
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
create(input, options = {}) {
|
|
579
|
+
return this.mutate(() => this.enqueueComment({ ...input, id: `fb_${crypto.randomUUID().replaceAll('-', '').slice(0, 12)}`,
|
|
580
|
+
createdAt: new Date().toISOString(), status: 'open', replies: [] }, options.attachmentIds));
|
|
581
|
+
}
|
|
582
|
+
async editable(id) {
|
|
583
|
+
const comment = (await this.view()).find((c) => c.id === id);
|
|
584
|
+
if (comment && this.unreadable.has(this.id(id, 'cmt')))
|
|
585
|
+
throw new Error('Cannot edit unreadable content');
|
|
586
|
+
return comment;
|
|
587
|
+
}
|
|
588
|
+
update(id, patch, actorId) {
|
|
589
|
+
return this.mutate(async () => {
|
|
590
|
+
const comment = await this.editable(id);
|
|
591
|
+
if (!comment)
|
|
592
|
+
return null;
|
|
593
|
+
const remoteId = this.id(id, 'cmt');
|
|
594
|
+
const changed = { ...comment,
|
|
595
|
+
...(typeof patch.body === 'string' ? { body: patch.body, editedAt: new Date().toISOString() } : {}),
|
|
596
|
+
...(patch.status === 'open' || patch.status === 'resolved' ? { status: patch.status } : {}),
|
|
597
|
+
};
|
|
598
|
+
const body = { actorId: this.actor(actorId) };
|
|
599
|
+
if (patch.status === 'open' || patch.status === 'resolved')
|
|
600
|
+
body.status = patch.status;
|
|
601
|
+
if (typeof patch.body === 'string')
|
|
602
|
+
Object.assign(body, await this.codec.seal(this.where(remoteId), commentContent(this.shareable(changed))));
|
|
603
|
+
if (!('status' in body) && !carriesContent(body))
|
|
604
|
+
return comment;
|
|
605
|
+
this.enqueueMutation({ id: remoteId, method: 'PATCH', path: this.resource(remoteId), body, ready: false, editedAt: changed.editedAt, idempotencyKey: newIdempotencyKey() });
|
|
606
|
+
return changed;
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
remove(id, actorId) {
|
|
610
|
+
return this.mutate(async () => {
|
|
611
|
+
const comment = await this.editable(id);
|
|
612
|
+
if (!comment)
|
|
613
|
+
return false;
|
|
614
|
+
const remoteId = this.id(id, 'cmt');
|
|
615
|
+
this.enqueueMutation({ id: remoteId, method: 'DELETE', path: this.resource(remoteId),
|
|
616
|
+
body: { actorId: this.actor(actorId) }, ready: false, idempotencyKey: newIdempotencyKey() });
|
|
617
|
+
return true;
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
addReply(commentId, input, options = {}) {
|
|
621
|
+
return this.mutate(async () => {
|
|
622
|
+
const comment = await this.editable(commentId);
|
|
623
|
+
if (!comment)
|
|
624
|
+
return null;
|
|
625
|
+
const reply = { ...input, id: `fbr_${crypto.randomUUID().replaceAll('-', '').slice(0, 12)}`, createdAt: new Date().toISOString() };
|
|
626
|
+
await this.enqueueReply(commentId, reply, options.attachmentIds);
|
|
627
|
+
return reply;
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
updateReply(commentId, replyId, patch, actorId) {
|
|
631
|
+
return this.mutate(async () => {
|
|
632
|
+
const comment = await this.editable(commentId), reply = comment?.replies.find((r) => r.id === replyId);
|
|
633
|
+
if (!comment || !reply)
|
|
634
|
+
return null;
|
|
635
|
+
const id = this.id(replyId, 'rpl'), parent = this.id(commentId, 'cmt');
|
|
636
|
+
if (this.unreadable.has(id))
|
|
637
|
+
throw new Error('Cannot edit unreadable content');
|
|
638
|
+
const changed = { ...reply, ...patch, editedAt: new Date().toISOString() };
|
|
639
|
+
const sealed = await this.codec.seal(this.where(id, parent), replyContent(changed));
|
|
640
|
+
this.enqueueMutation({ id, commentId: parent, method: 'PATCH', path: this.resource(id, parent),
|
|
641
|
+
body: { actorId: this.actor(actorId), ...sealed }, ready: false, editedAt: changed.editedAt, idempotencyKey: newIdempotencyKey() });
|
|
642
|
+
return changed;
|
|
643
|
+
});
|
|
644
|
+
}
|
|
645
|
+
removeReply(commentId, replyId, actorId) {
|
|
646
|
+
return this.mutate(async () => {
|
|
647
|
+
const comment = await this.editable(commentId), reply = comment?.replies.find((r) => r.id === replyId);
|
|
648
|
+
if (!reply)
|
|
649
|
+
return false;
|
|
650
|
+
const id = this.id(replyId, 'rpl'), parent = this.id(commentId, 'cmt');
|
|
651
|
+
this.enqueueMutation({ id, commentId: parent, method: 'DELETE', path: this.resource(id, parent),
|
|
652
|
+
body: { actorId: this.actor(actorId) }, ready: false, idempotencyKey: newIdempotencyKey() });
|
|
653
|
+
return true;
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
async retry(id) {
|
|
657
|
+
await this.lock(async () => {
|
|
658
|
+
const selected = id ? this.state.queue.filter((op) => op.idempotencyKey === id) : this.state.queue;
|
|
659
|
+
if (id && !selected.length)
|
|
660
|
+
throw new Error('Queue operation not found');
|
|
661
|
+
for (const op of selected) {
|
|
662
|
+
delete op.blocked;
|
|
663
|
+
delete op.blockedBy;
|
|
664
|
+
delete op.retryNotBefore;
|
|
665
|
+
}
|
|
666
|
+
delete this.state.error;
|
|
667
|
+
await this.save();
|
|
668
|
+
});
|
|
669
|
+
this.sync.resume();
|
|
670
|
+
if (this.started && !this.stopped)
|
|
671
|
+
await this.watcher.restart();
|
|
672
|
+
this.schedule(0);
|
|
673
|
+
}
|
|
674
|
+
async catchUp() {
|
|
675
|
+
return this.lock(async () => {
|
|
676
|
+
try {
|
|
677
|
+
await this.sync.catchUp();
|
|
678
|
+
if (this.sync.state === 'active') {
|
|
679
|
+
for (const op of this.state.queue)
|
|
680
|
+
if (op.blockedBy === 'session' && this.now() >= (op.retryNotBefore ?? 0)) {
|
|
681
|
+
delete op.blocked;
|
|
682
|
+
delete op.blockedBy;
|
|
683
|
+
delete op.retryNotBefore;
|
|
684
|
+
}
|
|
685
|
+
await this.refreshIdentities();
|
|
686
|
+
delete this.state.error;
|
|
687
|
+
this.schedule(0);
|
|
688
|
+
}
|
|
689
|
+
await this.save();
|
|
690
|
+
}
|
|
691
|
+
catch (error) {
|
|
692
|
+
this.state.error = error instanceof ApiError ? error.code : 'offline';
|
|
693
|
+
if (error instanceof ApiError && ['unauthorized', 'forbidden', 'session_expired', 'unavailable'].includes(error.code)) {
|
|
694
|
+
for (const op of this.state.queue)
|
|
695
|
+
if (!op.blocked)
|
|
696
|
+
this.blockSession(op, error.code);
|
|
697
|
+
}
|
|
698
|
+
await this.save();
|
|
699
|
+
throw error;
|
|
700
|
+
}
|
|
701
|
+
});
|
|
702
|
+
}
|
|
703
|
+
blockSession(op, code) {
|
|
704
|
+
op.blocked = code;
|
|
705
|
+
op.blockedBy = 'session';
|
|
706
|
+
op.retryNotBefore = this.now() + 5000;
|
|
707
|
+
}
|
|
708
|
+
async refreshIdentities() {
|
|
709
|
+
const { comments, replies } = this.sync.snapshot();
|
|
710
|
+
const authors = new Set([...comments, ...replies].map((entity) => entity.authorId));
|
|
711
|
+
if (this.now() - this.identitiesRefreshedAt < 30000 && [...authors].every((id) => this.seenAuthors.has(id)))
|
|
712
|
+
return;
|
|
713
|
+
this.identitiesRefreshedAt = this.now();
|
|
714
|
+
this.seenAuthors = authors;
|
|
715
|
+
try {
|
|
716
|
+
for (const participant of await this.api.listParticipants(this.config.sessionId)) {
|
|
717
|
+
if (participant.acceptedAt)
|
|
718
|
+
this.participantNames.set(participant.id, participant.displayName);
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
catch { /* Older APIs or transient metadata failures must not hide encrypted content. */ }
|
|
722
|
+
// Cloud members are server-confirmed identities too: their account name, else their email.
|
|
723
|
+
if (isCloudConfig(this.config)) {
|
|
724
|
+
try {
|
|
725
|
+
for (const member of await listCloudMembers(this.api))
|
|
726
|
+
this.participantNames.set(member.accountId, member.name || member.email);
|
|
727
|
+
}
|
|
728
|
+
catch { /* Same: names are metadata, never a reason to hide content. */ }
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
async reconcileCreate(operation) {
|
|
732
|
+
await this.catchUp();
|
|
733
|
+
return this.lock(async () => {
|
|
734
|
+
if (this.sync.tombstones().some((t) => t.id === operation.id || t.id === operation.commentId))
|
|
735
|
+
return false;
|
|
736
|
+
const entities = operation.commentId ? this.sync.snapshot().replies : this.sync.snapshot().comments;
|
|
737
|
+
if (entities.some((e) => e.id === operation.id)) {
|
|
738
|
+
// The idempotency window elapsed after a committed create. Catch-up proves it exists.
|
|
739
|
+
const known = entities.find((e) => e.id === operation.id);
|
|
740
|
+
this.acknowledgeDependency(operation, known.createdRevision);
|
|
741
|
+
this.state.queue = this.state.queue.filter((op) => op.idempotencyKey !== operation.idempotencyKey);
|
|
742
|
+
delete this.state.error;
|
|
743
|
+
await this.save();
|
|
744
|
+
return true;
|
|
745
|
+
}
|
|
746
|
+
// A deployment-wide ID collision: rebind this entity and every dependent envelope once.
|
|
747
|
+
const replacement = newId(operation.commentId ? 'rpl' : 'cmt');
|
|
748
|
+
const before = structuredClone(this.state);
|
|
749
|
+
const changedKeys = new Map();
|
|
750
|
+
try {
|
|
751
|
+
for (const queued of this.state.queue) {
|
|
752
|
+
if (queued.id !== operation.id && queued.commentId !== operation.id)
|
|
753
|
+
continue;
|
|
754
|
+
const oldId = queued.id, oldParent = queued.commentId;
|
|
755
|
+
if (queued.id === operation.id)
|
|
756
|
+
queued.id = replacement;
|
|
757
|
+
if (queued.commentId === operation.id)
|
|
758
|
+
queued.commentId = replacement;
|
|
759
|
+
if (carriesContent(queued.body)) {
|
|
760
|
+
const content = await this.codec.openBody(this.where(oldId, oldParent), queued.body);
|
|
761
|
+
Object.assign(queued.body, await this.codec.seal(this.where(queued.id, queued.commentId), content));
|
|
762
|
+
}
|
|
763
|
+
if (queued.id !== oldId && this.state.authors?.[oldId]) {
|
|
764
|
+
this.state.authors[queued.id] = this.state.authors[oldId];
|
|
765
|
+
delete this.state.authors[oldId];
|
|
766
|
+
}
|
|
767
|
+
queued.path = this.resource(queued.id, queued.commentId);
|
|
768
|
+
if (queued.method === 'POST') {
|
|
769
|
+
queued.path = queued.path.slice(0, -queued.id.length - 1);
|
|
770
|
+
queued.body.id = queued.id;
|
|
771
|
+
}
|
|
772
|
+
else {
|
|
773
|
+
delete queued.body.baseRevision;
|
|
774
|
+
queued.ready = false;
|
|
775
|
+
}
|
|
776
|
+
const newKey = newIdempotencyKey();
|
|
777
|
+
changedKeys.set(queued.idempotencyKey, newKey);
|
|
778
|
+
queued.idempotencyKey = newKey;
|
|
779
|
+
}
|
|
780
|
+
for (const queued of this.state.queue)
|
|
781
|
+
if (queued.dependsOn && changedKeys.has(queued.dependsOn))
|
|
782
|
+
queued.dependsOn = changedKeys.get(queued.dependsOn);
|
|
783
|
+
for (const local of Object.keys(this.state.ids))
|
|
784
|
+
if (this.state.ids[local] === operation.id)
|
|
785
|
+
this.state.ids[local] = replacement;
|
|
786
|
+
await this.save();
|
|
787
|
+
return true;
|
|
788
|
+
}
|
|
789
|
+
catch (error) {
|
|
790
|
+
this.state = before;
|
|
791
|
+
throw error;
|
|
792
|
+
}
|
|
793
|
+
});
|
|
794
|
+
}
|
|
795
|
+
schedule(delay) {
|
|
796
|
+
if (this.stopped || !this.started || this.timer)
|
|
797
|
+
return;
|
|
798
|
+
this.timer = setTimeout(() => { this.timer = undefined; void this.flush().catch(() => { }); }, delay);
|
|
799
|
+
this.timer.unref();
|
|
800
|
+
}
|
|
801
|
+
flush() {
|
|
802
|
+
if (this.sending)
|
|
803
|
+
return this.sending;
|
|
804
|
+
this.sending = this.flushLoop().finally(() => { this.sending = undefined; });
|
|
805
|
+
return this.sending;
|
|
806
|
+
}
|
|
807
|
+
async flushLoop() {
|
|
808
|
+
while (!this.stopped) {
|
|
809
|
+
const operation = await this.lock(async () => {
|
|
810
|
+
for (const head of this.state.queue) {
|
|
811
|
+
if (this.blockedReason(head))
|
|
812
|
+
continue;
|
|
813
|
+
const at = this.state.queue.indexOf(head);
|
|
814
|
+
if (this.state.queue.slice(0, at).some((prior) => prior.id === head.id || prior.id === head.commentId || prior.commentId === head.id))
|
|
815
|
+
continue;
|
|
816
|
+
if (head.dependsOn) {
|
|
817
|
+
if (this.state.queue.some((op) => op.idempotencyKey === head.dependsOn))
|
|
818
|
+
continue;
|
|
819
|
+
head.blocked = 'missing_dependency';
|
|
820
|
+
await this.save();
|
|
821
|
+
continue;
|
|
822
|
+
}
|
|
823
|
+
if (!head.ready) {
|
|
824
|
+
// Capture the revision once before first send; uncertain retries preserve it.
|
|
825
|
+
const entity = (head.commentId ? this.sync.snapshot().replies : this.sync.snapshot().comments).find((e) => e.id === head.id);
|
|
826
|
+
if (!entity) {
|
|
827
|
+
head.blocked = 'missing_remote_entity';
|
|
828
|
+
await this.save();
|
|
829
|
+
continue;
|
|
830
|
+
}
|
|
831
|
+
head.body.baseRevision = entity.revision;
|
|
832
|
+
head.ready = true;
|
|
833
|
+
await this.save();
|
|
834
|
+
}
|
|
835
|
+
return structuredClone(head);
|
|
836
|
+
}
|
|
837
|
+
return null;
|
|
838
|
+
});
|
|
839
|
+
if (!operation)
|
|
840
|
+
return;
|
|
841
|
+
try {
|
|
842
|
+
const response = await this.api.client.request(operation.method, operation.path, { auth: this.api.keys, body: operation.body, idempotencyKey: operation.idempotencyKey });
|
|
843
|
+
await this.lock(async () => {
|
|
844
|
+
if (response.body.comment)
|
|
845
|
+
this.sync.applyComment(response.body.comment);
|
|
846
|
+
if (response.body.reply)
|
|
847
|
+
this.sync.applyReply(response.body.reply);
|
|
848
|
+
if (response.body.tombstone)
|
|
849
|
+
this.sync.applyTombstone(response.body.tombstone);
|
|
850
|
+
const queue = structuredClone(this.state.queue);
|
|
851
|
+
const entity = response.body.comment ?? response.body.reply ?? response.body.tombstone;
|
|
852
|
+
if (entity)
|
|
853
|
+
this.acknowledgeDependency(operation, entity.revision);
|
|
854
|
+
this.state.queue = this.state.queue.filter((op) => op.idempotencyKey !== operation.idempotencyKey);
|
|
855
|
+
delete this.state.error;
|
|
856
|
+
this.attempt = 0;
|
|
857
|
+
try {
|
|
858
|
+
await this.save();
|
|
859
|
+
}
|
|
860
|
+
catch (error) {
|
|
861
|
+
this.state.queue = queue;
|
|
862
|
+
throw error;
|
|
863
|
+
}
|
|
864
|
+
});
|
|
865
|
+
await this.catchUp();
|
|
866
|
+
}
|
|
867
|
+
catch (error) {
|
|
868
|
+
if (error instanceof ApiError && error.code === 'already_exists' && operation.method === 'POST') {
|
|
869
|
+
try {
|
|
870
|
+
if (await this.reconcileCreate(operation))
|
|
871
|
+
continue;
|
|
872
|
+
}
|
|
873
|
+
catch (reconcileError) {
|
|
874
|
+
error = reconcileError;
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
const retryable = !(error instanceof ApiError) || error.retryable;
|
|
878
|
+
await this.lock(async () => {
|
|
879
|
+
this.state.error = error instanceof ApiError ? error.code : 'offline';
|
|
880
|
+
const queued = this.state.queue.find((op) => op.idempotencyKey === operation.idempotencyKey);
|
|
881
|
+
if (!retryable && queued) {
|
|
882
|
+
// Authentication and session expiry affect the whole session. A write-only 403
|
|
883
|
+
// can be permanent operation authorization and stays parked until explicit retry.
|
|
884
|
+
if (error instanceof ApiError && ['unauthorized', 'session_expired'].includes(error.code))
|
|
885
|
+
this.blockSession(queued, error.code);
|
|
886
|
+
else {
|
|
887
|
+
queued.blocked = this.state.error;
|
|
888
|
+
queued.blockedBy = 'operation';
|
|
889
|
+
delete queued.retryNotBefore;
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
await this.save();
|
|
893
|
+
});
|
|
894
|
+
if (!retryable)
|
|
895
|
+
continue;
|
|
896
|
+
if (retryable)
|
|
897
|
+
this.schedule(Math.max(error instanceof ApiError ? (error.retryAfterSeconds ?? 0) * 1000 : 0, Math.random() * Math.min(30000, this.retryDelayMs * 2 ** this.attempt++)));
|
|
898
|
+
return;
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
/** Store capability is explicit; constructors are not a protocol discriminator. */
|
|
904
|
+
export function isRemoteStore(store) {
|
|
905
|
+
return store.apiKind === 'v0';
|
|
906
|
+
}
|
|
907
|
+
//# sourceMappingURL=store.js.map
|