Task 1 of Plan 04-08 (methodology reframe of ROADMAP SC #1): - Bundle 1.9 MB VP9 WebM fixture at tests/uat/fixtures/synthetic-display-source.webm (copy of internal Plan 01-07 fixture; CC0-equivalent project-owned) - Add globals.d.ts ambient `*.webm?url` module decl (mirrors Plan 01-10 `*.svg?url`) - Add manifest.json web_accessible_resources entry for `assets/*.webm` (iter-2 BLOCKER 1 — pre-decided to avoid executor improvisation; inert in production where dist/ has zero *.webm) - Rewrite installFakeDisplayMedia() at src/test-hooks/offscreen-hooks.ts: * Replace canvas.captureStream(30) with HTMLVideoElement.captureStream(30) — bypasses Chrome bug 653548 invisible-canvas throttling (debug session-2 root cause) * Function signature remains SYNCHRONOUS (`: void`; iter-2 BLOCKER 2 — eager-install contract preserved at lines 528-537) * Video element creation + DOM append + monkey-patch assignment execute synchronously * canplay wait + .play() deferred INTO fakeGetDisplayMedia closure (lazy first-frame pattern) * fakeVideoReadyPromise kicked off at install time so first call observes resolved Promise * WARNING 1 (autoplay reject): explicit error class identifier 'autoplay-blocked or codec-unsupported in headless context' * displaySurface monkey-patch preserved verbatim * A23 lastGetDisplayMediaConstraints capture preserved * uninstallFakeDisplayMedia teardown adapted for videoEl (pauses + removes + nulls) * All 6 bridge ops UNCHANGED in their sync return-false form - Add Tier-2 production-bundle filename-leak gate at tests/background/no-test-hooks-in-prod-bundle.test.ts (iter-2 WARNING 5 — synthetic-display-source string must be 0 hits in dist/) Verification: - npx tsc --noEmit: exit 0 - npm run build: dist/ produced; 0 *.webm files; 0 synthetic-display-source hits - npm run build:test: dist-test/assets/synthetic-display-source-mbtR1t3u.webm emitted (1.9 MB; Vite ?url asset) - Code-only grep (comment-filtered) on offscreen-hooks.ts: 0 canvas refs; 15 video refs - installFakeDisplayMedia signature unchanged: `: void` 2x; `: Promise` 0x; `await installFakeDisplayMedia` 0x - Architectural invariant unchanged: `let segments: Blob[] = []` at recorder.ts:91 (1 hit; grep gate enforces) - Tier-1 FORBIDDEN_HOOK_STRINGS unchanged at 12 entries - Tier-2 vitest gate PASSES: 14/14 GREEN under SKIP_BUILD=1 (12 Tier-1 + 1 build verify + 1 Tier-2) Per iter-3 checker advisory 1: the wrong-display-surface throw lives at recorder.ts:313-321 (not line 294 as plan text states; off by ~25 lines but unambiguous). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
51 lines
2.2 KiB
TypeScript
51 lines
2.2 KiB
TypeScript
// globals.d.ts — Plan 01-11 ambient declarations for Vite `define`
|
|
// text-replacement tokens.
|
|
//
|
|
// `__MOKOSH_UAT__` is a build-time boolean token replaced by Vite's
|
|
// `define` config (vite.config.ts sets it `false`, vite.test.config.ts
|
|
// overrides it to `true`). The token gates the test-hook dynamic
|
|
// imports in src/background/index.ts + src/offscreen/recorder.ts;
|
|
// production builds tree-shake the entire `if (__MOKOSH_UAT__)` block
|
|
// because Rollup recognizes `if (false)` as a static dead branch.
|
|
//
|
|
// Declaring the symbol here keeps the src/ tree type-clean under
|
|
// `npx tsc --noEmit` without spreading per-file ambient declarations.
|
|
//
|
|
// References:
|
|
// - Vite define: https://vite.dev/config/shared-options.html#define
|
|
// - TypeScript ambient declarations:
|
|
// https://www.typescriptlang.org/docs/handbook/declaration-files/templates/global-modifying-module-d-ts.html
|
|
|
|
declare const __MOKOSH_UAT__: boolean;
|
|
|
|
// Plan 01-10 must_have #9 path-A swap-in (landed 2026-05-20):
|
|
// ambient declaration for Vite `?url` asset imports. The `?url`
|
|
// suffix instructs Vite to emit the asset to `dist/assets/<hash>.<ext>`
|
|
// and replace the import with the hashed asset URL as a string at
|
|
// build time. We declare the wildcard module so TypeScript accepts
|
|
// the import without spreading per-file `vite/client` triple-slash
|
|
// directives.
|
|
//
|
|
// References:
|
|
// - Vite explicit URL imports:
|
|
// https://vite.dev/guide/assets.html#explicit-url-imports
|
|
// - TypeScript ambient module declarations:
|
|
// https://www.typescriptlang.org/docs/handbook/modules/reference.html#ambient-modules
|
|
declare module '*.svg?url' {
|
|
const url: string;
|
|
export default url;
|
|
}
|
|
|
|
// Plan 04-08 — Vite `?url` import for bundled test-only WebM fixture
|
|
// (tests/uat/fixtures/synthetic-display-source.webm). Mirrors the
|
|
// Plan 01-10 mokosh-mark.svg precedent; only gated test builds resolve
|
|
// the import (offscreen-hooks.ts is tree-shaken in production per
|
|
// `__MOKOSH_UAT__`). The hashed asset path emitted into
|
|
// `dist-test/assets/<hash>.webm` is authorized for chrome-extension://
|
|
// scheme access via the explicit `assets/*.webm` web_accessible_resources
|
|
// entry in manifest.json (also a Plan 04-08 addition).
|
|
declare module '*.webm?url' {
|
|
const url: string;
|
|
export default url;
|
|
}
|