@hamur/image 0.0.0-stage → 0.0.2

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 (156) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +24 -2
  3. package/dist/chunks/bun-index-n7xnn0a2.js +502 -0
  4. package/dist/src/adapters/angular.js +275 -0
  5. package/dist/src/adapters/html.js +70 -0
  6. package/dist/src/adapters/preact.js +82 -0
  7. package/dist/src/adapters/react.js +84 -0
  8. package/dist/src/adapters/solid.js +93 -0
  9. package/dist/src/adapters/svelte.js +15 -0
  10. package/dist/src/adapters/vue.js +147 -0
  11. package/dist/src/index.js +1442 -0
  12. package/dist/src/server/index.js +9 -0
  13. package/dist/types/src/adapters/angular-img.d.ts +43 -0
  14. package/dist/types/src/adapters/angular-picture.d.ts +39 -0
  15. package/dist/types/src/adapters/angular.d.ts +3 -0
  16. package/dist/types/src/adapters/html-img.d.ts +10 -0
  17. package/dist/types/src/adapters/html-picture.d.ts +6 -0
  18. package/dist/types/src/adapters/html.d.ts +6 -0
  19. package/dist/types/src/adapters/preact-img.d.ts +8 -0
  20. package/dist/types/src/adapters/preact-picture.d.ts +6 -0
  21. package/dist/types/src/adapters/preact.d.ts +6 -0
  22. package/dist/types/src/adapters/react-img.d.ts +8 -0
  23. package/dist/types/src/adapters/react-picture.d.ts +6 -0
  24. package/dist/types/src/adapters/react.d.ts +6 -0
  25. package/dist/types/src/adapters/solid-img.d.ts +8 -0
  26. package/dist/types/src/adapters/solid-picture.d.ts +6 -0
  27. package/dist/types/src/adapters/solid.d.ts +6 -0
  28. package/dist/types/src/adapters/svelte.d.ts +3 -0
  29. package/dist/types/src/adapters/vue-img.d.ts +119 -0
  30. package/dist/types/src/adapters/vue-picture.d.ts +121 -0
  31. package/dist/types/src/adapters/vue.d.ts +234 -0
  32. package/dist/types/src/build/endpoint.d.ts +12 -0
  33. package/dist/types/src/build/platform.d.ts +24 -0
  34. package/dist/types/src/build/runtime.d.ts +9 -0
  35. package/dist/types/src/build/types.d.ts +4 -0
  36. package/dist/types/src/build/variants.d.ts +8 -0
  37. package/dist/types/src/domains.d.ts +27 -0
  38. package/dist/types/src/index.d.ts +9 -0
  39. package/dist/types/src/module.d.ts +3 -0
  40. package/dist/types/src/options.d.ts +15 -0
  41. package/dist/types/src/providers/bunny.d.ts +9 -0
  42. package/dist/types/src/providers/cloudflare.d.ts +9 -0
  43. package/dist/types/src/providers/cloudflareImages.d.ts +9 -0
  44. package/dist/types/src/providers/cloudinary.d.ts +9 -0
  45. package/dist/types/src/providers/contentful.d.ts +9 -0
  46. package/dist/types/src/providers/fastly.d.ts +9 -0
  47. package/dist/types/src/providers/hamur-url.d.ts +3 -0
  48. package/dist/types/src/providers/hamur.d.ts +3 -0
  49. package/dist/types/src/providers/imagekit.d.ts +9 -0
  50. package/dist/types/src/providers/imgix.d.ts +9 -0
  51. package/dist/types/src/providers/imgproxy.d.ts +9 -0
  52. package/dist/types/src/providers/ipx.d.ts +9 -0
  53. package/dist/types/src/providers/netlify.d.ts +9 -0
  54. package/dist/types/src/providers/none.d.ts +8 -0
  55. package/dist/types/src/providers/sanity.d.ts +9 -0
  56. package/dist/types/src/providers/shared.d.ts +7 -0
  57. package/dist/types/src/providers/storyblok.d.ts +9 -0
  58. package/dist/types/src/providers/strapi.d.ts +9 -0
  59. package/dist/types/src/providers/supabase.d.ts +9 -0
  60. package/dist/types/src/providers/twicpics.d.ts +9 -0
  61. package/dist/types/src/providers/uploadcare.d.ts +9 -0
  62. package/dist/types/src/providers/vercel-url.d.ts +3 -0
  63. package/dist/types/src/providers/vercel.d.ts +3 -0
  64. package/dist/types/src/providers/weserv.d.ts +9 -0
  65. package/dist/types/src/runtime/image.d.ts +28 -0
  66. package/dist/types/src/runtime/img.d.ts +71 -0
  67. package/dist/types/src/runtime/index.d.ts +9 -0
  68. package/dist/types/src/runtime/picture.d.ts +24 -0
  69. package/dist/types/src/runtime/sizes.d.ts +8 -0
  70. package/dist/types/src/runtime/source.d.ts +3 -0
  71. package/dist/types/src/server/door.d.ts +1 -0
  72. package/dist/types/src/server/endpoint.d.ts +46 -0
  73. package/dist/types/src/server/handler.d.ts +1 -0
  74. package/dist/types/src/server/index.d.ts +1 -0
  75. package/dist/types/src/server/miss-handler.d.ts +1 -0
  76. package/dist/types/src/server/miss.d.ts +1 -0
  77. package/dist/types/src/server/parse.d.ts +30 -0
  78. package/dist/types/src/server/remote.d.ts +20 -0
  79. package/dist/types/src/types.d.ts +178 -0
  80. package/package.json +141 -4
  81. package/src/adapters/Img.svelte +33 -0
  82. package/src/adapters/Picture.svelte +39 -0
  83. package/src/adapters/angular-img.ts +143 -0
  84. package/src/adapters/angular-picture.ts +172 -0
  85. package/src/adapters/angular.ts +3 -0
  86. package/src/adapters/html-img.ts +42 -0
  87. package/src/adapters/html-picture.ts +30 -0
  88. package/src/adapters/html.ts +9 -0
  89. package/src/adapters/preact-img.ts +51 -0
  90. package/src/adapters/preact-picture.ts +40 -0
  91. package/src/adapters/preact.ts +9 -0
  92. package/src/adapters/react-img.ts +54 -0
  93. package/src/adapters/react-picture.ts +49 -0
  94. package/src/adapters/react.ts +9 -0
  95. package/src/adapters/solid-img.ts +47 -0
  96. package/src/adapters/solid-picture.ts +43 -0
  97. package/src/adapters/solid.ts +9 -0
  98. package/src/adapters/svelte.ts +3 -0
  99. package/src/adapters/test/ImgCustomPage.svelte +14 -0
  100. package/src/adapters/test/ImgPage.svelte +5 -0
  101. package/src/adapters/test/ImgPreloadPage.svelte +6 -0
  102. package/src/adapters/test/PicturePage.svelte +6 -0
  103. package/src/adapters/test/PicturePreloadPage.svelte +5 -0
  104. package/src/adapters/test/support.ts +116 -0
  105. package/src/adapters/vue-img.ts +72 -0
  106. package/src/adapters/vue-picture.ts +64 -0
  107. package/src/adapters/vue.ts +7 -0
  108. package/src/build/endpoint.ts +78 -0
  109. package/src/build/platform.ts +99 -0
  110. package/src/build/runtime.ts +118 -0
  111. package/src/build/types.ts +23 -0
  112. package/src/build/variants.ts +174 -0
  113. package/src/domains.ts +84 -0
  114. package/src/env.d.ts +24 -0
  115. package/src/index.ts +23 -0
  116. package/src/module.ts +29 -0
  117. package/src/options.ts +329 -0
  118. package/src/providers/bunny.ts +21 -0
  119. package/src/providers/cloudflare.ts +22 -0
  120. package/src/providers/cloudflareImages.ts +25 -0
  121. package/src/providers/cloudinary.ts +31 -0
  122. package/src/providers/contentful.ts +26 -0
  123. package/src/providers/fastly.ts +29 -0
  124. package/src/providers/hamur-url.ts +81 -0
  125. package/src/providers/hamur.ts +8 -0
  126. package/src/providers/imagekit.ts +30 -0
  127. package/src/providers/imgix.ts +26 -0
  128. package/src/providers/imgproxy.ts +24 -0
  129. package/src/providers/ipx.ts +26 -0
  130. package/src/providers/netlify.ts +23 -0
  131. package/src/providers/none.ts +9 -0
  132. package/src/providers/sanity.ts +29 -0
  133. package/src/providers/shared.ts +17 -0
  134. package/src/providers/storyblok.ts +24 -0
  135. package/src/providers/strapi.ts +24 -0
  136. package/src/providers/supabase.ts +26 -0
  137. package/src/providers/twicpics.ts +26 -0
  138. package/src/providers/uploadcare.ts +32 -0
  139. package/src/providers/vercel-url.ts +18 -0
  140. package/src/providers/vercel.ts +8 -0
  141. package/src/providers/weserv.ts +25 -0
  142. package/src/runtime/image.ts +266 -0
  143. package/src/runtime/img.ts +241 -0
  144. package/src/runtime/index.ts +18 -0
  145. package/src/runtime/picture.ts +62 -0
  146. package/src/runtime/sizes.ts +52 -0
  147. package/src/runtime/source.ts +8 -0
  148. package/src/server/door.ts +1 -0
  149. package/src/server/endpoint.ts +428 -0
  150. package/src/server/handler.ts +33 -0
  151. package/src/server/index.ts +1 -0
  152. package/src/server/miss-handler.ts +20 -0
  153. package/src/server/miss.ts +1 -0
  154. package/src/server/parse.ts +152 -0
  155. package/src/server/remote.ts +166 -0
  156. package/src/types.ts +177 -0
@@ -0,0 +1,234 @@
1
+ import { getImage, getSizes } from "../runtime/index.ts";
2
+ export { getImage, getSizes };
3
+ export declare const Img: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
4
+ src: {
5
+ type: import("vue").PropType<string | import("hamur").ImageMeta>;
6
+ required: true;
7
+ };
8
+ alt: {
9
+ type: StringConstructor;
10
+ };
11
+ width: {
12
+ type: import("vue").PropType<number | `${number}`>;
13
+ };
14
+ height: {
15
+ type: import("vue").PropType<number | `${number}`>;
16
+ };
17
+ sizes: {
18
+ type: StringConstructor;
19
+ };
20
+ densities: {
21
+ type: import("vue").PropType<number[]>;
22
+ };
23
+ format: {
24
+ type: import("vue").PropType<import("../types.ts").ImageFormat>;
25
+ };
26
+ quality: {
27
+ type: NumberConstructor;
28
+ };
29
+ fit: {
30
+ type: import("vue").PropType<import("../types.ts").ImageFit>;
31
+ };
32
+ modifiers: {
33
+ type: import("vue").PropType<import("../types.ts").ImageModifiers>;
34
+ };
35
+ provider: {
36
+ type: import("vue").PropType<import("../types.ts").HamurImageProvider>;
37
+ };
38
+ preset: {
39
+ type: import("vue").PropType<import("../types.ts").HamurImagePreset>;
40
+ };
41
+ loading: {
42
+ type: import("vue").PropType<"lazy" | "eager">;
43
+ };
44
+ fetchpriority: {
45
+ type: import("vue").PropType<"high" | "low" | "auto">;
46
+ };
47
+ placeholder: {
48
+ type: StringConstructor;
49
+ };
50
+ placeholderClass: {
51
+ type: StringConstructor;
52
+ };
53
+ preload: {
54
+ type: BooleanConstructor;
55
+ };
56
+ custom: {
57
+ type: import("vue").PropType<(state: import("../runtime/img.ts").ImgState) => import("vue").VNodeChild>;
58
+ };
59
+ }>, () => import("vue").VNodeChild, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
60
+ src: {
61
+ type: import("vue").PropType<string | import("hamur").ImageMeta>;
62
+ required: true;
63
+ };
64
+ alt: {
65
+ type: StringConstructor;
66
+ };
67
+ width: {
68
+ type: import("vue").PropType<number | `${number}`>;
69
+ };
70
+ height: {
71
+ type: import("vue").PropType<number | `${number}`>;
72
+ };
73
+ sizes: {
74
+ type: StringConstructor;
75
+ };
76
+ densities: {
77
+ type: import("vue").PropType<number[]>;
78
+ };
79
+ format: {
80
+ type: import("vue").PropType<import("../types.ts").ImageFormat>;
81
+ };
82
+ quality: {
83
+ type: NumberConstructor;
84
+ };
85
+ fit: {
86
+ type: import("vue").PropType<import("../types.ts").ImageFit>;
87
+ };
88
+ modifiers: {
89
+ type: import("vue").PropType<import("../types.ts").ImageModifiers>;
90
+ };
91
+ provider: {
92
+ type: import("vue").PropType<import("../types.ts").HamurImageProvider>;
93
+ };
94
+ preset: {
95
+ type: import("vue").PropType<import("../types.ts").HamurImagePreset>;
96
+ };
97
+ loading: {
98
+ type: import("vue").PropType<"lazy" | "eager">;
99
+ };
100
+ fetchpriority: {
101
+ type: import("vue").PropType<"high" | "low" | "auto">;
102
+ };
103
+ placeholder: {
104
+ type: StringConstructor;
105
+ };
106
+ placeholderClass: {
107
+ type: StringConstructor;
108
+ };
109
+ preload: {
110
+ type: BooleanConstructor;
111
+ };
112
+ custom: {
113
+ type: import("vue").PropType<(state: import("../runtime/img.ts").ImgState) => import("vue").VNodeChild>;
114
+ };
115
+ }>> & Readonly<{}>, {
116
+ preload: boolean;
117
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
118
+ export declare const Picture: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
119
+ src: {
120
+ type: import("vue").PropType<string | import("hamur").ImageMeta>;
121
+ required: true;
122
+ };
123
+ alt: {
124
+ type: StringConstructor;
125
+ };
126
+ width: {
127
+ type: import("vue").PropType<number | `${number}`>;
128
+ };
129
+ height: {
130
+ type: import("vue").PropType<number | `${number}`>;
131
+ };
132
+ sizes: {
133
+ type: StringConstructor;
134
+ };
135
+ densities: {
136
+ type: import("vue").PropType<number[]>;
137
+ };
138
+ format: {
139
+ type: import("vue").PropType<import("../types.ts").ImageFormat | import("../types.ts").ImageFormat[]>;
140
+ };
141
+ legacyFormat: {
142
+ type: import("vue").PropType<import("../types.ts").ImageFormat>;
143
+ };
144
+ quality: {
145
+ type: NumberConstructor;
146
+ };
147
+ fit: {
148
+ type: import("vue").PropType<import("../types.ts").ImageFit>;
149
+ };
150
+ modifiers: {
151
+ type: import("vue").PropType<import("../types.ts").ImageModifiers>;
152
+ };
153
+ provider: {
154
+ type: import("vue").PropType<import("../types.ts").HamurImageProvider>;
155
+ };
156
+ preset: {
157
+ type: import("vue").PropType<import("../types.ts").HamurImagePreset>;
158
+ };
159
+ loading: {
160
+ type: import("vue").PropType<"lazy" | "eager">;
161
+ };
162
+ fetchpriority: {
163
+ type: import("vue").PropType<"high" | "low" | "auto">;
164
+ };
165
+ preload: {
166
+ type: BooleanConstructor;
167
+ };
168
+ placeholder: {
169
+ type: StringConstructor;
170
+ };
171
+ placeholderClass: {
172
+ type: StringConstructor;
173
+ };
174
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
175
+ [key: string]: any;
176
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
177
+ src: {
178
+ type: import("vue").PropType<string | import("hamur").ImageMeta>;
179
+ required: true;
180
+ };
181
+ alt: {
182
+ type: StringConstructor;
183
+ };
184
+ width: {
185
+ type: import("vue").PropType<number | `${number}`>;
186
+ };
187
+ height: {
188
+ type: import("vue").PropType<number | `${number}`>;
189
+ };
190
+ sizes: {
191
+ type: StringConstructor;
192
+ };
193
+ densities: {
194
+ type: import("vue").PropType<number[]>;
195
+ };
196
+ format: {
197
+ type: import("vue").PropType<import("../types.ts").ImageFormat | import("../types.ts").ImageFormat[]>;
198
+ };
199
+ legacyFormat: {
200
+ type: import("vue").PropType<import("../types.ts").ImageFormat>;
201
+ };
202
+ quality: {
203
+ type: NumberConstructor;
204
+ };
205
+ fit: {
206
+ type: import("vue").PropType<import("../types.ts").ImageFit>;
207
+ };
208
+ modifiers: {
209
+ type: import("vue").PropType<import("../types.ts").ImageModifiers>;
210
+ };
211
+ provider: {
212
+ type: import("vue").PropType<import("../types.ts").HamurImageProvider>;
213
+ };
214
+ preset: {
215
+ type: import("vue").PropType<import("../types.ts").HamurImagePreset>;
216
+ };
217
+ loading: {
218
+ type: import("vue").PropType<"lazy" | "eager">;
219
+ };
220
+ fetchpriority: {
221
+ type: import("vue").PropType<"high" | "low" | "auto">;
222
+ };
223
+ preload: {
224
+ type: BooleanConstructor;
225
+ };
226
+ placeholder: {
227
+ type: StringConstructor;
228
+ };
229
+ placeholderClass: {
230
+ type: StringConstructor;
231
+ };
232
+ }>> & Readonly<{}>, {
233
+ preload: boolean;
234
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -0,0 +1,12 @@
1
+ import { type HamurContext } from "hamur/kit";
2
+ import type { ImageBuildOptions, ImageProviderName } from "../types.ts";
3
+ /** True where the `hamur` provider transforms at run time: `hamur dev` on any preset, and a preset whose `features.imageTransforms` is not `unsupported`. */
4
+ export declare function transformsAtRunTime(hamur: HamurContext): boolean;
5
+ /** What `image.provider` names on this build. `auto` is `hamur` under `hamur dev`, else the preset's `features.imageService`, else `hamur`. */
6
+ export declare function resolveProvider(provider: string, hamur: HamurContext): ImageProviderName;
7
+ /** Blob sources need run-time transforms: the build has no blob to read. */
8
+ export declare function blobsUntransformed(options: ImageBuildOptions, hamur: HamurContext): boolean;
9
+ /** The built-in providers a build may call: the default, the presets' and every configured entry. */
10
+ export declare function providersUsed(options: ImageBuildOptions): Set<string>;
11
+ /** The door with `/_hamur/image/**` where transforms run at run time; the 404 route on a build-variants preset with a server, none on `static`. */
12
+ export declare function setupEndpoint(options: ImageBuildOptions, hamur: HamurContext): void;
@@ -0,0 +1,24 @@
1
+ import { type HamurContext } from "hamur/kit";
2
+ import type { ImageBuildOptions } from "../types.ts";
3
+ export interface RemotePattern {
4
+ protocol: "http" | "https";
5
+ hostname: string;
6
+ port: string;
7
+ pathname: string;
8
+ }
9
+ type Sources = Pick<ImageBuildOptions, "domains" | "alias">;
10
+ /** `image.domains` and the `alias` targets as URL patterns. A target contributes its protocol, host, port and path (below which everything matches); `resolveOptions` has refused a query, a fragment and credentials. */
11
+ export declare function remotePatterns({ domains, alias }: Sources): RemotePattern[];
12
+ /** One anchored expression per `image.domains` entry and alias target: the whole URL, an optional query string allowed. */
13
+ export declare function remoteImages(sources: Sources): string[];
14
+ /** The qualities a `getImage` URL on Vercel can carry: the default, each preset's and the 75 sent when none is set. */
15
+ export declare function qualities(options: Pick<ImageBuildOptions, "quality" | "presets">): number[];
16
+ /** The `images` of `.vercel/output/config.json`. */
17
+ export declare function vercelImages(options: ImageBuildOptions): Record<string, unknown>;
18
+ /** The `images` of `.netlify/v1/config.json`. */
19
+ export declare function netlifyImages(options: ImageBuildOptions): Record<string, unknown>;
20
+ /** The app's `images` with Hamur's over it: a plain object merges, an array is the union of both (the app's entries first), any other value is Hamur's. */
21
+ export declare function mergeImages(own: unknown, ours: Record<string, unknown>): Record<string, unknown>;
22
+ /** Puts the platform service's `images` into `vercel.config.images` or `netlify.config.images`, which the preset writes. */
23
+ export declare function setupPlatform(options: ImageBuildOptions, hamur: HamurContext): void;
24
+ export {};
@@ -0,0 +1,9 @@
1
+ import { type HamurContext } from "hamur/kit";
2
+ import type { ImageSources, ImageBuildOptions } from "../types.ts";
3
+ export declare const normalizedBase: (baseURL: string) => string;
4
+ /** The names `#hamur/image/providers` imports: the default provider, the keys of `providers`, the presets' providers and `none`. */
5
+ export declare function providerNames(options: ImageBuildOptions): string[];
6
+ /** One entry per image file below the source dirs; the first dir that holds a path wins. A file whose header cannot be read, or whose path holds `:` (the separator of a storage key), is left out with one `warn`. */
7
+ export declare function readSources(dirs: string[], warn?: (message: string) => void): Promise<ImageSources>;
8
+ /** `#hamur/image/options`, `#hamur/image/providers` and `#hamur/image/sources`. */
9
+ export declare function setupRuntime(options: ImageBuildOptions, hamur: HamurContext): void;
@@ -0,0 +1,4 @@
1
+ import type { ImageBuildOptions } from "../types.ts";
2
+ /** The provider and preset names the build knows, as the registries `HamurImageProvider` and `HamurImagePreset` read; the first line pulls the module's `#hamur/image/*` declarations into every program that reads the file. */
3
+ export declare function typesTemplate(options: ImageBuildOptions): string;
4
+ export declare function setupTypes(options: ImageBuildOptions): void;
@@ -0,0 +1,8 @@
1
+ import { type HamurContext } from "hamur/kit";
2
+ import type { ImageBuildOptions, ImageSources, ResolvedImageOptions } from "../types.ts";
3
+ /** The `<baseURL>_hamur/image/` URLs of `src`, `srcset`, `imagesrcset`, `href` and `url(…)` in `style`, entities decoded, as path and query. */
4
+ export declare function collectImageUrls(html: string, baseURL: string): string[];
5
+ /** The URLs `getSizes` gives for `path`: every width of `widths` up to the source's, and the source's own, in each format `hamur` makes. */
6
+ export declare function sourceUrls(path: string, entry: ImageSources[string], options: Pick<ResolvedImageOptions, "widths" | "format" | "quality">, baseURL: string): string[];
7
+ /** Build variants, on every preset whose `hamur` provider has no run-time transform. */
8
+ export declare function setupVariants(options: ImageBuildOptions, hamur: HamurContext): void;
@@ -0,0 +1,27 @@
1
+ export type DomainKind = "ok" | "invalid" | "every";
2
+ export interface DomainMatcher {
3
+ protocol: string;
4
+ host: RegExp;
5
+ port: string;
6
+ path?: RegExp;
7
+ }
8
+ /** The regular expression source of a lower-case host pattern: `*.` one label, `**.` one label or more. */
9
+ export declare function hostSource(host: string): string;
10
+ /** The regular expression source of a path pattern: `*` one segment, `**` anything. */
11
+ export declare function pathSource(path: string): string;
12
+ export interface DomainParts {
13
+ protocol: "http:" | "https:";
14
+ /** Lower case, with its wildcards. */
15
+ host: string;
16
+ /** `""` for the scheme's default port. */
17
+ port: string;
18
+ /** Absent for a host pattern. */
19
+ path?: string;
20
+ }
21
+ /** `pattern` passed `checkDomain` as `"ok"`. */
22
+ export declare function parseDomain(pattern: string): DomainParts;
23
+ /** `domains` takes a host pattern (`cdn.example.com`, `*.example.com`, `**.example.com`) or a URL pattern (`http://cdn.example.com:8080/img/**`). */
24
+ export declare function checkDomain(pattern: string): DomainKind;
25
+ /** `pattern` passed `checkDomain` as `"ok"`. */
26
+ export declare function compileDomain(pattern: string): DomainMatcher;
27
+ export declare function matchesDomain(matcher: DomainMatcher, url: URL): boolean;
@@ -0,0 +1,9 @@
1
+ import type { ImageOptions } from "./types.ts";
2
+ export { default } from "./module.ts";
3
+ export type { ImageMeta } from "hamur";
4
+ export type { ImageFit, ImageFormat, ImageModifiers, ImageOptions, ImageProvider, ImageProviderContext, ImageSizes, HamurImagePreset, HamurImagePresets, HamurImageProvider, HamurImageProviders, } from "./types.ts";
5
+ declare module "hamur" {
6
+ interface HamurModuleOptions {
7
+ image?: ImageOptions;
8
+ }
9
+ }
@@ -0,0 +1,3 @@
1
+ import type { ImageOptions } from "./types.ts";
2
+ declare const _default: import("hamur/kit").HamurModule<ImageOptions>;
3
+ export default _default;
@@ -0,0 +1,15 @@
1
+ import type { ResolvedImageOptions } from "./types.ts";
2
+ export declare const BUILT_IN_PROVIDERS: readonly string[];
3
+ export declare const DEFAULT_SCREENS: Record<string, number>;
4
+ export declare const DEFAULT_DENSITIES: number[];
5
+ export declare const SMALL_WIDTHS: number[];
6
+ export declare const DEFAULT_MAX_PIXELS = 50000000;
7
+ export declare const DEFAULT_MAX_BYTES = 26214400;
8
+ export interface ResolveEnvironment {
9
+ rootDir: string;
10
+ /** The app's `public/` and each layer's, highest priority first. */
11
+ publicDirs: string[];
12
+ exists(path: string): boolean;
13
+ }
14
+ /** The `image` key checked, with the defaults; every load error names the key. */
15
+ export declare function resolveOptions(input: unknown, env: ResolveEnvironment): ResolvedImageOptions;
@@ -0,0 +1,9 @@
1
+ /** Bunny Optimizer on a pull zone; `options.origin` is the zone's URL, `https://example.b-cdn.net` for example. It converts to `webp` and `png` by `format` and serves WebP to browsers that accept it; the docs give no behaviour for both `width` and `height`, so no fit is made; a remote `src` is returned as it is. */
2
+ declare const _default: {
3
+ formats: ("png" | "webp")[];
4
+ negotiates: true;
5
+ fits: never[];
6
+ modifiers: never[];
7
+ getImage(src: string, { modifiers: m, options, baseURL }: import("../types.ts").ImageProviderContext): string;
8
+ };
9
+ export default _default;
@@ -0,0 +1,9 @@
1
+ /** Cloudflare Image Transformations, which the zone must have turned on; `fit=contain` there is `inside` and `fit=pad` is `contain`. */
2
+ declare const _default: {
3
+ formats: ("avif" | "jpeg" | "png" | "webp")[];
4
+ negotiates: true;
5
+ fits: ("contain" | "cover" | "inside")[];
6
+ modifiers: never[];
7
+ getImage(src: string, { modifiers: m, baseURL }: import("../types.ts").ImageProviderContext): string;
8
+ };
9
+ export default _default;
@@ -0,0 +1,9 @@
1
+ /** Cloudflare Images delivery with flexible variants, which the account must have turned on; `options.accountHash` is required. `src` is the image id; a remote `src` is returned as it is. `fit=contain` there is `inside` and `fit=pad` is `contain`. */
2
+ declare const _default: {
3
+ formats: ("avif" | "jpeg" | "png" | "webp")[];
4
+ negotiates: true;
5
+ fits: ("contain" | "cover" | "inside")[];
6
+ modifiers: never[];
7
+ getImage(src: string, { modifiers: m, options, baseURL }: import("../types.ts").ImageProviderContext): string;
8
+ };
9
+ export default _default;
@@ -0,0 +1,9 @@
1
+ /** Cloudinary; `options.cloudName` is required. A local `src` is a public id of the `upload` type, a remote one is delivered through `fetch`. */
2
+ declare const _default: {
3
+ formats: ("avif" | "jpeg" | "png" | "webp")[];
4
+ negotiates: true;
5
+ fits: ("contain" | "cover" | "fill" | "inside")[];
6
+ modifiers: string[];
7
+ getImage(src: string, { modifiers: m, options, baseURL }: import("../types.ts").ImageProviderContext): string;
8
+ };
9
+ export default _default;
@@ -0,0 +1,9 @@
1
+ /** The Contentful Images API; a local `src` is the asset's path below `options.origin` (default `https://images.ctfassets.net`). `fit=fill` there is `cover`, `fit=pad` is `contain` and `fit=scale` is `fill`. */
2
+ declare const _default: {
3
+ formats: ("avif" | "jpeg" | "png" | "webp")[];
4
+ negotiates: false;
5
+ fits: ("contain" | "cover" | "fill")[];
6
+ modifiers: never[];
7
+ getImage(src: string, { modifiers: m, options, baseURL }: import("../types.ts").ImageProviderContext): string;
8
+ };
9
+ export default _default;
@@ -0,0 +1,9 @@
1
+ /** Fastly Image Optimizer; `options.origin` is the service's domain and is unset when it serves the app's own domain. A remote `src` gets the query as it is. `fit=bounds` there is `inside` and `fit=crop` is `cover`; `fit` takes effect only with both sizes. */
2
+ declare const _default: {
3
+ formats: ("avif" | "jpeg" | "png" | "webp")[];
4
+ negotiates: true;
5
+ fits: ("cover" | "inside")[];
6
+ modifiers: string[];
7
+ getImage(src: string, { modifiers: m, options, baseURL }: import("../types.ts").ImageProviderContext): string;
8
+ };
9
+ export default _default;
@@ -0,0 +1,3 @@
1
+ import type { ImageProvider, ImageSources } from "../types.ts";
2
+ /** The built-in `hamur` provider; `sources` is `#hamur/image/sources`. */
3
+ export declare function createHamurProvider(sources: ImageSources): ImageProvider;
@@ -0,0 +1,3 @@
1
+ import type { ImageProvider } from "../types.ts";
2
+ declare const provider: ImageProvider;
3
+ export default provider;
@@ -0,0 +1,9 @@
1
+ /** ImageKit; `options.origin` is the URL endpoint, `https://ik.imagekit.io/your_id` for example. A remote `src` follows the endpoint as a web proxy source. */
2
+ declare const _default: {
3
+ formats: ("avif" | "jpeg" | "png" | "webp")[];
4
+ negotiates: true;
5
+ fits: ("contain" | "cover" | "fill" | "inside" | "outside")[];
6
+ modifiers: string[];
7
+ getImage(src: string, { modifiers: m, options, baseURL }: import("../types.ts").ImageProviderContext): string;
8
+ };
9
+ export default _default;
@@ -0,0 +1,9 @@
1
+ /** Imgix; `rot` turns counter-clockwise, so `rotate` is sent as 360 minus it; `options.origin` is the source's domain, `https://assets.imgix.net` for example. A remote `src` is a web proxy source: the whole URL, encoded, is the path. */
2
+ declare const _default: {
3
+ formats: ("avif" | "jpeg" | "png" | "webp")[];
4
+ negotiates: true;
5
+ fits: ("contain" | "cover" | "fill" | "inside")[];
6
+ modifiers: string[];
7
+ getImage(src: string, { modifiers: m, options, baseURL }: import("../types.ts").ImageProviderContext): string;
8
+ };
9
+ export default _default;
@@ -0,0 +1,9 @@
1
+ /** imgproxy's unsigned `/insecure/` URLs: a signing key would reach every browser, so the service must restrict its sources (`IMGPROXY_ALLOWED_SOURCES`). `options.origin` is the service's URL; a local `src` is read as `local:///<path>`. Without a format the service decides from `Accept` when its WebP and AVIF detection is on. */
2
+ declare const _default: {
3
+ formats: ("avif" | "jpeg" | "png" | "webp")[];
4
+ negotiates: true;
5
+ fits: ("cover" | "fill" | "inside")[];
6
+ modifiers: string[];
7
+ getImage(src: string, { modifiers: m, options, baseURL }: import("../types.ts").ImageProviderContext): string;
8
+ };
9
+ export default _default;
@@ -0,0 +1,9 @@
1
+ /** An IPX server the app runs; `options.origin` is its URL. A local `src` is its path below the source dir, a remote one the URL IPX's `http` storage takes (its `domains` allowlist). */
2
+ declare const _default: {
3
+ formats: ("avif" | "jpeg" | "png" | "webp")[];
4
+ negotiates: false;
5
+ fits: ("contain" | "cover" | "fill" | "inside" | "outside")[];
6
+ modifiers: string[];
7
+ getImage(src: string, { modifiers: m, options, baseURL }: import("../types.ts").ImageProviderContext): string;
8
+ };
9
+ export default _default;
@@ -0,0 +1,9 @@
1
+ /** The Netlify Image CDN; `fit=contain` there is `inside`. */
2
+ declare const _default: {
3
+ formats: ("avif" | "jpeg" | "png" | "webp")[];
4
+ negotiates: true;
5
+ fits: ("cover" | "fill" | "inside")[];
6
+ modifiers: never[];
7
+ getImage(src: string, { modifiers: m, baseURL }: import("../types.ts").ImageProviderContext): string;
8
+ };
9
+ export default _default;
@@ -0,0 +1,8 @@
1
+ declare const _default: {
2
+ formats: never[];
3
+ negotiates: false;
4
+ fits: never[];
5
+ modifiers: never[];
6
+ getImage: (src: string) => string;
7
+ };
8
+ export default _default;
@@ -0,0 +1,9 @@
1
+ /** The Sanity image pipeline; a local `src` is a file name below `options.projectId` and `options.dataset` (default `production`), a remote one is the asset URL. No AVIF there. */
2
+ declare const _default: {
3
+ formats: ("jpeg" | "png" | "webp")[];
4
+ negotiates: true;
5
+ fits: ("contain" | "cover" | "fill" | "inside")[];
6
+ modifiers: string[];
7
+ getImage(src: string, { modifiers: m, options, baseURL }: import("../types.ts").ImageProviderContext): string;
8
+ };
9
+ export default _default;
@@ -0,0 +1,7 @@
1
+ import type { ImageFormat } from "../types.ts";
2
+ /** The string option `key` of `image.providers.<provider>.options` without a trailing slash; `fallback` stands in when it is unset. */
3
+ export declare function option(provider: string, options: Record<string, unknown>, key: string, fallback?: string): string;
4
+ /** `url` with `pairs` (`key=value`) after its query, if any. */
5
+ export declare function withQuery(url: string, pairs: string[]): string;
6
+ /** The name most services give an output format: `jpg` for `jpeg`. */
7
+ export declare const JPG: Record<ImageFormat, string>;
@@ -0,0 +1,9 @@
1
+ /** The Storyblok Image Service, which takes the operations after `/m/` on the asset's own URL; a local `src` is the asset's path below `options.origin` (default `https://a.storyblok.com`). A size has `0` for the side left open, and `fit-in` there is `inside`. */
2
+ declare const _default: {
3
+ formats: ("avif" | "jpeg" | "png" | "webp")[];
4
+ negotiates: false;
5
+ fits: ("cover" | "inside")[];
6
+ modifiers: never[];
7
+ getImage(src: string, { modifiers: m, options, baseURL }: import("../types.ts").ImageProviderContext): string;
8
+ };
9
+ export default _default;
@@ -0,0 +1,9 @@
1
+ /** Strapi's upload plugin has no transform URL; its default responsive breakpoints are `small` (500), `medium` (750) and `large` (1000), and the file of each is the original name with `small_`, `medium_` or `large_` before it, and the smallest one that is at least `width` wide is used. A wider `width`, or none, gives the original. `options.origin` is Strapi's URL for a local `src`. */
2
+ declare const _default: {
3
+ formats: never[];
4
+ negotiates: false;
5
+ fits: never[];
6
+ modifiers: never[];
7
+ getImage(src: string, { modifiers: m, options, baseURL }: import("../types.ts").ImageProviderContext): string;
8
+ };
9
+ export default _default;
@@ -0,0 +1,9 @@
1
+ /** Supabase Storage image transformations of a public bucket; `options.origin` is the project's URL (`https://<project>.supabase.co`) and a local `src` is `/<bucket>/<path>`. A remote `src` of the object route is moved to the render route. The service picks WebP from `Accept`, and `resize=contain` there is `inside`. */
2
+ declare const _default: {
3
+ formats: never[];
4
+ negotiates: true;
5
+ fits: ("cover" | "fill" | "inside")[];
6
+ modifiers: never[];
7
+ getImage(src: string, { modifiers: m, options, baseURL }: import("../types.ts").ImageProviderContext): string;
8
+ };
9
+ export default _default;
@@ -0,0 +1,9 @@
1
+ /** TwicPics; `options.origin` is the domain, `https://demo.twic.pics` for example. `contain` there fits inside without padding, so it is `inside`; a fit needs both sizes, else `resize=<width>`. `flip=y` mirrors vertically. A remote `src` gets the `twic` query as it is. */
2
+ declare const _default: {
3
+ formats: ("avif" | "jpeg" | "png" | "webp")[];
4
+ negotiates: true;
5
+ fits: ("cover" | "fill" | "inside")[];
6
+ modifiers: string[];
7
+ getImage(src: string, { modifiers: m, options, baseURL }: import("../types.ts").ImageProviderContext): string;
8
+ };
9
+ export default _default;
@@ -0,0 +1,9 @@
1
+ /** Uploadcare CDN operations; `src` is `/<uuid>/…` or an asset URL; the file name after the uuid is dropped, and the file is served from `options.origin` (default `https://ucarecdn.com`). `-/rotate/` turns counter-clockwise, so `rotate` is sent as 360 minus it; `-/format/` has no AVIF, only `auto` may choose it; the docs do not say which axis `-/flip/` and `-/mirror/` use, so neither is made. The service takes named qualities only: up to 25 is `lightest`, 45 `lighter`, 70 `normal`, 85 `better`, above `best`. */
2
+ declare const _default: {
3
+ formats: ("jpeg" | "png" | "webp")[];
4
+ negotiates: true;
5
+ fits: ("cover" | "inside")[];
6
+ modifiers: string[];
7
+ getImage(src: string, { modifiers: m, options, baseURL }: import("../types.ts").ImageProviderContext): string;
8
+ };
9
+ export default _default;
@@ -0,0 +1,3 @@
1
+ import type { ImageProvider } from "../types.ts";
2
+ /** Vercel's image optimisation, which refuses a width outside `images.sizes` and needs a quality; `widths` is `image.widths`, sorted. */
3
+ export declare function createVercelProvider(widths: readonly number[]): ImageProvider;
@@ -0,0 +1,3 @@
1
+ import type { ImageProvider } from "../types.ts";
2
+ declare const provider: ImageProvider;
3
+ export default provider;
@@ -0,0 +1,9 @@
1
+ /** images.weserv.nl; `options.origin` is the service (default `https://wsrv.nl`) and `options.sourceURL` the public URL of the app, which a local `src` is read from. */
2
+ declare const _default: {
3
+ formats: ("jpeg" | "png" | "webp")[];
4
+ negotiates: false;
5
+ fits: ("contain" | "cover" | "fill" | "inside" | "outside")[];
6
+ modifiers: string[];
7
+ getImage(src: string, { modifiers: m, options, baseURL }: import("../types.ts").ImageProviderContext): string;
8
+ };
9
+ export default _default;
@@ -0,0 +1,28 @@
1
+ import type { ImageMeta } from "hamur";
2
+ import type { ImageModifiers, ImageProvider, ImageRuntimeOptions, ImageSizes, ImageSources, HamurImagePreset, HamurImageProvider } from "../types.ts";
3
+ export interface ImageCallOptions {
4
+ provider?: HamurImageProvider;
5
+ preset?: HamurImagePreset;
6
+ }
7
+ export interface GetSizesOptions extends ImageCallOptions {
8
+ sizes?: string;
9
+ width?: number;
10
+ height?: number;
11
+ densities?: number[];
12
+ modifiers?: ImageModifiers;
13
+ }
14
+ export interface ImageApi {
15
+ getImage(src: string | ImageMeta, modifiers?: ImageModifiers, options?: ImageCallOptions): {
16
+ url: string;
17
+ };
18
+ getSizes(src: string | ImageMeta, options: GetSizesOptions): ImageSizes;
19
+ }
20
+ export interface ImageEnvironment {
21
+ options: ImageRuntimeOptions;
22
+ sources: ImageSources;
23
+ providers: Record<string, ImageProvider>;
24
+ /** Default: `console.warn` under `hamur dev`. */
25
+ warn?: (message: string) => void;
26
+ }
27
+ /** `getImage` and `getSizes` as pure functions of the options and the sources. */
28
+ export declare function createImage(env: ImageEnvironment): ImageApi;