@vxrn/color-scheme 1.1.202

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Nate Wienert
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,85 @@
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 src_exports = {};
16
+ __export(src_exports, {
17
+ SchemeProvider: () => SchemeProvider,
18
+ getColorScheme: () => import_universal_color_scheme2.getColorScheme,
19
+ onColorSchemeChange: () => import_universal_color_scheme2.onColorSchemeChange,
20
+ setSchemeSetting: () => setSchemeSetting,
21
+ useColorScheme: () => useColorScheme,
22
+ useSchemeSetting: () => useSchemeSetting
23
+ });
24
+ module.exports = __toCommonJS(src_exports);
25
+ var import_universal_color_scheme = require("@vxrn/universal-color-scheme"), import_use_isomorphic_layout_effect = require("@vxrn/use-isomorphic-layout-effect"), import_react = require("react"), import_universal_color_scheme2 = require("@vxrn/universal-color-scheme"), import_jsx_runtime = require("react/jsx-runtime");
26
+ const storageKey = "vxrn-scheme", getSetting = () => typeof localStorage < "u" && localStorage.getItem(storageKey) || "system", setting = getSetting();
27
+ setting !== "system" && (0, import_universal_color_scheme.setColorScheme)(setting);
28
+ const SchemeContext = (0, import_react.createContext)({
29
+ setting: "system",
30
+ value: "light"
31
+ }), useColorScheme = () => {
32
+ const [state] = (0, import_universal_color_scheme.useColorScheme)();
33
+ return [state, setSchemeSetting];
34
+ };
35
+ function useSchemeSetting() {
36
+ return [(0, import_react.useContext)(SchemeContext), setSchemeSetting];
37
+ }
38
+ function setSchemeSetting(next) {
39
+ typeof localStorage < "u" && localStorage.setItem(storageKey, next), (0, import_universal_color_scheme.setColorScheme)(next);
40
+ }
41
+ function SchemeProvider({
42
+ children,
43
+ // defaults to tamagui-compatible
44
+ getClassName = (name) => `t_${name}`
45
+ }) {
46
+ const [colorSchemeSetting] = (0, import_universal_color_scheme.useColorSchemeSetting)(), [colorScheme] = useColorScheme();
47
+ return (0, import_use_isomorphic_layout_effect.useIsomorphicLayoutEffect)(() => {
48
+ const toAdd = getClassName(colorScheme), { classList } = document.documentElement;
49
+ if (!classList.contains(toAdd)) {
50
+ const toRemove = colorScheme === "light" ? "dark" : "light";
51
+ classList.remove(getClassName(toRemove)), classList.add(toAdd);
52
+ }
53
+ }, [colorScheme]), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
54
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
55
+ "script",
56
+ {
57
+ dangerouslySetInnerHTML: {
58
+ __html: `let d = document.documentElement.classList
59
+ d.remove('${getClassName("light")}')
60
+ d.remove('${getClassName("dark")}')
61
+ let e = localStorage.getItem('user-theme')
62
+ let t =
63
+ 'system' === e || !e
64
+ ? window.matchMedia('(prefers-color-scheme: dark)').matches
65
+ : e === 'dark'
66
+ t ? d.add('${getClassName("dark")}') : d.add('${getClassName("light")}')`
67
+ }
68
+ }
69
+ ),
70
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
71
+ SchemeContext.Provider,
72
+ {
73
+ value: (0, import_react.useMemo)(
74
+ () => ({
75
+ value: colorScheme,
76
+ setting: colorSchemeSetting
77
+ }),
78
+ [colorScheme, colorSchemeSetting]
79
+ ),
80
+ children
81
+ }
82
+ )
83
+ ] });
84
+ }
85
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.tsx"],
4
+ "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oCAKO,yCACP,sCAA0C,+CAC1C,eAAmD,kBAKnDA,iCAAoD,yCA6DhD;AA3DJ,MAAM,aAAa,eAEb,aAAa,MAChB,OAAO,eAAiB,OAAgB,aAAa,QAAQ,UAAU,KACxE,UAGI,UAAU,WAAW;AAEvB,YAAY,gBACd,8CAAe,OAAO;AAGxB,MAAM,oBAAgB,4BAGnB;AAAA,EACD,SAAS;AAAA,EACT,OAAO;AACT,CAAC,GAEY,iBAAiB,MAAM;AAClC,QAAM,CAAC,KAAK,QAA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+ 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 src_exports = {};
17
+ __export(src_exports, {
18
+ SchemeProvider: () => SchemeProvider,
19
+ getColorScheme: () => import_universal_color_scheme2.getColorScheme,
20
+ onColorSchemeChange: () => import_universal_color_scheme2.onColorSchemeChange,
21
+ setSchemeSetting: () => setSchemeSetting,
22
+ useColorScheme: () => useColorScheme,
23
+ useSchemeSetting: () => useSchemeSetting
24
+ });
25
+ module.exports = __toCommonJS(src_exports);
26
+ var import_jsx_runtime = require("react/jsx-runtime"), import_universal_color_scheme = require("@vxrn/universal-color-scheme"), import_use_isomorphic_layout_effect = require("@vxrn/use-isomorphic-layout-effect"), import_react = require("react"), import_universal_color_scheme2 = require("@vxrn/universal-color-scheme");
27
+ function _array_like_to_array(arr, len) {
28
+ (len == null || len > arr.length) && (len = arr.length);
29
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
30
+ return arr2;
31
+ }
32
+ function _array_with_holes(arr) {
33
+ if (Array.isArray(arr)) return arr;
34
+ }
35
+ function _iterable_to_array_limit(arr, i) {
36
+ var _i = arr == null ? null : typeof Symbol < "u" && arr[Symbol.iterator] || arr["@@iterator"];
37
+ if (_i != null) {
38
+ var _arr = [], _n = !0, _d = !1, _s, _e;
39
+ try {
40
+ for (_i = _i.call(arr); !(_n = (_s = _i.next()).done) && (_arr.push(_s.value), !(i && _arr.length === i)); _n = !0)
41
+ ;
42
+ } catch (err) {
43
+ _d = !0, _e = err;
44
+ } finally {
45
+ try {
46
+ !_n && _i.return != null && _i.return();
47
+ } finally {
48
+ if (_d) throw _e;
49
+ }
50
+ }
51
+ return _arr;
52
+ }
53
+ }
54
+ function _non_iterable_rest() {
55
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
56
+ }
57
+ function _sliced_to_array(arr, i) {
58
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
59
+ }
60
+ function _unsupported_iterable_to_array(o, minLen) {
61
+ if (o) {
62
+ if (typeof o == "string") return _array_like_to_array(o, minLen);
63
+ var n = Object.prototype.toString.call(o).slice(8, -1);
64
+ if (n === "Object" && o.constructor && (n = o.constructor.name), n === "Map" || n === "Set") return Array.from(n);
65
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
66
+ }
67
+ }
68
+ var storageKey = "vxrn-scheme", getSetting = function() {
69
+ return typeof localStorage < "u" && localStorage.getItem(storageKey) || "system";
70
+ }, setting = getSetting();
71
+ setting !== "system" && (0, import_universal_color_scheme.setColorScheme)(setting);
72
+ var SchemeContext = /* @__PURE__ */ (0, import_react.createContext)({
73
+ setting: "system",
74
+ value: "light"
75
+ }), useColorScheme = function() {
76
+ var _useColorSchemeBase = _sliced_to_array((0, import_universal_color_scheme.useColorScheme)(), 1), state = _useColorSchemeBase[0];
77
+ return [
78
+ state,
79
+ setSchemeSetting
80
+ ];
81
+ };
82
+ function useSchemeSetting() {
83
+ var values = (0, import_react.useContext)(SchemeContext);
84
+ return [
85
+ values,
86
+ setSchemeSetting
87
+ ];
88
+ }
89
+ function setSchemeSetting(next) {
90
+ typeof localStorage < "u" && localStorage.setItem(storageKey, next), (0, import_universal_color_scheme.setColorScheme)(next);
91
+ }
92
+ function SchemeProvider(param) {
93
+ var children = param.children, _param_getClassName = param.getClassName, getClassName = _param_getClassName === void 0 ? function(name) {
94
+ return "t_".concat(name);
95
+ } : _param_getClassName, _useColorSchemeSetting = _sliced_to_array((0, import_universal_color_scheme.useColorSchemeSetting)(), 1), colorSchemeSetting = _useColorSchemeSetting[0], _useColorScheme = _sliced_to_array(useColorScheme(), 1), colorScheme = _useColorScheme[0];
96
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
97
+ children: [
98
+ null,
99
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SchemeContext.Provider, {
100
+ value: (0, import_react.useMemo)(function() {
101
+ return {
102
+ value: colorScheme,
103
+ setting: colorSchemeSetting
104
+ };
105
+ }, [
106
+ colorScheme,
107
+ colorSchemeSetting
108
+ ]),
109
+ children
110
+ })
111
+ ]
112
+ });
113
+ }
114
+ // Annotate the CommonJS export names for ESM import in node:
115
+ 0 && (module.exports = {
116
+ SchemeProvider,
117
+ getColorScheme,
118
+ onColorSchemeChange,
119
+ setSchemeSetting,
120
+ useColorScheme,
121
+ useSchemeSetting
122
+ });
123
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/Users/n8/vxrn/packages/color-scheme/src/index.tsx"],
4
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;uDAAA,gCAKO,yCACP,sCAA0C,+CAC1C,eAAmD,kBAKnDA,iCAAoD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEpD,IAAMC,aAAa,eAEbC,aAAa,WAAA;SAChB,OAAOC,eAAiB,OAAgBA,aAAaC,QAAQH,UAAAA,KAC9D;GAGII,UAAUH,WAAAA;AAEZG,YAAY,gBACdC,8CAAeD,OAAAA;AAGjB,IAAME,gBAAgBC,gDAGnB;EACDH,SAAS;EACTI,OAAO;AACT,CAAA,GAEaC,iBAAiB,WAAA;AAC5B,MAAgBC,sBAAAA,qBAAAA,8BAAAA,gBAAAA,GAAAA,CAAAA,GAATC,QAASD,oBAAAA,CAAAA;AAChB,SAAO;IAACC;IAAOC;;AACjB;AAEO,SAASC,mBAAAA;AACd,MAAMC,aAASC,yBAAWT,aAAAA;AAC1B,SAAO;IAACQ;IAAQF;;AAClB;AAEO,SAASA,iBAAiBI,MAAmB;AAClD,EAAI,OAAOd,eAAiB,OAC1BA,aAAae,QAAQjB,YAAYgB,IAAAA,OAEnCX,8CAAeW,IAAAA;AACjB;AAEO,SAASE,eAAe,OAIuC;MAHpEC,WAD6B,MAC7BA,UAAAA,sBAD6B,MAG7BC,cAAAA,eAAAA,wBAAAA,SAAe,SAACC,MAAAA;WAAU,KAAS,OAALA,IAAAA;2BAEDC,yBAAAA,qBAAAA,qDAAAA,GAAAA,CAAAA,GAAtBC,qBAAsBD,uBAAAA,CAAAA,GACPb,kBAAAA,iBAAAA,eAAAA,GAAAA,CAAAA,GAAfe,cAAef,gBAAAA,CAAAA;AActB,SACE,uCAAAgB,MAAA,mBAAAC,UAAA;;MAC6C;MAe3C,uCAAAC,KAACrB,cAAcsB,UAAQ;QACrBpB,WAAOqB,sBACL,WAAA;iBAAO;YACLrB,OAAOgB;YACPpB,SAASmB;UACX;WACA;UAACC;UAAaD;SAAmB;;;;;AAO3C;",
5
+ "names": ["import_universal_color_scheme", "storageKey", "getSetting", "localStorage", "getItem", "setting", "setColorScheme", "SchemeContext", "createContext", "value", "useColorScheme", "useColorSchemeBase", "state", "setSchemeSetting", "useSchemeSetting", "values", "useContext", "next", "setItem", "SchemeProvider", "children", "getClassName", "name", "useColorSchemeSetting", "colorSchemeSetting", "colorScheme", "_jsxs", "_Fragment", "_jsx", "Provider", "useMemo"]
6
+ }
@@ -0,0 +1,14 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from == "object" || typeof from == "function")
7
+ for (let key of __getOwnPropNames(from))
8
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
9
+ return to;
10
+ };
11
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
12
+ var types_exports = {};
13
+ module.exports = __toCommonJS(types_exports);
14
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/types.ts"],
4
+ "mappings": ";;;;;;;;;;;AAAA;AAAA;",
5
+ "names": []
6
+ }
@@ -0,0 +1,15 @@
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 __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from == "object" || typeof from == "function")
8
+ for (let key of __getOwnPropNames(from))
9
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ return to;
11
+ };
12
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
13
+ var types_exports = {};
14
+ module.exports = __toCommonJS(types_exports);
15
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/Users/n8/tamagui/code/packages/one-theme/src/types.ts"],
4
+ "mappings": ";;;;;;;;;;;;AACA;;",
5
+ "names": []
6
+ }
@@ -0,0 +1,36 @@
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 useSystemTheme_exports = {};
16
+ __export(useSystemTheme_exports, {
17
+ useSystemTheme: () => useSystemTheme
18
+ });
19
+ module.exports = __toCommonJS(useSystemTheme_exports);
20
+ var import_use_did_finish_ssr = require("@tamagui/use-did-finish-ssr"), import_react = require("react");
21
+ const media = typeof window < "u" && window.matchMedia ? window.matchMedia("(prefers-color-scheme: dark)") : null;
22
+ function getSystemTheme() {
23
+ return media?.matches ? "dark" : "light";
24
+ }
25
+ function useSystemTheme() {
26
+ const [systemTheme, setSystemTheme] = (0, import_react.useState)(() => getSystemTheme()), didHydrate = (0, import_use_did_finish_ssr.useDidFinishSSR)();
27
+ return (0, import_react.useEffect)(() => {
28
+ const onChange = () => {
29
+ setSystemTheme(getSystemTheme());
30
+ };
31
+ return media?.addEventListener("change", onChange), () => {
32
+ media?.removeEventListener("change", onChange);
33
+ };
34
+ }, []), didHydrate ? systemTheme : "light";
35
+ }
36
+ //# sourceMappingURL=useSystemTheme.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/useSystemTheme.tsx"],
4
+ "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCAAgC,wCAChC,eAAoC;AAGpC,MAAM,QACJ,OAAO,SAAW,OAAe,OAAO,aACpC,OAAO,WAAW,8BAA8B,IAChD;AAEN,SAAS,iBAAiB;AACxB,SAAO,OAAO,UAAU,SAAS;AACnC;AAEO,SAAS,iBAAiB;AAC/B,QAAM,CAAC,aAAa,cAAc,QAAI,uBAAiB,MAAM,eAAe,CAAC,GACvE,iBAAa,2CAAgB;AAYnC,aAVA,wBAAU,MAAM;AACd,UAAM,WAAW,MAAM;AACrB,qBAAe,eAAe,CAAC;AAAA,IACjC;AACA,kBAAO,iBAAiB,UAAU,QAAQ,GACnC,MAAM;AACX,aAAO,oBAAoB,UAAU,QAAQ;AAAA,IAC/C;AAAA,EACF,GAAG,CAAC,CAAC,GAEA,aAIE,cAHE;AAIX;",
5
+ "names": []
6
+ }
@@ -0,0 +1,78 @@
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 useSystemTheme_native_exports = {};
17
+ __export(useSystemTheme_native_exports, {
18
+ useSystemTheme: () => useSystemTheme
19
+ });
20
+ module.exports = __toCommonJS(useSystemTheme_native_exports);
21
+ var import_react = require("react"), import_react_native = require("react-native");
22
+ function _array_like_to_array(arr, len) {
23
+ (len == null || len > arr.length) && (len = arr.length);
24
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
25
+ return arr2;
26
+ }
27
+ function _array_with_holes(arr) {
28
+ if (Array.isArray(arr)) return arr;
29
+ }
30
+ function _iterable_to_array_limit(arr, i) {
31
+ var _i = arr == null ? null : typeof Symbol < "u" && arr[Symbol.iterator] || arr["@@iterator"];
32
+ if (_i != null) {
33
+ var _arr = [], _n = !0, _d = !1, _s, _e;
34
+ try {
35
+ for (_i = _i.call(arr); !(_n = (_s = _i.next()).done) && (_arr.push(_s.value), !(i && _arr.length === i)); _n = !0)
36
+ ;
37
+ } catch (err) {
38
+ _d = !0, _e = err;
39
+ } finally {
40
+ try {
41
+ !_n && _i.return != null && _i.return();
42
+ } finally {
43
+ if (_d) throw _e;
44
+ }
45
+ }
46
+ return _arr;
47
+ }
48
+ }
49
+ function _non_iterable_rest() {
50
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
51
+ }
52
+ function _sliced_to_array(arr, i) {
53
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
54
+ }
55
+ function _unsupported_iterable_to_array(o, minLen) {
56
+ if (o) {
57
+ if (typeof o == "string") return _array_like_to_array(o, minLen);
58
+ var n = Object.prototype.toString.call(o).slice(8, -1);
59
+ if (n === "Object" && o.constructor && (n = o.constructor.name), n === "Map" || n === "Set") return Array.from(n);
60
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
61
+ }
62
+ }
63
+ function useSystemTheme() {
64
+ var _useState = _sliced_to_array((0, import_react.useState)(import_react_native.Appearance.getColorScheme() || "light"), 2), scheme = _useState[0], setScheme = _useState[1];
65
+ return (0, import_react.useEffect)(function() {
66
+ var listener = import_react_native.Appearance.addChangeListener(function(next) {
67
+ setScheme(next.colorScheme || "light");
68
+ });
69
+ return function() {
70
+ listener.remove();
71
+ };
72
+ }, []), scheme;
73
+ }
74
+ // Annotate the CommonJS export names for ESM import in node:
75
+ 0 && (module.exports = {
76
+ useSystemTheme
77
+ });
78
+ //# sourceMappingURL=useSystemTheme.native.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/Users/n8/tamagui/code/packages/one-theme/src/useSystemTheme.native.tsx"],
4
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA,mBAAoC,kBACpC,sBAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGpB,SAASA,iBAAAA;AACd,MAA4BC,YAAAA,qBAAAA,uBAASC,+BAAWC,eAAc,KAAM,OAAA,GAAA,CAAA,GAA7DC,SAAqBH,UAAAA,CAAAA,GAAbI,YAAaJ,UAAAA,CAAAA;AAE5BK,qCAAU,WAAA;AACR,QAAMC,WAAWL,+BAAWM,kBAAkB,SAACC,MAAAA;AAC7CJ,gBAAUI,KAAKC,eAAe,OAAA;IAChC,CAAA;AAEA,WAAO,WAAA;AACLH,eAASI,OAAM;IACjB;EACF,GAAG,CAAA,CAAE,GAEEP;AACT;",
5
+ "names": ["useSystemTheme", "useState", "Appearance", "getColorScheme", "scheme", "setScheme", "useEffect", "listener", "addChangeListener", "next", "colorScheme", "remove"]
6
+ }
@@ -0,0 +1,77 @@
1
+ import {
2
+ setColorScheme,
3
+ useColorScheme as useColorSchemeBase,
4
+ useColorSchemeSetting
5
+ } from "@vxrn/universal-color-scheme";
6
+ import { useIsomorphicLayoutEffect } from "@vxrn/use-isomorphic-layout-effect";
7
+ import { createContext, useContext, useMemo } from "react";
8
+ import { getColorScheme, onColorSchemeChange } from "@vxrn/universal-color-scheme";
9
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
10
+ const storageKey = "vxrn-scheme", getSetting = () => typeof localStorage < "u" && localStorage.getItem(storageKey) || "system", setting = getSetting();
11
+ setting !== "system" && setColorScheme(setting);
12
+ const SchemeContext = createContext({
13
+ setting: "system",
14
+ value: "light"
15
+ }), useColorScheme = () => {
16
+ const [state] = useColorSchemeBase();
17
+ return [state, setSchemeSetting];
18
+ };
19
+ function useSchemeSetting() {
20
+ return [useContext(SchemeContext), setSchemeSetting];
21
+ }
22
+ function setSchemeSetting(next) {
23
+ typeof localStorage < "u" && localStorage.setItem(storageKey, next), setColorScheme(next);
24
+ }
25
+ function SchemeProvider({
26
+ children,
27
+ // defaults to tamagui-compatible
28
+ getClassName = (name) => `t_${name}`
29
+ }) {
30
+ const [colorSchemeSetting] = useColorSchemeSetting(), [colorScheme] = useColorScheme();
31
+ return useIsomorphicLayoutEffect(() => {
32
+ const toAdd = getClassName(colorScheme), { classList } = document.documentElement;
33
+ if (!classList.contains(toAdd)) {
34
+ const toRemove = colorScheme === "light" ? "dark" : "light";
35
+ classList.remove(getClassName(toRemove)), classList.add(toAdd);
36
+ }
37
+ }, [colorScheme]), /* @__PURE__ */ jsxs(Fragment, { children: [
38
+ /* @__PURE__ */ jsx(
39
+ "script",
40
+ {
41
+ dangerouslySetInnerHTML: {
42
+ __html: `let d = document.documentElement.classList
43
+ d.remove('${getClassName("light")}')
44
+ d.remove('${getClassName("dark")}')
45
+ let e = localStorage.getItem('user-theme')
46
+ let t =
47
+ 'system' === e || !e
48
+ ? window.matchMedia('(prefers-color-scheme: dark)').matches
49
+ : e === 'dark'
50
+ t ? d.add('${getClassName("dark")}') : d.add('${getClassName("light")}')`
51
+ }
52
+ }
53
+ ),
54
+ /* @__PURE__ */ jsx(
55
+ SchemeContext.Provider,
56
+ {
57
+ value: useMemo(
58
+ () => ({
59
+ value: colorScheme,
60
+ setting: colorSchemeSetting
61
+ }),
62
+ [colorScheme, colorSchemeSetting]
63
+ ),
64
+ children
65
+ }
66
+ )
67
+ ] });
68
+ }
69
+ export {
70
+ SchemeProvider,
71
+ getColorScheme,
72
+ onColorSchemeChange,
73
+ setSchemeSetting,
74
+ useColorScheme,
75
+ useSchemeSetting
76
+ };
77
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["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BACrB,aAAa,MAAM,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAMnB,aAAa,MAAM,CAAC,eAAe,aAAa,OAAO,CAAC;AAAA,QACrE;AAAA;AAAA,IACF;AAAA,IAEF;AAAA,MAAC,cAAc;AAAA,MAAd;AAAA,QACC,OAAO;AAAA,UACL,OAAO;AAAA,YACL,OAAO;AAAA,YACP,SAAS;AAAA,UACX;AAAA,UACA,CAAC,aAAa,kBAAkB;AAAA,QAClC;AAAA,QAEC;AAAA;AAAA,IACH;AAAA,KACF;AAEJ;",
5
+ "names": []
6
+ }
@@ -0,0 +1,63 @@
1
+ import { setColorScheme, useColorScheme as useColorSchemeBase, useColorSchemeSetting } from "@vxrn/universal-color-scheme";
2
+ import { useIsomorphicLayoutEffect } from "@vxrn/use-isomorphic-layout-effect";
3
+ import { createContext, useContext, useMemo } from "react";
4
+ import { getColorScheme, onColorSchemeChange } from "@vxrn/universal-color-scheme";
5
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
+ const storageKey = "vxrn-scheme",
7
+ getSetting = () => typeof localStorage < "u" && localStorage.getItem(storageKey) || "system",
8
+ setting = getSetting();
9
+ setting !== "system" && setColorScheme(setting);
10
+ const SchemeContext = createContext({
11
+ setting: "system",
12
+ value: "light"
13
+ }),
14
+ useColorScheme = () => {
15
+ const [state] = useColorSchemeBase();
16
+ return [state, setSchemeSetting];
17
+ };
18
+ function useSchemeSetting() {
19
+ return [useContext(SchemeContext), setSchemeSetting];
20
+ }
21
+ function setSchemeSetting(next) {
22
+ typeof localStorage < "u" && localStorage.setItem(storageKey, next), setColorScheme(next);
23
+ }
24
+ function SchemeProvider({
25
+ children,
26
+ // defaults to tamagui-compatible
27
+ getClassName = name => `t_${name}`
28
+ }) {
29
+ const [colorSchemeSetting] = useColorSchemeSetting(),
30
+ [colorScheme] = useColorScheme();
31
+ return useIsomorphicLayoutEffect(() => {
32
+ const toAdd = getClassName(colorScheme),
33
+ {
34
+ classList
35
+ } = document.documentElement;
36
+ if (!classList.contains(toAdd)) {
37
+ const toRemove = colorScheme === "light" ? "dark" : "light";
38
+ classList.remove(getClassName(toRemove)), classList.add(toAdd);
39
+ }
40
+ }, [colorScheme]), /* @__PURE__ */jsxs(Fragment, {
41
+ children: [/* @__PURE__ */jsx("script", {
42
+ dangerouslySetInnerHTML: {
43
+ __html: `let d = document.documentElement.classList
44
+ d.remove('${getClassName("light")}')
45
+ d.remove('${getClassName("dark")}')
46
+ let e = localStorage.getItem('user-theme')
47
+ let t =
48
+ 'system' === e || !e
49
+ ? window.matchMedia('(prefers-color-scheme: dark)').matches
50
+ : e === 'dark'
51
+ t ? d.add('${getClassName("dark")}') : d.add('${getClassName("light")}')`
52
+ }
53
+ }), /* @__PURE__ */jsx(SchemeContext.Provider, {
54
+ value: useMemo(() => ({
55
+ value: colorScheme,
56
+ setting: colorSchemeSetting
57
+ }), [colorScheme, colorSchemeSetting]),
58
+ children
59
+ })]
60
+ });
61
+ }
62
+ export { SchemeProvider, getColorScheme, onColorSchemeChange, setSchemeSetting, useColorScheme, useSchemeSetting };
63
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["setColorScheme","useColorScheme","useColorSchemeBase","useColorSchemeSetting","useIsomorphicLayoutEffect","createContext","useContext","useMemo","getColorScheme","onColorSchemeChange","Fragment","jsx","jsxs","storageKey","getSetting","localStorage","getItem","setting","SchemeContext","value","state","setSchemeSetting","useSchemeSetting","next","setItem","SchemeProvider","children","getClassName","name","colorSchemeSetting","colorScheme","toAdd","classList","document","documentElement","contains","toRemove","remove","add","dangerouslySetInnerHTML","__html","Provider"],"sources":["../../src/index.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAEEA,cAAA,EACAC,cAAA,IAAkBC,kBAAA,EAClBC,qBAAA,QACK;AACP,SAASC,yBAAA,QAAiC;AAC1C,SAASC,aAAA,EAAeC,UAAA,EAAYC,OAAA,QAAe;AAKnD,SAASC,cAAA,EAAgBC,mBAA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M,GAAA,CAAIP,KAAK;IACrB;EACF,GAAG,CAACD,WAAW,CAAC,GAIhB,eAAAlB,IAAA,CAAAF,QAAA;IAEIgB,QAAA,kBAAAf,GAAA,CAAC;MACC4B,uBAAA,EAAyB;QACvBC,MAAA,EAAQ;AAAA,sBACEb,YAAA,CAAa,OAAO,CAAC;AAAA,sBACrBA,YAAA,CAAa,MAAM,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAMnBA,YAAA,CAAa,MAAM,CAAC,eAAeA,YAAA,CAAa,OAAO,CAAC;MACrE;IAAA,CACF,GAEF,eAAAhB,GAAA,CAACO,aAAA,CAAcuB,QAAA,EAAd;MACCtB,KAAA,EAAOZ,OAAA,CACL,OAAO;QACLY,KAAA,EAAOW,WAAA;QACPb,OAAA,EAASY;MACX,IACA,CAACC,WAAA,EAAaD,kBAAkB,CAClC;MAECH;IAAA,CACH;EAAA,CACF;AAEJ","ignoreList":[]}
@@ -0,0 +1,101 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { setColorScheme, useColorScheme as useColorSchemeBase, useColorSchemeSetting } from "@vxrn/universal-color-scheme";
3
+ import "@vxrn/use-isomorphic-layout-effect";
4
+ import { createContext, useContext, useMemo } from "react";
5
+ import { getColorScheme, onColorSchemeChange } from "@vxrn/universal-color-scheme";
6
+ function _array_like_to_array(arr, len) {
7
+ (len == null || len > arr.length) && (len = arr.length);
8
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
9
+ return arr2;
10
+ }
11
+ function _array_with_holes(arr) {
12
+ if (Array.isArray(arr)) return arr;
13
+ }
14
+ function _iterable_to_array_limit(arr, i) {
15
+ var _i = arr == null ? null : typeof Symbol < "u" && arr[Symbol.iterator] || arr["@@iterator"];
16
+ if (_i != null) {
17
+ var _arr = [], _n = !0, _d = !1, _s, _e;
18
+ try {
19
+ for (_i = _i.call(arr); !(_n = (_s = _i.next()).done) && (_arr.push(_s.value), !(i && _arr.length === i)); _n = !0)
20
+ ;
21
+ } catch (err) {
22
+ _d = !0, _e = err;
23
+ } finally {
24
+ try {
25
+ !_n && _i.return != null && _i.return();
26
+ } finally {
27
+ if (_d) throw _e;
28
+ }
29
+ }
30
+ return _arr;
31
+ }
32
+ }
33
+ function _non_iterable_rest() {
34
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
35
+ }
36
+ function _sliced_to_array(arr, i) {
37
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
38
+ }
39
+ function _unsupported_iterable_to_array(o, minLen) {
40
+ if (o) {
41
+ if (typeof o == "string") return _array_like_to_array(o, minLen);
42
+ var n = Object.prototype.toString.call(o).slice(8, -1);
43
+ if (n === "Object" && o.constructor && (n = o.constructor.name), n === "Map" || n === "Set") return Array.from(n);
44
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
45
+ }
46
+ }
47
+ var storageKey = "vxrn-scheme", getSetting = function() {
48
+ return typeof localStorage < "u" && localStorage.getItem(storageKey) || "system";
49
+ }, setting = getSetting();
50
+ setting !== "system" && setColorScheme(setting);
51
+ var SchemeContext = /* @__PURE__ */ createContext({
52
+ setting: "system",
53
+ value: "light"
54
+ }), useColorScheme = function() {
55
+ var _useColorSchemeBase = _sliced_to_array(useColorSchemeBase(), 1), state = _useColorSchemeBase[0];
56
+ return [
57
+ state,
58
+ setSchemeSetting
59
+ ];
60
+ };
61
+ function useSchemeSetting() {
62
+ var values = useContext(SchemeContext);
63
+ return [
64
+ values,
65
+ setSchemeSetting
66
+ ];
67
+ }
68
+ function setSchemeSetting(next) {
69
+ typeof localStorage < "u" && localStorage.setItem(storageKey, next), setColorScheme(next);
70
+ }
71
+ function SchemeProvider(param) {
72
+ var children = param.children, _param_getClassName = param.getClassName, getClassName = _param_getClassName === void 0 ? function(name) {
73
+ return "t_".concat(name);
74
+ } : _param_getClassName, _useColorSchemeSetting = _sliced_to_array(useColorSchemeSetting(), 1), colorSchemeSetting = _useColorSchemeSetting[0], _useColorScheme = _sliced_to_array(useColorScheme(), 1), colorScheme = _useColorScheme[0];
75
+ return /* @__PURE__ */ _jsxs(_Fragment, {
76
+ children: [
77
+ null,
78
+ /* @__PURE__ */ _jsx(SchemeContext.Provider, {
79
+ value: useMemo(function() {
80
+ return {
81
+ value: colorScheme,
82
+ setting: colorSchemeSetting
83
+ };
84
+ }, [
85
+ colorScheme,
86
+ colorSchemeSetting
87
+ ]),
88
+ children
89
+ })
90
+ ]
91
+ });
92
+ }
93
+ export {
94
+ SchemeProvider,
95
+ getColorScheme,
96
+ onColorSchemeChange,
97
+ setSchemeSetting,
98
+ useColorScheme,
99
+ useSchemeSetting
100
+ };
101
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/Users/n8/vxrn/packages/color-scheme/src/index.tsx"],
4
+ "mappings": ";AAAA,SAEEA,gBACAC,kBAAkBC,oBAClBC,6BACK;AACP,OAA0C;AAC1C,SAASC,eAAeC,YAAYC,eAAe;AAKnD,SAASC,gBAAgBC,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEpD,IAAMC,aAAa,eAEbC,aAAa,WAAA;SAChB,OAAOC,eAAiB,OAAgBA,aAAaC,QAAQH,UAAAA,KAC9D;GAGII,UAAUH,WAAAA;AAEZG,YAAY,YACdb,eAAea,OAAAA;AAGjB,IAAMC,gBAAgBV,8BAGnB;EACDS,SAAS;EACTE,OAAO;AACT,CAAA,GAEad,iBAAiB,WAAA;AAC5B,MAAgBC,sBAAAA,iBAAAA,mBAAAA,GAAAA,CAAAA,GAATc,QAASd,oBAAAA,CAAAA;AAChB,SAAO;IAACc;IAAOC;;AACjB;AAEO,SAASC,mBAAAA;AACd,MAAMC,SAASd,WAAWS,aAAAA;AAC1B,SAAO;IAACK;IAAQF;;AAClB;AAEO,SAASA,iBAAiBG,MAAmB;AAClD,EAAI,OAAOT,eAAiB,OAC1BA,aAAaU,QAAQZ,YAAYW,IAAAA,GAEnCpB,eAAeoB,IAAAA;AACjB;AAEO,SAASE,eAAe,OAIuC;MAHpEC,WAD6B,MAC7BA,UAAAA,sBAD6B,MAG7BC,cAAAA,eAAAA,wBAAAA,SAAe,SAACC,MAAAA;WAAU,KAAS,OAALA,IAAAA;2BAEDtB,yBAAAA,iBAAAA,sBAAAA,GAAAA,CAAAA,GAAtBuB,qBAAsBvB,uBAAAA,CAAAA,GACPF,kBAAAA,iBAAAA,eAAAA,GAAAA,CAAAA,GAAf0B,cAAe1B,gBAAAA,CAAAA;AActB,SACE,sBAAA,WAAA;;MAC6C;MAe3C,qBAACa,cAAcc,UAAQ;QACrBb,OAAOT,QACL,WAAA;iBAAO;YACLS,OAAOY;YACPd,SAASa;UACX;WACA;UAACC;UAAaD;SAAmB;;;;;AAO3C;",
5
+ "names": ["setColorScheme", "useColorScheme", "useColorSchemeBase", "useColorSchemeSetting", "createContext", "useContext", "useMemo", "getColorScheme", "onColorSchemeChange", "storageKey", "getSetting", "localStorage", "getItem", "setting", "SchemeContext", "value", "state", "setSchemeSetting", "useSchemeSetting", "values", "next", "setItem", "SchemeProvider", "children", "getClassName", "name", "colorSchemeSetting", "colorScheme", "Provider"]
6
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "mappings": "",
5
+ "names": []
6
+ }
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":[],"sourcesContent":[],"mappings":"","ignoreList":[]}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "mappings": "",
5
+ "names": []
6
+ }
@@ -0,0 +1,21 @@
1
+ import { useDidFinishSSR } from "@tamagui/use-did-finish-ssr";
2
+ import { useState, useEffect } from "react";
3
+ const media = typeof window < "u" && window.matchMedia ? window.matchMedia("(prefers-color-scheme: dark)") : null;
4
+ function getSystemTheme() {
5
+ return media?.matches ? "dark" : "light";
6
+ }
7
+ function useSystemTheme() {
8
+ const [systemTheme, setSystemTheme] = useState(() => getSystemTheme()), didHydrate = useDidFinishSSR();
9
+ return useEffect(() => {
10
+ const onChange = () => {
11
+ setSystemTheme(getSystemTheme());
12
+ };
13
+ return media?.addEventListener("change", onChange), () => {
14
+ media?.removeEventListener("change", onChange);
15
+ };
16
+ }, []), didHydrate ? systemTheme : "light";
17
+ }
18
+ export {
19
+ useSystemTheme
20
+ };
21
+ //# sourceMappingURL=useSystemTheme.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/useSystemTheme.tsx"],
4
+ "mappings": "AAAA,SAAS,uBAAuB;AAChC,SAAS,UAAU,iBAAiB;AAGpC,MAAM,QACJ,OAAO,SAAW,OAAe,OAAO,aACpC,OAAO,WAAW,8BAA8B,IAChD;AAEN,SAAS,iBAAiB;AACxB,SAAO,OAAO,UAAU,SAAS;AACnC;AAEO,SAAS,iBAAiB;AAC/B,QAAM,CAAC,aAAa,cAAc,IAAI,SAAiB,MAAM,eAAe,CAAC,GACvE,aAAa,gBAAgB;AAYnC,SAVA,UAAU,MAAM;AACd,UAAM,WAAW,MAAM;AACrB,qBAAe,eAAe,CAAC;AAAA,IACjC;AACA,kBAAO,iBAAiB,UAAU,QAAQ,GACnC,MAAM;AACX,aAAO,oBAAoB,UAAU,QAAQ;AAAA,IAC/C;AAAA,EACF,GAAG,CAAC,CAAC,GAEA,aAIE,cAHE;AAIX;",
5
+ "names": []
6
+ }
@@ -0,0 +1,20 @@
1
+ import { useDidFinishSSR } from "@tamagui/use-did-finish-ssr";
2
+ import { useState, useEffect } from "react";
3
+ const media = typeof window < "u" && window.matchMedia ? window.matchMedia("(prefers-color-scheme: dark)") : null;
4
+ function getSystemTheme() {
5
+ return media?.matches ? "dark" : "light";
6
+ }
7
+ function useSystemTheme() {
8
+ const [systemTheme, setSystemTheme] = useState(() => getSystemTheme()),
9
+ didHydrate = useDidFinishSSR();
10
+ return useEffect(() => {
11
+ const onChange = () => {
12
+ setSystemTheme(getSystemTheme());
13
+ };
14
+ return media?.addEventListener("change", onChange), () => {
15
+ media?.removeEventListener("change", onChange);
16
+ };
17
+ }, []), didHydrate ? systemTheme : "light";
18
+ }
19
+ export { useSystemTheme };
20
+ //# sourceMappingURL=useSystemTheme.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useDidFinishSSR","useState","useEffect","media","window","matchMedia","getSystemTheme","matches","useSystemTheme","systemTheme","setSystemTheme","didHydrate","onChange","addEventListener","removeEventListener"],"sources":["../../src/useSystemTheme.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAASA,eAAA,QAAuB;AAChC,SAASC,QAAA,EAAUC,SAAA,QAAiB;AAGpC,MAAMC,KAAA,GACJ,OAAOC,MAAA,GAAW,OAAeA,MAAA,CAAOC,UAAA,GACpCD,MAAA,CAAOC,UAAA,CAAW,8BAA8B,IAChD;AAEN,SAASC,eAAA,EAAiB;EACxB,OAAOH,KAAA,EAAOI,OAAA,GAAU,SAAS;AACnC;AAEO,SAASC,eAAA,EAAiB;EAC/B,MAAM,CAACC,WAAA,EAAaC,cAAc,IAAIT,QAAA,CAAiB,MAAMK,cAAA,CAAe,CAAC;IACvEK,UAAA,GAAaX,eAAA,CAAgB;EAYnC,OAVAE,SAAA,CAAU,MAAM;IACd,MAAMU,QAAA,GAAWA,CAAA,KAAM;MACrBF,cAAA,CAAeJ,cAAA,CAAe,CAAC;IACjC;IACA,OAAAH,KAAA,EAAOU,gBAAA,CAAiB,UAAUD,QAAQ,GACnC,MAAM;MACXT,KAAA,EAAOW,mBAAA,CAAoB,UAAUF,QAAQ;IAC/C;EACF,GAAG,EAAE,GAEAD,UAAA,GAIEF,WAAA,GAHE;AAIX","ignoreList":[]}
@@ -0,0 +1,58 @@
1
+ import { useState, useEffect } 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 useSystemTheme() {
45
+ var _useState = _sliced_to_array(useState(Appearance.getColorScheme() || "light"), 2), scheme = _useState[0], setScheme = _useState[1];
46
+ return useEffect(function() {
47
+ var listener = Appearance.addChangeListener(function(next) {
48
+ setScheme(next.colorScheme || "light");
49
+ });
50
+ return function() {
51
+ listener.remove();
52
+ };
53
+ }, []), scheme;
54
+ }
55
+ export {
56
+ useSystemTheme
57
+ };
58
+ //# sourceMappingURL=useSystemTheme.native.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/Users/n8/tamagui/code/packages/one-theme/src/useSystemTheme.native.tsx"],
4
+ "mappings": "AAAA,SAASA,UAAUC,iBAAiB;AACpC,SAASC,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGpB,SAASC,iBAAAA;AACd,MAA4BH,YAAAA,iBAAAA,SAASE,WAAWE,eAAc,KAAM,OAAA,GAAA,CAAA,GAA7DC,SAAqBL,UAAAA,CAAAA,GAAbM,YAAaN,UAAAA,CAAAA;AAE5BC,mBAAU,WAAA;AACR,QAAMM,WAAWL,WAAWM,kBAAkB,SAACC,MAAAA;AAC7CH,gBAAUG,KAAKC,eAAe,OAAA;IAChC,CAAA;AAEA,WAAO,WAAA;AACLH,eAASI,OAAM;IACjB;EACF,GAAG,CAAA,CAAE,GAEEN;AACT;",
5
+ "names": ["useState", "useEffect", "Appearance", "useSystemTheme", "getColorScheme", "scheme", "setScheme", "listener", "addChangeListener", "next", "colorScheme", "remove"]
6
+ }
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@vxrn/color-scheme",
3
+ "version": "1.1.202",
4
+ "sideEffects": false,
5
+ "source": "src/index.ts",
6
+ "types": "./types/index.d.ts",
7
+ "main": "dist/cjs",
8
+ "module": "dist/esm",
9
+ "exports": {
10
+ "./package.json": "./package.json",
11
+ ".": {
12
+ "react-native-import": "./dist/esm/index.native.js",
13
+ "react-native": "./dist/cjs/index.native.js",
14
+ "types": "./types/index.d.ts",
15
+ "import": "./dist/esm/index.mjs",
16
+ "require": "./dist/cjs/index.js"
17
+ }
18
+ },
19
+ "files": [
20
+ "src",
21
+ "types",
22
+ "dist"
23
+ ],
24
+ "scripts": {
25
+ "build": "tamagui-build",
26
+ "watch": "tamagui-build --watch",
27
+ "lint": "npx biome check src",
28
+ "lint:fix": "npx biome check --apply-unsafe src",
29
+ "clean": "tamagui-build clean",
30
+ "clean:build": "tamagui-build clean:build"
31
+ },
32
+ "dependencies": {
33
+ "@tamagui/use-did-finish-ssr": "^1.110.0",
34
+ "@vxrn/universal-color-scheme": "1.1.202",
35
+ "@vxrn/use-isomorphic-layout-effect": "1.1.202"
36
+ },
37
+ "devDependencies": {
38
+ "@tamagui/build": "^1.110.0",
39
+ "react": "^18.2.0 || ^19.0.0",
40
+ "react-native": "0.74.1"
41
+ },
42
+ "peerDependencies": {
43
+ "react": "*",
44
+ "react-native": "*"
45
+ },
46
+ "publishConfig": {
47
+ "access": "public"
48
+ }
49
+ }
package/src/index.tsx ADDED
@@ -0,0 +1,103 @@
1
+ import {
2
+ type ColorSchemeName,
3
+ setColorScheme,
4
+ useColorScheme as useColorSchemeBase,
5
+ useColorSchemeSetting,
6
+ } from '@vxrn/universal-color-scheme'
7
+ import { useIsomorphicLayoutEffect } from '@vxrn/use-isomorphic-layout-effect'
8
+ import { createContext, useContext, useMemo } from 'react'
9
+
10
+ export type Scheme = 'light' | 'dark'
11
+ export type SchemeSetting = 'system' | 'light' | 'dark'
12
+
13
+ export { getColorScheme, onColorSchemeChange } from '@vxrn/universal-color-scheme'
14
+
15
+ const storageKey = 'vxrn-scheme'
16
+
17
+ const getSetting = (): SchemeSetting =>
18
+ (typeof localStorage !== 'undefined' && (localStorage.getItem(storageKey) as SchemeSetting)) ||
19
+ 'system'
20
+
21
+ // on startup lets set from localstorage
22
+ const setting = getSetting()
23
+
24
+ if (setting !== 'system') {
25
+ setColorScheme(setting)
26
+ }
27
+
28
+ const SchemeContext = createContext<{
29
+ setting: SchemeSetting
30
+ value: 'light' | 'dark'
31
+ }>({
32
+ setting: 'system',
33
+ value: 'light',
34
+ })
35
+
36
+ export const useColorScheme = () => {
37
+ const [state] = useColorSchemeBase()
38
+ return [state, setSchemeSetting] as const
39
+ }
40
+
41
+ export function useSchemeSetting() {
42
+ const values = useContext(SchemeContext)
43
+ return [values, setSchemeSetting] as const
44
+ }
45
+
46
+ export function setSchemeSetting(next: SchemeSetting) {
47
+ if (typeof localStorage !== 'undefined') {
48
+ localStorage.setItem(storageKey, next)
49
+ }
50
+ setColorScheme(next)
51
+ }
52
+
53
+ export function SchemeProvider({
54
+ children,
55
+ // defaults to tamagui-compatible
56
+ getClassName = (name) => `t_${name}`,
57
+ }: { children: any; getClassName?: (name: ColorSchemeName) => string }) {
58
+ const [colorSchemeSetting] = useColorSchemeSetting()
59
+ const [colorScheme] = useColorScheme()
60
+
61
+ if (process.env.TAMAGUI_TARGET !== 'native') {
62
+ useIsomorphicLayoutEffect(() => {
63
+ const toAdd = getClassName(colorScheme)
64
+ const { classList } = document.documentElement
65
+ if (!classList.contains(toAdd)) {
66
+ const toRemove = colorScheme === 'light' ? 'dark' : 'light'
67
+ classList.remove(getClassName(toRemove))
68
+ classList.add(toAdd)
69
+ }
70
+ }, [colorScheme])
71
+ }
72
+
73
+ return (
74
+ <>
75
+ {process.env.TAMAGUI_TARGET === 'native' ? null : (
76
+ <script
77
+ dangerouslySetInnerHTML={{
78
+ __html: `let d = document.documentElement.classList
79
+ d.remove('${getClassName('light')}')
80
+ d.remove('${getClassName('dark')}')
81
+ let e = localStorage.getItem('user-theme')
82
+ let t =
83
+ 'system' === e || !e
84
+ ? window.matchMedia('(prefers-color-scheme: dark)').matches
85
+ : e === 'dark'
86
+ t ? d.add('${getClassName('dark')}') : d.add('${getClassName('light')}')`,
87
+ }}
88
+ />
89
+ )}
90
+ <SchemeContext.Provider
91
+ value={useMemo(
92
+ () => ({
93
+ value: colorScheme,
94
+ setting: colorSchemeSetting,
95
+ }),
96
+ [colorScheme, colorSchemeSetting]
97
+ )}
98
+ >
99
+ {children}
100
+ </SchemeContext.Provider>
101
+ </>
102
+ )
103
+ }
@@ -0,0 +1,15 @@
1
+ import { type ColorSchemeName } from '@vxrn/universal-color-scheme';
2
+ export type Scheme = 'light' | 'dark';
3
+ export type SchemeSetting = 'system' | 'light' | 'dark';
4
+ export { getColorScheme, onColorSchemeChange } from '@vxrn/universal-color-scheme';
5
+ export declare const useColorScheme: () => readonly ["light" | "dark", typeof setSchemeSetting];
6
+ export declare function useSchemeSetting(): readonly [{
7
+ setting: SchemeSetting;
8
+ value: "light" | "dark";
9
+ }, typeof setSchemeSetting];
10
+ export declare function setSchemeSetting(next: SchemeSetting): void;
11
+ export declare function SchemeProvider({ children, getClassName, }: {
12
+ children: any;
13
+ getClassName?: (name: ColorSchemeName) => string;
14
+ }): import("react/jsx-runtime").JSX.Element;
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,EAIrB,MAAM,8BAA8B,CAAA;AAIrC,MAAM,MAAM,MAAM,GAAG,OAAO,GAAG,MAAM,CAAA;AACrC,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAA;AAEvD,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAA;AAuBlF,eAAO,MAAM,cAAc,4DAG1B,CAAA;AAED,wBAAgB,gBAAgB;;;4BAG/B;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,aAAa,QAKnD;AAED,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EAER,YAAoC,GACrC,EAAE;IAAE,QAAQ,EAAE,GAAG,CAAC;IAAC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,eAAe,KAAK,MAAM,CAAA;CAAE,2CA8CrE"}