piclist 0.1.0 → 0.2.0

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.
@@ -0,0 +1,5 @@
1
+ import { IPicGo, IPluginConfig } from '../../types';
2
+ declare const _default: {
3
+ config: (ctx: IPicGo) => IPluginConfig[];
4
+ };
5
+ export default _default;
@@ -0,0 +1,5 @@
1
+ import { IPicGo, IPluginConfig } from '../../types';
2
+ declare const _default: {
3
+ config: (ctx: IPicGo) => IPluginConfig[];
4
+ };
5
+ export default _default;
@@ -2,6 +2,7 @@
2
2
  /// <reference types="node" />
3
3
  import { Command } from 'commander';
4
4
  import { Inquirer } from 'inquirer';
5
+ import { FormatEnum, GravityEnum } from 'sharp';
5
6
  import { IRequestPromiseOptions } from './oldRequest';
6
7
  export interface IPicGo extends NodeJS.EventEmitter {
7
8
  /**
@@ -550,4 +551,30 @@ export interface II18nManager {
550
551
  */
551
552
  getLanguageList: () => string[];
552
553
  }
554
+ export declare type availableConvertFormat = keyof FormatEnum;
555
+ export declare type availableWatermarkPosition = keyof GravityEnum;
556
+ export interface IBuildInWaterMarkOptions {
557
+ isAddWatermark?: boolean;
558
+ watermarkType?: 'text' | 'image';
559
+ isFullScreenWatermark?: boolean;
560
+ watermarkDegree?: number;
561
+ watermarkText?: string;
562
+ watermarkFontPath?: string;
563
+ watermarkScaleRatio?: number;
564
+ watermarkColor?: string;
565
+ watermarkImagePath?: string;
566
+ watermarkPosition?: availableWatermarkPosition;
567
+ }
568
+ export interface IBuildInCompressOptions {
569
+ quality?: number;
570
+ isConvert?: boolean;
571
+ convertFormat?: availableConvertFormat;
572
+ isReSize?: boolean;
573
+ reSizeWidth?: number;
574
+ reSizeHeight?: number;
575
+ isReSizeByPercent?: boolean;
576
+ reSizePercent?: number;
577
+ isRotate?: boolean;
578
+ rotateDegree?: number;
579
+ }
553
580
  export {};
@@ -1,6 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
- import { IImgSize, IPathTransformedImgInfo, IPluginNameType, ILogger, IPicGo } from '../types';
3
+ import { IImgSize, IPathTransformedImgInfo, IPluginNameType, ILogger, IPicGo, IBuildInCompressOptions, IBuildInWaterMarkOptions } from '../types';
4
+ import sharp from 'sharp';
4
5
  export declare const isUrl: (url: string) => boolean;
5
6
  export declare const isUrlEncode: (url: string) => boolean;
6
7
  export declare const handleUrlEncode: (url: string) => string;
@@ -104,3 +105,8 @@ export declare function safeParse<T>(str: string): T | string;
104
105
  export declare const forceNumber: (num?: string | number) => number;
105
106
  export declare const isDev: () => boolean;
106
107
  export declare const isProd: () => boolean;
108
+ export declare function AddWatermark(img: Buffer, watermarkType: 'text' | 'image', isFullScreenWatermark?: boolean, watermarkDegree?: number, text?: string, watermarkFontPath?: string, watermarkScaleRatio?: number, watermarkColor?: string, watermarkImagePath?: string, position?: sharp.Gravity): Promise<Buffer>;
109
+ export declare function imageAddWaterMark(img: Buffer, options: IBuildInWaterMarkOptions): Promise<Buffer>;
110
+ export declare function imageProcess(img: Buffer, options: IBuildInCompressOptions, rawFormat: string): Promise<Buffer>;
111
+ export declare const needAddWatermark: (watermarkOptions: IBuildInWaterMarkOptions | undefined) => boolean;
112
+ export declare const needCompress: (compressOptions: IBuildInCompressOptions | undefined, fileExt: string) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "piclist",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Modified PicGo core, A tool for picture uploading",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -67,6 +67,8 @@
67
67
  "@types/node": "16.11.7",
68
68
  "@types/resolve": "^0.0.8",
69
69
  "@types/rimraf": "^3.0.0",
70
+ "@types/sharp": "^0.31.1",
71
+ "@types/text-to-svg": "^3.1.1",
70
72
  "@types/tunnel": "^0.0.3",
71
73
  "@typescript-eslint/eslint-plugin": "3",
72
74
  "@typescript-eslint/parser": "^3.2.0",
@@ -89,12 +91,13 @@
89
91
  "rollup-plugin-string": "^3.0.0",
90
92
  "rollup-plugin-terser": "^7.0.2",
91
93
  "rollup-plugin-typescript2": "^0.30.0",
94
+ "rollup-plugin-copy": "^3.4.0",
92
95
  "typescript": "^4.8.2"
93
96
  },
94
97
  "dependencies": {
95
98
  "@picgo/i18n": "^1.0.0",
96
99
  "@picgo/store": "^2.0.4",
97
- "axios": "^1.3.2",
100
+ "axios": "^1.3.4",
98
101
  "chalk": "^2.4.1",
99
102
  "commander": "^8.1.0",
100
103
  "comment-json": "^2.3.1",
@@ -116,6 +119,8 @@
116
119
  "qiniu": "^7.8.0",
117
120
  "resolve": "^1.8.1",
118
121
  "rimraf": "^3.0.2",
122
+ "sharp": "^0.31.3",
123
+ "text-to-svg": "^3.1.5",
119
124
  "tunnel": "^0.0.6"
120
125
  },
121
126
  "repository": {
package/rollup.config.js CHANGED
@@ -2,6 +2,7 @@ import { terser } from 'rollup-plugin-terser'
2
2
  import pkg from './package.json'
3
3
  import typescript from 'rollup-plugin-typescript2'
4
4
  import commonjs from '@rollup/plugin-commonjs'
5
+ import copy from 'rollup-plugin-copy'
5
6
  import { string } from 'rollup-plugin-string'
6
7
  import json from '@rollup/plugin-json'
7
8
  import builtins from 'builtins'
@@ -32,6 +33,11 @@ const commonOptions = {
32
33
  }
33
34
  }
34
35
  }),
36
+ copy({
37
+ targets: [
38
+ { src: 'assets', dest: 'dist' }
39
+ ]
40
+ }),
35
41
  // terser(),
36
42
  commonjs(),
37
43
  string({