@opendesign-plus-test/plugins 0.0.1-rc.6 → 0.0.1-rc.7
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 +59 -56
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as B, o as K, v as z } from "./plugin-lvjNLBe-.js";
|
|
2
|
-
const
|
|
2
|
+
const g = {}, L = `
|
|
3
3
|
(function () {
|
|
4
4
|
function getCookie(key) {
|
|
5
5
|
const name = encodeURIComponent(key) + '=';
|
|
@@ -29,46 +29,46 @@ function R(e) {
|
|
|
29
29
|
const {
|
|
30
30
|
cookieKey: n,
|
|
31
31
|
lightValue: t = "light",
|
|
32
|
-
darkValue:
|
|
33
|
-
attribute:
|
|
34
|
-
attributeLightValue:
|
|
35
|
-
attributeDarkValue:
|
|
36
|
-
classLightValue:
|
|
37
|
-
classDarkValue:
|
|
38
|
-
filename:
|
|
39
|
-
} = e,
|
|
40
|
-
let
|
|
32
|
+
darkValue: r = "dark",
|
|
33
|
+
attribute: o = "data-o-theme",
|
|
34
|
+
attributeLightValue: s = t,
|
|
35
|
+
attributeDarkValue: p = r,
|
|
36
|
+
classLightValue: x = t,
|
|
37
|
+
classDarkValue: k = r,
|
|
38
|
+
filename: l = "check-theme.js"
|
|
39
|
+
} = e, m = L.replace(/\$COOKIE_KEY/g, n).replace(/\$LIGHT_VALUE/g, t).replace(/\$DARK_VALUE/g, r).replace(/\$CLASS_LIGHT_VALUE/g, x).replace(/\$CLASS_DARK_VALUE/g, k).replace(/\$ATTRIBUTE_NAME/g, o).replace(/\$ATTRIBUTE_LIGHT_VALUE/g, s).replace(/\$ATTRIBUTE_DARK_VALUE/g, p);
|
|
40
|
+
let c = "", f = !1, d = "", u = !1;
|
|
41
41
|
return {
|
|
42
42
|
name: "vite-check-theme-plugin",
|
|
43
43
|
enforce: "pre",
|
|
44
|
-
configResolved(
|
|
45
|
-
if (
|
|
44
|
+
configResolved(a) {
|
|
45
|
+
if (c = a.base, f = a.command === "serve", d = a.build.outDir, u = !!a.vitepress, !u || !Array.isArray(a.vitepress.site.head))
|
|
46
46
|
return;
|
|
47
|
-
const
|
|
47
|
+
const w = a.vitepress.site.head.find((h) => {
|
|
48
48
|
var y, E;
|
|
49
|
-
return
|
|
49
|
+
return h[0] === "script" && ((E = (y = h[1]) == null ? void 0 : y.src) == null ? void 0 : E.startsWith(`${c}${l}`));
|
|
50
50
|
});
|
|
51
|
-
|
|
51
|
+
w ? w[1].src = `${c}${l}?t=${(/* @__PURE__ */ new Date()).getTime()}` : a.vitepress.site.head.push([
|
|
52
52
|
"script",
|
|
53
53
|
{
|
|
54
|
-
src: `${
|
|
54
|
+
src: `${c}${l}?t=${(/* @__PURE__ */ new Date()).getTime()}`
|
|
55
55
|
}
|
|
56
56
|
]);
|
|
57
57
|
},
|
|
58
58
|
generateBundle() {
|
|
59
|
-
|
|
59
|
+
f || g.existsSync(g.join(d, l)) || (g.existsSync(d) || g.mkdirSync(d, { recursive: !0 }), g.writeFileSync(g.join(d, l), m, "utf-8"));
|
|
60
60
|
},
|
|
61
|
-
configureServer(
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
configureServer(a) {
|
|
62
|
+
a.middlewares.use(`${c}${l}`, (w, h) => {
|
|
63
|
+
h.setHeader("Content-Type", "application/javascript"), h.end(m);
|
|
64
64
|
});
|
|
65
65
|
},
|
|
66
|
-
transformIndexHtml(
|
|
67
|
-
return
|
|
66
|
+
transformIndexHtml(a) {
|
|
67
|
+
return u ? a : a.replace("</head>", `<script src="${c}${l}?t=${(/* @__PURE__ */ new Date()).getTime()}"><\/script></head>`);
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
|
-
function
|
|
71
|
+
function b(e) {
|
|
72
72
|
let n;
|
|
73
73
|
try {
|
|
74
74
|
n = new URL(e, window.location.href);
|
|
@@ -77,12 +77,12 @@ function A(e) {
|
|
|
77
77
|
}
|
|
78
78
|
return /^https?:$/.test(n.protocol) ? n.hostname !== window.location.hostname : !1;
|
|
79
79
|
}
|
|
80
|
-
function
|
|
80
|
+
function A(e, n = []) {
|
|
81
81
|
return n.some((t) => {
|
|
82
82
|
if (t === "*") return !0;
|
|
83
83
|
if (t.startsWith("*.")) {
|
|
84
|
-
const
|
|
85
|
-
return e ===
|
|
84
|
+
const r = t.slice(2);
|
|
85
|
+
return e === r || e.endsWith(`.${r}`);
|
|
86
86
|
}
|
|
87
87
|
return e === t || e.endsWith(`.${t}`);
|
|
88
88
|
});
|
|
@@ -101,33 +101,36 @@ const T = {
|
|
|
101
101
|
confirm: "Continue"
|
|
102
102
|
}
|
|
103
103
|
};
|
|
104
|
-
let
|
|
104
|
+
let i = null, v = !1;
|
|
105
105
|
function C(e, n, t) {
|
|
106
|
-
const
|
|
107
|
-
return new Promise((
|
|
108
|
-
if (
|
|
109
|
-
|
|
106
|
+
const r = T[e];
|
|
107
|
+
return new Promise((o) => {
|
|
108
|
+
if (v) {
|
|
109
|
+
o(!1);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
v = !0, _(), i || (i = document.createElement("div"), i.className = "elg-mask", i.innerHTML = `
|
|
110
113
|
<div class="elg-modal">
|
|
111
114
|
<div class="elg-title"></div>
|
|
112
115
|
<div class="elg-content">
|
|
113
116
|
<div class="elg-message"></div>
|
|
114
|
-
<div class="elg-url"
|
|
117
|
+
<div class="elg-url"></div>
|
|
115
118
|
</div>
|
|
116
119
|
|
|
117
120
|
<div class="elg-actions">
|
|
118
|
-
<button class="elg-btn elg-confirm">${
|
|
119
|
-
<button class="elg-btn elg-cancel">${
|
|
121
|
+
<button class="elg-btn elg-confirm">${r.confirm}</button>
|
|
122
|
+
<button class="elg-btn elg-cancel">${r.cancel}</button>
|
|
120
123
|
</div>
|
|
121
124
|
</div>
|
|
122
|
-
`, document.body.appendChild(
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
},
|
|
128
|
-
|
|
125
|
+
`, document.body.appendChild(i));
|
|
126
|
+
const s = i.querySelector(".elg-title"), p = i.querySelector(".elg-message"), x = i.querySelector(".elg-url"), k = i.querySelector(".elg-cancel"), l = i.querySelector(".elg-confirm");
|
|
127
|
+
s.textContent = r.title, p.textContent = r.message(t), x.textContent = n, i.style.display = "flex";
|
|
128
|
+
const m = (u) => {
|
|
129
|
+
i && (i.style.display = "none", i.removeEventListener("click", d), k.removeEventListener("click", c), l.removeEventListener("click", f), v = !1, o(u));
|
|
130
|
+
}, c = () => m(!1), f = () => m(!0), d = (u) => {
|
|
131
|
+
u.target === i && m(!1);
|
|
129
132
|
};
|
|
130
|
-
|
|
133
|
+
i.addEventListener("click", d), k.addEventListener("click", c), l.addEventListener("click", f);
|
|
131
134
|
});
|
|
132
135
|
}
|
|
133
136
|
function _() {
|
|
@@ -195,7 +198,7 @@ function _() {
|
|
|
195
198
|
.elg-url,.elg-message {
|
|
196
199
|
font-size: 18px;
|
|
197
200
|
line-height: 26px;
|
|
198
|
-
|
|
201
|
+
word-break: break-all;
|
|
199
202
|
|
|
200
203
|
@media (max-width: 1440px) {
|
|
201
204
|
font-size: 16px;
|
|
@@ -263,32 +266,32 @@ function U(e) {
|
|
|
263
266
|
const t = n.target;
|
|
264
267
|
if (!t)
|
|
265
268
|
return;
|
|
266
|
-
const
|
|
267
|
-
if (!
|
|
269
|
+
const r = t.closest("a[href]");
|
|
270
|
+
if (!r)
|
|
268
271
|
return;
|
|
269
|
-
const
|
|
270
|
-
if (!
|
|
272
|
+
const o = r.getAttribute("href");
|
|
273
|
+
if (!o || o.startsWith("#") || !b(o))
|
|
271
274
|
return;
|
|
272
|
-
const
|
|
273
|
-
if (
|
|
275
|
+
const s = new URL(o, window.location.href);
|
|
276
|
+
if (A(s.hostname, e.whitelist))
|
|
274
277
|
return;
|
|
275
|
-
n.preventDefault(), await $(
|
|
278
|
+
n.preventDefault(), await $(s.href, e) && ((r.getAttribute("target") || "_self") === "_blank" ? window.open(s.href, "_blank", "noopener,noreferrer") : window.location.href = s.href);
|
|
276
279
|
},
|
|
277
280
|
!0
|
|
278
281
|
);
|
|
279
282
|
}
|
|
280
283
|
function S(e) {
|
|
281
284
|
const n = window.open;
|
|
282
|
-
window.open = async function(t, ...
|
|
285
|
+
window.open = async function(t, ...r) {
|
|
283
286
|
if (t) {
|
|
284
|
-
const
|
|
285
|
-
if (
|
|
286
|
-
const
|
|
287
|
-
if (!
|
|
287
|
+
const o = t.toString();
|
|
288
|
+
if (b(o)) {
|
|
289
|
+
const s = new URL(o, window.location.href);
|
|
290
|
+
if (!A(s.hostname, e.whitelist) && !await $(s.href, e))
|
|
288
291
|
return null;
|
|
289
292
|
}
|
|
290
293
|
}
|
|
291
|
-
return n.call(window, t, ...
|
|
294
|
+
return n.call(window, t, ...r);
|
|
292
295
|
};
|
|
293
296
|
}
|
|
294
297
|
function I(e = {}) {
|