@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.
Files changed (2) hide show
  1. package/dist/index.js +47 -44
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { i as B, o as K, v as z } from "./plugin-lvjNLBe-.js";
2
- const g = {}, L = `
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: o = "data-o-theme",
33
+ attribute: a = "data-o-theme",
34
34
  attributeLightValue: s = t,
35
- attributeDarkValue: p = r,
36
- classLightValue: x = t,
37
- classDarkValue: k = r,
35
+ attributeDarkValue: c = r,
36
+ classLightValue: w = t,
37
+ classDarkValue: p = r,
38
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;
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(a) {
45
- if (c = a.base, f = a.command === "serve", d = a.build.outDir, u = !!a.vitepress, !u || !Array.isArray(a.vitepress.site.head))
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 w = a.vitepress.site.head.find((h) => {
47
+ const k = o.vitepress.site.head.find((x) => {
48
48
  var y, E;
49
- return h[0] === "script" && ((E = (y = h[1]) == null ? void 0 : y.src) == null ? void 0 : E.startsWith(`${c}${l}`));
49
+ return x[0] === "script" && ((E = (y = x[1]) == null ? void 0 : y.src) == null ? void 0 : E.startsWith(`${d}${l}`));
50
50
  });
51
- w ? w[1].src = `${c}${l}?t=${(/* @__PURE__ */ new Date()).getTime()}` : a.vitepress.site.head.push([
51
+ k ? k[1].src = `${d}${l}?t=${(/* @__PURE__ */ new Date()).getTime()}` : o.vitepress.site.head.push([
52
52
  "script",
53
53
  {
54
- src: `${c}${l}?t=${(/* @__PURE__ */ new Date()).getTime()}`
54
+ src: `${d}${l}?t=${(/* @__PURE__ */ new Date()).getTime()}`
55
55
  }
56
56
  ]);
57
57
  },
58
58
  generateBundle() {
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"));
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(a) {
62
- a.middlewares.use(`${c}${l}`, (w, h) => {
63
- h.setHeader("Content-Type", "application/javascript"), h.end(m);
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(a) {
67
- return u ? a : a.replace("</head>", `<script src="${c}${l}?t=${(/* @__PURE__ */ new Date()).getTime()}"><\/script></head>`);
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((o) => {
109
+ return new Promise((a) => {
108
110
  if (v) {
109
- o(!1);
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"), 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);
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", d), k.addEventListener("click", c), l.addEventListener("click", f);
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 (n) => {
266
- const t = n.target;
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 o = r.getAttribute("href");
273
- if (!o || o.startsWith("#") || !b(o))
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 s = new URL(o, window.location.href);
276
- if (A(s.hostname, e.whitelist))
278
+ const c = new URL(s, window.location.href);
279
+ if (A(c.hostname, e.whitelist))
277
280
  return;
278
- n.preventDefault(), await $(s.href, e) && ((r.getAttribute("target") || "_self") === "_blank" ? window.open(s.href, "_blank", "noopener,noreferrer") : window.location.href = s.href);
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 o = t.toString();
288
- if (b(o)) {
289
- const s = new URL(o, window.location.href);
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
- z as vAnalytics
312
+ O as vAnalytics
310
313
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opendesign-plus-test/plugins",
3
- "version": "0.0.1-rc.7",
3
+ "version": "0.0.1-rc.9",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public",