monocart-coverage-reports 2.13.2 → 3.0.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.
Files changed (68) hide show
  1. package/README.md +267 -114
  2. package/README.zh-Hans.md +268 -115
  3. package/lib/assets.js +6 -6
  4. package/lib/cli.js +191 -95
  5. package/lib/client/cdp-client.js +74 -43
  6. package/lib/client/coverage-client.js +24 -8
  7. package/lib/client/ws-session.js +115 -37
  8. package/lib/converter/ast-visitor.js +5 -7
  9. package/lib/converter/ast.js +6 -6
  10. package/lib/converter/collect-source-maps.js +9 -9
  11. package/lib/converter/converter.js +41 -115
  12. package/lib/converter/fake-source-coverage.js +64 -0
  13. package/lib/converter/find-original-range.js +3 -3
  14. package/lib/converter/flatten-source-maps.js +2 -4
  15. package/lib/converter/ignore.js +2 -4
  16. package/lib/converter/info-branch.js +5 -3
  17. package/lib/converter/info-function.js +5 -3
  18. package/lib/converter/info-statement.js +5 -3
  19. package/lib/converter/range-index.js +78 -0
  20. package/lib/converter/source-range-merge.js +103 -0
  21. package/lib/converter/untested.js +27 -55
  22. package/lib/default/options.js +13 -1
  23. package/lib/generate.js +44 -26
  24. package/lib/index.d.ts +52 -4
  25. package/lib/index.js +35 -41
  26. package/lib/istanbul/istanbul-summary.js +2 -2
  27. package/lib/istanbul/istanbul.js +35 -13
  28. package/lib/packages/chunks/chunk-RVOSNMVU.js +2 -0
  29. package/lib/packages/monocart-coverage-assets.js +4 -3
  30. package/lib/packages/monocart-coverage-converter.js +27 -0
  31. package/lib/packages/monocart-coverage-vendor.js +2 -41
  32. package/lib/packages/monocart-coverage-vendor.js.LICENSE +3 -221
  33. package/lib/platform/concurrency.js +47 -43
  34. package/lib/platform/share.js +1 -1
  35. package/lib/register/hooks.js +19 -13
  36. package/lib/register/register.js +5 -3
  37. package/lib/reports/codacy.js +3 -5
  38. package/lib/reports/codecov.js +3 -5
  39. package/lib/reports/console-details.js +5 -5
  40. package/lib/reports/console-summary.js +4 -4
  41. package/lib/reports/custom.js +8 -24
  42. package/lib/reports/markdown-details.js +4 -6
  43. package/lib/reports/markdown-summary.js +4 -6
  44. package/lib/reports/raw.js +10 -12
  45. package/lib/reports/v8-json.js +3 -5
  46. package/lib/reports/v8.js +3 -5
  47. package/lib/utils/dedupe.js +1 -1
  48. package/lib/utils/gc.js +30 -14
  49. package/lib/utils/markdown.js +2 -2
  50. package/lib/utils/merge/merge.js +2 -4
  51. package/lib/utils/merge/range-tree.js +1 -1
  52. package/lib/utils/request.js +85 -73
  53. package/lib/utils/snapshot.js +4 -4
  54. package/lib/utils/source-path.js +5 -5
  55. package/lib/utils/util.js +61 -41
  56. package/lib/v8/v8-summary.js +2 -4
  57. package/lib/v8/v8.js +11 -11
  58. package/migrate-to-3.md +175 -0
  59. package/package.json +153 -149
  60. package/skills/monocart-coverage-reports/SKILL.md +106 -0
  61. package/skills/monocart-coverage-reports/references/cli.md +108 -0
  62. package/skills/monocart-coverage-reports/references/collection.md +152 -0
  63. package/skills/monocart-coverage-reports/references/filtering-and-sourcemaps.md +170 -0
  64. package/skills/monocart-coverage-reports/references/reports-and-ci.md +219 -0
  65. package/skills/monocart-coverage-reports/references/repository-map.md +55 -0
  66. package/lib/index.mjs +0 -9
  67. package/lib/register/hooks.mjs +0 -3
  68. package/lib/register/register.mjs +0 -3
@@ -4,51 +4,19 @@ THIRD-PARTY SOFTWARE NOTICES AND INFORMATION
4
4
 
5
5
  The following inlined npm packages have license or notice files included below.
6
6
 
7
- - @jridgewell/sourcemap-codec@1.6.0 (https://github.com/jridgewell/sourcemaps)
8
7
  - balanced-match@4.0.4 (https://github.com/juliangruber/balanced-match)
9
8
  - brace-expansion@5.0.9 (https://github.com/juliangruber/brace-expansion)
10
- - buffer-crc32@1.0.0 (https://github.com/brianloveswords/buffer-crc32)
11
- - convert-source-map@2.0.0 (https://github.com/thlorenz/convert-source-map)
12
9
  - diff-sequences@29.6.3 (https://github.com/jestjs/jest)
13
10
  - find-up@8.0.0 (https://github.com/sindresorhus/find-up)
14
11
  - locate-path@8.0.0 (https://github.com/sindresorhus/locate-path)
15
12
  - minimatch@10.2.6 (https://github.com/isaacs/minimatch)
16
13
  - nanoid@3.3.20 (https://github.com/ai/nanoid)
17
- - node-stream-zip@1.16.0 (https://github.com/antelle/node-stream-zip)
18
- - p-limit@4.0.0 (https://github.com/sindresorhus/p-limit)
19
- - p-locate@6.0.0 (https://github.com/sindresorhus/p-locate)
20
14
  - picocolors@1.1.1 (https://github.com/alexeyraspopov/picocolors)
21
- - postcss@8.5.29 (https://github.com/postcss/postcss)
15
+ - postcss@8.5.30 (https://github.com/postcss/postcss)
22
16
  - source-map-js@1.2.2 (https://github.com/7rulnik/source-map-js)
23
17
  - supports-color@11.0.0 (https://github.com/chalk/supports-color)
24
18
  - unicorn-magic@0.3.0 (https://github.com/sindresorhus/unicorn-magic)
25
- - ws@8.22.0 (https://github.com/websockets/ws)
26
- - yazl@3.3.1 (https://github.com/thejoshwolfe/yazl)
27
- - yocto-queue@1.2.2 (https://github.com/sindresorhus/yocto-queue)
28
19
 
29
- %% @jridgewell/sourcemap-codec@1.6.0 NOTICES AND INFORMATION BEGIN HERE
30
- =========================================
31
- Copyright 2024 Justin Ridgewell <justin@ridgewell.name>
32
-
33
- Permission is hereby granted, free of charge, to any person obtaining a copy
34
- of this software and associated documentation files (the "Software"), to deal
35
- in the Software without restriction, including without limitation the rights
36
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
37
- copies of the Software, and to permit persons to whom the Software is
38
- furnished to do so, subject to the following conditions:
39
-
40
- The above copyright notice and this permission notice shall be included in
41
- all copies or substantial portions of the Software.
42
-
43
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
44
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
45
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
46
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
47
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
48
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
49
- SOFTWARE.
50
- =========================================
51
- END OF @jridgewell/sourcemap-codec@1.6.0 NOTICES AND INFORMATION
52
20
  %% balanced-match@4.0.4 NOTICES AND INFORMATION BEGIN HERE
53
21
  =========================================
54
22
  (MIT)
@@ -103,56 +71,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
103
71
  SOFTWARE.
104
72
  =========================================
105
73
  END OF brace-expansion@5.0.9 NOTICES AND INFORMATION
106
- %% buffer-crc32@1.0.0 NOTICES AND INFORMATION BEGIN HERE
107
- =========================================
108
- The MIT License
109
-
110
- Copyright (c) 2013-2024 Brian J. Brennan
111
-
112
- Permission is hereby granted, free of charge, to any person obtaining a copy
113
- of this software and associated documentation files (the "Software"), to deal in
114
- the Software without restriction, including without limitation the rights to use,
115
- copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
116
- Software, and to permit persons to whom the Software is furnished to do so,
117
- subject to the following conditions:
118
-
119
- The above copyright notice and this permission notice shall be included in all
120
- copies or substantial portions of the Software.
121
-
122
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
123
- INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
124
- PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
125
- FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
126
- ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
127
- =========================================
128
- END OF buffer-crc32@1.0.0 NOTICES AND INFORMATION
129
- %% convert-source-map@2.0.0 NOTICES AND INFORMATION BEGIN HERE
130
- =========================================
131
- Copyright 2013 Thorsten Lorenz.
132
- All rights reserved.
133
-
134
- Permission is hereby granted, free of charge, to any person
135
- obtaining a copy of this software and associated documentation
136
- files (the "Software"), to deal in the Software without
137
- restriction, including without limitation the rights to use,
138
- copy, modify, merge, publish, distribute, sublicense, and/or sell
139
- copies of the Software, and to permit persons to whom the
140
- Software is furnished to do so, subject to the following
141
- conditions:
142
-
143
- The above copyright notice and this permission notice shall be
144
- included in all copies or substantial portions of the Software.
145
-
146
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
147
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
148
- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
149
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
150
- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
151
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
152
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
153
- OTHER DEALINGS IN THE SOFTWARE.
154
- =========================================
155
- END OF convert-source-map@2.0.0 NOTICES AND INFORMATION
156
74
  %% diff-sequences@29.6.3 NOTICES AND INFORMATION BEGIN HERE
157
75
  =========================================
158
76
  MIT License
@@ -287,80 +205,6 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
287
205
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
288
206
  =========================================
289
207
  END OF nanoid@3.3.20 NOTICES AND INFORMATION
290
- %% node-stream-zip@1.16.0 NOTICES AND INFORMATION BEGIN HERE
291
- =========================================
292
- Copyright (c) 2021 Antelle https://github.com/antelle
293
-
294
- Permission is hereby granted, free of charge, to any person obtaining
295
- a copy of this software and associated documentation files (the
296
- "Software"), to deal in the Software without restriction, including
297
- without limitation the rights to use, copy, modify, merge, publish,
298
- distribute, sublicense, and/or sell copies of the Software, and to
299
- permit persons to whom the Software is furnished to do so, subject to
300
- the following conditions:
301
-
302
- The above copyright notice and this permission notice shall be
303
- included in all copies or substantial portions of the Software.
304
-
305
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
306
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
307
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
308
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
309
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
310
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
311
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
312
-
313
- == dependency license: adm-zip ==
314
-
315
- Copyright (c) 2012 Another-D-Mention Software and other contributors,
316
- http://www.another-d-mention.ro/
317
-
318
- Permission is hereby granted, free of charge, to any person obtaining
319
- a copy of this software and associated documentation files (the
320
- "Software"), to deal in the Software without restriction, including
321
- without limitation the rights to use, copy, modify, merge, publish,
322
- distribute, sublicense, and/or sell copies of the Software, and to
323
- permit persons to whom the Software is furnished to do so, subject to
324
- the following conditions:
325
-
326
- The above copyright notice and this permission notice shall be
327
- included in all copies or substantial portions of the Software.
328
-
329
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
330
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
331
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
332
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
333
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
334
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
335
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
336
- =========================================
337
- END OF node-stream-zip@1.16.0 NOTICES AND INFORMATION
338
- %% p-limit@4.0.0 NOTICES AND INFORMATION BEGIN HERE
339
- =========================================
340
- MIT License
341
-
342
- Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
343
-
344
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
345
-
346
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
347
-
348
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
349
- =========================================
350
- END OF p-limit@4.0.0 NOTICES AND INFORMATION
351
- %% p-locate@6.0.0 NOTICES AND INFORMATION BEGIN HERE
352
- =========================================
353
- MIT License
354
-
355
- Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
356
-
357
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
358
-
359
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
360
-
361
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
362
- =========================================
363
- END OF p-locate@6.0.0 NOTICES AND INFORMATION
364
208
  %% picocolors@1.1.1 NOTICES AND INFORMATION BEGIN HERE
365
209
  =========================================
366
210
  ISC License
@@ -380,7 +224,7 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
380
224
  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
381
225
  =========================================
382
226
  END OF picocolors@1.1.1 NOTICES AND INFORMATION
383
- %% postcss@8.5.29 NOTICES AND INFORMATION BEGIN HERE
227
+ %% postcss@8.5.30 NOTICES AND INFORMATION BEGIN HERE
384
228
  =========================================
385
229
  The MIT License (MIT)
386
230
 
@@ -403,7 +247,7 @@ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
403
247
  IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
404
248
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
405
249
  =========================================
406
- END OF postcss@8.5.29 NOTICES AND INFORMATION
250
+ END OF postcss@8.5.30 NOTICES AND INFORMATION
407
251
  %% source-map-js@1.2.2 NOTICES AND INFORMATION BEGIN HERE
408
252
  =========================================
409
253
  Copyright (c) 2009-2011, Mozilla Foundation and contributors
@@ -461,65 +305,3 @@ The above copyright notice and this permission notice shall be included in all c
461
305
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
462
306
  =========================================
463
307
  END OF unicorn-magic@0.3.0 NOTICES AND INFORMATION
464
- %% ws@8.22.0 NOTICES AND INFORMATION BEGIN HERE
465
- =========================================
466
- Copyright (c) 2011 Einar Otto Stangvik <einaros@gmail.com>
467
- Copyright (c) 2013 Arnout Kazemier and contributors
468
- Copyright (c) 2016 Luigi Pinca and contributors
469
-
470
- Permission is hereby granted, free of charge, to any person obtaining a copy of
471
- this software and associated documentation files (the "Software"), to deal in
472
- the Software without restriction, including without limitation the rights to
473
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
474
- the Software, and to permit persons to whom the Software is furnished to do so,
475
- subject to the following conditions:
476
-
477
- The above copyright notice and this permission notice shall be included in all
478
- copies or substantial portions of the Software.
479
-
480
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
481
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
482
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
483
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
484
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
485
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
486
- =========================================
487
- END OF ws@8.22.0 NOTICES AND INFORMATION
488
- %% yazl@3.3.1 NOTICES AND INFORMATION BEGIN HERE
489
- =========================================
490
- The MIT License (MIT)
491
-
492
- Copyright (c) 2014 Josh Wolfe
493
-
494
- Permission is hereby granted, free of charge, to any person obtaining a copy
495
- of this software and associated documentation files (the "Software"), to deal
496
- in the Software without restriction, including without limitation the rights
497
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
498
- copies of the Software, and to permit persons to whom the Software is
499
- furnished to do so, subject to the following conditions:
500
-
501
- The above copyright notice and this permission notice shall be included in all
502
- copies or substantial portions of the Software.
503
-
504
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
505
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
506
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
507
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
508
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
509
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
510
- SOFTWARE.
511
- =========================================
512
- END OF yazl@3.3.1 NOTICES AND INFORMATION
513
- %% yocto-queue@1.2.2 NOTICES AND INFORMATION BEGIN HERE
514
- =========================================
515
- MIT License
516
-
517
- Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
518
-
519
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
520
-
521
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
522
-
523
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
524
- =========================================
525
- END OF yocto-queue@1.2.2 NOTICES AND INFORMATION
@@ -1,8 +1,13 @@
1
1
  class Concurrency {
2
2
 
3
3
  constructor(maxCount = 10) {
4
+ if (!Number.isSafeInteger(maxCount) || maxCount < 1) {
5
+ throw new RangeError('Concurrency must be a positive safe integer');
6
+ }
4
7
  this.maxCount = maxCount;
5
8
  this.list = [];
9
+ this.count = 0;
10
+ this.run = null;
6
11
  }
7
12
 
8
13
  addItem(item) {
@@ -14,61 +19,60 @@ class Concurrency {
14
19
  }
15
20
 
16
21
  start(handler) {
17
- // must be async function
18
22
  if (typeof handler !== 'function') {
19
- return;
23
+ throw new TypeError('Concurrency handler must be a function');
20
24
  }
21
- this.handler = handler;
22
- this.count = 0;
23
- return new Promise((resolve) => {
24
- this.resolve = resolve;
25
- this.next();
25
+ if (this.run) {
26
+ throw new Error('Concurrency queue is already running');
27
+ }
28
+ const run = {
29
+ index: 0, failed: false, error: null
30
+ };
31
+ this.run = run;
32
+ const workers = Array.from({
33
+ length: Math.min(this.maxCount, this.list.length)
34
+ }, () => this.worker(run, handler));
35
+ // Drain in-flight work before settling, including after failure or clear().
36
+ // This prevents old workers from touching a reused queue or its files.
37
+ return Promise.all(workers).then(() => {
38
+ if (run.failed) {
39
+ throw run.error;
40
+ }
41
+ }).finally(() => {
42
+ this.list = [];
43
+ this.count = 0;
44
+ this.run = null;
26
45
  });
27
46
  }
28
47
 
29
- next() {
30
- // console.log(`list: ${this.list.length} count: ${this.count}`);
31
-
32
- // if has clear
33
- if (!this.resolve) {
34
- return;
35
- }
36
-
37
- if (!this.list.length) {
38
- // no list but has in progress count
39
- if (this.count > 0) {
40
- return;
48
+ async worker(run, handler) {
49
+ while (!run.failed && run.index < this.list.length) {
50
+ const index = run.index++;
51
+ const item = this.list[index];
52
+ this.list[index] = null;
53
+ this.count++;
54
+ try {
55
+ await handler(item);
56
+ } catch (error) {
57
+ if (!run.failed) {
58
+ run.failed = true;
59
+ run.error = error;
60
+ }
61
+ } finally {
62
+ this.count--;
41
63
  }
42
- // all finish
43
- this.resolve();
44
- this.clear();
45
- return;
46
64
  }
47
-
48
- // out of concurrency count, just wait
49
- if (this.count >= this.maxCount) {
50
- return;
51
- }
52
-
53
- const item = this.list.shift();
54
- this.count += 1;
55
-
56
- // async handler
57
- this.handler(item).finally(() => {
58
- this.count -= 1;
59
- this.next();
60
- });
61
-
62
- this.next();
63
65
  }
64
66
 
65
67
  clear() {
66
68
  this.list = [];
67
- this.handler = null;
68
- this.count = 0;
69
- this.resolve = null;
69
+ if (this.run && !this.run.failed) {
70
+ this.run.failed = true;
71
+ this.run.error = new Error('Concurrency queue cleared');
72
+ this.run.error.code = 'ABORT_ERR';
73
+ }
70
74
  }
71
75
 
72
76
  }
73
77
 
74
- module.exports = Concurrency;
78
+ export { Concurrency };
@@ -543,4 +543,4 @@ const Util = {
543
543
  };
544
544
 
545
545
 
546
- module.exports = Util;
546
+ export { Util };
@@ -1,7 +1,7 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
- const Util = require('../utils/util.js');
4
- const { convertSourceMap } = require('../packages/monocart-coverage-vendor.js');
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { createHash } from 'node:crypto';
4
+ import convertSourceMap from 'convert-source-map';
5
5
 
6
6
  function saveFile(url, source, dir) {
7
7
  if (!fs.existsSync(dir)) {
@@ -10,7 +10,7 @@ function saveFile(url, source, dir) {
10
10
  });
11
11
  }
12
12
 
13
- const id = Util.calculateSha1(url + source);
13
+ const id = createHash('sha1').update(url + source).digest('hex');
14
14
  const filePath = path.resolve(dir, `source-${id}.json`);
15
15
  if (!fs.existsSync(filePath)) {
16
16
  fs.writeFileSync(filePath, JSON.stringify({
@@ -28,9 +28,17 @@ function saveSource(url, loaded, dir) {
28
28
  return;
29
29
  }
30
30
 
31
- const { source, format } = loaded;
32
- if (typeof source !== 'string' || !['module', 'commonjs'].includes(format)) {
33
- // no source or wrong format
31
+ const { format } = loaded;
32
+ if (!['module', 'commonjs'].includes(format)) {
33
+ return;
34
+ }
35
+ let { source } = loaded;
36
+ if (ArrayBuffer.isView(source)) {
37
+ source = Buffer.from(source.buffer, source.byteOffset, source.byteLength).toString('utf8');
38
+ } else if (source instanceof ArrayBuffer) {
39
+ source = Buffer.from(source).toString('utf8');
40
+ }
41
+ if (typeof source !== 'string') {
34
42
  return;
35
43
  }
36
44
 
@@ -43,8 +51,8 @@ function saveSource(url, loaded, dir) {
43
51
 
44
52
  }
45
53
 
46
- async function load(url, context, nextLoad) {
47
- const loaded = await nextLoad(url, context);
54
+ function load(url, context, nextLoad) {
55
+ const loaded = nextLoad(url, context);
48
56
  const dir = process.env.NODE_V8_COVERAGE;
49
57
  if (dir) {
50
58
  // only for coverage enabled
@@ -53,6 +61,4 @@ async function load(url, context, nextLoad) {
53
61
  return loaded;
54
62
  }
55
63
 
56
- module.exports = {
57
- load
58
- };
64
+ export { load };
@@ -1,4 +1,6 @@
1
- const { register } = require('module');
2
- const { pathToFileURL } = require('url');
1
+ import { registerHooks } from 'node:module';
2
+ import { load } from './hooks.js';
3
3
 
4
- register('./hooks.js', pathToFileURL(__filename));
4
+ registerHooks({
5
+ load
6
+ });
@@ -1,5 +1,5 @@
1
- const path = require('path');
2
- const Util = require('../utils/util.js');
1
+ import path from 'node:path';
2
+ import { Util } from '../utils/util.js';
3
3
 
4
4
  const codacyReport = async (reportData, reportOptions, options) => {
5
5
  const codacyOptions = {
@@ -38,6 +38,4 @@ const codacyReport = async (reportData, reportOptions, options) => {
38
38
  };
39
39
 
40
40
 
41
- module.exports = {
42
- codacyReport
43
- };
41
+ export { codacyReport };
@@ -1,5 +1,5 @@
1
- const path = require('path');
2
- const Util = require('../utils/util.js');
1
+ import path from 'node:path';
2
+ import { Util } from '../utils/util.js';
3
3
 
4
4
  const codecovReport = async (reportData, reportOptions, options) => {
5
5
  const codecovOptions = {
@@ -23,6 +23,4 @@ const codecovReport = async (reportData, reportOptions, options) => {
23
23
  return Util.relativePath(jsonPath);
24
24
  };
25
25
 
26
- module.exports = {
27
- codecovReport
28
- };
26
+ export { codecovReport };
@@ -1,7 +1,7 @@
1
- const CG = require('console-grid');
2
- const EC = require('eight-colors');
3
- const { getGroupedRows } = require('../utils/snapshot.js');
4
- const Util = require('../utils/util.js');
1
+ import CG from 'console-grid';
2
+ import EC from 'eight-colors';
3
+ import { getGroupedRows } from '../utils/snapshot.js';
4
+ import { Util } from '../utils/util.js';
5
5
 
6
6
  const getRowData = (rowName, summary, metrics, color) => {
7
7
  const summaryRow = {};
@@ -133,7 +133,7 @@ const consoleDetailsReport = (reportData, reportOptions, options) => {
133
133
  });
134
134
  };
135
135
 
136
- module.exports = {
136
+ export {
137
137
  getRowData,
138
138
  getFilteredFiles,
139
139
  consoleDetailsReport
@@ -1,6 +1,6 @@
1
- const CG = require('console-grid');
2
- const EC = require('eight-colors');
3
- const Util = require('../utils/util.js');
1
+ import CG from 'console-grid';
2
+ import EC from 'eight-colors';
3
+ import { Util } from '../utils/util.js';
4
4
 
5
5
  const nFormatter = (v) => {
6
6
  if (typeof v === 'number') {
@@ -77,7 +77,7 @@ const consoleSummaryReport = (reportData, reportOptions, options) => {
77
77
  });
78
78
  };
79
79
 
80
- module.exports = {
80
+ export {
81
81
  getSummaryColumns,
82
82
  consoleSummaryReport
83
83
  };
@@ -1,26 +1,12 @@
1
- const { pathToFileURL } = require('url');
2
- const Util = require('../utils/util.js');
1
+ import path from 'node:path';
2
+ import { pathToFileURL } from 'node:url';
3
3
 
4
4
  const customReport = async (reportName, reportData, reportOptions, globalOptions) => {
5
- let CustomReporter;
6
- let err;
7
- try {
8
- CustomReporter = await import(reportName);
9
- } catch (e) {
10
- err = e;
11
- try {
12
- CustomReporter = await import(pathToFileURL(reportName));
13
- } catch (ee) {
14
- err = ee;
15
- }
16
- }
17
-
18
- if (!CustomReporter) {
19
- Util.logError(err.message);
20
- return;
21
- }
22
-
23
- CustomReporter = CustomReporter.default || CustomReporter;
5
+ // Use native ESM loading, including Node's built-in CJS interoperability.
6
+ const isFile = path.isAbsolute(reportName) || reportName.startsWith('.');
7
+ const specifier = isFile ? pathToFileURL(path.resolve(reportName)).href : reportName;
8
+ const reporterModule = await import(specifier);
9
+ const CustomReporter = reporterModule.default || reporterModule;
24
10
 
25
11
  const reporter = new CustomReporter(reportOptions, globalOptions);
26
12
 
@@ -29,6 +15,4 @@ const customReport = async (reportName, reportData, reportOptions, globalOptions
29
15
  return results;
30
16
  };
31
17
 
32
- module.exports = {
33
- customReport
34
- };
18
+ export { customReport };
@@ -1,7 +1,7 @@
1
- const path = require('path');
2
- const Util = require('../utils/util.js');
1
+ import path from 'node:path';
2
+ import { Util } from '../utils/util.js';
3
3
 
4
- const { getRowData, getFilteredFiles } = require('./console-details.js');
4
+ import { getRowData, getFilteredFiles } from './console-details.js';
5
5
 
6
6
  const cutWithMaxCols = (str, maxCols, before) => {
7
7
  if (str && maxCols && str.length > maxCols) {
@@ -115,6 +115,4 @@ const markdownDetailsReport = async (reportData, reportOptions, options) => {
115
115
  };
116
116
 
117
117
 
118
- module.exports = {
119
- markdownDetailsReport
120
- };
118
+ export { markdownDetailsReport };
@@ -1,7 +1,7 @@
1
- const path = require('path');
2
- const Util = require('../utils/util.js');
1
+ import path from 'node:path';
2
+ import { Util } from '../utils/util.js';
3
3
 
4
- const { getSummaryColumns } = require('./console-summary.js');
4
+ import { getSummaryColumns } from './console-summary.js';
5
5
 
6
6
  const markdownSummaryReport = async (reportData, reportOptions, options) => {
7
7
  const msOptions = {
@@ -39,6 +39,4 @@ const markdownSummaryReport = async (reportData, reportOptions, options) => {
39
39
  return Util.relativePath(mdPath);
40
40
  };
41
41
 
42
- module.exports = {
43
- markdownSummaryReport
44
- };
42
+ export { markdownSummaryReport };