@quark-fw/store 0.1.14 → 0.1.16

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.
@@ -2,6 +2,8 @@
2
2
  // с потоковой SSR-гидратацией через window.cache.
3
3
  import { createFlatProxy } from "@trpc/server/shared";
4
4
  // createRecursiveProxy убран из shared в tRPC 11.18 — только unstable core
5
+ // путь официально нестабилен (может меняться в минорных версиях tRPC),
6
+ // поэтому @trpc/server в package.json закреплён на ~11.18
5
7
  import { createRecursiveProxy } from "@trpc/server/unstable-core-do-not-import";
6
8
  import { getUntypedClient } from "@trpc/client";
7
9
  import { useSyncExternalStore } from "react";
@@ -40,6 +42,14 @@ export const createTinyRPCClient = ({ callback, trpcClient, values, promises, re
40
42
  })
41
43
  .catch((e) => {
42
44
  console.error(e);
45
+ // Упавший промис не кэшируем: иначе каждый
46
+ // следующий getPromise отдавал бы тот же reject
47
+ // до ручного clearCache. React-путь (get) держит
48
+ // ошибку в своём reactPromises — error boundary
49
+ // её увидит, а восстановление — через reFetch.
50
+ if (promises[fullKey] === promise) {
51
+ delete promises[fullKey];
52
+ }
43
53
  // иначе SSR-стрим не закрыл бы ключ и клиент
44
54
  // висел бы в NOT_READY_STATE навсегда
45
55
  callback?.(fullKey, ERROR_STATE);
package/dist/index.d.ts CHANGED
@@ -4,4 +4,7 @@ export { jsonSafeFetch } from "./jsonSafeFetch.js";
4
4
  export { ERROR_STATE, NOT_READY_STATE } from "./sentinels.js";
5
5
  export { trpcClient, type TRPCClient } from "./trpcClient.js";
6
6
  export { StoreContext, TRPCContext, useStore, useTrpc, type TStore, } from "./context.js";
7
+ export { errorMessage, reportError, setErrorHandler, type ErrorHandler, } from "./errors.js";
8
+ export { usePromise } from "./usePromise.js";
9
+ export type { Serialize } from "./serialize.js";
7
10
  export default Store;
package/dist/index.js CHANGED
@@ -6,4 +6,8 @@ export { jsonSafeFetch } from "./jsonSafeFetch.js";
6
6
  export { ERROR_STATE, NOT_READY_STATE } from "./sentinels.js";
7
7
  export { trpcClient } from "./trpcClient.js";
8
8
  export { StoreContext, TRPCContext, useStore, useTrpc, } from "./context.js";
9
+ // раньше доступны только глубоким импортом (@quark-fw/store/src/*.js);
10
+ // глубокие пути остаются рабочими — на них завязаны приложения
11
+ export { errorMessage, reportError, setErrorHandler, } from "./errors.js";
12
+ export { usePromise } from "./usePromise.js";
9
13
  export default Store;
@@ -3,6 +3,11 @@
3
3
  const sortValue = (value) => {
4
4
  if (Array.isArray(value))
5
5
  return value.map(sortValue);
6
+ // Date и прочее с toJSON сериализуются сами: разбор по ключам превратил
7
+ // бы любую дату в {} — и все даты делили бы один ключ кэша
8
+ if (typeof value?.toJSON === "function") {
9
+ return value;
10
+ }
6
11
  if (value && typeof value === "object") {
7
12
  const source = value;
8
13
  return Object.fromEntries(Object.keys(source)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quark-fw/store",
3
- "version": "0.1.14",
3
+ "version": "0.1.16",
4
4
  "description": "Isomorphic store and tRPC client hooks for the Quark framework",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@trpc/client": "^11.0.0",
34
- "@trpc/server": "^11.0.0"
34
+ "@trpc/server": "~11.18.0"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "react": "^19.2.4"