@ohos-ports/vite-plugin-radar 0.11.0-beta.0

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.
@@ -0,0 +1,40 @@
1
+ const defaults = {
2
+ script: "https://snap.licdn.com/li.lms-analytics/insight.min.js",
3
+ noScript: "https://px.ads.linkedin.com/collect/",
4
+ async: true
5
+ };
6
+
7
+ function injectTag(options) {
8
+ const tags = [];
9
+ const properties = (Array.isArray(options) ? options : [options]).filter((property) => Boolean(property.id)).map((property) => ({ ...defaults, ...property }));
10
+ if (!properties.length)
11
+ return tags;
12
+ let template = "";
13
+ let noscriptTemplate = "";
14
+ template += "window._linkedin_data_partner_ids = window._linkedin_data_partner_ids || [];\n";
15
+ for (const property of properties) {
16
+ template += `window._linkedin_data_partner_ids.push(${property.id});
17
+ `;
18
+ noscriptTemplate += `<img height="1" width="1" style="display:none;" alt="" src="${property.noScript}?pid=${property.id}&fmt=gif" />`;
19
+ }
20
+ const [{ script, async }] = properties;
21
+ tags.push({
22
+ tag: "script",
23
+ children: template
24
+ });
25
+ tags.push({
26
+ tag: "script",
27
+ attrs: {
28
+ src: `${script}`,
29
+ async
30
+ }
31
+ });
32
+ tags.push({
33
+ tag: "noscript",
34
+ injectTo: "body-prepend",
35
+ children: noscriptTemplate
36
+ });
37
+ return tags;
38
+ }
39
+
40
+ export { injectTag as default };
@@ -0,0 +1,40 @@
1
+ 'use strict';
2
+
3
+ const defaults = {
4
+ script: "https://mc.yandex.ru/metrika/tag.js",
5
+ noScript: "https://mc.yandex.ru/watch/"
6
+ };
7
+
8
+ function injectTag(options) {
9
+ const tags = [];
10
+ const properties = (Array.isArray(options) ? options : [options]).filter((property) => Boolean(property.id)).map((property) => ({ ...defaults, ...property }));
11
+ if (!properties.length)
12
+ return tags;
13
+ const [{ script }] = properties;
14
+ let template = "";
15
+ let noscriptTemplate = "";
16
+ template += "(function(m,e,t,r,i,k,a){m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)};";
17
+ template += "m[i].l=1*new Date();k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)})";
18
+ template += `(window, document, "script", "${script}", "ym");`;
19
+ for (const property of properties) {
20
+ if (property.config)
21
+ template += `ym("${property.id}", "init", ${JSON.stringify(property.config)});
22
+ `;
23
+ else
24
+ template += `ym("${property.id}", "init");
25
+ `;
26
+ noscriptTemplate += `<img src="${property.noScript}${property.id}" style="position:absolute;left:-9999px;" alt="" />`;
27
+ }
28
+ tags.push({
29
+ tag: "script",
30
+ children: template
31
+ });
32
+ tags.push({
33
+ tag: "noscript",
34
+ injectTo: "body-prepend",
35
+ children: `<div>${noscriptTemplate}</div>`
36
+ });
37
+ return tags;
38
+ }
39
+
40
+ exports.default = injectTag;
@@ -0,0 +1,38 @@
1
+ const defaults = {
2
+ script: "https://mc.yandex.ru/metrika/tag.js",
3
+ noScript: "https://mc.yandex.ru/watch/"
4
+ };
5
+
6
+ function injectTag(options) {
7
+ const tags = [];
8
+ const properties = (Array.isArray(options) ? options : [options]).filter((property) => Boolean(property.id)).map((property) => ({ ...defaults, ...property }));
9
+ if (!properties.length)
10
+ return tags;
11
+ const [{ script }] = properties;
12
+ let template = "";
13
+ let noscriptTemplate = "";
14
+ template += "(function(m,e,t,r,i,k,a){m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)};";
15
+ template += "m[i].l=1*new Date();k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)})";
16
+ template += `(window, document, "script", "${script}", "ym");`;
17
+ for (const property of properties) {
18
+ if (property.config)
19
+ template += `ym("${property.id}", "init", ${JSON.stringify(property.config)});
20
+ `;
21
+ else
22
+ template += `ym("${property.id}", "init");
23
+ `;
24
+ noscriptTemplate += `<img src="${property.noScript}${property.id}" style="position:absolute;left:-9999px;" alt="" />`;
25
+ }
26
+ tags.push({
27
+ tag: "script",
28
+ children: template
29
+ });
30
+ tags.push({
31
+ tag: "noscript",
32
+ injectTo: "body-prepend",
33
+ children: `<div>${noscriptTemplate}</div>`
34
+ });
35
+ return tags;
36
+ }
37
+
38
+ export { injectTag as default };
@@ -0,0 +1,29 @@
1
+ 'use strict';
2
+
3
+ const defaults = {
4
+ script: "//bat.bing.com/bat.js",
5
+ async: 1
6
+ };
7
+
8
+ function injectTag(property) {
9
+ const tags = [];
10
+ if (!property.id)
11
+ return tags;
12
+ const { id, script, async } = { ...defaults, ...property };
13
+ let template = "";
14
+ template += "(function (w, d, t, r, u) {";
15
+ template += `var f, n, i; w[u] = w[u] || [], f = function () { var o = { ti: "${id}" };`;
16
+ template += 'o.q = w[u], w[u] = new UET(o), w[u].push("pageLoad") }, n = d.createElement(t), ';
17
+ template += `n.src = r, n.async = ${async}, n.onload = n.onreadystatechange = function () { `;
18
+ template += 'var s = this.readyState; s && s !== "loaded" && s !== "complete" || (f(), ';
19
+ template += "n.onload = n.onreadystatechange = null) }, i = d.getElementsByTagName(t)[0], ";
20
+ template += "i.parentNode.insertBefore(n, i) })";
21
+ template += `(window, document, "script", "${script}", "uetq");`;
22
+ tags.push({
23
+ tag: "script",
24
+ children: template
25
+ });
26
+ return tags;
27
+ }
28
+
29
+ exports.default = injectTag;
@@ -0,0 +1,27 @@
1
+ const defaults = {
2
+ script: "//bat.bing.com/bat.js",
3
+ async: 1
4
+ };
5
+
6
+ function injectTag(property) {
7
+ const tags = [];
8
+ if (!property.id)
9
+ return tags;
10
+ const { id, script, async } = { ...defaults, ...property };
11
+ let template = "";
12
+ template += "(function (w, d, t, r, u) {";
13
+ template += `var f, n, i; w[u] = w[u] || [], f = function () { var o = { ti: "${id}" };`;
14
+ template += 'o.q = w[u], w[u] = new UET(o), w[u].push("pageLoad") }, n = d.createElement(t), ';
15
+ template += `n.src = r, n.async = ${async}, n.onload = n.onreadystatechange = function () { `;
16
+ template += 'var s = this.readyState; s && s !== "loaded" && s !== "complete" || (f(), ';
17
+ template += "n.onload = n.onreadystatechange = null) }, i = d.getElementsByTagName(t)[0], ";
18
+ template += "i.parentNode.insertBefore(n, i) })";
19
+ template += `(window, document, "script", "${script}", "uetq");`;
20
+ tags.push({
21
+ tag: "script",
22
+ children: template
23
+ });
24
+ return tags;
25
+ }
26
+
27
+ export { injectTag as default };
@@ -0,0 +1,26 @@
1
+ 'use strict';
2
+
3
+ const defaults = {
4
+ script: "https://www.clarity.ms/tag/",
5
+ async: 1
6
+ };
7
+
8
+ function injectTag(property) {
9
+ const tags = [];
10
+ if (!property.id)
11
+ return tags;
12
+ const { id, script, async } = { ...defaults, ...property };
13
+ let template = "";
14
+ template += "(function(c,l,a,r,i,t,y){";
15
+ template += `c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};`;
16
+ template += `t=l.createElement(r);t.async=${async};t.src="${script}"+i;`;
17
+ template += "y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);";
18
+ template += `})(window, document, "clarity", "script", "${id}");`;
19
+ tags.push({
20
+ tag: "script",
21
+ children: template
22
+ });
23
+ return tags;
24
+ }
25
+
26
+ exports.default = injectTag;
@@ -0,0 +1,24 @@
1
+ const defaults = {
2
+ script: "https://www.clarity.ms/tag/",
3
+ async: 1
4
+ };
5
+
6
+ function injectTag(property) {
7
+ const tags = [];
8
+ if (!property.id)
9
+ return tags;
10
+ const { id, script, async } = { ...defaults, ...property };
11
+ let template = "";
12
+ template += "(function(c,l,a,r,i,t,y){";
13
+ template += `c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};`;
14
+ template += `t=l.createElement(r);t.async=${async};t.src="${script}"+i;`;
15
+ template += "y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);";
16
+ template += `})(window, document, "clarity", "script", "${id}");`;
17
+ tags.push({
18
+ tag: "script",
19
+ children: template
20
+ });
21
+ return tags;
22
+ }
23
+
24
+ export { injectTag as default };
package/dist/index.cjs ADDED
@@ -0,0 +1,57 @@
1
+ 'use strict';
2
+
3
+ function defineInjector(entry) {
4
+ return entry;
5
+ }
6
+ const INJECTORS = [
7
+ defineInjector({ key: "analytics", load: () => import('./chunks/index.cjs') }),
8
+ defineInjector({ key: "gtm", load: () => import('./chunks/index2.cjs') }),
9
+ defineInjector({ key: "pixel", load: () => import('./chunks/index3.cjs') }),
10
+ defineInjector({ key: "retargeting", load: () => import('./chunks/index4.cjs') }),
11
+ defineInjector({ key: "tongji", load: () => import('./chunks/index5.cjs') }),
12
+ defineInjector({ key: "linkedin", load: () => import('./chunks/index6.cjs') }),
13
+ defineInjector({ key: "metrica", load: () => import('./chunks/index7.cjs') }),
14
+ defineInjector({ key: "microsoft", load: () => import('./chunks/index8.cjs') }),
15
+ defineInjector({ key: "microsoftClarity", load: () => import('./chunks/index9.cjs') }),
16
+ defineInjector({ key: "hotjar", load: () => import('./chunks/index10.cjs') }),
17
+ defineInjector({ key: "fullStory", load: () => import('./chunks/index11.cjs') }),
18
+ defineInjector({
19
+ key: "unbounce",
20
+ enabled: (value) => value === true || typeof value === "object" && value.enabled === true,
21
+ load: () => import('./chunks/index12.cjs')
22
+ }),
23
+ defineInjector({ key: "tiktok", load: () => import('./chunks/index13.cjs') }),
24
+ defineInjector({ key: "simpleanalytics", load: () => import('./chunks/index14.cjs') }),
25
+ defineInjector({ key: "posthog", load: () => import('./chunks/index15.cjs') }),
26
+ defineInjector({ key: "plausible", load: () => import('./chunks/index16.cjs') })
27
+ ];
28
+ function VitePluginRadar({
29
+ enableDev = false,
30
+ ...options
31
+ }) {
32
+ let viteConfig;
33
+ return {
34
+ name: "vite-plugin-Radar",
35
+ configResolved(resolvedConfig) {
36
+ viteConfig = resolvedConfig;
37
+ },
38
+ async transformIndexHtml() {
39
+ if (viteConfig.command === "serve" && !enableDev)
40
+ return [];
41
+ const active = INJECTORS.filter((entry) => {
42
+ const value = options[entry.key];
43
+ if (value == null)
44
+ return false;
45
+ return entry.enabled ? entry.enabled(value) : Boolean(value);
46
+ });
47
+ const groups = await Promise.all(active.map(async (entry) => {
48
+ const inject = (await entry.load()).default;
49
+ return inject(options[entry.key]);
50
+ }));
51
+ return groups.flat();
52
+ }
53
+ };
54
+ }
55
+
56
+ exports.INJECTORS = INJECTORS;
57
+ exports.VitePluginRadar = VitePluginRadar;