@splitlab/react 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +9 -2
- package/dist/index.d.ts +9 -2
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var p=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var b=(e,t)=>{for(var o in t)p(e,o,{get:t[o],enumerable:!0})},d=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of u(t))!f.call(e,i)&&i!==o&&p(e,i,{get:()=>t[i],enumerable:!(n=c(t,i))||n.enumerable});return e};var S=e=>d(p({},"__esModule",{value:!0}),e);var x={};b(x,{SplitLabBootstrapProvider:()=>m,SplitLabProvider:()=>L,useFeatureFlag:()=>v,useSplitLab:()=>P,useVariant:()=>g});module.exports=S(x);var r=require("react"),s=require("@splitlab/js-client"),a=(0,r.createContext)(null);function L({config:e,children:t}){let[o,n]=(0,r.useState)(null),i=(0,r.useRef)(e);return(0,r.useEffect)(()=>{let l=new s.SplitLabClient(i.current);return l.initialize().then(()=>n(l)),()=>{l.destroy()}},[]),(0,r.createElement)(a.Provider,{value:o},t)}function m({config:e,bootstrap:t,children:o}){let n=(0,r.useMemo)(()=>{let i=new s.SplitLabClient({...e,bootstrap:t});return i.hydrateFromBootstrap(t),i},[]);return(0,r.useEffect)(()=>(n.initialize(),()=>{n.destroy()}),[n]),(0,r.createElement)(a.Provider,{value:n},o)}function P(){let e=(0,r.useContext)(a);if(!e)throw new Error("useSplitLab must be used within a <SplitLabProvider>. Make sure the provider has finished initializing.");return e}function g(e){let t=(0,r.useContext)(a);return t?t.getVariant(e):null}function v(e){let t=(0,r.useContext)(a);return t?t.isFeatureEnabled(e):!1}0&&(module.exports={SplitLabBootstrapProvider,SplitLabProvider,useFeatureFlag,useSplitLab,useVariant});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { SplitLabConfig, SplitLabClient } from '@splitlab/js-client';
|
|
3
|
+
import { SplitLabConfig, BootstrapData, SplitLabClient } from '@splitlab/js-client';
|
|
4
|
+
export { BootstrapData } from '@splitlab/js-client';
|
|
4
5
|
|
|
5
6
|
interface SplitLabProviderProps {
|
|
6
7
|
config: SplitLabConfig;
|
|
7
8
|
children: ReactNode;
|
|
8
9
|
}
|
|
9
10
|
declare function SplitLabProvider({ config, children }: SplitLabProviderProps): react.FunctionComponentElement<react.ProviderProps<SplitLabClient | null>>;
|
|
11
|
+
interface SplitLabBootstrapProviderProps {
|
|
12
|
+
config: SplitLabConfig;
|
|
13
|
+
bootstrap: BootstrapData;
|
|
14
|
+
children: ReactNode;
|
|
15
|
+
}
|
|
16
|
+
declare function SplitLabBootstrapProvider({ config, bootstrap, children }: SplitLabBootstrapProviderProps): react.FunctionComponentElement<react.ProviderProps<SplitLabClient | null>>;
|
|
10
17
|
declare function useSplitLab(): SplitLabClient;
|
|
11
18
|
declare function useVariant(experimentKey: string): string | null;
|
|
12
19
|
declare function useFeatureFlag(flagKey: string): boolean;
|
|
13
20
|
|
|
14
|
-
export { SplitLabProvider, type SplitLabProviderProps, useFeatureFlag, useSplitLab, useVariant };
|
|
21
|
+
export { SplitLabBootstrapProvider, type SplitLabBootstrapProviderProps, SplitLabProvider, type SplitLabProviderProps, useFeatureFlag, useSplitLab, useVariant };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { SplitLabConfig, SplitLabClient } from '@splitlab/js-client';
|
|
3
|
+
import { SplitLabConfig, BootstrapData, SplitLabClient } from '@splitlab/js-client';
|
|
4
|
+
export { BootstrapData } from '@splitlab/js-client';
|
|
4
5
|
|
|
5
6
|
interface SplitLabProviderProps {
|
|
6
7
|
config: SplitLabConfig;
|
|
7
8
|
children: ReactNode;
|
|
8
9
|
}
|
|
9
10
|
declare function SplitLabProvider({ config, children }: SplitLabProviderProps): react.FunctionComponentElement<react.ProviderProps<SplitLabClient | null>>;
|
|
11
|
+
interface SplitLabBootstrapProviderProps {
|
|
12
|
+
config: SplitLabConfig;
|
|
13
|
+
bootstrap: BootstrapData;
|
|
14
|
+
children: ReactNode;
|
|
15
|
+
}
|
|
16
|
+
declare function SplitLabBootstrapProvider({ config, bootstrap, children }: SplitLabBootstrapProviderProps): react.FunctionComponentElement<react.ProviderProps<SplitLabClient | null>>;
|
|
10
17
|
declare function useSplitLab(): SplitLabClient;
|
|
11
18
|
declare function useVariant(experimentKey: string): string | null;
|
|
12
19
|
declare function useFeatureFlag(flagKey: string): boolean;
|
|
13
20
|
|
|
14
|
-
export { SplitLabProvider, type SplitLabProviderProps, useFeatureFlag, useSplitLab, useVariant };
|
|
21
|
+
export { SplitLabBootstrapProvider, type SplitLabBootstrapProviderProps, SplitLabProvider, type SplitLabProviderProps, useFeatureFlag, useSplitLab, useVariant };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createElement as
|
|
1
|
+
import{createElement as p,createContext as u,useContext as l,useEffect as s,useState as f,useRef as b,useMemo as d}from"react";import{SplitLabClient as c}from"@splitlab/js-client";var i=u(null);function m({config:t,children:e}){let[o,r]=f(null),n=b(t);return s(()=>{let a=new c(n.current);return a.initialize().then(()=>r(a)),()=>{a.destroy()}},[]),p(i.Provider,{value:o},e)}function P({config:t,bootstrap:e,children:o}){let r=d(()=>{let n=new c({...t,bootstrap:e});return n.hydrateFromBootstrap(e),n},[]);return s(()=>(r.initialize(),()=>{r.destroy()}),[r]),p(i.Provider,{value:r},o)}function g(){let t=l(i);if(!t)throw new Error("useSplitLab must be used within a <SplitLabProvider>. Make sure the provider has finished initializing.");return t}function v(t){let e=l(i);return e?e.getVariant(t):null}function x(t){let e=l(i);return e?e.isFeatureEnabled(t):!1}export{P as SplitLabBootstrapProvider,m as SplitLabProvider,x as useFeatureFlag,g as useSplitLab,v as useVariant};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@splitlab/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "React bindings for SplitLab A/B testing and feature flags",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"dev": "tsup --watch"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@splitlab/js-client": "^0.
|
|
33
|
+
"@splitlab/js-client": "^0.6.0"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"react": ">=18"
|