@quark-fw/entity 0.1.8 → 0.1.9

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.
@@ -32,8 +32,14 @@ export function createEntityContext(entityKey) {
32
32
  // Кэш store обновляем именно по ним — иначе setCache пишет под
33
33
  // ключом, который никто не читает, и после ремонта виден старый список.
34
34
  const liveArgs = useRef(new Map());
35
+ // Массивы, которые провайдер САМ записал в кэш store. Их эхо приходит
36
+ // назад через fresh, и без пометки эффект синхронизации принимал его
37
+ // за серверные данные: оптимистичный массив, попавший в кэш до отката,
38
+ // перетирал откат (mutationsInFlight к этому моменту уже обнулён).
39
+ const ownCacheWrites = useRef(new WeakSet());
35
40
  const setList = (updater) => {
36
41
  const syncCache = (arr) => {
42
+ ownCacheWrites.current.add(arr);
37
43
  for (const args of liveArgs.current.values()) {
38
44
  tinyCaller.list.setCache(args)(arr);
39
45
  }
@@ -192,6 +198,11 @@ export function createEntityContext(entityKey) {
192
198
  useEffect(() => {
193
199
  if (syncedFrom.current === fresh)
194
200
  return;
201
+ // эхо собственной записи в кэш — это не серверные данные
202
+ if (ownCacheWrites.current.has(fresh)) {
203
+ syncedFrom.current = fresh;
204
+ return;
205
+ }
195
206
  // мутация в полёте — локальное состояние новее серверного
196
207
  if (mutationsInFlight.current > 0)
197
208
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quark-fw/entity",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "Entity CRUD layer over tRPC and Prisma for the Quark framework",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -19,7 +19,8 @@
19
19
  ],
20
20
  "scripts": {
21
21
  "dev": "tsx watch src/index.ts",
22
- "build": "tsc -p tsconfig.build.json && node ../../scripts/postbuild.mjs"
22
+ "build": "tsc -p tsconfig.build.json && node ../../scripts/postbuild.mjs",
23
+ "test": "vitest run"
23
24
  },
24
25
  "keywords": [
25
26
  "quark"
@@ -30,16 +31,20 @@
30
31
  "access": "public"
31
32
  },
32
33
  "dependencies": {
33
- "@quark-fw/plugin-trpc": "0.1.8",
34
- "@quark-fw/store": "0.1.8",
34
+ "@quark-fw/plugin-trpc": "0.1.9",
35
+ "@quark-fw/store": "0.1.9",
35
36
  "@trpc/server": "^11.0.0",
36
37
  "zod": "^4.0.0"
37
38
  },
38
39
  "peerDependencies": {
39
- "@quark-fw/core": "0.1.8",
40
+ "@quark-fw/core": "0.1.9",
40
41
  "react": "^19.2.4"
41
42
  },
42
43
  "devDependencies": {
43
- "@types/react": "^19.2.14"
44
+ "@types/react": "^19.2.14",
45
+ "happy-dom": "^20.14.0",
46
+ "react": "^19.2.8",
47
+ "react-dom": "^19.2.8",
48
+ "vitest": "^5.0.0"
44
49
  }
45
50
  }