@hanzogui/use-did-finish-ssr 3.0.6 → 4.4.0

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.
@@ -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
- 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, {
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
- return to;
17
- };
17
+ }
18
+ return to;
19
+ };
18
20
  var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
- value: !0
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
- import_jsx_runtime = require("react/jsx-runtime");
29
- const ClientOnlyContext = (0, import_react.createContext)(!1),
30
- ClientOnly = ({
31
- children,
32
- enabled
33
- }) => {
34
- const existingValue = (0, import_react.useContext)(ClientOnlyContext);
35
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(ClientOnlyContext.Provider, {
36
- value: enabled ?? existingValue,
37
- children
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
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: !0
11
- });
12
- },
13
- __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
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
- return to;
19
- };
19
+ }
20
+ return to;
21
+ };
20
22
  var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
- value: !0
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
- import_react = require("react"),
31
- ClientOnlyContext = /* @__PURE__ */(0, import_react.createContext)(!1),
32
- ClientOnly = function (param) {
33
- var {
34
- children,
35
- enabled
36
- } = param,
37
- existingValue = (0, import_react.useContext)(ClientOnlyContext);
38
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(ClientOnlyContext.Provider, {
39
- value: enabled ?? existingValue,
40
- children
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":";;;;;;;;;;;;;;;;;;;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,kBAatC;AAXG,IAAAM,kBAAM,GAAAC,OAA4C;EAAAC,YAE5C,GAAAD,OAAc;EAAAJ,iBAAA,sBAAAK,YAAA,CAAAC,aAAA;EAAAP,UAAA,YAAAA,CAAAQ,KAAA;IACzB;QAAAC,QAAA;QAAAC;MAAA,IAAAF,KAAA;MAAAG,aAAA,OAAAL,YAAA,CAAAM,UAAA,EAAAX,iBAAA;IACA,0BAAAG,kBAAA,CAAAS,GAAA,EAAAZ,iBAAA,CAAAa,QAAA;MACFjB,KAGuB,EAAAa,OAAA,IAAAC,aAAA;MACrBF;IACA;EAKF","ignoreList":[]}
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":[]}
@@ -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
- __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: !0
11
- });
12
- },
13
- __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
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
- return to;
19
- };
19
+ }
20
+ return to;
21
+ };
20
22
  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", {
26
- value: mod,
27
- enumerable: !0
28
- }) : target, mod)),
29
- __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
30
- value: !0
31
- }), mod);
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
- import_ClientOnly = require("./ClientOnly.cjs"),
43
- import_ClientOnly2 = require("./ClientOnly.cjs");
44
- const useIsClientOnly = () => React.useContext(import_ClientOnly.ClientOnlyContext);
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
- return React.useContext(import_ClientOnly.ClientOnlyContext) ? !0 : React.useSyncExternalStore(subscribe, () => !0, () => !1);
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
- return useDidFinishSSR() ? typeof value == "function" ? value() : value : void 0;
58
+ const done = useDidFinishSSR();
59
+ return !done ? void 0 : typeof value === "function" ? value() : value;
51
60
  }
@@ -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
- __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
9
  var __export = (target, all) => {
10
- for (var name in all) __defProp(target, name, {
11
- get: all[name],
12
- enumerable: !0
13
- });
14
- },
15
- __copyProps = (to, from, except, desc) => {
16
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
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
- return to;
21
- };
21
+ }
22
+ return to;
23
+ };
22
24
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
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: !0
30
- }) : target, mod)),
31
- __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
32
- value: !0
33
- }), mod);
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
- import_ClientOnly = require("./ClientOnly.native.js"),
45
- import_ClientOnly2 = require("./ClientOnly.native.js"),
46
- useIsClientOnly = function () {
47
- return React.useContext(import_ClientOnly.ClientOnlyContext);
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
- return !0;
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 == "function" ? value() : value : void 0;
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","subscribe","done"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAAA;EAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;IAAAC,KAAA;EAAA,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,aACvB;AAIO,IAAAU,KAAM,GAAAC,OAAA,CAAAC,OAAkB,QACtB,CAAM;EAAAC,iBAAW,GAAAD,OAAA,yBAAiB;EAAAT,kBAAA,GAAAS,OAAA;EAAAL,eAAA,YAAAA,CAAA;IAGpC,OAASG,KAAA,CAAAI,UAAA,CAAAD,iBAA2B,CAAAT,iBAAA;EAGzC;AAIa,SACXE,gBAAA;EAAA,IACAS,UAAM,GAAAL,KAAA,CAAAI,UAAA,CAAAD,iBAAA,CAAAT,iBAAA;EAAA,OACN,CAAM;AAAA;AAEV,IAAAY,SAAA,YAAAA,CAAA;EAEA,OAAM,YAAY,CAAa;AAIxB;AAGL,SAFaX,eAAAN,KAEc;EAC7B,IAAAkB,IAAA,GAAAX,eAAA","ignoreList":[]}
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":[]}
@@ -1,15 +1,15 @@
1
1
  import { createContext, useContext } from "react";
2
2
  import { jsx } from "react/jsx-runtime";
3
- const ClientOnlyContext = createContext(!1),
4
- 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
- };
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,EAAK;EAE/DI,UAAA,GAAaA,CAAC;IACzBC,QAAA;IACAC;EACF,MAGuB;IACrB,MAAMC,aAAA,GAAgBN,UAAA,CAAWE,iBAAiB;IAClD,OACE,eAAAD,GAAA,CAACC,iBAAA,CAAkBK,QAAA,EAAlB;MAA2BC,KAAA,EAAOH,OAAA,IAAWC,aAAA;MAC3CF;IAAA,CACH;EAEJ","ignoreList":[]}
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(!1),
4
- ClientOnly = function (param) {
5
- var {
6
- children,
7
- enabled
8
- } = param,
9
- existingValue = useContext(ClientOnlyContext);
10
- return /* @__PURE__ */_jsx(ClientOnlyContext.Provider, {
11
- value: enabled ?? existingValue,
12
- children
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,aAE1D;EAAcG,UAAA,YAAAA,CAAAC,KAAA;IACzB;QAAAC,QAAA;QAAAC;MAAA,IAAAF,KAAA;MAAAG,aAAA,GAAAN,UAAA,CAAAC,iBAAA;IACA,sBAAAH,IAAA,CAAAG,iBAAA,CAAAM,QAAA;MACFC,KAGuB,EAAAH,OAAA,IAAAC,aAAA;MACrBF;IACA;EAKF","ignoreList":[]}
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 = () => React.useContext(ClientOnlyContext);
4
+ const useIsClientOnly = () => {
5
+ return React.useContext(ClientOnlyContext);
6
+ };
5
7
  function useDidFinishSSR() {
6
- return React.useContext(ClientOnlyContext) ? !0 : React.useSyncExternalStore(subscribe, () => !0, () => !1);
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
- return useDidFinishSSR() ? typeof value == "function" ? value() : value : void 0;
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
@@ -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,KACtBJ,KAAA,CAAMK,UAAA,CAAWJ,iBAAiB;AAGpC,SAASK,gBAAA,EAA2B;EAGzC,OAFmBN,KAAA,CAAMK,UAAA,CAAWJ,iBAAiB,IAG5C,KAGFD,KAAA,CAAMO,oBAAA,CACXC,SAAA,EACA,MAAM,IACN,MAAM,EACR;AACF;AAEA,MAAMA,SAAA,GAAYA,CAAA,KAAM,MAAM,CAAC;AAIxB,SAASC,eAAsBC,KAAA,EAAmD;EAGvF,OAFaJ,eAAA,CAAgB,IAEF,OAAOI,KAAA,IAAU,aAAaA,KAAA,CAAM,IAAIA,KAAA,GAApD;AACjB","ignoreList":[]}
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":[]}
@@ -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 = () => React.useContext(ClientOnlyContext);
4
+ const useIsClientOnly = () => {
5
+ return React.useContext(ClientOnlyContext);
6
+ };
5
7
  function useDidFinishSSR() {
6
- return React.useContext(ClientOnlyContext) ? !0 : React.useSyncExternalStore(subscribe, () => !0, () => !1);
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
- return useDidFinishSSR() ? typeof value == "function" ? value() : value : void 0;
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
@@ -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,KACtBJ,KAAA,CAAMK,UAAA,CAAWJ,iBAAiB;AAGpC,SAASK,gBAAA,EAA2B;EAGzC,OAFmBN,KAAA,CAAMK,UAAA,CAAWJ,iBAAiB,IAG5C,KAGFD,KAAA,CAAMO,oBAAA,CACXC,SAAA,EACA,MAAM,IACN,MAAM,EACR;AACF;AAEA,MAAMA,SAAA,GAAYA,CAAA,KAAM,MAAM,CAAC;AAIxB,SAASC,eAAsBC,KAAA,EAAmD;EAGvF,OAFaJ,eAAA,CAAgB,IAEF,OAAOI,KAAA,IAAU,aAAaA,KAAA,CAAM,IAAIA,KAAA,GAApD;AACjB","ignoreList":[]}
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":[]}
@@ -6,14 +6,21 @@ var useIsClientOnly = function () {
6
6
  };
7
7
  function useDidFinishSSR() {
8
8
  var clientOnly = React.useContext(ClientOnlyContext);
9
- return !0;
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 == "function" ? value() : value : void 0;
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,EACJ;EAGF,OAASJ,KAAA,CAAAK,UAAA,CAAAJ,iBAA2B;AAGzC;AAIa,SACXK,gBAAA;EAAA,IACAC,UAAM,GAAAP,KAAA,CAAAK,UAAA,CAAAJ,iBAAA;EAAA,OACN,CAAM;AAAA;AAEV,IAAAO,SAAA,YAAAA,CAAA;EAEA,OAAM,YAAY,CAAa;AAIxB;AAGL,SAFaC,eAAAC,KAEc;EAC7B,IAAAC,IAAA,GAAAL,eAAA","ignoreList":[]}
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanzogui/use-did-finish-ssr",
3
- "version": "3.0.6",
3
+ "version": "4.4.0",
4
4
  "gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14",
5
5
  "files": [
6
6
  "src",
@@ -34,7 +34,7 @@
34
34
  "clean:build": "hanzo-gui-build clean:build"
35
35
  },
36
36
  "devDependencies": {
37
- "@hanzogui/build": "3.0.6",
37
+ "@hanzogui/build": "4.4.0",
38
38
  "react": ">=19"
39
39
  },
40
40
  "peerDependencies": {
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.HANZO_GUI_TARGET === 'native') {
13
+ if (clientOnly || process.env.GUI_TARGET === 'native') {
14
14
  return true
15
15
  }
16
16
 
@@ -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.HANZO_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"
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
  }