@o3co/ts.hocon 1.9.0 → 1.11.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.
@@ -0,0 +1,45 @@
1
+ import { C as Config } from '../config-Dlq6rF3w.cjs';
2
+
3
+ /**
4
+ * Read JSON with comments and trailing commas — the dialect VS Code and
5
+ * TypeScript use for their config files — as HOCON config.
6
+ *
7
+ * Plain JSON needs no adapter at all: HOCON is a JSON superset, so `parse`
8
+ * already accepts a .json file. This exists for the two things HOCON does not
9
+ * accept, block comments and trailing commas. (HOCON has `//` and `#` comments
10
+ * of its own.)
11
+ *
12
+ * Comments and trailing commas are removed and `JSON.parse` does the rest, so
13
+ * the accepted grammar is otherwise exactly the platform's JSON. A comment is
14
+ * replaced by whitespace rather than deleted, so it separates the tokens around
15
+ * it and `{"a":1/*x*\/2}` is a syntax error rather than `{"a":12}` (F3.2).
16
+ *
17
+ * Integers are ingested losslessly (F0.5): a literal too wide for a JS `number`
18
+ * keeps its digits — `getString` returns them exactly — and one outside int64
19
+ * is refused instead of being rounded. `getNumber` and `toObject` still apply
20
+ * the JS number model, as they do for HOCON's own literals, so read large
21
+ * identifiers with `getString`.
22
+ *
23
+ * See docs/specs/format-ingestion-mapping.md items F3.x in the hocon scope.
24
+ */
25
+ declare function parseJsonc(input: string, originDescription?: string): Config;
26
+ /**
27
+ * Remove `//` line comments and block comments, leaving string literals alone.
28
+ *
29
+ * F3.2: a comment is replaced by *whitespace*, never the empty string — it must
30
+ * keep separating the tokens around it, so a `1`, a block comment and a `2` stay
31
+ * two tokens and fail the JSON decode instead of silently reading as `12`.
32
+ * Newlines inside a removed span are kept so JSON.parse still reports useful
33
+ * positions; a span with no newline becomes a single space.
34
+ *
35
+ * A `//` comment ends at **LF or CR** (F3.2), and at nothing else. Stopping only
36
+ * at LF let a CR-terminated comment eat the rest of the line, and the
37
+ * trailing-comma pass then tidied the remains into valid JSON — so
38
+ * `{"a":1,//c\r"b":2,\n"c":3}` decoded as `{"a":1,"c":3}`, losing a key with no
39
+ * error at all. Stopping at U+2028/U+2029 would be the mirror-image mistake:
40
+ * ending a comment the dialect's own parser is still inside, so the document
41
+ * would mean something different here than in VS Code. See {@link isLineBreak}.
42
+ */
43
+ declare function stripComments(src: string): string;
44
+
45
+ export { parseJsonc, stripComments };
@@ -0,0 +1,45 @@
1
+ import { C as Config } from '../config-Dlq6rF3w.js';
2
+
3
+ /**
4
+ * Read JSON with comments and trailing commas — the dialect VS Code and
5
+ * TypeScript use for their config files — as HOCON config.
6
+ *
7
+ * Plain JSON needs no adapter at all: HOCON is a JSON superset, so `parse`
8
+ * already accepts a .json file. This exists for the two things HOCON does not
9
+ * accept, block comments and trailing commas. (HOCON has `//` and `#` comments
10
+ * of its own.)
11
+ *
12
+ * Comments and trailing commas are removed and `JSON.parse` does the rest, so
13
+ * the accepted grammar is otherwise exactly the platform's JSON. A comment is
14
+ * replaced by whitespace rather than deleted, so it separates the tokens around
15
+ * it and `{"a":1/*x*\/2}` is a syntax error rather than `{"a":12}` (F3.2).
16
+ *
17
+ * Integers are ingested losslessly (F0.5): a literal too wide for a JS `number`
18
+ * keeps its digits — `getString` returns them exactly — and one outside int64
19
+ * is refused instead of being rounded. `getNumber` and `toObject` still apply
20
+ * the JS number model, as they do for HOCON's own literals, so read large
21
+ * identifiers with `getString`.
22
+ *
23
+ * See docs/specs/format-ingestion-mapping.md items F3.x in the hocon scope.
24
+ */
25
+ declare function parseJsonc(input: string, originDescription?: string): Config;
26
+ /**
27
+ * Remove `//` line comments and block comments, leaving string literals alone.
28
+ *
29
+ * F3.2: a comment is replaced by *whitespace*, never the empty string — it must
30
+ * keep separating the tokens around it, so a `1`, a block comment and a `2` stay
31
+ * two tokens and fail the JSON decode instead of silently reading as `12`.
32
+ * Newlines inside a removed span are kept so JSON.parse still reports useful
33
+ * positions; a span with no newline becomes a single space.
34
+ *
35
+ * A `//` comment ends at **LF or CR** (F3.2), and at nothing else. Stopping only
36
+ * at LF let a CR-terminated comment eat the rest of the line, and the
37
+ * trailing-comma pass then tidied the remains into valid JSON — so
38
+ * `{"a":1,//c\r"b":2,\n"c":3}` decoded as `{"a":1,"c":3}`, losing a key with no
39
+ * error at all. Stopping at U+2028/U+2029 would be the mirror-image mistake:
40
+ * ending a comment the dialect's own parser is still inside, so the document
41
+ * would mean something different here than in VS Code. See {@link isLineBreak}.
42
+ */
43
+ declare function stripComments(src: string): string;
44
+
45
+ export { parseJsonc, stripComments };