From f1019fe92d89b6285be4e56543e53b9dd908ddb6 Mon Sep 17 00:00:00 2001 From: TheoryOfNekomata Date: Mon, 30 Nov 2020 11:55:19 +0800 Subject: [PATCH] Separate project Extract project from monorepo. --- .npmignore | 2 ++ README.md | 3 +++ package.json | 11 +++++++++++ src/plugin.ts | 5 +++++ src/storage.ts | 16 ++++++++++++++++ tsconfig.json | 28 ++++++++++++++++++++++++++++ 6 files changed, 65 insertions(+) create mode 100644 .npmignore create mode 100644 README.md create mode 100644 package.json create mode 100644 src/plugin.ts create mode 100644 src/storage.ts create mode 100644 tsconfig.json diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..bf193c2 --- /dev/null +++ b/.npmignore @@ -0,0 +1,2 @@ +*.ts +tsconfig.json diff --git a/README.md b/README.md new file mode 100644 index 0000000..4a1d8fa --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Zeichen - Core + +Library for authoring Zeichen plugins and themes. diff --git a/package.json b/package.json new file mode 100644 index 0000000..14a2acd --- /dev/null +++ b/package.json @@ -0,0 +1,11 @@ +{ + "name": "zeichen-core", + "description": "Library for authoring Zeichen plugins and themes.", + "version": "0.1.0", + "devDependencies": { + "typescript": "^4.0.3" + }, + "scripts": { + "build": "tsc **/*.ts" + } +} diff --git a/src/plugin.ts b/src/plugin.ts new file mode 100644 index 0000000..0e7ef4a --- /dev/null +++ b/src/plugin.ts @@ -0,0 +1,5 @@ +export type State = { + currentUserId: string, +} + +export type Plugin = (config: T) => (state: State) => void diff --git a/src/storage.ts b/src/storage.ts new file mode 100644 index 0000000..fbb7d40 --- /dev/null +++ b/src/storage.ts @@ -0,0 +1,16 @@ +export default interface Storage { + queryItems(): Promise + saveItem(item: T): Promise + deleteItem(item: T): Promise +} + +export interface Collection { + items: T[], + lastModifiedBy: string, + lastModifiedAt: Date, +} + +export type Serializer = (t: T) => string +export type Deserializer = (s: string) => T + +export class OutOfSyncError {} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..2c4714d --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "target": "es6", + "lib": [ + "dom", + "dom.iterable", + "esnext" + ], + "skipLibCheck": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "forceConsistentCasingInFileNames": true, + "module": "esnext", + "moduleResolution": "node", + "declaration": true, + "declarationDir": "./dist", + "emitDeclarationOnly": true, + "sourceMap": true, + "strict": false + }, + "exclude": [ + "node_modules", + "**/*.test.ts" + ], + "include": [ + "**/*.ts" + ] +}