picgo 1.4.26 → 1.5.0-alpha.2

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.
Files changed (101) hide show
  1. package/.eslintignore +2 -0
  2. package/.github/workflows/alpha.yml +22 -0
  3. package/CHANGELOG.md +43 -0
  4. package/README.md +14 -1
  5. package/bin/picgo +1 -1
  6. package/dist/{src/core → core}/Lifecycle.d.ts +15 -15
  7. package/dist/{src/core → core}/PicGo.d.ts +44 -44
  8. package/dist/i18n/en.d.ts +2 -0
  9. package/dist/i18n/index.d.ts +16 -0
  10. package/dist/i18n/zh-CN.d.ts +65 -0
  11. package/dist/index.cjs.js +2 -0
  12. package/dist/index.d.ts +9 -0
  13. package/dist/index.esm.js +2 -0
  14. package/dist/{src/lib → lib}/Commander.d.ts +16 -16
  15. package/dist/{src/lib → lib}/LifecyclePlugins.d.ts +16 -16
  16. package/dist/{src/lib → lib}/Logger.d.ts +16 -16
  17. package/dist/{src/lib → lib}/PluginHandler.d.ts +10 -10
  18. package/dist/{src/lib → lib}/PluginLoader.d.ts +27 -27
  19. package/dist/{src/lib → lib}/Request.d.ts +11 -11
  20. package/dist/{src/plugins → plugins}/commander/config.d.ts +3 -3
  21. package/dist/plugins/commander/i18n.d.ts +3 -0
  22. package/dist/{src/plugins → plugins}/commander/index.d.ts +3 -3
  23. package/dist/{src/plugins → plugins}/commander/init.d.ts +3 -3
  24. package/dist/{src/plugins → plugins}/commander/pluginHandler.d.ts +3 -3
  25. package/dist/{src/plugins → plugins}/commander/proxy.d.ts +3 -3
  26. package/dist/{src/plugins → plugins}/commander/setting.d.ts +5 -5
  27. package/dist/{src/plugins → plugins}/commander/upload.d.ts +3 -3
  28. package/dist/{src/plugins → plugins}/commander/use.d.ts +3 -3
  29. package/dist/{src/plugins → plugins}/transformer/base64.d.ts +5 -5
  30. package/dist/{src/plugins → plugins}/transformer/index.d.ts +3 -3
  31. package/dist/{src/plugins → plugins}/transformer/path.d.ts +5 -5
  32. package/dist/plugins/uploader/aliyun.d.ts +2 -0
  33. package/dist/plugins/uploader/github.d.ts +2 -0
  34. package/dist/plugins/uploader/imgur.d.ts +2 -0
  35. package/dist/{src/plugins → plugins}/uploader/index.d.ts +3 -3
  36. package/dist/plugins/uploader/qiniu.d.ts +2 -0
  37. package/dist/plugins/uploader/smms.d.ts +2 -0
  38. package/dist/plugins/uploader/tcyun.d.ts +8 -0
  39. package/dist/plugins/uploader/upyun.d.ts +2 -0
  40. package/dist/types/index.d.ts +468 -0
  41. package/dist/{src/utils → utils}/common.d.ts +102 -101
  42. package/dist/{src/utils → utils}/createContext.d.ts +6 -6
  43. package/dist/{src/utils → utils}/db.d.ts +15 -15
  44. package/dist/{src/utils → utils}/enum.d.ts +27 -27
  45. package/dist/{src/utils → utils}/eventBus.d.ts +4 -4
  46. package/dist/{src/utils → utils}/getClipboardImage.d.ts +4 -3
  47. package/dist/{src/utils → utils}/initUtils.d.ts +26 -26
  48. package/dist/{src/utils → utils}/interfaces.d.ts +203 -203
  49. package/package.json +27 -22
  50. package/rollup.config.js +82 -0
  51. package/dist/package.json +0 -127
  52. package/dist/src/core/Lifecycle.js +0 -123
  53. package/dist/src/core/PicGo.js +0 -210
  54. package/dist/src/index.d.ts +0 -2
  55. package/dist/src/index.js +0 -6
  56. package/dist/src/lib/Commander.js +0 -56
  57. package/dist/src/lib/LifecyclePlugins.js +0 -52
  58. package/dist/src/lib/Logger.js +0 -82
  59. package/dist/src/lib/PluginHandler.js +0 -260
  60. package/dist/src/lib/PluginLoader.js +0 -145
  61. package/dist/src/lib/Request.js +0 -42
  62. package/dist/src/plugins/commander/config.js +0 -11
  63. package/dist/src/plugins/commander/index.js +0 -21
  64. package/dist/src/plugins/commander/init.js +0 -122
  65. package/dist/src/plugins/commander/pluginHandler.js +0 -43
  66. package/dist/src/plugins/commander/proxy.js +0 -14
  67. package/dist/src/plugins/commander/setting.js +0 -102
  68. package/dist/src/plugins/commander/upload.js +0 -35
  69. package/dist/src/plugins/commander/use.js +0 -87
  70. package/dist/src/plugins/transformer/base64.js +0 -9
  71. package/dist/src/plugins/transformer/index.js +0 -16
  72. package/dist/src/plugins/transformer/path.js +0 -42
  73. package/dist/src/plugins/uploader/aliyun.d.ts +0 -7
  74. package/dist/src/plugins/uploader/aliyun.js +0 -129
  75. package/dist/src/plugins/uploader/github.d.ts +0 -7
  76. package/dist/src/plugins/uploader/github.js +0 -101
  77. package/dist/src/plugins/uploader/imgur.d.ts +0 -7
  78. package/dist/src/plugins/uploader/imgur.js +0 -81
  79. package/dist/src/plugins/uploader/index.js +0 -26
  80. package/dist/src/plugins/uploader/qiniu.d.ts +0 -7
  81. package/dist/src/plugins/uploader/qiniu.js +0 -132
  82. package/dist/src/plugins/uploader/smms.d.ts +0 -7
  83. package/dist/src/plugins/uploader/smms.js +0 -74
  84. package/dist/src/plugins/uploader/tcyun.d.ts +0 -13
  85. package/dist/src/plugins/uploader/tcyun.js +0 -218
  86. package/dist/src/plugins/uploader/upyun.d.ts +0 -7
  87. package/dist/src/plugins/uploader/upyun.js +0 -128
  88. package/dist/src/types/index.d.ts +0 -471
  89. package/dist/src/utils/clipboard/linux.sh +0 -18
  90. package/dist/src/utils/clipboard/mac.applescript +0 -0
  91. package/dist/src/utils/clipboard/windows.ps1 +0 -26
  92. package/dist/src/utils/clipboard/windows10.ps1 +0 -47
  93. package/dist/src/utils/clipboard/wsl.sh +0 -18
  94. package/dist/src/utils/common.js +0 -353
  95. package/dist/src/utils/createContext.js +0 -45
  96. package/dist/src/utils/db.js +0 -85
  97. package/dist/src/utils/enum.js +0 -33
  98. package/dist/src/utils/eventBus.js +0 -6
  99. package/dist/src/utils/getClipboardImage.js +0 -101
  100. package/dist/src/utils/initUtils.js +0 -120
  101. package/dist/src/utils/interfaces.js +0 -3
@@ -1,128 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const crypto_1 = __importDefault(require("crypto"));
7
- const md5_1 = __importDefault(require("md5"));
8
- const enum_1 = require("../../utils/enum");
9
- // generate COS signature string
10
- const generateSignature = (options, fileName) => {
11
- const path = options.path || '';
12
- const operator = options.operator;
13
- const password = options.password;
14
- const md5Password = md5_1.default(password);
15
- const date = new Date().toUTCString();
16
- const uri = `/${options.bucket}/${encodeURI(path)}${encodeURI(fileName)}`;
17
- const value = `PUT&${uri}&${date}`;
18
- const sign = crypto_1.default.createHmac('sha1', md5Password).update(value).digest('base64');
19
- return `UPYUN ${operator}:${sign}`;
20
- };
21
- const postOptions = (options, fileName, signature, image) => {
22
- const bucket = options.bucket;
23
- const path = options.path || '';
24
- return {
25
- method: 'PUT',
26
- url: `https://v0.api.upyun.com/${bucket}/${encodeURI(path)}${encodeURI(fileName)}`,
27
- headers: {
28
- Authorization: signature,
29
- Date: new Date().toUTCString()
30
- },
31
- body: image,
32
- resolveWithFullResponse: true
33
- };
34
- };
35
- const handle = async (ctx) => {
36
- const upyunOptions = ctx.getConfig('picBed.upyun');
37
- if (!upyunOptions) {
38
- throw new Error('Can\'t find upYun config');
39
- }
40
- try {
41
- const imgList = ctx.output;
42
- const path = upyunOptions.path || '';
43
- for (const img of imgList) {
44
- if (img.fileName && img.buffer) {
45
- let image = img.buffer;
46
- if (!image && img.base64Image) {
47
- image = Buffer.from(img.base64Image, 'base64');
48
- }
49
- const signature = generateSignature(upyunOptions, img.fileName);
50
- const options = postOptions(upyunOptions, img.fileName, signature, image);
51
- const body = await ctx.Request.request(options);
52
- if (body.statusCode === 200) {
53
- delete img.base64Image;
54
- delete img.buffer;
55
- img.imgUrl = `${upyunOptions.url}/${path}${img.fileName}${upyunOptions.options}`;
56
- }
57
- else {
58
- throw new Error('Upload failed');
59
- }
60
- }
61
- }
62
- return ctx;
63
- }
64
- catch (err) {
65
- if (err.message === 'Upload failed') {
66
- ctx.emit(enum_1.IBuildInEvent.NOTIFICATION, {
67
- title: '上传失败',
68
- body: '请检查你的配置项是否正确'
69
- });
70
- }
71
- else {
72
- const body = JSON.parse(err.error);
73
- ctx.emit(enum_1.IBuildInEvent.NOTIFICATION, {
74
- title: '上传失败',
75
- body: `错误码:${body.code},请打开浏览器粘贴地址查看相关原因`,
76
- text: 'http://docs.upyun.com/api/errno/'
77
- });
78
- }
79
- throw err;
80
- }
81
- };
82
- const config = (ctx) => {
83
- const userConfig = ctx.getConfig('picBed.upyun') || {};
84
- const config = [
85
- {
86
- name: 'bucket',
87
- type: 'input',
88
- default: userConfig.bucket || '',
89
- required: true
90
- },
91
- {
92
- name: 'operator',
93
- type: 'input',
94
- default: userConfig.operator || '',
95
- required: true
96
- },
97
- {
98
- name: 'password',
99
- type: 'password',
100
- default: userConfig.password || '',
101
- required: true
102
- },
103
- {
104
- name: 'url',
105
- type: 'input',
106
- default: userConfig.url || '',
107
- required: true
108
- },
109
- {
110
- name: 'options',
111
- type: 'input',
112
- default: userConfig.options || '',
113
- required: true
114
- },
115
- {
116
- name: 'path',
117
- type: 'input',
118
- default: userConfig.path || '',
119
- required: false
120
- }
121
- ];
122
- return config;
123
- };
124
- exports.default = {
125
- name: '又拍云图床',
126
- handle,
127
- config
128
- };
@@ -1,471 +0,0 @@
1
- import { RequestPromiseAPI } from 'request-promise-native'
2
- import { Command } from 'commander'
3
- import { Inquirer } from 'inquirer'
4
-
5
- interface IPicGo extends NodeJS.EventEmitter {
6
- /**
7
- * picgo configPath
8
- *
9
- * if do not provide, then it will use default configPath
10
- */
11
- configPath: string
12
- /**
13
- * the picgo configPath's baseDir
14
- */
15
- baseDir: string
16
- /**
17
- * picgo logger factory
18
- */
19
- log: ILogger
20
- /**
21
- * picgo commander, for cli
22
- */
23
- cmd: ICommander
24
- /**
25
- * after transformer, the input will be output
26
- */
27
- output: IImgInfo[]
28
- /**
29
- * the origin input
30
- */
31
- input: any[]
32
- /**
33
- * register\unregister\get picgo's plugin
34
- */
35
- pluginLoader: IPluginLoader
36
- /**
37
- * install\uninstall\update picgo's plugin via npm
38
- */
39
- pluginHandler: IPluginHandler
40
- /**
41
- * @deprecated will be removed in v1.5.0+
42
- *
43
- * use request instead.
44
- *
45
- * http request tool
46
- */
47
- Request: IRequest
48
- /**
49
- * plugin system core part transformer\uploader\beforeTransformPlugins...
50
- */
51
- helper: IHelper
52
- /**
53
- * picgo-core version
54
- */
55
- VERSION: string
56
- /**
57
- * electron picgo's version
58
- */
59
- GUI_VERSION?: string
60
- /**
61
- * will be released in v1.5.0+
62
- *
63
- * replace old Request
64
- *
65
- * http request tool
66
- */
67
- request: RequestPromiseAPI
68
-
69
- /**
70
- * get picgo config
71
- */
72
- getConfig: <T>(name?: string) => T
73
- /**
74
- * save picgo config to configPath
75
- */
76
- saveConfig: (config: IStringKeyMap<any>) => void
77
- /**
78
- * remove some [propName] in config[key] && save config to configPath
79
- */
80
- removeConfig: (key: string, propName: string) => void
81
- /**
82
- * set picgo config to ctx && will not save to configPath
83
- */
84
- setConfig: (config: IStringKeyMap<any>) => void
85
- /**
86
- * unset picgo config to ctx && will not save to configPath
87
- */
88
- unsetConfig: (key: string, propName: string) => void
89
- /**
90
- * upload gogogo
91
- */
92
- upload: (input?: any[]) => Promise<IImgInfo[] | Error>
93
- }
94
-
95
- /**
96
- * for plugin config
97
- */
98
- interface IPluginConfig {
99
- name: string
100
- type: string
101
- required: boolean
102
- default?: any
103
- [propName: string]: any
104
- }
105
-
106
- /**
107
- * for lifecycle plugins
108
- */
109
- interface ILifecyclePlugins {
110
- register: (id: string, plugin: IPlugin) => void
111
- unregister: (id: string) => void
112
- getName: () => string
113
- get: (id: string) => IPlugin | undefined
114
- getList: () => IPlugin[]
115
- getIdList: () => string[]
116
- }
117
-
118
- interface IHelper {
119
- transformer: ILifecyclePlugins
120
- uploader: ILifecyclePlugins
121
- beforeTransformPlugins: ILifecyclePlugins
122
- beforeUploadPlugins: ILifecyclePlugins
123
- afterUploadPlugins: ILifecyclePlugins
124
- }
125
-
126
- interface ICommander {
127
- program: Command
128
- inquirer: Inquirer
129
- get: (name: string) => IPlugin
130
- getList: () => IPlugin[]
131
- register: (name: string, plugin: IPlugin) => void
132
- }
133
-
134
- interface IPluginLoader {
135
- /**
136
- * register [local plugin] or [provided plugin]
137
- *
138
- * if the second param (plugin) is provided
139
- *
140
- * then picgo will register this plugin and enable it by default
141
- *
142
- * but picgo won't write any config to config file
143
- *
144
- * you should use ctx.setConfig to change the config context
145
- */
146
- registerPlugin: (name: string, plugin?: IPicGoPlugin) => void
147
- unregisterPlugin: (name: string) => void
148
- getPlugin: (name: string) => IPicGoPluginInterface | undefined
149
- /**
150
- * get enabled plugin list
151
- */
152
- getList: () => string[]
153
- /**
154
- * get all plugin list (enabled or not)
155
- */
156
- getFullList: () => string[]
157
- hasPlugin: (name: string) => boolean
158
- }
159
-
160
- interface IRequest {
161
- request: RequestPromiseAPI
162
- }
163
-
164
- type ILogColor = 'blue' | 'green' | 'yellow' | 'red'
165
-
166
- /**
167
- * for uploading image info
168
- */
169
- interface IImgInfo {
170
- buffer?: Buffer
171
- base64Image?: string
172
- fileName?: string
173
- width?: number
174
- height?: number
175
- extname?: string
176
- imgUrl?: string
177
- [propName: string]: any
178
- }
179
-
180
- interface IPathTransformedImgInfo extends IImgInfo {
181
- success: boolean
182
- }
183
-
184
- interface IStringKeyMap<T> {
185
- [key: string]: T extends T ? T : any
186
- }
187
-
188
- interface ICLIConfigs {
189
- [module: string]: IStringKeyMap<any>
190
- }
191
-
192
- /** SM.MS 图床配置项 */
193
- interface ISmmsConfig {
194
- token: string
195
- }
196
- /** 七牛云图床配置项 */
197
- interface IQiniuConfig {
198
- accessKey: string
199
- secretKey: string
200
- /** 存储空间名 */
201
- bucket: string
202
- /** 自定义域名 */
203
- url: string
204
- /** 存储区域编号 */
205
- area: 'z0' | 'z1' | 'z2' | 'na0' | 'as0'
206
- /** 网址后缀,比如使用 `?imageslim` 可进行[图片瘦身](https://developer.qiniu.com/dora/api/1271/image-thin-body-imageslim) */
207
- options: string
208
- /** 自定义存储路径,比如 `img/` */
209
- path: string
210
- }
211
- /** 又拍云图床配置项 */
212
- interface IUpyunConfig {
213
- /** 存储空间名,及你的服务名 */
214
- bucket: string
215
- /** 操作员 */
216
- operator: string
217
- /** 密码 */
218
- password: string
219
- /** 针对图片的一些后缀处理参数 */
220
- options: string
221
- /** 自定义存储路径,比如 `img/` */
222
- path: string
223
- /** 加速域名,注意要加 `http://` 或者 `https://` */
224
- url: string
225
- }
226
- /** 腾讯云图床配置项 */
227
- interface ITcyunConfig {
228
- secretId: string
229
- secretKey: string
230
- /** 存储桶名,v4 和 v5 版本不一样 */
231
- bucket: string
232
- appId: string
233
- /** 存储区域,例如 ap-beijing-1 */
234
- area: string
235
- /** 自定义存储路径,比如 img/ */
236
- path: string
237
- /** 自定义域名,注意要加 `http://` 或者 `https://` */
238
- customUrl: string
239
- /** COS 版本,v4 或者 v5 */
240
- version: 'v5' | 'v4'
241
- }
242
- /** GitHub 图床配置项 */
243
- interface IGithubConfig {
244
- /** 仓库名,格式是 `username/reponame` */
245
- repo: string
246
- /** github token */
247
- token: string
248
- /** 自定义存储路径,比如 `img/` */
249
- path: string
250
- /** 自定义域名,注意要加 `http://` 或者 `https://` */
251
- customUrl: string
252
- /** 分支名,默认是 `main` */
253
- branch: string
254
- }
255
- /** 阿里云图床配置项 */
256
- interface IAliyunConfig {
257
- accessKeyId: string
258
- accessKeySecret: string
259
- /** 存储空间名 */
260
- bucket: string
261
- /** 存储区域代号 */
262
- area: string
263
- /** 自定义存储路径 */
264
- path: string
265
- /** 自定义域名,注意要加 `http://` 或者 `https://` */
266
- customUrl: string
267
- /** 针对图片的一些后缀处理参数 PicGo 2.2.0+ PicGo-Core 1.4.0+ */
268
- options: string
269
- }
270
- /** Imgur 图床配置项 */
271
- interface IImgurConfig {
272
- /** imgur 的 `clientId` */
273
- clientId: string
274
- /** 代理地址,仅支持 http 代理 */
275
- proxy: string
276
- }
277
- /** PicGo 配置文件类型定义 */
278
- interface IConfig {
279
- picBed: {
280
- uploader: string
281
- current?: string
282
- smms?: ISmmsConfig
283
- qiniu?: IQiniuConfig
284
- upyun?: IUpyunConfig
285
- tcyun?: ITcyunConfig
286
- github?: IGithubConfig
287
- aliyun?: IAliyunConfig
288
- imgur?: IImgurConfig
289
- transformer?: string
290
- /** for uploader */
291
- proxy?: string
292
- [others: string]: any
293
- }
294
- picgoPlugins: {
295
- [pluginName: string]: boolean
296
- }
297
- debug?: boolean
298
- silent?: boolean
299
- settings?: {
300
- logLevel?: string
301
- logPath?: string
302
- /** for npm */
303
- registry?: string
304
- /** for npm */
305
- proxy?: string
306
- [others: string]: any
307
- }
308
- [configOptions: string]: any
309
- }
310
-
311
- /**
312
- * for plugin
313
- */
314
- interface IPlugin {
315
- handle: ((ctx: IPicGo) => Promise<any>) | ((ctx: IPicGo) => void)
316
- [propName: string]: any
317
- }
318
-
319
- type IPluginNameType = 'simple' | 'scope' | 'normal' | 'unknown'
320
-
321
- interface IPluginProcessResult {
322
- success: boolean
323
- /**
324
- * the package.json's name filed
325
- */
326
- pkgName: string
327
- /**
328
- * the plugin name or the fs absolute path
329
- */
330
- fullName: string
331
- }
332
-
333
- interface IPluginHandler {
334
- install: (plugins: string[], options: IPluginHandlerOptions, env?: IProcessEnv) => Promise<IPluginHandlerResult<boolean>>
335
- update: (plugins: string[], options: IPluginHandlerOptions, env?: IProcessEnv) => Promise<IPluginHandlerResult<boolean>>
336
- uninstall: (plugins: string[]) => Promise<IPluginHandlerResult<boolean>>
337
- }
338
-
339
- interface IPluginHandlerResult<T> {
340
- success: T
341
- body: T extends true ? string[] : string
342
- }
343
-
344
- interface IPluginHandlerOptions {
345
- proxy?: string
346
- registry?: string
347
- }
348
-
349
- /**
350
- * for picgo npm plugins
351
- */
352
- type IPicGoPlugin = (ctx: IPicGo) => IPicGoPluginInterface
353
-
354
- /**
355
- * interfaces for PicGo plugin
356
- */
357
- interface IPicGoPluginInterface {
358
- /**
359
- * since PicGo-Core v1.5, register will inject ctx
360
- */
361
- register: (ctx: IPicGo) => void
362
- /**
363
- * this plugin's config
364
- */
365
- config?: (ctx: IPicGo) => IPluginConfig[]
366
- /**
367
- * register uploader name
368
- */
369
- uploader?: string
370
- /**
371
- * register transformer name
372
- */
373
- transformer?: string
374
- /**
375
- * for picgo gui plugins
376
- */
377
- guiMenu?: (ctx: IPicGo) => IGuiMenuItem[]
378
-
379
- /**
380
- * for picgo gui plugins
381
- * short key -> command
382
- */
383
- commands?: (ctx: IPicGo) => ICommandItem[]
384
-
385
- [propName: string]: any
386
- }
387
-
388
- interface IGuiMenuItem {
389
- label: string
390
- handle: (ctx: IPicGo, guiApi: any) => Promise<void>
391
- }
392
-
393
- interface ICommandItem {
394
- label: string
395
- name: string
396
- key: string
397
- handle: (ctx: IPicGo, guiApi: any) => Promise<void>
398
- }
399
-
400
- /**
401
- * for spawn output
402
- */
403
- interface IResult {
404
- code: number
405
- data: string
406
- }
407
-
408
- /**
409
- * for transformer - path
410
- */
411
- interface IImgSize {
412
- width: number
413
- height: number
414
- real?: boolean
415
- }
416
-
417
- /**
418
- * for initUtils
419
- */
420
- interface IFileTree {
421
- [filePath: string]: string | Buffer
422
- }
423
-
424
- interface IOptions {
425
- template: string // template name
426
- dest: string // destination for template to generate
427
- hasSlash: boolean // check if is officail template
428
- inPlace: boolean // check if is given project name
429
- clone: boolean // check if use git clone
430
- offline: boolean // check if use offline mode
431
- tmp: string // cache template
432
- project: string // project name
433
- }
434
-
435
- /**
436
- * for clipboard image
437
- */
438
- interface IClipboardImage {
439
- imgPath: string
440
- /**
441
- * if the path is generate by picgo -> false
442
- * if the path is a real file path in system -> true
443
- */
444
- shouldKeepAfterUploading: boolean
445
- }
446
-
447
- /**
448
- * for install command environment variable
449
- */
450
- interface IProcessEnv {
451
- [propName: string]: Undefinable<string>
452
- }
453
-
454
- type ILogArgvType = string | number
455
-
456
- type ILogArgvTypeWithError = ILogArgvType | Error
457
-
458
- type Nullable<T> = T | null
459
- type Undefinable<T> = T | undefined
460
-
461
- interface ILogger {
462
- success: (...msg: ILogArgvType[]) => void
463
- info: (...msg: ILogArgvType[]) => void
464
- error: (...msg: ILogArgvTypeWithError[]) => void
465
- warn: (...msg: ILogArgvType[]) => void
466
- }
467
-
468
- interface IConfigChangePayload<T> {
469
- configName: string
470
- value: T
471
- }
@@ -1,18 +0,0 @@
1
- #!/bin/sh
2
- # require xclip(see http://stackoverflow.com/questions/592620/check-if-a-program-exists-from-a-bash-script/677212#677212)
3
- command -v xclip >/dev/null 2>&1 || { echo >&1 "no xclip"; exit 1; }
4
-
5
- # write image in clipboard to file (see http://unix.stackexchange.com/questions/145131/copy-image-from-clipboard-to-file)
6
- filePath=`xclip -selection clipboard -o 2>/dev/null | grep ^file:// | cut -c8-`
7
- if [ ! -n "$filePath" ] ;then
8
- if
9
- xclip -selection clipboard -target image/png -o >/dev/null 2>&1
10
- then
11
- xclip -selection clipboard -target image/png -o >$1 2>/dev/null
12
- echo $1
13
- else
14
- echo "no image"
15
- fi
16
- else
17
- echo $filePath
18
- fi
@@ -1,26 +0,0 @@
1
-
2
- param($imagePath)
3
-
4
- # Adapted from https://github.com/octan3/img-clipboard-dump/blob/master/dump-clipboard-png.ps1
5
-
6
- Add-Type -Assembly PresentationCore
7
- $img = [Windows.Clipboard]::GetImage()
8
-
9
- if ($img -eq $null) {
10
- "no image"
11
- Exit 1
12
- }
13
-
14
- if (-not $imagePath) {
15
- "no image"
16
- Exit 1
17
- }
18
-
19
- $fcb = new-object Windows.Media.Imaging.FormatConvertedBitmap($img, [Windows.Media.PixelFormats]::Rgb24, $null, 0)
20
- $stream = [IO.File]::Open($imagePath, "OpenOrCreate")
21
- $encoder = New-Object Windows.Media.Imaging.PngBitmapEncoder
22
- $encoder.Frames.Add([Windows.Media.Imaging.BitmapFrame]::Create($fcb)) | out-null
23
- $encoder.Save($stream) | out-null
24
- $stream.Dispose() | out-null
25
-
26
- $imagePath
@@ -1,47 +0,0 @@
1
- # Adapted from https://github.com/octan3/img-clipboard-dump/blob/master/dump-clipboard-png.ps1
2
- param($imagePath)
3
-
4
- # https://github.com/PowerShell/PowerShell/issues/7233
5
- # fix the output encoding bug
6
- [console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding
7
-
8
- Add-Type -Assembly PresentationCore
9
- function main {
10
- $img = [Windows.Clipboard]::GetImage()
11
-
12
- if ($img -eq $null) {
13
- "no image"
14
- Exit 1
15
- }
16
-
17
- if (-not $imagePath) {
18
- "no image"
19
- Exit 1
20
- }
21
-
22
- $fcb = new-object Windows.Media.Imaging.FormatConvertedBitmap($img, [Windows.Media.PixelFormats]::Rgb24, $null, 0)
23
- $stream = [IO.File]::Open($imagePath, "OpenOrCreate")
24
- $encoder = New-Object Windows.Media.Imaging.PngBitmapEncoder
25
- $encoder.Frames.Add([Windows.Media.Imaging.BitmapFrame]::Create($fcb)) | out-null
26
- $encoder.Save($stream) | out-null
27
- $stream.Dispose() | out-null
28
-
29
- $imagePath
30
- # fix windows 10 native cmd crash bug when "picgo upload"
31
- # https://github.com/PicGo/PicGo-Core/issues/32
32
- Exit 1
33
- }
34
-
35
- try {
36
- # For WIN10
37
- $file = Get-Clipboard -Format FileDropList
38
- if ($file -ne $null) {
39
- Convert-Path $file
40
- Exit 1
41
- }
42
- } catch {
43
- # For WIN7 WIN8 WIN10
44
- main
45
- }
46
-
47
- main
@@ -1,18 +0,0 @@
1
- #!/bin/sh
2
- # grab the paths
3
- scriptPath=$(echo $0 | awk '{ print substr( $0, 1, length($0)-6 ) }')"windows10.ps1"
4
- imagePath=$(echo $1 | awk '{ print substr( $0, 1, length($0)-18 ) }')
5
- imageName=$(echo $1 | awk '{ print substr( $0, length($0)-17, length($0) ) }')
6
-
7
- # run the powershell script
8
- res=$(powershell.exe -noprofile -noninteractive -nologo -sta -executionpolicy unrestricted -file $(wslpath -w $scriptPath) $(wslpath -w $imagePath)"\\"$imageName)
9
-
10
- # note that there is a return symbol in powershell result
11
- noImage=$(echo "no image\r")
12
-
13
- # check whether image exists
14
- if [ "$res" = "$noImage" ] ;then
15
- echo "no image"
16
- else
17
- echo $(wslpath -u -a "${res}")
18
- fi