@atlaspack/profiler 2.14.1-canary.43 → 2.14.1-canary.431

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,358 @@
1
1
  # @atlaspack/profiler
2
2
 
3
+ ## 2.15.10
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies []:
8
+ - @atlaspack/logger@2.14.41
9
+ - @atlaspack/utils@3.3.1
10
+ - @atlaspack/types-internal@2.22.6
11
+
12
+ ## 2.15.9
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies [[`47aa84e`](https://github.com/atlassian-labs/atlaspack/commit/47aa84e44c61066072a5bf3d57678565b9d2c5a3)]:
17
+ - @atlaspack/utils@3.3.0
18
+ - @atlaspack/logger@2.14.40
19
+ - @atlaspack/types-internal@2.22.5
20
+
21
+ ## 2.15.8
22
+
23
+ ### Patch Changes
24
+
25
+ - Updated dependencies []:
26
+ - @atlaspack/logger@2.14.39
27
+ - @atlaspack/utils@3.2.8
28
+ - @atlaspack/types-internal@2.22.4
29
+
30
+ ## 2.15.7
31
+
32
+ ### Patch Changes
33
+
34
+ - Updated dependencies [[`02cc8b3`](https://github.com/atlassian-labs/atlaspack/commit/02cc8b32c06ca6b51806b33f6f707ca06e55e957)]:
35
+ - @atlaspack/types-internal@2.22.3
36
+ - @atlaspack/logger@2.14.38
37
+ - @atlaspack/utils@3.2.7
38
+
39
+ ## 2.15.6
40
+
41
+ ### Patch Changes
42
+
43
+ - Updated dependencies []:
44
+ - @atlaspack/types-internal@2.22.2
45
+ - @atlaspack/utils@3.2.6
46
+ - @atlaspack/logger@2.14.37
47
+
48
+ ## 2.15.5
49
+
50
+ ### Patch Changes
51
+
52
+ - Updated dependencies []:
53
+ - @atlaspack/logger@2.14.36
54
+ - @atlaspack/utils@3.2.5
55
+ - @atlaspack/types-internal@2.22.1
56
+
57
+ ## 2.15.4
58
+
59
+ ### Patch Changes
60
+
61
+ - Updated dependencies [[`00fa643`](https://github.com/atlassian-labs/atlaspack/commit/00fa6433202bfd3311479f6314c9ec878a789f2c)]:
62
+ - @atlaspack/types-internal@2.22.0
63
+ - @atlaspack/logger@2.14.35
64
+ - @atlaspack/utils@3.2.4
65
+
66
+ ## 2.15.3
67
+
68
+ ### Patch Changes
69
+
70
+ - Updated dependencies []:
71
+ - @atlaspack/logger@2.14.34
72
+ - @atlaspack/utils@3.2.3
73
+ - @atlaspack/types-internal@2.21.3
74
+
75
+ ## 2.15.2
76
+
77
+ ### Patch Changes
78
+
79
+ - Updated dependencies []:
80
+ - @atlaspack/logger@2.14.33
81
+ - @atlaspack/utils@3.2.2
82
+ - @atlaspack/types-internal@2.21.2
83
+
84
+ ## 2.15.1
85
+
86
+ ### Patch Changes
87
+
88
+ - Updated dependencies []:
89
+ - @atlaspack/logger@2.14.32
90
+ - @atlaspack/utils@3.2.1
91
+ - @atlaspack/types-internal@2.21.1
92
+
93
+ ## 2.15.0
94
+
95
+ ### Minor Changes
96
+
97
+ - [#892](https://github.com/atlassian-labs/atlaspack/pull/892) [`617a318`](https://github.com/atlassian-labs/atlaspack/commit/617a318ddc9419b38360257353fec50b9051ee13) Thanks [@marcins](https://github.com/marcins)! - Added a new `shouldProfileNative` option that provides a way to pause and connect a native profiler to Atlaspack.
98
+
99
+ ### Patch Changes
100
+
101
+ - Updated dependencies [[`8eb84ee`](https://github.com/atlassian-labs/atlaspack/commit/8eb84ee61a42bfe87c58079b610802b07a6a13e4), [`73168c2`](https://github.com/atlassian-labs/atlaspack/commit/73168c275a5d9abff9907bcf536b340bca1ed5f0), [`617a318`](https://github.com/atlassian-labs/atlaspack/commit/617a318ddc9419b38360257353fec50b9051ee13)]:
102
+ - @atlaspack/types-internal@2.21.0
103
+ - @atlaspack/utils@3.2.0
104
+ - @atlaspack/logger@2.14.31
105
+
106
+ ## 2.14.35
107
+
108
+ ### Patch Changes
109
+
110
+ - Updated dependencies []:
111
+ - @atlaspack/types-internal@2.20.8
112
+
113
+ ## 2.14.34
114
+
115
+ ### Patch Changes
116
+
117
+ - Updated dependencies []:
118
+ - @atlaspack/types-internal@2.20.7
119
+
120
+ ## 2.14.33
121
+
122
+ ### Patch Changes
123
+
124
+ - Updated dependencies []:
125
+ - @atlaspack/types-internal@2.20.6
126
+
127
+ ## 2.14.32
128
+
129
+ ### Patch Changes
130
+
131
+ - Updated dependencies [[`c372f3f`](https://github.com/atlassian-labs/atlaspack/commit/c372f3fd6fce8200d5cf47f41bc7895c6cbb5558)]:
132
+ - @atlaspack/types-internal@2.20.5
133
+
134
+ ## 2.14.31
135
+
136
+ ### Patch Changes
137
+
138
+ - Updated dependencies []:
139
+ - @atlaspack/types-internal@2.20.4
140
+
141
+ ## 2.14.30
142
+
143
+ ### Patch Changes
144
+
145
+ - Updated dependencies []:
146
+ - @atlaspack/types-internal@2.20.3
147
+
148
+ ## 2.14.29
149
+
150
+ ### Patch Changes
151
+
152
+ - Updated dependencies []:
153
+ - @atlaspack/types-internal@2.20.2
154
+
155
+ ## 2.14.28
156
+
157
+ ### Patch Changes
158
+
159
+ - [#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.
160
+
161
+ - Updated dependencies [[`0e7dd5e`](https://github.com/atlassian-labs/atlaspack/commit/0e7dd5ec6fbe05aa9e0bb5775a9d0975f206a922)]:
162
+ - @atlaspack/diagnostic@2.14.4
163
+ - @atlaspack/types-internal@2.20.1
164
+ - @atlaspack/events@2.14.4
165
+
166
+ ## 2.14.27
167
+
168
+ ### Patch Changes
169
+
170
+ - Updated dependencies [[`eedcbc4`](https://github.com/atlassian-labs/atlaspack/commit/eedcbc408fc1e86a2a8e25f1a41c57146d8529e1), [`f6532d7`](https://github.com/atlassian-labs/atlaspack/commit/f6532d7a4f7f007bd4e5e36af04dd466f0b9f572)]:
171
+ - @atlaspack/types-internal@2.20.0
172
+
173
+ ## 2.14.26
174
+
175
+ ### Patch Changes
176
+
177
+ - Updated dependencies []:
178
+ - @atlaspack/types-internal@2.19.5
179
+
180
+ ## 2.14.25
181
+
182
+ ### Patch Changes
183
+
184
+ - Updated dependencies []:
185
+ - @atlaspack/types-internal@2.19.4
186
+
187
+ ## 2.14.24
188
+
189
+ ### Patch Changes
190
+
191
+ - Updated dependencies []:
192
+ - @atlaspack/types-internal@2.19.3
193
+
194
+ ## 2.14.23
195
+
196
+ ### Patch Changes
197
+
198
+ - [#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
199
+
200
+ - Updated dependencies [[`ee040bb`](https://github.com/atlassian-labs/atlaspack/commit/ee040bb6428f29b57d892ddd8107e29077d08ffd)]:
201
+ - @atlaspack/types-internal@2.19.2
202
+ - @atlaspack/diagnostic@2.14.3
203
+ - @atlaspack/events@2.14.3
204
+
205
+ ## 2.14.22
206
+
207
+ ### Patch Changes
208
+
209
+ - Updated dependencies []:
210
+ - @atlaspack/types-internal@2.19.1
211
+
212
+ ## 2.14.21
213
+
214
+ ### Patch Changes
215
+
216
+ - Updated dependencies [[`7f5841c`](https://github.com/atlassian-labs/atlaspack/commit/7f5841c39df049f9546cccbeea2a7337e0337b45)]:
217
+ - @atlaspack/types-internal@2.19.0
218
+
219
+ ## 2.14.20
220
+
221
+ ### Patch Changes
222
+
223
+ - Updated dependencies [[`23d561e`](https://github.com/atlassian-labs/atlaspack/commit/23d561e51e68b0c38fd1ff4e4fb173e5e7b01cf2)]:
224
+ - @atlaspack/types-internal@2.18.0
225
+
226
+ ## 2.14.19
227
+
228
+ ### Patch Changes
229
+
230
+ - [#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
231
+
232
+ - Updated dependencies [[`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94), [`43fdd22`](https://github.com/atlassian-labs/atlaspack/commit/43fdd223860fbc97af17d68c65419b97412cb888)]:
233
+ - @atlaspack/types-internal@2.17.0
234
+ - @atlaspack/diagnostic@2.14.2
235
+ - @atlaspack/events@2.14.2
236
+
237
+ ## 2.14.18
238
+
239
+ ### Patch Changes
240
+
241
+ - Updated dependencies [[`069de47`](https://github.com/atlassian-labs/atlaspack/commit/069de478e64fb5889f6f2ce023eb510782767fbd)]:
242
+ - @atlaspack/types-internal@2.16.0
243
+
244
+ ## 2.14.17
245
+
246
+ ### Patch Changes
247
+
248
+ - Updated dependencies []:
249
+ - @atlaspack/types-internal@2.15.2
250
+
251
+ ## 2.14.16
252
+
253
+ ### Patch Changes
254
+
255
+ - Updated dependencies []:
256
+ - @atlaspack/types-internal@2.15.1
257
+
258
+ ## 2.14.15
259
+
260
+ ### Patch Changes
261
+
262
+ - Updated dependencies [[`18a57cf`](https://github.com/atlassian-labs/atlaspack/commit/18a57cf8a4789b2de5ad8e2676f317a26cc91417)]:
263
+ - @atlaspack/types-internal@2.15.0
264
+
265
+ ## 2.14.14
266
+
267
+ ### Patch Changes
268
+
269
+ - Updated dependencies []:
270
+ - @atlaspack/types-internal@2.14.14
271
+
272
+ ## 2.14.13
273
+
274
+ ### Patch Changes
275
+
276
+ - Updated dependencies []:
277
+ - @atlaspack/types-internal@2.14.13
278
+
279
+ ## 2.14.12
280
+
281
+ ### Patch Changes
282
+
283
+ - Updated dependencies []:
284
+ - @atlaspack/types-internal@2.14.12
285
+
286
+ ## 2.14.11
287
+
288
+ ### Patch Changes
289
+
290
+ - Updated dependencies []:
291
+ - @atlaspack/types-internal@2.14.11
292
+
293
+ ## 2.14.10
294
+
295
+ ### Patch Changes
296
+
297
+ - Updated dependencies []:
298
+ - @atlaspack/types-internal@2.14.10
299
+
300
+ ## 2.14.9
301
+
302
+ ### Patch Changes
303
+
304
+ - Updated dependencies []:
305
+ - @atlaspack/types-internal@2.14.9
306
+
307
+ ## 2.14.8
308
+
309
+ ### Patch Changes
310
+
311
+ - Updated dependencies [[`51aba5f`](https://github.com/atlassian-labs/atlaspack/commit/51aba5fc0e49235ee06bbc3c376f48c3e7da5c4b)]:
312
+ - @atlaspack/types-internal@2.14.8
313
+
314
+ ## 2.14.7
315
+
316
+ ### Patch Changes
317
+
318
+ - Updated dependencies []:
319
+ - @atlaspack/types-internal@2.14.7
320
+
321
+ ## 2.14.6
322
+
323
+ ### Patch Changes
324
+
325
+ - Updated dependencies []:
326
+ - @atlaspack/types-internal@2.14.6
327
+
328
+ ## 2.14.5
329
+
330
+ ### Patch Changes
331
+
332
+ - Updated dependencies []:
333
+ - @atlaspack/types-internal@2.14.5
334
+
335
+ ## 2.14.4
336
+
337
+ ### Patch Changes
338
+
339
+ - Updated dependencies []:
340
+ - @atlaspack/types-internal@2.14.4
341
+
342
+ ## 2.14.3
343
+
344
+ ### Patch Changes
345
+
346
+ - Updated dependencies []:
347
+ - @atlaspack/types-internal@2.14.3
348
+
349
+ ## 2.14.2
350
+
351
+ ### Patch Changes
352
+
353
+ - Updated dependencies []:
354
+ - @atlaspack/types-internal@2.14.2
355
+
3
356
  ## 2.14.1
4
357
 
5
358
  ### Patch Changes
@@ -0,0 +1,205 @@
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 utils_1 = require("@atlaspack/utils");
7
+ const logger_1 = __importDefault(require("@atlaspack/logger"));
8
+ const readline_1 = __importDefault(require("readline"));
9
+ const chalk_1 = __importDefault(require("chalk"));
10
+ const child_process_1 = require("child_process");
11
+ const util_1 = require("util");
12
+ const execAsync = (0, util_1.promisify)(child_process_1.exec);
13
+ class NativeProfiler {
14
+ startProfiling(profilerType) {
15
+ const pid = process.pid;
16
+ const timeId = (0, utils_1.getTimeId)();
17
+ let filename;
18
+ let command;
19
+ logger_1.default.info({
20
+ origin: '@atlaspack/profiler',
21
+ message: 'Starting native profiling...',
22
+ });
23
+ if (profilerType === 'instruments') {
24
+ filename = `native-profile-${timeId}.trace`;
25
+ command = `xcrun xctrace record --template "CPU Profiler" --output ${filename} --attach ${pid}`;
26
+ }
27
+ else {
28
+ filename = `native-profile-${timeId}.json`;
29
+ command = `samply record --save-only --output ${filename} --pid ${pid}`;
30
+ }
31
+ // Display banner with PID and command
32
+ // Strip ANSI codes for length calculation
33
+ // eslint-disable-next-line no-control-regex
34
+ const stripAnsi = (str) => str.replace(/\u001b\[[0-9;]*m/g, '');
35
+ const boxWidth = Math.max(60, stripAnsi(command).length + 6);
36
+ const title = 'Native Profiling';
37
+ const titlePadding = Math.floor((boxWidth - title.length - 2) / 2);
38
+ const isTTY = process.stdin.isTTY;
39
+ const maxWaitTime = 30; // seconds
40
+ const padLine = (content) => {
41
+ const contentLength = stripAnsi(content).length;
42
+ const padding = Math.max(0, boxWidth - contentLength - 2);
43
+ return (chalk_1.default.blue('│') +
44
+ ' ' +
45
+ content +
46
+ ' '.repeat(padding) +
47
+ ' ' +
48
+ chalk_1.default.blue('│'));
49
+ };
50
+ // Make the command visually distinct and easy to copy
51
+ // Note: Hyperlinks can cause issues with commands (words become separate links)
52
+ // So we just make it visually prominent with colors
53
+ const makeCommandDisplay = (cmd) => {
54
+ return chalk_1.default.cyan.bold(cmd);
55
+ };
56
+ // Contextual message based on TTY
57
+ const continueMessage = isTTY
58
+ ? 'Press Enter or start the profiler to continue'
59
+ : `Build will continue when profiler has started, or after ${maxWaitTime}s`;
60
+ const banner = [
61
+ '',
62
+ chalk_1.default.blue('┌' + '─'.repeat(boxWidth) + '┐'),
63
+ chalk_1.default.blue('│') +
64
+ ' '.repeat(titlePadding) +
65
+ chalk_1.default.blue.bold(title) +
66
+ ' '.repeat(boxWidth - title.length - titlePadding) +
67
+ chalk_1.default.blue('│'),
68
+ chalk_1.default.blue('├' + '─'.repeat(boxWidth) + '┤'),
69
+ padLine(`${chalk_1.default.gray('PID:')} ${chalk_1.default.white.bold(String(pid))}`),
70
+ padLine(''),
71
+ padLine(chalk_1.default.gray('Command:')),
72
+ padLine(makeCommandDisplay(command)),
73
+ padLine(''),
74
+ padLine(chalk_1.default.gray('Run the command above to start profiling.')),
75
+ padLine(chalk_1.default.gray(continueMessage)),
76
+ chalk_1.default.blue('└' + '─'.repeat(boxWidth) + '┘'),
77
+ '',
78
+ ].join('\n');
79
+ // eslint-disable-next-line no-console
80
+ console.log(banner);
81
+ // In both interactive and non-interactive mode, detect when profiler is running
82
+ // In interactive mode, also allow user to press Enter to continue
83
+ if (!process.stdin.isTTY) {
84
+ return this.waitForProfiler(profilerType, pid);
85
+ }
86
+ // Interactive mode: wait for either user to press Enter OR profiler to be detected
87
+ return new Promise((resolve) => {
88
+ let resolved = false;
89
+ const doResolve = () => {
90
+ if (resolved)
91
+ return;
92
+ resolved = true;
93
+ logger_1.default.info({
94
+ origin: '@atlaspack/profiler',
95
+ message: 'Native profiling setup complete',
96
+ });
97
+ resolve();
98
+ };
99
+ const rl = readline_1.default.createInterface({
100
+ input: process.stdin,
101
+ output: process.stdout,
102
+ });
103
+ // User presses Enter
104
+ rl.on('line', () => {
105
+ rl.close();
106
+ doResolve();
107
+ });
108
+ // Also poll for profiler in the background
109
+ this.pollForProfiler(profilerType, pid, doResolve);
110
+ });
111
+ }
112
+ waitForProfiler(profilerType, pid) {
113
+ logger_1.default.info({
114
+ origin: '@atlaspack/profiler',
115
+ message: 'Non-interactive mode: waiting for profiler to attach...',
116
+ });
117
+ return new Promise((resolve) => {
118
+ this.pollForProfiler(profilerType, pid, () => {
119
+ logger_1.default.info({
120
+ origin: '@atlaspack/profiler',
121
+ message: 'Native profiling setup complete',
122
+ });
123
+ resolve();
124
+ });
125
+ });
126
+ }
127
+ async pollForProfiler(profilerType, pid, onDetected) {
128
+ const maxAttempts = 60; // 60 attempts * 500ms = 30 seconds max
129
+ const pollInterval = 500; // 500ms between checks
130
+ for (let attempt = 0; attempt < maxAttempts; attempt++) {
131
+ const isRunning = await this.checkProfilerRunning(profilerType, pid);
132
+ if (isRunning) {
133
+ // Instruments takes longer to start up (~5s), samply needs ~1s
134
+ const waitTime = profilerType === 'instruments' ? 5000 : 1000;
135
+ logger_1.default.info({
136
+ origin: '@atlaspack/profiler',
137
+ message: `Profiler detected, waiting ${waitTime}ms before continuing...`,
138
+ });
139
+ await new Promise((resolve) => setTimeout(resolve, waitTime));
140
+ onDetected();
141
+ return;
142
+ }
143
+ await new Promise((resolve) => setTimeout(resolve, pollInterval));
144
+ }
145
+ // If we couldn't detect the profiler after 30 seconds, log a warning and continue anyway
146
+ logger_1.default.warn({
147
+ origin: '@atlaspack/profiler',
148
+ message: 'Could not detect profiler after 30 seconds, continuing anyway...',
149
+ });
150
+ onDetected();
151
+ }
152
+ async checkProfilerRunning(profilerType, pid) {
153
+ try {
154
+ // Get all processes and filter in JavaScript
155
+ const { stdout } = await execAsync('ps aux');
156
+ const lines = stdout.split('\n').filter((line) => line.trim().length > 0);
157
+ // Use word boundaries to match the PID as a complete number
158
+ const pidRegex = new RegExp(`\\b${pid}\\b`);
159
+ // Determine the profiler process name to look for
160
+ const profilerName = profilerType === 'instruments' ? 'xctrace' : 'samply';
161
+ for (const line of lines) {
162
+ const lowerLine = line.toLowerCase();
163
+ // Skip lines that are part of our own process checking (avoid false positives)
164
+ // Skip lines containing "ps aux" or "grep" to avoid matching our own commands
165
+ if (lowerLine.includes('ps aux') || lowerLine.includes(' grep ')) {
166
+ continue;
167
+ }
168
+ // Skip our own process (the Atlaspack process itself)
169
+ // The PID column is the second field in ps aux output
170
+ const fields = line.trim().split(/\s+/);
171
+ if (fields.length >= 2 && fields[1] === String(pid)) {
172
+ continue;
173
+ }
174
+ // Check if this line contains the profiler name as a command
175
+ const profilerRegex = new RegExp(`\\b${profilerName}\\b`);
176
+ if (!profilerRegex.test(lowerLine)) {
177
+ continue;
178
+ }
179
+ // Now check if our PID appears in the command arguments (not in the PID column)
180
+ // The PID should appear after the profiler command, typically as --pid <pid> or --attach <pid>
181
+ // We need to check the command portion, which starts around column 11 in ps aux
182
+ // For safety, check if PID appears after the profiler name in the line
183
+ const profilerIndex = lowerLine.indexOf(profilerName);
184
+ if (profilerIndex === -1) {
185
+ continue;
186
+ }
187
+ // Check if PID appears in the command portion (after the profiler name)
188
+ const commandPortion = line.substring(profilerIndex);
189
+ if (pidRegex.test(commandPortion)) {
190
+ return true;
191
+ }
192
+ }
193
+ return false;
194
+ }
195
+ catch (error) {
196
+ // If the command fails, log and return false
197
+ logger_1.default.warn({
198
+ origin: '@atlaspack/profiler',
199
+ message: `Error checking profiler status: ${error.message}`,
200
+ });
201
+ return false;
202
+ }
203
+ }
204
+ }
205
+ exports.default = NativeProfiler;
@@ -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;