@replanejs/svelte 0.8.8 → 0.8.10
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/ReplaneContext.svelte +12 -7
- package/dist/ReplaneContext.svelte.d.ts +23 -2
- package/dist/ReplaneContext.svelte.d.ts.map +1 -1
- package/dist/context.d.ts +2 -2
- package/dist/context.d.ts.map +1 -1
- package/dist/types.d.ts +6 -6
- package/dist/types.d.ts.map +1 -1
- package/dist/version.d.ts +3 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +3 -0
- package/package.json +3 -2
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
ReplaneContextWithClientProps,
|
|
6
6
|
ReplaneContextWithOptionsProps,
|
|
7
7
|
} from "./types";
|
|
8
|
+
import { DEFAULT_AGENT } from "./version";
|
|
8
9
|
|
|
9
10
|
export type {
|
|
10
11
|
ReplaneContextProps,
|
|
@@ -13,20 +14,20 @@
|
|
|
13
14
|
};
|
|
14
15
|
</script>
|
|
15
16
|
|
|
16
|
-
<script lang="ts">
|
|
17
|
+
<script lang="ts" generics="T extends object">
|
|
17
18
|
import { createReplaneClient, restoreReplaneClient } from "@replanejs/sdk";
|
|
18
19
|
import { setReplaneContext } from "./context";
|
|
19
20
|
import { hasClient } from "./types";
|
|
20
21
|
|
|
21
|
-
let props: ReplaneContextProps = $props();
|
|
22
|
+
let props: ReplaneContextProps<T> = $props();
|
|
22
23
|
|
|
23
24
|
type ClientState =
|
|
24
25
|
| { status: "loading"; client: null; error: null }
|
|
25
|
-
| { status: "ready"; client: ReplaneClient<
|
|
26
|
+
| { status: "ready"; client: ReplaneClient<T>; error: null }
|
|
26
27
|
| { status: "error"; client: null; error: Error };
|
|
27
28
|
|
|
28
29
|
let state = $state<ClientState>({ status: "loading", client: null, error: null });
|
|
29
|
-
let clientRef: ReplaneClient<
|
|
30
|
+
let clientRef: ReplaneClient<T> | null = null;
|
|
30
31
|
let cancelled = false;
|
|
31
32
|
|
|
32
33
|
// Handle client initialization based on props
|
|
@@ -45,7 +46,7 @@
|
|
|
45
46
|
if (snapshot) {
|
|
46
47
|
// Restore from snapshot synchronously
|
|
47
48
|
try {
|
|
48
|
-
const client = restoreReplaneClient({
|
|
49
|
+
const client = restoreReplaneClient<T>({
|
|
49
50
|
snapshot,
|
|
50
51
|
connection: {
|
|
51
52
|
baseUrl: options.baseUrl,
|
|
@@ -55,6 +56,7 @@
|
|
|
55
56
|
retryDelayMs: options.retryDelayMs,
|
|
56
57
|
inactivityTimeoutMs: options.inactivityTimeoutMs,
|
|
57
58
|
logger: options.logger,
|
|
59
|
+
agent: options.agent ?? DEFAULT_AGENT,
|
|
58
60
|
},
|
|
59
61
|
context: options.context,
|
|
60
62
|
});
|
|
@@ -70,7 +72,10 @@
|
|
|
70
72
|
// Async client creation
|
|
71
73
|
state = { status: "loading", client: null, error: null };
|
|
72
74
|
|
|
73
|
-
createReplaneClient(
|
|
75
|
+
createReplaneClient<T>({
|
|
76
|
+
...options,
|
|
77
|
+
agent: options.agent ?? DEFAULT_AGENT,
|
|
78
|
+
})
|
|
74
79
|
.then((client) => {
|
|
75
80
|
if (cancelled) {
|
|
76
81
|
client.close();
|
|
@@ -98,7 +103,7 @@
|
|
|
98
103
|
// Set context when client is ready
|
|
99
104
|
$effect(() => {
|
|
100
105
|
if (state.status === "ready" && state.client) {
|
|
101
|
-
setReplaneContext(state.client);
|
|
106
|
+
setReplaneContext<T>(state.client);
|
|
102
107
|
}
|
|
103
108
|
});
|
|
104
109
|
|
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
import type { ReplaneContextProps, ReplaneContextWithClientProps, ReplaneContextWithOptionsProps } from "./types";
|
|
2
2
|
export type { ReplaneContextProps, ReplaneContextWithClientProps, ReplaneContextWithOptionsProps, };
|
|
3
|
-
declare
|
|
4
|
-
|
|
3
|
+
declare function $$render<T extends object>(): {
|
|
4
|
+
props: ReplaneContextProps<T>;
|
|
5
|
+
exports: {};
|
|
6
|
+
bindings: "";
|
|
7
|
+
slots: {};
|
|
8
|
+
events: {};
|
|
9
|
+
};
|
|
10
|
+
declare class __sveltets_Render<T extends object> {
|
|
11
|
+
props(): ReturnType<typeof $$render<T>>['props'];
|
|
12
|
+
events(): ReturnType<typeof $$render<T>>['events'];
|
|
13
|
+
slots(): ReturnType<typeof $$render<T>>['slots'];
|
|
14
|
+
bindings(): "";
|
|
15
|
+
exports(): {};
|
|
16
|
+
}
|
|
17
|
+
interface $$IsomorphicComponent {
|
|
18
|
+
new <T extends object>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & {
|
|
19
|
+
$$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
|
|
20
|
+
} & ReturnType<__sveltets_Render<T>['exports']>;
|
|
21
|
+
<T extends object>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
|
|
22
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
23
|
+
}
|
|
24
|
+
declare const ReplaneContext: $$IsomorphicComponent;
|
|
25
|
+
type ReplaneContext<T extends object> = InstanceType<typeof ReplaneContext<T>>;
|
|
5
26
|
export default ReplaneContext;
|
|
6
27
|
//# sourceMappingURL=ReplaneContext.svelte.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReplaneContext.svelte.d.ts","sourceRoot":"","sources":["../src/ReplaneContext.svelte.ts"],"names":[],"mappings":"AAIE,OAAO,KAAK,EACV,mBAAmB,EACnB,6BAA6B,EAC7B,8BAA8B,EAC/B,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"ReplaneContext.svelte.d.ts","sourceRoot":"","sources":["../src/ReplaneContext.svelte.ts"],"names":[],"mappings":"AAIE,OAAO,KAAK,EACV,m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CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;IAC1I,YAAY,CAAC,EAAE,UAAU,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;CACjE;AACD,QAAA,MAAM,cAAc,EAAE,qBAAmC,CAAC;AACxC,KAAK,cAAc,CAAC,CAAC,SAAS,MAAM,IAAI,YAAY,CAAC,OAAO,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;AACjF,eAAe,cAAc,CAAC"}
|
package/dist/context.d.ts
CHANGED
|
@@ -4,12 +4,12 @@ import type { ReplaneContextValue } from "./types";
|
|
|
4
4
|
* Set the Replane client in Svelte context.
|
|
5
5
|
* @internal
|
|
6
6
|
*/
|
|
7
|
-
export declare function setReplaneContext<T extends
|
|
7
|
+
export declare function setReplaneContext<T extends object>(client: ReplaneClient<T>): void;
|
|
8
8
|
/**
|
|
9
9
|
* Get the Replane context from Svelte context.
|
|
10
10
|
* @internal
|
|
11
11
|
*/
|
|
12
|
-
export declare function getReplaneContext<T extends Record<string, unknown
|
|
12
|
+
export declare function getReplaneContext<T extends object = Record<string, unknown>>(): ReplaneContextValue<T>;
|
|
13
13
|
/**
|
|
14
14
|
* Check if Replane context is available.
|
|
15
15
|
* @internal
|
package/dist/context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAInD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAInD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,IAAI,CAGlF;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,CAAC,SAAS,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KACvC,mBAAmB,CAAC,CAAC,CAAC,CAM1B;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAO3C"}
|
package/dist/types.d.ts
CHANGED
|
@@ -3,13 +3,13 @@ import type { Snippet } from "svelte";
|
|
|
3
3
|
/**
|
|
4
4
|
* Context value containing the Replane client
|
|
5
5
|
*/
|
|
6
|
-
export interface ReplaneContextValue<T extends Record<string, unknown
|
|
6
|
+
export interface ReplaneContextValue<T extends object = Record<string, unknown>> {
|
|
7
7
|
client: ReplaneClient<T>;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* Props for ReplaneContext when using a pre-created client.
|
|
11
11
|
*/
|
|
12
|
-
export interface ReplaneContextWithClientProps<T extends Record<string, unknown
|
|
12
|
+
export interface ReplaneContextWithClientProps<T extends object = Record<string, unknown>> {
|
|
13
13
|
/** Pre-created ReplaneClient instance */
|
|
14
14
|
client: ReplaneClient<T>;
|
|
15
15
|
/** Children snippet */
|
|
@@ -18,7 +18,7 @@ export interface ReplaneContextWithClientProps<T extends Record<string, unknown>
|
|
|
18
18
|
/**
|
|
19
19
|
* Props for ReplaneContext when letting it manage the client internally.
|
|
20
20
|
*/
|
|
21
|
-
export interface ReplaneContextWithOptionsProps<T extends Record<string, unknown
|
|
21
|
+
export interface ReplaneContextWithOptionsProps<T extends object = Record<string, unknown>> {
|
|
22
22
|
/** Options to create or restore the ReplaneClient */
|
|
23
23
|
options: ReplaneClientOptions<T>;
|
|
24
24
|
/** Children snippet */
|
|
@@ -37,13 +37,13 @@ export interface ReplaneContextWithOptionsProps<T extends Record<string, unknown
|
|
|
37
37
|
*/
|
|
38
38
|
loader?: Snippet;
|
|
39
39
|
}
|
|
40
|
-
export type ReplaneContextProps<T extends Record<string, unknown
|
|
40
|
+
export type ReplaneContextProps<T extends object = Record<string, unknown>> = ReplaneContextWithClientProps<T> | ReplaneContextWithOptionsProps<T>;
|
|
41
41
|
/**
|
|
42
42
|
* Type guard to check if props contain a pre-created client.
|
|
43
43
|
*/
|
|
44
|
-
export declare function hasClient<T extends
|
|
44
|
+
export declare function hasClient<T extends object>(props: ReplaneContextProps<T>): props is ReplaneContextWithClientProps<T>;
|
|
45
45
|
/**
|
|
46
46
|
* Type guard to check if props contain options (with or without snapshot).
|
|
47
47
|
*/
|
|
48
|
-
export declare function hasOptions<T extends
|
|
48
|
+
export declare function hasOptions<T extends object>(props: ReplaneContextProps<T>): props is ReplaneContextWithOptionsProps<T>;
|
|
49
49
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC3F,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEtC;;GAEG;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC3F,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEtC;;GAEG;AACH,MAAM,WAAW,mBAAmB,CAAC,CAAC,SAAS,MAAM,GAAG,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,MAAM,OAAO,WAAW,CAAC;AAChC,eAAO,MAAM,aAAa,0BAA8B,CAAC"}
|
package/dist/version.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@replanejs/svelte",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.10",
|
|
4
4
|
"description": "Svelte SDK for Replane - feature flags and remote configuration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"svelte": "./dist/index.js",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"svelte": ">=4.0.0"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@replanejs/sdk": "^0.8.
|
|
42
|
+
"@replanejs/sdk": "^0.8.10"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@sveltejs/package": "^2.3.10",
|
|
@@ -62,6 +62,7 @@
|
|
|
62
62
|
"access": "public"
|
|
63
63
|
},
|
|
64
64
|
"scripts": {
|
|
65
|
+
"prebuild": "node ../../scripts/update-version.js .",
|
|
65
66
|
"build": "svelte-package -i src -o dist",
|
|
66
67
|
"dev": "svelte-package -i src -o dist --watch",
|
|
67
68
|
"typecheck": "svelte-check --tsconfig ./tsconfig.json",
|