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

@chakra-ui/react-env

Package Overview
Dependencies
Maintainers
4
Versions
210
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@chakra-ui/react-env - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

18

CHANGELOG.md
# @chakra-ui/react-env
## 1.0.1
## 1.0.2
### Patch Changes
- [`a139b106f`](https://github.com/chakra-ui/chakra-ui/commit/a139b106f428cadbaaffe9cdbd45ff264804b2c2)
Thanks [@segunadebayo](https://github.com/segunadebayo)! - Fix bug where
`EnvProvider` breaks SSR
- Updated dependencies
[[`0974e547c`](https://github.com/chakra-ui/chakra-ui/commit/0974e547c29e4efc1ba4d1eb1507d0dad7d7a77a),
[`59ea894a7`](https://github.com/chakra-ui/chakra-ui/commit/59ea894a7e03d16cd7a1b89d00816eafa9fab65d)]:
- @chakra-ui/utils@1.6.0
- [`19421fa94`](https://github.com/chakra-ui/chakra-ui/commit/19421fa94f52c32d43a34768e232e7919708eae2) Thanks [@segunadebayo](https://github.com/segunadebayo)! - - Fix issue where window could be null
## 1.0.1
### Patch Changes
- [`19421fa94`](https://github.com/chakra-ui/chakra-ui/commit/19421fa94f52c32d43a34768e232e7919708eae2)
Thanks [@segunadebayo](https://github.com/segunadebayo)! - - Fix issue where
window could be null
- Skip logic when `environment` prop is passed

25

dist/cjs/env.js

@@ -7,8 +7,10 @@ "use strict";

var _utils = require("@chakra-ui/utils");
var _react = _interopRequireWildcard(require("react"));
var _mockDocument = require("./mock-document");
var _mockWindow = require("./mock-window");
var _mockDocument = require("./mock-document");
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }

@@ -22,3 +24,3 @@

};
var defaultEnv = typeof window !== "undefined" ? {
var defaultEnv = _utils.isBrowser ? {
window: window,

@@ -28,4 +30,7 @@ document: document

var EnvironmentContext = /*#__PURE__*/(0, _react.createContext)(defaultEnv);
EnvironmentContext.displayName = "EnvironmentContext";
if (_utils.__DEV__) {
EnvironmentContext.displayName = "EnvironmentContext";
}
function useEnvironment() {

@@ -48,13 +53,13 @@ return (0, _react.useContext)(EnvironmentContext);

var win = node == null ? void 0 : node.ownerDocument.defaultView;
var nodeEnv = {
var nodeEnv = doc ? {
document: doc,
window: win
};
} : undefined;
var env = (_ref = environmentProp != null ? environmentProp : nodeEnv) != null ? _ref : defaultEnv;
return env;
}, [node, environmentProp]);
var shouldRenderChildren = node || environmentProp;
var showEnvGetter = !node && !environmentProp;
return /*#__PURE__*/_react["default"].createElement(EnvironmentContext.Provider, {
value: context
}, shouldRenderChildren ? children : /*#__PURE__*/_react["default"].createElement("span", {
}, children, showEnvGetter && /*#__PURE__*/_react["default"].createElement("span", {
ref: function ref(el) {

@@ -65,2 +70,6 @@ if (el) setNode(el);

}
if (_utils.__DEV__) {
EnvironmentProvider.displayName = "EnvironmentProvider";
}
//# sourceMappingURL=env.js.map

@@ -1,4 +0,5 @@

import React, { useMemo, useState, createContext, useContext } from "react";
import { isBrowser, __DEV__ } from "@chakra-ui/utils";
import React, { createContext, useContext, useMemo, useState } from "react";
import { ssrDocument } from "./mock-document";
import { ssrWindow } from "./mock-window";
import { ssrDocument } from "./mock-document";
var mockEnv = {

@@ -8,3 +9,3 @@ window: ssrWindow,

};
var defaultEnv = typeof window !== "undefined" ? {
var defaultEnv = isBrowser ? {
window,

@@ -14,3 +15,7 @@ document

var EnvironmentContext = /*#__PURE__*/createContext(defaultEnv);
EnvironmentContext.displayName = "EnvironmentContext";
if (__DEV__) {
EnvironmentContext.displayName = "EnvironmentContext";
}
export function useEnvironment() {

@@ -30,13 +35,13 @@ return useContext(EnvironmentContext);

var win = node == null ? void 0 : node.ownerDocument.defaultView;
var nodeEnv = {
var nodeEnv = doc ? {
document: doc,
window: win
};
} : undefined;
var env = (_ref = environmentProp != null ? environmentProp : nodeEnv) != null ? _ref : defaultEnv;
return env;
}, [node, environmentProp]);
var shouldRenderChildren = node || environmentProp;
var showEnvGetter = !node && !environmentProp;
return /*#__PURE__*/React.createElement(EnvironmentContext.Provider, {
value: context
}, shouldRenderChildren ? children : /*#__PURE__*/React.createElement("span", {
}, children, showEnvGetter && /*#__PURE__*/React.createElement("span", {
ref: el => {

@@ -47,2 +52,6 @@ if (el) setNode(el);

}
if (__DEV__) {
EnvironmentProvider.displayName = "EnvironmentProvider";
}
//# sourceMappingURL=env.js.map

@@ -12,3 +12,6 @@ import React from "react";

export declare function EnvironmentProvider(props: EnvironmentProviderProps): JSX.Element;
export declare namespace EnvironmentProvider {
var displayName: string;
}
export {};
//# sourceMappingURL=env.d.ts.map
{
"name": "@chakra-ui/react-env",
"version": "1.0.1",
"version": "1.0.2",
"description": "Component and hook for handling window and document object in iframe or ssr environment",

@@ -54,2 +54,5 @@ "keywords": [

},
"dependencies": {
"@chakra-ui/utils": "1.6.0"
},
"peerDependencies": {

@@ -56,0 +59,0 @@ "react": ">=16.8.6"

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