@jsenv/test 3.6.13 → 3.7.1

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.
@@ -211,6 +211,30 @@ function isUnicodeSupported() {
211
211
  || env.TERMINAL_EMULATOR === 'JetBrains-JediTerm';
212
212
  }
213
213
 
214
+ function ansiRegex({onlyFirst = false} = {}) {
215
+ // Valid string terminator sequences are BEL, ESC\, and 0x9c
216
+ const ST = '(?:\\u0007|\\u001B\\u005C|\\u009C)';
217
+ const pattern = [
218
+ `[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?${ST})`,
219
+ '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))',
220
+ ].join('|');
221
+
222
+ return new RegExp(pattern, onlyFirst ? undefined : 'g');
223
+ }
224
+
225
+ const regex = ansiRegex();
226
+
227
+ function stripAnsi(string) {
228
+ if (typeof string !== 'string') {
229
+ throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
230
+ }
231
+
232
+ // Even though the regex is global, we don't need to reset the `.lastIndex`
233
+ // because unlike `.exec()` and `.test()`, `.replace()` does it automatically
234
+ // and doing it manually has a performance penalty.
235
+ return string.replace(regex, '');
236
+ }
237
+
214
238
  const r = String.raw;
215
239
  const seq = r`(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})`;
216
240
  const sTags = r`\u{E0061}-\u{E007A}`;
@@ -682,4 +706,177 @@ const clearTerminal = isWindows
682
706
  // More info: https://www.real-world-systems.com/docs/ANSIcode.html
683
707
  : `${eraseScreen}${ESC}3J${ESC}H`;
684
708
 
685
- export { clearTerminal, createSupportsColor, eastAsianWidth, emojiRegex, eraseLines, isUnicodeSupported };
709
+ function createRawFrame(raw) {
710
+ return {
711
+ column: -1,
712
+ fileName: "",
713
+ line: -1,
714
+ name: "",
715
+ raw: raw,
716
+ sourceColumn: -1,
717
+ sourceFileName: "",
718
+ sourceLine: -1,
719
+ type: "",
720
+ };
721
+ }
722
+ var FIREFOX_WEBKIT = /([^@]+|^)@(.*):(\d+):(\d+)/;
723
+ var WEBKIT_ADDRESS_UNNAMED = /^(http(s)?:\/\/.*):(\d+):(\d+)$/;
724
+ var WEBKIT_NATIVE_UNNAMED = "[native code]";
725
+ function parsWebkit(str) {
726
+ if (str.includes(WEBKIT_NATIVE_UNNAMED)) {
727
+ return {
728
+ line: -1,
729
+ column: -1,
730
+ type: "native",
731
+ fileName: "",
732
+ name: "",
733
+ raw: str,
734
+ sourceColumn: -1,
735
+ sourceFileName: "",
736
+ sourceLine: -1,
737
+ };
738
+ }
739
+ var match = str.match(WEBKIT_ADDRESS_UNNAMED);
740
+ if (match) {
741
+ var line = match[3] ? +match[3] : -1;
742
+ var column = match[4] ? +match[4] : -1;
743
+ var fileName = match[1] ? match[1] : "";
744
+ return {
745
+ line: line,
746
+ column: column,
747
+ type: "",
748
+ fileName: fileName,
749
+ name: "",
750
+ raw: str,
751
+ sourceColumn: -1,
752
+ sourceFileName: "",
753
+ sourceLine: -1,
754
+ };
755
+ }
756
+ return createRawFrame(str);
757
+ }
758
+ function parseFirefoxWebkit(lines) {
759
+ return lines.map(function (str) {
760
+ var match = str.match(FIREFOX_WEBKIT);
761
+ if (!match) {
762
+ return parsWebkit(str);
763
+ }
764
+ var line = match[3] ? +match[3] : -1;
765
+ var column = match[4] ? +match[4] : -1;
766
+ var fileName = match[2] ? match[2] : "";
767
+ return {
768
+ line: line,
769
+ column: column,
770
+ type: match[0] ? "" : "native",
771
+ fileName: fileName,
772
+ name: (match[1] || "").trim(),
773
+ raw: str,
774
+ sourceColumn: -1,
775
+ sourceFileName: "",
776
+ sourceLine: -1,
777
+ };
778
+ });
779
+ }
780
+ // foo.bar.js:123:39
781
+ // foo.bar.js:123:39 <- original.js:123:34
782
+ var CHROME_MAPPED = /(.*?):(\d+):(\d+)(\s<-\s(.+):(\d+):(\d+))?/;
783
+ function parseMapped(frame, maybeMapped) {
784
+ var match = maybeMapped.match(CHROME_MAPPED);
785
+ if (match) {
786
+ frame.fileName = match[1];
787
+ frame.line = +match[2];
788
+ frame.column = +match[3];
789
+ if (match[5])
790
+ frame.sourceFileName = match[5];
791
+ if (match[6])
792
+ frame.sourceLine = +match[6];
793
+ if (match[7])
794
+ frame.sourceColumn = +match[7];
795
+ }
796
+ }
797
+ // at <SomeFramework>
798
+ var CHROME_IE_NATIVE_NO_LINE = /^at\s(<.*>)$/;
799
+ // at <SomeFramework>:123:39
800
+ var CHROME_IE_NATIVE = /^\s*at\s(<.*>):(\d+):(\d+)$/;
801
+ // at foo.bar(bob) (foo.bar.js:123:39)
802
+ // at foo.bar(bob) (foo.bar.js:123:39 <- original.js:123:34)
803
+ var CHROME_IE_FUNCTION = /^at\s(.*)\s\((.*)\)$/;
804
+ // >= Chrome 88
805
+ // spy() at Component.Foo [as constructor] (original.js:123:34)
806
+ // spy() at Component.Foo [as constructor] (foo.bar.js:123:39 <- original.js:123:34)
807
+ var CHROME_IE_FUNCTION_WITH_CALL = /^([\w\W]*)\s\((.*)\)/;
808
+ var CHROME_IE_DETECTOR = /\s*at\s.+/;
809
+ // at about:blank:1:7
810
+ // >= Chrome 99
811
+ // at /projects/foo.test.js:689:1 <- /projects/foo.test.js:10:1
812
+ var CHROME_BLANK = /\s*at\s(.*):(\d+):(\d+)$/;
813
+ function parseChromeIe(lines) {
814
+ // Many frameworks mess with error.stack. So we use this check
815
+ // to find the first line of the actual stack
816
+ var start = lines.findIndex(function (line) { return CHROME_IE_DETECTOR.test(line); });
817
+ if (start === -1) {
818
+ return [];
819
+ }
820
+ var frames = [];
821
+ for (var i = start; i < lines.length; i++) {
822
+ var str = lines[i].replace(/^\s+|\s+$/g, "");
823
+ var frame = createRawFrame(lines[i]);
824
+ var nativeNoLine = str.match(CHROME_IE_NATIVE_NO_LINE);
825
+ if (nativeNoLine) {
826
+ frame.fileName = nativeNoLine[1];
827
+ frame.type = "native";
828
+ frames.push(frame);
829
+ continue;
830
+ }
831
+ var native = str.match(CHROME_IE_NATIVE);
832
+ if (native) {
833
+ frame.fileName = native[1];
834
+ frame.type = "native";
835
+ if (native[2])
836
+ frame.line = +native[2];
837
+ if (native[3])
838
+ frame.column = +native[3];
839
+ frames.push(frame);
840
+ continue;
841
+ }
842
+ var withFn = str.match(CHROME_IE_FUNCTION);
843
+ if (withFn) {
844
+ frame.name = withFn[1];
845
+ parseMapped(frame, withFn[2]);
846
+ frames.push(frame);
847
+ continue;
848
+ }
849
+ var blank = str.match(CHROME_BLANK);
850
+ if (blank) {
851
+ frame.fileName = blank[1];
852
+ frame.line = +blank[2];
853
+ frame.column = +blank[3];
854
+ parseMapped(frame, blank[1] + ":" + blank[2] + ":" + blank[3]);
855
+ frames.push(frame);
856
+ continue;
857
+ }
858
+ var withFnCall = str.match(CHROME_IE_FUNCTION_WITH_CALL);
859
+ if (withFnCall) {
860
+ frame.name = withFnCall[1];
861
+ parseMapped(frame, withFnCall[2]);
862
+ frames.push(frame);
863
+ continue;
864
+ }
865
+ frames.push(frame);
866
+ }
867
+ return frames;
868
+ }
869
+ function parseStackTrace(stack) {
870
+ if (!stack)
871
+ return [];
872
+ var lines = stack.split("\n").filter(Boolean);
873
+ // Libraries like node's "assert" module mess with the stack trace by
874
+ // prepending custom data. So we need to do a precheck, to determine
875
+ // which browser the trace is coming from.
876
+ if (lines.some(function (line) { return CHROME_IE_DETECTOR.test(line); })) {
877
+ return parseChromeIe(lines);
878
+ }
879
+ return parseFirefoxWebkit(lines);
880
+ }
881
+
882
+ export { clearTerminal, createSupportsColor, eastAsianWidth, emojiRegex, eraseLines, isUnicodeSupported, parseStackTrace, stripAnsi };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/test",
3
- "version": "3.6.13",
3
+ "version": "3.7.1",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -17,7 +17,7 @@
17
17
  "exports": {
18
18
  ".": {
19
19
  "import": {
20
- "development": "./src/main.js",
20
+ "dev:jsenv": "./src/main.js",
21
21
  "default": "./dist/jsenv_test.js"
22
22
  }
23
23
  },
@@ -33,38 +33,40 @@
33
33
  "./dist/js/node_child_process_controlled.mjs",
34
34
  "./dist/js/node_worker_thread_controlled.mjs",
35
35
  "./dist/jsenv_test_node_modules.js",
36
- "./dist/js/node_child_process_controlled.mjs",
37
- "./dist/js/node_worker_thread_controlled.mjs"
36
+ "./dist/jsenv_test.js"
38
37
  ],
39
38
  "scripts": {
40
- "build": "node --conditions=development ./scripts/build.mjs",
39
+ "build": "node --conditions=dev:jsenv ./scripts/build.mjs",
41
40
  "prepublishOnly": "npm run build"
42
41
  },
43
42
  "optionalDependencies": {
44
- "playwright": "1.x"
43
+ "playwright": "1.x",
44
+ "playwright-core": "1.x"
45
45
  },
46
46
  "dependencies": {
47
47
  "@c88/v8-coverage": "0.1.1",
48
- "@jsenv/abort": "4.3.1",
49
- "@jsenv/ast": "6.6.9",
50
- "@jsenv/exception": "1.1.7",
51
- "@jsenv/filesystem": "4.15.0",
52
- "@jsenv/github-check-run": "0.2.23",
53
- "@jsenv/node-esm-resolution": "1.2.0",
54
- "@jsenv/humanize": "1.5.0",
55
- "@jsenv/plugin-supervisor": "1.6.13",
56
- "@jsenv/sourcemap": "1.3.5",
57
- "@jsenv/url-meta": "8.5.6",
58
- "@jsenv/urls": "2.7.2",
59
- "@jsenv/utils": "2.3.0",
48
+ "@jsenv/ast": "6.6.11",
49
+ "@jsenv/plugin-supervisor": "1.6.15",
50
+ "@jsenv/sourcemap": "1.3.7",
60
51
  "he": "1.2.0",
61
52
  "istanbul-lib-coverage": "3.2.2",
62
53
  "istanbul-lib-instrument": "6.0.3",
63
54
  "istanbul-lib-report": "3.0.1",
64
55
  "istanbul-reports": "3.1.7",
65
56
  "pidtree": "0.6.0",
66
- "strip-ansi": "7.1.0",
67
- "supports-color": "10.0.0",
68
57
  "v8-to-istanbul": "9.3.0"
58
+ },
59
+ "devDependencies": {
60
+ "@jsenv/abort": "4.3.1",
61
+ "@jsenv/exception": "1.2.0",
62
+ "@jsenv/filesystem": "4.15.2",
63
+ "@jsenv/github-check-run": "0.3.1",
64
+ "@jsenv/node-esm-resolution": "1.2.1",
65
+ "@jsenv/url-meta": "8.5.7",
66
+ "@jsenv/urls": "2.7.4",
67
+ "@jsenv/utils": "2.3.1",
68
+ "@jsenv/humanize": "1.5.2",
69
+ "strip-ansi": "7.1.0",
70
+ "supports-color": "10.0.0"
69
71
  }
70
72
  }
@@ -1,6 +1,5 @@
1
- import { findFreePort } from "@jsenv/server";
2
-
3
1
  import { createDetailedMessage } from "@jsenv/humanize";
2
+ import { findFreePort } from "@jsenv/server/src/internal/listen.js";
4
3
  import { ExecOptions } from "./exec_options.js";
5
4
 
6
5
  export const createChildExecOptions = async ({