Skip to content

Commit cf31854

Browse files
author
Yan Heng
committed
feat: 创建history插件
1 parent 5a9797b commit cf31854

File tree

12 files changed

+152
-55
lines changed

12 files changed

+152
-55
lines changed

packages/core/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1+
export * from '@pictode/utils';
12
export * from './context';
2-
33
export * from './types';

packages/core/src/types.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import Context from './context';
33

44
export interface Plugin {
55
name: string;
6-
install: (context: Context, ...options: any[]) => any;
7-
dispose: () => void;
8-
enable?: () => void;
9-
disable?: () => void;
10-
isEnabled?: () => boolean;
6+
install(context: Context, ...options: any[]): any;
7+
dispose(): void;
8+
enable?(): void;
9+
disable?(): void;
10+
isEnabled?(): boolean;
1111
}
1212

1313
export namespace Cmd {
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "@pictode/plugin-history",
3+
"private": true,
4+
"version": "0.0.1",
5+
"main": "dist/pictode-plugin-history.umd.js",
6+
"module": "dist/pictode-plugin-history.mjs",
7+
"types": "types/index.d.ts",
8+
"exports": {
9+
".": {
10+
"import": "./dist/pictode-plugin-history.mjs",
11+
"require": "./dist/pictode-plugin-history.umd.js"
12+
}
13+
},
14+
"scripts": {
15+
"build": "npm run build:type && vite build",
16+
"build:type": "npm run clear:type && tsc --declaration --emitDeclarationOnly --project tsconfig.build.json",
17+
"clear:type": "rimraf ./types"
18+
},
19+
"dependencies": {
20+
"@pictode/core": "workspace:^0.0.1",
21+
"@pictode/utils": "workspace:^0.0.1",
22+
"dot": "2.0.0-beta.1",
23+
"rimraf": "^3.0.2",
24+
"roughjs": "^4.5.2"
25+
},
26+
"devDependencies": {
27+
"@types/fabric": "^5.3.3",
28+
"typescript": "^4.9.3",
29+
"vite": "^4.1.0"
30+
}
31+
}

packages/plugin-history/src/api.ts

Whitespace-only changes.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { BaseService, Context, Plugin } from '@pictode/core';
2+
3+
export class History extends BaseService implements Plugin {
4+
public name: string = 'history';
5+
private context?: Context;
6+
7+
constructor() {
8+
super();
9+
}
10+
11+
public install(context: Context) {
12+
this.context = context;
13+
}
14+
15+
public dispose(): void {
16+
throw new Error('Method not implemented.');
17+
}
18+
19+
public enable(): void {
20+
throw new Error('Method not implemented.');
21+
}
22+
23+
public disable(): void {
24+
throw new Error('Method not implemented.');
25+
}
26+
27+
public isEnabled(): boolean {
28+
throw new Error('Method not implemented.');
29+
}
30+
}
31+
32+
export default History;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export interface Options {
2+
enabled?: boolean;
3+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference types="vite/client" />
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
"compilerOptions": {
4+
"baseUrl": ".",
5+
"declaration": true,
6+
"declarationDir": "types",
7+
"forceConsistentCasingInFileNames": true,
8+
"paths": {}
9+
},
10+
"include": ["src"]
11+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
"compilerOptions": {
4+
"baseUrl": "../.."
5+
},
6+
"exclude": ["**/dist/**/*"]
7+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { join } from 'path';
2+
3+
import { defineConfig } from 'vite';
4+
5+
import pkg from './package.json';
6+
7+
const deps = Object.keys(pkg.dependencies);
8+
9+
export default defineConfig({
10+
resolve: {
11+
alias: [
12+
{ find: /^@pictode\/utils/, replacement: join(__dirname, '../packages/utils/src/index.ts') },
13+
{ find: /^@pictode\/core/, replacement: join(__dirname, '../packages/core/src/index.ts') },
14+
],
15+
},
16+
build: {
17+
cssCodeSplit: false,
18+
sourcemap: true,
19+
minify: false,
20+
target: 'esnext',
21+
lib: {
22+
entry: 'src/index.ts',
23+
name: 'PictodePluginHistory',
24+
fileName: 'pictode-plugin-history',
25+
},
26+
rollupOptions: {
27+
external(id: string) {
28+
return deps.some((k) => new RegExp(`^${k}`).test(id));
29+
},
30+
output: {
31+
globals: {
32+
axios: 'axios',
33+
},
34+
},
35+
},
36+
},
37+
});

0 commit comments

Comments
 (0)