tyfigo 0.2.0-next.a30eb96.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/README.md +28 -4
  2. package/dist/bun.d.mts +8 -1
  3. package/dist/bun.mjs +7 -7
  4. package/dist/bun.mjs.map +1 -1
  5. package/dist/effect.mjs +2 -2
  6. package/dist/{env-Bd-1Atoz.mjs → env--pSRlq_k.mjs} +2 -2
  7. package/dist/{env-Bd-1Atoz.mjs.map → env--pSRlq_k.mjs.map} +1 -1
  8. package/dist/env-Dv5OHfEf.mjs +51 -0
  9. package/dist/env-Dv5OHfEf.mjs.map +1 -0
  10. package/dist/{formats-D_dKXoPf.mjs → formats-Bf8-iQw-.mjs} +43 -15
  11. package/dist/{formats-D_dKXoPf.mjs.map → formats-Bf8-iQw-.mjs.map} +1 -1
  12. package/dist/index.mjs +1 -1
  13. package/dist/{load-C-kweoyY.d.mts → load-D1KO5LdK.d.mts} +6 -4
  14. package/dist/{load-DxIjRpX6.mjs → load-yFCdP4to.mjs} +49 -23
  15. package/dist/load-yFCdP4to.mjs.map +1 -0
  16. package/dist/mapper.mjs +28 -11
  17. package/dist/mapper.mjs.map +1 -1
  18. package/dist/plugins/esbuild.d.mts +2 -2
  19. package/dist/plugins/esbuild.mjs +1 -1
  20. package/dist/plugins/jest.d.mts +1 -1
  21. package/dist/plugins/jest.mjs +4 -4
  22. package/dist/plugins/loader.d.mts +1 -1
  23. package/dist/plugins/loader.mjs +3 -2
  24. package/dist/plugins/loader.mjs.map +1 -1
  25. package/dist/plugins/next.d.mts +1 -1
  26. package/dist/plugins/next.mjs +9 -4
  27. package/dist/plugins/next.mjs.map +1 -1
  28. package/dist/plugins/rolldown.d.mts +2 -2
  29. package/dist/plugins/rolldown.mjs +1 -1
  30. package/dist/plugins/rollup.d.mts +2 -2
  31. package/dist/plugins/rollup.mjs +1 -1
  32. package/dist/plugins/rsbuild.d.mts +2 -2
  33. package/dist/plugins/rsbuild.mjs +1 -1
  34. package/dist/plugins/rspack.d.mts +2 -2
  35. package/dist/plugins/rspack.mjs +1 -1
  36. package/dist/plugins/vite.d.mts +2 -2
  37. package/dist/plugins/vite.mjs +1 -1
  38. package/dist/plugins/webpack.d.mts +2 -2
  39. package/dist/plugins/webpack.mjs +1 -1
  40. package/dist/problems-DS_eJB6e.mjs +86 -0
  41. package/dist/problems-DS_eJB6e.mjs.map +1 -0
  42. package/dist/register.mjs +5 -5
  43. package/dist/register.mjs.map +1 -1
  44. package/dist/{resolve-D3geHCGs.mjs → resolve-DQfTdYJN.mjs} +32 -12
  45. package/dist/resolve-DQfTdYJN.mjs.map +1 -0
  46. package/dist/runtime/index.d.mts +13 -4
  47. package/dist/runtime/index.mjs +2 -2
  48. package/dist/{runtime-DeRUtPZ9.mjs → runtime-B3GmIYop.mjs} +13 -9
  49. package/dist/runtime-B3GmIYop.mjs.map +1 -0
  50. package/dist/{shared-CZ44uwQq.d.mts → shared-B6Y3_kdn.d.mts} +6 -5
  51. package/dist/{shared-BnK77Zcp.mjs → shared-DOMPQnVO.mjs} +4 -6
  52. package/dist/shared-DOMPQnVO.mjs.map +1 -0
  53. package/dist/{sync-B-HAK-_E.mjs → sync-mWkXcCOW.mjs} +2 -2
  54. package/dist/{sync-B-HAK-_E.mjs.map → sync-mWkXcCOW.mjs.map} +1 -1
  55. package/dist/unplugin-BYfqHkIE.d.mts +2 -0
  56. package/dist/{unplugin-BQGm_bhA.mjs → unplugin-Bkc569Qw.mjs} +10 -8
  57. package/dist/unplugin-Bkc569Qw.mjs.map +1 -0
  58. package/package.json +1 -1
  59. package/dist/env-R3_XPW_u.mjs +0 -78
  60. package/dist/env-R3_XPW_u.mjs.map +0 -1
  61. package/dist/load-DxIjRpX6.mjs.map +0 -1
  62. package/dist/problems-BNAqmOzL.mjs +0 -23
  63. package/dist/problems-BNAqmOzL.mjs.map +0 -1
  64. package/dist/resolve-D3geHCGs.mjs.map +0 -1
  65. package/dist/runtime-DeRUtPZ9.mjs.map +0 -1
  66. package/dist/shared-BnK77Zcp.mjs.map +0 -1
  67. package/dist/unplugin-AC_HM_T2.d.mts +0 -2
  68. package/dist/unplugin-BQGm_bhA.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"formats-D_dKXoPf.mjs","names":["parse","keyName","walk","parse","parseScalar","nodeRange","walk","parse","parseScalar","parse","parse","parseScalar","parse"],"sources":["../src/core/formats/format.ts","../src/core/placeholders.ts","../src/core/formats/ini.ts","../src/core/formats/json5.ts","../src/core/formats/jsonc.ts","../src/core/formats/properties.ts","../src/core/formats/toml.ts","../src/core/formats/xml.ts","../src/core/formats/yaml.ts","../src/core/formats/index.ts"],"sourcesContent":["import { pathKey, SourceIndex } from '../positions.ts';\nimport { problemAt } from '../problems.ts';\n\nimport type { Path, PositionMap, Span } from '../positions.ts';\nimport type { Problem, ProblemCode } from '../problems.ts';\n\nexport type FormatName = 'yaml' | 'toml' | 'jsonc' | 'json5' | 'ini' | 'properties' | 'xml';\n\n/**\n * A parsed config file. `value` is `undefined` when the file could not be parsed at all. An empty file is `{}`.\n */\nexport interface ParseResult {\n\treadonly value: unknown;\n\treadonly positions: PositionMap;\n\treadonly problems: readonly Problem[];\n}\n\nexport interface Format {\n\treadonly name: FormatName;\n\treadonly parse: (text: string, file?: string) => ParseResult;\n\t/**\n\t * Reads the text a whole-value placeholder resolved to with the format's scalar rules. Returns the text itself when it is not a\n\t * number, boolean or null.\n\t */\n\treadonly parseScalar: (text: string) => unknown;\n}\n\nexport class ParseContext {\n\treadonly source: SourceIndex;\n\treadonly file: string;\n\treadonly positions = new Map<string, Span>();\n\treadonly problems: Problem[] = [];\n\n\tconstructor(text: string, file: string) {\n\t\tthis.source = new SourceIndex(text);\n\t\tthis.file = file;\n\t}\n\n\t/**\n\t * Records a span from UTF-16 ranges. The first span recorded for a path wins unless `replace` is set.\n\t */\n\tadd(path: Path, key: readonly [number, number], value: readonly [number, number], replace = true) {\n\t\tconst id = pathKey(path);\n\t\tif (!replace && this.positions.has(id)) return;\n\t\tthis.positions.set(id, this.source.span(path, key, value));\n\t}\n\n\t/**\n\t * Records a problem from a UTF-16 range.\n\t */\n\tproblem(range: readonly [number, number], code: ProblemCode, message: string) {\n\t\tconst start = this.source.byteOffset(range[0]);\n\t\tthis.problems.push(\n\t\t\tproblemAt(this.source, this.file, start, this.source.byteOffset(range[1]) - start, code, message),\n\t\t);\n\t}\n\n\tresult(value: unknown): ParseResult {\n\t\treturn { value, positions: this.positions, problems: this.problems };\n\t}\n}\n\n/**\n * The scalar rule of formats whose values are all text (INI, `.properties` and XML): `true` and `false` are booleans, a number\n * is a number only when JavaScript prints it back as the same text (`8080`, `-1.5`, not `08080`, `1.50` or `1e3`), and\n * anything else stays a string.\n */\nexport const inferScalar = (text: string): unknown => {\n\tif (text === 'true') return true;\n\tif (text === 'false') return false;\n\tconst number = Number(text);\n\treturn text !== '' && Number.isFinite(number) && String(number) === text ? number : text;\n};\n","import { formatPath, pathKey } from './positions.ts';\nimport { problemAt } from './problems.ts';\n\nimport type { EnvVariables } from './env.ts';\nimport type { Format } from './formats/index.ts';\nimport type { Path, PositionMap, SourceIndex } from './positions.ts';\nimport type { Problem, ProblemCode } from './problems.ts';\n\nexport interface PlaceholderInput {\n\treadonly value: unknown;\n\treadonly positions: PositionMap;\n\treadonly source: SourceIndex;\n\treadonly file: string;\n\treadonly format: Format;\n\treadonly variables: EnvVariables;\n\t/**\n\t * For an environment or local file, the base value at a path, or `undefined` when the base has no such key. A whole-value\n\t * placeholder converts to that value's type. Without it, a placeholder converts to the type of its default, and stays a string\n\t * when it has none.\n\t */\n\treadonly baseValueAt?: ((path: Path) => unknown) | undefined;\n}\n\nexport interface PlaceholderResult {\n\treadonly value: unknown;\n\treadonly problems: readonly Problem[];\n}\n\nconst placeholderPattern = /\\$\\$\\{|\\$\\{([A-Za-z_]\\w*)(?:(:-|:\\?)([^}]*))?\\}|\\$\\{[^}]*\\}?/gu;\n\nconst wholeValuePattern = /^\\$\\{([A-Za-z_]\\w*)(?:(:-|:\\?)([^}]*))?\\}$/u;\n\nexport const hasPlaceholder = (text: string): boolean => text.includes('${');\n\nexport const isPlainObject = (value: unknown): value is Record<string, unknown> =>\n\ttypeof value === 'object' && value !== null && !Array.isArray(value);\n\nexport const kindOf = (value: unknown): string =>\n\tvalue === null ? 'null' : Array.isArray(value) ? 'array' : typeof value;\n\nconst scalarKinds = new Set(['null', 'boolean', 'number']);\n\n/**\n * Replaces `${VAR}`, `${VAR:-default}` and `${VAR:?message}` in every string value. A string that is exactly one placeholder takes\n * the type of its default, or of the base value it overrides (see {@link PlaceholderInput.baseValueAt}), and is read with the\n * format's scalar rules: `${PORT:-3000}` with `PORT=8080` becomes `8080`, while `${PORT}` stays `'8080'`. A value that does not\n * read as that type is a problem. A placeholder inside a longer string stays a string. `$${` is a literal `${`. Keys are never\n * resolved.\n */\nexport const resolvePlaceholders = (input: PlaceholderInput): PlaceholderResult => {\n\tconst problems: Problem[] = [];\n\n\tconst report = (path: Path, raw: string, occurrence: number, code: ProblemCode, message: string) => {\n\t\tconst span = input.positions.get(pathKey(path));\n\t\tif (!span) {\n\t\t\tproblems.push(problemAt(input.source, input.file, 0, 0, code, message));\n\t\t\treturn;\n\t\t}\n\n\t\tconst from = input.source.charIndex(span.valueStart);\n\t\tconst slice = input.source.text.slice(from, input.source.charIndex(span.valueStart + span.valueLength));\n\t\tlet index = -1;\n\t\tfor (let seen = 0; seen <= occurrence; seen++) {\n\t\t\tindex = slice.indexOf(raw, index + 1);\n\t\t\tif (index === -1) break;\n\t\t}\n\n\t\tif (index === -1) {\n\t\t\tproblems.push(problemAt(input.source, input.file, span.valueStart, span.valueLength, code, message));\n\t\t} else {\n\t\t\tconst start = input.source.byteOffset(from + index);\n\t\t\tproblems.push(\n\t\t\t\tproblemAt(\n\t\t\t\t\tinput.source,\n\t\t\t\t\tinput.file,\n\t\t\t\t\tstart,\n\t\t\t\t\tinput.source.byteOffset(from + index + raw.length) - start,\n\t\t\t\t\tcode,\n\t\t\t\t\tmessage,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t};\n\n\tconst convert = (whole: RegExpExecArray, resolved: string, path: Path, failed: boolean): unknown => {\n\t\tconst [text, name = '', operator, argument = ''] = whole;\n\t\tconst sample = input.baseValueAt\n\t\t\t? input.baseValueAt(path)\n\t\t\t: operator === ':-'\n\t\t\t\t? input.format.parseScalar(argument)\n\t\t\t\t: resolved;\n\t\tif (failed) return sample === undefined ? resolved : sample;\n\t\tconst expected = kindOf(sample);\n\t\tif (!scalarKinds.has(expected)) return resolved;\n\n\t\tconst value = input.format.parseScalar(resolved);\n\t\tif (kindOf(value) === expected) return value;\n\t\tconst variable = input.variables[name];\n\t\tconst origin =\n\t\t\tvariable === undefined || (operator === ':-' && variable === '')\n\t\t\t\t? `the default of '${name}'`\n\t\t\t\t: `environment variable '${name}'`;\n\t\treport(\n\t\t\tpath,\n\t\t\ttext,\n\t\t\t0,\n\t\t\t'placeholder-type',\n\t\t\t`Expected ${expected} at '${formatPath(path) || '(root)'}', but ${origin} is ${JSON.stringify(resolved)}`,\n\t\t);\n\t\treturn sample;\n\t};\n\n\tconst resolveString = (text: string, path: Path): unknown => {\n\t\tconst reported = problems.length;\n\t\tconst occurrences = new Map<string, number>();\n\t\tconst resolved = text.replaceAll(\n\t\t\tplaceholderPattern,\n\t\t\t(raw, name: string | undefined, operator: string | undefined, argument: string | undefined) => {\n\t\t\t\tif (raw === '$${') return '${';\n\t\t\t\tconst occurrence = occurrences.get(raw) ?? 0;\n\t\t\t\toccurrences.set(raw, occurrence + 1);\n\t\t\t\tif (name === undefined) {\n\t\t\t\t\treport(\n\t\t\t\t\t\tpath,\n\t\t\t\t\t\traw,\n\t\t\t\t\t\toccurrence,\n\t\t\t\t\t\t'invalid-placeholder',\n\t\t\t\t\t\t`Invalid placeholder '${raw}' at '${formatPath(path)}'`,\n\t\t\t\t\t);\n\t\t\t\t\treturn raw;\n\t\t\t\t}\n\n\t\t\t\tconst variable = input.variables[name];\n\t\t\t\tconst isEmpty = variable === undefined || variable === '';\n\t\t\t\tif (operator === ':-') return isEmpty ? (argument ?? '') : variable;\n\t\t\t\tif (operator === ':?' && isEmpty) {\n\t\t\t\t\treport(\n\t\t\t\t\t\tpath,\n\t\t\t\t\t\traw,\n\t\t\t\t\t\toccurrence,\n\t\t\t\t\t\t'missing-variable',\n\t\t\t\t\t\targument || `Environment variable '${name}' is required`,\n\t\t\t\t\t);\n\t\t\t\t\treturn raw;\n\t\t\t\t}\n\n\t\t\t\tif (variable === undefined) {\n\t\t\t\t\treport(path, raw, occurrence, 'missing-variable', `Environment variable '${name}' is not set`);\n\t\t\t\t\treturn raw;\n\t\t\t\t}\n\n\t\t\t\treturn variable;\n\t\t\t},\n\t\t);\n\t\tconst whole = wholeValuePattern.exec(text);\n\t\treturn whole ? convert(whole, resolved, path, problems.length > reported) : resolved;\n\t};\n\n\tconst visit = (value: unknown, path: Path): unknown => {\n\t\tif (typeof value === 'string') return hasPlaceholder(value) ? resolveString(value, path) : value;\n\t\tif (Array.isArray(value)) return value.map((item, index) => visit(item, [...path, index]));\n\t\tif (isPlainObject(value)) {\n\t\t\treturn Object.fromEntries(Object.entries(value).map(([key, item]) => [key, visit(item, [...path, key])]));\n\t\t}\n\t\treturn value;\n\t};\n\n\treturn { value: visit(input.value, []), problems };\n};\n","import { inferScalar, ParseContext } from './format.ts';\n\nimport { isPlainObject } from '../placeholders.ts';\nimport { pathKey } from '../positions.ts';\n\nimport type { Path } from '../positions.ts';\nimport type { Format, ParseResult } from './format.ts';\n\ntype Range = readonly [number, number];\n\nconst isSpace = (char: string | undefined) => char === ' ' || char === '\\t' || char === '\\r' || char === '\\n';\n\nconst trim = (text: string, [start, end]: Range): Range => {\n\tlet from = start;\n\tlet to = end;\n\twhile (from < to && isSpace(text[from])) from++;\n\twhile (to > from && isSpace(text[to - 1])) to--;\n\treturn [from, to];\n};\n\nconst isComment = (text: string, index: number, start: number) =>\n\t(text[index] === ';' || text[index] === '#') && (index === start || isSpace(text[index - 1]));\n\ninterface Section {\n\treadonly path: Path;\n\treadonly keys: readonly Range[];\n\treadonly start: number;\n\tend: number;\n}\n\nclass IniParser {\n\treadonly context: ParseContext;\n\treadonly text: string;\n\treadonly root: Record<string, unknown> = {};\n\treadonly #arrays = new Map<string, { key: Range; start: number }>();\n\t#target: Record<string, unknown> | undefined = this.root;\n\t#path: Path = [];\n\t#section: Section | undefined;\n\n\tconstructor(context: ParseContext) {\n\t\tthis.context = context;\n\t\tthis.text = context.source.text;\n\t}\n\n\tparse() {\n\t\tlet start = 0;\n\t\twhile (start <= this.text.length) {\n\t\t\tlet end = this.text.indexOf('\\n', start);\n\t\t\tif (end === -1) end = this.text.length;\n\t\t\tthis.line(trim(this.text, [start, end]));\n\t\t\tstart = end + 1;\n\t\t}\n\t\tthis.#closeSection();\n\t}\n\n\tline(range: Range) {\n\t\tconst [start, end] = range;\n\t\tif (start === end || isComment(this.text, start, start)) return;\n\t\tif (this.text[start] === '[') {\n\t\t\tthis.header(range);\n\t\t\treturn;\n\t\t}\n\t\tthis.keyValue(range);\n\t\tif (this.#section) this.#section.end = end;\n\t}\n\n\theader([start, end]: Range) {\n\t\tthis.#closeSection();\n\t\tconst close = this.text.indexOf(']', start);\n\t\tconst rest = close === -1 || close >= end ? undefined : trim(this.text, [close + 1, end]);\n\t\tif (!rest || (rest[0] !== rest[1] && !isComment(this.text, rest[0], rest[0]))) {\n\t\t\tthis.context.problem([start, end], 'parse-error', \"Expected a section header like '[name]'\");\n\t\t\tthis.#target = undefined;\n\t\t\treturn;\n\t\t}\n\n\t\tconst keys: Range[] = [];\n\t\tlet from = start + 1;\n\t\tfor (let index = start + 1; index <= close; index++) {\n\t\t\tif (index < close && this.text[index] !== '.') continue;\n\t\t\tconst part = trim(this.text, [from, index]);\n\t\t\tif (part[0] === part[1]) {\n\t\t\t\tthis.context.problem([start, close + 1], 'parse-error', 'Section names cannot have empty parts');\n\t\t\t\tthis.#target = undefined;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tkeys.push(part);\n\t\t\tfrom = index + 1;\n\t\t}\n\n\t\tlet target = this.root;\n\t\tconst path: string[] = [];\n\t\tfor (const key of keys) {\n\t\t\tconst name = this.text.slice(key[0], key[1]);\n\t\t\tpath.push(name);\n\t\t\tconst existing = target[name];\n\t\t\tif (existing === undefined) target[name] = {};\n\t\t\telse if (!isPlainObject(existing)) {\n\t\t\t\tthis.context.problem(key, 'duplicate-key', `'${path.join('.')}' is already a value`);\n\t\t\t\tthis.#target = undefined;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttarget = target[name] as Record<string, unknown>;\n\t\t}\n\n\t\tthis.#target = target;\n\t\tthis.#path = path;\n\t\tthis.#section = { path, keys, start, end: close + 1 };\n\t}\n\n\t#closeSection() {\n\t\tconst section = this.#section;\n\t\tif (!section) return;\n\t\tfor (const [index, key] of section.keys.entries()) {\n\t\t\tthis.context.add(section.path.slice(0, index + 1), key, [section.start, section.end], false);\n\t\t}\n\t\tthis.#section = undefined;\n\t}\n\n\tkeyValue([start, end]: Range) {\n\t\tconst equals = this.text.indexOf('=', start);\n\t\tif (equals === -1 || equals >= end) {\n\t\t\tthis.context.problem([start, end], 'parse-error', \"Expected '=' after the key\");\n\t\t\treturn;\n\t\t}\n\n\t\tlet key = trim(this.text, [start, equals]);\n\t\tconst isArray = this.text.slice(key[1] - 2, key[1]) === '[]';\n\t\tif (isArray) key = trim(this.text, [key[0], key[1] - 2]);\n\t\tif (key[0] === key[1]) {\n\t\t\tthis.context.problem([start, equals + 1], 'parse-error', 'Expected a key before the value');\n\t\t\treturn;\n\t\t}\n\n\t\tconst value = this.value(trim(this.text, [equals + 1, end]));\n\t\tconst target = this.#target;\n\t\tif (!value || !target) return;\n\n\t\tconst name = this.text.slice(key[0], key[1]);\n\t\tconst path = [...this.#path, name];\n\t\tconst id = pathKey(path);\n\t\tconst existing = target[name];\n\t\tif (isArray) {\n\t\t\tconst array = this.#arrays.get(id);\n\t\t\tif (existing !== undefined && !array) {\n\t\t\t\tthis.context.problem(key, 'duplicate-key', `Duplicate key '${name}'`);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst items = (existing as unknown[] | undefined) ?? [];\n\t\t\tconst first = array ?? { key, start: value.range[0] };\n\t\t\tthis.#arrays.set(id, first);\n\t\t\ttarget[name] = [...items, value.value];\n\t\t\tthis.context.add(path, first.key, [first.start, value.range[1]]);\n\t\t\tthis.context.add([...path, items.length], value.range, value.range);\n\t\t\treturn;\n\t\t}\n\n\t\tif (existing !== undefined) {\n\t\t\tthis.context.problem(key, 'duplicate-key', `Duplicate key '${name}'`);\n\t\t\tif (isPlainObject(existing) || Array.isArray(existing)) return;\n\t\t}\n\t\ttarget[name] = value.value;\n\t\tthis.context.add(path, key, value.range);\n\t}\n\n\tvalue(range: Range): { value: unknown; range: Range } | undefined {\n\t\tconst [start, end] = range;\n\t\tconst quote = this.text[start];\n\t\tif (quote !== '\"' && quote !== \"'\") {\n\t\t\tlet to = end;\n\t\t\tfor (let index = start; index < end; index++) {\n\t\t\t\tif (isComment(this.text, index, start)) {\n\t\t\t\t\tto = index;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst value = trim(this.text, [start, to]);\n\t\t\treturn { value: inferScalar(this.text.slice(value[0], value[1])), range: value };\n\t\t}\n\n\t\tlet close = -1;\n\t\tfor (let index = start + 1; index < end; index++) {\n\t\t\tif (quote === '\"' && this.text[index] === '\\\\') index++;\n\t\t\telse if (this.text[index] === quote) {\n\t\t\t\tclose = index;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (close === -1) {\n\t\t\tthis.context.problem(range, 'parse-error', 'Unterminated string');\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst rest = trim(this.text, [close + 1, end]);\n\t\tif (rest[0] !== rest[1] && !isComment(this.text, rest[0], rest[0])) {\n\t\t\tthis.context.problem(rest, 'parse-error', 'Unexpected text after the quoted value');\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst raw = this.text.slice(start, close + 1);\n\t\tif (quote === \"'\") return { value: raw.slice(1, -1), range: [start, close + 1] };\n\t\ttry {\n\t\t\treturn { value: JSON.parse(raw) as string, range: [start, close + 1] };\n\t\t} catch {\n\t\t\tthis.context.problem([start, close + 1], 'parse-error', 'Invalid escape sequence in string');\n\t\t\treturn undefined;\n\t\t}\n\t}\n}\n\nconst parse = (text: string, file = ''): ParseResult => {\n\tconst context = new ParseContext(text, file);\n\tconst parser = new IniParser(context);\n\tparser.parse();\n\tconst root = trim(text, [0, text.length]);\n\tcontext.add([], root, root);\n\treturn context.result(context.problems.some((problem) => problem.code === 'parse-error') ? undefined : parser.root);\n};\n\nexport const ini: Format = { name: 'ini', parse, parseScalar: inferScalar };\n","import { getStaticJSONValue, parseJSON, tokenize } from 'jsonc-eslint-parser';\n\nimport { ParseContext } from './format.ts';\n\nimport type { Path } from '../positions.ts';\nimport type { Format, ParseResult } from './format.ts';\nimport type { AST } from 'jsonc-eslint-parser';\n\nconst syntax = { jsonSyntax: 'JSON5' } as const;\n\nconst keyName = (key: AST.JSONProperty['key']) => (key.type === 'JSONIdentifier' ? key.name : String(key.value));\n\nconst walk = (context: ParseContext, node: AST.JSONExpression, path: Path) => {\n\tif (node.type === 'JSONObjectExpression') {\n\t\tconst seen = new Set<string>();\n\t\tfor (const property of node.properties) {\n\t\t\tconst name = keyName(property.key);\n\t\t\tif (seen.has(name)) context.problem(property.key.range, 'duplicate-key', `Duplicate key '${name}'`);\n\t\t\tseen.add(name);\n\t\t\tconst childPath = [...path, name];\n\t\t\tcontext.add(childPath, property.key.range, property.value.range);\n\t\t\twalk(context, property.value, childPath);\n\t\t}\n\t} else if (node.type === 'JSONArrayExpression') {\n\t\tfor (const [index, item] of node.elements.entries()) {\n\t\t\tif (!item) continue;\n\t\t\tconst childPath = [...path, index];\n\t\t\tcontext.add(childPath, item.range, item.range);\n\t\t\twalk(context, item, childPath);\n\t\t}\n\t}\n};\n\nconst isEmpty = (text: string) => {\n\ttry {\n\t\treturn tokenize(text, syntax).length === 0;\n\t} catch {\n\t\treturn false;\n\t}\n};\n\nconst parse = (text: string, file = ''): ParseResult => {\n\tconst context = new ParseContext(text, file);\n\tif (isEmpty(text)) {\n\t\tcontext.add([], [0, 0], [0, 0]);\n\t\treturn context.result({});\n\t}\n\n\tlet program: AST.JSONProgram;\n\ttry {\n\t\tprogram = parseJSON(text, syntax);\n\t} catch (error) {\n\t\tconst { index = 0, message } = error as Error & { index?: number };\n\t\tcontext.problem([index, index + 1], 'parse-error', message);\n\t\treturn context.result(undefined);\n\t}\n\n\tconst root = program.body[0].expression;\n\tcontext.add([], root.range, root.range);\n\twalk(context, root, []);\n\treturn context.result(getStaticJSONValue(root));\n};\n\nconst parseScalar = (text: string): unknown => {\n\ttry {\n\t\tconst value = getStaticJSONValue(parseJSON(text, syntax).body[0].expression);\n\t\treturn typeof value === 'number' || typeof value === 'boolean' || value === null ? value : text;\n\t} catch {\n\t\treturn text;\n\t}\n};\n\nexport const json5: Format = { name: 'json5', parse, parseScalar };\n","import { getNodeValue, parseTree, printParseErrorCode } from 'jsonc-parser';\n\nimport { ParseContext } from './format.ts';\n\nimport type { Path } from '../positions.ts';\nimport type { Format, ParseResult } from './format.ts';\nimport type { Node, ParseError } from 'jsonc-parser';\n\nconst nodeRange = (node: Node): readonly [number, number] => [node.offset, node.offset + node.length];\n\nconst errorMessage = (error: ParseError) => {\n\tconst words = printParseErrorCode(error.error)\n\t\t.replaceAll(/(?<=[a-z])(?=[A-Z])/gu, ' ')\n\t\t.toLowerCase();\n\treturn words.charAt(0).toUpperCase() + words.slice(1);\n};\n\nconst walk = (context: ParseContext, node: Node, path: Path) => {\n\tif (node.type === 'object') {\n\t\tconst seen = new Set<string>();\n\t\tfor (const property of node.children ?? []) {\n\t\t\tconst [key, value] = property.children ?? [];\n\t\t\tif (key?.type !== 'string') continue;\n\t\t\tconst name = String(key.value);\n\t\t\tif (seen.has(name)) context.problem(nodeRange(key), 'duplicate-key', `Duplicate key '${name}'`);\n\t\t\tseen.add(name);\n\t\t\tconst childPath = [...path, name];\n\t\t\tconst keyRange = nodeRange(key);\n\t\t\tcontext.add(childPath, keyRange, value ? nodeRange(value) : [keyRange[1], keyRange[1]]);\n\t\t\tif (value) walk(context, value, childPath);\n\t\t}\n\t} else if (node.type === 'array') {\n\t\tfor (const [index, item] of (node.children ?? []).entries()) {\n\t\t\tconst childPath = [...path, index];\n\t\t\tcontext.add(childPath, nodeRange(item), nodeRange(item));\n\t\t\twalk(context, item, childPath);\n\t\t}\n\t}\n};\n\nconst parse = (text: string, file = ''): ParseResult => {\n\tconst context = new ParseContext(text, file);\n\tconst errors: ParseError[] = [];\n\tconst root = parseTree(text, errors, { allowTrailingComma: true, disallowComments: false });\n\tif (!root) {\n\t\tconst onlyComments = errors.length === 1 && printParseErrorCode(errors[0]!.error) === 'ValueExpected';\n\t\tif (onlyComments && errors[0]!.offset >= text.trimEnd().length) {\n\t\t\tcontext.add([], [0, 0], [0, 0]);\n\t\t\treturn context.result({});\n\t\t}\n\t}\n\n\tfor (const error of errors) {\n\t\tcontext.problem([error.offset, error.offset + error.length], 'parse-error', errorMessage(error));\n\t}\n\tif (!root) return context.result(undefined);\n\tcontext.add([], nodeRange(root), nodeRange(root));\n\twalk(context, root, []);\n\treturn context.result(getNodeValue(root));\n};\n\nconst parseScalar = (text: string): unknown => {\n\ttry {\n\t\tconst value: unknown = JSON.parse(text);\n\t\treturn typeof value === 'number' || typeof value === 'boolean' || value === null ? value : text;\n\t} catch {\n\t\treturn text;\n\t}\n};\n\nexport const jsonc: Format = { name: 'jsonc', parse, parseScalar };\n","import { inferScalar, ParseContext } from './format.ts';\n\nimport { isPlainObject } from '../placeholders.ts';\n\nimport type { Format, ParseResult } from './format.ts';\n\ntype Range = readonly [number, number];\n\n/**\n * A character of a logical line after escapes, with the source range it was read from.\n */\ninterface Char {\n\treadonly char: string;\n\treadonly start: number;\n\treadonly end: number;\n\treadonly escaped: boolean;\n}\n\nconst isBlank = (char: string | undefined) => char === ' ' || char === '\\t' || char === '\\f';\n\nconst escapes: Readonly<Record<string, string>> = { t: '\\t', n: '\\n', r: '\\r', f: '\\f' };\n\nconst rangeOf = (chars: readonly Char[], fallback: number): Range =>\n\tchars.length === 0 ? [fallback, fallback] : [chars[0]!.start, chars.at(-1)!.end];\n\nclass PropertiesParser {\n\treadonly context: ParseContext;\n\treadonly text: string;\n\treadonly root: Record<string, unknown> = {};\n\n\tconstructor(context: ParseContext) {\n\t\tthis.context = context;\n\t\tthis.text = context.source.text;\n\t}\n\n\t#lineEnd(from: number) {\n\t\tlet index = from;\n\t\twhile (index < this.text.length && this.text[index] !== '\\n' && this.text[index] !== '\\r') index++;\n\t\treturn index;\n\t}\n\n\t#nextLine(end: number) {\n\t\treturn this.text[end] === '\\r' && this.text[end + 1] === '\\n' ? end + 2 : end + 1;\n\t}\n\n\tparse() {\n\t\tlet index = 0;\n\t\twhile (index < this.text.length) {\n\t\t\tlet start = index;\n\t\t\twhile (isBlank(this.text[start])) start++;\n\t\t\tconst end = this.#lineEnd(start);\n\t\t\tif (start === end || this.text[start] === '#' || this.text[start] === '!') {\n\t\t\t\tindex = this.#nextLine(end);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst raw: number[] = [];\n\t\t\tlet from = start;\n\t\t\tfor (;;) {\n\t\t\t\tconst lineEnd = this.#lineEnd(from);\n\t\t\t\tlet backslashes = 0;\n\t\t\t\twhile (lineEnd - backslashes > from && this.text[lineEnd - backslashes - 1] === '\\\\') backslashes++;\n\t\t\t\tconst continues = backslashes % 2 === 1;\n\t\t\t\tfor (let at = from; at < (continues ? lineEnd - 1 : lineEnd); at++) raw.push(at);\n\t\t\t\tindex = this.#nextLine(lineEnd);\n\t\t\t\tif (!continues || index >= this.text.length) break;\n\t\t\t\tfrom = index;\n\t\t\t\twhile (isBlank(this.text[from])) from++;\n\t\t\t}\n\n\t\t\tconst chars = this.decode(raw);\n\t\t\tif (chars) this.entry(chars);\n\t\t}\n\t}\n\n\tdecode(raw: readonly number[]): Char[] | undefined {\n\t\tconst chars: Char[] = [];\n\t\tfor (let index = 0; index < raw.length; index++) {\n\t\t\tconst at = raw[index]!;\n\t\t\tconst char = this.text[at]!;\n\t\t\tif (char !== '\\\\') {\n\t\t\t\tchars.push({ char, start: at, end: at + 1, escaped: false });\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst next = raw[index + 1];\n\t\t\tif (next === undefined) break;\n\t\t\tconst escape = this.text[next]!;\n\t\t\tif (escape === 'u') {\n\t\t\t\tconst digits = raw.slice(index + 2, index + 6);\n\t\t\t\tconst hex = digits.map((digit) => this.text[digit]).join('');\n\t\t\t\tconst end = (digits.at(-1) ?? next) + 1;\n\t\t\t\tif (!/^[\\da-f]{4}$/iu.test(hex)) {\n\t\t\t\t\tthis.context.problem([at, end], 'parse-error', 'Malformed \\\\uXXXX escape');\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\tchars.push({ char: String.fromCodePoint(Number.parseInt(hex, 16)), start: at, end, escaped: true });\n\t\t\t\tindex += 5;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tchars.push({ char: escapes[escape] ?? escape, start: at, end: next + 1, escaped: true });\n\t\t\tindex++;\n\t\t}\n\t\treturn chars;\n\t}\n\n\tentry(chars: readonly Char[]) {\n\t\tconst isSeparator = (char: Char | undefined) =>\n\t\t\tchar !== undefined && !char.escaped && (char.char === '=' || char.char === ':' || isBlank(char.char));\n\t\tconst isSpace = (char: Char | undefined) => char !== undefined && !char.escaped && isBlank(char.char);\n\n\t\tlet index = 0;\n\t\twhile (index < chars.length && !isSeparator(chars[index])) index++;\n\t\tconst key = chars.slice(0, index);\n\t\twhile (isSpace(chars[index])) index++;\n\t\tif (isSeparator(chars[index])) index++;\n\t\twhile (isSpace(chars[index])) index++;\n\t\tlet end = chars.length;\n\t\twhile (end > index && isSpace(chars[end - 1])) end--;\n\t\tconst value = chars.slice(index, end);\n\t\tconst valueRange = rangeOf(value, chars[index - 1]?.end ?? rangeOf(key, 0)[1]);\n\n\t\tif (key.length === 0) {\n\t\t\tthis.context.problem(rangeOf(chars, 0), 'parse-error', 'Expected a key before the value');\n\t\t\treturn;\n\t\t}\n\n\t\tconst parts: Char[][] = [[]];\n\t\tfor (const char of key) {\n\t\t\tif (char.char === '.' && !char.escaped) parts.push([]);\n\t\t\telse parts.at(-1)!.push(char);\n\t\t}\n\t\tconst segments = parts.some((part) => part.length === 0) ? [key] : parts;\n\n\t\tlet target = this.root;\n\t\tconst path: string[] = [];\n\t\tfor (const [position, segment] of segments.entries()) {\n\t\t\tconst name = segment.map((char) => char.char).join('');\n\t\t\tconst keyRange = rangeOf(segment, 0);\n\t\t\tpath.push(name);\n\t\t\tconst existing = target[name];\n\t\t\tif (position === segments.length - 1) {\n\t\t\t\tif (existing !== undefined) {\n\t\t\t\t\tthis.context.problem(keyRange, 'duplicate-key', `Duplicate key '${path.join('.')}'`);\n\t\t\t\t\tif (isPlainObject(existing)) return;\n\t\t\t\t}\n\t\t\t\ttarget[name] = inferScalar(value.map((char) => char.char).join(''));\n\t\t\t\tthis.context.add(path, keyRange, valueRange);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (existing === undefined) target[name] = {};\n\t\t\telse if (!isPlainObject(existing)) {\n\t\t\t\tthis.context.problem(keyRange, 'duplicate-key', `'${path.join('.')}' is already a value`);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.context.add([...path], keyRange, [keyRange[0], valueRange[1]], false);\n\t\t\ttarget = target[name] as Record<string, unknown>;\n\t\t}\n\t}\n}\n\nconst parse = (text: string, file = ''): ParseResult => {\n\tconst context = new ParseContext(text, file);\n\tconst parser = new PropertiesParser(context);\n\tparser.parse();\n\tconst end = text.trimEnd().length;\n\tconst start = Math.min(text.length - text.trimStart().length, end);\n\tcontext.add([], [start, end], [start, end]);\n\treturn context.result(context.problems.some((problem) => problem.code === 'parse-error') ? undefined : parser.root);\n};\n\nexport const properties: Format = { name: 'properties', parse, parseScalar: inferScalar };\n","import { getStaticTOMLValue, parseTOML } from 'toml-eslint-parser';\n\nimport { ParseContext } from './format.ts';\n\nimport { pathKey } from '../positions.ts';\n\nimport type { Path } from '../positions.ts';\nimport type { Format, ParseResult } from './format.ts';\nimport type { AST } from 'toml-eslint-parser';\n\ntype Range = readonly [number, number];\n\nconst keyName = (part: AST.TOMLBare | AST.TOMLQuoted) => (part.type === 'TOMLBare' ? part.name : part.value);\n\nclass TomlWalker {\n\treadonly context: ParseContext;\n\treadonly dates: { path: Path; text: string }[] = [];\n\treadonly #arrayStarts = new Map<string, { key: Range; start: number }>();\n\n\tconstructor(context: ParseContext) {\n\t\tthis.context = context;\n\t}\n\n\ttable(table: AST.TOMLTable) {\n\t\tconst parts = table.key.keys;\n\t\tconst path: (string | number)[] = [];\n\t\tlet part = 0;\n\t\tfor (const [index, segment] of table.resolvedKey.entries()) {\n\t\t\tpath.push(segment);\n\t\t\tconst isLast = index === table.resolvedKey.length - 1;\n\t\t\tif (typeof segment === 'number') {\n\t\t\t\tthis.context.add([...path], table.key.range, table.range, isLast);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst keyRange = parts[part++]?.range ?? table.key.range;\n\t\t\tconst nextIsIndex = typeof table.resolvedKey[index + 1] === 'number';\n\t\t\tif (nextIsIndex && table.kind === 'array' && index === table.resolvedKey.length - 2) {\n\t\t\t\tconst id = pathKey(path);\n\t\t\t\tconst first = this.#arrayStarts.get(id) ?? { key: keyRange, start: table.range[0] };\n\t\t\t\tthis.#arrayStarts.set(id, first);\n\t\t\t\tthis.context.add([...path], first.key, [first.start, table.range[1]]);\n\t\t\t} else this.context.add([...path], keyRange, isLast ? table.range : [keyRange[0], table.range[1]], isLast);\n\t\t}\n\n\t\tfor (const keyValue of table.body) this.keyValue(keyValue, table.resolvedKey);\n\t}\n\n\tkeyValue(keyValue: AST.TOMLKeyValue, base: Path) {\n\t\tconst path = [...base];\n\t\tfor (const [index, part] of keyValue.key.keys.entries()) {\n\t\t\tpath.push(keyName(part));\n\t\t\tconst isLast = index === keyValue.key.keys.length - 1;\n\t\t\tthis.context.add(\n\t\t\t\t[...path],\n\t\t\t\tpart.range,\n\t\t\t\tisLast ? keyValue.value.range : [part.range[0], keyValue.range[1]],\n\t\t\t\tisLast,\n\t\t\t);\n\t\t}\n\n\t\tthis.value(keyValue.value, path);\n\t}\n\n\tvalue(node: AST.TOMLContentNode, path: Path) {\n\t\tif (node.type === 'TOMLInlineTable') for (const keyValue of node.body) this.keyValue(keyValue, path);\n\t\telse if (node.type === 'TOMLArray') {\n\t\t\tfor (const [index, item] of node.elements.entries()) {\n\t\t\t\tconst childPath = [...path, index];\n\t\t\t\tthis.context.add(childPath, item.range, item.range);\n\t\t\t\tthis.value(item, childPath);\n\t\t\t}\n\t\t} else if (\n\t\t\tnode.kind !== 'string' &&\n\t\t\tnode.kind !== 'integer' &&\n\t\t\tnode.kind !== 'float' &&\n\t\t\tnode.kind !== 'boolean'\n\t\t) {\n\t\t\tthis.dates.push({ path, text: node.datetime });\n\t\t}\n\t}\n}\n\nconst setAt = (root: unknown, path: Path, value: unknown) => {\n\tlet target = root as Record<string | number, unknown>;\n\tfor (const segment of path.slice(0, -1)) target = target[segment] as Record<string | number, unknown>;\n\ttarget[path.at(-1)!] = value;\n};\n\nconst parse = (text: string, file = ''): ParseResult => {\n\tconst context = new ParseContext(text, file);\n\tlet program: AST.TOMLProgram;\n\ttry {\n\t\tprogram = parseTOML(text);\n\t} catch (error) {\n\t\tconst { index = 0, message } = error as Error & { index?: number };\n\t\tcontext.problem(\n\t\t\t[index, index + 1],\n\t\t\tmessage.startsWith('Defining a key multiple times') ? 'duplicate-key' : 'parse-error',\n\t\t\tmessage,\n\t\t);\n\t\treturn context.result(undefined);\n\t}\n\n\tconst top = program.body[0];\n\tcontext.add([], top.range, top.range);\n\tconst walker = new TomlWalker(context);\n\tfor (const item of top.body) {\n\t\tif (item.type === 'TOMLTable') walker.table(item);\n\t\telse walker.keyValue(item, []);\n\t}\n\n\tconst value = getStaticTOMLValue(program);\n\tfor (const date of walker.dates) setAt(value, date.path, date.text);\n\treturn context.result(value);\n};\n\nconst parseScalar = (text: string): unknown => {\n\tif (/[\\n\\r]/u.test(text)) return text;\n\ttry {\n\t\tconst item = parseTOML(`value = ${text}`).body[0].body[0];\n\t\tif (item?.type !== 'TOMLKeyValue' || item.value.type !== 'TOMLValue') return text;\n\t\tconst { kind, value } = item.value;\n\t\treturn kind === 'integer' || kind === 'float' || kind === 'boolean' ? value : text;\n\t} catch {\n\t\treturn text;\n\t}\n};\n\nexport const toml: Format = { name: 'toml', parse, parseScalar };\n","import { parseXml, XmlElement, XmlError, XmlText } from '@rgrove/parse-xml';\n\nimport { inferScalar, ParseContext } from './format.ts';\n\nimport type { Path } from '../positions.ts';\nimport type { Format, ParseResult } from './format.ts';\n\ntype Range = readonly [number, number];\n\nconst isNameEnd = (char: string | undefined) => char === undefined || /[\\s=/>]/u.test(char);\n\nconst isWhitespace = (text: string) => /^[\\t\\n\\r ]*$/u.test(text);\n\ninterface StartTag {\n\treadonly name: Range;\n\treadonly attributes: ReadonlyMap<string, { readonly name: Range; readonly value: Range }>;\n\treadonly end: number;\n}\n\n/**\n * Reads the ranges of an element's name and attributes from its start tag, which the parser has already checked.\n */\nconst startTag = (text: string, element: XmlElement): StartTag => {\n\tlet index = element.start + 1;\n\tconst name: Range = [index, index + element.name.length];\n\tindex = name[1];\n\tconst attributes = new Map<string, { name: Range; value: Range }>();\n\tfor (;;) {\n\t\twhile (/\\s/u.test(text[index] ?? '')) index++;\n\t\tif (text[index] === '>' || text[index] === '/' || index >= element.end) break;\n\t\tconst nameStart = index;\n\t\twhile (!isNameEnd(text[index])) index++;\n\t\tconst attribute: Range = [nameStart, index];\n\t\twhile (text[index] !== '\"' && text[index] !== \"'\") index++;\n\t\tconst close = text.indexOf(text[index]!, index + 1);\n\t\tattributes.set(text.slice(...attribute), { name: attribute, value: [index, close + 1] });\n\t\tindex = close + 1;\n\t}\n\treturn { name, attributes, end: text.indexOf('>', index) + 1 };\n};\n\nclass XmlWalker {\n\treadonly context: ParseContext;\n\treadonly text: string;\n\n\tconstructor(context: ParseContext) {\n\t\tthis.context = context;\n\t\tthis.text = context.source.text;\n\t}\n\n\t/**\n\t * The value of an element: a scalar for an element with only text, otherwise an object with `@name` attributes, `#text`\n\t * and child elements, where a repeated child element becomes an array.\n\t */\n\telement(element: XmlElement, path: Path, key: (tag: StartTag) => Range): unknown {\n\t\tconst tag = startTag(this.text, element);\n\t\tconst children = element.children.filter((child) => child instanceof XmlElement);\n\t\tconst texts = element.children.filter(\n\t\t\t(child): child is XmlText => child instanceof XmlText && !isWhitespace(child.text),\n\t\t);\n\t\tif (tag.attributes.size === 0 && children.length === 0) {\n\t\t\tconst selfClosing = this.text[tag.end - 2] === '/';\n\t\t\tconst content: Range = [tag.end, this.text.lastIndexOf('</', element.end - 1)];\n\t\t\tthis.context.add(path, key(tag), selfClosing ? [element.start, element.end] : content);\n\t\t\treturn inferScalar(element.text);\n\t\t}\n\n\t\tthis.context.add(path, key(tag), [element.start, element.end]);\n\t\tconst value: Record<string, unknown> = {};\n\t\tfor (const [name, attribute] of tag.attributes) {\n\t\t\tthis.context.add([...path, `@${name}`], attribute.name, attribute.value);\n\t\t\tvalue[`@${name}`] = inferScalar(element.attributes[name] ?? '');\n\t\t}\n\n\t\tif (texts.length > 0) {\n\t\t\tconst range: Range = [texts[0]!.start, texts.at(-1)!.end];\n\t\t\tthis.context.add([...path, '#text'], range, range);\n\t\t\tvalue['#text'] = inferScalar(texts.map((text) => text.text).join(''));\n\t\t}\n\n\t\tconst groups = Map.groupBy(children, (child) => child.name);\n\t\tfor (const [name, group] of groups) {\n\t\t\tconst childPath = [...path, name];\n\t\t\tif (group.length === 1) {\n\t\t\t\tvalue[name] = this.element(group[0]!, childPath, (child) => child.name);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst first = startTag(this.text, group[0]!);\n\t\t\tthis.context.add(childPath, first.name, [group[0]!.start, group.at(-1)!.end]);\n\t\t\tvalue[name] = group.map((child, index) => this.element(child, [...childPath, index], (item) => item.name));\n\t\t}\n\t\treturn value;\n\t}\n}\n\nconst markup = /<!--[\\s\\S]*?-->|<\\?[\\s\\S]*?\\?>/gu;\n\nconst parse = (text: string, file = ''): ParseResult => {\n\tconst context = new ParseContext(text, file);\n\tif (isWhitespace(text.replaceAll(markup, ''))) {\n\t\tcontext.add([], [0, 0], [0, 0]);\n\t\treturn context.result({});\n\t}\n\n\tlet root: XmlElement;\n\ttry {\n\t\tconst document = parseXml(text, { includeOffsets: true });\n\t\troot = document.root!;\n\t} catch (error) {\n\t\tif (!(error instanceof XmlError)) throw error;\n\t\tconst message = error.message.split('\\n')[0]!.replace(/ \\(line \\d+, column \\d+\\)$/u, '');\n\t\tcontext.problem([error.pos, error.pos + 1], 'parse-error', message);\n\t\treturn context.result(undefined);\n\t}\n\n\tcontext.add([], [root.start, root.end], [root.start, root.end]);\n\tconst value = new XmlWalker(context).element(root, [root.name], (tag) => tag.name);\n\treturn context.result({ [root.name]: value });\n};\n\nexport const xml: Format = { name: 'xml', parse, parseScalar: inferScalar };\n","import { isAlias, isMap, isNode, isScalar, isSeq, parseDocument } from 'yaml';\n\nimport { ParseContext } from './format.ts';\n\nimport type { Path } from '../positions.ts';\nimport type { Format, ParseResult } from './format.ts';\nimport type { Document, Node } from 'yaml';\n\ntype Range = readonly [number, number];\n\nconst nodeRange = (text: string, node: Node | null | undefined, fallback: number): Range => {\n\tif (!node?.range) return [fallback, fallback];\n\tconst [start] = node.range;\n\tlet end = node.range[1];\n\twhile (end > start && /\\s/u.test(text[end - 1] ?? '')) end--;\n\treturn [start, end];\n};\n\nconst walk = (context: ParseContext, document: Document, node: unknown, path: Path, seen: Set<Node>) => {\n\tconst target = isAlias(node) ? node.resolve(document) : node;\n\tif (!isNode(target) || seen.has(target)) return;\n\tif (isMap(target)) {\n\t\tseen.add(target);\n\t\tfor (const pair of target.items) {\n\t\t\tif (!isScalar(pair.key)) continue;\n\t\t\tconst keyRange = nodeRange(context.source.text, pair.key, 0);\n\t\t\tconst value = pair.value as Node | null;\n\t\t\tconst childPath = [...path, String(pair.key.value)];\n\t\t\tcontext.add(childPath, keyRange, nodeRange(context.source.text, value, keyRange[1]));\n\t\t\twalk(context, document, value, childPath, seen);\n\t\t}\n\t\tseen.delete(target);\n\t} else if (isSeq(target)) {\n\t\tseen.add(target);\n\t\tfor (const [index, item] of target.items.entries()) {\n\t\t\tconst range = nodeRange(context.source.text, item as Node | null, target.range?.[0] ?? 0);\n\t\t\tconst childPath = [...path, index];\n\t\t\tcontext.add(childPath, range, range);\n\t\t\twalk(context, document, item, childPath, seen);\n\t\t}\n\t\tseen.delete(target);\n\t}\n};\n\nconst parse = (text: string, file = ''): ParseResult => {\n\tconst context = new ParseContext(text, file);\n\tconst document = parseDocument(text, { prettyErrors: false });\n\tfor (const error of document.errors) {\n\t\tcontext.problem(error.pos, error.code === 'DUPLICATE_KEY' ? 'duplicate-key' : 'parse-error', error.message);\n\t}\n\tif (document.contents === null) {\n\t\tcontext.add([], [0, 0], [0, 0]);\n\t\treturn context.result({});\n\t}\n\n\tconst root = nodeRange(text, document.contents, 0);\n\tcontext.add([], root, root);\n\twalk(context, document, document.contents, [], new Set());\n\n\tlet value: unknown;\n\ttry {\n\t\tvalue = document.toJS();\n\t} catch (error) {\n\t\tcontext.problem(root, 'parse-error', (error as Error).message);\n\t\treturn context.result(undefined);\n\t}\n\treturn context.result(value);\n};\n\nconst parseScalar = (text: string): unknown => {\n\tif (text === '') return text;\n\tconst document = parseDocument(text, { prettyErrors: false });\n\tconst node = document.contents;\n\tif (document.errors.length > 0 || !isScalar(node) || node.type !== 'PLAIN') return text;\n\tif (node.range[0] !== 0 || node.range[1] !== text.length) return text;\n\treturn node.value;\n};\n\nexport const yaml: Format = { name: 'yaml', parse, parseScalar };\n","import { ini } from './ini.ts';\nimport { json5 } from './json5.ts';\nimport { jsonc } from './jsonc.ts';\nimport { properties } from './properties.ts';\nimport { toml } from './toml.ts';\nimport { xml } from './xml.ts';\nimport { yaml } from './yaml.ts';\n\nimport type { Format } from './format.ts';\n\nexport type { Format, FormatName, ParseResult } from './format.ts';\nexport { ini } from './ini.ts';\nexport { json5 } from './json5.ts';\nexport { jsonc } from './jsonc.ts';\nexport { properties } from './properties.ts';\nexport { toml } from './toml.ts';\nexport { xml } from './xml.ts';\nexport { yaml } from './yaml.ts';\n\nexport const formats: Readonly<Record<string, Format>> = {\n\t'.config.yaml': yaml,\n\t'.config.yml': yaml,\n\t'.config.toml': toml,\n\t'.config.jsonc': jsonc,\n\t'.config.json5': json5,\n\t'.config.ini': ini,\n\t'.config.properties': properties,\n\t'.config.xml': xml,\n};\n\nexport const configSuffixes = Object.keys(formats);\n\nexport interface ConfigFileName {\n\t/**\n\t * The file name before the suffix, `app` for `app.config.yaml`.\n\t */\n\treadonly stem: string;\n\t/**\n\t * The claimed suffix, `.config.yaml` for `app.config.yaml`.\n\t */\n\treadonly suffix: string;\n\treadonly format: Format;\n}\n\n/**\n * Splits a config file name (not a path) into its stem and suffix, or returns `undefined` when tyfigo does not claim it.\n */\nexport const parseConfigFileName = (fileName: string): ConfigFileName | undefined => {\n\tfor (const [suffix, format] of Object.entries(formats)) {\n\t\tif (fileName.endsWith(suffix) && fileName.length > suffix.length) {\n\t\t\treturn { stem: fileName.slice(0, -suffix.length), suffix, format };\n\t\t}\n\t}\n\treturn undefined;\n};\n"],"mappings":";;;;;;;;AA2BA,IAAa,eAAb,MAA0B;CACzB;CACA;CACA,4BAAqB,IAAI,IAAkB;CAC3C,WAA+B,CAAC;CAEhC,YAAY,MAAc,MAAc;EACvC,KAAK,SAAS,IAAI,YAAY,IAAI;EAClC,KAAK,OAAO;CACb;;;;CAKA,IAAI,MAAY,KAAgC,OAAkC,UAAU,MAAM;EACjG,MAAM,KAAK,QAAQ,IAAI;EACvB,IAAI,CAAC,WAAW,KAA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pD,IAAI,SAAS,SAAS,MAAM,KAAK,SAAS,SAAS,OAAO,QACzD,OAAO;EAAE,MAAM,SAAS,MAAM,GAAG,CAAC,OAAO,MAAM;EAAG;EAAQ;CAAO;AAIpE"}
1
+ {"version":3,"file":"formats-Bf8-iQw-.mjs","names":["parse","keyName","walk","parse","parseScalar","nodeRange","walk","parse","parseScalar","parse","parse","parseScalar","parse"],"sources":["../src/core/formats/format.ts","../src/core/placeholders.ts","../src/core/formats/ini.ts","../src/core/formats/json5.ts","../src/core/formats/jsonc.ts","../src/core/formats/properties.ts","../src/core/formats/toml.ts","../src/core/formats/xml.ts","../src/core/formats/yaml.ts","../src/core/formats/index.ts"],"sourcesContent":["import { pathKey, SourceIndex } from '../positions.ts';\nimport { problemAt } from '../problems.ts';\n\nimport type { Path, PositionMap, Span } from '../positions.ts';\nimport type { Problem, ProblemCode } from '../problems.ts';\n\nexport type FormatName = 'yaml' | 'toml' | 'jsonc' | 'json5' | 'ini' | 'properties' | 'xml';\n\n/**\n * A parsed config file. `value` is `undefined` when the file could not be parsed at all. An empty file is `{}`.\n */\nexport interface ParseResult {\n\treadonly value: unknown;\n\treadonly positions: PositionMap;\n\treadonly problems: readonly Problem[];\n}\n\nexport interface Format {\n\treadonly name: FormatName;\n\treadonly parse: (text: string, file?: string) => ParseResult;\n\t/**\n\t * Reads the text a whole-value placeholder resolved to with the format's scalar rules. Returns the text itself when it is not a\n\t * number, boolean or null.\n\t */\n\treadonly parseScalar: (text: string) => unknown;\n}\n\nexport class ParseContext {\n\treadonly source: SourceIndex;\n\treadonly file: string;\n\treadonly positions = new Map<string, Span>();\n\treadonly problems: Problem[] = [];\n\n\tconstructor(text: string, file: string) {\n\t\tthis.source = new SourceIndex(text);\n\t\tthis.file = file;\n\t}\n\n\t/**\n\t * Records a span from UTF-16 ranges. The first span recorded for a path wins unless `replace` is set.\n\t */\n\tadd(path: Path, key: readonly [number, number], value: readonly [number, number], replace = true) {\n\t\tconst id = pathKey(path);\n\t\tif (!replace && this.positions.has(id)) return;\n\t\tthis.positions.set(id, this.source.span(path, key, value));\n\t}\n\n\t/**\n\t * Records a problem from a UTF-16 range.\n\t */\n\tproblem(range: readonly [number, number], code: ProblemCode, message: string) {\n\t\tconst start = this.source.byteOffset(range[0]);\n\t\tthis.problems.push(\n\t\t\tproblemAt(this.source, this.file, start, this.source.byteOffset(range[1]) - start, code, message),\n\t\t);\n\t}\n\n\tresult(value: unknown): ParseResult {\n\t\treturn { value, positions: this.positions, problems: this.problems };\n\t}\n}\n\n/**\n * The scalar rule of formats whose values are all text (INI, `.properties` and XML): `true` and `false` are booleans, a number\n * is a number only when JavaScript prints it back as the same text (`8080`, `-1.5`, not `08080`, `1.50` or `1e3`), and\n * anything else stays a string.\n */\nexport const inferScalar = (text: string): unknown => {\n\tif (text === 'true') return true;\n\tif (text === 'false') return false;\n\tconst number = Number(text);\n\treturn text !== '' && Number.isFinite(number) && String(number) === text ? number : text;\n};\n","import { formatPath, pathKey } from './positions.ts';\nimport { problemAt } from './problems.ts';\n\nimport type { EnvVariables } from './env.ts';\nimport type { Format } from './formats/index.ts';\nimport type { Path, PositionMap, SourceIndex } from './positions.ts';\nimport type { Problem, ProblemCode } from './problems.ts';\n\nexport interface PlaceholderInput {\n\treadonly value: unknown;\n\treadonly positions: PositionMap;\n\treadonly source: SourceIndex;\n\treadonly file: string;\n\treadonly format: Format;\n\treadonly variables: EnvVariables;\n\t/**\n\t * For an environment or local file, the base value at a path, or `undefined` when the base has no such key. A whole-value\n\t * placeholder converts to that value's type. Without it, a placeholder converts to the type of its default, and stays a string\n\t * when it has none.\n\t */\n\treadonly baseValueAt?: ((path: Path) => unknown) | undefined;\n}\n\nexport interface PlaceholderResult {\n\treadonly value: unknown;\n\treadonly problems: readonly Problem[];\n}\n\nconst placeholderPattern = /\\$\\$\\{|\\$\\{([A-Za-z_]\\w*)(?:(:-|:\\?)([^}]*))?\\}|\\$\\{[^}]*\\}?/gu;\n\nconst wholeValuePattern = /^\\$\\{([A-Za-z_]\\w*)(?:(:-|:\\?)([^}]*))?\\}$/u;\n\nexport const hasPlaceholder = (text: string): boolean => text.includes('${');\n\nexport const isPlainObject = (value: unknown): value is Record<string, unknown> =>\n\ttypeof value === 'object' && value !== null && !Array.isArray(value);\n\nexport const kindOf = (value: unknown): string =>\n\tvalue === null ? 'null' : Array.isArray(value) ? 'array' : typeof value;\n\nconst scalarKinds = new Set(['null', 'boolean', 'number']);\n\n/**\n * Replaces `${VAR}`, `${VAR:-default}` and `${VAR:?message}` in every string value. A string that is exactly one placeholder takes\n * the type of its default, or of the base value it overrides (see {@link PlaceholderInput.baseValueAt}), and is read with the\n * format's scalar rules: `${PORT:-3000}` with `PORT=8080` becomes `8080`, while `${PORT}` stays `'8080'`. A value that does not\n * read as that type is a problem. A placeholder inside a longer string stays a string. `$${` is a literal `${`. Keys are never\n * resolved.\n */\nexport const resolvePlaceholders = (input: PlaceholderInput): PlaceholderResult => {\n\tconst problems: Problem[] = [];\n\n\tconst report = (path: Path, raw: string, occurrence: number, code: ProblemCode, message: string) => {\n\t\tconst span = input.positions.get(pathKey(path));\n\t\tif (!span) {\n\t\t\tproblems.push(problemAt(input.source, input.file, 0, 0, code, message));\n\t\t\treturn;\n\t\t}\n\n\t\tconst from = input.source.charIndex(span.valueStart);\n\t\tconst slice = input.source.text.slice(from, input.source.charIndex(span.valueStart + span.valueLength));\n\t\tlet index = -1;\n\t\tfor (let seen = 0; seen <= occurrence; seen++) {\n\t\t\tindex = slice.indexOf(raw, index + 1);\n\t\t\tif (index === -1) break;\n\t\t}\n\n\t\tif (index === -1) {\n\t\t\tproblems.push(problemAt(input.source, input.file, span.valueStart, span.valueLength, code, message));\n\t\t} else {\n\t\t\tconst start = input.source.byteOffset(from + index);\n\t\t\tproblems.push(\n\t\t\t\tproblemAt(\n\t\t\t\t\tinput.source,\n\t\t\t\t\tinput.file,\n\t\t\t\t\tstart,\n\t\t\t\t\tinput.source.byteOffset(from + index + raw.length) - start,\n\t\t\t\t\tcode,\n\t\t\t\t\tmessage,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t};\n\n\tconst convert = (whole: RegExpExecArray, resolved: string, path: Path, failed: boolean): unknown => {\n\t\tconst [text, name = '', operator, argument = ''] = whole;\n\t\tconst sample = input.baseValueAt\n\t\t\t? input.baseValueAt(path)\n\t\t\t: operator === ':-'\n\t\t\t\t? input.format.parseScalar(argument)\n\t\t\t\t: resolved;\n\t\tif (failed) return sample === undefined ? resolved : sample;\n\t\tconst expected = kindOf(sample);\n\t\tif (!scalarKinds.has(expected)) return resolved;\n\n\t\tconst value = input.format.parseScalar(resolved);\n\t\tif (kindOf(value) === expected) return value;\n\t\tconst variable = input.variables[name];\n\t\tconst origin =\n\t\t\tvariable === undefined || (operator === ':-' && variable === '')\n\t\t\t\t? `the default of '${name}'`\n\t\t\t\t: `environment variable '${name}'`;\n\t\treport(\n\t\t\tpath,\n\t\t\ttext,\n\t\t\t0,\n\t\t\t'placeholder-type',\n\t\t\t`Expected ${expected} at '${formatPath(path) || '(root)'}', but ${origin} is ${JSON.stringify(resolved)}`,\n\t\t);\n\t\treturn sample;\n\t};\n\n\tconst resolveString = (text: string, path: Path): unknown => {\n\t\tconst reported = problems.length;\n\t\tconst occurrences = new Map<string, number>();\n\t\tconst resolved = text.replaceAll(\n\t\t\tplaceholderPattern,\n\t\t\t(raw, name: string | undefined, operator: string | undefined, argument: string | undefined) => {\n\t\t\t\tif (raw === '$${') return '${';\n\t\t\t\tconst occurrence = occurrences.get(raw) ?? 0;\n\t\t\t\toccurrences.set(raw, occurrence + 1);\n\t\t\t\tif (name === undefined) {\n\t\t\t\t\treport(\n\t\t\t\t\t\tpath,\n\t\t\t\t\t\traw,\n\t\t\t\t\t\toccurrence,\n\t\t\t\t\t\t'invalid-placeholder',\n\t\t\t\t\t\t`Invalid placeholder '${raw}' at '${formatPath(path)}'`,\n\t\t\t\t\t);\n\t\t\t\t\treturn raw;\n\t\t\t\t}\n\n\t\t\t\tconst variable = input.variables[name];\n\t\t\t\tconst isEmpty = variable === undefined || variable === '';\n\t\t\t\tif (operator === ':-') return isEmpty ? (argument ?? '') : variable;\n\t\t\t\tif (operator === ':?' && isEmpty) {\n\t\t\t\t\treport(\n\t\t\t\t\t\tpath,\n\t\t\t\t\t\traw,\n\t\t\t\t\t\toccurrence,\n\t\t\t\t\t\t'missing-variable',\n\t\t\t\t\t\targument || `Environment variable '${name}' is required`,\n\t\t\t\t\t);\n\t\t\t\t\treturn raw;\n\t\t\t\t}\n\n\t\t\t\tif (variable === undefined) {\n\t\t\t\t\treport(path, raw, occurrence, 'missing-variable', `Environment variable '${name}' is not set`);\n\t\t\t\t\treturn raw;\n\t\t\t\t}\n\n\t\t\t\treturn variable;\n\t\t\t},\n\t\t);\n\t\tconst whole = wholeValuePattern.exec(text);\n\t\treturn whole ? convert(whole, resolved, path, problems.length > reported) : resolved;\n\t};\n\n\tconst visit = (value: unknown, path: Path): unknown => {\n\t\tif (typeof value === 'string') return hasPlaceholder(value) ? resolveString(value, path) : value;\n\t\tif (Array.isArray(value)) return value.map((item, index) => visit(item, [...path, index]));\n\t\tif (isPlainObject(value)) {\n\t\t\treturn Object.fromEntries(Object.entries(value).map(([key, item]) => [key, visit(item, [...path, key])]));\n\t\t}\n\t\treturn value;\n\t};\n\n\treturn { value: visit(input.value, []), problems };\n};\n","import { inferScalar, ParseContext } from './format.ts';\n\nimport { isPlainObject } from '../placeholders.ts';\nimport { pathKey } from '../positions.ts';\n\nimport type { Path } from '../positions.ts';\nimport type { Format, ParseResult } from './format.ts';\n\ntype Range = readonly [number, number];\n\nconst isSpace = (char: string | undefined) => char === ' ' || char === '\\t' || char === '\\r' || char === '\\n';\n\nconst trim = (text: string, [start, end]: Range): Range => {\n\tlet from = start;\n\tlet to = end;\n\twhile (from < to && isSpace(text[from])) from++;\n\twhile (to > from && isSpace(text[to - 1])) to--;\n\treturn [from, to];\n};\n\nconst isComment = (text: string, index: number, start: number) =>\n\t(text[index] === ';' || text[index] === '#') && (index === start || isSpace(text[index - 1]));\n\ninterface Section {\n\treadonly path: Path;\n\treadonly keys: readonly Range[];\n\treadonly start: number;\n\tend: number;\n}\n\nclass IniParser {\n\treadonly context: ParseContext;\n\treadonly text: string;\n\treadonly root: Record<string, unknown> = {};\n\treadonly #arrays = new Map<string, { key: Range; start: number }>();\n\t#target: Record<string, unknown> | undefined = this.root;\n\t#path: Path = [];\n\t#section: Section | undefined;\n\n\tconstructor(context: ParseContext) {\n\t\tthis.context = context;\n\t\tthis.text = context.source.text;\n\t}\n\n\tparse() {\n\t\tlet start = 0;\n\t\twhile (start <= this.text.length) {\n\t\t\tlet end = this.text.indexOf('\\n', start);\n\t\t\tif (end === -1) end = this.text.length;\n\t\t\tthis.line(trim(this.text, [start, end]));\n\t\t\tstart = end + 1;\n\t\t}\n\t\tthis.#closeSection();\n\t}\n\n\tline(range: Range) {\n\t\tconst [start, end] = range;\n\t\tif (start === end || isComment(this.text, start, start)) return;\n\t\tif (this.text[start] === '[') {\n\t\t\tthis.header(range);\n\t\t\treturn;\n\t\t}\n\t\tthis.keyValue(range);\n\t\tif (this.#section) this.#section.end = end;\n\t}\n\n\theader([start, end]: Range) {\n\t\tthis.#closeSection();\n\t\tconst close = this.text.indexOf(']', start);\n\t\tconst rest = close === -1 || close >= end ? undefined : trim(this.text, [close + 1, end]);\n\t\tif (!rest || (rest[0] !== rest[1] && !isComment(this.text, rest[0], rest[0]))) {\n\t\t\tthis.context.problem([start, end], 'parse-error', \"Expected a section header like '[name]'\");\n\t\t\tthis.#target = undefined;\n\t\t\treturn;\n\t\t}\n\n\t\tconst keys: Range[] = [];\n\t\tlet from = start + 1;\n\t\tfor (let index = start + 1; index <= close; index++) {\n\t\t\tif (index < close && this.text[index] !== '.') continue;\n\t\t\tconst part = trim(this.text, [from, index]);\n\t\t\tif (part[0] === part[1]) {\n\t\t\t\tthis.context.problem([start, close + 1], 'parse-error', 'Section names cannot have empty parts');\n\t\t\t\tthis.#target = undefined;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tkeys.push(part);\n\t\t\tfrom = index + 1;\n\t\t}\n\n\t\tlet target = this.root;\n\t\tconst path: string[] = [];\n\t\tfor (const key of keys) {\n\t\t\tconst name = this.text.slice(key[0], key[1]);\n\t\t\tpath.push(name);\n\t\t\tconst existing = target[name];\n\t\t\tif (existing === undefined) target[name] = {};\n\t\t\telse if (!isPlainObject(existing)) {\n\t\t\t\tthis.context.problem(key, 'duplicate-key', `'${path.join('.')}' is already a value`);\n\t\t\t\tthis.#target = undefined;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttarget = target[name] as Record<string, unknown>;\n\t\t}\n\n\t\tthis.#target = target;\n\t\tthis.#path = path;\n\t\tthis.#section = { path, keys, start, end: close + 1 };\n\t}\n\n\t#closeSection() {\n\t\tconst section = this.#section;\n\t\tif (!section) return;\n\t\tfor (const [index, key] of section.keys.entries()) {\n\t\t\tthis.context.add(section.path.slice(0, index + 1), key, [section.start, section.end], false);\n\t\t}\n\t\tthis.#section = undefined;\n\t}\n\n\tkeyValue([start, end]: Range) {\n\t\tconst equals = this.text.indexOf('=', start);\n\t\tif (equals === -1 || equals >= end) {\n\t\t\tthis.context.problem([start, end], 'parse-error', \"Expected '=' after the key\");\n\t\t\treturn;\n\t\t}\n\n\t\tlet key = trim(this.text, [start, equals]);\n\t\tconst isArray = this.text.slice(key[1] - 2, key[1]) === '[]';\n\t\tif (isArray) key = trim(this.text, [key[0], key[1] - 2]);\n\t\tif (key[0] === key[1]) {\n\t\t\tthis.context.problem([start, equals + 1], 'parse-error', 'Expected a key before the value');\n\t\t\treturn;\n\t\t}\n\n\t\tconst value = this.value(trim(this.text, [equals + 1, end]));\n\t\tconst target = this.#target;\n\t\tif (!value || !target) return;\n\n\t\tconst name = this.text.slice(key[0], key[1]);\n\t\tconst path = [...this.#path, name];\n\t\tconst id = pathKey(path);\n\t\tconst existing = target[name];\n\t\tif (isArray) {\n\t\t\tconst array = this.#arrays.get(id);\n\t\t\tif (existing !== undefined && !array) {\n\t\t\t\tthis.context.problem(key, 'duplicate-key', `Duplicate key '${name}'`);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst items = (existing as unknown[] | undefined) ?? [];\n\t\t\tconst first = array ?? { key, start: value.range[0] };\n\t\t\tthis.#arrays.set(id, first);\n\t\t\ttarget[name] = [...items, value.value];\n\t\t\tthis.context.add(path, first.key, [first.start, value.range[1]]);\n\t\t\tthis.context.add([...path, items.length], value.range, value.range);\n\t\t\treturn;\n\t\t}\n\n\t\tif (existing !== undefined) {\n\t\t\tthis.context.problem(key, 'duplicate-key', `Duplicate key '${name}'`);\n\t\t\tif (isPlainObject(existing) || Array.isArray(existing)) return;\n\t\t}\n\t\ttarget[name] = value.value;\n\t\tthis.context.add(path, key, value.range);\n\t}\n\n\tvalue(range: Range): { value: unknown; range: Range } | undefined {\n\t\tconst [start, end] = range;\n\t\tconst quote = this.text[start];\n\t\tif (quote !== '\"' && quote !== \"'\") {\n\t\t\tlet to = end;\n\t\t\tfor (let index = start; index < end; index++) {\n\t\t\t\tif (isComment(this.text, index, start)) {\n\t\t\t\t\tto = index;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst value = trim(this.text, [start, to]);\n\t\t\treturn { value: inferScalar(this.text.slice(value[0], value[1])), range: value };\n\t\t}\n\n\t\tlet close = -1;\n\t\tfor (let index = start + 1; index < end; index++) {\n\t\t\tif (quote === '\"' && this.text[index] === '\\\\') index++;\n\t\t\telse if (this.text[index] === quote) {\n\t\t\t\tclose = index;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (close === -1) {\n\t\t\tthis.context.problem(range, 'parse-error', 'Unterminated string');\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst rest = trim(this.text, [close + 1, end]);\n\t\tif (rest[0] !== rest[1] && !isComment(this.text, rest[0], rest[0])) {\n\t\t\tthis.context.problem(rest, 'parse-error', 'Unexpected text after the quoted value');\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst raw = this.text.slice(start, close + 1);\n\t\tif (quote === \"'\") return { value: raw.slice(1, -1), range: [start, close + 1] };\n\t\ttry {\n\t\t\treturn { value: JSON.parse(raw) as string, range: [start, close + 1] };\n\t\t} catch {\n\t\t\tthis.context.problem([start, close + 1], 'parse-error', 'Invalid escape sequence in string');\n\t\t\treturn undefined;\n\t\t}\n\t}\n}\n\nconst parse = (text: string, file = ''): ParseResult => {\n\tconst context = new ParseContext(text, file);\n\tconst parser = new IniParser(context);\n\tparser.parse();\n\tconst root = trim(text, [0, text.length]);\n\tcontext.add([], root, root);\n\treturn context.result(context.problems.some((problem) => problem.code === 'parse-error') ? undefined : parser.root);\n};\n\nexport const ini: Format = { name: 'ini', parse, parseScalar: inferScalar };\n","import { getStaticJSONValue, parseJSON, tokenize } from 'jsonc-eslint-parser';\n\nimport { ParseContext } from './format.ts';\n\nimport type { Path } from '../positions.ts';\nimport type { Format, ParseResult } from './format.ts';\nimport type { AST } from 'jsonc-eslint-parser';\n\nconst syntax = { jsonSyntax: 'JSON5' } as const;\n\nconst keyName = (key: AST.JSONProperty['key']) => (key.type === 'JSONIdentifier' ? key.name : String(key.value));\n\nconst walk = (context: ParseContext, node: AST.JSONExpression, path: Path) => {\n\tif (node.type === 'JSONObjectExpression') {\n\t\tconst seen = new Set<string>();\n\t\tfor (const property of node.properties) {\n\t\t\tconst name = keyName(property.key);\n\t\t\tif (seen.has(name)) context.problem(property.key.range, 'duplicate-key', `Duplicate key '${name}'`);\n\t\t\tseen.add(name);\n\t\t\tconst childPath = [...path, name];\n\t\t\tcontext.add(childPath, property.key.range, property.value.range);\n\t\t\twalk(context, property.value, childPath);\n\t\t}\n\t} else if (node.type === 'JSONArrayExpression') {\n\t\tfor (const [index, item] of node.elements.entries()) {\n\t\t\tif (!item) continue;\n\t\t\tconst childPath = [...path, index];\n\t\t\tcontext.add(childPath, item.range, item.range);\n\t\t\twalk(context, item, childPath);\n\t\t}\n\t}\n};\n\nconst isEmpty = (text: string) => {\n\ttry {\n\t\treturn tokenize(text, syntax).length === 0;\n\t} catch {\n\t\treturn false;\n\t}\n};\n\nconst parse = (text: string, file = ''): ParseResult => {\n\tconst context = new ParseContext(text, file);\n\tif (isEmpty(text)) {\n\t\tcontext.add([], [0, 0], [0, 0]);\n\t\treturn context.result({});\n\t}\n\n\tlet program: AST.JSONProgram;\n\ttry {\n\t\tprogram = parseJSON(text, syntax);\n\t} catch (error) {\n\t\tconst { index = 0, message } = error as Error & { index?: number };\n\t\tcontext.problem([index, index + 1], 'parse-error', message);\n\t\treturn context.result(undefined);\n\t}\n\n\tconst root = program.body[0].expression;\n\tcontext.add([], root.range, root.range);\n\twalk(context, root, []);\n\treturn context.result(getStaticJSONValue(root));\n};\n\nconst parseScalar = (text: string): unknown => {\n\ttry {\n\t\tconst value = getStaticJSONValue(parseJSON(text, syntax).body[0].expression);\n\t\treturn typeof value === 'number' || typeof value === 'boolean' || value === null ? value : text;\n\t} catch {\n\t\treturn text;\n\t}\n};\n\nexport const json5: Format = { name: 'json5', parse, parseScalar };\n","import { getNodeValue, parseTree, printParseErrorCode } from 'jsonc-parser';\n\nimport { ParseContext } from './format.ts';\n\nimport type { Path } from '../positions.ts';\nimport type { Format, ParseResult } from './format.ts';\nimport type { Node, ParseError } from 'jsonc-parser';\n\nconst nodeRange = (node: Node): readonly [number, number] => [node.offset, node.offset + node.length];\n\nconst errorMessage = (error: ParseError) => {\n\tconst words = printParseErrorCode(error.error)\n\t\t.replaceAll(/(?<=[a-z])(?=[A-Z])/gu, ' ')\n\t\t.toLowerCase();\n\treturn words.charAt(0).toUpperCase() + words.slice(1);\n};\n\nconst walk = (context: ParseContext, node: Node, path: Path) => {\n\tif (node.type === 'object') {\n\t\tconst seen = new Set<string>();\n\t\tfor (const property of node.children ?? []) {\n\t\t\tconst [key, value] = property.children ?? [];\n\t\t\tif (key?.type !== 'string') continue;\n\t\t\tconst name = String(key.value);\n\t\t\tif (seen.has(name)) context.problem(nodeRange(key), 'duplicate-key', `Duplicate key '${name}'`);\n\t\t\tseen.add(name);\n\t\t\tconst childPath = [...path, name];\n\t\t\tconst keyRange = nodeRange(key);\n\t\t\tcontext.add(childPath, keyRange, value ? nodeRange(value) : [keyRange[1], keyRange[1]]);\n\t\t\tif (value) walk(context, value, childPath);\n\t\t}\n\t} else if (node.type === 'array') {\n\t\tfor (const [index, item] of (node.children ?? []).entries()) {\n\t\t\tconst childPath = [...path, index];\n\t\t\tcontext.add(childPath, nodeRange(item), nodeRange(item));\n\t\t\twalk(context, item, childPath);\n\t\t}\n\t}\n};\n\nconst parse = (text: string, file = ''): ParseResult => {\n\tconst context = new ParseContext(text, file);\n\tconst errors: ParseError[] = [];\n\tconst root = parseTree(text, errors, { allowTrailingComma: true, disallowComments: false });\n\tif (!root) {\n\t\tconst onlyComments = errors.length === 1 && printParseErrorCode(errors[0]!.error) === 'ValueExpected';\n\t\tif (onlyComments && errors[0]!.offset >= text.trimEnd().length) {\n\t\t\tcontext.add([], [0, 0], [0, 0]);\n\t\t\treturn context.result({});\n\t\t}\n\t}\n\n\tfor (const error of errors) {\n\t\tcontext.problem([error.offset, error.offset + error.length], 'parse-error', errorMessage(error));\n\t}\n\tif (!root) return context.result(undefined);\n\tcontext.add([], nodeRange(root), nodeRange(root));\n\twalk(context, root, []);\n\treturn context.result(getNodeValue(root));\n};\n\nconst parseScalar = (text: string): unknown => {\n\ttry {\n\t\tconst value: unknown = JSON.parse(text);\n\t\treturn typeof value === 'number' || typeof value === 'boolean' || value === null ? value : text;\n\t} catch {\n\t\treturn text;\n\t}\n};\n\nexport const jsonc: Format = { name: 'jsonc', parse, parseScalar };\n","import { inferScalar, ParseContext } from './format.ts';\n\nimport { isPlainObject } from '../placeholders.ts';\n\nimport type { Format, ParseResult } from './format.ts';\n\ntype Range = readonly [number, number];\n\n/**\n * A character of a logical line after escapes, with the source range it was read from.\n */\ninterface Char {\n\treadonly char: string;\n\treadonly start: number;\n\treadonly end: number;\n\treadonly escaped: boolean;\n}\n\nconst isBlank = (char: string | undefined) => char === ' ' || char === '\\t' || char === '\\f';\n\nconst escapes: Readonly<Record<string, string>> = { t: '\\t', n: '\\n', r: '\\r', f: '\\f' };\n\nconst rangeOf = (chars: readonly Char[], fallback: number): Range =>\n\tchars.length === 0 ? [fallback, fallback] : [chars[0]!.start, chars.at(-1)!.end];\n\nclass PropertiesParser {\n\treadonly context: ParseContext;\n\treadonly text: string;\n\treadonly root: Record<string, unknown> = {};\n\n\tconstructor(context: ParseContext) {\n\t\tthis.context = context;\n\t\tthis.text = context.source.text;\n\t}\n\n\t#lineEnd(from: number) {\n\t\tlet index = from;\n\t\twhile (index < this.text.length && this.text[index] !== '\\n' && this.text[index] !== '\\r') index++;\n\t\treturn index;\n\t}\n\n\t#nextLine(end: number) {\n\t\treturn this.text[end] === '\\r' && this.text[end + 1] === '\\n' ? end + 2 : end + 1;\n\t}\n\n\tparse() {\n\t\tlet index = 0;\n\t\twhile (index < this.text.length) {\n\t\t\tlet start = index;\n\t\t\twhile (isBlank(this.text[start])) start++;\n\t\t\tconst end = this.#lineEnd(start);\n\t\t\tif (start === end || this.text[start] === '#' || this.text[start] === '!') {\n\t\t\t\tindex = this.#nextLine(end);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst raw: number[] = [];\n\t\t\tlet from = start;\n\t\t\tfor (;;) {\n\t\t\t\tconst lineEnd = this.#lineEnd(from);\n\t\t\t\tlet backslashes = 0;\n\t\t\t\twhile (lineEnd - backslashes > from && this.text[lineEnd - backslashes - 1] === '\\\\') backslashes++;\n\t\t\t\tconst continues = backslashes % 2 === 1;\n\t\t\t\tfor (let at = from; at < (continues ? lineEnd - 1 : lineEnd); at++) raw.push(at);\n\t\t\t\tindex = this.#nextLine(lineEnd);\n\t\t\t\tif (!continues || index >= this.text.length) break;\n\t\t\t\tfrom = index;\n\t\t\t\twhile (isBlank(this.text[from])) from++;\n\t\t\t}\n\n\t\t\tconst chars = this.decode(raw);\n\t\t\tif (chars) this.entry(chars);\n\t\t}\n\t}\n\n\tdecode(raw: readonly number[]): Char[] | undefined {\n\t\tconst chars: Char[] = [];\n\t\tfor (let index = 0; index < raw.length; index++) {\n\t\t\tconst at = raw[index]!;\n\t\t\tconst char = this.text[at]!;\n\t\t\tif (char !== '\\\\') {\n\t\t\t\tchars.push({ char, start: at, end: at + 1, escaped: false });\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst next = raw[index + 1];\n\t\t\tif (next === undefined) break;\n\t\t\tconst escape = this.text[next]!;\n\t\t\tif (escape === 'u') {\n\t\t\t\tconst digits = raw.slice(index + 2, index + 6);\n\t\t\t\tconst hex = digits.map((digit) => this.text[digit]).join('');\n\t\t\t\tconst end = (digits.at(-1) ?? next) + 1;\n\t\t\t\tif (!/^[\\da-f]{4}$/iu.test(hex)) {\n\t\t\t\t\tthis.context.problem([at, end], 'parse-error', 'Malformed \\\\uXXXX escape');\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\tchars.push({ char: String.fromCodePoint(Number.parseInt(hex, 16)), start: at, end, escaped: true });\n\t\t\t\tindex += 5;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tchars.push({ char: escapes[escape] ?? escape, start: at, end: next + 1, escaped: true });\n\t\t\tindex++;\n\t\t}\n\t\treturn chars;\n\t}\n\n\tentry(chars: readonly Char[]) {\n\t\tconst isSeparator = (char: Char | undefined) =>\n\t\t\tchar !== undefined && !char.escaped && (char.char === '=' || char.char === ':' || isBlank(char.char));\n\t\tconst isSpace = (char: Char | undefined) => char !== undefined && !char.escaped && isBlank(char.char);\n\n\t\tlet index = 0;\n\t\twhile (index < chars.length && !isSeparator(chars[index])) index++;\n\t\tconst key = chars.slice(0, index);\n\t\twhile (isSpace(chars[index])) index++;\n\t\tif (isSeparator(chars[index])) index++;\n\t\twhile (isSpace(chars[index])) index++;\n\t\tlet end = chars.length;\n\t\twhile (end > index && isSpace(chars[end - 1])) end--;\n\t\tconst value = chars.slice(index, end);\n\t\tconst valueRange = rangeOf(value, chars[index - 1]?.end ?? rangeOf(key, 0)[1]);\n\n\t\tif (key.length === 0) {\n\t\t\tthis.context.problem(rangeOf(chars, 0), 'parse-error', 'Expected a key before the value');\n\t\t\treturn;\n\t\t}\n\n\t\tconst parts: Char[][] = [[]];\n\t\tfor (const char of key) {\n\t\t\tif (char.char === '.' && !char.escaped) parts.push([]);\n\t\t\telse parts.at(-1)!.push(char);\n\t\t}\n\t\tconst segments = parts.some((part) => part.length === 0) ? [key] : parts;\n\n\t\tlet target = this.root;\n\t\tconst path: string[] = [];\n\t\tfor (const [position, segment] of segments.entries()) {\n\t\t\tconst name = segment.map((char) => char.char).join('');\n\t\t\tconst keyRange = rangeOf(segment, 0);\n\t\t\tpath.push(name);\n\t\t\tconst existing = target[name];\n\t\t\tif (position === segments.length - 1) {\n\t\t\t\tif (existing !== undefined) {\n\t\t\t\t\tthis.context.problem(keyRange, 'duplicate-key', `Duplicate key '${path.join('.')}'`);\n\t\t\t\t\tif (isPlainObject(existing)) return;\n\t\t\t\t}\n\t\t\t\ttarget[name] = inferScalar(value.map((char) => char.char).join(''));\n\t\t\t\tthis.context.add(path, keyRange, valueRange);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (existing === undefined) target[name] = {};\n\t\t\telse if (!isPlainObject(existing)) {\n\t\t\t\tthis.context.problem(keyRange, 'duplicate-key', `'${path.join('.')}' is already a value`);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.context.add([...path], keyRange, [keyRange[0], valueRange[1]], false);\n\t\t\ttarget = target[name] as Record<string, unknown>;\n\t\t}\n\t}\n}\n\nconst parse = (text: string, file = ''): ParseResult => {\n\tconst context = new ParseContext(text, file);\n\tconst parser = new PropertiesParser(context);\n\tparser.parse();\n\tconst end = text.trimEnd().length;\n\tconst start = Math.min(text.length - text.trimStart().length, end);\n\tcontext.add([], [start, end], [start, end]);\n\treturn context.result(context.problems.some((problem) => problem.code === 'parse-error') ? undefined : parser.root);\n};\n\nexport const properties: Format = { name: 'properties', parse, parseScalar: inferScalar };\n","import { getStaticTOMLValue, parseTOML } from 'toml-eslint-parser';\n\nimport { ParseContext } from './format.ts';\n\nimport { pathKey } from '../positions.ts';\n\nimport type { Path } from '../positions.ts';\nimport type { Format, ParseResult } from './format.ts';\nimport type { AST } from 'toml-eslint-parser';\n\ntype Range = readonly [number, number];\n\nconst keyName = (part: AST.TOMLBare | AST.TOMLQuoted) => (part.type === 'TOMLBare' ? part.name : part.value);\n\nclass TomlWalker {\n\treadonly context: ParseContext;\n\treadonly dates: { path: Path; text: string }[] = [];\n\treadonly #arrayStarts = new Map<string, { key: Range; start: number }>();\n\n\tconstructor(context: ParseContext) {\n\t\tthis.context = context;\n\t}\n\n\ttable(table: AST.TOMLTable) {\n\t\tconst parts = table.key.keys;\n\t\tconst path: (string | number)[] = [];\n\t\tlet part = 0;\n\t\tfor (const [index, segment] of table.resolvedKey.entries()) {\n\t\t\tpath.push(segment);\n\t\t\tconst isLast = index === table.resolvedKey.length - 1;\n\t\t\tif (typeof segment === 'number') {\n\t\t\t\tthis.context.add([...path], table.key.range, table.range, isLast);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst keyRange = parts[part++]?.range ?? table.key.range;\n\t\t\tconst nextIsIndex = typeof table.resolvedKey[index + 1] === 'number';\n\t\t\tif (nextIsIndex && table.kind === 'array' && index === table.resolvedKey.length - 2) {\n\t\t\t\tconst id = pathKey(path);\n\t\t\t\tconst first = this.#arrayStarts.get(id) ?? { key: keyRange, start: table.range[0] };\n\t\t\t\tthis.#arrayStarts.set(id, first);\n\t\t\t\tthis.context.add([...path], first.key, [first.start, table.range[1]]);\n\t\t\t} else this.context.add([...path], keyRange, isLast ? table.range : [keyRange[0], table.range[1]], isLast);\n\t\t}\n\n\t\tfor (const keyValue of table.body) this.keyValue(keyValue, table.resolvedKey);\n\t}\n\n\tkeyValue(keyValue: AST.TOMLKeyValue, base: Path) {\n\t\tconst path = [...base];\n\t\tfor (const [index, part] of keyValue.key.keys.entries()) {\n\t\t\tpath.push(keyName(part));\n\t\t\tconst isLast = index === keyValue.key.keys.length - 1;\n\t\t\tthis.context.add(\n\t\t\t\t[...path],\n\t\t\t\tpart.range,\n\t\t\t\tisLast ? keyValue.value.range : [part.range[0], keyValue.range[1]],\n\t\t\t\tisLast,\n\t\t\t);\n\t\t}\n\n\t\tthis.value(keyValue.value, path);\n\t}\n\n\tvalue(node: AST.TOMLContentNode, path: Path) {\n\t\tif (node.type === 'TOMLInlineTable') for (const keyValue of node.body) this.keyValue(keyValue, path);\n\t\telse if (node.type === 'TOMLArray') {\n\t\t\tfor (const [index, item] of node.elements.entries()) {\n\t\t\t\tconst childPath = [...path, index];\n\t\t\t\tthis.context.add(childPath, item.range, item.range);\n\t\t\t\tthis.value(item, childPath);\n\t\t\t}\n\t\t} else if (\n\t\t\tnode.kind !== 'string' &&\n\t\t\tnode.kind !== 'integer' &&\n\t\t\tnode.kind !== 'float' &&\n\t\t\tnode.kind !== 'boolean'\n\t\t) {\n\t\t\tthis.dates.push({ path, text: node.datetime });\n\t\t}\n\t}\n}\n\nconst setAt = (root: unknown, path: Path, value: unknown) => {\n\tlet target = root as Record<string | number, unknown>;\n\tfor (const segment of path.slice(0, -1)) target = target[segment] as Record<string | number, unknown>;\n\ttarget[path.at(-1)!] = value;\n};\n\nconst parse = (text: string, file = ''): ParseResult => {\n\tconst context = new ParseContext(text, file);\n\tlet program: AST.TOMLProgram;\n\ttry {\n\t\tprogram = parseTOML(text);\n\t} catch (error) {\n\t\tconst { index = 0, message } = error as Error & { index?: number };\n\t\tcontext.problem(\n\t\t\t[index, index + 1],\n\t\t\tmessage.startsWith('Defining a key multiple times') ? 'duplicate-key' : 'parse-error',\n\t\t\tmessage,\n\t\t);\n\t\treturn context.result(undefined);\n\t}\n\n\tconst top = program.body[0];\n\tcontext.add([], top.range, top.range);\n\tconst walker = new TomlWalker(context);\n\tfor (const item of top.body) {\n\t\tif (item.type === 'TOMLTable') walker.table(item);\n\t\telse walker.keyValue(item, []);\n\t}\n\n\tconst value = getStaticTOMLValue(program);\n\tfor (const date of walker.dates) setAt(value, date.path, date.text);\n\treturn context.result(value);\n};\n\nconst parseScalar = (text: string): unknown => {\n\tif (/[\\n\\r]/u.test(text)) return text;\n\ttry {\n\t\tconst item = parseTOML(`value = ${text}`).body[0].body[0];\n\t\tif (item?.type !== 'TOMLKeyValue' || item.value.type !== 'TOMLValue') return text;\n\t\tconst { kind, value } = item.value;\n\t\treturn kind === 'integer' || kind === 'float' || kind === 'boolean' ? value : text;\n\t} catch {\n\t\treturn text;\n\t}\n};\n\nexport const toml: Format = { name: 'toml', parse, parseScalar };\n","import { parseXml, XmlElement, XmlError, XmlText } from '@rgrove/parse-xml';\n\nimport { inferScalar, ParseContext } from './format.ts';\n\nimport type { Path } from '../positions.ts';\nimport type { Format, ParseResult } from './format.ts';\n\ntype Range = readonly [number, number];\n\nconst isNameEnd = (char: string | undefined) => char === undefined || /[\\s=/>]/u.test(char);\n\nconst isWhitespace = (text: string) => /^[\\t\\n\\r ]*$/u.test(text);\n\ninterface StartTag {\n\treadonly name: Range;\n\treadonly attributes: ReadonlyMap<string, { readonly name: Range; readonly value: Range }>;\n\treadonly end: number;\n}\n\n/**\n * Reads the ranges of an element's name and attributes from its start tag, which the parser has already checked.\n */\nconst startTag = (text: string, element: XmlElement): StartTag => {\n\tlet index = element.start + 1;\n\tconst name: Range = [index, index + element.name.length];\n\tindex = name[1];\n\tconst attributes = new Map<string, { name: Range; value: Range }>();\n\tfor (;;) {\n\t\twhile (/\\s/u.test(text[index] ?? '')) index++;\n\t\tif (text[index] === '>' || text[index] === '/' || index >= element.end) break;\n\t\tconst nameStart = index;\n\t\twhile (!isNameEnd(text[index])) index++;\n\t\tconst attribute: Range = [nameStart, index];\n\t\twhile (text[index] !== '\"' && text[index] !== \"'\") index++;\n\t\tconst close = text.indexOf(text[index]!, index + 1);\n\t\tattributes.set(text.slice(...attribute), { name: attribute, value: [index, close + 1] });\n\t\tindex = close + 1;\n\t}\n\treturn { name, attributes, end: text.indexOf('>', index) + 1 };\n};\n\nclass XmlWalker {\n\treadonly context: ParseContext;\n\treadonly text: string;\n\n\tconstructor(context: ParseContext) {\n\t\tthis.context = context;\n\t\tthis.text = context.source.text;\n\t}\n\n\t/**\n\t * The value of an element: a scalar for an element with only text, otherwise an object with `@name` attributes, `#text`\n\t * and child elements, where a repeated child element becomes an array.\n\t */\n\telement(element: XmlElement, path: Path, key: (tag: StartTag) => Range): unknown {\n\t\tconst tag = startTag(this.text, element);\n\t\tconst children = element.children.filter((child) => child instanceof XmlElement);\n\t\tconst texts = element.children.filter(\n\t\t\t(child): child is XmlText => child instanceof XmlText && !isWhitespace(child.text),\n\t\t);\n\t\tif (tag.attributes.size === 0 && children.length === 0) {\n\t\t\tconst selfClosing = this.text[tag.end - 2] === '/';\n\t\t\tconst content: Range = [tag.end, this.text.lastIndexOf('</', element.end - 1)];\n\t\t\tthis.context.add(path, key(tag), selfClosing ? [element.start, element.end] : content);\n\t\t\treturn inferScalar(element.text);\n\t\t}\n\n\t\tthis.context.add(path, key(tag), [element.start, element.end]);\n\t\tconst value: Record<string, unknown> = {};\n\t\tfor (const [name, attribute] of tag.attributes) {\n\t\t\tthis.context.add([...path, `@${name}`], attribute.name, attribute.value);\n\t\t\tvalue[`@${name}`] = inferScalar(element.attributes[name] ?? '');\n\t\t}\n\n\t\tif (texts.length > 0) {\n\t\t\tconst range: Range = [texts[0]!.start, texts.at(-1)!.end];\n\t\t\tthis.context.add([...path, '#text'], range, range);\n\t\t\tvalue['#text'] = inferScalar(texts.map((text) => text.text).join(''));\n\t\t}\n\n\t\tconst groups = Map.groupBy(children, (child) => child.name);\n\t\tfor (const [name, group] of groups) {\n\t\t\tconst childPath = [...path, name];\n\t\t\tif (group.length === 1) {\n\t\t\t\tvalue[name] = this.element(group[0]!, childPath, (child) => child.name);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst first = startTag(this.text, group[0]!);\n\t\t\tthis.context.add(childPath, first.name, [group[0]!.start, group.at(-1)!.end]);\n\t\t\tvalue[name] = group.map((child, index) => this.element(child, [...childPath, index], (item) => item.name));\n\t\t}\n\t\treturn value;\n\t}\n}\n\nconst markup = /<!--[\\s\\S]*?-->|<\\?[\\s\\S]*?\\?>/gu;\n\nconst parse = (text: string, file = ''): ParseResult => {\n\tconst context = new ParseContext(text, file);\n\tif (isWhitespace(text.replaceAll(markup, ''))) {\n\t\tcontext.add([], [0, 0], [0, 0]);\n\t\treturn context.result({});\n\t}\n\n\tlet root: XmlElement;\n\ttry {\n\t\tconst document = parseXml(text, { includeOffsets: true });\n\t\troot = document.root!;\n\t} catch (error) {\n\t\tif (!(error instanceof XmlError)) throw error;\n\t\tconst message = error.message.split('\\n')[0]!.replace(/ \\(line \\d+, column \\d+\\)$/u, '');\n\t\tcontext.problem([error.pos, error.pos + 1], 'parse-error', message);\n\t\treturn context.result(undefined);\n\t}\n\n\tcontext.add([], [root.start, root.end], [root.start, root.end]);\n\tconst value = new XmlWalker(context).element(root, [root.name], (tag) => tag.name);\n\treturn context.result({ [root.name]: value });\n};\n\nexport const xml: Format = { name: 'xml', parse, parseScalar: inferScalar };\n","import { isAlias, isMap, isNode, isScalar, isSeq, parseDocument } from 'yaml';\n\nimport { ParseContext } from './format.ts';\n\nimport type { Path } from '../positions.ts';\nimport type { Format, ParseResult } from './format.ts';\nimport type { Document, Node } from 'yaml';\n\ntype Range = readonly [number, number];\n\nconst nodeRange = (text: string, node: Node | null | undefined, fallback: number): Range => {\n\tif (!node?.range) return [fallback, fallback];\n\tconst [start] = node.range;\n\tlet end = node.range[1];\n\twhile (end > start && /\\s/u.test(text[end - 1] ?? '')) end--;\n\treturn [start, end];\n};\n\nconst walk = (context: ParseContext, document: Document, node: unknown, path: Path, seen: Set<Node>) => {\n\tconst target = isAlias(node) ? node.resolve(document) : node;\n\tif (!isNode(target) || seen.has(target)) return;\n\tif (isMap(target)) {\n\t\tseen.add(target);\n\t\tfor (const pair of target.items) {\n\t\t\tif (!isScalar(pair.key)) continue;\n\t\t\tconst keyRange = nodeRange(context.source.text, pair.key, 0);\n\t\t\tconst value = pair.value as Node | null;\n\t\t\tconst childPath = [...path, String(pair.key.value)];\n\t\t\tcontext.add(childPath, keyRange, nodeRange(context.source.text, value, keyRange[1]));\n\t\t\twalk(context, document, value, childPath, seen);\n\t\t}\n\t\tseen.delete(target);\n\t} else if (isSeq(target)) {\n\t\tseen.add(target);\n\t\tfor (const [index, item] of target.items.entries()) {\n\t\t\tconst range = nodeRange(context.source.text, item as Node | null, target.range?.[0] ?? 0);\n\t\t\tconst childPath = [...path, index];\n\t\t\tcontext.add(childPath, range, range);\n\t\t\twalk(context, document, item, childPath, seen);\n\t\t}\n\t\tseen.delete(target);\n\t}\n};\n\nconst parse = (text: string, file = ''): ParseResult => {\n\tconst context = new ParseContext(text, file);\n\tconst document = parseDocument(text, { prettyErrors: false });\n\tfor (const error of document.errors) {\n\t\tcontext.problem(error.pos, error.code === 'DUPLICATE_KEY' ? 'duplicate-key' : 'parse-error', error.message);\n\t}\n\tif (document.contents === null) {\n\t\tcontext.add([], [0, 0], [0, 0]);\n\t\treturn context.result({});\n\t}\n\n\tconst root = nodeRange(text, document.contents, 0);\n\tcontext.add([], root, root);\n\twalk(context, document, document.contents, [], new Set());\n\n\tlet value: unknown;\n\ttry {\n\t\tvalue = document.toJS();\n\t} catch (error) {\n\t\tcontext.problem(root, 'parse-error', (error as Error).message);\n\t\treturn context.result(undefined);\n\t}\n\treturn context.result(value);\n};\n\nconst parseScalar = (text: string): unknown => {\n\tif (text === '') return text;\n\tconst document = parseDocument(text, { prettyErrors: false });\n\tconst node = document.contents;\n\tif (document.errors.length > 0 || !isScalar(node) || node.type !== 'PLAIN') return text;\n\tif (node.range[0] !== 0 || node.range[1] !== text.length) return text;\n\treturn node.value;\n};\n\nexport const yaml: Format = { name: 'yaml', parse, parseScalar };\n","import { basename, extname } from 'node:path';\n\nimport { ini } from './ini.ts';\nimport { json5 } from './json5.ts';\nimport { jsonc } from './jsonc.ts';\nimport { properties } from './properties.ts';\nimport { toml } from './toml.ts';\nimport { xml } from './xml.ts';\nimport { yaml } from './yaml.ts';\n\nimport { configDirectory, isInConfigDirectory } from '../files.ts';\n\nimport type { Format } from './format.ts';\n\nexport type { Format, FormatName, ParseResult } from './format.ts';\nexport { ini } from './ini.ts';\nexport { json5 } from './json5.ts';\nexport { jsonc } from './jsonc.ts';\nexport { properties } from './properties.ts';\nexport { toml } from './toml.ts';\nexport { xml } from './xml.ts';\nexport { yaml } from './yaml.ts';\n\n/**\n * The formats by file extension.\n */\nexport const formatExtensions: Readonly<Record<string, Format>> = {\n\t'.yaml': yaml,\n\t'.yml': yaml,\n\t'.toml': toml,\n\t'.jsonc': jsonc,\n\t'.json5': json5,\n\t'.ini': ini,\n\t'.properties': properties,\n\t'.xml': xml,\n};\n\nexport const formats: Readonly<Record<string, Format>> = Object.fromEntries(\n\tObject.entries(formatExtensions).map(([extension, format]) => [`.config${extension}`, format]),\n);\n\nexport const configSuffixes = Object.keys(formats);\n\nexport interface ConfigFileName {\n\t/**\n\t * The file name before the suffix, `app` for `app.config.yaml` and `.config/app.yaml`.\n\t */\n\treadonly stem: string;\n\t/**\n\t * The claimed suffix, `.config.yaml` for `app.config.yaml` and `.yaml` for `.config/app.yaml`.\n\t */\n\treadonly suffix: string;\n\treadonly format: Format;\n}\n\n/**\n * The format of a file extension such as `.yaml`, or `undefined` when tyfigo does not read it.\n */\nexport const formatOfExtension = (extension: string): Format | undefined =>\n\tObject.hasOwn(formatExtensions, extension) ? formatExtensions[extension] : undefined;\n\n/**\n * Splits a config file path into its stem and suffix, or returns `undefined` when tyfigo does not claim it. A config file's name\n * ends in a suffix such as `.config.yaml`, or it has a format extension such as `.yaml` and sits in a `.config` directory.\n */\nexport const parseConfigPath = (path: string): ConfigFileName | undefined => {\n\tconst fileName = basename(path);\n\tfor (const [suffix, format] of Object.entries(formats)) {\n\t\tif (fileName.endsWith(suffix) && fileName.length > suffix.length) {\n\t\t\treturn { stem: fileName.slice(0, -suffix.length), suffix, format };\n\t\t}\n\t}\n\tconst suffix = extname(fileName);\n\tconst format = formatOfExtension(suffix);\n\tif (!format || !isInConfigDirectory(path) || fileName.startsWith('.')) return undefined;\n\treturn { stem: fileName.slice(0, -suffix.length), suffix, format };\n};\n\nconst escape = (text: string) => text.replaceAll('.', String.raw`\\.`);\n\n/**\n * Matches the paths {@link parseConfigPath} claims, with either path separator, for loader and bundler filters.\n */\nexport const configPathPattern = new RegExp(\n\tString.raw`(?:[^/\\\\](?:${configSuffixes.map(escape).join('|')})|(?:^|[/\\\\])${escape(configDirectory)}[/\\\\][^/\\\\.][^/\\\\]*(?:${Object.keys(formatExtensions).map(escape).join('|')}))$`,\n\t'u',\n);\n\n/**\n * A short description of the files tyfigo claims, for error messages.\n */\nexport const configFileDescription = `a name ending in ${configSuffixes.join(', ')}, or a ${Object.keys(formatExtensions).join(', ')} file in a ${configDirectory} directory`;\n"],"mappings":";;;;;;;;;AA2BA,IAAa,eAAb,MAA0B;CACzB;CACA;CACA,4BAAqB,IAAI,IAAkB;CAC3C,WAA+B,CAAC;CAEhC,YAAY,MAAc,MAAc;EACvC,KAAK,SAAS,IAAI,YAAY,IAAI;EAClC,KAAK,OAAO;CACb;;;;CAKA,IAAI,MAAY,KAAgC,OAAkC,UAAU,MAAM;EACjG,MAAM,KAAK,QAAQ,IAAI;EACvB,IAAI,CAAC,WAAW,KAAK,UAAU,IAAI,EAAE,GAAG;EACxC,KAAK,UAAU,IAAI,IAAI,KAAK,OAAO,KAAK,MAAM,KAAK,KAAK,CAAC;CAC1D;;;;CAKA,QAAQ,OAAkC,MAAmB,SAAiB;EAC7E,MAAM,QAAQ,KAAK,OAAO,WAAW,MAAM,EAAE;EAC7C,KAAK,SAAS,KACb,UAAU,KAAK,QAAQ,KAAK,MAAM,OAAO,KAAK,OAAO,WAAW,MAAM,EAAE,IAAI,OAAO,MAAM,OAAO,CACjG;CACD;CAEA,OAA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AC,OAAO,MAAM;EAAG;EAAQ;CAAO;CAGnE,MAAM,SAAS,QAAQ,QAAQ;CAC/B,MAAM,SAAS,kBAAkB,MAAM;CACvC,IAAI,CAAC,UAAU,CAAC,oBAAoB,IAAI,KAAK,SAAS,WAAW,GAAG,GAAG,OAAO,KAAA;CAC9E,OAAO;EAAE,MAAM,SAAS,MAAM,GAAG,CAAC,OAAO,MAAM;EAAG;EAAQ;CAAO;AAClE;AAEA,MAAM,UAAU,SAAiB,KAAK,WAAW,KAAK,OAAO,GAAG,IAAI;;;;AAKpE,MAAa,oBAAoB,IAAI,OACpC,OAAO,GAAG,eAAe,eAAe,IAAI,MAAM,CAAC,CAAC,KAAK,GAAG,EAAE,eAAe,OAAO,eAAe,EAAE,wBAAwB,OAAO,KAAK,gBAAgB,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,KAAK,GAAG,EAAE,MACjL,GACD;;;;AAKA,MAAa,wBAAwB,oBAAoB,eAAe,KAAK,IAAI,EAAE,SAAS,OAAO,KAAK,gBAAgB,CAAC,CAAC,KAAK,IAAI,EAAE,aAAa,gBAAgB"}
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { t as ConfigValidationError } from "./schema-DcD4N9N-.mjs";
2
- import { t as decodeEnv } from "./env-Bd-1Atoz.mjs";
2
+ import { t as decodeEnv } from "./env--pSRlq_k.mjs";
3
3
  import { n as loadConfigAsync, t as loadConfig } from "./index.browser-C5z_VT_3.mjs";
4
4
  import { Effect } from "effect";
5
5
  // src/index.ts
@@ -9,7 +9,8 @@ interface LoadOptions {
9
9
  readonly target: LoadTarget;
10
10
  /**
11
11
  * The environment name, such as the bundler's mode. Defaults to `NODE_ENV`, read when the server module runs and when
12
- * `load` runs for the browser.
12
+ * `load` runs for the browser. A bundled server module inlines only this environment's files when it is given, and every
13
+ * environment's files otherwise.
13
14
  */
14
15
  readonly environment?: string | undefined;
15
16
  /**
@@ -17,8 +18,9 @@ interface LoadOptions {
17
18
  */
18
19
  readonly runtime?: string | undefined;
19
20
  /**
20
- * For `server`: inline the text of the layer files that exist at build time, and read `.env` files and environment variables
21
- * from `process.cwd()` when the module runs, so a bundle does not depend on the paths of the machine that built it.
21
+ * For `server`: inline the text of the layer files that exist at build time, for every environment unless `environment` is
22
+ * given, and pick the environment's layers and read `.env` files and environment variables from `process.cwd()` when the
23
+ * module runs, so a bundle does not depend on the paths of the machine that built it.
22
24
  */
23
25
  readonly bundle?: boolean | undefined;
24
26
  }
@@ -50,4 +52,4 @@ declare const loadModule: (path: string, options: LoadOptions) => Effect.Effect<
50
52
  */
51
53
  declare const load: (path: string, options: LoadOptions) => LoadResult;
52
54
  export { loadModule as a, load as i, LoadResult as n, valueLiteral as o, LoadTarget as r, LoadOptions as t };
53
- //# sourceMappingURL=load-C-kweoyY.d.mts.map
55
+ //# sourceMappingURL=load-D1KO5LdK.d.mts.map
@@ -1,21 +1,21 @@
1
- import { a as findProjectRoot, n as processEnv, o as isFile, s as searchDirectories, t as envFileNames } from "./env-R3_XPW_u.mjs";
2
- import { n as formatProblems, r as problemAt, t as fileProblem } from "./problems-BNAqmOzL.mjs";
1
+ import { a as envDirectories, c as isFile, n as formatProblems, r as problemAt, s as findProjectRoot, t as fileProblem, u as layerDirectories } from "./problems-DS_eJB6e.mjs";
2
+ import { n as processEnv, t as envFileNames } from "./env-Dv5OHfEf.mjs";
3
3
  import { n as formatPath, r as pathKey, t as SourceIndex } from "./positions-BCTEFZTX.mjs";
4
- import { i as isPlainObject, n as parseConfigFileName, r as hasPlaceholder, t as configSuffixes } from "./formats-D_dKXoPf.mjs";
5
- import { t as resolveConfig } from "./resolve-D3geHCGs.mjs";
4
+ import { c as isPlainObject, o as parseConfigPath, s as hasPlaceholder, t as configFileDescription } from "./formats-Bf8-iQw-.mjs";
5
+ import { r as discoverEnvironments, t as resolveConfig } from "./resolve-DQfTdYJN.mjs";
6
6
  import { Effect } from "effect";
7
7
  import { basename, dirname, join, relative, resolve, sep } from "node:path";
8
8
  // src/runtime/load.ts
9
9
  const browserLayers = ["base", "environment"];
10
10
  const watchFilesOf = Effect.fn("watchFilesOf")(function* (file, environment, target) {
11
- const name = parseConfigFileName(basename(file));
11
+ const name = parseConfigPath(file);
12
12
  if (!name) return [file];
13
13
  const files = [file];
14
14
  if (environment) files.push(join(dirname(file), `${name.stem}.${environment}${name.suffix}`));
15
15
  if (target === "browser") return files;
16
- const directories = yield* searchDirectories(file);
17
16
  const locals = environment ? [`${name.stem}.local${name.suffix}`, `${name.stem}.${environment}.local${name.suffix}`] : [`${name.stem}.local${name.suffix}`];
18
- for (const fileName of [...locals, ...envFileNames(environment)]) for (const directory of directories) files.push(join(directory, fileName));
17
+ const searches = [[yield* layerDirectories(file), locals], [yield* envDirectories(file), envFileNames(environment)]];
18
+ for (const [directories, fileNames] of searches) for (const fileName of fileNames) for (const directory of directories) files.push(join(directory, fileName));
19
19
  return files;
20
20
  });
21
21
  /**
@@ -59,7 +59,7 @@ const placeholderProblems = (file, text, value, positions) => {
59
59
  const failingCode = (file, problems) => `throw new Error(${JSON.stringify(`Invalid config ${file}\n${formatProblems(problems)}`)});\n\nexport default undefined;\n`;
60
60
  const serverModule = Effect.fn("serverModule")(function* (file, options) {
61
61
  const problems = [];
62
- if (!parseConfigFileName(basename(file))) problems.push(fileProblem(file, "unsupported-file", `${basename(file)} is not a config file; expected a name ending in ${configSuffixes.join(", ")}`));
62
+ if (!parseConfigPath(file)) problems.push(fileProblem(file, "unsupported-file", `${basename(file)} is not a config file; expected ${configFileDescription}`));
63
63
  else if (!(yield* isFile(file))) problems.push(fileProblem(file, "file-not-found", `Cannot find ${file}`));
64
64
  const settings = options.environment === void 0 ? "" : `, { environment: ${JSON.stringify(options.environment)} }`;
65
65
  const code = `import { resolveConfigModule } from ${JSON.stringify(options.runtime ?? "tyfigo/runtime")};\n\nexport default resolveConfigModule(${JSON.stringify(file)}${settings});\n`;
@@ -89,25 +89,51 @@ const browserModule = Effect.fn("browserModule")(function* (file, options) {
89
89
  problems
90
90
  };
91
91
  });
92
+ const layerOrder = {
93
+ base: 0,
94
+ environment: 1,
95
+ local: 2,
96
+ "environment-local": 3
97
+ };
92
98
  const bundledServerModule = Effect.fn("bundledServerModule")(function* (file, options) {
93
- const environment = options.environment ?? (processEnv().NODE_ENV || void 0);
94
- const result = yield* resolveConfig(file, { environment });
95
- const problems = result.problems.filter((problem) => problem.code !== "missing-variable" && problem.code !== "placeholder-type");
96
- const root = (yield* findProjectRoot(dirname(result.file))) ?? dirname(result.file);
99
+ const environments = options.environment === void 0 ? [void 0, ...yield* discoverEnvironments(file)] : [options.environment];
100
+ const results = [];
101
+ for (const environment of environments) results.push(yield* resolveConfig(file, environment === void 0 ? { layers: ["base", "local"] } : { environment }));
102
+ const root = (yield* findProjectRoot(dirname(file))) ?? dirname(file);
97
103
  const name = (path) => relative(root, path).split(sep).join("/");
104
+ const problems = /* @__PURE__ */ new Map();
105
+ const layers = /* @__PURE__ */ new Map();
106
+ for (const result of results) {
107
+ for (const problem of result.problems) {
108
+ if (problem.code === "missing-variable" || problem.code === "placeholder-type") continue;
109
+ problems.set(JSON.stringify([
110
+ problem.file,
111
+ problem.start,
112
+ problem.code,
113
+ problem.message
114
+ ]), problem);
115
+ }
116
+ for (const layer of result.layers) {
117
+ const specific = layer.kind === "environment" || layer.kind === "environment-local";
118
+ layers.set(layer.file, {
119
+ file: name(layer.file),
120
+ kind: layer.kind,
121
+ ...specific ? { environment: result.environment } : {},
122
+ text: layer.text
123
+ });
124
+ }
125
+ }
98
126
  const bundle = {
99
- file: name(result.file),
100
- environment,
101
- layers: result.layers.map((layer) => ({
102
- file: name(layer.file),
103
- kind: layer.kind,
104
- text: layer.text
105
- }))
127
+ file: name(file),
128
+ ...options.environment === void 0 ? {} : { environment: options.environment },
129
+ layers: [...layers.values()].toSorted((a, b) => layerOrder[a.kind] - layerOrder[b.kind])
106
130
  };
131
+ const watchFiles = /* @__PURE__ */ new Set();
132
+ for (const environment of /* @__PURE__ */ new Set([...environments, processEnv().NODE_ENV || void 0])) for (const watchFile of yield* watchFilesOf(file, environment, "server")) watchFiles.add(watchFile);
107
133
  return {
108
- code: problems.length > 0 ? failingCode(result.file, problems) : `import { resolveBundledConfigModule } from ${JSON.stringify(options.runtime ?? "tyfigo/runtime")};\n\nexport default resolveBundledConfigModule(${JSON.stringify(bundle)});\n`,
109
- watchFiles: yield* watchFilesOf(result.file, environment, "server"),
110
- problems
134
+ code: problems.size > 0 ? failingCode(file, [...problems.values()]) : `import { resolveBundledConfigModule } from ${JSON.stringify(options.runtime ?? "tyfigo/runtime")};\n\nexport default resolveBundledConfigModule(${JSON.stringify(bundle)});\n`,
135
+ watchFiles: [...watchFiles],
136
+ problems: [...problems.values()]
111
137
  };
112
138
  });
113
139
  /**
@@ -124,4 +150,4 @@ const loadModule = Effect.fn("loadModule")(function* (path, options) {
124
150
  const load = (path, options) => Effect.runSync(loadModule(path, options));
125
151
  export { loadModule as n, valueLiteral as r, load as t };
126
152
 
127
- //# sourceMappingURL=load-DxIjRpX6.mjs.map
153
+ //# sourceMappingURL=load-yFCdP4to.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-yFCdP4to.mjs","names":[],"sources":["../src/runtime/load.ts"],"sourcesContent":["import { basename, dirname, join, relative, resolve, sep } from 'node:path';\n\nimport { Effect } from 'effect';\n\nimport { envDirectories, findProjectRoot, isFile, layerDirectories } from '../core/files.ts';\nimport {\n\tconfigFileDescription,\n\tdiscoverEnvironments,\n\tenvFileNames,\n\tfileProblem,\n\tformatPath,\n\tformatProblems,\n\thasPlaceholder,\n\tisPlainObject,\n\tparseConfigPath,\n\tpathKey,\n\tproblemAt,\n\tprocessEnv,\n\tresolveConfig,\n\tSourceIndex,\n} from '../core/index.ts';\n\nimport type { LayerKind, Path, PositionMap, Problem, ResolvedConfig } from '../core/index.ts';\nimport type { BundledConfig, BundledLayer } from './resolve.ts';\n\nexport type LoadTarget = 'server' | 'browser';\n\nexport interface LoadOptions {\n\t/**\n\t * `server` resolves the config when the module runs. `browser` inlines the base and environment files at build time and\n\t * reports every placeholder as a problem.\n\t */\n\treadonly target: LoadTarget;\n\t/**\n\t * The environment name, such as the bundler's mode. Defaults to `NODE_ENV`, read when the server module runs and when\n\t * `load` runs for the browser. A bundled server module inlines only this environment's files when it is given, and every\n\t * environment's files otherwise.\n\t */\n\treadonly environment?: string | undefined;\n\t/**\n\t * The specifier the server module imports the runtime from. Defaults to `tyfigo/runtime`.\n\t */\n\treadonly runtime?: string | undefined;\n\t/**\n\t * For `server`: inline the text of the layer files that exist at build time, for every environment unless `environment` is\n\t * given, and pick the environment's layers and read `.env` files and environment variables from `process.cwd()` when the\n\t * module runs, so a bundle does not depend on the paths of the machine that built it.\n\t */\n\treadonly bundle?: boolean | undefined;\n}\n\nexport interface LoadResult {\n\t/**\n\t * The JavaScript module, with the config as its default export.\n\t */\n\treadonly code: string;\n\t/**\n\t * Every file whose creation, change or removal changes the module, whether or not it exists now.\n\t */\n\treadonly watchFiles: readonly string[];\n\treadonly problems: readonly Problem[];\n}\n\nconst browserLayers = ['base', 'environment'] as const;\n\nconst watchFilesOf = Effect.fn('watchFilesOf')(function* (\n\tfile: string,\n\tenvironment: string | undefined,\n\ttarget: LoadTarget,\n) {\n\tconst name = parseConfigPath(file);\n\tif (!name) return [file];\n\n\tconst files = [file];\n\tif (environment) files.push(join(dirname(file), `${name.stem}.${environment}${name.suffix}`));\n\tif (target === 'browser') return files;\n\n\tconst locals = environment\n\t\t? [`${name.stem}.local${name.suffix}`, `${name.stem}.${environment}.local${name.suffix}`]\n\t\t: [`${name.stem}.local${name.suffix}`];\n\tconst searches = [\n\t\t[yield* layerDirectories(file), locals],\n\t\t[yield* envDirectories(file), envFileNames(environment)],\n\t] as const;\n\tfor (const [directories, fileNames] of searches) {\n\t\tfor (const fileName of fileNames) {\n\t\t\tfor (const directory of directories) files.push(join(directory, fileName));\n\t\t}\n\t}\n\treturn files;\n});\n\n/**\n * A JavaScript expression that evaluates to a deep-frozen copy of a config value.\n */\nexport const valueLiteral = (value: unknown, indent = ''): string => {\n\tif (value === undefined) return 'undefined';\n\tif (typeof value === 'number') return Object.is(value, -0) ? '-0' : String(value);\n\tif (typeof value === 'bigint') return `${value}n`;\n\tif (value instanceof Date) return `new Date(${valueLiteral(value.getTime(), indent)})`;\n\tconst inner = `${indent}\\t`;\n\tif (Array.isArray(value)) {\n\t\tif (value.length === 0) return 'Object.freeze([])';\n\t\tconst items = value.map((item) => `${inner}${valueLiteral(item, inner)},\\n`);\n\t\treturn `Object.freeze([\\n${items.join('')}${indent}])`;\n\t}\n\tif (isPlainObject(value)) {\n\t\tconst entries = Object.entries(value);\n\t\tif (entries.length === 0) return 'Object.freeze({})';\n\t\tconst properties = entries.map(([key, item]) => {\n\t\t\tconst name = key === '__proto__' ? `[${JSON.stringify(key)}]` : JSON.stringify(key);\n\t\t\treturn `${inner}${name}: ${valueLiteral(item, inner)},\\n`;\n\t\t});\n\t\treturn `Object.freeze({\\n${properties.join('')}${indent}})`;\n\t}\n\treturn JSON.stringify(value);\n};\n\nconst hasUnescapedPlaceholder = (text: string) => hasPlaceholder(text.replaceAll('$${', ''));\n\nconst placeholderProblems = (file: string, text: string, value: unknown, positions: PositionMap) => {\n\tconst source = new SourceIndex(text);\n\tconst problems: Problem[] = [];\n\tconst visit = (item: unknown, path: Path) => {\n\t\tif (typeof item === 'string') {\n\t\t\tif (!hasUnescapedPlaceholder(item)) return;\n\t\t\tconst span = positions.get(pathKey(path));\n\t\t\tproblems.push(\n\t\t\t\tproblemAt(\n\t\t\t\t\tsource,\n\t\t\t\t\tfile,\n\t\t\t\t\tspan?.valueStart ?? 0,\n\t\t\t\t\tspan?.valueLength ?? 0,\n\t\t\t\t\t'browser-placeholder',\n\t\t\t\t\t`'${formatPath(path) || '(root)'}' uses an environment placeholder, which browser builds cannot read`,\n\t\t\t\t),\n\t\t\t);\n\t\t} else if (Array.isArray(item)) for (const [index, child] of item.entries()) visit(child, [...path, index]);\n\t\telse if (isPlainObject(item)) for (const [key, child] of Object.entries(item)) visit(child, [...path, key]);\n\t};\n\tvisit(value, []);\n\treturn problems;\n};\n\nconst failingCode = (file: string, problems: readonly Problem[]) =>\n\t`throw new Error(${JSON.stringify(`Invalid config ${file}\\n${formatProblems(problems)}`)});\\n\\nexport default undefined;\\n`;\n\nconst serverModule = Effect.fn('serverModule')(function* (file: string, options: LoadOptions) {\n\tconst problems: Problem[] = [];\n\tif (!parseConfigPath(file)) {\n\t\tproblems.push(\n\t\t\tfileProblem(\n\t\t\t\tfile,\n\t\t\t\t'unsupported-file',\n\t\t\t\t`${basename(file)} is not a config file; expected ${configFileDescription}`,\n\t\t\t),\n\t\t);\n\t} else if (!(yield* isFile(file))) problems.push(fileProblem(file, 'file-not-found', `Cannot find ${file}`));\n\n\tconst settings =\n\t\toptions.environment === undefined ? '' : `, { environment: ${JSON.stringify(options.environment)} }`;\n\tconst code = `import { resolveConfigModule } from ${JSON.stringify(options.runtime ?? 'tyfigo/runtime')};\\n\\nexport default resolveConfigModule(${JSON.stringify(file)}${settings});\\n`;\n\tconst environment = options.environment ?? (processEnv().NODE_ENV || undefined);\n\treturn { code, watchFiles: yield* watchFilesOf(file, environment, 'server'), problems } satisfies LoadResult;\n});\n\nconst browserModule = Effect.fn('browserModule')(function* (file: string, options: LoadOptions) {\n\tconst environment = options.environment ?? (processEnv().NODE_ENV || undefined);\n\tconst result = yield* resolveConfig(file, { environment, env: {}, layers: browserLayers });\n\tconst files = new Set([result.file, ...result.layers.map((layer) => layer.file)]);\n\tconst problems = result.problems.filter(\n\t\t(problem) =>\n\t\t\tfiles.has(problem.file) && problem.code !== 'missing-variable' && problem.code !== 'invalid-placeholder',\n\t);\n\tfor (const layer of result.layers) {\n\t\tconst parsed = result.format?.parse(layer.text, layer.file);\n\t\tif (parsed?.value !== undefined) {\n\t\t\tproblems.push(...placeholderProblems(layer.file, layer.text, parsed.value, layer.positions));\n\t\t}\n\t}\n\n\tconst code =\n\t\tproblems.length > 0\n\t\t\t? failingCode(result.file, problems)\n\t\t\t: `export default ${valueLiteral(result.value, '')};\\n`;\n\treturn {\n\t\tcode,\n\t\twatchFiles: yield* watchFilesOf(result.file, environment, 'browser'),\n\t\tproblems,\n\t} satisfies LoadResult;\n});\n\nconst layerOrder: Readonly<Record<LayerKind, number>> = { base: 0, environment: 1, local: 2, 'environment-local': 3 };\n\nconst bundledServerModule = Effect.fn('bundledServerModule')(function* (file: string, options: LoadOptions) {\n\tconst environments =\n\t\toptions.environment === undefined ? [undefined, ...(yield* discoverEnvironments(file))] : [options.environment];\n\tconst results: ResolvedConfig[] = [];\n\tfor (const environment of environments) {\n\t\tresults.push(\n\t\t\tyield* resolveConfig(file, environment === undefined ? { layers: ['base', 'local'] } : { environment }),\n\t\t);\n\t}\n\n\tconst root = (yield* findProjectRoot(dirname(file))) ?? dirname(file);\n\tconst name = (path: string) => relative(root, path).split(sep).join('/');\n\tconst problems = new Map<string, Problem>();\n\tconst layers = new Map<string, BundledLayer>();\n\tfor (const result of results) {\n\t\tfor (const problem of result.problems) {\n\t\t\tif (problem.code === 'missing-variable' || problem.code === 'placeholder-type') continue;\n\t\t\tproblems.set(JSON.stringify([problem.file, problem.start, problem.code, problem.message]), problem);\n\t\t}\n\t\tfor (const layer of result.layers) {\n\t\t\tconst specific = layer.kind === 'environment' || layer.kind === 'environment-local';\n\t\t\tlayers.set(layer.file, {\n\t\t\t\tfile: name(layer.file),\n\t\t\t\tkind: layer.kind,\n\t\t\t\t...(specific ? { environment: result.environment } : {}),\n\t\t\t\ttext: layer.text,\n\t\t\t});\n\t\t}\n\t}\n\tconst bundle: BundledConfig = {\n\t\tfile: name(file),\n\t\t...(options.environment === undefined ? {} : { environment: options.environment }),\n\t\tlayers: [...layers.values()].toSorted((a, b) => layerOrder[a.kind] - layerOrder[b.kind]),\n\t};\n\n\tconst watchFiles = new Set<string>();\n\tfor (const environment of new Set([...environments, processEnv().NODE_ENV || undefined])) {\n\t\tfor (const watchFile of yield* watchFilesOf(file, environment, 'server')) watchFiles.add(watchFile);\n\t}\n\tconst code =\n\t\tproblems.size > 0\n\t\t\t? failingCode(file, [...problems.values()])\n\t\t\t: `import { resolveBundledConfigModule } from ${JSON.stringify(options.runtime ?? 'tyfigo/runtime')};\\n\\nexport default resolveBundledConfigModule(${JSON.stringify(bundle)});\\n`;\n\treturn {\n\t\tcode,\n\t\twatchFiles: [...watchFiles],\n\t\tproblems: [...problems.values()],\n\t} satisfies LoadResult;\n});\n\n/**\n * Generates the JavaScript module for a config file import. Loaders fail the import or build when `problems` is not empty.\n */\nexport const loadModule = Effect.fn('loadModule')(function* (path: string, options: LoadOptions) {\n\tconst file = resolve(path);\n\tif (options.target === 'browser') return yield* browserModule(file, options);\n\treturn options.bundle ? yield* bundledServerModule(file, options) : yield* serverModule(file, options);\n});\n\n/**\n * {@link loadModule} for synchronous callers such as Node `registerHooks` load hooks.\n */\nexport const load = (path: string, options: LoadOptions): LoadResult => Effect.runSync(loadModule(path, options));\n"],"mappings":";;;;;;;;AA+DA,MAAM,gBAAgB,CAAC,QAAQ,aAAa;AAE5C,MAAM,eAAe,OAAO,GAAG,cAAc,CAAC,CAAC,WAC9C,MACA,aACA,QACC;CACD,MAAM,OAAO,gBAAgB,IAAI;CACjC,IAAI,CAAC,MAAM,OAAO,CAAC,IAAI;CAEvB,MAAM,QAAQ,CAAC,IAAI;CACnB,IAAI,aAAa,MAAM,KAAK,KAAK,QAAQ,IAAI,GAAG,GAAG,KAAK,KAAK,GAAG,cAAc,KAAK,QAAQ,CAAC;CAC5F,IAAI,WAAW,WAAW,OAAO;CAEjC,MAAM,SAAS,cACZ,CAAC,GAAG,KAAK,KAAK,QAAQ,KAAK,UAAU,GAAG,KAAK,KAAK,GAAG,YAAY,QAAQ,KAAK,QAAQ,IACtF,CAAC,GAAG,KAAK,KAAK,QAAQ,KAAK,QAAQ;CACtC,MAAM,WAAW,CAChB,CAAC,OAAO,iBAAiB,IAAI,GAAG,MAAM,GACtC,CAAC,OAAO,eAAe,IAAI,GA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CAAC,YAAY,KAAA,CAAS,CAAC,GACtF,KAAK,MAAM,aAAa,OAAO,aAAa,MAAM,aAAa,QAAQ,GAAG,WAAW,IAAI,SAAS;CAMnG,OAAO;EACN,MAJA,SAAS,OAAO,IACb,YAAY,MAAM,CAAC,GAAG,SAAS,OAAO,CAAC,CAAC,IACxC,8CAA8C,KAAK,UAAU,QAAQ,WAAW,gBAAgB,EAAE,iDAAiD,KAAK,UAAU,MAAM,EAAE;EAG7K,YAAY,CAAC,GAAG,UAAU;EAC1B,UAAU,CAAC,GAAG,SAAS,OAAO,CAAC;CAChC;AACD,CAAC;;;;AAKD,MAAa,aAAa,OAAO,GAAG,YAAY,CAAC,CAAC,WAAW,MAAc,SAAsB;CAChG,MAAM,OAAO,QAAQ,IAAI;CACzB,IAAI,QAAQ,WAAW,WAAW,OAAO,OAAO,cAAc,MAAM,OAAO;CAC3E,OAAO,QAAQ,SAAS,OAAO,oBAAoB,MAAM,OAAO,IAAI,OAAO,aAAa,MAAM,OAAO;AACtG,CAAC;;;;AAKD,MAAa,QAAQ,MAAc,YAAqC,OAAO,QAAQ,WAAW,MAAM,OAAO,CAAC"}
package/dist/mapper.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { t as fileProblem } from "./problems-BNAqmOzL.mjs";
1
+ import { t as fileProblem } from "./problems-DS_eJB6e.mjs";
2
2
  import { r as pathKey, t as SourceIndex } from "./positions-BCTEFZTX.mjs";
3
- import { i as isPlainObject, n as parseConfigFileName, o as resolvePlaceholders, t as configSuffixes } from "./formats-D_dKXoPf.mjs";
4
- import { basename, dirname, relative, resolve } from "node:path";
3
+ import { a as formatOfExtension, c as isPlainObject, i as formatExtensions, o as parseConfigPath, u as resolvePlaceholders } from "./formats-Bf8-iQw-.mjs";
4
+ import { basename, dirname, extname, relative, resolve } from "node:path";
5
5
  import process from "node:process";
6
6
  import { Buffer } from "node:buffer";
7
7
  // src/mapper/rpc.ts
@@ -135,11 +135,11 @@ const diagnosticCodes = {
135
135
  "placeholder-type": 1011
136
136
  };
137
137
  /**
138
- * Reads a config file's layer from its name: the first dot-separated part of the stem names the base file, a trailing `local`
138
+ * Reads a config file's layer from its path: the first dot-separated part of the stem names the base file, a trailing `local`
139
139
  * marks a local file and anything in between is the environment.
140
140
  */
141
- const configFileRole = (fileName) => {
142
- const name = parseConfigFileName(fileName);
141
+ const configFileRole = (path) => {
142
+ const name = parseConfigPath(path);
143
143
  if (!name) return void 0;
144
144
  const [stem = "", ...rest] = name.stem.split(".");
145
145
  const base = `${stem}${name.suffix}`;
@@ -184,10 +184,12 @@ var Generator = class {
184
184
  source;
185
185
  positions;
186
186
  format;
187
- constructor(text, positions, format) {
187
+ placeholders;
188
+ constructor(text, positions, format, placeholders = true) {
188
189
  this.source = new SourceIndex(text);
189
190
  this.positions = positions;
190
191
  this.format = format;
192
+ this.placeholders = placeholders;
191
193
  }
192
194
  #slice(start, length) {
193
195
  return this.source.text.slice(this.source.charIndex(start), this.source.charIndex(start + length));
@@ -219,7 +221,7 @@ var Generator = class {
219
221
  return writer.map(text, start, length, this.#slice(start, length) === text ? SpanMapKind.Verbatim : fallback);
220
222
  }
221
223
  placeholderType(text) {
222
- const match = wholePlaceholder.exec(text);
224
+ const match = this.placeholders ? wholePlaceholder.exec(text) : null;
223
225
  if (match?.[1] !== ":-") return "string";
224
226
  const value = this.format.parseScalar(match[2] ?? "");
225
227
  return value === null ? "null" : typeof value;
@@ -338,16 +340,31 @@ const layerModule = (generator, value, specifier) => {
338
340
  if (statements.text !== "") writer.write("\n").append(statements);
339
341
  return writer.write("\ndeclare const config: Config;\nexport default config;\n");
340
342
  };
343
+ const dataModule = (file, text, format) => {
344
+ const parsed = format.parse(text, file);
345
+ const diagnostics = parsed.problems.map(toDiagnostic);
346
+ if (parsed.value === void 0 || parsed.problems.some((problem) => problem.code === "parse-error")) return untyped(diagnostics);
347
+ const writer = baseModule(new Generator(text, parsed.positions, format, false), parsed.value);
348
+ return {
349
+ text: writer.text,
350
+ extension: ".ts",
351
+ mappings: writer.mappings,
352
+ diagnostics
353
+ };
354
+ };
341
355
  /**
342
356
  * Turns a config file into a TypeScript module for a content mapper. A base file declares its widened, readonly type. An
343
357
  * environment or local file checks each of its keys against the base file's type, with every key and value mapped back to the
344
- * config file, and exports the base file's type.
358
+ * config file, and exports the base file's type. Any other file of a format extension, such as `data.yaml` when a project
359
+ * claims `.yaml`, declares its widened, readonly type as plain data, with no layers or placeholders.
345
360
  */
346
361
  const generateTypes = (path, text, options = {}) => {
347
362
  const file = resolve(path);
348
- const role = configFileRole(basename(file));
363
+ const role = configFileRole(file);
349
364
  if (!role) {
350
- const message = `${basename(file)} is not a config file. tyfigo handles files ending in ${configSuffixes.join(", ")}`;
365
+ const format = formatOfExtension(extname(file));
366
+ if (format) return dataModule(file, text, format);
367
+ const message = `${basename(file)} is not a file tyfigo reads. tyfigo handles files ending in ${Object.keys(formatExtensions).join(", ")}`;
351
368
  return untyped([toDiagnostic(fileProblem(file, "unsupported-file", message))]);
352
369
  }
353
370
  const parsed = role.format.parse(text, file);