@lucidkiln/core 1.0.0 → 1.1.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.1.0
4
+
5
+ - New `KilnFunctions`, `KilnFilters`, `KilnTests` and `KilnGlobals` interfaces. Add your own to them so your editor can show their types. See [Types from TypeScript](https://kilnlang.com/docs/tooling/editors/#types-from-typescript). ([d55ef63](https://github.com/buildlucid/kiln/commit/d55ef63677df3b34ea247f3b9f25562b201a18b0))
6
+ - `withRender` now keeps the types of your function's arguments and result. ([d55ef63](https://github.com/buildlucid/kiln/commit/d55ef63677df3b34ea247f3b9f25562b201a18b0))
7
+ - Cache tags. A function wrapped in `withRender` can call `render.tagCache("collection:pages")` to tag the `cache` section it runs in. The store's `set` now receives the section's `tags`, so it can clear copies when that data changes. See [Tags](https://kilnlang.com/docs/tags/cache/#tags). ([6a9b26f](https://github.com/buildlucid/kiln/commit/6a9b26f4d8beadc6d04f358e617a11b237a1487e))
8
+ - `memoryCache` has a `clear` method, which removes every copy, or those with any of the tags you pass. ([6a9b26f](https://github.com/buildlucid/kiln/commit/6a9b26f4d8beadc6d04f358e617a11b237a1487e))
9
+ - Copies saved by an earlier version of Kiln are treated as missing, so each section renders once more and is saved again. ([6a9b26f](https://github.com/buildlucid/kiln/commit/6a9b26f4d8beadc6d04f358e617a11b237a1487e))
10
+ - New `@lucidkiln/core/syntax` entry point with Kiln's parser, for editor tools. Its shapes can change in any minor release. ([d55ef63](https://github.com/buildlucid/kiln/commit/d55ef63677df3b34ea247f3b9f25562b201a18b0))
11
+
3
12
  ## 1.0.0
4
13
 
5
14
  - The first stable release. Read the [documentation](https://kilnlang.com/docs/) to get started.
@@ -0,0 +1,357 @@
1
+ //#region src/source.d.ts
2
+ /** A range of a template's source, as zero-based offsets. `end` is exclusive. */
3
+ type Span = {
4
+ start: number;
5
+ end: number;
6
+ };
7
+ type Position = {
8
+ /** Zero-based offset into the source. */
9
+ offset: number;
10
+ /** One-based. */
11
+ line: number;
12
+ /** One-based, counted in UTF-16 code units. */
13
+ column: number;
14
+ };
15
+ /**
16
+ * A template's text and resolved name.
17
+ *
18
+ * The line index is built on first use, because only errors and tooling need lines and columns. A byte order mark at the
19
+ * start is not counted in columns or shown in frames, as editors hide it, but offsets still count it.
20
+ */
21
+ declare class Source {
22
+ #private;
23
+ readonly name: string;
24
+ readonly text: string;
25
+ constructor(name: string, text: string);
26
+ /** Converts an offset into a line and column. */
27
+ position(offset: number): Position;
28
+ /**
29
+ * Renders a few lines around a span, with a marker under it.
30
+ *
31
+ * ```text
32
+ * 3 | {% block content %}
33
+ * > 4 | <h1>{{ titel }}</h1>
34
+ * | ^^^^^
35
+ * ```
36
+ */
37
+ frame(span: Span, context?: number): string;
38
+ }
39
+ //#endregion
40
+ //#region src/parser/ast.d.ts
41
+ type EscapeStrategy = "html" | "attr" | "js" | "css" | "url";
42
+ type BinaryOperator = "or" | "and" | "??" | "?:" | "==" | "!=" | "<" | ">" | "<=" | ">=" | "in" | "not in" | "starts with" | "ends with" | ".." | "~" | "+" | "-" | "*" | "/" | "//" | "%" | "**";
43
+ type Spread = {
44
+ type: "Spread";
45
+ value: Expression;
46
+ span: Span;
47
+ };
48
+ type Argument = {
49
+ type: "Positional";
50
+ value: Expression;
51
+ span: Span;
52
+ } | {
53
+ type: "Named";
54
+ name: string;
55
+ value: Expression;
56
+ span: Span;
57
+ } | Spread;
58
+ type HashEntry = {
59
+ type: "Property";
60
+ key: Expression;
61
+ value: Expression;
62
+ span: Span;
63
+ } | Spread;
64
+ type Expression = {
65
+ type: "Literal";
66
+ value: null | boolean | number | string;
67
+ span: Span;
68
+ } | {
69
+ type: "Name";
70
+ name: string;
71
+ span: Span;
72
+ } |
73
+ /** A double-quoted string with `#{}` interpolation. */
74
+ {
75
+ type: "Interpolation";
76
+ parts: Expression[];
77
+ span: Span;
78
+ } | {
79
+ type: "Array";
80
+ elements: (Expression | Spread)[];
81
+ span: Span;
82
+ } | {
83
+ type: "Hash";
84
+ entries: HashEntry[];
85
+ span: Span;
86
+ } | {
87
+ type: "Unary";
88
+ operator: "-" | "+" | "not";
89
+ operand: Expression;
90
+ span: Span;
91
+ } | {
92
+ type: "Binary";
93
+ operator: BinaryOperator;
94
+ left: Expression;
95
+ right: Expression;
96
+ span: Span;
97
+ } | {
98
+ type: "Conditional";
99
+ test: Expression;
100
+ consequent: Expression;
101
+ alternate: Expression | null;
102
+ span: Span;
103
+ } | {
104
+ type: "Member";
105
+ object: Expression;
106
+ property: Expression;
107
+ /** True for `a?.b` and `a?.[b]`. */
108
+ optional: boolean;
109
+ span: Span;
110
+ } | {
111
+ type: "Call";
112
+ callee: Expression;
113
+ args: Argument[];
114
+ span: Span;
115
+ } | {
116
+ type: "Filter";
117
+ name: string;
118
+ nameSpan: Span;
119
+ input: Expression;
120
+ args: Argument[];
121
+ span: Span;
122
+ } | {
123
+ type: "Test";
124
+ name: string;
125
+ nameSpan: Span;
126
+ input: Expression;
127
+ args: Argument[];
128
+ negated: boolean;
129
+ span: Span;
130
+ } | {
131
+ type: "Arrow";
132
+ params: string[];
133
+ body: Expression;
134
+ span: Span;
135
+ } |
136
+ /** Wraps a member and call chain that contains `?.`, so null short-circuits the whole chain. */
137
+ {
138
+ type: "OptionalChain";
139
+ expression: Expression;
140
+ span: Span;
141
+ } |
142
+ /** Stands in for an expression that failed to parse. */
143
+ {
144
+ type: "Invalid";
145
+ span: Span;
146
+ };
147
+ type Param = {
148
+ name: string;
149
+ default: Expression | null;
150
+ span: Span;
151
+ };
152
+ /** Type names a prop can declare. See `TYPE_NAMES`. */
153
+ type TypeName = (typeof TYPE_NAMES)[number];
154
+ /**
155
+ * One member of a prop's type. A full type is a list of members, read as a union.
156
+ *
157
+ * - A built-in type name, such as `string`.
158
+ * - `{ literal }`: one exact string or number, such as `"primary"`.
159
+ * - `{ list }`: `T[]`, an array of the inner type.
160
+ * - `{ shape }`: `{ name: string }`, a hash or object with these keys.
161
+ * - `{ named }`: a type the host registers, such as `Post`.
162
+ */
163
+ type PropType = TypeName | {
164
+ literal: string | number;
165
+ } | {
166
+ list: PropType[];
167
+ } | {
168
+ shape: ShapeKey[];
169
+ } | {
170
+ named: string;
171
+ };
172
+ /** One key of a shape type, such as `url?: string`. */
173
+ type ShapeKey = {
174
+ name: string;
175
+ optional: boolean;
176
+ type: PropType[];
177
+ };
178
+ /** A `props` entry. `type` is null when the prop is untyped. */
179
+ type PropParam = Param & {
180
+ type: PropType[] | null;
181
+ };
182
+ type FilterCall = {
183
+ name: string;
184
+ args: Argument[];
185
+ span: Span;
186
+ };
187
+ /**
188
+ * On a tag that inserts content, when it stands on a line of its own: the line's indentation in the output, which
189
+ * every inserted line gets on top of the indentation around it. See `indent.ts`.
190
+ */
191
+ type Placement = {
192
+ indent?: string;
193
+ };
194
+ type Statement = {
195
+ type: "Text";
196
+ value: string;
197
+ /** Where lines start in `value`, which get the indentation of the content they are inserted into. */
198
+ lines?: number[];
199
+ span: Span;
200
+ } | {
201
+ type: "Output";
202
+ expression: Expression;
203
+ span: Span;
204
+ } | {
205
+ type: "If";
206
+ branches: {
207
+ test: Expression;
208
+ body: Statement[];
209
+ }[];
210
+ alternate: Statement[] | null;
211
+ span: Span;
212
+ } | {
213
+ type: "For";
214
+ keyName: string | null;
215
+ valueName: string;
216
+ iterable: Expression;
217
+ body: Statement[];
218
+ alternate: Statement[] | null;
219
+ span: Span;
220
+ } | {
221
+ type: "Set";
222
+ name: string;
223
+ value: Expression;
224
+ span: Span;
225
+ } | {
226
+ type: "SetBlock";
227
+ name: string;
228
+ body: Statement[];
229
+ span: Span;
230
+ } |
231
+ /** `rest` names the hash that collects undeclared variables, as in `...attributes`, or is null. */
232
+ {
233
+ type: "Props";
234
+ props: PropParam[];
235
+ rest: string | null;
236
+ span: Span;
237
+ } | {
238
+ type: "Extends";
239
+ template: Expression;
240
+ span: Span;
241
+ } | ({
242
+ type: "Block";
243
+ name: string;
244
+ body: Statement[];
245
+ span: Span;
246
+ } & Placement) | ({
247
+ type: "Include";
248
+ template: Expression;
249
+ with: Expression | null;
250
+ ignoreMissing: boolean;
251
+ span: Span;
252
+ } & Placement) | ({
253
+ type: "Component";
254
+ template: Expression;
255
+ with: Expression | null;
256
+ fills: {
257
+ name: string;
258
+ body: Statement[];
259
+ span: Span;
260
+ }[];
261
+ /** Content outside any `fill`, which fills the default slot. */
262
+ body: Statement[];
263
+ span: Span;
264
+ } & Placement) | ({
265
+ type: "Slot";
266
+ name: string;
267
+ body: Statement[];
268
+ span: Span;
269
+ } & Placement) |
270
+ /**
271
+ * A component that can load after the page. `body` is the fallback, shown until a deferred island loads. `closing`
272
+ * is set when `endisland` stands on a line of its own: its indentation, or null when it shares that line with the
273
+ * `island` tag, and whether a line break followed it.
274
+ */
275
+ ({
276
+ type: "Island";
277
+ template: Expression;
278
+ with: Expression | null;
279
+ body: Statement[];
280
+ closing?: {
281
+ indent: string | null;
282
+ newline: boolean;
283
+ };
284
+ span: Span;
285
+ } & Placement) | {
286
+ type: "Macro";
287
+ name: string;
288
+ params: Param[];
289
+ body: Statement[];
290
+ span: Span;
291
+ } | {
292
+ type: "Import";
293
+ template: string;
294
+ alias: string;
295
+ span: Span;
296
+ } | {
297
+ type: "FromImport";
298
+ template: string;
299
+ names: {
300
+ name: string;
301
+ alias: string;
302
+ span: Span;
303
+ }[];
304
+ span: Span;
305
+ } | {
306
+ type: "With";
307
+ value: Expression;
308
+ body: Statement[];
309
+ span: Span;
310
+ } |
311
+ /** A place other templates add content to with `add to`, filled when the render ends. */
312
+ ({
313
+ type: "Outlet";
314
+ name: string;
315
+ span: Span;
316
+ } & Placement) |
317
+ /** Closes the outlets reached so far, so a streamed render can send its output up to here. */
318
+ {
319
+ type: "Flush";
320
+ span: Span;
321
+ } |
322
+ /** Content for the outlet named `outlet`. `once` adds it only the first time the tag runs in a render. */
323
+ {
324
+ type: "Add";
325
+ outlet: string;
326
+ once: boolean;
327
+ body: Statement[];
328
+ span: Span;
329
+ } |
330
+ /** `seconds` is the `for` value, or null. */
331
+ {
332
+ type: "Cache";
333
+ key: Expression;
334
+ seconds: Expression | null;
335
+ body: Statement[];
336
+ span: Span;
337
+ } | {
338
+ type: "Apply";
339
+ filters: FilterCall[];
340
+ body: Statement[];
341
+ span: Span;
342
+ } | {
343
+ type: "Autoescape";
344
+ strategy: EscapeStrategy | false;
345
+ body: Statement[];
346
+ span: Span;
347
+ };
348
+ type TemplateNode = {
349
+ type: "Template";
350
+ body: Statement[];
351
+ span: Span;
352
+ };
353
+ /** The value types a prop can declare, named as in the docs' table of types. */
354
+ declare const TYPE_NAMES: readonly ["null", "boolean", "number", "string", "array", "hash", "set", "date", "markup", "object"];
355
+ //#endregion
356
+ export { HashEntry as a, PropType as c, Statement as d, TemplateNode as f, Span as g, Source as h, Expression as i, ShapeKey as l, Position as m, BinaryOperator as n, Param as o, TypeName as p, EscapeStrategy as r, PropParam as s, Argument as t, Spread as u };
357
+ //# sourceMappingURL=ast-1akLiy-A.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ast-1akLiy-A.d.ts","names":[],"sources":["../src/source.ts","../src/parser/ast.ts"],"mappings":";;KAGY;EAAS;EAAe;;KAExB;;EAEX;;EAEA;;EAEA;;;;;;;;cASY;;WAIF;WACA;EAFV,YACU,cACA;;EAIV,SAAS,iBAAiB;;;;;;;;;;EA0B1B,MAAM,MAAM,MAAM;;;;KCrDP;KAEA;KAyBA;EAAW;EAAgB,OAAO;EAAY,MAAM;;KAEpD;EACP;EAAoB,OAAO;EAAY,MAAM;;EAC7C;EAAe;EAAc,OAAO;EAAY,MAAM;IACxD;KAES;EACP;EAAkB,KAAK;EAAY,OAAO;EAAY,MAAM;IAC9D;KAES;EAET;EACA;EACA,MAAM;;EAEJ;EAAc;EAAc,MAAM;;;;EAElC;EAAuB,OAAO;EAAc,MAAM;;EAClD;EAAe,WAAW,aAAa;EAAW,MAAM;;E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ACF;EACD;EAAc;EAAc,MAAM;EAAa,MAAM;IAAS;;;;;;;EAOjE;EACA,UAAU;EACV,MAAM;EACN,MAAM;EACN;IAAY;IAAuB;;EACnC,MAAM;IACF;EAEJ;EACA;EACA,QAAQ;EACR,MAAM;EACN,MAAM;;EAEJ;EAAgB;EAAkB;EAAe,MAAM;;EAEzD;EACA;EACA;IAAS;IAAc;IAAe,MAAM;;EAC5C,MAAM;;EAEJ;EAAc,OAAO;EAAY,MAAM;EAAa,MAAM;;;;EAEzD;EAAgB;EAAc,MAAM;IAAS;;;EAE9C;EAAe,MAAM;;;;EAGvB;EACA;EACA;EACA,MAAM;EACN,MAAM;;;;EAIN;EACA,KAAK;EACL,SAAS;EACT,MAAM;EACN,MAAM;;EAEJ;EAAe,SAAS;EAAc,MAAM;EAAa,MAAM;;EAEjE;EACA,UAAU;EACV,MAAM;EACN,MAAM;;KAGG;EAAiB;EAAkB,MAAM;EAAa,MAAM;;;cAoB3D"}
package/dist/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { mn as KilnSyntaxError } from "./source-BQxJGo5Y.js";
3
- import { n as format, t as KilnFormatError } from "./format-CJoqhehX.js";
2
+ import { un as KilnSyntaxError } from "./source-BHcxowQp.js";
3
+ import { n as format, t as KilnFormatError } from "./format-CLCViAPn.js";
4
4
  import { readFile, readdir, stat, writeFile } from "node:fs/promises";
5
5
  import { join, relative, resolve } from "node:path";
6
6
  import process from "node:process";
@@ -1,42 +1,4 @@
1
- //#region src/source.d.ts
2
- /** A range of a template's source, as zero-based offsets. `end` is exclusive. */
3
- type Span = {
4
- start: number;
5
- end: number;
6
- };
7
- type Position = {
8
- /** Zero-based offset into the source. */
9
- offset: number;
10
- /** One-based. */
11
- line: number;
12
- /** One-based, counted in UTF-16 code units. */
13
- column: number;
14
- };
15
- /**
16
- * A template's text and resolved name.
17
- *
18
- * The line index is built on first use, because only errors and tooling need lines and columns. A byte order mark at the
19
- * start is not counted in columns or shown in frames, as editors hide it, but offsets still count it.
20
- */
21
- declare class Source {
22
- #private;
23
- readonly name: string;
24
- readonly text: string;
25
- constructor(name: string, text: string);
26
- /** Converts an offset into a line and column. */
27
- position(offset: number): Position;
28
- /**
29
- * Renders a few lines around a span, with a marker under it.
30
- *
31
- * ```text
32
- * 3 | {% block content %}
33
- * > 4 | <h1>{{ titel }}</h1>
34
- * | ^^^^^
35
- * ```
36
- */
37
- frame(span: Span, context?: number): string;
38
- }
39
- //#endregion
1
+ import { c as PropType, g as Span, h as Source, m as Position, r as EscapeStrategy } from "./ast-1akLiy-A.js";
40
2
  //#region src/errors.d.ts
41
3
  type Diagnostic = {
42
4
  /** A stable kebab-case code, such as `unknown-filter`. */
@@ -86,37 +48,6 @@ declare class KilnRenderError extends Error {
86
48
  get detail(): string;
87
49
  }
88
50
  //#endregion
89
- //#region src/parser/ast.d.ts
90
- type EscapeStrategy = "html" | "attr" | "js" | "css" | "url";
91
- /** Type names a prop can declare. See `TYPE_NAMES`. */
92
- type TypeName = (typeof TYPE_NAMES)[number];
93
- /**
94
- * One member of a prop's type. A full type is a list of members, read as a union.
95
- *
96
- * - A built-in type name, such as `string`.
97
- * - `{ literal }`: one exact string or number, such as `"primary"`.
98
- * - `{ list }`: `T[]`, an array of the inner type.
99
- * - `{ shape }`: `{ name: string }`, a hash or object with these keys.
100
- * - `{ named }`: a type the host registers, such as `Post`.
101
- */
102
- type PropType = TypeName | {
103
- literal: string | number;
104
- } | {
105
- list: PropType[];
106
- } | {
107
- shape: ShapeKey[];
108
- } | {
109
- named: string;
110
- };
111
- /** One key of a shape type, such as `url?: string`. */
112
- type ShapeKey = {
113
- name: string;
114
- optional: boolean;
115
- type: PropType[];
116
- };
117
- /** The value types a prop can declare, named as in the docs' table of types. */
118
- declare const TYPE_NAMES: readonly ["null", "boolean", "number", "string", "array", "hash", "set", "date", "markup", "object"];
119
- //#endregion
120
51
  //#region src/runtime/islands.d.ts
121
52
  /** A value that survives JSON unchanged, which is what island props must be. */
122
53
  type JsonValue = null | boolean | number | string | JsonValue[] | {
@@ -206,12 +137,14 @@ type KilnCache = {
206
137
  }): string | null | undefined | Promise<string | null | undefined>;
207
138
  /**
208
139
  * Saves `value` under `key`. The value is Kiln's own string, holding the HTML and what the section added to outlets,
209
- * to save as it is. `seconds` is the tag's `for` value, or null to let the store decide.
140
+ * to save as it is. `seconds` is the tag's `for` value, or null to let the store decide. `tags` are the section's
141
+ * tags from `RenderInfo.tagCache`, sorted, for a store that clears copies by tag.
210
142
  */
211
143
  set(entry: {
212
144
  key: string;
213
145
  value: string;
214
146
  seconds: number | null;
147
+ tags: string[];
215
148
  }): void | Promise<void>;
216
149
  };
217
150
  type RenderInfo<State = unknown> = {
@@ -221,6 +154,11 @@ type RenderInfo<State = unknown> = {
221
154
  /** Resolved name of the template making the call. */
222
155
  template: string;
223
156
  signal: AbortSignalLike | undefined;
157
+ /**
158
+ * Tags the cached section the call runs in, and every cached section around it, so a store can clear its copies
159
+ * when that data changes. Does nothing outside a cached section.
160
+ */
161
+ tagCache(...tags: string[]): void;
224
162
  };
225
163
  //#endregion
226
164
  //#region src/analyzer.d.ts
@@ -301,6 +239,24 @@ type Loader = {
301
239
  * ```
302
240
  */
303
241
  interface KilnTypes {}
242
+ /**
243
+ * TypeScript types for the functions a project registers, which editors read to show types and complete properties.
244
+ * Empty until the host adds to it. `createKiln` doesn't check it against what you register.
245
+ *
246
+ * ```ts
247
+ * type Functions = typeof functions;
248
+ * declare module "@lucidkiln/core" {
249
+ * interface KilnFunctions extends Functions {}
250
+ * }
251
+ * ```
252
+ */
253
+ interface KilnFunctions {}
254
+ /** Like `KilnFunctions`, for filters. A filter's first argument is the value before the `|`. */
255
+ interface KilnFilters {}
256
+ /** Like `KilnFunctions`, for tests. */
257
+ interface KilnTests {}
258
+ /** Like `KilnFunctions`, for globals. */
259
+ interface KilnGlobals {}
304
260
  /**
305
261
  * Project-wide template defaults, keyed by name without `.kiln`. An explicit schema on `createKiln` replaces these.
306
262
  */
@@ -331,10 +287,13 @@ type TemplateBlock<Name extends string, Templates extends object = KilnTemplates
331
287
  blocks: infer Block;
332
288
  } ? Block : string;
333
289
  declare const renderAware: unique symbol;
334
- /** A host function that receives `RenderInfo` before its arguments. Create it with `withRender`. */
335
- type RenderAware<State> = {
290
+ /**
291
+ * A host function that receives `RenderInfo` before its arguments. Create it with `withRender`. `Args` and `Result` keep
292
+ * the function's own types, so editors can show them.
293
+ */
294
+ type RenderAware<State, Args extends unknown[] = never, Result = unknown> = {
336
295
  readonly [renderAware]: true;
337
- readonly call: (render: RenderInfo<State>, ...args: never) => unknown;
296
+ readonly call: (render: RenderInfo<State>, ...args: Args) => Result;
338
297
  };
339
298
  /** A function, filter or test a host registers. Parameter types are the host's to declare. */
340
299
  type KilnCallable<State = undefined> = ((...args: never) => unknown) | RenderAware<State>;
@@ -424,7 +383,7 @@ type Kiln<State = undefined, Schema extends KilnSchema = DefaultSchema> = {
424
383
  * document: withRender((render, collection: string) => fetchDocument(collection, render.state.locale))
425
384
  * ```
426
385
  */
427
- declare const withRender: <State, Args extends unknown[], Result>(fn: (render: RenderInfo<State>, ...args: Args) => Result) => RenderAware<State>;
386
+ declare const withRender: <State, Args extends unknown[], Result>(fn: (render: RenderInfo<State>, ...args: Args) => Result) => RenderAware<State, Args, Result>;
428
387
  /**
429
388
  * Creates a Kiln environment: the loader, functions, filters, tests, globals and options every render uses.
430
389
  *
@@ -445,7 +404,7 @@ declare const memoryLoader: (templates: Record<string, string | PrecompiledTempl
445
404
  };
446
405
  /**
447
406
  * A store for the `cache` tag that keeps output in memory, for a long-running server. Holds up to `max` copies, 1,000
448
- * by default, and drops the oldest first.
407
+ * by default, and drops the oldest first. `clear` removes every copy, or those with any of the tags passed.
449
408
  *
450
409
  * ```ts
451
410
  * const kiln = createKiln({ loader, cache: memoryCache() });
@@ -457,12 +416,17 @@ declare const memoryCache: ({ max }?: {
457
416
  get: ({ key }: {
458
417
  key: string;
459
418
  }) => string | null;
460
- set: ({ key, value, seconds }: {
419
+ set: ({ key, value, seconds, tags }: {
461
420
  key: string;
462
421
  value: string;
463
422
  seconds: number | null;
423
+ tags: string[];
424
+ }) => void;
425
+ /** Removes every copy, or with `tags`, the copies that have any of them. */
426
+ clear: ({ tags }?: {
427
+ tags?: readonly string[];
464
428
  }) => void;
465
429
  };
466
430
  //#endregion
467
- export { IslandEntry as A, ShapeKey as B, AnalysedProp as C, KilnCache as D, AbortSignalLike as E, deferIslands as F, TemplateLocation as G, Diagnostic as H, islandScript as I, Position as K, streamIslands as L, IslandMode as M, JsonValue as N, RenderInfo as O, StreamedIslands as P, EscapeStrategy as R, PrecompiledTemplate as S, TemplateReference as T, KilnRenderError as U, TypeName as V, KilnSyntaxError as W, memoryLoader as _, KilnTemplates as a, HtmlCheckLevel as b, Loader as c, TemplateBlock as d, TemplateContext as f, memoryCache as g, createKiln as h, KilnSchema as i, IslandManifest as j, DeferredIslands as k, RenderAware as l, TypeChecks as m, KilnCallable as n, KilnTypes as o, TemplateName as p, KilnOptions as r, Limits as s, Kiln as t, RenderOptions as u, withRender as v, Analysis as w, HtmlChecks as x, HtmlCheck as y, PropType as z };
468
- //# sourceMappingURL=environment-BlQ8V4tX.d.ts.map
431
+ export { AbortSignalLike as A, islandScript as B, HtmlCheck as C, AnalysedProp as D, PrecompiledTemplate as E, IslandManifest as F, TemplateLocation as G, Diagnostic as H, IslandMode as I, JsonValue as L, RenderInfo as M, DeferredIslands as N, Analysis as O, IslandEntry as P, StreamedIslands as R, withRender as S, HtmlChecks as T, KilnRenderError as U, streamIslands as V, KilnSyntaxError as W, TemplateName as _, KilnGlobals as a, memoryCache as b, KilnTemplates as c, Limits as d, Loader as f, TemplateContext as g, TemplateBlock as h, KilnFunctions as i, KilnCache as j, TemplateReference as k, KilnTests as l, RenderOptions as m, KilnCallable as n, KilnOptions as o, RenderAware as p, KilnFilters as r, KilnSchema as s, Kiln as t, KilnTypes as u, TypeChecks as v, HtmlCheckLevel as w, memoryLoader as x, createKiln as y, deferIslands as z };
432
+ //# sourceMappingURL=environment-DkfrPazl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"environment-DkfrPazl.d.ts","names":[],"sources":["../src/errors.ts","../src/runtime/islands.ts","../src/runtime/types.ts","../src/analyzer.ts","../src/compiler/precompiled.ts","../src/html/options.ts","../src/environment.ts"],"mappings":";;KAEY;;EAEX;EACA;EACA;;EAEA;EACA,OAAO;EACP,KAAK;;KAGM;EACX;EACA;EACA;;;;;cAyBY,wBAAwB;EAC3B;WACA,aAAa;EAEtB,YAAY,aAAa,cAAc,QAAQ;;;;;cAqBnC,wBAAwB;;EAC3B;WACA;WACA;WACA;WACA;;WAEA;;WAEA,eAAe;;;;EAMxB,YACC,cACA,gBACA,QAAQ,iBACR,OAAM,MACN;IAAW;IAAe;;;MA8BvB;;;;;KCnFO,+CAKT;GACG,cAAc;;;KAGR;EACX;EACA,OAAO,eAAe;;;KAIX,iBAAiB,eAAe;;KAGhC;WACF;;WAEA;;WAEA;;WAEA,UAAU;;;;;;;;;;;cAYP,iBAAY,KAAA;EAIxB;EACA;MACG;;KAQQ;WACF;;WAEA;;;;;;;;;;cAWG,kBAAa;EAGzB;MACQ;;KAGG,aAAa,kBAAkB;;;;;;;;;;;cAY9B;;;;;;;KCvGD;WACF;EACT,kBAAkB,eAAe;EACjC,qBAAqB,eAAe;;;KAoLzB,aAAa;;;;;KAMb;;EAEX,IAAI;IACH;kCAC+B;;;;;;EAMhC,IAAI;IACH;IACA;IACA;IACA;aACU;;KAuBA,WAAW;EACtB,OAAO;EACP;EACA;;EAEA;EACA,QAAQ;;;;;EAKR,YAAY;;;;KCjPD;EACX;;EAEA;EACA,OAAO;EACP,KAAK;;KAGM;EACX;EACA;EACA,MAAM;;KAGK;EACX,aAAa;;EAEb;;EAEA,OAAO;;EAEP;;EAEA;EACA;EACA;EACA;EACA,WAAW;EACX;EACA;;;;;;;;KCqCW;;WAEF;;WAEA,YAAY;;WAEZ;;WAEA,SAAS;;;;cCjFN;K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hB,KACX,mBACA,eAAe,aAAa;;EAG5B,OAAO,aAAa,aAAa,sBAChC,MAAM,SACH,MAAM,gBAAgB,gBAAgB,MAAM,sBAAsB,SACnE;;;;EAIH,YAAY,aAAa,aAAa,sBACrC,MAAM,MACN,OAAO,cAAc,MAAM,yBACxB,MAAM,gBAAgB,gBAAgB,MAAM,sBAAsB,SACnE;;;;;EAKH,aAAa,aAAa,aAAa,sBACtC,MAAM,SACH,MAAM,gBAAgB,gBAAgB,MAAM,sBAAsB,SACnE,QAAQ,eAAe;;EAE1B,MAAM,cAAc,kBAAkB,QAAQ;;EAE9C,QAAQ,cAAc,kBAAkB,QAAQ;;;;;EAKhD,WAAW,cAAc,kBAAkB;;EAE3C,WAAW;;;;;;;;;cAUC,aAAc,OAAO,wBAAwB,QAAM,KAC1D,QAAQ,WAAW,WAAW,MAAM,SAAS,WAChD,YAAY,OAAO,MAAM;;;;;;;;;cA6iBf,aACZ,mBACA,eAAe,aAAa,eAAa,SAEhC,YAAY,OAAO,YAC1B,KAAK,OAAO;;;;;;;cA6GF,eAAY,WAErB,wBAAwB,uBACxB,qBAAqB,yBACtB,KAAK;EAAoB;;;;;;;;;;cAkBf,gBAAW;EAAsB;;;;;;;;;;;;EA0B1B,UAAA;IAAE"}
@@ -1,4 +1,5 @@
1
- import { hn as createDiagnostic, mn as KilnSyntaxError, n as parse, r as scanParts, s as builtinTests, t as Source } from "./source-BQxJGo5Y.js";
1
+ import { dn as createDiagnostic, r as builtinTests, t as Source, un as KilnSyntaxError } from "./source-BHcxowQp.js";
2
+ import { r as scanParts, t as parse } from "./parser-BU5dThuk.js";
2
3
  //#region src/formatter/delimiters.ts
3
4
  const KEYWORDS = /* @__PURE__ */ new Set([
4
5
  "and",
@@ -693,4 +694,4 @@ const format = (text, options = {}) => applyEdits(text, formatEdits(text, option
693
694
  //#endregion
694
695
  export { format as n, formatEdits as r, KilnFormatError as t };
695
696
 
696
- //# sourceMappingURL=format-CJoqhehX.js.map
697
+ //# sourceMappingURL=format-CLCViAPn.js.map