@johnhenry/sitefile 0.0.0-stage → 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/LICENSE +21 -0
  3. package/README.md +475 -2
  4. package/lib/src/archive-writers.d.ts +31 -0
  5. package/lib/src/archive-writers.js +197 -0
  6. package/lib/src/attest.d.ts +126 -0
  7. package/lib/src/attest.js +220 -0
  8. package/lib/src/bake.d.ts +74 -0
  9. package/lib/src/bake.js +372 -0
  10. package/lib/src/base-image.d.ts +76 -0
  11. package/lib/src/base-image.js +138 -0
  12. package/lib/src/build-args.d.ts +26 -0
  13. package/lib/src/build-args.js +164 -0
  14. package/lib/src/cache-limit.d.ts +54 -0
  15. package/lib/src/cache-limit.js +239 -0
  16. package/lib/src/casefold-data.d.ts +2 -0
  17. package/lib/src/casefold-data.js +217 -0
  18. package/lib/src/cbor.d.ts +39 -0
  19. package/lib/src/cbor.js +174 -0
  20. package/lib/src/checklinks.d.ts +42 -0
  21. package/lib/src/checklinks.js +118 -0
  22. package/lib/src/cli/bake.d.ts +2 -0
  23. package/lib/src/cli/bake.js +179 -0
  24. package/lib/src/cli/build-image.d.ts +21 -0
  25. package/lib/src/cli/build-image.js +42 -0
  26. package/lib/src/cli/cache.d.ts +8 -0
  27. package/lib/src/cli/cache.js +109 -0
  28. package/lib/src/cli/common.d.ts +29 -0
  29. package/lib/src/cli/common.js +100 -0
  30. package/lib/src/cli/git-context.d.ts +18 -0
  31. package/lib/src/cli/git-context.js +48 -0
  32. package/lib/src/cli/images.d.ts +6 -0
  33. package/lib/src/cli/images.js +285 -0
  34. package/lib/src/cli/index.d.ts +10 -0
  35. package/lib/src/cli/index.js +95 -0
  36. package/lib/src/cli/outdated.d.ts +5 -0
  37. package/lib/src/cli/outdated.js +94 -0
  38. package/lib/src/cli/registry.d.ts +2 -0
  39. package/lib/src/cli/registry.js +122 -0
  40. package/lib/src/cli/serve-worker.d.ts +2 -0
  41. package/lib/src/cli/serve-worker.js +42 -0
  42. package/lib/src/cli/servers.d.ts +15 -0
  43. package/lib/src/cli/servers.js +451 -0
  44. package/lib/src/cli/vendor.d.ts +2 -0
  45. package/lib/src/cli/vendor.js +92 -0
  46. package/lib/src/cli/watch.d.ts +26 -0
  47. package/lib/src/cli/watch.js +81 -0
  48. package/lib/src/cli.d.ts +12 -0
  49. package/lib/src/cli.js +486 -0
  50. package/lib/src/csv.d.ts +27 -0
  51. package/lib/src/csv.js +117 -0
  52. package/lib/src/deflate.d.ts +76 -0
  53. package/lib/src/deflate.js +604 -0
  54. package/lib/src/digest.d.ts +3 -0
  55. package/lib/src/digest.js +7 -0
  56. package/lib/src/errors.d.ts +34 -0
  57. package/lib/src/errors.js +20 -0
  58. package/lib/src/executor.d.ts +386 -0
  59. package/lib/src/executor.js +2193 -0
  60. package/lib/src/explain.d.ts +64 -0
  61. package/lib/src/explain.js +445 -0
  62. package/lib/src/export-formats.d.ts +16 -0
  63. package/lib/src/export-formats.js +52 -0
  64. package/lib/src/exporter.d.ts +103 -0
  65. package/lib/src/exporter.js +676 -0
  66. package/lib/src/fingerprint.d.ts +40 -0
  67. package/lib/src/fingerprint.js +168 -0
  68. package/lib/src/frontmatter.d.ts +22 -0
  69. package/lib/src/frontmatter.js +45 -0
  70. package/lib/src/index.d.ts +12 -0
  71. package/lib/src/index.js +12 -0
  72. package/lib/src/language/ast.d.ts +353 -0
  73. package/lib/src/language/ast.js +57 -0
  74. package/lib/src/language/parser.d.ts +3 -0
  75. package/lib/src/language/parser.js +612 -0
  76. package/lib/src/language/scanner.d.ts +110 -0
  77. package/lib/src/language/scanner.js +449 -0
  78. package/lib/src/language/validate.d.ts +13 -0
  79. package/lib/src/language/validate.js +367 -0
  80. package/lib/src/links.d.ts +79 -0
  81. package/lib/src/links.js +583 -0
  82. package/lib/src/lint.d.ts +10 -0
  83. package/lib/src/lint.js +223 -0
  84. package/lib/src/markdown.d.ts +29 -0
  85. package/lib/src/markdown.js +612 -0
  86. package/lib/src/media.d.ts +82 -0
  87. package/lib/src/media.js +650 -0
  88. package/lib/src/memo.d.ts +57 -0
  89. package/lib/src/memo.js +93 -0
  90. package/lib/src/oci.d.ts +178 -0
  91. package/lib/src/oci.js +380 -0
  92. package/lib/src/outdated.d.ts +46 -0
  93. package/lib/src/outdated.js +195 -0
  94. package/lib/src/pages.d.ts +10 -0
  95. package/lib/src/pages.js +54 -0
  96. package/lib/src/paths.d.ts +39 -0
  97. package/lib/src/paths.js +101 -0
  98. package/lib/src/planner.d.ts +297 -0
  99. package/lib/src/planner.js +410 -0
  100. package/lib/src/plugins/cache.d.ts +70 -0
  101. package/lib/src/plugins/cache.js +226 -0
  102. package/lib/src/plugins/exec.d.ts +51 -0
  103. package/lib/src/plugins/exec.js +144 -0
  104. package/lib/src/plugins/host.d.ts +75 -0
  105. package/lib/src/plugins/host.js +277 -0
  106. package/lib/src/plugins/wasm.d.ts +23 -0
  107. package/lib/src/plugins/wasm.js +249 -0
  108. package/lib/src/profile.d.ts +42 -0
  109. package/lib/src/profile.js +68 -0
  110. package/lib/src/ref.d.ts +40 -0
  111. package/lib/src/ref.js +79 -0
  112. package/lib/src/registry-auth.d.ts +32 -0
  113. package/lib/src/registry-auth.js +151 -0
  114. package/lib/src/registry-cache.d.ts +71 -0
  115. package/lib/src/registry-cache.js +333 -0
  116. package/lib/src/registry-ops.d.ts +51 -0
  117. package/lib/src/registry-ops.js +248 -0
  118. package/lib/src/registry.d.ts +109 -0
  119. package/lib/src/registry.js +505 -0
  120. package/lib/src/render.d.ts +134 -0
  121. package/lib/src/render.js +576 -0
  122. package/lib/src/resources/archive.d.ts +11 -0
  123. package/lib/src/resources/archive.js +306 -0
  124. package/lib/src/resources/bundle-data.d.ts +16 -0
  125. package/lib/src/resources/bundle-data.js +50 -0
  126. package/lib/src/resources/convert.d.ts +12 -0
  127. package/lib/src/resources/convert.js +63 -0
  128. package/lib/src/resources/documents.d.ts +35 -0
  129. package/lib/src/resources/documents.js +122 -0
  130. package/lib/src/resources/git.d.ts +103 -0
  131. package/lib/src/resources/git.js +720 -0
  132. package/lib/src/resources/https.d.ts +40 -0
  133. package/lib/src/resources/https.js +256 -0
  134. package/lib/src/resources/ignore.d.ts +33 -0
  135. package/lib/src/resources/ignore.js +119 -0
  136. package/lib/src/resources/local.d.ts +64 -0
  137. package/lib/src/resources/local.js +248 -0
  138. package/lib/src/resources/lockfile.d.ts +52 -0
  139. package/lib/src/resources/lockfile.js +172 -0
  140. package/lib/src/resources/netpolicy.d.ts +6 -0
  141. package/lib/src/resources/netpolicy.js +82 -0
  142. package/lib/src/resources/types.d.ts +63 -0
  143. package/lib/src/resources/types.js +13 -0
  144. package/lib/src/resources/vendor.d.ts +94 -0
  145. package/lib/src/resources/vendor.js +296 -0
  146. package/lib/src/resources/wbn-reader.d.ts +44 -0
  147. package/lib/src/resources/wbn-reader.js +302 -0
  148. package/lib/src/schema.d.ts +25 -0
  149. package/lib/src/schema.js +169 -0
  150. package/lib/src/secrets.d.ts +21 -0
  151. package/lib/src/secrets.js +103 -0
  152. package/lib/src/serve-rules.d.ts +29 -0
  153. package/lib/src/serve-rules.js +122 -0
  154. package/lib/src/server.d.ts +45 -0
  155. package/lib/src/server.js +246 -0
  156. package/lib/src/servers.d.ts +71 -0
  157. package/lib/src/servers.js +139 -0
  158. package/lib/src/site.d.ts +60 -0
  159. package/lib/src/site.js +169 -0
  160. package/lib/src/store.d.ts +151 -0
  161. package/lib/src/store.js +596 -0
  162. package/lib/src/tree.d.ts +50 -0
  163. package/lib/src/tree.js +134 -0
  164. package/lib/src/values.d.ts +7 -0
  165. package/lib/src/values.js +37 -0
  166. package/lib/src/vendor.d.ts +19 -0
  167. package/lib/src/vendor.js +145 -0
  168. package/lib/src/watch.d.ts +44 -0
  169. package/lib/src/watch.js +137 -0
  170. package/lib/src/wbn.d.ts +5 -0
  171. package/lib/src/wbn.js +147 -0
  172. package/lib/src/yaml.d.ts +34 -0
  173. package/lib/src/yaml.js +562 -0
  174. package/package.json +58 -4
@@ -0,0 +1,57 @@
1
+ import { ExportState } from './exporter.js';
2
+ /**
3
+ * Incremental rebuilds (watch mode): results of build steps, memoized in memory by
4
+ * content digests of everything each step reads, like Bazel's action cache.
5
+ *
6
+ * Keys are SHA-256 digests of a step's identity (the planned operation with its
7
+ * Sitefile position, the ARG/LET values) and the digests of its inputs (file and
8
+ * tree digests, import keys, earlier steps' keys). A step whose key is unchanged
9
+ * returns its previous result without running; anything else runs as in a clean
10
+ * build. Failures are never memoized. Every entry holds the warnings the step
11
+ * printed, which a hit prints again, so an incremental build prints and writes
12
+ * exactly what a clean build does.
13
+ *
14
+ * The memo lives only in memory, for one `build --watch` / `serve --watch`
15
+ * session (see docs/ARCHITECTURE.md, "Incremental rebuilds"). Entries not used by
16
+ * the latest build (or by the last successful one, while builds fail) are dropped.
17
+ */
18
+ export interface MemoStats {
19
+ /** Steps whose result was reused (operations, FOR elements, imports, documents). */
20
+ hits: number;
21
+ /** Steps that ran (and were memoized when they succeeded). */
22
+ misses: number;
23
+ }
24
+ export declare class BuildMemo {
25
+ private readonly entries;
26
+ private gen;
27
+ private goodGen;
28
+ stats: MemoStats;
29
+ /** What the session's last directory export wrote, so the next one writes only the changes. */
30
+ readonly exportState: ExportState;
31
+ /** Start a build: new statistics, a new generation. */
32
+ begin(): void;
33
+ /** End a build: keep what it used (and, after a failure, what the last good build used). */
34
+ finish(ok: boolean): void;
35
+ get size(): number;
36
+ /** Mark an entry and everything inside it as used by this build. */
37
+ private touch;
38
+ /** The value memoized under `key`; `parent` (an entry being computed) records it as a child. */
39
+ get<T>(key: string, parent?: string[]): T | undefined;
40
+ set(key: string, value: unknown, children?: readonly string[]): void;
41
+ /** `compute(children)` unless `key` is memoized (a throw is not memoized). */
42
+ memoize<T>(key: string, compute: (children: string[]) => T, parent?: string[]): T;
43
+ /** Per-document memo for Markdown and data collections (one entry per file digest, path and label), children of `parent`. */
44
+ documents(parent: string[]): DocumentMemo;
45
+ }
46
+ export type DocumentMemo = <T>(parts: readonly string[], compute: () => T) => T;
47
+ /** Set to a non-empty value other than `0` to make watch mode rebuild everything every time. */
48
+ export declare const NO_INCREMENTAL_ENV = "SITEFILE_NO_INCREMENTAL";
49
+ /** The memo for a watch session: undefined when $SITEFILE_NO_INCREMENTAL turns it off. */
50
+ export declare function watchMemo(): BuildMemo | undefined;
51
+ /** A memo key: the digest of its parts (strings joined unambiguously). */
52
+ export declare function memoKey(...parts: readonly string[]): string;
53
+ /**
54
+ * An unambiguous text form of a JSON-like value (imported data, ARG/LET values, plans).
55
+ * Unlike JSON.stringify alone it tells `undefined`, NaN and ±Infinity apart from null.
56
+ */
57
+ export declare function valueKey(v: unknown): string;
@@ -0,0 +1,93 @@
1
+ import { sha256 } from './digest.js';
2
+ import { ExportState } from './exporter.js';
3
+ export class BuildMemo {
4
+ entries = new Map();
5
+ gen = 0;
6
+ goodGen = 0;
7
+ stats = { hits: 0, misses: 0 };
8
+ /** What the session's last directory export wrote, so the next one writes only the changes. */
9
+ exportState = new ExportState();
10
+ /** Start a build: new statistics, a new generation. */
11
+ begin() {
12
+ this.gen++;
13
+ this.stats = { hits: 0, misses: 0 };
14
+ }
15
+ /** End a build: keep what it used (and, after a failure, what the last good build used). */
16
+ finish(ok) {
17
+ if (ok)
18
+ this.goodGen = this.gen;
19
+ const keep = Math.min(this.gen, this.goodGen);
20
+ for (const [k, e] of this.entries)
21
+ if (e.gen < keep)
22
+ this.entries.delete(k);
23
+ }
24
+ get size() {
25
+ return this.entries.size;
26
+ }
27
+ /** Mark an entry and everything inside it as used by this build. */
28
+ touch(e) {
29
+ if (e.gen === this.gen)
30
+ return;
31
+ e.gen = this.gen;
32
+ for (const c of e.children) {
33
+ const child = this.entries.get(c);
34
+ if (child)
35
+ this.touch(child);
36
+ }
37
+ }
38
+ /** The value memoized under `key`; `parent` (an entry being computed) records it as a child. */
39
+ get(key, parent) {
40
+ parent?.push(key);
41
+ const e = this.entries.get(key);
42
+ if (!e)
43
+ return undefined;
44
+ this.touch(e);
45
+ this.stats.hits++;
46
+ return e.value;
47
+ }
48
+ set(key, value, children = []) {
49
+ this.stats.misses++;
50
+ this.entries.set(key, { gen: this.gen, value, children });
51
+ }
52
+ /** `compute(children)` unless `key` is memoized (a throw is not memoized). */
53
+ memoize(key, compute, parent) {
54
+ const hit = this.get(key, parent);
55
+ if (hit !== undefined)
56
+ return hit;
57
+ const children = [];
58
+ const v = compute(children);
59
+ this.set(key, v, children);
60
+ return v;
61
+ }
62
+ /** Per-document memo for Markdown and data collections (one entry per file digest, path and label), children of `parent`. */
63
+ documents(parent) {
64
+ return (parts, compute) => this.memoize(memoKey('document', ...parts), compute, parent);
65
+ }
66
+ }
67
+ /** Set to a non-empty value other than `0` to make watch mode rebuild everything every time. */
68
+ export const NO_INCREMENTAL_ENV = 'SITEFILE_NO_INCREMENTAL';
69
+ /** The memo for a watch session: undefined when $SITEFILE_NO_INCREMENTAL turns it off. */
70
+ export function watchMemo() {
71
+ const v = process.env[NO_INCREMENTAL_ENV];
72
+ return v !== undefined && v !== '' && v !== '0' ? undefined : new BuildMemo();
73
+ }
74
+ /** A memo key: the digest of its parts (strings joined unambiguously). */
75
+ export function memoKey(...parts) {
76
+ return sha256(parts.map((p) => `${p.length}:${p}`).join(''));
77
+ }
78
+ /**
79
+ * An unambiguous text form of a JSON-like value (imported data, ARG/LET values, plans).
80
+ * Unlike JSON.stringify alone it tells `undefined`, NaN and ±Infinity apart from null.
81
+ */
82
+ export function valueKey(v) {
83
+ return (JSON.stringify(v, (_k, x) => {
84
+ if (x === undefined)
85
+ return { '\u0000': 'undefined' };
86
+ if (typeof x === 'number' && !Number.isFinite(x))
87
+ return { '\u0000': String(x) };
88
+ if (x instanceof Map)
89
+ return { '\u0000': 'map', entries: [...x] };
90
+ return x;
91
+ }) ?? 'undefined');
92
+ }
93
+ //# sourceMappingURL=memo.js.map
@@ -0,0 +1,178 @@
1
+ import type { Referrer } from './attest.js';
2
+ import type { OciCompression } from './language/ast.js';
3
+ import { Tree } from './tree.js';
4
+ /**
5
+ * OCI image-spec v1.1 writer and reader for Sitefile images.
6
+ *
7
+ * A Sitefile image has exactly one layer: a deterministic tar of the site's files placed under a
8
+ * root directory (default /srv/www), gzip-compressed. It carries files only: it has no entrypoint
9
+ * and is not runnable by itself (use it with `COPY --from=` in a Dockerfile). Everything that is
10
+ * hashed (config, manifest, index) is canonical JSON, so the same tree and options always give the
11
+ * same manifest digest.
12
+ *
13
+ * Layout (the on-disk image store is this layout; `save`/`EXPORT AS oci` write it standalone):
14
+ * oci-layout {"imageLayoutVersion":"1.0.0"}
15
+ * index.json image index; entries carry org.opencontainers.image.ref.name
16
+ * blobs/sha256/<hex> manifest, config and layer blobs
17
+ */
18
+ export declare const DEFAULT_OCI_ROOT = "/srv/www";
19
+ export declare const MEDIA: {
20
+ readonly manifest: 'application/vnd.oci.image.manifest.v1+json';
21
+ readonly config: 'application/vnd.oci.image.config.v1+json';
22
+ readonly layer: 'application/vnd.oci.image.layer.v1.tar+gzip';
23
+ /** Uncompressed layer (`EXPORT ... COMPRESSION none`): the blob is the tar itself, digest = diff_id. */
24
+ readonly layerTar: 'application/vnd.oci.image.layer.v1.tar';
25
+ readonly index: 'application/vnd.oci.image.index.v1+json';
26
+ readonly dockerManifest: 'application/vnd.docker.distribution.manifest.v2+json';
27
+ readonly dockerList: 'application/vnd.docker.distribution.manifest.list.v2+json';
28
+ readonly dockerConfig: 'application/vnd.docker.container.image.v1+json';
29
+ readonly dockerLayer: 'application/vnd.docker.image.rootfs.diff.tar.gzip';
30
+ };
31
+ export declare const ANN_BASE_NAME = "org.opencontainers.image.base.name";
32
+ export declare const ANN_BASE_DIGEST = "org.opencontainers.image.base.digest";
33
+ export declare const ANN: {
34
+ readonly refName: 'org.opencontainers.image.ref.name';
35
+ readonly title: 'org.opencontainers.image.title';
36
+ readonly source: 'org.opencontainers.image.source';
37
+ readonly revision: 'org.opencontainers.image.revision';
38
+ readonly root: 'dev.sitefile.root';
39
+ readonly files: 'dev.sitefile.files';
40
+ readonly size: 'dev.sitefile.size';
41
+ readonly stored: 'dev.sitefile.created';
42
+ };
43
+ export interface OciOptions {
44
+ /** Where the files live inside the layer. Default /srv/www. */
45
+ readonly root?: string | undefined;
46
+ /** `os/arch`, default linux/amd64. Metadata only: the image holds no executables. */
47
+ readonly platform?: string | undefined;
48
+ /** `SOURCE_DATE_EPOCH` seconds; default the fixed epoch, so digests are reproducible. */
49
+ readonly epoch?: number | undefined;
50
+ readonly title?: string | undefined;
51
+ readonly source?: string | undefined;
52
+ readonly revision?: string | undefined;
53
+ /** Extra config labels (`--label key=value`); they override the defaults above. */
54
+ readonly labels?: Readonly<Record<string, string>> | undefined;
55
+ /**
56
+ * Build on top of this image (`EXPORT ... AS oci BASE <image>`): its layers come first, its config
57
+ * (Entrypoint, Cmd, Env, ExposedPorts, WorkingDir, ...) is kept, and the site layer is appended.
58
+ * The base's blobs must already be in the store (see base-image.ts).
59
+ */
60
+ readonly base?: BaseImage | undefined;
61
+ /** Site layer encoding: gzip (default, `tar+gzip`) or none (plain `tar`). Base layers are kept as they are. */
62
+ readonly compression?: OciCompression | undefined;
63
+ }
64
+ /** A resolved base image: one platform manifest, its config and layers. */
65
+ export interface BaseImage {
66
+ /** Canonical reference as written (`docker.io/library/nginx:alpine`), without any digest. */
67
+ readonly name: string;
68
+ /** Digest of the platform manifest the layers come from (recorded in the image). */
69
+ readonly manifestDigest: string;
70
+ readonly layers: readonly Descriptor[];
71
+ /** The base's parsed config JSON. */
72
+ readonly config: Readonly<Record<string, unknown>>;
73
+ }
74
+ export interface Descriptor {
75
+ readonly mediaType: string;
76
+ readonly digest: string;
77
+ readonly size: number;
78
+ readonly annotations?: Readonly<Record<string, string>>;
79
+ }
80
+ export interface OciImage {
81
+ readonly manifestBytes: Uint8Array;
82
+ readonly manifestDigest: string;
83
+ readonly configBytes: Uint8Array;
84
+ readonly configDigest: string;
85
+ readonly layerBytes: Uint8Array;
86
+ readonly layerDigest: string;
87
+ /** sha256 of the uncompressed tar. */
88
+ readonly diffId: string;
89
+ readonly root: string;
90
+ /** Layers below the site layer (from BASE), already normalized to OCI media types. Empty otherwise. */
91
+ readonly baseLayers: readonly Descriptor[];
92
+ }
93
+ /** JSON with sorted keys and no whitespace. */
94
+ export declare function canonicalJson(v: unknown): string;
95
+ export declare function parsePlatform(p: string | undefined): {
96
+ os: string;
97
+ arch: string;
98
+ };
99
+ /** Validate an in-image root path (absolute, no `..`); returns the normalized form. */
100
+ export declare function normalizeOciRoot(raw: string | undefined): string;
101
+ /** Build the single-layer image for `tree` (the site's files, rooted at `/`). */
102
+ export declare function buildOciImage(tree: Tree, options?: OciOptions): OciImage;
103
+ export interface IndexEntry {
104
+ readonly digest: string;
105
+ readonly size: number;
106
+ readonly refName?: string | undefined;
107
+ /** When the image was first stored locally (store bookkeeping; not part of any digest). */
108
+ readonly stored?: string | undefined;
109
+ /** Extra annotations written verbatim (exports only). */
110
+ readonly extra?: Readonly<Record<string, string>> | undefined;
111
+ /** OCI 1.1 artifactType (attestation entries of exports only). */
112
+ readonly artifactType?: string | undefined;
113
+ }
114
+ export declare const ANN_CONTAINERD_NAME = "io.containerd.image.name";
115
+ /**
116
+ * Index annotations for an exported image named `refName` (`blog:1`, `localhost:5000/blog:1`), in the
117
+ * convention `docker save` uses so Docker's containerd store finds the image by name after `docker load`:
118
+ * `io.containerd.image.name` is the full normalized reference and `org.opencontainers.image.ref.name` the tag.
119
+ * Single-component names live in docker.io/library/, other names without a registry host in docker.io/.
120
+ */
121
+ export declare function exportNameAnnotations(refName: string): Record<string, string>;
122
+ export declare function encodeIndex(entries: readonly IndexEntry[]): Uint8Array;
123
+ export declare const OCI_LAYOUT_BYTES: NodeJS.NonSharedUint8Array;
124
+ export declare function decodeIndex(bytes: Uint8Array): IndexEntry[];
125
+ export declare function blobPathOf(digest: string): string;
126
+ /**
127
+ * A standalone OCI image layout holding one image, as a Tree (write it as a directory or tar it).
128
+ * `referrers` (attestations, `build --provenance/--sbom`) are listed in index.json after the image,
129
+ * without a name, and their blobs are included.
130
+ */
131
+ export declare function layoutTree(img: Pick<OciImage, 'manifestBytes' | 'manifestDigest' | 'configBytes' | 'configDigest' | 'layerBytes' | 'layerDigest'>, refName?: string,
132
+ /** Blobs of the layers below the site layer (digest -> bytes), for images built on a BASE. */
133
+ baseBlobs?: ReadonlyMap<string, Uint8Array>, referrers?: readonly Referrer[]): Tree;
134
+ /** Deterministic tar of {@link layoutTree}: an "OCI archive" (`.oci.tar`). */
135
+ export declare function ociArchive(img: Parameters<typeof layoutTree>[0], refName: string | undefined, epoch: number | undefined, baseBlobs?: ReadonlyMap<string, Uint8Array>, referrers?: readonly Referrer[]): Uint8Array;
136
+ export interface ParsedManifest {
137
+ readonly config: Descriptor;
138
+ readonly layers: readonly Descriptor[];
139
+ readonly annotations: Readonly<Record<string, string>>;
140
+ }
141
+ export declare function parseManifest(bytes: Uint8Array): ParsedManifest;
142
+ export interface ParsedConfig {
143
+ readonly os: string;
144
+ readonly architecture: string;
145
+ readonly created: string;
146
+ readonly labels: Readonly<Record<string, string>>;
147
+ readonly diffIds: readonly string[];
148
+ }
149
+ export declare function parseConfig(bytes: Uint8Array): ParsedConfig;
150
+ /**
151
+ * Index of the layer holding the site's files: the only layer, or the last one of an image that
152
+ * carries the `dev.sitefile.root` label (built with BASE). -1 when the image is not a Sitefile image.
153
+ */
154
+ export declare function siteLayerIndex(m: ParsedManifest, cfg: ParsedConfig): number;
155
+ /**
156
+ * Decode a site image's files, verifying the layer digest and diff_id.
157
+ * `layerBytes` are the compressed blob bytes. Returns the tree under the image's root (its
158
+ * `dev.sitefile.root` label, else `/`), or under `rootOverride` (`FROM image … AT <dir>`).
159
+ */
160
+ export declare function extractImageFiles(m: ParsedManifest, cfg: ParsedConfig, layerBytes: Uint8Array, origin: string, rootOverride?: string): Promise<Tree>;
161
+ /**
162
+ * Label values for an image built from `contextDir`: the title (directory name),
163
+ * extra `--label`s, and, only with `--git-labels`, source/revision from a git
164
+ * checkout. Git labels are opt-in because they make the image ID change with
165
+ * every commit even when the files don't, and because finding the checkout
166
+ * reads outside the build context.
167
+ */
168
+ export declare function imageMeta(contextDir: string, opts?: {
169
+ readonly git?: boolean;
170
+ readonly labels?: Readonly<Record<string, string>>;
171
+ }): Promise<Pick<OciOptions, 'title' | 'source' | 'revision' | 'labels'>>;
172
+ /** Parse `--label key=value` flags. */
173
+ export declare function parseLabels(flags: readonly string[]): Record<string, string>;
174
+ /** Best-effort `org.opencontainers.image.{source,revision}` from a git checkout (never runs git; credentials in URLs are dropped). */
175
+ export declare function gitInfo(contextDir: string): Promise<{
176
+ source?: string;
177
+ revision?: string;
178
+ }>;