@gospore/theme 1.0.164 → 1.0.165

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/theme.es.js CHANGED
@@ -73,7 +73,7 @@ function ee() {
73
73
  }
74
74
  //#endregion
75
75
  //#region src/Theme.vue?vue&type=script&setup=true&lang.ts
76
- var j = [], M = /* @__PURE__ */ new Set(), N = /* @__PURE__ */ new Map(), P = [], F, te = "(prefers-color-scheme: dark)", ne = "(prefers-reduced-motion: reduce)", re = 200, I = 4.5, ie = 1.8, ae = 1.15, oe = 1.08, L = 4.5, R = 3, z = "#ffffff", B = "#1f2228", V = /* @__PURE__ */ a({
76
+ var j = [], M = /* @__PURE__ */ new Set(), N = /* @__PURE__ */ new Map(), P = [], F, te = "(prefers-color-scheme: dark)", ne = "(prefers-reduced-motion: reduce)", re = 200, I = 4.5, ie = 1.8, ae = 1.15, oe = 1.08, L = 4.5, se = 3, R = "#ffffff", z = "#1f2228", B = /* @__PURE__ */ a({
77
77
  name: "Theme",
78
78
  __name: "Theme",
79
79
  props: {
@@ -118,7 +118,7 @@ var j = [], M = /* @__PURE__ */ new Set(), N = /* @__PURE__ */ new Map(), P = []
118
118
  }), e.style.setProperty(t, n), M.add(t);
119
119
  });
120
120
  }
121
- let p = W(te), h = W(ne), g = o("theme", null), _ = U(), v = d(_), y = null, b = d({ darkMode: D(_) }), x = { darkMode: b.value.darkMode }, S = !1;
121
+ let p = U(te), h = U(ne), g = o("theme", null), _ = H(), v = d(_), y = null, b = d({ darkMode: D(_) }), x = { darkMode: b.value.darkMode }, S = !1;
122
122
  E();
123
123
  let w = d(null);
124
124
  p.addEventListener("change", O), m(() => i.mode, () => {
@@ -126,27 +126,27 @@ var j = [], M = /* @__PURE__ */ new Set(), N = /* @__PURE__ */ new Map(), P = []
126
126
  }, { immediate: !0 }), m(() => g?.value.darkMode, () => {
127
127
  i.mode === void 0 && T();
128
128
  }), m(() => b.value.darkMode, (e, t) => {
129
- if (x.darkMode = e, !(!S || !V(x))) {
129
+ if (x.darkMode = e, !(!S || !B(x))) {
130
130
  if (t === void 0) {
131
131
  k(e);
132
132
  return;
133
133
  }
134
- se(() => {
135
- V(x) && k(e);
134
+ ce(() => {
135
+ B(x) && k(e);
136
136
  });
137
137
  }
138
138
  }, { immediate: !0 }), c(() => {
139
- p.removeEventListener("change", O), y !== null && typeof window < "u" && (window.cancelAnimationFrame(y), y = null), S && H(x);
139
+ p.removeEventListener("change", O), y !== null && typeof window < "u" && (window.cancelAnimationFrame(y), y = null), S && V(x);
140
140
  let e = j.indexOf($);
141
141
  e !== -1 && j.splice(e, 1), a();
142
142
  });
143
143
  function T() {
144
- let e = U(), t = D(e);
144
+ let e = H(), t = D(e);
145
145
  v.value = e, x.darkMode = t, E(), b.value.darkMode = t;
146
146
  }
147
147
  function E() {
148
148
  let e = g === null || i.mode !== void 0;
149
- e && !S ? S = ee(x) : !e && S && (H(x), S = !1);
149
+ e && !S ? S = ee(x) : !e && S && (V(x), S = !1);
150
150
  }
151
151
  function D(e) {
152
152
  return e === "dark" || e !== "light" && p.matches;
@@ -160,10 +160,10 @@ var j = [], M = /* @__PURE__ */ new Set(), N = /* @__PURE__ */ new Map(), P = []
160
160
  function ee(e) {
161
161
  return typeof document > "u" ? !1 : (P.length === 0 && (F = document.documentElement.getAttribute("dark-mode")), P.push(e), k(e.darkMode), !0);
162
162
  }
163
- function V(e) {
163
+ function B(e) {
164
164
  return P.at(-1) === e;
165
165
  }
166
- function H(e) {
166
+ function V(e) {
167
167
  let t = P.indexOf(e);
168
168
  if (t === -1) return;
169
169
  let n = t === P.length - 1;
@@ -175,7 +175,7 @@ var j = [], M = /* @__PURE__ */ new Set(), N = /* @__PURE__ */ new Map(), P = []
175
175
  }
176
176
  F === null ? document.documentElement.removeAttribute("dark-mode") : F !== void 0 && document.documentElement.setAttribute("dark-mode", F), F = void 0;
177
177
  }
178
- function se(e) {
178
+ function ce(e) {
179
179
  if (h.matches || typeof document > "u" || typeof window > "u") {
180
180
  e();
181
181
  return;
@@ -196,10 +196,10 @@ var j = [], M = /* @__PURE__ */ new Set(), N = /* @__PURE__ */ new Map(), P = []
196
196
  });
197
197
  }));
198
198
  }
199
- function U() {
199
+ function H() {
200
200
  return i.mode === void 0 && g ? g.value.darkMode ? "dark" : "light" : i.mode ?? C() ?? "auto";
201
201
  }
202
- function W(e) {
202
+ function U(e) {
203
203
  if (typeof window < "u" && typeof window.matchMedia == "function") try {
204
204
  return window.matchMedia(e);
205
205
  } catch {}
@@ -215,7 +215,7 @@ var j = [], M = /* @__PURE__ */ new Set(), N = /* @__PURE__ */ new Map(), P = []
215
215
  };
216
216
  }
217
217
  u("theme", b), u(A, w);
218
- function ce(e) {
218
+ function W(e) {
219
219
  if (!e) return null;
220
220
  let t = e.trim().toLowerCase();
221
221
  if (!/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i.exec(t)) return null;
@@ -225,66 +225,66 @@ var j = [], M = /* @__PURE__ */ new Set(), N = /* @__PURE__ */ new Map(), P = []
225
225
  }
226
226
  return t;
227
227
  }
228
- function le(e) {
229
- let t = ce(e);
228
+ function G(e) {
229
+ let t = W(e);
230
230
  return t ? {
231
231
  r: parseInt(t.slice(1, 3), 16),
232
232
  g: parseInt(t.slice(3, 5), 16),
233
233
  b: parseInt(t.slice(5, 7), 16)
234
234
  } : null;
235
235
  }
236
- function G({ r: e, g: t, b: n }) {
236
+ function K({ r: e, g: t, b: n }) {
237
237
  let r = (e) => e.toString(16).padStart(2, "0");
238
238
  return `#${r(e)}${r(t)}${r(n)}`;
239
239
  }
240
- function K(e) {
240
+ function q(e) {
241
241
  return Math.max(0, Math.min(1, e));
242
242
  }
243
- function q(e) {
243
+ function J(e) {
244
244
  return e <= .04045 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4;
245
245
  }
246
- function J(e) {
247
- let t = K(e);
246
+ function Y(e) {
247
+ let t = q(e);
248
248
  return t <= .0031308 ? 12.92 * t : 1.055 * t ** (1 / 2.4) - .055;
249
249
  }
250
- function ue({ r: e, g: t, b: n }) {
251
- let r = e / 255, i = t / 255, a = n / 255, o = q(r), s = q(i), c = q(a), l = .4122214708 * o + .5363325363 * s + .0514459929 * c, u = .2119034982 * o + .6806995451 * s + .1073969566 * c, d = .0883024619 * o + .2817188376 * s + .6299787005 * c, f = Math.cbrt(l), p = Math.cbrt(u), m = Math.cbrt(d), h = .2104542553 * f + .793617785 * p - .0040720468 * m, g = 1.9779984951 * f - 2.428592205 * p + .4505937099 * m, _ = .0259040371 * f + .7827717662 * p - .808675766 * m, v = Math.sqrt(g * g + _ * _), y = 180 / Math.PI * Math.atan2(_, g);
250
+ function le({ r: e, g: t, b: n }) {
251
+ let r = e / 255, i = t / 255, a = n / 255, o = J(r), s = J(i), c = J(a), l = .4122214708 * o + .5363325363 * s + .0514459929 * c, u = .2119034982 * o + .6806995451 * s + .1073969566 * c, d = .0883024619 * o + .2817188376 * s + .6299787005 * c, f = Math.cbrt(l), p = Math.cbrt(u), m = Math.cbrt(d), h = .2104542553 * f + .793617785 * p - .0040720468 * m, g = 1.9779984951 * f - 2.428592205 * p + .4505937099 * m, _ = .0259040371 * f + .7827717662 * p - .808675766 * m, v = Math.sqrt(g * g + _ * _), y = 180 / Math.PI * Math.atan2(_, g);
252
252
  return y < 0 && (y += 360), {
253
253
  l: h,
254
254
  c: v,
255
255
  h: y
256
256
  };
257
257
  }
258
- function de(e, t, n, r = !1) {
259
- let i = n * Math.PI / 180, a = t * Math.cos(i), o = t * Math.sin(i), s = e + .3963377774 * a + .2158037573 * o, c = e - .1055613458 * a - .0638541728 * o, l = e - .0894841775 * a - 1.291485548 * o, u = r ? K(s) : s, d = r ? K(c) : c, f = r ? K(l) : l;
258
+ function ue(e, t, n, r = !1) {
259
+ let i = n * Math.PI / 180, a = t * Math.cos(i), o = t * Math.sin(i), s = e + .3963377774 * a + .2158037573 * o, c = e - .1055613458 * a - .0638541728 * o, l = e - .0894841775 * a - 1.291485548 * o, u = r ? q(s) : s, d = r ? q(c) : c, f = r ? q(l) : l;
260
260
  if (!r && (u < -1e-4 || u > 1.0001 || d < -1e-4 || d > 1.0001 || f < -1e-4 || f > 1.0001)) return null;
261
261
  let p = u * u * u, m = d * d * d, h = f * f * f, g = 4.0767416621 * p - 3.3077115913 * m + .2309699292 * h, _ = -1.2684380046 * p + 2.6097574011 * m - .3413193965 * h, v = -.0041960863 * p - .7034186147 * m + 1.707614701 * h;
262
- if (r) g = K(g), _ = K(_), v = K(v);
262
+ if (r) g = q(g), _ = q(_), v = q(v);
263
263
  else if (g < -1e-4 || g > 1.0001 || _ < -1e-4 || _ > 1.0001 || v < -1e-4 || v > 1.0001) return null;
264
- let y = K(J(g)), b = K(J(_)), x = K(J(v));
264
+ let y = q(Y(g)), b = q(Y(_)), x = q(Y(v));
265
265
  return {
266
266
  r: Math.round(y * 255),
267
267
  g: Math.round(b * 255),
268
268
  b: Math.round(x * 255)
269
269
  };
270
270
  }
271
- function Y(e, t, n) {
271
+ function de(e, t, n) {
272
272
  let r = t;
273
273
  for (let t = 0; t < 8; t += 1) {
274
- let t = de(e, r, n);
274
+ let t = ue(e, r, n);
275
275
  if (t) return t;
276
276
  r *= .9;
277
277
  }
278
- return de(e, K(r), n, !0) || {
278
+ return ue(e, q(r), n, !0) || {
279
279
  r: 0,
280
280
  g: 0,
281
281
  b: 0
282
282
  };
283
283
  }
284
284
  function fe(e) {
285
- let t = le(e);
285
+ let t = G(e);
286
286
  if (!t) return 0;
287
- let n = q(t.r / 255), r = q(t.g / 255), i = q(t.b / 255);
287
+ let n = J(t.r / 255), r = J(t.g / 255), i = J(t.b / 255);
288
288
  return .2126 * n + .7152 * r + .0722 * i;
289
289
  }
290
290
  function X(e, t) {
@@ -292,11 +292,11 @@ var j = [], M = /* @__PURE__ */ new Set(), N = /* @__PURE__ */ new Map(), P = []
292
292
  return (i + .05) / (a + .05);
293
293
  }
294
294
  function pe(e, t, n = {}) {
295
- let r = n.minContrast ?? I, i = n.preferDark !== !1, a = Math.max(.01, Math.min(.06, (e.c || .12) * (n.chromaScale ?? .25))), o = n.initialLightness ?? (i ? .24 : .94), s = i ? -1 : 1, c = n.step ?? .03, l = K(o), u = G(Y(l, a, e.h)), d = X(t, u);
295
+ let r = n.minContrast ?? I, i = n.preferDark !== !1, a = Math.max(.01, Math.min(.06, (e.c || .12) * (n.chromaScale ?? .25))), o = n.initialLightness ?? (i ? .24 : .94), s = i ? -1 : 1, c = n.step ?? .03, l = q(o), u = K(de(l, a, e.h)), d = X(t, u);
296
296
  for (let n = 0; n < 48; n += 1) {
297
- let n = G(Y(l, a, e.h)), i = X(t, n);
297
+ let n = K(de(l, a, e.h)), i = X(t, n);
298
298
  if (i > d && (d = i, u = n), i >= r) return n;
299
- if (l = K(l + s * c), l === 0 || l === 1) break;
299
+ if (l = q(l + s * c), l === 0 || l === 1) break;
300
300
  }
301
301
  let f = "#000000", p = "#ffffff", m = X(t, f), h = X(t, p);
302
302
  return m >= r || h >= r ? m >= h ? f : p : u;
@@ -368,7 +368,7 @@ var j = [], M = /* @__PURE__ */ new Set(), N = /* @__PURE__ */ new Map(), P = []
368
368
  }
369
369
  function ve(e) {
370
370
  let t = e.l - he[5], n = e.c > .02 ? .02 : 0;
371
- return me.reduce((r, i, a) => (r[i] = G(Y(K(he[a] + t), Math.min(.4, Math.max(n, e.c * ge[a])), e.h)), r), {});
371
+ return me.reduce((r, i, a) => (r[i] = K(de(q(he[a] + t), Math.min(.4, Math.max(n, e.c * ge[a])), e.h)), r), {});
372
372
  }
373
373
  function ye(e, t) {
374
374
  let n = [
@@ -379,14 +379,14 @@ var j = [], M = /* @__PURE__ */ new Set(), N = /* @__PURE__ */ new Map(), P = []
379
379
  500,
380
380
  600,
381
381
  700
382
- ], r = Q(t, n, z, oe), i = n.indexOf(r), a = n[Math.min(i + 1, n.length - 1)], o = n[Math.min(i + 2, n.length - 1)], s = [
382
+ ], r = Q(t, n, R, oe), i = n.indexOf(r), a = n[Math.min(i + 1, n.length - 1)], o = n[Math.min(i + 2, n.length - 1)], s = [
383
383
  1e3,
384
384
  900,
385
385
  800,
386
386
  700,
387
387
  600,
388
388
  500
389
- ], c = Q(t, s, B, oe), l = s.indexOf(c), u = s[Math.min(l + 1, s.length - 1)], d = s[Math.min(l + 2, s.length - 1)], f = Q(t, [
389
+ ], c = Q(t, s, z, oe), l = s.indexOf(c), u = s[Math.min(l + 1, s.length - 1)], d = s[Math.min(l + 2, s.length - 1)], f = Q(t, [
390
390
  200,
391
391
  300,
392
392
  400,
@@ -394,25 +394,25 @@ var j = [], M = /* @__PURE__ */ new Set(), N = /* @__PURE__ */ new Map(), P = []
394
394
  600,
395
395
  700,
396
396
  800
397
- ], z, ae), p = Q(t, [
397
+ ], R, ae), p = Q(t, [
398
398
  900,
399
399
  800,
400
400
  700,
401
401
  600,
402
402
  500,
403
403
  400
404
- ], B, ae), m = [
404
+ ], z, ae), m = [
405
405
  600,
406
406
  700,
407
407
  800,
408
408
  900,
409
409
  1e3
410
- ], h = Q(t, m, z, ie), g = m.indexOf(h), _ = m[Math.min(g + 1, m.length - 1)], v = m[Math.min(g + 2, m.length - 1)], y = [
410
+ ], h = Q(t, m, R, ie), g = m.indexOf(h), _ = m[Math.min(g + 1, m.length - 1)], v = m[Math.min(g + 2, m.length - 1)], y = [
411
411
  400,
412
412
  300,
413
413
  200,
414
414
  100
415
- ], b = Q(t, y, B, ie), x = y.indexOf(b), S = y[Math.min(x + 1, y.length - 1)], C = y[Math.min(x + 2, y.length - 1)], w = {
415
+ ], b = Q(t, y, z, ie), x = y.indexOf(b), S = y[Math.min(x + 1, y.length - 1)], C = y[Math.min(x + 2, y.length - 1)], w = {
416
416
  "--color-brand-surface-soft-light": t[r],
417
417
  "--color-brand-surface-soft-hovered-light": t[a],
418
418
  "--color-brand-surface-soft-pressed-light": t[o],
@@ -432,31 +432,31 @@ var j = [], M = /* @__PURE__ */ new Set(), N = /* @__PURE__ */ new Map(), P = []
432
432
  minContrast: L,
433
433
  preferredCandidate: "light",
434
434
  preferredMinContrast: L,
435
- preferredSwitchDelta: R
435
+ preferredSwitchDelta: se
436
436
  }), w["--color-brand-on-subtle-dark"] = Z(e, w["--color-brand-surface-subtle-dark"], { minContrast: I }), w["--color-brand-on-strong-light"] = Z(e, w["--color-brand-surface-strong-light"], {
437
437
  minContrast: L,
438
438
  preferredCandidate: "light",
439
439
  preferredMinContrast: L,
440
- preferredSwitchDelta: R
440
+ preferredSwitchDelta: se
441
441
  }), w["--color-brand-on-strong-dark"] = Z(e, w["--color-brand-surface-strong-dark"], { minContrast: I }), w["--color-brand-text-light"] = _e(e, t, [
442
442
  600,
443
443
  700,
444
444
  800,
445
445
  900,
446
446
  1e3
447
- ], z, !0), w["--color-brand-text-dark"] = _e(e, t, [
447
+ ], R, !0), w["--color-brand-text-dark"] = _e(e, t, [
448
448
  400,
449
449
  300,
450
450
  200,
451
451
  100
452
- ], B, !1), w["--color-brand-icon-light"] = w["--color-brand-text-light"], w["--color-brand-icon-dark"] = w["--color-brand-text-dark"], w["--color-brand-border-light"] = w["--color-brand-text-light"], w["--color-brand-border-dark"] = w["--color-brand-text-dark"], w;
452
+ ], z, !1), w["--color-brand-icon-light"] = w["--color-brand-text-light"], w["--color-brand-icon-dark"] = w["--color-brand-text-dark"], w["--color-brand-border-light"] = w["--color-brand-text-light"], w["--color-brand-border-dark"] = w["--color-brand-text-dark"], w;
453
453
  }
454
454
  function be(e) {
455
- let t = ce(e);
455
+ let t = W(e);
456
456
  if (!t) return null;
457
- let n = le(t);
457
+ let n = G(t);
458
458
  if (!n) return null;
459
- let r = ue(n), i = ve(r);
459
+ let r = le(n), i = ve(r);
460
460
  return i[600] = t, {
461
461
  "--color-brand-seed": t,
462
462
  "--color-brand-100": i[100],
@@ -489,7 +489,7 @@ var j = [], M = /* @__PURE__ */ new Set(), N = /* @__PURE__ */ new Map(), P = []
489
489
  class: "theme__portal-host"
490
490
  }, null, 512)], 4));
491
491
  }
492
- }), H = /*#__PURE__*/ ((e, t) => {
492
+ }), V = /*#__PURE__*/ ((e, t) => {
493
493
  let n = e.__vccOpts || e;
494
494
  for (let [e, r] of t) n[e] = r;
495
495
  return n;
@@ -581,8 +581,75 @@ var j = [], M = /* @__PURE__ */ new Set(), N = /* @__PURE__ */ new Map(), P = []
581
581
  _: 1
582
582
  }, 8, ["open"]));
583
583
  }
584
- }), [["__scopeId", "data-v-80f281b2"]]);
584
+ }), [["__scopeId", "data-v-80f281b2"]]), ce = "(prefers-color-scheme: dark)", H = "#ffffff", U = "oklch(100% 0 250)", W = "#1f2228", G = "oklch(15% 0.0045 250)";
585
+ function K() {
586
+ return {
587
+ name: "gospore-theme-bootstrap",
588
+ enforce: "pre",
589
+ transformIndexHtml: {
590
+ order: "pre",
591
+ handler: () => [{
592
+ tag: "style",
593
+ children: J(),
594
+ injectTo: "head"
595
+ }, {
596
+ tag: "script",
597
+ children: q(),
598
+ injectTo: "head"
599
+ }]
600
+ }
601
+ };
602
+ }
603
+ function q() {
604
+ return `(() => {
605
+ const storageKey = ${JSON.stringify(b)};
606
+ const validModes = ${JSON.stringify(y)};
607
+ const encodedKey = encodeURIComponent(storageKey) + "=";
608
+ const storedCookie = document.cookie
609
+ .split("; ")
610
+ .find((entry) => entry.startsWith(encodedKey));
611
+ let mode = "auto";
612
+
613
+ if (storedCookie) {
614
+ try {
615
+ const storedMode = decodeURIComponent(storedCookie.slice(encodedKey.length));
616
+ if (validModes.includes(storedMode)) mode = storedMode;
617
+ } catch {}
618
+ }
619
+
620
+ let systemDark = false;
621
+ if (mode === "auto") {
622
+ try {
623
+ systemDark =
624
+ typeof window.matchMedia === "function" &&
625
+ window.matchMedia(${JSON.stringify(ce)}).matches;
626
+ } catch {}
627
+ }
628
+
629
+ document.documentElement.setAttribute(
630
+ "dark-mode",
631
+ String(mode === "dark" || (mode === "auto" && systemDark)),
632
+ );
633
+ })();`;
634
+ }
635
+ function J() {
636
+ return `html {
637
+ background-color: ${H};
638
+ background-color: ${U};
639
+ color-scheme: light;
640
+ }
641
+
642
+ html[dark-mode="true"] {
643
+ background-color: ${W};
644
+ background-color: ${G};
645
+ color-scheme: dark;
646
+ }
647
+
648
+ body {
649
+ background-color: inherit;
650
+ }`;
651
+ }
585
652
  //#endregion
586
- export { b as STORAGE_KEY, V as Theme, H as ThemeSwitcher, y as VALID_THEME_MODES, E as applyStoredModeToDocument, C as readStoredMode, A as themePortalHostKey, ee as useThemePortalTarget, w as writeStoredMode };
653
+ export { b as STORAGE_KEY, B as Theme, V as ThemeSwitcher, y as VALID_THEME_MODES, E as applyStoredModeToDocument, K as createThemeBootstrapPlugin, C as readStoredMode, A as themePortalHostKey, ee as useThemePortalTarget, w as writeStoredMode };
587
654
 
588
655
  //# sourceMappingURL=theme.es.js.map