@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 CHANGED
@@ -80,6 +80,7 @@ HOCON は単なるシリアライズ形式ではなく、**プログラムに注
80
80
  - `+=` 追加演算子
81
81
  - `include "file.conf"` および `include file("file.conf")` ディレクティブ
82
82
  - トリプルクォート文字列(`"""..."""`)
83
+ - HOCON エミッタ(`renderHocon()`)— 解決済み `Config` を HOCON テキストとして出力。再パースすると同一の値ツリーになる(E18 ラウンドトリップ契約)
83
84
  - 同期・非同期 API(`parse` / `parseAsync` / `parseFile` / `parseFileAsync`)
84
85
  - ESM + CJS デュアルパッケージ(全エントリポイントを CI で両形式ロード検証)
85
86
  - [Zod](https://zod.dev/) スキーマバリデーション統合(オプション)
@@ -121,6 +122,7 @@ parseFileAsync(path: string, opts?: ParseOptions): Promise<Config>
121
122
  | `keys()` | `string[]` | — |
122
123
  | `withFallback(fallback)` | `Config` | — |
123
124
  | `toObject()` | `unknown` | — |
125
+ | `renderHocon()` | `string` | 未解決の場合 |
124
126
 
125
127
  ### Zod 統合
126
128
 
@@ -193,18 +195,17 @@ description = """
193
195
 
194
196
  ## 仕様準拠
195
197
 
196
- [Lightbend HOCON 仕様](https://github.com/lightbend/config/blob/main/HOCON.md) への準拠状況は [`docs/spec-compliance.md`](docs/spec-compliance.md) に項目単位で記載しています。以下の表は 2026-05-13 時点のスナップショットです — 最新値は [`xx.hocon/docs/compliance-matrix.md`](https://github.com/o3co/xx.hocon/blob/main/docs/compliance-matrix.md) を参照してください。
198
+ [Lightbend HOCON 仕様](https://github.com/lightbend/config/blob/main/HOCON.md) への準拠状況は [`docs/spec-compliance.md`](docs/spec-compliance.md) に項目単位で記載しており、以下の表はそこから計算されます — `tests/docs.test.ts` が再計算し、表がずれるとビルドが fail します。実装横断のロールアップは [`xx.hocon/docs/compliance-matrix.md`](https://github.com/o3co/xx.hocon/blob/main/docs/compliance-matrix.md) を参照してください。
197
199
 
198
200
  | 指標 | 状況 |
199
201
  | -------------------------------------- | ------------- |
200
- | 仕様全体(out-of-scope を含む) | **74.2%** |
201
- | In-scope のみ | **83.3%** |
202
+ | 仕様全体(out-of-scope を含む) | **90.0%** |
203
+ | In-scope のみ | **100.0%** |
202
204
  | Lightbend `test01`–`test13` テスト群 | 13/13 合格 |
203
205
 
204
- v0.1.0 で未対応の機能:
206
+ 未対応の機能:
205
207
  - `include url(...)`
206
208
  - `include classpath(...)`
207
- - `.properties` ファイルのパース
208
209
 
209
210
  ## パフォーマンス
210
211
 
@@ -350,6 +351,7 @@ const merged = cfg.withFallback(base).resolve()
350
351
  | `@o3co/ts.hocon/adapters/properties` | — | `java.util.Properties`。`include` と構文レイヤーを共有 |
351
352
  | `@o3co/ts.hocon/adapters/env` | — | プレフィックス付き名前空間の一括マウント。`.env` の読み込みも可能 |
352
353
  | `@o3co/ts.hocon/adapters/jsonc` | — | コメントと末尾カンマを許す JSON |
354
+ | `@o3co/ts.hocon/adapters/json5` | — | JSON5 1.0.0。手書き scanner で依存ゼロ |
353
355
  | `@o3co/ts.hocon/adapters/toml` | `smol-toml` | オプショナルなピア依存 |
354
356
  | `@o3co/ts.hocon/adapters/yaml` | `yaml` 2.9.x | オプショナルなピア依存。スカラー解決はそのライブラリの答えで、`version: '1.2'` を明示してドリフトを防止 |
355
357
 
package/README.md CHANGED
@@ -86,6 +86,7 @@ On top of that, HOCON combines the readability of YAML with the structure of JSO
86
86
  - `include "file.conf"` and `include file("file.conf")` directives
87
87
  - Triple-quoted strings (`"""..."""`)
88
88
  - Duration and byte size parsing (`getDuration()`, `getBytes()`)
89
+ - HOCON emitter (`renderHocon()`) — renders a resolved `Config` back to HOCON text; re-parsing yields the same value tree (E18 round-trip contract)
89
90
  - Sync and async API (`parse` / `parseAsync` / `parseFile` / `parseFileAsync`)
90
91
  - ESM + CJS dual package (every entrypoint smoke-tested in both formats on each CI run)
91
92
  - Optional [Zod](https://zod.dev/) integration for schema validation
@@ -134,6 +135,7 @@ parseFileAsync(path: string, opts?: ParseOptions): Promise<Config>
134
135
  | `resolveWith(source, opts?)` | `Config` | source unresolved, or unresolvable substitution |
135
136
  | `isResolved()` | `boolean` | — |
136
137
  | `toObject()` | `unknown` | — |
138
+ | `renderHocon()` | `string` | unresolved |
137
139
 
138
140
  ### Deferred resolution API (E12)
139
141
 
@@ -269,8 +271,8 @@ Conformance against the [Lightbend HOCON specification](https://github.com/light
269
271
 
270
272
  | Metric | Status |
271
273
  | ------------------------------------- | ------------- |
272
- | Spec total (incl. out-of-scope) | **89.3%** |
273
- | In-scope only | **99.2%** |
274
+ | Spec total (incl. out-of-scope) | **90.0%** |
275
+ | In-scope only | **100.0%** |
274
276
  | Lightbend `test01`–`test13` suite | 13/13 passing |
275
277
 
276
278
  **Extra-spec conventions (E-series) — implementation status:**
@@ -435,6 +437,7 @@ Deferring resolution matters: the plain `parse` resolves as it goes, so a
435
437
  | `@o3co/ts.hocon/adapters/properties` | — | `java.util.Properties`, sharing the `include` syntax layer |
436
438
  | `@o3co/ts.hocon/adapters/env` | — | Bulk-mounts a prefixed namespace; also reads `.env` |
437
439
  | `@o3co/ts.hocon/adapters/jsonc` | — | JSON with comments and trailing commas |
440
+ | `@o3co/ts.hocon/adapters/json5` | — | JSON5 1.0.0, hand-rolled scanner, zero dependencies |
438
441
  | `@o3co/ts.hocon/adapters/toml` | `smol-toml` | Optional peer dependency |
439
442
  | `@o3co/ts.hocon/adapters/yaml` | `yaml` 2.9.x | Optional peer dependency; scalar resolution is that library's answer, with `version: '1.2'` declared so it cannot drift |
440
443
 
@@ -458,11 +461,12 @@ cfg.getString('"foo.bar"') // "dotted" — one key whose name contains a dot
458
461
  cfg.getString('foo.bar') // "nested" — foo -> bar
459
462
  ```
460
463
 
461
- ### Numbers from JSONC and YAML
464
+ ### Numbers from JSONC, JSON5 and YAML
462
465
 
463
466
  Integers are ingested losslessly: an integer literal too wide for a JS `number`
464
467
  keeps its digits instead of being rounded, and one outside the int64 range is
465
- refused rather than silently mangled. What you get back depends on the getter:
468
+ refused rather than silently mangled (JSON5's hex integers included). What you
469
+ get back depends on the getter:
466
470
 
467
471
  ```ts
468
472
  const cfg = parseJsonc('{"id": 9007199254740993}')