Compare commits

..

No commits in common. "a84aa2426b0f89c2d8ad65ebeeee60c90e1227f7" and "6352977791f7cbdc956f86511a37e8d3b575edc8" have entirely different histories.

5 changed files with 9 additions and 56 deletions

View File

@ -1 +0,0 @@
!node_modules

View File

@ -9,15 +9,10 @@
".": { ".": {
"types": "./dist/index.d.ts", "types": "./dist/index.d.ts",
"import": "./dist/index.js" "import": "./dist/index.js"
},
"./samples/*": {
"types": "./dist/samples/*.d.ts",
"import": "./dist/samples/*.js"
} }
}, },
"scripts": { "scripts": {
"build": "tsup", "build": "tsup",
"build:samples": "tsup --config tsup.samples.config.ts",
"prepare": "npm run build", "prepare": "npm run build",
"test": "vitest", "test": "vitest",
"test:run": "vitest run", "test:run": "vitest run",

View File

@ -16,6 +16,7 @@ export interface IGameContext<TState extends Record<string, unknown> = {} > {
run<T>(input: string): Promise<CommandResult<T>>; run<T>(input: string): Promise<CommandResult<T>>;
runParsed<T>(command: Command): Promise<CommandResult<T>>; runParsed<T>(command: Command): Promise<CommandResult<T>>;
prompt: <TResult,TArgs extends any[]=any[]>(def: PromptDef<TArgs>, validator: PromptValidator<TResult,TArgs>, currentPlayer?: string | null) => Promise<TResult>; prompt: <TResult,TArgs extends any[]=any[]>(def: PromptDef<TArgs>, validator: PromptValidator<TResult,TArgs>, currentPlayer?: string | null) => Promise<TResult>;
addInterruption(promise: Promise<void>): void;
// test only // test only
_state: MutableSignal<TState>; _state: MutableSignal<TState>;
@ -49,6 +50,9 @@ export function createGameContext<TState extends Record<string, unknown> = {} >(
prompt(def, validator, currentPlayer) { prompt(def, validator, currentPlayer) {
return commands.prompt(def.schema, validator, currentPlayer); return commands.prompt(def.schema, validator, currentPlayer);
}, },
addInterruption(promise) {
state.addInterruption(promise);
},
_state: state, _state: state,
_commands: commands, _commands: commands,

View File

@ -1,6 +1,8 @@
import {Part} from "boardgame-core"; import {
import {createRegion} from "boardgame-core"; createGameCommandRegistry, Part, createRegion,
import {createGameCommandRegistry, createPromptDef, IGameContext} from "boardgame-core"; IGameContext
} from '@/index';
import {createPromptDef} from "@/core/game";
const BOARD_SIZE = 3; const BOARD_SIZE = 3;
const MAX_TURNS = BOARD_SIZE * BOARD_SIZE; const MAX_TURNS = BOARD_SIZE * BOARD_SIZE;

View File

@ -1,47 +0,0 @@
import { defineConfig } from 'tsup';
import { fileURLToPath } from 'url';
import * as fs from 'fs';
import * as path from 'path';
import {csvLoader} from 'inline-schema/csv-loader/esbuild';
const srcDir = fileURLToPath(new URL('./src', import.meta.url));
const samplesDir = fileURLToPath(new URL('./src/samples', import.meta.url));
// Auto-discover samples entry points
function getSamplesEntries(): Record<string, string> {
const entries: Record<string, string> = {};
if (!fs.existsSync(samplesDir)) return entries;
for (const item of fs.readdirSync(samplesDir)) {
const fullPath = path.join(samplesDir, item);
if (fs.statSync(fullPath).isDirectory()) {
// Directory sample (e.g. boop) - look for index.ts
const indexPath = path.join(fullPath, 'index.ts');
if (fs.existsSync(indexPath)) {
entries[item] = indexPath;
}
} else if (item.endsWith('.ts')) {
// Single file sample (e.g. tic-tac-toe.ts)
entries[item.replace('.ts', '')] = fullPath;
}
}
return entries;
}
const samplesEntries = getSamplesEntries();
export default defineConfig({
entry: samplesEntries,
format: ['esm'],
dts: true,
clean: true,
sourcemap: true,
outDir: 'dist/samples',
external: ['@preact/signals-core', 'mutative', 'inline-schema', 'boardgame-core'],
esbuildPlugins: [csvLoader()],
esbuildOptions(options) {
options.alias = {
'@': srcDir,
};
},
});