heroshot 0.14.0 → 0.14.1
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,26 +1,34 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
2
|
+
import y from "@heroshot/manifest";
|
|
3
|
+
import { jsx as h, jsxs as I } from "react/jsx-runtime";
|
|
4
|
+
import $, { createContext as j, useContext as C, useMemo as g, useState as L, useEffect as z } from "react";
|
|
5
|
+
let x = null;
|
|
6
|
+
function N(e) {
|
|
7
|
+
x = e;
|
|
8
|
+
}
|
|
9
|
+
function O() {
|
|
10
|
+
return x;
|
|
11
|
+
}
|
|
12
|
+
function R(e, t) {
|
|
5
13
|
return e.screenshots[t];
|
|
6
14
|
}
|
|
7
|
-
function
|
|
15
|
+
function V(e, t = {}) {
|
|
8
16
|
const { slug: a, format: s } = e, { viewport: r, colorScheme: c } = t, n = [a];
|
|
9
17
|
r && n.push(r), c && n.push(c);
|
|
10
18
|
const i = s === "jpeg" ? "jpg" : "png";
|
|
11
19
|
return `${n.join("-")}.${i}`;
|
|
12
20
|
}
|
|
13
|
-
function
|
|
14
|
-
const s =
|
|
21
|
+
function A(e, t, a = {}) {
|
|
22
|
+
const s = V(t, a);
|
|
15
23
|
return `${e.outputDirectory}/${s}`;
|
|
16
24
|
}
|
|
17
25
|
function H(e, t, a) {
|
|
18
|
-
const { colorSchemes: s } = t, r = s.length > 0, c = (i) =>
|
|
26
|
+
const { colorSchemes: s } = t, r = s.length > 0, c = (i) => A(e, t, { viewport: a, colorScheme: i }), n = {
|
|
19
27
|
default: r ? c("light") : c()
|
|
20
28
|
};
|
|
21
29
|
return s.includes("light") && (n.light = c("light")), s.includes("dark") && (n.dark = c("dark")), n;
|
|
22
30
|
}
|
|
23
|
-
function
|
|
31
|
+
function F(e, t) {
|
|
24
32
|
const a = H(e, t), s = {};
|
|
25
33
|
for (const r of t.viewports)
|
|
26
34
|
s[r] = H(e, t, r);
|
|
@@ -29,15 +37,8 @@ function R(e, t) {
|
|
|
29
37
|
viewports: s
|
|
30
38
|
};
|
|
31
39
|
}
|
|
32
|
-
|
|
33
|
-
function
|
|
34
|
-
x = e;
|
|
35
|
-
}
|
|
36
|
-
function V() {
|
|
37
|
-
return x;
|
|
38
|
-
}
|
|
39
|
-
const D = $(null);
|
|
40
|
-
function _({
|
|
40
|
+
const D = j(null);
|
|
41
|
+
function G({
|
|
41
42
|
manifest: e,
|
|
42
43
|
children: t
|
|
43
44
|
}) {
|
|
@@ -48,9 +49,9 @@ function S() {
|
|
|
48
49
|
const { theme: e } = document.documentElement.dataset;
|
|
49
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 };
|
|
50
51
|
}
|
|
51
|
-
function
|
|
52
|
-
const e =
|
|
53
|
-
return
|
|
52
|
+
function W() {
|
|
53
|
+
const e = $.useRef(!1), [t, a] = L(() => S().isDark);
|
|
54
|
+
return z(() => {
|
|
54
55
|
const s = S();
|
|
55
56
|
e.current = s.hasThemeHandling;
|
|
56
57
|
const r = () => {
|
|
@@ -77,13 +78,13 @@ const k = {
|
|
|
77
78
|
tablet: 768,
|
|
78
79
|
desktop: 1280
|
|
79
80
|
};
|
|
80
|
-
function
|
|
81
|
+
function J({
|
|
81
82
|
name: e,
|
|
82
83
|
alt: t = "",
|
|
83
84
|
manifest: a,
|
|
84
85
|
className: s
|
|
85
86
|
}) {
|
|
86
|
-
const r =
|
|
87
|
+
const r = W(), c = C(D), n = a ?? c ?? O(), i = g(() => n ? R(n, e) : null, [n, e]), u = g(() => !i || !n ? null : F(n, i), [n, i]), v = g(() => {
|
|
87
88
|
if (!u) return "";
|
|
88
89
|
const { light: o, dark: f } = u;
|
|
89
90
|
return r && f ? f : !r && o ? o : u.default;
|
|
@@ -115,7 +116,7 @@ function q({
|
|
|
115
116
|
const o = `Heroshot: Screenshot "${e}" not found in config`;
|
|
116
117
|
return typeof console < "u" && console.warn(o), /* @__PURE__ */ h("span", { style: { color: "red", fontSize: "12px" }, children: o });
|
|
117
118
|
}
|
|
118
|
-
return P ? /* @__PURE__ */
|
|
119
|
+
return P ? /* @__PURE__ */ I("picture", { className: s, children: [
|
|
119
120
|
T.map((o) => /* @__PURE__ */ h(
|
|
120
121
|
"source",
|
|
121
122
|
{
|
|
@@ -127,8 +128,11 @@ function q({
|
|
|
127
128
|
/* @__PURE__ */ h("img", { src: v, alt: t, loading: "lazy" })
|
|
128
129
|
] }) : /* @__PURE__ */ h("img", { src: v, alt: t, className: s, loading: "lazy" });
|
|
129
130
|
}
|
|
131
|
+
(function() {
|
|
132
|
+
N(y);
|
|
133
|
+
})();
|
|
130
134
|
export {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
135
|
+
J as Heroshot,
|
|
136
|
+
G as HeroshotProvider,
|
|
137
|
+
N as setManifest
|
|
134
138
|
};
|
|
@@ -1,5 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
import manifest from './manifest.json';
|
|
3
|
-
setManifest(manifest);
|
|
4
|
-
export default manifest;
|
|
5
|
-
`),t.resolve??={},t.resolve.alias??={},t.resolve.alias["@heroshot/manifest"]=u,t.resolve.alias["virtual:heroshot-manifest"]=h,typeof e.webpack=="function"?e.webpack(t,m):t}}}exports.withHeroshot=p;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("node:fs"),i=require("node:path"),c=require("./getManifest-BMMzQAE9.cjs");function d(e){return e.startsWith("public/")?e.slice(7):e}function m(e={},l={}){return{...e,webpack(o,h){const r=process.cwd();let t=null;l.config?t=i.resolve(r,l.config):t=c.findConfig(r);let u=c.emptyManifest();if(t&&n.existsSync(t)){const s=c.loadManifest(t);s&&(u={...s,outputDirectory:d(s.outputDirectory)},console.log(`[heroshot] Loaded config from ${t}`))}else console.log("[heroshot] No config found, using empty manifest");const a=i.join(r,"node_modules",".heroshot");n.mkdirSync(a,{recursive:!0});const f=i.join(a,"manifest.json");return n.writeFileSync(f,JSON.stringify(u,null,2)),o.resolve??={},o.resolve.alias??={},o.resolve.alias["@heroshot/manifest"]=f,typeof e.webpack=="function"?e.webpack(o,h):o}}}exports.withHeroshot=m;
|
|
@@ -1,41 +1,32 @@
|
|
|
1
|
-
import { existsSync as
|
|
2
|
-
import { resolve as
|
|
3
|
-
import { f as
|
|
4
|
-
function
|
|
1
|
+
import { existsSync as u, mkdirSync as m, writeFileSync as p } from "node:fs";
|
|
2
|
+
import { resolve as h, join as c } from "node:path";
|
|
3
|
+
import { f as d, l as y, e as w } from "./getManifest-DfRVQbEx.js";
|
|
4
|
+
function g(e) {
|
|
5
5
|
return e.startsWith("public/") ? e.slice(7) : e;
|
|
6
6
|
}
|
|
7
|
-
function
|
|
7
|
+
function D(e = {}, i = {}) {
|
|
8
8
|
return {
|
|
9
9
|
...e,
|
|
10
|
-
webpack(t,
|
|
11
|
-
const
|
|
10
|
+
webpack(t, f) {
|
|
11
|
+
const r = process.cwd();
|
|
12
12
|
let o = null;
|
|
13
|
-
|
|
14
|
-
let
|
|
15
|
-
if (o &&
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
...
|
|
19
|
-
outputDirectory:
|
|
13
|
+
i.config ? o = h(r, i.config) : o = d(r);
|
|
14
|
+
let n = w();
|
|
15
|
+
if (o && u(o)) {
|
|
16
|
+
const s = y(o);
|
|
17
|
+
s && (n = {
|
|
18
|
+
...s,
|
|
19
|
+
outputDirectory: g(s.outputDirectory)
|
|
20
20
|
}, console.log(`[heroshot] Loaded config from ${o}`));
|
|
21
21
|
} else
|
|
22
22
|
console.log("[heroshot] No config found, using empty manifest");
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
const c = n(r, "client.js");
|
|
28
|
-
return m(
|
|
29
|
-
c,
|
|
30
|
-
`import { setManifest } from 'heroshot/next';
|
|
31
|
-
import manifest from './manifest.json';
|
|
32
|
-
setManifest(manifest);
|
|
33
|
-
export default manifest;
|
|
34
|
-
`
|
|
35
|
-
), t.resolve ??= {}, t.resolve.alias ??= {}, t.resolve.alias["@heroshot/manifest"] = l, t.resolve.alias["virtual:heroshot-manifest"] = c, typeof e.webpack == "function" ? e.webpack(t, u) : t;
|
|
23
|
+
const l = c(r, "node_modules", ".heroshot");
|
|
24
|
+
m(l, { recursive: !0 });
|
|
25
|
+
const a = c(l, "manifest.json");
|
|
26
|
+
return p(a, JSON.stringify(n, null, 2)), t.resolve ??= {}, t.resolve.alias ??= {}, t.resolve.alias["@heroshot/manifest"] = a, typeof e.webpack == "function" ? e.webpack(t, f) : t;
|
|
36
27
|
}
|
|
37
28
|
};
|
|
38
29
|
}
|
|
39
30
|
export {
|
|
40
|
-
|
|
31
|
+
D as withHeroshot
|
|
41
32
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("node:fs"),c=require("node:path"),i=require("./getManifest-BMMzQAE9.cjs");function h(n){return n.startsWith("public/")||n.startsWith("static/")?n.slice(7):n}const r="virtual:heroshot-manifest",f="\0"+r;function m(n={}){let t=null,l=i.emptyManifest(),a="heroshot/vue";return{name:"heroshot",configResolved(e){const o=e.root;if(e.plugins.some(s=>s.name.includes("svelte"))&&(a="heroshot/svelte"),n.config?t=c.resolve(o,n.config):t=i.findConfig(o),t&&d.existsSync(t)){const s=i.loadManifest(t);s&&(l={...s,outputDirectory:h(s.outputDirectory)},console.log(`[heroshot] Loaded config from ${t}`))}else console.log("[heroshot] No config found, using empty manifest")},transform(e,o){if(!(o.includes("\0")||o.includes("node_modules"))&&(e.includes("from 'heroshot/")||e.includes('from "heroshot/')))return e.includes(r)?void 0:`import '${r}';
|
|
2
|
+
${e}`},resolveId(e){if(e===r)return f},load(e){if(e===f)return`import { setManifest } from '${a}';
|
|
3
|
+
const manifest = ${JSON.stringify(l,null,2)};
|
|
3
4
|
setManifest(manifest);
|
|
4
|
-
export default manifest;`},handleHotUpdate({file:
|
|
5
|
+
export default manifest;`},handleHotUpdate({file:e,server:o}){if(t&&e===t){const u=i.loadManifest(t);if(u){l=u,console.log("[heroshot] Config updated");const s=o.moduleGraph.getModuleById(f);s&&(o.moduleGraph.invalidateModule(s),o.ws.send({type:"full-reload"}))}}}}}exports.heroshot=m;
|
|
@@ -1,44 +1,50 @@
|
|
|
1
|
-
import { existsSync as
|
|
1
|
+
import { existsSync as d } from "node:fs";
|
|
2
2
|
import { resolve as m } from "node:path";
|
|
3
|
-
import { e as
|
|
4
|
-
function p(
|
|
5
|
-
return
|
|
3
|
+
import { e as c, f as h, l as a } from "./getManifest-DfRVQbEx.js";
|
|
4
|
+
function p(n) {
|
|
5
|
+
return n.startsWith("public/") || n.startsWith("static/") ? n.slice(7) : n;
|
|
6
6
|
}
|
|
7
|
-
const
|
|
8
|
-
function D(
|
|
9
|
-
let
|
|
7
|
+
const i = "virtual:heroshot-manifest", f = "\0" + i;
|
|
8
|
+
function D(n = {}) {
|
|
9
|
+
let o = null, r = c(), u = "heroshot/vue";
|
|
10
10
|
return {
|
|
11
11
|
name: "heroshot",
|
|
12
|
-
configResolved(
|
|
13
|
-
const
|
|
14
|
-
if (
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
...
|
|
18
|
-
outputDirectory: p(
|
|
19
|
-
}, console.log(`[heroshot] Loaded config from ${
|
|
12
|
+
configResolved(e) {
|
|
13
|
+
const t = e.root;
|
|
14
|
+
if (e.plugins.some((s) => s.name.includes("svelte")) && (u = "heroshot/svelte"), n.config ? o = m(t, n.config) : o = h(t), o && d(o)) {
|
|
15
|
+
const s = a(o);
|
|
16
|
+
s && (r = {
|
|
17
|
+
...s,
|
|
18
|
+
outputDirectory: p(s.outputDirectory)
|
|
19
|
+
}, console.log(`[heroshot] Loaded config from ${o}`));
|
|
20
20
|
} else
|
|
21
21
|
console.log("[heroshot] No config found, using empty manifest");
|
|
22
22
|
},
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
// Auto-inject manifest import into entry modules so users don't need a separate plugin file
|
|
24
|
+
transform(e, t) {
|
|
25
|
+
if (!(t.includes("\0") || t.includes("node_modules")) && (e.includes("from 'heroshot/") || e.includes('from "heroshot/')))
|
|
26
|
+
return e.includes(i) ? void 0 : `import '${i}';
|
|
27
|
+
${e}`;
|
|
26
28
|
},
|
|
27
|
-
|
|
28
|
-
if (
|
|
29
|
-
return
|
|
30
|
-
|
|
29
|
+
resolveId(e) {
|
|
30
|
+
if (e === i)
|
|
31
|
+
return f;
|
|
32
|
+
},
|
|
33
|
+
load(e) {
|
|
34
|
+
if (e === f)
|
|
35
|
+
return `import { setManifest } from '${u}';
|
|
36
|
+
const manifest = ${JSON.stringify(r, null, 2)};
|
|
31
37
|
setManifest(manifest);
|
|
32
38
|
export default manifest;`;
|
|
33
39
|
},
|
|
34
40
|
// Hot reload on config changes
|
|
35
|
-
handleHotUpdate({ file:
|
|
36
|
-
if (
|
|
37
|
-
const
|
|
38
|
-
if (
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
|
|
41
|
+
handleHotUpdate({ file: e, server: t }) {
|
|
42
|
+
if (o && e === o) {
|
|
43
|
+
const l = a(o);
|
|
44
|
+
if (l) {
|
|
45
|
+
r = l, console.log("[heroshot] Config updated");
|
|
46
|
+
const s = t.moduleGraph.getModuleById(f);
|
|
47
|
+
s && (t.moduleGraph.invalidateModule(s), t.ws.send({ type: "full-reload" }));
|
|
42
48
|
}
|
|
43
49
|
}
|
|
44
50
|
}
|