@tamagui/use-did-finish-ssr 1.129.3 → 1.129.5-1751174117974
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 +35 -0
- package/dist/cjs/ClientOnly.js +23 -0
- package/dist/cjs/ClientOnly.js.map +6 -0
- package/dist/cjs/ClientOnly.native.js +34 -0
- package/dist/cjs/ClientOnly.native.js.map +6 -0
- package/dist/cjs/index.cjs +9 -3
- package/dist/cjs/index.js +7 -3
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/index.native.js +12 -3
- package/dist/cjs/index.native.js.map +2 -2
- package/dist/esm/ClientOnly.js +8 -0
- package/dist/esm/ClientOnly.js.map +6 -0
- package/dist/esm/ClientOnly.mjs +11 -0
- package/dist/esm/ClientOnly.mjs.map +1 -0
- package/dist/esm/ClientOnly.native.js +14 -0
- package/dist/esm/ClientOnly.native.js.map +1 -0
- package/dist/esm/index.js +8 -2
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/index.mjs +5 -2
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/index.native.js +7 -1
- package/dist/esm/index.native.js.map +1 -1
- package/package.json +2 -2
- package/src/ClientOnly.tsx +7 -0
- package/src/index.ts +10 -1
- package/types/ClientOnly.d.ts +6 -0
- package/types/ClientOnly.d.ts.map +13 -0
- package/types/index.d.ts +2 -1
- package/types/index.d.ts.map +2 -2
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: !0
|
|
9
|
+
});
|
|
10
|
+
},
|
|
11
|
+
__copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
13
|
+
get: () => from[key],
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
+
value: !0
|
|
20
|
+
}), mod);
|
|
21
|
+
var ClientOnly_exports = {};
|
|
22
|
+
__export(ClientOnly_exports, {
|
|
23
|
+
ClientOnly: () => ClientOnly,
|
|
24
|
+
ClientOnlyContext: () => ClientOnlyContext
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(ClientOnly_exports);
|
|
27
|
+
var import_react = require("react"),
|
|
28
|
+
import_jsx_runtime = require("react/jsx-runtime");
|
|
29
|
+
const ClientOnlyContext = (0, import_react.createContext)(!1),
|
|
30
|
+
ClientOnly = ({
|
|
31
|
+
children
|
|
32
|
+
}) => /* @__PURE__ */(0, import_jsx_runtime.jsx)(ClientOnlyContext.Provider, {
|
|
33
|
+
value: !0,
|
|
34
|
+
children
|
|
35
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
+
var ClientOnly_exports = {};
|
|
16
|
+
__export(ClientOnly_exports, {
|
|
17
|
+
ClientOnly: () => ClientOnly,
|
|
18
|
+
ClientOnlyContext: () => ClientOnlyContext
|
|
19
|
+
});
|
|
20
|
+
module.exports = __toCommonJS(ClientOnly_exports);
|
|
21
|
+
var import_react = require("react"), import_jsx_runtime = require("react/jsx-runtime");
|
|
22
|
+
const ClientOnlyContext = (0, import_react.createContext)(!1), ClientOnly = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ClientOnlyContext.Provider, { value: !0, children });
|
|
23
|
+
//# sourceMappingURL=ClientOnly.js.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
9
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
return to;
|
|
14
|
+
};
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
16
|
+
var ClientOnly_exports = {};
|
|
17
|
+
__export(ClientOnly_exports, {
|
|
18
|
+
ClientOnly: () => ClientOnly,
|
|
19
|
+
ClientOnlyContext: () => ClientOnlyContext
|
|
20
|
+
});
|
|
21
|
+
module.exports = __toCommonJS(ClientOnly_exports);
|
|
22
|
+
var import_jsx_runtime = require("react/jsx-runtime"), import_react = require("react"), ClientOnlyContext = /* @__PURE__ */ (0, import_react.createContext)(!1), ClientOnly = function(param) {
|
|
23
|
+
var { children } = param;
|
|
24
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ClientOnlyContext.Provider, {
|
|
25
|
+
value: !0,
|
|
26
|
+
children
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
+
0 && (module.exports = {
|
|
31
|
+
ClientOnly,
|
|
32
|
+
ClientOnlyContext
|
|
33
|
+
});
|
|
34
|
+
//# sourceMappingURL=ClientOnly.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/ClientOnly.tsx"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;uDAAA,eAA8B,kBAEjBA,oBAA4CC,gDAAc,EAAA,GAE1DC,aAAa,SAAA,OAAA;MAAC,EAAEC,SAAQ,IAAqB;AACxD,SAAO,uCAAAC,KAACJ,kBAAkBK,UAAQ;IAACC,OAAO;;;AAC5C;",
|
|
5
|
+
"names": ["ClientOnlyContext", "createContext", "ClientOnly", "children", "_jsx", "Provider", "value"]
|
|
6
|
+
}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -31,13 +31,19 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
31
31
|
}), mod);
|
|
32
32
|
var index_exports = {};
|
|
33
33
|
__export(index_exports, {
|
|
34
|
+
ClientOnly: () => import_ClientOnly2.ClientOnly,
|
|
35
|
+
ClientOnlyContext: () => import_ClientOnly2.ClientOnlyContext,
|
|
34
36
|
useClientValue: () => useClientValue,
|
|
35
|
-
useDidFinishSSR: () => useDidFinishSSR
|
|
37
|
+
useDidFinishSSR: () => useDidFinishSSR,
|
|
38
|
+
useIsClientOnly: () => useIsClientOnly
|
|
36
39
|
});
|
|
37
40
|
module.exports = __toCommonJS(index_exports);
|
|
38
|
-
var React = __toESM(require("react"))
|
|
41
|
+
var React = __toESM(require("react")),
|
|
42
|
+
import_ClientOnly = require("./ClientOnly.cjs"),
|
|
43
|
+
import_ClientOnly2 = require("./ClientOnly.cjs");
|
|
44
|
+
const useIsClientOnly = () => React.useContext(import_ClientOnly.ClientOnlyContext);
|
|
39
45
|
function useDidFinishSSR(value) {
|
|
40
|
-
return React.useSyncExternalStore(subscribe, () => value ?? !0, () => !1);
|
|
46
|
+
return React.useContext(import_ClientOnly.ClientOnlyContext) ? value ?? !0 : React.useSyncExternalStore(subscribe, () => value ?? !0, () => !1);
|
|
41
47
|
}
|
|
42
48
|
const subscribe = () => () => {};
|
|
43
49
|
function useClientValue(value) {
|
package/dist/cjs/index.js
CHANGED
|
@@ -22,13 +22,17 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
22
|
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
23
23
|
var index_exports = {};
|
|
24
24
|
__export(index_exports, {
|
|
25
|
+
ClientOnly: () => import_ClientOnly2.ClientOnly,
|
|
26
|
+
ClientOnlyContext: () => import_ClientOnly2.ClientOnlyContext,
|
|
25
27
|
useClientValue: () => useClientValue,
|
|
26
|
-
useDidFinishSSR: () => useDidFinishSSR
|
|
28
|
+
useDidFinishSSR: () => useDidFinishSSR,
|
|
29
|
+
useIsClientOnly: () => useIsClientOnly
|
|
27
30
|
});
|
|
28
31
|
module.exports = __toCommonJS(index_exports);
|
|
29
|
-
var React = __toESM(require("react"));
|
|
32
|
+
var React = __toESM(require("react")), import_ClientOnly = require("./ClientOnly"), import_ClientOnly2 = require("./ClientOnly");
|
|
33
|
+
const useIsClientOnly = () => React.useContext(import_ClientOnly.ClientOnlyContext);
|
|
30
34
|
function useDidFinishSSR(value) {
|
|
31
|
-
return React.useSyncExternalStore(
|
|
35
|
+
return React.useContext(import_ClientOnly.ClientOnlyContext) ? value ?? !0 : React.useSyncExternalStore(
|
|
32
36
|
subscribe,
|
|
33
37
|
() => value ?? !0,
|
|
34
38
|
() => !1
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAAuB;
|
|
5
|
-
"names": []
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAAuB,2BACvB,oBAAkC,yBAElCA,qBAA8C;AAEvC,MAAM,kBAAkB,MACtB,MAAM,WAAW,mCAAiB;AAGpC,SAAS,gBAA6B,OAAsB;AAGjE,SAFmB,MAAM,WAAW,mCAAiB,IAI5C,SAAS,KAGX,MAAM;AAAA,IACX;AAAA,IACA,MAAM,SAAS;AAAA,IACf,MACS;AAAA,EAEX;AACF;AAEA,MAAM,YAAY,MAAM,MAAM;AAAC;AAIxB,SAAS,eAAsB,OAAmD;AAGvF,SAFa,gBAAgB,IAEF,OAAO,SAAU,aAAa,MAAM,IAAI,QAApD;AACjB;",
|
|
5
|
+
"names": ["import_ClientOnly"]
|
|
6
6
|
}
|
package/dist/cjs/index.native.js
CHANGED
|
@@ -23,12 +23,18 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
23
|
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
24
24
|
var index_exports = {};
|
|
25
25
|
__export(index_exports, {
|
|
26
|
+
ClientOnly: () => import_ClientOnly2.ClientOnly,
|
|
27
|
+
ClientOnlyContext: () => import_ClientOnly2.ClientOnlyContext,
|
|
26
28
|
useClientValue: () => useClientValue,
|
|
27
|
-
useDidFinishSSR: () => useDidFinishSSR
|
|
29
|
+
useDidFinishSSR: () => useDidFinishSSR,
|
|
30
|
+
useIsClientOnly: () => useIsClientOnly
|
|
28
31
|
});
|
|
29
32
|
module.exports = __toCommonJS(index_exports);
|
|
30
|
-
var React = __toESM(require("react"))
|
|
33
|
+
var React = __toESM(require("react")), import_ClientOnly = require("./ClientOnly"), import_ClientOnly2 = require("./ClientOnly"), useIsClientOnly = function() {
|
|
34
|
+
return React.useContext(import_ClientOnly.ClientOnlyContext);
|
|
35
|
+
};
|
|
31
36
|
function useDidFinishSSR(value) {
|
|
37
|
+
var clientOnly = React.useContext(import_ClientOnly.ClientOnlyContext);
|
|
32
38
|
return value ?? !0;
|
|
33
39
|
}
|
|
34
40
|
var subscribe = function() {
|
|
@@ -41,7 +47,10 @@ function useClientValue(value) {
|
|
|
41
47
|
}
|
|
42
48
|
// Annotate the CommonJS export names for ESM import in node:
|
|
43
49
|
0 && (module.exports = {
|
|
50
|
+
ClientOnly,
|
|
51
|
+
ClientOnlyContext,
|
|
44
52
|
useClientValue,
|
|
45
|
-
useDidFinishSSR
|
|
53
|
+
useDidFinishSSR,
|
|
54
|
+
useIsClientOnly
|
|
46
55
|
});
|
|
47
56
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA
|
|
5
|
-
"names": ["useDidFinishSSR", "value", "subscribe", "useClientValue", "done", "undefined"]
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;YAAuB,2BACvB,oBAAkC,yBAElCA,qBAA8C,yBAEjCC,kBAAkB,WAAA;AAC7B,SAAOC,MAAMC,WAAWC,mCAAAA;AAC1B;AAEO,SAASC,gBAA6BC,OAAS;AACpD,MAAMC,aAAaL,MAAMC,WAAWC,mCAAAA;AAIlC,SAAOE,SAAS;AAUpB;AAEA,IAAME,YAAY,WAAA;SAAM,WAAA;EAAO;;AAIxB,SAASC,eAAsBH,OAAa;AACjD,MAAMI,OAAOL,gBAAAA;AAEb,SAAQK,OAAmB,OAAOJ,SAAU,aAAaA,MAAAA,IAAUA,QAApDK;AACjB;",
|
|
5
|
+
"names": ["import_ClientOnly", "useIsClientOnly", "React", "useContext", "ClientOnlyContext", "useDidFinishSSR", "value", "clientOnly", "subscribe", "useClientValue", "done", "undefined"]
|
|
6
6
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createContext } from "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
const ClientOnlyContext = createContext(!1), ClientOnly = ({ children }) => /* @__PURE__ */ jsx(ClientOnlyContext.Provider, { value: !0, children });
|
|
4
|
+
export {
|
|
5
|
+
ClientOnly,
|
|
6
|
+
ClientOnlyContext
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=ClientOnly.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createContext } from "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
const ClientOnlyContext = createContext(!1),
|
|
4
|
+
ClientOnly = ({
|
|
5
|
+
children
|
|
6
|
+
}) => /* @__PURE__ */jsx(ClientOnlyContext.Provider, {
|
|
7
|
+
value: !0,
|
|
8
|
+
children
|
|
9
|
+
});
|
|
10
|
+
export { ClientOnly, ClientOnlyContext };
|
|
11
|
+
//# sourceMappingURL=ClientOnly.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createContext","jsx","ClientOnlyContext","ClientOnly","children","Provider","value"],"sources":["../../src/ClientOnly.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAASA,aAAA,QAAqB;AAKrB,SAAAC,GAAA;AAHF,MAAMC,iBAAA,GAA4CF,aAAA,CAAc,EAAK;EAE/DG,UAAA,GAAaA,CAAC;IAAEC;EAAS,MAC7B,eAAAH,GAAA,CAACC,iBAAA,CAAkBG,QAAA,EAAlB;IAA2BC,KAAA,EAAO;IAAOF;EAAA,CAAS","ignoreList":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext } from "react";
|
|
3
|
+
var ClientOnlyContext = /* @__PURE__ */createContext(!1),
|
|
4
|
+
ClientOnly = function (param) {
|
|
5
|
+
var {
|
|
6
|
+
children
|
|
7
|
+
} = param;
|
|
8
|
+
return /* @__PURE__ */_jsx(ClientOnlyContext.Provider, {
|
|
9
|
+
value: !0,
|
|
10
|
+
children
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
export { ClientOnly, ClientOnlyContext };
|
|
14
|
+
//# sourceMappingURL=ClientOnly.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["jsx","_jsx","createContext","ClientOnlyContext","ClientOnly","param"],"sources":["../../src/ClientOnly.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAASA,GAAA,IAAAC,IAAA,2BAAqB;AAKrB,SAAAC,aAAA;AAHF,IAAAC,iBAAM,kBAA0DD,aAE1D;EAAcE,UAAE,GAAS,SAAAA,CAC7BC,KAAA","ignoreList":[]}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
import { ClientOnlyContext } from "./ClientOnly";
|
|
3
|
+
import { ClientOnly, ClientOnlyContext as ClientOnlyContext2 } from "./ClientOnly";
|
|
4
|
+
const useIsClientOnly = () => React.useContext(ClientOnlyContext);
|
|
2
5
|
function useDidFinishSSR(value) {
|
|
3
|
-
return React.useSyncExternalStore(
|
|
6
|
+
return React.useContext(ClientOnlyContext) ? value ?? !0 : React.useSyncExternalStore(
|
|
4
7
|
subscribe,
|
|
5
8
|
() => value ?? !0,
|
|
6
9
|
() => !1
|
|
@@ -12,7 +15,10 @@ function useClientValue(value) {
|
|
|
12
15
|
return useDidFinishSSR() ? typeof value == "function" ? value() : value : void 0;
|
|
13
16
|
}
|
|
14
17
|
export {
|
|
18
|
+
ClientOnly,
|
|
19
|
+
ClientOnlyContext2 as ClientOnlyContext,
|
|
15
20
|
useClientValue,
|
|
16
|
-
useDidFinishSSR
|
|
21
|
+
useDidFinishSSR,
|
|
22
|
+
useIsClientOnly
|
|
17
23
|
};
|
|
18
24
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"mappings": "AAAA,YAAY,WAAW;
|
|
5
|
-
"names": []
|
|
4
|
+
"mappings": "AAAA,YAAY,WAAW;AACvB,SAAS,yBAAyB;AAElC,SAAS,YAAY,qBAAAA,0BAAyB;AAEvC,MAAM,kBAAkB,MACtB,MAAM,WAAW,iBAAiB;AAGpC,SAAS,gBAA6B,OAAsB;AAGjE,SAFmB,MAAM,WAAW,iBAAiB,IAI5C,SAAS,KAGX,MAAM;AAAA,IACX;AAAA,IACA,MAAM,SAAS;AAAA,IACf,MACS;AAAA,EAEX;AACF;AAEA,MAAM,YAAY,MAAM,MAAM;AAAC;AAIxB,SAAS,eAAsB,OAAmD;AAGvF,SAFa,gBAAgB,IAEF,OAAO,SAAU,aAAa,MAAM,IAAI,QAApD;AACjB;",
|
|
5
|
+
"names": ["ClientOnlyContext"]
|
|
6
6
|
}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
import { ClientOnlyContext } from "./ClientOnly.mjs";
|
|
3
|
+
import { ClientOnly, ClientOnlyContext as ClientOnlyContext2 } from "./ClientOnly.mjs";
|
|
4
|
+
const useIsClientOnly = () => React.useContext(ClientOnlyContext);
|
|
2
5
|
function useDidFinishSSR(value) {
|
|
3
|
-
return React.useSyncExternalStore(subscribe, () => value ?? !0, () => !1);
|
|
6
|
+
return React.useContext(ClientOnlyContext) ? value ?? !0 : React.useSyncExternalStore(subscribe, () => value ?? !0, () => !1);
|
|
4
7
|
}
|
|
5
8
|
const subscribe = () => () => {};
|
|
6
9
|
function useClientValue(value) {
|
|
7
10
|
return useDidFinishSSR() ? typeof value == "function" ? value() : value : void 0;
|
|
8
11
|
}
|
|
9
|
-
export { useClientValue, useDidFinishSSR };
|
|
12
|
+
export { ClientOnly, ClientOnlyContext2 as ClientOnlyContext, useClientValue, useDidFinishSSR, useIsClientOnly };
|
|
10
13
|
//# sourceMappingURL=index.mjs.map
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useDidFinishSSR","value","useSyncExternalStore","subscribe","useClientValue"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,YAAYA,KAAA,MAAW;
|
|
1
|
+
{"version":3,"names":["React","ClientOnlyContext","ClientOnly","ClientOnlyContext2","useIsClientOnly","useContext","useDidFinishSSR","value","useSyncExternalStore","subscribe","useClientValue"],"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,KACtBJ,KAAA,CAAMK,UAAA,CAAWJ,iBAAiB;AAGpC,SAASK,gBAA6BC,KAAA,EAAsB;EAGjE,OAFmBP,KAAA,CAAMK,UAAA,CAAWJ,iBAAiB,IAI5CM,KAAA,IAAS,KAGXP,KAAA,CAAMQ,oBAAA,CACXC,SAAA,EACA,MAAMF,KAAA,IAAS,IACf,MACS,EAEX;AACF;AAEA,MAAME,SAAA,GAAYA,CAAA,KAAM,MAAM,CAAC;AAIxB,SAASC,eAAsBH,KAAA,EAAmD;EAGvF,OAFaD,eAAA,CAAgB,IAEF,OAAOC,KAAA,IAAU,aAAaA,KAAA,CAAM,IAAIA,KAAA,GAApD;AACjB","ignoreList":[]}
|
package/dist/esm/index.native.js
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
import { ClientOnlyContext } from "./ClientOnly.native.js";
|
|
3
|
+
import { ClientOnly, ClientOnlyContext as ClientOnlyContext2 } from "./ClientOnly.native.js";
|
|
4
|
+
var useIsClientOnly = function () {
|
|
5
|
+
return React.useContext(ClientOnlyContext);
|
|
6
|
+
};
|
|
2
7
|
function useDidFinishSSR(value) {
|
|
8
|
+
var clientOnly = React.useContext(ClientOnlyContext);
|
|
3
9
|
return value ?? !0;
|
|
4
10
|
}
|
|
5
11
|
var subscribe = function () {
|
|
@@ -9,5 +15,5 @@ function useClientValue(value) {
|
|
|
9
15
|
var done = useDidFinishSSR();
|
|
10
16
|
return done ? typeof value == "function" ? value() : value : void 0;
|
|
11
17
|
}
|
|
12
|
-
export { useClientValue, useDidFinishSSR };
|
|
18
|
+
export { ClientOnly, ClientOnlyContext2 as ClientOnlyContext, useClientValue, useDidFinishSSR, useIsClientOnly };
|
|
13
19
|
//# sourceMappingURL=index.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useDidFinishSSR","value","subscribe","useClientValue","done"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,YAAYA,KAAA,MAAW;
|
|
1
|
+
{"version":3,"names":["React","ClientOnlyContext","ClientOnly","ClientOnlyContext2","useIsClientOnly","useContext","useDidFinishSSR","value","clientOnly","subscribe","useClientValue","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,EACJ;EAGF,OAASJ,KAAA,CAAAK,UAA6B,CAAAJ,iBAAsB;AAGjE;AAKa,SACXK,gBAAAC,KAAA;EAAA,IACAC,UAAM,GAASR,KAAA,CAAAK,UAAA,CAAAJ,iBAAA;EAAA,OACfM,KACS;AAAA;AAGb,IAAAE,SAAA,YAAAA,CAAA;EAEA,OAAM,YAAY,CAAa;AAIxB;AAGL,SAFaC,eAAAH,KAEc;EAC7B,IAAAI,IAAA,GAAAL,eAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/use-did-finish-ssr",
|
|
3
|
-
"version": "1.129.
|
|
3
|
+
"version": "1.129.5-1751174117974",
|
|
4
4
|
"types": "./types/index.d.ts",
|
|
5
5
|
"main": "dist/cjs",
|
|
6
6
|
"module": "dist/esm",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@tamagui/build": "1.129.
|
|
34
|
+
"@tamagui/build": "1.129.5-1751174117974",
|
|
35
35
|
"react": "*"
|
|
36
36
|
},
|
|
37
37
|
"publishConfig": {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createContext } from 'react'
|
|
2
|
+
|
|
3
|
+
export const ClientOnlyContext: React.Context<boolean> = createContext(false)
|
|
4
|
+
|
|
5
|
+
export const ClientOnly = ({ children }: { children: any }): React.ReactNode => {
|
|
6
|
+
return <ClientOnlyContext.Provider value={true}>{children}</ClientOnlyContext.Provider>
|
|
7
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import * as React from 'react'
|
|
2
|
+
import { ClientOnlyContext } from './ClientOnly'
|
|
3
|
+
|
|
4
|
+
export { ClientOnly, ClientOnlyContext } from './ClientOnly'
|
|
5
|
+
|
|
6
|
+
export const useIsClientOnly = (): boolean => {
|
|
7
|
+
return React.useContext(ClientOnlyContext)
|
|
8
|
+
}
|
|
2
9
|
|
|
3
10
|
export function useDidFinishSSR<A = boolean>(value?: A): A | false {
|
|
4
|
-
|
|
11
|
+
const clientOnly = React.useContext(ClientOnlyContext)
|
|
12
|
+
|
|
13
|
+
if (clientOnly || process.env.TAMAGUI_TARGET === 'native') {
|
|
5
14
|
// @ts-expect-error
|
|
6
15
|
return value ?? true
|
|
7
16
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"mappings": "AAEA,OAAO,cAAMA,mBAAmB,MAAM;AAEtC,OAAO,cAAM,aAAc,EAAE,UAA6B,EAAjB;CAAE;AAAe,MAAG,MAAM",
|
|
3
|
+
"names": [
|
|
4
|
+
"ClientOnlyContext: React.Context<boolean>"
|
|
5
|
+
],
|
|
6
|
+
"sources": [
|
|
7
|
+
"src/ClientOnly.tsx"
|
|
8
|
+
],
|
|
9
|
+
"sourcesContent": [
|
|
10
|
+
"import { createContext } from 'react'\n\nexport const ClientOnlyContext: React.Context<boolean> = createContext(false)\n\nexport const ClientOnly = ({ children }: { children: any }): React.ReactNode => {\n return <ClientOnlyContext.Provider value={true}>{children}</ClientOnlyContext.Provider>\n}\n"
|
|
11
|
+
],
|
|
12
|
+
"version": 3
|
|
13
|
+
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
export { ClientOnly, ClientOnlyContext } from "./ClientOnly";
|
|
2
|
+
export declare const useIsClientOnly: () => boolean;
|
|
1
3
|
export declare function useDidFinishSSR<A = boolean>(value?: A): A | false;
|
|
2
4
|
type FunctionOrValue<Value> = Value extends () => infer X ? X : Value;
|
|
3
5
|
export declare function useClientValue<Value>(value?: Value): FunctionOrValue<Value> | undefined;
|
|
4
|
-
export {};
|
|
5
6
|
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
package/types/index.d.ts.map
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"mappings": "
|
|
2
|
+
"mappings": "AAGA,SAAS,YAAY,yBAAyB;AAE9C,OAAO,cAAM;AAIb,OAAO,iBAAS,gBAAgB,aAAaA,QAAQ,IAAI,IAAI;KAmBxD,gBAAgB,SAAS,0BAA0B,IAAI,IAAI;AAEhE,OAAO,iBAAS,eAAe,OAAOC,QAAQ,QAAQ,gBAAgB",
|
|
3
3
|
"names": [
|
|
4
4
|
"value?: A",
|
|
5
5
|
"value?: Value"
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"src/index.ts"
|
|
9
9
|
],
|
|
10
10
|
"sourcesContent": [
|
|
11
|
-
"import * as React from 'react'\n\nexport function useDidFinishSSR<A = boolean>(value?: A): A | false {\n if (process.env.TAMAGUI_TARGET === 'native') {\n // @ts-expect-error\n return value ?? true\n }\n\n return React.useSyncExternalStore(\n subscribe,\n () => value ?? true,\n () => {\n return false as any\n }\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"
|
|
11
|
+
"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<A = boolean>(value?: A): A | false {\n const clientOnly = React.useContext(ClientOnlyContext)\n\n if (clientOnly || process.env.TAMAGUI_TARGET === 'native') {\n // @ts-expect-error\n return value ?? true\n }\n\n return React.useSyncExternalStore(\n subscribe,\n () => value ?? true,\n () => {\n return false as any\n }\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"
|
|
12
12
|
],
|
|
13
13
|
"version": 3
|
|
14
14
|
}
|