@stati/core 1.27.2 → 1.29.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 (136) hide show
  1. package/README.md +6 -1
  2. package/dist/config/errors.d.ts +10 -0
  3. package/dist/config/errors.d.ts.map +1 -0
  4. package/dist/config/errors.js +10 -0
  5. package/dist/config/loader.d.ts.map +1 -1
  6. package/dist/config/loader.js +15 -2
  7. package/dist/constants.d.ts +26 -0
  8. package/dist/constants.d.ts.map +1 -1
  9. package/dist/constants.js +23 -0
  10. package/dist/core/build.d.ts.map +1 -1
  11. package/dist/core/build.js +201 -41
  12. package/dist/core/collections.d.ts +139 -0
  13. package/dist/core/collections.d.ts.map +1 -0
  14. package/dist/core/collections.js +342 -0
  15. package/dist/core/content.d.ts.map +1 -1
  16. package/dist/core/content.js +2 -1
  17. package/dist/core/dev.d.ts.map +1 -1
  18. package/dist/core/dev.js +11 -62
  19. package/dist/core/expand.d.ts +86 -0
  20. package/dist/core/expand.d.ts.map +1 -0
  21. package/dist/core/expand.js +484 -0
  22. package/dist/core/isg/builder.d.ts +27 -2
  23. package/dist/core/isg/builder.d.ts.map +1 -1
  24. package/dist/core/isg/builder.js +83 -11
  25. package/dist/core/isg/deps.d.ts +9 -0
  26. package/dist/core/isg/deps.d.ts.map +1 -1
  27. package/dist/core/isg/deps.js +30 -1
  28. package/dist/core/isg/hash.d.ts +14 -2
  29. package/dist/core/isg/hash.d.ts.map +1 -1
  30. package/dist/core/isg/hash.js +30 -2
  31. package/dist/core/isg/index.d.ts +4 -2
  32. package/dist/core/isg/index.d.ts.map +1 -1
  33. package/dist/core/isg/index.js +4 -2
  34. package/dist/core/isg/manifest.js +14 -0
  35. package/dist/core/isg/prune.d.ts +32 -0
  36. package/dist/core/isg/prune.d.ts.map +1 -0
  37. package/dist/core/isg/prune.js +113 -0
  38. package/dist/core/markdown.d.ts +10 -1
  39. package/dist/core/markdown.d.ts.map +1 -1
  40. package/dist/core/markdown.js +13 -3
  41. package/dist/core/navigation.d.ts +4 -2
  42. package/dist/core/navigation.d.ts.map +1 -1
  43. package/dist/core/navigation.js +17 -2
  44. package/dist/core/templates.d.ts +15 -1
  45. package/dist/core/templates.d.ts.map +1 -1
  46. package/dist/core/templates.js +121 -126
  47. package/dist/core/utils/fs.utils.d.ts +29 -1
  48. package/dist/core/utils/fs.utils.d.ts.map +1 -1
  49. package/dist/core/utils/fs.utils.js +74 -1
  50. package/dist/core/utils/index.d.ts +3 -3
  51. package/dist/core/utils/index.d.ts.map +1 -1
  52. package/dist/core/utils/index.js +3 -3
  53. package/dist/core/utils/paths.utils.d.ts +15 -0
  54. package/dist/core/utils/paths.utils.d.ts.map +1 -1
  55. package/dist/core/utils/paths.utils.js +20 -0
  56. package/dist/core/utils/template-discovery.utils.d.ts +25 -1
  57. package/dist/core/utils/template-discovery.utils.d.ts.map +1 -1
  58. package/dist/core/utils/template-discovery.utils.js +61 -11
  59. package/dist/images/config.d.ts +52 -0
  60. package/dist/images/config.d.ts.map +1 -0
  61. package/dist/images/config.js +200 -0
  62. package/dist/images/index.d.ts +15 -0
  63. package/dist/images/index.d.ts.map +1 -0
  64. package/dist/images/index.js +11 -0
  65. package/dist/images/manifest.d.ts +36 -0
  66. package/dist/images/manifest.d.ts.map +1 -0
  67. package/dist/images/manifest.js +69 -0
  68. package/dist/images/markdown-rule.d.ts +26 -0
  69. package/dist/images/markdown-rule.d.ts.map +1 -0
  70. package/dist/images/markdown-rule.js +60 -0
  71. package/dist/images/markup.d.ts +39 -0
  72. package/dist/images/markup.d.ts.map +1 -0
  73. package/dist/images/markup.js +72 -0
  74. package/dist/images/og.d.ts +52 -0
  75. package/dist/images/og.d.ts.map +1 -0
  76. package/dist/images/og.js +165 -0
  77. package/dist/images/plan.d.ts +101 -0
  78. package/dist/images/plan.d.ts.map +1 -0
  79. package/dist/images/plan.js +128 -0
  80. package/dist/images/provider.d.ts +35 -0
  81. package/dist/images/provider.d.ts.map +1 -0
  82. package/dist/images/provider.js +70 -0
  83. package/dist/images/resolve.d.ts +45 -0
  84. package/dist/images/resolve.d.ts.map +1 -0
  85. package/dist/images/resolve.js +51 -0
  86. package/dist/images/runtime.d.ts +258 -0
  87. package/dist/images/runtime.d.ts.map +1 -0
  88. package/dist/images/runtime.js +659 -0
  89. package/dist/images/sources.d.ts +47 -0
  90. package/dist/images/sources.d.ts.map +1 -0
  91. package/dist/images/sources.js +97 -0
  92. package/dist/images/utils/image-probe.utils.d.ts +30 -0
  93. package/dist/images/utils/image-probe.utils.d.ts.map +1 -0
  94. package/dist/images/utils/image-probe.utils.js +307 -0
  95. package/dist/images/utils/index.d.ts +7 -0
  96. package/dist/images/utils/index.d.ts.map +1 -0
  97. package/dist/images/utils/index.js +5 -0
  98. package/dist/index.d.ts +2 -1
  99. package/dist/index.d.ts.map +1 -1
  100. package/dist/metrics/noop.d.ts.map +1 -1
  101. package/dist/metrics/noop.js +3 -0
  102. package/dist/metrics/recorder.d.ts.map +1 -1
  103. package/dist/metrics/recorder.js +3 -0
  104. package/dist/metrics/types.d.ts +8 -0
  105. package/dist/metrics/types.d.ts.map +1 -1
  106. package/dist/rss/generator.d.ts.map +1 -1
  107. package/dist/rss/generator.js +5 -2
  108. package/dist/search/generator.d.ts +9 -0
  109. package/dist/search/generator.d.ts.map +1 -1
  110. package/dist/search/generator.js +20 -0
  111. package/dist/search/index.d.ts +1 -1
  112. package/dist/search/index.d.ts.map +1 -1
  113. package/dist/search/index.js +1 -1
  114. package/dist/seo/auto-inject.d.ts +3 -0
  115. package/dist/seo/auto-inject.d.ts.map +1 -1
  116. package/dist/seo/auto-inject.js +1 -0
  117. package/dist/seo/generator.d.ts +24 -0
  118. package/dist/seo/generator.d.ts.map +1 -1
  119. package/dist/seo/generator.js +65 -1
  120. package/dist/seo/index.d.ts +1 -1
  121. package/dist/seo/index.d.ts.map +1 -1
  122. package/dist/seo/index.js +1 -1
  123. package/dist/types/config.d.ts +60 -0
  124. package/dist/types/config.d.ts.map +1 -1
  125. package/dist/types/content.d.ts +150 -3
  126. package/dist/types/content.d.ts.map +1 -1
  127. package/dist/types/images.d.ts +185 -0
  128. package/dist/types/images.d.ts.map +1 -0
  129. package/dist/types/images.js +8 -0
  130. package/dist/types/index.d.ts +3 -2
  131. package/dist/types/index.d.ts.map +1 -1
  132. package/dist/types/isg.d.ts +19 -0
  133. package/dist/types/isg.d.ts.map +1 -1
  134. package/dist/types/seo.d.ts +9 -0
  135. package/dist/types/seo.d.ts.map +1 -1
  136. package/package.json +1 -1
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Finds and loads the optional `@stati/images` package.
3
+ * @module images/provider
4
+ */
5
+ import { createRequire } from 'node:module';
6
+ import { resolve as resolvePath } from 'node:path';
7
+ import { pathToFileURL } from 'node:url';
8
+ import { IMAGES_PACKAGE_NAME } from '../constants.js';
9
+ import { getStatiVersion } from '../core/utils/index.js';
10
+ /** Provider contract version this core supports. */
11
+ export const SUPPORTED_PROVIDER_API_VERSION = 1;
12
+ /**
13
+ * Resolves the package from the project, as markdown-it plugins are, so it is found under
14
+ * strict layouts such as pnpm's where core cannot see the project's dependencies.
15
+ * Resolution walks up from the project, which also covers workspaces.
16
+ *
17
+ * @returns The resolved entry file, or null when the package is not installed
18
+ */
19
+ export function resolveImagesPackage(cwd = process.cwd()) {
20
+ try {
21
+ const require = createRequire(pathToFileURL(resolvePath(cwd, 'package.json')));
22
+ return require.resolve(IMAGES_PACKAGE_NAME);
23
+ }
24
+ catch {
25
+ return null;
26
+ }
27
+ }
28
+ /**
29
+ * The error shown when a feature is on but the package is missing.
30
+ */
31
+ export function missingPackageMessage(features) {
32
+ const names = features.map((feature) => `images.${feature}`).join(' and ');
33
+ const verb = features.length > 1 ? 'require' : 'requires';
34
+ return `${names} ${verb} ${IMAGES_PACKAGE_NAME}. Run: npm i -D ${IMAGES_PACKAGE_NAME}`;
35
+ }
36
+ /**
37
+ * Checks that the package is installed and, when `load` is set, creates its provider.
38
+ *
39
+ * @param options.features - The features that are on; they decide the error message
40
+ * @param options.load - Whether to import the package; false only checks it is installed
41
+ * @returns The provider, or null when `load` is false
42
+ * @throws {Error} When the package is missing, fails to load, or is incompatible
43
+ */
44
+ export async function loadImageProvider(options) {
45
+ const entry = resolveImagesPackage(options.cwd);
46
+ if (!entry) {
47
+ throw new Error(missingPackageMessage(options.features));
48
+ }
49
+ if (!options.load) {
50
+ return null;
51
+ }
52
+ let provider;
53
+ try {
54
+ const module = (await import(pathToFileURL(entry).href));
55
+ if (typeof module.createImageProvider !== 'function') {
56
+ throw new Error(`${IMAGES_PACKAGE_NAME} does not export createImageProvider()`);
57
+ }
58
+ provider = await module.createImageProvider();
59
+ }
60
+ catch (error) {
61
+ throw new Error(`Failed to load ${IMAGES_PACKAGE_NAME}: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
62
+ }
63
+ if (provider?.apiVersion !== SUPPORTED_PROVIDER_API_VERSION) {
64
+ throw new Error(`${IMAGES_PACKAGE_NAME} ${provider?.version ?? ''} is not compatible with @stati/core ${getStatiVersion()}. Update both packages.`.replace(/\s+/g, ' '));
65
+ }
66
+ if (options.features.includes('og') && typeof provider.renderOgImage !== 'function') {
67
+ throw new Error(`images.og needs a newer ${IMAGES_PACKAGE_NAME} (${provider.version}). Update the package.`);
68
+ }
69
+ return provider;
70
+ }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Maps an image `src` as written in Markdown or a template to a file on disk.
3
+ * @module images/resolve
4
+ */
5
+ /**
6
+ * Where an image's `src` points.
7
+ * - `skip`: leave the image alone (remote, SVG, unsupported, opted out or outside the site);
8
+ * `src` is the value to emit, with any `?raw` suffix removed.
9
+ * - `static`: a file under the static directory, served at its own URL.
10
+ * - `colocated`: a file under the source directory, next to the page that uses it.
11
+ */
12
+ export type ResolvedImageSource = {
13
+ kind: 'skip';
14
+ src: string;
15
+ } | {
16
+ kind: 'static';
17
+ src: string;
18
+ filePath: string;
19
+ } | {
20
+ kind: 'colocated';
21
+ src: string;
22
+ filePath: string;
23
+ };
24
+ /**
25
+ * Paths needed to resolve an image for one page.
26
+ */
27
+ export interface ImageResolveContext {
28
+ /** Absolute path of the Markdown file being rendered */
29
+ pageSourcePath: string;
30
+ /** Absolute source directory */
31
+ srcDir: string;
32
+ /** Absolute static assets directory */
33
+ staticDir: string;
34
+ }
35
+ /**
36
+ * Resolves an image `src`.
37
+ * Root-relative paths (`/images/hero.jpg`) resolve from the static directory; relative
38
+ * paths (`./hero.jpg`) resolve next to the page's Markdown file.
39
+ *
40
+ * @param rawSrc - The `src` as authored
41
+ * @param context - The page and site directories
42
+ * @returns Where the image lives, or `skip` when it should be left as authored
43
+ */
44
+ export declare function resolveImageSource(rawSrc: string, context: ImageResolveContext): ResolvedImageSource;
45
+ //# sourceMappingURL=resolve.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/images/resolve.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAWH;;;;;;GAMG;AACH,MAAM,MAAM,mBAAmB,GAC3B;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAC7B;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GACjD;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,wDAAwD;IACxD,cAAc,EAAE,MAAM,CAAC;IACvB,gCAAgC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,uCAAuC;IACvC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,mBAAmB,GAC3B,mBAAmB,CAmCrB"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Maps an image `src` as written in Markdown or a template to a file on disk.
3
+ * @module images/resolve
4
+ */
5
+ import { dirname, extname, join, resolve } from 'node:path';
6
+ import { isPathWithinDirectory } from '../core/utils/index.js';
7
+ /** Extensions Stati reads dimensions from. SVG and anything else are left as authored. */
8
+ const SUPPORTED_EXTENSIONS = new Set(['.png', '.jpg', '.jpeg', '.gif', '.webp', '.avif']);
9
+ /** Suffix that opts a single image out of processing. */
10
+ const RAW_SUFFIX = '?raw';
11
+ /**
12
+ * Resolves an image `src`.
13
+ * Root-relative paths (`/images/hero.jpg`) resolve from the static directory; relative
14
+ * paths (`./hero.jpg`) resolve next to the page's Markdown file.
15
+ *
16
+ * @param rawSrc - The `src` as authored
17
+ * @param context - The page and site directories
18
+ * @returns Where the image lives, or `skip` when it should be left as authored
19
+ */
20
+ export function resolveImageSource(rawSrc, context) {
21
+ const src = rawSrc.trim();
22
+ if (!src)
23
+ return { kind: 'skip', src: rawSrc };
24
+ if (src.endsWith(RAW_SUFFIX)) {
25
+ return { kind: 'skip', src: src.slice(0, -RAW_SUFFIX.length) };
26
+ }
27
+ // Remote URLs, protocol-relative URLs and data URIs
28
+ if (/^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(src)) {
29
+ return { kind: 'skip', src };
30
+ }
31
+ let path;
32
+ try {
33
+ path = decodeURIComponent(src.replace(/[?#].*$/, ''));
34
+ }
35
+ catch {
36
+ return { kind: 'skip', src };
37
+ }
38
+ if (!SUPPORTED_EXTENSIONS.has(extname(path).toLowerCase())) {
39
+ return { kind: 'skip', src };
40
+ }
41
+ if (path.startsWith('/')) {
42
+ const filePath = join(context.staticDir, path);
43
+ return isPathWithinDirectory(context.staticDir, filePath)
44
+ ? { kind: 'static', src, filePath }
45
+ : { kind: 'skip', src };
46
+ }
47
+ const filePath = resolve(dirname(context.pageSourcePath), path);
48
+ return isPathWithinDirectory(context.srcDir, filePath)
49
+ ? { kind: 'colocated', src, filePath }
50
+ : { kind: 'skip', src };
51
+ }
@@ -0,0 +1,258 @@
1
+ /**
2
+ * Per-build image pipeline: renders image markup while pages render, runs the jobs the
3
+ * written pages need, recovers from failed jobs and prunes outputs no page uses.
4
+ * @module images/runtime
5
+ */
6
+ import type { Eta } from 'eta';
7
+ import type Token from 'markdown-it/lib/token.mjs';
8
+ import type { CacheManifest, GeneratedOgImage, ImageProvider, Logger, OgFont, PageModel, StatiConfig } from '../types/index.js';
9
+ import type { RenderedAssets } from '../core/isg/builder.js';
10
+ import { type ResolvedImagesConfig, type ResolvedOgConfig, type ResolvedResponsiveConfig } from './config.js';
11
+ import { type SourceInfo } from './sources.js';
12
+ import { type CopyPlan, type VariantPlan } from './plan.js';
13
+ /**
14
+ * Options for `stati.image()` in templates.
15
+ */
16
+ export interface StatiImageOptions {
17
+ /** Alternative text; use an empty string for decorative images */
18
+ alt?: string;
19
+ /** `sizes` attribute for responsive images */
20
+ sizes?: string;
21
+ /** Load eagerly with high fetch priority, for the main image above the fold */
22
+ priority?: boolean;
23
+ /** `class` attribute */
24
+ class?: string;
25
+ /** `title` attribute */
26
+ title?: string;
27
+ }
28
+ /** A unit of work that writes one or more files under the output directory. */
29
+ interface JobSpec {
30
+ key: string;
31
+ /** Output files, relative to the output directory */
32
+ outputs: string[];
33
+ /** Source or page, for messages */
34
+ label: string;
35
+ /** Absolute path of the source image, for jobs that copy or encode one */
36
+ sourcePath?: string;
37
+ run: () => Promise<void>;
38
+ }
39
+ /** One processed image (or Open Graph card) in a page. */
40
+ interface ImageUse {
41
+ jobKey: string;
42
+ outputs: string[];
43
+ /** A URL the written page contains when it actually uses this image */
44
+ marker: string;
45
+ /** Markup core emitted, swapped for `fallbackMarkup` if the job fails */
46
+ markup?: string;
47
+ fallbackMarkup?: string;
48
+ /** Copy the fallback markup needs, for co-located sources */
49
+ fallbackCopy?: JobSpec;
50
+ /** Set for Open Graph cards: their tags are removed if the job fails */
51
+ ogImage?: GeneratedOgImage;
52
+ }
53
+ /** Fonts and template for Open Graph cards, loaded once per build. */
54
+ interface OgState {
55
+ fonts: OgFont[];
56
+ fontsHash: string;
57
+ defaultTemplate: string | undefined;
58
+ }
59
+ /**
60
+ * Failures found while settling jobs.
61
+ */
62
+ export interface SettleResult {
63
+ /** Pages rewritten to fall back to plain images */
64
+ patchedPages: number;
65
+ /** Failed jobs, for reporting */
66
+ failures: Array<{
67
+ label: string;
68
+ message: string;
69
+ og: boolean;
70
+ }>;
71
+ }
72
+ /**
73
+ * Checks that og:image URLs will be absolute and public.
74
+ * @throws {Error} When `site.baseUrl` is not an absolute http(s) URL on a public host
75
+ */
76
+ export declare function validateOgBaseUrl(baseUrl: string): void;
77
+ /**
78
+ * Image state for one page while it renders.
79
+ */
80
+ export declare class PageImages {
81
+ private readonly runtime;
82
+ readonly page: PageModel;
83
+ /** Source files whose content affects the page */
84
+ readonly assetDeps: Set<string>;
85
+ /** Processed images and cards, filtered against the written HTML when the page commits */
86
+ readonly uses: ImageUse[];
87
+ /** The Markdown image that `eagerFirst` loads eagerly, chosen by `renderMarkdown()` */
88
+ eagerToken: Token | undefined;
89
+ private readonly context;
90
+ constructor(runtime: ImageRuntime, page: PageModel);
91
+ /**
92
+ * Renders a Markdown image token.
93
+ *
94
+ * @returns The markup, or the `src` to give markdown-it's default renderer when the image
95
+ * is left as authored
96
+ */
97
+ renderMarkdownImage(token: Token, alt: string): {
98
+ html: string;
99
+ } | {
100
+ src: string;
101
+ };
102
+ /**
103
+ * Implements `stati.image(src, options)` for templates. Synchronous, because templates
104
+ * print its result directly.
105
+ */
106
+ renderHelperImage(src: unknown, options?: StatiImageOptions): string;
107
+ private renderImage;
108
+ /**
109
+ * Whether this page gets a generated Open Graph image.
110
+ */
111
+ wantsOg(): boolean;
112
+ /**
113
+ * Size of the page's Open Graph image, exposed to the template as `stati.og`.
114
+ */
115
+ ogSize(): {
116
+ width: number;
117
+ height: number;
118
+ } | undefined;
119
+ /**
120
+ * Renders this page's Open Graph template and registers the card.
121
+ *
122
+ * @param context - Template context: the layout's, with an empty body and `stati.og`
123
+ * @param eta - The template engine
124
+ * @returns The generated image, or null when the page gets none
125
+ */
126
+ renderOg(context: object, eta: Eta): Promise<GeneratedOgImage | null>;
127
+ }
128
+ /**
129
+ * Options for {@link ImageRuntime.create}.
130
+ */
131
+ export interface ImageRuntimeOptions {
132
+ /** Absolute output directory */
133
+ outDir: string;
134
+ /** Absolute cache directory (`.stati`) */
135
+ cacheDir: string;
136
+ logger: Logger;
137
+ /** True for dev server builds */
138
+ development: boolean;
139
+ }
140
+ /**
141
+ * The image pipeline for one build.
142
+ */
143
+ export declare class ImageRuntime {
144
+ readonly settings: ResolvedImagesConfig;
145
+ readonly provider: ImageProvider | null;
146
+ readonly ogState: OgState | null;
147
+ private readonly manifest;
148
+ private readonly existing;
149
+ readonly srcDir: string;
150
+ readonly staticDir: string;
151
+ readonly outDir: string;
152
+ private readonly cacheDir;
153
+ readonly baseUrl: string;
154
+ readonly logger: Logger;
155
+ readonly development: boolean;
156
+ /** Responsive options in effect for this build; null when off or skipped in dev */
157
+ readonly responsive: ResolvedResponsiveConfig | null;
158
+ /** Open Graph options in effect for this build; null when off or skipped in dev */
159
+ readonly og: ResolvedOgConfig | null;
160
+ /** Counters for the build summary and metrics */
161
+ readonly stats: {
162
+ generated: number;
163
+ cached: number;
164
+ failed: number;
165
+ };
166
+ private readonly specs;
167
+ /** Source file of each generated image registered this build, by URL path */
168
+ private readonly generatedSources;
169
+ private readonly jobs;
170
+ private readonly failures;
171
+ private readonly records;
172
+ private readonly touched;
173
+ private readonly warned;
174
+ /** Whether the images manifest changed and needs saving */
175
+ private dirty;
176
+ private constructor();
177
+ /**
178
+ * Creates the pipeline for a build.
179
+ *
180
+ * @returns The runtime, or null when images are turned off with `images: false`
181
+ * @throws {ConfigValidationError} When the `images` block is invalid
182
+ * @throws {Error} When a feature needs `@stati/images` and it is missing or incompatible,
183
+ * or when an Open Graph font or `site.baseUrl` is unusable
184
+ */
185
+ static create(config: StatiConfig, options: ImageRuntimeOptions): Promise<ImageRuntime | null>;
186
+ /**
187
+ * Settings that change generated HTML, added to every page's render-inputs hash.
188
+ */
189
+ fingerprint(): Record<string, unknown>;
190
+ /**
191
+ * Creates the image state for a page about to render.
192
+ */
193
+ createPageContext(page: PageModel): PageImages;
194
+ /**
195
+ * Whether every generated file a cached page references still exists.
196
+ */
197
+ outputsExist(images: readonly string[] | undefined): boolean;
198
+ /**
199
+ * Records a written page and starts the jobs for the images its HTML actually contains.
200
+ *
201
+ * @param pageImages - The page's image state
202
+ * @param html - The final HTML of the page
203
+ * @param info - Output path and cache key of the page
204
+ * @returns The files to record on the page's cache entry
205
+ */
206
+ commitPage(pageImages: PageImages, html: string, info: {
207
+ outputPath: string;
208
+ cacheKey: string;
209
+ }): RenderedAssets;
210
+ /**
211
+ * Waits for every job, then rewrites pages whose images failed so they show plain images,
212
+ * and marks those pages stale so the next build retries.
213
+ *
214
+ * @param cacheManifest - The ISG manifest, updated in place
215
+ */
216
+ settle(cacheManifest: CacheManifest): Promise<SettleResult>;
217
+ /**
218
+ * Saves the images manifest.
219
+ */
220
+ save(): Promise<void>;
221
+ /**
222
+ * Deletes generated files no page of this build references. Only files recorded in the
223
+ * images manifest are ever deleted.
224
+ *
225
+ * @param liveImages - Generated files referenced by this build's pages
226
+ * @param liveSources - Source files referenced by this build's pages
227
+ * @returns Number of files deleted
228
+ */
229
+ prune(liveImages: ReadonlySet<string>, liveSources: ReadonlySet<string>): Promise<number>;
230
+ /**
231
+ * Inspects a source image and remembers it for the manifest.
232
+ */
233
+ inspect(filePath: string): SourceInfo | null;
234
+ /**
235
+ * Logs a warning once per build.
236
+ */
237
+ warnOnce(key: string, message: string): void;
238
+ /**
239
+ * Registers a job. It only runs once a written page references its outputs.
240
+ */
241
+ registerJob(spec: JobSpec): void;
242
+ /**
243
+ * The source file of an image this build generates, by its URL path, such as
244
+ * `/_img/hero-1a2b3c4d-960.webp`.
245
+ */
246
+ generatedSourceFor(path: string): string | undefined;
247
+ /**
248
+ * Job that copies a co-located image to its hashed URL.
249
+ */
250
+ copyJob(plan: CopyPlan, sourcePath: string): JobSpec;
251
+ /**
252
+ * Job that encodes the responsive variants of an image.
253
+ */
254
+ variantJob(plan: VariantPlan, sourcePath: string): JobSpec;
255
+ private startJob;
256
+ }
257
+ export {};
258
+ //# sourceMappingURL=runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/images/runtime.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC/B,OAAO,KAAK,KAAK,MAAM,2BAA2B,CAAC;AAqBnD,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAChB,aAAa,EACb,MAAM,EACN,MAAM,EAEN,SAAS,EACT,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAGL,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,wBAAwB,EAC9B,MAAM,aAAa,CAAC;AAGrB,OAAO,EAIL,KAAK,UAAU,EAChB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAA0B,KAAK,QAAQ,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAkBpF;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,kEAAkE;IAClE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,8CAA8C;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+EAA+E;IAC/E,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,wBAAwB;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wBAAwB;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,+EAA+E;AAC/E,UAAU,OAAO;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,qDAAqD;IACrD,OAAO,EAAE,MAAM,EAAE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