@capybara-devtools/core 0.2.0 → 0.3.0
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/README.md +2 -2
- package/dist/client.d.ts +3 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +9 -4
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/plugins/state/context.d.ts +102 -0
- package/dist/plugins/state/context.d.ts.map +1 -0
- package/dist/plugins/state/context.js +765 -0
- package/dist/plugins/state/context.js.map +1 -0
- package/dist/plugins/state/engine.d.ts +71 -0
- package/dist/plugins/state/engine.d.ts.map +1 -0
- package/dist/plugins/state/engine.js +710 -0
- package/dist/plugins/state/engine.js.map +1 -0
- package/dist/plugins/state/index.d.ts +59 -0
- package/dist/plugins/state/index.d.ts.map +1 -0
- package/dist/plugins/state/index.js +52 -0
- package/dist/plugins/state/index.js.map +1 -0
- package/dist/plugins/state/redux.d.ts +43 -0
- package/dist/plugins/state/redux.d.ts.map +1 -0
- package/dist/plugins/state/redux.js +580 -0
- package/dist/plugins/state/redux.js.map +1 -0
- package/dist/plugins/state/registry.d.ts +22 -0
- package/dist/plugins/state/registry.d.ts.map +1 -0
- package/dist/plugins/state/registry.js +109 -0
- package/dist/plugins/state/registry.js.map +1 -0
- package/dist/plugins/state/swr.d.ts +49 -0
- package/dist/plugins/state/swr.d.ts.map +1 -0
- package/dist/plugins/state/swr.js +359 -0
- package/dist/plugins/state/swr.js.map +1 -0
- package/dist/plugins/state/tanstack.d.ts +31 -0
- package/dist/plugins/state/tanstack.d.ts.map +1 -0
- package/dist/plugins/state/tanstack.js +461 -0
- package/dist/plugins/state/tanstack.js.map +1 -0
- package/dist/plugins/state/zustand.d.ts +21 -0
- package/dist/plugins/state/zustand.d.ts.map +1 -0
- package/dist/plugins/state/zustand.js +70 -0
- package/dist/plugins/state/zustand.js.map +1 -0
- package/package.json +11 -2
- package/src/client.ts +12 -6
- package/src/index.ts +19 -0
- package/src/plugins/state/context.ts +831 -0
- package/src/plugins/state/engine.ts +739 -0
- package/src/plugins/state/index.ts +112 -0
- package/src/plugins/state/redux.ts +609 -0
- package/src/plugins/state/registry.ts +126 -0
- package/src/plugins/state/swr.ts +375 -0
- package/src/plugins/state/tanstack.ts +488 -0
- package/src/plugins/state/zustand.ts +82 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where registered stores live. On `globalThis` so adapters can run before or after `init()`, and stores
|
|
3
|
+
* outlive hot reloads, a client stopped and started again, and a second copy of the SDK in the bundle.
|
|
4
|
+
* The name carries the version of the shape: changing the shape means a new name.
|
|
5
|
+
*/
|
|
6
|
+
export const REGISTRY_GLOBAL = '__CAPYBARA_STATE_V1__';
|
|
7
|
+
/** Hot reload re-creates a store under the same label; the older instances make way. */
|
|
8
|
+
const MAX_INSTANCES = 3;
|
|
9
|
+
const MAX_STORES = 100;
|
|
10
|
+
function registry() {
|
|
11
|
+
const scope = globalThis;
|
|
12
|
+
let reg = scope[REGISTRY_GLOBAL];
|
|
13
|
+
if (!reg) {
|
|
14
|
+
reg = { version: 1, stores: new Map(), ids: new WeakMap(), keep: new WeakMap(), counts: {}, sink: null };
|
|
15
|
+
scope[REGISTRY_GLOBAL] = reg;
|
|
16
|
+
}
|
|
17
|
+
return reg;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Adds a store and returns its id, e.g. "zustand:2"; undefined where there is no `window` (server
|
|
21
|
+
* rendering, Node). Pass the store, client or cache the driver reads as `target`: registering the same
|
|
22
|
+
* target again then returns the same id, and the driver is held only as long as the target lives.
|
|
23
|
+
* Without a target the driver is held until it is unregistered or pushed out by the caps.
|
|
24
|
+
*/
|
|
25
|
+
export function register(driver, target) {
|
|
26
|
+
if (typeof window === 'undefined')
|
|
27
|
+
return undefined;
|
|
28
|
+
let id;
|
|
29
|
+
try {
|
|
30
|
+
const reg = registry();
|
|
31
|
+
const key = target ?? driver;
|
|
32
|
+
const known = reg.ids.get(key);
|
|
33
|
+
if (known !== undefined && reg.stores.has(known))
|
|
34
|
+
return known;
|
|
35
|
+
sweep(reg);
|
|
36
|
+
const { library, label } = driver.info;
|
|
37
|
+
const twins = [...reg.stores].filter(([, slot]) => slot.info.library === library && slot.info.label === label);
|
|
38
|
+
for (const [old] of twins.slice(0, Math.max(0, twins.length - (MAX_INSTANCES - 1))))
|
|
39
|
+
dispose(reg, old);
|
|
40
|
+
while (reg.stores.size >= MAX_STORES) {
|
|
41
|
+
dispose(reg, reg.stores.keys().next().value, `Dropped to stay under ${MAX_STORES} stores`);
|
|
42
|
+
}
|
|
43
|
+
const n = (reg.counts[library] ?? 0) + 1;
|
|
44
|
+
reg.counts[library] = n;
|
|
45
|
+
id = `${library}:${n}`;
|
|
46
|
+
let held = { deref: () => driver };
|
|
47
|
+
if (target && typeof WeakRef === 'function') {
|
|
48
|
+
reg.keep.set(target, driver);
|
|
49
|
+
held = new WeakRef(driver);
|
|
50
|
+
}
|
|
51
|
+
reg.stores.set(id, { info: driver.info, driver: held });
|
|
52
|
+
reg.ids.set(key, id);
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
registry().sink?.track(id, driver);
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
// the engine reports its own failures as a disposed store
|
|
62
|
+
}
|
|
63
|
+
return id;
|
|
64
|
+
}
|
|
65
|
+
/** Removes a store, e.g. when an adapter's untrack function runs. */
|
|
66
|
+
export function unregister(id) {
|
|
67
|
+
if (typeof window === 'undefined')
|
|
68
|
+
return;
|
|
69
|
+
dispose(registry(), id);
|
|
70
|
+
}
|
|
71
|
+
/** Has `sink` watch every registered store, and the ones registered later. Returns the undo. */
|
|
72
|
+
export function attach(sink) {
|
|
73
|
+
const reg = registry();
|
|
74
|
+
sweep(reg);
|
|
75
|
+
reg.sink = sink;
|
|
76
|
+
for (const [id, slot] of [...reg.stores]) {
|
|
77
|
+
const driver = slot.driver.deref();
|
|
78
|
+
if (!driver)
|
|
79
|
+
continue;
|
|
80
|
+
try {
|
|
81
|
+
sink.track(id, driver);
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
// keep attaching the rest
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return () => {
|
|
88
|
+
if (reg.sink === sink)
|
|
89
|
+
reg.sink = null;
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
// Hermes may lack FinalizationRegistry, so collected stores are found by looking, whenever stores change.
|
|
93
|
+
function sweep(reg) {
|
|
94
|
+
for (const [id, slot] of [...reg.stores]) {
|
|
95
|
+
if (!slot.driver.deref())
|
|
96
|
+
dispose(reg, id);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function dispose(reg, id, note) {
|
|
100
|
+
if (!reg.stores.delete(id))
|
|
101
|
+
return;
|
|
102
|
+
try {
|
|
103
|
+
reg.sink?.untrack(id, note);
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
// nothing to report then
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/plugins/state/registry.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,uBAAuB,CAAC;AACvD,wFAAwF;AACxF,MAAM,aAAa,GAAG,CAAC,CAAC;AACxB,MAAM,UAAU,GAAG,GAAG,CAAC;AAuBvB,SAAS,QAAQ;IACf,MAAM,KAAK,GAAG,UAAqC,CAAC;IACpD,IAAI,GAAG,GAAG,KAAK,CAAC,eAAe,CAAyB,CAAC;IACzD,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,GAAG,GAAG,EAAE,OAAO,EAAE,CAAC,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AG,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;IAC9B,CAAC;IAAC,MAAM,CAAC;QACP,yBAAyB;IAC3B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { StateEntrySummary } from '@capybara-devtools/protocol';
|
|
2
|
+
/** What Capybara uses of an SWR cache. SWR's `Cache` and a `Map` both fit. */
|
|
3
|
+
export interface SWRCacheLike {
|
|
4
|
+
keys(): IterableIterator<string>;
|
|
5
|
+
get(key: string): any;
|
|
6
|
+
set(key: string, value: any): void;
|
|
7
|
+
delete(key: string): void;
|
|
8
|
+
}
|
|
9
|
+
/** A cache and the `mutate` bound to it, as `useSWRConfig()` and `SWRConfig.defaultValue` hold them. */
|
|
10
|
+
export interface SWRHandle {
|
|
11
|
+
cache: SWRCacheLike;
|
|
12
|
+
/** Runs the revalidate, clear and reset commands. */
|
|
13
|
+
mutate?: (...args: any[]) => unknown;
|
|
14
|
+
unload?: unknown;
|
|
15
|
+
}
|
|
16
|
+
export interface WatchSWROptions {
|
|
17
|
+
/** Names the cache in the State tab. Defaults to "default" for SWR's own cache, else "cache #1", "cache #2"… */
|
|
18
|
+
name?: string;
|
|
19
|
+
}
|
|
20
|
+
/** SWR's hook, as a middleware receives it. */
|
|
21
|
+
type SWRHookLike = (key: any, fetcher: any, config: any) => any;
|
|
22
|
+
/**
|
|
23
|
+
* Shows an SWR cache in the State tab. Pass `SWRConfig` for SWR's default cache, the result of
|
|
24
|
+
* `useSWRConfig()`, or `{ cache, mutate }`. Watching a cache again only fills in a `mutate` it lacked.
|
|
25
|
+
* Returns a function that stops showing it. Does nothing where there is no `window` (server rendering).
|
|
26
|
+
*/
|
|
27
|
+
export declare function watchSWR(target: SWRHandle | {
|
|
28
|
+
defaultValue: SWRHandle;
|
|
29
|
+
}, options?: WatchSWROptions): () => void;
|
|
30
|
+
/**
|
|
31
|
+
* Watches the cache of each hook rendered under it: `<SWRConfig value={{ use: [swrMiddleware] }}>`.
|
|
32
|
+
* For an SWRConfig with its own `provider`, as React Native apps have; it also hands over the `mutate`
|
|
33
|
+
* that commands need, which `swrProvider` cannot reach.
|
|
34
|
+
*/
|
|
35
|
+
export declare function swrMiddleware(useSWRNext: SWRHookLike): SWRHookLike;
|
|
36
|
+
/**
|
|
37
|
+
* Watches the cache an SWRConfig `provider` makes: `provider: swrProvider(() => new Map())`. Without
|
|
38
|
+
* `inner`, watches the parent cache. SWR creates the cache's `mutate` only after the provider returns,
|
|
39
|
+
* so add `swrMiddleware` too for the revalidate, clear and reset commands.
|
|
40
|
+
*/
|
|
41
|
+
export declare function swrProvider(inner?: (parent: SWRCacheLike) => SWRCacheLike, options?: WatchSWROptions): (parent: SWRCacheLike) => SWRCacheLike;
|
|
42
|
+
/**
|
|
43
|
+
* Describes an SWR cache entry without its data. Self-contained: the Metro bridge runs it from its source
|
|
44
|
+
* inside apps without the SDK, so it uses nothing from module scope. `updatedAt` is when the entry's
|
|
45
|
+
* data or error was last seen changing. Entries with only SWR's internal fields give undefined.
|
|
46
|
+
*/
|
|
47
|
+
export declare function summarizeSWREntry(key: string, entry: unknown, updatedAt?: number): StateEntrySummary | undefined;
|
|
48
|
+
export {};
|
|
49
|
+
//# sourceMappingURL=swr.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swr.d.ts","sourceRoot":"","sources":["../../../src/plugins/state/swr.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAKrE,8EAA8E;AAC9E,MAAM,WAAW,YAAY;IAC3B,IAAI,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACjC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;IACtB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI,CAAC;IACnC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,wGAAwG;AACxG,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,YAAY,CAAC;IACpB,qDAAqD;IACrD,MAAM,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC;IACrC,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,eAAe;IAC9B,gHAAgH;IAChH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,+CAA+C;AAC/C,KAAK,WAAW,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,KAAK,GAAG,CAAC;AAmBhE;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG;IAAE,YAAY,EAAE,SAAS,CAAA;CAAE,EAAE,OAAO,GAAE,eAAoB,GAAG,MAAM,IAAI,CA0BnH;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,WAAW,GAAG,WAAW,CAKlE;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,YAAY,EAC9C,OAAO,CAAC,EAAE,eAAe,GACxB,CAAC,MAAM,EAAE,YAAY,KAAK,YAAY,CAOxC;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAsEhH"}
|
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
import { errorMessage } from '../../utils.js';
|
|
2
|
+
import { register, unregister } from './registry.js';
|
|
3
|
+
/** Keys listed per cache. SWR never evicts, so a long session can hold many more. */
|
|
4
|
+
const MAX_KEYS = 1_000;
|
|
5
|
+
/** How long a revalidate waits for its fetch before answering anyway; the UI gives up on a command after 15 s. */
|
|
6
|
+
const REVALIDATE_WAIT = 10_000;
|
|
7
|
+
const NO_HOOK = 'No mounted hook fetches this key, so nothing was revalidated';
|
|
8
|
+
const NO_MUTATE = 'Capybara has no mutate() for this cache yet: add swrMiddleware to the SWRConfig that creates it';
|
|
9
|
+
/** Caches already registered, so the middleware, which runs on every render, only looks one up. */
|
|
10
|
+
const watched = new WeakMap();
|
|
11
|
+
let unnamed = 0;
|
|
12
|
+
const noop = () => { };
|
|
13
|
+
/**
|
|
14
|
+
* Shows an SWR cache in the State tab. Pass `SWRConfig` for SWR's default cache, the result of
|
|
15
|
+
* `useSWRConfig()`, or `{ cache, mutate }`. Watching a cache again only fills in a `mutate` it lacked.
|
|
16
|
+
* Returns a function that stops showing it. Does nothing where there is no `window` (server rendering).
|
|
17
|
+
*/
|
|
18
|
+
export function watchSWR(target, options = {}) {
|
|
19
|
+
if (typeof window === 'undefined')
|
|
20
|
+
return noop;
|
|
21
|
+
try {
|
|
22
|
+
const defaults = target.defaultValue;
|
|
23
|
+
const handle = (defaults ?? target);
|
|
24
|
+
const cache = handle.cache;
|
|
25
|
+
if (!isCache(cache))
|
|
26
|
+
return noop;
|
|
27
|
+
const mutate = typeof handle.mutate === 'function' ? handle.mutate : undefined;
|
|
28
|
+
const known = watched.get(cache);
|
|
29
|
+
if (known) {
|
|
30
|
+
known.mutate ??= mutate;
|
|
31
|
+
return known.untrack;
|
|
32
|
+
}
|
|
33
|
+
const watch = { mutate, untrack: noop };
|
|
34
|
+
const label = options.name ?? (defaults ? 'default' : `cache #${++unnamed}`);
|
|
35
|
+
const id = register(swrDriver(cache, label, watch), cache);
|
|
36
|
+
if (id === undefined)
|
|
37
|
+
return noop;
|
|
38
|
+
watch.untrack = () => {
|
|
39
|
+
if (watched.get(cache) === watch)
|
|
40
|
+
watched.delete(cache);
|
|
41
|
+
unregister(id);
|
|
42
|
+
};
|
|
43
|
+
watched.set(cache, watch);
|
|
44
|
+
return watch.untrack;
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return noop;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Watches the cache of each hook rendered under it: `<SWRConfig value={{ use: [swrMiddleware] }}>`.
|
|
52
|
+
* For an SWRConfig with its own `provider`, as React Native apps have; it also hands over the `mutate`
|
|
53
|
+
* that commands need, which `swrProvider` cannot reach.
|
|
54
|
+
*/
|
|
55
|
+
export function swrMiddleware(useSWRNext) {
|
|
56
|
+
return (key, fetcher, config) => {
|
|
57
|
+
if (config)
|
|
58
|
+
watchSWR(config);
|
|
59
|
+
return useSWRNext(key, fetcher, config);
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Watches the cache an SWRConfig `provider` makes: `provider: swrProvider(() => new Map())`. Without
|
|
64
|
+
* `inner`, watches the parent cache. SWR creates the cache's `mutate` only after the provider returns,
|
|
65
|
+
* so add `swrMiddleware` too for the revalidate, clear and reset commands.
|
|
66
|
+
*/
|
|
67
|
+
export function swrProvider(inner, options) {
|
|
68
|
+
return (parent) => {
|
|
69
|
+
const cache = inner ? inner(parent) : parent;
|
|
70
|
+
// SWR keys its state for a cache by the object itself, so a wrapper would split the hooks from `mutate`.
|
|
71
|
+
watchSWR({ cache }, options);
|
|
72
|
+
return cache;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Describes an SWR cache entry without its data. Self-contained: the Metro bridge runs it from its source
|
|
77
|
+
* inside apps without the SDK, so it uses nothing from module scope. `updatedAt` is when the entry's
|
|
78
|
+
* data or error was last seen changing. Entries with only SWR's internal fields give undefined.
|
|
79
|
+
*/
|
|
80
|
+
export function summarizeSWREntry(key, entry, updatedAt) {
|
|
81
|
+
if (entry === null || typeof entry !== 'object')
|
|
82
|
+
return undefined;
|
|
83
|
+
const state = entry;
|
|
84
|
+
// `useSWRMutation` leaves `{ _c: undefined }` behind, and a hook that has not fetched only `{ _k }`.
|
|
85
|
+
if (!('data' in state || 'error' in state || 'isValidating' in state || 'isLoading' in state))
|
|
86
|
+
return undefined;
|
|
87
|
+
const cut = (text, max) => (text.length > max ? `${text.slice(0, max)}…` : text);
|
|
88
|
+
// The shape alone, never a value: the MCP server hands previews to AI assistants as they are.
|
|
89
|
+
const preview = (value) => {
|
|
90
|
+
if (value === null)
|
|
91
|
+
return 'null';
|
|
92
|
+
if (typeof value === 'string')
|
|
93
|
+
return `string(${value.length})`;
|
|
94
|
+
if (typeof value !== 'object')
|
|
95
|
+
return typeof value;
|
|
96
|
+
if (Array.isArray(value))
|
|
97
|
+
return `Array(${value.length})`;
|
|
98
|
+
const tag = Object.prototype.toString.call(value).slice(8, -1);
|
|
99
|
+
if (tag === 'Map' || tag === 'Set')
|
|
100
|
+
return `${tag}(${value.size})`;
|
|
101
|
+
if (tag === 'Date')
|
|
102
|
+
return 'Date';
|
|
103
|
+
// Only names that look like fields: an object keyed by ids, emails or tokens would show those.
|
|
104
|
+
const fields = [];
|
|
105
|
+
let more = false;
|
|
106
|
+
let checked = 0;
|
|
107
|
+
for (const name in value) {
|
|
108
|
+
if (!Object.prototype.hasOwnProperty.call(value, name))
|
|
109
|
+
continue;
|
|
110
|
+
if (fields.length === 3 || ++checked > 10) {
|
|
111
|
+
more = true;
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
if (name.length <= 24 && /^[A-Za-z_$]+\d*$/.test(name))
|
|
115
|
+
fields.push(name);
|
|
116
|
+
else
|
|
117
|
+
more = true;
|
|
118
|
+
}
|
|
119
|
+
const shape = `{${fields.join(', ')}${more ? (fields.length > 0 ? ', …' : '…') : ''}}`;
|
|
120
|
+
const proto = Object.getPrototypeOf(value);
|
|
121
|
+
const type = proto && proto !== Object.prototype && typeof proto.constructor === 'function' && proto.constructor.name;
|
|
122
|
+
return type ? `${type} ${shape}` : shape;
|
|
123
|
+
};
|
|
124
|
+
const describeError = (error) => {
|
|
125
|
+
if (typeof error === 'string')
|
|
126
|
+
return error;
|
|
127
|
+
const { name, message, status } = (error !== null && typeof error === 'object' ? error : {});
|
|
128
|
+
const title = typeof name === 'string' && name ? name : 'Error';
|
|
129
|
+
// Anything thrown that is not an error is described like data.
|
|
130
|
+
let text = typeof message !== 'string' ? preview(error) : message ? `${title}: ${message}` : title;
|
|
131
|
+
// SWR's docs put the HTTP status on the error, and the State tab shows a status it finds as "error 404".
|
|
132
|
+
if (typeof status === 'number' && !text.includes(String(status)))
|
|
133
|
+
text += ` (status ${status})`;
|
|
134
|
+
return text;
|
|
135
|
+
};
|
|
136
|
+
const prefix = key.startsWith('$inf$') ? '$inf$' : key.startsWith('$sub$') ? '$sub$' : '';
|
|
137
|
+
const kind = prefix === '$inf$' ? 'swr-infinite' : prefix ? 'swr-subscription' : 'swr';
|
|
138
|
+
let label = key.slice(prefix.length);
|
|
139
|
+
// A key that is not a string is stored hashed, e.g. `@"/api/user",1,`; `_k` keeps the hook's arguments.
|
|
140
|
+
if (state._k !== null && typeof state._k === 'object') {
|
|
141
|
+
try {
|
|
142
|
+
label = JSON.stringify(state._k, (_, value) => (typeof value === 'bigint' ? `${value}n` : value)) ?? label;
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
// cyclic arguments: the hashed key will do
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
const { data, error } = state;
|
|
149
|
+
const fetching = state.isValidating === true;
|
|
150
|
+
const loading = fetching || state.isLoading === true;
|
|
151
|
+
const status = error !== undefined ? 'error' : data !== undefined ? 'success' : loading ? 'pending' : 'idle';
|
|
152
|
+
const summary = { key, label: cut(label, 1_000), kind, status, fetching };
|
|
153
|
+
if (updatedAt !== undefined)
|
|
154
|
+
summary.updatedAt = updatedAt;
|
|
155
|
+
if (error !== undefined)
|
|
156
|
+
summary.error = cut(describeError(error), 500);
|
|
157
|
+
if (data !== undefined)
|
|
158
|
+
summary.preview = preview(data);
|
|
159
|
+
return summary;
|
|
160
|
+
}
|
|
161
|
+
// The registry holds this driver only as long as the cache lives, so the driver can hold the cache.
|
|
162
|
+
function swrDriver(cache, label, watch) {
|
|
163
|
+
/** The last write seen per key, least recent first. */
|
|
164
|
+
const marks = new Map();
|
|
165
|
+
let report = null;
|
|
166
|
+
let probe = null;
|
|
167
|
+
/** Undo of each method patched; kept while another patch sits on top of ours, which then only passes calls on. */
|
|
168
|
+
const restores = {};
|
|
169
|
+
const read = (key) => {
|
|
170
|
+
try {
|
|
171
|
+
return cache.get(key);
|
|
172
|
+
}
|
|
173
|
+
catch {
|
|
174
|
+
return undefined;
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
// Same rule as summarizeSWREntry, without building a summary for every key in the cache.
|
|
178
|
+
const listed = (entry) => entry !== null &&
|
|
179
|
+
typeof entry === 'object' &&
|
|
180
|
+
('data' in entry || 'error' in entry || 'isValidating' in entry || 'isLoading' in entry);
|
|
181
|
+
const keys = () => {
|
|
182
|
+
const shown = [];
|
|
183
|
+
try {
|
|
184
|
+
for (const key of cache.keys()) {
|
|
185
|
+
if (typeof key === 'string' && listed(read(key)))
|
|
186
|
+
shown.push(key);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
catch {
|
|
190
|
+
// list what was read before the cache failed
|
|
191
|
+
}
|
|
192
|
+
if (shown.length <= MAX_KEYS)
|
|
193
|
+
return shown;
|
|
194
|
+
// The keys written to most recently, then the newest others; in cache order, so rows keep their place.
|
|
195
|
+
const present = new Set(shown);
|
|
196
|
+
const picked = new Set();
|
|
197
|
+
const recent = [...marks.keys()];
|
|
198
|
+
for (let i = recent.length - 1; i >= 0 && picked.size < MAX_KEYS; i--) {
|
|
199
|
+
if (present.has(recent[i]))
|
|
200
|
+
picked.add(recent[i]);
|
|
201
|
+
}
|
|
202
|
+
for (let i = shown.length - 1; i >= 0 && picked.size < MAX_KEYS; i--)
|
|
203
|
+
picked.add(shown[i]);
|
|
204
|
+
return shown.filter((key) => picked.has(key));
|
|
205
|
+
};
|
|
206
|
+
const wrap = (name) => {
|
|
207
|
+
if (restores[name])
|
|
208
|
+
return;
|
|
209
|
+
const target = cache;
|
|
210
|
+
const own = Object.getOwnPropertyDescriptor(target, name);
|
|
211
|
+
const original = own && 'value' in own ? own.value : target[name];
|
|
212
|
+
if (typeof original !== 'function')
|
|
213
|
+
throw new Error(`The cache has no ${name}()`);
|
|
214
|
+
const removal = name === 'delete';
|
|
215
|
+
// SWR writes during render too (Suspense, providers): the write goes first, and the rest is O(1) and never throws.
|
|
216
|
+
const wrapper = function (key, value) {
|
|
217
|
+
const result = original.apply(this, arguments);
|
|
218
|
+
if (report) {
|
|
219
|
+
try {
|
|
220
|
+
report(key, value, removal);
|
|
221
|
+
}
|
|
222
|
+
catch {
|
|
223
|
+
// never break the app's cache
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return result;
|
|
227
|
+
};
|
|
228
|
+
const ours = () => Object.getOwnPropertyDescriptor(target, name)?.value === wrapper;
|
|
229
|
+
Object.defineProperty(target, name, { value: wrapper, configurable: true, writable: true, enumerable: own?.enumerable ?? false });
|
|
230
|
+
// A proxy can accept the definition and keep the old method.
|
|
231
|
+
if (!ours())
|
|
232
|
+
throw new Error(`Could not patch the cache's ${name}()`);
|
|
233
|
+
restores[name] = () => {
|
|
234
|
+
if (!ours())
|
|
235
|
+
return false;
|
|
236
|
+
if (own)
|
|
237
|
+
Object.defineProperty(target, name, own);
|
|
238
|
+
else
|
|
239
|
+
delete target[name];
|
|
240
|
+
return true;
|
|
241
|
+
};
|
|
242
|
+
};
|
|
243
|
+
const unpatch = () => {
|
|
244
|
+
for (const name of ['set', 'delete']) {
|
|
245
|
+
try {
|
|
246
|
+
if (restores[name]?.())
|
|
247
|
+
delete restores[name];
|
|
248
|
+
}
|
|
249
|
+
catch {
|
|
250
|
+
// left in place, passing calls on
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
const start = (sink, id) => {
|
|
255
|
+
report = (key, value, removal) => {
|
|
256
|
+
if (typeof key !== 'string')
|
|
257
|
+
return;
|
|
258
|
+
if (removal) {
|
|
259
|
+
marks.delete(key);
|
|
260
|
+
sink.removed(id, key);
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
const state = (value !== null && typeof value === 'object' ? value : {});
|
|
264
|
+
const { data, error } = state;
|
|
265
|
+
if (probe && probe.key === key && state.isValidating === true)
|
|
266
|
+
probe.hit = true;
|
|
267
|
+
let mark = marks.get(key);
|
|
268
|
+
if (mark)
|
|
269
|
+
marks.delete(key);
|
|
270
|
+
if (!mark || mark.data !== data || mark.error !== error)
|
|
271
|
+
mark = { data, error, at: Date.now() };
|
|
272
|
+
marks.set(key, mark);
|
|
273
|
+
sink.dirty(id, key);
|
|
274
|
+
};
|
|
275
|
+
try {
|
|
276
|
+
wrap('set');
|
|
277
|
+
wrap('delete');
|
|
278
|
+
}
|
|
279
|
+
catch (error) {
|
|
280
|
+
report = null;
|
|
281
|
+
unpatch();
|
|
282
|
+
throw error;
|
|
283
|
+
}
|
|
284
|
+
return () => {
|
|
285
|
+
report = null;
|
|
286
|
+
marks.clear();
|
|
287
|
+
unpatch();
|
|
288
|
+
};
|
|
289
|
+
};
|
|
290
|
+
const act = async (key, op) => {
|
|
291
|
+
const mutate = watch.mutate;
|
|
292
|
+
if (!mutate)
|
|
293
|
+
return { done: false, note: NO_MUTATE };
|
|
294
|
+
try {
|
|
295
|
+
if (op === 'clear') {
|
|
296
|
+
await mutate(key, undefined, { revalidate: false });
|
|
297
|
+
return { done: true };
|
|
298
|
+
}
|
|
299
|
+
if (op !== 'revalidate' && op !== 'reset')
|
|
300
|
+
return { done: false, note: `SWR has no "${op}"` };
|
|
301
|
+
// A mounted hook revalidates within the call, and its first write sets `isValidating`.
|
|
302
|
+
const call = { key, hit: false };
|
|
303
|
+
probe = call;
|
|
304
|
+
let pending;
|
|
305
|
+
try {
|
|
306
|
+
pending = op === 'revalidate' ? mutate(key) : mutate(key, undefined);
|
|
307
|
+
}
|
|
308
|
+
finally {
|
|
309
|
+
probe = null;
|
|
310
|
+
}
|
|
311
|
+
if (op === 'reset') {
|
|
312
|
+
await pending;
|
|
313
|
+
return call.hit ? { done: true } : { done: true, note: 'Cleared; no mounted hook fetched it again' };
|
|
314
|
+
}
|
|
315
|
+
if (!call.hit) {
|
|
316
|
+
Promise.resolve(pending).catch(noop);
|
|
317
|
+
return { done: false, note: NO_HOOK };
|
|
318
|
+
}
|
|
319
|
+
await settle(pending, REVALIDATE_WAIT);
|
|
320
|
+
return { done: true };
|
|
321
|
+
}
|
|
322
|
+
catch (error) {
|
|
323
|
+
return { done: false, note: errorMessage(error) };
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
return {
|
|
327
|
+
info: { library: 'swr', label, via: 'cache', actions: false, ops: ['revalidate', 'clear', 'reset'] },
|
|
328
|
+
keys,
|
|
329
|
+
summarize: (key) => summarizeSWREntry(key, read(key), marks.get(key)?.at),
|
|
330
|
+
data: (key) => {
|
|
331
|
+
const entry = read(key);
|
|
332
|
+
return entry !== null && typeof entry === 'object' ? entry.data : undefined;
|
|
333
|
+
},
|
|
334
|
+
act,
|
|
335
|
+
start,
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
function isCache(value) {
|
|
339
|
+
if (value === null || typeof value !== 'object')
|
|
340
|
+
return false;
|
|
341
|
+
const cache = value;
|
|
342
|
+
return (typeof cache.get === 'function' &&
|
|
343
|
+
typeof cache.set === 'function' &&
|
|
344
|
+
typeof cache.delete === 'function' &&
|
|
345
|
+
typeof cache.keys === 'function');
|
|
346
|
+
}
|
|
347
|
+
/** Resolves once `pending` settles, or after `ms`. */
|
|
348
|
+
function settle(pending, ms) {
|
|
349
|
+
return new Promise((resolve) => {
|
|
350
|
+
const timer = setTimeout(resolve, ms);
|
|
351
|
+
Promise.resolve(pending)
|
|
352
|
+
.catch(noop)
|
|
353
|
+
.then(() => {
|
|
354
|
+
clearTimeout(timer);
|
|
355
|
+
resolve();
|
|
356
|
+
});
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
//# sourceMappingURL=swr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
2
|
+
import type { StoreDriver } from './index.js';
|
|
3
|
+
export interface WatchQueryClientOptions {
|
|
4
|
+
/** The client's label in the State tab; give each its own when the app has several. Default "QueryClient". */
|
|
5
|
+
name?: string;
|
|
6
|
+
}
|
|
7
|
+
/** What `watchQueryClient` checks for: a TanStack Query `QueryClient`, v5 or v4. */
|
|
8
|
+
export interface QueryClientLike {
|
|
9
|
+
getQueryCache(): unknown;
|
|
10
|
+
getMutationCache(): unknown;
|
|
11
|
+
}
|
|
12
|
+
export type SummarizeQueryFn = typeof summarizeQuery;
|
|
13
|
+
export type SummarizeMutationFn = typeof summarizeMutation;
|
|
14
|
+
/**
|
|
15
|
+
* Shows the client's queries and mutations in the State tab, where a query can be refetched, invalidated,
|
|
16
|
+
* reset, cancelled or removed. Returns a function that stops watching. Does nothing where there is no `window`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function watchQueryClient(client: QueryClientLike, options?: WatchQueryClientOptions): () => void;
|
|
19
|
+
/**
|
|
20
|
+
* Reads a QueryClient for the state engine: queries keyed by `queryHash`, mutations by `m:<mutationId>`.
|
|
21
|
+
* Undefined for anything that is not a QueryClient.
|
|
22
|
+
*/
|
|
23
|
+
export declare function createQueryClientDriver(client: unknown, label: string, summarizeQuery: SummarizeQueryFn, summarizeMutation: SummarizeMutationFn): StoreDriver | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* A query's summary, without its data. `previews` remembers the preview of each data object: TanStack keeps the
|
|
26
|
+
* same object until the data changes, while observer updates summarize the query again and again.
|
|
27
|
+
*/
|
|
28
|
+
export declare function summarizeQuery(query: unknown, previews?: WeakMap<object, string>): StateEntrySummary | undefined;
|
|
29
|
+
/** A mutation without its variables or data. */
|
|
30
|
+
export declare function summarizeMutation(mutation: unknown): StateEntrySummary | undefined;
|
|
31
|
+
//# sourceMappingURL=tanstack.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tanstack.d.ts","sourceRoot":"","sources":["../../../src/plugins/state/tanstack.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAO9C,MAAM,WAAW,uBAAuB;IACtC,8GAA8G;IAC9G,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,oFAAoF;AACpF,MAAM,WAAW,eAAe;IAC9B,aAAa,IAAI,OAAO,CAAC;IACzB,gBAAgB,IAAI,OAAO,CAAC;CAC7B;AAED,MAAM,MAAM,gBAAgB,GAAG,OAAO,cAAc,CAAC;AACrD,MAAM,MAAM,mBAAmB,GAAG,OAAO,iBAAiB,CAAC;AAyD3D;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,uBAAuB,GAAG,MAAM,IAAI,CAsBvG;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,OAAO,EACf,KAAK,EAAE,MAAM,EACb,cAAc,EAAE,gBAAgB,EAChC,iBAAiB,EAAE,mBAAmB,GACrC,WAAW,GAAG,SAAS,CA6LzB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,iBAAiB,GAAG,SAAS,CA4HhH;AAED,gDAAgD;AAChD,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,OAAO,GAAG,iBAAiB,GAAG,SAAS,CAmDlF"}
|