@hanzogui/use-window-dimensions 4.4.0 → 102.0.0-rc.41-hanzoai.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.
@@ -27,13 +27,9 @@ __export(helpers_exports, {
27
27
  });
28
28
  module.exports = __toCommonJS(helpers_exports);
29
29
  var import_constants = require("@hanzogui/constants");
30
- var import_initialValue = require("./initialValue.cjs");
31
- let lastSize = import_initialValue.initialValue;
30
+ let lastSize = require("./initialValue.cjs").initialValue;
32
31
  let docEl = null;
33
32
  function getWindowSize() {
34
- if (false) {
35
- return import_initialValue.initialValue;
36
- }
37
33
  docEl ||= window.document.documentElement;
38
34
  const nextSize = {
39
35
  fontScale: 1,
@@ -55,18 +51,14 @@ if (import_constants.isClient && typeof window !== "undefined" && typeof window.
55
51
  };
56
52
  let lastUpdate = Date.now();
57
53
  let tm;
58
- const USER_MAX_MS = process.env.GUI_USE_WINDOW_DIMENSIONS_MAX_UPDATE_MS;
54
+ const USER_MAX_MS = process.env.TAMAGUI_USE_WINDOW_DIMENSIONS_MAX_UPDATE_MS;
59
55
  const updateMaxMs = USER_MAX_MS ? +USER_MAX_MS : 100;
60
56
  const onResize = () => {
61
57
  clearTimeout(tm);
62
58
  const timeSinceLast = Date.now() - lastUpdate;
63
- if (timeSinceLast < updateMaxMs) {
64
- tm = setTimeout(() => {
65
- flushUpdate();
66
- }, updateMaxMs - timeSinceLast);
67
- } else {
59
+ if (timeSinceLast < updateMaxMs) tm = setTimeout(() => {
68
60
  flushUpdate();
69
- }
61
+ }, updateMaxMs - timeSinceLast);else flushUpdate();
70
62
  };
71
63
  window.addEventListener("resize", onResize);
72
64
  }
@@ -1 +1 @@
1
- {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","__export","configureInitialWindowDimensions","import_initialValue2","useWindowDimensions","module","exports","import_react","__toESM","require","import_constants","import_helpers","import_initialValue","serverValue","initialValue","arguments","length","default","useSyncExternalStore","subscribe","getWindowSize","isWeb"],"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,gCAAA,EAAAA,CAAA,KAAAC,oBAAA,CAAAD,gCAAA;EAAAE,mBAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAX,YAAkB,CAAAK,aAAA;AAClB,IAAAO,YAAA,GAAAC,OAAsB,CAAAC,OAAA;AAEtB,IAAAC,gBAAA,GAAyCD,OAAA;AAEzC,IAAAE,cAAA,GAAAF,OAA6B;AAE7B,IAAAG,mBAAA,GAAAH,OAAiD;AAE1C,IAAAN,oBAAS,GAAAM,OAAoB;AAAA,SAClCL,mBAAcA,CAAA;EAChB,IAAmC;IAAeS,WAAA,GAAAD,mBAAA,CAAAE;EAAA,IAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,iBAAAA,SAAA;EAChD,OAAOR,YAAA,CAAAU,OAAA,CAAMC,oBAAA,CAAAP,cAAA,CAAAQ,SAAA,EAAAR,cAAA,CAAAS,aAAA;IAAqB,OAAAV,gBAAA,CAAAW,KAAA,GAAAR,WAAA,OAAAF,cAAA,CAAAS,aAAA;EAAA,EAAW;AAAA","ignoreList":[]}
1
+ {"version":3,"names":["__create","Object","create","__defProp","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__getProtoOf","getPrototypeOf","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toESM","mod","isNodeMode","__esModule","value","__toCommonJS","index_exports","configureInitialWindowDimensions","import_initialValue2","useWindowDimensions","module","exports","import_react","require","import_constants","import_helpers","import_initialValue","serverValue","initialValue","arguments","length","default","useSyncExternalStore","subscribe","getWindowSize","isWeb"],"sources":["index.native.js"],"sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar index_exports = {};\n__export(index_exports, {\n configureInitialWindowDimensions: () => import_initialValue2.configureInitialWindowDimensions,\n useWindowDimensions: () => useWindowDimensions\n});\nmodule.exports = __toCommonJS(index_exports);\nvar import_react = __toESM(require(\"react\"), 1);\nvar import_constants = require(\"@hanzogui/constants\");\nvar import_helpers = require(\"./helpers\");\nvar import_initialValue = require(\"./initialValue\");\nvar import_initialValue2 = require(\"./initialValue\");\nfunction useWindowDimensions() {\n var { serverValue = import_initialValue.initialValue } = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};\n return import_react.default.useSyncExternalStore(import_helpers.subscribe, import_helpers.getWindowSize, function() {\n return import_constants.isWeb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AAC,CAAC,CAAC,KAAK,KAAK,CAAC,GAAGA,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;EAC5H,OAAOP,YAAY,CAACS,OAAO,CAACC,oBAAoB,CAACP,cAAc,CAACQ,SAAS,EAAER,cAAc,CAACS,aAAa,EAAE,YAAW;IAClH,OAAOV,gBAAgB,CAACW,KAAK,GAAGR,WAAW,GAAG,CAAC,CAAC,EAAEF,cAAc,CAACS,aAAa,EAAE,CAAC;EACnF,CAAC,CAAC;AACJ","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","initialValue_exports","__export","configureInitialWindowDimensions","initialValue","module","exports","width","height","scale","fontScale","next","Object","assign"],"sources":["../../src/initialValue.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,oBAAA;AAAAC,QAAA,CAAAD,oBAAA;EAAAE,gCAAA,EAAAA,CAAA,KAAAA,gCAAA;EAAAC,YAAA,EAAAA,CAAA,KAAAA;AAAA;AAKOC,MAAM,CAAAC,OAAA,GAAAV,YAA2B,CAAAK,oBAAA;AAAA,IACtCG,YAAO;EACPG,KAAA,KAAQ;EACRC,MAAA,EAAO;EACPC,KAAA;EACFC,SAAA;AAEO;AACL,SAAOP,gCAAyBA,CAAAQ,IAAA;EAClCC,MAAA,CAAAC,MAAA,CAAAT,YAAA,EAAAO,IAAA","ignoreList":[]}
1
+ {"version":3,"names":["__defProp","Object","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toCommonJS","mod","value","initialValue_exports","configureInitialWindowDimensions","initialValue","module","exports","width","height","scale","fontScale","next","assign"],"sources":["initialValue.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar initialValue_exports = {};\n__export(initialValue_exports, {\n configureInitialWindowDimensions: () => configureInitialWindowDimensions,\n initialValue: () => initialValue\n});\nmodule.exports = __toCommonJS(initialValue_exports);\nvar initialValue = {\n width: 800,\n height: 600,\n scale: 1,\n fontScale: 1\n};\nfunction configureInitialWindowDimensions(next) {\n Object.assign(initialValue, next);\n}\n//# sourceMappingURL=initialValue.js.map\n"],"mappings":"AAAA,YAAY;;AACZ,IAAIA,SAAS,GAAGC,MAAM,CAACC,cAAc;AACrC,IAAIC,gBAAgB,GAAGF,MAAM,CAACG,wBAAwB;AACtD,IAAIC,iBAAiB,GAAGJ,MAAM,CAACK,mBAAmB;AAClD,IAAIC,YAAY,GAAGN,MAAM,CAACO,SAAS,CAACC,cAAc;AAClD,IAAIC,QAAQ,GAAGA,CAACC,MAAM,EAAEC,GAAG,KAAK;EAC9B,KAAK,IAAIC,IAAI,IAAID,GAAG,EAClBZ,SAAS,CAACW,MAAM,EAAEE,IAAI,EAAE;IAAEC,GAAG,EAAEF,GAAG,CAACC,IAAI,CAAC;IAAEE,UAAU,EAAE;EAAK,CAAC,CAAC;AACjE,CAAC;AACD,IAAIC,WAAW,GAAGA,CAACC,EAAE,EAAEC,IAAI,EAAEC,MA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["../../src/types.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA","ignoreList":[]}
1
+ {"version":3,"names":["__defProp","Object","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__hasOwnProp","prototype","hasOwnProperty","__copyProps","to","from","except","desc","key","call","get","enumerable","__toCommonJS","mod","value","types_exports","module","exports"],"sources":["types.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar types_exports = {};\nmodule.exports = __toCommonJS(types_exports);\n//# sourceMappingURL=types.js.map\n"],"mappings":"AAAA,YAAY;;AACZ,IAAIA,SAAS,GAAGC,MAAM,CAACC,cAAc;AACrC,IAAIC,gBAAgB,GAAGF,MAAM,CAACG,wBAAwB;AACtD,IAAIC,iBAAiB,GAAGJ,MAAM,CAACK,mBAAmB;AAClD,IAAIC,YAAY,GAAGN,MAAM,CAACO,SAAS,CAACC,cAAc;AAClD,IAAIC,WAAW,GAAGA,CAACC,EAAE,EAAEC,IAAI,EAAEC,MAAM,EAAEC,IAAI,KAAK;EAC5C,IAAIF,IAAI,IAAI,OAAOA,IAAI,KAAK,QAAQ,IAAI,OAAOA,IAAI,KAAK,UAAU,EAAE;IAClE,KAAK,IAAIG,GAAG,IAAIV,iBAAiB,CAACO,IAAI,CAAC,EACrC,IAAI,CAACL,YAAY,CAACS,IAAI,CAACL,EAAE,EAAEI,GAAG,CAAC,IAAIA,GAAG,KAAKF,MAAM,EAC/Cb,SAAS,CAACW,EAAE,EAAEI,GAAG,EAAE;MAAEE,GAAG,EAAEA,CAAA,KAAML,IAAI,CAACG,GAAG,CAAC;MAAEG,UAAU,EAAE,EAAEJ,IAAI,GAAGX,gBAAgB,CAACS,IAAI,EAAEG,GAAG,CAAC,CAAC,IAAID,IAAI,CAACI;IAAW,CAAC,CAAC;EACxH;EACA,OAAOP,EAAE;AACX,CAAC;AACD,IAAIQ,YAAY,GAAIC,GAAG,IAAKV,WAAW,CAACV,SAAS,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE;EAAEqB,KAAK,EAAE;AAAK,CAAC,CAAC,EAAED,GAAG,CAAC;AAC1F,IAAIE,aAAa,GAAG,CAAC,CAAC;AACtBC,MAAM,CAACC,OAAO,GAAGL,YAAY,CAACG,aAAa,CAAC","ignoreList":[]}
@@ -3,9 +3,6 @@ import { initialValue } from "./initialValue.mjs";
3
3
  let lastSize = initialValue;
4
4
  let docEl = null;
5
5
  function getWindowSize() {
6
- if (false) {
7
- return initialValue;
8
- }
9
6
  docEl ||= window.document.documentElement;
10
7
  const nextSize = {
11
8
  fontScale: 1,
@@ -27,18 +24,14 @@ if (isClient && typeof window !== "undefined" && typeof window.addEventListener
27
24
  };
28
25
  let lastUpdate = Date.now();
29
26
  let tm;
30
- const USER_MAX_MS = process.env.GUI_USE_WINDOW_DIMENSIONS_MAX_UPDATE_MS;
27
+ const USER_MAX_MS = process.env.TAMAGUI_USE_WINDOW_DIMENSIONS_MAX_UPDATE_MS;
31
28
  const updateMaxMs = USER_MAX_MS ? +USER_MAX_MS : 100;
32
29
  const onResize = () => {
33
30
  clearTimeout(tm);
34
31
  const timeSinceLast = Date.now() - lastUpdate;
35
- if (timeSinceLast < updateMaxMs) {
36
- tm = setTimeout(() => {
37
- flushUpdate();
38
- }, updateMaxMs - timeSinceLast);
39
- } else {
32
+ if (timeSinceLast < updateMaxMs) tm = setTimeout(() => {
40
33
  flushUpdate();
41
- }
34
+ }, updateMaxMs - timeSinceLast);else flushUpdate();
42
35
  };
43
36
  window.addEventListener("resize", onResize);
44
37
  }
@@ -1 +1 @@
1
- {"version":3,"names":["isClient","initialValue","lastSize","docEl","getWindowSize","window","document","documentElement","nextSize","fontScale","height","clientHeight","scale","devicePixelRatio","width","clientWidth","cbs","Set","addEventListener","flushUpdate","lastUpdate","Date","now","forEach","cb","tm","USER_MAX_MS","process","env","GUI_USE_WINDOW_DIMENSIONS_MAX_UPDATE_MS","updateMaxMs","onResize","clearTimeout","timeSinceLast","setTimeout","subscribe","add","delete"],"sources":["../../src/helpers.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,QAAA,QAAgB;AACzB,SAASC,YAAA,QAAoB;AAG7B,IAAIC,QAAA,GAAuBD,YAAA;AAC3B,IAAIE,KAAA,GAA4B;AAEzB,SAASC,cAAA,EAA4B;EAC1C,IAAI,OAAkC;IACpC,OAAOH,YAAA;EACT;EAEAE,KAAA,KAAUE,MAAA,CAAOC,QAAA,CAASC,eAAA;EAE1B,MAAMC,QAAA,GAAuB;IAC3BC,SAAA,EAAW;IACXC,MAAA,EAAQP,KAAA,CAAMQ,YAAA;IACdC,KAAA,EAAOP,MAAA,CAAOQ,gBAAA,IAAoB;IAClCC,KAAA,EAAOX,KAAA,CAAMY;EACf;EAEA,IACEP,QAAA,CAASE,MAAA,KAAWR,QAAA,CAASQ,MAAA,IAC7BF,QAAA,CAASM,KAAA,KAAUZ,QAAA,CAASY,KAAA,IAC5BN,QAAA,CAASI,KAAA,KAAUV,QAAA,CAASU,KAAA,EAC5B;IACAV,QAAA,GAAWM,QAAA;IACX,OAAOA,QAAA;EACT;EAEA,OAAON,QAAA;AACT;AAEA,MAAMc,GAAA,GAAM,mBAAIC,GAAA,CAAwB;AAIxC,IACEjB,QAAA,IACA,OAAOK,MAAA,KAAW,eAClB,OAAOA,MAAA,CAAOa,gBAAA,KAAqB,YACnC;EAMA,IAASC,WAAA,GAAT,SAAAA,CAAA,EAAuB;IACrBC,UAAA,GAAaC,IAAA,CAAKC,GAAA,CAAI;IACtBN,GAAA,CAAIO,OAAA,CAASC,EAAA,IAAOA,EAAA,CAAGpB,aAAA,CAAc,CAAC,CAAC;EACzC;EARA,IAAIgB,UAAA,GAAaC,IAAA,CAAKC,GAAA,CAAI;EAC1B,IAAIG,EAAA;EACJ,MAAMC,WAAA,GAAcC,OAAA,CAAQC,GAAA,CAAIC,uCAAA;EAChC,MAAMC,WAAA,GAAcJ,WAAA,GAAc,CAACA,WAAA,GAAc;EAOjD,MAAMK,QAAA,GAAWA,CAAA,KAAM;IACrBC,YAAA,CAAaP,EAAE;IAGf,MAAMQ,aAAA,GAAgBZ,IAAA,CAAKC,GAAA,CAAI,IAAIF,UAAA;IACnC,IAAIa,aAAA,GAAgBH,WAAA,EAAa;MAC/BL,EAAA,GAAKS,UAAA,CAAW,MAAM;QACpBf,WAAA,CAAY;MACd,GAAGW,WAAA,GAAcG,aAAa;IAChC,OAAO;MACLd,WAAA,CAAY;IACd;EACF;EAEAd,MAAA,CAAOa,gBAAA,CAAiB,UAAUa,QAAQ;AAC5C;AAEO,SAASI,UAAUX,EAAA,EAAoC;EAC5DR,GAAA,CAAIoB,GAAA,CAAIZ,EAAE;EACV,OAAO,MAAMR,GAAA,CAAIqB,MAAA,CAAOb,EAAE;AAC5B","ignoreList":[]}
1
+ {"version":3,"names":["isClient","initialValue","lastSize","docEl","getWindowSize","window","document","documentElement","nextSize","fontScale","height","clientHeight","scale","devicePixelRatio","width","clientWidth","cbs","Set","addEventListener","flushUpdate","lastUpdate","Date","now","forEach","cb","tm","USER_MAX_MS","process","env","TAMAGUI_USE_WINDOW_DIMENSIONS_MAX_UPDATE_MS","updateMaxMs","onResize","clearTimeout","timeSinceLast","setTimeout","subscribe","add","delete"],"s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AAA;IAGA,GAAAW,WAAM,GAAAG,aAAqB,OAC3Bd,WAAI;EACF;EACEd,MAAA,CAAAa,gBAAY,WAAAa,QAAA;AAAA;AACgB,SAChCI,SAAOA,CAAAX,EAAA;EACLR,GAAA,CAAAoB,GAAA,CAAAZ,EAAA;EAAY,OACd,MAAAR,GAAA,CAAAqB,MAAA,CAAAb,EAAA;AAAA;AAGF,SAAOpB,aAAA,EAAA+B,SAAiB","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanzogui/use-window-dimensions",
3
- "version": "4.4.0",
3
+ "version": "102.0.0-rc.41-hanzoai.1",
4
4
  "gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14",
5
5
  "files": [
6
6
  "src",
@@ -28,16 +28,16 @@
28
28
  "access": "public"
29
29
  },
30
30
  "scripts": {
31
- "build": "hanzo-gui-build",
32
- "watch": "hanzo-gui-build --watch",
33
- "clean": "hanzo-gui-build clean",
34
- "clean:build": "hanzo-gui-build clean:build"
31
+ "build": "hanzogui-build",
32
+ "watch": "hanzogui-build --watch",
33
+ "clean": "hanzogui-build clean",
34
+ "clean:build": "hanzogui-build clean:build"
35
35
  },
36
36
  "dependencies": {
37
- "@hanzogui/constants": "4.4.0"
37
+ "@hanzogui/constants": "102.0.0-rc.41-hanzoai.1"
38
38
  },
39
39
  "devDependencies": {
40
- "@hanzogui/build": "4.4.0",
40
+ "@hanzogui/build": "102.0.0-rc.41-hanzoai.1",
41
41
  "react": ">=19",
42
42
  "react-native": "0.83.2"
43
43
  },
package/src/helpers.ts CHANGED
@@ -6,7 +6,7 @@ let lastSize: WindowSize = initialValue
6
6
  let docEl: HTMLElement | null = null
7
7
 
8
8
  export function getWindowSize(): WindowSize {
9
- if (process.env.GUI_TARGET !== 'web') {
9
+ if (process.env.TAMAGUI_TARGET !== 'web') {
10
10
  return initialValue
11
11
  }
12
12
 
@@ -42,7 +42,7 @@ if (
42
42
  ) {
43
43
  let lastUpdate = Date.now()
44
44
  let tm: ReturnType<typeof setTimeout> | undefined
45
- const USER_MAX_MS = process.env.GUI_USE_WINDOW_DIMENSIONS_MAX_UPDATE_MS
45
+ const USER_MAX_MS = process.env.TAMAGUI_USE_WINDOW_DIMENSIONS_MAX_UPDATE_MS
46
46
  const updateMaxMs = USER_MAX_MS ? +USER_MAX_MS : 100
47
47
 
48
48
  function flushUpdate() {
@@ -6,6 +6,6 @@
6
6
  ],
7
7
  "version": 3,
8
8
  "sourcesContent": [
9
- "import { isClient } from '@hanzogui/constants'\nimport { initialValue } from './initialValue'\nimport type { WindowSize, WindowSizeListener } from './types'\n\nlet lastSize: WindowSize = initialValue\nlet docEl: HTMLElement | null = null\n\nexport function getWindowSize(): WindowSize {\n if (process.env.GUI_TARGET !== 'web') {\n return initialValue\n }\n\n docEl ||= window.document.documentElement\n\n const nextSize: WindowSize = {\n fontScale: 1,\n height: docEl.clientHeight,\n scale: window.devicePixelRatio || 1,\n width: docEl.clientWidth,\n }\n\n if (\n nextSize.height !== lastSize.height ||\n nextSize.width !== lastSize.width ||\n nextSize.scale !== lastSize.scale\n ) {\n lastSize = nextSize\n return nextSize\n }\n\n return lastSize\n}\n\nconst cbs = new Set<WindowSizeListener>()\n\n// only attach resize listener on client (not during SSR)\n// also guard window.addEventListener since isClient=true on native but window.addEventListener is undefined\nif (\n isClient &&\n typeof window !== 'undefined' &&\n typeof window.addEventListener === 'function'\n) {\n let lastUpdate = Date.now()\n let tm: ReturnType<typeof setTimeout> | undefined\n const USER_MAX_MS = process.env.GUI_USE_WINDOW_DIMENSIONS_MAX_UPDATE_MS\n const updateMaxMs = USER_MAX_MS ? +USER_MAX_MS : 100\n\n function flushUpdate() {\n lastUpdate = Date.now()\n cbs.forEach((cb) => cb(getWindowSize()))\n }\n\n const onResize = () => {\n clearTimeout(tm)\n\n // only update every few frames\n const timeSinceLast = Date.now() - lastUpdate\n if (timeSinceLast < updateMaxMs) {\n tm = setTimeout(() => {\n flushUpdate()\n }, updateMaxMs - timeSinceLast)\n } else {\n flushUpdate()\n }\n }\n\n window.addEventListener('resize', onResize)\n}\n\nexport function subscribe(cb: WindowSizeListener): () => void {\n cbs.add(cb)\n return () => cbs.delete(cb)\n}\n"
9
+ "import { isClient } from '@hanzogui/constants'\nimport { initialValue } from './initialValue'\nimport type { WindowSize, WindowSizeListener } from './types'\n\nlet lastSize: WindowSize = initialValue\nlet docEl: HTMLElement | null = null\n\nexport function getWindowSize(): WindowSize {\n if (process.env.TAMAGUI_TARGET !== 'web') {\n return initialValue\n }\n\n docEl ||= window.document.documentElement\n\n const nextSize: WindowSize = {\n fontScale: 1,\n height: docEl.clientHeight,\n scale: window.devicePixelRatio || 1,\n width: docEl.clientWidth,\n }\n\n if (\n nextSize.height !== lastSize.height ||\n nextSize.width !== lastSize.width ||\n nextSize.scale !== lastSize.scale\n ) {\n lastSize = nextSize\n return nextSize\n }\n\n return lastSize\n}\n\nconst cbs = new Set<WindowSizeListener>()\n\n// only attach resize listener on client (not during SSR)\n// also guard window.addEventListener since isClient=true on native but window.addEventListener is undefined\nif (\n isClient &&\n typeof window !== 'undefined' &&\n typeof window.addEventListener === 'function'\n) {\n let lastUpdate = Date.now()\n let tm: ReturnType<typeof setTimeout> | undefined\n const USER_MAX_MS = process.env.TAMAGUI_USE_WINDOW_DIMENSIONS_MAX_UPDATE_MS\n const updateMaxMs = USER_MAX_MS ? +USER_MAX_MS : 100\n\n function flushUpdate() {\n lastUpdate = Date.now()\n cbs.forEach((cb) => cb(getWindowSize()))\n }\n\n const onResize = () => {\n clearTimeout(tm)\n\n // only update every few frames\n const timeSinceLast = Date.now() - lastUpdate\n if (timeSinceLast < updateMaxMs) {\n tm = setTimeout(() => {\n flushUpdate()\n }, updateMaxMs - timeSinceLast)\n } else {\n flushUpdate()\n }\n }\n\n window.addEventListener('resize', onResize)\n}\n\nexport function subscribe(cb: WindowSizeListener): () => void {\n cbs.add(cb)\n return () => cbs.delete(cb)\n}\n"
10
10
  ]
11
11
  }