@o3co/ts.hocon 1.12.0 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +7 -5
- package/README.md +8 -4
- package/dist/adapters/env.cjs +419 -79
- package/dist/adapters/env.d.cts +1 -1
- package/dist/adapters/env.d.ts +1 -1
- package/dist/adapters/env.js +419 -79
- package/dist/adapters/json5.cjs +2450 -0
- package/dist/adapters/json5.d.cts +47 -0
- package/dist/adapters/json5.d.ts +47 -0
- package/dist/adapters/json5.js +2413 -0
- package/dist/adapters/jsonc.cjs +419 -79
- package/dist/adapters/jsonc.d.cts +1 -1
- package/dist/adapters/jsonc.d.ts +1 -1
- package/dist/adapters/jsonc.js +419 -79
- package/dist/adapters/properties.cjs +419 -79
- package/dist/adapters/properties.d.cts +1 -1
- package/dist/adapters/properties.d.ts +1 -1
- package/dist/adapters/properties.js +419 -79
- package/dist/adapters/toml.cjs +419 -79
- package/dist/adapters/toml.d.cts +1 -1
- package/dist/adapters/toml.d.ts +1 -1
- package/dist/adapters/toml.js +419 -79
- package/dist/adapters/yaml.cjs +419 -79
- package/dist/adapters/yaml.d.cts +1 -1
- package/dist/adapters/yaml.d.ts +1 -1
- package/dist/adapters/yaml.js +419 -79
- package/dist/{config-Dlq6rF3w.d.cts → config-6sApTEMM.d.cts} +22 -0
- package/dist/{config-Dlq6rF3w.d.ts → config-6sApTEMM.d.ts} +22 -0
- package/dist/index.cjs +432 -87
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +432 -87
- package/dist/zod.cjs +432 -87
- package/dist/zod.d.cts +1 -1
- package/dist/zod.d.ts +1 -1
- package/dist/zod.js +432 -87
- package/package.json +12 -2
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { C as Config } from '../config-6sApTEMM.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Read JSON5 (https://json5.org, spec 1.0.0) as HOCON config.
|
|
5
|
+
*
|
|
6
|
+
* Unlike the jsonc adapter — which strips comments and hands the rest to
|
|
7
|
+
* `JSON.parse` — JSON5 changes the token grammar itself (unquoted identifier
|
|
8
|
+
* keys, single-quoted strings with line continuations, hex integers, leading
|
|
9
|
+
* and trailing decimal points, an explicit plus sign), so this adapter is a
|
|
10
|
+
* hand-rolled scanner and recursive-descent parser. Zero dependencies, like
|
|
11
|
+
* every adapter in this package; it is a port of go.hocon's `adapters/json5`.
|
|
12
|
+
*
|
|
13
|
+
* The accepted grammar is JSON5 1.0.0 as defined by the reference
|
|
14
|
+
* implementation (the json5 npm package), the dialect owner this spec item
|
|
15
|
+
* tracks — the same ownership rule F3.2 applies to JSONC. That is why a `//`
|
|
16
|
+
* comment here ends at LS/PS as well as LF/CR, while the jsonc adapter's runs
|
|
17
|
+
* through them: each dialect's owner decides. Where the mapping spec is
|
|
18
|
+
* stricter than JSON5, the spec wins:
|
|
19
|
+
*
|
|
20
|
+
* - `Infinity` and `NaN` (signed or bare) are errors, not values (spec F0.6).
|
|
21
|
+
* - Integers — decimal or hex — must fit in int64 (spec F0.5); a number
|
|
22
|
+
* written with `.`, `e` or `E` is a float, all other decimal forms and
|
|
23
|
+
* every hex form are integers. An integer past 2^53 is carried as a
|
|
24
|
+
* `bigint` so its digits survive verbatim (`getString` returns them
|
|
25
|
+
* exactly); `getNumber` and `toObject` still apply the JS number model,
|
|
26
|
+
* as they do for HOCON's own literals.
|
|
27
|
+
* - An unpaired `\uXXXX` surrogate **escape** is an error, and a valid pair
|
|
28
|
+
* combines into the astral codepoint (spec F3.5). This deliberately
|
|
29
|
+
* differs from the jsonc adapter, which accepts one: there `JSON.parse` —
|
|
30
|
+
* the host language's own decoder — owns the escape, and refusing would be
|
|
31
|
+
* the spec overriding the platform (the S1.2.6 class). Here the scanner is
|
|
32
|
+
* ours, so the four implementations can and do agree. A lone surrogate
|
|
33
|
+
* *code unit* sitting raw in the source string is still accepted as data —
|
|
34
|
+
* a JavaScript string is UTF-16 and holds it natively; go.hocon's
|
|
35
|
+
* equivalent check rejects invalid UTF-8 bytes, a case that cannot arise
|
|
36
|
+
* in a JS string.
|
|
37
|
+
* - Duplicate keys follow HOCON semantics: objects merge, otherwise the
|
|
38
|
+
* later value wins (spec F0.7).
|
|
39
|
+
* - The document holds exactly one value; whitespace and comments may follow
|
|
40
|
+
* it, anything else is an error (the F3.2 strictness rule).
|
|
41
|
+
*
|
|
42
|
+
* See the F3.x items in the format-ingestion mapping spec:
|
|
43
|
+
* https://github.com/o3co/xx.hocon/blob/main/docs/format-ingestion-mapping.md
|
|
44
|
+
*/
|
|
45
|
+
declare function parseJson5(input: string, originDescription?: string): Config;
|
|
46
|
+
|
|
47
|
+
export { parseJson5 };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { C as Config } from '../config-6sApTEMM.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Read JSON5 (https://json5.org, spec 1.0.0) as HOCON config.
|
|
5
|
+
*
|
|
6
|
+
* Unlike the jsonc adapter — which strips comments and hands the rest to
|
|
7
|
+
* `JSON.parse` — JSON5 changes the token grammar itself (unquoted identifier
|
|
8
|
+
* keys, single-quoted strings with line continuations, hex integers, leading
|
|
9
|
+
* and trailing decimal points, an explicit plus sign), so this adapter is a
|
|
10
|
+
* hand-rolled scanner and recursive-descent parser. Zero dependencies, like
|
|
11
|
+
* every adapter in this package; it is a port of go.hocon's `adapters/json5`.
|
|
12
|
+
*
|
|
13
|
+
* The accepted grammar is JSON5 1.0.0 as defined by the reference
|
|
14
|
+
* implementation (the json5 npm package), the dialect owner this spec item
|
|
15
|
+
* tracks — the same ownership rule F3.2 applies to JSONC. That is why a `//`
|
|
16
|
+
* comment here ends at LS/PS as well as LF/CR, while the jsonc adapter's runs
|
|
17
|
+
* through them: each dialect's owner decides. Where the mapping spec is
|
|
18
|
+
* stricter than JSON5, the spec wins:
|
|
19
|
+
*
|
|
20
|
+
* - `Infinity` and `NaN` (signed or bare) are errors, not values (spec F0.6).
|
|
21
|
+
* - Integers — decimal or hex — must fit in int64 (spec F0.5); a number
|
|
22
|
+
* written with `.`, `e` or `E` is a float, all other decimal forms and
|
|
23
|
+
* every hex form are integers. An integer past 2^53 is carried as a
|
|
24
|
+
* `bigint` so its digits survive verbatim (`getString` returns them
|
|
25
|
+
* exactly); `getNumber` and `toObject` still apply the JS number model,
|
|
26
|
+
* as they do for HOCON's own literals.
|
|
27
|
+
* - An unpaired `\uXXXX` surrogate **escape** is an error, and a valid pair
|
|
28
|
+
* combines into the astral codepoint (spec F3.5). This deliberately
|
|
29
|
+
* differs from the jsonc adapter, which accepts one: there `JSON.parse` —
|
|
30
|
+
* the host language's own decoder — owns the escape, and refusing would be
|
|
31
|
+
* the spec overriding the platform (the S1.2.6 class). Here the scanner is
|
|
32
|
+
* ours, so the four implementations can and do agree. A lone surrogate
|
|
33
|
+
* *code unit* sitting raw in the source string is still accepted as data —
|
|
34
|
+
* a JavaScript string is UTF-16 and holds it natively; go.hocon's
|
|
35
|
+
* equivalent check rejects invalid UTF-8 bytes, a case that cannot arise
|
|
36
|
+
* in a JS string.
|
|
37
|
+
* - Duplicate keys follow HOCON semantics: objects merge, otherwise the
|
|
38
|
+
* later value wins (spec F0.7).
|
|
39
|
+
* - The document holds exactly one value; whitespace and comments may follow
|
|
40
|
+
* it, anything else is an error (the F3.2 strictness rule).
|
|
41
|
+
*
|
|
42
|
+
* See the F3.x items in the format-ingestion mapping spec:
|
|
43
|
+
* https://github.com/o3co/xx.hocon/blob/main/docs/format-ingestion-mapping.md
|
|
44
|
+
*/
|
|
45
|
+
declare function parseJson5(input: string, originDescription?: string): Config;
|
|
46
|
+
|
|
47
|
+
export { parseJson5 };
|