@replanejs/svelte 0.7.8 → 0.8.0

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 CHANGED
@@ -1,5 +1,9 @@
1
1
  # @replanejs/svelte
2
2
 
3
+ [![npm](https://img.shields.io/npm/v/@replanejs/svelte)](https://www.npmjs.com/package/@replanejs/svelte)
4
+ [![License](https://img.shields.io/github/license/replane-dev/replane-javascript)](https://github.com/replane-dev/replane-javascript/blob/main/LICENSE)
5
+ [![Community](https://img.shields.io/badge/discussions-join-blue?logo=github)](https://github.com/orgs/replane-dev/discussions)
6
+
3
7
  Svelte SDK for [Replane](https://github.com/replane-dev/replane-javascript) - feature flags and remote configuration with reactive stores.
4
8
 
5
9
  ## Installation
@@ -15,13 +19,13 @@ npm install @replanejs/svelte
15
19
  import { ReplaneContext, config } from '@replanejs/svelte';
16
20
  import { createReplaneClient } from '@replanejs/svelte';
17
21
 
18
- const client = await createReplaneClient({
22
+ const replane = await createReplaneClient({
19
23
  baseUrl: 'https://your-replane-server.com',
20
24
  sdkKey: 'your-sdk-key',
21
25
  });
22
26
  </script>
23
27
 
24
- <ReplaneContext {client}>
28
+ <ReplaneContext client={replane}>
25
29
  <MyComponent />
26
30
  </ReplaneContext>
27
31
  ```
@@ -73,10 +77,10 @@ Get direct access to the Replane client from context.
73
77
  <script>
74
78
  import { getReplane } from '@replanejs/svelte';
75
79
 
76
- const { client } = getReplane();
80
+ const replane = getReplane();
77
81
 
78
82
  function handleClick() {
79
- const value = client.get('some-config');
83
+ const value = replane.get('some-config');
80
84
  console.log(value);
81
85
  }
82
86
  </script>
@@ -86,14 +90,15 @@ Get direct access to the Replane client from context.
86
90
 
87
91
  ### configFrom
88
92
 
89
- Create a reactive store from a client directly (without context).
93
+ Create a reactive store from a client directly (without context). Type-safe with full autocomplete for config names.
90
94
 
91
95
  ```svelte
92
96
  <script>
93
97
  import { configFrom } from '@replanejs/svelte';
94
- import { client } from './replane-client';
98
+ import { replane } from './replane-client';
95
99
 
96
- const featureEnabled = configFrom<boolean>(client, 'featureEnabled');
100
+ // Config name is validated against TConfigs, return type is inferred
101
+ const featureEnabled = configFrom(replane, 'featureEnabled');
97
102
  </script>
98
103
 
99
104
  {#if $featureEnabled}
@@ -113,13 +118,13 @@ Can be used in three ways:
113
118
  <script>
114
119
  import { ReplaneContext, createReplaneClient } from '@replanejs/svelte';
115
120
 
116
- const client = await createReplaneClient({
121
+ const replane = await createReplaneClient({
117
122
  baseUrl: 'https://your-replane-server.com',
118
123
  sdkKey: 'your-sdk-key',
119
124
  });
120
125
  </script>
121
126
 
122
- <ReplaneContext {client}>
127
+ <ReplaneContext client={replane}>
123
128
  <App />
124
129
  </ReplaneContext>
125
130
  ```
@@ -189,11 +194,15 @@ export const getAppReplane = createTypedReplane<AppConfigs>();
189
194
 
190
195
  ```svelte
191
196
  <script lang="ts">
192
- import { appConfig } from '$lib/replane';
197
+ import { appConfig, getAppReplane } from '$lib/replane';
193
198
 
194
199
  // Config names autocomplete, values are fully typed
195
200
  const theme = appConfig("theme");
196
201
  // $theme is { darkMode: boolean; primaryColor: string }
202
+
203
+ // Direct client access
204
+ const replane = getAppReplane();
205
+ const features = replane.get("features"); // fully typed
197
206
  </script>
198
207
 
199
208
  <div style:color={$theme.primaryColor}>
@@ -253,6 +262,10 @@ All stores automatically subscribe to realtime updates via SSE. When a config ch
253
262
  {/if}
254
263
  ```
255
264
 
265
+ ## Community
266
+
267
+ Have questions or want to discuss Replane? Join the conversation in [GitHub Discussions](https://github.com/orgs/replane-dev/discussions).
268
+
256
269
  ## License
257
270
 
258
271
  MIT
@@ -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,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,IAAI,CAGnG;AAED;;;GAGG;AAEH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,GAAG,KAAK,mBAAmB,CAAC,CAAC,CAAC,CAMnG;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAO3C"}
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,CAAC,MAAM,EAAE,OAAO,CAAC,EACjE,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,GACvB,IAAI,CAGN;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAE/B,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,GAAG,KACpC,mBAAmB,CAAC,CAAC,CAAC,CAM1B;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAO3C"}
package/dist/context.js CHANGED
@@ -12,11 +12,10 @@ export function setReplaneContext(client) {
12
12
  * Get the Replane context from Svelte context.
13
13
  * @internal
14
14
  */
15
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
15
  export function getReplaneContext() {
17
16
  const context = getContext(REPLANE_CONTEXT_KEY);
18
17
  if (!context) {
19
- throw new Error("getReplane() must be used within a ReplaneProvider");
18
+ throw new Error("getReplane() must be used within a ReplaneContext");
20
19
  }
21
20
  return context;
22
21
  }
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  export { default as ReplaneContext } from "./ReplaneContext.svelte";
2
2
  export { getReplane, config, configFrom, createTypedReplane, createTypedConfig } from "./stores";
3
3
  export { setReplaneContext, getReplaneContext, hasReplaneContext } from "./context";
4
- export { createReplaneClient, createInMemoryReplaneClient, restoreReplaneClient, getReplaneSnapshot, clearSnapshotCache, ReplaneError, ReplaneErrorCode, } from "@replanejs/sdk";
4
+ export { createReplaneClient, createInMemoryReplaneClient, restoreReplaneClient, getReplaneSnapshot, ReplaneError, ReplaneErrorCode, } from "@replanejs/sdk";
5
5
  export type { ReplaneClient, ReplaneClientOptions, ReplaneSnapshot, ReplaneLogger, GetConfigOptions, RestoreReplaneClientOptions, GetReplaneSnapshotOptions, } from "@replanejs/sdk";
6
- export type { ReplaneContextValue, ReplaneContextProps, ReplaneContextWithClientProps, ReplaneContextWithOptionsProps, ConfigOptions, } from "./types";
6
+ export type { ReplaneContextValue, ReplaneContextProps, ReplaneContextWithClientProps, ReplaneContextWithOptionsProps, } from "./types";
7
7
  export { hasClient, hasOptions } from "./types";
8
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAGpE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAGjG,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAGpF,OAAO,EACL,mBAAmB,EACnB,2BAA2B,EAC3B,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AAExB,YAAY,EACV,aAAa,EACb,oBAAoB,EACpB,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,2BAA2B,EAC3B,yBAAyB,GAC1B,MAAM,gBAAgB,CAAC;AAGxB,YAAY,EACV,mBAAmB,EACnB,mBAAmB,EACnB,6BAA6B,EAC7B,8BAA8B,EAC9B,aAAa,GACd,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAGpE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAGjG,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAGpF,OAAO,EACL,mBAAmB,EACnB,2BAA2B,EAC3B,oBAAoB,EACpB,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AAExB,YAAY,EACV,aAAa,EACb,oBAAoB,EACpB,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,2BAA2B,EAC3B,yBAAyB,GAC1B,MAAM,gBAAgB,CAAC;AAGxB,YAAY,EACV,mBAAmB,EACnB,mBAAmB,EACnB,6BAA6B,EAC7B,8BAA8B,GAC/B,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -5,6 +5,6 @@ export { getReplane, config, configFrom, createTypedReplane, createTypedConfig }
5
5
  // Context utilities (for advanced use cases)
6
6
  export { setReplaneContext, getReplaneContext, hasReplaneContext } from "./context";
7
7
  // Re-export from SDK for convenience
8
- export { createReplaneClient, createInMemoryReplaneClient, restoreReplaneClient, getReplaneSnapshot, clearSnapshotCache, ReplaneError, ReplaneErrorCode, } from "@replanejs/sdk";
8
+ export { createReplaneClient, createInMemoryReplaneClient, restoreReplaneClient, getReplaneSnapshot, ReplaneError, ReplaneErrorCode, } from "@replanejs/sdk";
9
9
  // Type guards
10
10
  export { hasClient, hasOptions } from "./types";
package/dist/stores.d.ts CHANGED
@@ -1,12 +1,11 @@
1
1
  import { type Readable } from "svelte/store";
2
- import type { ReplaneClient } from "@replanejs/sdk";
3
- import type { ReplaneContextValue, ConfigOptions } from "./types";
2
+ import type { GetConfigOptions, ReplaneClient } from "@replanejs/sdk";
4
3
  /**
5
- * Get the Replane context containing the client.
4
+ * Get the Replane client from context.
6
5
  *
7
6
  * Must be called during component initialization (in the script section, not in event handlers).
8
7
  *
9
- * @returns The Replane context with the client
8
+ * @returns The Replane client
10
9
  * @throws Error if called outside a ReplaneProvider
11
10
  *
12
11
  * @example
@@ -14,12 +13,12 @@ import type { ReplaneContextValue, ConfigOptions } from "./types";
14
13
  * <script>
15
14
  * import { getReplane } from '@replanejs/svelte';
16
15
  *
17
- * const { client } = getReplane();
18
- * // Access client directly: client.get('configName')
16
+ * const replane = getReplane();
17
+ * // Access client directly: replane.get('configName')
19
18
  * </script>
20
19
  * ```
21
20
  */
22
- export declare function getReplane<T extends Record<string, unknown> = any>(): ReplaneContextValue<T>;
21
+ export declare function getReplane<T extends Record<string, unknown> = any>(): ReplaneClient<T>;
23
22
  /**
24
23
  * Create a reactive store for a specific config value.
25
24
  *
@@ -46,14 +45,14 @@ export declare function getReplane<T extends Record<string, unknown> = any>(): R
46
45
  * {/if}
47
46
  * ```
48
47
  */
49
- export declare function config<T>(name: string, options?: ConfigOptions): Readable<T>;
48
+ export declare function config<T>(name: string, options?: GetConfigOptions<T>): Readable<T>;
50
49
  /**
51
50
  * Create a reactive store for a config value using a pre-existing client.
52
51
  *
53
52
  * This is useful when you have direct access to a client and don't want to
54
53
  * use the context-based approach. Similar to readable() or derived().
55
54
  *
56
- * @param client - The Replane client to use
55
+ * @param replane - The Replane client to use
57
56
  * @param name - The name of the config to subscribe to
58
57
  * @param options - Optional context for override evaluation
59
58
  * @returns A Svelte readable store containing the config value
@@ -62,9 +61,9 @@ export declare function config<T>(name: string, options?: ConfigOptions): Readab
62
61
  * ```svelte
63
62
  * <script>
64
63
  * import { configFrom } from '@replanejs/svelte';
65
- * import { client } from './replane-client';
64
+ * import { replane } from './replane-client';
66
65
  *
67
- * const featureEnabled = configFrom<boolean>(client, 'featureEnabled');
66
+ * const featureEnabled = configFrom(replane, 'featureEnabled');
68
67
  * </script>
69
68
  *
70
69
  * {#if $featureEnabled}
@@ -72,7 +71,7 @@ export declare function config<T>(name: string, options?: ConfigOptions): Readab
72
71
  * {/if}
73
72
  * ```
74
73
  */
75
- export declare function configFrom<T, C extends Record<string, unknown> = any>(client: ReplaneClient<C>, name: string, options?: ConfigOptions): Readable<T>;
74
+ export declare function configFrom<TConfigs extends Record<string, unknown>, K extends keyof TConfigs>(replane: ReplaneClient<TConfigs>, name: K, options?: GetConfigOptions<TConfigs[K]>): Readable<TConfigs[K]>;
76
75
  /**
77
76
  * Creates a typed version of getReplane().
78
77
  *
@@ -97,12 +96,12 @@ export declare function configFrom<T, C extends Record<string, unknown> = any>(c
97
96
  * <script>
98
97
  * import { getAppReplane } from './lib/replane';
99
98
  *
100
- * const { client } = getAppReplane();
101
- * const theme = client.get("theme"); // fully typed
99
+ * const replane = getAppReplane();
100
+ * const theme = replane.get("theme"); // fully typed
102
101
  * </script>
103
102
  * ```
104
103
  */
105
- export declare function createTypedReplane<TConfigs extends Record<string, unknown>>(): () => ReplaneContextValue<TConfigs>;
104
+ export declare function createTypedReplane<TConfigs extends Record<string, unknown>>(): () => ReplaneClient<TConfigs>;
106
105
  /**
107
106
  * Creates a typed version of config().
108
107
  *
@@ -137,5 +136,5 @@ export declare function createTypedReplane<TConfigs extends Record<string, unkno
137
136
  * </div>
138
137
  * ```
139
138
  */
140
- export declare function createTypedConfig<TConfigs extends Record<string, unknown>>(): <K extends keyof TConfigs>(name: K, options?: ConfigOptions) => Readable<TConfigs[K]>;
139
+ export declare function createTypedConfig<TConfigs extends Record<string, unknown>>(): <K extends keyof TConfigs>(name: K, options?: GetConfigOptions<TConfigs[K]>) => Readable<TConfigs[K]>;
141
140
  //# sourceMappingURL=stores.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"stores.d.ts","sourceRoot":"","sources":["../src/stores.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAElE;;;;;;;;;;;;;;;;;GAiBG;AAEH,wBAAgB,UAAU,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,GAAG,KAAK,mBAAmB,CAAC,CAAC,CAAC,CAE5F;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,QAAQ,CAAC,CAAC,CAAC,CAY5E;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,wBAAgB,UAAU,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,GAAG,EACnE,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,EACxB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,aAAa,GACtB,QAAQ,CAAC,CAAC,CAAC,CAOb;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,WACrD,mBAAmB,CAAC,QAAQ,CAAC,CAGlD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,MACvD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AAC,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,MACvD,CAAC,SAAS,MAAM,QAAQ,EACvC,MAAM,CAAC,EACP,UAAU,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KACtC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAGzB"}
package/dist/stores.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import { readable } from "svelte/store";
2
2
  import { getReplaneContext } from "./context";
3
3
  /**
4
- * Get the Replane context containing the client.
4
+ * Get the Replane client from context.
5
5
  *
6
6
  * Must be called during component initialization (in the script section, not in event handlers).
7
7
  *
8
- * @returns The Replane context with the client
8
+ * @returns The Replane client
9
9
  * @throws Error if called outside a ReplaneProvider
10
10
  *
11
11
  * @example
@@ -13,14 +13,14 @@ import { getReplaneContext } from "./context";
13
13
  * <script>
14
14
  * import { getReplane } from '@replanejs/svelte';
15
15
  *
16
- * const { client } = getReplane();
17
- * // Access client directly: client.get('configName')
16
+ * const replane = getReplane();
17
+ * // Access client directly: replane.get('configName')
18
18
  * </script>
19
19
  * ```
20
20
  */
21
21
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
22
22
  export function getReplane() {
23
- return getReplaneContext();
23
+ return getReplaneContext().client;
24
24
  }
25
25
  /**
26
26
  * Create a reactive store for a specific config value.
@@ -65,7 +65,7 @@ export function config(name, options) {
65
65
  * This is useful when you have direct access to a client and don't want to
66
66
  * use the context-based approach. Similar to readable() or derived().
67
67
  *
68
- * @param client - The Replane client to use
68
+ * @param replane - The Replane client to use
69
69
  * @param name - The name of the config to subscribe to
70
70
  * @param options - Optional context for override evaluation
71
71
  * @returns A Svelte readable store containing the config value
@@ -74,9 +74,9 @@ export function config(name, options) {
74
74
  * ```svelte
75
75
  * <script>
76
76
  * import { configFrom } from '@replanejs/svelte';
77
- * import { client } from './replane-client';
77
+ * import { replane } from './replane-client';
78
78
  *
79
- * const featureEnabled = configFrom<boolean>(client, 'featureEnabled');
79
+ * const featureEnabled = configFrom(replane, 'featureEnabled');
80
80
  * </script>
81
81
  *
82
82
  * {#if $featureEnabled}
@@ -84,11 +84,10 @@ export function config(name, options) {
84
84
  * {/if}
85
85
  * ```
86
86
  */
87
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
88
- export function configFrom(client, name, options) {
89
- return readable(client.get(name, options), (set) => {
90
- const unsubscribe = client.subscribe(name, () => {
91
- set(client.get(name, options));
87
+ export function configFrom(replane, name, options) {
88
+ return readable(replane.get(name, options), (set) => {
89
+ const unsubscribe = replane.subscribe(name, () => {
90
+ set(replane.get(name, options));
92
91
  });
93
92
  return unsubscribe;
94
93
  });
@@ -117,8 +116,8 @@ export function configFrom(client, name, options) {
117
116
  * <script>
118
117
  * import { getAppReplane } from './lib/replane';
119
118
  *
120
- * const { client } = getAppReplane();
121
- * const theme = client.get("theme"); // fully typed
119
+ * const replane = getAppReplane();
120
+ * const theme = replane.get("theme"); // fully typed
122
121
  * </script>
123
122
  * ```
124
123
  */
package/dist/types.d.ts CHANGED
@@ -46,13 +46,4 @@ export declare function hasClient<T extends Record<string, unknown>>(props: Repl
46
46
  * Type guard to check if props contain options (with or without snapshot).
47
47
  */
48
48
  export declare function hasOptions<T extends Record<string, unknown>>(props: ReplaneContextProps<T>): props is ReplaneContextWithOptionsProps<T>;
49
- /**
50
- * Options for config()
51
- */
52
- export interface ConfigOptions {
53
- /**
54
- * Context for override evaluation (merged with client-level context).
55
- */
56
- context?: Record<string, string | number | boolean | null>;
57
- }
58
49
  //# sourceMappingURL=types.d.ts.map
@@ -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;AAEH,MAAM,WAAW,mBAAmB,CAAC,C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C;AAEtC;;GAEG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACzD,KAAK,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAC5B,KAAK,IAAI,6BAA6B,CAAC,CAAC,CAAC,CAE3C;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC1D,KAAK,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAC5B,KAAK,IAAI,8BAA8B,CAAC,CAAC,CAAC,CAE5C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@replanejs/svelte",
3
- "version": "0.7.8",
3
+ "version": "0.8.0",
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.7.8"
42
+ "@replanejs/sdk": "^0.8.0"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@sveltejs/package": "^2.3.10",