@openfeature/react-sdk 0.4.2 → 0.4.3

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
@@ -16,8 +16,8 @@
16
16
  <img alt="Specification" src="https://img.shields.io/static/v1?label=specification&message=v0.8.0&color=yellow&style=for-the-badge" />
17
17
  </a>
18
18
  <!-- x-release-please-start-version -->
19
- <a href="https://github.com/open-feature/js-sdk/releases/tag/react-sdk-v0.4.2">
20
- <img alt="Release" src="https://img.shields.io/static/v1?label=release&message=v0.4.2&color=blue&style=for-the-badge" />
19
+ <a href="https://github.com/open-feature/js-sdk/releases/tag/react-sdk-v0.4.3">
20
+ <img alt="Release" src="https://img.shields.io/static/v1?label=release&message=v0.4.3&color=blue&style=for-the-badge" />
21
21
  </a>
22
22
  <!-- x-release-please-end -->
23
23
  <br/>
package/dist/cjs/index.js CHANGED
@@ -9,7 +9,6 @@ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
9
  var __getProtoOf = Object.getPrototypeOf;
10
10
  var __hasOwnProp = Object.prototype.hasOwnProperty;
11
11
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
- var __reflectGet = Reflect.get;
13
12
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
14
13
  var __spreadValues = (a, b) => {
15
14
  for (var prop in b || (b = {}))
@@ -57,7 +56,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
57
56
  mod
58
57
  ));
59
58
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
60
- var __superGet = (cls, obj, key) => __reflectGet(__getProtoOf(cls), key, obj);
61
59
  var __async = (__this, __arguments, generator) => {
62
60
  return new Promise((resolve, reject) => {
63
61
  var fulfilled = (value) => {
@@ -349,7 +347,7 @@ var import_web_sdk7 = require("@openfeature/web-sdk");
349
347
  var import_react5 = __toESM(require("react"));
350
348
  var TEST_VARIANT = "test-variant";
351
349
  var TEST_PROVIDER = "test-provider";
352
- var TestProvider = class _TestProvider extends import_web_sdk7.InMemoryProvider {
350
+ var TestProvider = class extends import_web_sdk7.InMemoryProvider {
353
351
  constructor(flagValueMap, delay = 0) {
354
352
  const flagConfig = Object.entries(flagValueMap).reduce((acc, flag) => {
355
353
  return __spreadProps(__spreadValues({}, acc), {
@@ -364,11 +362,17 @@ var TestProvider = class _TestProvider extends import_web_sdk7.InMemoryProvider
364
362
  }, {});
365
363
  super(flagConfig);
366
364
  this.delay = delay;
367
- }
368
- initialize(context) {
369
- return __async(this, null, function* () {
370
- yield Promise.all([__superGet(_TestProvider.prototype, this, "initialize").call(this, context), new Promise((resolve) => setTimeout(resolve, this.delay))]);
365
+ // initially make this undefined, we still set it if a delay is specified
366
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
367
+ // @ts-ignore - For maximum compatibility with previous versions, we ignore a possible TS error here,
368
+ // since "initialize" was previously defined in superclass.
369
+ // We can safely remove this ts-ignore in a few versions
370
+ this.initialize = void 0;
371
+ // "place-holder" init function which we only assign if want a delay
372
+ this.delayedInitialize = () => __async(this, null, function* () {
373
+ yield new Promise((resolve) => setTimeout(resolve, this.delay));
371
374
  });
375
+ this.initialize = this.delay ? this.delayedInitialize.bind(this) : void 0;
372
376
  }
373
377
  onContextChange() {
374
378
  return __async(this, null, function* () {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts", "../../src/evaluation/use-feature-flag.ts", "../../src/common/options.ts", "../../src/common/suspense.ts", "../../src/provider/context.ts", "../../src/provider/use-open-feature-client.ts", "../../src/provider/use-open-feature-client-status.ts", "../../src/evaluation/hook-flag-query.ts", "../../src/provider/provider.tsx", "../../src/provider/use-when-provider-ready.ts", "../../src/provider/test-provider.tsx"],
4
- "sourcesContent": ["export * from './evaluation';\nexport * from './query';\nexport * from './provider';\n// re-export the web-sdk so consumers can access that API from the react-sdk\nexport * from '@openfeature/web-sdk';\n", "import {\n Client,\n EvaluationDetails,\n FlagEvaluationOptions,\n FlagValue,\n JsonValue,\n ProviderEvents,\n ProviderStatus,\n} from '@openfeature/web-sdk';\nimport { useEffect, useState } from 'react';\nimport { DEFAULT_OPTIONS, ReactFlagEvaluationOptions, normalizeOptions } from '../common/options';\nimport { suspendUntilReady } from '../common/suspense';\nimport { useProviderOptions } from '../provider/context';\nimport { useOpenFeatureClient } from '../provider/use-open-feature-client';\nimport { useOpenFeatureClientStatus } from '../provider/use-open-feature-client-status';\nimport { FlagQuery } from '../query';\nimport { HookFlagQuery } from './hook-flag-query';\n\n// This type is a bit wild-looking, but I think we need it.\n// We have to use the conditional, because otherwise useFlag('key', false) would return false, not boolean (too constrained).\n// We have a duplicate for the hook return below, this one is just used for casting because the name isn't as clear\ntype ConstrainedFlagQuery<T> = FlagQuery<\n T extends boolean\n ? boolean\n : T extends number\n ? number\n : T extends string\n ? string\n : T extends JsonValue\n ? T\n : JsonValue\n>;\n\n// suspense options removed for the useSuspenseFlag hooks\ntype NoSuspenseOptions = Omit<ReactFlagEvaluationOptions, 'suspend' | 'suspendUntilReady' | 'suspendWhileReconciling'>\n\n/**\n * Evaluates a feature flag generically, returning an react-flavored queryable object.\n * The resolver method to use is based on the type of the defaultValue.\n * For type-specific hooks, use {@link useBooleanFlagValue}, {@link useBooleanFlagDetails} and equivalents.\n * By default, components will re-render when the flag value changes.\n * @param {string} flagKey the flag identifier\n * @template {FlagValue} T A optional generic argument constraining the default.\n * @param {T} defaultValue the default value; used to determine what resolved type should be used.\n * @param {ReactFlagEvaluationOptions} options for this evaluation\n * @returns { FlagQuery } a queryable object containing useful information about the flag.\n */\nexport function useFlag<T extends FlagValue = FlagValue>(\n flagKey: string,\n defaultValue: T,\n options?: ReactFlagEvaluationOptions,\n): FlagQuery<\nT extends boolean\n ? boolean\n : T extends number\n ? number\n : T extends string\n ? string\n : T extends JsonValue\n ? T\n : JsonValue\n> {\n // use the default value to determine the resolver to call\n const query =\n typeof defaultValue === 'boolean'\n ? new HookFlagQuery<boolean>(useBooleanFlagDetails(flagKey, defaultValue, options))\n : typeof defaultValue === 'number'\n ? new HookFlagQuery<number>(useNumberFlagDetails(flagKey, defaultValue, options))\n : typeof defaultValue === 'string'\n ? new HookFlagQuery<string>(useStringFlagDetails(flagKey, defaultValue, options))\n : new HookFlagQuery<JsonValue>(useObjectFlagDetails(flagKey, defaultValue, options));\n // TS sees this as HookFlagQuery<JsonValue>, because the compiler isn't aware of the `typeof` checks above.\n return query as unknown as ConstrainedFlagQuery<T>;\n}\n\n// alias to the return value of useFlag, used to keep useSuspenseFlag consistent\ntype UseFlagReturn<T extends FlagValue> = ReturnType<typeof useFlag<T>>\n\n/**\n * Equivalent to {@link useFlag} with `options: { suspend: true }`\n * @experimental Suspense is an experimental feature subject to change in future versions.\n * @param {string} flagKey the flag identifier\n * @template {FlagValue} T A optional generic argument constraining the default.\n * @param {T} defaultValue the default value; used to determine what resolved type should be used.\n * @param {NoSuspenseOptions} options for this evaluation\n * @returns { UseFlagReturn<T> } a queryable object containing useful information about the flag.\n */\nexport function useSuspenseFlag<T extends FlagValue = FlagValue>(\n flagKey: string,\n defaultValue: T,\n options?: NoSuspenseOptions,\n): UseFlagReturn<T> {\n return useFlag(flagKey, defaultValue, { ...options, suspendUntilReady: true, suspendWhileReconciling: true });\n}\n\n/**\n * Evaluates a feature flag, returning a boolean.\n * By default, components will re-render when the flag value changes.\n * For a generic hook returning a queryable interface, see {@link useFlag}.\n * @param {string} flagKey the flag identifier\n * @param {boolean} defaultValue the default value\n * @param {ReactFlagEvaluationOptions} options options for this evaluation\n * @returns { boolean} a EvaluationDetails object for this evaluation\n */\nexport function useBooleanFlagValue(\n flagKey: string,\n defaultValue: boolean,\n options?: ReactFlagEvaluationOptions,\n): boolean {\n return useBooleanFlagDetails(flagKey, defaultValue, options).value;\n}\n\n/**\n * Evaluates a feature flag, returning evaluation details.\n * By default, components will re-render when the flag value changes.\n * For a generic hook returning a queryable interface, see {@link useFlag}.\n * @param {string} flagKey the flag identifier\n * @param {boolean} defaultValue the default value\n * @param {ReactFlagEvaluationOptions} options options for this evaluation\n * @returns { EvaluationDetails<boolean>} a EvaluationDetails object for this evaluation\n */\nexport function useBooleanFlagDetails(\n flagKey: string,\n defaultValue: boolean,\n options?: ReactFlagEvaluationOptions,\n): EvaluationDetails<boolean> {\n return attachHandlersAndResolve(\n flagKey,\n defaultValue,\n (client) => {\n return client.getBooleanDetails;\n },\n options,\n );\n}\n\n/**\n * Evaluates a feature flag, returning a string.\n * By default, components will re-render when the flag value changes.\n * For a generic hook returning a queryable interface, see {@link useFlag}.\n * @param {string} flagKey the flag identifier\n * @template {string} [T=string] A optional generic argument constraining the string\n * @param {T} defaultValue the default value\n * @param {ReactFlagEvaluationOptions} options options for this evaluation\n * @returns { boolean} a EvaluationDetails object for this evaluation\n */\nexport function useStringFlagValue<T extends string = string>(\n flagKey: string,\n defaultValue: T,\n options?: ReactFlagEvaluationOptions,\n): string {\n return useStringFlagDetails(flagKey, defaultValue, options).value;\n}\n\n/**\n * Evaluates a feature flag, returning evaluation details.\n * By default, components will re-render when the flag value changes.\n * For a generic hook returning a queryable interface, see {@link useFlag}.\n * @param {string} flagKey the flag identifier\n * @template {string} [T=string] A optional generic argument constraining the string\n * @param {T} defaultValue the default value\n * @param {ReactFlagEvaluationOptions} options options for this evaluation\n * @returns { EvaluationDetails<string>} a EvaluationDetails object for this evaluation\n */\nexport function useStringFlagDetails<T extends string = string>(\n flagKey: string,\n defaultValue: T,\n options?: ReactFlagEvaluationOptions,\n): EvaluationDetails<string> {\n return attachHandlersAndResolve(\n flagKey,\n defaultValue,\n (client) => {\n return client.getStringDetails<T>;\n },\n options,\n );\n}\n\n/**\n * Evaluates a feature flag, returning a number.\n * By default, components will re-render when the flag value changes.\n * For a generic hook returning a queryable interface, see {@link useFlag}.\n * @param {string} flagKey the flag identifier\n * @template {number} [T=number] A optional generic argument constraining the number\n * @param {T} defaultValue the default value\n * @param {ReactFlagEvaluationOptions} options options for this evaluation\n * @returns { boolean} a EvaluationDetails object for this evaluation\n */\nexport function useNumberFlagValue<T extends number = number>(\n flagKey: string,\n defaultValue: T,\n options?: ReactFlagEvaluationOptions,\n): number {\n return useNumberFlagDetails(flagKey, defaultValue, options).value;\n}\n\n/**\n * Evaluates a feature flag, returning evaluation details.\n * By default, components will re-render when the flag value changes.\n * For a generic hook returning a queryable interface, see {@link useFlag}.\n * @param {string} flagKey the flag identifier\n * @template {number} [T=number] A optional generic argument constraining the number\n * @param {T} defaultValue the default value\n * @param {ReactFlagEvaluationOptions} options options for this evaluation\n * @returns { EvaluationDetails<number>} a EvaluationDetails object for this evaluation\n */\nexport function useNumberFlagDetails<T extends number = number>(\n flagKey: string,\n defaultValue: T,\n options?: ReactFlagEvaluationOptions,\n): EvaluationDetails<number> {\n return attachHandlersAndResolve(\n flagKey,\n defaultValue,\n (client) => {\n return client.getNumberDetails<T>;\n },\n options,\n );\n}\n\n/**\n * Evaluates a feature flag, returning an object.\n * By default, components will re-render when the flag value changes.\n * For a generic hook returning a queryable interface, see {@link useFlag}.\n * @param {string} flagKey the flag identifier\n * @template {JsonValue} [T=JsonValue] A optional generic argument describing the structure\n * @param {T} defaultValue the default value\n * @param {ReactFlagEvaluationOptions} options options for this evaluation\n * @returns { boolean} a EvaluationDetails object for this evaluation\n */\nexport function useObjectFlagValue<T extends JsonValue = JsonValue>(\n flagKey: string,\n defaultValue: T,\n options?: ReactFlagEvaluationOptions,\n): T {\n return useObjectFlagDetails<T>(flagKey, defaultValue, options).value;\n}\n\n/**\n * Evaluates a feature flag, returning evaluation details.\n * By default, components will re-render when the flag value changes.\n * For a generic hook returning a queryable interface, see {@link useFlag}.\n * @param {string} flagKey the flag identifier\n * @param {T} defaultValue the default value\n * @template {JsonValue} [T=JsonValue] A optional generic argument describing the structure\n * @param {ReactFlagEvaluationOptions} options options for this evaluation\n * @returns { EvaluationDetails<T>} a EvaluationDetails object for this evaluation\n */\nexport function useObjectFlagDetails<T extends JsonValue = JsonValue>(\n flagKey: string,\n defaultValue: T,\n options?: ReactFlagEvaluationOptions,\n): EvaluationDetails<T> {\n return attachHandlersAndResolve(\n flagKey,\n defaultValue,\n (client) => {\n return client.getObjectDetails<T>;\n },\n options,\n );\n}\n\nfunction attachHandlersAndResolve<T extends FlagValue>(\n flagKey: string,\n defaultValue: T,\n resolver: (client: Client) => (flagKey: string, defaultValue: T, options?: FlagEvaluationOptions) => EvaluationDetails<T>,\n options?: ReactFlagEvaluationOptions,\n): EvaluationDetails<T> {\n // highest priority > evaluation hook options > provider options > default options > lowest priority\n const defaultedOptions = { ...DEFAULT_OPTIONS, ...useProviderOptions(), ...normalizeOptions(options) };\n const client = useOpenFeatureClient();\n const status = useOpenFeatureClientStatus();\n\n // suspense\n if (defaultedOptions.suspendUntilReady && status === ProviderStatus.NOT_READY) {\n suspendUntilReady(client);\n }\n\n if (defaultedOptions.suspendWhileReconciling && status === ProviderStatus.RECONCILING) {\n suspendUntilReady(client);\n }\n\n const [evalutationDetails, setEvaluationDetails] = useState<EvaluationDetails<T>>(\n resolver(client).call(client, flagKey, defaultValue, options),\n );\n\n const updateEvaluationDetailsRef = () => {\n setEvaluationDetails(resolver(client).call(client, flagKey, defaultValue, options));\n };\n\n useEffect(() => {\n if (status === ProviderStatus.NOT_READY) {\n // update when the provider is ready\n client.addHandler(ProviderEvents.Ready, updateEvaluationDetailsRef);\n }\n\n if (defaultedOptions.updateOnContextChanged) {\n // update when the context changes\n client.addHandler(ProviderEvents.ContextChanged, updateEvaluationDetailsRef);\n }\n return () => {\n // cleanup the handlers\n client.removeHandler(ProviderEvents.Ready, updateEvaluationDetailsRef);\n client.removeHandler(ProviderEvents.ContextChanged, updateEvaluationDetailsRef);\n };\n }, []);\n\n useEffect(() => {\n if (defaultedOptions.updateOnConfigurationChanged) {\n // update when the provider configuration changes\n client.addHandler(ProviderEvents.ConfigurationChanged, updateEvaluationDetailsRef);\n }\n return () => {\n // cleanup the handlers\n client.removeHandler(ProviderEvents.ConfigurationChanged, updateEvaluationDetailsRef);\n };\n }, []);\n\n return evalutationDetails;\n}\n", "import { FlagEvaluationOptions } from '@openfeature/web-sdk';\n\nexport type ReactFlagEvaluationOptions = ({\n /**\n * Enable or disable all suspense functionality.\n * Cannot be used in conjunction with `suspendUntilReady` and `suspendWhileReconciling` options.\n * @experimental Suspense is an experimental feature subject to change in future versions.\n */\n suspend?: boolean;\n suspendUntilReady?: never;\n suspendWhileReconciling?: never;\n} | {\n /**\n * Suspend flag evaluations while the provider is not ready.\n * Set to false if you don't want to show suspense fallbacks until the provider is initialized.\n * Defaults to false.\n * Cannot be used in conjunction with `suspend` option.\n * @experimental Suspense is an experimental feature subject to change in future versions.\n */\n suspendUntilReady?: boolean;\n /**\n * Suspend flag evaluations while the provider's context is being reconciled.\n * Set to true if you want to show suspense fallbacks while flags are re-evaluated after context changes.\n * Defaults to false.\n * Cannot be used in conjunction with `suspend` option.\n * @experimental Suspense is an experimental feature subject to change in future versions.\n */\n suspendWhileReconciling?: boolean;\n suspend?: never;\n}) & {\n /**\n * Update the component if the provider emits a ConfigurationChanged event.\n * Set to false to prevent components from re-rendering when flag value changes\n * are received by the associated provider.\n * Defaults to true.\n */\n updateOnConfigurationChanged?: boolean;\n /**\n * Update the component when the OpenFeature context changes.\n * Set to false to prevent components from re-rendering when attributes which\n * may be factors in flag evaluation change.\n * Defaults to true.\n */\n updateOnContextChanged?: boolean;\n} & FlagEvaluationOptions;\n\nexport type NormalizedOptions = Omit<ReactFlagEvaluationOptions, 'suspend'>;\n\n/**\n * Default options.\n * DO NOT EXPORT PUBLICLY\n * @internal\n */\nexport const DEFAULT_OPTIONS: ReactFlagEvaluationOptions = {\n updateOnContextChanged: true,\n updateOnConfigurationChanged: true,\n suspendUntilReady: false,\n suspendWhileReconciling: false,\n};\n\n/**\n * Returns normalization options (all `undefined` fields removed, and `suspend` decomposed to `suspendUntilReady` and `suspendWhileReconciling`).\n * DO NOT EXPORT PUBLICLY\n * @internal\n * @param {ReactFlagEvaluationOptions} options options to normalize\n * @returns {NormalizedOptions} normalized options\n */\nexport const normalizeOptions: (options?: ReactFlagEvaluationOptions) => NormalizedOptions = (options: ReactFlagEvaluationOptions = {}) => {\n const updateOnContextChanged = options.updateOnContextChanged;\n const updateOnConfigurationChanged = options.updateOnConfigurationChanged;\n\n // fall-back the suspense options to the catch-all `suspend` property \n const suspendUntilReady = 'suspendUntilReady' in options ? options.suspendUntilReady : options.suspend;\n const suspendWhileReconciling = 'suspendWhileReconciling' in options ? options.suspendWhileReconciling : options.suspend;\n\n return {\n // only return these if properly set (no undefined to allow overriding with spread)\n ...(typeof suspendUntilReady === 'boolean' && {suspendUntilReady}),\n ...(typeof suspendWhileReconciling === 'boolean' && {suspendWhileReconciling}),\n ...(typeof updateOnContextChanged === 'boolean' && {updateOnContextChanged}),\n ...(typeof updateOnConfigurationChanged === 'boolean' && {updateOnConfigurationChanged}),\n };\n};\n", "import { Client, ProviderEvents } from '@openfeature/web-sdk';\n\n/**\n * Suspends until the client is ready to evaluate feature flags.\n * DO NOT EXPORT PUBLICLY\n * @param {Client} client OpenFeature client\n */\nexport function suspendUntilReady(client: Client): Promise<void> {\n let resolve: (value: unknown) => void;\n let reject: () => void;\n throw new Promise((_resolve, _reject) => {\n resolve = _resolve;\n reject = _reject;\n client.addHandler(ProviderEvents.Ready, resolve);\n client.addHandler(ProviderEvents.Error, reject);\n }).finally(() => {\n client.removeHandler(ProviderEvents.Ready, resolve);\n client.removeHandler(ProviderEvents.Ready, reject);\n });\n}\n", "import { Client } from '@openfeature/web-sdk';\nimport React from 'react';\nimport { NormalizedOptions, ReactFlagEvaluationOptions, normalizeOptions } from '../common/options';\n\n/**\n * The underlying React context.\n * DO NOT EXPORT PUBLICLY\n * @internal\n */\nexport const Context = React.createContext<{ client: Client; options: ReactFlagEvaluationOptions } | undefined>(undefined);\n\n/**\n * Get a normalized copy of the options used for this OpenFeatureProvider, see {@link normalizeOptions}.\n * DO NOT EXPORT PUBLICLY\n * @internal\n * @returns {NormalizedOptions} normalized options the defaulted options, not defaulted or normalized.\n */\nexport function useProviderOptions(): NormalizedOptions {\n const { options } = React.useContext(Context) || {};\n return normalizeOptions(options);\n}\n", "import React from 'react';\nimport { Context } from './context';\nimport { Client } from '@openfeature/web-sdk';\n\n/**\n * Get the {@link Client} instance for this OpenFeatureProvider context.\n * Note that the provider to which this is bound is determined by the OpenFeatureProvider's domain.\n * @returns {Client} client for this scope\n */\nexport function useOpenFeatureClient(): Client {\n const { client } = React.useContext(Context) || {};\n\n if (!client) {\n throw new Error(\n 'No OpenFeature client available - components using OpenFeature must be wrapped with an <OpenFeatureProvider>. If you are seeing this in a test, see: https://openfeature.dev/docs/reference/technologies/client/web/react#testing',\n );\n }\n\n return client;\n}\n", "import { useEffect, useState } from 'react';\nimport { useOpenFeatureClient } from './use-open-feature-client';\nimport { ProviderEvents, ProviderStatus } from '@openfeature/web-sdk';\n\n/**\n * Get the {@link ProviderStatus} for the OpenFeatureClient.\n * @returns {ProviderStatus} status of the client for this scope\n */\nexport function useOpenFeatureClientStatus(): ProviderStatus {\n const client = useOpenFeatureClient();\n const [status, setStatus] = useState(client.providerStatus);\n\n useEffect(() => {\n const updateStatus = () => setStatus(client.providerStatus);\n client.addHandler(ProviderEvents.ConfigurationChanged, updateStatus);\n client.addHandler(ProviderEvents.ContextChanged, updateStatus);\n client.addHandler(ProviderEvents.Error, updateStatus);\n client.addHandler(ProviderEvents.Ready, updateStatus);\n client.addHandler(ProviderEvents.Stale, updateStatus);\n client.addHandler(ProviderEvents.Reconciling, updateStatus);\n return () => {\n client.removeHandler(ProviderEvents.ConfigurationChanged, updateStatus);\n client.removeHandler(ProviderEvents.ContextChanged, updateStatus);\n client.removeHandler(ProviderEvents.Error, updateStatus);\n client.removeHandler(ProviderEvents.Ready, updateStatus);\n client.removeHandler(ProviderEvents.Stale, updateStatus);\n client.removeHandler(ProviderEvents.Reconciling, updateStatus);\n };\n }, [client]);\n\n return status;\n}\n", "import {\n EvaluationDetails,\n FlagValue,\n StandardResolutionReasons\n} from '@openfeature/web-sdk';\nimport { FlagQuery } from '../query';\n\n\n// FlagQuery implementation, do not export\nexport class HookFlagQuery<T extends FlagValue = FlagValue> implements FlagQuery {\n constructor(private _details: EvaluationDetails<T>) {}\n\n get details() {\n return this._details;\n }\n\n get value() {\n return this._details?.value;\n }\n\n get variant() {\n return this._details.variant;\n }\n\n get flagMetadata() {\n return this._details.flagMetadata;\n }\n\n get reason() {\n return this._details.reason;\n }\n\n get isError() {\n return !!this._details?.errorCode || this._details.reason == StandardResolutionReasons.ERROR;\n }\n\n get errorCode() {\n return this._details?.errorCode;\n }\n\n get errorMessage() {\n return this._details?.errorMessage;\n }\n\n get isAuthoritative() {\n return (\n !this.isError &&\n this._details.reason != StandardResolutionReasons.STALE &&\n this._details.reason != StandardResolutionReasons.DISABLED\n );\n }\n\n get type() {\n return typeof this._details.value;\n }\n}\n", "import { Client, OpenFeature } from '@openfeature/web-sdk';\nimport * as React from 'react';\nimport { ReactFlagEvaluationOptions } from '../common/options';\nimport { Context } from './context';\n\ntype ClientOrDomain =\n | {\n /**\n * An identifier which logically binds clients with providers\n * @see OpenFeature.setProvider() and overloads.\n */\n domain?: string;\n client?: never;\n }\n | {\n /**\n * OpenFeature client to use.\n */\n client?: Client;\n domain?: never;\n };\n\ntype ProviderProps = {\n children?: React.ReactNode;\n} & ClientOrDomain &\n ReactFlagEvaluationOptions;\n\n /**\n * Provides a scope for evaluating feature flags by binding a client to all child components.\n * @param {ProviderProps} properties props for the context provider\n * @returns {OpenFeatureProvider} context provider\n */\nexport function OpenFeatureProvider({ client, domain, children, ...options }: ProviderProps) {\n if (!client) {\n client = OpenFeature.getClient(domain);\n }\n\n return <Context.Provider value={{ client, options }}>{children}</Context.Provider>;\n}\n", "import { ProviderStatus } from '@openfeature/web-sdk';\nimport { DEFAULT_OPTIONS, ReactFlagEvaluationOptions, normalizeOptions } from '../common/options';\nimport { useProviderOptions } from './context';\nimport { useOpenFeatureClient } from './use-open-feature-client';\nimport { useOpenFeatureClientStatus } from './use-open-feature-client-status';\nimport { suspendUntilReady } from '../common/suspense';\n\ntype Options = Pick<ReactFlagEvaluationOptions, 'suspendUntilReady'>;\n\n/**\n * Utility hook that triggers suspense until the provider is {@link ProviderStatus.READY}, without evaluating any flags.\n * Especially useful for React v16/17 \"Legacy Suspense\", in which siblings to suspending components are\n * initially mounted and then hidden (see: https://github.com/reactwg/react-18/discussions/7).\n * @param {Options} options options for suspense\n * @returns {boolean} boolean indicating if provider is {@link ProviderStatus.READY}, useful if suspense is disabled and you want to handle loaders on your own\n */\nexport function useWhenProviderReady(options?: Options): boolean {\n const client = useOpenFeatureClient();\n const status = useOpenFeatureClientStatus();\n // highest priority > evaluation hook options > provider options > default options > lowest priority\n const defaultedOptions = { ...DEFAULT_OPTIONS, ...useProviderOptions(), ...normalizeOptions(options) };\n\n // suspense\n if (defaultedOptions.suspendUntilReady && status === ProviderStatus.NOT_READY) {\n suspendUntilReady(client);\n }\n\n return status === ProviderStatus.READY;\n}\n", "import {\n EvaluationContext,\n InMemoryProvider,\n JsonValue,\n NOOP_PROVIDER,\n OpenFeature,\n Provider,\n} from '@openfeature/web-sdk';\nimport React from 'react';\nimport { NormalizedOptions } from '../common/options';\nimport { OpenFeatureProvider } from './provider';\n\ntype FlagValueMap = { [flagKey: string]: JsonValue };\ntype FlagConfig = ConstructorParameters<typeof InMemoryProvider>[0];\ntype TestProviderProps = Omit<React.ComponentProps<typeof OpenFeatureProvider>, 'client'> &\n (\n | {\n provider?: never;\n /**\n * Optional map of flagKeys to flagValues for this OpenFeatureTestProvider context.\n * If not supplied, all flag evaluations will default.\n */\n flagValueMap?: FlagValueMap;\n /**\n * Optional delay for the underlying test provider's readiness and reconciliation.\n * Defaults to 0.\n */\n delayMs?: number;\n }\n | {\n /**\n * An optional partial provider to pass for full control over the flag resolution for this OpenFeatureTestProvider context.\n * Any un-implemented methods or properties will no-op.\n */\n provider?: Partial<Provider>;\n flagValueMap?: never;\n delayMs?: never;\n }\n );\n\n const TEST_VARIANT = 'test-variant';\n const TEST_PROVIDER = 'test-provider';\n\n// internal provider which is basically the in-memory provider with a simpler config and some optional fake delays\nclass TestProvider extends InMemoryProvider {\n constructor(\n flagValueMap: FlagValueMap,\n private delay = 0,\n ) {\n // convert the simple flagValueMap into an in-memory config\n const flagConfig = Object.entries(flagValueMap).reduce((acc: FlagConfig, flag): FlagConfig => {\n return {\n ...acc,\n [flag[0]]: {\n variants: {\n [TEST_VARIANT]: flag[1],\n },\n defaultVariant: TEST_VARIANT,\n disabled: false,\n },\n };\n }, {});\n super(flagConfig);\n }\n\n async initialize(context?: EvaluationContext | undefined): Promise<void> {\n await Promise.all([super.initialize(context), new Promise<void>((resolve) => setTimeout(resolve, this.delay))]);\n }\n\n async onContextChange() {\n return new Promise<void>((resolve) => setTimeout(resolve, this.delay));\n }\n}\n\n/**\n * A React Context provider based on the {@link InMemoryProvider}, specifically built for testing.\n * Use this for testing components that use flag evaluation hooks.\n * @param {TestProviderProps} testProviderOptions options for the OpenFeatureTestProvider\n * @returns {OpenFeatureProvider} OpenFeatureTestProvider\n */\nexport function OpenFeatureTestProvider(testProviderOptions: TestProviderProps) {\n const { flagValueMap, provider } = testProviderOptions;\n const effectiveProvider = (\n flagValueMap ? new TestProvider(flagValueMap, testProviderOptions.delayMs) : mixInNoop(provider) || NOOP_PROVIDER\n ) as Provider;\n testProviderOptions.domain\n ? OpenFeature.setProvider(testProviderOptions.domain, effectiveProvider)\n : OpenFeature.setProvider(effectiveProvider);\n\n return (\n <OpenFeatureProvider {...(testProviderOptions as NormalizedOptions)} domain={testProviderOptions.domain}>\n {testProviderOptions.children}\n </OpenFeatureProvider>\n );\n}\n\n// mix in the no-op provider when the partial is passed\nfunction mixInNoop(provider: Partial<Provider> = {}) {\n // fill in any missing methods with no-ops\n for (const prop of Object.getOwnPropertyNames(Object.getPrototypeOf(NOOP_PROVIDER)).filter(prop => prop !== 'constructor')) {\n const patchedProvider = provider as {[key: string]: keyof Provider};\n if (!Object.getPrototypeOf(patchedProvider)[prop] && !patchedProvider[prop]) {\n patchedProvider[prop] = Object.getPrototypeOf(NOOP_PROVIDER)[prop];\n }\n }\n // fill in the metadata if missing\n if (!provider.metadata || !provider.metadata.name) {\n (provider.metadata as unknown) = { name: TEST_PROVIDER };\n }\n return provider;\n}"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,kBAQO;AACP,IAAAC,gBAAoC;;;AC4C7B,IAAM,kBAA8C;AAAA,EACzD,wBAAwB;AAAA,EACxB,8BAA8B;AAAA,EAC9B,mBAAmB;AAAA,EACnB,yBAAyB;AAC3B;AASO,IAAM,mBAAgF,CAAC,UAAsC,CAAC,MAAM;AACzI,QAAM,yBAAyB,QAAQ;AACvC,QAAM,+BAA+B,QAAQ;AAG7C,QAAMC,qBAAoB,uBAAuB,UAAU,QAAQ,oBAAoB,QAAQ;AAC/F,QAAM,0BAA0B,6BAA6B,UAAU,QAAQ,0BAA0B,QAAQ;AAEjH,SAAO,gEAED,OAAOA,uBAAsB,aAAa,EAAC,mBAAAA,mBAAiB,IAC5D,OAAO,4BAA4B,aAAa,EAAC,wBAAuB,IACxE,OAAO,2BAA2B,aAAa,EAAC,uBAAsB,IACtE,OAAO,iCAAiC,aAAa,EAAC,6BAA4B;AAE1F;;;AClFA,qBAAuC;AAOhC,SAAS,kBAAkB,QAA+B;AAC/D,MAAI;AACJ,MAAI;AACJ,QAAM,IAAI,QAAQ,CAAC,UAAU,YAAY;AACvC,cAAU;AACV,aAAS;AACT,WAAO,WAAW,8BAAe,OAAO,OAAO;AAC/C,WAAO,WAAW,8BAAe,OAAO,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AAO,IAAI,UAAU,QAAQ,KAAK;AAEtG,sBAAoB,SAChB,4BAAY,YAAY,oBAAoB,QAAQ,iBAAiB,IACrE,4BAAY,YAAY,iBAAiB;AAE7C,SACE,8BAAAC,QAAA,cAAC,sDAAyB,sBAAzB,EAAoE,QAAQ,oBAAoB,WAC9F,oBAAoB,QACvB;AAEJ;AAGA,SAAS,UAAU,WAA8B,CAAC,GAAG;AAEnD,aAAW,QAAQ,OAAO,oBAAoB,OAAO,eAAe,6BAAa,CAAC,EAAE,OAAO,CAAAC,UAAQA,UAAS,aAAa,GAAG;AAC1H,UAAM,kBAAkB;AACxB,QAAI,CAAC,OAAO,eAAe,eAAe,EAAE,IAAI,KAAK,CAAC,gBAAgB,IAAI,GAAG;AAC3E,sBAAgB,IAAI,IAAI,OAAO,eAAe,6BAAa,EAAE,IAAI;AAAA,IACnE;AAAA,EACF;AAEA,MAAI,CAAC,SAAS,YAAY,CAAC,SAAS,SAAS,MAAM;AACjD,IAAC,SAAS,WAAuB,EAAE,MAAM,cAAc;AAAA,EACzD;AACA,SAAO;AACT;;;AV1GA,wBAAc,iCAJd;",
4
+ "sourcesContent": ["export * from './evaluation';\nexport * from './query';\nexport * from './provider';\n// re-export the web-sdk so consumers can access that API from the react-sdk\nexport * from '@openfeature/web-sdk';\n", "import {\n Client,\n EvaluationDetails,\n FlagEvaluationOptions,\n FlagValue,\n JsonValue,\n ProviderEvents,\n ProviderStatus,\n} from '@openfeature/web-sdk';\nimport { useEffect, useState } from 'react';\nimport { DEFAULT_OPTIONS, ReactFlagEvaluationOptions, normalizeOptions } from '../common/options';\nimport { suspendUntilReady } from '../common/suspense';\nimport { useProviderOptions } from '../provider/context';\nimport { useOpenFeatureClient } from '../provider/use-open-feature-client';\nimport { useOpenFeatureClientStatus } from '../provider/use-open-feature-client-status';\nimport { FlagQuery } from '../query';\nimport { HookFlagQuery } from './hook-flag-query';\n\n// This type is a bit wild-looking, but I think we need it.\n// We have to use the conditional, because otherwise useFlag('key', false) would return false, not boolean (too constrained).\n// We have a duplicate for the hook return below, this one is just used for casting because the name isn't as clear\ntype ConstrainedFlagQuery<T> = FlagQuery<\n T extends boolean\n ? boolean\n : T extends number\n ? number\n : T extends string\n ? string\n : T extends JsonValue\n ? T\n : JsonValue\n>;\n\n// suspense options removed for the useSuspenseFlag hooks\ntype NoSuspenseOptions = Omit<ReactFlagEvaluationOptions, 'suspend' | 'suspendUntilReady' | 'suspendWhileReconciling'>\n\n/**\n * Evaluates a feature flag generically, returning an react-flavored queryable object.\n * The resolver method to use is based on the type of the defaultValue.\n * For type-specific hooks, use {@link useBooleanFlagValue}, {@link useBooleanFlagDetails} and equivalents.\n * By default, components will re-render when the flag value changes.\n * @param {string} flagKey the flag identifier\n * @template {FlagValue} T A optional generic argument constraining the default.\n * @param {T} defaultValue the default value; used to determine what resolved type should be used.\n * @param {ReactFlagEvaluationOptions} options for this evaluation\n * @returns { FlagQuery } a queryable object containing useful information about the flag.\n */\nexport function useFlag<T extends FlagValue = FlagValue>(\n flagKey: string,\n defaultValue: T,\n options?: ReactFlagEvaluationOptions,\n): FlagQuery<\nT extends boolean\n ? boolean\n : T extends number\n ? number\n : T extends string\n ? string\n : T extends JsonValue\n ? T\n : JsonValue\n> {\n // use the default value to determine the resolver to call\n const query =\n typeof defaultValue === 'boolean'\n ? new HookFlagQuery<boolean>(useBooleanFlagDetails(flagKey, defaultValue, options))\n : typeof defaultValue === 'number'\n ? new HookFlagQuery<number>(useNumberFlagDetails(flagKey, defaultValue, options))\n : typeof defaultValue === 'string'\n ? new HookFlagQuery<string>(useStringFlagDetails(flagKey, defaultValue, options))\n : new HookFlagQuery<JsonValue>(useObjectFlagDetails(flagKey, defaultValue, options));\n // TS sees this as HookFlagQuery<JsonValue>, because the compiler isn't aware of the `typeof` checks above.\n return query as unknown as ConstrainedFlagQuery<T>;\n}\n\n// alias to the return value of useFlag, used to keep useSuspenseFlag consistent\ntype UseFlagReturn<T extends FlagValue> = ReturnType<typeof useFlag<T>>\n\n/**\n * Equivalent to {@link useFlag} with `options: { suspend: true }`\n * @experimental Suspense is an experimental feature subject to change in future versions.\n * @param {string} flagKey the flag identifier\n * @template {FlagValue} T A optional generic argument constraining the default.\n * @param {T} defaultValue the default value; used to determine what resolved type should be used.\n * @param {NoSuspenseOptions} options for this evaluation\n * @returns { UseFlagReturn<T> } a queryable object containing useful information about the flag.\n */\nexport function useSuspenseFlag<T extends FlagValue = FlagValue>(\n flagKey: string,\n defaultValue: T,\n options?: NoSuspenseOptions,\n): UseFlagReturn<T> {\n return useFlag(flagKey, defaultValue, { ...options, suspendUntilReady: true, suspendWhileReconciling: true });\n}\n\n/**\n * Evaluates a feature flag, returning a boolean.\n * By default, components will re-render when the flag value changes.\n * For a generic hook returning a queryable interface, see {@link useFlag}.\n * @param {string} flagKey the flag identifier\n * @param {boolean} defaultValue the default value\n * @param {ReactFlagEvaluationOptions} options options for this evaluation\n * @returns { boolean} a EvaluationDetails object for this evaluation\n */\nexport function useBooleanFlagValue(\n flagKey: string,\n defaultValue: boolean,\n options?: ReactFlagEvaluationOptions,\n): boolean {\n return useBooleanFlagDetails(flagKey, defaultValue, options).value;\n}\n\n/**\n * Evaluates a feature flag, returning evaluation details.\n * By default, components will re-render when the flag value changes.\n * For a generic hook returning a queryable interface, see {@link useFlag}.\n * @param {string} flagKey the flag identifier\n * @param {boolean} defaultValue the default value\n * @param {ReactFlagEvaluationOptions} options options for this evaluation\n * @returns { EvaluationDetails<boolean>} a EvaluationDetails object for this evaluation\n */\nexport function useBooleanFlagDetails(\n flagKey: string,\n defaultValue: boolean,\n options?: ReactFlagEvaluationOptions,\n): EvaluationDetails<boolean> {\n return attachHandlersAndResolve(\n flagKey,\n defaultValue,\n (client) => {\n return client.getBooleanDetails;\n },\n options,\n );\n}\n\n/**\n * Evaluates a feature flag, returning a string.\n * By default, components will re-render when the flag value changes.\n * For a generic hook returning a queryable interface, see {@link useFlag}.\n * @param {string} flagKey the flag identifier\n * @template {string} [T=string] A optional generic argument constraining the string\n * @param {T} defaultValue the default value\n * @param {ReactFlagEvaluationOptions} options options for this evaluation\n * @returns { boolean} a EvaluationDetails object for this evaluation\n */\nexport function useStringFlagValue<T extends string = string>(\n flagKey: string,\n defaultValue: T,\n options?: ReactFlagEvaluationOptions,\n): string {\n return useStringFlagDetails(flagKey, defaultValue, options).value;\n}\n\n/**\n * Evaluates a feature flag, returning evaluation details.\n * By default, components will re-render when the flag value changes.\n * For a generic hook returning a queryable interface, see {@link useFlag}.\n * @param {string} flagKey the flag identifier\n * @template {string} [T=string] A optional generic argument constraining the string\n * @param {T} defaultValue the default value\n * @param {ReactFlagEvaluationOptions} options options for this evaluation\n * @returns { EvaluationDetails<string>} a EvaluationDetails object for this evaluation\n */\nexport function useStringFlagDetails<T extends string = string>(\n flagKey: string,\n defaultValue: T,\n options?: ReactFlagEvaluationOptions,\n): EvaluationDetails<string> {\n return attachHandlersAndResolve(\n flagKey,\n defaultValue,\n (client) => {\n return client.getStringDetails<T>;\n },\n options,\n );\n}\n\n/**\n * Evaluates a feature flag, returning a number.\n * By default, components will re-render when the flag value changes.\n * For a generic hook returning a queryable interface, see {@link useFlag}.\n * @param {string} flagKey the flag identifier\n * @template {number} [T=number] A optional generic argument constraining the number\n * @param {T} defaultValue the default value\n * @param {ReactFlagEvaluationOptions} options options for this evaluation\n * @returns { boolean} a EvaluationDetails object for this evaluation\n */\nexport function useNumberFlagValue<T extends number = number>(\n flagKey: string,\n defaultValue: T,\n options?: ReactFlagEvaluationOptions,\n): number {\n return useNumberFlagDetails(flagKey, defaultValue, options).value;\n}\n\n/**\n * Evaluates a feature flag, returning evaluation details.\n * By default, components will re-render when the flag value changes.\n * For a generic hook returning a queryable interface, see {@link useFlag}.\n * @param {string} flagKey the flag identifier\n * @template {number} [T=number] A optional generic argument constraining the number\n * @param {T} defaultValue the default value\n * @param {ReactFlagEvaluationOptions} options options for this evaluation\n * @returns { EvaluationDetails<number>} a EvaluationDetails object for this evaluation\n */\nexport function useNumberFlagDetails<T extends number = number>(\n flagKey: string,\n defaultValue: T,\n options?: ReactFlagEvaluationOptions,\n): EvaluationDetails<number> {\n return attachHandlersAndResolve(\n flagKey,\n defaultValue,\n (client) => {\n return client.getNumberDetails<T>;\n },\n options,\n );\n}\n\n/**\n * Evaluates a feature flag, returning an object.\n * By default, components will re-render when the flag value changes.\n * For a generic hook returning a queryable interface, see {@link useFlag}.\n * @param {string} flagKey the flag identifier\n * @template {JsonValue} [T=JsonValue] A optional generic argument describing the structure\n * @param {T} defaultValue the default value\n * @param {ReactFlagEvaluationOptions} options options for this evaluation\n * @returns { boolean} a EvaluationDetails object for this evaluation\n */\nexport function useObjectFlagValue<T extends JsonValue = JsonValue>(\n flagKey: string,\n defaultValue: T,\n options?: ReactFlagEvaluationOptions,\n): T {\n return useObjectFlagDetails<T>(flagKey, defaultValue, options).value;\n}\n\n/**\n * Evaluates a feature flag, returning evaluation details.\n * By default, components will re-render when the flag value changes.\n * For a generic hook returning a queryable interface, see {@link useFlag}.\n * @param {string} flagKey the flag identifier\n * @param {T} defaultValue the default value\n * @template {JsonValue} [T=JsonValue] A optional generic argument describing the structure\n * @param {ReactFlagEvaluationOptions} options options for this evaluation\n * @returns { EvaluationDetails<T>} a EvaluationDetails object for this evaluation\n */\nexport function useObjectFlagDetails<T extends JsonValue = JsonValue>(\n flagKey: string,\n defaultValue: T,\n options?: ReactFlagEvaluationOptions,\n): EvaluationDetails<T> {\n return attachHandlersAndResolve(\n flagKey,\n defaultValue,\n (client) => {\n return client.getObjectDetails<T>;\n },\n options,\n );\n}\n\nfunction attachHandlersAndResolve<T extends FlagValue>(\n flagKey: string,\n defaultValue: T,\n resolver: (client: Client) => (flagKey: string, defaultValue: T, options?: FlagEvaluationOptions) => EvaluationDetails<T>,\n options?: ReactFlagEvaluationOptions,\n): EvaluationDetails<T> {\n // highest priority > evaluation hook options > provider options > default options > lowest priority\n const defaultedOptions = { ...DEFAULT_OPTIONS, ...useProviderOptions(), ...normalizeOptions(options) };\n const client = useOpenFeatureClient();\n const status = useOpenFeatureClientStatus();\n\n // suspense\n if (defaultedOptions.suspendUntilReady && status === ProviderStatus.NOT_READY) {\n suspendUntilReady(client);\n }\n\n if (defaultedOptions.suspendWhileReconciling && status === ProviderStatus.RECONCILING) {\n suspendUntilReady(client);\n }\n\n const [evalutationDetails, setEvaluationDetails] = useState<EvaluationDetails<T>>(\n resolver(client).call(client, flagKey, defaultValue, options),\n );\n\n const updateEvaluationDetailsRef = () => {\n setEvaluationDetails(resolver(client).call(client, flagKey, defaultValue, options));\n };\n\n useEffect(() => {\n if (status === ProviderStatus.NOT_READY) {\n // update when the provider is ready\n client.addHandler(ProviderEvents.Ready, updateEvaluationDetailsRef);\n }\n\n if (defaultedOptions.updateOnContextChanged) {\n // update when the context changes\n client.addHandler(ProviderEvents.ContextChanged, updateEvaluationDetailsRef);\n }\n return () => {\n // cleanup the handlers\n client.removeHandler(ProviderEvents.Ready, updateEvaluationDetailsRef);\n client.removeHandler(ProviderEvents.ContextChanged, updateEvaluationDetailsRef);\n };\n }, []);\n\n useEffect(() => {\n if (defaultedOptions.updateOnConfigurationChanged) {\n // update when the provider configuration changes\n client.addHandler(ProviderEvents.ConfigurationChanged, updateEvaluationDetailsRef);\n }\n return () => {\n // cleanup the handlers\n client.removeHandler(ProviderEvents.ConfigurationChanged, updateEvaluationDetailsRef);\n };\n }, []);\n\n return evalutationDetails;\n}\n", "import { FlagEvaluationOptions } from '@openfeature/web-sdk';\n\nexport type ReactFlagEvaluationOptions = ({\n /**\n * Enable or disable all suspense functionality.\n * Cannot be used in conjunction with `suspendUntilReady` and `suspendWhileReconciling` options.\n * @experimental Suspense is an experimental feature subject to change in future versions.\n */\n suspend?: boolean;\n suspendUntilReady?: never;\n suspendWhileReconciling?: never;\n} | {\n /**\n * Suspend flag evaluations while the provider is not ready.\n * Set to false if you don't want to show suspense fallbacks until the provider is initialized.\n * Defaults to false.\n * Cannot be used in conjunction with `suspend` option.\n * @experimental Suspense is an experimental feature subject to change in future versions.\n */\n suspendUntilReady?: boolean;\n /**\n * Suspend flag evaluations while the provider's context is being reconciled.\n * Set to true if you want to show suspense fallbacks while flags are re-evaluated after context changes.\n * Defaults to false.\n * Cannot be used in conjunction with `suspend` option.\n * @experimental Suspense is an experimental feature subject to change in future versions.\n */\n suspendWhileReconciling?: boolean;\n suspend?: never;\n}) & {\n /**\n * Update the component if the provider emits a ConfigurationChanged event.\n * Set to false to prevent components from re-rendering when flag value changes\n * are received by the associated provider.\n * Defaults to true.\n */\n updateOnConfigurationChanged?: boolean;\n /**\n * Update the component when the OpenFeature context changes.\n * Set to false to prevent components from re-rendering when attributes which\n * may be factors in flag evaluation change.\n * Defaults to true.\n */\n updateOnContextChanged?: boolean;\n} & FlagEvaluationOptions;\n\nexport type NormalizedOptions = Omit<ReactFlagEvaluationOptions, 'suspend'>;\n\n/**\n * Default options.\n * DO NOT EXPORT PUBLICLY\n * @internal\n */\nexport const DEFAULT_OPTIONS: ReactFlagEvaluationOptions = {\n updateOnContextChanged: true,\n updateOnConfigurationChanged: true,\n suspendUntilReady: false,\n suspendWhileReconciling: false,\n};\n\n/**\n * Returns normalization options (all `undefined` fields removed, and `suspend` decomposed to `suspendUntilReady` and `suspendWhileReconciling`).\n * DO NOT EXPORT PUBLICLY\n * @internal\n * @param {ReactFlagEvaluationOptions} options options to normalize\n * @returns {NormalizedOptions} normalized options\n */\nexport const normalizeOptions: (options?: ReactFlagEvaluationOptions) => NormalizedOptions = (options: ReactFlagEvaluationOptions = {}) => {\n const updateOnContextChanged = options.updateOnContextChanged;\n const updateOnConfigurationChanged = options.updateOnConfigurationChanged;\n\n // fall-back the suspense options to the catch-all `suspend` property \n const suspendUntilReady = 'suspendUntilReady' in options ? options.suspendUntilReady : options.suspend;\n const suspendWhileReconciling = 'suspendWhileReconciling' in options ? options.suspendWhileReconciling : options.suspend;\n\n return {\n // only return these if properly set (no undefined to allow overriding with spread)\n ...(typeof suspendUntilReady === 'boolean' && {suspendUntilReady}),\n ...(typeof suspendWhileReconciling === 'boolean' && {suspendWhileReconciling}),\n ...(typeof updateOnContextChanged === 'boolean' && {updateOnContextChanged}),\n ...(typeof updateOnConfigurationChanged === 'boolean' && {updateOnConfigurationChanged}),\n };\n};\n", "import { Client, ProviderEvents } from '@openfeature/web-sdk';\n\n/**\n * Suspends until the client is ready to evaluate feature flags.\n * DO NOT EXPORT PUBLICLY\n * @param {Client} client OpenFeature client\n */\nexport function suspendUntilReady(client: Client): Promise<void> {\n let resolve: (value: unknown) => void;\n let reject: () => void;\n throw new Promise((_resolve, _reject) => {\n resolve = _resolve;\n reject = _reject;\n client.addHandler(ProviderEvents.Ready, resolve);\n client.addHandler(ProviderEvents.Error, reject);\n }).finally(() => {\n client.removeHandler(ProviderEvents.Ready, resolve);\n client.removeHandler(ProviderEvents.Ready, reject);\n });\n}\n", "import { Client } from '@openfeature/web-sdk';\nimport React from 'react';\nimport { NormalizedOptions, ReactFlagEvaluationOptions, normalizeOptions } from '../common/options';\n\n/**\n * The underlying React context.\n * DO NOT EXPORT PUBLICLY\n * @internal\n */\nexport const Context = React.createContext<{ client: Client; options: ReactFlagEvaluationOptions } | undefined>(undefined);\n\n/**\n * Get a normalized copy of the options used for this OpenFeatureProvider, see {@link normalizeOptions}.\n * DO NOT EXPORT PUBLICLY\n * @internal\n * @returns {NormalizedOptions} normalized options the defaulted options, not defaulted or normalized.\n */\nexport function useProviderOptions(): NormalizedOptions {\n const { options } = React.useContext(Context) || {};\n return normalizeOptions(options);\n}\n", "import React from 'react';\nimport { Context } from './context';\nimport { Client } from '@openfeature/web-sdk';\n\n/**\n * Get the {@link Client} instance for this OpenFeatureProvider context.\n * Note that the provider to which this is bound is determined by the OpenFeatureProvider's domain.\n * @returns {Client} client for this scope\n */\nexport function useOpenFeatureClient(): Client {\n const { client } = React.useContext(Context) || {};\n\n if (!client) {\n throw new Error(\n 'No OpenFeature client available - components using OpenFeature must be wrapped with an <OpenFeatureProvider>. If you are seeing this in a test, see: https://openfeature.dev/docs/reference/technologies/client/web/react#testing',\n );\n }\n\n return client;\n}\n", "import { useEffect, useState } from 'react';\nimport { useOpenFeatureClient } from './use-open-feature-client';\nimport { ProviderEvents, ProviderStatus } from '@openfeature/web-sdk';\n\n/**\n * Get the {@link ProviderStatus} for the OpenFeatureClient.\n * @returns {ProviderStatus} status of the client for this scope\n */\nexport function useOpenFeatureClientStatus(): ProviderStatus {\n const client = useOpenFeatureClient();\n const [status, setStatus] = useState(client.providerStatus);\n\n useEffect(() => {\n const updateStatus = () => setStatus(client.providerStatus);\n client.addHandler(ProviderEvents.ConfigurationChanged, updateStatus);\n client.addHandler(ProviderEvents.ContextChanged, updateStatus);\n client.addHandler(ProviderEvents.Error, updateStatus);\n client.addHandler(ProviderEvents.Ready, updateStatus);\n client.addHandler(ProviderEvents.Stale, updateStatus);\n client.addHandler(ProviderEvents.Reconciling, updateStatus);\n return () => {\n client.removeHandler(ProviderEvents.ConfigurationChanged, updateStatus);\n client.removeHandler(ProviderEvents.ContextChanged, updateStatus);\n client.removeHandler(ProviderEvents.Error, updateStatus);\n client.removeHandler(ProviderEvents.Ready, updateStatus);\n client.removeHandler(ProviderEvents.Stale, updateStatus);\n client.removeHandler(ProviderEvents.Reconciling, updateStatus);\n };\n }, [client]);\n\n return status;\n}\n", "import {\n EvaluationDetails,\n FlagValue,\n StandardResolutionReasons\n} from '@openfeature/web-sdk';\nimport { FlagQuery } from '../query';\n\n\n// FlagQuery implementation, do not export\nexport class HookFlagQuery<T extends FlagValue = FlagValue> implements FlagQuery {\n constructor(private _details: EvaluationDetails<T>) {}\n\n get details() {\n return this._details;\n }\n\n get value() {\n return this._details?.value;\n }\n\n get variant() {\n return this._details.variant;\n }\n\n get flagMetadata() {\n return this._details.flagMetadata;\n }\n\n get reason() {\n return this._details.reason;\n }\n\n get isError() {\n return !!this._details?.errorCode || this._details.reason == StandardResolutionReasons.ERROR;\n }\n\n get errorCode() {\n return this._details?.errorCode;\n }\n\n get errorMessage() {\n return this._details?.errorMessage;\n }\n\n get isAuthoritative() {\n return (\n !this.isError &&\n this._details.reason != StandardResolutionReasons.STALE &&\n this._details.reason != StandardResolutionReasons.DISABLED\n );\n }\n\n get type() {\n return typeof this._details.value;\n }\n}\n", "import { Client, OpenFeature } from '@openfeature/web-sdk';\nimport * as React from 'react';\nimport { ReactFlagEvaluationOptions } from '../common/options';\nimport { Context } from './context';\n\ntype ClientOrDomain =\n | {\n /**\n * An identifier which logically binds clients with providers\n * @see OpenFeature.setProvider() and overloads.\n */\n domain?: string;\n client?: never;\n }\n | {\n /**\n * OpenFeature client to use.\n */\n client?: Client;\n domain?: never;\n };\n\ntype ProviderProps = {\n children?: React.ReactNode;\n} & ClientOrDomain &\n ReactFlagEvaluationOptions;\n\n /**\n * Provides a scope for evaluating feature flags by binding a client to all child components.\n * @param {ProviderProps} properties props for the context provider\n * @returns {OpenFeatureProvider} context provider\n */\nexport function OpenFeatureProvider({ client, domain, children, ...options }: ProviderProps) {\n if (!client) {\n client = OpenFeature.getClient(domain);\n }\n\n return <Context.Provider value={{ client, options }}>{children}</Context.Provider>;\n}\n", "import { ProviderStatus } from '@openfeature/web-sdk';\nimport { DEFAULT_OPTIONS, ReactFlagEvaluationOptions, normalizeOptions } from '../common/options';\nimport { useProviderOptions } from './context';\nimport { useOpenFeatureClient } from './use-open-feature-client';\nimport { useOpenFeatureClientStatus } from './use-open-feature-client-status';\nimport { suspendUntilReady } from '../common/suspense';\n\ntype Options = Pick<ReactFlagEvaluationOptions, 'suspendUntilReady'>;\n\n/**\n * Utility hook that triggers suspense until the provider is {@link ProviderStatus.READY}, without evaluating any flags.\n * Especially useful for React v16/17 \"Legacy Suspense\", in which siblings to suspending components are\n * initially mounted and then hidden (see: https://github.com/reactwg/react-18/discussions/7).\n * @param {Options} options options for suspense\n * @returns {boolean} boolean indicating if provider is {@link ProviderStatus.READY}, useful if suspense is disabled and you want to handle loaders on your own\n */\nexport function useWhenProviderReady(options?: Options): boolean {\n const client = useOpenFeatureClient();\n const status = useOpenFeatureClientStatus();\n // highest priority > evaluation hook options > provider options > default options > lowest priority\n const defaultedOptions = { ...DEFAULT_OPTIONS, ...useProviderOptions(), ...normalizeOptions(options) };\n\n // suspense\n if (defaultedOptions.suspendUntilReady && status === ProviderStatus.NOT_READY) {\n suspendUntilReady(client);\n }\n\n return status === ProviderStatus.READY;\n}\n", "import {\n InMemoryProvider,\n JsonValue,\n NOOP_PROVIDER,\n OpenFeature,\n Provider,\n} from '@openfeature/web-sdk';\nimport React from 'react';\nimport { NormalizedOptions } from '../common/options';\nimport { OpenFeatureProvider } from './provider';\n\ntype FlagValueMap = { [flagKey: string]: JsonValue };\ntype FlagConfig = ConstructorParameters<typeof InMemoryProvider>[0];\ntype TestProviderProps = Omit<React.ComponentProps<typeof OpenFeatureProvider>, 'client'> &\n (\n | {\n provider?: never;\n /**\n * Optional map of flagKeys to flagValues for this OpenFeatureTestProvider context.\n * If not supplied, all flag evaluations will default.\n */\n flagValueMap?: FlagValueMap;\n /**\n * Optional delay for the underlying test provider's readiness and reconciliation.\n * Defaults to 0.\n */\n delayMs?: number;\n }\n | {\n /**\n * An optional partial provider to pass for full control over the flag resolution for this OpenFeatureTestProvider context.\n * Any un-implemented methods or properties will no-op.\n */\n provider?: Partial<Provider>;\n flagValueMap?: never;\n delayMs?: never;\n }\n );\n\n const TEST_VARIANT = 'test-variant';\n const TEST_PROVIDER = 'test-provider';\n\n// internal provider which is basically the in-memory provider with a simpler config and some optional fake delays\nclass TestProvider extends InMemoryProvider {\n\n // initially make this undefined, we still set it if a delay is specified\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - For maximum compatibility with previous versions, we ignore a possible TS error here,\n // since \"initialize\" was previously defined in superclass.\n // We can safely remove this ts-ignore in a few versions\n initialize: Provider['initialize'] = undefined;\n\n // \"place-holder\" init function which we only assign if want a delay\n private delayedInitialize = async () => {\n await new Promise<void>((resolve) => setTimeout(resolve, this.delay));\n };\n\n constructor(\n flagValueMap: FlagValueMap,\n private delay = 0,\n ) {\n // convert the simple flagValueMap into an in-memory config\n const flagConfig = Object.entries(flagValueMap).reduce((acc: FlagConfig, flag): FlagConfig => {\n return {\n ...acc,\n [flag[0]]: {\n variants: {\n [TEST_VARIANT]: flag[1],\n },\n defaultVariant: TEST_VARIANT,\n disabled: false,\n },\n };\n }, {});\n super(flagConfig);\n // only define and init if there's a non-zero delay specified\n this.initialize = this.delay ? this.delayedInitialize.bind(this) : undefined;\n }\n\n async onContextChange() {\n return new Promise<void>((resolve) => setTimeout(resolve, this.delay));\n }\n}\n\n/**\n * A React Context provider based on the {@link InMemoryProvider}, specifically built for testing.\n * Use this for testing components that use flag evaluation hooks.\n * @param {TestProviderProps} testProviderOptions options for the OpenFeatureTestProvider\n * @returns {OpenFeatureProvider} OpenFeatureTestProvider\n */\nexport function OpenFeatureTestProvider(testProviderOptions: TestProviderProps) {\n const { flagValueMap, provider } = testProviderOptions;\n const effectiveProvider = (\n flagValueMap ? new TestProvider(flagValueMap, testProviderOptions.delayMs) : mixInNoop(provider) || NOOP_PROVIDER\n ) as Provider;\n testProviderOptions.domain\n ? OpenFeature.setProvider(testProviderOptions.domain, effectiveProvider)\n : OpenFeature.setProvider(effectiveProvider);\n\n return (\n <OpenFeatureProvider {...(testProviderOptions as NormalizedOptions)} domain={testProviderOptions.domain}>\n {testProviderOptions.children}\n </OpenFeatureProvider>\n );\n}\n\n// mix in the no-op provider when the partial is passed\nfunction mixInNoop(provider: Partial<Provider> = {}) {\n // fill in any missing methods with no-ops\n for (const prop of Object.getOwnPropertyNames(Object.getPrototypeOf(NOOP_PROVIDER)).filter(prop => prop !== 'constructor')) {\n const patchedProvider = provider as {[key: string]: keyof Provider};\n if (!Object.getPrototypeOf(patchedProvider)[prop] && !patchedProvider[prop]) {\n patchedProvider[prop] = Object.getPrototypeOf(NOOP_PROVIDER)[prop];\n }\n }\n // fill in the metadata if missing\n if (!provider.metadata || !provider.metadata.name) {\n (provider.metadata as unknown) = { name: TEST_PROVIDER };\n }\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C9F,oBAAoB,QACvB;AAEJ;AAGA,SAAS,UAAU,WAA8B,CAAC,GAAG;AAEnD,aAAW,QAAQ,OAAO,oBAAoB,OAAO,eAAe,6BAAa,CAAC,EAAE,OAAO,CAAAC,UAAQA,UAAS,aAAa,GAAG;AAC1H,UAAM,kBAAkB;AACxB,QAAI,CAAC,OAAO,eAAe,eAAe,EAAE,IAAI,KAAK,CAAC,gBAAgB,IAAI,GAAG;AAC3E,sBAAgB,IAAI,IAAI,OAAO,eAAe,6BAAa,EAAE,IAAI;AAAA,IACnE;AAAA,EACF;AAEA,MAAI,CAAC,SAAS,YAAY,CAAC,SAAS,SAAS,MAAM;AACjD,IAAC,SAAS,WAAuB,EAAE,MAAM,cAAc;AAAA,EACzD;AACA,SAAO;AACT;;;AVpHA,wBAAc,iCAJd;",
6
6
  "names": ["import_web_sdk", "import_react", "suspendUntilReady", "React", "import_react", "React", "import_react", "import_web_sdk", "import_web_sdk", "import_web_sdk", "React", "import_web_sdk", "import_web_sdk", "import_react", "React", "prop"]
7
7
  }
package/dist/esm/index.js CHANGED
@@ -2,10 +2,8 @@ var __defProp = Object.defineProperty;
2
2
  var __defProps = Object.defineProperties;
3
3
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
4
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __getProtoOf = Object.getPrototypeOf;
6
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
6
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
8
- var __reflectGet = Reflect.get;
9
7
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
8
  var __spreadValues = (a, b) => {
11
9
  for (var prop in b || (b = {}))
@@ -31,7 +29,6 @@ var __objRest = (source, exclude) => {
31
29
  }
32
30
  return target;
33
31
  };
34
- var __superGet = (cls, obj, key) => __reflectGet(__getProtoOf(cls), key, obj);
35
32
  var __async = (__this, __arguments, generator) => {
36
33
  return new Promise((resolve, reject) => {
37
34
  var fulfilled = (value) => {
@@ -312,7 +309,7 @@ import {
312
309
  import React4 from "react";
313
310
  var TEST_VARIANT = "test-variant";
314
311
  var TEST_PROVIDER = "test-provider";
315
- var TestProvider = class _TestProvider extends InMemoryProvider {
312
+ var TestProvider = class extends InMemoryProvider {
316
313
  constructor(flagValueMap, delay = 0) {
317
314
  const flagConfig = Object.entries(flagValueMap).reduce((acc, flag) => {
318
315
  return __spreadProps(__spreadValues({}, acc), {
@@ -327,11 +324,17 @@ var TestProvider = class _TestProvider extends InMemoryProvider {
327
324
  }, {});
328
325
  super(flagConfig);
329
326
  this.delay = delay;
330
- }
331
- initialize(context) {
332
- return __async(this, null, function* () {
333
- yield Promise.all([__superGet(_TestProvider.prototype, this, "initialize").call(this, context), new Promise((resolve) => setTimeout(resolve, this.delay))]);
327
+ // initially make this undefined, we still set it if a delay is specified
328
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
329
+ // @ts-ignore - For maximum compatibility with previous versions, we ignore a possible TS error here,
330
+ // since "initialize" was previously defined in superclass.
331
+ // We can safely remove this ts-ignore in a few versions
332
+ this.initialize = void 0;
333
+ // "place-holder" init function which we only assign if want a delay
334
+ this.delayedInitialize = () => __async(this, null, function* () {
335
+ yield new Promise((resolve) => setTimeout(resolve, this.delay));
334
336
  });
337
+ this.initialize = this.delay ? this.delayedInitialize.bind(this) : void 0;
335
338
  }
336
339
  onContextChange() {
337
340
  return __async(this, null, function* () {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/evaluation/use-feature-flag.ts", "../../src/common/options.ts", "../../src/common/suspense.ts", "../../src/provider/context.ts", "../../src/provider/use-open-feature-client.ts", "../../src/provider/use-open-feature-client-status.ts", "../../src/evaluation/hook-flag-query.ts", "../../src/provider/provider.tsx", "../../src/provider/use-when-provider-ready.ts", "../../src/provider/test-provider.tsx", "../../src/index.ts"],
4
- "sourcesContent": ["import {\n Client,\n EvaluationDetails,\n FlagEvaluationOptions,\n FlagValue,\n JsonValue,\n ProviderEvents,\n ProviderStatus,\n} from '@openfeature/web-sdk';\nimport { useEffect, useState } from 'react';\nimport { DEFAULT_OPTIONS, ReactFlagEvaluationOptions, normalizeOptions } from '../common/options';\nimport { suspendUntilReady } from '../common/suspense';\nimport { useProviderOptions } from '../provider/context';\nimport { useOpenFeatureClient } from '../provider/use-open-feature-client';\nimport { useOpenFeatureClientStatus } from '../provider/use-open-feature-client-status';\nimport { FlagQuery } from '../query';\nimport { HookFlagQuery } from './hook-flag-query';\n\n// This type is a bit wild-looking, but I think we need it.\n// We have to use the conditional, because otherwise useFlag('key', false) would return false, not boolean (too constrained).\n// We have a duplicate for the hook return below, this one is just used for casting because the name isn't as clear\ntype ConstrainedFlagQuery<T> = FlagQuery<\n T extends boolean\n ? boolean\n : T extends number\n ? number\n : T extends string\n ? string\n : T extends JsonValue\n ? T\n : JsonValue\n>;\n\n// suspense options removed for the useSuspenseFlag hooks\ntype NoSuspenseOptions = Omit<ReactFlagEvaluationOptions, 'suspend' | 'suspendUntilReady' | 'suspendWhileReconciling'>\n\n/**\n * Evaluates a feature flag generically, returning an react-flavored queryable object.\n * The resolver method to use is based on the type of the defaultValue.\n * For type-specific hooks, use {@link useBooleanFlagValue}, {@link useBooleanFlagDetails} and equivalents.\n * By default, components will re-render when the flag value changes.\n * @param {string} flagKey the flag identifier\n * @template {FlagValue} T A optional generic argument constraining the default.\n * @param {T} defaultValue the default value; used to determine what resolved type should be used.\n * @param {ReactFlagEvaluationOptions} options for this evaluation\n * @returns { FlagQuery } a queryable object containing useful information about the flag.\n */\nexport function useFlag<T extends FlagValue = FlagValue>(\n flagKey: string,\n defaultValue: T,\n options?: ReactFlagEvaluationOptions,\n): FlagQuery<\nT extends boolean\n ? boolean\n : T extends number\n ? number\n : T extends string\n ? string\n : T extends JsonValue\n ? T\n : JsonValue\n> {\n // use the default value to determine the resolver to call\n const query =\n typeof defaultValue === 'boolean'\n ? new HookFlagQuery<boolean>(useBooleanFlagDetails(flagKey, defaultValue, options))\n : typeof defaultValue === 'number'\n ? new HookFlagQuery<number>(useNumberFlagDetails(flagKey, defaultValue, options))\n : typeof defaultValue === 'string'\n ? new HookFlagQuery<string>(useStringFlagDetails(flagKey, defaultValue, options))\n : new HookFlagQuery<JsonValue>(useObjectFlagDetails(flagKey, defaultValue, options));\n // TS sees this as HookFlagQuery<JsonValue>, because the compiler isn't aware of the `typeof` checks above.\n return query as unknown as ConstrainedFlagQuery<T>;\n}\n\n// alias to the return value of useFlag, used to keep useSuspenseFlag consistent\ntype UseFlagReturn<T extends FlagValue> = ReturnType<typeof useFlag<T>>\n\n/**\n * Equivalent to {@link useFlag} with `options: { suspend: true }`\n * @experimental Suspense is an experimental feature subject to change in future versions.\n * @param {string} flagKey the flag identifier\n * @template {FlagValue} T A optional generic argument constraining the default.\n * @param {T} defaultValue the default value; used to determine what resolved type should be used.\n * @param {NoSuspenseOptions} options for this evaluation\n * @returns { UseFlagReturn<T> } a queryable object containing useful information about the flag.\n */\nexport function useSuspenseFlag<T extends FlagValue = FlagValue>(\n flagKey: string,\n defaultValue: T,\n options?: NoSuspenseOptions,\n): UseFlagReturn<T> {\n return useFlag(flagKey, defaultValue, { ...options, suspendUntilReady: true, suspendWhileReconciling: true });\n}\n\n/**\n * Evaluates a feature flag, returning a boolean.\n * By default, components will re-render when the flag value changes.\n * For a generic hook returning a queryable interface, see {@link useFlag}.\n * @param {string} flagKey the flag identifier\n * @param {boolean} defaultValue the default value\n * @param {ReactFlagEvaluationOptions} options options for this evaluation\n * @returns { boolean} a EvaluationDetails object for this evaluation\n */\nexport function useBooleanFlagValue(\n flagKey: string,\n defaultValue: boolean,\n options?: ReactFlagEvaluationOptions,\n): boolean {\n return useBooleanFlagDetails(flagKey, defaultValue, options).value;\n}\n\n/**\n * Evaluates a feature flag, returning evaluation details.\n * By default, components will re-render when the flag value changes.\n * For a generic hook returning a queryable interface, see {@link useFlag}.\n * @param {string} flagKey the flag identifier\n * @param {boolean} defaultValue the default value\n * @param {ReactFlagEvaluationOptions} options options for this evaluation\n * @returns { EvaluationDetails<boolean>} a EvaluationDetails object for this evaluation\n */\nexport function useBooleanFlagDetails(\n flagKey: string,\n defaultValue: boolean,\n options?: ReactFlagEvaluationOptions,\n): EvaluationDetails<boolean> {\n return attachHandlersAndResolve(\n flagKey,\n defaultValue,\n (client) => {\n return client.getBooleanDetails;\n },\n options,\n );\n}\n\n/**\n * Evaluates a feature flag, returning a string.\n * By default, components will re-render when the flag value changes.\n * For a generic hook returning a queryable interface, see {@link useFlag}.\n * @param {string} flagKey the flag identifier\n * @template {string} [T=string] A optional generic argument constraining the string\n * @param {T} defaultValue the default value\n * @param {ReactFlagEvaluationOptions} options options for this evaluation\n * @returns { boolean} a EvaluationDetails object for this evaluation\n */\nexport function useStringFlagValue<T extends string = string>(\n flagKey: string,\n defaultValue: T,\n options?: ReactFlagEvaluationOptions,\n): string {\n return useStringFlagDetails(flagKey, defaultValue, options).value;\n}\n\n/**\n * Evaluates a feature flag, returning evaluation details.\n * By default, components will re-render when the flag value changes.\n * For a generic hook returning a queryable interface, see {@link useFlag}.\n * @param {string} flagKey the flag identifier\n * @template {string} [T=string] A optional generic argument constraining the string\n * @param {T} defaultValue the default value\n * @param {ReactFlagEvaluationOptions} options options for this evaluation\n * @returns { EvaluationDetails<string>} a EvaluationDetails object for this evaluation\n */\nexport function useStringFlagDetails<T extends string = string>(\n flagKey: string,\n defaultValue: T,\n options?: ReactFlagEvaluationOptions,\n): EvaluationDetails<string> {\n return attachHandlersAndResolve(\n flagKey,\n defaultValue,\n (client) => {\n return client.getStringDetails<T>;\n },\n options,\n );\n}\n\n/**\n * Evaluates a feature flag, returning a number.\n * By default, components will re-render when the flag value changes.\n * For a generic hook returning a queryable interface, see {@link useFlag}.\n * @param {string} flagKey the flag identifier\n * @template {number} [T=number] A optional generic argument constraining the number\n * @param {T} defaultValue the default value\n * @param {ReactFlagEvaluationOptions} options options for this evaluation\n * @returns { boolean} a EvaluationDetails object for this evaluation\n */\nexport function useNumberFlagValue<T extends number = number>(\n flagKey: string,\n defaultValue: T,\n options?: ReactFlagEvaluationOptions,\n): number {\n return useNumberFlagDetails(flagKey, defaultValue, options).value;\n}\n\n/**\n * Evaluates a feature flag, returning evaluation details.\n * By default, components will re-render when the flag value changes.\n * For a generic hook returning a queryable interface, see {@link useFlag}.\n * @param {string} flagKey the flag identifier\n * @template {number} [T=number] A optional generic argument constraining the number\n * @param {T} defaultValue the default value\n * @param {ReactFlagEvaluationOptions} options options for this evaluation\n * @returns { EvaluationDetails<number>} a EvaluationDetails object for this evaluation\n */\nexport function useNumberFlagDetails<T extends number = number>(\n flagKey: string,\n defaultValue: T,\n options?: ReactFlagEvaluationOptions,\n): EvaluationDetails<number> {\n return attachHandlersAndResolve(\n flagKey,\n defaultValue,\n (client) => {\n return client.getNumberDetails<T>;\n },\n options,\n );\n}\n\n/**\n * Evaluates a feature flag, returning an object.\n * By default, components will re-render when the flag value changes.\n * For a generic hook returning a queryable interface, see {@link useFlag}.\n * @param {string} flagKey the flag identifier\n * @template {JsonValue} [T=JsonValue] A optional generic argument describing the structure\n * @param {T} defaultValue the default value\n * @param {ReactFlagEvaluationOptions} options options for this evaluation\n * @returns { boolean} a EvaluationDetails object for this evaluation\n */\nexport function useObjectFlagValue<T extends JsonValue = JsonValue>(\n flagKey: string,\n defaultValue: T,\n options?: ReactFlagEvaluationOptions,\n): T {\n return useObjectFlagDetails<T>(flagKey, defaultValue, options).value;\n}\n\n/**\n * Evaluates a feature flag, returning evaluation details.\n * By default, components will re-render when the flag value changes.\n * For a generic hook returning a queryable interface, see {@link useFlag}.\n * @param {string} flagKey the flag identifier\n * @param {T} defaultValue the default value\n * @template {JsonValue} [T=JsonValue] A optional generic argument describing the structure\n * @param {ReactFlagEvaluationOptions} options options for this evaluation\n * @returns { EvaluationDetails<T>} a EvaluationDetails object for this evaluation\n */\nexport function useObjectFlagDetails<T extends JsonValue = JsonValue>(\n flagKey: string,\n defaultValue: T,\n options?: ReactFlagEvaluationOptions,\n): EvaluationDetails<T> {\n return attachHandlersAndResolve(\n flagKey,\n defaultValue,\n (client) => {\n return client.getObjectDetails<T>;\n },\n options,\n );\n}\n\nfunction attachHandlersAndResolve<T extends FlagValue>(\n flagKey: string,\n defaultValue: T,\n resolver: (client: Client) => (flagKey: string, defaultValue: T, options?: FlagEvaluationOptions) => EvaluationDetails<T>,\n options?: ReactFlagEvaluationOptions,\n): EvaluationDetails<T> {\n // highest priority > evaluation hook options > provider options > default options > lowest priority\n const defaultedOptions = { ...DEFAULT_OPTIONS, ...useProviderOptions(), ...normalizeOptions(options) };\n const client = useOpenFeatureClient();\n const status = useOpenFeatureClientStatus();\n\n // suspense\n if (defaultedOptions.suspendUntilReady && status === ProviderStatus.NOT_READY) {\n suspendUntilReady(client);\n }\n\n if (defaultedOptions.suspendWhileReconciling && status === ProviderStatus.RECONCILING) {\n suspendUntilReady(client);\n }\n\n const [evalutationDetails, setEvaluationDetails] = useState<EvaluationDetails<T>>(\n resolver(client).call(client, flagKey, defaultValue, options),\n );\n\n const updateEvaluationDetailsRef = () => {\n setEvaluationDetails(resolver(client).call(client, flagKey, defaultValue, options));\n };\n\n useEffect(() => {\n if (status === ProviderStatus.NOT_READY) {\n // update when the provider is ready\n client.addHandler(ProviderEvents.Ready, updateEvaluationDetailsRef);\n }\n\n if (defaultedOptions.updateOnContextChanged) {\n // update when the context changes\n client.addHandler(ProviderEvents.ContextChanged, updateEvaluationDetailsRef);\n }\n return () => {\n // cleanup the handlers\n client.removeHandler(ProviderEvents.Ready, updateEvaluationDetailsRef);\n client.removeHandler(ProviderEvents.ContextChanged, updateEvaluationDetailsRef);\n };\n }, []);\n\n useEffect(() => {\n if (defaultedOptions.updateOnConfigurationChanged) {\n // update when the provider configuration changes\n client.addHandler(ProviderEvents.ConfigurationChanged, updateEvaluationDetailsRef);\n }\n return () => {\n // cleanup the handlers\n client.removeHandler(ProviderEvents.ConfigurationChanged, updateEvaluationDetailsRef);\n };\n }, []);\n\n return evalutationDetails;\n}\n", "import { FlagEvaluationOptions } from '@openfeature/web-sdk';\n\nexport type ReactFlagEvaluationOptions = ({\n /**\n * Enable or disable all suspense functionality.\n * Cannot be used in conjunction with `suspendUntilReady` and `suspendWhileReconciling` options.\n * @experimental Suspense is an experimental feature subject to change in future versions.\n */\n suspend?: boolean;\n suspendUntilReady?: never;\n suspendWhileReconciling?: never;\n} | {\n /**\n * Suspend flag evaluations while the provider is not ready.\n * Set to false if you don't want to show suspense fallbacks until the provider is initialized.\n * Defaults to false.\n * Cannot be used in conjunction with `suspend` option.\n * @experimental Suspense is an experimental feature subject to change in future versions.\n */\n suspendUntilReady?: boolean;\n /**\n * Suspend flag evaluations while the provider's context is being reconciled.\n * Set to true if you want to show suspense fallbacks while flags are re-evaluated after context changes.\n * Defaults to false.\n * Cannot be used in conjunction with `suspend` option.\n * @experimental Suspense is an experimental feature subject to change in future versions.\n */\n suspendWhileReconciling?: boolean;\n suspend?: never;\n}) & {\n /**\n * Update the component if the provider emits a ConfigurationChanged event.\n * Set to false to prevent components from re-rendering when flag value changes\n * are received by the associated provider.\n * Defaults to true.\n */\n updateOnConfigurationChanged?: boolean;\n /**\n * Update the component when the OpenFeature context changes.\n * Set to false to prevent components from re-rendering when attributes which\n * may be factors in flag evaluation change.\n * Defaults to true.\n */\n updateOnContextChanged?: boolean;\n} & FlagEvaluationOptions;\n\nexport type NormalizedOptions = Omit<ReactFlagEvaluationOptions, 'suspend'>;\n\n/**\n * Default options.\n * DO NOT EXPORT PUBLICLY\n * @internal\n */\nexport const DEFAULT_OPTIONS: ReactFlagEvaluationOptions = {\n updateOnContextChanged: true,\n updateOnConfigurationChanged: true,\n suspendUntilReady: false,\n suspendWhileReconciling: false,\n};\n\n/**\n * Returns normalization options (all `undefined` fields removed, and `suspend` decomposed to `suspendUntilReady` and `suspendWhileReconciling`).\n * DO NOT EXPORT PUBLICLY\n * @internal\n * @param {ReactFlagEvaluationOptions} options options to normalize\n * @returns {NormalizedOptions} normalized options\n */\nexport const normalizeOptions: (options?: ReactFlagEvaluationOptions) => NormalizedOptions = (options: ReactFlagEvaluationOptions = {}) => {\n const updateOnContextChanged = options.updateOnContextChanged;\n const updateOnConfigurationChanged = options.updateOnConfigurationChanged;\n\n // fall-back the suspense options to the catch-all `suspend` property \n const suspendUntilReady = 'suspendUntilReady' in options ? options.suspendUntilReady : options.suspend;\n const suspendWhileReconciling = 'suspendWhileReconciling' in options ? options.suspendWhileReconciling : options.suspend;\n\n return {\n // only return these if properly set (no undefined to allow overriding with spread)\n ...(typeof suspendUntilReady === 'boolean' && {suspendUntilReady}),\n ...(typeof suspendWhileReconciling === 'boolean' && {suspendWhileReconciling}),\n ...(typeof updateOnContextChanged === 'boolean' && {updateOnContextChanged}),\n ...(typeof updateOnConfigurationChanged === 'boolean' && {updateOnConfigurationChanged}),\n };\n};\n", "import { Client, ProviderEvents } from '@openfeature/web-sdk';\n\n/**\n * Suspends until the client is ready to evaluate feature flags.\n * DO NOT EXPORT PUBLICLY\n * @param {Client} client OpenFeature client\n */\nexport function suspendUntilReady(client: Client): Promise<void> {\n let resolve: (value: unknown) => void;\n let reject: () => void;\n throw new Promise((_resolve, _reject) => {\n resolve = _resolve;\n reject = _reject;\n client.addHandler(ProviderEvents.Ready, resolve);\n client.addHandler(ProviderEvents.Error, reject);\n }).finally(() => {\n client.removeHandler(ProviderEvents.Ready, resolve);\n client.removeHandler(ProviderEvents.Ready, reject);\n });\n}\n", "import { Client } from '@openfeature/web-sdk';\nimport React from 'react';\nimport { NormalizedOptions, ReactFlagEvaluationOptions, normalizeOptions } from '../common/options';\n\n/**\n * The underlying React context.\n * DO NOT EXPORT PUBLICLY\n * @internal\n */\nexport const Context = React.createContext<{ client: Client; options: ReactFlagEvaluationOptions } | undefined>(undefined);\n\n/**\n * Get a normalized copy of the options used for this OpenFeatureProvider, see {@link normalizeOptions}.\n * DO NOT EXPORT PUBLICLY\n * @internal\n * @returns {NormalizedOptions} normalized options the defaulted options, not defaulted or normalized.\n */\nexport function useProviderOptions(): NormalizedOptions {\n const { options } = React.useContext(Context) || {};\n return normalizeOptions(options);\n}\n", "import React from 'react';\nimport { Context } from './context';\nimport { Client } from '@openfeature/web-sdk';\n\n/**\n * Get the {@link Client} instance for this OpenFeatureProvider context.\n * Note that the provider to which this is bound is determined by the OpenFeatureProvider's domain.\n * @returns {Client} client for this scope\n */\nexport function useOpenFeatureClient(): Client {\n const { client } = React.useContext(Context) || {};\n\n if (!client) {\n throw new Error(\n 'No OpenFeature client available - components using OpenFeature must be wrapped with an <OpenFeatureProvider>. If you are seeing this in a test, see: https://openfeature.dev/docs/reference/technologies/client/web/react#testing',\n );\n }\n\n return client;\n}\n", "import { useEffect, useState } from 'react';\nimport { useOpenFeatureClient } from './use-open-feature-client';\nimport { ProviderEvents, ProviderStatus } from '@openfeature/web-sdk';\n\n/**\n * Get the {@link ProviderStatus} for the OpenFeatureClient.\n * @returns {ProviderStatus} status of the client for this scope\n */\nexport function useOpenFeatureClientStatus(): ProviderStatus {\n const client = useOpenFeatureClient();\n const [status, setStatus] = useState(client.providerStatus);\n\n useEffect(() => {\n const updateStatus = () => setStatus(client.providerStatus);\n client.addHandler(ProviderEvents.ConfigurationChanged, updateStatus);\n client.addHandler(ProviderEvents.ContextChanged, updateStatus);\n client.addHandler(ProviderEvents.Error, updateStatus);\n client.addHandler(ProviderEvents.Ready, updateStatus);\n client.addHandler(ProviderEvents.Stale, updateStatus);\n client.addHandler(ProviderEvents.Reconciling, updateStatus);\n return () => {\n client.removeHandler(ProviderEvents.ConfigurationChanged, updateStatus);\n client.removeHandler(ProviderEvents.ContextChanged, updateStatus);\n client.removeHandler(ProviderEvents.Error, updateStatus);\n client.removeHandler(ProviderEvents.Ready, updateStatus);\n client.removeHandler(ProviderEvents.Stale, updateStatus);\n client.removeHandler(ProviderEvents.Reconciling, updateStatus);\n };\n }, [client]);\n\n return status;\n}\n", "import {\n EvaluationDetails,\n FlagValue,\n StandardResolutionReasons\n} from '@openfeature/web-sdk';\nimport { FlagQuery } from '../query';\n\n\n// FlagQuery implementation, do not export\nexport class HookFlagQuery<T extends FlagValue = FlagValue> implements FlagQuery {\n constructor(private _details: EvaluationDetails<T>) {}\n\n get details() {\n return this._details;\n }\n\n get value() {\n return this._details?.value;\n }\n\n get variant() {\n return this._details.variant;\n }\n\n get flagMetadata() {\n return this._details.flagMetadata;\n }\n\n get reason() {\n return this._details.reason;\n }\n\n get isError() {\n return !!this._details?.errorCode || this._details.reason == StandardResolutionReasons.ERROR;\n }\n\n get errorCode() {\n return this._details?.errorCode;\n }\n\n get errorMessage() {\n return this._details?.errorMessage;\n }\n\n get isAuthoritative() {\n return (\n !this.isError &&\n this._details.reason != StandardResolutionReasons.STALE &&\n this._details.reason != StandardResolutionReasons.DISABLED\n );\n }\n\n get type() {\n return typeof this._details.value;\n }\n}\n", "import { Client, OpenFeature } from '@openfeature/web-sdk';\nimport * as React from 'react';\nimport { ReactFlagEvaluationOptions } from '../common/options';\nimport { Context } from './context';\n\ntype ClientOrDomain =\n | {\n /**\n * An identifier which logically binds clients with providers\n * @see OpenFeature.setProvider() and overloads.\n */\n domain?: string;\n client?: never;\n }\n | {\n /**\n * OpenFeature client to use.\n */\n client?: Client;\n domain?: never;\n };\n\ntype ProviderProps = {\n children?: React.ReactNode;\n} & ClientOrDomain &\n ReactFlagEvaluationOptions;\n\n /**\n * Provides a scope for evaluating feature flags by binding a client to all child components.\n * @param {ProviderProps} properties props for the context provider\n * @returns {OpenFeatureProvider} context provider\n */\nexport function OpenFeatureProvider({ client, domain, children, ...options }: ProviderProps) {\n if (!client) {\n client = OpenFeature.getClient(domain);\n }\n\n return <Context.Provider value={{ client, options }}>{children}</Context.Provider>;\n}\n", "import { ProviderStatus } from '@openfeature/web-sdk';\nimport { DEFAULT_OPTIONS, ReactFlagEvaluationOptions, normalizeOptions } from '../common/options';\nimport { useProviderOptions } from './context';\nimport { useOpenFeatureClient } from './use-open-feature-client';\nimport { useOpenFeatureClientStatus } from './use-open-feature-client-status';\nimport { suspendUntilReady } from '../common/suspense';\n\ntype Options = Pick<ReactFlagEvaluationOptions, 'suspendUntilReady'>;\n\n/**\n * Utility hook that triggers suspense until the provider is {@link ProviderStatus.READY}, without evaluating any flags.\n * Especially useful for React v16/17 \"Legacy Suspense\", in which siblings to suspending components are\n * initially mounted and then hidden (see: https://github.com/reactwg/react-18/discussions/7).\n * @param {Options} options options for suspense\n * @returns {boolean} boolean indicating if provider is {@link ProviderStatus.READY}, useful if suspense is disabled and you want to handle loaders on your own\n */\nexport function useWhenProviderReady(options?: Options): boolean {\n const client = useOpenFeatureClient();\n const status = useOpenFeatureClientStatus();\n // highest priority > evaluation hook options > provider options > default options > lowest priority\n const defaultedOptions = { ...DEFAULT_OPTIONS, ...useProviderOptions(), ...normalizeOptions(options) };\n\n // suspense\n if (defaultedOptions.suspendUntilReady && status === ProviderStatus.NOT_READY) {\n suspendUntilReady(client);\n }\n\n return status === ProviderStatus.READY;\n}\n", "import {\n EvaluationContext,\n InMemoryProvider,\n JsonValue,\n NOOP_PROVIDER,\n OpenFeature,\n Provider,\n} from '@openfeature/web-sdk';\nimport React from 'react';\nimport { NormalizedOptions } from '../common/options';\nimport { OpenFeatureProvider } from './provider';\n\ntype FlagValueMap = { [flagKey: string]: JsonValue };\ntype FlagConfig = ConstructorParameters<typeof InMemoryProvider>[0];\ntype TestProviderProps = Omit<React.ComponentProps<typeof OpenFeatureProvider>, 'client'> &\n (\n | {\n provider?: never;\n /**\n * Optional map of flagKeys to flagValues for this OpenFeatureTestProvider context.\n * If not supplied, all flag evaluations will default.\n */\n flagValueMap?: FlagValueMap;\n /**\n * Optional delay for the underlying test provider's readiness and reconciliation.\n * Defaults to 0.\n */\n delayMs?: number;\n }\n | {\n /**\n * An optional partial provider to pass for full control over the flag resolution for this OpenFeatureTestProvider context.\n * Any un-implemented methods or properties will no-op.\n */\n provider?: Partial<Provider>;\n flagValueMap?: never;\n delayMs?: never;\n }\n );\n\n const TEST_VARIANT = 'test-variant';\n const TEST_PROVIDER = 'test-provider';\n\n// internal provider which is basically the in-memory provider with a simpler config and some optional fake delays\nclass TestProvider extends InMemoryProvider {\n constructor(\n flagValueMap: FlagValueMap,\n private delay = 0,\n ) {\n // convert the simple flagValueMap into an in-memory config\n const flagConfig = Object.entries(flagValueMap).reduce((acc: FlagConfig, flag): FlagConfig => {\n return {\n ...acc,\n [flag[0]]: {\n variants: {\n [TEST_VARIANT]: flag[1],\n },\n defaultVariant: TEST_VARIANT,\n disabled: false,\n },\n };\n }, {});\n super(flagConfig);\n }\n\n async initialize(context?: EvaluationContext | undefined): Promise<void> {\n await Promise.all([super.initialize(context), new Promise<void>((resolve) => setTimeout(resolve, this.delay))]);\n }\n\n async onContextChange() {\n return new Promise<void>((resolve) => setTimeout(resolve, this.delay));\n }\n}\n\n/**\n * A React Context provider based on the {@link InMemoryProvider}, specifically built for testing.\n * Use this for testing components that use flag evaluation hooks.\n * @param {TestProviderProps} testProviderOptions options for the OpenFeatureTestProvider\n * @returns {OpenFeatureProvider} OpenFeatureTestProvider\n */\nexport function OpenFeatureTestProvider(testProviderOptions: TestProviderProps) {\n const { flagValueMap, provider } = testProviderOptions;\n const effectiveProvider = (\n flagValueMap ? new TestProvider(flagValueMap, testProviderOptions.delayMs) : mixInNoop(provider) || NOOP_PROVIDER\n ) as Provider;\n testProviderOptions.domain\n ? OpenFeature.setProvider(testProviderOptions.domain, effectiveProvider)\n : OpenFeature.setProvider(effectiveProvider);\n\n return (\n <OpenFeatureProvider {...(testProviderOptions as NormalizedOptions)} domain={testProviderOptions.domain}>\n {testProviderOptions.children}\n </OpenFeatureProvider>\n );\n}\n\n// mix in the no-op provider when the partial is passed\nfunction mixInNoop(provider: Partial<Provider> = {}) {\n // fill in any missing methods with no-ops\n for (const prop of Object.getOwnPropertyNames(Object.getPrototypeOf(NOOP_PROVIDER)).filter(prop => prop !== 'constructor')) {\n const patchedProvider = provider as {[key: string]: keyof Provider};\n if (!Object.getPrototypeOf(patchedProvider)[prop] && !patchedProvider[prop]) {\n patchedProvider[prop] = Object.getPrototypeOf(NOOP_PROVIDER)[prop];\n }\n }\n // fill in the metadata if missing\n if (!provider.metadata || !provider.metadata.name) {\n (provider.metadata as unknown) = { name: TEST_PROVIDER };\n }\n return provider;\n}", "export * from './evaluation';\nexport * from './query';\nexport * from './provider';\n// re-export the web-sdk so consumers can access that API from the react-sdk\nexport * from '@openfeature/web-sdk';\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,EAME,kBAAAA;AAAA,EACA,kBAAAC;AAAA,OACK;AACP,SAAS,aAAAC,YAAW,YAAAC,iBAAgB;;;AC4C7B,IAAM,kBAA8C;AAAA,EACzD,wBAAwB;AAAA,EACxB,8BAA8B;AAAA,EAC9B,mBAAmB;AAAA,EACnB,yBAAyB;AAC3B;AASO,IAAM,mBAAgF,CAAC,UAAsC,CAAC,MAAM;AACzI,QAAM,yBAAyB,QAAQ;AACvC,QAAM,+BAA+B,QAAQ;AAG7C,QAAMC,qBAAoB,uBAAuB,UAAU,QAAQ,oBAAoB,QAAQ;AAC/F,QAAM,0BAA0B,6BAA6B,UAAU,QAAQ,0BAA0B,QAAQ;AAEjH,SAAO,gEAED,OAAOA,uBAAsB,aAAa,EAAC,mBAAAA,mBAAiB,IAC5D,OAAO,4BAA4B,aAAa,EAAC,wBAAuB,IACxE,OAAO,2BAA2B,aAAa,EAAC,uBAAsB,IACtE,OAAO,iCAAiC,aAAa,EAAC,6BAA4B;AAE1F;;;AClFA,SAAiB,sBAAsB;AAOhC,SAAS,kBAAkB,QAA+B;AAC/D,MAAI;AACJ,MAAI;AACJ,QAAM,IAAI,QAAQ,CAAC,UAAU,YAAY;AACvC,cAAU;AACV,aAAS;AACT,WAAO,WAAW,eAAe,OAAO,OAAO;AAC/C,WAAO,WAAW,eAAe,OAAO,MAAM;AAAA,EAChD,CAAC,EAAE,QAAQ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M,oBACJ,eAAe,IAAI,aAAa,cAAc,oBAAoB,OAAO,IAAI,UAAU,QAAQ,KAAK;AAEtG,sBAAoB,SAChBC,aAAY,YAAY,oBAAoB,QAAQ,iBAAiB,IACrEA,aAAY,YAAY,iBAAiB;AAE7C,SACE,gBAAAC,OAAA,cAAC,sDAAyB,sBAAzB,EAAoE,QAAQ,oBAAoB,WAC9F,oBAAoB,QACvB;AAEJ;AAGA,SAAS,UAAU,WAA8B,CAAC,GAAG;AAEnD,aAAW,QAAQ,OAAO,oBAAoB,OAAO,eAAe,aAAa,CAAC,EAAE,OAAO,CAAAC,UAAQA,UAAS,aAAa,GAAG;AAC1H,UAAM,kBAAkB;AACxB,QAAI,CAAC,OAAO,eAAe,eAAe,EAAE,IAAI,KAAK,CAAC,gBAAgB,IAAI,GAAG;AAC3E,sBAAgB,IAAI,IAAI,OAAO,eAAe,aAAa,EAAE,IAAI;AAAA,IACnE;AAAA,EACF;AAEA,MAAI,CAAC,SAAS,YAAY,CAAC,SAAS,SAAS,MAAM;AACjD,IAAC,SAAS,WAAuB,EAAE,MAAM,cAAc;AAAA,EACzD;AACA,SAAO;AACT;;;AC1GA,cAAc;",
4
+ "sourcesContent": ["import {\n Client,\n EvaluationDetails,\n FlagEvaluationOptions,\n FlagValue,\n JsonValue,\n ProviderEvents,\n ProviderStatus,\n} from '@openfeature/web-sdk';\nimport { useEffect, useState } from 'react';\nimport { DEFAULT_OPTIONS, ReactFlagEvaluationOptions, normalizeOptions } from '../common/options';\nimport { suspendUntilReady } from '../common/suspense';\nimport { useProviderOptions } from '../provider/context';\nimport { useOpenFeatureClient } from '../provider/use-open-feature-client';\nimport { useOpenFeatureClientStatus } from '../provider/use-open-feature-client-status';\nimport { FlagQuery } from '../query';\nimport { HookFlagQuery } from './hook-flag-query';\n\n// This type is a bit wild-looking, but I think we need it.\n// We have to use the conditional, because otherwise useFlag('key', false) would return false, not boolean (too constrained).\n// We have a duplicate for the hook return below, this one is just used for casting because the name isn't as clear\ntype ConstrainedFlagQuery<T> = FlagQuery<\n T extends boolean\n ? boolean\n : T extends number\n ? number\n : T extends string\n ? string\n : T extends JsonValue\n ? T\n : JsonValue\n>;\n\n// suspense options removed for the useSuspenseFlag hooks\ntype NoSuspenseOptions = Omit<ReactFlagEvaluationOptions, 'suspend' | 'suspendUntilReady' | 'suspendWhileReconciling'>\n\n/**\n * Evaluates a feature flag generically, returning an react-flavored queryable object.\n * The resolver method to use is based on the type of the defaultValue.\n * For type-specific hooks, use {@link useBooleanFlagValue}, {@link useBooleanFlagDetails} and equivalents.\n * By default, components will re-render when the flag value changes.\n * @param {string} flagKey the flag identifier\n * @template {FlagValue} T A optional generic argument constraining the default.\n * @param {T} defaultValue the default value; used to determine what resolved type should be used.\n * @param {ReactFlagEvaluationOptions} options for this evaluation\n * @returns { FlagQuery } a queryable object containing useful information about the flag.\n */\nexport function useFlag<T extends FlagValue = FlagValue>(\n flagKey: string,\n defaultValue: T,\n options?: ReactFlagEvaluationOptions,\n): FlagQuery<\nT extends boolean\n ? boolean\n : T extends number\n ? number\n : T extends string\n ? string\n : T extends JsonValue\n ? T\n : JsonValue\n> {\n // use the default value to determine the resolver to call\n const query =\n typeof defaultValue === 'boolean'\n ? new HookFlagQuery<boolean>(useBooleanFlagDetails(flagKey, defaultValue, options))\n : typeof defaultValue === 'number'\n ? new HookFlagQuery<number>(useNumberFlagDetails(flagKey, defaultValue, options))\n : typeof defaultValue === 'string'\n ? new HookFlagQuery<string>(useStringFlagDetails(flagKey, defaultValue, options))\n : new HookFlagQuery<JsonValue>(useObjectFlagDetails(flagKey, defaultValue, options));\n // TS sees this as HookFlagQuery<JsonValue>, because the compiler isn't aware of the `typeof` checks above.\n return query as unknown as ConstrainedFlagQuery<T>;\n}\n\n// alias to the return value of useFlag, used to keep useSuspenseFlag consistent\ntype UseFlagReturn<T extends FlagValue> = ReturnType<typeof useFlag<T>>\n\n/**\n * Equivalent to {@link useFlag} with `options: { suspend: true }`\n * @experimental Suspense is an experimental feature subject to change in future versions.\n * @param {string} flagKey the flag identifier\n * @template {FlagValue} T A optional generic argument constraining the default.\n * @param {T} defaultValue the default value; used to determine what resolved type should be used.\n * @param {NoSuspenseOptions} options for this evaluation\n * @returns { UseFlagReturn<T> } a queryable object containing useful information about the flag.\n */\nexport function useSuspenseFlag<T extends FlagValue = FlagValue>(\n flagKey: string,\n defaultValue: T,\n options?: NoSuspenseOptions,\n): UseFlagReturn<T> {\n return useFlag(flagKey, defaultValue, { ...options, suspendUntilReady: true, suspendWhileReconciling: true });\n}\n\n/**\n * Evaluates a feature flag, returning a boolean.\n * By default, components will re-render when the flag value changes.\n * For a generic hook returning a queryable interface, see {@link useFlag}.\n * @param {string} flagKey the flag identifier\n * @param {boolean} defaultValue the default value\n * @param {ReactFlagEvaluationOptions} options options for this evaluation\n * @returns { boolean} a EvaluationDetails object for this evaluation\n */\nexport function useBooleanFlagValue(\n flagKey: string,\n defaultValue: boolean,\n options?: ReactFlagEvaluationOptions,\n): boolean {\n return useBooleanFlagDetails(flagKey, defaultValue, options).value;\n}\n\n/**\n * Evaluates a feature flag, returning evaluation details.\n * By default, components will re-render when the flag value changes.\n * For a generic hook returning a queryable interface, see {@link useFlag}.\n * @param {string} flagKey the flag identifier\n * @param {boolean} defaultValue the default value\n * @param {ReactFlagEvaluationOptions} options options for this evaluation\n * @returns { EvaluationDetails<boolean>} a EvaluationDetails object for this evaluation\n */\nexport function useBooleanFlagDetails(\n flagKey: string,\n defaultValue: boolean,\n options?: ReactFlagEvaluationOptions,\n): EvaluationDetails<boolean> {\n return attachHandlersAndResolve(\n flagKey,\n defaultValue,\n (client) => {\n return client.getBooleanDetails;\n },\n options,\n );\n}\n\n/**\n * Evaluates a feature flag, returning a string.\n * By default, components will re-render when the flag value changes.\n * For a generic hook returning a queryable interface, see {@link useFlag}.\n * @param {string} flagKey the flag identifier\n * @template {string} [T=string] A optional generic argument constraining the string\n * @param {T} defaultValue the default value\n * @param {ReactFlagEvaluationOptions} options options for this evaluation\n * @returns { boolean} a EvaluationDetails object for this evaluation\n */\nexport function useStringFlagValue<T extends string = string>(\n flagKey: string,\n defaultValue: T,\n options?: ReactFlagEvaluationOptions,\n): string {\n return useStringFlagDetails(flagKey, defaultValue, options).value;\n}\n\n/**\n * Evaluates a feature flag, returning evaluation details.\n * By default, components will re-render when the flag value changes.\n * For a generic hook returning a queryable interface, see {@link useFlag}.\n * @param {string} flagKey the flag identifier\n * @template {string} [T=string] A optional generic argument constraining the string\n * @param {T} defaultValue the default value\n * @param {ReactFlagEvaluationOptions} options options for this evaluation\n * @returns { EvaluationDetails<string>} a EvaluationDetails object for this evaluation\n */\nexport function useStringFlagDetails<T extends string = string>(\n flagKey: string,\n defaultValue: T,\n options?: ReactFlagEvaluationOptions,\n): EvaluationDetails<string> {\n return attachHandlersAndResolve(\n flagKey,\n defaultValue,\n (client) => {\n return client.getStringDetails<T>;\n },\n options,\n );\n}\n\n/**\n * Evaluates a feature flag, returning a number.\n * By default, components will re-render when the flag value changes.\n * For a generic hook returning a queryable interface, see {@link useFlag}.\n * @param {string} flagKey the flag identifier\n * @template {number} [T=number] A optional generic argument constraining the number\n * @param {T} defaultValue the default value\n * @param {ReactFlagEvaluationOptions} options options for this evaluation\n * @returns { boolean} a EvaluationDetails object for this evaluation\n */\nexport function useNumberFlagValue<T extends number = number>(\n flagKey: string,\n defaultValue: T,\n options?: ReactFlagEvaluationOptions,\n): number {\n return useNumberFlagDetails(flagKey, defaultValue, options).value;\n}\n\n/**\n * Evaluates a feature flag, returning evaluation details.\n * By default, components will re-render when the flag value changes.\n * For a generic hook returning a queryable interface, see {@link useFlag}.\n * @param {string} flagKey the flag identifier\n * @template {number} [T=number] A optional generic argument constraining the number\n * @param {T} defaultValue the default value\n * @param {ReactFlagEvaluationOptions} options options for this evaluation\n * @returns { EvaluationDetails<number>} a EvaluationDetails object for this evaluation\n */\nexport function useNumberFlagDetails<T extends number = number>(\n flagKey: string,\n defaultValue: T,\n options?: ReactFlagEvaluationOptions,\n): EvaluationDetails<number> {\n return attachHandlersAndResolve(\n flagKey,\n defaultValue,\n (client) => {\n return client.getNumberDetails<T>;\n },\n options,\n );\n}\n\n/**\n * Evaluates a feature flag, returning an object.\n * By default, components will re-render when the flag value changes.\n * For a generic hook returning a queryable interface, see {@link useFlag}.\n * @param {string} flagKey the flag identifier\n * @template {JsonValue} [T=JsonValue] A optional generic argument describing the structure\n * @param {T} defaultValue the default value\n * @param {ReactFlagEvaluationOptions} options options for this evaluation\n * @returns { boolean} a EvaluationDetails object for this evaluation\n */\nexport function useObjectFlagValue<T extends JsonValue = JsonValue>(\n flagKey: string,\n defaultValue: T,\n options?: ReactFlagEvaluationOptions,\n): T {\n return useObjectFlagDetails<T>(flagKey, defaultValue, options).value;\n}\n\n/**\n * Evaluates a feature flag, returning evaluation details.\n * By default, components will re-render when the flag value changes.\n * For a generic hook returning a queryable interface, see {@link useFlag}.\n * @param {string} flagKey the flag identifier\n * @param {T} defaultValue the default value\n * @template {JsonValue} [T=JsonValue] A optional generic argument describing the structure\n * @param {ReactFlagEvaluationOptions} options options for this evaluation\n * @returns { EvaluationDetails<T>} a EvaluationDetails object for this evaluation\n */\nexport function useObjectFlagDetails<T extends JsonValue = JsonValue>(\n flagKey: string,\n defaultValue: T,\n options?: ReactFlagEvaluationOptions,\n): EvaluationDetails<T> {\n return attachHandlersAndResolve(\n flagKey,\n defaultValue,\n (client) => {\n return client.getObjectDetails<T>;\n },\n options,\n );\n}\n\nfunction attachHandlersAndResolve<T extends FlagValue>(\n flagKey: string,\n defaultValue: T,\n resolver: (client: Client) => (flagKey: string, defaultValue: T, options?: FlagEvaluationOptions) => EvaluationDetails<T>,\n options?: ReactFlagEvaluationOptions,\n): EvaluationDetails<T> {\n // highest priority > evaluation hook options > provider options > default options > lowest priority\n const defaultedOptions = { ...DEFAULT_OPTIONS, ...useProviderOptions(), ...normalizeOptions(options) };\n const client = useOpenFeatureClient();\n const status = useOpenFeatureClientStatus();\n\n // suspense\n if (defaultedOptions.suspendUntilReady && status === ProviderStatus.NOT_READY) {\n suspendUntilReady(client);\n }\n\n if (defaultedOptions.suspendWhileReconciling && status === ProviderStatus.RECONCILING) {\n suspendUntilReady(client);\n }\n\n const [evalutationDetails, setEvaluationDetails] = useState<EvaluationDetails<T>>(\n resolver(client).call(client, flagKey, defaultValue, options),\n );\n\n const updateEvaluationDetailsRef = () => {\n setEvaluationDetails(resolver(client).call(client, flagKey, defaultValue, options));\n };\n\n useEffect(() => {\n if (status === ProviderStatus.NOT_READY) {\n // update when the provider is ready\n client.addHandler(ProviderEvents.Ready, updateEvaluationDetailsRef);\n }\n\n if (defaultedOptions.updateOnContextChanged) {\n // update when the context changes\n client.addHandler(ProviderEvents.ContextChanged, updateEvaluationDetailsRef);\n }\n return () => {\n // cleanup the handlers\n client.removeHandler(ProviderEvents.Ready, updateEvaluationDetailsRef);\n client.removeHandler(ProviderEvents.ContextChanged, updateEvaluationDetailsRef);\n };\n }, []);\n\n useEffect(() => {\n if (defaultedOptions.updateOnConfigurationChanged) {\n // update when the provider configuration changes\n client.addHandler(ProviderEvents.ConfigurationChanged, updateEvaluationDetailsRef);\n }\n return () => {\n // cleanup the handlers\n client.removeHandler(ProviderEvents.ConfigurationChanged, updateEvaluationDetailsRef);\n };\n }, []);\n\n return evalutationDetails;\n}\n", "import { FlagEvaluationOptions } from '@openfeature/web-sdk';\n\nexport type ReactFlagEvaluationOptions = ({\n /**\n * Enable or disable all suspense functionality.\n * Cannot be used in conjunction with `suspendUntilReady` and `suspendWhileReconciling` options.\n * @experimental Suspense is an experimental feature subject to change in future versions.\n */\n suspend?: boolean;\n suspendUntilReady?: never;\n suspendWhileReconciling?: never;\n} | {\n /**\n * Suspend flag evaluations while the provider is not ready.\n * Set to false if you don't want to show suspense fallbacks until the provider is initialized.\n * Defaults to false.\n * Cannot be used in conjunction with `suspend` option.\n * @experimental Suspense is an experimental feature subject to change in future versions.\n */\n suspendUntilReady?: boolean;\n /**\n * Suspend flag evaluations while the provider's context is being reconciled.\n * Set to true if you want to show suspense fallbacks while flags are re-evaluated after context changes.\n * Defaults to false.\n * Cannot be used in conjunction with `suspend` option.\n * @experimental Suspense is an experimental feature subject to change in future versions.\n */\n suspendWhileReconciling?: boolean;\n suspend?: never;\n}) & {\n /**\n * Update the component if the provider emits a ConfigurationChanged event.\n * Set to false to prevent components from re-rendering when flag value changes\n * are received by the associated provider.\n * Defaults to true.\n */\n updateOnConfigurationChanged?: boolean;\n /**\n * Update the component when the OpenFeature context changes.\n * Set to false to prevent components from re-rendering when attributes which\n * may be factors in flag evaluation change.\n * Defaults to true.\n */\n updateOnContextChanged?: boolean;\n} & FlagEvaluationOptions;\n\nexport type NormalizedOptions = Omit<ReactFlagEvaluationOptions, 'suspend'>;\n\n/**\n * Default options.\n * DO NOT EXPORT PUBLICLY\n * @internal\n */\nexport const DEFAULT_OPTIONS: ReactFlagEvaluationOptions = {\n updateOnContextChanged: true,\n updateOnConfigurationChanged: true,\n suspendUntilReady: false,\n suspendWhileReconciling: false,\n};\n\n/**\n * Returns normalization options (all `undefined` fields removed, and `suspend` decomposed to `suspendUntilReady` and `suspendWhileReconciling`).\n * DO NOT EXPORT PUBLICLY\n * @internal\n * @param {ReactFlagEvaluationOptions} options options to normalize\n * @returns {NormalizedOptions} normalized options\n */\nexport const normalizeOptions: (options?: ReactFlagEvaluationOptions) => NormalizedOptions = (options: ReactFlagEvaluationOptions = {}) => {\n const updateOnContextChanged = options.updateOnContextChanged;\n const updateOnConfigurationChanged = options.updateOnConfigurationChanged;\n\n // fall-back the suspense options to the catch-all `suspend` property \n const suspendUntilReady = 'suspendUntilReady' in options ? options.suspendUntilReady : options.suspend;\n const suspendWhileReconciling = 'suspendWhileReconciling' in options ? options.suspendWhileReconciling : options.suspend;\n\n return {\n // only return these if properly set (no undefined to allow overriding with spread)\n ...(typeof suspendUntilReady === 'boolean' && {suspendUntilReady}),\n ...(typeof suspendWhileReconciling === 'boolean' && {suspendWhileReconciling}),\n ...(typeof updateOnContextChanged === 'boolean' && {updateOnContextChanged}),\n ...(typeof updateOnConfigurationChanged === 'boolean' && {updateOnConfigurationChanged}),\n };\n};\n", "import { Client, ProviderEvents } from '@openfeature/web-sdk';\n\n/**\n * Suspends until the client is ready to evaluate feature flags.\n * DO NOT EXPORT PUBLICLY\n * @param {Client} client OpenFeature client\n */\nexport function suspendUntilReady(client: Client): Promise<void> {\n let resolve: (value: unknown) => void;\n let reject: () => void;\n throw new Promise((_resolve, _reject) => {\n resolve = _resolve;\n reject = _reject;\n client.addHandler(ProviderEvents.Ready, resolve);\n client.addHandler(ProviderEvents.Error, reject);\n }).finally(() => {\n client.removeHandler(ProviderEvents.Ready, resolve);\n client.removeHandler(ProviderEvents.Ready, reject);\n });\n}\n", "import { Client } from '@openfeature/web-sdk';\nimport React from 'react';\nimport { NormalizedOptions, ReactFlagEvaluationOptions, normalizeOptions } from '../common/options';\n\n/**\n * The underlying React context.\n * DO NOT EXPORT PUBLICLY\n * @internal\n */\nexport const Context = React.createContext<{ client: Client; options: ReactFlagEvaluationOptions } | undefined>(undefined);\n\n/**\n * Get a normalized copy of the options used for this OpenFeatureProvider, see {@link normalizeOptions}.\n * DO NOT EXPORT PUBLICLY\n * @internal\n * @returns {NormalizedOptions} normalized options the defaulted options, not defaulted or normalized.\n */\nexport function useProviderOptions(): NormalizedOptions {\n const { options } = React.useContext(Context) || {};\n return normalizeOptions(options);\n}\n", "import React from 'react';\nimport { Context } from './context';\nimport { Client } from '@openfeature/web-sdk';\n\n/**\n * Get the {@link Client} instance for this OpenFeatureProvider context.\n * Note that the provider to which this is bound is determined by the OpenFeatureProvider's domain.\n * @returns {Client} client for this scope\n */\nexport function useOpenFeatureClient(): Client {\n const { client } = React.useContext(Context) || {};\n\n if (!client) {\n throw new Error(\n 'No OpenFeature client available - components using OpenFeature must be wrapped with an <OpenFeatureProvider>. If you are seeing this in a test, see: https://openfeature.dev/docs/reference/technologies/client/web/react#testing',\n );\n }\n\n return client;\n}\n", "import { useEffect, useState } from 'react';\nimport { useOpenFeatureClient } from './use-open-feature-client';\nimport { ProviderEvents, ProviderStatus } from '@openfeature/web-sdk';\n\n/**\n * Get the {@link ProviderStatus} for the OpenFeatureClient.\n * @returns {ProviderStatus} status of the client for this scope\n */\nexport function useOpenFeatureClientStatus(): ProviderStatus {\n const client = useOpenFeatureClient();\n const [status, setStatus] = useState(client.providerStatus);\n\n useEffect(() => {\n const updateStatus = () => setStatus(client.providerStatus);\n client.addHandler(ProviderEvents.ConfigurationChanged, updateStatus);\n client.addHandler(ProviderEvents.ContextChanged, updateStatus);\n client.addHandler(ProviderEvents.Error, updateStatus);\n client.addHandler(ProviderEvents.Ready, updateStatus);\n client.addHandler(ProviderEvents.Stale, updateStatus);\n client.addHandler(ProviderEvents.Reconciling, updateStatus);\n return () => {\n client.removeHandler(ProviderEvents.ConfigurationChanged, updateStatus);\n client.removeHandler(ProviderEvents.ContextChanged, updateStatus);\n client.removeHandler(ProviderEvents.Error, updateStatus);\n client.removeHandler(ProviderEvents.Ready, updateStatus);\n client.removeHandler(ProviderEvents.Stale, updateStatus);\n client.removeHandler(ProviderEvents.Reconciling, updateStatus);\n };\n }, [client]);\n\n return status;\n}\n", "import {\n EvaluationDetails,\n FlagValue,\n StandardResolutionReasons\n} from '@openfeature/web-sdk';\nimport { FlagQuery } from '../query';\n\n\n// FlagQuery implementation, do not export\nexport class HookFlagQuery<T extends FlagValue = FlagValue> implements FlagQuery {\n constructor(private _details: EvaluationDetails<T>) {}\n\n get details() {\n return this._details;\n }\n\n get value() {\n return this._details?.value;\n }\n\n get variant() {\n return this._details.variant;\n }\n\n get flagMetadata() {\n return this._details.flagMetadata;\n }\n\n get reason() {\n return this._details.reason;\n }\n\n get isError() {\n return !!this._details?.errorCode || this._details.reason == StandardResolutionReasons.ERROR;\n }\n\n get errorCode() {\n return this._details?.errorCode;\n }\n\n get errorMessage() {\n return this._details?.errorMessage;\n }\n\n get isAuthoritative() {\n return (\n !this.isError &&\n this._details.reason != StandardResolutionReasons.STALE &&\n this._details.reason != StandardResolutionReasons.DISABLED\n );\n }\n\n get type() {\n return typeof this._details.value;\n }\n}\n", "import { Client, OpenFeature } from '@openfeature/web-sdk';\nimport * as React from 'react';\nimport { ReactFlagEvaluationOptions } from '../common/options';\nimport { Context } from './context';\n\ntype ClientOrDomain =\n | {\n /**\n * An identifier which logically binds clients with providers\n * @see OpenFeature.setProvider() and overloads.\n */\n domain?: string;\n client?: never;\n }\n | {\n /**\n * OpenFeature client to use.\n */\n client?: Client;\n domain?: never;\n };\n\ntype ProviderProps = {\n children?: React.ReactNode;\n} & ClientOrDomain &\n ReactFlagEvaluationOptions;\n\n /**\n * Provides a scope for evaluating feature flags by binding a client to all child components.\n * @param {ProviderProps} properties props for the context provider\n * @returns {OpenFeatureProvider} context provider\n */\nexport function OpenFeatureProvider({ client, domain, children, ...options }: ProviderProps) {\n if (!client) {\n client = OpenFeature.getClient(domain);\n }\n\n return <Context.Provider value={{ client, options }}>{children}</Context.Provider>;\n}\n", "import { ProviderStatus } from '@openfeature/web-sdk';\nimport { DEFAULT_OPTIONS, ReactFlagEvaluationOptions, normalizeOptions } from '../common/options';\nimport { useProviderOptions } from './context';\nimport { useOpenFeatureClient } from './use-open-feature-client';\nimport { useOpenFeatureClientStatus } from './use-open-feature-client-status';\nimport { suspendUntilReady } from '../common/suspense';\n\ntype Options = Pick<ReactFlagEvaluationOptions, 'suspendUntilReady'>;\n\n/**\n * Utility hook that triggers suspense until the provider is {@link ProviderStatus.READY}, without evaluating any flags.\n * Especially useful for React v16/17 \"Legacy Suspense\", in which siblings to suspending components are\n * initially mounted and then hidden (see: https://github.com/reactwg/react-18/discussions/7).\n * @param {Options} options options for suspense\n * @returns {boolean} boolean indicating if provider is {@link ProviderStatus.READY}, useful if suspense is disabled and you want to handle loaders on your own\n */\nexport function useWhenProviderReady(options?: Options): boolean {\n const client = useOpenFeatureClient();\n const status = useOpenFeatureClientStatus();\n // highest priority > evaluation hook options > provider options > default options > lowest priority\n const defaultedOptions = { ...DEFAULT_OPTIONS, ...useProviderOptions(), ...normalizeOptions(options) };\n\n // suspense\n if (defaultedOptions.suspendUntilReady && status === ProviderStatus.NOT_READY) {\n suspendUntilReady(client);\n }\n\n return status === ProviderStatus.READY;\n}\n", "import {\n InMemoryProvider,\n JsonValue,\n NOOP_PROVIDER,\n OpenFeature,\n Provider,\n} from '@openfeature/web-sdk';\nimport React from 'react';\nimport { NormalizedOptions } from '../common/options';\nimport { OpenFeatureProvider } from './provider';\n\ntype FlagValueMap = { [flagKey: string]: JsonValue };\ntype FlagConfig = ConstructorParameters<typeof InMemoryProvider>[0];\ntype TestProviderProps = Omit<React.ComponentProps<typeof OpenFeatureProvider>, 'client'> &\n (\n | {\n provider?: never;\n /**\n * Optional map of flagKeys to flagValues for this OpenFeatureTestProvider context.\n * If not supplied, all flag evaluations will default.\n */\n flagValueMap?: FlagValueMap;\n /**\n * Optional delay for the underlying test provider's readiness and reconciliation.\n * Defaults to 0.\n */\n delayMs?: number;\n }\n | {\n /**\n * An optional partial provider to pass for full control over the flag resolution for this OpenFeatureTestProvider context.\n * Any un-implemented methods or properties will no-op.\n */\n provider?: Partial<Provider>;\n flagValueMap?: never;\n delayMs?: never;\n }\n );\n\n const TEST_VARIANT = 'test-variant';\n const TEST_PROVIDER = 'test-provider';\n\n// internal provider which is basically the in-memory provider with a simpler config and some optional fake delays\nclass TestProvider extends InMemoryProvider {\n\n // initially make this undefined, we still set it if a delay is specified\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - For maximum compatibility with previous versions, we ignore a possible TS error here,\n // since \"initialize\" was previously defined in superclass.\n // We can safely remove this ts-ignore in a few versions\n initialize: Provider['initialize'] = undefined;\n\n // \"place-holder\" init function which we only assign if want a delay\n private delayedInitialize = async () => {\n await new Promise<void>((resolve) => setTimeout(resolve, this.delay));\n };\n\n constructor(\n flagValueMap: FlagValueMap,\n private delay = 0,\n ) {\n // convert the simple flagValueMap into an in-memory config\n const flagConfig = Object.entries(flagValueMap).reduce((acc: FlagConfig, flag): FlagConfig => {\n return {\n ...acc,\n [flag[0]]: {\n variants: {\n [TEST_VARIANT]: flag[1],\n },\n defaultVariant: TEST_VARIANT,\n disabled: false,\n },\n };\n }, {});\n super(flagConfig);\n // only define and init if there's a non-zero delay specified\n this.initialize = this.delay ? this.delayedInitialize.bind(this) : undefined;\n }\n\n async onContextChange() {\n return new Promise<void>((resolve) => setTimeout(resolve, this.delay));\n }\n}\n\n/**\n * A React Context provider based on the {@link InMemoryProvider}, specifically built for testing.\n * Use this for testing components that use flag evaluation hooks.\n * @param {TestProviderProps} testProviderOptions options for the OpenFeatureTestProvider\n * @returns {OpenFeatureProvider} OpenFeatureTestProvider\n */\nexport function OpenFeatureTestProvider(testProviderOptions: TestProviderProps) {\n const { flagValueMap, provider } = testProviderOptions;\n const effectiveProvider = (\n flagValueMap ? new TestProvider(flagValueMap, testProviderOptions.delayMs) : mixInNoop(provider) || NOOP_PROVIDER\n ) as Provider;\n testProviderOptions.domain\n ? OpenFeature.setProvider(testProviderOptions.domain, effectiveProvider)\n : OpenFeature.setProvider(effectiveProvider);\n\n return (\n <OpenFeatureProvider {...(testProviderOptions as NormalizedOptions)} domain={testProviderOptions.domain}>\n {testProviderOptions.children}\n </OpenFeatureProvider>\n );\n}\n\n// mix in the no-op provider when the partial is passed\nfunction mixInNoop(provider: Partial<Provider> = {}) {\n // fill in any missing methods with no-ops\n for (const prop of Object.getOwnPropertyNames(Object.getPrototypeOf(NOOP_PROVIDER)).filter(prop => prop !== 'constructor')) {\n const patchedProvider = provider as {[key: string]: keyof Provider};\n if (!Object.getPrototypeOf(patchedProvider)[prop] && !patchedProvider[prop]) {\n patchedProvider[prop] = Object.getPrototypeOf(NOOP_PROVIDER)[prop];\n }\n }\n // fill in the metadata if missing\n if (!provider.metadata || !provider.metadata.name) {\n (provider.metadata as unknown) = { name: TEST_PROVIDER };\n }\n return provider;\n}", "export * from './evaluation';\nexport * from './query';\nexport * from './provider';\n// re-export the web-sdk so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,EAAoE,QAAQ,oBAAoB,WAC9F,oBAAoB,QACvB;AAEJ;AAGA,SAAS,UAAU,WAA8B,CAAC,GAAG;AAEnD,aAAW,QAAQ,OAAO,oBAAoB,OAAO,eAAe,aAAa,CAAC,EAAE,OAAO,CAAAC,UAAQA,UAAS,aAAa,GAAG;AAC1H,UAAM,kBAAkB;AACxB,QAAI,CAAC,OAAO,eAAe,eAAe,EAAE,IAAI,KAAK,CAAC,gBAAgB,IAAI,GAAG;AAC3E,sBAAgB,IAAI,IAAI,OAAO,eAAe,aAAa,EAAE,IAAI;AAAA,IACnE;AAAA,EACF;AAEA,MAAI,CAAC,SAAS,YAAY,CAAC,SAAS,SAAS,MAAM;AACjD,IAAC,SAAS,WAAuB,EAAE,MAAM,cAAc;AAAA,EACzD;AACA,SAAO;AACT;;;ACpHA,cAAc;",
6
6
  "names": ["ProviderEvents", "ProviderStatus", "useEffect", "useState", "suspendUntilReady", "React", "React", "ProviderEvents", "ProviderStatus", "useState", "useEffect", "ProviderEvents", "React", "ProviderStatus", "ProviderStatus", "OpenFeature", "React", "OpenFeature", "React", "prop"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfeature/react-sdk",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "OpenFeature React SDK",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "files": [
@@ -46,7 +46,7 @@
46
46
  },
47
47
  "homepage": "https://github.com/open-feature/js-sdk#readme",
48
48
  "peerDependencies": {
49
- "@openfeature/web-sdk": "^1.0.2",
49
+ "@openfeature/web-sdk": "^1.2.2",
50
50
  "react": ">=16.8.0"
51
51
  },
52
52
  "devDependencies": {