@lucidkiln/core 1.3.0 → 1.4.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,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.4.0
4
+
5
+ - New `builtins` export, which lists Kiln's own function, filter and test names. ([8d99639](https://github.com/buildlucid/kiln/commit/8d99639916ce3dfb920d567ed4de9069ec739cd7))
6
+ - New `export` tag. A template can give your code a value without rendering, which `evaluate` works out and `analyze` lists in `exports`. ([1e5cff7](https://github.com/buildlucid/kiln/commit/1e5cff72e7416abbc4695334e405bd38e5986f01))
7
+
3
8
  ## 1.3.0
4
9
 
5
10
  - `analyze` now reports each function call and its arguments in `calls`, with the value of every literal argument. ([72780ec](https://github.com/buildlucid/kiln/commit/72780ec6a827a8d416141b0e8921efa22bcd5a65))
@@ -219,6 +219,13 @@ type Statement = {
219
219
  body: Statement[];
220
220
  span: Span;
221
221
  } |
222
+ /** A value the host reads with `evaluate`, never run during a render. */
223
+ {
224
+ type: "Export";
225
+ name: string;
226
+ value: Expression;
227
+ span: Span;
228
+ } |
222
229
  /** `rest` names the hash that collects undeclared variables, as in `...attributes`, or is null. */
223
230
  {
224
231
  type: "Props";
@@ -347,4 +354,4 @@ type TemplateNode = {
347
354
  declare const TYPE_NAMES: readonly ["null", "boolean", "number", "string", "array", "hash", "set", "date", "markup", "object"];
348
355
  //#endregion
349
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 };
350
- //# sourceMappingURL=ast-DDhHuwaY.d.ts.map
357
+ //# sourceMappingURL=ast-DzzSn9tS.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ast-DDhHuwaY.d.ts","names":[],"sources":["../src/source.ts","../src/parser/ast.ts"],"mappings":";;KAGY;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AY,MAAM;;EACpD;EAAkB;EAAc,MAAM;EAAa,MAAM;;;;EAEzD;EAAgB;EAAc,OAAO;EAAY,MAAM;;;;EAEvD;EAAe,OAAO;EAAa;EAAqB,MAAM;;EAC9D;EAAiB,UAAU;EAAY,MAAM;;EAC7C;EAAe;EAAc,MAAM;EAAa,MAAM;;EAExD;EACA,UAAU;EACV,MAAM;EACN;EACA,MAAM;;EAGN;EACA,UAAU;EACV,MAAM;EACN;IAAS;IAAc,MAAM;IAAa,MAAM;;;EAEhD,MAAM;EACN,MAAM;;EAEJ;EAAc;EAAc,MAAM;EAAa,MAAM;;;;;;;;;EAQvD;EACA,UAAU;EACV,MAAM;EACN,MAAM;EACN;EACA;IAAY;IAAuB;;EACnC,MAAM;;EAGN;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;;;;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 { an as KilnSyntaxError } from "./source-BbikGqIb.js";
3
- import { n as format, t as KilnFormatError } from "./format-Di6-GUtH.js";
2
+ import { an as KilnSyntaxError } from "./source-C2pjTx-Y.js";
3
+ import { n as format, t as KilnFormatError } from "./format-A7Ol0apX.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,4 +1,4 @@
1
- import { c as PropType, g as Span, h as Source, m as Position, r as EscapeStrategy } from "./ast-DDhHuwaY.js";
1
+ import { c as PropType, g as Span, h as Source, m as Position, r as EscapeStrategy } from "./ast-DzzSn9tS.js";
2
2
  //#region src/errors.d.ts
3
3
  type Diagnostic = {
4
4
  /** A stable kebab-case code, such as `unknown-filter`. */
@@ -177,6 +177,13 @@ type CallArgument = {
177
177
  /** The literal's value, or `null` when the argument is computed. */
178
178
  value: null | boolean | number | string;
179
179
  };
180
+ /** A top-level `export`: its literal value, or `literal: false` when only `evaluate` can work it out. */
181
+ type TemplateExport = {
182
+ name: string;
183
+ literal: boolean;
184
+ /** The literal's value, or `null` when the export is computed. */
185
+ value: null | boolean | number | string;
186
+ };
180
187
  type FunctionCall = {
181
188
  name: string;
182
189
  args: CallArgument[];
@@ -206,6 +213,7 @@ type Analysis = {
206
213
  templates: TemplateReference[];
207
214
  blocks: string[];
208
215
  macros: string[];
216
+ exports: TemplateExport[];
209
217
  };
210
218
  //#endregion
211
219
  //#region src/compiler/precompiled.d.ts
@@ -389,8 +397,13 @@ type Kiln<State = undefined, Schema extends KilnSchema = DefaultSchema> = {
389
397
  renderStream<Name extends TemplateName<Schema["templates"]>>(name: Name, ...args: RenderArguments<TemplateContext<Name, Schema["templates"]>, State>): Promise<ReadableStream<Uint8Array>>;
390
398
  /** Parses and checks a template without rendering it. Pass `source` to check unsaved text. */
391
399
  check(name: string, source?: string): Promise<Diagnostic[]>;
392
- /** Reports what a template uses: variables, props, functions, filters, tests, templates, blocks and macros. */
400
+ /** Reports what a template uses: variables, props, functions, filters, tests, templates, blocks, macros and exports. */
393
401
  analyze(name: string, source?: string): Promise<Analysis>;
402
+ /**
403
+ * Works out one of a template's exports without rendering it, waiting for async functions. Resolves to `undefined`
404
+ * when the template has no export with that name.
405
+ */
406
+ evaluate(name: TemplateName<Schema["templates"]>, exportName: string, ...options: undefined extends State ? [options?: RenderOptions<State>] : [options: RenderOptions<State>]): Promise<unknown>;
394
407
  /**
395
408
  * Compiles a template to the source of a JavaScript module, at build time. Loaders return the module's default
396
409
  * export in place of the source. Rejects with `KilnSyntaxError` when the template has problems.
@@ -407,6 +420,12 @@ type Kiln<State = undefined, Schema extends KilnSchema = DefaultSchema> = {
407
420
  * ```
408
421
  */
409
422
  declare const withRender: <Call extends RenderCall>(fn: Call) => RenderAware<Call>;
423
+ /** Kiln's own function, filter and test names, sorted and including reserved ones, for hosts that stop a name replacing one. */
424
+ declare const builtins: {
425
+ readonly functions: readonly string[];
426
+ readonly filters: readonly string[];
427
+ readonly tests: readonly string[];
428
+ };
410
429
  /**
411
430
  * Creates a Kiln environment: the loader, functions, filters, tests, globals and options every render uses.
412
431
  *
@@ -451,5 +470,5 @@ declare const memoryCache: ({ max }?: {
451
470
  }) => void;
452
471
  };
453
472
  //#endregion
454
- export { FunctionCall as A, StreamedIslands as B, HtmlCheck as C, AnalysedProp as D, PrecompiledTemplate as E, DeferredIslands as F, KilnRenderError as G, islandScript as H, IslandEntry as I, KilnSyntaxError as K, IslandManifest as L, AbortSignalLike as M, KilnCache as N, Analysis as O, RenderInfo as P, IslandMode as R, withRender as S, HtmlChecks as T, streamIslands as U, deferIslands as V, Diagnostic 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, TemplateReference as j, CallArgument as k, KilnTests as l, RenderOptions as m, KilnCallable as n, KilnOptions as o, RenderAware as p, TemplateLocation as q, KilnFilters as r, KilnSchema as s, Kiln as t, KilnTypes as u, TypeChecks as v, HtmlCheckLevel as w, memoryLoader as x, createKiln as y, JsonValue as z };
455
- //# sourceMappingURL=environment-CgQfwDAJ.d.ts.map
473
+ export { CallArgument as A, IslandMode as B, withRender as C, PrecompiledTemplate as D, HtmlChecks as E, KilnCache as F, streamIslands as G, StreamedIslands as H, RenderInfo as I, KilnSyntaxError as J, Diagnostic as K, DeferredIslands as L, TemplateExport as M, TemplateReference as N, AnalysedProp as O, AbortSignalLike as P, IslandEntry as R, memoryLoader as S, HtmlCheckLevel as T, deferIslands as U, JsonValue as V, islandScript as W, TemplateLocation as Y, TemplateName as _, KilnGlobals as a, createKiln as b, KilnTemplates as c, Limits as d, Loader as f, TemplateContext as g, TemplateBlock as h, KilnFunctions as i, FunctionCall as j, Analysis as k, KilnTests as l, RenderOptions as m, KilnCallable as n, KilnOptions as o, RenderAware as p, KilnRenderError as q, KilnFilters as r, KilnSchema as s, Kiln as t, KilnTypes as u, TypeChecks as v, HtmlCheck as w, memoryCache as x, builtins as y, IslandManifest as z };
474
+ //# sourceMappingURL=environment-CFAjojgY.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"environment-CFAjojgY.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;;;KA6KzB,aAAa;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,OAAO;;;;;;;cAoHF,eAAY,WAErB,wBAAwB,uBACxB,qBAAqB,yBACtB,KAAK;EAAoB;;;;;;;;;;cAkBf,gBAAW;EAAsB;;;;;;;;;;;;EA0B1B,UAAA;IAAE"}
@@ -1,5 +1,5 @@
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";
1
+ import { an as KilnSyntaxError, on as createDiagnostic, r as builtinTests, t as Source } from "./source-C2pjTx-Y.js";
2
+ import { r as scanParts, t as parse } from "./parser-BZpRlGWi.js";
3
3
  //#region src/formatter/delimiters.ts
4
4
  const KEYWORDS = /* @__PURE__ */ new Set([
5
5
  "and",
@@ -694,4 +694,4 @@ const format = (text, options = {}) => applyEdits(text, formatEdits(text, option
694
694
  //#endregion
695
695
  export { format as n, formatEdits as r, KilnFormatError as t };
696
696
 
697
- //# sourceMappingURL=format-Di6-GUtH.js.map
697
+ //# sourceMappingURL=format-A7Ol0apX.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"format-Di6-GUtH.js","names":[],"sources":["../src/formatter/delimiters.ts","../src/formatter/format.ts"],"sourcesContent":["import type { DelimitedPart, Token } from \"../lexer/lexer.js\";\n\n/** A token as the formatter prints it: its source text, unchanged. An interpolated string is one piece. */\ntype Piece = {\n\ttype: Token[\"type\"];\n\ttext: string;\n\tstart: number;\n\tend: number;\n};\n\n/**\n * What a piece does, where that changes its spacing.\n *\n * - `word`: a name, number or string.\n * - `keyword`: a tag's name, or a name such as `and` or `in`. A bracket after it groups rather than calls.\n * - `unary`: a sign that makes a number negative or positive, written against its operand.\n * - `tight`: `.`, `?.`, `..` and a filter's `|`, with no space either side.\n * - `key`: the colon after a key or named argument, or `?` and `?:` marking an optional key in `props`.\n * - `call`: a bracket that calls or indexes the piece before it.\n * - `open`, `close`: other brackets.\n * - `spaced`: operators with a space either side.\n */\ntype Role =\n\t| \"word\"\n\t| \"keyword\"\n\t| \"unary\"\n\t| \"tight\"\n\t| \"key\"\n\t| \"call\"\n\t| \"open\"\n\t| \"close\"\n\t| \"comma\"\n\t| \"spread\"\n\t| \"spaced\";\n\nconst KEYWORDS = new Set([\n\t\"and\",\n\t\"or\",\n\t\"not\",\n\t\"in\",\n\t\"is\",\n\t\"starts\",\n\t\"ends\",\n\t\"with\",\n\t\"as\",\n\t\"import\",\n\t\"ignore\",\n\t\"missing\",\n]);\n\n/** Joins each interpolated string's tokens, from `stringStart` to its matching `stringEnd`, into one piece. */\nconst toPieces = (source: string, tokens: readonly Token[]): Piece[] => {\n\tconst pieces: Piece[] = [];\n\tfor (let index = 0; index < tokens.length; index++) {\n\t\tconst token = tokens[index] as Token;\n\t\tlet end = token.end;\n\t\tif (token.type === \"stringStart\") {\n\t\t\tlet depth = 0;\n\t\t\tfor (; index < tokens.length; index++) {\n\t\t\t\tconst inner = tokens[index] as Token;\n\t\t\t\tif (inner.type === \"stringStart\") depth++;\n\t\t\t\telse if (inner.type === \"stringEnd\" && --depth === 0) break;\n\t\t\t}\n\t\t\tend = (tokens[Math.min(index, tokens.length - 1)] as Token).end;\n\t\t}\n\t\tpieces.push({\n\t\t\ttype: token.type === \"stringStart\" ? \"string\" : token.type,\n\t\t\ttext: source.slice(token.start, end),\n\t\t\tstart: token.start,\n\t\t\tend,\n\t\t});\n\t}\n\treturn pieces;\n};\n\n/** Works out each piece's role. `isTag` means the first piece is a tag's name. */\nconst rolesOf = (pieces: readonly Piece[], isTag: boolean): Role[] => {\n\tconst roles: Role[] = [];\n\t// In `props`, `|` joins types and `?:` marks an optional key, until `=` starts a default value.\n\tconst props = isTag && pieces[0]?.text === \"props\";\n\tlet inDefault = false;\n\t// Open `?`s at each bracket depth, so a conditional's `:` can be told from a key's.\n\tconst conditionals: number[] = [0];\n\n\tfor (const [index, piece] of pieces.entries()) {\n\t\tconst previous = roles[index - 1];\n\t\tconst depth = conditionals.length - 1;\n\t\tconst types = props && !inDefault;\n\t\tlet role: Role;\n\n\t\tif (piece.type !== \"punct\") {\n\t\t\trole =\n\t\t\t\t(isTag && index === 0) ||\n\t\t\t\t(piece.type === \"name\" && KEYWORDS.has(piece.text))\n\t\t\t\t\t? \"keyword\"\n\t\t\t\t\t: \"word\";\n\t\t} else {\n\t\t\tswitch (piece.text) {\n\t\t\t\tcase \"(\":\n\t\t\t\tcase \"[\":\n\t\t\t\t\trole = previous === \"word\" || previous === \"close\" ? \"call\" : \"open\";\n\t\t\t\t\tconditionals.push(0);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"{\":\n\t\t\t\t\trole = \"open\";\n\t\t\t\t\tconditionals.push(0);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \")\":\n\t\t\t\tcase \"]\":\n\t\t\t\tcase \"}\":\n\t\t\t\t\trole = \"close\";\n\t\t\t\t\tif (conditionals.length > 1) conditionals.pop();\n\t\t\t\t\tbreak;\n\t\t\t\tcase \",\":\n\t\t\t\t\trole = \"comma\";\n\t\t\t\t\tif (props && depth === 0) inDefault = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"...\":\n\t\t\t\t\trole = \"spread\";\n\t\t\t\t\tbreak;\n\t\t\t\tcase \".\":\n\t\t\t\tcase \"?.\":\n\t\t\t\tcase \"..\":\n\t\t\t\t\trole = \"tight\";\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"|\":\n\t\t\t\t\trole = types ? \"spaced\" : \"tight\";\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"-\":\n\t\t\t\tcase \"+\":\n\t\t\t\t\trole =\n\t\t\t\t\t\tprevious === undefined ||\n\t\t\t\t\t\t(previous !== \"word\" && previous !== \"close\")\n\t\t\t\t\t\t\t? \"unary\"\n\t\t\t\t\t\t\t: \"spaced\";\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"?\":\n\t\t\t\tcase \"?:\":\n\t\t\t\t\trole = types ? \"key\" : \"spaced\";\n\t\t\t\t\tif (piece.text === \"?\" && !types) {\n\t\t\t\t\t\tconditionals[depth] = (conditionals[depth] ?? 0) + 1;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase \":\":\n\t\t\t\t\tif ((conditionals[depth] ?? 0) > 0) {\n\t\t\t\t\t\tconditionals[depth] = (conditionals[depth] ?? 0) - 1;\n\t\t\t\t\t\trole = \"spaced\";\n\t\t\t\t\t} else role = \"key\";\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\trole = \"spaced\";\n\t\t\t\t\tif (props && depth === 0 && piece.text === \"=\") inDefault = true;\n\t\t\t}\n\t\t}\n\t\troles.push(role);\n\t}\n\treturn roles;\n};\n\n/** The gap between two pieces: a space or nothing. */\nconst gapBetween = (\n\tprevious: Piece,\n\tpreviousRole: Role,\n\tpiece: Piece,\n\trole: Role,\n): string => {\n\tif (role === \"comma\" || role === \"tight\" || role === \"key\" || role === \"call\")\n\t\treturn \"\";\n\tif (role === \"close\") {\n\t\treturn piece.text === \"}\" && previous.text !== \"{\" ? \" \" : \"\";\n\t}\n\tif (previousRole === \"tight\" || previousRole === \"unary\") return \"\";\n\tif (previousRole === \"spread\") return \"\";\n\tif (previousRole === \"open\" || previousRole === \"call\") {\n\t\treturn previous.text === \"{\" ? \" \" : \"\";\n\t}\n\treturn \" \";\n};\n\n/**\n * 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.\n *\n * Returns null for a delimiter that never closed, which the formatter leaves as it is.\n */\nexport const printDelimiter = (\n\tsource: string,\n\tpart: DelimitedPart,\n\tindent: string,\n\tunit: string,\n): string | null => {\n\tconst tokens = part.tokens;\n\tconst open = tokens[0];\n\tconst close = tokens[tokens.length - 1];\n\tif (!open || !close || close.value === \"\" || tokens.length < 3) return null;\n\n\tconst pieces = toPieces(source, tokens.slice(1, -1));\n\tconst roles = rolesOf(pieces, part.kind === \"tag\");\n\tlet out = open.value;\n\tlet previousEnd = part.start + open.value.length;\n\t// The line each open bracket started on. Brackets opened on the same line add one step between them.\n\tconst openedOn: number[] = [];\n\tlet line = 0;\n\t/** Steps of indentation for a new line, once `closers` brackets at its start have closed. */\n\tconst steps = (closers: number) =>\n\t\tnew Set(openedOn.slice(0, openedOn.length - closers)).size;\n\n\tfor (const [index, piece] of pieces.entries()) {\n\t\tconst role = roles[index] as Role;\n\t\tconst gap = source.slice(previousEnd, piece.start);\n\t\tif (gap.includes(\"\\n\")) {\n\t\t\tline++;\n\t\t\t// Closing brackets at the start of a line line up with the line that opened them. Only those on this line count.\n\t\t\tlet closers = 0;\n\t\t\twhile (\n\t\t\t\troles[index + closers] === \"close\" &&\n\t\t\t\t(closers === 0 ||\n\t\t\t\t\t!source\n\t\t\t\t\t\t.slice(\n\t\t\t\t\t\t\t(pieces[index + closers - 1] as Piece).end,\n\t\t\t\t\t\t\t(pieces[index + closers] as Piece).start,\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.includes(\"\\n\"))\n\t\t\t) {\n\t\t\t\tclosers++;\n\t\t\t}\n\t\t\tout += `\\n${indent}${unit.repeat(closers > 0 ? steps(closers) : Math.max(steps(0), 1))}`;\n\t\t} else if (index === 0) out += \" \";\n\t\telse {\n\t\t\tout += gapBetween(\n\t\t\t\tpieces[index - 1] as Piece,\n\t\t\t\troles[index - 1] as Role,\n\t\t\t\tpiece,\n\t\t\t\trole,\n\t\t\t);\n\t\t}\n\t\tout += piece.text;\n\t\tif (role === \"open\" || role === \"call\") openedOn.push(line);\n\t\telse if (role === \"close\") openedOn.pop();\n\t\tpreviousEnd = piece.end;\n\t}\n\n\tconst closeStart = part.end - close.value.length;\n\tout += source.slice(previousEnd, closeStart).includes(\"\\n\")\n\t\t? `\\n${indent}`\n\t\t: \" \";\n\treturn out + close.value;\n};\n","import { builtinTests } from \"../builtins/functions.js\";\nimport { KilnSyntaxError } from \"../errors.js\";\nimport { createDiagnostic } from \"../errors.js\";\nimport { type DelimitedPart, type Part, scanParts } from \"../lexer/lexer.js\";\nimport { parse } from \"../parser/parser.js\";\nimport { Source } from \"../source.js\";\nimport { printDelimiter } from \"./delimiters.js\";\n\nexport type FormatOptions = {\n\t/** Indent with tabs. Default `true`. */\n\tuseTabs?: boolean;\n\t/** Spaces per step without tabs, and the width of a tab when moving lines. A whole number of at least 1. Default `4`. */\n\ttabWidth?: number;\n\t/** Only format lines that overlap this range of offsets. */\n\trange?: { start: number; end: number };\n};\n\n/** Replace `start` to `end` of the original source with `text`. */\nexport type FormatEdit = { start: number; end: number; text: string };\n\n/** Thrown when formatting would have changed what a template renders. That is a bug in the formatter. */\nexport class KilnFormatError extends Error {\n\toverride name = \"KilnFormatError\";\n}\n\n/**\n * How the formatter treats one line.\n *\n * - `indent`: set its indentation to `level` steps.\n * - `shift`: move it by as much as line `anchor` moved, keeping its own indentation relative to it. For scripts, styles and comments.\n * - `keep`: leave it alone, for `<pre>`, `<textarea>`, `verbatim`, text inside attribute values, and the body of a `set` or `apply` whose tag shares its line.\n * - `inside`: it starts inside an output or tag, which `printDelimiter` indents.\n */\ntype Line =\n\t| { kind: \"indent\"; start: number; level: number }\n\t| { kind: \"shift\"; start: number; anchor: number }\n\t| { kind: \"keep\" | \"inside\"; start: number };\n\ntype Frame = { kind: \"kiln\" | \"html\"; name: string };\n\n/**\n * Where the scanner is in the HTML.\n *\n * - `tag`: inside `<name ...>` or `</name>`, which started on line `line`. `inner` counts block tags open inside it.\n * - `raw`: inside `<script>` or `<style>`, or kept as written inside `<pre>`, `<textarea>` and the like.\n * - `kept`: inside the body of block tag `name`, output as written: `verbatim`, or a `set` or `apply` whose tag shares\n * its line, where Kiln doesn't remove the body's indentation. `depth` counts the tags of that name open.\n */\ntype Mode =\n\t| { kind: \"data\" }\n\t| {\n\t\t\tkind: \"tag\";\n\t\t\tname: string;\n\t\t\tclosing: boolean;\n\t\t\tquote: string | null;\n\t\t\tline: number;\n\t\t\tatLineStart: boolean;\n\t\t\tinner: number;\n\t }\n\t| { kind: \"comment\"; anchor: number; level: number }\n\t| { kind: \"raw\"; name: string; keep: boolean; anchor: number; level: number }\n\t| { kind: \"kept\"; name: string; depth: number; level: number };\n\nconst VOID_ELEMENTS = new Set([\n\t\"area\",\n\t\"base\",\n\t\"br\",\n\t\"col\",\n\t\"embed\",\n\t\"hr\",\n\t\"img\",\n\t\"input\",\n\t\"link\",\n\t\"meta\",\n\t\"source\",\n\t\"track\",\n\t\"wbr\",\n]);\n\n/** Elements written in `<script>` or `<style>`'s own language, whose lines move together. */\nconst RAW_ELEMENTS = new Set([\"script\", \"style\"]);\n/** Elements whose whitespace shows on the page. Nothing closes `<plaintext>`. */\nconst KEPT_ELEMENTS = new Set([\n\t\"pre\",\n\t\"textarea\",\n\t\"xmp\",\n\t\"listing\",\n\t\"plaintext\",\n]);\n\n/** Whether `</name` starts at `index`, as a whole tag name. */\nconst closesElement = (text: string, index: number, name: string): boolean => {\n\tif (name === \"plaintext\") return false;\n\tconst end = index + 2 + name.length;\n\treturn (\n\t\ttext.slice(index, end).toLowerCase() === `</${name}` &&\n\t\t(end === text.length || /[\\s/>]/.test(text[end] as string))\n\t);\n};\n\n/**\n * Whether a line starting with `trimmed` begins with the tag that ends the outermost `kept` body, and the formatter\n * may indent it. It may when Kiln removes the whitespace before the tag: a `-` trim marker, or a tag alone on its line.\n */\nconst endsKept = (\n\ttrimmed: string,\n\tmode: Extract<Mode, { kind: \"kept\" }>,\n): boolean => {\n\tconst match = /^\\{%(-?)\\s*end([A-Za-z]+)\\s*-?%\\}([^\\n]*)/.exec(trimmed);\n\treturn (\n\t\tmatch !== null &&\n\t\tmatch[2] === mode.name &&\n\t\tmode.depth === 1 &&\n\t\t(match[1] === \"-\" || /^[ \\t\\r]*$/.test(match[3] as string))\n\t);\n};\n\n/** Elements that the next of these siblings closes, such as a `<li>` without `</li>`. */\nconst CLOSED_BY: Record<string, readonly string[]> = {\n\tli: [\"li\"],\n\tdt: [\"dt\", \"dd\"],\n\tdd: [\"dt\", \"dd\"],\n\tp: [\"p\"],\n\toption: [\"option\"],\n\ttr: [\"tr\"],\n\ttd: [\"td\", \"th\"],\n\tth: [\"td\", \"th\"],\n\tthead: [\"tbody\", \"tfoot\"],\n\ttbody: [\"tbody\", \"tfoot\"],\n};\n\n/** Block tags that hold a body, and so indent what follows. */\nconst BLOCK_TAGS = new Set([\n\t\"if\",\n\t\"for\",\n\t\"set\",\n\t\"block\",\n\t\"component\",\n\t\"fill\",\n\t\"slot\",\n\t\"macro\",\n\t\"with\",\n\t\"cache\",\n\t\"island\",\n\t\"add\",\n\t\"apply\",\n\t\"autoescape\",\n\t\"verbatim\",\n]);\n\n/** What a tag does to indentation: opens a body, starts another branch of one, closes one, or nothing. */\nconst roleOf = (\n\tpart: DelimitedPart,\n): { kind: \"open\" | \"close\"; name: string } | { kind: \"branch\" } | null => {\n\tconst name = part.tokens[1];\n\tif (name?.type !== \"name\") return null;\n\tif (BLOCK_TAGS.has(name.value)) {\n\t\tif (\n\t\t\tname.value === \"set\" &&\n\t\t\tpart.tokens.some((token) => token.type === \"punct\" && token.value === \"=\")\n\t\t) {\n\t\t\treturn null;\n\t\t}\n\t\t// `{% block title page.title %}` is the short form, with no body.\n\t\tif (name.value === \"block\" && part.tokens.length > 4) return null;\n\t\treturn { kind: \"open\", name: name.value };\n\t}\n\tif (name.value === \"else\" || name.value === \"elseif\")\n\t\treturn { kind: \"branch\" };\n\tif (name.value.startsWith(\"end\")) {\n\t\treturn { kind: \"close\", name: name.value.slice(3) };\n\t}\n\treturn null;\n};\n\nconst isLetter = (char: string | undefined) =>\n\tchar !== undefined && /[A-Za-z]/.test(char);\n\nconst isTest = (name: string) => Object.hasOwn(builtinTests, name);\n\n/** The start offset of every line. */\nconst lineStarts = (text: string): number[] => {\n\tconst starts = [0];\n\tfor (let index = text.indexOf(\"\\n\"); index !== -1;) {\n\t\tstarts.push(index + 1);\n\t\tindex = text.indexOf(\"\\n\", index + 1);\n\t}\n\treturn starts;\n};\n\n/**\n * Walks the template once, tracking open block tags and HTML elements, and decides how to treat each line.\n *\n * Returns the lines, which lines may lose trailing whitespace, and the outputs and tags to print.\n */\nconst planLines = (text: string, parts: readonly Part[]) => {\n\tconst starts = lineStarts(text);\n\tconst lines: Line[] = [];\n\tconst trimEnd: boolean[] = [];\n\tconst stack: Frame[] = [];\n\tlet mode: Mode = { kind: \"data\" };\n\tlet atLineStart = true;\n\t// A line that starts where the next part does, recorded when that part begins.\n\tlet pendingLine = -1;\n\n\tconst lineText = (index: number) =>\n\t\ttext.slice(starts[index], starts[index + 1] ?? text.length);\n\t/** Whether only spaces and tabs come between `offset` and the end of its line. */\n\tconst endsLine = (offset: number) => {\n\t\tlet index = offset;\n\t\twhile (index < text.length && \" \\t\\r\".includes(text[index] as string)) {\n\t\t\tindex++;\n\t\t}\n\t\treturn index === text.length || text[index] === \"\\n\";\n\t};\n\tconst current = () => lines.length - 1;\n\n\t/** Lowers the current line's level when a closing tag comes before anything else on it. */\n\tconst outdent = (line: number, level: number, first: boolean) => {\n\t\tconst info = lines[line];\n\t\tif (first && info?.kind === \"indent\") {\n\t\t\tinfo.level = Math.min(info.level, level);\n\t\t}\n\t};\n\n\tconst levelOf = (line: number): number => {\n\t\tconst info = lines[line];\n\t\treturn info?.kind === \"indent\" ? info.level : stack.length;\n\t};\n\n\t/** Records how to treat the line that starts at `start`, from the current state. */\n\tconst beginLine = (start: number) => {\n\t\tconst index = lines.length;\n\t\tconst trimmed = lineText(index).trimStart();\n\t\tatLineStart = true;\n\t\tswitch (mode.kind) {\n\t\t\tcase \"data\":\n\t\t\t\tlines.push({ kind: \"indent\", start, level: stack.length });\n\t\t\t\treturn;\n\t\t\tcase \"tag\": {\n\t\t\t\tif (mode.quote !== null) {\n\t\t\t\t\tlines.push({ kind: \"keep\", start });\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst base = levelOf(mode.line);\n\t\t\t\tconst level =\n\t\t\t\t\ttrimmed.startsWith(\">\") || trimmed.startsWith(\"/>\")\n\t\t\t\t\t\t? base\n\t\t\t\t\t\t: base + 1 + mode.inner;\n\t\t\t\tlines.push({ kind: \"indent\", start, level });\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"comment\":\n\t\t\t\tlines.push(\n\t\t\t\t\ttrimmed.startsWith(\"-->\")\n\t\t\t\t\t\t? { kind: \"indent\", start, level: mode.level }\n\t\t\t\t\t\t: { kind: \"shift\", start, anchor: mode.anchor },\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\tcase \"raw\":\n\t\t\t\tif (mode.keep) lines.push({ kind: \"keep\", start });\n\t\t\t\telse if (closesElement(trimmed, 0, mode.name)) {\n\t\t\t\t\tlines.push({ kind: \"indent\", start, level: mode.level });\n\t\t\t\t} else lines.push({ kind: \"shift\", start, anchor: mode.anchor });\n\t\t\t\treturn;\n\t\t\tcase \"kept\":\n\t\t\t\tlines.push(\n\t\t\t\t\tendsKept(trimmed, mode)\n\t\t\t\t\t\t? { kind: \"indent\", start, level: mode.level }\n\t\t\t\t\t\t: { kind: \"keep\", start },\n\t\t\t\t);\n\t\t}\n\t};\n\n\t/** Whether trailing whitespace on a line ending here can go. Not inside attribute values or kept elements. */\n\tconst canTrimHere = () =>\n\t\t!(mode.kind === \"tag\" && mode.quote !== null) &&\n\t\t!(mode.kind === \"raw\" && mode.keep) &&\n\t\tmode.kind !== \"kept\";\n\n\tconst finishTag = (\n\t\ttag: Extract<Mode, { kind: \"tag\" }>,\n\t\tselfClosing: boolean,\n\t) => {\n\t\tmode = { kind: \"data\" };\n\t\tconst name = tag.name;\n\t\tif (tag.closing) {\n\t\t\t// Close the nearest open element of this name, without crossing a block tag.\n\t\t\tfor (let index = stack.length - 1; index >= 0; index--) {\n\t\t\t\tconst frame = stack[index] as Frame;\n\t\t\t\tif (frame.kind === \"kiln\") break;\n\t\t\t\tif (frame.name === name) {\n\t\t\t\t\tstack.length = index;\n\t\t\t\t\toutdent(tag.line, index, tag.atLineStart);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (name.startsWith(\"!\") || selfClosing || VOID_ELEMENTS.has(name)) return;\n\t\tif (RAW_ELEMENTS.has(name) || KEPT_ELEMENTS.has(name)) {\n\t\t\tmode = {\n\t\t\t\tkind: \"raw\",\n\t\t\t\tname,\n\t\t\t\tkeep: KEPT_ELEMENTS.has(name),\n\t\t\t\tanchor: tag.line,\n\t\t\t\tlevel: stack.length,\n\t\t\t};\n\t\t\treturn;\n\t\t}\n\t\tconst top = stack[stack.length - 1];\n\t\tif (top?.kind === \"html\" && CLOSED_BY[top.name]?.includes(name)) {\n\t\t\tstack.pop();\n\t\t\toutdent(tag.line, stack.length, tag.atLineStart);\n\t\t}\n\t\tstack.push({ kind: \"html\", name });\n\t};\n\n\t/** Starts a tag at `index` if one starts there, and returns where scanning continues. */\n\tconst startTag = (index: number, closing: boolean): number => {\n\t\tconst nameStart = index + (closing ? 2 : 1);\n\t\tlet nameEnd = nameStart;\n\t\twhile (\n\t\t\tnameEnd < text.length &&\n\t\t\t/[A-Za-z0-9:!_-]/.test(text[nameEnd] as string)\n\t\t) {\n\t\t\tnameEnd++;\n\t\t}\n\t\tmode = {\n\t\t\tkind: \"tag\",\n\t\t\tname: text.slice(nameStart, nameEnd).toLowerCase(),\n\t\t\tclosing,\n\t\t\tquote: null,\n\t\t\tline: current(),\n\t\t\tatLineStart,\n\t\t\tinner: 0,\n\t\t};\n\t\tatLineStart = false;\n\t\treturn nameEnd;\n\t};\n\n\t/** Moves through a text part one character at a time. */\n\tconst scanText = (start: number, end: number) => {\n\t\tfor (let index = start; index < end; index++) {\n\t\t\tconst char = text[index] as string;\n\t\t\tif (char === \"\\n\") {\n\t\t\t\ttrimEnd[current()] = canTrimHere();\n\t\t\t\tif (index + 1 < end) beginLine(index + 1);\n\t\t\t\telse if (index + 1 === text.length) {\n\t\t\t\t\t// The file ends with a line break: there is no further line.\n\t\t\t\t} else pendingLine = index + 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tswitch (mode.kind) {\n\t\t\t\tcase \"data\":\n\t\t\t\t\tif (char === \" \" || char === \"\\t\" || char === \"\\r\") break;\n\t\t\t\t\tif (char === \"<\") {\n\t\t\t\t\t\tif (text.startsWith(\"<!--\", index)) {\n\t\t\t\t\t\t\tmode = {\n\t\t\t\t\t\t\t\tkind: \"comment\",\n\t\t\t\t\t\t\t\tanchor: current(),\n\t\t\t\t\t\t\t\tlevel: levelOf(current()),\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tatLineStart = false;\n\t\t\t\t\t\t\tindex += 3;\n\t\t\t\t\t\t} else if (text[index + 1] === \"/\" && isLetter(text[index + 2])) {\n\t\t\t\t\t\t\tindex = startTag(index, true) - 1;\n\t\t\t\t\t\t} else if (isLetter(text[index + 1]) || text[index + 1] === \"!\") {\n\t\t\t\t\t\t\tindex = startTag(index, false) - 1;\n\t\t\t\t\t\t} else atLineStart = false;\n\t\t\t\t\t} else atLineStart = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"tag\":\n\t\t\t\t\tif (mode.quote !== null) {\n\t\t\t\t\t\tif (char === mode.quote) mode.quote = null;\n\t\t\t\t\t} else if (char === '\"' || char === \"'\") mode.quote = char;\n\t\t\t\t\telse if (char === \">\") finishTag(mode, text[index - 1] === \"/\");\n\t\t\t\t\telse if (char !== \" \" && char !== \"\\t\" && char !== \"\\r\") {\n\t\t\t\t\t\tatLineStart = false;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"comment\":\n\t\t\t\t\tif (text.startsWith(\"-->\", index)) {\n\t\t\t\t\t\tmode = { kind: \"data\" };\n\t\t\t\t\t\tindex += 2;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"raw\":\n\t\t\t\t\tif (char === \"<\" && closesElement(text, index, mode.name)) {\n\t\t\t\t\t\tindex = startTag(index, true) - 1;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"kept\":\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t};\n\n\t/** Applies a block tag to the stack, or to the count of block tags open inside an HTML tag. */\n\tconst applyTag = (part: DelimitedPart) => {\n\t\tconst role = roleOf(part);\n\t\tconst first = atLineStart;\n\t\tatLineStart = false;\n\t\tif (!role) return;\n\t\tif (mode.kind === \"tag\") {\n\t\t\tconst base = levelOf(mode.line) + 1;\n\t\t\tif (role.kind === \"open\") mode.inner++;\n\t\t\telse if (role.kind === \"close\") {\n\t\t\t\tmode.inner = Math.max(0, mode.inner - 1);\n\t\t\t\toutdent(current(), base + mode.inner, first);\n\t\t\t} else outdent(current(), base + mode.inner - 1, first);\n\t\t\treturn;\n\t\t}\n\t\tif (mode.kind === \"kept\") {\n\t\t\tif (role.kind === \"open\" && role.name === mode.name) mode.depth++;\n\t\t\telse if (\n\t\t\t\trole.kind === \"close\" &&\n\t\t\t\trole.name === mode.name &&\n\t\t\t\t--mode.depth === 0\n\t\t\t) {\n\t\t\t\tconst index = stack.findLastIndex((frame) => frame.kind === \"kiln\");\n\t\t\t\tif (index !== -1) stack.length = index;\n\t\t\t\tmode = { kind: \"data\" };\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (mode.kind !== \"data\") return;\n\t\tif (role.kind === \"open\") {\n\t\t\tstack.push({ kind: \"kiln\", name: role.name });\n\t\t\tif (\n\t\t\t\trole.name === \"verbatim\" ||\n\t\t\t\t((role.name === \"set\" || role.name === \"apply\") &&\n\t\t\t\t\t!(first && endsLine(part.end)))\n\t\t\t) {\n\t\t\t\tmode = {\n\t\t\t\t\tkind: \"kept\",\n\t\t\t\t\tname: role.name,\n\t\t\t\t\tdepth: 1,\n\t\t\t\t\tlevel: stack.length - 1,\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tconst index =\n\t\t\trole.kind === \"branch\"\n\t\t\t\t? stack.findLastIndex((frame) => frame.kind === \"kiln\")\n\t\t\t\t: stack.findLastIndex(\n\t\t\t\t\t\t(frame) => frame.kind === \"kiln\" && frame.name === role.name,\n\t\t\t\t\t);\n\t\tif (index === -1) return;\n\t\t// Elements opened in this body or branch end with it.\n\t\tstack.length = role.kind === \"branch\" ? index + 1 : index;\n\t\toutdent(current(), index, first);\n\t};\n\n\tbeginLine(0);\n\tconst delimiters: { part: DelimitedPart; line: number }[] = [];\n\n\tfor (const part of parts) {\n\t\tif (pendingLine !== -1) {\n\t\t\tbeginLine(pendingLine);\n\t\t\tpendingLine = -1;\n\t\t}\n\t\tif (part.kind === \"text\") {\n\t\t\tscanText(part.start, part.end);\n\t\t\tcontinue;\n\t\t}\n\t\tconst line = current();\n\t\tif (part.kind === \"comment\") atLineStart = false;\n\t\telse {\n\t\t\tdelimiters.push({ part, line });\n\t\t\tif (part.kind === \"tag\") applyTag(part);\n\t\t\telse atLineStart = false;\n\t\t}\n\t\t// Lines that start inside this delimiter.\n\t\tfor (\n\t\t\tlet index = text.indexOf(\"\\n\", part.start);\n\t\t\tindex !== -1 && index < part.end;\n\t\t\tindex = text.indexOf(\"\\n\", index + 1)\n\t\t) {\n\t\t\ttrimEnd[current()] = part.kind === \"comment\";\n\t\t\tlines.push(\n\t\t\t\tpart.kind === \"comment\"\n\t\t\t\t\t? { kind: \"shift\", start: index + 1, anchor: line }\n\t\t\t\t\t: { kind: \"inside\", start: index + 1 },\n\t\t\t);\n\t\t}\n\t}\n\ttrimEnd[current()] ??= canTrimHere();\n\treturn { lines, trimEnd, delimiters };\n};\n\nconst widthOf = (whitespace: string, tabWidth: number): number => {\n\tlet width = 0;\n\tfor (const char of whitespace) width += char === \"\\t\" ? tabWidth : 1;\n\treturn width;\n};\n\n/**\n * Works out the edits that format a template, without checking them. See `formatEdits`.\n */\nconst planEdits = (\n\ttext: string,\n\tparts: readonly Part[],\n\toptions: Required<Omit<FormatOptions, \"range\">>,\n): FormatEdit[] => {\n\tconst { useTabs, tabWidth } = options;\n\tconst unit = useTabs ? \"\\t\" : \" \".repeat(tabWidth);\n\tconst indentOfWidth = (width: number) =>\n\t\tuseTabs\n\t\t\t? \"\\t\".repeat(Math.floor(width / tabWidth)) + \" \".repeat(width % tabWidth)\n\t\t\t: \" \".repeat(width);\n\tconst { lines, trimEnd, delimiters } = planLines(text, parts);\n\n\tconst oldIndent = (line: number) => {\n\t\tconst start = lines[line]?.start ?? 0;\n\t\tlet end = start;\n\t\twhile (text[end] === \" \" || text[end] === \"\\t\") end++;\n\t\treturn text.slice(start, end);\n\t};\n\t/** Where a line's content ends: at its line break, or the end of the file. */\n\tconst lineEnd = (line: number) => {\n\t\tconst next = lines[line + 1]?.start;\n\t\tif (next !== undefined) return next - 1;\n\t\treturn text.endsWith(\"\\n\") ? text.length - 1 : text.length;\n\t};\n\tconst isBlank = (line: number) => {\n\t\tconst info = lines[line] as Line;\n\t\treturn (\n\t\t\tinfo.kind !== \"keep\" &&\n\t\t\tinfo.kind !== \"inside\" &&\n\t\t\ttext.slice(info.start, lineEnd(line)).trim() === \"\"\n\t\t);\n\t};\n\n\t// Whitespace before the first content and after the last is output as written wherever the template is placed, so\n\t// it stays as it is, as does a file of only whitespace.\n\tlet firstContent = 0;\n\twhile (firstContent < lines.length && isBlank(firstContent)) firstContent++;\n\tlet lastContent = lines.length - 1;\n\twhile (lastContent >= 0 && isBlank(lastContent)) lastContent--;\n\n\tconst newIndents = new Map<number, string | null>();\n\tconst newIndent = (line: number): string | null => {\n\t\tif (newIndents.has(line)) return newIndents.get(line) ?? null;\n\t\tconst info = lines[line];\n\t\tlet indent: string | null = null;\n\t\tif (info?.kind === \"indent\") {\n\t\t\t// The first content line keeps its indentation. See `firstContent`.\n\t\t\tindent =\n\t\t\t\tline === firstContent ? oldIndent(line) : unit.repeat(info.level);\n\t\t} else if (info?.kind === \"shift\") {\n\t\t\tconst anchor = newIndent(info.anchor);\n\t\t\tconst moved =\n\t\t\t\tanchor === null\n\t\t\t\t\t? 0\n\t\t\t\t\t: widthOf(anchor, tabWidth) -\n\t\t\t\t\t\twidthOf(oldIndent(info.anchor), tabWidth);\n\t\t\tindent = indentOfWidth(\n\t\t\t\tMath.max(0, widthOf(oldIndent(line), tabWidth) + moved),\n\t\t\t);\n\t\t}\n\t\tnewIndents.set(line, indent);\n\t\treturn indent;\n\t};\n\n\tconst edits: FormatEdit[] = [];\n\t// Blank lines go where the line before is blank too, so runs become one.\n\tlet previousBlank = false;\n\n\tfor (const [index, info] of lines.entries()) {\n\t\tif (index > lastContent) break;\n\t\tif (index < firstContent) continue;\n\t\tconst start = info.start;\n\t\tconst end = lineEnd(index);\n\t\tif (isBlank(index)) {\n\t\t\tif (info.kind === \"indent\" && previousBlank) {\n\t\t\t\tedits.push({ start, end: end + 1, text: \"\" });\n\t\t\t} else if (end > start) edits.push({ start, end, text: \"\" });\n\t\t\tpreviousBlank = true;\n\t\t\tcontinue;\n\t\t}\n\t\tpreviousBlank = false;\n\n\t\tconst indent = newIndent(index);\n\t\tif (indent !== null) {\n\t\t\tconst current = oldIndent(index);\n\t\t\tif (current !== indent) {\n\t\t\t\tedits.push({ start, end: start + current.length, text: indent });\n\t\t\t}\n\t\t}\n\t\tif (trimEnd[index] && info.kind !== \"keep\" && index !== lastContent) {\n\t\t\tlet from = end;\n\t\t\twhile (from > start && /[ \\t\\r]/.test(text[from - 1] as string)) from--;\n\t\t\tif (from < end && !insideDelimiter(delimiters, from)) {\n\t\t\t\tedits.push({ start: from, end, text: \"\" });\n\t\t\t}\n\t\t}\n\t}\n\n\tfor (const { part, line } of delimiters) {\n\t\tconst indent = newIndent(line) ?? oldIndent(line);\n\t\tconst printed = printDelimiter(text, part, indent, unit);\n\t\tif (printed !== null && printed !== text.slice(part.start, part.end)) {\n\t\t\tedits.push({ start: part.start, end: part.end, text: printed });\n\t\t}\n\t}\n\n\treturn edits.sort((a, b) => a.start - b.start || a.end - b.end);\n};\n\nconst insideDelimiter = (\n\tdelimiters: readonly { part: DelimitedPart }[],\n\toffset: number,\n) => delimiters.some(({ part }) => offset > part.start && offset < part.end);\n\nconst applyEdits = (text: string, edits: readonly FormatEdit[]): string => {\n\tlet out = \"\";\n\tlet position = 0;\n\tfor (const edit of edits) {\n\t\tout += text.slice(position, edit.start) + edit.text;\n\t\tposition = edit.end;\n\t}\n\treturn out + text.slice(position);\n};\n\n/** Removes whitespace at the start and end of lines, and blank lines, which the formatter may change. */\nconst normaliseText = (value: string) =>\n\tvalue\n\t\t.replace(/[ \\t\\r\\f\\v]+$/gm, \"\")\n\t\t.replace(/^[ \\t\\f\\v]+/gm, \"\")\n\t\t.replace(/\\n{2,}/g, \"\\n\");\n\n/** A copy of a syntax tree without positions or layout, with text normalised and text left empty by that removed. */\nconst normaliseTree = (value: unknown): unknown => {\n\tif (Array.isArray(value)) {\n\t\treturn value\n\t\t\t.map(normaliseTree)\n\t\t\t.filter(\n\t\t\t\t(item) =>\n\t\t\t\t\t!(\n\t\t\t\t\t\ttypeof item === \"object\" &&\n\t\t\t\t\t\titem !== null &&\n\t\t\t\t\t\t(item as { type?: unknown }).type === \"Text\" &&\n\t\t\t\t\t\t(item as { value?: unknown }).value === \"\"\n\t\t\t\t\t),\n\t\t\t);\n\t}\n\tif (typeof value !== \"object\" || value === null) return value;\n\tconst copy: Record<string, unknown> = {};\n\tfor (const [key, item] of Object.entries(value)) {\n\t\tif (key === \"span\" || key === \"nameSpan\" || key === \"indent\") continue;\n\t\tcopy[key] =\n\t\t\tkey === \"value\" && (value as { type?: unknown }).type === \"Text\"\n\t\t\t\t? normaliseText(item as string)\n\t\t\t\t: normaliseTree(item);\n\t}\n\treturn copy;\n};\n\n/** The syntax tree as JSON, without the whitespace the formatter may change, so two trees can be compared. */\nconst shape = (text: string): string =>\n\tJSON.stringify(normaliseTree(parse(text, { isTest }).ast));\n\n/**\n * 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.\n */\nexport const formatEdits = (\n\ttext: string,\n\toptions: FormatOptions = {},\n): FormatEdit[] => {\n\tconst parsed = parse(text, { isTest });\n\tif (parsed.problems.length > 0) {\n\t\tconst source = new Source(\"template.kiln\", text);\n\t\tthrow new KilnSyntaxError(\n\t\t\tparsed.problems.map((problem) =>\n\t\t\t\tcreateDiagnostic(source, problem.code, problem.message, problem.span),\n\t\t\t),\n\t\t\tsource,\n\t\t);\n\t}\n\n\tconst tabWidth = options.tabWidth ?? 4;\n\tif (!Number.isInteger(tabWidth) || tabWidth < 1) {\n\t\tthrow new RangeError(\n\t\t\t`tabWidth must be a whole number of at least 1, but got ${tabWidth}`,\n\t\t);\n\t}\n\tlet edits = planEdits(text, scanParts(text).parts, {\n\t\tuseTabs: options.useTabs ?? true,\n\t\ttabWidth,\n\t});\n\tconst range = options.range;\n\tif (range) {\n\t\tedits = edits.filter(\n\t\t\t(edit) => edit.end >= range.start && edit.start <= range.end,\n\t\t);\n\t}\n\n\tconst formatted = applyEdits(text, edits);\n\tconst changed = parse(formatted, { isTest });\n\tif (changed.problems.length > 0 || shape(formatted) !== shape(text)) {\n\t\tthrow new KilnFormatError(\n\t\t\t\"Formatting would have changed what this template renders, so nothing was changed. This is a bug in Kiln's formatter.\",\n\t\t);\n\t}\n\treturn edits;\n};\n\n/**\n * Formats a template: indents it to match its structure, and tidies spacing inside outputs and tags. Never changes what it renders.\n *\n * Throws `KilnSyntaxError` when the template has syntax errors, `KilnFormatError` if the safety check fails, and\n * `RangeError` for a `tabWidth` that isn't a whole number of at least 1.\n *\n * ```ts\n * const formatted = format(source, { useTabs: false, tabWidth: 2 });\n * ```\n */\nexport const format = (text: string, options: FormatOptions = {}): string =>\n\tapplyEdits(text, formatEdits(text, options));\n"],"mappings":";;;AAmCA,MAAM,2BAAW,IAAI,IAAI;CACxB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;;AAGD,MAAM,YAAY,QAAgB,WAAsC;CACvE,MAAM,SAAkB,CAAC;CACzB,KAAK,IAAI,QAAQ,GAAG,QAAQ,OAAO,QAAQ,SAAS;EACnD,MAAM,QAAQ,OAAO;EACrB,IAAI,MAAM,MAAM;EAChB,IAAI,MAA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pB,iBAAiB,QAAQ,QAAQ,MAAM,QAAQ,SAAS,QAAQ,IAAI,CACrE,GACA,MACD;CACD;CAEA,MAAM,WAAW,QAAQ,YAAY;CACrC,IAAI,CAAC,OAAO,UAAU,QAAQ,KAAK,WAAW,GAC7C,MAAM,IAAI,WACT,0DAA0D,UAC3D;CAED,IAAI,QAAQ,UAAU,MAAM,UAAU,IAAI,CAAC,CAAC,OAAO;EAClD,SAAS,QAAQ,WAAW;EAC5B;CACD,CAAC;CACD,MAAM,QAAQ,QAAQ;CACtB,IAAI,OACH,QAAQ,MAAM,QACZ,SAAS,KAAK,OAAO,MAAM,SAAS,KAAK,SAAS,MAAM,GAC1D;CAGD,MAAM,YAAY,WAAW,MAAM,KAAK;CAExC,IADgB,MAAM,WAAW,EAAE,OAAO,CAChC,CAAC,CAAC,SAAS,SAAS,KAAK,MAAM,SAAS,MAAM,MAAM,IAAI,GACjE,MAAM,IAAI,gBACT,sHACD;CAED,OAAO;AACR;;;;;;;;;;;AAYA,MAAa,UAAU,MAAc,UAAyB,CAAC,MAC9D,WAAW,MAAM,YAAY,MAAM,OAAO,CAAC"}
1
+ {"version":3,"file":"format-A7Ol0apX.js","names":[],"sources":["../src/formatter/delimiters.ts","../src/formatter/format.ts"],"sourcesContent":["import type { DelimitedPart, Token } from \"../lexer/lexer.js\";\n\n/** A token as the formatter prints it: its source text, unchanged. An interpolated string is one piece. */\ntype Piece = {\n\ttype: Token[\"type\"];\n\ttext: string;\n\tstart: number;\n\tend: number;\n};\n\n/**\n * What a piece does, where that changes its spacing.\n *\n * - `word`: a name, number or string.\n * - `keyword`: a tag's name, or a name such as `and` or `in`. A bracket after it groups rather than calls.\n * - `unary`: a sign that makes a number negative or positive, written against its operand.\n * - `tight`: `.`, `?.`, `..` and a filter's `|`, with no space either side.\n * - `key`: the colon after a key or named argument, or `?` and `?:` marking an optional key in `props`.\n * - `call`: a bracket that calls or indexes the piece before it.\n * - `open`, `close`: other brackets.\n * - `spaced`: operators with a space either side.\n */\ntype Role =\n\t| \"word\"\n\t| \"keyword\"\n\t| \"unary\"\n\t| \"tight\"\n\t| \"key\"\n\t| \"call\"\n\t| \"open\"\n\t| \"close\"\n\t| \"comma\"\n\t| \"spread\"\n\t| \"spaced\";\n\nconst KEYWORDS = new Set([\n\t\"and\",\n\t\"or\",\n\t\"not\",\n\t\"in\",\n\t\"is\",\n\t\"starts\",\n\t\"ends\",\n\t\"with\",\n\t\"as\",\n\t\"import\",\n\t\"ignore\",\n\t\"missing\",\n]);\n\n/** Joins each interpolated string's tokens, from `stringStart` to its matching `stringEnd`, into one piece. */\nconst toPieces = (source: string, tokens: readonly Token[]): Piece[] => {\n\tconst pieces: Piece[] = [];\n\tfor (let index = 0; index < tokens.length; index++) {\n\t\tconst token = tokens[index] as Token;\n\t\tlet end = token.end;\n\t\tif (token.type === \"stringStart\") {\n\t\t\tlet depth = 0;\n\t\t\tfor (; index < tokens.length; index++) {\n\t\t\t\tconst inner = tokens[index] as Token;\n\t\t\t\tif (inner.type === \"stringStart\") depth++;\n\t\t\t\telse if (inner.type === \"stringEnd\" && --depth === 0) break;\n\t\t\t}\n\t\t\tend = (tokens[Math.min(index, tokens.length - 1)] as Token).end;\n\t\t}\n\t\tpieces.push({\n\t\t\ttype: token.type === \"stringStart\" ? \"string\" : token.type,\n\t\t\ttext: source.slice(token.start, end),\n\t\t\tstart: token.start,\n\t\t\tend,\n\t\t});\n\t}\n\treturn pieces;\n};\n\n/** Works out each piece's role. `isTag` means the first piece is a tag's name. */\nconst rolesOf = (pieces: readonly Piece[], isTag: boolean): Role[] => {\n\tconst roles: Role[] = [];\n\t// In `props`, `|` joins types and `?:` marks an optional key, until `=` starts a default value.\n\tconst props = isTag && pieces[0]?.text === \"props\";\n\tlet inDefault = false;\n\t// Open `?`s at each bracket depth, so a conditional's `:` can be told from a key's.\n\tconst conditionals: number[] = [0];\n\n\tfor (const [index, piece] of pieces.entries()) {\n\t\tconst previous = roles[index - 1];\n\t\tconst depth = conditionals.length - 1;\n\t\tconst types = props && !inDefault;\n\t\tlet role: Role;\n\n\t\tif (piece.type !== \"punct\") {\n\t\t\trole =\n\t\t\t\t(isTag && index === 0) ||\n\t\t\t\t(piece.type === \"name\" && KEYWORDS.has(piece.text))\n\t\t\t\t\t? \"keyword\"\n\t\t\t\t\t: \"word\";\n\t\t} else {\n\t\t\tswitch (piece.text) {\n\t\t\t\tcase \"(\":\n\t\t\t\tcase \"[\":\n\t\t\t\t\trole = previous === \"word\" || previous === \"close\" ? \"call\" : \"open\";\n\t\t\t\t\tconditionals.push(0);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"{\":\n\t\t\t\t\trole = \"open\";\n\t\t\t\t\tconditionals.push(0);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \")\":\n\t\t\t\tcase \"]\":\n\t\t\t\tcase \"}\":\n\t\t\t\t\trole = \"close\";\n\t\t\t\t\tif (conditionals.length > 1) conditionals.pop();\n\t\t\t\t\tbreak;\n\t\t\t\tcase \",\":\n\t\t\t\t\trole = \"comma\";\n\t\t\t\t\tif (props && depth === 0) inDefault = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"...\":\n\t\t\t\t\trole = \"spread\";\n\t\t\t\t\tbreak;\n\t\t\t\tcase \".\":\n\t\t\t\tcase \"?.\":\n\t\t\t\tcase \"..\":\n\t\t\t\t\trole = \"tight\";\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"|\":\n\t\t\t\t\trole = types ? \"spaced\" : \"tight\";\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"-\":\n\t\t\t\tcase \"+\":\n\t\t\t\t\trole =\n\t\t\t\t\t\tprevious === undefined ||\n\t\t\t\t\t\t(previous !== \"word\" && previous !== \"close\")\n\t\t\t\t\t\t\t? \"unary\"\n\t\t\t\t\t\t\t: \"spaced\";\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"?\":\n\t\t\t\tcase \"?:\":\n\t\t\t\t\trole = types ? \"key\" : \"spaced\";\n\t\t\t\t\tif (piece.text === \"?\" && !types) {\n\t\t\t\t\t\tconditionals[depth] = (conditionals[depth] ?? 0) + 1;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase \":\":\n\t\t\t\t\tif ((conditionals[depth] ?? 0) > 0) {\n\t\t\t\t\t\tconditionals[depth] = (conditionals[depth] ?? 0) - 1;\n\t\t\t\t\t\trole = \"spaced\";\n\t\t\t\t\t} else role = \"key\";\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\trole = \"spaced\";\n\t\t\t\t\tif (props && depth === 0 && piece.text === \"=\") inDefault = true;\n\t\t\t}\n\t\t}\n\t\troles.push(role);\n\t}\n\treturn roles;\n};\n\n/** The gap between two pieces: a space or nothing. */\nconst gapBetween = (\n\tprevious: Piece,\n\tpreviousRole: Role,\n\tpiece: Piece,\n\trole: Role,\n): string => {\n\tif (role === \"comma\" || role === \"tight\" || role === \"key\" || role === \"call\")\n\t\treturn \"\";\n\tif (role === \"close\") {\n\t\treturn piece.text === \"}\" && previous.text !== \"{\" ? \" \" : \"\";\n\t}\n\tif (previousRole === \"tight\" || previousRole === \"unary\") return \"\";\n\tif (previousRole === \"spread\") return \"\";\n\tif (previousRole === \"open\" || previousRole === \"call\") {\n\t\treturn previous.text === \"{\" ? \" \" : \"\";\n\t}\n\treturn \" \";\n};\n\n/**\n * 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.\n *\n * Returns null for a delimiter that never closed, which the formatter leaves as it is.\n */\nexport const printDelimiter = (\n\tsource: string,\n\tpart: DelimitedPart,\n\tindent: string,\n\tunit: string,\n): string | null => {\n\tconst tokens = part.tokens;\n\tconst open = tokens[0];\n\tconst close = tokens[tokens.length - 1];\n\tif (!open || !close || close.value === \"\" || tokens.length < 3) return null;\n\n\tconst pieces = toPieces(source, tokens.slice(1, -1));\n\tconst roles = rolesOf(pieces, part.kind === \"tag\");\n\tlet out = open.value;\n\tlet previousEnd = part.start + open.value.length;\n\t// The line each open bracket started on. Brackets opened on the same line add one step between them.\n\tconst openedOn: number[] = [];\n\tlet line = 0;\n\t/** Steps of indentation for a new line, once `closers` brackets at its start have closed. */\n\tconst steps = (closers: number) =>\n\t\tnew Set(openedOn.slice(0, openedOn.length - closers)).size;\n\n\tfor (const [index, piece] of pieces.entries()) {\n\t\tconst role = roles[index] as Role;\n\t\tconst gap = source.slice(previousEnd, piece.start);\n\t\tif (gap.includes(\"\\n\")) {\n\t\t\tline++;\n\t\t\t// Closing brackets at the start of a line line up with the line that opened them. Only those on this line count.\n\t\t\tlet closers = 0;\n\t\t\twhile (\n\t\t\t\troles[index + closers] === \"close\" &&\n\t\t\t\t(closers === 0 ||\n\t\t\t\t\t!source\n\t\t\t\t\t\t.slice(\n\t\t\t\t\t\t\t(pieces[index + closers - 1] as Piece).end,\n\t\t\t\t\t\t\t(pieces[index + closers] as Piece).start,\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.includes(\"\\n\"))\n\t\t\t) {\n\t\t\t\tclosers++;\n\t\t\t}\n\t\t\tout += `\\n${indent}${unit.repeat(closers > 0 ? steps(closers) : Math.max(steps(0), 1))}`;\n\t\t} else if (index === 0) out += \" \";\n\t\telse {\n\t\t\tout += gapBetween(\n\t\t\t\tpieces[index - 1] as Piece,\n\t\t\t\troles[index - 1] as Role,\n\t\t\t\tpiece,\n\t\t\t\trole,\n\t\t\t);\n\t\t}\n\t\tout += piece.text;\n\t\tif (role === \"open\" || role === \"call\") openedOn.push(line);\n\t\telse if (role === \"close\") openedOn.pop();\n\t\tpreviousEnd = piece.end;\n\t}\n\n\tconst closeStart = part.end - close.value.length;\n\tout += source.slice(previousEnd, closeStart).includes(\"\\n\")\n\t\t? `\\n${indent}`\n\t\t: \" \";\n\treturn out + close.value;\n};\n","import { builtinTests } from \"../builtins/functions.js\";\nimport { KilnSyntaxError } from \"../errors.js\";\nimport { createDiagnostic } from \"../errors.js\";\nimport { type DelimitedPart, type Part, scanParts } from \"../lexer/lexer.js\";\nimport { parse } from \"../parser/parser.js\";\nimport { Source } from \"../source.js\";\nimport { printDelimiter } from \"./delimiters.js\";\n\nexport type FormatOptions = {\n\t/** Indent with tabs. Default `true`. */\n\tuseTabs?: boolean;\n\t/** Spaces per step without tabs, and the width of a tab when moving lines. A whole number of at least 1. Default `4`. */\n\ttabWidth?: number;\n\t/** Only format lines that overlap this range of offsets. */\n\trange?: { start: number; end: number };\n};\n\n/** Replace `start` to `end` of the original source with `text`. */\nexport type FormatEdit = { start: number; end: number; text: string };\n\n/** Thrown when formatting would have changed what a template renders. That is a bug in the formatter. */\nexport class KilnFormatError extends Error {\n\toverride name = \"KilnFormatError\";\n}\n\n/**\n * How the formatter treats one line.\n *\n * - `indent`: set its indentation to `level` steps.\n * - `shift`: move it by as much as line `anchor` moved, keeping its own indentation relative to it. For scripts, styles and comments.\n * - `keep`: leave it alone, for `<pre>`, `<textarea>`, `verbatim`, text inside attribute values, and the body of a `set` or `apply` whose tag shares its line.\n * - `inside`: it starts inside an output or tag, which `printDelimiter` indents.\n */\ntype Line =\n\t| { kind: \"indent\"; start: number; level: number }\n\t| { kind: \"shift\"; start: number; anchor: number }\n\t| { kind: \"keep\" | \"inside\"; start: number };\n\ntype Frame = { kind: \"kiln\" | \"html\"; name: string };\n\n/**\n * Where the scanner is in the HTML.\n *\n * - `tag`: inside `<name ...>` or `</name>`, which started on line `line`. `inner` counts block tags open inside it.\n * - `raw`: inside `<script>` or `<style>`, or kept as written inside `<pre>`, `<textarea>` and the like.\n * - `kept`: inside the body of block tag `name`, output as written: `verbatim`, or a `set` or `apply` whose tag shares\n * its line, where Kiln doesn't remove the body's indentation. `depth` counts the tags of that name open.\n */\ntype Mode =\n\t| { kind: \"data\" }\n\t| {\n\t\t\tkind: \"tag\";\n\t\t\tname: string;\n\t\t\tclosing: boolean;\n\t\t\tquote: string | null;\n\t\t\tline: number;\n\t\t\tatLineStart: boolean;\n\t\t\tinner: number;\n\t }\n\t| { kind: \"comment\"; anchor: number; level: number }\n\t| { kind: \"raw\"; name: string; keep: boolean; anchor: number; level: number }\n\t| { kind: \"kept\"; name: string; depth: number; level: number };\n\nconst VOID_ELEMENTS = new Set([\n\t\"area\",\n\t\"base\",\n\t\"br\",\n\t\"col\",\n\t\"embed\",\n\t\"hr\",\n\t\"img\",\n\t\"input\",\n\t\"link\",\n\t\"meta\",\n\t\"source\",\n\t\"track\",\n\t\"wbr\",\n]);\n\n/** Elements written in `<script>` or `<style>`'s own language, whose lines move together. */\nconst RAW_ELEMENTS = new Set([\"script\", \"style\"]);\n/** Elements whose whitespace shows on the page. Nothing closes `<plaintext>`. */\nconst KEPT_ELEMENTS = new Set([\n\t\"pre\",\n\t\"textarea\",\n\t\"xmp\",\n\t\"listing\",\n\t\"plaintext\",\n]);\n\n/** Whether `</name` starts at `index`, as a whole tag name. */\nconst closesElement = (text: string, index: number, name: string): boolean => {\n\tif (name === \"plaintext\") return false;\n\tconst end = index + 2 + name.length;\n\treturn (\n\t\ttext.slice(index, end).toLowerCase() === `</${name}` &&\n\t\t(end === text.length || /[\\s/>]/.test(text[end] as string))\n\t);\n};\n\n/**\n * Whether a line starting with `trimmed` begins with the tag that ends the outermost `kept` body, and the formatter\n * may indent it. It may when Kiln removes the whitespace before the tag: a `-` trim marker, or a tag alone on its line.\n */\nconst endsKept = (\n\ttrimmed: string,\n\tmode: Extract<Mode, { kind: \"kept\" }>,\n): boolean => {\n\tconst match = /^\\{%(-?)\\s*end([A-Za-z]+)\\s*-?%\\}([^\\n]*)/.exec(trimmed);\n\treturn (\n\t\tmatch !== null &&\n\t\tmatch[2] === mode.name &&\n\t\tmode.depth === 1 &&\n\t\t(match[1] === \"-\" || /^[ \\t\\r]*$/.test(match[3] as string))\n\t);\n};\n\n/** Elements that the next of these siblings closes, such as a `<li>` without `</li>`. */\nconst CLOSED_BY: Record<string, readonly string[]> = {\n\tli: [\"li\"],\n\tdt: [\"dt\", \"dd\"],\n\tdd: [\"dt\", \"dd\"],\n\tp: [\"p\"],\n\toption: [\"option\"],\n\ttr: [\"tr\"],\n\ttd: [\"td\", \"th\"],\n\tth: [\"td\", \"th\"],\n\tthead: [\"tbody\", \"tfoot\"],\n\ttbody: [\"tbody\", \"tfoot\"],\n};\n\n/** Block tags that hold a body, and so indent what follows. */\nconst BLOCK_TAGS = new Set([\n\t\"if\",\n\t\"for\",\n\t\"set\",\n\t\"block\",\n\t\"component\",\n\t\"fill\",\n\t\"slot\",\n\t\"macro\",\n\t\"with\",\n\t\"cache\",\n\t\"island\",\n\t\"add\",\n\t\"apply\",\n\t\"autoescape\",\n\t\"verbatim\",\n]);\n\n/** What a tag does to indentation: opens a body, starts another branch of one, closes one, or nothing. */\nconst roleOf = (\n\tpart: DelimitedPart,\n): { kind: \"open\" | \"close\"; name: string } | { kind: \"branch\" } | null => {\n\tconst name = part.tokens[1];\n\tif (name?.type !== \"name\") return null;\n\tif (BLOCK_TAGS.has(name.value)) {\n\t\tif (\n\t\t\tname.value === \"set\" &&\n\t\t\tpart.tokens.some((token) => token.type === \"punct\" && token.value === \"=\")\n\t\t) {\n\t\t\treturn null;\n\t\t}\n\t\t// `{% block title page.title %}` is the short form, with no body.\n\t\tif (name.value === \"block\" && part.tokens.length > 4) return null;\n\t\treturn { kind: \"open\", name: name.value };\n\t}\n\tif (name.value === \"else\" || name.value === \"elseif\")\n\t\treturn { kind: \"branch\" };\n\tif (name.value.startsWith(\"end\")) {\n\t\treturn { kind: \"close\", name: name.value.slice(3) };\n\t}\n\treturn null;\n};\n\nconst isLetter = (char: string | undefined) =>\n\tchar !== undefined && /[A-Za-z]/.test(char);\n\nconst isTest = (name: string) => Object.hasOwn(builtinTests, name);\n\n/** The start offset of every line. */\nconst lineStarts = (text: string): number[] => {\n\tconst starts = [0];\n\tfor (let index = text.indexOf(\"\\n\"); index !== -1;) {\n\t\tstarts.push(index + 1);\n\t\tindex = text.indexOf(\"\\n\", index + 1);\n\t}\n\treturn starts;\n};\n\n/**\n * Walks the template once, tracking open block tags and HTML elements, and decides how to treat each line.\n *\n * Returns the lines, which lines may lose trailing whitespace, and the outputs and tags to print.\n */\nconst planLines = (text: string, parts: readonly Part[]) => {\n\tconst starts = lineStarts(text);\n\tconst lines: Line[] = [];\n\tconst trimEnd: boolean[] = [];\n\tconst stack: Frame[] = [];\n\tlet mode: Mode = { kind: \"data\" };\n\tlet atLineStart = true;\n\t// A line that starts where the next part does, recorded when that part begins.\n\tlet pendingLine = -1;\n\n\tconst lineText = (index: number) =>\n\t\ttext.slice(starts[index], starts[index + 1] ?? text.length);\n\t/** Whether only spaces and tabs come between `offset` and the end of its line. */\n\tconst endsLine = (offset: number) => {\n\t\tlet index = offset;\n\t\twhile (index < text.length && \" \\t\\r\".includes(text[index] as string)) {\n\t\t\tindex++;\n\t\t}\n\t\treturn index === text.length || text[index] === \"\\n\";\n\t};\n\tconst current = () => lines.length - 1;\n\n\t/** Lowers the current line's level when a closing tag comes before anything else on it. */\n\tconst outdent = (line: number, level: number, first: boolean) => {\n\t\tconst info = lines[line];\n\t\tif (first && info?.kind === \"indent\") {\n\t\t\tinfo.level = Math.min(info.level, level);\n\t\t}\n\t};\n\n\tconst levelOf = (line: number): number => {\n\t\tconst info = lines[line];\n\t\treturn info?.kind === \"indent\" ? info.level : stack.length;\n\t};\n\n\t/** Records how to treat the line that starts at `start`, from the current state. */\n\tconst beginLine = (start: number) => {\n\t\tconst index = lines.length;\n\t\tconst trimmed = lineText(index).trimStart();\n\t\tatLineStart = true;\n\t\tswitch (mode.kind) {\n\t\t\tcase \"data\":\n\t\t\t\tlines.push({ kind: \"indent\", start, level: stack.length });\n\t\t\t\treturn;\n\t\t\tcase \"tag\": {\n\t\t\t\tif (mode.quote !== null) {\n\t\t\t\t\tlines.push({ kind: \"keep\", start });\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst base = levelOf(mode.line);\n\t\t\t\tconst level =\n\t\t\t\t\ttrimmed.startsWith(\">\") || trimmed.startsWith(\"/>\")\n\t\t\t\t\t\t? base\n\t\t\t\t\t\t: base + 1 + mode.inner;\n\t\t\t\tlines.push({ kind: \"indent\", start, level });\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"comment\":\n\t\t\t\tlines.push(\n\t\t\t\t\ttrimmed.startsWith(\"-->\")\n\t\t\t\t\t\t? { kind: \"indent\", start, level: mode.level }\n\t\t\t\t\t\t: { kind: \"shift\", start, anchor: mode.anchor },\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\tcase \"raw\":\n\t\t\t\tif (mode.keep) lines.push({ kind: \"keep\", start });\n\t\t\t\telse if (closesElement(trimmed, 0, mode.name)) {\n\t\t\t\t\tlines.push({ kind: \"indent\", start, level: mode.level });\n\t\t\t\t} else lines.push({ kind: \"shift\", start, anchor: mode.anchor });\n\t\t\t\treturn;\n\t\t\tcase \"kept\":\n\t\t\t\tlines.push(\n\t\t\t\t\tendsKept(trimmed, mode)\n\t\t\t\t\t\t? { kind: \"indent\", start, level: mode.level }\n\t\t\t\t\t\t: { kind: \"keep\", start },\n\t\t\t\t);\n\t\t}\n\t};\n\n\t/** Whether trailing whitespace on a line ending here can go. Not inside attribute values or kept elements. */\n\tconst canTrimHere = () =>\n\t\t!(mode.kind === \"tag\" && mode.quote !== null) &&\n\t\t!(mode.kind === \"raw\" && mode.keep) &&\n\t\tmode.kind !== \"kept\";\n\n\tconst finishTag = (\n\t\ttag: Extract<Mode, { kind: \"tag\" }>,\n\t\tselfClosing: boolean,\n\t) => {\n\t\tmode = { kind: \"data\" };\n\t\tconst name = tag.name;\n\t\tif (tag.closing) {\n\t\t\t// Close the nearest open element of this name, without crossing a block tag.\n\t\t\tfor (let index = stack.length - 1; index >= 0; index--) {\n\t\t\t\tconst frame = stack[index] as Frame;\n\t\t\t\tif (frame.kind === \"kiln\") break;\n\t\t\t\tif (frame.name === name) {\n\t\t\t\t\tstack.length = index;\n\t\t\t\t\toutdent(tag.line, index, tag.atLineStart);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (name.startsWith(\"!\") || selfClosing || VOID_ELEMENTS.has(name)) return;\n\t\tif (RAW_ELEMENTS.has(name) || KEPT_ELEMENTS.has(name)) {\n\t\t\tmode = {\n\t\t\t\tkind: \"raw\",\n\t\t\t\tname,\n\t\t\t\tkeep: KEPT_ELEMENTS.has(name),\n\t\t\t\tanchor: tag.line,\n\t\t\t\tlevel: stack.length,\n\t\t\t};\n\t\t\treturn;\n\t\t}\n\t\tconst top = stack[stack.length - 1];\n\t\tif (top?.kind === \"html\" && CLOSED_BY[top.name]?.includes(name)) {\n\t\t\tstack.pop();\n\t\t\toutdent(tag.line, stack.length, tag.atLineStart);\n\t\t}\n\t\tstack.push({ kind: \"html\", name });\n\t};\n\n\t/** Starts a tag at `index` if one starts there, and returns where scanning continues. */\n\tconst startTag = (index: number, closing: boolean): number => {\n\t\tconst nameStart = index + (closing ? 2 : 1);\n\t\tlet nameEnd = nameStart;\n\t\twhile (\n\t\t\tnameEnd < text.length &&\n\t\t\t/[A-Za-z0-9:!_-]/.test(text[nameEnd] as string)\n\t\t) {\n\t\t\tnameEnd++;\n\t\t}\n\t\tmode = {\n\t\t\tkind: \"tag\",\n\t\t\tname: text.slice(nameStart, nameEnd).toLowerCase(),\n\t\t\tclosing,\n\t\t\tquote: null,\n\t\t\tline: current(),\n\t\t\tatLineStart,\n\t\t\tinner: 0,\n\t\t};\n\t\tatLineStart = false;\n\t\treturn nameEnd;\n\t};\n\n\t/** Moves through a text part one character at a time. */\n\tconst scanText = (start: number, end: number) => {\n\t\tfor (let index = start; index < end; index++) {\n\t\t\tconst char = text[index] as string;\n\t\t\tif (char === \"\\n\") {\n\t\t\t\ttrimEnd[current()] = canTrimHere();\n\t\t\t\tif (index + 1 < end) beginLine(index + 1);\n\t\t\t\telse if (index + 1 === text.length) {\n\t\t\t\t\t// The file ends with a line break: there is no further line.\n\t\t\t\t} else pendingLine = index + 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tswitch (mode.kind) {\n\t\t\t\tcase \"data\":\n\t\t\t\t\tif (char === \" \" || char === \"\\t\" || char === \"\\r\") break;\n\t\t\t\t\tif (char === \"<\") {\n\t\t\t\t\t\tif (text.startsWith(\"<!--\", index)) {\n\t\t\t\t\t\t\tmode = {\n\t\t\t\t\t\t\t\tkind: \"comment\",\n\t\t\t\t\t\t\t\tanchor: current(),\n\t\t\t\t\t\t\t\tlevel: levelOf(current()),\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tatLineStart = false;\n\t\t\t\t\t\t\tindex += 3;\n\t\t\t\t\t\t} else if (text[index + 1] === \"/\" && isLetter(text[index + 2])) {\n\t\t\t\t\t\t\tindex = startTag(index, true) - 1;\n\t\t\t\t\t\t} else if (isLetter(text[index + 1]) || text[index + 1] === \"!\") {\n\t\t\t\t\t\t\tindex = startTag(index, false) - 1;\n\t\t\t\t\t\t} else atLineStart = false;\n\t\t\t\t\t} else atLineStart = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"tag\":\n\t\t\t\t\tif (mode.quote !== null) {\n\t\t\t\t\t\tif (char === mode.quote) mode.quote = null;\n\t\t\t\t\t} else if (char === '\"' || char === \"'\") mode.quote = char;\n\t\t\t\t\telse if (char === \">\") finishTag(mode, text[index - 1] === \"/\");\n\t\t\t\t\telse if (char !== \" \" && char !== \"\\t\" && char !== \"\\r\") {\n\t\t\t\t\t\tatLineStart = false;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"comment\":\n\t\t\t\t\tif (text.startsWith(\"-->\", index)) {\n\t\t\t\t\t\tmode = { kind: \"data\" };\n\t\t\t\t\t\tindex += 2;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"raw\":\n\t\t\t\t\tif (char === \"<\" && closesElement(text, index, mode.name)) {\n\t\t\t\t\t\tindex = startTag(index, true) - 1;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"kept\":\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t};\n\n\t/** Applies a block tag to the stack, or to the count of block tags open inside an HTML tag. */\n\tconst applyTag = (part: DelimitedPart) => {\n\t\tconst role = roleOf(part);\n\t\tconst first = atLineStart;\n\t\tatLineStart = false;\n\t\tif (!role) return;\n\t\tif (mode.kind === \"tag\") {\n\t\t\tconst base = levelOf(mode.line) + 1;\n\t\t\tif (role.kind === \"open\") mode.inner++;\n\t\t\telse if (role.kind === \"close\") {\n\t\t\t\tmode.inner = Math.max(0, mode.inner - 1);\n\t\t\t\toutdent(current(), base + mode.inner, first);\n\t\t\t} else outdent(current(), base + mode.inner - 1, first);\n\t\t\treturn;\n\t\t}\n\t\tif (mode.kind === \"kept\") {\n\t\t\tif (role.kind === \"open\" && role.name === mode.name) mode.depth++;\n\t\t\telse if (\n\t\t\t\trole.kind === \"close\" &&\n\t\t\t\trole.name === mode.name &&\n\t\t\t\t--mode.depth === 0\n\t\t\t) {\n\t\t\t\tconst index = stack.findLastIndex((frame) => frame.kind === \"kiln\");\n\t\t\t\tif (index !== -1) stack.length = index;\n\t\t\t\tmode = { kind: \"data\" };\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (mode.kind !== \"data\") return;\n\t\tif (role.kind === \"open\") {\n\t\t\tstack.push({ kind: \"kiln\", name: role.name });\n\t\t\tif (\n\t\t\t\trole.name === \"verbatim\" ||\n\t\t\t\t((role.name === \"set\" || role.name === \"apply\") &&\n\t\t\t\t\t!(first && endsLine(part.end)))\n\t\t\t) {\n\t\t\t\tmode = {\n\t\t\t\t\tkind: \"kept\",\n\t\t\t\t\tname: role.name,\n\t\t\t\t\tdepth: 1,\n\t\t\t\t\tlevel: stack.length - 1,\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tconst index =\n\t\t\trole.kind === \"branch\"\n\t\t\t\t? stack.findLastIndex((frame) => frame.kind === \"kiln\")\n\t\t\t\t: stack.findLastIndex(\n\t\t\t\t\t\t(frame) => frame.kind === \"kiln\" && frame.name === role.name,\n\t\t\t\t\t);\n\t\tif (index === -1) return;\n\t\t// Elements opened in this body or branch end with it.\n\t\tstack.length = role.kind === \"branch\" ? index + 1 : index;\n\t\toutdent(current(), index, first);\n\t};\n\n\tbeginLine(0);\n\tconst delimiters: { part: DelimitedPart; line: number }[] = [];\n\n\tfor (const part of parts) {\n\t\tif (pendingLine !== -1) {\n\t\t\tbeginLine(pendingLine);\n\t\t\tpendingLine = -1;\n\t\t}\n\t\tif (part.kind === \"text\") {\n\t\t\tscanText(part.start, part.end);\n\t\t\tcontinue;\n\t\t}\n\t\tconst line = current();\n\t\tif (part.kind === \"comment\") atLineStart = false;\n\t\telse {\n\t\t\tdelimiters.push({ part, line });\n\t\t\tif (part.kind === \"tag\") applyTag(part);\n\t\t\telse atLineStart = false;\n\t\t}\n\t\t// Lines that start inside this delimiter.\n\t\tfor (\n\t\t\tlet index = text.indexOf(\"\\n\", part.start);\n\t\t\tindex !== -1 && index < part.end;\n\t\t\tindex = text.indexOf(\"\\n\", index + 1)\n\t\t) {\n\t\t\ttrimEnd[current()] = part.kind === \"comment\";\n\t\t\tlines.push(\n\t\t\t\tpart.kind === \"comment\"\n\t\t\t\t\t? { kind: \"shift\", start: index + 1, anchor: line }\n\t\t\t\t\t: { kind: \"inside\", start: index + 1 },\n\t\t\t);\n\t\t}\n\t}\n\ttrimEnd[current()] ??= canTrimHere();\n\treturn { lines, trimEnd, delimiters };\n};\n\nconst widthOf = (whitespace: string, tabWidth: number): number => {\n\tlet width = 0;\n\tfor (const char of whitespace) width += char === \"\\t\" ? tabWidth : 1;\n\treturn width;\n};\n\n/**\n * Works out the edits that format a template, without checking them. See `formatEdits`.\n */\nconst planEdits = (\n\ttext: string,\n\tparts: readonly Part[],\n\toptions: Required<Omit<FormatOptions, \"range\">>,\n): FormatEdit[] => {\n\tconst { useTabs, tabWidth } = options;\n\tconst unit = useTabs ? \"\\t\" : \" \".repeat(tabWidth);\n\tconst indentOfWidth = (width: number) =>\n\t\tuseTabs\n\t\t\t? \"\\t\".repeat(Math.floor(width / tabWidth)) + \" \".repeat(width % tabWidth)\n\t\t\t: \" \".repeat(width);\n\tconst { lines, trimEnd, delimiters } = planLines(text, parts);\n\n\tconst oldIndent = (line: number) => {\n\t\tconst start = lines[line]?.start ?? 0;\n\t\tlet end = start;\n\t\twhile (text[end] === \" \" || text[end] === \"\\t\") end++;\n\t\treturn text.slice(start, end);\n\t};\n\t/** Where a line's content ends: at its line break, or the end of the file. */\n\tconst lineEnd = (line: number) => {\n\t\tconst next = lines[line + 1]?.start;\n\t\tif (next !== undefined) return next - 1;\n\t\treturn text.endsWith(\"\\n\") ? text.length - 1 : text.length;\n\t};\n\tconst isBlank = (line: number) => {\n\t\tconst info = lines[line] as Line;\n\t\treturn (\n\t\t\tinfo.kind !== \"keep\" &&\n\t\t\tinfo.kind !== \"inside\" &&\n\t\t\ttext.slice(info.start, lineEnd(line)).trim() === \"\"\n\t\t);\n\t};\n\n\t// Whitespace before the first content and after the last is output as written wherever the template is placed, so\n\t// it stays as it is, as does a file of only whitespace.\n\tlet firstContent = 0;\n\twhile (firstContent < lines.length && isBlank(firstContent)) firstContent++;\n\tlet lastContent = lines.length - 1;\n\twhile (lastContent >= 0 && isBlank(lastContent)) lastContent--;\n\n\tconst newIndents = new Map<number, string | null>();\n\tconst newIndent = (line: number): string | null => {\n\t\tif (newIndents.has(line)) return newIndents.get(line) ?? null;\n\t\tconst info = lines[line];\n\t\tlet indent: string | null = null;\n\t\tif (info?.kind === \"indent\") {\n\t\t\t// The first content line keeps its indentation. See `firstContent`.\n\t\t\tindent =\n\t\t\t\tline === firstContent ? oldIndent(line) : unit.repeat(info.level);\n\t\t} else if (info?.kind === \"shift\") {\n\t\t\tconst anchor = newIndent(info.anchor);\n\t\t\tconst moved =\n\t\t\t\tanchor === null\n\t\t\t\t\t? 0\n\t\t\t\t\t: widthOf(anchor, tabWidth) -\n\t\t\t\t\t\twidthOf(oldIndent(info.anchor), tabWidth);\n\t\t\tindent = indentOfWidth(\n\t\t\t\tMath.max(0, widthOf(oldIndent(line), tabWidth) + moved),\n\t\t\t);\n\t\t}\n\t\tnewIndents.set(line, indent);\n\t\treturn indent;\n\t};\n\n\tconst edits: FormatEdit[] = [];\n\t// Blank lines go where the line before is blank too, so runs become one.\n\tlet previousBlank = false;\n\n\tfor (const [index, info] of lines.entries()) {\n\t\tif (index > lastContent) break;\n\t\tif (index < firstContent) continue;\n\t\tconst start = info.start;\n\t\tconst end = lineEnd(index);\n\t\tif (isBlank(index)) {\n\t\t\tif (info.kind === \"indent\" && previousBlank) {\n\t\t\t\tedits.push({ start, end: end + 1, text: \"\" });\n\t\t\t} else if (end > start) edits.push({ start, end, text: \"\" });\n\t\t\tpreviousBlank = true;\n\t\t\tcontinue;\n\t\t}\n\t\tpreviousBlank = false;\n\n\t\tconst indent = newIndent(index);\n\t\tif (indent !== null) {\n\t\t\tconst current = oldIndent(index);\n\t\t\tif (current !== indent) {\n\t\t\t\tedits.push({ start, end: start + current.length, text: indent });\n\t\t\t}\n\t\t}\n\t\tif (trimEnd[index] && info.kind !== \"keep\" && index !== lastContent) {\n\t\t\tlet from = end;\n\t\t\twhile (from > start && /[ \\t\\r]/.test(text[from - 1] as string)) from--;\n\t\t\tif (from < end && !insideDelimiter(delimiters, from)) {\n\t\t\t\tedits.push({ start: from, end, text: \"\" });\n\t\t\t}\n\t\t}\n\t}\n\n\tfor (const { part, line } of delimiters) {\n\t\tconst indent = newIndent(line) ?? oldIndent(line);\n\t\tconst printed = printDelimiter(text, part, indent, unit);\n\t\tif (printed !== null && printed !== text.slice(part.start, part.end)) {\n\t\t\tedits.push({ start: part.start, end: part.end, text: printed });\n\t\t}\n\t}\n\n\treturn edits.sort((a, b) => a.start - b.start || a.end - b.end);\n};\n\nconst insideDelimiter = (\n\tdelimiters: readonly { part: DelimitedPart }[],\n\toffset: number,\n) => delimiters.some(({ part }) => offset > part.start && offset < part.end);\n\nconst applyEdits = (text: string, edits: readonly FormatEdit[]): string => {\n\tlet out = \"\";\n\tlet position = 0;\n\tfor (const edit of edits) {\n\t\tout += text.slice(position, edit.start) + edit.text;\n\t\tposition = edit.end;\n\t}\n\treturn out + text.slice(position);\n};\n\n/** Removes whitespace at the start and end of lines, and blank lines, which the formatter may change. */\nconst normaliseText = (value: string) =>\n\tvalue\n\t\t.replace(/[ \\t\\r\\f\\v]+$/gm, \"\")\n\t\t.replace(/^[ \\t\\f\\v]+/gm, \"\")\n\t\t.replace(/\\n{2,}/g, \"\\n\");\n\n/** A copy of a syntax tree without positions or layout, with text normalised and text left empty by that removed. */\nconst normaliseTree = (value: unknown): unknown => {\n\tif (Array.isArray(value)) {\n\t\treturn value\n\t\t\t.map(normaliseTree)\n\t\t\t.filter(\n\t\t\t\t(item) =>\n\t\t\t\t\t!(\n\t\t\t\t\t\ttypeof item === \"object\" &&\n\t\t\t\t\t\titem !== null &&\n\t\t\t\t\t\t(item as { type?: unknown }).type === \"Text\" &&\n\t\t\t\t\t\t(item as { value?: unknown }).value === \"\"\n\t\t\t\t\t),\n\t\t\t);\n\t}\n\tif (typeof value !== \"object\" || value === null) return value;\n\tconst copy: Record<string, unknown> = {};\n\tfor (const [key, item] of Object.entries(value)) {\n\t\tif (key === \"span\" || key === \"nameSpan\" || key === \"indent\") continue;\n\t\tcopy[key] =\n\t\t\tkey === \"value\" && (value as { type?: unknown }).type === \"Text\"\n\t\t\t\t? normaliseText(item as string)\n\t\t\t\t: normaliseTree(item);\n\t}\n\treturn copy;\n};\n\n/** The syntax tree as JSON, without the whitespace the formatter may change, so two trees can be compared. */\nconst shape = (text: string): string =>\n\tJSON.stringify(normaliseTree(parse(text, { isTest }).ast));\n\n/**\n * 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.\n */\nexport const formatEdits = (\n\ttext: string,\n\toptions: FormatOptions = {},\n): FormatEdit[] => {\n\tconst parsed = parse(text, { isTest });\n\tif (parsed.problems.length > 0) {\n\t\tconst source = new Source(\"template.kiln\", text);\n\t\tthrow new KilnSyntaxError(\n\t\t\tparsed.problems.map((problem) =>\n\t\t\t\tcreateDiagnostic(source, problem.code, problem.message, problem.span),\n\t\t\t),\n\t\t\tsource,\n\t\t);\n\t}\n\n\tconst tabWidth = options.tabWidth ?? 4;\n\tif (!Number.isInteger(tabWidth) || tabWidth < 1) {\n\t\tthrow new RangeError(\n\t\t\t`tabWidth must be a whole number of at least 1, but got ${tabWidth}`,\n\t\t);\n\t}\n\tlet edits = planEdits(text, scanParts(text).parts, {\n\t\tuseTabs: options.useTabs ?? true,\n\t\ttabWidth,\n\t});\n\tconst range = options.range;\n\tif (range) {\n\t\tedits = edits.filter(\n\t\t\t(edit) => edit.end >= range.start && edit.start <= range.end,\n\t\t);\n\t}\n\n\tconst formatted = applyEdits(text, edits);\n\tconst changed = parse(formatted, { isTest });\n\tif (changed.problems.length > 0 || shape(formatted) !== shape(text)) {\n\t\tthrow new KilnFormatError(\n\t\t\t\"Formatting would have changed what this template renders, so nothing was changed. This is a bug in Kiln's formatter.\",\n\t\t);\n\t}\n\treturn edits;\n};\n\n/**\n * Formats a template: indents it to match its structure, and tidies spacing inside outputs and tags. Never changes what it renders.\n *\n * Throws `KilnSyntaxError` when the template has syntax errors, `KilnFormatError` if the safety check fails, and\n * `RangeError` for a `tabWidth` that isn't a whole number of at least 1.\n *\n * ```ts\n * const formatted = format(source, { useTabs: false, tabWidth: 2 });\n * ```\n */\nexport const format = (text: string, options: FormatOptions = {}): string =>\n\tapplyEdits(text, formatEdits(text, options));\n"],"mappings":";;;AAmCA,MAAM,2BAAW,IAAI,IAAI;CACxB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;;AAGD,MAAM,YAAY,QAAgB,WAAsC;CACvE,MAAM,SAAkB,CAAC;CACzB,KAAK,IAAI,QAAQ,GAAG,QAAQ,OAAO,QAAQ,SAAS;EACnD,MAAM,QAAQ,OA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C/C,MAAM,IAAI,gBACT,OAAO,SAAS,KAAK,YACpB,iBAAiB,QAAQ,QAAQ,MAAM,QAAQ,SAAS,QAAQ,IAAI,CACrE,GACA,MACD;CACD;CAEA,MAAM,WAAW,QAAQ,YAAY;CACrC,IAAI,CAAC,OAAO,UAAU,QAAQ,KAAK,WAAW,GAC7C,MAAM,IAAI,WACT,0DAA0D,UAC3D;CAED,IAAI,QAAQ,UAAU,MAAM,UAAU,IAAI,CAAC,CAAC,OAAO;EAClD,SAAS,QAAQ,WAAW;EAC5B;CACD,CAAC;CACD,MAAM,QAAQ,QAAQ;CACtB,IAAI,OACH,QAAQ,MAAM,QACZ,SAAS,KAAK,OAAO,MAAM,SAAS,KAAK,SAAS,MAAM,GAC1D;CAGD,MAAM,YAAY,WAAW,MAAM,KAAK;CAExC,IADgB,MAAM,WAAW,EAAE,OAAO,CAChC,CAAC,CAAC,SAAS,SAAS,KAAK,MAAM,SAAS,MAAM,MAAM,IAAI,GACjE,MAAM,IAAI,gBACT,sHACD;CAED,OAAO;AACR;;;;;;;;;;;AAYA,MAAa,UAAU,MAAc,UAAyB,CAAC,MAC9D,WAAW,MAAM,YAAY,MAAM,OAAO,CAAC"}
package/dist/format.js CHANGED
@@ -1 +1 @@
1
- export { t as KilnFormatError, n as format, r as formatEdits } from "./format-Di6-GUtH.js";
1
+ export { t as KilnFormatError, n as format, r as formatEdits } from "./format-A7Ol0apX.js";
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { c as PropType, l as ShapeKey, m as Position, p as TypeName, r as EscapeStrategy } from "./ast-DDhHuwaY.js";
2
- import { A as FunctionCall, B as StreamedIslands, C as HtmlCheck, D as AnalysedProp, E as PrecompiledTemplate, F as DeferredIslands, G as KilnRenderError, H as islandScript, I as IslandEntry, K as KilnSyntaxError, L as IslandManifest, M as AbortSignalLike, N as KilnCache, O as Analysis, P as RenderInfo, R as IslandMode, S as withRender, T as HtmlChecks, U as streamIslands, V as deferIslands, W as Diagnostic, _ as TemplateName, a as KilnGlobals, b as memoryCache, c as KilnTemplates, d as Limits, f as Loader, g as TemplateContext, h as TemplateBlock, i as KilnFunctions, j as TemplateReference, k as CallArgument, l as KilnTests, m as RenderOptions, n as KilnCallable, o as KilnOptions, p as RenderAware, q as TemplateLocation, r as KilnFilters, s as KilnSchema, t as Kiln, u as KilnTypes, v as TypeChecks, w as HtmlCheckLevel, x as memoryLoader, y as createKiln, z as JsonValue } from "./environment-CgQfwDAJ.js";
1
+ import { c as PropType, l as ShapeKey, m as Position, p as TypeName, r as EscapeStrategy } from "./ast-DzzSn9tS.js";
2
+ import { A as CallArgument, B as IslandMode, C as withRender, D as PrecompiledTemplate, E as HtmlChecks, F as KilnCache, G as streamIslands, H as StreamedIslands, I as RenderInfo, J as KilnSyntaxError, K as Diagnostic, L as DeferredIslands, M as TemplateExport, N as TemplateReference, O as AnalysedProp, P as AbortSignalLike, R as IslandEntry, S as memoryLoader, T as HtmlCheckLevel, U as deferIslands, V as JsonValue, W as islandScript, Y as TemplateLocation, _ as TemplateName, a as KilnGlobals, b as createKiln, c as KilnTemplates, d as Limits, f as Loader, g as TemplateContext, h as TemplateBlock, i as KilnFunctions, j as FunctionCall, k as Analysis, l as KilnTests, m as RenderOptions, n as KilnCallable, o as KilnOptions, p as RenderAware, q as KilnRenderError, r as KilnFilters, s as KilnSchema, t as Kiln, u as KilnTypes, v as TypeChecks, w as HtmlCheck, x as memoryCache, y as builtins, z as IslandManifest } from "./environment-CFAjojgY.js";
3
3
  //#region src/runtime/markup.d.ts
4
4
  /**
5
5
  * A string that is already safe to output with one escaping strategy.
@@ -87,5 +87,5 @@ export declare const generateManifest: <State, Schema extends KilnSchema>(kiln:
87
87
  */
88
88
  export declare const generateTypes: (kiln: Pick<Kiln, "analyze">, names: Iterable<string>) => Promise<string>;
89
89
  //#endregion
90
- export { type AbortSignalLike, type AnalysedProp, type Analysis, type CallArgument, type DeferredIslands, type Diagnostic, type EscapeStrategy, type FunctionCall, type HtmlCheck, type HtmlCheckLevel, type HtmlChecks, type IslandEntry, type IslandManifest, type IslandMode, type JsonValue, type Kiln, type KilnCache, type KilnCallable, type KilnFilters, type KilnFunctions, type KilnGlobals, type KilnManifest, type KilnOptions, KilnRenderError, type KilnSchema, KilnSyntaxError, type KilnTemplates, type KilnTests, type KilnTypes, type Limits, type Loader, type Position, type PrecompiledTemplate, type PropType, type RenderAware, type RenderInfo, type RenderOptions, type ShapeKey, type StreamedIslands, type TemplateBlock, type TemplateContext, type TemplateLocation, type TemplateName, type TemplateReference, type TypeChecks, type TypeName, createKiln, deferIslands, islandScript, memoryCache, memoryLoader, streamIslands, withRender };
90
+ export { type AbortSignalLike, type AnalysedProp, type Analysis, type CallArgument, type DeferredIslands, type Diagnostic, type EscapeStrategy, type FunctionCall, type HtmlCheck, type HtmlCheckLevel, type HtmlChecks, type IslandEntry, type IslandManifest, type IslandMode, type JsonValue, type Kiln, type KilnCache, type KilnCallable, type KilnFilters, type KilnFunctions, type KilnGlobals, type KilnManifest, type KilnOptions, KilnRenderError, type KilnSchema, KilnSyntaxError, type KilnTemplates, type KilnTests, type KilnTypes, type Limits, type Loader, type Position, type PrecompiledTemplate, type PropType, type RenderAware, type RenderInfo, type RenderOptions, type ShapeKey, type StreamedIslands, type TemplateBlock, type TemplateContext, type TemplateExport, type TemplateLocation, type TemplateName, type TemplateReference, type TypeChecks, type TypeName, builtins, createKiln, deferIslands, islandScript, memoryCache, memoryLoader, streamIslands, withRender };
91
91
  //# sourceMappingURL=index.d.ts.map