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
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/* image-upload-kit — Layer 1: Design Tokens & Base Reset */
|
|
2
|
+
|
|
3
|
+
:root,
|
|
4
|
+
.iuk-root {
|
|
5
|
+
--iuk-bg: #ffffff;
|
|
6
|
+
--iuk-surface: #f8fafc;
|
|
7
|
+
--iuk-surface-hover: #f1f5f9;
|
|
8
|
+
--iuk-border: #e2e8f0;
|
|
9
|
+
--iuk-border-strong: #cbd5e1;
|
|
10
|
+
--iuk-text: #0f172a;
|
|
11
|
+
--iuk-text-muted: #64748b;
|
|
12
|
+
--iuk-primary: #2563eb;
|
|
13
|
+
--iuk-primary-hover: #1d4ed8;
|
|
14
|
+
--iuk-primary-soft: rgba(37, 99, 235, 0.1);
|
|
15
|
+
--iuk-danger: #dc2626;
|
|
16
|
+
--iuk-danger-soft: rgba(220, 38, 38, 0.1);
|
|
17
|
+
--iuk-success: #16a34a;
|
|
18
|
+
--iuk-success-soft: rgba(22, 163, 74, 0.1);
|
|
19
|
+
--iuk-warning: #d97706;
|
|
20
|
+
--iuk-warning-soft: rgba(217, 119, 6, 0.12);
|
|
21
|
+
--iuk-info: #0284c7;
|
|
22
|
+
--iuk-info-soft: rgba(2, 132, 199, 0.1);
|
|
23
|
+
--iuk-placeholder-bg: #f1f5f9;
|
|
24
|
+
--iuk-radius-sm: 6px;
|
|
25
|
+
--iuk-radius-md: 10px;
|
|
26
|
+
--iuk-radius-lg: 14px;
|
|
27
|
+
--iuk-shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
|
|
28
|
+
--iuk-shadow-lg: 0 20px 40px -12px rgba(15, 23, 42, 0.22), 0 8px 16px -8px rgba(15, 23, 42, 0.12);
|
|
29
|
+
--iuk-font: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@media (prefers-color-scheme: dark) {
|
|
33
|
+
:root:not([data-theme="light"]):not(.light),
|
|
34
|
+
:root:not([data-theme="light"]):not(.light) .iuk-root {
|
|
35
|
+
--iuk-bg: #0f172a;
|
|
36
|
+
--iuk-surface: #1e293b;
|
|
37
|
+
--iuk-surface-hover: #283548;
|
|
38
|
+
--iuk-border: #334155;
|
|
39
|
+
--iuk-border-strong: #475569;
|
|
40
|
+
--iuk-text: #f8fafc;
|
|
41
|
+
--iuk-text-muted: #94a3b8;
|
|
42
|
+
--iuk-primary: #3b82f6;
|
|
43
|
+
--iuk-primary-hover: #60a5fa;
|
|
44
|
+
--iuk-primary-soft: rgba(59, 130, 246, 0.18);
|
|
45
|
+
--iuk-danger: #ef4444;
|
|
46
|
+
--iuk-danger-soft: rgba(239, 68, 68, 0.18);
|
|
47
|
+
--iuk-success: #22c55e;
|
|
48
|
+
--iuk-success-soft: rgba(34, 197, 94, 0.18);
|
|
49
|
+
--iuk-warning: #f59e0b;
|
|
50
|
+
--iuk-warning-soft: rgba(245, 158, 11, 0.18);
|
|
51
|
+
--iuk-info: #38bdf8;
|
|
52
|
+
--iuk-info-soft: rgba(56, 189, 248, 0.18);
|
|
53
|
+
--iuk-placeholder-bg: #1e293b;
|
|
54
|
+
--iuk-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
|
|
55
|
+
--iuk-shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, 0.6);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
[data-theme="dark"],
|
|
60
|
+
[data-theme="dark"] .iuk-root,
|
|
61
|
+
.dark,
|
|
62
|
+
.dark .iuk-root {
|
|
63
|
+
--iuk-bg: #0f172a;
|
|
64
|
+
--iuk-surface: #1e293b;
|
|
65
|
+
--iuk-surface-hover: #283548;
|
|
66
|
+
--iuk-border: #334155;
|
|
67
|
+
--iuk-border-strong: #475569;
|
|
68
|
+
--iuk-text: #f8fafc;
|
|
69
|
+
--iuk-text-muted: #94a3b8;
|
|
70
|
+
--iuk-primary: #3b82f6;
|
|
71
|
+
--iuk-primary-hover: #60a5fa;
|
|
72
|
+
--iuk-primary-soft: rgba(59, 130, 246, 0.18);
|
|
73
|
+
--iuk-danger: #ef4444;
|
|
74
|
+
--iuk-danger-soft: rgba(239, 68, 68, 0.18);
|
|
75
|
+
--iuk-success: #22c55e;
|
|
76
|
+
--iuk-success-soft: rgba(34, 197, 94, 0.18);
|
|
77
|
+
--iuk-warning: #f59e0b;
|
|
78
|
+
--iuk-warning-soft: rgba(245, 158, 11, 0.18);
|
|
79
|
+
--iuk-info: #38bdf8;
|
|
80
|
+
--iuk-info-soft: rgba(56, 189, 248, 0.18);
|
|
81
|
+
--iuk-placeholder-bg: #1e293b;
|
|
82
|
+
--iuk-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
|
|
83
|
+
--iuk-shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, 0.6);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.iuk-root, .iuk-single, .iuk-multi, .iuk-modal-backdrop, .iuk-progress-dock, .iuk-minimized-dock {
|
|
87
|
+
box-sizing: border-box;
|
|
88
|
+
font-family: var(--iuk-font);
|
|
89
|
+
color: var(--iuk-text);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.iuk-root *, .iuk-root *::before, .iuk-root *::after, .iuk-modal-backdrop *, .iuk-progress-dock * {
|
|
93
|
+
box-sizing: border-box;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.iuk-hidden-input { display: none !important; }
|
|
97
|
+
|
|
98
|
+
@keyframes iuk-spin { to { transform: rotate(360deg); } }
|
|
99
|
+
|
|
100
|
+
.iuk-spin { animation: iuk-spin 0.85s linear infinite; flex-shrink: 0; }
|
|
101
|
+
|
|
102
|
+
.iuk-spinner {
|
|
103
|
+
width: 30px;
|
|
104
|
+
height: 30px;
|
|
105
|
+
border-radius: 9999px;
|
|
106
|
+
border: 2.5px solid var(--iuk-border);
|
|
107
|
+
border-top-color: var(--iuk-primary);
|
|
108
|
+
animation: iuk-spin 0.8s linear infinite;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
@media (prefers-reduced-motion: reduce) {
|
|
112
|
+
.iuk-spin,
|
|
113
|
+
.iuk-spinner,
|
|
114
|
+
.iuk-root *,
|
|
115
|
+
.iuk-single *,
|
|
116
|
+
.iuk-multi *,
|
|
117
|
+
.iuk-modal-backdrop *,
|
|
118
|
+
.iuk-progress-dock * {
|
|
119
|
+
animation-duration: 0.01ms !important;
|
|
120
|
+
animation-iteration-count: 1 !important;
|
|
121
|
+
transition-duration: 0.01ms !important;
|
|
122
|
+
}
|
|
123
|
+
}
|
package/dist/styles.css
CHANGED
|
@@ -109,6 +109,20 @@
|
|
|
109
109
|
animation: iuk-spin 0.8s linear infinite;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
+
@media (prefers-reduced-motion: reduce) {
|
|
113
|
+
.iuk-spin,
|
|
114
|
+
.iuk-spinner,
|
|
115
|
+
.iuk-root *,
|
|
116
|
+
.iuk-single *,
|
|
117
|
+
.iuk-multi *,
|
|
118
|
+
.iuk-modal-backdrop *,
|
|
119
|
+
.iuk-progress-dock * {
|
|
120
|
+
animation-duration: 0.01ms !important;
|
|
121
|
+
animation-iteration-count: 1 !important;
|
|
122
|
+
transition-duration: 0.01ms !important;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
112
126
|
|
|
113
127
|
/* image-upload-kit — Layer 2: UI Primitives */
|
|
114
128
|
|
|
@@ -994,7 +1008,7 @@
|
|
|
994
1008
|
}
|
|
995
1009
|
|
|
996
1010
|
|
|
997
|
-
/* ── AnimatedImage: blur-up crossfade image
|
|
1011
|
+
/* ── AnimatedImage: blur-up crossfade image (Imagine-Global parity) ─────── */
|
|
998
1012
|
.iuk-animated-image {
|
|
999
1013
|
position: relative;
|
|
1000
1014
|
width: 100%;
|
|
@@ -1004,6 +1018,7 @@
|
|
|
1004
1018
|
border-radius: inherit;
|
|
1005
1019
|
clip-path: inset(0 round inherit);
|
|
1006
1020
|
contain: paint;
|
|
1021
|
+
transition: background-color var(--iuk-animated-image-color-transition, 300ms ease);
|
|
1007
1022
|
}
|
|
1008
1023
|
|
|
1009
1024
|
.iuk-animated-image--fill {
|
|
@@ -1013,19 +1028,18 @@
|
|
|
1013
1028
|
|
|
1014
1029
|
.iuk-animated-image__placeholder {
|
|
1015
1030
|
position: absolute;
|
|
1016
|
-
inset:
|
|
1017
|
-
width:
|
|
1018
|
-
height:
|
|
1031
|
+
inset: 0;
|
|
1032
|
+
width: 100%;
|
|
1033
|
+
height: 100%;
|
|
1019
1034
|
object-position: center;
|
|
1020
|
-
/* Tiny placeholder stretched to full size
|
|
1021
|
-
|
|
1035
|
+
/* Tiny placeholder stretched to full size is blurred and scaled slightly so
|
|
1036
|
+
blurred edges stay clipped inside the overflow: hidden wrapper. */
|
|
1022
1037
|
filter: blur(var(--iuk-animated-image-blur, 20px));
|
|
1023
|
-
transform: scale(1.
|
|
1038
|
+
transform: scale(var(--iuk-animated-image-placeholder-scale, 1.1));
|
|
1024
1039
|
transform-origin: center;
|
|
1025
1040
|
z-index: 1;
|
|
1026
1041
|
opacity: 1;
|
|
1027
|
-
transition
|
|
1028
|
-
transition-timing-function: cubic-bezier(0.25, 0.1, 0.25, 1);
|
|
1042
|
+
transition: opacity var(--iuk-ai-ph-dur, 500ms) ease-in-out;
|
|
1029
1043
|
pointer-events: none;
|
|
1030
1044
|
}
|
|
1031
1045
|
|
|
@@ -1040,33 +1054,34 @@
|
|
|
1040
1054
|
width: 100%;
|
|
1041
1055
|
height: auto;
|
|
1042
1056
|
opacity: 0;
|
|
1057
|
+
transform: scale(var(--iuk-animated-image-reveal-scale, 1.02));
|
|
1043
1058
|
border-radius: inherit;
|
|
1044
1059
|
user-select: none;
|
|
1045
1060
|
-webkit-user-select: none;
|
|
1046
1061
|
-webkit-user-drag: none;
|
|
1047
|
-
transition
|
|
1048
|
-
|
|
1062
|
+
transition:
|
|
1063
|
+
opacity var(--iuk-animated-image-duration, 600ms) ease-in-out,
|
|
1064
|
+
transform var(--iuk-animated-image-duration, 600ms) ease-in-out;
|
|
1049
1065
|
}
|
|
1050
1066
|
|
|
1051
|
-
.iuk-animated-image__img[data-state='loaded']
|
|
1052
|
-
.iuk-animated-image__img[data-state='error'] {
|
|
1067
|
+
.iuk-animated-image__img[data-state='loaded'] {
|
|
1053
1068
|
opacity: 1;
|
|
1069
|
+
transform: scale(1);
|
|
1054
1070
|
}
|
|
1055
1071
|
|
|
1056
|
-
.iuk-animated-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
height: 100%;
|
|
1072
|
+
.iuk-animated-image__img[data-state='error'] {
|
|
1073
|
+
opacity: 0;
|
|
1074
|
+
visibility: hidden;
|
|
1060
1075
|
}
|
|
1061
1076
|
|
|
1062
|
-
|
|
1063
|
-
|
|
1077
|
+
.iuk-animated-image--fill .iuk-animated-image__img {
|
|
1078
|
+
position: absolute;
|
|
1064
1079
|
inset: 0;
|
|
1065
|
-
width: 100%;
|
|
1066
1080
|
height: 100%;
|
|
1067
|
-
transform: none;
|
|
1068
1081
|
}
|
|
1069
1082
|
|
|
1083
|
+
/* In contain mode, the generated blur placeholder stays visible with object-fit: cover
|
|
1084
|
+
and scale(1.1) behind the contained image so letterbox/pillarbox bars show the blur. */
|
|
1070
1085
|
.iuk-animated-image--contain .iuk-animated-image__img {
|
|
1071
1086
|
transform: none;
|
|
1072
1087
|
}
|
|
@@ -1078,12 +1093,11 @@
|
|
|
1078
1093
|
background: linear-gradient(
|
|
1079
1094
|
90deg,
|
|
1080
1095
|
transparent 0%,
|
|
1081
|
-
var(--iuk-animated-image-shimmer, rgba(255, 255, 255, 0.
|
|
1096
|
+
var(--iuk-animated-image-shimmer, rgba(255, 255, 255, 0.1)) 50%,
|
|
1082
1097
|
transparent 100%
|
|
1083
1098
|
);
|
|
1084
|
-
animation: iuk-animated-image-shimmer
|
|
1099
|
+
animation: iuk-animated-image-shimmer 2s infinite;
|
|
1085
1100
|
pointer-events: none;
|
|
1086
|
-
transition: opacity 0.35s ease-out;
|
|
1087
1101
|
}
|
|
1088
1102
|
|
|
1089
1103
|
.iuk-animated-image__shimmer--hidden {
|
|
@@ -1098,6 +1112,7 @@
|
|
|
1098
1112
|
@media (prefers-reduced-motion: reduce) {
|
|
1099
1113
|
.iuk-animated-image__img,
|
|
1100
1114
|
.iuk-animated-image__placeholder {
|
|
1115
|
+
transform: none !important;
|
|
1101
1116
|
transition-duration: 0ms !important;
|
|
1102
1117
|
transition-delay: 0ms !important;
|
|
1103
1118
|
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { I as ImageUploadRecord } from './upload-C5Trd6Dh.cjs';
|
|
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,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
|
-
|
|
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 };
|