From 8f38fcab47af9804860e46606c4f9f8dd7e13dbc Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Mon, 16 Nov 2026 05:52:33 -0800 Subject: [PATCH 1/4] chore(quest): claim quest/m2/ui-private.md Quest-Claim: 038f614df7245980 From 7575a5900fbd3d3e7a9f32ada624cdf6c87a74a7 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Mon, 16 Nov 2026 06:20:20 -0800 Subject: [PATCH 2/4] feat(js): @moq/ui is a private workspace package bundled into watch and publish @moq/ui is private and never published. @moq/watch and @moq/publish list it under devDependencies; Vite bundles its code and stylesheet, and common/package.ts emits its declarations into dist/bundled/ui and points every import at that copy. A built package that still imports an @moq package it does not depend on fails its build, and deps.ts rejects a published package depending on a private one. The support elements now export the Support base, Report, Status, and Show they are typed with, and each ./support entrypoint's Level is that same declaration. @moq/video exports rotateDimensions (was the @internal rotateVideoDimensions). Co-Authored-By: Claude Opus 5.5 --- bun.lock | 7 +-- doc/.vitepress/api/package.json | 1 - doc/lib/js/index.md | 1 - doc/setup/upgrade.md | 2 +- js/common/deps.test.ts | 13 +++++ js/common/deps.ts | 27 +++++++-- js/common/package.ts | 80 +++++++++++++++++++++++++-- js/publish/api/support-element.api.md | 28 +++++++++- js/publish/package.json | 2 +- js/publish/src/broadcast.ts | 4 +- js/publish/src/preview.ts | 2 +- js/publish/src/support/element.ts | 6 +- js/publish/src/support/index.ts | 3 +- js/publish/test-dts/support.ts | 13 +++++ js/publish/vite.config.ts | 7 ++- js/ui/MIGRATE.md | 5 -- js/ui/README.md | 35 +----------- js/ui/api/index.api.md | 30 ---------- js/ui/package.json | 14 ++--- js/ui/src/graph.ts | 4 +- js/ui/src/index.ts | 12 ++-- js/ui/src/stats.ts | 4 +- js/ui/vite.config.ts | 19 ------- js/video/api/index.api.md | 8 +++ js/video/src/index.ts | 3 +- js/video/src/presentation.test.ts | 4 +- js/video/src/presentation.ts | 10 +++- js/watch/api/support-element.api.md | 28 +++++++++- js/watch/package.json | 4 +- js/watch/src/support/element.ts | 6 +- js/watch/src/support/index.ts | 3 +- js/watch/src/video/decoder.ts | 4 +- js/watch/test-dts/support.ts | 13 +++++ js/watch/test-dts/tsconfig.json | 10 ++++ js/watch/vite.config.ts | 7 ++- quest/m2/README.md | 4 +- quest/m2/browser-packages.md | 1 - quest/m2/ui-private.md | 79 -------------------------- quest/m3/release/npm-first-publish.md | 5 +- 39 files changed, 265 insertions(+), 243 deletions(-) create mode 100644 js/publish/test-dts/support.ts delete mode 100644 js/ui/MIGRATE.md delete mode 100644 js/ui/api/index.api.md delete mode 100644 js/ui/vite.config.ts create mode 100644 js/watch/test-dts/support.ts create mode 100644 js/watch/test-dts/tsconfig.json delete mode 100644 quest/m2/ui-private.md diff --git a/bun.lock b/bun.lock index c8a86cca560..1b820a0d602 100644 --- a/bun.lock +++ b/bun.lock @@ -143,7 +143,6 @@ "@moq/room": "workspace:*", "@moq/signals": "workspace:*", "@moq/stats": "workspace:*", - "@moq/ui": "workspace:*", "@moq/video": "workspace:*", "@moq/watch": "workspace:*", "typedoc": "^0.28.20", @@ -314,12 +313,12 @@ "@moq/json": "workspace:^", "@moq/net": "workspace:^", "@moq/signals": "workspace:^", - "@moq/ui": "workspace:^", "@moq/video": "workspace:^", "mediabunny": "^1.65.2", }, "devDependencies": { "@moq/libav": "workspace:^", + "@moq/ui": "workspace:^", "@types/audioworklet": "^0.0.100", "@types/bun": "^1.4.4", "@typescript/lib-dom": "npm:@types/web@^0.0.358", @@ -402,7 +401,7 @@ }, "js/ui": { "name": "@moq/ui", - "version": "0.1.0", + "version": "0.0.0", "dependencies": { "@moq/signals": "workspace:^", }, @@ -436,12 +435,12 @@ "@moq/msf": "workspace:^", "@moq/net": "workspace:^", "@moq/signals": "workspace:^", - "@moq/ui": "workspace:^", "@moq/video": "workspace:^", "media-captions": "0.0.18", }, "devDependencies": { "@moq/libav": "workspace:^", + "@moq/ui": "workspace:^", "@types/audioworklet": "^0.0.100", "@types/bun": "^1.4.4", "@typescript/lib-dom": "npm:@types/web@^0.0.358", diff --git a/doc/.vitepress/api/package.json b/doc/.vitepress/api/package.json index edea55e42d2..cf09ee3c316 100644 --- a/doc/.vitepress/api/package.json +++ b/doc/.vitepress/api/package.json @@ -20,7 +20,6 @@ "@moq/signals": "workspace:*", "@moq/obs": "workspace:*", "@moq/stats": "workspace:*", - "@moq/ui": "workspace:*", "@moq/video": "workspace:*", "@moq/watch": "workspace:*", "typedoc": "^0.28.20", diff --git a/doc/lib/js/index.md b/doc/lib/js/index.md index 8ca0e816c82..848210a5b83 100644 --- a/doc/lib/js/index.md +++ b/doc/lib/js/index.md @@ -25,7 +25,6 @@ small examples. The [API reference](/lib/js/api/) covers every package; source l | [@moq/watch](/lib/js/watch) | Subscribe, decode, and render. `` plus an optional UI overlay. | | [@moq/video](/lib/js/video) | Draw video frames into a canvas through WebGPU or Canvas2D. Used by `@moq/watch` and `@moq/publish`. | | [@moq/publish](/lib/js/publish) | Capture, encode, and publish. `` plus an optional UI overlay. | -| [@moq/ui](/lib/js/api/ui) | The base of the watch and publish browser support banners. | | [@moq/room](/lib/js/room) | Headless rooms: announce-derived roster, local publish, remote watch, and a chat track. | | [@moq/auth](/lib/js/auth) | Validate a relay's request, build its grant, and mint and verify relay JWTs. | | [@moq/clock](/lib/js/clock) | Logical monotonic time, wall time, and deterministic timers. | diff --git a/doc/setup/upgrade.md b/doc/setup/upgrade.md index 21950eba480..6a19576481c 100644 --- a/doc/setup/upgrade.md +++ b/doc/setup/upgrade.md @@ -28,7 +28,7 @@ replaces it. - **Binaries:** [moq-relay](https://github.com/moq-dev/moq/blob/main/rs/moq-relay/MIGRATE.md), [moq-cli (`moq`)](https://github.com/moq-dev/moq/blob/main/rs/moq-cli/MIGRATE.md), [moq-gst](https://github.com/moq-dev/moq/blob/main/rs/moq-gst/MIGRATE.md), [obs-moq](https://github.com/moq-dev/moq/blob/main/cpp/obs/MIGRATE.md) - **Bindings:** [moq-ffi (UniFFI)](https://github.com/moq-dev/moq/blob/main/rs/moq-ffi/MIGRATE.md), [moq-c (C)](https://github.com/moq-dev/moq/blob/main/rs/moq-c/MIGRATE.md), [Python](https://github.com/moq-dev/moq/blob/main/py/moq-rs/MIGRATE.md), [Go](https://github.com/moq-dev/moq/blob/main/go/wrapper/MIGRATE.md), [Swift](https://github.com/moq-dev/moq/blob/main/swift/MIGRATE.md), [Kotlin](https://github.com/moq-dev/moq/blob/main/kt/moq/MIGRATE.md), [Dart](https://github.com/moq-dev/moq/blob/main/dart/moq/MIGRATE.md), [C++](https://github.com/moq-dev/moq/blob/main/cpp/moq/MIGRATE.md) - **Rust:** [hang](https://github.com/moq-dev/moq/blob/main/rs/hang/MIGRATE.md), [kio](https://github.com/moq-dev/moq/blob/main/rs/kio/MIGRATE.md), [kio-macros](https://github.com/moq-dev/moq/blob/main/rs/kio/macros/MIGRATE.md), [moq-archive](https://github.com/moq-dev/moq/blob/main/rs/moq-archive/MIGRATE.md), [moq-audio](https://github.com/moq-dev/moq/blob/main/rs/moq-audio/MIGRATE.md), [moq-auth](https://github.com/moq-dev/moq/blob/main/rs/moq-auth/MIGRATE.md), [moq-crypto](https://github.com/moq-dev/moq/blob/main/rs/moq-crypto/MIGRATE.md), [moq-hls](https://github.com/moq-dev/moq/blob/main/rs/moq-hls/MIGRATE.md), [moq-json](https://github.com/moq-dev/moq/blob/main/rs/moq-json/MIGRATE.md), [moq-loc](https://github.com/moq-dev/moq/blob/main/rs/moq-loc/MIGRATE.md), [moq-msf](https://github.com/moq-dev/moq/blob/main/rs/moq-msf/MIGRATE.md), [moq-mux](https://github.com/moq-dev/moq/blob/main/rs/moq-mux/MIGRATE.md), [moq-net](https://github.com/moq-dev/moq/blob/main/rs/moq-net/MIGRATE.md), [moq-nvenc](https://github.com/moq-dev/moq/blob/main/rs/moq-nvenc/MIGRATE.md), [moq-pattern](https://github.com/moq-dev/moq/blob/main/rs/moq-pattern/MIGRATE.md), [moq-rtmp](https://github.com/moq-dev/moq/blob/main/rs/moq-rtmp/MIGRATE.md), [moq-sock](https://github.com/moq-dev/moq/blob/main/rs/moq-sock/MIGRATE.md), [moq-srt](https://github.com/moq-dev/moq/blob/main/rs/moq-srt/MIGRATE.md), [moq-stats](https://github.com/moq-dev/moq/blob/main/rs/moq-stats/MIGRATE.md), [moq-tokio](https://github.com/moq-dev/moq/blob/main/rs/moq-tokio/MIGRATE.md), [moq-transcode](https://github.com/moq-dev/moq/blob/main/rs/moq-transcode/MIGRATE.md), [moq-uring](https://github.com/moq-dev/moq/blob/main/rs/moq-uring/MIGRATE.md), [moq-v4l](https://github.com/moq-dev/moq/blob/main/rs/moq-v4l/MIGRATE.md), [moq-video](https://github.com/moq-dev/moq/blob/main/rs/moq-video/MIGRATE.md), [moq-webrtc (was moq-rtc)](https://github.com/moq-dev/moq/blob/main/rs/moq-webrtc/MIGRATE.md), [qmux](https://github.com/moq-dev/moq/blob/main/rs/qmux/MIGRATE.md) -- **JavaScript:** [`@moq/auth`](https://github.com/moq-dev/moq/blob/main/js/auth/MIGRATE.md), [`@moq/clock`](https://github.com/moq-dev/moq/blob/main/js/clock/MIGRATE.md), [`@moq/hang`](https://github.com/moq-dev/moq/blob/main/js/hang/MIGRATE.md), [`@moq/json`](https://github.com/moq-dev/moq/blob/main/js/json/MIGRATE.md), [`@moq/loc`](https://github.com/moq-dev/moq/blob/main/js/loc/MIGRATE.md), [`@moq/msf`](https://github.com/moq-dev/moq/blob/main/js/msf/MIGRATE.md), [`@moq/net`](https://github.com/moq-dev/moq/blob/main/js/net/MIGRATE.md), [`@moq/pattern`](https://github.com/moq-dev/moq/blob/main/js/pattern/MIGRATE.md), [`@moq/publish`](https://github.com/moq-dev/moq/blob/main/js/publish/MIGRATE.md), [`@moq/qmux`](https://github.com/moq-dev/moq/blob/main/js/qmux/MIGRATE.md), [`@moq/room`](https://github.com/moq-dev/moq/blob/main/js/room/MIGRATE.md), [`@moq/signals`](https://github.com/moq-dev/moq/blob/main/js/signals/MIGRATE.md), [`@moq/ui`](https://github.com/moq-dev/moq/blob/main/js/ui/MIGRATE.md), [`@moq/video`](https://github.com/moq-dev/moq/blob/main/js/video/MIGRATE.md), [`@moq/watch`](https://github.com/moq-dev/moq/blob/main/js/watch/MIGRATE.md) +- **JavaScript:** [`@moq/auth`](https://github.com/moq-dev/moq/blob/main/js/auth/MIGRATE.md), [`@moq/clock`](https://github.com/moq-dev/moq/blob/main/js/clock/MIGRATE.md), [`@moq/hang`](https://github.com/moq-dev/moq/blob/main/js/hang/MIGRATE.md), [`@moq/json`](https://github.com/moq-dev/moq/blob/main/js/json/MIGRATE.md), [`@moq/loc`](https://github.com/moq-dev/moq/blob/main/js/loc/MIGRATE.md), [`@moq/msf`](https://github.com/moq-dev/moq/blob/main/js/msf/MIGRATE.md), [`@moq/net`](https://github.com/moq-dev/moq/blob/main/js/net/MIGRATE.md), [`@moq/pattern`](https://github.com/moq-dev/moq/blob/main/js/pattern/MIGRATE.md), [`@moq/publish`](https://github.com/moq-dev/moq/blob/main/js/publish/MIGRATE.md), [`@moq/qmux`](https://github.com/moq-dev/moq/blob/main/js/qmux/MIGRATE.md), [`@moq/room`](https://github.com/moq-dev/moq/blob/main/js/room/MIGRATE.md), [`@moq/signals`](https://github.com/moq-dev/moq/blob/main/js/signals/MIGRATE.md), [`@moq/video`](https://github.com/moq-dev/moq/blob/main/js/video/MIGRATE.md), [`@moq/watch`](https://github.com/moq-dev/moq/blob/main/js/watch/MIGRATE.md) ## Unreleased diff --git a/js/common/deps.test.ts b/js/common/deps.test.ts index 95e9261dfec..98527f6ef6d 100644 --- a/js/common/deps.test.ts +++ b/js/common/deps.test.ts @@ -28,6 +28,19 @@ describe("specifiers", () => { ]); }); + test("reads declaration files", () => { + const source = ` + import { type Report, Support } from "@moq/static"; + export { type Show } from "@moq/export"; + export default class Banner extends Support { + protected detect(): Promise; + } + export declare function rows(): import("@moq/query").Rows; + `; + + expect(specifiers(source)).toEqual(["@moq/static", "@moq/export", "@moq/query"]); + }); + test("ignores comments and strings", () => { const source = ` // import "@moq/comment"; diff --git a/js/common/deps.ts b/js/common/deps.ts index d84aee799f4..f14192b9dc0 100644 --- a/js/common/deps.ts +++ b/js/common/deps.ts @@ -1,5 +1,6 @@ -// Verifies that every workspace package declares the `@moq/*` packages it imports, and -// that every workspace whose tests can reach `@moq/clock` loads its test preload. +// Verifies that every workspace package declares the `@moq/*` packages it imports, that no +// published package depends on a private one, and that every workspace whose tests can reach +// `@moq/clock` loads its test preload. // // A bundler resolves an undeclared import through hoisting, so the tree builds and // the tests pass while a published consumer with a stricter resolver gets `undefined`. @@ -13,6 +14,7 @@ import { parse } from "@babel/parser"; /** A package.json, narrowed to the fields this script reads. */ type Manifest = { name?: string; + private?: boolean; dependencies?: Record; peerDependencies?: Record; optionalDependencies?: Record; @@ -100,7 +102,7 @@ function visit(value: unknown, found: string[]) { for (const child of Object.values(value)) visit(child, found); } -/** The module specifiers referenced by JavaScript or TypeScript source. */ +/** The module specifiers referenced by JavaScript or TypeScript source, declarations included. */ export function specifiers(source: string): string[] { const ast = parse(source, { createImportExpressions: true, @@ -164,6 +166,19 @@ function main() { } const runtime = new Set([...Object.keys(pkg.dependencies ?? {}), ...Object.keys(pkg.peerDependencies ?? {})]); + // A private package is never published, so a published one bundles it (common/package.ts) + // from its devDependencies instead of depending on it. + const bundled = new Set(Object.keys(pkg.devDependencies ?? {}).filter((name) => manifests.get(name)?.private)); + if (pkg.scripts?.release) { + for (const name of [...runtime, ...Object.keys(pkg.optionalDependencies ?? {})]) { + if (manifests.get(name)?.private) { + problems.add( + `${workspace}/package.json: depends on the private ${name}, which only devDependencies may bundle`, + ); + } + } + } + const shipping = new Set([...runtime, ...bundled]); const dev = new Set([ ...runtime, ...Object.keys(pkg.optionalDependencies ?? {}), @@ -174,13 +189,15 @@ function main() { // Only files that ship need a runtime dependency; configs, examples, and // tests may lean on a devDependency instead. const shipped = relative(dir, file).startsWith(`src${sep}`) && !TEST.test(file); - const declared = shipped ? runtime : dev; + const declared = shipped ? shipping : dev; for (const specifier of specifiers(readFileSync(file, "utf8"))) { const name = packageName(specifier); if (!name || name === pkg.name || declared.has(name)) continue; - const where = shipped ? "dependencies or peerDependencies" : "any dependency list"; + const where = shipped + ? "dependencies, peerDependencies, or bundled devDependencies" + : "any dependency list"; problems.add(`${relative(root, file)}: imports ${name}, missing from ${pkg.name} ${where}`); } } diff --git a/js/common/package.ts b/js/common/package.ts index 51bd17488d4..bedb8e9d13e 100644 --- a/js/common/package.ts +++ b/js/common/package.ts @@ -2,11 +2,13 @@ // This creates a dist/ folder with the correct paths and dependencies for publishing // Split from release.ts to allow building packages without publishing +import { execFileSync } from "node:child_process"; import { copyFileSync, existsSync, readdirSync, readFileSync, writeFileSync } from "node:fs"; -import { join, resolve } from "node:path"; +import { dirname, join, relative, resolve } from "node:path"; import { publint } from "publint"; import { formatMessage } from "publint/utils"; import { checkPackageConstructors } from "./constructors.ts"; +import { specifiers } from "./deps.ts"; checkPackageConstructors(process.cwd()); @@ -73,15 +75,21 @@ if (pkg.bin) { } } +// The directory of a workspace package, named without its scope. +function workspaceDir(name: string): string { + return `../${name.includes("/") ? name.split("/")[1] : name}`; +} + function rewriteWorkspaceDependency(dependencies?: Record) { if (!dependencies) return; for (const [name, version] of Object.entries(dependencies)) { if (typeof version === "string" && version.startsWith("workspace:")) { // Read the actual version from the workspace package - // Handle both scoped (@scope/name) and unscoped (name) packages - const packageDir = name.includes("/") ? name.split("/")[1] : name; - const workspacePkgPath = `../${packageDir}/package.json`; - const workspacePkg = JSON.parse(readFileSync(workspacePkgPath, "utf8")); + const workspacePkg = JSON.parse(readFileSync(`${workspaceDir(name)}/package.json`, "utf8")); + if (workspacePkg.private && !pkg.private) { + console.error(`${pkg.name} depends on the private ${name}; bundle it from devDependencies instead`); + process.exit(1); + } dependencies[name] = `^${workspacePkg.version}`; console.log(`🔗 Converted ${name}: ${version} → ^${workspacePkg.version}`); } @@ -92,6 +100,68 @@ function rewriteWorkspaceDependency(dependencies?: Record) { rewriteWorkspaceDependency(pkg.dependencies); rewriteWorkspaceDependency(pkg.peerDependencies); +function files(dir: string): string[] { + return readdirSync(dir, { withFileTypes: true }).flatMap((entry) => { + const path = join(dir, entry.name); + return entry.isDirectory() ? files(path) : [path]; + }); +} + +// A private workspace package ships inside each published package that imports it: Vite bundles +// its code and stylesheets, and here its declarations are emitted to dist/bundled/, with each +// import of it in this package's declarations pointed at that copy. +for (const [name, version] of Object.entries(pkg.devDependencies ?? {})) { + if (!version.startsWith("workspace:")) continue; + const source = workspaceDir(name); + const bundled = JSON.parse(readFileSync(`${source}/package.json`, "utf8")); + if (!bundled.private) continue; + + const imports = (file: string) => + specifiers(readFileSync(file, "utf8")).some((s) => s === name || s.startsWith(`${name}/`)); + const importers = files("dist").filter((file) => file.endsWith(".d.ts") && imports(file)); + if (importers.length === 0) continue; + + const out = join("dist", "bundled", source.slice("../".length)); + console.log(`📎 Bundling the declarations of ${name} into ${out}...`); + execFileSync( + process.execPath, + ["x", "--no-install", "tsc", "-p", `${source}/tsconfig.build.json`, "--outDir", out], + { + stdio: "inherit", + }, + ); + const literal = new RegExp(`(["'])${name}(/[^"']*)?\\1`, "g"); + for (const file of importers) { + const body = readFileSync(file, "utf8").replace(literal, (_, quote: string, subpath = "") => { + const target = bundled.exports?.[`.${subpath}`]; + if (typeof target !== "string" || !target.endsWith(".ts")) { + console.error(`${file}: imports ${name}${subpath}, which has no such code export`); + process.exit(1); + } + const path = relative(dirname(file), join(out, rewritePath(target, "js"))); + return `${quote}${path.startsWith(".") ? path : `./${path}`}${quote}`; + }); + writeFileSync(file, body); + } +} + +// What ships imports no @moq package it does not depend on, such as a private one left unbundled. +const declared = new Set([ + pkg.name, + ...Object.keys(pkg.dependencies ?? {}), + ...Object.keys(pkg.peerDependencies ?? {}), +]); +for (const file of files("dist")) { + if (!file.endsWith(".js") && !file.endsWith(".d.ts")) continue; + for (const specifier of specifiers(readFileSync(file, "utf8"))) { + const [scope, base] = specifier.split("/"); + if (scope === "@moq" && base && !declared.has(`${scope}/${base}`)) { + console.error(`${file}: imports ${specifier}, which ${pkg.name} does not depend on`); + process.exit(1); + } + } +} + pkg.devDependencies = undefined; pkg.scripts = undefined; diff --git a/js/publish/api/support-element.api.md b/js/publish/api/support-element.api.md index 91c6fbbf4c4..1bdbbc01811 100644 --- a/js/publish/api/support-element.api.md +++ b/js/publish/api/support-element.api.md @@ -1,10 +1,32 @@ # `@moq/publish/support/element` ```ts -import { Report } from "@moq/ui"; -import { Support } from "@moq/ui"; +import { Level } from "@moq/publish/support"; -export { Show } from "@moq/ui"; +export interface Report { + rows: [group: string, feature: string, status: Status][]; + summary: Level; +} + +export type Show = "always" | "warning" | "error" | "never"; + +export type Status = boolean | Level | { + hardware?: boolean; + software: boolean; +} | undefined; + +export abstract class Support extends HTMLElement { + constructor(); + attributeChangedCallback(name: "show" | "details", _oldValue: string | null, newValue: string | null): void; + connectedCallback(): void; + get details(): boolean; + set details(details: boolean); + protected abstract detect(): Promise; + disconnectedCallback(): void; + static observedAttributes: readonly ["show", "details"]; + get show(): Show; + set show(show: Show); +} export default class extends Support { protected detect(): Promise; diff --git a/js/publish/package.json b/js/publish/package.json index 093c136c5e9..311599b18c5 100644 --- a/js/publish/package.json +++ b/js/publish/package.json @@ -33,12 +33,12 @@ "@moq/json": "workspace:^", "@moq/net": "workspace:^", "@moq/signals": "workspace:^", - "@moq/ui": "workspace:^", "@moq/video": "workspace:^", "mediabunny": "^1.65.2" }, "devDependencies": { "@moq/libav": "workspace:^", + "@moq/ui": "workspace:^", "@types/audioworklet": "^0.0.100", "@types/bun": "^1.4.4", "@typescript/lib-dom": "npm:@types/web@^0.0.358", diff --git a/js/publish/src/broadcast.ts b/js/publish/src/broadcast.ts index 7ae897b9d2a..993009d2687 100644 --- a/js/publish/src/broadcast.ts +++ b/js/publish/src/broadcast.ts @@ -4,7 +4,7 @@ import * as Catalog from "@moq/hang/catalog"; import * as Container from "@moq/hang/container"; import * as Moq from "@moq/net"; import { Effect, type Getter, getter, type Inputs, type Readonlys, Signal } from "@moq/signals"; -import { rotateVideoDimensions } from "@moq/video"; +import { rotateDimensions } from "@moq/video"; import { CatalogProducer } from "./catalog"; import { Order } from "./order"; import { type Identity, identity, type Listing, Publication, type Slot } from "./publication"; @@ -335,7 +335,7 @@ export class Broadcast { const section: Catalog.Video = { renditions: video }; // display is optional in the schema, so it gates only itself, not the whole section. if (display) { - const { width, height } = rotateVideoDimensions(display, rotation); + const { width, height } = rotateDimensions(display, rotation); section.display = { width: Catalog.u53(width), height: Catalog.u53(height) }; } if (flip) section.flip = true; diff --git a/js/publish/src/preview.ts b/js/publish/src/preview.ts index 309fce3effc..088b616ab2b 100644 --- a/js/publish/src/preview.ts +++ b/js/publish/src/preview.ts @@ -96,7 +96,7 @@ export class Renderer { const display = current ? { width: current.displayWidth, height: current.displayHeight } : effect.get(this.in.display); - return display ? Video.rotateVideoDimensions(display, effect.get(this.in.rotation)) : undefined; + return display ? Video.rotateDimensions(display, effect.get(this.in.rotation)) : undefined; }), presentation: this.#signals.computed((effect) => ({ flip: effect.get(this.in.flip), diff --git a/js/publish/src/support/element.ts b/js/publish/src/support/element.ts index 5c75ac8b796..c8a86590fb9 100644 --- a/js/publish/src/support/element.ts +++ b/js/publish/src/support/element.ts @@ -6,10 +6,10 @@ * @module */ -import { type Level, type Report, Support } from "@moq/ui"; -import { type Full, isSupported } from "./"; +import { type Report, Support } from "@moq/ui"; +import { type Full, isSupported, type Level } from "./"; -export type { Show } from "@moq/ui"; +export { type Report, type Show, type Status, Support } from "@moq/ui"; function summarize(support: Full): Level { if (support.webtransport === "none") return "none"; diff --git a/js/publish/src/support/index.ts b/js/publish/src/support/index.ts index 300236575e7..15a25688a87 100644 --- a/js/publish/src/support/index.ts +++ b/js/publish/src/support/index.ts @@ -6,11 +6,12 @@ */ import { Connection } from "@moq/net"; +import type { Level } from "@moq/ui"; import { workerSupported } from "../video/processor"; import { probe } from "./video"; /** How well a feature works: natively, through a fallback, or not at all. */ -export type Level = "full" | "partial" | "none"; +export type { Level }; /** Whether a codec encodes in hardware and in software. */ export type Codec = { diff --git a/js/publish/test-dts/support.ts b/js/publish/test-dts/support.ts new file mode 100644 index 00000000000..bb83dd5f10c --- /dev/null +++ b/js/publish/test-dts/support.ts @@ -0,0 +1,13 @@ +import MoqPublishSupport, { type Report, type Show, Support } from "../dist/support/element.js"; + +// The banner's types ship in this package, though the private @moq/ui they come from does not. +class Custom extends Support { + protected async detect(): Promise { + return { summary: "partial", rows: [["Capture", "Video", { hardware: false, software: true }]] }; + } +} + +const show: Show = "error"; +const banner: Support = new MoqPublishSupport(); +banner.show = show; +new Custom().details = true; diff --git a/js/publish/vite.config.ts b/js/publish/vite.config.ts index b9d249e5b88..8a3001a8907 100644 --- a/js/publish/vite.config.ts +++ b/js/publish/vite.config.ts @@ -18,9 +18,10 @@ export default defineConfig({ formats: ["es"], }, rollupOptions: { - // Keep every @moq workspace dep (and its subpaths, e.g. @moq/signals/dom) - // external so consumers dedupe against their own copy instead of bundling ours. - external: (id) => id.startsWith("@moq/"), + // Keep every published @moq dep (and its subpaths, e.g. @moq/signals/dom) external + // so consumers dedupe against their own copy instead of bundling ours. The private + // @moq/ui is never published, so it is bundled. + external: (id) => id.startsWith("@moq/") && id !== "@moq/ui", }, sourcemap: true, target: "esnext", diff --git a/js/ui/MIGRATE.md b/js/ui/MIGRATE.md deleted file mode 100644 index a406b05184d..00000000000 --- a/js/ui/MIGRATE.md +++ /dev/null @@ -1,5 +0,0 @@ -# Migrating @moq/ui - -How to update your code for each breaking change, newest first. - -## Unreleased diff --git a/js/ui/README.md b/js/ui/README.md index 799eee3cf1f..80965ecb3ff 100644 --- a/js/ui/README.md +++ b/js/ui/README.md @@ -1,38 +1,9 @@ -

- Media over QUIC -

- # @moq/ui -[![npm](https://img.shields.io/npm/v/@moq/ui)](https://www.npmjs.com/package/@moq/ui) -[![TypeScript](https://img.shields.io/badge/TypeScript-ready-blue.svg)](https://www.typescriptlang.org/) - -The base of the `` and `` banners in [@moq/watch](../watch) and [@moq/publish](../publish), built on [@moq/signals](../signals). -You only need it directly to build a support banner for your own capability checks. - -`Support` is an abstract `HTMLElement` that renders a banner and details table for the `Report` its `detect()` returns. Its `show` attribute (`Show`) picks when the banner appears, by the report's `Level`. -The overlay helpers the two packages share (control buttons, stats cards, sparkline, formatters) live here too, but are internal and may change in any release. - -It holds no capability detection and publishes no styles: each overlay styles these elements and detects its own support. -Inside this repository, `@moq/watch` and `@moq/publish` inline the shared stats card and sparkline styles from `src/stats.css` at build time; that file is not part of the npm package. - -```bash -bun add @moq/ui -# or -npm add @moq/ui -``` - -```ts -import { type Report, Support } from "@moq/ui"; +Presentation code that [@moq/watch](../watch) and [@moq/publish](../publish) share: the `Support` banner base, overlay control buttons, stats cards, the sparkline, and value formatters, plus `stats.css`. -class MySupport extends Support { - protected async detect(): Promise { - const webcodecs = typeof VideoDecoder !== "undefined"; - return { summary: webcodecs ? "full" : "none", rows: [["Video", "WebCodecs", webcodecs]] }; - } -} -customElements.define("my-support", MySupport); -``` +It is a private workspace package, never published. Each of the two packages bundles its code, its declarations, and its stylesheet into its own build, so their published packages import nothing from it, and anything here may change with them in any commit. +A published package lists it under `devDependencies`, and `js/common/package.ts` emits its declarations into that package's `dist/bundled/ui/`. ## License diff --git a/js/ui/api/index.api.md b/js/ui/api/index.api.md deleted file mode 100644 index 72c2af3f932..00000000000 --- a/js/ui/api/index.api.md +++ /dev/null @@ -1,30 +0,0 @@ -# `@moq/ui` - -```ts -export type Level = "full" | "partial" | "none"; - -export interface Report { - rows: [group: string, feature: string, status: Status][]; - summary: Level; -} - -export type Show = "always" | "warning" | "error" | "never"; - -export type Status = boolean | Level | { - hardware?: boolean; - software: boolean; -} | undefined; - -export abstract class Support extends HTMLElement { - constructor(); - attributeChangedCallback(name: "show" | "details", _oldValue: string | null, newValue: string | null): void; - connectedCallback(): void; - get details(): boolean; - set details(details: boolean); - protected abstract detect(): Promise; - disconnectedCallback(): void; - static observedAttributes: readonly ["show", "details"]; - get show(): Show; - set show(show: Show); -} -``` diff --git a/js/ui/package.json b/js/ui/package.json index 893f3bede21..5c999120f13 100644 --- a/js/ui/package.json +++ b/js/ui/package.json @@ -1,24 +1,18 @@ { "name": "@moq/ui", "type": "module", - "version": "0.1.0", - "description": "Presentation components shared by the @moq/watch and @moq/publish overlays", + "version": "0.0.0", + "description": "Presentation code the @moq/watch and @moq/publish overlays share, bundled into each", "license": "(MIT OR Apache-2.0)", - "repository": { - "type": "git", - "url": "git+https://github.com/moq-dev/moq.git", - "directory": "js/ui" - }, + "private": true, "exports": { ".": "./src/index.ts", "./stats.css": "./src/stats.css" }, "sideEffects": false, "scripts": { - "build": "rm -rf dist && vite build && tsc -p tsconfig.build.json && bun ../common/package.ts", "check": "tsc --noEmit", - "test": "bun test --pass-with-no-tests", - "release": "bun ../common/release.ts" + "test": "bun test --pass-with-no-tests" }, "dependencies": { "@moq/signals": "workspace:^" diff --git a/js/ui/src/graph.ts b/js/ui/src/graph.ts index 414662c22a4..4799749a690 100644 --- a/js/ui/src/graph.ts +++ b/js/ui/src/graph.ts @@ -1,6 +1,6 @@ import type { Effect } from "@moq/signals"; -/** Options for {@link graph}. @internal */ +/** Options for {@link graph}. */ export interface GraphOptions { /** Stroke/fill color for the line (any CSS color). */ color?: string; @@ -8,7 +8,7 @@ export interface GraphOptions { format?: (v: number) => string; } -/** A sparkline created by {@link graph}. @internal */ +/** A sparkline created by {@link graph}. */ export interface Graph { /** The root element to mount. */ el: HTMLElement; diff --git a/js/ui/src/index.ts b/js/ui/src/index.ts index b49b2aa0b1d..06042d01a79 100644 --- a/js/ui/src/index.ts +++ b/js/ui/src/index.ts @@ -1,18 +1,18 @@ /** - * The base of the `@moq/watch` and `@moq/publish` browser support banners: {@link Support} and - * the report it renders. + * What the `@moq/watch` and `@moq/publish` overlays share, bundled into each: the {@link Support} + * banner base, control buttons, stats cards, a sparkline, and formatters. * * Browser-only: {@link Support} extends `HTMLElement` when this module loads. * * @module */ -/** Overlay control buttons and SVG glyphs. @internal */ +/** Overlay control buttons and SVG glyphs. */ export { controlButton, fullscreenButton, icon, settingsButton } from "./button"; -/** Human-readable stats values. @internal */ +/** Human-readable stats values. */ export { formatBitrate, formatFps, formatHz, formatMillis } from "./format"; -/** A rolling sparkline. @internal */ +/** A rolling sparkline. */ export { type Graph, type GraphOptions, graph } from "./graph"; -/** Stats panel cards and key/value rows. @internal */ +/** Stats panel cards and key/value rows. */ export { type StatCard, type StatKind, statCard, statLine } from "./stats"; export { type Level, type Report, type Show, type Status, Support } from "./support"; diff --git a/js/ui/src/stats.ts b/js/ui/src/stats.ts index 0ab8a4a0a1f..0bd5a288941 100644 --- a/js/ui/src/stats.ts +++ b/js/ui/src/stats.ts @@ -1,10 +1,10 @@ import * as DOM from "@moq/signals/dom"; import { icon } from "./button"; -/** Which accent a {@link statCard} takes. @internal */ +/** Which accent a {@link statCard} takes. */ export type StatKind = "network" | "video" | "audio"; -/** A stats card created by {@link statCard}. @internal */ +/** A stats card created by {@link statCard}. */ export interface StatCard { /** The root element to mount. */ el: HTMLElement; diff --git a/js/ui/vite.config.ts b/js/ui/vite.config.ts deleted file mode 100644 index c3307bbd21a..00000000000 --- a/js/ui/vite.config.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { resolve } from "path"; -import { defineConfig } from "vite"; - -export default defineConfig({ - build: { - lib: { - entry: { - index: resolve(import.meta.dirname, "src/index.ts"), - }, - formats: ["es"], - }, - rollupOptions: { - // Keep every @moq workspace dep (and its subpaths) external so consumers dedupe against their own copy. - external: (id) => id.startsWith("@moq/"), - }, - sourcemap: true, - target: "esnext", - }, -}); diff --git a/js/video/api/index.api.md b/js/video/api/index.api.md index 8a4af9cc1c8..41c14f3d473 100644 --- a/js/video/api/index.api.md +++ b/js/video/api/index.api.md @@ -38,4 +38,12 @@ export type RendererOutput = { }; export type RendererProps = Inputs; + +export function rotateDimensions(dimensions: { + height: number; + width: number; +}, rotation?: number): { + height: number; + width: number; +}; ``` diff --git a/js/video/src/index.ts b/js/video/src/index.ts index cb75aaeb2ee..102b7039f65 100644 --- a/js/video/src/index.ts +++ b/js/video/src/index.ts @@ -23,6 +23,5 @@ * * @module */ -/** Swap a width and height for a quarter-turn rotation. @internal */ -export { rotateVideoDimensions } from "./presentation"; +export { rotateDimensions } from "./presentation"; export * from "./renderer"; diff --git a/js/video/src/presentation.test.ts b/js/video/src/presentation.test.ts index f0910cf6c69..061555ab863 100644 --- a/js/video/src/presentation.test.ts +++ b/js/video/src/presentation.test.ts @@ -2,7 +2,7 @@ import { describe, expect, it } from "bun:test"; import { canvasPresentationTransform, type Presentation, - rotateVideoDimensions, + rotateDimensions, texturePresentationTransform, } from "./presentation"; @@ -31,7 +31,7 @@ function video(rotation: number, flip = false): Presentation { describe("video presentation", () => { it.each(rotations)("rotates %i degrees clockwise", (rotation, matrix, source) => { expect(canvasPresentationTransform(output, video(rotation))).toEqual({ matrix, source }); - expect(rotateVideoDimensions(output, rotation)).toEqual(source); + expect(rotateDimensions(output, rotation)).toEqual(source); }); it.each(flips)("flips the %i degree presentation horizontally", (rotation, matrix) => { diff --git a/js/video/src/presentation.ts b/js/video/src/presentation.ts index 0d9b0af231d..b07a4c4f7b3 100644 --- a/js/video/src/presentation.ts +++ b/js/video/src/presentation.ts @@ -31,8 +31,12 @@ function normalizeRotation(rotation = 0): Rotation { return ((Math.round(normalized / 90) % 4) * 90) as Rotation; } -/** Return dimensions after applying a clockwise quarter-turn. */ -export function rotateVideoDimensions(dimensions: Dimensions, rotation = 0): Dimensions { +// The shape is spelled out, like `RendererInput.display`, keeping `Dimensions` off the public API. +/** Swap a width and height when a clockwise rotation, rounded to a quarter-turn, turns them sideways. */ +export function rotateDimensions( + dimensions: { width: number; height: number }, + rotation = 0, +): { width: number; height: number } { const normalized = normalizeRotation(rotation); return normalized === 90 || normalized === 270 ? { width: dimensions.height, height: dimensions.width } @@ -58,7 +62,7 @@ export function canvasPresentationTransform( presentation?: Presentation, ): CanvasPresentationTransform { const rotation = normalizeRotation(presentation?.rotation); - const source = rotateVideoDimensions(output, rotation); + const source = rotateDimensions(output, rotation); let matrix: Matrix; switch (rotation) { diff --git a/js/watch/api/support-element.api.md b/js/watch/api/support-element.api.md index 3092161e352..c3bf184d3a6 100644 --- a/js/watch/api/support-element.api.md +++ b/js/watch/api/support-element.api.md @@ -1,10 +1,32 @@ # `@moq/watch/support/element` ```ts -import { Report } from "@moq/ui"; -import { Support } from "@moq/ui"; +import { Level } from "@moq/watch/support"; -export { Show } from "@moq/ui"; +export interface Report { + rows: [group: string, feature: string, status: Status][]; + summary: Level; +} + +export type Show = "always" | "warning" | "error" | "never"; + +export type Status = boolean | Level | { + hardware?: boolean; + software: boolean; +} | undefined; + +export abstract class Support extends HTMLElement { + constructor(); + attributeChangedCallback(name: "show" | "details", _oldValue: string | null, newValue: string | null): void; + connectedCallback(): void; + get details(): boolean; + set details(details: boolean); + protected abstract detect(): Promise; + disconnectedCallback(): void; + static observedAttributes: readonly ["show", "details"]; + get show(): Show; + set show(show: Show); +} export default class extends Support { protected detect(): Promise; diff --git a/js/watch/package.json b/js/watch/package.json index ce1e6ba236a..e607977fa3c 100644 --- a/js/watch/package.json +++ b/js/watch/package.json @@ -22,7 +22,7 @@ "./src/support/element.ts" ], "scripts": { - "build": "rm -rf dist && vite build && tsc -p tsconfig.build.json && bun ../common/package.ts", + "build": "rm -rf dist && vite build && tsc -p tsconfig.build.json && bun ../common/package.ts && tsc --project test-dts/tsconfig.json", "check": "tsc --noEmit", "test": "bun test --only-failures", "release": "bun ../common/release.ts" @@ -34,12 +34,12 @@ "@moq/net": "workspace:^", "@moq/msf": "workspace:^", "@moq/signals": "workspace:^", - "@moq/ui": "workspace:^", "@moq/video": "workspace:^", "media-captions": "0.0.18" }, "devDependencies": { "@moq/libav": "workspace:^", + "@moq/ui": "workspace:^", "@types/audioworklet": "^0.0.100", "@types/bun": "^1.4.4", "@typescript/lib-dom": "npm:@types/web@^0.0.358", diff --git a/js/watch/src/support/element.ts b/js/watch/src/support/element.ts index 399a63dedfb..cacdf5dc9e0 100644 --- a/js/watch/src/support/element.ts +++ b/js/watch/src/support/element.ts @@ -6,10 +6,10 @@ * @module */ -import { type Level, type Report, Support } from "@moq/ui"; -import { type Full, isSupported } from "./"; +import { type Report, Support } from "@moq/ui"; +import { type Full, isSupported, type Level } from "./"; -export type { Show } from "@moq/ui"; +export { type Report, type Show, type Status, Support } from "@moq/ui"; function summarize(support: Full): Level { if (support.webtransport === "none") return "none"; diff --git a/js/watch/src/support/index.ts b/js/watch/src/support/index.ts index 4f1d630dc2c..83d971ba011 100644 --- a/js/watch/src/support/index.ts +++ b/js/watch/src/support/index.ts @@ -5,12 +5,13 @@ */ import { Connection } from "@moq/net"; +import type { Level } from "@moq/ui"; // https://bugzilla.mozilla.org/show_bug.cgi?id=1967793 const isFirefox = navigator.userAgent.toLowerCase().includes("firefox"); /** How well a feature works: natively, through a fallback, or not at all. */ -export type Level = "full" | "partial" | "none"; +export type { Level }; /** Whether a codec decodes in hardware and in software. */ export type Codec = { diff --git a/js/watch/src/video/decoder.ts b/js/watch/src/video/decoder.ts index fdadbb35d57..e5e6ced79b0 100644 --- a/js/watch/src/video/decoder.ts +++ b/js/watch/src/video/decoder.ts @@ -15,7 +15,7 @@ import { readonlys, Signal, } from "@moq/signals"; -import { rotateVideoDimensions } from "@moq/video"; +import { rotateDimensions } from "@moq/video"; import { base64ToBytes } from "../base64"; import { arrivedAt, type Counter, type Key, type Received, Tally } from "../feedback"; import { type Failure, failureMoved, nextMedia, subscribeMedia } from "../media"; @@ -471,7 +471,7 @@ export class Decoder { effect.set( this.#out.display, - rotateVideoDimensions({ width: frame.displayWidth, height: frame.displayHeight }, catalog.rotation), + rotateDimensions({ width: frame.displayWidth, height: frame.displayHeight }, catalog.rotation), ); } diff --git a/js/watch/test-dts/support.ts b/js/watch/test-dts/support.ts new file mode 100644 index 00000000000..c78c60a1d82 --- /dev/null +++ b/js/watch/test-dts/support.ts @@ -0,0 +1,13 @@ +import MoqWatchSupport, { type Report, type Show, Support } from "../dist/support/element.js"; + +// The banner's types ship in this package, though the private @moq/ui they come from does not. +class Custom extends Support { + protected async detect(): Promise { + return { summary: "partial", rows: [["Decoding", "H.264", { hardware: false, software: true }]] }; + } +} + +const show: Show = "error"; +const banner: Support = new MoqWatchSupport(); +banner.show = show; +new Custom().details = true; diff --git a/js/watch/test-dts/tsconfig.json b/js/watch/test-dts/tsconfig.json new file mode 100644 index 00000000000..f06c4a424b2 --- /dev/null +++ b/js/watch/test-dts/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "noEmit": true, + "emitDeclarationOnly": false, + "allowImportingTsExtensions": true, + "types": ["bun", "audioworklet"] + }, + "include": [".", "../../common/worklet.d.ts"] +} diff --git a/js/watch/vite.config.ts b/js/watch/vite.config.ts index ac4791cc979..e05afba775f 100644 --- a/js/watch/vite.config.ts +++ b/js/watch/vite.config.ts @@ -17,12 +17,13 @@ export default defineConfig({ formats: ["es"], }, rollupOptions: { - // Keep every @moq workspace dep (and its subpaths, e.g. @moq/signals/dom) - // external so consumers dedupe against their own copy instead of bundling ours. + // Keep every published @moq dep (and its subpaths, e.g. @moq/signals/dom) external + // so consumers dedupe against their own copy instead of bundling ours. The private + // @moq/ui is never published, so it is bundled. // media-captions too: its browser build reads `window.VTTCue` on load, and only // an external import lets a server runtime pick its `node` export instead. Its // stylesheets stay bundled, since they are inlined as strings. - external: (id) => id.startsWith("@moq/") || id === "media-captions", + external: (id) => (id.startsWith("@moq/") && id !== "@moq/ui") || id === "media-captions", }, sourcemap: true, target: "esnext", diff --git a/quest/m2/README.md b/quest/m2/README.md index 42df4d4cfa6..3824ad98509 100644 --- a/quest/m2/README.md +++ b/quest/m2/README.md @@ -71,8 +71,8 @@ removal, a rename, or a wire, catalog, or format change that is free until [upstream str0m](/quest/m2/str0m-upstream.md), which reverses the 2026-10-30 vendoring. - **JS and browser.** [`@moq/net`](/quest/m2/js-net-api.md), - [signals](/quest/m2/signals-semantics.md), [`@moq/ui`](/quest/m2/ui-private.md), - and [room, publish, and OBS names](/quest/m2/browser-packages.md). + [signals](/quest/m2/signals-semantics.md), and + [room, publish, and OBS names](/quest/m2/browser-packages.md). - **Bindings.** [Open selectors](/quest/m2/ffi-open-selectors.md), [Dart as experimental](/quest/m2/dart-experimental.md), and [the C API as `libmoq`](/quest/m2/libmoq-name.md), reversing 2026-10-25. diff --git a/quest/m2/browser-packages.md b/quest/m2/browser-packages.md index edfb4855289..b24be143af5 100644 --- a/quest/m2/browser-packages.md +++ b/quest/m2/browser-packages.md @@ -92,5 +92,4 @@ and the unpublished `@moq/obs`. Wire: none. ## Related -- [@moq/ui is a workspace package](/quest/m2/ui-private.md) - the packaging change to the same overlays - [Unused media API](/quest/m2/unused-api/media.md) - the browser exports removed beside these renames diff --git a/quest/m2/ui-private.md b/quest/m2/ui-private.md deleted file mode 100644 index f33a7cc79db..00000000000 --- a/quest/m2/ui-private.md +++ /dev/null @@ -1,79 +0,0 @@ -# [M] @moq/ui is a workspace package, bundled into watch and publish - -## Goal - -`@moq/ui` is `private: true` and never reaches npm. `@moq/watch` and -`@moq/publish` bundle its code and its types, so their published packages -import nothing from it and no cross-package contract hides behind -`@internal`. `@moq/video` exports nothing marked `@internal` to another -package either. The npm name is not claimed, and the docs, the API reports, -and the release list drop it. - -## Plan - -Decided 2026-11-16 (maintainer, /quest-plan of the pre-cut audit): - -- ✅ Workspace-private and bundled (rejected: keeping it published with the - helpers as a typed public API under `just api-diff`; keeping it as is with - watch and publish pinned to its exact version). The package exists to - share code between two packages, which is a build concern, and its name - promises a player UI it does not hold. - -Facts found by the audit, re-checked at `80ca9787e3`: - -- Its public API is one abstract class, `Support`, and four types - (`js/ui/src/index.ts:18`). What watch and publish take at runtime is - `controlButton`, `fullscreenButton`, `settingsButton`, `icon`, `graph`, - `statCard`, `statLine`, and four formatters, all tagged `@internal` - (`js/ui/src/index.ts:10-17`), from 17 import sites (10 in `js/watch`, 7 - in `js/publish`). -- `stripInternal` removes those from the published types, but the published - watch and publish keep every `@moq/*` import external - (`js/watch/vite.config.ts:25`, `js/publish/vite.config.ts:23`) and depend - on `^` of the workspace version (`js/common/package.ts:85`). So changing - an `@internal` helper in a patch breaks an installed watch or publish: - the contract is real, untyped, and outside the API reports. -- `Support`, `Report`, and `Show` are part of watch's and publish's own - public types (`js/publish/api/support-element.api.md:4-7`, - `js/watch/src/support/element.ts:9-12`), so bundling must inline the - types, not only the code. -- `@moq/video` does the same thing once: `rotateVideoDimensions` is - `@internal` (`js/video/src/index.ts:26-27`) and imported by - `js/watch/src/video/decoder.ts:18`, `js/publish/src/broadcast.ts:7`, and - `js/publish/src/preview.ts:99`. -- Nothing is published under the name: `@moq/ui` returned 404 on - 2026-11-12 ([first publish](/quest/m3/release/npm-first-publish.md)). - `js/crypto` is already `private: true`. -- The package is 783 lines of source and CSS, so a page loading both - overlays carries that much twice. - -For the PR: - -- Set `private: true`, drop the `release` script, and remove `@moq/ui` - from each vite `external` rule and from the dependencies `package.ts` - rewrites, so the build fails if a published package still imports it. - `just js check` already rejects an undeclared `@moq/*` import; make it - reject a published package depending on a private one. -- Bundle the types: the support elements' declarations must resolve - without `@moq/ui` installed. The `test-dts` checks in `js/publish` are - where to prove it, with one for `js/watch`. -- `stats.css` (`js/ui/package.json` exports `./stats.css`) is bundled the - same way. -- For `@moq/video`, recommended: export `rotateVideoDimensions` as public - API, since it is a five-line pure helper (alternative: inline it in the - two callers). -- Drop the name from `doc/lib/js/index.md`, `doc/setup/upgrade.md`, - `doc/.vitepress/api/package.json`, and `js/ui/api/`. Delete - `js/ui/MIGRATE.md`; the README says what the package is for inside the - workspace. -- Measure `@moq/watch/element` and `@moq/publish/element` first-load size - before and after with `sh/size/bundles.ts` and put both in the PR. - -Public API: `@moq/ui` is never published; `@moq/watch` and `@moq/publish` -keep the same exported names, now declared in their own types. `@moq/video` -gains one export. Wire: none. - -## Related - -- [Claim the new @moq npm names](/quest/m3/release/npm-first-publish.md) - no longer claims `@moq/ui` -- [Browser package names](/quest/m2/browser-packages.md) - the other browser package changes before the cut diff --git a/quest/m3/release/npm-first-publish.md b/quest/m3/release/npm-first-publish.md index 8d88945463d..3b43b760a20 100644 --- a/quest/m3/release/npm-first-publish.md +++ b/quest/m3/release/npm-first-publish.md @@ -27,9 +27,8 @@ depends on it, so a miss fails only its own publish. All five still returned 404 on 2026-11-12. Decided 2026-11-16 (maintainer, /quest-plan of the pre-cut audit): `@moq/ui` -becomes a workspace-private package bundled into watch and publish -([its quest](/quest/m2/ui-private.md), which the cut waits on), so its name -is not claimed and it left this list, which had five names. +became a workspace-private package bundled into watch and publish, so its +name is not claimed and it left this list, which had five names. Decided 2026-10-22 (maintainer): publish a minimal `0.0.0` placeholder (README only) per name to claim it, then attach the trusted publisher. The From c42ee5c6210aa85ff2f8cc06a309dc697d7fe656 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Mon, 16 Nov 2026 06:25:06 -0800 Subject: [PATCH 3/4] style(js): name the bundling tsc arguments --- js/common/package.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/js/common/package.ts b/js/common/package.ts index bedb8e9d13e..53a1bab23cb 100644 --- a/js/common/package.ts +++ b/js/common/package.ts @@ -123,13 +123,8 @@ for (const [name, version] of Object.entries(pkg.devDependencies ?? {})) const out = join("dist", "bundled", source.slice("../".length)); console.log(`📎 Bundling the declarations of ${name} into ${out}...`); - execFileSync( - process.execPath, - ["x", "--no-install", "tsc", "-p", `${source}/tsconfig.build.json`, "--outDir", out], - { - stdio: "inherit", - }, - ); + const tsc = ["x", "--no-install", "tsc", "-p", `${source}/tsconfig.build.json`, "--outDir", out]; + execFileSync(process.execPath, tsc, { stdio: "inherit" }); const literal = new RegExp(`(["'])${name}(/[^"']*)?\\1`, "g"); for (const file of importers) { const body = readFileSync(file, "utf8").replace(literal, (_, quote: string, subpath = "") => { From f28fcaeb30ffa4dc32f4aa60849d0b2bb61f177c Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Mon, 16 Nov 2026 14:03:28 -0800 Subject: [PATCH 4/4] fix(js): bundled declaration imports use / on every platform path.relative() returns backslashes on Windows, which broke the quoted module specifier package.ts writes into each rewritten .d.ts. Co-Authored-By: Claude Opus 5.5 --- js/common/package.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/js/common/package.ts b/js/common/package.ts index 53a1bab23cb..8d2ad5848cc 100644 --- a/js/common/package.ts +++ b/js/common/package.ts @@ -4,7 +4,7 @@ import { execFileSync } from "node:child_process"; import { copyFileSync, existsSync, readdirSync, readFileSync, writeFileSync } from "node:fs"; -import { dirname, join, relative, resolve } from "node:path"; +import { dirname, join, relative, resolve, sep } from "node:path"; import { publint } from "publint"; import { formatMessage } from "publint/utils"; import { checkPackageConstructors } from "./constructors.ts"; @@ -133,7 +133,10 @@ for (const [name, version] of Object.entries(pkg.devDependencies ?? {})) console.error(`${file}: imports ${name}${subpath}, which has no such code export`); process.exit(1); } - const path = relative(dirname(file), join(out, rewritePath(target, "js"))); + // A module specifier separates with "/" on every platform, unlike a Windows path. + const path = relative(dirname(file), join(out, rewritePath(target, "js"))) + .split(sep) + .join("/"); return `${quote}${path.startsWith(".") ? path : `./${path}`}${quote}`; }); writeFileSync(file, body);