New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@unleash/proxy-client-react

Package Overview
Dependencies
Maintainers
0
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@unleash/proxy-client-react - npm Package Compare versions

Comparing version 4.2.4 to 4.3.0

dist/useFlagStatus.test.d.ts

2

dist/FlagContext.d.ts
import React from 'react';
import type { UnleashClient } from 'unleash-proxy-client';
export interface IFlagContextValue extends Pick<UnleashClient, 'on' | 'updateContext' | 'isEnabled' | 'getVariant'> {
export interface IFlagContextValue extends Pick<UnleashClient, 'on' | 'off' | 'updateContext' | 'isEnabled' | 'getVariant'> {
client: UnleashClient;

@@ -5,0 +5,0 @@ flagsReady: boolean;

/** @format */
import * as React from 'react';
import { IConfig, UnleashClient } from 'unleash-proxy-client';
import { type FC, type PropsWithChildren } from 'react';
import { type IConfig, UnleashClient } from 'unleash-proxy-client';
export interface IFlagProvider {

@@ -8,4 +8,5 @@ config?: IConfig;

startClient?: boolean;
stopClient?: boolean;
}
declare const FlagProvider: React.FC<React.PropsWithChildren<IFlagProvider>>;
declare const FlagProvider: FC<PropsWithChildren<IFlagProvider>>;
export default FlagProvider;

@@ -1,6 +0,5 @@

import { UnleashClient as _ } from "unleash-proxy-client";
import { InMemoryStorageProvider as G, LocalStorageProvider as J, UnleashClient as Q } from "unleash-proxy-client";
import * as d from "react";
import k, { useContext as i, useState as h, useRef as R, useEffect as E } from "react";
const f = k.createContext(null), A = {
import { UnleashClient as k } from "unleash-proxy-client";
import { InMemoryStorageProvider as J, LocalStorageProvider as Q, UnleashClient as W } from "unleash-proxy-client";
import g, { useState as b, useEffect as y, useMemo as A, useContext as p, useRef as H } from "react";
const d = g.createContext(null), P = {
bootstrap: [],

@@ -12,15 +11,17 @@ disableRefresh: !0,

clientKey: "not-used"
}, P = "startTransition", v = d[P] || ((e) => e()), I = ({
}, M = "startTransition", x = g[M] || ((e) => e()), O = ({
config: e,
children: t,
unleashClient: o,
startClient: s = !0
startClient: c = !0,
stopClient: l = !0
}) => {
const c = e || A, r = d.useRef(
o || new _(c)
), [l, 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);
d.useEffect(() => {
!c && !o && console.error(
var F, h, T;
const s = e || P, r = g.useRef(
o || new k(s)
), [u, n] = g.useState(
!!(o ? e != null && e.bootstrap && (e == null ? void 0 : e.bootstrapOverride) !== !1 || (F = o.isReady) != null && F.call(o) : s.bootstrap && s.bootstrapOverride !== !1)
), [R, v] = b(((T = (h = r.current).getError) == null ? void 0 : T.call(h)) || null);
y(() => {
!s && !o && console.error(
`You must provide either a config or an unleash client to the flag provider.

@@ -30,112 +31,111 @@ If you are initializing the client in useEffect, you can avoid this warning

);
const a = (y) => {
v(() => {
b((U) => U || y);
const a = (E) => {
x(() => {
v((U) => U || E);
});
}, g = (y) => {
v(() => {
b(null);
}, f = (E) => {
x(() => {
v(null);
});
};
let p;
const x = () => {
p = setTimeout(() => {
v(() => {
u(!0);
let i = null;
const m = () => {
i = setTimeout(() => {
x(() => {
n(!0);
});
}, 0);
};
return r.current.on("ready", x), r.current.on("error", a), r.current.on("recovered", g), s && (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);
return r.current.on("ready", m), r.current.on("error", a), r.current.on("recovered", f), c && (r.current.stop(), r.current.start()), function() {
r.current && (r.current.off("error", a), r.current.off("ready", m), r.current.off("recovered", f), l && r.current.stop()), i && clearTimeout(i);
};
}, []);
const F = async (a) => {
await r.current.updateContext(a);
}, m = (a) => r.current.isEnabled(a), T = (a) => r.current.getVariant(a), S = (a, g, p) => r.current.on(a, g, p), H = d.useMemo(
const S = A(
() => ({
on: S,
updateContext: F,
isEnabled: m,
getVariant: T,
on: (a, f, i) => r.current.on(a, f, i),
off: (a, f) => r.current.off(a, f),
updateContext: async (a) => await r.current.updateContext(a),
isEnabled: (a) => r.current.isEnabled(a),
getVariant: (a) => r.current.getVariant(a),
client: r.current,
flagsReady: l,
flagsError: n,
setFlagsReady: u,
setFlagsError: b
flagsReady: u,
flagsError: R,
setFlagsReady: n,
setFlagsError: v
}),
[l, n]
[u, R]
);
return /* @__PURE__ */ d.createElement(f.Provider, { value: H }, t);
}, O = (e) => {
const { isEnabled: t, client: o } = i(f), [s, c] = h(!!t(e)), r = R();
return r.current = s, E(() => {
return /* @__PURE__ */ g.createElement(d.Provider, { value: S }, t);
}, z = (e) => {
const { isEnabled: t, client: o } = p(d), [c, l] = b(!!t(e)), s = H();
return s.current = c, y(() => {
if (!o)
return;
const l = () => {
const r = () => {
const n = t(e);
n !== r.current && (r.current = n, c(!!n));
n !== s.current && (s.current = n, l(!!n));
}, u = () => {
const n = t(e);
r.current = n, c(n);
s.current = n, l(n);
};
return o.on("update", l), o.on("ready", u), () => {
o.off("update", l), o.off("ready", u);
return o.on("update", r), o.on("ready", u), () => {
o.off("update", r), o.off("ready", u);
};
}, [o]), s;
}, z = () => {
const { client: e } = i(f), [t, o] = h(e.getAllToggles());
return E(() => {
const s = () => {
}, [o]), c;
}, B = () => {
const { client: e } = p(d), [t, o] = b(e.getAllToggles());
return y(() => {
const c = () => {
o(e.getAllToggles());
};
return e.on("update", s), () => {
e.off("update", s);
return e.on("update", c), () => {
e.off("update", c);
};
}, []), t;
}, B = () => {
const { flagsReady: e, flagsError: t } = i(f);
}, K = () => {
const { flagsReady: e, flagsError: t } = p(d);
return { flagsReady: e, flagsError: t };
}, C = (e, t) => {
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));
}, K = (e) => {
const { getVariant: t, client: o } = i(f), [s, c] = h(t(e)), r = R({
name: s.name,
enabled: s.enabled
}, _ = (e, t) => {
var c, l, s, r;
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) && ((c = e.payload) == null ? void 0 : c.type) === ((l = t == null ? void 0 : t.payload) == null ? void 0 : l.type) && ((s = e.payload) == null ? void 0 : s.value) === ((r = t == null ? void 0 : t.payload) == null ? void 0 : r.value));
}, L = (e) => {
const { getVariant: t, client: o } = p(d), [c, l] = b(t(e)), s = H({
name: c.name,
enabled: c.enabled
});
return r.current = s, E(() => {
return s.current = c, y(() => {
if (!o)
return;
const l = () => {
const r = () => {
const n = t(e);
C(r.current, n) && (c(n), r.current = n);
_(s.current, n) && (l(n), s.current = n);
}, 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);
s.current.name = n == null ? void 0 : n.name, s.current.enabled = n == null ? void 0 : n.enabled, l(n);
};
return o.on("update", l), o.on("ready", u), () => {
o.off("update", l), o.off("ready", u);
return o.on("update", r), o.on("ready", u), () => {
o.off("update", r), o.off("ready", u);
};
}, [o]), s || {};
}, L = () => {
const { updateContext: e } = i(f);
return e;
}, [o]), c || {};
}, Y = () => {
const { client: e } = i(f);
const { updateContext: e } = p(d);
return e;
}, j = () => {
const { client: e } = p(d);
return e;
};
export {
f as FlagContext,
I as FlagProvider,
G as InMemoryStorageProvider,
J as LocalStorageProvider,
Q as UnleashClient,
I as default,
O as useFlag,
z as useFlags,
B as useFlagsStatus,
Y as useUnleashClient,
L as useUnleashContext,
K as useVariant
d as FlagContext,
O as FlagProvider,
J as InMemoryStorageProvider,
Q as LocalStorageProvider,
W as UnleashClient,
O as default,
z as useFlag,
B as useFlags,
K as useFlagsStatus,
j as useUnleashClient,
Y as useUnleashContext,
L as useVariant
};
//# sourceMappingURL=unleash-react.js.map
{
"name": "@unleash/proxy-client-react",
"version": "4.2.4",
"version": "4.3.0",
"description": "React interface for working with unleash",

@@ -53,3 +53,3 @@ "type": "module",

"typescript": "^5.3.2",
"unleash-proxy-client": "^3.4.0",
"unleash-proxy-client": "^3.5.1",
"vite": "^4.5.0",

@@ -60,4 +60,4 @@ "vite-plugin-dts": "^3.6.3",

"peerDependencies": {
"unleash-proxy-client": "^3.4.0"
"unleash-proxy-client": "^3.5.1"
}
}

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc