@lucidkiln/core 1.7.1 → 1.8.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 +39 -0
- package/dist/ast-DzzSn9tS.d.ts.map +1 -1
- package/dist/cli.js +2 -2
- package/dist/environment-BQipJ3kg.d.ts.map +1 -1
- package/dist/{format-Cgjx6D1j.js → format-8A_kD0sb.js} +272 -24
- package/dist/format-8A_kD0sb.js.map +1 -0
- package/dist/format.d.ts.map +1 -1
- package/dist/format.js +1 -1
- package/dist/index.js +431 -1362
- package/dist/index.js.map +1 -1
- package/dist/{parser-BZpRlGWi.js → parser-CRWl5Lka.js} +131 -64
- package/dist/parser-CRWl5Lka.js.map +1 -0
- package/dist/{source-DxHQeBEo.js → source-tVX6J33O.js} +1258 -34
- package/dist/source-tVX6J33O.js.map +1 -0
- package/dist/syntax.js +1 -1
- package/package.json +1 -1
- package/dist/format-Cgjx6D1j.js.map +0 -1
- package/dist/parser-BZpRlGWi.js.map +0 -1
- package/dist/source-DxHQeBEo.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.8.0
|
|
4
|
+
|
|
5
|
+
- Regenerate precompiled templates after upgrading, as with every release. Modules from earlier versions are refused. ([3c0a5fb](https://github.com/buildlucid/kiln/commit/3c0a5fb24751d289dbd685b57e6d2db5004d2970))
|
|
6
|
+
- Fixed precompiled templates failing or printing the wrong value when a loop that waits inside a slot's fallback read a variable the fallback set. ([f838138](https://github.com/buildlucid/kiln/commit/f83813803389319d65d6160b203c4e52dab230bc))
|
|
7
|
+
- Fixed precompiled templates printing an old value of a variable after a loop whose component fills changed it. ([f838138](https://github.com/buildlucid/kiln/commit/f83813803389319d65d6160b203c4e52dab230bc))
|
|
8
|
+
- Fixed precompiled templates counting too few steps towards `maxSteps` when a loop's passes ran ahead. ([f838138](https://github.com/buildlucid/kiln/commit/f83813803389319d65d6160b203c4e52dab230bc))
|
|
9
|
+
- Precompiled templates now run the passes of a range loop such as `1..5` at the same time when they wait, and report step and output limits at the same place as other templates when output runs ahead. ([f838138](https://github.com/buildlucid/kiln/commit/f83813803389319d65d6160b203c4e52dab230bc)) ([3c0a5fb](https://github.com/buildlucid/kiln/commit/3c0a5fb24751d289dbd685b57e6d2db5004d2970))
|
|
10
|
+
- Fixed `precompile` failing on templates with more than about 120,000 statements in a row. ([f838138](https://github.com/buildlucid/kiln/commit/f83813803389319d65d6160b203c4e52dab230bc))
|
|
11
|
+
- Precompiling very long templates is much faster. ([f838138](https://github.com/buildlucid/kiln/commit/f83813803389319d65d6160b203c4e52dab230bc))
|
|
12
|
+
- Fixed renders getting slower for the rest of the process after a streamed island. Streamed islands still count towards the page's `maxSteps`. ([3c0a5fb](https://github.com/buildlucid/kiln/commit/3c0a5fb24751d289dbd685b57e6d2db5004d2970))
|
|
13
|
+
- Fixed a streamed island adding to the page's outlets instead of its own when the page was waiting. ([7f0d65e](https://github.com/buildlucid/kiln/commit/7f0d65e05a0a8669a581b308125a86382c973b7b))
|
|
14
|
+
- Fixed `flush` getting slower with every `add to` in a page once part of the page had waited. ([7f0d65e](https://github.com/buildlucid/kiln/commit/7f0d65e05a0a8669a581b308125a86382c973b7b))
|
|
15
|
+
- Fixed `add to` content from macro calls in one expression arriving out of template order when their arguments waited for different times. ([7f0d65e](https://github.com/buildlucid/kiln/commit/7f0d65e05a0a8669a581b308125a86382c973b7b))
|
|
16
|
+
- Fixed slow error messages when a template reads a very long, unknown name or key. ([7f0d65e](https://github.com/buildlucid/kiln/commit/7f0d65e05a0a8669a581b308125a86382c973b7b))
|
|
17
|
+
- An error thrown by an iterable in your data now stops the render with a located `host-error`, instead of escaping as a raw error. ([7f0d65e](https://github.com/buildlucid/kiln/commit/7f0d65e05a0a8669a581b308125a86382c973b7b))
|
|
18
|
+
- Fixed island props nested more than 1,000 levels deep crashing the render. They now give a `too-deep` error, as `json` does. ([7f0d65e](https://github.com/buildlucid/kiln/commit/7f0d65e05a0a8669a581b308125a86382c973b7b))
|
|
19
|
+
- Fixed an error on `if`, `for` or `component` bodies with more than about 130,000 statements. ([6096ce6](https://github.com/buildlucid/kiln/commit/6096ce6657632336eb4fcdfbce18ff1234293761))
|
|
20
|
+
- Error messages show only the part of a very long line around the problem. ([6096ce6](https://github.com/buildlucid/kiln/commit/6096ce6657632336eb4fcdfbce18ff1234293761))
|
|
21
|
+
- Nesting limits now count each level once: tags up to 200 deep, and expressions in brackets up to 100. Everything that parsed before still parses. ([6096ce6](https://github.com/buildlucid/kiln/commit/6096ce6657632336eb4fcdfbce18ff1234293761))
|
|
22
|
+
- Faster lexing and parsing of text-heavy templates and templates with `<pre>` or `<textarea>`. ([6096ce6](https://github.com/buildlucid/kiln/commit/6096ce6657632336eb4fcdfbce18ff1234293761))
|
|
23
|
+
- Fixed string filters such as `upper` and `trim` escaping the content of `<script>` and `<style>` elements in safe markup. ([254eac3](https://github.com/buildlucid/kiln/commit/254eac3e753257157e3a498452a4fedf5548a442))
|
|
24
|
+
- Fixed `stripTags` on safe markup leaving a tag or comment that never closes live in the page. A leftover `<` is now printed as `<`. ([254eac3](https://github.com/buildlucid/kiln/commit/254eac3e753257157e3a498452a4fedf5548a442))
|
|
25
|
+
- Fixed `json` with a NaN indent skipping the output length check. ([254eac3](https://github.com/buildlucid/kiln/commit/254eac3e753257157e3a498452a4fedf5548a442))
|
|
26
|
+
- Building a new number, date or plural formatter now counts 100 steps, so a template can't use slow formatting to get round `maxSteps`. ([254eac3](https://github.com/buildlucid/kiln/commit/254eac3e753257157e3a498452a4fedf5548a442))
|
|
27
|
+
- Fixed `map`, `filter` and `merge` losing the order of a sorted or reversed hash with keys that look like numbers. ([254eac3](https://github.com/buildlucid/kiln/commit/254eac3e753257157e3a498452a4fedf5548a442))
|
|
28
|
+
- Fixed `title` skipping words in quotes, and words after block tags or `<br>` in safe markup. ([254eac3](https://github.com/buildlucid/kiln/commit/254eac3e753257157e3a498452a4fedf5548a442))
|
|
29
|
+
- `title` now starts a new word at table cells, rows, options and other block tags in safe markup. ([254eac3](https://github.com/buildlucid/kiln/commit/254eac3e753257157e3a498452a4fedf5548a442))
|
|
30
|
+
- A promise in your data that an arrow function returns in `map`, `filter`, `sort`, `reduce` or `find` is no longer waited for, unless the arrow itself calls something that waits. ([254eac3](https://github.com/buildlucid/kiln/commit/254eac3e753257157e3a498452a4fedf5548a442))
|
|
31
|
+
- Filters that build hashes, query strings or attributes from a `Map` now skip keys that are objects, instead of calling their methods. ([254eac3](https://github.com/buildlucid/kiln/commit/254eac3e753257157e3a498452a4fedf5548a442))
|
|
32
|
+
- `check` reports template names that rendering rejects, such as `""` or `"../x"`. ([6096ce6](https://github.com/buildlucid/kiln/commit/6096ce6657632336eb4fcdfbce18ff1234293761))
|
|
33
|
+
- `check` no longer warns about variables inside `with data`. ([6096ce6](https://github.com/buildlucid/kiln/commit/6096ce6657632336eb4fcdfbce18ff1234293761))
|
|
34
|
+
- Fixed `analyze` crashing on a very long chain before `??`. ([6096ce6](https://github.com/buildlucid/kiln/commit/6096ce6657632336eb4fcdfbce18ff1234293761))
|
|
35
|
+
- HTML checks are much faster on deeply nested HTML, which could take seconds. ([6096ce6](https://github.com/buildlucid/kiln/commit/6096ce6657632336eb4fcdfbce18ff1234293761))
|
|
36
|
+
- `kiln format` no longer changes the spacing between words when a trim marker or loop joins lines. ([d9cd556](https://github.com/buildlucid/kiln/commit/d9cd55687c063a8488c6453a80849e310ea263ac))
|
|
37
|
+
- `kiln format` no longer adds or removes the space before a captured `set` or macro value, or before the line after an include, when that text renders mid-line. ([d9cd556](https://github.com/buildlucid/kiln/commit/d9cd55687c063a8488c6453a80849e310ea263ac))
|
|
38
|
+
- Fixed `kiln format` needing a second run when a tag starts on the closing line of another. ([d9cd556](https://github.com/buildlucid/kiln/commit/d9cd55687c063a8488c6453a80849e310ea263ac))
|
|
39
|
+
- Fixed `kiln format` leaving a final `\r\n`, and failing on `1 . 5`. ([d9cd556](https://github.com/buildlucid/kiln/commit/d9cd55687c063a8488c6453a80849e310ea263ac))
|
|
40
|
+
- `kiln format` is much faster on lines with long runs of spaces and on long files with trailing spaces. ([d9cd556](https://github.com/buildlucid/kiln/commit/d9cd55687c063a8488c6453a80849e310ea263ac))
|
|
41
|
+
|
|
3
42
|
## 1.7.1
|
|
4
43
|
|
|
5
44
|
- Supports Node 26 as well as Node 24. ([de608f3](https://github.com/buildlucid/kiln/commit/de608f35b8e5a022eb28e03e8083e8c64f4e3d15))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast-DzzSn9tS.d.ts","names":[],"sources":["../src/source.ts","../src/parser/ast.ts"],"mappings":";;KAGY;EAAS;EAAe;;KAExB;;EAEX;;EAEA;;EAEA;;;;;;;;
|
|
1
|
+
{"version":3,"file":"ast-DzzSn9tS.d.ts","names":[],"sources":["../src/source.ts","../src/parser/ast.ts"],"mappings":";;KAGY;EAAS;EAAe;;KAExB;;EAEX;;EAEA;;EAEA;;;;;;;;cAaY;;WAIF;WACA;EAFV,YACU,cACA;;EAIV,SAAS,iBAAiB;;;;;;;;;;EA0B1B,MAAM,MAAM,MAAM;;;;KCzDP;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;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AM;;EAEJ;EAAgB;EAAkB;EAAe,MAAM;;EAEzD;EACA;EACA;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 { Fn as KilnSyntaxError } from "./source-tVX6J33O.js";
|
|
3
|
+
import { n as format, t as KilnFormatError } from "./format-8A_kD0sb.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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environment-BQipJ3kg.d.ts","names":[],"sources":["../src/errors.ts","../src/runtime/islands.ts","../src/runtime/types.ts","../src/analyzer.ts","../src/runtime/markup.ts","../src/compiler/host.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;;;;;
|
|
1
|
+
{"version":3,"file":"environment-BQipJ3kg.d.ts","names":[],"sources":["../src/errors.ts","../src/runtime/islands.ts","../src/runtime/types.ts","../src/analyzer.ts","../src/runtime/markup.ts","../src/compiler/host.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;;;;;KCjFO,+CAKT;GACG,cAAc;;;;;;;KAOR;EACX;EACA,OAAO,eAAe;EACtB;EACA;;;KAIW,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;;;;;;;KC1GD;WACF;EACT,kBAAkB,eAAe;EACjC,qBAAqB,eAAe;;;KA+KzB,aAAa;;;;;;KAOb,UAAU;;EAErB,IAAI;IACH;IACA,OAAO;kCACwB;;;;;;EAMhC,IAAI;IACH;IACA;IACA;IACA;IACA,OAAO;aACG;;KAwBA,WAAW;EACtB,OAAO;EACP;EACA;;EAEA;EACA,QAAQ;;;;;EAKR,YAAY;;;;;EAKZ,MAAM,gBAAgB,cAAc;IAAY;;;;;KC1PrC;EACX;;EAEA;EACA,OAAO;EACP,KAAK;;;KAIM;;EAEX;EACA;;EAEA;;;KAIW;EACX;EACA;;EAEA;;KAGW;EACX;EACA,MAAM;EACN,OAAO;EACP,KAA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A2hBG,aACZ,mBACA,eAAe,aAAa,eAAa,SAEhC,YAAY,OAAO,YAC1B,KAAK,OAAO;;;;;;;cAoHF,eAAY,WACb,eAAe,kBAAkB,YAAY,oBACtD,KAAK;EAAoB;;;;;;;;;;cAkBf,gBAAW;EAAsB;;EAQ7B,QAAA;IAAE;;EAYd,QAAA,KAAA,OAAA,SAAA;IACF;IACA;IACA;IACA;;;EAaiB,UAAA;IAAE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { r as
|
|
1
|
+
import { Fn as KilnSyntaxError, In as createDiagnostic, r as builtinTests, t as Source, un as BLOCK } from "./source-tVX6J33O.js";
|
|
2
|
+
import { r as scanControlled, t as parse } from "./parser-CRWl5Lka.js";
|
|
3
3
|
//#region src/formatter/delimiters.ts
|
|
4
4
|
const KEYWORDS = /* @__PURE__ */ new Set([
|
|
5
5
|
"and",
|
|
@@ -115,6 +115,15 @@ const gapBetween = (previous, previousRole, piece, role) => {
|
|
|
115
115
|
return " ";
|
|
116
116
|
};
|
|
117
117
|
/**
|
|
118
|
+
* Whether `pieces[index]`, a number after a `.`, would join the number before the `.` if printed against it, as `1 . 5`
|
|
119
|
+
* would read as `1.5`. A number right after `.` or `?.` is read as a whole number, so `items.0 . 1` can't join.
|
|
120
|
+
*/
|
|
121
|
+
const joinsNumber = (pieces, index) => {
|
|
122
|
+
const number = pieces[index - 2];
|
|
123
|
+
const before = pieces[index - 3]?.text;
|
|
124
|
+
return pieces[index]?.type === "number" && pieces[index - 1]?.text === "." && number?.type === "number" && !number.text.includes(".") && before !== "." && before !== "?.";
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
118
127
|
* Prints one output or tag with normalised spacing. Line breaks between tokens stay; each line after one is indented from `indent`, one step further or to match the brackets it sits inside, using `unit` per step.
|
|
119
128
|
*
|
|
120
129
|
* Returns null for a delimiter that never closed, which the formatter leaves as it is.
|
|
@@ -140,6 +149,7 @@ const printDelimiter = (source, part, indent, unit) => {
|
|
|
140
149
|
while (roles[index + closers] === "close" && (closers === 0 || !source.slice(pieces[index + closers - 1].end, pieces[index + closers].start).includes("\n"))) closers++;
|
|
141
150
|
out += `\n${indent}${unit.repeat(closers > 0 ? steps(closers) : Math.max(steps(0), 1))}`;
|
|
142
151
|
} else if (index === 0) out += " ";
|
|
152
|
+
else if (joinsNumber(pieces, index)) out += " ";
|
|
143
153
|
else out += gapBetween(pieces[index - 1], roles[index - 1], piece, role);
|
|
144
154
|
out += piece.text;
|
|
145
155
|
if (role === "open" || role === "call") openedOn.push(line);
|
|
@@ -245,6 +255,13 @@ const roleOf = (part) => {
|
|
|
245
255
|
};
|
|
246
256
|
return null;
|
|
247
257
|
};
|
|
258
|
+
const BLOCK_TAG = /[ \t]*<\/?([A-Za-z][A-Za-z0-9-]*)/y;
|
|
259
|
+
/** Whether the line at `start` begins with a tag of an element shown on a line of its own, such as `<p>` or `</td>`, before which HTML shows no space. */
|
|
260
|
+
const startsWithBlock = (text, start) => {
|
|
261
|
+
BLOCK_TAG.lastIndex = start;
|
|
262
|
+
const name = BLOCK_TAG.exec(text)?.[1];
|
|
263
|
+
return name !== void 0 && BLOCK.has(name.toLowerCase());
|
|
264
|
+
};
|
|
248
265
|
const isLetter = (char) => char !== void 0 && /[A-Za-z]/.test(char);
|
|
249
266
|
const isTest = (name) => Object.hasOwn(builtinTests, name);
|
|
250
267
|
/** The start offset of every line. */
|
|
@@ -257,6 +274,131 @@ const lineStarts = (text) => {
|
|
|
257
274
|
return starts;
|
|
258
275
|
};
|
|
259
276
|
/**
|
|
277
|
+
* What the output before a point may end with, as flags: the start of a line, the middle of one, or either. `UNSEEN`
|
|
278
|
+
* means content the template can't see the end of, such as an include's, which may end mid-line.
|
|
279
|
+
*/
|
|
280
|
+
const LINE_START = 1;
|
|
281
|
+
const MID_LINE = 2;
|
|
282
|
+
const UNSEEN = 4;
|
|
283
|
+
/** Block tags whose body renders somewhere else, such as where a macro is called, so it starts at an unknown point. */
|
|
284
|
+
const ELSEWHERE = /* @__PURE__ */ new Set([
|
|
285
|
+
"macro",
|
|
286
|
+
"set",
|
|
287
|
+
"add",
|
|
288
|
+
"component",
|
|
289
|
+
"fill"
|
|
290
|
+
]);
|
|
291
|
+
/**
|
|
292
|
+
* Tags that insert content from elsewhere where they stand. A `block` may be a child template's, and a child's block
|
|
293
|
+
* body renders after whatever its parent has before the block.
|
|
294
|
+
*/
|
|
295
|
+
const INSERTS = /* @__PURE__ */ new Set([
|
|
296
|
+
"include",
|
|
297
|
+
"outlet",
|
|
298
|
+
"block"
|
|
299
|
+
]);
|
|
300
|
+
/** Block tags whose output, after their end tag, may come from elsewhere: a component's, a slot's fill, a child's block. */
|
|
301
|
+
const INSERTED_BODIES = /* @__PURE__ */ new Set([
|
|
302
|
+
"component",
|
|
303
|
+
"slot",
|
|
304
|
+
"block"
|
|
305
|
+
]);
|
|
306
|
+
/**
|
|
307
|
+
* The start of each line whose indentation may render in the middle of a line, so changing it changes the spacing
|
|
308
|
+
* between words. Kiln removes a line holding only tags with its line break, so the next line follows whatever came
|
|
309
|
+
* before them, which a trim marker can leave mid-line, as can the end of a loop's body for its next iteration.
|
|
310
|
+
*
|
|
311
|
+
* `unseen` holds the lines that may render mid-line only after content the template can't see the end of: what an
|
|
312
|
+
* include or component inserts, or for the first line of a `set`, `macro` or `block` body, whatever comes before it
|
|
313
|
+
* where it is used. Most of that content ends with a line break, so `formatEdits` keeps these lines only when
|
|
314
|
+
* formatting would change them. See `movedLines`. A line starting with a block tag, such as `<p>`, is left out, since
|
|
315
|
+
* HTML shows no space before it.
|
|
316
|
+
*/
|
|
317
|
+
const midLineStarts = (text, parts, standalone) => {
|
|
318
|
+
const loopEnds = /* @__PURE__ */ new Map();
|
|
319
|
+
for (;;) {
|
|
320
|
+
const starts = [];
|
|
321
|
+
const unseen = [];
|
|
322
|
+
const frames = [];
|
|
323
|
+
let settled = true;
|
|
324
|
+
let state = LINE_START;
|
|
325
|
+
const endLoop = (frame, end) => {
|
|
326
|
+
if (loopEnds.get(frame.start) !== end) settled = false;
|
|
327
|
+
loopEnds.set(frame.start, end);
|
|
328
|
+
};
|
|
329
|
+
for (const [index, part] of parts.entries()) {
|
|
330
|
+
if (part.kind === "text") {
|
|
331
|
+
const at = part.from;
|
|
332
|
+
const previous = parts[index - 1];
|
|
333
|
+
const next = parts[index + 1];
|
|
334
|
+
const cut = at > part.start && text[at - 1] === "\n" && !(previous !== void 0 && previous.kind !== "text" && previous.trimAfter);
|
|
335
|
+
const shows = at < part.to || at === part.end && next !== void 0 && next.kind !== "text" && !next.trimBefore && !standalone.has(next.start);
|
|
336
|
+
if (cut && shows && state & MID_LINE) starts.push(at);
|
|
337
|
+
else if (cut && shows && state & UNSEEN && !startsWithBlock(text, at)) unseen.push(at);
|
|
338
|
+
let end = part.to;
|
|
339
|
+
while (end > part.from && " \r".includes(text[end - 1])) end--;
|
|
340
|
+
if (end > part.from) state = text[end - 1] === "\n" ? LINE_START : MID_LINE;
|
|
341
|
+
continue;
|
|
342
|
+
}
|
|
343
|
+
if (part.kind === "output") state = 3;
|
|
344
|
+
if (part.kind !== "tag") continue;
|
|
345
|
+
const role = roleOf(part);
|
|
346
|
+
const name = part.tokens[1]?.value;
|
|
347
|
+
if (name !== void 0 && INSERTS.has(name)) state |= UNSEEN;
|
|
348
|
+
if (role?.kind === "open") {
|
|
349
|
+
frames.push({
|
|
350
|
+
name: role.name,
|
|
351
|
+
start: part.start,
|
|
352
|
+
before: state,
|
|
353
|
+
ends: 0,
|
|
354
|
+
hasElse: false
|
|
355
|
+
});
|
|
356
|
+
if (ELSEWHERE.has(role.name)) state = 5;
|
|
357
|
+
else if (role.name === "for") state |= loopEnds.get(part.start) ?? 0;
|
|
358
|
+
} else if (role?.kind === "branch") {
|
|
359
|
+
const frame = frames.at(-1);
|
|
360
|
+
if (!frame) continue;
|
|
361
|
+
if (frame.name === "for") endLoop(frame, state);
|
|
362
|
+
frame.ends |= state;
|
|
363
|
+
frame.hasElse ||= part.tokens[1]?.value === "else";
|
|
364
|
+
state = frame.before;
|
|
365
|
+
} else if (role?.kind === "close") {
|
|
366
|
+
let frame = frames.pop();
|
|
367
|
+
while (frame && frame.name !== role.name) frame = frames.pop();
|
|
368
|
+
if (!frame) continue;
|
|
369
|
+
if (frame.name === "if") state |= frame.ends | (frame.hasElse ? 0 : frame.before);
|
|
370
|
+
else if (frame.name === "for") {
|
|
371
|
+
if (!frame.hasElse) endLoop(frame, state);
|
|
372
|
+
state |= frame.hasElse ? frame.ends : frame.before;
|
|
373
|
+
} else if (ELSEWHERE.has(frame.name)) state = frame.before;
|
|
374
|
+
if (INSERTED_BODIES.has(frame.name)) state |= UNSEEN;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
if (settled) return {
|
|
378
|
+
starts,
|
|
379
|
+
unseen
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
/**
|
|
384
|
+
* Ranges of the template, as [start, end] offsets, whose lines the formatter leaves as they are, for each line in
|
|
385
|
+
* `starts` that may render mid-line. That line's rendered indentation depends on the indentation of the lines around
|
|
386
|
+
* it, through the indentation Kiln removes inside tags, so the whole top-level tag around it stays. See `midLineStarts`.
|
|
387
|
+
*/
|
|
388
|
+
const keptRanges = (body, starts) => {
|
|
389
|
+
const ranges = [];
|
|
390
|
+
let index = 0;
|
|
391
|
+
for (const start of starts) {
|
|
392
|
+
while (index < body.length && body[index].span.end <= start) index++;
|
|
393
|
+
const node = body[index];
|
|
394
|
+
const range = node && node.span.start <= start && node.type !== "Text" ? [node.span.start, node.span.end] : [start, start];
|
|
395
|
+
const last = ranges.at(-1);
|
|
396
|
+
if (last && range[0] <= last[1]) last[1] = Math.max(last[1], range[1]);
|
|
397
|
+
else ranges.push(range);
|
|
398
|
+
}
|
|
399
|
+
return ranges;
|
|
400
|
+
};
|
|
401
|
+
/**
|
|
260
402
|
* Walks the template once, tracking open block tags and HTML elements, and decides how to treat each line.
|
|
261
403
|
*
|
|
262
404
|
* Returns the lines, which lines may lose trailing whitespace, and the outputs and tags to print.
|
|
@@ -543,11 +685,20 @@ const widthOf = (whitespace, tabWidth) => {
|
|
|
543
685
|
/**
|
|
544
686
|
* Works out the edits that format a template, without checking them. See `formatEdits`.
|
|
545
687
|
*/
|
|
546
|
-
const planEdits = (text, parts, options) => {
|
|
688
|
+
const planEdits = (text, parts, kept, options) => {
|
|
547
689
|
const { useTabs, tabWidth } = options;
|
|
548
690
|
const unit = useTabs ? " " : " ".repeat(tabWidth);
|
|
549
691
|
const indentOfWidth = (width) => useTabs ? " ".repeat(Math.floor(width / tabWidth)) + " ".repeat(width % tabWidth) : " ".repeat(width);
|
|
550
692
|
const { lines, trimEnd, delimiters } = planLines(text, parts);
|
|
693
|
+
let range = 0;
|
|
694
|
+
for (const [index, line] of lines.entries()) {
|
|
695
|
+
const next = lines[index + 1]?.start ?? text.length + 1;
|
|
696
|
+
while (range < kept.length && kept[range][1] < line.start) range++;
|
|
697
|
+
if (range < kept.length && kept[range][0] < next && (line.kind === "indent" || line.kind === "shift")) lines[index] = {
|
|
698
|
+
kind: "keep",
|
|
699
|
+
start: line.start
|
|
700
|
+
};
|
|
701
|
+
}
|
|
551
702
|
const oldIndent = (line) => {
|
|
552
703
|
const start = lines[line]?.start ?? 0;
|
|
553
704
|
let end = start;
|
|
@@ -613,7 +764,8 @@ const planEdits = (text, parts, options) => {
|
|
|
613
764
|
text: indent
|
|
614
765
|
});
|
|
615
766
|
}
|
|
616
|
-
if (trimEnd[index]
|
|
767
|
+
if (!trimEnd[index] || info.kind === "keep") continue;
|
|
768
|
+
if (index !== lastContent) {
|
|
617
769
|
let from = end;
|
|
618
770
|
while (from > start && /[ \t\r]/.test(text[from - 1])) from--;
|
|
619
771
|
if (from < end && !insideDelimiter(delimiters, from)) edits.push({
|
|
@@ -621,20 +773,43 @@ const planEdits = (text, parts, options) => {
|
|
|
621
773
|
end,
|
|
622
774
|
text: ""
|
|
623
775
|
});
|
|
624
|
-
}
|
|
776
|
+
} else if (text[end - 1] === "\r" && text[end] === "\n") edits.push({
|
|
777
|
+
start: end - 1,
|
|
778
|
+
end,
|
|
779
|
+
text: ""
|
|
780
|
+
});
|
|
625
781
|
}
|
|
782
|
+
const insideIndents = /* @__PURE__ */ new Map();
|
|
626
783
|
for (const { part, line } of delimiters) {
|
|
627
|
-
const indent = newIndent(line) ?? oldIndent(line);
|
|
784
|
+
const indent = newIndent(line) ?? insideIndents.get(line) ?? oldIndent(line);
|
|
785
|
+
const source = text.slice(part.start, part.end);
|
|
628
786
|
const printed = printDelimiter(text, part, indent, unit);
|
|
629
|
-
if (printed !== null && printed !==
|
|
787
|
+
if (printed !== null && printed !== source) edits.push({
|
|
630
788
|
start: part.start,
|
|
631
789
|
end: part.end,
|
|
632
790
|
text: printed
|
|
633
791
|
});
|
|
792
|
+
const lastBreak = (printed ?? source).lastIndexOf("\n");
|
|
793
|
+
if (lastBreak !== -1) {
|
|
794
|
+
const endLine = line + (source.match(/\n/g)?.length ?? 0);
|
|
795
|
+
const after = (printed ?? source).slice(lastBreak + 1);
|
|
796
|
+
insideIndents.set(endLine, /^[ \t]*/.exec(after)?.[0] ?? "");
|
|
797
|
+
}
|
|
634
798
|
}
|
|
635
799
|
return edits.sort((a, b) => a.start - b.start || a.end - b.end);
|
|
636
800
|
};
|
|
637
|
-
|
|
801
|
+
/** Whether `offset` is strictly inside one of `delimiters`, which are in source order. */
|
|
802
|
+
const insideDelimiter = (delimiters, offset) => {
|
|
803
|
+
let low = 0;
|
|
804
|
+
let high = delimiters.length;
|
|
805
|
+
while (low < high) {
|
|
806
|
+
const middle = low + high >>> 1;
|
|
807
|
+
if (delimiters[middle].part.start < offset) low = middle + 1;
|
|
808
|
+
else high = middle;
|
|
809
|
+
}
|
|
810
|
+
const before = delimiters[low - 1];
|
|
811
|
+
return before !== void 0 && offset < before.part.end;
|
|
812
|
+
};
|
|
638
813
|
const applyEdits = (text, edits) => {
|
|
639
814
|
let out = "";
|
|
640
815
|
let position = 0;
|
|
@@ -644,21 +819,62 @@ const applyEdits = (text, edits) => {
|
|
|
644
819
|
}
|
|
645
820
|
return out + text.slice(position);
|
|
646
821
|
};
|
|
647
|
-
/**
|
|
648
|
-
const
|
|
649
|
-
|
|
650
|
-
const
|
|
651
|
-
|
|
822
|
+
/** The lines of a template that may render mid-line, by their start, and how to compare each. */
|
|
823
|
+
const midLinesOf = (text, parts, standalone) => {
|
|
824
|
+
const { starts, unseen } = midLineStarts(text, parts, standalone);
|
|
825
|
+
const kinds = /* @__PURE__ */ new Map();
|
|
826
|
+
for (const start of starts) kinds.set(start, "exact");
|
|
827
|
+
for (const start of unseen) kinds.set(start, "any");
|
|
828
|
+
return {
|
|
829
|
+
starts,
|
|
830
|
+
unseen,
|
|
831
|
+
kinds
|
|
832
|
+
};
|
|
833
|
+
};
|
|
834
|
+
/**
|
|
835
|
+
* Removes whitespace at the start and end of lines, and blank lines, which the formatter may change. With `midLine`,
|
|
836
|
+
* the text starts a line that may render mid-line, so its leading spaces and tabs stay, or for `any`, whether it has any.
|
|
837
|
+
*/
|
|
838
|
+
const normaliseText = (value, midLine) => {
|
|
839
|
+
const indent = midLine ? /^[ \t]*/.exec(value)?.[0] ?? "" : "";
|
|
840
|
+
return (midLine === "any" && indent !== "" ? " " : indent) + value.slice(indent.length).replace(/(?<![ \t\r\f\v])[ \t\r\f\v]+$/gm, "").replace(/^[ \t\f\v]+/gm, "").replace(/\n{2,}/g, "\n");
|
|
841
|
+
};
|
|
842
|
+
/**
|
|
843
|
+
* A copy of a syntax tree without positions or layout, with text normalised and text left empty by that removed.
|
|
844
|
+
* Text starting at one of `midLine` keeps its leading whitespace. See `midLineStarts`.
|
|
845
|
+
*/
|
|
846
|
+
const normaliseTree = (value, midLine) => {
|
|
847
|
+
if (Array.isArray(value)) return value.map((item) => normaliseTree(item, midLine)).filter((item) => !(typeof item === "object" && item !== null && item.type === "Text" && item.value === ""));
|
|
652
848
|
if (typeof value !== "object" || value === null) return value;
|
|
849
|
+
const node = value;
|
|
653
850
|
const copy = {};
|
|
654
851
|
for (const [key, item] of Object.entries(value)) {
|
|
655
852
|
if (key === "span" || key === "nameSpan" || key === "indent") continue;
|
|
656
|
-
copy[key] = key === "value" &&
|
|
853
|
+
copy[key] = key === "value" && node.type === "Text" ? normaliseText(item, midLine.get(node.span?.start ?? -1)) : normaliseTree(item, midLine);
|
|
657
854
|
}
|
|
658
855
|
return copy;
|
|
659
856
|
};
|
|
660
|
-
/**
|
|
661
|
-
const shape = (
|
|
857
|
+
/** A syntax tree as JSON, without the whitespace the formatter may change, so two trees can be compared. */
|
|
858
|
+
const shape = (value, midLine) => JSON.stringify(normaliseTree(value, midLine));
|
|
859
|
+
/**
|
|
860
|
+
* The lines in `unseen` whose rendered indentation formatting changes, as the safety check compares it: those in a
|
|
861
|
+
* top-level statement that differs once formatted. `formatEdits` keeps these, with the statement, as written.
|
|
862
|
+
*/
|
|
863
|
+
const movedLines = (before, after, unseen) => {
|
|
864
|
+
if (before.body.length !== after.body.length) return [...unseen];
|
|
865
|
+
const moved = [];
|
|
866
|
+
let index = 0;
|
|
867
|
+
for (const [position, node] of before.body.entries()) {
|
|
868
|
+
const inside = [];
|
|
869
|
+
for (; index < unseen.length; index++) {
|
|
870
|
+
const start = unseen[index];
|
|
871
|
+
if (start >= node.span.end) break;
|
|
872
|
+
if (start >= node.span.start) inside.push(start);
|
|
873
|
+
}
|
|
874
|
+
if (inside.length > 0 && shape(node, before.kinds) !== shape(after.body[position], after.kinds)) moved.push(...inside);
|
|
875
|
+
}
|
|
876
|
+
return moved;
|
|
877
|
+
};
|
|
662
878
|
/**
|
|
663
879
|
* Works out the edits that format a template, in source order and never overlapping. Editors apply these so the cursor and undo history stay put. See `format` for what it throws.
|
|
664
880
|
*/
|
|
@@ -670,14 +886,46 @@ const formatEdits = (text, options = {}) => {
|
|
|
670
886
|
}
|
|
671
887
|
const tabWidth = options.tabWidth ?? 4;
|
|
672
888
|
if (!Number.isInteger(tabWidth) || tabWidth < 1) throw new RangeError(`tabWidth must be a whole number of at least 1, but got ${tabWidth}`);
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
tabWidth
|
|
676
|
-
});
|
|
889
|
+
const { parts, standalone } = scanControlled(text);
|
|
890
|
+
const before = midLinesOf(text, parts, standalone);
|
|
677
891
|
const range = options.range;
|
|
678
|
-
|
|
679
|
-
const
|
|
680
|
-
|
|
892
|
+
/** The edits, keeping lines starting at `starts` as written, with the top-level tags around them. */
|
|
893
|
+
const plan = (starts) => {
|
|
894
|
+
const edits = planEdits(text, parts, keptRanges(parsed.ast.body, starts), {
|
|
895
|
+
useTabs: options.useTabs ?? true,
|
|
896
|
+
tabWidth
|
|
897
|
+
});
|
|
898
|
+
return range ? edits.filter((edit) => edit.end >= range.start && edit.start <= range.end) : edits;
|
|
899
|
+
};
|
|
900
|
+
const formatWith = (starts) => {
|
|
901
|
+
const edits = plan(starts);
|
|
902
|
+
const formatted = applyEdits(text, edits);
|
|
903
|
+
const changed = parse(formatted, { isTest });
|
|
904
|
+
const scanned = scanControlled(formatted);
|
|
905
|
+
return {
|
|
906
|
+
edits,
|
|
907
|
+
changed,
|
|
908
|
+
kinds: midLinesOf(formatted, scanned.parts, scanned.standalone).kinds
|
|
909
|
+
};
|
|
910
|
+
};
|
|
911
|
+
let result = formatWith(before.starts);
|
|
912
|
+
let kept = before.starts;
|
|
913
|
+
for (let unseen = before.unseen; result.changed.problems.length === 0;) {
|
|
914
|
+
const moved = movedLines({
|
|
915
|
+
body: parsed.ast.body,
|
|
916
|
+
kinds: before.kinds
|
|
917
|
+
}, {
|
|
918
|
+
body: result.changed.ast.body,
|
|
919
|
+
kinds: result.kinds
|
|
920
|
+
}, unseen);
|
|
921
|
+
if (moved.length === 0) break;
|
|
922
|
+
kept = [...kept, ...moved].sort((a, b) => a - b);
|
|
923
|
+
const done = new Set(moved);
|
|
924
|
+
unseen = unseen.filter((start) => !done.has(start));
|
|
925
|
+
result = formatWith(kept);
|
|
926
|
+
}
|
|
927
|
+
const { edits, changed, kinds } = result;
|
|
928
|
+
if (changed.problems.length > 0 || shape(changed.ast, kinds) !== shape(parsed.ast, before.kinds)) throw new KilnFormatError("Formatting would have changed what this template renders, so nothing was changed. This is a bug in Kiln's formatter.");
|
|
681
929
|
return edits;
|
|
682
930
|
};
|
|
683
931
|
/**
|
|
@@ -694,4 +942,4 @@ const format = (text, options = {}) => applyEdits(text, formatEdits(text, option
|
|
|
694
942
|
//#endregion
|
|
695
943
|
export { format as n, formatEdits as r, KilnFormatError as t };
|
|
696
944
|
|
|
697
|
-
//# sourceMappingURL=format-
|
|
945
|
+
//# sourceMappingURL=format-8A_kD0sb.js.map
|