@softistx/alxia-media 0.0.0-stage → 0.12.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.
Files changed (51) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +373 -2
  3. package/dist/body.d.ts +24 -0
  4. package/dist/body.d.ts.map +1 -0
  5. package/dist/bucket.d.ts +21 -0
  6. package/dist/bucket.d.ts.map +1 -0
  7. package/dist/checks.d.ts +11 -0
  8. package/dist/checks.d.ts.map +1 -0
  9. package/dist/chunks/index-8s779ve6.js +106 -0
  10. package/dist/chunks/index-8s779ve6.js.map +10 -0
  11. package/dist/headers.d.ts +19 -0
  12. package/dist/headers.d.ts.map +1 -0
  13. package/dist/image/index.d.ts +2 -0
  14. package/dist/image/index.d.ts.map +1 -0
  15. package/dist/image/index.js +199 -0
  16. package/dist/image/index.js.map +11 -0
  17. package/dist/image/peer.d.ts +14 -0
  18. package/dist/image/peer.d.ts.map +1 -0
  19. package/dist/image/rendition.d.ts +109 -0
  20. package/dist/image/rendition.d.ts.map +1 -0
  21. package/dist/index.d.ts +9 -0
  22. package/dist/index.d.ts.map +1 -0
  23. package/dist/index.js +825 -0
  24. package/dist/index.js.map +22 -0
  25. package/dist/key.d.ts +40 -0
  26. package/dist/key.d.ts.map +1 -0
  27. package/dist/kind-callbacks.d.ts +28 -0
  28. package/dist/kind-callbacks.d.ts.map +1 -0
  29. package/dist/kind-check.d.ts +20 -0
  30. package/dist/kind-check.d.ts.map +1 -0
  31. package/dist/kind.d.ts +173 -0
  32. package/dist/kind.d.ts.map +1 -0
  33. package/dist/range.d.ts +17 -0
  34. package/dist/range.d.ts.map +1 -0
  35. package/dist/read.d.ts +11 -0
  36. package/dist/read.d.ts.map +1 -0
  37. package/dist/refusal.d.ts +90 -0
  38. package/dist/refusal.d.ts.map +1 -0
  39. package/dist/rendition.d.ts +94 -0
  40. package/dist/rendition.d.ts.map +1 -0
  41. package/dist/routes.d.ts +62 -0
  42. package/dist/routes.d.ts.map +1 -0
  43. package/dist/sniff.d.ts +16 -0
  44. package/dist/sniff.d.ts.map +1 -0
  45. package/dist/write.d.ts +42 -0
  46. package/dist/write.d.ts.map +1 -0
  47. package/docs/README.md +11 -0
  48. package/docs/guide.md +902 -0
  49. package/docs/roadmap.md +73 -0
  50. package/docs/troubleshooting.md +563 -0
  51. package/package.json +65 -5
@@ -0,0 +1,199 @@
1
+ import {
2
+ MediaRefusal2
3
+ } from "../chunks/index-8s779ve6.js";
4
+
5
+ // src/image/peer.ts
6
+ var notFound = (error, specifier) => error instanceof Error && ("code" in error) && (error.code === "MODULE_NOT_FOUND" || error.code === "ERR_MODULE_NOT_FOUND") && error.message.includes(specifier);
7
+ async function importPeer(specifier, load) {
8
+ try {
9
+ return await load();
10
+ } catch (error) {
11
+ if (!notFound(error, specifier))
12
+ throw error;
13
+ throw new Error(`@softistx/alxia-media/image needs ${specifier}, an optional peer that is not installed: bun add ${specifier}`, { cause: error });
14
+ }
15
+ }
16
+ var image = await importPeer("@softistx/image", () => import("@softistx/image"));
17
+
18
+ // src/image/rendition.ts
19
+ var FULL = "full";
20
+ var TYPES = { png: "image/png", webp: "image/webp" };
21
+ function formatOf(format) {
22
+ if (format === undefined)
23
+ return "png";
24
+ if (format === "png" || format === "webp")
25
+ return format;
26
+ throw new TypeError(`withImageRendition(): format must be "png" or "webp", got ${JSON.stringify(format)}`);
27
+ }
28
+ function refusalOf(error, min) {
29
+ if (!(error instanceof image.ImageError))
30
+ return error;
31
+ const { code, reason } = error;
32
+ if (code === "INVALID_CROP") {
33
+ return new MediaRefusal2("invalid_crop", {}, { cause: error });
34
+ }
35
+ if (code === "UNSUPPORTED_TYPE") {
36
+ return new MediaRefusal2("unsupported_type", {}, { cause: error });
37
+ }
38
+ return new MediaRefusal2("unprocessable", { reason, ...reason === "dimensions" && { min } }, { cause: error });
39
+ }
40
+ function cropOf(crop, request) {
41
+ if (crop === undefined)
42
+ return;
43
+ if (crop === "query") {
44
+ return image.cropFromQuery(new URL(request.url).searchParams);
45
+ }
46
+ return crop(request);
47
+ }
48
+ function withImageRendition(options) {
49
+ const format = formatOf(options.format);
50
+ const { crop } = options;
51
+ if (crop !== undefined && crop !== "query" && typeof crop !== "function") {
52
+ throw new TypeError(`withImageRendition(): crop must be "query" or a function of the request, got ${JSON.stringify(crop)}`);
53
+ }
54
+ if (format === "png" && options.quality !== undefined) {
55
+ throw new TypeError('withImageRendition(): quality is the WebP quality; a png is not lossy, drop it or use format: "webp"');
56
+ }
57
+ const { full } = options;
58
+ const fit = options.fit ?? "cover";
59
+ if (fit !== "cover" && fit !== "inside") {
60
+ throw new TypeError(`withImageRendition(): fit must be "cover" or "inside", got ${JSON.stringify(options.fit)}`);
61
+ }
62
+ if (options.enlarge !== undefined && typeof options.enlarge !== "boolean") {
63
+ throw new TypeError(`withImageRendition(): enlarge must be a boolean, got ${JSON.stringify(options.enlarge)}`);
64
+ }
65
+ if (fit === "inside" && crop !== undefined) {
66
+ throw new TypeError('withImageRendition(): crop picks a square, which fit: "inside" does not make; drop one');
67
+ }
68
+ const fitted = fit === "inside" || options.enlarge === false;
69
+ if (full !== undefined) {
70
+ if (full === null || typeof full !== "object" || full.fit !== "inside" || !Number.isInteger(full.maxSide) || full.maxSide < 1 || full.maxSide > 8192) {
71
+ throw new TypeError(`withImageRendition(): full must be { fit: "inside", maxSide } with maxSide a whole number from 1 to 8192, got ${JSON.stringify(full)}`);
72
+ }
73
+ }
74
+ const squares = options.sizes ?? [];
75
+ if (options.sizes === undefined && full === undefined) {
76
+ throw new TypeError("withImageRendition(): give sizes (the square sides), full (the whole picture), or both");
77
+ }
78
+ const quality = format === "webp" ? options.quality ?? 80 : undefined;
79
+ const set = squares.length === 0 && full !== undefined || fitted ? undefined : image.defineImageSet({
80
+ ...format === "png" ? { format: "png" } : { format: "webp", quality: quality ?? 80 },
81
+ sizes: squares,
82
+ maxBytes: Number.MAX_SAFE_INTEGER,
83
+ ...options.minSide !== undefined && { minSide: options.minSide },
84
+ ...options.maxPixels !== undefined && {
85
+ maxPixels: options.maxPixels
86
+ },
87
+ ...options.concurrency !== undefined && {
88
+ concurrency: options.concurrency
89
+ }
90
+ });
91
+ const contentType = TYPES[format];
92
+ const min = options.minSide ?? (set === undefined ? 1 : Math.max(...squares));
93
+ const limits = {
94
+ maxBytes: Number.MAX_SAFE_INTEGER,
95
+ ...options.maxPixels !== undefined && { maxPixels: options.maxPixels }
96
+ };
97
+ const render = (bytes, width, height, crop) => image.renderImage(bytes, {
98
+ width,
99
+ height,
100
+ ...crop !== undefined && { crop },
101
+ format,
102
+ ...quality !== undefined && { quality },
103
+ ...limits
104
+ }).catch((error) => {
105
+ throw refusalOf(error, min);
106
+ });
107
+ const make = async ({
108
+ bytes,
109
+ request
110
+ }) => {
111
+ const made = [];
112
+ let source;
113
+ if (set !== undefined) {
114
+ const box = cropOf(crop, request);
115
+ const done = await set.process(bytes, box === undefined ? undefined : { crop: box }).catch((error) => {
116
+ throw refusalOf(error, min);
117
+ });
118
+ source = done.source;
119
+ for (const variant of done.variants) {
120
+ made.push({
121
+ size: String(variant.size),
122
+ contentType,
123
+ bytes: variant.bytes,
124
+ width: variant.width,
125
+ height: variant.height
126
+ });
127
+ }
128
+ }
129
+ if (fitted) {
130
+ const probe = (await render(bytes, 1, 1)).source;
131
+ source = probe;
132
+ const short = Math.min(probe.width, probe.height);
133
+ if (options.minSide !== undefined && short < options.minSide) {
134
+ throw new MediaRefusal2("unprocessable", {
135
+ reason: "dimensions",
136
+ min: options.minSide
137
+ });
138
+ }
139
+ const box = cropOf(crop, request);
140
+ for (const side of squares) {
141
+ let one;
142
+ if (fit === "inside") {
143
+ const scale = Math.min(1, side / Math.max(probe.width, probe.height));
144
+ one = await render(bytes, Math.max(1, Math.round(probe.width * scale)), Math.max(1, Math.round(probe.height * scale)));
145
+ } else {
146
+ const square = box ?? {
147
+ x: Math.floor((probe.width - short) / 2),
148
+ y: Math.floor((probe.height - short) / 2),
149
+ size: short
150
+ };
151
+ const out = Math.min(side, square.size);
152
+ one = await render(bytes, out, out, {
153
+ x: square.x,
154
+ y: square.y,
155
+ width: square.size,
156
+ height: square.size
157
+ });
158
+ }
159
+ made.push({
160
+ size: String(side),
161
+ contentType,
162
+ bytes: one.bytes,
163
+ width: one.width,
164
+ height: one.height
165
+ });
166
+ }
167
+ }
168
+ if (full !== undefined) {
169
+ source ??= (await render(bytes, 1, 1)).source;
170
+ const scale = Math.min(1, full.maxSide / Math.max(source.width, source.height));
171
+ const one = await render(bytes, Math.max(1, Math.round(source.width * scale)), Math.max(1, Math.round(source.height * scale)));
172
+ made.push({
173
+ size: FULL,
174
+ contentType,
175
+ bytes: one.bytes,
176
+ width: one.width,
177
+ height: one.height
178
+ });
179
+ }
180
+ return made;
181
+ };
182
+ return {
183
+ sizes: [
184
+ ...fitted ? squares.map(String) : set?.sizes.map(String) ?? [],
185
+ ...full === undefined ? [] : [FULL]
186
+ ],
187
+ renditions: {
188
+ types: [contentType],
189
+ make,
190
+ ...options.keyExtension === true && { keyExtension: format }
191
+ }
192
+ };
193
+ }
194
+ export {
195
+ withImageRendition
196
+ };
197
+
198
+ //# debugId=E15A003F63AE7E7464756E2164756E21
199
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,11 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/image/peer.ts", "../src/image/rendition.ts"],
4
+ "sourcesContent": [
5
+ "/** The optional peer of `@softistx/alxia-media/image`, loaded when the subpath is imported. */\n\n/** Whether `error` says `specifier` itself is missing, not one of its imports. */\nconst notFound = (error: unknown, specifier: string) =>\n\terror instanceof Error &&\n\t'code' in error &&\n\t(error.code === 'MODULE_NOT_FOUND' ||\n\t\terror.code === 'ERR_MODULE_NOT_FOUND') &&\n\terror.message.includes(specifier);\n\n/**\n * What `load` gives, or, when the package it imports is not installed, an\n * error that says what to add. `load` must be `() => import('<literal>')`,\n * so a bundler follows it into the app's bundle.\n */\nexport async function importPeer<T>(\n\tspecifier: string,\n\tload: () => Promise<T>,\n): Promise<T> {\n\ttry {\n\t\treturn await load();\n\t} catch (error) {\n\t\tif (!notFound(error, specifier)) throw error;\n\t\tthrow new Error(\n\t\t\t`@softistx/alxia-media/image needs ${specifier}, an optional peer that is not installed: bun add ${specifier}`,\n\t\t\t{ cause: error },\n\t\t);\n\t}\n}\n\n/**\n * `@softistx/image`, imported once with the subpath: an app that uses\n * `@softistx/alxia-media/image` without it fails at startup, not at the first upload.\n * Importing `@softistx/alxia-media` alone never loads it.\n */\nexport const image: typeof import('@softistx/image') = await importPeer(\n\t'@softistx/image',\n\t() => import('@softistx/image'),\n);\n",
6
+ "/** `withImageRendition`: the sizes of an image kind, made at upload. */\n\nimport { MediaRefusal } from '../refusal';\nimport type { MediaRendition, MediaRenditions } from '../rendition';\nimport { image } from './peer';\n\n/** What `withImageRendition` takes. */\nexport interface ImageRenditionOptions {\n\t/**\n\t * The square sides to make, in pixels: unique whole numbers, 1 to 4096.\n\t * Each is a size named by its number: `sizes: [256, 64]` serves\n\t * `/<key>/256` and `/<key>/64`.\n\t */\n\treadonly sizes?: readonly number[];\n\t/**\n\t * The whole picture besides (or instead of) the squares: kept in full\n\t * with its aspect ratio, so that its longer side is at most `maxSide`\n\t * (1 to 8192) and never enlarged, a picture already within it keeping its\n\t * size. Every metadata is stripped and the EXIF rotation applied. Stored\n\t * under the size `full` (`GET /<key>/full`), in `format`. `sizes` may be\n\t * left out when `full` is set.\n\t */\n\treadonly full?: ImageFull;\n\t/** What each size is stored as: `'png'` (default) or `'webp'`. */\n\treadonly format?: 'png' | 'webp';\n\t/**\n\t * Ends each rendition's bucket key in the format's extension:\n\t * `<kind>/<key>/256.webp` instead of `<kind>/<key>/256` (`.png` for the\n\t * default format). For a bucket that already stores renditions that way.\n\t * The URL stays `/<key>/256` and the original's key is unchanged. Off by\n\t * default.\n\t */\n\treadonly keyExtension?: boolean;\n\t/**\n\t * How a square size is made: `'cover'` (default) keeps the centred square\n\t * of the short side; `'inside'` keeps the whole picture, its aspect ratio\n\t * kept, within a `size` x `size` box, and never enlarges it. A crop does not\n\t * apply to `'inside'` (a `TypeError` with both).\n\t */\n\treadonly fit?: 'cover' | 'inside';\n\t/**\n\t * Whether a picture smaller than a size is enlarged to it (default `true`).\n\t * `false` makes the size at the picture's own side instead (the square a\n\t * 20 px picture gives for 256 is 20 px), so a thumbnail is never blown up;\n\t * `minSide` still refuses a picture that is too small. Not needed with\n\t * `fit: 'inside'`, which never enlarges.\n\t */\n\treadonly enlarge?: boolean;\n\t/** The smallest side a picture may have: the largest of `sizes` by default (1 with none), so nothing is enlarged. */\n\treadonly minSide?: number;\n\t/** The most pixels a picture may claim: 25 000 000 by default. */\n\treadonly maxPixels?: number;\n\t/** The WebP quality of the resize, 1 to 100 (80 by default); a `TypeError` with `format: 'png'`. */\n\treadonly quality?: number;\n\t/** How many pictures are decoded at once, 1 to 64: 2 by default. */\n\treadonly concurrency?: number;\n\t/**\n\t * The square to keep, instead of the centred one of the short side, in\n\t * pixels of the picture as a person sees it (after EXIF rotation).\n\t *\n\t * - `'query'`: read from the upload's `?x=&y=&size=` (none of the three\n\t * means the centred default; a missing or non-numeric one is refused).\n\t * - a function of the request: `{ x, y, size }`, or `undefined` for the\n\t * default. Parse and validate the request yourself there.\n\t *\n\t * A crop that is not three whole numbers of 0 or more, or does not fit\n\t * the picture, is refused 400 `invalid_crop`. Not set (the default): the\n\t * centred square.\n\t */\n\treadonly crop?: 'query' | ((request: Request) => ImageCrop | undefined);\n}\n\n/** The whole picture, bounded: `fit: 'inside'` is the only fit. */\nexport type ImageFull = { fit: 'inside'; maxSide: number };\n\n/** A square to keep: its top-left corner and its side, in pixels. */\nexport type ImageCrop = { x: number; y: number; size: number };\n\n/** What `withImageRendition` gives: spread it into `defineMediaKind`. */\nexport interface ImageRendition {\n\treadonly sizes: readonly string[];\n\treadonly renditions: MediaRenditions;\n}\n\n/** The size name of the `full` rendition. */\nconst FULL = 'full';\n\nconst TYPES = { png: 'image/png', webp: 'image/webp' } as const;\n\nfunction formatOf(format: unknown): 'png' | 'webp' {\n\tif (format === undefined) return 'png';\n\tif (format === 'png' || format === 'webp') return format;\n\tthrow new TypeError(\n\t\t`withImageRendition(): format must be \"png\" or \"webp\", got ${JSON.stringify(format)}`,\n\t);\n}\n\n/** An `ImageError` as the refusal it answers; anything else as it is. */\nfunction refusalOf(error: unknown, min: number): unknown {\n\tif (!(error instanceof image.ImageError)) return error;\n\tconst { code, reason } = error;\n\tif (code === 'INVALID_CROP') {\n\t\treturn new MediaRefusal('invalid_crop', {}, { cause: error });\n\t}\n\t// A type it cannot decode (a GIF, a HEIC on Linux) is not one it takes;\n\t// the routes add the kind's `accept` to the refusal.\n\tif (code === 'UNSUPPORTED_TYPE') {\n\t\treturn new MediaRefusal('unsupported_type', {}, { cause: error });\n\t}\n\treturn new MediaRefusal(\n\t\t'unprocessable',\n\t\t{ reason, ...(reason === 'dimensions' && { min }) },\n\t\t{ cause: error },\n\t);\n}\n\n/** The crop a request asks for, per the `crop` option. */\nfunction cropOf(\n\tcrop: ImageRenditionOptions['crop'],\n\trequest: Request,\n): ImageCrop | undefined {\n\tif (crop === undefined) return undefined;\n\tif (crop === 'query') {\n\t\treturn image.cropFromQuery(new URL(request.url).searchParams);\n\t}\n\treturn crop(request);\n}\n\n/**\n * Square renditions of each picture an image kind takes, made once the\n * upload is stored and before it answers: the picture is decoded by\n * `@softistx/image` (its first bytes checked, EXIF rotation applied, the\n * centred square of its short side kept, every piece of metadata stripped)\n * and resized to each of `sizes`, then stored as PNG (or WebP). A picture\n * that cannot be read, or is smaller than `minSide`, is refused 422\n * `unprocessable` (`min` in the answer for a picture too small) and nothing\n * stays stored. The original stays as uploaded, unless the kind says\n * `keepOriginal: false`. With `crop`, the square is the one the request asks\n * for (`invalid_crop`, 400, when it does not fit).\n *\n * ```ts\n * const logos = defineMediaKind({\n * name: 'logos',\n * accept: ['image/png', 'image/jpeg', 'image/webp'],\n * maxBytes: 2 * 1024 * 1024,\n * authorizeWrite: () => true,\n * authorizeRead: () => true,\n * ...withImageRendition({ sizes: [256, 64] }),\n * });\n * // GET /media/logos/<key>/64: a 64 px PNG square\n * ```\n */\nexport function withImageRendition(\n\toptions: ImageRenditionOptions,\n): ImageRendition {\n\tconst format = formatOf(options.format);\n\tconst { crop } = options;\n\tif (crop !== undefined && crop !== 'query' && typeof crop !== 'function') {\n\t\tthrow new TypeError(\n\t\t\t`withImageRendition(): crop must be \"query\" or a function of the request, got ${JSON.stringify(crop)}`,\n\t\t);\n\t}\n\tif (format === 'png' && options.quality !== undefined) {\n\t\tthrow new TypeError(\n\t\t\t'withImageRendition(): quality is the WebP quality; a png is not lossy, drop it or use format: \"webp\"',\n\t\t);\n\t}\n\tconst { full } = options;\n\tconst fit = options.fit ?? 'cover';\n\tif (fit !== 'cover' && fit !== 'inside') {\n\t\tthrow new TypeError(\n\t\t\t`withImageRendition(): fit must be \"cover\" or \"inside\", got ${JSON.stringify(options.fit)}`,\n\t\t);\n\t}\n\tif (options.enlarge !== undefined && typeof options.enlarge !== 'boolean') {\n\t\tthrow new TypeError(\n\t\t\t`withImageRendition(): enlarge must be a boolean, got ${JSON.stringify(options.enlarge)}`,\n\t\t);\n\t}\n\tif (fit === 'inside' && crop !== undefined) {\n\t\tthrow new TypeError(\n\t\t\t'withImageRendition(): crop picks a square, which fit: \"inside\" does not make; drop one',\n\t\t);\n\t}\n\t// The squares `Bun.Image` resizes itself would enlarge a small picture;\n\t// these are rendered one by one at a size that never exceeds the picture.\n\tconst fitted = fit === 'inside' || options.enlarge === false;\n\tif (full !== undefined) {\n\t\tif (\n\t\t\tfull === null ||\n\t\t\ttypeof full !== 'object' ||\n\t\t\tfull.fit !== 'inside' ||\n\t\t\t!Number.isInteger(full.maxSide) ||\n\t\t\tfull.maxSide < 1 ||\n\t\t\tfull.maxSide > 8192\n\t\t) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`withImageRendition(): full must be { fit: \"inside\", maxSide } with maxSide a whole number from 1 to 8192, got ${JSON.stringify(full)}`,\n\t\t\t);\n\t\t}\n\t}\n\tconst squares = options.sizes ?? [];\n\tif (options.sizes === undefined && full === undefined) {\n\t\tthrow new TypeError(\n\t\t\t'withImageRendition(): give sizes (the square sides), full (the whole picture), or both',\n\t\t);\n\t}\n\tconst quality = format === 'webp' ? (options.quality ?? 80) : undefined;\n\tconst set =\n\t\t(squares.length === 0 && full !== undefined) || fitted\n\t\t\t? undefined\n\t\t\t: image.defineImageSet({\n\t\t\t\t\t// `@softistx/image` encodes PNG itself; `quality` is WebP's alone.\n\t\t\t\t\t...(format === 'png'\n\t\t\t\t\t\t? { format: 'png' as const }\n\t\t\t\t\t\t: { format: 'webp' as const, quality: quality ?? 80 }),\n\t\t\t\t\tsizes: squares,\n\t\t\t\t\t// The kind's `maxBytes` already bounded the upload.\n\t\t\t\t\tmaxBytes: Number.MAX_SAFE_INTEGER,\n\t\t\t\t\t...(options.minSide !== undefined && { minSide: options.minSide }),\n\t\t\t\t\t...(options.maxPixels !== undefined && {\n\t\t\t\t\t\tmaxPixels: options.maxPixels,\n\t\t\t\t\t}),\n\t\t\t\t\t...(options.concurrency !== undefined && {\n\t\t\t\t\t\tconcurrency: options.concurrency,\n\t\t\t\t\t}),\n\t\t\t\t});\n\tconst contentType = TYPES[format];\n\t// The smallest side `set` takes: what refuses a picture as too small.\n\tconst min = options.minSide ?? (set === undefined ? 1 : Math.max(...squares));\n\tconst limits = {\n\t\tmaxBytes: Number.MAX_SAFE_INTEGER,\n\t\t...(options.maxPixels !== undefined && { maxPixels: options.maxPixels }),\n\t};\n\tconst render = (\n\t\tbytes: Uint8Array,\n\t\twidth: number,\n\t\theight: number,\n\t\tcrop?: { x: number; y: number; width: number; height: number },\n\t): Promise<{\n\t\tbytes: Uint8Array;\n\t\twidth: number;\n\t\theight: number;\n\t\tsource: { width: number; height: number };\n\t}> =>\n\t\timage\n\t\t\t.renderImage(bytes, {\n\t\t\t\twidth,\n\t\t\t\theight,\n\t\t\t\t...(crop !== undefined && { crop }),\n\t\t\t\tformat,\n\t\t\t\t...(quality !== undefined && { quality }),\n\t\t\t\t...limits,\n\t\t\t})\n\t\t\t.catch((error: unknown) => {\n\t\t\t\tthrow refusalOf(error, min);\n\t\t\t});\n\tconst make = async ({\n\t\tbytes,\n\t\trequest,\n\t}: {\n\t\tbytes: Uint8Array;\n\t\trequest: Request;\n\t}) => {\n\t\tconst made: MediaRendition[] = [];\n\t\tlet source: { width: number; height: number } | undefined;\n\t\tif (set !== undefined) {\n\t\t\tconst box = cropOf(crop, request);\n\t\t\tconst done = await set\n\t\t\t\t.process(bytes, box === undefined ? undefined : { crop: box })\n\t\t\t\t.catch((error: unknown) => {\n\t\t\t\t\tthrow refusalOf(error, min);\n\t\t\t\t});\n\t\t\tsource = done.source;\n\t\t\tfor (const variant of done.variants) {\n\t\t\t\tmade.push({\n\t\t\t\t\tsize: String(variant.size),\n\t\t\t\t\tcontentType,\n\t\t\t\t\tbytes: variant.bytes,\n\t\t\t\t\twidth: variant.width,\n\t\t\t\t\theight: variant.height,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\tif (fitted) {\n\t\t\tconst probe = (await render(bytes, 1, 1)).source;\n\t\t\tsource = probe;\n\t\t\tconst short = Math.min(probe.width, probe.height);\n\t\t\tif (options.minSide !== undefined && short < options.minSide) {\n\t\t\t\tthrow new MediaRefusal('unprocessable', {\n\t\t\t\t\treason: 'dimensions',\n\t\t\t\t\tmin: options.minSide,\n\t\t\t\t});\n\t\t\t}\n\t\t\tconst box = cropOf(crop, request);\n\t\t\tfor (const side of squares) {\n\t\t\t\tlet one: Awaited<ReturnType<typeof render>>;\n\t\t\t\tif (fit === 'inside') {\n\t\t\t\t\tconst scale = Math.min(1, side / Math.max(probe.width, probe.height));\n\t\t\t\t\tone = await render(\n\t\t\t\t\t\tbytes,\n\t\t\t\t\t\tMath.max(1, Math.round(probe.width * scale)),\n\t\t\t\t\t\tMath.max(1, Math.round(probe.height * scale)),\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\t// A square: the requested one or the centred one of the short\n\t\t\t\t\t// side, made at `side` or its own size when that is smaller.\n\t\t\t\t\tconst square = box ?? {\n\t\t\t\t\t\tx: Math.floor((probe.width - short) / 2),\n\t\t\t\t\t\ty: Math.floor((probe.height - short) / 2),\n\t\t\t\t\t\tsize: short,\n\t\t\t\t\t};\n\t\t\t\t\tconst out = Math.min(side, square.size);\n\t\t\t\t\tone = await render(bytes, out, out, {\n\t\t\t\t\t\tx: square.x,\n\t\t\t\t\t\ty: square.y,\n\t\t\t\t\t\twidth: square.size,\n\t\t\t\t\t\theight: square.size,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tmade.push({\n\t\t\t\t\tsize: String(side),\n\t\t\t\t\tcontentType,\n\t\t\t\t\tbytes: one.bytes,\n\t\t\t\t\twidth: one.width,\n\t\t\t\t\theight: one.height,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\tif (full !== undefined) {\n\t\t\t// The upright size, from the squares' decode or a 1 px probe.\n\t\t\tsource ??= (await render(bytes, 1, 1)).source;\n\t\t\tconst scale = Math.min(\n\t\t\t\t1,\n\t\t\t\tfull.maxSide / Math.max(source.width, source.height),\n\t\t\t);\n\t\t\tconst one = await render(\n\t\t\t\tbytes,\n\t\t\t\tMath.max(1, Math.round(source.width * scale)),\n\t\t\t\tMath.max(1, Math.round(source.height * scale)),\n\t\t\t);\n\t\t\tmade.push({\n\t\t\t\tsize: FULL,\n\t\t\t\tcontentType,\n\t\t\t\tbytes: one.bytes,\n\t\t\t\twidth: one.width,\n\t\t\t\theight: one.height,\n\t\t\t});\n\t\t}\n\t\treturn made;\n\t};\n\treturn {\n\t\tsizes: [\n\t\t\t...(fitted ? squares.map(String) : (set?.sizes.map(String) ?? [])),\n\t\t\t...(full === undefined ? [] : [FULL]),\n\t\t],\n\t\trenditions: {\n\t\t\ttypes: [contentType],\n\t\t\tmake,\n\t\t\t...(options.keyExtension === true && { keyExtension: format }),\n\t\t},\n\t};\n}\n"
7
+ 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,YAAY;AAAA,MACX,OAAO,CAAC,WAAW;AAAA,MACnB;AAAA,SACI,QAAQ,iBAAiB,QAAQ,EAAE,cAAc,OAAO;AAAA,IAC7D;AAAA,EACD;AAAA;",
9
+ "debugId": "E15A003F63AE7E7464756E2164756E21",
10
+ "names": []
11
+ }
@@ -0,0 +1,14 @@
1
+ /** The optional peer of `@softistx/alxia-media/image`, loaded when the subpath is imported. */
2
+ /**
3
+ * What `load` gives, or, when the package it imports is not installed, an
4
+ * error that says what to add. `load` must be `() => import('<literal>')`,
5
+ * so a bundler follows it into the app's bundle.
6
+ */
7
+ export declare function importPeer<T>(specifier: string, load: () => Promise<T>): Promise<T>;
8
+ /**
9
+ * `@softistx/image`, imported once with the subpath: an app that uses
10
+ * `@softistx/alxia-media/image` without it fails at startup, not at the first upload.
11
+ * Importing `@softistx/alxia-media` alone never loads it.
12
+ */
13
+ export declare const image: typeof import('@softistx/image');
14
+ //# sourceMappingURL=peer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"peer.d.ts","sourceRoot":"","sources":["../../src/image/peer.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAU/F;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,CAAC,EACjC,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACpB,OAAO,CAAC,CAAC,CAAC,CAUZ;AAED;;;;GAIG;AACH,eAAO,MAAM,KAAK,EAAE,cAAc,iBAAiB,CAGlD,CAAC"}
@@ -0,0 +1,109 @@
1
+ /** `withImageRendition`: the sizes of an image kind, made at upload. */
2
+ import type { MediaRenditions } from '../rendition';
3
+ /** What `withImageRendition` takes. */
4
+ export interface ImageRenditionOptions {
5
+ /**
6
+ * The square sides to make, in pixels: unique whole numbers, 1 to 4096.
7
+ * Each is a size named by its number: `sizes: [256, 64]` serves
8
+ * `/<key>/256` and `/<key>/64`.
9
+ */
10
+ readonly sizes?: readonly number[];
11
+ /**
12
+ * The whole picture besides (or instead of) the squares: kept in full
13
+ * with its aspect ratio, so that its longer side is at most `maxSide`
14
+ * (1 to 8192) and never enlarged, a picture already within it keeping its
15
+ * size. Every metadata is stripped and the EXIF rotation applied. Stored
16
+ * under the size `full` (`GET /<key>/full`), in `format`. `sizes` may be
17
+ * left out when `full` is set.
18
+ */
19
+ readonly full?: ImageFull;
20
+ /** What each size is stored as: `'png'` (default) or `'webp'`. */
21
+ readonly format?: 'png' | 'webp';
22
+ /**
23
+ * Ends each rendition's bucket key in the format's extension:
24
+ * `<kind>/<key>/256.webp` instead of `<kind>/<key>/256` (`.png` for the
25
+ * default format). For a bucket that already stores renditions that way.
26
+ * The URL stays `/<key>/256` and the original's key is unchanged. Off by
27
+ * default.
28
+ */
29
+ readonly keyExtension?: boolean;
30
+ /**
31
+ * How a square size is made: `'cover'` (default) keeps the centred square
32
+ * of the short side; `'inside'` keeps the whole picture, its aspect ratio
33
+ * kept, within a `size` x `size` box, and never enlarges it. A crop does not
34
+ * apply to `'inside'` (a `TypeError` with both).
35
+ */
36
+ readonly fit?: 'cover' | 'inside';
37
+ /**
38
+ * Whether a picture smaller than a size is enlarged to it (default `true`).
39
+ * `false` makes the size at the picture's own side instead (the square a
40
+ * 20 px picture gives for 256 is 20 px), so a thumbnail is never blown up;
41
+ * `minSide` still refuses a picture that is too small. Not needed with
42
+ * `fit: 'inside'`, which never enlarges.
43
+ */
44
+ readonly enlarge?: boolean;
45
+ /** The smallest side a picture may have: the largest of `sizes` by default (1 with none), so nothing is enlarged. */
46
+ readonly minSide?: number;
47
+ /** The most pixels a picture may claim: 25 000 000 by default. */
48
+ readonly maxPixels?: number;
49
+ /** The WebP quality of the resize, 1 to 100 (80 by default); a `TypeError` with `format: 'png'`. */
50
+ readonly quality?: number;
51
+ /** How many pictures are decoded at once, 1 to 64: 2 by default. */
52
+ readonly concurrency?: number;
53
+ /**
54
+ * The square to keep, instead of the centred one of the short side, in
55
+ * pixels of the picture as a person sees it (after EXIF rotation).
56
+ *
57
+ * - `'query'`: read from the upload's `?x=&y=&size=` (none of the three
58
+ * means the centred default; a missing or non-numeric one is refused).
59
+ * - a function of the request: `{ x, y, size }`, or `undefined` for the
60
+ * default. Parse and validate the request yourself there.
61
+ *
62
+ * A crop that is not three whole numbers of 0 or more, or does not fit
63
+ * the picture, is refused 400 `invalid_crop`. Not set (the default): the
64
+ * centred square.
65
+ */
66
+ readonly crop?: 'query' | ((request: Request) => ImageCrop | undefined);
67
+ }
68
+ /** The whole picture, bounded: `fit: 'inside'` is the only fit. */
69
+ export type ImageFull = {
70
+ fit: 'inside';
71
+ maxSide: number;
72
+ };
73
+ /** A square to keep: its top-left corner and its side, in pixels. */
74
+ export type ImageCrop = {
75
+ x: number;
76
+ y: number;
77
+ size: number;
78
+ };
79
+ /** What `withImageRendition` gives: spread it into `defineMediaKind`. */
80
+ export interface ImageRendition {
81
+ readonly sizes: readonly string[];
82
+ readonly renditions: MediaRenditions;
83
+ }
84
+ /**
85
+ * Square renditions of each picture an image kind takes, made once the
86
+ * upload is stored and before it answers: the picture is decoded by
87
+ * `@softistx/image` (its first bytes checked, EXIF rotation applied, the
88
+ * centred square of its short side kept, every piece of metadata stripped)
89
+ * and resized to each of `sizes`, then stored as PNG (or WebP). A picture
90
+ * that cannot be read, or is smaller than `minSide`, is refused 422
91
+ * `unprocessable` (`min` in the answer for a picture too small) and nothing
92
+ * stays stored. The original stays as uploaded, unless the kind says
93
+ * `keepOriginal: false`. With `crop`, the square is the one the request asks
94
+ * for (`invalid_crop`, 400, when it does not fit).
95
+ *
96
+ * ```ts
97
+ * const logos = defineMediaKind({
98
+ * name: 'logos',
99
+ * accept: ['image/png', 'image/jpeg', 'image/webp'],
100
+ * maxBytes: 2 * 1024 * 1024,
101
+ * authorizeWrite: () => true,
102
+ * authorizeRead: () => true,
103
+ * ...withImageRendition({ sizes: [256, 64] }),
104
+ * });
105
+ * // GET /media/logos/<key>/64: a 64 px PNG square
106
+ * ```
107
+ */
108
+ export declare function withImageRendition(options: ImageRenditionOptions): ImageRendition;
109
+ //# sourceMappingURL=rendition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rendition.d.ts","sourceRoot":"","sources":["../../src/image/rendition.ts"],"names":[],"mappings":"AAAA,wEAAwE;AAGxE,OAAO,KAAK,EAAkB,eAAe,EAAE,MAAM,cAAc,CAAC;AAGpE,uCAAuC;AACvC,MAAM,WAAW,qBAAqB;IACrC;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC;;;;;;;OAOG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC;IAC1B,kEAAkE;IAClE,QAAQ,CAAC,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IACjC;;;;;;OAMG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC;IAChC;;;;;OAKG;IACH,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IAClC;;;;;;OAMG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,qHAAqH;IACrH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,kEAAkE;IAClE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,oGAAoG;IACpG,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,oEAAoE;IACpE,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,OAAO,EAAE,OAAO,KAAK,SAAS,GAAG,SAAS,CAAC,CAAC;CACxE;AAED,mEAAmE;AACnE,MAAM,MAAM,SAAS,GAAG;IAAE,GAAG,EAAE,QAAQ,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3D,qEAAqE;AACrE,MAAM,MAAM,SAAS,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/D,yEAAyE;AACzE,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,UAAU,EAAE,eAAe,CAAC;CACrC;AA8CD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,kBAAkB,CACjC,OAAO,EAAE,qBAAqB,GAC5B,cAAc,CAgNhB"}
@@ -0,0 +1,9 @@
1
+ export type { MediaBucket } from './bucket';
2
+ export { isMediaKey, isMediaKindName, type MediaKey, type MediaPlace, mediaObjectKey, mediaPlace, newMediaKey, } from './key';
3
+ export { defineMediaKind, type MediaContext, type MediaKind, type MediaKindInput, type MediaUploadIntent, type ThrottleDecision, } from './kind';
4
+ export { isMediaRefusal, MEDIA_REFUSAL_STATUS, type MediaDenial, MediaRefusal, type MediaRefusalCode, type MediaRefusalDetails, type MediaRefusalStatus, type MediaVerdict, } from './refusal';
5
+ export type { MediaFile, MediaRendition, MediaRenditions, MediaStoredRendition, } from './rendition';
6
+ export { type MediaRoutesOptions, mediaRoutes } from './routes';
7
+ export { MEDIA_SIGNATURES } from './sniff';
8
+ export type { MediaUpload, MediaUploaded } from './write';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EACN,UAAU,EACV,eAAe,EACf,KAAK,QAAQ,EACb,KAAK,UAAU,EACf,cAAc,EACd,UAAU,EACV,WAAW,GACX,MAAM,OAAO,CAAC;AACf,OAAO,EACN,eAAe,EACf,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,GACrB,MAAM,QAAQ,CAAC;AAChB,OAAO,EACN,cAAc,EACd,oBAAoB,EACpB,KAAK,WAAW,EAChB,YAAY,EACZ,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,YAAY,GACjB,MAAM,WAAW,CAAC;AACnB,YAAY,EACX,SAAS,EACT,cAAc,EACd,eAAe,EACf,oBAAoB,GACpB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,KAAK,kBAAkB,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC"}