@hanzogui/constants 7.3.0 → 8.0.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.
- package/dist/cjs/constants.cjs +5 -1
- package/dist/cjs/constants.native.js +8 -2
- package/dist/cjs/constants.native.js.map +1 -1
- package/dist/cjs/index.cjs +2 -1
- package/dist/cjs/index.native.js +1 -0
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/platformDriver.cjs +35 -0
- package/dist/cjs/platformDriver.native.js +38 -0
- package/dist/cjs/platformDriver.native.js.map +1 -0
- package/dist/esm/constants.mjs +4 -2
- package/dist/esm/constants.mjs.map +1 -1
- package/dist/esm/constants.native.js +7 -3
- package/dist/esm/constants.native.js.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.mjs +1 -0
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/index.native.js +1 -0
- package/dist/esm/index.native.js.map +1 -1
- package/dist/esm/platformDriver.mjs +9 -0
- package/dist/esm/platformDriver.mjs.map +1 -0
- package/dist/esm/platformDriver.native.js +9 -0
- package/dist/esm/platformDriver.native.js.map +1 -0
- package/package.json +8 -11
- package/src/constants.native.ts +12 -3
- package/src/constants.ts +9 -3
- package/src/index.ts +1 -0
- package/src/platformDriver.ts +41 -0
- package/types/constants.d.ts +2 -0
- package/types/constants.d.ts.map +2 -2
- package/types/constants.native.d.ts +3 -1
- package/types/constants.native.d.ts.map +2 -2
- package/types/index.d.ts +1 -0
- package/types/index.d.ts.map +2 -2
- package/types/platformDriver.d.ts +20 -0
- package/types/platformDriver.d.ts.map +11 -0
- package/LICENSE +0 -42
package/dist/cjs/constants.cjs
CHANGED
|
@@ -28,26 +28,30 @@ __export(constants_exports, {
|
|
|
28
28
|
isChrome: () => isChrome,
|
|
29
29
|
isClient: () => isClient,
|
|
30
30
|
isIos: () => isIos,
|
|
31
|
+
isNativeDesktop: () => isNativeDesktop,
|
|
31
32
|
isServer: () => isServer,
|
|
32
33
|
isTV: () => isTV,
|
|
33
34
|
isTouchable: () => isTouchable,
|
|
34
35
|
isWeb: () => isWeb,
|
|
35
36
|
isWebTouchable: () => isWebTouchable,
|
|
36
37
|
isWindowDefined: () => isWindowDefined,
|
|
38
|
+
supportsDynamicColorIOS: () => supportsDynamicColorIOS,
|
|
37
39
|
useIsomorphicLayoutEffect: () => useIsomorphicLayoutEffect
|
|
38
40
|
});
|
|
39
41
|
module.exports = __toCommonJS(constants_exports);
|
|
40
42
|
var import_react = require("react");
|
|
41
43
|
const isWeb = true;
|
|
42
|
-
const isBrowser = typeof
|
|
44
|
+
const isBrowser = typeof navigator !== "undefined" && typeof location !== "undefined";
|
|
43
45
|
const isServer = !isBrowser;
|
|
44
46
|
const isClient = isBrowser;
|
|
45
47
|
const isWindowDefined = isBrowser;
|
|
46
48
|
const useIsomorphicLayoutEffect = isServer ? import_react.useEffect : import_react.useLayoutEffect;
|
|
47
49
|
const isChrome = typeof navigator !== "undefined" && /Chrome/.test(navigator.userAgent || "");
|
|
48
50
|
const isWebTouchable = isClient && ("ontouchstart" in window || navigator.maxTouchPoints > 0);
|
|
51
|
+
const isNativeDesktop = false;
|
|
49
52
|
const isTouchable = isWebTouchable;
|
|
50
53
|
const isAndroid = process.env.TEST_NATIVE_PLATFORM === "android" || process.env.TEST_NATIVE_PLATFORM === "androidtv";
|
|
51
54
|
const isIos = process.env.TEST_NATIVE_PLATFORM === "ios" || process.env.TEST_NATIVE_PLATFORM === "tvos";
|
|
55
|
+
const supportsDynamicColorIOS = isIos || process.env.GUI_DYNAMIC_COLOR_IOS === "1";
|
|
52
56
|
const isTV = process.env.TEST_NATIVE_PLATFORM === "androidtv" || process.env.TEST_NATIVE_PLATFORM === "tvos";
|
|
53
57
|
const currentPlatform = "web";
|
|
@@ -30,12 +30,14 @@ __export(constants_native_exports, {
|
|
|
30
30
|
isChrome: () => isChrome,
|
|
31
31
|
isClient: () => isClient,
|
|
32
32
|
isIos: () => isIos,
|
|
33
|
+
isNativeDesktop: () => isNativeDesktop,
|
|
33
34
|
isServer: () => isServer,
|
|
34
35
|
isTV: () => isTV,
|
|
35
36
|
isTouchable: () => isTouchable,
|
|
36
37
|
isWeb: () => isWeb,
|
|
37
38
|
isWebTouchable: () => isWebTouchable,
|
|
38
39
|
isWindowDefined: () => isWindowDefined,
|
|
40
|
+
supportsDynamicColorIOS: () => supportsDynamicColorIOS,
|
|
39
41
|
useIsomorphicLayoutEffect: () => useIsomorphicLayoutEffect
|
|
40
42
|
});
|
|
41
43
|
module.exports = __toCommonJS(constants_native_exports);
|
|
@@ -49,12 +51,16 @@ var isWindowDefined = false;
|
|
|
49
51
|
var useIsomorphicLayoutEffect = import_react.useLayoutEffect;
|
|
50
52
|
var isChrome = false;
|
|
51
53
|
var isWebTouchable = false;
|
|
52
|
-
var
|
|
54
|
+
var isNativeDesktop = (import_react_native.Platform === null || import_react_native.Platform === void 0 ? void 0 : import_react_native.Platform.OS) === "macos" || (import_react_native.Platform === null || import_react_native.Platform === void 0 ? void 0 : import_react_native.Platform.OS) === "windows";
|
|
55
|
+
var isTouchable = !isNativeDesktop;
|
|
53
56
|
var isAndroid = (import_react_native.Platform === null || import_react_native.Platform === void 0 ? void 0 : import_react_native.Platform.OS) === "android" || process.env.TEST_NATIVE_PLATFORM === "android" || process.env.TEST_NATIVE_PLATFORM === "androidtv";
|
|
54
57
|
var isIos = (import_react_native.Platform === null || import_react_native.Platform === void 0 ? void 0 : import_react_native.Platform.OS) === "ios" || process.env.TEST_NATIVE_PLATFORM === "ios" || process.env.TEST_NATIVE_PLATFORM === "tvos";
|
|
58
|
+
var supportsDynamicColorIOS = isIos || process.env.GUI_DYNAMIC_COLOR_IOS === "1";
|
|
55
59
|
var isTV = (import_react_native.Platform === null || import_react_native.Platform === void 0 ? void 0 : import_react_native.Platform.isTV) || process.env.TEST_NATIVE_PLATFORM === "androidtv" || process.env.TEST_NATIVE_PLATFORM === "tvos";
|
|
56
60
|
var currentPlatform = ((import_react_native.Platform === null || import_react_native.Platform === void 0 ? void 0 : import_react_native.Platform.OS) ? {
|
|
57
61
|
ios: "ios",
|
|
58
|
-
android: "android"
|
|
62
|
+
android: "android",
|
|
63
|
+
macos: "macos",
|
|
64
|
+
windows: "windows"
|
|
59
65
|
}[import_react_native.Platform.OS] : void 0) || "native";
|
|
60
66
|
//# sourceMappingURL=constants.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["to","__toCommonJS","mod","__copyProps","__defProp","value","constants_native_exports","__export","currentPlatform","isAndroid","isBrowser","isChrome","isClient","isIos","isServer","isTV","isTouchable","isWeb","isWebTouchable","isWindowDefined","useIsomorphicLayoutEffect","module","exports","import_react","require","import_react_native","useLayoutEffect","Platform","OS","process","env","TEST_NATIVE_PLATFORM","ios","android"],"sources":["../../src/constants.native.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;EAAA,OAAAA,EAAA;AAAA;AAAA,IAAAC,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,wBAAA;AAAAC,QAAA,CAAAD,wBAAA;EAAAE,eAAA,EAAAA,CAAA,KAAAA,eAAA;EAAAC,SAAA,EAAAA,CAAA,KAAAA,SAAA;EAAAC,SAAA,EAAAA,CAAA,KAAAA,SAAA;EAAAC,QAAA,EAAAA,CAAA,KAAAA,QAAA;EAAAC,QAAA,EAAAA,CAAA,KAAAA,QAAA;EAAAC,KAAA,EAAAA,CAAA,KAAAA,KAAA;EAAAC,QAAA,EAAAA,CAAA,KAAAA,QAAA;EAAAC,IAAA,EAAAA,CAAA,KAAAA,IAAA;EAAAC,WAAA,EAAAA,CAAA,KAAAA,WAAA;EAAAC,KAAA,EAAAA,CAAA,KAAAA,KAAA;EAAAC,cAAA,EAAAA,CAAA,KAAAA,cAAA;EAAAC,eAAA,EAAAA,CAAA,KAAAA,eAAA;EAAAC,yBAAgC,EAAAA,CAAA,KAAAA;AAChC;AACOC,MAAI,CAAAC,OAAQ,
|
|
1
|
+
{"version":3,"names":["to","__toCommonJS","mod","__copyProps","__defProp","value","constants_native_exports","__export","currentPlatform","isAndroid","isBrowser","isChrome","isClient","isIos","isNativeDesktop","isServer","isTV","isTouchable","isWeb","isWebTouchable","isWindowDefined","supportsDynamicColorIOS","useIsomorphicLayoutEffect","module","exports","import_react","require","import_react_native","useLayoutEffect","Platform","OS","process","env","TEST_NATIVE_PLATFORM","GUI_DYNAMIC_COLOR_IOS","ios","android","macos","windows"],"sources":["../../src/constants.native.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;EAAA,OAAAA,EAAA;AAAA;AAAA,IAAAC,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,wBAAA;AAAAC,QAAA,CAAAD,wBAAA;EAAAE,eAAA,EAAAA,CAAA,KAAAA,eAAA;EAAAC,SAAA,EAAAA,CAAA,KAAAA,SAAA;EAAAC,SAAA,EAAAA,CAAA,KAAAA,SAAA;EAAAC,QAAA,EAAAA,CAAA,KAAAA,QAAA;EAAAC,QAAA,EAAAA,CAAA,KAAAA,QAAA;EAAAC,KAAA,EAAAA,CAAA,KAAAA,KAAA;EAAAC,eAAA,EAAAA,CAAA,KAAAA,eAAA;EAAAC,QAAA,EAAAA,CAAA,KAAAA,QAAA;EAAAC,IAAA,EAAAA,CAAA,KAAAA,IAAA;EAAAC,WAAA,EAAAA,CAAA,KAAAA,WAAA;EAAAC,KAAA,EAAAA,CAAA,KAAAA,KAAA;EAAAC,cAAA,EAAAA,CAAA,KAAAA,cAAA;EAAAC,eAAA,EAAAA,CAAA,KAAAA,eAAA;EAAAC,uBAAA,EAAAA,CAAA,KAAAA,uBAAA;EAAAC,yBAAgC,EAAAA,CAAA,KAAAA;AAChC;AACOC,MAAI,CAAAC,OAAQ,GAAAvB,YAAA,CAAAK,wBAAA;AACZ,IAAImB,YAAY,GAAAC,OAAA;AAChB,IAAIC,mBAAW,GAAAD,OAAA;AACf,IAAIR,KAAA,QAAW;AAC0B,IAAIR,SAAA;AAC7C,IAAIK,QAAA;AACJ,IAAIH,QAAA,GAAW;AACf,IAAIQ,eAAA,GAAiB;AACrB,IAAIE,yBAAmB,GAAAG,YAAA,CAAAG,eAAa;AACpC,IAAIjB,QAAA,QAAe;AAGnB,IAAIQ,cAAa;AAEjB,IAAIL,eAAS,IAAAa,mBAAA,CAAAE,QAAa,KAAQ,QAAAF,mBAAA,CAAAE,QAAa,KAAS,SAAS,SAAAF,mBAAS,CAAAE,QAAQ,CAAAC,EAAA,MAAS,OAAQ,IAAI,CAAAH,mBAAA,CAAAE,QAAyB,KAAS,QAAQF,mBAAI,CAAAE,QAAA,KAAyB,kBAAAF,mBAAA,CAAAE,QAAA,CAAAC,EAAA;AAC9K,IAAIb,WAAA,IAAAH,eAA0B;AAC9B,IAAIL,SAAQ,IAAAkB,mBAAA,CAAAE,QAAa,SAAQ,IAAAF,mBAAA,CAAAE,QAAa,UAAS,SAAS,IAAAF,mBAAA,CAAAE,QAAS,CAAAC,EAAA,MAAS,SAAY,IAAAC,OAAA,CAAAC,GAAA,CAAAC,oBAAyB,KAAe,SAAQ,IAAIF,OAAA,CAAAC,GAAA,CAAAC,oBAAyB;AAClL,IAAIpB,KAAA,IAAAc,mBAAY,CAAAE,QAAA,aAAAF,mBAAA,CAAAE,QAAA,uBAAAF,mBAAA,CAAAE,QAAA,CAAAC,EAAA,eAAAC,OAAA,CAAAC,GAAA,CAAAC,oBAAA,cAAAF,OAAA,CAAAC,GAAA,CAAAC,oBAAA;AAAA,IACZZ,uBAAK,GAAAR,KAAA,IAAAkB,OAAA,CAAAC,GAAA,CAAAE,qBAAA;AAAA,IACLlB,IAAA,GAAS,CAAAW,mBAAA,CAAAE,QAAA,aAAAF,mBAAA,CAAAE,QAAA,uBAAAF,mBAAA,CAAAE,QAAA,CAAAb,IAAA,KAAAe,OAAA,CAAAC,GAAA,CAAAC,oBAAA,oBAAAF,OAAA,CAAAC,GAAA,CAAAC,oBAAA;AAAA,IACTzB,eAAO,KAAAmB,mBAAA,CAAAE,QAAA,aAAAF,mBAAA,CAAAE,QAAA,uBAAAF,mBAAA,CAAAE,QAAA,CAAAC,EAAA;EAAAK,GACP,OAAS;EACbC,OAAA;EAMWC,KAAI;EAKfC,OAAK;AACD,EAAAX,mBAAY,CAAAE,QAAa,CAAAC,EAAA","ignoreList":[]}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -17,4 +17,5 @@ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
|
17
17
|
}), mod);
|
|
18
18
|
var index_exports = {};
|
|
19
19
|
module.exports = __toCommonJS(index_exports);
|
|
20
|
-
__reExport(index_exports, require("./constants.cjs"), module.exports);
|
|
20
|
+
__reExport(index_exports, require("./constants.cjs"), module.exports);
|
|
21
|
+
__reExport(index_exports, require("./platformDriver.cjs"), module.exports);
|
package/dist/cjs/index.native.js
CHANGED
|
@@ -20,4 +20,5 @@ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
|
20
20
|
var index_exports = {};
|
|
21
21
|
module.exports = __toCommonJS(index_exports);
|
|
22
22
|
__reExport(index_exports, require("./constants.native.js"), module.exports);
|
|
23
|
+
__reExport(index_exports, require("./platformDriver.native.js"), module.exports);
|
|
23
24
|
//# sourceMappingURL=index.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","module","exports","__reExport","require"],"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,MAAA,CAAAC,OAAA,GAAAP,YAAc,CAAAK,aAAA;AACdG,UAAA,CAAAH,aAAA,EAAcI,OAAA,2BAAAH,MADd,CAAAC,OAAA","ignoreList":[]}
|
|
@@ -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: 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, {
|
|
14
|
+
get: () => from[key],
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
+
value: true
|
|
22
|
+
}), mod);
|
|
23
|
+
var platformDriver_exports = {};
|
|
24
|
+
__export(platformDriver_exports, {
|
|
25
|
+
getPlatformDriver: () => getPlatformDriver,
|
|
26
|
+
setupPlatformDriver: () => setupPlatformDriver
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(platformDriver_exports);
|
|
29
|
+
let platformDriver = null;
|
|
30
|
+
function setupPlatformDriver(driver) {
|
|
31
|
+
platformDriver = driver;
|
|
32
|
+
}
|
|
33
|
+
function getPlatformDriver() {
|
|
34
|
+
return platformDriver;
|
|
35
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
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, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
23
|
+
value: true
|
|
24
|
+
}), mod);
|
|
25
|
+
var platformDriver_exports = {};
|
|
26
|
+
__export(platformDriver_exports, {
|
|
27
|
+
getPlatformDriver: () => getPlatformDriver,
|
|
28
|
+
setupPlatformDriver: () => setupPlatformDriver
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(platformDriver_exports);
|
|
31
|
+
var platformDriver = null;
|
|
32
|
+
function setupPlatformDriver(driver) {
|
|
33
|
+
platformDriver = driver;
|
|
34
|
+
}
|
|
35
|
+
function getPlatformDriver() {
|
|
36
|
+
return platformDriver;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=platformDriver.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","platformDriver_exports","__export","getPlatformDriver","setupPlatformDriver","module","exports","platformDriver","driver"],"sources":["../../src/platformDriver.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,sBAAA;AAAAC,QAAA,CAAAD,sBAAA;EAAAE,iBAAA,EAAAA,CAAA,KAAAA,iBAAA;EAAAC,mBAAA,EAAAA,CAAA,KAAAA;AAAA;AA+BAC,MAAI,CAAAC,OAAA,GAAAV,YAAwC,CAAAK,sBAAA;AAGrC,IAAAM,cAAS;AACd,SAAAH,mBAAiBA,CAAAI,MAAA;EACnBD,cAAA,GAAAC,MAAA;AAEO;AACL,SAAOL,kBAAA;EACT,OAAAI,cAAA","ignoreList":[]}
|
package/dist/esm/constants.mjs
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { useEffect, useLayoutEffect } from "react";
|
|
2
2
|
const isWeb = true;
|
|
3
|
-
const isBrowser = typeof
|
|
3
|
+
const isBrowser = typeof navigator !== "undefined" && typeof location !== "undefined";
|
|
4
4
|
const isServer = !isBrowser;
|
|
5
5
|
const isClient = isBrowser;
|
|
6
6
|
const isWindowDefined = isBrowser;
|
|
7
7
|
const useIsomorphicLayoutEffect = isServer ? useEffect : useLayoutEffect;
|
|
8
8
|
const isChrome = typeof navigator !== "undefined" && /Chrome/.test(navigator.userAgent || "");
|
|
9
9
|
const isWebTouchable = isClient && ("ontouchstart" in window || navigator.maxTouchPoints > 0);
|
|
10
|
+
const isNativeDesktop = false;
|
|
10
11
|
const isTouchable = isWebTouchable;
|
|
11
12
|
const isAndroid = process.env.TEST_NATIVE_PLATFORM === "android" || process.env.TEST_NATIVE_PLATFORM === "androidtv";
|
|
12
13
|
const isIos = process.env.TEST_NATIVE_PLATFORM === "ios" || process.env.TEST_NATIVE_PLATFORM === "tvos";
|
|
14
|
+
const supportsDynamicColorIOS = isIos || process.env.GUI_DYNAMIC_COLOR_IOS === "1";
|
|
13
15
|
const isTV = process.env.TEST_NATIVE_PLATFORM === "androidtv" || process.env.TEST_NATIVE_PLATFORM === "tvos";
|
|
14
16
|
const currentPlatform = "web";
|
|
15
|
-
export { currentPlatform, isAndroid, isBrowser, isChrome, isClient, isIos, isServer, isTV, isTouchable, isWeb, isWebTouchable, isWindowDefined, useIsomorphicLayoutEffect };
|
|
17
|
+
export { currentPlatform, isAndroid, isBrowser, isChrome, isClient, isIos, isNativeDesktop, isServer, isTV, isTouchable, isWeb, isWebTouchable, isWindowDefined, supportsDynamicColorIOS, useIsomorphicLayoutEffect };
|
|
16
18
|
//# sourceMappingURL=constants.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useLayoutEffect","isWeb","isBrowser","
|
|
1
|
+
{"version":3,"names":["useEffect","useLayoutEffect","isWeb","isBrowser","navigator","location","isServer","isClient","isWindowDefined","useIsomorphicLayoutEffect","isChrome","test","userAgent","isWebTouchable","window","maxTouchPoints","isNativeDesktop","isTouchable","isAndroid","process","env","TEST_NATIVE_PLATFORM","isIos","supportsDynamicColorIOS","GUI_DYNAMIC_COLOR_IOS","isTV","currentPlatform"],"sources":["constants.mjs"],"sourcesContent":["import { useEffect, useLayoutEffect } from \"react\";\n\nconst isWeb = true;\nconst isBrowser = typeof navigator !== \"undefined\" && typeof location !== \"undefined\";\nconst isServer = !isBrowser;\nconst isClient = isBrowser;\nconst isWindowDefined = isBrowser;\nconst useIsomorphicLayoutEffect = isServer ? useEffect : useLayoutEffect;\nconst isChrome = typeof navigator !== \"undefined\" && /Chrome/.test(navigator.userAgent || \"\");\nconst isWebTouchable = isClient && (\"ontouchstart\" in window || navigator.maxTouchPoints > 0);\nconst isNativeDesktop = false;\nconst isTouchable = isWebTouchable;\nconst isAndroid = process.env.TEST_NATIVE_PLATFORM === \"android\" || process.env.TEST_NATIVE_PLATFORM === \"androidtv\";\nconst isIos = process.env.TEST_NATIVE_PLATFORM === \"ios\" || process.env.TEST_NATIVE_PLATFORM === \"tvos\";\nconst supportsDynamicColorIOS = isIos || process.env.GUI_DYNAMIC_COLOR_IOS === \"1\";\nconst isTV = process.env.TEST_NATIVE_PLATFORM === \"androidtv\" || process.env.TEST_NATIVE_PLATFORM === \"tvos\";\nconst currentPlatform = \"web\";\n\nexport { currentPlatform, isAndroid, isBrowser, isChrome, isClient, isIos, isNativeDesktop, isServer, isTV, isTouchable, isWeb, isWebTouchable, isWindowDefined, supportsDynamicColorIOS, useIsomorphicLayoutEffect };"],"mappings":"AAAA,SAASA,SAAS,EAAEC,eAAe,QAAQ,OAAO;AAElD,MAAMC,KAAK,GAAG,IAAI;AAClB,MAAMC,SAAS,GAAG,OAAOC,SAAS,KAAK,WAAW,IAAI,OAAOC,QAAQ,KAAK,WAAW;AACrF,MAAMC,QAAQ,GAAG,CAACH,SAAS;AAC3B,MAAMI,QAAQ,GAAGJ,SAAS;AAC1B,MAAMK,eAAe,GAAGL,SAAS;AACjC,MAAMM,yBAAyB,GAAGH,QAAQ,GAAGN,SAAS,GAAGC,eAAe;AACxE,MAAMS,QAAQ,GAAG,OAAON,SAAS,KAAK,WAAW,IAAI,QAAQ,CAACO,IAAI,CAACP,SAAS,CAACQ,SAAS,IAAI,EAAE,CAAC;AAC7F,MAAMC,cAAc,GAAGN,QAAQ,KAAK,cAAc,IAAIO,MAAM,IAAIV,SAAS,CAACW,cAAc,GAAG,CAAC,CAAC;AAC7F,MAAMC,eAAe,GAAG,KAAK;AAC7B,MAAMC,WAAW,GAAGJ,cAAc;AAClC,MAAMK,SAAS,GAAGC,OAAO,CAACC,GAAG,CAACC,oBAAoB,KAAK,SAAS,IAAIF,OAAO,CAACC,GAAG,CAACC,oBAAoB,KAAK,WAAW;AACpH,MAAMC,KAAK,GAAGH,OAAO,CAACC,GAAG,CAACC,oBAAoB,KAAK,KAAK,IAAIF,OAAO,CAACC,GAAG,CAACC,oBAAoB,KAAK,MAAM;AACvG,MAAME,uBAAuB,GAAGD,KAAK,IAAIH,OAAO,CAACC,GAAG,CAACI,qBAAqB,KAAK,GAAG;AAClF,MAAMC,IAAI,GAAGN,OAAO,CAACC,GAAG,CAACC,oBAAoB,KAAK,WAAW,IAAIF,OAAO,CAACC,GAAG,CAACC,oBAAoB,KAAK,MAAM;AAC5G,MAAMK,eAAe,GAAG,KAAK;AAE7B,SAASA,eAAe,EAAER,SAAS,EAAEf,SAAS,EAAEO,QAAQ,EAAEH,QAAQ,EAAEe,KAAK,EAAEN,eAAe,EAAEV,QAAQ,EAAEmB,IAAI,EAAER,WAAW,EAAEf,KAAK,EAAEW,cAAc,EAAEL,eAAe,EAAEe,uBAAuB,EAAEd,yBAAyB","ignoreList":[]}
|
|
@@ -8,13 +8,17 @@ var isWindowDefined = false;
|
|
|
8
8
|
var useIsomorphicLayoutEffect = useLayoutEffect;
|
|
9
9
|
var isChrome = false;
|
|
10
10
|
var isWebTouchable = false;
|
|
11
|
-
var
|
|
11
|
+
var isNativeDesktop = (Platform === null || Platform === void 0 ? void 0 : Platform.OS) === "macos" || (Platform === null || Platform === void 0 ? void 0 : Platform.OS) === "windows";
|
|
12
|
+
var isTouchable = !isNativeDesktop;
|
|
12
13
|
var isAndroid = (Platform === null || Platform === void 0 ? void 0 : Platform.OS) === "android" || process.env.TEST_NATIVE_PLATFORM === "android" || process.env.TEST_NATIVE_PLATFORM === "androidtv";
|
|
13
14
|
var isIos = (Platform === null || Platform === void 0 ? void 0 : Platform.OS) === "ios" || process.env.TEST_NATIVE_PLATFORM === "ios" || process.env.TEST_NATIVE_PLATFORM === "tvos";
|
|
15
|
+
var supportsDynamicColorIOS = isIos || process.env.GUI_DYNAMIC_COLOR_IOS === "1";
|
|
14
16
|
var isTV = (Platform === null || Platform === void 0 ? void 0 : Platform.isTV) || process.env.TEST_NATIVE_PLATFORM === "androidtv" || process.env.TEST_NATIVE_PLATFORM === "tvos";
|
|
15
17
|
var currentPlatform = ((Platform === null || Platform === void 0 ? void 0 : Platform.OS) ? {
|
|
16
18
|
ios: "ios",
|
|
17
|
-
android: "android"
|
|
19
|
+
android: "android",
|
|
20
|
+
macos: "macos",
|
|
21
|
+
windows: "windows"
|
|
18
22
|
}[Platform.OS] : void 0) || "native";
|
|
19
|
-
export { currentPlatform, isAndroid, isBrowser, isChrome, isClient, isIos, isServer, isTV, isTouchable, isWeb, isWebTouchable, isWindowDefined, useIsomorphicLayoutEffect };
|
|
23
|
+
export { currentPlatform, isAndroid, isBrowser, isChrome, isClient, isIos, isNativeDesktop, isServer, isTV, isTouchable, isWeb, isWebTouchable, isWindowDefined, supportsDynamicColorIOS, useIsomorphicLayoutEffect };
|
|
20
24
|
//# sourceMappingURL=constants.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useLayoutEffect","Platform","isWeb","isBrowser","isServer","isClient","isWindowDefined","useIsomorphicLayoutEffect","isChrome","isWebTouchable","
|
|
1
|
+
{"version":3,"names":["useLayoutEffect","Platform","isWeb","isBrowser","isServer","isClient","isWindowDefined","useIsomorphicLayoutEffect","isChrome","isWebTouchable","isNativeDesktop","OS","isTouchable","isAndroid","process","env","TEST_NATIVE_PLATFORM","isIos","supportsDynamicColorIOS","GUI_DYNAMIC_COLOR_IOS","isTV","currentPlatform","ios","android","macos","windows"],"sources":["constants.native.js"],"sourcesContent":["import { useLayoutEffect } from \"react\";\nimport { Platform } from \"react-native\";\n\nvar isWeb = false;\nvar isBrowser = false;\nvar isServer = false;\nvar isClient = true;\nvar isWindowDefined = false;\nvar useIsomorphicLayoutEffect = useLayoutEffect;\nvar isChrome = false;\nvar isWebTouchable = false;\nvar isNativeDesktop = (Platform === null || Platform === void 0 ? void 0 : Platform.OS) === \"macos\" || (Platform === null || Platform === void 0 ? void 0 : Platform.OS) === \"windows\";\nvar isTouchable = !isNativeDesktop;\nvar isAndroid = (Platform === null || Platform === void 0 ? void 0 : Platform.OS) === \"android\" || process.env.TEST_NATIVE_PLATFORM === \"android\" || process.env.TEST_NATIVE_PLATFORM === \"androidtv\";\nvar isIos = (Platform === null || Platform === void 0 ? void 0 : Platform.OS) === \"ios\" || process.env.TEST_NATIVE_PLATFORM === \"ios\" || process.env.TEST_NATIVE_PLATFORM === \"tvos\";\nvar supportsDynamicColorIOS = isIos || process.env.GUI_DYNAMIC_COLOR_IOS === \"1\";\nvar isTV = (Platform === null || Platform === void 0 ? void 0 : Platform.isTV) || process.env.TEST_NATIVE_PLATFORM === \"androidtv\" || process.env.TEST_NATIVE_PLATFORM === \"tvos\";\nvar currentPlatform = ((Platform === null || Platform === void 0 ? void 0 : Platform.OS) ? {\n\tios: \"ios\",\n\tandroid: \"android\",\n\tmacos: \"macos\",\n\twindows: \"windows\"\n}[Platform.OS] : void 0) || \"native\";\n\nexport { currentPlatform, isAndroid, isBrowser, isChrome, isClient, isIos, isNativeDesktop, isServer, isTV, isTouchable, isWeb, isWebTouchable, isWindowDefined, supportsDynamicColorIOS, useIsomorphicLayoutEffect };"],"mappings":"AAAA,SAASA,eAAe,QAAQ,OAAO;AACvC,SAASC,QAAQ,QAAQ,cAAc;AAEvC,IAAIC,KAAK,GAAG,KAAK;AACjB,IAAIC,SAAS,GAAG,KAAK;AACrB,IAAIC,QAAQ,GAAG,KAAK;AACpB,IAAIC,QAAQ,GAAG,IAAI;AACnB,IAAIC,eAAe,GAAG,KAAK;AAC3B,IAAIC,yBAAyB,GAAGP,eAAe;AAC/C,IAAIQ,QAAQ,GAAG,KAAK;AACpB,IAAIC,cAAc,GAAG,KAAK;AAC1B,IAAIC,eAAe,GAAG,CAACT,QAAQ,KAAK,IAAI,IAAIA,QAAQ,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAGA,QAAQ,CAACU,EAAE,MAAM,OAAO,IAAI,CAACV,QAAQ,KAAK,IAAI,IAAIA,QAAQ,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAGA,QAAQ,CAACU,EAAE,MAAM,SAAS;AACtL,IAAIC,WAAW,GAAG,CAACF,eAAe;AAClC,IAAIG,SAAS,GAAG,CAACZ,QAAQ,KAAK,IAAI,IAAIA,QAAQ,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAGA,QAAQ,CAACU,EAAE,MAAM,SAAS,IAAIG,OAAO,CAACC,GAAG,CAACC,oBAAoB,KAAK,SAAS,IAAIF,OAAO,CAACC,GAAG,CAACC,oBAAoB,KAAK,WAAW;AACrM,IAAIC,KAAK,GAAG,CAAChB,QAAQ,KAAK,IAAI,IAAIA,QAAQ,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAGA,QAAQ,CAACU,EAAE,MAAM,KAAK,IAAIG,OAAO,CAACC,GAAG,CAACC,oBAAoB,KAAK,KAAK,IAAIF,OAAO,CAACC,GAAG,CAACC,oBAAoB,KAAK,MAAM;AACpL,IAAIE,uBAAuB,GAAGD,KAAK,IAAIH,OAAO,CAACC,GAAG,CAACI,qBAAqB,KAAK,GAAG;AAChF,IAAIC,IAAI,GAAG,CAACnB,QAAQ,KAAK,IAAI,IAAIA,QAAQ,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAGA,QAAQ,CAACmB,IAAI,KAAKN,OAAO,CAACC,GAAG,CAACC,oBAAoB,KAAK,WAAW,IAAIF,OAAO,CAACC,GAAG,CAACC,oBAAoB,KAAK,MAAM;AACjL,IAAIK,eAAe,GAAG,CAAC,CAACpB,QAAQ,KAAK,IAAI,IAAIA,QAAQ,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAGA,QAAQ,CAACU,EAAE,IAAI;EAC1FW,GAAG,EAAE,KAAK;EACVC,OAAO,EAAE,SAAS;EAClBC,KAAK,EAAE,OAAO;EACdC,OAAO,EAAE;AACV,CAAC,CAACxB,QAAQ,CAACU,EAAE,CAAC,GAAG,KAAK,CAAC,KAAK,QAAQ;AAEpC,SAASU,eAAe,EAAER,SAAS,EAAEV,SAAS,EAAEK,QAAQ,EAAEH,QAAQ,EAAEY,KAAK,EAAEP,eAAe,EAAEN,QAAQ,EAAEgB,IAAI,EAAER,WAAW,EAAEV,KAAK,EAAEO,cAAc,EAAEH,eAAe,EAAEY,uBAAuB,EAAEX,yBAAyB","ignoreList":[]}
|
package/dist/esm/index.js
CHANGED
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc;AACd,cAAc","ignoreList":[]}
|
package/dist/esm/index.mjs
CHANGED
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc;AACd,cAAc","ignoreList":[]}
|
package/dist/esm/index.native.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc;AACd,cAAc","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["platformDriver","setupPlatformDriver","driver","getPlatformDriver"],"sources":["../../src/platformDriver.ts"],"sourcesContent":[null],"mappings":"AA+BA,IAAIA,cAAA,GAAwC;AAGrC,SAASC,oBAAoBC,MAAA,EAA8B;EAChEF,cAAA,GAAiBE,MAAA;AACnB;AAEO,SAASC,kBAAA,EAA2C;EACzD,OAAOH,cAAA;AACT","ignoreList":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
var platformDriver = null;
|
|
2
|
+
function setupPlatformDriver(driver) {
|
|
3
|
+
platformDriver = driver;
|
|
4
|
+
}
|
|
5
|
+
function getPlatformDriver() {
|
|
6
|
+
return platformDriver;
|
|
7
|
+
}
|
|
8
|
+
export { getPlatformDriver, setupPlatformDriver };
|
|
9
|
+
//# sourceMappingURL=platformDriver.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["platformDriver","setupPlatformDriver","driver","getPlatformDriver"],"sources":["../../src/platformDriver.ts"],"sourcesContent":[null],"mappings":"AA+BA,IAAIA,cAAA,GAAwC;AAGrC,SAASC,oBAAoBC,MAAA,EAA8B;EAChEF,cAAA,GAAiBE,MAAA;AACnB;AAEO,SAASC,kBAAA,EAA2C;EACzD,OAAOH,cAAA;AACT","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hanzogui/constants",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14",
|
|
5
5
|
"files": [
|
|
6
6
|
"src",
|
|
@@ -28,20 +28,17 @@
|
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
|
-
"build": "
|
|
32
|
-
"watch": "
|
|
33
|
-
"clean": "
|
|
34
|
-
"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
|
"devDependencies": {
|
|
37
|
-
"@hanzogui/build": "
|
|
37
|
+
"@hanzogui/build": "8.0.0",
|
|
38
38
|
"react": ">=19",
|
|
39
39
|
"react-native": "0.83.2"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"react": ">=19"
|
|
43
|
-
|
|
44
|
-
},
|
|
45
|
-
"license": "BSD-3-Clause",
|
|
46
|
-
"author": "Hanzo AI <dev@hanzo.ai>"
|
|
42
|
+
"react": ">=19"
|
|
43
|
+
}
|
|
47
44
|
}
|
package/src/constants.native.ts
CHANGED
|
@@ -10,7 +10,9 @@ export const isWindowDefined: boolean = false
|
|
|
10
10
|
export const useIsomorphicLayoutEffect: typeof useEffect = useLayoutEffect
|
|
11
11
|
export const isChrome: boolean = false
|
|
12
12
|
export const isWebTouchable: boolean = false
|
|
13
|
-
export const
|
|
13
|
+
export const isNativeDesktop: boolean =
|
|
14
|
+
Platform?.OS === 'macos' || Platform?.OS === 'windows'
|
|
15
|
+
export const isTouchable: boolean = !isNativeDesktop
|
|
14
16
|
// optional chain required: babel extractor loads native.cjs in node where Platform is undefined
|
|
15
17
|
// On Android TV: Platform.OS === 'android' per react-native-tvos
|
|
16
18
|
export const isAndroid: boolean =
|
|
@@ -22,19 +24,26 @@ export const isIos: boolean =
|
|
|
22
24
|
Platform?.OS === 'ios' ||
|
|
23
25
|
process.env.TEST_NATIVE_PLATFORM === 'ios' ||
|
|
24
26
|
process.env.TEST_NATIVE_PLATFORM === 'tvos'
|
|
27
|
+
export const supportsDynamicColorIOS: boolean =
|
|
28
|
+
isIos || process.env.GUI_DYNAMIC_COLOR_IOS === '1'
|
|
25
29
|
export const isTV: boolean =
|
|
26
30
|
Platform?.isTV ||
|
|
27
31
|
process.env.TEST_NATIVE_PLATFORM === 'androidtv' ||
|
|
28
32
|
process.env.TEST_NATIVE_PLATFORM === 'tvos'
|
|
29
33
|
|
|
30
|
-
const platforms = {
|
|
34
|
+
const platforms = {
|
|
35
|
+
ios: 'ios',
|
|
36
|
+
android: 'android',
|
|
37
|
+
macos: 'macos',
|
|
38
|
+
windows: 'windows',
|
|
39
|
+
} as const
|
|
31
40
|
/**
|
|
32
41
|
* Reflects Platform.OS. TV platforms are intentionally NOT separate values:
|
|
33
42
|
* - Android TV has Platform.OS === 'android' (react-native-tvos behavior)
|
|
34
43
|
* - tvOS has Platform.OS === 'ios' (react-native-tvos behavior)
|
|
35
44
|
* Use `isTV` combined with `isAndroid`/`isIos` to detect specific TV platforms.
|
|
36
45
|
*/
|
|
37
|
-
export const currentPlatform: 'web' | 'ios' | 'native' | 'android' =
|
|
46
|
+
export const currentPlatform: 'web' | 'ios' | 'native' | 'android' | 'macos' | 'windows' =
|
|
38
47
|
(Platform?.OS ? platforms[Platform.OS] : undefined) || 'native'
|
|
39
48
|
|
|
40
49
|
// In Metro source mode, GUI_TARGET may not be set by the build tool.
|
package/src/constants.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { useEffect, useLayoutEffect } from 'react'
|
|
2
2
|
|
|
3
3
|
export const isWeb: boolean = true
|
|
4
|
-
|
|
5
|
-
//
|
|
6
|
-
|
|
4
|
+
|
|
5
|
+
// RN adds fake window and document so its not simple to get this right
|
|
6
|
+
// check both navigator and location
|
|
7
|
+
export const isBrowser: boolean =
|
|
8
|
+
typeof navigator !== 'undefined' && typeof location !== 'undefined'
|
|
9
|
+
|
|
7
10
|
export const isServer: boolean = isWeb && !isBrowser
|
|
8
11
|
export const isClient: boolean = isWeb && isBrowser
|
|
9
12
|
/** @deprecated use isBrowser instead */
|
|
@@ -19,6 +22,7 @@ export const isChrome: boolean =
|
|
|
19
22
|
export const isWebTouchable: boolean =
|
|
20
23
|
isClient && ('ontouchstart' in window || navigator.maxTouchPoints > 0)
|
|
21
24
|
|
|
25
|
+
export const isNativeDesktop: boolean = false
|
|
22
26
|
export const isTouchable: boolean = !isWeb || isWebTouchable
|
|
23
27
|
// set :boolean to avoid inferring type to false
|
|
24
28
|
// On web, isAndroid/isIos are always false in production.
|
|
@@ -32,6 +36,8 @@ export const isIos: boolean =
|
|
|
32
36
|
process.env.TEST_NATIVE_PLATFORM === 'ios' ||
|
|
33
37
|
// tvOS has Platform.OS === 'ios' per react-native-tvos
|
|
34
38
|
process.env.TEST_NATIVE_PLATFORM === 'tvos'
|
|
39
|
+
export const supportsDynamicColorIOS: boolean =
|
|
40
|
+
isIos || process.env.GUI_DYNAMIC_COLOR_IOS === '1'
|
|
35
41
|
export const isTV: boolean =
|
|
36
42
|
process.env.TEST_NATIVE_PLATFORM === 'androidtv' ||
|
|
37
43
|
process.env.TEST_NATIVE_PLATFORM === 'tvos'
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// the renderer-platform extension point: a custom renderer (e.g. react-native-gpui,
|
|
2
|
+
// which reconciles React into GPUI/Metal) registers ONE driver object at app setup
|
|
3
|
+
// and hanzogui consults it for capabilities the renderer owns better than JS can.
|
|
4
|
+
//
|
|
5
|
+
// first capability: `pseudo` — the renderer resolves hover natively per hitbox
|
|
6
|
+
// (zero latency, no event round-trip) and pushes pseudo-state flips INTO hanzogui,
|
|
7
|
+
// which runs its normal animation-driver/emitter path off them (spring if styled,
|
|
8
|
+
// instant otherwise, zero React commits). this replaces both the per-site
|
|
9
|
+
// `transition="0ms"` requirement and the mouseEnter/mouseLeave hover lane on such
|
|
10
|
+
// renderers. more capabilities (measure, focus, scroll) can slot in over time.
|
|
11
|
+
|
|
12
|
+
export interface PlatformDriverPseudoState {
|
|
13
|
+
hovered: boolean
|
|
14
|
+
pressed: boolean
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface PlatformDriver {
|
|
18
|
+
pseudo?: {
|
|
19
|
+
/**
|
|
20
|
+
* subscribe a mounted component's host instance to native pseudo-state flips.
|
|
21
|
+
* the host instance is whatever the renderer's ref resolves to (on
|
|
22
|
+
* react-native-gpui, the reconciler Instance whose `.id` is the host node id).
|
|
23
|
+
* returns an unsubscribe.
|
|
24
|
+
*/
|
|
25
|
+
subscribe(
|
|
26
|
+
hostInstance: unknown,
|
|
27
|
+
listener: (state: PlatformDriverPseudoState) => void
|
|
28
|
+
): () => void
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
let platformDriver: PlatformDriver | null = null
|
|
33
|
+
|
|
34
|
+
/** register the renderer platform driver — call once at app setup, before render. */
|
|
35
|
+
export function setupPlatformDriver(driver: PlatformDriver): void {
|
|
36
|
+
platformDriver = driver
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function getPlatformDriver(): PlatformDriver | null {
|
|
40
|
+
return platformDriver
|
|
41
|
+
}
|
package/types/constants.d.ts
CHANGED
|
@@ -8,9 +8,11 @@ export declare const isWindowDefined: boolean;
|
|
|
8
8
|
export declare const useIsomorphicLayoutEffect: typeof useEffect;
|
|
9
9
|
export declare const isChrome: boolean;
|
|
10
10
|
export declare const isWebTouchable: boolean;
|
|
11
|
+
export declare const isNativeDesktop: boolean;
|
|
11
12
|
export declare const isTouchable: boolean;
|
|
12
13
|
export declare const isAndroid: boolean;
|
|
13
14
|
export declare const isIos: boolean;
|
|
15
|
+
export declare const supportsDynamicColorIOS: boolean;
|
|
14
16
|
export declare const isTV: boolean;
|
|
15
17
|
/**
|
|
16
18
|
* Reflects Platform.OS. TV platforms are intentionally NOT separate values:
|
package/types/constants.d.ts.map
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"mappings": "AAAA,SAAS,iBAAkC;AAE3C,OAAO,cAAM;
|
|
2
|
+
"mappings": "AAAA,SAAS,iBAAkC;AAE3C,OAAO,cAAM;AAIb,OAAO,cAAM;AAGb,OAAO,cAAM;AACb,OAAO,cAAM;;AAEb,OAAO,cAAM;AAEb,OAAO,cAAM,kCAAkC;AAI/C,OAAO,cAAM;AAGb,OAAO,cAAM;AAGb,OAAO,cAAM;AACb,OAAO,cAAM;AAKb,OAAO,cAAM;AAIb,OAAO,cAAM;AAIb,OAAO,cAAM;AAEb,OAAO,cAAM;;;;;;;AASb,OAAO,cAAM,iBAAiB,QAAQ,QAAQ,WAAW",
|
|
3
3
|
"names": [],
|
|
4
4
|
"sources": [
|
|
5
5
|
"src/constants.ts"
|
|
6
6
|
],
|
|
7
7
|
"version": 3,
|
|
8
8
|
"sourcesContent": [
|
|
9
|
-
"import { useEffect, useLayoutEffect } from 'react'\n\nexport const isWeb: boolean = true\n//
|
|
9
|
+
"import { useEffect, useLayoutEffect } from 'react'\n\nexport const isWeb: boolean = true\n\n// RN adds fake window and document so its not simple to get this right\n// check both navigator and location\nexport const isBrowser: boolean =\n typeof navigator !== 'undefined' && typeof location !== 'undefined'\n\nexport const isServer: boolean = isWeb && !isBrowser\nexport const isClient: boolean = isWeb && isBrowser\n/** @deprecated use isBrowser instead */\nexport const isWindowDefined: boolean = isBrowser\n\nexport const useIsomorphicLayoutEffect: typeof useEffect = isServer\n ? useEffect\n : useLayoutEffect\n\nexport const isChrome: boolean =\n typeof navigator !== 'undefined' && /Chrome/.test(navigator.userAgent || '')\n\nexport const isWebTouchable: boolean =\n isClient && ('ontouchstart' in window || navigator.maxTouchPoints > 0)\n\nexport const isNativeDesktop: boolean = false\nexport const isTouchable: boolean = !isWeb || isWebTouchable\n// set :boolean to avoid inferring type to false\n// On web, isAndroid/isIos are always false in production.\n// TEST_NATIVE_PLATFORM is only set by the test runner (vitest) to simulate native\n// environments (e.g. androidtv, tvos) from a web/jsdom test context.\nexport const isAndroid: boolean =\n process.env.TEST_NATIVE_PLATFORM === 'android' ||\n // Android TV has Platform.OS === 'android' per react-native-tvos\n process.env.TEST_NATIVE_PLATFORM === 'androidtv'\nexport const isIos: boolean =\n process.env.TEST_NATIVE_PLATFORM === 'ios' ||\n // tvOS has Platform.OS === 'ios' per react-native-tvos\n process.env.TEST_NATIVE_PLATFORM === 'tvos'\nexport const supportsDynamicColorIOS: boolean =\n isIos || process.env.GUI_DYNAMIC_COLOR_IOS === '1'\nexport const isTV: boolean =\n process.env.TEST_NATIVE_PLATFORM === 'androidtv' ||\n process.env.TEST_NATIVE_PLATFORM === 'tvos'\n/**\n * Reflects Platform.OS. TV platforms are intentionally NOT separate values:\n * - Android TV has Platform.OS === 'android' (react-native-tvos behavior)\n * - tvOS has Platform.OS === 'ios' (react-native-tvos behavior)\n * Use `isTV` combined with `isAndroid`/`isIos` to detect specific TV platforms.\n */\nexport const currentPlatform: 'web' | 'ios' | 'native' | 'android' = 'web'\n\n// In web source mode (Vite/webpack without pre-built dist), GUI_TARGET may not be set.\n// Set it here so all process.env.GUI_TARGET runtime checks work correctly.\n// In pre-built dist, the build tool inlines GUI_TARGET as a literal string,\n// making this block dead code (if (!'web') → never executes).\nif (!process.env.GUI_TARGET) {\n process.env.GUI_TARGET = 'web'\n}\n"
|
|
10
10
|
]
|
|
11
11
|
}
|
|
@@ -8,9 +8,11 @@ export declare const isWindowDefined: boolean;
|
|
|
8
8
|
export declare const useIsomorphicLayoutEffect: typeof useEffect;
|
|
9
9
|
export declare const isChrome: boolean;
|
|
10
10
|
export declare const isWebTouchable: boolean;
|
|
11
|
+
export declare const isNativeDesktop: boolean;
|
|
11
12
|
export declare const isTouchable: boolean;
|
|
12
13
|
export declare const isAndroid: boolean;
|
|
13
14
|
export declare const isIos: boolean;
|
|
15
|
+
export declare const supportsDynamicColorIOS: boolean;
|
|
14
16
|
export declare const isTV: boolean;
|
|
15
17
|
/**
|
|
16
18
|
* Reflects Platform.OS. TV platforms are intentionally NOT separate values:
|
|
@@ -18,6 +20,6 @@ export declare const isTV: boolean;
|
|
|
18
20
|
* - tvOS has Platform.OS === 'ios' (react-native-tvos behavior)
|
|
19
21
|
* Use `isTV` combined with `isAndroid`/`isIos` to detect specific TV platforms.
|
|
20
22
|
*/
|
|
21
|
-
export declare const currentPlatform: "web" | "ios" | "native" | "android";
|
|
23
|
+
export declare const currentPlatform: "web" | "ios" | "native" | "android" | "macos" | "windows";
|
|
22
24
|
|
|
23
25
|
//# sourceMappingURL=constants.native.d.ts.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"mappings": "AAAA,cAA+B,iBAAiB;AAGhD,OAAO,cAAM;AACb,OAAO,cAAM;AACb,OAAO,cAAM;AACb,OAAO,cAAM;;AAEb,OAAO,cAAM;AACb,OAAO,cAAM,kCAAkC;AAC/C,OAAO,cAAM;AACb,OAAO,cAAM;AACb,OAAO,cAAM;AAGb,OAAO,cAAM;AAKb,OAAO,cAAM;AAIb,OAAO,cAAM;;;;;;;
|
|
2
|
+
"mappings": "AAAA,cAA+B,iBAAiB;AAGhD,OAAO,cAAM;AACb,OAAO,cAAM;AACb,OAAO,cAAM;AACb,OAAO,cAAM;;AAEb,OAAO,cAAM;AACb,OAAO,cAAM,kCAAkC;AAC/C,OAAO,cAAM;AACb,OAAO,cAAM;AACb,OAAO,cAAM;AAEb,OAAO,cAAM;AAGb,OAAO,cAAM;AAKb,OAAO,cAAM;AAIb,OAAO,cAAM;AAEb,OAAO,cAAM;;;;;;;AAiBb,OAAO,cAAM,iBAAiB,QAAQ,QAAQ,WAAW,YAAY,UAAU",
|
|
3
3
|
"names": [],
|
|
4
4
|
"sources": [
|
|
5
5
|
"src/constants.native.ts"
|
|
6
6
|
],
|
|
7
7
|
"version": 3,
|
|
8
8
|
"sourcesContent": [
|
|
9
|
-
"import { useLayoutEffect, type useEffect } from 'react'\nimport { Platform } from 'react-native'\n\nexport const isWeb: boolean = false\nexport const isBrowser: boolean = false\nexport const isServer: boolean = false\nexport const isClient: boolean = true\n/** @deprecated use isBrowser instead */\nexport const isWindowDefined: boolean = false\nexport const useIsomorphicLayoutEffect: typeof useEffect = useLayoutEffect\nexport const isChrome: boolean = false\nexport const isWebTouchable: boolean = false\nexport const isTouchable: boolean =
|
|
9
|
+
"import { useLayoutEffect, type useEffect } from 'react'\nimport { Platform } from 'react-native'\n\nexport const isWeb: boolean = false\nexport const isBrowser: boolean = false\nexport const isServer: boolean = false\nexport const isClient: boolean = true\n/** @deprecated use isBrowser instead */\nexport const isWindowDefined: boolean = false\nexport const useIsomorphicLayoutEffect: typeof useEffect = useLayoutEffect\nexport const isChrome: boolean = false\nexport const isWebTouchable: boolean = false\nexport const isNativeDesktop: boolean =\n Platform?.OS === 'macos' || Platform?.OS === 'windows'\nexport const isTouchable: boolean = !isNativeDesktop\n// optional chain required: babel extractor loads native.cjs in node where Platform is undefined\n// On Android TV: Platform.OS === 'android' per react-native-tvos\nexport const isAndroid: boolean =\n Platform?.OS === 'android' ||\n process.env.TEST_NATIVE_PLATFORM === 'android' ||\n process.env.TEST_NATIVE_PLATFORM === 'androidtv'\n// On tvOS: Platform.OS === 'ios' per react-native-tvos\nexport const isIos: boolean =\n Platform?.OS === 'ios' ||\n process.env.TEST_NATIVE_PLATFORM === 'ios' ||\n process.env.TEST_NATIVE_PLATFORM === 'tvos'\nexport const supportsDynamicColorIOS: boolean =\n isIos || process.env.GUI_DYNAMIC_COLOR_IOS === '1'\nexport const isTV: boolean =\n Platform?.isTV ||\n process.env.TEST_NATIVE_PLATFORM === 'androidtv' ||\n process.env.TEST_NATIVE_PLATFORM === 'tvos'\n\nconst platforms = {\n ios: 'ios',\n android: 'android',\n macos: 'macos',\n windows: 'windows',\n} as const\n/**\n * Reflects Platform.OS. TV platforms are intentionally NOT separate values:\n * - Android TV has Platform.OS === 'android' (react-native-tvos behavior)\n * - tvOS has Platform.OS === 'ios' (react-native-tvos behavior)\n * Use `isTV` combined with `isAndroid`/`isIos` to detect specific TV platforms.\n */\nexport const currentPlatform: 'web' | 'ios' | 'native' | 'android' | 'macos' | 'windows' =\n (Platform?.OS ? platforms[Platform.OS] : undefined) || 'native'\n\n// In Metro source mode, GUI_TARGET may not be set by the build tool.\n// Set it here so all process.env.GUI_TARGET runtime checks work correctly.\n// In pre-built dist, the build tool inlines GUI_TARGET as a literal string,\n// making this block dead code (if (!'native') → never executes).\nif (!process.env.GUI_TARGET) {\n process.env.GUI_TARGET = 'native'\n}\n"
|
|
10
10
|
]
|
|
11
11
|
}
|
package/types/index.d.ts
CHANGED
package/types/index.d.ts.map
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"mappings": "AAAA,cAAc",
|
|
2
|
+
"mappings": "AAAA,cAAc;AACd,cAAc",
|
|
3
3
|
"names": [],
|
|
4
4
|
"sources": [
|
|
5
5
|
"src/index.ts"
|
|
6
6
|
],
|
|
7
7
|
"version": 3,
|
|
8
8
|
"sourcesContent": [
|
|
9
|
-
"export * from './constants'\n"
|
|
9
|
+
"export * from './constants'\nexport * from './platformDriver'\n"
|
|
10
10
|
]
|
|
11
11
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface PlatformDriverPseudoState {
|
|
2
|
+
hovered: boolean;
|
|
3
|
+
pressed: boolean;
|
|
4
|
+
}
|
|
5
|
+
export interface PlatformDriver {
|
|
6
|
+
pseudo?: {
|
|
7
|
+
/**
|
|
8
|
+
* subscribe a mounted component's host instance to native pseudo-state flips.
|
|
9
|
+
* the host instance is whatever the renderer's ref resolves to (on
|
|
10
|
+
* react-native-gpui, the reconciler Instance whose `.id` is the host node id).
|
|
11
|
+
* returns an unsubscribe.
|
|
12
|
+
*/
|
|
13
|
+
subscribe(hostInstance: unknown, listener: (state: PlatformDriverPseudoState) => void): () => void;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/** register the renderer platform driver — call once at app setup, before render. */
|
|
17
|
+
export declare function setupPlatformDriver(driver: PlatformDriver): void;
|
|
18
|
+
export declare function getPlatformDriver(): PlatformDriver | null;
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=platformDriver.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"mappings": "AAWA,iBAAiB,0BAA0B;CACzC;CACA;;AAGF,iBAAiB,eAAe;CAC9B,SAAS;;;;;;;EAOP,UACE,uBACA,WAAW,OAAO;;;;AAQxB,OAAO,iBAAS,oBAAoB,QAAQ;AAI5C,OAAO,iBAAS,qBAAqB",
|
|
3
|
+
"names": [],
|
|
4
|
+
"sources": [
|
|
5
|
+
"src/platformDriver.ts"
|
|
6
|
+
],
|
|
7
|
+
"version": 3,
|
|
8
|
+
"sourcesContent": [
|
|
9
|
+
"// the renderer-platform extension point: a custom renderer (e.g. react-native-gpui,\n// which reconciles React into GPUI/Metal) registers ONE driver object at app setup\n// and hanzogui consults it for capabilities the renderer owns better than JS can.\n//\n// first capability: `pseudo` — the renderer resolves hover natively per hitbox\n// (zero latency, no event round-trip) and pushes pseudo-state flips INTO hanzogui,\n// which runs its normal animation-driver/emitter path off them (spring if styled,\n// instant otherwise, zero React commits). this replaces both the per-site\n// `transition=\"0ms\"` requirement and the mouseEnter/mouseLeave hover lane on such\n// renderers. more capabilities (measure, focus, scroll) can slot in over time.\n\nexport interface PlatformDriverPseudoState {\n hovered: boolean\n pressed: boolean\n}\n\nexport interface PlatformDriver {\n pseudo?: {\n /**\n * subscribe a mounted component's host instance to native pseudo-state flips.\n * the host instance is whatever the renderer's ref resolves to (on\n * react-native-gpui, the reconciler Instance whose `.id` is the host node id).\n * returns an unsubscribe.\n */\n subscribe(\n hostInstance: unknown,\n listener: (state: PlatformDriverPseudoState) => void\n ): () => void\n }\n}\n\nlet platformDriver: PlatformDriver | null = null\n\n/** register the renderer platform driver — call once at app setup, before render. */\nexport function setupPlatformDriver(driver: PlatformDriver): void {\n platformDriver = driver\n}\n\nexport function getPlatformDriver(): PlatformDriver | null {\n return platformDriver\n}\n"
|
|
10
|
+
]
|
|
11
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
BSD 3-Clause License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026-present, Hanzo AI, Inc.
|
|
4
|
-
|
|
5
|
-
Portions of this software are derived from upstream code originally licensed under
|
|
6
|
-
the MIT License, with the following copyright notices retained per its terms:
|
|
7
|
-
|
|
8
|
-
Copyright (c) 2020 Nate Wienert
|
|
9
|
-
Copyright (c) 2015-present, Nicolas Gallagher.
|
|
10
|
-
Copyright (c) 2015-present, Facebook, Inc.
|
|
11
|
-
Copyright (c) 2021 Radix
|
|
12
|
-
Copyright (c) 2017 Carmelo Pullara
|
|
13
|
-
Copyright (c) 2018 Framer B.V.
|
|
14
|
-
Copyright (c) 2022 WorkOS
|
|
15
|
-
|
|
16
|
-
All rights reserved.
|
|
17
|
-
|
|
18
|
-
Redistribution and use in source and binary forms, with or without
|
|
19
|
-
modification, are permitted provided that the following conditions are met:
|
|
20
|
-
|
|
21
|
-
1. Redistributions of source code must retain the above copyright notice, this
|
|
22
|
-
list of conditions and the following disclaimer.
|
|
23
|
-
|
|
24
|
-
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
25
|
-
this list of conditions and the following disclaimer in the documentation
|
|
26
|
-
and/or other materials provided with the distribution.
|
|
27
|
-
|
|
28
|
-
3. Neither the name of the copyright holder nor the names of its contributors
|
|
29
|
-
may be used to endorse or promote products derived from this software
|
|
30
|
-
without specific prior written permission.
|
|
31
|
-
|
|
32
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
33
|
-
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
34
|
-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
35
|
-
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
36
|
-
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
37
|
-
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
38
|
-
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
39
|
-
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
40
|
-
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
41
|
-
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
42
|
-
POSSIBILITY OF SUCH DAMAGE.
|