img-upload-kit 1.1.1 → 2.0.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/CHANGELOG.md +56 -41
- package/MIGRATION.md +192 -0
- package/README.md +138 -154
- package/dist/bin.js +1186 -0
- package/dist/bin.js.map +1 -0
- package/dist/blur.cjs +40 -412
- package/dist/blur.cjs.map +1 -1
- package/dist/blur.d.cts +5 -5
- package/dist/blur.d.ts +5 -5
- package/dist/blur.js +39 -393
- package/dist/blur.js.map +1 -1
- package/dist/blurDataUtils-DveBRtqE.d.cts +43 -0
- package/dist/blurDataUtils-yx9Q6HlU.d.ts +43 -0
- package/dist/blurService-D5TpMNji.d.ts +83 -0
- package/dist/blurService-DacwylJx.d.cts +83 -0
- package/dist/chunk-2OVNXHTN.cjs +514 -0
- package/dist/chunk-2OVNXHTN.cjs.map +1 -0
- package/dist/chunk-3ICG2SLL.cjs +135 -0
- package/dist/chunk-3ICG2SLL.cjs.map +1 -0
- package/dist/chunk-4ASFG3KB.js +514 -0
- package/dist/chunk-4ASFG3KB.js.map +1 -0
- package/dist/chunk-AI3JJLSA.js +2370 -0
- package/dist/chunk-AI3JJLSA.js.map +1 -0
- package/dist/chunk-CV23O4YU.js +145 -0
- package/dist/chunk-CV23O4YU.js.map +1 -0
- package/dist/chunk-G7LLSKBV.js +158 -0
- package/dist/chunk-G7LLSKBV.js.map +1 -0
- package/dist/chunk-IB3TEDLR.js +294 -0
- package/dist/chunk-IB3TEDLR.js.map +1 -0
- package/dist/chunk-KJVYWKIG.cjs +158 -0
- package/dist/chunk-KJVYWKIG.cjs.map +1 -0
- package/dist/chunk-NEDBIIE3.cjs +226 -0
- package/dist/chunk-NEDBIIE3.cjs.map +1 -0
- package/dist/chunk-QHU7FUO4.cjs +37 -0
- package/dist/chunk-QHU7FUO4.cjs.map +1 -0
- package/dist/chunk-QQHZJKNA.js +135 -0
- package/dist/chunk-QQHZJKNA.js.map +1 -0
- package/dist/chunk-S2IFAWJK.js +37 -0
- package/dist/chunk-S2IFAWJK.js.map +1 -0
- package/dist/chunk-TT5C7K3Q.js +226 -0
- package/dist/chunk-TT5C7K3Q.js.map +1 -0
- package/dist/chunk-U2TWTEBY.cjs +2370 -0
- package/dist/chunk-U2TWTEBY.cjs.map +1 -0
- package/dist/chunk-WISG74VL.cjs +294 -0
- package/dist/chunk-WISG74VL.cjs.map +1 -0
- package/dist/chunk-YRXXQUDE.cjs +145 -0
- package/dist/chunk-YRXXQUDE.cjs.map +1 -0
- package/dist/cli.cjs +273 -76
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +269 -73
- package/dist/cli.js.map +1 -1
- package/dist/headless.cjs +8 -1880
- package/dist/headless.cjs.map +1 -1
- package/dist/headless.d.cts +3 -1
- package/dist/headless.d.ts +3 -1
- package/dist/headless.js +25 -1886
- package/dist/headless.js.map +1 -1
- package/dist/index-BIdnqtW8.d.ts +234 -0
- package/dist/index-Brk_uHs6.d.cts +234 -0
- package/dist/{index-FVXXKf2v.d.ts → index-CPMlaQsC.d.ts} +76 -153
- package/dist/{index-FVXXKf2v.d.cts → index-DHINe-rA.d.cts} +76 -153
- package/dist/index.cjs +64 -532
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -4
- package/dist/index.d.ts +7 -4
- package/dist/index.js +63 -504
- package/dist/index.js.map +1 -1
- package/dist/{memoryAdapter-CBu7_3Pp.d.ts → memoryAdapter-Ck0ccZbF.d.cts} +3 -2
- package/dist/{memoryAdapter-BJjyLR-1.d.cts → memoryAdapter-DxEKaG0b.d.ts} +3 -2
- package/dist/placeholders-C4ftwaII.d.ts +5 -0
- package/dist/placeholders-x_3rt65M.d.cts +5 -0
- package/dist/react.cjs +1952 -3257
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +188 -50
- package/dist/react.d.ts +188 -50
- package/dist/react.js +1763 -3013
- package/dist/react.js.map +1 -1
- package/dist/server-handler.cjs +14 -0
- package/dist/server-handler.cjs.map +1 -0
- package/dist/server-handler.d.cts +3 -0
- package/dist/server-handler.d.ts +3 -0
- package/dist/server-handler.js +14 -0
- package/dist/server-handler.js.map +1 -0
- package/dist/server.cjs +1096 -532
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +77 -154
- package/dist/server.d.ts +77 -154
- package/dist/server.js +1050 -448
- package/dist/server.js.map +1 -1
- package/dist/storage.cjs +239 -232
- package/dist/storage.cjs.map +1 -1
- package/dist/storage.d.cts +21 -5
- package/dist/storage.d.ts +21 -5
- package/dist/storage.js +227 -207
- package/dist/storage.js.map +1 -1
- package/dist/styles/animated-image.css +112 -0
- package/dist/styles/dropzone-and-tiles.css +247 -0
- package/dist/styles/modals-and-dock.css +248 -0
- package/dist/styles/primitives.css +197 -0
- package/dist/styles/quality-and-inputs.css +184 -0
- package/dist/styles/tokens.css +123 -0
- package/dist/styles.css +39 -24
- package/dist/types-BrP-o9nd.d.cts +85 -0
- package/dist/types-sZ3KoFQY.d.ts +85 -0
- package/dist/types-yShGNQnW.d.cts +61 -0
- package/dist/types-yShGNQnW.d.ts +61 -0
- package/dist/{types-CiLY0DwB.d.cts → upload-C5Trd6Dh.d.cts} +27 -53
- package/dist/{types-CiLY0DwB.d.ts → upload-C5Trd6Dh.d.ts} +27 -53
- package/package.json +92 -32
- package/dist/blurService-DqsnfPTd.d.cts +0 -172
- package/dist/blurService-DqsnfPTd.d.ts +0 -172
|
@@ -62,11 +62,18 @@ interface UploadPresetConfig {
|
|
|
62
62
|
};
|
|
63
63
|
/** Generate compact BlurHash string alongside WebP LQIP data URL */
|
|
64
64
|
includeBlurHash?: boolean;
|
|
65
|
+
/** Opt-in to allow SVG uploads for this preset (sanitized before storage). Defaults to `false`. */
|
|
66
|
+
allowSvg?: boolean;
|
|
67
|
+
/** Maximum input pixel count allowed by Sharp (defaults to 50 MP = 50,000,000) */
|
|
68
|
+
limitInputPixels?: number;
|
|
69
|
+
/** Responsive variant widths in pixels (e.g. [640, 1024, 1920]); widths >= main image width are skipped */
|
|
70
|
+
variantWidths?: number[];
|
|
65
71
|
/** Optional local directory to mirror uploaded files into */
|
|
66
72
|
mirrorDir?: string;
|
|
67
73
|
/** Optional public URL prefix when `mirrorDir` is used */
|
|
68
74
|
publicUrlBase?: string;
|
|
69
75
|
}
|
|
76
|
+
declare const SVG_MIME_TYPE = "image/svg+xml";
|
|
70
77
|
declare const DEFAULT_ALLOWED_FORMATS: string[];
|
|
71
78
|
declare const RASTER_ALLOWED_FORMATS: string[];
|
|
72
79
|
declare const DEFAULT_IMAGE_DIMENSIONS: ImageDimensions;
|
|
@@ -101,6 +108,23 @@ interface ImageUploadOptions<TPreset extends string = UploadPresetName> {
|
|
|
101
108
|
metadata?: Record<string, string>;
|
|
102
109
|
/** Generate compact BlurHash string alongside WebP LQIP data URL */
|
|
103
110
|
includeBlurHash?: boolean;
|
|
111
|
+
/** Opt-in to allow SVG uploads (sanitized before storage). Defaults to `false`. */
|
|
112
|
+
allowSvg?: boolean;
|
|
113
|
+
/** Maximum input pixel count allowed by Sharp (defaults to 50 MP = 50,000,000) */
|
|
114
|
+
limitInputPixels?: number;
|
|
115
|
+
/** Marks `customFilename` as client-supplied (disables upsert and retries with a suffix on collision) */
|
|
116
|
+
isClientFilename?: boolean;
|
|
117
|
+
/** Target widths (px) for responsive image variants (widths >= main output width are skipped) */
|
|
118
|
+
variantWidths?: number[];
|
|
119
|
+
/** Optional AbortSignal to cancel queued or in-flight processing */
|
|
120
|
+
signal?: AbortSignal;
|
|
121
|
+
}
|
|
122
|
+
interface ImageVariant {
|
|
123
|
+
width: number;
|
|
124
|
+
height: number;
|
|
125
|
+
url: string;
|
|
126
|
+
size: number;
|
|
127
|
+
storagePath?: string;
|
|
104
128
|
}
|
|
105
129
|
interface UploadedImageData {
|
|
106
130
|
url: string;
|
|
@@ -119,62 +143,12 @@ interface UploadedImageData {
|
|
|
119
143
|
preset?: string;
|
|
120
144
|
folder?: string;
|
|
121
145
|
metadata?: Record<string, string>;
|
|
146
|
+
variants?: ImageVariant[];
|
|
147
|
+
srcSet?: string;
|
|
122
148
|
uploadedAt: string;
|
|
123
149
|
}
|
|
124
150
|
interface ImageUploadRecord extends UploadedImageData {
|
|
125
151
|
quality: number;
|
|
126
152
|
}
|
|
127
153
|
|
|
128
|
-
|
|
129
|
-
bucket: string;
|
|
130
|
-
path: string;
|
|
131
|
-
data: Buffer | Uint8Array;
|
|
132
|
-
contentType: string;
|
|
133
|
-
upsert?: boolean;
|
|
134
|
-
cacheControl?: string;
|
|
135
|
-
contentHash?: string;
|
|
136
|
-
metadata?: Record<string, string>;
|
|
137
|
-
}
|
|
138
|
-
interface StorageUploadResult {
|
|
139
|
-
bucket: string;
|
|
140
|
-
path: string;
|
|
141
|
-
url: string;
|
|
142
|
-
}
|
|
143
|
-
interface StorageFileEntry {
|
|
144
|
-
name: string;
|
|
145
|
-
id?: string;
|
|
146
|
-
createdAt?: string;
|
|
147
|
-
size?: number;
|
|
148
|
-
}
|
|
149
|
-
type StorageUploadOptions = StorageUploadParams;
|
|
150
|
-
type StorageFileMetadata = StorageFileEntry;
|
|
151
|
-
type StorageListResult = StorageFileEntry[];
|
|
152
|
-
interface StorageAdapter {
|
|
153
|
-
/**
|
|
154
|
-
* Upload optimized image bytes to your storage backend and return its public URL.
|
|
155
|
-
*/
|
|
156
|
-
upload(params: StorageUploadParams): Promise<StorageUploadResult>;
|
|
157
|
-
/**
|
|
158
|
-
* Delete an image from your storage backend by bucket and relative path.
|
|
159
|
-
*/
|
|
160
|
-
delete(bucket: string, path: string): Promise<void>;
|
|
161
|
-
/**
|
|
162
|
-
* Optional: Resolve a public URL for a bucket and path.
|
|
163
|
-
*/
|
|
164
|
-
getPublicUrl?(bucket: string, path: string): string | Promise<string>;
|
|
165
|
-
/**
|
|
166
|
-
* Optional: List files inside a bucket/folder.
|
|
167
|
-
*/
|
|
168
|
-
list?(bucket: string, folder?: string): Promise<StorageFileEntry[]>;
|
|
169
|
-
/**
|
|
170
|
-
* Optional: Delete an asset directly from its public URL.
|
|
171
|
-
*/
|
|
172
|
-
deleteByUrl?(url: string): Promise<boolean>;
|
|
173
|
-
}
|
|
174
|
-
type UploadRecordHook = (record: ImageUploadRecord) => void | Promise<void>;
|
|
175
|
-
/**
|
|
176
|
-
* Type-safe helper for authoring a custom StorageAdapter (S3, R2, Vercel Blob, Firebase, etc.).
|
|
177
|
-
*/
|
|
178
|
-
declare function createStorageAdapter(adapter: StorageAdapter): StorageAdapter;
|
|
179
|
-
|
|
180
|
-
export { DEFAULT_ALLOWED_FORMATS as D, type ExplicitOutputFormat as E, type ImageDimensions as I, type QualityLevel as Q, RASTER_ALLOWED_FORMATS as R, STANDARD_PRESETS as S, type UploadLocale as U, DEFAULT_IMAGE_DIMENSIONS as a, type ImageOutputFormat as b, type ImageUploadOptions as c, type ImageUploadRecord as d, QUALITY_PRESETS as e, type QualityPreset as f, type StandardPresetName as g, type StorageAdapter as h, type StorageFileEntry as i, type StorageFileMetadata as j, type StorageListResult as k, type StorageUploadOptions as l, type StorageUploadParams as m, type StorageUploadResult as n, type UploadKitRegister as o, type UploadPresetConfig as p, type UploadPresetName as q, type UploadedImageData as r, defineUploadPresets as s, type UploadRecordHook as t, createStorageAdapter as u };
|
|
154
|
+
export { DEFAULT_ALLOWED_FORMATS as D, type ExplicitOutputFormat as E, type ImageUploadRecord as I, type QualityLevel as Q, RASTER_ALLOWED_FORMATS as R, STANDARD_PRESETS as S, type UploadLocale as U, DEFAULT_IMAGE_DIMENSIONS as a, type ImageDimensions as b, type ImageOutputFormat as c, type ImageUploadOptions as d, type ImageVariant as e, QUALITY_PRESETS as f, type QualityPreset as g, SVG_MIME_TYPE as h, type StandardPresetName as i, type UploadKitRegister as j, type UploadPresetConfig as k, type UploadPresetName as l, type UploadedImageData as m, defineUploadPresets as n };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "img-upload-kit",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"files": [
|
|
36
36
|
"dist",
|
|
37
37
|
"README.md",
|
|
38
|
+
"MIGRATION.md",
|
|
38
39
|
"CHANGELOG.md",
|
|
39
40
|
"LICENSE"
|
|
40
41
|
],
|
|
@@ -42,47 +43,93 @@
|
|
|
42
43
|
"module": "./dist/index.js",
|
|
43
44
|
"types": "./dist/index.d.ts",
|
|
44
45
|
"bin": {
|
|
45
|
-
"img-upload-kit": "dist/
|
|
46
|
-
"image-upload-kit": "dist/
|
|
47
|
-
"blur-cli": "dist/
|
|
46
|
+
"img-upload-kit": "dist/bin.js",
|
|
47
|
+
"image-upload-kit": "dist/bin.js",
|
|
48
|
+
"blur-cli": "dist/bin.js"
|
|
48
49
|
},
|
|
49
50
|
"exports": {
|
|
50
51
|
".": {
|
|
51
|
-
"
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
"import": {
|
|
53
|
+
"types": "./dist/index.d.ts",
|
|
54
|
+
"default": "./dist/index.js"
|
|
55
|
+
},
|
|
56
|
+
"require": {
|
|
57
|
+
"types": "./dist/index.d.cts",
|
|
58
|
+
"default": "./dist/index.cjs"
|
|
59
|
+
}
|
|
54
60
|
},
|
|
55
61
|
"./server": {
|
|
56
|
-
"
|
|
57
|
-
|
|
58
|
-
|
|
62
|
+
"import": {
|
|
63
|
+
"types": "./dist/server.d.ts",
|
|
64
|
+
"default": "./dist/server.js"
|
|
65
|
+
},
|
|
66
|
+
"require": {
|
|
67
|
+
"types": "./dist/server.d.cts",
|
|
68
|
+
"default": "./dist/server.cjs"
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"./server/handler": {
|
|
72
|
+
"import": {
|
|
73
|
+
"types": "./dist/server-handler.d.ts",
|
|
74
|
+
"default": "./dist/server-handler.js"
|
|
75
|
+
},
|
|
76
|
+
"require": {
|
|
77
|
+
"types": "./dist/server-handler.d.cts",
|
|
78
|
+
"default": "./dist/server-handler.cjs"
|
|
79
|
+
}
|
|
59
80
|
},
|
|
60
81
|
"./storage": {
|
|
61
|
-
"
|
|
62
|
-
|
|
63
|
-
|
|
82
|
+
"import": {
|
|
83
|
+
"types": "./dist/storage.d.ts",
|
|
84
|
+
"default": "./dist/storage.js"
|
|
85
|
+
},
|
|
86
|
+
"require": {
|
|
87
|
+
"types": "./dist/storage.d.cts",
|
|
88
|
+
"default": "./dist/storage.cjs"
|
|
89
|
+
}
|
|
64
90
|
},
|
|
65
91
|
"./blur": {
|
|
66
|
-
"
|
|
67
|
-
|
|
68
|
-
|
|
92
|
+
"import": {
|
|
93
|
+
"types": "./dist/blur.d.ts",
|
|
94
|
+
"default": "./dist/blur.js"
|
|
95
|
+
},
|
|
96
|
+
"require": {
|
|
97
|
+
"types": "./dist/blur.d.cts",
|
|
98
|
+
"default": "./dist/blur.cjs"
|
|
99
|
+
}
|
|
69
100
|
},
|
|
70
101
|
"./react": {
|
|
71
|
-
"
|
|
72
|
-
|
|
73
|
-
|
|
102
|
+
"import": {
|
|
103
|
+
"types": "./dist/react.d.ts",
|
|
104
|
+
"default": "./dist/react.js"
|
|
105
|
+
},
|
|
106
|
+
"require": {
|
|
107
|
+
"types": "./dist/react.d.cts",
|
|
108
|
+
"default": "./dist/react.cjs"
|
|
109
|
+
}
|
|
74
110
|
},
|
|
75
111
|
"./headless": {
|
|
76
|
-
"
|
|
77
|
-
|
|
78
|
-
|
|
112
|
+
"import": {
|
|
113
|
+
"types": "./dist/headless.d.ts",
|
|
114
|
+
"default": "./dist/headless.js"
|
|
115
|
+
},
|
|
116
|
+
"require": {
|
|
117
|
+
"types": "./dist/headless.d.cts",
|
|
118
|
+
"default": "./dist/headless.cjs"
|
|
119
|
+
}
|
|
79
120
|
},
|
|
80
121
|
"./cli": {
|
|
81
|
-
"
|
|
82
|
-
|
|
83
|
-
|
|
122
|
+
"import": {
|
|
123
|
+
"types": "./dist/cli.d.ts",
|
|
124
|
+
"default": "./dist/cli.js"
|
|
125
|
+
},
|
|
126
|
+
"require": {
|
|
127
|
+
"types": "./dist/cli.d.cts",
|
|
128
|
+
"default": "./dist/cli.cjs"
|
|
129
|
+
}
|
|
84
130
|
},
|
|
85
131
|
"./styles.css": "./dist/styles.css",
|
|
132
|
+
"./styles/*.css": "./dist/styles/*.css",
|
|
86
133
|
"./package.json": "./package.json"
|
|
87
134
|
},
|
|
88
135
|
"scripts": {
|
|
@@ -92,7 +139,8 @@
|
|
|
92
139
|
"lint": "eslint .",
|
|
93
140
|
"test": "vitest run",
|
|
94
141
|
"test:watch": "vitest",
|
|
95
|
-
"
|
|
142
|
+
"check:dist": "node scripts/check-dist.mjs",
|
|
143
|
+
"prepublishOnly": "npm run typecheck && npm run lint && npm run test && npm run build && npm run check:dist"
|
|
96
144
|
},
|
|
97
145
|
"pnpm": {
|
|
98
146
|
"onlyBuiltDependencies": [
|
|
@@ -102,39 +150,51 @@
|
|
|
102
150
|
},
|
|
103
151
|
"dependencies": {
|
|
104
152
|
"blurhash": "^2.0.5",
|
|
105
|
-
"commander": "^14.0.0"
|
|
106
|
-
"lqip-modern": "^2.2.1",
|
|
107
|
-
"lucide-react": "^0.577.0",
|
|
108
|
-
"sharp": "^0.34.5"
|
|
153
|
+
"commander": "^14.0.0"
|
|
109
154
|
},
|
|
110
155
|
"peerDependencies": {
|
|
156
|
+
"lqip-modern": "^2.2.1",
|
|
111
157
|
"react": ">=18.0.0",
|
|
112
|
-
"react-dom": ">=18.0.0"
|
|
158
|
+
"react-dom": ">=18.0.0",
|
|
159
|
+
"sharp": "^0.34.5"
|
|
113
160
|
},
|
|
114
161
|
"peerDependenciesMeta": {
|
|
162
|
+
"lqip-modern": {
|
|
163
|
+
"optional": true
|
|
164
|
+
},
|
|
115
165
|
"react": {
|
|
116
166
|
"optional": true
|
|
117
167
|
},
|
|
118
168
|
"react-dom": {
|
|
119
169
|
"optional": true
|
|
170
|
+
},
|
|
171
|
+
"sharp": {
|
|
172
|
+
"optional": true
|
|
120
173
|
}
|
|
121
174
|
},
|
|
122
175
|
"devDependencies": {
|
|
123
176
|
"@eslint/js": "^9.26.0",
|
|
177
|
+
"@testing-library/dom": "^10.4.2",
|
|
178
|
+
"@testing-library/jest-dom": "^7.0.1",
|
|
179
|
+
"@testing-library/react": "^16.3.3",
|
|
180
|
+
"@testing-library/user-event": "^14.6.8",
|
|
124
181
|
"@types/node": "^22.15.0",
|
|
125
182
|
"@types/react": "^19.1.0",
|
|
126
183
|
"@types/react-dom": "^19.1.0",
|
|
127
184
|
"eslint": "^9.26.0",
|
|
128
185
|
"eslint-plugin-react-hooks": "^5.2.0",
|
|
186
|
+
"jsdom": "^31.0.0",
|
|
187
|
+
"lqip-modern": "^2.2.1",
|
|
129
188
|
"prettier": "^3.5.3",
|
|
130
189
|
"react": "^19.1.0",
|
|
131
190
|
"react-dom": "^19.1.0",
|
|
191
|
+
"sharp": "^0.34.5",
|
|
132
192
|
"tsup": "^8.5.0",
|
|
133
193
|
"typescript": "^5.8.3",
|
|
134
194
|
"typescript-eslint": "^8.32.0",
|
|
135
195
|
"vitest": "^3.2.0"
|
|
136
196
|
},
|
|
137
197
|
"engines": {
|
|
138
|
-
"node": ">=
|
|
198
|
+
"node": ">=20.0.0"
|
|
139
199
|
}
|
|
140
200
|
}
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
type BlurPlaceholderType = 'default' | 'hero' | 'card' | 'thumbnail';
|
|
2
|
-
type BlurSize = 'small' | 'medium';
|
|
3
|
-
interface BlurDataOptions {
|
|
4
|
-
type?: BlurPlaceholderType;
|
|
5
|
-
size?: BlurSize;
|
|
6
|
-
width?: number;
|
|
7
|
-
height?: number;
|
|
8
|
-
punch?: number;
|
|
9
|
-
}
|
|
10
|
-
interface BlurManifestEntry {
|
|
11
|
-
hash: string;
|
|
12
|
-
variants: {
|
|
13
|
-
small: string;
|
|
14
|
-
medium?: string;
|
|
15
|
-
[key: string]: string | undefined;
|
|
16
|
-
};
|
|
17
|
-
color: string;
|
|
18
|
-
width?: number;
|
|
19
|
-
height?: number;
|
|
20
|
-
metadata?: Record<string, string>;
|
|
21
|
-
}
|
|
22
|
-
interface BlurManifestData {
|
|
23
|
-
version: string;
|
|
24
|
-
generatedAt: string;
|
|
25
|
-
totalImages: number;
|
|
26
|
-
processedImages?: number;
|
|
27
|
-
cachedImages?: number;
|
|
28
|
-
failedImages?: number;
|
|
29
|
-
hashes: Record<string, BlurManifestEntry>;
|
|
30
|
-
}
|
|
31
|
-
interface BlurCacheEntry {
|
|
32
|
-
dataUrl: string;
|
|
33
|
-
timestamp: number;
|
|
34
|
-
}
|
|
35
|
-
interface BlurServiceMetrics {
|
|
36
|
-
totalRequests: number;
|
|
37
|
-
cacheHits: number;
|
|
38
|
-
cacheMisses: number;
|
|
39
|
-
errors: number;
|
|
40
|
-
}
|
|
41
|
-
interface BlurImageSource {
|
|
42
|
-
url?: string;
|
|
43
|
-
blurDataUrl?: string | null;
|
|
44
|
-
blurColor?: string | null;
|
|
45
|
-
blurHash?: string | null;
|
|
46
|
-
altText?: string | null;
|
|
47
|
-
width?: number;
|
|
48
|
-
height?: number;
|
|
49
|
-
}
|
|
50
|
-
interface BlurData {
|
|
51
|
-
blurDataUrl: string;
|
|
52
|
-
blurColor: string;
|
|
53
|
-
blurHash?: string;
|
|
54
|
-
hasBlur: boolean;
|
|
55
|
-
}
|
|
56
|
-
interface BlurServiceConfig {
|
|
57
|
-
cacheSize?: number;
|
|
58
|
-
manifest?: BlurManifestData | Record<string, BlurManifestEntry>;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
interface BlurPlaceholderStyle {
|
|
62
|
-
backgroundColor: string;
|
|
63
|
-
backgroundImage?: string;
|
|
64
|
-
backgroundSize?: string;
|
|
65
|
-
backgroundPosition?: string;
|
|
66
|
-
backgroundRepeat?: string;
|
|
67
|
-
filter?: string;
|
|
68
|
-
transform?: string;
|
|
69
|
-
}
|
|
70
|
-
declare function getBlurData(image: BlurImageSource | null | undefined): BlurData;
|
|
71
|
-
declare function getImagePropsWithBlur(image: BlurImageSource | null | undefined): {
|
|
72
|
-
placeholder?: "blur" | undefined;
|
|
73
|
-
blurDataURL?: string | undefined;
|
|
74
|
-
src: string;
|
|
75
|
-
alt: string;
|
|
76
|
-
width: number;
|
|
77
|
-
height: number;
|
|
78
|
-
} | null;
|
|
79
|
-
declare function getBackgroundPropsWithBlur(image: BlurImageSource | null | undefined): BlurPlaceholderStyle;
|
|
80
|
-
declare function getBlurPlaceholderStyle(image: BlurImageSource | null | undefined): BlurPlaceholderStyle;
|
|
81
|
-
declare function hasBlurData(image: BlurImageSource | null | undefined): boolean;
|
|
82
|
-
declare function getBulkBlurData(images: Array<BlurImageSource | null | undefined>): BlurData[];
|
|
83
|
-
declare function createSrcSetWithBlur(image: BlurImageSource | null | undefined): string;
|
|
84
|
-
declare function preloadImageWithBlur(image: BlurImageSource | null | undefined): void;
|
|
85
|
-
declare function extractImageUrls(image: BlurImageSource | null | undefined): string[];
|
|
86
|
-
/**
|
|
87
|
-
* Browser helper: Decodes a compact BlurHash string (e.g. "LEHV6nWB2yk8pyo0adR*.7kCMdnj")
|
|
88
|
-
* into a `data:image/png;base64,...` URL using an offscreen `<canvas>`.
|
|
89
|
-
*/
|
|
90
|
-
declare function decodeBlurHashToDataURL(hash: string, width?: number, height?: number, punch?: number): string | null;
|
|
91
|
-
|
|
92
|
-
declare const DEFAULT_CDN_PATTERNS: RegExp[];
|
|
93
|
-
interface NormalizePathOptions {
|
|
94
|
-
cdnPatterns?: RegExp[];
|
|
95
|
-
stripPrefixes?: string[];
|
|
96
|
-
}
|
|
97
|
-
interface PathInfo {
|
|
98
|
-
normalizedPath: string;
|
|
99
|
-
folder?: string;
|
|
100
|
-
filename?: string;
|
|
101
|
-
extension?: string;
|
|
102
|
-
isExternal: boolean;
|
|
103
|
-
originalPath: string;
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Project-agnostic image URL / path normalizer.
|
|
107
|
-
* Strips query parameters, leading `/public/`, relative `./`, and common CDN prefixes
|
|
108
|
-
* so manifest keys match consistently across local and CDN environments.
|
|
109
|
-
*/
|
|
110
|
-
declare function normalizeImagePath(imageSrc: string, options?: NormalizePathOptions): PathInfo;
|
|
111
|
-
|
|
112
|
-
interface BlurServiceOptions {
|
|
113
|
-
cacheSize?: number;
|
|
114
|
-
manifest?: BlurManifestData | Record<string, BlurManifestEntry>;
|
|
115
|
-
pathOptions?: NormalizePathOptions;
|
|
116
|
-
}
|
|
117
|
-
declare class BlurService {
|
|
118
|
-
private blurData;
|
|
119
|
-
private readonly cache;
|
|
120
|
-
private readonly pathOptions?;
|
|
121
|
-
private metadata;
|
|
122
|
-
private metrics;
|
|
123
|
-
constructor(options?: BlurServiceOptions);
|
|
124
|
-
/**
|
|
125
|
-
* Hydrate the service with a generated `blur-hashes.json` manifest or hash map.
|
|
126
|
-
*/
|
|
127
|
-
loadManifest(manifest: BlurManifestData | Record<string, BlurManifestEntry>): void;
|
|
128
|
-
/**
|
|
129
|
-
* Register or update a single image's blur data at runtime.
|
|
130
|
-
*/
|
|
131
|
-
registerEntry(imagePath: string, entry: BlurManifestEntry): void;
|
|
132
|
-
getDefaultPlaceholder(type?: BlurPlaceholderType): string;
|
|
133
|
-
private findBlurDataByPath;
|
|
134
|
-
getDominantColor(imageSrc: string): string;
|
|
135
|
-
getBlurDataURL(imageSrc: string, options?: {
|
|
136
|
-
type?: BlurPlaceholderType;
|
|
137
|
-
size?: BlurSize;
|
|
138
|
-
}): string;
|
|
139
|
-
getBulkBlurData(imageSrcs: string[], options?: {
|
|
140
|
-
type?: BlurPlaceholderType;
|
|
141
|
-
size?: BlurSize;
|
|
142
|
-
}): Record<string, string>;
|
|
143
|
-
getProgressiveData(imageSrc: string, size?: BlurSize): {
|
|
144
|
-
color: string;
|
|
145
|
-
blur: string;
|
|
146
|
-
hasBlur: boolean;
|
|
147
|
-
};
|
|
148
|
-
hasBlurHash(imageSrc: string): boolean;
|
|
149
|
-
getMetadata(): {
|
|
150
|
-
cacheSize: number;
|
|
151
|
-
metrics: {
|
|
152
|
-
cacheHitRate: string;
|
|
153
|
-
totalRequests: number;
|
|
154
|
-
cacheHits: number;
|
|
155
|
-
cacheMisses: number;
|
|
156
|
-
errors: number;
|
|
157
|
-
};
|
|
158
|
-
version: string;
|
|
159
|
-
generatedAt: string;
|
|
160
|
-
totalImages: number;
|
|
161
|
-
};
|
|
162
|
-
clearCache(): void;
|
|
163
|
-
getBlurHash(imageSrc: string): string | null;
|
|
164
|
-
preloadBlurData(imageSrcs: string[], size?: BlurSize): void;
|
|
165
|
-
fetchBlurDataForImage(imageSrc: string, type?: BlurPlaceholderType): Promise<string>;
|
|
166
|
-
getAvailableKeys(): string[];
|
|
167
|
-
findMatchingKeys(searchTerm: string): string[];
|
|
168
|
-
}
|
|
169
|
-
declare function createBlurService(options?: BlurServiceOptions): BlurService;
|
|
170
|
-
declare const blurService: BlurService;
|
|
171
|
-
|
|
172
|
-
export { type BlurPlaceholderType as B, DEFAULT_CDN_PATTERNS as D, type NormalizePathOptions as N, type PathInfo as P, type BlurCacheEntry as a, type BlurData as b, type BlurDataOptions as c, type BlurImageSource as d, type BlurManifestData as e, type BlurManifestEntry as f, type BlurPlaceholderStyle as g, BlurService as h, type BlurServiceConfig as i, type BlurServiceMetrics as j, type BlurServiceOptions as k, type BlurSize as l, blurService as m, createBlurService as n, createSrcSetWithBlur as o, decodeBlurHashToDataURL as p, extractImageUrls as q, getBackgroundPropsWithBlur as r, getBlurData as s, getBlurPlaceholderStyle as t, getBulkBlurData as u, getImagePropsWithBlur as v, hasBlurData as w, normalizeImagePath as x, preloadImageWithBlur as y };
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
type BlurPlaceholderType = 'default' | 'hero' | 'card' | 'thumbnail';
|
|
2
|
-
type BlurSize = 'small' | 'medium';
|
|
3
|
-
interface BlurDataOptions {
|
|
4
|
-
type?: BlurPlaceholderType;
|
|
5
|
-
size?: BlurSize;
|
|
6
|
-
width?: number;
|
|
7
|
-
height?: number;
|
|
8
|
-
punch?: number;
|
|
9
|
-
}
|
|
10
|
-
interface BlurManifestEntry {
|
|
11
|
-
hash: string;
|
|
12
|
-
variants: {
|
|
13
|
-
small: string;
|
|
14
|
-
medium?: string;
|
|
15
|
-
[key: string]: string | undefined;
|
|
16
|
-
};
|
|
17
|
-
color: string;
|
|
18
|
-
width?: number;
|
|
19
|
-
height?: number;
|
|
20
|
-
metadata?: Record<string, string>;
|
|
21
|
-
}
|
|
22
|
-
interface BlurManifestData {
|
|
23
|
-
version: string;
|
|
24
|
-
generatedAt: string;
|
|
25
|
-
totalImages: number;
|
|
26
|
-
processedImages?: number;
|
|
27
|
-
cachedImages?: number;
|
|
28
|
-
failedImages?: number;
|
|
29
|
-
hashes: Record<string, BlurManifestEntry>;
|
|
30
|
-
}
|
|
31
|
-
interface BlurCacheEntry {
|
|
32
|
-
dataUrl: string;
|
|
33
|
-
timestamp: number;
|
|
34
|
-
}
|
|
35
|
-
interface BlurServiceMetrics {
|
|
36
|
-
totalRequests: number;
|
|
37
|
-
cacheHits: number;
|
|
38
|
-
cacheMisses: number;
|
|
39
|
-
errors: number;
|
|
40
|
-
}
|
|
41
|
-
interface BlurImageSource {
|
|
42
|
-
url?: string;
|
|
43
|
-
blurDataUrl?: string | null;
|
|
44
|
-
blurColor?: string | null;
|
|
45
|
-
blurHash?: string | null;
|
|
46
|
-
altText?: string | null;
|
|
47
|
-
width?: number;
|
|
48
|
-
height?: number;
|
|
49
|
-
}
|
|
50
|
-
interface BlurData {
|
|
51
|
-
blurDataUrl: string;
|
|
52
|
-
blurColor: string;
|
|
53
|
-
blurHash?: string;
|
|
54
|
-
hasBlur: boolean;
|
|
55
|
-
}
|
|
56
|
-
interface BlurServiceConfig {
|
|
57
|
-
cacheSize?: number;
|
|
58
|
-
manifest?: BlurManifestData | Record<string, BlurManifestEntry>;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
interface BlurPlaceholderStyle {
|
|
62
|
-
backgroundColor: string;
|
|
63
|
-
backgroundImage?: string;
|
|
64
|
-
backgroundSize?: string;
|
|
65
|
-
backgroundPosition?: string;
|
|
66
|
-
backgroundRepeat?: string;
|
|
67
|
-
filter?: string;
|
|
68
|
-
transform?: string;
|
|
69
|
-
}
|
|
70
|
-
declare function getBlurData(image: BlurImageSource | null | undefined): BlurData;
|
|
71
|
-
declare function getImagePropsWithBlur(image: BlurImageSource | null | undefined): {
|
|
72
|
-
placeholder?: "blur" | undefined;
|
|
73
|
-
blurDataURL?: string | undefined;
|
|
74
|
-
src: string;
|
|
75
|
-
alt: string;
|
|
76
|
-
width: number;
|
|
77
|
-
height: number;
|
|
78
|
-
} | null;
|
|
79
|
-
declare function getBackgroundPropsWithBlur(image: BlurImageSource | null | undefined): BlurPlaceholderStyle;
|
|
80
|
-
declare function getBlurPlaceholderStyle(image: BlurImageSource | null | undefined): BlurPlaceholderStyle;
|
|
81
|
-
declare function hasBlurData(image: BlurImageSource | null | undefined): boolean;
|
|
82
|
-
declare function getBulkBlurData(images: Array<BlurImageSource | null | undefined>): BlurData[];
|
|
83
|
-
declare function createSrcSetWithBlur(image: BlurImageSource | null | undefined): string;
|
|
84
|
-
declare function preloadImageWithBlur(image: BlurImageSource | null | undefined): void;
|
|
85
|
-
declare function extractImageUrls(image: BlurImageSource | null | undefined): string[];
|
|
86
|
-
/**
|
|
87
|
-
* Browser helper: Decodes a compact BlurHash string (e.g. "LEHV6nWB2yk8pyo0adR*.7kCMdnj")
|
|
88
|
-
* into a `data:image/png;base64,...` URL using an offscreen `<canvas>`.
|
|
89
|
-
*/
|
|
90
|
-
declare function decodeBlurHashToDataURL(hash: string, width?: number, height?: number, punch?: number): string | null;
|
|
91
|
-
|
|
92
|
-
declare const DEFAULT_CDN_PATTERNS: RegExp[];
|
|
93
|
-
interface NormalizePathOptions {
|
|
94
|
-
cdnPatterns?: RegExp[];
|
|
95
|
-
stripPrefixes?: string[];
|
|
96
|
-
}
|
|
97
|
-
interface PathInfo {
|
|
98
|
-
normalizedPath: string;
|
|
99
|
-
folder?: string;
|
|
100
|
-
filename?: string;
|
|
101
|
-
extension?: string;
|
|
102
|
-
isExternal: boolean;
|
|
103
|
-
originalPath: string;
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Project-agnostic image URL / path normalizer.
|
|
107
|
-
* Strips query parameters, leading `/public/`, relative `./`, and common CDN prefixes
|
|
108
|
-
* so manifest keys match consistently across local and CDN environments.
|
|
109
|
-
*/
|
|
110
|
-
declare function normalizeImagePath(imageSrc: string, options?: NormalizePathOptions): PathInfo;
|
|
111
|
-
|
|
112
|
-
interface BlurServiceOptions {
|
|
113
|
-
cacheSize?: number;
|
|
114
|
-
manifest?: BlurManifestData | Record<string, BlurManifestEntry>;
|
|
115
|
-
pathOptions?: NormalizePathOptions;
|
|
116
|
-
}
|
|
117
|
-
declare class BlurService {
|
|
118
|
-
private blurData;
|
|
119
|
-
private readonly cache;
|
|
120
|
-
private readonly pathOptions?;
|
|
121
|
-
private metadata;
|
|
122
|
-
private metrics;
|
|
123
|
-
constructor(options?: BlurServiceOptions);
|
|
124
|
-
/**
|
|
125
|
-
* Hydrate the service with a generated `blur-hashes.json` manifest or hash map.
|
|
126
|
-
*/
|
|
127
|
-
loadManifest(manifest: BlurManifestData | Record<string, BlurManifestEntry>): void;
|
|
128
|
-
/**
|
|
129
|
-
* Register or update a single image's blur data at runtime.
|
|
130
|
-
*/
|
|
131
|
-
registerEntry(imagePath: string, entry: BlurManifestEntry): void;
|
|
132
|
-
getDefaultPlaceholder(type?: BlurPlaceholderType): string;
|
|
133
|
-
private findBlurDataByPath;
|
|
134
|
-
getDominantColor(imageSrc: string): string;
|
|
135
|
-
getBlurDataURL(imageSrc: string, options?: {
|
|
136
|
-
type?: BlurPlaceholderType;
|
|
137
|
-
size?: BlurSize;
|
|
138
|
-
}): string;
|
|
139
|
-
getBulkBlurData(imageSrcs: string[], options?: {
|
|
140
|
-
type?: BlurPlaceholderType;
|
|
141
|
-
size?: BlurSize;
|
|
142
|
-
}): Record<string, string>;
|
|
143
|
-
getProgressiveData(imageSrc: string, size?: BlurSize): {
|
|
144
|
-
color: string;
|
|
145
|
-
blur: string;
|
|
146
|
-
hasBlur: boolean;
|
|
147
|
-
};
|
|
148
|
-
hasBlurHash(imageSrc: string): boolean;
|
|
149
|
-
getMetadata(): {
|
|
150
|
-
cacheSize: number;
|
|
151
|
-
metrics: {
|
|
152
|
-
cacheHitRate: string;
|
|
153
|
-
totalRequests: number;
|
|
154
|
-
cacheHits: number;
|
|
155
|
-
cacheMisses: number;
|
|
156
|
-
errors: number;
|
|
157
|
-
};
|
|
158
|
-
version: string;
|
|
159
|
-
generatedAt: string;
|
|
160
|
-
totalImages: number;
|
|
161
|
-
};
|
|
162
|
-
clearCache(): void;
|
|
163
|
-
getBlurHash(imageSrc: string): string | null;
|
|
164
|
-
preloadBlurData(imageSrcs: string[], size?: BlurSize): void;
|
|
165
|
-
fetchBlurDataForImage(imageSrc: string, type?: BlurPlaceholderType): Promise<string>;
|
|
166
|
-
getAvailableKeys(): string[];
|
|
167
|
-
findMatchingKeys(searchTerm: string): string[];
|
|
168
|
-
}
|
|
169
|
-
declare function createBlurService(options?: BlurServiceOptions): BlurService;
|
|
170
|
-
declare const blurService: BlurService;
|
|
171
|
-
|
|
172
|
-
export { type BlurPlaceholderType as B, DEFAULT_CDN_PATTERNS as D, type NormalizePathOptions as N, type PathInfo as P, type BlurCacheEntry as a, type BlurData as b, type BlurDataOptions as c, type BlurImageSource as d, type BlurManifestData as e, type BlurManifestEntry as f, type BlurPlaceholderStyle as g, BlurService as h, type BlurServiceConfig as i, type BlurServiceMetrics as j, type BlurServiceOptions as k, type BlurSize as l, blurService as m, createBlurService as n, createSrcSetWithBlur as o, decodeBlurHashToDataURL as p, extractImageUrls as q, getBackgroundPropsWithBlur as r, getBlurData as s, getBlurPlaceholderStyle as t, getBulkBlurData as u, getImagePropsWithBlur as v, hasBlurData as w, normalizeImagePath as x, preloadImageWithBlur as y };
|