@tamagui/use-constant 1.108.0 → 1.108.2

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/index.js CHANGED
@@ -1,7 +1,8 @@
1
+ var __create = Object.create;
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
5
6
  var __export = (target, all) => {
6
7
  for (var name in all)
7
8
  __defProp(target, name, { get: all[name], enumerable: !0 });
@@ -11,17 +12,24 @@ var __export = (target, all) => {
11
12
  !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
13
  return to;
13
14
  };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
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);
15
23
  var src_exports = {};
16
24
  __export(src_exports, {
17
25
  useConstant: () => useConstant
18
26
  });
19
27
  module.exports = __toCommonJS(src_exports);
20
- var import_react = require("react");
28
+ var React = __toESM(require("react"));
21
29
  function useConstant(fn) {
22
30
  if (typeof document > "u")
23
- return (0, import_react.useMemo)(() => fn(), []);
24
- const ref = (0, import_react.useRef)();
31
+ return React.useMemo(() => fn(), []);
32
+ const ref = React.useRef();
25
33
  return ref.current || (ref.current = { v: fn() }), ref.current.v;
26
34
  }
27
35
  //# sourceMappingURL=index.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
- "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAgC;AAIzB,SAAS,YAAe,IAAgB;AAE7C,MAAI,OAAO,WAAa;AACtB,eAAO,sBAAQ,MAAM,GAAG,GAAG,CAAC,CAAC;AAG/B,QAAM,UAAM,qBAAqB;AAEjC,SAAK,IAAI,YACP,IAAI,UAAU,EAAE,GAAG,GAAG,EAAE,IAGnB,IAAI,QAAQ;AACrB;",
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;AAEvC,SAAK,IAAI,YACP,IAAI,UAAU,EAAE,GAAG,GAAG,EAAE,IAGnB,IAAI,QAAQ;AACrB;",
5
5
  "names": []
6
6
  }
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
6
7
  var __export = (target, all) => {
7
8
  for (var name in all)
8
9
  __defProp(target, name, { get: all[name], enumerable: !0 });
@@ -12,19 +13,26 @@ var __export = (target, all) => {
12
13
  !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
14
  return to;
14
15
  };
15
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
16
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
+ // If the importer is in node compatibility mode or this is not an ESM
18
+ // file that has been converted to a CommonJS file using a Babel-
19
+ // compatible transform (i.e. "__esModule" has not been set), then set
20
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
22
+ mod
23
+ )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
16
24
  var src_exports = {};
17
25
  __export(src_exports, {
18
26
  useConstant: () => useConstant
19
27
  });
20
28
  module.exports = __toCommonJS(src_exports);
21
- var import_react = require("react");
29
+ var React = __toESM(require("react"));
22
30
  function useConstant(fn) {
23
31
  if (typeof document > "u")
24
- return (0, import_react.useMemo)(function() {
32
+ return React.useMemo(function() {
25
33
  return fn();
26
34
  }, []);
27
- var ref = (0, import_react.useRef)();
35
+ var ref = React.useRef();
28
36
  return ref.current || (ref.current = {
29
37
  v: fn()
30
38
  }), ref.current.v;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/Users/n8/tamagui/code/core/use-constant/src/index.ts"],
4
- "mappings": ";;;;;;;;;;;;;;;AAAA;;;;;mBAAgC;AAIzB,SAASA,YAAeC,IAAW;AAExC,MAAI,OAAOC,WAAa;AACtB,eAAOC,sBAAQ,WAAA;aAAMF,GAAAA;OAAM,CAAA,CAAE;AAG/B,MAAMG,UAAMC,qBAAAA;AAEZ,SAAKD,IAAIE,YACPF,IAAIE,UAAU;IAAEC,GAAGN,GAAAA;EAAK,IAGnBG,IAAIE,QAAQC;AACrB;",
5
- "names": ["useConstant", "fn", "document", "useMemo", "ref", "useRef", "current", "v"]
4
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;YAAuB;AAIhB,SAASA,YAAeC,IAAW;AAExC,MAAI,OAAOC,WAAa;AACtB,WAAOC,MAAMC,QAAQ,WAAA;aAAMH,GAAAA;OAAM,CAAA,CAAE;AAGrC,MAAMI,MAAMF,MAAMG,OAAM;AAExB,SAAKD,IAAIE,YACPF,IAAIE,UAAU;IAAEC,GAAGP,GAAAA;EAAK,IAGnBI,IAAIE,QAAQC;AACrB;",
5
+ "names": ["useConstant", "fn", "document", "React", "useMemo", "ref", "useRef", "current", "v"]
6
6
  }
package/dist/esm/index.js CHANGED
@@ -1,8 +1,8 @@
1
- import { useMemo, useRef } from "react";
1
+ import * as React from "react";
2
2
  function useConstant(fn) {
3
3
  if (typeof document > "u")
4
- return useMemo(() => fn(), []);
5
- const ref = useRef();
4
+ return React.useMemo(() => fn(), []);
5
+ const ref = React.useRef();
6
6
  return ref.current || (ref.current = { v: fn() }), ref.current.v;
7
7
  }
8
8
  export {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
- "mappings": "AAAA,SAAS,SAAS,cAAc;AAIzB,SAAS,YAAe,IAAgB;AAE7C,MAAI,OAAO,WAAa;AACtB,WAAO,QAAQ,MAAM,GAAG,GAAG,CAAC,CAAC;AAG/B,QAAM,MAAM,OAAqB;AAEjC,SAAK,IAAI,YACP,IAAI,UAAU,EAAE,GAAG,GAAG,EAAE,IAGnB,IAAI,QAAQ;AACrB;",
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;AAEvC,SAAK,IAAI,YACP,IAAI,UAAU,EAAE,GAAG,GAAG,EAAE,IAGnB,IAAI,QAAQ;AACrB;",
5
5
  "names": []
6
6
  }
@@ -1,7 +1,7 @@
1
- import { useMemo, useRef } from "react";
1
+ import * as React from "react";
2
2
  function useConstant(fn) {
3
- if (typeof document > "u") return useMemo(() => fn(), []);
4
- const ref = useRef();
3
+ if (typeof document > "u") return React.useMemo(() => fn(), []);
4
+ const ref = React.useRef();
5
5
  return ref.current || (ref.current = {
6
6
  v: fn()
7
7
  }), ref.current.v;
@@ -1 +1 @@
1
- {"version":3,"names":["useMemo","useRef","useConstant","fn","document","ref","current","v"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,OAAA,EAASC,MAAA,QAAc;AAIzB,SAASC,YAAeC,EAAA,EAAgB;EAE7C,IAAI,OAAOC,QAAA,GAAa,KACtB,OAAOJ,OAAA,CAAQ,MAAMG,EAAA,CAAG,GAAG,EAAE;EAG/B,MAAME,GAAA,GAAMJ,MAAA,CAAqB;EAEjC,OAAKI,GAAA,CAAIC,OAAA,KACPD,GAAA,CAAIC,OAAA,GAAU;IAAEC,CAAA,EAAGJ,EAAA,CAAG;EAAE,IAGnBE,GAAA,CAAIC,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,GAAa,KACtB,OAAOH,KAAA,CAAMI,OAAA,CAAQ,MAAMF,EAAA,CAAG,GAAG,EAAE;EAGrC,MAAMG,GAAA,GAAML,KAAA,CAAMM,MAAA,CAAqB;EAEvC,OAAKD,GAAA,CAAIE,OAAA,KACPF,GAAA,CAAIE,OAAA,GAAU;IAAEC,CAAA,EAAGN,EAAA,CAAG;EAAE,IAGnBG,GAAA,CAAIE,OAAA,CAAQC,CAAA;AACrB","ignoreList":[]}
@@ -1,10 +1,10 @@
1
- import { useMemo, useRef } from "react";
1
+ import * as React from "react";
2
2
  function useConstant(fn) {
3
3
  if (typeof document > "u")
4
- return useMemo(function() {
4
+ return React.useMemo(function() {
5
5
  return fn();
6
6
  }, []);
7
- var ref = useRef();
7
+ var ref = React.useRef();
8
8
  return ref.current || (ref.current = {
9
9
  v: fn()
10
10
  }), ref.current.v;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/Users/n8/tamagui/code/core/use-constant/src/index.ts"],
4
- "mappings": "AAAA,SAASA,SAASC,cAAc;AAIzB,SAASC,YAAeC,IAAW;AAExC,MAAI,OAAOC,WAAa;AACtB,WAAOJ,QAAQ,WAAA;aAAMG,GAAAA;OAAM,CAAA,CAAE;AAG/B,MAAME,MAAMJ,OAAAA;AAEZ,SAAKI,IAAIC,YACPD,IAAIC,UAAU;IAAEC,GAAGJ,GAAAA;EAAK,IAGnBE,IAAIC,QAAQC;AACrB;",
5
- "names": ["useMemo", "useRef", "useConstant", "fn", "document", "ref", "current", "v"]
4
+ "mappings": "AAAA,YAAYA,WAAW;AAIhB,SAASC,YAAeC,IAAW;AAExC,MAAI,OAAOC,WAAa;AACtB,WAAOH,MAAMI,QAAQ,WAAA;aAAMF,GAAAA;OAAM,CAAA,CAAE;AAGrC,MAAMG,MAAML,MAAMM,OAAM;AAExB,SAAKD,IAAIE,YACPF,IAAIE,UAAU;IAAEC,GAAGN,GAAAA;EAAK,IAGnBG,IAAIE,QAAQC;AACrB;",
5
+ "names": ["React", "useConstant", "fn", "document", "useMemo", "ref", "useRef", "current", "v"]
6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/use-constant",
3
- "version": "1.108.0",
3
+ "version": "1.108.2",
4
4
  "types": "./types/index.d.ts",
5
5
  "main": "dist/cjs",
6
6
  "module": "dist/esm",
@@ -27,7 +27,7 @@
27
27
  }
28
28
  },
29
29
  "devDependencies": {
30
- "@tamagui/build": "1.108.0",
30
+ "@tamagui/build": "1.108.2",
31
31
  "react": "^18.2.0 || ^19.0.0"
32
32
  },
33
33
  "publishConfig": {
package/src/index.ts CHANGED
@@ -1,14 +1,14 @@
1
- import { useMemo, useRef } from 'react'
1
+ import * as React from 'react'
2
2
 
3
3
  type ResultBox<T> = { v: T }
4
4
 
5
5
  export function useConstant<T>(fn: () => T): T {
6
6
  // RSC compat
7
7
  if (typeof document === 'undefined') {
8
- return useMemo(() => fn(), [])
8
+ return React.useMemo(() => fn(), [])
9
9
  }
10
10
 
11
- const ref = useRef<ResultBox<T>>()
11
+ const ref = React.useRef<ResultBox<T>>()
12
12
 
13
13
  if (!ref.current) {
14
14
  ref.current = { v: fn() }