image-exporter 1.2.2 → 1.3.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/README.md +32 -3
- package/dist/capture/capture-element.d.ts +2 -1
- package/dist/capture/capture-element.d.ts.map +1 -1
- package/dist/capture/capture.dom.test.d.ts +2 -0
- package/dist/capture/capture.dom.test.d.ts.map +1 -0
- package/dist/capture/copy-to-clipboard.d.ts +13 -0
- package/dist/capture/copy-to-clipboard.d.ts.map +1 -0
- package/dist/capture/copy-to-clipboard.dom.test.d.ts +2 -0
- package/dist/capture/copy-to-clipboard.dom.test.d.ts.map +1 -0
- package/dist/capture/cors-cleanup.dom.test.d.ts +2 -0
- package/dist/capture/cors-cleanup.dom.test.d.ts.map +1 -0
- package/dist/capture/data-url-to-blob.d.ts +9 -0
- package/dist/capture/data-url-to-blob.d.ts.map +1 -0
- package/dist/capture/data-url-to-blob.node.test.d.ts +2 -0
- package/dist/capture/data-url-to-blob.node.test.d.ts.map +1 -0
- package/dist/capture/dedup-consistency.node.test.d.ts +2 -0
- package/dist/capture/dedup-consistency.node.test.d.ts.map +1 -0
- package/dist/capture/determine-total-elements.d.ts +7 -3
- package/dist/capture/determine-total-elements.d.ts.map +1 -1
- package/dist/capture/determine-total-elements.dom.test.d.ts +2 -0
- package/dist/capture/determine-total-elements.dom.test.d.ts.map +1 -0
- package/dist/capture/download-images.d.ts +8 -0
- package/dist/capture/download-images.d.ts.map +1 -1
- package/dist/capture/get-image-options.dom.test.d.ts +2 -0
- package/dist/capture/get-image-options.dom.test.d.ts.map +1 -0
- package/dist/capture/handle-filenames.d.ts +5 -6
- package/dist/capture/handle-filenames.d.ts.map +1 -1
- package/dist/capture/index.d.ts.map +1 -1
- package/dist/capture/make-unique.d.ts +14 -0
- package/dist/capture/make-unique.d.ts.map +1 -0
- package/dist/capture/make-unique.node.test.d.ts +2 -0
- package/dist/capture/make-unique.node.test.d.ts.map +1 -0
- package/dist/index.browser.js +16 -16
- package/dist/index.browser.js.map +20 -17
- package/dist/index.cjs +198 -125
- package/dist/index.cjs.map +20 -17
- package/dist/index.d.ts +10 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +198 -125
- package/dist/index.js.map +20 -17
- package/dist/logger.d.ts +5 -5
- package/dist/logger.d.ts.map +1 -1
- package/dist/types.d.ts +81 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +27 -3
package/dist/logger.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export declare const log: {
|
|
2
|
-
info: (...messages:
|
|
3
|
-
error: (...messages:
|
|
4
|
-
verbose: (...messages:
|
|
2
|
+
info: (...messages: unknown[]) => Promise<void>;
|
|
3
|
+
error: (...messages: unknown[]) => Promise<void>;
|
|
4
|
+
verbose: (...messages: unknown[]) => Promise<void>;
|
|
5
5
|
progress: (progress: number, total: number) => Promise<void>;
|
|
6
6
|
group: {
|
|
7
|
-
open: (...messages:
|
|
8
|
-
close: (...messages:
|
|
7
|
+
open: (...messages: unknown[]) => Promise<void>;
|
|
8
|
+
close: (...messages: unknown[]) => Promise<void>;
|
|
9
9
|
};
|
|
10
10
|
};
|
|
11
11
|
type LogType = "info" | "error" | "verbose" | "progress" | "group" | "groupEnd";
|
package/dist/logger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,GAAG;wBACM,OAAO,EAAE;yBACR,OAAO,EAAE;2BACP,OAAO,EAAE;yBACX,MAAM,SAAS,MAAM;;4BAEpB,OAAO,EAAE;6BACR,OAAO,EAAE;;CAEjC,CAAC;AAyCF,KAAK,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,UAAU,GAAG,OAAO,GAAG,UAAU,CAAC;AAEhF,KAAK,GAAG,GAAG;IACT,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,KAAK,QAAQ,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEjC,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,iBAAiB,EAAE,GAAG,EAAE,CAAC;QACzB,qBAAqB,EAAE,QAAQ,EAAE,CAAC;KACnC;CACF"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { Options as ModernScreenshotOptions } from "modern-screenshot";
|
|
2
|
+
export interface ImageOptions {
|
|
3
|
+
/** Label for image. Does not include file extension or scale. */
|
|
4
|
+
label: Label;
|
|
5
|
+
/** File format, jpg, png, or svg. */
|
|
6
|
+
format: Format;
|
|
7
|
+
/** Scale of image. Can be a number or a comma-separated list of numbers. */
|
|
8
|
+
scale: Scale;
|
|
9
|
+
/** Quality of image. 0.0 to 1.0, only applies to jpg.*/
|
|
10
|
+
quality: Quality;
|
|
11
|
+
/** Include scale in label. True or false. Automatically true if scale is an array. */
|
|
12
|
+
includeScaleInLabel: IncludeScaleInLabel;
|
|
13
|
+
}
|
|
14
|
+
export interface Config extends ImageOptions {
|
|
15
|
+
/** Download images as files upon capture. */
|
|
16
|
+
downloadImages: boolean;
|
|
17
|
+
/** Default label for images. Does not include file extension or scale. */
|
|
18
|
+
defaultImageLabel: string;
|
|
19
|
+
/** Label for zip file. Does not include file extension or scale. */
|
|
20
|
+
zipLabel: Label;
|
|
21
|
+
/** Base URL for CORS proxy used when fetching external images.
|
|
22
|
+
*
|
|
23
|
+
* URLs will be encoded and appended without a `?`. Include your own trailing slash.
|
|
24
|
+
*
|
|
25
|
+
* I recommend [cors-proxy-worker](https://github.com/briantuckerdesign/cors-proxy-worker) for production and [local-cors-proxy-encoded](https://github.com/briantuckerdesign/local-cors-proxy-encoded) for development.
|
|
26
|
+
*
|
|
27
|
+
* Example: `https://cors-proxy.com/` -> `https://cors-proxy.com/https%3A%2F%2FmyEncodedUrl.com`
|
|
28
|
+
*/
|
|
29
|
+
corsProxyBaseUrl: string;
|
|
30
|
+
/** Enable window logging for use by external scripts. */
|
|
31
|
+
enableWindowLogging: boolean;
|
|
32
|
+
/** Enable verbose logging for debugging. */
|
|
33
|
+
loggingLevel: LoggingLevel;
|
|
34
|
+
/**
|
|
35
|
+
* Called after each capture completes, with the number completed so far and
|
|
36
|
+
* the total number of captures. A package-friendly alternative to polling
|
|
37
|
+
* `window.imageExporterProgress`.
|
|
38
|
+
*/
|
|
39
|
+
onProgress?: (completed: number, total: number) => void;
|
|
40
|
+
/**
|
|
41
|
+
* Abort an in-progress capture. When the signal fires, the loop stops and
|
|
42
|
+
* the images captured so far are returned (download is skipped).
|
|
43
|
+
*/
|
|
44
|
+
signal?: AbortSignal;
|
|
45
|
+
/**
|
|
46
|
+
* Extra options passed through to modern-screenshot (fonts, width/height,
|
|
47
|
+
* pixelRatio, backgroundColor, etc.). `scale` and `quality` remain controlled
|
|
48
|
+
* by the per-image options; a `filter` here is combined with the built-in
|
|
49
|
+
* `data-ignore-capture` filter (both must pass).
|
|
50
|
+
*/
|
|
51
|
+
screenshotOptions?: Partial<ModernScreenshotOptions>;
|
|
52
|
+
/**
|
|
53
|
+
* What the returned images carry:
|
|
54
|
+
* - `"dataurl"` (default): `dataURL` only
|
|
55
|
+
* - `"blob"`: `blob` only (no base64 retained — lighter on memory)
|
|
56
|
+
* - `"both"`: `dataURL` and `blob`
|
|
57
|
+
*
|
|
58
|
+
* Downloading works in every mode.
|
|
59
|
+
*/
|
|
60
|
+
output?: Output;
|
|
61
|
+
}
|
|
62
|
+
export interface ParsedImageOptions extends ImageOptions {
|
|
63
|
+
/** After parsing, this will always be a number rather than possibly an array. */
|
|
64
|
+
scale: number;
|
|
65
|
+
}
|
|
66
|
+
export interface Image {
|
|
67
|
+
/** base64 data URL. Empty when `output` is `"blob"`. */
|
|
68
|
+
dataURL: string;
|
|
69
|
+
fileName: string;
|
|
70
|
+
/** Populated when `config.output` is `"blob"` or `"both"`. */
|
|
71
|
+
blob?: Blob;
|
|
72
|
+
}
|
|
73
|
+
/** What the returned Image carries. Default `"dataurl"`. */
|
|
74
|
+
export type Output = "dataurl" | "blob" | "both";
|
|
75
|
+
export type Label = string;
|
|
76
|
+
export type Format = "jpg" | "png" | "svg" | "webp";
|
|
77
|
+
export type Scale = number | number[];
|
|
78
|
+
export type Quality = number;
|
|
79
|
+
export type IncludeScaleInLabel = boolean;
|
|
80
|
+
export type LoggingLevel = "none" | "info" | "error" | "verbose";
|
|
81
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,IAAI,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAE5E,MAAM,WAAW,YAAY;IAC3B,iEAAiE;IACjE,KAAK,EAAE,KAAK,CAAC;IACb,qCAAqC;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,4EAA4E;IAC5E,KAAK,EAAE,KAAK,CAAC;IACb,wDAAwD;IACxD,OAAO,EAAE,OAAO,CAAC;IACjB,sFAAsF;IACtF,mBAAmB,EAAE,mBAAmB,CAAC;CAC1C;AAED,MAAM,WAAW,MAAO,SAAQ,YAAY;IAC1C,6CAA6C;IAC7C,cAAc,EAAE,OAAO,CAAC;IACxB,0EAA0E;IAC1E,iBAAiB,EAAE,MAAM,CAAC;IAC1B,oEAAoE;IACpE,QAAQ,EAAE,KAAK,CAAC;IAChB;;;;;;;OAOG;IACH,gBAAgB,EAAE,MAAM,CAAC;IACzB,yDAAyD;IACzD,mBAAmB,EAAE,OAAO,CAAC;IAC7B,4CAA4C;IAC5C,YAAY,EAAE,YAAY,CAAC;IAC3B;;;;OAIG;IACH,UAAU,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxD;;;OAGG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACrD;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,kBAAmB,SAAQ,YAAY;IACtD,iFAAiF;IACjF,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,KAAK;IACpB,wDAAwD;IACxD,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,8DAA8D;IAC9D,IAAI,CAAC,EAAE,IAAI,CAAC;CACb;AAED,4DAA4D;AAC5D,MAAM,MAAM,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;AAEjD,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC;AAC3B,MAAM,MAAM,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,CAAC;AACpD,MAAM,MAAM,KAAK,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC;AACtC,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC;AAC7B,MAAM,MAAM,mBAAmB,GAAG,OAAO,CAAC;AAC1C,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "image-exporter",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Easily download one or more DOM elements as images",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
7
7
|
"module": "./dist/index.js",
|
|
8
8
|
"browser": "./dist/index.browser.js",
|
|
9
|
+
"unpkg": "./dist/index.browser.js",
|
|
10
|
+
"jsdelivr": "./dist/index.browser.js",
|
|
9
11
|
"types": "./dist/index.d.ts",
|
|
10
12
|
"exports": {
|
|
11
13
|
".": {
|
|
@@ -23,6 +25,14 @@
|
|
|
23
25
|
"scripts": {
|
|
24
26
|
"dev": "bun run --watch src/index.ts",
|
|
25
27
|
"build": "bun run scripts/build.ts",
|
|
28
|
+
"test": "bun run test:dom && bun run test:node",
|
|
29
|
+
"test:dom": "bun test --preload ./test/happydom.ts dom.test",
|
|
30
|
+
"test:node": "bun test node.test",
|
|
31
|
+
"typecheck": "tsc --noEmit -p tsconfig.test.json",
|
|
32
|
+
"lint": "eslint .",
|
|
33
|
+
"format:check": "prettier --check \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
34
|
+
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
35
|
+
"release": "bun run build && changeset publish",
|
|
26
36
|
"prepublishOnly": "bun run build"
|
|
27
37
|
},
|
|
28
38
|
"repository": {
|
|
@@ -39,18 +49,32 @@
|
|
|
39
49
|
"gennyflow"
|
|
40
50
|
],
|
|
41
51
|
"author": "Brian Tucker",
|
|
42
|
-
"license": "
|
|
52
|
+
"license": "Apache-2.0",
|
|
43
53
|
"bugs": {
|
|
44
54
|
"url": "https://github.com/briantuckerdesign/image-exporter/issues"
|
|
45
55
|
},
|
|
46
56
|
"homepage": "https://github.com/briantuckerdesign/image-exporter#readme",
|
|
57
|
+
"publishConfig": {
|
|
58
|
+
"access": "public",
|
|
59
|
+
"provenance": true
|
|
60
|
+
},
|
|
47
61
|
"dependencies": {
|
|
48
62
|
"jszip": "^3.10.1",
|
|
49
63
|
"modern-screenshot": "^4.6.0"
|
|
50
64
|
},
|
|
51
65
|
"devDependencies": {
|
|
66
|
+
"@changesets/changelog-github": "^0.7.0",
|
|
67
|
+
"@changesets/cli": "^2.31.0",
|
|
68
|
+
"@eslint/js": "^10.0.1",
|
|
69
|
+
"@happy-dom/global-registrator": "^20.10.6",
|
|
70
|
+
"@types/bun": "^1.3.14",
|
|
52
71
|
"concurrently": "^9.1.2",
|
|
72
|
+
"eslint": "^10.5.0",
|
|
73
|
+
"eslint-config-prettier": "^10.1.8",
|
|
74
|
+
"globals": "^17.7.0",
|
|
53
75
|
"http-server": "^14.1.1",
|
|
54
|
-
"
|
|
76
|
+
"prettier": "^3.8.4",
|
|
77
|
+
"typescript": "^5.7.3",
|
|
78
|
+
"typescript-eslint": "^8.62.0"
|
|
55
79
|
}
|
|
56
80
|
}
|