march-hare 0.13.1 → 0.13.2
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 +20 -0
- package/dist/cache/index.d.ts +89 -7
- package/dist/index.d.ts +1 -1
- package/dist/march-hare.js +9 -8
- package/dist/march-hare.js.map +1 -1
- package/dist/march-hare.umd.cjs +1 -1
- package/dist/march-hare.umd.cjs.map +1 -1
- package/dist/resource/index.d.ts +2 -1
- package/dist/resource/utils.d.ts +8 -1
- package/dist/scope/utils.d.ts +4 -2
- package/package.json +2 -2
package/dist/resource/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ResourceHandle } from './types.js';
|
|
2
2
|
import { Cache } from './utils.js';
|
|
3
3
|
import { AppFetcher } from '../app/types.js';
|
|
4
|
+
import { Env } from '../boundary/components/env/types.js';
|
|
4
5
|
export type { Coalesce, Fetcher, Invocation, ResourceHandle } from './types.js';
|
|
5
6
|
/**
|
|
6
7
|
* Evicts cache entries across every Resource constructed in the
|
|
@@ -74,4 +75,4 @@ export declare function nuke(where?: object): void;
|
|
|
74
75
|
* — consumers should use `App({ cache })` instead of passing it
|
|
75
76
|
* directly.
|
|
76
77
|
*/
|
|
77
|
-
export declare function Resource<E extends object, T, P extends object = Record<never, never>>(ƒ: AppFetcher<E, T, P>, cache?: Cache): ResourceHandle<T, P>;
|
|
78
|
+
export declare function Resource<E extends object, T, P extends object = Record<never, never>>(ƒ: AppFetcher<E, T, P>, cache?: Cache, getEnv?: () => Env | undefined): ResourceHandle<T, P>;
|
package/dist/resource/utils.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Cache } from '../cache/index.js';
|
|
2
2
|
import { unset } from '../utils/utils.js';
|
|
3
|
+
import { Env } from '../boundary/components/env/types.js';
|
|
3
4
|
import { Fetcher, ResourceEvictor, ResourceHandle } from './types.js';
|
|
4
5
|
export { Cache } from '../cache/index.js';
|
|
5
6
|
/**
|
|
@@ -60,6 +61,12 @@ export declare function nextResourceId(fetcher: object): string;
|
|
|
60
61
|
* `context.actions.resource(...)` for fetch/evict. `.get(params)` reads
|
|
61
62
|
* the per-params cache slot synchronously.
|
|
62
63
|
*
|
|
64
|
+
* `getEnv` is the App-supplied accessor used to resolve the live env at
|
|
65
|
+
* sync read time (`.get(params)`) and at App-side eviction (when the
|
|
66
|
+
* handler context isn't available). It returns `undefined` when no
|
|
67
|
+
* Boundary has mounted yet — in which case `cache.scope(undefined)`
|
|
68
|
+
* yields the empty prefix and the read/evict targets the unscoped slot.
|
|
69
|
+
*
|
|
63
70
|
* @internal
|
|
64
71
|
*/
|
|
65
|
-
export declare function build<T, P extends object>(ƒ: Fetcher<T, P>, backing: Cache, namespace: string | null): ResourceHandle<T, P>;
|
|
72
|
+
export declare function build<T, P extends object>(ƒ: Fetcher<T, P>, backing: Cache, namespace: string | null, getEnv: () => Env | undefined): ResourceHandle<T, P>;
|
package/dist/scope/utils.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { Cache } from '../cache/index.js';
|
|
2
|
+
import { Env } from '../boundary/components/env/types.js';
|
|
2
3
|
import { ScopeHandle } from './types.js';
|
|
3
4
|
/**
|
|
4
5
|
* Internal constructor for a {@link ScopeHandle}. Called from inside
|
|
5
6
|
* `App<E>()` so the enclosing Env shape `E` is captured at the type
|
|
6
7
|
* level. The optional `cache` is the same value `App({ cache })` was
|
|
7
8
|
* constructed with — resources declared via `scope.Resource`
|
|
8
|
-
* share that cache.
|
|
9
|
+
* share that cache. `getEnv` resolves the live Env from the enclosing
|
|
10
|
+
* `app.Boundary` so cache-key scoping works for sync `.get()` reads.
|
|
9
11
|
*
|
|
10
12
|
* @internal
|
|
11
13
|
*/
|
|
12
|
-
export declare function createScope<E extends object, MulticastActions>(cache?: Cache): ScopeHandle<E, MulticastActions>;
|
|
14
|
+
export declare function createScope<E extends object, MulticastActions>(cache?: Cache, getEnv?: () => Env | undefined): ScopeHandle<E, MulticastActions>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "march-hare",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"packageManager": "yarn@1.22.22",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"figlet": "^1.7.0",
|
|
25
25
|
"find-up": "^8.0.0",
|
|
26
26
|
"gray-matter": "^4.0.3",
|
|
27
|
-
"immertation": "^0.1.
|
|
27
|
+
"immertation": "^0.1.27",
|
|
28
28
|
"kleur": "^4.1.5",
|
|
29
29
|
"tinyglobby": "^0.2.17"
|
|
30
30
|
},
|