@avsbhq/vue 1.0.0 → 1.0.1

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
@@ -12,7 +12,7 @@ Drop an `<AvsbProvider>` at the top of your component tree (or call `app.use(Avs
12
12
  npm install @avsbhq/vue
13
13
  ```
14
14
 
15
- Vue 3.4 or later is required as a peer dependency. Pinia integration is optional — install `pinia` only if you use `useAvsbStore`.
15
+ Vue 3.4 or later is required as a peer dependency. Pinia integration is optional: install `pinia` only if you use `useAvsbStore`.
16
16
 
17
17
  ---
18
18
 
@@ -53,7 +53,7 @@ const track = useTrack()
53
53
 
54
54
  Get a client SDK key from your A vs B project's Environments page.
55
55
 
56
- Client SDK keys are safe to embed in browser bundles — store them in your framework's public env variable:
56
+ Client SDK keys are safe to embed in browser bundles. Store them in your framework's public env variable:
57
57
 
58
58
  ```
59
59
  VITE_AVSB_SDK_KEY=sdk-...
@@ -68,7 +68,7 @@ Server SDK keys (used by `@avsbhq/node`) must never be exposed to the browser.
68
68
 
69
69
  ---
70
70
 
71
- ## 4. Identity — identify, updateAttributes, alias, reset
71
+ ## 4. Identity (identify, updateAttributes, alias, reset)
72
72
 
73
73
  ### Provider-level context
74
74
 
@@ -92,7 +92,7 @@ function onSignIn(user: User) {
92
92
  }
93
93
  ```
94
94
 
95
- The function is stable — it will not change reference between renders.
95
+ The function is stable; it will not change reference between renders.
96
96
 
97
97
  ### useAlias
98
98
 
@@ -119,7 +119,7 @@ Call `client.reset()` via `useAvsbClient()` to clear the current identity and re
119
119
 
120
120
  ## 5. Multi-context
121
121
 
122
- A vs B supports multi-context evaluation — evaluating a flag for both a user and an organisation simultaneously:
122
+ A vs B supports multi-context evaluation: evaluating a flag for both a user and an organisation simultaneously:
123
123
 
124
124
  ```ts
125
125
  identify({
@@ -133,7 +133,7 @@ identify({
133
133
 
134
134
  ## 6. Reading flags
135
135
 
136
- ### useFlag — full Flag object
136
+ ### useFlag (full Flag object)
137
137
 
138
138
  ```ts
139
139
  import { useFlag } from '@avsbhq/vue'
@@ -150,7 +150,7 @@ const checkoutFlag = useFlag('new-checkout-flow', false)
150
150
 
151
151
  A default value is always required. It is returned until the SDK is ready and whenever the flag is not found.
152
152
 
153
- ### useFlagValue — raw value shortcut
153
+ ### useFlagValue (raw value shortcut)
154
154
 
155
155
  ```ts
156
156
  import { useFlagValue } from '@avsbhq/vue'
@@ -176,14 +176,14 @@ All return `ComputedRef<Flag<T>>`.
176
176
 
177
177
  ### Reactive flag key
178
178
 
179
- `useFlag` (and `useFlagValue`) accept a `Ref<string>` or `ComputedRef<string>` as the key — the subscription updates automatically when the key changes:
179
+ `useFlag` (and `useFlagValue`) accept a `Ref<string>` or `ComputedRef<string>` as the key, and the subscription updates automatically when the key changes:
180
180
 
181
181
  ```ts
182
182
  const selectedFlag = ref('feature-a')
183
183
  const flag = useFlag(selectedFlag, false)
184
184
  ```
185
185
 
186
- ### useAllFlags — all evaluated flags
186
+ ### useAllFlags (all evaluated flags)
187
187
 
188
188
  ```ts
189
189
  import { useAllFlags } from '@avsbhq/vue'
@@ -193,7 +193,7 @@ const flags = useAllFlags()
193
193
  // Re-computes on any flagChange event.
194
194
  ```
195
195
 
196
- Prefer individual `useFlag` composables in most components — `useAllFlags` triggers on any flag change and is best suited for debug panels.
196
+ Prefer individual `useFlag` composables in most components. `useAllFlags` triggers on any flag change and is best suited for debug panels.
197
197
 
198
198
  ---
199
199
 
@@ -209,7 +209,7 @@ function onClick() {
209
209
  }
210
210
  ```
211
211
 
212
- The function is defined once in setup — it is safe to use as an event handler without wrapping in a closure.
212
+ The function is defined once in setup, so it is safe to use as an event handler without wrapping in a closure.
213
213
 
214
214
  ---
215
215
 
@@ -260,7 +260,7 @@ const client = new AvsbClient({ sdkKey: '...', bootstrap: serverDatafile })
260
260
  ```
261
261
 
262
262
  ```vue
263
- <!-- App.vue — client side -->
263
+ <!-- App.vue, client side -->
264
264
  <AvsbProvider :sdk-key="sdkKey" :bootstrap="bootstrapDatafile">
265
265
  <NuxtPage />
266
266
  </AvsbProvider>
@@ -289,7 +289,7 @@ The `AvsbPlugin` (Mode A) proxies `app.unmount` to close the client when the Vue
289
289
 
290
290
  ## 11. Testing
291
291
 
292
- Inject a mock context directly via `provide` — no need to mount the full provider:
292
+ Inject a mock context directly via `provide`; no need to mount the full provider:
293
293
 
294
294
  ```ts
295
295
  import { defineComponent, h, provide } from 'vue'
@@ -360,4 +360,4 @@ Key differences:
360
360
 
361
361
  - `useFlag` returns a `Flag<T>` object, not a raw `T`. Access `.value` for the primitive or `.isEnabled()` for a boolean gate. This gives you the evaluation metadata (source, variationKey, reasons) without a second call.
362
362
  - All `getFlag` variants require an explicit `defaultValue`. There is no untyped `.variation()`.
363
- - Multi-context is a first-class concept — no adapter required.
363
+ - Multi-context is a first-class concept, with no adapter required.
package/dist/index.d.cts CHANGED
@@ -77,7 +77,7 @@ declare const AvsbProvider: vue.DefineComponent<vue.ExtractPropTypes<{
77
77
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
78
78
 
79
79
  /**
80
- * AvsbPlugin — Vue plugin alternative to mounting <AvsbProvider>.
80
+ * AvsbPlugin: Vue plugin alternative to mounting <AvsbProvider>.
81
81
  *
82
82
  * Usage:
83
83
  * // Mode A: SDK creates and owns the client
@@ -107,7 +107,7 @@ interface AvsbContextValue {
107
107
  declare const AvsbInjectionKey: InjectionKey<AvsbContextValue>;
108
108
 
109
109
  /**
110
- * §5.13 + §5.14 — Subscribe to a single flag.
110
+ * §5.13 + §5.14: Subscribe to a single flag.
111
111
  *
112
112
  * Returns `ComputedRef<Flag<T>>` (not raw `T`). The computed re-evaluates
113
113
  * only when the value of `flagKey` changes via the subscribe callback.
@@ -120,7 +120,7 @@ declare const AvsbInjectionKey: InjectionKey<AvsbContextValue>;
120
120
  declare function useFlag<T>(flagKey: string | Ref<string> | ComputedRef<string>, defaultValue: T): ComputedRef<Flag<T>>;
121
121
 
122
122
  /**
123
- * §5.16 — Convenience shortcut that returns the flag's raw value `T`
123
+ * §5.16: Convenience shortcut that returns the flag's raw value `T`
124
124
  * instead of the full `Flag<T>` object.
125
125
  *
126
126
  * Use `useFlag()` when you need `variationKey`, `source`, `reasons`, or
@@ -130,7 +130,7 @@ declare function useFlag<T>(flagKey: string | Ref<string> | ComputedRef<string>,
130
130
  declare function useFlagValue<T>(flagKey: string | Ref<string> | ComputedRef<string>, defaultValue: T): ComputedRef<T>;
131
131
 
132
132
  /**
133
- * §5.16 — Typed boolean flag composable.
133
+ * §5.16: Typed boolean flag composable.
134
134
  *
135
135
  * Calls `client.getBoolFlag` under the hood, which performs a runtime
136
136
  * type check against the datafile's declared flag type and logs a warning
@@ -141,7 +141,7 @@ declare function useFlagValue<T>(flagKey: string | Ref<string> | ComputedRef<str
141
141
  declare function useBoolFlag(flagKey: string, defaultValue: boolean): ComputedRef<Flag<boolean>>;
142
142
 
143
143
  /**
144
- * §5.16 — Typed string flag composable.
144
+ * §5.16: Typed string flag composable.
145
145
  *
146
146
  * Calls `client.getStringFlag` under the hood, which performs a runtime
147
147
  * type check against the datafile's declared flag type and logs a warning
@@ -152,7 +152,7 @@ declare function useBoolFlag(flagKey: string, defaultValue: boolean): ComputedRe
152
152
  declare function useStringFlag(flagKey: string, defaultValue: string): ComputedRef<Flag<string>>;
153
153
 
154
154
  /**
155
- * §5.16 — Typed number flag composable.
155
+ * §5.16: Typed number flag composable.
156
156
  *
157
157
  * Calls `client.getNumberFlag` under the hood, which performs a runtime
158
158
  * type check against the datafile's declared flag type and logs a warning
@@ -163,7 +163,7 @@ declare function useStringFlag(flagKey: string, defaultValue: string): ComputedR
163
163
  declare function useNumberFlag(flagKey: string, defaultValue: number): ComputedRef<Flag<number>>;
164
164
 
165
165
  /**
166
- * §5.16 — Typed JSON flag composable.
166
+ * §5.16: Typed JSON flag composable.
167
167
  *
168
168
  * Calls `client.getJsonFlag` under the hood, which performs a runtime
169
169
  * type check against the datafile's declared flag type and logs a warning
@@ -174,7 +174,7 @@ declare function useNumberFlag(flagKey: string, defaultValue: number): ComputedR
174
174
  declare function useJsonFlag<T>(flagKey: string, defaultValue: T): ComputedRef<Flag<T>>;
175
175
 
176
176
  /**
177
- * §5.16 — Returns `ComputedRef<Record<string, Flag>>` containing all
177
+ * §5.16: Returns `ComputedRef<Record<string, Flag>>` containing all
178
178
  * evaluated flags.
179
179
  *
180
180
  * Subscribes to the global `'flagChange'` event bus rather than per-flag
@@ -187,7 +187,7 @@ declare function useJsonFlag<T>(flagKey: string, defaultValue: T): ComputedRef<F
187
187
  declare function useAllFlags(): ComputedRef<Record<string, Flag>>;
188
188
 
189
189
  /**
190
- * §5.15 — Returns `ComputedRef<boolean>` that is `true` once the
190
+ * §5.15: Returns `ComputedRef<boolean>` that is `true` once the
191
191
  * Provider's client is ready.
192
192
  *
193
193
  * Simple boolean alternative to reading status directly for components
@@ -198,7 +198,7 @@ declare function useFlagReady(): ComputedRef<boolean>;
198
198
  /**
199
199
  * Returns the underlying `AvsbClient` instance (or `null` while loading).
200
200
  *
201
- * The type is `VueAvsbClient` — the interface declaring the surface this
201
+ * The type is `VueAvsbClient`, the interface declaring the surface this
202
202
  * package uses. Once @avsbhq/browser ships the full reshape, `AvsbClient`
203
203
  * satisfies this interface structurally.
204
204
  *
@@ -209,7 +209,7 @@ declare function useFlagReady(): ComputedRef<boolean>;
209
209
  declare function useAvsbClient(): VueAvsbClient | null;
210
210
 
211
211
  /**
212
- * §5.16 — Returns a stable `identify` function.
212
+ * §5.16: Returns a stable `identify` function.
213
213
  *
214
214
  * Calling `identify(ctx)` replaces the client's current evaluation context.
215
215
  * All subsequent flag evaluations and exposure events use the new context.
@@ -220,7 +220,7 @@ declare function useAvsbClient(): VueAvsbClient | null;
220
220
  declare function useIdentify(): (ctx: EvalContext) => void;
221
221
 
222
222
  /**
223
- * §5.16 — Returns a stable `alias` function.
223
+ * §5.16: Returns a stable `alias` function.
224
224
  *
225
225
  * Calling `alias(prev, next)` records that two contexts represent the
226
226
  * same user identity (e.g. anonymous visitor → identified user after
@@ -231,7 +231,7 @@ declare function useIdentify(): (ctx: EvalContext) => void;
231
231
  declare function useAlias(): (prev: EvalContext, next: EvalContext) => Promise<void>;
232
232
 
233
233
  /**
234
- * §5.16 — Returns a stable `track` function that survives the
234
+ * §5.16: Returns a stable `track` function that survives the
235
235
  * loading → ready transition without changing its reference.
236
236
  *
237
237
  * The function delegates to `client.track()` via a ref so that callers
package/dist/index.d.ts CHANGED
@@ -77,7 +77,7 @@ declare const AvsbProvider: vue.DefineComponent<vue.ExtractPropTypes<{
77
77
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
78
78
 
79
79
  /**
80
- * AvsbPlugin — Vue plugin alternative to mounting <AvsbProvider>.
80
+ * AvsbPlugin: Vue plugin alternative to mounting <AvsbProvider>.
81
81
  *
82
82
  * Usage:
83
83
  * // Mode A: SDK creates and owns the client
@@ -107,7 +107,7 @@ interface AvsbContextValue {
107
107
  declare const AvsbInjectionKey: InjectionKey<AvsbContextValue>;
108
108
 
109
109
  /**
110
- * §5.13 + §5.14 — Subscribe to a single flag.
110
+ * §5.13 + §5.14: Subscribe to a single flag.
111
111
  *
112
112
  * Returns `ComputedRef<Flag<T>>` (not raw `T`). The computed re-evaluates
113
113
  * only when the value of `flagKey` changes via the subscribe callback.
@@ -120,7 +120,7 @@ declare const AvsbInjectionKey: InjectionKey<AvsbContextValue>;
120
120
  declare function useFlag<T>(flagKey: string | Ref<string> | ComputedRef<string>, defaultValue: T): ComputedRef<Flag<T>>;
121
121
 
122
122
  /**
123
- * §5.16 — Convenience shortcut that returns the flag's raw value `T`
123
+ * §5.16: Convenience shortcut that returns the flag's raw value `T`
124
124
  * instead of the full `Flag<T>` object.
125
125
  *
126
126
  * Use `useFlag()` when you need `variationKey`, `source`, `reasons`, or
@@ -130,7 +130,7 @@ declare function useFlag<T>(flagKey: string | Ref<string> | ComputedRef<string>,
130
130
  declare function useFlagValue<T>(flagKey: string | Ref<string> | ComputedRef<string>, defaultValue: T): ComputedRef<T>;
131
131
 
132
132
  /**
133
- * §5.16 — Typed boolean flag composable.
133
+ * §5.16: Typed boolean flag composable.
134
134
  *
135
135
  * Calls `client.getBoolFlag` under the hood, which performs a runtime
136
136
  * type check against the datafile's declared flag type and logs a warning
@@ -141,7 +141,7 @@ declare function useFlagValue<T>(flagKey: string | Ref<string> | ComputedRef<str
141
141
  declare function useBoolFlag(flagKey: string, defaultValue: boolean): ComputedRef<Flag<boolean>>;
142
142
 
143
143
  /**
144
- * §5.16 — Typed string flag composable.
144
+ * §5.16: Typed string flag composable.
145
145
  *
146
146
  * Calls `client.getStringFlag` under the hood, which performs a runtime
147
147
  * type check against the datafile's declared flag type and logs a warning
@@ -152,7 +152,7 @@ declare function useBoolFlag(flagKey: string, defaultValue: boolean): ComputedRe
152
152
  declare function useStringFlag(flagKey: string, defaultValue: string): ComputedRef<Flag<string>>;
153
153
 
154
154
  /**
155
- * §5.16 — Typed number flag composable.
155
+ * §5.16: Typed number flag composable.
156
156
  *
157
157
  * Calls `client.getNumberFlag` under the hood, which performs a runtime
158
158
  * type check against the datafile's declared flag type and logs a warning
@@ -163,7 +163,7 @@ declare function useStringFlag(flagKey: string, defaultValue: string): ComputedR
163
163
  declare function useNumberFlag(flagKey: string, defaultValue: number): ComputedRef<Flag<number>>;
164
164
 
165
165
  /**
166
- * §5.16 — Typed JSON flag composable.
166
+ * §5.16: Typed JSON flag composable.
167
167
  *
168
168
  * Calls `client.getJsonFlag` under the hood, which performs a runtime
169
169
  * type check against the datafile's declared flag type and logs a warning
@@ -174,7 +174,7 @@ declare function useNumberFlag(flagKey: string, defaultValue: number): ComputedR
174
174
  declare function useJsonFlag<T>(flagKey: string, defaultValue: T): ComputedRef<Flag<T>>;
175
175
 
176
176
  /**
177
- * §5.16 — Returns `ComputedRef<Record<string, Flag>>` containing all
177
+ * §5.16: Returns `ComputedRef<Record<string, Flag>>` containing all
178
178
  * evaluated flags.
179
179
  *
180
180
  * Subscribes to the global `'flagChange'` event bus rather than per-flag
@@ -187,7 +187,7 @@ declare function useJsonFlag<T>(flagKey: string, defaultValue: T): ComputedRef<F
187
187
  declare function useAllFlags(): ComputedRef<Record<string, Flag>>;
188
188
 
189
189
  /**
190
- * §5.15 — Returns `ComputedRef<boolean>` that is `true` once the
190
+ * §5.15: Returns `ComputedRef<boolean>` that is `true` once the
191
191
  * Provider's client is ready.
192
192
  *
193
193
  * Simple boolean alternative to reading status directly for components
@@ -198,7 +198,7 @@ declare function useFlagReady(): ComputedRef<boolean>;
198
198
  /**
199
199
  * Returns the underlying `AvsbClient` instance (or `null` while loading).
200
200
  *
201
- * The type is `VueAvsbClient` — the interface declaring the surface this
201
+ * The type is `VueAvsbClient`, the interface declaring the surface this
202
202
  * package uses. Once @avsbhq/browser ships the full reshape, `AvsbClient`
203
203
  * satisfies this interface structurally.
204
204
  *
@@ -209,7 +209,7 @@ declare function useFlagReady(): ComputedRef<boolean>;
209
209
  declare function useAvsbClient(): VueAvsbClient | null;
210
210
 
211
211
  /**
212
- * §5.16 — Returns a stable `identify` function.
212
+ * §5.16: Returns a stable `identify` function.
213
213
  *
214
214
  * Calling `identify(ctx)` replaces the client's current evaluation context.
215
215
  * All subsequent flag evaluations and exposure events use the new context.
@@ -220,7 +220,7 @@ declare function useAvsbClient(): VueAvsbClient | null;
220
220
  declare function useIdentify(): (ctx: EvalContext) => void;
221
221
 
222
222
  /**
223
- * §5.16 — Returns a stable `alias` function.
223
+ * §5.16: Returns a stable `alias` function.
224
224
  *
225
225
  * Calling `alias(prev, next)` records that two contexts represent the
226
226
  * same user identity (e.g. anonymous visitor → identified user after
@@ -231,7 +231,7 @@ declare function useIdentify(): (ctx: EvalContext) => void;
231
231
  declare function useAlias(): (prev: EvalContext, next: EvalContext) => Promise<void>;
232
232
 
233
233
  /**
234
- * §5.16 — Returns a stable `track` function that survives the
234
+ * §5.16: Returns a stable `track` function that survives the
235
235
  * loading → ready transition without changing its reference.
236
236
  *
237
237
  * The function delegates to `client.track()` via a ref so that callers
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@avsbhq/vue",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
@@ -27,8 +27,8 @@
27
27
  "pinia": { "optional": true }
28
28
  },
29
29
  "dependencies": {
30
- "@avsbhq/core": "1.0.0",
31
- "@avsbhq/browser": "1.0.0"
30
+ "@avsbhq/core": "1.4.0",
31
+ "@avsbhq/browser": "1.3.0"
32
32
  },
33
33
  "scripts": {
34
34
  "build": "tsup",