Socket
Socket
Sign inDemoInstall

@react-aria/ssr

Package Overview
Dependencies
Maintainers
2
Versions
741
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-aria/ssr - npm Package Compare versions

Comparing version 3.0.0-nightly.2359 to 3.0.0-nightly-4980928d3-240906

dist/import.mjs

93

dist/main.js

@@ -1,83 +0,24 @@

var _react2 = require("react");
var $97d95f6660b1bb14$exports = require("./SSRProvider.main.js");
var _react = $parcel$interopDefault(_react2);
var {
useContext,
useLayoutEffect,
useMemo,
useState
} = _react2;
function $parcel$interopDefault(a) {
return a && a.__esModule ? a.default : a;
function $parcel$export(e, n, v, s) {
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
}
// Default context value to use in case there is no SSRProvider. This is fine for
// client-only apps. In order to support multiple copies of React Aria potentially
// being on the page at once, the prefix is set to a random number. SSRProvider
// will reset this to zero for consistency between server and client, so in the
// SSR case multiple copies of React Aria is not supported.
const $e873f27652f6cc1e1ee5ebcb9b5e51$var$defaultContext = {
prefix: Math.round(Math.random() * 10000000000),
current: 0
};
$parcel$export(module.exports, "SSRProvider", () => $97d95f6660b1bb14$exports.SSRProvider);
$parcel$export(module.exports, "useSSRSafeId", () => $97d95f6660b1bb14$exports.useSSRSafeId);
$parcel$export(module.exports, "useIsSSR", () => $97d95f6660b1bb14$exports.useIsSSR);
/*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
const $e873f27652f6cc1e1ee5ebcb9b5e51$var$SSRContext = _react.createContext($e873f27652f6cc1e1ee5ebcb9b5e51$var$defaultContext);
/**
* When using SSR with React Aria, applications must be wrapped in an SSRProvider.
* This ensures that auto generated ids are consistent between the client and server
* by resetting the incremented value on each request.
*/
function SSRProvider(props) {
let cur = useContext($e873f27652f6cc1e1ee5ebcb9b5e51$var$SSRContext);
let value = {
// If this is the first SSRProvider, set to zero, otherwise increment.
prefix: cur === $e873f27652f6cc1e1ee5ebcb9b5e51$var$defaultContext ? 0 : cur.prefix + 1,
current: 0
};
return /*#__PURE__*/_react.createElement($e873f27652f6cc1e1ee5ebcb9b5e51$var$SSRContext.Provider, {
value: value
}, props.children);
}
exports.SSRProvider = SSRProvider;
let $e873f27652f6cc1e1ee5ebcb9b5e51$var$canUseDOM = Boolean(typeof window !== 'undefined' && window.document && window.document.createElement);
/** @private */
function useSSRSafeId(defaultId) {
let ctx = useContext($e873f27652f6cc1e1ee5ebcb9b5e51$var$SSRContext); // If we are rendering in a non-DOM environment, and there's no SSRProvider,
// provide a warning to hint to the developer to add one.
if (ctx === $e873f27652f6cc1e1ee5ebcb9b5e51$var$defaultContext && !$e873f27652f6cc1e1ee5ebcb9b5e51$var$canUseDOM) {
console.warn('When server rendering, you must wrap your application in an <SSRProvider> to ensure consistent ids are generated between the client and server.');
}
return useMemo(() => defaultId || "react-aria-" + ctx.prefix + "-" + ++ctx.current, [defaultId]);
}
/** @private */
exports.useSSRSafeId = useSSRSafeId;
function useIsSSR() {
let cur = useContext($e873f27652f6cc1e1ee5ebcb9b5e51$var$SSRContext);
let isInSSRContext = cur !== $e873f27652f6cc1e1ee5ebcb9b5e51$var$defaultContext;
let [isSSR, setIsSSR] = useState(isInSSRContext); // If on the client, and the component was initially server rendered,
// then schedule a layout effect to update the component after hydration.
if (typeof window !== 'undefined' && isInSSRContext) {
// This if statement technically breaks the rules of hooks, but is safe
// because the condition never changes after mounting.
// eslint-disable-next-line react-hooks/rules-of-hooks
useLayoutEffect(() => {
setIsSSR(false);
}, []);
}
return isSSR;
}
exports.useIsSSR = useIsSSR;
//# sourceMappingURL=main.js.map

@@ -1,62 +0,17 @@

import _react, { useContext, useLayoutEffect, useMemo, useState } from "react";
// Default context value to use in case there is no SSRProvider. This is fine for
// client-only apps. In order to support multiple copies of React Aria potentially
// being on the page at once, the prefix is set to a random number. SSRProvider
// will reset this to zero for consistency between server and client, so in the
// SSR case multiple copies of React Aria is not supported.
const $f01a183cc7bdff77849e49ad26eb904$var$defaultContext = {
prefix: Math.round(Math.random() * 10000000000),
current: 0
};
import {SSRProvider as $b5e257d569688ac6$export$9f8ac96af4b1b2ae, useIsSSR as $b5e257d569688ac6$export$535bd6ca7f90a273, useSSRSafeId as $b5e257d569688ac6$export$619500959fc48b26} from "./SSRProvider.module.js";
const $f01a183cc7bdff77849e49ad26eb904$var$SSRContext = _react.createContext($f01a183cc7bdff77849e49ad26eb904$var$defaultContext);
/*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
/**
* When using SSR with React Aria, applications must be wrapped in an SSRProvider.
* This ensures that auto generated ids are consistent between the client and server
* by resetting the incremented value on each request.
*/
export function SSRProvider(props) {
let cur = useContext($f01a183cc7bdff77849e49ad26eb904$var$SSRContext);
let value = {
// If this is the first SSRProvider, set to zero, otherwise increment.
prefix: cur === $f01a183cc7bdff77849e49ad26eb904$var$defaultContext ? 0 : cur.prefix + 1,
current: 0
};
return /*#__PURE__*/_react.createElement($f01a183cc7bdff77849e49ad26eb904$var$SSRContext.Provider, {
value: value
}, props.children);
}
let $f01a183cc7bdff77849e49ad26eb904$var$canUseDOM = Boolean(typeof window !== 'undefined' && window.document && window.document.createElement);
/** @private */
export function useSSRSafeId(defaultId) {
let ctx = useContext($f01a183cc7bdff77849e49ad26eb904$var$SSRContext); // If we are rendering in a non-DOM environment, and there's no SSRProvider,
// provide a warning to hint to the developer to add one.
if (ctx === $f01a183cc7bdff77849e49ad26eb904$var$defaultContext && !$f01a183cc7bdff77849e49ad26eb904$var$canUseDOM) {
console.warn('When server rendering, you must wrap your application in an <SSRProvider> to ensure consistent ids are generated between the client and server.');
}
return useMemo(() => defaultId || "react-aria-" + ctx.prefix + "-" + ++ctx.current, [defaultId]);
}
/** @private */
export function useIsSSR() {
let cur = useContext($f01a183cc7bdff77849e49ad26eb904$var$SSRContext);
let isInSSRContext = cur !== $f01a183cc7bdff77849e49ad26eb904$var$defaultContext;
let [isSSR, setIsSSR] = useState(isInSSRContext); // If on the client, and the component was initially server rendered,
// then schedule a layout effect to update the component after hydration.
if (typeof window !== 'undefined' && isInSSRContext) {
// This if statement technically breaks the rules of hooks, but is safe
// because the condition never changes after mounting.
// eslint-disable-next-line react-hooks/rules-of-hooks
useLayoutEffect(() => {
setIsSSR(false);
}, []);
}
return isSSR;
}
export {$b5e257d569688ac6$export$9f8ac96af4b1b2ae as SSRProvider, $b5e257d569688ac6$export$619500959fc48b26 as useSSRSafeId, $b5e257d569688ac6$export$535bd6ca7f90a273 as useIsSSR};
//# sourceMappingURL=module.js.map

@@ -1,16 +0,21 @@

import { ReactNode } from "react";
interface SSRProviderProps {
import { JSX, ReactNode } from "react";
export interface SSRProviderProps {
/** Your application here. */
children: ReactNode;
}
/**
* When using SSR with React Aria, applications must be wrapped in an SSRProvider.
* This ensures that auto generated ids are consistent between the client and server
* by resetting the incremented value on each request.
* When using SSR with React Aria in React 16 or 17, applications must be wrapped in an SSRProvider.
* This ensures that auto generated ids are consistent between the client and server.
*/
export function SSRProvider(props: SSRProviderProps): JSX.Element;
declare function useModernSSRSafeId(defaultId?: string): string;
/** @private */
export function useSSRSafeId(defaultId?: string): string;
/** @private */
export const useSSRSafeId: typeof useModernSSRSafeId;
/**
* Returns whether the component is currently being server side rendered or
* hydrated on the client. Can be used to delay browser-specific rendering
* until after hydration.
*/
export function useIsSSR(): boolean;
//# sourceMappingURL=types.d.ts.map
{
"name": "@react-aria/ssr",
"version": "3.0.0-nightly.2359+1ad0f163",
"version": "3.0.0-nightly-4980928d3-240906",
"description": "Spectrum UI components in React",

@@ -8,2 +8,7 @@ "license": "Apache-2.0",

"module": "dist/module.js",
"exports": {
"types": "./dist/types.d.ts",
"import": "./dist/import.mjs",
"require": "./dist/main.js"
},
"types": "dist/types.d.ts",

@@ -21,6 +26,6 @@ "source": "src/index.ts",

"dependencies": {
"@babel/runtime": "^7.6.2"
"@swc/helpers": "^0.5.0"
},
"peerDependencies": {
"react": "^16.8.0"
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
},

@@ -30,3 +35,14 @@ "publishConfig": {

},
"gitHead": "1ad0f16354f7114e4ecfa5c75b16ec6f11ff1ec0"
}
"engines": {
"node": ">= 12"
},
"targets": {
"main": {
"context": "node"
},
"module": {
"context": "node"
}
},
"stableVersion": "3.9.5"
}

@@ -12,3 +12,3 @@ /*

*/
export * from './SSRProvider';
export {SSRProvider, useSSRSafeId, useIsSSR} from './SSRProvider';
export type {SSRProviderProps} from './SSRProvider';

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