@liteguard/liteguard-react 0.2.20260314 → 0.3.20260315

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
@@ -4,9 +4,9 @@
4
4
  [![npm](https://img.shields.io/npm/v/@liteguard/liteguard-react)](https://www.npmjs.com/package/@liteguard/liteguard-react)
5
5
  [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/liteguard/liteguard/blob/main/LICENSE)
6
6
 
7
- > Feature guards, observability, and security response in a single import evaluated locally, zero network overhead per check.
7
+ > Feature guards, observability, and security response in a single import. Evaluated locally, zero network overhead per check.
8
8
 
9
- React bindings for Liteguard. Drop in `<LiteguardProvider>` and use the `useIsOpen` hook to gate any component tree guards are evaluated locally with no network round-trips.
9
+ React bindings for Liteguard. Drop in `<LiteguardProvider>` and use the `useIsOpen` hook to gate any component tree. Guards are evaluated locally with no network round-trips.
10
10
 
11
11
  Powered by [`@liteguard/liteguard-browser`](https://www.npmjs.com/package/@liteguard/liteguard-browser) under the hood, so runtime behavior, signal telemetry, and CVE auto-disable all work out of the box.
12
12
 
@@ -35,7 +35,7 @@ function CheckoutButton() {
35
35
 
36
36
  export function App() {
37
37
  return (
38
- <LiteguardProvider projectClientKeyId="pckid-..." properties={{ userId: 'user-123', plan: 'pro' }}>
38
+ <LiteguardProvider projectClientToken="pct-..." properties={{ userId: 'user-123', plan: 'pro' }}>
39
39
  <CheckoutButton />
40
40
  </LiteguardProvider>
41
41
  );
@@ -52,8 +52,8 @@ Context provider that initializes the Liteguard browser client and makes it avai
52
52
 
53
53
  ```tsx
54
54
  <LiteguardProvider
55
- projectClientKeyId="pckid-..."
56
- environment="production" // optional uses workspace default if omitted
55
+ projectClientToken="pct-..."
56
+ environment="production" // optional uses workspace default if omitted
57
57
  properties={{ userId: 'user-123', plan: 'pro' }} // optional initial properties
58
58
  fallback={false} // default result while guards are loading
59
59
  >
@@ -65,7 +65,7 @@ All `init` options are accepted as props with the same `camelCase` names:
65
65
 
66
66
  | Prop | Default | Description |
67
67
  |---|---|---|
68
- | `projectClientKeyId` | required | Your Liteguard project client key |
68
+ | `projectClientToken` | required | Your Liteguard project client token |
69
69
  | `environment` | workspace default | Environment slug |
70
70
  | `fallback` | `false` | Guard result before rules load |
71
71
  | `refreshRateSeconds` | `30` | Guard rule refresh interval |
@@ -113,7 +113,7 @@ function CheckoutButton() {
113
113
 
114
114
  ## Guard Evaluation
115
115
 
116
- Guards are evaluated **client-side** against rules fetched once at initialization and refreshed periodically. Rules are evaluated in order **first matching rule wins**. If no rule matches the guard's configured default applies.
116
+ Guards are evaluated **client-side** against rules fetched once at initialization and refreshed periodically. Rules are evaluated in order **first matching rule wins**. If no rule matches the guard's configured default applies.
117
117
 
118
118
  ```
119
119
  guard "payments.checkout"
@@ -138,4 +138,4 @@ guard "payments.checkout"
138
138
 
139
139
  ## License
140
140
 
141
- Apache 2.0 see [LICENSE](https://github.com/liteguard/liteguard/blob/main/LICENSE).
141
+ Apache 2.0 see [LICENSE](https://github.com/liteguard/liteguard/blob/main/LICENSE).
package/dist/index.d.mts CHANGED
@@ -11,10 +11,10 @@ type LiteguardProviderProps = {
11
11
  */
12
12
  client?: LiteguardClient;
13
13
  /**
14
- * Your project client key ID. When provided (without `client`), the
14
+ * Your project client token. When provided (without `client`), the
15
15
  * provider automatically creates, starts, and shuts down a managed client.
16
16
  */
17
- projectClientKeyId?: string;
17
+ projectClientToken?: string;
18
18
  /** Optional SDK configuration overrides for the managed client. */
19
19
  options?: ClientOptions;
20
20
  /** Optional default properties applied to the active client scope. */
@@ -41,31 +41,31 @@ type LiteguardProviderProps = {
41
41
  * React context provider that makes a Liteguard client available to the
42
42
  * component tree via React context.
43
43
  *
44
- * **Managed mode** pass `projectClientKeyId` (and optional `options`) to
44
+ * **Managed mode** pass `projectClientToken` (and optional `options`) to
45
45
  * have the provider create, start, and shut down a client automatically.
46
46
  * While the initial guard bundle is loading, the optional `loading` subtree
47
47
  * is rendered instead of `children`.
48
48
  *
49
- * **External mode** pass a pre-configured `client` instance and the
49
+ * **External mode** pass a pre-configured `client` instance and the
50
50
  * provider simply makes it available through context without managing its
51
51
  * lifecycle.
52
52
  *
53
53
  * @example
54
54
  * ```tsx
55
55
  * // Managed mode
56
- * <LiteguardProvider projectClientKeyId="pk_live_..." loading={<Spinner />}>
56
+ * <LiteguardProvider projectClientToken="pctok_live_..." loading={<Spinner />}>
57
57
  * <App />
58
58
  * </LiteguardProvider>
59
59
  *
60
60
  * // External mode
61
- * const client = new LiteguardClient('pk_live_...');
61
+ * const client = new LiteguardClient('pctok_live_...');
62
62
  * await client.start();
63
63
  * <LiteguardProvider client={client}>
64
64
  * <App />
65
65
  * </LiteguardProvider>
66
66
  * ```
67
67
  */
68
- declare function LiteguardProvider({ client, projectClientKeyId, options, properties, environment, fallback, refreshRateSeconds, flushRateSeconds, flushSize, backendUrl, quiet, httpTimeoutSeconds, flushBufferMultiplier, disableMeasurement, loading, children, }: LiteguardProviderProps): react_jsx_runtime.JSX.Element;
68
+ declare function LiteguardProvider({ client, projectClientToken, options, properties, environment, fallback, refreshRateSeconds, flushRateSeconds, flushSize, backendUrl, quiet, httpTimeoutSeconds, flushBufferMultiplier, disableMeasurement, loading, children, }: LiteguardProviderProps): react_jsx_runtime.JSX.Element;
69
69
  /**
70
70
  * Return the nearest Liteguard client from React context, or `null` if no
71
71
  * provider is present.
@@ -78,7 +78,7 @@ declare function LiteguardProvider({ client, projectClientKeyId, options, proper
78
78
  declare function useLiteguard(): LiteguardClient | null;
79
79
  /**
80
80
  * Return the nearest Liteguard client from React context. Throws if no
81
- * client is available ensures the component is rendered inside a
81
+ * client is available. Ensures the component is rendered inside a
82
82
  * {@link LiteguardProvider}.
83
83
  *
84
84
  * @returns The {@link LiteguardClient}.
package/dist/index.d.ts CHANGED
@@ -11,10 +11,10 @@ type LiteguardProviderProps = {
11
11
  */
12
12
  client?: LiteguardClient;
13
13
  /**
14
- * Your project client key ID. When provided (without `client`), the
14
+ * Your project client token. When provided (without `client`), the
15
15
  * provider automatically creates, starts, and shuts down a managed client.
16
16
  */
17
- projectClientKeyId?: string;
17
+ projectClientToken?: string;
18
18
  /** Optional SDK configuration overrides for the managed client. */
19
19
  options?: ClientOptions;
20
20
  /** Optional default properties applied to the active client scope. */
@@ -41,31 +41,31 @@ type LiteguardProviderProps = {
41
41
  * React context provider that makes a Liteguard client available to the
42
42
  * component tree via React context.
43
43
  *
44
- * **Managed mode** pass `projectClientKeyId` (and optional `options`) to
44
+ * **Managed mode** pass `projectClientToken` (and optional `options`) to
45
45
  * have the provider create, start, and shut down a client automatically.
46
46
  * While the initial guard bundle is loading, the optional `loading` subtree
47
47
  * is rendered instead of `children`.
48
48
  *
49
- * **External mode** pass a pre-configured `client` instance and the
49
+ * **External mode** pass a pre-configured `client` instance and the
50
50
  * provider simply makes it available through context without managing its
51
51
  * lifecycle.
52
52
  *
53
53
  * @example
54
54
  * ```tsx
55
55
  * // Managed mode
56
- * <LiteguardProvider projectClientKeyId="pk_live_..." loading={<Spinner />}>
56
+ * <LiteguardProvider projectClientToken="pctok_live_..." loading={<Spinner />}>
57
57
  * <App />
58
58
  * </LiteguardProvider>
59
59
  *
60
60
  * // External mode
61
- * const client = new LiteguardClient('pk_live_...');
61
+ * const client = new LiteguardClient('pctok_live_...');
62
62
  * await client.start();
63
63
  * <LiteguardProvider client={client}>
64
64
  * <App />
65
65
  * </LiteguardProvider>
66
66
  * ```
67
67
  */
68
- declare function LiteguardProvider({ client, projectClientKeyId, options, properties, environment, fallback, refreshRateSeconds, flushRateSeconds, flushSize, backendUrl, quiet, httpTimeoutSeconds, flushBufferMultiplier, disableMeasurement, loading, children, }: LiteguardProviderProps): react_jsx_runtime.JSX.Element;
68
+ declare function LiteguardProvider({ client, projectClientToken, options, properties, environment, fallback, refreshRateSeconds, flushRateSeconds, flushSize, backendUrl, quiet, httpTimeoutSeconds, flushBufferMultiplier, disableMeasurement, loading, children, }: LiteguardProviderProps): react_jsx_runtime.JSX.Element;
69
69
  /**
70
70
  * Return the nearest Liteguard client from React context, or `null` if no
71
71
  * provider is present.
@@ -78,7 +78,7 @@ declare function LiteguardProvider({ client, projectClientKeyId, options, proper
78
78
  declare function useLiteguard(): LiteguardClient | null;
79
79
  /**
80
80
  * Return the nearest Liteguard client from React context. Throws if no
81
- * client is available ensures the component is rendered inside a
81
+ * client is available. Ensures the component is rendered inside a
82
82
  * {@link LiteguardProvider}.
83
83
  *
84
84
  * @returns The {@link LiteguardClient}.
package/dist/index.js CHANGED
@@ -49,7 +49,7 @@ function useClientValue(client, getSnapshot, fallback) {
49
49
  }
50
50
  function LiteguardProvider({
51
51
  client,
52
- projectClientKeyId,
52
+ projectClientToken,
53
53
  options,
54
54
  properties,
55
55
  environment,
@@ -102,12 +102,12 @@ function LiteguardProvider({
102
102
  setManagedClient(client);
103
103
  return;
104
104
  }
105
- if (!projectClientKeyId) {
105
+ if (!projectClientToken) {
106
106
  setManagedClient(null);
107
107
  return;
108
108
  }
109
109
  let cancelled = false;
110
- const nextClient = new import_liteguard_browser.LiteguardClient(projectClientKeyId, resolvedOptions);
110
+ const nextClient = new import_liteguard_browser.LiteguardClient(projectClientToken, resolvedOptions);
111
111
  setManagedClient(nextClient);
112
112
  setError(null);
113
113
  const unsubscribe = nextClient.subscribe(() => {
@@ -125,7 +125,7 @@ function LiteguardProvider({
125
125
  unsubscribe();
126
126
  void nextClient.shutdown();
127
127
  };
128
- }, [client, projectClientKeyId, optionsKey, resolvedOptions]);
128
+ }, [client, projectClientToken, optionsKey, resolvedOptions]);
129
129
  const activeClient = client ?? managedClient;
130
130
  const ready = useClientValue(activeClient, () => activeClient?.isReady() ?? false, false);
131
131
  (0, import_react.useEffect)(() => {
@@ -140,7 +140,7 @@ function LiteguardProvider({
140
140
  if (error) {
141
141
  throw error;
142
142
  }
143
- if (projectClientKeyId && !ready) {
143
+ if (projectClientToken && !ready) {
144
144
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: loading });
145
145
  }
146
146
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LiteguardContext.Provider, { value: activeClient, children });
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/provider.tsx"],"sourcesContent":["export {\n LiteguardProvider,\n useIsOpen,\n useLiteguard,\n useLiteguardClient,\n useLiteguardReady,\n} from './provider.js';\nexport type { LiteguardProviderProps } from './provider.js';\n","import {\n createContext,\n useContext,\n useEffect,\n useMemo,\n useState,\n useSyncExternalStore,\n type ReactNode,\n} from 'react';\nimport { LiteguardClient } from '@liteguard/liteguard-browser';\nimport type { ClientOptions, Options, Properties } from '@liteguard/liteguard-browser';\n\nconst LiteguardContext = createContext<LiteguardClient | null>(null);\n\n/** Props for {@link LiteguardProvider}. */\nexport type LiteguardProviderProps = {\n /**\n * An externally created {@link LiteguardClient} instance. When provided,\n * the provider uses this client directly and does **not** manage its\n * lifecycle (you are responsible for calling `start()` / `shutdown()`).\n */\n client?: LiteguardClient;\n /**\n * Your project client key ID. When provided (without `client`), the\n * provider automatically creates, starts, and shuts down a managed client.\n */\n projectClientKeyId?: string;\n /** Optional SDK configuration overrides for the managed client. */\n options?: ClientOptions;\n /** Optional default properties applied to the active client scope. */\n properties?: Properties;\n environment?: ClientOptions['environment'];\n fallback?: ClientOptions['fallback'];\n refreshRateSeconds?: ClientOptions['refreshRateSeconds'];\n flushRateSeconds?: ClientOptions['flushRateSeconds'];\n flushSize?: ClientOptions['flushSize'];\n backendUrl?: ClientOptions['backendUrl'];\n quiet?: ClientOptions['quiet'];\n httpTimeoutSeconds?: ClientOptions['httpTimeoutSeconds'];\n flushBufferMultiplier?: ClientOptions['flushBufferMultiplier'];\n disableMeasurement?: ClientOptions['disableMeasurement'];\n /**\n * React node rendered while the managed client is fetching its initial\n * guard bundle. Defaults to `null` (render nothing).\n */\n loading?: ReactNode;\n /** Application subtree that gains access to the Liteguard client via context. */\n children: ReactNode;\n};\n\n/** Provide a stable no-op subscription for components rendered without a client. */\nfunction subscribeNoop(): () => void {\n return () => {};\n}\n\n/** Resolve the nearest Liteguard client from React context. */\nfunction useOptionalClient(): LiteguardClient | null {\n return useContext(LiteguardContext);\n}\n\n/** Subscribe a component to client refreshes and fall back cleanly when absent. */\nfunction useClientValue<T>(client: LiteguardClient | null, getSnapshot: () => T, fallback: T): T {\n return useSyncExternalStore(\n client ? client.subscribe.bind(client) : subscribeNoop,\n client ? getSnapshot : () => fallback,\n () => fallback,\n );\n}\n\n/**\n * React context provider that makes a Liteguard client available to the\n * component tree via React context.\n *\n * **Managed mode** — pass `projectClientKeyId` (and optional `options`) to\n * have the provider create, start, and shut down a client automatically.\n * While the initial guard bundle is loading, the optional `loading` subtree\n * is rendered instead of `children`.\n *\n * **External mode** — pass a pre-configured `client` instance and the\n * provider simply makes it available through context without managing its\n * lifecycle.\n *\n * @example\n * ```tsx\n * // Managed mode\n * <LiteguardProvider projectClientKeyId=\"pk_live_...\" loading={<Spinner />}>\n * <App />\n * </LiteguardProvider>\n *\n * // External mode\n * const client = new LiteguardClient('pk_live_...');\n * await client.start();\n * <LiteguardProvider client={client}>\n * <App />\n * </LiteguardProvider>\n * ```\n */\nexport function LiteguardProvider({\n client,\n projectClientKeyId,\n options,\n properties,\n environment,\n fallback,\n refreshRateSeconds,\n flushRateSeconds,\n flushSize,\n backendUrl,\n quiet,\n httpTimeoutSeconds,\n flushBufferMultiplier,\n disableMeasurement,\n loading = null,\n children,\n}: LiteguardProviderProps) {\n const resolvedOptions = useMemo<ClientOptions>(\n () => ({\n ...(options ?? {}),\n ...(environment !== undefined ? { environment } : {}),\n ...(fallback !== undefined ? { fallback } : {}),\n ...(refreshRateSeconds !== undefined ? { refreshRateSeconds } : {}),\n ...(flushRateSeconds !== undefined ? { flushRateSeconds } : {}),\n ...(flushSize !== undefined ? { flushSize } : {}),\n ...(backendUrl !== undefined ? { backendUrl } : {}),\n ...(quiet !== undefined ? { quiet } : {}),\n ...(httpTimeoutSeconds !== undefined ? { httpTimeoutSeconds } : {}),\n ...(flushBufferMultiplier !== undefined ? { flushBufferMultiplier } : {}),\n ...(disableMeasurement !== undefined ? { disableMeasurement } : {}),\n }),\n [\n options,\n environment,\n fallback,\n refreshRateSeconds,\n flushRateSeconds,\n flushSize,\n backendUrl,\n quiet,\n httpTimeoutSeconds,\n flushBufferMultiplier,\n disableMeasurement,\n ],\n );\n const optionsKey = useMemo(() => JSON.stringify(resolvedOptions), [resolvedOptions]);\n const propertiesKey = useMemo(() => JSON.stringify(properties ?? {}), [properties]);\n const [managedClient, setManagedClient] = useState<LiteguardClient | null>(() => client ?? null);\n const [error, setError] = useState<unknown>(null);\n\n useEffect(() => {\n if (client) {\n setManagedClient(client);\n return;\n }\n\n if (!projectClientKeyId) {\n setManagedClient(null);\n return;\n }\n\n let cancelled = false;\n const nextClient = new LiteguardClient(projectClientKeyId, resolvedOptions);\n setManagedClient(nextClient);\n setError(null);\n\n const unsubscribe = nextClient.subscribe(() => {\n if (!cancelled) {\n setManagedClient(nextClient);\n }\n });\n\n void nextClient.start().catch((startError) => {\n if (!cancelled) {\n setError(startError);\n }\n });\n\n return () => {\n cancelled = true;\n unsubscribe();\n void nextClient.shutdown();\n };\n }, [client, projectClientKeyId, optionsKey, resolvedOptions]);\n\n const activeClient = client ?? managedClient;\n const ready = useClientValue(activeClient, () => activeClient?.isReady() ?? false, false);\n\n useEffect(() => {\n if (!activeClient) {\n return;\n }\n\n activeClient.resetProperties();\n if (properties && Object.keys(properties).length > 0) {\n activeClient.addProperties(properties);\n }\n }, [activeClient, propertiesKey, properties]);\n\n if (error) {\n throw error;\n }\n if (projectClientKeyId && !ready) {\n return <>{loading}</>;\n }\n\n return <LiteguardContext.Provider value={activeClient}>{children}</LiteguardContext.Provider>;\n}\n\n/**\n * Return the nearest Liteguard client from React context, or `null` if no\n * provider is present.\n *\n * Prefer {@link useLiteguardClient} when you need to assert that a client\n * is available.\n *\n * @returns The {@link LiteguardClient}, or `null`.\n */\nexport function useLiteguard(): LiteguardClient | null {\n return useOptionalClient();\n}\n\n/**\n * Return the nearest Liteguard client from React context. Throws if no\n * client is available — ensures the component is rendered inside a\n * {@link LiteguardProvider}.\n *\n * @returns The {@link LiteguardClient}.\n * @throws {Error} When no Liteguard client is reachable.\n */\nexport function useLiteguardClient(): LiteguardClient {\n const client = useOptionalClient();\n if (!client) {\n throw new Error(\n '[liteguard] No Liteguard React client available. Wrap your app in LiteguardProvider.',\n );\n }\n return client;\n}\n\n/**\n * Returns `true` once the Liteguard client has fetched its initial guard\n * bundle. Re-renders the component automatically when the ready state\n * changes.\n *\n * @returns `true` when the client is ready, `false` otherwise.\n */\nexport function useLiteguardReady(): boolean {\n const client = useOptionalClient();\n return useClientValue(client, () => client?.isReady() ?? false, false);\n}\n\n/**\n * Return `true` if the named guard is open for the current context.\n * Re-renders automatically whenever the guard bundle is refreshed.\n *\n * Internally uses `peekIsOpen` so guard checks during renders do **not**\n * emit telemetry signals or consume rate-limit slots. For guarded\n * side-effects that need telemetry, call\n * `useLiteguardClient().executeIfOpen()` in an event handler or effect.\n *\n * @param name - Guard name to evaluate (e.g. `\"feature.beta\"`).\n * @param options - Optional per-call overrides (extra properties, fallback).\n * @returns `true` if the guard is open, `false` otherwise.\n *\n * @example\n * ```tsx\n * function Banner() {\n * const showBeta = useIsOpen('promo.banner');\n * if (!showBeta) return null;\n * return <div>Try our new beta!</div>;\n * }\n * ```\n */\nexport function useIsOpen(name: string, options?: Partial<Options>): boolean {\n const client = useOptionalClient();\n const fallback = options?.fallback ?? false;\n return useClientValue(client, () => client?.peekIsOpen(name, options) ?? fallback, fallback);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAQO;AACP,+BAAgC;AAgMrB;AA7LX,IAAM,uBAAmB,4BAAsC,IAAI;AAuCnE,SAAS,gBAA4B;AACnC,SAAO,MAAM;AAAA,EAAC;A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AO;AACT,UAAM;AAAA,EACR;AACA,MAAI,sBAAsB,CAAC,OAAO;AAChC,WAAO,2EAAG,mBAAQ;AAAA,EACpB;AAEA,SAAO,4CAAC,iBAAiB,UAAjB,EAA0B,OAAO,cAAe,UAAS;AACnE;AAWO,SAAS,eAAuC;AACrD,SAAO,kBAAkB;AAC3B;AAUO,SAAS,qBAAsC;AACpD,QAAM,SAAS,kBAAkB;AACjC,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AASO,SAAS,oBAA6B;AAC3C,QAAM,SAAS,kBAAkB;AACjC,SAAO,eAAe,QAAQ,MAAM,QAAQ,QAAQ,KAAK,OAAO,KAAK;AACvE;AAwBO,SAAS,UAAU,MAAc,SAAqC;AAC3E,QAAM,SAAS,kBAAkB;AACjC,QAAM,WAAW,SAAS,YAAY;AACtC,SAAO,eAAe,QAAQ,MAAM,QAAQ,WAAW,MAAM,OAAO,KAAK,UAAU,QAAQ;AAC7F;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts","../src/provider.tsx"],"sourcesContent":["export {\n LiteguardProvider,\n useIsOpen,\n useLiteguard,\n useLiteguardClient,\n useLiteguardReady,\n} from './provider.js';\nexport type { LiteguardProviderProps } from './provider.js';\n","import {\n createContext,\n useContext,\n useEffect,\n useMemo,\n useState,\n useSyncExternalStore,\n type ReactNode,\n} from 'react';\nimport { LiteguardClient } from '@liteguard/liteguard-browser';\nimport type { ClientOptions, Options, Properties } from '@liteguard/liteguard-browser';\n\nconst LiteguardContext = createContext<LiteguardClient | null>(null);\n\n/** Props for {@link LiteguardProvider}. */\nexport type LiteguardProviderProps = {\n /**\n * An externally created {@link LiteguardClient} instance. When provided,\n * the provider uses this client directly and does **not** manage its\n * lifecycle (you are responsible for calling `start()` / `shutdown()`).\n */\n client?: LiteguardClient;\n /**\n * Your project client token. When provided (without `client`), the\n * provider automatically creates, starts, and shuts down a managed client.\n */\n projectClientToken?: string;\n /** Optional SDK configuration overrides for the managed client. */\n options?: ClientOptions;\n /** Optional default properties applied to the active client scope. */\n properties?: Properties;\n environment?: ClientOptions['environment'];\n fallback?: ClientOptions['fallback'];\n refreshRateSeconds?: ClientOptions['refreshRateSeconds'];\n flushRateSeconds?: ClientOptions['flushRateSeconds'];\n flushSize?: ClientOptions['flushSize'];\n backendUrl?: ClientOptions['backendUrl'];\n quiet?: ClientOptions['quiet'];\n httpTimeoutSeconds?: ClientOptions['httpTimeoutSeconds'];\n flushBufferMultiplier?: ClientOptions['flushBufferMultiplier'];\n disableMeasurement?: ClientOptions['disableMeasurement'];\n /**\n * React node rendered while the managed client is fetching its initial\n * guard bundle. Defaults to `null` (render nothing).\n */\n loading?: ReactNode;\n /** Application subtree that gains access to the Liteguard client via context. */\n children: ReactNode;\n};\n\n/** Provide a stable no-op subscription for components rendered without a client. */\nfunction subscribeNoop(): () => void {\n return () => {};\n}\n\n/** Resolve the nearest Liteguard client from React context. */\nfunction useOptionalClient(): LiteguardClient | null {\n return useContext(LiteguardContext);\n}\n\n/** Subscribe a component to client refreshes and fall back cleanly when absent. */\nfunction useClientValue<T>(client: LiteguardClient | null, getSnapshot: () => T, fallback: T): T {\n return useSyncExternalStore(\n client ? client.subscribe.bind(client) : subscribeNoop,\n client ? getSnapshot : () => fallback,\n () => fallback,\n );\n}\n\n/**\n * React context provider that makes a Liteguard client available to the\n * component tree via React context.\n *\n * **Managed mode** pass `projectClientToken` (and optional `options`) to\n * have the provider create, start, and shut down a client automatically.\n * While the initial guard bundle is loading, the optional `loading` subtree\n * is rendered instead of `children`.\n *\n * **External mode** pass a pre-configured `client` instance and the\n * provider simply makes it available through context without managing its\n * lifecycle.\n *\n * @example\n * ```tsx\n * // Managed mode\n * <LiteguardProvider projectClientToken=\"pctok_live_...\" loading={<Spinner />}>\n * <App />\n * </LiteguardProvider>\n *\n * // External mode\n * const client = new LiteguardClient('pctok_live_...');\n * await client.start();\n * <LiteguardProvider client={client}>\n * <App />\n * </LiteguardProvider>\n * ```\n */\nexport function LiteguardProvider({\n client,\n projectClientToken,\n options,\n properties,\n environment,\n fallback,\n refreshRateSeconds,\n flushRateSeconds,\n flushSize,\n backendUrl,\n quiet,\n httpTimeoutSeconds,\n flushBufferMultiplier,\n disableMeasurement,\n loading = null,\n children,\n}: LiteguardProviderProps) {\n const resolvedOptions = useMemo<ClientOptions>(\n () => ({\n ...(options ?? {}),\n ...(environment !== undefined ? { environment } : {}),\n ...(fallback !== undefined ? { fallback } : {}),\n ...(refreshRateSeconds !== undefined ? { refreshRateSeconds } : {}),\n ...(flushRateSeconds !== undefined ? { flushRateSeconds } : {}),\n ...(flushSize !== undefined ? { flushSize } : {}),\n ...(backendUrl !== undefined ? { backendUrl } : {}),\n ...(quiet !== undefined ? { quiet } : {}),\n ...(httpTimeoutSeconds !== undefined ? { httpTimeoutSeconds } : {}),\n ...(flushBufferMultiplier !== undefined ? { flushBufferMultiplier } : {}),\n ...(disableMeasurement !== undefined ? { disableMeasurement } : {}),\n }),\n [\n options,\n environment,\n fallback,\n refreshRateSeconds,\n flushRateSeconds,\n flushSize,\n backendUrl,\n quiet,\n httpTimeoutSeconds,\n flushBufferMultiplier,\n disableMeasurement,\n ],\n );\n const optionsKey = useMemo(() => JSON.stringify(resolvedOptions), [resolvedOptions]);\n const propertiesKey = useMemo(() => JSON.stringify(properties ?? {}), [properties]);\n const [managedClient, setManagedClient] = useState<LiteguardClient | null>(() => client ?? null);\n const [error, setError] = useState<unknown>(null);\n\n useEffect(() => {\n if (client) {\n setManagedClient(client);\n return;\n }\n\n if (!projectClientToken) {\n setManagedClient(null);\n return;\n }\n\n let cancelled = false;\n const nextClient = new LiteguardClient(projectClientToken, resolvedOptions);\n setManagedClient(nextClient);\n setError(null);\n\n const unsubscribe = nextClient.subscribe(() => {\n if (!cancelled) {\n setManagedClient(nextClient);\n }\n });\n\n void nextClient.start().catch((startError) => {\n if (!cancelled) {\n setError(startError);\n }\n });\n\n return () => {\n cancelled = true;\n unsubscribe();\n void nextClient.shutdown();\n };\n }, [client, projectClientToken, optionsKey, resolvedOptions]);\n\n const activeClient = client ?? managedClient;\n const ready = useClientValue(activeClient, () => activeClient?.isReady() ?? false, false);\n\n useEffect(() => {\n if (!activeClient) {\n return;\n }\n\n activeClient.resetProperties();\n if (properties && Object.keys(properties).length > 0) {\n activeClient.addProperties(properties);\n }\n }, [activeClient, propertiesKey, properties]);\n\n if (error) {\n throw error;\n }\n if (projectClientToken && !ready) {\n return <>{loading}</>;\n }\n\n return <LiteguardContext.Provider value={activeClient}>{children}</LiteguardContext.Provider>;\n}\n\n/**\n * Return the nearest Liteguard client from React context, or `null` if no\n * provider is present.\n *\n * Prefer {@link useLiteguardClient} when you need to assert that a client\n * is available.\n *\n * @returns The {@link LiteguardClient}, or `null`.\n */\nexport function useLiteguard(): LiteguardClient | null {\n return useOptionalClient();\n}\n\n/**\n * Return the nearest Liteguard client from React context. Throws if no\n * client is available. Ensures the component is rendered inside a\n * {@link LiteguardProvider}.\n *\n * @returns The {@link LiteguardClient}.\n * @throws {Error} When no Liteguard client is reachable.\n */\nexport function useLiteguardClient(): LiteguardClient {\n const client = useOptionalClient();\n if (!client) {\n throw new Error(\n '[liteguard] No Liteguard React client available. Wrap your app in LiteguardProvider.',\n );\n }\n return client;\n}\n\n/**\n * Returns `true` once the Liteguard client has fetched its initial guard\n * bundle. Re-renders the component automatically when the ready state\n * changes.\n *\n * @returns `true` when the client is ready, `false` otherwise.\n */\nexport function useLiteguardReady(): boolean {\n const client = useOptionalClient();\n return useClientValue(client, () => client?.isReady() ?? false, false);\n}\n\n/**\n * Return `true` if the named guard is open for the current context.\n * Re-renders automatically whenever the guard bundle is refreshed.\n *\n * Internally uses `peekIsOpen` so guard checks during renders do **not**\n * emit telemetry signals or consume rate-limit slots. For guarded\n * side-effects that need telemetry, call\n * `useLiteguardClient().executeIfOpen()` in an event handler or effect.\n *\n * @param name - Guard name to evaluate (e.g. `\"feature.beta\"`).\n * @param options - Optional per-call overrides (extra properties, fallback).\n * @returns `true` if the guard is open, `false` otherwise.\n *\n * @example\n * ```tsx\n * function Banner() {\n * const showBeta = useIsOpen('promo.banner');\n * if (!showBeta) return null;\n * return <div>Try our new beta!</div>;\n * }\n * ```\n */\nexport function useIsOpen(name: string, options?: Partial<Options>): boolean {\n const client = useOptionalClient();\n const fallback = options?.fallback ?? false;\n return useClientValue(client, () => client?.peekIsOpen(name, options) ?? fallback, fallback);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAQO;AACP,+BAAgC;AAgMrB;AA7LX,IAAM,uBAAmB,4BAAsC,IAAI;AAuCnE,SAAS,gBAA4B;AACnC,SAAO,MAAM;AAAA,EAAC;AAChB;AAGA,SAAS,oBAA4C;AACnD,aAAO,yBAAW,gBAAgB;AACpC;AAGA,SAAS,eAAkB,QAAgC,aAAsB,UAAgB;AAC/F,aAAO;AAAA,IACL,SAAS,OAAO,UAAU,KAAK,MAAM,IAAI;AAAA,IACzC,SAAS,cAAc,MAAM;AAAA,IAC7B,MAAM;AAAA,EACR;AACF;AA8BO,SAAS,kBAAkB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV;AACF,GAA2B;AACzB,QAAM,sBAAkB;AAAA,IACtB,OAAO;AAAA,MACL,GAAI,WAAW,CAAC;AAAA,MAChB,GAAI,gBAAgB,SAAY,EAAE,YAAY,IAAI,CAAC;AAAA,MACnD,GAAI,aAAa,SAAY,EAAE,SAAS,IAAI,CAAC;AAAA,MAC7C,GAAI,uBAAuB,SAAY,EAAE,mBAAmB,IAAI,CAAC;AAAA,MACjE,GAAI,qBAAqB,SAAY,EAAE,iBAAiB,IAAI,CAAC;AAA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A,MACrB;AAAA,IACF,CAAC;AAED,WAAO,MAAM;AACX,kBAAY;AACZ,kBAAY;AACZ,WAAK,WAAW,SAAS;AAAA,IAC3B;AAAA,EACF,GAAG,CAAC,QAAQ,oBAAoB,YAAY,eAAe,CAAC;AAE5D,QAAM,eAAe,UAAU;AAC/B,QAAM,QAAQ,eAAe,cAAc,MAAM,cAAc,QAAQ,KAAK,OAAO,KAAK;AAExF,8BAAU,MAAM;AACd,QAAI,CAAC,cAAc;AACjB;AAAA,IACF;AAEA,iBAAa,gBAAgB;AAC7B,QAAI,cAAc,OAAO,KAAK,UAAU,EAAE,SAAS,GAAG;AACpD,mBAAa,cAAc,UAAU;AAAA,IACvC;AAAA,EACF,GAAG,CAAC,cAAc,eAAe,UAAU,CAAC;AAE5C,MAAI,OAAO;AACT,UAAM;AAAA,EACR;AACA,MAAI,sBAAsB,CAAC,OAAO;AAChC,WAAO,2EAAG,mBAAQ;AAAA,EACpB;AAEA,SAAO,4CAAC,iBAAiB,UAAjB,EAA0B,OAAO,cAAe,UAAS;AACnE;AAWO,SAAS,eAAuC;AACrD,SAAO,kBAAkB;AAC3B;AAUO,SAAS,qBAAsC;AACpD,QAAM,SAAS,kBAAkB;AACjC,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AASO,SAAS,oBAA6B;AAC3C,QAAM,SAAS,kBAAkB;AACjC,SAAO,eAAe,QAAQ,MAAM,QAAQ,QAAQ,KAAK,OAAO,KAAK;AACvE;AAwBO,SAAS,UAAU,MAAc,SAAqC;AAC3E,QAAM,SAAS,kBAAkB;AACjC,QAAM,WAAW,SAAS,YAAY;AACtC,SAAO,eAAe,QAAQ,MAAM,QAAQ,WAAW,MAAM,OAAO,KAAK,UAAU,QAAQ;AAC7F;","names":[]}
package/dist/index.mjs CHANGED
@@ -26,7 +26,7 @@ function useClientValue(client, getSnapshot, fallback) {
26
26
  }
27
27
  function LiteguardProvider({
28
28
  client,
29
- projectClientKeyId,
29
+ projectClientToken,
30
30
  options,
31
31
  properties,
32
32
  environment,
@@ -79,12 +79,12 @@ function LiteguardProvider({
79
79
  setManagedClient(client);
80
80
  return;
81
81
  }
82
- if (!projectClientKeyId) {
82
+ if (!projectClientToken) {
83
83
  setManagedClient(null);
84
84
  return;
85
85
  }
86
86
  let cancelled = false;
87
- const nextClient = new LiteguardClient(projectClientKeyId, resolvedOptions);
87
+ const nextClient = new LiteguardClient(projectClientToken, resolvedOptions);
88
88
  setManagedClient(nextClient);
89
89
  setError(null);
90
90
  const unsubscribe = nextClient.subscribe(() => {
@@ -102,7 +102,7 @@ function LiteguardProvider({
102
102
  unsubscribe();
103
103
  void nextClient.shutdown();
104
104
  };
105
- }, [client, projectClientKeyId, optionsKey, resolvedOptions]);
105
+ }, [client, projectClientToken, optionsKey, resolvedOptions]);
106
106
  const activeClient = client ?? managedClient;
107
107
  const ready = useClientValue(activeClient, () => activeClient?.isReady() ?? false, false);
108
108
  useEffect(() => {
@@ -117,7 +117,7 @@ function LiteguardProvider({
117
117
  if (error) {
118
118
  throw error;
119
119
  }
120
- if (projectClientKeyId && !ready) {
120
+ if (projectClientToken && !ready) {
121
121
  return /* @__PURE__ */ jsx(Fragment, { children: loading });
122
122
  }
123
123
  return /* @__PURE__ */ jsx(LiteguardContext.Provider, { value: activeClient, children });
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/provider.tsx"],"sourcesContent":["import {\n createContext,\n useContext,\n useEffect,\n useMemo,\n useState,\n useSyncExternalStore,\n type ReactNode,\n} from 'react';\nimport { LiteguardClient } from '@liteguard/liteguard-browser';\nimport type { ClientOptions, Options, Properties } from '@liteguard/liteguard-browser';\n\nconst LiteguardContext = createContext<LiteguardClient | null>(null);\n\n/** Props for {@link LiteguardProvider}. */\nexport type LiteguardProviderProps = {\n /**\n * An externally created {@link LiteguardClient} instance. When provided,\n * the provider uses this client directly and does **not** manage its\n * lifecycle (you are responsible for calling `start()` / `shutdown()`).\n */\n client?: LiteguardClient;\n /**\n * Your project client key ID. When provided (without `client`), the\n * provider automatically creates, starts, and shuts down a managed client.\n */\n projectClientKeyId?: string;\n /** Optional SDK configuration overrides for the managed client. */\n options?: ClientOptions;\n /** Optional default properties applied to the active client scope. */\n properties?: Properties;\n environment?: ClientOptions['environment'];\n fallback?: ClientOptions['fallback'];\n refreshRateSeconds?: ClientOptions['refreshRateSeconds'];\n flushRateSeconds?: ClientOptions['flushRateSeconds'];\n flushSize?: ClientOptions['flushSize'];\n backendUrl?: ClientOptions['backendUrl'];\n quiet?: ClientOptions['quiet'];\n httpTimeoutSeconds?: ClientOptions['httpTimeoutSeconds'];\n flushBufferMultiplier?: ClientOptions['flushBufferMultiplier'];\n disableMeasurement?: ClientOptions['disableMeasurement'];\n /**\n * React node rendered while the managed client is fetching its initial\n * guard bundle. Defaults to `null` (render nothing).\n */\n loading?: ReactNode;\n /** Application subtree that gains access to the Liteguard client via context. */\n children: ReactNode;\n};\n\n/** Provide a stable no-op subscription for components rendered without a client. */\nfunction subscribeNoop(): () => void {\n return () => {};\n}\n\n/** Resolve the nearest Liteguard client from React context. */\nfunction useOptionalClient(): LiteguardClient | null {\n return useContext(LiteguardContext);\n}\n\n/** Subscribe a component to client refreshes and fall back cleanly when absent. */\nfunction useClientValue<T>(client: LiteguardClient | null, getSnapshot: () => T, fallback: T): T {\n return useSyncExternalStore(\n client ? client.subscribe.bind(client) : subscribeNoop,\n client ? getSnapshot : () => fallback,\n () => fallback,\n );\n}\n\n/**\n * React context provider that makes a Liteguard client available to the\n * component tree via React context.\n *\n * **Managed mode** — pass `projectClientKeyId` (and optional `options`) to\n * have the provider create, start, and shut down a client automatically.\n * While the initial guard bundle is loading, the optional `loading` subtree\n * is rendered instead of `children`.\n *\n * **External mode** — pass a pre-configured `client` instance and the\n * provider simply makes it available through context without managing its\n * lifecycle.\n *\n * @example\n * ```tsx\n * // Managed mode\n * <LiteguardProvider projectClientKeyId=\"pk_live_...\" loading={<Spinner />}>\n * <App />\n * </LiteguardProvider>\n *\n * // External mode\n * const client = new LiteguardClient('pk_live_...');\n * await client.start();\n * <LiteguardProvider client={client}>\n * <App />\n * </LiteguardProvider>\n * ```\n */\nexport function LiteguardProvider({\n client,\n projectClientKeyId,\n options,\n properties,\n environment,\n fallback,\n refreshRateSeconds,\n flushRateSeconds,\n flushSize,\n backendUrl,\n quiet,\n httpTimeoutSeconds,\n flushBufferMultiplier,\n disableMeasurement,\n loading = null,\n children,\n}: LiteguardProviderProps) {\n const resolvedOptions = useMemo<ClientOptions>(\n () => ({\n ...(options ?? {}),\n ...(environment !== undefined ? { environment } : {}),\n ...(fallback !== undefined ? { fallback } : {}),\n ...(refreshRateSeconds !== undefined ? { refreshRateSeconds } : {}),\n ...(flushRateSeconds !== undefined ? { flushRateSeconds } : {}),\n ...(flushSize !== undefined ? { flushSize } : {}),\n ...(backendUrl !== undefined ? { backendUrl } : {}),\n ...(quiet !== undefined ? { quiet } : {}),\n ...(httpTimeoutSeconds !== undefined ? { httpTimeoutSeconds } : {}),\n ...(flushBufferMultiplier !== undefined ? { flushBufferMultiplier } : {}),\n ...(disableMeasurement !== undefined ? { disableMeasurement } : {}),\n }),\n [\n options,\n environment,\n fallback,\n refreshRateSeconds,\n flushRateSeconds,\n flushSize,\n backendUrl,\n quiet,\n httpTimeoutSeconds,\n flushBufferMultiplier,\n disableMeasurement,\n ],\n );\n const optionsKey = useMemo(() => JSON.stringify(resolvedOptions), [resolvedOptions]);\n const propertiesKey = useMemo(() => JSON.stringify(properties ?? {}), [properties]);\n const [managedClient, setManagedClient] = useState<LiteguardClient | null>(() => client ?? null);\n const [error, setError] = useState<unknown>(null);\n\n useEffect(() => {\n if (client) {\n setManagedClient(client);\n return;\n }\n\n if (!projectClientKeyId) {\n setManagedClient(null);\n return;\n }\n\n let cancelled = false;\n const nextClient = new LiteguardClient(projectClientKeyId, resolvedOptions);\n setManagedClient(nextClient);\n setError(null);\n\n const unsubscribe = nextClient.subscribe(() => {\n if (!cancelled) {\n setManagedClient(nextClient);\n }\n });\n\n void nextClient.start().catch((startError) => {\n if (!cancelled) {\n setError(startError);\n }\n });\n\n return () => {\n cancelled = true;\n unsubscribe();\n void nextClient.shutdown();\n };\n }, [client, projectClientKeyId, optionsKey, resolvedOptions]);\n\n const activeClient = client ?? managedClient;\n const ready = useClientValue(activeClient, () => activeClient?.isReady() ?? false, false);\n\n useEffect(() => {\n if (!activeClient) {\n return;\n }\n\n activeClient.resetProperties();\n if (properties && Object.keys(properties).length > 0) {\n activeClient.addProperties(properties);\n }\n }, [activeClient, propertiesKey, properties]);\n\n if (error) {\n throw error;\n }\n if (projectClientKeyId && !ready) {\n return <>{loading}</>;\n }\n\n return <LiteguardContext.Provider value={activeClient}>{children}</LiteguardContext.Provider>;\n}\n\n/**\n * Return the nearest Liteguard client from React context, or `null` if no\n * provider is present.\n *\n * Prefer {@link useLiteguardClient} when you need to assert that a client\n * is available.\n *\n * @returns The {@link LiteguardClient}, or `null`.\n */\nexport function useLiteguard(): LiteguardClient | null {\n return useOptionalClient();\n}\n\n/**\n * Return the nearest Liteguard client from React context. Throws if no\n * client is available — ensures the component is rendered inside a\n * {@link LiteguardProvider}.\n *\n * @returns The {@link LiteguardClient}.\n * @throws {Error} When no Liteguard client is reachable.\n */\nexport function useLiteguardClient(): LiteguardClient {\n const client = useOptionalClient();\n if (!client) {\n throw new Error(\n '[liteguard] No Liteguard React client available. Wrap your app in LiteguardProvider.',\n );\n }\n return client;\n}\n\n/**\n * Returns `true` once the Liteguard client has fetched its initial guard\n * bundle. Re-renders the component automatically when the ready state\n * changes.\n *\n * @returns `true` when the client is ready, `false` otherwise.\n */\nexport function useLiteguardReady(): boolean {\n const client = useOptionalClient();\n return useClientValue(client, () => client?.isReady() ?? false, false);\n}\n\n/**\n * Return `true` if the named guard is open for the current context.\n * Re-renders automatically whenever the guard bundle is refreshed.\n *\n * Internally uses `peekIsOpen` so guard checks during renders do **not**\n * emit telemetry signals or consume rate-limit slots. For guarded\n * side-effects that need telemetry, call\n * `useLiteguardClient().executeIfOpen()` in an event handler or effect.\n *\n * @param name - Guard name to evaluate (e.g. `\"feature.beta\"`).\n * @param options - Optional per-call overrides (extra properties, fallback).\n * @returns `true` if the guard is open, `false` otherwise.\n *\n * @example\n * ```tsx\n * function Banner() {\n * const showBeta = useIsOpen('promo.banner');\n * if (!showBeta) return null;\n * return <div>Try our new beta!</div>;\n * }\n * ```\n */\nexport function useIsOpen(name: string, options?: Partial<Options>): boolean {\n const client = useOptionalClient();\n const fallback = options?.fallback ?? false;\n return useClientValue(client, () => client?.peekIsOpen(name, options) ?? fallback, fallback);\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,uBAAuB;AAgMrB;AA7LX,IAAM,mBAAmB,cAAsC,IAAI;AAuCnE,SAAS,gBAA4B;AACnC,SAAO,MAAM;AAAA,EAAC;AAChB;AAGA,SAAS,oBAA4C;AACnD,SAAO,WAAW,gBAAgB;AACpC;AAGA,SAAS,eAAkB,QAAgC,aAAsB,UAAgB;AAC/F,SAAO;AAAA,IACL,SAAS,OAAO,UAAU,KAAK,MAAM,IAAI;AAAA,IACzC,SAAS,cAAc,MAAM;AAAA,IAC7B,MAAM;AAAA,EACR;AACF;AA8BO,SAAS,kBAAkB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV;AACF,GAA2B;AACzB,QAAM,kBAAkB;AAAA,IACtB,OAAO;AAAA,MACL,GAAI,WAAW,CAAC;AAAA,MAChB,GAAI,gBAAgB,SAAY,EAAE,YAAY,IAAI,CAAC;AAAA,MACnD,GAAI,aAAa,SAAY,EAAE,SAAS,IAAI,CAAC;AAAA,MAC7C,GA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]}
1
+ {"version":3,"sources":["../src/provider.tsx"],"sourcesContent":["import {\n createContext,\n useContext,\n useEffect,\n useMemo,\n useState,\n useSyncExternalStore,\n type ReactNode,\n} from 'react';\nimport { LiteguardClient } from '@liteguard/liteguard-browser';\nimport type { ClientOptions, Options, Properties } from '@liteguard/liteguard-browser';\n\nconst LiteguardContext = createContext<LiteguardClient | null>(null);\n\n/** Props for {@link LiteguardProvider}. */\nexport type LiteguardProviderProps = {\n /**\n * An externally created {@link LiteguardClient} instance. When provided,\n * the provider uses this client directly and does **not** manage its\n * lifecycle (you are responsible for calling `start()` / `shutdown()`).\n */\n client?: LiteguardClient;\n /**\n * Your project client token. When provided (without `client`), the\n * provider automatically creates, starts, and shuts down a managed client.\n */\n projectClientToken?: string;\n /** Optional SDK configuration overrides for the managed client. */\n options?: ClientOptions;\n /** Optional default properties applied to the active client scope. */\n properties?: Properties;\n environment?: ClientOptions['environment'];\n fallback?: ClientOptions['fallback'];\n refreshRateSeconds?: ClientOptions['refreshRateSeconds'];\n flushRateSeconds?: ClientOptions['flushRateSeconds'];\n flushSize?: ClientOptions['flushSize'];\n backendUrl?: ClientOptions['backendUrl'];\n quiet?: ClientOptions['quiet'];\n httpTimeoutSeconds?: ClientOptions['httpTimeoutSeconds'];\n flushBufferMultiplier?: ClientOptions['flushBufferMultiplier'];\n disableMeasurement?: ClientOptions['disableMeasurement'];\n /**\n * React node rendered while the managed client is fetching its initial\n * guard bundle. Defaults to `null` (render nothing).\n */\n loading?: ReactNode;\n /** Application subtree that gains access to the Liteguard client via context. */\n children: ReactNode;\n};\n\n/** Provide a stable no-op subscription for components rendered without a client. */\nfunction subscribeNoop(): () => void {\n return () => {};\n}\n\n/** Resolve the nearest Liteguard client from React context. */\nfunction useOptionalClient(): LiteguardClient | null {\n return useContext(LiteguardContext);\n}\n\n/** Subscribe a component to client refreshes and fall back cleanly when absent. */\nfunction useClientValue<T>(client: LiteguardClient | null, getSnapshot: () => T, fallback: T): T {\n return useSyncExternalStore(\n client ? client.subscribe.bind(client) : subscribeNoop,\n client ? getSnapshot : () => fallback,\n () => fallback,\n );\n}\n\n/**\n * React context provider that makes a Liteguard client available to the\n * component tree via React context.\n *\n * **Managed mode** pass `projectClientToken` (and optional `options`) to\n * have the provider create, start, and shut down a client automatically.\n * While the initial guard bundle is loading, the optional `loading` subtree\n * is rendered instead of `children`.\n *\n * **External mode** pass a pre-configured `client` instance and the\n * provider simply makes it available through context without managing its\n * lifecycle.\n *\n * @example\n * ```tsx\n * // Managed mode\n * <LiteguardProvider projectClientToken=\"pctok_live_...\" loading={<Spinner />}>\n * <App />\n * </LiteguardProvider>\n *\n * // External mode\n * const client = new LiteguardClient('pctok_live_...');\n * await client.start();\n * <LiteguardProvider client={client}>\n * <App />\n * </LiteguardProvider>\n * ```\n */\nexport function LiteguardProvider({\n client,\n projectClientToken,\n options,\n properties,\n environment,\n fallback,\n refreshRateSeconds,\n flushRateSeconds,\n flushSize,\n backendUrl,\n quiet,\n httpTimeoutSeconds,\n flushBufferMultiplier,\n disableMeasurement,\n loading = null,\n children,\n}: LiteguardProviderProps) {\n const resolvedOptions = useMemo<ClientOptions>(\n () => ({\n ...(options ?? {}),\n ...(environment !== undefined ? { environment } : {}),\n ...(fallback !== undefined ? { fallback } : {}),\n ...(refreshRateSeconds !== undefined ? { refreshRateSeconds } : {}),\n ...(flushRateSeconds !== undefined ? { flushRateSeconds } : {}),\n ...(flushSize !== undefined ? { flushSize } : {}),\n ...(backendUrl !== undefined ? { backendUrl } : {}),\n ...(quiet !== undefined ? { quiet } : {}),\n ...(httpTimeoutSeconds !== undefined ? { httpTimeoutSeconds } : {}),\n ...(flushBufferMultiplier !== undefined ? { flushBufferMultiplier } : {}),\n ...(disableMeasurement !== undefined ? { disableMeasurement } : {}),\n }),\n [\n options,\n environment,\n fallback,\n refreshRateSeconds,\n flushRateSeconds,\n flushSize,\n backendUrl,\n quiet,\n httpTimeoutSeconds,\n flushBufferMultiplier,\n disableMeasurement,\n ],\n );\n const optionsKey = useMemo(() => JSON.stringify(resolvedOptions), [resolvedOptions]);\n const propertiesKey = useMemo(() => JSON.stringify(properties ?? {}), [properties]);\n const [managedClient, setManagedClient] = useState<LiteguardClient | null>(() => client ?? null);\n const [error, setError] = useState<unknown>(null);\n\n useEffect(() => {\n if (client) {\n setManagedClient(client);\n return;\n }\n\n if (!projectClientToken) {\n setManagedClient(null);\n return;\n }\n\n let cancelled = false;\n const nextClient = new LiteguardClient(projectClientToken, resolvedOptions);\n setManagedClient(nextClient);\n setError(null);\n\n const unsubscribe = nextClient.subscribe(() => {\n if (!cancelled) {\n setManagedClient(nextClient);\n }\n });\n\n void nextClient.start().catch((startError) => {\n if (!cancelled) {\n setError(startError);\n }\n });\n\n return () => {\n cancelled = true;\n unsubscribe();\n void nextClient.shutdown();\n };\n }, [client, projectClientToken, optionsKey, resolvedOptions]);\n\n const activeClient = client ?? managedClient;\n const ready = useClientValue(activeClient, () => activeClient?.isReady() ?? false, false);\n\n useEffect(() => {\n if (!activeClient) {\n return;\n }\n\n activeClient.resetProperties();\n if (properties && Object.keys(properties).length > 0) {\n activeClient.addProperties(properties);\n }\n }, [activeClient, propertiesKey, properties]);\n\n if (error) {\n throw error;\n }\n if (projectClientToken && !ready) {\n return <>{loading}</>;\n }\n\n return <LiteguardContext.Provider value={activeClient}>{children}</LiteguardContext.Provider>;\n}\n\n/**\n * Return the nearest Liteguard client from React context, or `null` if no\n * provider is present.\n *\n * Prefer {@link useLiteguardClient} when you need to assert that a client\n * is available.\n *\n * @returns The {@link LiteguardClient}, or `null`.\n */\nexport function useLiteguard(): LiteguardClient | null {\n return useOptionalClient();\n}\n\n/**\n * Return the nearest Liteguard client from React context. Throws if no\n * client is available. Ensures the component is rendered inside a\n * {@link LiteguardProvider}.\n *\n * @returns The {@link LiteguardClient}.\n * @throws {Error} When no Liteguard client is reachable.\n */\nexport function useLiteguardClient(): LiteguardClient {\n const client = useOptionalClient();\n if (!client) {\n throw new Error(\n '[liteguard] No Liteguard React client available. Wrap your app in LiteguardProvider.',\n );\n }\n return client;\n}\n\n/**\n * Returns `true` once the Liteguard client has fetched its initial guard\n * bundle. Re-renders the component automatically when the ready state\n * changes.\n *\n * @returns `true` when the client is ready, `false` otherwise.\n */\nexport function useLiteguardReady(): boolean {\n const client = useOptionalClient();\n return useClientValue(client, () => client?.isReady() ?? false, false);\n}\n\n/**\n * Return `true` if the named guard is open for the current context.\n * Re-renders automatically whenever the guard bundle is refreshed.\n *\n * Internally uses `peekIsOpen` so guard checks during renders do **not**\n * emit telemetry signals or consume rate-limit slots. For guarded\n * side-effects that need telemetry, call\n * `useLiteguardClient().executeIfOpen()` in an event handler or effect.\n *\n * @param name - Guard name to evaluate (e.g. `\"feature.beta\"`).\n * @param options - Optional per-call overrides (extra properties, fallback).\n * @returns `true` if the guard is open, `false` otherwise.\n *\n * @example\n * ```tsx\n * function Banner() {\n * const showBeta = useIsOpen('promo.banner');\n * if (!showBeta) return null;\n * return <div>Try our new beta!</div>;\n * }\n * ```\n */\nexport function useIsOpen(name: string, options?: Partial<Options>): boolean {\n const client = useOptionalClient();\n const fallback = options?.fallback ?? false;\n return useClientValue(client, () => client?.peekIsOpen(name, options) ?? fallback, fallback);\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,uBAAuB;AAgMrB;AA7LX,IAAM,mBAAmB,cAAsC,IAAI;AAuCnE,SAAS,gBAA4B;AACnC,SAAO,MAAM;AAAA,EAAC;AAChB;AAGA,SAAS,oBAA4C;AACnD,SAAO,WAAW,gBAAgB;AACpC;AAGA,SAAS,eAAkB,QAAgC,aAAsB,UAAgB;AAC/F,SAAO;AAAA,IACL,SAAS,OAAO,UAAU,KAAK,MAAM,IAAI;AAAA,IACzC,SAAS,cAAc,MAAM;AAAA,IAC7B,MAAM;AAAA,EACR;AACF;AA8BO,SAAS,kBAAkB;AAAA,EAChC;AAAA,EACA;AAA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AACX,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AASO,SAAS,oBAA6B;AAC3C,QAAM,SAAS,kBAAkB;AACjC,SAAO,eAAe,QAAQ,MAAM,QAAQ,QAAQ,KAAK,OAAO,KAAK;AACvE;AAwBO,SAAS,UAAU,MAAc,SAAqC;AAC3E,QAAM,SAAS,kBAAkB;AACjC,QAAM,WAAW,SAAS,YAAY;AACtC,SAAO,eAAe,QAAQ,MAAM,QAAQ,WAAW,MAAM,OAAO,KAAK,UAAU,QAAQ;AAC7F;","names":[]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@liteguard/liteguard-react",
3
- "version": "0.2.20260314",
4
- "description": "React bindings for Liteguard feature guards, observability, and CVE auto-disable via LiteguardProvider and useIsOpen hook",
3
+ "version": "0.3.20260315",
4
+ "description": "React bindings for Liteguard. Feature guards, observability, and CVE auto-disable via LiteguardProvider and useIsOpen hook",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.ts",