@buoy-gg/react-query 7.0.18 → 7.0.20
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/lib/commonjs/react-query/sync/dehydrate.js +11 -46
- package/lib/module/react-query/sync/dehydrate.js +12 -45
- package/lib/typescript/react-query/sync/dehydrate.d.ts +0 -1
- package/lib/typescript/react-query/sync/dehydrate.d.ts.map +1 -1
- package/lib/typescript/react-query/sync/reactQuerySyncAdapter.d.ts +1 -1
- package/lib/typescript/react-query/sync/reactQuerySyncAdapter.d.ts.map +1 -1
- package/package.json +9 -4
|
@@ -9,9 +9,9 @@ exports.dehydrateQueryClient = dehydrateQueryClient;
|
|
|
9
9
|
exports.isDataOnDeviceMarker = isDataOnDeviceMarker;
|
|
10
10
|
exports.isUnserializableMarker = isUnserializableMarker;
|
|
11
11
|
exports.isWireDataMarker = isWireDataMarker;
|
|
12
|
-
exports.jsonLongerThan = jsonLongerThan;
|
|
13
12
|
exports.toWireData = toWireData;
|
|
14
13
|
exports.toWireError = toWireError;
|
|
14
|
+
var _sharedUi = require("@buoy-gg/shared-ui");
|
|
15
15
|
/**
|
|
16
16
|
* Dehydration for external sync — ported from buoy-desktop's
|
|
17
17
|
* react-query-external-sync/hydration.ts so the desktop dashboard can
|
|
@@ -38,30 +38,6 @@ const UNSERIALIZABLE_DATA = exports.UNSERIALIZABLE_DATA = Object.freeze({
|
|
|
38
38
|
/** Keep small payloads inline; strip anything over this (same as network bodies). */
|
|
39
39
|
const SNAPSHOT_DATA_INLINE_LIMIT = exports.SNAPSHOT_DATA_INLINE_LIMIT = 16 * 1024;
|
|
40
40
|
const MAX_QUERY_DETAIL_BYTES = exports.MAX_QUERY_DETAIL_BYTES = 8 * 1024 * 1024;
|
|
41
|
-
function jsonLongerThan(value, limit) {
|
|
42
|
-
let bytes = 0;
|
|
43
|
-
const stack = [value];
|
|
44
|
-
const seen = new Set();
|
|
45
|
-
while (stack.length > 0) {
|
|
46
|
-
if (bytes > limit) return true;
|
|
47
|
-
const v = stack.pop();
|
|
48
|
-
if (v === null || v === undefined) bytes += 4;else if (typeof v === "string") bytes += v.length + 2;else if (typeof v === "number") bytes += 8;else if (typeof v === "boolean") bytes += 5;else if (typeof v === "object") {
|
|
49
|
-
if (seen.has(v)) continue;
|
|
50
|
-
seen.add(v);
|
|
51
|
-
if (Array.isArray(v)) {
|
|
52
|
-
bytes += 2 + v.length;
|
|
53
|
-
for (let i = 0; i < v.length; i++) stack.push(v[i]);
|
|
54
|
-
} else {
|
|
55
|
-
bytes += 2;
|
|
56
|
-
for (const k in v) {
|
|
57
|
-
bytes += k.length + 4;
|
|
58
|
-
stack.push(v[k]);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
} else bytes += 4;
|
|
62
|
-
}
|
|
63
|
-
return bytes > limit;
|
|
64
|
-
}
|
|
65
41
|
function isDataOnDeviceMarker(value) {
|
|
66
42
|
return !!value && typeof value === "object" && value.__buoyDataOnDevice === true;
|
|
67
43
|
}
|
|
@@ -75,15 +51,10 @@ function isWireDataMarker(value) {
|
|
|
75
51
|
/** Replace unserializable / oversized values with a wire marker. */
|
|
76
52
|
function toWireData(value) {
|
|
77
53
|
if (value === undefined) return undefined;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
if (jsonLongerThan(value, SNAPSHOT_DATA_INLINE_LIMIT)) {
|
|
84
|
-
return DATA_ON_DEVICE;
|
|
85
|
-
}
|
|
86
|
-
return value;
|
|
54
|
+
if (!(0, _sharedUi.isOverWireBudget)(value, SNAPSHOT_DATA_INLINE_LIMIT)) return value;
|
|
55
|
+
// Distinguish "too big to send" from "cannot be sent at all" — the dashboard
|
|
56
|
+
// offers a fetch for the first and must not for the second.
|
|
57
|
+
return (0, _sharedUi.isJsonSerializable)(value) ? DATA_ON_DEVICE : UNSERIALIZABLE_DATA;
|
|
87
58
|
}
|
|
88
59
|
|
|
89
60
|
/**
|
|
@@ -115,18 +86,12 @@ function toWireError(value) {
|
|
|
115
86
|
|
|
116
87
|
/** Cap an on-demand detail payload (action result, not the per-tick snapshot). */
|
|
117
88
|
function capQueryDetail(value) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
return {
|
|
125
|
-
__buoyTruncated: true,
|
|
126
|
-
note: `Exceeds the ${MAX_QUERY_DETAIL_BYTES / (1024 * 1024)}MB detail limit — inspect it on-device.`
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
return value;
|
|
89
|
+
if (!(0, _sharedUi.isOverWireBudget)(value, MAX_QUERY_DETAIL_BYTES)) return value;
|
|
90
|
+
if (!(0, _sharedUi.isJsonSerializable)(value)) return UNSERIALIZABLE_DATA;
|
|
91
|
+
return {
|
|
92
|
+
__buoyTruncated: true,
|
|
93
|
+
note: `Exceeds the ${MAX_QUERY_DETAIL_BYTES / (1024 * 1024)}MB detail limit — inspect it on-device.`
|
|
94
|
+
};
|
|
130
95
|
}
|
|
131
96
|
function dehydrateQueryClient(client) {
|
|
132
97
|
const mutations = client.getMutationCache().getAll().map(mutation => dehydrateMutation(mutation));
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
* hydrate an identical mirror of the device's QueryClient.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
import { isJsonSerializable, isOverWireBudget } from "@buoy-gg/shared-ui";
|
|
10
|
+
|
|
9
11
|
/**
|
|
10
12
|
* Sentinel used in WIRE-FORM snapshots in place of oversized query/mutation
|
|
11
13
|
* data. Same hazard as redux/zustand: a single cached payload can exceed the
|
|
@@ -26,30 +28,6 @@ export const UNSERIALIZABLE_DATA = Object.freeze({
|
|
|
26
28
|
/** Keep small payloads inline; strip anything over this (same as network bodies). */
|
|
27
29
|
export const SNAPSHOT_DATA_INLINE_LIMIT = 16 * 1024;
|
|
28
30
|
export const MAX_QUERY_DETAIL_BYTES = 8 * 1024 * 1024;
|
|
29
|
-
export function jsonLongerThan(value, limit) {
|
|
30
|
-
let bytes = 0;
|
|
31
|
-
const stack = [value];
|
|
32
|
-
const seen = new Set();
|
|
33
|
-
while (stack.length > 0) {
|
|
34
|
-
if (bytes > limit) return true;
|
|
35
|
-
const v = stack.pop();
|
|
36
|
-
if (v === null || v === undefined) bytes += 4;else if (typeof v === "string") bytes += v.length + 2;else if (typeof v === "number") bytes += 8;else if (typeof v === "boolean") bytes += 5;else if (typeof v === "object") {
|
|
37
|
-
if (seen.has(v)) continue;
|
|
38
|
-
seen.add(v);
|
|
39
|
-
if (Array.isArray(v)) {
|
|
40
|
-
bytes += 2 + v.length;
|
|
41
|
-
for (let i = 0; i < v.length; i++) stack.push(v[i]);
|
|
42
|
-
} else {
|
|
43
|
-
bytes += 2;
|
|
44
|
-
for (const k in v) {
|
|
45
|
-
bytes += k.length + 4;
|
|
46
|
-
stack.push(v[k]);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
} else bytes += 4;
|
|
50
|
-
}
|
|
51
|
-
return bytes > limit;
|
|
52
|
-
}
|
|
53
31
|
export function isDataOnDeviceMarker(value) {
|
|
54
32
|
return !!value && typeof value === "object" && value.__buoyDataOnDevice === true;
|
|
55
33
|
}
|
|
@@ -63,15 +41,10 @@ export function isWireDataMarker(value) {
|
|
|
63
41
|
/** Replace unserializable / oversized values with a wire marker. */
|
|
64
42
|
export function toWireData(value) {
|
|
65
43
|
if (value === undefined) return undefined;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
if (jsonLongerThan(value, SNAPSHOT_DATA_INLINE_LIMIT)) {
|
|
72
|
-
return DATA_ON_DEVICE;
|
|
73
|
-
}
|
|
74
|
-
return value;
|
|
44
|
+
if (!isOverWireBudget(value, SNAPSHOT_DATA_INLINE_LIMIT)) return value;
|
|
45
|
+
// Distinguish "too big to send" from "cannot be sent at all" — the dashboard
|
|
46
|
+
// offers a fetch for the first and must not for the second.
|
|
47
|
+
return isJsonSerializable(value) ? DATA_ON_DEVICE : UNSERIALIZABLE_DATA;
|
|
75
48
|
}
|
|
76
49
|
|
|
77
50
|
/**
|
|
@@ -103,18 +76,12 @@ export function toWireError(value) {
|
|
|
103
76
|
|
|
104
77
|
/** Cap an on-demand detail payload (action result, not the per-tick snapshot). */
|
|
105
78
|
export function capQueryDetail(value) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
return {
|
|
113
|
-
__buoyTruncated: true,
|
|
114
|
-
note: `Exceeds the ${MAX_QUERY_DETAIL_BYTES / (1024 * 1024)}MB detail limit — inspect it on-device.`
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
return value;
|
|
79
|
+
if (!isOverWireBudget(value, MAX_QUERY_DETAIL_BYTES)) return value;
|
|
80
|
+
if (!isJsonSerializable(value)) return UNSERIALIZABLE_DATA;
|
|
81
|
+
return {
|
|
82
|
+
__buoyTruncated: true,
|
|
83
|
+
note: `Exceeds the ${MAX_QUERY_DETAIL_BYTES / (1024 * 1024)}MB detail limit — inspect it on-device.`
|
|
84
|
+
};
|
|
118
85
|
}
|
|
119
86
|
export function dehydrateQueryClient(client) {
|
|
120
87
|
const mutations = client.getMutationCache().getAll().map(mutation => dehydrateMutation(mutation));
|
|
@@ -22,7 +22,6 @@ export declare const UNSERIALIZABLE_DATA: Readonly<{
|
|
|
22
22
|
/** Keep small payloads inline; strip anything over this (same as network bodies). */
|
|
23
23
|
export declare const SNAPSHOT_DATA_INLINE_LIMIT: number;
|
|
24
24
|
export declare const MAX_QUERY_DETAIL_BYTES: number;
|
|
25
|
-
export declare function jsonLongerThan(value: unknown, limit: number): boolean;
|
|
26
25
|
export declare function isDataOnDeviceMarker(value: unknown): boolean;
|
|
27
26
|
export declare function isUnserializableMarker(value: unknown): boolean;
|
|
28
27
|
export declare function isWireDataMarker(value: unknown): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dehydrate.d.ts","sourceRoot":"","sources":["../../../../src/react-query/sync/dehydrate.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EACV,YAAY,EAEZ,WAAW,EACX,YAAY,EACZ,aAAa,EACb,aAAa,EAEb,WAAW,EAEX,QAAQ,EACR,SAAS,EACT,oBAAoB,EACpB,UAAU,EACX,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"dehydrate.d.ts","sourceRoot":"","sources":["../../../../src/react-query/sync/dehydrate.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EACV,YAAY,EAEZ,WAAW,EACX,YAAY,EACZ,aAAa,EACb,aAAa,EAEb,WAAW,EAEX,QAAQ,EACR,SAAS,EACT,oBAAoB,EACpB,UAAU,EACX,MAAM,uBAAuB,CAAC;AAG/B;;;;;GAKG;AACH,eAAO,MAAM,cAAc;;;EAGzB,CAAC;AAEH,sEAAsE;AACtE,eAAO,MAAM,mBAAmB;;;EAG9B,CAAC;AAEH,qFAAqF;AACrF,eAAO,MAAM,0BAA0B,QAAY,CAAC;AAEpD,eAAO,MAAM,sBAAsB,QAAkB,CAAC;AAEtD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAM5D;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAM9D;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAExD;AAED,oEAAoE;AACpE,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAMlD;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAcnD;AAED,kFAAkF;AAClF,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAOtD;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,kBAAkB,EAAE,CAAC;IAChC,OAAO,EAAE,eAAe,EAAE,CAAC;CAC5B;AAED,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,KAAK,EAAE,aAAa,CAAC;IACrB,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,QAAQ,CAAC;IACnB,KAAK,EAAE,UAAU,CAAC;IAClB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,SAAS,EAAE,aAAa,EAAE,CAAC;CAC5B;AAED,MAAM,WAAW,aAAa,CAC5B,YAAY,GAAG,OAAO,EACtB,MAAM,GAAG,YAAY,EACrB,KAAK,GAAG,YAAY,EACpB,UAAU,GAAG,YAAY,EACzB,SAAS,SAAS,QAAQ,GAAG,QAAQ;IAErC,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,oBAAoB,CAC3B,YAAY,EACZ,MAAM,EACN,KAAK,EACL,UAAU,EACV,SAAS,CACV,CAAC;CACH;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,WAAW,GAAG,eAAe,CAYzE"}
|
|
@@ -43,7 +43,7 @@ export declare function createReactQuerySyncAdapter(queryClient: QueryClient): {
|
|
|
43
43
|
* the device unless `includeData` is set. Unlike getSnapshot (full
|
|
44
44
|
* dehydrated cache), this is safe to read repeatedly.
|
|
45
45
|
*/
|
|
46
|
-
listQueries: (params
|
|
46
|
+
listQueries: (params?: unknown) => {
|
|
47
47
|
queries: {
|
|
48
48
|
data?: unknown;
|
|
49
49
|
queryHash: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactQuerySyncAdapter.d.ts","sourceRoot":"","sources":["../../../../src/react-query/sync/reactQuerySyncAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAiB,KAAK,WAAW,EAAiB,MAAM,uBAAuB,CAAC;AA0BvF,wBAAgB,2BAA2B,CAAC,WAAW,EAAE,WAAW;;;;;;0BAgB1C,MAAM,IAAI;;QAa9B;;;;WAIG;+BACoB,OAAO;;;;;;;;;;;QAY9B;;;;;;WAMG
|
|
1
|
+
{"version":3,"file":"reactQuerySyncAdapter.d.ts","sourceRoot":"","sources":["../../../../src/react-query/sync/reactQuerySyncAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAiB,KAAK,WAAW,EAAiB,MAAM,uBAAuB,CAAC;AA0BvF,wBAAgB,2BAA2B,CAAC,WAAW,EAAE,WAAW;;;;;;0BAgB1C,MAAM,IAAI;;QAa9B;;;;WAIG;+BACoB,OAAO;;;;;;;;;;;QAY9B;;;;;;WAMG;+BACoB,OAAO;;;;;;;;;;;;;;;;0BAkCZ,OAAO;6BAKJ,OAAO;wBAEZ,OAAO;yBACN,OAAO;+BAGD,OAAO;+BAIP,OAAO;+BAaP,OAAO;iCAEL,OAAO;iCAwBP,OAAO;;;4BA4BZ,OAAO;;EAMhC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buoy-gg/react-query",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.20",
|
|
4
4
|
"description": "TanStack Query devtools inside your React Native app — cache inspection, refetch & invalidate, offline toggle. Part of Buoy devtools.",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"**/snapshotProvider.ts"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@buoy-gg/
|
|
33
|
-
"@buoy-gg/
|
|
32
|
+
"@buoy-gg/shared-ui": "^7.0.20",
|
|
33
|
+
"@buoy-gg/floating-tools-core": "^7.0.20"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"@tanstack/react-query": ">=5.0.0",
|
|
@@ -59,7 +59,12 @@
|
|
|
59
59
|
"sourceMaps": false
|
|
60
60
|
}
|
|
61
61
|
],
|
|
62
|
-
|
|
62
|
+
[
|
|
63
|
+
"typescript",
|
|
64
|
+
{
|
|
65
|
+
"project": "tsconfig.build.json"
|
|
66
|
+
}
|
|
67
|
+
]
|
|
63
68
|
]
|
|
64
69
|
},
|
|
65
70
|
"repository": {
|