@myrialabs/clopen 0.4.50 → 0.4.51
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/README.md +2 -1
- package/backend/chat/attachments.test.ts +106 -17
- package/backend/chat/attachments.ts +131 -34
- package/backend/chat/engine-handoff.ts +42 -6
- package/backend/chat/stream-manager.ts +41 -5
- package/backend/containers/actions.ts +22 -0
- package/backend/control/actions/projects.ts +93 -37
- package/backend/control/folders.test.ts +27 -2
- package/backend/control/index.ts +2 -1
- package/backend/database/migrations/056_support_mssql_driver.ts +7 -0
- package/backend/database/migrations/077_create_integration_db_links.ts +7 -0
- package/backend/database/migrations/086_single_owner.ts +66 -73
- package/backend/database/migrations/090_create_storage_tables.ts +83 -0
- package/backend/database/migrations/index.ts +11 -2
- package/backend/database/queries/integration-queries.ts +10 -0
- package/backend/database/queries/memory-queue-queries.ts +11 -0
- package/backend/database/queries/project-queries.ts +6 -0
- package/backend/database/queries/session-queries.ts +3 -0
- package/backend/database/utils/migration-runner.test.ts +196 -0
- package/backend/database/utils/migration-runner.ts +61 -16
- package/backend/database/utils/seeder-runner.ts +22 -16
- package/backend/engine/adapters/claude/stream.ts +5 -0
- package/backend/engine/adapters/cursor/environment.ts +1 -1
- package/backend/engine/adapters/qwen/session-store.ts +10 -1
- package/backend/engine/types.ts +7 -0
- package/backend/git/identity/cli.ts +35 -0
- package/backend/git/identity/env.test.ts +52 -1
- package/backend/git/identity/env.ts +69 -10
- package/backend/git/identity/index.ts +25 -6
- package/backend/git/identity/resolve.ts +2 -1
- package/backend/git/identity/scope-config.ts +13 -7
- package/backend/git-hosts/accounts.ts +106 -0
- package/backend/git-hosts/auth/client-ids.ts +34 -0
- package/backend/git-hosts/auth/connect.ts +110 -0
- package/backend/git-hosts/auth/endpoints.ts +130 -0
- package/backend/git-hosts/auth/flows.ts +355 -0
- package/backend/git-hosts/auth/local.ts +152 -0
- package/backend/git-hosts/ci.ts +18 -0
- package/backend/git-hosts/cli.test.ts +82 -0
- package/backend/git-hosts/cli.ts +342 -0
- package/backend/git-hosts/credentials.ts +173 -0
- package/backend/git-hosts/git-credential.ts +30 -0
- package/backend/git-hosts/health.ts +39 -0
- package/backend/git-hosts/http.ts +174 -0
- package/backend/git-hosts/index.ts +34 -0
- package/backend/git-hosts/providers/bitbucket.ts +186 -0
- package/backend/git-hosts/providers/gitea.ts +208 -0
- package/backend/git-hosts/providers/github.ts +270 -0
- package/backend/git-hosts/providers/gitlab-client.ts +70 -0
- package/backend/git-hosts/providers/gitlab.ts +285 -0
- package/backend/git-hosts/providers/locators.test.ts +68 -0
- package/backend/git-hosts/registry.ts +50 -0
- package/backend/git-hosts/service.ts +432 -0
- package/backend/git-hosts/types.ts +82 -0
- package/backend/git-hosts/urls.test.ts +42 -0
- package/backend/git-hosts/urls.ts +69 -0
- package/backend/index.ts +50 -10
- package/backend/integrations/accounts.ts +50 -3
- package/backend/integrations/registry/define.ts +9 -0
- package/backend/integrations/registry/index.ts +11 -0
- package/backend/integrations/registry/providers/bitbucket.ts +51 -0
- package/backend/integrations/registry/providers/gitea.ts +53 -0
- package/backend/integrations/registry/providers/github.ts +24 -7
- package/backend/integrations/registry/providers/gitlab.ts +57 -0
- package/backend/integrations/registry/types.ts +13 -1
- package/backend/mcp/internal/servers/browser-automation/actions/inspect.ts +115 -31
- package/backend/mcp/internal/servers/browser-automation/description.ts +5 -0
- package/backend/mentions/diff.ts +63 -0
- package/backend/mentions/index.ts +109 -0
- package/backend/mentions/mentions.test.ts +27 -0
- package/backend/mentions/shared.ts +82 -0
- package/backend/mentions/sources/ai-changes.ts +140 -0
- package/backend/mentions/sources/chats.ts +122 -0
- package/backend/mentions/sources/database.ts +211 -0
- package/backend/mentions/sources/files.ts +240 -0
- package/backend/mentions/sources/git.ts +308 -0
- package/backend/mentions/sources/notes-memory.ts +121 -0
- package/backend/mentions/sources/ops.ts +125 -0
- package/backend/mentions/sources/preview.ts +153 -0
- package/backend/mentions/sources/projects.ts +114 -0
- package/backend/mentions/sources/system.ts +135 -0
- package/backend/mentions/sources/terminal.ts +50 -0
- package/backend/mentions/types.ts +75 -0
- package/backend/preview/browser/bot-check-frames.test.ts +49 -0
- package/backend/preview/browser/bot-check-frames.ts +66 -0
- package/backend/preview/browser/browser-dialog-handler.ts +6 -5
- package/backend/preview/browser/browser-host-bridge.ts +4 -2
- package/backend/preview/browser/browser-native-ui-handler.ts +21 -0
- package/backend/preview/browser/browser-pool.ts +26 -17
- package/backend/preview/browser/browser-preview-service.ts +164 -2
- package/backend/preview/browser/browser-screenshot.test.ts +113 -0
- package/backend/preview/browser/browser-screenshot.ts +396 -0
- package/backend/preview/browser/browser-tab-manager.ts +35 -186
- package/backend/preview/browser/browser-video-capture.ts +12 -17
- package/backend/preview/browser/element-describe.ts +125 -0
- package/backend/preview/browser/page-binding.ts +141 -0
- package/backend/preview/browser/screenshot-files.test.ts +117 -0
- package/backend/preview/browser/screenshot-files.ts +134 -0
- package/backend/preview/browser/user-agent.test.ts +25 -0
- package/backend/preview/browser/user-agent.ts +100 -0
- package/backend/projects/engine-transcripts.ts +153 -0
- package/backend/projects/folder-guard.ts +55 -0
- package/backend/projects/move.test.ts +208 -0
- package/backend/projects/move.ts +277 -0
- package/backend/projects/project-cleanup.integration.test.ts +3 -1
- package/backend/projects/project-cleanup.ts +10 -0
- package/backend/storage/actions.ts +260 -0
- package/backend/storage/chats.test.ts +57 -0
- package/backend/storage/chats.ts +170 -0
- package/backend/storage/database.ts +105 -0
- package/backend/storage/engine-homes.ts +145 -0
- package/backend/storage/fs-size.ts +111 -0
- package/backend/storage/history.ts +39 -0
- package/backend/storage/policy.ts +156 -0
- package/backend/storage/preview-profiles.ts +169 -0
- package/backend/storage/purge.ts +158 -0
- package/backend/storage/scanner.ts +339 -0
- package/backend/storage/session-index.ts +208 -0
- package/backend/storage/snapshots.ts +99 -0
- package/backend/storage/storage-flow.test.ts +137 -0
- package/backend/storage/transcripts/aliases.ts +75 -0
- package/backend/storage/transcripts/claude-dedupe.test.ts +101 -0
- package/backend/storage/transcripts/claude-dedupe.ts +152 -0
- package/backend/storage/transcripts/claude.ts +155 -0
- package/backend/storage/transcripts/cursor.ts +165 -0
- package/backend/storage/transcripts/file-stores.ts +224 -0
- package/backend/storage/transcripts/index.ts +207 -0
- package/backend/storage/transcripts/opencode.ts +124 -0
- package/backend/storage/transcripts/references.ts +42 -0
- package/backend/storage/transcripts/types.ts +58 -0
- package/backend/storage/worktrees.ts +114 -0
- package/backend/terminal/ptykit.ts +25 -0
- package/backend/update/registry.ts +24 -0
- package/backend/update/release-notes.test.ts +110 -0
- package/backend/update/release-notes.ts +132 -0
- package/backend/update/restart.ts +159 -0
- package/backend/utils/env.test.ts +64 -0
- package/backend/utils/env.ts +23 -55
- package/backend/utils/port-utils.ts +13 -0
- package/backend/work/index.ts +13 -2
- package/backend/work/providers/github/actions-logs.ts +1 -1
- package/backend/work/providers/github/adapter.ts +32 -1
- package/backend/work/providers/github/client.ts +7 -3
- package/backend/work/providers/gitlab/adapter.ts +770 -0
- package/backend/work/providers/gitlab/system-notes.test.ts +24 -0
- package/backend/work/service.ts +60 -36
- package/backend/work/start-work.ts +1 -1
- package/backend/work/types.ts +4 -0
- package/backend/worktrees/index.ts +1 -0
- package/backend/worktrees/service.ts +23 -2
- package/backend/ws/chat/composer.ts +47 -6
- package/backend/ws/files/search.ts +1 -1
- package/backend/ws/files/write.ts +27 -0
- package/backend/ws/hosting/index.ts +231 -0
- package/backend/ws/index.ts +12 -2
- package/backend/ws/integrations/crud.ts +31 -5
- package/backend/ws/integrations/hosting-auth.ts +227 -0
- package/backend/ws/integrations/index.ts +2 -0
- package/backend/ws/mentions/index.ts +81 -0
- package/backend/ws/preview/browser/screenshot.ts +184 -0
- package/backend/ws/preview/index.ts +23 -0
- package/backend/ws/projects/crud.ts +66 -58
- package/backend/ws/sessions/crud.ts +7 -95
- package/backend/ws/snapshot/changes.ts +3 -3
- package/backend/ws/storage/index.ts +102 -0
- package/backend/ws/system/index.ts +7 -0
- package/backend/ws/system/operations.ts +125 -69
- package/backend/ws/work/context.ts +3 -4
- package/backend/ws/work/crud.ts +33 -0
- package/backend/ws/work/schemas.ts +4 -1
- package/bin/clopen.ts +15 -16
- package/dist/assets/{index-By6KdSLT.js → index-B9rHDvjg.js} +1 -1
- package/dist/assets/index-B9rHDvjg.js.br +0 -0
- package/dist/assets/index-B9rHDvjg.js.gz +0 -0
- package/dist/assets/{index-DV4TiDn1.js → index-DFlwOd7k.js} +1 -1
- package/dist/assets/index-DFlwOd7k.js.br +0 -0
- package/dist/assets/index-DFlwOd7k.js.gz +0 -0
- package/dist/assets/main-Bz_brxxS.css +1 -0
- package/dist/assets/main-Bz_brxxS.css.br +0 -0
- package/dist/assets/main-Bz_brxxS.css.gz +0 -0
- package/dist/assets/main-DRcX9SHx.js +1273 -0
- package/dist/assets/main-DRcX9SHx.js.br +0 -0
- package/dist/assets/main-DRcX9SHx.js.gz +0 -0
- package/dist/assets/pdf-DfwfQPLy.js +57 -0
- package/dist/assets/pdf-DfwfQPLy.js.br +0 -0
- package/dist/assets/pdf-DfwfQPLy.js.gz +0 -0
- package/dist/assets/pdf.worker.min-B5Yc7dP4.mjs +27 -0
- package/dist/assets/pdf.worker.min-B5Yc7dP4.mjs.br +0 -0
- package/dist/assets/pdf.worker.min-B5Yc7dP4.mjs.gz +0 -0
- package/dist/assets/pdf.worker.min-BOrSNwfp.js +1 -0
- package/dist/index.html +2 -2
- package/dist/index.html.br +0 -0
- package/dist/index.html.gz +0 -0
- package/dist/vendor/pdfjs/cmaps/78-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/78-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/78-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/78-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/78-RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/78-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/78ms-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/78ms-RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/83pv-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/90ms-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/90ms-RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/90msp-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/90msp-RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/90pv-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/90pv-RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Add-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Add-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Add-RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Add-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-0.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-1.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-3.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-4.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-5.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-6.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-UCS2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-GB1-0.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-GB1-1.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-GB1-2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-GB1-3.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-GB1-4.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-GB1-5.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-GB1-UCS2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-0.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-1.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-3.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-4.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-5.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-6.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-UCS2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Korea1-0.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Korea1-1.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Korea1-2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Korea1-UCS2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/B5pc-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/B5pc-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/CNS-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/CNS-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/CNS1-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/CNS1-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/CNS2-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/CNS2-V.bcmap +3 -0
- package/dist/vendor/pdfjs/cmaps/ETHK-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/ETHK-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/ETen-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/ETen-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/ETenms-B5-H.bcmap +3 -0
- package/dist/vendor/pdfjs/cmaps/ETenms-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Ext-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Ext-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Ext-RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Ext-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GB-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GB-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GB-H.bcmap +6 -0
- package/dist/vendor/pdfjs/cmaps/GB-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBK-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBK-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBK2K-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBK2K-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBKp-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBKp-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBT-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBT-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBT-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBT-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBTpc-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBTpc-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBpc-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBpc-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKdla-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKdla-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKdlb-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKdlb-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKgccs-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKgccs-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKm314-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKm314-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKm471-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKm471-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKscs-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKscs-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Hankaku.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Hiragana.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSC-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSC-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSC-Johab-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSC-Johab-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSCms-UHC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSCms-UHC-HW-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSCms-UHC-HW-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSCms-UHC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSCpc-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSCpc-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Katakana.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/LICENSE +36 -0
- package/dist/vendor/pdfjs/cmaps/NWP-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/NWP-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Roman.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UCS2-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UCS2-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UTF16-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UTF16-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UTF32-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UTF32-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UTF8-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UTF8-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UCS2-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UCS2-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UTF16-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UTF16-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UTF32-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UTF32-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UTF8-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UTF8-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UCS2-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UCS2-HW-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UCS2-HW-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UCS2-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UTF16-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UTF16-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UTF32-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UTF32-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UTF8-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UTF8-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF16-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF16-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF32-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF32-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF8-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF8-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJISPro-UCS2-HW-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJISPro-UCS2-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJISPro-UTF8-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJISX0213-UTF32-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJISX0213-UTF32-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJISX02132004-UTF32-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJISX02132004-UTF32-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UCS2-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UCS2-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UTF16-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UTF16-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UTF32-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UTF32-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UTF8-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UTF8-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/WP-Symbol.bcmap +0 -0
- package/dist/vendor/pdfjs/iccs/CGATS001Compat-v2-micro.icc +0 -0
- package/dist/vendor/pdfjs/iccs/LICENSE +116 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitDingbats.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitFixed.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitFixedBold.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitFixedBoldItalic.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitFixedItalic.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitSerif.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitSerifBold.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitSerifBoldItalic.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitSerifItalic.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitSymbol.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/LICENSE_FOXIT +27 -0
- package/dist/vendor/pdfjs/standard_fonts/LICENSE_LIBERATION +363 -0
- package/dist/vendor/pdfjs/standard_fonts/LiberationSans-Bold.ttf +0 -0
- package/dist/vendor/pdfjs/standard_fonts/LiberationSans-BoldItalic.ttf +0 -0
- package/dist/vendor/pdfjs/standard_fonts/LiberationSans-Italic.ttf +0 -0
- package/dist/vendor/pdfjs/standard_fonts/LiberationSans-Regular.ttf +0 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_JBIG2 +196 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_OPENJPEG +39 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_PDFJS_JBIG2 +13 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_PDFJS_OPENJPEG +22 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_PDFJS_QCMS +19 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_PDFJS_QUICKJS +21 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_QCMS +21 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_QUICKJS +22 -0
- package/dist/vendor/pdfjs/wasm/jbig2.wasm +0 -0
- package/dist/vendor/pdfjs/wasm/jbig2.wasm.br +0 -0
- package/dist/vendor/pdfjs/wasm/jbig2.wasm.gz +0 -0
- package/dist/vendor/pdfjs/wasm/jbig2_nowasm_fallback.js +2 -0
- package/dist/vendor/pdfjs/wasm/jbig2_nowasm_fallback.js.br +0 -0
- package/dist/vendor/pdfjs/wasm/jbig2_nowasm_fallback.js.gz +0 -0
- package/dist/vendor/pdfjs/wasm/openjpeg.wasm +0 -0
- package/dist/vendor/pdfjs/wasm/openjpeg.wasm.br +0 -0
- package/dist/vendor/pdfjs/wasm/openjpeg.wasm.gz +0 -0
- package/dist/vendor/pdfjs/wasm/openjpeg_nowasm_fallback.js +2 -0
- package/dist/vendor/pdfjs/wasm/openjpeg_nowasm_fallback.js.br +0 -0
- package/dist/vendor/pdfjs/wasm/openjpeg_nowasm_fallback.js.gz +0 -0
- package/dist/vendor/pdfjs/wasm/qcms_bg.wasm +0 -0
- package/dist/vendor/pdfjs/wasm/qcms_bg.wasm.br +0 -0
- package/dist/vendor/pdfjs/wasm/qcms_bg.wasm.gz +0 -0
- package/dist/vendor/pdfjs/wasm/quickjs-eval.js +16 -0
- package/dist/vendor/pdfjs/wasm/quickjs-eval.js.br +0 -0
- package/dist/vendor/pdfjs/wasm/quickjs-eval.js.gz +0 -0
- package/dist/vendor/pdfjs/wasm/quickjs-eval.wasm +0 -0
- package/dist/vendor/pdfjs/wasm/quickjs-eval.wasm.br +0 -0
- package/dist/vendor/pdfjs/wasm/quickjs-eval.wasm.gz +0 -0
- package/package.json +6 -7
- package/scripts/start.ts +21 -4
- package/shared/constants/binary-extensions.ts +20 -4
- package/shared/constants/support.test.ts +27 -0
- package/shared/constants/support.ts +79 -0
- package/shared/constants/tool-icons.ts +7 -1
- package/shared/types/database/schema.ts +6 -0
- package/shared/types/git-hosting.ts +241 -0
- package/shared/types/integrations.ts +51 -1
- package/shared/types/mentions.ts +96 -0
- package/shared/types/release-notes.ts +31 -0
- package/shared/types/storage.ts +175 -0
- package/shared/types/stores/settings.ts +16 -0
- package/shared/types/unified/index.ts +1 -0
- package/shared/types/unified/message.ts +26 -1
- package/shared/types/unified/tool.ts +4 -0
- package/shared/types/work.ts +6 -0
- package/shared/utils/attachment-mentions.test.ts +39 -0
- package/shared/utils/attachment-mentions.ts +100 -0
- package/shared/utils/context-document.test.ts +53 -0
- package/shared/utils/context-document.ts +226 -0
- package/shared/utils/device-frame.test.ts +73 -0
- package/shared/utils/device-frame.ts +320 -0
- package/shared/utils/fuzzy.ts +79 -0
- package/shared/utils/launcher-fingerprint.test.ts +73 -0
- package/shared/utils/launcher-fingerprint.ts +108 -0
- package/shared/utils/logger.ts +2 -0
- package/shared/utils/page-colors.test.ts +17 -0
- package/shared/utils/page-colors.ts +24 -0
- package/shared/utils/process-supervisor.test.ts +18 -1
- package/shared/utils/process-supervisor.ts +12 -23
- package/shared/utils/restart-intent.test.ts +57 -0
- package/shared/utils/restart-intent.ts +80 -0
- package/shared/utils/semver.test.ts +33 -0
- package/shared/utils/semver.ts +35 -0
- package/shared/utils/supervised-child.ts +44 -0
- package/shared/utils/supervisor-protocol.ts +20 -0
- package/.env.example +0 -9
- package/dist/assets/index-By6KdSLT.js.br +0 -0
- package/dist/assets/index-By6KdSLT.js.gz +0 -0
- package/dist/assets/index-DV4TiDn1.js.br +0 -0
- package/dist/assets/index-DV4TiDn1.js.gz +0 -0
- package/dist/assets/main-DIESTGTD.css +0 -1
- package/dist/assets/main-DIESTGTD.css.br +0 -0
- package/dist/assets/main-DIESTGTD.css.gz +0 -0
- package/dist/assets/main-Da3JKoua.js +0 -1240
- package/dist/assets/main-Da3JKoua.js.br +0 -0
- package/dist/assets/main-Da3JKoua.js.gz +0 -0
|
@@ -42,6 +42,8 @@ import { DEFAULT_STREAMING_CONFIG, resolveCodecCandidates } from './types';
|
|
|
42
42
|
import { videoEncoderScript } from './scripts/video-stream';
|
|
43
43
|
import { audioCaptureScript } from './scripts/audio-stream';
|
|
44
44
|
import { applyViewport } from './viewport';
|
|
45
|
+
import { outsideBotChecks } from './bot-check-frames';
|
|
46
|
+
import { exposeBinding } from './page-binding';
|
|
45
47
|
|
|
46
48
|
/**
|
|
47
49
|
* Install the audio tap in every frame.
|
|
@@ -50,7 +52,8 @@ import { applyViewport } from './viewport';
|
|
|
50
52
|
* inside an iframe — an embedded player, anything served from a CDN origin —
|
|
51
53
|
* was never tapped and the preview played silently. The script's own
|
|
52
54
|
* idempotency guard makes the repeat injections harmless, and it relays its
|
|
53
|
-
* encoded chunks up to the top frame's DataChannel.
|
|
55
|
+
* encoded chunks up to the top frame's DataChannel. Bot-check frames are
|
|
56
|
+
* skipped, as everywhere else — see `bot-check-frames.ts`.
|
|
54
57
|
*/
|
|
55
58
|
async function injectAudioCaptureIntoAllFrames(
|
|
56
59
|
page: Page,
|
|
@@ -59,7 +62,7 @@ async function injectAudioCaptureIntoAllFrames(
|
|
|
59
62
|
await Promise.all(
|
|
60
63
|
page.frames().map(async (frame) => {
|
|
61
64
|
try {
|
|
62
|
-
await frame.evaluate(audioCaptureScript, audioConfig);
|
|
65
|
+
await frame.evaluate(outsideBotChecks(audioCaptureScript, audioConfig));
|
|
63
66
|
} catch {
|
|
64
67
|
// Detached or navigating; the on-new-document copy covers it.
|
|
65
68
|
}
|
|
@@ -878,25 +881,17 @@ export class BrowserVideoCapture extends EventEmitter {
|
|
|
878
881
|
*
|
|
879
882
|
* Whether they are already installed is remembered here rather than probed
|
|
880
883
|
* from the page. `typeof window.__sendIceCandidate === 'function'` describes
|
|
881
|
-
* the *current document*, and
|
|
882
|
-
*
|
|
883
|
-
*
|
|
884
|
-
*
|
|
885
|
-
*
|
|
884
|
+
* the *current document*, and bindings are re-installed on each new one —
|
|
885
|
+
* so mid-navigation the probe says "absent" while the binding is in fact
|
|
886
|
+
* registered. Puppeteer's `exposeFunction` threw on that, which took out the
|
|
887
|
+
* whole handshake; `exposeBinding` just swaps the handler, but probing the
|
|
888
|
+
* page would still answer the wrong question.
|
|
886
889
|
*/
|
|
887
890
|
private async exposeBindings(sessionId: string, page: Page): Promise<void> {
|
|
888
891
|
const state = this.injectionState(sessionId);
|
|
889
892
|
if (state.bindingsExposed) return;
|
|
890
893
|
|
|
891
|
-
|
|
892
|
-
const expose = async (name: string, fn: (...args: any[]) => void) => {
|
|
893
|
-
try {
|
|
894
|
-
await page.exposeFunction(name, fn);
|
|
895
|
-
} catch (error) {
|
|
896
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
897
|
-
if (!message.includes('already exists')) throw error;
|
|
898
|
-
}
|
|
899
|
-
};
|
|
894
|
+
const expose = (name: string, fn: (...args: any[]) => void) => exposeBinding(page, name, fn);
|
|
900
895
|
|
|
901
896
|
await expose('__sendIceCandidate', (viewerId: string, candidate: RTCIceCandidateInit) => {
|
|
902
897
|
this.emit('ice-candidate', { sessionId, viewerId, candidate, from: 'headless' });
|
|
@@ -982,7 +977,7 @@ export class BrowserVideoCapture extends EventEmitter {
|
|
|
982
977
|
// after enough switches each page load ran a stack of them, and the only
|
|
983
978
|
// cure was restarting the server.
|
|
984
979
|
if (!state.audioScriptId) {
|
|
985
|
-
const registered = await page.evaluateOnNewDocument(audioCaptureScript, audioConfig);
|
|
980
|
+
const registered = await page.evaluateOnNewDocument(outsideBotChecks(audioCaptureScript, audioConfig));
|
|
986
981
|
state.audioScriptId = (registered as { identifier?: string })?.identifier ?? 'registered';
|
|
987
982
|
}
|
|
988
983
|
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Everything worth telling a model about one element of a preview page.
|
|
3
|
+
*
|
|
4
|
+
* The element is found the way the screenshot picker finds it — under a
|
|
5
|
+
* viewport point, `depth` ancestors up — so what the user highlighted is what
|
|
6
|
+
* is described. Runs in a single round trip into the page.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { Page } from 'puppeteer';
|
|
10
|
+
|
|
11
|
+
export interface DescribedElement {
|
|
12
|
+
tag: string;
|
|
13
|
+
/** A selector that matches this element, unique on the page when one could be built. */
|
|
14
|
+
selector: string;
|
|
15
|
+
/** `tag#id.class` of each ancestor, outermost first. */
|
|
16
|
+
ancestors: string[];
|
|
17
|
+
attributes: Record<string, string>;
|
|
18
|
+
text: string;
|
|
19
|
+
html: string;
|
|
20
|
+
htmlTruncated: boolean;
|
|
21
|
+
rect: { x: number; y: number; width: number; height: number };
|
|
22
|
+
styles: Record<string, string>;
|
|
23
|
+
url: string;
|
|
24
|
+
title: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Largest outerHTML carried; a whole app's root element can be megabytes. */
|
|
28
|
+
const MAX_HTML = 200_000;
|
|
29
|
+
const MAX_TEXT = 20_000;
|
|
30
|
+
|
|
31
|
+
/** Computed styles that explain how an element looks and is laid out. */
|
|
32
|
+
const STYLE_PROPERTIES = [
|
|
33
|
+
'display', 'position', 'top', 'right', 'bottom', 'left', 'z-index',
|
|
34
|
+
'width', 'height', 'min-width', 'max-width', 'min-height', 'max-height',
|
|
35
|
+
'margin', 'padding', 'box-sizing', 'overflow',
|
|
36
|
+
'flex-direction', 'flex-wrap', 'justify-content', 'align-items', 'align-self', 'gap', 'flex',
|
|
37
|
+
'grid-template-columns', 'grid-template-rows',
|
|
38
|
+
'color', 'background-color', 'background-image', 'opacity',
|
|
39
|
+
'font-family', 'font-size', 'font-weight', 'line-height', 'letter-spacing', 'text-align', 'white-space',
|
|
40
|
+
'border', 'border-radius', 'box-shadow', 'outline',
|
|
41
|
+
'cursor', 'pointer-events', 'visibility', 'transform', 'transition'
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
export async function describeElementAt(page: Page, x: number, y: number, depth = 0): Promise<DescribedElement | null> {
|
|
45
|
+
return page.evaluate(
|
|
46
|
+
(input: { x: number; y: number; depth: number; maxHtml: number; maxText: number; properties: string[] }) => {
|
|
47
|
+
let element = document.elementFromPoint(input.x, input.y);
|
|
48
|
+
if (!element) return null;
|
|
49
|
+
for (let reached = 0; reached < input.depth && element.parentElement; reached++) element = element.parentElement;
|
|
50
|
+
|
|
51
|
+
const label = (el: Element) => {
|
|
52
|
+
const classes = Array.from(el.classList).slice(0, 3);
|
|
53
|
+
return el.tagName.toLowerCase() + (el.id ? `#${el.id}` : '') + (classes.length ? `.${classes.join('.')}` : '');
|
|
54
|
+
};
|
|
55
|
+
const escape = (value: string) => (window.CSS && CSS.escape ? CSS.escape(value) : value.replace(/[^\w-]/g, '\\$&'));
|
|
56
|
+
const unique = (selector: string) => {
|
|
57
|
+
try {
|
|
58
|
+
return document.querySelectorAll(selector).length === 1;
|
|
59
|
+
} catch {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// Shortest path of steps from the nearest id (or the root) that
|
|
65
|
+
// matches only this element.
|
|
66
|
+
const selectorFor = (target: Element): string => {
|
|
67
|
+
if (target.id && unique(`#${escape(target.id)}`)) return `#${escape(target.id)}`;
|
|
68
|
+
const steps: string[] = [];
|
|
69
|
+
let node: Element | null = target;
|
|
70
|
+
while (node && node !== document.documentElement) {
|
|
71
|
+
let step = node.tagName.toLowerCase();
|
|
72
|
+
if (node.id && unique(`#${escape(node.id)}`)) {
|
|
73
|
+
steps.unshift(`#${escape(node.id)}`);
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
const stable = Array.from(node.classList).filter((name) => !/\d{3,}|^svelte-|^css-|^_/.test(name)).slice(0, 2);
|
|
77
|
+
if (stable.length) step += stable.map((name) => `.${escape(name)}`).join('');
|
|
78
|
+
const parent: Element | null = node.parentElement;
|
|
79
|
+
if (parent) {
|
|
80
|
+
const same = Array.from(parent.children).filter((child) => child.tagName === node!.tagName);
|
|
81
|
+
if (same.length > 1) step += `:nth-of-type(${same.indexOf(node) + 1})`;
|
|
82
|
+
}
|
|
83
|
+
steps.unshift(step);
|
|
84
|
+
const candidate = steps.join(' > ');
|
|
85
|
+
if (unique(candidate)) return candidate;
|
|
86
|
+
node = parent;
|
|
87
|
+
}
|
|
88
|
+
return steps.join(' > ');
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const ancestors: string[] = [];
|
|
92
|
+
for (let node = element.parentElement; node && node !== document.documentElement; node = node.parentElement) {
|
|
93
|
+
ancestors.unshift(label(node));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const attributes: Record<string, string> = {};
|
|
97
|
+
for (const attribute of Array.from(element.attributes)) attributes[attribute.name] = attribute.value.slice(0, 2000);
|
|
98
|
+
|
|
99
|
+
const computed = window.getComputedStyle(element);
|
|
100
|
+
const styles: Record<string, string> = {};
|
|
101
|
+
for (const property of input.properties) {
|
|
102
|
+
const value = computed.getPropertyValue(property);
|
|
103
|
+
if (value && value !== 'none' && value !== 'normal' && value !== 'auto' && value !== '0px') styles[property] = value;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const html = element.outerHTML;
|
|
107
|
+
const text = ((element as HTMLElement).innerText ?? element.textContent ?? '').trim();
|
|
108
|
+
const box = element.getBoundingClientRect();
|
|
109
|
+
return {
|
|
110
|
+
tag: element.tagName.toLowerCase(),
|
|
111
|
+
selector: selectorFor(element),
|
|
112
|
+
ancestors,
|
|
113
|
+
attributes,
|
|
114
|
+
text: text.slice(0, input.maxText),
|
|
115
|
+
html: html.slice(0, input.maxHtml),
|
|
116
|
+
htmlTruncated: html.length > input.maxHtml,
|
|
117
|
+
rect: { x: Math.round(box.left), y: Math.round(box.top), width: Math.round(box.width), height: Math.round(box.height) },
|
|
118
|
+
styles,
|
|
119
|
+
url: location.href,
|
|
120
|
+
title: document.title
|
|
121
|
+
};
|
|
122
|
+
},
|
|
123
|
+
{ x, y, depth: Math.max(0, Math.floor(depth)), maxHtml: MAX_HTML, maxText: MAX_TEXT, properties: STYLE_PROPERTIES }
|
|
124
|
+
);
|
|
125
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Page → server function calls, without Puppeteer's `exposeFunction`.
|
|
3
|
+
*
|
|
4
|
+
* `exposeFunction` installs its binding and a script wrapper in every frame of
|
|
5
|
+
* the page, cross-origin iframes included. Cloudflare's challenge runs in one
|
|
6
|
+
* of those iframes, sees them, and fails the check — on a challenge page the
|
|
7
|
+
* user then ticks "Verify you are human" and lands back on the same page,
|
|
8
|
+
* indefinitely. A binding added straight over CDP, on the page's own target,
|
|
9
|
+
* reaches the main frame and its same-process iframes and nothing else, which
|
|
10
|
+
* is all Clopen's in-page scripts need: cross-origin frames already relay
|
|
11
|
+
* through the top frame.
|
|
12
|
+
*
|
|
13
|
+
* The page sees `window[name](...args)` returning a promise of the handler's
|
|
14
|
+
* result, exactly as with `exposeFunction`.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import type { CDPSession, Page, Protocol } from 'puppeteer';
|
|
18
|
+
import { debug } from '$shared/utils/logger';
|
|
19
|
+
|
|
20
|
+
type Handler = (...args: any[]) => unknown;
|
|
21
|
+
|
|
22
|
+
interface PageBindings {
|
|
23
|
+
session: CDPSession;
|
|
24
|
+
handlers: Map<string, Handler>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const pages = new WeakMap<Page, Promise<PageBindings>>();
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Replaces Chrome's binding (which takes one string and returns nothing) with
|
|
31
|
+
* a function that takes any JSON arguments and resolves with the reply. The
|
|
32
|
+
* reply comes back through a non-enumerable property, so the page's own key
|
|
33
|
+
* listing shows one function and nothing else.
|
|
34
|
+
*/
|
|
35
|
+
function installWrapper(name: string): void {
|
|
36
|
+
const scope = globalThis as unknown as Record<string, unknown>;
|
|
37
|
+
const send = scope[name] as ((payload: string) => void) | undefined;
|
|
38
|
+
if (typeof send !== 'function' || (send as { __wrapped?: boolean }).__wrapped) return;
|
|
39
|
+
|
|
40
|
+
const pending = new Map<number, { resolve: (value: unknown) => void; reject: (error: Error) => void }>();
|
|
41
|
+
let seq = 0;
|
|
42
|
+
|
|
43
|
+
const call = function (...args: unknown[]): Promise<unknown> {
|
|
44
|
+
seq += 1;
|
|
45
|
+
const id = seq;
|
|
46
|
+
return new Promise((resolve, reject) => {
|
|
47
|
+
pending.set(id, { resolve, reject });
|
|
48
|
+
send(JSON.stringify({ id, args }));
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
Object.defineProperty(call, 'name', { value: name });
|
|
52
|
+
Object.defineProperty(call, '__wrapped', { value: true });
|
|
53
|
+
Object.defineProperty(call, '__reply', {
|
|
54
|
+
value(id: number, ok: boolean, value: unknown) {
|
|
55
|
+
const waiter = pending.get(id);
|
|
56
|
+
if (!waiter) return;
|
|
57
|
+
pending.delete(id);
|
|
58
|
+
if (ok) waiter.resolve(value);
|
|
59
|
+
else waiter.reject(new Error(String(value)));
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
scope[name] = call;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async function bindingsFor(page: Page): Promise<PageBindings> {
|
|
66
|
+
let entry = pages.get(page);
|
|
67
|
+
if (!entry) {
|
|
68
|
+
entry = (async () => {
|
|
69
|
+
const session = await page.createCDPSession();
|
|
70
|
+
const handlers = new Map<string, Handler>();
|
|
71
|
+
session.on('Runtime.bindingCalled', (event: Protocol.Runtime.BindingCalledEvent) => {
|
|
72
|
+
const handler = handlers.get(event.name);
|
|
73
|
+
if (handler) void answer(session, handler, event);
|
|
74
|
+
});
|
|
75
|
+
// New-document scripts only run for a session with the Page domain on.
|
|
76
|
+
await session.send('Page.enable');
|
|
77
|
+
await session.send('Runtime.enable');
|
|
78
|
+
return { session, handlers };
|
|
79
|
+
})();
|
|
80
|
+
pages.set(page, entry);
|
|
81
|
+
// A failed setup is not remembered, so the next call tries again.
|
|
82
|
+
entry.catch(() => pages.delete(page));
|
|
83
|
+
}
|
|
84
|
+
return entry;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async function answer(
|
|
88
|
+
session: CDPSession,
|
|
89
|
+
handler: Handler,
|
|
90
|
+
event: Protocol.Runtime.BindingCalledEvent
|
|
91
|
+
): Promise<void> {
|
|
92
|
+
let id: number;
|
|
93
|
+
let args: unknown[];
|
|
94
|
+
try {
|
|
95
|
+
({ id, args } = JSON.parse(event.payload) as { id: number; args: unknown[] });
|
|
96
|
+
} catch {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
let ok = true;
|
|
101
|
+
let value: unknown;
|
|
102
|
+
try {
|
|
103
|
+
value = await handler(...args);
|
|
104
|
+
} catch (error) {
|
|
105
|
+
ok = false;
|
|
106
|
+
value = error instanceof Error ? error.message : String(error);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
try {
|
|
110
|
+
await session.send('Runtime.callFunctionOn', {
|
|
111
|
+
functionDeclaration: `function (name, id, ok, value) {
|
|
112
|
+
const fn = globalThis[name];
|
|
113
|
+
if (fn && fn.__reply) fn.__reply(id, ok, value);
|
|
114
|
+
}`,
|
|
115
|
+
executionContextId: event.executionContextId,
|
|
116
|
+
arguments: [{ value: event.name }, { value: id }, { value: ok }, { value: value ?? null }]
|
|
117
|
+
});
|
|
118
|
+
} catch {
|
|
119
|
+
// The document that asked has gone — a navigation or a closed tab.
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Make `window[name]` call `handler` on the server, in the page's current
|
|
125
|
+
* document and every one after it. Calling it again for a name already bound
|
|
126
|
+
* on this page swaps the handler.
|
|
127
|
+
*/
|
|
128
|
+
export async function exposeBinding(page: Page, name: string, handler: Handler): Promise<void> {
|
|
129
|
+
const { session, handlers } = await bindingsFor(page);
|
|
130
|
+
const known = handlers.has(name);
|
|
131
|
+
handlers.set(name, handler);
|
|
132
|
+
if (known) return;
|
|
133
|
+
|
|
134
|
+
const wrapper = `(${installWrapper.toString()})(${JSON.stringify(name)});`;
|
|
135
|
+
await session.send('Runtime.addBinding', { name });
|
|
136
|
+
await session.send('Page.addScriptToEvaluateOnNewDocument', { source: wrapper });
|
|
137
|
+
// The document already loaded never runs new-document scripts.
|
|
138
|
+
await session.send('Runtime.evaluate', { expression: wrapper }).catch((error: unknown) => {
|
|
139
|
+
debug.warn('preview', `⚠️ Binding ${name} not wrapped in the current document:`, error);
|
|
140
|
+
});
|
|
141
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
|
2
|
+
import { mkdtemp, readFile, realpath, rm, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { tmpdir } from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { execGit } from '$backend/git/git-executor';
|
|
6
|
+
import {
|
|
7
|
+
ignoreScreenshotFolder,
|
|
8
|
+
normalizeScreenshotFolder,
|
|
9
|
+
sanitizeScreenshotFileName,
|
|
10
|
+
saveScreenshotFile,
|
|
11
|
+
uniqueFileName,
|
|
12
|
+
withIgnoredFolder
|
|
13
|
+
} from './screenshot-files';
|
|
14
|
+
|
|
15
|
+
const PNG = new Uint8Array([0x89, 0x50, 0x4e, 0x47]);
|
|
16
|
+
|
|
17
|
+
describe('normalizeScreenshotFolder', () => {
|
|
18
|
+
test('an empty folder is the default one', () => {
|
|
19
|
+
expect(normalizeScreenshotFolder(undefined)).toBe('screenshots');
|
|
20
|
+
expect(normalizeScreenshotFolder(' ')).toBe('screenshots');
|
|
21
|
+
expect(normalizeScreenshotFolder('./')).toBe('screenshots');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test('tidies separators and dot segments', () => {
|
|
25
|
+
expect(normalizeScreenshotFolder('docs//images/./shots/')).toBe('docs/images/shots');
|
|
26
|
+
expect(normalizeScreenshotFolder('docs\\images')).toBe('docs/images');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test('refuses anything outside the project', () => {
|
|
30
|
+
expect(() => normalizeScreenshotFolder('../elsewhere')).toThrow('inside the project');
|
|
31
|
+
expect(() => normalizeScreenshotFolder('a/../../b')).toThrow('inside the project');
|
|
32
|
+
expect(() => normalizeScreenshotFolder('/tmp/shots')).toThrow('inside the project');
|
|
33
|
+
expect(() => normalizeScreenshotFolder('C:/shots')).toThrow('inside the project');
|
|
34
|
+
expect(() => normalizeScreenshotFolder('.git/hooks')).toThrow('.git');
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
describe('sanitizeScreenshotFileName', () => {
|
|
39
|
+
test('keeps a plain name and sets the extension', () => {
|
|
40
|
+
expect(sanitizeScreenshotFileName('localhost-5173-20261126-143005', 'png')).toBe('localhost-5173-20261126-143005.png');
|
|
41
|
+
expect(sanitizeScreenshotFileName('shot.png', 'jpg')).toBe('shot.jpg');
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test('nothing in it can be read as a path', () => {
|
|
45
|
+
expect(sanitizeScreenshotFileName('../../etc/passwd', 'png')).toBe('etc-passwd.png');
|
|
46
|
+
expect(sanitizeScreenshotFileName('a:b*c?', 'png')).toBe('a-b-c-.png');
|
|
47
|
+
expect(sanitizeScreenshotFileName('...', 'png')).toBe('screenshot.png');
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
describe('withIgnoredFolder', () => {
|
|
52
|
+
test('appends a root-anchored entry, on its own line', () => {
|
|
53
|
+
expect(withIgnoredFolder('', 'screenshots')).toBe('/screenshots/\n');
|
|
54
|
+
expect(withIgnoredFolder('node_modules\n', 'screenshots')).toBe('node_modules\n/screenshots/\n');
|
|
55
|
+
expect(withIgnoredFolder('node_modules', 'screenshots')).toBe('node_modules\n/screenshots/\n');
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test('leaves a file that already covers the folder alone', () => {
|
|
59
|
+
expect(withIgnoredFolder('/screenshots/\n', 'screenshots')).toBeNull();
|
|
60
|
+
expect(withIgnoredFolder('screenshots/\n', 'screenshots')).toBeNull();
|
|
61
|
+
expect(withIgnoredFolder('dist\r\nscreenshots\r\n', 'screenshots')).toBeNull();
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
describe('saving into a workspace', () => {
|
|
66
|
+
let root: string;
|
|
67
|
+
|
|
68
|
+
async function git(...args: string[]) {
|
|
69
|
+
const result = await execGit(args, root);
|
|
70
|
+
if (result.exitCode !== 0) throw new Error(`git ${args.join(' ')}: ${result.stderr}`);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
beforeEach(async () => {
|
|
74
|
+
root = await realpath(await mkdtemp(path.join(tmpdir(), 'clopen-screenshots-')));
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
afterEach(async () => {
|
|
78
|
+
await rm(root, { recursive: true, force: true });
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
test('never overwrites an earlier screenshot', async () => {
|
|
82
|
+
const first = await saveScreenshotFile(root, 'shots', 'page', PNG, 'png');
|
|
83
|
+
const second = await saveScreenshotFile(root, 'shots', 'page', PNG, 'png');
|
|
84
|
+
expect(first.path).toBe('shots/page.png');
|
|
85
|
+
expect(second.path).toBe('shots/page-2.png');
|
|
86
|
+
expect(uniqueFileName(path.join(root, 'shots'), 'page.png')).toBe('page-3.png');
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
test('outside a repository there is nothing to warn about', async () => {
|
|
90
|
+
const saved = await saveScreenshotFile(root, undefined, 'page', PNG, 'png');
|
|
91
|
+
expect(saved).toEqual({ path: 'screenshots/page.png', folder: 'screenshots', git: 'no-repo' });
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
test('reports a file git would track, and ignoring the folder fixes it', async () => {
|
|
95
|
+
await git('init', '-b', 'main', '.');
|
|
96
|
+
|
|
97
|
+
const saved = await saveScreenshotFile(root, undefined, 'page', PNG, 'png');
|
|
98
|
+
expect(saved.git).toBe('not-ignored');
|
|
99
|
+
|
|
100
|
+
expect(await ignoreScreenshotFolder(root, saved.folder)).toBe('ignored');
|
|
101
|
+
expect(await readFile(path.join(root, '.gitignore'), 'utf8')).toBe('/screenshots/\n');
|
|
102
|
+
|
|
103
|
+
const next = await saveScreenshotFile(root, undefined, 'page', PNG, 'png');
|
|
104
|
+
expect(next.git).toBe('ignored');
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
test('a folder the project already ignores is reported as ignored', async () => {
|
|
108
|
+
await git('init', '-b', 'main', '.');
|
|
109
|
+
await writeFile(path.join(root, '.gitignore'), 'screenshots/\n');
|
|
110
|
+
|
|
111
|
+
const saved = await saveScreenshotFile(root, undefined, 'page', PNG, 'png');
|
|
112
|
+
expect(saved.git).toBe('ignored');
|
|
113
|
+
// And nothing is added on top of the rule that already covers it.
|
|
114
|
+
await ignoreScreenshotFolder(root, saved.folder);
|
|
115
|
+
expect(await readFile(path.join(root, '.gitignore'), 'utf8')).toBe('screenshots/\n');
|
|
116
|
+
});
|
|
117
|
+
});
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Saving preview screenshots into the workspace.
|
|
3
|
+
*
|
|
4
|
+
* Saving into the tree a repository tracks has one real hazard: the image
|
|
5
|
+
* gets committed by accident along with the work it was meant to illustrate.
|
|
6
|
+
* So every save reports whether git would pick the file up, and the folder can
|
|
7
|
+
* be added to `.gitignore` in one step — the choice stays the user's, but it
|
|
8
|
+
* is never made without them knowing.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { existsSync } from 'node:fs';
|
|
12
|
+
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
13
|
+
import { join, relative, sep } from 'node:path';
|
|
14
|
+
import { execGit } from '$backend/git/git-executor';
|
|
15
|
+
|
|
16
|
+
export const DEFAULT_SCREENSHOT_FOLDER = 'screenshots';
|
|
17
|
+
|
|
18
|
+
/** Whether git would pick a path up: ignored, not ignored, or no repository at all. */
|
|
19
|
+
export type GitIgnoreState = 'ignored' | 'not-ignored' | 'no-repo';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* A folder the user typed, as a clean path relative to the workspace.
|
|
23
|
+
*
|
|
24
|
+
* Lexical on purpose: the folder is meant to live in the workspace, so
|
|
25
|
+
* anything climbing out of it, or pointing elsewhere outright, is a typo to
|
|
26
|
+
* report rather than a destination to honour.
|
|
27
|
+
*/
|
|
28
|
+
export function normalizeScreenshotFolder(folder: string | undefined): string {
|
|
29
|
+
const trimmed = (folder ?? '').trim().replace(/\\/g, '/');
|
|
30
|
+
if (!trimmed) return DEFAULT_SCREENSHOT_FOLDER;
|
|
31
|
+
if (trimmed.startsWith('/') || /^[a-zA-Z]:/.test(trimmed)) {
|
|
32
|
+
throw new Error('The folder must be inside the project');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const segments = trimmed.split('/').filter((segment) => segment && segment !== '.');
|
|
36
|
+
if (segments.some((segment) => segment === '..')) throw new Error('The folder must be inside the project');
|
|
37
|
+
if (segments.length === 0) return DEFAULT_SCREENSHOT_FOLDER;
|
|
38
|
+
if (segments[0] === '.git') throw new Error('Screenshots cannot be saved inside .git');
|
|
39
|
+
|
|
40
|
+
return segments.join('/');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** A file name with nothing in it that a filesystem would refuse or read as a path. */
|
|
44
|
+
export function sanitizeScreenshotFileName(fileName: string, extension: 'png' | 'jpg'): string {
|
|
45
|
+
const stem = fileName
|
|
46
|
+
.replace(/\.(png|jpe?g)$/i, '')
|
|
47
|
+
.replace(/[\\/:*?"<>|\x00-\x1f]+/g, '-')
|
|
48
|
+
.replace(/^[.\s-]+|[.\s]+$/g, '')
|
|
49
|
+
.slice(0, 120);
|
|
50
|
+
return `${stem || 'screenshot'}.${extension}`;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** `name.png`, or `name-2.png` and so on when that is taken — a save never overwrites. */
|
|
54
|
+
export function uniqueFileName(directory: string, fileName: string): string {
|
|
55
|
+
if (!existsSync(join(directory, fileName))) return fileName;
|
|
56
|
+
|
|
57
|
+
const dot = fileName.lastIndexOf('.');
|
|
58
|
+
const stem = fileName.slice(0, dot);
|
|
59
|
+
const extension = fileName.slice(dot);
|
|
60
|
+
for (let index = 2; index < 1000; index++) {
|
|
61
|
+
const candidate = `${stem}-${index}${extension}`;
|
|
62
|
+
if (!existsSync(join(directory, candidate))) return candidate;
|
|
63
|
+
}
|
|
64
|
+
throw new Error('Too many screenshots with that name in the folder');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Whether git would track `path`, asked of git itself so every ignore source counts. */
|
|
68
|
+
export async function gitIgnoreState(root: string, path: string): Promise<GitIgnoreState> {
|
|
69
|
+
const result = await execGit(['check-ignore', '-q', '--', relative(root, path).split(sep).join('/')], root, {
|
|
70
|
+
timeout: 10_000,
|
|
71
|
+
okExitCodes: [1, 128]
|
|
72
|
+
});
|
|
73
|
+
if (result.exitCode === 0) return 'ignored';
|
|
74
|
+
if (result.exitCode === 1) return 'not-ignored';
|
|
75
|
+
return 'no-repo';
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface SavedScreenshot {
|
|
79
|
+
/** Relative to the workspace root, with forward slashes. */
|
|
80
|
+
path: string;
|
|
81
|
+
folder: string;
|
|
82
|
+
git: GitIgnoreState;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export async function saveScreenshotFile(
|
|
86
|
+
root: string,
|
|
87
|
+
folder: string | undefined,
|
|
88
|
+
fileName: string,
|
|
89
|
+
data: Uint8Array,
|
|
90
|
+
extension: 'png' | 'jpg'
|
|
91
|
+
): Promise<SavedScreenshot> {
|
|
92
|
+
const cleanFolder = normalizeScreenshotFolder(folder);
|
|
93
|
+
const directory = join(root, ...cleanFolder.split('/'));
|
|
94
|
+
await mkdir(directory, { recursive: true });
|
|
95
|
+
|
|
96
|
+
const name = uniqueFileName(directory, sanitizeScreenshotFileName(fileName, extension));
|
|
97
|
+
const absolute = join(directory, name);
|
|
98
|
+
await writeFile(absolute, data);
|
|
99
|
+
|
|
100
|
+
return {
|
|
101
|
+
path: `${cleanFolder}/${name}`,
|
|
102
|
+
folder: cleanFolder,
|
|
103
|
+
git: await gitIgnoreState(root, absolute)
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The `.gitignore` after adding a folder to it, or null when a line already
|
|
109
|
+
* covers it. Anchored to the root so a same-named folder deeper in the tree
|
|
110
|
+
* is left alone.
|
|
111
|
+
*/
|
|
112
|
+
export function withIgnoredFolder(current: string, folder: string): string | null {
|
|
113
|
+
const entry = `/${folder}/`;
|
|
114
|
+
const lines = current.split(/\r?\n/).map((line) => line.trim());
|
|
115
|
+
if (lines.some((line) => line === entry || line === `/${folder}` || line === `${folder}/` || line === folder)) {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const separator = current.length === 0 || current.endsWith('\n') ? '' : '\n';
|
|
120
|
+
return `${current}${separator}${entry}\n`;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** Add a screenshot folder to the workspace's `.gitignore`, creating it when there is none. */
|
|
124
|
+
export async function ignoreScreenshotFolder(root: string, folder: string | undefined): Promise<GitIgnoreState> {
|
|
125
|
+
const cleanFolder = normalizeScreenshotFolder(folder);
|
|
126
|
+
const gitignorePath = join(root, '.gitignore');
|
|
127
|
+
const current = existsSync(gitignorePath) ? await readFile(gitignorePath, 'utf8') : '';
|
|
128
|
+
const next = withIgnoredFolder(current, cleanFolder);
|
|
129
|
+
if (next !== null) await writeFile(gitignorePath, next);
|
|
130
|
+
|
|
131
|
+
// Re-asked rather than assumed: a negation further down, or a global rule,
|
|
132
|
+
// can still decide otherwise, and the UI has to show what git will do.
|
|
133
|
+
return gitIgnoreState(root, join(root, ...cleanFolder.split('/'), '.probe'));
|
|
134
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test';
|
|
2
|
+
import { toHeadfulUserAgent } from './user-agent';
|
|
3
|
+
|
|
4
|
+
describe('toHeadfulUserAgent', () => {
|
|
5
|
+
test('drops only the headless marker, keeping the platform and version Chrome reported', () => {
|
|
6
|
+
expect(
|
|
7
|
+
toHeadfulUserAgent(
|
|
8
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/158.0.0.0 Safari/537.36'
|
|
9
|
+
)
|
|
10
|
+
).toBe(
|
|
11
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/158.0.0.0 Safari/537.36'
|
|
12
|
+
);
|
|
13
|
+
expect(
|
|
14
|
+
toHeadfulUserAgent(
|
|
15
|
+
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/131.0.0.0 Safari/537.36'
|
|
16
|
+
)
|
|
17
|
+
).toBe('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36');
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test('leaves a headful User-Agent as it is', () => {
|
|
21
|
+
const ua =
|
|
22
|
+
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/158.0.0.0 Safari/537.36';
|
|
23
|
+
expect(toHeadfulUserAgent(ua)).toBe(ua);
|
|
24
|
+
});
|
|
25
|
+
});
|