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

@fluentui/react-context-selector

Package Overview
Dependencies
Maintainers
13
Versions
870
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fluentui/react-context-selector - npm Package Compare versions

Comparing version 0.0.0-nightly0e0cf06c3420211029.1 to 0.0.0-nightly57a9843f2620211119.1

41

CHANGELOG.json

@@ -5,5 +5,5 @@ {

{
"date": "Fri, 29 Oct 2021 06:39:57 GMT",
"tag": "@fluentui/react-context-selector_v0.0.0-nightly0e0cf06c3420211029.1",
"version": "0.0.0-nightly0e0cf06c3420211029.1",
"date": "Fri, 19 Nov 2021 04:18:54 GMT",
"tag": "@fluentui/react-context-selector_v0.0.0-nightly57a9843f2620211119.1",
"version": "0.0.0-nightly57a9843f2620211119.1",
"comments": {

@@ -14,3 +14,3 @@ "prerelease": [

"package": "@fluentui/react-context-selector",
"commit": "3535f78f7af73f13f2c1e7470293fb5e592866de",
"commit": "e6017db01058700b10f0f2b6b36ef51efb28b9b9",
"comment": "Release nightly v9"

@@ -21,4 +21,4 @@ },

"package": "@fluentui/react-context-selector",
"comment": "Bump @fluentui/react-utilities to v0.0.0-nightly0e0cf06c3420211029.1",
"commit": "3535f78f7af73f13f2c1e7470293fb5e592866de"
"comment": "Bump @fluentui/react-utilities to v0.0.0-nightly57a9843f2620211119.1",
"commit": "e6017db01058700b10f0f2b6b36ef51efb28b9b9"
}

@@ -29,2 +29,31 @@ ]

{
"date": "Fri, 12 Nov 2021 13:25:22 GMT",
"tag": "@fluentui/react-context-selector_v9.0.0-beta.3",
"version": "9.0.0-beta.3",
"comments": {
"none": [
{
"author": "lingfangao@hotmail.com",
"package": "@fluentui/react-context-selector",
"commit": "00f70581480b536e723fb69edf0ae617beac4807",
"comment": "Remove beta release tag"
}
],
"prerelease": [
{
"author": "gcox@microsoft.com",
"package": "@fluentui/react-context-selector",
"commit": "c9bd5b5a02ae94a8239ce1b56cac2f0d0dbd3586",
"comment": "Updated beta and RC components to ES2019"
},
{
"author": "beachball",
"package": "@fluentui/react-context-selector",
"comment": "Bump @fluentui/react-utilities to v9.0.0-beta.3",
"commit": "742342e52c65066f779232e4e1302fedf0dd460d"
}
]
}
},
{
"date": "Wed, 27 Oct 2021 12:14:24 GMT",

@@ -31,0 +60,0 @@ "tag": "@fluentui/react-context-selector_v9.0.0-beta.2",

22

CHANGELOG.md
# Change Log - @fluentui/react-context-selector
This log was last generated on Fri, 29 Oct 2021 06:39:57 GMT and should not be manually modified.
This log was last generated on Fri, 19 Nov 2021 04:18:54 GMT and should not be manually modified.
<!-- Start content -->
## [0.0.0-nightly0e0cf06c3420211029.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-context-selector_v0.0.0-nightly0e0cf06c3420211029.1)
## [0.0.0-nightly57a9843f2620211119.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-context-selector_v0.0.0-nightly57a9843f2620211119.1)
Fri, 29 Oct 2021 06:39:57 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-context-selector_v9.0.0-beta.2..@fluentui/react-context-selector_v0.0.0-nightly0e0cf06c3420211029.1)
Fri, 19 Nov 2021 04:18:54 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-context-selector_v9.0.0-beta.3..@fluentui/react-context-selector_v0.0.0-nightly57a9843f2620211119.1)
### Changes
- Release nightly v9 ([commit](https://github.com/microsoft/fluentui/commit/3535f78f7af73f13f2c1e7470293fb5e592866de) by email not defined)
- Bump @fluentui/react-utilities to v0.0.0-nightly0e0cf06c3420211029.1 ([commit](https://github.com/microsoft/fluentui/commit/3535f78f7af73f13f2c1e7470293fb5e592866de) by beachball)
- Release nightly v9 ([commit](https://github.com/microsoft/fluentui/commit/e6017db01058700b10f0f2b6b36ef51efb28b9b9) by email not defined)
- Bump @fluentui/react-utilities to v0.0.0-nightly57a9843f2620211119.1 ([commit](https://github.com/microsoft/fluentui/commit/e6017db01058700b10f0f2b6b36ef51efb28b9b9) by beachball)
## [9.0.0-beta.3](https://github.com/microsoft/fluentui/tree/@fluentui/react-context-selector_v9.0.0-beta.3)
Fri, 12 Nov 2021 13:25:22 GMT
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-context-selector_v9.0.0-beta.2..@fluentui/react-context-selector_v9.0.0-beta.3)
### Changes
- Updated beta and RC components to ES2019 ([PR #20405](https://github.com/microsoft/fluentui/pull/20405) by gcox@microsoft.com)
- Bump @fluentui/react-utilities to v9.0.0-beta.3 ([PR #20583](https://github.com/microsoft/fluentui/pull/20583) by beachball)
## [9.0.0-beta.2](https://github.com/microsoft/fluentui/tree/@fluentui/react-context-selector_v9.0.0-beta.2)

@@ -18,0 +28,0 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createContext = void 0;
var react_utilities_1 = require("@fluentui/react-utilities");
var React = require("react");
var scheduler_1 = require("scheduler");
var createProvider = function (Original) {
var Provider = function (props) {
const react_utilities_1 = require("@fluentui/react-utilities");
const React = require("react");
const scheduler_1 = require("scheduler");
const createProvider = (Original) => {
const Provider = props => {
// Holds an actual "props.value"
var valueRef = React.useRef(props.value);
const valueRef = React.useRef(props.value);
// Used to sync context updates and avoid stale values, can be considered as render/effect counter of Provider.
var versionRef = React.useRef(0);
const versionRef = React.useRef(0);
// A stable object, is used to avoid context updates via mutation of its values.
var contextValue = React.useRef();
const contextValue = React.useRef();
if (!contextValue.current) {

@@ -22,7 +22,7 @@ contextValue.current = {

}
react_utilities_1.useIsomorphicLayoutEffect(function () {
react_utilities_1.useIsomorphicLayoutEffect(() => {
valueRef.current = props.value;
versionRef.current += 1;
scheduler_1.unstable_runWithPriority(scheduler_1.unstable_NormalPriority, function () {
contextValue.current.listeners.forEach(function (listener) {
scheduler_1.unstable_runWithPriority(scheduler_1.unstable_NormalPriority, () => {
contextValue.current.listeners.forEach(listener => {
listener([versionRef.current, props.value]);

@@ -40,4 +40,4 @@ });

};
var createContext = function (defaultValue) {
var context = React.createContext({
const createContext = (defaultValue) => {
const context = React.createContext({
value: { current: defaultValue },

@@ -44,0 +44,0 @@ version: { current: -1 },

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useHasParentContext = exports.useContextSelector = exports.createContext = void 0;
var tslib_1 = require("tslib");
const tslib_1 = require("tslib");
var createContext_1 = require("./createContext");

@@ -6,0 +6,0 @@ Object.defineProperty(exports, "createContext", { enumerable: true, get: function () { return createContext_1.createContext; } });

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useContextSelector = void 0;
var react_utilities_1 = require("@fluentui/react-utilities");
var React = require("react");
const react_utilities_1 = require("@fluentui/react-utilities");
const React = require("react");
/**

@@ -11,7 +11,7 @@ * This hook returns context selected value by selector.

*/
var useContextSelector = function (context, selector) {
var contextValue = React.useContext(context);
var value = contextValue.value.current, version = contextValue.version.current, listeners = contextValue.listeners;
var selected = selector(value);
var _a = React.useReducer(function (prevState, payload) {
const useContextSelector = (context, selector) => {
const contextValue = React.useContext(context);
const { value: { current: value }, version: { current: version }, listeners, } = contextValue;
const selected = selector(value);
const [state, dispatch] = React.useReducer((prevState, payload) => {
if (!payload) {

@@ -31,3 +31,3 @@ // early bail out when is dispatched during render

}
var nextSelected = selector(payload[1]);
const nextSelected = selector(payload[1]);
if (objectIs(prevState[1], nextSelected)) {

@@ -43,3 +43,3 @@ return prevState; // do not update

return [prevState[0], prevState[1]]; // schedule update
}, [value, selected]), state = _a[0], dispatch = _a[1];
}, [value, selected]);
if (!objectIs(state[1], selected)) {

@@ -50,6 +50,6 @@ // schedule re-render

}
react_utilities_1.useIsomorphicLayoutEffect(function () {
react_utilities_1.useIsomorphicLayoutEffect(() => {
listeners.push(dispatch);
return function () {
var index = listeners.indexOf(dispatch);
return () => {
const index = listeners.indexOf(dispatch);
listeners.splice(index, 1);

@@ -71,3 +71,3 @@ };

// eslint-disable-next-line @typescript-eslint/no-explicit-any
var objectIs =
const objectIs =
// eslint-disable-next-line @typescript-eslint/ban-ts-comment

@@ -74,0 +74,0 @@ // @ts-ignore fallback to native if it exists (not in IE11)

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useHasParentContext = void 0;
var React = require("react");
const React = require("react");
/**

@@ -13,3 +13,3 @@ * Utility hook for contexts created by react-context-selector to determine if a parent context exists

function useHasParentContext(context) {
var contextValue = React.useContext(context);
const contextValue = React.useContext(context);
if (contextValue.version) {

@@ -16,0 +16,0 @@ return contextValue.version.current !== -1;

import { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';
import * as React from 'react';
import { unstable_NormalPriority as NormalPriority, unstable_runWithPriority as runWithPriority } from 'scheduler';
var createProvider = function (Original) {
var Provider = function (props) {
const createProvider = (Original) => {
const Provider = props => {
// Holds an actual "props.value"
var valueRef = React.useRef(props.value);
const valueRef = React.useRef(props.value);
// Used to sync context updates and avoid stale values, can be considered as render/effect counter of Provider.
var versionRef = React.useRef(0);
const versionRef = React.useRef(0);
// A stable object, is used to avoid context updates via mutation of its values.
var contextValue = React.useRef();
const contextValue = React.useRef();
if (!contextValue.current) {

@@ -19,7 +19,7 @@ contextValue.current = {

}
useIsomorphicLayoutEffect(function () {
useIsomorphicLayoutEffect(() => {
valueRef.current = props.value;
versionRef.current += 1;
runWithPriority(NormalPriority, function () {
contextValue.current.listeners.forEach(function (listener) {
runWithPriority(NormalPriority, () => {
contextValue.current.listeners.forEach(listener => {
listener([versionRef.current, props.value]);

@@ -37,4 +37,4 @@ });

};
export var createContext = function (defaultValue) {
var context = React.createContext({
export const createContext = (defaultValue) => {
const context = React.createContext({
value: { current: defaultValue },

@@ -41,0 +41,0 @@ version: { current: -1 },

@@ -8,7 +8,7 @@ import { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';

*/
export var useContextSelector = function (context, selector) {
var contextValue = React.useContext(context);
var value = contextValue.value.current, version = contextValue.version.current, listeners = contextValue.listeners;
var selected = selector(value);
var _a = React.useReducer(function (prevState, payload) {
export const useContextSelector = (context, selector) => {
const contextValue = React.useContext(context);
const { value: { current: value }, version: { current: version }, listeners, } = contextValue;
const selected = selector(value);
const [state, dispatch] = React.useReducer((prevState, payload) => {
if (!payload) {

@@ -28,3 +28,3 @@ // early bail out when is dispatched during render

}
var nextSelected = selector(payload[1]);
const nextSelected = selector(payload[1]);
if (objectIs(prevState[1], nextSelected)) {

@@ -40,3 +40,3 @@ return prevState; // do not update

return [prevState[0], prevState[1]]; // schedule update
}, [value, selected]), state = _a[0], dispatch = _a[1];
}, [value, selected]);
if (!objectIs(state[1], selected)) {

@@ -47,6 +47,6 @@ // schedule re-render

}
useIsomorphicLayoutEffect(function () {
useIsomorphicLayoutEffect(() => {
listeners.push(dispatch);
return function () {
var index = listeners.indexOf(dispatch);
return () => {
const index = listeners.indexOf(dispatch);
listeners.splice(index, 1);

@@ -67,3 +67,3 @@ };

// eslint-disable-next-line @typescript-eslint/no-explicit-any
var objectIs =
const objectIs =
// eslint-disable-next-line @typescript-eslint/ban-ts-comment

@@ -70,0 +70,0 @@ // @ts-ignore fallback to native if it exists (not in IE11)

@@ -10,3 +10,3 @@ import * as React from 'react';

export function useHasParentContext(context) {
var contextValue = React.useContext(context);
const contextValue = React.useContext(context);
if (contextValue.version) {

@@ -13,0 +13,0 @@ return contextValue.version.current !== -1;

{
"name": "@fluentui/react-context-selector",
"version": "0.0.0-nightly0e0cf06c3420211029.1",
"version": "0.0.0-nightly57a9843f2620211119.1",
"description": "React useContextSelector hook in userland",

@@ -37,3 +37,3 @@ "main": "lib-commonjs/index.js",

"dependencies": {
"@fluentui/react-utilities": "0.0.0-nightly0e0cf06c3420211029.1",
"@fluentui/react-utilities": "0.0.0-nightly57a9843f2620211119.1",
"scheduler": "^0.20.1",

@@ -49,3 +49,2 @@ "tslib": "^2.1.0"

"beachball": {
"tag": "beta",
"disallowedChangeTypes": [

@@ -52,0 +51,0 @@ "major",

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

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