@vxrn/color-scheme 1.25.4 → 1.25.5
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/package.json +2 -2
- package/dist/cjs/index.cjs +0 -121
- package/dist/cjs/index.native.js +0 -96
- package/dist/cjs/index.native.js.map +0 -1
- package/dist/cjs/safeStorage.cjs +0 -40
- package/dist/cjs/safeStorage.native.js +0 -43
- package/dist/cjs/safeStorage.native.js.map +0 -1
- package/dist/cjs/safeStorage.test.cjs +0 -49
- package/dist/cjs/safeStorage.test.native.js +0 -66
- package/dist/cjs/safeStorage.test.native.js.map +0 -1
- package/dist/cjs/systemScheme.cjs +0 -44
- package/dist/cjs/systemScheme.native.js +0 -64
- package/dist/cjs/systemScheme.native.js.map +0 -1
- package/dist/cjs/userScheme.cjs +0 -156
- package/dist/cjs/userScheme.native.js +0 -171
- package/dist/cjs/userScheme.native.js.map +0 -1
- package/dist/cjs/userSchemeAppearance.cjs +0 -35
- package/dist/cjs/userSchemeAppearance.native.js +0 -42
- package/dist/cjs/userSchemeAppearance.native.js.map +0 -1
- package/dist/esm/index.js +0 -88
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/index.mjs +0 -88
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/index.native.js +0 -58
- package/dist/esm/index.native.js.map +0 -1
- package/dist/esm/safeStorage.mjs +0 -14
- package/dist/esm/safeStorage.mjs.map +0 -1
- package/dist/esm/safeStorage.native.js +0 -14
- package/dist/esm/safeStorage.native.js.map +0 -1
- package/dist/esm/safeStorage.test.mjs +0 -50
- package/dist/esm/safeStorage.test.mjs.map +0 -1
- package/dist/esm/safeStorage.test.native.js +0 -64
- package/dist/esm/safeStorage.test.native.js.map +0 -1
- package/dist/esm/systemScheme.mjs +0 -18
- package/dist/esm/systemScheme.mjs.map +0 -1
- package/dist/esm/systemScheme.native.js +0 -35
- package/dist/esm/systemScheme.native.js.map +0 -1
- package/dist/esm/userScheme.mjs +0 -125
- package/dist/esm/userScheme.mjs.map +0 -1
- package/dist/esm/userScheme.native.js +0 -137
- package/dist/esm/userScheme.native.js.map +0 -1
- package/dist/esm/userSchemeAppearance.mjs +0 -8
- package/dist/esm/userSchemeAppearance.mjs.map +0 -1
- package/dist/esm/userSchemeAppearance.native.js +0 -12
- package/dist/esm/userSchemeAppearance.native.js.map +0 -1
- package/types/index.d.ts.map +0 -1
- package/types/safeStorage.d.ts.map +0 -1
- package/types/safeStorage.test.d.ts.map +0 -1
- package/types/systemScheme.d.ts.map +0 -1
- package/types/systemScheme.native.d.ts.map +0 -1
- package/types/userScheme.d.ts.map +0 -1
- package/types/userSchemeAppearance.d.ts.map +0 -1
- package/types/userSchemeAppearance.native.d.ts.map +0 -1
package/dist/esm/index.native.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { getForceScheme, getUserScheme, onUserSchemeChange, setForceScheme, setUserScheme as setUserScheme2, useUserScheme, useUserScheme as useUserScheme2 } from "./userScheme.native.js";
|
|
3
|
-
import { getSystemScheme, useSystemScheme } from "./systemScheme.native.js";
|
|
4
|
-
var storageKey = "vxrn-scheme";
|
|
5
|
-
function SchemeProvider(param) {
|
|
6
|
-
var {
|
|
7
|
-
children,
|
|
8
|
-
getClassName = function (name) {
|
|
9
|
-
return `t_${name}`;
|
|
10
|
-
},
|
|
11
|
-
defaultScheme,
|
|
12
|
-
forceScheme
|
|
13
|
-
} = param;
|
|
14
|
-
setForceScheme(forceScheme !== null && forceScheme !== void 0 ? forceScheme : null);
|
|
15
|
-
var {
|
|
16
|
-
value
|
|
17
|
-
} = useUserScheme();
|
|
18
|
-
if (forceScheme) `${getClassName("light")}${getClassName("dark")}${getClassName(forceScheme)}`;else {
|
|
19
|
-
var fallback = defaultScheme ? `'${defaultScheme}' === 'dark'` : `window.matchMedia('(prefers-color-scheme: dark)').matches`;
|
|
20
|
-
var seedStorage = defaultScheme ? `;if(!e){localStorage.setItem('${storageKey}','${defaultScheme}')}` : "";
|
|
21
|
-
`${getClassName("light")}${getClassName("dark")}${storageKey}${seedStorage}${fallback}${getClassName("dark")}${getClassName("light")}`;
|
|
22
|
-
}
|
|
23
|
-
return /* @__PURE__ */jsxs(Fragment, {
|
|
24
|
-
children: [null, children]
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
function MetaTheme(param) {
|
|
28
|
-
var {
|
|
29
|
-
color,
|
|
30
|
-
darkColor,
|
|
31
|
-
lightColor
|
|
32
|
-
} = param;
|
|
33
|
-
var {
|
|
34
|
-
value
|
|
35
|
-
} = useUserScheme();
|
|
36
|
-
var forced = getForceScheme();
|
|
37
|
-
var scriptContent = forced ? `document.getElementById('vxrn-theme-color').setAttribute('content','${forced === "dark" ? darkColor : lightColor}')` : `let dc = document.getElementById('vxrn-theme-color')
|
|
38
|
-
let e1 = null
|
|
39
|
-
try { e1 = localStorage.getItem('${storageKey}') } catch (_e) {}
|
|
40
|
-
let isD = 'system' === e1 || !e1 ? window.matchMedia('(prefers-color-scheme: dark)').matches : e1 === 'dark'
|
|
41
|
-
dc.setAttribute('content', isD ? '${darkColor}' : '${lightColor}')`;
|
|
42
|
-
return /* @__PURE__ */jsxs(Fragment, {
|
|
43
|
-
children: [/* @__PURE__ */jsx("meta", {
|
|
44
|
-
suppressHydrationWarning: true,
|
|
45
|
-
id: "vxrn-theme-color",
|
|
46
|
-
name: "theme-color",
|
|
47
|
-
content: color !== null && color !== void 0 ? color : value === "dark" ? darkColor : lightColor
|
|
48
|
-
}), /* @__PURE__ */jsx("script", {
|
|
49
|
-
suppressHydrationWarning: true,
|
|
50
|
-
id: "meta-theme-hydrate",
|
|
51
|
-
dangerouslySetInnerHTML: {
|
|
52
|
-
__html: scriptContent
|
|
53
|
-
}
|
|
54
|
-
})]
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
export { MetaTheme, SchemeProvider, getSystemScheme, getUserScheme, onUserSchemeChange, setUserScheme2 as setUserScheme, useSystemScheme, useUserScheme2 as useUserScheme };
|
|
58
|
-
//# sourceMappingURL=index.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["Fragment","jsx","jsxs","getForceScheme","getUserScheme","onUserSchemeChange","setForceScheme","setUserScheme","setUserScheme2","useUserScheme","useUserScheme2","getSystemScheme","useSystemScheme","storageKey","SchemeProvider","param","children","getClassName","name","defaultScheme","forceScheme","value","fallback","seedStorage","MetaTheme","color","darkColor","lightColor","forced","scriptContent","suppressHydrationWarning","id","content","dangerouslySetInnerHTML","__html"],"sources":["index.native.js"],"sourcesContent":["import { Fragment, jsx, jsxs } from \"react/jsx-runtime\";\nimport { getForceScheme, getUserScheme, onUserSchemeChange, setForceScheme, setUserScheme as setUserScheme2, useUserScheme, useUserScheme as useUserScheme2 } from \"./userScheme\";\nimport { getSystemScheme, useSystemScheme } from \"./systemScheme\";\n\nvar storageKey = \"vxrn-scheme\";\nfunction SchemeProvider(param) {\n\tvar { children, getClassName = function(name) {\n\t\treturn `t_${name}`;\n\t}, defaultScheme, forceScheme } = param;\n\tsetForceScheme(forceScheme !== null && forceScheme !== void 0 ? forceScheme : null);\n\tvar { value } = useUserScheme();\n\tif (forceScheme) `${getClassName(\"light\")}${getClassName(\"dark\")}${getClassName(forceScheme)}`;\n\telse {\n\t\tvar fallback = defaultScheme ? `'${defaultScheme}' === 'dark'` : `window.matchMedia('(prefers-color-scheme: dark)').matches`;\n\t\tvar seedStorage = defaultScheme ? `;if(!e){localStorage.setItem('${storageKey}','${defaultScheme}')}` : \"\";\n\t\t`${getClassName(\"light\")}${getClassName(\"dark\")}${storageKey}${seedStorage}${fallback}${getClassName(\"dark\")}${getClassName(\"light\")}`;\n\t}\n\treturn /* @__PURE__ */ jsxs(Fragment, { children: [null, children] });\n}\nfunction MetaTheme(param) {\n\tvar { color, darkColor, lightColor } = param;\n\tvar { value } = useUserScheme();\n\tvar forced = getForceScheme();\n\tvar scriptContent = forced ? `document.getElementById('vxrn-theme-color').setAttribute('content','${forced === \"dark\" ? darkColor : lightColor}')` : `let dc = document.getElementById('vxrn-theme-color')\nlet e1 = null\ntry { e1 = localStorage.getItem('${storageKey}') } catch (_e) {}\nlet isD = 'system' === e1 || !e1 ? window.matchMedia('(prefers-color-scheme: dark)').matches : e1 === 'dark'\ndc.setAttribute('content', isD ? '${darkColor}' : '${lightColor}')`;\n\treturn /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(\"meta\", {\n\t\tsuppressHydrationWarning: true,\n\t\tid: \"vxrn-theme-color\",\n\t\tname: \"theme-color\",\n\t\tcontent: color !== null && color !== void 0 ? color : value === \"dark\" ? darkColor : lightColor\n\t}), /* @__PURE__ */ jsx(\"script\", {\n\t\tsuppressHydrationWarning: true,\n\t\tid: \"meta-theme-hydrate\",\n\t\tdangerouslySetInnerHTML: { __html: scriptContent }\n\t})] });\n}\n\nexport { MetaTheme, SchemeProvider, getSystemScheme, getUserScheme, onUserSchemeChange, setUserScheme2 as setUserScheme, useSystemScheme, useUserScheme2 as useUserScheme };"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,GAAG,EAAEC,IAAI,QAAQ,mBAAmB;AACvD,SAASC,cAAc,EAAEC,aAAa,EAAEC,kBAAkB,EAAEC,cAAc,EAAEC,aAAa,IAAIC,cAAc,EAAEC,aAAa,EAAEA,aAAa,IAAIC,cAAc,QAAQ,wBAAc;AACjL,SAASC,eAAe,EAAEC,eAAe,QAAQ,0BAAgB;AAEjE,IAAIC,UAAU,GAAG,aAAa;AAC9B,SAASC,cAAcA,CAACC,KAAK,EAAE;EAC9B,IAAI;IAAEC,QAAQ;IAAEC,YAAY,GAAG,SAAAA,CAASC,IAAI,EAAE;MAC7C,OAAO,KAAKA,IAAI,EAAE;IACnB,CAAC;IAAEC,aAAa;IAAEC;EAAY,CAAC,GAAGL,KAAK;EACvCT,cAAc,CAACc,WAAW,KAAK,IAAI,IAAIA,WAAW,KAAK,KAAK,CAAC,GA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AAE,EAAE,kBAAkB;MACtBb,IAAI,EAAE,aAAa;MACnBc,OAAO,EAAEP,KAAK,KAAK,IAAI,IAAIA,KAAK,KAAK,KAAK,CAAC,GAAGA,KAAK,GAAGJ,KAAK,KAAK,MAAM,GAAGK,SAAS,GAAGC;IACtF,CAAC,CAAC,EAAE,eAAgB1B,GAAG,CAAC,QAAQ,EAAE;MACjC6B,wBAAwB,EAAE,IAAI;MAC9BC,EAAE,EAAE,oBAAoB;MACxBE,uBAAuB,EAAE;QAAEC,MAAM,EAAEL;MAAc;IAClD,CAAC,CAAC;EAAE,CAAC,CAAC;AACP;AAEA,SAASL,SAAS,EAAEV,cAAc,EAAEH,eAAe,EAAEP,aAAa,EAAEC,kBAAkB,EAAEG,cAAc,IAAID,aAAa,EAAEK,eAAe,EAAEF,cAAc,IAAID,aAAa","ignoreList":[]}
|
package/dist/esm/safeStorage.mjs
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
function getStorageItem(key) {
|
|
2
|
-
try {
|
|
3
|
-
return localStorage.getItem(key);
|
|
4
|
-
} catch {
|
|
5
|
-
return null;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
function setStorageItem(key, value) {
|
|
9
|
-
try {
|
|
10
|
-
localStorage.setItem(key, value);
|
|
11
|
-
} catch {}
|
|
12
|
-
}
|
|
13
|
-
export { getStorageItem, setStorageItem };
|
|
14
|
-
//# sourceMappingURL=safeStorage.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["getStorageItem","key","localStorage","getItem","setStorageItem","value","setItem"],"sources":["../../src/safeStorage.ts"],"sourcesContent":[null],"mappings":"AAOO,SAASA,eAAeC,GAAA,EAA4B;EACzD,IAAI;IACF,OAAOC,YAAA,CAAaC,OAAA,CAAQF,GAAG;EACjC,QAAQ;IACN,OAAO;EACT;AACF;AAEO,SAASG,eAAeH,GAAA,EAAaI,KAAA,EAAqB;EAC/D,IAAI;IACFH,YAAA,CAAaI,OAAA,CAAQL,GAAA,EAAKI,KAAK;EACjC,QAAQ,CAAC;AACX","ignoreList":[]}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
function getStorageItem(key) {
|
|
2
|
-
try {
|
|
3
|
-
return localStorage.getItem(key);
|
|
4
|
-
} catch (unused) {
|
|
5
|
-
return null;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
function setStorageItem(key, value) {
|
|
9
|
-
try {
|
|
10
|
-
localStorage.setItem(key, value);
|
|
11
|
-
} catch (unused) {}
|
|
12
|
-
}
|
|
13
|
-
export { getStorageItem, setStorageItem };
|
|
14
|
-
//# sourceMappingURL=safeStorage.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["getStorageItem","key","localStorage","getItem","unused","setStorageItem","value","setItem"],"sources":["../../src/safeStorage.ts"],"sourcesContent":[null],"mappings":"AAOO,SAASA,eAAeC,GAAA,EAA4B;EACzD,IAAI;IACF,OAAOC,YAAA,CAAaC,OAAA,CAAQF,GAAG;EACjC,SAAQG,MAAA;IACN,OAAO;EACT;AACF;AAEO,SAASC,eAAeJ,GAAA,EAAaK,KAAA,EAAqB;EAC/D,IAAI;IACFJ,YAAA,CAAaK,OAAA,CAAQN,GAAA,EAAKK,KAAK;EACjC,SAAQF,MAAA,GAAC;AACX","ignoreList":[]}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { afterEach, describe, expect, it } from "vitest";
|
|
2
|
-
import { getStorageItem, setStorageItem } from "./safeStorage.mjs";
|
|
3
|
-
afterEach(() => {
|
|
4
|
-
delete globalThis.localStorage;
|
|
5
|
-
});
|
|
6
|
-
function defineLocalStorage(descriptor) {
|
|
7
|
-
Object.defineProperty(globalThis, "localStorage", {
|
|
8
|
-
configurable: true,
|
|
9
|
-
...descriptor
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
describe("safeStorage", () => {
|
|
13
|
-
it("reads and writes through to a working localStorage", () => {
|
|
14
|
-
const store = /* @__PURE__ */new Map();
|
|
15
|
-
defineLocalStorage({
|
|
16
|
-
value: {
|
|
17
|
-
getItem: k => store.has(k) ? store.get(k) : null,
|
|
18
|
-
setItem: (k, v) => void store.set(k, v)
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
setStorageItem("vxrn-scheme", "dark");
|
|
22
|
-
expect(getStorageItem("vxrn-scheme")).toBe("dark");
|
|
23
|
-
});
|
|
24
|
-
it("returns null instead of throwing when the localStorage getter throws", () => {
|
|
25
|
-
defineLocalStorage({
|
|
26
|
-
get() {
|
|
27
|
-
throw new Error('Failed to read the "localStorage" property: Access is denied.');
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
expect(() => getStorageItem("vxrn-scheme")).not.toThrow();
|
|
31
|
-
expect(getStorageItem("vxrn-scheme")).toBeNull();
|
|
32
|
-
expect(() => setStorageItem("vxrn-scheme", "dark")).not.toThrow();
|
|
33
|
-
});
|
|
34
|
-
it("swallows errors when setItem throws (quota / blocked)", () => {
|
|
35
|
-
defineLocalStorage({
|
|
36
|
-
value: {
|
|
37
|
-
getItem: () => null,
|
|
38
|
-
setItem: () => {
|
|
39
|
-
throw new Error("QuotaExceededError");
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
expect(() => setStorageItem("vxrn-scheme", "dark")).not.toThrow();
|
|
44
|
-
});
|
|
45
|
-
it("returns null when localStorage is undefined (native)", () => {
|
|
46
|
-
expect(getStorageItem("vxrn-scheme")).toBeNull();
|
|
47
|
-
expect(() => setStorageItem("vxrn-scheme", "dark")).not.toThrow();
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
//# sourceMappingURL=safeStorage.test.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["afterEach","describe","expect","it","getStorageItem","setStorageItem","globalThis","localStorage","defineLocalStorage","descriptor","Object","defineProperty","configurable","store","Map","value","getItem","k","has","get","setItem","v","set","toBe","Error","not","toThrow","toBeNull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AA,CAAQ;EAClE,CAAC;EAEDvB,EAAA,CAAG,yDAAyD,MAAM;IAChEK,kBAAA,CAAmB;MACjBO,KAAA,EAAO;QACLC,OAAA,EAASA,CAAA,KAAM;QACfI,OAAA,EAASA,CAAA,KAAM;UACb,MAAM,IAAII,KAAA,CAAM,oBAAoB;QACtC;MACF;IACF,CAAC;IAEDtB,MAAA,CAAO,MAAMG,cAAA,CAAe,eAAe,MAAM,CAAC,EAAEoB,GAAA,CAAIC,OAAA,CAAQ;EAClE,CAAC;EAEDvB,EAAA,CAAG,wDAAwD,MAAM;IAC/DD,MAAA,CAAOE,cAAA,CAAe,aAAa,CAAC,EAAEuB,QAAA,CAAS;IAC/CzB,MAAA,CAAO,MAAMG,cAAA,CAAe,eAAe,MAAM,CAAC,EAAEoB,GAAA,CAAIC,OAAA,CAAQ;EAClE,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { afterEach, describe, expect, it } from "vitest";
|
|
2
|
-
import { getStorageItem, setStorageItem } from "./safeStorage.native.js";
|
|
3
|
-
afterEach(function () {
|
|
4
|
-
delete globalThis.localStorage;
|
|
5
|
-
});
|
|
6
|
-
function defineLocalStorage(descriptor) {
|
|
7
|
-
Object.defineProperty(globalThis, "localStorage", {
|
|
8
|
-
configurable: true,
|
|
9
|
-
...descriptor
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
describe("safeStorage", function () {
|
|
13
|
-
it("reads and writes through to a working localStorage", function () {
|
|
14
|
-
var store = /* @__PURE__ */new Map();
|
|
15
|
-
defineLocalStorage({
|
|
16
|
-
value: {
|
|
17
|
-
getItem: function (k) {
|
|
18
|
-
return store.has(k) ? store.get(k) : null;
|
|
19
|
-
},
|
|
20
|
-
setItem: function (k, v) {
|
|
21
|
-
return void store.set(k, v);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
setStorageItem("vxrn-scheme", "dark");
|
|
26
|
-
expect(getStorageItem("vxrn-scheme")).toBe("dark");
|
|
27
|
-
});
|
|
28
|
-
it("returns null instead of throwing when the localStorage getter throws", function () {
|
|
29
|
-
defineLocalStorage({
|
|
30
|
-
get() {
|
|
31
|
-
throw new Error('Failed to read the "localStorage" property: Access is denied.');
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
expect(function () {
|
|
35
|
-
return getStorageItem("vxrn-scheme");
|
|
36
|
-
}).not.toThrow();
|
|
37
|
-
expect(getStorageItem("vxrn-scheme")).toBeNull();
|
|
38
|
-
expect(function () {
|
|
39
|
-
return setStorageItem("vxrn-scheme", "dark");
|
|
40
|
-
}).not.toThrow();
|
|
41
|
-
});
|
|
42
|
-
it("swallows errors when setItem throws (quota / blocked)", function () {
|
|
43
|
-
defineLocalStorage({
|
|
44
|
-
value: {
|
|
45
|
-
getItem: function () {
|
|
46
|
-
return null;
|
|
47
|
-
},
|
|
48
|
-
setItem: function () {
|
|
49
|
-
throw new Error("QuotaExceededError");
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
expect(function () {
|
|
54
|
-
return setStorageItem("vxrn-scheme", "dark");
|
|
55
|
-
}).not.toThrow();
|
|
56
|
-
});
|
|
57
|
-
it("returns null when localStorage is undefined (native)", function () {
|
|
58
|
-
expect(getStorageItem("vxrn-scheme")).toBeNull();
|
|
59
|
-
expect(function () {
|
|
60
|
-
return setStorageItem("vxrn-scheme", "dark");
|
|
61
|
-
}).not.toThrow();
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
//# sourceMappingURL=safeStorage.test.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["afterEach","describe","expect","it","getStorageItem","setStorageItem","globalThis","localStorage","defineLocalStorage","descriptor","Object","defineProperty","configurable","store","Map","value","getItem","k","has","get","setItem","v","set","toBe","Error","not","toThrow","toBeNull"],"sources":["../../src/safeStorage.test.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,SAAA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1,18 +0,0 @@
|
|
|
1
|
-
import { useIsomorphicLayoutEffect } from "@vxrn/use-isomorphic-layout-effect";
|
|
2
|
-
import { useState } from "react";
|
|
3
|
-
const media = typeof window !== "undefined" && window.matchMedia ? window.matchMedia("(prefers-color-scheme: dark)") : null;
|
|
4
|
-
function getSystemScheme() {
|
|
5
|
-
return media?.matches ? "dark" : "light";
|
|
6
|
-
}
|
|
7
|
-
function useSystemScheme() {
|
|
8
|
-
const [scheme, setScheme] = useState("light");
|
|
9
|
-
useIsomorphicLayoutEffect(() => {
|
|
10
|
-
setScheme(getSystemScheme());
|
|
11
|
-
const onChange = () => setScheme(getSystemScheme());
|
|
12
|
-
media?.addEventListener("change", onChange);
|
|
13
|
-
return () => media?.removeEventListener("change", onChange);
|
|
14
|
-
}, []);
|
|
15
|
-
return scheme;
|
|
16
|
-
}
|
|
17
|
-
export { getSystemScheme, useSystemScheme };
|
|
18
|
-
//# sourceMappingURL=systemScheme.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useIsomorphicLayoutEffect","useState","media","window","matchMedia","getSystemScheme","matches","useSystemScheme","scheme","setScheme","onChange","addEventListener","removeEventListener"],"sources":["../../src/systemScheme.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,yBAAA,QAAiC;AAC1C,SAASC,QAAA,QAAgB;AAIzB,MAAMC,KAAA,GACJ,OAAOC,MAAA,KAAW,eAAeA,MAAA,CAAOC,UAAA,GACpCD,MAAA,CAAOC,UAAA,CAAW,8BAA8B,IAChD;AAEC,SAASC,gBAAA,EAA0B;EACxC,OAAOH,KAAA,EAAOI,OAAA,GAAU,SAAS;AACnC;AAEO,SAASC,gBAAA,EAA0B;EACxC,MAAM,CAACC,MAAA,EAAQC,SAAS,IAAIR,QAAA,CAAiB,OAAO;EAEpDD,yBAAA,CAA0B,MAAM;IAC9BS,SAAA,CAAUJ,eAAA,CAAgB,CAAC;IAC3B,MAAMK,QAAA,GAAWA,CAAA,KAAMD,SAAA,CAAUJ,eAAA,CAAgB,CAAC;IAClDH,KAAA,EAAOS,gBAAA,CAAiB,UAAUD,QAAQ;IAC1C,OAAO,MAAMR,KAAA,EAAOU,mBAAA,CAAoB,UAAUF,QAAQ;EAC5D,GAAG,EAAE;EAEL,OAAOF,MAAA;AACT","ignoreList":[]}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect } from "react";
|
|
2
|
-
import { Appearance, AppState } from "react-native";
|
|
3
|
-
function toScheme(colorScheme) {
|
|
4
|
-
return colorScheme === "dark" ? "dark" : "light";
|
|
5
|
-
}
|
|
6
|
-
function getSystemScheme() {
|
|
7
|
-
return toScheme(Appearance.getColorScheme());
|
|
8
|
-
}
|
|
9
|
-
function useSystemScheme() {
|
|
10
|
-
var [scheme, setScheme] = useState(getSystemScheme);
|
|
11
|
-
useEffect(function () {
|
|
12
|
-
var appearanceSubscription = Appearance.addChangeListener(function (param) {
|
|
13
|
-
var {
|
|
14
|
-
colorScheme
|
|
15
|
-
} = param;
|
|
16
|
-
setScheme(toScheme(colorScheme));
|
|
17
|
-
});
|
|
18
|
-
var handleAppStateChange = function (nextAppState) {
|
|
19
|
-
if (nextAppState === "active") {
|
|
20
|
-
var currentScheme = getSystemScheme();
|
|
21
|
-
setScheme(function (prev) {
|
|
22
|
-
return prev !== currentScheme ? currentScheme : prev;
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
var appStateSubscription = AppState.addEventListener("change", handleAppStateChange);
|
|
27
|
-
return function () {
|
|
28
|
-
appearanceSubscription.remove();
|
|
29
|
-
appStateSubscription.remove();
|
|
30
|
-
};
|
|
31
|
-
}, []);
|
|
32
|
-
return scheme;
|
|
33
|
-
}
|
|
34
|
-
export { getSystemScheme, useSystemScheme };
|
|
35
|
-
//# sourceMappingURL=systemScheme.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useState","useEffect","Appearance","AppState","toScheme","colorScheme","getSystemScheme","getColorScheme","useSystemScheme","scheme","setScheme","appearanceSubscription","addChangeListener","param","handleAppStateChange","nextAppState","currentScheme","prev","appStateSubscription","addEventListener","remove"],"sources":["../../src/systemScheme.native.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,QAAA,EAAUC,SAAA,QAAiB;AACpC,SAASC,UAAA,EAAYC,QAAA,QAAgB;AACrC,SAASC,SAASC,WAAA,EAAa;EAC3B,OAAOA,WAAA,KAAgB,SAAS,SAAS;AAC7C;AACO,SAASC,gBAAA,EAAkB;EAC9B,OAAOF,QAAA,CAASF,UAAA,CAAWK,cAAA,CAAe,CAAC;AAC/C;AACO,SAASC,gBAAA,EAAkB;EAC9B,IAAI,CAACC,MAAA,EAAQC,SAAS,IAAIV,QAAA,CAASM,eAAe;EAClDL,SAAA,CAAU,YAAW;IAEjB,IAAIU,sBAAA,GAAyBT,UAAA,CAAWU,iBAAA,CAAkB,UAASC,KAAA,EAAO;MACtE,IAAI;QAAER;MAAY,IAAIQ,KAAA;MACtBH,SAAA,CAAUN,QAAA,CAASC,WAAW,CAAC;IACnC,CAAC;IAGD,IAAIS,oBAAA,GAAuB,SAAAA,CAASC,YAAA,EAAc;MAC9C,IAAIA,YAAA,KAAiB,UAAU;QAC3B,IAAIC,aAAA,GAAgBV,eAAA,CAAgB;QACpCI,SAAA,CAAU,UAASO,IAAA,EAAM;UACrB,OAAOA,IAAA,KAASD,aAAA,GAAgBA,aAAA,GAAgBC,IAAA;QACpD,CAAC;MACL;IACJ;IACA,IAAIC,oBAAA,GAAuBf,QAAA,CAASgB,gBAAA,CAAiB,UAAUL,oBAAoB;IACnF,OAAO,YAAW;MACdH,sBAAA,CAAuBS,MAAA,CAAO;MAC9BF,oBAAA,CAAqBE,MAAA,CAAO;IAChC;EACJ,GAAG,EAAE;EACL,OAAOX,MAAA;AACX","ignoreList":[]}
|
package/dist/esm/userScheme.mjs
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { useIsomorphicLayoutEffect } from "@vxrn/use-isomorphic-layout-effect";
|
|
2
|
-
import { useMemo, useState } from "react";
|
|
3
|
-
import { getStorageItem, setStorageItem } from "./safeStorage.mjs";
|
|
4
|
-
import { getSystemScheme } from "./systemScheme.mjs";
|
|
5
|
-
const listeners = /* @__PURE__ */new Set();
|
|
6
|
-
const storageKey = "vxrn-scheme";
|
|
7
|
-
let _forceScheme = null;
|
|
8
|
-
function notifyListeners() {
|
|
9
|
-
listeners.forEach(listener => {
|
|
10
|
-
listener(currentSetting, currentValue);
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
function restoreUnforcedScheme() {
|
|
14
|
-
const stored = getStorageItem(storageKey);
|
|
15
|
-
if (stored) {
|
|
16
|
-
currentSetting = stored;
|
|
17
|
-
currentValue = stored === "system" ? resolveValue("system") : stored;
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
currentSetting = "system";
|
|
21
|
-
currentValue = resolveValue("system");
|
|
22
|
-
}
|
|
23
|
-
function setForceScheme(scheme) {
|
|
24
|
-
const wasForced = _forceScheme;
|
|
25
|
-
if (wasForced === scheme) return;
|
|
26
|
-
_forceScheme = scheme;
|
|
27
|
-
if (scheme) {
|
|
28
|
-
currentSetting = scheme;
|
|
29
|
-
currentValue = scheme;
|
|
30
|
-
} else if (wasForced) {
|
|
31
|
-
restoreUnforcedScheme();
|
|
32
|
-
startWebListener();
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
function getForceScheme() {
|
|
36
|
-
return _forceScheme;
|
|
37
|
-
}
|
|
38
|
-
function getInitialSetting() {
|
|
39
|
-
return "system";
|
|
40
|
-
}
|
|
41
|
-
function getInitialValue(setting) {
|
|
42
|
-
return "light";
|
|
43
|
-
}
|
|
44
|
-
const initialSetting = getInitialSetting();
|
|
45
|
-
let currentSetting = initialSetting;
|
|
46
|
-
let currentValue = getInitialValue(initialSetting);
|
|
47
|
-
let isWebListening = false;
|
|
48
|
-
function startWebListener() {
|
|
49
|
-
if (isWebListening) return;
|
|
50
|
-
isWebListening = true;
|
|
51
|
-
const matcher = typeof window !== "undefined" ? window.matchMedia?.("(prefers-color-scheme: dark)") : null;
|
|
52
|
-
const onSystemChange = () => {
|
|
53
|
-
if (currentSetting === "system") updateValueFromSystem();
|
|
54
|
-
};
|
|
55
|
-
onSystemChange();
|
|
56
|
-
matcher?.addEventListener?.("change", onSystemChange);
|
|
57
|
-
}
|
|
58
|
-
function resolveValue(setting) {
|
|
59
|
-
if (setting === "system") return getSystemScheme();
|
|
60
|
-
return setting;
|
|
61
|
-
}
|
|
62
|
-
function updateValueFromSystem() {
|
|
63
|
-
if (_forceScheme) return;
|
|
64
|
-
const value = resolveValue("system");
|
|
65
|
-
if (value !== currentValue) {
|
|
66
|
-
currentValue = value;
|
|
67
|
-
notifyListeners();
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
function updateScheme(setting) {
|
|
71
|
-
if (_forceScheme) return;
|
|
72
|
-
const value = setting === "system" ? resolveValue("system") : setting;
|
|
73
|
-
if (value !== currentValue || currentSetting !== setting) {
|
|
74
|
-
currentSetting = setting;
|
|
75
|
-
currentValue = value;
|
|
76
|
-
notifyListeners();
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
function setUserScheme(setting) {
|
|
80
|
-
if (_forceScheme) return;
|
|
81
|
-
setStorageItem(storageKey, setting);
|
|
82
|
-
updateScheme(setting);
|
|
83
|
-
}
|
|
84
|
-
function getUserScheme() {
|
|
85
|
-
if (_forceScheme) return {
|
|
86
|
-
setting: _forceScheme,
|
|
87
|
-
value: _forceScheme
|
|
88
|
-
};
|
|
89
|
-
return {
|
|
90
|
-
setting: currentSetting,
|
|
91
|
-
value: currentValue
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
function onUserSchemeChange(listener) {
|
|
95
|
-
listeners.add(listener);
|
|
96
|
-
listener(currentSetting, currentValue);
|
|
97
|
-
return () => {
|
|
98
|
-
listeners.delete(listener);
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
function useUserScheme() {
|
|
102
|
-
const [state, setState] = useState(() => getUserScheme());
|
|
103
|
-
const snapshot = getUserScheme();
|
|
104
|
-
const resolvedState = state.setting === snapshot.setting && state.value === snapshot.value ? state : snapshot;
|
|
105
|
-
useIsomorphicLayoutEffect(() => {
|
|
106
|
-
if (!_forceScheme) {
|
|
107
|
-
const stored = getStorageItem(storageKey);
|
|
108
|
-
if (stored) updateScheme(stored);
|
|
109
|
-
startWebListener();
|
|
110
|
-
}
|
|
111
|
-
return onUserSchemeChange((setting, value) => {
|
|
112
|
-
setState({
|
|
113
|
-
setting,
|
|
114
|
-
value
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
}, []);
|
|
118
|
-
return useMemo(() => ({
|
|
119
|
-
setting: resolvedState.setting,
|
|
120
|
-
value: resolvedState.value,
|
|
121
|
-
set: setUserScheme
|
|
122
|
-
}), [resolvedState.setting, resolvedState.value]);
|
|
123
|
-
}
|
|
124
|
-
export { getForceScheme, getUserScheme, onUserSchemeChange, setForceScheme, setUserScheme, useUserScheme };
|
|
125
|
-
//# sourceMappingURL=userScheme.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useIsomorphicLayoutEffect","useMemo","useState","getStorageItem","setStorageItem","getSystemScheme","listeners","Set","storageKey","_forceScheme","notifyListeners","forEach","listener","currentSetting","currentValue","restoreUnforcedScheme","stored","resolveValue","setForceScheme","scheme","wasForced","startWebListener","getForceScheme","getInitialSetting","getInitialValue","setting","initialSetting","isWebListening","matcher","window","matchMedia","onSystemChange","updateValueFromSystem","addEventListener","value","updateScheme","setUserScheme","getUserScheme","onUserSchemeChange","add","delete","useUserScheme","state","setState","snapshot","resolvedState","set"],"sources":["userScheme.mjs"],"sourcesContent":["import { useIsomorphicLayoutEffect } from \"@vxrn/use-isomorphic-layout-effect\";\nimport { useMemo, useState } from \"react\";\nimport { getStorageItem, setStorageItem } from \"./safeStorage\";\nimport { getSystemScheme } from \"./systemScheme\";\n\nconst listeners = /* @__PURE__ */ new Set();\nconst storageKey = \"vxrn-scheme\";\nlet _forceScheme = null;\nfunction notifyListeners() {\n\tlisteners.forEach((listener) => {\n\t\tlistener(currentSetting, currentValue);\n\t});\n}\nfunction restoreUnforcedScheme() {\n\tconst stored = getStorageItem(storageKey);\n\tif (stored) {\n\t\tcurrentSetting = stored;\n\t\tcurrentValue = stored === \"system\" ? resolveValue(\"system\") : stored;\n\t\treturn;\n\t}\n\tcurrentSetting = \"system\";\n\tcurrentValue = resolveValue(\"system\");\n}\nfunction setForceScheme(scheme) {\n\tconst wasForced = _forceScheme;\n\tif (wasForced === scheme) return;\n\t_forceScheme = scheme;\n\tif (scheme) {\n\t\tcurrentSetting = scheme;\n\t\tcurrentValue = scheme;\n\t} else if (wasForced) {\n\t\trestoreUnforcedScheme();\n\t\tstartWebListener();\n\t}\n}\nfunction getForceScheme() {\n\treturn _forceScheme;\n}\nfunction getInitialSetting() {\n\treturn \"system\";\n}\nfunction getInitialValue(setting) {\n\treturn \"light\";\n}\nconst initialSetting = getInitialSetting();\nlet currentSetting = initialSetting;\nlet currentValue = getInitialValue(initialSetting);\nlet isWebListening = false;\nfunction startWebListener() {\n\tif (isWebListening) return;\n\tisWebListening = true;\n\tconst matcher = typeof window !== \"undefined\" ? window.matchMedia?.(\"(prefers-color-scheme: dark)\") : null;\n\tconst onSystemChange = () => {\n\t\tif (currentSetting === \"system\") updateValueFromSystem();\n\t};\n\tonSystemChange();\n\tmatcher?.addEventListener?.(\"change\", onSystemChange);\n}\nfunction resolveValue(setting) {\n\tif (setting === \"system\") return getSystemScheme();\n\treturn setting;\n}\nfunction updateValueFromSystem() {\n\tif (_forceScheme) return;\n\tconst value = resolveValue(\"system\");\n\tif (value !== currentValue) {\n\t\tcurrentValue = value;\n\t\tnotifyListeners();\n\t}\n}\nfunction updateScheme(setting) {\n\tif (_forceScheme) return;\n\tconst value = setting === \"system\" ? resolveValue(\"system\") : setting;\n\tif (value !== currentValue || currentSetting !== setting) {\n\t\tcurrentSetting = setting;\n\t\tcurrentValue = value;\n\t\tnotifyListeners();\n\t}\n}\nfunction setUserScheme(setting) {\n\tif (_forceScheme) return;\n\tsetStorageItem(storageKey, setting);\n\tupdateScheme(setting);\n}\nfunction getUserScheme() {\n\tif (_forceScheme) return {\n\t\tsetting: _forceScheme,\n\t\tvalue: _forceScheme\n\t};\n\treturn {\n\t\tsetting: currentSetting,\n\t\tvalue: currentValue\n\t};\n}\nfunction onUserSchemeChange(listener) {\n\tlisteners.add(listener);\n\tlistener(currentSetting, currentValue);\n\treturn () => {\n\t\tlisteners.delete(listener);\n\t};\n}\nfunction useUserScheme() {\n\tconst [state, setState] = useState(() => getUserScheme());\n\tconst snapshot = getUserScheme();\n\tconst resolvedState = state.setting === snapshot.setting && state.value === snapshot.value ? state : snapshot;\n\tuseIsomorphicLayoutEffect(() => {\n\t\tif (!_forceScheme) {\n\t\t\tconst stored = getStorageItem(storageKey);\n\t\t\tif (stored) updateScheme(stored);\n\t\t\tstartWebListener();\n\t\t}\n\t\treturn onUserSchemeChange((setting, value) => {\n\t\t\tsetState({\n\t\t\t\tsetting,\n\t\t\t\tvalue\n\t\t\t});\n\t\t});\n\t}, []);\n\treturn useMemo(() => ({\n\t\tsetting: resolvedState.setting,\n\t\tvalue: resolvedState.value,\n\t\tset: setUserScheme\n\t}), [resolvedState.setting, resolvedState.value]);\n}\n\nexport { getForceScheme, getUserScheme, onUserSchemeChange, setForceScheme, setUserScheme, useUserScheme };"],"mappings":"AAAA,SAASA,yBAAyB,QAAQ,oCAAoC;AAC9E,SAASC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AACzC,SAASC,cAAc,EAAEC,cAAc,QAAQ,mBAAe;AAC9D,SAASC,eAAe,QAAQ,oBAAgB;AAEhD,MAAMC,SAAS,GAAG,eAAgB,IAAIC,GAAG,CAAC,CAAC;AAC3C,MAAMC,UAAU,GAAG,aAAa;AAChC,IAAIC,YAAY,GAAG,IAAI;AACvB,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,EAAEC,kBAAkB,EAAEpB,cAAc,EAAEkB,aAAa,EAAEK,aAAa","ignoreList":[]}
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { useIsomorphicLayoutEffect } from "@vxrn/use-isomorphic-layout-effect";
|
|
2
|
-
import { useMemo, useState } from "react";
|
|
3
|
-
import { getStorageItem, setStorageItem } from "./safeStorage.native.js";
|
|
4
|
-
import { addAppearanceChangeListener, getAppearanceScheme, setAppearanceScheme } from "./userSchemeAppearance.native.js";
|
|
5
|
-
var listeners = /* @__PURE__ */new Set();
|
|
6
|
-
var storageKey = "vxrn-scheme";
|
|
7
|
-
var _forceScheme = null;
|
|
8
|
-
function notifyListeners() {
|
|
9
|
-
listeners.forEach(function (listener) {
|
|
10
|
-
listener(currentSetting, currentValue);
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
function restoreUnforcedScheme() {
|
|
14
|
-
var stored = getStorageItem(storageKey);
|
|
15
|
-
if (stored) {
|
|
16
|
-
currentSetting = stored;
|
|
17
|
-
currentValue = stored === "system" ? resolveValue("system") : stored;
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
currentSetting = "system";
|
|
21
|
-
currentValue = resolveValue("system");
|
|
22
|
-
}
|
|
23
|
-
function setForceScheme(scheme) {
|
|
24
|
-
var wasForced = _forceScheme;
|
|
25
|
-
if (wasForced === scheme) return;
|
|
26
|
-
_forceScheme = scheme;
|
|
27
|
-
if (scheme) {
|
|
28
|
-
currentSetting = scheme;
|
|
29
|
-
currentValue = scheme;
|
|
30
|
-
} else if (wasForced) {
|
|
31
|
-
restoreUnforcedScheme();
|
|
32
|
-
startWebListener();
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
function getForceScheme() {
|
|
36
|
-
return _forceScheme;
|
|
37
|
-
}
|
|
38
|
-
function getInitialSetting() {
|
|
39
|
-
var stored = getStorageItem(storageKey);
|
|
40
|
-
if (stored === "light" || stored === "dark" || stored === "system") return stored;
|
|
41
|
-
return "system";
|
|
42
|
-
}
|
|
43
|
-
function getInitialValue(setting) {
|
|
44
|
-
if (setting === "system") return getAppearanceScheme();
|
|
45
|
-
return setting;
|
|
46
|
-
}
|
|
47
|
-
var initialSetting = getInitialSetting();
|
|
48
|
-
var currentSetting = initialSetting;
|
|
49
|
-
var currentValue = getInitialValue(initialSetting);
|
|
50
|
-
addAppearanceChangeListener(function () {
|
|
51
|
-
if (currentSetting === "system") updateValueFromSystem();
|
|
52
|
-
});
|
|
53
|
-
var isWebListening = false;
|
|
54
|
-
function startWebListener() {
|
|
55
|
-
var _window_matchMedia, _window, _matcher_addEventListener;
|
|
56
|
-
if (isWebListening) return;
|
|
57
|
-
isWebListening = true;
|
|
58
|
-
var matcher = typeof window !== "undefined" ? (_window_matchMedia = (_window = window).matchMedia) === null || _window_matchMedia === void 0 ? void 0 : _window_matchMedia.call(_window, "(prefers-color-scheme: dark)") : null;
|
|
59
|
-
var onSystemChange = function () {
|
|
60
|
-
if (currentSetting === "system") updateValueFromSystem();
|
|
61
|
-
};
|
|
62
|
-
onSystemChange();
|
|
63
|
-
matcher === null || matcher === void 0 || (_matcher_addEventListener = matcher.addEventListener) == null || _matcher_addEventListener.call(matcher, "change", onSystemChange);
|
|
64
|
-
}
|
|
65
|
-
function resolveValue(setting) {
|
|
66
|
-
if (setting === "system") return getAppearanceScheme();
|
|
67
|
-
return setting;
|
|
68
|
-
}
|
|
69
|
-
function updateValueFromSystem() {
|
|
70
|
-
if (_forceScheme) return;
|
|
71
|
-
var value = resolveValue("system");
|
|
72
|
-
if (value !== currentValue) {
|
|
73
|
-
currentValue = value;
|
|
74
|
-
notifyListeners();
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
function updateScheme(setting) {
|
|
78
|
-
if (_forceScheme) return;
|
|
79
|
-
var value = setting === "system" ? resolveValue("system") : setting;
|
|
80
|
-
if (value !== currentValue || currentSetting !== setting) {
|
|
81
|
-
currentSetting = setting;
|
|
82
|
-
currentValue = value;
|
|
83
|
-
if (setting !== "system") setAppearanceScheme(value);else setAppearanceScheme("unspecified");
|
|
84
|
-
notifyListeners();
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
function setUserScheme(setting) {
|
|
88
|
-
if (_forceScheme) return;
|
|
89
|
-
setStorageItem(storageKey, setting);
|
|
90
|
-
updateScheme(setting);
|
|
91
|
-
}
|
|
92
|
-
function getUserScheme() {
|
|
93
|
-
if (_forceScheme) return {
|
|
94
|
-
setting: _forceScheme,
|
|
95
|
-
value: _forceScheme
|
|
96
|
-
};
|
|
97
|
-
return {
|
|
98
|
-
setting: currentSetting,
|
|
99
|
-
value: currentValue
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
function onUserSchemeChange(listener) {
|
|
103
|
-
listeners.add(listener);
|
|
104
|
-
listener(currentSetting, currentValue);
|
|
105
|
-
return function () {
|
|
106
|
-
listeners.delete(listener);
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
function useUserScheme() {
|
|
110
|
-
var [state, setState] = useState(function () {
|
|
111
|
-
return getUserScheme();
|
|
112
|
-
});
|
|
113
|
-
var snapshot = getUserScheme();
|
|
114
|
-
var resolvedState = state.setting === snapshot.setting && state.value === snapshot.value ? state : snapshot;
|
|
115
|
-
useIsomorphicLayoutEffect(function () {
|
|
116
|
-
if (!_forceScheme) {
|
|
117
|
-
var stored = getStorageItem(storageKey);
|
|
118
|
-
if (stored) updateScheme(stored);
|
|
119
|
-
startWebListener();
|
|
120
|
-
}
|
|
121
|
-
return onUserSchemeChange(function (setting, value) {
|
|
122
|
-
setState({
|
|
123
|
-
setting,
|
|
124
|
-
value
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
}, []);
|
|
128
|
-
return useMemo(function () {
|
|
129
|
-
return {
|
|
130
|
-
setting: resolvedState.setting,
|
|
131
|
-
value: resolvedState.value,
|
|
132
|
-
set: setUserScheme
|
|
133
|
-
};
|
|
134
|
-
}, [resolvedState.setting, resolvedState.value]);
|
|
135
|
-
}
|
|
136
|
-
export { getForceScheme, getUserScheme, onUserSchemeChange, setForceScheme, setUserScheme, useUserScheme };
|
|
137
|
-
//# sourceMappingURL=userScheme.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useIsomorphicLayoutEffect","useMemo","useState","getStorageItem","setStorageItem","addAppearanceChangeListener","getAppearanceScheme","setAppearanceScheme","listeners","Set","storageKey","_forceScheme","notifyListeners","forEach","listener","currentSetting","currentValue","restoreUnforcedScheme","stored","resolveValue","setForceScheme","scheme","wasForced","startWebListener","getForceScheme","getInitialSetting","getInitialValue","setting","initialSetting","updateValueFromSystem","isWebListening","_window_matchMedia","_window","_matcher_addEventListener","matcher","window","matchMedia","call","onSystemChange","addEventListener","value","updateScheme","setUserScheme","getUserScheme","onUserSchemeChange","add","delete","useUserScheme","state","setState","snapshot","resolvedState","set"],"sources":["userScheme.native.js"],"sourcesContent":["import { useIsomorphicLayoutEffect } from \"@vxrn/use-isomorphic-layout-effect\";\nimport { useMemo, useState } from \"react\";\nimport { getStorageItem, setStorageItem } from \"./safeStorage\";\nimport { addAppearanceChangeListener, getAppearanceScheme, setAppearanceScheme } from \"./userSchemeAppearance\";\n\nvar listeners = /* @__PURE__ */ new Set();\nvar storageKey = \"vxrn-scheme\";\nvar _forceScheme = null;\nfunction notifyListeners() {\n\tlisteners.forEach(function(listener) {\n\t\tlistener(currentSetting, currentValue);\n\t});\n}\nfunction restoreUnforcedScheme() {\n\tvar stored = getStorageItem(storageKey);\n\tif (stored) {\n\t\tcurrentSetting = stored;\n\t\tcurrentValue = stored === \"system\" ? resolveValue(\"system\") : stored;\n\t\treturn;\n\t}\n\tcurrentSetting = \"system\";\n\tcurrentValue = resolveValue(\"system\");\n}\nfunction setForceScheme(scheme) {\n\tvar wasForced = _forceScheme;\n\tif (wasForced === scheme) return;\n\t_forceScheme = scheme;\n\tif (scheme) {\n\t\tcurrentSetting = scheme;\n\t\tcurrentValue = scheme;\n\t} else if (wasForced) {\n\t\trestoreUnforcedScheme();\n\t\tstartWebListener();\n\t}\n}\nfunction getForceScheme() {\n\treturn _forceScheme;\n}\nfunction getInitialSetting() {\n\tvar stored = getStorageItem(storageKey);\n\tif (stored === \"light\" || stored === \"dark\" || stored === \"system\") return stored;\n\treturn \"system\";\n}\nfunction getInitialValue(setting) {\n\tif (setting === \"system\") return getAppearanceScheme();\n\treturn setting;\n}\nvar initialSetting = getInitialSetting();\nvar currentSetting = initialSetting;\nvar currentValue = getInitialValue(initialSetting);\naddAppearanceChangeListener(function() {\n\tif (currentSetting === \"system\") updateValueFromSystem();\n});\nvar isWebListening = false;\nfunction startWebListener() {\n\tvar _window_matchMedia, _window, _matcher_addEventListener;\n\tif (isWebListening) return;\n\tisWebListening = true;\n\tvar matcher = typeof window !== \"undefined\" ? (_window_matchMedia = (_window = window).matchMedia) === null || _window_matchMedia === void 0 ? void 0 : _window_matchMedia.call(_window, \"(prefers-color-scheme: dark)\") : null;\n\tvar onSystemChange = function() {\n\t\tif (currentSetting === \"system\") updateValueFromSystem();\n\t};\n\tonSystemChange();\n\tmatcher === null || matcher === void 0 || (_matcher_addEventListener = matcher.addEventListener) == null || _matcher_addEventListener.call(matcher, \"change\", onSystemChange);\n}\nfunction resolveValue(setting) {\n\tif (setting === \"system\") return getAppearanceScheme();\n\treturn setting;\n}\nfunction updateValueFromSystem() {\n\tif (_forceScheme) return;\n\tvar value = resolveValue(\"system\");\n\tif (value !== currentValue) {\n\t\tcurrentValue = value;\n\t\tnotifyListeners();\n\t}\n}\nfunction updateScheme(setting) {\n\tif (_forceScheme) return;\n\tvar value = setting === \"system\" ? resolveValue(\"system\") : setting;\n\tif (value !== currentValue || currentSetting !== setting) {\n\t\tcurrentSetting = setting;\n\t\tcurrentValue = value;\n\t\tif (setting !== \"system\") setAppearanceScheme(value);\n\t\telse setAppearanceScheme(\"unspecified\");\n\t\tnotifyListeners();\n\t}\n}\nfunction setUserScheme(setting) {\n\tif (_forceScheme) return;\n\tsetStorageItem(storageKey, setting);\n\tupdateScheme(setting);\n}\nfunction getUserScheme() {\n\tif (_forceScheme) return {\n\t\tsetting: _forceScheme,\n\t\tvalue: _forceScheme\n\t};\n\treturn {\n\t\tsetting: currentSetting,\n\t\tvalue: currentValue\n\t};\n}\nfunction onUserSchemeChange(listener) {\n\tlisteners.add(listener);\n\tlistener(currentSetting, currentValue);\n\treturn function() {\n\t\tlisteners.delete(listener);\n\t};\n}\nfunction useUserScheme() {\n\tvar [state, setState] = useState(function() {\n\t\treturn getUserScheme();\n\t});\n\tvar snapshot = getUserScheme();\n\tvar resolvedState = state.setting === snapshot.setting && state.value === snapshot.value ? state : snapshot;\n\tuseIsomorphicLayoutEffect(function() {\n\t\tif (!_forceScheme) {\n\t\t\tvar stored = getStorageItem(storageKey);\n\t\t\tif (stored) updateScheme(stored);\n\t\t\tstartWebListener();\n\t\t}\n\t\treturn onUserSchemeChange(function(setting, value) {\n\t\t\tsetState({\n\t\t\t\tsetting,\n\t\t\t\tvalue\n\t\t\t});\n\t\t});\n\t}, []);\n\treturn useMemo(function() {\n\t\treturn {\n\t\t\tsetting: resolvedState.setting,\n\t\t\tvalue: resolvedState.value,\n\t\t\tset: setUserScheme\n\t\t};\n\t}, [resolvedState.setting, resolvedState.value]);\n}\n\nexport { getForceScheme, getUserScheme, onUserSchemeChange, setForceScheme, setUserScheme, useUserScheme };"],"mappings":"AAAA,SAASA,yBAAyB,QAAQ,oCAAoC;AAC9E,SAASC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AACzC,SAASC,cAAc,EAAEC,cAAc,QAAQ,yBAAe;AAC9D,SAASC,2BAA2B,EAAEC,mBAAmB,EAAEC,mBAAmB,QAAQ,kCAAwB;AAE9G,IAAIC,SAAS,GAAG,eAAgB,IAAIC,GAAG,CAAC,CAAC;AACzC,IAAIC,UAAU,GAAG,aAAa;AAC9B,IAAIC,YAAY,GAAG,IAAI;AACvB,SAASC,eAAeA,CAAA,EAAG;EAC1BJ,SAAS,CAACK,OAAO,CA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AK,CAACrB,OAAO,KAAKuB,QAAQ,CAACvB,OAAO,IAAIqB,KAAK,CAACR,KAAK,KAAKU,QAAQ,CAACV,KAAK,GAAGQ,KAAK,GAAGE,QAAQ;EAC3GlD,yBAAyB,CAAC,YAAW;IACpC,IAAI,CAACW,YAAY,EAAE;MAClB,IAAIO,MAAM,GAAGf,cAAc,CAACO,UAAU,CAAC;MACvC,IAAIQ,MAAM,EAAEuB,YAAY,CAACvB,MAAM,CAAC;MAChCK,gBAAgB,CAAC,CAAC;IACnB;IACA,OAAOqB,kBAAkB,CAAC,UAASjB,OAAO,EAAEa,KAAK,EAAE;MAClDS,QAAQ,CAAC;QACRtB,OAAO;QACPa;MACD,CAAC,CAAC;IACH,CAAC,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EACN,OAAOvC,OAAO,CAAC,YAAW;IACzB,OAAO;MACN0B,OAAO,EAAEwB,aAAa,CAACxB,OAAO;MAC9Ba,KAAK,EAAEW,aAAa,CAACX,KAAK;MAC1BY,GAAG,EAAEV;IACN,CAAC;EACF,CAAC,EAAE,CAACS,aAAa,CAACxB,OAAO,EAAEwB,aAAa,CAACX,KAAK,CAAC,CAAC;AACjD;AAEA,SAAShB,cAAc,EAAEmB,aAAa,EAAEC,kBAAkB,EAAExB,cAAc,EAAEsB,aAAa,EAAEK,aAAa","ignoreList":[]}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { getSystemScheme } from "./systemScheme.mjs";
|
|
2
|
-
function getAppearanceScheme() {
|
|
3
|
-
return getSystemScheme();
|
|
4
|
-
}
|
|
5
|
-
function setAppearanceScheme(_scheme) {}
|
|
6
|
-
function addAppearanceChangeListener(_listener) {}
|
|
7
|
-
export { addAppearanceChangeListener, getAppearanceScheme, setAppearanceScheme };
|
|
8
|
-
//# sourceMappingURL=userSchemeAppearance.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["getSystemScheme","getAppearanceScheme","setAppearanceScheme","_scheme","addAppearanceChangeListener","_listener"],"sources":["../../src/userSchemeAppearance.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,eAAA,QAAoC;AAEtC,SAASC,oBAAA,EAA8B;EAC5C,OAAOD,eAAA,CAAgB;AACzB;AAEO,SAASE,oBAAoBC,OAAA,EAAiC,CAAC;AAE/D,SAASC,4BAA4BC,SAAA,EAAuB,CAAC","ignoreList":[]}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Appearance } from "react-native";
|
|
2
|
-
function getAppearanceScheme() {
|
|
3
|
-
return Appearance.getColorScheme() === "dark" ? "dark" : "light";
|
|
4
|
-
}
|
|
5
|
-
function setAppearanceScheme(scheme) {
|
|
6
|
-
Appearance.setColorScheme(scheme);
|
|
7
|
-
}
|
|
8
|
-
function addAppearanceChangeListener(listener) {
|
|
9
|
-
Appearance.addChangeListener(listener);
|
|
10
|
-
}
|
|
11
|
-
export { addAppearanceChangeListener, getAppearanceScheme, setAppearanceScheme };
|
|
12
|
-
//# sourceMappingURL=userSchemeAppearance.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["Appearance","getAppearanceScheme","getColorScheme","setAppearanceScheme","scheme","setColorScheme","addAppearanceChangeListener","listener","addChangeListener"],"sources":["../../src/userSchemeAppearance.native.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,UAAA,QAAkB;AACpB,SAASC,oBAAA,EAAsB;EAClC,OAAOD,UAAA,CAAWE,cAAA,CAAe,MAAM,SAAS,SAAS;AAC7D;AACO,SAASC,oBAAoBC,MAAA,EAAQ;EACxCJ,UAAA,CAAWK,cAAA,CAAeD,MAAM;AACpC;AACO,SAASE,4BAA4BC,QAAA,EAAU;EAClDP,UAAA,CAAWQ,iBAAA,CAAkBD,QAAQ;AACzC","ignoreList":[]}
|
package/types/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAS5C,YAAY,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAC5C,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAG7D,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACjE,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,aAAa,EACb,aAAa,GACd,MAAM,cAAc,CAAA;AAIrB,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,YAAoC,EACpC,aAAa,EACb,WAAW,GACZ,EAAE;IACD,QAAQ,EAAE,GAAG,CAAA;IACb,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAA;IACvC,+GAA+G;IAC/G,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,+HAA+H;IAC/H,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,2CAqEA;AAED,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,SAAS,EACT,UAAU,GACX,EAAE;IACD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;CACnB,2CA2BA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"safeStorage.d.ts","sourceRoot":"","sources":["../src/safeStorage.ts"],"names":[],"mappings":"AAOA,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAMzD;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAI/D"}
|