@replanejs/react 0.8.20 → 0.9.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 +60 -30
- package/dist/index.cjs +162 -151
- package/dist/index.d.cts +24 -29
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +24 -29
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +146 -153
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
2
|
-
import { GetConfigOptions, GetReplaneSnapshotOptions,
|
|
2
|
+
import { ConnectOptions, ConnectOptions as ConnectOptions$1, GetConfigOptions, GetConfigOptions as GetConfigOptions$1, GetReplaneSnapshotOptions, Replane, Replane as Replane$1, ReplaneContext, ReplaneError, ReplaneErrorCode, ReplaneLogger, ReplaneOptions, ReplaneOptions as ReplaneOptions$1, ReplaneSnapshot, getReplaneSnapshot } from "@replanejs/sdk";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
4
|
|
|
5
5
|
//#region src/types.d.ts
|
|
@@ -8,24 +8,20 @@ type UntypedReplaneConfig = Record<string, unknown>;
|
|
|
8
8
|
* Props for ReplaneProvider when using a pre-created client.
|
|
9
9
|
*/
|
|
10
10
|
interface ReplaneProviderWithClientProps<T extends object = UntypedReplaneConfig> {
|
|
11
|
-
/** Pre-created
|
|
12
|
-
client:
|
|
11
|
+
/** Pre-created Replane client instance */
|
|
12
|
+
client: Replane$1<T>;
|
|
13
13
|
children: ReactNode;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Props for ReplaneProvider when letting it manage the client internally.
|
|
17
17
|
*/
|
|
18
|
-
interface ReplaneProviderWithOptionsProps<T extends object = UntypedReplaneConfig> {
|
|
19
|
-
/** Options to create or restore the ReplaneClient */
|
|
20
|
-
options: ReplaneClientOptions<T>;
|
|
18
|
+
interface ReplaneProviderWithOptionsProps<T extends object = UntypedReplaneConfig> extends ReplaneOptions$1<T> {
|
|
21
19
|
children: ReactNode;
|
|
22
20
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* instead of fetching configs from the server.
|
|
26
|
-
* The `options` will be used for live updates connection if provided.
|
|
21
|
+
* Connection options for connecting to the Replane server.
|
|
22
|
+
* Pass null to explicitly skip connection (client will use defaults/snapshot only).
|
|
27
23
|
*/
|
|
28
|
-
|
|
24
|
+
connection: ConnectOptions$1 | null;
|
|
29
25
|
/**
|
|
30
26
|
* Optional loading component to show while the client is initializing.
|
|
31
27
|
* If not provided and suspense is false/undefined, children will not render until ready.
|
|
@@ -39,6 +35,11 @@ interface ReplaneProviderWithOptionsProps<T extends object = UntypedReplaneConfi
|
|
|
39
35
|
* @default false
|
|
40
36
|
*/
|
|
41
37
|
suspense?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* If true, the client will be connected asynchronously. Make sure to provide defaults or snapshot.
|
|
40
|
+
* @default false
|
|
41
|
+
*/
|
|
42
|
+
async?: boolean;
|
|
42
43
|
}
|
|
43
44
|
type ReplaneProviderProps<T extends object = UntypedReplaneConfig> = ReplaneProviderWithClientProps<T> | ReplaneProviderWithOptionsProps<T>;
|
|
44
45
|
/**
|
|
@@ -48,13 +49,14 @@ type ReplaneProviderProps<T extends object = UntypedReplaneConfig> = ReplaneProv
|
|
|
48
49
|
//#endregion
|
|
49
50
|
//#region src/provider.d.ts
|
|
50
51
|
/**
|
|
51
|
-
* Provider component that makes a
|
|
52
|
+
* Provider component that makes a Replane client available to the component tree.
|
|
52
53
|
*
|
|
53
|
-
* Can be used in
|
|
54
|
+
* Can be used in several ways:
|
|
54
55
|
*
|
|
55
56
|
* 1. With a pre-created client:
|
|
56
57
|
* ```tsx
|
|
57
|
-
* const client =
|
|
58
|
+
* const client = new Replane({ defaults: { ... } });
|
|
59
|
+
* await client.connect({ baseUrl: '...', sdkKey: '...' });
|
|
58
60
|
* <ReplaneProvider client={client}>
|
|
59
61
|
* <App />
|
|
60
62
|
* </ReplaneProvider>
|
|
@@ -107,8 +109,8 @@ declare function ReplaneProvider<T extends object>(props: ReplaneProviderProps<T
|
|
|
107
109
|
//# sourceMappingURL=provider.d.ts.map
|
|
108
110
|
//#endregion
|
|
109
111
|
//#region src/hooks.d.ts
|
|
110
|
-
declare function useReplane<T extends object = UntypedReplaneConfig>():
|
|
111
|
-
declare function useConfig<T>(name: string, options?: GetConfigOptions<T>): T;
|
|
112
|
+
declare function useReplane<T extends object = UntypedReplaneConfig>(): Replane$1<T>;
|
|
113
|
+
declare function useConfig<T>(name: string, options?: GetConfigOptions$1<T>): T;
|
|
112
114
|
/**
|
|
113
115
|
* Creates a typed version of useReplane hook.
|
|
114
116
|
*
|
|
@@ -127,7 +129,7 @@ declare function useConfig<T>(name: string, options?: GetConfigOptions<T>): T;
|
|
|
127
129
|
* }
|
|
128
130
|
* ```
|
|
129
131
|
*/
|
|
130
|
-
declare function createReplaneHook<TConfigs extends object>(): () =>
|
|
132
|
+
declare function createReplaneHook<TConfigs extends object>(): () => Replane$1<TConfigs>;
|
|
131
133
|
/**
|
|
132
134
|
* Creates a typed version of useConfig hook.
|
|
133
135
|
*
|
|
@@ -146,22 +148,15 @@ declare function createReplaneHook<TConfigs extends object>(): () => ReplaneClie
|
|
|
146
148
|
* }
|
|
147
149
|
* ```
|
|
148
150
|
*/
|
|
149
|
-
declare function createConfigHook<TConfigs extends object>(): <K extends keyof TConfigs>(name: K, options?: GetConfigOptions<TConfigs[K]>) => TConfigs[K];
|
|
150
|
-
|
|
151
|
-
* Hook for creating stateful resources with cleanup support.
|
|
152
|
-
* Unlike useMemo, this guarantees cleanup when dependencies change or on unmount.
|
|
153
|
-
*
|
|
154
|
-
* @param factory - Function that creates the resource
|
|
155
|
-
* @param cleanup - Function that cleans up the resource
|
|
156
|
-
* @param deps - Dependencies array (resource is recreated when these change)
|
|
157
|
-
*/
|
|
151
|
+
declare function createConfigHook<TConfigs extends object>(): <K extends keyof TConfigs>(name: K, options?: GetConfigOptions$1<TConfigs[K]>) => TConfigs[K];
|
|
152
|
+
//# sourceMappingURL=hooks.d.ts.map
|
|
158
153
|
//#endregion
|
|
159
154
|
//#region src/useReplaneClient.d.ts
|
|
160
155
|
/**
|
|
161
|
-
* Clear the suspense cache for a specific
|
|
156
|
+
* Clear the suspense cache for a specific connection configuration.
|
|
162
157
|
* Useful for testing or when you need to force re-initialization.
|
|
163
158
|
*/
|
|
164
|
-
declare function clearSuspenseCache
|
|
159
|
+
declare function clearSuspenseCache(connection?: ConnectOptions$1): void;
|
|
165
160
|
//#endregion
|
|
166
|
-
export { type GetReplaneSnapshotOptions, ReplaneProvider, type ReplaneProviderProps, type ReplaneProviderWithClientProps, type ReplaneProviderWithOptionsProps, clearSuspenseCache, createConfigHook, createReplaneHook, getReplaneSnapshot, useConfig, useReplane };
|
|
161
|
+
export { type ConnectOptions, type GetConfigOptions, type GetReplaneSnapshotOptions, Replane, type ReplaneContext, ReplaneError, ReplaneErrorCode, type ReplaneLogger, type ReplaneOptions, ReplaneProvider, type ReplaneProviderProps, type ReplaneProviderWithClientProps, type ReplaneProviderWithOptionsProps, type ReplaneSnapshot, clearSuspenseCache, createConfigHook, createReplaneHook, getReplaneSnapshot, useConfig, useReplane };
|
|
167
162
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/types.ts","../src/provider.tsx","../src/hooks.ts","../src/useReplaneClient.ts"],"sourcesContent":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/types.ts","../src/provider.tsx","../src/hooks.ts","../src/useReplaneClient.ts"],"sourcesContent":[],"mappings":";;;;;KAGY,oBAAA,GAAuB;AASnC;;;AAEkB,UAFD,8BAEC,CAAA,UAAA,MAAA,GAFiD,oBAEjD,CAAA,CAAA;EAAC;EAA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IAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
|
-
import { GetConfigOptions, GetReplaneSnapshotOptions,
|
|
2
|
+
import { ConnectOptions, ConnectOptions as ConnectOptions$1, GetConfigOptions, GetConfigOptions as GetConfigOptions$1, GetReplaneSnapshotOptions, Replane, Replane as Replane$1, ReplaneContext, ReplaneError, ReplaneErrorCode, ReplaneLogger, ReplaneOptions, ReplaneOptions as ReplaneOptions$1, ReplaneSnapshot, getReplaneSnapshot } from "@replanejs/sdk";
|
|
3
3
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
4
4
|
|
|
5
5
|
//#region src/types.d.ts
|
|
@@ -8,24 +8,20 @@ type UntypedReplaneConfig = Record<string, unknown>;
|
|
|
8
8
|
* Props for ReplaneProvider when using a pre-created client.
|
|
9
9
|
*/
|
|
10
10
|
interface ReplaneProviderWithClientProps<T extends object = UntypedReplaneConfig> {
|
|
11
|
-
/** Pre-created
|
|
12
|
-
client:
|
|
11
|
+
/** Pre-created Replane client instance */
|
|
12
|
+
client: Replane$1<T>;
|
|
13
13
|
children: ReactNode;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Props for ReplaneProvider when letting it manage the client internally.
|
|
17
17
|
*/
|
|
18
|
-
interface ReplaneProviderWithOptionsProps<T extends object = UntypedReplaneConfig> {
|
|
19
|
-
/** Options to create or restore the ReplaneClient */
|
|
20
|
-
options: ReplaneClientOptions<T>;
|
|
18
|
+
interface ReplaneProviderWithOptionsProps<T extends object = UntypedReplaneConfig> extends ReplaneOptions$1<T> {
|
|
21
19
|
children: ReactNode;
|
|
22
20
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* instead of fetching configs from the server.
|
|
26
|
-
* The `options` will be used for live updates connection if provided.
|
|
21
|
+
* Connection options for connecting to the Replane server.
|
|
22
|
+
* Pass null to explicitly skip connection (client will use defaults/snapshot only).
|
|
27
23
|
*/
|
|
28
|
-
|
|
24
|
+
connection: ConnectOptions$1 | null;
|
|
29
25
|
/**
|
|
30
26
|
* Optional loading component to show while the client is initializing.
|
|
31
27
|
* If not provided and suspense is false/undefined, children will not render until ready.
|
|
@@ -39,6 +35,11 @@ interface ReplaneProviderWithOptionsProps<T extends object = UntypedReplaneConfi
|
|
|
39
35
|
* @default false
|
|
40
36
|
*/
|
|
41
37
|
suspense?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* If true, the client will be connected asynchronously. Make sure to provide defaults or snapshot.
|
|
40
|
+
* @default false
|
|
41
|
+
*/
|
|
42
|
+
async?: boolean;
|
|
42
43
|
}
|
|
43
44
|
type ReplaneProviderProps<T extends object = UntypedReplaneConfig> = ReplaneProviderWithClientProps<T> | ReplaneProviderWithOptionsProps<T>;
|
|
44
45
|
/**
|
|
@@ -48,13 +49,14 @@ type ReplaneProviderProps<T extends object = UntypedReplaneConfig> = ReplaneProv
|
|
|
48
49
|
//#endregion
|
|
49
50
|
//#region src/provider.d.ts
|
|
50
51
|
/**
|
|
51
|
-
* Provider component that makes a
|
|
52
|
+
* Provider component that makes a Replane client available to the component tree.
|
|
52
53
|
*
|
|
53
|
-
* Can be used in
|
|
54
|
+
* Can be used in several ways:
|
|
54
55
|
*
|
|
55
56
|
* 1. With a pre-created client:
|
|
56
57
|
* ```tsx
|
|
57
|
-
* const client =
|
|
58
|
+
* const client = new Replane({ defaults: { ... } });
|
|
59
|
+
* await client.connect({ baseUrl: '...', sdkKey: '...' });
|
|
58
60
|
* <ReplaneProvider client={client}>
|
|
59
61
|
* <App />
|
|
60
62
|
* </ReplaneProvider>
|
|
@@ -107,8 +109,8 @@ declare function ReplaneProvider<T extends object>(props: ReplaneProviderProps<T
|
|
|
107
109
|
//# sourceMappingURL=provider.d.ts.map
|
|
108
110
|
//#endregion
|
|
109
111
|
//#region src/hooks.d.ts
|
|
110
|
-
declare function useReplane<T extends object = UntypedReplaneConfig>():
|
|
111
|
-
declare function useConfig<T>(name: string, options?: GetConfigOptions<T>): T;
|
|
112
|
+
declare function useReplane<T extends object = UntypedReplaneConfig>(): Replane$1<T>;
|
|
113
|
+
declare function useConfig<T>(name: string, options?: GetConfigOptions$1<T>): T;
|
|
112
114
|
/**
|
|
113
115
|
* Creates a typed version of useReplane hook.
|
|
114
116
|
*
|
|
@@ -127,7 +129,7 @@ declare function useConfig<T>(name: string, options?: GetConfigOptions<T>): T;
|
|
|
127
129
|
* }
|
|
128
130
|
* ```
|
|
129
131
|
*/
|
|
130
|
-
declare function createReplaneHook<TConfigs extends object>(): () =>
|
|
132
|
+
declare function createReplaneHook<TConfigs extends object>(): () => Replane$1<TConfigs>;
|
|
131
133
|
/**
|
|
132
134
|
* Creates a typed version of useConfig hook.
|
|
133
135
|
*
|
|
@@ -146,22 +148,15 @@ declare function createReplaneHook<TConfigs extends object>(): () => ReplaneClie
|
|
|
146
148
|
* }
|
|
147
149
|
* ```
|
|
148
150
|
*/
|
|
149
|
-
declare function createConfigHook<TConfigs extends object>(): <K extends keyof TConfigs>(name: K, options?: GetConfigOptions<TConfigs[K]>) => TConfigs[K];
|
|
150
|
-
|
|
151
|
-
* Hook for creating stateful resources with cleanup support.
|
|
152
|
-
* Unlike useMemo, this guarantees cleanup when dependencies change or on unmount.
|
|
153
|
-
*
|
|
154
|
-
* @param factory - Function that creates the resource
|
|
155
|
-
* @param cleanup - Function that cleans up the resource
|
|
156
|
-
* @param deps - Dependencies array (resource is recreated when these change)
|
|
157
|
-
*/
|
|
151
|
+
declare function createConfigHook<TConfigs extends object>(): <K extends keyof TConfigs>(name: K, options?: GetConfigOptions$1<TConfigs[K]>) => TConfigs[K];
|
|
152
|
+
//# sourceMappingURL=hooks.d.ts.map
|
|
158
153
|
//#endregion
|
|
159
154
|
//#region src/useReplaneClient.d.ts
|
|
160
155
|
/**
|
|
161
|
-
* Clear the suspense cache for a specific
|
|
156
|
+
* Clear the suspense cache for a specific connection configuration.
|
|
162
157
|
* Useful for testing or when you need to force re-initialization.
|
|
163
158
|
*/
|
|
164
|
-
declare function clearSuspenseCache
|
|
159
|
+
declare function clearSuspenseCache(connection?: ConnectOptions$1): void;
|
|
165
160
|
//#endregion
|
|
166
|
-
export { type GetReplaneSnapshotOptions, ReplaneProvider, type ReplaneProviderProps, type ReplaneProviderWithClientProps, type ReplaneProviderWithOptionsProps, clearSuspenseCache, createConfigHook, createReplaneHook, getReplaneSnapshot, useConfig, useReplane };
|
|
161
|
+
export { type ConnectOptions, type GetConfigOptions, type GetReplaneSnapshotOptions, Replane, type ReplaneContext, ReplaneError, ReplaneErrorCode, type ReplaneLogger, type ReplaneOptions, ReplaneProvider, type ReplaneProviderProps, type ReplaneProviderWithClientProps, type ReplaneProviderWithOptionsProps, type ReplaneSnapshot, clearSuspenseCache, createConfigHook, createReplaneHook, getReplaneSnapshot, useConfig, useReplane };
|
|
167
162
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/provider.tsx","../src/hooks.ts","../src/useReplaneClient.ts"],"sourcesContent":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/provider.tsx","../src/hooks.ts","../src/useReplaneClient.ts"],"sourcesContent":[],"mappings":";;;;;KAGY,oBAAA,GAAuB;AASnC;;;AAEkB,UAFD,8BAEC,CAAA,UAAA,MAAA,GAFiD,oBAEjD,CAAA,CAAA;EAAC;EAAF,MACL,EADF,SACE,CADM,CACN,CAAA;EAAS,QAAA,EAAT,SAAS;AAMrB;;;;AAGY,UAHK,+BAGL,CAAA,UAAA,MAAA,GAFS,oBAET,CAAA,SADF,gBACE,CADa,CACb,CAAA,CAAA;EAAS,QAKP,EALF,SAKE;EAAc;;AANJ;AA2BxB;EAAgC,UAAA,EArBlB,gBAqBkB,GAAA,IAAA;EAAA;;;;;EAEG,MAAA,CAAA,EAjBxB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