@johnhenry/sitefile 0.0.0-stage → 0.0.1
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.
- package/CHANGELOG.md +152 -0
- package/LICENSE +21 -0
- package/README.md +513 -2
- package/lib/src/archive-writers.d.ts +31 -0
- package/lib/src/archive-writers.js +197 -0
- package/lib/src/attest.d.ts +126 -0
- package/lib/src/attest.js +220 -0
- package/lib/src/bake.d.ts +74 -0
- package/lib/src/bake.js +372 -0
- package/lib/src/base-image.d.ts +76 -0
- package/lib/src/base-image.js +138 -0
- package/lib/src/build-args.d.ts +26 -0
- package/lib/src/build-args.js +164 -0
- package/lib/src/cache-limit.d.ts +54 -0
- package/lib/src/cache-limit.js +239 -0
- package/lib/src/casefold-data.d.ts +2 -0
- package/lib/src/casefold-data.js +217 -0
- package/lib/src/cbor.d.ts +39 -0
- package/lib/src/cbor.js +174 -0
- package/lib/src/checklinks.d.ts +42 -0
- package/lib/src/checklinks.js +120 -0
- package/lib/src/cli/bake.d.ts +2 -0
- package/lib/src/cli/bake.js +179 -0
- package/lib/src/cli/build-image.d.ts +21 -0
- package/lib/src/cli/build-image.js +42 -0
- package/lib/src/cli/cache.d.ts +8 -0
- package/lib/src/cli/cache.js +119 -0
- package/lib/src/cli/common.d.ts +29 -0
- package/lib/src/cli/common.js +100 -0
- package/lib/src/cli/git-context.d.ts +18 -0
- package/lib/src/cli/git-context.js +48 -0
- package/lib/src/cli/images.d.ts +6 -0
- package/lib/src/cli/images.js +285 -0
- package/lib/src/cli/index.d.ts +10 -0
- package/lib/src/cli/index.js +95 -0
- package/lib/src/cli/network.d.ts +34 -0
- package/lib/src/cli/network.js +56 -0
- package/lib/src/cli/outdated.d.ts +5 -0
- package/lib/src/cli/outdated.js +99 -0
- package/lib/src/cli/registry.d.ts +2 -0
- package/lib/src/cli/registry.js +127 -0
- package/lib/src/cli/serve-worker.d.ts +2 -0
- package/lib/src/cli/serve-worker.js +42 -0
- package/lib/src/cli/servers.d.ts +15 -0
- package/lib/src/cli/servers.js +467 -0
- package/lib/src/cli/vendor.d.ts +2 -0
- package/lib/src/cli/vendor.js +97 -0
- package/lib/src/cli/watch.d.ts +26 -0
- package/lib/src/cli/watch.js +81 -0
- package/lib/src/cli.d.ts +12 -0
- package/lib/src/cli.js +522 -0
- package/lib/src/csv.d.ts +27 -0
- package/lib/src/csv.js +117 -0
- package/lib/src/deflate.d.ts +76 -0
- package/lib/src/deflate.js +604 -0
- package/lib/src/digest.d.ts +3 -0
- package/lib/src/digest.js +7 -0
- package/lib/src/errors.d.ts +56 -0
- package/lib/src/errors.js +29 -0
- package/lib/src/executor.d.ts +393 -0
- package/lib/src/executor.js +2201 -0
- package/lib/src/explain.d.ts +64 -0
- package/lib/src/explain.js +445 -0
- package/lib/src/export-formats.d.ts +23 -0
- package/lib/src/export-formats.js +63 -0
- package/lib/src/exporter.d.ts +103 -0
- package/lib/src/exporter.js +676 -0
- package/lib/src/fingerprint.d.ts +40 -0
- package/lib/src/fingerprint.js +168 -0
- package/lib/src/frontmatter.d.ts +22 -0
- package/lib/src/frontmatter.js +45 -0
- package/lib/src/index.d.ts +13 -0
- package/lib/src/index.js +13 -0
- package/lib/src/language/ast.d.ts +360 -0
- package/lib/src/language/ast.js +57 -0
- package/lib/src/language/parser.d.ts +3 -0
- package/lib/src/language/parser.js +612 -0
- package/lib/src/language/scanner.d.ts +110 -0
- package/lib/src/language/scanner.js +449 -0
- package/lib/src/language/validate.d.ts +13 -0
- package/lib/src/language/validate.js +367 -0
- package/lib/src/links.d.ts +79 -0
- package/lib/src/links.js +583 -0
- package/lib/src/lint.d.ts +10 -0
- package/lib/src/lint.js +223 -0
- package/lib/src/markdown.d.ts +29 -0
- package/lib/src/markdown.js +612 -0
- package/lib/src/media.d.ts +82 -0
- package/lib/src/media.js +650 -0
- package/lib/src/memo.d.ts +57 -0
- package/lib/src/memo.js +93 -0
- package/lib/src/oci.d.ts +178 -0
- package/lib/src/oci.js +380 -0
- package/lib/src/outdated.d.ts +46 -0
- package/lib/src/outdated.js +195 -0
- package/lib/src/pages.d.ts +10 -0
- package/lib/src/pages.js +54 -0
- package/lib/src/paths.d.ts +39 -0
- package/lib/src/paths.js +101 -0
- package/lib/src/planner.d.ts +297 -0
- package/lib/src/planner.js +410 -0
- package/lib/src/plugins/cache.d.ts +96 -0
- package/lib/src/plugins/cache.js +325 -0
- package/lib/src/plugins/exec.d.ts +51 -0
- package/lib/src/plugins/exec.js +144 -0
- package/lib/src/plugins/host.d.ts +75 -0
- package/lib/src/plugins/host.js +277 -0
- package/lib/src/plugins/wasm.d.ts +23 -0
- package/lib/src/plugins/wasm.js +249 -0
- package/lib/src/profile.d.ts +42 -0
- package/lib/src/profile.js +68 -0
- package/lib/src/ref.d.ts +40 -0
- package/lib/src/ref.js +79 -0
- package/lib/src/registry-auth.d.ts +32 -0
- package/lib/src/registry-auth.js +151 -0
- package/lib/src/registry-cache.d.ts +71 -0
- package/lib/src/registry-cache.js +333 -0
- package/lib/src/registry-ops.d.ts +51 -0
- package/lib/src/registry-ops.js +248 -0
- package/lib/src/registry.d.ts +115 -0
- package/lib/src/registry.js +524 -0
- package/lib/src/render.d.ts +134 -0
- package/lib/src/render.js +576 -0
- package/lib/src/resources/archive.d.ts +11 -0
- package/lib/src/resources/archive.js +306 -0
- package/lib/src/resources/bundle-data.d.ts +16 -0
- package/lib/src/resources/bundle-data.js +50 -0
- package/lib/src/resources/convert.d.ts +12 -0
- package/lib/src/resources/convert.js +63 -0
- package/lib/src/resources/documents.d.ts +35 -0
- package/lib/src/resources/documents.js +122 -0
- package/lib/src/resources/git.d.ts +103 -0
- package/lib/src/resources/git.js +720 -0
- package/lib/src/resources/https.d.ts +74 -0
- package/lib/src/resources/https.js +413 -0
- package/lib/src/resources/ignore.d.ts +33 -0
- package/lib/src/resources/ignore.js +119 -0
- package/lib/src/resources/local.d.ts +64 -0
- package/lib/src/resources/local.js +248 -0
- package/lib/src/resources/lockfile.d.ts +52 -0
- package/lib/src/resources/lockfile.js +172 -0
- package/lib/src/resources/netpolicy.d.ts +6 -0
- package/lib/src/resources/netpolicy.js +82 -0
- package/lib/src/resources/network.d.ts +70 -0
- package/lib/src/resources/network.js +304 -0
- package/lib/src/resources/types.d.ts +69 -0
- package/lib/src/resources/types.js +13 -0
- package/lib/src/resources/vendor.d.ts +94 -0
- package/lib/src/resources/vendor.js +296 -0
- package/lib/src/resources/wbn-reader.d.ts +44 -0
- package/lib/src/resources/wbn-reader.js +302 -0
- package/lib/src/schema.d.ts +25 -0
- package/lib/src/schema.js +169 -0
- package/lib/src/secrets.d.ts +21 -0
- package/lib/src/secrets.js +103 -0
- package/lib/src/serve-rules.d.ts +29 -0
- package/lib/src/serve-rules.js +123 -0
- package/lib/src/server.d.ts +45 -0
- package/lib/src/server.js +246 -0
- package/lib/src/servers.d.ts +85 -0
- package/lib/src/servers.js +225 -0
- package/lib/src/site.d.ts +60 -0
- package/lib/src/site.js +169 -0
- package/lib/src/store.d.ts +151 -0
- package/lib/src/store.js +596 -0
- package/lib/src/tree.d.ts +50 -0
- package/lib/src/tree.js +134 -0
- package/lib/src/values.d.ts +7 -0
- package/lib/src/values.js +37 -0
- package/lib/src/vendor.d.ts +19 -0
- package/lib/src/vendor.js +145 -0
- package/lib/src/watch.d.ts +44 -0
- package/lib/src/watch.js +137 -0
- package/lib/src/wbn.d.ts +26 -0
- package/lib/src/wbn.js +241 -0
- package/lib/src/yaml.d.ts +34 -0
- package/lib/src/yaml.js +562 -0
- package/package.json +59 -4
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { SitefileError, type SourceSpan } from './errors.js';
|
|
2
|
+
import type { EscapeMode } from './language/ast.js';
|
|
3
|
+
import type { Scalar } from './values.js';
|
|
4
|
+
import { type TemplateTree } from './media.js';
|
|
5
|
+
/** A string of a `${file …}` expression: text and `${name.key}` references. */
|
|
6
|
+
export type HelperText = ReadonlyArray<{
|
|
7
|
+
readonly kind: 'text';
|
|
8
|
+
readonly value: string;
|
|
9
|
+
} | {
|
|
10
|
+
readonly kind: 'ref';
|
|
11
|
+
readonly name: string;
|
|
12
|
+
readonly path: readonly string[];
|
|
13
|
+
readonly span: SourceSpan;
|
|
14
|
+
}>;
|
|
15
|
+
/**
|
|
16
|
+
* Resolves a template variable to a scalar. Supplied by the executor, which
|
|
17
|
+
* throws E_UNDEFINED / E_TYPE itself for unknown names or non-scalar values.
|
|
18
|
+
*/
|
|
19
|
+
export type TemplateLookup = (name: string, path: readonly string[], span: SourceSpan) => Scalar;
|
|
20
|
+
/**
|
|
21
|
+
* Resolves a value for `${#each}` and `${#if}`. `loose` (used by `#if`) means a
|
|
22
|
+
* missing name or key yields `undefined` instead of an error.
|
|
23
|
+
*/
|
|
24
|
+
export type TemplateValueLookup = (name: string, path: readonly string[], span: SourceSpan, loose: boolean) => unknown;
|
|
25
|
+
/** A parsed RENDER template: text, substitutions and blocks. */
|
|
26
|
+
export type TemplateNode = {
|
|
27
|
+
readonly kind: 'text';
|
|
28
|
+
readonly value: string;
|
|
29
|
+
}
|
|
30
|
+
/** `raw` is set (true) only for `${x|raw}`, which is never escaped. */
|
|
31
|
+
| {
|
|
32
|
+
readonly kind: 'var';
|
|
33
|
+
readonly name: string;
|
|
34
|
+
readonly path: readonly string[];
|
|
35
|
+
readonly span: SourceSpan;
|
|
36
|
+
readonly raw?: true;
|
|
37
|
+
} | {
|
|
38
|
+
readonly kind: 'each';
|
|
39
|
+
readonly list: Ref;
|
|
40
|
+
readonly as: string;
|
|
41
|
+
readonly body: readonly TemplateNode[];
|
|
42
|
+
readonly empty: readonly TemplateNode[];
|
|
43
|
+
readonly span: SourceSpan;
|
|
44
|
+
}
|
|
45
|
+
/** `${file "<path>" [| helper attr…]}`: markup or a value for a file of the RENDER's tree (src/media.ts). */
|
|
46
|
+
| {
|
|
47
|
+
readonly kind: 'file';
|
|
48
|
+
readonly path: HelperText;
|
|
49
|
+
readonly helper?: string;
|
|
50
|
+
readonly attrs: ReadonlyArray<{
|
|
51
|
+
readonly name: string;
|
|
52
|
+
readonly value?: HelperText;
|
|
53
|
+
}>;
|
|
54
|
+
readonly span: SourceSpan;
|
|
55
|
+
} | {
|
|
56
|
+
readonly kind: 'if';
|
|
57
|
+
readonly cond: Ref;
|
|
58
|
+
readonly negate: boolean;
|
|
59
|
+
readonly then: readonly TemplateNode[];
|
|
60
|
+
readonly otherwise: readonly TemplateNode[];
|
|
61
|
+
readonly span: SourceSpan;
|
|
62
|
+
};
|
|
63
|
+
interface Ref {
|
|
64
|
+
readonly name: string;
|
|
65
|
+
readonly path: readonly string[];
|
|
66
|
+
readonly span: SourceSpan;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Parse a RENDER template.
|
|
70
|
+
*
|
|
71
|
+
* - `${name}` / `${name.seg.seg}` substitutes a value (segments may be array
|
|
72
|
+
* indexes); `${name|raw}` substitutes it without escaping.
|
|
73
|
+
* - `${#each list as item}…${else}…${/each}` repeats for each element of a list
|
|
74
|
+
* (the `${else}` part renders when the list is empty). A missing key such as
|
|
75
|
+
* `post.tags` counts as an empty list; an unknown top-level name is an error.
|
|
76
|
+
* - `${#if x}…${else}…${/if}` / `${#if !x}`: false, null, missing, '', 0 and
|
|
77
|
+
* empty lists are falsy.
|
|
78
|
+
* - A block tag alone on its line removes that whole line from the output.
|
|
79
|
+
* - `$${` writes a literal `${`; a `$` not followed by `{` is literal.
|
|
80
|
+
* - Anything else inside `${…}`, or unbalanced blocks, fails with E_TEMPLATE.
|
|
81
|
+
*/
|
|
82
|
+
export declare function parseRenderTemplate(text: string, file: string, firstLine?: number, firstColumn?: number): TemplateNode[];
|
|
83
|
+
/** Every `${name}` reference of a `${file …}` expression, in order. */
|
|
84
|
+
export declare function fileRefs(n: Extract<TemplateNode, {
|
|
85
|
+
kind: 'file';
|
|
86
|
+
}>): Array<Extract<HelperText[number], {
|
|
87
|
+
kind: 'ref';
|
|
88
|
+
}>>;
|
|
89
|
+
/** A name a template reads from outside itself (not a `${#each}` variable of its own), in template order. */
|
|
90
|
+
export interface FreeRef {
|
|
91
|
+
readonly name: string;
|
|
92
|
+
readonly path: readonly string[];
|
|
93
|
+
readonly span: SourceSpan;
|
|
94
|
+
/** `var`: `${name…}`; `each`: the list of `${#each}`; `if`: the condition of `${#if}`; `text`: inside a `${file …}` string. */
|
|
95
|
+
readonly use: 'var' | 'each' | 'if' | 'text';
|
|
96
|
+
}
|
|
97
|
+
/** The names a template reads that its own `${#each}` blocks do not bind, in order. */
|
|
98
|
+
export declare function freeRefs(nodes: readonly TemplateNode[]): FreeRef[];
|
|
99
|
+
/** What renderTemplate needs beyond values: html fragments (`LET name: html`, `IMPORT … AS html`). */
|
|
100
|
+
export interface TemplateContext {
|
|
101
|
+
/** Whether `name` is an html fragment (checked after loop variables, before `lookup`). */
|
|
102
|
+
readonly isFragment?: (name: string) => boolean;
|
|
103
|
+
/** The parsed template of fragment `name` (may throw, e.g. E_TEMPLATE for an imported partial). */
|
|
104
|
+
readonly fragment?: (name: string) => readonly TemplateNode[];
|
|
105
|
+
/** The stage's tree at this RENDER, for `${file …}`. */
|
|
106
|
+
readonly tree?: TemplateTree;
|
|
107
|
+
/** RENDER --inline-svg. */
|
|
108
|
+
readonly inlineSvg?: boolean;
|
|
109
|
+
}
|
|
110
|
+
/** E_TYPE for a fragment used where a value is needed. */
|
|
111
|
+
export declare function fragmentNotValue(name: string, span: SourceSpan): SitefileError;
|
|
112
|
+
/**
|
|
113
|
+
* Render a parsed template. `lookup` resolves scalars; `values` resolves lists
|
|
114
|
+
* and conditions for blocks (needed only if the template has blocks). Loop
|
|
115
|
+
* variables are resolved here and shadow every other name. Escaping applies to
|
|
116
|
+
* substituted values only, never to template text or `|raw` values.
|
|
117
|
+
*/
|
|
118
|
+
export declare function renderTemplate(nodes: readonly TemplateNode[], lookup: TemplateLookup, escape: EscapeMode, values?: TemplateValueLookup, ctx?: TemplateContext): string;
|
|
119
|
+
export declare function isTruthy(v: unknown): boolean;
|
|
120
|
+
/**
|
|
121
|
+
* Walk `value` along `path`. Strict mode fails like resolveJsonPath on a
|
|
122
|
+
* missing key; loose mode returns undefined. Any value type may be returned.
|
|
123
|
+
*/
|
|
124
|
+
export declare function walk(value: unknown, path: readonly string[], name: string, span: SourceSpan, loose: boolean): unknown;
|
|
125
|
+
export declare function escapeHtml(s: string): string;
|
|
126
|
+
/** Decode strict UTF-8 (E_ENCODING on invalid bytes), stripping a leading BOM. */
|
|
127
|
+
export declare function decodeUtf8(bytes: Uint8Array, what: string, span?: SourceSpan): string;
|
|
128
|
+
/**
|
|
129
|
+
* Walk a parsed JSON value along `path` and return the scalar found there.
|
|
130
|
+
* Missing keys/indexes fail with E_UNDEFINED; null, objects and arrays fail
|
|
131
|
+
* with E_TYPE. Messages name the full dotted path.
|
|
132
|
+
*/
|
|
133
|
+
export declare function resolveJsonPath(value: unknown, path: readonly string[], name: string, span: SourceSpan): Scalar;
|
|
134
|
+
export {};
|