@teamscale/javascript-instrumenter 0.1.0-beta.8 → 1.0.0-beta.4

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,36 @@
1
+ import { ConfigurationParameters } from '@cqse/commons';
2
+ import { LogLevelString } from 'bunyan';
3
+ /**
4
+ * The options the Instrumenter is configured with.
5
+ * For more details on these options:
6
+ * @see #buildInstrumenterConfigurationParameters
7
+ */
8
+ export type InstrumenterOptions = {
9
+ version?: boolean;
10
+ help?: boolean;
11
+ input?: string[];
12
+ inPlace?: boolean;
13
+ to?: string;
14
+ logLevel?: LogLevelString;
15
+ configId?: string;
16
+ appName?: string;
17
+ commit?: string;
18
+ sourceMap?: string;
19
+ collector: string;
20
+ relativeCollector?: string;
21
+ includeOrigin?: string[];
22
+ excludeOrigin?: string[];
23
+ excludeBundle?: string[];
24
+ dumpOriginsTo?: string;
25
+ dumpOriginMatchesTo?: string;
26
+ collectorConfigFile?: string;
27
+ collectorConfigFileContent?: string;
28
+ collectorOption?: string[];
29
+ collectorOptionsList?: boolean;
30
+ };
31
+ /**
32
+ * Builds and returns a configuration parameters object for the JavaScript instrumenter.
33
+ * This function defines all supported command-line arguments and their descriptions.
34
+ */
35
+ export declare function buildInstrumenterConfigurationParameters(): ConfigurationParameters;
36
+ //# sourceMappingURL=InstrumenterConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InstrumenterConfig.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/InstrumenterConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,uBAAuB,EAGvB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAGxC;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG;IACjC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,0BAA0B,CAAC,EAAE,MAAM,CAAC;IACpC,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAC/B,CAAC;AAsBF;;;GAGG;AACH,wBAAgB,wCAAwC,IAAI,uBAAuB,CA0HlF"}
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildInstrumenterConfigurationParameters = buildInstrumenterConfigurationParameters;
4
+ const commons_1 = require("@cqse/commons");
5
+ const commons_2 = require("@cqse/commons");
6
+ const CONFIG_GROUP_INPUT = {
7
+ order: 1,
8
+ title: 'Instrumenter Input and Output'
9
+ };
10
+ const CONFIG_GROUP_TARGET_PARAMS = {
11
+ order: 2,
12
+ title: 'Coverage Target Parameters'
13
+ };
14
+ const CONFIG_GROUP_COVERAGE_SUBJECT = {
15
+ order: 3,
16
+ title: 'Coverage Subject'
17
+ };
18
+ const CONFIG_GROUP_DEBUGGING = {
19
+ order: 4,
20
+ title: 'Troubleshooting'
21
+ };
22
+ /**
23
+ * Builds and returns a configuration parameters object for the JavaScript instrumenter.
24
+ * This function defines all supported command-line arguments and their descriptions.
25
+ */
26
+ function buildInstrumenterConfigurationParameters() {
27
+ const parameters = new commons_1.ConfigurationParameters();
28
+ function addParameter(shortParameter, longParameter, type, options) {
29
+ parameters.addParameter(shortParameter, longParameter, type, options);
30
+ }
31
+ addParameter('-i', '--input', 'string[]', {
32
+ help: 'The input file(s) or folder(s) to instrument.',
33
+ group: CONFIG_GROUP_INPUT
34
+ });
35
+ addParameter('-l', '--in-place', 'bool', {
36
+ help: 'If set, the original files to instrument are replaced by their instrumented counterparts.',
37
+ group: CONFIG_GROUP_INPUT
38
+ });
39
+ addParameter('-o', '--to', 'string', {
40
+ help: 'Path (directory or file name) to write the instrumented version to.',
41
+ group: CONFIG_GROUP_INPUT
42
+ });
43
+ addParameter('-r', '--commit', 'string', {
44
+ help: 'The commit (<branch name>:<UNIX timestamp in milliseconds>) or revision (Git hash) of the code to report coverage for.',
45
+ group: CONFIG_GROUP_TARGET_PARAMS
46
+ });
47
+ addParameter('-c', '--collector', 'string', {
48
+ help: 'The collector (`host:port` or `wss://host:port/` or `ws://host:port/`) to send coverage information to.',
49
+ default: 'ws://localhost:54678',
50
+ group: CONFIG_GROUP_TARGET_PARAMS
51
+ });
52
+ addParameter('-a', '--app-name', 'string', {
53
+ help: 'The name of the application to report coverage for. Will be used to make the automatically generated application ID more readable.',
54
+ group: CONFIG_GROUP_TARGET_PARAMS
55
+ });
56
+ addParameter('-f', '--config-id', 'string', {
57
+ help: 'The ID of the profiler configuration to use; this configuration is refetched from Teamscale once a minute.',
58
+ group: CONFIG_GROUP_TARGET_PARAMS
59
+ });
60
+ addParameter('-t', '--collector-config-file', 'string', {
61
+ help: 'Provide a configuration file that specifies or overwrites the configuration of the Coverage Collector.',
62
+ group: CONFIG_GROUP_TARGET_PARAMS
63
+ });
64
+ addParameter(undefined, '--collector-option', 'string[]', {
65
+ help: 'Sets a given collector configuration option. Provided as key=value pairs.',
66
+ group: CONFIG_GROUP_TARGET_PARAMS
67
+ });
68
+ addParameter(undefined, '--collector-options-list', 'bool', {
69
+ help: 'Lists the options that can be set for the collector, via a --collector-config-file or via --collector-option.',
70
+ group: CONFIG_GROUP_TARGET_PARAMS
71
+ });
72
+ addParameter(undefined, '--source-map', 'string', {
73
+ help: 'External location of source-map files to consider.',
74
+ group: CONFIG_GROUP_COVERAGE_SUBJECT
75
+ });
76
+ addParameter(undefined, '--relative-collector', 'string', {
77
+ help: 'Pattern used to determine the collector URL from the application hostname.'
78
+ + ' Useful for Kubernetes deployments where the collector URL is not known at instrumentation time.'
79
+ + ' Example: `replace-in-host:app collector,scheme:wss`.'
80
+ + ' This causes the first occurrence of `app` in the application hostname to be replaced with `collector`'
81
+ + ' and the URL scheme changed to wss.'
82
+ + ' Available operations:'
83
+ + ' `replace-in-host:SEARCH REPLACE` replaces the literal term SEARCH once in the hostname with REPLACE.'
84
+ + ' `port:NUMBER` changes the port to NUMBER.'
85
+ + ' `port:keep` keeps the port of the application (instead of using the chosen scheme\'s default port).'
86
+ + ' `scheme:SCHEME` changes the URL scheme to one of ws, wss, http or https.'
87
+ + ' `path:PATH` uses the URL path PATH (instead of no path).',
88
+ group: CONFIG_GROUP_TARGET_PARAMS
89
+ });
90
+ addParameter('-x', '--exclude-origin', 'string[]', {
91
+ help: 'Glob pattern(s) of files in the source origin to not produce coverage for. Multiple patterns can be separated by comma.',
92
+ group: CONFIG_GROUP_INPUT
93
+ });
94
+ addParameter('-k', '--include-origin', 'string[]', {
95
+ help: 'Glob pattern(s) of files in the source origin to produce coverage for. Multiple patterns can be separated by comma.',
96
+ group: CONFIG_GROUP_INPUT
97
+ });
98
+ addParameter('-e', '--exclude-bundle', 'string[]', {
99
+ help: 'Glob pattern(s) of input (bundle) files to keep unchanged (to not instrument).',
100
+ group: CONFIG_GROUP_INPUT
101
+ });
102
+ addParameter('-p', '--dump-origins-to', 'string', {
103
+ help: 'Path specifying where to dump source origins file names, based on the source maps, as a JSON file.',
104
+ group: CONFIG_GROUP_DEBUGGING
105
+ });
106
+ addParameter('-m', '--dump-origin-matches-to', 'string', {
107
+ help: 'Path specifying where to dump a JSON with the names of the files that have matched the origin include/exclude patterns.',
108
+ group: CONFIG_GROUP_DEBUGGING
109
+ });
110
+ addParameter(undefined, '--log-level', 'string', {
111
+ help: 'Log level', default: 'info', group: CONFIG_GROUP_DEBUGGING
112
+ });
113
+ parameters.addArgumentCheck(options => {
114
+ if (!Array.isArray(options.input) || options.input.length === 0) {
115
+ return 'The --input parameter must be provided with the list of files or folders to instrument.';
116
+ }
117
+ });
118
+ parameters.addRequiredArgumentFor('commit');
119
+ parameters.addArgumentCheck(options => {
120
+ if (!(0, commons_2.isValidCommitInfo)(options.commit)) {
121
+ return 'The given commit must be of the form <branch>:<UNIX timestamp in milliseconds> or a Git hash.';
122
+ }
123
+ });
124
+ parameters.addArgumentCheck(options => {
125
+ if (!options.collector && !options.relativeCollector) {
126
+ return 'Either a collector URL or a relative collector URL must be specified.';
127
+ }
128
+ });
129
+ parameters.addArgumentCheck(options => {
130
+ if (!options.configId && !options.collectorConfigFile && !(Array.isArray(options.collectorOption) && options.collectorOption.length > 0)) {
131
+ return 'Either a configuration ID (--config-id), a collector configuration file (--collector-config-file) or explicit collector options (--collector-option) must be specified.';
132
+ }
133
+ });
134
+ parameters.addArgumentCheck(options => {
135
+ if (options.logLevel !== undefined) {
136
+ const validLevels = ["trace", "debug", "info", "warn", "error", "fatal"];
137
+ if (!validLevels.includes(options.logLevel)) {
138
+ return "Please provide a valid value for --log-level. One of: " + validLevels.join(", ");
139
+ }
140
+ }
141
+ });
142
+ return parameters;
143
+ }
@@ -1,5 +1,5 @@
1
1
  import { Optional } from 'typescript-optional';
2
- import { CollectorSpecifier } from '../vaccine/types';
2
+ import { CollectorSpecifier, CoverageBucketSpecifier } from '../vaccine/types';
3
3
  /**
4
4
  * An abstract source map type.
5
5
  */
@@ -137,6 +137,10 @@ export declare class InstrumentationTask {
137
137
  * The collector to send coverage information to.
138
138
  */
139
139
  readonly collector: CollectorSpecifier;
140
+ /**
141
+ * The target bucket within the collector the coverage is supposed to be sent to.
142
+ */
143
+ readonly targetBucket: CoverageBucketSpecifier;
140
144
  /**
141
145
  * The files to instrument along with a specification of the target.
142
146
  */
@@ -159,7 +163,7 @@ export declare class InstrumentationTask {
159
163
  * File to write the matched files to.
160
164
  */
161
165
  readonly dumpMatchedOriginsFile: string | undefined;
162
- constructor(collector: CollectorSpecifier, elements: TaskElement[], excludeFilesPattern: FileExcludePattern, originSourcePattern: OriginSourcePattern, dumpOriginsFile: string | undefined, dumpMatchedOriginsFile: string | undefined);
166
+ constructor(collector: CollectorSpecifier, targetBucket: CoverageBucketSpecifier, elements: TaskElement[], excludeFilesPattern: FileExcludePattern, originSourcePattern: OriginSourcePattern, dumpOriginsFile: string | undefined, dumpMatchedOriginsFile: string | undefined);
163
167
  /**
164
168
  * @returns the elements of the task.
165
169
  */
@@ -1 +1 @@
1
- {"version":3,"file":"Task.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/Task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAG/C,OAAO,EAAE,kBAAkB,EAAqD,MAAM,kBAAkB,CAAA;AAGxG;;GAEG;AACH,8BAAsB,kBAAkB;CAAI;AAE5C,KAAK,UAAU,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAE/D;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG;IAAE,IAAI,EAAE,YAAY,CAAA;CAAE,CAAC;AAEjE;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG;IACpC,IAAI,EAAE,KAAK,CAAC;IACZ,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,mBAAmB,EAAE,OAAO,CAAC;CAC7B,CAAC;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importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.SourceMapFileReference = exports.TaskResult = exports.InstrumentationTask = exports.FileExcludePattern = exports.OriginSourcePattern = exports.createCollectorSpecifier = exports.TaskElement = exports.SourceMapReference = void 0;
6
+ exports.SourceMapFileReference = exports.TaskResult = exports.InstrumentationTask = exports.FileExcludePattern = exports.OriginSourcePattern = exports.TaskElement = exports.SourceMapReference = void 0;
7
+ exports.createCollectorSpecifier = createCollectorSpecifier;
7
8
  const typescript_optional_1 = require("typescript-optional");
8
9
  const commons_1 = require("@cqse/commons");
9
10
  const micromatch_1 = __importDefault(require("micromatch"));
@@ -47,7 +48,6 @@ function createCollectorSpecifier(commandLineUrl, relativePattern) {
47
48
  }
48
49
  return parseCommandLineUrl(commandLineUrl);
49
50
  }
50
- exports.createCollectorSpecifier = createCollectorSpecifier;
51
51
  /**
52
52
  * Parses, validates and normalizes the given URL that the user provided on the command-line.
53
53
  */
@@ -223,8 +223,9 @@ function removePrefix(prefix, removeFrom) {
223
223
  * The actual instrumentation task.
224
224
  */
225
225
  class InstrumentationTask {
226
- constructor(collector, elements, excludeFilesPattern, originSourcePattern, dumpOriginsFile, dumpMatchedOriginsFile) {
226
+ constructor(collector, targetBucket, elements, excludeFilesPattern, originSourcePattern, dumpOriginsFile, dumpMatchedOriginsFile) {
227
227
  this.collector = commons_1.Contract.requireDefined(collector);
228
+ this.targetBucket = commons_1.Contract.requireDefined(targetBucket);
228
229
  this.excludeFilesPattern = commons_1.Contract.requireDefined(excludeFilesPattern);
229
230
  this.originSourcePattern = commons_1.Contract.requireDefined(originSourcePattern);
230
231
  this._elements = commons_1.Contract.requireDefined(elements).slice();
@@ -1,19 +1,5 @@
1
1
  import { InstrumentationTask, SourceMapReference } from './Task';
2
- /** The parameters the instrumenter can be configured by */
3
- export type ConfigurationParameters = {
4
- inputs?: string[];
5
- in_place?: boolean;
6
- debug?: boolean;
7
- to?: string;
8
- source_map?: string;
9
- collector: string;
10
- relative_collector?: string;
11
- include_origin?: string[];
12
- exclude_origin?: string[];
13
- exclude_bundle?: string[];
14
- dump_origins_to?: string;
15
- dump_origin_matches_to?: string;
16
- };
2
+ import { InstrumenterOptions } from './InstrumenterConfig';
17
3
  /**
18
4
  * A builder for an instrumentation task.
19
5
  */
@@ -37,9 +23,19 @@ export declare class TaskBuilder {
37
23
  * `undefined` if this information should not be dumped.
38
24
  */
39
25
  private dumpMatchedOriginsFile;
26
+ /**
27
+ * The bucket within the collector the coverage is supposed to be sent to.
28
+ */
29
+ private targetBucket;
30
+ /**
31
+ * The automatically generated unique app id to use.
32
+ */
33
+ private appId;
40
34
  constructor();
41
35
  /** Set the collector specification based on the command-line arguments. */
42
36
  setCollectorFromCommandLine(commandLineUrl: string, relativePattern?: string): this;
37
+ /** Set the coverage bucket to be used within the collector. */
38
+ setCollectorTargetBucket(configId: string | undefined, commit: string, configOptions?: string, appName?: string): this;
43
39
  /** Set the origin include pattern. If multiple patterns are present, concatenates them via the OR operator. */
44
40
  setOriginSourceIncludePatterns(patterns: string[] | undefined): this;
45
41
  /** Set the origin exclude pattern(s). If multiple patterns are present, concatenates them via the OR operator. */
@@ -53,7 +49,7 @@ export declare class TaskBuilder {
53
49
  *
54
50
  * @param config - The configuration based on that the task is built.
55
51
  */
56
- addFromConfig(config: ConfigurationParameters): this;
52
+ addFromConfig(config: InstrumenterOptions): this;
57
53
  /**
58
54
  * Adds instrumentation tasks based on a given pattern `inputs` describing the set of
59
55
  * input files and produces the output files in the specified output folder `target.
@@ -1 +1 @@
1
- {"version":3,"file":"TaskBuilder.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/TaskBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,mBAAmB,EAGnB,kBAAkB,EAGlB,MAAM,QAAQ,CAAC;AAOhB,2DAA2D;AAC3D,MAAM,MAAM,uBAAuB,GAAG;IACrC,MAAM,CAAC,EAA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GAAG,IAAI;IAO9B,gHAAgH;IAChH,8BAA8B,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,SAAS,GAAG,IAAI;IAKpE,kHAAkH;IAClH,8BAA8B,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,SAAS,GAAG,IAAI;IAKpE,qHAAqH;IACrH,wBAAwB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,SAAS,GAAG,IAAI;IAK9D,yBAAyB;IACzB,UAAU,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,iBAAiB,CAAC,EAAE,kBAAkB,GAAG,IAAI;IAKlG;;;;OAIG;IACH,aAAa,CAAC,MAAM,EAAE,mBAAmB,GAAG,IAAI;IAuChD;;;;;;;OAOG;IACH,OAAO,CAAC,4CAA4C;IAgCpD;;;;;;OAMG;IACH,OAAO,CAAC,0BAA0B;IASlC;;OAEG;IACI,KAAK,IAAI,mBAAmB;CAWnC"}
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
36
  exports.TaskBuilder = void 0;
27
37
  const Task_1 = require("./Task");
@@ -29,6 +39,7 @@ const commons_1 = require("@cqse/commons");
29
39
  const fs = __importStar(require("fs"));
30
40
  const path = __importStar(require("path"));
31
41
  const FileSystem_1 = require("./FileSystem");
42
+ const uuid_1 = require("uuid");
32
43
  /**
33
44
  * Load a source map object from the given file (path).
34
45
  * Exception if the specified file does not exist.
@@ -49,8 +60,10 @@ function loadSourceMap(sourceMapPath) {
49
60
  */
50
61
  class TaskBuilder {
51
62
  constructor() {
63
+ this.appId = (0, uuid_1.v4)();
52
64
  this.elements = [];
53
65
  this.collector = null;
66
+ this.targetBucket = null;
54
67
  }
55
68
  /** Set the collector specification based on the command-line arguments. */
56
69
  setCollectorFromCommandLine(commandLineUrl, relativePattern) {
@@ -58,6 +71,13 @@ class TaskBuilder {
58
71
  this.collector = (0, Task_1.createCollectorSpecifier)(commandLineUrl, relativePattern);
59
72
  return this;
60
73
  }
74
+ /** Set the coverage bucket to be used within the collector. */
75
+ setCollectorTargetBucket(configId, commit, configOptions, appName) {
76
+ commons_1.Contract.requireNonEmpty(commit, "The commit must not be empty");
77
+ this.appId = generateAppId(appName);
78
+ this.targetBucket = { appId: this.appId, configId, commit, configOptions };
79
+ return this;
80
+ }
61
81
  /** Set the origin include pattern. If multiple patterns are present, concatenates them via the OR operator. */
62
82
  setOriginSourceIncludePatterns(patterns) {
63
83
  this.originSourceIncludePatterns = patterns;
@@ -84,20 +104,21 @@ class TaskBuilder {
84
104
  * @param config - The configuration based on that the task is built.
85
105
  */
86
106
  addFromConfig(config) {
87
- var _a, _b;
88
- const inputs = ((_a = config.inputs) !== null && _a !== void 0 ? _a : []);
89
- const inPlace = (_b = config.in_place) !== null && _b !== void 0 ? _b : true;
107
+ var _a, _b, _c;
108
+ const inputs = ((_a = config.input) !== null && _a !== void 0 ? _a : []);
109
+ const inPlace = (_b = config.inPlace) !== null && _b !== void 0 ? _b : false;
90
110
  const target = config.to;
91
- const sourceMap = config.source_map;
92
- this.dumpOriginsFile = config.dump_origins_to;
93
- this.dumpMatchedOriginsFile = config.dump_origin_matches_to;
94
- this.setCollectorFromCommandLine(config.collector, config.relative_collector);
95
- this.setOriginSourceIncludePatterns(config.include_origin);
96
- this.setOriginSourceExcludePatterns(config.exclude_origin);
97
- this.setBundleExcludePatterns(config.exclude_bundle);
111
+ const sourceMap = config.sourceMap;
112
+ this.dumpOriginsFile = config.dumpOriginsTo;
113
+ this.dumpMatchedOriginsFile = config.dumpOriginMatchesTo;
114
+ this.setCollectorFromCommandLine(config.collector, config.relativeCollector);
115
+ this.setOriginSourceIncludePatterns(config.includeOrigin);
116
+ this.setOriginSourceExcludePatterns(config.excludeOrigin);
117
+ this.setBundleExcludePatterns(config.excludeBundle);
118
+ this.setCollectorTargetBucket(config.configId, (_c = config.commit) !== null && _c !== void 0 ? _c : 'HEAD', config.collectorConfigFileContent, config.appName);
98
119
  // Handle an explicitly specified source map
99
120
  const sourceMapInfo = loadSourceMap(sourceMap);
100
- // If an in place instrumentation is needed
121
+ // If an in-place instrumentation is needed,
101
122
  // the task has to be built differently and different invariants
102
123
  // have to be satisfied by the passed configuration.
103
124
  if (inPlace) {
@@ -171,10 +192,21 @@ class TaskBuilder {
171
192
  * Build the instrumentation task.
172
193
  */
173
194
  build() {
174
- return new Task_1.InstrumentationTask(commons_1.Contract.requireDefined(this.collector), this.elements, new Task_1.FileExcludePattern(this.bundleFileExcludePatterns), new Task_1.OriginSourcePattern(this.originSourceIncludePatterns, this.originSourceExcludePatterns), this.dumpOriginsFile, this.dumpMatchedOriginsFile);
195
+ return new Task_1.InstrumentationTask(commons_1.Contract.requireDefined(this.collector), commons_1.Contract.requireDefined(this.targetBucket), this.elements, new Task_1.FileExcludePattern(this.bundleFileExcludePatterns), new Task_1.OriginSourcePattern(this.originSourceIncludePatterns, this.originSourceExcludePatterns), this.dumpOriginsFile, this.dumpMatchedOriginsFile);
175
196
  }
176
197
  }
177
198
  exports.TaskBuilder = TaskBuilder;
199
+ /**
200
+ * Generates an application ID, if an `appName` is given, with a user-friendly prefix.
201
+ */
202
+ function generateAppId(appName) {
203
+ const result = (0, uuid_1.v4)();
204
+ if (appName) {
205
+ const appPrefix = (0, FileSystem_1.replaceNonFilesystemCharacters)(appName).toLowerCase();
206
+ return `${appPrefix}-${result.substring(0, 10)}`;
207
+ }
208
+ return result;
209
+ }
178
210
  /**
179
211
  * Does the given string look like a RegExp or Glob pattern?
180
212
  */
@@ -3,7 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.isGwtBundle = exports.determineGwtFileUid = exports.loadInputSourceMapsGwt = exports.extractGwtCallInfos = exports.determineSymbolMapsDir = void 0;
6
+ exports.determineSymbolMapsDir = determineSymbolMapsDir;
7
+ exports.extractGwtCallInfos = extractGwtCallInfos;
8
+ exports.loadInputSourceMapsGwt = loadInputSourceMapsGwt;
9
+ exports.determineGwtFileUid = determineGwtFileUid;
10
+ exports.isGwtBundle = isGwtBundle;
7
11
  const path_1 = __importDefault(require("path"));
8
12
  const FileSystem_1 = require("./FileSystem");
9
13
  const types_1 = require("@babel/types");
@@ -36,7 +40,6 @@ function determineSymbolMapsDir(taskFile) {
36
40
  }
37
41
  return symbolMapDirs;
38
42
  }
39
- exports.determineSymbolMapsDir = determineSymbolMapsDir;
40
43
  function expressionToString(expression) {
41
44
  if ((0, types_1.isMemberExpression)(expression) && (0, types_1.isExpression)(expression.property)) {
42
45
  return `${expressionToString(expression.object)}.${expressionToString(expression.property)}`;
@@ -92,7 +95,6 @@ function extractGwtCallInfos(bundleContent) {
92
95
  }
93
96
  return null;
94
97
  }
95
- exports.extractGwtCallInfos = extractGwtCallInfos;
96
98
  /**
97
99
  * Load the source map for the given GWT bundle.
98
100
  */
@@ -125,7 +127,6 @@ function loadInputSourceMapsGwt(taskFile, bundleFile) {
125
127
  return undefined;
126
128
  });
127
129
  }
128
- exports.loadInputSourceMapsGwt = loadInputSourceMapsGwt;
129
130
  /**
130
131
  * Determine the ID of the given GWT bundle file.
131
132
  */
@@ -137,11 +138,9 @@ function determineGwtFileUid(filename) {
137
138
  }
138
139
  return uidMatches[1];
139
140
  }
140
- exports.determineGwtFileUid = determineGwtFileUid;
141
141
  /**
142
142
  * Is the given bundle a GWT bundle?
143
143
  */
144
144
  function isGwtBundle(bundle) {
145
145
  return bundle.type === 'gwt';
146
146
  }
147
- exports.isGwtBundle = isGwtBundle;
package/dist/src/main.js CHANGED
@@ -1,7 +1,42 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
3
36
  Object.defineProperty(exports, "__esModule", { value: true });
4
37
  const App_1 = require("./App");
38
+ const commons_1 = require("@cqse/commons");
39
+ const process = __importStar(require("node:process"));
5
40
  // Run the instrumenter and print the results to the console.
6
41
  App_1.App.run()
7
42
  .then(result => {
@@ -25,7 +60,14 @@ App_1.App.run()
25
60
  }
26
61
  })
27
62
  .catch(reason => {
28
- console.log('Failed: ', reason);
63
+ if (reason instanceof commons_1.InvalidConfigurationException) {
64
+ // Do not print the stack trace for invalid configuration parameters from the user.
65
+ console.error(`Failed: ${reason.message}`);
66
+ }
67
+ else {
68
+ console.error('Failed: ', reason);
69
+ }
70
+ process.exit(1);
29
71
  })
30
72
  .finally(() => {
31
73
  console.log('Bye bye.');
@@ -3,7 +3,7 @@
3
3
  */
4
4
  export interface CollectorSpecifierUrl {
5
5
  /** Type of collector specifier. */
6
- type: "url";
6
+ type: 'url';
7
7
  /** The URL under which the collector can be reached at runtime. */
8
8
  url: string;
9
9
  }
@@ -19,11 +19,11 @@ export interface SearchReplace {
19
19
  */
20
20
  export interface CollectorSpecifierRelative {
21
21
  /** Type of collector specifier. */
22
- type: "relative";
22
+ type: 'relative';
23
23
  /** Literal replacement string. */
24
24
  hostReplace?: SearchReplace;
25
25
  /** Optional port. If no port is given, uses the protocol's default port. */
26
- port?: number | "keep";
26
+ port?: number | 'keep';
27
27
  /** Optional URL scheme to use. If no scheme is given, uses ws. */
28
28
  scheme?: string;
29
29
  /** Optional path. If no path is given, uses only the hostname. */
@@ -44,6 +44,22 @@ export interface LocationMessage {
44
44
  /** Port of the profiled document, e.g. "1234" */
45
45
  port: string;
46
46
  }
47
- /** Enumerates all types of messages to the worker. */
48
- export type WorkerMessage = LocationMessage;
47
+ /** Details about the bucket the coverage is added to. */
48
+ export type CoverageBucketSpecifier = {
49
+ /** A unique identifier of the instrumented application. */
50
+ appId: string;
51
+ /**
52
+ * The ID of the profiler configuration to use. No config ID might be given
53
+ * if the coverage shall be collected while Teamscale is not available.
54
+ */
55
+ configId?: string;
56
+ /**
57
+ * Concrete collector configuration options to pass. ATTENTION: These are generally
58
+ * unencrypted and shall not contain sensitive information or the execution
59
+ * environment must ensure that they cannot be leaked.
60
+ */
61
+ configOptions?: string;
62
+ /** The project commit or revision to contribute coverage for. */
63
+ commit: string;
64
+ };
49
65
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/vaccine/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACrC,mCAAmC;IACnC,IAAI,EAAE,KAAK,CAAC;IACZ,mEAAmE;IACnE,GAAG,EAAE,MAAM,CAAC;CACZ;AAED,qEAAqE;AACrE,MAAM,WAAW,aAAa;IAC7B,oCAAoC;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IAC1C,mCAAmC;IACnC,IAAI,EAAE,UAAU,CAAC;IACjB,kCAAkC;IAClC,WAAW,CAAC,EAAE,aAAa,CAAC;IAC5B,4EAA4E;IAC5E,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,kEAAkE;IAClE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kEAAkE;IAClE,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,qBAAqB,GAAG,0BAA0B,CAAA;AAEnF;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B,oBAAoB;IACpB,IAAI,EAAE,UAAU,CAAC;IACjB,2DAA2D;IAC3D,QAAQ,EAAE,MAAM,CAAC;IACjB,iDAAiD;IACjD,IAAI,EAAE,MAAM,CAAC;CACb;AAED,sDAAsD;AACtD,MAAM,MAAM,aAAa,GAAG,eAAe,CAAA"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/vaccine/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACrC,mCAAmC;IACnC,IAAI,EAAE,KAAK,CAAC;IACZ,mEAAmE;IACnE,GAAG,EAAE,MAAM,CAAC;CACZ;AAED,qEAAqE;AACrE,MAAM,WAAW,aAAa;IAC7B,oCAAoC;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IAC1C,mCAAmC;IACnC,IAAI,EAAE,UAAU,CAAC;IACjB,kCAAkC;IAClC,WAAW,CAAC,EAAE,aAAa,CAAC;IAC5B,4EAA4E;IAC5E,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,kEAAkE;IAClE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kEAAkE;IAClE,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,qBAAqB,GAAG,0BAA0B,CAAC;AAEpF;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B,oBAAoB;IACpB,IAAI,EAAE,UAAU,CAAC;IACjB,2DAA2D;IAC3D,QAAQ,EAAE,MAAM,CAAC;IACjB,iDAAiD;IACjD,IAAI,EAAE,MAAM,CAAC;CACb;AAED,yDAAyD;AACzD,MAAM,MAAM,uBAAuB,GAAG;IACrC,2DAA2D;IAC3D,KAAK,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,iEAAiE;IACjE,MAAM,EAAE,MAAM,CAAC;CAEf,CAAA"}
package/dist/vaccine.js CHANGED
@@ -1 +1 @@
1
- "use strict";(()=>{function u(e){let n=new Blob([e],{type:"text/javascript"}),t=URL.createObjectURL(n),a=new Worker(t);return URL.revokeObjectURL(t),a}function d(){return u('var i=class{constructor(){this.cachedMessages=[]}connect(e){this.url=e,this.socket=this.createSocket()}createSocket(){let e=new WebSocket(this.url);return e.onopen=()=>this.onopen(),e.onclose=()=>this.onclose(),e}onclose(){this.socket=this.createSocket()}onopen(){console.log("Connection to Coverage Collector established."),this.cachedMessages.forEach(e=>this.socket.send(e)),this.cachedMessages=[]}send(e){this.socket!==null&&this.socket.readyState===WebSocket.OPEN?this.socket.send(e):(this.cachedMessages.push(e),this.cachedMessages.length%500===0&&console.log(`More than ${this.cachedMessages.length} messages are queued to be sent.`))}};var a=class{constructor(e,o){this.milliseconds=e;this.onCountedToZero=o;this.timerHandle=null}restartCountdown(){this.stopCountdown(),this.timerHandle=self.setTimeout(()=>{this.stopCountdown(),this.onCountedToZero()},this.milliseconds)}stopCountdown(){this.timerHandle!==null&&(self.clearTimeout(this.timerHandle),this.timerHandle=null)}};var C=20,f=1e3,v="c",c=class{constructor(e){this.socket=e,this.cachedCoveredRanges=new Map,this.numberOfCachedPositions=0,this.flushCountdown=new a(f,()=>this.flush())}addLines(e,o){let t=this.cachedCoveredRanges.get(e);t||(t=new Set,this.cachedCoveredRanges.set(e,t)),o.forEach(n=>t.add(n)),this.numberOfCachedPositions+=1,this.flushCountdown.restartCountdown(),this.numberOfCachedPositions>=C&&this.flush()}arrayToLineCov(e){let o=[];for(let t of e)o.push(`${t}`);return o.join(";")}flush(){if(this.numberOfCachedPositions===0)return;this.flushCountdown.stopCountdown();let e=[];this.cachedCoveredRanges.forEach((o,t)=>{e.push(`@${t}`),e.push(this.arrayToLineCov(o))}),this.socket.send(`${v} ${e.join(";")}`),this.cachedCoveredRanges.clear(),this.numberOfCachedPositions=0}};var l=class s{static resolve(e,o,t){switch(e.type){case"url":return e.url;case"relative":return s.resolveRelative(o,t,e)}}static resolveRelative(e,o,t){var u;let n=e;t.hostReplace&&(n=e.replace(t.hostReplace.search,t.hostReplace.replace));let m=(u=t.scheme)!=null?u:"ws",r;t.port===void 0?r="":t.port==="keep"?r=`:${o}`:r=`:${t.port}`;let h="";t.path&&(h=`/${t.path}`);let d=`${m}://${n}${r}${h}`;return console.debug(`Resolved collector URL ${d} from ${e}:${o}`),d}};console.log("Starting coverage forwarding worker.");var g=new i,p=new c(g);onmessage=s=>{if(Array.isArray(s.data)){let[e,o]=s.data;p.addLines(e,o)}else if(s.data==="unload")p.flush();else if(s.data.type==="location"){let e=s.data,o=l.resolve($COLLECTOR_SPECIFIER,e.hostname,e.port);g.connect(`${o}/socket`)}else console.error(`No handler for message: ${s.data}`)};\n')}function c(){return f()}function f(){return window}function g(e,n){let t=c()[e];return t||(t=n,c()[e]=t),t}function p(e,n){let t=new Map;function a(i){let o=t.get(i);return o||(o={lines:new Set},t.set(i,o),o)}function s(i,o,w=o){let h=a(i).lines;for(let l=o;l<=w;l++)h.add(l);h.size>255&&r()}function r(){n(t),t.clear()}return setInterval(()=>r(),e),{putLineCoverage:s,flush:r}}var v=g("__TS_AGENT",{});function m(){return v._$BcWorker}function b(e){return v._$BcWorker=e,e}var C=p(250,e=>{for(let n of e.entries())m().postMessage([n[0],Array.from(n[1].lines)])});c()._$l=C.putLineCoverage;if(!m()){let e=b(new d),n={type:"location",hostname:document.location.hostname,port:document.location.port};e.postMessage(n),function(){let a=()=>{C.flush(),e.postMessage("unload")},s=function(i,o){o&&o.addEventListener(i,a,{capture:!0})},r=f();s("blur",r),s("unload",r),s("visibilitychange",r),s("beforeunload",r)}()}})();
1
+ "use strict";(()=>{function u(e){let n=new Blob([e],{type:"text/javascript"}),t=URL.createObjectURL(n),a=new Worker(t);return URL.revokeObjectURL(t),a}function h(){return u('var r=class{constructor(){this.socket=null,this.url="",this.messageOnConnect="",this.cachedMessages=[],this.reconnectTimer=null}connect(e,s){this.url=e,this.messageOnConnect=s,this.socket=this.createSocket(),this.startReconnectTimer()}createSocket(){let e=new WebSocket(this.url);return e.onopen=()=>this.onopen(),e.onclose=()=>this.onclose(),e}startReconnectTimer(){this.reconnectTimer!==null&&clearInterval(this.reconnectTimer),this.reconnectTimer=setInterval(()=>{this.checkConnectionAndReconnect()},1e4)}checkConnectionAndReconnect(){var e;(this.socket===null||this.socket.readyState!==WebSocket.OPEN)&&((e=this.socket)==null||e.close(),console.log("Connection lost, attempting to reconnect..."),this.socket=this.createSocket())}onclose(){this.socket=this.createSocket()}onopen(){console.log("Connection to Coverage Collector established."),this.socket.send(this.messageOnConnect),this.cachedMessages.forEach(e=>this.socket.send(e)),this.cachedMessages=[]}send(e){if(this.socket!==null&&this.socket.readyState===WebSocket.OPEN)try{this.socket.send(e)}catch(s){console.error("Sending failed. Message will be re-sent when connection is available again.",s),this.addMessageToCache(e)}else this.addMessageToCache(e)}addMessageToCache(e){this.cachedMessages.push(e),this.cachedMessages.length%500===0&&console.log(`More than ${this.cachedMessages.length} messages are queued to be sent.`)}disconnect(){this.reconnectTimer!==null&&(clearInterval(this.reconnectTimer),this.reconnectTimer=null),this.socket!==null&&(this.socket.close(),this.socket=null)}};var c=class{constructor(e,s){this.milliseconds=e;this.onCountedToZero=s;this.timerHandle=null}restartCountdown(){this.stopCountdown(),this.timerHandle=self.setTimeout(()=>{this.stopCountdown(),this.onCountedToZero()},this.milliseconds)}stopCountdown(){this.timerHandle!==null&&(self.clearTimeout(this.timerHandle),this.timerHandle=null)}};var v=20,f=1e3,S="c",g="b",a=class{constructor(e){this.socket=e,this.cachedCoveredRanges=new Map,this.numberOfCachedPositions=0,this.flushCountdown=new c(f,()=>this.flush())}addLines(e,s){let t=this.cachedCoveredRanges.get(e);t||(t=new Set,this.cachedCoveredRanges.set(e,t)),s.forEach(n=>t.add(n)),this.numberOfCachedPositions+=1,this.flushCountdown.restartCountdown(),this.numberOfCachedPositions>=v&&this.flush()}arrayToLineCov(e){let s=[];for(let t of e)s.push(`${t}`);return s.join(";")}flush(){if(this.numberOfCachedPositions===0)return;this.flushCountdown.stopCountdown();let e=[];this.cachedCoveredRanges.forEach((s,t)=>{e.push(`@${t}`),e.push(this.arrayToLineCov(s))}),this.socket.send(`${S} ${e.join(";")}`),this.cachedCoveredRanges.clear(),this.numberOfCachedPositions=0}};var l=class o{static resolve(e,s,t){switch(e.type){case"url":return e.url;case"relative":return o.resolveRelative(s,t,e)}}static resolveRelative(e,s,t){var u;let n=e;t.hostReplace&&(n=e.replace(t.hostReplace.search,t.hostReplace.replace));let C=(u=t.scheme)!=null?u:"ws",i;t.port===void 0?i="":t.port==="keep"?i=`:${s}`:i=`:${t.port}`;let h="";t.path&&(h=`/${t.path}`);let d=`${C}://${n}${i}${h}`;return console.debug(`Resolved collector URL ${d} from ${e}:${s}`),d}};console.log("Starting coverage forwarding worker.");var p=new r,m=new a(p);onmessage=o=>{if(Array.isArray(o.data)){let[e,s]=o.data;m.addLines(e,s)}else if(o.data==="unload")m.flush();else if(o.data.type==="location"){let e=o.data,s=l.resolve($COLLECTOR_SPECIFIER,e.hostname,e.port),t=`${g} $BUCKET_SPECIFIER`;p.connect(`${s}/socket`,t)}else console.error(`No handler for message: ${o.data}`)};\n')}function c(){return d()}function d(){return window}function g(e,n){let t=c()[e];return t||(t=n,c()[e]=t),t}function p(e,n){let t=new Map;function a(i){let o=t.get(i);return o||(o={lines:new Set},t.set(i,o),o)}function r(i,o,k=o){let f=a(i).lines;for(let l=o;l<=k;l++)f.add(l);f.size>255&&s()}function s(){n(t),t.clear()}return setInterval(()=>s(),e),{putLineCoverage:r,flush:s}}var v=g("__TS_AGENT",{});function m(){return v._$BcWorker}function b(e){return v._$BcWorker=e,e}var C=p(250,e=>{for(let n of e.entries())m().postMessage([n[0],Array.from(n[1].lines)])});c()._$l=C.putLineCoverage;if(!m()){let e=b(new h),n={type:"location",hostname:document.location.hostname,port:document.location.port};e.postMessage(n),function(){let a=()=>{C.flush(),e.postMessage("unload")},r=function(i,o){o&&o.addEventListener(i,a,{capture:!0})},s=d();r("blur",s),r("unload",s),r("visibilitychange",s),r("beforeunload",s)}()}})();