Compare commits
No commits in common. "a84aa2426b0f89c2d8ad65ebeeee60c90e1227f7" and "6352977791f7cbdc956f86511a37e8d3b575edc8" have entirely different histories.
a84aa2426b
...
6352977791
|
|
@ -1 +0,0 @@
|
|||
!node_modules
|
||||
|
|
@ -9,15 +9,10 @@
|
|||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"import": "./dist/index.js"
|
||||
},
|
||||
"./samples/*": {
|
||||
"types": "./dist/samples/*.d.ts",
|
||||
"import": "./dist/samples/*.js"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsup",
|
||||
"build:samples": "tsup --config tsup.samples.config.ts",
|
||||
"prepare": "npm run build",
|
||||
"test": "vitest",
|
||||
"test:run": "vitest run",
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ export interface IGameContext<TState extends Record<string, unknown> = {} > {
|
|||
run<T>(input: string): 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>;
|
||||
addInterruption(promise: Promise<void>): void;
|
||||
|
||||
// test only
|
||||
_state: MutableSignal<TState>;
|
||||
|
|
@ -49,6 +50,9 @@ export function createGameContext<TState extends Record<string, unknown> = {} >(
|
|||
prompt(def, validator, currentPlayer) {
|
||||
return commands.prompt(def.schema, validator, currentPlayer);
|
||||
},
|
||||
addInterruption(promise) {
|
||||
state.addInterruption(promise);
|
||||
},
|
||||
|
||||
_state: state,
|
||||
_commands: commands,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
import {Part} from "boardgame-core";
|
||||
import {createRegion} from "boardgame-core";
|
||||
import {createGameCommandRegistry, createPromptDef, IGameContext} from "boardgame-core";
|
||||
import {
|
||||
createGameCommandRegistry, Part, createRegion,
|
||||
IGameContext
|
||||
} from '@/index';
|
||||
import {createPromptDef} from "@/core/game";
|
||||
|
||||
const BOARD_SIZE = 3;
|
||||
const MAX_TURNS = BOARD_SIZE * BOARD_SIZE;
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
},
|
||||
});
|
||||
Loading…
Reference in New Issue