@avsbhq/vue 1.0.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.
@@ -0,0 +1,279 @@
1
+ import * as vue from 'vue';
2
+ import { PropType, Plugin, InjectionKey, Ref, ComputedRef } from 'vue';
3
+ import { InitResult, EvalContext, Flag, TrackPayload, ClientEventName, ClientEventMap } from '@avsbhq/core';
4
+ export { ClientEventMap, ClientEventName, DecideOption, EvalContext, EvaluationSource, Flag, FlagDatafile, FlagDatafileAudience, FlagDatafileEntry, FlagDatafileOverride, FlagDatafileRule, FlagDatafileVariation, InitResult, Logger, MultiContext, SingleContext, TrackPayload } from '@avsbhq/core';
5
+ import { AvsbClientOptions } from '@avsbhq/browser';
6
+ export { AvsbClientOptions } from '@avsbhq/browser';
7
+ import * as pinia from 'pinia';
8
+
9
+ /**
10
+ * The surface of AvsbClient that @avsbhq/vue depends on.
11
+ *
12
+ * This interface describes the new browser SDK surface being added in
13
+ * CoW 3 (sdk-launch-readiness). Until @avsbhq/browser ships the full
14
+ * implementation, the Vue package compiles against this interface rather
15
+ * than the concrete class, avoiding cross-package coupling during the
16
+ * in-progress reshape.
17
+ *
18
+ * When the browser SDK reshape lands, AvsbClient will satisfy this
19
+ * interface structurally — no cast required. Until then, any runtime
20
+ * use of these methods is guarded with `typeof client.method === 'function'`
21
+ * checks in each composable.
22
+ */
23
+
24
+ interface VueAvsbClient {
25
+ onReady(): Promise<InitResult>;
26
+ close(): Promise<void>;
27
+ flush(): Promise<void>;
28
+ identify(ctx: EvalContext): void;
29
+ updateAttributes(partial: Record<string, unknown>, kind?: string): void;
30
+ alias(prev: EvalContext, next: EvalContext): Promise<void>;
31
+ getContext(): EvalContext;
32
+ reset(): void;
33
+ getFlag<T>(key: string, defaultValue: T): Flag<T>;
34
+ getBoolFlag(key: string, defaultValue: boolean): Flag<boolean>;
35
+ getStringFlag(key: string, defaultValue: string): Flag<string>;
36
+ getNumberFlag(key: string, defaultValue: number): Flag<number>;
37
+ getJsonFlag<T>(key: string, defaultValue: T): Flag<T>;
38
+ getAllFlags(options?: {
39
+ fireExposures?: boolean;
40
+ }): Record<string, Flag>;
41
+ /** Subscribe to changes for a specific flagKey; returns unsubscribe. */
42
+ subscribe(flagKey: string, listener: () => void): () => void;
43
+ /** Return a stable Flag<T> snapshot without firing an exposure event. */
44
+ getSnapshot<T>(flagKey: string, defaultValue: T): Flag<T>;
45
+ track(eventKey: string, payload?: TrackPayload): void;
46
+ on<E extends ClientEventName>(event: E, cb: ClientEventMap[E]): () => void;
47
+ setOverrideForUser(flagKey: string, contextKey: string, variationKey: string, contextKind?: string): void;
48
+ setGlobalOverride(flagKey: string, variationKey: string): void;
49
+ clearOverrideForUser(flagKey: string, contextKey: string, contextKind?: string): void;
50
+ clearGlobalOverride(flagKey: string): void;
51
+ clearAllOverrides(): void;
52
+ }
53
+
54
+ declare const AvsbProvider: vue.DefineComponent<vue.ExtractPropTypes<{
55
+ client: {
56
+ type: PropType<VueAvsbClient>;
57
+ default: undefined;
58
+ };
59
+ sdkKey: {
60
+ type: StringConstructor;
61
+ default: undefined;
62
+ };
63
+ }>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
64
+ [key: string]: any;
65
+ }>[] | undefined, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
66
+ client: {
67
+ type: PropType<VueAvsbClient>;
68
+ default: undefined;
69
+ };
70
+ sdkKey: {
71
+ type: StringConstructor;
72
+ default: undefined;
73
+ };
74
+ }>> & Readonly<{}>, {
75
+ client: VueAvsbClient;
76
+ sdkKey: string;
77
+ }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
78
+
79
+ /**
80
+ * AvsbPlugin — Vue plugin alternative to mounting <AvsbProvider>.
81
+ *
82
+ * Usage:
83
+ * // Mode A: SDK creates and owns the client
84
+ * app.use(AvsbPlugin, { sdkKey: 'sdk-xxx', attributes: { userId: 'u_1' } })
85
+ *
86
+ * // Mode B: pass a pre-built client
87
+ * app.use(AvsbPlugin, { client: myClient })
88
+ *
89
+ * The plugin installs AvsbProvider semantics at the app level via
90
+ * app.provide(). It is equivalent to wrapping the root component in
91
+ * <AvsbProvider>, but works better with apps that prefer the plugin
92
+ * pattern over SFC wrapper components.
93
+ */
94
+
95
+ type AvsbPluginOptions = (AvsbClientOptions & {
96
+ client?: never;
97
+ }) | {
98
+ client: VueAvsbClient;
99
+ };
100
+ declare const AvsbPlugin: Plugin<AvsbPluginOptions>;
101
+
102
+ interface AvsbContextValue {
103
+ client: VueAvsbClient | null;
104
+ status: 'loading' | 'ready' | 'error';
105
+ error?: Error;
106
+ }
107
+ declare const AvsbInjectionKey: InjectionKey<AvsbContextValue>;
108
+
109
+ /**
110
+ * §5.13 + §5.14 — Subscribe to a single flag.
111
+ *
112
+ * Returns `ComputedRef<Flag<T>>` (not raw `T`). The computed re-evaluates
113
+ * only when the value of `flagKey` changes via the subscribe callback.
114
+ *
115
+ * When flagKey is a Ref or ComputedRef, the subscription updates reactively
116
+ * when the key changes (watchEffect re-subscribes).
117
+ *
118
+ * For a plain `T` shortcut, use `useFlagValue()`.
119
+ */
120
+ declare function useFlag<T>(flagKey: string | Ref<string> | ComputedRef<string>, defaultValue: T): ComputedRef<Flag<T>>;
121
+
122
+ /**
123
+ * §5.16 — Convenience shortcut that returns the flag's raw value `T`
124
+ * instead of the full `Flag<T>` object.
125
+ *
126
+ * Use `useFlag()` when you need `variationKey`, `source`, `reasons`, or
127
+ * other evaluation metadata. Use this composable when you only care about
128
+ * the value itself.
129
+ */
130
+ declare function useFlagValue<T>(flagKey: string | Ref<string> | ComputedRef<string>, defaultValue: T): ComputedRef<T>;
131
+
132
+ /**
133
+ * §5.16 — Typed boolean flag composable.
134
+ *
135
+ * Calls `client.getBoolFlag` under the hood, which performs a runtime
136
+ * type check against the datafile's declared flag type and logs a warning
137
+ * on mismatch before returning the default.
138
+ *
139
+ * Returns `ComputedRef<Flag<boolean>>`.
140
+ */
141
+ declare function useBoolFlag(flagKey: string, defaultValue: boolean): ComputedRef<Flag<boolean>>;
142
+
143
+ /**
144
+ * §5.16 — Typed string flag composable.
145
+ *
146
+ * Calls `client.getStringFlag` under the hood, which performs a runtime
147
+ * type check against the datafile's declared flag type and logs a warning
148
+ * on mismatch before returning the default.
149
+ *
150
+ * Returns `ComputedRef<Flag<string>>`.
151
+ */
152
+ declare function useStringFlag(flagKey: string, defaultValue: string): ComputedRef<Flag<string>>;
153
+
154
+ /**
155
+ * §5.16 — Typed number flag composable.
156
+ *
157
+ * Calls `client.getNumberFlag` under the hood, which performs a runtime
158
+ * type check against the datafile's declared flag type and logs a warning
159
+ * on mismatch before returning the default.
160
+ *
161
+ * Returns `ComputedRef<Flag<number>>`.
162
+ */
163
+ declare function useNumberFlag(flagKey: string, defaultValue: number): ComputedRef<Flag<number>>;
164
+
165
+ /**
166
+ * §5.16 — Typed JSON flag composable.
167
+ *
168
+ * Calls `client.getJsonFlag` under the hood, which performs a runtime
169
+ * type check against the datafile's declared flag type and logs a warning
170
+ * on mismatch before returning the default.
171
+ *
172
+ * Returns `ComputedRef<Flag<T>>` where `T` is your expected JSON shape.
173
+ */
174
+ declare function useJsonFlag<T>(flagKey: string, defaultValue: T): ComputedRef<Flag<T>>;
175
+
176
+ /**
177
+ * §5.16 — Returns `ComputedRef<Record<string, Flag>>` containing all
178
+ * evaluated flags.
179
+ *
180
+ * Subscribes to the global `'flagChange'` event bus rather than per-flag
181
+ * subscriptions. Any flag change causes re-evaluation of all flags.
182
+ *
183
+ * Use this composable for dashboards or debug panels that display the full
184
+ * flag state. For individual flag reads, prefer `useFlag()` which only
185
+ * re-renders on changes to that specific flag.
186
+ */
187
+ declare function useAllFlags(): ComputedRef<Record<string, Flag>>;
188
+
189
+ /**
190
+ * §5.15 — Returns `ComputedRef<boolean>` that is `true` once the
191
+ * Provider's client is ready.
192
+ *
193
+ * Simple boolean alternative to reading status directly for components
194
+ * that only need to gate rendering on readiness.
195
+ */
196
+ declare function useFlagReady(): ComputedRef<boolean>;
197
+
198
+ /**
199
+ * Returns the underlying `AvsbClient` instance (or `null` while loading).
200
+ *
201
+ * The type is `VueAvsbClient` — the interface declaring the surface this
202
+ * package uses. Once @avsbhq/browser ships the full reshape, `AvsbClient`
203
+ * satisfies this interface structurally.
204
+ *
205
+ * Prefer typed flag composables (`useFlag`, `useBoolFlag`, etc.) for feature
206
+ * flag reads. Use this composable when you need low-level SDK access (e.g.
207
+ * manual `flush()`, direct `track()`).
208
+ */
209
+ declare function useAvsbClient(): VueAvsbClient | null;
210
+
211
+ /**
212
+ * §5.16 — Returns a stable `identify` function.
213
+ *
214
+ * Calling `identify(ctx)` replaces the client's current evaluation context.
215
+ * All subsequent flag evaluations and exposure events use the new context.
216
+ * Triggers re-evaluation for any `useFlag` subscribers whose values changed.
217
+ *
218
+ * @returns `(ctx: EvalContext) => void`
219
+ */
220
+ declare function useIdentify(): (ctx: EvalContext) => void;
221
+
222
+ /**
223
+ * §5.16 — Returns a stable `alias` function.
224
+ *
225
+ * Calling `alias(prev, next)` records that two contexts represent the
226
+ * same user identity (e.g. anonymous visitor → identified user after
227
+ * sign-in). Used by the analytics backend to stitch sessions.
228
+ *
229
+ * @returns `(prev: EvalContext, next: EvalContext) => Promise<void>`
230
+ */
231
+ declare function useAlias(): (prev: EvalContext, next: EvalContext) => Promise<void>;
232
+
233
+ /**
234
+ * §5.16 — Returns a stable `track` function that survives the
235
+ * loading → ready transition without changing its reference.
236
+ *
237
+ * The function delegates to `client.track()` via a ref so that callers
238
+ * do not need to call `useTrack` again when the client becomes ready.
239
+ *
240
+ * @returns `(eventKey: string, payload?: TrackPayload) => void`
241
+ */
242
+ declare function useTrack(): (eventKey: string, payload?: TrackPayload) => void;
243
+
244
+ declare const useAvsbStore: pinia.StoreDefinition<"avsb", Pick<{
245
+ client: vue.ComputedRef<VueAvsbClient | null>;
246
+ status: vue.ComputedRef<"ready" | "error" | "loading">;
247
+ error: vue.ComputedRef<Error | undefined>;
248
+ setClient: (c: VueAvsbClient | null) => void;
249
+ identify: (ctx: EvalContext) => void;
250
+ track: (eventKey: string, payload?: TrackPayload) => void;
251
+ alias: (prev: EvalContext, next: EvalContext) => Promise<void>;
252
+ reset: () => void;
253
+ }, never>, Pick<{
254
+ client: vue.ComputedRef<VueAvsbClient | null>;
255
+ status: vue.ComputedRef<"ready" | "error" | "loading">;
256
+ error: vue.ComputedRef<Error | undefined>;
257
+ setClient: (c: VueAvsbClient | null) => void;
258
+ identify: (ctx: EvalContext) => void;
259
+ track: (eventKey: string, payload?: TrackPayload) => void;
260
+ alias: (prev: EvalContext, next: EvalContext) => Promise<void>;
261
+ reset: () => void;
262
+ }, "error" | "client" | "status">, Pick<{
263
+ client: vue.ComputedRef<VueAvsbClient | null>;
264
+ status: vue.ComputedRef<"ready" | "error" | "loading">;
265
+ error: vue.ComputedRef<Error | undefined>;
266
+ setClient: (c: VueAvsbClient | null) => void;
267
+ identify: (ctx: EvalContext) => void;
268
+ track: (eventKey: string, payload?: TrackPayload) => void;
269
+ alias: (prev: EvalContext, next: EvalContext) => Promise<void>;
270
+ reset: () => void;
271
+ }, "track" | "identify" | "alias" | "reset" | "setClient">>;
272
+
273
+ type AvsbProviderProps = (AvsbClientOptions & {
274
+ client?: never;
275
+ }) | {
276
+ client: VueAvsbClient;
277
+ };
278
+
279
+ export { type AvsbContextValue, AvsbInjectionKey, AvsbPlugin, type AvsbPluginOptions, AvsbProvider, type AvsbProviderProps, type VueAvsbClient, useAlias, useAllFlags, useAvsbClient, useAvsbStore, useBoolFlag, useFlag, useFlagReady, useFlagValue, useIdentify, useJsonFlag, useNumberFlag, useStringFlag, useTrack };
@@ -0,0 +1,279 @@
1
+ import * as vue from 'vue';
2
+ import { PropType, Plugin, InjectionKey, Ref, ComputedRef } from 'vue';
3
+ import { InitResult, EvalContext, Flag, TrackPayload, ClientEventName, ClientEventMap } from '@avsbhq/core';
4
+ export { ClientEventMap, ClientEventName, DecideOption, EvalContext, EvaluationSource, Flag, FlagDatafile, FlagDatafileAudience, FlagDatafileEntry, FlagDatafileOverride, FlagDatafileRule, FlagDatafileVariation, InitResult, Logger, MultiContext, SingleContext, TrackPayload } from '@avsbhq/core';
5
+ import { AvsbClientOptions } from '@avsbhq/browser';
6
+ export { AvsbClientOptions } from '@avsbhq/browser';
7
+ import * as pinia from 'pinia';
8
+
9
+ /**
10
+ * The surface of AvsbClient that @avsbhq/vue depends on.
11
+ *
12
+ * This interface describes the new browser SDK surface being added in
13
+ * CoW 3 (sdk-launch-readiness). Until @avsbhq/browser ships the full
14
+ * implementation, the Vue package compiles against this interface rather
15
+ * than the concrete class, avoiding cross-package coupling during the
16
+ * in-progress reshape.
17
+ *
18
+ * When the browser SDK reshape lands, AvsbClient will satisfy this
19
+ * interface structurally — no cast required. Until then, any runtime
20
+ * use of these methods is guarded with `typeof client.method === 'function'`
21
+ * checks in each composable.
22
+ */
23
+
24
+ interface VueAvsbClient {
25
+ onReady(): Promise<InitResult>;
26
+ close(): Promise<void>;
27
+ flush(): Promise<void>;
28
+ identify(ctx: EvalContext): void;
29
+ updateAttributes(partial: Record<string, unknown>, kind?: string): void;
30
+ alias(prev: EvalContext, next: EvalContext): Promise<void>;
31
+ getContext(): EvalContext;
32
+ reset(): void;
33
+ getFlag<T>(key: string, defaultValue: T): Flag<T>;
34
+ getBoolFlag(key: string, defaultValue: boolean): Flag<boolean>;
35
+ getStringFlag(key: string, defaultValue: string): Flag<string>;
36
+ getNumberFlag(key: string, defaultValue: number): Flag<number>;
37
+ getJsonFlag<T>(key: string, defaultValue: T): Flag<T>;
38
+ getAllFlags(options?: {
39
+ fireExposures?: boolean;
40
+ }): Record<string, Flag>;
41
+ /** Subscribe to changes for a specific flagKey; returns unsubscribe. */
42
+ subscribe(flagKey: string, listener: () => void): () => void;
43
+ /** Return a stable Flag<T> snapshot without firing an exposure event. */
44
+ getSnapshot<T>(flagKey: string, defaultValue: T): Flag<T>;
45
+ track(eventKey: string, payload?: TrackPayload): void;
46
+ on<E extends ClientEventName>(event: E, cb: ClientEventMap[E]): () => void;
47
+ setOverrideForUser(flagKey: string, contextKey: string, variationKey: string, contextKind?: string): void;
48
+ setGlobalOverride(flagKey: string, variationKey: string): void;
49
+ clearOverrideForUser(flagKey: string, contextKey: string, contextKind?: string): void;
50
+ clearGlobalOverride(flagKey: string): void;
51
+ clearAllOverrides(): void;
52
+ }
53
+
54
+ declare const AvsbProvider: vue.DefineComponent<vue.ExtractPropTypes<{
55
+ client: {
56
+ type: PropType<VueAvsbClient>;
57
+ default: undefined;
58
+ };
59
+ sdkKey: {
60
+ type: StringConstructor;
61
+ default: undefined;
62
+ };
63
+ }>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
64
+ [key: string]: any;
65
+ }>[] | undefined, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
66
+ client: {
67
+ type: PropType<VueAvsbClient>;
68
+ default: undefined;
69
+ };
70
+ sdkKey: {
71
+ type: StringConstructor;
72
+ default: undefined;
73
+ };
74
+ }>> & Readonly<{}>, {
75
+ client: VueAvsbClient;
76
+ sdkKey: string;
77
+ }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
78
+
79
+ /**
80
+ * AvsbPlugin — Vue plugin alternative to mounting <AvsbProvider>.
81
+ *
82
+ * Usage:
83
+ * // Mode A: SDK creates and owns the client
84
+ * app.use(AvsbPlugin, { sdkKey: 'sdk-xxx', attributes: { userId: 'u_1' } })
85
+ *
86
+ * // Mode B: pass a pre-built client
87
+ * app.use(AvsbPlugin, { client: myClient })
88
+ *
89
+ * The plugin installs AvsbProvider semantics at the app level via
90
+ * app.provide(). It is equivalent to wrapping the root component in
91
+ * <AvsbProvider>, but works better with apps that prefer the plugin
92
+ * pattern over SFC wrapper components.
93
+ */
94
+
95
+ type AvsbPluginOptions = (AvsbClientOptions & {
96
+ client?: never;
97
+ }) | {
98
+ client: VueAvsbClient;
99
+ };
100
+ declare const AvsbPlugin: Plugin<AvsbPluginOptions>;
101
+
102
+ interface AvsbContextValue {
103
+ client: VueAvsbClient | null;
104
+ status: 'loading' | 'ready' | 'error';
105
+ error?: Error;
106
+ }
107
+ declare const AvsbInjectionKey: InjectionKey<AvsbContextValue>;
108
+
109
+ /**
110
+ * §5.13 + §5.14 — Subscribe to a single flag.
111
+ *
112
+ * Returns `ComputedRef<Flag<T>>` (not raw `T`). The computed re-evaluates
113
+ * only when the value of `flagKey` changes via the subscribe callback.
114
+ *
115
+ * When flagKey is a Ref or ComputedRef, the subscription updates reactively
116
+ * when the key changes (watchEffect re-subscribes).
117
+ *
118
+ * For a plain `T` shortcut, use `useFlagValue()`.
119
+ */
120
+ declare function useFlag<T>(flagKey: string | Ref<string> | ComputedRef<string>, defaultValue: T): ComputedRef<Flag<T>>;
121
+
122
+ /**
123
+ * §5.16 — Convenience shortcut that returns the flag's raw value `T`
124
+ * instead of the full `Flag<T>` object.
125
+ *
126
+ * Use `useFlag()` when you need `variationKey`, `source`, `reasons`, or
127
+ * other evaluation metadata. Use this composable when you only care about
128
+ * the value itself.
129
+ */
130
+ declare function useFlagValue<T>(flagKey: string | Ref<string> | ComputedRef<string>, defaultValue: T): ComputedRef<T>;
131
+
132
+ /**
133
+ * §5.16 — Typed boolean flag composable.
134
+ *
135
+ * Calls `client.getBoolFlag` under the hood, which performs a runtime
136
+ * type check against the datafile's declared flag type and logs a warning
137
+ * on mismatch before returning the default.
138
+ *
139
+ * Returns `ComputedRef<Flag<boolean>>`.
140
+ */
141
+ declare function useBoolFlag(flagKey: string, defaultValue: boolean): ComputedRef<Flag<boolean>>;
142
+
143
+ /**
144
+ * §5.16 — Typed string flag composable.
145
+ *
146
+ * Calls `client.getStringFlag` under the hood, which performs a runtime
147
+ * type check against the datafile's declared flag type and logs a warning
148
+ * on mismatch before returning the default.
149
+ *
150
+ * Returns `ComputedRef<Flag<string>>`.
151
+ */
152
+ declare function useStringFlag(flagKey: string, defaultValue: string): ComputedRef<Flag<string>>;
153
+
154
+ /**
155
+ * §5.16 — Typed number flag composable.
156
+ *
157
+ * Calls `client.getNumberFlag` under the hood, which performs a runtime
158
+ * type check against the datafile's declared flag type and logs a warning
159
+ * on mismatch before returning the default.
160
+ *
161
+ * Returns `ComputedRef<Flag<number>>`.
162
+ */
163
+ declare function useNumberFlag(flagKey: string, defaultValue: number): ComputedRef<Flag<number>>;
164
+
165
+ /**
166
+ * §5.16 — Typed JSON flag composable.
167
+ *
168
+ * Calls `client.getJsonFlag` under the hood, which performs a runtime
169
+ * type check against the datafile's declared flag type and logs a warning
170
+ * on mismatch before returning the default.
171
+ *
172
+ * Returns `ComputedRef<Flag<T>>` where `T` is your expected JSON shape.
173
+ */
174
+ declare function useJsonFlag<T>(flagKey: string, defaultValue: T): ComputedRef<Flag<T>>;
175
+
176
+ /**
177
+ * §5.16 — Returns `ComputedRef<Record<string, Flag>>` containing all
178
+ * evaluated flags.
179
+ *
180
+ * Subscribes to the global `'flagChange'` event bus rather than per-flag
181
+ * subscriptions. Any flag change causes re-evaluation of all flags.
182
+ *
183
+ * Use this composable for dashboards or debug panels that display the full
184
+ * flag state. For individual flag reads, prefer `useFlag()` which only
185
+ * re-renders on changes to that specific flag.
186
+ */
187
+ declare function useAllFlags(): ComputedRef<Record<string, Flag>>;
188
+
189
+ /**
190
+ * §5.15 — Returns `ComputedRef<boolean>` that is `true` once the
191
+ * Provider's client is ready.
192
+ *
193
+ * Simple boolean alternative to reading status directly for components
194
+ * that only need to gate rendering on readiness.
195
+ */
196
+ declare function useFlagReady(): ComputedRef<boolean>;
197
+
198
+ /**
199
+ * Returns the underlying `AvsbClient` instance (or `null` while loading).
200
+ *
201
+ * The type is `VueAvsbClient` — the interface declaring the surface this
202
+ * package uses. Once @avsbhq/browser ships the full reshape, `AvsbClient`
203
+ * satisfies this interface structurally.
204
+ *
205
+ * Prefer typed flag composables (`useFlag`, `useBoolFlag`, etc.) for feature
206
+ * flag reads. Use this composable when you need low-level SDK access (e.g.
207
+ * manual `flush()`, direct `track()`).
208
+ */
209
+ declare function useAvsbClient(): VueAvsbClient | null;
210
+
211
+ /**
212
+ * §5.16 — Returns a stable `identify` function.
213
+ *
214
+ * Calling `identify(ctx)` replaces the client's current evaluation context.
215
+ * All subsequent flag evaluations and exposure events use the new context.
216
+ * Triggers re-evaluation for any `useFlag` subscribers whose values changed.
217
+ *
218
+ * @returns `(ctx: EvalContext) => void`
219
+ */
220
+ declare function useIdentify(): (ctx: EvalContext) => void;
221
+
222
+ /**
223
+ * §5.16 — Returns a stable `alias` function.
224
+ *
225
+ * Calling `alias(prev, next)` records that two contexts represent the
226
+ * same user identity (e.g. anonymous visitor → identified user after
227
+ * sign-in). Used by the analytics backend to stitch sessions.
228
+ *
229
+ * @returns `(prev: EvalContext, next: EvalContext) => Promise<void>`
230
+ */
231
+ declare function useAlias(): (prev: EvalContext, next: EvalContext) => Promise<void>;
232
+
233
+ /**
234
+ * §5.16 — Returns a stable `track` function that survives the
235
+ * loading → ready transition without changing its reference.
236
+ *
237
+ * The function delegates to `client.track()` via a ref so that callers
238
+ * do not need to call `useTrack` again when the client becomes ready.
239
+ *
240
+ * @returns `(eventKey: string, payload?: TrackPayload) => void`
241
+ */
242
+ declare function useTrack(): (eventKey: string, payload?: TrackPayload) => void;
243
+
244
+ declare const useAvsbStore: pinia.StoreDefinition<"avsb", Pick<{
245
+ client: vue.ComputedRef<VueAvsbClient | null>;
246
+ status: vue.ComputedRef<"ready" | "error" | "loading">;
247
+ error: vue.ComputedRef<Error | undefined>;
248
+ setClient: (c: VueAvsbClient | null) => void;
249
+ identify: (ctx: EvalContext) => void;
250
+ track: (eventKey: string, payload?: TrackPayload) => void;
251
+ alias: (prev: EvalContext, next: EvalContext) => Promise<void>;
252
+ reset: () => void;
253
+ }, never>, Pick<{
254
+ client: vue.ComputedRef<VueAvsbClient | null>;
255
+ status: vue.ComputedRef<"ready" | "error" | "loading">;
256
+ error: vue.ComputedRef<Error | undefined>;
257
+ setClient: (c: VueAvsbClient | null) => void;
258
+ identify: (ctx: EvalContext) => void;
259
+ track: (eventKey: string, payload?: TrackPayload) => void;
260
+ alias: (prev: EvalContext, next: EvalContext) => Promise<void>;
261
+ reset: () => void;
262
+ }, "error" | "client" | "status">, Pick<{
263
+ client: vue.ComputedRef<VueAvsbClient | null>;
264
+ status: vue.ComputedRef<"ready" | "error" | "loading">;
265
+ error: vue.ComputedRef<Error | undefined>;
266
+ setClient: (c: VueAvsbClient | null) => void;
267
+ identify: (ctx: EvalContext) => void;
268
+ track: (eventKey: string, payload?: TrackPayload) => void;
269
+ alias: (prev: EvalContext, next: EvalContext) => Promise<void>;
270
+ reset: () => void;
271
+ }, "track" | "identify" | "alias" | "reset" | "setClient">>;
272
+
273
+ type AvsbProviderProps = (AvsbClientOptions & {
274
+ client?: never;
275
+ }) | {
276
+ client: VueAvsbClient;
277
+ };
278
+
279
+ export { type AvsbContextValue, AvsbInjectionKey, AvsbPlugin, type AvsbPluginOptions, AvsbProvider, type AvsbProviderProps, type VueAvsbClient, useAlias, useAllFlags, useAvsbClient, useAvsbStore, useBoolFlag, useFlag, useFlagReady, useFlagValue, useIdentify, useJsonFlag, useNumberFlag, useStringFlag, useTrack };