@scalar/use-hooks 0.1.10 → 0.1.12

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.
@@ -1 +1 @@
1
- {"version":3,"file":"useColorMode.d.ts","sourceRoot":"","sources":["../../src/useColorMode/useColorMode.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAS5E;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,GAAE,mBAAwB;;;;0BAc5B,SAAS;mCAOF,aAAa;EA+DlD"}
1
+ {"version":3,"file":"useColorMode.d.ts","sourceRoot":"","sources":["../../src/useColorMode/useColorMode.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAS5E;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,GAAE,mBAAwB;;;;0BAc5B,SAAS;mCAOF,aAAa;EAqElD"}
@@ -1,41 +1,41 @@
1
- import { ref as M, computed as c, watch as h, onMounted as w, onUnmounted as v } from "vue";
2
- import { z as y } from "zod";
3
- const o = M("dark"), g = y.enum(["dark", "light", "system"]).optional().catch(void 0);
4
- function C(i = {}) {
5
- var a;
6
- const { initialColorMode: s = "system", overrideColorMode: l } = i;
7
- function m() {
1
+ import { ref as w, computed as a, watch as y, onMounted as M, onUnmounted as h } from "vue";
2
+ import { z as p } from "zod";
3
+ const o = w("dark"), v = p.enum(["dark", "light", "system"]).optional().catch(void 0);
4
+ function C(s = {}) {
5
+ var i;
6
+ const { initialColorMode: c = "system", overrideColorMode: l } = s;
7
+ function u() {
8
8
  var e;
9
9
  o.value = n.value === "dark" ? "light" : "dark", !(typeof window > "u") && ((e = window == null ? void 0 : window.localStorage) == null || e.setItem("colorMode", o.value));
10
10
  }
11
- function u(e) {
11
+ function m(e) {
12
12
  var t;
13
13
  o.value = e, !(typeof window > "u") && ((t = window == null ? void 0 : window.localStorage) == null || t.setItem("colorMode", o.value));
14
14
  }
15
15
  function d() {
16
16
  var e;
17
- return typeof (window == null ? void 0 : window.matchMedia) != "function" || (e = window == null ? void 0 : window.matchMedia("(prefers-color-scheme: dark)")) != null && e.matches ? "dark" : "light";
17
+ return typeof window > "u" ? "light" : typeof (window == null ? void 0 : window.matchMedia) != "function" || (e = window == null ? void 0 : window.matchMedia("(prefers-color-scheme: dark)")) != null && e.matches ? "dark" : "light";
18
18
  }
19
- const n = c(() => o.value === "system" ? d() : o.value);
19
+ const n = a(() => o.value === "system" ? d() : o.value);
20
20
  function r(e) {
21
- if (typeof document > "u") return;
21
+ if (typeof document > "u" || typeof window > "u") return;
22
22
  (l ?? (e === "system" ? d() : e)) === "dark" ? (document.body.classList.add("dark-mode"), document.body.classList.remove("light-mode")) : (document.body.classList.add("light-mode"), document.body.classList.remove("dark-mode"));
23
23
  }
24
- const f = g.parse(
25
- (a = window == null ? void 0 : window.localStorage) == null ? void 0 : a.getItem("colorMode")
24
+ const f = v.parse(
25
+ typeof window < "u" ? (i = window == null ? void 0 : window.localStorage) == null ? void 0 : i.getItem("colorMode") : "system"
26
26
  );
27
- return o.value = f ?? s, h(o, r, { immediate: !0 }), w(() => {
28
- if (typeof (window == null ? void 0 : window.matchMedia) == "function") {
27
+ return o.value = f ?? c, y(o, r, { immediate: !0 }), M(() => {
28
+ if (typeof window < "u" && typeof (window == null ? void 0 : window.matchMedia) == "function") {
29
29
  const e = window.matchMedia("(prefers-color-scheme: dark)"), t = () => o.value === "system" && r("system");
30
- e.addEventListener("change", t), v(() => {
30
+ e.addEventListener("change", t), h(() => {
31
31
  e.removeEventListener("change", t);
32
32
  });
33
33
  }
34
34
  }), {
35
- colorMode: c(() => o.value),
35
+ colorMode: a(() => o.value),
36
36
  darkLightMode: n,
37
- toggleColorMode: m,
38
- setColorMode: u,
37
+ toggleColorMode: u,
38
+ setColorMode: m,
39
39
  getSystemModePreference: d
40
40
  };
41
41
  }
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "url": "git+https://github.com/scalar/scalar.git",
11
11
  "directory": "packages/use-hooks"
12
12
  },
13
- "version": "0.1.10",
13
+ "version": "0.1.12",
14
14
  "engines": {
15
15
  "node": ">=18"
16
16
  },
@@ -42,8 +42,8 @@
42
42
  "@vueuse/core": "^10.10.0",
43
43
  "vue": "^3.5.12",
44
44
  "zod": "^3.23.8",
45
- "@scalar/use-toasts": "0.7.7",
46
- "@scalar/themes": "0.9.57"
45
+ "@scalar/themes": "0.9.58",
46
+ "@scalar/use-toasts": "0.7.8"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@vitejs/plugin-vue": "^5.0.4",