@ringcentral/juno 1.12.3 → 1.12.4-beta.5835-b8c3da57

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,11 +7,14 @@ var RcConfig = /** @class */ (function () {
7
7
  this._WARNING_FUNCTION = function (message, options) {
8
8
  console[(options === null || options === void 0 ? void 0 : options.level) || 'warn'](message);
9
9
  };
10
- // * get value once when init
11
- this._WARNING_IGNORE =
12
- ((_a = window === null || window === void 0 ? void 0 : window.localStorage) === null || _a === void 0 ? void 0 : _a.getItem(JUNO_WARNING_IGNORE_KEY)) === 'true';
13
- // * also provide user to set variable from window
14
- window.__JUNO__ = this;
10
+ if (typeof window !== 'undefined') {
11
+ // SSR support
12
+ // * get value once when init
13
+ this._WARNING_IGNORE =
14
+ ((_a = window === null || window === void 0 ? void 0 : window.localStorage) === null || _a === void 0 ? void 0 : _a.getItem(JUNO_WARNING_IGNORE_KEY)) === 'true';
15
+ // * also provide user to set variable from window
16
+ window.__JUNO__ = this;
17
+ }
15
18
  }
16
19
  Object.defineProperty(RcConfig.prototype, "WARNING_IGNORE", {
17
20
  get: function () {
@@ -1,6 +1,8 @@
1
1
  import { createContext, useContext } from 'react';
2
2
  var RcPortalWindowContext = createContext({
3
- document: document,
3
+ document:
4
+ // directly access `document` will cause error in next.js
5
+ typeof globalThis !== 'undefined' ? globalThis.document : window.document,
4
6
  });
5
7
  var useRcPortalWindowContext = function () { return useContext(RcPortalWindowContext); };
6
8
  export { RcPortalWindowContext, useRcPortalWindowContext };
@@ -9,11 +9,14 @@ var RcConfig = /** @class */ (function () {
9
9
  this._WARNING_FUNCTION = function (message, options) {
10
10
  console[(options === null || options === void 0 ? void 0 : options.level) || 'warn'](message);
11
11
  };
12
- // * get value once when init
13
- this._WARNING_IGNORE =
14
- ((_a = window === null || window === void 0 ? void 0 : window.localStorage) === null || _a === void 0 ? void 0 : _a.getItem(JUNO_WARNING_IGNORE_KEY)) === 'true';
15
- // * also provide user to set variable from window
16
- window.__JUNO__ = this;
12
+ if (typeof window !== 'undefined') {
13
+ // SSR support
14
+ // * get value once when init
15
+ this._WARNING_IGNORE =
16
+ ((_a = window === null || window === void 0 ? void 0 : window.localStorage) === null || _a === void 0 ? void 0 : _a.getItem(JUNO_WARNING_IGNORE_KEY)) === 'true';
17
+ // * also provide user to set variable from window
18
+ window.__JUNO__ = this;
19
+ }
17
20
  }
18
21
  Object.defineProperty(RcConfig.prototype, "WARNING_IGNORE", {
19
22
  get: function () {
@@ -2,7 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var react_1 = require("react");
4
4
  var RcPortalWindowContext = react_1.createContext({
5
- document: document,
5
+ document:
6
+ // directly access `document` will cause error in next.js
7
+ typeof globalThis !== 'undefined' ? globalThis.document : window.document,
6
8
  });
7
9
  exports.RcPortalWindowContext = RcPortalWindowContext;
8
10
  var useRcPortalWindowContext = function () { return react_1.useContext(RcPortalWindowContext); };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ringcentral/juno",
3
- "version": "1.12.3",
3
+ "version": "1.12.4-beta.5835-b8c3da57",
4
4
  "main": "./index.js",
5
5
  "module": "./es6/index.js",
6
6
  "author": "RingCentral",