@unleash/proxy-client-react
Advanced tools
Comparing version 4.1.2-beta.0 to 4.1.2
import { UnleashClient as _ } from "unleash-proxy-client"; | ||
import { InMemoryStorageProvider as G, LocalStorageProvider as J, UnleashClient as Q } from "unleash-proxy-client"; | ||
import { InMemoryStorageProvider as J, LocalStorageProvider as Q, UnleashClient as W } from "unleash-proxy-client"; | ||
import * as d from "react"; | ||
@@ -15,12 +15,12 @@ import k, { useContext as i, useState as h, useRef as R, useEffect as E } from "react"; | ||
children: t, | ||
unleashClient: o, | ||
unleashClient: n, | ||
startClient: s = !0 | ||
}) => { | ||
const c = e || A, r = d.useRef( | ||
o || new _(c) | ||
), [a, u] = d.useState( | ||
!!(o ? e != null && e.bootstrap && (e == null ? void 0 : e.bootstrapOverride) !== !1 : c.bootstrap && c.bootstrapOverride !== !1) | ||
), [n, b] = d.useState(null); | ||
n || new _(c) | ||
), [l, u] = d.useState( | ||
!!(n ? e != null && e.bootstrap && (e == null ? void 0 : e.bootstrapOverride) !== !1 : c.bootstrap && c.bootstrapOverride !== !1) | ||
), [o, b] = d.useState(null); | ||
d.useEffect(() => { | ||
!c && !o && console.error( | ||
!c && !n && console.error( | ||
`You must provide either a config or an unleash client to the flag provider. | ||
@@ -30,3 +30,3 @@ If you are initializing the client in useEffect, you can avoid this warning | ||
); | ||
const l = (y) => { | ||
const a = (y) => { | ||
v(() => { | ||
@@ -48,9 +48,9 @@ b((U) => U || y); | ||
}; | ||
return r.current.on("ready", x), r.current.on("error", l), r.current.on("recovered", g), (s || !o) && (r.current.stop(), r.current.start()), function() { | ||
r.current && (r.current.off("error", l), r.current.off("ready", x), r.current.off("recovered", g), r.current.stop()), p && clearTimeout(p); | ||
return r.current.on("ready", x), r.current.on("error", a), r.current.on("recovered", g), (s || !n) && (r.current.stop(), r.current.start()), function() { | ||
r.current && (r.current.off("error", a), r.current.off("ready", x), r.current.off("recovered", g), r.current.stop()), p && clearTimeout(p); | ||
}; | ||
}, []); | ||
const F = async (l) => { | ||
await r.current.updateContext(l); | ||
}, S = (l) => r.current.isEnabled(l), m = (l) => r.current.getVariant(l), T = (l, g, p) => r.current.on(l, g, p), H = d.useMemo( | ||
const F = async (a) => { | ||
await r.current.updateContext(a); | ||
}, S = (a) => r.current.isEnabled(a), m = (a) => r.current.getVariant(a), T = (a, g, p) => r.current.on(a, g, p), H = d.useMemo( | ||
() => ({ | ||
@@ -62,31 +62,31 @@ on: T, | ||
client: r.current, | ||
flagsReady: a, | ||
flagsError: n, | ||
flagsReady: l, | ||
flagsError: o, | ||
setFlagsReady: u, | ||
setFlagsError: b | ||
}), | ||
[a, n] | ||
[l, o] | ||
); | ||
return /* @__PURE__ */ d.createElement(f.Provider, { value: H }, t); | ||
}, z = (e) => { | ||
const { isEnabled: t, client: o } = i(f), [s, c] = h(!!t(e)), r = R(); | ||
const { isEnabled: t, client: n } = i(f), [s, c] = h(!!t(e)), r = R(); | ||
return r.current = s, E(() => { | ||
if (!o) | ||
if (!n) | ||
return; | ||
const a = () => { | ||
const n = t(e); | ||
n !== r.current && (r.current = n, c(!!n)); | ||
const l = () => { | ||
const o = t(e); | ||
o !== r.current && (r.current = o, c(!!o)); | ||
}, u = () => { | ||
const n = t(e); | ||
r.current = n, c(n); | ||
const o = t(e); | ||
r.current = o, c(o); | ||
}; | ||
return o.on("update", a), o.on("ready", u), () => { | ||
o.off("update", a), o.off("ready", u); | ||
return n.on("update", l), n.on("ready", u), () => { | ||
n.off("update", l), n.off("ready", u); | ||
}; | ||
}, [o]), s; | ||
}, [n]), s; | ||
}, B = () => { | ||
const { client: e } = i(f), [t, o] = h(e.getAllToggles()); | ||
const { client: e } = i(f), [t, n] = h(e.getAllToggles()); | ||
return E(() => { | ||
const s = () => { | ||
o(e.getAllToggles()); | ||
n(e.getAllToggles()); | ||
}; | ||
@@ -101,6 +101,6 @@ return e.on("update", s), () => { | ||
}, P = (e, t) => { | ||
var s, c, r, a; | ||
return !(e.name === (t == null ? void 0 : t.name) && e.enabled === (t == null ? void 0 : t.enabled) && e.feature_enabled === (t == null ? void 0 : t.feature_enabled) && ((s = e.payload) == null ? void 0 : s.type) === ((c = t == null ? void 0 : t.payload) == null ? void 0 : c.type) && ((r = e.payload) == null ? void 0 : r.value) === ((a = t == null ? void 0 : t.payload) == null ? void 0 : a.value)); | ||
var s, c, r, l; | ||
return !(e.name === (t == null ? void 0 : t.name) && e.enabled === (t == null ? void 0 : t.enabled) && e.feature_enabled === (t == null ? void 0 : t.feature_enabled) && ((s = e.payload) == null ? void 0 : s.type) === ((c = t == null ? void 0 : t.payload) == null ? void 0 : c.type) && ((r = e.payload) == null ? void 0 : r.value) === ((l = t == null ? void 0 : t.payload) == null ? void 0 : l.value)); | ||
}, L = (e) => { | ||
const { getVariant: t, client: o } = i(f), [s, c] = h(t(e)), r = R({ | ||
const { getVariant: t, client: n } = i(f), [s, c] = h(t(e)), r = R({ | ||
name: s.name, | ||
@@ -110,19 +110,19 @@ enabled: s.enabled | ||
return r.current = s, E(() => { | ||
if (!o) | ||
if (!n) | ||
return; | ||
const a = () => { | ||
const n = t(e); | ||
P(r.current, n) && (c(n), r.current = n); | ||
const l = () => { | ||
const o = t(e); | ||
P(r.current, o) && (c(o), r.current = o); | ||
}, u = () => { | ||
const n = t(e); | ||
r.current.name = n == null ? void 0 : n.name, r.current.enabled = n == null ? void 0 : n.enabled, c(n); | ||
const o = t(e); | ||
r.current.name = o == null ? void 0 : o.name, r.current.enabled = o == null ? void 0 : o.enabled, c(o); | ||
}; | ||
return o.on("update", a), o.on("ready", u), () => { | ||
o.off("update", a), o.off("ready", u); | ||
return n.on("update", l), n.on("ready", u), () => { | ||
n.off("update", l), n.off("ready", u); | ||
}; | ||
}, [o]), s || {}; | ||
}, N = () => { | ||
}, [n]), s || {}; | ||
}, Y = () => { | ||
const { updateContext: e } = i(f); | ||
return e; | ||
}, Y = () => { | ||
}, j = () => { | ||
const { client: e } = i(f); | ||
@@ -134,5 +134,5 @@ return e; | ||
O as FlagProvider, | ||
G as InMemoryStorageProvider, | ||
J as LocalStorageProvider, | ||
Q as UnleashClient, | ||
J as InMemoryStorageProvider, | ||
Q as LocalStorageProvider, | ||
W as UnleashClient, | ||
O as default, | ||
@@ -142,6 +142,6 @@ z as useFlag, | ||
K as useFlagsStatus, | ||
Y as useUnleashClient, | ||
N as useUnleashContext, | ||
j as useUnleashClient, | ||
Y as useUnleashContext, | ||
L as useVariant | ||
}; | ||
//# sourceMappingURL=unleash-react.js.map |
@@ -1,2 +0,2 @@ | ||
declare const useFlag: (name: string) => boolean; | ||
declare const useFlag: (featureName: string) => boolean; | ||
export default useFlag; |
import { IVariant } from 'unleash-proxy-client'; | ||
export declare const variantHasChanged: (oldVariant: IVariant, newVariant?: IVariant) => boolean; | ||
declare const useVariant: (name: string) => Partial<IVariant>; | ||
declare const useVariant: (featureName: string) => Partial<IVariant>; | ||
export default useVariant; |
{ | ||
"name": "@unleash/proxy-client-react", | ||
"version": "4.1.2-beta.0", | ||
"version": "4.1.2", | ||
"description": "React interface for working with unleash", | ||
@@ -53,3 +53,3 @@ "type": "module", | ||
"typescript": "^5.3.2", | ||
"unleash-proxy-client": "^3.3.0-beta.1", | ||
"unleash-proxy-client": "^3.3.1", | ||
"vite": "^4.5.0", | ||
@@ -56,0 +56,0 @@ "vite-plugin-dts": "^3.6.3", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
61609
2