@lucidkiln/core 1.0.0 → 1.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.
- package/CHANGELOG.md +14 -0
- package/dist/ast-DDhHuwaY.d.ts +350 -0
- package/dist/ast-DDhHuwaY.d.ts.map +1 -0
- package/dist/cli.js +2 -2
- package/dist/{environment-BlQ8V4tX.d.ts → environment-DBvRrOn0.d.ts} +51 -80
- package/dist/environment-DBvRrOn0.d.ts.map +1 -0
- package/dist/{format-CJoqhehX.js → format-Di6-GUtH.js} +4 -3
- package/dist/{format-CJoqhehX.js.map → format-Di6-GUtH.js.map} +1 -1
- package/dist/format.d.ts.map +1 -1
- package/dist/format.js +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +76 -158
- package/dist/index.js.map +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/parser-isboTef0.js +2627 -0
- package/dist/parser-isboTef0.js.map +1 -0
- package/dist/{source-BQxJGo5Y.js → source-BbikGqIb.js} +40 -2765
- package/dist/source-BbikGqIb.js.map +1 -0
- package/dist/syntax.d.ts +22 -0
- package/dist/syntax.d.ts.map +1 -0
- package/dist/syntax.js +1 -0
- package/package.json +5 -1
- package/dist/environment-BlQ8V4tX.d.ts.map +0 -1
- package/dist/source-BQxJGo5Y.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.2.0
|
|
4
|
+
|
|
5
|
+
- Inserted content is no longer re-indented to line up with its tag. ([46e6cae](https://github.com/buildlucid/kiln/commit/46e6cae3afbbc88ded8a19dcd9018f8559d4e7ce))
|
|
6
|
+
- `withRender` now keeps your function's type parameters, and `RenderAware` takes the whole function type. ([08f192c](https://github.com/buildlucid/kiln/commit/08f192cd0fcf7913039bd065d9ced29d5453a73a))
|
|
7
|
+
|
|
8
|
+
## 1.1.0
|
|
9
|
+
|
|
10
|
+
- 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))
|
|
11
|
+
- `withRender` now keeps the types of your function's arguments and result. ([d55ef63](https://github.com/buildlucid/kiln/commit/d55ef63677df3b34ea247f3b9f25562b201a18b0))
|
|
12
|
+
- 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))
|
|
13
|
+
- `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))
|
|
14
|
+
- 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))
|
|
15
|
+
- 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))
|
|
16
|
+
|
|
3
17
|
## 1.0.0
|
|
4
18
|
|
|
5
19
|
- The first stable release. Read the [documentation](https://kilnlang.com/docs/) to get started.
|
|
@@ -0,0 +1,350 @@
|
|
|
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
|
+
type Statement = {
|
|
188
|
+
type: "Text";
|
|
189
|
+
value: string;
|
|
190
|
+
span: Span;
|
|
191
|
+
} | {
|
|
192
|
+
type: "Output";
|
|
193
|
+
expression: Expression;
|
|
194
|
+
span: Span;
|
|
195
|
+
} | {
|
|
196
|
+
type: "If";
|
|
197
|
+
branches: {
|
|
198
|
+
test: Expression;
|
|
199
|
+
body: Statement[];
|
|
200
|
+
}[];
|
|
201
|
+
alternate: Statement[] | null;
|
|
202
|
+
span: Span;
|
|
203
|
+
} | {
|
|
204
|
+
type: "For";
|
|
205
|
+
keyName: string | null;
|
|
206
|
+
valueName: string;
|
|
207
|
+
iterable: Expression;
|
|
208
|
+
body: Statement[];
|
|
209
|
+
alternate: Statement[] | null;
|
|
210
|
+
span: Span;
|
|
211
|
+
} | {
|
|
212
|
+
type: "Set";
|
|
213
|
+
name: string;
|
|
214
|
+
value: Expression;
|
|
215
|
+
span: Span;
|
|
216
|
+
} | {
|
|
217
|
+
type: "SetBlock";
|
|
218
|
+
name: string;
|
|
219
|
+
body: Statement[];
|
|
220
|
+
span: Span;
|
|
221
|
+
} |
|
|
222
|
+
/** `rest` names the hash that collects undeclared variables, as in `...attributes`, or is null. */
|
|
223
|
+
{
|
|
224
|
+
type: "Props";
|
|
225
|
+
props: PropParam[];
|
|
226
|
+
rest: string | null;
|
|
227
|
+
span: Span;
|
|
228
|
+
} | {
|
|
229
|
+
type: "Extends";
|
|
230
|
+
template: Expression;
|
|
231
|
+
span: Span;
|
|
232
|
+
} | {
|
|
233
|
+
type: "Block";
|
|
234
|
+
name: string;
|
|
235
|
+
body: Statement[];
|
|
236
|
+
span: Span;
|
|
237
|
+
} | {
|
|
238
|
+
type: "Include";
|
|
239
|
+
template: Expression;
|
|
240
|
+
with: Expression | null;
|
|
241
|
+
ignoreMissing: boolean;
|
|
242
|
+
span: Span;
|
|
243
|
+
} | {
|
|
244
|
+
type: "Component";
|
|
245
|
+
template: Expression;
|
|
246
|
+
with: Expression | null;
|
|
247
|
+
fills: {
|
|
248
|
+
name: string;
|
|
249
|
+
body: Statement[];
|
|
250
|
+
span: Span;
|
|
251
|
+
}[];
|
|
252
|
+
/** Content outside any `fill`, which fills the default slot. */
|
|
253
|
+
body: Statement[];
|
|
254
|
+
span: Span;
|
|
255
|
+
} | {
|
|
256
|
+
type: "Slot";
|
|
257
|
+
name: string;
|
|
258
|
+
body: Statement[];
|
|
259
|
+
span: Span;
|
|
260
|
+
} |
|
|
261
|
+
/**
|
|
262
|
+
* A component that can load after the page. `body` is the fallback, shown until a deferred island loads. A deferred
|
|
263
|
+
* island writes its tags back as `<kiln-island>` lines where they stand on lines of their own. `indent` is set when
|
|
264
|
+
* the `island` tag does: its line's indentation. `closing` is set when `endisland` does: its indentation, or null
|
|
265
|
+
* when it shares that line with the `island` tag, and whether a line break followed it.
|
|
266
|
+
*/
|
|
267
|
+
{
|
|
268
|
+
type: "Island";
|
|
269
|
+
template: Expression;
|
|
270
|
+
with: Expression | null;
|
|
271
|
+
body: Statement[];
|
|
272
|
+
indent?: string;
|
|
273
|
+
closing?: {
|
|
274
|
+
indent: string | null;
|
|
275
|
+
newline: boolean;
|
|
276
|
+
};
|
|
277
|
+
span: Span;
|
|
278
|
+
} | {
|
|
279
|
+
type: "Macro";
|
|
280
|
+
name: string;
|
|
281
|
+
params: Param[];
|
|
282
|
+
body: Statement[];
|
|
283
|
+
span: Span;
|
|
284
|
+
} | {
|
|
285
|
+
type: "Import";
|
|
286
|
+
template: string;
|
|
287
|
+
alias: string;
|
|
288
|
+
span: Span;
|
|
289
|
+
} | {
|
|
290
|
+
type: "FromImport";
|
|
291
|
+
template: string;
|
|
292
|
+
names: {
|
|
293
|
+
name: string;
|
|
294
|
+
alias: string;
|
|
295
|
+
span: Span;
|
|
296
|
+
}[];
|
|
297
|
+
span: Span;
|
|
298
|
+
} | {
|
|
299
|
+
type: "With";
|
|
300
|
+
value: Expression;
|
|
301
|
+
body: Statement[];
|
|
302
|
+
span: Span;
|
|
303
|
+
} |
|
|
304
|
+
/** A place other templates add content to with `add to`, filled when the render ends. */
|
|
305
|
+
{
|
|
306
|
+
type: "Outlet";
|
|
307
|
+
name: string;
|
|
308
|
+
span: Span;
|
|
309
|
+
} |
|
|
310
|
+
/** Closes the outlets reached so far, so a streamed render can send its output up to here. */
|
|
311
|
+
{
|
|
312
|
+
type: "Flush";
|
|
313
|
+
span: Span;
|
|
314
|
+
} |
|
|
315
|
+
/** Content for the outlet named `outlet`. `once` adds it only the first time the tag runs in a render. */
|
|
316
|
+
{
|
|
317
|
+
type: "Add";
|
|
318
|
+
outlet: string;
|
|
319
|
+
once: boolean;
|
|
320
|
+
body: Statement[];
|
|
321
|
+
span: Span;
|
|
322
|
+
} |
|
|
323
|
+
/** `seconds` is the `for` value, or null. */
|
|
324
|
+
{
|
|
325
|
+
type: "Cache";
|
|
326
|
+
key: Expression;
|
|
327
|
+
seconds: Expression | null;
|
|
328
|
+
body: Statement[];
|
|
329
|
+
span: Span;
|
|
330
|
+
} | {
|
|
331
|
+
type: "Apply";
|
|
332
|
+
filters: FilterCall[];
|
|
333
|
+
body: Statement[];
|
|
334
|
+
span: Span;
|
|
335
|
+
} | {
|
|
336
|
+
type: "Autoescape";
|
|
337
|
+
strategy: EscapeStrategy | false;
|
|
338
|
+
body: Statement[];
|
|
339
|
+
span: Span;
|
|
340
|
+
};
|
|
341
|
+
type TemplateNode = {
|
|
342
|
+
type: "Template";
|
|
343
|
+
body: Statement[];
|
|
344
|
+
span: Span;
|
|
345
|
+
};
|
|
346
|
+
/** The value types a prop can declare, named as in the docs' table of types. */
|
|
347
|
+
declare const TYPE_NAMES: readonly ["null", "boolean", "number", "string", "array", "hash", "set", "date", "markup", "object"];
|
|
348
|
+
//#endregion
|
|
349
|
+
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 };
|
|
350
|
+
//# sourceMappingURL=ast-DDhHuwaY.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast-DDhHuwaY.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;;EACxD;EAAc,SAAS;EAAa,MAAM;;EAE5C;EACA;EACA,SAAS;EACT,MAAM;;EAGN;EACA,UAAU;EACV,MAAM;EACN,OAAO;EACP,MAAM;;EAGN;EACA,MAAM;EACN,YAAY;EACZ,WAAW;EACX,MAAM;;EAGN;EACA,QAAQ;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A;IAAS;IAAc;IAAe,MAAM;;EAC5C,MAAM;;EAEJ;EAAc,OAAO;EAAY,MAAM;EAAa,MAAM;;;;EAE1D;EAAgB;EAAc,MAAM;;;;EAEpC;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;;;cAgB3D"}
|
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import { n as format, t as KilnFormatError } from "./format-
|
|
2
|
+
import { an as KilnSyntaxError } from "./source-BbikGqIb.js";
|
|
3
|
+
import { n as format, t as KilnFormatError } from "./format-Di6-GUtH.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
|
-
|
|
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-DDhHuwaY.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,13 +287,23 @@ 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
|
-
/**
|
|
335
|
-
|
|
290
|
+
/**
|
|
291
|
+
* Any function that takes `RenderInfo` first. Written as a method so `render` can declare any state, while a `render`
|
|
292
|
+
* without a type gets `RenderInfo<unknown>`, or the environment's state inside `createKiln`.
|
|
293
|
+
*/
|
|
294
|
+
type RenderCall = {
|
|
295
|
+
call(render: RenderInfo<unknown>, ...args: never): unknown;
|
|
296
|
+
}["call"];
|
|
297
|
+
/**
|
|
298
|
+
* A host function that receives `RenderInfo` before its arguments. Create it with `withRender`. `Call` is the function's
|
|
299
|
+
* own type, type parameters included, so editors can show it and work out what each call returns.
|
|
300
|
+
*/
|
|
301
|
+
type RenderAware<Call extends RenderCall = RenderCall> = {
|
|
336
302
|
readonly [renderAware]: true;
|
|
337
|
-
readonly call:
|
|
303
|
+
readonly call: Call;
|
|
338
304
|
};
|
|
339
305
|
/** A function, filter or test a host registers. Parameter types are the host's to declare. */
|
|
340
|
-
type KilnCallable<State = undefined> = ((...args: never) => unknown) | RenderAware<State>;
|
|
306
|
+
type KilnCallable<State = undefined> = ((...args: never) => unknown) | RenderAware<(render: RenderInfo<State>, ...args: never) => unknown>;
|
|
341
307
|
type Limits = {
|
|
342
308
|
/** Characters of output, counted as string length. */
|
|
343
309
|
maxOutputLength: number;
|
|
@@ -424,7 +390,7 @@ type Kiln<State = undefined, Schema extends KilnSchema = DefaultSchema> = {
|
|
|
424
390
|
* document: withRender((render, collection: string) => fetchDocument(collection, render.state.locale))
|
|
425
391
|
* ```
|
|
426
392
|
*/
|
|
427
|
-
declare const withRender: <
|
|
393
|
+
declare const withRender: <Call extends RenderCall>(fn: Call) => RenderAware<Call>;
|
|
428
394
|
/**
|
|
429
395
|
* Creates a Kiln environment: the loader, functions, filters, tests, globals and options every render uses.
|
|
430
396
|
*
|
|
@@ -445,7 +411,7 @@ declare const memoryLoader: (templates: Record<string, string | PrecompiledTempl
|
|
|
445
411
|
};
|
|
446
412
|
/**
|
|
447
413
|
* 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.
|
|
414
|
+
* by default, and drops the oldest first. `clear` removes every copy, or those with any of the tags passed.
|
|
449
415
|
*
|
|
450
416
|
* ```ts
|
|
451
417
|
* const kiln = createKiln({ loader, cache: memoryCache() });
|
|
@@ -457,12 +423,17 @@ declare const memoryCache: ({ max }?: {
|
|
|
457
423
|
get: ({ key }: {
|
|
458
424
|
key: string;
|
|
459
425
|
}) => string | null;
|
|
460
|
-
set: ({ key, value, seconds }: {
|
|
426
|
+
set: ({ key, value, seconds, tags }: {
|
|
461
427
|
key: string;
|
|
462
428
|
value: string;
|
|
463
429
|
seconds: number | null;
|
|
430
|
+
tags: string[];
|
|
431
|
+
}) => void;
|
|
432
|
+
/** Removes every copy, or with `tags`, the copies that have any of them. */
|
|
433
|
+
clear: ({ tags }?: {
|
|
434
|
+
tags?: readonly string[];
|
|
464
435
|
}) => void;
|
|
465
436
|
};
|
|
466
437
|
//#endregion
|
|
467
|
-
export {
|
|
468
|
-
//# sourceMappingURL=environment-
|
|
438
|
+
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 };
|
|
439
|
+
//# sourceMappingURL=environment-DBvRrOn0.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment-DBvRrOn0.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,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sB,SACnE,QAAQ,eAAe;;EAE1B,MAAM,cAAc,kBAAkB,QAAQ;;EAE9C,QAAQ,cAAc,kBAAkB,QAAQ;;;;;EAKhD,WAAW,cAAc,kBAAkB;;EAE3C,WAAW;;;;;;;;;cAUC,aAAc,aAAa,YAAU,IAC7C,SACF,YAAY;;;;;;;;;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 {
|
|
1
|
+
import { an as KilnSyntaxError, on as createDiagnostic, r as builtinTests, t as Source } from "./source-BbikGqIb.js";
|
|
2
|
+
import { r as scanParts, t as parse } from "./parser-isboTef0.js";
|
|
2
3
|
//#region src/formatter/delimiters.ts
|
|
3
4
|
const KEYWORDS = /* @__PURE__ */ new Set([
|
|
4
5
|
"and",
|
|
@@ -651,7 +652,7 @@ const normaliseTree = (value) => {
|
|
|
651
652
|
if (typeof value !== "object" || value === null) return value;
|
|
652
653
|
const copy = {};
|
|
653
654
|
for (const [key, item] of Object.entries(value)) {
|
|
654
|
-
if (key === "span" || key === "nameSpan" || key === "
|
|
655
|
+
if (key === "span" || key === "nameSpan" || key === "indent") continue;
|
|
655
656
|
copy[key] = key === "value" && value.type === "Text" ? normaliseText(item) : normaliseTree(item);
|
|
656
657
|
}
|
|
657
658
|
return copy;
|
|
@@ -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-
|
|
697
|
+
//# sourceMappingURL=format-Di6-GUtH.js.map
|