full site update

This commit is contained in:
2025-07-24 18:46:24 +02:00
parent bfe2b90d8d
commit 37a6e0ab31
6912 changed files with 540482 additions and 361712 deletions

24
node_modules/smol-toml/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,24 @@
Copyright (c) Squirrel Chat et al., All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

236
node_modules/smol-toml/README.md generated vendored Normal file
View File

@@ -0,0 +1,236 @@
# smol-toml
[![TOML 1.0.0](https://img.shields.io/badge/TOML-1.0.0-9c4221?style=flat-square)](https://toml.io/en/v1.0.0)
[![License](https://img.shields.io/github/license/squirrelchat/smol-toml.svg?style=flat-square)](https://github.com/squirrelchat/smol-toml/blob/mistress/LICENSE)
[![npm](https://img.shields.io/npm/v/smol-toml?style=flat-square)](https://npm.im/smol-toml)
[![Build](https://img.shields.io/github/actions/workflow/status/squirrelchat/smol-toml/build.yml?style=flat-square&logo=github)](https://github.com/squirrelchat/smol-toml/actions/workflows/build.yml)
[![GitHub Sponsors](https://img.shields.io/badge/GitHub%20Sponsors-support%20me-EA4AAA?style=flat-square)](https://github.com/sponsors/cyyynthia)
[![Weekly downloads](https://img.shields.io/npm/dw/smol-toml?style=flat-square)](https://npm.im/smol-toml)
[![Monthly downloads](https://img.shields.io/npm/dm/smol-toml?style=flat-square)](https://npm.im/smol-toml)
A small, fast, and correct TOML parser and serializer. smol-toml is fully(ish) spec-compliant with TOML v1.0.0.
Why yet another TOML parser? Well, the ecosystem of TOML parsers in JavaScript is quite underwhelming, most likely due
to a lack of interest. With most parsers being outdated, unmaintained, non-compliant, or a combination of these, a new
parser didn't feel too out of place.
*[insert xkcd 927]*
Nowadays, smol-toml is the most downloaded TOML parser on npm thanks to its quality. From frameworks to tooling, it
has been battle-tested and is actively used in production systems.
smol-toml passes most of the tests from the [`toml-test` suite](https://github.com/toml-lang/toml-test); use the
`run-toml-test.bash` script to run the tests. Due to the nature of JavaScript and the limits of the language,
it doesn't pass certain tests, namely:
- Invalid UTF-8 strings are not rejected
- Certain invalid UTF-8 codepoints are not rejected
- Certain invalid dates are not rejected
- For instance, `2023-02-30` would be accepted and parsed as `2023-03-02`. While additional checks could be performed
to reject these, they've not been added for performance reasons.
Please also note that by default, the behavior regarding integers doesn't preserve type information, nor does it allow
deserializing integers larger than 53 bits. See [Integers](#integers).
You can see a list of all tests smol-toml fails (and the reason why it fails these) in the list of skipped tests in
`run-toml-test.bash`. Note that some failures are *not* specification violations per-se. For instance, the TOML spec
does not require 64-bit integer range support or sub-millisecond time precision, but are included in the `toml-test`
suite. See https://github.com/toml-lang/toml-test/issues/154 and https://github.com/toml-lang/toml-test/issues/155
## Installation
```
[pnpm | yarn | npm] i smol-toml
```
## Usage
```js
import { parse, stringify } from 'smol-toml'
const doc = '...'
const parsed = parse(doc)
console.log(parsed)
const toml = stringify(parsed)
console.log(toml)
```
Alternatively, if you prefer something similar to the JSON global, you can import the library as follows
```js
import TOML from 'smol-toml'
TOML.stringify({ ... })
```
A few notes on the `stringify` function:
- `undefined` and `null` values on objects are ignored (does not produce a key/value).
- `undefined` and `null` values in arrays are **rejected**.
- Functions, classes and symbols are **rejected**.
- By default, floats will be serialized as integers if they don't have a decimal part. See [Integers](#integers)
- `stringify(parse('a = 1.0')) === 'a = 1'`
- JS `Date` will be serialized as Offset Date Time
- Use the [`TomlDate` object](#dates) for representing other types.
### Integers
When parsing, both integers and floats are read as plain JavaScript numbers, which essentially are floats. This means
loss of type information, and makes it impossible to safely represent integers beyond 53 bits.
When serializing, numbers without a decimal part are serialized as integers. This allows in most cases to preserve
whether a number is an integer or not, but fails to preserve type information for numbers like `1.0`.
#### Enabling BigInt support and type preservation
To parse integers beyond 53 bits, it's possible to tell the parser to return all integers as BigInt. This will
therefore preserve the type information at the cost of using a slightly more expensive container.
```js
import { parse } from 'smol-toml'
const doc = '...'
const parsed = parse(doc, { integersAsBigInt: true })
```
If you want to keep numbers for integers that can safely be represented as a JavaScript number, you can pass
`"asNeeded"` instead.
To get end-to-end type preservation, you can tell the serializer to always treat numbers as floating point numbers.
Then, only BigInts will be serialized as integers and numbers without a decimal part will still be serialized as float.
```js
import { stringify } from 'smol-toml'
const obj = { ... }
const toml = stringify(obj, { numbersAsFloat: true })
```
### Dates
`smol-toml` uses an extended `Date` object to represent all types of TOML Dates. In the future, `smol-toml` will use
objects from the Temporal proposal, but for now we're stuck with the legacy Date object.
```js
import { TomlDate } from 'smol-toml'
// Offset Date Time
const date = new TomlDate('1979-05-27T07:32:00.000-08:00')
console.log(date.isDateTime(), date.isDate(), date.isTime(), date.isLocal()) // ~> true, false, false, false
console.log(date.toISOString()) // ~> 1979-05-27T07:32:00.000-08:00
// Local Date Time
const date = new TomlDate('1979-05-27T07:32:00.000')
console.log(date.isDateTime(), date.isDate(), date.isTime(), date.isLocal()) // ~> true, false, false, true
console.log(date.toISOString()) // ~> 1979-05-27T07:32:00.000
// Local Date
const date = new TomlDate('1979-05-27')
console.log(date.isDateTime(), date.isDate(), date.isTime(), date.isLocal()) // ~> false, true, false, true
console.log(date.toISOString()) // ~> 1979-05-27
// Local Time
const date = new TomlDate('07:32:00')
console.log(date.isDateTime(), date.isDate(), date.isTime(), date.isLocal()) // ~> false, false, true, true
console.log(date.toISOString()) // ~> 07:32:00.000
```
You can also wrap a native `Date` object and specify using different methods depending on the type of date you wish
to represent:
```js
import { TomlDate } from 'smol-toml'
const jsDate = new Date()
const offsetDateTime = TomlDate.wrapAsOffsetDateTime(jsDate)
const localDateTime = TomlDate.wrapAsLocalDateTime(jsDate)
const localDate = TomlDate.wrapAsLocalDate(jsDate)
const localTime = TomlDate.wrapAsLocalTime(jsDate)
```
## Performance
> [!NOTE]
> These benchmarks are starting to get a bit old. They will be updated in the (hopefully near) future to better
> reflect numbers of the latest version of smol-toml on the latest version of Node.js.
A note on these performance numbers: in some highly synthetic tests, other parsers such as `fast-toml` greatly
outperform other parsers, mostly due to their lack of compliance with the spec. For example, to parse a string,
`fast-toml` skips the entire string while `smol-toml` does validate the string, costing a fair share of performance.
The ~5MB test file used for benchmark here is filled with random data which attempts to be close-ish to reality in
terms of structure. The idea is to have a file relatively close to a real-world application, with moderately sized
strings etc.
The large TOML generator can be found [here](https://gist.github.com/cyyynthia/e77c744cb6494dabe37d0182506526b9)
| **Parse** | smol-toml | @iarna/toml@3.0.0 | @ltd/j-toml | fast-toml |
|----------------|---------------------|-------------------|-----------------|-----------------|
| Spec example | **71,356.51 op/s** | 33,629.31 op/s | 16,433.86 op/s | 29,421.60 op/s |
| ~5MB test file | **3.8091 op/s** | *DNF* | 2.4369 op/s | 2.6078 op/s |
| **Stringify** | smol-toml | @iarna/toml@3.0.0 | @ltd/j-toml |
|----------------|----------------------|-------------------|----------------|
| Spec example | **195,191.99 op/s** | 46,583.07 op/s | 5,670.12 op/s |
| ~5MB test file | **14.6709 op/s** | 3.5941 op/s | 0.7856 op/s |
<details>
<summary>Detailed benchmark data</summary>
Tests ran using Vitest v0.31.0 on commit f58cb6152e667e9cea09f31c93d90652e3b82bf5
CPU: Intel Core i7 7700K (4.2GHz)
```
RUN v0.31.0
✓ bench/parseSpecExample.bench.ts (4) 2462ms
name hz min max mean p75 p99 p995 p999 rme samples
· smol-toml 71,356.51 0.0132 0.2633 0.0140 0.0137 0.0219 0.0266 0.1135 ±0.37% 35679 fastest
· @iarna/toml 33,629.31 0.0272 0.2629 0.0297 0.0287 0.0571 0.0650 0.1593 ±0.45% 16815
· @ltd/j-toml 16,433.86 0.0523 1.3088 0.0608 0.0550 0.1140 0.1525 0.7348 ±1.47% 8217 slowest
· fast-toml 29,421.60 0.0305 0.2995 0.0340 0.0312 0.0618 0.0640 0.1553 ±0.47% 14711
✓ bench/parseLargeMixed.bench.ts (3) 16062ms
name hz min max mean p75 p99 p995 p999 rme samples
· smol-toml 3.8091 239.60 287.30 262.53 274.17 287.30 287.30 287.30 ±3.66% 10 fastest
· @ltd/j-toml 2.4369 376.73 493.49 410.35 442.58 493.49 493.49 493.49 ±7.08% 10 slowest
· fast-toml 2.6078 373.88 412.79 383.47 388.62 412.79 412.79 412.79 ±2.72% 10
✓ bench/stringifySpecExample.bench.ts (3) 1886ms
name hz min max mean p75 p99 p995 p999 rme samples
· smol-toml 195,191.99 0.0047 0.2704 0.0051 0.0050 0.0099 0.0110 0.0152 ±0.41% 97596 fastest
· @iarna/toml 46,583.07 0.0197 0.2808 0.0215 0.0208 0.0448 0.0470 0.1704 ±0.47% 23292
· @ltd/j-toml 5,670.12 0.1613 0.5768 0.1764 0.1726 0.3036 0.3129 0.4324 ±0.56% 2836 slowest
✓ bench/stringifyLargeMixed.bench.ts (3) 24057ms
name hz min max mean p75 p99 p995 p999 rme samples
· smol-toml 14.6709 65.1071 79.2199 68.1623 67.1088 79.2199 79.2199 79.2199 ±5.25% 10 fastest
· @iarna/toml 3.5941 266.48 295.24 278.24 290.10 295.24 295.24 295.24 ±2.83% 10
· @ltd/j-toml 0.7856 1,254.33 1,322.05 1,272.87 1,286.82 1,322.05 1,322.05 1,322.05 ±1.37% 10 slowest
BENCH Summary
smol-toml - bench/parseLargeMixed.bench.ts >
1.46x faster than fast-toml
1.56x faster than @ltd/j-toml
smol-toml - bench/parseSpecExample.bench.ts >
2.12x faster than @iarna/toml
2.43x faster than fast-toml
4.34x faster than @ltd/j-toml
smol-toml - bench/stringifyLargeMixed.bench.ts >
4.00x faster than @iarna/toml
18.33x faster than @ltd/j-toml
smol-toml - bench/stringifySpecExample.bench.ts >
4.19x faster than @iarna/toml
34.42x faster than @ltd/j-toml
```
---
Additional notes:
I initially tried to benchmark `toml-nodejs`, but the 0.3.0 package is broken.
I initially reported this to the library author, but the author decided to
- a) advise to use a custom loader (via *experimental* flag) to circumvent the invalid imports.
- Said flag, `--experimental-specifier-resolution`, has been removed in Node v20.
- b) [delete the issue](https://github.com/huan231/toml-nodejs/issues/12) when pointed out links to the Node.js
documentation about the flag removal and standard resolution algorithm.
For the reference anyway, `toml-nodejs` (with proper imports) is ~8x slower on both parse benchmark with:
- spec example: 7,543.47 op/s
- 5mb mixed: 0.7006 op/s
</details>

41
node_modules/smol-toml/dist/date.d.ts generated vendored Normal file
View File

@@ -0,0 +1,41 @@
/*!
* Copyright (c) Squirrel Chat et al., All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
export declare class TomlDate extends Date {
#private;
constructor(date: string | Date);
isDateTime(): boolean;
isLocal(): boolean;
isDate(): boolean;
isTime(): boolean;
isValid(): boolean;
toISOString(): string;
static wrapAsOffsetDateTime(jsDate: Date, offset?: string): TomlDate;
static wrapAsLocalDateTime(jsDate: Date): TomlDate;
static wrapAsLocalDate(jsDate: Date): TomlDate;
static wrapAsLocalTime(jsDate: Date): TomlDate;
}

127
node_modules/smol-toml/dist/date.js generated vendored Normal file
View File

@@ -0,0 +1,127 @@
/*!
* Copyright (c) Squirrel Chat et al., All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
let DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}:\d{2}(?:\.\d+)?)?(Z|[-+]\d{2}:\d{2})?$/i;
export class TomlDate extends Date {
#hasDate = false;
#hasTime = false;
#offset = null;
constructor(date) {
let hasDate = true;
let hasTime = true;
let offset = 'Z';
if (typeof date === 'string') {
let match = date.match(DATE_TIME_RE);
if (match) {
if (!match[1]) {
hasDate = false;
date = `0000-01-01T${date}`;
}
hasTime = !!match[2];
// Make sure to use T instead of a space. Breaks in case of extreme values otherwise.
hasTime && date[10] === ' ' && (date = date.replace(' ', 'T'));
// Do not allow rollover hours.
if (match[2] && +match[2] > 23) {
date = '';
}
else {
offset = match[3] || null;
date = date.toUpperCase();
if (!offset && hasTime)
date += 'Z';
}
}
else {
date = '';
}
}
super(date);
if (!isNaN(this.getTime())) {
this.#hasDate = hasDate;
this.#hasTime = hasTime;
this.#offset = offset;
}
}
isDateTime() {
return this.#hasDate && this.#hasTime;
}
isLocal() {
return !this.#hasDate || !this.#hasTime || !this.#offset;
}
isDate() {
return this.#hasDate && !this.#hasTime;
}
isTime() {
return this.#hasTime && !this.#hasDate;
}
isValid() {
return this.#hasDate || this.#hasTime;
}
toISOString() {
let iso = super.toISOString();
// Local Date
if (this.isDate())
return iso.slice(0, 10);
// Local Time
if (this.isTime())
return iso.slice(11, 23);
// Local DateTime
if (this.#offset === null)
return iso.slice(0, -1);
// Offset DateTime
if (this.#offset === 'Z')
return iso;
// This part is quite annoying: JS strips the original timezone from the ISO string representation
// Instead of using a "modified" date and "Z", we restore the representation "as authored"
let offset = (+(this.#offset.slice(1, 3)) * 60) + +(this.#offset.slice(4, 6));
offset = this.#offset[0] === '-' ? offset : -offset;
let offsetDate = new Date(this.getTime() - (offset * 60e3));
return offsetDate.toISOString().slice(0, -1) + this.#offset;
}
static wrapAsOffsetDateTime(jsDate, offset = 'Z') {
let date = new TomlDate(jsDate);
date.#offset = offset;
return date;
}
static wrapAsLocalDateTime(jsDate) {
let date = new TomlDate(jsDate);
date.#offset = null;
return date;
}
static wrapAsLocalDate(jsDate) {
let date = new TomlDate(jsDate);
date.#hasTime = false;
date.#offset = null;
return date;
}
static wrapAsLocalTime(jsDate) {
let date = new TomlDate(jsDate);
date.#hasDate = false;
date.#offset = null;
return date;
}
}

38
node_modules/smol-toml/dist/error.d.ts generated vendored Normal file
View File

@@ -0,0 +1,38 @@
/*!
* Copyright (c) Squirrel Chat et al., All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
type TomlErrorOptions = ErrorOptions & {
toml: string;
ptr: number;
};
export declare class TomlError extends Error {
line: number;
column: number;
codeblock: string;
constructor(message: string, options: TomlErrorOptions);
}
export {};

63
node_modules/smol-toml/dist/error.js generated vendored Normal file
View File

@@ -0,0 +1,63 @@
/*!
* Copyright (c) Squirrel Chat et al., All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
function getLineColFromPtr(string, ptr) {
let lines = string.slice(0, ptr).split(/\r\n|\n|\r/g);
return [lines.length, lines.pop().length + 1];
}
function makeCodeBlock(string, line, column) {
let lines = string.split(/\r\n|\n|\r/g);
let codeblock = '';
let numberLen = (Math.log10(line + 1) | 0) + 1;
for (let i = line - 1; i <= line + 1; i++) {
let l = lines[i - 1];
if (!l)
continue;
codeblock += i.toString().padEnd(numberLen, ' ');
codeblock += ': ';
codeblock += l;
codeblock += '\n';
if (i === line) {
codeblock += ' '.repeat(numberLen + column + 2);
codeblock += '^\n';
}
}
return codeblock;
}
export class TomlError extends Error {
line;
column;
codeblock;
constructor(message, options) {
const [line, column] = getLineColFromPtr(options.toml, options.ptr);
const codeblock = makeCodeBlock(options.toml, line, column);
super(`Invalid TOML document: ${message}\n\n${codeblock}`, options);
this.line = line;
this.column = column;
this.codeblock = codeblock;
}
}

30
node_modules/smol-toml/dist/extract.d.ts generated vendored Normal file
View File

@@ -0,0 +1,30 @@
/*!
* Copyright (c) Squirrel Chat et al., All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import { type IntegersAsBigInt } from './primitive.js';
import { type TomlValue } from './util.js';
export declare function extractValue(str: string, ptr: number, end: string | undefined, depth: number, integersAsBigInt: IntegersAsBigInt): [TomlValue, number];

109
node_modules/smol-toml/dist/extract.js generated vendored Normal file
View File

@@ -0,0 +1,109 @@
/*!
* Copyright (c) Squirrel Chat et al., All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import { parseString, parseValue } from './primitive.js';
import { parseArray, parseInlineTable } from './struct.js';
import { indexOfNewline, skipVoid, skipUntil, skipComment, getStringEnd } from './util.js';
import { TomlError } from './error.js';
function sliceAndTrimEndOf(str, startPtr, endPtr, allowNewLines) {
let value = str.slice(startPtr, endPtr);
let commentIdx = value.indexOf('#');
if (commentIdx > -1) {
// The call to skipComment allows to "validate" the comment
// (absence of control characters)
skipComment(str, commentIdx);
value = value.slice(0, commentIdx);
}
let trimmed = value.trimEnd();
if (!allowNewLines) {
let newlineIdx = value.indexOf('\n', trimmed.length);
if (newlineIdx > -1) {
throw new TomlError('newlines are not allowed in inline tables', {
toml: str,
ptr: startPtr + newlineIdx
});
}
}
return [trimmed, commentIdx];
}
export function extractValue(str, ptr, end, depth, integersAsBigInt) {
if (depth === 0) {
throw new TomlError('document contains excessively nested structures. aborting.', {
toml: str,
ptr: ptr
});
}
let c = str[ptr];
if (c === '[' || c === '{') {
let [value, endPtr] = c === '['
? parseArray(str, ptr, depth, integersAsBigInt)
: parseInlineTable(str, ptr, depth, integersAsBigInt);
let newPtr = end ? skipUntil(str, endPtr, ',', end) : endPtr;
if (endPtr - newPtr && end === '}') {
let nextNewLine = indexOfNewline(str, endPtr, newPtr);
if (nextNewLine > -1) {
throw new TomlError('newlines are not allowed in inline tables', {
toml: str,
ptr: nextNewLine
});
}
}
return [value, newPtr];
}
let endPtr;
if (c === '"' || c === "'") {
endPtr = getStringEnd(str, ptr);
let parsed = parseString(str, ptr, endPtr);
if (end) {
endPtr = skipVoid(str, endPtr, end !== ']');
if (str[endPtr] && str[endPtr] !== ',' && str[endPtr] !== end && str[endPtr] !== '\n' && str[endPtr] !== '\r') {
throw new TomlError('unexpected character encountered', {
toml: str,
ptr: endPtr,
});
}
endPtr += (+(str[endPtr] === ','));
}
return [parsed, endPtr];
}
endPtr = skipUntil(str, ptr, ',', end);
let slice = sliceAndTrimEndOf(str, ptr, endPtr - (+(str[endPtr - 1] === ',')), end === ']');
if (!slice[0]) {
throw new TomlError('incomplete key-value declaration: no value specified', {
toml: str,
ptr: ptr
});
}
if (end && slice[1] > -1) {
endPtr = skipVoid(str, ptr + slice[1]);
endPtr += +(str[endPtr] === ',');
}
return [
parseValue(slice[0], str, ptr, integersAsBigInt),
endPtr,
];
}

900
node_modules/smol-toml/dist/index.cjs generated vendored Normal file
View File

@@ -0,0 +1,900 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// dist/index.js
var index_exports = {};
__export(index_exports, {
TomlDate: () => TomlDate,
TomlError: () => TomlError,
default: () => index_default,
parse: () => parse,
stringify: () => stringify
});
module.exports = __toCommonJS(index_exports);
// dist/error.js
function getLineColFromPtr(string, ptr) {
let lines = string.slice(0, ptr).split(/\r\n|\n|\r/g);
return [lines.length, lines.pop().length + 1];
}
function makeCodeBlock(string, line, column) {
let lines = string.split(/\r\n|\n|\r/g);
let codeblock = "";
let numberLen = (Math.log10(line + 1) | 0) + 1;
for (let i = line - 1; i <= line + 1; i++) {
let l = lines[i - 1];
if (!l)
continue;
codeblock += i.toString().padEnd(numberLen, " ");
codeblock += ": ";
codeblock += l;
codeblock += "\n";
if (i === line) {
codeblock += " ".repeat(numberLen + column + 2);
codeblock += "^\n";
}
}
return codeblock;
}
var TomlError = class extends Error {
line;
column;
codeblock;
constructor(message, options) {
const [line, column] = getLineColFromPtr(options.toml, options.ptr);
const codeblock = makeCodeBlock(options.toml, line, column);
super(`Invalid TOML document: ${message}
${codeblock}`, options);
this.line = line;
this.column = column;
this.codeblock = codeblock;
}
};
// dist/util.js
function indexOfNewline(str, start = 0, end = str.length) {
let idx = str.indexOf("\n", start);
if (str[idx - 1] === "\r")
idx--;
return idx <= end ? idx : -1;
}
function skipComment(str, ptr) {
for (let i = ptr; i < str.length; i++) {
let c = str[i];
if (c === "\n")
return i;
if (c === "\r" && str[i + 1] === "\n")
return i + 1;
if (c < " " && c !== " " || c === "\x7F") {
throw new TomlError("control characters are not allowed in comments", {
toml: str,
ptr
});
}
}
return str.length;
}
function skipVoid(str, ptr, banNewLines, banComments) {
let c;
while ((c = str[ptr]) === " " || c === " " || !banNewLines && (c === "\n" || c === "\r" && str[ptr + 1] === "\n"))
ptr++;
return banComments || c !== "#" ? ptr : skipVoid(str, skipComment(str, ptr), banNewLines);
}
function skipUntil(str, ptr, sep, end, banNewLines = false) {
if (!end) {
ptr = indexOfNewline(str, ptr);
return ptr < 0 ? str.length : ptr;
}
for (let i = ptr; i < str.length; i++) {
let c = str[i];
if (c === "#") {
i = indexOfNewline(str, i);
} else if (c === sep) {
return i + 1;
} else if (c === end || banNewLines && (c === "\n" || c === "\r" && str[i + 1] === "\n")) {
return i;
}
}
throw new TomlError("cannot find end of structure", {
toml: str,
ptr
});
}
function getStringEnd(str, seek) {
let first = str[seek];
let target = first === str[seek + 1] && str[seek + 1] === str[seek + 2] ? str.slice(seek, seek + 3) : first;
seek += target.length - 1;
do
seek = str.indexOf(target, ++seek);
while (seek > -1 && first !== "'" && str[seek - 1] === "\\" && (str[seek - 2] !== "\\" || str[seek - 3] === "\\"));
if (seek > -1) {
seek += target.length;
if (target.length > 1) {
if (str[seek] === first)
seek++;
if (str[seek] === first)
seek++;
}
}
return seek;
}
// dist/date.js
var DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}:\d{2}(?:\.\d+)?)?(Z|[-+]\d{2}:\d{2})?$/i;
var TomlDate = class _TomlDate extends Date {
#hasDate = false;
#hasTime = false;
#offset = null;
constructor(date) {
let hasDate = true;
let hasTime = true;
let offset = "Z";
if (typeof date === "string") {
let match = date.match(DATE_TIME_RE);
if (match) {
if (!match[1]) {
hasDate = false;
date = `0000-01-01T${date}`;
}
hasTime = !!match[2];
hasTime && date[10] === " " && (date = date.replace(" ", "T"));
if (match[2] && +match[2] > 23) {
date = "";
} else {
offset = match[3] || null;
date = date.toUpperCase();
if (!offset && hasTime)
date += "Z";
}
} else {
date = "";
}
}
super(date);
if (!isNaN(this.getTime())) {
this.#hasDate = hasDate;
this.#hasTime = hasTime;
this.#offset = offset;
}
}
isDateTime() {
return this.#hasDate && this.#hasTime;
}
isLocal() {
return !this.#hasDate || !this.#hasTime || !this.#offset;
}
isDate() {
return this.#hasDate && !this.#hasTime;
}
isTime() {
return this.#hasTime && !this.#hasDate;
}
isValid() {
return this.#hasDate || this.#hasTime;
}
toISOString() {
let iso = super.toISOString();
if (this.isDate())
return iso.slice(0, 10);
if (this.isTime())
return iso.slice(11, 23);
if (this.#offset === null)
return iso.slice(0, -1);
if (this.#offset === "Z")
return iso;
let offset = +this.#offset.slice(1, 3) * 60 + +this.#offset.slice(4, 6);
offset = this.#offset[0] === "-" ? offset : -offset;
let offsetDate = new Date(this.getTime() - offset * 6e4);
return offsetDate.toISOString().slice(0, -1) + this.#offset;
}
static wrapAsOffsetDateTime(jsDate, offset = "Z") {
let date = new _TomlDate(jsDate);
date.#offset = offset;
return date;
}
static wrapAsLocalDateTime(jsDate) {
let date = new _TomlDate(jsDate);
date.#offset = null;
return date;
}
static wrapAsLocalDate(jsDate) {
let date = new _TomlDate(jsDate);
date.#hasTime = false;
date.#offset = null;
return date;
}
static wrapAsLocalTime(jsDate) {
let date = new _TomlDate(jsDate);
date.#hasDate = false;
date.#offset = null;
return date;
}
};
// dist/primitive.js
var INT_REGEX = /^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/;
var FLOAT_REGEX = /^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/;
var LEADING_ZERO = /^[+-]?0[0-9_]/;
var ESCAPE_REGEX = /^[0-9a-f]{4,8}$/i;
var ESC_MAP = {
b: "\b",
t: " ",
n: "\n",
f: "\f",
r: "\r",
'"': '"',
"\\": "\\"
};
function parseString(str, ptr = 0, endPtr = str.length) {
let isLiteral = str[ptr] === "'";
let isMultiline = str[ptr++] === str[ptr] && str[ptr] === str[ptr + 1];
if (isMultiline) {
endPtr -= 2;
if (str[ptr += 2] === "\r")
ptr++;
if (str[ptr] === "\n")
ptr++;
}
let tmp = 0;
let isEscape;
let parsed = "";
let sliceStart = ptr;
while (ptr < endPtr - 1) {
let c = str[ptr++];
if (c === "\n" || c === "\r" && str[ptr] === "\n") {
if (!isMultiline) {
throw new TomlError("newlines are not allowed in strings", {
toml: str,
ptr: ptr - 1
});
}
} else if (c < " " && c !== " " || c === "\x7F") {
throw new TomlError("control characters are not allowed in strings", {
toml: str,
ptr: ptr - 1
});
}
if (isEscape) {
isEscape = false;
if (c === "u" || c === "U") {
let code = str.slice(ptr, ptr += c === "u" ? 4 : 8);
if (!ESCAPE_REGEX.test(code)) {
throw new TomlError("invalid unicode escape", {
toml: str,
ptr: tmp
});
}
try {
parsed += String.fromCodePoint(parseInt(code, 16));
} catch {
throw new TomlError("invalid unicode escape", {
toml: str,
ptr: tmp
});
}
} else if (isMultiline && (c === "\n" || c === " " || c === " " || c === "\r")) {
ptr = skipVoid(str, ptr - 1, true);
if (str[ptr] !== "\n" && str[ptr] !== "\r") {
throw new TomlError("invalid escape: only line-ending whitespace may be escaped", {
toml: str,
ptr: tmp
});
}
ptr = skipVoid(str, ptr);
} else if (c in ESC_MAP) {
parsed += ESC_MAP[c];
} else {
throw new TomlError("unrecognized escape sequence", {
toml: str,
ptr: tmp
});
}
sliceStart = ptr;
} else if (!isLiteral && c === "\\") {
tmp = ptr - 1;
isEscape = true;
parsed += str.slice(sliceStart, tmp);
}
}
return parsed + str.slice(sliceStart, endPtr - 1);
}
function parseValue(value, toml, ptr, integersAsBigInt) {
if (value === "true")
return true;
if (value === "false")
return false;
if (value === "-inf")
return -Infinity;
if (value === "inf" || value === "+inf")
return Infinity;
if (value === "nan" || value === "+nan" || value === "-nan")
return NaN;
if (value === "-0")
return integersAsBigInt ? 0n : 0;
let isInt = INT_REGEX.test(value);
if (isInt || FLOAT_REGEX.test(value)) {
if (LEADING_ZERO.test(value)) {
throw new TomlError("leading zeroes are not allowed", {
toml,
ptr
});
}
value = value.replace(/_/g, "");
let numeric = +value;
if (isNaN(numeric)) {
throw new TomlError("invalid number", {
toml,
ptr
});
}
if (isInt) {
if ((isInt = !Number.isSafeInteger(numeric)) && !integersAsBigInt) {
throw new TomlError("integer value cannot be represented losslessly", {
toml,
ptr
});
}
if (isInt || integersAsBigInt === true)
numeric = BigInt(value);
}
return numeric;
}
const date = new TomlDate(value);
if (!date.isValid()) {
throw new TomlError("invalid value", {
toml,
ptr
});
}
return date;
}
// dist/extract.js
function sliceAndTrimEndOf(str, startPtr, endPtr, allowNewLines) {
let value = str.slice(startPtr, endPtr);
let commentIdx = value.indexOf("#");
if (commentIdx > -1) {
skipComment(str, commentIdx);
value = value.slice(0, commentIdx);
}
let trimmed = value.trimEnd();
if (!allowNewLines) {
let newlineIdx = value.indexOf("\n", trimmed.length);
if (newlineIdx > -1) {
throw new TomlError("newlines are not allowed in inline tables", {
toml: str,
ptr: startPtr + newlineIdx
});
}
}
return [trimmed, commentIdx];
}
function extractValue(str, ptr, end, depth, integersAsBigInt) {
if (depth === 0) {
throw new TomlError("document contains excessively nested structures. aborting.", {
toml: str,
ptr
});
}
let c = str[ptr];
if (c === "[" || c === "{") {
let [value, endPtr2] = c === "[" ? parseArray(str, ptr, depth, integersAsBigInt) : parseInlineTable(str, ptr, depth, integersAsBigInt);
let newPtr = end ? skipUntil(str, endPtr2, ",", end) : endPtr2;
if (endPtr2 - newPtr && end === "}") {
let nextNewLine = indexOfNewline(str, endPtr2, newPtr);
if (nextNewLine > -1) {
throw new TomlError("newlines are not allowed in inline tables", {
toml: str,
ptr: nextNewLine
});
}
}
return [value, newPtr];
}
let endPtr;
if (c === '"' || c === "'") {
endPtr = getStringEnd(str, ptr);
let parsed = parseString(str, ptr, endPtr);
if (end) {
endPtr = skipVoid(str, endPtr, end !== "]");
if (str[endPtr] && str[endPtr] !== "," && str[endPtr] !== end && str[endPtr] !== "\n" && str[endPtr] !== "\r") {
throw new TomlError("unexpected character encountered", {
toml: str,
ptr: endPtr
});
}
endPtr += +(str[endPtr] === ",");
}
return [parsed, endPtr];
}
endPtr = skipUntil(str, ptr, ",", end);
let slice = sliceAndTrimEndOf(str, ptr, endPtr - +(str[endPtr - 1] === ","), end === "]");
if (!slice[0]) {
throw new TomlError("incomplete key-value declaration: no value specified", {
toml: str,
ptr
});
}
if (end && slice[1] > -1) {
endPtr = skipVoid(str, ptr + slice[1]);
endPtr += +(str[endPtr] === ",");
}
return [
parseValue(slice[0], str, ptr, integersAsBigInt),
endPtr
];
}
// dist/struct.js
var KEY_PART_RE = /^[a-zA-Z0-9-_]+[ \t]*$/;
function parseKey(str, ptr, end = "=") {
let dot = ptr - 1;
let parsed = [];
let endPtr = str.indexOf(end, ptr);
if (endPtr < 0) {
throw new TomlError("incomplete key-value: cannot find end of key", {
toml: str,
ptr
});
}
do {
let c = str[ptr = ++dot];
if (c !== " " && c !== " ") {
if (c === '"' || c === "'") {
if (c === str[ptr + 1] && c === str[ptr + 2]) {
throw new TomlError("multiline strings are not allowed in keys", {
toml: str,
ptr
});
}
let eos = getStringEnd(str, ptr);
if (eos < 0) {
throw new TomlError("unfinished string encountered", {
toml: str,
ptr
});
}
dot = str.indexOf(".", eos);
let strEnd = str.slice(eos, dot < 0 || dot > endPtr ? endPtr : dot);
let newLine = indexOfNewline(strEnd);
if (newLine > -1) {
throw new TomlError("newlines are not allowed in keys", {
toml: str,
ptr: ptr + dot + newLine
});
}
if (strEnd.trimStart()) {
throw new TomlError("found extra tokens after the string part", {
toml: str,
ptr: eos
});
}
if (endPtr < eos) {
endPtr = str.indexOf(end, eos);
if (endPtr < 0) {
throw new TomlError("incomplete key-value: cannot find end of key", {
toml: str,
ptr
});
}
}
parsed.push(parseString(str, ptr, eos));
} else {
dot = str.indexOf(".", ptr);
let part = str.slice(ptr, dot < 0 || dot > endPtr ? endPtr : dot);
if (!KEY_PART_RE.test(part)) {
throw new TomlError("only letter, numbers, dashes and underscores are allowed in keys", {
toml: str,
ptr
});
}
parsed.push(part.trimEnd());
}
}
} while (dot + 1 && dot < endPtr);
return [parsed, skipVoid(str, endPtr + 1, true, true)];
}
function parseInlineTable(str, ptr, depth, integersAsBigInt) {
let res = {};
let seen = /* @__PURE__ */ new Set();
let c;
let comma = 0;
ptr++;
while ((c = str[ptr++]) !== "}" && c) {
let err = { toml: str, ptr: ptr - 1 };
if (c === "\n") {
throw new TomlError("newlines are not allowed in inline tables", err);
} else if (c === "#") {
throw new TomlError("inline tables cannot contain comments", err);
} else if (c === ",") {
throw new TomlError("expected key-value, found comma", err);
} else if (c !== " " && c !== " ") {
let k;
let t = res;
let hasOwn = false;
let [key, keyEndPtr] = parseKey(str, ptr - 1);
for (let i = 0; i < key.length; i++) {
if (i)
t = hasOwn ? t[k] : t[k] = {};
k = key[i];
if ((hasOwn = Object.hasOwn(t, k)) && (typeof t[k] !== "object" || seen.has(t[k]))) {
throw new TomlError("trying to redefine an already defined value", {
toml: str,
ptr
});
}
if (!hasOwn && k === "__proto__") {
Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
}
}
if (hasOwn) {
throw new TomlError("trying to redefine an already defined value", {
toml: str,
ptr
});
}
let [value, valueEndPtr] = extractValue(str, keyEndPtr, "}", depth - 1, integersAsBigInt);
seen.add(value);
t[k] = value;
ptr = valueEndPtr;
comma = str[ptr - 1] === "," ? ptr - 1 : 0;
}
}
if (comma) {
throw new TomlError("trailing commas are not allowed in inline tables", {
toml: str,
ptr: comma
});
}
if (!c) {
throw new TomlError("unfinished table encountered", {
toml: str,
ptr
});
}
return [res, ptr];
}
function parseArray(str, ptr, depth, integersAsBigInt) {
let res = [];
let c;
ptr++;
while ((c = str[ptr++]) !== "]" && c) {
if (c === ",") {
throw new TomlError("expected value, found comma", {
toml: str,
ptr: ptr - 1
});
} else if (c === "#")
ptr = skipComment(str, ptr);
else if (c !== " " && c !== " " && c !== "\n" && c !== "\r") {
let e = extractValue(str, ptr - 1, "]", depth - 1, integersAsBigInt);
res.push(e[0]);
ptr = e[1];
}
}
if (!c) {
throw new TomlError("unfinished array encountered", {
toml: str,
ptr
});
}
return [res, ptr];
}
// dist/parse.js
function peekTable(key, table, meta, type) {
let t = table;
let m = meta;
let k;
let hasOwn = false;
let state;
for (let i = 0; i < key.length; i++) {
if (i) {
t = hasOwn ? t[k] : t[k] = {};
m = (state = m[k]).c;
if (type === 0 && (state.t === 1 || state.t === 2)) {
return null;
}
if (state.t === 2) {
let l = t.length - 1;
t = t[l];
m = m[l].c;
}
}
k = key[i];
if ((hasOwn = Object.hasOwn(t, k)) && m[k]?.t === 0 && m[k]?.d) {
return null;
}
if (!hasOwn) {
if (k === "__proto__") {
Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
Object.defineProperty(m, k, { enumerable: true, configurable: true, writable: true });
}
m[k] = {
t: i < key.length - 1 && type === 2 ? 3 : type,
d: false,
i: 0,
c: {}
};
}
}
state = m[k];
if (state.t !== type && !(type === 1 && state.t === 3)) {
return null;
}
if (type === 2) {
if (!state.d) {
state.d = true;
t[k] = [];
}
t[k].push(t = {});
state.c[state.i++] = state = { t: 1, d: false, i: 0, c: {} };
}
if (state.d) {
return null;
}
state.d = true;
if (type === 1) {
t = hasOwn ? t[k] : t[k] = {};
} else if (type === 0 && hasOwn) {
return null;
}
return [k, t, state.c];
}
function parse(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
let res = {};
let meta = {};
let tbl = res;
let m = meta;
for (let ptr = skipVoid(toml, 0); ptr < toml.length; ) {
if (toml[ptr] === "[") {
let isTableArray = toml[++ptr] === "[";
let k = parseKey(toml, ptr += +isTableArray, "]");
if (isTableArray) {
if (toml[k[1] - 1] !== "]") {
throw new TomlError("expected end of table declaration", {
toml,
ptr: k[1] - 1
});
}
k[1]++;
}
let p = peekTable(
k[0],
res,
meta,
isTableArray ? 2 : 1
/* Type.EXPLICIT */
);
if (!p) {
throw new TomlError("trying to redefine an already defined table or value", {
toml,
ptr
});
}
m = p[2];
tbl = p[1];
ptr = k[1];
} else {
let k = parseKey(toml, ptr);
let p = peekTable(
k[0],
tbl,
m,
0
/* Type.DOTTED */
);
if (!p) {
throw new TomlError("trying to redefine an already defined table or value", {
toml,
ptr
});
}
let v = extractValue(toml, k[1], void 0, maxDepth, integersAsBigInt);
p[1][p[0]] = v[0];
ptr = v[1];
}
ptr = skipVoid(toml, ptr, true);
if (toml[ptr] && toml[ptr] !== "\n" && toml[ptr] !== "\r") {
throw new TomlError("each key-value declaration must be followed by an end-of-line", {
toml,
ptr
});
}
ptr = skipVoid(toml, ptr);
}
return res;
}
// dist/stringify.js
var BARE_KEY = /^[a-z0-9-_]+$/i;
function extendedTypeOf(obj) {
let type = typeof obj;
if (type === "object") {
if (Array.isArray(obj))
return "array";
if (obj instanceof Date)
return "date";
}
return type;
}
function isArrayOfTables(obj) {
for (let i = 0; i < obj.length; i++) {
if (extendedTypeOf(obj[i]) !== "object")
return false;
}
return obj.length != 0;
}
function formatString(s) {
return JSON.stringify(s).replace(/\x7f/g, "\\u007f");
}
function stringifyValue(val, type, depth, numberAsFloat) {
if (depth === 0) {
throw new Error("Could not stringify the object: maximum object depth exceeded");
}
if (type === "number") {
if (isNaN(val))
return "nan";
if (val === Infinity)
return "inf";
if (val === -Infinity)
return "-inf";
if (numberAsFloat && Number.isInteger(val))
return val.toFixed(1);
return val.toString();
}
if (type === "bigint" || type === "boolean") {
return val.toString();
}
if (type === "string") {
return formatString(val);
}
if (type === "date") {
if (isNaN(val.getTime())) {
throw new TypeError("cannot serialize invalid date");
}
return val.toISOString();
}
if (type === "object") {
return stringifyInlineTable(val, depth, numberAsFloat);
}
if (type === "array") {
return stringifyArray(val, depth, numberAsFloat);
}
}
function stringifyInlineTable(obj, depth, numberAsFloat) {
let keys = Object.keys(obj);
if (keys.length === 0)
return "{}";
let res = "{ ";
for (let i = 0; i < keys.length; i++) {
let k = keys[i];
if (i)
res += ", ";
res += BARE_KEY.test(k) ? k : formatString(k);
res += " = ";
res += stringifyValue(obj[k], extendedTypeOf(obj[k]), depth - 1, numberAsFloat);
}
return res + " }";
}
function stringifyArray(array, depth, numberAsFloat) {
if (array.length === 0)
return "[]";
let res = "[ ";
for (let i = 0; i < array.length; i++) {
if (i)
res += ", ";
if (array[i] === null || array[i] === void 0) {
throw new TypeError("arrays cannot contain null or undefined values");
}
res += stringifyValue(array[i], extendedTypeOf(array[i]), depth - 1, numberAsFloat);
}
return res + " ]";
}
function stringifyArrayTable(array, key, depth, numberAsFloat) {
if (depth === 0) {
throw new Error("Could not stringify the object: maximum object depth exceeded");
}
let res = "";
for (let i = 0; i < array.length; i++) {
res += `[[${key}]]
`;
res += stringifyTable(array[i], key, depth, numberAsFloat);
res += "\n\n";
}
return res;
}
function stringifyTable(obj, prefix, depth, numberAsFloat) {
if (depth === 0) {
throw new Error("Could not stringify the object: maximum object depth exceeded");
}
let preamble = "";
let tables = "";
let keys = Object.keys(obj);
for (let i = 0; i < keys.length; i++) {
let k = keys[i];
if (obj[k] !== null && obj[k] !== void 0) {
let type = extendedTypeOf(obj[k]);
if (type === "symbol" || type === "function") {
throw new TypeError(`cannot serialize values of type '${type}'`);
}
let key = BARE_KEY.test(k) ? k : formatString(k);
if (type === "array" && isArrayOfTables(obj[k])) {
tables += stringifyArrayTable(obj[k], prefix ? `${prefix}.${key}` : key, depth - 1, numberAsFloat);
} else if (type === "object") {
let tblKey = prefix ? `${prefix}.${key}` : key;
tables += `[${tblKey}]
`;
tables += stringifyTable(obj[k], tblKey, depth - 1, numberAsFloat);
tables += "\n\n";
} else {
preamble += key;
preamble += " = ";
preamble += stringifyValue(obj[k], type, depth, numberAsFloat);
preamble += "\n";
}
}
}
return `${preamble}
${tables}`.trim();
}
function stringify(obj, { maxDepth = 1e3, numbersAsFloat = false } = {}) {
if (extendedTypeOf(obj) !== "object") {
throw new TypeError("stringify can only be called with an object");
}
return stringifyTable(obj, "", maxDepth, numbersAsFloat);
}
// dist/index.js
var index_default = { parse, stringify, TomlDate, TomlError };
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
TomlDate,
TomlError,
parse,
stringify
});
/*!
* Copyright (c) Squirrel Chat et al., All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

43
node_modules/smol-toml/dist/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,43 @@
/*!
* Copyright (c) Squirrel Chat et al., All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import { parse } from './parse.js';
import { stringify } from './stringify.js';
import { TomlDate } from './date.js';
import { TomlError } from './error.js';
export type { TomlValue, TomlTable, TomlValueWithoutBigInt, TomlTableWithoutBigInt } from './util.js';
declare const _default: {
parse: typeof parse;
stringify: typeof stringify;
TomlDate: typeof TomlDate;
TomlError: typeof TomlError;
};
export default _default;
export { parse, stringify, TomlDate, TomlError };
export type {
/** @deprecated use TomlValue instead */
TomlValue as TomlPrimitive } from './util.js';

33
node_modules/smol-toml/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,33 @@
/*!
* Copyright (c) Squirrel Chat et al., All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import { parse } from './parse.js';
import { stringify } from './stringify.js';
import { TomlDate } from './date.js';
import { TomlError } from './error.js';
export default { parse, stringify, TomlDate, TomlError };
export { parse, stringify, TomlDate, TomlError };

37
node_modules/smol-toml/dist/parse.d.ts generated vendored Normal file
View File

@@ -0,0 +1,37 @@
/*!
* Copyright (c) Squirrel Chat et al., All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import type { IntegersAsBigInt } from './primitive.js';
import { type TomlTable, type TomlTableWithoutBigInt } from './util.js';
export interface ParseOptions {
maxDepth?: number;
integersAsBigInt?: IntegersAsBigInt;
}
export declare function parse(toml: string, options?: ParseOptions & {
integersAsBigInt: Exclude<IntegersAsBigInt, undefined | false>;
}): TomlTable;
export declare function parse(toml: string, options?: ParseOptions): TomlTableWithoutBigInt;

148
node_modules/smol-toml/dist/parse.js generated vendored Normal file
View File

@@ -0,0 +1,148 @@
/*!
* Copyright (c) Squirrel Chat et al., All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import { parseKey } from './struct.js';
import { extractValue } from './extract.js';
import { skipVoid } from './util.js';
import { TomlError } from './error.js';
function peekTable(key, table, meta, type) {
let t = table;
let m = meta;
let k;
let hasOwn = false;
let state;
for (let i = 0; i < key.length; i++) {
if (i) {
t = hasOwn ? t[k] : (t[k] = {});
m = (state = m[k]).c;
if (type === 0 /* Type.DOTTED */ && (state.t === 1 /* Type.EXPLICIT */ || state.t === 2 /* Type.ARRAY */)) {
return null;
}
if (state.t === 2 /* Type.ARRAY */) {
let l = t.length - 1;
t = t[l];
m = m[l].c;
}
}
k = key[i];
if ((hasOwn = Object.hasOwn(t, k)) && m[k]?.t === 0 /* Type.DOTTED */ && m[k]?.d) {
return null;
}
if (!hasOwn) {
if (k === '__proto__') {
Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
Object.defineProperty(m, k, { enumerable: true, configurable: true, writable: true });
}
m[k] = {
t: i < key.length - 1 && type === 2 /* Type.ARRAY */
? 3 /* Type.ARRAY_DOTTED */
: type,
d: false,
i: 0,
c: {},
};
}
}
state = m[k];
if (state.t !== type && !(type === 1 /* Type.EXPLICIT */ && state.t === 3 /* Type.ARRAY_DOTTED */)) {
// Bad key type!
return null;
}
if (type === 2 /* Type.ARRAY */) {
if (!state.d) {
state.d = true;
t[k] = [];
}
t[k].push(t = {});
state.c[state.i++] = (state = { t: 1 /* Type.EXPLICIT */, d: false, i: 0, c: {} });
}
if (state.d) {
// Redefining a table!
return null;
}
state.d = true;
if (type === 1 /* Type.EXPLICIT */) {
t = hasOwn ? t[k] : (t[k] = {});
}
else if (type === 0 /* Type.DOTTED */ && hasOwn) {
return null;
}
return [k, t, state.c];
}
export function parse(toml, { maxDepth = 1000, integersAsBigInt } = {}) {
let res = {};
let meta = {};
let tbl = res;
let m = meta;
for (let ptr = skipVoid(toml, 0); ptr < toml.length;) {
if (toml[ptr] === '[') {
let isTableArray = toml[++ptr] === '[';
let k = parseKey(toml, ptr += +isTableArray, ']');
if (isTableArray) {
if (toml[k[1] - 1] !== ']') {
throw new TomlError('expected end of table declaration', {
toml: toml,
ptr: k[1] - 1,
});
}
k[1]++;
}
let p = peekTable(k[0], res, meta, isTableArray ? 2 /* Type.ARRAY */ : 1 /* Type.EXPLICIT */);
if (!p) {
throw new TomlError('trying to redefine an already defined table or value', {
toml: toml,
ptr: ptr,
});
}
m = p[2];
tbl = p[1];
ptr = k[1];
}
else {
let k = parseKey(toml, ptr);
let p = peekTable(k[0], tbl, m, 0 /* Type.DOTTED */);
if (!p) {
throw new TomlError('trying to redefine an already defined table or value', {
toml: toml,
ptr: ptr,
});
}
let v = extractValue(toml, k[1], void 0, maxDepth, integersAsBigInt);
p[1][p[0]] = v[0];
ptr = v[1];
}
ptr = skipVoid(toml, ptr, true);
if (toml[ptr] && toml[ptr] !== '\n' && toml[ptr] !== '\r') {
throw new TomlError('each key-value declaration must be followed by an end-of-line', {
toml: toml,
ptr: ptr
});
}
ptr = skipVoid(toml, ptr);
}
return res;
}

31
node_modules/smol-toml/dist/primitive.d.ts generated vendored Normal file
View File

@@ -0,0 +1,31 @@
/*!
* Copyright (c) Squirrel Chat et al., All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import { TomlDate } from './date.js';
export declare function parseString(str: string, ptr?: number, endPtr?: number): string;
export type IntegersAsBigInt = undefined | boolean | 'asNeeded';
export declare function parseValue(value: string, toml: string, ptr: number, integersAsBigInt: IntegersAsBigInt): boolean | number | bigint | TomlDate;

178
node_modules/smol-toml/dist/primitive.js generated vendored Normal file
View File

@@ -0,0 +1,178 @@
/*!
* Copyright (c) Squirrel Chat et al., All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import { skipVoid } from './util.js';
import { TomlDate } from './date.js';
import { TomlError } from './error.js';
let INT_REGEX = /^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/;
let FLOAT_REGEX = /^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/;
let LEADING_ZERO = /^[+-]?0[0-9_]/;
let ESCAPE_REGEX = /^[0-9a-f]{4,8}$/i;
let ESC_MAP = {
b: '\b',
t: '\t',
n: '\n',
f: '\f',
r: '\r',
'"': '"',
'\\': '\\',
};
export function parseString(str, ptr = 0, endPtr = str.length) {
let isLiteral = str[ptr] === '\'';
let isMultiline = str[ptr++] === str[ptr] && str[ptr] === str[ptr + 1];
if (isMultiline) {
endPtr -= 2;
if (str[ptr += 2] === '\r')
ptr++;
if (str[ptr] === '\n')
ptr++;
}
let tmp = 0;
let isEscape;
let parsed = '';
let sliceStart = ptr;
while (ptr < endPtr - 1) {
let c = str[ptr++];
if (c === '\n' || (c === '\r' && str[ptr] === '\n')) {
if (!isMultiline) {
throw new TomlError('newlines are not allowed in strings', {
toml: str,
ptr: ptr - 1,
});
}
}
else if ((c < '\x20' && c !== '\t') || c === '\x7f') {
throw new TomlError('control characters are not allowed in strings', {
toml: str,
ptr: ptr - 1,
});
}
if (isEscape) {
isEscape = false;
if (c === 'u' || c === 'U') {
// Unicode escape
let code = str.slice(ptr, (ptr += (c === 'u' ? 4 : 8)));
if (!ESCAPE_REGEX.test(code)) {
throw new TomlError('invalid unicode escape', {
toml: str,
ptr: tmp,
});
}
try {
parsed += String.fromCodePoint(parseInt(code, 16));
}
catch {
throw new TomlError('invalid unicode escape', {
toml: str,
ptr: tmp,
});
}
}
else if (isMultiline && (c === '\n' || c === ' ' || c === '\t' || c === '\r')) {
// Multiline escape
ptr = skipVoid(str, ptr - 1, true);
if (str[ptr] !== '\n' && str[ptr] !== '\r') {
throw new TomlError('invalid escape: only line-ending whitespace may be escaped', {
toml: str,
ptr: tmp,
});
}
ptr = skipVoid(str, ptr);
}
else if (c in ESC_MAP) {
// Classic escape
parsed += ESC_MAP[c];
}
else {
throw new TomlError('unrecognized escape sequence', {
toml: str,
ptr: tmp,
});
}
sliceStart = ptr;
}
else if (!isLiteral && c === '\\') {
tmp = ptr - 1;
isEscape = true;
parsed += str.slice(sliceStart, tmp);
}
}
return parsed + str.slice(sliceStart, endPtr - 1);
}
export function parseValue(value, toml, ptr, integersAsBigInt) {
// Constant values
if (value === 'true')
return true;
if (value === 'false')
return false;
if (value === '-inf')
return -Infinity;
if (value === 'inf' || value === '+inf')
return Infinity;
if (value === 'nan' || value === '+nan' || value === '-nan')
return NaN;
// Avoid FP representation of -0
if (value === '-0')
return integersAsBigInt ? 0n : 0;
// Numbers
let isInt = INT_REGEX.test(value);
if (isInt || FLOAT_REGEX.test(value)) {
if (LEADING_ZERO.test(value)) {
throw new TomlError('leading zeroes are not allowed', {
toml: toml,
ptr: ptr,
});
}
value = value.replace(/_/g, '');
let numeric = +value;
if (isNaN(numeric)) {
throw new TomlError('invalid number', {
toml: toml,
ptr: ptr,
});
}
if (isInt) {
if ((isInt = !Number.isSafeInteger(numeric)) && !integersAsBigInt) {
throw new TomlError('integer value cannot be represented losslessly', {
toml: toml,
ptr: ptr,
});
}
if (isInt || integersAsBigInt === true)
numeric = BigInt(value);
}
return numeric;
}
const date = new TomlDate(value);
if (!date.isValid()) {
throw new TomlError('invalid value', {
toml: toml,
ptr: ptr,
});
}
return date;
}

31
node_modules/smol-toml/dist/stringify.d.ts generated vendored Normal file
View File

@@ -0,0 +1,31 @@
/*!
* Copyright (c) Squirrel Chat et al., All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
export declare function stringify(obj: any, { maxDepth, numbersAsFloat }?: {
maxDepth?: number;
numbersAsFloat?: boolean;
}): string;

163
node_modules/smol-toml/dist/stringify.js generated vendored Normal file
View File

@@ -0,0 +1,163 @@
/*!
* Copyright (c) Squirrel Chat et al., All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
let BARE_KEY = /^[a-z0-9-_]+$/i;
function extendedTypeOf(obj) {
let type = typeof obj;
if (type === 'object') {
if (Array.isArray(obj))
return 'array';
if (obj instanceof Date)
return 'date';
}
return type;
}
function isArrayOfTables(obj) {
for (let i = 0; i < obj.length; i++) {
if (extendedTypeOf(obj[i]) !== 'object')
return false;
}
return obj.length != 0;
}
function formatString(s) {
return JSON.stringify(s).replace(/\x7f/g, '\\u007f');
}
function stringifyValue(val, type, depth, numberAsFloat) {
if (depth === 0) {
throw new Error('Could not stringify the object: maximum object depth exceeded');
}
if (type === 'number') {
if (isNaN(val))
return 'nan';
if (val === Infinity)
return 'inf';
if (val === -Infinity)
return '-inf';
if (numberAsFloat && Number.isInteger(val))
return val.toFixed(1);
return val.toString();
}
if (type === 'bigint' || type === 'boolean') {
return val.toString();
}
if (type === 'string') {
return formatString(val);
}
if (type === 'date') {
if (isNaN(val.getTime())) {
throw new TypeError('cannot serialize invalid date');
}
return val.toISOString();
}
if (type === 'object') {
return stringifyInlineTable(val, depth, numberAsFloat);
}
if (type === 'array') {
return stringifyArray(val, depth, numberAsFloat);
}
}
function stringifyInlineTable(obj, depth, numberAsFloat) {
let keys = Object.keys(obj);
if (keys.length === 0)
return '{}';
let res = '{ ';
for (let i = 0; i < keys.length; i++) {
let k = keys[i];
if (i)
res += ', ';
res += BARE_KEY.test(k) ? k : formatString(k);
res += ' = ';
res += stringifyValue(obj[k], extendedTypeOf(obj[k]), depth - 1, numberAsFloat);
}
return res + ' }';
}
function stringifyArray(array, depth, numberAsFloat) {
if (array.length === 0)
return '[]';
let res = '[ ';
for (let i = 0; i < array.length; i++) {
if (i)
res += ', ';
if (array[i] === null || array[i] === void 0) {
throw new TypeError('arrays cannot contain null or undefined values');
}
res += stringifyValue(array[i], extendedTypeOf(array[i]), depth - 1, numberAsFloat);
}
return res + ' ]';
}
function stringifyArrayTable(array, key, depth, numberAsFloat) {
if (depth === 0) {
throw new Error('Could not stringify the object: maximum object depth exceeded');
}
let res = '';
for (let i = 0; i < array.length; i++) {
res += `[[${key}]]\n`;
res += stringifyTable(array[i], key, depth, numberAsFloat);
res += '\n\n';
}
return res;
}
function stringifyTable(obj, prefix, depth, numberAsFloat) {
if (depth === 0) {
throw new Error('Could not stringify the object: maximum object depth exceeded');
}
let preamble = '';
let tables = '';
let keys = Object.keys(obj);
for (let i = 0; i < keys.length; i++) {
let k = keys[i];
if (obj[k] !== null && obj[k] !== void 0) {
let type = extendedTypeOf(obj[k]);
if (type === 'symbol' || type === 'function') {
throw new TypeError(`cannot serialize values of type '${type}'`);
}
let key = BARE_KEY.test(k) ? k : formatString(k);
if (type === 'array' && isArrayOfTables(obj[k])) {
tables += stringifyArrayTable(obj[k], prefix ? `${prefix}.${key}` : key, depth - 1, numberAsFloat);
}
else if (type === 'object') {
let tblKey = prefix ? `${prefix}.${key}` : key;
tables += `[${tblKey}]\n`;
tables += stringifyTable(obj[k], tblKey, depth - 1, numberAsFloat);
tables += '\n\n';
}
else {
preamble += key;
preamble += ' = ';
preamble += stringifyValue(obj[k], type, depth, numberAsFloat);
preamble += '\n';
}
}
}
return `${preamble}\n${tables}`.trim();
}
export function stringify(obj, { maxDepth = 1000, numbersAsFloat = false } = {}) {
if (extendedTypeOf(obj) !== 'object') {
throw new TypeError('stringify can only be called with an object');
}
return stringifyTable(obj, '', maxDepth, numbersAsFloat);
}

32
node_modules/smol-toml/dist/struct.d.ts generated vendored Normal file
View File

@@ -0,0 +1,32 @@
/*!
* Copyright (c) Squirrel Chat et al., All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import { type IntegersAsBigInt } from './primitive.js';
import { type TomlTable, type TomlValue } from './util.js';
export declare function parseKey(str: string, ptr: number, end?: string): [string[], number];
export declare function parseInlineTable(str: string, ptr: number, depth: number, integersAsBigInt: IntegersAsBigInt): [TomlTable, number];
export declare function parseArray(str: string, ptr: number, depth: number, integersAsBigInt: IntegersAsBigInt): [TomlValue[], number];

194
node_modules/smol-toml/dist/struct.js generated vendored Normal file
View File

@@ -0,0 +1,194 @@
/*!
* Copyright (c) Squirrel Chat et al., All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import { parseString } from './primitive.js';
import { extractValue } from './extract.js';
import { getStringEnd, indexOfNewline, skipComment, skipVoid } from './util.js';
import { TomlError } from './error.js';
let KEY_PART_RE = /^[a-zA-Z0-9-_]+[ \t]*$/;
export function parseKey(str, ptr, end = '=') {
let dot = ptr - 1;
let parsed = [];
let endPtr = str.indexOf(end, ptr);
if (endPtr < 0) {
throw new TomlError('incomplete key-value: cannot find end of key', {
toml: str,
ptr: ptr,
});
}
do {
let c = str[ptr = ++dot];
// If it's whitespace, ignore
if (c !== ' ' && c !== '\t') {
// If it's a string
if (c === '"' || c === '\'') {
if (c === str[ptr + 1] && c === str[ptr + 2]) {
throw new TomlError('multiline strings are not allowed in keys', {
toml: str,
ptr: ptr,
});
}
let eos = getStringEnd(str, ptr);
if (eos < 0) {
throw new TomlError('unfinished string encountered', {
toml: str,
ptr: ptr,
});
}
dot = str.indexOf('.', eos);
let strEnd = str.slice(eos, dot < 0 || dot > endPtr ? endPtr : dot);
let newLine = indexOfNewline(strEnd);
if (newLine > -1) {
throw new TomlError('newlines are not allowed in keys', {
toml: str,
ptr: ptr + dot + newLine,
});
}
if (strEnd.trimStart()) {
throw new TomlError('found extra tokens after the string part', {
toml: str,
ptr: eos,
});
}
if (endPtr < eos) {
endPtr = str.indexOf(end, eos);
if (endPtr < 0) {
throw new TomlError('incomplete key-value: cannot find end of key', {
toml: str,
ptr: ptr,
});
}
}
parsed.push(parseString(str, ptr, eos));
}
else {
// Normal raw key part consumption and validation
dot = str.indexOf('.', ptr);
let part = str.slice(ptr, dot < 0 || dot > endPtr ? endPtr : dot);
if (!KEY_PART_RE.test(part)) {
throw new TomlError('only letter, numbers, dashes and underscores are allowed in keys', {
toml: str,
ptr: ptr,
});
}
parsed.push(part.trimEnd());
}
}
// Until there's no more dot
} while (dot + 1 && dot < endPtr);
return [parsed, skipVoid(str, endPtr + 1, true, true)];
}
export function parseInlineTable(str, ptr, depth, integersAsBigInt) {
let res = {};
let seen = new Set();
let c;
let comma = 0;
ptr++;
while ((c = str[ptr++]) !== '}' && c) {
let err = { toml: str, ptr: ptr - 1 };
if (c === '\n') {
throw new TomlError('newlines are not allowed in inline tables', err);
}
else if (c === '#') {
throw new TomlError('inline tables cannot contain comments', err);
}
else if (c === ',') {
throw new TomlError('expected key-value, found comma', err);
}
else if (c !== ' ' && c !== '\t') {
let k;
let t = res;
let hasOwn = false;
let [key, keyEndPtr] = parseKey(str, ptr - 1);
for (let i = 0; i < key.length; i++) {
if (i)
t = hasOwn ? t[k] : (t[k] = {});
k = key[i];
if ((hasOwn = Object.hasOwn(t, k)) && (typeof t[k] !== 'object' || seen.has(t[k]))) {
throw new TomlError('trying to redefine an already defined value', {
toml: str,
ptr: ptr,
});
}
if (!hasOwn && k === '__proto__') {
Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
}
}
if (hasOwn) {
throw new TomlError('trying to redefine an already defined value', {
toml: str,
ptr: ptr,
});
}
let [value, valueEndPtr] = extractValue(str, keyEndPtr, '}', depth - 1, integersAsBigInt);
seen.add(value);
t[k] = value;
ptr = valueEndPtr;
comma = str[ptr - 1] === ',' ? ptr - 1 : 0;
}
}
if (comma) {
throw new TomlError('trailing commas are not allowed in inline tables', {
toml: str,
ptr: comma,
});
}
if (!c) {
throw new TomlError('unfinished table encountered', {
toml: str,
ptr: ptr,
});
}
return [res, ptr];
}
export function parseArray(str, ptr, depth, integersAsBigInt) {
let res = [];
let c;
ptr++;
while ((c = str[ptr++]) !== ']' && c) {
if (c === ',') {
throw new TomlError('expected value, found comma', {
toml: str,
ptr: ptr - 1,
});
}
else if (c === '#')
ptr = skipComment(str, ptr);
else if (c !== ' ' && c !== '\t' && c !== '\n' && c !== '\r') {
let e = extractValue(str, ptr - 1, ']', depth - 1, integersAsBigInt);
res.push(e[0]);
ptr = e[1];
}
}
if (!c) {
throw new TomlError('unfinished array encountered', {
toml: str,
ptr: ptr,
});
}
return [res, ptr];
}

42
node_modules/smol-toml/dist/util.d.ts generated vendored Normal file
View File

@@ -0,0 +1,42 @@
/*!
* Copyright (c) Squirrel Chat et al., All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import type { TomlDate } from './date.js';
export type TomlPrimitive = string | number | bigint | boolean | TomlDate;
export type TomlTable = {
[key: string]: TomlValue;
};
export type TomlValue = TomlPrimitive | TomlValue[] | TomlTable;
export type TomlTableWithoutBigInt = {
[key: string]: TomlValueWithoutBigInt;
};
export type TomlValueWithoutBigInt = Exclude<TomlPrimitive, bigint> | TomlValueWithoutBigInt[] | TomlTableWithoutBigInt;
export declare function indexOfNewline(str: string, start?: number, end?: number): number;
export declare function skipComment(str: string, ptr: number): number;
export declare function skipVoid(str: string, ptr: number, banNewLines?: boolean, banComments?: boolean): number;
export declare function skipUntil(str: string, ptr: number, sep: string, end?: string, banNewLines?: boolean): number;
export declare function getStringEnd(str: string, seek: number): number;

100
node_modules/smol-toml/dist/util.js generated vendored Normal file
View File

@@ -0,0 +1,100 @@
/*!
* Copyright (c) Squirrel Chat et al., All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import { TomlError } from './error.js';
export function indexOfNewline(str, start = 0, end = str.length) {
let idx = str.indexOf('\n', start);
if (str[idx - 1] === '\r')
idx--;
return idx <= end ? idx : -1;
}
export function skipComment(str, ptr) {
for (let i = ptr; i < str.length; i++) {
let c = str[i];
if (c === '\n')
return i;
if (c === '\r' && str[i + 1] === '\n')
return i + 1;
if ((c < '\x20' && c !== '\t') || c === '\x7f') {
throw new TomlError('control characters are not allowed in comments', {
toml: str,
ptr: ptr,
});
}
}
return str.length;
}
export function skipVoid(str, ptr, banNewLines, banComments) {
let c;
while ((c = str[ptr]) === ' ' || c === '\t' || (!banNewLines && (c === '\n' || c === '\r' && str[ptr + 1] === '\n')))
ptr++;
return banComments || c !== '#'
? ptr
: skipVoid(str, skipComment(str, ptr), banNewLines);
}
export function skipUntil(str, ptr, sep, end, banNewLines = false) {
if (!end) {
ptr = indexOfNewline(str, ptr);
return ptr < 0 ? str.length : ptr;
}
for (let i = ptr; i < str.length; i++) {
let c = str[i];
if (c === '#') {
i = indexOfNewline(str, i);
}
else if (c === sep) {
return i + 1;
}
else if (c === end || (banNewLines && (c === '\n' || (c === '\r' && str[i + 1] === '\n')))) {
return i;
}
}
throw new TomlError('cannot find end of structure', {
toml: str,
ptr: ptr
});
}
export function getStringEnd(str, seek) {
let first = str[seek];
let target = first === str[seek + 1] && str[seek + 1] === str[seek + 2]
? str.slice(seek, seek + 3)
: first;
seek += target.length - 1;
do
seek = str.indexOf(target, ++seek);
while (seek > -1 && first !== "'" && str[seek - 1] === '\\' && (str[seek - 2] !== '\\' || str[seek - 3] === '\\'));
if (seek > -1) {
seek += target.length;
if (target.length > 1) {
if (str[seek] === first)
seek++;
if (str[seek] === first)
seek++;
}
}
return seek;
}

54
node_modules/smol-toml/package.json generated vendored Normal file
View File

@@ -0,0 +1,54 @@
{
"name": "smol-toml",
"license": "BSD-3-Clause",
"version": "1.4.1",
"description": "A small, fast, and correct TOML parser/serializer",
"author": "Cynthia <cyyynthia@borkenware.com>",
"repository": "github:squirrelchat/smol-toml",
"bugs": "https://github.com/squirrelchat/smol-toml/issues",
"funding": "https://github.com/sponsors/cyyynthia",
"keywords": [
"toml",
"parser",
"serializer"
],
"type": "module",
"engines": {
"node": ">= 18"
},
"devDependencies": {
"@iarna/toml": "3.0.0",
"@ltd/j-toml": "^1.38.0",
"@tsconfig/node-lts": "^22.0.2",
"@tsconfig/strictest": "^2.0.5",
"@types/node": "^24.0.7",
"@vitest/ui": "^3.2.4",
"esbuild": "^0.25.5",
"fast-toml": "^0.5.4",
"pin-github-action": "^3.4.0",
"typescript": "^5.8.3",
"vitest": "^3.2.4"
},
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.cjs"
},
"files": [
"README.md",
"LICENSE",
"dist"
],
"scripts": {
"test": "vitest",
"test-ui": "vitest --ui",
"bench": "vitest bench",
"build": "pnpm run build:mjs && pnpm run build:cjs && node test/package/package-test.mjs",
"build:mjs": "tsc",
"build:cjs": "esbuild dist/index.js --bundle --platform=node --target=node18 --format=cjs --outfile=dist/index.cjs",
"update-gha": "pin-github-action .github/workflows"
}
}