-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreporter.cjs.js
35 lines (35 loc) · 1.12 KB
/
reporter.cjs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ReporterEvent = void 0;
class ReporterEvent extends Event {
constructor(name, data) {
super('cpx-report', { bubbles: true, composed: true });
Object.defineProperty(this, "data", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "name", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "toJSON", {
enumerable: true,
configurable: true,
writable: true,
value: () => Object.assign({ event: this.name }, this.data)
});
this.name = name;
this.data = data;
}
}
exports.ReporterEvent = ReporterEvent;
console.log(import.meta);
const reporter = document.currentScript;
if (reporter) {
const data = JSON.parse(reporter.textContent ? reporter.textContent : '');
globalThis.dispatchEvent(new ReporterEvent(reporter.dataset.event, data));
}