heroshot 0.14.1 → 0.14.2
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,76 +1,76 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import y from "@heroshot/manifest";
|
|
3
|
-
import { jsx as h, jsxs as
|
|
4
|
-
import
|
|
5
|
-
let
|
|
3
|
+
import { jsx as h, jsxs as $ } from "react/jsx-runtime";
|
|
4
|
+
import I, { createContext as j, useContext as C, useMemo as g, useState as L, useEffect as z } from "react";
|
|
5
|
+
let S = null;
|
|
6
6
|
function N(e) {
|
|
7
|
-
|
|
7
|
+
S = e;
|
|
8
8
|
}
|
|
9
9
|
function O() {
|
|
10
|
-
return
|
|
10
|
+
return S;
|
|
11
11
|
}
|
|
12
|
-
function R(e,
|
|
13
|
-
return e.screenshots[
|
|
12
|
+
function R(e, n) {
|
|
13
|
+
return e.screenshots[n];
|
|
14
14
|
}
|
|
15
|
-
function V(e,
|
|
16
|
-
const { slug:
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
return `${
|
|
15
|
+
function V(e, n = {}) {
|
|
16
|
+
const { slug: c, format: s } = e, { viewport: t, colorScheme: i } = n, r = [c];
|
|
17
|
+
t && r.push(t), i && r.push(i);
|
|
18
|
+
const a = s === "jpeg" ? "jpg" : "png";
|
|
19
|
+
return `${r.join("-")}.${a}`;
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
const s = V(
|
|
23
|
-
return `${
|
|
21
|
+
function W(e, n, c = {}) {
|
|
22
|
+
const s = V(n, c), t = e.outputDirectory;
|
|
23
|
+
return `${t.startsWith("/") ? "" : "/"}${t}/${s}`;
|
|
24
24
|
}
|
|
25
|
-
function
|
|
26
|
-
const { colorSchemes: s } =
|
|
27
|
-
default:
|
|
25
|
+
function x(e, n, c) {
|
|
26
|
+
const { colorSchemes: s } = n, t = s.length > 0, i = (a) => W(e, n, { viewport: c, colorScheme: a }), r = {
|
|
27
|
+
default: t ? i("light") : i()
|
|
28
28
|
};
|
|
29
|
-
return s.includes("light") && (
|
|
29
|
+
return s.includes("light") && (r.light = i("light")), s.includes("dark") && (r.dark = i("dark")), r;
|
|
30
30
|
}
|
|
31
|
-
function
|
|
32
|
-
const
|
|
33
|
-
for (const
|
|
34
|
-
s[
|
|
31
|
+
function A(e, n) {
|
|
32
|
+
const c = x(e, n), s = {};
|
|
33
|
+
for (const t of n.viewports)
|
|
34
|
+
s[t] = x(e, n, t);
|
|
35
35
|
return {
|
|
36
|
-
...
|
|
36
|
+
...c,
|
|
37
37
|
viewports: s
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
40
|
const D = j(null);
|
|
41
41
|
function G({
|
|
42
42
|
manifest: e,
|
|
43
|
-
children:
|
|
43
|
+
children: n
|
|
44
44
|
}) {
|
|
45
|
-
return /* @__PURE__ */ h(D.Provider, { value: e, children:
|
|
45
|
+
return /* @__PURE__ */ h(D.Provider, { value: e, children: n });
|
|
46
46
|
}
|
|
47
|
-
function
|
|
47
|
+
function H() {
|
|
48
48
|
if (globalThis.window === void 0) return { isDark: !1, hasThemeHandling: !1 };
|
|
49
49
|
const { theme: e } = document.documentElement.dataset;
|
|
50
50
|
return e ? { isDark: e === "dark", hasThemeHandling: !0 } : document.documentElement.classList.contains("dark") ? { isDark: !0, hasThemeHandling: !0 } : document.documentElement.classList.length > 0 ? { isDark: !1, hasThemeHandling: !0 } : globalThis.matchMedia?.("(prefers-color-scheme: dark)").matches ? { isDark: !0, hasThemeHandling: !1 } : { isDark: !1, hasThemeHandling: !1 };
|
|
51
51
|
}
|
|
52
|
-
function
|
|
53
|
-
const e =
|
|
52
|
+
function F() {
|
|
53
|
+
const e = I.useRef(!1), [n, c] = L(() => H().isDark);
|
|
54
54
|
return z(() => {
|
|
55
|
-
const s =
|
|
55
|
+
const s = H();
|
|
56
56
|
e.current = s.hasThemeHandling;
|
|
57
|
-
const
|
|
57
|
+
const t = () => {
|
|
58
58
|
const { theme: u } = document.documentElement.dataset;
|
|
59
59
|
return u ? (e.current = !0, u === "dark") : document.documentElement.classList.contains("dark") ? (e.current = !0, !0) : e.current ? !1 : globalThis.matchMedia?.("(prefers-color-scheme: dark)").matches ?? !1;
|
|
60
|
-
},
|
|
61
|
-
e.current = !0,
|
|
60
|
+
}, i = new MutationObserver(() => {
|
|
61
|
+
e.current = !0, c(t());
|
|
62
62
|
});
|
|
63
|
-
|
|
63
|
+
i.observe(document.documentElement, {
|
|
64
64
|
attributes: !0,
|
|
65
65
|
attributeFilter: ["data-theme", "class"]
|
|
66
66
|
});
|
|
67
|
-
const
|
|
68
|
-
|
|
67
|
+
const r = globalThis.matchMedia?.("(prefers-color-scheme: dark)"), a = () => {
|
|
68
|
+
c(t());
|
|
69
69
|
};
|
|
70
|
-
return
|
|
71
|
-
|
|
70
|
+
return r?.addEventListener("change", a), () => {
|
|
71
|
+
i.disconnect(), r?.removeEventListener("change", a);
|
|
72
72
|
};
|
|
73
|
-
}, []),
|
|
73
|
+
}, []), n;
|
|
74
74
|
}
|
|
75
75
|
const k = {
|
|
76
76
|
mobile: 430,
|
|
@@ -80,16 +80,16 @@ const k = {
|
|
|
80
80
|
};
|
|
81
81
|
function J({
|
|
82
82
|
name: e,
|
|
83
|
-
alt:
|
|
84
|
-
manifest:
|
|
83
|
+
alt: n = "",
|
|
84
|
+
manifest: c,
|
|
85
85
|
className: s
|
|
86
86
|
}) {
|
|
87
|
-
const
|
|
87
|
+
const t = F(), i = C(D), r = c ?? i ?? O(), a = g(() => r ? R(r, e) : null, [r, e]), u = g(() => !a || !r ? null : A(r, a), [r, a]), v = g(() => {
|
|
88
88
|
if (!u) return "";
|
|
89
89
|
const { light: o, dark: f } = u;
|
|
90
|
-
return
|
|
91
|
-
}, [u,
|
|
92
|
-
if (!u || !
|
|
90
|
+
return t && f ? f : !t && o ? o : u.default;
|
|
91
|
+
}, [u, t]), T = g(() => {
|
|
92
|
+
if (!u || !a) return [];
|
|
93
93
|
const { viewports: o } = u, f = Object.keys(o);
|
|
94
94
|
if (f.length === 0) return [];
|
|
95
95
|
const b = [...f].sort((l, m) => {
|
|
@@ -102,31 +102,31 @@ function J({
|
|
|
102
102
|
const p = d.light || d.default, E = d.dark || d.light || d.default, w = k[l] || Number.parseInt(l.split("x")[0] || "1280", 10), M = m === b.length - 1;
|
|
103
103
|
return {
|
|
104
104
|
viewport: l,
|
|
105
|
-
srcset:
|
|
105
|
+
srcset: t ? E : p,
|
|
106
106
|
width: w,
|
|
107
107
|
media: M ? void 0 : `(max-width: ${w}px)`
|
|
108
108
|
};
|
|
109
109
|
}).filter((l) => l !== null);
|
|
110
|
-
}, [u,
|
|
111
|
-
if (!
|
|
110
|
+
}, [u, a, t]), P = T.length > 0;
|
|
111
|
+
if (!r) {
|
|
112
112
|
const o = "Heroshot: No manifest found. Add heroshot() plugin to vite config, use HeroshotProvider, or pass manifest prop.";
|
|
113
113
|
return typeof console < "u" && console.warn(o), /* @__PURE__ */ h("span", { style: { color: "red", fontSize: "12px" }, children: o });
|
|
114
114
|
}
|
|
115
|
-
if (!
|
|
115
|
+
if (!a) {
|
|
116
116
|
const o = `Heroshot: Screenshot "${e}" not found in config`;
|
|
117
117
|
return typeof console < "u" && console.warn(o), /* @__PURE__ */ h("span", { style: { color: "red", fontSize: "12px" }, children: o });
|
|
118
118
|
}
|
|
119
|
-
return P ? /* @__PURE__ */
|
|
119
|
+
return P ? /* @__PURE__ */ $("picture", { className: s, children: [
|
|
120
120
|
T.map((o) => /* @__PURE__ */ h(
|
|
121
121
|
"source",
|
|
122
122
|
{
|
|
123
123
|
srcSet: o.srcset,
|
|
124
124
|
media: o.media
|
|
125
125
|
},
|
|
126
|
-
`${o.viewport}-${
|
|
126
|
+
`${o.viewport}-${t}`
|
|
127
127
|
)),
|
|
128
|
-
/* @__PURE__ */ h("img", { src: v, alt:
|
|
129
|
-
] }) : /* @__PURE__ */ h("img", { src: v, alt:
|
|
128
|
+
/* @__PURE__ */ h("img", { src: v, alt: n, loading: "lazy" })
|
|
129
|
+
] }) : /* @__PURE__ */ h("img", { src: v, alt: n, className: s, loading: "lazy" });
|
|
130
130
|
}
|
|
131
131
|
(function() {
|
|
132
132
|
N(y);
|
|
@@ -1,74 +1,74 @@
|
|
|
1
1
|
import { jsx as h, jsxs as y } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
function z(e,
|
|
4
|
-
return e.screenshots[
|
|
2
|
+
import $, { createContext as I, useContext as j, useMemo as g, useState as C, useEffect as L } from "react";
|
|
3
|
+
function z(e, n) {
|
|
4
|
+
return e.screenshots[n];
|
|
5
5
|
}
|
|
6
|
-
function N(e,
|
|
7
|
-
const { slug:
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
return `${
|
|
6
|
+
function N(e, n = {}) {
|
|
7
|
+
const { slug: c, format: s } = e, { viewport: t, colorScheme: i } = n, r = [c];
|
|
8
|
+
t && r.push(t), i && r.push(i);
|
|
9
|
+
const a = s === "jpeg" ? "jpg" : "png";
|
|
10
|
+
return `${r.join("-")}.${a}`;
|
|
11
11
|
}
|
|
12
|
-
function O(e,
|
|
13
|
-
const s = N(
|
|
14
|
-
return `${
|
|
12
|
+
function O(e, n, c = {}) {
|
|
13
|
+
const s = N(n, c), t = e.outputDirectory;
|
|
14
|
+
return `${t.startsWith("/") ? "" : "/"}${t}/${s}`;
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
const { colorSchemes: s } =
|
|
18
|
-
default:
|
|
16
|
+
function x(e, n, c) {
|
|
17
|
+
const { colorSchemes: s } = n, t = s.length > 0, i = (a) => O(e, n, { viewport: c, colorScheme: a }), r = {
|
|
18
|
+
default: t ? i("light") : i()
|
|
19
19
|
};
|
|
20
|
-
return s.includes("light") && (
|
|
20
|
+
return s.includes("light") && (r.light = i("light")), s.includes("dark") && (r.dark = i("dark")), r;
|
|
21
21
|
}
|
|
22
|
-
function R(e,
|
|
23
|
-
const
|
|
24
|
-
for (const
|
|
25
|
-
s[
|
|
22
|
+
function R(e, n) {
|
|
23
|
+
const c = x(e, n), s = {};
|
|
24
|
+
for (const t of n.viewports)
|
|
25
|
+
s[t] = x(e, n, t);
|
|
26
26
|
return {
|
|
27
|
-
...
|
|
27
|
+
...c,
|
|
28
28
|
viewports: s
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
-
let
|
|
31
|
+
let S = null;
|
|
32
32
|
function Q(e) {
|
|
33
|
-
|
|
33
|
+
S = e;
|
|
34
34
|
}
|
|
35
35
|
function V() {
|
|
36
|
-
return
|
|
36
|
+
return S;
|
|
37
37
|
}
|
|
38
|
-
const D =
|
|
38
|
+
const D = I(null);
|
|
39
39
|
function _({
|
|
40
40
|
manifest: e,
|
|
41
|
-
children:
|
|
41
|
+
children: n
|
|
42
42
|
}) {
|
|
43
|
-
return /* @__PURE__ */ h(D.Provider, { value: e, children:
|
|
43
|
+
return /* @__PURE__ */ h(D.Provider, { value: e, children: n });
|
|
44
44
|
}
|
|
45
|
-
function
|
|
45
|
+
function H() {
|
|
46
46
|
if (globalThis.window === void 0) return { isDark: !1, hasThemeHandling: !1 };
|
|
47
47
|
const { theme: e } = document.documentElement.dataset;
|
|
48
48
|
return e ? { isDark: e === "dark", hasThemeHandling: !0 } : document.documentElement.classList.contains("dark") ? { isDark: !0, hasThemeHandling: !0 } : document.documentElement.classList.length > 0 ? { isDark: !1, hasThemeHandling: !0 } : globalThis.matchMedia?.("(prefers-color-scheme: dark)").matches ? { isDark: !0, hasThemeHandling: !1 } : { isDark: !1, hasThemeHandling: !1 };
|
|
49
49
|
}
|
|
50
|
-
function
|
|
51
|
-
const e =
|
|
50
|
+
function W() {
|
|
51
|
+
const e = $.useRef(!1), [n, c] = C(() => H().isDark);
|
|
52
52
|
return L(() => {
|
|
53
|
-
const s =
|
|
53
|
+
const s = H();
|
|
54
54
|
e.current = s.hasThemeHandling;
|
|
55
|
-
const
|
|
55
|
+
const t = () => {
|
|
56
56
|
const { theme: u } = document.documentElement.dataset;
|
|
57
57
|
return u ? (e.current = !0, u === "dark") : document.documentElement.classList.contains("dark") ? (e.current = !0, !0) : e.current ? !1 : globalThis.matchMedia?.("(prefers-color-scheme: dark)").matches ?? !1;
|
|
58
|
-
},
|
|
59
|
-
e.current = !0,
|
|
58
|
+
}, i = new MutationObserver(() => {
|
|
59
|
+
e.current = !0, c(t());
|
|
60
60
|
});
|
|
61
|
-
|
|
61
|
+
i.observe(document.documentElement, {
|
|
62
62
|
attributes: !0,
|
|
63
63
|
attributeFilter: ["data-theme", "class"]
|
|
64
64
|
});
|
|
65
|
-
const
|
|
66
|
-
|
|
65
|
+
const r = globalThis.matchMedia?.("(prefers-color-scheme: dark)"), a = () => {
|
|
66
|
+
c(t());
|
|
67
67
|
};
|
|
68
|
-
return
|
|
69
|
-
|
|
68
|
+
return r?.addEventListener("change", a), () => {
|
|
69
|
+
i.disconnect(), r?.removeEventListener("change", a);
|
|
70
70
|
};
|
|
71
|
-
}, []),
|
|
71
|
+
}, []), n;
|
|
72
72
|
}
|
|
73
73
|
const k = {
|
|
74
74
|
mobile: 430,
|
|
@@ -78,16 +78,16 @@ const k = {
|
|
|
78
78
|
};
|
|
79
79
|
function q({
|
|
80
80
|
name: e,
|
|
81
|
-
alt:
|
|
82
|
-
manifest:
|
|
81
|
+
alt: n = "",
|
|
82
|
+
manifest: c,
|
|
83
83
|
className: s
|
|
84
84
|
}) {
|
|
85
|
-
const
|
|
85
|
+
const t = W(), i = j(D), r = c ?? i ?? V(), a = g(() => r ? z(r, e) : null, [r, e]), u = g(() => !a || !r ? null : R(r, a), [r, a]), v = g(() => {
|
|
86
86
|
if (!u) return "";
|
|
87
87
|
const { light: o, dark: f } = u;
|
|
88
|
-
return
|
|
89
|
-
}, [u,
|
|
90
|
-
if (!u || !
|
|
88
|
+
return t && f ? f : !t && o ? o : u.default;
|
|
89
|
+
}, [u, t]), T = g(() => {
|
|
90
|
+
if (!u || !a) return [];
|
|
91
91
|
const { viewports: o } = u, f = Object.keys(o);
|
|
92
92
|
if (f.length === 0) return [];
|
|
93
93
|
const b = [...f].sort((l, m) => {
|
|
@@ -100,17 +100,17 @@ function q({
|
|
|
100
100
|
const p = d.light || d.default, E = d.dark || d.light || d.default, w = k[l] || Number.parseInt(l.split("x")[0] || "1280", 10), M = m === b.length - 1;
|
|
101
101
|
return {
|
|
102
102
|
viewport: l,
|
|
103
|
-
srcset:
|
|
103
|
+
srcset: t ? E : p,
|
|
104
104
|
width: w,
|
|
105
105
|
media: M ? void 0 : `(max-width: ${w}px)`
|
|
106
106
|
};
|
|
107
107
|
}).filter((l) => l !== null);
|
|
108
|
-
}, [u,
|
|
109
|
-
if (!
|
|
108
|
+
}, [u, a, t]), P = T.length > 0;
|
|
109
|
+
if (!r) {
|
|
110
110
|
const o = "Heroshot: No manifest found. Add heroshot() plugin to vite config, use HeroshotProvider, or pass manifest prop.";
|
|
111
111
|
return typeof console < "u" && console.warn(o), /* @__PURE__ */ h("span", { style: { color: "red", fontSize: "12px" }, children: o });
|
|
112
112
|
}
|
|
113
|
-
if (!
|
|
113
|
+
if (!a) {
|
|
114
114
|
const o = `Heroshot: Screenshot "${e}" not found in config`;
|
|
115
115
|
return typeof console < "u" && console.warn(o), /* @__PURE__ */ h("span", { style: { color: "red", fontSize: "12px" }, children: o });
|
|
116
116
|
}
|
|
@@ -121,10 +121,10 @@ function q({
|
|
|
121
121
|
srcSet: o.srcset,
|
|
122
122
|
media: o.media
|
|
123
123
|
},
|
|
124
|
-
`${o.viewport}-${
|
|
124
|
+
`${o.viewport}-${t}`
|
|
125
125
|
)),
|
|
126
|
-
/* @__PURE__ */ h("img", { src: v, alt:
|
|
127
|
-
] }) : /* @__PURE__ */ h("img", { src: v, alt:
|
|
126
|
+
/* @__PURE__ */ h("img", { src: v, alt: n, loading: "lazy" })
|
|
127
|
+
] }) : /* @__PURE__ */ h("img", { src: v, alt: n, className: s, loading: "lazy" });
|
|
128
128
|
}
|
|
129
129
|
export {
|
|
130
130
|
q as Heroshot,
|
|
@@ -2,27 +2,27 @@ function h(t, n) {
|
|
|
2
2
|
return t.screenshots[n];
|
|
3
3
|
}
|
|
4
4
|
function l(t, n = {}) {
|
|
5
|
-
const { slug:
|
|
6
|
-
|
|
5
|
+
const { slug: i, format: e } = t, { viewport: o, colorScheme: r } = n, s = [i];
|
|
6
|
+
o && s.push(o), r && s.push(r);
|
|
7
7
|
const c = e === "jpeg" ? "jpg" : "png";
|
|
8
8
|
return `${s.join("-")}.${c}`;
|
|
9
9
|
}
|
|
10
|
-
function f(t, n,
|
|
11
|
-
const e = l(n, o
|
|
12
|
-
return `${
|
|
10
|
+
function f(t, n, i = {}) {
|
|
11
|
+
const e = l(n, i), o = t.outputDirectory;
|
|
12
|
+
return `${o.startsWith("/") ? "" : "/"}${o}/${e}`;
|
|
13
13
|
}
|
|
14
|
-
function a(t, n,
|
|
15
|
-
const { colorSchemes: e } = n,
|
|
16
|
-
default:
|
|
14
|
+
function a(t, n, i) {
|
|
15
|
+
const { colorSchemes: e } = n, o = e.length > 0, r = (c) => f(t, n, { viewport: i, colorScheme: c }), s = {
|
|
16
|
+
default: o ? r("light") : r()
|
|
17
17
|
};
|
|
18
|
-
return e.includes("light") && (s.light =
|
|
18
|
+
return e.includes("light") && (s.light = r("light")), e.includes("dark") && (s.dark = r("dark")), s;
|
|
19
19
|
}
|
|
20
20
|
function g(t, n) {
|
|
21
|
-
const
|
|
22
|
-
for (const
|
|
23
|
-
e[
|
|
21
|
+
const i = a(t, n), e = {};
|
|
22
|
+
for (const o of n.viewports)
|
|
23
|
+
e[o] = a(t, n, o);
|
|
24
24
|
return {
|
|
25
|
-
...
|
|
25
|
+
...i,
|
|
26
26
|
viewports: e
|
|
27
27
|
};
|
|
28
28
|
}
|
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import { defineComponent as L, computed as
|
|
2
|
-
let
|
|
1
|
+
import { defineComponent as L, computed as h, ref as N, onMounted as T, onUnmounted as C, createElementBlock as m, openBlock as v, normalizeClass as x, createElementVNode as D, Fragment as I, renderList as j, toDisplayString as z } from "vue";
|
|
2
|
+
let E = null;
|
|
3
3
|
function G(n) {
|
|
4
|
-
|
|
4
|
+
E = n;
|
|
5
5
|
}
|
|
6
6
|
function B() {
|
|
7
|
-
return
|
|
7
|
+
return E;
|
|
8
8
|
}
|
|
9
9
|
function V(n, e) {
|
|
10
10
|
return n.screenshots[e];
|
|
11
11
|
}
|
|
12
12
|
function F(n, e = {}) {
|
|
13
|
-
const { slug:
|
|
14
|
-
|
|
13
|
+
const { slug: o, format: t } = n, { viewport: s, colorScheme: a } = e, r = [o];
|
|
14
|
+
s && r.push(s), a && r.push(a);
|
|
15
15
|
const l = t === "jpeg" ? "jpg" : "png";
|
|
16
|
-
return `${
|
|
16
|
+
return `${r.join("-")}.${l}`;
|
|
17
17
|
}
|
|
18
|
-
function O(n, e,
|
|
19
|
-
const t = F(e,
|
|
20
|
-
return `${
|
|
18
|
+
function O(n, e, o = {}) {
|
|
19
|
+
const t = F(e, o), s = n.outputDirectory;
|
|
20
|
+
return `${s.startsWith("/") ? "" : "/"}${s}/${t}`;
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
const { colorSchemes: t } = e,
|
|
24
|
-
default:
|
|
22
|
+
function _(n, e, o) {
|
|
23
|
+
const { colorSchemes: t } = e, s = t.length > 0, a = (l) => O(n, e, { viewport: o, colorScheme: l }), r = {
|
|
24
|
+
default: s ? a("light") : a()
|
|
25
25
|
};
|
|
26
|
-
return t.includes("light") && (
|
|
26
|
+
return t.includes("light") && (r.light = a("light")), t.includes("dark") && (r.dark = a("dark")), r;
|
|
27
27
|
}
|
|
28
|
-
function
|
|
29
|
-
const
|
|
30
|
-
for (const
|
|
31
|
-
t[
|
|
28
|
+
function W(n, e) {
|
|
29
|
+
const o = _(n, e), t = {};
|
|
30
|
+
for (const s of e.viewports)
|
|
31
|
+
t[s] = _(n, e, s);
|
|
32
32
|
return {
|
|
33
|
-
...
|
|
33
|
+
...o,
|
|
34
34
|
viewports: t
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
-
const
|
|
37
|
+
const A = ["srcset", "media"], Q = ["src", "alt"], R = ["src", "alt"], U = {
|
|
38
38
|
key: 2,
|
|
39
39
|
style: { color: "red", "font-size": "12px" }
|
|
40
40
|
}, J = /* @__PURE__ */ L({
|
|
@@ -46,78 +46,78 @@ const W = ["srcset", "media"], Q = ["src", "alt"], R = ["src", "alt"], U = {
|
|
|
46
46
|
class: {}
|
|
47
47
|
},
|
|
48
48
|
setup(n) {
|
|
49
|
-
const e = n,
|
|
50
|
-
let
|
|
51
|
-
function
|
|
52
|
-
return globalThis.window === void 0 ? !1 : document.documentElement.classList.contains("dark") ? !0 :
|
|
49
|
+
const e = n, o = h(() => e.manifest ?? B()), t = N(!1);
|
|
50
|
+
let s = !1;
|
|
51
|
+
function a() {
|
|
52
|
+
return globalThis.window === void 0 ? !1 : document.documentElement.classList.contains("dark") ? !0 : s ? !1 : !!globalThis.matchMedia?.("(prefers-color-scheme: dark)").matches;
|
|
53
53
|
}
|
|
54
54
|
T(() => {
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
|
|
55
|
+
s = document.documentElement.classList.length > 0 || document.documentElement.dataset.theme !== void 0, t.value = a();
|
|
56
|
+
const i = new MutationObserver(() => {
|
|
57
|
+
s = !0, t.value = document.documentElement.classList.contains("dark");
|
|
58
58
|
});
|
|
59
|
-
|
|
59
|
+
i.observe(document.documentElement, {
|
|
60
60
|
attributes: !0,
|
|
61
61
|
attributeFilter: ["class"]
|
|
62
62
|
});
|
|
63
|
-
const c = globalThis.matchMedia?.("(prefers-color-scheme: dark)"),
|
|
64
|
-
t.value =
|
|
63
|
+
const c = globalThis.matchMedia?.("(prefers-color-scheme: dark)"), u = () => {
|
|
64
|
+
t.value = a();
|
|
65
65
|
};
|
|
66
|
-
c?.addEventListener("change",
|
|
67
|
-
|
|
66
|
+
c?.addEventListener("change", u), C(() => {
|
|
67
|
+
i.disconnect(), c?.removeEventListener("change", u);
|
|
68
68
|
});
|
|
69
69
|
});
|
|
70
|
-
const
|
|
70
|
+
const r = h(() => o.value ? V(o.value, e.name) : null), l = h(() => !r.value || !o.value ? null : W(o.value, r.value)), w = h(() => {
|
|
71
71
|
if (!l.value) return "";
|
|
72
|
-
const { light:
|
|
73
|
-
return t.value && c ? c : !t.value &&
|
|
72
|
+
const { light: i, dark: c } = l.value;
|
|
73
|
+
return t.value && c ? c : !t.value && i ? i : l.value.default;
|
|
74
74
|
}), g = {
|
|
75
75
|
mobile: 430,
|
|
76
76
|
// iPhone 15/16 Pro Max viewport
|
|
77
77
|
tablet: 768,
|
|
78
78
|
desktop: 1280
|
|
79
|
-
}, y =
|
|
80
|
-
if (!l.value || !
|
|
81
|
-
const { viewports:
|
|
79
|
+
}, y = h(() => {
|
|
80
|
+
if (!l.value || !r.value) return [];
|
|
81
|
+
const { viewports: i } = l.value, c = Object.keys(i);
|
|
82
82
|
if (c.length === 0) return [];
|
|
83
|
-
const
|
|
83
|
+
const u = [...c].sort((f, p) => {
|
|
84
84
|
const d = g[f] || Number.parseInt(f.split("x")[0] || "1280", 10), b = g[p] || Number.parseInt(p.split("x")[0] || "1280", 10);
|
|
85
85
|
return d - b;
|
|
86
86
|
});
|
|
87
|
-
return
|
|
88
|
-
const d =
|
|
87
|
+
return u.map((f, p) => {
|
|
88
|
+
const d = i[f];
|
|
89
89
|
if (!d) return null;
|
|
90
|
-
const b = d.light || d.default,
|
|
90
|
+
const b = d.light || d.default, $ = d.dark || d.light || d.default, S = g[f] || Number.parseInt(f.split("x")[0] || "1280", 10), P = p === u.length - 1, H = t.value ? $ : b;
|
|
91
91
|
return {
|
|
92
92
|
viewport: f,
|
|
93
93
|
srcset: H,
|
|
94
94
|
width: S,
|
|
95
95
|
// Media query: max-width for this viewport (except for largest which is fallback)
|
|
96
|
-
media:
|
|
96
|
+
media: P ? void 0 : `(max-width: ${S}px)`
|
|
97
97
|
};
|
|
98
98
|
}).filter(Boolean);
|
|
99
|
-
}),
|
|
100
|
-
return k.value && typeof console < "u" && console.warn(k.value), (
|
|
99
|
+
}), M = h(() => y.value.length > 0), k = h(() => o.value ? r.value ? null : `Heroshot: Screenshot "${e.name}" not found in config` : "Heroshot: No manifest found. Add heroshot() plugin to vite config or pass manifest prop.");
|
|
100
|
+
return k.value && typeof console < "u" && console.warn(k.value), (i, c) => r.value && M.value ? (v(), m("picture", {
|
|
101
101
|
key: 0,
|
|
102
|
-
class:
|
|
102
|
+
class: x(e.class)
|
|
103
103
|
}, [
|
|
104
|
-
(v(!0),
|
|
105
|
-
key: `${
|
|
106
|
-
srcset:
|
|
107
|
-
media:
|
|
108
|
-
}, null, 8,
|
|
104
|
+
(v(!0), m(I, null, j(y.value, (u) => (v(), m("source", {
|
|
105
|
+
key: `${u.viewport}-${t.value}`,
|
|
106
|
+
srcset: u.srcset,
|
|
107
|
+
media: u.media
|
|
108
|
+
}, null, 8, A))), 128)),
|
|
109
109
|
D("img", {
|
|
110
110
|
src: w.value,
|
|
111
111
|
alt: n.alt,
|
|
112
112
|
loading: "lazy"
|
|
113
113
|
}, null, 8, Q)
|
|
114
|
-
], 2)) :
|
|
114
|
+
], 2)) : r.value ? (v(), m("img", {
|
|
115
115
|
key: 1,
|
|
116
116
|
src: w.value,
|
|
117
117
|
alt: n.alt,
|
|
118
|
-
class:
|
|
118
|
+
class: x(e.class),
|
|
119
119
|
loading: "lazy"
|
|
120
|
-
}, null, 10, R)) : (v(),
|
|
120
|
+
}, null, 10, R)) : (v(), m("span", U, z(k.value), 1));
|
|
121
121
|
}
|
|
122
122
|
});
|
|
123
123
|
export {
|