@vxrn/use-isomorphic-layout-effect 1.1.221 → 1.1.227
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/esm/index.native.mjs +4 -0
- package/dist/esm/index.native.mjs.map +1 -0
- package/package.json +2 -2
- package/dist/cjs/colorScheme.js +0 -56
- package/dist/cjs/colorScheme.js.map +0 -6
- package/dist/cjs/colorScheme.native.js +0 -128
- package/dist/cjs/colorScheme.native.js.map +0 -6
- package/dist/esm/colorScheme.js +0 -41
- package/dist/esm/colorScheme.js.map +0 -6
- package/dist/esm/colorScheme.mjs +0 -37
- package/dist/esm/colorScheme.mjs.map +0 -1
- package/dist/esm/colorScheme.native.js +0 -104
- package/dist/esm/colorScheme.native.js.map +0 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useLayoutEffect","useIsomorphicLayoutEffect"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,eAAW;AAGb,IAAAC,yBAAM,GAAAD,eACuC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vxrn/use-isomorphic-layout-effect",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.227",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"types": "./types/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"react": "^18.2.0 || ^19.0.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@tamagui/build": "^1.
|
|
34
|
+
"@tamagui/build": "^1.111.1"
|
|
35
35
|
},
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public"
|
package/dist/cjs/colorScheme.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
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)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
-
var colorScheme_exports = {};
|
|
16
|
-
__export(colorScheme_exports, {
|
|
17
|
-
getColorScheme: () => getColorScheme,
|
|
18
|
-
onColorSchemeChange: () => onColorSchemeChange,
|
|
19
|
-
setColorScheme: () => setColorScheme,
|
|
20
|
-
useColorScheme: () => useColorScheme,
|
|
21
|
-
useColorSchemeSetting: () => useColorSchemeSetting
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(colorScheme_exports);
|
|
24
|
-
var import_react = require("react"), import_react_native = require("react-native-web");
|
|
25
|
-
function setColorScheme(next) {
|
|
26
|
-
isOverriden = next !== "system", update(next === "system" ? getSystemColorScheme() : next);
|
|
27
|
-
}
|
|
28
|
-
function getColorScheme() {
|
|
29
|
-
return colorScheme;
|
|
30
|
-
}
|
|
31
|
-
function onColorSchemeChange(listener) {
|
|
32
|
-
return listeners.add(listener), () => {
|
|
33
|
-
listeners.delete(listener);
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
function useColorScheme() {
|
|
37
|
-
const [state, setState] = (0, import_react.useState)(getColorScheme());
|
|
38
|
-
return (0, import_react.useLayoutEffect)(() => onColorSchemeChange(setState), []), [state, setColorScheme];
|
|
39
|
-
}
|
|
40
|
-
function useColorSchemeSetting() {
|
|
41
|
-
const [state, setState] = (0, import_react.useState)(getColorSchemeSetting());
|
|
42
|
-
return (0, import_react.useLayoutEffect)(() => onColorSchemeChange(() => setState(getColorSchemeSetting())), []), [state, setColorScheme];
|
|
43
|
-
}
|
|
44
|
-
const getColorSchemeSetting = () => isOverriden ? colorScheme : "system", getWebIsDarkMatcher = () => typeof window < "u" ? window.matchMedia?.("(prefers-color-scheme: dark)") : null;
|
|
45
|
-
function getSystemColorScheme() {
|
|
46
|
-
return getWebIsDarkMatcher()?.matches ? "dark" : "light";
|
|
47
|
-
}
|
|
48
|
-
let isOverriden = !1, colorScheme = getSystemColorScheme();
|
|
49
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
50
|
-
function update(next) {
|
|
51
|
-
next !== colorScheme && (colorScheme = next, listeners.forEach((l) => l(colorScheme)));
|
|
52
|
-
}
|
|
53
|
-
getWebIsDarkMatcher()?.addEventListener("change", (val) => {
|
|
54
|
-
isOverriden || update(getSystemColorScheme());
|
|
55
|
-
});
|
|
56
|
-
//# sourceMappingURL=colorScheme.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/colorScheme.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,mBAA0C,kBAC1C,sBAA2B;AAMpB,SAAS,eAAe,MAA0B;AACvD,gBAAc,SAAS,UACvB,OAAO,SAAS,WAAW,qBAAqB,IAAI,IAAI;AAC1D;AAEO,SAAS,iBAAkC;AAChD,SAAO;AACT;AAEO,SAAS,oBAAoB,UAA+B;AACjE,mBAAU,IAAI,QAAQ,GACf,MAAM;AACX,cAAU,OAAO,QAAQ;AAAA,EAC3B;AACF;AAEO,SAAS,iBAAiB;AAC/B,QAAM,CAAC,OAAO,QAAQ,QAAI,uBAAS,eAAe,CAAC;AAEnD,2CAAgB,MACP,oBAAoB,QAAQ,GAClC,CAAC,CAAC,GAEE,CAAC,OAAO,cAAc;AAC/B;AAEO,SAAS,wBAAwB;AACtC,QAAM,CAAC,OAAO,QAAQ,QAAI,uBAAS,sBAAsB,CAAC;AAE1D,2CAAgB,MACP,oBAAoB,MAAM,SAAS,sBAAsB,CAAC,CAAC,GACjE,CAAC,CAAC,GAEE,CAAC,OAAO,cAAc;AAC/B;AAIA,MAAM,wBAAwB,MACxB,cACK,cAEF,UAGH,sBAAsB,MAC1B,OAAO,SAAW,MAAc,OAAO,aAAa,8BAA8B,IAAI;AAExF,SAAS,uBAAuB;AAI9B,SAAO,oBAAoB,GAAG,UAAU,SAAS;AACnD;AAEA,IAAI,cAAc,IACd,cAA+B,qBAAqB;AAExD,MAAM,YAAY,oBAAI,IAAyB;AAE/C,SAAS,OAAO,MAAuB;AACrC,EAAI,SAAS,gBACb,cAAc,MAId,UAAU,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;AACzC;AAUE,oBAAoB,GAAG,iBAAiB,UAAU,CAAC,QAAQ;AACzD,EAAI,eACJ,OAAO,qBAAqB,CAAC;AAC/B,CAAC;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
16
|
-
var colorScheme_exports = {};
|
|
17
|
-
__export(colorScheme_exports, {
|
|
18
|
-
getColorScheme: () => getColorScheme,
|
|
19
|
-
onColorSchemeChange: () => onColorSchemeChange,
|
|
20
|
-
setColorScheme: () => setColorScheme,
|
|
21
|
-
useColorScheme: () => useColorScheme,
|
|
22
|
-
useColorSchemeSetting: () => useColorSchemeSetting
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(colorScheme_exports);
|
|
25
|
-
var import_react = require("react"), import_react_native = require("react-native");
|
|
26
|
-
function _array_like_to_array(arr, len) {
|
|
27
|
-
(len == null || len > arr.length) && (len = arr.length);
|
|
28
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
29
|
-
return arr2;
|
|
30
|
-
}
|
|
31
|
-
function _array_with_holes(arr) {
|
|
32
|
-
if (Array.isArray(arr)) return arr;
|
|
33
|
-
}
|
|
34
|
-
function _iterable_to_array_limit(arr, i) {
|
|
35
|
-
var _i = arr == null ? null : typeof Symbol < "u" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
36
|
-
if (_i != null) {
|
|
37
|
-
var _arr = [], _n = !0, _d = !1, _s, _e;
|
|
38
|
-
try {
|
|
39
|
-
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done) && (_arr.push(_s.value), !(i && _arr.length === i)); _n = !0)
|
|
40
|
-
;
|
|
41
|
-
} catch (err) {
|
|
42
|
-
_d = !0, _e = err;
|
|
43
|
-
} finally {
|
|
44
|
-
try {
|
|
45
|
-
!_n && _i.return != null && _i.return();
|
|
46
|
-
} finally {
|
|
47
|
-
if (_d) throw _e;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return _arr;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
function _non_iterable_rest() {
|
|
54
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
55
|
-
}
|
|
56
|
-
function _sliced_to_array(arr, i) {
|
|
57
|
-
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
58
|
-
}
|
|
59
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
60
|
-
if (o) {
|
|
61
|
-
if (typeof o == "string") return _array_like_to_array(o, minLen);
|
|
62
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
63
|
-
if (n === "Object" && o.constructor && (n = o.constructor.name), n === "Map" || n === "Set") return Array.from(n);
|
|
64
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
function setColorScheme(next) {
|
|
68
|
-
isOverriden = next !== "system", update(next === "system" ? getSystemColorScheme() : next);
|
|
69
|
-
}
|
|
70
|
-
function getColorScheme() {
|
|
71
|
-
return colorScheme;
|
|
72
|
-
}
|
|
73
|
-
function onColorSchemeChange(listener) {
|
|
74
|
-
return listeners.add(listener), function() {
|
|
75
|
-
listeners.delete(listener);
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
function useColorScheme() {
|
|
79
|
-
var _useState = _sliced_to_array((0, import_react.useState)(getColorScheme()), 2), state = _useState[0], setState = _useState[1];
|
|
80
|
-
return (0, import_react.useLayoutEffect)(function() {
|
|
81
|
-
return onColorSchemeChange(setState);
|
|
82
|
-
}, []), [
|
|
83
|
-
state,
|
|
84
|
-
setColorScheme
|
|
85
|
-
];
|
|
86
|
-
}
|
|
87
|
-
function useColorSchemeSetting() {
|
|
88
|
-
var _useState = _sliced_to_array((0, import_react.useState)(getColorSchemeSetting()), 2), state = _useState[0], setState = _useState[1];
|
|
89
|
-
return (0, import_react.useLayoutEffect)(function() {
|
|
90
|
-
return onColorSchemeChange(function() {
|
|
91
|
-
return setState(getColorSchemeSetting());
|
|
92
|
-
});
|
|
93
|
-
}, []), [
|
|
94
|
-
state,
|
|
95
|
-
setColorScheme
|
|
96
|
-
];
|
|
97
|
-
}
|
|
98
|
-
var getColorSchemeSetting = function() {
|
|
99
|
-
return isOverriden ? colorScheme : "system";
|
|
100
|
-
}, getWebIsDarkMatcher = function() {
|
|
101
|
-
var _window_matchMedia, _window;
|
|
102
|
-
return typeof window < "u" ? (_window_matchMedia = (_window = window).matchMedia) === null || _window_matchMedia === void 0 ? void 0 : _window_matchMedia.call(_window, "(prefers-color-scheme: dark)") : null;
|
|
103
|
-
};
|
|
104
|
-
function getSystemColorScheme() {
|
|
105
|
-
var _getWebIsDarkMatcher;
|
|
106
|
-
return import_react_native.Appearance.getColorScheme() || "light";
|
|
107
|
-
}
|
|
108
|
-
var isOverriden = !1, colorScheme = getSystemColorScheme(), listeners = /* @__PURE__ */ new Set();
|
|
109
|
-
function update(next) {
|
|
110
|
-
next !== colorScheme && (colorScheme = next, import_react_native.Appearance.setColorScheme(next), listeners.forEach(function(l) {
|
|
111
|
-
return l(colorScheme);
|
|
112
|
-
}));
|
|
113
|
-
}
|
|
114
|
-
if (1)
|
|
115
|
-
import_react_native.Appearance.addChangeListener(function(next) {
|
|
116
|
-
isOverriden || next.colorScheme && update(next.colorScheme);
|
|
117
|
-
});
|
|
118
|
-
else
|
|
119
|
-
var _getWebIsDarkMatcher;
|
|
120
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
121
|
-
0 && (module.exports = {
|
|
122
|
-
getColorScheme,
|
|
123
|
-
onColorSchemeChange,
|
|
124
|
-
setColorScheme,
|
|
125
|
-
useColorScheme,
|
|
126
|
-
useColorSchemeSetting
|
|
127
|
-
});
|
|
128
|
-
//# sourceMappingURL=colorScheme.js.map
|
|
@@ -1,6 +0,0 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SAAoB,8BAAA,IAAkC;;AAExF,SAAShB,uBAAAA;MAIAe;AAFL,SAAOG,+BAAWjB,eAAc,KAAM;AAG1C;AAEA,IAAIH,cAAc,IACdI,cAA+BF,qBAAAA,GAE7BK,YAAY,oBAAIc,IAAAA;AAEtB,SAASpB,OAAOF,MAAqB;AACnC,EAAIA,SAASK,gBACbA,cAAcL,MAEZqB,+BAAWtB,eAAeC,IAAAA,GAE5BQ,UAAUe,QAAQ,SAACC,GAAAA;WAAMA,EAAEnB,WAAAA;;AAC7B;AAEA,IAAIoB;AACFJ,iCAAWK,kBAAkB,SAAC1B,MAAAA;AAC5B,IAAIC,eACAD,KAAKK,eACPH,OAAOF,KAAKK,WAAW;EAE3B,CAAA;;MAEAa;",
|
|
5
|
-
"names": ["setColorScheme", "next", "isOverriden", "update", "getSystemColorScheme", "getColorScheme", "colorScheme", "onColorSchemeChange", "listener", "listeners", "add", "delete", "useColorScheme", "useState", "state", "setState", "useLayoutEffect", "useColorSchemeSetting", "getColorSchemeSetting", "getWebIsDarkMatcher", "window", "matchMedia", "Appearance", "Set", "forEach", "l", "process", "addChangeListener"]
|
|
6
|
-
}
|
package/dist/esm/colorScheme.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { useLayoutEffect, useState } from "react";
|
|
2
|
-
import "react-native";
|
|
3
|
-
function setColorScheme(next) {
|
|
4
|
-
isOverriden = next !== "system", update(next === "system" ? getSystemColorScheme() : next);
|
|
5
|
-
}
|
|
6
|
-
function getColorScheme() {
|
|
7
|
-
return colorScheme;
|
|
8
|
-
}
|
|
9
|
-
function onColorSchemeChange(listener) {
|
|
10
|
-
return listeners.add(listener), () => {
|
|
11
|
-
listeners.delete(listener);
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
function useColorScheme() {
|
|
15
|
-
const [state, setState] = useState(getColorScheme());
|
|
16
|
-
return useLayoutEffect(() => onColorSchemeChange(setState), []), [state, setColorScheme];
|
|
17
|
-
}
|
|
18
|
-
function useColorSchemeSetting() {
|
|
19
|
-
const [state, setState] = useState(getColorSchemeSetting());
|
|
20
|
-
return useLayoutEffect(() => onColorSchemeChange(() => setState(getColorSchemeSetting())), []), [state, setColorScheme];
|
|
21
|
-
}
|
|
22
|
-
const getColorSchemeSetting = () => isOverriden ? colorScheme : "system", getWebIsDarkMatcher = () => typeof window < "u" ? window.matchMedia?.("(prefers-color-scheme: dark)") : null;
|
|
23
|
-
function getSystemColorScheme() {
|
|
24
|
-
return getWebIsDarkMatcher()?.matches ? "dark" : "light";
|
|
25
|
-
}
|
|
26
|
-
let isOverriden = !1, colorScheme = getSystemColorScheme();
|
|
27
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
28
|
-
function update(next) {
|
|
29
|
-
next !== colorScheme && (colorScheme = next, listeners.forEach((l) => l(colorScheme)));
|
|
30
|
-
}
|
|
31
|
-
getWebIsDarkMatcher()?.addEventListener("change", (val) => {
|
|
32
|
-
isOverriden || update(getSystemColorScheme());
|
|
33
|
-
});
|
|
34
|
-
export {
|
|
35
|
-
getColorScheme,
|
|
36
|
-
onColorSchemeChange,
|
|
37
|
-
setColorScheme,
|
|
38
|
-
useColorScheme,
|
|
39
|
-
useColorSchemeSetting
|
|
40
|
-
};
|
|
41
|
-
//# sourceMappingURL=colorScheme.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/colorScheme.ts"],
|
|
4
|
-
"mappings": "AAKA,SAAS,iBAAiB,gBAAgB;AAC1C,OAA2B;AAMpB,SAAS,eAAe,MAA0B;AACvD,gBAAc,SAAS,UACvB,OAAO,SAAS,WAAW,qBAAqB,IAAI,IAAI;AAC1D;AAEO,SAAS,iBAAkC;AAChD,SAAO;AACT;AAEO,SAAS,oBAAoB,UAA+B;AACjE,mBAAU,IAAI,QAAQ,GACf,MAAM;AACX,cAAU,OAAO,QAAQ;AAAA,EAC3B;AACF;AAEO,SAAS,iBAAiB;AAC/B,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAS,eAAe,CAAC;AAEnD,yBAAgB,MACP,oBAAoB,QAAQ,GAClC,CAAC,CAAC,GAEE,CAAC,OAAO,cAAc;AAC/B;AAEO,SAAS,wBAAwB;AACtC,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAS,sBAAsB,CAAC;AAE1D,yBAAgB,MACP,oBAAoB,MAAM,SAAS,sBAAsB,CAAC,CAAC,GACjE,CAAC,CAAC,GAEE,CAAC,OAAO,cAAc;AAC/B;AAIA,MAAM,wBAAwB,MACxB,cACK,cAEF,UAGH,sBAAsB,MAC1B,OAAO,SAAW,MAAc,OAAO,aAAa,8BAA8B,IAAI;AAExF,SAAS,uBAAuB;AAI9B,SAAO,oBAAoB,GAAG,UAAU,SAAS;AACnD;AAEA,IAAI,cAAc,IACd,cAA+B,qBAAqB;AAExD,MAAM,YAAY,oBAAI,IAAyB;AAE/C,SAAS,OAAO,MAAuB;AACrC,EAAI,SAAS,gBACb,cAAc,MAId,UAAU,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;AACzC;AAUE,oBAAoB,GAAG,iBAAiB,UAAU,CAAC,QAAQ;AACzD,EAAI,eACJ,OAAO,qBAAqB,CAAC;AAC/B,CAAC;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|
package/dist/esm/colorScheme.mjs
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { useLayoutEffect, useState } from "react";
|
|
2
|
-
import "react-native";
|
|
3
|
-
function setColorScheme(next) {
|
|
4
|
-
isOverriden = next !== "system", update(next === "system" ? getSystemColorScheme() : next);
|
|
5
|
-
}
|
|
6
|
-
function getColorScheme() {
|
|
7
|
-
return colorScheme;
|
|
8
|
-
}
|
|
9
|
-
function onColorSchemeChange(listener) {
|
|
10
|
-
return listeners.add(listener), () => {
|
|
11
|
-
listeners.delete(listener);
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
function useColorScheme() {
|
|
15
|
-
const [state, setState] = useState(getColorScheme());
|
|
16
|
-
return useLayoutEffect(() => onColorSchemeChange(setState), []), [state, setColorScheme];
|
|
17
|
-
}
|
|
18
|
-
function useColorSchemeSetting() {
|
|
19
|
-
const [state, setState] = useState(getColorSchemeSetting());
|
|
20
|
-
return useLayoutEffect(() => onColorSchemeChange(() => setState(getColorSchemeSetting())), []), [state, setColorScheme];
|
|
21
|
-
}
|
|
22
|
-
const getColorSchemeSetting = () => isOverriden ? colorScheme : "system",
|
|
23
|
-
getWebIsDarkMatcher = () => typeof window < "u" ? window.matchMedia?.("(prefers-color-scheme: dark)") : null;
|
|
24
|
-
function getSystemColorScheme() {
|
|
25
|
-
return getWebIsDarkMatcher()?.matches ? "dark" : "light";
|
|
26
|
-
}
|
|
27
|
-
let isOverriden = !1,
|
|
28
|
-
colorScheme = getSystemColorScheme();
|
|
29
|
-
const listeners = /* @__PURE__ */new Set();
|
|
30
|
-
function update(next) {
|
|
31
|
-
next !== colorScheme && (colorScheme = next, listeners.forEach(l => l(colorScheme)));
|
|
32
|
-
}
|
|
33
|
-
getWebIsDarkMatcher()?.addEventListener("change", val => {
|
|
34
|
-
isOverriden || update(getSystemColorScheme());
|
|
35
|
-
});
|
|
36
|
-
export { getColorScheme, onColorSchemeChange, setColorScheme, useColorScheme, useColorSchemeSetting };
|
|
37
|
-
//# sourceMappingURL=colorScheme.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useLayoutEffect","useState","setColorScheme","next","isOverriden","update","getSystemColorScheme","getColorScheme","colorScheme","onColorSchemeChange","listener","listeners","add","delete","useColorScheme","state","setState","useColorSchemeSetting","getColorSchemeSetting","getWebIsDarkMatcher","window","matchMedia","matches","Set","forEach","l","addEventListener","val"],"sources":["../../src/colorScheme.ts"],"sourcesContent":[null],"mappings":"AAKA,SAASA,eAAA,EAAiBC,QAAA,QAAgB;AAC1C,OAA2B;AAMpB,SAASC,eAAeC,IAAA,EAA0B;EACvDC,WAAA,GAAcD,IAA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A,CAAA,CAAEjB,WAAW,CAAC;AACzC;AAUEW,mBAAA,CAAoB,GAAGO,gBAAA,CAAiB,UAAWC,GAAA,IAAQ;EACrDvB,WAAA,IACJC,MAAA,CAAOC,oBAAA,CAAqB,CAAC;AAC/B,CAAC","ignoreList":[]}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { useLayoutEffect, useState } from "react";
|
|
2
|
-
import { Appearance } from "react-native";
|
|
3
|
-
function _array_like_to_array(arr, len) {
|
|
4
|
-
(len == null || len > arr.length) && (len = arr.length);
|
|
5
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
6
|
-
return arr2;
|
|
7
|
-
}
|
|
8
|
-
function _array_with_holes(arr) {
|
|
9
|
-
if (Array.isArray(arr)) return arr;
|
|
10
|
-
}
|
|
11
|
-
function _iterable_to_array_limit(arr, i) {
|
|
12
|
-
var _i = arr == null ? null : typeof Symbol < "u" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
13
|
-
if (_i != null) {
|
|
14
|
-
var _arr = [], _n = !0, _d = !1, _s, _e;
|
|
15
|
-
try {
|
|
16
|
-
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done) && (_arr.push(_s.value), !(i && _arr.length === i)); _n = !0)
|
|
17
|
-
;
|
|
18
|
-
} catch (err) {
|
|
19
|
-
_d = !0, _e = err;
|
|
20
|
-
} finally {
|
|
21
|
-
try {
|
|
22
|
-
!_n && _i.return != null && _i.return();
|
|
23
|
-
} finally {
|
|
24
|
-
if (_d) throw _e;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return _arr;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
function _non_iterable_rest() {
|
|
31
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
32
|
-
}
|
|
33
|
-
function _sliced_to_array(arr, i) {
|
|
34
|
-
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
35
|
-
}
|
|
36
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
37
|
-
if (o) {
|
|
38
|
-
if (typeof o == "string") return _array_like_to_array(o, minLen);
|
|
39
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
40
|
-
if (n === "Object" && o.constructor && (n = o.constructor.name), n === "Map" || n === "Set") return Array.from(n);
|
|
41
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
function setColorScheme(next) {
|
|
45
|
-
isOverriden = next !== "system", update(next === "system" ? getSystemColorScheme() : next);
|
|
46
|
-
}
|
|
47
|
-
function getColorScheme() {
|
|
48
|
-
return colorScheme;
|
|
49
|
-
}
|
|
50
|
-
function onColorSchemeChange(listener) {
|
|
51
|
-
return listeners.add(listener), function() {
|
|
52
|
-
listeners.delete(listener);
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
function useColorScheme() {
|
|
56
|
-
var _useState = _sliced_to_array(useState(getColorScheme()), 2), state = _useState[0], setState = _useState[1];
|
|
57
|
-
return useLayoutEffect(function() {
|
|
58
|
-
return onColorSchemeChange(setState);
|
|
59
|
-
}, []), [
|
|
60
|
-
state,
|
|
61
|
-
setColorScheme
|
|
62
|
-
];
|
|
63
|
-
}
|
|
64
|
-
function useColorSchemeSetting() {
|
|
65
|
-
var _useState = _sliced_to_array(useState(getColorSchemeSetting()), 2), state = _useState[0], setState = _useState[1];
|
|
66
|
-
return useLayoutEffect(function() {
|
|
67
|
-
return onColorSchemeChange(function() {
|
|
68
|
-
return setState(getColorSchemeSetting());
|
|
69
|
-
});
|
|
70
|
-
}, []), [
|
|
71
|
-
state,
|
|
72
|
-
setColorScheme
|
|
73
|
-
];
|
|
74
|
-
}
|
|
75
|
-
var getColorSchemeSetting = function() {
|
|
76
|
-
return isOverriden ? colorScheme : "system";
|
|
77
|
-
}, getWebIsDarkMatcher = function() {
|
|
78
|
-
var _window_matchMedia, _window;
|
|
79
|
-
return typeof window < "u" ? (_window_matchMedia = (_window = window).matchMedia) === null || _window_matchMedia === void 0 ? void 0 : _window_matchMedia.call(_window, "(prefers-color-scheme: dark)") : null;
|
|
80
|
-
};
|
|
81
|
-
function getSystemColorScheme() {
|
|
82
|
-
var _getWebIsDarkMatcher;
|
|
83
|
-
return Appearance.getColorScheme() || "light";
|
|
84
|
-
}
|
|
85
|
-
var isOverriden = !1, colorScheme = getSystemColorScheme(), listeners = /* @__PURE__ */ new Set();
|
|
86
|
-
function update(next) {
|
|
87
|
-
next !== colorScheme && (colorScheme = next, Appearance.setColorScheme(next), listeners.forEach(function(l) {
|
|
88
|
-
return l(colorScheme);
|
|
89
|
-
}));
|
|
90
|
-
}
|
|
91
|
-
if (1)
|
|
92
|
-
Appearance.addChangeListener(function(next) {
|
|
93
|
-
isOverriden || next.colorScheme && update(next.colorScheme);
|
|
94
|
-
});
|
|
95
|
-
else
|
|
96
|
-
var _getWebIsDarkMatcher;
|
|
97
|
-
export {
|
|
98
|
-
getColorScheme,
|
|
99
|
-
onColorSchemeChange,
|
|
100
|
-
setColorScheme,
|
|
101
|
-
useColorScheme,
|
|
102
|
-
useColorSchemeSetting
|
|
103
|
-
};
|
|
104
|
-
//# sourceMappingURL=colorScheme.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/Users/n8/vxrn/packages/universal-color-scheme/src/colorScheme.ts"],
|
|
4
|
-
"mappings": "AAKA,SAASA,iBAAiBC,gBAAgB;AAC1C,SAASC,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMpB,SAASC,eAAeC,MAAwB;AACrDC,gBAAcD,SAAS,UACvBE,OAAOF,SAAS,WAAWG,qBAAAA,IAAyBH,IAAA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B,aAAWyB,kBAAkB,SAACvB,MAAAA;AAC5B,IAAIC,eACAD,KAAKK,eACPH,OAAOF,KAAKK,WAAW;EAE3B,CAAA;;MAEAW;",
|
|
5
|
-
"names": ["useLayoutEffect", "useState", "Appearance", "setColorScheme", "next", "isOverriden", "update", "getSystemColorScheme", "getColorScheme", "colorScheme", "onColorSchemeChange", "listener", "listeners", "add", "delete", "useColorScheme", "state", "setState", "useColorSchemeSetting", "getColorSchemeSetting", "getWebIsDarkMatcher", "window", "matchMedia", "Set", "forEach", "l", "process", "addChangeListener"]
|
|
6
|
-
}
|