@effected/toml 0.3.2 → 0.5.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.md CHANGED
@@ -8,7 +8,7 @@
8
8
  Zero-dependency TOML 1.1.0 parsing, editing and formatting expressed as Effect schemas and pure functions. Parse TOML into plain values or a byte-exact linear CST, compute comment-preserving edits, format, modify by path, walk a document as a `Stream`, and decode straight into a validated domain schema.
9
9
 
10
10
  > **Pre-release.** This package is part of the `@effected/*` kit, in pre-`1.0.0`
11
- > development against a single pinned Effect v4 beta. Packages graduate to
11
+ > development against a single pinned Effect v4 prerelease. Packages graduate to
12
12
  > `1.0.0` once Effect `4.0.0` ships. To hold your own `effect` versions at
13
13
  > exactly the ones the kit is built and tested against, install
14
14
  > [`@effected/pnpm-plugin-effect`](https://www.npmjs.com/package/@effected/pnpm-plugin-effect).
package/Toml.js CHANGED
@@ -4,7 +4,7 @@ import { parseExpressions } from "./internal/parser.js";
4
4
  import { buildValue } from "./internal/semantic.js";
5
5
  import { stringifyValue } from "./internal/stringifyValue.js";
6
6
  import { TomlDiagnostic } from "./TomlDiagnostic.js";
7
- import { Effect, Option, Result, Schema, SchemaIssue, SchemaTransformation } from "effect";
7
+ import { Effect, Result, Schema, SchemaIssue, SchemaTransformation } from "effect";
8
8
 
9
9
  //#region src/Toml.ts
10
10
  /**
@@ -29,7 +29,7 @@ var TomlStringifyOptions = class extends Schema.Class("TomlStringifyOptions")({
29
29
  *
30
30
  * @public
31
31
  */
32
- var TomlParseError = class extends Schema.TaggedErrorClass()("TomlParseError", { diagnostics: Schema.Array(TomlDiagnostic) }) {
32
+ var TomlParseError = class extends Schema.TaggedError()("TomlParseError", { diagnostics: Schema.Array(TomlDiagnostic) }) {
33
33
  get message() {
34
34
  const count = this.diagnostics.length;
35
35
  const first = this.diagnostics[0];
@@ -45,7 +45,7 @@ var TomlParseError = class extends Schema.TaggedErrorClass()("TomlParseError", {
45
45
  *
46
46
  * @public
47
47
  */
48
- var TomlStringifyError = class extends Schema.TaggedErrorClass()("TomlStringifyError", { diagnostic: TomlDiagnostic }) {
48
+ var TomlStringifyError = class extends Schema.TaggedError()("TomlStringifyError", { diagnostic: TomlDiagnostic }) {
49
49
  get message() {
50
50
  return `TOML stringify failed: ${this.diagnostic.code} ${this.diagnostic.message}`;
51
51
  }
@@ -228,8 +228,8 @@ var Toml = class Toml {
228
228
  */
229
229
  static fromString() {
230
230
  return Schema.String.pipe(Schema.decodeTo(Schema.Unknown, SchemaTransformation.transformOrFail({
231
- decode: (input) => Toml.parse(input).pipe(Effect.mapError((error) => new SchemaIssue.InvalidValue(Option.some(input), { message: error.message }))),
232
- encode: (value) => Effect.fromResult(Toml.stringifyResult(value)).pipe(Effect.mapError((error) => new SchemaIssue.InvalidValue(Option.some(value), { message: error.message })))
231
+ decode: (input) => Toml.parse(input).pipe(Effect.mapError((error) => new SchemaIssue.InvalidValue({ message: error.message }, input))),
232
+ encode: (value) => Effect.fromResult(Toml.stringifyResult(value)).pipe(Effect.mapError((error) => new SchemaIssue.InvalidValue({ message: error.message }, value)))
233
233
  })));
234
234
  }
235
235
  /**
package/TomlDocument.js CHANGED
@@ -5,7 +5,7 @@ import { parseExpressions } from "./internal/parser.js";
5
5
  import { analyze, buildValue } from "./internal/semantic.js";
6
6
  import { TomlDiagnostic } from "./TomlDiagnostic.js";
7
7
  import { TomlParseError } from "./Toml.js";
8
- import { Effect, Option, Schema, SchemaIssue, SchemaTransformation } from "effect";
8
+ import { Effect, Schema, SchemaIssue, SchemaTransformation } from "effect";
9
9
 
10
10
  //#region src/TomlDocument.ts
11
11
  /**
@@ -98,7 +98,7 @@ var TomlDocument = class TomlDocument extends Schema.Class("TomlDocument")({
98
98
  */
99
99
  static schema() {
100
100
  return Schema.String.pipe(Schema.decodeTo(Schema.instanceOf(TomlDocument), SchemaTransformation.transformOrFail({
101
- decode: (input) => TomlDocument.parse(input).pipe(Effect.mapError((error) => new SchemaIssue.InvalidValue(Option.some(input), { message: error.message }))),
101
+ decode: (input) => TomlDocument.parse(input).pipe(Effect.mapError((error) => new SchemaIssue.InvalidValue({ message: error.message }, input))),
102
102
  encode: (doc) => Effect.succeed(doc.stringify())
103
103
  })));
104
104
  }
package/TomlFormat.js CHANGED
@@ -28,7 +28,7 @@ var TomlFormattingOptions = class extends Schema.Class("TomlFormattingOptions")(
28
28
  *
29
29
  * @public
30
30
  */
31
- var TomlModificationError = class extends Schema.TaggedErrorClass()("TomlModificationError", { diagnostic: TomlDiagnostic }) {
31
+ var TomlModificationError = class extends Schema.TaggedError()("TomlModificationError", { diagnostic: TomlDiagnostic }) {
32
32
  get message() {
33
33
  return `TOML modification failed: ${this.diagnostic.code} ${this.diagnostic.message}`;
34
34
  }
@@ -55,8 +55,10 @@ const scanWsBack = (source, pos, start) => {
55
55
  const dominantNewline = (source) => {
56
56
  let lf = 0;
57
57
  let crlf = 0;
58
- for (let i = 0; i < source.length; i++) if (source.charCodeAt(i) === LF) if (i > 0 && source.charCodeAt(i - 1) === CR) crlf++;
59
- else lf++;
58
+ for (let i = 0; i < source.length; i++) if (source.charCodeAt(i) === LF) {
59
+ if (i > 0 && source.charCodeAt(i - 1) === CR) crlf++;
60
+ else lf++;
61
+ }
60
62
  return crlf > lf ? "\r\n" : "\n";
61
63
  };
62
64
  /** Multi-line string value spans — the bytes formatting must never touch. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effected/toml",
3
- "version": "0.3.2",
3
+ "version": "0.5.0",
4
4
  "private": false,
5
5
  "description": "TOML 1.1.0 parsing, editing and formatting as Effect schemas: typed diagnostics, a lossless CST and first-class date-time values.",
6
6
  "keywords": [
@@ -38,7 +38,7 @@
38
38
  "./package.json": "./package.json"
39
39
  },
40
40
  "peerDependencies": {
41
- "effect": "4.0.0-beta.101"
41
+ "effect": "4.0.0-rc.109"
42
42
  },
43
43
  "engines": {
44
44
  "node": ">=24.11.0"