react-simple-toasts
Advanced tools
Comparing version 3.6.2 to 3.7.0-beta.0
@@ -86,16 +86,11 @@ import React, { Fragment, cloneElement, useRef, useState, useLayoutEffect } from 'react'; | ||
var createId = function () { | ||
return Date.now() + Math.floor(Math.random() * 10000000000000000); | ||
}; | ||
var isBrowser = function () { | ||
return typeof window !== 'undefined'; | ||
}; | ||
// Let compiler not to search module usage | ||
var fullClone = __assign({}, ReactDOM); | ||
var version = fullClone.version, | ||
reactRender = fullClone.render; | ||
fullClone.unmountComponentAtNode; | ||
var createRoot; | ||
try { | ||
var mainVersion = Number((version || '').split('.')[0]); | ||
if (mainVersion >= 18) { | ||
if (mainVersion >= 18 && fullClone.createRoot) { | ||
createRoot = fullClone.createRoot; | ||
@@ -112,10 +107,9 @@ } | ||
} | ||
var ROOT_KEY = '__REACT_SIMPLE_TOAST_ROOT__'; | ||
var MARK = '__rc_react_root__'; | ||
function modernRender(node, container) { | ||
toggleWarning(true); | ||
if (isBrowser() && !window[ROOT_KEY]) window[ROOT_KEY] = createRoot(container); | ||
var root = container[MARK] || createRoot(container); | ||
toggleWarning(false); | ||
if (!window[ROOT_KEY]) return; | ||
var root = window[ROOT_KEY]; | ||
root.render(node); | ||
container[MARK] = root; | ||
} | ||
@@ -126,3 +120,3 @@ function legacyRender(node, container) { | ||
function render(node, container) { | ||
if (createRoot) { | ||
if (createRoot != null) { | ||
modernRender(node, container); | ||
@@ -134,2 +128,9 @@ return; | ||
var createId = function () { | ||
return Date.now() + Math.floor(Math.random() * 10000000000000000); | ||
}; | ||
var isBrowser = function () { | ||
return typeof window !== 'undefined'; | ||
}; | ||
var SET_TIMEOUT_MAX = 2147483647; | ||
@@ -136,0 +137,0 @@ var ToastPosition = { |
@@ -109,16 +109,11 @@ 'use strict'; | ||
var createId = function () { | ||
return Date.now() + Math.floor(Math.random() * 10000000000000000); | ||
}; | ||
var isBrowser = function () { | ||
return typeof window !== 'undefined'; | ||
}; | ||
// Let compiler not to search module usage | ||
var fullClone = __assign({}, ReactDOM__namespace); | ||
var version = fullClone.version, | ||
reactRender = fullClone.render; | ||
fullClone.unmountComponentAtNode; | ||
var createRoot; | ||
try { | ||
var mainVersion = Number((version || '').split('.')[0]); | ||
if (mainVersion >= 18) { | ||
if (mainVersion >= 18 && fullClone.createRoot) { | ||
createRoot = fullClone.createRoot; | ||
@@ -135,10 +130,9 @@ } | ||
} | ||
var ROOT_KEY = '__REACT_SIMPLE_TOAST_ROOT__'; | ||
var MARK = '__rc_react_root__'; | ||
function modernRender(node, container) { | ||
toggleWarning(true); | ||
if (isBrowser() && !window[ROOT_KEY]) window[ROOT_KEY] = createRoot(container); | ||
var root = container[MARK] || createRoot(container); | ||
toggleWarning(false); | ||
if (!window[ROOT_KEY]) return; | ||
var root = window[ROOT_KEY]; | ||
root.render(node); | ||
container[MARK] = root; | ||
} | ||
@@ -149,3 +143,3 @@ function legacyRender(node, container) { | ||
function render(node, container) { | ||
if (createRoot) { | ||
if (createRoot != null) { | ||
modernRender(node, container); | ||
@@ -157,2 +151,9 @@ return; | ||
var createId = function () { | ||
return Date.now() + Math.floor(Math.random() * 10000000000000000); | ||
}; | ||
var isBrowser = function () { | ||
return typeof window !== 'undefined'; | ||
}; | ||
var SET_TIMEOUT_MAX = 2147483647; | ||
@@ -159,0 +160,0 @@ var ToastPosition = { |
import type * as React from 'react'; | ||
export declare function render(node: React.ReactElement, container: Element): void; | ||
import type { Root } from 'react-dom/client'; | ||
declare const MARK = "__rc_react_root__"; | ||
type ContainerType = (Element | DocumentFragment) & { | ||
[MARK]?: Root; | ||
}; | ||
/** @private Test usage. Not work in prod */ | ||
export declare function _r(node: React.ReactElement, container: ContainerType): void; | ||
export declare function render(node: React.ReactElement, container: ContainerType): void; | ||
/** @private Test usage. Not work in prod */ | ||
export declare function _u(container: ContainerType): void; | ||
export declare function unmount(container: ContainerType): Promise<void>; | ||
export {}; |
{ | ||
"name": "react-simple-toasts", | ||
"version": "3.6.2", | ||
"version": "3.7.0-beta.0", | ||
"description": "React Simple Toasts is a simple and easy-to-use toast message popup for React.", | ||
@@ -34,3 +34,3 @@ "author": "almond-bongbong", | ||
"@testing-library/jest-dom": "^5.16.5", | ||
"@testing-library/react": "^12.1.2", | ||
"@testing-library/react": "^13.4.0", | ||
"@types/jest": "^23.1.5", | ||
@@ -47,5 +47,6 @@ "@types/react": "^18.0.20", | ||
"prettier": "^2.8.8", | ||
"react": "^16.8.0", | ||
"react-dom": "^16.8.0", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0", | ||
"rollup": "^3.10.0", | ||
"rollup-plugin-copy": "^3.4.0", | ||
"rollup-plugin-peer-deps-external": "^2.2.4", | ||
@@ -52,0 +53,0 @@ "rollup-plugin-postcss": "^4.0.2", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
46635
934
29
1