Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@parca/hooks

Package Overview
Dependencies
Maintainers
4
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@parca/hooks - npm Package Compare versions

Comparing version 0.0.8 to 0.0.9

4

CHANGELOG.md

@@ -6,2 +6,6 @@ # Change Log

## 0.0.9 (2023-06-15)
**Note:** Version bump only for package @parca/hooks
## 0.0.8 (2023-05-03)

@@ -8,0 +12,0 @@

16

dist/useContainerDimensions/index.js

@@ -14,7 +14,7 @@ // Copyright 2022 The Parca Authors

import { useEffect, useRef, useState } from 'react';
var useContainerDimensions = function () {
var ref = useRef(null);
var _a = useState(), dimensions = _a[0], setDimensions = _a[1];
useEffect(function () {
var updateDimensions = function () { var _a; return setDimensions((_a = ref.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect()); };
const useContainerDimensions = () => {
const ref = useRef(null);
const [dimensions, setDimensions] = useState();
useEffect(() => {
const updateDimensions = () => setDimensions(ref.current?.getBoundingClientRect());
updateDimensions();

@@ -24,8 +24,8 @@ if (ref.current == null) {

}
var observer = new ResizeObserver(updateDimensions);
const observer = new ResizeObserver(updateDimensions);
observer.observe(ref.current);
return function () { return observer.disconnect(); };
return () => observer.disconnect();
}, []);
return { dimensions: dimensions, ref: ref };
return { dimensions, ref };
};
export default useContainerDimensions;

@@ -13,28 +13,16 @@ // Copyright 2022 The Parca Authors

// limitations under the License.
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
import { useLocalStorage } from '@rehooks/local-storage';
import pick from 'lodash/pick';
var UI_FLAGS = 'ui-flags';
var initializeFlagsFromURL = function () {
var _a;
const UI_FLAGS = 'ui-flags';
const initializeFlagsFromURL = () => {
if (typeof window === 'undefined') {
return;
}
var url = new URL(window.location.href);
var enableFlag = url.searchParams.get('enable-ui-flag');
var disableFlag = url.searchParams.get('disable-ui-flag');
const url = new URL(window.location.href);
const enableFlag = url.searchParams.get('enable-ui-flag');
const disableFlag = url.searchParams.get('disable-ui-flag');
if (enableFlag !== null && disableFlag !== null) {
return;
}
var flags = JSON.parse((_a = window.localStorage.getItem(UI_FLAGS)) !== null && _a !== void 0 ? _a : '{}');
let flags = JSON.parse(window.localStorage.getItem(UI_FLAGS) ?? '{}');
if (enableFlag !== null) {

@@ -53,10 +41,7 @@ flags[enableFlag] = true;

initializeFlagsFromURL();
var useUIFeatureFlag = function (featureFlag, defaultValue) {
var _a;
if (defaultValue === void 0) { defaultValue = false; }
var _b = useLocalStorage(UI_FLAGS, {}), flags = _b[0], setFlags = _b[1];
var value = (_a = flags[featureFlag]) !== null && _a !== void 0 ? _a : defaultValue;
var setFlag = function (flag) {
var _a;
setFlags(__assign(__assign({}, flags), (_a = {}, _a[featureFlag] = flag, _a)));
const useUIFeatureFlag = (featureFlag, defaultValue = false) => {
const [flags, setFlags] = useLocalStorage(UI_FLAGS, {});
const value = flags[featureFlag] ?? defaultValue;
const setFlag = (flag) => {
setFlags({ ...flags, [featureFlag]: flag });
};

@@ -63,0 +48,0 @@ return [value, setFlag];

@@ -13,16 +13,5 @@ // Copyright 2022 The Parca Authors

// limitations under the License.
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
import { useLocalStorage } from '@rehooks/local-storage';
var USER_PREFERENCES_KEY = 'user-preferences';
export var USER_PREFERENCES = {
const USER_PREFERENCES_KEY = 'user-preferences';
export const USER_PREFERENCES = {
HIGHTLIGHT_AFTER_FILTERING: {

@@ -47,9 +36,7 @@ name: 'Highlight matching nodes after filtering',

};
var useUserPreference = function (preferenceName) {
var _a;
var _b = useLocalStorage(USER_PREFERENCES_KEY, {}), flags = _b[0], setFlags = _b[1];
var value = (_a = flags[preferenceName]) !== null && _a !== void 0 ? _a : USER_PREFERENCES[preferenceName].default;
var setFlag = function (flag) {
var _a;
setFlags(__assign(__assign({}, flags), (_a = {}, _a[preferenceName] = flag, _a)));
const useUserPreference = (preferenceName) => {
const [flags, setFlags] = useLocalStorage(USER_PREFERENCES_KEY, {});
const value = flags[preferenceName] ?? USER_PREFERENCES[preferenceName].default;
const setFlag = (flag) => {
setFlags({ ...flags, [preferenceName]: flag });
};

@@ -56,0 +43,0 @@ return [value, setFlag];

{
"name": "@parca/hooks",
"version": "0.0.8",
"version": "0.0.9",
"description": "A library containing React hooks used in the Parca UI",

@@ -13,3 +13,3 @@ "main": "dist/index.js",

"dependencies": {
"@parca/client": "^0.16.73",
"@parca/client": "^0.16.74",
"@rehooks/local-storage": "^2.4.4"

@@ -24,3 +24,3 @@ },

},
"gitHead": "fc53e202779c1b0d5c46cdfd6bafa7d0396956a4"
"gitHead": "e1dc36ad29a6efe06f45460bb721325df9416a6b"
}
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