@radix-ui/react-use-is-hydrated 0.1.0 → 0.1.1-rc.1780444360047
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.
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +35 -7
- package/dist/index.js.map +4 -4
- package/dist/index.mjs +25 -7
- package/dist/index.mjs.map +4 -4
- package/package.json +8 -13
- package/src/use-is-hydrated-legacy.ts +14 -0
- package/src/use-is-hydrated.tsx +15 -7
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,26 +17,52 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/index.ts
|
|
21
31
|
var index_exports = {};
|
|
22
32
|
__export(index_exports, {
|
|
23
|
-
useIsHydrated: () =>
|
|
33
|
+
useIsHydrated: () => useIsHydrated2
|
|
24
34
|
});
|
|
25
35
|
module.exports = __toCommonJS(index_exports);
|
|
26
36
|
|
|
27
37
|
// src/use-is-hydrated.tsx
|
|
28
|
-
var
|
|
38
|
+
var React2 = __toESM(require("react"));
|
|
39
|
+
|
|
40
|
+
// src/use-is-hydrated-legacy.ts
|
|
41
|
+
var React = __toESM(require("react"));
|
|
42
|
+
var _isHydrated = false;
|
|
29
43
|
function useIsHydrated() {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
()
|
|
33
|
-
|
|
34
|
-
|
|
44
|
+
const [isHydrated, setIsHydrated] = React.useState(_isHydrated);
|
|
45
|
+
React.useEffect(() => {
|
|
46
|
+
if (!_isHydrated) {
|
|
47
|
+
_isHydrated = true;
|
|
48
|
+
setIsHydrated(true);
|
|
49
|
+
}
|
|
50
|
+
}, []);
|
|
51
|
+
return isHydrated;
|
|
35
52
|
}
|
|
53
|
+
|
|
54
|
+
// src/use-is-hydrated.tsx
|
|
55
|
+
var useReactSyncExternalStore = React2[" useSyncExternalStore ".trim().toString()];
|
|
36
56
|
function subscribe() {
|
|
37
57
|
return () => {
|
|
38
58
|
};
|
|
39
59
|
}
|
|
60
|
+
function useIsHydratedModern() {
|
|
61
|
+
return useReactSyncExternalStore(
|
|
62
|
+
subscribe,
|
|
63
|
+
() => true,
|
|
64
|
+
() => false
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
var useIsHydrated2 = typeof useReactSyncExternalStore === "function" ? useIsHydratedModern : useIsHydrated;
|
|
40
68
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/index.ts", "../src/use-is-hydrated.tsx"],
|
|
4
|
-
"sourcesContent": ["export { useIsHydrated } from './use-is-hydrated';\n", "import {
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
3
|
+
"sources": ["../src/index.ts", "../src/use-is-hydrated.tsx", "../src/use-is-hydrated-legacy.ts"],
|
|
4
|
+
"sourcesContent": ["export { useIsHydrated } from './use-is-hydrated';\n", "import * as React from 'react';\nimport { useIsHydrated as useIsHydratedLegacy } from './use-is-hydrated-legacy';\n\nconst useReactSyncExternalStore: typeof React.useSyncExternalStore | undefined = (React as any)[\n ' useSyncExternalStore '.trim().toString()\n];\n\nfunction subscribe() {\n return () => {};\n}\n\n/**\n * Determines whether or not the component tree has been hydrated.\n */\nfunction useIsHydratedModern() {\n return useReactSyncExternalStore!(\n subscribe,\n () => true,\n () => false,\n );\n}\n\nexport const useIsHydrated =\n typeof useReactSyncExternalStore === 'function' ? useIsHydratedModern : useIsHydratedLegacy;\n", "import * as React from 'react';\n\nlet _isHydrated = false;\n\nexport function useIsHydrated() {\n const [isHydrated, setIsHydrated] = React.useState(_isHydrated);\n React.useEffect(() => {\n if (!_isHydrated) {\n _isHydrated = true;\n setIsHydrated(true);\n }\n }, []);\n return isHydrated;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,uBAAAA;AAAA;AAAA;;;ACAA,IAAAC,SAAuB;;;ACAvB,YAAuB;AAEvB,IAAI,cAAc;AAEX,SAAS,gBAAgB;AAC9B,QAAM,CAAC,YAAY,aAAa,IAAU,eAAS,WAAW;AAC9D,EAAM,gBAAU,MAAM;AACpB,QAAI,CAAC,aAAa;AAChB,oBAAc;AACd,oBAAc,IAAI;AAAA,IACpB;AAAA,EACF,GAAG,CAAC,CAAC;AACL,SAAO;AACT;;;ADVA,IAAM,4BAA4EC,OAChF,yBAAyB,KAAK,EAAE,SAAS,CAC3C;AAEA,SAAS,YAAY;AACnB,SAAO,MAAM;AAAA,EAAC;AAChB;AAKA,SAAS,sBAAsB;AAC7B,SAAO;AAAA,IACL;AAAA,IACA,MAAM;AAAA,IACN,MAAM;AAAA,EACR;AACF;AAEO,IAAMC,iBACX,OAAO,8BAA8B,aAAa,sBAAsB;",
|
|
6
|
+
"names": ["useIsHydrated", "React", "React", "useIsHydrated"]
|
|
7
7
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,17 +1,35 @@
|
|
|
1
1
|
// src/use-is-hydrated.tsx
|
|
2
|
-
import
|
|
2
|
+
import * as React2 from "react";
|
|
3
|
+
|
|
4
|
+
// src/use-is-hydrated-legacy.ts
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
var _isHydrated = false;
|
|
3
7
|
function useIsHydrated() {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
()
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
const [isHydrated, setIsHydrated] = React.useState(_isHydrated);
|
|
9
|
+
React.useEffect(() => {
|
|
10
|
+
if (!_isHydrated) {
|
|
11
|
+
_isHydrated = true;
|
|
12
|
+
setIsHydrated(true);
|
|
13
|
+
}
|
|
14
|
+
}, []);
|
|
15
|
+
return isHydrated;
|
|
9
16
|
}
|
|
17
|
+
|
|
18
|
+
// src/use-is-hydrated.tsx
|
|
19
|
+
var useReactSyncExternalStore = React2[" useSyncExternalStore ".trim().toString()];
|
|
10
20
|
function subscribe() {
|
|
11
21
|
return () => {
|
|
12
22
|
};
|
|
13
23
|
}
|
|
24
|
+
function useIsHydratedModern() {
|
|
25
|
+
return useReactSyncExternalStore(
|
|
26
|
+
subscribe,
|
|
27
|
+
() => true,
|
|
28
|
+
() => false
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
var useIsHydrated2 = typeof useReactSyncExternalStore === "function" ? useIsHydratedModern : useIsHydrated;
|
|
14
32
|
export {
|
|
15
|
-
useIsHydrated
|
|
33
|
+
useIsHydrated2 as useIsHydrated
|
|
16
34
|
};
|
|
17
35
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/use-is-hydrated.tsx"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": ";AAAA,
|
|
6
|
-
"names": []
|
|
3
|
+
"sources": ["../src/use-is-hydrated.tsx", "../src/use-is-hydrated-legacy.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nimport { useIsHydrated as useIsHydratedLegacy } from './use-is-hydrated-legacy';\n\nconst useReactSyncExternalStore: typeof React.useSyncExternalStore | undefined = (React as any)[\n ' useSyncExternalStore '.trim().toString()\n];\n\nfunction subscribe() {\n return () => {};\n}\n\n/**\n * Determines whether or not the component tree has been hydrated.\n */\nfunction useIsHydratedModern() {\n return useReactSyncExternalStore!(\n subscribe,\n () => true,\n () => false,\n );\n}\n\nexport const useIsHydrated =\n typeof useReactSyncExternalStore === 'function' ? useIsHydratedModern : useIsHydratedLegacy;\n", "import * as React from 'react';\n\nlet _isHydrated = false;\n\nexport function useIsHydrated() {\n const [isHydrated, setIsHydrated] = React.useState(_isHydrated);\n React.useEffect(() => {\n if (!_isHydrated) {\n _isHydrated = true;\n setIsHydrated(true);\n }\n }, []);\n return isHydrated;\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,YAAYA,YAAW;;;ACAvB,YAAY,WAAW;AAEvB,IAAI,cAAc;AAEX,SAAS,gBAAgB;AAC9B,QAAM,CAAC,YAAY,aAAa,IAAU,eAAS,WAAW;AAC9D,EAAM,gBAAU,MAAM;AACpB,QAAI,CAAC,aAAa;AAChB,oBAAc;AACd,oBAAc,IAAI;AAAA,IACpB;AAAA,EACF,GAAG,CAAC,CAAC;AACL,SAAO;AACT;;;ADVA,IAAM,4BAA4EC,OAChF,yBAAyB,KAAK,EAAE,SAAS,CAC3C;AAEA,SAAS,YAAY;AACnB,SAAO,MAAM;AAAA,EAAC;AAChB;AAKA,SAAS,sBAAsB;AAC7B,SAAO;AAAA,IACL;AAAA,IACA,MAAM;AAAA,IACN,MAAM;AAAA,EACR;AACF;AAEO,IAAMC,iBACX,OAAO,8BAA8B,aAAa,sBAAsB;",
|
|
6
|
+
"names": ["React", "React", "useIsHydrated"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@radix-ui/react-use-is-hydrated",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1-rc.1780444360047",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -11,9 +11,6 @@
|
|
|
11
11
|
"README.md"
|
|
12
12
|
],
|
|
13
13
|
"sideEffects": false,
|
|
14
|
-
"dependencies": {
|
|
15
|
-
"use-sync-external-store": "^1.5.0"
|
|
16
|
-
},
|
|
17
14
|
"peerDependencies": {
|
|
18
15
|
"@types/react": "*",
|
|
19
16
|
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
|
|
@@ -24,15 +21,12 @@
|
|
|
24
21
|
}
|
|
25
22
|
},
|
|
26
23
|
"devDependencies": {
|
|
27
|
-
"@types/react": "^19.
|
|
28
|
-
"@types/react-dom": "^19.
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"react-dom": "^19.1.0",
|
|
33
|
-
"typescript": "^5.7.3",
|
|
24
|
+
"@types/react": "^19.2.2",
|
|
25
|
+
"@types/react-dom": "^19.2.2",
|
|
26
|
+
"react": "^19.2.0",
|
|
27
|
+
"react-dom": "^19.2.0",
|
|
28
|
+
"typescript": "^5.9.3",
|
|
34
29
|
"@repo/builder": "0.0.0",
|
|
35
|
-
"@repo/eslint-config": "0.0.0",
|
|
36
30
|
"@repo/typescript-config": "0.0.0"
|
|
37
31
|
},
|
|
38
32
|
"homepage": "https://radix-ui.com/primitives",
|
|
@@ -44,8 +38,9 @@
|
|
|
44
38
|
"url": "https://github.com/radix-ui/primitives/issues"
|
|
45
39
|
},
|
|
46
40
|
"scripts": {
|
|
47
|
-
"lint": "
|
|
41
|
+
"lint": "oxlint --max-warnings 0 src",
|
|
48
42
|
"clean": "rm -rf dist",
|
|
43
|
+
"reset": "rm -rf dist node_modules",
|
|
49
44
|
"typecheck": "tsc --noEmit",
|
|
50
45
|
"build": "radix-build"
|
|
51
46
|
},
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
let _isHydrated = false;
|
|
4
|
+
|
|
5
|
+
export function useIsHydrated() {
|
|
6
|
+
const [isHydrated, setIsHydrated] = React.useState(_isHydrated);
|
|
7
|
+
React.useEffect(() => {
|
|
8
|
+
if (!_isHydrated) {
|
|
9
|
+
_isHydrated = true;
|
|
10
|
+
setIsHydrated(true);
|
|
11
|
+
}
|
|
12
|
+
}, []);
|
|
13
|
+
return isHydrated;
|
|
14
|
+
}
|
package/src/use-is-hydrated.tsx
CHANGED
|
@@ -1,16 +1,24 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useIsHydrated as useIsHydratedLegacy } from './use-is-hydrated-legacy';
|
|
3
|
+
|
|
4
|
+
const useReactSyncExternalStore: typeof React.useSyncExternalStore | undefined = (React as any)[
|
|
5
|
+
' useSyncExternalStore '.trim().toString()
|
|
6
|
+
];
|
|
7
|
+
|
|
8
|
+
function subscribe() {
|
|
9
|
+
return () => {};
|
|
10
|
+
}
|
|
2
11
|
|
|
3
12
|
/**
|
|
4
13
|
* Determines whether or not the component tree has been hydrated.
|
|
5
14
|
*/
|
|
6
|
-
|
|
7
|
-
return
|
|
15
|
+
function useIsHydratedModern() {
|
|
16
|
+
return useReactSyncExternalStore!(
|
|
8
17
|
subscribe,
|
|
9
18
|
() => true,
|
|
10
|
-
() => false
|
|
19
|
+
() => false,
|
|
11
20
|
);
|
|
12
21
|
}
|
|
13
22
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
23
|
+
export const useIsHydrated =
|
|
24
|
+
typeof useReactSyncExternalStore === 'function' ? useIsHydratedModern : useIsHydratedLegacy;
|