image-renditions 0.1.0 → 0.2.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.
@@ -1,64 +0,0 @@
1
- import { l as SourcePolicy, r as Recipe, s as RenditionOptions } from "./recipe-Je9DxqO1.mjs";
2
- //#region src/catalog.d.ts
3
- /** Named transformation in a catalog. */
4
- interface PresetDefinition extends RenditionOptions {
5
- /** Pixel densities to render, as multipliers of `width` and `height`; defaults to `[1]`. */
6
- densities?: readonly number[];
7
- }
8
- /** Shared configuration of renditions, imported by both the client and the server. */
9
- interface CatalogDefinition<Name extends string = string> {
10
- /** Path the rendition handler is mounted at, `/_renditions` by default. */
11
- basePath?: string;
12
- /** Bumping it gives every variant a new hash, so every rendition is generated again. */
13
- pipelineVersion?: number;
14
- /** Options of every preset; a preset overrides them field by field. */
15
- defaults?: PresetDefinition;
16
- /** How special kinds of sources are rendered. */
17
- sources?: Partial<SourcePolicy>;
18
- presets: Record<Name, PresetDefinition>;
19
- }
20
- /** One density of a preset, which is a separate recipe with its own hash. */
21
- interface RenditionVariant {
22
- readonly preset: string;
23
- readonly density: number;
24
- /** Readable URL label, such as `avatar` or `avatar@2x`. */
25
- readonly label: string;
26
- readonly recipe: Recipe;
27
- readonly hash: string;
28
- }
29
- /** Source a rendition is made from. */
30
- interface RenditionTarget {
31
- /** Application-defined space of the path, such as a tenant; omitted when the application has one space. */
32
- scope?: string;
33
- /** Logical source path inside the scope. */
34
- path: string;
35
- }
36
- /** Validated catalog with its variants and URL builders. */
37
- interface Catalog<Name extends string = string> {
38
- readonly basePath: string;
39
- readonly presets: readonly Name[];
40
- /** Variants of a preset ordered by density. */
41
- variants(preset: Name): readonly RenditionVariant[];
42
- /**
43
- * Variant of a preset at a density, `1` by default.
44
- *
45
- * @throws {RangeError} When the preset does not declare the density.
46
- */
47
- variant(preset: Name, density?: number): RenditionVariant;
48
- /** Variant with a recipe hash, if the catalog has one. */
49
- findVariant(hash: string): RenditionVariant | undefined;
50
- /** Root-relative URL of a rendition. */
51
- url(preset: Name, target: RenditionTarget, density?: number): string;
52
- /** `srcset` attribute value listing every density of a preset. */
53
- srcset(preset: Name, target: RenditionTarget): string;
54
- }
55
- /**
56
- * Validates a catalog and computes the recipe and hash of every preset density.
57
- *
58
- * Preset names are only labels: renaming a preset keeps its hashes and thus its stored renditions.
59
- *
60
- * @throws {RangeError} When the catalog is invalid.
61
- */
62
- declare function defineCatalog<const Name extends string>(definition: CatalogDefinition<Name>): Catalog<Name>;
63
- //#endregion
64
- export { RenditionVariant as a, RenditionTarget as i, CatalogDefinition as n, defineCatalog as o, PresetDefinition as r, Catalog as t };
@@ -1,14 +0,0 @@
1
- import { r as Recipe } from "./recipe-Je9DxqO1.mjs";
2
- import { t as EncodedImage } from "./stores-DFDRMZcC.mjs";
3
- //#region src/server/processor.d.ts
4
- /** Renders a source image according to a recipe. */
5
- interface Processor {
6
- /**
7
- * Renders the source.
8
- *
9
- * Rejects with a `RenditionError` of reason `unsupported-source` when the source cannot be decoded.
10
- */
11
- process(source: Uint8Array, recipe: Recipe): Promise<EncodedImage>;
12
- }
13
- //#endregion
14
- export { Processor as t };