@opendesign-plus-test/plugins 0.0.1-rc.7 → 0.0.1-rc.9
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/index.js +47 -44
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as B, o as K, v as
|
|
2
|
-
const
|
|
1
|
+
import { i as B, o as K, v as O } from "./plugin-lvjNLBe-.js";
|
|
2
|
+
const f = {}, L = `
|
|
3
3
|
(function () {
|
|
4
4
|
function getCookie(key) {
|
|
5
5
|
const name = encodeURIComponent(key) + '=';
|
|
@@ -30,45 +30,47 @@ function R(e) {
|
|
|
30
30
|
cookieKey: n,
|
|
31
31
|
lightValue: t = "light",
|
|
32
32
|
darkValue: r = "dark",
|
|
33
|
-
attribute:
|
|
33
|
+
attribute: a = "data-o-theme",
|
|
34
34
|
attributeLightValue: s = t,
|
|
35
|
-
attributeDarkValue:
|
|
36
|
-
classLightValue:
|
|
37
|
-
classDarkValue:
|
|
35
|
+
attributeDarkValue: c = r,
|
|
36
|
+
classLightValue: w = t,
|
|
37
|
+
classDarkValue: p = r,
|
|
38
38
|
filename: l = "check-theme.js"
|
|
39
|
-
} = e,
|
|
40
|
-
let
|
|
39
|
+
} = e, g = L.replace(/\$COOKIE_KEY/g, n).replace(/\$LIGHT_VALUE/g, t).replace(/\$DARK_VALUE/g, r).replace(/\$CLASS_LIGHT_VALUE/g, w).replace(/\$CLASS_DARK_VALUE/g, p).replace(/\$ATTRIBUTE_NAME/g, a).replace(/\$ATTRIBUTE_LIGHT_VALUE/g, s).replace(/\$ATTRIBUTE_DARK_VALUE/g, c);
|
|
40
|
+
let d = "", h = !1, u = "", m = !1;
|
|
41
41
|
return {
|
|
42
42
|
name: "vite-check-theme-plugin",
|
|
43
43
|
enforce: "pre",
|
|
44
|
-
configResolved(
|
|
45
|
-
if (
|
|
44
|
+
configResolved(o) {
|
|
45
|
+
if (d = o.base, h = o.command === "serve", u = o.build.outDir, m = !!o.vitepress, !m || !Array.isArray(o.vitepress.site.head))
|
|
46
46
|
return;
|
|
47
|
-
const
|
|
47
|
+
const k = o.vitepress.site.head.find((x) => {
|
|
48
48
|
var y, E;
|
|
49
|
-
return
|
|
49
|
+
return x[0] === "script" && ((E = (y = x[1]) == null ? void 0 : y.src) == null ? void 0 : E.startsWith(`${d}${l}`));
|
|
50
50
|
});
|
|
51
|
-
|
|
51
|
+
k ? k[1].src = `${d}${l}?t=${(/* @__PURE__ */ new Date()).getTime()}` : o.vitepress.site.head.push([
|
|
52
52
|
"script",
|
|
53
53
|
{
|
|
54
|
-
src: `${
|
|
54
|
+
src: `${d}${l}?t=${(/* @__PURE__ */ new Date()).getTime()}`
|
|
55
55
|
}
|
|
56
56
|
]);
|
|
57
57
|
},
|
|
58
58
|
generateBundle() {
|
|
59
|
-
|
|
59
|
+
h || f.existsSync(f.join(u, l)) || (f.existsSync(u) || f.mkdirSync(u, { recursive: !0 }), f.writeFileSync(f.join(u, l), g, "utf-8"));
|
|
60
60
|
},
|
|
61
|
-
configureServer(
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
configureServer(o) {
|
|
62
|
+
o.middlewares.use(`${d}${l}`, (k, x) => {
|
|
63
|
+
x.setHeader("Content-Type", "application/javascript"), x.end(g);
|
|
64
64
|
});
|
|
65
65
|
},
|
|
66
|
-
transformIndexHtml(
|
|
67
|
-
return
|
|
66
|
+
transformIndexHtml(o) {
|
|
67
|
+
return m ? o : o.replace("</head>", `<script src="${d}${l}?t=${(/* @__PURE__ */ new Date()).getTime()}"><\/script></head>`);
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
71
|
function b(e) {
|
|
72
|
+
if (typeof window > "u")
|
|
73
|
+
return !1;
|
|
72
74
|
let n;
|
|
73
75
|
try {
|
|
74
76
|
n = new URL(e, window.location.href);
|
|
@@ -104,9 +106,9 @@ const T = {
|
|
|
104
106
|
let i = null, v = !1;
|
|
105
107
|
function C(e, n, t) {
|
|
106
108
|
const r = T[e];
|
|
107
|
-
return new Promise((
|
|
109
|
+
return new Promise((a) => {
|
|
108
110
|
if (v) {
|
|
109
|
-
|
|
111
|
+
a(!1);
|
|
110
112
|
return;
|
|
111
113
|
}
|
|
112
114
|
v = !0, _(), i || (i = document.createElement("div"), i.className = "elg-mask", i.innerHTML = `
|
|
@@ -123,14 +125,14 @@ function C(e, n, t) {
|
|
|
123
125
|
</div>
|
|
124
126
|
</div>
|
|
125
127
|
`, document.body.appendChild(i));
|
|
126
|
-
const s = i.querySelector(".elg-title"),
|
|
127
|
-
s.textContent = r.title,
|
|
128
|
-
const
|
|
129
|
-
i && (i.style.display = "none", i.removeEventListener("click",
|
|
130
|
-
},
|
|
131
|
-
|
|
128
|
+
const s = i.querySelector(".elg-title"), c = i.querySelector(".elg-message"), w = i.querySelector(".elg-url"), p = i.querySelector(".elg-cancel"), l = i.querySelector(".elg-confirm");
|
|
129
|
+
s.textContent = r.title, c.textContent = r.message(t), w.textContent = n, i.style.display = "flex";
|
|
130
|
+
const g = (m) => {
|
|
131
|
+
i && (i.style.display = "none", i.removeEventListener("click", u), p.removeEventListener("click", d), l.removeEventListener("click", h), v = !1, a(m));
|
|
132
|
+
}, d = () => g(!1), h = () => g(!0), u = (m) => {
|
|
133
|
+
m.target === i && g(!1);
|
|
132
134
|
};
|
|
133
|
-
i.addEventListener("click",
|
|
135
|
+
i.addEventListener("click", u), p.addEventListener("click", d), l.addEventListener("click", h);
|
|
134
136
|
});
|
|
135
137
|
}
|
|
136
138
|
function _() {
|
|
@@ -260,22 +262,23 @@ ${e}`;
|
|
|
260
262
|
return Promise.resolve(window.confirm(t));
|
|
261
263
|
}
|
|
262
264
|
function U(e) {
|
|
265
|
+
const n = window.open;
|
|
263
266
|
document.addEventListener(
|
|
264
267
|
"click",
|
|
265
|
-
async (
|
|
266
|
-
const
|
|
267
|
-
if (!t)
|
|
268
|
-
return;
|
|
269
|
-
const r = t.closest("a[href]");
|
|
268
|
+
async (t) => {
|
|
269
|
+
const r = t.target;
|
|
270
270
|
if (!r)
|
|
271
271
|
return;
|
|
272
|
-
const
|
|
273
|
-
if (!
|
|
272
|
+
const a = r.closest("a[href]");
|
|
273
|
+
if (!a)
|
|
274
|
+
return;
|
|
275
|
+
const s = a.getAttribute("href");
|
|
276
|
+
if (!s || s.startsWith("#") || !b(s))
|
|
274
277
|
return;
|
|
275
|
-
const
|
|
276
|
-
if (A(
|
|
278
|
+
const c = new URL(s, window.location.href);
|
|
279
|
+
if (A(c.hostname, e.whitelist))
|
|
277
280
|
return;
|
|
278
|
-
|
|
281
|
+
t.preventDefault(), await $(c.href, e) && ((a.getAttribute("target") || "_self") === "_blank" ? n.call(window, c.href, "_blank", "noopener,noreferrer") : window.location.href = c.href);
|
|
279
282
|
},
|
|
280
283
|
!0
|
|
281
284
|
);
|
|
@@ -284,9 +287,9 @@ function S(e) {
|
|
|
284
287
|
const n = window.open;
|
|
285
288
|
window.open = async function(t, ...r) {
|
|
286
289
|
if (t) {
|
|
287
|
-
const
|
|
288
|
-
if (b(
|
|
289
|
-
const s = new URL(
|
|
290
|
+
const a = t.toString();
|
|
291
|
+
if (b(a)) {
|
|
292
|
+
const s = new URL(a, window.location.href);
|
|
290
293
|
if (!A(s.hostname, e.whitelist) && !await $(s.href, e))
|
|
291
294
|
return null;
|
|
292
295
|
}
|
|
@@ -297,7 +300,7 @@ function S(e) {
|
|
|
297
300
|
function I(e = {}) {
|
|
298
301
|
return {
|
|
299
302
|
install() {
|
|
300
|
-
U(e), S(e);
|
|
303
|
+
typeof window > "u" || (U(e), S(e));
|
|
301
304
|
}
|
|
302
305
|
};
|
|
303
306
|
}
|
|
@@ -306,5 +309,5 @@ export {
|
|
|
306
309
|
I as createExternalLinkGuard,
|
|
307
310
|
B as initOpenDesignAnalytics,
|
|
308
311
|
K as oaReport,
|
|
309
|
-
|
|
312
|
+
O as vAnalytics
|
|
310
313
|
};
|