Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,8 @@ jobs:

- name: Verify player SEA bundle
if: needs.changes.outputs.sea_player_changed == 'true'
run: pnpm exec tsx scripts/build-sea.ts --package player --bundle-only
run: node --conditions=source scripts/build-sea.ts --package player --bundle-only

- name: Verify audio-renderer SEA bundle
if: needs.changes.outputs.sea_audio_renderer_changed == 'true'
run: pnpm exec tsx scripts/build-sea.ts --package audio-renderer --bundle-only
run: node --conditions=source scripts/build-sea.ts --package audio-renderer --bundle-only
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:
shell: bash
run: |
set -euo pipefail
pnpm exec tsx --tsconfig tsconfig.typecheck.json scripts/release/resolve-package-releases.ts \
node --conditions=source scripts/release/resolve-package-releases.ts \
--base "${{ steps.release_refs.outputs.release_base }}" \
--head "${{ steps.release_refs.outputs.release_target }}" \
--github-output "$GITHUB_OUTPUT" \
Expand Down Expand Up @@ -403,7 +403,7 @@ jobs:
RELEASE_TARGET: ${{ needs.prepare.outputs.release_target }}
run: |
set -euo pipefail
pnpm exec tsx --tsconfig tsconfig.typecheck.json scripts/release/create-package-releases.ts \
node --conditions=source scripts/release/create-package-releases.ts \
--repo "$GITHUB_REPOSITORY" \
--release-target "$RELEASE_TARGET" \
--releases-json tmp/release-data/releases.json \
Expand Down
19 changes: 15 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"private": true,
"description": "TypeScript monorepo for the be-music BMS/BMSON toolchain",
"license": "MIT",
"type": "module",
"scripts": {
"build": "pnpm -r --sort --workspace-concurrency=Infinity run build",
"clean": "pnpm -r run clean && rimraf coverage \"packages/*/node_modules/.vite\"",
Expand All @@ -17,9 +18,9 @@
"format:check": "pnpm -r --parallel run format:check",
"test": "vitest run",
"test:coverage": "vitest run --coverage",
"bench": "tsx --tsconfig tsconfig.typecheck.json scripts/bench/exports.ts",
"bench:aggregate": "tsx --tsconfig tsconfig.typecheck.json scripts/bench/aggregate-results.ts",
"bench:compare": "tsx --tsconfig tsconfig.typecheck.json scripts/bench/compare-results.ts",
"bench": "node --conditions=source scripts/bench/exports.ts",
"bench:aggregate": "node --conditions=source scripts/bench/aggregate-results.ts",
"bench:compare": "node --conditions=source scripts/bench/compare-results.ts",
"player": "pnpm --filter @be-music/player-tui run dev",
"playlog": "pnpm --filter @be-music/player-tui run playlog",
"player:web": "pnpm --filter @be-music/player-web-demo run dev",
Expand All @@ -33,6 +34,17 @@
"stringify": "pnpm --filter @be-music/stringifier run dev"
},
"devDependencies": {
"@be-music/audio-renderer": "workspace:*",
"@be-music/chart": "workspace:*",
"@be-music/editor": "workspace:*",
"@be-music/json": "workspace:*",
"@be-music/lr2-skin": "workspace:*",
"@be-music/parser": "workspace:*",
"@be-music/player": "workspace:*",
"@be-music/player-tui": "workspace:*",
"@be-music/player-web": "workspace:*",
"@be-music/stringifier": "workspace:*",
"@be-music/utils": "workspace:*",
"@changesets/cli": "^3.0.1",
"@types/node": "^26.4.0",
"@vitest/coverage-v8": "^4.1.10",
Expand All @@ -41,7 +53,6 @@
"rimraf": "^6.0.1",
"tinybench": "^6.1.3",
"tsdown": "^0.22.14",
"tsx": "^4.23.13",
"typescript": "^7.0.2",
"vite": "^8.2.2",
"vitest": "^4.1.10"
Expand Down
6 changes: 3 additions & 3 deletions packages/audio-renderer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
"scripts": {
"build:bundle": "tsdown",
"build": "tsdown",
"build:sea": "tsx ../../scripts/build-sea.ts --package audio-renderer",
"build:sea": "node --conditions=source ../../scripts/build-sea.ts --package audio-renderer",
"clean": "rimraf dist tsconfig.tsbuildinfo",
"dev": "tsx --tsconfig ../../tsconfig.typecheck.json src/cli.ts",
"dev": "node --conditions=source src/cli.ts",
"typecheck": "tsc -p tsconfig.typecheck.json --pretty",
"lint": "oxlint .",
"lint:fix": "oxlint . --fix",
"format": "oxfmt . --write",
"format:check": "oxfmt . --check",
"bench": "tsx --tsconfig ../../tsconfig.typecheck.json scripts/bench.ts"
"bench": "node --conditions=source scripts/bench.ts"
},
"dependencies": {
"@be-music/chart": "workspace:*",
Expand Down
1 change: 1 addition & 0 deletions packages/audio-renderer/tsdown.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ export default createPackageTsdownConfig({
entries: {
index: 'src/index.ts',
cli: 'src/cli.ts',
'core/triggers': 'src/core/triggers.ts',
},
});
2 changes: 1 addition & 1 deletion packages/beatoraja-skin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"lint:fix": "oxlint . --fix",
"format": "oxfmt . --write",
"format:check": "oxfmt . --check",
"bench": "tsx --tsconfig ../../tsconfig.typecheck.json scripts/bench.ts"
"bench": "node --conditions=source scripts/bench.ts"
},
"dependencies": {
"@be-music/utils": "workspace:*",
Expand Down
19 changes: 17 additions & 2 deletions packages/beatoraja-skin/src/fengari-types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,22 @@ declare module 'fengari' {
}

// `fengari-web` re-exports the same `lua` / `lauxlib` / `lualib` / `to_luastring` shapes as `fengari` itself, so we
// declare it as the same module surface.
// declare it as the same module surface. Unlike `fengari`, `fengari-web` ships a webpack UMD bundle whose
// `module.exports` is built at runtime (an IIFE return value) rather than plain `exports.x = ...` assignments, so
// Node's static cjs-module-lexer can't discover named exports on it — the package must be imported as a single
// default value and destructured, hence the shape below is a default export instead of `fengari`'s named ones.
declare module 'fengari-web' {
export { lua_State, LuaCFunction, lua, lauxlib, lualib, to_luastring, to_jsstring, luastring_of } from 'fengari';
import type { lua, lauxlib, lualib, lua_State, LuaCFunction, to_luastring, to_jsstring, luastring_of } from 'fengari';

export type { lua_State, LuaCFunction };

const fengariWeb: {
lua: typeof lua;
lauxlib: typeof lauxlib;
lualib: typeof lualib;
to_luastring: typeof to_luastring;
to_jsstring: typeof to_jsstring;
luastring_of: typeof luastring_of;
};
export default fengariWeb;
}
8 changes: 6 additions & 2 deletions packages/beatoraja-skin/src/lua.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
// The reference beatoraja themes only use `base` / `table` / `string` / `math` so the strip is non-disruptive.

import { normalizePath } from '@be-music/utils/core';
import { lauxlib, lua, lualib, to_luastring } from 'fengari-web';
import fengariWeb from 'fengari-web';
import type { lua_State, LuaCFunction } from 'fengari-web';

const { lauxlib, lua, lualib, to_luastring } = fengariWeb;
const {
LUA_OK,
LUA_REGISTRYINDEX,
Expand Down Expand Up @@ -262,8 +263,11 @@ class LuaRuntimeOwner {
private refs = 0;
private closed = false;
context: BeatorajaLuaRuntimeContext | undefined;
readonly L: lua_State;

constructor(readonly L: lua_State) {}
constructor(L: lua_State) {
this.L = L;
}

makeFunction(ref: number): BeatorajaLuaFunctionValue {
this.refs += 1;
Expand Down
2 changes: 1 addition & 1 deletion packages/chart/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"lint:fix": "oxlint . --fix",
"format": "oxfmt . --write",
"format:check": "oxfmt . --check",
"bench": "tsx --tsconfig ../../tsconfig.typecheck.json scripts/bench.ts"
"bench": "node --conditions=source scripts/bench.ts"
},
"dependencies": {
"@be-music/json": "workspace:*"
Expand Down
4 changes: 2 additions & 2 deletions packages/editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
"build:bundle": "tsdown",
"build": "tsdown",
"clean": "rimraf dist tsconfig.tsbuildinfo",
"dev": "tsx --tsconfig ../../tsconfig.typecheck.json src/cli.ts",
"dev": "node --conditions=source src/cli.ts",
"typecheck": "tsc -p tsconfig.typecheck.json --pretty",
"lint": "oxlint .",
"lint:fix": "oxlint . --fix",
"format": "oxfmt . --write",
"format:check": "oxfmt . --check",
"bench": "tsx --tsconfig ../../tsconfig.typecheck.json scripts/bench.ts"
"bench": "node --conditions=source scripts/bench.ts"
},
"dependencies": {
"@be-music/chart": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/json/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"lint:fix": "oxlint . --fix",
"format": "oxfmt . --write",
"format:check": "oxfmt . --check",
"bench": "tsx --tsconfig ../../tsconfig.typecheck.json scripts/bench.ts"
"bench": "node --conditions=source scripts/bench.ts"
},
"dependencies": {
"@be-music/utils": "workspace:*"
Expand Down
2 changes: 1 addition & 1 deletion packages/lr2-skin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"lint:fix": "oxlint . --fix",
"format": "oxfmt . --write",
"format:check": "oxfmt . --check",
"bench": "tsx --tsconfig ../../tsconfig.typecheck.json scripts/bench.ts"
"bench": "node --conditions=source scripts/bench.ts"
},
"dependencies": {
"@be-music/chart": "workspace:*",
Expand Down
4 changes: 2 additions & 2 deletions packages/parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
"build:bundle": "tsdown",
"build": "tsdown",
"clean": "rimraf dist tsconfig.tsbuildinfo",
"dev": "tsx --tsconfig ../../tsconfig.typecheck.json src/cli.ts",
"dev": "node --conditions=source src/cli.ts",
"typecheck": "tsc -p tsconfig.typecheck.json --pretty",
"lint": "oxlint .",
"lint:fix": "oxlint . --fix",
"format": "oxfmt . --write",
"format:check": "oxfmt . --check",
"bench": "tsx --tsconfig ../../tsconfig.typecheck.json scripts/bench.ts"
"bench": "node --conditions=source scripts/bench.ts"
},
"dependencies": {
"@be-music/chart": "workspace:*",
Expand Down
12 changes: 6 additions & 6 deletions packages/player-tui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@
"scripts": {
"build:bundle": "tsdown",
"build": "tsdown",
"build:sea": "tsx ../../scripts/build-sea.ts --package player",
"build:sea": "node --conditions=source ../../scripts/build-sea.ts --package player",
"clean": "rimraf dist tsconfig.tsbuildinfo",
"dev": "tsx --tsconfig ../../tsconfig.typecheck.json src/cli.ts",
"playlog": "tsx --tsconfig ../../tsconfig.typecheck.json src/playlog-cli.ts",
"diag:keyboard": "tsx --tsconfig ../../tsconfig.typecheck.json src/keyboard-diagnostic.ts",
"diag:gameplay-input": "tsx --tsconfig ../../tsconfig.typecheck.json src/gameplay-input-diagnostic.ts",
"dev": "node --conditions=source src/cli.ts",
"playlog": "node --conditions=source src/playlog-cli.ts",
"diag:keyboard": "node --conditions=source src/keyboard-diagnostic.ts",
"diag:gameplay-input": "node --conditions=source src/gameplay-input-diagnostic.ts",
"typecheck": "tsc -p tsconfig.typecheck.json --pretty",
"lint": "oxlint .",
"lint:fix": "oxlint . --fix",
"format": "oxfmt . --write",
"format:check": "oxfmt . --check",
"bench": "tsx --tsconfig ../../tsconfig.typecheck.json scripts/bench.ts"
"bench": "node --conditions=source scripts/bench.ts"
},
"dependencies": {
"@be-music/audio-renderer": "workspace:*",
Expand Down
13 changes: 0 additions & 13 deletions packages/player-tui/src/bga-video.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { readFile } from 'node:fs/promises';
import { basename } from 'node:path';
import { fileURLToPath } from 'node:url';
import { Worker } from 'node:worker_threads';
import { createAbortError, isAbortError, throwIfAborted } from '@be-music/utils/core';
import { loadOptionalNodeModule } from '@be-music/utils/optional-node-module';
Expand Down Expand Up @@ -244,7 +243,6 @@ export async function decodeVideoFramesToSourceFramesInWorker(
: new Worker(resolveBgaVideoWorkerUrl(), {
workerData: workerInitData,
execArgv: resolveBgaVideoWorkerExecArgv(),
env: resolveBgaVideoWorkerEnv(),
});

return await new Promise((resolve, reject) => {
Expand Down Expand Up @@ -668,14 +666,3 @@ function resolveBgaVideoWorkerExecArgv(): string[] {
return [...process.execArgv, '--conditions=source'];
}

function resolveBgaVideoWorkerEnv(): NodeJS.ProcessEnv {
if (!import.meta.url.endsWith('.ts')) {
return process.env;
}

return {
...process.env,
TSX_TSCONFIG_PATH:
process.env.TSX_TSCONFIG_PATH ?? fileURLToPath(new URL('../../../tsconfig.typecheck.json', import.meta.url)),
};
}
14 changes: 0 additions & 14 deletions packages/player-tui/src/node/node-gameplay-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { effect } from 'alien-signals';
import { createAbortError } from '@be-music/utils/core';
import type { LogEntry } from '@be-music/utils/log';
import type { BeMusicJson } from '@be-music/json';
import { fileURLToPath } from 'node:url';
import { Worker, type MessagePort } from 'node:worker_threads';
import { createPlayerInputSignalBus } from '@be-music/player/core/input-signal-bus';
import type { PlayerLoadProgress, PlayerSummary } from '@be-music/player/core/engine';
Expand Down Expand Up @@ -42,7 +41,6 @@ export async function runNodeGameplayRuntime(options: NodeGameplayRuntimeOptions
: new Worker(resolveNodeGameplayWorkerUrl(), {
workerData: createWorkerInitData(options),
execArgv: resolveNodeGameplayWorkerExecArgv(),
env: resolveNodeGameplayWorkerEnv(),
});
const writeOutput = options.writeOutput ?? ((text: string) => process.stdout.write(text));

Expand Down Expand Up @@ -310,18 +308,6 @@ function resolveNodeGameplayWorkerExecArgv(): string[] {
return [...process.execArgv, '--conditions=source'];
}

function resolveNodeGameplayWorkerEnv(): NodeJS.ProcessEnv {
if (!import.meta.url.endsWith('.ts')) {
return process.env;
}

return {
...process.env,
TSX_TSCONFIG_PATH:
process.env.TSX_TSCONFIG_PATH ?? fileURLToPath(new URL('../../../../tsconfig.typecheck.json', import.meta.url)),
};
}

function postWorkerMessage(
worker: Worker,
message: NodeGameplayWorkerInboundMessage,
Expand Down
6 changes: 1 addition & 5 deletions packages/player-tui/src/node/node-ui-runtime.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,9 @@ describe('node ui runtime', () => {
expect(messagesOfKind(worker, 'dispose')).toHaveLength(1);
});

test('passes tsx tsconfig path to the UI worker in source runs', async () => {
test('passes the source-conditions exec flag to the UI worker in source runs', async () => {
const uiSignals = createPlayerUiSignalBus(createFrame());
const runtime = await createNodeUiRuntime(createContext(uiSignals));
const workerEnv = workerState.lastWorkerOptions?.env;
const workerEnvObject = typeof workerEnv === 'object' ? (workerEnv as NodeJS.ProcessEnv) : undefined;
const workerExecArgv = workerState.lastWorkerOptions?.execArgv;
const workerData = workerState.lastWorkerOptions?.workerData as
| {
Expand All @@ -235,8 +233,6 @@ describe('node ui runtime', () => {
}
| undefined;

expect(typeof workerEnv).toBe('object');
expect(workerEnvObject?.TSX_TSCONFIG_PATH).toContain('tsconfig.typecheck.json');
expect(workerExecArgv).toContain('--conditions=source');
expect(workerData).toMatchObject({
stdinIsTTY: Boolean(process.stdin.isTTY),
Expand Down
14 changes: 0 additions & 14 deletions packages/player-tui/src/node/node-ui-runtime.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { createAbortError, isAbortError } from '@be-music/utils/core';
import type { LogEntry } from '@be-music/utils/log';
import { effect } from 'alien-signals';
import { fileURLToPath } from 'node:url';
import { MessageChannel, type MessagePort, Worker } from 'node:worker_threads';
import type { LaneBinding } from '../manual-input.ts';
import type { PlayerStateSignals } from '@be-music/player/state-signals';
Expand Down Expand Up @@ -62,7 +61,6 @@ export async function createNodeUiRuntime(options: NodeUiRuntimeOptions): Promis
: new Worker(resolveNodeUiWorkerUrl(), {
workerData: createWorkerInitData(options),
execArgv: resolveNodeUiWorkerExecArgv(),
env: resolveNodeUiWorkerEnv(),
});
const workerReady = await waitForWorkerReady(worker, options.loadSignal, options.onBgaLoadProgress, options.onLog);
if (!workerReady.enabled) {
Expand Down Expand Up @@ -326,18 +324,6 @@ function resolveNodeUiWorkerExecArgv(): string[] {
return [...process.execArgv, '--conditions=source'];
}

function resolveNodeUiWorkerEnv(): NodeJS.ProcessEnv {
if (!import.meta.url.endsWith('.ts')) {
return process.env;
}

return {
...process.env,
TSX_TSCONFIG_PATH:
process.env.TSX_TSCONFIG_PATH ?? fileURLToPath(new URL('../../../../tsconfig.typecheck.json', import.meta.url)),
};
}

async function waitForWorkerReady(
worker: Worker,
signal: AbortSignal | undefined,
Expand Down
4 changes: 3 additions & 1 deletion packages/player-web-demo/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,9 @@ class PlayerWebDemoApp {
* disarmAutoRecord} so the flag doesn't survive into a future session that shouldn't be auto-captured.
*/
private autoRecordArmed = false;
public constructor(private readonly elements: PlayerWebDemoElements) {
private readonly elements: PlayerWebDemoElements;
public constructor(elements: PlayerWebDemoElements) {
this.elements = elements;
this.guiState = {
autoPlay: false,
autoPauseOnBlur: false,
Expand Down
2 changes: 1 addition & 1 deletion packages/player-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"lint:fix": "oxlint . --fix",
"format": "oxfmt . --write",
"format:check": "oxfmt . --check",
"bench": "tsx --tsconfig ../../tsconfig.typecheck.json scripts/bench.ts"
"bench": "node --conditions=source scripts/bench.ts"
},
"dependencies": {
"@be-music/audio-renderer": "workspace:*",
Expand Down
Loading