picgo 3.0.2 → 3.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.
- package/.node-version +1 -1
- package/README.md +126 -9
- package/dist/core/Lifecycle.d.ts +0 -2
- package/dist/i18n/zh-CN.d.ts +8 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/lib/Cloud/__mocks__/lifecycleScenarios.d.ts +3 -2
- package/dist/lib/UploadOption.d.ts +13 -0
- package/dist/types/index.d.ts +56 -1
- package/dist/types/internal.d.ts +4 -4
- package/dist/utils/createClipboardImagePath.d.ts +1 -0
- package/dist/utils/createContext.d.ts +2 -2
- package/dist/utils/getClipboardImage.d.ts +1 -2
- package/package.json +2 -1
- package/pnpm-workspace.yaml +3 -0
package/.node-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
24
|
package/README.md
CHANGED
|
@@ -1,12 +1,43 @@
|
|
|
1
|
-
<div align="center"
|
|
2
|
-
<
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h3>Special thanks to</h3>
|
|
3
|
+
<table>
|
|
4
|
+
<tr>
|
|
5
|
+
<td align="center" valign="middle" width="50%">
|
|
6
|
+
<a href="https://modelflare.dev/sign-up?partner=1GIMVVBLWP1V">
|
|
7
|
+
<img alt="Modelflare sponsorship" width="400" src="https://pics.picgo.app/m/ef1a160c-c9ce-4605-9b9c-b2d355cd2de4.png">
|
|
8
|
+
</a>
|
|
9
|
+
<h3><a href="https://modelflare.dev/sign-up?partner=1GIMVVBLWP1V">Modelflare</a></h3>
|
|
10
|
+
<p>Modelflare: Full strength, stable, nothing watered down. Global SOTA models at a lower cost.</p>
|
|
11
|
+
</td>
|
|
12
|
+
<td align="center" valign="middle" width="50%">
|
|
13
|
+
<a href="https://castaly.modelflare.dev/sign-up?partner=1GIMVVBLWP1V">
|
|
14
|
+
<img alt="Castaly sponsorship" width="400" src="https://pics.picgo.app/m/284def41-2f23-47e6-9d64-7017d386a221.png">
|
|
15
|
+
</a>
|
|
16
|
+
<h3><a href="https://castaly.modelflare.dev/sign-up?partner=1GIMVVBLWP1V">Castaly</a></h3>
|
|
17
|
+
<p>Castaly: Full strength, no upscaling. 40+ image and video models, including NSFW.</p>
|
|
18
|
+
</td>
|
|
19
|
+
</tr>
|
|
20
|
+
<tr>
|
|
21
|
+
<td align="center" valign="middle" width="50%">
|
|
22
|
+
<a href="https://www.nocobase.com/?utm_source=picgo">
|
|
23
|
+
<img alt="NocoBase sponsorship" width="400" src="https://static-docs.nocobase.com/Logo-Black.png">
|
|
24
|
+
</a>
|
|
25
|
+
<h3><a href="https://www.nocobase.com/?utm_source=picgo">NocoBase</a></h3>
|
|
26
|
+
<p>AI + No-Code Build reliable business systems</p>
|
|
27
|
+
</td>
|
|
28
|
+
<td align="center" valign="middle" width="50%">
|
|
29
|
+
<a href="https://console.neon.tech/app/?promo=PicGo">
|
|
30
|
+
<picture>
|
|
31
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://neon.com/brand/neon-logo-dark-color.svg">
|
|
32
|
+
<source media="(prefers-color-scheme: light)" srcset="https://neon.com/brand/neon-logo-light-color.svg">
|
|
33
|
+
<img alt="Neon sponsorship" width="400" src="https://neon.com/brand/neon-logo-dark-color.svg">
|
|
34
|
+
</picture>
|
|
35
|
+
</a>
|
|
36
|
+
<h3><a href="https://console.neon.tech/app/?promo=PicGo">Neon</a></h3>
|
|
37
|
+
<p>Fast Postgres Databases for Teams and Agents</p>
|
|
38
|
+
</td>
|
|
39
|
+
</tr>
|
|
40
|
+
</table>
|
|
10
41
|
</div>
|
|
11
42
|
|
|
12
43
|
---
|
|
@@ -96,6 +127,21 @@ $ picgo -h
|
|
|
96
127
|
picgo upload /xxx/xx/xx.jpg
|
|
97
128
|
```
|
|
98
129
|
|
|
130
|
+
#### Upload with a saved configuration
|
|
131
|
+
|
|
132
|
+
Use `--configName` to choose a saved configuration for one upload. Add `--uploader` when the same name exists in multiple uploader types. You can also use `--configId`; a unique ID match takes precedence over the name, and an unresolved ID falls back to the name when provided.
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
picgo upload ./photo.png --configName=Work
|
|
136
|
+
picgo upload ./photo.png --uploader=github --configName="Work Images"
|
|
137
|
+
picgo upload ./photo.png --uploader=github --configId=your-config-id --configName=Work
|
|
138
|
+
|
|
139
|
+
# Upload from the clipboard with a saved configuration.
|
|
140
|
+
picgo upload --configName=Work
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
These options use the same lookup rules as HTTP and SDK uploads and do not change saved defaults. Without these options, `picgo upload` retains its existing default behavior. Existing local input files are retained after upload; only temporary multipart files and clipboard images created by PicGo are cleaned up. Clipboard filenames keep the existing `YYYYMMDDHHmmssSSS.png` format.
|
|
144
|
+
|
|
99
145
|
#### Upload a picture from clipboard
|
|
100
146
|
|
|
101
147
|
> picture from clipboard will be converted to `png`
|
|
@@ -112,6 +158,40 @@ Thanks to [vs-picgo](https://github.com/Spades-S/vs-picgo) && [Spades-S](https:/
|
|
|
112
158
|
picgo server -p 36677 -h 127.0.0.1
|
|
113
159
|
```
|
|
114
160
|
|
|
161
|
+
##### Select a configuration for one upload
|
|
162
|
+
|
|
163
|
+
Add `uploader`, `configName`, or `configId` to `POST /upload` to choose an existing saved configuration for that request. Configuration names are recommended for readability. Use URL encoding for names containing spaces, Chinese characters, or other special characters:
|
|
164
|
+
|
|
165
|
+
```js
|
|
166
|
+
const url = new URL('http://127.0.0.1:36677/upload')
|
|
167
|
+
url.searchParams.set('uploader', 'github')
|
|
168
|
+
url.searchParams.set('configName', 'Work')
|
|
169
|
+
|
|
170
|
+
const response = await fetch(url, {
|
|
171
|
+
method: 'POST',
|
|
172
|
+
headers: { 'Content-Type': 'application/json' },
|
|
173
|
+
body: JSON.stringify({ list: ['/absolute/path/photo.png'] })
|
|
174
|
+
})
|
|
175
|
+
const result = await response.json()
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
The same query parameters work with an empty body for clipboard uploads, JSON without `list` or with an empty `list`, and multipart uploads using the `files` field. If server authentication is enabled, include your existing `Authorization: Bearer <secret>` header.
|
|
179
|
+
|
|
180
|
+
| Upload options | Behavior |
|
|
181
|
+
| --- | --- |
|
|
182
|
+
| No upload options | Existing default upload behavior. |
|
|
183
|
+
| `uploader=github` | Use GitHub's currently selected configuration (`defaultId`, falling back to its first configuration). |
|
|
184
|
+
| `uploader=github&configName=Work` | Find `Work` within GitHub, ignoring case and surrounding whitespace. |
|
|
185
|
+
| `configName=Work` | Search registered uploader types; exactly one configuration must match. |
|
|
186
|
+
| `configId=<id>` | Search by exact ID, optionally restricted by `uploader`. IDs remain stable when configurations are renamed. |
|
|
187
|
+
| Both `configId` and `configName` | Use a unique ID match first; if it cannot be uniquely resolved, try the name. |
|
|
188
|
+
|
|
189
|
+
Unknown uploaders, missing or ambiguous configurations, and blank or repeated upload parameters return HTTP `400` with `{ success: false, result: [], items: [], code, message }`. Messages explain the lookup failure or ambiguity; specify `uploader` to disambiguate names shared across types. Invalid upload options never fall back to the global default uploader. Existing authentication failures remain HTTP `401`.
|
|
190
|
+
|
|
191
|
+
Upload options do not change global defaults or save the requested configuration to disk. Concurrent requests can use different configurations. Plugins that read configuration through the context passed to their lifecycle handler see the request's configuration; plugins that cache global configuration may need adaptation. Explicit plugin persistence and Cloud session maintenance retain their normal behavior. `uploader=picgo-cloud` uses the current Cloud login; these options do not switch Cloud accounts.
|
|
192
|
+
|
|
193
|
+
Applications providing a custom internal server upload adapter must forward the optional `UploadOptions` argument to `picgo.upload`: `uploadPaths(paths, options)` forwards to `picgo.upload(paths, options)`, and `uploadClipboard(options)` forwards to `picgo.upload(undefined, options)`. Existing adapters can still handle requests without selectors, but ignoring these options will ignore the requested destination.
|
|
194
|
+
|
|
115
195
|
#### Login to [PicGo Cloud](https://cloud.picgo.app)
|
|
116
196
|
|
|
117
197
|
```bash
|
|
@@ -248,6 +328,43 @@ picgo.upload(['/xxx/xxx.jpg'])
|
|
|
248
328
|
picgo.upload()
|
|
249
329
|
```
|
|
250
330
|
|
|
331
|
+
The SDK accepts the same selectors in the second argument:
|
|
332
|
+
|
|
333
|
+
```js
|
|
334
|
+
import { PicGo, UploadOptionError } from 'picgo'
|
|
335
|
+
|
|
336
|
+
const picgo = new PicGo()
|
|
337
|
+
|
|
338
|
+
try {
|
|
339
|
+
await picgo.upload(['/absolute/path/photo.png'], {
|
|
340
|
+
uploader: 'github',
|
|
341
|
+
configName: 'Work'
|
|
342
|
+
})
|
|
343
|
+
|
|
344
|
+
// A globally unique name can identify both the uploader and its configuration.
|
|
345
|
+
await picgo.upload(undefined, { configName: 'Work' })
|
|
346
|
+
} catch (error) {
|
|
347
|
+
if (error instanceof UploadOptionError) {
|
|
348
|
+
console.error(error.code, error.message)
|
|
349
|
+
} else {
|
|
350
|
+
throw error
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
Invalid upload options reject the upload promise before processing inputs. Error codes are `INVALID_UPLOAD_OPTION`, `UNKNOWN_UPLOADER`, `UPLOAD_CONFIG_NOT_FOUND`, and `UPLOAD_CONFIG_AMBIGUOUS`. Temporary `setConfig`/`unsetConfig` calls on a scoped upload context affect that upload only; explicit `saveConfig`/`removeConfig` calls remain persistent. Existing SDK calls without upload options keep their behavior.
|
|
356
|
+
|
|
357
|
+
## Development
|
|
358
|
+
|
|
359
|
+
Use Node.js >= 22.13 and pnpm 11.7.0 for repository development. The package manager is pinned in `package.json`; `pnpm-workspace.yaml` records the allowed esbuild installation script. This tooling requirement does not change PicGo's published runtime requirements.
|
|
360
|
+
|
|
361
|
+
```bash
|
|
362
|
+
pnpm install --frozen-lockfile
|
|
363
|
+
pnpm lint
|
|
364
|
+
pnpm test
|
|
365
|
+
pnpm build
|
|
366
|
+
```
|
|
367
|
+
|
|
251
368
|
## Documentation
|
|
252
369
|
|
|
253
370
|
For more details, you can checkout [documentation](https://docs.picgo.app/core/).
|
package/dist/core/Lifecycle.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { EventEmitter } from 'events';
|
|
|
2
2
|
import { IPicGo, UploadOptions } from '../types';
|
|
3
3
|
export declare class Lifecycle extends EventEmitter {
|
|
4
4
|
private readonly ctx;
|
|
5
|
-
private step;
|
|
6
5
|
constructor(ctx: IPicGo);
|
|
7
6
|
start(input: any[], options?: UploadOptions): Promise<IPicGo>;
|
|
8
7
|
private beforeTransform;
|
|
@@ -13,4 +12,3 @@ export declare class Lifecycle extends EventEmitter {
|
|
|
13
12
|
private buildSuccessMessage;
|
|
14
13
|
private handlePlugins;
|
|
15
14
|
}
|
|
16
|
-
export default Lifecycle;
|
package/dist/i18n/zh-CN.d.ts
CHANGED
|
@@ -5,6 +5,14 @@ export declare const ZH_CN: {
|
|
|
5
5
|
UPLOAD_FAILED_REASON: string;
|
|
6
6
|
SERVER_ERROR: string;
|
|
7
7
|
AUTH_FAILED: string;
|
|
8
|
+
CONFIG_INVALID_FORMAT: string;
|
|
9
|
+
CONFIG_KEY_READ_ONLY: string;
|
|
10
|
+
CONFIG_KEY_CANNOT_UNSET: string;
|
|
11
|
+
UPLOAD_OPTION_INVALID_PARAMETER: string;
|
|
12
|
+
UPLOAD_OPTION_ACTIVE_CONFIG: string;
|
|
13
|
+
UPLOAD_OPTION_UNKNOWN_UPLOADER: string;
|
|
14
|
+
UPLOAD_OPTION_CONFIG_NOT_FOUND: string;
|
|
15
|
+
UPLOAD_OPTION_CONFIG_AMBIGUOUS: string;
|
|
8
16
|
CLOUD_LOGIN_CANCELLED: string;
|
|
9
17
|
CLOUD_LOGIN_IN_PROGRESS: string;
|
|
10
18
|
CLOUD_LOGIN_INVALID_TOKEN: string;
|