Skip to content

Commit

Permalink
create structure, dependencies for development
Browse files Browse the repository at this point in the history
  • Loading branch information
ummcheng committed Feb 17, 2021
0 parents commit b274be5
Show file tree
Hide file tree
Showing 10 changed files with 1,278 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
build
.DS_Store
*.log
.idea
test
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Serenade for Hyper

## Development

1. Clone this repo, and run `ln -s <path> ~/.hyper_plugins/local/serenade-hyper` to create a symlink.
1. In the menu bar, use Hyper > Preferences to open the preferences file, and towards the bottom, set:
```
localPlugins: [
"serenade-hyper"
],
```
1. Run `yarn` to get dependencies, then `yarn watch` to build.
27 changes: 27 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "serenade-hyper",
"version": "0.0.1",
"description": "Serenade for Hyper",
"main": "build/main.js",
"author": "Serenade",
"license": "MIT",
"scripts": {
"build": "webpack --mode development",
"watch": "webpack --mode development --watch"
},
"devDependencies": {
"@types/mkdirp": "^1.0.1",
"@types/uuid": "^8.3.0",
"@types/ws": "^7.4.0",
"prettier": "^2.2.1",
"ts-loader": "^8.0.17",
"typescript": "^3.9.7",
"webpack": "^5.22.0",
"webpack-cli": "^4.5.0"
},
"dependencies": {
"mkdirp": "^1.0.4",
"uuid": "^8.3.1",
"ws": "^7.4.1"
}
}
20 changes: 20 additions & 0 deletions src/command-handler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import IPC from "./shared/ipc";

/*
* The CommandHandler class is a wrapper around other handlers
* for each category of commands.
*
* This needs to be composed with "mixins" since TypeScript currently
* only allows extending one class.
*/

export class CommandHandler {
// We can use the extension's IPC to send messages back to the client if needed
ipc?: IPC;

setIPC(ipc: IPC) {
this.ipc = ipc;
}
}

export default CommandHandler;
48 changes: 48 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import CommandHandler from "./command-handler";
import IPC from "./shared/ipc";

export const onRendererWindow = (window: any) => {
let commandHandler: CommandHandler;
let ipc: IPC;

function resetAndConnect() {
commandHandler = new CommandHandler();
ipc = new IPC(commandHandler, "hyper");
commandHandler.setIPC(ipc);

ipc.start();
}

// resetAndConnect();
};

export const middleware = () => (next: any) => (action: any) => {
console.log("middleware:", action);

next(action);
};

export const reduceUI = (state: any, action: any) => {
console.log("reduceUI:", state, action);
return state;
}

export const reduceSessions = (state: any, action: any) => {
console.log("reduceSessions:", state, action);
return state;
}

export const reduceTermGroups = (state: any, action: any) => {
console.log("reduceTermGroups:", state, action);
return state;
}

export const getTermProps = (uid: any, parentProps: any, props: any) => {
console.log("getTermProps:", uid, parentProps, props);
return props;
}

export const mapHyperState = (state: any, map: any) => {
console.log("mapHyperState:", state, map);
return map;
}
1 change: 1 addition & 0 deletions src/shared
21 changes: 21 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"*": ["types/*"]
},
"module": "commonjs",
"target": "es5",
"outDir": "dist",
"lib": ["es2015", "dom"],
"sourceMap": true,
"rootDir": "src",
"strict": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noUnusedParameters": true,
"preserveSymlinks": true,
"esModuleInterop": true
},
"exclude": ["node_modules"]
}
15 changes: 15 additions & 0 deletions tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"rules": {
"no-string-throw": true,
"no-unused-expression": true,
"no-duplicate-variable": true,
"curly": true,
"class-name": true,
"semicolon": [
true,
"always"
],
"triple-equals": true
},
"defaultSeverity": "warning"
}
36 changes: 36 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"use strict";

const path = require("path");

const config = {
name: "serenade-hyper",
target: "web",
entry: "./src/index.ts",
output: {
path: path.resolve(__dirname, "build"),
filename: "[name].js",
// This is necessary for exports to work correctly with Hyper!
libraryTarget: 'commonjs2',
},
resolve: {
extensions: [".tsx", ".ts", ".js"],
symlinks: false
},
module: {
rules: [
{
exclude: /node_modules/,
test: /\.tsx?$/,
use: "ts-loader"
}
]
}
}

module.exports = (env, argv) => {
if (argv.mode === 'development') {
config.devtool = 'cheap-module-source-map';
}

return config;
};
Loading

0 comments on commit b274be5

Please sign in to comment.