img-upload-kit 1.1.1 → 2.0.1

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 (111) hide show
  1. package/CHANGELOG.md +89 -74
  2. package/MIGRATION.md +192 -0
  3. package/README.md +243 -259
  4. package/dist/bin.js +1186 -0
  5. package/dist/bin.js.map +1 -0
  6. package/dist/blur.cjs +40 -412
  7. package/dist/blur.cjs.map +1 -1
  8. package/dist/blur.d.cts +5 -5
  9. package/dist/blur.d.ts +5 -5
  10. package/dist/blur.js +39 -393
  11. package/dist/blur.js.map +1 -1
  12. package/dist/blurDataUtils-DveBRtqE.d.cts +43 -0
  13. package/dist/blurDataUtils-yx9Q6HlU.d.ts +43 -0
  14. package/dist/blurService-D5TpMNji.d.ts +83 -0
  15. package/dist/blurService-DacwylJx.d.cts +83 -0
  16. package/dist/chunk-25GYKQ6J.js +158 -0
  17. package/dist/chunk-25GYKQ6J.js.map +1 -0
  18. package/dist/chunk-34L4TEE3.cjs +226 -0
  19. package/dist/chunk-34L4TEE3.cjs.map +1 -0
  20. package/dist/chunk-DFCSN3X7.cjs +158 -0
  21. package/dist/chunk-DFCSN3X7.cjs.map +1 -0
  22. package/dist/chunk-EWVIL57J.js +294 -0
  23. package/dist/chunk-EWVIL57J.js.map +1 -0
  24. package/dist/chunk-FP5YIWG5.cjs +135 -0
  25. package/dist/chunk-FP5YIWG5.cjs.map +1 -0
  26. package/dist/chunk-HILELQGS.js +226 -0
  27. package/dist/chunk-HILELQGS.js.map +1 -0
  28. package/dist/chunk-IDLLCVGB.js +2370 -0
  29. package/dist/chunk-IDLLCVGB.js.map +1 -0
  30. package/dist/chunk-J6A44Y3W.js +514 -0
  31. package/dist/chunk-J6A44Y3W.js.map +1 -0
  32. package/dist/chunk-LOSVFO56.cjs +145 -0
  33. package/dist/chunk-LOSVFO56.cjs.map +1 -0
  34. package/dist/chunk-MBQJ6NVJ.cjs +294 -0
  35. package/dist/chunk-MBQJ6NVJ.cjs.map +1 -0
  36. package/dist/chunk-MHGQEBPW.js +145 -0
  37. package/dist/chunk-MHGQEBPW.js.map +1 -0
  38. package/dist/chunk-QHU7FUO4.cjs +37 -0
  39. package/dist/chunk-QHU7FUO4.cjs.map +1 -0
  40. package/dist/chunk-S2IFAWJK.js +37 -0
  41. package/dist/chunk-S2IFAWJK.js.map +1 -0
  42. package/dist/chunk-TA5Y64JM.cjs +2370 -0
  43. package/dist/chunk-TA5Y64JM.cjs.map +1 -0
  44. package/dist/chunk-VYVZVUNI.js +135 -0
  45. package/dist/chunk-VYVZVUNI.js.map +1 -0
  46. package/dist/chunk-XKQMCY5Z.cjs +514 -0
  47. package/dist/chunk-XKQMCY5Z.cjs.map +1 -0
  48. package/dist/cli.cjs +273 -76
  49. package/dist/cli.cjs.map +1 -1
  50. package/dist/cli.js +269 -73
  51. package/dist/cli.js.map +1 -1
  52. package/dist/headless.cjs +8 -1880
  53. package/dist/headless.cjs.map +1 -1
  54. package/dist/headless.d.cts +3 -1
  55. package/dist/headless.d.ts +3 -1
  56. package/dist/headless.js +25 -1886
  57. package/dist/headless.js.map +1 -1
  58. package/dist/index-BIdnqtW8.d.ts +234 -0
  59. package/dist/index-Brk_uHs6.d.cts +234 -0
  60. package/dist/{index-FVXXKf2v.d.ts → index-CPMlaQsC.d.ts} +76 -153
  61. package/dist/{index-FVXXKf2v.d.cts → index-DHINe-rA.d.cts} +76 -153
  62. package/dist/index.cjs +64 -532
  63. package/dist/index.cjs.map +1 -1
  64. package/dist/index.d.cts +7 -4
  65. package/dist/index.d.ts +7 -4
  66. package/dist/index.js +63 -504
  67. package/dist/index.js.map +1 -1
  68. package/dist/{memoryAdapter-CBu7_3Pp.d.ts → memoryAdapter-Ck0ccZbF.d.cts} +3 -2
  69. package/dist/{memoryAdapter-BJjyLR-1.d.cts → memoryAdapter-DxEKaG0b.d.ts} +3 -2
  70. package/dist/placeholders-C4ftwaII.d.ts +5 -0
  71. package/dist/placeholders-x_3rt65M.d.cts +5 -0
  72. package/dist/react.cjs +1952 -3257
  73. package/dist/react.cjs.map +1 -1
  74. package/dist/react.d.cts +188 -50
  75. package/dist/react.d.ts +188 -50
  76. package/dist/react.js +1763 -3013
  77. package/dist/react.js.map +1 -1
  78. package/dist/server-handler.cjs +14 -0
  79. package/dist/server-handler.cjs.map +1 -0
  80. package/dist/server-handler.d.cts +3 -0
  81. package/dist/server-handler.d.ts +3 -0
  82. package/dist/server-handler.js +14 -0
  83. package/dist/server-handler.js.map +1 -0
  84. package/dist/server.cjs +1096 -532
  85. package/dist/server.cjs.map +1 -1
  86. package/dist/server.d.cts +77 -154
  87. package/dist/server.d.ts +77 -154
  88. package/dist/server.js +1050 -448
  89. package/dist/server.js.map +1 -1
  90. package/dist/storage.cjs +239 -232
  91. package/dist/storage.cjs.map +1 -1
  92. package/dist/storage.d.cts +21 -5
  93. package/dist/storage.d.ts +21 -5
  94. package/dist/storage.js +227 -207
  95. package/dist/storage.js.map +1 -1
  96. package/dist/styles/animated-image.css +112 -0
  97. package/dist/styles/dropzone-and-tiles.css +247 -0
  98. package/dist/styles/modals-and-dock.css +248 -0
  99. package/dist/styles/primitives.css +197 -0
  100. package/dist/styles/quality-and-inputs.css +184 -0
  101. package/dist/styles/tokens.css +123 -0
  102. package/dist/styles.css +235 -220
  103. package/dist/types-BrP-o9nd.d.cts +85 -0
  104. package/dist/types-sZ3KoFQY.d.ts +85 -0
  105. package/dist/types-yShGNQnW.d.cts +61 -0
  106. package/dist/types-yShGNQnW.d.ts +61 -0
  107. package/dist/{types-CiLY0DwB.d.cts → upload-C5Trd6Dh.d.cts} +27 -53
  108. package/dist/{types-CiLY0DwB.d.ts → upload-C5Trd6Dh.d.ts} +27 -53
  109. package/package.json +92 -32
  110. package/dist/blurService-DqsnfPTd.d.cts +0 -172
  111. package/dist/blurService-DqsnfPTd.d.ts +0 -172
@@ -0,0 +1,85 @@
1
+ import { I as ImageUploadRecord } from './upload-C5Trd6Dh.js';
2
+
3
+ interface StorageUploadParams {
4
+ bucket: string;
5
+ path: string;
6
+ data: Buffer | Uint8Array;
7
+ contentType: string;
8
+ upsert?: boolean;
9
+ cacheControl?: string;
10
+ contentHash?: string;
11
+ metadata?: Record<string, string>;
12
+ }
13
+ interface StorageUploadResult {
14
+ bucket: string;
15
+ path: string;
16
+ url: string;
17
+ }
18
+ interface StorageFileEntry {
19
+ name: string;
20
+ id?: string;
21
+ createdAt?: string;
22
+ size?: number;
23
+ }
24
+ interface StorageListOptions {
25
+ cursor?: string;
26
+ limit?: number;
27
+ }
28
+ type StoragePaginatedListResult = StorageFileEntry[] & {
29
+ items: StorageFileEntry[];
30
+ nextCursor?: string;
31
+ };
32
+ type StorageUploadOptions = StorageUploadParams;
33
+ type StorageFileMetadata = StorageFileEntry;
34
+ type StorageListResult = StoragePaginatedListResult;
35
+ interface StorageAdapter {
36
+ /**
37
+ * Upload optimized image bytes to your storage backend and return its public URL.
38
+ */
39
+ upload(params: StorageUploadParams): Promise<StorageUploadResult>;
40
+ /**
41
+ * Delete an image from your storage backend by bucket and relative path.
42
+ */
43
+ delete(bucket: string, path: string): Promise<void>;
44
+ /**
45
+ * Optional: Check whether an object exists at the given bucket and relative path.
46
+ */
47
+ exists?(bucket: string, path: string): Promise<boolean>;
48
+ /**
49
+ * Optional: Resolve a public URL for a bucket and path.
50
+ */
51
+ getPublicUrl?(bucket: string, path: string): string | Promise<string>;
52
+ /**
53
+ * Optional: List files inside a bucket/folder (supports optional cursor/limit pagination).
54
+ */
55
+ list?(bucket: string, folder?: string, options?: StorageListOptions): Promise<StoragePaginatedListResult>;
56
+ /**
57
+ * Optional: Delete an asset directly from its public URL.
58
+ */
59
+ deleteByUrl?(url: string): Promise<boolean>;
60
+ /**
61
+ * Optional: Parse a public storage URL into its bucket and relative path.
62
+ */
63
+ parseUrl?(url: string): {
64
+ bucket?: string;
65
+ path: string;
66
+ } | null;
67
+ }
68
+ type UploadRecordHook = (record: ImageUploadRecord) => void | Promise<void>;
69
+ /**
70
+ * Attaches non-enumerable `.items` and `.nextCursor` properties to a `StorageFileEntry[]`
71
+ * array so both array callers (`entries.map(...)`) and paginated destructuring callers
72
+ * (`const { items, nextCursor } = await adapter.list(...)`) work seamlessly.
73
+ */
74
+ declare function toPaginatedListResult(entries: StorageFileEntry[], nextCursor?: string): StoragePaginatedListResult;
75
+ /**
76
+ * Validates that storage metadata keys and values contain only printable ASCII
77
+ * characters (preventing HTTP header/CRLF injection) and do not exceed 2 KB total.
78
+ */
79
+ declare function validateStorageMetadata(metadata?: Record<string, string>): void;
80
+ /**
81
+ * Type-safe helper for authoring a custom StorageAdapter (S3, R2, Vercel Blob, Firebase, etc.).
82
+ */
83
+ declare function createStorageAdapter(adapter: StorageAdapter): StorageAdapter;
84
+
85
+ export { type StorageAdapter as S, type UploadRecordHook as U, type StorageListOptions as a, type StoragePaginatedListResult as b, type StorageFileEntry as c, type StorageFileMetadata as d, type StorageListResult as e, type StorageUploadOptions as f, type StorageUploadParams as g, type StorageUploadResult as h, createStorageAdapter as i, toPaginatedListResult as t, validateStorageMetadata as v };
@@ -0,0 +1,61 @@
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
+ export type { BlurCacheEntry as B, BlurData as a, BlurDataOptions as b, BlurImageSource as c, BlurManifestData as d, BlurManifestEntry as e, BlurPlaceholderType as f, BlurServiceConfig as g, BlurServiceMetrics as h, BlurSize as i };
@@ -0,0 +1,61 @@
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
+ export type { BlurCacheEntry as B, BlurData as a, BlurDataOptions as b, BlurImageSource as c, BlurManifestData as d, BlurManifestEntry as e, BlurPlaceholderType as f, BlurServiceConfig as g, BlurServiceMetrics as h, BlurSize as i };
@@ -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
- interface StorageUploadParams {
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 };
@@ -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
- interface StorageUploadParams {
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": "1.1.1",
3
+ "version": "2.0.1",
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/cli.js",
46
- "image-upload-kit": "dist/cli.js",
47
- "blur-cli": "dist/cli.js"
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
- "types": "./dist/index.d.ts",
52
- "import": "./dist/index.js",
53
- "require": "./dist/index.cjs"
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
- "types": "./dist/server.d.ts",
57
- "import": "./dist/server.js",
58
- "require": "./dist/server.cjs"
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
- "types": "./dist/storage.d.ts",
62
- "import": "./dist/storage.js",
63
- "require": "./dist/storage.cjs"
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
- "types": "./dist/blur.d.ts",
67
- "import": "./dist/blur.js",
68
- "require": "./dist/blur.cjs"
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
- "types": "./dist/react.d.ts",
72
- "import": "./dist/react.js",
73
- "require": "./dist/react.cjs"
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
- "types": "./dist/headless.d.ts",
77
- "import": "./dist/headless.js",
78
- "require": "./dist/headless.cjs"
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
- "types": "./dist/cli.d.ts",
82
- "import": "./dist/cli.js",
83
- "require": "./dist/cli.cjs"
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
- "prepublishOnly": "npm run typecheck && npm run test && npm run build"
142
+ "check:dist": "node scripts/check-dist.mjs",
143
+ "prepublishOnly": "npm run typecheck && npm run lint && npm run build && npm run test && 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": "26.1.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": ">=18.17.0"
198
+ "node": ">=20.0.0"
139
199
  }
140
200
  }