diff --git a/.fallowrc.jsonc b/.fallowrc.jsonc index 93af8da0d3..fefab37443 100644 --- a/.fallowrc.jsonc +++ b/.fallowrc.jsonc @@ -453,6 +453,8 @@ "@hyperframes/core", "@hyperframes/studio", "@hyperframes/producer", + // Inspector's published declarations import it through the core sources they bundle. + "@hyperframes/parsers", "@fontsource/archivo-black", "@fontsource/eb-garamond", "@fontsource/ibm-plex-mono", diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 6ce255bb8e..cf02b84efc 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -153,6 +153,7 @@ jobs: publish_pkg "@hyperframes/lint" "@hyperframes/lint" publish_pkg "@hyperframes/studio-server" "@hyperframes/studio-server" publish_pkg "@hyperframes/core" "@hyperframes/core" + publish_pkg "@hyperframes/inspector" "@hyperframes/inspector" publish_pkg "@hyperframes/sdk" "@hyperframes/sdk" publish_pkg "@hyperframes/engine" "@hyperframes/engine" publish_pkg "@hyperframes/player" "@hyperframes/player" diff --git a/bun.lock b/bun.lock index f56e43e558..f8e9f71e31 100644 --- a/bun.lock +++ b/bun.lock @@ -197,9 +197,10 @@ }, "packages/inspector": { "name": "@hyperframes/inspector", - "version": "0.8.140", + "version": "0.8.150", "dependencies": { "@hyperframes/core": "workspace:*", + "@hyperframes/parsers": "workspace:*", "@jridgewell/trace-mapping": "^0.3.29", "acorn": "^8.17.0", "esbuild": "^0.25.12", diff --git a/package.json b/package.json index c5f8cb0e13..3973612f0f 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "type": "module", "scripts": { "dev": "bun run studio", - "build": "bun run --filter '@hyperframes/{parsers,lint,studio-server}' build && bun run --filter @hyperframes/core build && bun run --filter '@hyperframes/{engine,producer,player,studio,shader-transitions,aws-lambda,gcp-cloud-run,sdk}' build && bun run --filter @hyperframes/cli build && bun run --filter @hyperframes/sdk-playground build", + "build": "bun run --filter '@hyperframes/{parsers,lint,studio-server}' build && bun run --filter @hyperframes/core build && bun run --filter '@hyperframes/{engine,producer,player,studio,shader-transitions,aws-lambda,gcp-cloud-run,sdk,inspector}' build && bun run --filter @hyperframes/cli build && bun run --filter @hyperframes/sdk-playground build", "build:producer": "bun run --filter @hyperframes/producer build", "studio": "bun run --filter @hyperframes/studio dev", "build:hyperframes-runtime": "bun run --filter @hyperframes/core build:hyperframes-runtime", diff --git a/packages/inspector/build.mjs b/packages/inspector/build.mjs index 6f9dfc4a30..fff000526c 100644 --- a/packages/inspector/build.mjs +++ b/packages/inspector/build.mjs @@ -1,7 +1,15 @@ // Builds the inspector for Node and for the page. Bun runs the TypeScript sources directly (package.json "bun"). import { execFileSync } from "node:child_process"; -import { copyFileSync, readFileSync, rmSync } from "node:fs"; +import { + copyFileSync, + existsSync, + readdirSync, + readFileSync, + rmSync, + writeFileSync, +} from "node:fs"; import { createRequire } from "node:module"; +import { dirname, join } from "node:path"; import { build } from "esbuild"; const at = (path) => new URL(path, import.meta.url).pathname; @@ -33,3 +41,28 @@ const tsc = createRequire(import.meta.url).resolve("typescript/bin/tsc"); execFileSync(process.execPath, [tsc, "-p", at("./tsconfig.types.json")], { stdio: "inherit" }); // tsc emits declarations for TypeScript only; the element map's JavaScript ships its own. copyFileSync(at("./src/elementMap.d.ts"), at("./dist/types/inspector/src/elementMap.d.ts")); +addDeclarationExtensions(at("./dist/types")); + +// NodeNext consumers reject extensionless relative imports, and tsc keeps the source's bundler-style ones. +function addDeclarationExtensions(dir) { + for (const entry of readdirSync(dir, { recursive: true })) { + const file = join(dir, entry); + if (!file.endsWith(".d.ts")) continue; + const source = readFileSync(file, "utf8"); + const rewritten = source.replace( + /((?:from|import\()\s*["'])(\.{1,2}\/[^"']*)(["'])/g, + (whole, open, specifier, close) => { + const target = resolveDeclaration(dirname(file), specifier); + return target ? open + target + close : whole; + }, + ); + if (rewritten !== source) writeFileSync(file, rewritten); + } +} + +function resolveDeclaration(from, specifier) { + if (/\.[cm]?js$/.test(specifier)) return undefined; + if (existsSync(join(from, `${specifier}.d.ts`))) return `${specifier}.js`; + if (existsSync(join(from, specifier, "index.d.ts"))) return `${specifier}/index.js`; + throw new Error(`No declaration for ${specifier} imported from ${from}`); +} diff --git a/packages/inspector/package-subpaths.json b/packages/inspector/package-subpaths.json new file mode 100644 index 0000000000..4bd50db91a --- /dev/null +++ b/packages/inspector/package-subpaths.json @@ -0,0 +1,20 @@ +{ + "package": "@hyperframes/inspector", + "subpaths": { + ".": { + "source": "./src/service.ts", + "runtime": { + "default": "./dist/service.js" + }, + "types": "./dist/types/inspector/src/service.d.ts", + "environments": ["bun", "node"] + }, + "./live": { + "runtime": { + "default": "./dist/live.js" + }, + "types": "./dist/types/inspector/src/live.d.ts", + "environments": ["node"] + } + } +} diff --git a/packages/inspector/package.json b/packages/inspector/package.json index 3b8f24f812..3ab2761f6a 100644 --- a/packages/inspector/package.json +++ b/packages/inspector/package.json @@ -1,12 +1,24 @@ { "name": "@hyperframes/inspector", - "version": "0.8.140", - "private": true, + "version": "0.8.150", + "repository": { + "type": "git", + "url": "https://github.com/heygen-com/hyperframes", + "directory": "packages/inspector" + }, + "files": [ + "dist/service.js", + "dist/live.js", + "dist/inspection.js", + "dist/types", + "README.md" + ], "type": "module", "exports": { ".": { "bun": "./src/service.ts", - "types": "./dist/types/inspector/src/service.d.ts", + "import": "./src/service.ts", + "types": "./src/service.ts", "default": "./dist/service.js" }, "./live": { @@ -14,6 +26,19 @@ "default": "./dist/live.js" } }, + "publishConfig": { + "access": "public", + "exports": { + ".": { + "types": "./dist/types/inspector/src/service.d.ts", + "default": "./dist/service.js" + }, + "./live": { + "types": "./dist/types/inspector/src/live.d.ts", + "default": "./dist/live.js" + } + } + }, "scripts": { "build": "node build.mjs", "test": "vitest run", @@ -22,13 +47,13 @@ "mcp": "bun run build && bun src/mcp.ts", "test:timeline": "bun tests/timeline.ts", "test:timeline-compositions": "bun tests/timelineCompositions.ts", - "prepack": "node build.mjs", "test:live": "bun run build && bun tests/live.ts", "test:source-release": "bun tests/sourceRelease.ts", "serve:node": "node dist/server.js" }, "dependencies": { "@hyperframes/core": "workspace:*", + "@hyperframes/parsers": "workspace:*", "@jridgewell/trace-mapping": "^0.3.29", "acorn": "^8.17.0", "esbuild": "^0.25.12", diff --git a/scripts/package-size-budgets.json b/scripts/package-size-budgets.json index ba28f903b7..478af26fb6 100644 --- a/scripts/package-size-budgets.json +++ b/scripts/package-size-budgets.json @@ -4,6 +4,7 @@ "@hyperframes/core": { "packed": 1636442, "unpacked": 3903211 }, "@hyperframes/engine": { "packed": 428347, "unpacked": 1436293 }, "@hyperframes/gcp-cloud-run": { "packed": 49412, "unpacked": 192672 }, + "@hyperframes/inspector": { "packed": 808905, "unpacked": 3645432 }, "@hyperframes/lint": { "packed": 168745, "unpacked": 654607 }, "@hyperframes/parsers": { "packed": 190591, "unpacked": 831243 }, "@hyperframes/player": { "packed": 157145, "unpacked": 541601 }, diff --git a/scripts/set-version.ts b/scripts/set-version.ts index 388d1981b6..c068556b2a 100644 --- a/scripts/set-version.ts +++ b/scripts/set-version.ts @@ -25,6 +25,7 @@ const PACKAGES = [ "packages/lint", "packages/studio-server", "packages/core", + "packages/inspector", "packages/engine", "packages/player", "packages/producer",