Skip to content

Commit

Permalink
Merge pull request #9 from rustymotors/refactor
Browse files Browse the repository at this point in the history
refactor: use packages
  • Loading branch information
drazisil authored May 31, 2024
2 parents 25720e7 + c18adb6 commit c49db3c
Show file tree
Hide file tree
Showing 13 changed files with 1,531 additions and 1,248 deletions.
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
link-workspace-packages: true
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
{
"name": "probable-spoon",
"name": "obsidian",
"version": "1.0.0",
"description": "",
"exports": "./src/index.js",
"exports": "./packages/main/src/index.js",
"type": "module",
"private": true,
"scripts": {
"start": "node server.js",
"lint": "eslint .",
"test": "vitest run"
},
"keywords": [],
"author": "",
"license": "ISC",
"license": "LGPL-3.0-or-later",
"devDependencies": {
"@eslint/js": "^9.3.0",
"@types/node": "^20.12.12",
Expand All @@ -21,6 +22,7 @@
},
"packageManager": "[email protected]+sha256.30a1801ac4e723779efed13a21f4c39f9eb6c9fbb4ced101bce06b422593d7c9",
"dependencies": {
"express": "^4.19.2"
"express": "^4.19.2",
"obsidian-main": "link:packages/main"
}
}
6 changes: 2 additions & 4 deletions jsconfig.json → packages/main/jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
{
"compilerOptions": {
"module": "ESNext",
"moduleResolution": "Bundler",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"target": "ES2020",
"jsx": "react",
"allowImportingTsExtensions": true,
"checkJs": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
Expand Down
27 changes: 27 additions & 0 deletions packages/main/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "obsidian-main",
"version": "1.0.0",
"description": "",
"exports": "./src/index.js",
"type": "module",
"private": true,
"scripts": {
"start": "node server.js",
"test": "vitest run"
},
"keywords": [],
"author": "",
"license": "LGPL-3.0-or-later",
"devDependencies": {
"@eslint/js": "^9.3.0",
"@types/node": "^20.12.12",
"@vitest/coverage-v8": "^1.6.0",
"eslint": "^9.3.0",
"globals": "^15.3.0",
"vitest": "^1.6.0"
},
"packageManager": "[email protected]+sha256.30a1801ac4e723779efed13a21f4c39f9eb6c9fbb4ced101bce06b422593d7c9",
"dependencies": {
"express": "^4.19.2"
}
}
14 changes: 2 additions & 12 deletions src/MainLoop.js → packages/main/src/MainLoop.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
import { emitKeypressEvents } from "node:readline";
import { _atExit } from "./index.js";

/**
* @typedef KeypressEvent
* @type {object}
* @property {string} sequence
* @property {string} name
* @property {boolean} ctrl
* @property {boolean} meta
* @property {boolean} shift
*/
import { _atExit } from "obsidian-main";

export class MainLoop {
/** @type {NodeJS.Timeout | undefined} */
Expand All @@ -27,7 +17,7 @@ export class MainLoop {

/**
*
* @param {KeypressEvent} key
* @param {import("obsidian-main").KeypressEvent} key
*/
handleKeypressEvent(key) {
const keyString = key.sequence;
Expand Down
File renamed without changes.
File renamed without changes.
13 changes: 13 additions & 0 deletions packages/main/src/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
declare module "obsidian-main" {
export default function main(): void;

export interface KeypressEvent {
sequence: string;
name: string;
ctrl: boolean;
meta: boolean;
shift: boolean;
}

export function _atExit(): void;
}
4 changes: 0 additions & 4 deletions src/index.js → packages/main/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import { MainLoop } from "./MainLoop.js";
import { TCPServer } from "./TCPServer.js";
import { WebServer } from "./WebServer.js";

// === GLOBALS ===

/** @type {WebServer} */
let authServer;

Expand All @@ -29,8 +27,6 @@ let loginServer;
/** @type {TCPServer} */
let personaServer;

// === FUNCTIONS ===

/**
*
* @param {Buffer} data
Expand Down
Loading

0 comments on commit c49db3c

Please sign in to comment.