@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.
- package/LICENSE +21 -0
- package/README.md +337 -0
- package/dist/chunks/index.cjs +69 -0
- package/dist/chunks/index.mjs +67 -0
- package/dist/chunks/index10.cjs +30 -0
- package/dist/chunks/index10.mjs +28 -0
- package/dist/chunks/index11.cjs +29 -0
- package/dist/chunks/index11.mjs +27 -0
- package/dist/chunks/index12.cjs +28 -0
- package/dist/chunks/index12.mjs +26 -0
- package/dist/chunks/index13.cjs +48 -0
- package/dist/chunks/index13.mjs +46 -0
- package/dist/chunks/index14.cjs +39 -0
- package/dist/chunks/index14.mjs +37 -0
- package/dist/chunks/index15.cjs +28 -0
- package/dist/chunks/index15.mjs +26 -0
- package/dist/chunks/index16.cjs +27 -0
- package/dist/chunks/index16.mjs +25 -0
- package/dist/chunks/index2.cjs +39 -0
- package/dist/chunks/index2.mjs +37 -0
- package/dist/chunks/index3.cjs +43 -0
- package/dist/chunks/index3.mjs +41 -0
- package/dist/chunks/index4.cjs +38 -0
- package/dist/chunks/index4.mjs +36 -0
- package/dist/chunks/index5.cjs +37 -0
- package/dist/chunks/index5.mjs +35 -0
- package/dist/chunks/index6.cjs +42 -0
- package/dist/chunks/index6.mjs +40 -0
- package/dist/chunks/index7.cjs +40 -0
- package/dist/chunks/index7.mjs +38 -0
- package/dist/chunks/index8.cjs +29 -0
- package/dist/chunks/index8.mjs +27 -0
- package/dist/chunks/index9.cjs +26 -0
- package/dist/chunks/index9.mjs +24 -0
- package/dist/index.cjs +57 -0
- package/dist/index.d.cts +451 -0
- package/dist/index.d.mts +451 -0
- package/dist/index.d.ts +451 -0
- package/dist/index.mjs +54 -0
- package/package.json +36 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,451 @@
|
|
|
1
|
+
import { HtmlTagDescriptor, Plugin } from 'vite';
|
|
2
|
+
|
|
3
|
+
interface BaiduTongjiDefaults {
|
|
4
|
+
/**
|
|
5
|
+
* `hm.js` script source
|
|
6
|
+
*/
|
|
7
|
+
script?: string;
|
|
8
|
+
/**
|
|
9
|
+
* `async` attribute set on the injected script tag
|
|
10
|
+
*/
|
|
11
|
+
async?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Value pushed to `_hmt` for `_setAutoPageview`
|
|
14
|
+
*/
|
|
15
|
+
autoPageview?: boolean;
|
|
16
|
+
}
|
|
17
|
+
interface BaiduTongjiProperty extends BaiduTongjiDefaults {
|
|
18
|
+
id: string;
|
|
19
|
+
}
|
|
20
|
+
type BaiduTongjiOptions = BaiduTongjiProperty | BaiduTongjiProperty[];
|
|
21
|
+
|
|
22
|
+
declare global {
|
|
23
|
+
interface Window {
|
|
24
|
+
_hmt: any[];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface FacebookPixelDefaults {
|
|
29
|
+
/**
|
|
30
|
+
* `fbevents.js` script source
|
|
31
|
+
*/
|
|
32
|
+
script?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Tracking endpoint used by the `<noscript>` pixel
|
|
35
|
+
*/
|
|
36
|
+
noScript?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Event tracked on load (`fbq('track', <event>)`)
|
|
39
|
+
*/
|
|
40
|
+
event?: string;
|
|
41
|
+
}
|
|
42
|
+
interface FacebookPixel extends FacebookPixelDefaults {
|
|
43
|
+
/**
|
|
44
|
+
* Pixel tag
|
|
45
|
+
*/
|
|
46
|
+
id: string;
|
|
47
|
+
}
|
|
48
|
+
type FacebookPixelOption = FacebookPixel | FacebookPixel[];
|
|
49
|
+
|
|
50
|
+
declare global {
|
|
51
|
+
interface Window {
|
|
52
|
+
fbq: (event: string, id?: string, params?: Record<string, any>) => void;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
interface FullStoryDefaults {
|
|
57
|
+
host?: string;
|
|
58
|
+
script?: string;
|
|
59
|
+
namespace?: string;
|
|
60
|
+
/**
|
|
61
|
+
* The FullStory loader snippet (the IIFE that boots the `FS` API).
|
|
62
|
+
* Override only if you need to pin a different snippet version.
|
|
63
|
+
*/
|
|
64
|
+
loader?: string;
|
|
65
|
+
}
|
|
66
|
+
interface FullStoryOptions extends FullStoryDefaults {
|
|
67
|
+
org?: string;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
declare global {
|
|
71
|
+
interface Window {
|
|
72
|
+
_fs_host: any[];
|
|
73
|
+
_fs_script: any[];
|
|
74
|
+
_fs_org: any[];
|
|
75
|
+
_fs_namespace: any[];
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
interface GAConfiguration extends Record<string, any> {
|
|
80
|
+
send_page_view?: boolean;
|
|
81
|
+
allow_google_signals?: boolean;
|
|
82
|
+
allow_ad_personalization_signals?: boolean;
|
|
83
|
+
transport_url?: string;
|
|
84
|
+
cookie_domain?: string;
|
|
85
|
+
cookie_expires?: number;
|
|
86
|
+
cookie_prefix?: string;
|
|
87
|
+
cookie_update?: boolean;
|
|
88
|
+
cookie_flags?: string;
|
|
89
|
+
user_id?: string;
|
|
90
|
+
page_title?: string;
|
|
91
|
+
currency?: string;
|
|
92
|
+
debug_mode?: boolean;
|
|
93
|
+
}
|
|
94
|
+
interface GAConsentDefaults {
|
|
95
|
+
ad_storage?: 'granted' | 'denied';
|
|
96
|
+
analytics_storage?: 'granted' | 'denied';
|
|
97
|
+
wait_for_update?: number;
|
|
98
|
+
}
|
|
99
|
+
interface GoogleAnaliticsDefaults {
|
|
100
|
+
/**
|
|
101
|
+
* Origin serving `gtag.js` (e.g. a self-hosted proxy)
|
|
102
|
+
*/
|
|
103
|
+
source?: string;
|
|
104
|
+
/**
|
|
105
|
+
* Path appended to `source` to build the `gtag.js` URL
|
|
106
|
+
*/
|
|
107
|
+
basePath?: string;
|
|
108
|
+
/**
|
|
109
|
+
* `async` attribute set on the injected `gtag.js` script tag
|
|
110
|
+
*/
|
|
111
|
+
async?: boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Bootstrap snippet that defines `dataLayer` and the `gtag()` function
|
|
114
|
+
*/
|
|
115
|
+
loader?: string;
|
|
116
|
+
}
|
|
117
|
+
type GoogleAnaliticsMainProperty = GoogleAnaliticsProperty & GoogleAnaliticsDefaults & {
|
|
118
|
+
consentDefaults?: GAConsentDefaults;
|
|
119
|
+
injectTo?: HtmlTagDescriptor['injectTo'];
|
|
120
|
+
};
|
|
121
|
+
interface GoogleAnaliticsProperty {
|
|
122
|
+
id: string;
|
|
123
|
+
disable?: boolean;
|
|
124
|
+
config?: GAConfiguration;
|
|
125
|
+
persistentValues?: Record<string, string | number | boolean>;
|
|
126
|
+
}
|
|
127
|
+
type GoogleAnaliticsOptions = GoogleAnaliticsMainProperty | [GoogleAnaliticsMainProperty, ...GoogleAnaliticsProperty[]];
|
|
128
|
+
|
|
129
|
+
declare global {
|
|
130
|
+
interface Window {
|
|
131
|
+
dataLayer: any[];
|
|
132
|
+
gtag: (command: string, ...args: any[]) => void;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
interface GoogleTagManagerMainProperty {
|
|
137
|
+
id: string;
|
|
138
|
+
}
|
|
139
|
+
interface GoogleTagManagerEnvironment {
|
|
140
|
+
auth: string;
|
|
141
|
+
preview: string;
|
|
142
|
+
}
|
|
143
|
+
interface GoogleTagManagerDefaults {
|
|
144
|
+
/**
|
|
145
|
+
* `gtm.js` script source
|
|
146
|
+
*/
|
|
147
|
+
gtmBase?: string;
|
|
148
|
+
/**
|
|
149
|
+
* `ns.html` (noscript iframe) source
|
|
150
|
+
*/
|
|
151
|
+
nsBase?: string;
|
|
152
|
+
/**
|
|
153
|
+
* `async` attribute set on the injected `gtm.js` script tag
|
|
154
|
+
*/
|
|
155
|
+
async?: boolean;
|
|
156
|
+
/**
|
|
157
|
+
* Bootstrap snippet that initialises `dataLayer` and the `gtm.start` event
|
|
158
|
+
*/
|
|
159
|
+
loader?: string;
|
|
160
|
+
}
|
|
161
|
+
interface GoogleTagManagerDefaultProperty extends GoogleTagManagerDefaults {
|
|
162
|
+
environment?: GoogleTagManagerEnvironment;
|
|
163
|
+
}
|
|
164
|
+
type GoogleTagManagerProperty = GoogleTagManagerMainProperty & GoogleTagManagerDefaultProperty;
|
|
165
|
+
type GoogleTagManagerOptions = GoogleTagManagerProperty | GoogleTagManagerProperty[];
|
|
166
|
+
|
|
167
|
+
declare global {
|
|
168
|
+
interface Window {
|
|
169
|
+
dataLayer: any[];
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
interface HotjarDefaults {
|
|
174
|
+
/**
|
|
175
|
+
* Hotjar tracking script source prefix
|
|
176
|
+
*/
|
|
177
|
+
script?: string;
|
|
178
|
+
/**
|
|
179
|
+
* Hotjar snippet version (`hjsv`)
|
|
180
|
+
*/
|
|
181
|
+
version?: number;
|
|
182
|
+
/**
|
|
183
|
+
* `async` value set on the injected script element
|
|
184
|
+
*/
|
|
185
|
+
async?: number;
|
|
186
|
+
}
|
|
187
|
+
interface HotjarOptions extends HotjarDefaults {
|
|
188
|
+
id: number;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
declare global {
|
|
192
|
+
interface Window {
|
|
193
|
+
hj: any[];
|
|
194
|
+
_hjSettings: any[];
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
interface LinkedinInsightDefaults {
|
|
199
|
+
/**
|
|
200
|
+
* `insight.min.js` script source
|
|
201
|
+
*/
|
|
202
|
+
script?: string;
|
|
203
|
+
/**
|
|
204
|
+
* Collect endpoint used by the `<noscript>` pixel
|
|
205
|
+
*/
|
|
206
|
+
noScript?: string;
|
|
207
|
+
/**
|
|
208
|
+
* `async` attribute set on the injected script tag
|
|
209
|
+
*/
|
|
210
|
+
async?: boolean;
|
|
211
|
+
}
|
|
212
|
+
interface LinkedinInsightProperty extends LinkedinInsightDefaults {
|
|
213
|
+
id: string;
|
|
214
|
+
}
|
|
215
|
+
type LinkedinInsightOptions = LinkedinInsightProperty | LinkedinInsightProperty[];
|
|
216
|
+
|
|
217
|
+
declare global {
|
|
218
|
+
interface Window {
|
|
219
|
+
_linkedin_data_partner_ids: any[];
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
interface MicrosoftAdvertisingDefaults {
|
|
224
|
+
/**
|
|
225
|
+
* `bat.js` (UET) script source
|
|
226
|
+
*/
|
|
227
|
+
script?: string;
|
|
228
|
+
/**
|
|
229
|
+
* `async` value set on the injected script element
|
|
230
|
+
*/
|
|
231
|
+
async?: number;
|
|
232
|
+
}
|
|
233
|
+
interface MicrosoftAdvertisingOptions extends MicrosoftAdvertisingDefaults {
|
|
234
|
+
id: string;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
declare global {
|
|
238
|
+
interface Window {
|
|
239
|
+
uetq: any[];
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
interface MicrosoftClarityDefaults {
|
|
244
|
+
/**
|
|
245
|
+
* Clarity tag script source (the property id is appended to it)
|
|
246
|
+
*/
|
|
247
|
+
script?: string;
|
|
248
|
+
/**
|
|
249
|
+
* `async` value set on the injected script element
|
|
250
|
+
*/
|
|
251
|
+
async?: number;
|
|
252
|
+
}
|
|
253
|
+
interface MicrosoftClarityOptions extends MicrosoftClarityDefaults {
|
|
254
|
+
id: string;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
declare global {
|
|
258
|
+
interface Window {
|
|
259
|
+
clarity: any[];
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
interface PlausibleAnalyticsDefaults {
|
|
264
|
+
/**
|
|
265
|
+
* Tracking script source
|
|
266
|
+
*/
|
|
267
|
+
script?: string;
|
|
268
|
+
/**
|
|
269
|
+
* `defer` attribute set on the injected script tag
|
|
270
|
+
*/
|
|
271
|
+
defer?: boolean;
|
|
272
|
+
}
|
|
273
|
+
interface PlausibleAnalyticsOptions extends PlausibleAnalyticsDefaults {
|
|
274
|
+
enabled: boolean;
|
|
275
|
+
hostname?: string;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
interface PostHogAnalyticsDefaults {
|
|
279
|
+
/**
|
|
280
|
+
* The PostHog loader snippet (the `array.js` bootstrap).
|
|
281
|
+
* Override only if you need to pin a different snippet version.
|
|
282
|
+
*/
|
|
283
|
+
loader?: string;
|
|
284
|
+
}
|
|
285
|
+
interface PostHogAnalyticsOptions extends PostHogAnalyticsDefaults {
|
|
286
|
+
enabled: boolean;
|
|
287
|
+
token: string;
|
|
288
|
+
api_host: string;
|
|
289
|
+
config?: Record<string, any>;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
interface SimpleAnalyticsDefaults {
|
|
293
|
+
/**
|
|
294
|
+
* Tracking script source
|
|
295
|
+
*/
|
|
296
|
+
script?: string;
|
|
297
|
+
/**
|
|
298
|
+
* `<noscript>` pixel source
|
|
299
|
+
*/
|
|
300
|
+
noScript?: string;
|
|
301
|
+
/**
|
|
302
|
+
* `async` attribute set on the injected script tag
|
|
303
|
+
*/
|
|
304
|
+
async?: boolean;
|
|
305
|
+
/**
|
|
306
|
+
* `defer` attribute set on the injected script tag
|
|
307
|
+
*/
|
|
308
|
+
defer?: boolean;
|
|
309
|
+
}
|
|
310
|
+
interface SimpleAnalyticsOptions extends SimpleAnalyticsDefaults {
|
|
311
|
+
enabled: boolean;
|
|
312
|
+
hostname?: string;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
interface TikTokPixelDefaults {
|
|
316
|
+
/**
|
|
317
|
+
* TikTok pixel events script source
|
|
318
|
+
*/
|
|
319
|
+
script?: string;
|
|
320
|
+
/**
|
|
321
|
+
* Pixel methods registered on the `ttq` stub
|
|
322
|
+
*/
|
|
323
|
+
methods?: string[];
|
|
324
|
+
/**
|
|
325
|
+
* Call executed right after the pixel is loaded
|
|
326
|
+
*/
|
|
327
|
+
page?: string;
|
|
328
|
+
}
|
|
329
|
+
interface TikTokPixelOptions extends TikTokPixelDefaults {
|
|
330
|
+
id: string;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
declare global {
|
|
334
|
+
interface Window {
|
|
335
|
+
TiktokAnalyticsObject: 'ttq';
|
|
336
|
+
ttq: Record<string, (...args: any[]) => void>;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
interface UnbounceDefaults {
|
|
341
|
+
/**
|
|
342
|
+
* Unbounce tracking script source
|
|
343
|
+
*/
|
|
344
|
+
script?: string;
|
|
345
|
+
/**
|
|
346
|
+
* Goal pushed to `_ubaq` (raw arguments array as a string)
|
|
347
|
+
*/
|
|
348
|
+
goal?: string;
|
|
349
|
+
}
|
|
350
|
+
interface UnbounceOptions extends UnbounceDefaults {
|
|
351
|
+
enabled: boolean;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
interface VKRetargetingDefaults {
|
|
355
|
+
/**
|
|
356
|
+
* `openapi.js` script source
|
|
357
|
+
*/
|
|
358
|
+
script?: string;
|
|
359
|
+
/**
|
|
360
|
+
* Tracking endpoint used by the `<noscript>` pixel
|
|
361
|
+
*/
|
|
362
|
+
noScript?: string;
|
|
363
|
+
/**
|
|
364
|
+
* Hit call executed once the script is loaded
|
|
365
|
+
*/
|
|
366
|
+
hit?: string;
|
|
367
|
+
}
|
|
368
|
+
interface VKRetargeting extends VKRetargetingDefaults {
|
|
369
|
+
/**
|
|
370
|
+
* Retargeting tag
|
|
371
|
+
*/
|
|
372
|
+
id: string;
|
|
373
|
+
}
|
|
374
|
+
type VKRetargetingOption = VKRetargeting | VKRetargeting[];
|
|
375
|
+
|
|
376
|
+
declare global {
|
|
377
|
+
interface Window {
|
|
378
|
+
VK: any;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
interface MetricaConfiguration {
|
|
383
|
+
defer?: boolean;
|
|
384
|
+
clickmap?: boolean;
|
|
385
|
+
trackLinks?: boolean;
|
|
386
|
+
accurateTrackBounce?: boolean;
|
|
387
|
+
childIframe?: boolean;
|
|
388
|
+
webvisor?: boolean;
|
|
389
|
+
trackHash?: boolean;
|
|
390
|
+
triggerEvent?: boolean;
|
|
391
|
+
ecommerce?: string | boolean | any[];
|
|
392
|
+
trustedDomains?: string[];
|
|
393
|
+
type?: number;
|
|
394
|
+
params?: Record<string, string | number | boolean> | Record<string, string | number | boolean>[];
|
|
395
|
+
userParams?: Record<string, string | number | boolean>;
|
|
396
|
+
}
|
|
397
|
+
interface YandexMetricaDefaults {
|
|
398
|
+
/**
|
|
399
|
+
* `tag.js` script source
|
|
400
|
+
*/
|
|
401
|
+
script?: string;
|
|
402
|
+
/**
|
|
403
|
+
* Tracking endpoint used by the `<noscript>` pixel
|
|
404
|
+
*/
|
|
405
|
+
noScript?: string;
|
|
406
|
+
}
|
|
407
|
+
interface YandexMetricaProperty extends YandexMetricaDefaults {
|
|
408
|
+
id: string;
|
|
409
|
+
config?: MetricaConfiguration;
|
|
410
|
+
}
|
|
411
|
+
type YandexMetricaOptions = YandexMetricaProperty | YandexMetricaProperty[];
|
|
412
|
+
|
|
413
|
+
declare global {
|
|
414
|
+
interface Window {
|
|
415
|
+
dataLayer: any[];
|
|
416
|
+
ym: (id: string, command: string, ...args: any[]) => void;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
interface VitePluginRadarOptions {
|
|
421
|
+
enableDev?: boolean;
|
|
422
|
+
analytics?: GoogleAnaliticsOptions;
|
|
423
|
+
gtm?: GoogleTagManagerOptions;
|
|
424
|
+
pixel?: FacebookPixelOption;
|
|
425
|
+
linkedin?: LinkedinInsightOptions;
|
|
426
|
+
tongji?: BaiduTongjiOptions;
|
|
427
|
+
metrica?: YandexMetricaOptions;
|
|
428
|
+
microsoft?: MicrosoftAdvertisingOptions;
|
|
429
|
+
microsoftClarity?: MicrosoftClarityOptions;
|
|
430
|
+
retargeting?: VKRetargetingOption;
|
|
431
|
+
hotjar?: HotjarOptions;
|
|
432
|
+
fullStory?: FullStoryOptions;
|
|
433
|
+
unbounce?: UnbounceOptions | boolean;
|
|
434
|
+
tiktok?: TikTokPixelOptions;
|
|
435
|
+
simpleanalytics?: SimpleAnalyticsOptions;
|
|
436
|
+
posthog?: PostHogAnalyticsOptions;
|
|
437
|
+
plausible?: PlausibleAnalyticsOptions;
|
|
438
|
+
}
|
|
439
|
+
type InjectorKey = Exclude<keyof VitePluginRadarOptions, 'enableDev'>;
|
|
440
|
+
interface InjectorEntry {
|
|
441
|
+
key: InjectorKey;
|
|
442
|
+
enabled?: (value: any) => boolean;
|
|
443
|
+
load: () => Promise<{
|
|
444
|
+
default: (options: any) => HtmlTagDescriptor[];
|
|
445
|
+
}>;
|
|
446
|
+
}
|
|
447
|
+
declare const INJECTORS: InjectorEntry[];
|
|
448
|
+
declare function VitePluginRadar({ enableDev, ...options }: VitePluginRadarOptions): Plugin;
|
|
449
|
+
|
|
450
|
+
export { INJECTORS, VitePluginRadar };
|
|
451
|
+
export type { VitePluginRadarOptions };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
function defineInjector(entry) {
|
|
2
|
+
return entry;
|
|
3
|
+
}
|
|
4
|
+
const INJECTORS = [
|
|
5
|
+
defineInjector({ key: "analytics", load: () => import('./chunks/index.mjs') }),
|
|
6
|
+
defineInjector({ key: "gtm", load: () => import('./chunks/index2.mjs') }),
|
|
7
|
+
defineInjector({ key: "pixel", load: () => import('./chunks/index3.mjs') }),
|
|
8
|
+
defineInjector({ key: "retargeting", load: () => import('./chunks/index4.mjs') }),
|
|
9
|
+
defineInjector({ key: "tongji", load: () => import('./chunks/index5.mjs') }),
|
|
10
|
+
defineInjector({ key: "linkedin", load: () => import('./chunks/index6.mjs') }),
|
|
11
|
+
defineInjector({ key: "metrica", load: () => import('./chunks/index7.mjs') }),
|
|
12
|
+
defineInjector({ key: "microsoft", load: () => import('./chunks/index8.mjs') }),
|
|
13
|
+
defineInjector({ key: "microsoftClarity", load: () => import('./chunks/index9.mjs') }),
|
|
14
|
+
defineInjector({ key: "hotjar", load: () => import('./chunks/index10.mjs') }),
|
|
15
|
+
defineInjector({ key: "fullStory", load: () => import('./chunks/index11.mjs') }),
|
|
16
|
+
defineInjector({
|
|
17
|
+
key: "unbounce",
|
|
18
|
+
enabled: (value) => value === true || typeof value === "object" && value.enabled === true,
|
|
19
|
+
load: () => import('./chunks/index12.mjs')
|
|
20
|
+
}),
|
|
21
|
+
defineInjector({ key: "tiktok", load: () => import('./chunks/index13.mjs') }),
|
|
22
|
+
defineInjector({ key: "simpleanalytics", load: () => import('./chunks/index14.mjs') }),
|
|
23
|
+
defineInjector({ key: "posthog", load: () => import('./chunks/index15.mjs') }),
|
|
24
|
+
defineInjector({ key: "plausible", load: () => import('./chunks/index16.mjs') })
|
|
25
|
+
];
|
|
26
|
+
function VitePluginRadar({
|
|
27
|
+
enableDev = false,
|
|
28
|
+
...options
|
|
29
|
+
}) {
|
|
30
|
+
let viteConfig;
|
|
31
|
+
return {
|
|
32
|
+
name: "vite-plugin-Radar",
|
|
33
|
+
configResolved(resolvedConfig) {
|
|
34
|
+
viteConfig = resolvedConfig;
|
|
35
|
+
},
|
|
36
|
+
async transformIndexHtml() {
|
|
37
|
+
if (viteConfig.command === "serve" && !enableDev)
|
|
38
|
+
return [];
|
|
39
|
+
const active = INJECTORS.filter((entry) => {
|
|
40
|
+
const value = options[entry.key];
|
|
41
|
+
if (value == null)
|
|
42
|
+
return false;
|
|
43
|
+
return entry.enabled ? entry.enabled(value) : Boolean(value);
|
|
44
|
+
});
|
|
45
|
+
const groups = await Promise.all(active.map(async (entry) => {
|
|
46
|
+
const inject = (await entry.load()).default;
|
|
47
|
+
return inject(options[entry.key]);
|
|
48
|
+
}));
|
|
49
|
+
return groups.flat();
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export { INJECTORS, VitePluginRadar };
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ohos-ports/vite-plugin-radar",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.11.0-beta.0",
|
|
5
|
+
"description": "Analytics loader for vite (HarmonyOS port)",
|
|
6
|
+
"author": "stafyniaksacha",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/ohos-ports/ohos-ports.git",
|
|
11
|
+
"directory": "ports/vite-plugin-radar/0.11.0"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/ohos-ports/ohos-ports/issues"
|
|
15
|
+
},
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"import": "./dist/index.mjs",
|
|
20
|
+
"require": "./dist/index.cjs"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"main": "dist/index.cjs",
|
|
24
|
+
"module": "dist/index.mjs",
|
|
25
|
+
"types": "dist/index.d.ts",
|
|
26
|
+
"files": [
|
|
27
|
+
"dist"
|
|
28
|
+
],
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"@ohos-ports/vite": "^8.3.0-beta.0"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "unbuild",
|
|
34
|
+
"test": "vitest run"
|
|
35
|
+
}
|
|
36
|
+
}
|