@tamagui/use-constant 2.0.0-rc.4 → 2.0.0-rc.40

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.
@@ -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
  useConstant: () => useConstant
@@ -36,9 +38,14 @@ __export(index_exports, {
36
38
  module.exports = __toCommonJS(index_exports);
37
39
  var React = __toESM(require("react"), 1);
38
40
  function useConstant(fn) {
39
- if (typeof document > "u") return React.useMemo(() => fn(), []);
41
+ if (typeof document === "undefined") {
42
+ return React.useMemo(() => fn(), []);
43
+ }
40
44
  const ref = React.useRef(void 0);
41
- return ref.current || (ref.current = {
42
- v: fn()
43
- }), ref.current.v;
45
+ if (!ref.current) {
46
+ ref.current = {
47
+ v: fn()
48
+ };
49
+ }
50
+ return ref.current.v;
44
51
  }
@@ -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
  useConstant: () => useConstant
@@ -38,12 +40,17 @@ __export(index_exports, {
38
40
  module.exports = __toCommonJS(index_exports);
39
41
  var React = __toESM(require("react"), 1);
40
42
  function useConstant(fn) {
41
- if (typeof document > "u") return React.useMemo(function () {
42
- return fn();
43
- }, []);
43
+ if (typeof document === "undefined") {
44
+ return React.useMemo(function () {
45
+ return fn();
46
+ }, []);
47
+ }
44
48
  var ref = React.useRef(void 0);
45
- return ref.current || (ref.current = {
46
- v: fn()
47
- }), ref.current.v;
49
+ if (!ref.current) {
50
+ ref.current = {
51
+ v: fn()
52
+ };
53
+ }
54
+ return ref.current.v;
48
55
  }
49
56
  //# sourceMappingURL=index.native.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","__export","useConstant","module","exports","React","__toESM","require","fn","document","useMemo"],"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,WAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAuB,GAAAT,YAAA,CAAAK,aAAA;AAIhB,IAAAK,KAAS,GAAAC,OAAA,CAAAC,OAA+B;AAE7C,SAAIL,WAAOA,CAAAM,EAAA,EAAa;EACtB,WAAOC,QAAM,MAAQ,EAGvB,OAAMJ,KAAM,CAAAK,OAAM,aAA8B;IAEhD,OAASF,EAAA;EAKX","ignoreList":[]}
1
+ {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","__export","useConstant","module","exports","React","__toESM","require","fn","document","useMemo","ref","useRef","current"],"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,WAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAuB,GAAAT,YAAA,CAAAK,aAAA;AAIhB,IAAAK,KAAS,GAAAC,OAAA,CAAAC,OAA+B;AAE7C,SAAIL,WAAOA,CAAAM,EAAA;EACT,WAAOC,QAAM,KAAQ,WAAY,EAAE;IACrC,OAAAJ,KAAA,CAAAK,OAAA;MAEA,OAAMF,EAAM;IAEZ,GAAK;EACH;EACF,IAAAG,GAAA,GAAAN,KAAA,CAAAO,MAAA;EAEA,KAAAD,GAAO,CAAAE,OAAI;IACbF,GAAA,CAAAE,OAAA","ignoreList":[]}
package/dist/esm/index.js CHANGED
@@ -1,11 +1,15 @@
1
1
  import * as React from "react";
2
2
  function useConstant(fn) {
3
- if (typeof document > "u")
3
+ if (typeof document === "undefined") {
4
4
  return React.useMemo(() => fn(), []);
5
+ }
5
6
  const ref = React.useRef(void 0);
6
- return ref.current || (ref.current = { v: fn() }), ref.current.v;
7
+ if (!ref.current) {
8
+ ref.current = {
9
+ v: fn()
10
+ };
11
+ }
12
+ return ref.current.v;
7
13
  }
8
- export {
9
- useConstant
10
- };
14
+ export { useConstant };
11
15
  //# sourceMappingURL=index.js.map
@@ -1,6 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/index.ts"],
4
- "mappings": "AAAA,YAAY,WAAW;AAIhB,SAAS,YAAe,IAAgB;AAE7C,MAAI,OAAO,WAAa;AACtB,WAAO,MAAM,QAAQ,MAAM,GAAG,GAAG,CAAC,CAAC;AAGrC,QAAM,MAAM,MAAM,OAAqB,MAAS;AAEhD,SAAK,IAAI,YACP,IAAI,UAAU,EAAE,GAAG,GAAG,EAAE,IAGnB,IAAI,QAAQ;AACrB;",
5
- "names": []
6
- }
1
+ {"version":3,"names":["React","useConstant","fn","document","useMemo","ref","useRef","current","v"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,YAAYA,KAAA,MAAW;AAIhB,SAASC,YAAeC,EAAA,EAAgB;EAE7C,IAAI,OAAOC,QAAA,KAAa,aAAa;IACnC,OAAOH,KAAA,CAAMI,OAAA,CAAQ,MAAMF,EAAA,CAAG,GAAG,EAAE;EACrC;EAEA,MAAMG,GAAA,GAAML,KAAA,CAAMM,MAAA,CAAqB,MAAS;EAEhD,IAAI,CAACD,GAAA,CAAIE,OAAA,EAAS;IAChBF,GAAA,CAAIE,OAAA,GAAU;MAAEC,CAAA,EAAGN,EAAA,CAAG;IAAE;EAC1B;EAEA,OAAOG,GAAA,CAAIE,OAAA,CAAQC,CAAA;AACrB","ignoreList":[]}
@@ -1,10 +1,15 @@
1
1
  import * as React from "react";
2
2
  function useConstant(fn) {
3
- if (typeof document > "u") return React.useMemo(() => fn(), []);
3
+ if (typeof document === "undefined") {
4
+ return React.useMemo(() => fn(), []);
5
+ }
4
6
  const ref = React.useRef(void 0);
5
- return ref.current || (ref.current = {
6
- v: fn()
7
- }), ref.current.v;
7
+ if (!ref.current) {
8
+ ref.current = {
9
+ v: fn()
10
+ };
11
+ }
12
+ return ref.current.v;
8
13
  }
9
14
  export { useConstant };
10
15
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","useConstant","fn","document","useMemo","ref","useRef","current","v"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,YAAYA,KAAA,MAAW;AAIhB,SAASC,YAAeC,EAAA,EAAgB;EAE7C,IAAI,OAAOC,QAAA,GAAa,KACtB,OAAOH,KAAA,CAAMI,OAAA,CAAQ,MAAMF,EAAA,CAAG,GAAG,EAAE;EAGrC,MAAMG,GAAA,GAAML,KAAA,CAAMM,MAAA,CAAqB,MAAS;EAEhD,OAAKD,GAAA,CAAIE,OAAA,KACPF,GAAA,CAAIE,OAAA,GAAU;IAAEC,CAAA,EAAGN,EAAA,CAAG;EAAE,IAGnBG,GAAA,CAAIE,OAAA,CAAQC,CAAA;AACrB","ignoreList":[]}
1
+ {"version":3,"names":["React","useConstant","fn","document","useMemo","ref","useRef","current","v"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,YAAYA,KAAA,MAAW;AAIhB,SAASC,YAAeC,EAAA,EAAgB;EAE7C,IAAI,OAAOC,QAAA,KAAa,aAAa;IACnC,OAAOH,KAAA,CAAMI,OAAA,CAAQ,MAAMF,EAAA,CAAG,GAAG,EAAE;EACrC;EAEA,MAAMG,GAAA,GAAML,KAAA,CAAMM,MAAA,CAAqB,MAAS;EAEhD,IAAI,CAACD,GAAA,CAAIE,OAAA,EAAS;IAChBF,GAAA,CAAIE,OAAA,GAAU;MAAEC,CAAA,EAAGN,EAAA,CAAG;IAAE;EAC1B;EAEA,OAAOG,GAAA,CAAIE,OAAA,CAAQC,CAAA;AACrB","ignoreList":[]}
@@ -1,12 +1,17 @@
1
1
  import * as React from "react";
2
2
  function useConstant(fn) {
3
- if (typeof document > "u") return React.useMemo(function () {
4
- return fn();
5
- }, []);
3
+ if (typeof document === "undefined") {
4
+ return React.useMemo(function () {
5
+ return fn();
6
+ }, []);
7
+ }
6
8
  var ref = React.useRef(void 0);
7
- return ref.current || (ref.current = {
8
- v: fn()
9
- }), ref.current.v;
9
+ if (!ref.current) {
10
+ ref.current = {
11
+ v: fn()
12
+ };
13
+ }
14
+ return ref.current.v;
10
15
  }
11
16
  export { useConstant };
12
17
  //# sourceMappingURL=index.native.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","useConstant","fn","document","useMemo","ref","useRef"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,YAAYA,KAAA,MAAW;AAIhB,SAASC,YAAeC,EAAA,EAAgB;EAE7C,IAAI,OAAOC,QAAA,GAAa,KACtB,OAAOH,KAAA,CAAMI,OAAA,CAAQ,YAAS;IAGhC,OAAMF,EAAM;EAEZ,KAAK;EAKP,IAAAG,GAAA,GAAAL,KAAA,CAAAM,MAAA","ignoreList":[]}
1
+ {"version":3,"names":["React","useConstant","fn","document","useMemo","ref","useRef","current","v"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,YAAYA,KAAA,MAAW;AAIhB,SAASC,YAAeC,EAAA,EAAgB;EAE7C,IAAI,OAAOC,QAAA,KAAa,aAAa;IACnC,OAAOH,KAAA,CAAMI,OAAA,CAAQ,YAAS;MAChC,OAAAF,EAAA;IAEA,KAAM;EAEN;EACE,IAAAG,GAAI,GAAAL,KAAA,CAAUM,MAAK,MAAK;EAC1B,KAAAD,GAAA,CAAAE,OAAA;IAEAF,GAAA,CAAAE,OAAW;MACbC,CAAA,EAAAN,EAAA","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/use-constant",
3
- "version": "2.0.0-rc.4",
3
+ "version": "2.0.0-rc.40",
4
4
  "files": [
5
5
  "src",
6
6
  "types",
@@ -15,15 +15,12 @@
15
15
  "./package.json": "./package.json",
16
16
  ".": {
17
17
  "types": "./types/index.d.ts",
18
- "react-native": {
19
- "module": "./dist/esm/index.native.js",
20
- "import": "./dist/esm/index.native.js",
21
- "require": "./dist/cjs/index.native.js"
22
- },
18
+ "react-native": "./dist/esm/index.native.js",
19
+ "browser": "./dist/esm/index.mjs",
23
20
  "module": "./dist/esm/index.mjs",
24
21
  "import": "./dist/esm/index.mjs",
25
22
  "require": "./dist/cjs/index.cjs",
26
- "default": "./dist/cjs/index.native.js"
23
+ "default": "./dist/esm/index.mjs"
27
24
  }
28
25
  },
29
26
  "publishConfig": {
@@ -36,7 +33,7 @@
36
33
  "clean:build": "tamagui-build clean:build"
37
34
  },
38
35
  "devDependencies": {
39
- "@tamagui/build": "2.0.0-rc.4",
36
+ "@tamagui/build": "2.0.0-rc.40",
40
37
  "react": ">=19"
41
38
  },
42
39
  "peerDependencies": {
@@ -4,8 +4,8 @@
4
4
  "sources": [
5
5
  "src/index.ts"
6
6
  ],
7
+ "version": 3,
7
8
  "sourcesContent": [
8
9
  "import * as React from 'react'\n\ntype ResultBox<T> = { v: T }\n\nexport function useConstant<T>(fn: () => T): T {\n // RSC compat\n if (typeof document === 'undefined') {\n return React.useMemo(() => fn(), [])\n }\n\n const ref = React.useRef<ResultBox<T>>(undefined)\n\n if (!ref.current) {\n ref.current = { v: fn() }\n }\n\n return ref.current.v\n}\n"
9
- ],
10
- "version": 3
10
+ ]
11
11
  }
package/dist/cjs/index.js DELETED
@@ -1,35 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf, __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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
- // If the importer is in node compatibility mode or this is not an ESM
17
- // file that has been converted to a CommonJS file using a Babel-
18
- // compatible transform (i.e. "__esModule" has not been set), then set
19
- // "default" to the CommonJS "module.exports" for node compatibility.
20
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
21
- mod
22
- )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
23
- var index_exports = {};
24
- __export(index_exports, {
25
- useConstant: () => useConstant
26
- });
27
- module.exports = __toCommonJS(index_exports);
28
- var React = __toESM(require("react"), 1);
29
- function useConstant(fn) {
30
- if (typeof document > "u")
31
- return React.useMemo(() => fn(), []);
32
- const ref = React.useRef(void 0);
33
- return ref.current || (ref.current = { v: fn() }), ref.current.v;
34
- }
35
- //# sourceMappingURL=index.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/index.ts"],
4
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAAuB;AAIhB,SAAS,YAAe,IAAgB;AAE7C,MAAI,OAAO,WAAa;AACtB,WAAO,MAAM,QAAQ,MAAM,GAAG,GAAG,CAAC,CAAC;AAGrC,QAAM,MAAM,MAAM,OAAqB,MAAS;AAEhD,SAAK,IAAI,YACP,IAAI,UAAU,EAAE,GAAG,GAAG,EAAE,IAGnB,IAAI,QAAQ;AACrB;",
5
- "names": []
6
- }