diff --git a/app/src/utils/api.ts b/app/src/utils/api.ts index 94a987d..a0bbef5 100644 --- a/app/src/utils/api.ts +++ b/app/src/utils/api.ts @@ -1,5 +1,4 @@ import axios from 'axios' -import { Session } from '../types' const api = axios.create({ baseURL: '/api/v1', diff --git a/packages/file-graph/package.json b/packages/file-graph/package.json index 5d3f4d2..79cc492 100644 --- a/packages/file-graph/package.json +++ b/packages/file-graph/package.json @@ -1,13 +1,17 @@ { "name": "@linux-odyssey/file-graph", "version": "1.0.0", - "type": "module", - "main": "dist/index.js", - "types": "dist/index.d.ts", - "exports": "./dist/index.js", + "main": "./dist/cjs/index.js", + "types": "./dist/types/index.d.ts", + "exports": { + ".": { + "require": "./dist/cjs/index.js", + "types": "./dist/types/index.d.ts" + } + }, "license": "MIT", "scripts": { - "build": "tsc", + "build": "tsc -p tsconfig.cjs.json", "dev": "tsc -w", "test": "yarn build && jest" } diff --git a/packages/file-graph/src/index.ts b/packages/file-graph/src/index.ts index f9dc793..40b8ea8 100644 --- a/packages/file-graph/src/index.ts +++ b/packages/file-graph/src/index.ts @@ -1,3 +1,10 @@ export { default as File, FileObject } from './file.js' export { default as FileNode } from './fileNode.js' export { default as FileGraph, Event } from './fileGraph.js' + +export interface INode { + path: string + type: string + discovered: boolean + children?: INode[] +} diff --git a/packages/file-graph/tsconfig.cjs.json b/packages/file-graph/tsconfig.cjs.json new file mode 100644 index 0000000..0a63fde --- /dev/null +++ b/packages/file-graph/tsconfig.cjs.json @@ -0,0 +1,9 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "CommonJS", + "moduleResolution": "Node", + "outDir": "./dist/cjs", + "declarationDir": "./dist/types" + } +} diff --git a/packages/file-graph/tsconfig.json b/packages/file-graph/tsconfig.json index ccaf320..83e051b 100644 --- a/packages/file-graph/tsconfig.json +++ b/packages/file-graph/tsconfig.json @@ -3,7 +3,9 @@ "compilerOptions": { "rootDir": "src", "composite": true, - "outDir": "./dist" + "module": "NodeNext", + "outDir": "./dist/esm", + "declarationDir": "./dist/types" }, "include": ["src"], "exclude": ["node_modules", "dist"] diff --git a/packages/game/package.json b/packages/game/package.json index b6b6072..b7bc21d 100644 --- a/packages/game/package.json +++ b/packages/game/package.json @@ -10,6 +10,7 @@ "build": "tsc -b" }, "dependencies": { + "@linux-odyssey/file-graph": "*", "zod": "^3.23.8" } } diff --git a/packages/game/src/Session.ts b/packages/game/src/Session.ts index c0c72c6..d3e6ed8 100644 --- a/packages/game/src/Session.ts +++ b/packages/game/src/Session.ts @@ -1,3 +1,4 @@ +import { FileGraph, INode } from '@linux-odyssey/file-graph' import { Quest } from './Quest' import { IQuest, @@ -8,17 +9,19 @@ import { ITask, } from './schema' -export class GameSession implements ISession { +export class GameSession { private completed: string[] = [] private quest: Quest + private graph: FileGraph constructor( - { completedEvents }: ISession, + { completedEvents, graph }: ISession, quest: IQuest, checker: IFileExistenceChecker ) { this.completed = completedEvents this.quest = new Quest(quest, checker) + this.graph = new FileGraph(graph) } get completedEvents() { @@ -48,4 +51,8 @@ export class GameSession implements ISession { getTasks(): ITask[] { return this.quest.getTasks(this.completed) } + + getGraph(): INode { + return this.graph + } } diff --git a/packages/game/src/schema/index.ts b/packages/game/src/schema/index.ts index 962afb8..783c5c9 100644 --- a/packages/game/src/schema/index.ts +++ b/packages/game/src/schema/index.ts @@ -1,3 +1,5 @@ +import { INode } from '@linux-odyssey/file-graph' + export * from './condition.js' export * from './stage.js' export * from './requirements.js' @@ -14,6 +16,7 @@ export interface ICommand { export interface ISession { completedEvents: string[] + graph: INode } export interface ITask { diff --git a/packages/game/tsconfig.json b/packages/game/tsconfig.json index e0965f1..4cce621 100644 --- a/packages/game/tsconfig.json +++ b/packages/game/tsconfig.json @@ -3,7 +3,9 @@ "compilerOptions": { "outDir": "./dist", "rootDir": "./src", - "composite": true + "composite": true, + "module": "CommonJS", + "moduleResolution": "Node" }, "include": ["src"] }