Skip to content

Commit

Permalink
feat: update gopeed types
Browse files Browse the repository at this point in the history
  • Loading branch information
monkeyWie committed Dec 12, 2023
1 parent 453fe21 commit 0d61cad
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"private": true,
"version": "1.3.5",
"version": "1.3.6",
"packageManager": "pnpm@8.6.1",
"type": "module",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/create-gopeed-ext/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-gopeed-ext",
"version": "1.3.5",
"version": "1.3.6",
"keywords": [
"gopeed"
],
Expand Down
3 changes: 2 additions & 1 deletion packages/create-gopeed-ext/templates/webpack/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"node": true
},
"globals": {
"gopeed": true
"gopeed": true,
"MessageError": true
}
}
4 changes: 2 additions & 2 deletions packages/create-gopeed-ext/templates/webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "webpack --mode production --watch",
"dev": "webpack --mode development --watch",
"build": "webpack --mode production"
},
"keywords": [],
Expand All @@ -20,7 +20,7 @@
"eslint": "^8.51.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"gopeed": "^1.3.5",
"gopeed": "^1.3.6",
"gopeed-polyfill-webpack-plugin": "^1.0.2",
"prettier": "^3.0.3",
"webpack": "^5.75.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default {
filename: 'index.js',
path: path.resolve(__dirname, '../dist'),
},
devtool: false,
plugins: [new GopeedPolyfillPlugin()],
module: {
rules: [
Expand Down
2 changes: 1 addition & 1 deletion packages/gopeed-rest/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gopeed/rest",
"version": "1.3.5",
"version": "1.3.6",
"description": "",
"main": "dist/index.js",
"exports": {
Expand Down
2 changes: 1 addition & 1 deletion packages/gopeed-types/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gopeed/types",
"version": "1.3.5",
"version": "1.3.6",
"description": "",
"main": "dist/index.js",
"exports": {
Expand Down
8 changes: 8 additions & 0 deletions packages/gopeed/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,19 @@ export interface Gopeed {
storage: Storage;
}

export type MessageError = Error;

export interface MessageErrorConstructor {
new (message?: string): MessageError;
(message?: string): MessageError;
}

/**
* Global gopeed extension instance
*/
declare global {
const gopeed: Gopeed;
const MessageError: MessageErrorConstructor;
}

export * from './types/events';
Expand Down
2 changes: 1 addition & 1 deletion packages/gopeed/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gopeed",
"version": "1.3.5",
"version": "1.3.6",
"description": "",
"main": "index.js",
"type": "module",
Expand Down
20 changes: 19 additions & 1 deletion packages/gopeed/types/events.d.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,37 @@
/* eslint-disable no-unused-vars */
import { Request, Resource, Task } from '@gopeed/types';

export interface ExtensionTask extends Task {
/**
* Continue the task
*/
continue(): void;
/**
* Pause the task
*/
pause(): void;
}

export interface OnResovleContext {
req: Request;
res: Resource;
}

export interface OnStartContext {
task: Task;
task: ExtensionTask;
}

export interface OnErrorContext {
task: ExtensionTask;
error: Error;
}

export type EventOnResolve = (ctx: OnResovleContext) => Promise<void> | void;
export type EventOnStart = (ctx: OnStartContext) => Promise<void> | void;
export type EventOnError = (ctx: OnErrorContext) => Promise<void> | void;

export interface Events {
onResolve: (handler: EventOnResolve) => void;
onStart: (handler: EventOnStart) => void;
onError: (handler: EventOnError) => void;
}
2 changes: 1 addition & 1 deletion typedoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
],
"name": "Gopeed Library",
"entryPointStrategy": "packages",
"includeVersion": true,
"includeVersion": false,
"exclude": [
"./packages/create-gopeed-ext",
"./packages/gopeed-openapi"
Expand Down

0 comments on commit 0d61cad

Please sign in to comment.