mergestory 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/NOTICE +2 -0
- package/README.md +48 -2
- package/assets/kokoro-plugin/package-lock.json +1139 -0
- package/dist/analyzer/analyze.d.ts +8 -0
- package/dist/analyzer/analyze.js +328 -0
- package/dist/analyzer/components.d.ts +18 -0
- package/dist/analyzer/components.js +266 -0
- package/dist/analyzer/dependencies.d.ts +13 -0
- package/dist/analyzer/dependencies.js +349 -0
- package/dist/analyzer/evidence.d.ts +15 -0
- package/dist/analyzer/evidence.js +73 -0
- package/dist/analyzer/hunks.d.ts +21 -0
- package/dist/analyzer/hunks.js +88 -0
- package/dist/analyzer/imports.d.ts +46 -0
- package/dist/analyzer/imports.js +87 -0
- package/dist/analyzer/index.d.ts +14 -0
- package/dist/analyzer/index.js +16 -0
- package/dist/analyzer/languages/go.d.ts +2 -0
- package/dist/analyzer/languages/go.js +76 -0
- package/dist/analyzer/languages/index.d.ts +18 -0
- package/dist/analyzer/languages/index.js +72 -0
- package/dist/analyzer/languages/javascript.d.ts +2 -0
- package/dist/analyzer/languages/javascript.js +336 -0
- package/dist/analyzer/languages/jvm.d.ts +2 -0
- package/dist/analyzer/languages/jvm.js +157 -0
- package/dist/analyzer/languages/others.d.ts +2 -0
- package/dist/analyzer/languages/others.js +40 -0
- package/dist/analyzer/languages/php.d.ts +2 -0
- package/dist/analyzer/languages/php.js +81 -0
- package/dist/analyzer/languages/python.d.ts +2 -0
- package/dist/analyzer/languages/python.js +180 -0
- package/dist/analyzer/languages/ruby.d.ts +2 -0
- package/dist/analyzer/languages/ruby.js +99 -0
- package/dist/analyzer/languages/rust.d.ts +2 -0
- package/dist/analyzer/languages/rust.js +164 -0
- package/dist/analyzer/languages/shared.d.ts +35 -0
- package/dist/analyzer/languages/shared.js +43 -0
- package/dist/analyzer/languages/types.d.ts +78 -0
- package/dist/analyzer/languages/types.js +2 -0
- package/dist/analyzer/pack-format.d.ts +27 -0
- package/dist/analyzer/pack-format.js +139 -0
- package/dist/analyzer/pack.d.ts +26 -0
- package/dist/analyzer/pack.js +498 -0
- package/dist/analyzer/relationships.d.ts +17 -0
- package/dist/analyzer/relationships.js +34 -0
- package/dist/analyzer/risk-rules.d.ts +287 -0
- package/dist/analyzer/risk-rules.js +373 -0
- package/dist/analyzer/risks.d.ts +36 -0
- package/dist/analyzer/risks.js +480 -0
- package/dist/analyzer/roles.d.ts +11 -0
- package/dist/analyzer/roles.js +280 -0
- package/dist/analyzer/scan.d.ts +26 -0
- package/dist/analyzer/scan.js +157 -0
- package/dist/analyzer/signals.d.ts +20 -0
- package/dist/analyzer/signals.js +51 -0
- package/dist/analyzer/symbol-changes.d.ts +11 -0
- package/dist/analyzer/symbol-changes.js +101 -0
- package/dist/analyzer/symbol-types.d.ts +17 -0
- package/dist/analyzer/symbol-types.js +9 -0
- package/dist/analyzer/symbols.d.ts +4 -0
- package/dist/analyzer/symbols.js +16 -0
- package/dist/analyzer/trivial.d.ts +13 -0
- package/dist/analyzer/trivial.js +137 -0
- package/dist/analyzer/util.d.ts +6 -0
- package/dist/analyzer/util.js +24 -0
- package/dist/cli/commands/authoring.d.ts +9 -0
- package/dist/cli/commands/authoring.js +98 -0
- package/dist/cli/commands/cache.d.ts +4 -0
- package/dist/cli/commands/cache.js +37 -0
- package/dist/cli/commands/doctor.d.ts +5 -0
- package/dist/cli/commands/doctor.js +37 -0
- package/dist/cli/commands/generate.d.ts +8 -0
- package/dist/cli/commands/generate.js +69 -0
- package/dist/cli/commands/jobs.d.ts +8 -0
- package/dist/cli/commands/jobs.js +70 -0
- package/dist/cli/commands/publish.d.ts +8 -0
- package/dist/cli/commands/publish.js +120 -0
- package/dist/cli/commands/serve.d.ts +4 -0
- package/dist/cli/commands/serve.js +69 -0
- package/dist/cli/commands/setup.d.ts +14 -0
- package/dist/cli/commands/setup.js +108 -0
- package/dist/cli/commands/shared.d.ts +18 -0
- package/dist/cli/commands/shared.js +24 -0
- package/dist/cli/files.d.ts +26 -0
- package/dist/cli/files.js +98 -0
- package/dist/cli/format.d.ts +55 -0
- package/dist/cli/format.js +295 -0
- package/dist/cli/inputs.d.ts +23 -0
- package/dist/cli/inputs.js +96 -0
- package/dist/cli/io.d.ts +19 -0
- package/dist/cli/io.js +31 -0
- package/dist/cli/main.d.ts +2 -0
- package/dist/cli/main.js +15 -0
- package/dist/cli/options.d.ts +105 -0
- package/dist/cli/options.js +324 -0
- package/dist/cli/program.d.ts +12 -0
- package/dist/cli/program.js +146 -0
- package/dist/cli/runtime.d.ts +59 -0
- package/dist/cli/runtime.js +83 -0
- package/dist/cli/style.d.ts +13 -0
- package/dist/cli/style.js +27 -0
- package/dist/core/binaries.d.ts +7 -0
- package/dist/core/binaries.js +33 -0
- package/dist/core/binary-paths.d.ts +5 -0
- package/dist/core/binary-paths.js +92 -0
- package/dist/core/cache.d.ts +14 -0
- package/dist/core/cache.js +43 -0
- package/dist/core/child-env.d.ts +9 -0
- package/dist/core/child-env.js +61 -0
- package/dist/core/concurrency.d.ts +13 -0
- package/dist/core/concurrency.js +58 -0
- package/dist/core/config.d.ts +223 -0
- package/dist/core/config.js +454 -0
- package/dist/core/context.d.ts +39 -0
- package/dist/core/context.js +44 -0
- package/dist/core/cost.d.ts +46 -0
- package/dist/core/cost.js +108 -0
- package/dist/core/diagram-metrics.d.ts +57 -0
- package/dist/core/diagram-metrics.js +63 -0
- package/dist/core/diff-view.d.ts +44 -0
- package/dist/core/diff-view.js +136 -0
- package/dist/core/errors.d.ts +47 -0
- package/dist/core/errors.js +94 -0
- package/dist/core/ids.d.ts +11 -0
- package/dist/core/ids.js +36 -0
- package/dist/core/json.d.ts +8 -0
- package/dist/core/json.js +17 -0
- package/dist/core/languages.d.ts +19 -0
- package/dist/core/languages.js +292 -0
- package/dist/core/logger.d.ts +29 -0
- package/dist/core/logger.js +68 -0
- package/dist/core/net.d.ts +16 -0
- package/dist/core/net.js +80 -0
- package/dist/core/path-policy.d.ts +20 -0
- package/dist/core/path-policy.js +202 -0
- package/dist/core/paths.d.ts +18 -0
- package/dist/core/paths.js +53 -0
- package/dist/core/posix.d.ts +12 -0
- package/dist/core/posix.js +50 -0
- package/dist/core/process.d.ts +22 -0
- package/dist/core/process.js +117 -0
- package/dist/core/providers.d.ts +204 -0
- package/dist/core/providers.js +2 -0
- package/dist/core/redact.d.ts +11 -0
- package/dist/core/redact.js +70 -0
- package/dist/core/render-plan.d.ts +307 -0
- package/dist/core/render-plan.js +7 -0
- package/dist/core/retry.d.ts +54 -0
- package/dist/core/retry.js +116 -0
- package/dist/core/run-folder.d.ts +74 -0
- package/dist/core/run-folder.js +129 -0
- package/dist/core/secrets.d.ts +56 -0
- package/dist/core/secrets.js +301 -0
- package/dist/core/storyboard-facts.d.ts +22 -0
- package/dist/core/storyboard-facts.js +61 -0
- package/dist/core/storyboard-schema.d.ts +1279 -0
- package/dist/core/storyboard-schema.js +342 -0
- package/dist/core/text.d.ts +43 -0
- package/dist/core/text.js +94 -0
- package/dist/core/types.d.ts +459 -0
- package/dist/core/types.js +17 -0
- package/dist/doctor/check.d.ts +6 -0
- package/dist/doctor/check.js +18 -0
- package/dist/doctor/deps.d.ts +2 -0
- package/dist/doctor/deps.js +90 -0
- package/dist/doctor/format.d.ts +9 -0
- package/dist/doctor/format.js +19 -0
- package/dist/doctor/github.d.ts +2 -0
- package/dist/doctor/github.js +13 -0
- package/dist/doctor/home.d.ts +2 -0
- package/dist/doctor/home.js +26 -0
- package/dist/doctor/index.d.ts +18 -0
- package/dist/doctor/index.js +81 -0
- package/dist/doctor/llm.d.ts +2 -0
- package/dist/doctor/llm.js +32 -0
- package/dist/doctor/publish.d.ts +2 -0
- package/dist/doctor/publish.js +16 -0
- package/dist/doctor/s3.d.ts +2 -0
- package/dist/doctor/s3.js +125 -0
- package/dist/doctor/speech.d.ts +2 -0
- package/dist/doctor/speech.js +112 -0
- package/dist/doctor/tools.d.ts +5 -0
- package/dist/doctor/tools.js +58 -0
- package/dist/doctor/types.d.ts +92 -0
- package/dist/doctor/types.js +2 -0
- package/dist/doctor/youtube.d.ts +2 -0
- package/dist/doctor/youtube.js +73 -0
- package/dist/github/client.d.ts +108 -0
- package/dist/github/client.js +499 -0
- package/dist/github/errors.d.ts +37 -0
- package/dist/github/errors.js +155 -0
- package/dist/github/index.d.ts +13 -0
- package/dist/github/index.js +9 -0
- package/dist/github/linked-issues.d.ts +37 -0
- package/dist/github/linked-issues.js +131 -0
- package/dist/github/model.d.ts +81 -0
- package/dist/github/model.js +114 -0
- package/dist/github/notify.d.ts +27 -0
- package/dist/github/notify.js +118 -0
- package/dist/github/pr-url.d.ts +27 -0
- package/dist/github/pr-url.js +122 -0
- package/dist/github/token.d.ts +16 -0
- package/dist/github/token.js +69 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +19 -0
- package/dist/jobs/input-rules.d.ts +20 -0
- package/dist/jobs/input-rules.js +100 -0
- package/dist/jobs/model.d.ts +47 -0
- package/dist/jobs/model.js +18 -0
- package/dist/jobs/runner.d.ts +43 -0
- package/dist/jobs/runner.js +165 -0
- package/dist/jobs/store.d.ts +67 -0
- package/dist/jobs/store.js +314 -0
- package/dist/jobs/view.d.ts +48 -0
- package/dist/jobs/view.js +111 -0
- package/dist/jobs/worker.d.ts +24 -0
- package/dist/jobs/worker.js +47 -0
- package/dist/llm/anthropic.d.ts +11 -0
- package/dist/llm/anthropic.js +225 -0
- package/dist/llm/index.d.ts +10 -0
- package/dist/llm/index.js +27 -0
- package/dist/llm/openai-compatible.d.ts +33 -0
- package/dist/llm/openai-compatible.js +378 -0
- package/dist/llm/prices.d.ts +26 -0
- package/dist/llm/prices.js +41 -0
- package/dist/llm/shared.d.ts +30 -0
- package/dist/llm/shared.js +115 -0
- package/dist/narration/assemble.d.ts +36 -0
- package/dist/narration/assemble.js +282 -0
- package/dist/narration/audio.d.ts +61 -0
- package/dist/narration/audio.js +301 -0
- package/dist/narration/captions.d.ts +37 -0
- package/dist/narration/captions.js +195 -0
- package/dist/narration/chunking.d.ts +6 -0
- package/dist/narration/chunking.js +46 -0
- package/dist/narration/convert.d.ts +9 -0
- package/dist/narration/convert.js +90 -0
- package/dist/narration/elevenlabs.d.ts +5 -0
- package/dist/narration/elevenlabs.js +53 -0
- package/dist/narration/http-errors.d.ts +14 -0
- package/dist/narration/http-errors.js +74 -0
- package/dist/narration/index.d.ts +21 -0
- package/dist/narration/index.js +22 -0
- package/dist/narration/kokoro-install.d.ts +30 -0
- package/dist/narration/kokoro-install.js +284 -0
- package/dist/narration/kokoro-model.d.ts +54 -0
- package/dist/narration/kokoro-model.js +168 -0
- package/dist/narration/kokoro-plugin.d.ts +78 -0
- package/dist/narration/kokoro-plugin.js +245 -0
- package/dist/narration/kokoro.d.ts +22 -0
- package/dist/narration/kokoro.js +231 -0
- package/dist/narration/openai.d.ts +4 -0
- package/dist/narration/openai.js +54 -0
- package/dist/narration/pricing.d.ts +8 -0
- package/dist/narration/pricing.js +17 -0
- package/dist/narration/remote-speech.d.ts +53 -0
- package/dist/narration/remote-speech.js +100 -0
- package/dist/narration/say.d.ts +28 -0
- package/dist/narration/say.js +178 -0
- package/dist/narration/select.d.ts +27 -0
- package/dist/narration/select.js +80 -0
- package/dist/narration/silent.d.ts +2 -0
- package/dist/narration/silent.js +18 -0
- package/dist/narration/speakable.d.ts +20 -0
- package/dist/narration/speakable.js +398 -0
- package/dist/narration/synthesize.d.ts +25 -0
- package/dist/narration/synthesize.js +220 -0
- package/dist/narration/wav.d.ts +37 -0
- package/dist/narration/wav.js +170 -0
- package/dist/pipeline/authoring.d.ts +8 -0
- package/dist/pipeline/authoring.js +117 -0
- package/dist/pipeline/commands.d.ts +9 -0
- package/dist/pipeline/commands.js +21 -0
- package/dist/pipeline/fit-duration.d.ts +41 -0
- package/dist/pipeline/fit-duration.js +150 -0
- package/dist/pipeline/index.d.ts +9 -0
- package/dist/pipeline/index.js +9 -0
- package/dist/pipeline/inputs.d.ts +42 -0
- package/dist/pipeline/inputs.js +171 -0
- package/dist/pipeline/plan.d.ts +8 -0
- package/dist/pipeline/plan.js +85 -0
- package/dist/pipeline/planned-egress.d.ts +21 -0
- package/dist/pipeline/planned-egress.js +43 -0
- package/dist/pipeline/prepare.d.ts +26 -0
- package/dist/pipeline/prepare.js +84 -0
- package/dist/pipeline/presentation.d.ts +26 -0
- package/dist/pipeline/presentation.js +110 -0
- package/dist/pipeline/publish-run.d.ts +71 -0
- package/dist/pipeline/publish-run.js +295 -0
- package/dist/pipeline/run.d.ts +7 -0
- package/dist/pipeline/run.js +196 -0
- package/dist/pipeline/storyboard-choice.d.ts +34 -0
- package/dist/pipeline/storyboard-choice.js +129 -0
- package/dist/pipeline/types.d.ts +76 -0
- package/dist/pipeline/types.js +2 -0
- package/dist/publish/access-probe.d.ts +55 -0
- package/dist/publish/access-probe.js +249 -0
- package/dist/publish/bundle.d.ts +20 -0
- package/dist/publish/bundle.js +57 -0
- package/dist/publish/comment.d.ts +10 -0
- package/dist/publish/comment.js +184 -0
- package/dist/publish/content-types.d.ts +15 -0
- package/dist/publish/content-types.js +41 -0
- package/dist/publish/index.d.ts +18 -0
- package/dist/publish/index.js +30 -0
- package/dist/publish/keys.d.ts +10 -0
- package/dist/publish/keys.js +30 -0
- package/dist/publish/local.d.ts +33 -0
- package/dist/publish/local.js +143 -0
- package/dist/publish/privacy.d.ts +20 -0
- package/dist/publish/privacy.js +21 -0
- package/dist/publish/s3/bucket.d.ts +22 -0
- package/dist/publish/s3/bucket.js +82 -0
- package/dist/publish/s3/client.d.ts +33 -0
- package/dist/publish/s3/client.js +134 -0
- package/dist/publish/s3/failures.d.ts +22 -0
- package/dist/publish/s3/failures.js +110 -0
- package/dist/publish/s3/index.d.ts +5 -0
- package/dist/publish/s3/index.js +6 -0
- package/dist/publish/s3/links.d.ts +38 -0
- package/dist/publish/s3/links.js +60 -0
- package/dist/publish/s3/protected-links.d.ts +29 -0
- package/dist/publish/s3/protected-links.js +67 -0
- package/dist/publish/s3/publisher.d.ts +32 -0
- package/dist/publish/s3/publisher.js +123 -0
- package/dist/publish/s3/settings.d.ts +29 -0
- package/dist/publish/s3/settings.js +64 -0
- package/dist/publish/s3/upload.d.ts +29 -0
- package/dist/publish/s3/upload.js +145 -0
- package/dist/publish/severity.d.ts +9 -0
- package/dist/publish/severity.js +18 -0
- package/dist/publish/text.d.ts +23 -0
- package/dist/publish/text.js +94 -0
- package/dist/publish/types.d.ts +67 -0
- package/dist/publish/types.js +12 -0
- package/dist/publish/vtt.d.ts +9 -0
- package/dist/publish/vtt.js +43 -0
- package/dist/publish/watch-page.d.ts +4 -0
- package/dist/publish/watch-page.js +463 -0
- package/dist/publish/youtube/credentials.d.ts +33 -0
- package/dist/publish/youtube/credentials.js +162 -0
- package/dist/publish/youtube/description.d.ts +56 -0
- package/dist/publish/youtube/description.js +197 -0
- package/dist/publish/youtube/google-api.d.ts +95 -0
- package/dist/publish/youtube/google-api.js +339 -0
- package/dist/publish/youtube/index.d.ts +7 -0
- package/dist/publish/youtube/index.js +8 -0
- package/dist/publish/youtube/loopback.d.ts +13 -0
- package/dist/publish/youtube/loopback.js +144 -0
- package/dist/publish/youtube/oauth.d.ts +68 -0
- package/dist/publish/youtube/oauth.js +159 -0
- package/dist/publish/youtube/prompt.d.ts +27 -0
- package/dist/publish/youtube/prompt.js +94 -0
- package/dist/publish/youtube/publisher.d.ts +38 -0
- package/dist/publish/youtube/publisher.js +346 -0
- package/dist/publish/youtube/scopes.d.ts +32 -0
- package/dist/publish/youtube/scopes.js +55 -0
- package/dist/publish/youtube/sign-in.d.ts +37 -0
- package/dist/publish/youtube/sign-in.js +137 -0
- package/dist/publish/youtube/upload.d.ts +43 -0
- package/dist/publish/youtube/upload.js +210 -0
- package/dist/render/browser.d.ts +23 -0
- package/dist/render/browser.js +219 -0
- package/dist/render/chromium-renderer.d.ts +56 -0
- package/dist/render/chromium-renderer.js +519 -0
- package/dist/render/ffmpeg.d.ts +55 -0
- package/dist/render/ffmpeg.js +212 -0
- package/dist/render/fonts.d.ts +10 -0
- package/dist/render/fonts.js +42 -0
- package/dist/render/index.d.ts +9 -0
- package/dist/render/index.js +11 -0
- package/dist/render/page.d.ts +46 -0
- package/dist/render/page.js +123 -0
- package/dist/render/playwright.d.ts +3 -0
- package/dist/render/playwright.js +6 -0
- package/dist/render/runtime-bundle.d.ts +2 -0
- package/dist/render/runtime-bundle.js +72 -0
- package/dist/runtime/runtime.js +1626 -0
- package/dist/server/auth.d.ts +17 -0
- package/dist/server/auth.js +58 -0
- package/dist/server/http.d.ts +43 -0
- package/dist/server/http.js +119 -0
- package/dist/server/index.d.ts +46 -0
- package/dist/server/index.js +310 -0
- package/dist/server/queue.d.ts +30 -0
- package/dist/server/queue.js +76 -0
- package/dist/server/schema.d.ts +103 -0
- package/dist/server/schema.js +121 -0
- package/dist/server/source.d.ts +17 -0
- package/dist/server/source.js +100 -0
- package/dist/sources/assemble.d.ts +86 -0
- package/dist/sources/assemble.js +117 -0
- package/dist/sources/diff-parser.d.ts +14 -0
- package/dist/sources/diff-parser.js +84 -0
- package/dist/sources/git.d.ts +28 -0
- package/dist/sources/git.js +108 -0
- package/dist/sources/github.d.ts +20 -0
- package/dist/sources/github.js +192 -0
- package/dist/sources/hunk-selection.d.ts +25 -0
- package/dist/sources/hunk-selection.js +46 -0
- package/dist/sources/index.d.ts +23 -0
- package/dist/sources/index.js +62 -0
- package/dist/sources/limits.d.ts +27 -0
- package/dist/sources/limits.js +22 -0
- package/dist/sources/local.d.ts +34 -0
- package/dist/sources/local.js +555 -0
- package/dist/sources/reader.d.ts +13 -0
- package/dist/sources/reader.js +45 -0
- package/dist/sources/remote.d.ts +13 -0
- package/dist/sources/remote.js +41 -0
- package/dist/sources/repo-context.d.ts +34 -0
- package/dist/sources/repo-context.js +144 -0
- package/dist/sources/text.d.ts +25 -0
- package/dist/sources/text.js +71 -0
- package/dist/storyboard/authoring.d.ts +108 -0
- package/dist/storyboard/authoring.js +196 -0
- package/dist/storyboard/claims.d.ts +35 -0
- package/dist/storyboard/claims.js +318 -0
- package/dist/storyboard/coderef.d.ts +28 -0
- package/dist/storyboard/coderef.js +118 -0
- package/dist/storyboard/generate.d.ts +25 -0
- package/dist/storyboard/generate.js +194 -0
- package/dist/storyboard/heuristic-code.d.ts +91 -0
- package/dist/storyboard/heuristic-code.js +524 -0
- package/dist/storyboard/heuristic-context.d.ts +42 -0
- package/dist/storyboard/heuristic-context.js +102 -0
- package/dist/storyboard/heuristic-facts.d.ts +106 -0
- package/dist/storyboard/heuristic-facts.js +415 -0
- package/dist/storyboard/heuristic-overview.d.ts +4 -0
- package/dist/storyboard/heuristic-overview.js +151 -0
- package/dist/storyboard/heuristic-review.d.ts +10 -0
- package/dist/storyboard/heuristic-review.js +158 -0
- package/dist/storyboard/heuristic-scenes.d.ts +8 -0
- package/dist/storyboard/heuristic-scenes.js +357 -0
- package/dist/storyboard/heuristic-shared.d.ts +43 -0
- package/dist/storyboard/heuristic-shared.js +136 -0
- package/dist/storyboard/heuristic.d.ts +15 -0
- package/dist/storyboard/heuristic.js +324 -0
- package/dist/storyboard/identifiers.d.ts +51 -0
- package/dist/storyboard/identifiers.js +195 -0
- package/dist/storyboard/index.d.ts +10 -0
- package/dist/storyboard/index.js +10 -0
- package/dist/storyboard/prompts.d.ts +16 -0
- package/dist/storyboard/prompts.js +61 -0
- package/dist/storyboard/run.d.ts +82 -0
- package/dist/storyboard/run.js +332 -0
- package/dist/storyboard/text.d.ts +16 -0
- package/dist/storyboard/text.js +103 -0
- package/dist/storyboard/types.d.ts +47 -0
- package/dist/storyboard/types.js +2 -0
- package/dist/storyboard/urls.d.ts +15 -0
- package/dist/storyboard/urls.js +83 -0
- package/dist/storyboard/validate.d.ts +8 -0
- package/dist/storyboard/validate.js +525 -0
- package/dist/storyboard/visuals.d.ts +23 -0
- package/dist/storyboard/visuals.js +324 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +3 -0
- package/dist/visuals/code.d.ts +68 -0
- package/dist/visuals/code.js +385 -0
- package/dist/visuals/highlight.d.ts +17 -0
- package/dist/visuals/highlight.js +85 -0
- package/dist/visuals/image.d.ts +12 -0
- package/dist/visuals/image.js +96 -0
- package/dist/visuals/index.d.ts +10 -0
- package/dist/visuals/index.js +10 -0
- package/dist/visuals/layout.d.ts +89 -0
- package/dist/visuals/layout.js +506 -0
- package/dist/visuals/plan.d.ts +33 -0
- package/dist/visuals/plan.js +511 -0
- package/dist/visuals/timeline.d.ts +31 -0
- package/dist/visuals/timeline.js +96 -0
- package/package.json +74 -4
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Putting the files of a bundle into the bucket, the watch page last. Each file is retried after a
|
|
3
|
+
* temporary error and given up on when the connection stalls; what was sent is recorded as it goes.
|
|
4
|
+
*/
|
|
5
|
+
import { createReadStream } from 'node:fs';
|
|
6
|
+
import { assertNotAborted, MergeStoryError } from '../../core/errors.js';
|
|
7
|
+
import { retry } from '../../core/retry.js';
|
|
8
|
+
import { WATCH_PAGE_NAME } from '../bundle.js';
|
|
9
|
+
import { cacheControlFor, contentTypeFor } from '../content-types.js';
|
|
10
|
+
import { isTransient, toPublishError } from './failures.js';
|
|
11
|
+
/** One fixed part size for every part: some services require all parts but the last to match. */
|
|
12
|
+
const PART_SIZE = 8 * 1024 * 1024;
|
|
13
|
+
/** Safety net against a stalled connection, not a speed limit: two minutes plus the bytes at 20 kB/s. */
|
|
14
|
+
function uploadTimeoutMs(sizeBytes) {
|
|
15
|
+
return 120_000 + Math.ceil(sizeBytes / 20_000) * 1_000;
|
|
16
|
+
}
|
|
17
|
+
async function uploadObject(libs, client, bucket, job, ctx) {
|
|
18
|
+
await retry(async () => {
|
|
19
|
+
assertNotAborted(ctx.signal);
|
|
20
|
+
const abort = new AbortController();
|
|
21
|
+
let timedOut = false;
|
|
22
|
+
const timer = setTimeout(() => {
|
|
23
|
+
timedOut = true;
|
|
24
|
+
abort.abort();
|
|
25
|
+
}, uploadTimeoutMs(job.sizeBytes));
|
|
26
|
+
const onCancel = () => abort.abort();
|
|
27
|
+
ctx.signal.addEventListener('abort', onCancel, { once: true });
|
|
28
|
+
try {
|
|
29
|
+
const upload = new libs.Upload({
|
|
30
|
+
client,
|
|
31
|
+
// No ACL: buckets that enforce object ownership reject them.
|
|
32
|
+
params: {
|
|
33
|
+
Bucket: bucket,
|
|
34
|
+
Key: job.key,
|
|
35
|
+
Body: job.body(),
|
|
36
|
+
ContentType: job.contentType,
|
|
37
|
+
CacheControl: job.cacheControl,
|
|
38
|
+
ContentDisposition: 'inline',
|
|
39
|
+
ContentLength: job.sizeBytes,
|
|
40
|
+
},
|
|
41
|
+
queueSize: 4,
|
|
42
|
+
partSize: PART_SIZE,
|
|
43
|
+
leavePartsOnError: false,
|
|
44
|
+
abortController: abort,
|
|
45
|
+
});
|
|
46
|
+
await upload.done();
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
if (timedOut && !ctx.signal.aborted) {
|
|
50
|
+
throw new MergeStoryError('PUBLISH_FAILED', `The upload of ${job.name} stalled.`, {
|
|
51
|
+
hint: 'Check your network connection and try again.',
|
|
52
|
+
retryable: true,
|
|
53
|
+
cause: err,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
throw err;
|
|
57
|
+
}
|
|
58
|
+
finally {
|
|
59
|
+
clearTimeout(timer);
|
|
60
|
+
ctx.signal.removeEventListener('abort', onCancel);
|
|
61
|
+
}
|
|
62
|
+
}, {
|
|
63
|
+
attempts: 3,
|
|
64
|
+
minDelayMs: 750,
|
|
65
|
+
maxDelayMs: 8_000,
|
|
66
|
+
signal: ctx.signal,
|
|
67
|
+
isRetryable: isTransient,
|
|
68
|
+
onRetry: ({ attempt }) => ctx.logger.warn('Upload failed, trying again', { attempt }),
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
/** How long the removal of the files of a failed upload may take. */
|
|
72
|
+
const CLEANUP_TIMEOUT_MS = 30_000;
|
|
73
|
+
/**
|
|
74
|
+
* Remove what a failed upload left in the bucket, so no video stays there that nobody has a link to.
|
|
75
|
+
* Returns true when every file is gone.
|
|
76
|
+
*/
|
|
77
|
+
async function removeUploaded({ libs, client, bucket }, keys) {
|
|
78
|
+
const results = await Promise.allSettled(keys.map((Key) => client.send(new libs.DeleteObjectCommand({ Bucket: bucket, Key }), {
|
|
79
|
+
abortSignal: AbortSignal.timeout(CLEANUP_TIMEOUT_MS),
|
|
80
|
+
})));
|
|
81
|
+
return results.every((r) => r.status === 'fulfilled');
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Upload the files and then the watch page, in that order. Stops at the first file that cannot be sent
|
|
85
|
+
* and then removes the files that were already sent.
|
|
86
|
+
*/
|
|
87
|
+
export async function uploadBundle(upload) {
|
|
88
|
+
const { libs, client, bucket, host, keyPrefix, files, page, visibility, ctx } = upload;
|
|
89
|
+
const jobs = files.ordered.map(({ file, sizeBytes }) => ({
|
|
90
|
+
name: file.name,
|
|
91
|
+
key: `${keyPrefix}${file.name}`,
|
|
92
|
+
contentType: contentTypeFor(file.name),
|
|
93
|
+
cacheControl: cacheControlFor(file.name, visibility),
|
|
94
|
+
sizeBytes,
|
|
95
|
+
body: () => createReadStream(file.path),
|
|
96
|
+
}));
|
|
97
|
+
jobs.push({
|
|
98
|
+
name: WATCH_PAGE_NAME,
|
|
99
|
+
key: `${keyPrefix}${WATCH_PAGE_NAME}`,
|
|
100
|
+
contentType: contentTypeFor(WATCH_PAGE_NAME),
|
|
101
|
+
cacheControl: cacheControlFor(WATCH_PAGE_NAME, visibility),
|
|
102
|
+
sizeBytes: page.length,
|
|
103
|
+
body: () => page,
|
|
104
|
+
});
|
|
105
|
+
const totalBytes = jobs.reduce((sum, job) => sum + job.sizeBytes, 0);
|
|
106
|
+
ctx.logger.info('Uploading the video bundle', { bucket, files: jobs.length, bytes: totalBytes });
|
|
107
|
+
let sent = 0;
|
|
108
|
+
const sentKeys = [];
|
|
109
|
+
for (const job of jobs) {
|
|
110
|
+
try {
|
|
111
|
+
await uploadObject(libs, client, bucket, job, ctx);
|
|
112
|
+
}
|
|
113
|
+
catch (err) {
|
|
114
|
+
const failure = toPublishError(err, ctx, `Uploading ${job.name}`);
|
|
115
|
+
// The failed file is included: a stalled upload may have reached the bucket after all.
|
|
116
|
+
if (sentKeys.length === 0 || (await removeUploaded(upload, [...sentKeys, job.key])))
|
|
117
|
+
throw failure;
|
|
118
|
+
throw new MergeStoryError(failure.code, failure.message, {
|
|
119
|
+
hint: `${failure.hint ?? ''} Some files were already uploaded and could not be removed. Check ${bucket}/${keyPrefix} and delete that folder.`.trim(),
|
|
120
|
+
cause: failure.cause,
|
|
121
|
+
details: failure.details,
|
|
122
|
+
retryable: failure.retryable,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
sentKeys.push(job.key);
|
|
126
|
+
sent += job.sizeBytes;
|
|
127
|
+
ctx.egress.record(host, 'video upload', job.sizeBytes, upload.contains);
|
|
128
|
+
ctx.progress({
|
|
129
|
+
stage: 'publish',
|
|
130
|
+
status: 'progress',
|
|
131
|
+
progress: sent / totalBytes,
|
|
132
|
+
message: `Uploaded ${job.name}`,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
// Storage is billed by the provider and is not metered here, so the cost is recorded as zero (estimated).
|
|
136
|
+
ctx.cost.record({
|
|
137
|
+
provider: 's3',
|
|
138
|
+
kind: 'storage',
|
|
139
|
+
model: null,
|
|
140
|
+
bytes: totalBytes,
|
|
141
|
+
costUsd: 0,
|
|
142
|
+
estimated: true,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=upload.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Severity levels shared by the watch page and the pull request comment. */
|
|
2
|
+
/** Most severe first. */
|
|
3
|
+
export declare const SEVERITIES: readonly ['high', 'medium', 'low', 'info'];
|
|
4
|
+
export type Severity = (typeof SEVERITIES)[number];
|
|
5
|
+
export declare const SEVERITY_LABEL: Record<Severity, string>;
|
|
6
|
+
/** Unknown values count as "info". */
|
|
7
|
+
export declare function severityOf(value: unknown): Severity;
|
|
8
|
+
/** Rank for sorting, most severe first. */
|
|
9
|
+
export declare function severityRank(value: unknown): number;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Severity levels shared by the watch page and the pull request comment. */
|
|
2
|
+
/** Most severe first. */
|
|
3
|
+
export const SEVERITIES = ['high', 'medium', 'low', 'info'];
|
|
4
|
+
export const SEVERITY_LABEL = {
|
|
5
|
+
high: 'High',
|
|
6
|
+
medium: 'Medium',
|
|
7
|
+
low: 'Low',
|
|
8
|
+
info: 'Info',
|
|
9
|
+
};
|
|
10
|
+
/** Unknown values count as "info". */
|
|
11
|
+
export function severityOf(value) {
|
|
12
|
+
return SEVERITIES.find((s) => s === value) ?? 'info';
|
|
13
|
+
}
|
|
14
|
+
/** Rank for sorting, most severe first. */
|
|
15
|
+
export function severityRank(value) {
|
|
16
|
+
return SEVERITIES.indexOf(severityOf(value));
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=severity.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single-line plain text: invisible and direction-control characters removed, whitespace
|
|
3
|
+
* collapsed, length capped. Anything that is not a string becomes an empty string.
|
|
4
|
+
*/
|
|
5
|
+
export declare function cleanText(value: unknown, max?: number): string;
|
|
6
|
+
/** Escape text for use in HTML content and quoted attribute values. */
|
|
7
|
+
export declare function escapeHtml(value: string): string;
|
|
8
|
+
/** Escape a value for a double-quoted HTML attribute. Single quotes stay readable. */
|
|
9
|
+
export declare function escapeAttribute(value: string): string;
|
|
10
|
+
/** Clean, cap and HTML-escape in one step. */
|
|
11
|
+
export declare function htmlText(value: unknown, max?: number): string;
|
|
12
|
+
/** A normalised http(s) URL without embedded credentials, or null. */
|
|
13
|
+
export declare function safeHttpUrl(value: unknown): string | null;
|
|
14
|
+
/** An http(s) URL or a plain relative file path (used by the local watch page), or null. */
|
|
15
|
+
export declare function safeAssetUrl(value: unknown): string | null;
|
|
16
|
+
/** "m:ss", or "h:mm:ss" from one hour up. Negative and invalid values count as zero. */
|
|
17
|
+
export declare function formatTimestamp(totalSec: number): string;
|
|
18
|
+
/** "2026-11-03", or null when the value is not a valid date. */
|
|
19
|
+
export declare function formatDate(iso: unknown): string | null;
|
|
20
|
+
/** "2026-11-03 14:05 UTC", or null when the value is not a valid date. */
|
|
21
|
+
export declare function formatDateTime(iso: unknown): string | null;
|
|
22
|
+
/** First seven characters of a commit id, or null when it does not look like one. */
|
|
23
|
+
export declare function shortSha(sha: unknown): string | null;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers for text that comes from pull requests and models. Everything here treats its
|
|
3
|
+
* input as hostile: control characters are dropped, URLs are checked, markup is escaped.
|
|
4
|
+
*/
|
|
5
|
+
import { stripInvisible, truncate } from '../core/text.js';
|
|
6
|
+
/**
|
|
7
|
+
* Single-line plain text: invisible and direction-control characters removed, whitespace
|
|
8
|
+
* collapsed, length capped. Anything that is not a string becomes an empty string.
|
|
9
|
+
*/
|
|
10
|
+
export function cleanText(value, max = 500) {
|
|
11
|
+
const text = typeof value === 'string' ? value : typeof value === 'number' ? String(value) : '';
|
|
12
|
+
return truncate(stripInvisible(text, 'white-space').replace(/\s+/g, ' ').trim(), max);
|
|
13
|
+
}
|
|
14
|
+
const HTML_ENTITIES = {
|
|
15
|
+
'&': '&',
|
|
16
|
+
'<': '<',
|
|
17
|
+
'>': '>',
|
|
18
|
+
'"': '"',
|
|
19
|
+
"'": ''',
|
|
20
|
+
};
|
|
21
|
+
/** Escape text for use in HTML content and quoted attribute values. */
|
|
22
|
+
export function escapeHtml(value) {
|
|
23
|
+
return value.replace(/[&<>"']/g, (ch) => HTML_ENTITIES[ch] ?? ch);
|
|
24
|
+
}
|
|
25
|
+
/** Escape a value for a double-quoted HTML attribute. Single quotes stay readable. */
|
|
26
|
+
export function escapeAttribute(value) {
|
|
27
|
+
return value.replace(/[&<>"]/g, (ch) => HTML_ENTITIES[ch] ?? ch);
|
|
28
|
+
}
|
|
29
|
+
/** Clean, cap and HTML-escape in one step. */
|
|
30
|
+
export function htmlText(value, max = 500) {
|
|
31
|
+
return escapeHtml(cleanText(value, max));
|
|
32
|
+
}
|
|
33
|
+
/** A normalised http(s) URL without embedded credentials, or null. */
|
|
34
|
+
export function safeHttpUrl(value) {
|
|
35
|
+
if (typeof value !== 'string')
|
|
36
|
+
return null;
|
|
37
|
+
const trimmed = value.trim();
|
|
38
|
+
if (!trimmed || trimmed.length > 4096)
|
|
39
|
+
return null;
|
|
40
|
+
let url;
|
|
41
|
+
try {
|
|
42
|
+
url = new URL(trimmed);
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
if (url.protocol !== 'https:' && url.protocol !== 'http:')
|
|
48
|
+
return null;
|
|
49
|
+
if (url.username || url.password)
|
|
50
|
+
return null;
|
|
51
|
+
return url.href;
|
|
52
|
+
}
|
|
53
|
+
// A plain relative path such as "video.mp4": no scheme, no leading slash, no "..", no escapes.
|
|
54
|
+
const RELATIVE_ASSET = /^[A-Za-z0-9_~@+-][A-Za-z0-9._~@+-]*(?:\/[A-Za-z0-9_~@+-][A-Za-z0-9._~@+-]*)*$/;
|
|
55
|
+
/** An http(s) URL or a plain relative file path (used by the local watch page), or null. */
|
|
56
|
+
export function safeAssetUrl(value) {
|
|
57
|
+
const absolute = safeHttpUrl(value);
|
|
58
|
+
if (absolute)
|
|
59
|
+
return absolute;
|
|
60
|
+
if (typeof value !== 'string')
|
|
61
|
+
return null;
|
|
62
|
+
const path = value.trim();
|
|
63
|
+
if (!RELATIVE_ASSET.test(path))
|
|
64
|
+
return null;
|
|
65
|
+
return path.split('/').some((segment) => segment === '..' || segment === '.') ? null : path;
|
|
66
|
+
}
|
|
67
|
+
/** "m:ss", or "h:mm:ss" from one hour up. Negative and invalid values count as zero. */
|
|
68
|
+
export function formatTimestamp(totalSec) {
|
|
69
|
+
const total = Number.isFinite(totalSec) ? Math.max(0, Math.floor(totalSec)) : 0;
|
|
70
|
+
const hours = Math.floor(total / 3600);
|
|
71
|
+
const minutes = Math.floor((total % 3600) / 60);
|
|
72
|
+
const seconds = total % 60;
|
|
73
|
+
const ss = String(seconds).padStart(2, '0');
|
|
74
|
+
return hours > 0 ? `${hours}:${String(minutes).padStart(2, '0')}:${ss}` : `${minutes}:${ss}`;
|
|
75
|
+
}
|
|
76
|
+
/** "2026-11-03", or null when the value is not a valid date. */
|
|
77
|
+
export function formatDate(iso) {
|
|
78
|
+
const ms = typeof iso === 'string' ? Date.parse(iso) : Number.NaN;
|
|
79
|
+
return Number.isFinite(ms) ? new Date(ms).toISOString().slice(0, 10) : null;
|
|
80
|
+
}
|
|
81
|
+
/** "2026-11-03 14:05 UTC", or null when the value is not a valid date. */
|
|
82
|
+
export function formatDateTime(iso) {
|
|
83
|
+
const ms = typeof iso === 'string' ? Date.parse(iso) : Number.NaN;
|
|
84
|
+
if (!Number.isFinite(ms))
|
|
85
|
+
return null;
|
|
86
|
+
return `${new Date(ms).toISOString().slice(0, 16).replace('T', ' ')} UTC`;
|
|
87
|
+
}
|
|
88
|
+
/** First seven characters of a commit id, or null when it does not look like one. */
|
|
89
|
+
export function shortSha(sha) {
|
|
90
|
+
return typeof sha === 'string' && /^[0-9a-f]{7,64}$/i.test(sha.trim())
|
|
91
|
+
? sha.trim().slice(0, 7).toLowerCase()
|
|
92
|
+
: null;
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=text.js.map
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/** Shared types and constants of the publish module. Re-exported from index.ts. */
|
|
2
|
+
import type { Chapter, EgressContent } from '../core/types.ts';
|
|
3
|
+
/** What a published bundle carries: the video, its captions and the watch page with title, summary and claims. */
|
|
4
|
+
export declare const BUNDLE_CONTAINS: readonly EgressContent[];
|
|
5
|
+
/** First line of the pull request comment; used to find and update the comment later. */
|
|
6
|
+
export declare const COMMENT_MARKER = "<!-- mergestory:comment -->";
|
|
7
|
+
export declare const DESCRIPTION_START = "<!-- mergestory:start -->";
|
|
8
|
+
export declare const DESCRIPTION_END = "<!-- mergestory:end -->";
|
|
9
|
+
export interface EvidenceLink {
|
|
10
|
+
label: string;
|
|
11
|
+
/** http(s) link to the file at the head commit, or null when unknown. */
|
|
12
|
+
url: string | null;
|
|
13
|
+
}
|
|
14
|
+
export interface WatchPageData {
|
|
15
|
+
title: string;
|
|
16
|
+
summary: string;
|
|
17
|
+
repoLabel: string;
|
|
18
|
+
changeLabel: string;
|
|
19
|
+
/** Link to the pull request, when known. */
|
|
20
|
+
changeUrl: string | null;
|
|
21
|
+
headSha: string;
|
|
22
|
+
durationSec: number;
|
|
23
|
+
chapters: Chapter[];
|
|
24
|
+
checklist: {
|
|
25
|
+
title: string;
|
|
26
|
+
detail: string;
|
|
27
|
+
severity: 'info' | 'low' | 'medium' | 'high';
|
|
28
|
+
ref: EvidenceLink | null;
|
|
29
|
+
}[];
|
|
30
|
+
/** Every narration line with the evidence it cites, grouped by chapter. */
|
|
31
|
+
claims: {
|
|
32
|
+
chapter: string;
|
|
33
|
+
text: string;
|
|
34
|
+
evidence: EvidenceLink[];
|
|
35
|
+
}[];
|
|
36
|
+
uncertainties: string[];
|
|
37
|
+
storyboardSource: 'llm' | 'agent' | 'heuristic';
|
|
38
|
+
generator: {
|
|
39
|
+
llm: string | null;
|
|
40
|
+
tts: string;
|
|
41
|
+
};
|
|
42
|
+
/** true when the video contains simulated (illustrative) visuals. */
|
|
43
|
+
hasSimulatedVisuals: boolean;
|
|
44
|
+
generatedAt: string;
|
|
45
|
+
engineVersion: string;
|
|
46
|
+
/**
|
|
47
|
+
* Whether the sidecar caption track is switched on when the page loads. Defaults to true.
|
|
48
|
+
* Set it to false when the captions are already drawn into the video.
|
|
49
|
+
*/
|
|
50
|
+
captionsDefault?: boolean;
|
|
51
|
+
/** Language of the narration and captions as a BCP 47 code, for the caption track. Defaults to "en". */
|
|
52
|
+
language?: string;
|
|
53
|
+
}
|
|
54
|
+
export interface CommentData {
|
|
55
|
+
title: string;
|
|
56
|
+
summary: string;
|
|
57
|
+
watchUrl: string;
|
|
58
|
+
posterUrl: string | null;
|
|
59
|
+
durationSec: number;
|
|
60
|
+
chapters: Chapter[];
|
|
61
|
+
checklist: WatchPageData['checklist'];
|
|
62
|
+
headSha: string;
|
|
63
|
+
linkExpiresAt: string | null;
|
|
64
|
+
visibility: 'public' | 'private' | 'protected' | 'unlisted';
|
|
65
|
+
/** The publisher that made the link, such as "s3" or "youtube". */
|
|
66
|
+
provider: string;
|
|
67
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** What a published bundle carries: the video, its captions and the watch page with title, summary and claims. */
|
|
2
|
+
export const BUNDLE_CONTAINS = [
|
|
3
|
+
'video',
|
|
4
|
+
'narration-text',
|
|
5
|
+
'storyboard',
|
|
6
|
+
'pr-metadata',
|
|
7
|
+
];
|
|
8
|
+
/** First line of the pull request comment; used to find and update the comment later. */
|
|
9
|
+
export const COMMENT_MARKER = '<!-- mergestory:comment -->';
|
|
10
|
+
export const DESCRIPTION_START = '<!-- mergestory:start -->';
|
|
11
|
+
export const DESCRIPTION_END = '<!-- mergestory:end -->';
|
|
12
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** A small WebVTT reader, used to put captions into a local watch page. */
|
|
2
|
+
import type { CaptionCue } from '../core/types.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Read the cues of a WebVTT file. Identifiers and cue settings are ignored, and blocks that
|
|
5
|
+
* are not cues (header, notes, styles) or are malformed are skipped. The text is returned as it was
|
|
6
|
+
* before toWebVtt escaped it, so the cues of a file that MergeStory wrote read the same as the
|
|
7
|
+
* cues that were written.
|
|
8
|
+
*/
|
|
9
|
+
export declare function parseVtt(source: string, maxCues?: number): CaptionCue[];
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const TIMING = /^\s*((?:\d{1,3}:)?\d{1,2}:\d{2}[.,]\d{1,3})\s+-->\s+((?:\d{1,3}:)?\d{1,2}:\d{2}[.,]\d{1,3})(?:\s|$)/;
|
|
2
|
+
function toSeconds(stamp) {
|
|
3
|
+
const parts = stamp.replace(',', '.').split(':').map(Number);
|
|
4
|
+
const [seconds = 0, minutes = 0, hours = 0] = parts.reverse();
|
|
5
|
+
return hours * 3600 + minutes * 60 + seconds;
|
|
6
|
+
}
|
|
7
|
+
const ENTITIES = { amp: '&', lt: '<', gt: '>' };
|
|
8
|
+
/** Undo the escaping that toWebVtt does (&, < and >), in one pass so that "&lt;" gives "<". */
|
|
9
|
+
function unescapeCueText(text) {
|
|
10
|
+
return text.replace(/&(amp|lt|gt);/g, (_, name) => ENTITIES[name] ?? '');
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Read the cues of a WebVTT file. Identifiers and cue settings are ignored, and blocks that
|
|
14
|
+
* are not cues (header, notes, styles) or are malformed are skipped. The text is returned as it was
|
|
15
|
+
* before toWebVtt escaped it, so the cues of a file that MergeStory wrote read the same as the
|
|
16
|
+
* cues that were written.
|
|
17
|
+
*/
|
|
18
|
+
export function parseVtt(source, maxCues = 2000) {
|
|
19
|
+
const cues = [];
|
|
20
|
+
for (const block of source.replace(/\r\n?/g, '\n').split(/\n{2,}/)) {
|
|
21
|
+
const lines = block.split('\n');
|
|
22
|
+
// A cue may start with one identifier line before its timing line.
|
|
23
|
+
const at = lines.findIndex((line) => line.includes('-->'));
|
|
24
|
+
if (at < 0 || at > 1)
|
|
25
|
+
continue;
|
|
26
|
+
const timing = TIMING.exec(lines[at] ?? '');
|
|
27
|
+
if (!timing?.[1] || !timing[2])
|
|
28
|
+
continue;
|
|
29
|
+
const text = unescapeCueText(lines
|
|
30
|
+
.slice(at + 1)
|
|
31
|
+
.join('\n')
|
|
32
|
+
.trim());
|
|
33
|
+
const startSec = toSeconds(timing[1]);
|
|
34
|
+
const endSec = toSeconds(timing[2]);
|
|
35
|
+
if (!text || !(endSec > startSec))
|
|
36
|
+
continue;
|
|
37
|
+
cues.push({ startSec, endSec, text });
|
|
38
|
+
if (cues.length >= maxCues)
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
return cues;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=vtt.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { AssetUrls } from '../core/providers.ts';
|
|
2
|
+
import type { WatchPageData } from './types.ts';
|
|
3
|
+
/** Self-contained HTML page: no external scripts, fonts or trackers; all text escaped. */
|
|
4
|
+
export declare function buildWatchPage(data: WatchPageData, urls: AssetUrls): string;
|