@opendesign-plus-test/plugins 0.0.1-rc.6 → 0.0.1-rc.8
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 -55
- 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 p = {}, 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:
|
|
32
|
+
darkValue: r = "dark",
|
|
33
33
|
attribute: a = "data-o-theme",
|
|
34
|
-
attributeLightValue:
|
|
35
|
-
attributeDarkValue:
|
|
36
|
-
classLightValue:
|
|
37
|
-
classDarkValue:
|
|
38
|
-
filename:
|
|
39
|
-
} = e, g = L.replace(/\$COOKIE_KEY/g, n).replace(/\$LIGHT_VALUE/g, t).replace(/\$DARK_VALUE/g,
|
|
40
|
-
let
|
|
34
|
+
attributeLightValue: s = t,
|
|
35
|
+
attributeDarkValue: c = r,
|
|
36
|
+
classLightValue: w = t,
|
|
37
|
+
classDarkValue: f = r,
|
|
38
|
+
filename: l = "check-theme.js"
|
|
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, f).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
44
|
configResolved(o) {
|
|
45
|
-
if (
|
|
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 || p.existsSync(p.join(u, l)) || (p.existsSync(u) || p.mkdirSync(u, { recursive: !0 }), p.writeFileSync(p.join(u, l), g, "utf-8"));
|
|
60
60
|
},
|
|
61
61
|
configureServer(o) {
|
|
62
|
-
o.middlewares.use(`${
|
|
63
|
-
|
|
62
|
+
o.middlewares.use(`${d}${l}`, (k, x) => {
|
|
63
|
+
x.setHeader("Content-Type", "application/javascript"), x.end(g);
|
|
64
64
|
});
|
|
65
65
|
},
|
|
66
66
|
transformIndexHtml(o) {
|
|
67
|
-
return
|
|
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
|
-
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
|
|
106
|
+
const r = T[e];
|
|
107
107
|
return new Promise((a) => {
|
|
108
|
-
if (
|
|
109
|
-
|
|
108
|
+
if (v) {
|
|
109
|
+
a(!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"), c = i.querySelector(".elg-message"), w = i.querySelector(".elg-url"), f = i.querySelector(".elg-cancel"), l = i.querySelector(".elg-confirm");
|
|
127
|
+
s.textContent = r.title, c.textContent = r.message(t), w.textContent = n, i.style.display = "flex";
|
|
128
|
+
const g = (m) => {
|
|
129
|
+
i && (i.style.display = "none", i.removeEventListener("click", u), f.removeEventListener("click", d), l.removeEventListener("click", h), v = !1, a(m));
|
|
130
|
+
}, d = () => g(!1), h = () => g(!0), u = (m) => {
|
|
131
|
+
m.target === i && g(!1);
|
|
129
132
|
};
|
|
130
|
-
|
|
133
|
+
i.addEventListener("click", u), f.addEventListener("click", d), l.addEventListener("click", h);
|
|
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;
|
|
@@ -257,38 +260,39 @@ ${e}`;
|
|
|
257
260
|
return Promise.resolve(window.confirm(t));
|
|
258
261
|
}
|
|
259
262
|
function U(e) {
|
|
263
|
+
const n = window.open;
|
|
260
264
|
document.addEventListener(
|
|
261
265
|
"click",
|
|
262
|
-
async (
|
|
263
|
-
const
|
|
264
|
-
if (!
|
|
266
|
+
async (t) => {
|
|
267
|
+
const r = t.target;
|
|
268
|
+
if (!r)
|
|
265
269
|
return;
|
|
266
|
-
const
|
|
267
|
-
if (!
|
|
270
|
+
const a = r.closest("a[href]");
|
|
271
|
+
if (!a)
|
|
268
272
|
return;
|
|
269
|
-
const
|
|
270
|
-
if (!
|
|
273
|
+
const s = a.getAttribute("href");
|
|
274
|
+
if (!s || s.startsWith("#") || !b(s))
|
|
271
275
|
return;
|
|
272
|
-
const c = new URL(
|
|
273
|
-
if (
|
|
276
|
+
const c = new URL(s, window.location.href);
|
|
277
|
+
if (A(c.hostname, e.whitelist))
|
|
274
278
|
return;
|
|
275
|
-
|
|
279
|
+
t.preventDefault(), await $(c.href, e) && ((a.getAttribute("target") || "_self") === "_blank" ? n.call(window, c.href, "_blank", "noopener,noreferrer") : window.location.href = c.href);
|
|
276
280
|
},
|
|
277
281
|
!0
|
|
278
282
|
);
|
|
279
283
|
}
|
|
280
284
|
function S(e) {
|
|
281
285
|
const n = window.open;
|
|
282
|
-
window.open = async function(t, ...
|
|
286
|
+
window.open = async function(t, ...r) {
|
|
283
287
|
if (t) {
|
|
284
288
|
const a = t.toString();
|
|
285
|
-
if (
|
|
286
|
-
const
|
|
287
|
-
if (!
|
|
289
|
+
if (b(a)) {
|
|
290
|
+
const s = new URL(a, window.location.href);
|
|
291
|
+
if (!A(s.hostname, e.whitelist) && !await $(s.href, e))
|
|
288
292
|
return null;
|
|
289
293
|
}
|
|
290
294
|
}
|
|
291
|
-
return n.call(window, t, ...
|
|
295
|
+
return n.call(window, t, ...r);
|
|
292
296
|
};
|
|
293
297
|
}
|
|
294
298
|
function I(e = {}) {
|
|
@@ -303,5 +307,5 @@ export {
|
|
|
303
307
|
I as createExternalLinkGuard,
|
|
304
308
|
B as initOpenDesignAnalytics,
|
|
305
309
|
K as oaReport,
|
|
306
|
-
|
|
310
|
+
O as vAnalytics
|
|
307
311
|
};
|