@atlaspack/profiler 2.14.1-canary.34 → 2.14.1-canary.340

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/CHANGELOG.md CHANGED
@@ -1,5 +1,248 @@
1
1
  # @atlaspack/profiler
2
2
 
3
+ ## 2.14.34
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies []:
8
+ - @atlaspack/types-internal@2.20.7
9
+
10
+ ## 2.14.33
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies []:
15
+ - @atlaspack/types-internal@2.20.6
16
+
17
+ ## 2.14.32
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies [[`c372f3f`](https://github.com/atlassian-labs/atlaspack/commit/c372f3fd6fce8200d5cf47f41bc7895c6cbb5558)]:
22
+ - @atlaspack/types-internal@2.20.5
23
+
24
+ ## 2.14.31
25
+
26
+ ### Patch Changes
27
+
28
+ - Updated dependencies []:
29
+ - @atlaspack/types-internal@2.20.4
30
+
31
+ ## 2.14.30
32
+
33
+ ### Patch Changes
34
+
35
+ - Updated dependencies []:
36
+ - @atlaspack/types-internal@2.20.3
37
+
38
+ ## 2.14.29
39
+
40
+ ### Patch Changes
41
+
42
+ - Updated dependencies []:
43
+ - @atlaspack/types-internal@2.20.2
44
+
45
+ ## 2.14.28
46
+
47
+ ### Patch Changes
48
+
49
+ - [#785](https://github.com/atlassian-labs/atlaspack/pull/785) [`0e7dd5e`](https://github.com/atlassian-labs/atlaspack/commit/0e7dd5ec6fbe05aa9e0bb5775a9d0975f206a922) Thanks [@matt-koko](https://github.com/matt-koko)! - We need to re-publish every package in Atlaspack with the corrected types field.
50
+
51
+ - Updated dependencies [[`0e7dd5e`](https://github.com/atlassian-labs/atlaspack/commit/0e7dd5ec6fbe05aa9e0bb5775a9d0975f206a922)]:
52
+ - @atlaspack/diagnostic@2.14.4
53
+ - @atlaspack/types-internal@2.20.1
54
+ - @atlaspack/events@2.14.4
55
+
56
+ ## 2.14.27
57
+
58
+ ### Patch Changes
59
+
60
+ - Updated dependencies [[`eedcbc4`](https://github.com/atlassian-labs/atlaspack/commit/eedcbc408fc1e86a2a8e25f1a41c57146d8529e1), [`f6532d7`](https://github.com/atlassian-labs/atlaspack/commit/f6532d7a4f7f007bd4e5e36af04dd466f0b9f572)]:
61
+ - @atlaspack/types-internal@2.20.0
62
+
63
+ ## 2.14.26
64
+
65
+ ### Patch Changes
66
+
67
+ - Updated dependencies []:
68
+ - @atlaspack/types-internal@2.19.5
69
+
70
+ ## 2.14.25
71
+
72
+ ### Patch Changes
73
+
74
+ - Updated dependencies []:
75
+ - @atlaspack/types-internal@2.19.4
76
+
77
+ ## 2.14.24
78
+
79
+ ### Patch Changes
80
+
81
+ - Updated dependencies []:
82
+ - @atlaspack/types-internal@2.19.3
83
+
84
+ ## 2.14.23
85
+
86
+ ### Patch Changes
87
+
88
+ - [#742](https://github.com/atlassian-labs/atlaspack/pull/742) [`ee040bb`](https://github.com/atlassian-labs/atlaspack/commit/ee040bb6428f29b57d892ddd8107e29077d08ffd) Thanks [@yamadapc](https://github.com/yamadapc)! - Internal changes and bug fixes to environmentDeduplication flag
89
+
90
+ - Updated dependencies [[`ee040bb`](https://github.com/atlassian-labs/atlaspack/commit/ee040bb6428f29b57d892ddd8107e29077d08ffd)]:
91
+ - @atlaspack/types-internal@2.19.2
92
+ - @atlaspack/diagnostic@2.14.3
93
+ - @atlaspack/events@2.14.3
94
+
95
+ ## 2.14.22
96
+
97
+ ### Patch Changes
98
+
99
+ - Updated dependencies []:
100
+ - @atlaspack/types-internal@2.19.1
101
+
102
+ ## 2.14.21
103
+
104
+ ### Patch Changes
105
+
106
+ - Updated dependencies [[`7f5841c`](https://github.com/atlassian-labs/atlaspack/commit/7f5841c39df049f9546cccbeea2a7337e0337b45)]:
107
+ - @atlaspack/types-internal@2.19.0
108
+
109
+ ## 2.14.20
110
+
111
+ ### Patch Changes
112
+
113
+ - Updated dependencies [[`23d561e`](https://github.com/atlassian-labs/atlaspack/commit/23d561e51e68b0c38fd1ff4e4fb173e5e7b01cf2)]:
114
+ - @atlaspack/types-internal@2.18.0
115
+
116
+ ## 2.14.19
117
+
118
+ ### Patch Changes
119
+
120
+ - [#720](https://github.com/atlassian-labs/atlaspack/pull/720) [`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94) Thanks [@alshdavid](https://github.com/alshdavid)! - Migrate to TypeScript
121
+
122
+ - Updated dependencies [[`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94), [`43fdd22`](https://github.com/atlassian-labs/atlaspack/commit/43fdd223860fbc97af17d68c65419b97412cb888)]:
123
+ - @atlaspack/types-internal@2.17.0
124
+ - @atlaspack/diagnostic@2.14.2
125
+ - @atlaspack/events@2.14.2
126
+
127
+ ## 2.14.18
128
+
129
+ ### Patch Changes
130
+
131
+ - Updated dependencies [[`069de47`](https://github.com/atlassian-labs/atlaspack/commit/069de478e64fb5889f6f2ce023eb510782767fbd)]:
132
+ - @atlaspack/types-internal@2.16.0
133
+
134
+ ## 2.14.17
135
+
136
+ ### Patch Changes
137
+
138
+ - Updated dependencies []:
139
+ - @atlaspack/types-internal@2.15.2
140
+
141
+ ## 2.14.16
142
+
143
+ ### Patch Changes
144
+
145
+ - Updated dependencies []:
146
+ - @atlaspack/types-internal@2.15.1
147
+
148
+ ## 2.14.15
149
+
150
+ ### Patch Changes
151
+
152
+ - Updated dependencies [[`18a57cf`](https://github.com/atlassian-labs/atlaspack/commit/18a57cf8a4789b2de5ad8e2676f317a26cc91417)]:
153
+ - @atlaspack/types-internal@2.15.0
154
+
155
+ ## 2.14.14
156
+
157
+ ### Patch Changes
158
+
159
+ - Updated dependencies []:
160
+ - @atlaspack/types-internal@2.14.14
161
+
162
+ ## 2.14.13
163
+
164
+ ### Patch Changes
165
+
166
+ - Updated dependencies []:
167
+ - @atlaspack/types-internal@2.14.13
168
+
169
+ ## 2.14.12
170
+
171
+ ### Patch Changes
172
+
173
+ - Updated dependencies []:
174
+ - @atlaspack/types-internal@2.14.12
175
+
176
+ ## 2.14.11
177
+
178
+ ### Patch Changes
179
+
180
+ - Updated dependencies []:
181
+ - @atlaspack/types-internal@2.14.11
182
+
183
+ ## 2.14.10
184
+
185
+ ### Patch Changes
186
+
187
+ - Updated dependencies []:
188
+ - @atlaspack/types-internal@2.14.10
189
+
190
+ ## 2.14.9
191
+
192
+ ### Patch Changes
193
+
194
+ - Updated dependencies []:
195
+ - @atlaspack/types-internal@2.14.9
196
+
197
+ ## 2.14.8
198
+
199
+ ### Patch Changes
200
+
201
+ - Updated dependencies [[`51aba5f`](https://github.com/atlassian-labs/atlaspack/commit/51aba5fc0e49235ee06bbc3c376f48c3e7da5c4b)]:
202
+ - @atlaspack/types-internal@2.14.8
203
+
204
+ ## 2.14.7
205
+
206
+ ### Patch Changes
207
+
208
+ - Updated dependencies []:
209
+ - @atlaspack/types-internal@2.14.7
210
+
211
+ ## 2.14.6
212
+
213
+ ### Patch Changes
214
+
215
+ - Updated dependencies []:
216
+ - @atlaspack/types-internal@2.14.6
217
+
218
+ ## 2.14.5
219
+
220
+ ### Patch Changes
221
+
222
+ - Updated dependencies []:
223
+ - @atlaspack/types-internal@2.14.5
224
+
225
+ ## 2.14.4
226
+
227
+ ### Patch Changes
228
+
229
+ - Updated dependencies []:
230
+ - @atlaspack/types-internal@2.14.4
231
+
232
+ ## 2.14.3
233
+
234
+ ### Patch Changes
235
+
236
+ - Updated dependencies []:
237
+ - @atlaspack/types-internal@2.14.3
238
+
239
+ ## 2.14.2
240
+
241
+ ### Patch Changes
242
+
243
+ - Updated dependencies []:
244
+ - @atlaspack/types-internal@2.14.2
245
+
3
246
  ## 2.14.1
4
247
 
5
248
  ### Patch Changes
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const assert_1 = __importDefault(require("assert"));
7
+ const diagnostic_1 = __importDefault(require("@atlaspack/diagnostic"));
8
+ class SamplingProfiler {
9
+ startProfiling() {
10
+ let inspector;
11
+ try {
12
+ inspector = require('inspector');
13
+ }
14
+ catch (err) {
15
+ throw new diagnostic_1.default({
16
+ diagnostic: {
17
+ message: `The inspector module isn't available`,
18
+ origin: '@atlaspack/workers',
19
+ hints: ['Disable build profiling'],
20
+ },
21
+ });
22
+ }
23
+ this.session = new inspector.Session();
24
+ this.session.connect();
25
+ return Promise.all([
26
+ this.sendCommand('Profiler.setSamplingInterval', {
27
+ interval: 100,
28
+ }),
29
+ this.sendCommand('Profiler.enable'),
30
+ this.sendCommand('Profiler.start'),
31
+ ]);
32
+ }
33
+ sendCommand(method, params) {
34
+ (0, assert_1.default)(this.session != null);
35
+ return new Promise((resolve, reject) => {
36
+ this.session.post(method, params, (err, p) => {
37
+ if (err == null) {
38
+ resolve(p);
39
+ }
40
+ else {
41
+ reject(err);
42
+ }
43
+ });
44
+ });
45
+ }
46
+ destroy() {
47
+ if (this.session != null) {
48
+ this.session.disconnect();
49
+ }
50
+ }
51
+ async stopProfiling() {
52
+ let res = await this.sendCommand('Profiler.stop');
53
+ this.destroy();
54
+ return res.profile;
55
+ }
56
+ }
57
+ exports.default = SamplingProfiler;
package/dist/Trace.js ADDED
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const chrome_trace_event_1 = require("chrome-trace-event");
4
+ class Trace {
5
+ constructor() {
6
+ this.tracer = new chrome_trace_event_1.Tracer();
7
+ this.tid = 0;
8
+ this.eventId = 0;
9
+ }
10
+ getEventId() {
11
+ return this.eventId++;
12
+ }
13
+ init(ts) {
14
+ this.tracer.instantEvent({
15
+ name: 'TracingStartedInPage',
16
+ id: this.getEventId(),
17
+ ts,
18
+ cat: ['disabled-by-default-devtools.timeline'],
19
+ args: {
20
+ data: {
21
+ sessionId: '-1',
22
+ page: '0xfff',
23
+ frames: [
24
+ {
25
+ frame: '0xfff',
26
+ url: 'parcel',
27
+ name: '',
28
+ },
29
+ ],
30
+ },
31
+ },
32
+ });
33
+ this.tracer.instantEvent({
34
+ name: 'TracingStartedInBrowser',
35
+ id: this.getEventId(),
36
+ ts,
37
+ cat: ['disabled-by-default-devtools.timeline'],
38
+ args: {
39
+ data: {
40
+ sessionId: '-1',
41
+ },
42
+ },
43
+ });
44
+ }
45
+ addCPUProfile(name, profile) {
46
+ if (this.eventId === 0) {
47
+ this.init(profile.startTime);
48
+ }
49
+ const trace = this.tracer;
50
+ const tid = this.tid;
51
+ this.tid++;
52
+ const cpuStartTime = profile.startTime;
53
+ const cpuEndTime = profile.endTime;
54
+ trace.instantEvent({
55
+ tid,
56
+ id: this.getEventId(),
57
+ cat: ['toplevel'],
58
+ name: 'TaskQueueManager::ProcessTaskFromWorkQueue',
59
+ args: {
60
+ src_file: '../../ipc/ipc_moji_bootstrap.cc',
61
+ src_func: 'Accept',
62
+ },
63
+ ts: cpuStartTime,
64
+ });
65
+ trace.completeEvent({
66
+ tid,
67
+ name: 'EvaluateScript',
68
+ id: this.getEventId(),
69
+ cat: ['devtools.timeline'],
70
+ ts: cpuStartTime,
71
+ dur: cpuEndTime - cpuStartTime,
72
+ args: {
73
+ data: {
74
+ url: 'parcel',
75
+ lineNumber: 1,
76
+ columnNumber: 1,
77
+ frame: '0xFFF',
78
+ },
79
+ },
80
+ });
81
+ trace.instantEvent({
82
+ tid,
83
+ ts: 0,
84
+ ph: 'M',
85
+ cat: ['__metadata'],
86
+ name: 'thread_name',
87
+ args: { name },
88
+ });
89
+ trace.instantEvent({
90
+ tid,
91
+ name: 'CpuProfile',
92
+ id: this.getEventId(),
93
+ cat: ['disabled-by-default-devtools.timeline'],
94
+ ts: cpuEndTime,
95
+ args: {
96
+ data: {
97
+ cpuProfile: profile,
98
+ },
99
+ },
100
+ });
101
+ }
102
+ pipe(writable) {
103
+ return this.tracer.pipe(writable);
104
+ }
105
+ flush() {
106
+ this.tracer.push(null);
107
+ }
108
+ }
109
+ exports.default = Trace;
package/dist/Tracer.js ADDED
@@ -0,0 +1,132 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var _TraceMeasurement_active, _TraceMeasurement_name, _TraceMeasurement_pid, _TraceMeasurement_tid, _TraceMeasurement_start, _TraceMeasurement_data, _Tracer_traceEmitter, _Tracer_enabled;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.PluginTracer = exports.tracer = void 0;
16
+ const events_1 = require("@atlaspack/events");
17
+ const perf_hooks_1 = require("perf_hooks");
18
+ // @ts-expect-error TS7034
19
+ let tid;
20
+ try {
21
+ tid = require('worker_threads').threadId;
22
+ }
23
+ catch {
24
+ tid = 0;
25
+ }
26
+ const pid = process.pid;
27
+ class TraceMeasurement {
28
+ constructor(tracer, name, pid, tid, data) {
29
+ _TraceMeasurement_active.set(this, true);
30
+ _TraceMeasurement_name.set(this, void 0);
31
+ _TraceMeasurement_pid.set(this, void 0);
32
+ _TraceMeasurement_tid.set(this, void 0);
33
+ _TraceMeasurement_start.set(this, void 0);
34
+ _TraceMeasurement_data.set(this, void 0);
35
+ __classPrivateFieldSet(this, _TraceMeasurement_name, name, "f");
36
+ __classPrivateFieldSet(this, _TraceMeasurement_pid, pid, "f");
37
+ __classPrivateFieldSet(this, _TraceMeasurement_tid, tid, "f");
38
+ __classPrivateFieldSet(this, _TraceMeasurement_start, perf_hooks_1.performance.now(), "f");
39
+ __classPrivateFieldSet(this, _TraceMeasurement_data, data, "f");
40
+ }
41
+ end() {
42
+ if (!__classPrivateFieldGet(this, _TraceMeasurement_active, "f"))
43
+ return;
44
+ const duration = perf_hooks_1.performance.now() - __classPrivateFieldGet(this, _TraceMeasurement_start, "f");
45
+ exports.tracer.trace({
46
+ type: 'trace',
47
+ name: __classPrivateFieldGet(this, _TraceMeasurement_name, "f"),
48
+ pid: __classPrivateFieldGet(this, _TraceMeasurement_pid, "f"),
49
+ tid: __classPrivateFieldGet(this, _TraceMeasurement_tid, "f"),
50
+ duration,
51
+ ts: __classPrivateFieldGet(this, _TraceMeasurement_start, "f"),
52
+ ...__classPrivateFieldGet(this, _TraceMeasurement_data, "f"),
53
+ });
54
+ __classPrivateFieldSet(this, _TraceMeasurement_active, false, "f");
55
+ }
56
+ }
57
+ _TraceMeasurement_active = new WeakMap(), _TraceMeasurement_name = new WeakMap(), _TraceMeasurement_pid = new WeakMap(), _TraceMeasurement_tid = new WeakMap(), _TraceMeasurement_start = new WeakMap(), _TraceMeasurement_data = new WeakMap();
58
+ class Tracer {
59
+ constructor() {
60
+ _Tracer_traceEmitter.set(this, new events_1.ValueEmitter());
61
+ _Tracer_enabled.set(this, false);
62
+ }
63
+ onTrace(cb) {
64
+ return __classPrivateFieldGet(this, _Tracer_traceEmitter, "f").addListener(cb);
65
+ }
66
+ async wrap(name, fn) {
67
+ let measurement = this.createMeasurement(name);
68
+ try {
69
+ await fn();
70
+ }
71
+ finally {
72
+ measurement && measurement.end();
73
+ }
74
+ }
75
+ createMeasurement(name, category = 'Core', argumentName, otherArgs) {
76
+ if (!this.enabled)
77
+ return null;
78
+ // We create `args` in a fairly verbose way to avoid object
79
+ // allocation where not required.
80
+ let args;
81
+ if (typeof argumentName === 'string') {
82
+ args = { name: argumentName };
83
+ }
84
+ if (typeof otherArgs === 'object') {
85
+ // @ts-expect-error TS2454
86
+ if (typeof args == 'undefined') {
87
+ args = {};
88
+ }
89
+ for (const [k, v] of Object.entries(otherArgs)) {
90
+ args[k] = v;
91
+ }
92
+ }
93
+ const data = {
94
+ categories: [category],
95
+ // @ts-expect-error TS2454
96
+ args,
97
+ };
98
+ // @ts-expect-error TS7005
99
+ return new TraceMeasurement(this, name, pid, tid, data);
100
+ }
101
+ get enabled() {
102
+ return __classPrivateFieldGet(this, _Tracer_enabled, "f");
103
+ }
104
+ enable() {
105
+ __classPrivateFieldSet(this, _Tracer_enabled, true, "f");
106
+ }
107
+ disable() {
108
+ __classPrivateFieldSet(this, _Tracer_enabled, false, "f");
109
+ }
110
+ trace(event) {
111
+ if (!__classPrivateFieldGet(this, _Tracer_enabled, "f"))
112
+ return;
113
+ __classPrivateFieldGet(this, _Tracer_traceEmitter, "f").emit(event);
114
+ }
115
+ }
116
+ _Tracer_traceEmitter = new WeakMap(), _Tracer_enabled = new WeakMap();
117
+ exports.default = Tracer;
118
+ exports.tracer = new Tracer();
119
+ class PluginTracer {
120
+ /** @private */
121
+ constructor(opts) {
122
+ this.origin = opts.origin;
123
+ this.category = opts.category;
124
+ }
125
+ get enabled() {
126
+ return exports.tracer.enabled;
127
+ }
128
+ createMeasurement(name, category, argumentName, otherArgs) {
129
+ return exports.tracer.createMeasurement(name, `${this.category}:${this.origin}${typeof category === 'string' ? `:${category}` : ''}`, argumentName, otherArgs);
130
+ }
131
+ }
132
+ exports.PluginTracer = PluginTracer;
package/dist/index.js ADDED
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.PluginTracer = exports.tracer = exports.Trace = exports.SamplingProfiler = void 0;
7
+ var SamplingProfiler_1 = require("./SamplingProfiler");
8
+ Object.defineProperty(exports, "SamplingProfiler", { enumerable: true, get: function () { return __importDefault(SamplingProfiler_1).default; } });
9
+ var Trace_1 = require("./Trace");
10
+ Object.defineProperty(exports, "Trace", { enumerable: true, get: function () { return __importDefault(Trace_1).default; } });
11
+ var Tracer_1 = require("./Tracer");
12
+ Object.defineProperty(exports, "tracer", { enumerable: true, get: function () { return Tracer_1.tracer; } });
13
+ Object.defineProperty(exports, "PluginTracer", { enumerable: true, get: function () { return Tracer_1.PluginTracer; } });
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -20,10 +20,16 @@ function _diagnostic() {
20
20
  }
21
21
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22
22
  // https://chromedevtools.github.io/devtools-protocol/tot/Profiler#type-Profile
23
+
23
24
  // https://chromedevtools.github.io/devtools-protocol/tot/Profiler#type-ProfileNode
25
+
24
26
  // https://chromedevtools.github.io/devtools-protocol/tot/Runtime#type-CallFrame
27
+
25
28
  // https://chromedevtools.github.io/devtools-protocol/tot/Profiler#type-PositionTickInfo
29
+
26
30
  class SamplingProfiler {
31
+ // @ts-expect-error not initialized
32
+
27
33
  startProfiling() {
28
34
  let inspector;
29
35
  try {
package/lib/Tracer.js CHANGED
@@ -18,7 +18,7 @@ function _perf_hooks() {
18
18
  };
19
19
  return data;
20
20
  }
21
- // @ts-ignore
21
+ // @ts-expect-error TS7034
22
22
  let tid;
23
23
  try {
24
24
  tid = require('worker_threads').threadId;
@@ -32,7 +32,6 @@ class TraceMeasurement {
32
32
  #pid;
33
33
  #tid;
34
34
  #start;
35
- // $FlowFixMe
36
35
  #data;
37
36
  constructor(tracer, name, pid, tid, data) {
38
37
  this.#name = name;
@@ -82,6 +81,7 @@ class Tracer {
82
81
  };
83
82
  }
84
83
  if (typeof otherArgs === 'object') {
84
+ // @ts-expect-error TS2454
85
85
  if (typeof args == 'undefined') {
86
86
  args = {};
87
87
  }
@@ -91,8 +91,11 @@ class Tracer {
91
91
  }
92
92
  const data = {
93
93
  categories: [category],
94
+ // @ts-expect-error TS2454
94
95
  args
95
96
  };
97
+
98
+ // @ts-expect-error TS7005
96
99
  return new TraceMeasurement(this, name, pid, tid, data);
97
100
  }
98
101
  get enabled() {
@@ -1,4 +1,4 @@
1
- import type { Session } from "inspector";
1
+ import type { Session } from 'inspector';
2
2
  export type Profile = {
3
3
  nodes: Array<ProfileNode>;
4
4
  startTime: number;
@@ -28,7 +28,7 @@ type PositionTickInfo = {
28
28
  export default class SamplingProfiler {
29
29
  session: Session;
30
30
  startProfiling(): Promise<unknown>;
31
- sendCommand(method: string, params?: unknown): Promise<{
31
+ sendCommand(method: string, params?: any): Promise<{
32
32
  profile: Profile;
33
33
  }>;
34
34
  destroy(): void;
@@ -1,6 +1,6 @@
1
- import type { Profile } from "./SamplingProfiler";
2
- import type { Writable } from "stream";
3
- import { Tracer } from "chrome-trace-event";
1
+ import type { Profile } from './SamplingProfiler';
2
+ import type { Writable } from 'stream';
3
+ import { Tracer } from 'chrome-trace-event';
4
4
  export default class Trace {
5
5
  tracer: Tracer;
6
6
  tid: number;
@@ -1,10 +1,12 @@
1
- import type { TraceEvent, IDisposable, PluginTracer as IPluginTracer } from "@atlaspack/types";
2
- import type { TraceMeasurement as ITraceMeasurement } from "./types";
1
+ import type { TraceEvent, IDisposable, PluginTracer as IPluginTracer } from '@atlaspack/types-internal';
2
+ import type { TraceMeasurement as ITraceMeasurement } from './types';
3
3
  export default class Tracer {
4
-
4
+ #private;
5
5
  onTrace(cb: (event: TraceEvent) => unknown): IDisposable;
6
6
  wrap(name: string, fn: () => unknown): Promise<void>;
7
- createMeasurement(name: string, category?: string, argumentName?: string, otherArgs?: Record<string, unknown>): ITraceMeasurement | null;
7
+ createMeasurement(name: string, category?: string, argumentName?: string, otherArgs?: {
8
+ [key: string]: unknown;
9
+ }): ITraceMeasurement | null;
8
10
  get enabled(): boolean;
9
11
  enable(): void;
10
12
  disable(): void;
@@ -23,6 +25,8 @@ export declare class PluginTracer implements IPluginTracer {
23
25
  /** @private */
24
26
  constructor(opts: TracerOpts);
25
27
  get enabled(): boolean;
26
- createMeasurement(name: string, category?: string, argumentName?: string, otherArgs?: Record<string, unknown>): ITraceMeasurement | null;
28
+ createMeasurement(name: string, category?: string, argumentName?: string, otherArgs?: {
29
+ [key: string]: unknown;
30
+ }): ITraceMeasurement | null;
27
31
  }
28
32
  export {};
@@ -0,0 +1,4 @@
1
+ export { default as SamplingProfiler } from './SamplingProfiler';
2
+ export { default as Trace } from './Trace';
3
+ export { tracer, PluginTracer } from './Tracer';
4
+ export type { TraceMeasurement, TraceMeasurementData } from './types';
@@ -0,0 +1,7 @@
1
+ export type { TraceMeasurement } from '@atlaspack/types-internal';
2
+ export type TraceMeasurementData = {
3
+ readonly categories: string[];
4
+ readonly args?: {
5
+ [key: string]: unknown;
6
+ };
7
+ };