73 Commits

Author SHA1 Message Date
f23e54b96c Update dependency @effect/language-service to ^0.53.0
All checks were successful
Lint / lint (push) Successful in 43s
Test build / test-build (pull_request) Successful in 17s
2025-11-01 12:01:17 +00:00
Julien Valverdé
56f05e93e7 Fix
All checks were successful
Lint / lint (push) Successful in 11s
2025-10-31 15:52:12 +01:00
Julien Valverdé
9beddc0877 Example fix
All checks were successful
Lint / lint (push) Successful in 12s
2025-10-31 15:50:01 +01:00
Julien Valverdé
8a354b5519 Fix
All checks were successful
Lint / lint (push) Successful in 12s
2025-10-31 15:40:47 +01:00
Julien Valverdé
5de4773974 Cleanup
Some checks failed
Lint / lint (push) Failing after 11s
2025-10-31 15:38:08 +01:00
Julien Valverdé
1090a685d2 Fix
Some checks failed
Lint / lint (push) Failing after 11s
2025-10-31 15:33:59 +01:00
Julien Valverdé
f537490f40 Add forkEffect
All checks were successful
Lint / lint (push) Successful in 13s
2025-10-31 00:52:59 +01:00
Julien Valverdé
2348ea9bc1 Fix
All checks were successful
Lint / lint (push) Successful in 13s
2025-10-30 20:56:31 +01:00
Julien Valverdé
0619af6524 Fix
All checks were successful
Lint / lint (push) Successful in 12s
2025-10-30 14:36:47 +01:00
Julien Valverdé
993e97676f Fix
All checks were successful
Lint / lint (push) Successful in 12s
2025-10-30 12:23:19 +01:00
Julien Valverdé
95f53b8a00 Add useOnMountResult
Some checks failed
Lint / lint (push) Failing after 41s
2025-10-30 11:58:06 +01:00
Julien Valverdé
8b948b2251 useOnChangeResult
Some checks failed
Lint / lint (push) Failing after 11s
2025-10-29 16:52:56 +01:00
Julien Valverdé
626a9292d5 Fix forkEffectScoped
Some checks failed
Lint / lint (push) Failing after 1m40s
2025-10-29 15:07:49 +01:00
cb40ecff06 Update dependency node to v24 (#19)
Some checks failed
Lint / lint (push) Failing after 11s
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [node](https://github.com/actions/node-versions) | uses-with | major | `22` -> `24` |

---

### Release Notes

<details>
<summary>actions/node-versions (node)</summary>

### [`v24.11.0`](https://github.com/actions/node-versions/releases/tag/24.11.0-18894910158): 24.11.0

[Compare Source](https://github.com/actions/node-versions/compare/24.10.0-18453495281...24.11.0-18894910158)

Node.js 24.11.0

### [`v24.10.0`](https://github.com/actions/node-versions/releases/tag/24.10.0-18453495281): 24.10.0

[Compare Source](https://github.com/actions/node-versions/compare/24.9.0-18024003193...24.10.0-18453495281)

Node.js 24.10.0

### [`v24.9.0`](https://github.com/actions/node-versions/releases/tag/24.9.0-18024003193): 24.9.0

[Compare Source](https://github.com/actions/node-versions/compare/24.8.0-17630522236...24.9.0-18024003193)

Node.js 24.9.0

### [`v24.8.0`](https://github.com/actions/node-versions/releases/tag/24.8.0-17630522236): 24.8.0

[Compare Source](https://github.com/actions/node-versions/compare/24.7.0-17283839804...24.8.0-17630522236)

Node.js 24.8.0

### [`v24.7.0`](https://github.com/actions/node-versions/releases/tag/24.7.0-17283839804): 24.7.0

[Compare Source](https://github.com/actions/node-versions/compare/24.6.0-16980723897...24.7.0-17283839804)

Node.js 24.7.0

### [`v24.6.0`](https://github.com/actions/node-versions/releases/tag/24.6.0-16980723897): 24.6.0

[Compare Source](https://github.com/actions/node-versions/compare/24.5.0-16666195981...24.6.0-16980723897)

Node.js 24.6.0

### [`v24.5.0`](https://github.com/actions/node-versions/releases/tag/24.5.0-16666195981): 24.5.0

[Compare Source](https://github.com/actions/node-versions/compare/24.4.1-16309768053...24.5.0-16666195981)

Node.js 24.5.0

### [`v24.4.1`](https://github.com/actions/node-versions/releases/tag/24.4.1-16309768053): 24.4.1

[Compare Source](https://github.com/actions/node-versions/compare/24.4.0-16210503505...24.4.1-16309768053)

Node.js 24.4.1

### [`v24.4.0`](https://github.com/actions/node-versions/releases/tag/24.4.0-16210503505): 24.4.0

[Compare Source](https://github.com/actions/node-versions/compare/24.3.0-15866716565...24.4.0-16210503505)

Node.js 24.4.0

### [`v24.3.0`](https://github.com/actions/node-versions/releases/tag/24.3.0-15866716565): 24.3.0

[Compare Source](https://github.com/actions/node-versions/compare/24.2.0-15549907769...24.3.0-15866716565)

Node.js 24.3.0

### [`v24.2.0`](https://github.com/actions/node-versions/releases/tag/24.2.0-15549907769): 24.2.0

[Compare Source](https://github.com/actions/node-versions/compare/24.1.0-15177436545...24.2.0-15549907769)

Node.js 24.2.0

### [`v24.1.0`](https://github.com/actions/node-versions/releases/tag/24.1.0-15177436545): 24.1.0

[Compare Source](https://github.com/actions/node-versions/compare/24.0.2-15035852679...24.1.0-15177436545)

Node.js 24.1.0

### [`v24.0.2`](https://github.com/actions/node-versions/releases/tag/24.0.2-15035852679): 24.0.2

[Compare Source](https://github.com/actions/node-versions/compare/24.0.1-14928016774...24.0.2-15035852679)

Node.js 24.0.2

### [`v24.0.1`](https://github.com/actions/node-versions/releases/tag/24.0.1-14928016774): 24.0.1

[Compare Source](https://github.com/actions/node-versions/compare/24.0.0-14863421234...24.0.1-14928016774)

Node.js 24.0.1

### [`v24.0.0`](https://github.com/actions/node-versions/releases/tag/24.0.0-14863421234): 24.0.0

[Compare Source](https://github.com/actions/node-versions/compare/22.21.1-18894912842...24.0.0-14863421234)

Node.js 24.0.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS4xNjMuMSIsInVwZGF0ZWRJblZlciI6IjQxLjE2NS4yIiwidGFyZ2V0QnJhbmNoIjoibmV4dCIsImxhYmVscyI6W119-->

Reviewed-on: #19
Co-authored-by: Renovate Bot <renovate-bot@valverde.cloud>
Co-committed-by: Renovate Bot <renovate-bot@valverde.cloud>
2025-10-29 14:34:14 +01:00
b9b9f37859 Update dependency @effect/language-service to ^0.49.0 (#20)
Some checks failed
Lint / lint (push) Failing after 11s
This PR contains the following updates:

| Package | Change | Age | Confidence |
|---|---|---|---|
| [@effect/language-service](https://github.com/Effect-TS/language-service) | [`^0.48.0` -> `^0.49.0`](https://renovatebot.com/diffs/npm/@effect%2flanguage-service/0.48.0/0.49.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@effect%2flanguage-service/0.49.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@effect%2flanguage-service/0.48.0/0.49.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>Effect-TS/language-service (@&#8203;effect/language-service)</summary>

### [`v0.49.0`](https://github.com/Effect-TS/language-service/blob/HEAD/CHANGELOG.md#0490)

[Compare Source](https://github.com/Effect-TS/language-service/compare/v0.48.0...v0.49.0)

##### Minor Changes

- [#&#8203;445](https://github.com/Effect-TS/language-service/pull/445) [`fe0e390`](fe0e390f02) Thanks [@&#8203;mattiamanzati](https://github.com/mattiamanzati)! - Use the Graph module for outline line graph and layer magic

##### Patch Changes

- [#&#8203;449](https://github.com/Effect-TS/language-service/pull/449) [`ff11b7d`](ff11b7da9b) Thanks [@&#8203;mattiamanzati](https://github.com/mattiamanzati)! - Update effect package version to [`97ff1dc`](https://github.com/Effect-TS/language-service/commit/97ff1dc). This version improves handling of special characters in layer graph mermaid diagrams by properly escaping HTML entities (parentheses, braces, quotes) to ensure correct rendering.

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS4xNjUuMiIsInVwZGF0ZWRJblZlciI6IjQxLjE2NS4yIiwidGFyZ2V0QnJhbmNoIjoibmV4dCIsImxhYmVscyI6W119-->

Reviewed-on: #20
Co-authored-by: Renovate Bot <renovate-bot@valverde.cloud>
Co-committed-by: Renovate Bot <renovate-bot@valverde.cloud>
2025-10-29 14:33:36 +01:00
Julien Valverdé
363c7d24f4 Fix forkEffectScoped
Some checks failed
Lint / lint (push) Failing after 11s
2025-10-29 14:32:45 +01:00
Julien Valverdé
d57654d872 Fix
All checks were successful
Lint / lint (push) Successful in 12s
2025-10-28 21:35:54 +01:00
Julien Valverdé
0b7d9383ec Fix
All checks were successful
Lint / lint (push) Successful in 13s
2025-10-28 21:16:11 +01:00
Julien Valverdé
c380fe9d08 Result work
All checks were successful
Lint / lint (push) Successful in 13s
2025-10-28 21:03:31 +01:00
Julien Valverdé
92722444cf Revert "Fix Result"
All checks were successful
Lint / lint (push) Successful in 13s
This reverts commit 882054b53d.
2025-10-28 11:28:36 +01:00
Julien Valverdé
882054b53d Fix Result
Some checks failed
Lint / lint (push) Failing after 40s
2025-10-28 01:07:10 +01:00
Julien Valverdé
1c0519cfaf Progress work
All checks were successful
Lint / lint (push) Successful in 12s
2025-10-27 21:21:23 +01:00
Julien Valverdé
f69125012e Cleanup
All checks were successful
Lint / lint (push) Successful in 13s
2025-10-27 18:42:05 +01:00
Julien Valverdé
8c8560b63c Fix
All checks were successful
Lint / lint (push) Successful in 12s
2025-10-27 18:36:41 +01:00
Julien Valverdé
86e8a7bd92 Refactor Form
All checks were successful
Lint / lint (push) Successful in 12s
2025-10-27 18:11:11 +01:00
Julien Valverdé
12878cd76b Result work
Some checks failed
Lint / lint (push) Failing after 14s
2025-10-27 16:47:58 +01:00
Julien Valverdé
308025d662 Add Result type
All checks were successful
Lint / lint (push) Successful in 44s
2025-10-27 11:33:15 +01:00
Julien Valverdé
2094f254b3 Fix
All checks were successful
Lint / lint (push) Successful in 12s
2025-10-25 09:43:04 +02:00
Julien Valverdé
8ce4a959a6 Merge branch 'master' into next
All checks were successful
Lint / lint (push) Successful in 12s
2025-10-24 01:37:32 +02:00
3708059da4 Update dependency @effect/language-service to ^0.48.0 (#17)
All checks were successful
Lint / lint (push) Successful in 11s
Test build / test-build (pull_request) Successful in 18s
This PR contains the following updates:

| Package | Change | Age | Confidence |
|---|---|---|---|
| [@effect/language-service](https://github.com/Effect-TS/language-service) | [`^0.46.0` -> `^0.48.0`](https://renovatebot.com/diffs/npm/@effect%2flanguage-service/0.46.0/0.48.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@effect%2flanguage-service/0.48.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@effect%2flanguage-service/0.46.0/0.48.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>Effect-TS/language-service (@&#8203;effect/language-service)</summary>

### [`v0.48.0`](https://github.com/Effect-TS/language-service/blob/HEAD/CHANGELOG.md#0480)

[Compare Source](https://github.com/Effect-TS/language-service/compare/v0.47.3...v0.48.0)

##### Minor Changes

- [#&#8203;441](https://github.com/Effect-TS/language-service/pull/441) [`ed1db9e`](ed1db9ef24) Thanks [@&#8203;mattiamanzati](https://github.com/mattiamanzati)! - Add `default-hashed` pattern for deterministic keys

  A new `default-hashed` pattern option is now available for service and error key patterns. This pattern works like the `default` pattern but hashes the resulting string, which is useful when you want deterministic keys but are concerned about potentially exposing service names in builds.

  Example configuration:

  ```json
  {
    "keyPatterns": [
      { "target": "service", "pattern": "default-hashed" },
      { "target": "error", "pattern": "default-hashed" }
    ]
  }
  ```

##### Patch Changes

- [#&#8203;442](https://github.com/Effect-TS/language-service/pull/442) [`44f4304`](44f43041ce) Thanks [@&#8203;mattiamanzati](https://github.com/mattiamanzati)! - Tone down try/catch message to ignore try/finally blocks

- [#&#8203;439](https://github.com/Effect-TS/language-service/pull/439) [`b73c231`](b73c231dc1) Thanks [@&#8203;mattiamanzati](https://github.com/mattiamanzati)! - Fix regression in type unification for union types and prevent infinite recursion in layerMagic refactor

  - Fixed `toggleTypeAnnotation` refactor to properly unify boolean types instead of expanding them to `true | false`
  - Fixed infinite recursion issue in `layerMagic` refactor's `adjustedNode` function when processing variable and property declarations

### [`v0.47.3`](https://github.com/Effect-TS/language-service/blob/HEAD/CHANGELOG.md#0473)

[Compare Source](https://github.com/Effect-TS/language-service/compare/v0.47.2...v0.47.3)

##### Patch Changes

- [#&#8203;437](https://github.com/Effect-TS/language-service/pull/437) [`e583192`](e583192cf7) Thanks [@&#8203;mattiamanzati](https://github.com/mattiamanzati)! - In toggle return type refactors, skip type parameters if they are the same as the function default in some cases.

### [`v0.47.2`](https://github.com/Effect-TS/language-service/blob/HEAD/CHANGELOG.md#0472)

[Compare Source](https://github.com/Effect-TS/language-service/compare/v0.47.1...v0.47.2)

##### Patch Changes

- [#&#8203;433](https://github.com/Effect-TS/language-service/pull/433) [`f359cdb`](f359cdb106) Thanks [@&#8203;mattiamanzati](https://github.com/mattiamanzati)! - Improve memory by properly evicting older cached members

### [`v0.47.1`](https://github.com/Effect-TS/language-service/blob/HEAD/CHANGELOG.md#0471)

[Compare Source](https://github.com/Effect-TS/language-service/compare/v0.47.0...v0.47.1)

##### Patch Changes

- [#&#8203;431](https://github.com/Effect-TS/language-service/pull/431) [`acbbc55`](acbbc55f30) Thanks [@&#8203;mattiamanzati](https://github.com/mattiamanzati)! - Fix nested project references relative paths in CLI diagnostics command

  The CLI diagnostics command now correctly resolves paths for nested project references by:

  - Using absolute paths when parsing tsconfig files
  - Correctly resolving the base directory for relative paths in project references
  - Processing files in batches to improve memory usage and prevent leaks

### [`v0.47.0`](https://github.com/Effect-TS/language-service/blob/HEAD/CHANGELOG.md#0470)

[Compare Source](https://github.com/Effect-TS/language-service/compare/v0.46.0...v0.47.0)

##### Minor Changes

- [#&#8203;429](https://github.com/Effect-TS/language-service/pull/429) [`351d7fb`](351d7fbec1) Thanks [@&#8203;mattiamanzati](https://github.com/mattiamanzati)! - Add new `diagnostics` CLI command to check Effect-specific diagnostics for files or projects

  The new `effect-language-service diagnostics` command provides a way to get Effect-specific diagnostics through the CLI without patching your TypeScript installation. It supports:

  - `--file` option to get diagnostics for a specific file
  - `--project` option with a tsconfig file to check an entire project

  The command outputs diagnostics in the same format as the TypeScript compiler, showing errors, warnings, and messages with their locations and descriptions.

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS4xNTcuMCIsInVwZGF0ZWRJblZlciI6IjQxLjE1OC4wIiwidGFyZ2V0QnJhbmNoIjoibmV4dCIsImxhYmVscyI6W119-->

Reviewed-on: #17
Co-authored-by: Renovate Bot <renovate-bot@valverde.cloud>
Co-committed-by: Renovate Bot <renovate-bot@valverde.cloud>
2025-10-24 01:28:12 +02:00
Julien Valverdé
cd8b5e6364 Version bump
All checks were successful
Lint / lint (push) Successful in 12s
2025-10-24 01:27:36 +02:00
Julien Valverdé
a48b623822 Fix
All checks were successful
Lint / lint (push) Successful in 12s
2025-10-24 01:26:01 +02:00
Julien Valverdé
499e1e174b Fix
All checks were successful
Lint / lint (push) Successful in 12s
2025-10-24 00:48:21 +02:00
Julien Valverdé
6b9c177ae7 Fix
All checks were successful
Lint / lint (push) Successful in 11s
2025-10-24 00:00:14 +02:00
Julien Valverdé
b73b053cc8 Fix
All checks were successful
Lint / lint (push) Successful in 12s
2025-10-23 23:50:30 +02:00
Julien Valverdé
bbad86bf97 Cleanup
All checks were successful
Lint / lint (push) Successful in 12s
2025-10-23 23:36:30 +02:00
Julien Valverdé
6ae311cdfd Refactor
All checks were successful
Lint / lint (push) Successful in 12s
2025-10-23 23:01:27 +02:00
Julien Valverdé
03eca8a1af Fix useOnChange
All checks were successful
Lint / lint (push) Successful in 12s
2025-10-23 16:36:53 +02:00
Julien Valverdé
c03d697361 Fix
All checks were successful
Lint / lint (push) Successful in 13s
2025-10-23 16:20:30 +02:00
Julien Valverdé
3847686d54 Add Stream module
All checks were successful
Lint / lint (push) Successful in 12s
2025-10-23 16:08:25 +02:00
Julien Valverdé
9801444c0a Fix Component
All checks were successful
Lint / lint (push) Successful in 12s
2025-10-23 15:42:19 +02:00
Julien Valverdé
68d8c9fa84 Refactor Component
All checks were successful
Lint / lint (push) Successful in 12s
2025-10-23 15:19:47 +02:00
Julien Valverdé
cba42bfa52 Fix useScope
All checks were successful
Lint / lint (push) Successful in 17s
2025-10-23 14:31:51 +02:00
Julien Valverdé
874da0b963 Refactor component
All checks were successful
Lint / lint (push) Successful in 12s
2025-10-23 12:11:35 +02:00
Julien Valverdé
bb0579408d Fix
All checks were successful
Lint / lint (push) Successful in 12s
2025-10-23 10:49:00 +02:00
Julien Valverdé
b39c5946f9 Fix
All checks were successful
Lint / lint (push) Successful in 12s
2025-10-23 10:42:27 +02:00
Julien Valverdé
aaf494e27a Refactor component creation
All checks were successful
Lint / lint (push) Successful in 12s
2025-10-23 10:36:33 +02:00
Julien Valverdé
dbc5694b6d Fix
All checks were successful
Lint / lint (push) Successful in 13s
2025-10-23 09:48:37 +02:00
Julien Valverdé
86582de0c5 Fix
All checks were successful
Lint / lint (push) Successful in 12s
2025-10-23 02:30:32 +02:00
Julien Valverdé
72495bb9b5 Refactor useScope
All checks were successful
Lint / lint (push) Successful in 41s
2025-10-23 02:23:48 +02:00
Julien Valverdé
312c103e71 Fix
All checks were successful
Lint / lint (push) Successful in 13s
2025-10-22 13:29:35 +02:00
Julien Valverdé
a252cfec27 Fix
All checks were successful
Lint / lint (push) Successful in 19s
2025-10-22 13:07:59 +02:00
Julien Valverdé
4a5f4c329d Fix
All checks were successful
Lint / lint (push) Successful in 13s
2025-10-22 12:59:33 +02:00
Julien Valverdé
6f96608f64 Refactor
All checks were successful
Lint / lint (push) Successful in 15s
2025-10-22 11:58:48 +02:00
0bc29b2cb9 Update dependency @effect/language-service to ^0.46.0 (#16)
Some checks failed
Lint / lint (push) Failing after 10s
This PR contains the following updates:

| Package | Change | Age | Confidence |
|---|---|---|---|
| [@effect/language-service](https://github.com/Effect-TS/language-service) | [`^0.45.0` -> `^0.46.0`](https://renovatebot.com/diffs/npm/@effect%2flanguage-service/0.45.1/0.46.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@effect%2flanguage-service/0.46.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@effect%2flanguage-service/0.45.1/0.46.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>Effect-TS/language-service (@&#8203;effect/language-service)</summary>

### [`v0.46.0`](https://github.com/Effect-TS/language-service/blob/HEAD/CHANGELOG.md#0460)

[Compare Source](https://github.com/Effect-TS/language-service/compare/v0.45.1...v0.46.0)

##### Minor Changes

- [#&#8203;424](https://github.com/Effect-TS/language-service/pull/424) [`4bbfdb0`](4bbfdb0a48) Thanks [@&#8203;mattiamanzati](https://github.com/mattiamanzati)! - Add support to mark a service as "leakable" via JSDoc tag. Services marked with `@effect-leakable-service` will be excluded from the leaking requirements diagnostic, allowing requirements that are expected to be provided per method invocation (e.g. HttpServerRequest).

  Example:

  ```ts
  /**
   * @&#8203;effect-leakable-service
   */
  export class FileSystem extends Context.Tag("FileSystem")<
    FileSystem,
    {
      writeFile: (content: string) => Effect.Effect<void>;
    }
  >() {}
  ```

- [#&#8203;428](https://github.com/Effect-TS/language-service/pull/428) [`ebaa8e8`](ebaa8e85d1) Thanks [@&#8203;mattiamanzati](https://github.com/mattiamanzati)! - Add diagnostic to warn when `@effect-diagnostics-next-line` comments have no effect. This helps identify unused suppression comments that don't actually suppress any diagnostics, improving code cleanliness.

  The new `missingDiagnosticNextLine` option controls the severity of this diagnostic (default: "warning"). Set to "off" to disable.

  Example:

  ```ts
  // This comment will trigger a warning because it doesn't suppress any diagnostic
  // @&#8203;effect-diagnostics-next-line effect/floatingEffect:off
  const x = 1;

  // This comment is correctly suppressing a diagnostic
  // @&#8203;effect-diagnostics-next-line effect/floatingEffect:off
  Effect.succeed(1);
  ```

##### Patch Changes

- [#&#8203;426](https://github.com/Effect-TS/language-service/pull/426) [`22717bd`](22717bda12) Thanks [@&#8203;mattiamanzati](https://github.com/mattiamanzati)! - Improve Layer Magic refactor with enhanced dependency sorting and cycle detection

  The Layer Magic refactor now includes:

  - Better handling of complex layer composition scenarios
  - Support for detecting missing layer implementations with helpful error messages

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS4xNTYuMSIsInVwZGF0ZWRJblZlciI6IjQxLjE1Ni4xIiwidGFyZ2V0QnJhbmNoIjoibmV4dCIsImxhYmVscyI6W119-->

Reviewed-on: #16
Co-authored-by: Renovate Bot <renovate-bot@valverde.cloud>
Co-committed-by: Renovate Bot <renovate-bot@valverde.cloud>
2025-10-22 09:00:28 +02:00
Julien Valverdé
8642619a6a Form work
Some checks failed
Lint / lint (push) Failing after 9s
2025-10-21 14:49:53 +02:00
Julien Valverdé
e8b8df9449 Form work
Some checks failed
Lint / lint (push) Failing after 11s
2025-10-21 14:01:19 +02:00
Julien Valverdé
3695128923 Refactor Hooks
All checks were successful
Lint / lint (push) Successful in 41s
2025-10-21 06:16:54 +02:00
Julien Valverdé
1f14e8be6b Add useOnChange
All checks were successful
Lint / lint (push) Successful in 12s
2025-10-20 21:24:27 +02:00
Julien Valverdé
adc8835304 Add useOnMount
All checks were successful
Lint / lint (push) Successful in 12s
2025-10-20 07:09:49 +02:00
Julien Valverdé
8b06c56ec0 Merge branch 'master' into next
All checks were successful
Lint / lint (push) Successful in 12s
2025-10-20 06:37:12 +02:00
Julien Valverdé
003d2f19a2 Version bump
All checks were successful
Lint / lint (push) Successful in 12s
Test build / test-build (pull_request) Successful in 18s
2025-10-20 06:33:06 +02:00
Julien Valverdé
15f6d695f8 Fix
All checks were successful
Lint / lint (push) Successful in 11s
2025-10-20 05:57:00 +02:00
Julien Valverdé
64583601dc Fix
All checks were successful
Lint / lint (push) Successful in 12s
2025-10-20 05:55:58 +02:00
Julien Valverdé
cf4ba5805f Refactor Form
All checks were successful
Lint / lint (push) Successful in 12s
2025-10-20 05:36:45 +02:00
Julien Valverdé
90db94e905 Refactor Subscribable
All checks were successful
Lint / lint (push) Successful in 40s
2025-10-20 04:35:11 +02:00
Julien Valverdé
336ea67ea2 Add Subscribable.flatMapSubscriptionRef
All checks were successful
Lint / lint (push) Successful in 12s
2025-10-19 07:46:36 +02:00
Julien Valverdé
1af839f036 Fix example
All checks were successful
Lint / lint (push) Successful in 12s
2025-10-19 07:16:39 +02:00
Julien Valverdé
6bdf2a4d87 submit -> submitFn
All checks were successful
Lint / lint (push) Successful in 41s
2025-10-19 02:51:43 +02:00
8d55a67e75 Update dependency @effect/language-service to ^0.45.0 (#14)
All checks were successful
Lint / lint (push) Successful in 12s
This PR contains the following updates:

| Package | Change | Age | Confidence |
|---|---|---|---|
| [@effect/language-service](https://github.com/Effect-TS/language-service) | [`^0.44.0` -> `^0.45.0`](https://renovatebot.com/diffs/npm/@effect%2flanguage-service/0.44.1/0.45.1) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@effect%2flanguage-service/0.45.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@effect%2flanguage-service/0.44.1/0.45.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>Effect-TS/language-service (@&#8203;effect/language-service)</summary>

### [`v0.45.1`](https://github.com/Effect-TS/language-service/blob/HEAD/CHANGELOG.md#0451)

[Compare Source](https://github.com/Effect-TS/language-service/compare/v0.45.0...v0.45.1)

##### Patch Changes

- [#&#8203;423](https://github.com/Effect-TS/language-service/pull/423) [`70d8734`](70d8734558) Thanks [@&#8203;mattiamanzati](https://github.com/mattiamanzati)! - Add code fix to rewrite Schema class constructor overrides as static 'new' methods

  When detecting constructor overrides in Schema classes, the diagnostic now provides a new code fix option that automatically rewrites the constructor as a static 'new' method. This preserves the custom initialization logic while maintaining Schema's decoding behavior.

  Example:

  ```typescript
  // Before (with constructor override)
  class MyClass extends Schema.Class<MyClass>("MyClass")({ a: Schema.Number }) {
    b: number;
    constructor() {
      super({ a: 42 });
      this.b = 56;
    }
  }

  // After (using static 'new' method)
  class MyClass extends Schema.Class<MyClass>("MyClass")({ a: Schema.Number }) {
    b: number;
    public static new() {
      const _this = new this({ a: 42 });
      _this.b = 56;
      return _this;
    }
  }
  ```

- [#&#8203;421](https://github.com/Effect-TS/language-service/pull/421) [`8c455ed`](8c455ed7a4) Thanks [@&#8203;mattiamanzati](https://github.com/mattiamanzati)! - Update dependencies to their latest versions including Effect 3.18.4, TypeScript 5.9.3, and various ESLint and build tooling packages

### [`v0.45.0`](https://github.com/Effect-TS/language-service/blob/HEAD/CHANGELOG.md#0450)

[Compare Source](https://github.com/Effect-TS/language-service/compare/v0.44.1...v0.45.0)

##### Minor Changes

- [#&#8203;419](https://github.com/Effect-TS/language-service/pull/419) [`7cd7216`](7cd7216abc) Thanks [@&#8203;mattiamanzati](https://github.com/mattiamanzati)! - Add support for custom APIs in deterministicKeys diagnostic using the `@effect-identifier` JSDoc tag.

  You can now enforce deterministic keys in custom APIs that follow an `extends MyApi("identifier")` pattern by:

  - Adding `extendedKeyDetection: true` to plugin options to enable detection
  - Marking the identifier parameter with `/** @&#8203;effect-identifier */` JSDoc tag

  Example:

  ```ts
  export function Repository(/** @&#8203;effect-identifier */ identifier: string) {
    return Context.Tag("Repository/" + identifier);
  }

  export class UserRepo extends Repository("user-repo")<
    UserRepo,
    {
      /** ... */
    }
  >() {}
  ```

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS4xNTAuMCIsInVwZGF0ZWRJblZlciI6IjQxLjE1MC4wIiwidGFyZ2V0QnJhbmNoIjoibmV4dCIsImxhYmVscyI6W119-->

Reviewed-on: #14
Co-authored-by: Renovate Bot <renovate-bot@valverde.cloud>
Co-committed-by: Renovate Bot <renovate-bot@valverde.cloud>
2025-10-16 21:34:20 +02:00
Julien Valverdé
a1ec5c4781 Handle ParseError on form submit
All checks were successful
Lint / lint (push) Successful in 41s
2025-10-16 02:00:10 +02:00
756b652861 Update actions/setup-node action to v6 (#13)
All checks were successful
Lint / lint (push) Successful in 13s
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [actions/setup-node](https://github.com/actions/setup-node) | action | major | `v5` -> `v6` |

---

### Release Notes

<details>
<summary>actions/setup-node (actions/setup-node)</summary>

### [`v6`](https://github.com/actions/setup-node/compare/v5...v6)

[Compare Source](https://github.com/actions/setup-node/compare/v5...v6)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS4xNDguMyIsInVwZGF0ZWRJblZlciI6IjQxLjE0OC4zIiwidGFyZ2V0QnJhbmNoIjoibmV4dCIsImxhYmVscyI6W119-->

Reviewed-on: #13
Co-authored-by: Renovate Bot <renovate-bot@valverde.cloud>
Co-committed-by: Renovate Bot <renovate-bot@valverde.cloud>
2025-10-14 16:50:05 +02:00
59f9358b9a Update dependency @effect/language-service to ^0.44.0 (#12)
All checks were successful
Lint / lint (push) Successful in 12s
This PR contains the following updates:

| Package | Change | Age | Confidence |
|---|---|---|---|
| [@effect/language-service](https://github.com/Effect-TS/language-service) | [`^0.42.0` -> `^0.44.0`](https://renovatebot.com/diffs/npm/@effect%2flanguage-service/0.42.0/0.44.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@effect%2flanguage-service/0.44.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@effect%2flanguage-service/0.42.0/0.44.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>Effect-TS/language-service (@&#8203;effect/language-service)</summary>

### [`v0.44.0`](https://github.com/Effect-TS/language-service/blob/HEAD/CHANGELOG.md#0440)

[Compare Source](https://github.com/Effect-TS/language-service/compare/v0.43.2...v0.44.0)

##### Minor Changes

- [#&#8203;415](https://github.com/Effect-TS/language-service/pull/415) [`42c66a1`](42c66a1265) Thanks [@&#8203;mattiamanzati](https://github.com/mattiamanzati)! - Add `diagnosticsName` option to include rule names in diagnostic messages. When enabled (default: true), diagnostic messages will display the rule name at the end, e.g., "Effect must be yielded or assigned to a variable. effect(floatingEffect)"

### [`v0.43.2`](https://github.com/Effect-TS/language-service/blob/HEAD/CHANGELOG.md#0432)

[Compare Source](https://github.com/Effect-TS/language-service/compare/v0.43.1...v0.43.2)

##### Patch Changes

- [#&#8203;410](https://github.com/Effect-TS/language-service/pull/410) [`0b40c04`](0b40c04625) Thanks [@&#8203;mattiamanzati](https://github.com/mattiamanzati)! - Defer typescript loading in CLI

### [`v0.43.1`](https://github.com/Effect-TS/language-service/blob/HEAD/CHANGELOG.md#0431)

[Compare Source](https://github.com/Effect-TS/language-service/compare/v0.43.0...v0.43.1)

##### Patch Changes

- [#&#8203;408](https://github.com/Effect-TS/language-service/pull/408) [`9ccd800`](9ccd8007b3) Thanks [@&#8203;mattiamanzati](https://github.com/mattiamanzati)! - Fix handling of leading/trailing slashes

### [`v0.43.0`](https://github.com/Effect-TS/language-service/blob/HEAD/CHANGELOG.md#0430)

[Compare Source](https://github.com/Effect-TS/language-service/compare/v0.42.0...v0.43.0)

##### Minor Changes

- [#&#8203;407](https://github.com/Effect-TS/language-service/pull/407) [`6590590`](6590590c0d) Thanks [@&#8203;mattiamanzati](https://github.com/mattiamanzati)! - Add deterministicKeys diagnostic to enforce consistent key patterns for Services and Errors

  This new diagnostic helps maintain consistent and unique keys for Effect Services and Tagged Errors by validating them against configurable patterns. The diagnostic is disabled by default and can be enabled via the `deterministicKeys` diagnosticSeverity setting.

  Two patterns are supported:

  - `default`: Constructs keys from package name + file path + class identifier (e.g., `@effect/package/FileName/ClassIdentifier`)
  - `package-identifier`: Uses package name + identifier for flat project structures

  Example configuration:

  ```jsonc
  {
    "diagnosticSeverity": {
      "deterministicKeys": "error"
    },
    "keyPatterns": [
      {
        "target": "service",
        "pattern": "default",
        "skipLeadingPath": ["src/"]
      }
    ]
  }
  ```

  The diagnostic also provides auto-fix code actions to update keys to match the configured patterns.

##### Patch Changes

- [#&#8203;405](https://github.com/Effect-TS/language-service/pull/405) [`f43b3ab`](f43b3ab32c) Thanks [@&#8203;mattiamanzati](https://github.com/mattiamanzati)! - Fix wrapWithEffectGen refactor not working on class heritage clauses

  The wrapWithEffectGen refactor now correctly skips expressions in heritage clauses (e.g., `extends` clauses in class declarations) to avoid wrapping them inappropriately.

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS4xMzguNCIsInVwZGF0ZWRJblZlciI6IjQxLjE0Ni4wIiwidGFyZ2V0QnJhbmNoIjoibmV4dCIsImxhYmVscyI6W119-->

Reviewed-on: #12
Co-authored-by: Renovate Bot <renovate-bot@valverde.cloud>
Co-committed-by: Renovate Bot <renovate-bot@valverde.cloud>
2025-10-13 01:00:50 +02:00
14 changed files with 399 additions and 75 deletions

View File

@@ -12,7 +12,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v6
with:
node-version: "22"
node-version: "24"
- name: Clone repo
uses: actions/checkout@v5
- name: Install dependencies

View File

@@ -5,7 +5,7 @@
"name": "@effect-fc/monorepo",
"devDependencies": {
"@biomejs/biome": "^2.2.5",
"@effect/language-service": "^0.48.0",
"@effect/language-service": "^0.53.0",
"@types/bun": "^1.2.23",
"npm-check-updates": "^19.0.0",
"npm-sort": "^0.0.4",
@@ -15,10 +15,7 @@
},
"packages/effect-fc": {
"name": "effect-fc",
"version": "0.1.5",
"dependencies": {
"@typed/async-data": "^0.13.1",
},
"version": "0.2.0",
"peerDependencies": {
"@types/react": "^19.0.0",
"effect": "^3.15.0",
@@ -32,9 +29,7 @@
"@effect/platform": "^0.92.1",
"@effect/platform-browser": "^0.72.0",
"@radix-ui/themes": "^3.2.1",
"@typed/async-data": "^0.13.1",
"@typed/id": "^0.17.2",
"@typed/lazy-ref": "^0.3.3",
"effect": "^3.18.1",
"effect-fc": "workspace:*",
"react-icons": "^5.5.0",
@@ -135,7 +130,7 @@
"@effect-fc/example": ["@effect-fc/example@workspace:packages/example"],
"@effect/language-service": ["@effect/language-service@0.48.0", "", { "bin": { "effect-language-service": "cli.js" } }, "sha512-u7DTPoGFFeDGSdomjY5C2nCGNWSisxpYSqHp3dlSG8kCZh5cay+166bveHRYvuJSJS5yomdkPTJwjwrqMmT7Og=="],
"@effect/language-service": ["@effect/language-service@0.53.1", "", { "bin": { "effect-language-service": "cli.js" } }, "sha512-EZQMDtDqwOrgB2z7ncOLgOJYK4E0nv6XYeEOqEH7s8W/bxT/SPaaAd+thTcMvGyiz6MqRMaUMQMUyLa4H5Jetg=="],
"@effect/platform": ["@effect/platform@0.92.1", "", { "dependencies": { "find-my-way-ts": "^0.1.6", "msgpackr": "^1.11.4", "multipasta": "^0.2.7" }, "peerDependencies": { "effect": "^3.18.1" } }, "sha512-XXWCBVwyhaKZISN7aM1fv/3fWDGyxr84ObywnUrL8aHvJLoIeskWFAP/fqw3c5MFCrJ3ZV97RWLbv6JiBQugdg=="],
@@ -423,12 +418,8 @@
"@tanstack/virtual-file-routes": ["@tanstack/virtual-file-routes@1.132.31", "", {}, "sha512-rxS8Cm2nIXroLqkm9pE/8X2lFNuvcTIIiFi5VH4PwzvKscAuaW3YRMN1WmaGDI2mVEn+GLaoY6Kc3jOczL5i4w=="],
"@typed/async-data": ["@typed/async-data@0.13.1", "", { "dependencies": { "@typed/lazy-ref": "^0.3.2", "effect": "^3.11.9" } }, "sha512-rKv3HQtoHeGJwZpEaTL0FAEKfqHcMr/x3GtgkE01p2tJiKjq1eVaPZYpweZEEF/zUutox7DQ14oH85x+ZpPA/Q=="],
"@typed/id": ["@typed/id@0.17.2", "", { "peerDependencies": { "effect": "^3.14.7" } }, "sha512-z/Z14/moeu9x45IpkGaRwuvb+CQ3s3UCc/agcpZibTz1yPb3RgSDXx4rOHIuyb6hG6oNzqe9yY4GbbMq3Hb5Ug=="],
"@typed/lazy-ref": ["@typed/lazy-ref@0.3.3", "", { "dependencies": { "effect": "^3.11.9" } }, "sha512-qJoy01/RFYwWBaWhQBzL3Ow20Q+CPybJ/KJnGNKzyDpRUFcEvd3YSQMqZjRdBZmG2wnEpjedAnlCx9ApvKJIlA=="],
"@types/babel__core": ["@types/babel__core@7.20.5", "", { "dependencies": { "@babel/parser": "^7.20.7", "@babel/types": "^7.20.7", "@types/babel__generator": "*", "@types/babel__template": "*", "@types/babel__traverse": "*" } }, "sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA=="],
"@types/babel__generator": ["@types/babel__generator@7.27.0", "", { "dependencies": { "@babel/types": "^7.0.0" } }, "sha512-ufFd2Xi92OAVPYsy+P4n7/U7e68fex0+Ee8gSG9KX7eo084CWiQ4sdxktvdl0bOPupXtVJPY19zk6EwWqUQ8lg=="],

View File

@@ -16,7 +16,7 @@
},
"devDependencies": {
"@biomejs/biome": "^2.2.5",
"@effect/language-service": "^0.48.0",
"@effect/language-service": "^0.53.0",
"@types/bun": "^1.2.23",
"npm-check-updates": "^19.0.0",
"npm-sort": "^0.0.4",

View File

@@ -41,8 +41,5 @@
"@types/react": "^19.0.0",
"effect": "^3.15.0",
"react": "^19.0.0"
},
"dependencies": {
"@typed/async-data": "^0.13.1"
}
}

View File

@@ -1,6 +1,6 @@
/** biome-ignore-all lint/complexity/noBannedTypes: {} is the default type for React props */
/** biome-ignore-all lint/complexity/useArrowFunction: necessary for class prototypes */
import { Context, type Duration, Effect, Effectable, Equivalence, ExecutionStrategy, Exit, Fiber, Function, HashMap, Layer, ManagedRuntime, Option, Predicate, Ref, Runtime, Scope, Tracer, type Types, type Utils } from "effect"
import { Context, type Duration, Effect, Effectable, Equivalence, ExecutionStrategy, Exit, Fiber, Function, HashMap, Layer, ManagedRuntime, Option, Predicate, Ref, Runtime, Scope, Tracer, type Utils } from "effect"
import * as React from "react"
import { Memoized } from "./index.js"
@@ -386,9 +386,9 @@ export const withOptions: {
export const withRuntime: {
<P extends {}, A extends React.ReactNode, E, R>(
context: React.Context<Runtime.Runtime<R>>,
): (self: Component<P, A, E, Types.NoInfer<R>>) => (props: P) => A
): (self: Component<P, A, E, Scope.Scope | NoInfer<R>>) => (props: P) => A
<P extends {}, A extends React.ReactNode, E, R>(
self: Component<P, A, E, Types.NoInfer<R>>,
self: Component<P, A, E, Scope.Scope | NoInfer<R>>,
context: React.Context<Runtime.Runtime<R>>,
): (props: P) => A
} = Function.dual(2, <P extends {}, A extends React.ReactNode, E, R>(
@@ -402,7 +402,7 @@ export const withRuntime: {
})
export class ScopeMap extends Effect.Service<ScopeMap>()("effect-fc/Component/ScopeMap", {
export class ScopeMap extends Effect.Service<ScopeMap>()("@effect-fc/Component/ScopeMap", {
effect: Effect.bind(Effect.Do, "ref", () => Ref.make(HashMap.empty<object, ScopeMap.Entry>()))
}) {}
@@ -613,25 +613,15 @@ export const useCallbackPromise: {
})
export namespace useContext {
export type Options = useScope.Options
export type Options = useOnChange.Options
}
export const useContext: {
<ROut, E, RIn>(
export const useContext = <ROut, E, RIn>(
layer: Layer.Layer<ROut, E, RIn>,
options?: useContext.Options,
): Effect.Effect<Context.Context<ROut>, E, RIn>
} = Effect.fnUntraced(function* <ROut, E, RIn>(
layer: Layer.Layer<ROut, E, RIn>,
options?: useContext.Options,
) {
const scope = yield* useScope([layer], options)
return yield* useOnChange(() => Effect.context<RIn>().pipe(
): Effect.Effect<Context.Context<ROut>, E, RIn> => useOnChange(() => Effect.context<RIn>().pipe(
Effect.map(context => ManagedRuntime.make(Layer.provide(layer, Layer.succeedContext(context)))),
Effect.tap(runtime => Effect.addFinalizer(() => runtime.disposeEffect)),
Effect.andThen(runtime => runtime.runtimeEffect),
Effect.andThen(runtime => runtime.context),
Effect.provideService(Scope.Scope, scope),
), [scope])
})
), [layer], options)

View File

@@ -1,9 +1,9 @@
import * as AsyncData from "@typed/async-data"
import { Array, Cause, Chunk, type Duration, Effect, Equal, Exit, Fiber, flow, identity, Option, ParseResult, Pipeable, Predicate, Ref, Schema, type Scope, Stream } from "effect"
import type { NoSuchElementException } from "effect/Cause"
import * as React from "react"
import * as Component from "./Component.js"
import * as PropertyPath from "./PropertyPath.js"
import * as Result from "./Result.js"
import * as Subscribable from "./Subscribable.js"
import * as SubscriptionRef from "./SubscriptionRef.js"
import * as SubscriptionSubRef from "./SubscriptionSubRef.js"
@@ -25,7 +25,7 @@ extends Pipeable.Pipeable {
readonly encodedValueRef: SubscriptionRef.SubscriptionRef<I>
readonly errorRef: SubscriptionRef.SubscriptionRef<Option.Option<ParseResult.ParseError>>
readonly validationFiberRef: SubscriptionRef.SubscriptionRef<Option.Option<Fiber.Fiber<void, never>>>
readonly submitStateRef: SubscriptionRef.SubscriptionRef<AsyncData.AsyncData<SA, SE>>
readonly submitResultRef: SubscriptionRef.SubscriptionRef<Result.Result<SA, SE>>
readonly canSubmitSubscribable: Subscribable.Subscribable<boolean>
}
@@ -44,7 +44,7 @@ extends Pipeable.Class() implements Form<A, I, R, SA, SE, SR> {
readonly encodedValueRef: SubscriptionRef.SubscriptionRef<I>,
readonly errorRef: SubscriptionRef.SubscriptionRef<Option.Option<ParseResult.ParseError>>,
readonly validationFiberRef: SubscriptionRef.SubscriptionRef<Option.Option<Fiber.Fiber<void, never>>>,
readonly submitStateRef: SubscriptionRef.SubscriptionRef<AsyncData.AsyncData<SA, SE>>,
readonly submitResultRef: SubscriptionRef.SubscriptionRef<Result.Result<SA, SE>>,
readonly canSubmitSubscribable: Subscribable.Subscribable<boolean>,
) {
@@ -77,7 +77,7 @@ export const make: {
const valueRef = yield* SubscriptionRef.make(Option.none<A>())
const errorRef = yield* SubscriptionRef.make(Option.none<ParseResult.ParseError>())
const validationFiberRef = yield* SubscriptionRef.make(Option.none<Fiber.Fiber<void, never>>())
const submitStateRef = yield* SubscriptionRef.make(AsyncData.noData<SA, SE>())
const submitResultRef = yield* SubscriptionRef.make<Result.Result<SA, SE>>(Result.initial())
return new FormImpl(
options.schema,
@@ -89,15 +89,15 @@ export const make: {
yield* SubscriptionRef.make(options.initialEncodedValue),
errorRef,
validationFiberRef,
submitStateRef,
submitResultRef,
Subscribable.map(
Subscribable.zipLatestAll(valueRef, errorRef, validationFiberRef, submitStateRef),
([value, error, validationFiber, submitState]) => (
Subscribable.zipLatestAll(valueRef, errorRef, validationFiberRef, submitResultRef),
([value, error, validationFiber, submitResult]) => (
Option.isSome(value) &&
Option.isNone(error) &&
Option.isNone(validationFiber) &&
!AsyncData.isLoading(submitState)
!(Result.isRunning(submitResult) || Result.isRefreshing(submitResult))
),
),
)
@@ -150,20 +150,18 @@ export const run = <A, I, R, SA, SE, SR>(
export const submit = <A, I, R, SA, SE, SR>(
self: Form<A, I, R, SA, SE, SR>
): Effect.Effect<Option.Option<AsyncData.AsyncData<SA, SE>>, NoSuchElementException, SR> => Effect.whenEffect(
): Effect.Effect<Option.Option<Result.Result<SA, SE>>, NoSuchElementException, Scope.Scope | SR> => Effect.whenEffect(
self.valueRef.pipe(
Effect.andThen(identity),
Effect.tap(Ref.set(self.submitStateRef, AsyncData.loading())),
Effect.andThen(flow(
self.onSubmit as (value: NoInfer<A>) => Effect.Effect<SA, SE | ParseResult.ParseError, SR>,
Effect.tapErrorTag("ParseError", e => Ref.set(self.errorRef, Option.some(e as ParseResult.ParseError))),
Effect.exit,
Effect.map(Exit.match({
onSuccess: a => AsyncData.success(a),
onFailure: e => AsyncData.failure(e as Cause.Cause<SE>),
})),
Effect.tap(v => Ref.set(self.submitStateRef, v)),
)),
Effect.andThen(value => Result.forkEffectDequeue(
self.onSubmit(value) as Effect.Effect<SA, SE, Result.forkEffectDequeue.InputContext<SR, never>>)
),
Effect.andThen(Stream.fromQueue),
Stream.unwrap,
Stream.runFoldEffect(
Result.initial() as Result.Result<SA, SE>,
(_, result) => Effect.as(Ref.set(self.submitResultRef, result), result),
),
),
self.canSubmitSubscribable.get,
@@ -198,11 +196,11 @@ export const field = <A, I, R, SA, SE, SR, const P extends PropertyPath.Paths<No
onNone: () => Effect.succeed([]),
})),
Subscribable.map(self.validationFiberRef, Option.isSome),
Subscribable.map(self.submitStateRef, AsyncData.isLoading)
Subscribable.map(self.submitResultRef, result => Result.isRunning(result) || Result.isRefreshing(result)),
)
export const FormFieldTypeId: unique symbol = Symbol.for("effect-fc/FormField")
export const FormFieldTypeId: unique symbol = Symbol.for("@effect-fc/Form/FormField")
export type FormFieldTypeId = typeof FormFieldTypeId
export interface FormField<in out A, in out I = A>
@@ -237,9 +235,9 @@ export const isFormField = (u: unknown): u is FormField<unknown, unknown> => Pre
export const useSubmit = <A, I, R, SA, SE, SR>(
self: Form<A, I, R, SA, SE, SR>
): Effect.Effect<
() => Promise<Option.Option<AsyncData.AsyncData<SA, SE>>>,
() => Promise<Option.Option<Result.Result<SA, SE>>>,
never,
SR
Scope.Scope | SR
> => Component.useCallbackPromise(() => submit(self), [self])
export const useField = <A, I, R, SA, SE, SR, const P extends PropertyPath.Paths<NoInfer<I>>>(

View File

@@ -0,0 +1,253 @@
import { Cause, Context, Data, Effect, Equal, Exit, Hash, Layer, Match, Option, Pipeable, Predicate, pipe, Queue, Ref, type Scope, type Subscribable, SubscriptionRef } from "effect"
export const ResultTypeId: unique symbol = Symbol.for("@effect-fc/Result/Result")
export type ResultTypeId = typeof ResultTypeId
export type Result<A, E = never, P = never> = (
| Initial
| Running<P>
| Success<A>
| (Success<A> & Refreshing<P>)
| Failure<A, E>
| (Failure<A, E> & Refreshing<P>)
)
export namespace Result {
export interface Prototype extends Pipeable.Pipeable, Equal.Equal {
readonly [ResultTypeId]: ResultTypeId
}
export type Success<R extends Result<any, any, any>> = [R] extends [Result<infer A, infer _E, infer _P>] ? A : never
export type Failure<R extends Result<any, any, any>> = [R] extends [Result<infer _A, infer E, infer _P>] ? E : never
export type Progress<R extends Result<any, any, any>> = [R] extends [Result<infer _A, infer _E, infer P>] ? P : never
}
export interface Initial extends Result.Prototype {
readonly _tag: "Initial"
}
export interface Running<P = never> extends Result.Prototype {
readonly _tag: "Running"
readonly progress: P
}
export interface Success<A> extends Result.Prototype {
readonly _tag: "Success"
readonly value: A
}
export interface Failure<A, E = never> extends Result.Prototype {
readonly _tag: "Failure"
readonly cause: Cause.Cause<E>
readonly previousSuccess: Option.Option<Success<A>>
}
export interface Refreshing<P = never> {
readonly refreshing: true
readonly progress: P
}
const ResultPrototype = Object.freeze({
...Pipeable.Prototype,
[ResultTypeId]: ResultTypeId,
[Equal.symbol](this: Result<any, any, any>, that: Result<any, any, any>): boolean {
if (this._tag !== that._tag)
return false
return Match.value(this).pipe(
Match.tag("Initial", () => true),
Match.tag("Running", self => Equal.equals(self.progress, (that as Running<any>).progress)),
Match.tag("Success", self =>
Equal.equals(self.value, (that as Success<any>).value) &&
(isRefreshing(self) ? self.refreshing : false) === (isRefreshing(that) ? that.refreshing : false) &&
Equal.equals(isRefreshing(self) ? self.progress : undefined, isRefreshing(that) ? that.progress : undefined)
),
Match.tag("Failure", self =>
Equal.equals(self.cause, (that as Failure<any, any>).cause) &&
(isRefreshing(self) ? self.refreshing : false) === (isRefreshing(that) ? that.refreshing : false) &&
Equal.equals(isRefreshing(self) ? self.progress : undefined, isRefreshing(that) ? that.progress : undefined)
),
Match.exhaustive,
)
},
[Hash.symbol](this: Result<any, any, any>): number {
const tagHash = Hash.string(this._tag)
return Match.value(this).pipe(
Match.tag("Initial", () => tagHash),
Match.tag("Running", self => Hash.combine(Hash.hash(self.progress))(tagHash)),
Match.tag("Success", self => pipe(tagHash,
Hash.combine(Hash.hash(self.value)),
Hash.combine(Hash.hash(isRefreshing(self) ? self.progress : undefined)),
)),
Match.tag("Failure", self => pipe(tagHash,
Hash.combine(Hash.hash(self.cause)),
Hash.combine(Hash.hash(isRefreshing(self) ? self.progress : undefined)),
)),
Match.exhaustive,
Hash.cached(this),
)
},
} as const satisfies Result.Prototype)
export const isResult = (u: unknown): u is Result<unknown, unknown, unknown> => Predicate.hasProperty(u, ResultTypeId)
export const isInitial = (u: unknown): u is Initial => isResult(u) && u._tag === "Initial"
export const isRunning = (u: unknown): u is Running<unknown> => isResult(u) && u._tag === "Running"
export const isSuccess = (u: unknown): u is Success<unknown> => isResult(u) && u._tag === "Success"
export const isFailure = (u: unknown): u is Failure<unknown, unknown> => isResult(u) && u._tag === "Failure"
export const isRefreshing = (u: unknown): u is Refreshing<unknown> => isResult(u) && Predicate.hasProperty(u, "refreshing") && u.refreshing
export const initial = (): Initial => Object.setPrototypeOf({ _tag: "Initial" }, ResultPrototype)
export const running = <P = never>(progress?: P): Running<P> => Object.setPrototypeOf({ _tag: "Running", progress }, ResultPrototype)
export const succeed = <A>(value: A): Success<A> => Object.setPrototypeOf({ _tag: "Success", value }, ResultPrototype)
export const fail = <E, A = never>(
cause: Cause.Cause<E>,
previousSuccess?: Success<A>,
): Failure<A, E> => Object.setPrototypeOf({
_tag: "Failure",
cause,
previousSuccess: Option.fromNullable(previousSuccess),
}, ResultPrototype)
export const refreshing = <R extends Success<any> | Failure<any, any>, P = never>(
result: R,
progress?: P,
): Omit<R, keyof Refreshing<Result.Progress<R>>> & Refreshing<P> => Object.setPrototypeOf(
Object.assign({}, result, { progress }),
Object.getPrototypeOf(result),
)
export const fromExit = <A, E>(
exit: Exit.Exit<A, E>
): Success<A> | Failure<A, E> => exit._tag === "Success"
? succeed(exit.value)
: fail(exit.cause)
export const toExit = <A, E, P>(
self: Result<A, E, P>
): Exit.Exit<A, E | Cause.NoSuchElementException> => {
switch (self._tag) {
case "Success":
return Exit.succeed(self.value)
case "Failure":
return Exit.failCause(self.cause)
default:
return Exit.fail(new Cause.NoSuchElementException())
}
}
export interface State<A, E = never, P = never> {
readonly get: Effect.Effect<Result<A, E, P>>
readonly set: (v: Result<A, E, P>) => Effect.Effect<void>
}
export const State = <A, E = never, P = never>(): Context.Tag<State<A, E, P>, State<A, E, P>> => Context.GenericTag("@effect-fc/Result/State")
export interface Progress<P = never> {
readonly update: <E, R>(
f: (previous: P) => Effect.Effect<P, E, R>
) => Effect.Effect<void, PreviousResultNotRunningNorRefreshing | E, R>
}
export class PreviousResultNotRunningNorRefreshing extends Data.TaggedError("@effect-fc/Result/PreviousResultNotRunningNorRefreshing")<{
readonly previous: Result<unknown, unknown, unknown>
}> {}
export const Progress = <P = never>(): Context.Tag<Progress<P>, Progress<P>> => Context.GenericTag("@effect-fc/Result/Progress")
export const makeProgressLayer = <A, E, P = never>(): Layer.Layer<
Progress<P>,
never,
State<A, E, P>
> => Layer.effect(Progress<P>(), Effect.gen(function*() {
const state = yield* State<A, E, P>()
return {
update: <E, R>(f: (previous: P) => Effect.Effect<P, E, R>) => Effect.Do.pipe(
Effect.bind("previous", () => Effect.andThen(state.get, previous =>
isRunning(previous) || isRefreshing(previous)
? Effect.succeed(previous)
: Effect.fail(new PreviousResultNotRunningNorRefreshing({ previous })),
)),
Effect.bind("progress", ({ previous }) => f(previous.progress)),
Effect.let("next", ({ previous, progress }) => Object.setPrototypeOf(
Object.assign({}, previous, { progress }),
Object.getPrototypeOf(previous),
)),
Effect.andThen(({ next }) => state.set(next)),
),
}
}))
export namespace forkEffect {
export type InputContext<R, P> = R extends Progress<infer X> ? [X] extends [P] ? R : never : R
export type OutputContext<R> = Scope.Scope | Exclude<R, Progress<any> | Progress<never>>
export interface Options<P> {
readonly initialProgress?: P
}
}
export const forkEffect = <A, E, R, P = never>(
effect: Effect.Effect<A, E, forkEffect.InputContext<R, NoInfer<P>>>,
options?: forkEffect.Options<P>,
): Effect.Effect<
Subscribable.Subscribable<Result<A, E, P>>,
never,
forkEffect.OutputContext<R>
> => Effect.tap(
SubscriptionRef.make<Result<A, E, P>>(initial()),
ref => Effect.forkScoped(State<A, E, P>().pipe(
Effect.andThen(state => state.set(running(options?.initialProgress)).pipe(
Effect.andThen(effect),
Effect.onExit(exit => state.set(fromExit(exit))),
)),
Effect.provide(Layer.empty.pipe(
Layer.provideMerge(makeProgressLayer<A, E, P>()),
Layer.provideMerge(Layer.succeed(State<A, E, P>(), {
get: ref,
set: v => Ref.set(ref, v),
})),
)),
)),
) as Effect.Effect<Subscribable.Subscribable<Result<A, E, P>>, never, Scope.Scope>
export namespace forkEffectDequeue {
export type InputContext<R, P> = forkEffect.InputContext<R, P>
export type OutputContext<R> = forkEffect.OutputContext<R>
export interface Options<P> extends forkEffect.Options<P> {}
}
export const forkEffectDequeue = <A, E, R, P = never>(
effect: Effect.Effect<A, E, forkEffectDequeue.InputContext<R, NoInfer<P>>>,
options?: forkEffectDequeue.Options<P>,
): Effect.Effect<
Queue.Dequeue<Result<A, E, P>>,
never,
forkEffectDequeue.OutputContext<R>
> => Effect.all([
Ref.make<Result<A, E, P>>(initial()),
Queue.unbounded<Result<A, E, P>>(),
]).pipe(
Effect.tap(([ref, queue]) => Effect.forkScoped(State<A, E, P>().pipe(
Effect.andThen(state => state.set(running(options?.initialProgress)).pipe(
Effect.andThen(effect),
Effect.onExit(exit => Effect.andThen(state.set(fromExit(exit)), Queue.shutdown(queue))),
)),
Effect.provide(Layer.empty.pipe(
Layer.provideMerge(makeProgressLayer<A, E, P>()),
Layer.provideMerge(Layer.succeed(State<A, E, P>(), {
get: ref,
set: v => Effect.andThen(Ref.set(ref, v), Queue.offer(queue, v))
})),
)),
))),
Effect.map(([, queue]) => queue),
) as Effect.Effect<Queue.Dequeue<Result<A, E, P>>, never, Scope.Scope>

View File

@@ -4,16 +4,26 @@ import * as Component from "./Component.js"
import * as SetStateAction from "./SetStateAction.js"
export namespace useSubscriptionRefState {
export interface Options<A> {
readonly equivalence?: Equivalence.Equivalence<A>
}
}
export const useSubscriptionRefState: {
<A>(
ref: SubscriptionRef.SubscriptionRef<A>
ref: SubscriptionRef.SubscriptionRef<A>,
options?: useSubscriptionRefState.Options<NoInfer<A>>,
): Effect.Effect<readonly [A, React.Dispatch<React.SetStateAction<A>>], never, Scope.Scope>
} = Effect.fnUntraced(function* <A>(ref: SubscriptionRef.SubscriptionRef<A>) {
} = Effect.fnUntraced(function* <A>(
ref: SubscriptionRef.SubscriptionRef<A>,
options?: useSubscriptionRefState.Options<NoInfer<A>>,
) {
const [reactStateValue, setReactStateValue] = React.useState(yield* Component.useOnMount(() => ref))
yield* Component.useReactEffect(() => Effect.forkScoped(
Stream.runForEach(
Stream.changesWith(ref.changes, Equivalence.strict()),
Stream.changesWith(ref.changes, options?.equivalence ?? Equivalence.strict()),
v => Effect.sync(() => setReactStateValue(v)),
)
), [ref])
@@ -28,14 +38,23 @@ export const useSubscriptionRefState: {
return [reactStateValue, setValue]
})
export namespace useSubscriptionRefFromState {
export interface Options<A> {
readonly equivalence?: Equivalence.Equivalence<A>
}
}
export const useSubscriptionRefFromState: {
<A>(state: readonly [A, React.Dispatch<React.SetStateAction<A>>]): Effect.Effect<SubscriptionRef.SubscriptionRef<A>, never, Scope.Scope>
} = Effect.fnUntraced(function*([value, setValue]) {
<A>(
state: readonly [A, React.Dispatch<React.SetStateAction<A>>],
options?: useSubscriptionRefFromState.Options<NoInfer<A>>,
): Effect.Effect<SubscriptionRef.SubscriptionRef<A>, never, Scope.Scope>
} = Effect.fnUntraced(function*([value, setValue], options) {
const ref = yield* Component.useOnChange(() => Effect.tap(
SubscriptionRef.make(value),
ref => Effect.forkScoped(
Stream.runForEach(
Stream.changesWith(ref.changes, Equivalence.strict()),
Stream.changesWith(ref.changes, options?.equivalence ?? Equivalence.strict()),
v => Effect.sync(() => setValue(v)),
)
),

View File

@@ -2,7 +2,7 @@ import { Chunk, Effect, Effectable, Option, Predicate, Readable, Ref, Stream, Su
import * as PropertyPath from "./PropertyPath.js"
export const SubscriptionSubRefTypeId: unique symbol = Symbol.for("effect-fc/SubscriptionSubRef/SubscriptionSubRef")
export const SubscriptionSubRefTypeId: unique symbol = Symbol.for("@effect-fc/SubscriptionSubRef/SubscriptionSubRef")
export type SubscriptionSubRefTypeId = typeof SubscriptionSubRefTypeId
export interface SubscriptionSubRef<in out A, in out B extends SubscriptionRef.SubscriptionRef<any>>

View File

@@ -4,6 +4,7 @@ export * as Form from "./Form.js"
export * as Memoized from "./Memoized.js"
export * as PropertyPath from "./PropertyPath.js"
export * as ReactRuntime from "./ReactRuntime.js"
export * as Result from "./Result.js"
export * as SetStateAction from "./SetStateAction.js"
export * as Stream from "./Stream.js"
export * as Subscribable from "./Subscribable.js"

View File

@@ -29,9 +29,7 @@
"@effect/platform": "^0.92.1",
"@effect/platform-browser": "^0.72.0",
"@radix-ui/themes": "^3.2.1",
"@typed/async-data": "^0.13.1",
"@typed/id": "^0.17.2",
"@typed/lazy-ref": "^0.3.3",
"effect": "^3.18.1",
"effect-fc": "workspace:*",
"react-icons": "^5.5.0"

View File

@@ -9,6 +9,7 @@
// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
import { Route as rootRouteImport } from './routes/__root'
import { Route as ResultRouteImport } from './routes/result'
import { Route as FormRouteImport } from './routes/form'
import { Route as BlankRouteImport } from './routes/blank'
import { Route as IndexRouteImport } from './routes/index'
@@ -16,6 +17,11 @@ import { Route as DevMemoRouteImport } from './routes/dev/memo'
import { Route as DevContextRouteImport } from './routes/dev/context'
import { Route as DevAsyncRenderingRouteImport } from './routes/dev/async-rendering'
const ResultRoute = ResultRouteImport.update({
id: '/result',
path: '/result',
getParentRoute: () => rootRouteImport,
} as any)
const FormRoute = FormRouteImport.update({
id: '/form',
path: '/form',
@@ -51,6 +57,7 @@ export interface FileRoutesByFullPath {
'/': typeof IndexRoute
'/blank': typeof BlankRoute
'/form': typeof FormRoute
'/result': typeof ResultRoute
'/dev/async-rendering': typeof DevAsyncRenderingRoute
'/dev/context': typeof DevContextRoute
'/dev/memo': typeof DevMemoRoute
@@ -59,6 +66,7 @@ export interface FileRoutesByTo {
'/': typeof IndexRoute
'/blank': typeof BlankRoute
'/form': typeof FormRoute
'/result': typeof ResultRoute
'/dev/async-rendering': typeof DevAsyncRenderingRoute
'/dev/context': typeof DevContextRoute
'/dev/memo': typeof DevMemoRoute
@@ -68,6 +76,7 @@ export interface FileRoutesById {
'/': typeof IndexRoute
'/blank': typeof BlankRoute
'/form': typeof FormRoute
'/result': typeof ResultRoute
'/dev/async-rendering': typeof DevAsyncRenderingRoute
'/dev/context': typeof DevContextRoute
'/dev/memo': typeof DevMemoRoute
@@ -78,6 +87,7 @@ export interface FileRouteTypes {
| '/'
| '/blank'
| '/form'
| '/result'
| '/dev/async-rendering'
| '/dev/context'
| '/dev/memo'
@@ -86,6 +96,7 @@ export interface FileRouteTypes {
| '/'
| '/blank'
| '/form'
| '/result'
| '/dev/async-rendering'
| '/dev/context'
| '/dev/memo'
@@ -94,6 +105,7 @@ export interface FileRouteTypes {
| '/'
| '/blank'
| '/form'
| '/result'
| '/dev/async-rendering'
| '/dev/context'
| '/dev/memo'
@@ -103,6 +115,7 @@ export interface RootRouteChildren {
IndexRoute: typeof IndexRoute
BlankRoute: typeof BlankRoute
FormRoute: typeof FormRoute
ResultRoute: typeof ResultRoute
DevAsyncRenderingRoute: typeof DevAsyncRenderingRoute
DevContextRoute: typeof DevContextRoute
DevMemoRoute: typeof DevMemoRoute
@@ -110,6 +123,13 @@ export interface RootRouteChildren {
declare module '@tanstack/react-router' {
interface FileRoutesByPath {
'/result': {
id: '/result'
path: '/result'
fullPath: '/result'
preLoaderRoute: typeof ResultRouteImport
parentRoute: typeof rootRouteImport
}
'/form': {
id: '/form'
path: '/form'
@@ -159,6 +179,7 @@ const rootRouteChildren: RootRouteChildren = {
IndexRoute: IndexRoute,
BlankRoute: BlankRoute,
FormRoute: FormRoute,
ResultRoute: ResultRoute,
DevAsyncRenderingRoute: DevAsyncRenderingRoute,
DevContextRoute: DevContextRoute,
DevMemoRoute: DevMemoRoute,

View File

@@ -1,6 +1,6 @@
import { Button, Container, Flex } from "@radix-ui/themes"
import { Button, Container, Flex, Text } from "@radix-ui/themes"
import { createFileRoute } from "@tanstack/react-router"
import { Console, Effect, Option, ParseResult, Schema } from "effect"
import { Console, Effect, Match, Option, ParseResult, Schema } from "effect"
import { Component, Form, Subscribable } from "effect-fc"
import { TextFieldFormInput } from "@/lib/form/TextFieldFormInput"
import { DateTimeUtcFromZonedInput } from "@/lib/schema"
@@ -50,7 +50,10 @@ class RegisterForm extends Effect.Service<RegisterForm>()("RegisterForm", {
class RegisterFormView extends Component.makeUntraced("RegisterFormView")(function*() {
const form = yield* RegisterForm
const submit = yield* Form.useSubmit(form)
const [canSubmit] = yield* Subscribable.useSubscribables(form.canSubmitSubscribable)
const [canSubmit, submitResult] = yield* Subscribable.useSubscribables(
form.canSubmitSubscribable,
form.submitResultRef,
)
const TextFieldFormInputFC = yield* TextFieldFormInput
@@ -85,6 +88,14 @@ class RegisterFormView extends Component.makeUntraced("RegisterFormView")(functi
<Button disabled={!canSubmit}>Submit</Button>
</Flex>
</form>
{Match.value(submitResult).pipe(
Match.tag("Initial", () => <></>),
Match.tag("Running", () => <Text>Submitting...</Text>),
Match.tag("Success", () => <Text>Submitted successfully!</Text>),
Match.tag("Failure", v => <Text>Error: {v.cause.toString()}</Text>),
Match.exhaustive,
)}
</Container>
)
}) {}

View File

@@ -0,0 +1,45 @@
import { HttpClient } from "@effect/platform"
import { Container, Heading, Text } from "@radix-ui/themes"
import { createFileRoute } from "@tanstack/react-router"
import { Effect, Match, Schema } from "effect"
import { Component, Result, Subscribable } from "effect-fc"
import { runtime } from "@/runtime"
const Post = Schema.Struct({
userId: Schema.Int,
id: Schema.Int,
title: Schema.String,
body: Schema.String,
})
const ResultView = Component.makeUntraced("Result")(function*() {
const resultSubscribable = yield* Component.useOnMount(() => HttpClient.HttpClient.pipe(
Effect.andThen(client => client.get("https://jsonplaceholder.typicode.com/posts/1")),
Effect.andThen(response => response.json),
Effect.andThen(Schema.decodeUnknown(Post)),
Effect.tap(Effect.sleep("250 millis")),
Result.forkEffect,
))
const [result] = yield* Subscribable.useSubscribables(resultSubscribable)
return (
<Container>
{Match.value(result).pipe(
Match.tag("Running", () => <Text>Loading...</Text>),
Match.tag("Success", result => <>
<Heading>{result.value.title}</Heading>
<Text>{result.value.body}</Text>
</>),
Match.tag("Failure", result =>
<Text>An error has occured: {result.cause.toString()}</Text>
),
Match.orElse(() => <></>),
)}
</Container>
)
})
export const Route = createFileRoute("/result")({
component: Component.withRuntime(ResultView, runtime.context)
})