@firsthandjs/data 0.6.3 → 0.7.1
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/dist/cache.d.ts +24 -6
- package/dist/cache.d.ts.map +1 -1
- package/dist/codegen.d.ts +4 -4
- package/dist/codegen.d.ts.map +1 -1
- package/dist/document.d.ts +2 -2
- package/dist/document.d.ts.map +1 -1
- package/dist/http.d.ts +4 -4
- package/dist/http.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.dev.js +75 -2
- package/dist/index.js +2 -2
- package/dist/resource.d.ts +8 -8
- package/dist/resource.d.ts.map +1 -1
- package/dist/store.d.ts +75 -14
- package/dist/store.d.ts.map +1 -1
- package/dist/tags.d.ts +2 -2
- package/dist/tags.d.ts.map +1 -1
- package/dist/vite.d.ts +4 -4
- package/dist/vite.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/cache.d.ts
CHANGED
|
@@ -36,9 +36,18 @@
|
|
|
36
36
|
* was meant to defeat.
|
|
37
37
|
* - **Stays out of an action's way.** A `mutating` request is run and nothing
|
|
38
38
|
* else: not served from here, not shared with anybody, and not kept.
|
|
39
|
-
* - **Forgets.** `forget(key)`, `forget()` for all of it,
|
|
40
|
-
*
|
|
39
|
+
* - **Forgets.** `forget(key)`, `forget()` for all of it, `forgetTagged(…)`
|
|
40
|
+
* for everything an invalidation was about, and the oldest entry goes when
|
|
41
|
+
* `max` is reached.
|
|
42
|
+
*
|
|
43
|
+
* The last of those is the one worth explaining. An entry remembers what the
|
|
44
|
+
* request said it was about, and a store that is given this cache throws those
|
|
45
|
+
* entries away when it invalidates — so a list nobody is watching is not
|
|
46
|
+
* served a stale answer when somebody walks back to it. The tags are
|
|
47
|
+
* **metadata, never the key**: identity is still the scope and the request,
|
|
48
|
+
* which is what ADR-0022 is about and what this deliberately does not undo.
|
|
41
49
|
*/
|
|
50
|
+
import { type Tag } from './tags.js';
|
|
42
51
|
import type { Loader } from './store.js';
|
|
43
52
|
/**
|
|
44
53
|
* A key for a value, stable however the value was written.
|
|
@@ -50,7 +59,7 @@ import type { Loader } from './store.js';
|
|
|
50
59
|
* served for two different requests.
|
|
51
60
|
*/
|
|
52
61
|
export declare function stableKey(value: unknown): string;
|
|
53
|
-
export
|
|
62
|
+
export type CacheOptions = {
|
|
54
63
|
/**
|
|
55
64
|
* How long an answer is served again without running the producer, in ms.
|
|
56
65
|
*
|
|
@@ -69,8 +78,8 @@ export interface CacheOptions {
|
|
|
69
78
|
readonly max?: number;
|
|
70
79
|
/** For tests: what `Date.now()` should be. */
|
|
71
80
|
readonly now?: () => number;
|
|
72
|
-
}
|
|
73
|
-
export
|
|
81
|
+
};
|
|
82
|
+
export type CacheClient = {
|
|
74
83
|
/**
|
|
75
84
|
* Wraps a producer so its answer is kept under `key`.
|
|
76
85
|
*
|
|
@@ -91,8 +100,17 @@ export interface CacheClient {
|
|
|
91
100
|
peek(key: string): unknown;
|
|
92
101
|
/** Forgets one key, or everything. */
|
|
93
102
|
forget(key?: string): void;
|
|
103
|
+
/**
|
|
104
|
+
* Forgets every entry whose request said it was about one of these.
|
|
105
|
+
*
|
|
106
|
+
* What `store.invalidate` calls on a cache it was given. Matching is the
|
|
107
|
+
* tags' own rule — fewer variables match more — and an entry that never said
|
|
108
|
+
* what it was about is never matched, because nothing can be concluded about
|
|
109
|
+
* it.
|
|
110
|
+
*/
|
|
111
|
+
forgetTagged(patterns: readonly Tag[]): void;
|
|
94
112
|
/** How many entries are held, in flight included. */
|
|
95
113
|
readonly size: number;
|
|
96
|
-
}
|
|
114
|
+
};
|
|
97
115
|
export declare function createCacheClient(options?: CacheOptions): CacheClient;
|
|
98
116
|
//# sourceMappingURL=cache.d.ts.map
|
package/dist/cache.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+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ts
CHANGED
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
* are legal.
|
|
41
41
|
*/
|
|
42
42
|
/** The bits of codegen's document shape this needs. Typed here to avoid a dependency. */
|
|
43
|
-
export
|
|
43
|
+
export type CodegenDocument = {
|
|
44
44
|
readonly location?: string | undefined;
|
|
45
45
|
readonly document?: {
|
|
46
46
|
readonly definitions: readonly {
|
|
@@ -51,8 +51,8 @@ export interface CodegenDocument {
|
|
|
51
51
|
} | undefined;
|
|
52
52
|
}[];
|
|
53
53
|
} | undefined;
|
|
54
|
-
}
|
|
55
|
-
export
|
|
54
|
+
};
|
|
55
|
+
export type CodegenConfig = {
|
|
56
56
|
/**
|
|
57
57
|
* Where `typescript-operations` wrote its types, relative to this file.
|
|
58
58
|
*
|
|
@@ -61,7 +61,7 @@ export interface CodegenConfig {
|
|
|
61
61
|
readonly typesPath?: string;
|
|
62
62
|
/** Import path for the document type. Only useful when testing this plugin. */
|
|
63
63
|
readonly documentTypePath?: string;
|
|
64
|
-
}
|
|
64
|
+
};
|
|
65
65
|
/**
|
|
66
66
|
* Generates the module declarations.
|
|
67
67
|
*
|
package/dist/codegen.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codegen.d.ts","sourceRoot":"","sources":["../src/codegen.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,yFAAyF;AACzF,MAAM,
|
|
1
|
+
{"version":3,"file":"codegen.d.ts","sourceRoot":"","sources":["../src/codegen.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,yFAAyF;AACzF,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,QAAQ,CAAC,EACd;QACE,QAAQ,CAAC,WAAW,EAAE,SAAS;YAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;YACtB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;YAC5B,QAAQ,CAAC,IAAI,CAAC,EAAE;gBAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;aAAE,GAAG,SAAS,CAAC;SACxD,EAAE,CAAC;KACL,GACD,SAAS,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B;;;;OAIG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,+EAA+E;IAC/E,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CACpC,CAAC;AA8BF;;;;;;GAMG;AACH,wBAAgB,MAAM,CACpB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,SAAS,eAAe,EAAE,EACrC,MAAM,GAAE,aAAkB,GACzB,MAAM,CAgDR;;;;AAED,wBAA0B"}
|
package/dist/document.d.ts
CHANGED
|
@@ -45,10 +45,10 @@ export type TagValue = {
|
|
|
45
45
|
} | {
|
|
46
46
|
readonly literal: TagVars[string];
|
|
47
47
|
};
|
|
48
|
-
export
|
|
48
|
+
export type TagTemplate = {
|
|
49
49
|
readonly name: string;
|
|
50
50
|
readonly vars: Readonly<Record<string, TagValue>>;
|
|
51
|
-
}
|
|
51
|
+
};
|
|
52
52
|
/**
|
|
53
53
|
* A parsed operation, carrying what it returns and what it needs.
|
|
54
54
|
*
|
package/dist/document.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../src/document.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,OAAO,EAAO,KAAK,GAAG,EAAE,KAAK,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAGxE,sEAAsE;AACtE,MAAM,MAAM,QAAQ,GAAG;IAAE,QAAQ,C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QAAQ,CAAC,SAAS,CAAC,EAAE,UAAU,CAAC;CACjC;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,iBAAiB,CAAC,UAAU,SAAS,SAAS,IACxD,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,SAAS,UAAU,GAAG,CAAC,SAAS,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;AAMhG,iEAAiE;AACjE,qBAAa,uBAAwB,SAAQ,KAAK;gBACpC,OAAO,EAAE,MAAM;CAI5B;AAqND;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,KAAK,GAAG,OAAO,EAAE,UAAU,SAAS,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAChG,MAAM,EAAE,MAAM,GACb,eAAe,CAAC,KAAK,EAAE,UAAU,CAAC,CAYpC;AAED,sDAAsD;AACtD,wBAAgB,WAAW,CAAC,SAAS,EAAE,SAAS,WAAW,EAAE,EAAE,SAAS,EAAE,SAAS,GAAG,GAAG,EAAE,CAiB1F"}
|
package/dist/http.d.ts
CHANGED
|
@@ -51,7 +51,7 @@ export interface JsonRequest extends Omit<RequestInit, 'body'> {
|
|
|
51
51
|
*/
|
|
52
52
|
readonly cacheKey?: string | false;
|
|
53
53
|
}
|
|
54
|
-
export
|
|
54
|
+
export type FetchClientOptions = {
|
|
55
55
|
/** Prefixed to every relative path. A path beginning with `http` is left alone. */
|
|
56
56
|
readonly baseUrl?: string;
|
|
57
57
|
/**
|
|
@@ -91,8 +91,8 @@ export interface FetchClientOptions {
|
|
|
91
91
|
* and keep that in one place rather than in a plugin system.
|
|
92
92
|
*/
|
|
93
93
|
readonly fetch?: typeof globalThis.fetch;
|
|
94
|
-
}
|
|
95
|
-
export
|
|
94
|
+
};
|
|
95
|
+
export type FetchClient = {
|
|
96
96
|
/** Any method: the general form the others are named shortcuts for. */
|
|
97
97
|
request<T>(url: string, init?: JsonRequest): Loader<T>;
|
|
98
98
|
get<T>(url: string, init?: JsonRequest): Loader<T>;
|
|
@@ -109,6 +109,6 @@ export interface FetchClient {
|
|
|
109
109
|
with(options: FetchClientOptions): FetchClient;
|
|
110
110
|
/** The cache this client keeps its answers in, if it has one. */
|
|
111
111
|
readonly cache: CacheClient | undefined;
|
|
112
|
-
}
|
|
112
|
+
};
|
|
113
113
|
export declare function createFetchClient(options?: FetchClientOptions): FetchClient;
|
|
114
114
|
//# sourceMappingURL=http.d.ts.map
|
package/dist/http.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AA8BA,OAAO,EAAqB,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AACpF,OAAO,KAAK,EAAe,MAAM,EAAE,MAAM,YAAY,CAAC;AAEtD;;;;;GAKG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IAEzC,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM;IACpB,yCAAyC;IACzC,QAAQ,CAAC,IAAI,EAAE,OAAO;gBAHb,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM;IACpB,yCAAyC;IAChC,IAAI,EAAE,OAAO;CAKzB;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,WAAY,SAAQ,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC;IAC5D,QAAQ,CAAC,IAAI,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IAChC,6EAA6E;IAC7E,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IACxB;;;;;;;;;;;;;;;;;OAiBG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;CACpC;AAED,MAAM,
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AA8BA,OAAO,EAAqB,KA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M,MAAM,WAAW,GAAG;IACxB,uEAAuE;IACvE,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACvD,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACnD,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACpD,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACnD,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACrD,mEAAmE;IACnE,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACtD;;;;OAIG;IACH,IAAI,CAAC,OAAO,EAAE,kBAAkB,GAAG,WAAW,CAAC;IAC/C,iEAAiE;IACjE,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,CAAC;CACzC,CAAC;AAmDF,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,kBAAuB,GAAG,WAAW,CAoE/E"}
|
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
export { createData, DataContext, useData, useInvalidate } from './resource.js';
|
|
10
10
|
export { useResource, useAction, fromObservable, fromPromise } from './resource.js';
|
|
11
11
|
export type { Action, ObservableLike, BridgeOptions, ResourceOptions } from './resource.js';
|
|
12
|
-
export type { ActionContext, DataOptions, DataRequest, DataStore, LoadContext, Loader, Resource, Status, Storage, } from './store.js';
|
|
12
|
+
export type { ActionContext, DataOptions, DataRequest, Forgetful, DataStore, LoadContext, Loader, Resource, Status, Storage, } from './store.js';
|
|
13
13
|
/**
|
|
14
14
|
* The cache — one of them, and the transport's.
|
|
15
15
|
*
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACpF,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAC5F,YAAY,EACV,aAAa,EACb,WAAW,EACX,WAAW,EACX,SAAS,EACT,WAAW,EACX,MAAM,EACN,QAAQ,EACR,MAAM,EACN,OAAO,GACR,MAAM,YAAY,CAAC;AAEpB;;;;;;GAMG;AACH,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC1D,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE5D,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC3D,YAAY,EAAE,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEzD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AACnF,YAAY,EAAE,iBAAiB,EAAE,eAAe,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE/F;;;GAGG;AACH,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAClE,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACpF,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAC5F,YAAY,EACV,aAAa,EACb,WAAW,EACX,WAAW,EACX,SAAS,EACT,SAAS,EACT,WAAW,EACX,MAAM,EACN,QAAQ,EACR,MAAM,EACN,OAAO,GACR,MAAM,YAAY,CAAC;AAEpB;;;;;;GAMG;AACH,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC1D,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE5D,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC3D,YAAY,EAAE,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEzD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AACnF,YAAY,EAAE,iBAAiB,EAAE,eAAe,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE/F;;;GAGG;AACH,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAClE,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/index.dev.js
CHANGED
|
@@ -57,14 +57,42 @@ function readable(value) {
|
|
|
57
57
|
// packages/data/src/store.ts
|
|
58
58
|
function createData(options = {}) {
|
|
59
59
|
const held = /* @__PURE__ */ new Set();
|
|
60
|
+
const remember = options.remember ?? 6e4;
|
|
61
|
+
let recent = [];
|
|
62
|
+
const now = () => Date.now();
|
|
60
63
|
return {
|
|
61
64
|
storage: options.storage,
|
|
65
|
+
missed: (entry, tags) => {
|
|
66
|
+
if (remember === 0 || recent.length === 0) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
const since = now() - remember;
|
|
70
|
+
recent = recent.filter((one) => one.at >= since);
|
|
71
|
+
return recent.some(
|
|
72
|
+
// Younger than this resource's last answer, and about what it has just
|
|
73
|
+
// said it is about. A resource that has answered *since* the
|
|
74
|
+
// invalidation has already taken it into account.
|
|
75
|
+
(one) => one.at > entry.answeredAt && anyTagMatches(one.patterns, tags)
|
|
76
|
+
);
|
|
77
|
+
},
|
|
78
|
+
settled: (tags) => {
|
|
79
|
+
if (recent.length === 0) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
recent = recent.filter((one) => !anyTagMatches(one.patterns, tags));
|
|
83
|
+
},
|
|
62
84
|
hold: (entry) => {
|
|
63
85
|
held.add(entry);
|
|
64
86
|
return () => held.delete(entry);
|
|
65
87
|
},
|
|
66
88
|
invalidate: async (...patterns) => {
|
|
67
89
|
const waiting = [];
|
|
90
|
+
for (const cache of options.caches ?? []) {
|
|
91
|
+
cache.forgetTagged(patterns);
|
|
92
|
+
}
|
|
93
|
+
if (remember > 0) {
|
|
94
|
+
recent.push({ patterns, at: now() });
|
|
95
|
+
}
|
|
68
96
|
for (const entry of [...held]) {
|
|
69
97
|
if (entry.controller !== null) {
|
|
70
98
|
entry.pending.push(...patterns);
|
|
@@ -78,6 +106,7 @@ function createData(options = {}) {
|
|
|
78
106
|
await Promise.all(waiting);
|
|
79
107
|
},
|
|
80
108
|
clear: () => {
|
|
109
|
+
recent = [];
|
|
81
110
|
for (const entry of [...held]) {
|
|
82
111
|
entry.controller?.abort();
|
|
83
112
|
held.delete(entry);
|
|
@@ -103,11 +132,13 @@ function createHeld(store, name) {
|
|
|
103
132
|
pending: [],
|
|
104
133
|
superseded: false,
|
|
105
134
|
disposed: false,
|
|
135
|
+
answeredAt: 0,
|
|
106
136
|
name
|
|
107
137
|
};
|
|
108
138
|
return entry;
|
|
109
139
|
}
|
|
110
140
|
function succeed(entry, value) {
|
|
141
|
+
entry.answeredAt = Date.now();
|
|
111
142
|
batch(() => {
|
|
112
143
|
entry.data.value = value;
|
|
113
144
|
entry.error.value = void 0;
|
|
@@ -164,20 +195,51 @@ function useResource(load, options = {}) {
|
|
|
164
195
|
if (entry.data.peek() === void 0) {
|
|
165
196
|
entry.status.value = "loading";
|
|
166
197
|
}
|
|
198
|
+
let forced = force;
|
|
199
|
+
let asked = false;
|
|
167
200
|
const declare = (...next) => {
|
|
168
201
|
entry.tags = next;
|
|
202
|
+
if (!forced && store.missed(entry, next)) {
|
|
203
|
+
forced = true;
|
|
204
|
+
if (asked) {
|
|
205
|
+
entry.superseded = true;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
169
208
|
if (entry.pending.length > 0 && anyTagMatches(entry.pending, next)) {
|
|
170
209
|
entry.superseded = true;
|
|
171
210
|
}
|
|
172
211
|
};
|
|
173
|
-
const request = {
|
|
174
|
-
|
|
212
|
+
const request = {
|
|
213
|
+
signal: controller.signal,
|
|
214
|
+
get force() {
|
|
215
|
+
asked = true;
|
|
216
|
+
return forced;
|
|
217
|
+
},
|
|
218
|
+
// Read after `tags()` by a cache that keeps them, which is every client
|
|
219
|
+
// in this project: they declare first and look in their cache second.
|
|
220
|
+
get declared() {
|
|
221
|
+
return entry.tags;
|
|
222
|
+
},
|
|
223
|
+
tags: declare
|
|
224
|
+
};
|
|
225
|
+
const context = {
|
|
226
|
+
signal: controller.signal,
|
|
227
|
+
get force() {
|
|
228
|
+
asked = true;
|
|
229
|
+
return forced;
|
|
230
|
+
},
|
|
231
|
+
request,
|
|
232
|
+
tags: declare
|
|
233
|
+
};
|
|
175
234
|
return load(context).then(async (value) => {
|
|
176
235
|
if (controller.signal.aborted || entry.disposed) {
|
|
177
236
|
return void 0;
|
|
178
237
|
}
|
|
179
238
|
entry.controller = null;
|
|
180
239
|
succeed(entry, value);
|
|
240
|
+
if (!entry.superseded) {
|
|
241
|
+
store.settled(entry.tags);
|
|
242
|
+
}
|
|
181
243
|
if (options.persist !== void 0) {
|
|
182
244
|
try {
|
|
183
245
|
store.storage?.write?.(options.persist, value);
|
|
@@ -371,6 +433,7 @@ function createCacheClient(options = {}) {
|
|
|
371
433
|
write: (key, value) => {
|
|
372
434
|
keep(key, {
|
|
373
435
|
value,
|
|
436
|
+
tags: [],
|
|
374
437
|
expires: ttl === 0 ? Infinity : now() + ttl,
|
|
375
438
|
inflight: null,
|
|
376
439
|
controller: null,
|
|
@@ -386,6 +449,13 @@ function createCacheClient(options = {}) {
|
|
|
386
449
|
}
|
|
387
450
|
drop(key);
|
|
388
451
|
},
|
|
452
|
+
forgetTagged: (patterns) => {
|
|
453
|
+
for (const [key, entry] of [...entries]) {
|
|
454
|
+
if (entry.tags.length > 0 && anyTagMatches(patterns, entry.tags)) {
|
|
455
|
+
drop(key);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
},
|
|
389
459
|
read: (key, produce) => async (request) => {
|
|
390
460
|
if (request.mutating === true) {
|
|
391
461
|
return await produce(request);
|
|
@@ -406,6 +476,9 @@ function createCacheClient(options = {}) {
|
|
|
406
476
|
const controller = new AbortController();
|
|
407
477
|
const entry = {
|
|
408
478
|
value: void 0,
|
|
479
|
+
// What the request has been declared to be about by now. A client
|
|
480
|
+
// declares before it looks here, which is what makes this possible.
|
|
481
|
+
tags: request.declared ?? [],
|
|
409
482
|
expires: 0,
|
|
410
483
|
inflight: null,
|
|
411
484
|
controller,
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createContext as z,effect as N,onCleanup as D,untrack as
|
|
2
|
-
`,a);a=
|
|
1
|
+
import{createContext as z,effect as N,onCleanup as D,untrack as _,useContext as M}from"@firsthandjs/core";import{batch as S,signal as b}from"@firsthandjs/core";var H=Object.freeze({});function R(e,n=H){return{name:e,vars:n}}function L(e,n){if(e.name!==n.name)return!1;for(let r of Object.keys(e.vars))if(!Object.is(e.vars[r],n.vars[r]))return!1;return!0}function y(e,n){for(let r of e)for(let t of n)if(L(r,t))return!0;return!1}function A(e={}){let n=new Set,r=e.remember??6e4,t=[],a=()=>Date.now();return{storage:e.storage,missed:(s,l)=>{if(r===0||t.length===0)return!1;let o=a()-r;return t=t.filter(i=>i.at>=o),t.some(i=>i.at>s.answeredAt&&y(i.patterns,l))},settled:s=>{t.length!==0&&(t=t.filter(l=>!y(l.patterns,s)))},hold:s=>(n.add(s),()=>n.delete(s)),invalidate:async(...s)=>{let l=[];for(let o of e.caches??[])o.forgetTagged(s);r>0&&t.push({patterns:s,at:a()});for(let o of[...n])o.controller!==null&&o.pending.push(...s),y(s,o.tags)&&(o.name,o.tags,l.push(o.run(!0)));await Promise.all(l)},clear:()=>{t=[];for(let s of[...n])s.controller?.abort(),n.delete(s);try{e.storage?.clear?.()}catch{}},get size(){return n.size}}}function x(e,n){return{data:b(void 0),error:b(void 0),status:b("idle"),loading:b(!1),tags:[],controller:null,pending:[],superseded:!1,disposed:!1,answeredAt:0,name:n}}function m(e,n){e.answeredAt=Date.now(),S(()=>{e.data.value=n,e.error.value=void 0,e.status.value="success",e.loading.value=!1})}function v(e,n){S(()=>{e.error.value=n,e.status.value="error",e.loading.value=!1})}function C(e,n){return{data:e.data,error:e.error,status:e.status,loading:e.loading,reload:()=>e.run(!0),dispose:()=>{e.disposed=!0,e.controller?.abort(),n()}}}var P=z();function h(){return M(P).value}function Q(){let e=h();return(...n)=>e.invalidate(...n)}function V(e,n={}){let r=h(),t=x(r,n.persist),a=r.hold(t);n.persist,t.run=o=>{if(t.disposed)return Promise.resolve(void 0);t.controller?.abort();let i=new AbortController;t.controller=i,t.pending=[],t.superseded=!1,t.loading.value=!0,t.data.peek()===void 0&&(t.status.value="loading");let d=o,u=!1,f=(...c)=>{t.tags=c,!d&&r.missed(t,c)&&(d=!0,u&&(t.superseded=!0)),t.pending.length>0&&y(t.pending,c)&&(t.superseded=!0)},g={signal:i.signal,get force(){return u=!0,d},get declared(){return t.tags},tags:f},T={signal:i.signal,get force(){return u=!0,d},request:g,tags:f};return e(T).then(async c=>{if(!(i.signal.aborted||t.disposed)){if(t.controller=null,m(t,c),t.superseded||r.settled(t.tags),n.persist!==void 0)try{r.storage?.write?.(n.persist,c)}catch{}return t.superseded?(t.superseded=!1,t.run(!0)):c}}).catch(c=>{i.signal.aborted||t.disposed||(t.controller=null,v(t,c))})};let s=n.persist,l=r.storage;return s!==void 0&&l?.read!==void 0&&(async()=>{try{let o=await l.read?.(s);o!==void 0&&t.data.peek()===void 0&&!t.disposed&&(m(t,o),t.loading.value=!0)}catch{}})(),N(()=>{t.run(!1)}),D(()=>{t.disposed=!0,t.controller?.abort(),n.persist,t.tags,a()}),C(t,a)}function G(e){let n=h(),r=x(n,void 0),t=null;return D(()=>{r.disposed=!0,t?.abort()}),{data:r.data,error:r.error,status:r.status,running:r.loading,run:async a=>{t?.abort(),t=new AbortController;let s=t,l=[];r.loading.value=!0,r.status.value="loading";try{let o=(...d)=>{l=d},i=await _(()=>e(a,{signal:s.signal,invalidates:o,request:{signal:s.signal,force:!0,mutating:!0,tags:o}}));return s.signal.aborted||r.disposed?void 0:(m(r,i),l.length>0&&await n.invalidate(...l),i)}catch(o){if(s.signal.aborted||r.disposed)return;v(r,o);return}}}}function K(e,n={}){let r=h(),t=x(r,void 0),a=r.hold(t);t.run=()=>n.reload===void 0?Promise.resolve(void 0):U(n.reload()),t.loading.value=!0,t.status.value="loading";let s=e.subscribe({next:o=>{m(t,o)},error:o=>{v(t,o)}}),l=typeof s=="function"?s:()=>{s.unsubscribe()};return D(()=>{t.disposed=!0,l(),a()}),C(t,()=>{l(),a()})}function B(e){return V(()=>e())}async function U(e){await e}function k(e){return e===void 0?"undefined":e===null||typeof e!="object"?JSON.stringify(e):Array.isArray(e)?`[${e.map(k).join(",")}]`:e instanceof Date?e.toISOString():`{${Object.entries(e).filter(([,r])=>r!==void 0).sort(([r],[t])=>r<t?-1:1).map(([r,t])=>`${r}:${k(t)}`).join(",")}}`}function O(e={}){let n=e.ttl??0,r=e.max??100,t=e.now??(()=>Date.now()),a=new Map,s=o=>{a.get(o)?.controller?.abort(),a.delete(o)},l=(o,i)=>{if(a.delete(o),a.set(o,i),a.size>r)for(let d of a.keys()){s(d);break}};return{get size(){return a.size},peek:o=>{let i=a.get(o);if(!(i===void 0||i.expires<=t()))return i.value},write:(o,i)=>{l(o,{value:i,tags:[],expires:n===0?1/0:t()+n,inflight:null,controller:null,waiting:0})},forget:o=>{if(o===void 0){for(let i of[...a.keys()])s(i);return}s(o)},forgetTagged:o=>{for(let[i,d]of[...a])d.tags.length>0&&y(o,d.tags)&&s(i)},read:(o,i)=>async d=>{if(d.mutating===!0)return await i(d);let u=a.get(o);if(d.force)s(o);else if(u!==void 0){if(u.inflight!==null)return await $(u,d);if(u.expires>t())return l(o,u),u.value;a.delete(o)}let f=new AbortController,g={value:void 0,tags:d.declared??[],expires:0,inflight:null,controller:f,waiting:0},T=i({signal:f.signal,force:d.force}).then(c=>(a.get(o)===g&&(n===0?a.delete(o):(g.value=c,g.expires=t()+n,g.inflight=null,g.controller=null)),c)).catch(c=>{throw a.get(o)===g&&a.delete(o),c});return g.inflight=T,l(o,g),await $(g,d)}}}async function $(e,n){e.waiting+=1;let r=()=>{e.waiting<=1&&e.inflight!==null&&e.controller?.abort()};n.signal.addEventListener("abort",r,{once:!0});try{return await e.inflight}finally{n.signal.removeEventListener("abort",r),e.waiting-=1}}var Z=/^@(tag|invalidates)\b/,W=/\b(query|mutation|subscription)\b[^\S\n]*([A-Za-z_]\w*)?/,E=/^[_A-Za-z][_0-9A-Za-z]*/,p=class extends Error{constructor(n){super(n),this.name="FirsthandDirectiveError"}};function q(e,n){if(e.startsWith('"""',n)){let t=e.indexOf('"""',n+3);return t===-1?e.length:t+3}let r=n+1;for(;r<e.length&&e[r]!=='"';)r+=e[r]==="\\"?2:1;return r+1}function X(e,n){let r=0,t=n;for(;t<e.length;){let a=e[t];if(a==='"'){t=q(e,t);continue}if(a==="("||a==="["||a==="{")r++;else if((a===")"||a==="]"||a==="}")&&(r--,r===0))return t+1;t++}throw new p(`unclosed arguments in ${e.slice(n,n+40)}`)}function Y(e,n){try{return JSON.parse(e)}catch{throw new p(`@${n}: ${e} is not a valid string`)}}function ee(e,n){let r={},t=0,a=()=>{for(;t<e.length&&/[\s,]/.test(e[t]);)t++};for(a();t<e.length;){let s=E.exec(e.slice(t));if(s===null)throw new p(`@${n}: expected an argument name at "${e.slice(t)}"`);if(t+=s[0].length,a(),e[t]!==":")throw new p(`@${n}: argument ${s[0]} has no value`);t++,a();let l=te(e,n,t);r[s[0]]=l.value,t=l.next,a()}return r}function te(e,n,r){let t=e[r];if(t==="$"){let i=E.exec(e.slice(r+1));if(i===null)throw new p(`@${n}: expected a variable name after $`);return{value:{variable:i[0]},next:r+1+i[0].length}}if(t==='"'){let i=q(e,r),d=e.slice(r,i);return{value:{literal:d.startsWith('"""')?d.slice(3,-3).trim():Y(d,n)},next:i}}if(t==="["||t==="{")throw new p(`@${n}: a tag variable must be a scalar, not a list or object`);let a=/^[^\s,)]+/.exec(e.slice(r));if(a===null)throw new p(`@${n}: expected a value`);let s=a[0],l=r+s.length;if(s==="true"||s==="false")return{value:{literal:s==="true"},next:l};if(s==="null")return{value:{literal:null},next:l};let o=Number(s);return{value:{literal:Number.isNaN(o)?s:o},next:l}}function ne(e){let n=[],r=[],t="",a=0,s=0;for(;a<e.length;){let l=e[a];if(l==='"'){a=q(e,a);continue}if(l==="#"){let c=e.indexOf(`
|
|
2
|
+
`,a);a=c===-1?e.length:c;continue}if(l!=="@"){a++;continue}let o=Z.exec(e.slice(a));if(o===null){a++;continue}let i=a+o[0].length,d="",u=i;for(;u<e.length&&/\s/.test(e[u]);)u++;if(e[u]==="("){let c=X(e,u);d=e.slice(u+1,c-1),i=c}let f=ee(d,o[1]),g=f.name;if(g===void 0||!("literal"in g)||typeof g.literal!="string")throw new p(`@${o[1]} needs a literal name, as in @${o[1]}(name: "user", id: $id)`);delete f.name,(o[1]==="tag"?n:r).push({name:g.literal,vars:f});let T=a;for(;T>s&&/\s/.test(e[T-1]);)T--;t+=e.slice(s,T),s=i,a=i}return{tags:n,invalidates:r,stripped:t+e.slice(s)}}function re(e){let{tags:n,invalidates:r,stripped:t}=ne(e),a=W.exec(t.replace(/#[^\n]*/g,""));return{source:t,operation:a?.[2]??"",kind:a?.[1]??"query",tags:n,invalidates:r}}function ae(e,n){return e.map(r=>{let t={};for(let[a,s]of Object.entries(r.vars)){if("literal"in s){t[a]=s.literal;continue}let l=n[s.variable];l!=null&&(t[a]=typeof l=="object"?JSON.stringify(l):l)}return R(r.name,t)})}import{untrack as I}from"@firsthandjs/core";var w=class extends Error{constructor(r,t,a){super(`HTTP ${String(r)} for ${t}`);this.status=r;this.url=t;this.body=a;this.name="FirsthandHttpError"}status;url;body};function oe(e,n,r){let t=/^[a-z]+:\/\//i.test(n)?n:`${e.baseUrl??""}${n}`,{json:a,cacheKey:s,...l}=r,o={...e.init,...l},i=new Headers(typeof e.headers=="function"?I(e.headers):e.headers);for(let[d,u]of new Headers(r.headers??{}))i.set(d,u);return a!==void 0&&(o.body=JSON.stringify(a),i.has("content-type")||i.set("content-type","application/json")),o.headers=i,[t,o]}async function F(e,n,r,t){let s=await(e.fetch??globalThis.fetch)(n,{...r,signal:t.signal}),l=await s.text(),o=l===""?void 0:JSON.parse(l);if(!s.ok)throw new w(s.status,n,o);return o}function j(e={}){let n=e.cache===void 0||e.cache===!1?void 0:"read"in e.cache?e.cache:O(e.cache),r={cache:n,request:(t,a={})=>async s=>{let[l,o]=oe(e,t,a),i=(o.method??"GET").toUpperCase(),d=e.scope===void 0?o.headers.get("authorization")??"":I(e.scope),u=typeof a.cacheKey=="string"?a.cacheKey:i==="GET"||i==="HEAD"?`${i} ${l}`:void 0,f=u===void 0?void 0:`${d}\0${u}`;return n===void 0||a.cacheKey===!1||f===void 0||s.mutating===!0?await F(e,l,o,s):await n.read(f,g=>F(e,l,o,g))(s)},get:(t,a={})=>r.request(t,a),post:(t,a={})=>r.request(t,{method:"POST",...a}),put:(t,a={})=>r.request(t,{method:"PUT",...a}),patch:(t,a={})=>r.request(t,{method:"PATCH",...a}),remove:(t,a={})=>r.request(t,{method:"DELETE",...a}),with:t=>j({...e,...t,cache:t.cache??n??!1})};return r}export{P as DataContext,p as FirsthandDirectiveError,w as FirsthandHttpError,y as anyTagMatches,O as createCacheClient,A as createData,j as createFetchClient,K as fromObservable,B as fromPromise,re as parseGraphQL,ae as resolveTags,k as stableKey,R as tag,L as tagMatches,G as useAction,h as useData,Q as useInvalidate,V as useResource};
|
package/dist/resource.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare const DataContext: import("@firsthandjs/core").Context<DataStore>
|
|
|
5
5
|
export declare function useData(): DataStore;
|
|
6
6
|
/** Invalidates through the store this component is under. */
|
|
7
7
|
export declare function useInvalidate(): (...patterns: Tag[]) => Promise<void>;
|
|
8
|
-
export
|
|
8
|
+
export type ResourceOptions = {
|
|
9
9
|
/**
|
|
10
10
|
* A name to keep this resource's last value under, between visits.
|
|
11
11
|
*
|
|
@@ -15,7 +15,7 @@ export interface ResourceOptions {
|
|
|
15
15
|
* naming them the same asks for.
|
|
16
16
|
*/
|
|
17
17
|
readonly persist?: string;
|
|
18
|
-
}
|
|
18
|
+
};
|
|
19
19
|
/**
|
|
20
20
|
* Loads something, and keeps it as reactive state.
|
|
21
21
|
*
|
|
@@ -31,14 +31,14 @@ export interface ResourceOptions {
|
|
|
31
31
|
* if that is not what you want.
|
|
32
32
|
*/
|
|
33
33
|
export declare function useResource<T>(load: (context: LoadContext) => Promise<T>, options?: ResourceOptions): Resource<T>;
|
|
34
|
-
export
|
|
34
|
+
export type Action<I, R> = {
|
|
35
35
|
readonly data: Resource<R>['data'];
|
|
36
36
|
readonly error: Resource<R>['error'];
|
|
37
37
|
readonly status: Resource<R>['status'];
|
|
38
38
|
readonly running: Resource<R>['loading'];
|
|
39
39
|
/** Runs it. Never rejects: failure is reported through `error`. */
|
|
40
40
|
run(input: I): Promise<R | undefined>;
|
|
41
|
-
}
|
|
41
|
+
};
|
|
42
42
|
/**
|
|
43
43
|
* Changes something, and says what it changed.
|
|
44
44
|
*
|
|
@@ -51,18 +51,18 @@ export interface Action<I, R> {
|
|
|
51
51
|
* ```
|
|
52
52
|
*/
|
|
53
53
|
export declare function useAction<I, R>(run: (input: I, context: ActionContext) => Promise<R>): Action<I, R>;
|
|
54
|
-
export
|
|
54
|
+
export type ObservableLike<T> = {
|
|
55
55
|
subscribe(observer: {
|
|
56
56
|
next?: (value: T) => void;
|
|
57
57
|
error?: (error: unknown) => void;
|
|
58
58
|
}): {
|
|
59
59
|
unsubscribe: () => void;
|
|
60
60
|
} | (() => void);
|
|
61
|
-
}
|
|
62
|
-
export
|
|
61
|
+
};
|
|
62
|
+
export type BridgeOptions = {
|
|
63
63
|
/** What `reload()` should do, if the source can do it. */
|
|
64
64
|
readonly reload?: () => Promise<unknown>;
|
|
65
|
-
}
|
|
65
|
+
};
|
|
66
66
|
/**
|
|
67
67
|
* A source that pushes, as a resource.
|
|
68
68
|
*
|
package/dist/resource.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../src/resource.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAKL,KAAK,aAAa,EAElB,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,QAAQ,EACb,KAAK,MAAM,EACZ,MAAM,YAAY,CAAC;AACpB,OAAO,EAAiB,KAAK,GAAG,EAAE,MAAM,WAAW,CAAC;AAGpD,eAAO,MA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W,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC"}
|
package/dist/store.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export type Status = 'idle' | 'loading' | 'success' | 'error';
|
|
|
29
29
|
* memory would make that invalidation silently pointless. Every client in this
|
|
30
30
|
* project takes this object and honours both.
|
|
31
31
|
*/
|
|
32
|
-
export
|
|
32
|
+
export type DataRequest = {
|
|
33
33
|
/** Aborted when this run is superseded, or the resource goes away. */
|
|
34
34
|
readonly signal: AbortSignal;
|
|
35
35
|
/**
|
|
@@ -54,6 +54,15 @@ export interface DataRequest {
|
|
|
54
54
|
* is "do not answer me from memory"; this is "do not remember me".
|
|
55
55
|
*/
|
|
56
56
|
readonly mutating?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* What this request has been said to be about, if anything.
|
|
59
|
+
*
|
|
60
|
+
* A cache may keep it beside the entry — as metadata, never as the key —
|
|
61
|
+
* so that an invalidation can throw the entry away instead of waiting for
|
|
62
|
+
* somebody to ask for it again. Identity stays what it was: the scope and
|
|
63
|
+
* the request (ADR-0022, ADR-0025).
|
|
64
|
+
*/
|
|
65
|
+
readonly declared?: readonly Tag[];
|
|
57
66
|
/**
|
|
58
67
|
* Where a client reports what this request is about, when it knows.
|
|
59
68
|
*
|
|
@@ -65,7 +74,7 @@ export interface DataRequest {
|
|
|
65
74
|
* nothing to say.
|
|
66
75
|
*/
|
|
67
76
|
readonly tags?: (...tags: Tag[]) => void;
|
|
68
|
-
}
|
|
77
|
+
};
|
|
69
78
|
/** What a loader is given. */
|
|
70
79
|
export interface LoadContext extends DataRequest {
|
|
71
80
|
/**
|
|
@@ -81,7 +90,7 @@ export interface LoadContext extends DataRequest {
|
|
|
81
90
|
readonly request: DataRequest;
|
|
82
91
|
}
|
|
83
92
|
/** What an action is given. */
|
|
84
|
-
export
|
|
93
|
+
export type ActionContext = {
|
|
85
94
|
readonly signal: AbortSignal;
|
|
86
95
|
/**
|
|
87
96
|
* Declares what this action changed, so resources carrying a matching tag
|
|
@@ -94,10 +103,10 @@ export interface ActionContext {
|
|
|
94
103
|
* changes something, so nothing it sends may be answered from a cache.
|
|
95
104
|
*/
|
|
96
105
|
readonly request: DataRequest;
|
|
97
|
-
}
|
|
106
|
+
};
|
|
98
107
|
/** What a client hands back: a request waiting for the context to send it. */
|
|
99
108
|
export type Loader<T> = (request: DataRequest) => Promise<T>;
|
|
100
|
-
export
|
|
109
|
+
export type Resource<T> = {
|
|
101
110
|
readonly data: ReadonlyCell<T | undefined>;
|
|
102
111
|
readonly error: ReadonlyCell<unknown>;
|
|
103
112
|
readonly status: ReadonlyCell<Status>;
|
|
@@ -107,9 +116,9 @@ export interface Resource<T> {
|
|
|
107
116
|
reload(): Promise<T | undefined>;
|
|
108
117
|
/** Stops this resource and aborts anything in flight. */
|
|
109
118
|
dispose(): void;
|
|
110
|
-
}
|
|
119
|
+
};
|
|
111
120
|
/** Somewhere to keep results between visits. See {@link DataOptions}. */
|
|
112
|
-
export
|
|
121
|
+
export type Storage = {
|
|
113
122
|
/**
|
|
114
123
|
* What was kept under this name, if anything. May return a promise; a value
|
|
115
124
|
* that arrives after the loader has answered is dropped.
|
|
@@ -119,12 +128,52 @@ export interface Storage {
|
|
|
119
128
|
write?(name: string, data: unknown): void;
|
|
120
129
|
/** Called by `store.clear()`, which is what a sign-out calls. */
|
|
121
130
|
clear?(): void;
|
|
122
|
-
}
|
|
123
|
-
export
|
|
131
|
+
};
|
|
132
|
+
export type DataOptions = {
|
|
124
133
|
/** Where named resources are kept between visits. */
|
|
125
134
|
readonly storage?: Storage;
|
|
126
|
-
|
|
127
|
-
|
|
135
|
+
/**
|
|
136
|
+
* Caches to empty when something is invalidated.
|
|
137
|
+
*
|
|
138
|
+
* A cache given here is told which tags were invalidated, and drops the
|
|
139
|
+
* entries whose requests said they were about them — so a list nobody is
|
|
140
|
+
* watching does not keep a stale answer for anybody who walks back to it.
|
|
141
|
+
* The tags are metadata on the entry; identity is still the scope and the
|
|
142
|
+
* request (ADR-0025).
|
|
143
|
+
*
|
|
144
|
+
* A cache that is *not* given here is not touched, which is the right
|
|
145
|
+
* default for somebody else's: Apollo's and urql's caches are theirs, and
|
|
146
|
+
* `force` is how a run reaches past them.
|
|
147
|
+
*/
|
|
148
|
+
readonly caches?: readonly Forgetful[];
|
|
149
|
+
/**
|
|
150
|
+
* How long an invalidation is remembered for resources that did not exist
|
|
151
|
+
* when it happened, in ms. Default 60 000; `0` switches it off.
|
|
152
|
+
*
|
|
153
|
+
* An invalidation reaches every resource that is **alive**. Nothing is
|
|
154
|
+
* watching a list while you are two pages away from it, so a mutation there
|
|
155
|
+
* reaches nothing — and walking back creates a *new* resource, which asks
|
|
156
|
+
* the transport, which may still be holding the answer from before.
|
|
157
|
+
*
|
|
158
|
+
* So the store remembers what was invalidated and when. A resource whose
|
|
159
|
+
* first run declares a tag that was invalidated since it was created runs
|
|
160
|
+
* with `force`, which is what makes it reach past a cache exactly once. The
|
|
161
|
+
* window exists because the memory is about a cache's contents, and a cache
|
|
162
|
+
* entry does not live for ever; a minute is longer than any sensible `ttl`
|
|
163
|
+
* and short enough to be forgotten.
|
|
164
|
+
*/
|
|
165
|
+
readonly remember?: number;
|
|
166
|
+
};
|
|
167
|
+
/**
|
|
168
|
+
* The part of a cache a store touches: what to forget, and nothing else.
|
|
169
|
+
*
|
|
170
|
+
* Declared structurally so that the store depends on no cache in particular —
|
|
171
|
+
* ours satisfies it, and so does thirty lines of somebody's own.
|
|
172
|
+
*/
|
|
173
|
+
export type Forgetful = {
|
|
174
|
+
forgetTagged(patterns: readonly Tag[]): void;
|
|
175
|
+
};
|
|
176
|
+
type Held<T = unknown> = {
|
|
128
177
|
data: Signal<T | undefined>;
|
|
129
178
|
error: Signal<unknown>;
|
|
130
179
|
status: Signal<Status>;
|
|
@@ -138,9 +187,11 @@ interface Held<T = unknown> {
|
|
|
138
187
|
superseded: boolean;
|
|
139
188
|
disposed: boolean;
|
|
140
189
|
name: string | undefined;
|
|
190
|
+
/** When this resource last carried an answer. 0 until it has one. */
|
|
191
|
+
answeredAt: number;
|
|
141
192
|
run: (force: boolean) => Promise<T | undefined>;
|
|
142
|
-
}
|
|
143
|
-
export
|
|
193
|
+
};
|
|
194
|
+
export type DataStore = {
|
|
144
195
|
/** Everything carrying a matching tag runs again, with `force`. */
|
|
145
196
|
invalidate(...patterns: Tag[]): Promise<void>;
|
|
146
197
|
/** Forgets every resource and empties the storage. */
|
|
@@ -149,9 +200,19 @@ export interface DataStore {
|
|
|
149
200
|
readonly size: number;
|
|
150
201
|
/** Internal: a resource registers itself here. */
|
|
151
202
|
hold(held: Held): () => void;
|
|
203
|
+
/**
|
|
204
|
+
* Internal: whether an invalidation that this resource missed applies to the
|
|
205
|
+
* tags it has just declared.
|
|
206
|
+
*/
|
|
207
|
+
missed(entry: Held, tags: readonly Tag[]): boolean;
|
|
208
|
+
/**
|
|
209
|
+
* Internal: a run carrying these tags has answered, so an invalidation about
|
|
210
|
+
* them has been acted on and is no longer owed to anybody.
|
|
211
|
+
*/
|
|
212
|
+
settled(tags: readonly Tag[]): void;
|
|
152
213
|
/** Internal: the storage this store was given. */
|
|
153
214
|
readonly storage: Storage | undefined;
|
|
154
|
-
}
|
|
215
|
+
};
|
|
155
216
|
export declare function createData(options?: DataOptions): DataStore;
|
|
156
217
|
/**
|
|
157
218
|
* Runs one resource. Shared by `useResource` and the observable bridges, so
|
package/dist/store.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAiB,KAAK,YAAY,EAAE,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAClF,OAAO,EAAiB,KAAK,GAAG,EAAE,MAAM,WAAW,CAAC;AAGpD,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;AAE9D;;;;;;;;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,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,CAAC;CACvC,CAAC;AAEF,wBAAgB,UAAU,CAAC,OAAO,GAAE,WAAgB,GAAG,SAAS,CAsF/D;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC,CAAC,CAAC,CAmBjF;AAED,gFAAgF;AAChF,wBAAgB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAUzD;AAED,4BAA4B;AAC5B,wBAAgB,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAMtD;AAED,0CAA0C;AAC1C,wBAAgB,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,IAAI,GAAG,QAAQ,CAAC,CAAC,CAAC,CAa1E;AAED,YAAY,EAAE,IAAI,EAAE,CAAC"}
|
package/dist/tags.d.ts
CHANGED
|
@@ -23,10 +23,10 @@ export type TagVars = Readonly<Record<string, string | number | boolean | null>>
|
|
|
23
23
|
* identity.
|
|
24
24
|
*/
|
|
25
25
|
export type Variables = Readonly<Record<string, unknown>>;
|
|
26
|
-
export
|
|
26
|
+
export type Tag = {
|
|
27
27
|
readonly name: string;
|
|
28
28
|
readonly vars: TagVars;
|
|
29
|
-
}
|
|
29
|
+
};
|
|
30
30
|
/** Builds a tag. `tag('user', { id })` is the usual shape. */
|
|
31
31
|
export declare function tag(name: string, vars?: TagVars): Tag;
|
|
32
32
|
/**
|
package/dist/tags.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tags.d.ts","sourceRoot":"","sources":["../src/tags.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,uEAAuE;AACvE,MAAM,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC;AAEjF;;;;;;;GAOG;AACH,MAAM,MAAM,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAE1D,MAAM,
|
|
1
|
+
{"version":3,"file":"tags.d.ts","sourceRoot":"","sources":["../src/tags.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,uEAAuE;AACvE,MAAM,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC;AAEjF;;;;;;;GAOG;AACH,MAAM,MAAM,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAE1D,MAAM,MAAM,GAAG,GAAG;IAChB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;CACxB,CAAC;AAIF,8DAA8D;AAC9D,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,OAAiB,GAAG,GAAG,CAE9D;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,GAAG,OAAO,CAUhE;AAED,sDAAsD;AACtD,wBAAgB,aAAa,CAAC,QAAQ,EAAE,SAAS,GAAG,EAAE,EAAE,IAAI,EAAE,SAAS,GAAG,EAAE,GAAG,OAAO,CASrF"}
|
package/dist/vite.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
type TransformResult = {
|
|
2
2
|
code: string;
|
|
3
3
|
map: null;
|
|
4
|
-
}
|
|
5
|
-
export
|
|
4
|
+
};
|
|
5
|
+
export type GraphQLPlugin = {
|
|
6
6
|
name: string;
|
|
7
7
|
enforce: 'pre';
|
|
8
8
|
transform(this: unknown, code: string, id: string): TransformResult | null;
|
|
9
|
-
}
|
|
9
|
+
};
|
|
10
10
|
/**
|
|
11
11
|
* Inlines `#import "./fragments.gql"`, the convention every GraphQL loader
|
|
12
12
|
* uses.
|
package/dist/vite.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../src/vite.ts"],"names":[],"mappings":"AAgCA,
|
|
1
|
+
{"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../src/vite.ts"],"names":[],"mappings":"AAgCA,KAAK,eAAe,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,IAAI,CAAC;CACX,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,KAAK,CAAC;IACf,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,CAAC;CAC5E,CAAC;AAKF;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE,GAAG,CAAC,MAAM,CAAmB,EACnC,IAAI,GAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAA6C,GACpE,MAAM,CAWR;AAED,wBAAgB,OAAO,IAAI,aAAa,CAgBvC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firsthandjs/data",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "Resources, actions and invalidation for Firsthand: reactive async state, with the cache one layer down.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"LICENSE"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@firsthandjs/core": "0.
|
|
32
|
-
"@firsthandjs/dom": "0.
|
|
31
|
+
"@firsthandjs/core": "0.7.1",
|
|
32
|
+
"@firsthandjs/dom": "0.7.1"
|
|
33
33
|
},
|
|
34
34
|
"engines": {
|
|
35
35
|
"node": ">=20.11.0"
|