@getforma/core 0.9.1 → 1.0.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/README.md +24 -5
- package/dist/chunk-DCTOXHPF.cjs +399 -0
- package/dist/chunk-DCTOXHPF.cjs.map +1 -0
- package/dist/chunk-OUVOAYIO.js +359 -0
- package/dist/chunk-OUVOAYIO.js.map +1 -0
- package/dist/{chunk-GDULJFJO.cjs → chunk-V732ZBCU.cjs} +119 -511
- package/dist/chunk-V732ZBCU.cjs.map +1 -0
- package/dist/{chunk-CN56FSDT.js → chunk-VTPFK5TJ.js} +89 -442
- package/dist/chunk-VTPFK5TJ.js.map +1 -0
- package/dist/forma-runtime-csp.js +3400 -1
- package/dist/forma-runtime.js +3572 -1
- package/dist/formajs-runtime-hardened.global.js +3400 -1
- package/dist/formajs-runtime-hardened.global.js.map +1 -1
- package/dist/formajs-runtime.global.js +3572 -1
- package/dist/formajs-runtime.global.js.map +1 -1
- package/dist/formajs.global.js +3443 -1
- package/dist/formajs.global.js.map +1 -1
- package/dist/http.cjs +225 -0
- package/dist/http.cjs.map +1 -0
- package/dist/http.d.cts +108 -0
- package/dist/http.d.ts +108 -0
- package/dist/http.js +220 -0
- package/dist/http.js.map +1 -0
- package/dist/index.cjs +71 -607
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -456
- package/dist/index.d.ts +2 -456
- package/dist/index.js +7 -523
- package/dist/index.js.map +1 -1
- package/dist/resource-Cd0cGOxS.d.ts +62 -0
- package/dist/resource-DK98lW5e.d.cts +62 -0
- package/dist/runtime-hardened.cjs.map +1 -1
- package/dist/runtime-hardened.js.map +1 -1
- package/dist/runtime.cjs +23 -22
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.js +2 -1
- package/dist/runtime.js.map +1 -1
- package/dist/server.cjs +179 -0
- package/dist/server.cjs.map +1 -0
- package/dist/server.d.cts +217 -0
- package/dist/server.d.ts +217 -0
- package/dist/server.js +166 -0
- package/dist/server.js.map +1 -0
- package/dist/storage.cjs +151 -0
- package/dist/storage.cjs.map +1 -0
- package/dist/storage.d.cts +77 -0
- package/dist/storage.d.ts +77 -0
- package/dist/storage.js +147 -0
- package/dist/storage.js.map +1 -0
- package/package.json +31 -1
- package/dist/chunk-CN56FSDT.js.map +0 -1
- package/dist/chunk-GDULJFJO.cjs.map +0 -1
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { S as SignalGetter } from './signal-YlS1kgfh.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Forma Reactive - Resource
|
|
5
|
+
*
|
|
6
|
+
* Async data fetching primitive with reactive loading/error state.
|
|
7
|
+
* Tracks a source signal and refetches when it changes.
|
|
8
|
+
*
|
|
9
|
+
* SolidJS equivalent: createResource
|
|
10
|
+
* React equivalent: use() + Suspense (React 19), or useSWR/react-query
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
interface Resource<T> {
|
|
14
|
+
/** The resolved data (or undefined while loading). */
|
|
15
|
+
(): T | undefined;
|
|
16
|
+
/** True while the fetcher is running. */
|
|
17
|
+
loading: SignalGetter<boolean>;
|
|
18
|
+
/** The error if the fetcher rejected (or undefined). */
|
|
19
|
+
error: SignalGetter<unknown>;
|
|
20
|
+
/** Manually refetch with the current source value. */
|
|
21
|
+
refetch: () => void;
|
|
22
|
+
/** Manually set the data (overrides fetcher result). */
|
|
23
|
+
mutate: (value: T | undefined) => void;
|
|
24
|
+
}
|
|
25
|
+
interface ResourceOptions<T> {
|
|
26
|
+
/** Initial value before first fetch resolves. */
|
|
27
|
+
initialValue?: T;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Create an async resource that fetches data reactively.
|
|
31
|
+
*
|
|
32
|
+
* When `source` changes, the fetcher re-runs automatically.
|
|
33
|
+
* Provides reactive `loading` and `error` signals.
|
|
34
|
+
*
|
|
35
|
+
* ```ts
|
|
36
|
+
* const [userId, setUserId] = createSignal(1);
|
|
37
|
+
*
|
|
38
|
+
* const user = createResource(
|
|
39
|
+
* userId, // source signal
|
|
40
|
+
* (id) => fetch(`/api/users/${id}`).then(r => r.json()), // fetcher
|
|
41
|
+
* );
|
|
42
|
+
*
|
|
43
|
+
* internalEffect(() => {
|
|
44
|
+
* if (user.loading()) console.log('Loading...');
|
|
45
|
+
* else if (user.error()) console.log('Error:', user.error());
|
|
46
|
+
* else console.log('User:', user());
|
|
47
|
+
* });
|
|
48
|
+
*
|
|
49
|
+
* setUserId(2); // automatically refetches
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* Without a source signal (static fetch):
|
|
53
|
+
* ```ts
|
|
54
|
+
* const posts = createResource(
|
|
55
|
+
* () => true, // constant source — fetches once
|
|
56
|
+
* () => fetch('/api/posts').then(r => r.json()),
|
|
57
|
+
* );
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
declare function createResource<T, S = true>(source: SignalGetter<S>, fetcher: (source: S) => Promise<T>, options?: ResourceOptions<T>): Resource<T>;
|
|
61
|
+
|
|
62
|
+
export { type Resource as R, type ResourceOptions as a, createResource as c };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { S as SignalGetter } from './signal-YlS1kgfh.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Forma Reactive - Resource
|
|
5
|
+
*
|
|
6
|
+
* Async data fetching primitive with reactive loading/error state.
|
|
7
|
+
* Tracks a source signal and refetches when it changes.
|
|
8
|
+
*
|
|
9
|
+
* SolidJS equivalent: createResource
|
|
10
|
+
* React equivalent: use() + Suspense (React 19), or useSWR/react-query
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
interface Resource<T> {
|
|
14
|
+
/** The resolved data (or undefined while loading). */
|
|
15
|
+
(): T | undefined;
|
|
16
|
+
/** True while the fetcher is running. */
|
|
17
|
+
loading: SignalGetter<boolean>;
|
|
18
|
+
/** The error if the fetcher rejected (or undefined). */
|
|
19
|
+
error: SignalGetter<unknown>;
|
|
20
|
+
/** Manually refetch with the current source value. */
|
|
21
|
+
refetch: () => void;
|
|
22
|
+
/** Manually set the data (overrides fetcher result). */
|
|
23
|
+
mutate: (value: T | undefined) => void;
|
|
24
|
+
}
|
|
25
|
+
interface ResourceOptions<T> {
|
|
26
|
+
/** Initial value before first fetch resolves. */
|
|
27
|
+
initialValue?: T;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Create an async resource that fetches data reactively.
|
|
31
|
+
*
|
|
32
|
+
* When `source` changes, the fetcher re-runs automatically.
|
|
33
|
+
* Provides reactive `loading` and `error` signals.
|
|
34
|
+
*
|
|
35
|
+
* ```ts
|
|
36
|
+
* const [userId, setUserId] = createSignal(1);
|
|
37
|
+
*
|
|
38
|
+
* const user = createResource(
|
|
39
|
+
* userId, // source signal
|
|
40
|
+
* (id) => fetch(`/api/users/${id}`).then(r => r.json()), // fetcher
|
|
41
|
+
* );
|
|
42
|
+
*
|
|
43
|
+
* internalEffect(() => {
|
|
44
|
+
* if (user.loading()) console.log('Loading...');
|
|
45
|
+
* else if (user.error()) console.log('Error:', user.error());
|
|
46
|
+
* else console.log('User:', user());
|
|
47
|
+
* });
|
|
48
|
+
*
|
|
49
|
+
* setUserId(2); // automatically refetches
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* Without a source signal (static fetch):
|
|
53
|
+
* ```ts
|
|
54
|
+
* const posts = createResource(
|
|
55
|
+
* () => true, // constant source — fetches once
|
|
56
|
+
* () => fetch('/api/posts').then(r => r.json()),
|
|
57
|
+
* );
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
declare function createResource<T, S = true>(source: SignalGetter<S>, fetcher: (source: S) => Promise<T>, options?: ResourceOptions<T>): Resource<T>;
|
|
61
|
+
|
|
62
|
+
export { type Resource as R, type ResourceOptions as a, createResource as c };
|