mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 12:28:42 +00:00
This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [jotai-effect](https://jotai.org/docs/extensions/effect) ([source](https://redirect.github.com/jotaijs/jotai-effect)) | [`^1.0.5` -> `^2.0.0`](https://renovatebot.com/diffs/npm/jotai-effect/1.1.6/2.0.1) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>jotaijs/jotai-effect (jotai-effect)</summary> ### [`v2.0.1`](https://redirect.github.com/jotaijs/jotai-effect/compare/v2.0.0...v2.0.1) [Compare Source](https://redirect.github.com/jotaijs/jotai-effect/compare/v2.0.0...v2.0.1) ### [`v2.0.0`](https://redirect.github.com/jotaijs/jotai-effect/releases/tag/v2.0.0) [Compare Source](https://redirect.github.com/jotaijs/jotai-effect/compare/v1.1.6...v2.0.0) We’re excited to announce the release of **jotai-effect v2**, which brings a single but significant change to the core API: **`atomEffect` now runs synchronously** whenever it mounts or its dependencies change. This update improves consistency, helps avoid race conditions, and keeps related state changes in sync. *** #### What’s New? ##### Synchronous `atomEffect` - In v1, `atomEffect` would run **asynchronously** in the next microtask. - In v2, `atomEffect` runs **synchronously** on mount and whenever the dependencies it uses have changed. - **Batching is still supported** when you update multiple dependencies in a single writable atom. The effect runs only after that writable atom has finished all its updates, preventing partial updates or intermediate states. **Example:** ```ts const syncEffect = atomEffect((get, set) => { get(someAtom) set(anotherAtom) }) const store = createStore() store.set(someAtom, (v) => v + 1) // The effect above runs immediately, so anotherAtom is updated in the same microtask console.log(store.get(anotherAtom)) // Updated by atomEffect synchronously ``` When `someAtom` is updated, the effect runs **immediately**, updating `anotherAtom` in the same turn. If you update multiple atoms in the same writable atom, these changes are batched together, and `atomEffect` runs after those updates complete. *** #### Migration Guide For most users, **no change is required**. If you depended on the old microtask delay or cross-atom batching, read on. ##### 1. Adding back the microtask delay If your logic explicitly relied on `atomEffect` running in a separate microtask, you can reintroduce the delay yourself: **Before (v1)** ```ts const effect = atomEffect((get, set) => { console.log('effect') return () => { console.log('cleanup') } }) ``` **After (v2)** ```ts const effect = atomEffect((get, set) => { queueMicrotask(() => { console.log('effect') }) return () => { queueMicrotask(() => { console.log('cleanup') }) } }) ``` ##### 2. Batching updates In v1, updates to separate atoms were implicitly batched in the next microtask. In v2, **batching only occurs within a single writable atom update**: **Before (v1)** ```ts store.set(atomA, (v) => v + 1) store.set(atomB, (v) => v + 1) // atomEffect would 'see' both changes together in the next microtask ``` **After (v2)** ```ts const actionAtom = atom(null, (get, set) => { set(atomA, (v) => v + 1) set(atomB, (v) => v + 1) }) store.set(actionAtom) // atomEffect now runs after both updates, in one batch ``` *** ##### A Special Thanks to Daishi Kato I’d like to extend my deepest gratitude to **Daishi Kato**, author of Jotai. Daishi dedicated months of tireless work to rework and rewrite significant parts of the Jotai core—primarily to empower community library authors such as myself to implement features such as **synchronous effects** in jotai-effect. His willingness to refine Jotai’s internals and his thoughtfulness in API design made this effort possible. Thank you. ##### Final Thoughts - **Most code will just work** without any changes. - If you have specialized scenarios relying on microtask delays or separate updates to multiple atoms, you’ll need to wrap them in a single writable atom or manually queue the microtask. We hope these improvements make your state management more predictable and easier to reason about. If you have any issues, please feel free to open a GitHub [Discussion](https://redirect.github.com/jotaijs/jotai-effect/discussions). Happy coding! </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 was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/toeverything/AFFiNE). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4xNjcuMSIsInVwZGF0ZWRJblZlciI6IjM5LjE2Ny4xIiwidGFyZ2V0QnJhbmNoIjoiY2FuYXJ5IiwibGFiZWxzIjpbImRlcGVuZGVuY2llcyJdfQ==-->
51 lines
1.3 KiB
JSON
51 lines
1.3 KiB
JSON
{
|
|
"name": "@toeverything/infra",
|
|
"type": "module",
|
|
"private": true,
|
|
"sideEffects": false,
|
|
"exports": {
|
|
"./storage": "./src/storage/index.ts",
|
|
"./utils": "./src/utils/index.ts",
|
|
"./app-config-storage": "./src/app-config-storage.ts",
|
|
"./op": "./src/op/index.ts",
|
|
"./atom": "./src/atom/index.ts",
|
|
".": "./src/index.ts"
|
|
},
|
|
"dependencies": {
|
|
"@affine/debug": "workspace:*",
|
|
"@affine/env": "workspace:*",
|
|
"@affine/error": "workspace:*",
|
|
"@affine/templates": "workspace:*",
|
|
"@preact/signals-core": "^1.8.0",
|
|
"eventemitter2": "^6.4.9",
|
|
"foxact": "^0.2.43",
|
|
"fractional-indexing": "^3.2.0",
|
|
"fuse.js": "^7.0.0",
|
|
"graphemer": "^1.4.0",
|
|
"idb": "^8.0.0",
|
|
"jotai": "^2.10.3",
|
|
"jotai-effect": "^2.0.0",
|
|
"lodash-es": "^4.17.21",
|
|
"nanoid": "^5.0.9",
|
|
"react": "19.1.0",
|
|
"yjs": "^13.6.21",
|
|
"zod": "^3.24.1"
|
|
},
|
|
"devDependencies": {
|
|
"@affine/templates": "workspace:*",
|
|
"@emotion/react": "^11.14.0",
|
|
"@swc/core": "^1.10.1",
|
|
"@testing-library/dom": "^10.4.0",
|
|
"@testing-library/react": "^16.1.0",
|
|
"@types/react": "^19.0.1",
|
|
"fake-indexeddb": "^6.0.0",
|
|
"rxjs": "^7.8.1",
|
|
"vitest": "3.1.1"
|
|
},
|
|
"peerDependencies": {
|
|
"electron": "*",
|
|
"react-dom": "^19.0.0"
|
|
},
|
|
"version": "0.21.0"
|
|
}
|