@replanejs/next 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 +35 -21
- package/dist/index.cjs +22 -29
- package/dist/index.d.cts +7 -12
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +7 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -12
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -34,7 +34,7 @@ export default async function RootLayout({ children }: { children: React.ReactNo
|
|
|
34
34
|
<html lang="en">
|
|
35
35
|
<body>
|
|
36
36
|
<ReplaneRoot<AppConfigs>
|
|
37
|
-
|
|
37
|
+
connection={{
|
|
38
38
|
baseUrl: process.env.NEXT_PUBLIC_REPLANE_BASE_URL!,
|
|
39
39
|
sdkKey: process.env.NEXT_PUBLIC_REPLANE_SDK_KEY!,
|
|
40
40
|
}}
|
|
@@ -84,7 +84,7 @@ export default function MyApp({ Component, pageProps, replaneSnapshot }: AppProp
|
|
|
84
84
|
return (
|
|
85
85
|
<ReplaneProvider
|
|
86
86
|
snapshot={replaneSnapshot}
|
|
87
|
-
|
|
87
|
+
connection={{
|
|
88
88
|
baseUrl: process.env.NEXT_PUBLIC_REPLANE_BASE_URL!,
|
|
89
89
|
sdkKey: process.env.NEXT_PUBLIC_REPLANE_SDK_KEY!,
|
|
90
90
|
}}
|
|
@@ -99,8 +99,10 @@ MyApp.getInitialProps = async (appContext: AppContext) => {
|
|
|
99
99
|
const appProps = await App.getInitialProps(appContext);
|
|
100
100
|
|
|
101
101
|
const replaneSnapshot = await getReplaneSnapshot<AppConfigs>({
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
connection: {
|
|
103
|
+
baseUrl: process.env.REPLANE_BASE_URL!,
|
|
104
|
+
sdkKey: process.env.REPLANE_SDK_KEY!,
|
|
105
|
+
},
|
|
104
106
|
});
|
|
105
107
|
|
|
106
108
|
return { ...appProps, replaneSnapshot };
|
|
@@ -174,20 +176,31 @@ export function ConfigDisplay() {
|
|
|
174
176
|
}
|
|
175
177
|
```
|
|
176
178
|
|
|
177
|
-
##
|
|
179
|
+
## Provider Props
|
|
180
|
+
|
|
181
|
+
| Prop | Type | Required | Description |
|
|
182
|
+
| ------------ | ------------------------- | -------- | ------------------------------------------------------- |
|
|
183
|
+
| `connection` | `ConnectOptions` | No | Connection options (see below) |
|
|
184
|
+
| `defaults` | `Record<string, unknown>` | No | Default values if server is unavailable |
|
|
185
|
+
| `context` | `Record<string, unknown>` | No | Default context for override evaluations |
|
|
186
|
+
| `snapshot` | `ReplaneSnapshot` | No | Snapshot for SSR hydration |
|
|
187
|
+
| `logger` | `ReplaneLogger` | No | Custom logger (default: console) |
|
|
178
188
|
|
|
179
|
-
|
|
189
|
+
## Connection Options
|
|
180
190
|
|
|
181
|
-
|
|
182
|
-
| ------------------------- | ---------------------- | -------- | ------------------------------------------ |
|
|
183
|
-
| `baseUrl` | `string` | Yes | Replane server URL |
|
|
184
|
-
| `sdkKey` | `string` | Yes | SDK key for authentication |
|
|
185
|
-
| `context` | `Record<string, any>` | No | Default context for override evaluations |
|
|
186
|
-
| `defaults` | `Record<string, any>` | No | Default values if server is unavailable |
|
|
187
|
-
| `required` | `string[]` or `object` | No | Configs that must exist for initialization |
|
|
188
|
-
| `initializationTimeoutMs` | `number` | No | SDK initialization timeout (default: 5000) |
|
|
191
|
+
The `connection` prop accepts the following options:
|
|
189
192
|
|
|
190
|
-
|
|
193
|
+
| Option | Type | Required | Description |
|
|
194
|
+
| --------------------- | --------------------- | -------- | ---------------------------------------- |
|
|
195
|
+
| `baseUrl` | `string` | Yes | Replane server URL |
|
|
196
|
+
| `sdkKey` | `string` | Yes | SDK key for authentication |
|
|
197
|
+
| `connectTimeoutMs` | `number` | No | SDK connection timeout (default: 5000) |
|
|
198
|
+
| `requestTimeoutMs` | `number` | No | Timeout for SSE requests (default: 2000) |
|
|
199
|
+
| `retryDelayMs` | `number` | No | Base delay between retries (default: 200)|
|
|
200
|
+
| `inactivityTimeoutMs` | `number` | No | SSE inactivity timeout (default: 30000) |
|
|
201
|
+
| `fetchFn` | `typeof fetch` | No | Custom fetch implementation |
|
|
202
|
+
|
|
203
|
+
See [`@replanejs/sdk` documentation](https://github.com/replane-dev/replane-javascript/tree/main/packages/sdk#api) for more details.
|
|
191
204
|
|
|
192
205
|
## API Reference
|
|
193
206
|
|
|
@@ -199,10 +212,9 @@ Server component for App Router that fetches configs and provides them to the ap
|
|
|
199
212
|
|
|
200
213
|
```tsx
|
|
201
214
|
<ReplaneRoot<AppConfigs>
|
|
202
|
-
|
|
215
|
+
connection={{
|
|
203
216
|
baseUrl: string;
|
|
204
217
|
sdkKey: string;
|
|
205
|
-
// ... other ReplaneClientOptions
|
|
206
218
|
}}
|
|
207
219
|
>
|
|
208
220
|
{children}
|
|
@@ -216,7 +228,7 @@ Client-side provider for Pages Router or custom setups.
|
|
|
216
228
|
```tsx
|
|
217
229
|
<ReplaneProvider
|
|
218
230
|
snapshot={replaneSnapshot}
|
|
219
|
-
|
|
231
|
+
connection={{
|
|
220
232
|
baseUrl: string;
|
|
221
233
|
sdkKey: string;
|
|
222
234
|
}}
|
|
@@ -235,7 +247,7 @@ Returns the value of a config by name. Re-renders when the config changes.
|
|
|
235
247
|
const theme = useConfig<{ darkMode: boolean }>("theme");
|
|
236
248
|
```
|
|
237
249
|
|
|
238
|
-
#### `useReplane<T>():
|
|
250
|
+
#### `useReplane<T>(): Replane<T>`
|
|
239
251
|
|
|
240
252
|
Returns the Replane client instance for advanced usage.
|
|
241
253
|
|
|
@@ -271,8 +283,10 @@ Fetches a snapshot of all configs. Use in `getServerSideProps`, `getStaticProps`
|
|
|
271
283
|
|
|
272
284
|
```tsx
|
|
273
285
|
const snapshot = await getReplaneSnapshot<AppConfigs>({
|
|
274
|
-
|
|
275
|
-
|
|
286
|
+
connection: {
|
|
287
|
+
baseUrl: process.env.REPLANE_BASE_URL!,
|
|
288
|
+
sdkKey: process.env.REPLANE_SDK_KEY!,
|
|
289
|
+
},
|
|
276
290
|
// by default, getReplaneSnapshot will reuse the created client for 60 seconds for fast subsequent calls, the client will be syncing with the server in the background during this time
|
|
277
291
|
keepAliveMs: 60_000,
|
|
278
292
|
});
|
package/dist/index.cjs
CHANGED
|
@@ -26,7 +26,7 @@ const __replanejs_react = __toESM(require("@replanejs/react"));
|
|
|
26
26
|
const react_jsx_runtime = __toESM(require("react/jsx-runtime"));
|
|
27
27
|
|
|
28
28
|
//#region src/version.ts
|
|
29
|
-
const VERSION = "0.
|
|
29
|
+
const VERSION = "0.9.2";
|
|
30
30
|
const DEFAULT_AGENT = `replane-js-next/${VERSION}`;
|
|
31
31
|
|
|
32
32
|
//#endregion
|
|
@@ -45,7 +45,7 @@ const DEFAULT_AGENT = `replane-js-next/${VERSION}`;
|
|
|
45
45
|
* <html>
|
|
46
46
|
* <body>
|
|
47
47
|
* <ReplaneRoot
|
|
48
|
-
*
|
|
48
|
+
* connection={{
|
|
49
49
|
* baseUrl: process.env.NEXT_PUBLIC_REPLANE_BASE_URL!,
|
|
50
50
|
* sdkKey: process.env.NEXT_PUBLIC_REPLANE_SDK_KEY!,
|
|
51
51
|
* }}
|
|
@@ -58,30 +58,41 @@ const DEFAULT_AGENT = `replane-js-next/${VERSION}`;
|
|
|
58
58
|
* }
|
|
59
59
|
* ```
|
|
60
60
|
*/
|
|
61
|
-
async function ReplaneRoot({ options
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
61
|
+
async function ReplaneRoot({ children,...options }) {
|
|
62
|
+
const { connection: originalConnection,...replaneOptions } = options;
|
|
63
|
+
const connectionWithAgent = originalConnection ? {
|
|
64
|
+
...originalConnection,
|
|
65
|
+
agent: originalConnection.agent ?? DEFAULT_AGENT
|
|
66
|
+
} : null;
|
|
67
|
+
const snapshot = await (0, __replanejs_sdk.getReplaneSnapshot)({
|
|
68
|
+
...replaneOptions,
|
|
69
|
+
connection: connectionWithAgent
|
|
70
|
+
});
|
|
67
71
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__replanejs_react.ReplaneProvider, {
|
|
68
|
-
|
|
72
|
+
connection: connectionWithAgent,
|
|
69
73
|
snapshot,
|
|
74
|
+
...replaneOptions,
|
|
70
75
|
children
|
|
71
76
|
});
|
|
72
77
|
}
|
|
73
78
|
|
|
74
79
|
//#endregion
|
|
80
|
+
Object.defineProperty(exports, 'Replane', {
|
|
81
|
+
enumerable: true,
|
|
82
|
+
get: function () {
|
|
83
|
+
return __replanejs_react.Replane;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
75
86
|
Object.defineProperty(exports, 'ReplaneError', {
|
|
76
87
|
enumerable: true,
|
|
77
88
|
get: function () {
|
|
78
|
-
return
|
|
89
|
+
return __replanejs_react.ReplaneError;
|
|
79
90
|
}
|
|
80
91
|
});
|
|
81
92
|
Object.defineProperty(exports, 'ReplaneErrorCode', {
|
|
82
93
|
enumerable: true,
|
|
83
94
|
get: function () {
|
|
84
|
-
return
|
|
95
|
+
return __replanejs_react.ReplaneErrorCode;
|
|
85
96
|
}
|
|
86
97
|
});
|
|
87
98
|
Object.defineProperty(exports, 'ReplaneProvider', {
|
|
@@ -103,18 +114,6 @@ Object.defineProperty(exports, 'createConfigHook', {
|
|
|
103
114
|
return __replanejs_react.createConfigHook;
|
|
104
115
|
}
|
|
105
116
|
});
|
|
106
|
-
Object.defineProperty(exports, 'createInMemoryReplaneClient', {
|
|
107
|
-
enumerable: true,
|
|
108
|
-
get: function () {
|
|
109
|
-
return __replanejs_sdk.createInMemoryReplaneClient;
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
Object.defineProperty(exports, 'createReplaneClient', {
|
|
113
|
-
enumerable: true,
|
|
114
|
-
get: function () {
|
|
115
|
-
return __replanejs_sdk.createReplaneClient;
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
117
|
Object.defineProperty(exports, 'createReplaneHook', {
|
|
119
118
|
enumerable: true,
|
|
120
119
|
get: function () {
|
|
@@ -127,12 +126,6 @@ Object.defineProperty(exports, 'getReplaneSnapshot', {
|
|
|
127
126
|
return __replanejs_react.getReplaneSnapshot;
|
|
128
127
|
}
|
|
129
128
|
});
|
|
130
|
-
Object.defineProperty(exports, 'restoreReplaneClient', {
|
|
131
|
-
enumerable: true,
|
|
132
|
-
get: function () {
|
|
133
|
-
return __replanejs_sdk.restoreReplaneClient;
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
129
|
Object.defineProperty(exports, 'useConfig', {
|
|
137
130
|
enumerable: true,
|
|
138
131
|
get: function () {
|
package/dist/index.d.cts
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
2
2
|
import { ReactNode } from "react";
|
|
3
|
-
import {
|
|
4
|
-
import { GetReplaneSnapshotOptions, ReplaneProvider, ReplaneProviderProps, ReplaneProviderWithClientProps, ReplaneProviderWithOptionsProps, clearSuspenseCache, createConfigHook, createReplaneHook, getReplaneSnapshot, useConfig, useReplane } from "@replanejs/react";
|
|
3
|
+
import { GetReplaneSnapshotOptions as GetReplaneSnapshotOptions$1 } from "@replanejs/sdk";
|
|
4
|
+
import { ConnectOptions, GetConfigOptions, GetReplaneSnapshotOptions, Replane, ReplaneContext, ReplaneError, ReplaneErrorCode, ReplaneLogger, ReplaneOptions, ReplaneProvider, ReplaneProviderProps, ReplaneProviderWithClientProps, ReplaneProviderWithOptionsProps, ReplaneSnapshot, clearSuspenseCache, createConfigHook, createReplaneHook, getReplaneSnapshot, useConfig, useReplane } from "@replanejs/react";
|
|
5
5
|
|
|
6
6
|
//#region src/root.d.ts
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Props for ReplaneRoot server component
|
|
10
10
|
*/
|
|
11
|
-
interface ReplaneRootProps<T extends object> {
|
|
12
|
-
/**
|
|
13
|
-
* Options for Replane client.
|
|
14
|
-
* Used for both server-side fetching and client-side live updates.
|
|
15
|
-
*/
|
|
16
|
-
options: ReplaneClientOptions$1<T>;
|
|
11
|
+
interface ReplaneRootProps<T extends object> extends GetReplaneSnapshotOptions$1<T> {
|
|
17
12
|
/**
|
|
18
13
|
* React children to render inside the provider
|
|
19
14
|
*/
|
|
@@ -33,7 +28,7 @@ interface ReplaneRootProps<T extends object> {
|
|
|
33
28
|
* <html>
|
|
34
29
|
* <body>
|
|
35
30
|
* <ReplaneRoot
|
|
36
|
-
*
|
|
31
|
+
* connection={{
|
|
37
32
|
* baseUrl: process.env.NEXT_PUBLIC_REPLANE_BASE_URL!,
|
|
38
33
|
* sdkKey: process.env.NEXT_PUBLIC_REPLANE_SDK_KEY!,
|
|
39
34
|
* }}
|
|
@@ -47,10 +42,10 @@ interface ReplaneRootProps<T extends object> {
|
|
|
47
42
|
* ```
|
|
48
43
|
*/
|
|
49
44
|
declare function ReplaneRoot<T extends object>({
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
children,
|
|
46
|
+
...options
|
|
52
47
|
}: ReplaneRootProps<T>): Promise<react_jsx_runtime0.JSX.Element>;
|
|
53
48
|
//# sourceMappingURL=root.d.ts.map
|
|
54
49
|
//#endregion
|
|
55
|
-
export { type
|
|
50
|
+
export { type ConnectOptions, type GetConfigOptions, type GetReplaneSnapshotOptions, Replane, type ReplaneContext, ReplaneError, ReplaneErrorCode, type ReplaneLogger, type ReplaneOptions, ReplaneProvider, type ReplaneProviderProps, type ReplaneProviderWithClientProps, type ReplaneProviderWithOptionsProps, ReplaneRoot, type ReplaneRootProps, type ReplaneSnapshot, clearSuspenseCache, createConfigHook, createReplaneHook, getReplaneSnapshot, useConfig, useReplane };
|
|
56
51
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/root.tsx"],"sourcesContent":[],"mappings":";;;;;;;AAaA;;;
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/root.tsx"],"sourcesContent":[],"mappings":";;;;;;;AAaA;;;AAIY,UAJK,gBAIL,CAAA,UAAA,MAAA,CAAA,SAJgD,2BAIhD,CAJ0E,CAI1E,CAAA,CAAA;EAAS;AAJgE;AAkCrF;EAAiC,QAAA,EA9BrB,SA8BqB;;;;;;AAAgE;;;;;;;;;;;;;;;;;;;;;;;iBAA3E;;;GAAwD,iBAAiB,KAAE,QAAA,kBAAA,CAAA,GAAA,CAAA,OAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { GetReplaneSnapshotOptions, ReplaneProvider, ReplaneProviderProps, ReplaneProviderWithClientProps, ReplaneProviderWithOptionsProps, clearSuspenseCache, createConfigHook, createReplaneHook, getReplaneSnapshot, useConfig, useReplane } from "@replanejs/react";
|
|
1
|
+
import { GetReplaneSnapshotOptions as GetReplaneSnapshotOptions$1 } from "@replanejs/sdk";
|
|
2
|
+
import { ConnectOptions, GetConfigOptions, GetReplaneSnapshotOptions, Replane, ReplaneContext, ReplaneError, ReplaneErrorCode, ReplaneLogger, ReplaneOptions, ReplaneProvider, ReplaneProviderProps, ReplaneProviderWithClientProps, ReplaneProviderWithOptionsProps, ReplaneSnapshot, clearSuspenseCache, createConfigHook, createReplaneHook, getReplaneSnapshot, useConfig, useReplane } from "@replanejs/react";
|
|
3
3
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
4
4
|
import { ReactNode } from "react";
|
|
5
5
|
|
|
@@ -8,12 +8,7 @@ import { ReactNode } from "react";
|
|
|
8
8
|
/**
|
|
9
9
|
* Props for ReplaneRoot server component
|
|
10
10
|
*/
|
|
11
|
-
interface ReplaneRootProps<T extends object> {
|
|
12
|
-
/**
|
|
13
|
-
* Options for Replane client.
|
|
14
|
-
* Used for both server-side fetching and client-side live updates.
|
|
15
|
-
*/
|
|
16
|
-
options: ReplaneClientOptions$1<T>;
|
|
11
|
+
interface ReplaneRootProps<T extends object> extends GetReplaneSnapshotOptions$1<T> {
|
|
17
12
|
/**
|
|
18
13
|
* React children to render inside the provider
|
|
19
14
|
*/
|
|
@@ -33,7 +28,7 @@ interface ReplaneRootProps<T extends object> {
|
|
|
33
28
|
* <html>
|
|
34
29
|
* <body>
|
|
35
30
|
* <ReplaneRoot
|
|
36
|
-
*
|
|
31
|
+
* connection={{
|
|
37
32
|
* baseUrl: process.env.NEXT_PUBLIC_REPLANE_BASE_URL!,
|
|
38
33
|
* sdkKey: process.env.NEXT_PUBLIC_REPLANE_SDK_KEY!,
|
|
39
34
|
* }}
|
|
@@ -47,10 +42,10 @@ interface ReplaneRootProps<T extends object> {
|
|
|
47
42
|
* ```
|
|
48
43
|
*/
|
|
49
44
|
declare function ReplaneRoot<T extends object>({
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
children,
|
|
46
|
+
...options
|
|
52
47
|
}: ReplaneRootProps<T>): Promise<react_jsx_runtime0.JSX.Element>;
|
|
53
48
|
//# sourceMappingURL=root.d.ts.map
|
|
54
49
|
//#endregion
|
|
55
|
-
export { type
|
|
50
|
+
export { type ConnectOptions, type GetConfigOptions, type GetReplaneSnapshotOptions, Replane, type ReplaneContext, ReplaneError, ReplaneErrorCode, type ReplaneLogger, type ReplaneOptions, ReplaneProvider, type ReplaneProviderProps, type ReplaneProviderWithClientProps, type ReplaneProviderWithOptionsProps, ReplaneRoot, type ReplaneRootProps, type ReplaneSnapshot, clearSuspenseCache, createConfigHook, createReplaneHook, getReplaneSnapshot, useConfig, useReplane };
|
|
56
51
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/root.tsx"],"sourcesContent":[],"mappings":";;;;;;;AAaA;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/root.tsx"],"sourcesContent":[],"mappings":";;;;;;;AAaA;;;AAIY,UAJK,gBAIL,CAAA,UAAA,MAAA,CAAA,SAJgD,2BAIhD,CAJ0E,CAI1E,CAAA,CAAA;EAAS;AAJgE;AAkCrF;EAAiC,QAAA,EA9BrB,SA8BqB;;;;;;AAAgE;;;;;;;;;;;;;;;;;;;;;;;iBAA3E;;;GAAwD,iBAAiB,KAAE,QAAA,kBAAA,CAAA,GAAA,CAAA,OAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ReplaneProvider, ReplaneProvider as ReplaneProvider$1, clearSuspenseCache, createConfigHook, createReplaneHook, getReplaneSnapshot, useConfig, useReplane } from "@replanejs/react";
|
|
1
|
+
import { getReplaneSnapshot as getReplaneSnapshot$1 } from "@replanejs/sdk";
|
|
2
|
+
import { Replane, ReplaneError, ReplaneErrorCode, ReplaneProvider, ReplaneProvider as ReplaneProvider$1, clearSuspenseCache, createConfigHook, createReplaneHook, getReplaneSnapshot, useConfig, useReplane } from "@replanejs/react";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
|
|
5
5
|
//#region src/version.ts
|
|
6
|
-
const VERSION = "0.
|
|
6
|
+
const VERSION = "0.9.2";
|
|
7
7
|
const DEFAULT_AGENT = `replane-js-next/${VERSION}`;
|
|
8
8
|
|
|
9
9
|
//#endregion
|
|
@@ -22,7 +22,7 @@ const DEFAULT_AGENT = `replane-js-next/${VERSION}`;
|
|
|
22
22
|
* <html>
|
|
23
23
|
* <body>
|
|
24
24
|
* <ReplaneRoot
|
|
25
|
-
*
|
|
25
|
+
* connection={{
|
|
26
26
|
* baseUrl: process.env.NEXT_PUBLIC_REPLANE_BASE_URL!,
|
|
27
27
|
* sdkKey: process.env.NEXT_PUBLIC_REPLANE_SDK_KEY!,
|
|
28
28
|
* }}
|
|
@@ -35,19 +35,24 @@ const DEFAULT_AGENT = `replane-js-next/${VERSION}`;
|
|
|
35
35
|
* }
|
|
36
36
|
* ```
|
|
37
37
|
*/
|
|
38
|
-
async function ReplaneRoot({ options
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
async function ReplaneRoot({ children,...options }) {
|
|
39
|
+
const { connection: originalConnection,...replaneOptions } = options;
|
|
40
|
+
const connectionWithAgent = originalConnection ? {
|
|
41
|
+
...originalConnection,
|
|
42
|
+
agent: originalConnection.agent ?? DEFAULT_AGENT
|
|
43
|
+
} : null;
|
|
44
|
+
const snapshot = await getReplaneSnapshot$1({
|
|
45
|
+
...replaneOptions,
|
|
46
|
+
connection: connectionWithAgent
|
|
47
|
+
});
|
|
44
48
|
return /* @__PURE__ */ jsx(ReplaneProvider$1, {
|
|
45
|
-
|
|
49
|
+
connection: connectionWithAgent,
|
|
46
50
|
snapshot,
|
|
51
|
+
...replaneOptions,
|
|
47
52
|
children
|
|
48
53
|
});
|
|
49
54
|
}
|
|
50
55
|
|
|
51
56
|
//#endregion
|
|
52
|
-
export { ReplaneError, ReplaneErrorCode, ReplaneProvider, ReplaneRoot, clearSuspenseCache, createConfigHook,
|
|
57
|
+
export { Replane, ReplaneError, ReplaneErrorCode, ReplaneProvider, ReplaneRoot, clearSuspenseCache, createConfigHook, createReplaneHook, getReplaneSnapshot, useConfig, useReplane };
|
|
53
58
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["ReplaneProvider"],"sources":["../src/version.ts","../src/root.tsx"],"sourcesContent":["// Auto-generated - do not edit manually\nexport const VERSION = \"0.
|
|
1
|
+
{"version":3,"file":"index.js","names":["ReplaneProvider"],"sources":["../src/version.ts","../src/root.tsx"],"sourcesContent":["// Auto-generated - do not edit manually\nexport const VERSION = \"0.9.2\";\nexport const DEFAULT_AGENT = `replane-js-next/${VERSION}`;\n","/**\n * Server-side utilities for Next.js\n * Use this module in Server Components, getServerSideProps, or getStaticProps\n */\n\nimport type { ReactNode } from \"react\";\nimport { getReplaneSnapshot, type GetReplaneSnapshotOptions } from \"@replanejs/sdk\";\nimport { ReplaneProvider } from \"@replanejs/react\";\nimport { DEFAULT_AGENT } from \"./version\";\n\n/**\n * Props for ReplaneRoot server component\n */\nexport interface ReplaneRootProps<T extends object> extends GetReplaneSnapshotOptions<T> {\n /**\n * React children to render inside the provider\n */\n children: ReactNode;\n}\n\n/**\n * Server component that fetches Replane configs and provides them to the app.\n * This is the simplest way to set up Replane in Next.js App Router.\n *\n * @example Basic usage in layout.tsx\n * ```tsx\n * // app/layout.tsx\n * import { ReplaneRoot } from \"@replanejs/next\";\n *\n * export default function RootLayout({ children }) {\n * return (\n * <html>\n * <body>\n * <ReplaneRoot\n * connection={{\n * baseUrl: process.env.NEXT_PUBLIC_REPLANE_BASE_URL!,\n * sdkKey: process.env.NEXT_PUBLIC_REPLANE_SDK_KEY!,\n * }}\n * >\n * {children}\n * </ReplaneRoot>\n * </body>\n * </html>\n * );\n * }\n * ```\n */\nexport async function ReplaneRoot<T extends object>({ children, ...options }: ReplaneRootProps<T>) {\n const { connection: originalConnection, ...replaneOptions } = options;\n const connectionWithAgent = originalConnection\n ? {\n ...originalConnection,\n agent: originalConnection.agent ?? DEFAULT_AGENT,\n }\n : null;\n const snapshot = await getReplaneSnapshot({\n ...replaneOptions,\n connection: connectionWithAgent,\n });\n\n return (\n <ReplaneProvider connection={connectionWithAgent} snapshot={snapshot} {...replaneOptions}>\n {children}\n </ReplaneProvider>\n );\n}\n"],"mappings":";;;;;AACA,MAAa,UAAU;AACvB,MAAa,iBAAiB,kBAAkB,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC6CxD,eAAsB,YAA8B,EAAE,SAAU,GAAG,SAA8B,EAAE;CACjG,MAAM,EAAE,YAAY,mBAAoB,GAAG,gBAAgB,GAAG;CAC9D,MAAM,sBAAsB,qBACxB;EACE,GAAG;EACH,OAAO,mBAAmB,SAAS;CACpC,IACD;CACJ,MAAM,WAAW,MAAM,qBAAmB;EACxC,GAAG;EACH,YAAY;CACb,EAAC;AAEF,wBACE,IAACA;EAAgB,YAAY;EAA+B;EAAU,GAAI;EACvE;GACe;AAErB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@replanejs/next",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"description": "Next.js SDK for Replane - feature flags and remote configuration with SSR support",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"react": ">=18.0.0"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@replanejs/
|
|
49
|
-
"@replanejs/
|
|
48
|
+
"@replanejs/react": "^0.9.2",
|
|
49
|
+
"@replanejs/sdk": "^0.9.2"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@types/node": "^22.19.3",
|