picgo 1.5.0-alpha.9 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +104 -0
- package/dist/core/PicGo.d.ts +6 -1
- package/dist/i18n/zh-TW.d.ts +2 -0
- package/dist/index.cjs.js +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +2 -2
- package/dist/types/index.d.ts +36 -15
- package/dist/types/oldRequest.d.ts +19 -0
- package/dist/utils/common.d.ts +2 -2
- package/package.json +1 -2
package/dist/types/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import { Command } from 'commander';
|
|
4
4
|
import { Inquirer } from 'inquirer';
|
|
5
|
-
import {
|
|
5
|
+
import { IRequestPromiseOptions } from './oldRequest';
|
|
6
6
|
export interface IPicGo extends NodeJS.EventEmitter {
|
|
7
7
|
/**
|
|
8
8
|
* picgo configPath
|
|
@@ -155,34 +155,51 @@ export interface IPluginLoader {
|
|
|
155
155
|
export interface IRequestOld {
|
|
156
156
|
request: import('axios').AxiosInstance;
|
|
157
157
|
}
|
|
158
|
-
export declare type IOldReqOptions = Omit<
|
|
158
|
+
export declare type IOldReqOptions = Omit<IRequestPromiseOptions & {
|
|
159
159
|
url: string;
|
|
160
|
-
resolveWithFullResponse?: true;
|
|
161
160
|
}, 'auth'>;
|
|
162
161
|
export declare type IOldReqOptionsWithFullResponse = IOldReqOptions & {
|
|
163
162
|
resolveWithFullResponse: true;
|
|
164
163
|
};
|
|
165
164
|
export declare type IOldReqOptionsWithJSON = IOldReqOptions & {
|
|
166
|
-
json:
|
|
165
|
+
json: true;
|
|
167
166
|
};
|
|
168
|
-
|
|
169
|
-
|
|
167
|
+
/**
|
|
168
|
+
* for PicGo new request api, the response will be json format
|
|
169
|
+
*/
|
|
170
|
+
export declare type IReqOptions<T = any> = AxiosRequestConfig<T> & {
|
|
171
|
+
resolveWithFullResponse: true;
|
|
170
172
|
};
|
|
173
|
+
/**
|
|
174
|
+
* for PicGo new request api, the response will be Buffer
|
|
175
|
+
*/
|
|
176
|
+
export declare type IReqOptionsWithArrayBufferRes<T = any> = IReqOptions<T> & {
|
|
177
|
+
responseType: 'arraybuffer';
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
180
|
+
* for PicGo new request api, the response will be just response data. (not statusCode, headers, etc.)
|
|
181
|
+
*/
|
|
182
|
+
export declare type IReqOptionsWithBodyResOnly<T = any> = AxiosRequestConfig<T>;
|
|
171
183
|
export declare type IFullResponse<T = any, U = any> = AxiosResponse<T, U> & {
|
|
172
184
|
statusCode: number;
|
|
173
185
|
body: T;
|
|
174
186
|
};
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
* T is the config type
|
|
179
|
-
* U is the response data type
|
|
180
|
-
*/
|
|
181
|
-
export declare type IResponse<T, U> = U extends {
|
|
187
|
+
declare type AxiosResponse<T = any, U = any> = import('axios').AxiosResponse<T, U>;
|
|
188
|
+
declare type AxiosRequestConfig<T = any> = import('axios').AxiosRequestConfig<T>;
|
|
189
|
+
interface IRequestOptionsWithFullResponse {
|
|
182
190
|
resolveWithFullResponse: true;
|
|
183
|
-
}
|
|
191
|
+
}
|
|
192
|
+
interface IRequestOptionsWithJSON {
|
|
184
193
|
json: true;
|
|
185
|
-
}
|
|
194
|
+
}
|
|
195
|
+
interface IRequestOptionsWithResponseTypeArrayBuffer {
|
|
196
|
+
responseType: 'arraybuffer';
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* T is the response data type
|
|
200
|
+
* U is the config type
|
|
201
|
+
*/
|
|
202
|
+
export declare type IResponse<T, U> = U extends IRequestOptionsWithFullResponse ? IFullResponse<T, U> : U extends IRequestOptionsWithJSON ? T : U extends IRequestOptionsWithResponseTypeArrayBuffer ? Buffer : U extends IOldReqOptionsWithFullResponse ? IFullResponse<T, U> : U extends IOldReqOptionsWithJSON ? T : U extends IOldReqOptions ? string : U extends IReqOptionsWithBodyResOnly ? T : string;
|
|
186
203
|
/**
|
|
187
204
|
* the old request lib will be removed in v1.5.0+
|
|
188
205
|
* the request options have the following properties
|
|
@@ -489,6 +506,9 @@ export interface IConfigChangePayload<T> {
|
|
|
489
506
|
configName: string;
|
|
490
507
|
value: T;
|
|
491
508
|
}
|
|
509
|
+
export interface ILocale {
|
|
510
|
+
[key: string]: any;
|
|
511
|
+
}
|
|
492
512
|
export interface II18nManager {
|
|
493
513
|
/**
|
|
494
514
|
* translate text
|
|
@@ -514,3 +534,4 @@ export interface II18nManager {
|
|
|
514
534
|
*/
|
|
515
535
|
getLanguageList: () => string[];
|
|
516
536
|
}
|
|
537
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare type IMethod = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
|
|
2
|
+
export interface IHeaders {
|
|
3
|
+
[key: string]: any;
|
|
4
|
+
}
|
|
5
|
+
export interface IRequestPromiseOptions {
|
|
6
|
+
baseUrl?: string | undefined;
|
|
7
|
+
url?: string;
|
|
8
|
+
method?: IMethod;
|
|
9
|
+
formData?: {
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
} | undefined;
|
|
12
|
+
qs?: any;
|
|
13
|
+
json?: boolean;
|
|
14
|
+
body?: any;
|
|
15
|
+
resolveWithFullResponse?: boolean;
|
|
16
|
+
headers?: IHeaders;
|
|
17
|
+
proxy?: any;
|
|
18
|
+
timeout?: number;
|
|
19
|
+
}
|
package/dist/utils/common.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
import { IImgSize, IPathTransformedImgInfo, IPluginNameType, ILogger } from '../types';
|
|
3
|
+
import { IImgSize, IPathTransformedImgInfo, IPluginNameType, ILogger, IPicGo } from '../types';
|
|
4
4
|
export declare const isUrl: (url: string) => boolean;
|
|
5
5
|
export declare const isUrlEncode: (url: string) => boolean;
|
|
6
6
|
export declare const handleUrlEncode: (url: string) => string;
|
|
7
7
|
export declare const getImageSize: (file: Buffer) => IImgSize;
|
|
8
8
|
export declare const getFSFile: (filePath: string) => Promise<IPathTransformedImgInfo>;
|
|
9
|
-
export declare const getURLFile: (url: string) => Promise<IPathTransformedImgInfo>;
|
|
9
|
+
export declare const getURLFile: (url: string, ctx: IPicGo) => Promise<IPathTransformedImgInfo>;
|
|
10
10
|
/**
|
|
11
11
|
* detect the input string's type
|
|
12
12
|
* for example
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "picgo",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"description": "A tool for picture uploading",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -66,7 +66,6 @@
|
|
|
66
66
|
"@types/mime-types": "^2.1.0",
|
|
67
67
|
"@types/minimatch": "^3.0.3",
|
|
68
68
|
"@types/node": "16.11.7",
|
|
69
|
-
"@types/request-promise-native": "^1.0.15",
|
|
70
69
|
"@types/resolve": "^0.0.8",
|
|
71
70
|
"@types/rimraf": "^3.0.0",
|
|
72
71
|
"@types/tunnel": "^0.0.3",
|