From 04947d99f76645d48fc9eacf6b6cd5fdd42ae2a2 Mon Sep 17 00:00:00 2001 From: terencecho <3916587+terencecho@users.noreply.github.com> Date: Wed, 11 Nov 2026 06:26:24 +0000 Subject: [PATCH] feat(cli): share rendered videos through unified reviews (#7135) * feat(cli): share rendered videos through unified reviews (#7135) * feat(share): attach editable project sources to reviews (#7137) * feat(share): measure local sharing outcomes (#7138) * feat(cli): stage the sixty-day publish transition (#7136) * feat(studio): share review pages from local preview (#7140) Advertise the CLI sharing bridge before bootstrapping it so standalone Studio does not request unsupported routes. Preserve origin and session checks. Budget the intended sharing artifact: clean main packs at 8,060,519 bytes versus 8,162,979 with sharing (8,169,168 in CI). Required policy and Unicode tables, bundled sharing code, and Studio controls account for the growth. Set the packed-only budget to 8,577,627, following the 5% headroom convention; retain the unpacked cap and all package checks. * fix(share): persist refusals and improve CLI retry feedback * fix(ci): restore render diagnostics and include sharing workspace * fix(cli): keep sharing owner error codes stable * fix(share): clarify update feedback and align audience changes * fix(share): clarify updates and avoid scratch-file rerenders * fix(cli): report active shares and preserve update channels * fix(cli): resolve update channel when checking registry * fix(ci): refresh sharing package budgets after rebase * fix(share): require consent before uploading project files --- .github/workflows/ci.yml | 12 +- Dockerfile.test | 4 +- README.md | 10 +- bun.lock | 1 + docs/contributing/unified-sharing-rollout.md | 7 + docs/developers/share-source.mdx | 137 + docs/docs.json | 1 + docs/guides/export-and-share.mdx | 34 + docs/packages/cli.mdx | 95 +- docs/reference/share-status.mdx | 28 + packages/cli/package.json | 1 + packages/cli/scripts/build-copy.mjs | 7 + packages/cli/src/auth/errors.ts | 2 +- packages/cli/src/cli.agentMode.test.ts | 4 +- packages/cli/src/cli.lifecycle.test.ts | 4 +- packages/cli/src/cli.ts | 14 +- packages/cli/src/commands/auth/logout.test.ts | 7 + packages/cli/src/commands/auth/logout.ts | 7 +- packages/cli/src/commands/publish.test.ts | 59 +- packages/cli/src/commands/publish.ts | 6 +- packages/cli/src/commands/render.test.ts | 29 + packages/cli/src/commands/render.ts | 13 +- .../cli/src/commands/render/execute.test.ts | 21 +- packages/cli/src/commands/render/execute.ts | 22 +- packages/cli/src/commands/share.test.ts | 166 + packages/cli/src/commands/share.ts | 233 + packages/cli/src/commands/upgrade.ts | 3 +- packages/cli/src/help.ts | 1 + packages/cli/src/server/shareBoundary.ts | 31 + packages/cli/src/server/shareEvents.ts | 12 + .../cli/src/server/shareFreshness.test.ts | 75 + packages/cli/src/server/shareFreshness.ts | 44 + .../cli/src/server/sharePresentation.test.ts | 22 + packages/cli/src/server/sharePresentation.ts | 61 + packages/cli/src/server/shareRoutes.test.ts | 441 ++ packages/cli/src/server/shareRoutes.ts | 271 + packages/cli/src/server/shareSessions.ts | 31 + .../src/server/studioServer.file-race.test.ts | 1 + packages/cli/src/server/studioServer.ts | 9 +- packages/cli/src/share/activity.test.ts | 63 + packages/cli/src/share/activity.ts | 90 + packages/cli/src/share/auth.test.ts | 84 + packages/cli/src/share/auth.ts | 66 + packages/cli/src/share/errors.ts | 44 + packages/cli/src/share/host.ts | 67 + packages/cli/src/share/identity.test.ts | 78 + .../cli/src/share/publishTransition.test.ts | 91 + packages/cli/src/share/publishTransition.ts | 81 + .../cli/src/share/render.lifecycle.test.ts | 64 + packages/cli/src/share/render.test.ts | 89 + packages/cli/src/share/render.ts | 115 + packages/cli/src/share/service.test.ts | 522 ++ packages/cli/src/share/service.ts | 374 + packages/cli/src/share/sources.test.ts | 99 + packages/cli/src/share/sources.ts | 60 + .../cli/src/share/telemetry.optOut.test.ts | 61 + packages/cli/src/share/telemetry.test.ts | 49 + packages/cli/src/share/telemetry.ts | 96 + packages/cli/src/share/uploadOrigins.test.ts | 90 + packages/cli/src/share/uploadOrigins.ts | 28 + packages/cli/src/utils/project.test.ts | 19 +- packages/cli/src/utils/project.ts | 7 +- .../src/utils/render-success-state.test.ts | 29 + .../cli/src/utils/render-success-state.ts | 10 +- packages/cli/src/utils/updateChannel.test.ts | 46 + packages/cli/src/utils/updateCheck.test.ts | 7 +- packages/cli/src/utils/updateCheck.ts | 24 +- packages/cli/tsup.config.ts | 1 + .../src/services/browserManager.test.ts | 36 +- .../engine/src/services/browserManager.ts | 7 +- .../engine/src/services/frameCapture.test.ts | 1 - packages/engine/src/services/frameCapture.ts | 19 +- packages/producer/src/logger.ts | 4 +- .../src/services/htmlCompiler.test.ts | 12 +- .../producer/src/services/htmlCompiler.ts | 20 +- packages/share/README.md | 59 +- packages/share/scripts/copy-types.mjs | 3 + packages/share/src/index.mjs | 8 + packages/share/src/projectLock.mjs | 13 +- packages/share/src/projectSnapshot.mjs | 28 +- packages/share/src/reviewClient.mjs | 3 +- packages/share/src/reviewExport.mjs | 198 +- packages/share/src/reviewUpload.mjs | 34 +- packages/share/src/shareSources.mjs | 236 + packages/share/src/sourceIgnore.mjs | 92 + packages/share/src/sources/adapterTypes.d.ts | 39 + packages/share/src/sources/api.mjs | 114 + packages/share/src/sources/capture.mjs | 264 + packages/share/src/sources/contract.mjs | 13 + .../src/sources/contract/LICENSE-Unicode.txt | 39 + .../src/sources/contract/path-policy.json | 311 + .../src/sources/contract/unicode-15.1.0.json | 6179 +++++++++++++++++ packages/share/src/sources/errors.mjs | 77 + packages/share/src/sources/limits.mjs | 48 + packages/share/src/sources/manifest.mjs | 154 + packages/share/src/sources/pathPolicy.mjs | 197 + packages/share/src/sources/projectState.mjs | 59 + packages/share/src/sources/store.mjs | 82 + packages/share/src/sources/transfer.mjs | 196 + packages/share/src/sources/types.d.ts | 353 + packages/share/src/sources/unicode.mjs | 163 + packages/share/src/sources/upload.mjs | 201 + packages/share/src/sources/uploadFiles.mjs | 263 + packages/share/src/sources/wire.mjs | 205 + .../compositionSync/manifest-vectors.json | 4125 +++++++++++ packages/share/tests/kernel.test.mjs | 137 +- .../tests/reviewFailurePersistence.test.mjs | 251 + packages/share/tests/sourceAdapter.test.mjs | 410 ++ packages/share/tests/sourceCapture.test.mjs | 313 + packages/share/tests/sourceManifest.test.mjs | 129 + packages/share/tests/sourceUpload.test.mjs | 271 + packages/studio-server/src/index.ts | 9 + packages/studio-server/src/localShare.ts | 48 + packages/studio/src/App.tsx | 1 + .../studio/src/components/StudioHeader.tsx | 4 + .../src/components/share/QuickShare.test.tsx | 622 ++ .../src/components/share/QuickShare.tsx | 104 + .../components/share/QuickShareControls.tsx | 265 + .../src/components/share/ShareAudience.tsx | 120 + .../src/components/share/localShareClient.ts | 171 + .../share/localShareTelemetry.test.ts | 22 + .../components/share/localShareTelemetry.ts | 13 + .../src/components/share/useQuickShare.ts | 215 + scripts/check-cli-share-capture.mjs | 28 + scripts/package-size-budgets.json | 10 +- scripts/studio-runtime-smoke.mjs | 1 + scripts/studio-runtime-smoke.test.mjs | 3 + scripts/verify-packed-manifests.mjs | 8 + skills-manifest.json | 2 +- skills/hyperframes-cli/SKILL.md | 6 +- .../references/preview-render.md | 20 + 131 files changed, 21234 insertions(+), 184 deletions(-) create mode 100644 docs/contributing/unified-sharing-rollout.md create mode 100644 docs/developers/share-source.mdx create mode 100644 docs/reference/share-status.mdx create mode 100644 packages/cli/src/commands/share.test.ts create mode 100644 packages/cli/src/commands/share.ts create mode 100644 packages/cli/src/server/shareBoundary.ts create mode 100644 packages/cli/src/server/shareEvents.ts create mode 100644 packages/cli/src/server/shareFreshness.test.ts create mode 100644 packages/cli/src/server/shareFreshness.ts create mode 100644 packages/cli/src/server/sharePresentation.test.ts create mode 100644 packages/cli/src/server/sharePresentation.ts create mode 100644 packages/cli/src/server/shareRoutes.test.ts create mode 100644 packages/cli/src/server/shareRoutes.ts create mode 100644 packages/cli/src/server/shareSessions.ts create mode 100644 packages/cli/src/share/activity.test.ts create mode 100644 packages/cli/src/share/activity.ts create mode 100644 packages/cli/src/share/auth.test.ts create mode 100644 packages/cli/src/share/auth.ts create mode 100644 packages/cli/src/share/errors.ts create mode 100644 packages/cli/src/share/host.ts create mode 100644 packages/cli/src/share/identity.test.ts create mode 100644 packages/cli/src/share/publishTransition.test.ts create mode 100644 packages/cli/src/share/publishTransition.ts create mode 100644 packages/cli/src/share/render.lifecycle.test.ts create mode 100644 packages/cli/src/share/render.test.ts create mode 100644 packages/cli/src/share/render.ts create mode 100644 packages/cli/src/share/service.test.ts create mode 100644 packages/cli/src/share/service.ts create mode 100644 packages/cli/src/share/sources.test.ts create mode 100644 packages/cli/src/share/sources.ts create mode 100644 packages/cli/src/share/telemetry.optOut.test.ts create mode 100644 packages/cli/src/share/telemetry.test.ts create mode 100644 packages/cli/src/share/telemetry.ts create mode 100644 packages/cli/src/share/uploadOrigins.test.ts create mode 100644 packages/cli/src/share/uploadOrigins.ts create mode 100644 packages/cli/src/utils/updateChannel.test.ts create mode 100644 packages/share/src/shareSources.mjs create mode 100644 packages/share/src/sourceIgnore.mjs create mode 100644 packages/share/src/sources/adapterTypes.d.ts create mode 100644 packages/share/src/sources/api.mjs create mode 100644 packages/share/src/sources/capture.mjs create mode 100644 packages/share/src/sources/contract.mjs create mode 100644 packages/share/src/sources/contract/LICENSE-Unicode.txt create mode 100644 packages/share/src/sources/contract/path-policy.json create mode 100644 packages/share/src/sources/contract/unicode-15.1.0.json create mode 100644 packages/share/src/sources/errors.mjs create mode 100644 packages/share/src/sources/limits.mjs create mode 100644 packages/share/src/sources/manifest.mjs create mode 100644 packages/share/src/sources/pathPolicy.mjs create mode 100644 packages/share/src/sources/projectState.mjs create mode 100644 packages/share/src/sources/store.mjs create mode 100644 packages/share/src/sources/transfer.mjs create mode 100644 packages/share/src/sources/types.d.ts create mode 100644 packages/share/src/sources/unicode.mjs create mode 100644 packages/share/src/sources/upload.mjs create mode 100644 packages/share/src/sources/uploadFiles.mjs create mode 100644 packages/share/src/sources/wire.mjs create mode 100644 packages/share/tests/fixtures/compositionSync/manifest-vectors.json create mode 100644 packages/share/tests/reviewFailurePersistence.test.mjs create mode 100644 packages/share/tests/sourceAdapter.test.mjs create mode 100644 packages/share/tests/sourceCapture.test.mjs create mode 100644 packages/share/tests/sourceManifest.test.mjs create mode 100644 packages/share/tests/sourceUpload.test.mjs create mode 100644 packages/studio-server/src/localShare.ts create mode 100644 packages/studio/src/components/share/QuickShare.test.tsx create mode 100644 packages/studio/src/components/share/QuickShare.tsx create mode 100644 packages/studio/src/components/share/QuickShareControls.tsx create mode 100644 packages/studio/src/components/share/ShareAudience.tsx create mode 100644 packages/studio/src/components/share/localShareClient.ts create mode 100644 packages/studio/src/components/share/localShareTelemetry.test.ts create mode 100644 packages/studio/src/components/share/localShareTelemetry.ts create mode 100644 packages/studio/src/components/share/useQuickShare.ts create mode 100644 scripts/check-cli-share-capture.mjs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 06be500b87..6ad6e62abd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -231,7 +231,11 @@ jobs: - "packages/lint/src/**" - "packages/cli/src/{cli,help,version}.ts" - "packages/cli/src/renderSetupWorker*.ts" - - "packages/cli/src/commands/{preview*,add,browser}.ts" + - "packages/cli/src/commands/{preview*,add,browser,batchRender,render}.ts" + - "packages/cli/src/commands/render/**" + - "packages/cli/src/share/**" + - "packages/cli/src/cloud/parsing.ts" + - "packages/share/{src,scripts}/**" - "packages/cli/src/server/**" - "packages/cli/src/browser/**" - "packages/cli/src/utils/**" @@ -239,7 +243,7 @@ jobs: - "packages/cli/src/{background-removal,registry,telemetry}/**" - "packages/cli/src/capture/{captureCompositionFrame,captureTimeout,navigateForCapture,readBoundedResponse}.ts" - "packages/cli/src/media-use/lib/config-lock.mjs" - - "packages/cli/src/auth/{config,errors,paths,telemetryIdentity}.ts" + - "packages/cli/src/auth/**" - "packages/cli/scripts/**" - "packages/core/stubs/**" - "packages/engine/src/**" @@ -248,7 +252,7 @@ jobs: - "packages/producer/scripts/build-hf-early-stub.ts" - "packages/producer/build*.mjs" - "packages/player/scripts/verify-runtime-pin.mjs" - - "packages/{studio,studio-server,core,parsers,player,sdk,lint,cli,engine,producer}/{package.json,tsconfig.json,tsup.config.ts}" + - "packages/{studio,studio-server,core,parsers,player,sdk,lint,cli,engine,producer,share}/{package.json,tsconfig.json,tsup.config.ts}" - "packages/*/package-subpaths.json" - "scripts/package-subpaths.mjs" - "scripts/rewrite-relative-import-extensions.mjs" @@ -1529,7 +1533,7 @@ jobs: bun run --filter @hyperframes/cli dev -- lint /tmp/hf-cli-inside bun run --filter @hyperframes/cli dev -- validate /tmp/hf-cli-inside --timeout 3000 - bun run --filter @hyperframes/cli dev -- render /tmp/hf-cli-inside \ + HF_DEBUG_RENDER=1 bun run --filter @hyperframes/cli dev -- render /tmp/hf-cli-inside \ --quality standard \ --workers auto \ --strict \ diff --git a/Dockerfile.test b/Dockerfile.test index 4e6cf42d80..15b71567aa 100644 --- a/Dockerfile.test +++ b/Dockerfile.test @@ -104,6 +104,8 @@ COPY packages/engine/package.json packages/engine/package.json COPY packages/player/package.json packages/player/package.json COPY packages/producer/package.json packages/producer/package.json COPY packages/cli/package.json packages/cli/package.json +# Sharing runs its prepare script at install time, so include its build inputs. +COPY packages/share/ packages/share/ COPY packages/studio/package.json packages/studio/package.json COPY packages/shader-transitions/package.json packages/shader-transitions/package.json COPY packages/aws-lambda/package.json packages/aws-lambda/package.json @@ -137,7 +139,7 @@ COPY packages/studio-server/ packages/studio-server/ COPY packages/core/ packages/core/ # Build workspace packages so "node" export conditions resolve to built dist -RUN bun run --filter '@hyperframes/{parsers,lint,studio-server}' build \ +RUN bun run --filter '@hyperframes/{parsers,lint,studio-server,share}' build \ && bun run --cwd packages/core build # Build core runtime artifacts (needed by renderer) diff --git a/README.md b/README.md index a152519476..8e6fb67745 100644 --- a/README.md +++ b/README.md @@ -112,7 +112,7 @@ This writes `dist/hyperframes-plugin.zip` with a `hyperframes/` root folder and | Skill | Use when | | ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `/hyperframes` | **Read first** for any request to make, edit, animate or render a video, motion graphic, captions or overlays with HyperFrames (HTML rendered to video). Holds the render contract and the work loop, and points to the references for format, motion, look, captions, whole films and storyboards. | -| `/hyperframes-cli` | The HyperFrames CLI by job — scaffold, check, look at frames, edit the timeline, preview, render locally or in the cloud, publish, project history — plus reading its JSON and recovering from build or render failures. | +| `/hyperframes-cli` | The HyperFrames CLI by job — scaffold, check, look at frames, edit the timeline, preview, render locally or in the cloud, share, project history — plus reading its JSON and recovering from build or render failures. | | `/hyperframes-registry` | About 450 ready-made blocks and components installed as editable source — transitions, overlays, titles, kinetic type, captions, charts, maps, 3D, camera moves. Use before hand-building any named visual; also for `hyperframes add` and `catalog`. | | `/media-use` | Get or make any media for a video — music, sound effects, images, icons, logos, voiceover, avatar and generated video, transcripts, cutouts, colour grades and looks — with HeyGen or free local tools, and mix placed audio. Also for footage that looks dark, flat or dull. | | `/reverse-any-video` | Rebuilding any video file as an editable HyperFrames project (motion graphics, talking heads, live action, AI-generated footage), checked frame by frame against the original. HyperFrames Pro. | @@ -364,3 +364,11 @@ GIT_LFS_SKIP_SMUDGE=1 git clone https://github.com/heygen-com/hyperframes.git ## License [Apache 2.0](LICENSE) + +### Share a video for review + +Sign in with `npx hyperframes auth login`, then run `npx hyperframes share` to +choose who can open the rendered review. Use `share --update` when edits should +become a new version and `share --manage` for web settings. CLI and Desktop use +the same sharing system and five free projects per workspace. Existing legacy +published links remain reachable. diff --git a/bun.lock b/bun.lock index 7477213746..63f04c1d8d 100644 --- a/bun.lock +++ b/bun.lock @@ -99,6 +99,7 @@ "@hyperframes/lint": "workspace:*", "@hyperframes/parsers": "workspace:*", "@hyperframes/producer": "workspace:*", + "@hyperframes/share": "workspace:*", "@hyperframes/studio": "workspace:*", "@hyperframes/studio-server": "workspace:*", "@types/css-tree": "^3.2.0", diff --git a/docs/contributing/unified-sharing-rollout.md b/docs/contributing/unified-sharing-rollout.md new file mode 100644 index 0000000000..cb51f8097e --- /dev/null +++ b/docs/contributing/unified-sharing-rollout.md @@ -0,0 +1,7 @@ +# Validate local sharing + +Run the share package, CLI, and Studio tests before publishing a change to the sharing flow. For manual verification, create a review link in the CLI, then open the same folder in local Studio and add a version. Verify that both surfaces reuse the existing link and that an interrupted upload can resume without creating another version. + +Check that copying an existing link leaves local edits untouched, that changing or disabling access preserves the expected link state, and that existing published links and updates continue to work. For accounts that support editable project files, verify that the source matches the rendered version and can be opened by an authorized recipient. + +Sharing telemetry uses the existing CLI preference. Verify that opting out suppresses events and that payloads contain no project paths, titles, review links, credentials, or raw errors. Upload admission, playback readiness, and copying a link are separate events. diff --git a/docs/developers/share-source.mdx b/docs/developers/share-source.mdx new file mode 100644 index 0000000000..317ba2f2e1 --- /dev/null +++ b/docs/developers/share-source.mdx @@ -0,0 +1,137 @@ +--- +title: "Editable source in a share" +description: "Choose whether a CLI review includes the project files used by its rendered video." +--- + +`hyperframes share` can attach editable project files to the same review page +used by Desktop. Source upload requires `--include-source` for each upload, including updates. +Without it, terminal, JSON and unattended commands share video only. +Local Studio offers an unchecked **Include editable project files** option with +a disclosure of the upload scope before creating or updating a share. + +Source is available when the workspace's sharing and +Composition Sync permissions allow it. The recipient's access still depends on +the share's settings and their plan. + +```bash +hyperframes share --public # Video only (default) +hyperframes share --public --include-source # Also upload editable project files +hyperframes share --update # Update the existing review +hyperframes share --update --video-only # Explicitly omit editable source +``` + +The five-free-project sharing limit is unchanged. A workspace that cannot use +Composition Sync can still share its rendered video. The command reports +`source.at: "video_only"` and a reason in JSON; this is a successful video share. +A source upload does not grant anyone editing access by itself. Manage access +through `hyperframes share --manage`. + +## What travels + +Source uses the same portable project policy as Desktop: authored HTML, scripts, +styles, assets, and supported Studio edit metadata. Known credential filenames +(such as `.env`, `.npmrc`, and `*.pem`), dependency directories, chat +history, local sharing state, and recorded render outputs stay out. + +These are filename rules, not a secret scanner. `.gitignore` does not control +source capture. Other regular files can be included even if Git ignores them. +Keep private material outside the project, or use `--video-only` when you do not +want to upload project files. Unsupported symlinks and invalid file names stop +source preparation rather than silently producing an incomplete editable project. + +To exclude scratch files, add `.hyperframesignore` at the project root: + +```text +# Literal paths, relative to the project root +out.json +scratch/ +``` + +Each line excludes that file or folder and its contents from source capture and +sharing change detection. Blank lines and lines starting with `#` are ignored. +Use paths with `/` separators or a single `*` wildcard (for example, `*.log` +or `scratch/*.json`). Basename patterns apply in every folder. Negation, absolute paths, and +excluding `index.html` are rejected. Do not exclude assets your composition uses. +These rules can only exclude files, never re-include credentials or other files +blocked by the portable project policy. + +The upload uses the workspace's file-count, per-file, project-size and manifest +limits. Large media uploads in parts. Only a verified published snapshot that +still matches the rendered project can be attached to the video version. The CLI +checks the contents of rendered assets, including changes that preserve file +sizes and timestamps. Deployments must include the exact source storage origins +in `HYPERFRAMES_REVIEW_UPLOAD_ORIGINS` alongside the video storage origins. + +## Interrupted uploads and unavailable source + +Retry the same command after a network interruption. Its local record preserves +the composition identity, upload idempotency key and completed file parts. +A storage upload that makes no progress for 60 seconds is stopped and retried +within the retry limit. The source record lives at `.hyperframes/share-sync..json` and +contains no sign-in token. Do not copy that record into another project or edit +its account, workspace or path: mismatches stop sharing to avoid overwriting +another project's source. + +If source changed, conflicts with another snapshot, or remains under verification, +the command explains why it stopped. Retry after resolving the problem, or pass +`--video-only` to share just the rendered video. An unexpected source upload +failure never silently turns an eligible source share into video-only. If the +server confirms an upload expired or failed, a retry starts a new upload. If +the files changed while an earlier upload was still pending, the CLI cancels +that upload before starting a new one. It waits for uploads already under +verification and preserves conflicts for explicit resolution. + +A video-only retry does not resume an interrupted video upload that already +includes source. Check its status before retrying. To publish the same render as +a new video-only version after the earlier upload finishes, use +`hyperframes share --update --video-only`. Previous versions retain their files. + +`--status` reads the review without uploading anything. Its source state is +`not_checked`; it does not promise that local files match the shared version. +The upload result uses `ready` only after source verification and attachment +preparation; video readiness remains the separate top-level `ready` field. + +## Refused uploads + +A refused upload is saved locally so `--status` reports a failure, including +across CLI restarts. Retry an unfinished first share with the same command; +use `--update` to replace a previously shared video. An upload whose result is +still unknown keeps its recovery record to avoid creating duplicate versions. + +`export_blocked` means recent content moderation strikes prevent new video +versions in this workspace. Contact HeyGen support to appeal. Rendering again, +changing audience, or having a paid plan does not lift the block. +`can_register_project` describes project quota eligibility, not moderation +permission to upload a video. + +`--manage` requires an existing share. Audience flags are for first-share +creation and cannot be combined with `--status`, `--manage`, or `--update`. +Progress is written to stderr once per step; `--json` suppresses progress and +unrelated skill-update notices. Set `HF_DEBUG_RENDER=1` only when diagnosing +render initialization. + +## Integrating another local host + +`@hyperframes/share` exports `shareSources` and +`createProjectShareSourceStore`. Call `prepare(projectPath, renderedFingerprint)` +before `addVersion`, then pass `filesForExport` and `requireSource: true` for a +ready source result. `requireSource` prevents a later mismatch from degrading to +a video-only version. Pass `omitSource: true` for a video-only operation that +must not reuse a source-bearing version or pending upload. + +A host may inject its existing binding store, or supply a read-only +`existingBinding` resolver for Desktop bindings. Exact snapshots can be reused +only in the same account and owner workspace, without a pending sync operation. +Unsynced changes in a Desktop-owned binding require a Desktop sync first. The +standalone CLI keeps its own project-local sync record; it does not discover or +modify Desktop's application data directory. + +## Related topics + +- [CLI reference](/packages/cli#share) — audiences, updates, and processing status. +- [CLI guide](/developers/cli) — choose the command for your task. + +Sharing excludes scratch `*.log` and `*.swp` files by default, both from render +change detection and uploaded project files. Other files remain inputs because +compositions can load them dynamically. Invalid rules report +`invalid_source_ignore`; sharing stops rather than silently uploading excluded files. diff --git a/docs/docs.json b/docs/docs.json index 1ad3c55479..e882e4e999 100644 --- a/docs/docs.json +++ b/docs/docs.json @@ -196,6 +196,7 @@ "pages": [ "developers/cli", "packages/cli", + "developers/share-source", "developers/catalog-search", "developers/harness-tool-context", "packages/lint" diff --git a/docs/guides/export-and-share.mdx b/docs/guides/export-and-share.mdx index 29aaa74d0e..2f190c166d 100644 --- a/docs/guides/export-and-share.mdx +++ b/docs/guides/export-and-share.mdx @@ -161,3 +161,37 @@ editor or its render queue. - [Export and manage renders in the browser editor](/studio/export) - [Use advanced rendering options](/guides/rendering) - [Diagnose a project or render failure](/help) + +## Share from the local Studio preview + +Open a project with `hyperframes preview`, then choose **Share** beside **Export**. +Choose **Sign in** if prompted. You can also run +`hyperframes auth login` in your terminal, then return to Studio. Sharing reconnects +automatically after browser sign-in or when you return to the panel. Credentials stay +in the local CLI process. If you switch accounts in the terminal, reload Studio +or sign in from the panel before retrying. + +Choose the workspace and who can access the project, then choose **Create share +link**. Studio finishes saving pending edits before it renders and uploads the +project. The five free shared-project allowance is the same allowance used by +Desktop and the CLI. The workspace meter comes from the server; retries of an +existing registration do not need an extra slot. + +Project files are included when available for the workspace. The panel reports +whether the last Studio upload included files or was video only. If attaching +files fails, retry the upload or explicitly choose **Retry with video only**. + +When the video is ready, choose **Copy link**. Local edits do not automatically +replace the shared video: **Update shared version** uploads the saved project to +the same review page. Changes to access use a separate **Save access** action. +**Turn link off** keeps the project and comments; updating the video keeps an +off link off. Turning the link off does not free a shared-project slot. + +You can close the Share panel while sharing continues, but keep the local Studio +server running. Reopen the panel to recover progress, or use **Refresh** after a +connection problem. **Manage sharing** opens the web page for invites and owner +settings. Existing published project URLs continue to open separately. + +The local sharing bridge is available only from the same-origin loopback Studio +page. It does not expose CLI credentials or accept a different project path. +As with local preview, open projects whose scripts you trust. diff --git a/docs/packages/cli.mdx b/docs/packages/cli.mdx index d571070a31..595b2b8e84 100644 --- a/docs/packages/cli.mdx +++ b/docs/packages/cli.mdx @@ -26,7 +26,7 @@ npm install -g hyperframes | ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Start a project | [`init`](#init), [`add`](#add), [`catalog`](#catalog) | | Bring in source material | [`capture`](#capture), [`media-use`](#media-use), [`transcribe`](#transcribe), [`tts`](#tts), [`remove-background`](#remove-background), [`media-treatment`](#media-treatment), [`beats`](#beats), [`audio`](#audio), [`normalize-audio`](#normalize-audio), [`models`](#models) | -| Look at it, or share it | [`preview`](#preview), [`present`](#present-and-play), [`play`](#present-and-play), [`publish`](#publish), [`open`](#open-and-catch-up), [`catch-up`](#open-and-catch-up) | +| Look at it, or share it | [`share`](#share), [`preview`](#preview), [`present`](#present-and-play), [`play`](#present-and-play), [`publish`](#publish), [`open`](#open-and-catch-up), [`catch-up`](#open-and-catch-up) | | Find problems | [`lint`](#lint), [`check`](#check), [`snapshot`](#snapshot), [`keyframes`](#keyframes), [`compare`](#compare-and-grade-compare), [`grade-compare`](#compare-and-grade-compare) | | Rebuild a video | [`reverse`](#reverse), [`measure`](#measure), [`diff`](#diff) | | Edit from the terminal | [`timeline`](#timeline), [`history`](#history) | @@ -119,9 +119,9 @@ vision keys, models, Vertex settings and timeout, and the telemetry opt-outs `HY other key in the file is ignored, and one line on stderr names them. **Flags, not prompts.** A missing required flag fails immediately with a usage -example rather than waiting for input. Two commands are interactive on a TTY: +example rather than waiting for input. These commands can ask questions on a TTY: `init` prompts for a project name and example unless you pass -`--non-interactive`, and `catalog --human-friendly` opens a picker. Nothing else +`--non-interactive`, `catalog --human-friendly` opens a picker, and `share` asks for a first-share audience. Nothing else prompts, apart from confirmations you can skip with `--yes` or `--no-confirm`. **Unattended runs never prompt.** A run is unattended when stdin or stdout is not @@ -1104,6 +1104,15 @@ editor, just playback. Same flags, `--port` defaults to 3003, plus `--proxy` / ### `publish` +For new video reviews, use [`share`](#share). Legacy source publishing stays +available with a notice for 60 days from an announced notice release. That +release date has not been scheduled. After the window, new `publish` runs guide +you to `share`, where you choose a new audience; old flags are never silently +translated. Existing published URLs and legacy updates remain supported under +a separate retirement plan. After the window, sign in with `hyperframes auth login` +to update an existing publication; signed-out and API-key publishing cannot +preserve its ownership. Legacy server handling of missing update targets is unchanged. + Upload the project and get back a stable `hyperframes.studio` URL. ```bash @@ -3035,3 +3044,83 @@ Anything you leave out gets the default, so the file only needs your overrides. The capture engine. Use directly for custom frame capture pipelines. + + +## share + +Share a rendered MP4 for review, with the same project identity, access controls, +comments and version history as HyperFrames Desktop. Sign in with +`hyperframes auth login` first; API keys cannot own review projects. + +```bash +hyperframes share --public # Video only; anyone with the link +hyperframes share --public --include-source # Also upload editable project files +hyperframes share --status --json # Read status; never upload local edits +hyperframes share --update # Render and upload the current project +hyperframes share --manage # Open web sharing settings +``` + +Sharing uploads video only by default. `--include-source` explicitly includes portable project files, including unused and Git-ignored files; review your folder and `.hyperframesignore` first. `--video-only` remains available and cannot be combined with `--include-source`. Source inclusion must be chosen for each upload, including `--update`; `--yes` does not consent to source upload. + + +The first share requires an explicit audience: `--public`, `--team`, +`--invite-only`, or `--private`. In an attended terminal, `share` asks you to +choose. `--yes` suppresses questions but does not choose an audience. Available +audiences follow your workspace plan. `--space ` selects the owning workspace +on first share; later runs preserve it. + +Free workspaces retain up to **five shared projects**, across CLI and Desktop. +Adding versions uses the same project. Turning off its link does not free a slot; +remove a project in web management or upgrade when the workspace is full. +The server enforces the limit even when clients create projects simultaneously. + +Running `share` again returns the existing link without uploading edits. An explicit +audience flag (for example, `share --public`) changes an existing share’s audience +without uploading a version, just like Studio’s audience selector. Without an +audience flag, access stays unchanged. Use +`--update` to publish a new rendered version. If nothing changed, the command says +“Already up to date” (`upToDate: true` in JSON). A successful new version +sets `updated: true`; Studio confirms “Shared version updated.” Status reads +omit `upToDate` because they do not render or compare all inputs. The previous ready version remains +visible while an update processes. Interrupted first uploads can resume when +the source is unchanged; if it changed, explicitly use `--update`. If the +project's review or audience changes while rendering, check the current share +with `--status` before retrying. + +Completed renders accumulate in `.hyperframes/share-renders/`. To reclaim that +space, wait for uploads to finish and close any running share commands, then +remove that directory and `.hyperframes/share-render.json`. The next share or +update that needs a render will rebuild the cache. + +`--wait-seconds <1–1800>` controls how long the command waits for video +processing (default 300). A processing result is accepted, not playback-ready: +check `ready` and `state` in JSON before distributing a URL. `url` is only +returned for a ready share. Run `--status` to check again. Exit codes are 0 +for an accepted/read operation, 1 for failure, and 2 for invalid arguments. +A successful local render does not finish sharing: upload failures still return +a failure exit code. A failed processing or screening attempt stays failed across +CLI runs: `--status --json` returns `ok: false`, `state: "failed"`, an error, +and exit code 1. `previousUrl` keeps the earlier ready version available after a +failed update; `url` remains null. Use `--update` to explicitly retry with the +current project. Signing into a different account while a share is running +stops that operation; start it again after sign-in. + +When another account owns the review, JSON errors use the fixed code +`owner_signed_out` with the owner email in `error.owner`. The human-readable +message also identifies the account to sign into. + +The standard production CLI includes exact trusted storage origins for review +videos and editable project sources; no upload configuration is required. +Development environments, custom API/OAuth endpoints or clients, and custom +storage setups must set `HYPERFRAMES_REVIEW_UPLOAD_ORIGINS` to the +comma-separated HTTPS origins provided by their deployment. Use exact origins +without paths or wildcards. This setting replaces the production defaults; +setting it to an empty string disables uploads. Defaults apply only with the +production environment and standard production API, OAuth token endpoint, and +OAuth client. Storage URLs outside the selected origins are rejected. + +Existing `/p/...` publications remain separate and reachable. Sharing does not +convert a legacy publication or change its URL, visibility or ownership. + +Share renders keep warnings and failures visible. Routine compiler, browser-launch, +and runtime-FPS diagnostics require `HF_DEBUG_RENDER=1`. diff --git a/docs/reference/share-status.mdx b/docs/reference/share-status.mdx new file mode 100644 index 0000000000..993e168a5e --- /dev/null +++ b/docs/reference/share-status.mdx @@ -0,0 +1,28 @@ +--- +title: "CLI sharing status" +description: "Follow an upload from local rendering to a ready review link." +--- + +Run `hyperframes share --status` in another terminal to see an active share in +this project. You can also run it from a project subdirectory; an explicit +project directory always takes precedence. + +```bash +hyperframes share --status --json +``` + +During a running local command, `state` reports `preparing`, `rendering`, +`uploading_source`, `uploading_video`, or `checking`. `activity.startedAt` +identifies when the operation began. These states have `ready: false` and +`url: null`; `previousUrl` can still point to an earlier ready version. +After the command finishes, status reflects the server's processing result. +A crashed local process does not leave an active progress indicator forever. + +Free workspaces can share privately or with anyone who has the link. Team and +invite-only access require a paid plan. Free sharing includes the video; +editable project sources require Pro. The five-project Free limit still applies. + +Alpha installations check the alpha release channel for updates, so their +update notice does not recommend a stable release that lacks alpha features. + +See [CLI sharing](/packages/cli#share) for audience selection, updates and failures. diff --git a/packages/cli/package.json b/packages/cli/package.json index 4f4c9d4eca..e938916a74 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -84,6 +84,7 @@ "@hyperframes/lint": "workspace:*", "@hyperframes/parsers": "workspace:*", "@hyperframes/producer": "workspace:*", + "@hyperframes/share": "workspace:*", "@hyperframes/studio": "workspace:*", "@hyperframes/studio-server": "workspace:*", "@types/css-tree": "^3.2.0", diff --git a/packages/cli/scripts/build-copy.mjs b/packages/cli/scripts/build-copy.mjs index ee8798ed2d..2840596d10 100644 --- a/packages/cli/scripts/build-copy.mjs +++ b/packages/cli/scripts/build-copy.mjs @@ -104,6 +104,13 @@ async function main() { } mkdirSync(join(DIST, "commands"), { recursive: true }); + // The bundled sharing modules resolve their policy and Unicode tables beside + // the CLI chunks, rather than from the share package's source directory. + copyDir( + join(REPO_ROOT, "packages", "share", "src", "sources", "contract"), + join(DIST, "contract"), + ); + const studioDist = resolve(CLI_ROOT, "..", "studio", "dist"); await waitForStudioDist(studioDist); // Only the SPA studioServer.ts serves (index.html, /assets, /icons, /favicon.svg); diff --git a/packages/cli/src/auth/errors.ts b/packages/cli/src/auth/errors.ts index de229d270e..c1a2a33643 100644 --- a/packages/cli/src/auth/errors.ts +++ b/packages/cli/src/auth/errors.ts @@ -37,7 +37,7 @@ export class AuthError extends Error { export const ErrNotConfigured = () => new AuthError( "NOT_CONFIGURED", - "No HeyGen credentials found", + "No HeyGen credentials found.", "Run `hyperframes auth login` to sign in.", ); diff --git a/packages/cli/src/cli.agentMode.test.ts b/packages/cli/src/cli.agentMode.test.ts index 63acedffce..64583c25e8 100644 --- a/packages/cli/src/cli.agentMode.test.ts +++ b/packages/cli/src/cli.agentMode.test.ts @@ -353,7 +353,9 @@ describe("agent-mode contract", () => { expect(run.code, run.stderr).toBe(1); expectJsonFailure(run, "runtime_error"); const { message } = JSON.parse(run.stdout).error as { message: string }; - expect(message).toMatch(/Aborting render due to lint issues in --strict mode: [1-9]\d* error/); + expect(message).toMatch(/Cannot render: [1-9]\d* error/); + expect(message).toContain("root_missing_dimensions"); + expect(message).toContain("Run hyperframes lint for details."); expect(run.stderr).toContain(message); }); diff --git a/packages/cli/src/cli.lifecycle.test.ts b/packages/cli/src/cli.lifecycle.test.ts index a89f3242f9..8f0294c2b3 100644 --- a/packages/cli/src/cli.lifecycle.test.ts +++ b/packages/cli/src/cli.lifecycle.test.ts @@ -411,7 +411,7 @@ describe("CLI lifecycle", () => { }); describe("stale-skills notice under --json", () => { - it("prints on a --json run while the self-update notices stay off", async () => { + it("suppresses unrelated notices on a --json run", async () => { const printSkillsUpdateNotice = vi.fn(); const printUpdateNotice = vi.fn(); mockInitCommand(vi.fn()); @@ -431,7 +431,7 @@ describe("stale-skills notice under --json", () => { process.argv = ["node", "cli.ts", "init", "--json"]; await import("./cli.js"); - await vi.waitFor(() => expect(printSkillsUpdateNotice).toHaveBeenCalledTimes(1)); + expect(printSkillsUpdateNotice).not.toHaveBeenCalled(); expect(printUpdateNotice).not.toHaveBeenCalled(); }); }); diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.ts index 963005417b..a1e9d7466b 100644 --- a/packages/cli/src/cli.ts +++ b/packages/cli/src/cli.ts @@ -144,6 +144,7 @@ const commandLoaders = { present: () => import("./commands/present.js").then((m) => m.default), preview: () => assertStudioWorkspaceBuilt().then(() => import("./commands/preview.js").then((m) => m.default)), + share: () => import("./commands/share.js").then((m) => m.default), publish: () => import("./commands/publish.js").then((m) => m.default), open: () => import("./commands/open.js").then((m) => m.default), "catch-up": () => import("./commands/catch-up.js").then((m) => m.default), @@ -327,12 +328,13 @@ if ( .catch(() => {}); } - // Skills freshness nudge: stderr only, so it also runs under --json, which agents pass. - import("./utils/skillsUpdateCheck.js") - .then((mod) => { - _printSkillsUpdateNotice = mod.printSkillsUpdateNotice; - }) - .catch(() => {}); + // Machine-readable commands should not include unrelated update notices. + if (!hasJsonFlag) + import("./utils/skillsUpdateCheck.js") + .then((mod) => { + _printSkillsUpdateNotice = mod.printSkillsUpdateNotice; + }) + .catch(() => {}); // The notices read the caches; a detached child refreshes them for the next run. import("./utils/backgroundChecks.js").then((mod) => mod.launchBackgroundChecks()).catch(() => {}); diff --git a/packages/cli/src/commands/auth/logout.test.ts b/packages/cli/src/commands/auth/logout.test.ts index 68dcac48f9..8520421a42 100644 --- a/packages/cli/src/commands/auth/logout.test.ts +++ b/packages/cli/src/commands/auth/logout.test.ts @@ -22,3 +22,10 @@ it("warns that a host access token still signs commands after logout", async () expect(console.log).toHaveBeenCalledWith(expect.stringContaining("Unset HEYGEN_ACCESS_TOKEN")); }); + +it("requires an explicit confirmation without a terminal", async () => { + const cmd = (await import("./logout.js")).default; + await expect( + (cmd.run as (ctx: { args: Record }) => Promise)({ args: {} }), + ).rejects.toThrow("auth logout --yes"); +}); diff --git a/packages/cli/src/commands/auth/logout.ts b/packages/cli/src/commands/auth/logout.ts index 45b6041edd..62ab4ac0a2 100644 --- a/packages/cli/src/commands/auth/logout.ts +++ b/packages/cli/src/commands/auth/logout.ts @@ -1,4 +1,5 @@ -import { failCommand } from "../../utils/commandResult.js"; +import { isUnattended } from "../../utils/attendedTerminal.js"; +import { CliUsageError, failCommand } from "../../utils/commandResult.js"; /** * `hyperframes auth logout` — remove the credential file. With * `--keep-api-key`, only the OAuth block is cleared (no-op for @@ -68,6 +69,10 @@ function warnIfEnvCredentialActive(): void { async function ensureConfirmed(yes: boolean, keepApiKey: boolean): Promise { if (yes) return true; + if (isUnattended()) + throw new CliUsageError( + "Signing out requires confirmation. Run hyperframes auth logout --yes to sign out without a prompt.", + ); const prompt = keepApiKey ? `This will sign out of any active OAuth session on this machine (~/.hyperframes lives at ${configDir()}). Continue? [y/N] ` : `This will sign out of HeyGen on this machine (~/.hyperframes lives at ${configDir()}). Continue? [y/N] `; diff --git a/packages/cli/src/commands/publish.test.ts b/packages/cli/src/commands/publish.test.ts index b19f036db8..92b7e0986e 100644 --- a/packages/cli/src/commands/publish.test.ts +++ b/packages/cli/src/commands/publish.test.ts @@ -3,15 +3,24 @@ import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs"; import { dirname, join } from "node:path"; import { tmpdir } from "node:os"; -const publishState = vi.hoisted(() => ({ publish: vi.fn() })); +const publishState = vi.hoisted(() => ({ publish: vi.fn(), noticeRelease: null as string | null })); vi.mock("../utils/publishProject.js", async (importOriginal) => ({ ...(await importOriginal()), publishProjectArchive: publishState.publish, })); +vi.mock("../share/publishTransition.js", async (importOriginal) => { + const actual = await importOriginal(); + return { + ...actual, + checkPublishTransition: (args: { dir?: string; update?: string }) => + actual.checkPublishTransition(args, publishState.noticeRelease), + }; +}); + import publishCommand, { examples, parseUpdateTarget } from "./publish.js"; -import { ensureProjectId } from "../utils/projectLink.js"; +import { ensureProjectId, writeProjectLink, writeTeamProject } from "../utils/projectLink.js"; import { writeStore as writeUnboundStore, type Credentials } from "../auth/store.js"; import { oauthIdentity } from "../auth/config.js"; import { consumeCommandResult } from "../utils/commandResult.js"; @@ -371,3 +380,49 @@ describe("publish --update / --space ownership preflight", () => { } }); }); + +describe("expired transition preserves only owned legacy updates", () => { + it.each(["anonymous", "api-key", "oauth"])( + "checks %s ownership before publication", + async (kind) => { + const project = mkdtempSync(join(tmpdir(), "hf-publish-transition-owner-")); + const config = mkdtempSync(join(tmpdir(), "hf-publish-transition-config-")); + vi.stubEnv("HYPERFRAMES_CONFIG_DIR", config); + vi.stubEnv("HEYGEN_API_KEY", kind === "api-key" ? "fixture-key" : ""); + vi.stubEnv("HYPERFRAMES_API_KEY", ""); + writeFileSync(join(project, "index.html"), VISIBLE_INDEX); + writeProjectLink(project, { projectId: "legacy", url: "https://hyperframes.dev/p/legacy" }); + writeTeamProject(project, { projectId: "legacy" }); + if (kind === "oauth") + await writeStore({ oauth: { access_token: "fixture-token" } }, join(config, "credentials")); + mockPublished({ + projectId: "legacy", + url: "https://hyperframes.dev/p/legacy", + updated: true, + }); + publishState.noticeRelease = "2020-01-01T00:00:00.000Z"; + try { + const run = () => + publishCommand.run?.({ args: { dir: project, yes: true, proxy: false } } as never); + if (kind === "oauth") { + await captureLog(run); + expect(publishState.publish).toHaveBeenCalledWith( + project, + expect.objectContaining({ + projectId: "legacy", + credential: expect.objectContaining({ type: "oauth" }), + }), + ); + } else { + await expect(run()).rejects.toMatchObject({ code: "legacy_publish_login_required" }); + expect(publishState.publish).not.toHaveBeenCalled(); + } + } finally { + publishState.noticeRelease = null; + vi.unstubAllEnvs(); + rmSync(project, { recursive: true, force: true }); + rmSync(config, { recursive: true, force: true }); + } + }, + ); +}); diff --git a/packages/cli/src/commands/publish.ts b/packages/cli/src/commands/publish.ts index 2584165245..6da11d3710 100644 --- a/packages/cli/src/commands/publish.ts +++ b/packages/cli/src/commands/publish.ts @@ -1,3 +1,4 @@ +import { assertLegacyPublishOwner, checkPublishTransition } from "../share/publishTransition.js"; import { join, posix, relative, resolve } from "node:path"; import { failCommand, setCommandExitCode } from "../utils/commandResult.js"; import { existsSync } from "node:fs"; @@ -61,7 +62,7 @@ export function parseUpdateTarget(value: string): string { export default defineCommand({ meta: { name: "publish", - description: "Upload the project to a stable URL (private by default)", + description: "Legacy source publishing; use share for new video reviews", }, args: { dir: { type: "positional", description: "Project directory", required: false }, @@ -96,6 +97,7 @@ export default defineCommand({ }, }, async run({ args }) { + const publishPhase = checkPublishTransition(args); if (args.yes !== true && isUnattended()) { clack.confirmationRequired("hyperframes publish", "Pass --yes to publish without asking."); } @@ -183,6 +185,8 @@ export default defineCommand({ return; } + assertLegacyPublishOwner(publishPhase, credential?.type === "oauth"); + // --update / --space only take effect for a login (an API-key publish is never owned). // Fail loudly rather than silently minting a fresh URL. if (updateTarget || spaceOverride) { diff --git a/packages/cli/src/commands/render.test.ts b/packages/cli/src/commands/render.test.ts index a6ee07cd02..4b79561f33 100644 --- a/packages/cli/src/commands/render.test.ts +++ b/packages/cli/src/commands/render.test.ts @@ -1437,6 +1437,35 @@ describe("renderLocal browser GPU config", () => { expect(consumeCommandResult().exitCode).toBe(0); }); + it("does not finalize the host command or mask a later upload failure when embedded", async () => { + const success = await import("../utils/render-success-state.js"); + const lifecycle = await import("../utils/commandResult.js"); + const exit = vi.spyOn(lifecycle, "scheduleCliExit"); + success._resetRenderSuccessForTests(); + const uploadFailure = new Error("upload failed after render"); + try { + const share = async () => { + await renderLocal(PROJECT_DIR, "/tmp/out.mp4", { + fps: { num: 30, den: 1 }, + quality: "standard", + format: "mp4", + gpu: false, + browserGpuMode: "software", + hdrMode: "auto", + quiet: true, + embedded: true, + exitAfterComplete: true, + }); + throw uploadFailure; + }; + await expect(share()).rejects.toBe(uploadFailure); + expect(exit).not.toHaveBeenCalled(); + expect(success.isRunDelivered()).toBe(false); + } finally { + success._resetRenderSuccessForTests(); + } + }); + it("still completes the render when the output registry cannot be written", async () => { const project = mkdtempSync(join(tmpdir(), "hf-render-unrecorded-")); mkdirSync(join(project, ".hyperframes")); diff --git a/packages/cli/src/commands/render.ts b/packages/cli/src/commands/render.ts index f81fc36b66..acc8a5bc46 100644 --- a/packages/cli/src/commands/render.ts +++ b/packages/cli/src/commands/render.ts @@ -585,6 +585,7 @@ export interface RenderOptions { variables?: Record; entryFile?: string; exitAfterComplete?: boolean; + embedded?: boolean; /** Output resolution preset; see `resolveDeviceScaleFactor` for constraints. */ outputResolution?: CanvasResolution; /** Whether the resolution names a tier without fixing an orientation. */ @@ -958,7 +959,7 @@ async function renderDocker( // AND committed the artifact. Mirror renderLocal's post-success guarantee // so any late throw here (telemetry flush, feedback prompt) cannot flip // the exit code. - markRenderSucceeded(); + if (!options.embedded) markRenderSucceeded(); await runPostRenderStepAsync("recordRenderSuccess", () => recordRenderSuccess(projectDir, outputPath, "completed", capture).then(() => {}), ); @@ -1000,7 +1001,7 @@ async function renderDocker( runPostRenderStep("warnIfWebmAlphaDropped", () => warnIfWebmAlphaDropped(outputPath, options.format, options.quiet), ); - if (options.exitAfterComplete) scheduleCliExit(); + if (options.exitAfterComplete && !options.embedded) scheduleCliExit(); return { renderTimeMs: elapsed }; } @@ -1269,7 +1270,7 @@ async function executeLocalRender( // point on, ANY thrown teardown error must not be allowed to override // the exit code. Field signal ts=1784169760 / ts=1784171150 / ts=1784172467 // (win32/x64, CLI 0.7.58): valid MP4 on disk, exited 1 with no error print. - markRenderSucceeded(); + if (!options.embedded) markRenderSucceeded(); await runPostRenderStepAsync("recordRenderSuccess", () => recordRenderSuccess( projectDir, @@ -1315,7 +1316,7 @@ async function executeLocalRender( }), ); } - if (options.exitAfterComplete) scheduleCliExit(); + if (options.exitAfterComplete && !options.embedded) scheduleCliExit(); const durationMs = job.perfSummary ? Math.round(job.perfSummary.compositionDurationSeconds * 1000) : undefined; @@ -1365,7 +1366,7 @@ async function renderRange(input: { } catch (error: unknown) { handleRenderError(error, options, input.startTime, input.cpu, false, ""); } - markRenderSucceeded(); + if (!options.embedded) markRenderSucceeded(); const elapsed = Date.now() - input.startTime; input.cpu.stop(); printRenderComplete({ @@ -1376,7 +1377,7 @@ async function renderRange(input: { quiet: options.quiet, format: options.format, }); - if (options.exitAfterComplete) scheduleCliExit(); + if (options.exitAfterComplete && !options.embedded) scheduleCliExit(); return { renderTimeMs: elapsed, ...reference, diff --git a/packages/cli/src/commands/render/execute.test.ts b/packages/cli/src/commands/render/execute.test.ts index 2dc5133eaf..a7d158874a 100644 --- a/packages/cli/src/commands/render/execute.test.ts +++ b/packages/cli/src/commands/render/execute.test.ts @@ -4,7 +4,12 @@ import { join } from "node:path"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import type { ReferenceBackground } from "@hyperframes/producer"; import { createRenderPlan } from "./plan.js"; -import { batchRowRenderOptions, executeRenderPlan, renderOptionsFromPlan } from "./execute.js"; +import { + batchRowRenderOptions, + executeRenderPlan, + renderOptionsFromPlan, + runRenderLint, +} from "./execute.js"; import * as manager from "../../browser/manager.js"; import * as system from "../../telemetry/system.js"; import { wantsDesktopHint, type SingleRenderResult } from "../render.js"; @@ -209,3 +214,17 @@ describe("the machine result line after a single render", () => { expect(await resultLines({ renderTimeMs: 5 }, { docker: true })).toEqual([]); }); }); + +it("preserves actionable strict lint diagnostics for embedded sharing", async () => { + const dir = mkdtempSync(join(tmpdir(), "hf-render-invalid-")); + try { + writeFileSync( + join(dir, "index.html"), + '
', + ); + const plan = createRenderPlan({ dir, strict: true, quiet: true }); + await expect(runRenderLint(plan)).rejects.toThrow(/Cannot render:.*missing_timeline_registry/); + } finally { + rmSync(dir, { recursive: true, force: true }); + } +}); diff --git a/packages/cli/src/commands/render/execute.ts b/packages/cli/src/commands/render/execute.ts index a654146a65..70b73420c7 100644 --- a/packages/cli/src/commands/render/execute.ts +++ b/packages/cli/src/commands/render/execute.ts @@ -14,7 +14,7 @@ import { } from "../../utils/lintProject.js"; import { normalizeErrorMessage } from "../../utils/errorMessage.js"; import { makeOutputFolder } from "../../utils/outputFolder.js"; -import { failCommand, setCommandExitCode } from "../../utils/commandResult.js"; +import { CliRuntimeError, failCommand, setCommandExitCode } from "../../utils/commandResult.js"; import { reportVariableIssues, resolveVariablesArg, @@ -303,8 +303,8 @@ export async function runRenderLint( ); presentRenderLintFindings(lintResult, plan.effectiveQuiet, plan.lintVerbose || willAbort); if (willAbort) { - presentRenderLintAbort(plan, lintResult, definitiveEntryMismatch); - failCommand(); + const message = presentRenderLintAbort(lintResult, definitiveEntryMismatch); + throw new CliRuntimeError(message, { presented: true }); } presentRenderLintContinuation(plan); } @@ -339,21 +339,17 @@ function presentRenderLintFindings( } function presentRenderLintAbort( - plan: RenderPlan, lintResult: ProjectLintResult, definitiveEntryMismatch: boolean, -): void { - const mode = plan.strictAll ? "--strict-all" : "--strict"; +): string { const counts = `${lintResult.totalErrors} error(s), ${lintResult.totalWarnings} warning(s)`; const findings = lintResult.results.flatMap((entry) => entry.result.findings); const first = findings.find((finding) => finding.severity === "error") ?? findings[0]; - errorBox( - definitiveEntryMismatch - ? "Aborting render because the default index.html entry is blank." - : `Aborting render due to lint issues in ${mode} mode: ${counts}`, - first ? `${first.code}: ${first.message}` : undefined, - "Run hyperframes lint for the full list.", - ); + const message = definitiveEntryMismatch + ? "Cannot render: the default index.html entry is blank." + : `Cannot render: ${counts}. ${first ? `${first.code}: ${first.message}` : "Fix the project lint issues."} Run hyperframes lint for details.`; + errorBox(message); + return message; } function presentRenderLintContinuation(plan: RenderPlan): void { diff --git a/packages/cli/src/commands/share.test.ts b/packages/cli/src/commands/share.test.ts new file mode 100644 index 0000000000..0307c03b13 --- /dev/null +++ b/packages/cli/src/commands/share.test.ts @@ -0,0 +1,166 @@ +import { SourceIgnoreError, ReviewFailed } from "@hyperframes/share"; +import { afterEach, beforeEach, expect, it, vi } from "vitest"; +import { runCommand } from "citty"; +import { consumeCommandResult } from "../utils/commandResult.js"; +const mocks = vi.hoisted(() => ({ + run: vi.fn(), + progress: undefined as undefined | ((value: { step: string; slow?: boolean } | null) => void), +})); +vi.mock("../utils/project.js", () => ({ resolveProjectOrThrow: () => ({ dir: "/project" }) })); +vi.mock("../share/service.js", () => ({ + createShareService: (_dir: string, progress: typeof mocks.progress) => { + mocks.progress = progress; + return { run: mocks.run }; + }, +})); +import command from "./share.js"; +beforeEach(() => { + consumeCommandResult(); + mocks.run.mockReset(); + mocks.run.mockResolvedValue({ + state: "failed", + ready: false, + url: null, + previousUrl: "https://hyperframes.dev/r/previous", + manageUrl: "https://hyperframes.dev/shares", + source: { at: "not_checked" }, + version: { failure: "This video can't be shared." }, + }); +}); +afterEach(() => { + vi.restoreAllMocks(); + consumeCommandResult(); +}); +it("returns a failure envelope and the previous ready URL for a failed status", async () => { + const out = vi.spyOn(console, "log").mockImplementation(() => {}); + await runCommand(command, { rawArgs: ["--status", "--json"] }); + expect(consumeCommandResult().exitCode).toBe(1); + expect(out).toHaveBeenCalledOnce(); + expect(JSON.parse(String(out.mock.calls[0]?.[0]))).toMatchObject({ + ok: false, + state: "failed", + ready: false, + url: null, + previousUrl: "https://hyperframes.dev/r/previous", + error: { code: "share_export_failed", message: "This video can't be shared." }, + }); +}); +it("reports the failed attempt on stderr without calling the previous version ready", async () => { + const out = vi.spyOn(console, "log").mockImplementation(() => {}); + const err = vi.spyOn(console, "error").mockImplementation(() => {}); + await runCommand(command, { rawArgs: ["--status"] }); + expect(consumeCommandResult().exitCode).toBe(1); + expect(err).toHaveBeenCalledWith("This video can't be shared."); + expect(out).toHaveBeenCalledWith("Previous shared version: https://hyperframes.dev/r/previous"); + expect(out.mock.calls.flat().join(" ")).not.toContain("still processing"); +}); +it("still opens management when the latest export failed", async () => { + const out = vi.spyOn(console, "log").mockImplementation(() => {}); + await runCommand(command, { rawArgs: ["--manage", "--json"] }); + expect(consumeCommandResult().exitCode).toBe(0); + expect(JSON.parse(String(out.mock.calls[0]?.[0])).ok).toBe(true); +}); + +it.each(["--status", "--manage", "--update"])( + "rejects ignored audience flags with %s", + async (action) => { + vi.spyOn(console, "log").mockImplementation(() => {}); + await runCommand(command, { rawArgs: [action, "--public", "--json"] }); + expect(consumeCommandResult().exitCode).toBe(2); + expect(mocks.run).not.toHaveBeenCalled(); + }, +); +it("says there is nothing to manage before a first share", async () => { + mocks.run.mockResolvedValue({ state: "not_shared" }); + const out = vi.spyOn(console, "log").mockImplementation(() => {}); + await runCommand(command, { rawArgs: ["--manage", "--json"] }); + expect(JSON.parse(String(out.mock.calls[0]?.[0]))).toMatchObject({ + ok: false, + error: { code: "not_shared" }, + }); +}); + +it("deduplicates progress and terminates each message before the friendly error", async () => { + const err = vi.spyOn(process.stderr, "write").mockImplementation(() => true); + const friendly = vi.spyOn(console, "error").mockImplementation(() => {}); + mocks.run.mockImplementation(async () => { + mocks.progress?.({ step: "preparing" }); + mocks.progress?.({ step: "preparing" }); + mocks.progress?.({ step: "uploading" }); + mocks.progress?.(null); + throw new Error("Sharing blocked."); + }); + await runCommand(command, { rawArgs: ["--private", "-y"] }); + expect(err.mock.calls.map(([message]) => message)).toEqual([ + "Sharing: preparing\n", + "Sharing: uploading\n", + ]); + expect(friendly).toHaveBeenCalledWith("Sharing blocked."); +}); + +it.each(["owner@example.com", "another@example.com"])( + "keeps the owner error code stable for %s", + async (owner) => { + mocks.run.mockRejectedValue(new ReviewFailed(403, `owner_signed_out:${owner}`)); + const out = vi.spyOn(console, "log").mockImplementation(() => {}); + await runCommand(command, { rawArgs: ["--status", "--json"] }); + expect(consumeCommandResult().exitCode).toBe(1); + expect(out).toHaveBeenCalledOnce(); + expect(JSON.parse(String(out.mock.calls[0]?.[0]))).toEqual({ + ok: false, + error: { + code: "owner_signed_out", + owner, + message: `This review belongs to ${owner}. Switch to that account to manage it.`, + }, + }); + }, +); + +it("reports an unchanged update in human and JSON output", async () => { + mocks.run.mockResolvedValue({ + state: "ready", + ready: true, + upToDate: true, + source: { at: "ready" }, + }); + const out = vi.spyOn(console, "log").mockImplementation(() => {}); + await runCommand(command, { rawArgs: ["--update"] }); + expect(out).toHaveBeenCalledWith("Already up to date."); + await runCommand(command, { rawArgs: ["--update", "--json"] }); + expect(JSON.parse(String(out.mock.calls.at(-1)?.[0]))).toMatchObject({ + ok: true, + upToDate: true, + }); +}); + +it("reports a specific code for an invalid ignore file", async () => { + mocks.run.mockRejectedValue(new SourceIgnoreError("Invalid ignore pattern")); + const out = vi.spyOn(console, "log").mockImplementation(() => {}); + await runCommand(command, { rawArgs: ["--public", "--json"] }); + expect(JSON.parse(String(out.mock.calls[0]?.[0]))).toMatchObject({ + ok: false, + error: { code: "invalid_source_ignore" }, + }); +}); + +it.each([[[]], [["--json"]], [["--yes"]], [["--video-only"]]])( + "defaults to video-only without source consent %j", + async (flags) => { + vi.spyOn(console, "log").mockImplementation(() => {}); + vi.spyOn(console, "error").mockImplementation(() => {}); + await runCommand(command, { rawArgs: ["--public", ...flags] }); + expect(mocks.run).toHaveBeenCalledWith(expect.objectContaining({ includeSource: false })); + }, +); +it("accepts explicit source inclusion and rejects conflicting choices", async () => { + vi.spyOn(console, "log").mockImplementation(() => {}); + await runCommand(command, { rawArgs: ["--public", "--include-source", "--json"] }); + expect(mocks.run).toHaveBeenCalledWith(expect.objectContaining({ includeSource: true })); + mocks.run.mockClear(); + await runCommand(command, { + rawArgs: ["--public", "--include-source", "--video-only", "--json"], + }); + expect(consumeCommandResult().exitCode).toBe(2); + expect(mocks.run).not.toHaveBeenCalled(); +}); diff --git a/packages/cli/src/commands/share.ts b/packages/cli/src/commands/share.ts new file mode 100644 index 0000000000..678731d59a --- /dev/null +++ b/packages/cli/src/commands/share.ts @@ -0,0 +1,233 @@ +import { defineCommand } from "../utils/defineCommand.js"; +import { resolveProjectOrThrow } from "../utils/project.js"; +import { CliUsageError, setCommandExitCode } from "../utils/commandResult.js"; +import { isUnattended } from "../utils/attendedTerminal.js"; +import * as prompts from "../ui/prompts.js"; +import { + createShareService, + type ShareAction, + type ShareState, + type ShareService, +} from "../share/service.js"; +import { shareError } from "../share/errors.js"; +import { jsonFailure } from "../utils/jsonError.js"; +import type { Example } from "./_examples.js"; + +export const examples: Example[] = [ + ["Create a review anyone with its link can open", "hyperframes share --public"], + ["Add the current video as a new version", "hyperframes share --update"], + ["Read the existing share without uploading edits", "hyperframes share --status --json"], + ["Open sharing settings on the web", "hyperframes share --manage"], +]; + +export default defineCommand({ + meta: { + name: "share", + description: "Share a rendered video for review, using the same sharing as Desktop", + }, + args: { + dir: { type: "positional", description: "Project directory", required: false }, + public: { + type: "boolean", + description: "Explicitly allow anyone with the link on first share", + }, + team: { type: "boolean", description: "Share with workspace members (paid plan)" }, + "invite-only": { type: "boolean", description: "Share with invited people only (paid plan)" }, + private: { type: "boolean", description: "First share with private access" }, + update: { + type: "boolean", + description: "Render and add a new video version to the existing share", + }, + "include-source": { + type: "boolean", + description: "Upload editable project files, including unused and Git-ignored files", + }, + "video-only": { + type: "boolean", + description: "Share only the rendered video, without editable source", + }, + status: { type: "boolean", description: "Read status without rendering or uploading" }, + manage: { type: "boolean", description: "Open this share's web management page" }, + space: { type: "string", description: "Owning workspace for a new share" }, + "wait-seconds": { + type: "string", + description: "Wait for processing (1–1800 seconds)", + default: "300", + }, + json: { type: "boolean", description: "Emit a machine-readable result" }, + yes: { + type: "boolean", + alias: "y", + description: "Do not prompt; an explicit first-share audience is still required", + }, + }, + async run({ args }) { + try { + const input = parseInput(args); + const project = resolveProjectOrThrow(args.dir, { searchParents: true }); + let lastProgress = ""; + const service: ShareService = createShareService(project.dir, (value) => { + if (!value || args.json) return; + const message = `Sharing: ${value.step}${value.slow ? " (still processing)" : ""}`; + if (message !== lastProgress) process.stderr.write(`${message}\n`); + lastProgress = message; + }); + await chooseAudience(input, args, service); + const result = await service.run(input); + await presentResult(result, input, Boolean(args.json)); + } catch (error) { + const failure = shareError(error); + if (args.json) + console.log( + JSON.stringify({ ...jsonFailure(failure.code, failure.message), error: failure }), + ); + else console.error(failure.message); + setCommandExitCode(error instanceof CliUsageError ? 2 : 1); + } + }, +}); + +interface ShareArgs { + public?: boolean; + team?: boolean; + "invite-only"?: boolean; + private?: boolean; + update?: boolean; + status?: boolean; + manage?: boolean; + yes?: boolean; + json?: boolean; + "wait-seconds"?: string; + space?: string; + "video-only"?: boolean; + "include-source"?: boolean; +} +function parseInput(args: ShareArgs): ShareAction { + const waitSeconds = Number(args["wait-seconds"]); + if (!Number.isInteger(waitSeconds) || waitSeconds < 1 || waitSeconds > 1800) + throw new CliUsageError("--wait-seconds must be an integer from 1 to 1800."); + if ([args.update, args.status, args.manage].filter(Boolean).length > 1) + throw new CliUsageError("Choose only one of --update, --status or --manage."); + const audience = requestedAudience(args); + const action = args.status ? "status" : args.manage ? "manage" : args.update ? "update" : "share"; + + validateActionOptions(action, audience, args); + return { + action, + audience, + space: args.space, + waitSeconds, + videoOnly: args["video-only"], + includeSource: args["include-source"] === true, + }; +} + +function validateActionOptions( + action: ShareAction["action"], + audience: ShareAction["audience"], + args: ShareArgs, +) { + validateSourceOptions(args); + if (action !== "share" && audience) + throw new CliUsageError( + "Use audience flags with hyperframes share, without --update, --status or --manage.", + ); + if ( + (action === "status" || action === "manage") && + (args.space || args["video-only"] || args["include-source"]) + ) + throw new CliUsageError( + "--space, --include-source and --video-only cannot be used with --status or --manage.", + ); +} + +function validateSourceOptions(args: ShareArgs) { + if (args["include-source"] && args["video-only"]) + throw new CliUsageError("Choose only one of --include-source or --video-only."); +} + +function requestedAudience(args: ShareArgs) { + const audiences: NonNullable[] = []; + if (args.public) audiences.push("public"); + if (args.team) audiences.push("team"); + if (args["invite-only"]) audiences.push("invite"); + if (args.private) audiences.push("private"); + if (audiences.length > 1) throw new CliUsageError("Choose one audience."); + return audiences[0]; +} + +function shouldPrompt(input: ShareAction, args: ShareArgs) { + return input.action === "share" && !input.audience && !args.yes && !args.json && !isUnattended(); +} + +async function chooseAudience(input: ShareAction, args: ShareArgs, service: ShareService) { + if (!shouldPrompt(input, args)) return; + if ((await service.status()).share) return; + const selected = await prompts.select({ + message: "Who should be able to open this review?", + options: [ + { value: "public", label: "Anyone with the link (available on Free)" }, + { value: "team", label: "Workspace members" }, + { value: "invite", label: "Invited people" }, + { value: "private", label: "Only me" }, + ], + }); + if (prompts.isCancel(selected)) throw new CliUsageError("Sharing cancelled."); + if ( + selected === "public" || + selected === "team" || + selected === "invite" || + selected === "private" + ) + input.audience = selected; +} + +async function presentResult(result: ShareState, input: ShareAction, json: boolean) { + if (input.action === "manage" && result.state === "not_shared") + throw new CliUsageError("There is no share to manage yet. Create a share first.", { + code: "not_shared", + }); + if (!json && !result.upToDate && result.source.at === "video_only") + console.error(sourceNotice(result.source.reason)); + if (result.state === "failed" && input.action !== "manage") { + presentFailure(result, json); + return; + } + await presentSuccessfulResult(result, input, json); +} + +async function presentSuccessfulResult(result: ShareState, input: ShareAction, json: boolean) { + if (json) console.log(JSON.stringify({ ok: true, ...result })); + else if (result.activity) + console.log( + `Sharing: ${result.activity.step.replaceAll("_", " ")}. Run hyperframes share --status to check progress.`, + ); + else if (result.upToDate) console.log("Already up to date."); + else if (input.action === "manage") { + console.log(result.manageUrl); + if (!isUnattended()) await (await import("open")).default(result.manageUrl); + } else if (result.ready) console.log(`Shared video ready: ${result.url}`); + else if (result.state === "not_shared") console.log("This project has not been shared yet."); + else if (result.state === "link_off") + console.log("This share's link is off. Run hyperframes share --manage to turn it on."); + else console.log("Your video is still processing. Run hyperframes share --status to check it."); +} + +function presentFailure(result: ShareState, json: boolean) { + const message = result.version.failure ?? "The shared video could not be processed."; + if (json) + console.log(JSON.stringify({ ...result, ...jsonFailure("share_export_failed", message) })); + else { + console.error(message); + if (result.previousUrl) console.log(`Previous shared version: ${result.previousUrl}`); + } + setCommandExitCode(1); +} + +function sourceNotice(reason: string): string { + if (reason === "source_plan_required") + return "Your video is shared without editable project files. Upgrade to Pro to include source files: https://hyperframes.studio/pricing"; + if (reason === "requested") + return "Sharing the video without editable project files. Use --include-source to upload project files."; + return "Sharing the video without editable project files; source sharing is unavailable in this workspace."; +} diff --git a/packages/cli/src/commands/upgrade.ts b/packages/cli/src/commands/upgrade.ts index 31001a8805..2b1923c351 100644 --- a/packages/cli/src/commands/upgrade.ts +++ b/packages/cli/src/commands/upgrade.ts @@ -19,6 +19,7 @@ export const examples: Example[] = [ import { VERSION } from "../version.js"; import { checkForUpdate, + updateChannel, NO_UPDATE_NOTICE, withMeta, isSafeVersion, @@ -144,7 +145,7 @@ function applyUpgrade(result: UpdateCheckResult, autoYes: boolean): void { runDetectedInstall(plan.invocation, plan.displayCmd, result.latest); } -const NPX_LATEST = "npx hyperframes@latest"; +const NPX_LATEST = `npx hyperframes@${updateChannel()}`; /** * How `upgrade --yes` moves this install to `latest`: the detected manager's argv, or, for an diff --git a/packages/cli/src/help.ts b/packages/cli/src/help.ts index 2a0729b37d..971fddbb47 100644 --- a/packages/cli/src/help.ts +++ b/packages/cli/src/help.ts @@ -26,6 +26,7 @@ const GROUPS: Group[] = [ ["catalog", "Browse and install blocks and components"], ["preview", "Start the studio for previewing compositions"], ["present", "Open a slideshow deck in presenter mode (with audience sync)"], + ["share", "Share a rendered video for review"], ["publish", "Upload a project to a stable URL (private by default)"], ["render", "Render a composition to MP4 or WebM"], ["open", "Open a project in the HyperFrames desktop app"], diff --git a/packages/cli/src/server/shareBoundary.ts b/packages/cli/src/server/shareBoundary.ts new file mode 100644 index 0000000000..9765927696 --- /dev/null +++ b/packages/cli/src/server/shareBoundary.ts @@ -0,0 +1,31 @@ +import { randomBytes, timingSafeEqual } from "node:crypto"; + +export function localShareRequestAllowed(request: Request): boolean { + const host = request.headers.get("host"); + if (!host || request.headers.get("sec-fetch-site") !== "same-origin") return false; + try { + const local = new URL(`http://${host}`); + if (local.host !== host || !["localhost", "127.0.0.1", "[::1]"].includes(local.hostname)) + return false; + const origin = request.headers.get("origin"); + if (origin !== null) return origin === local.origin; + const referer = request.headers.get("referer"); + return referer !== null && new URL(referer).origin === local.origin; + } catch { + return false; + } +} + +export function createShareCsrf() { + const token = randomBytes(32).toString("base64url"); + return { + token, + accepts(value: string | null) { + return ( + value !== null && + Buffer.byteLength(value) === Buffer.byteLength(token) && + timingSafeEqual(Buffer.from(value), Buffer.from(token)) + ); + }, + }; +} diff --git a/packages/cli/src/server/shareEvents.ts b/packages/cli/src/server/shareEvents.ts new file mode 100644 index 0000000000..e3a650458e --- /dev/null +++ b/packages/cli/src/server/shareEvents.ts @@ -0,0 +1,12 @@ +import type { LocalShareInteraction } from "@hyperframes/studio-server"; + +export function shareEventInput(value: unknown): LocalShareInteraction | null { + if (typeof value !== "object" || value === null || Array.isArray(value)) return null; + if (Object.keys(value).length !== 2 || !("event" in value)) return null; + if (value.event === "share_link_copied" && "via" in value && value.via === "copy") + return { event: value.event, via: "copy" }; + if (value.event !== "share_opened" || !("link" in value)) return null; + const link = ["none", "live", "changed"] as const; + const chosen = link.find((item) => item === value.link); + return chosen ? { event: value.event, link: chosen } : null; +} diff --git a/packages/cli/src/server/shareFreshness.test.ts b/packages/cli/src/server/shareFreshness.test.ts new file mode 100644 index 0000000000..d8e6d5db06 --- /dev/null +++ b/packages/cli/src/server/shareFreshness.test.ts @@ -0,0 +1,75 @@ +import { mkdtempSync, mkdirSync, realpathSync, rmSync, writeFileSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { dirname, join } from "node:path"; +import { afterEach, expect, it } from "vitest"; +import { shareContentFingerprint } from "../share/render.js"; +import type { ShareState } from "../share/service.js"; +import { presentPortableShare } from "./shareFreshness.js"; +const dirs: string[] = []; +afterEach(() => { + for (const dir of dirs.splice(0)) rmSync(dir, { recursive: true, force: true }); +}); +const state: ShareState = { + upToDate: false, + share: { + projectId: "project", + url: "https://hyperframes.dev/r/test", + access: "private", + role: "viewer", + commentsOn: true, + space: null, + elsewhere: false, + held: false, + }, + source: { + at: "ready", + snapshot: { space_id: "space", composition_id: "composition", snapshot_id: "snapshot" }, + }, + version: { + last: { exportedAt: "2026-11-06T00:00:00Z", current: true }, + source: "ready", + exporting: null, + failure: null, + }, + pending: null, + state: "ready", + ready: true, + url: "https://hyperframes.dev/r/test", + previousUrl: null, + manageUrl: "https://hyperframes.dev/shares", +}; +it.each([".media/voice.mp3", ".hyperframes/studio-manual-edits.json"])( + "detects %s edits even while the Desktop watcher still says current", + async (path) => { + const dir = realpathSync(mkdtempSync(join(tmpdir(), "hf-studio-freshness-"))); + dirs.push(dir); + writeFileSync(join(dir, "index.html"), ''); + mkdirSync(dirname(join(dir, path)), { recursive: true }); + writeFileSync(join(dir, path), "original"); + const contentFingerprint = (await shareContentFingerprint(dir))!; + let checksum = "uploaded-video"; + const deps = { + render: () => ({ + id: "render", + path: "video.mp4", + fingerprint: "watcher", + contentFingerprint, + }), + fingerprint: shareContentFingerprint, + uploaded: async () => ({ + projectId: "project", + exportedAt: "2026-11-06T00:00:00Z", + fingerprint: "watcher", + versionId: "version", + checksum: "uploaded-video", + }), + checksum: async () => checksum, + }; + expect((await presentPortableShare(dir, state, deps)).changed).toBeNull(); + writeFileSync(join(dir, path), "changed"); + expect((await presentPortableShare(dir, state, deps)).changed).toBe(true); + // Another command replaced the render pointer while the original video uploaded. + checksum = "different-video"; + expect((await presentPortableShare(dir, state, deps)).changed).toBeNull(); + }, +); diff --git a/packages/cli/src/server/shareFreshness.ts b/packages/cli/src/server/shareFreshness.ts new file mode 100644 index 0000000000..ff2d27a524 --- /dev/null +++ b/packages/cli/src/server/shareFreshness.ts @@ -0,0 +1,44 @@ +import { fileSha256Base64, versionOnPage } from "@hyperframes/share"; +import type { ShareState } from "../share/service.js"; +import { latestShareRender, shareContentFingerprint } from "../share/render.js"; +import { presentShare } from "./sharePresentation.js"; + +const dependencies = { + render: latestShareRender, + fingerprint: shareContentFingerprint, + uploaded: versionOnPage, + checksum: fileSha256Base64, +}; + +export async function presentPortableShare( + projectDir: string, + state: ShareState, + deps = dependencies, +) { + const result = presentShare(state); + try { + const render = deps.render(projectDir); + if (!render?.contentFingerprint) return result; + const last = await deps.uploaded(projectDir); + if (!matchesUpload(state, last)) return result; + if ((await deps.checksum(render.path)) !== last.checksum) return result; + const current = await deps.fingerprint(projectDir); + // Equal video bytes do not prove equal source inputs (for example metadata-only edits). + // Until exports persist the portable digest, only report known changes, never "clean". + result.changed = current && current !== render.contentFingerprint ? true : null; + } catch { + // Missing local artifacts cannot establish freshness of the published video. + } + return result; +} + +function matchesUpload( + state: ShareState, + last: Awaited>, +): last is NonNullable { + return Boolean( + last?.checksum && + last.projectId === state.share?.projectId && + last.exportedAt === state.version.last?.exportedAt, + ); +} diff --git a/packages/cli/src/server/sharePresentation.test.ts b/packages/cli/src/server/sharePresentation.test.ts new file mode 100644 index 0000000000..987bae7334 --- /dev/null +++ b/packages/cli/src/server/sharePresentation.test.ts @@ -0,0 +1,22 @@ +import { expect, it, vi } from "vitest"; +import { presentSpaces } from "./sharePresentation.js"; +vi.mock("../share/auth.js", () => ({ shareSite: () => "https://hyperframes.dev" })); + +it.each(["free", "subscribed", undefined] as const)( + "preserves authoritative plan %s for the upgrade offer", + (plan) => { + const space = { + space_id: "space", + name: "Workspace", + kind: "personal", + bound: true, + can_create_review: true, + review_entitlements: plan + ? { plan, project_limit: plan === "free" ? 5 : null, projects_used_up_to_limit: 2 } + : null, + } as Parameters[0][number]; + const [result] = presentSpaces([space]); + expect(result?.plan).toBe(plan ?? null); + expect(result?.upgradeUrl).toBe(plan === "free" ? "https://hyperframes.dev/pricing" : null); + }, +); diff --git a/packages/cli/src/server/sharePresentation.ts b/packages/cli/src/server/sharePresentation.ts new file mode 100644 index 0000000000..614e6ad554 --- /dev/null +++ b/packages/cli/src/server/sharePresentation.ts @@ -0,0 +1,61 @@ +import type { LocalShareSpace, LocalShareState } from "@hyperframes/studio-server"; +import { shareSite } from "../share/auth.js"; +import type { ShareService, ShareState } from "../share/service.js"; + +export function presentShare(value: ShareState): LocalShareState { + const held = + value.share?.held || + value.share?.takedown || + value.share?.sharingState?.state === "subscription_required"; + return { + upToDate: value.upToDate, + updated: value.updated, + state: presentedState(value, Boolean(held)), + url: held ? null : (value.url ?? value.previousUrl), + failure: value.state === "failed" ? value.version.failure : null, + hasReadyVersion: value.ready || Boolean(value.previousUrl), + manageUrl: value.manageUrl, + // Desktop's watcher does not cover every portable render input. + changed: knownChanges(value), + audience: value.share?.access ?? null, + spaceId: value.share?.space?.id ?? null, + source: value.source.at, + }; +} + +export function presentSpaces( + spaces: Awaited>, +): LocalShareSpace[] { + return spaces.map((space) => ({ + id: space.space_id, + name: space.name || (space.kind === "personal" ? "Personal workspace" : space.space_id), + bound: space.bound === true, + canCreate: space.can_create_review, + ...planOffer(space.review_entitlements), + audiences: [ + "private", + ...(space.review_entitlements?.allowed_collaborative_access_modes ?? []), + ], + used: space.review_entitlements?.projects_used_up_to_limit ?? null, + limit: space.review_entitlements?.project_limit ?? null, + })); +} + +function knownChanges(value: ShareState): boolean | null { + if (!value.share) return false; + return value.version.last && !value.version.last.current ? true : null; +} + +function planOffer( + entitlements: Awaited>[number]["review_entitlements"], +) { + const plan = entitlements?.plan ?? null; + return { plan, upgradeUrl: plan === "free" ? `${shareSite()}/pricing` : null }; +} + +function presentedState(value: ShareState, held: boolean): LocalShareState["state"] { + if (held) return "unavailable"; + if (value.state === "failed" || value.state === "not_shared" || value.state === "link_off") + return value.state; + return value.ready ? "ready" : "processing"; +} diff --git a/packages/cli/src/server/shareRoutes.test.ts b/packages/cli/src/server/shareRoutes.test.ts new file mode 100644 index 0000000000..e8a6916d33 --- /dev/null +++ b/packages/cli/src/server/shareRoutes.test.ts @@ -0,0 +1,441 @@ +import { describe, expect, it, vi } from "vitest"; +import { Hono } from "hono"; +import type { ShareService, ShareState } from "../share/service.js"; +import { mountShareRoutes } from "./shareRoutes.js"; +import { ReviewFailed } from "@hyperframes/share"; +import { AuthError } from "../auth/errors.js"; +import { createShareCsrf, localShareRequestAllowed } from "./shareBoundary.js"; + +const state: ShareState = { + upToDate: false, + source: { at: "not_checked" }, + share: null, + version: { last: null, source: "none", exporting: null, failure: null }, + pending: null, + state: "not_shared", + ready: false, + url: null, + previousUrl: null, + manageUrl: "https://hyperframes.dev/shares", +}; +function fixture() { + const service: ShareService = { + checkSession: vi.fn(async () => ({ + token: "secret", + owner: "owner", + heygen: "https://heygen.com", + heygenApi: "https://api.heygen.com", + })), + status: vi.fn(async () => state), + run: vi.fn(async () => state), + spaces: vi.fn(async () => []), + capabilities: vi.fn(async () => ({ versionSharing: true, shareFiles: false })), + setAccess: vi.fn(async () => state), + linkOff: vi.fn(async () => state), + linkOn: vi.fn(async () => state), + }; + const app = new Hono(); + const create = vi.fn(async () => service); + const login = vi.fn(async () => {}); + const track = vi.fn(); + mountShareRoutes(app, "/fixed/project", create, login, track); + return { app, service, create, login, track }; +} +const headers = { + host: "localhost:3000", + origin: "http://localhost:3000", + "sec-fetch-site": "same-origin", +}; +async function token(app: Hono) { + const response = await app.request("/api/share/bootstrap", { headers }); + expect(response.status).toBe(200); + const body: unknown = await response.json(); + if (!body || typeof body !== "object" || !("csrf" in body) || typeof body.csrf !== "string") + throw new Error("missing token"); + return body.csrf; +} +function request(app: Hono, path: string, csrf: string, body?: unknown) { + return app.request(`/api/share/${path}`, { + method: body ? "POST" : "GET", + headers: { ...headers, "x-hyperframes-share-csrf": csrf, "content-type": "application/json" }, + ...(body ? { body: JSON.stringify(body) } : {}), + }); +} +describe("local share boundary", () => { + it.each([ + { ...headers, host: "evil.example" }, + { ...headers, origin: "https://evil.example" }, + { ...headers, "sec-fetch-site": "cross-site" }, + { ...headers, "sec-fetch-site": "none" }, + { host: headers.host }, + { ...headers, host: "192.168.1.2:3000", origin: "http://192.168.1.2:3000" }, + { ...headers, host: "localhost:3000@evil.example" }, + ])("denies foreign, LAN and missing-origin requests before authentication %j", async (input) => { + const { app, create } = fixture(); + expect((await app.request("/api/share/bootstrap", { headers: input })).status).toBe(403); + expect(create).not.toHaveBeenCalled(); + }); + it("allows same-origin browser GET Referer and IPv6 loopback", () => { + expect( + localShareRequestAllowed( + new Request("http://localhost:3000/api/share/bootstrap", { + headers: { + host: headers.host, + referer: "http://localhost:3000/?project=x", + "sec-fetch-site": "same-origin", + }, + }), + ), + ).toBe(true); + expect( + localShareRequestAllowed( + new Request("http://[::1]:3000/api/share/bootstrap", { + headers: { + host: "[::1]:3000", + origin: "http://[::1]:3000", + "sec-fetch-site": "same-origin", + }, + }), + ), + ).toBe(true); + }); + it("guards reads and mutations with a separate token for each server", async () => { + const one = fixture(), + two = fixture(); + const csrf = await token(one.app); + for (const [path, body] of [ + ["snapshot", undefined], + ["jobs/x", undefined], + ["actions", { action: "off" }], + ] as const) { + expect((await request(one.app, path, "", body)).status).toBe(403); + expect((await request(two.app, path, csrf, body)).status).toBe(403); + } + expect((await request(one.app, "snapshot", csrf)).status).toBe(200); + expect(one.create).toHaveBeenCalledWith("/fixed/project", expect.any(Function)); + expect(two.create).not.toHaveBeenCalled(); + const guard = createShareCsrf(); + expect(guard.accepts("💜".repeat(43))).toBe(false); + }); +}); +it("requires explicit first audience and refuses arbitrary project paths", async () => { + const { app, service } = fixture(); + const csrf = await token(app); + for (const body of [ + { action: "share" }, + { action: "share", audience: "public", projectPath: "/other" }, + { action: "share", audience: "public", space: "../other" }, + { action: "remove" }, + ]) { + expect((await request(app, "actions", csrf, body)).status).toBe(400); + } + expect(service.run).not.toHaveBeenCalled(); +}); +it("keeps one server job alive after the request completes and recovers it on reopening", async () => { + const { app, service } = fixture(); + const csrf = await token(app); + let finish: (value: ShareState) => void = () => {}; + vi.mocked(service.run).mockImplementation( + () => + new Promise((resolve) => { + finish = resolve; + }), + ); + const response = await request(app, "actions", csrf, { + action: "share", + audience: "private", + space: "team1", + videoOnly: undefined, + }); + expect(response.status).toBe(202); + const started = await response.json(); + expect(started.state).toBe("running"); + expect((await request(app, "actions", csrf, { action: "update" })).status).toBe(409); + expect((await (await request(app, "snapshot", csrf)).json()).job.id).toBe(started.id); + finish(state); + await vi.waitFor(async () => + expect((await (await request(app, `jobs/${started.id}`, csrf)).json()).state).toBe("done"), + ); + expect(service.run).toHaveBeenCalledOnce(); + expect(service.run).toHaveBeenCalledWith({ + action: "share", + audience: "private", + space: "team1", + videoOnly: undefined, + }); +}); +it("returns failed jobs without changing access or retrying automatically", async () => { + const { app, service } = fixture(); + const csrf = await token(app); + vi.mocked(service.run).mockRejectedValue(new Error("Render failed")); + await request(app, "actions", csrf, { action: "update" }); + await vi.waitFor(async () => + expect((await (await request(app, "snapshot", csrf)).json()).job.error.message).toBe( + "Render failed", + ), + ); + expect(service.linkOn).not.toHaveBeenCalled(); + expect(service.setAccess).not.toHaveBeenCalled(); +}); +it.each(["off", "on", "access"] as const)( + "routes explicit %s management without starting an upload", + async (action) => { + const { app, service } = fixture(); + const csrf = await token(app); + await request(app, "actions", csrf, { + action, + ...(action === "access" ? { audience: "invite" } : {}), + }); + await vi.waitFor(() => + expect( + action === "off" ? service.linkOff : action === "on" ? service.linkOn : service.setAccess, + ).toHaveBeenCalledOnce(), + ); + expect(service.run).not.toHaveBeenCalled(); + }, +); + +it("runs one browser sign-in job without returning credentials and verifies identity afterward", async () => { + const { app, service, login, create } = fixture(); + const csrf = await token(app); + vi.mocked(service.status).mockRejectedValue(new AuthError("UNAUTHENTICATED", "Sign in first")); + let finish = () => {}; + login.mockImplementation( + () => + new Promise((resolve) => { + finish = resolve; + }), + ); + const started = await (await request(app, "actions", csrf, { action: "login" })).json(); + expect(started.step).toBe("signing_in"); + expect((await request(app, "actions", csrf, { action: "login" })).status).toBe(409); + const reopening = await (await request(app, "snapshot", csrf)).json(); + expect(reopening.code).toBe("unauthenticated"); + expect(reopening.job.id).toBe(started.id); + vi.mocked(service.status).mockResolvedValue(state); + finish(); + await vi.waitFor(async () => + expect((await (await request(app, `jobs/${started.id}`, csrf)).json()).state).toBe("done"), + ); + expect(login).toHaveBeenCalledOnce(); + expect(create).toHaveBeenCalledTimes(2); + const complete = await (await request(app, "snapshot", csrf)).json(); + expect(JSON.stringify(complete)).not.toMatch(/access_token|refresh_token|authorize_url/); + expect(service.run).not.toHaveBeenCalled(); +}); +it("passes explicit video-only recovery and rejects nonboolean bypass values", async () => { + const { app, service } = fixture(); + const csrf = await token(app); + expect( + (await request(app, "actions", csrf, { action: "update", videoOnly: "true" })).status, + ).toBe(400); + await request(app, "actions", csrf, { action: "update", videoOnly: true }); + await vi.waitFor(() => + expect(service.run).toHaveBeenCalledWith({ + action: "update", + audience: undefined, + space: undefined, + videoOnly: true, + }), + ); +}); + +it("requires the same boundary for events and never forwards arbitrary properties", async () => { + const { app, track } = fixture(); + const csrf = await token(app); + expect((await request(app, "events", "", { event: "share_opened", link: "live" })).status).toBe( + 403, + ); + expect( + (await request(app, "events", csrf, { event: "share_opened", link: "live", url: "secret" })) + .status, + ).toBe(400); + expect( + (await request(app, "events", csrf, { event: "share_link_copied", via: "update" })).status, + ).toBe(400); + expect( + (await request(app, "events", csrf, { event: "share_opened", link: "changed" })).status, + ).toBe(204); + expect(track).toHaveBeenCalledExactlyOnceWith( + { event: "share_opened", link: "changed" }, + "local_studio", + ); +}); + +it("rejects stale actions and job reads after logout without returning the previous result", async () => { + const { app, service } = fixture(); + const csrf = await token(app); + const started = await (await request(app, "actions", csrf, { action: "update" })).json(); + await vi.waitFor(async () => + expect((await (await request(app, `jobs/${started.id}`, csrf)).json()).state).toBe("done"), + ); + const signedOut = new AuthError("UNAUTHENTICATED", "Sign in first"); + vi.mocked(service.checkSession).mockRejectedValue(signedOut); + vi.mocked(service.status).mockRejectedValue(signedOut); + for (const [path, action] of [ + [`jobs/${started.id}`, undefined], + ["snapshot", undefined], + ["actions", { action: "off" }], + ] as const) { + const response = await request(app, path, csrf, action); + expect(response.status).toBe(400); + const body = await response.json(); + expect(body.code).toBe("unauthenticated"); + expect(body.result).toBeUndefined(); + expect(body.job ?? null).toBeNull(); + } + expect(service.linkOff).not.toHaveBeenCalled(); +}); + +it("does not reveal another account's completed job to a newly opened panel", async () => { + const { app, service } = fixture(); + const first = await token(app); + const started = await (await request(app, "actions", first, { action: "update" })).json(); + await vi.waitFor(async () => + expect((await (await request(app, `jobs/${started.id}`, first)).json()).state).toBe("done"), + ); + vi.mocked(service.checkSession).mockResolvedValue({ + token: "other-secret", + owner: "other", + heygen: "https://heygen.com", + heygenApi: "https://api.heygen.com", + }); + const second = await token(app); + expect(second).not.toBe(first); + expect((await request(app, `jobs/${started.id}`, second)).status).toBe(404); + expect((await (await request(app, "snapshot", second)).json()).job).toBeNull(); +}); + +it("serializes actions even when concurrent requests await identity verification", async () => { + const { app, service } = fixture(); + const csrf = await token(app); + let verify = () => {}; + const barrier = new Promise((resolve) => { + verify = resolve; + }); + vi.mocked(service.checkSession).mockImplementation(async () => { + await barrier; + return { + token: "secret", + owner: "owner", + heygen: "https://heygen.com", + heygenApi: "https://api.heygen.com", + }; + }); + let finish = () => {}; + vi.mocked(service.run).mockImplementation( + () => + new Promise((resolve) => { + finish = () => resolve(state); + }), + ); + const requests = [ + request(app, "actions", csrf, { action: "update" }), + request(app, "actions", csrf, { action: "update" }), + ]; + await vi.waitFor(() => expect(service.checkSession).toHaveBeenCalledTimes(2)); + verify(); + expect((await Promise.all(requests)).map((response) => response.status).sort()).toEqual([ + 202, 409, + ]); + expect(service.run).toHaveBeenCalledOnce(); + finish(); +}); + +it("withholds an in-flight result when the account changes before completion", async () => { + const { app, service } = fixture(); + const csrf = await token(app); + let finish = () => {}; + vi.mocked(service.run).mockImplementation( + () => + new Promise((resolve) => { + finish = () => resolve(state); + }), + ); + const started = await (await request(app, "actions", csrf, { action: "update" })).json(); + vi.mocked(service.checkSession).mockRejectedValue( + new AuthError("LOGIN_CHANGED", "Login changed"), + ); + finish(); + await vi.waitFor(async () => { + const response = await request(app, `jobs/${started.id}`, csrf); + expect(response.status).toBe(400); + expect(await response.json()).toEqual({ code: "login_changed", message: "Login changed" }); + }); +}); + +it.each(["login_required", "", "invalid_token"])( + "exposes browser sign-in recovery for a review 401 (%s)", + async (reason) => { + const { app, service, login } = fixture(); + const csrf = await token(app); + vi.mocked(service.status).mockRejectedValue(new ReviewFailed(401, reason)); + vi.mocked(service.checkSession).mockRejectedValueOnce( + new AuthError("LOGIN_EXPIRED", "Your sign-in has expired. Sign in again."), + ); + const response = await request(app, "snapshot", csrf); + expect(response.status).toBe(400); + expect(await response.json()).toMatchObject({ + code: "login_expired", + message: expect.stringContaining("Sign in again"), + }); + expect(login).not.toHaveBeenCalled(); + vi.mocked(service.status).mockResolvedValue(state); + const started = await (await request(app, "actions", csrf, { action: "login" })).json(); + await vi.waitFor(async () => + expect((await (await request(app, `jobs/${started.id}`, csrf)).json()).state).toBe("done"), + ); + expect(login).toHaveBeenCalledOnce(); + }, +); + +it("preserves admission failures instead of offering an expired-session retry", async () => { + const { app, service, login } = fixture(); + const csrf = await token(app); + vi.mocked(service.status).mockRejectedValue(new ReviewFailed(403, "feature_unavailable")); + const response = await request(app, "snapshot", csrf); + expect(await response.json()).toMatchObject({ code: "feature_unavailable" }); + expect(login).not.toHaveBeenCalled(); +}); + +it("distinguishes review admission refusal only after fresh account validation", async () => { + const { app, service, login } = fixture(); + const csrf = await token(app); + vi.mocked(service.status).mockRejectedValue(new ReviewFailed(401, "login_required")); + const response = await request(app, "snapshot", csrf); + expect(await response.json()).toMatchObject({ + code: "sharing_not_admitted", + message: expect.stringContaining("You're signed in"), + }); + expect(service.checkSession).toHaveBeenCalledWith(true); + expect(login).not.toHaveBeenCalled(); +}); + +it("shows a completed login's admission failure to its initiating panel", async () => { + const { app, service } = fixture(); + const csrf = await token(app); + vi.mocked(service.status).mockRejectedValue(new ReviewFailed(401, "login_required")); + const started = await (await request(app, "actions", csrf, { action: "login" })).json(); + await vi.waitFor(async () => { + const response = await request(app, `jobs/${started.id}`, csrf); + expect(response.status).toBe(200); + expect(await response.json()).toMatchObject({ + state: "failed", + result: null, + error: { code: "sharing_not_admitted" }, + }); + }); +}); + +it.each([undefined, true])("forwards only explicit source consent (%s)", async (includeSource) => { + const { app, service } = fixture(); + const csrf = await token(app); + const response = await request(app, "actions", csrf, { + action: "share", + audience: "public", + includeSource, + }); + expect(response.status).toBe(202); + await new Promise((resolve) => setTimeout(resolve, 0)); + expect(service.run).toHaveBeenCalledWith(expect.objectContaining({ includeSource })); +}); diff --git a/packages/cli/src/server/shareRoutes.ts b/packages/cli/src/server/shareRoutes.ts new file mode 100644 index 0000000000..ede794699e --- /dev/null +++ b/packages/cli/src/server/shareRoutes.ts @@ -0,0 +1,271 @@ +import { randomUUID } from "node:crypto"; +import { Hono } from "hono"; +import { bodyLimit } from "hono/body-limit"; +import type { + LocalShareAction, + LocalShareAudience, + LocalShareJob, + LocalShareSnapshot, +} from "@hyperframes/studio-server"; +import { ReviewFailed, type ReviewExportProgress } from "@hyperframes/share"; +import type { ShareService } from "../share/service.js"; +import { shareError } from "../share/errors.js"; +import { localShareRequestAllowed } from "./shareBoundary.js"; +import { trackShareInteraction } from "../share/telemetry.js"; +import { shareEventInput } from "./shareEvents.js"; +import { presentSpaces } from "./sharePresentation.js"; + +import { createShareSessions, shareSessionKey } from "./shareSessions.js"; + +import { presentPortableShare } from "./shareFreshness.js"; + +const AUDIENCES: readonly LocalShareAudience[] = ["public", "team", "invite", "private"]; +function actionInput(value: unknown): LocalShareAction | null { + if (!isRecord(value)) return null; + const record = Object.fromEntries(Object.entries(value)); + if ( + Object.keys(record).some( + (key) => !["action", "audience", "space", "videoOnly", "includeSource"].includes(key), + ) + ) + return null; + const { action, audience, space, videoOnly, includeSource } = record; + if (!isAction(action)) return null; + const chosen = AUDIENCES.find((mode) => mode === audience); + if (audience !== undefined && !chosen) return null; + const options = actionOptions(space, videoOnly, includeSource); + if (!options) return null; + if (["share", "access"].includes(action) && !chosen) return null; + return { + action, + audience: chosen, + ...options, + }; +} + +function isRecord(value: unknown): value is Record { + return typeof value === "object" && value !== null && !Array.isArray(value); +} + +function isAction(value: unknown): value is LocalShareAction["action"] { + return ["share", "update", "access", "off", "on", "login"].some((action) => action === value); +} +function actionOptions( + space: unknown, + videoOnly: unknown, + includeSource: unknown, +): Pick | null { + if (!validSpace(space)) return null; + if (![videoOnly, includeSource].every(optionalBoolean)) return null; + if (includeSource === true && videoOnly === true) return null; + const options: Pick = {}; + if (typeof space === "string") options.space = space; + if (videoOnly === true) options.videoOnly = true; + if (includeSource === true) options.includeSource = true; + return options; +} +function optionalBoolean(value: unknown): boolean { + return value === undefined || typeof value === "boolean"; +} +function validSpace(value: unknown): boolean { + return value === undefined || (typeof value === "string" && /^[A-Za-z0-9_-]{1,128}$/.test(value)); +} + +type CreateService = ( + path: string, + progress: (value: ReviewExportProgress | null) => void, +) => Promise; +const defaultCreate: CreateService = async (path, progress) => + (await import("../share/service.js")).createShareService(path, progress, { + surface: "local_studio", + pinIdentity: true, + }); + +async function defaultLogin(): Promise { + const { startAuthorizationCodeFlow } = await import("../auth/oauth.js"); + await startAuthorizationCodeFlow({ timeoutMs: 300_000 }); +} + +export function mountShareRoutes( + app: Hono, + projectDir: string, + create: CreateService = defaultCreate, + login: () => Promise = defaultLogin, + track: typeof trackShareInteraction = trackShareInteraction, +): void { + const routes = new Hono(); + let job: LocalShareJob | null = null; + const hasRunningJob = () => job?.state === "running"; + let jobOwner: string | null = null; + let loginToken: string | null = null; + const sessions = createShareSessions(() => + create(projectDir, (progress) => { + if (job?.state === "running" && progress) job.step = progress.step; + }), + ); + const visibleJob = async (token: string) => { + if (loginToken === token && job && job.state !== "done") return job; + const session = sessions.get(token); + if (!session) return null; + const key = shareSessionKey(await (await session.get()).checkSession()); + return key === jobOwner ? job : null; + }; + routes.use("*", async (c, next) => { + c.header("Cache-Control", "no-store"); + if (!localShareRequestAllowed(c.req.raw)) + return c.json({ code: "forbidden", message: "Open sharing from this local Studio." }, 403); + if ( + c.req.path !== "/api/share/bootstrap" && + !sessions.get(c.req.header("x-hyperframes-share-csrf") ?? "") + ) + return c.json({ code: "forbidden", message: "Refresh Studio to reconnect sharing." }, 403); + return next(); + }); + routes.use("*", bodyLimit({ maxSize: 4096 })); + routes.get("/bootstrap", (c) => c.json({ csrf: sessions.open() })); + routes.post("/events", async (c) => { + const event = shareEventInput(await c.req.json().catch(() => null)); + if (!event) return c.json({ code: "invalid_event", message: "Unknown sharing event." }, 400); + track(event, "local_studio"); + return c.body(null, 204); + }); + routes.get("/snapshot", async (c) => { + try { + const sharing = await sessions.get(c.req.header("x-hyperframes-share-csrf")!)!.get(); + const [state, spaces, capabilities] = await Promise.all([ + sharing.status(), + sharing.spaces(), + sharing.capabilities(), + ]); + return c.json({ + versionSharing: capabilities.versionSharing, + share: await presentPortableShare(projectDir, state), + spaces: presentSpaces(spaces), + job: await visibleJob(c.req.header("x-hyperframes-share-csrf")!), + } satisfies LocalShareSnapshot); + } catch (error) { + return c.json( + { + ...(await presentError(error, c.req.header("x-hyperframes-share-csrf")!)), + job: + loginToken === c.req.header("x-hyperframes-share-csrf") && job && job.state !== "done" + ? job + : null, + }, + 400, + ); + } + }); + routes.get("/jobs/:id", async (c) => { + try { + const current = await visibleJob(c.req.header("x-hyperframes-share-csrf")!); + return current?.id === c.req.param("id") + ? c.json(current) + : c.json( + { code: "job_not_found", message: "Refresh sharing to see the current state." }, + 404, + ); + } catch (error) { + return c.json(await presentError(error, c.req.header("x-hyperframes-share-csrf")!), 400); + } + }); + routes.post("/actions", async (c) => { + const input = actionInput(await c.req.json().catch(() => null)); + if (!input) + return c.json( + { code: "invalid_action", message: "Choose a valid sharing action and audience." }, + 400, + ); + const token = c.req.header("x-hyperframes-share-csrf")!; + const session = sessions.get(token)!; + if (hasRunningJob()) + return c.json( + { + code: "share_busy", + message: "Sharing is already in progress.", + job: await visibleJob(token).catch(() => null), + }, + 409, + ); + let owner: string | null = null; + if (input.action !== "login") { + try { + owner = await sessionOwner(session); + } catch (error) { + return c.json(await presentError(error, c.req.header("x-hyperframes-share-csrf")!), 400); + } + } + if (hasRunningJob()) + return c.json({ code: "share_busy", message: "Sharing is already in progress." }, 409); + jobOwner = owner; + loginToken = input.action === "login" ? token : null; + const current: LocalShareJob = { + id: randomUUID(), + state: "running", + step: actionStep(input), + result: null, + error: null, + }; + job = current; + void runJob(current, input, session, token); + return c.json(current, 202); + }); + async function runJob( + current: LocalShareJob, + input: LocalShareAction, + session: NonNullable>, + token: string, + ) { + try { + if (input.action === "login") { + await login(); + session.reset(); + } + const sharing = await session.get(); + const result = await executeAction(sharing, input); + jobOwner = shareSessionKey(await sharing.checkSession()); + current.result = await presentPortableShare(projectDir, result); + current.state = "done"; + } catch (error) { + current.error = await presentError(error, token); + current.state = "failed"; + } + } + async function presentError(error: unknown, token: string) { + if (!(error instanceof ReviewFailed) || error.status !== 401) return shareError(error); + const session = sessions.get(token); + if (!session) return shareError(error); + try { + await (await session.get()).checkSession(true); + return { + code: "sharing_not_admitted", + message: + "You're signed in, but sharing isn't accepting this sign-in. Try again later or contact support.", + }; + } catch (verificationError) { + return shareError(verificationError); + } + } + app.route("/api/share", routes); +} + +function executeAction(sharing: ShareService, input: LocalShareAction) { + if (input.action === "login") return sharing.status(); + if (input.action === "access" && input.audience) return sharing.setAccess(input.audience); + if (input.action === "off") return sharing.linkOff(); + if (input.action === "on") return sharing.linkOn(); + return sharing.run({ + action: input.action === "update" ? "update" : "share", + audience: input.audience, + space: input.space, + videoOnly: input.videoOnly, + includeSource: input.includeSource, + }); +} + +function actionStep(input: LocalShareAction) { + return input.action === "login" ? "signing_in" : "preparing"; +} +async function sessionOwner(session: { get: () => Promise }) { + return shareSessionKey(await (await session.get()).checkSession()); +} diff --git a/packages/cli/src/server/shareSessions.ts b/packages/cli/src/server/shareSessions.ts new file mode 100644 index 0000000000..2b3e5f6318 --- /dev/null +++ b/packages/cli/src/server/shareSessions.ts @@ -0,0 +1,31 @@ +import type { ShareService } from "../share/service.js"; +import { createShareCsrf } from "./shareBoundary.js"; + +export function shareSessionKey(value: Awaited>) { + return JSON.stringify([value.owner, value.heygen, value.heygenApi]); +} + +export function createShareSessions(create: () => Promise) { + const sessions = new Map>(); + function session() { + let service: Promise | null = null; + return { + get: () => (service ??= create()), + reset: () => { + service = null; + }, + }; + } + return { + open() { + const token = createShareCsrf().token; + if (sessions.size >= 128) { + const oldest = sessions.keys().next().value; + if (oldest) sessions.delete(oldest); + } + sessions.set(token, session()); + return token; + }, + get: (token: string) => sessions.get(token), + }; +} diff --git a/packages/cli/src/server/studioServer.file-race.test.ts b/packages/cli/src/server/studioServer.file-race.test.ts index 384ce2b974..c6c3deebfe 100644 --- a/packages/cli/src/server/studioServer.file-race.test.ts +++ b/packages/cli/src/server/studioServer.file-race.test.ts @@ -253,6 +253,7 @@ describe("Studio bundle file reads", () => { const text = await response.text(); expect(text).toContain("Studio"); expect(text).toContain('"VITE_STUDIO_STATIC_TEST":"runtime-value"'); + expect(text).toContain(''); expectClosed(); }); diff --git a/packages/cli/src/server/studioServer.ts b/packages/cli/src/server/studioServer.ts index 9389fe4acc..de9ce8eae3 100644 --- a/packages/cli/src/server/studioServer.ts +++ b/packages/cli/src/server/studioServer.ts @@ -41,6 +41,7 @@ import { PREVIEW_ALLOWED_HOSTS_ENV, previewAllowedHostsFromEnv, } from "@hyperframes/studio-server/request-identity"; +import { mountShareRoutes } from "./shareRoutes.js"; import { isDevMode } from "../utils/env.js"; import { insideHostApp } from "../utils/desktopApp.js"; import { runRenderSetupWorker } from "../utils/cancellableProcess.js"; @@ -1097,6 +1098,7 @@ export function createStudioServer(options: StudioServerOptions): StudioServer { }); mountDesktopRoutes(app, projectDir); + mountShareRoutes(app, projectDir); // ── Pre-flight checks for render ──────────────────────────────────────── // Intercept render requests before they reach the shared API so we can @@ -1241,9 +1243,10 @@ export function createStudioServer(options: StudioServerOptions): StudioServer { // (`HYPERFRAMES_PREVIEW_HOST=0.0.0.0`) needs it to stay in agreement with // the CLI. See buildStudioHeadScriptsForHost. const headScript = buildStudioHeadScriptsForHost(buildRuntimeEnvScript(), c.req.header("host")); - if (headScript) { - html = html.replace("", `${headScript}`); - } + html = html.replace( + "", + `${headScript}`, + ); // The shell names the current hashed bundle, so it always revalidates. // `no-cache` not `no-store`: same refetch without an ETag, but `no-store` // would blocklist the document from Chrome's bfcache. diff --git a/packages/cli/src/share/activity.test.ts b/packages/cli/src/share/activity.test.ts new file mode 100644 index 0000000000..72223d7ba3 --- /dev/null +++ b/packages/cli/src/share/activity.test.ts @@ -0,0 +1,63 @@ +import { mkdtemp, realpath, rm, writeFile } from "node:fs/promises"; +import { hostname, tmpdir } from "node:os"; +import { join } from "node:path"; +import { afterEach, expect, it } from "vitest"; +import { readShareActivity, withShareActivity } from "./activity.js"; +const dirs: string[] = []; +afterEach(async () => { + for (const dir of dirs.splice(0)) await rm(dir, { recursive: true, force: true }); +}); +async function folder() { + const dir = await realpath(await mkdtemp(join(tmpdir(), "hf-share-activity-"))); + dirs.push(dir); + return dir; +} +it("exposes preparation, rendering and upload until completion, then clears status", async () => { + const dir = await folder(); + await withShareActivity(dir, async (phase) => { + expect((await readShareActivity(dir))?.step).toBe("preparing"); + await phase("rendering"); + expect((await readShareActivity(dir))?.step).toBe("rendering"); + await phase("uploading_source"); + expect((await readShareActivity(dir))?.step).toBe("uploading_source"); + await expect(withShareActivity(dir, async () => {})).rejects.toThrow("Another process"); + }); + expect(await readShareActivity(dir)).toBeNull(); +}); +it("clears a failed attempt and ignores stale records for dead processes", async () => { + const dir = await folder(); + await expect( + withShareActivity(dir, async () => { + throw new Error("upload refused"); + }), + ).rejects.toThrow("upload refused"); + expect(await readShareActivity(dir)).toBeNull(); + await writeFile( + join(dir, ".hyperframes", "share-activity.json"), + JSON.stringify({ + step: "rendering", + pid: 2147483647, + hostname: (await import("node:os")).hostname(), + startedAt: "now", + updatedAt: Date.now(), + }), + ); + expect(await readShareActivity(dir)).toBeNull(); +}); + +it("ignores an expired heartbeat even when the process is alive", async () => { + const dir = await folder(); + await withShareActivity(dir, async () => { + await writeFile( + join(dir, ".hyperframes", "share-activity.json"), + JSON.stringify({ + step: "rendering", + pid: process.pid, + hostname: hostname(), + startedAt: "now", + updatedAt: Date.now() - 61000, + }), + ); + expect(await readShareActivity(dir)).toBeNull(); + }); +}); diff --git a/packages/cli/src/share/activity.ts b/packages/cli/src/share/activity.ts new file mode 100644 index 0000000000..3784ca6a2c --- /dev/null +++ b/packages/cli/src/share/activity.ts @@ -0,0 +1,90 @@ +import { hostname } from "node:os"; +import { join } from "node:path"; +import { mkdirInside, readJsonRecord, writeJsonAtomic, rm } from "@hyperframes/share/storage.mjs"; +import { withProjectShareLock } from "@hyperframes/share/projectLock.mjs"; + +export type SharePhase = + | "preparing" + | "rendering" + | "uploading_source" + | "uploading_video" + | "checking"; +export interface ShareActivity { + step: SharePhase; + startedAt: string; +} +const phases = [ + "preparing", + "rendering", + "uploading_source", + "uploading_video", + "checking", +] as const; +const fileFor = (dir: string) => join(dir, ".hyperframes", "share-activity.json"); + +export async function readShareActivity(dir: string): Promise { + const value = await readJsonRecord(fileFor(dir)); + if ( + !value || + value.hostname !== hostname() || + typeof value.pid !== "number" || + !Number.isSafeInteger(value.pid) || + value.pid <= 0 + ) + return null; + const step = phases.find((step) => step === value.step); + if ( + !step || + typeof value.startedAt !== "string" || + typeof value.updatedAt !== "number" || + Date.now() - value.updatedAt > 60000 + ) + return null; + try { + process.kill(value.pid, 0); + } catch { + return null; + } + return { step, startedAt: value.startedAt }; +} + +export async function withShareActivity( + dir: string, + run: (phase: (step: SharePhase) => Promise) => Promise, +): Promise { + return withProjectShareLock( + dir, + "operation", + async () => { + await mkdirInside(dir, ".hyperframes"); + const startedAt = new Date().toISOString(); + let step: SharePhase = "preparing"; + let pending = Promise.resolve(); + const phase = (next: SharePhase) => { + step = next; + pending = writeJsonAtomic(fileFor(dir), { + step, + startedAt, + updatedAt: Date.now(), + pid: process.pid, + hostname: hostname(), + }); + void pending.catch(() => {}); + return pending; + }; + const heartbeat = setInterval(() => { + void phase(step); + }, 10000); + heartbeat.unref(); + try { + await phase("preparing"); + return await run(phase); + } finally { + clearInterval(heartbeat); + await pending.catch(() => {}); + await rm(fileFor(dir), { force: true }); + } + }, + { timeoutMs: 0 }, + ); +} diff --git a/packages/cli/src/share/auth.test.ts b/packages/cli/src/share/auth.test.ts new file mode 100644 index 0000000000..031e05cad6 --- /dev/null +++ b/packages/cli/src/share/auth.test.ts @@ -0,0 +1,84 @@ +import { beforeEach, describe, expect, it, vi } from "vitest"; +import type { ResolvedCredential } from "../auth/resolver.js"; +const mocks = vi.hoisted(() => ({ + resolve: vi.fn<() => Promise>(), + refresh: vi.fn(), + user: vi.fn(), +})); +vi.mock("../auth/resolver.js", () => ({ resolveCredential: mocks.resolve })); +vi.mock("../auth/oauth.js", () => ({ refreshTokens: mocks.refresh })); +vi.mock("../auth/client.js", () => ({ + apiBaseUrl: () => "https://api.heygen.com", + AuthClient: class { + getCurrentUser = mocks.user; + }, +})); +import { createShareAccess } from "./auth.js"; +const oauth = (token: string): ResolvedCredential => ({ + type: "oauth", + access_token: token, + source: "file_json", + refreshable: false, +}); +beforeEach(() => { + vi.resetAllMocks(); + mocks.user.mockResolvedValue({ username: "owner", email: "owner@example.com" }); +}); +describe("share OAuth identity", () => { + it("rejects API keys before any account request", async () => { + mocks.resolve.mockResolvedValue({ type: "api_key", key: "secret", source: "env" }); + await expect(createShareAccess().access()).rejects.toMatchObject({ code: "UNAUTHENTICATED" }); + expect(mocks.user).not.toHaveBeenCalled(); + }); + it("never falls back to an API key after refresh", async () => { + mocks.resolve + .mockResolvedValueOnce({ + ...oauth("old"), + type: "oauth", + access_token: "old", + refresh_token: "refresh", + refreshable: true, + }) + .mockResolvedValueOnce({ type: "api_key", key: "key", source: "env" }); + await expect(createShareAccess().access()).rejects.toMatchObject({ code: "UNAUTHENTICATED" }); + expect(mocks.refresh).toHaveBeenCalledWith("refresh"); + expect(mocks.user).not.toHaveBeenCalled(); + }); + it("rejects a different actor when the credential changes", async () => { + mocks.resolve.mockResolvedValueOnce(oauth("a")).mockResolvedValueOnce(oauth("b")); + mocks.user + .mockResolvedValueOnce({ username: "first" }) + .mockResolvedValueOnce({ username: "second" }); + const auth = createShareAccess(); + expect((await auth.access()).owner).toBe("first"); + await expect(auth.access()).rejects.toMatchObject({ code: "LOGIN_CHANGED" }); + }); + it("does not retry a refused environment token", async () => { + mocks.resolve.mockResolvedValue(oauth("refused")); + await expect(createShareAccess().access("refused")).rejects.toMatchObject({ + code: "UNAUTHENTICATED", + }); + expect(mocks.refresh).not.toHaveBeenCalled(); + }); +}); + +it("pins a Studio session across account switches but permits same-account token rotation", async () => { + const auth = createShareAccess(true); + mocks.resolve.mockResolvedValue(oauth("first")); + await auth.access(); + mocks.resolve.mockResolvedValue(oauth("refreshed")); + await expect(auth.access()).resolves.toMatchObject({ owner: "owner", token: "refreshed" }); + mocks.resolve.mockResolvedValue(oauth("other")); + mocks.user.mockResolvedValue({ username: "other" }); + await expect(auth.access()).rejects.toMatchObject({ code: "LOGIN_CHANGED" }); + await expect(auth.access()).rejects.toMatchObject({ code: "LOGIN_CHANGED" }); +}); + +it("can revalidate the same token instead of trusting a cached account", async () => { + mocks.resolve.mockResolvedValue(oauth("same")); + const auth = createShareAccess(true); + await auth.access(); + mocks.user.mockRejectedValue(new Error("account validation refused")); + await expect(auth.access(undefined, true)).rejects.toThrow("account validation refused"); + expect(mocks.user).toHaveBeenCalledTimes(2); +}); diff --git a/packages/cli/src/share/auth.ts b/packages/cli/src/share/auth.ts new file mode 100644 index 0000000000..9bdd571b42 --- /dev/null +++ b/packages/cli/src/share/auth.ts @@ -0,0 +1,66 @@ +import { apiBaseUrl, AuthClient } from "../auth/client.js"; +import { tokenEndpoint, oauthEnvironment } from "../auth/config.js"; +import { AuthError, ErrLoginChanged } from "../auth/errors.js"; +import { refreshTokens } from "../auth/oauth.js"; +import { resolveCredential } from "../auth/resolver.js"; + +export function shareSite(): string { + return oauthEnvironment() === "dev" ? "https://dev.hyperframes.dev" : "https://hyperframes.dev"; +} + +export function createShareAccess(pinIdentity = true) { + let bound: string | undefined; + let identity: { token: string; owner: string; email: string | null } | undefined; + const userClient = new AuthClient(); + const access = async (refused?: string, verifyIdentity = false) => { + const credential = await shareCredential(refused); + let account = identity; + if (verifyIdentity || account?.token !== credential.access_token) { + const user = await userClient.getCurrentUser(credential); + if (!user.username) throw loginRequired(); + account = { + token: credential.access_token, + owner: user.username, + email: user.email ?? null, + }; + } + const key = JSON.stringify([account.owner, new URL(tokenEndpoint()).origin, apiBaseUrl()]); + if (pinIdentity && bound !== undefined && bound !== key) throw ErrLoginChanged(); + bound = key; + identity = account; + return { + token: credential.access_token, + heygen: new URL(tokenEndpoint()).origin, + heygenApi: apiBaseUrl(), + owner: account.owner, + }; + }; + return { + access, + signedInEmail: async () => { + await access(); + return identity?.email ?? null; + }, + }; +} + +function loginRequired(): AuthError { + return new AuthError( + "UNAUTHENTICATED", + "Sharing requires a signed-in HeyGen account.", + "Run hyperframes auth login. API keys cannot own shared projects.", + ); +} + +async function shareCredential(refused?: string) { + let credential = await resolveCredential(); + if (credential.type !== "oauth") throw loginRequired(); + if (credential.refreshable || credential.access_token === refused) { + if (!credential.refresh_token) throw loginRequired(); + await refreshTokens(credential.refresh_token); + credential = await resolveCredential(); + if (credential.type !== "oauth") throw loginRequired(); + } + if (credential.access_token === refused) throw loginRequired(); + return credential; +} diff --git a/packages/cli/src/share/errors.ts b/packages/cli/src/share/errors.ts new file mode 100644 index 0000000000..0dead0e477 --- /dev/null +++ b/packages/cli/src/share/errors.ts @@ -0,0 +1,44 @@ +import { SourceIgnoreError, ownerOf, ReviewFailed, reviewSentence } from "@hyperframes/share"; +import { ShareSourceError } from "./sources.js"; +import { isAuthError } from "../auth/errors.js"; +import { CliUsageError } from "../utils/commandResult.js"; + +const HINTS: Record = { + review_upload_origins_required: + "Review video storage is not configured. Set HYPERFRAMES_REVIEW_UPLOAD_ORIGINS to the exact storage origins provided by your deployment.", + review_project_limit_reached: + "Your workspace has used its five free shared projects. Update an existing share, or manage and remove one to free a slot. Turning a link off does not free a slot.", + review_subscription_required: + "Workspace and invite-only sharing require a paid plan. On Free, choose --private (only you) or --public (anyone with the link), or upgrade your workspace plan.", + workspace_mismatch: + "This folder already shares into another workspace. Manage the existing share instead of changing its identity.", + review_binding_changed: + "The review linked to this folder changed. Run hyperframes share --status before trying again.", + manage_existing_audience: + "Manage this existing share to change its audience. Copying or updating a share preserves its settings.", + not_shared: + "This project has no shared review yet. Run hyperframes share with an explicit audience.", +}; +export function shareError(error: unknown): { code: string; message: string; owner?: string } { + if (error instanceof SourceIgnoreError) return { code: error.code, message: error.message }; + if (error instanceof CliUsageError) return { code: error.code, message: error.message }; + if (error instanceof ShareSourceError) + return { code: "source_unavailable", message: error.message }; + if (isAuthError(error)) + return { + code: error.code.toLowerCase(), + message: `${error.message} ${error.hint ?? ""}`.trim(), + }; + if (error instanceof ReviewFailed) { + const owner = error.status === 401 ? null : ownerOf(error.reason); + if (owner !== null) return { code: "owner_signed_out", owner, message: reviewSentence(error) }; + return { + code: error.status === 401 ? "login_expired" : error.reason || "share_failed", + message: HINTS[error.reason] ?? reviewSentence(error), + }; + } + return { + code: "share_failed", + message: error instanceof Error ? error.message : "Sharing failed. Try again.", + }; +} diff --git a/packages/cli/src/share/host.ts b/packages/cli/src/share/host.ts new file mode 100644 index 0000000000..9ca09afafb --- /dev/null +++ b/packages/cli/src/share/host.ts @@ -0,0 +1,67 @@ +import { basename } from "node:path"; +import { realpathSync } from "node:fs"; +import { + bindShareHost, + projectFingerprint, + ReviewFailed, + setReviewSite, + signedInRequest, +} from "@hyperframes/share"; +import { reviewUploadOrigins } from "@hyperframes/share/host.mjs"; +import { findFFprobe } from "../browser/ffmpeg.js"; +import { latestShareRender } from "./render.js"; +import { shareSite } from "./auth.js"; +import { cliReviewUploadOrigins } from "./uploadOrigins.js"; + +const projects = new Set(); + +function isStorageOrigin(origin: string): boolean { + if (!URL.canParse(origin)) return false; + const url = new URL(origin); + const loopback = url.protocol === "http:" && url.hostname === "127.0.0.1"; + return ( + url.origin === origin && !url.hostname.includes("*") && (url.protocol === "https:" || loopback) + ); +} + +export function assertReviewUploadStorage(): void { + const origins = reviewUploadOrigins().filter(Boolean); + if (origins.length === 0 || !origins.every(isStorageOrigin)) + throw new ReviewFailed(503, "review_upload_origins_required"); +} + +export function bindCliShareProject(path: string): string { + const dir = realpathSync(path); + projects.add(dir); + bindShareHost({ + reviewUploadOrigins: cliReviewUploadOrigins(), + normalize: realpathSync, + assertOpenProject: (path) => { + const normalized = realpathSync(path); + if (!projects.has(normalized)) throw new Error("This project is not open for sharing."); + return normalized; + }, + resolveOpenProjectByPath: (path) => { + const normalized = realpathSync(path); + return projects.has(normalized) ? { id: normalized, dir: normalized } : null; + }, + listOpenProjects: () => [...projects].map((dir) => ({ dir })), + homeName: basename, + latestExportFile: latestShareRender, + projectFingerprint, + signedInRequest: (deps) => + signedInRequest({ + ...deps, + headers: { "X-HeyGen-Source": "cli", "X-HeyGen-Client-Source": "hyperframes" }, + }), + ffBinary: () => { + const binary = findFFprobe(); + if (!binary) throw new Error("Install FFmpeg to prepare a shared video."); + return binary; + }, + channelSite: "https://hyperframes.dev", + signinSites: ["https://hyperframes.dev", "https://dev.hyperframes.dev"], + }); + setReviewSite(shareSite()); + return dir; +} diff --git a/packages/cli/src/share/identity.test.ts b/packages/cli/src/share/identity.test.ts new file mode 100644 index 0000000000..6972a0ed33 --- /dev/null +++ b/packages/cli/src/share/identity.test.ts @@ -0,0 +1,78 @@ +import { beforeEach, expect, it, vi } from "vitest"; +vi.mock("./activity.js", () => ({ + readShareActivity: async () => null, + withShareActivity: async (_dir: string, run: (phase: () => Promise) => Promise) => + run(async () => {}), +})); +const mocks = vi.hoisted(() => ({ + token: "first", + owner: "first-owner", + register: vi.fn(), + add: vi.fn(), + render: vi.fn(), +})); +vi.mock("../auth/resolver.js", () => ({ + resolveCredential: async () => ({ type: "oauth", access_token: mocks.token, refreshable: false }), +})); +vi.mock("../auth/client.js", () => ({ + apiBaseUrl: () => "https://api.heygen.com", + AuthClient: class { + getCurrentUser = async () => ({ username: mocks.owner }); + }, +})); +vi.mock("./host.js", () => ({ + bindCliShareProject: (path: string) => path, + assertReviewUploadStorage: () => {}, +})); +vi.mock("./render.js", () => ({ prepareShareRender: mocks.render })); +vi.mock("../telemetry/client.js", () => ({ trackEvent: vi.fn() })); +vi.mock("@hyperframes/share", async (original) => { + const actual = await original(); + return { + ...actual, + reviewClient: ({ access }: { access: () => Promise }) => ({ + access, + reviewFlags: async () => ({ versionSharing: true, shareFiles: false }), + spaces: async () => [ + { + space_id: "space", + bound: true, + can_create_review: true, + review_entitlements: { + can_register_project: true, + allowed_collaborative_access_modes: ["public"], + }, + }, + ], + project: async () => ({ latest_ready_version_id: "version" }), + }), + reviewStatus: async () => null, + reviewRecord: async () => null, + reviewVersion: async () => ({ last: null, source: "ready", failure: null }), + pendingReviewExport: async () => null, + refreshReviewExport: async () => {}, + shareForReview: async ({ client }: { client: { access: () => Promise } }) => { + await client.access(); + mocks.register(); + return { projectId: "project", space: { id: "space" }, access: "public" }; + }, + addVersion: mocks.add, + }; +}); +import { createShareService } from "./service.js"; +beforeEach(() => { + vi.clearAllMocks(); + mocks.token = "first"; + mocks.owner = "first-owner"; +}); +it("does not register or upload as a different account after rendering", async () => { + mocks.render.mockImplementation(async () => { + mocks.token = "second"; + mocks.owner = "second-owner"; + }); + await expect( + createShareService("/project").run({ action: "share", audience: "public" }), + ).rejects.toMatchObject({ code: "LOGIN_CHANGED" }); + expect(mocks.register).not.toHaveBeenCalled(); + expect(mocks.add).not.toHaveBeenCalled(); +}); diff --git a/packages/cli/src/share/publishTransition.test.ts b/packages/cli/src/share/publishTransition.test.ts new file mode 100644 index 0000000000..bf84cb1fbe --- /dev/null +++ b/packages/cli/src/share/publishTransition.test.ts @@ -0,0 +1,91 @@ +import { describe, expect, it } from "vitest"; +import { publishPhase, publishTransitionDecision } from "./publishTransition.js"; +describe("announced 60-day publish transition", () => { + const start = "2027-01-01T00:00:00.000Z"; + const day = 86_400_000; + it("never starts the clock from approval or installation", () => { + expect(publishPhase(null, Date.parse(start) + 365 * day)).toBe("unscheduled"); + expect(publishPhase(start, Date.parse(start) - 1)).toBe("unscheduled"); + }); + it("preserves exactly sixty days and guides only after the boundary", () => { + expect(publishPhase(start, Date.parse(start))).toBe("compatibility"); + expect(publishPhase(start, Date.parse(start) + 60 * day - 1)).toBe("compatibility"); + expect(publishPhase(start, Date.parse(start) + 60 * day)).toBe("share"); + }); + it("retains legacy updates after the new-project transition", () => { + expect(publishTransitionDecision("share", true)).toBe("keep_legacy"); + expect(publishTransitionDecision("share", false)).toBe("guide_to_share"); + expect(publishTransitionDecision("compatibility", false)).toBe("keep_legacy"); + }); + it("fails on an invalid scheduled date rather than silently switching behavior", () => { + expect(() => publishPhase("invalid")).toThrow("timestamp"); + }); +}); + +import { afterEach, beforeEach, vi } from "vitest"; +import { mkdtempSync, rmSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; +import { assertLegacyPublishOwner, checkPublishTransition } from "./publishTransition.js"; +import { writeProjectLink, writeTeamProject } from "../utils/projectLink.js"; +import { CliUsageError } from "../utils/commandResult.js"; + +describe("publish transition guard", () => { + let dir: string; + const start = "2027-01-01T00:00:00.000Z"; + beforeEach(() => { + dir = mkdtempSync(join(tmpdir(), "publish-transition-")); + vi.stubEnv("HYPERFRAMES_CONFIG_DIR", join(dir, "config")); + vi.spyOn(process.stderr, "write").mockReturnValue(true); + vi.useFakeTimers(); + vi.setSystemTime(new Date("2027-04-01T00:00:00.000Z")); + }); + afterEach(() => { + vi.useRealTimers(); + vi.restoreAllMocks(); + vi.unstubAllEnvs(); + rmSync(dir, { recursive: true, force: true }); + }); + it("leaves the shipped window unscheduled even far in the future", () => { + vi.setSystemTime(new Date("2099-01-01T00:00:00.000Z")); + expect(() => checkPublishTransition({ dir })).not.toThrow(); + expect(process.stderr.write).toHaveBeenCalledWith( + expect.stringContaining("not been scheduled"), + ); + }); + it("guides new projects without changing their audience or uploading", () => { + expect(() => checkPublishTransition({ dir }, start)).toThrowError(CliUsageError); + try { + checkPublishTransition({ dir }, start); + } catch (error) { + expect(error).toMatchObject({ + code: "publish_replaced", + result: { exitCode: 2 }, + hint: expect.stringContaining("do not convert"), + }); + } + }); + it("keeps explicit legacy updates and stored published links", () => { + expect(() => checkPublishTransition({ dir, update: "legacy-project" }, start)).not.toThrow(); + writeProjectLink(dir, { projectId: "legacy", url: "https://hyperframes.dev/p/legacy" }); + expect(() => checkPublishTransition({ dir }, start)).not.toThrow(); + expect(process.stderr.write).toHaveBeenCalledWith( + expect.stringContaining("uses the legacy update workflow"), + ); + }); + it("keeps committed team project targets", () => { + writeTeamProject(dir, { projectId: "legacy-team", spaceId: "team" }); + expect(() => checkPublishTransition({ dir }, start)).not.toThrow(); + }); + it("does not count an unused local identity or whitespace as a published project", () => { + writeProjectLink(dir, { projectId: "unused", url: "" }); + expect(() => checkPublishTransition({ dir, update: " " }, start)).toThrowError(CliUsageError); + }); +}); + +it("requires an owner after the window so legacy targets cannot silently create fresh projects", () => { + expect(() => assertLegacyPublishOwner("share", false)).toThrowError(CliUsageError); + expect(() => assertLegacyPublishOwner("share", true)).not.toThrow(); + expect(() => assertLegacyPublishOwner("compatibility", false)).not.toThrow(); + expect(() => assertLegacyPublishOwner("unscheduled", false)).not.toThrow(); +}); diff --git a/packages/cli/src/share/publishTransition.ts b/packages/cli/src/share/publishTransition.ts new file mode 100644 index 0000000000..e562188c67 --- /dev/null +++ b/packages/cli/src/share/publishTransition.ts @@ -0,0 +1,81 @@ +import { resolve } from "node:path"; +import { CliUsageError } from "../utils/commandResult.js"; +import { asNotice } from "../utils/jsonError.js"; +import { readProjectLink, readTeamProject } from "../utils/projectLink.js"; + +/** Set to the announced notice release's UTC timestamp in the release PR, after launch gates pass. */ +const PUBLISH_NOTICE_RELEASE: string | null = null; +const PUBLISH_COMPATIBILITY_DAYS = 60; + +export function publishPhase( + start: string | null, + now: number = Date.now(), +): "unscheduled" | "compatibility" | "share" { + if (!start) return "unscheduled"; + const begins = Date.parse(start); + if (!Number.isFinite(begins)) throw new Error("Invalid publish transition release timestamp."); + if (now < begins) return "unscheduled"; + return now < begins + PUBLISH_COMPATIBILITY_DAYS * 86_400_000 ? "compatibility" : "share"; +} +export function publishTransitionDecision( + phase: ReturnType, + legacyUpdate: boolean, +) { + if (phase === "share" && !legacyUpdate) return "guide_to_share"; + return "keep_legacy"; +} +export function checkPublishTransition( + args: { dir?: string; update?: string }, + noticeRelease: string | null = PUBLISH_NOTICE_RELEASE, +): ReturnType { + const dir = resolve(args.dir ?? "."); + const prior = readProjectLink(dir); + const legacyUpdate = Boolean( + args.update?.trim() || prior?.url || readTeamProject(dir)?.projectId, + ); + const phase = publishPhase(noticeRelease); + asNotice(() => process.stderr.write(publishNotice(phase, legacyUpdate) + "\n")); + if (publishTransitionDecision(phase, legacyUpdate) === "guide_to_share") { + throw new CliUsageError( + "New projects now use hyperframes share. Run it from this project folder and choose an audience; for scripts pass --public, --team, --invite-only or --private explicitly.", + { + code: "publish_replaced", + hint: "Existing publications remain reachable. Use publish --update for a legacy update. --yes and legacy --public do not convert a project or consent to a new review audience.", + }, + ); + } + return phase; +} + +export function assertLegacyPublishOwner( + phase: ReturnType, + signedIn: boolean, +): void { + if (phase === "share" && !signedIn) + throw new CliUsageError( + "Updating an existing publication requires a signed-in account. Run hyperframes auth login, then retry.", + { + code: "legacy_publish_login_required", + hint: "Without a login, publishing would create a new project instead of updating the existing URL.", + }, + ); +} +function publishNotice(phase: ReturnType, update: boolean): string { + const kept = update + ? " This run uses the legacy update workflow." + : " This run keeps legacy publishing behavior."; + if (phase === "unscheduled") + return ( + "For new video reviews, use hyperframes share. The legacy publish transition date has not been scheduled." + + kept + ); + if (phase === "compatibility") + return ( + "Legacy publish is in its 60-day compatibility window. Use hyperframes share for new video reviews." + + kept + ); + return ( + "New projects use hyperframes share. Existing published URLs and explicit legacy updates remain supported." + + (update ? kept : "") + ); +} diff --git a/packages/cli/src/share/render.lifecycle.test.ts b/packages/cli/src/share/render.lifecycle.test.ts new file mode 100644 index 0000000000..6e05bd29f7 --- /dev/null +++ b/packages/cli/src/share/render.lifecycle.test.ts @@ -0,0 +1,64 @@ +import { afterEach, beforeEach, expect, it, vi } from "vitest"; +import { existsSync, mkdtempSync, realpathSync, readdirSync, rmSync, writeFileSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; +import type { RenderExecutionDependencies } from "../commands/render/execute.js"; +import type { RenderOptions } from "../commands/render.js"; +const mocks = vi.hoisted(() => ({ render: vi.fn(), plan: vi.fn(), execute: vi.fn() })); +vi.mock("@hyperframes/share", () => ({ + projectFingerprint: async () => "unchanged", + shareSourceFingerprint: async () => "unchanged-content", +})); +vi.mock("../commands/render/plan.js", () => ({ createRenderPlan: mocks.plan })); +vi.mock("../commands/render/execute.js", () => ({ executeRenderPlan: mocks.execute })); +vi.mock("../commands/render.js", () => ({ + renderLocal: mocks.render, + checkRenderResolutionPreflight: vi.fn(), +})); +import { latestShareRender, prepareShareRender } from "./render.js"; +let project: string; +const options: RenderOptions = { + fps: { num: 30, den: 1 }, + quality: "standard", + format: "mp4", + gpu: false, + browserGpuMode: "software", + hdrMode: "auto", + quiet: true, + exitAfterComplete: true, +}; +beforeEach(() => { + vi.resetAllMocks(); + project = realpathSync(mkdtempSync(join(tmpdir(), "hf-share-render-lifecycle-"))); + mocks.plan.mockImplementation((plan) => plan); + mocks.execute.mockImplementation( + async (plan: { output: string }, dependencies: RenderExecutionDependencies) => { + await dependencies.renderLocal(project, plan.output, options); + }, + ); + mocks.render.mockImplementation(async (_dir: string, output: string) => { + writeFileSync(output, "rendered-video"); + }); +}); +afterEach(() => rmSync(project, { recursive: true, force: true })); +it("keeps rendering embedded even when the command plan asks to exit", async () => { + await prepareShareRender(project); + expect(mocks.render).toHaveBeenCalledWith( + project, + expect.any(String), + expect.objectContaining({ embedded: true, exitAfterComplete: false }), + undefined, + ); + expect(options.exitAfterComplete).toBe(true); + expect(latestShareRender(project)?.fingerprint).toBe("unchanged"); +}); +it("propagates render failures without publishing a successful artifact record", async () => { + const error = new Error("render failed"); + mocks.render.mockImplementation(async (_dir: string, output: string) => { + writeFileSync(output, "partial-video"); + throw error; + }); + await expect(prepareShareRender(project)).rejects.toBe(error); + expect(existsSync(join(project, ".hyperframes", "share-render.json"))).toBe(false); + expect(readdirSync(join(project, ".hyperframes", "share-renders"))).toEqual([]); +}); diff --git a/packages/cli/src/share/render.test.ts b/packages/cli/src/share/render.test.ts new file mode 100644 index 0000000000..71df8df17e --- /dev/null +++ b/packages/cli/src/share/render.test.ts @@ -0,0 +1,89 @@ +import { mkdtempSync, mkdirSync, realpathSync, rmSync, symlinkSync, writeFileSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { dirname, join } from "node:path"; +import { afterEach, describe, expect, it, vi } from "vitest"; +import { projectFingerprint } from "@hyperframes/share"; +import { latestShareRender, prepareShareRender, shareContentFingerprint } from "./render.js"; +const rendering = vi.hoisted(() => ({ execute: vi.fn() })); +vi.mock("../commands/render/plan.js", () => ({ createRenderPlan: (plan: unknown) => plan })); +vi.mock("../commands/render/execute.js", () => ({ executeRenderPlan: rendering.execute })); +vi.mock("../commands/render.js", () => ({ + renderLocal: vi.fn(), + checkRenderResolutionPreflight: vi.fn(), +})); +const dirs: string[] = []; +function folder() { + const dir = realpathSync(mkdtempSync(join(tmpdir(), "hf-share-"))); + dirs.push(dir); + return dir; +} +afterEach(() => { + for (const dir of dirs.splice(0)) rmSync(dir, { recursive: true, force: true }); +}); +describe("local sharing render boundary", () => { + it("rejects a symlinked state directory before creating descendants", async () => { + const dir = folder(); + const outside = folder(); + writeFileSync(join(dir, "index.html"), ""); + symlinkSync(outside, join(dir, ".hyperframes")); + await expect(prepareShareRender(dir)).rejects.toThrow("without symlinks"); + }); + it("does not accept a sidecar pointing outside the project", () => { + const dir = folder(); + mkdirSync(join(dir, ".hyperframes")); + writeFileSync( + join(dir, ".hyperframes", "share-render.json"), + JSON.stringify({ id: "../../escape", path: "/tmp/escape.mp4", fingerprint: "f" }), + ); + expect(latestShareRender(dir)).toBeNull(); + }); + it("reuses only the exact locally recorded file", () => { + const dir = folder(); + const id = "41c4587b-abcd-42ab-87ab-21a7b64cc010"; + const output = join(dir, ".hyperframes", "share-renders", `${id}.mp4`); + mkdirSync(join(dir, ".hyperframes", "share-renders"), { recursive: true }); + writeFileSync(output, "video"); + writeFileSync( + join(dir, ".hyperframes", "share-render.json"), + JSON.stringify({ id, path: output, fingerprint: "f" }), + ); + expect(latestShareRender(dir)).toEqual({ id, path: output, fingerprint: "f" }); + }); + it.each([".media/voice.mp3", ".hyperframes/studio-manual-edits.json"])( + "invalidates a cached render when %s changes", + async (path) => { + const dir = folder(); + writeFileSync(join(dir, "index.html"), ''); + mkdirSync(dirname(join(dir, path)), { recursive: true }); + writeFileSync(join(dir, path), "original"); + rendering.execute.mockImplementation(async ({ output }: { output: string }) => { + writeFileSync(output, "rendered video"); + }); + await prepareShareRender(dir); + const original = latestShareRender(dir); + const watcher = await projectFingerprint(dir); + await prepareShareRender(dir); + expect(latestShareRender(dir)?.id).toBe(original?.id); + writeFileSync(join(dir, path), "changed"); + expect(await projectFingerprint(dir)).toBe(watcher); + expect(await shareContentFingerprint(dir)).not.toBe(original?.contentFingerprint); + await prepareShareRender(dir); + expect(latestShareRender(dir)?.id).not.toBe(original?.id); + }, + ); +}); + +it("reuses the video when only a scratch log is added", async () => { + const dir = folder(); + writeFileSync(join(dir, "index.html"), ""); + rendering.execute.mockImplementation(async ({ output }: { output: string }) => + writeFileSync(output, "video"), + ); + await prepareShareRender(dir); + const original = latestShareRender(dir); + rendering.execute.mockClear(); + writeFileSync(join(dir, "other.log"), "scratch output"); + await prepareShareRender(dir); + expect(rendering.execute).not.toHaveBeenCalled(); + expect(latestShareRender(dir)?.id).toBe(original?.id); +}); diff --git a/packages/cli/src/share/render.ts b/packages/cli/src/share/render.ts new file mode 100644 index 0000000000..fc9bb17550 --- /dev/null +++ b/packages/cli/src/share/render.ts @@ -0,0 +1,115 @@ +import { randomUUID } from "node:crypto"; +import { existsSync, readFileSync, realpathSync } from "node:fs"; +import { mkdir, writeFile, rename, rm } from "node:fs/promises"; +import { join } from "node:path"; +import { projectFingerprint, shareSourceFingerprint } from "@hyperframes/share"; + +export const shareContentFingerprint = shareSourceFingerprint; + +export interface ShareRender { + path: string; + id: string; + fingerprint: string; + contentFingerprint?: string; +} + +export function latestShareRender(dir: string): ShareRender | null { + try { + const value: unknown = JSON.parse( + readFileSync(join(dir, ".hyperframes", "share-render.json"), "utf8"), + ); + if ( + !value || + typeof value !== "object" || + !("path" in value) || + !("id" in value) || + !("fingerprint" in value) + ) + return null; + if ( + typeof value.path !== "string" || + typeof value.id !== "string" || + typeof value.fingerprint !== "string" || + !/^[a-f0-9-]{36}$/.test(value.id) + ) + return null; + const expected = join(realpathSync(dir), ".hyperframes", "share-renders", `${value.id}.mp4`); + if (value.path !== expected || !existsSync(expected) || realpathSync(expected) !== expected) + return null; + const contentFingerprint = + "contentFingerprint" in value && typeof value.contentFingerprint === "string" + ? value.contentFingerprint + : undefined; + return { + path: expected, + id: value.id, + fingerprint: value.fingerprint, + ...(contentFingerprint && { contentFingerprint }), + }; + } catch { + return null; + } +} + +export async function prepareShareRender(dir: string): Promise { + const [before, content] = await Promise.all([ + projectFingerprint(dir), + shareContentFingerprint(dir), + ]); + const previous = latestShareRender(dir); + if (content && previous?.fingerprint === before && previous.contentFingerprint === content) + return; + const stateFolder = join(dir, ".hyperframes"); + if (existsSync(stateFolder) && realpathSync(stateFolder) !== stateFolder) + throw new Error("Sharing state must stay inside this project, without symlinks."); + await mkdir(stateFolder, { recursive: true }); + const folder = join(stateFolder, "share-renders"); + if (existsSync(folder) && realpathSync(folder) !== folder) + throw new Error("Sharing state must stay inside this project, without symlinks."); + await mkdir(folder, { recursive: true }); + if (realpathSync(folder) !== folder) + throw new Error("Sharing state must stay inside this project, without symlinks."); + const id = randomUUID(); + const output = join(folder, `${id}.mp4`); + const [{ createRenderPlan }, { executeRenderPlan }, render] = await Promise.all([ + import("../commands/render/plan.js"), + import("../commands/render/execute.js"), + import("../commands/render.js"), + ]); + const target = join(stateFolder, "share-render.json"); + const temporary = `${target}.${id}.tmp`; + try { + const plan = createRenderPlan({ dir, output, format: "mp4", quiet: true, strict: true }); + await executeRenderPlan(plan, { + renderLocal: (project, output, options, cancellation) => + render.renderLocal( + project, + output, + { ...options, embedded: true, exitAfterComplete: false }, + cancellation, + ), + renderDocker: async () => { + throw new Error("Share renders locally."); + }, + checkResolution: render.checkRenderResolutionPreflight, + }); + if (!existsSync(output)) + throw new Error("The render did not produce a video. Run hyperframes render to diagnose it."); + const [after, afterContent] = await Promise.all([ + projectFingerprint(dir), + shareContentFingerprint(dir), + ]); + if (after !== before || afterContent !== content) + throw new Error( + "The project changed while rendering. Share again to capture the current project.", + ); + await writeFile( + temporary, + JSON.stringify({ id, path: output, fingerprint: before, contentFingerprint: content }), + ); + await rename(temporary, target); + } catch (error) { + await Promise.allSettled([rm(output, { force: true }), rm(temporary, { force: true })]); + throw error; + } +} diff --git a/packages/cli/src/share/service.test.ts b/packages/cli/src/share/service.test.ts new file mode 100644 index 0000000000..082af5f0ce --- /dev/null +++ b/packages/cli/src/share/service.test.ts @@ -0,0 +1,522 @@ +import { beforeEach, describe, expect, it, vi } from "vitest"; +vi.mock("./activity.js", () => ({ + readShareActivity: () => mocks.activity(), + withShareActivity: async (_dir: string, run: (phase: () => Promise) => Promise) => + run(async () => {}), +})); +const mocks = vi.hoisted(() => ({ + source: vi.fn(), + activity: vi.fn(), + status: vi.fn(), + version: vi.fn(), + record: vi.fn(), + project: vi.fn(), + spaces: vi.fn(), + flags: vi.fn(), + render: vi.fn(), + create: vi.fn(), + add: vi.fn(), + pending: vi.fn(), + refresh: vi.fn(), + event: vi.fn(), + access: vi.fn(), + setAccess: vi.fn(), +})); +vi.mock("@hyperframes/share", () => ({ + reviewClient: () => ({ project: mocks.project, spaces: mocks.spaces, reviewFlags: mocks.flags }), + reviewStatus: mocks.status, + reviewVersion: mocks.version, + reviewRecord: mocks.record, + shareForReview: mocks.create, + addVersion: mocks.add, + pendingReviewExport: mocks.pending, + refreshReviewExport: mocks.refresh, + setReviewAccess: mocks.setAccess, + turnOffReviewLink: vi.fn(), + ReviewFailed: class extends Error { + constructor( + public status: number, + public reason: string, + ) { + super(reason); + } + }, +})); +vi.mock("./auth.js", () => ({ + createShareAccess: () => ({ access: mocks.access }), + shareSite: () => "https://hyperframes.dev", +})); +vi.mock("./host.js", () => ({ + assertReviewUploadStorage: vi.fn(), + bindCliShareProject: (path: string) => path, +})); +vi.mock("./sources.js", () => ({ + prepareCliShareSource: mocks.source, + uncheckedSource: () => ({ at: "not_checked" }), +})); +vi.mock("./render.js", () => ({ prepareShareRender: mocks.render })); +vi.mock("../telemetry/client.js", () => ({ + trackEvent: mocks.event, + resetTelemetryPostureCache: vi.fn(), +})); +vi.mock("../telemetry/config.js", () => ({ readConfigFresh: vi.fn() })); +import { createShareService } from "./service.js"; +const shared = { + projectId: "project", + url: "https://hyperframes.dev/review/link", + access: "public", + space: { id: "space" }, +}; +beforeEach(() => { + vi.resetAllMocks(); + mocks.activity.mockResolvedValue(null); + mocks.status.mockResolvedValue(null); + mocks.record.mockResolvedValue(null); + mocks.pending.mockResolvedValue(null); + mocks.version.mockResolvedValue({ last: null, source: "ready" }); + mocks.project.mockResolvedValue({ latest_ready_version_id: "version-id" }); + mocks.flags.mockResolvedValue({ versionSharing: true }); + mocks.spaces.mockResolvedValue([ + { + space_id: "space", + bound: true, + can_create_review: true, + review_entitlements: { + can_register_project: true, + allowed_collaborative_access_modes: ["public"], + }, + }, + ]); +}); +describe("share operation consent and identity", () => { + it("reads an existing link without rendering or creating a version", async () => { + mocks.status.mockResolvedValue(shared); + expect((await createShareService("/project").run({ action: "share" })).url).toBe(shared.url); + expect(mocks.render).not.toHaveBeenCalled(); + expect(mocks.create).not.toHaveBeenCalled(); + expect(mocks.add).not.toHaveBeenCalled(); + }); + it("never chooses an audience for unattended first share", async () => { + await expect(createShareService("/project").run({ action: "share" })).rejects.toMatchObject({ + code: "audience_required", + }); + expect(mocks.render).not.toHaveBeenCalled(); + expect(mocks.create).not.toHaveBeenCalled(); + }); + it("checks free quota before rendering", async () => { + mocks.spaces.mockResolvedValue([ + { + space_id: "space", + bound: true, + can_create_review: true, + review_entitlements: { can_register_project: false }, + }, + ]); + await expect( + createShareService("/project").run({ action: "share", audience: "public" }), + ).rejects.toMatchObject({ reason: "review_project_limit_reached" }); + expect(mocks.render).not.toHaveBeenCalled(); + }); + it("preserves existing workspace and changes an explicitly requested audience", async () => { + mocks.status.mockResolvedValue(shared); + const service = createShareService("/project"); + await expect(service.run({ action: "update", space: "other" })).rejects.toMatchObject({ + reason: "workspace_mismatch", + }); + mocks.setAccess.mockImplementation(async () => + mocks.status.mockResolvedValue({ ...shared, access: "private" }), + ); + await service.run({ action: "share", audience: "private" }); + expect(mocks.setAccess).toHaveBeenCalledWith( + expect.objectContaining({ change: { access: "private" } }), + ); + expect(mocks.add).not.toHaveBeenCalled(); + expect(mocks.render).not.toHaveBeenCalled(); + }); + it("refuses a public share opened while a private first share was rendering", async () => { + mocks.render.mockImplementation(async () => { + mocks.create.mockResolvedValue(shared); + }); + + await expect( + createShareService("/project").run({ action: "share", audience: "private" }), + ).rejects.toMatchObject({ reason: "manage_existing_audience" }); + expect(mocks.add).not.toHaveBeenCalled(); + }); + it("refuses a first share bound to another workspace during rendering", async () => { + mocks.render.mockImplementation(async () => { + mocks.create.mockResolvedValue({ ...shared, space: { id: "other" } }); + }); + + await expect( + createShareService("/project").run({ action: "share", audience: "public", space: "space" }), + ).rejects.toMatchObject({ reason: "workspace_mismatch" }); + expect(mocks.add).not.toHaveBeenCalled(); + }); + it("refuses an update when the folder changes review projects during rendering", async () => { + mocks.status.mockResolvedValue(shared); + mocks.render.mockImplementation(async () => { + mocks.status.mockResolvedValue({ ...shared, projectId: "different-project" }); + }); + + await expect(createShareService("/project").run({ action: "update" })).rejects.toMatchObject({ + reason: "review_binding_changed", + }); + expect(mocks.add).not.toHaveBeenCalled(); + }); + it("refuses an update when access changes during rendering", async () => { + mocks.status.mockResolvedValue({ ...shared, access: "private" }); + mocks.render.mockImplementation(async () => { + mocks.status.mockResolvedValue(shared); + }); + + await expect(createShareService("/project").run({ action: "update" })).rejects.toMatchObject({ + reason: "manage_existing_audience", + }); + expect(mocks.add).not.toHaveBeenCalled(); + }); + it("pins the approved project into a first upload", async () => { + mocks.create.mockImplementation(async () => { + mocks.status.mockResolvedValue(shared); + return shared; + }); + mocks.add.mockResolvedValue(null); + + await createShareService("/project").run({ action: "share", audience: "public" }); + + expect(mocks.create).toHaveBeenCalledWith(expect.objectContaining({ spaceId: "space" })); + expect(mocks.add).toHaveBeenCalledWith(expect.objectContaining({ projectId: "project" })); + }); + it("retries an unfinished first share in its saved workspace", async () => { + mocks.record.mockResolvedValue({ spaceId: "saved", projectId: "project" }); + mocks.spaces.mockResolvedValue([ + { space_id: "space", bound: true, can_create_review: true }, + { space_id: "saved", can_create_review: true }, + ]); + mocks.create.mockImplementation(async () => { + const saved = { ...shared, space: { id: "saved" }, access: "private" }; + mocks.status.mockResolvedValue(saved); + return saved; + }); + mocks.add.mockResolvedValue(null); + const service = createShareService("/project"); + + await expect( + service.run({ action: "share", audience: "private", space: "space" }), + ).rejects.toMatchObject({ reason: "workspace_mismatch" }); + expect(mocks.render).not.toHaveBeenCalled(); + await service.run({ action: "share", audience: "private" }); + expect(mocks.create).toHaveBeenCalledWith(expect.objectContaining({ spaceId: "saved" })); + expect(mocks.add).toHaveBeenCalledWith(expect.objectContaining({ projectId: "project" })); + }); + it("does not report a different project's link if the folder changes during upload", async () => { + mocks.status.mockResolvedValue(shared); + mocks.add.mockImplementation(async () => { + mocks.status.mockResolvedValue({ ...shared, projectId: "different-project" }); + return null; + }); + + await expect(createShareService("/project").run({ action: "update" })).rejects.toMatchObject({ + reason: "review_binding_changed", + }); + expect(mocks.add).toHaveBeenCalledWith(expect.objectContaining({ projectId: "project" })); + }); + it("does not label an old ready version as a completed update", async () => { + mocks.status.mockResolvedValue(shared); + mocks.add.mockResolvedValue(null); + mocks.version.mockResolvedValue({ last: { current: false }, source: "ready" }); + const result = await createShareService("/project").run({ action: "update" }); + expect(result).toMatchObject({ state: "processing", ready: false, url: null }); + }); + it("reports rejection discovered after the upload watch ends", async () => { + mocks.status.mockResolvedValue(shared); + mocks.add.mockResolvedValue(null); + mocks.refresh.mockResolvedValueOnce(undefined).mockImplementationOnce(async () => { + mocks.version.mockResolvedValue({ last: null, source: "ready", failure: "Video rejected." }); + }); + + await expect(createShareService("/project").run({ action: "update" })).rejects.toThrow( + "Video rejected.", + ); + }); + it("keeps the kernel's default source callback for a video-only update", async () => { + mocks.status.mockResolvedValue(shared); + mocks.flags.mockResolvedValue({ versionSharing: true, shareFiles: true }); + mocks.add.mockResolvedValue(null); + + const result = await createShareService("/project").run({ action: "update", videoOnly: true }); + + expect(result.source).toEqual({ at: "video_only", reason: "requested" }); + expect(mocks.add).toHaveBeenCalledOnce(); + expect(mocks.add.mock.calls[0]?.[0]).not.toHaveProperty("filesForExport"); + expect(mocks.add).toHaveBeenCalledWith(expect.objectContaining({ omitSource: true })); + }); + it("does not silently upload changed edits while resuming first share", async () => { + mocks.status.mockResolvedValue(shared); + mocks.project.mockResolvedValue({ latest_ready_version_id: null }); + mocks.version.mockResolvedValue({ last: null, source: "stale" }); + mocks.pending.mockResolvedValue({ projectId: "project", videoId: "upload" }); + await expect(createShareService("/project").run({ action: "share" })).rejects.toThrow( + "--update", + ); + expect(mocks.render).not.toHaveBeenCalled(); + expect(mocks.add).not.toHaveBeenCalled(); + }); + it("keeps an off link off on repeat share", async () => { + mocks.status.mockResolvedValue({ ...shared, url: null }); + expect((await createShareService("/project").run({ action: "share" })).state).toBe("link_off"); + expect(mocks.create).not.toHaveBeenCalled(); + }); +}); + +describe("asynchronous share recovery", () => { + it("reconciles completion before reading project and local status", async () => { + mocks.status.mockResolvedValue(shared); + mocks.pending.mockResolvedValue({ projectId: "project", videoId: "video-id" }); + mocks.refresh.mockImplementation(async () => { + mocks.pending.mockResolvedValue(null); + }); + const result = await createShareService("/project").run({ action: "status" }); + expect(mocks.refresh).toHaveBeenCalledOnce(); + expect(mocks.refresh.mock.invocationCallOrder[0]).toBeLessThan( + mocks.project.mock.invocationCallOrder[0] ?? 0, + ); + expect(result).toMatchObject({ state: "ready", ready: true, url: shared.url }); + expect(mocks.add).not.toHaveBeenCalled(); + expect(mocks.render).not.toHaveBeenCalled(); + }); + it("keeps an active upload processing even if unrelated IDs happen to match", async () => { + mocks.status.mockResolvedValue(shared); + mocks.pending.mockResolvedValue({ projectId: "project", videoId: "version-id" }); + expect(await createShareService("/project").status()).toMatchObject({ + state: "processing", + ready: false, + url: null, + }); + }); +}); +describe("share rollout signals", () => { + const events = () => mocks.event.mock.calls.map(([name]) => name); + it("records a completed video even when its review link is disabled", async () => { + mocks.status.mockResolvedValue({ ...shared, url: null }); + mocks.add.mockImplementation(async (request) => request.onAdded()); + const result = await createShareService("/secret").run({ action: "update" }); + expect(result.state).toBe("link_off"); + expect(events()).toContain("share_video_ready"); + expect(events()).not.toContain("share_mutation_processing"); + }); + it("records the allowlisted missing-audience usage reason", async () => { + await expect(createShareService("/secret").run({ action: "share" })).rejects.toMatchObject({ + code: "audience_required", + }); + expect(mocks.event.mock.lastCall?.[1]).toMatchObject({ reason: "audience_required" }); + }); + it("records recovery before refreshing a completed pending upload clears its state", async () => { + mocks.status.mockResolvedValue(shared); + mocks.pending.mockResolvedValue({ projectId: "project", videoId: "pending" }); + mocks.refresh.mockImplementation(async () => mocks.pending.mockResolvedValue(null)); + await createShareService("/secret").run({ action: "share" }); + expect(events()).toContain("share_recovery_attempted"); + expect(mocks.event.mock.lastCall?.[1]).toMatchObject({ recovery: true }); + expect(events()).not.toContain("share_video_ready"); + expect(mocks.add).not.toHaveBeenCalled(); + }); + it("records only verified upload admission and ready, attributed to local Studio", async () => { + mocks.status.mockResolvedValue(shared); + mocks.add.mockImplementation(async (request) => { + request.onProgress({ step: "preparing", sent: 0, total: 0 }); + request.onProgress({ step: "uploading", sent: 1, total: 2 }); + request.onProgress({ step: "processing", sent: 2, total: 2 }); + request.onAdded(); + }); + await createShareService("/private/project", undefined, { surface: "local_studio" }).run({ + action: "update", + }); + expect(events()).toEqual([ + "share_mutation_attempted", + "share_mutation_authenticated", + "share_mutation_admitted", + "share_video_ready", + ]); + expect(mocks.event.mock.calls.every(([, data]) => data.client_surface === "local_studio")).toBe( + true, + ); + expect(new Set(mocks.event.mock.calls.map(([, data]) => data.attempt_id)).size).toBe(1); + }); + it("counts quota refusal without admission, rendering, or raw error details", async () => { + mocks.spaces.mockResolvedValue([ + { + space_id: "space", + bound: true, + can_create_review: true, + review_entitlements: { can_register_project: false }, + }, + ]); + await expect( + createShareService("/secret").run({ action: "share", audience: "public" }), + ).rejects.toBeDefined(); + expect(events()).toEqual([ + "share_mutation_attempted", + "share_mutation_authenticated", + "share_mutation_failed", + ]); + expect(mocks.event.mock.lastCall?.[1]).toMatchObject({ + reason: "review_project_limit_reached", + }); + expect(mocks.render).not.toHaveBeenCalled(); + }); + it("records pending recovery without labeling the prior ready version new", async () => { + mocks.status.mockResolvedValue(shared); + mocks.pending.mockResolvedValue({ projectId: "project", videoId: "pending" }); + mocks.add.mockResolvedValue(null); + mocks.version.mockResolvedValue({ last: { current: false }, source: "ready" }); + await createShareService("/secret").run({ action: "update" }); + expect(events()).toContain("share_recovery_attempted"); + expect(events()).toContain("share_mutation_processing"); + expect(events()).not.toContain("share_video_ready"); + expect(mocks.event.mock.lastCall?.[1]).toMatchObject({ recovery: true }); + }); + it("existing-link retrieval and polling never count as a new video or copied link", async () => { + mocks.status.mockResolvedValue(shared); + const service = createShareService("/secret"); + await service.run({ action: "status" }); + expect(events()).toEqual([]); + await service.run({ action: "share" }); + expect(events()).toEqual([ + "share_mutation_attempted", + "share_mutation_authenticated", + "share_existing_link_returned", + ]); + }); + it("stops entry creation on authoritative rollback while keeping existing links readable", async () => { + mocks.flags.mockResolvedValue({ versionSharing: false }); + await expect( + createShareService("/secret").run({ action: "share", audience: "public" }), + ).rejects.toMatchObject({ reason: "feature_unavailable" }); + expect(mocks.render).not.toHaveBeenCalled(); + expect(mocks.create).not.toHaveBeenCalled(); + mocks.status.mockResolvedValue(shared); + expect((await createShareService("/secret").run({ action: "share" })).ready).toBe(true); + }); +}); + +it("link reactivation cannot bypass the first-share rollout gate", async () => { + mocks.flags.mockResolvedValue({ versionSharing: false }); + await expect(createShareService("/secret").linkOn()).rejects.toMatchObject({ + reason: "not_shared", + }); + expect(mocks.create).not.toHaveBeenCalled(); +}); + +it.each([null, "previous-version"])( + "keeps a terminal failure separate from ready version %s", + async (latest) => { + mocks.status.mockResolvedValue(shared); + mocks.project.mockResolvedValue({ latest_ready_version_id: latest }); + mocks.version.mockResolvedValue({ + last: null, + source: "ready", + failure: "This video can't be shared.", + }); + const result = await createShareService("/project").run({ action: "status" }); + expect(result).toMatchObject({ + state: "failed", + ready: false, + url: null, + previousUrl: latest ? shared.url : null, + }); + expect(mocks.add).not.toHaveBeenCalled(); + }, +); + +it("retries an uncreated first version after refusal even when local files changed", async () => { + mocks.status.mockResolvedValue(shared); + mocks.project.mockResolvedValue({ latest_ready_version_id: null }); + mocks.version.mockResolvedValue({ last: null, source: "stale", failure: "Sharing blocked." }); + mocks.add.mockResolvedValue("Sharing blocked."); + await expect( + createShareService("/project").run({ action: "share", audience: "public" }), + ).rejects.toThrow("Sharing blocked."); + expect(mocks.render).toHaveBeenCalledOnce(); + expect(mocks.add).toHaveBeenCalledOnce(); + expect(mocks.create).not.toHaveBeenCalled(); +}); + +it("reports an unchanged completed update without claiming a new version", async () => { + mocks.status.mockResolvedValue(shared); + mocks.version.mockResolvedValue({ last: { current: true }, source: "ready" }); + mocks.add.mockResolvedValue(null); + const result = await createShareService("/project").run({ action: "update" }); + expect(result.upToDate).toBe(true); +}); +it("propagates a refused audience change without rendering", async () => { + mocks.status.mockResolvedValue(shared); + mocks.setAccess.mockRejectedValue(new Error("Restricted sharing requires a subscription")); + await expect( + createShareService("/project").run({ action: "share", audience: "team" }), + ).rejects.toThrow("subscription"); + expect(mocks.render).not.toHaveBeenCalled(); +}); + +it("does not label a newly published version as already up to date", async () => { + mocks.status.mockResolvedValue(shared); + mocks.version.mockResolvedValue({ last: { current: true }, source: "ready" }); + mocks.add.mockImplementation(async ({ onAdded }) => { + onAdded(); + return null; + }); + expect(await createShareService("/project").run({ action: "update" })).toMatchObject({ + upToDate: false, + }); +}); +it("does not label a still-processing update as already up to date", async () => { + mocks.status.mockResolvedValue(shared); + mocks.version.mockResolvedValue({ last: { current: true }, source: "ready" }); + mocks.pending.mockResolvedValue({ projectId: "project" }); + mocks.add.mockResolvedValue(null); + expect(await createShareService("/project").run({ action: "update" })).toMatchObject({ + upToDate: false, + }); +}); + +it("does not claim to check freshness in status", async () => { + mocks.status.mockResolvedValue(shared); + expect(await createShareService("/project").run({ action: "status" })).not.toHaveProperty( + "upToDate", + ); +}); + +it("reports local rendering instead of the previous ready version", async () => { + mocks.status.mockResolvedValue(shared); + mocks.activity.mockResolvedValue({ step: "rendering", startedAt: "2026-11-10T00:00:00Z" }); + const state = await createShareService("/project").run({ action: "status" }); + expect(state).toMatchObject({ + state: "rendering", + ready: false, + url: null, + previousUrl: shared.url, + }); + expect(mocks.render).not.toHaveBeenCalled(); +}); +it("reports the first share while it has no server project yet", async () => { + mocks.activity.mockResolvedValue({ step: "uploading_source", startedAt: "2026-11-10T00:00:00Z" }); + expect(await createShareService("/project").run({ action: "status" })).toMatchObject({ + state: "uploading_source", + ready: false, + url: null, + }); +}); + +it.each([false, true])( + "only prepares source after affirmative consent (%s)", + async (includeSource) => { + mocks.status.mockResolvedValue(shared); + mocks.flags.mockResolvedValue({ versionSharing: true, shareFiles: true }); + mocks.source.mockResolvedValue({ + source: { at: "video_only", reason: "source_plan_required" }, + requireSource: false, + }); + await createShareService("/project").run({ action: "update", includeSource }); + expect(mocks.source).toHaveBeenCalledTimes(includeSource ? 1 : 0); + }, +); diff --git a/packages/cli/src/share/service.ts b/packages/cli/src/share/service.ts new file mode 100644 index 0000000000..3a1b779db6 --- /dev/null +++ b/packages/cli/src/share/service.ts @@ -0,0 +1,374 @@ +import { + readShareActivity, + withShareActivity, + type ShareActivity, + type SharePhase, +} from "./activity.js"; +import { basename } from "node:path"; +import { CliUsageError } from "../utils/commandResult.js"; +import { + addVersion, + pendingReviewExport, + refreshReviewExport, + reviewClient, + reviewRecord, + reviewStatus, + reviewVersion, + shareForReview, + setReviewAccess, + turnOffReviewLink, + ReviewFailed, + type AccessMode, + type ReviewClient, + type ReviewExportProgress, + type ReviewShare, +} from "@hyperframes/share"; +import { createShareAccess, shareSite } from "./auth.js"; +import { assertReviewUploadStorage, bindCliShareProject } from "./host.js"; +import { prepareShareRender } from "./render.js"; +import { prepareCliShareSource, uncheckedSource, type PreparedShareSource } from "./sources.js"; +import { observeShareMutation, type ShareAttempt, type ShareSurface } from "./telemetry.js"; + +export interface ShareAction { + action: "share" | "update" | "status" | "manage"; + audience?: AccessMode; + space?: string; + waitSeconds?: number; + videoOnly?: boolean; + includeSource?: boolean; +} +function linkState(share: ReviewShare | null, ready: boolean, failed: boolean): string { + if (!share) return "not_shared"; + if (failed) return "failed"; + if (!share.url) return "link_off"; + return ready ? "ready" : "processing"; +} +async function refreshShare( + dir: string, + client: ReviewClient, + expectedProjectId?: string, + onRecovery?: (pending: boolean) => void, +) { + const share = await reviewStatus({ projectPath: dir, client }); + if (expectedProjectId) assertUploadProject(share, expectedProjectId); + if (onRecovery) onRecovery(isProcessing(await pendingReviewExport(dir), share)); + if (share) await refreshReviewExport(dir, client); + return share; +} +async function readStatus( + dir: string, + client: ReviewClient, + expectedProjectId?: string, + onRecovery?: (pending: boolean) => void, +) { + const share = await refreshShare(dir, client, expectedProjectId, onRecovery); + const project = await readProject(share, client); + const latest = project?.latest_ready_version_id ?? null; + const version = await reviewVersion(dir, { latestReadyVersionId: latest }); + const pending = await pendingReviewExport(dir); + const activeUrl = share?.url ?? null; + const processing = isProcessing(pending, share); + const failed = hasFailedVersion(version); + const ready = Boolean(activeUrl && latest && !processing && !failed); + return { + share, + version, + pending, + state: linkState(share, ready, failed), + ready, + source: uncheckedSource(), + ...statusLinks(activeUrl, ready, processing || failed, project), + }; +} +async function readProject(share: ReviewShare | null, client: ReviewClient) { + return share?.projectId ? client.project(share.projectId) : null; +} +function statusLinks( + url: string | null, + ready: boolean, + processing: boolean, + project: Awaited>, +) { + return { + url: ready ? url : null, + previousUrl: processing && project?.latest_ready_version_id ? url : null, + manageUrl: + project?.authenticated_review_url ?? + `${shareSite() === "https://hyperframes.dev" ? "https://hyperframes.studio" : shareSite()}/shares`, + }; +} +function isProcessing( + pending: Awaited>, + share: ReviewShare | null, +) { + return Boolean(pending && pending.projectId === share?.projectId); +} +function selectSpace(spaces: Awaited>, id?: string) { + if (id) return spaces.find((space) => space.space_id === id); + return spaces.find((space) => space.bound) ?? spaces.find((space) => space.kind === "personal"); +} +function assertUploadProject( + share: ReviewShare | null, + expectedId?: string, +): asserts share is ReviewShare & { projectId: string } { + const id = share?.projectId; + if (!id || (expectedId && id !== expectedId)) + throw new ReviewFailed(409, "review_binding_changed"); +} +function assertExistingIntent(share: ReviewShare | null, input: ShareAction) { + if (!share) { + if (input.action === "update") throw new ReviewFailed(404, "not_shared"); + return; + } + if (input.space && share.space?.id !== input.space) + throw new ReviewFailed(409, "workspace_mismatch"); + if (input.audience && share.access !== input.audience) + throw new ReviewFailed(409, "manage_existing_audience"); +} +function retrievesExisting(current: ShareState, input: ShareAction) { + return ( + current.share && + input.action === "share" && + (current.ready || + current.state === "link_off" || + (current.version.last && current.state !== "processing")) + ); +} +async function preflightFirst(dir: string, client: ReviewClient, input: ShareAction) { + const audience = input.audience; + if (!audience) + throw new CliUsageError( + "Choose an audience with --public, --team, --invite-only or --private.", + { code: "audience_required" }, + ); + const [spaces, record] = await Promise.all([client.spaces(), reviewRecord(dir)]); + const space = selectSpace(spaces, registrationSpace(record, input.space)); + if (!space || !space.can_create_review) throw new ReviewFailed(403, "workspace_cannot_share"); + assertQuota(record, space); + assertAudience(audience, space); + return space.space_id; +} +type Space = Awaited>[number]; +type ShareRecord = Awaited>; +function registrationSpace(record: ShareRecord, requested?: string) { + if (!record?.spaceId) return requested; + if (!requested || requested === record.spaceId) return record.spaceId; + if (record.registration || record.projectId) throw new ReviewFailed(409, "workspace_mismatch"); + return requested; +} +function assertQuota(record: ShareRecord, space: Space) { + if (record?.registration || record?.projectId) return; + if (space.review_entitlements?.can_register_project === false) + throw new ReviewFailed(402, "review_project_limit_reached"); +} +function assertAudience(audience: AccessMode, space: Space) { + if (audience === "private") return; + if (!space.review_entitlements?.allowed_collaborative_access_modes.includes(audience)) + throw new ReviewFailed(402, "review_subscription_required"); +} +function assertResumeSource(current: ShareState, input: ShareAction) { + if ( + current.share && + current.pending && + input.action === "share" && + current.version.source !== "ready" + ) + throw new Error( + "The shared video is unfinished and local edits have changed. Run hyperframes share --update to explicitly upload the current project.", + ); +} +export function createShareService( + projectPath: string, + progress: (value: ReviewExportProgress | null) => void = () => {}, + options: { surface?: ShareSurface; pinIdentity?: boolean } = {}, +) { + const dir = bindCliShareProject(projectPath); + const auth = createShareAccess(options.pinIdentity); + const client = reviewClient(auth); + const status = async (expectedProjectId?: string): Promise => { + await auth.access(); + const current = await readStatus(dir, client, expectedProjectId); + const activity = expectedProjectId ? null : await readShareActivity(dir); + return activity + ? { + ...current, + activity, + state: activity.step, + ready: false, + previousUrl: current.url ?? current.previousUrl, + url: null, + } + : current; + }; + const upload = async ( + input: ShareAction, + projectId: string, + sources: PreparedShareSource, + attempt: ShareAttempt, + phase: (step: SharePhase) => Promise, + ) => { + const end = Date.now() + (input.waitSeconds ?? 300) * 1000; + let added = false; + const failure = await addVersion({ + projectPath: dir, + projectId, + title: basename(dir), + client, + onProgress: (value) => { + attempt.progress(value); + progress(value); + if (value?.step === "checking") void phase("checking"); + }, + allowPending: true, + ...(sources.filesForExport && { filesForExport: sources.filesForExport }), + requireSource: sources.requireSource, + omitSource: sources.source.at === "video_only", + onAdded: () => { + added = true; + }, + open: () => Date.now() < end, + }); + if (failure) throw new Error(failure); + const result = { ...(await status(projectId)), source: sources.source }; + if (result.version.failure) throw new Error(result.version.failure); + if (!added && !result.version.last?.current) { + attempt.complete(false, added); + return { ...result, state: "processing", ready: false, url: null }; + } + attempt.complete(result.ready, added); + return { + ...result, + upToDate: isUnchangedUpdate(input, added, result), + updated: input.action === "update" && added, + }; + }; + const uploadTarget = async (current: ReviewShare | null, input: ShareAction, space?: string) => { + const share = current + ? await reviewStatus({ projectPath: dir, client }) + : await shareForReview({ + projectPath: dir, + title: basename(dir), + client, + spaceId: space, + audience: input.audience, + }); + assertUploadProject(share, current?.projectId); + if (share.takedown) throw new ReviewFailed(409, "moderation_hold"); + assertExistingIntent(share, { + ...input, + space: input.space ?? space, + audience: input.audience ?? current?.access, + }); + return { projectId: share.projectId, spaceId: share.space?.id, audience: share.access }; + }; + const checkPreparedTarget = async (target: Awaited>) => { + const share = await reviewStatus({ projectPath: dir, client }); + assertUploadProject(share, target.projectId); + if (share.takedown) throw new ReviewFailed(409, "moderation_hold"); + assertExistingIntent(share, { + action: "update", + space: target.spaceId, + audience: target.audience, + }); + }; + const mutate = async ( + input: ShareAction, + attempt: ShareAttempt, + phase: (step: SharePhase) => Promise, + ): Promise => { + await auth.access(); + attempt.authenticated(); + let current = await readStatus(dir, client, undefined, attempt.recover); + if (current.share && input.audience && changesAudience(input, current.share)) { + assertExistingIntent(current.share, { ...input, audience: undefined }); + const projectId = current.share.projectId; + await setReviewAccess({ projectPath: dir, client, change: { access: input.audience } }); + current = await readStatus(dir, client, projectId); + assertExistingIntent(current.share, input); + attempt.retrieved(); + return current; + } + assertExistingIntent(current.share, input); + if (retrievesExisting(current, input)) { + attempt.retrieved(); + return current; + } + const flags = await client.reviewFlags(); + if (!flags.versionSharing) throw new ReviewFailed(403, "feature_unavailable"); + const space = current.share + ? current.share.space?.id + : await preflightFirst(dir, client, input); + assertResumeSource(current, input); + assertReviewUploadStorage(); + await phase("rendering"); + await prepareShareRender(dir); + const target = await uploadTarget(current.share, input, space); + await phase("uploading_source"); + const sources = await prepareSelectedSource( + dir, + auth.access, + target.spaceId, + input, + flags.shareFiles, + ); + if (sources.requireSource) await checkPreparedTarget(target); + await phase("uploading_video"); + return upload(input, target.projectId, sources, attempt, phase); + }; + return { + checkSession: (verifyIdentity = false) => auth.access(undefined, verifyIdentity), + status, + run: (input: ShareAction) => + input.action === "status" || input.action === "manage" + ? status() + : observeShareMutation(input.action, options.surface ?? "cli", (attempt) => + withShareActivity(dir, (phase) => mutate(input, attempt, phase)), + ), + capabilities: () => client.reviewFlags(), + spaces: () => client.spaces(), + setAccess: async (access: AccessMode) => { + await setReviewAccess({ projectPath: dir, client, change: { access } }); + return status(); + }, + linkOff: async () => { + await turnOffReviewLink({ projectPath: dir, client }); + return status(); + }, + linkOn: async () => { + if (!(await status()).share) throw new ReviewFailed(404, "not_shared"); + await shareForReview({ projectPath: dir, title: basename(dir), client }); + return status(); + }, + }; +} +export type ShareService = ReturnType; +export type ShareState = Awaited> & { + upToDate?: boolean; + updated?: boolean; + activity?: ShareActivity; +}; + +function hasFailedVersion(version: Awaited>): boolean { + return Boolean(version.failure && !version.held); +} + +function changesAudience(input: ShareAction, share: ReviewShare) { + return input.action === "share" && Boolean(input.audience) && share.access !== input.audience; +} +function isUnchangedUpdate(input: ShareAction, added: boolean, result: ShareState) { + return ( + input.action === "update" && !added && Boolean(result.version.last?.current) && !result.pending + ); +} + +async function prepareSelectedSource( + dir: string, + access: Parameters[1], + spaceId: string | undefined, + input: ShareAction, + shareFiles: boolean, +): Promise { + if (input.includeSource !== true || input.videoOnly) + return { source: { at: "video_only", reason: "requested" }, requireSource: false }; + return prepareCliShareSource(dir, access, spaceId, { includeSource: true, shareFiles }); +} diff --git a/packages/cli/src/share/sources.test.ts b/packages/cli/src/share/sources.test.ts new file mode 100644 index 0000000000..d048f7f971 --- /dev/null +++ b/packages/cli/src/share/sources.test.ts @@ -0,0 +1,99 @@ +import { beforeEach, expect, it, vi } from "vitest"; +const mocks = vi.hoisted(() => ({ + prepare: vi.fn(), + filesForExport: vi.fn(), + factory: vi.fn(), + content: vi.fn(), +})); +vi.mock("@hyperframes/share", async (original) => ({ + ...(await original()), + shareSources: mocks.factory, + projectFingerprint: async () => "rendered", +})); +vi.mock("./render.js", () => ({ + latestShareRender: () => ({ fingerprint: "rendered", contentFingerprint: "original-content" }), + shareContentFingerprint: mocks.content, +})); +import { prepareCliShareSource, ShareSourceError } from "./sources.js"; +import { shareError } from "./errors.js"; +const access = async () => ({ + token: "test", + heygen: "https://app.test", + heygenApi: "https://api.test", + owner: "owner", +}); +beforeEach(() => { + vi.resetAllMocks(); + mocks.content.mockResolvedValue("original-content"); + mocks.factory.mockReturnValue({ prepare: mocks.prepare, filesForExport: mocks.filesForExport }); +}); +it("eligible source requires attachment on the version", async () => { + const snapshot = { space_id: "space", composition_id: "composition", snapshot_id: "snapshot" }; + mocks.prepare.mockResolvedValue({ at: "ready", snapshot }); + expect( + await prepareCliShareSource("/project", access, "space", { + shareFiles: true, + includeSource: true, + }), + ).toEqual({ + source: { at: "ready", snapshot }, + requireSource: true, + filesForExport: mocks.filesForExport, + }); + expect(mocks.prepare).toHaveBeenCalledWith("/project", "rendered"); +}); +it("refuses source bytes that differ from the rendered assets even when metadata matches", async () => { + mocks.prepare.mockImplementation(async (dir: string) => { + const fingerprint = mocks.factory.mock.calls[0]?.[0].fingerprint; + expect(await fingerprint(dir)).toBe("rendered"); + mocks.content.mockResolvedValue("changed-content"); + expect(await fingerprint(dir)).toBeNull(); + return { at: "unavailable", reason: "source_render_changed" }; + }); + await expect( + prepareCliShareSource("/project", access, "space", { shareFiles: true, includeSource: true }), + ).rejects.toThrow("source_render_changed"); +}); +it("free plan ineligibility preserves video sharing and reports source unavailable", async () => { + mocks.prepare.mockResolvedValue({ at: "unavailable", reason: "source_plan_required" }); + expect( + await prepareCliShareSource("/project", access, "space", { + shareFiles: true, + includeSource: true, + }), + ).toEqual({ + source: { at: "video_only", reason: "source_plan_required" }, + requireSource: false, + }); +}); +it("explicit video-only skips source network requests", async () => { + await prepareCliShareSource("/project", access, "space", { + shareFiles: true, + includeSource: true, + videoOnly: true, + }); + expect(mocks.factory).not.toHaveBeenCalled(); +}); +it("unexpected upload errors and stale source block with an explicit video-only retry", async () => { + mocks.prepare.mockRejectedValueOnce(new Error("network failed")); + await expect( + prepareCliShareSource("/project", access, "space", { shareFiles: true, includeSource: true }), + ).rejects.toThrow("--video-only"); + mocks.prepare.mockResolvedValue({ at: "unavailable", reason: "source_render_changed" }); + await expect( + prepareCliShareSource("/project", access, "space", { shareFiles: true, includeSource: true }), + ).rejects.toThrow("--video-only"); +}); + +it("source failure has a stable bridge and JSON error code", () => { + expect(shareError(new ShareSourceError("Retry or choose video-only"))).toEqual({ + code: "source_unavailable", + message: "Retry or choose video-only", + }); +}); + +it("defaults to video only even when source sharing is available", async () => { + const result = await prepareCliShareSource("/project", access, "space", { shareFiles: true }); + expect(result.requireSource).toBe(false); + expect(mocks.factory).not.toHaveBeenCalled(); +}); diff --git a/packages/cli/src/share/sources.ts b/packages/cli/src/share/sources.ts new file mode 100644 index 0000000000..223ca1fdf8 --- /dev/null +++ b/packages/cli/src/share/sources.ts @@ -0,0 +1,60 @@ +import { projectFingerprint, shareSources, type VersionRequest } from "@hyperframes/share"; +import type { createShareAccess } from "./auth.js"; +import { latestShareRender, shareContentFingerprint } from "./render.js"; + +export class ShareSourceError extends Error {} + +export type ShareSourceState = + | { at: "not_checked" } + | { at: "video_only"; reason: string } + | { at: "ready"; snapshot: { space_id: string; composition_id: string; snapshot_id: string } }; +export interface PreparedShareSource { + source: ShareSourceState; + filesForExport?: VersionRequest["filesForExport"]; + requireSource: boolean; +} +const unavailablePlans = new Set([ + "source_disabled", + "source_plan_required", + "source_composition_limit", +]); +export function uncheckedSource(): ShareSourceState { + return { at: "not_checked" }; +} +export async function prepareCliShareSource( + dir: string, + access: ReturnType["access"], + spaceId: string | undefined, + options: { includeSource?: boolean; videoOnly?: boolean; shareFiles: boolean }, +): Promise { + if (options.includeSource !== true || options.videoOnly) return videoOnly("requested"); + if (!options.shareFiles) return videoOnly("source_disabled"); + if (!spaceId) throw new Error("The owning workspace could not be verified. Retry sharing."); + try { + const render = latestShareRender(dir); + const source = shareSources({ + access, + spaceId, + fingerprint: async (path) => + render?.contentFingerprint === (await shareContentFingerprint(path)) + ? projectFingerprint(path) + : null, + }); + const prepared = await source.prepare(dir, render?.fingerprint ?? null); + if (prepared.at === "ready") + return { source: prepared, filesForExport: source.filesForExport, requireSource: true }; + if (unavailablePlans.has(prepared.reason)) return videoOnly(prepared.reason); + throw new Error(`Source could not be attached (${prepared.reason}).`); + } catch (error) { + const reason = error instanceof Error ? error.message : "Source upload failed."; + throw new ShareSourceError( + `${reason} Retry sharing, or use --video-only to share just the video.`, + { + cause: error, + }, + ); + } +} +function videoOnly(reason: string): PreparedShareSource { + return { source: { at: "video_only", reason }, requireSource: false }; +} diff --git a/packages/cli/src/share/telemetry.optOut.test.ts b/packages/cli/src/share/telemetry.optOut.test.ts new file mode 100644 index 0000000000..855f541884 --- /dev/null +++ b/packages/cli/src/share/telemetry.optOut.test.ts @@ -0,0 +1,61 @@ +import { mkdtempSync, rmSync, writeFileSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; +import { afterEach, beforeEach, expect, it, vi } from "vitest"; + +const mocks = vi.hoisted(() => ({ enqueue: vi.fn() })); +vi.mock("../telemetry/transport.js", () => ({ + enqueue: mocks.enqueue, + flush: vi.fn(), + flushSync: vi.fn(), +})); +vi.mock("../utils/env.js", () => ({ isDevMode: () => false })); +vi.mock("../telemetry/system.js", () => ({ getSystemMeta: () => ({}) })); +vi.mock("../telemetry/canary.js", () => ({ canaryEventProperties: () => ({}) })); +vi.mock("../telemetry/signedInUser.js", () => ({ signedInHeygenUsername: () => undefined })); +import { observeShareMutation, trackShareInteraction } from "./telemetry.js"; + +let folder: string; +function preference(enabled: boolean) { + writeFileSync( + join(folder, "config.json"), + JSON.stringify({ anonymousId: "test", bucketSeed: "test", telemetryEnabled: enabled }), + ); +} +beforeEach(() => { + mocks.enqueue.mockClear(); + folder = mkdtempSync(join(tmpdir(), "hf-share-opt-out-")); + vi.stubEnv("HYPERFRAMES_CONFIG_DIR", folder); + vi.stubEnv("HYPERFRAMES_NO_TELEMETRY", ""); + vi.stubEnv("DO_NOT_TRACK", ""); + preference(true); +}); +afterEach(() => { + vi.unstubAllEnvs(); + rmSync(folder, { recursive: true, force: true }); +}); + +it("stops queueing events after a separate process changes the persisted preference", async () => { + trackShareInteraction({ event: "share_opened", link: "none" }, "local_studio"); + expect(mocks.enqueue).toHaveBeenCalledOnce(); + preference(false); + mocks.enqueue.mockClear(); + trackShareInteraction({ event: "share_link_copied", via: "copy" }, "local_studio"); + await observeShareMutation("update", "local_studio", async (attempt) => { + attempt.authenticated(); + attempt.complete(true, true); + }); + expect(mocks.enqueue).not.toHaveBeenCalled(); +}); + +it.each(["HYPERFRAMES_NO_TELEMETRY", "DO_NOT_TRACK"])( + "honors %s even after a previous event enabled the client cache", + async (name) => { + trackShareInteraction({ event: "share_opened", link: "none" }); + expect(mocks.enqueue).toHaveBeenCalledOnce(); + vi.stubEnv(name, "1"); + mocks.enqueue.mockClear(); + await observeShareMutation("share", "cli", async (attempt) => attempt.complete(true, true)); + expect(mocks.enqueue).not.toHaveBeenCalled(); + }, +); diff --git a/packages/cli/src/share/telemetry.test.ts b/packages/cli/src/share/telemetry.test.ts new file mode 100644 index 0000000000..732d6a9e66 --- /dev/null +++ b/packages/cli/src/share/telemetry.test.ts @@ -0,0 +1,49 @@ +import { beforeEach, describe, expect, it, vi } from "vitest"; +const mocks = vi.hoisted(() => ({ track: vi.fn(), fresh: vi.fn(), reset: vi.fn() })); +vi.mock("../telemetry/client.js", () => ({ + trackEvent: mocks.track, + resetTelemetryPostureCache: mocks.reset, +})); +vi.mock("../telemetry/config.js", () => ({ readConfigFresh: mocks.fresh })); +import { observeShareMutation, trackShareInteraction } from "./telemetry.js"; +beforeEach(() => vi.resetAllMocks()); +describe("share telemetry privacy boundary", () => { + it("only forwards the declared interaction fields, never links or project data", () => { + const input = { + event: "share_link_copied" as const, + via: "copy" as const, + url: "https://private/token", + project: "/example/project", + }; + trackShareInteraction(input, "local_studio"); + expect(mocks.track).toHaveBeenCalledExactlyOnceWith("share_link_copied", { + client_surface: "local_studio", + via: "copy", + }); + }); + it("refreshes persisted opt-out posture at each event in a long-lived preview", () => { + trackShareInteraction({ event: "share_opened", link: "none" }, "local_studio"); + trackShareInteraction({ event: "share_link_copied", via: "publish" }, "local_studio"); + expect(mocks.fresh).toHaveBeenCalledTimes(2); + expect(mocks.reset).toHaveBeenCalledTimes(2); + }); + it("drops unknown failure reasons and never sends raw messages", async () => { + const error = Object.assign(new Error("secret email@example.com"), { + reason: "/secret/project", + }); + await expect( + observeShareMutation("update", "cli", async () => { + throw error; + }), + ).rejects.toBe(error); + expect(mocks.track.mock.lastCall?.[1]).toMatchObject({ reason: "other" }); + expect(JSON.stringify(mocks.track.mock.calls)).not.toContain("secret"); + }); + it("telemetry configuration errors cannot block sharing or change its failure", async () => { + mocks.fresh.mockImplementation(() => { + throw new Error("EACCES"); + }); + expect(await observeShareMutation("share", "cli", async () => "done")).toBe("done"); + expect(mocks.track).not.toHaveBeenCalled(); + }); +}); diff --git a/packages/cli/src/share/telemetry.ts b/packages/cli/src/share/telemetry.ts new file mode 100644 index 0000000000..3852cb8d20 --- /dev/null +++ b/packages/cli/src/share/telemetry.ts @@ -0,0 +1,96 @@ +import { randomUUID } from "node:crypto"; +import { AuthError } from "../auth/errors.js"; +import { CliUsageError } from "../utils/commandResult.js"; +import { readConfigFresh } from "../telemetry/config.js"; +import { resetTelemetryPostureCache, trackEvent } from "../telemetry/client.js"; +import type { ReviewExportProgress } from "@hyperframes/share"; + +export type ShareSurface = "cli" | "local_studio"; +export type ShareInteraction = + | { event: "share_opened"; link: "none" | "live" | "changed" } + | { event: "share_link_copied"; via: "copy" | "publish" | "update" }; +const REASONS = new Set([ + "feature_unavailable", + "audience_required", + "workspace_cannot_share", + "workspace_mismatch", + "manage_existing_audience", + "review_project_limit_reached", + "review_subscription_required", + "review_entitlement_unavailable", + "review_public_consent_required", + "moderation_hold", + "review_operation_busy", + "not_shared", + "offline", + "signed_out", +]); +function failureReason(error: unknown): string { + if (error instanceof AuthError) return "authentication"; + if (error instanceof CliUsageError && REASONS.has(error.code)) return error.code; + if (typeof error === "object" && error !== null && "reason" in error) { + const reason = error.reason; + if (typeof reason === "string" && REASONS.has(reason)) return reason; + } + return "other"; +} +function emit(event: string, properties: Record): void { + try { + // A preview process can outlive an opt-out made from another terminal. + readConfigFresh(); + resetTelemetryPostureCache(); + trackEvent(event, properties); + } catch { + // Telemetry must not alter whether a share succeeds or fails. + } +} +export function trackShareInteraction(input: ShareInteraction, surface: ShareSurface = "cli") { + if (input.event === "share_opened") + emit(input.event, { client_surface: surface, link: input.link }); + else emit(input.event, { client_surface: surface, via: input.via }); +} +function shareAttempt(action: "share" | "update", surface: ShareSurface) { + const base = { client_surface: surface, action, attempt_id: randomUUID() }; + let admitted = false; + let recovery = false; + const track = (event: string, extra: Record = {}) => + emit(event, { ...base, recovery, ...extra }); + const admit = () => { + if (admitted) return; + admitted = true; + track("share_mutation_admitted"); + }; + track("share_mutation_attempted"); + return { + authenticated: () => track("share_mutation_authenticated"), + recover: (pending: boolean) => { + recovery = pending; + if (pending) track("share_recovery_attempted"); + }, + progress: (value: ReviewExportProgress | null) => { + if (value && value.step !== "preparing") admit(); + }, + retrieved: () => track("share_existing_link_returned"), + complete: (ready: boolean, added: boolean) => { + if (!added) + return track(ready ? "share_existing_link_returned" : "share_mutation_processing"); + admit(); + track("share_video_ready"); + }, + failed: (error: unknown) => track("share_mutation_failed", { reason: failureReason(error) }), + }; +} +export type ShareAttempt = ReturnType; +export async function observeShareMutation( + action: "share" | "update", + surface: ShareSurface, + run: (attempt: ShareAttempt) => Promise, +): Promise { + const attempt = shareAttempt(action, surface); + try { + return await run(attempt); + } catch (error) { + attempt.failed(error); + throw error; + } +} diff --git a/packages/cli/src/share/uploadOrigins.test.ts b/packages/cli/src/share/uploadOrigins.test.ts new file mode 100644 index 0000000000..facba479c9 --- /dev/null +++ b/packages/cli/src/share/uploadOrigins.test.ts @@ -0,0 +1,90 @@ +import { afterEach, beforeEach, expect, it, vi } from "vitest"; +import { mkdtempSync, rmSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; +import { cliReviewUploadOrigins } from "./uploadOrigins.js"; +import { assertReviewUploadStorage, bindCliShareProject } from "./host.js"; +import { trustedUploadUrl } from "@hyperframes/share/reviewUpload.mjs"; + +let dir: string; +beforeEach(() => { + for (const key of [ + "HYPERFRAMES_REVIEW_UPLOAD_ORIGINS", + "HYPERFRAMES_ENV", + "HEYGEN_API_URL", + "HYPERFRAMES_OAUTH_TOKEN_URL", + "HYPERFRAMES_OAUTH_CLIENT_ID", + ]) + vi.stubEnv(key, undefined); + dir = mkdtempSync(join(tmpdir(), "share-upload-origins-")); +}); +afterEach(() => { + vi.unstubAllEnvs(); + rmSync(dir, { recursive: true, force: true }); +}); + +it("trusts only the production video and source storage origins by default", () => { + expect(cliReviewUploadOrigins()).toEqual([ + "https://heygen-hyperframes-reviews-prod-767398024897-us-east-2.s3.amazonaws.com", + "https://heygen-hyperframes-reviews-prod-767398024897-us-east-2.s3.us-east-2.amazonaws.com", + "https://hyperframes-composition-sync-prod.s3.us-east-2.amazonaws.com", + ]); + bindCliShareProject(dir); + expect(() => assertReviewUploadStorage()).not.toThrow(); + for (const origin of cliReviewUploadOrigins()) + expect(trustedUploadUrl(`${origin}/object?signature=fixture`)).not.toBeNull(); +}); +it.each([ + ["HYPERFRAMES_ENV", "dev"], + ["HEYGEN_API_URL", "https://custom.example"], + ["HYPERFRAMES_OAUTH_TOKEN_URL", "https://custom.example/token"], + ["HYPERFRAMES_OAUTH_CLIENT_ID", "custom-client"], +])("does not inherit production trust when %s changes", (key, value) => { + bindCliShareProject(dir); + const production = cliReviewUploadOrigins()[0]; + vi.stubEnv(key, value); + bindCliShareProject(dir); + expect(cliReviewUploadOrigins()).toEqual([]); + expect(() => assertReviewUploadStorage()).toThrow(); + expect(trustedUploadUrl(`${production}/object`)).toBeNull(); +}); +it("replaces defaults with an explicit exact-origin override for custom deployments", () => { + vi.stubEnv("HYPERFRAMES_ENV", "dev"); + vi.stubEnv( + "HYPERFRAMES_REVIEW_UPLOAD_ORIGINS", + " https://storage.example , https://sources.example ", + ); + bindCliShareProject(dir); + expect(cliReviewUploadOrigins()).toEqual(["https://storage.example", "https://sources.example"]); + expect(() => assertReviewUploadStorage()).not.toThrow(); + expect(trustedUploadUrl("https://storage.example/object")).not.toBeNull(); + expect( + trustedUploadUrl("https://hyperframes-composition-sync-prod.s3.us-east-2.amazonaws.com/object"), + ).toBeNull(); +}); +it.each(["", " , "])("keeps explicit empty overrides fail-closed (%j)", (override) => { + vi.stubEnv("HYPERFRAMES_REVIEW_UPLOAD_ORIGINS", override); + bindCliShareProject(dir); + expect(cliReviewUploadOrigins()).toEqual([]); + expect(() => assertReviewUploadStorage()).toThrow(); +}); +it("rejects sibling buckets, userinfo, non-HTTPS and accelerated hosts", () => { + bindCliShareProject(dir); + for (const url of [ + "https://other-bucket.s3.us-east-2.amazonaws.com/object", + "https://hyperframes-composition-sync-prod.s3.us-east-2.amazonaws.com.evil.example/object", + "https://user:password@hyperframes-composition-sync-prod.s3.us-east-2.amazonaws.com/object", + "http://hyperframes-composition-sync-prod.s3.us-east-2.amazonaws.com/object", + "https://heygen-hyperframes-reviews-prod-767398024897-us-east-2.s3-accelerate.amazonaws.com/object", + ]) + expect(trustedUploadUrl(url)).toBeNull(); +}); + +it.each(["https://storage.example/path", "https://*.example", "http://storage.example"])( + "does not accept invalid override %s", + (override) => { + vi.stubEnv("HYPERFRAMES_REVIEW_UPLOAD_ORIGINS", override); + bindCliShareProject(dir); + expect(() => assertReviewUploadStorage()).toThrow(); + }, +); diff --git a/packages/cli/src/share/uploadOrigins.ts b/packages/cli/src/share/uploadOrigins.ts new file mode 100644 index 0000000000..2b910ffd91 --- /dev/null +++ b/packages/cli/src/share/uploadOrigins.ts @@ -0,0 +1,28 @@ +import { apiBaseUrl } from "../auth/client.js"; +import { + defaultClientId, + oauthEnvironment, + resolveClientId, + tokenEndpoint, +} from "../auth/config.js"; + +const PRODUCTION_UPLOAD_ORIGINS = [ + "https://heygen-hyperframes-reviews-prod-767398024897-us-east-2.s3.amazonaws.com", + "https://heygen-hyperframes-reviews-prod-767398024897-us-east-2.s3.us-east-2.amazonaws.com", + "https://hyperframes-composition-sync-prod.s3.us-east-2.amazonaws.com", +] as const; + +export function cliReviewUploadOrigins(): readonly string[] { + const override = process.env.HYPERFRAMES_REVIEW_UPLOAD_ORIGINS; + if (override !== undefined) + return override + .split(",") + .map((origin) => origin.trim()) + .filter(Boolean); + const standardProduction = + oauthEnvironment() === "prod" && + apiBaseUrl() === "https://api.heygen.com" && + tokenEndpoint() === "https://api2.heygen.com/v1/oauth/token" && + resolveClientId() === defaultClientId(); + return standardProduction ? PRODUCTION_UPLOAD_ORIGINS : []; +} diff --git a/packages/cli/src/utils/project.test.ts b/packages/cli/src/utils/project.test.ts index 6011739704..74e3cb5dd1 100644 --- a/packages/cli/src/utils/project.test.ts +++ b/packages/cli/src/utils/project.test.ts @@ -1,4 +1,4 @@ -import { describe, expect, it } from "vitest"; +import { describe, expect, it, vi } from "vitest"; import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join, basename } from "node:path"; @@ -118,3 +118,20 @@ describe("resolveLintTarget", () => { } }); }); + +it("finds a parent project only when no directory was explicitly supplied", () => { + const dir = mkdtempSync(join(tmpdir(), "hf-parent-project-")); + const child = join(dir, "compositions"); + mkdirSync(child); + writeFileSync(join(dir, "index.html"), ""); + const cwd = vi.spyOn(process, "cwd").mockReturnValue(child); + try { + expect(resolveProjectOrThrow(undefined, { searchParents: true }).dir).toBe(dir); + expect(() => resolveProjectOrThrow(child, { searchParents: true })).toThrow( + "No composition found", + ); + } finally { + cwd.mockRestore(); + rmSync(dir, { recursive: true, force: true }); + } +}); diff --git a/packages/cli/src/utils/project.ts b/packages/cli/src/utils/project.ts index 8a3f044ebc..f3b3ff1e6b 100644 --- a/packages/cli/src/utils/project.ts +++ b/packages/cli/src/utils/project.ts @@ -12,6 +12,7 @@ export interface ProjectDir { export interface ResolveProjectOptions { requireIndex?: boolean; + searchParents?: boolean; } export class InvalidProjectError extends Error { @@ -41,7 +42,11 @@ export function resolveProjectOrThrow( ); } - const dir = resolve(dirArg ?? "."); + const start = resolve(dirArg ?? "."); + const dir = + options.searchParents && dirArg === undefined + ? projectHolding(join(start, "index.html")) + : start; const name = basename(dir); const indexPath = resolve(dir, "index.html"); diff --git a/packages/cli/src/utils/render-success-state.test.ts b/packages/cli/src/utils/render-success-state.test.ts index 95c084c42a..db645ddea6 100644 --- a/packages/cli/src/utils/render-success-state.test.ts +++ b/packages/cli/src/utils/render-success-state.test.ts @@ -40,6 +40,7 @@ describe("runPostRenderStep", () => { const originalExitCode = process.exitCode; beforeEach(() => { + markRenderSucceeded(); registerRootExitCodeSanitizer(() => { process.exitCode = 0; }); @@ -126,6 +127,7 @@ describe("runPostRenderStepAsync", () => { const originalExitCode = process.exitCode; beforeEach(() => { + markRenderSucceeded(); registerRootExitCodeSanitizer(() => { process.exitCode = 0; }); @@ -164,3 +166,30 @@ describe("runPostRenderStepAsync", () => { expect(process.exitCode).toBe(0); }); }); + +it("does not sanitize the host exit code after embedded-render cleanup fails", async () => { + _resetRenderSuccessForTests(); + const sanitize = vi.fn(); + registerRootExitCodeSanitizer(sanitize); + try { + runPostRenderStep( + "metrics", + () => { + throw new Error("metrics failed"); + }, + vi.fn(), + ); + await runPostRenderStepAsync( + "history", + async () => { + throw new Error("history failed"); + }, + vi.fn(), + ); + expect(sanitize).not.toHaveBeenCalled(); + expect(isRenderSucceeded()).toBe(false); + } finally { + registerRootExitCodeSanitizer(() => {}); + _resetRenderSuccessForTests(); + } +}); diff --git a/packages/cli/src/utils/render-success-state.ts b/packages/cli/src/utils/render-success-state.ts index 531d6ba6a9..1e0bce5ec5 100644 --- a/packages/cli/src/utils/render-success-state.ts +++ b/packages/cli/src/utils/render-success-state.ts @@ -69,10 +69,10 @@ const defaultErrorSink: PostRenderErrorSink = (message) => { /** * Run a post-artifact-validated cleanup step so a throw cannot flip the CLI - * exit code. `markRenderSucceeded()` MUST have been called first — this - * helper is only safe on the success path where the artifact is already - * committed to disk. Logs a compact warning to stderr, asks the root CLI to - * clear a stray exit code, and swallows the error. + * exit code. Use only after the artifact is committed to disk. Logs a compact + * warning and swallows the error. Only a top-level render that called + * `markRenderSucceeded()` may ask the root CLI to clear a stray exit code; + * an embedded render does not own the surrounding command’s outcome. */ export function runPostRenderStep( label: string, @@ -103,5 +103,5 @@ function reportPostRenderStepFailure(label: string, err: unknown, sink: PostRend sink(` [hyperframes] Post-render step '${label}' failed (render already succeeded): ${message}`); // The failing step (or something it triggered) may have set a non-zero // exitCode. The render succeeded, so ask the root CLI owner to clear it. - sanitizeSuccessfulExitCode(); + if (isRenderSucceeded()) sanitizeSuccessfulExitCode(); } diff --git a/packages/cli/src/utils/updateChannel.test.ts b/packages/cli/src/utils/updateChannel.test.ts new file mode 100644 index 0000000000..98c191f9e3 --- /dev/null +++ b/packages/cli/src/utils/updateChannel.test.ts @@ -0,0 +1,46 @@ +import { afterEach, beforeEach, expect, it, vi } from "vitest"; +const state = vi.hoisted(() => ({ config: {} as Record })); +vi.mock("../version.js", () => ({ VERSION: "0.9.28-alpha.3" })); +vi.mock("../telemetry/config.js", () => ({ + readConfig: () => state.config, + readConfigFresh: () => state.config, + writeConfig: (value: Record) => { + state.config = value; + }, +})); +import { cachedUpdateCheck, checkForUpdate, updateChannel } from "./updateCheck.js"; +beforeEach(() => { + state.config = {}; +}); +afterEach(() => vi.unstubAllGlobals()); +it("keeps alpha update checks on alpha even when stable has a higher version", async () => { + state.config = { latestVersion: "0.9.31", lastUpdateCheck: new Date().toISOString() }; + expect(cachedUpdateCheck().updateAvailable).toBe(false); + const fetch = vi + .fn() + .mockResolvedValue({ ok: true, json: async () => ({ version: "0.9.32-alpha.1" }) }); + vi.stubGlobal("fetch", fetch); + expect(await checkForUpdate(true)).toMatchObject({ + latest: "0.9.32-alpha.1", + updateAvailable: true, + }); + expect(fetch.mock.calls[0]?.[0]).toBe("https://registry.npmjs.org/hyperframes/alpha"); +}); +it("does not accept a stable registry response for an alpha installation", async () => { + vi.stubGlobal( + "fetch", + vi.fn().mockResolvedValue({ ok: true, json: async () => ({ version: "0.9.31" }) }), + ); + expect((await checkForUpdate(true)).updateAvailable).toBe(false); +}); +it("does not advertise stale cached versions", () => { + state.config = { + latestVersion: "0.9.29-alpha.1", + lastUpdateCheck: new Date(Date.now() - 3 * 3600000).toISOString(), + }; + expect(cachedUpdateCheck().updateAvailable).toBe(false); +}); +it("selects stable and prerelease channels from the running version", () => { + expect(updateChannel("0.9.31")).toBe("latest"); + expect(updateChannel("0.9.31-rc.1")).toBe("rc"); +}); diff --git a/packages/cli/src/utils/updateCheck.test.ts b/packages/cli/src/utils/updateCheck.test.ts index 9052323ded..6a41a18f69 100644 --- a/packages/cli/src/utils/updateCheck.test.ts +++ b/packages/cli/src/utils/updateCheck.test.ts @@ -697,7 +697,8 @@ describe("updateCheckDue / cachedUpdateCheck — what the parent reads without f vi.setSystemTime(new Date("2026-11-03T08:00:00Z")); const at = (h: number) => new Date(Date.parse("2026-11-03T08:00:00Z") - h * 3_600_000).toISOString(); - const mod = await loadNotice(behind({ lastUpdateCheck: at(1), lastSkillsCheck: at(1) })); + const config = behind({ lastUpdateCheck: at(1), lastSkillsCheck: at(1) }); + const mod = await loadNotice(config); const first = mod.withMeta({ ok: true })._meta; expect(first.updateNotice).toEqual(expect.any(String)); @@ -711,6 +712,8 @@ describe("updateCheckDue / cachedUpdateCheck — what the parent reads without f expect(again.checkedAt).toEqual(expect.any(String)); vi.setSystemTime(new Date("2026-11-04T08:30:00Z")); + config.lastUpdateCheck = new Date().toISOString(); + config.lastSkillsCheck = new Date().toISOString(); expect(mod.withMeta({ ok: true })._meta.updateNotice).toEqual(expect.any(String)); }); @@ -772,7 +775,7 @@ describe("updateCheckDue / cachedUpdateCheck — what the parent reads without f expect(mod.cachedUpdateCheck().latest).toBe("0.9.6"); }); - it.each(["999.0.0", "999.0.0-beta.1+build.5"])( + it.each(["999.0.0", "999.0.0+build.5"])( "preserves safe cached version %s and the update-check result in metadata", async (latestVersion) => { const mod = await load({ latestVersion }); diff --git a/packages/cli/src/utils/updateCheck.ts b/packages/cli/src/utils/updateCheck.ts index 74de0042f4..fe354323e9 100644 --- a/packages/cli/src/utils/updateCheck.ts +++ b/packages/cli/src/utils/updateCheck.ts @@ -20,7 +20,11 @@ import { isSafeVersion } from "./safeVersion.js"; export { isSafeVersion } from "./safeVersion.js"; -const NPM_REGISTRY_URL = "https://registry.npmjs.org/hyperframes/latest"; +export function updateChannel(version = VERSION): string { + if (version === "0.0.0-dev") return "latest"; + return version.match(/^\d+\.\d+\.\d+-([a-z][a-z0-9-]*)(?:\.|$)/i)?.[1] ?? "latest"; +} +const npmRegistryUrl = () => `https://registry.npmjs.org/hyperframes/${updateChannel()}`; const CHECK_INTERVAL_MS = 2 * 60 * 60 * 1000; const SKILLS_COUNT_MAX_AGE_MS = 24 * 60 * 60 * 1000; const FETCH_TIMEOUT_MS = 3000; @@ -70,14 +74,14 @@ export async function checkForUpdate(force?: boolean): Promise controller.abort(), FETCH_TIMEOUT_MS); let data: { version?: unknown }; try { - const res = await fetch(NPM_REGISTRY_URL, { + const res = await fetch(npmRegistryUrl(), { signal: controller.signal, headers: { Connection: "close" }, }); @@ -92,7 +96,11 @@ export async function checkForUpdate(force?: boolean): Promise - typeof value === "string" && isSafeVersion(value); + typeof value === "string" && isSafeVersion(value) && updateChannel(value) === updateChannel(); function cachedVersionForThisInstall(value: unknown): string | undefined { + const checkedAt = readConfig().lastUpdateCheck; + if (checkedAt && Date.now() - Date.parse(checkedAt) >= CHECK_INTERVAL_MS) return undefined; return isSafeCache(value) && !isNewerSemver(VERSION, value) ? value : undefined; } @@ -227,7 +237,7 @@ export function updateCommandForThisInstall( return projectNoticeCommand(install, cliBehind, skillsBehind, latest); } return install.channel === "npx" && cliBehind - ? "npx hyperframes@latest update" + ? `npx hyperframes@${updateChannel()} update` : "npx hyperframes update"; } @@ -346,7 +356,7 @@ export function printUpdateNotice(): void { // the suppression + update-available gates, so it adds no cost to normal runs. const safeLatest = isSafeVersion(meta.latestVersion); const managerCommand = safeLatest ? detectInstaller().installCommand(meta.latestVersion) : null; - const command = managerCommand ?? "npx hyperframes@latest"; + const command = managerCommand ?? `npx hyperframes@${updateChannel()}`; process.stderr.write( `\n Update available: ${meta.version} \u2192 ${meta.latestVersion}\n` + diff --git a/packages/cli/tsup.config.ts b/packages/cli/tsup.config.ts index 6992026bdb..2089f2e205 100644 --- a/packages/cli/tsup.config.ts +++ b/packages/cli/tsup.config.ts @@ -77,6 +77,7 @@ var __dirname = __hf_dirname(__filename);`, "@hyperframes/gcp-cloud-run/terraform", ], noExternal: [ + "@hyperframes/share", "@hyperframes/core", "@hyperframes/parsers", "@hyperframes/studio-server", diff --git a/packages/engine/src/services/browserManager.test.ts b/packages/engine/src/services/browserManager.test.ts index 5adc41f394..46a701d02c 100644 --- a/packages/engine/src/services/browserManager.test.ts +++ b/packages/engine/src/services/browserManager.test.ts @@ -1624,22 +1624,28 @@ describe("browser pool", () => { _setPuppeteerForTests(undefined); }); - it("keeps the launch diagnostic on stderr when a command emits JSON", async () => { - const stdout = vi.spyOn(console, "log").mockImplementation(() => {}); - const stderr = vi.spyOn(console, "error").mockImplementation(() => {}); - try { - const result = await acquireBrowser(["--no-sandbox"], poolCfg); - await result.release(); + it.each([undefined, "1"])( + "emits the launch diagnostic only in debug mode (%s)", + async (debug) => { + vi.stubEnv("HF_DEBUG_RENDER", debug); + const stdout = vi.spyOn(console, "log").mockImplementation(() => {}); + const stderr = vi.spyOn(console, "error").mockImplementation(() => {}); + try { + const result = await acquireBrowser(["--no-sandbox"], poolCfg); + await result.release(); - expect(stderr).toHaveBeenCalledWith( - expect.stringMatching(/^\[BrowserManager\] Browser launched/), - ); - expect(stdout).not.toHaveBeenCalled(); - } finally { - stdout.mockRestore(); - stderr.mockRestore(); - } - }); + const launches = stderr.mock.calls.filter(([line]) => + String(line).startsWith("[BrowserManager] Browser launched"), + ); + expect(launches.length).toBe(debug ? 1 : 0); + expect(stdout).not.toHaveBeenCalled(); + } finally { + stdout.mockRestore(); + stderr.mockRestore(); + vi.unstubAllEnvs(); + } + }, + ); it("sequential acquires with pool enabled return the same browser", async () => { const first = await acquireBrowser(["--no-sandbox"], poolCfg); diff --git a/packages/engine/src/services/browserManager.ts b/packages/engine/src/services/browserManager.ts index aba22bba95..3ee7dd2d12 100644 --- a/packages/engine/src/services/browserManager.ts +++ b/packages/engine/src/services/browserManager.ts @@ -955,9 +955,10 @@ async function launchBrowser( const gpuFlags = fingerprint.args.filter( (a) => a.startsWith("--use-gl=") || a.startsWith("--use-angle="), ); - console.error( - `[BrowserManager] Browser launched (${browserVersion}, ${captureMode}, gl=${gpuFlags.join(" ") || "default"}, headlessShell=${!!fingerprint.executablePath}, platform=${process.platform})`, - ); + if (process.env.HF_DEBUG_RENDER === "1") + console.error( + `[BrowserManager] Browser launched (${browserVersion}, ${captureMode}, gl=${gpuFlags.join(" ") || "default"}, headlessShell=${!!fingerprint.executablePath}, platform=${process.platform})`, + ); if (captureMode === "beginframe") { let result = await probe(browser); diff --git a/packages/engine/src/services/frameCapture.test.ts b/packages/engine/src/services/frameCapture.test.ts index 2c3cf0405a..0f54395e38 100644 --- a/packages/engine/src/services/frameCapture.test.ts +++ b/packages/engine/src/services/frameCapture.test.ts @@ -203,7 +203,6 @@ describe("classifyPageError", () => { emit("error", "Failed to load resource", "https://fonts.gstatic.com/font.woff2"); expect(stderr.mock.calls).toEqual([ - ["[HyperFrames] render runtime fps"], ["[Browser:WARN] GPU readback warning"], ["[Browser:ERROR] [HyperFrames] composition script error: scene TypeError: x"], ]); diff --git a/packages/engine/src/services/frameCapture.ts b/packages/engine/src/services/frameCapture.ts index 246b4649a5..f1539cf1e9 100644 --- a/packages/engine/src/services/frameCapture.ts +++ b/packages/engine/src/services/frameCapture.ts @@ -1463,8 +1463,10 @@ async function finalizeDrawElementInit( export async function completeDeferredDrawElementInit(session: CaptureSession): Promise { if (!session.deInitDeferred || !session.onBeforeCapture) return; const page = session.page; - const logInitPhase = (phase: string) => - console.error(`[initSession:${session.captureMode}] ${phase} (deferred drawElement init)`); + const logInitPhase = (phase: string) => { + if (process.env.HF_DEBUG_RENDER === "1") + console.error(`[initSession:${session.captureMode}] ${phase} (deferred drawElement init)`); + }; await finalizeDrawElementInit(session, page, logInitPhase, { transparent: capturesAlpha(session.options), forceDE: process.env.HF_FORCE_DRAWELEMENT === "1", @@ -3086,7 +3088,11 @@ export async function initializeSession(session: CaptureSession): Promise const text = msg.text(); const locationUrl = msg.location()?.url ?? ""; const diagnostic = formatConsoleDiagnostic(type, text, locationUrl); - if (!diagnostic.suppressHostLog && !loggedEarlierInRender(session, text)) { + if ( + !diagnostic.suppressHostLog && + !quietRuntimeDetail(text) && + !loggedEarlierInRender(session, text) + ) { console.error(diagnostic.text); } appendBrowserDiagnostic(session, diagnostic.text); @@ -3163,7 +3169,8 @@ export async function initializeSession(session: CaptureSession): Promise session.config?.pageNavigationTimeout ?? DEFAULT_CONFIG.pageNavigationTimeout; const initStart = Date.now(); const logInitPhase = (phase: string) => { - console.error(`[initSession:${session.captureMode}] ${phase} (${Date.now() - initStart}ms)`); + if (process.env.HF_DEBUG_RENDER === "1") + console.error(`[initSession:${session.captureMode}] ${phase} (${Date.now() - initStart}ms)`); }; const gotoEntryPage = async (): Promise => { appendBrowserDiagnostic( @@ -6178,3 +6185,7 @@ export function getCapturePerfSummary(session: CaptureSession): CapturePerfSumma deFrameTimeouts: session.deFrameTimeouts ?? 0, }; } + +function quietRuntimeDetail(text: string): boolean { + return process.env.HF_DEBUG_RENDER !== "1" && text.startsWith("[hyperframes] render runtime fps"); +} diff --git a/packages/producer/src/logger.ts b/packages/producer/src/logger.ts index 845d321e58..34952b40e7 100644 --- a/packages/producer/src/logger.ts +++ b/packages/producer/src/logger.ts @@ -92,4 +92,6 @@ export function createConsoleLogger(level: LogLevel = "info"): ProducerLogger { } /** Default logger singleton (level: "info"). */ -export const defaultLogger: ProducerLogger = createConsoleLogger("info"); +export const defaultLogger: ProducerLogger = createConsoleLogger( + process.env.HF_DEBUG_RENDER === "1" ? "debug" : "info", +); diff --git a/packages/producer/src/services/htmlCompiler.test.ts b/packages/producer/src/services/htmlCompiler.test.ts index 6a1a99b578..e714ee2564 100644 --- a/packages/producer/src/services/htmlCompiler.test.ts +++ b/packages/producer/src/services/htmlCompiler.test.ts @@ -1461,16 +1461,16 @@ describe("local font embedding", () => { `, ); - const originalInfo = defaultLogger.info; + const originalDebug = defaultLogger.debug; const embeddedMessages: string[] = []; - defaultLogger.info = (message) => { + defaultLogger.debug = (message) => { if (message.includes("Embedded local font file")) embeddedMessages.push(message); }; try { await compileForRender(projectDir, join(projectDir, "index.html"), projectDir); } finally { - defaultLogger.info = originalInfo; + defaultLogger.debug = originalDebug; } expect(embeddedMessages).toHaveLength(1); @@ -1550,9 +1550,9 @@ describe("local font embedding", () => { `, ); - const originalInfo = defaultLogger.info; + const originalDebug = defaultLogger.debug; const fileBackedMessages: string[] = []; - defaultLogger.info = (message) => { + defaultLogger.debug = (message) => { if (message.includes("Kept large local font file-backed")) { fileBackedMessages.push(message); } @@ -1562,7 +1562,7 @@ describe("local font embedding", () => { try { compiled = await compileForRender(projectDir, join(projectDir, "index.html"), projectDir); } finally { - defaultLogger.info = originalInfo; + defaultLogger.debug = originalDebug; } expect(compiled.html).toContain('url("assets/large.ttc")'); diff --git a/packages/producer/src/services/htmlCompiler.ts b/packages/producer/src/services/htmlCompiler.ts index c2fb3b9710..fba7bfdd48 100644 --- a/packages/producer/src/services/htmlCompiler.ts +++ b/packages/producer/src/services/htmlCompiler.ts @@ -113,7 +113,7 @@ import { assertAssetMediaTypeProfile } from "./assetMediaType.js"; import { withMediaProbeSlot } from "../utils/mediaProbeConcurrency.js"; function logRemoteDownloadTelemetry(event: UrlDownloadTelemetry): void { - defaultLogger.info("[Compiler] Remote asset download integrity", { ...event }); + defaultLogger.debug("[Compiler] Remote asset download integrity", { ...event }); } export interface CompiledComposition { @@ -1345,7 +1345,7 @@ export async function inlineExternalScripts(html: string): Promise { } inlineScript.textContent = `/* inlined: ${src} */\n${safeText}\n//# sourceURL=${new URL(src).href}\n`; el.replaceWith(inlineScript); - defaultLogger.info(`[Compiler] Inlined CDN script: ${src}`); + defaultLogger.debug(`[Compiler] Inlined CDN script: ${src}`); } else { // A verified mismatch must never fall back to an executable external tag: // browser support for integrity metadata (including casing) can differ. @@ -1428,7 +1428,7 @@ export function collectExternalAssets( } if (externalAssets.size > 0) { - defaultLogger.info( + defaultLogger.debug( `[Compiler] Found ${externalAssets.size} asset(s) outside project directory, will copy to render output`, ); } @@ -1512,7 +1512,7 @@ async function downloadAndRewriteUrls( if (extraRewrite) result = extraRewrite(result, url, relPath); } - defaultLogger.info(`[Compiler] ${logLabel} ${urlToLocal.size} to ${REMOTE_MEDIA_SUBDIR}/`); + defaultLogger.debug(`[Compiler] ${logLabel} ${urlToLocal.size} to ${REMOTE_MEDIA_SUBDIR}/`); return { html: result, remoteMediaAssets }; } @@ -1767,7 +1767,7 @@ async function inlineExternalFontStylesheets(html: string): Promise { const identity = safeDownloadUrlIdentity(href); const inlineStyle = ``; result = result.replace(fullMatch, inlineStyle); - defaultLogger.info("[Compiler] Inlined external @font-face rule(s)", { + defaultLogger.debug("[Compiler] Inlined external @font-face rule(s)", { count: fontFaceBlocks.length, urlFingerprint: identity.urlFingerprint, host: identity.host, @@ -1937,7 +1937,7 @@ async function embedLocalFontFaces(html: string, projectDir: string): Promise ${(MAX_LOCAL_FONT_DATA_URI_BYTES / 1024 / 1024).toFixed(1)} MB)`, ); embeddedPaths.add(localPath); @@ -1945,7 +1945,7 @@ async function embedLocalFontFaces(html: string, projectDir: string): Promise 0) { - defaultLogger.info(`[Compiler] Converted ${preparedHeifImages.length} HEIC image(s) to JPEG`); + defaultLogger.debug(`[Compiler] Converted ${preparedHeifImages.length} HEIC image(s) to JPEG`); } const gifSourceAssets = new Map(remoteImageAssets); @@ -2288,7 +2288,7 @@ export async function compileForRender( timeoutMs: options.ffmpegProcessTimeout, }); if (preparedGifs.length > 0) { - defaultLogger.info(`[Compiler] Prepared ${preparedGifs.length} animated GIF input(s) as WebM`); + defaultLogger.debug(`[Compiler] Prepared ${preparedGifs.length} animated GIF input(s) as WebM`); } const embeddedHtml = await embedLocalFontFaces(htmlWithPreparedGifs, projectDir); diff --git a/packages/share/README.md b/packages/share/README.md index 38037ec6ca..afa95dad60 100644 --- a/packages/share/README.md +++ b/packages/share/README.md @@ -35,7 +35,7 @@ const [current, version] = await Promise.all([ `access(refusedToken?)` returns `{ token, heygen, heygenApi, owner }` or null. It is read for every request. A refused bearer is passed back so the host can refresh it. `heygen` is the review API base. A host can inject its own `signedInRequest` to retain network tracing. `execFile` can likewise be injected to retain native process policy. -Video uploads require exact storage origins from trusted host configuration. Set `reviewUploadOrigins` on the host or supply a comma-separated `HYPERFRAMES_REVIEW_UPLOAD_ORIGINS` environment variable. Configure the bucket-specific HTTPS origins used by the signer. Use URL origins without paths, trailing slashes, or wildcards. Local tests can explicitly allow an HTTP origin on `127.0.0.1`. An empty list refuses every video upload. +Video and source uploads require exact storage origins from trusted host configuration. Set `reviewUploadOrigins` on the host or supply a comma-separated `HYPERFRAMES_REVIEW_UPLOAD_ORIGINS` environment variable. Configure the bucket-specific HTTPS origins used by the signer. Use URL origins without paths, trailing slashes, or wildcards. Local tests can explicitly allow an HTTP origin on `127.0.0.1`. An empty list refuses every upload. Before first registration the host must obtain explicit audience consent. For a video share, prepare a current MP4, call `shareForReview`, then await `addVersion` and check the latest ready version before reporting success. `shareForReview` registers or enables the link. Hosts can pass `beforeOpen(projectId)` to prepare or validate other review content, such as a synced storyboard. The hook runs under the review lock after registration is saved, only for the first opening or when reopening a revoked link, before link or audience changes. An already-open link returns its status without running the hook. If preparation fails, retry uses the same registration, so the hook must be safe to retry. Keep the hook short because it holds the review lock. That lock is not reentrant: the hook must not call same-project review-lock operations such as `shareForReview`, `setReviewAccess`, `turnOffReviewLink`, `removeReviewProject`, or review-switch operations; they would wait on the hook itself. Use direct client requests for preparation instead. @@ -54,3 +54,60 @@ Metadata mutations and version uploads use separate cross-process locks under `. `snapshotProject` skips symlinks by default, retaining Desktop watcher, change-set and saved-render compatibility; `snapshotFiles` also skips symlink entries. Set `followSymlinks: true` for a link-aware full snapshot. The CLI-facing `projectFingerprint` opts into following linked media (with cycle detection), so edited linked files invalidate its cached render. Both comparisons ignore HTML ID stamps. Export/history metadata, caches, hidden folders and installed packages are excluded. Hosts must record the fingerprint of the actual rendered source and must not relabel an old render with a newer fingerprint. Public type exports include `ShareHost`, `ReviewClient`, `ReviewShare`, `VersionRequest`, and `Wire`, plus `@hyperframes/share/types/reviewWire` and `types/share`. Per-module entry points preserve Desktop imports during adoption. + +## Source snapshots + +`shareSources({access, spaceId})` prepares editable source for a rendered version: + +```js +const sources = shareSources({ access, spaceId }); +const result = await sources.prepare(projectPath, renderedFingerprint); +if (result.at === "ready") { + await addVersion({ + projectPath, + title, + client, + filesForExport: sources.filesForExport, + requireSource: true, + }); +} +``` + +Handle `unavailable.reason` before creating the video version. Plan ineligibility +can use video-only; changed source, conflicts and unexpected upload failures need +an explicit choice to omit source. The CLI exposes `--video-only` for that choice. +`filesForExport` only validates already-prepared source; it does not upload. + +The adapter uses the portable-source-v4 capture/manifest rules and +multipart transport. The pinned policy, Unicode 15.1 registry (with its license), +and manifest test vectors are checked into this repository. Source is captured through +verified file handles; upload bytes are streamed and checked against their hash. +Workspace limits, upload receipts and published snapshot identity are checked. +Pending uploads retain their original idempotency key across retries. A conflict +is never auto-resolved. When local source changes, the adapter cancels an older +pending upload before starting another; uploads under verification are preserved. +A stalled storage PUT stops after 60 seconds without progress and can retry with +the same upload identity. + +Default state uses `.hyperframes/share-sync..json`, with strict +account/backend/realpath binding, private atomic writes, and a process lock. +Hosts can inject a compatible `store` or read-only `existingBinding` resolver. +An external Desktop binding is reused only when exact and settled; this adapter +never writes Desktop's binding or starts a second upload on its behalf. + +Source sharing requires an authorized account and a workspace that supports editable project files. +Source-plan/feature eligibility remains server controlled. Automated fixtures do +not establish live entitlement, moderation, source download or outside-editor +acceptance. See [the source guide](https://hyperframes.heygen.com/developers/share-source). + +Tests run locally without an account or service credentials: + +```bash +node --test packages/share/tests/*.test.mjs +bun run --cwd packages/share build +``` + +The bundled Unicode data records SHA-256 hashes for its inputs in `sources`. +Those files are published in the [Unicode 15.1 database](https://www.unicode.org/Public/15.1.0/ucd/). +Keep the included Unicode license with redistributed data. The pinned version +keeps path comparison consistent across Node versions and operating systems. diff --git a/packages/share/scripts/copy-types.mjs b/packages/share/scripts/copy-types.mjs index 94b13b5991..4942530020 100644 --- a/packages/share/scripts/copy-types.mjs +++ b/packages/share/scripts/copy-types.mjs @@ -1,3 +1,6 @@ import { cp } from "node:fs/promises"; await cp("src/types", "dist/types", { recursive: true }); await cp("src/hosts.d.ts", "dist/hosts.d.ts"); + +await cp("src/sources/types.d.ts", "dist/sources/types.d.ts"); +await cp("src/sources/adapterTypes.d.ts", "dist/sources/adapterTypes.d.ts"); diff --git a/packages/share/src/index.mjs b/packages/share/src/index.mjs index 4401f442d1..b359b18d87 100644 --- a/packages/share/src/index.mjs +++ b/packages/share/src/index.mjs @@ -80,3 +80,11 @@ export { bindShareHost } from "./host.mjs"; /** @typedef {import("./types/share.js").AccessMode} AccessMode */ /** @typedef {import("./types/share.js").ReviewExportProgress} ReviewExportProgress */ export { pendingReviewExport } from "./reviewExport.mjs"; + +export { + shareSources, + shareSourceFingerprint, + createProjectShareSourceStore, +} from "./shareSources.mjs"; + +export { SourceIgnoreError } from "./sourceIgnore.mjs"; diff --git a/packages/share/src/projectLock.mjs b/packages/share/src/projectLock.mjs index 3dcb56af50..6518404357 100644 --- a/packages/share/src/projectLock.mjs +++ b/packages/share/src/projectLock.mjs @@ -159,7 +159,7 @@ async function claimDirectory(draft, lock, deadline) { throw error; } } -/** @template T @param {string} projectPath @param {"review" | "export"} lane @param {() => Promise} run +/** @template T @param {string} projectPath @param {"review" | "export" | "source" | "operation"} lane @param {() => Promise} run * @param {{ timeoutMs?: number, signal?: AbortSignal }} [options] @returns {Promise} */ export async function withProjectShareLock( projectPath, @@ -169,7 +169,16 @@ export async function withProjectShareLock( ) { const root = await realpath(projectPath); const folder = await mkdirInside(root, ".hyperframes"); - const lock = join(folder, lane === "review" ? "review.lock" : "review-export.lock"); + const lock = join( + folder, + lane === "operation" + ? "share-operation.lock" + : lane === "review" + ? "review.lock" + : lane === "source" + ? "share-source.lock" + : "review-export.lock", + ); const owner = { token: randomUUID(), pid: process.pid, hostname: hostname() }; const draft = `${lock}.${owner.token}.tmp`; const marker = `${owner.token}.json`; diff --git a/packages/share/src/projectSnapshot.mjs b/packages/share/src/projectSnapshot.mjs index 02386fadc2..7370bd839a 100644 --- a/packages/share/src/projectSnapshot.mjs +++ b/packages/share/src/projectSnapshot.mjs @@ -1,6 +1,7 @@ // @ts-check // A project's files as change detection sees them: every file the film can use (isOutsideFilm), keyed by mtime and // size, except html, keyed by content without the data-hf-id stamps. A run's change set and the watcher both read it. +import { readSourceIgnore } from "./sourceIgnore.mjs"; import fs from "node:fs/promises"; import { constants } from "node:fs"; import path from "node:path"; @@ -31,7 +32,7 @@ async function snapshotKey(full, byContent) { const stat = await handle.stat(); if (!stat.isFile()) return undefined; if (full.endsWith(".html")) return contentKey(await handle.readFile("utf8")); - if (byContent) return sha256(await handle.readFile()); + if (byContent) return await hashFile(handle); return `${stat.mtimeMs}:${stat.size}`; } catch { return undefined; @@ -40,6 +41,13 @@ async function snapshotKey(full, byContent) { } } +/** @param {import("node:fs/promises").FileHandle} handle */ +async function hashFile(handle) { + const hash = createHash("sha256"); + for await (const chunk of handle.createReadStream({ autoClose: false })) hash.update(chunk); + return hash.digest("hex"); +} + /** @param {import("node:fs").Dirent} entry @param {string} full @param {boolean} followSymlinks */ async function entryKind(entry, full, followSymlinks) { if (!entry.isSymbolicLink()) return entry; @@ -53,6 +61,7 @@ async function entryKind(entry, full, followSymlinks) { export async function snapshotProject(dir, { byContent = false, followSymlinks = false } = {}) { /** @type {Snapshot} */ const result = new Map(); + const ignored = await readSourceIgnore(dir); /** @param {string} current @param {Set} ancestors */ async function walk(current, ancestors) { const real = await fs.realpath(current).catch(() => null); @@ -67,7 +76,7 @@ export async function snapshotProject(dir, { byContent = false, followSymlinks = } for (const entry of entries) { const full = path.join(current, entry.name); - if (isOutsideFilm(path.relative(dir, full))) continue; + if (excludedFromSnapshot(dir, full, ignored)) continue; const kind = await entryKind(entry, full, followSymlinks); if (kind?.isDirectory()) await walk(full, parents); else if (kind?.isFile()) { @@ -93,11 +102,12 @@ export function snapshotFingerprint(snapshot) { export async function snapshotFiles(dir, files) { /** @type {Map} */ const result = new Map(); + const ignored = await readSourceIgnore(dir); for (const file of files) { const full = path.join(dir, file); const stat = await fs.lstat(full).catch(() => null); if (stat?.isDirectory()) return null; - const holds = stat?.isFile() && !isOutsideFilm(path.relative(dir, full)); + const holds = stat?.isFile() && !excludedFromSnapshot(dir, full, ignored); result.set(file, holds ? await snapshotKey(full, false) : undefined); } return result; @@ -115,6 +125,12 @@ export function diffChangedFiles(before, after) { return changed; } -/** @param {string} projectPath */ -export const projectFingerprint = async (projectPath) => - snapshotFingerprint(await snapshotProject(projectPath, { followSymlinks: true })); +/** @param {string} projectPath @param {{ byContent?: boolean }} [options] */ +export const projectFingerprint = async (projectPath, options) => + snapshotFingerprint(await snapshotProject(projectPath, { ...options, followSymlinks: true })); + +/** @param {string} dir @param {string} full @param {(path: string) => boolean} ignored */ +function excludedFromSnapshot(dir, full, ignored) { + const relative = path.relative(dir, full); + return isOutsideFilm(relative) || ignored(relative.split(path.sep).join("/")); +} diff --git a/packages/share/src/reviewClient.mjs b/packages/share/src/reviewClient.mjs index de3e186f04..d3ef464397 100644 --- a/packages/share/src/reviewClient.mjs +++ b/packages/share/src/reviewClient.mjs @@ -40,7 +40,8 @@ async function dataOf(reply, what) { /** @param {Response} reply @param {string} what @param {import("./types/reviewWire.js").ErrorEnvelope["data"] | undefined} data */ function responseFailure(reply, what, data) { - console.error(`[review] ${what} refused:`, reply.status, data?.reason); + if (process.env.HF_DEBUG_SHARE === "1") + console.error(`[review] ${what} refused:`, reply.status, data?.reason); const retryAfter = Number(reply.headers.get("retry-after") ?? NaN); return new ReviewFailed( reply.status, diff --git a/packages/share/src/reviewExport.mjs b/packages/share/src/reviewExport.mjs index af95e456b0..e3af240d09 100644 --- a/packages/share/src/reviewExport.mjs +++ b/packages/share/src/reviewExport.mjs @@ -39,9 +39,10 @@ import { versionSentence } from "./reviewVersionSentences.mjs"; * definitive result; `reviewSent`: cleanup cutoff, with attribution only when the accepted attempt is * known; `last`: the newest version. * @typedef {{ pending: { body: ExportRequest, videoId: string | null, projectId?: string | null, - * checkingSince?: number, snapshotRefused?: boolean, unanswered?: boolean, reviewSent?: ReviewSent } | null, - * last: { fingerprint: string, versionId: string, exportedAt: string, projectId: string, files?: boolean, checksum?: string } - * | null }} VersionRecord */ + * renderKey?: string, checkingSince?: number, snapshotRefused?: boolean, unanswered?: boolean, reviewSent?: ReviewSent } | null, + * last: { fingerprint: string, versionId: string, exportedAt: string, projectId: string, files?: boolean, + * snapshot?: ExportRequest["snapshot"], checksum?: string } + * | null, failure?: (Failure & { projectId: string }) | null }} VersionRecord */ /** `onAdded`: a version went ready, with whether it carries files and whether it is the page's first from here. * @typedef {{ onProgress?: (progress: ReviewExportProgress | null) => void, onUploaded?: () => Promise, @@ -49,10 +50,11 @@ import { versionSentence } from "./reviewVersionSentences.mjs"; /** `projectId` overrides the recorded review project; `open`: a held video is watched only while the project is open. * `filesForExport`: the synced snapshot a new version carries, null for - * none. + * none. `allowPending` lets a host treat accepted processing or screening as a successful return. * @typedef {VersionHooks & { projectPath: string, title: string, client: ReviewClient, put?: typeof putFile, * sleep?: (ms: number) => Promise, probe?: (file: string) => Promise, now?: () => number, - * projectId?: string | null, filesForExport?: FilesForRender, fromReview?: FromReview | null }} VersionRequest */ + * projectId?: string | null, filesForExport?: FilesForRender, fromReview?: FromReview | null, + * allowPending?: boolean, requireSource?: boolean, omitSource?: boolean }} VersionRequest */ /** The snapshot of `rendered`, the project as the export was rendered; null when the folder is not that render. * @typedef {(projectPath: string, rendered: string | null) => Promise} @@ -179,18 +181,36 @@ function isLast(value) { isSavedId(value.versionId) && isSavedId(value.exportedAt) && isSavedId(value.projectId) && + isLastMetadata(value) + ); +} + +/** @param {Record} value */ +function isLastMetadata(value) { + return ( isOptionalBoolean(value.files) && + isOptionalSnapshot(value.snapshot) && (value.checksum === undefined || isSavedId(value.checksum)) ); } /** @param {Record} saved - * @returns {saved is {pending?: VersionRecord["pending"], last?: SavedLast | null}} */ + * @returns {saved is {pending?: VersionRecord["pending"], last?: SavedLast | null, failure?: unknown}} */ const isExportState = (saved) => ("pending" in saved || "last" in saved) && (saved.pending == null || isPending(saved.pending)) && (saved.last == null || isLast(saved.last)); +/** @param {unknown} value @returns {value is Failure & { projectId: string }} */ +const isSavedFailure = (value) => + isJsonObject(value) && + isSavedId(value.projectId) && + typeof value.exportKey === "string" && + typeof value.sentence === "string" && + typeof value.final === "boolean" && + typeof value.exportHelps === "boolean" && + isOptionalBoolean(value.held); + /** @param {string} dir @returns {Promise} */ async function readState(dir) { const file = statePath(dir); @@ -200,6 +220,7 @@ async function readState(dir) { const { last, pending } = saved; return { pending: pending ?? null, + failure: isSavedFailure(saved.failure) ? saved.failure : null, last: typeof last?.fingerprint === "string" ? { ...last, fingerprint: last.fingerprint } : null, }; } @@ -267,7 +288,8 @@ export async function reviewVersion(projectPath, server = {}) { const last = state.last?.projectId === projectId ? state.last : null; const onServer = server.latestReadyVersionId === undefined || server.latestReadyVersionId === last?.versionId; - const failed = failures.get(key); + const savedFailure = state.failure?.projectId === projectId ? state.failure : null; + const failed = savedFailure ?? failures.get(key); return { last: last ? { exportedAt: last.exportedAt, current: last.fingerprint === now && onServer } @@ -287,8 +309,8 @@ export async function reviewVersion(projectPath, server = {}) { /** The newest MP4 and the body that adds it; a stale, non-MP4, too big or too long export never sends anything. * @param {string} dir @param {string} title @param {(file: string) => Promise} probe - * @param {FilesForRender} filesForExport */ -async function exportSource(dir, title, probe, filesForExport) { + * @param {FilesForRender} filesForExport @param {boolean} requireSource */ +async function exportSource(dir, title, probe, filesForExport, requireSource) { const latest = latestExportFile(dir); if (!latest || sourceOf(dir, await projectFingerprint(dir)) !== "ready") return { failure: local("Export an MP4 of the project as it is now first.") }; @@ -315,18 +337,34 @@ async function exportSource(dir, title, probe, filesForExport) { content_type: "video/mp4", }, }; - const snapshot = await filesForExport(dir, body.source_fingerprint).catch((error) => { - // expected: the version still goes up, and Share's files line says it has no files and offers Sync now. - console.error( - "[review files] couldn't read the synced snapshot; the version goes up without files:", - error, - ); - return null; - }); + const snapshot = await sourceSnapshot( + dir, + body.source_fingerprint, + filesForExport, + requireSource, + ); + if (missingRequiredSource(requireSource, snapshot)) + return { + failure: local( + "Source changed after preparation. Retry sharing, or choose video-only explicitly.", + ), + }; if (snapshot) body.snapshot = snapshot; return { file: latest.path, body }; } +/** @param {boolean} required @param {import("./types/reviewWire.js").SnapshotRef | null} snapshot */ +const missingRequiredSource = (required, snapshot) => required && !snapshot; + +/** @param {string} dir @param {string | null} rendered @param {FilesForRender} filesForExport @param {boolean} requireSource */ +async function sourceSnapshot(dir, rendered, filesForExport, requireSource) { + return filesForExport(dir, rendered).catch((error) => { + if (requireSource) throw error; + console.error("[review files] could not read source; adding video only:", error); + return null; + }); +} + /** @param {ExportRequest["snapshot"]} a @param {ExportRequest["snapshot"]} b */ const sameSnapshot = (a, b) => a?.space_id === b?.space_id && @@ -376,7 +414,7 @@ async function createdExport(r, id, pending, kept) { return await sendCreate(r, id, pending, kept); } catch (error) { const refused = error instanceof ReviewFailed && error.reason === "snapshot_mismatch"; - if (!refused || !pending.body.snapshot || pending.unanswered) throw error; + if (!refused || !pending.body.snapshot || pending.unanswered || r.requireSource) throw error; console.error("[review] snapshot refused; the version goes up without files:", error); const body = { ...pending.body, client_operation_id: `export-${randomUUID()}` }; delete body.snapshot; @@ -569,17 +607,31 @@ const permanentRefusal = (error) => * @param {string} id @param {ExportDTO} done @param {FromReview | null} fromReview @returns {Promise} */ async function finish(dir, state, pending, id, done, fromReview) { const ready = done.status === "ready"; - const last = { - fingerprint: pending.body.source_fingerprint ?? "", - versionId: done.version_id, - exportedAt: done.exported_at, - projectId: id, - files: Boolean(pending.body.snapshot), - checksum: pending.body.local_upload.checksum_sha256, - }; - await writeState(dir, { pending: null, last: ready ? last : state.last }); + const last = readyRecord(pending, id, done); + const failure = ready ? null : said(new ReviewFailed(200, done.error?.reason ?? "")); + await writeState(dir, { + pending: null, + last: ready ? last : state.last, + ...(failure && { + failure: { ...failure, projectId: id, exportKey: await failedExportKey(dir, pending) }, + }), + }); if (ready) await sharedFromReview(fromReview, dir, pending.reviewSent?.since); - return ready ? null : said(new ReviewFailed(200, done.error?.reason ?? "")); + return failure; +} + +/** @param {string} dir @param {NonNullable} pending */ +async function failedExportKey(dir, pending) { + if (typeof pending.renderKey === "string") return pending.renderKey; + const latest = latestExportFile(dir); + if (!latest) return ""; + const checksum = + latest.fingerprint === pending.body.source_fingerprint + ? await fileSha256Base64(latest.path).catch(() => null) + : null; + return checksum === pending.body.local_upload.checksum_sha256 + ? exportKeyOf(dir) + : `pending:${pending.body.client_operation_id}`; } /** @param {Required} r @param {(progress: ReviewExportProgress) => void} report @@ -587,17 +639,37 @@ async function finish(dir, state, pending, id, done, fromReview) { async function run(r, report) { report({ step: "preparing", sent: 0, total: 0 }); const state = await readState(r.projectPath); - const source = await exportSource(r.projectPath, r.title, r.probe, r.filesForExport); + const source = await exportSource( + r.projectPath, + r.title, + r.probe, + r.omitSource ? noSource : r.filesForExport, + r.requireSource, + ); if ("failure" in source) return source.failure ?? null; const id = r.projectId ?? (await reviewProjectId(r.projectPath)); if (!id) return local("Share the project first, then add a version."); - if (await alreadyUploaded(r.client, id, state, source.body)) return null; + if ( + sameSourceMode(r, state.last, source.body.snapshot) && + (await alreadyUploaded(r.client, id, state, source.body)) + ) + return null; return sendVersion(r, report, source, id, state); } +const noSource = async () => null; + +/** @param {Required} r @param {VersionRecord["last"]} last @param {ExportRequest["snapshot"]} snapshot */ +function sameSourceMode(r, last, snapshot) { + if (r.requireSource) return sameSnapshot(last?.snapshot, snapshot); + if (r.omitSource) return last?.files !== true; + return true; +} + /** @param {ReviewClient} client @param {string} id @param {VersionRecord} state @param {ExportRequest} body */ async function alreadyUploaded(client, id, state, body) { const last = state.last; - if (state.pending || !last || last.projectId !== id) return false; + if (state.pending || state.failure?.projectId === id || !last || last.projectId !== id) + return false; if ( last.fingerprint !== body.source_fingerprint || last.checksum !== body.local_upload.checksum_sha256 @@ -609,8 +681,10 @@ async function alreadyUploaded(client, id, state, body) { * @param {{file: string, body: ExportRequest}} source @param {string} id @param {VersionRecord} state */ async function sendVersion(r, report, source, id, state) { const first = state.last?.projectId !== id; - let pending = bodyToSend(state, source.body, id); - await writeState(r.projectPath, (state = { ...state, pending })); + let pending = bindRenderKey(bodyToSend(state, source.body, id), r.projectPath); + const sourceConflict = pendingSourceConflict(r, pending, source.body); + if (sourceConflict) return local(sourceConflict); + await writeState(r.projectPath, (state = { ...state, pending, failure: null })); try { const answer = await createdExport(r, id, pending, (next) => writeState(r.projectPath, (state = { ...state, pending: next })), @@ -636,24 +710,40 @@ async function sendVersion(r, report, source, id, state) { const done = await watch(r, id, uploaded, size, report, clock); return finishRun(r, state, pending, id, done, first); } catch (error) { - return failedSend(r.projectPath, state, error); + return failedSend(r.projectPath, state, pending, id, error); } } -/** @param {string} dir @param {VersionRecord} state @param {unknown} error */ -async function failedSend(dir, state, error) { +/** @param {string} dir @param {VersionRecord} state + * @param {NonNullable} pending @param {string} id @param {unknown} error */ +async function failedSend(dir, state, pending, id, error) { const refused = permanentRefusal(error); // An earlier create can still be in flight when the replay is refused. const unansweredCreate = state.pending?.unanswered === true && state.pending.videoId === null; - if (refused && !unansweredCreate) await writeState(dir, { ...state, pending: null }); - console.error("[review] version failed:", error); - return said(error, refused && unansweredCreate); + const failure = said(error, refused && unansweredCreate); + await writeState(dir, { + ...state, + pending: refused && !unansweredCreate ? null : state.pending, + failure: { ...failure, projectId: id, exportKey: await failedExportKey(dir, pending) }, + }); + return failure; +} + +/** @param {Required} r @param {NonNullable} pending @param {ExportRequest} fresh */ +function pendingSourceConflict(r, pending, fresh) { + if (r.requireSource && !pending.body.snapshot) + return "A pending video-only upload must finish before attaching source. Retry with --video-only, then share source again."; + if (r.omitSource && pending.body.snapshot) + return "A pending upload includes source. Check its status or retry with source before creating a video-only version."; + if (r.requireSource && !sameSnapshot(pending.body.snapshot, fresh.snapshot)) + return "A pending upload includes a different source snapshot. Check its status before sharing again."; + return null; } /** @param {Required} r @param {VersionRecord} state * @param {NonNullable} pending @param {string} id @param {ExportDTO} done @param {boolean} first */ async function finishRun(r, state, pending, id, done, first) { - if (going(done)) return stillGoing(done); + if (going(done)) return r.allowPending ? null : stillGoing(done); const failed = await finish(r.projectPath, state, pending, id, done, r.fromReview); if (!failed) { const fromReview = pending.reviewSent?.value; @@ -676,8 +766,11 @@ export async function addVersion(request) { now: () => Date.now(), onProgress: () => {}, open: () => true, - filesForExport: async () => null, + allowPending: false, + filesForExport: noSource, fromReview: null, + requireSource: false, + omitSource: false, onAdded: () => {}, ...request, projectId: request.projectId ?? null, @@ -698,7 +791,6 @@ export async function addVersion(request) { if (kept) failures.set(key, { ...failure, exportKey: exportKeyOf(r.projectPath) }); return failure?.sentence ?? null; } catch (error) { - console.error("[review] version failed:", error); const sentence = error instanceof SharingStateError ? error.message : "Couldn't add this version. Try again."; failures.set(key, { @@ -768,7 +860,7 @@ async function settleSavedExport(dir, client, fromReview) { const id = await reviewProjectId(dir); if (!pending?.videoId || !id || pending.projectId !== id) return; const done = await client.readExport(id, pending.videoId); - if (going(done)) return; + if (done.status === "upload_pending" || going(done)) return; const failure = await finish(dir, state, pending, id, done, fromReview); const key = normalize(dir); if (failure) failures.set(key, { ...failure, exportKey: exportKeyOf(dir) }); @@ -838,3 +930,23 @@ export async function pendingReviewExport(projectPath) { checksum: pending.body.local_upload.checksum_sha256, }; } + +/** @param {NonNullable} pending @param {string} id @param {ExportDTO} done */ +function readyRecord(pending, id, done) { + return { + fingerprint: pending.body.source_fingerprint ?? "", + versionId: done.version_id, + exportedAt: done.exported_at, + projectId: id, + files: Boolean(pending.body.snapshot), + ...(pending.body.snapshot && { snapshot: pending.body.snapshot }), + checksum: pending.body.local_upload.checksum_sha256, + }; +} + +/** @param {NonNullable} pending @param {string} dir */ +function bindRenderKey(pending, dir) { + return typeof pending.renderKey === "string" + ? pending + : { ...pending, renderKey: exportKeyOf(dir) }; +} diff --git a/packages/share/src/reviewUpload.mjs b/packages/share/src/reviewUpload.mjs index b11a8bfb4f..84695a8e25 100644 --- a/packages/share/src/reviewUpload.mjs +++ b/packages/share/src/reviewUpload.mjs @@ -18,6 +18,22 @@ export function fileSha256Base64(file) { /** @typedef {"sent" | "expired" | "refused" | "offline"} PutOutcome */ +/** @param {string} url */ +export function trustedUploadUrl(url) { + if (!URL.canParse(url)) return null; + const target = new URL(url); + const loopback = target.protocol === "http:" && target.hostname === "127.0.0.1"; + if ( + (target.protocol !== "https:" && !loopback) || + target.username || + target.password || + target.hash || + !reviewUploadOrigins().includes(target.origin) + ) + return null; + return target; +} + /** Streams the file to the signed URL through main's fetch (the app's proxy), the server's headers as given plus * the length, and no bearer. Nothing sent or answered for `stallMs` ends it as offline, never "Uploading" forever. * @param {{ put_url: string, headers: Record }} upload @param {string} file @param {number} size @@ -29,22 +45,8 @@ export async function putFile( onSent, { stallMs = 60_000, fetchImpl = fetch } = {}, ) { - let target; - try { - target = new URL(upload.put_url); - } catch { - return "refused"; - } - const loopback = target.protocol === "http:" && target.hostname === "127.0.0.1"; - if ( - (target.protocol !== "https:" && !loopback) || - target.username || - target.password || - target.hash || - !reviewUploadOrigins().includes(target.origin) - ) { - return "refused"; - } + const target = trustedUploadUrl(upload.put_url); + if (!target) return "refused"; const stall = new AbortController(); /** @type {ReturnType | undefined} */ let timer; diff --git a/packages/share/src/shareSources.mjs b/packages/share/src/shareSources.mjs new file mode 100644 index 0000000000..bc2f030ece --- /dev/null +++ b/packages/share/src/shareSources.mjs @@ -0,0 +1,236 @@ +// @ts-check +import { realpath } from "node:fs/promises"; +import { randomUUID } from "node:crypto"; +import { basename } from "node:path"; +import { projectFingerprint } from "./projectSnapshot.mjs"; +import { withProjectShareLock } from "./projectLock.mjs"; +import { captureProject } from "./sources/capture.mjs"; +import { sourceApi } from "./sources/api.mjs"; +import { createProjectShareSourceStore } from "./sources/store.mjs"; +import { realWait } from "./sources/transfer.mjs"; +import { recoverSourceUpload, uploadSource } from "./sources/upload.mjs"; + +/** @typedef {import("./sources/adapterTypes.js").SourceResult} SourceResult + * @typedef {import("./sources/types.js").Binding} Binding */ +/** @param {string} reason @returns {SourceResult} */ +const unavailable = (reason) => ({ at: "unavailable", reason }); +/** Content identity for sharing, including portable hidden render inputs. The Desktop watch inventory stays separate. + * @param {string} projectPath @returns {Promise} */ +export async function shareSourceFingerprint(projectPath) { + const capture = await captureProject(await realpath(projectPath)); + return capture.at === "captured" && !captureRefusal(capture) ? capture.manifest.sha256 : null; +} +/** @param {Binding} binding @param {string} space */ +function bindingRefusal(binding, space) { + if (binding.ownerSpaceId !== space) return "source_other_workspace"; + if (binding.sharedFrom) return "source_owned_by_someone_else"; + if (binding.gettingFromCloud || binding.duplicate) return "source_operation_in_progress"; + return null; +} +/** @param {import("./sources/types.js").Capture} capture */ +function captureRefusal(capture) { + if (capture.at === "too-big") return `source_${capture.over.limit}_exceeded`; + if (capture.at === "problems") return `source_${capture.problems[0]?.problem ?? "invalid"}`; + if (capture.settled.agentTurnOpen || capture.settled.projectLocked || capture.waiting.length) + return "source_edit_in_progress"; + return null; +} + +/** Prepare source explicitly before adding the video version. No unexpected network or filesystem failure is + * converted to video-only. `filesForExport` revalidates the prepared bytes and never starts another upload. + * @param {import("./sources/adapterTypes.js").SourceOptions} options */ +export function shareSources(options) { + const store = options.store ?? createProjectShareSourceStore(); + const fingerprint = options.fingerprint ?? projectFingerprint; + const signal = options.signal ?? new AbortController().signal; + /** @type {Map} */ + const prepared = new Map(); + /** @param {string} projectPath @param {string | null} rendered @returns {Promise} */ + const prepare = async (projectPath, rendered) => { + const root = await realpath(projectPath); + prepared.delete(root); + if (!enabled(options)) return unavailable("source_disabled"); + if (!rendered || (await fingerprint(root)) !== rendered) + return unavailable("source_render_changed"); + return withProjectShareLock( + root, + "source", + async () => { + const signed = await options.access(); + if (!signed?.owner) return unavailable("source_signed_out"); + const key = { backend: signed.heygenApi, account: signed.owner, projectPath: root }; + const guardedAccess = async (/** @type {string | undefined} */ refused) => { + const next = await options.access(refused); + if (!next || next.owner !== key.account || next.heygenApi !== key.backend) + throw new Error("Source account or backend changed while sharing."); + return next; + }; + const api = + options.api ?? sourceApi({ access: guardedAccess, fetchImpl: options.fetchImpl }); + const { own, existing, binding } = await selectBinding(key, options, store); + const refused = bindingRefusal(binding, options.spaceId); + if (refused) return unavailable(refused); + const result = await prepareBinding({ + binding, + own: Boolean(own), + external: Boolean(existing), + api, + store, + options, + signal, + fingerprint, + rendered, + }); + const manifest = result.manifest; + await guardedAccess(undefined); + if (result.at !== "ready" || !manifest) return result; + if (!(await stillMatches(root, rendered, manifest.sha256, fingerprint))) + return unavailable("source_render_changed"); + prepared.set(root, { + rendered, + digest: manifest.sha256, + snapshot: result.snapshot, + account: key.account, + backend: key.backend, + }); + return { at: "ready", snapshot: result.snapshot }; + }, + { signal }, + ); + }; + /** @param {string} projectPath @param {string | null} rendered */ + const filesForExport = async (projectPath, rendered) => { + const root = await realpath(projectPath); + const held = prepared.get(root); + const signed = await options.access(); + if ( + !held || + !rendered || + held.rendered !== rendered || + !sameOwner(signed, held) || + !enabled(options) + ) + return null; + return (await stillMatches(root, rendered, held.digest, fingerprint)) ? held.snapshot : null; + }; + return { prepare, filesForExport }; +} + +/** @param {import("./sources/adapterTypes.js").SourceOptions} options */ +const enabled = (options) => options.enabled?.() ?? true; +/** @param {Awaited>} signed + * @param {{account: string, backend: string}} held */ +const sameOwner = (signed, held) => + signed?.owner === held.account && signed?.heygenApi === held.backend; +/** @typedef {{ binding: Binding, own: boolean, external: boolean, api: import("./sources/api.mjs").SourceApi, + * store: import("./sources/adapterTypes.js").SourceStore, options: import("./sources/adapterTypes.js").SourceOptions, + * signal: AbortSignal, fingerprint: (path: string) => Promise, rendered: string }} Preparation */ +/** @param {Preparation} job @returns {Promise} */ +async function prepareBinding(job) { + const { binding, api, fingerprint, rendered } = job; + const limits = await api.limits(binding.ownerSpaceId); + if (!limits.syncAllowed) return unavailable("source_plan_required"); + const capture = await captureProject(binding.projectPath, { limits: limits.push }); + const bad = captureRefusal(capture); + if (bad) return unavailable(bad); + if (capture.at !== "captured") return unavailable("source_invalid"); + if ((await fingerprint(binding.projectPath)) !== rendered) + return unavailable("source_render_changed"); + const result = await snapshotFor(job, capture.manifest, limits); + return { ...result, manifest: capture.manifest }; +} +/** @param {Preparation} job @param {import("./sources/types.js").Manifest} manifest + * @param {Extract} limits @returns {Promise} */ +async function snapshotFor(job, manifest, limits) { + const { binding, api, store, options, signal } = job; + const blocked = await recoverEarlierCapture(job, manifest.sha256); + if (blocked) return blocked; + if (binding.base?.manifestSha256 === manifest.sha256 && !binding.inflight) + return reuseSnapshot(api, binding, manifest.sha256); + if (job.external) return unavailable("source_sync_required"); + if (!job.own && limits.compositions >= limits.maxCompositions) + return unavailable("source_composition_limit"); + await store.write(binding); + binding.composition = await api.create( + binding.ownerSpaceId, + binding.compositionId, + basename(binding.projectPath), + ); + await store.write(binding); + return uploadSource({ binding, manifest, api, store, signal, ...uploadOptions(options) }); +} +/** @param {Preparation} job @param {string} digest */ +function recoverEarlierCapture({ external, binding, api, store }, digest) { + const inflight = binding.inflight; + if (external || !inflight || inflight.manifestSha256 === digest) return null; + return recoverSourceUpload({ binding, api, store }); +} + +/** @param {import("./sources/adapterTypes.js").SourceOptions} options */ +function uploadOptions(options) { + return { + fetchImpl: options.fetchImpl ?? fetch, + wait: options.wait ?? realWait, + timeoutMs: options.verificationTimeoutMs ?? 120_000, + onProgress: options.onProgress ?? (() => {}), + }; +} + +/** @param {import("./sources/types.js").BindingKey} key @param {import("./sources/adapterTypes.js").SourceOptions} options + * @param {import("./sources/adapterTypes.js").SourceStore} store */ +async function selectBinding(key, options, store) { + const own = await store.read(key); + const existing = own ? null : await options.existingBinding?.(key); + return { own, existing, binding: own ?? existing ?? newBinding(key, options.spaceId) }; +} +/** @param {import("./sources/types.js").BindingKey} key @param {string} space @returns {Binding} */ +function newBinding(key, space) { + return { + ...key, + version: 1, + compositionId: randomUUID(), + ownerSpaceId: space, + boundAt: Date.now(), + composition: null, + etag: null, + base: null, + inflight: null, + }; +} +/** @param {import("./sources/api.mjs").SourceApi} api @param {Binding} binding @param {string} digest @returns {Promise} */ +async function reuseSnapshot(api, binding, digest) { + if (!binding.base) return unavailable("source_sync_required"); + const remote = await api.snapshot( + binding.ownerSpaceId, + binding.compositionId, + binding.base.snapshotId, + ); + if ( + remote.id !== binding.base.snapshotId || + remote.compositionId !== binding.compositionId || + remote.manifestSha256 !== digest || + remote.manifest?.sha256 !== digest || + remote.publicationOutcome !== "published" + ) + return unavailable("source_snapshot_mismatch"); + return { + at: "ready", + snapshot: { + space_id: binding.ownerSpaceId, + composition_id: binding.compositionId, + snapshot_id: remote.id, + }, + }; +} +/** @param {string} root @param {string} rendered @param {string} digest @param {(path: string) => Promise} fingerprint */ +async function stillMatches(root, rendered, digest, fingerprint) { + if ((await fingerprint(root)) !== rendered) return false; + const capture = await captureProject(root); + return ( + !captureRefusal(capture) && + capture.at === "captured" && + capture.manifest.sha256 === digest && + (await fingerprint(root)) === rendered + ); +} +export { createProjectShareSourceStore } from "./sources/store.mjs"; diff --git a/packages/share/src/sourceIgnore.mjs b/packages/share/src/sourceIgnore.mjs new file mode 100644 index 0000000000..3928b94e9f --- /dev/null +++ b/packages/share/src/sourceIgnore.mjs @@ -0,0 +1,92 @@ +// @ts-check +import { constants } from "node:fs"; +import { lstat, open } from "node:fs/promises"; +import { join } from "node:path"; + +export class SourceIgnoreError extends Error { + code = "invalid_source_ignore"; +} +const scratch = (/** @type {string} */ path) => /(?:^|\/)[^/]+\.(?:log|swp)$/.test(path); + +/** Explicit, project-relative exclusions. This only removes files; it cannot override safety exclusions. + * @param {string} root @returns {Promise<(path: string) => boolean>} */ +export async function readSourceIgnore(root) { + const file = join(root, ".hyperframesignore"); + const invalid = () => + new SourceIgnoreError( + ".hyperframesignore must be a regular file inside the project, smaller than 64 KiB.", + ); + const handle = await open( + file, + constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0) | (constants.O_NONBLOCK ?? 0), + ).catch(async (/** @type {NodeJS.ErrnoException} */ error) => { + if (error.code !== "ENOENT") throw invalid(); + // An absent file means no exclusions; a dangling symlink is invalid. + const named = await lstat(file).catch((/** @type {NodeJS.ErrnoException} */ missing) => { + if (missing.code === "ENOENT") return null; + throw invalid(); + }); + if (named) throw invalid(); + return null; + }); + if (!handle) return scratch; + let text; + try { + // Validate the opened descriptor before reading. lstat additionally rejects links on + // platforms without O_NOFOLLOW; it never authorizes a later open of this path. + const [stat, named] = await Promise.all([handle.stat(), lstat(file)]); + if ( + !stat.isFile() || + stat.size >= 65536 || + !named.isFile() || + stat.ino !== named.ino || + stat.dev !== named.dev + ) + throw invalid(); + const buffer = Buffer.alloc(65536); + let length = 0; + while (length < buffer.length) { + const { bytesRead } = await handle.read(buffer, length, buffer.length - length, length); + if (!bytesRead) break; + length += bytesRead; + } + if (length === buffer.length) throw invalid(); + text = buffer.subarray(0, length).toString("utf8"); + } finally { + await handle.close(); + } + const paths = text + .split(/\r?\n/) + .map((line) => line.trim()) + .filter((line) => line && !line.startsWith("#")); + const entries = paths.map(ignorePattern); + return (path) => scratch(path) || entries.some((entry) => entry.test(path)); +} + +/** @param {string} entry */ +function ignorePattern(entry) { + const path = entry.replace(/\/$/, ""); + const invalid = () => + new SourceIgnoreError( + ".hyperframesignore accepts project-relative paths or patterns with one * wildcard. Negation, traversal, and excluding index.html are not supported.", + ); + if (!validPatternPath(path)) throw invalid(); + const escaped = path + .split("*") + .map((part) => part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")) + .join("[^/]*"); + const prefix = path.includes("*") && !path.includes("/") ? "(?:^|/)" : "^"; + const pattern = new RegExp(`${prefix}${escaped}(?:/|$)`); + if (pattern.test("index.html")) throw invalid(); + return pattern; +} + +/** @param {string} path */ +function validPatternPath(path) { + return ( + !/[\\?![\]:]/.test(path) && + !path.includes("\0") && + !path.split("/").some((part) => !part || part === "." || part === "..") && + path.split("*").length <= 2 + ); +} diff --git a/packages/share/src/sources/adapterTypes.d.ts b/packages/share/src/sources/adapterTypes.d.ts new file mode 100644 index 0000000000..497c4a9043 --- /dev/null +++ b/packages/share/src/sources/adapterTypes.d.ts @@ -0,0 +1,39 @@ +import type { Binding, BindingKey, Manifest } from "./types.js"; +import type { SnapshotRef } from "../types/reviewWire.js"; +import type { SignedInAccess } from "../signedInRequest.mjs"; +import type { SourceApi } from "./api.mjs"; + +export interface SourceStore { + read(key: BindingKey): Promise; + write(binding: Binding): Promise; +} +export type SourceResult = + | { at: "ready"; snapshot: SnapshotRef } + | { at: "unavailable"; reason: string }; +export interface SourceOptions { + access: SignedInAccess; + spaceId: string; + store?: SourceStore; + enabled?: () => boolean; + fingerprint?: (path: string) => Promise; + /** Host-owned Desktop bindings may be read for exact reuse, never overwritten. */ + existingBinding?: (key: BindingKey) => Promise; + fetchImpl?: typeof fetch; + signal?: AbortSignal; + verificationTimeoutMs?: number; + onProgress?: (bytes: number) => void; + /** Test/host seams; the default is the authenticated v3 client. */ + api?: SourceApi; + wait?: (ms: number, signal?: AbortSignal) => Promise; +} +export interface SourceRun { + binding: Binding; + manifest: Manifest; + api: SourceApi; + store: SourceStore; + fetchImpl: typeof fetch; + signal: AbortSignal; + wait: (ms: number, signal?: AbortSignal) => Promise; + timeoutMs: number; + onProgress: (bytes: number) => void; +} diff --git a/packages/share/src/sources/api.mjs b/packages/share/src/sources/api.mjs new file mode 100644 index 0000000000..d91ab9d347 --- /dev/null +++ b/packages/share/src/sources/api.mjs @@ -0,0 +1,114 @@ +// @ts-check +import { signedInRequest } from "../signedInRequest.mjs"; +import { SyncApiError, refusalOf } from "./errors.mjs"; +import { + beginOf, + grantsOf, + objectOf, + uploadOf, + syncLimitsOf, + compositionOf, + snapshotOf, +} from "./wire.mjs"; + +/** @param {{ access: import("../signedInRequest.mjs").SignedInAccess, fetchImpl?: typeof fetch }} deps */ +export function sourceApi({ access, fetchImpl = fetch }) { + const request = signedInRequest({ + access, + fetchImpl, + timeoutMs: 120_000, + tag: "share-source", + host: "heygenApi", + offline: () => new SyncApiError("offline"), + signedOut: () => new SyncApiError("signed-out"), + }); + /** @param {string} method @param {string} route @param {unknown} [body] @param {Record} [headers] */ + const send = async (method, route, body, headers) => { + const { reply } = await request(method, route, body, headers); + if (!reply.ok) throw await refusalOf(reply); + return objectOf(await reply.json(), "envelope").data; + }; + /** @param {string} space @param {string} composition */ + const path = (space, composition) => + `/v3/hyperframes/workspaces/${encodeURIComponent(space)}/compositions/${encodeURIComponent(composition)}`; + return { + /** @param {string} space */ + limits: async (space) => + syncLimitsOf( + await send( + "GET", + `/v3/hyperframes/workspaces/${encodeURIComponent(space)}/composition-sync/limits`, + ), + ), + /** @param {string} space @param {string} composition @param {string} title */ + create: async (space, composition, title) => + compositionOf(await send("PUT", path(space, composition), { title })), + /** @param {string} space @param {string} composition @param {string} snapshot */ + snapshot: async (space, composition, snapshot) => + snapshotOf( + await send( + "GET", + `${path(space, composition)}/snapshots/${encodeURIComponent(snapshot)}?include=manifest`, + ), + ), + /** @param {string} space @param {string} composition @param {import("./types.js").BeginRequest} body */ + begin: async (space, composition, body) => + beginOf( + await send( + "POST", + `${path(space, composition)}/uploads`, + { + base_snapshot_id: body.baseSnapshotId, + resolves_conflict_snapshot_ids: [], + client_type: "cli", + manifest_sha256: body.manifest.sha256, + manifest: body.manifest.document, + }, + { "Idempotency-Key": body.idempotencyKey }, + ), + false, + ), + /** @param {string} space @param {string} composition @param {string} upload @param {import("./types.js").GrantRequest[]} files */ + uploadUrls: async (space, composition, upload, files) => + grantsOf( + await send( + "POST", + `${path(space, composition)}/uploads/${encodeURIComponent(upload)}/upload-urls`, + { + files: files.map((file) => ({ + sha256: file.sha256, + ...(file.multipartUploadId && { multipart_upload_id: file.multipartUploadId }), + ...(file.parts && { + parts: file.parts.map((part) => ({ + part_number: part.partNumber, + sha256: part.sha256, + })), + }), + })), + }, + ), + ), + /** @param {string} space @param {string} composition @param {string} upload */ + status: async (space, composition, upload) => + uploadOf( + await send("GET", `${path(space, composition)}/uploads/${encodeURIComponent(upload)}`), + ), + /** @param {string} space @param {string} composition @param {string} upload */ + cancel: async (space, composition, upload) => + uploadOf( + await send( + "POST", + `${path(space, composition)}/uploads/${encodeURIComponent(upload)}/cancel`, + ), + ), + /** @param {string} space @param {string} composition @param {string} upload */ + submit: async (space, composition, upload) => + uploadOf( + await send( + "POST", + `${path(space, composition)}/uploads/${encodeURIComponent(upload)}/verification`, + ), + ), + }; +} +/** @typedef {ReturnType} SourceApi */ diff --git a/packages/share/src/sources/capture.mjs b/packages/share/src/sources/capture.mjs new file mode 100644 index 0000000000..a82366bdb5 --- /dev/null +++ b/packages/share/src/sources/capture.mjs @@ -0,0 +1,264 @@ +// @ts-check +// Captures a project folder as the canonical manifest the server accepts: every portable regular file with its +// SHA-256 and length. A file that cannot be read, a link, a special file or a name no client can store fails the +// capture with a list of them; it never becomes a deletion. Limits are checked from sizes alone, before any hashing. +import { readSourceIgnore } from "../sourceIgnore.mjs"; +import { createHash } from "node:crypto"; +import { constants } from "node:fs"; +import { lstat, open, readdir, realpath } from "node:fs/promises"; +import { dirname, join } from "node:path"; + +import { ENTRYPOINT, ManifestInvalid, canonicalBytes, parseManifest } from "./manifest.mjs"; +import { V1_LIMITS, overLimit } from "./limits.mjs"; +import { + PathViolation, + checkInventoryPaths, + classifyPath, + excludedFolder, + prefiltered, + skippedSymlink, + validatePath, +} from "./pathPolicy.mjs"; +import { readRenderOutputs, settledState } from "./projectState.mjs"; + +/** @typedef {import("./types.js").CaptureProblem} CaptureProblem @typedef {import("./types.js").Found} Found + * @typedef {import("./types.js").Walk} Walk @typedef {import("./types.js").Capture} Capture */ + +/** Files up to this size use one bounded buffer; larger files stream from the verified handle. */ +const INLINE_HASH_BYTES = 4 * 1024 * 1024; +const HASHING_AT_ONCE = 4; + +/** @param {string} root @param {string} rel @param {import("node:fs").Dirent} entry @param {Walk} walk + * @param {string[]} dirs */ +async function visit(root, rel, entry, walk, dirs) { + if (entry.isDirectory()) { + if (!excludedFolder(rel)) dirs.push(rel); + return; + } + const action = classifyPath(rel).client_action; + if (action === "exclude") return; + if (action === "wait_then_exclude") return void walk.waiting.push(rel); + if (entry.isSymbolicLink()) { + if (skippedSymlink(rel)) walk.skippedLinks.push(rel); + else walk.problems.push({ path: rel, problem: "symlink" }); + return; + } + if (!entry.isFile()) return void walk.problems.push({ path: rel, problem: "special-file" }); + await visitFile(root, rel, walk); +} +/** @param {string} root @param {string} rel @param {Walk} walk */ +async function visitFile(root, rel, walk) { + try { + validatePath(rel); + } catch (error) { + if (!(error instanceof PathViolation)) throw error; + return void walk.problems.push({ path: rel, problem: "invalid-name", code: error.code }); + } + const full = join(root, rel); + try { + const { size, mtimeMs, ino, dev } = await lstat(full); + walk.files.push({ path: rel, full, size, mtimeMs, ino, dev }); + } catch { + walk.problems.push({ path: rel, problem: "unreadable" }); + } +} + +/** A folder that was a link, or another folder, by the time it was read. */ +class FolderMoved extends Error {} + +/** A folder's entries, read only while the same real folder stands at its path before and after: one swapped for a + * link to somewhere else is never listed. @param {string} root @param {string} dir */ +async function listFolder(root, dir) { + const full = join(root, dir); + const before = await lstat(full); + if (!before.isDirectory()) throw new FolderMoved(); + const entries = await readdir(full, { withFileTypes: true }); + const after = await lstat(full); + if (!after.isDirectory() || after.ino !== before.ino || after.dev !== before.dev) + throw new FolderMoved(); + return entries; +} + +/** Every file a capture would list, and what keeps one from being listed. @param {string} root + * @param {(rel: string) => boolean} renderOutput @returns {Promise} */ +async function walkProject(root, renderOutput) { + /** @type {Walk} */ + const walk = { files: [], problems: [], waiting: [], skippedLinks: [] }; + const ignored = await readSourceIgnore(root); + const dirs = [""]; + for (let dir = dirs.pop(); dir !== undefined; dir = dirs.pop()) { + let entries; + try { + entries = await listFolder(root, dir); + } catch (error) { + const changed = error instanceof FolderMoved; + walk.problems.push({ path: dir, problem: changed ? "changed" : "unreadable" }); + continue; + } + for (const entry of entries) { + const rel = dir ? `${dir}/${entry.name}` : entry.name; + if (prefiltered(entry.name) || renderOutput(rel) || ignored(rel)) continue; + await visit(root, rel, entry, walk, dirs); + } + } + return walk; +} + +/** The manifest's canonical length, from paths and sizes alone: every SHA-256 is 64 characters. + * @param {Found[]} files */ +const manifestBytes = (files) => + canonicalBytes({ + format_version: 1, + entrypoint: ENTRYPOINT, + files: files.map(({ path, size }) => ({ path, sha256: "0".repeat(64), size })), + }).length; + +/** A file changed this recently can be written again within its time's granularity, keeping its size and time. */ +const SETTLED_MS = 2_000; + +/** A file's SHA-256 by path, size, time and inode, kept for the launch so a check after a focus reads no bytes. + * Only a settled file's hash is kept. */ +export function hashMemo(now = Date.now) { + /** @type {Map} */ + const known = new Map(); + return { + /** @param {Found} file */ + get: (file) => { + const kept = known.get(file.full); + const same = + kept?.size === file.size && kept.mtimeMs === file.mtimeMs && kept.ino === file.ino; + return same ? kept.sha256 : null; + }, + /** @param {Found} file @param {string} sha256 */ + set: (file, sha256) => { + if (now() - file.mtimeMs > SETTLED_MS) known.set(file.full, { ...file, sha256 }); + }, + }; +} + +/** The file the walk listed, as an open handle: never through a link at its own name (O_NOFOLLOW), and only when the + * opened file is the same regular file (inode, device, size) found inside the project, so a file or folder swapped + * for a link after the walk is refused rather than followed. Null when it is not. @param {string} root + * @param {Found} file @param {typeof realpath} [resolve] */ +async function openListed(root, file, resolve = realpath) { + const handle = await open(file.full, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0)).catch( + (/** @type {NodeJS.ErrnoException} */ error) => { + if (error.code === "ELOOP" || error.code === "EMLINK") return null; + throw error; + }, + ); + if (!handle) return null; + try { + const opened = await handle.stat(); + const same = + opened.isFile() && + opened.ino === file.ino && + opened.dev === file.dev && + opened.size === file.size && + (await resolve(dirname(file.full))) === join(root, dirname(file.path)); + if (same) return handle; + } catch (error) { + await handle.close(); + throw error; + } + await handle.close(); + return null; +} + +/** The file's SHA-256, read through the handle `openListed` checked; null when the file is not the one listed, or its + * bytes changed while being read. `root` is the project's real path; `resolve` finds a folder's real path. + * @param {string} root @param {Found} file @param {typeof realpath} [resolve] */ +export async function hashListedFile(root, file, resolve = realpath) { + const handle = await openListed(root, file, resolve); + if (!handle) return null; + try { + const sha256 = + file.size <= INLINE_HASH_BYTES + ? await handle + .readFile() + .then((bytes) => + bytes.length === file.size ? createHash("sha256").update(bytes).digest("hex") : null, + ) + : await hashHandle(handle); + const after = await handle.stat(); + return after.size === file.size && after.mtimeMs === file.mtimeMs ? sha256 : null; + } finally { + await handle.close(); + } +} + +/** @param {string} root @param {Found[]} files @param {ReturnType} memo + * @returns {Promise<{ hashed: import("./types.js").ManifestFile[], problems: CaptureProblem[] }>} */ +async function hashAll(root, files, memo) { + /** @type {import("./types.js").ManifestFile[]} */ + const hashed = []; + /** @type {CaptureProblem[]} */ + const problems = []; + const queue = [...files]; + const worker = async () => { + for (let file = queue.shift(); file; file = queue.shift()) { + const sha256 = memo.get(file) ?? (await hashListedFile(root, file).catch(() => undefined)); + if (sha256 === undefined) problems.push({ path: file.path, problem: "unreadable" }); + else if (sha256 === null) problems.push({ path: file.path, problem: "changed" }); + else { + memo.set(file, sha256); + hashed.push({ path: file.path, sha256, size: file.size }); + } + } + }; + await Promise.all(Array.from({ length: HASHING_AT_ONCE }, worker)); + return { hashed, problems }; +} + +/** Problems that keep the files found from being one manifest: two names one disk stores as one, no index.html. + * @param {Found[]} files @returns {CaptureProblem[]} */ +function inventoryProblems(files) { + if (!files.some((file) => file.path === ENTRYPOINT)) + return [{ path: ENTRYPOINT, problem: "no-entrypoint" }]; + try { + checkInventoryPaths(files.map((file) => file.path)); + return []; + } catch (error) { + if (!(error instanceof PathViolation)) throw error; + return [{ path: error.path, problem: "invalid-name", code: error.code }]; + } +} + +/** Captures `root` (a project's real path). `memo` reuses hashes of unchanged files; a send should pass a fresh one. + * @param {string} root @param {{ memo?: ReturnType, limits?: import("./types.js").Limits }} [options] + * @returns {Promise} */ +export async function captureProject(root, { memo = hashMemo(), limits = V1_LIMITS } = {}) { + const renderOutput = await readRenderOutputs(root); + const walk = await walkProject(root, renderOutput); + const problems = walk.problems.length ? walk.problems : inventoryProblems(walk.files); + if (problems.length) return { at: "problems", problems }; + const over = overLimit(walk.files, manifestBytes(walk.files), limits); + if (over) return { at: "too-big", over }; + const { hashed, problems: unhashed } = await hashAll(await realpath(root), walk.files, memo); + if (unhashed.length) return { at: "problems", problems: unhashed }; + try { + const manifest = parseManifest({ format_version: 1, entrypoint: ENTRYPOINT, files: hashed }); + const settled = await settledState(root); + return { + at: "captured", + manifest, + settled, + waiting: walk.waiting, + skippedLinks: walk.skippedLinks, + }; + } catch (error) { + if (!(error instanceof ManifestInvalid)) throw error; + const first = error.violations[0]; + return { + at: "problems", + problems: [{ path: first?.path ?? "", problem: "invalid-name", code: error.code }], + }; + } +} + +/** @param {import("node:fs/promises").FileHandle} handle */ +async function hashHandle(handle) { + const hash = createHash("sha256"); + for await (const chunk of handle.createReadStream({ autoClose: false })) hash.update(chunk); + return hash.digest("hex"); +} diff --git a/packages/share/src/sources/contract.mjs b/packages/share/src/sources/contract.mjs new file mode 100644 index 0000000000..1832ab9ea1 --- /dev/null +++ b/packages/share/src/sources/contract.mjs @@ -0,0 +1,13 @@ +// @ts-check +// Load the bundled snapshot policy and Unicode registries from JSON or Brotli. +import { existsSync, readFileSync } from "node:fs"; +import { brotliDecompressSync } from "node:zlib"; + +/** A registry's parsed JSON. @param {string} name a file in contract/, such as "path-policy.json" @returns {any} */ +export function readContract(name) { + const packed = new URL(`./contract/${name}.br`, import.meta.url); + const text = existsSync(packed) + ? brotliDecompressSync(readFileSync(packed)).toString("utf8") + : readFileSync(new URL(`./contract/${name}`, import.meta.url), "utf8"); + return JSON.parse(text); +} diff --git a/packages/share/src/sources/contract/LICENSE-Unicode.txt b/packages/share/src/sources/contract/LICENSE-Unicode.txt new file mode 100644 index 0000000000..56da589128 --- /dev/null +++ b/packages/share/src/sources/contract/LICENSE-Unicode.txt @@ -0,0 +1,39 @@ +UNICODE LICENSE V3 + +COPYRIGHT AND PERMISSION NOTICE + +Copyright © 1991-2026 Unicode, Inc. + +NOTICE TO USER: Carefully read the following legal agreement. BY +DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING DATA FILES, AND/OR +SOFTWARE, YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE +TERMS AND CONDITIONS OF THIS AGREEMENT. IF YOU DO NOT AGREE, DO NOT +DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE THE DATA FILES OR SOFTWARE. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of data files and any associated documentation (the "Data Files") or +software and any associated documentation (the "Software") to deal in the +Data Files or Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, and/or sell +copies of the Data Files or Software, and to permit persons to whom the +Data Files or Software are furnished to do so, provided that either (a) +this copyright and permission notice appear with all copies of the Data +Files or Software, or (b) this copyright and permission notice appear in +associated Documentation. + +THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF +THIRD PARTY RIGHTS. + +IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE +BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, +OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA +FILES OR SOFTWARE. + +Except as contained in this notice, the name of a copyright holder shall +not be used in advertising or otherwise to promote the sale, use or other +dealings in these Data Files or Software without prior written +authorization of the copyright holder. diff --git a/packages/share/src/sources/contract/path-policy.json b/packages/share/src/sources/contract/path-policy.json new file mode 100644 index 0000000000..1ca5982201 --- /dev/null +++ b/packages/share/src/sources/contract/path-policy.json @@ -0,0 +1,311 @@ +{ + "policy_version": "portable-source-v4", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "fields": ["format_version", "entrypoint", "files"], + "file_fields": ["path", "sha256", "size"], + "sha256": "64 lowercase hex characters: the SHA-256 of the file's exact bytes", + "size": "the file's byte length, an integer from 0 to 9007199254740991 (2^53 - 1, the largest integer every JSON client reads exactly)", + "same_digest_same_size": "two entries with the same sha256 must have the same size", + "not_in_manifest": "upload state, latest pointer, authors, comments, timestamps, URLs, S3 keys and sync binding metadata" + }, + "canonical_encoding": { + "files_order": "ascending by the UTF-8 bytes of path (not UTF-16 code units: JavaScript's default sort differs above U+FFFF)", + "object_keys": "sorted; every key is ASCII, so byte, code-point and UTF-16 order agree", + "whitespace": "none outside strings: separators are ',' and ':'", + "strings": "UTF-8; only '\"' and '\\' are escaped, because policy-valid paths contain no control characters or lone surrogates", + "numbers": "integers in decimal with no sign, fraction or exponent", + "manifest_sha256": "lowercase hex SHA-256 of the canonical bytes" + }, + "unicode": { + "version": "15.1.0", + "table": "unicode-15.1.0.json", + "assigned_only": "every code point must be assigned in Unicode 15.1; unassigned and future code points are refused", + "normalization": "every path must already be NFC", + "comparison_key": "NFC(full_casefold(NFC(segment))), with default full case folding (CaseFolding.txt status C and F)" + }, + "path": { + "max_path_bytes": 1024, + "max_segment_bytes": 240, + "separator": "/", + "forbidden_characters": "<>:\"|?*\\", + "reserved_segment_regex": "(?:con|prn|aux|nul|com[1-9\u00b9\u00b2\u00b3]|lpt[1-9\u00b9\u00b2\u00b3])(?:\\..*)?", + "reserved_segment_match": "full match against each segment's comparison key, so CON, Con.txt and nul.tar.gz are all reserved", + "canonical_spelling_roots": [".media", ".hyperframes"], + "checks": [ + { + "code": "path_empty", + "rule": "the path is not the empty string" + }, + { + "code": "path_invalid_character", + "rule": "no C0 or C1 control character, DEL, lone surrogate or forbidden character" + }, + { + "code": "path_unassigned_code_point", + "rule": "every code point is assigned in Unicode 15.1" + }, + { + "code": "path_not_nfc", + "rule": "the path equals its NFC form" + }, + { + "code": "path_too_long", + "rule": "at most max_path_bytes UTF-8 bytes" + }, + { + "code": "path_not_relative", + "rule": "does not start with '/'" + }, + { + "code": "path_empty_segment", + "rule": "no empty segment ('a//b', a trailing '/')" + }, + { + "code": "path_dot_segment", + "rule": "no '.' or '..' segment" + }, + { + "code": "segment_too_long", + "rule": "each segment is at most max_segment_bytes UTF-8 bytes" + }, + { + "code": "segment_trailing_dot_or_space", + "rule": "no segment ends in '.' or ' ' (Windows strips them)" + }, + { + "code": "reserved_name", + "rule": "no segment matches reserved_segment_regex" + }, + { + "code": "reserved_path_alias", + "rule": "a first segment whose comparison key equals a canonical_spelling_roots entry is spelled exactly like it, and an allowed rule that matches the folded path also matches the path as spelled" + }, + { + "code": "excluded_path", + "rule": "the first rule matching the folded path does not have server_action 'reject'" + } + ], + "check_order": "checks run in the order listed; the first failing check names the error" + }, + "matching": { + "syntax": "each rule's regex must match the whole path (Python re.fullmatch, JavaScript ^(?:regex)$ with the 's' and 'u' flags)", + "subject": "the folded path: every segment replaced by its comparison key, joined with '/'", + "first_match_wins": true, + "case": "rule regexes are written in lowercase, because they are matched against the case-folded path", + "client_actions": { + "include": "list the file", + "exclude": "leave the file out", + "wait_then_exclude": "wait for the writer to finish (the reserved sibling may be incomplete), then leave the marker out" + }, + "rule_order": "every rule that rejects at any depth comes before the first allow rule, so a credential, environment file, package-manager config, VCS or dependency directory, agent state, build cache or OS metadata inside an allowed .hyperframes subtree stays out" + }, + "rules": [ + { + "id": "media-lock", + "regex": "\\.media/\\.lock", + "client_action": "exclude", + "server_action": "reject", + "basis": "Process lock held by the media writer, not project content" + }, + { + "id": "media-reservation", + "regex": "\\.media/(?:audio/(?:bgm|sfx|voice)|images|video|luts|recipes)/[^/]+\\.hf[0-9a-f]{6}\\.tmp", + "client_action": "wait_then_exclude", + "server_action": "reject", + "basis": "Media id reservation: the sibling asset may still be incomplete, so capture waits for the writer to finish" + }, + { + "id": "media-ledger", + "regex": "\\.media/manifest\\.jsonl", + "client_action": "exclude", + "server_action": "reject", + "basis": "Generated media metadata that the project does not use for preview or rendering" + }, + { + "id": "unfinished-writes", + "regex": "(?:[^/]+/)*(?:[^/]+\\.hf[0-9a-f]{6}\\.tmp|[^/]*\\.(?:tmp|part|swp)|[^/]+~)", + "client_action": "exclude", + "server_action": "reject", + "basis": "Unfinished or abandoned writes at any depth: core's atomic-write temp .hfXXXXXX.tmp, *.tmp, *.part, editor *.swp and *~" + }, + { + "id": "render-temp-dirs", + "regex": "(?:[^/]+/)*(?:(?:work-[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}|hf-render|\\.[^/]+\\.hf-transaction)-[A-Za-z0-9]{6}|[^/]+\\.assemble-work-[A-Za-z0-9]{6})(?:/.*)?", + "client_action": "exclude", + "server_action": "reject", + "basis": "Render work directories at any depth (frames, often GBs): core RENDER_TEMP_DIR (packages/core/src/projectFolders.ts) plus distributed assembly's .assemble-work-XXXXXX" + }, + { + "id": "agent-client-state", + "regex": "(?:[^/]+/)*(?:\\.claude|\\.codex|\\.agents|\\.cursor|\\.vscode|\\.idea)(?:/.*)?", + "client_action": "exclude", + "server_action": "reject", + "basis": "Agent and IDE state at any depth; Desktop vendors .claude/skills into every project and regenerates it" + }, + { + "id": "dependencies-and-git", + "regex": "(?:[^/]+/)*(?:\\.git|\\.svn|\\.hg|node_modules)(?:/.*)?", + "client_action": "exclude", + "server_action": "reject", + "basis": "Version control and installed dependencies at any depth" + }, + { + "id": "build-caches", + "regex": "(?:[^/]+/)*(?:\\.cache|\\.vite|\\.next|\\.turbo|\\.parcel-cache)(?:/.*)?", + "client_action": "exclude", + "server_action": "reject", + "basis": "Build tool caches at any depth" + }, + { + "id": "environment-secrets", + "regex": "(?:[^/]+/)*\\.env(?:rc|\\.[^/]+)?", + "client_action": "exclude", + "server_action": "reject", + "basis": "Credentials: .env, every .env.* (templates included: real keys land there and no reader needs them) and .envrc, at any depth" + }, + { + "id": "package-manager-config", + "regex": "(?:[^/]+/)*(?:\\.npmrc|\\.yarnrc|\\.yarnrc\\.yml|pip\\.conf)", + "client_action": "exclude", + "server_action": "reject", + "basis": "May hold registry tokens, and nothing in a HyperFrames project reads them; stripping credentials would change the bytes" + }, + { + "id": "credential-files", + "regex": "(?:[^/]+/)*(?:\\.netrc|\\.pypirc|\\.git-credentials|[^/]*\\.(?:pem|p12|pfx)|id_rsa[^/]*|id_ed25519[^/]*|(?:\\.ssh|\\.aws)(?:/.*)?)", + "client_action": "exclude", + "server_action": "reject", + "basis": "Credential files by name at any depth. *.key is deliberately absent: Keynote decks are plausible project sources" + }, + { + "id": "os-metadata", + "regex": "(?:[^/]+/)*(?:\\.ds_store|thumbs\\.db|desktop\\.ini|\\._[^/]*|__macosx(?:/.*)?)", + "client_action": "exclude", + "server_action": "reject", + "basis": "Operating-system metadata: it changes when a folder is browsed and would show as false edits and conflicts" + }, + { + "id": "portable-transcripts", + "regex": "\\.hyperframes/transcripts/(?:[^/]+/)*[^/]+\\.json", + "client_action": "include", + "server_action": "allow", + "basis": "Completed transcripts, keyed by media hash; costly to regenerate" + }, + { + "id": "portable-transcription-settings", + "regex": "\\.hyperframes/transcription\\.json", + "client_action": "include", + "server_action": "allow", + "basis": "Transcription (ASR) preferences, not run state; Desktop's Duplicate copies it with the transcripts" + }, + { + "id": "portable-brand-kit", + "regex": "\\.hyperframes/brand-kit\\.json", + "client_action": "include", + "server_action": "allow", + "basis": "The project's brand kit selection is authored, portable project content" + }, + { + "id": "portable-studio-edits", + "regex": "\\.hyperframes/(?:studio-manual-edits|studio-motion)\\.json", + "client_action": "include", + "server_action": "allow", + "basis": "Studio edits read at render and preview time; without them a pulled project renders differently" + }, + { + "id": "portable-caption-skin", + "regex": "\\.hyperframes/caption-skin\\.html", + "client_action": "include", + "server_action": "allow", + "basis": "Authored input to the caption build; rebuilding captions needs it" + }, + { + "id": "portable-podcast-media", + "regex": "\\.hyperframes/prepared-assets/podcast/(?:[^/]+/)*[^./][^/]*", + "client_action": "include", + "server_action": "allow", + "basis": "Desktop's podcast camera and recorder transcodes (media/, proxies/), which the page plays by this path and a receiving client cannot regenerate without the original files; a dotfile there stays out" + }, + { + "id": "sync-and-share-bindings", + "regex": "\\.hyperframes/(?:share\\.json|review\\.json|review-export\\.json|review-[^/]+\\.json|project\\.json|lambda-stack-[^/]+\\.json|(?:sync|receipts)/.*)", + "client_action": "exclude", + "server_action": "reject", + "basis": "External bindings and sync receipts: share and review links (review files carry the owner's email), the CLI publish id and deploy stacks. A copy must start unbound, so these never travel" + }, + { + "id": "known-hyperframes-state", + "regex": "\\.hyperframes/(?:comments\\.jsonl|agent-runs\\.jsonl|app-history\\.jsonl|chat-starts\\.json|agent-handoff\\.json|agent-handoff-read\\.json|history-id|video-state\\.json|film-snapshot\\.json|moved-from\\.jsonl|hf-ids-stamped\\.json|settled-signature|render-outputs\\.json|render-outputs-lock|project\\.lock|history-turn\\.json|history-turns\\.json|voices\\.json|asset-creation\\.json|lesson\\.json|element-map\\.txt|\\.gitignore|(?:live-runs|run-traces|agent-sessions|agent-steps|video-state-lock|backup|preview|history|undo|artifacts|heygen-recipes|heygen-reperform|fixes|heygen-jobs|heygen-paid|podcast|prepared-assets|requests|recordings|frames|refs|references|review|heygen-previews|frame-packets|anim-map|contrast|bin|diagnostics)(?:/.*)?)", + "client_action": "exclude", + "server_action": "reject", + "basis": "Known client state: comments, chat and run logs; machine pointers, locks and caches; personal data (photo and voice copies) and account-bound job state, podcast job state included; studio preview caches under prepared-assets/ other than the podcast media above" + }, + { + "id": "unknown-hyperframes-state", + "regex": "\\.hyperframes(?:/.*)?", + "client_action": "exclude", + "server_action": "reject", + "basis": "Reserved client state area: only the named portable files above travel" + }, + { + "id": "root-generated-output", + "regex": "(?:\\.thumbnails|\\.transcode-cache|\\.waveform-cache|renders|snapshots)(?:/.*)?", + "client_action": "exclude", + "server_action": "reject", + "basis": "Caches and render or snapshot output at the project root" + }, + { + "id": "root-build-output", + "regex": "(?:dist|coverage)(?:/.*)?", + "client_action": "exclude", + "server_action": "reject", + "basis": "Web build and test-coverage output at the project root, which the CLI publish leaves out and render never reads (build/ and outputs/ travel, because the publish ships them)" + }, + { + "id": "authoring-scratch", + "regex": "(?:remotion-src|moments|references/moments)(?:/.*)?", + "client_action": "exclude", + "server_action": "reject", + "basis": "Authoring scratch at the project root: a Remotion port's source and the moment working copies with their references, none of which preview or render reads" + }, + { + "id": "reference-video", + "regex": "\\.viral-clone(?:/.*)?", + "client_action": "exclude", + "server_action": "reject", + "basis": "Third-party reference video, large and re-downloadable" + }, + { + "id": "default-authored-file", + "regex": ".+", + "client_action": "include", + "server_action": "allow", + "basis": "Authored source and config (index.html, compositions/, scenes/, assets/, hyperframes.json, meta.json, project.json, package.json, lockfiles, .hyperframesignore, .gitignore), portable briefs, AGENTS.md and CLAUDE.md, completed .media assets with unused alternatives, .media/index.md, .media/preferences.json and .media/CREDITS.md, build/ and outputs/, and any unknown regular file outside a reserved area" + } + ], + "client_notes": { + "project_json": "Root project.json is portable project content and is included. It is not sync identity: the owner workspace, composition, base snapshot, revision and receipts live outside the inventory, never in project.json.", + "capture_preconditions": "Do not capture while .hyperframes/history-turn.json exists (an agent turn is open) or while .hyperframes/project.lock is held.", + "render_outputs": "Leave out every path listed in .hyperframes/render-outputs.json: render outputs written outside renders/ are recorded there, and the server cannot know them.", + "complete_capture": "A file the client cannot read fails the capture; it never becomes a deletion. The exclusions above and the symlinks client_symlinks skips are the only files left out.", + "symlinks": "Symlinks and special files fail the capture, listing them; they are neither followed nor skipped, except the symlinks client_symlinks skips.", + "empty_directories": "Empty directories are not represented. Pull never deletes a local empty directory." + }, + "client_prefilter": { + "names": ["Icon\r"], + "rule": "skip a file whose last segment is one of these before running any path check; macOS writes 'Icon\\r' for a folder with a custom icon, and the carriage return would otherwise fail the whole capture with path_invalid_character" + }, + "client_symlinks": { + "default": "fail_capture", + "skip_prefixes": ["assets/podcast/"], + "match": "a symlink whose folded path (each segment replaced by its comparison key, as for rules) starts with a listed prefix, at any depth below it", + "rule": "skip such a symlink instead of failing the capture, and on Pull leave such a local symlink in place as local state; a regular file under the prefix is captured like any other, and every other symlink or special file fails the capture", + "basis": "Desktop's podcast intake links the original camera files, which live outside the project, under assets/podcast/, and the page plays the transcodes under .hyperframes/prepared-assets/podcast/; real files there, such as the joins under assets/podcast/joins/, travel normally" + }, + "stored_manifest": { + "legacy_agent_state_regex": "(?:[^/]+/)*(?:\\.claude|\\.agents|\\.cursor|\\.vscode|\\.idea)(?:/.*)?", + "rule": "Only stored snapshot reads use the v3 agent-state rule to retain immutable manifest digests. New captures and uploads use the current rules. Clients never install excluded paths; the server never signs their download URLs." + } +} diff --git a/packages/share/src/sources/contract/unicode-15.1.0.json b/packages/share/src/sources/contract/unicode-15.1.0.json new file mode 100644 index 0000000000..988dc650e7 --- /dev/null +++ b/packages/share/src/sources/contract/unicode-15.1.0.json @@ -0,0 +1,6179 @@ +{ + "assigned_ranges": [ + [0, 887], + [890, 895], + [900, 906], + [908, 908], + [910, 929], + [931, 1327], + [1329, 1366], + [1369, 1418], + [1421, 1423], + [1425, 1479], + [1488, 1514], + [1519, 1524], + [1536, 1805], + [1807, 1866], + [1869, 1969], + [1984, 2042], + [2045, 2093], + [2096, 2110], + [2112, 2139], + [2142, 2142], + [2144, 2154], + [2160, 2190], + [2192, 2193], + [2200, 2435], + [2437, 2444], + [2447, 2448], + [2451, 2472], + [2474, 2480], + [2482, 2482], + [2486, 2489], + [2492, 2500], + [2503, 2504], + [2507, 2510], + [2519, 2519], + [2524, 2525], + [2527, 2531], + [2534, 2558], + [2561, 2563], + [2565, 2570], + [2575, 2576], + [2579, 2600], + [2602, 2608], + [2610, 2611], + [2613, 2614], + [2616, 2617], + [2620, 2620], + [2622, 2626], + [2631, 2632], + [2635, 2637], + [2641, 2641], + [2649, 2652], + [2654, 2654], + [2662, 2678], + [2689, 2691], + [2693, 2701], + [2703, 2705], + [2707, 2728], + [2730, 2736], + [2738, 2739], + [2741, 2745], + [2748, 2757], + [2759, 2761], + [2763, 2765], + [2768, 2768], + [2784, 2787], + [2790, 2801], + [2809, 2815], + [2817, 2819], + [2821, 2828], + [2831, 2832], + [2835, 2856], + [2858, 2864], + [2866, 2867], + [2869, 2873], + [2876, 2884], + [2887, 2888], + [2891, 2893], + [2901, 2903], + [2908, 2909], + [2911, 2915], + [2918, 2935], + [2946, 2947], + [2949, 2954], + [2958, 2960], + [2962, 2965], + [2969, 2970], + [2972, 2972], + [2974, 2975], + [2979, 2980], + [2984, 2986], + [2990, 3001], + [3006, 3010], + [3014, 3016], + [3018, 3021], + [3024, 3024], + [3031, 3031], + [3046, 3066], + [3072, 3084], + [3086, 3088], + [3090, 3112], + [3114, 3129], + [3132, 3140], + [3142, 3144], + [3146, 3149], + [3157, 3158], + [3160, 3162], + [3165, 3165], + [3168, 3171], + [3174, 3183], + [3191, 3212], + [3214, 3216], + [3218, 3240], + [3242, 3251], + [3253, 3257], + [3260, 3268], + [3270, 3272], + [3274, 3277], + [3285, 3286], + [3293, 3294], + [3296, 3299], + [3302, 3311], + [3313, 3315], + [3328, 3340], + [3342, 3344], + [3346, 3396], + [3398, 3400], + [3402, 3407], + [3412, 3427], + [3430, 3455], + [3457, 3459], + [3461, 3478], + [3482, 3505], + [3507, 3515], + [3517, 3517], + [3520, 3526], + [3530, 3530], + [3535, 3540], + [3542, 3542], + [3544, 3551], + [3558, 3567], + [3570, 3572], + [3585, 3642], + [3647, 3675], + [3713, 3714], + [3716, 3716], + [3718, 3722], + [3724, 3747], + [3749, 3749], + [3751, 3773], + [3776, 3780], + [3782, 3782], + [3784, 3790], + [3792, 3801], + [3804, 3807], + [3840, 3911], + [3913, 3948], + [3953, 3991], + [3993, 4028], + [4030, 4044], + [4046, 4058], + [4096, 4293], + [4295, 4295], + [4301, 4301], + [4304, 4680], + [4682, 4685], + [4688, 4694], + [4696, 4696], + [4698, 4701], + [4704, 4744], + [4746, 4749], + [4752, 4784], + [4786, 4789], + [4792, 4798], + [4800, 4800], + [4802, 4805], + [4808, 4822], + [4824, 4880], + [4882, 4885], + [4888, 4954], + [4957, 4988], + [4992, 5017], + [5024, 5109], + [5112, 5117], + [5120, 5788], + [5792, 5880], + [5888, 5909], + [5919, 5942], + [5952, 5971], + [5984, 5996], + [5998, 6000], + [6002, 6003], + [6016, 6109], + [6112, 6121], + [6128, 6137], + [6144, 6169], + [6176, 6264], + [6272, 6314], + [6320, 6389], + [6400, 6430], + [6432, 6443], + [6448, 6459], + [6464, 6464], + [6468, 6509], + [6512, 6516], + [6528, 6571], + [6576, 6601], + [6608, 6618], + [6622, 6683], + [6686, 6750], + [6752, 6780], + [6783, 6793], + [6800, 6809], + [6816, 6829], + [6832, 6862], + [6912, 6988], + [6992, 7038], + [7040, 7155], + [7164, 7223], + [7227, 7241], + [7245, 7304], + [7312, 7354], + [7357, 7367], + [7376, 7418], + [7424, 7957], + [7960, 7965], + [7968, 8005], + [8008, 8013], + [8016, 8023], + [8025, 8025], + [8027, 8027], + [8029, 8029], + [8031, 8061], + [8064, 8116], + [8118, 8132], + [8134, 8147], + [8150, 8155], + [8157, 8175], + [8178, 8180], + [8182, 8190], + [8192, 8292], + [8294, 8305], + [8308, 8334], + [8336, 8348], + [8352, 8384], + [8400, 8432], + [8448, 8587], + [8592, 9254], + [9280, 9290], + [9312, 11123], + [11126, 11157], + [11159, 11507], + [11513, 11557], + [11559, 11559], + [11565, 11565], + [11568, 11623], + [11631, 11632], + [11647, 11670], + [11680, 11686], + [11688, 11694], + [11696, 11702], + [11704, 11710], + [11712, 11718], + [11720, 11726], + [11728, 11734], + [11736, 11742], + [11744, 11869], + [11904, 11929], + [11931, 12019], + [12032, 12245], + [12272, 12351], + [12353, 12438], + [12441, 12543], + [12549, 12591], + [12593, 12686], + [12688, 12771], + [12783, 12830], + [12832, 42124], + [42128, 42182], + [42192, 42539], + [42560, 42743], + [42752, 42954], + [42960, 42961], + [42963, 42963], + [42965, 42969], + [42994, 43052], + [43056, 43065], + [43072, 43127], + [43136, 43205], + [43214, 43225], + [43232, 43347], + [43359, 43388], + [43392, 43469], + [43471, 43481], + [43486, 43518], + [43520, 43574], + [43584, 43597], + [43600, 43609], + [43612, 43714], + [43739, 43766], + [43777, 43782], + [43785, 43790], + [43793, 43798], + [43808, 43814], + [43816, 43822], + [43824, 43883], + [43888, 44013], + [44016, 44025], + [44032, 55203], + [55216, 55238], + [55243, 55291], + [55296, 64109], + [64112, 64217], + [64256, 64262], + [64275, 64279], + [64285, 64310], + [64312, 64316], + [64318, 64318], + [64320, 64321], + [64323, 64324], + [64326, 64450], + [64467, 64911], + [64914, 64967], + [64975, 64975], + [65008, 65049], + [65056, 65106], + [65108, 65126], + [65128, 65131], + [65136, 65140], + [65142, 65276], + [65279, 65279], + [65281, 65470], + [65474, 65479], + [65482, 65487], + [65490, 65495], + [65498, 65500], + [65504, 65510], + [65512, 65518], + [65529, 65533], + [65536, 65547], + [65549, 65574], + [65576, 65594], + [65596, 65597], + [65599, 65613], + [65616, 65629], + [65664, 65786], + [65792, 65794], + [65799, 65843], + [65847, 65934], + [65936, 65948], + [65952, 65952], + [66000, 66045], + [66176, 66204], + [66208, 66256], + [66272, 66299], + [66304, 66339], + [66349, 66378], + [66384, 66426], + [66432, 66461], + [66463, 66499], + [66504, 66517], + [66560, 66717], + [66720, 66729], + [66736, 66771], + [66776, 66811], + [66816, 66855], + [66864, 66915], + [66927, 66938], + [66940, 66954], + [66956, 66962], + [66964, 66965], + [66967, 66977], + [66979, 66993], + [66995, 67001], + [67003, 67004], + [67072, 67382], + [67392, 67413], + [67424, 67431], + [67456, 67461], + [67463, 67504], + [67506, 67514], + [67584, 67589], + [67592, 67592], + [67594, 67637], + [67639, 67640], + [67644, 67644], + [67647, 67669], + [67671, 67742], + [67751, 67759], + [67808, 67826], + [67828, 67829], + [67835, 67867], + [67871, 67897], + [67903, 67903], + [67968, 68023], + [68028, 68047], + [68050, 68099], + [68101, 68102], + [68108, 68115], + [68117, 68119], + [68121, 68149], + [68152, 68154], + [68159, 68168], + [68176, 68184], + [68192, 68255], + [68288, 68326], + [68331, 68342], + [68352, 68405], + [68409, 68437], + [68440, 68466], + [68472, 68497], + [68505, 68508], + [68521, 68527], + [68608, 68680], + [68736, 68786], + [68800, 68850], + [68858, 68903], + [68912, 68921], + [69216, 69246], + [69248, 69289], + [69291, 69293], + [69296, 69297], + [69373, 69415], + [69424, 69465], + [69488, 69513], + [69552, 69579], + [69600, 69622], + [69632, 69709], + [69714, 69749], + [69759, 69826], + [69837, 69837], + [69840, 69864], + [69872, 69881], + [69888, 69940], + [69942, 69959], + [69968, 70006], + [70016, 70111], + [70113, 70132], + [70144, 70161], + [70163, 70209], + [70272, 70278], + [70280, 70280], + [70282, 70285], + [70287, 70301], + [70303, 70313], + [70320, 70378], + [70384, 70393], + [70400, 70403], + [70405, 70412], + [70415, 70416], + [70419, 70440], + [70442, 70448], + [70450, 70451], + [70453, 70457], + [70459, 70468], + [70471, 70472], + [70475, 70477], + [70480, 70480], + [70487, 70487], + [70493, 70499], + [70502, 70508], + [70512, 70516], + [70656, 70747], + [70749, 70753], + [70784, 70855], + [70864, 70873], + [71040, 71093], + [71096, 71133], + [71168, 71236], + [71248, 71257], + [71264, 71276], + [71296, 71353], + [71360, 71369], + [71424, 71450], + [71453, 71467], + [71472, 71494], + [71680, 71739], + [71840, 71922], + [71935, 71942], + [71945, 71945], + [71948, 71955], + [71957, 71958], + [71960, 71989], + [71991, 71992], + [71995, 72006], + [72016, 72025], + [72096, 72103], + [72106, 72151], + [72154, 72164], + [72192, 72263], + [72272, 72354], + [72368, 72440], + [72448, 72457], + [72704, 72712], + [72714, 72758], + [72760, 72773], + [72784, 72812], + [72816, 72847], + [72850, 72871], + [72873, 72886], + [72960, 72966], + [72968, 72969], + [72971, 73014], + [73018, 73018], + [73020, 73021], + [73023, 73031], + [73040, 73049], + [73056, 73061], + [73063, 73064], + [73066, 73102], + [73104, 73105], + [73107, 73112], + [73120, 73129], + [73440, 73464], + [73472, 73488], + [73490, 73530], + [73534, 73561], + [73648, 73648], + [73664, 73713], + [73727, 74649], + [74752, 74862], + [74864, 74868], + [74880, 75075], + [77712, 77810], + [77824, 78933], + [82944, 83526], + [92160, 92728], + [92736, 92766], + [92768, 92777], + [92782, 92862], + [92864, 92873], + [92880, 92909], + [92912, 92917], + [92928, 92997], + [93008, 93017], + [93019, 93025], + [93027, 93047], + [93053, 93071], + [93760, 93850], + [93952, 94026], + [94031, 94087], + [94095, 94111], + [94176, 94180], + [94192, 94193], + [94208, 100343], + [100352, 101589], + [101632, 101640], + [110576, 110579], + [110581, 110587], + [110589, 110590], + [110592, 110882], + [110898, 110898], + [110928, 110930], + [110933, 110933], + [110948, 110951], + [110960, 111355], + [113664, 113770], + [113776, 113788], + [113792, 113800], + [113808, 113817], + [113820, 113827], + [118528, 118573], + [118576, 118598], + [118608, 118723], + [118784, 119029], + [119040, 119078], + [119081, 119274], + [119296, 119365], + [119488, 119507], + [119520, 119539], + [119552, 119638], + [119648, 119672], + [119808, 119892], + [119894, 119964], + [119966, 119967], + [119970, 119970], + [119973, 119974], + [119977, 119980], + [119982, 119993], + [119995, 119995], + [119997, 120003], + [120005, 120069], + [120071, 120074], + [120077, 120084], + [120086, 120092], + [120094, 120121], + [120123, 120126], + [120128, 120132], + [120134, 120134], + [120138, 120144], + [120146, 120485], + [120488, 120779], + [120782, 121483], + [121499, 121503], + [121505, 121519], + [122624, 122654], + [122661, 122666], + [122880, 122886], + [122888, 122904], + [122907, 122913], + [122915, 122916], + [122918, 122922], + [122928, 122989], + [123023, 123023], + [123136, 123180], + [123184, 123197], + [123200, 123209], + [123214, 123215], + [123536, 123566], + [123584, 123641], + [123647, 123647], + [124112, 124153], + [124896, 124902], + [124904, 124907], + [124909, 124910], + [124912, 124926], + [124928, 125124], + [125127, 125142], + [125184, 125259], + [125264, 125273], + [125278, 125279], + [126065, 126132], + [126209, 126269], + [126464, 126467], + [126469, 126495], + [126497, 126498], + [126500, 126500], + [126503, 126503], + [126505, 126514], + [126516, 126519], + [126521, 126521], + [126523, 126523], + [126530, 126530], + [126535, 126535], + [126537, 126537], + [126539, 126539], + [126541, 126543], + [126545, 126546], + [126548, 126548], + [126551, 126551], + [126553, 126553], + [126555, 126555], + [126557, 126557], + [126559, 126559], + [126561, 126562], + [126564, 126564], + [126567, 126570], + [126572, 126578], + [126580, 126583], + [126585, 126588], + [126590, 126590], + [126592, 126601], + [126603, 126619], + [126625, 126627], + [126629, 126633], + [126635, 126651], + [126704, 126705], + [126976, 127019], + [127024, 127123], + [127136, 127150], + [127153, 127167], + [127169, 127183], + [127185, 127221], + [127232, 127405], + [127462, 127490], + [127504, 127547], + [127552, 127560], + [127568, 127569], + [127584, 127589], + [127744, 128727], + [128732, 128748], + [128752, 128764], + [128768, 128886], + [128891, 128985], + [128992, 129003], + [129008, 129008], + [129024, 129035], + [129040, 129095], + [129104, 129113], + [129120, 129159], + [129168, 129197], + [129200, 129201], + [129280, 129619], + [129632, 129645], + [129648, 129660], + [129664, 129672], + [129680, 129725], + [129727, 129733], + [129742, 129755], + [129760, 129768], + [129776, 129784], + [129792, 129938], + [129940, 129994], + [130032, 130041], + [131072, 173791], + [173824, 177977], + [177984, 178205], + [178208, 183969], + [183984, 191456], + [191472, 192093], + [194560, 195101], + [196608, 201546], + [201552, 205743], + [917505, 917505], + [917536, 917631], + [917760, 917999], + [983040, 1048573], + [1048576, 1114109] + ], + "casefold": { + "0041": "a", + "0042": "b", + "0043": "c", + "0044": "d", + "0045": "e", + "0046": "f", + "0047": "g", + "0048": "h", + "0049": "i", + "004A": "j", + "004B": "k", + "004C": "l", + "004D": "m", + "004E": "n", + "004F": "o", + "0050": "p", + "0051": "q", + "0052": "r", + "0053": "s", + "0054": "t", + "0055": "u", + "0056": "v", + "0057": "w", + "0058": "x", + "0059": "y", + "005A": "z", + "00B5": "\u03bc", + "00C0": "\u00e0", + "00C1": "\u00e1", + "00C2": "\u00e2", + "00C3": "\u00e3", + "00C4": "\u00e4", + "00C5": "\u00e5", + "00C6": "\u00e6", + "00C7": "\u00e7", + "00C8": "\u00e8", + "00C9": "\u00e9", + "00CA": "\u00ea", + "00CB": "\u00eb", + "00CC": "\u00ec", + "00CD": "\u00ed", + "00CE": "\u00ee", + "00CF": "\u00ef", + "00D0": "\u00f0", + "00D1": "\u00f1", + "00D2": "\u00f2", + "00D3": "\u00f3", + "00D4": "\u00f4", + "00D5": "\u00f5", + "00D6": "\u00f6", + "00D8": "\u00f8", + "00D9": "\u00f9", + "00DA": "\u00fa", + "00DB": "\u00fb", + "00DC": "\u00fc", + "00DD": "\u00fd", + "00DE": "\u00fe", + "00DF": "ss", + "0100": "\u0101", + "0102": "\u0103", + "0104": "\u0105", + "0106": "\u0107", + "0108": "\u0109", + "010A": "\u010b", + "010C": "\u010d", + "010E": "\u010f", + "0110": "\u0111", + "0112": "\u0113", + "0114": "\u0115", + "0116": "\u0117", + "0118": "\u0119", + "011A": "\u011b", + "011C": "\u011d", + "011E": "\u011f", + "0120": "\u0121", + "0122": "\u0123", + "0124": "\u0125", + "0126": "\u0127", + "0128": "\u0129", + "012A": "\u012b", + "012C": "\u012d", + "012E": "\u012f", + "0130": "i\u0307", + "0132": "\u0133", + "0134": "\u0135", + "0136": "\u0137", + "0139": "\u013a", + "013B": "\u013c", + "013D": "\u013e", + "013F": "\u0140", + "0141": "\u0142", + "0143": "\u0144", + "0145": "\u0146", + "0147": "\u0148", + "0149": "\u02bcn", + "014A": "\u014b", + "014C": "\u014d", + "014E": "\u014f", + "0150": "\u0151", + "0152": "\u0153", + "0154": "\u0155", + "0156": "\u0157", + "0158": "\u0159", + "015A": "\u015b", + "015C": "\u015d", + "015E": "\u015f", + "0160": "\u0161", + "0162": "\u0163", + "0164": "\u0165", + "0166": "\u0167", + "0168": "\u0169", + "016A": "\u016b", + "016C": "\u016d", + "016E": "\u016f", + "0170": "\u0171", + "0172": "\u0173", + "0174": "\u0175", + "0176": "\u0177", + "0178": "\u00ff", + "0179": "\u017a", + "017B": "\u017c", + "017D": "\u017e", + "017F": "s", + "0181": "\u0253", + "0182": "\u0183", + "0184": "\u0185", + "0186": "\u0254", + "0187": "\u0188", + "0189": "\u0256", + "018A": "\u0257", + "018B": "\u018c", + "018E": "\u01dd", + "018F": "\u0259", + "0190": "\u025b", + "0191": "\u0192", + "0193": "\u0260", + "0194": "\u0263", + "0196": "\u0269", + "0197": "\u0268", + "0198": "\u0199", + "019C": "\u026f", + "019D": "\u0272", + "019F": "\u0275", + "01A0": "\u01a1", + "01A2": "\u01a3", + "01A4": "\u01a5", + "01A6": "\u0280", + "01A7": "\u01a8", + "01A9": "\u0283", + "01AC": "\u01ad", + "01AE": "\u0288", + "01AF": "\u01b0", + "01B1": "\u028a", + "01B2": "\u028b", + "01B3": "\u01b4", + "01B5": "\u01b6", + "01B7": "\u0292", + "01B8": "\u01b9", + "01BC": "\u01bd", + "01C4": "\u01c6", + "01C5": "\u01c6", + "01C7": "\u01c9", + "01C8": "\u01c9", + "01CA": "\u01cc", + "01CB": "\u01cc", + "01CD": "\u01ce", + "01CF": "\u01d0", + "01D1": "\u01d2", + "01D3": "\u01d4", + "01D5": "\u01d6", + "01D7": "\u01d8", + "01D9": "\u01da", + "01DB": "\u01dc", + "01DE": "\u01df", + "01E0": "\u01e1", + "01E2": "\u01e3", + "01E4": "\u01e5", + "01E6": "\u01e7", + "01E8": "\u01e9", + "01EA": "\u01eb", + "01EC": "\u01ed", + "01EE": "\u01ef", + "01F0": "j\u030c", + "01F1": "\u01f3", + "01F2": "\u01f3", + "01F4": "\u01f5", + "01F6": "\u0195", + "01F7": "\u01bf", + "01F8": "\u01f9", + "01FA": "\u01fb", + "01FC": "\u01fd", + "01FE": "\u01ff", + "0200": "\u0201", + "0202": "\u0203", + "0204": "\u0205", + "0206": "\u0207", + "0208": "\u0209", + "020A": "\u020b", + "020C": "\u020d", + "020E": "\u020f", + "0210": "\u0211", + "0212": "\u0213", + "0214": "\u0215", + "0216": "\u0217", + "0218": "\u0219", + "021A": "\u021b", + "021C": "\u021d", + "021E": "\u021f", + "0220": "\u019e", + "0222": "\u0223", + "0224": "\u0225", + "0226": "\u0227", + "0228": "\u0229", + "022A": "\u022b", + "022C": "\u022d", + "022E": "\u022f", + "0230": "\u0231", + "0232": "\u0233", + "023A": "\u2c65", + "023B": "\u023c", + "023D": "\u019a", + "023E": "\u2c66", + "0241": "\u0242", + "0243": "\u0180", + "0244": "\u0289", + "0245": "\u028c", + "0246": "\u0247", + "0248": "\u0249", + "024A": "\u024b", + "024C": "\u024d", + "024E": "\u024f", + "0345": "\u03b9", + "0370": "\u0371", + "0372": "\u0373", + "0376": "\u0377", + "037F": "\u03f3", + "0386": "\u03ac", + "0388": "\u03ad", + "0389": "\u03ae", + "038A": "\u03af", + "038C": "\u03cc", + "038E": "\u03cd", + "038F": "\u03ce", + "0390": "\u03b9\u0308\u0301", + "0391": "\u03b1", + "0392": "\u03b2", + "0393": "\u03b3", + "0394": "\u03b4", + "0395": "\u03b5", + "0396": "\u03b6", + "0397": "\u03b7", + "0398": "\u03b8", + "0399": "\u03b9", + "039A": "\u03ba", + "039B": "\u03bb", + "039C": "\u03bc", + "039D": "\u03bd", + "039E": "\u03be", + "039F": "\u03bf", + "03A0": "\u03c0", + "03A1": "\u03c1", + "03A3": "\u03c3", + "03A4": "\u03c4", + "03A5": "\u03c5", + "03A6": "\u03c6", + "03A7": "\u03c7", + "03A8": "\u03c8", + "03A9": "\u03c9", + "03AA": "\u03ca", + "03AB": "\u03cb", + "03B0": "\u03c5\u0308\u0301", + "03C2": "\u03c3", + "03CF": "\u03d7", + "03D0": "\u03b2", + "03D1": "\u03b8", + "03D5": "\u03c6", + "03D6": "\u03c0", + "03D8": "\u03d9", + "03DA": "\u03db", + "03DC": "\u03dd", + "03DE": "\u03df", + "03E0": "\u03e1", + "03E2": "\u03e3", + "03E4": "\u03e5", + "03E6": "\u03e7", + "03E8": "\u03e9", + "03EA": "\u03eb", + "03EC": "\u03ed", + "03EE": "\u03ef", + "03F0": "\u03ba", + "03F1": "\u03c1", + "03F4": "\u03b8", + "03F5": "\u03b5", + "03F7": "\u03f8", + "03F9": "\u03f2", + "03FA": "\u03fb", + "03FD": "\u037b", + "03FE": "\u037c", + "03FF": "\u037d", + "0400": "\u0450", + "0401": "\u0451", + "0402": "\u0452", + "0403": "\u0453", + "0404": "\u0454", + "0405": "\u0455", + "0406": "\u0456", + "0407": "\u0457", + "0408": "\u0458", + "0409": "\u0459", + "040A": "\u045a", + "040B": "\u045b", + "040C": "\u045c", + "040D": "\u045d", + "040E": "\u045e", + "040F": "\u045f", + "0410": "\u0430", + "0411": "\u0431", + "0412": "\u0432", + "0413": "\u0433", + "0414": "\u0434", + "0415": "\u0435", + "0416": "\u0436", + "0417": "\u0437", + "0418": "\u0438", + "0419": "\u0439", + "041A": "\u043a", + "041B": "\u043b", + "041C": "\u043c", + "041D": "\u043d", + "041E": "\u043e", + "041F": "\u043f", + "0420": "\u0440", + "0421": "\u0441", + "0422": "\u0442", + "0423": "\u0443", + "0424": "\u0444", + "0425": "\u0445", + "0426": "\u0446", + "0427": "\u0447", + "0428": "\u0448", + "0429": "\u0449", + "042A": "\u044a", + "042B": "\u044b", + "042C": "\u044c", + "042D": "\u044d", + "042E": "\u044e", + "042F": "\u044f", + "0460": "\u0461", + "0462": "\u0463", + "0464": "\u0465", + "0466": "\u0467", + "0468": "\u0469", + "046A": "\u046b", + "046C": "\u046d", + "046E": "\u046f", + "0470": "\u0471", + "0472": "\u0473", + "0474": "\u0475", + "0476": "\u0477", + "0478": "\u0479", + "047A": "\u047b", + "047C": "\u047d", + "047E": "\u047f", + "0480": "\u0481", + "048A": "\u048b", + "048C": "\u048d", + "048E": "\u048f", + "0490": "\u0491", + "0492": "\u0493", + "0494": "\u0495", + "0496": "\u0497", + "0498": "\u0499", + "049A": "\u049b", + "049C": "\u049d", + "049E": "\u049f", + "04A0": "\u04a1", + "04A2": "\u04a3", + "04A4": "\u04a5", + "04A6": "\u04a7", + "04A8": "\u04a9", + "04AA": "\u04ab", + "04AC": "\u04ad", + "04AE": "\u04af", + "04B0": "\u04b1", + "04B2": "\u04b3", + "04B4": "\u04b5", + "04B6": "\u04b7", + "04B8": "\u04b9", + "04BA": "\u04bb", + "04BC": "\u04bd", + "04BE": "\u04bf", + "04C0": "\u04cf", + "04C1": "\u04c2", + "04C3": "\u04c4", + "04C5": "\u04c6", + "04C7": "\u04c8", + "04C9": "\u04ca", + "04CB": "\u04cc", + "04CD": "\u04ce", + "04D0": "\u04d1", + "04D2": "\u04d3", + "04D4": "\u04d5", + "04D6": "\u04d7", + "04D8": "\u04d9", + "04DA": "\u04db", + "04DC": "\u04dd", + "04DE": "\u04df", + "04E0": "\u04e1", + "04E2": "\u04e3", + "04E4": "\u04e5", + "04E6": "\u04e7", + "04E8": "\u04e9", + "04EA": "\u04eb", + "04EC": "\u04ed", + "04EE": "\u04ef", + "04F0": "\u04f1", + "04F2": "\u04f3", + "04F4": "\u04f5", + "04F6": "\u04f7", + "04F8": "\u04f9", + "04FA": "\u04fb", + "04FC": "\u04fd", + "04FE": "\u04ff", + "0500": "\u0501", + "0502": "\u0503", + "0504": "\u0505", + "0506": "\u0507", + "0508": "\u0509", + "050A": "\u050b", + "050C": "\u050d", + "050E": "\u050f", + "0510": "\u0511", + "0512": "\u0513", + "0514": "\u0515", + "0516": "\u0517", + "0518": "\u0519", + "051A": "\u051b", + "051C": "\u051d", + "051E": "\u051f", + "0520": "\u0521", + "0522": "\u0523", + "0524": "\u0525", + "0526": "\u0527", + "0528": "\u0529", + "052A": "\u052b", + "052C": "\u052d", + "052E": "\u052f", + "0531": "\u0561", + "0532": "\u0562", + "0533": "\u0563", + "0534": "\u0564", + "0535": "\u0565", + "0536": "\u0566", + "0537": "\u0567", + "0538": "\u0568", + "0539": "\u0569", + "053A": "\u056a", + "053B": "\u056b", + "053C": "\u056c", + "053D": "\u056d", + "053E": "\u056e", + "053F": "\u056f", + "0540": "\u0570", + "0541": "\u0571", + "0542": "\u0572", + "0543": "\u0573", + "0544": "\u0574", + "0545": "\u0575", + "0546": "\u0576", + "0547": "\u0577", + "0548": "\u0578", + "0549": "\u0579", + "054A": "\u057a", + "054B": "\u057b", + "054C": "\u057c", + "054D": "\u057d", + "054E": "\u057e", + "054F": "\u057f", + "0550": "\u0580", + "0551": "\u0581", + "0552": "\u0582", + "0553": "\u0583", + "0554": "\u0584", + "0555": "\u0585", + "0556": "\u0586", + "0587": "\u0565\u0582", + "10400": "\ud801\udc28", + "10401": "\ud801\udc29", + "10402": "\ud801\udc2a", + "10403": "\ud801\udc2b", + "10404": "\ud801\udc2c", + "10405": "\ud801\udc2d", + "10406": "\ud801\udc2e", + "10407": "\ud801\udc2f", + "10408": "\ud801\udc30", + "10409": "\ud801\udc31", + "1040A": "\ud801\udc32", + "1040B": "\ud801\udc33", + "1040C": "\ud801\udc34", + "1040D": "\ud801\udc35", + "1040E": "\ud801\udc36", + "1040F": "\ud801\udc37", + "10410": "\ud801\udc38", + "10411": "\ud801\udc39", + "10412": "\ud801\udc3a", + "10413": "\ud801\udc3b", + "10414": "\ud801\udc3c", + "10415": "\ud801\udc3d", + "10416": "\ud801\udc3e", + "10417": "\ud801\udc3f", + "10418": "\ud801\udc40", + "10419": "\ud801\udc41", + "1041A": "\ud801\udc42", + "1041B": "\ud801\udc43", + "1041C": "\ud801\udc44", + "1041D": "\ud801\udc45", + "1041E": "\ud801\udc46", + "1041F": "\ud801\udc47", + "10420": "\ud801\udc48", + "10421": "\ud801\udc49", + "10422": "\ud801\udc4a", + "10423": "\ud801\udc4b", + "10424": "\ud801\udc4c", + "10425": "\ud801\udc4d", + "10426": "\ud801\udc4e", + "10427": "\ud801\udc4f", + "104B0": "\ud801\udcd8", + "104B1": "\ud801\udcd9", + "104B2": "\ud801\udcda", + "104B3": "\ud801\udcdb", + "104B4": "\ud801\udcdc", + "104B5": "\ud801\udcdd", + "104B6": "\ud801\udcde", + "104B7": "\ud801\udcdf", + "104B8": "\ud801\udce0", + "104B9": "\ud801\udce1", + "104BA": "\ud801\udce2", + "104BB": "\ud801\udce3", + "104BC": "\ud801\udce4", + "104BD": "\ud801\udce5", + "104BE": "\ud801\udce6", + "104BF": "\ud801\udce7", + "104C0": "\ud801\udce8", + "104C1": "\ud801\udce9", + "104C2": "\ud801\udcea", + "104C3": "\ud801\udceb", + "104C4": "\ud801\udcec", + "104C5": "\ud801\udced", + "104C6": "\ud801\udcee", + "104C7": "\ud801\udcef", + "104C8": "\ud801\udcf0", + "104C9": "\ud801\udcf1", + "104CA": "\ud801\udcf2", + "104CB": "\ud801\udcf3", + "104CC": "\ud801\udcf4", + "104CD": "\ud801\udcf5", + "104CE": "\ud801\udcf6", + "104CF": "\ud801\udcf7", + "104D0": "\ud801\udcf8", + "104D1": "\ud801\udcf9", + "104D2": "\ud801\udcfa", + "104D3": "\ud801\udcfb", + "10570": "\ud801\udd97", + "10571": "\ud801\udd98", + "10572": "\ud801\udd99", + "10573": "\ud801\udd9a", + "10574": "\ud801\udd9b", + "10575": "\ud801\udd9c", + "10576": "\ud801\udd9d", + "10577": "\ud801\udd9e", + "10578": "\ud801\udd9f", + "10579": "\ud801\udda0", + "1057A": "\ud801\udda1", + "1057C": "\ud801\udda3", + "1057D": "\ud801\udda4", + "1057E": "\ud801\udda5", + "1057F": "\ud801\udda6", + "10580": "\ud801\udda7", + "10581": "\ud801\udda8", + "10582": "\ud801\udda9", + "10583": "\ud801\uddaa", + "10584": "\ud801\uddab", + "10585": "\ud801\uddac", + "10586": "\ud801\uddad", + "10587": "\ud801\uddae", + "10588": "\ud801\uddaf", + "10589": "\ud801\uddb0", + "1058A": "\ud801\uddb1", + "1058C": "\ud801\uddb3", + "1058D": "\ud801\uddb4", + "1058E": "\ud801\uddb5", + "1058F": "\ud801\uddb6", + "10590": "\ud801\uddb7", + "10591": "\ud801\uddb8", + "10592": "\ud801\uddb9", + "10594": "\ud801\uddbb", + "10595": "\ud801\uddbc", + "10A0": "\u2d00", + "10A1": "\u2d01", + "10A2": "\u2d02", + "10A3": "\u2d03", + "10A4": "\u2d04", + "10A5": "\u2d05", + "10A6": "\u2d06", + "10A7": "\u2d07", + "10A8": "\u2d08", + "10A9": "\u2d09", + "10AA": "\u2d0a", + "10AB": "\u2d0b", + "10AC": "\u2d0c", + "10AD": "\u2d0d", + "10AE": "\u2d0e", + "10AF": "\u2d0f", + "10B0": "\u2d10", + "10B1": "\u2d11", + "10B2": "\u2d12", + "10B3": "\u2d13", + "10B4": "\u2d14", + "10B5": "\u2d15", + "10B6": "\u2d16", + "10B7": "\u2d17", + "10B8": "\u2d18", + "10B9": "\u2d19", + "10BA": "\u2d1a", + "10BB": "\u2d1b", + "10BC": "\u2d1c", + "10BD": "\u2d1d", + "10BE": "\u2d1e", + "10BF": "\u2d1f", + "10C0": "\u2d20", + "10C1": "\u2d21", + "10C2": "\u2d22", + "10C3": "\u2d23", + "10C4": "\u2d24", + "10C5": "\u2d25", + "10C7": "\u2d27", + "10C80": "\ud803\udcc0", + "10C81": "\ud803\udcc1", + "10C82": "\ud803\udcc2", + "10C83": "\ud803\udcc3", + "10C84": "\ud803\udcc4", + "10C85": "\ud803\udcc5", + "10C86": "\ud803\udcc6", + "10C87": "\ud803\udcc7", + "10C88": "\ud803\udcc8", + "10C89": "\ud803\udcc9", + "10C8A": "\ud803\udcca", + "10C8B": "\ud803\udccb", + "10C8C": "\ud803\udccc", + "10C8D": "\ud803\udccd", + "10C8E": "\ud803\udcce", + "10C8F": "\ud803\udccf", + "10C90": "\ud803\udcd0", + "10C91": "\ud803\udcd1", + "10C92": "\ud803\udcd2", + "10C93": "\ud803\udcd3", + "10C94": "\ud803\udcd4", + "10C95": "\ud803\udcd5", + "10C96": "\ud803\udcd6", + "10C97": "\ud803\udcd7", + "10C98": "\ud803\udcd8", + "10C99": "\ud803\udcd9", + "10C9A": "\ud803\udcda", + "10C9B": "\ud803\udcdb", + "10C9C": "\ud803\udcdc", + "10C9D": "\ud803\udcdd", + "10C9E": "\ud803\udcde", + "10C9F": "\ud803\udcdf", + "10CA0": "\ud803\udce0", + "10CA1": "\ud803\udce1", + "10CA2": "\ud803\udce2", + "10CA3": "\ud803\udce3", + "10CA4": "\ud803\udce4", + "10CA5": "\ud803\udce5", + "10CA6": "\ud803\udce6", + "10CA7": "\ud803\udce7", + "10CA8": "\ud803\udce8", + "10CA9": "\ud803\udce9", + "10CAA": "\ud803\udcea", + "10CAB": "\ud803\udceb", + "10CAC": "\ud803\udcec", + "10CAD": "\ud803\udced", + "10CAE": "\ud803\udcee", + "10CAF": "\ud803\udcef", + "10CB0": "\ud803\udcf0", + "10CB1": "\ud803\udcf1", + "10CB2": "\ud803\udcf2", + "10CD": "\u2d2d", + "118A0": "\ud806\udcc0", + "118A1": "\ud806\udcc1", + "118A2": "\ud806\udcc2", + "118A3": "\ud806\udcc3", + "118A4": "\ud806\udcc4", + "118A5": "\ud806\udcc5", + "118A6": "\ud806\udcc6", + "118A7": "\ud806\udcc7", + "118A8": "\ud806\udcc8", + "118A9": "\ud806\udcc9", + "118AA": "\ud806\udcca", + "118AB": "\ud806\udccb", + "118AC": "\ud806\udccc", + "118AD": "\ud806\udccd", + "118AE": "\ud806\udcce", + "118AF": "\ud806\udccf", + "118B0": "\ud806\udcd0", + "118B1": "\ud806\udcd1", + "118B2": "\ud806\udcd2", + "118B3": "\ud806\udcd3", + "118B4": "\ud806\udcd4", + "118B5": "\ud806\udcd5", + "118B6": "\ud806\udcd6", + "118B7": "\ud806\udcd7", + "118B8": "\ud806\udcd8", + "118B9": "\ud806\udcd9", + "118BA": "\ud806\udcda", + "118BB": "\ud806\udcdb", + "118BC": "\ud806\udcdc", + "118BD": "\ud806\udcdd", + "118BE": "\ud806\udcde", + "118BF": "\ud806\udcdf", + "13F8": "\u13f0", + "13F9": "\u13f1", + "13FA": "\u13f2", + "13FB": "\u13f3", + "13FC": "\u13f4", + "13FD": "\u13f5", + "16E40": "\ud81b\ude60", + "16E41": "\ud81b\ude61", + "16E42": "\ud81b\ude62", + "16E43": "\ud81b\ude63", + "16E44": "\ud81b\ude64", + "16E45": "\ud81b\ude65", + "16E46": "\ud81b\ude66", + "16E47": "\ud81b\ude67", + "16E48": "\ud81b\ude68", + "16E49": "\ud81b\ude69", + "16E4A": "\ud81b\ude6a", + "16E4B": "\ud81b\ude6b", + "16E4C": "\ud81b\ude6c", + "16E4D": "\ud81b\ude6d", + "16E4E": "\ud81b\ude6e", + "16E4F": "\ud81b\ude6f", + "16E50": "\ud81b\ude70", + "16E51": "\ud81b\ude71", + "16E52": "\ud81b\ude72", + "16E53": "\ud81b\ude73", + "16E54": "\ud81b\ude74", + "16E55": "\ud81b\ude75", + "16E56": "\ud81b\ude76", + "16E57": "\ud81b\ude77", + "16E58": "\ud81b\ude78", + "16E59": "\ud81b\ude79", + "16E5A": "\ud81b\ude7a", + "16E5B": "\ud81b\ude7b", + "16E5C": "\ud81b\ude7c", + "16E5D": "\ud81b\ude7d", + "16E5E": "\ud81b\ude7e", + "16E5F": "\ud81b\ude7f", + "1C80": "\u0432", + "1C81": "\u0434", + "1C82": "\u043e", + "1C83": "\u0441", + "1C84": "\u0442", + "1C85": "\u0442", + "1C86": "\u044a", + "1C87": "\u0463", + "1C88": "\ua64b", + "1C90": "\u10d0", + "1C91": "\u10d1", + "1C92": "\u10d2", + "1C93": "\u10d3", + "1C94": "\u10d4", + "1C95": "\u10d5", + "1C96": "\u10d6", + "1C97": "\u10d7", + "1C98": "\u10d8", + "1C99": "\u10d9", + "1C9A": "\u10da", + "1C9B": "\u10db", + "1C9C": "\u10dc", + "1C9D": "\u10dd", + "1C9E": "\u10de", + "1C9F": "\u10df", + "1CA0": "\u10e0", + "1CA1": "\u10e1", + "1CA2": "\u10e2", + "1CA3": "\u10e3", + "1CA4": "\u10e4", + "1CA5": "\u10e5", + "1CA6": "\u10e6", + "1CA7": "\u10e7", + "1CA8": "\u10e8", + "1CA9": "\u10e9", + "1CAA": "\u10ea", + "1CAB": "\u10eb", + "1CAC": "\u10ec", + "1CAD": "\u10ed", + "1CAE": "\u10ee", + "1CAF": "\u10ef", + "1CB0": "\u10f0", + "1CB1": "\u10f1", + "1CB2": "\u10f2", + "1CB3": "\u10f3", + "1CB4": "\u10f4", + "1CB5": "\u10f5", + "1CB6": "\u10f6", + "1CB7": "\u10f7", + "1CB8": "\u10f8", + "1CB9": "\u10f9", + "1CBA": "\u10fa", + "1CBD": "\u10fd", + "1CBE": "\u10fe", + "1CBF": "\u10ff", + "1E00": "\u1e01", + "1E02": "\u1e03", + "1E04": "\u1e05", + "1E06": "\u1e07", + "1E08": "\u1e09", + "1E0A": "\u1e0b", + "1E0C": "\u1e0d", + "1E0E": "\u1e0f", + "1E10": "\u1e11", + "1E12": "\u1e13", + "1E14": "\u1e15", + "1E16": "\u1e17", + "1E18": "\u1e19", + "1E1A": "\u1e1b", + "1E1C": "\u1e1d", + "1E1E": "\u1e1f", + "1E20": "\u1e21", + "1E22": "\u1e23", + "1E24": "\u1e25", + "1E26": "\u1e27", + "1E28": "\u1e29", + "1E2A": "\u1e2b", + "1E2C": "\u1e2d", + "1E2E": "\u1e2f", + "1E30": "\u1e31", + "1E32": "\u1e33", + "1E34": "\u1e35", + "1E36": "\u1e37", + "1E38": "\u1e39", + "1E3A": "\u1e3b", + "1E3C": "\u1e3d", + "1E3E": "\u1e3f", + "1E40": "\u1e41", + "1E42": "\u1e43", + "1E44": "\u1e45", + "1E46": "\u1e47", + "1E48": "\u1e49", + "1E4A": "\u1e4b", + "1E4C": "\u1e4d", + "1E4E": "\u1e4f", + "1E50": "\u1e51", + "1E52": "\u1e53", + "1E54": "\u1e55", + "1E56": "\u1e57", + "1E58": "\u1e59", + "1E5A": "\u1e5b", + "1E5C": "\u1e5d", + "1E5E": "\u1e5f", + "1E60": "\u1e61", + "1E62": "\u1e63", + "1E64": "\u1e65", + "1E66": "\u1e67", + "1E68": "\u1e69", + "1E6A": "\u1e6b", + "1E6C": "\u1e6d", + "1E6E": "\u1e6f", + "1E70": "\u1e71", + "1E72": "\u1e73", + "1E74": "\u1e75", + "1E76": "\u1e77", + "1E78": "\u1e79", + "1E7A": "\u1e7b", + "1E7C": "\u1e7d", + "1E7E": "\u1e7f", + "1E80": "\u1e81", + "1E82": "\u1e83", + "1E84": "\u1e85", + "1E86": "\u1e87", + "1E88": "\u1e89", + "1E8A": "\u1e8b", + "1E8C": "\u1e8d", + "1E8E": "\u1e8f", + "1E90": "\u1e91", + "1E900": "\ud83a\udd22", + "1E901": "\ud83a\udd23", + "1E902": "\ud83a\udd24", + "1E903": "\ud83a\udd25", + "1E904": "\ud83a\udd26", + "1E905": "\ud83a\udd27", + "1E906": "\ud83a\udd28", + "1E907": "\ud83a\udd29", + "1E908": "\ud83a\udd2a", + "1E909": "\ud83a\udd2b", + "1E90A": "\ud83a\udd2c", + "1E90B": "\ud83a\udd2d", + "1E90C": "\ud83a\udd2e", + "1E90D": "\ud83a\udd2f", + "1E90E": "\ud83a\udd30", + "1E90F": "\ud83a\udd31", + "1E910": "\ud83a\udd32", + "1E911": "\ud83a\udd33", + "1E912": "\ud83a\udd34", + "1E913": "\ud83a\udd35", + "1E914": "\ud83a\udd36", + "1E915": "\ud83a\udd37", + "1E916": "\ud83a\udd38", + "1E917": "\ud83a\udd39", + "1E918": "\ud83a\udd3a", + "1E919": "\ud83a\udd3b", + "1E91A": "\ud83a\udd3c", + "1E91B": "\ud83a\udd3d", + "1E91C": "\ud83a\udd3e", + "1E91D": "\ud83a\udd3f", + "1E91E": "\ud83a\udd40", + "1E91F": "\ud83a\udd41", + "1E92": "\u1e93", + "1E920": "\ud83a\udd42", + "1E921": "\ud83a\udd43", + "1E94": "\u1e95", + "1E96": "h\u0331", + "1E97": "t\u0308", + "1E98": "w\u030a", + "1E99": "y\u030a", + "1E9A": "a\u02be", + "1E9B": "\u1e61", + "1E9E": "ss", + "1EA0": "\u1ea1", + "1EA2": "\u1ea3", + "1EA4": "\u1ea5", + "1EA6": "\u1ea7", + "1EA8": "\u1ea9", + "1EAA": "\u1eab", + "1EAC": "\u1ead", + "1EAE": "\u1eaf", + "1EB0": "\u1eb1", + "1EB2": "\u1eb3", + "1EB4": "\u1eb5", + "1EB6": "\u1eb7", + "1EB8": "\u1eb9", + "1EBA": "\u1ebb", + "1EBC": "\u1ebd", + "1EBE": "\u1ebf", + "1EC0": "\u1ec1", + "1EC2": "\u1ec3", + "1EC4": "\u1ec5", + "1EC6": "\u1ec7", + "1EC8": "\u1ec9", + "1ECA": "\u1ecb", + "1ECC": "\u1ecd", + "1ECE": "\u1ecf", + "1ED0": "\u1ed1", + "1ED2": "\u1ed3", + "1ED4": "\u1ed5", + "1ED6": "\u1ed7", + "1ED8": "\u1ed9", + "1EDA": "\u1edb", + "1EDC": "\u1edd", + "1EDE": "\u1edf", + "1EE0": "\u1ee1", + "1EE2": "\u1ee3", + "1EE4": "\u1ee5", + "1EE6": "\u1ee7", + "1EE8": "\u1ee9", + "1EEA": "\u1eeb", + "1EEC": "\u1eed", + "1EEE": "\u1eef", + "1EF0": "\u1ef1", + "1EF2": "\u1ef3", + "1EF4": "\u1ef5", + "1EF6": "\u1ef7", + "1EF8": "\u1ef9", + "1EFA": "\u1efb", + "1EFC": "\u1efd", + "1EFE": "\u1eff", + "1F08": "\u1f00", + "1F09": "\u1f01", + "1F0A": "\u1f02", + "1F0B": "\u1f03", + "1F0C": "\u1f04", + "1F0D": "\u1f05", + "1F0E": "\u1f06", + "1F0F": "\u1f07", + "1F18": "\u1f10", + "1F19": "\u1f11", + "1F1A": "\u1f12", + "1F1B": "\u1f13", + "1F1C": "\u1f14", + "1F1D": "\u1f15", + "1F28": "\u1f20", + "1F29": "\u1f21", + "1F2A": "\u1f22", + "1F2B": "\u1f23", + "1F2C": "\u1f24", + "1F2D": "\u1f25", + "1F2E": "\u1f26", + "1F2F": "\u1f27", + "1F38": "\u1f30", + "1F39": "\u1f31", + "1F3A": "\u1f32", + "1F3B": "\u1f33", + "1F3C": "\u1f34", + "1F3D": "\u1f35", + "1F3E": "\u1f36", + "1F3F": "\u1f37", + "1F48": "\u1f40", + "1F49": "\u1f41", + "1F4A": "\u1f42", + "1F4B": "\u1f43", + "1F4C": "\u1f44", + "1F4D": "\u1f45", + "1F50": "\u03c5\u0313", + "1F52": "\u03c5\u0313\u0300", + "1F54": "\u03c5\u0313\u0301", + "1F56": "\u03c5\u0313\u0342", + "1F59": "\u1f51", + "1F5B": "\u1f53", + "1F5D": "\u1f55", + "1F5F": "\u1f57", + "1F68": "\u1f60", + "1F69": "\u1f61", + "1F6A": "\u1f62", + "1F6B": "\u1f63", + "1F6C": "\u1f64", + "1F6D": "\u1f65", + "1F6E": "\u1f66", + "1F6F": "\u1f67", + "1F80": "\u1f00\u03b9", + "1F81": "\u1f01\u03b9", + "1F82": "\u1f02\u03b9", + "1F83": "\u1f03\u03b9", + "1F84": "\u1f04\u03b9", + "1F85": "\u1f05\u03b9", + "1F86": "\u1f06\u03b9", + "1F87": "\u1f07\u03b9", + "1F88": "\u1f00\u03b9", + "1F89": "\u1f01\u03b9", + "1F8A": "\u1f02\u03b9", + "1F8B": "\u1f03\u03b9", + "1F8C": "\u1f04\u03b9", + "1F8D": "\u1f05\u03b9", + "1F8E": "\u1f06\u03b9", + "1F8F": "\u1f07\u03b9", + "1F90": "\u1f20\u03b9", + "1F91": "\u1f21\u03b9", + "1F92": "\u1f22\u03b9", + "1F93": "\u1f23\u03b9", + "1F94": "\u1f24\u03b9", + "1F95": "\u1f25\u03b9", + "1F96": "\u1f26\u03b9", + "1F97": "\u1f27\u03b9", + "1F98": "\u1f20\u03b9", + "1F99": "\u1f21\u03b9", + "1F9A": "\u1f22\u03b9", + "1F9B": "\u1f23\u03b9", + "1F9C": "\u1f24\u03b9", + "1F9D": "\u1f25\u03b9", + "1F9E": "\u1f26\u03b9", + "1F9F": "\u1f27\u03b9", + "1FA0": "\u1f60\u03b9", + "1FA1": "\u1f61\u03b9", + "1FA2": "\u1f62\u03b9", + "1FA3": "\u1f63\u03b9", + "1FA4": "\u1f64\u03b9", + "1FA5": "\u1f65\u03b9", + "1FA6": "\u1f66\u03b9", + "1FA7": "\u1f67\u03b9", + "1FA8": "\u1f60\u03b9", + "1FA9": "\u1f61\u03b9", + "1FAA": "\u1f62\u03b9", + "1FAB": "\u1f63\u03b9", + "1FAC": "\u1f64\u03b9", + "1FAD": "\u1f65\u03b9", + "1FAE": "\u1f66\u03b9", + "1FAF": "\u1f67\u03b9", + "1FB2": "\u1f70\u03b9", + "1FB3": "\u03b1\u03b9", + "1FB4": "\u03ac\u03b9", + "1FB6": "\u03b1\u0342", + "1FB7": "\u03b1\u0342\u03b9", + "1FB8": "\u1fb0", + "1FB9": "\u1fb1", + "1FBA": "\u1f70", + "1FBB": "\u1f71", + "1FBC": "\u03b1\u03b9", + "1FBE": "\u03b9", + "1FC2": "\u1f74\u03b9", + "1FC3": "\u03b7\u03b9", + "1FC4": "\u03ae\u03b9", + "1FC6": "\u03b7\u0342", + "1FC7": "\u03b7\u0342\u03b9", + "1FC8": "\u1f72", + "1FC9": "\u1f73", + "1FCA": "\u1f74", + "1FCB": "\u1f75", + "1FCC": "\u03b7\u03b9", + "1FD2": "\u03b9\u0308\u0300", + "1FD3": "\u03b9\u0308\u0301", + "1FD6": "\u03b9\u0342", + "1FD7": "\u03b9\u0308\u0342", + "1FD8": "\u1fd0", + "1FD9": "\u1fd1", + "1FDA": "\u1f76", + "1FDB": "\u1f77", + "1FE2": "\u03c5\u0308\u0300", + "1FE3": "\u03c5\u0308\u0301", + "1FE4": "\u03c1\u0313", + "1FE6": "\u03c5\u0342", + "1FE7": "\u03c5\u0308\u0342", + "1FE8": "\u1fe0", + "1FE9": "\u1fe1", + "1FEA": "\u1f7a", + "1FEB": "\u1f7b", + "1FEC": "\u1fe5", + "1FF2": "\u1f7c\u03b9", + "1FF3": "\u03c9\u03b9", + "1FF4": "\u03ce\u03b9", + "1FF6": "\u03c9\u0342", + "1FF7": "\u03c9\u0342\u03b9", + "1FF8": "\u1f78", + "1FF9": "\u1f79", + "1FFA": "\u1f7c", + "1FFB": "\u1f7d", + "1FFC": "\u03c9\u03b9", + "2126": "\u03c9", + "212A": "k", + "212B": "\u00e5", + "2132": "\u214e", + "2160": "\u2170", + "2161": "\u2171", + "2162": "\u2172", + "2163": "\u2173", + "2164": "\u2174", + "2165": "\u2175", + "2166": "\u2176", + "2167": "\u2177", + "2168": "\u2178", + "2169": "\u2179", + "216A": "\u217a", + "216B": "\u217b", + "216C": "\u217c", + "216D": "\u217d", + "216E": "\u217e", + "216F": "\u217f", + "2183": "\u2184", + "24B6": "\u24d0", + "24B7": "\u24d1", + "24B8": "\u24d2", + "24B9": "\u24d3", + "24BA": "\u24d4", + "24BB": "\u24d5", + "24BC": "\u24d6", + "24BD": "\u24d7", + "24BE": "\u24d8", + "24BF": "\u24d9", + "24C0": "\u24da", + "24C1": "\u24db", + "24C2": "\u24dc", + "24C3": "\u24dd", + "24C4": "\u24de", + "24C5": "\u24df", + "24C6": "\u24e0", + "24C7": "\u24e1", + "24C8": "\u24e2", + "24C9": "\u24e3", + "24CA": "\u24e4", + "24CB": "\u24e5", + "24CC": "\u24e6", + "24CD": "\u24e7", + "24CE": "\u24e8", + "24CF": "\u24e9", + "2C00": "\u2c30", + "2C01": "\u2c31", + "2C02": "\u2c32", + "2C03": "\u2c33", + "2C04": "\u2c34", + "2C05": "\u2c35", + "2C06": "\u2c36", + "2C07": "\u2c37", + "2C08": "\u2c38", + "2C09": "\u2c39", + "2C0A": "\u2c3a", + "2C0B": "\u2c3b", + "2C0C": "\u2c3c", + "2C0D": "\u2c3d", + "2C0E": "\u2c3e", + "2C0F": "\u2c3f", + "2C10": "\u2c40", + "2C11": "\u2c41", + "2C12": "\u2c42", + "2C13": "\u2c43", + "2C14": "\u2c44", + "2C15": "\u2c45", + "2C16": "\u2c46", + "2C17": "\u2c47", + "2C18": "\u2c48", + "2C19": "\u2c49", + "2C1A": "\u2c4a", + "2C1B": "\u2c4b", + "2C1C": "\u2c4c", + "2C1D": "\u2c4d", + "2C1E": "\u2c4e", + "2C1F": "\u2c4f", + "2C20": "\u2c50", + "2C21": "\u2c51", + "2C22": "\u2c52", + "2C23": "\u2c53", + "2C24": "\u2c54", + "2C25": "\u2c55", + "2C26": "\u2c56", + "2C27": "\u2c57", + "2C28": "\u2c58", + "2C29": "\u2c59", + "2C2A": "\u2c5a", + "2C2B": "\u2c5b", + "2C2C": "\u2c5c", + "2C2D": "\u2c5d", + "2C2E": "\u2c5e", + "2C2F": "\u2c5f", + "2C60": "\u2c61", + "2C62": "\u026b", + "2C63": "\u1d7d", + "2C64": "\u027d", + "2C67": "\u2c68", + "2C69": "\u2c6a", + "2C6B": "\u2c6c", + "2C6D": "\u0251", + "2C6E": "\u0271", + "2C6F": "\u0250", + "2C70": "\u0252", + "2C72": "\u2c73", + "2C75": "\u2c76", + "2C7E": "\u023f", + "2C7F": "\u0240", + "2C80": "\u2c81", + "2C82": "\u2c83", + "2C84": "\u2c85", + "2C86": "\u2c87", + "2C88": "\u2c89", + "2C8A": "\u2c8b", + "2C8C": "\u2c8d", + "2C8E": "\u2c8f", + "2C90": "\u2c91", + "2C92": "\u2c93", + "2C94": "\u2c95", + "2C96": "\u2c97", + "2C98": "\u2c99", + "2C9A": "\u2c9b", + "2C9C": "\u2c9d", + "2C9E": "\u2c9f", + "2CA0": "\u2ca1", + "2CA2": "\u2ca3", + "2CA4": "\u2ca5", + "2CA6": "\u2ca7", + "2CA8": "\u2ca9", + "2CAA": "\u2cab", + "2CAC": "\u2cad", + "2CAE": "\u2caf", + "2CB0": "\u2cb1", + "2CB2": "\u2cb3", + "2CB4": "\u2cb5", + "2CB6": "\u2cb7", + "2CB8": "\u2cb9", + "2CBA": "\u2cbb", + "2CBC": "\u2cbd", + "2CBE": "\u2cbf", + "2CC0": "\u2cc1", + "2CC2": "\u2cc3", + "2CC4": "\u2cc5", + "2CC6": "\u2cc7", + "2CC8": "\u2cc9", + "2CCA": "\u2ccb", + "2CCC": "\u2ccd", + "2CCE": "\u2ccf", + "2CD0": "\u2cd1", + "2CD2": "\u2cd3", + "2CD4": "\u2cd5", + "2CD6": "\u2cd7", + "2CD8": "\u2cd9", + "2CDA": "\u2cdb", + "2CDC": "\u2cdd", + "2CDE": "\u2cdf", + "2CE0": "\u2ce1", + "2CE2": "\u2ce3", + "2CEB": "\u2cec", + "2CED": "\u2cee", + "2CF2": "\u2cf3", + "A640": "\ua641", + "A642": "\ua643", + "A644": "\ua645", + "A646": "\ua647", + "A648": "\ua649", + "A64A": "\ua64b", + "A64C": "\ua64d", + "A64E": "\ua64f", + "A650": "\ua651", + "A652": "\ua653", + "A654": "\ua655", + "A656": "\ua657", + "A658": "\ua659", + "A65A": "\ua65b", + "A65C": "\ua65d", + "A65E": "\ua65f", + "A660": "\ua661", + "A662": "\ua663", + "A664": "\ua665", + "A666": "\ua667", + "A668": "\ua669", + "A66A": "\ua66b", + "A66C": "\ua66d", + "A680": "\ua681", + "A682": "\ua683", + "A684": "\ua685", + "A686": "\ua687", + "A688": "\ua689", + "A68A": "\ua68b", + "A68C": "\ua68d", + "A68E": "\ua68f", + "A690": "\ua691", + "A692": "\ua693", + "A694": "\ua695", + "A696": "\ua697", + "A698": "\ua699", + "A69A": "\ua69b", + "A722": "\ua723", + "A724": "\ua725", + "A726": "\ua727", + "A728": "\ua729", + "A72A": "\ua72b", + "A72C": "\ua72d", + "A72E": "\ua72f", + "A732": "\ua733", + "A734": "\ua735", + "A736": "\ua737", + "A738": "\ua739", + "A73A": "\ua73b", + "A73C": "\ua73d", + "A73E": "\ua73f", + "A740": "\ua741", + "A742": "\ua743", + "A744": "\ua745", + "A746": "\ua747", + "A748": "\ua749", + "A74A": "\ua74b", + "A74C": "\ua74d", + "A74E": "\ua74f", + "A750": "\ua751", + "A752": "\ua753", + "A754": "\ua755", + "A756": "\ua757", + "A758": "\ua759", + "A75A": "\ua75b", + "A75C": "\ua75d", + "A75E": "\ua75f", + "A760": "\ua761", + "A762": "\ua763", + "A764": "\ua765", + "A766": "\ua767", + "A768": "\ua769", + "A76A": "\ua76b", + "A76C": "\ua76d", + "A76E": "\ua76f", + "A779": "\ua77a", + "A77B": "\ua77c", + "A77D": "\u1d79", + "A77E": "\ua77f", + "A780": "\ua781", + "A782": "\ua783", + "A784": "\ua785", + "A786": "\ua787", + "A78B": "\ua78c", + "A78D": "\u0265", + "A790": "\ua791", + "A792": "\ua793", + "A796": "\ua797", + "A798": "\ua799", + "A79A": "\ua79b", + "A79C": "\ua79d", + "A79E": "\ua79f", + "A7A0": "\ua7a1", + "A7A2": "\ua7a3", + "A7A4": "\ua7a5", + "A7A6": "\ua7a7", + "A7A8": "\ua7a9", + "A7AA": "\u0266", + "A7AB": "\u025c", + "A7AC": "\u0261", + "A7AD": "\u026c", + "A7AE": "\u026a", + "A7B0": "\u029e", + "A7B1": "\u0287", + "A7B2": "\u029d", + "A7B3": "\uab53", + "A7B4": "\ua7b5", + "A7B6": "\ua7b7", + "A7B8": "\ua7b9", + "A7BA": "\ua7bb", + "A7BC": "\ua7bd", + "A7BE": "\ua7bf", + "A7C0": "\ua7c1", + "A7C2": "\ua7c3", + "A7C4": "\ua794", + "A7C5": "\u0282", + "A7C6": "\u1d8e", + "A7C7": "\ua7c8", + "A7C9": "\ua7ca", + "A7D0": "\ua7d1", + "A7D6": "\ua7d7", + "A7D8": "\ua7d9", + "A7F5": "\ua7f6", + "AB70": "\u13a0", + "AB71": "\u13a1", + "AB72": "\u13a2", + "AB73": "\u13a3", + "AB74": "\u13a4", + "AB75": "\u13a5", + "AB76": "\u13a6", + "AB77": "\u13a7", + "AB78": "\u13a8", + "AB79": "\u13a9", + "AB7A": "\u13aa", + "AB7B": "\u13ab", + "AB7C": "\u13ac", + "AB7D": "\u13ad", + "AB7E": "\u13ae", + "AB7F": "\u13af", + "AB80": "\u13b0", + "AB81": "\u13b1", + "AB82": "\u13b2", + "AB83": "\u13b3", + "AB84": "\u13b4", + "AB85": "\u13b5", + "AB86": "\u13b6", + "AB87": "\u13b7", + "AB88": "\u13b8", + "AB89": "\u13b9", + "AB8A": "\u13ba", + "AB8B": "\u13bb", + "AB8C": "\u13bc", + "AB8D": "\u13bd", + "AB8E": "\u13be", + "AB8F": "\u13bf", + "AB90": "\u13c0", + "AB91": "\u13c1", + "AB92": "\u13c2", + "AB93": "\u13c3", + "AB94": "\u13c4", + "AB95": "\u13c5", + "AB96": "\u13c6", + "AB97": "\u13c7", + "AB98": "\u13c8", + "AB99": "\u13c9", + "AB9A": "\u13ca", + "AB9B": "\u13cb", + "AB9C": "\u13cc", + "AB9D": "\u13cd", + "AB9E": "\u13ce", + "AB9F": "\u13cf", + "ABA0": "\u13d0", + "ABA1": "\u13d1", + "ABA2": "\u13d2", + "ABA3": "\u13d3", + "ABA4": "\u13d4", + "ABA5": "\u13d5", + "ABA6": "\u13d6", + "ABA7": "\u13d7", + "ABA8": "\u13d8", + "ABA9": "\u13d9", + "ABAA": "\u13da", + "ABAB": "\u13db", + "ABAC": "\u13dc", + "ABAD": "\u13dd", + "ABAE": "\u13de", + "ABAF": "\u13df", + "ABB0": "\u13e0", + "ABB1": "\u13e1", + "ABB2": "\u13e2", + "ABB3": "\u13e3", + "ABB4": "\u13e4", + "ABB5": "\u13e5", + "ABB6": "\u13e6", + "ABB7": "\u13e7", + "ABB8": "\u13e8", + "ABB9": "\u13e9", + "ABBA": "\u13ea", + "ABBB": "\u13eb", + "ABBC": "\u13ec", + "ABBD": "\u13ed", + "ABBE": "\u13ee", + "ABBF": "\u13ef", + "FB00": "ff", + "FB01": "fi", + "FB02": "fl", + "FB03": "ffi", + "FB04": "ffl", + "FB05": "st", + "FB06": "st", + "FB13": "\u0574\u0576", + "FB14": "\u0574\u0565", + "FB15": "\u0574\u056b", + "FB16": "\u057e\u0576", + "FB17": "\u0574\u056d", + "FF21": "\uff41", + "FF22": "\uff42", + "FF23": "\uff43", + "FF24": "\uff44", + "FF25": "\uff45", + "FF26": "\uff46", + "FF27": "\uff47", + "FF28": "\uff48", + "FF29": "\uff49", + "FF2A": "\uff4a", + "FF2B": "\uff4b", + "FF2C": "\uff4c", + "FF2D": "\uff4d", + "FF2E": "\uff4e", + "FF2F": "\uff4f", + "FF30": "\uff50", + "FF31": "\uff51", + "FF32": "\uff52", + "FF33": "\uff53", + "FF34": "\uff54", + "FF35": "\uff55", + "FF36": "\uff56", + "FF37": "\uff57", + "FF38": "\uff58", + "FF39": "\uff59", + "FF3A": "\uff5a" + }, + "combining": { + "0300": 230, + "0301": 230, + "0302": 230, + "0303": 230, + "0304": 230, + "0305": 230, + "0306": 230, + "0307": 230, + "0308": 230, + "0309": 230, + "030A": 230, + "030B": 230, + "030C": 230, + "030D": 230, + "030E": 230, + "030F": 230, + "0310": 230, + "0311": 230, + "0312": 230, + "0313": 230, + "0314": 230, + "0315": 232, + "0316": 220, + "0317": 220, + "0318": 220, + "0319": 220, + "031A": 232, + "031B": 216, + "031C": 220, + "031D": 220, + "031E": 220, + "031F": 220, + "0320": 220, + "0321": 202, + "0322": 202, + "0323": 220, + "0324": 220, + "0325": 220, + "0326": 220, + "0327": 202, + "0328": 202, + "0329": 220, + "032A": 220, + "032B": 220, + "032C": 220, + "032D": 220, + "032E": 220, + "032F": 220, + "0330": 220, + "0331": 220, + "0332": 220, + "0333": 220, + "0334": 1, + "0335": 1, + "0336": 1, + "0337": 1, + "0338": 1, + "0339": 220, + "033A": 220, + "033B": 220, + "033C": 220, + "033D": 230, + "033E": 230, + "033F": 230, + "0340": 230, + "0341": 230, + "0342": 230, + "0343": 230, + "0344": 230, + "0345": 240, + "0346": 230, + "0347": 220, + "0348": 220, + "0349": 220, + "034A": 230, + "034B": 230, + "034C": 230, + "034D": 220, + "034E": 220, + "0350": 230, + "0351": 230, + "0352": 230, + "0353": 220, + "0354": 220, + "0355": 220, + "0356": 220, + "0357": 230, + "0358": 232, + "0359": 220, + "035A": 220, + "035B": 230, + "035C": 233, + "035D": 234, + "035E": 234, + "035F": 233, + "0360": 234, + "0361": 234, + "0362": 233, + "0363": 230, + "0364": 230, + "0365": 230, + "0366": 230, + "0367": 230, + "0368": 230, + "0369": 230, + "036A": 230, + "036B": 230, + "036C": 230, + "036D": 230, + "036E": 230, + "036F": 230, + "0483": 230, + "0484": 230, + "0485": 230, + "0486": 230, + "0487": 230, + "0591": 220, + "0592": 230, + "0593": 230, + "0594": 230, + "0595": 230, + "0596": 220, + "0597": 230, + "0598": 230, + "0599": 230, + "059A": 222, + "059B": 220, + "059C": 230, + "059D": 230, + "059E": 230, + "059F": 230, + "05A0": 230, + "05A1": 230, + "05A2": 220, + "05A3": 220, + "05A4": 220, + "05A5": 220, + "05A6": 220, + "05A7": 220, + "05A8": 230, + "05A9": 230, + "05AA": 220, + "05AB": 230, + "05AC": 230, + "05AD": 222, + "05AE": 228, + "05AF": 230, + "05B0": 10, + "05B1": 11, + "05B2": 12, + "05B3": 13, + "05B4": 14, + "05B5": 15, + "05B6": 16, + "05B7": 17, + "05B8": 18, + "05B9": 19, + "05BA": 19, + "05BB": 20, + "05BC": 21, + "05BD": 22, + "05BF": 23, + "05C1": 24, + "05C2": 25, + "05C4": 230, + "05C5": 220, + "05C7": 18, + "0610": 230, + "0611": 230, + "0612": 230, + "0613": 230, + "0614": 230, + "0615": 230, + "0616": 230, + "0617": 230, + "0618": 30, + "0619": 31, + "061A": 32, + "064B": 27, + "064C": 28, + "064D": 29, + "064E": 30, + "064F": 31, + "0650": 32, + "0651": 33, + "0652": 34, + "0653": 230, + "0654": 230, + "0655": 220, + "0656": 220, + "0657": 230, + "0658": 230, + "0659": 230, + "065A": 230, + "065B": 230, + "065C": 220, + "065D": 230, + "065E": 230, + "065F": 220, + "0670": 35, + "06D6": 230, + "06D7": 230, + "06D8": 230, + "06D9": 230, + "06DA": 230, + "06DB": 230, + "06DC": 230, + "06DF": 230, + "06E0": 230, + "06E1": 230, + "06E2": 230, + "06E3": 220, + "06E4": 230, + "06E7": 230, + "06E8": 230, + "06EA": 220, + "06EB": 230, + "06EC": 230, + "06ED": 220, + "0711": 36, + "0730": 230, + "0731": 220, + "0732": 230, + "0733": 230, + "0734": 220, + "0735": 230, + "0736": 230, + "0737": 220, + "0738": 220, + "0739": 220, + "073A": 230, + "073B": 220, + "073C": 220, + "073D": 230, + "073E": 220, + "073F": 230, + "0740": 230, + "0741": 230, + "0742": 220, + "0743": 230, + "0744": 220, + "0745": 230, + "0746": 220, + "0747": 230, + "0748": 220, + "0749": 230, + "074A": 230, + "07EB": 230, + "07EC": 230, + "07ED": 230, + "07EE": 230, + "07EF": 230, + "07F0": 230, + "07F1": 230, + "07F2": 220, + "07F3": 230, + "07FD": 220, + "0816": 230, + "0817": 230, + "0818": 230, + "0819": 230, + "081B": 230, + "081C": 230, + "081D": 230, + "081E": 230, + "081F": 230, + "0820": 230, + "0821": 230, + "0822": 230, + "0823": 230, + "0825": 230, + "0826": 230, + "0827": 230, + "0829": 230, + "082A": 230, + "082B": 230, + "082C": 230, + "082D": 230, + "0859": 220, + "085A": 220, + "085B": 220, + "0898": 230, + "0899": 220, + "089A": 220, + "089B": 220, + "089C": 230, + "089D": 230, + "089E": 230, + "089F": 230, + "08CA": 230, + "08CB": 230, + "08CC": 230, + "08CD": 230, + "08CE": 230, + "08CF": 220, + "08D0": 220, + "08D1": 220, + "08D2": 220, + "08D3": 220, + "08D4": 230, + "08D5": 230, + "08D6": 230, + "08D7": 230, + "08D8": 230, + "08D9": 230, + "08DA": 230, + "08DB": 230, + "08DC": 230, + "08DD": 230, + "08DE": 230, + "08DF": 230, + "08E0": 230, + "08E1": 230, + "08E3": 220, + "08E4": 230, + "08E5": 230, + "08E6": 220, + "08E7": 230, + "08E8": 230, + "08E9": 220, + "08EA": 230, + "08EB": 230, + "08EC": 230, + "08ED": 220, + "08EE": 220, + "08EF": 220, + "08F0": 27, + "08F1": 28, + "08F2": 29, + "08F3": 230, + "08F4": 230, + "08F5": 230, + "08F6": 220, + "08F7": 230, + "08F8": 230, + "08F9": 220, + "08FA": 220, + "08FB": 230, + "08FC": 230, + "08FD": 230, + "08FE": 230, + "08FF": 230, + "093C": 7, + "094D": 9, + "0951": 230, + "0952": 220, + "0953": 230, + "0954": 230, + "09BC": 7, + "09CD": 9, + "09FE": 230, + "0A3C": 7, + "0A4D": 9, + "0ABC": 7, + "0ACD": 9, + "0B3C": 7, + "0B4D": 9, + "0BCD": 9, + "0C3C": 7, + "0C4D": 9, + "0C55": 84, + "0C56": 91, + "0CBC": 7, + "0CCD": 9, + "0D3B": 9, + "0D3C": 9, + "0D4D": 9, + "0DCA": 9, + "0E38": 103, + "0E39": 103, + "0E3A": 9, + "0E48": 107, + "0E49": 107, + "0E4A": 107, + "0E4B": 107, + "0EB8": 118, + "0EB9": 118, + "0EBA": 9, + "0EC8": 122, + "0EC9": 122, + "0ECA": 122, + "0ECB": 122, + "0F18": 220, + "0F19": 220, + "0F35": 220, + "0F37": 220, + "0F39": 216, + "0F71": 129, + "0F72": 130, + "0F74": 132, + "0F7A": 130, + "0F7B": 130, + "0F7C": 130, + "0F7D": 130, + "0F80": 130, + "0F82": 230, + "0F83": 230, + "0F84": 9, + "0F86": 230, + "0F87": 230, + "0FC6": 220, + "101FD": 220, + "102E0": 220, + "1037": 7, + "10376": 230, + "10377": 230, + "10378": 230, + "10379": 230, + "1037A": 230, + "1039": 9, + "103A": 9, + "108D": 220, + "10A0D": 220, + "10A0F": 230, + "10A38": 230, + "10A39": 1, + "10A3A": 220, + "10A3F": 9, + "10AE5": 230, + "10AE6": 220, + "10D24": 230, + "10D25": 230, + "10D26": 230, + "10D27": 230, + "10EAB": 230, + "10EAC": 230, + "10EFD": 220, + "10EFE": 220, + "10EFF": 220, + "10F46": 220, + "10F47": 220, + "10F48": 230, + "10F49": 230, + "10F4A": 230, + "10F4B": 220, + "10F4C": 230, + "10F4D": 220, + "10F4E": 220, + "10F4F": 220, + "10F50": 220, + "10F82": 230, + "10F83": 220, + "10F84": 230, + "10F85": 220, + "11046": 9, + "11070": 9, + "1107F": 9, + "110B9": 9, + "110BA": 7, + "11100": 230, + "11101": 230, + "11102": 230, + "11133": 9, + "11134": 9, + "11173": 7, + "111C0": 9, + "111CA": 7, + "11235": 9, + "11236": 7, + "112E9": 7, + "112EA": 9, + "1133B": 7, + "1133C": 7, + "1134D": 9, + "11366": 230, + "11367": 230, + "11368": 230, + "11369": 230, + "1136A": 230, + "1136B": 230, + "1136C": 230, + "11370": 230, + "11371": 230, + "11372": 230, + "11373": 230, + "11374": 230, + "11442": 9, + "11446": 7, + "1145E": 230, + "114C2": 9, + "114C3": 7, + "115BF": 9, + "115C0": 7, + "1163F": 9, + "116B6": 9, + "116B7": 7, + "1172B": 9, + "11839": 9, + "1183A": 7, + "1193D": 9, + "1193E": 9, + "11943": 7, + "119E0": 9, + "11A34": 9, + "11A47": 9, + "11A99": 9, + "11C3F": 9, + "11D42": 7, + "11D44": 9, + "11D45": 9, + "11D97": 9, + "11F41": 9, + "11F42": 9, + "135D": 230, + "135E": 230, + "135F": 230, + "16AF0": 1, + "16AF1": 1, + "16AF2": 1, + "16AF3": 1, + "16AF4": 1, + "16B30": 230, + "16B31": 230, + "16B32": 230, + "16B33": 230, + "16B34": 230, + "16B35": 230, + "16B36": 230, + "16FF0": 6, + "16FF1": 6, + "1714": 9, + "1715": 9, + "1734": 9, + "17D2": 9, + "17DD": 230, + "18A9": 228, + "1939": 222, + "193A": 230, + "193B": 220, + "1A17": 230, + "1A18": 220, + "1A60": 9, + "1A75": 230, + "1A76": 230, + "1A77": 230, + "1A78": 230, + "1A79": 230, + "1A7A": 230, + "1A7B": 230, + "1A7C": 230, + "1A7F": 220, + "1AB0": 230, + "1AB1": 230, + "1AB2": 230, + "1AB3": 230, + "1AB4": 230, + "1AB5": 220, + "1AB6": 220, + "1AB7": 220, + "1AB8": 220, + "1AB9": 220, + "1ABA": 220, + "1ABB": 230, + "1ABC": 230, + "1ABD": 220, + "1ABF": 220, + "1AC0": 220, + "1AC1": 230, + "1AC2": 230, + "1AC3": 220, + "1AC4": 220, + "1AC5": 230, + "1AC6": 230, + "1AC7": 230, + "1AC8": 230, + "1AC9": 230, + "1ACA": 220, + "1ACB": 230, + "1ACC": 230, + "1ACD": 230, + "1ACE": 230, + "1B34": 7, + "1B44": 9, + "1B6B": 230, + "1B6C": 220, + "1B6D": 230, + "1B6E": 230, + "1B6F": 230, + "1B70": 230, + "1B71": 230, + "1B72": 230, + "1B73": 230, + "1BAA": 9, + "1BAB": 9, + "1BC9E": 1, + "1BE6": 7, + "1BF2": 9, + "1BF3": 9, + "1C37": 7, + "1CD0": 230, + "1CD1": 230, + "1CD2": 230, + "1CD4": 1, + "1CD5": 220, + "1CD6": 220, + "1CD7": 220, + "1CD8": 220, + "1CD9": 220, + "1CDA": 230, + "1CDB": 230, + "1CDC": 220, + "1CDD": 220, + "1CDE": 220, + "1CDF": 220, + "1CE0": 230, + "1CE2": 1, + "1CE3": 1, + "1CE4": 1, + "1CE5": 1, + "1CE6": 1, + "1CE7": 1, + "1CE8": 1, + "1CED": 220, + "1CF4": 230, + "1CF8": 230, + "1CF9": 230, + "1D165": 216, + "1D166": 216, + "1D167": 1, + "1D168": 1, + "1D169": 1, + "1D16D": 226, + "1D16E": 216, + "1D16F": 216, + "1D170": 216, + "1D171": 216, + "1D172": 216, + "1D17B": 220, + "1D17C": 220, + "1D17D": 220, + "1D17E": 220, + "1D17F": 220, + "1D180": 220, + "1D181": 220, + "1D182": 220, + "1D185": 230, + "1D186": 230, + "1D187": 230, + "1D188": 230, + "1D189": 230, + "1D18A": 220, + "1D18B": 220, + "1D1AA": 230, + "1D1AB": 230, + "1D1AC": 230, + "1D1AD": 230, + "1D242": 230, + "1D243": 230, + "1D244": 230, + "1DC0": 230, + "1DC1": 230, + "1DC2": 220, + "1DC3": 230, + "1DC4": 230, + "1DC5": 230, + "1DC6": 230, + "1DC7": 230, + "1DC8": 230, + "1DC9": 230, + "1DCA": 220, + "1DCB": 230, + "1DCC": 230, + "1DCD": 234, + "1DCE": 214, + "1DCF": 220, + "1DD0": 202, + "1DD1": 230, + "1DD2": 230, + "1DD3": 230, + "1DD4": 230, + "1DD5": 230, + "1DD6": 230, + "1DD7": 230, + "1DD8": 230, + "1DD9": 230, + "1DDA": 230, + "1DDB": 230, + "1DDC": 230, + "1DDD": 230, + "1DDE": 230, + "1DDF": 230, + "1DE0": 230, + "1DE1": 230, + "1DE2": 230, + "1DE3": 230, + "1DE4": 230, + "1DE5": 230, + "1DE6": 230, + "1DE7": 230, + "1DE8": 230, + "1DE9": 230, + "1DEA": 230, + "1DEB": 230, + "1DEC": 230, + "1DED": 230, + "1DEE": 230, + "1DEF": 230, + "1DF0": 230, + "1DF1": 230, + "1DF2": 230, + "1DF3": 230, + "1DF4": 230, + "1DF5": 230, + "1DF6": 232, + "1DF7": 228, + "1DF8": 228, + "1DF9": 220, + "1DFA": 218, + "1DFB": 230, + "1DFC": 233, + "1DFD": 220, + "1DFE": 230, + "1DFF": 220, + "1E000": 230, + "1E001": 230, + "1E002": 230, + "1E003": 230, + "1E004": 230, + "1E005": 230, + "1E006": 230, + "1E008": 230, + "1E009": 230, + "1E00A": 230, + "1E00B": 230, + "1E00C": 230, + "1E00D": 230, + "1E00E": 230, + "1E00F": 230, + "1E010": 230, + "1E011": 230, + "1E012": 230, + "1E013": 230, + "1E014": 230, + "1E015": 230, + "1E016": 230, + "1E017": 230, + "1E018": 230, + "1E01B": 230, + "1E01C": 230, + "1E01D": 230, + "1E01E": 230, + "1E01F": 230, + "1E020": 230, + "1E021": 230, + "1E023": 230, + "1E024": 230, + "1E026": 230, + "1E027": 230, + "1E028": 230, + "1E029": 230, + "1E02A": 230, + "1E08F": 230, + "1E130": 230, + "1E131": 230, + "1E132": 230, + "1E133": 230, + "1E134": 230, + "1E135": 230, + "1E136": 230, + "1E2AE": 230, + "1E2EC": 230, + "1E2ED": 230, + "1E2EE": 230, + "1E2EF": 230, + "1E4EC": 232, + "1E4ED": 232, + "1E4EE": 220, + "1E4EF": 230, + "1E8D0": 220, + "1E8D1": 220, + "1E8D2": 220, + "1E8D3": 220, + "1E8D4": 220, + "1E8D5": 220, + "1E8D6": 220, + "1E944": 230, + "1E945": 230, + "1E946": 230, + "1E947": 230, + "1E948": 230, + "1E949": 230, + "1E94A": 7, + "20D0": 230, + "20D1": 230, + "20D2": 1, + "20D3": 1, + "20D4": 230, + "20D5": 230, + "20D6": 230, + "20D7": 230, + "20D8": 1, + "20D9": 1, + "20DA": 1, + "20DB": 230, + "20DC": 230, + "20E1": 230, + "20E5": 1, + "20E6": 1, + "20E7": 230, + "20E8": 220, + "20E9": 230, + "20EA": 1, + "20EB": 1, + "20EC": 220, + "20ED": 220, + "20EE": 220, + "20EF": 220, + "20F0": 230, + "2CEF": 230, + "2CF0": 230, + "2CF1": 230, + "2D7F": 9, + "2DE0": 230, + "2DE1": 230, + "2DE2": 230, + "2DE3": 230, + "2DE4": 230, + "2DE5": 230, + "2DE6": 230, + "2DE7": 230, + "2DE8": 230, + "2DE9": 230, + "2DEA": 230, + "2DEB": 230, + "2DEC": 230, + "2DED": 230, + "2DEE": 230, + "2DEF": 230, + "2DF0": 230, + "2DF1": 230, + "2DF2": 230, + "2DF3": 230, + "2DF4": 230, + "2DF5": 230, + "2DF6": 230, + "2DF7": 230, + "2DF8": 230, + "2DF9": 230, + "2DFA": 230, + "2DFB": 230, + "2DFC": 230, + "2DFD": 230, + "2DFE": 230, + "2DFF": 230, + "302A": 218, + "302B": 228, + "302C": 232, + "302D": 222, + "302E": 224, + "302F": 224, + "3099": 8, + "309A": 8, + "A66F": 230, + "A674": 230, + "A675": 230, + "A676": 230, + "A677": 230, + "A678": 230, + "A679": 230, + "A67A": 230, + "A67B": 230, + "A67C": 230, + "A67D": 230, + "A69E": 230, + "A69F": 230, + "A6F0": 230, + "A6F1": 230, + "A806": 9, + "A82C": 9, + "A8C4": 9, + "A8E0": 230, + "A8E1": 230, + "A8E2": 230, + "A8E3": 230, + "A8E4": 230, + "A8E5": 230, + "A8E6": 230, + "A8E7": 230, + "A8E8": 230, + "A8E9": 230, + "A8EA": 230, + "A8EB": 230, + "A8EC": 230, + "A8ED": 230, + "A8EE": 230, + "A8EF": 230, + "A8F0": 230, + "A8F1": 230, + "A92B": 220, + "A92C": 220, + "A92D": 220, + "A953": 9, + "A9B3": 7, + "A9C0": 9, + "AAB0": 230, + "AAB2": 230, + "AAB3": 230, + "AAB4": 220, + "AAB7": 230, + "AAB8": 230, + "AABE": 230, + "AABF": 230, + "AAC1": 230, + "AAF6": 9, + "ABED": 9, + "FB1E": 26, + "FE20": 230, + "FE21": 230, + "FE22": 230, + "FE23": 230, + "FE24": 230, + "FE25": 230, + "FE26": 230, + "FE27": 220, + "FE28": 220, + "FE29": 220, + "FE2A": 220, + "FE2B": 220, + "FE2C": 220, + "FE2D": 220, + "FE2E": 230, + "FE2F": 230 + }, + "composition": { + "102,300": 7856, + "102,301": 7854, + "102,303": 7860, + "102,309": 7858, + "1025,102E": 4134, + "103,300": 7857, + "103,301": 7855, + "103,303": 7861, + "103,309": 7859, + "11099,110BA": 69786, + "1109B,110BA": 69788, + "110A5,110BA": 69803, + "11131,11127": 69934, + "11132,11127": 69935, + "112,300": 7700, + "112,301": 7702, + "113,300": 7701, + "113,301": 7703, + "11347,1133E": 70475, + "11347,11357": 70476, + "114B9,114B0": 70844, + "114B9,114BA": 70843, + "114B9,114BD": 70846, + "115B8,115AF": 71098, + "115B9,115AF": 71099, + "11935,11930": 71992, + "14C,300": 7760, + "14C,301": 7762, + "14D,300": 7761, + "14D,301": 7763, + "15A,307": 7780, + "15B,307": 7781, + "160,307": 7782, + "161,307": 7783, + "168,301": 7800, + "169,301": 7801, + "16A,308": 7802, + "16B,308": 7803, + "17F,307": 7835, + "1A0,300": 7900, + "1A0,301": 7898, + "1A0,303": 7904, + "1A0,309": 7902, + "1A0,323": 7906, + "1A1,300": 7901, + "1A1,301": 7899, + "1A1,303": 7905, + "1A1,309": 7903, + "1A1,323": 7907, + "1AF,300": 7914, + "1AF,301": 7912, + "1AF,303": 7918, + "1AF,309": 7916, + "1AF,323": 7920, + "1B0,300": 7915, + "1B0,301": 7913, + "1B0,303": 7919, + "1B0,309": 7917, + "1B0,323": 7921, + "1B05,1B35": 6918, + "1B07,1B35": 6920, + "1B09,1B35": 6922, + "1B0B,1B35": 6924, + "1B0D,1B35": 6926, + "1B11,1B35": 6930, + "1B3A,1B35": 6971, + "1B3C,1B35": 6973, + "1B3E,1B35": 6976, + "1B3F,1B35": 6977, + "1B42,1B35": 6979, + "1B7,30C": 494, + "1E36,304": 7736, + "1E37,304": 7737, + "1E5A,304": 7772, + "1E5B,304": 7773, + "1E62,307": 7784, + "1E63,307": 7785, + "1EA,304": 492, + "1EA0,302": 7852, + "1EA0,306": 7862, + "1EA1,302": 7853, + "1EA1,306": 7863, + "1EB,304": 493, + "1EB8,302": 7878, + "1EB9,302": 7879, + "1ECC,302": 7896, + "1ECD,302": 7897, + "1F00,300": 7938, + "1F00,301": 7940, + "1F00,342": 7942, + "1F00,345": 8064, + "1F01,300": 7939, + "1F01,301": 7941, + "1F01,342": 7943, + "1F01,345": 8065, + "1F02,345": 8066, + "1F03,345": 8067, + "1F04,345": 8068, + "1F05,345": 8069, + "1F06,345": 8070, + "1F07,345": 8071, + "1F08,300": 7946, + "1F08,301": 7948, + "1F08,342": 7950, + "1F08,345": 8072, + "1F09,300": 7947, + "1F09,301": 7949, + "1F09,342": 7951, + "1F09,345": 8073, + "1F0A,345": 8074, + "1F0B,345": 8075, + "1F0C,345": 8076, + "1F0D,345": 8077, + "1F0E,345": 8078, + "1F0F,345": 8079, + "1F10,300": 7954, + "1F10,301": 7956, + "1F11,300": 7955, + "1F11,301": 7957, + "1F18,300": 7962, + "1F18,301": 7964, + "1F19,300": 7963, + "1F19,301": 7965, + "1F20,300": 7970, + "1F20,301": 7972, + "1F20,342": 7974, + "1F20,345": 8080, + "1F21,300": 7971, + "1F21,301": 7973, + "1F21,342": 7975, + "1F21,345": 8081, + "1F22,345": 8082, + "1F23,345": 8083, + "1F24,345": 8084, + "1F25,345": 8085, + "1F26,345": 8086, + "1F27,345": 8087, + "1F28,300": 7978, + "1F28,301": 7980, + "1F28,342": 7982, + "1F28,345": 8088, + "1F29,300": 7979, + "1F29,301": 7981, + "1F29,342": 7983, + "1F29,345": 8089, + "1F2A,345": 8090, + "1F2B,345": 8091, + "1F2C,345": 8092, + "1F2D,345": 8093, + "1F2E,345": 8094, + "1F2F,345": 8095, + "1F30,300": 7986, + "1F30,301": 7988, + "1F30,342": 7990, + "1F31,300": 7987, + "1F31,301": 7989, + "1F31,342": 7991, + "1F38,300": 7994, + "1F38,301": 7996, + "1F38,342": 7998, + "1F39,300": 7995, + "1F39,301": 7997, + "1F39,342": 7999, + "1F40,300": 8002, + "1F40,301": 8004, + "1F41,300": 8003, + "1F41,301": 8005, + "1F48,300": 8010, + "1F48,301": 8012, + "1F49,300": 8011, + "1F49,301": 8013, + "1F50,300": 8018, + "1F50,301": 8020, + "1F50,342": 8022, + "1F51,300": 8019, + "1F51,301": 8021, + "1F51,342": 8023, + "1F59,300": 8027, + "1F59,301": 8029, + "1F59,342": 8031, + "1F60,300": 8034, + "1F60,301": 8036, + "1F60,342": 8038, + "1F60,345": 8096, + "1F61,300": 8035, + "1F61,301": 8037, + "1F61,342": 8039, + "1F61,345": 8097, + "1F62,345": 8098, + "1F63,345": 8099, + "1F64,345": 8100, + "1F65,345": 8101, + "1F66,345": 8102, + "1F67,345": 8103, + "1F68,300": 8042, + "1F68,301": 8044, + "1F68,342": 8046, + "1F68,345": 8104, + "1F69,300": 8043, + "1F69,301": 8045, + "1F69,342": 8047, + "1F69,345": 8105, + "1F6A,345": 8106, + "1F6B,345": 8107, + "1F6C,345": 8108, + "1F6D,345": 8109, + "1F6E,345": 8110, + "1F6F,345": 8111, + "1F70,345": 8114, + "1F74,345": 8130, + "1F7C,345": 8178, + "1FB6,345": 8119, + "1FBF,300": 8141, + "1FBF,301": 8142, + "1FBF,342": 8143, + "1FC6,345": 8135, + "1FF6,345": 8183, + "1FFE,300": 8157, + "1FFE,301": 8158, + "1FFE,342": 8159, + "2190,338": 8602, + "2192,338": 8603, + "2194,338": 8622, + "21D0,338": 8653, + "21D2,338": 8655, + "21D4,338": 8654, + "2203,338": 8708, + "2208,338": 8713, + "220B,338": 8716, + "2223,338": 8740, + "2225,338": 8742, + "223C,338": 8769, + "2243,338": 8772, + "2245,338": 8775, + "2248,338": 8777, + "224D,338": 8813, + "226,304": 480, + "2261,338": 8802, + "2264,338": 8816, + "2265,338": 8817, + "227,304": 481, + "2272,338": 8820, + "2273,338": 8821, + "2276,338": 8824, + "2277,338": 8825, + "227A,338": 8832, + "227B,338": 8833, + "227C,338": 8928, + "227D,338": 8929, + "228,306": 7708, + "2282,338": 8836, + "2283,338": 8837, + "2286,338": 8840, + "2287,338": 8841, + "229,306": 7709, + "2291,338": 8930, + "2292,338": 8931, + "22A2,338": 8876, + "22A8,338": 8877, + "22A9,338": 8878, + "22AB,338": 8879, + "22B2,338": 8938, + "22B3,338": 8939, + "22B4,338": 8940, + "22B5,338": 8941, + "22E,304": 560, + "22F,304": 561, + "292,30C": 495, + "3046,3099": 12436, + "304B,3099": 12364, + "304D,3099": 12366, + "304F,3099": 12368, + "3051,3099": 12370, + "3053,3099": 12372, + "3055,3099": 12374, + "3057,3099": 12376, + "3059,3099": 12378, + "305B,3099": 12380, + "305D,3099": 12382, + "305F,3099": 12384, + "3061,3099": 12386, + "3064,3099": 12389, + "3066,3099": 12391, + "3068,3099": 12393, + "306F,3099": 12400, + "306F,309A": 12401, + "3072,3099": 12403, + "3072,309A": 12404, + "3075,3099": 12406, + "3075,309A": 12407, + "3078,3099": 12409, + "3078,309A": 12410, + "307B,3099": 12412, + "307B,309A": 12413, + "309D,3099": 12446, + "30A6,3099": 12532, + "30AB,3099": 12460, + "30AD,3099": 12462, + "30AF,3099": 12464, + "30B1,3099": 12466, + "30B3,3099": 12468, + "30B5,3099": 12470, + "30B7,3099": 12472, + "30B9,3099": 12474, + "30BB,3099": 12476, + "30BD,3099": 12478, + "30BF,3099": 12480, + "30C1,3099": 12482, + "30C4,3099": 12485, + "30C6,3099": 12487, + "30C8,3099": 12489, + "30CF,3099": 12496, + "30CF,309A": 12497, + "30D2,3099": 12499, + "30D2,309A": 12500, + "30D5,3099": 12502, + "30D5,309A": 12503, + "30D8,3099": 12505, + "30D8,309A": 12506, + "30DB,3099": 12508, + "30DB,309A": 12509, + "30EF,3099": 12535, + "30F0,3099": 12536, + "30F1,3099": 12537, + "30F2,3099": 12538, + "30FD,3099": 12542, + "391,300": 8122, + "391,301": 902, + "391,304": 8121, + "391,306": 8120, + "391,313": 7944, + "391,314": 7945, + "391,345": 8124, + "395,300": 8136, + "395,301": 904, + "395,313": 7960, + "395,314": 7961, + "397,300": 8138, + "397,301": 905, + "397,313": 7976, + "397,314": 7977, + "397,345": 8140, + "399,300": 8154, + "399,301": 906, + "399,304": 8153, + "399,306": 8152, + "399,308": 938, + "399,313": 7992, + "399,314": 7993, + "39F,300": 8184, + "39F,301": 908, + "39F,313": 8008, + "39F,314": 8009, + "3A1,314": 8172, + "3A5,300": 8170, + "3A5,301": 910, + "3A5,304": 8169, + "3A5,306": 8168, + "3A5,308": 939, + "3A5,314": 8025, + "3A9,300": 8186, + "3A9,301": 911, + "3A9,313": 8040, + "3A9,314": 8041, + "3A9,345": 8188, + "3AC,345": 8116, + "3AE,345": 8132, + "3B1,300": 8048, + "3B1,301": 940, + "3B1,304": 8113, + "3B1,306": 8112, + "3B1,313": 7936, + "3B1,314": 7937, + "3B1,342": 8118, + "3B1,345": 8115, + "3B5,300": 8050, + "3B5,301": 941, + "3B5,313": 7952, + "3B5,314": 7953, + "3B7,300": 8052, + "3B7,301": 942, + "3B7,313": 7968, + "3B7,314": 7969, + "3B7,342": 8134, + "3B7,345": 8131, + "3B9,300": 8054, + "3B9,301": 943, + "3B9,304": 8145, + "3B9,306": 8144, + "3B9,308": 970, + "3B9,313": 7984, + "3B9,314": 7985, + "3B9,342": 8150, + "3BF,300": 8056, + "3BF,301": 972, + "3BF,313": 8000, + "3BF,314": 8001, + "3C,338": 8814, + "3C1,313": 8164, + "3C1,314": 8165, + "3C5,300": 8058, + "3C5,301": 973, + "3C5,304": 8161, + "3C5,306": 8160, + "3C5,308": 971, + "3C5,313": 8016, + "3C5,314": 8017, + "3C5,342": 8166, + "3C9,300": 8060, + "3C9,301": 974, + "3C9,313": 8032, + "3C9,314": 8033, + "3C9,342": 8182, + "3C9,345": 8179, + "3CA,300": 8146, + "3CA,301": 912, + "3CA,342": 8151, + "3CB,300": 8162, + "3CB,301": 944, + "3CB,342": 8167, + "3CE,345": 8180, + "3D,338": 8800, + "3D2,301": 979, + "3D2,308": 980, + "3E,338": 8815, + "406,308": 1031, + "41,300": 192, + "41,301": 193, + "41,302": 194, + "41,303": 195, + "41,304": 256, + "41,306": 258, + "41,307": 550, + "41,308": 196, + "41,309": 7842, + "41,30A": 197, + "41,30C": 461, + "41,30F": 512, + "41,311": 514, + "41,323": 7840, + "41,325": 7680, + "41,328": 260, + "410,306": 1232, + "410,308": 1234, + "413,301": 1027, + "415,300": 1024, + "415,306": 1238, + "415,308": 1025, + "416,306": 1217, + "416,308": 1244, + "417,308": 1246, + "418,300": 1037, + "418,304": 1250, + "418,306": 1049, + "418,308": 1252, + "41A,301": 1036, + "41E,308": 1254, + "42,307": 7682, + "42,323": 7684, + "42,331": 7686, + "423,304": 1262, + "423,306": 1038, + "423,308": 1264, + "423,30B": 1266, + "427,308": 1268, + "42B,308": 1272, + "42D,308": 1260, + "43,301": 262, + "43,302": 264, + "43,307": 266, + "43,30C": 268, + "43,327": 199, + "430,306": 1233, + "430,308": 1235, + "433,301": 1107, + "435,300": 1104, + "435,306": 1239, + "435,308": 1105, + "436,306": 1218, + "436,308": 1245, + "437,308": 1247, + "438,300": 1117, + "438,304": 1251, + "438,306": 1081, + "438,308": 1253, + "43A,301": 1116, + "43E,308": 1255, + "44,307": 7690, + "44,30C": 270, + "44,323": 7692, + "44,327": 7696, + "44,32D": 7698, + "44,331": 7694, + "443,304": 1263, + "443,306": 1118, + "443,308": 1265, + "443,30B": 1267, + "447,308": 1269, + "44B,308": 1273, + "44D,308": 1261, + "45,300": 200, + "45,301": 201, + "45,302": 202, + "45,303": 7868, + "45,304": 274, + "45,306": 276, + "45,307": 278, + "45,308": 203, + "45,309": 7866, + "45,30C": 282, + "45,30F": 516, + "45,311": 518, + "45,323": 7864, + "45,327": 552, + "45,328": 280, + "45,32D": 7704, + "45,330": 7706, + "456,308": 1111, + "46,307": 7710, + "47,301": 500, + "47,302": 284, + "47,304": 7712, + "47,306": 286, + "47,307": 288, + "47,30C": 486, + "47,327": 290, + "474,30F": 1142, + "475,30F": 1143, + "48,302": 292, + "48,307": 7714, + "48,308": 7718, + "48,30C": 542, + "48,323": 7716, + "48,327": 7720, + "48,32E": 7722, + "49,300": 204, + "49,301": 205, + "49,302": 206, + "49,303": 296, + "49,304": 298, + "49,306": 300, + "49,307": 304, + "49,308": 207, + "49,309": 7880, + "49,30C": 463, + "49,30F": 520, + "49,311": 522, + "49,323": 7882, + "49,328": 302, + "49,330": 7724, + "4A,302": 308, + "4B,301": 7728, + "4B,30C": 488, + "4B,323": 7730, + "4B,327": 310, + "4B,331": 7732, + "4C,301": 313, + "4C,30C": 317, + "4C,323": 7734, + "4C,327": 315, + "4C,32D": 7740, + "4C,331": 7738, + "4D,301": 7742, + "4D,307": 7744, + "4D,323": 7746, + "4D8,308": 1242, + "4D9,308": 1243, + "4E,300": 504, + "4E,301": 323, + "4E,303": 209, + "4E,307": 7748, + "4E,30C": 327, + "4E,323": 7750, + "4E,327": 325, + "4E,32D": 7754, + "4E,331": 7752, + "4E8,308": 1258, + "4E9,308": 1259, + "4F,300": 210, + "4F,301": 211, + "4F,302": 212, + "4F,303": 213, + "4F,304": 332, + "4F,306": 334, + "4F,307": 558, + "4F,308": 214, + "4F,309": 7886, + "4F,30B": 336, + "4F,30C": 465, + "4F,30F": 524, + "4F,311": 526, + "4F,31B": 416, + "4F,323": 7884, + "4F,328": 490, + "50,301": 7764, + "50,307": 7766, + "52,301": 340, + "52,307": 7768, + "52,30C": 344, + "52,30F": 528, + "52,311": 530, + "52,323": 7770, + "52,327": 342, + "52,331": 7774, + "53,301": 346, + "53,302": 348, + "53,307": 7776, + "53,30C": 352, + "53,323": 7778, + "53,326": 536, + "53,327": 350, + "54,307": 7786, + "54,30C": 356, + "54,323": 7788, + "54,326": 538, + "54,327": 354, + "54,32D": 7792, + "54,331": 7790, + "55,300": 217, + "55,301": 218, + "55,302": 219, + "55,303": 360, + "55,304": 362, + "55,306": 364, + "55,308": 220, + "55,309": 7910, + "55,30A": 366, + "55,30B": 368, + "55,30C": 467, + "55,30F": 532, + "55,311": 534, + "55,31B": 431, + "55,323": 7908, + "55,324": 7794, + "55,328": 370, + "55,32D": 7798, + "55,330": 7796, + "56,303": 7804, + "56,323": 7806, + "57,300": 7808, + "57,301": 7810, + "57,302": 372, + "57,307": 7814, + "57,308": 7812, + "57,323": 7816, + "58,307": 7818, + "58,308": 7820, + "59,300": 7922, + "59,301": 221, + "59,302": 374, + "59,303": 7928, + "59,304": 562, + "59,307": 7822, + "59,308": 376, + "59,309": 7926, + "59,323": 7924, + "5A,301": 377, + "5A,302": 7824, + "5A,307": 379, + "5A,30C": 381, + "5A,323": 7826, + "5A,331": 7828, + "61,300": 224, + "61,301": 225, + "61,302": 226, + "61,303": 227, + "61,304": 257, + "61,306": 259, + "61,307": 551, + "61,308": 228, + "61,309": 7843, + "61,30A": 229, + "61,30C": 462, + "61,30F": 513, + "61,311": 515, + "61,323": 7841, + "61,325": 7681, + "61,328": 261, + "62,307": 7683, + "62,323": 7685, + "62,331": 7687, + "627,653": 1570, + "627,654": 1571, + "627,655": 1573, + "63,301": 263, + "63,302": 265, + "63,307": 267, + "63,30C": 269, + "63,327": 231, + "64,307": 7691, + "64,30C": 271, + "64,323": 7693, + "64,327": 7697, + "64,32D": 7699, + "64,331": 7695, + "648,654": 1572, + "64A,654": 1574, + "65,300": 232, + "65,301": 233, + "65,302": 234, + "65,303": 7869, + "65,304": 275, + "65,306": 277, + "65,307": 279, + "65,308": 235, + "65,309": 7867, + "65,30C": 283, + "65,30F": 517, + "65,311": 519, + "65,323": 7865, + "65,327": 553, + "65,328": 281, + "65,32D": 7705, + "65,330": 7707, + "66,307": 7711, + "67,301": 501, + "67,302": 285, + "67,304": 7713, + "67,306": 287, + "67,307": 289, + "67,30C": 487, + "67,327": 291, + "68,302": 293, + "68,307": 7715, + "68,308": 7719, + "68,30C": 543, + "68,323": 7717, + "68,327": 7721, + "68,32E": 7723, + "68,331": 7830, + "69,300": 236, + "69,301": 237, + "69,302": 238, + "69,303": 297, + "69,304": 299, + "69,306": 301, + "69,308": 239, + "69,309": 7881, + "69,30C": 464, + "69,30F": 521, + "69,311": 523, + "69,323": 7883, + "69,328": 303, + "69,330": 7725, + "6A,302": 309, + "6A,30C": 496, + "6B,301": 7729, + "6B,30C": 489, + "6B,323": 7731, + "6B,327": 311, + "6B,331": 7733, + "6C,301": 314, + "6C,30C": 318, + "6C,323": 7735, + "6C,327": 316, + "6C,32D": 7741, + "6C,331": 7739, + "6C1,654": 1730, + "6D,301": 7743, + "6D,307": 7745, + "6D,323": 7747, + "6D2,654": 1747, + "6D5,654": 1728, + "6E,300": 505, + "6E,301": 324, + "6E,303": 241, + "6E,307": 7749, + "6E,30C": 328, + "6E,323": 7751, + "6E,327": 326, + "6E,32D": 7755, + "6E,331": 7753, + "6F,300": 242, + "6F,301": 243, + "6F,302": 244, + "6F,303": 245, + "6F,304": 333, + "6F,306": 335, + "6F,307": 559, + "6F,308": 246, + "6F,309": 7887, + "6F,30B": 337, + "6F,30C": 466, + "6F,30F": 525, + "6F,311": 527, + "6F,31B": 417, + "6F,323": 7885, + "6F,328": 491, + "70,301": 7765, + "70,307": 7767, + "72,301": 341, + "72,307": 7769, + "72,30C": 345, + "72,30F": 529, + "72,311": 531, + "72,323": 7771, + "72,327": 343, + "72,331": 7775, + "73,301": 347, + "73,302": 349, + "73,307": 7777, + "73,30C": 353, + "73,323": 7779, + "73,326": 537, + "73,327": 351, + "74,307": 7787, + "74,308": 7831, + "74,30C": 357, + "74,323": 7789, + "74,326": 539, + "74,327": 355, + "74,32D": 7793, + "74,331": 7791, + "75,300": 249, + "75,301": 250, + "75,302": 251, + "75,303": 361, + "75,304": 363, + "75,306": 365, + "75,308": 252, + "75,309": 7911, + "75,30A": 367, + "75,30B": 369, + "75,30C": 468, + "75,30F": 533, + "75,311": 535, + "75,31B": 432, + "75,323": 7909, + "75,324": 7795, + "75,328": 371, + "75,32D": 7799, + "75,330": 7797, + "76,303": 7805, + "76,323": 7807, + "77,300": 7809, + "77,301": 7811, + "77,302": 373, + "77,307": 7815, + "77,308": 7813, + "77,30A": 7832, + "77,323": 7817, + "78,307": 7819, + "78,308": 7821, + "79,300": 7923, + "79,301": 253, + "79,302": 375, + "79,303": 7929, + "79,304": 563, + "79,307": 7823, + "79,308": 255, + "79,309": 7927, + "79,30A": 7833, + "79,323": 7925, + "7A,301": 378, + "7A,302": 7825, + "7A,307": 380, + "7A,30C": 382, + "7A,323": 7827, + "7A,331": 7829, + "928,93C": 2345, + "930,93C": 2353, + "933,93C": 2356, + "9C7,9BE": 2507, + "9C7,9D7": 2508, + "A8,300": 8173, + "A8,301": 901, + "A8,342": 8129, + "B47,B3E": 2891, + "B47,B56": 2888, + "B47,B57": 2892, + "B92,BD7": 2964, + "BC6,BBE": 3018, + "BC6,BD7": 3020, + "BC7,BBE": 3019, + "C2,300": 7846, + "C2,301": 7844, + "C2,303": 7850, + "C2,309": 7848, + "C4,304": 478, + "C46,C56": 3144, + "C5,301": 506, + "C6,301": 508, + "C6,304": 482, + "C7,301": 7688, + "CA,300": 7872, + "CA,301": 7870, + "CA,303": 7876, + "CA,309": 7874, + "CBF,CD5": 3264, + "CC6,CC2": 3274, + "CC6,CD5": 3271, + "CC6,CD6": 3272, + "CCA,CD5": 3275, + "CF,301": 7726, + "D4,300": 7890, + "D4,301": 7888, + "D4,303": 7894, + "D4,309": 7892, + "D46,D3E": 3402, + "D46,D57": 3404, + "D47,D3E": 3403, + "D5,301": 7756, + "D5,304": 556, + "D5,308": 7758, + "D6,304": 554, + "D8,301": 510, + "DC,300": 475, + "DC,301": 471, + "DC,304": 469, + "DC,30C": 473, + "DD9,DCA": 3546, + "DD9,DCF": 3548, + "DD9,DDF": 3550, + "DDC,DCA": 3549, + "E2,300": 7847, + "E2,301": 7845, + "E2,303": 7851, + "E2,309": 7849, + "E4,304": 479, + "E5,301": 507, + "E6,301": 509, + "E6,304": 483, + "E7,301": 7689, + "EA,300": 7873, + "EA,301": 7871, + "EA,303": 7877, + "EA,309": 7875, + "EF,301": 7727, + "F4,300": 7891, + "F4,301": 7889, + "F4,303": 7895, + "F4,309": 7893, + "F5,301": 7757, + "F5,304": 557, + "F5,308": 7759, + "F6,304": 555, + "F8,301": 511, + "FC,300": 476, + "FC,301": 472, + "FC,304": 470, + "FC,30C": 474 + }, + "decomposition": { + "00C0": [65, 768], + "00C1": [65, 769], + "00C2": [65, 770], + "00C3": [65, 771], + "00C4": [65, 776], + "00C5": [65, 778], + "00C7": [67, 807], + "00C8": [69, 768], + "00C9": [69, 769], + "00CA": [69, 770], + "00CB": [69, 776], + "00CC": [73, 768], + "00CD": [73, 769], + "00CE": [73, 770], + "00CF": [73, 776], + "00D1": [78, 771], + "00D2": [79, 768], + "00D3": [79, 769], + "00D4": [79, 770], + "00D5": [79, 771], + "00D6": [79, 776], + "00D9": [85, 768], + "00DA": [85, 769], + "00DB": [85, 770], + "00DC": [85, 776], + "00DD": [89, 769], + "00E0": [97, 768], + "00E1": [97, 769], + "00E2": [97, 770], + "00E3": [97, 771], + "00E4": [97, 776], + "00E5": [97, 778], + "00E7": [99, 807], + "00E8": [101, 768], + "00E9": [101, 769], + "00EA": [101, 770], + "00EB": [101, 776], + "00EC": [105, 768], + "00ED": [105, 769], + "00EE": [105, 770], + "00EF": [105, 776], + "00F1": [110, 771], + "00F2": [111, 768], + "00F3": [111, 769], + "00F4": [111, 770], + "00F5": [111, 771], + "00F6": [111, 776], + "00F9": [117, 768], + "00FA": [117, 769], + "00FB": [117, 770], + "00FC": [117, 776], + "00FD": [121, 769], + "00FF": [121, 776], + "0100": [65, 772], + "0101": [97, 772], + "0102": [65, 774], + "0103": [97, 774], + "0104": [65, 808], + "0105": [97, 808], + "0106": [67, 769], + "0107": [99, 769], + "0108": [67, 770], + "0109": [99, 770], + "010A": [67, 775], + "010B": [99, 775], + "010C": [67, 780], + "010D": [99, 780], + "010E": [68, 780], + "010F": [100, 780], + "0112": [69, 772], + "0113": [101, 772], + "0114": [69, 774], + "0115": [101, 774], + "0116": [69, 775], + "0117": [101, 775], + "0118": [69, 808], + "0119": [101, 808], + "011A": [69, 780], + "011B": [101, 780], + "011C": [71, 770], + "011D": [103, 770], + "011E": [71, 774], + "011F": [103, 774], + "0120": [71, 775], + "0121": [103, 775], + "0122": [71, 807], + "0123": [103, 807], + "0124": [72, 770], + "0125": [104, 770], + "0128": [73, 771], + "0129": [105, 771], + "012A": [73, 772], + "012B": [105, 772], + "012C": [73, 774], + "012D": [105, 774], + "012E": [73, 808], + "012F": [105, 808], + "0130": [73, 775], + "0134": [74, 770], + "0135": [106, 770], + "0136": [75, 807], + "0137": [107, 807], + "0139": [76, 769], + "013A": [108, 769], + "013B": [76, 807], + "013C": [108, 807], + "013D": [76, 780], + "013E": [108, 780], + "0143": [78, 769], + "0144": [110, 769], + "0145": [78, 807], + "0146": [110, 807], + "0147": [78, 780], + "0148": [110, 780], + "014C": [79, 772], + "014D": [111, 772], + "014E": [79, 774], + "014F": [111, 774], + "0150": [79, 779], + "0151": [111, 779], + "0154": [82, 769], + "0155": [114, 769], + "0156": [82, 807], + "0157": [114, 807], + "0158": [82, 780], + "0159": [114, 780], + "015A": [83, 769], + "015B": [115, 769], + "015C": [83, 770], + "015D": [115, 770], + "015E": [83, 807], + "015F": [115, 807], + "0160": [83, 780], + "0161": [115, 780], + "0162": [84, 807], + "0163": [116, 807], + "0164": [84, 780], + "0165": [116, 780], + "0168": [85, 771], + "0169": [117, 771], + "016A": [85, 772], + "016B": [117, 772], + "016C": [85, 774], + "016D": [117, 774], + "016E": [85, 778], + "016F": [117, 778], + "0170": [85, 779], + "0171": [117, 779], + "0172": [85, 808], + "0173": [117, 808], + "0174": [87, 770], + "0175": [119, 770], + "0176": [89, 770], + "0177": [121, 770], + "0178": [89, 776], + "0179": [90, 769], + "017A": [122, 769], + "017B": [90, 775], + "017C": [122, 775], + "017D": [90, 780], + "017E": [122, 780], + "01A0": [79, 795], + "01A1": [111, 795], + "01AF": [85, 795], + "01B0": [117, 795], + "01CD": [65, 780], + "01CE": [97, 780], + "01CF": [73, 780], + "01D0": [105, 780], + "01D1": [79, 780], + "01D2": [111, 780], + "01D3": [85, 780], + "01D4": [117, 780], + "01D5": [220, 772], + "01D6": [252, 772], + "01D7": [220, 769], + "01D8": [252, 769], + "01D9": [220, 780], + "01DA": [252, 780], + "01DB": [220, 768], + "01DC": [252, 768], + "01DE": [196, 772], + "01DF": [228, 772], + "01E0": [550, 772], + "01E1": [551, 772], + "01E2": [198, 772], + "01E3": [230, 772], + "01E6": [71, 780], + "01E7": [103, 780], + "01E8": [75, 780], + "01E9": [107, 780], + "01EA": [79, 808], + "01EB": [111, 808], + "01EC": [490, 772], + "01ED": [491, 772], + "01EE": [439, 780], + "01EF": [658, 780], + "01F0": [106, 780], + "01F4": [71, 769], + "01F5": [103, 769], + "01F8": [78, 768], + "01F9": [110, 768], + "01FA": [197, 769], + "01FB": [229, 769], + "01FC": [198, 769], + "01FD": [230, 769], + "01FE": [216, 769], + "01FF": [248, 769], + "0200": [65, 783], + "0201": [97, 783], + "0202": [65, 785], + "0203": [97, 785], + "0204": [69, 783], + "0205": [101, 783], + "0206": [69, 785], + "0207": [101, 785], + "0208": [73, 783], + "0209": [105, 783], + "020A": [73, 785], + "020B": [105, 785], + "020C": [79, 783], + "020D": [111, 783], + "020E": [79, 785], + "020F": [111, 785], + "0210": [82, 783], + "0211": [114, 783], + "0212": [82, 785], + "0213": [114, 785], + "0214": [85, 783], + "0215": [117, 783], + "0216": [85, 785], + "0217": [117, 785], + "0218": [83, 806], + "0219": [115, 806], + "021A": [84, 806], + "021B": [116, 806], + "021E": [72, 780], + "021F": [104, 780], + "0226": [65, 775], + "0227": [97, 775], + "0228": [69, 807], + "0229": [101, 807], + "022A": [214, 772], + "022B": [246, 772], + "022C": [213, 772], + "022D": [245, 772], + "022E": [79, 775], + "022F": [111, 775], + "0230": [558, 772], + "0231": [559, 772], + "0232": [89, 772], + "0233": [121, 772], + "0340": [768], + "0341": [769], + "0343": [787], + "0344": [776, 769], + "0374": [697], + "037E": [59], + "0385": [168, 769], + "0386": [913, 769], + "0387": [183], + "0388": [917, 769], + "0389": [919, 769], + "038A": [921, 769], + "038C": [927, 769], + "038E": [933, 769], + "038F": [937, 769], + "0390": [970, 769], + "03AA": [921, 776], + "03AB": [933, 776], + "03AC": [945, 769], + "03AD": [949, 769], + "03AE": [951, 769], + "03AF": [953, 769], + "03B0": [971, 769], + "03CA": [953, 776], + "03CB": [965, 776], + "03CC": [959, 769], + "03CD": [965, 769], + "03CE": [969, 769], + "03D3": [978, 769], + "03D4": [978, 776], + "0400": [1045, 768], + "0401": [1045, 776], + "0403": [1043, 769], + "0407": [1030, 776], + "040C": [1050, 769], + "040D": [1048, 768], + "040E": [1059, 774], + "0419": [1048, 774], + "0439": [1080, 774], + "0450": [1077, 768], + "0451": [1077, 776], + "0453": [1075, 769], + "0457": [1110, 776], + "045C": [1082, 769], + "045D": [1080, 768], + "045E": [1091, 774], + "0476": [1140, 783], + "0477": [1141, 783], + "04C1": [1046, 774], + "04C2": [1078, 774], + "04D0": [1040, 774], + "04D1": [1072, 774], + "04D2": [1040, 776], + "04D3": [1072, 776], + "04D6": [1045, 774], + "04D7": [1077, 774], + "04DA": [1240, 776], + "04DB": [1241, 776], + "04DC": [1046, 776], + "04DD": [1078, 776], + "04DE": [1047, 776], + "04DF": [1079, 776], + "04E2": [1048, 772], + "04E3": [1080, 772], + "04E4": [1048, 776], + "04E5": [1080, 776], + "04E6": [1054, 776], + "04E7": [1086, 776], + "04EA": [1256, 776], + "04EB": [1257, 776], + "04EC": [1069, 776], + "04ED": [1101, 776], + "04EE": [1059, 772], + "04EF": [1091, 772], + "04F0": [1059, 776], + "04F1": [1091, 776], + "04F2": [1059, 779], + "04F3": [1091, 779], + "04F4": [1063, 776], + "04F5": [1095, 776], + "04F8": [1067, 776], + "04F9": [1099, 776], + "0622": [1575, 1619], + "0623": [1575, 1620], + "0624": [1608, 1620], + "0625": [1575, 1621], + "0626": [1610, 1620], + "06C0": [1749, 1620], + "06C2": [1729, 1620], + "06D3": [1746, 1620], + "0929": [2344, 2364], + "0931": [2352, 2364], + "0934": [2355, 2364], + "0958": [2325, 2364], + "0959": [2326, 2364], + "095A": [2327, 2364], + "095B": [2332, 2364], + "095C": [2337, 2364], + "095D": [2338, 2364], + "095E": [2347, 2364], + "095F": [2351, 2364], + "09CB": [2503, 2494], + "09CC": [2503, 2519], + "09DC": [2465, 2492], + "09DD": [2466, 2492], + "09DF": [2479, 2492], + "0A33": [2610, 2620], + "0A36": [2616, 2620], + "0A59": [2582, 2620], + "0A5A": [2583, 2620], + "0A5B": [2588, 2620], + "0A5E": [2603, 2620], + "0B48": [2887, 2902], + "0B4B": [2887, 2878], + "0B4C": [2887, 2903], + "0B5C": [2849, 2876], + "0B5D": [2850, 2876], + "0B94": [2962, 3031], + "0BCA": [3014, 3006], + "0BCB": [3015, 3006], + "0BCC": [3014, 3031], + "0C48": [3142, 3158], + "0CC0": [3263, 3285], + "0CC7": [3270, 3285], + "0CC8": [3270, 3286], + "0CCA": [3270, 3266], + "0CCB": [3274, 3285], + "0D4A": [3398, 3390], + "0D4B": [3399, 3390], + "0D4C": [3398, 3415], + "0DDA": [3545, 3530], + "0DDC": [3545, 3535], + "0DDD": [3548, 3530], + "0DDE": [3545, 3551], + "0F43": [3906, 4023], + "0F4D": [3916, 4023], + "0F52": [3921, 4023], + "0F57": [3926, 4023], + "0F5C": [3931, 4023], + "0F69": [3904, 4021], + "0F73": [3953, 3954], + "0F75": [3953, 3956], + "0F76": [4018, 3968], + "0F78": [4019, 3968], + "0F81": [3953, 3968], + "0F93": [3986, 4023], + "0F9D": [3996, 4023], + "0FA2": [4001, 4023], + "0FA7": [4006, 4023], + "0FAC": [4011, 4023], + "0FB9": [3984, 4021], + "1026": [4133, 4142], + "1109A": [69785, 69818], + "1109C": [69787, 69818], + "110AB": [69797, 69818], + "1112E": [69937, 69927], + "1112F": [69938, 69927], + "1134B": [70471, 70462], + "1134C": [70471, 70487], + "114BB": [70841, 70842], + "114BC": [70841, 70832], + "114BE": [70841, 70845], + "115BA": [71096, 71087], + "115BB": [71097, 71087], + "11938": [71989, 71984], + "1B06": [6917, 6965], + "1B08": [6919, 6965], + "1B0A": [6921, 6965], + "1B0C": [6923, 6965], + "1B0E": [6925, 6965], + "1B12": [6929, 6965], + "1B3B": [6970, 6965], + "1B3D": [6972, 6965], + "1B40": [6974, 6965], + "1B41": [6975, 6965], + "1B43": [6978, 6965], + "1D15E": [119127, 119141], + "1D15F": [119128, 119141], + "1D160": [119135, 119150], + "1D161": [119135, 119151], + "1D162": [119135, 119152], + "1D163": [119135, 119153], + "1D164": [119135, 119154], + "1D1BB": [119225, 119141], + "1D1BC": [119226, 119141], + "1D1BD": [119227, 119150], + "1D1BE": [119228, 119150], + "1D1BF": [119227, 119151], + "1D1C0": [119228, 119151], + "1E00": [65, 805], + "1E01": [97, 805], + "1E02": [66, 775], + "1E03": [98, 775], + "1E04": [66, 803], + "1E05": [98, 803], + "1E06": [66, 817], + "1E07": [98, 817], + "1E08": [199, 769], + "1E09": [231, 769], + "1E0A": [68, 775], + "1E0B": [100, 775], + "1E0C": [68, 803], + "1E0D": [100, 803], + "1E0E": [68, 817], + "1E0F": [100, 817], + "1E10": [68, 807], + "1E11": [100, 807], + "1E12": [68, 813], + "1E13": [100, 813], + "1E14": [274, 768], + "1E15": [275, 768], + "1E16": [274, 769], + "1E17": [275, 769], + "1E18": [69, 813], + "1E19": [101, 813], + "1E1A": [69, 816], + "1E1B": [101, 816], + "1E1C": [552, 774], + "1E1D": [553, 774], + "1E1E": [70, 775], + "1E1F": [102, 775], + "1E20": [71, 772], + "1E21": [103, 772], + "1E22": [72, 775], + "1E23": [104, 775], + "1E24": [72, 803], + "1E25": [104, 803], + "1E26": [72, 776], + "1E27": [104, 776], + "1E28": [72, 807], + "1E29": [104, 807], + "1E2A": [72, 814], + "1E2B": [104, 814], + "1E2C": [73, 816], + "1E2D": [105, 816], + "1E2E": [207, 769], + "1E2F": [239, 769], + "1E30": [75, 769], + "1E31": [107, 769], + "1E32": [75, 803], + "1E33": [107, 803], + "1E34": [75, 817], + "1E35": [107, 817], + "1E36": [76, 803], + "1E37": [108, 803], + "1E38": [7734, 772], + "1E39": [7735, 772], + "1E3A": [76, 817], + "1E3B": [108, 817], + "1E3C": [76, 813], + "1E3D": [108, 813], + "1E3E": [77, 769], + "1E3F": [109, 769], + "1E40": [77, 775], + "1E41": [109, 775], + "1E42": [77, 803], + "1E43": [109, 803], + "1E44": [78, 775], + "1E45": [110, 775], + "1E46": [78, 803], + "1E47": [110, 803], + "1E48": [78, 817], + "1E49": [110, 817], + "1E4A": [78, 813], + "1E4B": [110, 813], + "1E4C": [213, 769], + "1E4D": [245, 769], + "1E4E": [213, 776], + "1E4F": [245, 776], + "1E50": [332, 768], + "1E51": [333, 768], + "1E52": [332, 769], + "1E53": [333, 769], + "1E54": [80, 769], + "1E55": [112, 769], + "1E56": [80, 775], + "1E57": [112, 775], + "1E58": [82, 775], + "1E59": [114, 775], + "1E5A": [82, 803], + "1E5B": [114, 803], + "1E5C": [7770, 772], + "1E5D": [7771, 772], + "1E5E": [82, 817], + "1E5F": [114, 817], + "1E60": [83, 775], + "1E61": [115, 775], + "1E62": [83, 803], + "1E63": [115, 803], + "1E64": [346, 775], + "1E65": [347, 775], + "1E66": [352, 775], + "1E67": [353, 775], + "1E68": [7778, 775], + "1E69": [7779, 775], + "1E6A": [84, 775], + "1E6B": [116, 775], + "1E6C": [84, 803], + "1E6D": [116, 803], + "1E6E": [84, 817], + "1E6F": [116, 817], + "1E70": [84, 813], + "1E71": [116, 813], + "1E72": [85, 804], + "1E73": [117, 804], + "1E74": [85, 816], + "1E75": [117, 816], + "1E76": [85, 813], + "1E77": [117, 813], + "1E78": [360, 769], + "1E79": [361, 769], + "1E7A": [362, 776], + "1E7B": [363, 776], + "1E7C": [86, 771], + "1E7D": [118, 771], + "1E7E": [86, 803], + "1E7F": [118, 803], + "1E80": [87, 768], + "1E81": [119, 768], + "1E82": [87, 769], + "1E83": [119, 769], + "1E84": [87, 776], + "1E85": [119, 776], + "1E86": [87, 775], + "1E87": [119, 775], + "1E88": [87, 803], + "1E89": [119, 803], + "1E8A": [88, 775], + "1E8B": [120, 775], + "1E8C": [88, 776], + "1E8D": [120, 776], + "1E8E": [89, 775], + "1E8F": [121, 775], + "1E90": [90, 770], + "1E91": [122, 770], + "1E92": [90, 803], + "1E93": [122, 803], + "1E94": [90, 817], + "1E95": [122, 817], + "1E96": [104, 817], + "1E97": [116, 776], + "1E98": [119, 778], + "1E99": [121, 778], + "1E9B": [383, 775], + "1EA0": [65, 803], + "1EA1": [97, 803], + "1EA2": [65, 777], + "1EA3": [97, 777], + "1EA4": [194, 769], + "1EA5": [226, 769], + "1EA6": [194, 768], + "1EA7": [226, 768], + "1EA8": [194, 777], + "1EA9": [226, 777], + "1EAA": [194, 771], + "1EAB": [226, 771], + "1EAC": [7840, 770], + "1EAD": [7841, 770], + "1EAE": [258, 769], + "1EAF": [259, 769], + "1EB0": [258, 768], + "1EB1": [259, 768], + "1EB2": [258, 777], + "1EB3": [259, 777], + "1EB4": [258, 771], + "1EB5": [259, 771], + "1EB6": [7840, 774], + "1EB7": [7841, 774], + "1EB8": [69, 803], + "1EB9": [101, 803], + "1EBA": [69, 777], + "1EBB": [101, 777], + "1EBC": [69, 771], + "1EBD": [101, 771], + "1EBE": [202, 769], + "1EBF": [234, 769], + "1EC0": [202, 768], + "1EC1": [234, 768], + "1EC2": [202, 777], + "1EC3": [234, 777], + "1EC4": [202, 771], + "1EC5": [234, 771], + "1EC6": [7864, 770], + "1EC7": [7865, 770], + "1EC8": [73, 777], + "1EC9": [105, 777], + "1ECA": [73, 803], + "1ECB": [105, 803], + "1ECC": [79, 803], + "1ECD": [111, 803], + "1ECE": [79, 777], + "1ECF": [111, 777], + "1ED0": [212, 769], + "1ED1": [244, 769], + "1ED2": [212, 768], + "1ED3": [244, 768], + "1ED4": [212, 777], + "1ED5": [244, 777], + "1ED6": [212, 771], + "1ED7": [244, 771], + "1ED8": [7884, 770], + "1ED9": [7885, 770], + "1EDA": [416, 769], + "1EDB": [417, 769], + "1EDC": [416, 768], + "1EDD": [417, 768], + "1EDE": [416, 777], + "1EDF": [417, 777], + "1EE0": [416, 771], + "1EE1": [417, 771], + "1EE2": [416, 803], + "1EE3": [417, 803], + "1EE4": [85, 803], + "1EE5": [117, 803], + "1EE6": [85, 777], + "1EE7": [117, 777], + "1EE8": [431, 769], + "1EE9": [432, 769], + "1EEA": [431, 768], + "1EEB": [432, 768], + "1EEC": [431, 777], + "1EED": [432, 777], + "1EEE": [431, 771], + "1EEF": [432, 771], + "1EF0": [431, 803], + "1EF1": [432, 803], + "1EF2": [89, 768], + "1EF3": [121, 768], + "1EF4": [89, 803], + "1EF5": [121, 803], + "1EF6": [89, 777], + "1EF7": [121, 777], + "1EF8": [89, 771], + "1EF9": [121, 771], + "1F00": [945, 787], + "1F01": [945, 788], + "1F02": [7936, 768], + "1F03": [7937, 768], + "1F04": [7936, 769], + "1F05": [7937, 769], + "1F06": [7936, 834], + "1F07": [7937, 834], + "1F08": [913, 787], + "1F09": [913, 788], + "1F0A": [7944, 768], + "1F0B": [7945, 768], + "1F0C": [7944, 769], + "1F0D": [7945, 769], + "1F0E": [7944, 834], + "1F0F": [7945, 834], + "1F10": [949, 787], + "1F11": [949, 788], + "1F12": [7952, 768], + "1F13": [7953, 768], + "1F14": [7952, 769], + "1F15": [7953, 769], + "1F18": [917, 787], + "1F19": [917, 788], + "1F1A": [7960, 768], + "1F1B": [7961, 768], + "1F1C": [7960, 769], + "1F1D": [7961, 769], + "1F20": [951, 787], + "1F21": [951, 788], + "1F22": [7968, 768], + "1F23": [7969, 768], + "1F24": [7968, 769], + "1F25": [7969, 769], + "1F26": [7968, 834], + "1F27": [7969, 834], + "1F28": [919, 787], + "1F29": [919, 788], + "1F2A": [7976, 768], + "1F2B": [7977, 768], + "1F2C": [7976, 769], + "1F2D": [7977, 769], + "1F2E": [7976, 834], + "1F2F": [7977, 834], + "1F30": [953, 787], + "1F31": [953, 788], + "1F32": [7984, 768], + "1F33": [7985, 768], + "1F34": [7984, 769], + "1F35": [7985, 769], + "1F36": [7984, 834], + "1F37": [7985, 834], + "1F38": [921, 787], + "1F39": [921, 788], + "1F3A": [7992, 768], + "1F3B": [7993, 768], + "1F3C": [7992, 769], + "1F3D": [7993, 769], + "1F3E": [7992, 834], + "1F3F": [7993, 834], + "1F40": [959, 787], + "1F41": [959, 788], + "1F42": [8000, 768], + "1F43": [8001, 768], + "1F44": [8000, 769], + "1F45": [8001, 769], + "1F48": [927, 787], + "1F49": [927, 788], + "1F4A": [8008, 768], + "1F4B": [8009, 768], + "1F4C": [8008, 769], + "1F4D": [8009, 769], + "1F50": [965, 787], + "1F51": [965, 788], + "1F52": [8016, 768], + "1F53": [8017, 768], + "1F54": [8016, 769], + "1F55": [8017, 769], + "1F56": [8016, 834], + "1F57": [8017, 834], + "1F59": [933, 788], + "1F5B": [8025, 768], + "1F5D": [8025, 769], + "1F5F": [8025, 834], + "1F60": [969, 787], + "1F61": [969, 788], + "1F62": [8032, 768], + "1F63": [8033, 768], + "1F64": [8032, 769], + "1F65": [8033, 769], + "1F66": [8032, 834], + "1F67": [8033, 834], + "1F68": [937, 787], + "1F69": [937, 788], + "1F6A": [8040, 768], + "1F6B": [8041, 768], + "1F6C": [8040, 769], + "1F6D": [8041, 769], + "1F6E": [8040, 834], + "1F6F": [8041, 834], + "1F70": [945, 768], + "1F71": [940], + "1F72": [949, 768], + "1F73": [941], + "1F74": [951, 768], + "1F75": [942], + "1F76": [953, 768], + "1F77": [943], + "1F78": [959, 768], + "1F79": [972], + "1F7A": [965, 768], + "1F7B": [973], + "1F7C": [969, 768], + "1F7D": [974], + "1F80": [7936, 837], + "1F81": [7937, 837], + "1F82": [7938, 837], + "1F83": [7939, 837], + "1F84": [7940, 837], + "1F85": [7941, 837], + "1F86": [7942, 837], + "1F87": [7943, 837], + "1F88": [7944, 837], + "1F89": [7945, 837], + "1F8A": [7946, 837], + "1F8B": [7947, 837], + "1F8C": [7948, 837], + "1F8D": [7949, 837], + "1F8E": [7950, 837], + "1F8F": [7951, 837], + "1F90": [7968, 837], + "1F91": [7969, 837], + "1F92": [7970, 837], + "1F93": [7971, 837], + "1F94": [7972, 837], + "1F95": [7973, 837], + "1F96": [7974, 837], + "1F97": [7975, 837], + "1F98": [7976, 837], + "1F99": [7977, 837], + "1F9A": [7978, 837], + "1F9B": [7979, 837], + "1F9C": [7980, 837], + "1F9D": [7981, 837], + "1F9E": [7982, 837], + "1F9F": [7983, 837], + "1FA0": [8032, 837], + "1FA1": [8033, 837], + "1FA2": [8034, 837], + "1FA3": [8035, 837], + "1FA4": [8036, 837], + "1FA5": [8037, 837], + "1FA6": [8038, 837], + "1FA7": [8039, 837], + "1FA8": [8040, 837], + "1FA9": [8041, 837], + "1FAA": [8042, 837], + "1FAB": [8043, 837], + "1FAC": [8044, 837], + "1FAD": [8045, 837], + "1FAE": [8046, 837], + "1FAF": [8047, 837], + "1FB0": [945, 774], + "1FB1": [945, 772], + "1FB2": [8048, 837], + "1FB3": [945, 837], + "1FB4": [940, 837], + "1FB6": [945, 834], + "1FB7": [8118, 837], + "1FB8": [913, 774], + "1FB9": [913, 772], + "1FBA": [913, 768], + "1FBB": [902], + "1FBC": [913, 837], + "1FBE": [953], + "1FC1": [168, 834], + "1FC2": [8052, 837], + "1FC3": [951, 837], + "1FC4": [942, 837], + "1FC6": [951, 834], + "1FC7": [8134, 837], + "1FC8": [917, 768], + "1FC9": [904], + "1FCA": [919, 768], + "1FCB": [905], + "1FCC": [919, 837], + "1FCD": [8127, 768], + "1FCE": [8127, 769], + "1FCF": [8127, 834], + "1FD0": [953, 774], + "1FD1": [953, 772], + "1FD2": [970, 768], + "1FD3": [912], + "1FD6": [953, 834], + "1FD7": [970, 834], + "1FD8": [921, 774], + "1FD9": [921, 772], + "1FDA": [921, 768], + "1FDB": [906], + "1FDD": [8190, 768], + "1FDE": [8190, 769], + "1FDF": [8190, 834], + "1FE0": [965, 774], + "1FE1": [965, 772], + "1FE2": [971, 768], + "1FE3": [944], + "1FE4": [961, 787], + "1FE5": [961, 788], + "1FE6": [965, 834], + "1FE7": [971, 834], + "1FE8": [933, 774], + "1FE9": [933, 772], + "1FEA": [933, 768], + "1FEB": [910], + "1FEC": [929, 788], + "1FED": [168, 768], + "1FEE": [901], + "1FEF": [96], + "1FF2": [8060, 837], + "1FF3": [969, 837], + "1FF4": [974, 837], + "1FF6": [969, 834], + "1FF7": [8182, 837], + "1FF8": [927, 768], + "1FF9": [908], + "1FFA": [937, 768], + "1FFB": [911], + "1FFC": [937, 837], + "1FFD": [180], + "2000": [8194], + "2001": [8195], + "2126": [937], + "212A": [75], + "212B": [197], + "219A": [8592, 824], + "219B": [8594, 824], + "21AE": [8596, 824], + "21CD": [8656, 824], + "21CE": [8660, 824], + "21CF": [8658, 824], + "2204": [8707, 824], + "2209": [8712, 824], + "220C": [8715, 824], + "2224": [8739, 824], + "2226": [8741, 824], + "2241": [8764, 824], + "2244": [8771, 824], + "2247": [8773, 824], + "2249": [8776, 824], + "2260": [61, 824], + "2262": [8801, 824], + "226D": [8781, 824], + "226E": [60, 824], + "226F": [62, 824], + "2270": [8804, 824], + "2271": [8805, 824], + "2274": [8818, 824], + "2275": [8819, 824], + "2278": [8822, 824], + "2279": [8823, 824], + "2280": [8826, 824], + "2281": [8827, 824], + "2284": [8834, 824], + "2285": [8835, 824], + "2288": [8838, 824], + "2289": [8839, 824], + "22AC": [8866, 824], + "22AD": [8872, 824], + "22AE": [8873, 824], + "22AF": [8875, 824], + "22E0": [8828, 824], + "22E1": [8829, 824], + "22E2": [8849, 824], + "22E3": [8850, 824], + "22EA": [8882, 824], + "22EB": [8883, 824], + "22EC": [8884, 824], + "22ED": [8885, 824], + "2329": [12296], + "232A": [12297], + "2ADC": [10973, 824], + "2F800": [20029], + "2F801": [20024], + "2F802": [20033], + "2F803": [131362], + "2F804": [20320], + "2F805": [20398], + "2F806": [20411], + "2F807": [20482], + "2F808": [20602], + "2F809": [20633], + "2F80A": [20711], + "2F80B": [20687], + "2F80C": [13470], + "2F80D": [132666], + "2F80E": [20813], + "2F80F": [20820], + "2F810": [20836], + "2F811": [20855], + "2F812": [132380], + "2F813": [13497], + "2F814": [20839], + "2F815": [20877], + "2F816": [132427], + "2F817": [20887], + "2F818": [20900], + "2F819": [20172], + "2F81A": [20908], + "2F81B": [20917], + "2F81C": [168415], + "2F81D": [20981], + "2F81E": [20995], + "2F81F": [13535], + "2F820": [21051], + "2F821": [21062], + "2F822": [21106], + "2F823": [21111], + "2F824": [13589], + "2F825": [21191], + "2F826": [21193], + "2F827": [21220], + "2F828": [21242], + "2F829": [21253], + "2F82A": [21254], + "2F82B": [21271], + "2F82C": [21321], + "2F82D": [21329], + "2F82E": [21338], + "2F82F": [21363], + "2F830": [21373], + "2F831": [21375], + "2F832": [21375], + "2F833": [21375], + "2F834": [133676], + "2F835": [28784], + "2F836": [21450], + "2F837": [21471], + "2F838": [133987], + "2F839": [21483], + "2F83A": [21489], + "2F83B": [21510], + "2F83C": [21662], + "2F83D": [21560], + "2F83E": [21576], + "2F83F": [21608], + "2F840": [21666], + "2F841": [21750], + "2F842": [21776], + "2F843": [21843], + "2F844": [21859], + "2F845": [21892], + "2F846": [21892], + "2F847": [21913], + "2F848": [21931], + "2F849": [21939], + "2F84A": [21954], + "2F84B": [22294], + "2F84C": [22022], + "2F84D": [22295], + "2F84E": [22097], + "2F84F": [22132], + "2F850": [20999], + "2F851": [22766], + "2F852": [22478], + "2F853": [22516], + "2F854": [22541], + "2F855": [22411], + "2F856": [22578], + "2F857": [22577], + "2F858": [22700], + "2F859": [136420], + "2F85A": [22770], + "2F85B": [22775], + "2F85C": [22790], + "2F85D": [22810], + "2F85E": [22818], + "2F85F": [22882], + "2F860": [136872], + "2F861": [136938], + "2F862": [23020], + "2F863": [23067], + "2F864": [23079], + "2F865": [23000], + "2F866": [23142], + "2F867": [14062], + "2F868": [14076], + "2F869": [23304], + "2F86A": [23358], + "2F86B": [23358], + "2F86C": [137672], + "2F86D": [23491], + "2F86E": [23512], + "2F86F": [23527], + "2F870": [23539], + "2F871": [138008], + "2F872": [23551], + "2F873": [23558], + "2F874": [24403], + "2F875": [23586], + "2F876": [14209], + "2F877": [23648], + "2F878": [23662], + "2F879": [23744], + "2F87A": [23693], + "2F87B": [138724], + "2F87C": [23875], + "2F87D": [138726], + "2F87E": [23918], + "2F87F": [23915], + "2F880": [23932], + "2F881": [24033], + "2F882": [24034], + "2F883": [14383], + "2F884": [24061], + "2F885": [24104], + "2F886": [24125], + "2F887": [24169], + "2F888": [14434], + "2F889": [139651], + "2F88A": [14460], + "2F88B": [24240], + "2F88C": [24243], + "2F88D": [24246], + "2F88E": [24266], + "2F88F": [172946], + "2F890": [24318], + "2F891": [140081], + "2F892": [140081], + "2F893": [33281], + "2F894": [24354], + "2F895": [24354], + "2F896": [14535], + "2F897": [144056], + "2F898": [156122], + "2F899": [24418], + "2F89A": [24427], + "2F89B": [14563], + "2F89C": [24474], + "2F89D": [24525], + "2F89E": [24535], + "2F89F": [24569], + "2F8A0": [24705], + "2F8A1": [14650], + "2F8A2": [14620], + "2F8A3": [24724], + "2F8A4": [141012], + "2F8A5": [24775], + "2F8A6": [24904], + "2F8A7": [24908], + "2F8A8": [24910], + "2F8A9": [24908], + "2F8AA": [24954], + "2F8AB": [24974], + "2F8AC": [25010], + "2F8AD": [24996], + "2F8AE": [25007], + "2F8AF": [25054], + "2F8B0": [25074], + "2F8B1": [25078], + "2F8B2": [25104], + "2F8B3": [25115], + "2F8B4": [25181], + "2F8B5": [25265], + "2F8B6": [25300], + "2F8B7": [25424], + "2F8B8": [142092], + "2F8B9": [25405], + "2F8BA": [25340], + "2F8BB": [25448], + "2F8BC": [25475], + "2F8BD": [25572], + "2F8BE": [142321], + "2F8BF": [25634], + "2F8C0": [25541], + "2F8C1": [25513], + "2F8C2": [14894], + "2F8C3": [25705], + "2F8C4": [25726], + "2F8C5": [25757], + "2F8C6": [25719], + "2F8C7": [14956], + "2F8C8": [25935], + "2F8C9": [25964], + "2F8CA": [143370], + "2F8CB": [26083], + "2F8CC": [26360], + "2F8CD": [26185], + "2F8CE": [15129], + "2F8CF": [26257], + "2F8D0": [15112], + "2F8D1": [15076], + "2F8D2": [20882], + "2F8D3": [20885], + "2F8D4": [26368], + "2F8D5": [26268], + "2F8D6": [32941], + "2F8D7": [17369], + "2F8D8": [26391], + "2F8D9": [26395], + "2F8DA": [26401], + "2F8DB": [26462], + "2F8DC": [26451], + "2F8DD": [144323], + "2F8DE": [15177], + "2F8DF": [26618], + "2F8E0": [26501], + "2F8E1": [26706], + "2F8E2": [26757], + "2F8E3": [144493], + "2F8E4": [26766], + "2F8E5": [26655], + "2F8E6": [26900], + "2F8E7": [15261], + "2F8E8": [26946], + "2F8E9": [27043], + "2F8EA": [27114], + "2F8EB": [27304], + "2F8EC": [145059], + "2F8ED": [27355], + "2F8EE": [15384], + "2F8EF": [27425], + "2F8F0": [145575], + "2F8F1": [27476], + "2F8F2": [15438], + "2F8F3": [27506], + "2F8F4": [27551], + "2F8F5": [27578], + "2F8F6": [27579], + "2F8F7": [146061], + "2F8F8": [138507], + "2F8F9": [146170], + "2F8FA": [27726], + "2F8FB": [146620], + "2F8FC": [27839], + "2F8FD": [27853], + "2F8FE": [27751], + "2F8FF": [27926], + "2F900": [27966], + "2F901": [28023], + "2F902": [27969], + "2F903": [28009], + "2F904": [28024], + "2F905": [28037], + "2F906": [146718], + "2F907": [27956], + "2F908": [28207], + "2F909": [28270], + "2F90A": [15667], + "2F90B": [28363], + "2F90C": [28359], + "2F90D": [147153], + "2F90E": [28153], + "2F90F": [28526], + "2F910": [147294], + "2F911": [147342], + "2F912": [28614], + "2F913": [28729], + "2F914": [28702], + "2F915": [28699], + "2F916": [15766], + "2F917": [28746], + "2F918": [28797], + "2F919": [28791], + "2F91A": [28845], + "2F91B": [132389], + "2F91C": [28997], + "2F91D": [148067], + "2F91E": [29084], + "2F91F": [148395], + "2F920": [29224], + "2F921": [29237], + "2F922": [29264], + "2F923": [149000], + "2F924": [29312], + "2F925": [29333], + "2F926": [149301], + "2F927": [149524], + "2F928": [29562], + "2F929": [29579], + "2F92A": [16044], + "2F92B": [29605], + "2F92C": [16056], + "2F92D": [16056], + "2F92E": [29767], + "2F92F": [29788], + "2F930": [29809], + "2F931": [29829], + "2F932": [29898], + "2F933": [16155], + "2F934": [29988], + "2F935": [150582], + "2F936": [30014], + "2F937": [150674], + "2F938": [30064], + "2F939": [139679], + "2F93A": [30224], + "2F93B": [151457], + "2F93C": [151480], + "2F93D": [151620], + "2F93E": [16380], + "2F93F": [16392], + "2F940": [30452], + "2F941": [151795], + "2F942": [151794], + "2F943": [151833], + "2F944": [151859], + "2F945": [30494], + "2F946": [30495], + "2F947": [30495], + "2F948": [30538], + "2F949": [16441], + "2F94A": [30603], + "2F94B": [16454], + "2F94C": [16534], + "2F94D": [152605], + "2F94E": [30798], + "2F94F": [30860], + "2F950": [30924], + "2F951": [16611], + "2F952": [153126], + "2F953": [31062], + "2F954": [153242], + "2F955": [153285], + "2F956": [31119], + "2F957": [31211], + "2F958": [16687], + "2F959": [31296], + "2F95A": [31306], + "2F95B": [31311], + "2F95C": [153980], + "2F95D": [154279], + "2F95E": [154279], + "2F95F": [31470], + "2F960": [16898], + "2F961": [154539], + "2F962": [31686], + "2F963": [31689], + "2F964": [16935], + "2F965": [154752], + "2F966": [31954], + "2F967": [17056], + "2F968": [31976], + "2F969": [31971], + "2F96A": [32000], + "2F96B": [155526], + "2F96C": [32099], + "2F96D": [17153], + "2F96E": [32199], + "2F96F": [32258], + "2F970": [32325], + "2F971": [17204], + "2F972": [156200], + "2F973": [156231], + "2F974": [17241], + "2F975": [156377], + "2F976": [32634], + "2F977": [156478], + "2F978": [32661], + "2F979": [32762], + "2F97A": [32773], + "2F97B": [156890], + "2F97C": [156963], + "2F97D": [32864], + "2F97E": [157096], + "2F97F": [32880], + "2F980": [144223], + "2F981": [17365], + "2F982": [32946], + "2F983": [33027], + "2F984": [17419], + "2F985": [33086], + "2F986": [23221], + "2F987": [157607], + "2F988": [157621], + "2F989": [144275], + "2F98A": [144284], + "2F98B": [33281], + "2F98C": [33284], + "2F98D": [36766], + "2F98E": [17515], + "2F98F": [33425], + "2F990": [33419], + "2F991": [33437], + "2F992": [21171], + "2F993": [33457], + "2F994": [33459], + "2F995": [33469], + "2F996": [33510], + "2F997": [158524], + "2F998": [33509], + "2F999": [33565], + "2F99A": [33635], + "2F99B": [33709], + "2F99C": [33571], + "2F99D": [33725], + "2F99E": [33767], + "2F99F": [33879], + "2F9A0": [33619], + "2F9A1": [33738], + "2F9A2": [33740], + "2F9A3": [33756], + "2F9A4": [158774], + "2F9A5": [159083], + "2F9A6": [158933], + "2F9A7": [17707], + "2F9A8": [34033], + "2F9A9": [34035], + "2F9AA": [34070], + "2F9AB": [160714], + "2F9AC": [34148], + "2F9AD": [159532], + "2F9AE": [17757], + "2F9AF": [17761], + "2F9B0": [159665], + "2F9B1": [159954], + "2F9B2": [17771], + "2F9B3": [34384], + "2F9B4": [34396], + "2F9B5": [34407], + "2F9B6": [34409], + "2F9B7": [34473], + "2F9B8": [34440], + "2F9B9": [34574], + "2F9BA": [34530], + "2F9BB": [34681], + "2F9BC": [34600], + "2F9BD": [34667], + "2F9BE": [34694], + "2F9BF": [17879], + "2F9C0": [34785], + "2F9C1": [34817], + "2F9C2": [17913], + "2F9C3": [34912], + "2F9C4": [34915], + "2F9C5": [161383], + "2F9C6": [35031], + "2F9C7": [35038], + "2F9C8": [17973], + "2F9C9": [35066], + "2F9CA": [13499], + "2F9CB": [161966], + "2F9CC": [162150], + "2F9CD": [18110], + "2F9CE": [18119], + "2F9CF": [35488], + "2F9D0": [35565], + "2F9D1": [35722], + "2F9D2": [35925], + "2F9D3": [162984], + "2F9D4": [36011], + "2F9D5": [36033], + "2F9D6": [36123], + "2F9D7": [36215], + "2F9D8": [163631], + "2F9D9": [133124], + "2F9DA": [36299], + "2F9DB": [36284], + "2F9DC": [36336], + "2F9DD": [133342], + "2F9DE": [36564], + "2F9DF": [36664], + "2F9E0": [165330], + "2F9E1": [165357], + "2F9E2": [37012], + "2F9E3": [37105], + "2F9E4": [37137], + "2F9E5": [165678], + "2F9E6": [37147], + "2F9E7": [37432], + "2F9E8": [37591], + "2F9E9": [37592], + "2F9EA": [37500], + "2F9EB": [37881], + "2F9EC": [37909], + "2F9ED": [166906], + "2F9EE": [38283], + "2F9EF": [18837], + "2F9F0": [38327], + "2F9F1": [167287], + "2F9F2": [18918], + "2F9F3": [38595], + "2F9F4": [23986], + "2F9F5": [38691], + "2F9F6": [168261], + "2F9F7": [168474], + "2F9F8": [19054], + "2F9F9": [19062], + "2F9FA": [38880], + "2F9FB": [168970], + "2F9FC": [19122], + "2F9FD": [169110], + "2F9FE": [38923], + "2F9FF": [38923], + "2FA00": [38953], + "2FA01": [169398], + "2FA02": [39138], + "2FA03": [19251], + "2FA04": [39209], + "2FA05": [39335], + "2FA06": [39362], + "2FA07": [39422], + "2FA08": [19406], + "2FA09": [170800], + "2FA0A": [39698], + "2FA0B": [40000], + "2FA0C": [40189], + "2FA0D": [19662], + "2FA0E": [19693], + "2FA0F": [40295], + "2FA10": [172238], + "2FA11": [19704], + "2FA12": [172293], + "2FA13": [172558], + "2FA14": [172689], + "2FA15": [40635], + "2FA16": [19798], + "2FA17": [40697], + "2FA18": [40702], + "2FA19": [40709], + "2FA1A": [40719], + "2FA1B": [40726], + "2FA1C": [40763], + "2FA1D": [173568], + "304C": [12363, 12441], + "304E": [12365, 12441], + "3050": [12367, 12441], + "3052": [12369, 12441], + "3054": [12371, 12441], + "3056": [12373, 12441], + "3058": [12375, 12441], + "305A": [12377, 12441], + "305C": [12379, 12441], + "305E": [12381, 12441], + "3060": [12383, 12441], + "3062": [12385, 12441], + "3065": [12388, 12441], + "3067": [12390, 12441], + "3069": [12392, 12441], + "3070": [12399, 12441], + "3071": [12399, 12442], + "3073": [12402, 12441], + "3074": [12402, 12442], + "3076": [12405, 12441], + "3077": [12405, 12442], + "3079": [12408, 12441], + "307A": [12408, 12442], + "307C": [12411, 12441], + "307D": [12411, 12442], + "3094": [12358, 12441], + "309E": [12445, 12441], + "30AC": [12459, 12441], + "30AE": [12461, 12441], + "30B0": [12463, 12441], + "30B2": [12465, 12441], + "30B4": [12467, 12441], + "30B6": [12469, 12441], + "30B8": [12471, 12441], + "30BA": [12473, 12441], + "30BC": [12475, 12441], + "30BE": [12477, 12441], + "30C0": [12479, 12441], + "30C2": [12481, 12441], + "30C5": [12484, 12441], + "30C7": [12486, 12441], + "30C9": [12488, 12441], + "30D0": [12495, 12441], + "30D1": [12495, 12442], + "30D3": [12498, 12441], + "30D4": [12498, 12442], + "30D6": [12501, 12441], + "30D7": [12501, 12442], + "30D9": [12504, 12441], + "30DA": [12504, 12442], + "30DC": [12507, 12441], + "30DD": [12507, 12442], + "30F4": [12454, 12441], + "30F7": [12527, 12441], + "30F8": [12528, 12441], + "30F9": [12529, 12441], + "30FA": [12530, 12441], + "30FE": [12541, 12441], + "F900": [35912], + "F901": [26356], + "F902": [36554], + "F903": [36040], + "F904": [28369], + "F905": [20018], + "F906": [21477], + "F907": [40860], + "F908": [40860], + "F909": [22865], + "F90A": [37329], + "F90B": [21895], + "F90C": [22856], + "F90D": [25078], + "F90E": [30313], + "F90F": [32645], + "F910": [34367], + "F911": [34746], + "F912": [35064], + "F913": [37007], + "F914": [27138], + "F915": [27931], + "F916": [28889], + "F917": [29662], + "F918": [33853], + "F919": [37226], + "F91A": [39409], + "F91B": [20098], + "F91C": [21365], + "F91D": [27396], + "F91E": [29211], + "F91F": [34349], + "F920": [40478], + "F921": [23888], + "F922": [28651], + "F923": [34253], + "F924": [35172], + "F925": [25289], + "F926": [33240], + "F927": [34847], + "F928": [24266], + "F929": [26391], + "F92A": [28010], + "F92B": [29436], + "F92C": [37070], + "F92D": [20358], + "F92E": [20919], + "F92F": [21214], + "F930": [25796], + "F931": [27347], + "F932": [29200], + "F933": [30439], + "F934": [32769], + "F935": [34310], + "F936": [34396], + "F937": [36335], + "F938": [38706], + "F939": [39791], + "F93A": [40442], + "F93B": [30860], + "F93C": [31103], + "F93D": [32160], + "F93E": [33737], + "F93F": [37636], + "F940": [40575], + "F941": [35542], + "F942": [22751], + "F943": [24324], + "F944": [31840], + "F945": [32894], + "F946": [29282], + "F947": [30922], + "F948": [36034], + "F949": [38647], + "F94A": [22744], + "F94B": [23650], + "F94C": [27155], + "F94D": [28122], + "F94E": [28431], + "F94F": [32047], + "F950": [32311], + "F951": [38475], + "F952": [21202], + "F953": [32907], + "F954": [20956], + "F955": [20940], + "F956": [31260], + "F957": [32190], + "F958": [33777], + "F959": [38517], + "F95A": [35712], + "F95B": [25295], + "F95C": [27138], + "F95D": [35582], + "F95E": [20025], + "F95F": [23527], + "F960": [24594], + "F961": [29575], + "F962": [30064], + "F963": [21271], + "F964": [30971], + "F965": [20415], + "F966": [24489], + "F967": [19981], + "F968": [27852], + "F969": [25976], + "F96A": [32034], + "F96B": [21443], + "F96C": [22622], + "F96D": [30465], + "F96E": [33865], + "F96F": [35498], + "F970": [27578], + "F971": [36784], + "F972": [27784], + "F973": [25342], + "F974": [33509], + "F975": [25504], + "F976": [30053], + "F977": [20142], + "F978": [20841], + "F979": [20937], + "F97A": [26753], + "F97B": [31975], + "F97C": [33391], + "F97D": [35538], + "F97E": [37327], + "F97F": [21237], + "F980": [21570], + "F981": [22899], + "F982": [24300], + "F983": [26053], + "F984": [28670], + "F985": [31018], + "F986": [38317], + "F987": [39530], + "F988": [40599], + "F989": [40654], + "F98A": [21147], + "F98B": [26310], + "F98C": [27511], + "F98D": [36706], + "F98E": [24180], + "F98F": [24976], + "F990": [25088], + "F991": [25754], + "F992": [28451], + "F993": [29001], + "F994": [29833], + "F995": [31178], + "F996": [32244], + "F997": [32879], + "F998": [36646], + "F999": [34030], + "F99A": [36899], + "F99B": [37706], + "F99C": [21015], + "F99D": [21155], + "F99E": [21693], + "F99F": [28872], + "F9A0": [35010], + "F9A1": [35498], + "F9A2": [24265], + "F9A3": [24565], + "F9A4": [25467], + "F9A5": [27566], + "F9A6": [31806], + "F9A7": [29557], + "F9A8": [20196], + "F9A9": [22265], + "F9AA": [23527], + "F9AB": [23994], + "F9AC": [24604], + "F9AD": [29618], + "F9AE": [29801], + "F9AF": [32666], + "F9B0": [32838], + "F9B1": [37428], + "F9B2": [38646], + "F9B3": [38728], + "F9B4": [38936], + "F9B5": [20363], + "F9B6": [31150], + "F9B7": [37300], + "F9B8": [38584], + "F9B9": [24801], + "F9BA": [20102], + "F9BB": [20698], + "F9BC": [23534], + "F9BD": [23615], + "F9BE": [26009], + "F9BF": [27138], + "F9C0": [29134], + "F9C1": [30274], + "F9C2": [34044], + "F9C3": [36988], + "F9C4": [40845], + "F9C5": [26248], + "F9C6": [38446], + "F9C7": [21129], + "F9C8": [26491], + "F9C9": [26611], + "F9CA": [27969], + "F9CB": [28316], + "F9CC": [29705], + "F9CD": [30041], + "F9CE": [30827], + "F9CF": [32016], + "F9D0": [39006], + "F9D1": [20845], + "F9D2": [25134], + "F9D3": [38520], + "F9D4": [20523], + "F9D5": [23833], + "F9D6": [28138], + "F9D7": [36650], + "F9D8": [24459], + "F9D9": [24900], + "F9DA": [26647], + "F9DB": [29575], + "F9DC": [38534], + "F9DD": [21033], + "F9DE": [21519], + "F9DF": [23653], + "F9E0": [26131], + "F9E1": [26446], + "F9E2": [26792], + "F9E3": [27877], + "F9E4": [29702], + "F9E5": [30178], + "F9E6": [32633], + "F9E7": [35023], + "F9E8": [35041], + "F9E9": [37324], + "F9EA": [38626], + "F9EB": [21311], + "F9EC": [28346], + "F9ED": [21533], + "F9EE": [29136], + "F9EF": [29848], + "F9F0": [34298], + "F9F1": [38563], + "F9F2": [40023], + "F9F3": [40607], + "F9F4": [26519], + "F9F5": [28107], + "F9F6": [33256], + "F9F7": [31435], + "F9F8": [31520], + "F9F9": [31890], + "F9FA": [29376], + "F9FB": [28825], + "F9FC": [35672], + "F9FD": [20160], + "F9FE": [33590], + "F9FF": [21050], + "FA00": [20999], + "FA01": [24230], + "FA02": [25299], + "FA03": [31958], + "FA04": [23429], + "FA05": [27934], + "FA06": [26292], + "FA07": [36667], + "FA08": [34892], + "FA09": [38477], + "FA0A": [35211], + "FA0B": [24275], + "FA0C": [20800], + "FA0D": [21952], + "FA10": [22618], + "FA12": [26228], + "FA15": [20958], + "FA16": [29482], + "FA17": [30410], + "FA18": [31036], + "FA19": [31070], + "FA1A": [31077], + "FA1B": [31119], + "FA1C": [38742], + "FA1D": [31934], + "FA1E": [32701], + "FA20": [34322], + "FA22": [35576], + "FA25": [36920], + "FA26": [37117], + "FA2A": [39151], + "FA2B": [39164], + "FA2C": [39208], + "FA2D": [40372], + "FA2E": [37086], + "FA2F": [38583], + "FA30": [20398], + "FA31": [20711], + "FA32": [20813], + "FA33": [21193], + "FA34": [21220], + "FA35": [21329], + "FA36": [21917], + "FA37": [22022], + "FA38": [22120], + "FA39": [22592], + "FA3A": [22696], + "FA3B": [23652], + "FA3C": [23662], + "FA3D": [24724], + "FA3E": [24936], + "FA3F": [24974], + "FA40": [25074], + "FA41": [25935], + "FA42": [26082], + "FA43": [26257], + "FA44": [26757], + "FA45": [28023], + "FA46": [28186], + "FA47": [28450], + "FA48": [29038], + "FA49": [29227], + "FA4A": [29730], + "FA4B": [30865], + "FA4C": [31038], + "FA4D": [31049], + "FA4E": [31048], + "FA4F": [31056], + "FA50": [31062], + "FA51": [31069], + "FA52": [31117], + "FA53": [31118], + "FA54": [31296], + "FA55": [31361], + "FA56": [31680], + "FA57": [32244], + "FA58": [32265], + "FA59": [32321], + "FA5A": [32626], + "FA5B": [32773], + "FA5C": [33261], + "FA5D": [33401], + "FA5E": [33401], + "FA5F": [33879], + "FA60": [35088], + "FA61": [35222], + "FA62": [35585], + "FA63": [35641], + "FA64": [36051], + "FA65": [36104], + "FA66": [36790], + "FA67": [36920], + "FA68": [38627], + "FA69": [38911], + "FA6A": [38971], + "FA6B": [24693], + "FA6C": [148206], + "FA6D": [33304], + "FA70": [20006], + "FA71": [20917], + "FA72": [20840], + "FA73": [20352], + "FA74": [20805], + "FA75": [20864], + "FA76": [21191], + "FA77": [21242], + "FA78": [21917], + "FA79": [21845], + "FA7A": [21913], + "FA7B": [21986], + "FA7C": [22618], + "FA7D": [22707], + "FA7E": [22852], + "FA7F": [22868], + "FA80": [23138], + "FA81": [23336], + "FA82": [24274], + "FA83": [24281], + "FA84": [24425], + "FA85": [24493], + "FA86": [24792], + "FA87": [24910], + "FA88": [24840], + "FA89": [24974], + "FA8A": [24928], + "FA8B": [25074], + "FA8C": [25140], + "FA8D": [25540], + "FA8E": [25628], + "FA8F": [25682], + "FA90": [25942], + "FA91": [26228], + "FA92": [26391], + "FA93": [26395], + "FA94": [26454], + "FA95": [27513], + "FA96": [27578], + "FA97": [27969], + "FA98": [28379], + "FA99": [28363], + "FA9A": [28450], + "FA9B": [28702], + "FA9C": [29038], + "FA9D": [30631], + "FA9E": [29237], + "FA9F": [29359], + "FAA0": [29482], + "FAA1": [29809], + "FAA2": [29958], + "FAA3": [30011], + "FAA4": [30237], + "FAA5": [30239], + "FAA6": [30410], + "FAA7": [30427], + "FAA8": [30452], + "FAA9": [30538], + "FAAA": [30528], + "FAAB": [30924], + "FAAC": [31409], + "FAAD": [31680], + "FAAE": [31867], + "FAAF": [32091], + "FAB0": [32244], + "FAB1": [32574], + "FAB2": [32773], + "FAB3": [33618], + "FAB4": [33775], + "FAB5": [34681], + "FAB6": [35137], + "FAB7": [35206], + "FAB8": [35222], + "FAB9": [35519], + "FABA": [35576], + "FABB": [35531], + "FABC": [35585], + "FABD": [35582], + "FABE": [35565], + "FABF": [35641], + "FAC0": [35722], + "FAC1": [36104], + "FAC2": [36664], + "FAC3": [36978], + "FAC4": [37273], + "FAC5": [37494], + "FAC6": [38524], + "FAC7": [38627], + "FAC8": [38742], + "FAC9": [38875], + "FACA": [38911], + "FACB": [38923], + "FACC": [38971], + "FACD": [39698], + "FACE": [40860], + "FACF": [141386], + "FAD0": [141380], + "FAD1": [144341], + "FAD2": [15261], + "FAD3": [16408], + "FAD4": [16441], + "FAD5": [152137], + "FAD6": [154832], + "FAD7": [163539], + "FAD8": [40771], + "FAD9": [40846], + "FB1D": [1497, 1460], + "FB1F": [1522, 1463], + "FB2A": [1513, 1473], + "FB2B": [1513, 1474], + "FB2C": [64329, 1473], + "FB2D": [64329, 1474], + "FB2E": [1488, 1463], + "FB2F": [1488, 1464], + "FB30": [1488, 1468], + "FB31": [1489, 1468], + "FB32": [1490, 1468], + "FB33": [1491, 1468], + "FB34": [1492, 1468], + "FB35": [1493, 1468], + "FB36": [1494, 1468], + "FB38": [1496, 1468], + "FB39": [1497, 1468], + "FB3A": [1498, 1468], + "FB3B": [1499, 1468], + "FB3C": [1500, 1468], + "FB3E": [1502, 1468], + "FB40": [1504, 1468], + "FB41": [1505, 1468], + "FB43": [1507, 1468], + "FB44": [1508, 1468], + "FB46": [1510, 1468], + "FB47": [1511, 1468], + "FB48": [1512, 1468], + "FB49": [1513, 1468], + "FB4A": [1514, 1468], + "FB4B": [1493, 1465], + "FB4C": [1489, 1471], + "FB4D": [1499, 1471], + "FB4E": [1508, 1471] + }, + "sources": { + "CaseFolding.txt": "4e55acfdc32825a22e87670e9056a3bf94ad7c5400065778e9e10f8314372bcf", + "CompositionExclusions.txt": "59d2d9e3dfdf0a999cf9dae11d594f053631222679a2f5710315ea07f7fe82af", + "UnicodeData.txt": "2fc713e6a31a87c4850a37fe2caffa4218180fadb5de86b43a143ddb4581fb86" + }, + "unicode_version": "15.1.0" +} diff --git a/packages/share/src/sources/errors.mjs b/packages/share/src/sources/errors.mjs new file mode 100644 index 0000000000..2484185d0e --- /dev/null +++ b/packages/share/src/sources/errors.mjs @@ -0,0 +1,77 @@ +// @ts-check +// Map sync API error codes to stable client error kinds. + +/** @typedef {import("./types.js").SyncErrorKind} SyncErrorKind */ + +/** @type {Record} */ +const KIND_BY_CODE = { + hyperframes_composition_sync_not_enabled: "not-enabled", + hf_subscription_required: "plan-required", + hyperframes_composition_sync_limit_reached: "limit-reached", + byok_not_supported: "byok", + resource_access_denied: "no-write-role", + forbidden: "forbidden", + hyperframes_composition_not_found: "composition-not-found", + resource_not_found: "not-found", + hyperframes_composition_upload_too_large: "too-large", + hyperframes_composition_upload_reference_invalid: "reference-invalid", + hyperframes_composition_upload_not_pending: "upload-not-pending", + hyperframes_composition_active_uploads_exceeded: "active-uploads-exceeded", + hyperframes_composition_upload_file_not_writable: "file-not-writable", + conflict: "idempotency-key-reused", + request_in_progress: "request-in-progress", + hyperframes_composition_snapshot_not_downloadable: "snapshot-not-downloadable", + hyperframes_composition_conflict_not_open: "conflict-not-open", + hyperframes_composition_download_expired: "download-expired", + invalid_parameter: "invalid-parameter", + rate_limit_exceeded: "rate-limited", + service_unavailable: "unavailable", +}; + +/** A sync route's refusal or failure. `status` is 0 when the server was never reached. */ +export class SyncApiError extends Error { + /** @param {SyncErrorKind} kind @param {{ status?: number, code?: string | null, param?: string | null, + * requestId?: string | null, retryAfterMs?: number | null, detail?: string }} [about] */ + constructor(kind, about = {}) { + super(`composition sync: ${kind}${about.code ? ` (${about.code})` : ""}`); + this.name = "SyncApiError"; + this.kind = kind; + this.status = about.status ?? 0; + this.code = about.code ?? null; + this.param = about.param ?? null; + this.requestId = about.requestId ?? null; + this.retryAfterMs = about.retryAfterMs ?? null; + this.detail = about.detail ?? null; + } +} + +/** The kind for an HTTP status whose code this client does not know. @param {number} status + * @returns {SyncErrorKind} */ +function kindOfStatus(status) { + if (status === 404) return "not-found"; + if (status === 429) return "rate-limited"; + if (status === 503) return "unavailable"; + if (status >= 500) return "server-error"; + return "refused"; +} + +/** The typed error for a refusal: the envelope's code when it is one of the sync routes', else the status's. + * @param {Response} reply @returns {Promise} */ +export async function refusalOf(reply) { + const payload = await reply.json().catch(() => null); + /** @type {{ code?: unknown, param?: unknown, request_id?: unknown, message?: unknown } | undefined} */ + const error = payload?.error; + const code = typeof error?.code === "string" ? error.code : null; + const seconds = Number(reply.headers.get("retry-after") ?? Number.NaN); + return new SyncApiError((code && KIND_BY_CODE[code]) || kindOfStatus(reply.status), { + status: reply.status, + code, + param: typeof error?.param === "string" ? error.param : null, + requestId: + typeof error?.request_id === "string" + ? error.request_id + : reply.headers.get("x-heygen-request-id"), + retryAfterMs: seconds >= 0 ? seconds * 1000 : null, + ...(typeof error?.message === "string" ? { detail: error.message } : {}), + }); +} diff --git a/packages/share/src/sources/limits.mjs b/packages/share/src/sources/limits.mjs new file mode 100644 index 0000000000..e70173c694 --- /dev/null +++ b/packages/share/src/sources/limits.mjs @@ -0,0 +1,48 @@ +// @ts-check +// Check the workspace upload limits before hashing or sending files. + +const MIB = 1024 * 1024; +const GIB = 1024 * MIB; + +/** @typedef {import("./types.js").Limits} Limits @typedef {import("./types.js").LimitName} LimitName */ + +/** @type {Limits} */ +export const V1_LIMITS = Object.freeze({ + maxFiles: 10_000, + maxFileBytes: 5 * GIB, + maxProjectBytes: 10 * GIB, + maxManifestBytes: 8 * MIB, +}); + +/** How many of the biggest files an over-limit answer names. */ +const NAMED = 10; + +/** A manifest's file count, largest file, total and canonical size; every listed file counts, reused ones too. + * @param {readonly { size: number }[]} files @param {number} manifestBytes */ +const measure = (files, manifestBytes) => ({ + fileCount: files.length, + largestFileBytes: files.reduce((most, file) => Math.max(most, file.size), 0), + projectBytes: files.reduce((sum, file) => sum + file.size, 0), + manifestBytes, +}); + +/** The first limit broken, in the server's fixed order (file count, file size, project size, manifest size), with + * the biggest files first; null when the push fits. @param {readonly { path: string, size: number }[]} files + * @param {number} manifestBytes @param {Limits} [limits] @returns {import("./types.js").OverLimit | null} */ +export function overLimit(files, manifestBytes, limits = V1_LIMITS) { + const size = measure(files, manifestBytes); + /** @type {[LimitName, number, number][]} */ + const checks = [ + ["file_count", size.fileCount, limits.maxFiles], + ["file_size", size.largestFileBytes, limits.maxFileBytes], + ["project_size", size.projectBytes, limits.maxProjectBytes], + ["manifest_size", size.manifestBytes, limits.maxManifestBytes], + ]; + const broken = checks.find(([, actual, maximum]) => actual > maximum); + if (!broken) return null; + const biggest = [...files] + .sort((a, b) => b.size - a.size || (a.path < b.path ? -1 : 1)) + .slice(0, NAMED) + .map(({ path, size: bytes }) => ({ path, size: bytes })); + return { limit: broken[0], actual: broken[1], maximum: broken[2], biggest }; +} diff --git a/packages/share/src/sources/manifest.mjs b/packages/share/src/sources/manifest.mjs new file mode 100644 index 0000000000..bb327488bc --- /dev/null +++ b/packages/share/src/sources/manifest.mjs @@ -0,0 +1,154 @@ +// @ts-check +// Serialize snapshots to canonical UTF-8 bytes so clients and the server compute the same digest. +import { createHash } from "node:crypto"; +import { PathViolation, checkInventoryPaths, validatePath } from "./pathPolicy.mjs"; + +const FORMAT_VERSION = 1; +export const ENTRYPOINT = "index.html"; +const MAX_SAFE_SIZE = Number.MAX_SAFE_INTEGER; +const SHA256 = /^[0-9a-f]{64}$/; + +/** @typedef {import("./types.js").ManifestFile} ManifestFile @typedef {import("./types.js").Violation} Violation + * @typedef {import("./types.js").ManifestDocument} ManifestDocument @typedef {import("./types.js").Manifest} Manifest */ + +/** Why a manifest was refused; `code` is the first violation's, in the server's order. */ +export class ManifestInvalid extends Error { + /** @param {Violation[]} violations */ + constructor(violations) { + super(violations.map((violation) => violation.code).join(", ")); + this.name = "ManifestInvalid"; + this.violations = violations; + this.code = violations[0]?.code ?? "invalid_schema"; + } +} + +/** @param {unknown} value @returns {value is Record} */ +const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value); +/** @param {unknown} error @returns {Violation} */ +const violationOf = (error) => { + if (!(error instanceof PathViolation)) throw error; + return { code: error.code, path: error.path, ...(error.rule ? { rule: error.rule } : {}) }; +}; + +/** A schema violation for each field `fields` does not name. + * @param {Record} value @param {readonly string[]} fields @param {Violation[]} out */ +function unknownFields(value, fields, out) { + for (const key of Object.keys(value)) + if (!fields.includes(key)) out.push({ code: "invalid_schema" }); +} + +/** @param {unknown} raw @param {Violation[]} out @param {boolean} stored @returns {ManifestFile | null} */ +function fileOf(raw, out, stored) { + if (!isObject(raw)) return (out.push({ code: "invalid_schema" }), null); + const before = out.length; + const { path, sha256, size } = raw; + if (typeof path !== "string") out.push({ code: "invalid_schema" }); + else { + try { + validatePath(path, stored); + } catch (error) { + out.push(violationOf(error)); + } + } + checkBlob(sha256, size, out); + unknownFields(raw, ["path", "sha256", "size"], out); + return out.length === before + ? { path: String(path), sha256: String(sha256), size: Number(size) } + : null; +} + +/** @param {unknown} sha256 @param {unknown} size @param {Violation[]} out */ +function checkBlob(sha256, size, out) { + if (typeof sha256 !== "string") out.push({ code: "invalid_schema" }); + else if (!SHA256.test(sha256)) out.push({ code: "invalid_sha256" }); + if (typeof size !== "number" || !Number.isInteger(size)) out.push({ code: "invalid_schema" }); + else if (size < 0 || size > MAX_SAFE_SIZE) out.push({ code: "invalid_size" }); +} + +/** UTF-8 byte order, which is code point order; JavaScript's default sort compares UTF-16 units instead. + * @param {ManifestFile} a @param {ManifestFile} b */ +const byUtf8 = (a, b) => Buffer.compare(Buffer.from(a.path, "utf8"), Buffer.from(b.path, "utf8")); + +/** The files in canonical order, or the inventory's first violation. @param {ManifestFile[]} files + * @param {Violation[]} out */ +function canonicalInventory(files, out) { + const ordered = [...files].sort(byUtf8); + /** @type {Map} */ + const sizeByDigest = new Map(); + for (const file of ordered) { + const size = sizeByDigest.get(file.sha256) ?? file.size; + sizeByDigest.set(file.sha256, size); + if (size !== file.size) + return (out.push({ code: "inconsistent_digest_size", path: file.path }), null); + } + try { + checkInventoryPaths(ordered.map((file) => file.path)); + } catch (error) { + return (out.push(violationOf(error)), null); + } + return ordered; +} + +/** @param {unknown} raw @param {Violation[]} out @param {boolean} stored */ +function filesOf(raw, out, stored) { + if (!Array.isArray(raw)) return (out.push({ code: "invalid_schema" }), null); + const before = out.length; + const files = raw.map((item) => fileOf(item, out, stored)); + if (out.length !== before) return null; + return canonicalInventory(/** @type {ManifestFile[]} */ (files), out); +} + +/** The canonical bytes of a valid document. @param {ManifestDocument} document */ +export function canonicalBytes(document) { + const files = document.files + .map( + ({ path, sha256, size }) => + `{"path":${JSON.stringify(path)},"sha256":${JSON.stringify(sha256)},"size":${size}}`, + ) + .join(","); + const text = `{"entrypoint":${JSON.stringify(document.entrypoint)},"files":[${files}],"format_version":${document.format_version}}`; + return Buffer.from(text, "utf8"); +} + +/** Validates a manifest document as the server does; throws ManifestInvalid. @param {unknown} raw + * @param {boolean} [stored] @returns {Manifest} */ +export function parseManifest(raw, stored = false) { + if (!isObject(raw)) throw new ManifestInvalid([{ code: "invalid_schema" }]); + /** @type {Violation[]} */ + const out = []; + const { format_version: version, entrypoint } = raw; + if (!("format_version" in raw) || typeof version !== "number" || !Number.isInteger(version)) + out.push({ code: "invalid_schema" }); + else if (version !== FORMAT_VERSION) out.push({ code: "unsupported_format_version" }); + if (typeof entrypoint !== "string") out.push({ code: "invalid_schema" }); + else if (entrypoint !== ENTRYPOINT) out.push({ code: "invalid_entrypoint" }); + const files = filesOf(raw.files, out, stored); + unknownFields(raw, ["format_version", "entrypoint", "files"], out); + if (out.length) throw new ManifestInvalid(out); + const ordered = /** @type {ManifestFile[]} */ (files); + if (!ordered.some((file) => file.path === ENTRYPOINT)) + throw new ManifestInvalid([{ code: "entrypoint_not_listed" }]); + /** @type {ManifestDocument} */ + const document = { format_version: FORMAT_VERSION, entrypoint: ENTRYPOINT, files: ordered }; + const canonical = canonicalBytes(document); + return { document, canonical, sha256: createHash("sha256").update(canonical).digest("hex") }; +} + +/** Stored manifest bytes, which must already be canonical so their hash is the snapshot's manifest_sha256. + * @param {Uint8Array} body @returns {Manifest} */ +export function parseCanonicalManifest(body) { + let document; + try { + document = JSON.parse(new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(body)); + } catch { + throw new ManifestInvalid([{ code: "invalid_json" }]); + } + const manifest = parseManifest(document); + if (!manifest.canonical.equals(Buffer.from(body))) + throw new ManifestInvalid([{ code: "not_canonical" }]); + return manifest; +} + +/** A published snapshot or local base can retain v3 paths; its bytes and digest remain immutable. + * @param {unknown} raw @returns {Manifest} */ +export const parseStoredManifest = (raw) => parseManifest(raw, true); diff --git a/packages/share/src/sources/pathPolicy.mjs b/packages/share/src/sources/pathPolicy.mjs new file mode 100644 index 0000000000..99da38412b --- /dev/null +++ b/packages/share/src/sources/pathPolicy.mjs @@ -0,0 +1,197 @@ +// @ts-check +// Validate snapshot paths in the order defined by the bundled portable-source-v4 policy. +import { readContract } from "./contract.mjs"; +import { UNICODE_VERSION, allAssigned, comparisonKey, nfc } from "./unicode.mjs"; + +const PATH_POLICY_VERSION = "portable-source-v4"; + +/** @typedef {import("./types.js").PathRule} PathRule @typedef {import("./types.js").PolicyDocument} PolicyDocument */ + +/** A path the policy refuses: `code` is the golden vectors' shared vocabulary, `rule` the excluding rule's id. */ +export class PathViolation extends Error { + /** @param {string} code @param {string} path @param {string} [rule] */ + constructor(code, path, rule) { + super(`${code}: ${JSON.stringify(path)}${rule ? ` (${rule})` : ""}`); + this.name = "PathViolation"; + this.code = code; + this.path = path; + this.rule = rule ?? null; + } +} + +const ASCII = /^\p{ASCII}*$/u; + +/** @param {string} pattern */ +const whole = (pattern) => new RegExp(`^(?:${pattern})$`, "su"); +/** @param {string} text */ +const escaped = (text) => text.replace(/[\\\]^-]/g, "\\$&"); + +/** @param {PolicyDocument} document */ +function compile(document) { + if (document.policy_version !== PATH_POLICY_VERSION) + throw new Error(`path policy is ${document.policy_version}, expected ${PATH_POLICY_VERSION}`); + if (document.unicode.version !== UNICODE_VERSION) + throw new Error( + `path policy pins Unicode ${document.unicode.version}, the table is ${UNICODE_VERSION}`, + ); + if (document.rules.at(-1)?.regex !== ".+") + throw new Error("path policy must end with a catch-all rule, so every path is classified"); + for (const rule of document.rules) + if ((rule.server_action === "allow") !== (rule.client_action === "include")) + throw new Error(`path rule ${rule.id}: the server allows exactly what clients include`); + const limits = document.path; + return { + limits, + invalidCharacter: new RegExp( + `[\\x00-\\x1f\\x7f-\\x9f\\ud800-\\udfff${escaped(limits.forbidden_characters)}]`, + "u", + ), + reservedSegment: whole(limits.reserved_segment_regex), + canonicalRoots: new Map( + limits.canonical_spelling_roots.map((root) => [comparisonKey(root), root]), + ), + rules: document.rules.map((rule) => ({ rule, pattern: whole(rule.regex) })), + storedRules: document.rules.map((rule) => ({ + rule, + pattern: whole( + rule.id === "agent-client-state" + ? document.stored_manifest.legacy_agent_state_regex + : rule.regex, + ), + })), + prefilter: new Set(document.client_prefilter.names), + symlinkPrefixes: document.client_symlinks.skip_prefixes, + }; +} + +/** @type {ReturnType | null} */ +let compiled = null; +/** The policy, read and compiled when a path is first checked: an app that never syncs never reads it. */ +const policy = () => (compiled ??= compile(readContract("path-policy.json"))); + +/** Every segment replaced by its comparison key. @param {string} path */ +const foldedPath = (path) => path.split("/").map(comparisonKey).join("/"); + +/** The first rule matching a path's folded spelling. @param {string} path @returns {PathRule} */ +export function classifyPath(path) { + const folded = foldedPath(path); + const found = policy().rules.find(({ pattern }) => pattern.test(folded)); + if (!found) throw new Error("the path policy's catch-all rule did not match"); + return found.rule; +} + +/** Checks 1 to 10 of the registry's `path.checks`: the ones about the string itself. @param {string} path */ +function checkSpelling(path) { + const { limits, invalidCharacter } = policy(); + if (!path) throw new PathViolation("path_empty", path); + if (invalidCharacter.test(path)) throw new PathViolation("path_invalid_character", path); + if (!ASCII.test(path) && !allAssigned(path)) + throw new PathViolation("path_unassigned_code_point", path); + if (nfc(path) !== path) throw new PathViolation("path_not_nfc", path); + if (Buffer.byteLength(path, "utf8") > limits.max_path_bytes) + throw new PathViolation("path_too_long", path); + if (path.startsWith("/")) throw new PathViolation("path_not_relative", path); + return checkSegments(path, limits); +} +/** @param {string} path @param {PolicyDocument["path"]} limits */ +function checkSegments(path, limits) { + const segments = path.split("/"); + if (segments.some((segment) => !segment)) throw new PathViolation("path_empty_segment", path); + if (segments.some((segment) => segment === "." || segment === "..")) + throw new PathViolation("path_dot_segment", path); + if (segments.some((segment) => Buffer.byteLength(segment, "utf8") > limits.max_segment_bytes)) + throw new PathViolation("segment_too_long", path); + if (segments.some((segment) => segment.endsWith(".") || segment.endsWith(" "))) + throw new PathViolation("segment_trailing_dot_or_space", path); + return segments; +} + +/** `path` unchanged when every client can store it and the policy lets it travel; throws PathViolation otherwise, + * naming the first failing check in the registry's order. @param {string} path + * @param {boolean} [stored] */ +export function validatePath(path, stored = false) { + const segments = checkSpelling(path); + const keys = segments.map(comparisonKey); + const { reservedSegment, canonicalRoots } = policy(); + const rules = stored ? policy().storedRules : policy().rules; + if (keys.some((key) => reservedSegment.test(key))) throw new PathViolation("reserved_name", path); + const root = canonicalRoots.get(keys[0] ?? ""); + if (root !== undefined && segments[0] !== root) + throw new PathViolation("reserved_path_alias", path); + const folded = keys.join("/"); + const found = rules.find(({ pattern }) => pattern.test(folded)); + if (!found) throw new Error("the path policy's catch-all rule did not match"); + if (found.rule.server_action === "reject") + throw new PathViolation("excluded_path", path, found.rule.id); + if (!found.pattern.test(path)) + throw new PathViolation("reserved_path_alias", path, found.rule.id); + return path; +} + +/** Refuses duplicates, and any two paths (or a path and a directory prefix) one filesystem would store as one name. + * Each path must already pass validatePath. @param {readonly string[]} paths */ +export function checkInventoryPaths(paths) { + const seen = { spellingByKey: new Map(), fileKeys: new Set(), directoryKeys: new Set() }; + for (const path of paths) { + const segments = path.split("/"); + const keys = segments.map(comparisonKey); + for (let depth = 1; depth <= segments.length; depth++) + notePrefix(seen, path, { + prefix: segments.slice(0, depth).join("/"), + key: keys.slice(0, depth).join("/"), + isFile: depth === segments.length, + }); + } +} + +/** One prefix of `path`, against every prefix before it, in the server's order of checks. + * @param {{ spellingByKey: Map, fileKeys: Set, directoryKeys: Set }} seen + * @param {string} path @param {{ prefix: string, key: string, isFile: boolean }} at */ +function notePrefix(seen, path, { prefix, key, isFile }) { + const spelling = seen.spellingByKey.get(key) ?? prefix; + seen.spellingByKey.set(key, spelling); + if (isFile && seen.fileKeys.has(key)) + throw new PathViolation(spelling === prefix ? "duplicate_path" : "path_collision", path); + if (spelling !== prefix) throw new PathViolation("path_collision", path); + if (isFile ? seen.directoryKeys.has(key) : seen.fileKeys.has(key)) + throw new PathViolation("file_directory_collision", path); + (isFile ? seen.fileKeys : seen.directoryKeys).add(key); +} + +/** The registry's `client_prefilter`: a name (macOS's `Icon\r`) skipped before any path check. @param {string} name */ +export const prefiltered = (name) => policy().prefilter.has(name); + +/** The registry's `client_symlinks`: a link under `assets/podcast/` is skipped instead of failing the capture. + * @param {string} path */ +export const skippedSymlink = (path) => + policy().symlinkPrefixes.some((prefix) => foldedPath(path).startsWith(prefix)); + +/** The literal text a rule's regex starts with, up to its first metacharacter. @param {string} regex */ +function literalPrefix(regex) { + let text = ""; + for (let i = 0; i < regex.length; i++) { + const char = regex[i] ?? ""; + if (char === "\\" && /[./-]/.test(regex[i + 1] ?? "")) text += regex[++i]; + else if (/[\w/-]/.test(char)) text += char; + else break; + } + return text; +} + +/** Whether no file under folder `dir` can be listed, so a capture need not open it: its first matching rule + * excludes the folder and all below it, and no include rule before that one can reach inside. @param {string} dir */ +export function excludedFolder(dir) { + const folded = foldedPath(dir); + const at = policy().rules.findIndex( + ({ pattern, rule }) => + rule.client_action !== "include" && pattern.test(folded) && pattern.test(`${folded}/x`), + ); + if (at < 0) return false; + return policy() + .rules.slice(0, at) + .every(({ rule }) => { + if (rule.client_action !== "include") return true; + const prefix = literalPrefix(rule.regex); + return !(prefix.startsWith(`${folded}/`) || `${folded}/`.startsWith(prefix)); + }); +} diff --git a/packages/share/src/sources/projectState.mjs b/packages/share/src/sources/projectState.mjs new file mode 100644 index 0000000000..cfbc77337f --- /dev/null +++ b/packages/share/src/sources/projectState.mjs @@ -0,0 +1,59 @@ +// @ts-check +// What the HyperFrames CLI keeps in a project's .hyperframes folder that a capture must honour: render outputs written +// outside renders/ (left out of every manifest), an open agent turn and a held project lock (no capture until both +// end). The formats are the pinned hyperframes CLI's, version 1 of render-outputs.json. +import { readFile } from "node:fs/promises"; +import { join } from "node:path"; + +/** A predicate for the paths the project's render-outputs.json lists, and everything under them; none when the file + * is missing or not version 1. @param {string} root @returns {Promise<(rel: string) => boolean>} */ +export async function readRenderOutputs(root) { + const raw = await readFile(join(root, ".hyperframes", "render-outputs.json"), "utf8").catch( + () => null, + ); + /** @type {{ version?: unknown, paths?: unknown } | null} */ + let record = null; + try { + record = raw === null ? null : JSON.parse(raw); + } catch { + record = null; + } + const paths = + record?.version === 1 && Array.isArray(record.paths) + ? record.paths + .filter((path) => typeof path === "string") + .map((path) => path.replace(/\\/g, "/")) + : []; + const listed = new Set(paths); + return (rel) => listed.has(rel) || paths.some((path) => rel.startsWith(`${path}/`)); +} + +/** Whether a pid still runs: EPERM is a process another user owns. @param {number} pid */ +function alive(pid) { + try { + process.kill(pid, 0); + return true; + } catch (error) { + return /** @type {NodeJS.ErrnoException} */ (error).code === "EPERM"; + } +} + +/** An open agent turn (its history-turn.json exists) or a project lock whose holder still runs. + * @param {string} root */ +export async function settledState(root) { + const dir = join(root, ".hyperframes"); + const turn = await readFile(join(dir, "history-turn.json")).then( + () => true, + () => false, + ); + const lock = await readFile(join(dir, "project.lock"), "utf8").catch(() => null); + /** @type {{ pid?: unknown } | null} */ + let holder = null; + try { + holder = lock === null ? null : JSON.parse(lock); + } catch { + holder = null; + } + const locked = lock !== null && (typeof holder?.pid !== "number" || alive(holder.pid)); + return { agentTurnOpen: turn, projectLocked: locked }; +} diff --git a/packages/share/src/sources/store.mjs b/packages/share/src/sources/store.mjs new file mode 100644 index 0000000000..c614d9f62a --- /dev/null +++ b/packages/share/src/sources/store.mjs @@ -0,0 +1,82 @@ +// @ts-check +import { createHash } from "node:crypto"; +import { constants } from "node:fs"; +import { lstat, open } from "node:fs/promises"; +import { join } from "node:path"; +import { errorCode, mkdirInside, writeJsonAtomic } from "../storage.mjs"; +import { parseStoredManifest } from "./manifest.mjs"; + +/** @param {unknown} value @returns {value is Record} */ +const object = (value) => typeof value === "object" && value !== null && !Array.isArray(value); +/** @param {unknown} raw @param {import("./types.js").BindingKey} key @returns {import("./types.js").Binding} */ +function bindingOf(raw, key) { + if ( + !object(raw) || + raw.version !== 1 || + raw.backend !== key.backend || + raw.account !== key.account || + raw.projectPath !== key.projectPath || + typeof raw.compositionId !== "string" || + typeof raw.ownerSpaceId !== "string" + ) + throw new Error( + "Source binding belongs to another account, backend or project. Reset explicitly before sharing this copy.", + ); + checkSnapshots(raw); + return /** @type {import("./types.js").Binding} */ (/** @type {unknown} */ (raw)); +} + +/** @param {Record} raw */ +function checkSnapshots(raw) { + if ( + raw.base !== null && + (!object(raw.base) || + typeof raw.base.snapshotId !== "string" || + parseStoredManifest(raw.base.manifest).sha256 !== raw.base.manifestSha256) + ) + throw new Error("Invalid source base snapshot."); + if ( + raw.inflight !== null && + (!object(raw.inflight) || + typeof raw.inflight.idempotencyKey !== "string" || + parseStoredManifest(raw.inflight.manifest).sha256 !== raw.inflight.manifestSha256) + ) + throw new Error("Invalid pending source upload."); +} + +/** Project-local state is excluded by the portable source policy. Account/root mismatches fail closed, including copied folders. + * @returns {import("./adapterTypes.js").SourceStore} */ +export function createProjectShareSourceStore() { + /** @param {import("./types.js").BindingKey} key */ + const location = async (key) => { + const dir = await mkdirInside(key.projectPath, ".hyperframes"); + const environment = createHash("sha256").update(key.backend).digest("hex").slice(0, 16); + return join(dir, `share-sync.${environment}.json`); + }; + return { + read: async (key) => { + const file = await location(key); + const handle = await open(file, constants.O_RDONLY | constants.O_NOFOLLOW).catch((error) => { + if (errorCode(error) === "ENOENT") return null; + throw error; + }); + if (!handle) return null; + try { + if (!(await handle.stat()).isFile()) + throw new Error("Source binding must be a regular file."); + return bindingOf(JSON.parse(await handle.readFile("utf8")), key); + } finally { + await handle.close(); + } + }, + write: async (binding) => { + const file = await location(binding); + const held = await lstat(file).catch((error) => { + if (errorCode(error) === "ENOENT") return null; + throw error; + }); + if (held && !held.isFile()) throw new Error("Source binding must be a regular file."); + await writeJsonAtomic(file, binding); + }, + }; +} diff --git a/packages/share/src/sources/transfer.mjs b/packages/share/src/sources/transfer.mjs new file mode 100644 index 0000000000..8359483f53 --- /dev/null +++ b/packages/share/src/sources/transfer.mjs @@ -0,0 +1,196 @@ +// @ts-check +// Bytes to signed storage URLs: one file or multipart range, streamed and hashed as it is sent. +// Large media costs one chunk at a time. Storage URLs carry their own signature, never an OAuth bearer. +import { createHash } from "node:crypto"; +import { constants, createReadStream } from "node:fs"; +import { open, realpath } from "node:fs/promises"; +import { dirname } from "node:path"; +import { setTimeout as sleep } from "node:timers/promises"; +import { trustedUploadUrl } from "../reviewUpload.mjs"; + +/** Why a transfer stopped. `expired`: the signed URL no longer works (ask for a new one). `exists`: a create-only PUT + * found the object already written. `changed`: the file's bytes are not the ones captured. `unreadable`: the file + * could not be read (a drive unplugged, a file deleted). `corrupt`: downloaded bytes do not hash to what was asked. + * `transient`: the network or the store failed; the same request may be sent again. */ +export class TransferError extends Error { + /** @param {"expired" | "exists" | "changed" | "unreadable" | "corrupt" | "transient" | "refused"} kind + * @param {{ status?: number, path?: string }} [about] */ + constructor(kind, about = {}) { + super(`composition sync transfer: ${kind}${about.status ? ` (${about.status})` : ""}`); + this.name = "TransferError"; + this.kind = kind; + this.status = about.status ?? 0; + this.path = about.path ?? null; + } +} + +/** @param {unknown} error */ +export const isAbort = (error) => + error instanceof Error && (error.name === "AbortError" || error.name === "TimeoutError"); + +/** @param {number} ms @param {AbortSignal} [signal] */ +export const realWait = (ms, signal) => sleep(ms, undefined, { signal }); + +/** S3 answers 403 for a URL past its expiry; a 5xx or 429 is worth sending again. @param {number} status + * @returns {TransferError} */ +function refusalOf(status) { + if (status === 403) return new TransferError("expired", { status }); + if (status === 412) return new TransferError("exists", { status }); + if (status === 429 || status >= 500) return new TransferError("transient", { status }); + return new TransferError("refused", { status }); +} + +/** @param {string} file */ +async function openSource(file) { + const handle = await open(file, constants.O_RDONLY | constants.O_NOFOLLOW); + try { + const stat = await handle.stat(); + if (!stat.isFile() || (await realpath(dirname(file))) !== dirname(file)) + throw new TransferError("unreadable", { path: file }); + return handle; + } catch (error) { + await handle.close(); + throw error; + } +} + +/** @param {string} file @param {number} start @param {number} length @param {(bytes: number) => void} onBytes */ +async function hashedBody(file, start, length, onBytes) { + const handle = await openSource(file); + const hash = createHash("sha256"); + const seen = { bytes: 0, ended: false, readError: /** @type {unknown} */ (null) }; + const chunks = + length === 0 + ? null + : handle + .createReadStream({ start, end: start + length - 1, autoClose: false }) + [Symbol.asyncIterator](); + const body = new ReadableStream( + { + async pull(controller) { + if (!chunks) return controller.close(); + try { + const { value, done } = await chunks.next(); + if (done) return ((seen.ended = true), controller.close()); + hash.update(value); + seen.bytes += value.length; + onBytes(value.length); + controller.enqueue(value); + } catch (error) { + seen.readError = error; + controller.error(error); + } + }, + cancel: () => void chunks?.return?.(), + }, + { highWaterMark: 0 }, + ); + return { body, seen, digest: () => hash.digest("hex"), close: () => handle.close() }; +} + +/** What the bytes taken from the file say about it once a PUT ended: unreadable, changed (shorter than captured, + * or another hash), or null when they are the captured bytes, all of them or a prefix the network cut short. + * @param {Awaited>} sent @param {{ length: number, sha256: string, path: string }} expected */ +function fileProblem({ seen, digest }, { length, sha256, path }) { + if (seen.readError) return new TransferError("unreadable", { path }); + const short = seen.ended && seen.bytes < length; + if (short || (seen.bytes === length && digest() !== sha256)) + return new TransferError("changed", { path }); + return null; +} + +/** PUTs bytes of `file` to a signed URL with exactly the headers the grant signed. Resolves once storage keeps them; + * the bytes sent must hash to `sha256`, or it throws `changed` whatever storage answered. + * @param {{ fetchImpl: typeof fetch, url: string, headers: Record, file: string, path: string, + * start: number, length: number, sha256: string, signal: AbortSignal, onBytes?: (bytes: number) => void, stallMs?: number }} put */ +export async function putRange(put) { + const { fetchImpl, url, headers, file, start, length, signal } = put; + const target = trustedUploadUrl(url); + if (!target) throw new TransferError("refused", { path: put.path }); + signal.throwIfAborted(); + const stall = new AbortController(); + const sent = await hashedBody(file, start, length, (bytes) => { + timer.refresh(); + put.onBytes?.(bytes); + }); + const timer = setTimeout(() => stall.abort(), put.stallMs ?? 60_000); + // Node's fetch needs `duplex` for a streamed body; lib.dom's RequestInit does not name it. + const init = { + method: "PUT", + headers, + body: sent.body, + duplex: "half", + redirect: "error", + signal: AbortSignal.any([signal, stall.signal]), + }; + /** @type {Response} */ + let reply; + try { + reply = await fetchImpl(target.href, /** @type {RequestInit} */ (init)); + } catch (error) { + signal.throwIfAborted(); + if (!stall.signal.aborted && isAbort(error)) throw error; + throw fileProblem(sent, put) ?? new TransferError("transient", { path: put.path }); + } finally { + clearTimeout(timer); + await sent.close(); + } + await reply.body?.cancel().catch(() => {}); + const problem = fileProblem(sent, put); + if (problem) throw problem; + if (!reply.ok) throw refusalOf(reply.status); +} + +/** Each part's SHA-256 (parts of `partBytes`, the last one shorter) and the whole file's, in one read. + * @param {string} file @param {number} size @param {number} partBytes @param {AbortSignal} signal */ +export async function partDigests(file, size, partBytes, signal) { + const whole = createHash("sha256"); + /** @type {string[]} */ + const parts = []; + let part = createHash("sha256"); + let inPart = 0; + for await (const chunk of createReadStream(file, { highWaterMark: 1 << 20, signal })) { + whole.update(chunk); + for (let at = 0; at < chunk.length; ) { + const take = Math.min(partBytes - inPart, chunk.length - at); + part.update(chunk.subarray(at, at + take)); + inPart += take; + at += take; + if (inPart === partBytes) { + parts.push(part.digest("hex")); + part = createHash("sha256"); + inPart = 0; + } + } + } + if (inPart > 0 || parts.length === 0) parts.push(part.digest("hex")); + return { + parts, + whole: whole.digest("hex"), + complete: parts.length === Math.ceil(size / partBytes), + }; +} + +/** Runs `work` over `items`, `limit` at a time. The first failure stops new work; the rest finish, then it throws. + * @template T @param {readonly T[]} items @param {number} limit @param {(item: T) => Promise} work */ +export async function eachLimit(items, limit, work) { + let next = 0; + const failure = { failed: false, error: /** @type {unknown} */ (null) }; + const worker = async () => { + while (!failure.failed && next < items.length) { + const item = /** @type {T} */ (items[next++]); + try { + await work(item); + } catch (error) { + if (!failure.failed) Object.assign(failure, { failed: true, error }); + } + } + }; + await Promise.all(Array.from({ length: Math.min(limit, items.length) }, worker)); + if (failure.failed) throw failure.error; +} + +/** The wait before attempt `attempt` (from 1): doubling from `baseMs`, at most `maxMs`, or what the server asked. + * @param {number} attempt @param {number | null} [askedMs] */ +export const backoffMs = (attempt, askedMs = null, baseMs = 1_000, maxMs = 30_000) => + askedMs ?? Math.min(maxMs, baseMs * 2 ** (attempt - 1)); diff --git a/packages/share/src/sources/types.d.ts b/packages/share/src/sources/types.d.ts new file mode 100644 index 0000000000..725024ddf4 --- /dev/null +++ b/packages/share/src/sources/types.d.ts @@ -0,0 +1,353 @@ +export interface SyncTooBig { + limit: "file_count" | "file_size" | "project_size" | "manifest_size"; + actual: number; + maximum: number; + biggest: { path: string; size: number }[]; +} + +/** A file that keeps a project from being captured; it is never left out silently. */ +export interface SyncCaptureProblem { + path: string; + problem: "symlink" | "special-file" | "unreadable" | "invalid-name" | "changed" | "no-entrypoint"; + /** For `invalid-name`, the path policy's code (`reserved_name`, `path_collision`, ...). */ + code?: string; +} + +export interface ManifestFile { + path: string; + sha256: string; + size: number; +} + +export interface ManifestDocument { + format_version: 1; + entrypoint: "index.html"; + files: ManifestFile[]; +} + +/** A valid manifest: its document in canonical order, the canonical bytes and their SHA-256. */ +export interface Manifest { + document: ManifestDocument; + canonical: Buffer; + sha256: string; +} + +export interface Violation { + code: string; + path?: string; + rule?: string; +} + +export type LimitName = SyncTooBig["limit"]; + +export interface Limits { + maxFiles: number; + maxFileBytes: number; + maxProjectBytes: number; + maxManifestBytes: number; +} + +export type OverLimit = SyncTooBig; + +type ClientAction = "include" | "exclude" | "wait_then_exclude"; + +export interface PathRule { + id: string; + regex: string; + client_action: ClientAction; + server_action: "allow" | "reject"; +} + +/** The fields of contract/path-policy.json this client reads. */ +export interface PolicyDocument { + policy_version: string; + stored_manifest: { legacy_agent_state_regex: string }; + unicode: { version: string }; + rules: PathRule[]; + path: { + max_path_bytes: number; + max_segment_bytes: number; + forbidden_characters: string; + reserved_segment_regex: string; + canonical_spelling_roots: string[]; + }; + client_prefilter: { names: string[] }; + client_symlinks: { skip_prefixes: string[] }; +} + +export type CaptureProblem = SyncCaptureProblem; + +/** What an owner workspace's plan allows composition sync, as the limits route answered it. `unread` when it could not + * be read: `not-deployed` is a server without the route (a 404), and nothing is refused on an unread answer. */ +export type SyncLimitsRead = + | { + at: "read"; + syncAllowed: boolean; + maxCompositions: number; + /** Live compositions in the workspace when it was read. */ + compositions: number; + push: Limits; + } + | { at: "unread"; why: "not-deployed" | "offline" | "failed" }; + +/** A file a capture lists, before hashing. */ +export interface Found { + path: string; + full: string; + size: number; + mtimeMs: number; + ino: number; + dev: number; +} + +export interface Walk { + files: Found[]; + problems: CaptureProblem[]; + waiting: string[]; + skippedLinks: string[]; +} + +export type Capture = + | { + at: "captured"; + manifest: Manifest; + settled: { agentTurnOpen: boolean; projectLocked: boolean }; + waiting: string[]; + skippedLinks: string[]; + } + | { at: "problems"; problems: CaptureProblem[] } + | { at: "too-big"; over: OverLimit }; + +export type SyncErrorKind = + | "offline" + | "signed-out" + | "malformed" + | "not-enabled" + | "byok" + | "no-write-role" + | "forbidden" + | "composition-not-found" + | "not-found" + | "too-large" + | "reference-invalid" + | "upload-not-pending" + | "active-uploads-exceeded" + | "file-not-writable" + | "idempotency-key-reused" + | "request-in-progress" + | "snapshot-not-downloadable" + | "conflict-not-open" + | "download-expired" + | "invalid-parameter" + | "plan-required" + | "limit-reached" + | "rate-limited" + | "unavailable" + | "server-error" + | "refused"; + +export interface Composition { + id: string; + spaceId: string; + title: string; + createdBy: string; + /** Null before the first publish. */ + latestSnapshotId: string | null; + createdAt: string; + updatedAt: string; +} + +export interface Snapshot { + id: string; + compositionId: string; + baseSnapshotId: string | null; + publicationOutcome: "published" | "conflict_saved"; + conflictedWithSnapshotId: string | null; + conflictState: "open" | "resolved" | "discarded" | null; + resolvedBySnapshotId: string | null; + createdBy: string; + createdByName?: string | null; + clientType: string; + summary: string | null; + summarySource: string; + manifestSha256: string; + createdAt: string; + /** Only with `include=manifest`, and only once its bytes hash to manifestSha256. */ + manifest: Manifest | null; +} + +type UploadStatus = "pending" | "verifying" | "completed" | "failed" | "expired"; + +export interface UploadReceipt { + uploadId: string; + compositionId: string; + snapshotId: string; + status: UploadStatus; + /** Why a failed upload failed: cancelled, content_incomplete, verification_timeout, access_revoked. */ + errorCode: string | null; + baseSnapshotId: string | null; + resolvesConflictSnapshotIds: string[]; + manifestSha256: string; + uploadDeadline: string; + verificationDeadline: string | null; + completedAt: string | null; + result: { + snapshotId: string; + publicationOutcome: "published" | "conflict_saved"; + conflictedWithSnapshotId: string | null; + } | null; +} + +interface BlobRef { + sha256: string; + size: number; +} + +export interface BeginResult extends UploadReceipt { + /** Already saved in the base or a named conflict: never uploaded. */ + present: BlobRef[]; + /** To upload through upload-urls before submitting. */ + needed: BlobRef[]; + /** False for a replay of the same push under the same Idempotency-Key. */ + created: boolean; +} + +export interface BeginRequest { + idempotencyKey: string; + baseSnapshotId: string | null; + resolvesConflictSnapshotIds: string[]; + summary: { text: string; source: "user" | "agent" } | null; + manifest: Manifest; +} + +interface PartGrant { + partNumber: number; + length: number; + url: string; + headers: Record; +} + +export interface FileGrant { + sha256: string; + size: number; + expiresAt: string; + /** Files up to 64 MiB: one PUT. */ + url: string | null; + headers: Record; + /** Files over 64 MiB: the file's one multipart upload, and the requested parts. */ + multipartUploadId: string | null; + parts: PartGrant[]; +} + +export interface GrantRequest { + sha256: string; + multipartUploadId?: string; + parts?: { partNumber: number; sha256: string }[]; +} + +export interface DownloadBatch { + snapshotId: string; + manifestSha256: string; + continuationToken: string; + continuationExpiresAt: string; + urls: { sha256: string; size: number; url: string; expiresAt: string }[]; +} + +export interface Page { + items: T[]; + nextToken: string | null; +} + +export type CompositionRead = + | { at: "fresh"; composition: Composition; etag: string | null } + | { at: "unchanged"; etag: string }; + +/** Whose binding: the backend's API host, the signed-in account (accountPrincipal) and the project's real path. */ +export interface BindingKey { + backend: string; + account: string; + projectPath: string; +} + +/** A push recorded before its Begin is sent, so a lost answer is recovered by sending the same body under the same + * Idempotency-Key; the upload's ids and deadlines land once an answer comes back. */ +export interface InflightUpload { + idempotencyKey: string; + baseSnapshotId: string | null; + resolvesConflictSnapshotIds: string[]; + summary: { text: string; source: "user" | "agent" } | null; + manifest: ManifestDocument; + manifestSha256: string; + uploadId: string | null; + snapshotId: string | null; + uploadDeadline: string | null; + verificationDeadline: string | null; + begunAt: number; + /** Files whose bytes reached staging, by SHA-256, so a resumed send does not write them again. */ + sent?: string[]; + /** Each multipart file's pinned upload and the parts already written, by the file's SHA-256. */ + multipart?: Record; +} + +export interface Binding extends BindingKey { + version: 1; + /** Client-generated, kept before the first request so a retried create names the same composition. */ + compositionId: string; + ownerSpaceId: string; + /** The owner workspace as the account's list last named it, so a project whose workspace the account left can + * still be named. Absent from bindings made before it was kept, and until a list names the workspace. */ + owner?: { name: string; kind: "personal" | "team" }; + boundAt: number; + /** The composition as last read, and the ETag it came with; null before the create was answered. */ + composition: Composition | null; + etag: string | null; + /** The snapshot this copy was last sent as or got from, with its manifest, so local changes need no network. */ + base: { snapshotId: string; manifest: ManifestDocument; manifestSha256: string } | null; + inflight: InflightUpload | null; + /** Set while Get from the cloud is filling a folder it made, until the folder is added to Home. Until then the + * folder is not a project on this Mac, and the next Get of the composition finishes it. */ + gettingFromCloud?: true; + /** What the marker that Get put in its folder holds: the only proof a file of that name there is not the person's. */ + getToken?: string; + /** Set on the folder a Duplicate fills from the cloud: it is bound only while it downloads, so no Get ever opens + * it, and its binding goes once latest is in (duplicate.mjs). */ + duplicate?: true; + /** The conflicts this Mac's sends saved, newest last: Compare names them as this project's, not another + * computer's. */ + savedHere?: string[]; + /** Set on a binding Work on {owner}'s project made from a share: the account reaches the owner's workspace through + * that share's grant, not membership, so every request names the review project (sync-backed sharing C5). */ + sharedFrom?: SharedFrom; +} + +/** The share a binding came from: its review project, the owner's name and their workspace's, as the share named + * them when it was opened. */ +export interface SharedFrom { + reviewProjectId: string; + owner: string; + workspace: string | null; +} + +/** A workspace's last refusal of a new composition: not admitted to sync yet, or encrypted (BYOK). */ +export interface SpaceRefusal { + kind: "not-enabled" | "byok"; + at: number; +} + +/** One send or get under way for a project: the binding it owns until it ends, and where its states go. */ +export interface UploadJob { + api: import("./api.mjs").SourceApi; + space: string; + composition: string; + uploadId: string; + inflight: InflightUpload; + local: Map; + needed: { sha256: string; size: number }[]; + fetchImpl: typeof fetch; + wait: (ms: number, signal?: AbortSignal) => Promise; + signal: AbortSignal; + now: () => number; + persist: () => void; + onBytes: (bytes: number) => void; + onFile: () => void; +} diff --git a/packages/share/src/sources/unicode.mjs b/packages/share/src/sources/unicode.mjs new file mode 100644 index 0000000000..54eb3561fc --- /dev/null +++ b/packages/share/src/sources/unicode.mjs @@ -0,0 +1,163 @@ +// @ts-check +// Use the bundled Unicode 15.1 tables so path comparison is independent of the runtime Unicode version. +import { readContract } from "./contract.mjs"; + +export const UNICODE_VERSION = "15.1.0"; + +/** @typedef {{ unicode_version: string, casefold: Record, combining: Record, + * decomposition: Record, composition: Record, + * assigned_ranges: [number, number][] }} UnicodeTableFile */ + +const HANGUL_BASE = 0xac00; +const HANGUL_COUNT = 11172; +const L_BASE = 0x1100; +const V_BASE = 0x1161; +const T_BASE = 0x11a7; +const L_COUNT = 19; +const V_COUNT = 21; +const T_COUNT = 28; +const N_COUNT = V_COUNT * T_COUNT; + +/** The table re-keyed by code point, decompositions fully expanded. @param {UnicodeTableFile} raw */ +function tablesOf(raw) { + if (raw.unicode_version !== UNICODE_VERSION) + throw new Error(`unicode table is ${raw.unicode_version}, expected ${UNICODE_VERSION}`); + const hex = (/** @type {string} */ code) => Number.parseInt(code, 16); + const casefold = new Map(Object.entries(raw.casefold).map(([code, to]) => [hex(code), to])); + const combining = new Map(Object.entries(raw.combining).map(([code, cc]) => [hex(code), cc])); + const direct = new Map(Object.entries(raw.decomposition).map(([code, seq]) => [hex(code), seq])); + /** @param {number} code @returns {number[]} */ + const expand = (code) => direct.get(code)?.flatMap(expand) ?? [code]; + const decomposition = new Map([...direct.keys()].map((code) => [code, expand(code)])); + const composition = new Map( + Object.entries(raw.composition).map(([pair, composite]) => { + const [first = "", second = ""] = pair.split(","); + return [`${hex(first)},${hex(second)}`, composite]; + }), + ); + const starts = raw.assigned_ranges.map(([start]) => start); + const ends = raw.assigned_ranges.map(([, end]) => end); + return { casefold, combining, decomposition, composition, starts, ends }; +} + +/** @type {ReturnType | null} */ +let loaded = null; +/** The table, read and indexed when a path is first compared: an app that never syncs never reads it. */ +const tables = () => (loaded ??= tablesOf(readContract("unicode-15.1.0.json"))); + +/** @param {number} code */ +const classOf = (code) => tables().combining.get(code) ?? 0; + +/** @param {number} code @returns {readonly number[]} */ +function decompose(code) { + const syllable = code - HANGUL_BASE; + if (syllable >= 0 && syllable < HANGUL_COUNT) { + const trailing = syllable % T_COUNT; + const leading = [ + L_BASE + Math.floor(syllable / N_COUNT), + V_BASE + Math.floor((syllable % N_COUNT) / T_COUNT), + ]; + return trailing ? [...leading, T_BASE + trailing] : leading; + } + return tables().decomposition.get(code) ?? [code]; +} + +/** @param {number} first @param {number} second @returns {number | undefined} */ +function composePair(first, second) { + if (first >= L_BASE && first < L_BASE + L_COUNT && second >= V_BASE && second < V_BASE + V_COUNT) + return HANGUL_BASE + ((first - L_BASE) * V_COUNT + second - V_BASE) * T_COUNT; + return composeSyllable(first, second) ?? tables().composition.get(`${first},${second}`); +} +/** @param {number} first @param {number} second */ +function composeSyllable(first, second) { + if ( + first >= HANGUL_BASE && + first < HANGUL_BASE + HANGUL_COUNT && + (first - HANGUL_BASE) % T_COUNT === 0 && + second > T_BASE && + second < T_BASE + T_COUNT + ) + return first + second - T_BASE; +} + +/** Canonical decomposition then canonical ordering of combining marks. @param {string} value */ +function orderedCodes(value) { + /** @type {number[]} */ + const ordered = []; + for (const char of value) { + for (const code of decompose(char.codePointAt(0) ?? 0)) { + const current = classOf(code); + let position = ordered.length; + while (current && position && classOf(ordered[position - 1] ?? 0) > current) position--; + ordered.splice(position, 0, code); + } + } + return ordered; +} + +/** Canonical composition under the pinned Unicode table. @param {number[]} ordered */ +function composed(ordered) { + /** @type {number[]} */ + const result = []; + let starter = 0; + let lastClass = 0; + for (const code of ordered) { + const current = classOf(code); + const head = result[starter]; + const composite = head === undefined ? undefined : composePair(head, code); + if (composite !== undefined && (lastClass < current || lastClass === 0)) { + result[starter] = composite; + continue; + } + if (current === 0) starter = result.length; + result.push(code); + lastClass = current; + } + return String.fromCodePoint(...result); +} + +const ASCII = /^\p{ASCII}*$/u; + +/** NFC (UAX #15) under the pinned table. @param {string} value */ +export const nfc = (value) => (ASCII.test(value) ? value : composed(orderedCodes(value))); + +/** Default full case folding (status C and F), so `ß` folds to `ss`. @param {string} value */ +function fullCasefold(value) { + if (ASCII.test(value)) return value.toLowerCase(); + let folded = ""; + for (const char of value) folded += tables().casefold.get(char.codePointAt(0) ?? 0) ?? char; + return folded; +} + +/** Whether every code point is assigned in Unicode 15.1. @param {string} value */ +export function allAssigned(value) { + const { starts, ends } = tables(); + for (const char of value) { + const code = char.codePointAt(0) ?? 0; + let low = 0; + let high = starts.length; + while (low < high) { + const middle = (low + high) >>> 1; + if ((starts[middle] ?? Infinity) <= code) low = middle + 1; + else high = middle; + } + if (low === 0 || code > (ends[low - 1] ?? -1)) return false; + } + return true; +} + +/** Directory names repeat across a manifest's paths, and each segment is keyed twice (policy, then collisions). */ +const KEYS_KEPT = 16384; +/** @type {Map} */ +const keys = new Map(); + +/** The spelling two names share on a case-insensitive or normalizing filesystem: NFC(casefold(NFC(value))). + * @param {string} value */ +export function comparisonKey(value) { + const known = keys.get(value); + if (known !== undefined) return known; + const key = nfc(fullCasefold(nfc(value))); + if (keys.size >= KEYS_KEPT) keys.clear(); + keys.set(value, key); + return key; +} diff --git a/packages/share/src/sources/upload.mjs b/packages/share/src/sources/upload.mjs new file mode 100644 index 0000000000..ea84f720c8 --- /dev/null +++ b/packages/share/src/sources/upload.mjs @@ -0,0 +1,201 @@ +// @ts-check +import { randomUUID } from "node:crypto"; +import { join } from "node:path"; +import { NotWritable, uploadNeeded } from "./uploadFiles.mjs"; +import { parseStoredManifest } from "./manifest.mjs"; +import { SyncApiError } from "./errors.mjs"; + +/** @typedef {import("./adapterTypes.js").SourceRun} SourceRun + * @typedef {Pick} SourceUpload + * @typedef {import("./types.js").UploadReceipt} UploadReceipt */ +/** @param {SourceUpload & Pick} run */ +async function begin(run) { + const { binding, manifest, api, store } = run; + if (!binding.inflight) { + binding.inflight = { + idempotencyKey: randomUUID(), + baseSnapshotId: binding.base?.snapshotId ?? null, + resolvesConflictSnapshotIds: [], + summary: null, + manifest: manifest.document, + manifestSha256: manifest.sha256, + uploadId: null, + snapshotId: null, + uploadDeadline: null, + verificationDeadline: null, + begunAt: Date.now(), + sent: [], + multipart: {}, + }; + await store.write(binding); + } + const inflight = binding.inflight; + const receipt = await api.begin(binding.ownerSpaceId, binding.compositionId, { + ...inflight, + manifest, + }); + assertReceipt(binding, receipt); + Object.assign(inflight, { + uploadId: receipt.uploadId, + snapshotId: receipt.snapshotId, + uploadDeadline: receipt.uploadDeadline, + verificationDeadline: receipt.verificationDeadline, + }); + await store.write(binding); + return receipt; +} +/** @param {SourceRun} run @param {import("./types.js").BeginResult} receipt */ +async function sendFiles(run, receipt) { + const { binding, manifest, store } = run; + if (!binding.inflight) throw new Error("Missing source upload intent."); + const local = new Map( + manifest.document.files.map((file) => [ + file.sha256, + { path: file.path, full: join(binding.projectPath, file.path) }, + ]), + ); + const known = new Map(manifest.document.files.map((file) => [file.sha256, file.size])); + for (const blob of receipt.needed) + if (known.get(blob.sha256) !== blob.size) + throw new Error("Upload requested an unknown source file."); + let persisted = Promise.resolve(); + await uploadNeeded({ + api: run.api, + space: binding.ownerSpaceId, + composition: binding.compositionId, + uploadId: receipt.uploadId, + inflight: binding.inflight, + local, + needed: receipt.needed, + fetchImpl: run.fetchImpl, + wait: run.wait, + signal: run.signal, + now: Date.now, + persist: () => { + persisted = persisted.then(() => store.write(binding)); + }, + onBytes: run.onProgress, + onFile: () => {}, + }).finally(() => persisted); + return run.api.submit(binding.ownerSpaceId, binding.compositionId, receipt.uploadId); +} +/** @param {SourceUpload["binding"]} binding @param {UploadReceipt} receipt */ +function assertReceipt(binding, receipt) { + const saved = binding.inflight; + if (!saved || receipt.manifestSha256 !== saved.manifestSha256) + throw new Error("Source upload receipt does not match the captured project."); + if (receipt.compositionId !== binding.compositionId) + throw new Error("Source upload receipt does not match the composition."); + if (saved.uploadId !== null && receipt.uploadId !== saved.uploadId) + throw new Error("Source upload receipt identity changed."); + if (saved.snapshotId !== null && receipt.snapshotId !== saved.snapshotId) + throw new Error("Source snapshot identity changed."); +} + +/** @param {SourceUpload} job @param {UploadReceipt} receipt */ +async function storePublished({ binding, store }, receipt) { + const saved = binding.inflight; + const result = receipt.result; + if (!saved || !result || result.snapshotId !== receipt.snapshotId) + throw new Error("Source snapshot identity changed."); + binding.base = { + snapshotId: result.snapshotId, + manifest: saved.manifest, + manifestSha256: saved.manifestSha256, + }; + await clearIntent({ binding, store }); +} + +/** @param {Pick} job */ +async function clearIntent({ binding, store }) { + binding.inflight = null; + await store.write(binding); +} + +/** @param {SourceUpload} job @param {UploadReceipt} receipt */ +async function cancelPending({ binding, api }, receipt) { + const { ownerSpaceId, compositionId } = binding; + try { + return await api.cancel(ownerSpaceId, compositionId, receipt.uploadId); + } catch (error) { + if (!(error instanceof SyncApiError) || error.kind !== "upload-not-pending") throw error; + return api.status(ownerSpaceId, compositionId, receipt.uploadId); + } +} + +/** Resolve an older capture before starting an upload for the current files. + * @param {SourceUpload} job @returns {Promise} */ +export async function recoverSourceUpload(job) { + const { binding, api } = job; + const saved = binding.inflight; + if (!saved) return null; + const manifest = parseStoredManifest(saved.manifest); + if (manifest.sha256 !== saved.manifestSha256) + throw new Error("Saved source upload manifest does not match its checksum."); + let receipt = saved.uploadId + ? await api.status(binding.ownerSpaceId, binding.compositionId, saved.uploadId) + : await begin({ ...job, manifest }); + assertReceipt(binding, receipt); + if (receipt.status === "pending") receipt = await cancelPending(job, receipt); + assertReceipt(binding, receipt); + return recoverReceipt(job, receipt); +} + +/** @param {SourceUpload} job @param {UploadReceipt} receipt */ +async function recoverReceipt(job, receipt) { + if (receipt.status === "completed") { + if (receipt.result?.publicationOutcome !== "published") + return { at: /** @type {const} */ ("unavailable"), reason: "source_conflict" }; + await storePublished(job, receipt); + } else if (terminalFailure(receipt)) await clearIntent(job); + else return { at: /** @type {const} */ ("unavailable"), reason: "source_verification_pending" }; + return null; +} + +/** @param {UploadReceipt} receipt */ +const terminalFailure = (receipt) => receipt.status === "failed" || receipt.status === "expired"; + +/** Only published verification results can become share source; conflict_saved is preserved for explicit recovery. + * @param {SourceRun} run @returns {Promise} */ +export async function uploadSource(run) { + const receipt = await begin(run); + let status; + try { + status = receipt.status === "pending" ? await sendFiles(run, receipt) : receipt; + } catch (error) { + if (!(error instanceof NotWritable)) throw error; + return ( + (await recoverSourceUpload(run)) ?? { + at: "unavailable", + reason: "source_upload_not_writable", + } + ); + } + const deadline = Date.now() + run.timeoutMs; + while (status.status === "verifying") { + run.signal.throwIfAborted(); + if (Date.now() >= deadline) return { at: "unavailable", reason: "source_verification_pending" }; + await run.wait(1000, run.signal); + status = await run.api.status( + run.binding.ownerSpaceId, + run.binding.compositionId, + receipt.uploadId, + ); + } + assertReceipt(run.binding, status); + if (status.status !== "completed" || !status.result) { + if (terminalFailure(status)) await clearIntent(run); + return { at: "unavailable", reason: status.errorCode ?? `source_upload_${status.status}` }; + } + if (status.result.publicationOutcome !== "published") + return { at: "unavailable", reason: "source_conflict" }; + await storePublished(run, status); + return { + at: "ready", + snapshot: { + space_id: run.binding.ownerSpaceId, + composition_id: run.binding.compositionId, + snapshot_id: status.snapshotId, + }, + }; +} diff --git a/packages/share/src/sources/uploadFiles.mjs b/packages/share/src/sources/uploadFiles.mjs new file mode 100644 index 0000000000..adfaa5d467 --- /dev/null +++ b/packages/share/src/sources/uploadFiles.mjs @@ -0,0 +1,263 @@ +// @ts-check +// The files a Begin said are needed, written to the upload's staging through signed URLs: one PUT for a file up to +// 64 MiB, parts of 64 MiB above that through the file's one pinned multipart upload. URLs live at most 15 minutes, so +// one about to end is asked for again; a send resumed after a quit skips what the in-flight record says was written. +import { SyncApiError } from "./errors.mjs"; +import { + TransferError, + backoffMs, + eachLimit, + isAbort, + partDigests, + putRange, +} from "./transfer.mjs"; +import { lstat } from "node:fs/promises"; + +/** @typedef {import("./types.js").FileGrant} FileGrant @typedef {import("./types.js").GrantRequest} GrantRequest + * @typedef {import("./types.js").InflightUpload} InflightUpload */ + +/** The server's single-PUT ceiling and part size. */ +const PART_BYTES = 64 * 1024 * 1024; +const GRANT_FILES = 100; +const PARTS_PER_GRANT = 8; +const AT_ONCE = 4; +const ATTEMPTS = 5; +/** A URL with less than this left is asked for again rather than started. */ +const URL_MARGIN_MS = 60_000; + +/** The file's multipart upload can take no more parts (`hyperframes_composition_upload_file_not_writable`): this + * upload cannot finish, so its owner must resolve it before a retry can begin a new one. */ +export class NotWritable extends Error { + constructor() { + super("composition sync: a file's multipart upload can no longer take parts"); + this.name = "NotWritable"; + } +} + +/** @typedef {import("./types.js").UploadJob} UploadJob */ + +/** @param {UploadJob} job @param {unknown} error @param {number} attempt the attempt that just failed, from 1 + * @returns {Promise} whether to try again */ +async function againAfter(job, error, attempt) { + if (attempt >= ATTEMPTS || isAbort(error)) return false; + const transient = + (error instanceof TransferError && (error.kind === "transient" || error.kind === "corrupt")) || + (error instanceof SyncApiError && + ["offline", "unavailable", "server-error", "rate-limited"].includes(error.kind)); + if (!transient) return false; + const asked = error instanceof SyncApiError ? error.retryAfterMs : null; + await job.wait(backoffMs(attempt, asked), job.signal); + return true; +} + +/** A refusal of a pinned multipart id, which its refusal says to drop and ask again without. + * @param {unknown} error @param {GrantRequest[]} asked */ +const wrongPinnedId = (error, asked) => + error instanceof SyncApiError && + error.kind === "invalid-parameter" && + (error.param ?? "").endsWith("multipart_upload_id") && + asked.some((file) => file.multipartUploadId); + +/** Write grants for `files`, sent again on a transient failure. A file that can take no more parts throws NotWritable. + * @param {UploadJob} job @param {GrantRequest[]} files @returns {Promise} */ +async function grant(job, files) { + let asked = files; + for (let attempt = 1; ; attempt++) { + try { + return await job.api.uploadUrls(job.space, job.composition, job.uploadId, asked); + } catch (error) { + if (error instanceof SyncApiError && error.kind === "file-not-writable") + throw new NotWritable(); + if (wrongPinnedId(error, asked)) + asked = asked.map(({ multipartUploadId: _dropped, ...file }) => file); + else if (!(await againAfter(job, error, attempt))) throw error; + } + } +} + +/** @param {UploadJob} job @param {string} sha256 */ +function localFile(job, sha256) { + const file = job.local.get(sha256); + if (!file) throw new Error(`composition sync: needed file ${sha256} is not in the capture`); + return file; +} + +/** @typedef {{ url: string, headers: Record, expiresAt: string }} Signed + * @typedef {{ number: number, sha256: string, start: number, length: number }} Part + * @typedef {{ file: { path: string, full: string }, start: number, length: number, sha256: string }} Bytes */ + +/** One PUT attempt: `done` once stored (or found already stored), `expired` when storage says the URL has, else the + * failure. Bytes counted for an attempt that failed are taken back. + * @param {UploadJob} job @param {Signed} held @param {Bytes} bytes + * @returns {Promise<"done" | "expired" | { failed: unknown }>} */ +async function attemptPut(job, held, { file, ...range }) { + let sent = 0; + try { + await putRange({ + fetchImpl: job.fetchImpl, + url: held.url, + headers: held.headers, + file: file.full, + path: file.path, + ...range, + signal: job.signal, + onBytes: (count) => ((sent += count), job.onBytes(count)), + }); + return "done"; + } catch (error) { + job.onBytes(-sent); + if (!(error instanceof TransferError)) return { failed: error }; + if (error.kind === "exists") return (job.onBytes(range.length), "done"); + return error.kind === "expired" ? "expired" : { failed: error }; + } +} + +/** Writes `bytes` through `given`, or a fresh grant when it is missing or about to end; asks again when storage says + * the URL ended, and sends again after a transient failure. + * @param {UploadJob} job @param {Signed | null} given @param {() => Promise} fresh @param {Bytes} bytes */ +async function putWithGrant(job, given, fresh, bytes) { + const usable = (/** @type {Signed | null} */ signed) => + signed && Date.parse(signed.expiresAt) - job.now() >= URL_MARGIN_MS ? signed : null; + let held = usable(given); + for (let attempt = 1; ; attempt++) { + held ??= await fresh(); + const outcome = await attemptPut(job, held, bytes); + if (outcome === "done") return; + if (outcome === "expired" && attempt < ATTEMPTS) held = null; + else { + const failed = outcome === "expired" ? new TransferError("expired") : outcome.failed; + if (!(await againAfter(job, failed, attempt))) throw failed; + } + } +} + +/** @param {FileGrant | undefined} held @returns {Signed} */ +function singleUrl(held) { + if (!held?.url) throw new Error("composition sync: a single-PUT grant came without its URL"); + return { url: held.url, headers: held.headers, expiresAt: held.expiresAt }; +} + +/** Files up to 64 MiB: grants a hundred at a time, written four at once. @param {UploadJob} job + * @param {{ sha256: string, size: number }[]} blobs */ +async function sendSmall(job, blobs) { + for (let at = 0; at < blobs.length; at += GRANT_FILES) { + const batch = blobs.slice(at, at + GRANT_FILES); + const grants = await grant( + job, + batch.map((blob) => ({ sha256: blob.sha256 })), + ); + const bySha = new Map(grants.map((one) => [one.sha256, one])); + await eachLimit(batch, AT_ONCE, async (blob) => { + const given = bySha.has(blob.sha256) ? singleUrl(bySha.get(blob.sha256)) : null; + const fresh = async () => singleUrl((await grant(job, [{ sha256: blob.sha256 }]))[0]); + const bytes = { + file: localFile(job, blob.sha256), + start: 0, + length: blob.size, + sha256: blob.sha256, + }; + await putWithGrant(job, given, fresh, bytes); + (job.inflight.sent ??= []).push(blob.sha256); + job.persist(); + job.onFile(); + }); + } +} + +/** Grants for `parts` of a multipart file, naming its pinned upload once one is known, and keeping the id the server + * pins. @param {UploadJob} job @param {{ sha256: string }} blob @param {Part[]} parts */ +async function partGrants(job, blob, parts) { + const pinned = job.inflight.multipart?.[blob.sha256]; + const [held] = await grant(job, [ + { + sha256: blob.sha256, + ...(pinned && { multipartUploadId: pinned.uploadId }), + parts: parts.map((part) => ({ partNumber: part.number, sha256: part.sha256 })), + }, + ]); + if (!held?.multipartUploadId) + throw new Error("composition sync: a multipart grant came without its upload id"); + // Parts recorded as written belong to the pinned upload; another id would leave them unwritten. + if (pinned && pinned.uploadId !== held.multipartUploadId) throw new NotWritable(); + if (!pinned) { + job.inflight.multipart = { + ...job.inflight.multipart, + [blob.sha256]: { uploadId: held.multipartUploadId, partsDone: [] }, + }; + job.persist(); + } + return { expiresAt: held.expiresAt, parts: held.parts }; +} + +/** The file's parts still to write, each with its SHA-256; throws `changed` when the file no longer hashes to the + * captured SHA-256. @param {UploadJob} job @param {{ sha256: string, size: number }} blob + * @returns {Promise} */ +async function partsToSend(job, blob) { + const file = localFile(job, blob.sha256); + const digests = await partDigests(file.full, blob.size, PART_BYTES, job.signal).catch((error) => { + if (isAbort(error)) throw error; + throw new TransferError("unreadable", { path: file.path }); + }); + if (digests.whole !== blob.sha256 || !digests.complete) + throw new TransferError("changed", { path: file.path }); + const done = new Set(job.inflight.multipart?.[blob.sha256]?.partsDone ?? []); + return digests.parts + .map((sha256, index) => ({ + number: index + 1, + sha256, + start: index * PART_BYTES, + length: Math.min(PART_BYTES, blob.size - index * PART_BYTES), + })) + .filter((part) => !done.has(part.number)); +} + +/** A file over 64 MiB, eight parts a grant, four parts at once; its size and time are compared after, so a file that + * changed while its parts were read fails as changed. @param {UploadJob} job + * @param {{ sha256: string, size: number }} blob */ +async function sendLarge(job, blob) { + const file = localFile(job, blob.sha256); + const before = await lstat(file.full); + const parts = await partsToSend(job, blob); + job.onBytes(blob.size - parts.reduce((sum, part) => sum + part.length, 0)); + for (let at = 0; at < parts.length; at += PARTS_PER_GRANT) { + const batch = parts.slice(at, at + PARTS_PER_GRANT); + const granted = await partGrants(job, blob, batch); + const byNumber = new Map(granted.parts.map((part) => [part.partNumber, part])); + await eachLimit(batch, AT_ONCE, async (part) => { + const signed = byNumber.get(part.number); + const given = signed + ? { url: signed.url, headers: signed.headers, expiresAt: granted.expiresAt } + : null; + const fresh = async () => { + const again = await partGrants(job, blob, [part]); + const one = again.parts[0]; + if (!one) throw new Error("composition sync: a part grant came without its part"); + return { url: one.url, headers: one.headers, expiresAt: again.expiresAt }; + }; + await putWithGrant(job, given, fresh, { file, ...part }); + job.inflight.multipart?.[blob.sha256]?.partsDone.push(part.number); + job.persist(); + }); + } + const after = await lstat(file.full).catch(() => null); + if (!after || after.size !== before.size || after.mtimeMs !== before.mtimeMs) + throw new TransferError("changed", { path: file.path }); + (job.inflight.sent ??= []).push(blob.sha256); + job.persist(); + job.onFile(); +} + +/** Writes every needed file the in-flight record does not list as sent. @param {UploadJob} job */ +export async function uploadNeeded(job) { + const sent = new Set(job.inflight.sent ?? []); + const waiting = job.needed.filter((blob) => !sent.has(blob.sha256)); + for (const blob of job.needed.filter((one) => sent.has(one.sha256))) { + job.onBytes(blob.size); + job.onFile(); + } + await sendSmall( + job, + waiting.filter((blob) => blob.size <= PART_BYTES), + ); + for (const blob of waiting.filter((one) => one.size > PART_BYTES)) await sendLarge(job, blob); +} diff --git a/packages/share/src/sources/wire.mjs b/packages/share/src/sources/wire.mjs new file mode 100644 index 0000000000..55c6472acc --- /dev/null +++ b/packages/share/src/sources/wire.mjs @@ -0,0 +1,205 @@ +// @ts-check +// Parse and validate sync API responses at the transport boundary. +import { ManifestInvalid, parseStoredManifest } from "./manifest.mjs"; +import { SyncApiError } from "./errors.mjs"; + +/** @typedef {import("./types.js").SyncLimitsRead} SyncLimitsRead + * @typedef {import("./types.js").Composition} Composition @typedef {import("./types.js").Snapshot} Snapshot + * @typedef {import("./types.js").UploadReceipt} UploadReceipt @typedef {import("./types.js").BeginResult} BeginResult + * @typedef {import("./types.js").FileGrant} FileGrant @typedef {import("./types.js").DownloadBatch} DownloadBatch */ + +/** @param {string} field */ +const malformed = (field) => + new SyncApiError("malformed", { detail: `missing or mistyped ${field}` }); + +/** @param {unknown} value @param {string} field @returns {Record} */ +export function objectOf(value, field) { + if (typeof value !== "object" || value === null || Array.isArray(value)) throw malformed(field); + return /** @type {Record} */ (value); +} +/** @param {Record} o @param {string} key @returns {string} */ +const str = (o, key) => { + const value = o[key]; + if (typeof value !== "string") throw malformed(key); + return value; +}; +/** Absent (the server drops nulls) reads as null. @param {Record} o @param {string} key */ +const optStr = (o, key) => (o[key] === undefined || o[key] === null ? null : str(o, key)); +/** @param {Record} o @param {string} key @returns {number} */ +const int = (o, key) => { + const value = o[key]; + if (typeof value !== "number" || !Number.isSafeInteger(value)) throw malformed(key); + return value; +}; +/** @param {Record} o @param {string} key @returns {unknown[]} */ +const list = (o, key) => { + const value = o[key] ?? []; + if (!Array.isArray(value)) throw malformed(key); + return value; +}; +/** @param {Record} o @param {string} key @returns {Record} */ +const headers = (o, key) => { + const value = objectOf(o[key] ?? {}, key); + return Object.fromEntries(Object.keys(value).map((name) => [name, str(value, name)])); +}; +/** @template {string} T @param {Record} o @param {string} key @param {readonly T[]} allowed + * @returns {T} */ +const oneOf = (o, key, allowed) => { + const value = str(o, key); + if (!allowed.includes(/** @type {T} */ (value))) throw malformed(key); + return /** @type {T} */ (value); +}; + +/** @param {unknown} raw @returns {Composition} */ +export function compositionOf(raw) { + const o = objectOf(raw, "composition"); + return { + id: str(o, "id"), + spaceId: str(o, "space_id"), + title: str(o, "title"), + createdBy: str(o, "created_by"), + latestSnapshotId: optStr(o, "latest_snapshot_id"), + createdAt: str(o, "created_at"), + updatedAt: str(o, "updated_at"), + }; +} + +/** The snapshot's manifest, trusted only when its canonical bytes hash to the snapshot's manifest_sha256. + * @param {unknown} raw @param {string} sha256 */ +function snapshotManifestOf(raw, sha256) { + const o = objectOf(raw, "manifest"); + try { + const manifest = parseStoredManifest(o.document); + if (manifest.sha256 !== sha256) throw malformed("manifest.document (sha256)"); + return manifest; + } catch (error) { + if (error instanceof ManifestInvalid) throw malformed(`manifest.document (${error.code})`); + throw error; + } +} + +/** @param {unknown} raw @returns {Snapshot} */ +export function snapshotOf(raw) { + const o = objectOf(raw, "snapshot"); + const manifestSha256 = str(o, "manifest_sha256"); + const state = optStr(o, "conflict_state"); + if (state !== null && !["open", "resolved", "discarded"].includes(state)) + throw malformed("conflict_state"); + return { + id: str(o, "id"), + compositionId: str(o, "composition_id"), + baseSnapshotId: optStr(o, "base_snapshot_id"), + publicationOutcome: oneOf( + o, + "publication_outcome", + /** @type {const} */ (["published", "conflict_saved"]), + ), + conflictedWithSnapshotId: optStr(o, "conflicted_with_snapshot_id"), + conflictState: /** @type {Snapshot["conflictState"]} */ (state), + resolvedBySnapshotId: optStr(o, "resolved_by_snapshot_id"), + createdBy: str(o, "created_by"), + createdByName: optStr(o, "created_by_name"), + clientType: str(o, "client_type"), + summary: optStr(o, "summary"), + summarySource: str(o, "summary_source"), + manifestSha256, + createdAt: str(o, "created_at"), + manifest: o.manifest === undefined ? null : snapshotManifestOf(o.manifest, manifestSha256), + }; +} + +const UPLOAD_STATUSES = /** @type {const} */ ([ + "pending", + "verifying", + "completed", + "failed", + "expired", +]); + +/** @param {unknown} raw @returns {UploadReceipt} */ +export function uploadOf(raw) { + const o = objectOf(raw, "upload"); + const result = o.result === undefined || o.result === null ? null : objectOf(o.result, "result"); + return { + uploadId: str(o, "upload_id"), + compositionId: str(o, "composition_id"), + snapshotId: str(o, "snapshot_id"), + status: oneOf(o, "status", UPLOAD_STATUSES), + errorCode: optStr(o, "error_code"), + baseSnapshotId: optStr(o, "base_snapshot_id"), + resolvesConflictSnapshotIds: list(o, "resolves_conflict_snapshot_ids").map((id) => { + if (typeof id !== "string") throw malformed("resolves_conflict_snapshot_ids"); + return id; + }), + manifestSha256: str(o, "manifest_sha256"), + uploadDeadline: str(o, "upload_deadline"), + verificationDeadline: optStr(o, "verification_deadline"), + completedAt: optStr(o, "completed_at"), + result: result && { + snapshotId: str(result, "snapshot_id"), + publicationOutcome: oneOf( + result, + "publication_outcome", + /** @type {const} */ (["published", "conflict_saved"]), + ), + conflictedWithSnapshotId: optStr(result, "conflicted_with_snapshot_id"), + }, + }; +} + +/** @param {unknown} raw @param {string} field */ +const blobsOf = (raw, field) => + list(objectOf(raw, field), field).map((item) => { + const blob = objectOf(item, field); + return { sha256: str(blob, "sha256"), size: int(blob, "size") }; + }); + +/** @param {unknown} raw @param {boolean} created @returns {BeginResult} */ +export const beginOf = (raw, created) => ({ + ...uploadOf(raw), + present: blobsOf(raw, "present"), + needed: blobsOf(raw, "needed"), + created, +}); + +/** @param {unknown} raw @returns {FileGrant[]} */ +export const grantsOf = (raw) => + list(objectOf(raw, "grants"), "files").map((item) => { + const o = objectOf(item, "files"); + return { + sha256: str(o, "sha256"), + size: int(o, "size"), + expiresAt: str(o, "expires_at"), + url: optStr(o, "url"), + headers: headers(o, "headers"), + multipartUploadId: optStr(o, "multipart_upload_id"), + parts: list(o, "parts").map((part) => { + const p = objectOf(part, "parts"); + return { + partNumber: int(p, "part_number"), + length: int(p, "length"), + url: str(p, "url"), + headers: headers(p, "headers"), + }; + }), + }; + }); + +/** @param {unknown} raw @returns {Extract} */ +export function syncLimitsOf(raw) { + const o = objectOf(raw, "limits answer"); + const limits = objectOf(o.limits, "limits"); + if (typeof o.sync_allowed !== "boolean") throw malformed("sync_allowed"); + return { + at: "read", + syncAllowed: o.sync_allowed, + maxCompositions: int(limits, "max_compositions"), + compositions: int(objectOf(o.usage, "usage"), "compositions"), + push: { + maxFiles: int(limits, "max_files"), + maxFileBytes: int(limits, "max_file_bytes"), + maxProjectBytes: int(limits, "max_project_bytes"), + maxManifestBytes: int(limits, "max_manifest_bytes"), + }, + }; +} diff --git a/packages/share/tests/fixtures/compositionSync/manifest-vectors.json b/packages/share/tests/fixtures/compositionSync/manifest-vectors.json new file mode 100644 index 0000000000..bf116fcbb5 --- /dev/null +++ b/packages/share/tests/fixtures/compositionSync/manifest-vectors.json @@ -0,0 +1,4125 @@ +{ + "policy_version": "portable-source-v4", + "about": "Golden vectors for the composition sync manifest. valid: build the canonical bytes from `manifest`; UTF-8 encoding `canonical` gives those bytes and `manifest_sha256` is their SHA-256. invalid: validating `manifest` fails with `error.code` (and `error.rule` for path-policy rules). limits: with `limits`, the first exceeded limit in the order file_count, file_size, project_size, manifest_size is `limit` (null: admitted). stored: base64 `body` is stored manifest bytes; reading them requires they are already canonical.", + "valid": [ + { + "name": "minimal", + "description": "Only the entrypoint.", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + } + ] + }, + "canonical": "{\"entrypoint\":\"index.html\",\"files\":[{\"path\":\"index.html\",\"sha256\":\"0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051\",\"size\":10}],\"format_version\":1}", + "manifest_sha256": "63fddbeea6bfbcae0680f96a62407a25e20cce85fb4adc41d96c638df88c4547", + "file_count": 1, + "project_bytes": 10 + }, + { + "name": "project-source", + "description": "Authored source and config, including project.json, lockfiles and AGENTS.md.", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "hyperframes.json", + "sha256": "5b1abe04cdbb4d91eaa411a7106e6cee742d8f3eefac446c2f3da0db37ccbcc8", + "size": 16 + }, + { + "path": "meta.json", + "sha256": "61e02d96a75c79ab075606e62395cfebf1fc27a12f685dbd6acf7c9b108bb377", + "size": 9 + }, + { + "path": "project.json", + "sha256": "7680eb66f8e7b2155dfc25c4aa16a606a8fd3decb988265f218f3e11a8afa2be", + "size": 12 + }, + { + "path": "package.json", + "sha256": "7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519", + "size": 12 + }, + { + "path": "package-lock.json", + "sha256": "053150b640a7ce75eff69d1a22cae7f0f94ad64ce9a855db544dda0929316519", + "size": 17 + }, + { + "path": "AGENTS.md", + "sha256": "a54ff182c7e8acf56acfd6e4b9c3ff41e2c41a31c9b211b2deb9df75d9a478f9", + "size": 9 + }, + { + "path": "brief.md", + "sha256": "014c777fd4684e1994134767ade25b4db7b7e23d86379b6c01c2a2b22aac6641", + "size": 8 + }, + { + "path": "scenes/intro.html", + "sha256": "3da5cbe92a3fa8870e22a9ce0161ef4359e9bdf221e2a361e20775ff2c11f79b", + "size": 17 + }, + { + "path": "scenes/outro/scene.js", + "sha256": "8911604a0800a4704a94f85ae7d1783a562d3222a049ac2778246a1ba24e7219", + "size": 21 + }, + { + "path": "assets/logo.png", + "sha256": "90580d12fbd0edace7745ba49a090bc882d32c9f7d6bfa1345df935f7a6816d3", + "size": 15 + } + ] + }, + "canonical": "{\"entrypoint\":\"index.html\",\"files\":[{\"path\":\"AGENTS.md\",\"sha256\":\"a54ff182c7e8acf56acfd6e4b9c3ff41e2c41a31c9b211b2deb9df75d9a478f9\",\"size\":9},{\"path\":\"assets/logo.png\",\"sha256\":\"90580d12fbd0edace7745ba49a090bc882d32c9f7d6bfa1345df935f7a6816d3\",\"size\":15},{\"path\":\"brief.md\",\"sha256\":\"014c777fd4684e1994134767ade25b4db7b7e23d86379b6c01c2a2b22aac6641\",\"size\":8},{\"path\":\"hyperframes.json\",\"sha256\":\"5b1abe04cdbb4d91eaa411a7106e6cee742d8f3eefac446c2f3da0db37ccbcc8\",\"size\":16},{\"path\":\"index.html\",\"sha256\":\"0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051\",\"size\":10},{\"path\":\"meta.json\",\"sha256\":\"61e02d96a75c79ab075606e62395cfebf1fc27a12f685dbd6acf7c9b108bb377\",\"size\":9},{\"path\":\"package-lock.json\",\"sha256\":\"053150b640a7ce75eff69d1a22cae7f0f94ad64ce9a855db544dda0929316519\",\"size\":17},{\"path\":\"package.json\",\"sha256\":\"7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519\",\"size\":12},{\"path\":\"project.json\",\"sha256\":\"7680eb66f8e7b2155dfc25c4aa16a606a8fd3decb988265f218f3e11a8afa2be\",\"size\":12},{\"path\":\"scenes/intro.html\",\"sha256\":\"3da5cbe92a3fa8870e22a9ce0161ef4359e9bdf221e2a361e20775ff2c11f79b\",\"size\":17},{\"path\":\"scenes/outro/scene.js\",\"sha256\":\"8911604a0800a4704a94f85ae7d1783a562d3222a049ac2778246a1ba24e7219\",\"size\":21}],\"format_version\":1}", + "manifest_sha256": "6c9a9486ad8df805d78074f5a86715db115635e7ad5fcdf90a18d41a3ecbe34d", + "file_count": 11, + "project_bytes": 146 + }, + { + "name": "input-order-ignored", + "description": "The same files as project-source in a different order produce the same canonical bytes.", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "scenes/outro/scene.js", + "sha256": "8911604a0800a4704a94f85ae7d1783a562d3222a049ac2778246a1ba24e7219", + "size": 21 + }, + { + "path": "project.json", + "sha256": "7680eb66f8e7b2155dfc25c4aa16a606a8fd3decb988265f218f3e11a8afa2be", + "size": 12 + }, + { + "path": "assets/logo.png", + "sha256": "90580d12fbd0edace7745ba49a090bc882d32c9f7d6bfa1345df935f7a6816d3", + "size": 15 + }, + { + "path": "package-lock.json", + "sha256": "053150b640a7ce75eff69d1a22cae7f0f94ad64ce9a855db544dda0929316519", + "size": 17 + }, + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "brief.md", + "sha256": "014c777fd4684e1994134767ade25b4db7b7e23d86379b6c01c2a2b22aac6641", + "size": 8 + }, + { + "path": "meta.json", + "sha256": "61e02d96a75c79ab075606e62395cfebf1fc27a12f685dbd6acf7c9b108bb377", + "size": 9 + }, + { + "path": "AGENTS.md", + "sha256": "a54ff182c7e8acf56acfd6e4b9c3ff41e2c41a31c9b211b2deb9df75d9a478f9", + "size": 9 + }, + { + "path": "scenes/intro.html", + "sha256": "3da5cbe92a3fa8870e22a9ce0161ef4359e9bdf221e2a361e20775ff2c11f79b", + "size": 17 + }, + { + "path": "package.json", + "sha256": "7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519", + "size": 12 + }, + { + "path": "hyperframes.json", + "sha256": "5b1abe04cdbb4d91eaa411a7106e6cee742d8f3eefac446c2f3da0db37ccbcc8", + "size": 16 + } + ] + }, + "canonical": "{\"entrypoint\":\"index.html\",\"files\":[{\"path\":\"AGENTS.md\",\"sha256\":\"a54ff182c7e8acf56acfd6e4b9c3ff41e2c41a31c9b211b2deb9df75d9a478f9\",\"size\":9},{\"path\":\"assets/logo.png\",\"sha256\":\"90580d12fbd0edace7745ba49a090bc882d32c9f7d6bfa1345df935f7a6816d3\",\"size\":15},{\"path\":\"brief.md\",\"sha256\":\"014c777fd4684e1994134767ade25b4db7b7e23d86379b6c01c2a2b22aac6641\",\"size\":8},{\"path\":\"hyperframes.json\",\"sha256\":\"5b1abe04cdbb4d91eaa411a7106e6cee742d8f3eefac446c2f3da0db37ccbcc8\",\"size\":16},{\"path\":\"index.html\",\"sha256\":\"0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051\",\"size\":10},{\"path\":\"meta.json\",\"sha256\":\"61e02d96a75c79ab075606e62395cfebf1fc27a12f685dbd6acf7c9b108bb377\",\"size\":9},{\"path\":\"package-lock.json\",\"sha256\":\"053150b640a7ce75eff69d1a22cae7f0f94ad64ce9a855db544dda0929316519\",\"size\":17},{\"path\":\"package.json\",\"sha256\":\"7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519\",\"size\":12},{\"path\":\"project.json\",\"sha256\":\"7680eb66f8e7b2155dfc25c4aa16a606a8fd3decb988265f218f3e11a8afa2be\",\"size\":12},{\"path\":\"scenes/intro.html\",\"sha256\":\"3da5cbe92a3fa8870e22a9ce0161ef4359e9bdf221e2a361e20775ff2c11f79b\",\"size\":17},{\"path\":\"scenes/outro/scene.js\",\"sha256\":\"8911604a0800a4704a94f85ae7d1783a562d3222a049ac2778246a1ba24e7219\",\"size\":21}],\"format_version\":1}", + "manifest_sha256": "6c9a9486ad8df805d78074f5a86715db115635e7ad5fcdf90a18d41a3ecbe34d", + "file_count": 11, + "project_bytes": 146 + }, + { + "name": "utf8-byte-order", + "description": "Files sort by UTF-8 bytes: U+E000 sorts before U+1F600 although UTF-16 code-unit order puts the emoji first.", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "caf\u00e9.txt", + "sha256": "5996d1f7905c244c4fa2c38e29b4f1f2374831626a311489221ccb3f233cc4e8", + "size": 9 + }, + { + "path": "\ud83d\ude00.js", + "sha256": "3a104efc97344482a5f82f4649422c643e3ab1ad93d0683cb06a772cf32918e0", + "size": 7 + }, + { + "path": "\ue000.js", + "sha256": "09540a21a6bce7a79a8cbe278124fa179e1571b4611827f4d644e84c788ddda6", + "size": 6 + }, + { + "path": "line\u2028break.txt", + "sha256": "926be9d9e0842bee270b2999e0807889ff18237bea036da6573ce5fa09a4ccc6", + "size": 16 + }, + { + "path": "\u65e5\u672c\u8a9e/\u30b7\u30fc\u30f3.html", + "sha256": "fc18b4689e367cd842408c2d6d47456e545e13d2b1924fb0026b09e58acbc203", + "size": 24 + }, + { + "path": "\ud55c\uad6d\uc5b4.html", + "sha256": "930ff314ffaac67ac51d1038a4cb06a83f72c51c0c82c59b02ffae303538df16", + "size": 14 + }, + { + "path": "Zebra.txt", + "sha256": "b88ccf27f74370d6261042b79259c3b4ce22a4a02ebce66f312d74c038ad3e30", + "size": 9 + }, + { + "path": "apple.txt", + "sha256": "7269b27861e2a5ba6947b6279bb5e66b23439d83a65a3c0cf529f5834ed2e7fb", + "size": 9 + } + ] + }, + "canonical": "{\"entrypoint\":\"index.html\",\"files\":[{\"path\":\"Zebra.txt\",\"sha256\":\"b88ccf27f74370d6261042b79259c3b4ce22a4a02ebce66f312d74c038ad3e30\",\"size\":9},{\"path\":\"apple.txt\",\"sha256\":\"7269b27861e2a5ba6947b6279bb5e66b23439d83a65a3c0cf529f5834ed2e7fb\",\"size\":9},{\"path\":\"caf\u00e9.txt\",\"sha256\":\"5996d1f7905c244c4fa2c38e29b4f1f2374831626a311489221ccb3f233cc4e8\",\"size\":9},{\"path\":\"index.html\",\"sha256\":\"0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051\",\"size\":10},{\"path\":\"line\u2028break.txt\",\"sha256\":\"926be9d9e0842bee270b2999e0807889ff18237bea036da6573ce5fa09a4ccc6\",\"size\":16},{\"path\":\"\u65e5\u672c\u8a9e/\u30b7\u30fc\u30f3.html\",\"sha256\":\"fc18b4689e367cd842408c2d6d47456e545e13d2b1924fb0026b09e58acbc203\",\"size\":24},{\"path\":\"\ud55c\uad6d\uc5b4.html\",\"sha256\":\"930ff314ffaac67ac51d1038a4cb06a83f72c51c0c82c59b02ffae303538df16\",\"size\":14},{\"path\":\"\ue000.js\",\"sha256\":\"09540a21a6bce7a79a8cbe278124fa179e1571b4611827f4d644e84c788ddda6\",\"size\":6},{\"path\":\"\ud83d\ude00.js\",\"sha256\":\"3a104efc97344482a5f82f4649422c643e3ab1ad93d0683cb06a772cf32918e0\",\"size\":7}],\"format_version\":1}", + "manifest_sha256": "0b646beea7798921286b56544f5fadf086121521a2248351ce596b858b2626f7", + "file_count": 9, + "project_bytes": 104 + }, + { + "name": "portable-hidden-and-media", + "description": "Completed .media assets with unused alternatives, .media/index.md, the named portable .hyperframes files, and hidden authored files.", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".media/video/unused-take.mp4", + "sha256": "a3e29b7ba3f66207df6182ec09ed749df364378cf2cfb8cf589163a6cdac93e2", + "size": 28 + }, + { + "path": ".media/images/image_001.png", + "sha256": "35037cf8cd8a2d3e2b20a04563ecba015e6404678af5631c0e9e3a50fec200de", + "size": 27 + }, + { + "path": ".media/index.md", + "sha256": "8a925d0e3cc08cd0ed4601d0f94e8a781881d1b3034d07fe11cc02d296a2ad43", + "size": 15 + }, + { + "path": ".hyperframes/transcripts/a.json", + "sha256": "7ffb8ceda0a4b872cc4a9ba63bdd040a70631e3343157454a95206f2fc9f27cf", + "size": 31 + }, + { + "path": ".hyperframes/transcripts/nested/b.json", + "sha256": "a5222ca2063d161da3e06294d2ab5c6c32d7692a1177bb0f79ddde4001deb47b", + "size": 38 + }, + { + "path": ".hyperframes/brand-kit.json", + "sha256": "dda44abb548e99aad3ec261c6b87c5f545eb09f8fb1b261d3c75a7cfc21bfa94", + "size": 27 + }, + { + "path": ".hyperframes/transcription.json", + "sha256": "bc0b9ef4215d81d0ae7adabc471993f63ac70a24a693f4f91b4c18a103dd9ba1", + "size": 31 + }, + { + "path": ".hyperframes/studio-manual-edits.json", + "sha256": "450ba94d0f2fbb1ac30cc5e1dcae043e2f7f970357984a6bdfaf2f2087904fe0", + "size": 37 + }, + { + "path": ".hyperframes/studio-motion.json", + "sha256": "205f890f2a576608d6f009ef4738fc2b81df387329f2e20bdf67356c5365b55d", + "size": 31 + }, + { + "path": ".hyperframes/caption-skin.html", + "sha256": "a2e2d9315c6a9e3437f752e69a8514d8c662f53a9ade33db2686fa9affaa97b2", + "size": 30 + }, + { + "path": ".media/preferences.json", + "sha256": "888316c0c00d9d6929423a311f302500134d74315226a6a78a7a73bf66b4ef58", + "size": 23 + }, + { + "path": ".media/CREDITS.md", + "sha256": "4056dedc9ad51868f89af43f34035af851bb566f6d30f804e57551da7ec0dd9c", + "size": 17 + }, + { + "path": ".gitignore", + "sha256": "bc37d034bad564583790a46f19d807abfe519c5671395fd494d8cce506c42947", + "size": 10 + }, + { + "path": ".gitattributes", + "sha256": "618cd5b83d62060ba3d027e314a21ceaf75d36067ff820db126642944145393e", + "size": 14 + }, + { + "path": ".hyperframesignore", + "sha256": "4f7382fe2d1d64d27e88900b9997a85f9d9fa42062f04aab7426b03cabba7497", + "size": 18 + }, + { + "path": "CLAUDE.md", + "sha256": "6ebdb617a8104a7756d0cf36578ab01103dc9f07e4dc6feb751296b9c402faf7", + "size": 9 + }, + { + "path": "deck.key", + "sha256": "8e11a86cf1052f458f6766baba49f519b80b3eee7c35433debd93483515626d4", + "size": 8 + }, + { + "path": "notes/TRANSCRIPTS/file.bin", + "sha256": "0392523321b470965a29a3ec513f460128fe11513b1dc2e2396fe510d5e67b15", + "size": 26 + }, + { + "path": "docs/node_modules.md", + "sha256": "ef0612da92e8204f7277982d4d3ce82b4589d200192fcfa74371a5b80365d5ba", + "size": 20 + }, + { + "path": "templates/env.example.md", + "sha256": "bf8e2a33ac126e948ed744ea606beb8f150409bbfcea9fbdf3184a710d0d3bff", + "size": 24 + } + ] + }, + "canonical": "{\"entrypoint\":\"index.html\",\"files\":[{\"path\":\".gitattributes\",\"sha256\":\"618cd5b83d62060ba3d027e314a21ceaf75d36067ff820db126642944145393e\",\"size\":14},{\"path\":\".gitignore\",\"sha256\":\"bc37d034bad564583790a46f19d807abfe519c5671395fd494d8cce506c42947\",\"size\":10},{\"path\":\".hyperframes/brand-kit.json\",\"sha256\":\"dda44abb548e99aad3ec261c6b87c5f545eb09f8fb1b261d3c75a7cfc21bfa94\",\"size\":27},{\"path\":\".hyperframes/caption-skin.html\",\"sha256\":\"a2e2d9315c6a9e3437f752e69a8514d8c662f53a9ade33db2686fa9affaa97b2\",\"size\":30},{\"path\":\".hyperframes/studio-manual-edits.json\",\"sha256\":\"450ba94d0f2fbb1ac30cc5e1dcae043e2f7f970357984a6bdfaf2f2087904fe0\",\"size\":37},{\"path\":\".hyperframes/studio-motion.json\",\"sha256\":\"205f890f2a576608d6f009ef4738fc2b81df387329f2e20bdf67356c5365b55d\",\"size\":31},{\"path\":\".hyperframes/transcription.json\",\"sha256\":\"bc0b9ef4215d81d0ae7adabc471993f63ac70a24a693f4f91b4c18a103dd9ba1\",\"size\":31},{\"path\":\".hyperframes/transcripts/a.json\",\"sha256\":\"7ffb8ceda0a4b872cc4a9ba63bdd040a70631e3343157454a95206f2fc9f27cf\",\"size\":31},{\"path\":\".hyperframes/transcripts/nested/b.json\",\"sha256\":\"a5222ca2063d161da3e06294d2ab5c6c32d7692a1177bb0f79ddde4001deb47b\",\"size\":38},{\"path\":\".hyperframesignore\",\"sha256\":\"4f7382fe2d1d64d27e88900b9997a85f9d9fa42062f04aab7426b03cabba7497\",\"size\":18},{\"path\":\".media/CREDITS.md\",\"sha256\":\"4056dedc9ad51868f89af43f34035af851bb566f6d30f804e57551da7ec0dd9c\",\"size\":17},{\"path\":\".media/images/image_001.png\",\"sha256\":\"35037cf8cd8a2d3e2b20a04563ecba015e6404678af5631c0e9e3a50fec200de\",\"size\":27},{\"path\":\".media/index.md\",\"sha256\":\"8a925d0e3cc08cd0ed4601d0f94e8a781881d1b3034d07fe11cc02d296a2ad43\",\"size\":15},{\"path\":\".media/preferences.json\",\"sha256\":\"888316c0c00d9d6929423a311f302500134d74315226a6a78a7a73bf66b4ef58\",\"size\":23},{\"path\":\".media/video/unused-take.mp4\",\"sha256\":\"a3e29b7ba3f66207df6182ec09ed749df364378cf2cfb8cf589163a6cdac93e2\",\"size\":28},{\"path\":\"CLAUDE.md\",\"sha256\":\"6ebdb617a8104a7756d0cf36578ab01103dc9f07e4dc6feb751296b9c402faf7\",\"size\":9},{\"path\":\"deck.key\",\"sha256\":\"8e11a86cf1052f458f6766baba49f519b80b3eee7c35433debd93483515626d4\",\"size\":8},{\"path\":\"docs/node_modules.md\",\"sha256\":\"ef0612da92e8204f7277982d4d3ce82b4589d200192fcfa74371a5b80365d5ba\",\"size\":20},{\"path\":\"index.html\",\"sha256\":\"0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051\",\"size\":10},{\"path\":\"notes/TRANSCRIPTS/file.bin\",\"sha256\":\"0392523321b470965a29a3ec513f460128fe11513b1dc2e2396fe510d5e67b15\",\"size\":26},{\"path\":\"templates/env.example.md\",\"sha256\":\"bf8e2a33ac126e948ed744ea606beb8f150409bbfcea9fbdf3184a710d0d3bff\",\"size\":24}],\"format_version\":1}", + "manifest_sha256": "fef0aa616de293c3b89370e19a3df5839c9d99b862f7f0416b742b72d2986c36", + "file_count": 21, + "project_bytes": 474 + }, + { + "name": "podcast-prepared-media", + "description": "Desktop's podcast transcodes under .hyperframes/prepared-assets/podcast/ travel, because the page plays them by that path.", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "podcast-lanes.html", + "sha256": "23f2572fb52084f5d1bfd67b8744730c538fa8d147636ad0d1359271c4f7f53a", + "size": 18 + }, + { + "path": ".hyperframes/prepared-assets/podcast/media/Wide/C1.MP4.mp4", + "sha256": "b2e0a5ccfef76057f4b7fab8df0d692adc387d3191a960a29d6df6472ef785dd", + "size": 58 + }, + { + "path": ".hyperframes/prepared-assets/podcast/proxies/Recorder/ZOOM0001.WAV.m4a", + "sha256": "ce43faf5a276945c1579f363336dafdaa24e7eb0fcaa457a7366e6583166f593", + "size": 70 + } + ] + }, + "canonical": "{\"entrypoint\":\"index.html\",\"files\":[{\"path\":\".hyperframes/prepared-assets/podcast/media/Wide/C1.MP4.mp4\",\"sha256\":\"b2e0a5ccfef76057f4b7fab8df0d692adc387d3191a960a29d6df6472ef785dd\",\"size\":58},{\"path\":\".hyperframes/prepared-assets/podcast/proxies/Recorder/ZOOM0001.WAV.m4a\",\"sha256\":\"ce43faf5a276945c1579f363336dafdaa24e7eb0fcaa457a7366e6583166f593\",\"size\":70},{\"path\":\"index.html\",\"sha256\":\"0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051\",\"size\":10},{\"path\":\"podcast-lanes.html\",\"sha256\":\"23f2572fb52084f5d1bfd67b8744730c538fa8d147636ad0d1359271c4f7f53a\",\"size\":18}],\"format_version\":1}", + "manifest_sha256": "f9e62e4d5549f908d8389f513a51507ef381e46a5c0a6fc61f1a70e1ee0fb851", + "file_count": 4, + "project_bytes": 156 + }, + { + "name": "root-only-exclusions-below-the-root", + "description": "dist/, coverage/, remotion-src/, moments/ and references/moments/ are left out only at the project root; build/ and outputs/ travel, and a .media ledger name elsewhere is an ordinary file.", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "build/index.js", + "sha256": "b45a82899e064eecd30590584dc256fbf4aecbf4a782d303c94091b56d659a50", + "size": 14 + }, + { + "path": "outputs/final-cut.json", + "sha256": "cf91e22a830da8b8ee66ad52f92a1cd1dd7729819fc54429a169c707373b1352", + "size": 22 + }, + { + "path": "site/dist/app.js", + "sha256": "efda832dc95fe712e14fee6d5ad65f81b33dc07ed97d02b1c469108710e6e546", + "size": 16 + }, + { + "path": "docs/coverage/index.html", + "sha256": "cc94d405c55521f535188b00011bc740a0c7ea22fccb597ea4d1dea12b8bbab7", + "size": 24 + }, + { + "path": "distribution.md", + "sha256": "83b8682bde66aedd4caaef8d64467832f54d7bf053c51b51dd77c9620c1beae6", + "size": 15 + }, + { + "path": "scenes/moments/intro.html", + "sha256": "e35994dd5678e2ed114526fa1f6c0959b1bcac5b02d8cd6577c7c51497197720", + "size": 25 + }, + { + "path": "moments.md", + "sha256": "03e8ca80fdbb8d01439c94c2766c11e0a704947fb2724171245bb566dff5fa3b", + "size": 10 + }, + { + "path": "references/brand.png", + "sha256": "a5bc608efc70f7851c7f96a26979a86b76c1f1c5c61fcdd442d55dd8f74ea9b6", + "size": 20 + }, + { + "path": "assets/remotion-src/notes.md", + "sha256": "d567b8f18b801aa7ff31dc3f483f1792276a91a84ff0960708f8f47fc3c18551", + "size": 28 + }, + { + "path": "assets/manifest.jsonl", + "sha256": "ec59c6727a8bf05b23d5db504a481d5bef3ac9ba2db6378940df276330ae0a12", + "size": 21 + } + ] + }, + "canonical": "{\"entrypoint\":\"index.html\",\"files\":[{\"path\":\"assets/manifest.jsonl\",\"sha256\":\"ec59c6727a8bf05b23d5db504a481d5bef3ac9ba2db6378940df276330ae0a12\",\"size\":21},{\"path\":\"assets/remotion-src/notes.md\",\"sha256\":\"d567b8f18b801aa7ff31dc3f483f1792276a91a84ff0960708f8f47fc3c18551\",\"size\":28},{\"path\":\"build/index.js\",\"sha256\":\"b45a82899e064eecd30590584dc256fbf4aecbf4a782d303c94091b56d659a50\",\"size\":14},{\"path\":\"distribution.md\",\"sha256\":\"83b8682bde66aedd4caaef8d64467832f54d7bf053c51b51dd77c9620c1beae6\",\"size\":15},{\"path\":\"docs/coverage/index.html\",\"sha256\":\"cc94d405c55521f535188b00011bc740a0c7ea22fccb597ea4d1dea12b8bbab7\",\"size\":24},{\"path\":\"index.html\",\"sha256\":\"0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051\",\"size\":10},{\"path\":\"moments.md\",\"sha256\":\"03e8ca80fdbb8d01439c94c2766c11e0a704947fb2724171245bb566dff5fa3b\",\"size\":10},{\"path\":\"outputs/final-cut.json\",\"sha256\":\"cf91e22a830da8b8ee66ad52f92a1cd1dd7729819fc54429a169c707373b1352\",\"size\":22},{\"path\":\"references/brand.png\",\"sha256\":\"a5bc608efc70f7851c7f96a26979a86b76c1f1c5c61fcdd442d55dd8f74ea9b6\",\"size\":20},{\"path\":\"scenes/moments/intro.html\",\"sha256\":\"e35994dd5678e2ed114526fa1f6c0959b1bcac5b02d8cd6577c7c51497197720\",\"size\":25},{\"path\":\"site/dist/app.js\",\"sha256\":\"efda832dc95fe712e14fee6d5ad65f81b33dc07ed97d02b1c469108710e6e546\",\"size\":16}],\"format_version\":1}", + "manifest_sha256": "b002a2ef6570769789f378e2638a4ef9f7ad2fb3937971e920d1d4765377825c", + "file_count": 11, + "project_bytes": 205 + }, + { + "name": "reused-content-and-empty-file", + "description": "Two paths may share content; an empty file has size 0.", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "copy.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "empty.txt", + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "size": 0 + } + ] + }, + "canonical": "{\"entrypoint\":\"index.html\",\"files\":[{\"path\":\"copy.html\",\"sha256\":\"0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051\",\"size\":10},{\"path\":\"empty.txt\",\"sha256\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"size\":0},{\"path\":\"index.html\",\"sha256\":\"0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051\",\"size\":10}],\"format_version\":1}", + "manifest_sha256": "57e5be944cc6089467e890512fcda319e683bdb4daadae5dcdffa15965936089", + "file_count": 3, + "project_bytes": 20 + }, + { + "name": "allowed-punctuation", + "description": "Punctuation other than the forbidden characters is portable.", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "a b/c&d#e%.txt", + "sha256": "1fb67bec75eb557356b4041a1ff905f6b7306ac4817cc1c6c90aa067e709ef9b", + "size": 14 + }, + { + "path": "a,b;c=d'.txt", + "sha256": "2819f043cab3930987005eec2308929f30c621295c05613d9b9929ea7bb9bf40", + "size": 12 + }, + { + "path": "[x]{y}(z)!@$^~`+.txt", + "sha256": "9c420f8d454083d0bd63c9b68a1dab89a2f3f16eba95bb4a744a45b9e18b7f48", + "size": 20 + }, + { + "path": "-leading-dash.txt", + "sha256": "43c4babb12e54cd711ab4e1c03e4c57666376009002c656fb9f3a15e9e26878a", + "size": 17 + } + ] + }, + "canonical": "{\"entrypoint\":\"index.html\",\"files\":[{\"path\":\"-leading-dash.txt\",\"sha256\":\"43c4babb12e54cd711ab4e1c03e4c57666376009002c656fb9f3a15e9e26878a\",\"size\":17},{\"path\":\"[x]{y}(z)!@$^~`+.txt\",\"sha256\":\"9c420f8d454083d0bd63c9b68a1dab89a2f3f16eba95bb4a744a45b9e18b7f48\",\"size\":20},{\"path\":\"a b/c&d#e%.txt\",\"sha256\":\"1fb67bec75eb557356b4041a1ff905f6b7306ac4817cc1c6c90aa067e709ef9b\",\"size\":14},{\"path\":\"a,b;c=d'.txt\",\"sha256\":\"2819f043cab3930987005eec2308929f30c621295c05613d9b9929ea7bb9bf40\",\"size\":12},{\"path\":\"index.html\",\"sha256\":\"0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051\",\"size\":10}],\"format_version\":1}", + "manifest_sha256": "64c1e278a7bd74d33965eb4363796463a02706fbdd34db7aeb7f4cd08be45a37", + "file_count": 5, + "project_bytes": 73 + }, + { + "name": "length-boundaries", + "description": "A 240-byte segment and a 1,024-byte path are at the limit, not over it.", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss", + "sha256": "d4b313e9c9a1f2007c5479c7adaf8d10a3e8cb8457c515944e484160bb6e5361", + "size": 240 + }, + { + "path": "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd/dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd/dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd/dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd/ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "sha256": "c5c6c3e05ec6aa09b2493bc5b309726a7ad678bb10575697a2a6405bc67d609d", + "size": 1024 + } + ] + }, + "canonical": "{\"entrypoint\":\"index.html\",\"files\":[{\"path\":\"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd/dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd/dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd/dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd/ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\",\"sha256\":\"c5c6c3e05ec6aa09b2493bc5b309726a7ad678bb10575697a2a6405bc67d609d\",\"size\":1024},{\"path\":\"index.html\",\"sha256\":\"0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051\",\"size\":10},{\"path\":\"ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss\",\"sha256\":\"d4b313e9c9a1f2007c5479c7adaf8d10a3e8cb8457c515944e484160bb6e5361\",\"size\":240}],\"format_version\":1}", + "manifest_sha256": "c66869a7fe7b94c200e752244796ff044f8bb3f76d2652e3896d476b59b131f5", + "file_count": 3, + "project_bytes": 1274 + }, + { + "name": "largest-safe-size", + "description": "Sizes up to 2^53 - 1 are valid manifests; the push size limits are checked separately.", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "huge.bin", + "sha256": "3f25c33d62813f93fc81c0acb634181760cb83d1a6bc491c1c81fa29e7bca154", + "size": 9007199254740991 + } + ] + }, + "canonical": "{\"entrypoint\":\"index.html\",\"files\":[{\"path\":\"huge.bin\",\"sha256\":\"3f25c33d62813f93fc81c0acb634181760cb83d1a6bc491c1c81fa29e7bca154\",\"size\":9007199254740991},{\"path\":\"index.html\",\"sha256\":\"0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051\",\"size\":10}],\"format_version\":1}", + "manifest_sha256": "de1efa6fe285757b315b4ea3ba2ef857b16fc7c95ca1bc5cdfa1e60bb78f955a", + "file_count": 2, + "project_bytes": 9007199254741001 + } + ], + "invalid": [ + { + "name": "missing-files", + "manifest": { + "format_version": 1, + "entrypoint": "index.html" + }, + "error": { + "code": "invalid_schema" + } + }, + { + "name": "unknown-top-level-field", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + } + ], + "author": "someone" + }, + "error": { + "code": "invalid_schema" + } + }, + { + "name": "unknown-file-field", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10, + "url": "https://example.com/index.html" + } + ] + }, + "error": { + "code": "invalid_schema" + } + }, + { + "name": "size-as-string", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": "10" + } + ] + }, + "error": { + "code": "invalid_schema" + } + }, + { + "name": "path-as-number", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": 7, + "sha256": "2d711642b726b04401627ca9fbac32f5c8530fb1903cc4db02258717921a4881", + "size": 1 + } + ] + }, + "error": { + "code": "invalid_schema" + } + }, + { + "name": "format-version-2", + "manifest": { + "format_version": 2, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + } + ] + }, + "error": { + "code": "unsupported_format_version" + } + }, + { + "name": "other-entrypoint", + "manifest": { + "format_version": 1, + "entrypoint": "scenes/main.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "scenes/main.html", + "sha256": "3850b0e48638480b2b9210e3131976ced8f8d66ae36b24936407dabf09923dca", + "size": 16 + } + ] + }, + "error": { + "code": "invalid_entrypoint" + } + }, + { + "name": "entrypoint-not-listed", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "scenes/main.html", + "sha256": "3850b0e48638480b2b9210e3131976ced8f8d66ae36b24936407dabf09923dca", + "size": 16 + } + ] + }, + "error": { + "code": "entrypoint_not_listed" + } + }, + { + "name": "uppercase-sha256", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0EB547304658805AAD788D320F10BF1F292797B5E6D745A3BF617584DA017051", + "size": 10 + } + ] + }, + "error": { + "code": "invalid_sha256" + } + }, + { + "name": "short-sha256", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da01705", + "size": 10 + } + ] + }, + "error": { + "code": "invalid_sha256" + } + }, + { + "name": "negative-size", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": -1 + } + ] + }, + "error": { + "code": "invalid_size" + } + }, + { + "name": "size-above-2-53", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "huge.bin", + "sha256": "3f25c33d62813f93fc81c0acb634181760cb83d1a6bc491c1c81fa29e7bca154", + "size": 9007199254740992 + } + ] + }, + "error": { + "code": "invalid_size" + } + }, + { + "name": "one-digest-two-sizes", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "b.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 1 + } + ] + }, + "error": { + "code": "inconsistent_digest_size" + } + }, + { + "name": "duplicate-path", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "a.js", + "sha256": "dc5985b2a377c4ea735c99979da277be3bd24be88cf411c11b52b5c3f9570536", + "size": 4 + }, + { + "path": "a.js", + "sha256": "dc5985b2a377c4ea735c99979da277be3bd24be88cf411c11b52b5c3f9570536", + "size": 4 + } + ] + }, + "error": { + "code": "duplicate_path" + } + }, + { + "name": "case-collision", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "a.js", + "sha256": "dc5985b2a377c4ea735c99979da277be3bd24be88cf411c11b52b5c3f9570536", + "size": 4 + }, + { + "path": "A.js", + "sha256": "9a75ab6bc200aa8acfb0e422b461e0f5875b983e426abc3a3dc4493aba31c233", + "size": 4 + } + ] + }, + "error": { + "code": "path_collision" + } + }, + { + "name": "directory-case-collision", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "Assets/a.png", + "sha256": "aa838516b8faede2e75b29d6b0ad1b99b7cca1a6eec18cd20e09e9d63ac336dd", + "size": 12 + }, + { + "path": "assets/b.png", + "sha256": "6b5ccff86cd078bb49880b35ac1784320c768526f4199ab9f7923bf67effc4ee", + "size": 12 + } + ] + }, + "error": { + "code": "path_collision" + } + }, + { + "name": "full-casefold-collision", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "stra\u00dfe.txt", + "sha256": "fbba3f5ff0440287811826d6c3c4160b1631c5541293c9959075610732f3b167", + "size": 11 + }, + { + "path": "strasse.txt", + "sha256": "d860b68ac02417bcde5058c0aa98fb6c77e24337c462d3756c2aab0c3f98ffa3", + "size": 11 + } + ] + }, + "error": { + "code": "path_collision" + } + }, + { + "name": "final-sigma-collision", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "\u03a3/a", + "sha256": "32e8b8da0483605ae6db163a980d3a72385ac9c3118c33da049f6c7e383241b0", + "size": 4 + }, + { + "path": "\u03c2/b", + "sha256": "56d5841b83008207d8190915dec97a32d040b98ff1e41515555aa393819ebad8", + "size": 4 + } + ] + }, + "error": { + "code": "path_collision" + } + }, + { + "name": "ligature-collision", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "\ufb01le.txt", + "sha256": "dca39d9d97123b2230297327532a68ac3a75014089707b91a4ee4fba8a4a9bc2", + "size": 9 + }, + { + "path": "file.txt", + "sha256": "aadf327c8267c09d6fffd87a1a80ad3c798469ff332b7a57b9e8c045d46b2af7", + "size": 8 + } + ] + }, + "error": { + "code": "path_collision" + } + }, + { + "name": "file-and-directory", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "a", + "sha256": "ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb", + "size": 1 + }, + { + "path": "a/b", + "sha256": "c14cddc033f64b9dea80ea675cf280a015e672516090a5626781153dc68fea11", + "size": 3 + } + ] + }, + "error": { + "code": "file_directory_collision" + } + }, + { + "name": "empty-path", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "", + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "size": 0 + } + ] + }, + "error": { + "code": "path_empty" + } + }, + { + "name": "backslash", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "a\\b", + "sha256": "c62016d0f8ee333350283fd879b50b692932e932794e5d686f7d37d67484e199", + "size": 3 + } + ] + }, + "error": { + "code": "path_invalid_character" + } + }, + { + "name": "drive-letter", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "C:/x", + "sha256": "35a70e2c9b7d9f56c30880d982fbc7e3d5fddea11a37035a3c39d0328c265ddd", + "size": 4 + } + ] + }, + "error": { + "code": "path_invalid_character" + } + }, + { + "name": "nul", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "a\u0000b", + "sha256": "59b271ae1bbcb1d31d41929817f4b16fb439eb4f31520b5ad1d5ce98920a7138", + "size": 3 + } + ] + }, + "error": { + "code": "path_invalid_character" + } + }, + { + "name": "c1-control", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "a\u0085b", + "sha256": "75e7cf7e9bf896d878d3b49a7225fc0ef80d9b03356eb6d783bb276e67afe8fa", + "size": 4 + } + ] + }, + "error": { + "code": "path_invalid_character" + } + }, + { + "name": "lone-surrogate", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "a\ud800b", + "sha256": "45e334b6c74ca5db8d8f8fcd1157fb31a2ebc9953e0d8d182e37b6b67e6a1705", + "size": 5 + } + ] + }, + "error": { + "code": "path_invalid_character" + } + }, + { + "name": "question-mark", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "a?b", + "sha256": "c2a7b64a2d2520047bfc9248fdda834c9cc2c0c9e89826355c7a6ae16fe11179", + "size": 3 + } + ] + }, + "error": { + "code": "path_invalid_character" + } + }, + { + "name": "unassigned-code-point", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "\u0378.txt", + "sha256": "e5a1e84dddf1b2d2dfd36a6351c188eef9104feeff775bdffbd406b7214d3bd7", + "size": 6 + } + ] + }, + "error": { + "code": "path_unassigned_code_point" + } + }, + { + "name": "assigned-after-15-1", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "\u1c89.txt", + "sha256": "89262795c39f249edc772f152e0c4e0cc596dbf4f4035d6969edd98e503f6490", + "size": 7 + } + ] + }, + "error": { + "code": "path_unassigned_code_point" + } + }, + { + "name": "decomposed", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "cafe\u0301.txt", + "sha256": "da33d471fceb496fca38f333c2169a3ebc666a5fb12f044cb617c87eac1f54ff", + "size": 10 + } + ] + }, + "error": { + "code": "path_not_nfc" + } + }, + { + "name": "angstrom-sign", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "\u212b.txt", + "sha256": "55c57fdf869ca6a036f6fd840abb97e5d9f28a08cc7c5ab98f43a3d38b718234", + "size": 7 + } + ] + }, + "error": { + "code": "path_not_nfc" + } + }, + { + "name": "path-over-1024-bytes", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd/dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd/dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd/dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd/fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + "sha256": "3b1c473b1463ccb1ab14f1f0a78e71dc49445f3f94e9290e3eb3bbfd4b8491e9", + "size": 1025 + } + ] + }, + "error": { + "code": "path_too_long" + } + }, + { + "name": "absolute", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "/index.html", + "sha256": "213456c5dc963e03ec1f27600c46c954c70224985fa62603db2fb2ab1ca06d35", + "size": 11 + } + ] + }, + "error": { + "code": "path_not_relative" + } + }, + { + "name": "double-slash", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "a//b", + "sha256": "7a9acf331a5dc1e020c17901e85936a279e0aa49b04474b13fa2ee63f80fa57a", + "size": 4 + } + ] + }, + "error": { + "code": "path_empty_segment" + } + }, + { + "name": "trailing-slash", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "a/", + "sha256": "b3dda5b674f9ce730a37dee0a33bb31efeea2335f517774f6ea133d448df2178", + "size": 2 + } + ] + }, + "error": { + "code": "path_empty_segment" + } + }, + { + "name": "parent-segment", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "../x", + "sha256": "d6b96a97d147daaae49eb87a5ca7bfbc280e79551016df8aa5edc5920d21c274", + "size": 4 + } + ] + }, + "error": { + "code": "path_dot_segment" + } + }, + { + "name": "dot-segment", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "a/./b", + "sha256": "323f86c5ac40686f53f7cd0f4d3cb805d1a8f237bfee51a2d30943f81260e99d", + "size": 5 + } + ] + }, + "error": { + "code": "path_dot_segment" + } + }, + { + "name": "segment-over-240-bytes", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss", + "sha256": "1b21942235ac8a80199d3b087703496ebd76d322ffe2b8730d920940421c0cff", + "size": 241 + } + ] + }, + "error": { + "code": "segment_too_long" + } + }, + { + "name": "trailing-dot", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "x.", + "sha256": "c92f00b196e2fb020317afd79909f3894536d631a3366d77c9653176e12a5c4f", + "size": 2 + } + ] + }, + "error": { + "code": "segment_trailing_dot_or_space" + } + }, + { + "name": "trailing-space", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "dir /x", + "sha256": "11b00276f199a1890fca0cd5c9a41cd09c9ac318d9baaaece9a7061955668029", + "size": 6 + } + ] + }, + "error": { + "code": "segment_trailing_dot_or_space" + } + }, + { + "name": "device-name", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "con", + "sha256": "1143da2bc54c495c4be31d3868785d39ffdfd56df5668f0645d8f14d47647952", + "size": 3 + } + ] + }, + "error": { + "code": "reserved_name" + } + }, + { + "name": "device-name-with-extension", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "assets/CON.txt", + "sha256": "975115b3c016b03653062c8ac360e25cab7b6bd5bb3824a39dcaef1be09cb764", + "size": 14 + } + ] + }, + "error": { + "code": "reserved_name" + } + }, + { + "name": "device-name-double-extension", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "a/nul.tar.gz", + "sha256": "6217f5ba481b78ab735c342e3ea6a4bf74d54922b36a44c2192d33984815c01e", + "size": 12 + } + ] + }, + "error": { + "code": "reserved_name" + } + }, + { + "name": "device-name-superscript", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "LPT\u00b2.txt", + "sha256": "ca3aab60cfc72e6431367509c0b966332eb3f6123ee308f5446c7f89f4e2d02a", + "size": 9 + } + ] + }, + "error": { + "code": "reserved_name" + } + }, + { + "name": "media-alias", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".MEDIA/a.mp4", + "sha256": "9f65ed7eafecaafd9e800173934f233b95b0d9bb642811fbcd1b1d9674a7440a", + "size": 12 + } + ] + }, + "error": { + "code": "reserved_path_alias" + } + }, + { + "name": "hyperframes-alias", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".Hyperframes/transcripts/a.json", + "sha256": "c2821bb113dcb6bd956a4dc6b97f9a3083294f4db13904c0db3e665d620c0242", + "size": 31 + } + ] + }, + "error": { + "code": "reserved_path_alias" + } + }, + { + "name": "transcripts-alias", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".hyperframes/TRANSCRIPTS/a.json", + "sha256": "b1c2c648c3c99106e57916500c84220834c813ccdae5047dcb10d83b4bc1b045", + "size": 31 + } + ] + }, + "error": { + "code": "reserved_path_alias", + "rule": "portable-transcripts" + } + }, + { + "name": "brand-kit-alias", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".hyperframes/Brand-Kit.json", + "sha256": "44dbad5584a14ca61eaab0abbc4d943fe28b287ae941929b58408e8d19976cc2", + "size": 27 + } + ] + }, + "error": { + "code": "reserved_path_alias", + "rule": "portable-brand-kit" + } + }, + { + "name": "studio-edits-alias", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".hyperframes/Studio-Motion.json", + "sha256": "af4607f49d27b27af5f8e14025c60c20656b22c900f5cd0c84be580372b1c45f", + "size": 31 + } + ] + }, + "error": { + "code": "reserved_path_alias", + "rule": "portable-studio-edits" + } + }, + { + "name": "media-lock", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".media/.lock", + "sha256": "9973d24679eb4fe7ca7e21cf03a5b5e5ce89380cf1e15f96bb3529b2045f68a9", + "size": 12 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "media-lock" + } + }, + { + "name": "media-reservation", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".media/images/x.png.hfabcdef.tmp", + "sha256": "b1434ad4413cffbb82b9026ce05480a60c6af8d53415a1b3980d4df4c7397b4e", + "size": 32 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "media-reservation" + } + }, + { + "name": "media-ledger", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".media/manifest.jsonl", + "sha256": "c35dbd7aec9f4cfeff3fef24916e8ed21a8432a6d3ed65924b857a65f55ac68f", + "size": 21 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "media-ledger" + } + }, + { + "name": "media-ledger-case", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".media/Manifest.JSONL", + "sha256": "d7f76ede83651197b1e54d76b5227f272a5a19ad1ac6b758a9efc5af47b254cf", + "size": 21 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "media-ledger" + } + }, + { + "name": "comments", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".hyperframes/comments.jsonl", + "sha256": "986857a0b40fb1ab13acd7718f74677a9b1329651a68b99bfdd827bd6065e2b1", + "size": 27 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "known-hyperframes-state" + } + }, + { + "name": "chat-history", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".hyperframes/agent-runs.jsonl", + "sha256": "61aee44837a8fb87c824d703255c2e497f03b6a997de9773c7e4decda22a5f7c", + "size": 29 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "known-hyperframes-state" + } + }, + { + "name": "sync-binding", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".hyperframes/sync/binding.json", + "sha256": "ca2bef6cb7269ec5b2a2aa291e668ca2c40379f3b729abc44019472b89cbf711", + "size": 30 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "sync-and-share-bindings" + } + }, + { + "name": "sync-receipt", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".hyperframes/receipts/upload.json", + "sha256": "74cb6f7afd974d113a6cb6077ca1947d19d412b3ad2023ed771ee5db78536e43", + "size": 33 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "sync-and-share-bindings" + } + }, + { + "name": "share-link", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".hyperframes/share.json", + "sha256": "2a90ff0795de7b1dee0003f8399d8ca926278eaabc7ebc9bfa7b94bde1894511", + "size": 23 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "sync-and-share-bindings" + } + }, + { + "name": "review-link", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".hyperframes/review-abc123.json", + "sha256": "347fbe328490ebae27b54d768d6357091783ee516a32cf75c7bdd9ed78d50f7e", + "size": 31 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "sync-and-share-bindings" + } + }, + { + "name": "cli-publish-id", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".hyperframes/project.json", + "sha256": "61162859aceaf2e637350d3eef12ad2dc0250c3dc07b35903e0b3e3bb689eb4f", + "size": 25 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "sync-and-share-bindings" + } + }, + { + "name": "deploy-stack", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".hyperframes/lambda-stack-prod.json", + "sha256": "362688ebc40e3a9a8d09a0e8f74c54892bc3fddcedd163c2dead083d0aca54ee", + "size": 35 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "sync-and-share-bindings" + } + }, + { + "name": "check-artifacts", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".hyperframes/artifacts/checks/frame.png", + "sha256": "5029a36abd99708a1e250ed716bd3e56d987b4e8b2f06de87755098fa306828b", + "size": 39 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "known-hyperframes-state" + } + }, + { + "name": "voice-copies", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".hyperframes/voices.json", + "sha256": "642b37742a237f49a110881d85c4727531de98c26b7898e45944995c1012623e", + "size": 24 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "known-hyperframes-state" + } + }, + { + "name": "prepared-assets-gif", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".hyperframes/prepared-assets/gif/preview.gif", + "sha256": "e808f4eea9660b90af1fb56e282a50d24ccf9580fc5b1fa5c87570a5e060a34d", + "size": 44 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "known-hyperframes-state" + } + }, + { + "name": "prepared-assets-downloads", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".hyperframes/prepared-assets/downloads/clip.mp4", + "sha256": "c774b5f01db05f64c52e687fe891e56a0e3e0b14bf89cc8883f87a2eb1b22327", + "size": 47 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "known-hyperframes-state" + } + }, + { + "name": "podcast-job-state", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".hyperframes/podcast/job.json", + "sha256": "190f70986587aae69e999eab453a9d0abf0f047067dd1bca6f1c48dfa18944ac", + "size": 29 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "known-hyperframes-state" + } + }, + { + "name": "podcast-media-dotfile", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".hyperframes/prepared-assets/podcast/media/.DS_Store", + "sha256": "25f927d71f5b2b5d14b76e5eda58e2470115fb53fc3c5cc757768afc07555b8b", + "size": 52 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "os-metadata" + } + }, + { + "name": "podcast-media-temporary", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".hyperframes/prepared-assets/podcast/media/Wide/C1.MP4.mp4.0b1c2d3e-4f50-4617-8899-aabbccddeeff.tmp", + "sha256": "2b312ac98f86d15e6fc55391c518c437d99d38de6583c3073ca08578a6237e64", + "size": 99 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "unfinished-writes" + } + }, + { + "name": "podcast-media-alias", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".hyperframes/Prepared-Assets/podcast/media/C1.mp4", + "sha256": "7c315f54ae843132f5344c8488c98b94a05b045024d2605539440ea4905ba6aa", + "size": 49 + } + ] + }, + "error": { + "code": "reserved_path_alias", + "rule": "portable-podcast-media" + } + }, + { + "name": "podcast-media-ssh-key", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".hyperframes/prepared-assets/podcast/.ssh/id_rsa", + "sha256": "673c5f43bb96ed6dc6c179356b2b2d76925e25ff653029da8d5e520f37fad2c7", + "size": 48 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "credential-files" + } + }, + { + "name": "podcast-media-aws-credentials", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".hyperframes/prepared-assets/podcast/media/.aws/credentials", + "sha256": "33d38760a731ca8467010421db5441fcd80709a530155fafbc8f81ecc2948f0f", + "size": 59 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "credential-files" + } + }, + { + "name": "podcast-media-pem", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".hyperframes/prepared-assets/podcast/media/secret.pem", + "sha256": "ed4a446ead9b837b1e2119f32c39f505ed7c41aa39961c7a230c8f72c563de15", + "size": 53 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "credential-files" + } + }, + { + "name": "podcast-media-git", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".hyperframes/prepared-assets/podcast/.git/config", + "sha256": "bdba0ca5b99e8986612bbcdd8283e6f8235f9f4351505bd5abfd67272239b402", + "size": 48 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "dependencies-and-git" + } + }, + { + "name": "podcast-media-node-modules", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".hyperframes/prepared-assets/podcast/proxies/node_modules/x/index.js", + "sha256": "4614d76393b403e42faee1f5eafb433608f7dfdde5d8943b7077e554d910bf36", + "size": 68 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "dependencies-and-git" + } + }, + { + "name": "podcast-media-env-dir", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".hyperframes/prepared-assets/podcast/media/.env", + "sha256": "00466d6462cb60f88d59304017e03180138637c16340c5d5a6d0ba63aeb52bb7", + "size": 47 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "environment-secrets" + } + }, + { + "name": "podcast-media-pip-conf", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".hyperframes/prepared-assets/podcast/media/pip.conf", + "sha256": "e14fb225fed89b477192bbc3aaecd653872e80c9554391a264867bd387de23cc", + "size": 51 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "package-manager-config" + } + }, + { + "name": "podcast-media-agent-state", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".hyperframes/prepared-assets/podcast/.claude/settings.json", + "sha256": "7f4b87b1dc55c173b7cec8369667397a06fdf612b48b1bc6e12aa027296de233", + "size": 58 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "agent-client-state" + } + }, + { + "name": "podcast-media-build-cache", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".hyperframes/prepared-assets/podcast/media/.cache/C1.mp4", + "sha256": "a3ca2e8f81d8bf18536e9e3ffd6d09cb0a6b10c67cd4452a5f20e9a26a8b9735", + "size": 56 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "build-caches" + } + }, + { + "name": "podcast-media-ds-store-direct", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".hyperframes/prepared-assets/podcast/.DS_Store", + "sha256": "937f699c059c74eb6fda2c02153fdf4c2c42ff23acf01111273f9b34dbb35ea3", + "size": 46 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "os-metadata" + } + }, + { + "name": "podcast-media-thumbs-db", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".hyperframes/prepared-assets/podcast/media/Thumbs.db", + "sha256": "61fe6ac97e701da5ac15f0eb1fcd228198031bae829ce9bfeb31610beb042cc5", + "size": 52 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "os-metadata" + } + }, + { + "name": "podcast-media-macosx", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".hyperframes/prepared-assets/podcast/__MACOSX/media/C1.mp4", + "sha256": "c04a5ac2f2f3969d261e003a2732db9f9c8dbe8f63b7943fa42a5ee4440bc805", + "size": 58 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "os-metadata" + } + }, + { + "name": "transcripts-env-json", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".hyperframes/transcripts/.env.json", + "sha256": "f968aafe086ade3c0a00627ee405350f6d235780c8b10025d9e3898614d3bb23", + "size": 34 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "environment-secrets" + } + }, + { + "name": "transcripts-nested-npmrc", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".hyperframes/transcripts/x/.npmrc", + "sha256": "16efe6092c7243e9e2195f2fbdc34597bb23a1f192b13cf186016c85f59d9bc2", + "size": 33 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "package-manager-config" + } + }, + { + "name": "transcripts-ssh-key", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".hyperframes/transcripts/.ssh/id_rsa.json", + "sha256": "c52be8541e42c47cc41addc845de1b86d8e9323d88497656995ab0fd363d10f0", + "size": 41 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "credential-files" + } + }, + { + "name": "transcripts-nested-key-name", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".hyperframes/transcripts/x/id_ed25519.json", + "sha256": "edfeb0d890654f80a0f648a76e0a6295a81ad5c106f3d938f2d8021c97854f7e", + "size": 42 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "credential-files" + } + }, + { + "name": "transcripts-git", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".hyperframes/transcripts/.git/config.json", + "sha256": "926f9e367e75853cda20a85232eb5e34c32782699536439b6133210da74de687", + "size": 41 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "dependencies-and-git" + } + }, + { + "name": "transcripts-node-modules", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".hyperframes/transcripts/node_modules/a.json", + "sha256": "6f5267956792664a277aedebd91528445066cceeb250708601cf5fda9ae2a661", + "size": 44 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "dependencies-and-git" + } + }, + { + "name": "transcripts-agent-state", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".hyperframes/transcripts/.vscode/settings.json", + "sha256": "82b0657304c0738bd9091464ac35731d7e257792dc0a21bf825a2684b821b478", + "size": 46 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "agent-client-state" + } + }, + { + "name": "transcripts-appledouble", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".hyperframes/transcripts/._a.json", + "sha256": "f1ec51871fdd2955d8a4caf4f9a38c8472817066a3622b4ff0862f6c2c5651fc", + "size": 33 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "os-metadata" + } + }, + { + "name": "transcripts-ds-store", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".hyperframes/transcripts/x/.DS_Store", + "sha256": "b33e190354e883e4646077d5516e019417e31d1d83b77378565be3a55be2e83e", + "size": 36 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "os-metadata" + } + }, + { + "name": "transcripts-macosx", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".hyperframes/transcripts/__MACOSX/a.json", + "sha256": "207e13b571365f4757569bc48864f70234e2c83ff99c5a6bcd5126f935e2736f", + "size": 40 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "os-metadata" + } + }, + { + "name": "run-traces", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".hyperframes/run-traces/t1.json", + "sha256": "ad72358819398bced031145bf0dccb2715a0bb64cd2a2e0db49e0b04126ec7da", + "size": 31 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "known-hyperframes-state" + } + }, + { + "name": "unknown-hyperframes-state", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".hyperframes/notes.md", + "sha256": "171eb0417135308796aca9fe3b9015fe3ca772e6fc945e36db767b804a63dfe1", + "size": 21 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "unknown-hyperframes-state" + } + }, + { + "name": "transcript-temporary", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".hyperframes/transcripts/a.json.tmp", + "sha256": "dcc3acb5f3b764c1c7ead0400126e0cdb352fa3da16dbdc4ab06032f3a6ab508", + "size": 35 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "unfinished-writes" + } + }, + { + "name": "atomic-write-temp", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "index.html.hf1a2b3c.tmp", + "sha256": "98263e7b51ce89ee7ded7034737f988d62ce8fc45f19f9f59bcce29c5640c5dd", + "size": 23 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "unfinished-writes" + } + }, + { + "name": "nested-tmp", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "compositions/scene.html.tmp", + "sha256": "1bfaa7a596c9009790a941be98740f72966389edac5e184cd423f86901a665f4", + "size": 27 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "unfinished-writes" + } + }, + { + "name": "partial-download", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "assets/clip.mov.part", + "sha256": "8e76846fa546063f772cadf3fa7620e43aeb6572a83c380f2d4240eef7a25899", + "size": 20 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "unfinished-writes" + } + }, + { + "name": "editor-swap", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".index.html.swp", + "sha256": "7993241a828f5ecb96321408a7d94838ea8f2ab988eaf51ba86f1ef8c6340512", + "size": 15 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "unfinished-writes" + } + }, + { + "name": "editor-backup", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "notes.md~", + "sha256": "c3defad44cf17ab076123993461f4805daf5d435cae4bd777614d9a870c3e478", + "size": 9 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "unfinished-writes" + } + }, + { + "name": "render-work-dir", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "work-0123abcd-0123-4567-89ab-0123456789ab-a1B2c3/frame-0001.png", + "sha256": "e0d88a5cc4c4a6f2d3de1139d7bfeb1f58da21e99d293a51ee0474a4b0bbd779", + "size": 63 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "render-temp-dirs" + } + }, + { + "name": "hf-render-dir", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "out/hf-render-Zz9yX8/frame.png", + "sha256": "2fd4c9ff40809f7053d5514c38ac618910e429db16e1de6ffb2eecff8cc44d07", + "size": 30 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "render-temp-dirs" + } + }, + { + "name": "transaction-dir", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".final.hf-transaction-Ab12Cd/final.mp4", + "sha256": "273e025f3d266ac7397591b02653baefc90c699d1fbadf384f77556e9ee5196b", + "size": 38 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "render-temp-dirs" + } + }, + { + "name": "assemble-work-dir", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "final.mp4.assemble-work-xY12zQ/part-001.mp4", + "sha256": "818dc63f4d6feaf8dec362f872d0816625fe551b8b318fd0962a1ce85da5478e", + "size": 43 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "render-temp-dirs" + } + }, + { + "name": "agent-client-state", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".claude/settings.json", + "sha256": "f27ac6f39d89fe021c56900069198aa7d9968f2cd6645c00b11ffd1b78fcf546", + "size": 21 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "agent-client-state" + } + }, + { + "name": "cursor-rules", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".cursor/rules/style.md", + "sha256": "c5b4b1add518f55124c284201df673a8267c5021b27fa33c06a97a7e95da4d20", + "size": 22 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "agent-client-state" + } + }, + { + "name": "vscode-settings", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "sub/.vscode/settings.json", + "sha256": "c5084aafd97d0f1a7b66a365fbdcc59a1889c05fa69c8663ff94a6bd43897d5c", + "size": 25 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "agent-client-state" + } + }, + { + "name": "idea", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".idea/workspace.xml", + "sha256": "9f043e4e89d784b579b6d75ea8704b232f9475fa5b3afd11f805fdf8e74c675c", + "size": 19 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "agent-client-state" + } + }, + { + "name": "agents-dir", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".agents/skills/x.md", + "sha256": "b425dd94d23650cb37df5e3e75eed78675f1784a2fc1509e7608963cc4bce27a", + "size": 19 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "agent-client-state" + } + }, + { + "name": "svn", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".svn/entries", + "sha256": "ff1bd8565d1ae3f065b4df1171319ac45642883cebb67d159d17556ceb7c621e", + "size": 12 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "dependencies-and-git" + } + }, + { + "name": "mercurial", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "vendor/.hg/store/data", + "sha256": "37400dbc74c76d0efd45d654e29b2c2bd4a8511383679a64ad772264cd7410d4", + "size": 21 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "dependencies-and-git" + } + }, + { + "name": "snapshots", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "snapshots/frame-0001.png", + "sha256": "94a2fe06458a8c9532a6b3aee28a297c3041d1946c43fb5054952832d8cdea37", + "size": 24 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "root-generated-output" + } + }, + { + "name": "root-dist", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "dist/index.js", + "sha256": "3d2b59189eeedc2d428ddd632e97658fe310f587f7cb63b01f9b98ffc11c0197", + "size": 13 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "root-build-output" + } + }, + { + "name": "root-coverage", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "coverage/lcov.info", + "sha256": "d38234dcd085270f6a057c86bd3e6c7771528a9ba0a78fd6128da5be9e0cc1de", + "size": 18 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "root-build-output" + } + }, + { + "name": "remotion-src", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "remotion-src/src/Root.tsx", + "sha256": "a0c964a08bdb2b895b105242431c6c9ba536f3cd7f8cb4e11f7957528d366d71", + "size": 25 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "authoring-scratch" + } + }, + { + "name": "moments", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "moments/m1/.work/clip.mp4", + "sha256": "54cd521aba75dd5a0e1bf63f0524b4427d5d46b482ac1ae86c1800b4e1f5ac35", + "size": 25 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "authoring-scratch" + } + }, + { + "name": "references-moments", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "references/moments/ref.mp4", + "sha256": "a5ed787bcb0d6d53a9683378cbaef4e267a88b60252503e9e1aad56f5f1ed466", + "size": 26 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "authoring-scratch" + } + }, + { + "name": "vite-cache", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".vite/deps/chunk.js", + "sha256": "c3a4237710998cee2dbb83bddfbe437842c04505b10b55f252ab6680354159fa", + "size": 19 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "build-caches" + } + }, + { + "name": "nested-next", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "site/.next/cache/x", + "sha256": "e5ff1be6d5c5067c92f049eedd21f72572e90ce73718b4ae0f89f32810420788", + "size": 18 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "build-caches" + } + }, + { + "name": "generic-cache", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".cache/thumbs/a.png", + "sha256": "84793a78d04a6dc0a78bb607ed12c9d0fd7a56a9aa4c708815bed4d38dc27af4", + "size": 19 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "build-caches" + } + }, + { + "name": "viral-clone", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".viral-clone/ref.mp4", + "sha256": "74d8d7a4426313aa0c60436b14b029d1a4a226d6711121a633105cd905bd45b9", + "size": 20 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "reference-video" + } + }, + { + "name": "npmrc", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".npmrc", + "sha256": "e813096d69c49812e40e00be9ac8fa14d77f0ec1f97ab4c45cb096b3bedd35de", + "size": 6 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "package-manager-config" + } + }, + { + "name": "pip-conf", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "tools/pip.conf", + "sha256": "89297b895495ae041f60994bec31485ca633472556352f1a6778b85e24f90749", + "size": 14 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "package-manager-config" + } + }, + { + "name": "netrc", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".netrc", + "sha256": "3de95a09ee1730e3dc474455103e6db896a8efe5a860f85ba57e548c2f276465", + "size": 6 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "credential-files" + } + }, + { + "name": "pem", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "certs/server.PEM", + "sha256": "3689af7a474196cce74bbd95034f5a1beb662e273ea9f601098c264514835be3", + "size": 16 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "credential-files" + } + }, + { + "name": "ssh-key", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "id_ed25519.pub", + "sha256": "f7184d2ebba2aba7182214d1c36ebb1af7a36215c96117bafd63ad2901e35444", + "size": 14 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "credential-files" + } + }, + { + "name": "ssh-dir", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".ssh/config", + "sha256": "19b529d4faff68e955a68c11da36f42da81f792d32d3c101b0bd4e64c740f6ca", + "size": 11 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "credential-files" + } + }, + { + "name": "aws-dir", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".aws/credentials", + "sha256": "c0515f87612986c6296a343be4a69b67e142dd55076a885f2c8604eaf7cf694e", + "size": 16 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "credential-files" + } + }, + { + "name": "git-credentials", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".git-credentials", + "sha256": "fd3e0d72bea3532d2615d9f8bd5bf849d31505795102e687529b9aca2957cf80", + "size": 16 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "credential-files" + } + }, + { + "name": "ds-store", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".DS_Store", + "sha256": "e2eb93a61ffd7877ea5c751abcb3a618e8e2e9a2073a27f66d4114fe10819f86", + "size": 9 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "os-metadata" + } + }, + { + "name": "thumbs-db", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "assets/Thumbs.db", + "sha256": "addf73f06bac0cdf3076663b0285957d1fbd7a0f13e3cc204dc6d01e2a77a683", + "size": 16 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "os-metadata" + } + }, + { + "name": "desktop-ini", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "desktop.ini", + "sha256": "f13dbd1ccb62e9262979f2763488d6be8882507c5fee47a45c64981005ec2289", + "size": 11 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "os-metadata" + } + }, + { + "name": "appledouble", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "assets/._logo.png", + "sha256": "b65e2349788f187108d2be235870acaef9aab0eaefb1a42011058f14d2cb63b5", + "size": 17 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "os-metadata" + } + }, + { + "name": "macosx-archive-dir", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "__MACOSX/assets/._logo.png", + "sha256": "d6b504fa7e54cf226dda8285d98803b121425b9d32f1a7c9674cb346fd1e8dba", + "size": 26 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "os-metadata" + } + }, + { + "name": "git", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".git/config", + "sha256": "24d5d24b83021e1b2d03e9db75e2b0211bcc4db36d989a90fc0018ac39532f1b", + "size": 11 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "dependencies-and-git" + } + }, + { + "name": "nested-git-alias", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "vendor/.GIT/HEAD", + "sha256": "01586f537b463dbf237f9d81c1be9fb415f142e147397f495c9672b45abce31f", + "size": 16 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "dependencies-and-git" + } + }, + { + "name": "node-modules", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "tools/node_modules/x/index.js", + "sha256": "4dc9a7d37083252de686764e8d40b758ecc55be5d36d54057d00330918458f60", + "size": 29 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "dependencies-and-git" + } + }, + { + "name": "cache", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".thumbnails/a.png", + "sha256": "c619acdc2c5fe699cad09544842a6645fe5b544816be734cd2fa5f24e936da11", + "size": 17 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "root-generated-output" + } + }, + { + "name": "renders", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "renders/final.mp4", + "sha256": "9467c7c20a7b98b344ba740bcd09cb407c0c399e5fee553a6b999937489f2492", + "size": 17 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "root-generated-output" + } + }, + { + "name": "env", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".env", + "sha256": "e9cbb0224c4a3d23a6019ba557e0cd568c1ad5e1582ff1e335fb7d99b7a1055d", + "size": 4 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "environment-secrets" + } + }, + { + "name": "nested-env-local", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "server/.env.local", + "sha256": "4d7ff31f5c459d4fa73b5fe648698597448cfc1f5ec48d85986cd1457e3446fb", + "size": 17 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "environment-secrets" + } + }, + { + "name": "env-uppercase", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".ENV", + "sha256": "d2e25423e23bb13c9e87726ce664945c343f4fd7fe4f99030ba3e6e66e34af6e", + "size": 4 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "environment-secrets" + } + }, + { + "name": "env-example", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".env.example", + "sha256": "a3046da0d15a27e89f2afe639b25748a7ad4d9290af3e7b1b6c1a5533c8f0a8c", + "size": 12 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "environment-secrets" + } + }, + { + "name": "envrc", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": ".envrc", + "sha256": "d33e979799a45c7c51752e9c8d96a3e452015d1a40b1e4b6ec6a98e92c4d8430", + "size": 6 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "environment-secrets" + } + }, + { + "name": "codex-agent-state-1", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "size": 1 + }, + { + "path": ".codex/config.toml", + "sha256": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + "size": 2 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "agent-client-state" + } + }, + { + "name": "codex-agent-state-2", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "size": 1 + }, + { + "path": "scenes/.CoDeX/agents/private.json", + "sha256": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + "size": 2 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "agent-client-state" + } + }, + { + "name": "codex-agent-state-3", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "size": 1 + }, + { + "path": ".hyperframes/prepared-assets/podcast/media/.codex/config.toml", + "sha256": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + "size": 2 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "agent-client-state" + } + }, + { + "name": "codex-agent-state-4", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "size": 1 + }, + { + "path": ".hyperframes/transcripts/.codex/private.json", + "sha256": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + "size": 2 + } + ] + }, + "error": { + "code": "excluded_path", + "rule": "agent-client-state" + } + } + ], + "limits": [ + { + "name": "within-limits", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "a.bin", + "sha256": "4fef9cffec13baaa0b8bab5ae61005c5ee8bdb7880b255d60c27e8b7b45202ba", + "size": 100 + }, + { + "path": "b.bin", + "sha256": "87b6c6feb9fc94a9998018df8566c72835e2e25573894d97480bd8d47af927d0", + "size": 200 + }, + { + "path": "b-copy.bin", + "sha256": "87b6c6feb9fc94a9998018df8566c72835e2e25573894d97480bd8d47af927d0", + "size": 200 + } + ] + }, + "limits": { + "max_files": 4, + "max_file_bytes": 200, + "max_project_bytes": 510, + "max_manifest_bytes": 481 + }, + "limit": null + }, + { + "name": "file-count", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "a.bin", + "sha256": "4fef9cffec13baaa0b8bab5ae61005c5ee8bdb7880b255d60c27e8b7b45202ba", + "size": 100 + }, + { + "path": "b.bin", + "sha256": "87b6c6feb9fc94a9998018df8566c72835e2e25573894d97480bd8d47af927d0", + "size": 200 + }, + { + "path": "b-copy.bin", + "sha256": "87b6c6feb9fc94a9998018df8566c72835e2e25573894d97480bd8d47af927d0", + "size": 200 + } + ] + }, + "limits": { + "max_files": 3, + "max_file_bytes": 1, + "max_project_bytes": 1, + "max_manifest_bytes": 1 + }, + "limit": "file_count" + }, + { + "name": "file-size", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "a.bin", + "sha256": "4fef9cffec13baaa0b8bab5ae61005c5ee8bdb7880b255d60c27e8b7b45202ba", + "size": 100 + }, + { + "path": "b.bin", + "sha256": "87b6c6feb9fc94a9998018df8566c72835e2e25573894d97480bd8d47af927d0", + "size": 200 + }, + { + "path": "b-copy.bin", + "sha256": "87b6c6feb9fc94a9998018df8566c72835e2e25573894d97480bd8d47af927d0", + "size": 200 + } + ] + }, + "limits": { + "max_files": 4, + "max_file_bytes": 199, + "max_project_bytes": 1, + "max_manifest_bytes": 1 + }, + "limit": "file_size" + }, + { + "name": "project-size-counts-reused-files", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "a.bin", + "sha256": "4fef9cffec13baaa0b8bab5ae61005c5ee8bdb7880b255d60c27e8b7b45202ba", + "size": 100 + }, + { + "path": "b.bin", + "sha256": "87b6c6feb9fc94a9998018df8566c72835e2e25573894d97480bd8d47af927d0", + "size": 200 + }, + { + "path": "b-copy.bin", + "sha256": "87b6c6feb9fc94a9998018df8566c72835e2e25573894d97480bd8d47af927d0", + "size": 200 + } + ] + }, + "limits": { + "max_files": 4, + "max_file_bytes": 200, + "max_project_bytes": 509, + "max_manifest_bytes": 1 + }, + "limit": "project_size" + }, + { + "name": "manifest-size", + "manifest": { + "format_version": 1, + "entrypoint": "index.html", + "files": [ + { + "path": "index.html", + "sha256": "0eb547304658805aad788d320f10bf1f292797b5e6d745a3bf617584da017051", + "size": 10 + }, + { + "path": "a.bin", + "sha256": "4fef9cffec13baaa0b8bab5ae61005c5ee8bdb7880b255d60c27e8b7b45202ba", + "size": 100 + }, + { + "path": "b.bin", + "sha256": "87b6c6feb9fc94a9998018df8566c72835e2e25573894d97480bd8d47af927d0", + "size": 200 + }, + { + "path": "b-copy.bin", + "sha256": "87b6c6feb9fc94a9998018df8566c72835e2e25573894d97480bd8d47af927d0", + "size": 200 + } + ] + }, + "limits": { + "max_files": 4, + "max_file_bytes": 200, + "max_project_bytes": 510, + "max_manifest_bytes": 480 + }, + "limit": "manifest_size" + } + ], + "stored": [ + { + "name": "canonical", + "body": "eyJlbnRyeXBvaW50IjoiaW5kZXguaHRtbCIsImZpbGVzIjpbeyJwYXRoIjoiY2Fmw6kudHh0Iiwic2hhMjU2IjoiNTk5NmQxZjc5MDVjMjQ0YzRmYTJjMzhlMjliNGYxZjIzNzQ4MzE2MjZhMzExNDg5MjIxY2NiM2YyMzNjYzRlOCIsInNpemUiOjl9LHsicGF0aCI6ImluZGV4Lmh0bWwiLCJzaGEyNTYiOiIwZWI1NDczMDQ2NTg4MDVhYWQ3ODhkMzIwZjEwYmYxZjI5Mjc5N2I1ZTZkNzQ1YTNiZjYxNzU4NGRhMDE3MDUxIiwic2l6ZSI6MTB9XSwiZm9ybWF0X3ZlcnNpb24iOjF9", + "error": null + }, + { + "name": "pretty-printed", + "body": "ewogICJlbnRyeXBvaW50IjogImluZGV4Lmh0bWwiLAogICJmaWxlcyI6IFsKICAgIHsKICAgICAgInBhdGgiOiAiY2Fmw6kudHh0IiwKICAgICAgInNoYTI1NiI6ICI1OTk2ZDFmNzkwNWMyNDRjNGZhMmMzOGUyOWI0ZjFmMjM3NDgzMTYyNmEzMTE0ODkyMjFjY2IzZjIzM2NjNGU4IiwKICAgICAgInNpemUiOiA5CiAgICB9LAogICAgewogICAgICAicGF0aCI6ICJpbmRleC5odG1sIiwKICAgICAgInNoYTI1NiI6ICIwZWI1NDczMDQ2NTg4MDVhYWQ3ODhkMzIwZjEwYmYxZjI5Mjc5N2I1ZTZkNzQ1YTNiZjYxNzU4NGRhMDE3MDUxIiwKICAgICAgInNpemUiOiAxMAogICAgfQogIF0sCiAgImZvcm1hdF92ZXJzaW9uIjogMQp9", + "error": { + "code": "not_canonical" + } + }, + { + "name": "ascii-escaped", + "body": "eyJlbnRyeXBvaW50IjoiaW5kZXguaHRtbCIsImZpbGVzIjpbeyJwYXRoIjoiY2FmXHUwMGU5LnR4dCIsInNoYTI1NiI6IjU5OTZkMWY3OTA1YzI0NGM0ZmEyYzM4ZTI5YjRmMWYyMzc0ODMxNjI2YTMxMTQ4OTIyMWNjYjNmMjMzY2M0ZTgiLCJzaXplIjo5fSx7InBhdGgiOiJpbmRleC5odG1sIiwic2hhMjU2IjoiMGViNTQ3MzA0NjU4ODA1YWFkNzg4ZDMyMGYxMGJmMWYyOTI3OTdiNWU2ZDc0NWEzYmY2MTc1ODRkYTAxNzA1MSIsInNpemUiOjEwfV0sImZvcm1hdF92ZXJzaW9uIjoxfQ==", + "error": { + "code": "not_canonical" + } + }, + { + "name": "keys-unsorted", + "body": "eyJmb3JtYXRfdmVyc2lvbiI6MSwiZW50cnlwb2ludCI6ImluZGV4Lmh0bWwiLCJmaWxlcyI6W3sicGF0aCI6ImNhZsOpLnR4dCIsInNoYTI1NiI6IjU5OTZkMWY3OTA1YzI0NGM0ZmEyYzM4ZTI5YjRmMWYyMzc0ODMxNjI2YTMxMTQ4OTIyMWNjYjNmMjMzY2M0ZTgiLCJzaXplIjo5fSx7InBhdGgiOiJpbmRleC5odG1sIiwic2hhMjU2IjoiMGViNTQ3MzA0NjU4ODA1YWFkNzg4ZDMyMGYxMGJmMWYyOTI3OTdiNWU2ZDc0NWEzYmY2MTc1ODRkYTAxNzA1MSIsInNpemUiOjEwfV19", + "error": { + "code": "not_canonical" + } + }, + { + "name": "files-unsorted", + "body": "eyJlbnRyeXBvaW50IjoiaW5kZXguaHRtbCIsImZpbGVzIjpbeyJwYXRoIjoiaW5kZXguaHRtbCIsInNoYTI1NiI6IjBlYjU0NzMwNDY1ODgwNWFhZDc4OGQzMjBmMTBiZjFmMjkyNzk3YjVlNmQ3NDVhM2JmNjE3NTg0ZGEwMTcwNTEiLCJzaXplIjoxMH0seyJwYXRoIjoiY2Fmw6kudHh0Iiwic2hhMjU2IjoiNTk5NmQxZjc5MDVjMjQ0YzRmYTJjMzhlMjliNGYxZjIzNzQ4MzE2MjZhMzExNDg5MjIxY2NiM2YyMzNjYzRlOCIsInNpemUiOjl9XSwiZm9ybWF0X3ZlcnNpb24iOjF9", + "error": { + "code": "not_canonical" + } + }, + { + "name": "byte-order-mark", + "body": "77u/eyJlbnRyeXBvaW50IjoiaW5kZXguaHRtbCIsImZpbGVzIjpbeyJwYXRoIjoiY2Fmw6kudHh0Iiwic2hhMjU2IjoiNTk5NmQxZjc5MDVjMjQ0YzRmYTJjMzhlMjliNGYxZjIzNzQ4MzE2MjZhMzExNDg5MjIxY2NiM2YyMzNjYzRlOCIsInNpemUiOjl9LHsicGF0aCI6ImluZGV4Lmh0bWwiLCJzaGEyNTYiOiIwZWI1NDczMDQ2NTg4MDVhYWQ3ODhkMzIwZjEwYmYxZjI5Mjc5N2I1ZTZkNzQ1YTNiZjYxNzU4NGRhMDE3MDUxIiwic2l6ZSI6MTB9XSwiZm9ybWF0X3ZlcnNpb24iOjF9", + "error": { + "code": "invalid_json" + } + }, + { + "name": "not-utf8", + "body": "eyJlbnRyeXBvaW50IjoiaW5kZXguaHRtbCIsImZpbGVzIjpbeyJwYXRoIjoiY2Fm6S50eHQiLCJzaGEyNTYiOiI1OTk2ZDFmNzkwNWMyNDRjNGZhMmMzOGUyOWI0ZjFmMjM3NDgzMTYyNmEzMTE0ODkyMjFjY2IzZjIzM2NjNGU4Iiwic2l6ZSI6OX0seyJwYXRoIjoiaW5kZXguaHRtbCIsInNoYTI1NiI6IjBlYjU0NzMwNDY1ODgwNWFhZDc4OGQzMjBmMTBiZjFmMjkyNzk3YjVlNmQ3NDVhM2JmNjE3NTg0ZGEwMTcwNTEiLCJzaXplIjoxMH1dLCJmb3JtYXRfdmVyc2lvbiI6MX0=", + "error": { + "code": "invalid_json" + } + }, + { + "name": "truncated", + "body": "eyJlbnRyeXBvaW50IjoiaW5kZXguaHRtbCIsImZpbGVzIjpbeyJwYXRoIjoiY2Fmw6kudHh0Iiwic2hhMjU2IjoiNTk5NmQxZjc5MDVjMjQ0YzRmYTJjMzhlMjliNGYxZjIzNzQ4MzE2MjZhMzExNDg5MjIxY2NiM2YyMzNjYzRlOCIsInNpemUiOjl9LHsicGF0aCI6ImluZGV4Lmh0bWwiLCJzaGEyNTYiOiIwZWI1NDczMDQ2NTg4MDVhYWQ3ODhkMzIwZjEwYmYxZjI5Mjc5N2I1ZTZkNzQ1YTNiZjYxNzU4NGRhMDE3MDUxIiwic2l6ZSI6MTB9XSwiZm9ybWF0X3ZlcnNpb24iOjE=", + "error": { + "code": "invalid_json" + } + } + ] +} diff --git a/packages/share/tests/kernel.test.mjs b/packages/share/tests/kernel.test.mjs index 2728435f49..ef8d4dd97a 100644 --- a/packages/share/tests/kernel.test.mjs +++ b/packages/share/tests/kernel.test.mjs @@ -1,6 +1,6 @@ import { test } from "node:test"; import assert from "node:assert/strict"; -import fs, { mkdtemp, mkdir, readFile, writeFile, rm, symlink } from "node:fs/promises"; +import fs, { mkdtemp, mkdir, readFile, writeFile, rm, symlink, utimes } from "node:fs/promises"; import { tmpdir, hostname } from "node:os"; import { join } from "node:path"; import { realpathSync } from "node:fs"; @@ -13,6 +13,7 @@ import { reviewClient, reviewRecord, addVersion, + pendingReviewExport, reviewVersion, refreshReviewExport, putFile, @@ -273,6 +274,45 @@ test("HTML stamps and generated render metadata do not dirty the shared source", await writeFile(join(dir, "index.html"), '
Changed
'); assert.notEqual(await projectFingerprint(dir), before); }); +test("a host can accept a version that is still screening when it stops waiting", async (t) => { + const dir = await folder(t); + const api = client(); + await shareForReview({ projectPath: dir, title: "Video", client: api, audience: "public" }); + await writeFile(join(dir, ".hyperframes/video.mp4"), "video bytes"); + bindShareHost({ projectFingerprint: async () => "rendered" }); + t.after(() => bindShareHost({ projectFingerprint })); + let video = { + status: "screening", + screening_state: "held", + video_id: "vid", + version_id: "v1", + exported_at: "2026-11-04T00:00:00Z", + }; + api.createExport = t.mock.fn(async () => video); + api.readExport = async () => video; + const onAdded = t.mock.fn(); + const request = { + projectPath: dir, + title: "Video", + client: api, + probe: async () => ({ width: 1920, height: 1080, duration: 1 }), + open: () => false, + onAdded, + }; + + assert.ok(await addVersion(request)); + assert.equal((await reviewVersion(dir)).held, true); + assert.equal(await addVersion({ ...request, allowPending: true }), null); + assert.equal((await pendingReviewExport(dir)).videoId, "vid"); + assert.equal((await reviewVersion(dir)).failure, null); + assert.equal(onAdded.mock.callCount(), 0); + assert.equal(api.createExport.mock.callCount(), 1); + + video = { ...video, status: "ready" }; + await refreshReviewExport(dir, api); + assert.equal(await pendingReviewExport(dir), null); + assert.equal((await reviewVersion(dir)).last.current, true); +}); const moduleUrl = new URL("../src/index.mjs", import.meta.url).href; function child(script, args) { return spawn(process.execPath, ["--input-type=module", "-e", script, ...args], { @@ -359,13 +399,15 @@ test("status recovery settles distinct video/version IDs without a new upload", }, }), ); + const saved = await readFile(file, "utf8"); + let status = "upload_pending"; let reads = 0; api.readExport = async (project, video) => { reads++; assert.equal(project, "p1"); assert.equal(video, "video-id"); return { - status: "ready", + status, video_id: video, version_id: "version-id", exported_at: "2026-11-04T00:00:00Z", @@ -375,13 +417,17 @@ test("status recovery settles distinct video/version IDs without a new upload", assert.equal(reads, 0); await refreshReviewExport(dir, api); assert.equal(reads, 1); + assert.equal(await readFile(file, "utf8"), saved); + status = "ready"; + await refreshReviewExport(dir, api); + assert.equal(reads, 2); assert.equal(JSON.parse(await readFile(file, "utf8")).pending, null); assert.equal( (await reviewVersion(dir, { latestReadyVersionId: "version-id" })).last.current, true, ); await refreshReviewExport(dir, api); - assert.equal(reads, 1); + assert.equal(reads, 2); }); test("refuses an unconfigured review upload destination before sending the file", async (t) => { const dir = await folder(t); @@ -518,3 +564,88 @@ for (const name of ["review.json", "review-export.json", "review-switch.json"]) assert.equal(await readFile(file, "utf8"), ""); }); } +test("required source never silently degrades after preparation or a server mismatch", async (t) => { + const dir = await folder(t); + await mkdir(join(dir, ".hyperframes")); + await writeFile(join(dir, ".hyperframes/video.mp4"), "video"); + bindShareHost({ projectFingerprint: async () => "rendered" }); + t.after(() => bindShareHost({ projectFingerprint })); + let creates = 0; + const api = { + createExport: async () => { + creates++; + throw new Error("should not send"); + }, + }; + const request = { + projectPath: dir, + title: "Video", + client: api, + projectId: "project", + requireSource: true, + probe: async () => ({ width: 100, height: 100, duration: 1 }), + filesForExport: async () => null, + }; + assert.match(await addVersion(request), /Source changed/); + assert.equal(creates, 0); + const { ReviewFailed } = await import("../src/reviewClient.mjs"); + api.createExport = async () => { + creates++; + throw new ReviewFailed(422, "snapshot_mismatch"); + }; + await addVersion({ + ...request, + filesForExport: async () => ({ + space_id: "space", + composition_id: "comp", + snapshot_id: "snap", + }), + }); + assert.equal(creates, 1); +}); + +test("content fingerprints detect same-size changes with restored timestamps", async (t) => { + const dir = await folder(t); + const file = join(dir, "asset.txt"); + const time = new Date("2026-11-01T00:00:00Z"); + await writeFile(file, "first"); + await utimes(file, time, time); + const metadata = await projectFingerprint(dir); + const content = await projectFingerprint(dir, { byContent: true }); + await writeFile(file, "other"); + await utimes(file, time, time); + assert.equal(await projectFingerprint(dir), metadata); + assert.notEqual(await projectFingerprint(dir, { byContent: true }), content); +}); + +test("a video-only retry never replays an unanswered source-bearing export", async (t) => { + const dir = await folder(t); + await mkdir(join(dir, ".hyperframes")); + await writeFile(join(dir, ".hyperframes/video.mp4"), "video bytes"); + bindShareHost({ projectFingerprint: async () => "rendered" }); + t.after(() => bindShareHost({ projectFingerprint })); + let creates = 0; + const request = { + projectPath: dir, + title: "Video", + client: { + createExport: async () => { + creates++; + throw new Error("lost response"); + }, + }, + projectId: "project", + probe: async () => ({ width: 100, height: 100, duration: 1 }), + filesForExport: async () => ({ + space_id: "space", + composition_id: "composition", + snapshot_id: "snapshot", + }), + }; + await addVersion({ ...request, requireSource: true }); + assert.match( + await addVersion({ ...request, omitSource: true }), + /pending upload includes source/, + ); + assert.equal(creates, 1); +}); diff --git a/packages/share/tests/reviewFailurePersistence.test.mjs b/packages/share/tests/reviewFailurePersistence.test.mjs new file mode 100644 index 0000000000..a7095258de --- /dev/null +++ b/packages/share/tests/reviewFailurePersistence.test.mjs @@ -0,0 +1,251 @@ +import assert from "node:assert/strict"; +import { createHash } from "node:crypto"; +import { execFile } from "node:child_process"; +import { realpathSync } from "node:fs"; +import { mkdtemp, mkdir, writeFile, readFile, rm } from "node:fs/promises"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; +import { promisify } from "node:util"; +import { test } from "node:test"; +import { addVersion, bindShareHost, refreshReviewExport, ReviewFailed } from "../src/index.mjs"; + +const run = promisify(execFile); +const moduleUrl = new URL("../src/index.mjs", import.meta.url).href; +async function fixture(t) { + const dir = realpathSync(await mkdtemp(join(tmpdir(), "hf-failed-export-"))); + t.after(() => rm(dir, { recursive: true, force: true })); + await mkdir(join(dir, ".hyperframes")); + await writeFile(join(dir, ".hyperframes", "video.mp4"), "video"); + await writeFile( + join(dir, ".hyperframes", "review.json"), + JSON.stringify({ + studioProjectId: "studio", + projectId: "project", + opened: true, + }), + ); + bindShareHost({ + normalize: realpathSync, + channelSite: "https://hyperframes.dev", + projectFingerprint: async () => "rendered", + latestExportFile: () => ({ + path: join(dir, ".hyperframes", "video.mp4"), + fingerprint: "rendered", + id: "render", + }), + }); + return dir; +} +async function readFromAnotherProcess(dir, fingerprint = "rendered", renderId = "render") { + const script = ` + import { realpathSync } from 'node:fs'; + import { join } from 'node:path'; + import { bindShareHost, reviewVersion } from ${JSON.stringify(moduleUrl)}; + const [dir, fingerprint, renderId] = process.argv.slice(1); + bindShareHost({ normalize: realpathSync, channelSite: 'https://hyperframes.dev', + projectFingerprint: async () => fingerprint, + latestExportFile: () => ({ path: join(dir, '.hyperframes', 'video.mp4'), fingerprint, id: renderId }), + }); + console.log(JSON.stringify(await reviewVersion(dir))); + `; + const { stdout } = await run(process.execPath, [ + "--input-type=module", + "-e", + script, + dir, + fingerprint, + renderId, + ]); + return JSON.parse(stdout); +} +const pending = { + projectId: "project", + videoId: "failed-video", + body: { + title_snapshot: "Video", + coordinate_width: 100, + coordinate_height: 100, + duration_seconds: 1, + render_settings: {}, + source_revision_id: null, + source_fingerprint: "rendered", + local_upload: { + checksum_sha256: createHash("sha256").update("video").digest("base64"), + content_type: "video/mp4", + size_bytes: 5, + }, + client_operation_id: "operation", + }, +}; +const ready = { + status: "ready", + video_id: "new-video", + version_id: "new-version", + exported_at: "2026-11-08T00:00:00Z", +}; +for (const update of [false, true]) { + test(`a rejected ${update ? "update" : "first export"} survives a new process until a successful retry`, async (t) => { + const dir = await fixture(t); + const file = join(dir, ".hyperframes", "review-export.json"); + const last = update + ? { + projectId: "project", + versionId: "old-version", + fingerprint: "old-render", + exportedAt: "2026-11-07T00:00:00Z", + } + : null; + await writeFile(file, JSON.stringify({ pending, last })); + await refreshReviewExport(dir, { + readExport: async () => ({ + status: "failed", + error: { reason: "content_rejected", message: "raw-sensitive-message" }, + }), + }); + const fresh = await readFromAnotherProcess(dir); + assert.equal(fresh.failure, "This video can't be shared."); + assert.equal(fresh.retryable, false); + assert.equal(fresh.last?.exportedAt ?? null, last?.exportedAt ?? null); + assert.equal((await readFromAnotherProcess(dir)).failure, fresh.failure); + assert.equal((await readFromAnotherProcess(dir, "new-render")).failure, null); + const saved = JSON.parse(await readFile(file, "utf8")); + assert.equal(saved.pending, null); + assert.equal(JSON.stringify(saved).includes("raw-sensitive-message"), false); + const error = await addVersion({ + projectPath: dir, + projectId: "project", + title: "Video", + probe: async () => ({ width: 100, height: 100, duration: 1 }), + client: { createExport: async () => ready }, + }); + assert.equal(error, null); + const succeeded = await readFromAnotherProcess(dir); + assert.equal(succeeded.failure, null); + assert.equal(succeeded.last.exportedAt, ready.exported_at); + }); +} + +test("malformed optional failure metadata is ignored and valid failures never follow another project", async (t) => { + const dir = await fixture(t); + const file = join(dir, ".hyperframes", "review-export.json"); + await writeFile(file, JSON.stringify({ pending, last: null })); + await refreshReviewExport(dir, { + readExport: async () => ({ status: "failed", error: { reason: "content_rejected" } }), + }); + await writeFile( + join(dir, ".hyperframes", "review.json"), + JSON.stringify({ + studioProjectId: "other-studio", + projectId: "other-project", + opened: true, + }), + ); + assert.equal((await readFromAnotherProcess(dir)).failure, null); + await writeFile( + file, + JSON.stringify({ pending: null, last: null, failure: { projectId: "other-project" } }), + ); + assert.equal((await readFromAnotherProcess(dir)).failure, null); +}); + +test("a replacement render with the same source cannot inherit the failed upload", async (t) => { + const dir = await fixture(t); + await addVersion({ + projectPath: dir, + projectId: "project", + title: "Video", + allowPending: true, + open: () => false, + probe: async () => ({ width: 100, height: 100, duration: 1 }), + client: { createExport: async () => ({ status: "processing", video_id: "video" }) }, + }); + await refreshReviewExport(dir, { + readExport: async () => ({ status: "failed", error: { reason: "content_rejected" } }), + }); + assert.equal((await readFromAnotherProcess(dir)).failure, "This video can't be shared."); + assert.equal((await readFromAnotherProcess(dir, "rendered", "new-render-id")).failure, null); +}); + +test("legacy pending uploads use the video checksum before binding a recovered failure", async (t) => { + const dir = await fixture(t); + await writeFile( + join(dir, ".hyperframes", "review-export.json"), + JSON.stringify({ pending, last: null }), + ); + await writeFile(join(dir, ".hyperframes", "video.mp4"), "replacement-video"); + await refreshReviewExport(dir, { + readExport: async () => ({ status: "failed", error: { reason: "content_rejected" } }), + }); + assert.equal((await readFromAnotherProcess(dir)).failure, null); +}); + +test("malformed optional failure leaves a valid pending upload and previous version intact", async (t) => { + const dir = await fixture(t); + const file = join(dir, ".hyperframes", "review-export.json"); + const last = { + projectId: "project", + versionId: "old", + fingerprint: "rendered", + exportedAt: "before", + }; + await writeFile(file, JSON.stringify({ pending, last, failure: { projectId: "project" } })); + const value = await readFromAnotherProcess(dir); + assert.equal(value.failure, null); + assert.equal(value.last.exportedAt, "before"); + assert.deepEqual(JSON.parse(await readFile(file, "utf8")).pending, pending); +}); + +for (const update of [false, true]) { + test(`registration 403 for ${update ? "update" : "first share"} persists across processes and allows retry`, async (t) => { + const dir = await fixture(t); + const file = join(dir, ".hyperframes", "review-export.json"); + const last = update + ? { projectId: "project", versionId: "old", fingerprint: "old", exportedAt: "2026-11-01" } + : null; + await writeFile(file, JSON.stringify({ pending: null, last })); + const request = { + projectPath: dir, + projectId: "project", + title: "Video", + probe: async () => ({ width: 100, height: 100, duration: 1 }), + }; + const failure = await addVersion({ + ...request, + client: { + createExport: async () => { + throw new ReviewFailed(403, "export_blocked"); + }, + }, + }); + assert.equal(failure, "Adding videos to review pages isn't available for this account."); + const fresh = await readFromAnotherProcess(dir); + assert.equal(fresh.failure, failure); + assert.equal(fresh.retryable, false); + const saved = JSON.parse(await readFile(file, "utf8")); + assert.equal(saved.pending, null); + assert.deepEqual(saved.last, last); + assert.equal( + await addVersion({ ...request, client: { createExport: async () => ready } }), + null, + ); + assert.equal((await readFromAnotherProcess(dir)).failure, null); + }); +} + +test("hourly registration limit retains its retry guidance after recovery", async (t) => { + const dir = await fixture(t); + const failure = await addVersion({ + projectPath: dir, + projectId: "project", + title: "Video", + probe: async () => ({ width: 100, height: 100, duration: 1 }), + client: { + createExport: async () => { + throw new ReviewFailed(429, "export_hourly_limit", undefined, 90_000); + }, + }, + }); + assert.match(failure, /this hour.*in 2 minutes/); + const recovered = await readFromAnotherProcess(dir); + assert.equal(recovered.failure, failure); +}); diff --git a/packages/share/tests/sourceAdapter.test.mjs b/packages/share/tests/sourceAdapter.test.mjs new file mode 100644 index 0000000000..61b9b3ae0a --- /dev/null +++ b/packages/share/tests/sourceAdapter.test.mjs @@ -0,0 +1,410 @@ +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { mkdtemp, writeFile, rm, readFile, symlink, mkdir, realpath } from "node:fs/promises"; +import { tmpdir } from "node:os"; +import { dirname, join } from "node:path"; +import { createHash } from "node:crypto"; +import { + shareSources, + shareSourceFingerprint, + createProjectShareSourceStore, +} from "../src/shareSources.mjs"; +import { projectFingerprint } from "../src/projectSnapshot.mjs"; +import { captureProject } from "../src/sources/capture.mjs"; +import { sourceApi } from "../src/sources/api.mjs"; +import { SyncApiError } from "../src/sources/errors.mjs"; +import { V1_LIMITS } from "../src/sources/limits.mjs"; +import { bindShareHost } from "../src/host.mjs"; + +bindShareHost({ reviewUploadOrigins: ["https://storage.test"] }); + +const signed = { + token: "test-token", + owner: "owner", + heygen: "https://app.test", + heygenApi: "https://api.test", +}; +async function fixture(t, files = {}) { + const root = await realpath(await mkdtemp(join(tmpdir(), "hf-source-test-"))); + t.after(() => rm(root, { recursive: true, force: true })); + await writeFile(join(root, "index.html"), "video"); + for (const [file, content] of Object.entries(files)) await writeFile(join(root, file), content); + const rendered = await projectFingerprint(root); + const store = createProjectShareSourceStore(); + return { + root, + rendered, + store, + key: { backend: signed.heygenApi, account: signed.owner, projectPath: root }, + }; +} +function fakeServer(overrides = {}) { + const calls = { create: 0, begin: [], puts: [], submit: 0, snapshot: 0 }; + let held; + let composition; + const receipt = (status = "pending") => ({ + uploadId: "upload", + compositionId: composition, + snapshotId: "snapshot", + status, + errorCode: null, + baseSnapshotId: null, + resolvesConflictSnapshotIds: [], + manifestSha256: held.manifest.sha256, + uploadDeadline: "2099-01-01T00:00:00Z", + verificationDeadline: null, + completedAt: null, + result: + status === "completed" + ? { + snapshotId: "snapshot", + publicationOutcome: "published", + conflictedWithSnapshotId: null, + } + : null, + }); + const api = { + limits: async () => ({ + at: "read", + syncAllowed: true, + maxCompositions: 5, + compositions: 0, + push: V1_LIMITS, + }), + create: async (_space, id) => { + calls.create++; + composition = id; + return { id }; + }, + begin: async (_space, id, request) => { + composition = id; + held = request; + calls.begin.push(request); + return { ...receipt(), created: true, present: [], needed: request.manifest.document.files }; + }, + uploadUrls: async (_space, _comp, _upload, files) => + files.map((file) => ({ + ...file, + url: `https://storage.test/${file.sha256}`, + headers: {}, + expiresAt: "2099-01-01T00:00:00Z", + parts: [], + })), + submit: async () => { + calls.submit++; + return receipt("completed"); + }, + status: async () => receipt("completed"), + snapshot: async (_space, id, snapshot) => { + calls.snapshot++; + return { + id: snapshot, + compositionId: id, + manifestSha256: held.manifest.sha256, + manifest: held.manifest, + publicationOutcome: "published", + }; + }, + ...overrides, + }; + const fetchImpl = async (url, init) => { + assert.equal(init.headers.authorization, undefined); + const bytes = Buffer.from(await new Response(init.body).arrayBuffer()); + assert.equal(createHash("sha256").update(bytes).digest("hex"), url.split("/").at(-1)); + calls.puts.push(bytes); + return new Response(null, { status: 200 }); + }; + return { api, calls, fetchImpl, receipt }; +} + +for (const path of [".media/voice.mp3", ".hyperframes/studio-manual-edits.json"]) { + test(`changing ${path} refuses source preparation and final attachment to the old render`, async (t) => { + const f = await fixture(t); + await writeFile(join(f.root, "index.html"), ''); + await mkdir(dirname(join(f.root, path)), { recursive: true }); + await writeFile(join(f.root, path), "original"); + const rendered = await projectFingerprint(f.root); + const content = await shareSourceFingerprint(f.root); + const server = fakeServer(); + const source = shareSources({ + access: async () => signed, + spaceId: "personal", + ...server, + fingerprint: async (root) => + content === (await shareSourceFingerprint(root)) ? projectFingerprint(root) : null, + }); + await writeFile(join(f.root, path), "changed"); + assert.equal(await projectFingerprint(f.root), rendered); + assert.equal((await source.prepare(f.root, rendered)).reason, "source_render_changed"); + assert.equal(server.calls.begin.length, 0); + assert.equal(await source.filesForExport(f.root, rendered), null); + await writeFile(join(f.root, path), "original"); + assert.equal((await source.prepare(f.root, rendered)).at, "ready"); + assert.ok(await source.filesForExport(f.root, rendered)); + await writeFile(join(f.root, path), "changed after preparation"); + assert.equal(await source.filesForExport(f.root, rendered), null); + }); +} + +test("source upload verifies before attachment and a fresh adapter reuses the exact published snapshot", async (t) => { + const f = await fixture(t); + const server = fakeServer(); + const options = { access: async () => signed, spaceId: "personal", ...server }; + const source = shareSources(options); + assert.equal(await source.filesForExport(f.root, f.rendered), null); + const result = await source.prepare(f.root, f.rendered); + assert.equal(result.at, "ready"); + assert.equal(server.calls.puts.length, 1); + assert.equal(server.calls.submit, 1); + assert.deepEqual(await source.filesForExport(f.root, f.rendered), result.snapshot); + assert.equal((await shareSources(options).prepare(f.root, f.rendered)).at, "ready"); + assert.equal(server.calls.begin.length, 1); + assert.equal(server.calls.snapshot, 1); + const binding = await f.store.read(f.key); + assert.equal(binding.inflight, null); + assert.equal(binding.base.snapshotId, "snapshot"); +}); + +test("changed assets invalidate prepared source even when the HTML render fingerprint stays unchanged", async (t) => { + const f = await fixture(t, { "media.mp4": "first" }); + const source = shareSources({ + access: async () => signed, + spaceId: "personal", + ...fakeServer(), + fingerprint: async () => f.rendered, + }); + assert.equal((await source.prepare(f.root, f.rendered)).at, "ready"); + await writeFile(join(f.root, "media.mp4"), "other"); + assert.equal(await source.filesForExport(f.root, f.rendered), null); +}); + +test("eligibility and busy edits refuse before creating cloud compositions", async (t) => { + const f = await fixture(t); + const server = fakeServer({ limits: async () => ({ syncAllowed: false }) }); + assert.deepEqual( + await shareSources({ access: async () => signed, spaceId: "personal", ...server }).prepare( + f.root, + f.rendered, + ), + { at: "unavailable", reason: "source_plan_required" }, + ); + assert.equal(server.calls.create, 0); + await mkdir(join(f.root, ".hyperframes"), { recursive: true }); + await writeFile(join(f.root, ".hyperframes/history-turn.json"), "{}"); + const next = fakeServer(); + assert.equal( + ( + await shareSources({ access: async () => signed, spaceId: "personal", ...next }).prepare( + f.root, + f.rendered, + ) + ).reason, + "source_edit_in_progress", + ); + assert.equal(next.calls.create, 0); +}); + +test("lost Begin response retries the durable idempotency key, without creating a second composition", async (t) => { + const f = await fixture(t); + const server = fakeServer(); + const begin = server.api.begin; + let fail = true; + server.api.begin = async (...args) => { + const answer = await begin(...args); + if (fail) { + fail = false; + throw new Error("network lost"); + } + return answer; + }; + const opts = { access: async () => signed, spaceId: "personal", ...server }; + await assert.rejects(shareSources(opts).prepare(f.root, f.rendered), /network lost/); + assert.equal((await shareSources(opts).prepare(f.root, f.rendered)).at, "ready"); + assert.equal(server.calls.begin[0].idempotencyKey, server.calls.begin[1].idempotencyKey); + assert.deepEqual(server.calls.begin[0].manifest, server.calls.begin[1].manifest); +}); + +test("confirmed expired upload clears its intent so a retry starts with a new key", async (t) => { + const f = await fixture(t); + const server = fakeServer(); + const begin = server.api.begin; + server.api.begin = async (...args) => { + const answer = await begin(...args); + return server.calls.begin.length === 1 ? { ...answer, status: "expired" } : answer; + }; + const source = shareSources({ access: async () => signed, spaceId: "personal", ...server }); + + assert.equal((await source.prepare(f.root, f.rendered)).reason, "source_upload_expired"); + assert.equal((await f.store.read(f.key)).inflight, null); + assert.equal((await source.prepare(f.root, f.rendered)).at, "ready"); + assert.notEqual(server.calls.begin[0].idempotencyKey, server.calls.begin[1].idempotencyKey); +}); + +test("an unwritable pending upload is cancelled so unchanged files can retry with a new key", async (t) => { + const f = await fixture(t); + const server = fakeServer(); + const grants = server.api.uploadUrls; + server.api.uploadUrls = async () => { + throw new SyncApiError("file-not-writable"); + }; + server.api.status = async () => server.receipt("pending"); + let cancelled = 0; + server.api.cancel = async () => { + cancelled++; + return { ...server.receipt("failed"), errorCode: "cancelled" }; + }; + const source = shareSources({ access: async () => signed, spaceId: "personal", ...server }); + assert.equal((await source.prepare(f.root, f.rendered)).reason, "source_upload_not_writable"); + assert.equal(cancelled, 1); + assert.equal((await f.store.read(f.key)).inflight, null); + server.api.uploadUrls = grants; + assert.equal((await source.prepare(f.root, f.rendered)).at, "ready"); + assert.notEqual(server.calls.begin[0].idempotencyKey, server.calls.begin[1].idempotencyKey); +}); + +for (const status of ["verifying", "completed"]) { + test(`unwritable recovery retains an upload that raced cancellation into ${status}`, async (t) => { + const f = await fixture(t); + const server = fakeServer(); + server.api.uploadUrls = async () => { + throw new SyncApiError("file-not-writable"); + }; + let reads = 0; + server.api.status = async () => { + const receipt = server.receipt(++reads === 1 ? "pending" : status); + if (receipt.result) receipt.result.publicationOutcome = "conflict_saved"; + return receipt; + }; + server.api.cancel = async () => { + throw new SyncApiError("upload-not-pending"); + }; + const source = shareSources({ access: async () => signed, spaceId: "personal", ...server }); + assert.equal( + (await source.prepare(f.root, f.rendered)).reason, + status === "verifying" ? "source_verification_pending" : "source_conflict", + ); + assert.equal((await f.store.read(f.key)).inflight.uploadId, "upload"); + assert.equal(server.calls.begin.length, 1); + }); +} + +test("changed source cancels the previous pending upload before using a new key", async (t) => { + const f = await fixture(t); + const server = fakeServer(); + const submit = server.api.submit; + server.api.submit = async () => { + throw new Error("lost connection"); + }; + server.api.status = async () => server.receipt("pending"); + let cancelled = 0; + server.api.cancel = async () => { + cancelled++; + return { ...server.receipt("failed"), errorCode: "cancelled" }; + }; + const source = shareSources({ access: async () => signed, spaceId: "personal", ...server }); + + await assert.rejects(source.prepare(f.root, f.rendered), /lost connection/); + await writeFile(join(f.root, "index.html"), "updated"); + server.api.submit = submit; + assert.equal((await source.prepare(f.root, await projectFingerprint(f.root))).at, "ready"); + assert.equal(cancelled, 1); + assert.notEqual(server.calls.begin[0].idempotencyKey, server.calls.begin[1].idempotencyKey); +}); + +test("conflict and pending verification cannot be attached and keep recovery intent", async (t) => { + const f = await fixture(t); + const server = fakeServer(); + server.api.submit = async () => ({ + ...server.receipt("completed"), + result: { snapshotId: "snapshot", publicationOutcome: "conflict_saved" }, + }); + const source = shareSources({ access: async () => signed, spaceId: "personal", ...server }); + assert.equal((await source.prepare(f.root, f.rendered)).reason, "source_conflict"); + assert.equal(await source.filesForExport(f.root, f.rendered), null); + assert.ok((await f.store.read(f.key)).inflight); + server.api.submit = async () => server.receipt("verifying"); + const pending = shareSources({ + access: async () => signed, + spaceId: "personal", + ...server, + verificationTimeoutMs: 0, + }); + assert.equal((await pending.prepare(f.root, f.rendered)).reason, "source_verification_pending"); +}); + +test("Desktop-owned source is read-only and never re-shared into a different workspace", async (t) => { + const f = await fixture(t); + const server = fakeServer(); + const capture = await captureProject(f.root); + const binding = { + ...f.key, + version: 1, + compositionId: "desktop", + ownerSpaceId: "team", + base: { manifestSha256: capture.manifest.sha256, snapshotId: "desktop-snapshot" }, + inflight: null, + }; + const opts = { + access: async () => signed, + spaceId: "personal", + existingBinding: async () => binding, + ...server, + }; + assert.equal( + (await shareSources(opts).prepare(f.root, f.rendered)).reason, + "source_other_workspace", + ); + binding.ownerSpaceId = "personal"; + binding.sharedFrom = { reviewProjectId: "someone-elses-share" }; + assert.equal( + (await shareSources(opts).prepare(f.root, f.rendered)).reason, + "source_owned_by_someone_else", + ); + assert.equal(server.calls.create, 0); +}); + +test("binding reads reject copied folders, account changes, and symlink state files", async (t) => { + const f = await fixture(t); + await shareSources({ access: async () => signed, spaceId: "personal", ...fakeServer() }).prepare( + f.root, + f.rendered, + ); + await assert.rejects(f.store.read({ ...f.key, account: "other" }), /another account/); + const g = await fixture(t); + const hash = createHash("sha256").update(signed.heygenApi).digest("hex").slice(0, 16); + const name = `.hyperframes/share-sync.${hash}.json`; + await mkdir(join(g.root, ".hyperframes")); + await writeFile(join(g.root, name), await readFile(join(f.root, name))); + await assert.rejects(g.store.read(g.key), /another account/); + await rm(join(g.root, name)); + await symlink(join(f.root, name), join(g.root, name)); + await assert.rejects(g.store.read(g.key)); +}); + +test("HTTP adapter identifies CLI and sends credentials only to the API host", async () => { + const requests = []; + const api = sourceApi({ + access: async () => signed, + fetchImpl: async (url, init) => { + requests.push({ url, init }); + return Response.json({ + data: { + upload_id: "up", + composition_id: "comp", + snapshot_id: "snap", + status: "pending", + manifest_sha256: "hash", + upload_deadline: "2099-01-01T00:00:00Z", + }, + }); + }, + }); + await api.begin("space", "comp", { + idempotencyKey: "key", + baseSnapshotId: null, + manifest: { sha256: "hash", document: {} }, + }); + assert.equal(JSON.parse(requests[0].init.body).client_type, "cli"); + assert.equal(requests[0].init.headers.authorization, "Bearer test-token"); + assert.match(requests[0].url, /^https:\/\/api.test\/v3\//); +}); diff --git a/packages/share/tests/sourceCapture.test.mjs b/packages/share/tests/sourceCapture.test.mjs new file mode 100644 index 0000000000..29929d0797 --- /dev/null +++ b/packages/share/tests/sourceCapture.test.mjs @@ -0,0 +1,313 @@ +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { createHash } from "node:crypto"; +import { + lstat, + mkdir, + readdir, + mkdtemp, + realpath, + rename, + rm, + symlink, + utimes, + writeFile, +} from "node:fs/promises"; +import { tmpdir } from "node:os"; +import { dirname, join } from "node:path"; +import { captureProject, hashListedFile, hashMemo } from "../src/sources/capture.mjs"; + +/** A project folder holding `files` (path to contents). @param {Record} files */ +async function project(files) { + const root = await mkdtemp(join(tmpdir(), "hf-sync-capture-")); + for (const [path, text] of Object.entries(files)) { + await mkdir(dirname(join(root, path)), { recursive: true }); + await writeFile(join(root, path), text); + } + return root; +} + +const sha = (/** @type {string} */ text) => createHash("sha256").update(text).digest("hex"); + +/** @param {Awaited>} capture */ +function captured(capture) { + assert.equal(capture.at, "captured", JSON.stringify(capture)); + return /** @type {Extract} */ (capture); +} + +test("a capture lists portable files with their hashes and leaves out what the policy excludes", async () => { + const root = await project({ + "index.html": "", + "assets/logo.png": "png", + ".hyperframes/brand-kit.json": "{}", + ".hyperframes/comments.jsonl": "{}", + ".hyperframes/share.json": "{}", + "node_modules/x/index.js": "x", + ".env": "SECRET=1", + ".DS_Store": "", + "renders/out.mp4": "mp4", + "Icon\r": "", + }); + const { manifest, waiting, skippedLinks } = captured(await captureProject(root)); + assert.deepEqual(manifest.document.files, [ + { path: ".hyperframes/brand-kit.json", sha256: sha("{}"), size: 2 }, + { path: "assets/logo.png", sha256: sha("png"), size: 3 }, + { path: "index.html", sha256: sha(""), size: 13 }, + ]); + assert.match(manifest.sha256, /^[0-9a-f]{64}$/); + assert.deepEqual([waiting, skippedLinks], [[], []]); +}); + +test("a render output the CLI recorded outside renders/ stays out", async () => { + const root = await project({ + "index.html": "x", + "exports/cut.mp4": "mp4", + "exports/keep.txt": "keep", + "stills/a/b.png": "png", + ".hyperframes/render-outputs.json": JSON.stringify({ + version: 1, + paths: ["exports/cut.mp4", "stills"], + }), + }); + const { manifest } = captured(await captureProject(root)); + assert.deepEqual( + manifest.document.files.map((file) => file.path), + ["exports/keep.txt", "index.html"], + ); +}); + +test("a link fails the capture, except one under assets/podcast/, which is skipped", async () => { + const root = await project({ "index.html": "x", "outside.mov": "mov" }); + await mkdir(join(root, "assets/podcast"), { recursive: true }); + await symlink(join(root, "outside.mov"), join(root, "assets/podcast/cam.mov")); + const skipped = captured(await captureProject(root)); + assert.deepEqual(skipped.skippedLinks, ["assets/podcast/cam.mov"]); + await symlink(join(root, "outside.mov"), join(root, "assets/cam.mov")); + assert.deepEqual(await captureProject(root), { + at: "problems", + problems: [{ path: "assets/cam.mov", problem: "symlink" }], + }); +}); + +test("a name no client can store fails the capture with its code", async () => { + const root = await project({ "index.html": "x", "scenes/con.html": "x", "a?.txt": "x" }); + const capture = await captureProject(root); + assert.equal(capture.at, "problems"); + assert.deepEqual( + capture.at === "problems" ? capture.problems.map((p) => [p.path, p.code]).sort() : [], + [ + ["a?.txt", "path_invalid_character"], + ["scenes/con.html", "reserved_name"], + ], + ); +}); + +test("a project without index.html cannot be captured", async () => { + const root = await project({ "scene.html": "x" }); + assert.deepEqual(await captureProject(root), { + at: "problems", + problems: [{ path: "index.html", problem: "no-entrypoint" }], + }); +}); + +test("over a limit, the capture says which and names the biggest files before hashing any", async () => { + const root = await project({ "index.html": "x", "big.bin": "0123456789", "mid.bin": "01234" }); + const limits = { maxFiles: 10, maxFileBytes: 6, maxProjectBytes: 100, maxManifestBytes: 10_000 }; + const capture = await captureProject(root, { limits }); + assert.equal(capture.at, "too-big"); + if (capture.at !== "too-big") return; + assert.deepEqual( + { limit: capture.over.limit, actual: capture.over.actual, maximum: capture.over.maximum }, + { limit: "file_size", actual: 10, maximum: 6 }, + ); + assert.deepEqual( + capture.over.biggest.map((file) => file.path), + ["big.bin", "mid.bin", "index.html"], + ); +}); + +test("a media reservation is waited on and left out, and an open agent turn is reported", async () => { + const root = await project({ + "index.html": "x", + ".media/images/a.hf0a1b2c.tmp": "", + ".hyperframes/history-turn.json": "{}", + }); + const capture = captured(await captureProject(root)); + assert.deepEqual(capture.waiting, [".media/images/a.hf0a1b2c.tmp"]); + assert.deepEqual(capture.settled, { agentTurnOpen: true, projectLocked: false }); +}); + +test("a project lock held by a running process is reported; a dead holder's is not", async () => { + const root = await project({ "index.html": "x" }); + const lock = join(root, ".hyperframes/project.lock"); + await mkdir(dirname(lock), { recursive: true }); + await writeFile(lock, JSON.stringify({ pid: process.pid, startedAt: 1, command: "render" })); + assert.equal(captured(await captureProject(root)).settled.projectLocked, true); + await writeFile(lock, JSON.stringify({ pid: 2 ** 30, startedAt: 1, command: "render" })); + assert.equal(captured(await captureProject(root)).settled.projectLocked, false); +}); + +test("a file over 4 MiB is hashed as a bounded stream, to the same digest", async () => { + const big = "x".repeat(5 * 1024 * 1024); + const root = await project({ "index.html": "x", "assets/big.bin": big }); + const { manifest } = captured(await captureProject(root)); + assert.deepEqual(manifest.document.files[0], { + path: "assets/big.bin", + sha256: sha(big), + size: big.length, + }); +}); + +test("a kept hash is reused only while the file's size and time are unchanged", async () => { + const root = await project({ "index.html": "one" }); + const memo = hashMemo(); + const first = captured(await captureProject(root, { memo })); + await writeFile(join(root, "index.html"), "two"); + await utimes(join(root, "index.html"), new Date(2030, 0, 1), new Date(2030, 0, 1)); + const second = captured(await captureProject(root, { memo })); + assert.equal(first.manifest.document.files[0]?.sha256, sha("one")); + assert.equal(second.manifest.document.files[0]?.sha256, sha("two")); +}); + +test("a same-size edit inside the file time's granularity is hashed again, never read from a kept hash", async () => { + const root = await project({ "index.html": "one" }); + const file = join(root, "index.html"); + const tick = new Date(); + await utimes(file, tick, tick); + const memo = hashMemo(); + const first = captured(await captureProject(root, { memo })); + await writeFile(file, "two"); + await utimes(file, tick, tick); + const second = captured(await captureProject(root, { memo })); + assert.equal(first.manifest.document.files[0]?.sha256, sha("one")); + assert.equal(second.manifest.document.files[0]?.sha256, sha("two")); +}); + +test("a settled file's hash is kept, so a check after a focus reads no bytes", async () => { + const root = await project({ "index.html": "one" }); + const memo = hashMemo(); + captured(await captureProject(root, { memo })); + await writeFile(join(root, "index.html"), "two"); + const settled = new Date(2020, 0, 1); + await utimes(join(root, "index.html"), settled, settled); + captured(await captureProject(root, { memo })); + await writeFile(join(root, "index.html"), "six"); + await utimes(join(root, "index.html"), settled, settled); + const kept = captured(await captureProject(root, { memo })); + assert.equal(kept.manifest.document.files[0]?.sha256, sha("two")); +}); + +/** A file as the walk lists it, read from disk now. @param {string} root @param {string} path */ +async function listed(root, path) { + const full = join(root, path); + const { size, mtimeMs, ino, dev } = await lstat(full); + return { path, full, size, mtimeMs, ino, dev }; +} + +test("a file swapped for a link of the same size after the walk is refused, never followed", async () => { + const root = await realpath(await mkdtemp(join(tmpdir(), "hf-sync-swap-"))); + const outside = await realpath(await mkdtemp(join(tmpdir(), "hf-sync-outside-"))); + await writeFile(join(root, "a.txt"), "inside"); + await writeFile(join(outside, "secret"), "SECRET"); + // The same size and time as the file listed: only the file's identity tells them apart. + await utimes(join(root, "a.txt"), 1_700_000_000, 1_700_000_000); + await utimes(join(outside, "secret"), 1_700_000_000, 1_700_000_000); + const file = await listed(root, "a.txt"); + assert.match(String(await hashListedFile(root, file)), /^[0-9a-f]{64}$/); + await rm(join(root, "a.txt")); + await symlink(join(outside, "secret"), join(root, "a.txt")); + assert.equal(await hashListedFile(root, file), null); +}); + +test("a folder swapped for a link to elsewhere after the walk is refused, even holding the same file", async () => { + const root = await realpath(await mkdtemp(join(tmpdir(), "hf-sync-swap-"))); + const outside = await realpath(await mkdtemp(join(tmpdir(), "hf-sync-outside-"))); + await mkdir(join(root, "assets")); + await writeFile(join(root, "assets", "logo.txt"), "inside"); + const file = await listed(root, "assets/logo.txt"); + await rename(join(root, "assets"), join(outside, "assets")); + await symlink(join(outside, "assets"), join(root, "assets")); + assert.equal(await hashListedFile(root, file), null, "the moved folder's own file was followed"); +}); + +test("a file whose folder cannot be resolved once opened is refused, and its handle is closed", async () => { + const root = await realpath(await mkdtemp(join(tmpdir(), "hf-sync-close-"))); + await mkdir(join(root, "assets")); + await writeFile(join(root, "assets", "logo.txt"), "inside"); + const file = await listed(root, "assets/logo.txt"); + const openFiles = async () => (await readdir("/dev/fd")).length; + const before = await openFiles(); + const gone = async () => { + throw Object.assign(new Error("ENOENT: the folder was renamed"), { code: "ENOENT" }); + }; + await assert.rejects(hashListedFile(root, file, gone), /ENOENT/); + assert.equal(await openFiles(), before, "the opened file was left open"); +}); + +test("explicit exclusions remove scratch files from capture and render fingerprints", async (t) => { + const { projectFingerprint } = await import("../src/projectSnapshot.mjs"); + const root = await project({ + "index.html": "", + ".hyperframesignore": "# Scratch files\nout.json\nscratch/\n", + "out.json": "private", + "scratch/nested.txt": "private", + "assets/data.json": "asset", + ".env": "secret", + }); + t.after(() => rm(root, { recursive: true, force: true })); + const first = captured(await captureProject(root)); + assert.deepEqual( + first.manifest.document.files.map((file) => file.path), + [".hyperframesignore", "assets/data.json", "index.html"], + ); + const before = await projectFingerprint(root); + await rm(join(root, "out.json")); + await writeFile(join(root, "scratch/nested.txt"), "changed"); + assert.equal(await projectFingerprint(root), before); + assert.deepEqual(captured(await captureProject(root)).manifest, first.manifest); + await writeFile(join(root, "assets/data.json"), "changed asset"); + assert.notEqual(await projectFingerprint(root), before); +}); + +test("ignore rules fail closed for unsupported patterns, entrypoint exclusions, and symlinks", async (t) => { + const root = await project({ "index.html": "" }); + t.after(() => rm(root, { recursive: true, force: true })); + for (const rule of ["index.html", "../secret", "*.html", "**/*.json", "!out.json"]) { + await writeFile(join(root, ".hyperframesignore"), rule); + await assert.rejects(captureProject(root), /project-relative/); + } + await rm(join(root, ".hyperframesignore")); + await symlink(join(root, "index.html"), join(root, ".hyperframesignore")); + await assert.rejects(captureProject(root), /regular file/); +}); + +test("ignore configuration rejects oversized files, directories and dangling symlinks", async (t) => { + const root = await project({ "index.html": "" }); + t.after(() => rm(root, { recursive: true, force: true })); + const file = join(root, ".hyperframesignore"); + await writeFile(file, "a".repeat(65536)); + await assert.rejects(captureProject(root), /regular file/); + await rm(file); + await mkdir(file); + await assert.rejects(captureProject(root), /regular file/); + await rm(file, { recursive: true }); + await symlink(join(root, "missing"), file); + await assert.rejects(captureProject(root), /regular file/); +}); + +test("scratch files and wildcard exclusions do not change the snapshot", async (t) => { + const { projectFingerprint } = await import("../src/projectSnapshot.mjs"); + const root = await project({ + "index.html": "", + ".hyperframesignore": "*.scratch\n", + }); + t.after(() => rm(root, { recursive: true, force: true })); + const before = await projectFingerprint(root); + const first = captured(await captureProject(root)); + await writeFile(join(root, "other.log"), "diagnostic"); + await writeFile(join(root, "notes.scratch"), "temporary"); + assert.equal(await projectFingerprint(root), before); + assert.deepEqual(captured(await captureProject(root)).manifest, first.manifest); + await writeFile(join(root, "data.json"), "{}"); + assert.notEqual(await projectFingerprint(root), before); +}); diff --git a/packages/share/tests/sourceManifest.test.mjs b/packages/share/tests/sourceManifest.test.mjs new file mode 100644 index 0000000000..ca2c534b88 --- /dev/null +++ b/packages/share/tests/sourceManifest.test.mjs @@ -0,0 +1,129 @@ +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { createHash } from "node:crypto"; +import { readFileSync } from "node:fs"; +import { + ManifestInvalid, + parseCanonicalManifest, + parseManifest, +} from "../src/sources/manifest.mjs"; +import { overLimit, V1_LIMITS } from "../src/sources/limits.mjs"; +import { excludedFolder, skippedSymlink } from "../src/sources/pathPolicy.mjs"; + +/** Reference vectors for the source manifest format. */ +const vectors = JSON.parse( + readFileSync( + new URL("./fixtures/compositionSync/manifest-vectors.json", import.meta.url), + "utf8", + ), +); + +/** @param {() => unknown} run */ +function refusal(run) { + try { + run(); + } catch (error) { + if (error instanceof ManifestInvalid) return error; + throw error; + } + return null; +} + +test("the vectors are portable-source-v4's, and there are vectors of every kind", () => { + assert.equal(vectors.policy_version, "portable-source-v4"); + assert.deepEqual( + [vectors.valid.length, vectors.invalid.length, vectors.limits.length, vectors.stored.length], + [11, 147, 5, 8], + ); +}); + +test("every valid vector builds the server's canonical bytes and manifest_sha256", () => { + for (const vector of vectors.valid) { + const manifest = parseManifest(vector.manifest); + assert.equal(manifest.canonical.toString("utf8"), vector.canonical, vector.name); + assert.equal(manifest.sha256, vector.manifest_sha256, vector.name); + assert.equal( + createHash("sha256").update(Buffer.from(vector.canonical, "utf8")).digest("hex"), + vector.manifest_sha256, + ); + assert.equal(manifest.document.files.length, vector.file_count, vector.name); + const bytes = manifest.document.files.reduce((sum, file) => sum + file.size, 0); + assert.equal(bytes, vector.project_bytes, vector.name); + } +}); + +test("every invalid vector is refused with the server's code and rule", () => { + for (const vector of vectors.invalid) { + const error = refusal(() => parseManifest(vector.manifest)); + assert.ok(error, `${vector.name} was accepted`); + assert.equal(error.code, vector.error.code, vector.name); + if (vector.error.rule) assert.equal(error.violations[0]?.rule, vector.error.rule, vector.name); + } +}); + +test("every limits vector breaks the server's first limit, or none", () => { + for (const vector of vectors.limits) { + const manifest = parseManifest(vector.manifest); + const limits = { + maxFiles: vector.limits.max_files, + maxFileBytes: vector.limits.max_file_bytes, + maxProjectBytes: vector.limits.max_project_bytes, + maxManifestBytes: vector.limits.max_manifest_bytes, + }; + const over = overLimit(manifest.document.files, manifest.canonical.length, limits); + assert.equal(over?.limit ?? null, vector.limit, vector.name); + } +}); + +test("every stored vector reads only canonical bytes", () => { + for (const vector of vectors.stored) { + const body = Buffer.from(vector.body, "base64"); + const error = refusal(() => parseCanonicalManifest(body)); + assert.equal(error?.code ?? null, vector.error?.code ?? null, vector.name); + } +}); + +test("V1 limits are 10,000 files, 5 GiB a file, 10 GiB a project and an 8 MiB manifest", () => { + assert.deepEqual(V1_LIMITS, { + maxFiles: 10000, + maxFileBytes: 5368709120, + maxProjectBytes: 10737418240, + maxManifestBytes: 8388608, + }); +}); + +test("a project over a limit names its biggest files first", () => { + const files = [ + { path: "index.html", size: 10 }, + { path: "assets/b.mp4", size: 6 * 1024 ** 3 }, + { path: "assets/a.mp4", size: 7 * 1024 ** 3 }, + ]; + const over = overLimit(files, 300); + assert.equal(over?.limit, "file_size"); + assert.equal(over?.actual, 7 * 1024 ** 3); + assert.deepEqual( + over?.biggest.map((file) => file.path), + ["assets/a.mp4", "assets/b.mp4", "index.html"], + ); +}); + +test("a capture skips only folders no included file can be under", () => { + assert.equal(excludedFolder("node_modules"), true); + assert.equal(excludedFolder("assets/node_modules"), true); + assert.equal(excludedFolder(".git"), true); + assert.equal(excludedFolder(".claude"), true); + assert.equal(excludedFolder("dist"), true); + assert.equal(excludedFolder("assets/dist"), false); + assert.equal(excludedFolder("renders"), true); + assert.equal(excludedFolder(".hyperframes"), false); + assert.equal(excludedFolder(".hyperframes/prepared-assets"), false); + assert.equal(excludedFolder("assets"), false); + assert.equal(excludedFolder("assets/renders"), false); +}); + +test("only links under assets/podcast/, in any spelling, are skipped", () => { + assert.equal(skippedSymlink("assets/podcast/cam-a.mov"), true); + assert.equal(skippedSymlink("Assets/Podcast/raw/cam-a.mov"), true); + assert.equal(skippedSymlink("assets/cam-a.mov"), false); + assert.equal(skippedSymlink("other/assets/podcast/cam-a.mov"), false); +}); diff --git a/packages/share/tests/sourceUpload.test.mjs b/packages/share/tests/sourceUpload.test.mjs new file mode 100644 index 0000000000..f2354df624 --- /dev/null +++ b/packages/share/tests/sourceUpload.test.mjs @@ -0,0 +1,271 @@ +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { mkdtemp, open, rm, realpath, symlink, writeFile } from "node:fs/promises"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; +import { createHash } from "node:crypto"; +import { uploadNeeded } from "../src/sources/uploadFiles.mjs"; +import { partDigests, putRange } from "../src/sources/transfer.mjs"; +import fsPromises from "node:fs/promises"; +import { syncBuiltinESMExports } from "node:module"; +import { bindShareHost } from "../src/host.mjs"; + +bindShareHost({ reviewUploadOrigins: ["https://store.test"] }); + +async function folder(t) { + const root = await realpath(await mkdtemp(join(tmpdir(), "hf-source-upload-"))); + t.after(() => rm(root, { recursive: true, force: true })); + return root; +} +const signal = () => new AbortController().signal; + +test("multipart retries retain the pinned upload and skip completed parts after restart", async (t) => { + const root = await folder(t); + const file = join(root, "media.mp4"); + const size = 65 * 1024 * 1024; + const handle = await open(file, "w"); + await handle.truncate(size); + await handle.close(); + const digests = await partDigests(file, size, 64 * 1024 * 1024, signal()); + const inflight = { sent: [], multipart: {} }; + const requests = []; + let fail = true; + let persisted = 0; + const job = { + api: { + uploadUrls: async (_space, _comp, _upload, files) => { + requests.push(...files); + return files.map((item) => ({ + sha256: item.sha256, + multipartUploadId: "pinned", + expiresAt: "2099-01-01T00:00:00Z", + parts: item.parts.map((part) => ({ + ...part, + url: `https://store.test/${part.partNumber}`, + headers: { checksum: part.sha256 }, + })), + })); + }, + }, + space: "space", + composition: "comp", + uploadId: "upload", + inflight, + local: new Map([[digests.whole, { path: "media.mp4", full: file }]]), + needed: [{ sha256: digests.whole, size }], + fetchImpl: async (url, init) => { + if (url.endsWith("/2") && fail) { + await init.body.cancel(); + return new Response(null, { status: 400 }); + } + const hash = createHash("sha256"); + for await (const chunk of init.body) hash.update(chunk); + assert.equal(hash.digest("hex"), init.headers.checksum); + return new Response(null, { status: 200 }); + }, + signal: signal(), + wait: async () => {}, + now: Date.now, + persist: () => persisted++, + onBytes: () => {}, + onFile: () => {}, + }; + await assert.rejects(uploadNeeded(job), /refused/); + assert.deepEqual(inflight.multipart[digests.whole].partsDone, [1]); + fail = false; + await uploadNeeded(job); + assert.equal(requests[1].multipartUploadId, "pinned"); + assert.deepEqual( + requests[1].parts.map((p) => p.partNumber), + [2], + ); + assert.deepEqual(inflight.sent, [digests.whole]); + assert.ok(persisted >= 4); +}); + +test("signed URL expiry refreshes the grant without changing the uploaded content", async (t) => { + const root = await folder(t); + const file = join(root, "index.html"); + await writeFile(file, "source"); + const digest = createHash("sha256").update("source").digest("hex"); + let grants = 0; + let puts = 0; + await uploadNeeded({ + api: { + uploadUrls: async () => { + grants++; + return [ + { + sha256: digest, + url: "https://store.test/file", + headers: {}, + expiresAt: "2099-01-01T00:00:00Z", + }, + ]; + }, + }, + space: "s", + composition: "c", + uploadId: "u", + inflight: { sent: [] }, + local: new Map([[digest, { path: "index.html", full: file }]]), + needed: [{ sha256: digest, size: 6 }], + fetchImpl: async (_url, init) => { + puts++; + await new Response(init.body).arrayBuffer(); + return new Response(null, { status: puts === 1 ? 403 : 200 }); + }, + signal: signal(), + wait: async () => {}, + now: Date.now, + persist: () => {}, + onBytes: () => {}, + onFile: () => {}, + }); + assert.equal(grants, 2); + assert.equal(puts, 2); +}); + +test("storage PUT refuses a file swapped for a symlink before reading bytes", async (t) => { + const root = await folder(t); + const target = join(root, "private.txt"); + const file = join(root, "asset.txt"); + await writeFile(target, "secret"); + await symlink(target, file); + let sent = false; + await assert.rejects( + putRange({ + file, + path: "asset.txt", + start: 0, + length: 6, + sha256: "wrong", + signal: signal(), + url: "https://store.test", + headers: {}, + fetchImpl: async () => { + sent = true; + return new Response(); + }, + }), + ); + assert.equal(sent, false); +}); + +test("source PUT refuses untrusted or redirected targets before it opens a file", async () => { + for (const url of [ + "https://untrusted.test/source", + "http://127.0.0.1:18080/source", + "https://store.test.untrusted.test/source", + "https://user:secret@store.test/source", + ]) { + await assert.rejects( + putRange({ + file: "/missing-source", + path: "index.html", + start: 0, + length: 6, + sha256: "unused", + signal: signal(), + url, + headers: {}, + fetchImpl: async () => assert.fail("Must not send bytes"), + }), + { kind: "refused" }, + ); + } +}); + +async function sourcePut(t, overrides = {}) { + const root = await folder(t); + const file = join(root, "index.html"); + await writeFile(file, "source"); + return { + file, + path: "index.html", + start: 0, + length: 6, + sha256: createHash("sha256").update("source").digest("hex"), + signal: signal(), + url: "https://store.test/file", + headers: {}, + ...overrides, + }; +} + +for (const consume of [false, true]) { + test(`source PUT times out when ${consume ? "the storage response" : "body consumption"} stalls`, async (t) => { + let requestSignal; + const put = await sourcePut(t, { + stallMs: 20, + signal: AbortSignal.timeout(2_000), + fetchImpl: async (_url, init) => { + requestSignal = init.signal; + if (consume) await new Response(init.body).arrayBuffer(); + init.signal.throwIfAborted(); + return new Promise((_resolve, reject) => { + init.signal.addEventListener("abort", () => reject(init.signal.reason), { once: true }); + }); + }, + }); + await assert.rejects(putRange(put), { kind: "transient" }); + assert.equal(requestSignal.aborted, true); + }); +} + +test("source PUT preserves caller cancellation instead of retrying it", async (t) => { + const controller = new AbortController(); + const cancelled = new DOMException("Sharing cancelled", "AbortError"); + await assert.rejects( + putRange( + await sourcePut(t, { + signal: controller.signal, + fetchImpl: async (_url, init) => { + assert.equal(init.redirect, "error"); + await new Response(init.body).arrayBuffer(); + controller.abort(cancelled); + throw init.signal.reason; + }, + }), + ), + (error) => error === cancelled, + ); +}); + +test("successful source PUT clears its stall timer", async (t) => { + let requestSignal; + await putRange( + await sourcePut(t, { + stallMs: 200, + fetchImpl: async (_url, init) => { + requestSignal = init.signal; + await new Response(init.body).arrayBuffer(); + return new Response(null, { status: 200 }); + }, + }), + ); + await new Promise((resolve) => setTimeout(resolve, 250)); + assert.equal(requestSignal.aborted, false); +}); + +test("source PUT closes its file when resolving its parent fails", async (t) => { + const put = await sourcePut(t, { fetchImpl: async () => assert.fail("Must not send bytes") }); + const originalOpen = fsPromises.open; + let opened; + t.mock.method(fsPromises, "open", async (...args) => { + opened = await originalOpen(...args); + return opened; + }); + t.mock.method(fsPromises, "realpath", async () => { + throw Object.assign(new Error("Parent directory disappeared"), { code: "ENOENT" }); + }); + syncBuiltinESMExports(); + try { + await assert.rejects(putRange(put), { code: "ENOENT" }); + assert.equal(opened.fd, -1, "source file handle was left open"); + } finally { + await opened?.close(); + t.mock.restoreAll(); + syncBuiltinESMExports(); + } +}); diff --git a/packages/studio-server/src/index.ts b/packages/studio-server/src/index.ts index 2ad1e7afa3..c9de6a82c8 100644 --- a/packages/studio-server/src/index.ts +++ b/packages/studio-server/src/index.ts @@ -83,3 +83,12 @@ export { createStudioMotionRenderBodyScript, type StudioMotionRenderScriptOptions, } from "./helpers/studioMotionRenderScript.js"; +export type { + LocalShareAudience, + LocalShareSpace, + LocalShareState, + LocalShareJob, + LocalShareSnapshot, + LocalShareAction, + LocalShareInteraction, +} from "./localShare.js"; diff --git a/packages/studio-server/src/localShare.ts b/packages/studio-server/src/localShare.ts new file mode 100644 index 0000000000..e4d7b536cd --- /dev/null +++ b/packages/studio-server/src/localShare.ts @@ -0,0 +1,48 @@ +export type LocalShareAudience = "public" | "team" | "invite" | "private"; +export interface LocalShareSpace { + id: string; + name: string; + bound: boolean; + canCreate: boolean; + plan?: "free" | "subscribed" | null; + upgradeUrl?: string | null; + audiences: LocalShareAudience[]; + used: number | null; + limit: number | null; +} +export interface LocalShareState { + upToDate?: boolean; + updated?: boolean; + state: "not_shared" | "link_off" | "ready" | "processing" | "failed" | "unavailable"; + url: string | null; + manageUrl: string; + changed: boolean | null; + hasReadyVersion?: boolean; + failure?: string | null; + audience: LocalShareAudience | null; + spaceId: string | null; + source: "not_checked" | "ready" | "video_only"; +} +export interface LocalShareJob { + id: string; + state: "running" | "done" | "failed"; + step: string; + result: LocalShareState | null; + error: { code: string; message: string } | null; +} +export interface LocalShareSnapshot { + versionSharing: boolean; + share: LocalShareState; + spaces: LocalShareSpace[]; + job: LocalShareJob | null; +} +export type LocalShareAction = { + action: "share" | "update" | "access" | "off" | "on" | "login"; + audience?: LocalShareAudience; + space?: string; + videoOnly?: boolean; + includeSource?: boolean; +}; +export type LocalShareInteraction = + | { event: "share_opened"; link: "none" | "live" | "changed" } + | { event: "share_link_copied"; via: "copy" }; diff --git a/packages/studio/src/App.tsx b/packages/studio/src/App.tsx index e9b0ce971b..5071cfc083 100644 --- a/packages/studio/src/App.tsx +++ b/packages/studio/src/App.tsx @@ -517,6 +517,7 @@ export function StudioApp({ readOnlyPreview = false, readOnlyPreviewReason }: St inspectorButtonActive={inspectorButtonActive} inspectorPanelActive={inspectorPanelActive} onExport={handleExport} + beforeShare={previewPersistence.waitForPendingDomEditSaves} /> {previewPersistence.domEditSaveQueuePaused && !externalFileChanges.blocked && ( void; + beforeShare?: () => Promise; } /** @@ -45,6 +47,7 @@ export const StudioHeader = memo(function StudioHeader({ inspectorButtonActive, inspectorPanelActive, onExport, + beforeShare, }: StudioHeaderProps) { const showThemeToggle = useContext(ShowThemeToggle); const { projectId, renderQueue } = useStudioShellContext(); @@ -153,6 +156,7 @@ export const StudioHeader = memo(function StudioHeader({ {showThemeToggle && } + ; + +const interaction = vi.hoisted(() => vi.fn()); +vi.mock("./localShareTelemetry", () => ({ shareInteraction: interaction })); +vi.mock("../ui", () => ({ + Button: ({ children, variant: _variant, ...props }: ButtonProps) => ( + + ), + Menu: ({ children }: { children: React.ReactNode }) =>
{children}
, + MenuRadioGroup: ({ + children, + value, + onValueChange, + }: { + children: React.ReactNode; + value: string; + onValueChange: (value: string) => void; + }) => ( + + ), + MenuRadioItem: ({ value, disabled }: { value: string; disabled?: boolean }) => ( + + ), + Popover: ({ children }: { children: React.ReactNode }) =>
{children}
, +})); +const { QuickShare, QuickShareContent } = await import("./QuickShare"); +Reflect.set(globalThis, "IS_REACT_ACT_ENVIRONMENT", true); +let root: Root; +let host: HTMLDivElement; +let snapshot: LocalShareSnapshot; +let calls: unknown[]; +let job: LocalShareJob; +const token = "a".repeat(43); +beforeEach(() => { + interaction.mockReset(); + calls = []; + snapshot = { + versionSharing: true, + share: { + source: "not_checked", + state: "not_shared", + url: null, + manageUrl: "https://hyperframes.dev/shares", + changed: false, + audience: null, + spaceId: null, + }, + spaces: [ + { + id: "team1", + name: "Design team", + bound: true, + canCreate: true, + audiences: ["public", "private", "invite"], + used: 5, + limit: 5, + }, + ], + job: null, + }; + job = { id: "job1", state: "running", step: "uploading", result: null, error: null }; + host = document.createElement("div"); + document.body.append(host); + root = createRoot(host); + vi.stubGlobal( + "fetch", + vi.fn(async (url: string, init?: RequestInit) => { + expect(new Headers(init?.headers).get("X-Hyperframes-Share-CSRF")).toBe(token); + if (url.endsWith("/snapshot")) return Response.json(snapshot); + if (url.endsWith("/actions")) { + calls.push(JSON.parse(String(init?.body))); + return Response.json(job, { status: 202 }); + } + return Response.json(job); + }), + ); +}); +afterEach(() => { + act(() => root.unmount()); + host.remove(); + vi.unstubAllGlobals(); + vi.useRealTimers(); +}); +const button = (label: string) => + [...host.querySelectorAll("button")].find((element) => element.textContent === label); +async function mount(beforeShare?: () => Promise) { + await act(async () => root.render()); +} +async function choose(value: string) { + const select = host.querySelector('[aria-label="Who can access"]'); + if (!select) throw new Error("Missing audience"); + await act(async () => { + select.value = value; + select.dispatchEvent(new Event("change", { bubbles: true })); + }); +} +it("requires explicit audience, uses the bound workspace and permits server-authoritative quota retries", async () => { + await mount(); + expect(host.textContent).toContain("5 of 5 free share links used"); + expect(button("Create share link")?.disabled).toBe(true); + expect(calls).toEqual([]); + await choose("public"); + expect(button("Create share link")?.disabled).toBe(false); + await act(async () => button("Create share link")?.click()); + expect(calls).toEqual([ + { action: "share", audience: "public", space: "team1", includeSource: false }, + ]); +}); +it("drains pending editor saves before creating or uploading", async () => { + let resolveSave = () => {}; + const save = vi.fn( + () => + new Promise((resolve) => { + resolveSave = resolve; + }), + ); + await mount(save); + await choose("public"); + await act(async () => button("Create share link")?.click()); + expect(save).toHaveBeenCalledOnce(); + expect(calls).toEqual([]); + await act(async () => resolveSave()); + expect(calls).toHaveLength(1); +}); +it("does not publish when saving fails", async () => { + await mount(async () => { + throw new Error("write failed"); + }); + await choose("public"); + await act(async () => button("Create share link")?.click()); + expect(calls).toEqual([]); + expect(host.querySelector('[role="alert"]')).not.toBeNull(); +}); +it("shows stale copy separately and never uploads merely by opening", async () => { + snapshot.share = { + ...snapshot.share, + state: "ready", + url: "https://hyperframes.dev/r/live", + changed: true, + audience: "private", + spaceId: "team1", + }; + await mount(); + expect(button("Copy current shared link")).toBeDefined(); + expect(calls).toEqual([]); + await act(async () => button("Update shared version")?.click()); + expect(calls).toEqual([{ action: "update", includeSource: false }]); +}); +it("keeps link-off updates separate from explicit re-enabling", async () => { + snapshot.share = { ...snapshot.share, state: "link_off", audience: "private", spaceId: "team1" }; + await mount(); + expect(button("Turn link on")).toBeDefined(); + await act(async () => button("Update shared version")?.click()); + expect(calls).toEqual([{ action: "update", includeSource: false }]); +}); +it("recovers a running job on reopening, and stops browser polling on close", async () => { + vi.useFakeTimers(); + snapshot.job = job; + await mount(); + expect(host.textContent).toContain("Uploading your video"); + expect(calls).toEqual([]); + await act(async () => root.render(null)); + const before = vi.mocked(fetch).mock.calls.length; + await act(async () => vi.advanceTimersByTime(3000)); + expect(vi.mocked(fetch).mock.calls.length).toBe(before); + await mount(); + expect(host.textContent).toContain("Uploading your video"); + expect(calls).toEqual([]); +}); +it("hides creation while feature is off but keeps existing management", async () => { + snapshot.versionSharing = false; + snapshot.share = { ...snapshot.share, state: "link_off", audience: "private", spaceId: "team1" }; + await mount(); + expect(button("Update shared version")).toBeUndefined(); + expect(button("Turn link on")).toBeDefined(); +}); +it("recovers a failed job on reopening instead of silently dropping the error", async () => { + snapshot.job = { + ...job, + state: "failed", + error: { code: "share_failed", message: "The upload failed. Try again." }, + }; + await mount(); + expect(host.querySelector('[role="alert"]')?.textContent).toContain("The upload failed"); + expect(calls).toEqual([]); +}); + +it("offers video-only recovery explicitly after a failed source upload", async () => { + snapshot.share = { + ...snapshot.share, + state: "processing", + audience: "private", + spaceId: "team1", + }; + snapshot.job = { + ...job, + state: "failed", + error: { code: "source_unavailable", message: "Project files could not be attached." }, + }; + await mount(); + expect(calls).toEqual([]); + await act(async () => button("Retry with video only")?.click()); + expect(calls).toEqual([{ action: "update", videoOnly: true, includeSource: false }]); +}); +it("labels files as included only after a ready upload result", async () => { + snapshot.job = { + ...job, + state: "done", + result: { ...snapshot.share, state: "ready", source: "ready" }, + }; + await mount(); + expect(host.textContent).toContain("Last Studio upload: project files included."); +}); +it.each(["unauthenticated", "login_expired"])( + "offers explicit browser login for %s and recovers signed-out polling", + async (code) => { + vi.stubGlobal( + "fetch", + vi.fn(async (url: string, init?: RequestInit) => { + if (url.endsWith("/actions")) { + calls.push(JSON.parse(String(init?.body))); + return Response.json({ ...job, step: "signing_in" }); + } + return Response.json({ code, message: "Sign in to share.", job: null }, { status: 400 }); + }), + ); + await mount(); + expect(calls).toEqual([]); + expect(button("Sign in")).toBeDefined(); + await act(async () => button("Sign in")?.click()); + expect(calls).toEqual([{ action: "login" }]); + expect(host.textContent).toContain("Finish signing in in your browser"); + }, +); + +it("records a copy only after the clipboard succeeds and opening once per panel", async () => { + snapshot.share = { + ...snapshot.share, + state: "ready", + url: "https://hyperframes.dev/r/old", + audience: "private", + spaceId: "team1", + }; + const copy = vi.spyOn(navigator.clipboard, "writeText"); + copy.mockRejectedValueOnce(new Error("denied")).mockResolvedValue(undefined); + await mount(); + expect(interaction).toHaveBeenCalledExactlyOnceWith(token, { + event: "share_opened", + link: "live", + }); + await act(async () => button("Copy link")?.click()); + expect(interaction).toHaveBeenCalledTimes(1); + await act(async () => button("Copy link")?.click()); + expect(interaction).toHaveBeenLastCalledWith(token, { event: "share_link_copied", via: "copy" }); + expect(calls).toEqual([]); + copy.mockRestore(); +}); + +it("clears account-specific links and workspace controls after an identity failure", async () => { + snapshot.share = { + ...snapshot.share, + state: "ready", + url: "https://hyperframes.dev/r/private", + audience: "private", + spaceId: "team1", + }; + await mount(); + expect(button("Copy link")).toBeDefined(); + vi.mocked(fetch).mockResolvedValue( + Response.json({ code: "login_changed", message: "Your login changed" }, { status: 400 }), + ); + await act(async () => button("Update shared version")?.click()); + expect(button("Copy link")).toBeUndefined(); + expect(button("Update shared version")).toBeUndefined(); + expect(host.querySelector('[aria-label="Sharing workspace"]')).toBeNull(); + expect(host.textContent).not.toContain("Design team"); + expect(button("Sign in")).toBeDefined(); +}); + +it("does not claim an older upload is current when its portable content identity is unknown", async () => { + snapshot.share = { + ...snapshot.share, + state: "ready", + changed: null, + url: "https://hyperframes.dev/r/live", + }; + await mount(); + expect(button("Copy current shared link")).toBeDefined(); + expect(host.textContent).toContain("Changes after your last upload aren’t shared automatically"); +}); + +it("continues from a running browser login to fresh controls without refreshing or publishing", async () => { + vi.useFakeTimers(); + let signedIn = false; + const loginJob = { ...job, step: "signing_in" }; + vi.mocked(fetch).mockImplementation(async (url, init) => { + const path = String(url); + if (path.endsWith("/actions")) { + calls.push(JSON.parse(String(init?.body))); + return Response.json(loginJob, { status: 202 }); + } + if (path.includes("/jobs/")) + return Response.json( + signedIn ? { ...loginJob, state: "done", result: snapshot.share } : loginJob, + ); + return signedIn + ? Response.json({ ...snapshot, job: { ...loginJob, state: "done", result: snapshot.share } }) + : Response.json({ code: "login_expired", message: "Sign in again." }, { status: 400 }); + }); + await mount(); + await act(async () => button("Sign in")?.click()); + await act(async () => vi.advanceTimersByTime(1000)); + expect(host.textContent).toContain("Finish signing in"); + signedIn = true; + await act(async () => vi.advanceTimersByTime(1000)); + expect(button("Sign in")).toBeUndefined(); + expect(host.querySelector('[aria-label="Who can access"]')).not.toBeNull(); + expect(button("Create share link")?.disabled).toBe(true); + expect(calls).toEqual([{ action: "login" }]); +}); + +it.each(["snapshot", "poll"])( + "reconnects on return after a %s error without a refresh press", + async (failureAt) => { + vi.useFakeTimers(); + let restored = false; + snapshot.job = failureAt === "poll" ? { ...job, step: "signing_in" } : null; + vi.mocked(fetch).mockImplementation(async (url) => { + if (restored) return Response.json({ ...snapshot, job: null }); + if (failureAt === "snapshot") + return Response.json({ code: "login_expired", message: "Sign in again." }, { status: 400 }); + if (String(url).includes("/jobs/")) throw new Error("Connection lost"); + return Response.json(snapshot); + }); + await mount(); + if (failureAt === "poll") await act(async () => vi.advanceTimersByTime(1000)); + restored = true; + await act(async () => window.dispatchEvent(new Event("focus"))); + expect(host.querySelector('[aria-label="Who can access"]')).not.toBeNull(); + expect(button("Create share link")?.disabled).toBe(true); + expect(calls).toEqual([]); + }, +); + +it("keeps audience choices when a healthy panel regains focus", async () => { + await mount(); + await choose("invite"); + const requests = vi.mocked(fetch).mock.calls.length; + await act(async () => window.dispatchEvent(new Event("focus"))); + await act(async () => document.dispatchEvent(new Event("visibilitychange"))); + expect(host.querySelector('[aria-label="Who can access"]')?.value).toBe( + "invite", + ); + expect(vi.mocked(fetch).mock.calls.length).toBe(requests); + expect(calls).toEqual([]); +}); + +it("does not send an authenticated sharing-admission refusal into another login loop", async () => { + vi.mocked(fetch).mockResolvedValue( + Response.json( + { + code: "sharing_not_admitted", + message: + "You're signed in, but sharing isn't accepting this sign-in. Try again later or contact support.", + }, + { status: 400 }, + ), + ); + await mount(); + expect(host.textContent).toContain("You're signed in"); + expect(button("Sign in")).toBeUndefined(); + expect(button("Create share link")).toBeUndefined(); + expect(calls).toEqual([]); +}); + +it("shows retry only for recoverable errors, never a permanent refresh footer", async () => { + await mount(); + expect(button("Refresh")).toBeUndefined(); + expect(button("Try again")).toBeUndefined(); +}); + +it.each(["login_expired", "sharing_not_admitted", "review_upload_origins_required"])( + "does not offer a misleading retry for %s", + async (code) => { + vi.mocked(fetch).mockResolvedValue( + Response.json({ code, message: "Unavailable" }, { status: 400 }), + ); + await mount(); + expect(button("Try again")).toBeUndefined(); + }, +); + +it.each(["request", "job"])( + "restores the create action and audience after a failed %s", + async (failureAt) => { + await mount(); + await choose("public"); + const failed = { + ...job, + state: "failed" as const, + error: { code: "share_failed", message: "Cannot render" }, + }; + if (failureAt === "request") + vi.mocked(fetch).mockResolvedValueOnce(Response.json(failed.error, { status: 400 })); + else { + job = failed; + snapshot.job = failed; + } + await act(async () => button("Create share link")?.click()); + expect(button("Create share link")?.disabled).toBe(false); + expect(host.querySelector('[aria-label="Who can access"]')?.value).toBe( + "public", + ); + expect(button("Try again")).toBeUndefined(); + expect(host.textContent).toContain("Cannot render"); + }, +); + +it("uses the OAuth-selected workspace among several without a dropdown", async () => { + snapshot.spaces.unshift({ ...snapshot.spaces[0]!, id: "other", name: "Other", bound: false }); + await mount(); + expect(host.querySelector('[aria-label="Sharing workspace"]')).toBeNull(); + await choose("public"); + await act(async () => button("Create share link")?.click()); + expect(calls).toEqual([ + { action: "share", audience: "public", space: "team1", includeSource: false }, + ]); +}); +it("refuses to substitute another workspace when the OAuth selection is missing", async () => { + snapshot.spaces[0]!.bound = false; + await mount(); + expect(button("Create share link")?.disabled).toBe(true); + expect(host.textContent).toContain("workspace selected at sign-in"); + expect(calls).toEqual([]); +}); + +it("omits Only you for new shares but preserves an existing private audience", async () => { + await mount(); + expect(host.querySelector('option[value="private"]')).toBeNull(); +}); +it("displays an existing private share without converting its audience", async () => { + snapshot.share = { ...snapshot.share, state: "ready", audience: "private", spaceId: "team1" }; + await mount(); + expect(host.querySelector('[aria-label="Who can access"]')?.value).toBe( + "private", + ); + expect(host.textContent).toContain("Only you"); + expect(calls).toEqual([]); +}); + +it("resumes a failed first creation without presenting an uploaded version", async () => { + snapshot.share = { + ...snapshot.share, + state: "processing", + audience: "public", + spaceId: "team1", + hasReadyVersion: false, + }; + snapshot.job = { + ...job, + state: "failed", + error: { code: "source_unavailable", message: "Project files could not upload" }, + }; + await mount(); + expect(button("Create share link")?.disabled).toBe(false); + expect(button("Update shared version")).toBeUndefined(); + expect(host.textContent).not.toContain("still being prepared"); + await act(async () => button("Create share link")?.click()); + expect(calls).toEqual([{ action: "update", includeSource: false }]); +}); + +it.each(["free", "subscribed", null] as const)( + "shows the Pro CTA only for authoritative free entitlement: %s", + async (plan) => { + snapshot.spaces[0]!.plan = plan; + snapshot.spaces[0]!.upgradeUrl = "https://hyperframes.dev/pricing"; + await mount(); + const link = [...host.querySelectorAll("a")].find((a) => + a.textContent?.includes("Upgrade to Pro"), + ); + if (plan === "free") expect(link?.href).toBe("https://hyperframes.dev/pricing"); + else expect(link).toBeUndefined(); + }, +); +it("refuses an upgrade destination outside the public pricing flow", async () => { + snapshot.spaces[0]!.plan = "free"; + snapshot.spaces[0]!.upgradeUrl = "https://example.com/checkout"; + await mount(); + expect( + [...host.querySelectorAll("a")].some((link) => link.textContent?.includes("Upgrade to Pro")), + ).toBe(false); +}); + +it.each([false, true])( + "shows a persisted failed export after reopen (previous version: %s)", + async (previous) => { + snapshot.share = { + ...snapshot.share, + state: "failed", + failure: "This video can't be shared.", + hasReadyVersion: previous, + changed: true, + audience: "public", + spaceId: "team1", + url: previous ? "https://hyperframes.dev/r/previous" : null, + }; + await mount(); + expect(host.querySelector('[role="alert"]')?.textContent).toBe("This video can't be shared."); + expect(host.textContent).not.toContain("still being prepared"); + expect(calls).toEqual([]); + const action = button(previous ? "Update shared version" : "Create share link"); + expect(action?.disabled).toBe(false); + if (previous) expect(button("Copy current shared link")).toBeDefined(); + await act(async () => action?.click()); + expect(calls).toEqual([{ action: "update", includeSource: false }]); + }, +); + +it("does not probe unsupported Studio hosts for the CLI sharing bridge", async () => { + await act(async () => root.render()); + expect(fetch).not.toHaveBeenCalled(); +}); + +it("bootstraps sharing when the CLI advertises its bridge", async () => { + const marker = document.createElement("meta"); + marker.name = "hyperframes-local-share"; + marker.content = "1"; + document.head.append(marker); + vi.mocked(fetch).mockResolvedValue(Response.json({ csrf: token })); + try { + await act(async () => root.render()); + expect(fetch).toHaveBeenCalledWith( + "/api/share/bootstrap", + expect.objectContaining({ method: "GET" }), + ); + } finally { + marker.remove(); + } +}); + +it("acknowledges an unchanged update", async () => { + snapshot.share = { + ...snapshot.share, + state: "ready", + url: "https://hyperframes.dev/r/test", + audience: "public", + spaceId: "team1", + }; + job = { ...job, state: "done", result: { ...snapshot.share, upToDate: true } }; + await act(async () => root.render()); + await act(async () => button("Update shared version")?.click()); + expect(host.textContent).toContain("Already up to date."); +}); +it("resets the copied acknowledgement after two seconds", async () => { + vi.useFakeTimers(); + Object.defineProperty(navigator, "clipboard", { + configurable: true, + value: { writeText: vi.fn().mockResolvedValue(undefined) }, + }); + snapshot.share = { + ...snapshot.share, + state: "ready", + url: "https://hyperframes.dev/r/test", + audience: "public", + spaceId: "team1", + }; + await act(async () => root.render()); + await act(async () => button("Copy link")?.click()); + expect(button("Copied")).toBeDefined(); + await act(async () => vi.advanceTimersByTime(2000)); + expect(button("Copied")).toBeUndefined(); + expect(button("Copy link")).toBeDefined(); + vi.useRealTimers(); +}); + +it("offers Only you for an existing public share", async () => { + snapshot.share = { ...snapshot.share, state: "ready", audience: "public", spaceId: "team1" }; + await mount(); + const option = host.querySelector('option[value="private"]'); + expect(option?.disabled).toBe(false); +}); +it("confirms a newly published version", async () => { + snapshot.share = { + ...snapshot.share, + state: "ready", + url: "https://hyperframes.dev/r/test", + audience: "public", + spaceId: "team1", + }; + job = { ...job, state: "done", result: { ...snapshot.share, updated: true } }; + await mount(); + await act(async () => button("Update shared version")?.click()); + expect(host.textContent).toContain("Shared version updated."); +}); + +it("discloses source scope and uploads files only after checking the option", async () => { + await mount(); + expect(host.textContent).toContain("including unused and Git-ignored files"); + const choice = host.querySelector('input[type="checkbox"]'); + expect(choice?.checked).toBe(false); + await act(async () => choice?.click()); + await choose("public"); + await act(async () => button("Create share link")?.click()); + expect(calls).toEqual([ + { action: "share", audience: "public", space: "team1", includeSource: true }, + ]); +}); diff --git a/packages/studio/src/components/share/QuickShare.tsx b/packages/studio/src/components/share/QuickShare.tsx new file mode 100644 index 0000000000..6a48190fa7 --- /dev/null +++ b/packages/studio/src/components/share/QuickShare.tsx @@ -0,0 +1,104 @@ +import { useState } from "react"; +import { useMountEffect } from "../../hooks/useMountEffect"; +import { Button, Popover } from "../ui"; +import { shareBootstrap, safeShareUrl } from "./localShareClient"; +import { useQuickShare } from "./useQuickShare"; +import { + ShareSettings, + ShareNotices, + ShareActions, + ShareSourceStatus, + ShareLogin, + SharePlan, +} from "./QuickShareControls"; +export function QuickShare({ beforeShare }: { beforeShare?: () => Promise }) { + const [token, setToken] = useState(null); + const [open, setOpen] = useState(false); + useMountEffect(() => { + if (!document.querySelector('meta[name="hyperframes-local-share"][content="1"]')) return; + const controller = new AbortController(); + void shareBootstrap(controller.signal) + .then((value) => { + if (!controller.signal.aborted) setToken(value); + }) + .catch(() => {}); + return () => controller.abort(); + }); + if (!token) return null; + return ( + Share} + className="w-96 max-w-[calc(100vw-2rem)] rounded-2xl p-4" + > + {open ? : null} + + ); +} + +export function QuickShareContent({ + token, + beforeShare, +}: { + token: string; + beforeShare?: () => Promise; +}) { + const [includeSource, setIncludeSource] = useState(false); + const model = { ...useQuickShare(token, beforeShare), includeSource, setIncludeSource }; + const { snapshot, progress, error } = model; + const url = safeShareUrl(snapshot?.share.url ?? ""); + const manageUrl = safeShareUrl(snapshot?.share.manageUrl ?? ""); + return ( +
+
+

Share project

+

Share the latest saved project.

+
+ {snapshot ? ( + <> + + + + + + + ) : null} + {!snapshot && !error ?

Loading sharing…

: null} + {progress ? ( +

{progress} You can close this panel; keep Studio running.

+ ) : null} + {model.notice ?

{model.notice}

: null} + + {error ? ( +

+ {error} +

+ ) : null} +
+ {manageUrl ? ( + + Manage sharing + + ) : null} + {url ? ( + + Open shared page + + ) : null} +
+
+ ); +} diff --git a/packages/studio/src/components/share/QuickShareControls.tsx b/packages/studio/src/components/share/QuickShareControls.tsx new file mode 100644 index 0000000000..97fe5aad5f --- /dev/null +++ b/packages/studio/src/components/share/QuickShareControls.tsx @@ -0,0 +1,265 @@ +import type { LocalShareSnapshot } from "@hyperframes/studio-server"; +import { Button } from "../ui"; +import { ShareAudience } from "./ShareAudience"; +import { Link, ArrowUpRight } from "@phosphor-icons/react"; +import type { QuickShareModel } from "./useQuickShare"; + +type Props = { model: QuickShareModel; snapshot: LocalShareSnapshot }; +export function ShareSettings({ model, snapshot }: Props) { + return ; +} +export function ShareNotices({ model, snapshot }: Props) { + const { share } = snapshot; + const messages = [ + model.audience === "invite" ? "Add people from Manage sharing after creating the link." : null, + share.changed + ? "Local changes aren’t shared yet. Update the shared version when you’re ready." + : share.changed === null + ? "Changes after your last upload aren’t shared automatically. Update to share the current project." + : null, + share.state === "link_off" ? "The link is off. Updating the video keeps it off." : null, + share.state === "processing" && !model.busy && snapshot.job?.state !== "failed" + ? "The shared video is still being prepared. Reopen sharing to check its status." + : null, + share.state === "unavailable" ? "Sharing is paused. Open Manage sharing for details." : null, + !snapshot.versionSharing && share.state === "not_shared" + ? "Sharing isn’t available for this account yet." + : null, + ]; + return ( + <> + {share.state === "failed" && share.failure ? ( +

+ {share.failure} +

+ ) : null} + {messages.filter(Boolean).map((message) => ( +

+ {message} +

+ ))} + + ); +} +export function ShareActions({ model, snapshot, url }: Props & { url: string | null }) { + if (snapshot.share.state === "not_shared") + return ; + return ( + <> + {url ? : null} + {snapshot.versionSharing && snapshot.share.state !== "unavailable" ? ( + + ) : null} + + + ); +} +function CreateShare({ model, snapshot }: Props) { + const space = snapshot.spaces.find((item) => item.id === model.spaceId); + const canCreate = snapshot.versionSharing && space?.canCreate && model.audience !== ""; + return ( + <> + {!space || !space.canCreate ? ( +

+ Sharing isn’t available in the workspace selected at sign-in. Sign in with an accessible + workspace to continue. +

+ ) : null} + + + ); +} +function CopyShare({ model, snapshot, url }: Props & { url: string }) { + const label = model.copied + ? "Copied" + : snapshot.share.changed !== false + ? "Copy current shared link" + : "Copy link"; + return ( +
+ + {url.replace(/^https:\/\//, "")} + + +
+ ); +} +function ManageShare({ model, snapshot, url }: Props & { url: string | null }) { + return ( +
+ {model.audience && model.audience !== snapshot.share.audience ? ( + + ) : null} + {snapshot.share.state === "link_off" ? ( + + ) : null} + {url ? ( + + ) : null} +
+ ); +} + +export function ShareSourceStatus({ model, snapshot }: Props) { + const last = snapshot.job?.result; + const recover = snapshot.job?.error?.code === "source_unavailable"; + let message = "Video only unless you choose to include project files."; + if (last?.source === "video_only") + message = "Last Studio upload: video only. Project files weren’t included."; + if (last?.source === "ready") + message = + last.state === "ready" + ? "Last Studio upload: project files included." + : "Project files are ready; sharing is still processing."; + return ( + <> + +

{message}

+ {recover ? ( + + ) : null} + + ); +} + +export function ShareLogin({ model }: { model: QuickShareModel }) { + if ( + !model.errorCode || + ![ + "not_configured", + "unauthenticated", + "login_expired", + "login_changed", + "refresh_failed", + "device_auth_failed", + ].includes(model.errorCode) + ) + return null; + return ( + <> + +

+ Or run hyperframes auth login in your terminal, then return to Studio. Sharing + reconnects automatically. +

+ + ); +} + +export function SharePlan({ model, snapshot }: Props) { + const space = snapshot.spaces.find((item) => item.id === model.spaceId); + const upgrade = space?.upgradeUrl; + const allowed = + upgrade && + ["https://hyperframes.dev/pricing", "https://dev.hyperframes.dev/pricing"].includes(upgrade); + return ( +
+ {space && space.limit !== null && space.used !== null ? ( + + {space.used} of {space.limit} free share links used + + ) : null} + {space?.plan === "free" && allowed ? ( + + Upgrade to Pro + + ) : null} +
+ ); +} diff --git a/packages/studio/src/components/share/ShareAudience.tsx b/packages/studio/src/components/share/ShareAudience.tsx new file mode 100644 index 0000000000..65dba8a101 --- /dev/null +++ b/packages/studio/src/components/share/ShareAudience.tsx @@ -0,0 +1,120 @@ +import { CaretDown, Globe, Lock, Users, UserPlus } from "@phosphor-icons/react"; +import type { LocalShareAudience, LocalShareSnapshot } from "@hyperframes/studio-server"; +import { Menu, MenuRadioGroup, MenuRadioItem } from "../ui"; +import { isAudience } from "./localShareClient"; +import type { QuickShareModel } from "./useQuickShare"; + +const AUDIENCES = { + public: { label: "Anyone with the link", detail: "Anyone you send the link to", icon: Globe }, + team: { + label: "Anyone in this workspace", + detail: "People in your signed-in workspace", + icon: Users, + }, + invite: { + label: "Only invited people", + detail: "People you add in Manage sharing", + icon: UserPlus, + }, + private: { label: "Only you", detail: "Only you can access this share", icon: Lock }, +}; + +export function ShareAudience({ + model, + snapshot, +}: { + model: QuickShareModel; + snapshot: LocalShareSnapshot; +}) { + const selected = model.audience ? AUDIENCES[model.audience] : null; + const Icon = selected?.icon ?? Lock; + const space = snapshot.spaces.find((item) => item.id === model.spaceId); + const choices: LocalShareAudience[] = ["public", "team", "invite"]; + if (snapshot.share.state !== "not_shared") choices.push("private"); + return ( + + + + + {selected?.label ?? "Choose who can access"} + + + ); +} + +function requiresPro( + space: LocalShareSnapshot["spaces"][number] | undefined, + value: LocalShareAudience, + current: LocalShareAudience | null, +) { + return ( + space?.plan === "free" && + !space.audiences.includes(value) && + value !== current && + (value === "team" || value === "invite") + ); +} diff --git a/packages/studio/src/components/share/localShareClient.ts b/packages/studio/src/components/share/localShareClient.ts new file mode 100644 index 0000000000..c2002fdc0e --- /dev/null +++ b/packages/studio/src/components/share/localShareClient.ts @@ -0,0 +1,171 @@ +import type { + LocalShareAction, + LocalShareAudience, + LocalShareJob, + LocalShareSnapshot, + LocalShareState, + LocalShareSpace, +} from "@hyperframes/studio-server"; +import { studioApiFetch } from "../../utils/studioApiFetch"; + +const audiences: readonly LocalShareAudience[] = ["public", "team", "invite", "private"]; +const record = (value: unknown): value is Record => + typeof value === "object" && value !== null && !Array.isArray(value); +const text = (value: unknown): value is string => typeof value === "string"; +const nullableText = (value: unknown): value is string | null => value === null || text(value); +const nullableBoolean = (value: unknown): value is boolean | null => + value === null || typeof value === "boolean"; +const nullableNumber = (value: unknown): value is number | null => + value === null || (typeof value === "number" && Number.isFinite(value)); +export const isAudience = (value: unknown): value is LocalShareAudience => + audiences.some((mode) => mode === value); +function isState(value: unknown): value is LocalShareState { + return ( + record(value) && + ["not_shared", "link_off", "ready", "processing", "failed", "unavailable"].includes( + String(value.state), + ) && + optionalFailure(value.failure) && + nullableText(value.url) && + text(value.manageUrl) && + nullableBoolean(value.changed) && + nullableAudience(value.audience) && + nullableText(value.spaceId) && + ["not_checked", "ready", "video_only"].includes(String(value.source)) + ); +} +function isSpace(value: unknown): value is LocalShareSpace { + return ( + record(value) && + text(value.id) && + text(value.name) && + typeof value.bound === "boolean" && + typeof value.canCreate === "boolean" && + Array.isArray(value.audiences) && + value.audiences.every(isAudience) && + nullableNumber(value.used) && + nullableNumber(value.limit) + ); +} +function isError(value: unknown): boolean { + return value === null || (record(value) && text(value.code) && text(value.message)); +} + +function isJob(value: unknown): value is LocalShareJob { + return ( + record(value) && + text(value.id) && + ["running", "done", "failed"].includes(String(value.state)) && + text(value.step) && + (value.result === null || isState(value.result)) && + isError(value.error) + ); +} +function isSnapshot(value: unknown): value is LocalShareSnapshot { + return ( + record(value) && + typeof value.versionSharing === "boolean" && + isState(value.share) && + Array.isArray(value.spaces) && + value.spaces.every(isSpace) && + (value.job === null || isJob(value.job)) + ); +} +export class LocalShareError extends Error { + constructor( + public readonly code: string, + message: string, + public readonly job: LocalShareJob | null = null, + ) { + super(message); + } +} +async function json( + path: string, + token: string | null, + signal: AbortSignal, + action?: LocalShareAction, +): Promise { + const response = await studioApiFetch(`/api/share/${path}`, { + method: action ? "POST" : "GET", + signal: AbortSignal.any([signal, AbortSignal.timeout(30_000)]), + headers: { + ...(token ? { "X-Hyperframes-Share-CSRF": token } : {}), + ...(action ? { "Content-Type": "application/json" } : {}), + }, + ...(action ? { body: JSON.stringify(action) } : {}), + }); + const body: unknown = await response.json().catch(() => null); + if (!response.ok) throw responseError(body); + return body; +} +function responseError(body: unknown): LocalShareError { + const code = record(body) && text(body.code) ? body.code : "unavailable"; + const message = + record(body) && text(body.message) + ? body.message + : "Sharing is unavailable. Try again from a local Studio preview."; + const job = record(body) && isJob(body.job) ? body.job : null; + return new LocalShareError(code, message, job); +} + +export async function shareBootstrap(signal: AbortSignal): Promise { + const value = await json("bootstrap", null, signal); + if (!record(value) || !text(value.csrf) || !/^[A-Za-z0-9_-]{43}$/.test(value.csrf)) + throw new LocalShareError("unavailable", "Sharing is not available in this Studio host."); + return value.csrf; +} +export async function shareSnapshot( + token: string, + signal: AbortSignal, +): Promise { + const value = await json("snapshot", token, signal); + if (!isSnapshot(value)) + throw new LocalShareError( + "unavailable", + "Sharing returned an unreadable response. Refresh Studio.", + ); + return value; +} +export async function shareAction( + token: string, + action: LocalShareAction, + signal: AbortSignal, +): Promise { + const value = await json("actions", token, signal, action); + if (!isJob(value)) + throw new LocalShareError( + "unavailable", + "Could not start sharing. Refresh to check its status.", + ); + return value; +} +export async function shareJob( + token: string, + id: string, + signal: AbortSignal, +): Promise { + const value = await json(`jobs/${encodeURIComponent(id)}`, token, signal); + if (!isJob(value)) + throw new LocalShareError( + "unavailable", + "Could not read sharing progress. Refresh to check its status.", + ); + return value; +} +export function safeShareUrl(value: string): string | null { + try { + const url = new URL(value); + return url.protocol === "https:" && !url.username && !url.password ? url.href : null; + } catch { + return null; + } +} + +function optionalFailure(value: unknown): boolean { + return value === undefined || nullableText(value); +} + +function nullableAudience(value: unknown): boolean { + return value === null || isAudience(value); +} diff --git a/packages/studio/src/components/share/localShareTelemetry.test.ts b/packages/studio/src/components/share/localShareTelemetry.test.ts new file mode 100644 index 0000000000..b98659de7a --- /dev/null +++ b/packages/studio/src/components/share/localShareTelemetry.test.ts @@ -0,0 +1,22 @@ +import { afterEach, expect, it, vi } from "vitest"; +const policy = vi.hoisted(() => vi.fn()); +vi.mock("../../telemetry/policy", () => ({ browserTelemetryAllowed: policy })); +import { shareInteraction } from "./localShareTelemetry"; +afterEach(() => vi.unstubAllGlobals()); +it("obeys browser opt-out before calling the guarded local bridge", async () => { + const fetch = vi.fn(async () => new Response(null, { status: 204 })); + vi.stubGlobal("fetch", fetch); + policy.mockReturnValue(false); + shareInteraction("token", { event: "share_opened", link: "none" }); + expect(fetch).not.toHaveBeenCalled(); + policy.mockReturnValue(true); + shareInteraction("token", { event: "share_link_copied", via: "copy" }); + expect(fetch).toHaveBeenCalledWith( + "/api/share/events", + expect.objectContaining({ + method: "POST", + headers: { "Content-Type": "application/json", "X-Hyperframes-Share-CSRF": "token" }, + body: JSON.stringify({ event: "share_link_copied", via: "copy" }), + }), + ); +}); diff --git a/packages/studio/src/components/share/localShareTelemetry.ts b/packages/studio/src/components/share/localShareTelemetry.ts new file mode 100644 index 0000000000..965b2ca8bb --- /dev/null +++ b/packages/studio/src/components/share/localShareTelemetry.ts @@ -0,0 +1,13 @@ +import type { LocalShareInteraction } from "@hyperframes/studio-server"; +import { browserTelemetryAllowed } from "../../telemetry/policy"; +import { studioApiFetch } from "../../utils/studioApiFetch"; + +export function shareInteraction(token: string, event: LocalShareInteraction): void { + if (!browserTelemetryAllowed()) return; + void studioApiFetch("/api/share/events", { + method: "POST", + signal: AbortSignal.timeout(5000), + headers: { "Content-Type": "application/json", "X-Hyperframes-Share-CSRF": token }, + body: JSON.stringify(event), + }).catch(() => {}); +} diff --git a/packages/studio/src/components/share/useQuickShare.ts b/packages/studio/src/components/share/useQuickShare.ts new file mode 100644 index 0000000000..733e03600a --- /dev/null +++ b/packages/studio/src/components/share/useQuickShare.ts @@ -0,0 +1,215 @@ +import { useRef, useState } from "react"; +import type { + LocalShareAction, + LocalShareAudience, + LocalShareJob, + LocalShareSnapshot, +} from "@hyperframes/studio-server"; +import { useMountEffect } from "../../hooks/useMountEffect"; +import { LocalShareError, shareAction, shareJob, shareSnapshot } from "./localShareClient"; +import { shareInteraction } from "./localShareTelemetry"; +const STEP_LABELS: Record = { + preparing: "Preparing your video…", + signing_in: "Finish signing in in your browser…", + uploading: "Uploading your video…", + processing: "Processing your video…", + checking: "Checking your video…", +}; +const failure = (error: unknown) => + error instanceof LocalShareError + ? error.message + : "Sharing couldn’t finish. Try again to check its status."; + +export function useQuickShare(token: string, beforeShare?: () => Promise) { + const [snapshot, setSnapshot] = useState(null); + const [audience, setAudience] = useState(""); + const [spaceId, setSpaceId] = useState(""); + const [busy, setBusyState] = useState(false); + const working = useRef(false); + const reconnectOnReturn = useRef(false); + const [error, setError] = useState(null); + const [errorCode, setErrorCode] = useState(null); + const { copied, setCopied, acknowledgeCopy } = useCopyAcknowledgement(); + const [notice, setNotice] = useState(""); + const opened = useRef(false); + const lifetime = useRef(null); + const timer = useRef | null>(null); + const [progress, setProgress] = useState(""); + + function setWorking(value: boolean) { + working.current = value; + setBusyState(value); + } + + async function poll(job: LocalShareJob, signal: AbortSignal) { + if (signal.aborted) return; + if (job.state === "running") { + setWorking(true); + setProgress(STEP_LABELS[job.step] ?? "Preparing share…"); + timer.current = setTimeout(() => { + void shareJob(token, job.id, signal) + .then((next) => poll(next, signal)) + .catch((cause) => { + reportFailure(cause, signal); + }); + }, 1000); + return; + } + setWorking(false); + setProgress(""); + const result = job.result; + if (result) setSnapshot((prior) => (prior ? { ...prior, share: result, job } : prior)); + await refresh(signal, job.state === "failed"); + if (!signal.aborted) setNotice(completionNotice(job)); + } + async function refresh(signal: AbortSignal, preserveSelection = false) { + setError(null); + setErrorCode(null); + setWorking(true); + if (timer.current) clearTimeout(timer.current); + try { + const next = await shareSnapshot(token, signal); + if (signal.aborted) return; + recordOpen(next); + reconnectOnReturn.current = false; + setSnapshot(next); + if (!preserveSelection) resetSelection(next); + if (next.job?.error) { + setError(next.job.error.message); + setErrorCode(next.job.error.code); + } + if (next.job?.state === "running") await poll(next.job, signal); + else setWorking(false); + return true; + } catch (cause) { + reportFailure(cause, signal); + return false; + } + } + useMountEffect(() => { + const controller = new AbortController(); + lifetime.current = controller; + const resume = () => { + if (document.visibilityState !== "hidden" && reconnectOnReturn.current && !working.current) + void refresh(controller.signal); + }; + window.addEventListener("focus", resume); + document.addEventListener("visibilitychange", resume); + void refresh(controller.signal); + return () => { + window.removeEventListener("focus", resume); + document.removeEventListener("visibilitychange", resume); + controller.abort(); + if (timer.current) clearTimeout(timer.current); + }; + }); + async function run(action: LocalShareAction) { + const signal = lifetime.current?.signal; + if (!signal || signal.aborted || working.current) return; + setWorking(true); + setError(null); + setErrorCode(null); + setCopied(false); + setNotice(""); + setProgress("Preparing share…"); + try { + if (["share", "update"].includes(action.action)) await beforeShare?.(); + if (!signal.aborted) await poll(await shareAction(token, action, signal), signal); + } catch (cause) { + await recoverActionFailure(cause, signal); + } + } + async function recoverActionFailure(cause: unknown, signal: AbortSignal) { + if ( + cause instanceof LocalShareError && + [ + "login_changed", + "login_expired", + "unauthenticated", + "refresh_failed", + "not_configured", + ].includes(cause.code) + ) { + reportFailure(cause, signal); + return; + } + setProgress(""); + const recovered = await refresh(signal, true); + if (recovered && !signal.aborted) { + setError(failure(cause)); + setErrorCode(cause instanceof LocalShareError ? cause.code : null); + } + } + function recordOpen(value: LocalShareSnapshot | null) { + if (opened.current) return; + opened.current = true; + const share = value?.share; + const link = share?.url ? (share.changed ? "changed" : "live") : "none"; + shareInteraction(token, { event: "share_opened", link }); + } + function resetSelection(next: LocalShareSnapshot) { + setAudience(next.share.audience ?? ""); + setSpaceId(next.share.spaceId ?? next.spaces.find((space) => space.bound)?.id ?? ""); + } + function reportFailure(cause: unknown, signal: AbortSignal) { + if (signal.aborted) return; + recordOpen(null); + reconnectOnReturn.current = true; + setSnapshot(null); + setCopied(false); + setError(failure(cause)); + setErrorCode(cause instanceof LocalShareError ? cause.code : null); + if (cause instanceof LocalShareError && cause.job?.state === "running") { + void poll(cause.job, signal); + return; + } + setWorking(false); + setProgress(""); + } + async function copy(url: string) { + try { + await navigator.clipboard.writeText(url); + if (lifetime.current?.signal.aborted) return; + acknowledgeCopy(); + shareInteraction(token, { event: "share_link_copied", via: "copy" }); + } catch { + setError("Couldn’t copy. Open the shared page and copy its address."); + } + } + return { + snapshot, + audience, + setAudience, + spaceId, + busy, + error, + errorCode, + copied, + notice, + progress, + run, + copy, + }; +} +export type QuickShareModel = ReturnType & { + includeSource: boolean; + setIncludeSource: (value: boolean) => void; +}; + +function completionNotice(job: LocalShareJob) { + if (job.state !== "done") return ""; + if (job.result?.upToDate) return "Already up to date."; + return job.result?.updated ? "Shared version updated." : ""; +} + +function useCopyAcknowledgement() { + const [copied, setCopied] = useState(false); + const timer = useRef | undefined>(undefined); + useMountEffect(() => () => clearTimeout(timer.current)); + function acknowledgeCopy() { + clearTimeout(timer.current); + setCopied(true); + timer.current = setTimeout(() => setCopied(false), 2000); + } + return { copied, setCopied, acknowledgeCopy }; +} diff --git a/scripts/check-cli-share-capture.mjs b/scripts/check-cli-share-capture.mjs new file mode 100644 index 0000000000..4406f01a7f --- /dev/null +++ b/scripts/check-cli-share-capture.mjs @@ -0,0 +1,28 @@ +import assert from "node:assert/strict"; +import { mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { join, resolve } from "node:path"; +import { pathToFileURL } from "node:url"; + +// Exercise the bundled CLI, whose import.meta.url differs from the share source tree. +const dist = resolve(process.argv[2]); +const chunk = readdirSync(dist).find((name) => { + if (!name.endsWith(".js")) return false; + const source = readFileSync(join(dist, name), "utf8"); + return /export\s*\{[^}]*\bshareContentFingerprint\b/s.test(source); +}); +assert.ok(chunk, "CLI must expose its bundled source fingerprint to the share command"); +const { shareContentFingerprint } = await import(pathToFileURL(join(dist, chunk)).href); +const project = mkdtempSync(join(tmpdir(), "hyperframes-packed-share-")); +try { + writeFileSync(join(project, "index.html"), "Video"); + const asset = join(project, "café.txt"); + writeFileSync(asset, "first"); + const before = await shareContentFingerprint(project); + assert.match(before, /^[a-f0-9]{64}$/); + writeFileSync(asset, "second"); + assert.notEqual(await shareContentFingerprint(project), before); + console.log("Bundled CLI captures portable source with its policy and Unicode registries."); +} finally { + rmSync(project, { recursive: true, force: true }); +} diff --git a/scripts/package-size-budgets.json b/scripts/package-size-budgets.json index f45ed173c9..5138625f7a 100644 --- a/scripts/package-size-budgets.json +++ b/scripts/package-size-budgets.json @@ -4,7 +4,7 @@ "unpacked": 290508 }, "@hyperframes/cli": { - "packed": 8062664, + "packed": 8577627, "unpacked": 25159107 }, "@hyperframes/core": { @@ -48,12 +48,12 @@ "unpacked": 825937 }, "@hyperframes/share": { - "packed": 64831, - "unpacked": 257736 + "packed": 148738, + "unpacked": 575775 }, "@hyperframes/studio": { - "packed": 5998328, - "unpacked": 24360208 + "packed": 6589635, + "unpacked": 26703858 }, "@hyperframes/studio-server": { "packed": 164800, diff --git a/scripts/studio-runtime-smoke.mjs b/scripts/studio-runtime-smoke.mjs index 4d2843042a..ff9af88220 100644 --- a/scripts/studio-runtime-smoke.mjs +++ b/scripts/studio-runtime-smoke.mjs @@ -23,6 +23,7 @@ function text(body, contentType = "text/plain") { const PROJECT_PATH = `/api/projects/${PROJECT_ID}`; const GET_RESPONSES = new Map([ + ["/api/share/bootstrap", json({ csrf: "s".repeat(43) })], [ "/api/projects", json({ projects: [{ id: PROJECT_ID, dir: "/tmp/smoke-test", title: "Smoke test" }] }), diff --git a/scripts/studio-runtime-smoke.test.mjs b/scripts/studio-runtime-smoke.test.mjs index 3b687069ba..23d37ad3f6 100644 --- a/scripts/studio-runtime-smoke.test.mjs +++ b/scripts/studio-runtime-smoke.test.mjs @@ -13,6 +13,9 @@ function bodyOf(method, path) { } describe("Studio runtime smoke fixtures", () => { + it("bootstraps the sharing entry point without credentials", () => { + assert.deepEqual(bodyOf("GET", "/api/share/bootstrap"), { csrf: "s".repeat(43) }); + }); it("matches the collection and project-detail API schemas", () => { assert.deepEqual(bodyOf("GET", "/api/projects"), { projects: [{ id: "smoke-test", dir: "/tmp/smoke-test", title: "Smoke test" }], diff --git a/scripts/verify-packed-manifests.mjs b/scripts/verify-packed-manifests.mjs index b9827bbc2e..8d964bc233 100644 --- a/scripts/verify-packed-manifests.mjs +++ b/scripts/verify-packed-manifests.mjs @@ -558,6 +558,14 @@ function verifyPackedConsumer(packDir, packedWorkspaces) { if (!cliOutput.toLowerCase().includes("hyperframes")) { throw new Error("Packed CLI help did not identify HyperFrames"); } + execFileSync( + "node", + [ + join(ROOT, "scripts", "check-cli-share-capture.mjs"), + join(fixtureDir, "node_modules", "@hyperframes", "cli", "dist"), + ], + { cwd: fixtureDir, stdio: "inherit", timeout: 30_000 }, + ); console.log(smokeOutput.trim()); console.log( "Verified clean packed consumer install, Node execution, NodeNext declaration check, Vite resolution, and CLI startup.", diff --git a/skills-manifest.json b/skills-manifest.json index c6e025b9f6..d677bcc706 100644 --- a/skills-manifest.json +++ b/skills-manifest.json @@ -10,7 +10,7 @@ "files": 78 }, "hyperframes-cli": { - "hash": "ad1f72d3e42f3005", + "hash": "2492752b9f8616f2", "files": 13 }, "hyperframes-registry": { diff --git a/skills/hyperframes-cli/SKILL.md b/skills/hyperframes-cli/SKILL.md index d65e6fbc66..d7ce8f536e 100644 --- a/skills/hyperframes-cli/SKILL.md +++ b/skills/hyperframes-cli/SKILL.md @@ -1,6 +1,6 @@ --- name: hyperframes-cli -description: The HyperFrames CLI by job - scaffold, check, look at frames, edit the timeline, preview, render locally or in the cloud, publish, project history - plus reading its JSON and recovering from build or render failures. +description: HyperFrames CLI - scaffold, check frames, edit timelines, preview, render, share and project history; read JSON and recover from failures. --- **Plugin installs:** Inside a HyperFrames plugin, follow [plugin execution rules](../hyperframes/references/plugin-installation.md). @@ -24,7 +24,7 @@ A `--json` result may carry `_meta.updateNotice`: a newer HyperFrames release is | Edit the timeline | `timeline` with `move`, `trim`, `split`, `set`, `duplicate`, `delete`, `apply`, `undo`, `ids` | | Reuse | `catalog`, `add` (`/hyperframes-registry`) | | Media and sound | `media-treatment`, `grade-compare`, `remove-background`, `tts`, `transcribe`, `beats`, `normalize-audio` (`/media-use`) | -| Show and ship | `preview`, `present` (`/slideshow`), `render`, `publish`, `cloud`, `lambda`, `cloudrun` | +| Show and ship | `preview`, `present` (`/slideshow`), `render`, `share`, `publish` (legacy), `cloud`, `lambda`, `cloudrun` | | Desktop app | `open`, `catch-up` | | Upkeep | `doctor`, `browser`, `upgrade`, `usage`, `clean`, `feedback` | @@ -94,7 +94,7 @@ Read the row before running its command. | `lint`, `check`, motion sidecars, `snapshot` | `references/lint-validate-inspect.md` | | `compare`, `grade-compare`, `render --batch` | `references/compare-and-batch.md` | | `beats` | `references/beats.md` | -| `preview`, `play`, `render`, `publish`, Studio context | `references/preview-render.md` | +| `preview`, `play`, `render`, `share`, `publish` (legacy), Studio context | `references/preview-render.md` | | `doctor`, `browser` | `references/doctor-browser.md` | | `auth`, `cloud`, template variables | `references/cloud.md` | | `lambda`, `cloudrun` | `references/lambda.md`, `references/cloudrun.md` | diff --git a/skills/hyperframes-cli/references/preview-render.md b/skills/hyperframes-cli/references/preview-render.md index dae84e54b5..f0cec96af6 100644 --- a/skills/hyperframes-cli/references/preview-render.md +++ b/skills/hyperframes-cli/references/preview-render.md @@ -203,3 +203,23 @@ Uploads the project's source (HTML + assets) and returns a stable hosted URL tha Use cloud rendering when the user wants hosted rendering without local Chrome, FFmpeg, or AWS, and for the final render on a paid HyperFrames plan (`cloud.md`). Use Lambda only when AWS ownership is a requirement. Use Cloud Run only when GCP ownership is a requirement. Read the matching reference before running any cloud path. Skill attribution is automatic — the examples above need no `--skill`. A project scaffolded with `hyperframes init --skill=` records its owning skill in `hyperframes.json`, and every later render inherits it on usage telemetry: re-renders, `npm run render`, and `--batch` alike. Pass `--skill=` explicitly only to stamp a project that was not scaffolded with one (its first render then persists it). + +## Share a video for review + +Use `hyperframes share --public` only when the user explicitly wants anyone with +the link to access the review. First sign in with `hyperframes auth login`. +Other first-share choices are `--team`, `--invite-only` and `--private`, subject +to workspace entitlement. `--yes` is not audience consent. + +Read `hyperframes share --status --json`: `ready: true` is required before +calling the video ready to watch. Re-running `share` retrieves the existing +link; `share --update` explicitly renders/uploads changed content. Five retained +free projects are counted per workspace across CLI and Desktop; versions do +not consume slots and turning a link off does not release a slot. + +`publish` uploads source to legacy `/p/` pages. It is not a review share alias. +During the announced 60-day window its old behavior stays available with a +notice. The start date is release-owned and currently unscheduled. After it, new +projects are guided to Share; existing publications and legacy updates stay +reachable. After the window, legacy updates require a signed-in account. +Never convert legacy IDs or carry a legacy flag into review consent.