@hanzogui/use-did-finish-ssr 3.0.6 → 4.3.1
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/cjs/ClientOnly.cjs +25 -23
- package/dist/cjs/ClientOnly.native.js +26 -24
- package/dist/cjs/ClientOnly.native.js.map +1 -1
- package/dist/cjs/index.cjs +37 -28
- package/dist/cjs/index.native.js +39 -30
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/esm/ClientOnly.mjs +11 -11
- package/dist/esm/ClientOnly.mjs.map +1 -1
- package/dist/esm/ClientOnly.native.js +12 -12
- package/dist/esm/ClientOnly.native.js.map +1 -1
- package/dist/esm/index.js +10 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.mjs +10 -3
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/index.native.js +9 -2
- package/dist/esm/index.native.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/types/index.d.ts.map +1 -1
package/dist/cjs/ClientOnly.cjs
CHANGED
|
@@ -3,20 +3,22 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
5
|
var __export = (target, all) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
14
|
get: () => from[key],
|
|
14
15
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
16
|
});
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
18
20
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
-
value:
|
|
21
|
+
value: true
|
|
20
22
|
}), mod);
|
|
21
23
|
var ClientOnly_exports = {};
|
|
22
24
|
__export(ClientOnly_exports, {
|
|
@@ -24,16 +26,16 @@ __export(ClientOnly_exports, {
|
|
|
24
26
|
ClientOnlyContext: () => ClientOnlyContext
|
|
25
27
|
});
|
|
26
28
|
module.exports = __toCommonJS(ClientOnly_exports);
|
|
27
|
-
var import_react = require("react")
|
|
28
|
-
|
|
29
|
-
const ClientOnlyContext = (0, import_react.createContext)(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
29
|
+
var import_react = require("react");
|
|
30
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
31
|
+
const ClientOnlyContext = (0, import_react.createContext)(false);
|
|
32
|
+
const ClientOnly = ({
|
|
33
|
+
children,
|
|
34
|
+
enabled
|
|
35
|
+
}) => {
|
|
36
|
+
const existingValue = (0, import_react.useContext)(ClientOnlyContext);
|
|
37
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(ClientOnlyContext.Provider, {
|
|
38
|
+
value: enabled ?? existingValue,
|
|
39
|
+
children
|
|
40
|
+
});
|
|
41
|
+
};
|
|
@@ -5,20 +5,22 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
16
|
get: () => from[key],
|
|
16
17
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
20
22
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
-
value:
|
|
23
|
+
value: true
|
|
22
24
|
}), mod);
|
|
23
25
|
var ClientOnly_exports = {};
|
|
24
26
|
__export(ClientOnly_exports, {
|
|
@@ -26,18 +28,18 @@ __export(ClientOnly_exports, {
|
|
|
26
28
|
ClientOnlyContext: () => ClientOnlyContext
|
|
27
29
|
});
|
|
28
30
|
module.exports = __toCommonJS(ClientOnly_exports);
|
|
29
|
-
var import_jsx_runtime = require("react/jsx-runtime")
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
31
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
32
|
+
var import_react = require("react");
|
|
33
|
+
var ClientOnlyContext = /* @__PURE__ */(0, import_react.createContext)(false);
|
|
34
|
+
var ClientOnly = function (param) {
|
|
35
|
+
var {
|
|
36
|
+
children,
|
|
37
|
+
enabled
|
|
38
|
+
} = param;
|
|
39
|
+
var existingValue = (0, import_react.useContext)(ClientOnlyContext);
|
|
40
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(ClientOnlyContext.Provider, {
|
|
41
|
+
value: enabled !== null && enabled !== void 0 ? enabled : existingValue,
|
|
42
|
+
children
|
|
43
|
+
});
|
|
44
|
+
};
|
|
43
45
|
//# sourceMappingURL=ClientOnly.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","ClientOnly_exports","__export","ClientOnly","ClientOnlyContext","module","exports","import_jsx_runtime","require","import_react","createContext","param","children","enabled","existingValue","useContext","jsx","Provider"],"sources":["../../src/ClientOnly.tsx"],"sourcesContent":[null],"mappings":"
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","ClientOnly_exports","__export","ClientOnly","ClientOnlyContext","module","exports","import_jsx_runtime","require","import_react","createContext","param","children","enabled","existingValue","useContext","jsx","Provider"],"sources":["../../src/ClientOnly.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,kBAAA;AAAAC,QAAA,CAAAD,kBAAA;EAAAE,UAAA,EAAAA,CAAA,KAAAA,UAAA;EAAAC,iBAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAV,YAA0C,CAAAK,kBAAA;AAatC,IAAAM,kBAAA,GAAAC,OAAA;AAXG,IAAAC,YAAM,GAAAD,OAAA,QAA4C;AAElD,IAAAJ,iBAAoB,sBAAAK,YAAA,CAAAC,aAAA;AAAA,IACzBP,UAAA,YAAAA,CAAAQ,KAAA;EACA;IAAAC,QAAA;IAAAC;EAAA,IAAAF,KAAA;EACF,IAGuBG,aAAA,OAAAL,YAAA,CAAAM,UAAA,EAAAX,iBAAA;EACrB,OAAM,mBAAgBG,kBAAA,CAAAS,GAAA,EAAWZ,iBAAiB,CAAAa,QAAA;IAClDjB,KACE,EAAAa,OAAA,aAAAA,OAAA,cAAAA,OAAC,GAAAC,aAAkB;IAIvBF","ignoreList":[]}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -2,33 +2,35 @@ var __create = Object.create;
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf
|
|
6
|
-
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
16
|
get: () => from[key],
|
|
16
17
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
20
22
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
+
value: mod,
|
|
29
|
+
enumerable: true
|
|
30
|
+
}) : target, mod));
|
|
31
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
+
value: true
|
|
33
|
+
}), mod);
|
|
32
34
|
var index_exports = {};
|
|
33
35
|
__export(index_exports, {
|
|
34
36
|
ClientOnly: () => import_ClientOnly2.ClientOnly,
|
|
@@ -38,14 +40,21 @@ __export(index_exports, {
|
|
|
38
40
|
useIsClientOnly: () => useIsClientOnly
|
|
39
41
|
});
|
|
40
42
|
module.exports = __toCommonJS(index_exports);
|
|
41
|
-
var React = __toESM(require("react"), 1)
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const useIsClientOnly = () =>
|
|
43
|
+
var React = __toESM(require("react"), 1);
|
|
44
|
+
var import_ClientOnly = require("./ClientOnly.cjs");
|
|
45
|
+
var import_ClientOnly2 = require("./ClientOnly.cjs");
|
|
46
|
+
const useIsClientOnly = () => {
|
|
47
|
+
return React.useContext(import_ClientOnly.ClientOnlyContext);
|
|
48
|
+
};
|
|
45
49
|
function useDidFinishSSR() {
|
|
46
|
-
|
|
50
|
+
const clientOnly = React.useContext(import_ClientOnly.ClientOnlyContext);
|
|
51
|
+
if (clientOnly || false) {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
return React.useSyncExternalStore(subscribe, () => true, () => false);
|
|
47
55
|
}
|
|
48
56
|
const subscribe = () => () => {};
|
|
49
57
|
function useClientValue(value) {
|
|
50
|
-
|
|
58
|
+
const done = useDidFinishSSR();
|
|
59
|
+
return !done ? void 0 : typeof value === "function" ? value() : value;
|
|
51
60
|
}
|
package/dist/cjs/index.native.js
CHANGED
|
@@ -4,33 +4,35 @@ var __create = Object.create;
|
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf
|
|
8
|
-
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
9
|
var __export = (target, all) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: true
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
18
|
get: () => from[key],
|
|
18
19
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
20
|
});
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
22
24
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
30
|
+
value: mod,
|
|
31
|
+
enumerable: true
|
|
32
|
+
}) : target, mod));
|
|
33
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
34
|
+
value: true
|
|
35
|
+
}), mod);
|
|
34
36
|
var index_exports = {};
|
|
35
37
|
__export(index_exports, {
|
|
36
38
|
ClientOnly: () => import_ClientOnly2.ClientOnly,
|
|
@@ -40,21 +42,28 @@ __export(index_exports, {
|
|
|
40
42
|
useIsClientOnly: () => useIsClientOnly
|
|
41
43
|
});
|
|
42
44
|
module.exports = __toCommonJS(index_exports);
|
|
43
|
-
var React = __toESM(require("react"), 1)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
var React = __toESM(require("react"), 1);
|
|
46
|
+
var import_ClientOnly = require("./ClientOnly.native.js");
|
|
47
|
+
var import_ClientOnly2 = require("./ClientOnly.native.js");
|
|
48
|
+
var useIsClientOnly = function () {
|
|
49
|
+
return React.useContext(import_ClientOnly.ClientOnlyContext);
|
|
50
|
+
};
|
|
49
51
|
function useDidFinishSSR() {
|
|
50
52
|
var clientOnly = React.useContext(import_ClientOnly.ClientOnlyContext);
|
|
51
|
-
|
|
53
|
+
if (clientOnly || true) {
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
return React.useSyncExternalStore(subscribe, function () {
|
|
57
|
+
return true;
|
|
58
|
+
}, function () {
|
|
59
|
+
return false;
|
|
60
|
+
});
|
|
52
61
|
}
|
|
53
62
|
var subscribe = function () {
|
|
54
63
|
return function () {};
|
|
55
64
|
};
|
|
56
65
|
function useClientValue(value) {
|
|
57
66
|
var done = useDidFinishSSR();
|
|
58
|
-
return done ? typeof value
|
|
67
|
+
return !done ? void 0 : typeof value === "function" ? value() : value;
|
|
59
68
|
}
|
|
60
69
|
//# sourceMappingURL=index.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","__export","ClientOnly","import_ClientOnly2","ClientOnlyContext","useClientValue","useDidFinishSSR","useIsClientOnly","module","exports","React","__toESM","require","import_ClientOnly","useContext","clientOnly","
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","__export","ClientOnly","import_ClientOnly2","ClientOnlyContext","useClientValue","useDidFinishSSR","useIsClientOnly","module","exports","React","__toESM","require","import_ClientOnly","useContext","clientOnly","useSyncExternalStore","subscribe"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA;AAAAC,QAAA,CAAAD,aAAA;EAAAE,UAAA,EAAAA,CAAA,KAAAC,kBAAA,CAAAD,UAAA;EAAAE,iBAAA,EAAAA,CAAA,KAAAD,kBAAA,CAAAC,iBAAA;EAAAC,cAAA,EAAAA,CAAA,KAAAA,cAAA;EAAAC,eAAA,EAAAA,CAAA,KAAAA,eAAA;EAAAC,eAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAuB,GAAAd,YAAA,CAAAK,aAAA;AACvB,IAAAU,KAAA,GAAAC,OAAA,CAAAC,OAAkC;AAElC,IAAAC,iBAAA,GAAAD,OAA8C;AAEvC,IAAAT,kBAAM,GAAkBS,OAAe;AAC5C,IAAAL,eAAa,YAAAA,CAAA,EAAW;EAC1B,OAAAG,KAAA,CAAAI,UAAA,CAAAD,iBAAA,CAAAT,iBAAA;AAEO;AACL,SAAME,eAAaA,CAAA,EAAM;EAEzB,IAAIS,UAAA,GAAAL,KAAc,CAAAI,UAAqC,CAAAD,iBAAA,CAAAT,iBAAA;EACrD,IAAAW,UAAO;IACT;EAEA;EAAa,OACXL,KAAA,CAAAM,oBAAA,CAAAC,SAAA;IACA,OAAM;EAAA,GACN,YAAM;IACR;EACF;AAEA;AAA+B,IAAAA,SAAA,YAAAA,CAAA;EAIxB,OAAS,aACd;AAEA;AACF,SAAAZ,eAAAN,KAAA","ignoreList":[]}
|
package/dist/esm/ClientOnly.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { createContext, useContext } from "react";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
const ClientOnlyContext = createContext(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
const ClientOnlyContext = createContext(false);
|
|
4
|
+
const ClientOnly = ({
|
|
5
|
+
children,
|
|
6
|
+
enabled
|
|
7
|
+
}) => {
|
|
8
|
+
const existingValue = useContext(ClientOnlyContext);
|
|
9
|
+
return /* @__PURE__ */jsx(ClientOnlyContext.Provider, {
|
|
10
|
+
value: enabled ?? existingValue,
|
|
11
|
+
children
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
14
|
export { ClientOnly, ClientOnlyContext };
|
|
15
15
|
//# sourceMappingURL=ClientOnly.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createContext","useContext","jsx","ClientOnlyContext","ClientOnly","children","enabled","existingValue","Provider","value"],"sources":["../../src/ClientOnly.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAASA,aAAA,EAAeC,UAAA,QAAkB;AAatC,SAAAC,GAAA;AAXG,MAAMC,iBAAA,GAA4CH,aAAA,CAAc,
|
|
1
|
+
{"version":3,"names":["createContext","useContext","jsx","ClientOnlyContext","ClientOnly","children","enabled","existingValue","Provider","value"],"sources":["../../src/ClientOnly.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAASA,aAAA,EAAeC,UAAA,QAAkB;AAatC,SAAAC,GAAA;AAXG,MAAMC,iBAAA,GAA4CH,aAAA,CAAc,KAAK;AAErE,MAAMI,UAAA,GAAaA,CAAC;EACzBC,QAAA;EACAC;AACF,MAGuB;EACrB,MAAMC,aAAA,GAAgBN,UAAA,CAAWE,iBAAiB;EAClD,OACE,eAAAD,GAAA,CAACC,iBAAA,CAAkBK,QAAA,EAAlB;IAA2BC,KAAA,EAAOH,OAAA,IAAWC,aAAA;IAC3CF;EAAA,CACH;AAEJ","ignoreList":[]}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { createContext, useContext } from "react";
|
|
3
|
-
var ClientOnlyContext = /* @__PURE__ */createContext(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
3
|
+
var ClientOnlyContext = /* @__PURE__ */createContext(false);
|
|
4
|
+
var ClientOnly = function (param) {
|
|
5
|
+
var {
|
|
6
|
+
children,
|
|
7
|
+
enabled
|
|
8
|
+
} = param;
|
|
9
|
+
var existingValue = useContext(ClientOnlyContext);
|
|
10
|
+
return /* @__PURE__ */_jsx(ClientOnlyContext.Provider, {
|
|
11
|
+
value: enabled !== null && enabled !== void 0 ? enabled : existingValue,
|
|
12
|
+
children
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
15
|
export { ClientOnly, ClientOnlyContext };
|
|
16
16
|
//# sourceMappingURL=ClientOnly.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["jsx","_jsx","createContext","useContext","ClientOnlyContext","ClientOnly","param","children","enabled","existingValue","Provider","value"],"sources":["../../src/ClientOnly.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAASA,GAAA,IAAAC,IAAA,QAAe,mBAAkB;AAatC,SAAAC,aAAA,EAAAC,UAAA;AAXG,IAAAC,iBAAM,kBAA0DF,
|
|
1
|
+
{"version":3,"names":["jsx","_jsx","createContext","useContext","ClientOnlyContext","ClientOnly","param","children","enabled","existingValue","Provider","value"],"sources":["../../src/ClientOnly.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAASA,GAAA,IAAAC,IAAA,QAAe,mBAAkB;AAatC,SAAAC,aAAA,EAAAC,UAAA;AAXG,IAAAC,iBAAM,kBAA0DF,aAAK;AAErE,IAAAG,UAAM,YAAAA,CAAcC,KAAA;EACzB;IAAAC,QAAA;IAAAC;EAAA,IAAAF,KAAA;EACA,IAAAG,aAAA,GAAAN,UAAA,CAAAC,iBAAA;EACF,OAGuB,eAAAH,IAAA,CAAAG,iBAAA,CAAAM,QAAA;IACrBC,KAAM,EAAAH,OAAA,SAAgB,IAAAA,OAAW,cAAiBA,OAAA,GAAAC,aAAA;IAClDF;EAKF","ignoreList":[]}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { ClientOnlyContext } from "./ClientOnly.mjs";
|
|
3
3
|
import { ClientOnly, ClientOnlyContext as ClientOnlyContext2 } from "./ClientOnly.mjs";
|
|
4
|
-
const useIsClientOnly = () =>
|
|
4
|
+
const useIsClientOnly = () => {
|
|
5
|
+
return React.useContext(ClientOnlyContext);
|
|
6
|
+
};
|
|
5
7
|
function useDidFinishSSR() {
|
|
6
|
-
|
|
8
|
+
const clientOnly = React.useContext(ClientOnlyContext);
|
|
9
|
+
if (clientOnly || false) {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
return React.useSyncExternalStore(subscribe, () => true, () => false);
|
|
7
13
|
}
|
|
8
14
|
const subscribe = () => () => {};
|
|
9
15
|
function useClientValue(value) {
|
|
10
|
-
|
|
16
|
+
const done = useDidFinishSSR();
|
|
17
|
+
return !done ? void 0 : typeof value === "function" ? value() : value;
|
|
11
18
|
}
|
|
12
19
|
export { ClientOnly, ClientOnlyContext2 as ClientOnlyContext, useClientValue, useDidFinishSSR, useIsClientOnly };
|
|
13
20
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","ClientOnlyContext","ClientOnly","ClientOnlyContext2","useIsClientOnly","useContext","useDidFinishSSR","useSyncExternalStore","subscribe","useClientValue","value"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAASC,iBAAA,QAAyB;AAElC,SAASC,UAAA,EAAYD,iBAAA,IAAAE,kBAAA,QAAyB;AAEvC,MAAMC,eAAA,GAAkBA,CAAA,
|
|
1
|
+
{"version":3,"names":["React","ClientOnlyContext","ClientOnly","ClientOnlyContext2","useIsClientOnly","useContext","useDidFinishSSR","clientOnly","useSyncExternalStore","subscribe","useClientValue","value","done"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAASC,iBAAA,QAAyB;AAElC,SAASC,UAAA,EAAYD,iBAAA,IAAAE,kBAAA,QAAyB;AAEvC,MAAMC,eAAA,GAAkBA,CAAA,KAAe;EAC5C,OAAOJ,KAAA,CAAMK,UAAA,CAAWJ,iBAAiB;AAC3C;AAEO,SAASK,gBAAA,EAA2B;EACzC,MAAMC,UAAA,GAAaP,KAAA,CAAMK,UAAA,CAAWJ,iBAAiB;EAErD,IAAIM,UAAA,IAAc,OAAqC;IACrD,OAAO;EACT;EAEA,OAAOP,KAAA,CAAMQ,oBAAA,CACXC,SAAA,EACA,MAAM,MACN,MAAM,KACR;AACF;AAEA,MAAMA,SAAA,GAAYA,CAAA,KAAM,MAAM,CAAC;AAIxB,SAASC,eAAsBC,KAAA,EAAmD;EACvF,MAAMC,IAAA,GAAON,eAAA,CAAgB;EAE7B,OAAO,CAACM,IAAA,GAAO,SAAY,OAAOD,KAAA,KAAU,aAAaA,KAAA,CAAM,IAAIA,KAAA;AACrE","ignoreList":[]}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { ClientOnlyContext } from "./ClientOnly.mjs";
|
|
3
3
|
import { ClientOnly, ClientOnlyContext as ClientOnlyContext2 } from "./ClientOnly.mjs";
|
|
4
|
-
const useIsClientOnly = () =>
|
|
4
|
+
const useIsClientOnly = () => {
|
|
5
|
+
return React.useContext(ClientOnlyContext);
|
|
6
|
+
};
|
|
5
7
|
function useDidFinishSSR() {
|
|
6
|
-
|
|
8
|
+
const clientOnly = React.useContext(ClientOnlyContext);
|
|
9
|
+
if (clientOnly || false) {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
return React.useSyncExternalStore(subscribe, () => true, () => false);
|
|
7
13
|
}
|
|
8
14
|
const subscribe = () => () => {};
|
|
9
15
|
function useClientValue(value) {
|
|
10
|
-
|
|
16
|
+
const done = useDidFinishSSR();
|
|
17
|
+
return !done ? void 0 : typeof value === "function" ? value() : value;
|
|
11
18
|
}
|
|
12
19
|
export { ClientOnly, ClientOnlyContext2 as ClientOnlyContext, useClientValue, useDidFinishSSR, useIsClientOnly };
|
|
13
20
|
//# sourceMappingURL=index.mjs.map
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","ClientOnlyContext","ClientOnly","ClientOnlyContext2","useIsClientOnly","useContext","useDidFinishSSR","useSyncExternalStore","subscribe","useClientValue","value"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAASC,iBAAA,QAAyB;AAElC,SAASC,UAAA,EAAYD,iBAAA,IAAAE,kBAAA,QAAyB;AAEvC,MAAMC,eAAA,GAAkBA,CAAA,
|
|
1
|
+
{"version":3,"names":["React","ClientOnlyContext","ClientOnly","ClientOnlyContext2","useIsClientOnly","useContext","useDidFinishSSR","clientOnly","useSyncExternalStore","subscribe","useClientValue","value","done"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAASC,iBAAA,QAAyB;AAElC,SAASC,UAAA,EAAYD,iBAAA,IAAAE,kBAAA,QAAyB;AAEvC,MAAMC,eAAA,GAAkBA,CAAA,KAAe;EAC5C,OAAOJ,KAAA,CAAMK,UAAA,CAAWJ,iBAAiB;AAC3C;AAEO,SAASK,gBAAA,EAA2B;EACzC,MAAMC,UAAA,GAAaP,KAAA,CAAMK,UAAA,CAAWJ,iBAAiB;EAErD,IAAIM,UAAA,IAAc,OAAqC;IACrD,OAAO;EACT;EAEA,OAAOP,KAAA,CAAMQ,oBAAA,CACXC,SAAA,EACA,MAAM,MACN,MAAM,KACR;AACF;AAEA,MAAMA,SAAA,GAAYA,CAAA,KAAM,MAAM,CAAC;AAIxB,SAASC,eAAsBC,KAAA,EAAmD;EACvF,MAAMC,IAAA,GAAON,eAAA,CAAgB;EAE7B,OAAO,CAACM,IAAA,GAAO,SAAY,OAAOD,KAAA,KAAU,aAAaA,KAAA,CAAM,IAAIA,KAAA;AACrE","ignoreList":[]}
|
package/dist/esm/index.native.js
CHANGED
|
@@ -6,14 +6,21 @@ var useIsClientOnly = function () {
|
|
|
6
6
|
};
|
|
7
7
|
function useDidFinishSSR() {
|
|
8
8
|
var clientOnly = React.useContext(ClientOnlyContext);
|
|
9
|
-
|
|
9
|
+
if (clientOnly || true) {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
return React.useSyncExternalStore(subscribe, function () {
|
|
13
|
+
return true;
|
|
14
|
+
}, function () {
|
|
15
|
+
return false;
|
|
16
|
+
});
|
|
10
17
|
}
|
|
11
18
|
var subscribe = function () {
|
|
12
19
|
return function () {};
|
|
13
20
|
};
|
|
14
21
|
function useClientValue(value) {
|
|
15
22
|
var done = useDidFinishSSR();
|
|
16
|
-
return done ? typeof value
|
|
23
|
+
return !done ? void 0 : typeof value === "function" ? value() : value;
|
|
17
24
|
}
|
|
18
25
|
export { ClientOnly, ClientOnlyContext2 as ClientOnlyContext, useClientValue, useDidFinishSSR, useIsClientOnly };
|
|
19
26
|
//# sourceMappingURL=index.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","ClientOnlyContext","ClientOnly","ClientOnlyContext2","useIsClientOnly","useContext","useDidFinishSSR","clientOnly","subscribe","useClientValue","value","done"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAASC,iBAAA,QAAyB;AAElC,SAASC,UAAA,EAAYD,iBAAA,IAAAE,kBAAA,QAAyB;AAEvC,IAAAC,eAAM,YAAAA,CAAA,
|
|
1
|
+
{"version":3,"names":["React","ClientOnlyContext","ClientOnly","ClientOnlyContext2","useIsClientOnly","useContext","useDidFinishSSR","clientOnly","useSyncExternalStore","subscribe","useClientValue","value","done"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAASC,iBAAA,QAAyB;AAElC,SAASC,UAAA,EAAYD,iBAAA,IAAAE,kBAAA,QAAyB;AAEvC,IAAAC,eAAM,YAAAA,CAAA,EAAiC;EAC5C,OAAOJ,KAAA,CAAMK,UAAA,CAAWJ,iBAAiB;AAC3C;AAEO,SAASK,gBAAA,EAA2B;EACzC,IAAAC,UAAM,GAAAP,KAAa,CAAAK,UAAM,CAAAJ,iBAAW;EAEpC,IAAIM,UAAA,IAAc;IAChB,OAAO;EACT;EAEA,OAAOP,KAAA,CAAMQ,oBAAA,CAAAC,SAAA;IACX;EAAA,GACA,YAAM;IACN,OAAM;EACR;AACF;AAEA,IAAAA,SAAM,YAAAA,CAAA,EAAkB;EAAO,oBAIxB;AACL;AAEA,SAAOC,cAAQA,CAAAC,KAAY;EAC7B,IAAAC,IAAA,GAAAN,eAAA","ignoreList":[]}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -10,7 +10,7 @@ export const useIsClientOnly = (): boolean => {
|
|
|
10
10
|
export function useDidFinishSSR(): boolean {
|
|
11
11
|
const clientOnly = React.useContext(ClientOnlyContext)
|
|
12
12
|
|
|
13
|
-
if (clientOnly || process.env.
|
|
13
|
+
if (clientOnly || process.env.GUI_TARGET === 'native') {
|
|
14
14
|
return true
|
|
15
15
|
}
|
|
16
16
|
|
package/types/index.d.ts.map
CHANGED
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
],
|
|
7
7
|
"version": 3,
|
|
8
8
|
"sourcesContent": [
|
|
9
|
-
"import * as React from 'react'\nimport { ClientOnlyContext } from './ClientOnly'\n\nexport { ClientOnly, ClientOnlyContext } from './ClientOnly'\n\nexport const useIsClientOnly = (): boolean => {\n return React.useContext(ClientOnlyContext)\n}\n\nexport function useDidFinishSSR(): boolean {\n const clientOnly = React.useContext(ClientOnlyContext)\n\n if (clientOnly || process.env.
|
|
9
|
+
"import * as React from 'react'\nimport { ClientOnlyContext } from './ClientOnly'\n\nexport { ClientOnly, ClientOnlyContext } from './ClientOnly'\n\nexport const useIsClientOnly = (): boolean => {\n return React.useContext(ClientOnlyContext)\n}\n\nexport function useDidFinishSSR(): boolean {\n const clientOnly = React.useContext(ClientOnlyContext)\n\n if (clientOnly || process.env.GUI_TARGET === 'native') {\n return true\n }\n\n return React.useSyncExternalStore(\n subscribe,\n () => true,\n () => false\n )\n}\n\nconst subscribe = () => () => {}\n\ntype FunctionOrValue<Value> = Value extends () => infer X ? X : Value\n\nexport function useClientValue<Value>(value?: Value): FunctionOrValue<Value> | undefined {\n const done = useDidFinishSSR()\n // @ts-expect-error this is fine but started to error in ts latest\n return !done ? undefined : typeof value === 'function' ? value() : value\n}\n"
|
|
10
10
|
]
|
|
11
11
|
}
|