@tapjs/processinfo 2.5.5 → 2.5.6

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,3 @@
1
+ /// <reference types="node" />
2
+ export declare const findSourceMapSafe: (s: string) => import("module").SourceMap | undefined;
3
+ //# sourceMappingURL=find-source-map-safe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find-source-map-safe.d.ts","sourceRoot":"","sources":["../../lib/find-source-map-safe.ts"],"names":[],"mappings":";AAIA,eAAO,MAAM,iBAAiB,MAAO,MAAM,2CAI1C,CAAA"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.findSourceMapSafe = void 0;
4
+ const module_1 = require("module");
5
+ // this can throw in some cases in node 19
6
+ /* c8 ignore start */
7
+ const findSourceMapSafe = (s) => {
8
+ try {
9
+ return (0, module_1.findSourceMap)(s);
10
+ }
11
+ catch { }
12
+ };
13
+ exports.findSourceMapSafe = findSourceMapSafe;
14
+ /* c8 ignore stop */
15
+ //# sourceMappingURL=find-source-map-safe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find-source-map-safe.js","sourceRoot":"","sources":["../../lib/find-source-map-safe.ts"],"names":[],"mappings":";;;AAAA,mCAAsC;AAEtC,0CAA0C;AAC1C,qBAAqB;AACd,MAAM,iBAAiB,GAAG,CAAC,CAAS,EAAE,EAAE;IAC7C,IAAI;QACF,OAAO,IAAA,sBAAa,EAAC,CAAC,CAAC,CAAA;KACxB;IAAC,MAAM,GAAE;AACZ,CAAC,CAAA;AAJY,QAAA,iBAAiB,qBAI7B;AACD,oBAAoB","sourcesContent":["import { findSourceMap } from 'module'\n\n// this can throw in some cases in node 19\n/* c8 ignore start */\nexport const findSourceMapSafe = (s: string) => {\n try {\n return findSourceMap(s)\n } catch {}\n}\n/* c8 ignore stop */\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"register-coverage.d.ts","sourceRoot":"","sources":["../../lib/register-coverage.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAKxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAY3D,eAAO,IAAI,OAAO,EAAE,OAAO,GAAG,SAAqB,CAAA;AAmDnD,eAAO,MAAM,QAAQ,YAYpB,CAAA;AAGD,eAAO,MAAM,oBAAoB,QAC1B,MAAM,eACE,mBAAmB,SA2DjC,CAAA"}
1
+ {"version":3,"file":"register-coverage.d.ts","sourceRoot":"","sources":["../../lib/register-coverage.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAMxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAG3D,eAAO,IAAI,OAAO,EAAE,OAAO,GAAG,SAAqB,CAAA;AAmDnD,eAAO,MAAM,QAAQ,YAYpB,CAAA;AAGD,eAAO,MAAM,oBAAoB,QAC1B,MAAM,eACE,mBAAmB,SA2DjC,CAAA"}
@@ -7,20 +7,11 @@ const p = process;
7
7
  const enabled = p.env._TAPJS_PROCESSINFO_COVERAGE_ !== '0';
8
8
  const node_fs_1 = require("node:fs");
9
9
  const node_inspector_1 = require("node:inspector");
10
- const node_module_1 = require("node:module");
11
10
  const node_path_1 = require("node:path");
12
11
  const node_url_1 = require("node:url");
12
+ const find_source_map_safe_js_1 = require("./find-source-map-safe.js");
13
13
  const get_exclude_js_1 = require("./get-exclude.js");
14
14
  const line_lengths_js_1 = require("./line-lengths.js");
15
- // this can throw in some cases in node 19
16
- /* c8 ignore start */
17
- const findSourceMapSafe = (s) => {
18
- try {
19
- return (0, node_module_1.findSourceMap)(s);
20
- }
21
- catch { }
22
- };
23
- /* c8 ignore stop */
24
15
  exports.SESSION = undefined;
25
16
  // NB: coverage exclusion is in addition to processinfo
26
17
  // exclusion. Only show coverage for a file we care
@@ -110,7 +101,7 @@ const coverageOnProcessEnd = (cwd, processInfo) => {
110
101
  // see if it has a source map
111
102
  // need to look up via the url, not the file path, because mocks
112
103
  // attach a tapmock search param, which is in node's internal key.
113
- const s = findSourceMapSafe(String(obj.url));
104
+ const s = (0, find_source_map_safe_js_1.findSourceMapSafe)(String(obj.url));
114
105
  if (!fileCovered(f, s?.payload, processInfo.files)) {
115
106
  return false;
116
107
  }
@@ -1 +1 @@
1
- {"version":3,"file":"register-coverage.js","sourceRoot":"","sources":["../../lib/register-coverage.ts"],"names":[],"mappings":";;;AAAA,sDAAsD;AACtD,8DAA8D;AAC9D,MAAM,CAAC,GAAG,OAAO,CAAA;AACjB,MAAM,OAAO,GAAG,CAAC,CAAC,GAAG,CAAC,4BAA4B,KAAK,GAAG,CAAA;AAC1D,qCAAkD;AAClD,mDAAwC;AACxC,6CAA6D;AAC7D,yCAAmC;AACnC,uCAAwC;AACxC,qDAA6C;AAE7C,uDAAkD;AAElD,0CAA0C;AAC1C,qBAAqB;AACrB,MAAM,iBAAiB,GAAG,CAAC,CAAS,EAAE,EAAE;IACtC,IAAI;QACF,OAAO,IAAA,2BAAa,EAAC,CAAC,CAAC,CAAA;KACxB;IAAC,MAAM,GAAE;AACZ,CAAC,CAAA;AACD,oBAAoB;AAET,QAAA,OAAO,GAAwB,SAAS,CAAA;AAEnD,uDAAuD;AACvD,oDAAoD;AACpD,qDAAqD;AACrD,MAAM,OAAO,GAAG,IAAA,2BAAU,EAAC,iCAAiC,CAAC,CAAA;AAE7D,4DAA4D;AAC5D,gEAAgE;AAChE,mEAAmE;AACnE,8DAA8D;AAC9D,MAAM,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,6BAA6B,IAAI,EAAE,CAAA;AACvD,MAAM,YAAY,GAAa,KAAK;KACjC,IAAI,EAAE;KACN,KAAK,CAAC,IAAI,CAAC;KACX,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AACnB,MAAM,WAAW,GAAG,CAClB,CAA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6B;YAC7B,gEAAgE;YAChE,kEAAkE;YAClE,MAAM,CAAC,GAAG,iBAAiB,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;YAC5C,IAAI,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,EAAE;gBAClD,OAAO,KAAK,CAAA;aACb;YACD,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;YAC1C,IAAI,OAAO,EAAE;gBACX,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;oBAC3D,WAAW,EAAE,IAAA,gCAAc,EAAC,CAAC,CAAC;oBAC9B,IAAI,EAAE,OAAO;iBACd,CAAC,CAAA;aACH;YACD,OAAO,IAAI,CAAA;QACb,CAAC,CAAC,CAAA;QAEF,IAAA,uBAAa,EAAC,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,CAAA;QAC7D,qBAAqB;IACvB,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AA7DY,QAAA,oBAAoB,wBA6DhC;AACD,oBAAoB","sourcesContent":["// start tracking coverage, unless disabled explicltly\n// export so that we know to collect at the end of the process\nconst p = process\nconst enabled = p.env._TAPJS_PROCESSINFO_COVERAGE_ !== '0'\nimport { mkdirSync, writeFileSync } from 'node:fs'\nimport { Session } from 'node:inspector'\nimport { findSourceMap, SourceMapPayload } from 'node:module'\nimport { resolve } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { getExclude } from './get-exclude.js'\nimport { ProcessInfoNodeData } from './get-process-info.js'\nimport { getLineLengths } from './line-lengths.js'\n\n// this can throw in some cases in node 19\n/* c8 ignore start */\nconst findSourceMapSafe = (s: string) => {\n try {\n return findSourceMap(s)\n } catch {}\n}\n/* c8 ignore stop */\n\nexport let SESSION: Session | undefined = undefined\n\n// NB: coverage exclusion is in addition to processinfo\n// exclusion. Only show coverage for a file we care\n// about at least somewhat, but coverage is a subset.\nconst exclude = getExclude('_TAPJS_PROCESSINFO_COV_EXCLUDE_')\n\n// This is a \\n delimited list of files to show coverage for\n// If not set, or empty, then coverage is included for all files\n// that pass the exclusion RegExp filter. If included in this list,\n// then coverage will be recorded, even if it matches exclude.\nconst cfEnv = p.env._TAPJS_PROCESSINFO_COV_FILES_ || ''\nconst coveredFiles: string[] = cfEnv\n .trim()\n .split('\\n')\n .filter(f => !!f)\nconst fileCovered = (\n f: string,\n s?: SourceMapPayload,\n files: string[] = []\n) => {\n const testFiles = [f]\n if (s) {\n for (const src of s.sources || []) {\n testFiles.push(\n resolve(src.startsWith('file://') ? fileURLToPath(src) : src)\n )\n }\n }\n if (!testFiles.some(f => files.includes(f))) return false\n\n // if at least one of them are explicitly covered, then include it,\n // otherwise omit if we explicitly listed\n if (coveredFiles.length) {\n return testFiles.some(f => coveredFiles.includes(f))\n }\n\n for (const f of testFiles) {\n if (!exclude.test(f)) return true\n }\n return false\n}\n\n// C8 can't see that this function runs, best theory is that it\n// collides with what it's doing with the coverage it's collecting\n// This ignore can possibly be removed once this is being tested\n// with a version of tap that uses this library, but it might just\n// be an unresolveable bootstrap problem.\n// The test does verify that it ran, because otherwise, there would\n// be no coverage, and it verifies that it gets the expected coverage.\n/* c8 ignore start */\nexport const register = () => {\n if (!enabled) return\n p.env._TAPJS_PROCESSINFO_COVERAGE_ = '1'\n\n SESSION = new Session()\n SESSION.connect()\n SESSION.post('Profiler.enable')\n SESSION.post('Runtime.enable')\n SESSION.post('Profiler.startPreciseCoverage', {\n callCount: true,\n detailed: true,\n })\n}\n/* c8 ignore stop */\n\nexport const coverageOnProcessEnd = (\n cwd: string,\n processInfo: ProcessInfoNodeData\n) => {\n // Similar to the coverage tracking bootstrap problem above, c8\n // doesn't see that this function runs, even though it DOES see\n // that the function defined below runs, which is weird.\n /* c8 ignore start */\n if (!SESSION) return\n const session = SESSION\n\n const f = `${cwd}/.tap/coverage/${processInfo.uuid}.json`\n mkdirSync(`${cwd}/.tap/coverage`, { recursive: true })\n\n session.post('Profiler.takePreciseCoverage', (er, cov) => {\n session.post('Profiler.stopPreciseCoverage')\n /* c8 ignore stop */\n\n // something very strange and bad happened\n /* c8 ignore start */\n if (er) {\n throw er\n }\n /* c8 ignore stop */\n\n // Create a source-map-cache that c8 uses in report generation\n const sourceMapCache: {\n [k: string]: {\n lineLengths: number[]\n data: SourceMapPayload\n }\n } = {}\n Object.assign(cov, {\n 'source-map-cache': sourceMapCache,\n })\n\n cov.result = cov.result.filter(obj => {\n if (!/^file:/.test(obj.url)) {\n return false\n }\n const f = fileURLToPath(obj.url)\n // see if it has a source map\n // need to look up via the url, not the file path, because mocks\n // attach a tapmock search param, which is in node's internal key.\n const s = findSourceMapSafe(String(obj.url))\n if (!fileCovered(f, s?.payload, processInfo.files)) {\n return false\n }\n const { payload } = s || { payload: null }\n if (payload) {\n sourceMapCache[obj.url] = Object.assign(Object.create(null), {\n lineLengths: getLineLengths(f),\n data: payload,\n })\n }\n return true\n })\n\n writeFileSync(f, JSON.stringify(cov, null, 2) + '\\n', 'utf8')\n /* c8 ignore start */\n })\n}\n/* c8 ignore stop */\n"]}
1
+ {"version":3,"file":"register-coverage.js","sourceRoot":"","sources":["../../lib/register-coverage.ts"],"names":[],"mappings":";;;AAAA,sDAAsD;AACtD,8DAA8D;AAC9D,MAAM,CAAC,GAAG,OAAO,CAAA;AACjB,MAAM,OAAO,GAAG,CAAC,CAAC,GAAG,CAAC,4BAA4B,KAAK,GAAG,CAAA;AAC1D,qCAAkD;AAClD,mDAAwC;AAExC,yCAAmC;AACnC,uCAAwC;AACxC,uEAA6D;AAC7D,qDAA6C;AAE7C,uDAAkD;AAEvC,QAAA,OAAO,GAAwB,SAAS,CAAA;AAEnD,uDAAuD;AACv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A,oBAAoB,wBA6DhC;AACD,oBAAoB","sourcesContent":["// start tracking coverage, unless disabled explicltly\n// export so that we know to collect at the end of the process\nconst p = process\nconst enabled = p.env._TAPJS_PROCESSINFO_COVERAGE_ !== '0'\nimport { mkdirSync, writeFileSync } from 'node:fs'\nimport { Session } from 'node:inspector'\nimport { SourceMapPayload } from 'node:module'\nimport { resolve } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { findSourceMapSafe } from './find-source-map-safe.js'\nimport { getExclude } from './get-exclude.js'\nimport { ProcessInfoNodeData } from './get-process-info.js'\nimport { getLineLengths } from './line-lengths.js'\n\nexport let SESSION: Session | undefined = undefined\n\n// NB: coverage exclusion is in addition to processinfo\n// exclusion. Only show coverage for a file we care\n// about at least somewhat, but coverage is a subset.\nconst exclude = getExclude('_TAPJS_PROCESSINFO_COV_EXCLUDE_')\n\n// This is a \\n delimited list of files to show coverage for\n// If not set, or empty, then coverage is included for all files\n// that pass the exclusion RegExp filter. If included in this list,\n// then coverage will be recorded, even if it matches exclude.\nconst cfEnv = p.env._TAPJS_PROCESSINFO_COV_FILES_ || ''\nconst coveredFiles: string[] = cfEnv\n .trim()\n .split('\\n')\n .filter(f => !!f)\nconst fileCovered = (\n f: string,\n s?: SourceMapPayload,\n files: string[] = []\n) => {\n const testFiles = [f]\n if (s) {\n for (const src of s.sources || []) {\n testFiles.push(\n resolve(src.startsWith('file://') ? fileURLToPath(src) : src)\n )\n }\n }\n if (!testFiles.some(f => files.includes(f))) return false\n\n // if at least one of them are explicitly covered, then include it,\n // otherwise omit if we explicitly listed\n if (coveredFiles.length) {\n return testFiles.some(f => coveredFiles.includes(f))\n }\n\n for (const f of testFiles) {\n if (!exclude.test(f)) return true\n }\n return false\n}\n\n// C8 can't see that this function runs, best theory is that it\n// collides with what it's doing with the coverage it's collecting\n// This ignore can possibly be removed once this is being tested\n// with a version of tap that uses this library, but it might just\n// be an unresolveable bootstrap problem.\n// The test does verify that it ran, because otherwise, there would\n// be no coverage, and it verifies that it gets the expected coverage.\n/* c8 ignore start */\nexport const register = () => {\n if (!enabled) return\n p.env._TAPJS_PROCESSINFO_COVERAGE_ = '1'\n\n SESSION = new Session()\n SESSION.connect()\n SESSION.post('Profiler.enable')\n SESSION.post('Runtime.enable')\n SESSION.post('Profiler.startPreciseCoverage', {\n callCount: true,\n detailed: true,\n })\n}\n/* c8 ignore stop */\n\nexport const coverageOnProcessEnd = (\n cwd: string,\n processInfo: ProcessInfoNodeData\n) => {\n // Similar to the coverage tracking bootstrap problem above, c8\n // doesn't see that this function runs, even though it DOES see\n // that the function defined below runs, which is weird.\n /* c8 ignore start */\n if (!SESSION) return\n const session = SESSION\n\n const f = `${cwd}/.tap/coverage/${processInfo.uuid}.json`\n mkdirSync(`${cwd}/.tap/coverage`, { recursive: true })\n\n session.post('Profiler.takePreciseCoverage', (er, cov) => {\n session.post('Profiler.stopPreciseCoverage')\n /* c8 ignore stop */\n\n // something very strange and bad happened\n /* c8 ignore start */\n if (er) {\n throw er\n }\n /* c8 ignore stop */\n\n // Create a source-map-cache that c8 uses in report generation\n const sourceMapCache: {\n [k: string]: {\n lineLengths: number[]\n data: SourceMapPayload\n }\n } = {}\n Object.assign(cov, {\n 'source-map-cache': sourceMapCache,\n })\n\n cov.result = cov.result.filter(obj => {\n if (!/^file:/.test(obj.url)) {\n return false\n }\n const f = fileURLToPath(obj.url)\n // see if it has a source map\n // need to look up via the url, not the file path, because mocks\n // attach a tapmock search param, which is in node's internal key.\n const s = findSourceMapSafe(String(obj.url))\n if (!fileCovered(f, s?.payload, processInfo.files)) {\n return false\n }\n const { payload } = s || { payload: null }\n if (payload) {\n sourceMapCache[obj.url] = Object.assign(Object.create(null), {\n lineLengths: getLineLengths(f),\n data: payload,\n })\n }\n return true\n })\n\n writeFileSync(f, JSON.stringify(cov, null, 2) + '\\n', 'utf8')\n /* c8 ignore start */\n })\n}\n/* c8 ignore stop */\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"register-process-end.d.ts","sourceRoot":"","sources":["../../lib/register-process-end.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,QAAQ,YAqCpB,CAAA"}
1
+ {"version":3,"file":"register-process-end.d.ts","sourceRoot":"","sources":["../../lib/register-process-end.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,QAAQ,YAsCpB,CAAA"}
@@ -4,8 +4,8 @@ exports.register = void 0;
4
4
  const signal_exit_1 = require("signal-exit");
5
5
  const get_process_info_js_1 = require("./get-process-info.js");
6
6
  const fs_1 = require("fs");
7
- const module_1 = require("module");
8
7
  const url_1 = require("url");
8
+ const find_source_map_safe_js_1 = require("./find-source-map-safe.js");
9
9
  const register_coverage_js_1 = require("./register-coverage.js");
10
10
  const proc = process;
11
11
  const cwd = proc.env._TAPJS_PROCESSINFO_CWD_ || proc.cwd();
@@ -24,7 +24,7 @@ const register = () => {
24
24
  // This can't be done up front, because the sourcemap isn't
25
25
  // present during the load phase, since it's in the contents.
26
26
  for (const file of processInfo.files) {
27
- const sm = sourceMaps.get(file) || (0, module_1.findSourceMap)(file);
27
+ const sm = sourceMaps.get(file) || (0, find_source_map_safe_js_1.findSourceMapSafe)(file);
28
28
  if (sm && !sourceMaps.has(file))
29
29
  sourceMaps.set(file, sm);
30
30
  const sources = sm?.payload.sources?.map(s =>
@@ -1 +1 @@
1
- {"version":3,"file":"register-process-end.js","sourceRoot":"","sources":["../../lib/register-process-end.ts"],"names":[],"mappings":";;;AAAA,6CAAoC;AACpC,+DAAsD;AAEtD,2BAA6C;AAC7C,mCAAiD;AACjD,6BAAmC;AACnC,iEAA6D;AAE7D,MAAM,IAAI,GAAG,OAAO,CAAA;AAEpB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,uBAAuB,IAAI,IAAI,CAAC,GAAG,EAAE,CAAA;AAC1D,IAAI,CAAC,GAAG,CAAC,uBAAuB,GAAG,GAAG,CAAA;AACtC,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,MA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AO,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,GAAG,CAAA;QACzD,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;QACrE,IAAI,YAAY,CAAC,MAAM,EAAE;YACvB,WAAW,CAAC,YAAY,GAAG,YAAY,CAAA;SACxC;QAED,MAAM,CAAC,GAAG,GAAG,GAAG,qBAAqB,WAAW,CAAC,IAAI,OAAO,CAAA;QAC5D,IAAA,cAAS,EAAC,GAAG,GAAG,mBAAmB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;QACzD,IAAA,kBAAa,EAAC,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,CAAA;QACrE,IAAA,2CAAoB,EAAC,GAAG,EAAE,WAAW,CAAC,CAAA;IACxC,CAAC,EACD,EAAE,UAAU,EAAE,IAAI,EAAE,CACrB,CAAA;AACH,CAAC,CAAA;AArCY,QAAA,QAAQ,YAqCpB","sourcesContent":["import { onExit } from 'signal-exit'\nimport { getProcessInfo } from './get-process-info.js'\n\nimport { mkdirSync, writeFileSync } from 'fs'\nimport { findSourceMap, SourceMap } from 'module'\nimport { fileURLToPath } from 'url'\nimport { coverageOnProcessEnd } from './register-coverage.js'\n\nconst proc = process\n\nconst cwd = proc.env._TAPJS_PROCESSINFO_CWD_ || proc.cwd()\nproc.env._TAPJS_PROCESSINFO_CWD_ = cwd\nconst globals = new Set(Object.keys(global))\n\nconst sourceMaps = new Map<string, SourceMap>()\n\nexport const register = () => {\n onExit(\n (code, signal) => {\n const processInfo = getProcessInfo()\n processInfo.code = code\n processInfo.signal = signal\n const runtime = proc.hrtime(processInfo.hrstart)\n delete processInfo.hrstart\n processInfo.files = [...new Set(processInfo.files)]\n // try to find the actual sources of the files we loaded\n // This can't be done up front, because the sourcemap isn't\n // present during the load phase, since it's in the contents.\n for (const file of processInfo.files) {\n const sm = sourceMaps.get(file) || findSourceMap(file)\n if (sm && !sourceMaps.has(file)) sourceMaps.set(file, sm)\n const sources = sm?.payload.sources?.map(s =>\n // it SHOULD always start with file://, but could in theory\n // be literally any string.\n /* c8 ignore start */\n s.startsWith('file://') ? fileURLToPath(s) : s\n /* c8 ignore stop */\n )\n if (sources) processInfo.sources[file] = sources\n }\n processInfo.runtime = runtime[0] * 1e3 + runtime[1] / 1e6\n const globalsAdded = Object.keys(global).filter(k => !globals.has(k))\n if (globalsAdded.length) {\n processInfo.globalsAdded = globalsAdded\n }\n\n const f = `${cwd}/.tap/processinfo/${processInfo.uuid}.json`\n mkdirSync(`${cwd}/.tap/processinfo`, { recursive: true })\n writeFileSync(f, JSON.stringify(processInfo, null, 2) + '\\n', 'utf8')\n coverageOnProcessEnd(cwd, processInfo)\n },\n { alwaysLast: true }\n )\n}\n"]}
1
+ {"version":3,"file":"register-process-end.js","sourceRoot":"","sources":["../../lib/register-process-end.ts"],"names":[],"mappings":";;;AAAA,6CAAoC;AACpC,+DAAsD;AAEtD,2BAA6C;AAE7C,6BAAmC;AACnC,uEAA6D;AAC7D,iEAA6D;AAE7D,MAAM,IAAI,GAAG,OAAO,CAAA;AAEpB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,uBAAuB,IAAI,IAAI,CAAC,GAAG,EAAE,CAAA;AAC1D,IAAI,CAAC,GAAG,CAAC,uBAAuB,GAAG,GAAG,CAAA;AACtC,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA;AAE5C,MAAM,UAAU,GAAG,IAAI,GAAG,EAAqB,CAAA;AAExC,MAAM,QAAQ,GAAG,GAAG,EAAE;IAC3B,IAAA,oBAAM,EACJ,C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AC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;QACrE,IAAI,YAAY,CAAC,MAAM,EAAE;YACvB,WAAW,CAAC,YAAY,GAAG,YAAY,CAAA;SACxC;QAED,MAAM,CAAC,GAAG,GAAG,GAAG,qBAAqB,WAAW,CAAC,IAAI,OAAO,CAAA;QAC5D,IAAA,cAAS,EAAC,GAAG,GAAG,mBAAmB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;QACzD,IAAA,kBAAa,EAAC,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,CAAA;QACrE,IAAA,2CAAoB,EAAC,GAAG,EAAE,WAAW,CAAC,CAAA;IACxC,CAAC,EACD,EAAE,UAAU,EAAE,IAAI,EAAE,CACrB,CAAA;AACH,CAAC,CAAA;AAtCY,QAAA,QAAQ,YAsCpB","sourcesContent":["import { onExit } from 'signal-exit'\nimport { getProcessInfo } from './get-process-info.js'\n\nimport { mkdirSync, writeFileSync } from 'fs'\nimport { SourceMap } from 'module'\nimport { fileURLToPath } from 'url'\nimport { findSourceMapSafe } from './find-source-map-safe.js'\nimport { coverageOnProcessEnd } from './register-coverage.js'\n\nconst proc = process\n\nconst cwd = proc.env._TAPJS_PROCESSINFO_CWD_ || proc.cwd()\nproc.env._TAPJS_PROCESSINFO_CWD_ = cwd\nconst globals = new Set(Object.keys(global))\n\nconst sourceMaps = new Map<string, SourceMap>()\n\nexport const register = () => {\n onExit(\n (code, signal) => {\n const processInfo = getProcessInfo()\n processInfo.code = code\n processInfo.signal = signal\n const runtime = proc.hrtime(processInfo.hrstart)\n delete processInfo.hrstart\n processInfo.files = [...new Set(processInfo.files)]\n // try to find the actual sources of the files we loaded\n // This can't be done up front, because the sourcemap isn't\n // present during the load phase, since it's in the contents.\n for (const file of processInfo.files) {\n const sm = sourceMaps.get(file) || findSourceMapSafe(file)\n if (sm && !sourceMaps.has(file)) sourceMaps.set(file, sm)\n const sources = sm?.payload.sources?.map(\n s =>\n // it SHOULD always start with file://, but could in theory\n // be literally any string.\n /* c8 ignore start */\n s.startsWith('file://') ? fileURLToPath(s) : s\n /* c8 ignore stop */\n )\n if (sources) processInfo.sources[file] = sources\n }\n processInfo.runtime = runtime[0] * 1e3 + runtime[1] / 1e6\n const globalsAdded = Object.keys(global).filter(k => !globals.has(k))\n if (globalsAdded.length) {\n processInfo.globalsAdded = globalsAdded\n }\n\n const f = `${cwd}/.tap/processinfo/${processInfo.uuid}.json`\n mkdirSync(`${cwd}/.tap/processinfo`, { recursive: true })\n writeFileSync(f, JSON.stringify(processInfo, null, 2) + '\\n', 'utf8')\n coverageOnProcessEnd(cwd, processInfo)\n },\n { alwaysLast: true }\n )\n}\n"]}
package/dist/mjs/esm.mjs CHANGED
@@ -17,7 +17,7 @@ export const globalPreload = (context) => {
17
17
  PORT = port;
18
18
  return `
19
19
  if (typeof port !== 'undefined') {
20
- const { createRequire, findSourceMap } = getBuiltin('module')
20
+ const { createRequire } = getBuiltin('module')
21
21
  const { fileURLToPath } = getBuiltin('url')
22
22
  const require = createRequire(${JSON.stringify(base)})
23
23
  const { getProcessInfo } = require('./get-process-info.js')
@@ -1 +1 @@
1
- {"version":3,"file":"esm.mjs","sourceRoot":"","sources":["../../lib/esm.mts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAA;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAA;AAEnC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;A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AA;QACnC,MAAM,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAA;QAC/B,+DAA+D;QAC/D,gEAAgE;QAChE,kEAAkE;QAClE,2BAA2B;QAC3B,IAAI,CAAC,GAAG,EAAE;YACR,MAAM,CAAC,GAAG,CAAC,CAAA;YACX,OAAO;gBACL,MAAM,EAAE,UAAU;gBAClB,YAAY,EAAE,IAAI;aACnB,CAAA;SACF;KACF;IAED,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;IACxC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAA;IAC/B,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA","sourcesContent":["// usage: node '--loader=@tapjs/processinfo/esm' foo.mjs\nimport { parse } from 'path'\nimport { fileURLToPath } from 'url'\nimport type { Serializable } from 'worker_threads'\nimport { getExclude } from './get-exclude.js'\nimport { getProcessInfo } from './get-process-info.js'\nimport { saveLineLengths } from './line-lengths.js'\nimport { resolve } from './require-resolve.js'\n\n// copy main module so that we can --loader=@tapjs/processinfo and use\n// this as the entry point as well.\nexport * from './index.js'\n\n// on Node v20, loaders are executed in a separate isolated environment\n// As a result, to register coverage and track files, we need to act in\n// the globalPreload function. The load() method posts a message with the\n// filename being loaded, because any registrations that happen in the\n// loader thread will not have any effect.\n// The check for the 'port' being undefined is to allow for support back to\n// 16.12, which had a globalPreload method, but did not have a sendMessage\n// port in that environment.\ntype GPPort = {\n postMessage: (x: Serializable) => any\n}\nlet PORT: undefined | GPPort = undefined\nexport const globalPreload = (context: { port?: GPPort }) => {\n // this will be something like path/to/dist/mjs/lib/esm.mjs\n // but we need path/to/dist/cjs/cjs.js\n const base = resolve('../cjs/cjs.js')\n const { port } = context || {}\n PORT = port\n return `\nif (typeof port !== 'undefined') {\n const { createRequire, findSourceMap } = getBuiltin('module')\n const { fileURLToPath } = getBuiltin('url')\n const require = createRequire(${JSON.stringify(base)})\n const { getProcessInfo } = require('./get-process-info.js')\n const { saveLineLengths } = require('./line-lengths.js')\n // must be called eagerly here.\n // this does all the registration as well.\n const processInfo = getProcessInfo()\n port.onmessage = (e) => {\n const { filename, content } = e.data\n processInfo.files.push(filename)\n saveLineLengths(filename, content)\n }\n port.unref()\n}\n`\n}\n\nconst exclude = getExclude('_TAPJS_PROCESSINFO_EXCLUDE_', false)\nconst record = (url: string, content?: string) => {\n const filename = url.startsWith('file://') ? fileURLToPath(url) : url\n if (exclude.test(filename)) return\n if (PORT) {\n PORT.postMessage({ filename, content })\n } else {\n // call lazily so we don't double-register\n getProcessInfo().files.push(filename)\n if (content) saveLineLengths(filename, content)\n }\n}\n\nexport const load = async (\n url: string,\n context: any,\n nextLoad: Function\n) => {\n if (url.startsWith('file://')) {\n const filename = fileURLToPath(url)\n const { ext } = parse(filename)\n // Package bins will sometimes have an extensionless bin script\n // instead of just naming their extensioned file and letting npm\n // symlink it for them. Don't blow up when this happens, just tell\n // node that it's commonjs.\n if (!ext) {\n record(url)\n return {\n format: 'commonjs',\n shortCircuit: true,\n }\n }\n }\n\n const ret = await nextLoad(url, context)\n record(url, String(ret.source))\n return ret\n}\n"]}
1
+ {"version":3,"file":"esm.mjs","sourceRoot":"","sources":["../../lib/esm.mts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAA;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAA;AAEnC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAE9C,sEAAsE;AACtE,mCAAmC;AACnC,cAAc,YAAY,CAAA;AAa1B,IAAI,IAAI,GAAuB,SAAS,CAAA;AACx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EAAgE;QAChE,kEAAkE;QAClE,2BAA2B;QAC3B,IAAI,CAAC,GAAG,EAAE;YACR,MAAM,CAAC,GAAG,CAAC,CAAA;YACX,OAAO;gBACL,MAAM,EAAE,UAAU;gBAClB,YAAY,EAAE,IAAI;aACnB,CAAA;SACF;KACF;IAED,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;IACxC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAA;IAC/B,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA","sourcesContent":["// usage: node '--loader=@tapjs/processinfo/esm' foo.mjs\nimport { parse } from 'path'\nimport { fileURLToPath } from 'url'\nimport type { Serializable } from 'worker_threads'\nimport { getExclude } from './get-exclude.js'\nimport { getProcessInfo } from './get-process-info.js'\nimport { saveLineLengths } from './line-lengths.js'\nimport { resolve } from './require-resolve.js'\n\n// copy main module so that we can --loader=@tapjs/processinfo and use\n// this as the entry point as well.\nexport * from './index.js'\n\n// on Node v20, loaders are executed in a separate isolated environment\n// As a result, to register coverage and track files, we need to act in\n// the globalPreload function. The load() method posts a message with the\n// filename being loaded, because any registrations that happen in the\n// loader thread will not have any effect.\n// The check for the 'port' being undefined is to allow for support back to\n// 16.12, which had a globalPreload method, but did not have a sendMessage\n// port in that environment.\ntype GPPort = {\n postMessage: (x: Serializable) => any\n}\nlet PORT: undefined | GPPort = undefined\nexport const globalPreload = (context: { port?: GPPort }) => {\n // this will be something like path/to/dist/mjs/lib/esm.mjs\n // but we need path/to/dist/cjs/cjs.js\n const base = resolve('../cjs/cjs.js')\n const { port } = context || {}\n PORT = port\n return `\nif (typeof port !== 'undefined') {\n const { createRequire } = getBuiltin('module')\n const { fileURLToPath } = getBuiltin('url')\n const require = createRequire(${JSON.stringify(base)})\n const { getProcessInfo } = require('./get-process-info.js')\n const { saveLineLengths } = require('./line-lengths.js')\n // must be called eagerly here.\n // this does all the registration as well.\n const processInfo = getProcessInfo()\n port.onmessage = (e) => {\n const { filename, content } = e.data\n processInfo.files.push(filename)\n saveLineLengths(filename, content)\n }\n port.unref()\n}\n`\n}\n\nconst exclude = getExclude('_TAPJS_PROCESSINFO_EXCLUDE_', false)\nconst record = (url: string, content?: string) => {\n const filename = url.startsWith('file://') ? fileURLToPath(url) : url\n if (exclude.test(filename)) return\n if (PORT) {\n PORT.postMessage({ filename, content })\n } else {\n // call lazily so we don't double-register\n getProcessInfo().files.push(filename)\n if (content) saveLineLengths(filename, content)\n }\n}\n\nexport const load = async (\n url: string,\n context: any,\n nextLoad: Function\n) => {\n if (url.startsWith('file://')) {\n const filename = fileURLToPath(url)\n const { ext } = parse(filename)\n // Package bins will sometimes have an extensionless bin script\n // instead of just naming their extensioned file and letting npm\n // symlink it for them. Don't blow up when this happens, just tell\n // node that it's commonjs.\n if (!ext) {\n record(url)\n return {\n format: 'commonjs',\n shortCircuit: true,\n }\n }\n }\n\n const ret = await nextLoad(url, context)\n record(url, String(ret.source))\n return ret\n}\n"]}
@@ -0,0 +1,3 @@
1
+ /// <reference types="node" />
2
+ export declare const findSourceMapSafe: (s: string) => import("module").SourceMap | undefined;
3
+ //# sourceMappingURL=find-source-map-safe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find-source-map-safe.d.ts","sourceRoot":"","sources":["../../lib/find-source-map-safe.ts"],"names":[],"mappings":";AAIA,eAAO,MAAM,iBAAiB,MAAO,MAAM,2CAI1C,CAAA"}
@@ -0,0 +1,11 @@
1
+ import { findSourceMap } from 'module';
2
+ // this can throw in some cases in node 19
3
+ /* c8 ignore start */
4
+ export const findSourceMapSafe = (s) => {
5
+ try {
6
+ return findSourceMap(s);
7
+ }
8
+ catch { }
9
+ };
10
+ /* c8 ignore stop */
11
+ //# sourceMappingURL=find-source-map-safe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find-source-map-safe.js","sourceRoot":"","sources":["../../lib/find-source-map-safe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AAEtC,0CAA0C;AAC1C,qBAAqB;AACrB,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAS,EAAE,EAAE;IAC7C,IAAI;QACF,OAAO,aAAa,CAAC,CAAC,CAAC,CAAA;KACxB;IAAC,MAAM,GAAE;AACZ,CAAC,CAAA;AACD,oBAAoB","sourcesContent":["import { findSourceMap } from 'module'\n\n// this can throw in some cases in node 19\n/* c8 ignore start */\nexport const findSourceMapSafe = (s: string) => {\n try {\n return findSourceMap(s)\n } catch {}\n}\n/* c8 ignore stop */\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"register-coverage.d.ts","sourceRoot":"","sources":["../../lib/register-coverage.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAKxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAY3D,eAAO,IAAI,OAAO,EAAE,OAAO,GAAG,SAAqB,CAAA;AAmDnD,eAAO,MAAM,QAAQ,YAYpB,CAAA;AAGD,eAAO,MAAM,oBAAoB,QAC1B,MAAM,eACE,mBAAmB,SA2DjC,CAAA"}
1
+ {"version":3,"file":"register-coverage.d.ts","sourceRoot":"","sources":["../../lib/register-coverage.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAMxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAG3D,eAAO,IAAI,OAAO,EAAE,OAAO,GAAG,SAAqB,CAAA;AAmDnD,eAAO,MAAM,QAAQ,YAYpB,CAAA;AAGD,eAAO,MAAM,oBAAoB,QAC1B,MAAM,eACE,mBAAmB,SA2DjC,CAAA"}
@@ -4,20 +4,11 @@ const p = process;
4
4
  const enabled = p.env._TAPJS_PROCESSINFO_COVERAGE_ !== '0';
5
5
  import { mkdirSync, writeFileSync } from 'node:fs';
6
6
  import { Session } from 'node:inspector';
7
- import { findSourceMap } from 'node:module';
8
7
  import { resolve } from 'node:path';
9
8
  import { fileURLToPath } from 'node:url';
9
+ import { findSourceMapSafe } from './find-source-map-safe.js';
10
10
  import { getExclude } from './get-exclude.js';
11
11
  import { getLineLengths } from './line-lengths.js';
12
- // this can throw in some cases in node 19
13
- /* c8 ignore start */
14
- const findSourceMapSafe = (s) => {
15
- try {
16
- return findSourceMap(s);
17
- }
18
- catch { }
19
- };
20
- /* c8 ignore stop */
21
12
  export let SESSION = undefined;
22
13
  // NB: coverage exclusion is in addition to processinfo
23
14
  // exclusion. Only show coverage for a file we care
@@ -1 +1 @@
1
- {"version":3,"file":"register-coverage.js","sourceRoot":"","sources":["../../lib/register-coverage.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,8DAA8D;AAC9D,MAAM,CAAC,GAAG,OAAO,CAAA;AACjB,MAAM,OAAO,GAAG,CAAC,CAAC,GAAG,CAAC,4BAA4B,KAAK,GAAG,CAAA;AAC1D,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AACxC,OAAO,EAAE,aAAa,EAAoB,MAAM,aAAa,CAAA;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE7C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAElD,0CAA0C;AAC1C,qBAAqB;AACrB,MAAM,iBAAiB,GAAG,CAAC,CAAS,EAAE,EAAE;IACtC,IAAI;QACF,OAAO,aAAa,CAAC,CAAC,CAAC,CAAA;KACxB;IAAC,MAAM,GAAE;AACZ,CAAC,CAAA;AACD,oBAAoB;AAEpB,MAAM,CAAC,IAAI,OAAO,GAAwB,SAAS,CAAA;AAEnD,uDAAuD;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Ac,GAKhB,EAAE,CAAA;QACN,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE;YACjB,kBAAkB,EAAE,cAAc;SACnC,CAAC,CAAA;QAEF,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;YACnC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;gBAC3B,OAAO,KAAK,CAAA;aACb;YACD,MAAM,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;YAChC,6BAA6B;YAC7B,gEAAgE;YAChE,kEAAkE;YAClE,MAAM,CAAC,GAAG,iBAAiB,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;YAC5C,IAAI,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,EAAE;gBAClD,OAAO,KAAK,CAAA;aACb;YACD,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;YAC1C,IAAI,OAAO,EAAE;gBACX,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;oBAC3D,WAAW,EAAE,cAAc,CAAC,CAAC,CAAC;oBAC9B,IAAI,EAAE,OAAO;iBACd,CAAC,CAAA;aACH;YACD,OAAO,IAAI,CAAA;QACb,CAAC,CAAC,CAAA;QAEF,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,CAAA;QAC7D,qBAAqB;IACvB,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AACD,oBAAoB","sourcesContent":["// start tracking coverage, unless disabled explicltly\n// export so that we know to collect at the end of the process\nconst p = process\nconst enabled = p.env._TAPJS_PROCESSINFO_COVERAGE_ !== '0'\nimport { mkdirSync, writeFileSync } from 'node:fs'\nimport { Session } from 'node:inspector'\nimport { findSourceMap, SourceMapPayload } from 'node:module'\nimport { resolve } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { getExclude } from './get-exclude.js'\nimport { ProcessInfoNodeData } from './get-process-info.js'\nimport { getLineLengths } from './line-lengths.js'\n\n// this can throw in some cases in node 19\n/* c8 ignore start */\nconst findSourceMapSafe = (s: string) => {\n try {\n return findSourceMap(s)\n } catch {}\n}\n/* c8 ignore stop */\n\nexport let SESSION: Session | undefined = undefined\n\n// NB: coverage exclusion is in addition to processinfo\n// exclusion. Only show coverage for a file we care\n// about at least somewhat, but coverage is a subset.\nconst exclude = getExclude('_TAPJS_PROCESSINFO_COV_EXCLUDE_')\n\n// This is a \\n delimited list of files to show coverage for\n// If not set, or empty, then coverage is included for all files\n// that pass the exclusion RegExp filter. If included in this list,\n// then coverage will be recorded, even if it matches exclude.\nconst cfEnv = p.env._TAPJS_PROCESSINFO_COV_FILES_ || ''\nconst coveredFiles: string[] = cfEnv\n .trim()\n .split('\\n')\n .filter(f => !!f)\nconst fileCovered = (\n f: string,\n s?: SourceMapPayload,\n files: string[] = []\n) => {\n const testFiles = [f]\n if (s) {\n for (const src of s.sources || []) {\n testFiles.push(\n resolve(src.startsWith('file://') ? fileURLToPath(src) : src)\n )\n }\n }\n if (!testFiles.some(f => files.includes(f))) return false\n\n // if at least one of them are explicitly covered, then include it,\n // otherwise omit if we explicitly listed\n if (coveredFiles.length) {\n return testFiles.some(f => coveredFiles.includes(f))\n }\n\n for (const f of testFiles) {\n if (!exclude.test(f)) return true\n }\n return false\n}\n\n// C8 can't see that this function runs, best theory is that it\n// collides with what it's doing with the coverage it's collecting\n// This ignore can possibly be removed once this is being tested\n// with a version of tap that uses this library, but it might just\n// be an unresolveable bootstrap problem.\n// The test does verify that it ran, because otherwise, there would\n// be no coverage, and it verifies that it gets the expected coverage.\n/* c8 ignore start */\nexport const register = () => {\n if (!enabled) return\n p.env._TAPJS_PROCESSINFO_COVERAGE_ = '1'\n\n SESSION = new Session()\n SESSION.connect()\n SESSION.post('Profiler.enable')\n SESSION.post('Runtime.enable')\n SESSION.post('Profiler.startPreciseCoverage', {\n callCount: true,\n detailed: true,\n })\n}\n/* c8 ignore stop */\n\nexport const coverageOnProcessEnd = (\n cwd: string,\n processInfo: ProcessInfoNodeData\n) => {\n // Similar to the coverage tracking bootstrap problem above, c8\n // doesn't see that this function runs, even though it DOES see\n // that the function defined below runs, which is weird.\n /* c8 ignore start */\n if (!SESSION) return\n const session = SESSION\n\n const f = `${cwd}/.tap/coverage/${processInfo.uuid}.json`\n mkdirSync(`${cwd}/.tap/coverage`, { recursive: true })\n\n session.post('Profiler.takePreciseCoverage', (er, cov) => {\n session.post('Profiler.stopPreciseCoverage')\n /* c8 ignore stop */\n\n // something very strange and bad happened\n /* c8 ignore start */\n if (er) {\n throw er\n }\n /* c8 ignore stop */\n\n // Create a source-map-cache that c8 uses in report generation\n const sourceMapCache: {\n [k: string]: {\n lineLengths: number[]\n data: SourceMapPayload\n }\n } = {}\n Object.assign(cov, {\n 'source-map-cache': sourceMapCache,\n })\n\n cov.result = cov.result.filter(obj => {\n if (!/^file:/.test(obj.url)) {\n return false\n }\n const f = fileURLToPath(obj.url)\n // see if it has a source map\n // need to look up via the url, not the file path, because mocks\n // attach a tapmock search param, which is in node's internal key.\n const s = findSourceMapSafe(String(obj.url))\n if (!fileCovered(f, s?.payload, processInfo.files)) {\n return false\n }\n const { payload } = s || { payload: null }\n if (payload) {\n sourceMapCache[obj.url] = Object.assign(Object.create(null), {\n lineLengths: getLineLengths(f),\n data: payload,\n })\n }\n return true\n })\n\n writeFileSync(f, JSON.stringify(cov, null, 2) + '\\n', 'utf8')\n /* c8 ignore start */\n })\n}\n/* c8 ignore stop */\n"]}
1
+ {"version":3,"file":"register-coverage.js","sourceRoot":"","sources":["../../lib/register-co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AO,EAAE,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;YAC1C,IAAI,OAAO,EAAE;gBACX,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;oBAC3D,WAAW,EAAE,cAAc,CAAC,CAAC,CAAC;oBAC9B,IAAI,EAAE,OAAO;iBACd,CAAC,CAAA;aACH;YACD,OAAO,IAAI,CAAA;QACb,CAAC,CAAC,CAAA;QAEF,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,CAAA;QAC7D,qBAAqB;IACvB,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AACD,oBAAoB","sourcesContent":["// start tracking coverage, unless disabled explicltly\n// export so that we know to collect at the end of the process\nconst p = process\nconst enabled = p.env._TAPJS_PROCESSINFO_COVERAGE_ !== '0'\nimport { mkdirSync, writeFileSync } from 'node:fs'\nimport { Session } from 'node:inspector'\nimport { SourceMapPayload } from 'node:module'\nimport { resolve } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { findSourceMapSafe } from './find-source-map-safe.js'\nimport { getExclude } from './get-exclude.js'\nimport { ProcessInfoNodeData } from './get-process-info.js'\nimport { getLineLengths } from './line-lengths.js'\n\nexport let SESSION: Session | undefined = undefined\n\n// NB: coverage exclusion is in addition to processinfo\n// exclusion. Only show coverage for a file we care\n// about at least somewhat, but coverage is a subset.\nconst exclude = getExclude('_TAPJS_PROCESSINFO_COV_EXCLUDE_')\n\n// This is a \\n delimited list of files to show coverage for\n// If not set, or empty, then coverage is included for all files\n// that pass the exclusion RegExp filter. If included in this list,\n// then coverage will be recorded, even if it matches exclude.\nconst cfEnv = p.env._TAPJS_PROCESSINFO_COV_FILES_ || ''\nconst coveredFiles: string[] = cfEnv\n .trim()\n .split('\\n')\n .filter(f => !!f)\nconst fileCovered = (\n f: string,\n s?: SourceMapPayload,\n files: string[] = []\n) => {\n const testFiles = [f]\n if (s) {\n for (const src of s.sources || []) {\n testFiles.push(\n resolve(src.startsWith('file://') ? fileURLToPath(src) : src)\n )\n }\n }\n if (!testFiles.some(f => files.includes(f))) return false\n\n // if at least one of them are explicitly covered, then include it,\n // otherwise omit if we explicitly listed\n if (coveredFiles.length) {\n return testFiles.some(f => coveredFiles.includes(f))\n }\n\n for (const f of testFiles) {\n if (!exclude.test(f)) return true\n }\n return false\n}\n\n// C8 can't see that this function runs, best theory is that it\n// collides with what it's doing with the coverage it's collecting\n// This ignore can possibly be removed once this is being tested\n// with a version of tap that uses this library, but it might just\n// be an unresolveable bootstrap problem.\n// The test does verify that it ran, because otherwise, there would\n// be no coverage, and it verifies that it gets the expected coverage.\n/* c8 ignore start */\nexport const register = () => {\n if (!enabled) return\n p.env._TAPJS_PROCESSINFO_COVERAGE_ = '1'\n\n SESSION = new Session()\n SESSION.connect()\n SESSION.post('Profiler.enable')\n SESSION.post('Runtime.enable')\n SESSION.post('Profiler.startPreciseCoverage', {\n callCount: true,\n detailed: true,\n })\n}\n/* c8 ignore stop */\n\nexport const coverageOnProcessEnd = (\n cwd: string,\n processInfo: ProcessInfoNodeData\n) => {\n // Similar to the coverage tracking bootstrap problem above, c8\n // doesn't see that this function runs, even though it DOES see\n // that the function defined below runs, which is weird.\n /* c8 ignore start */\n if (!SESSION) return\n const session = SESSION\n\n const f = `${cwd}/.tap/coverage/${processInfo.uuid}.json`\n mkdirSync(`${cwd}/.tap/coverage`, { recursive: true })\n\n session.post('Profiler.takePreciseCoverage', (er, cov) => {\n session.post('Profiler.stopPreciseCoverage')\n /* c8 ignore stop */\n\n // something very strange and bad happened\n /* c8 ignore start */\n if (er) {\n throw er\n }\n /* c8 ignore stop */\n\n // Create a source-map-cache that c8 uses in report generation\n const sourceMapCache: {\n [k: string]: {\n lineLengths: number[]\n data: SourceMapPayload\n }\n } = {}\n Object.assign(cov, {\n 'source-map-cache': sourceMapCache,\n })\n\n cov.result = cov.result.filter(obj => {\n if (!/^file:/.test(obj.url)) {\n return false\n }\n const f = fileURLToPath(obj.url)\n // see if it has a source map\n // need to look up via the url, not the file path, because mocks\n // attach a tapmock search param, which is in node's internal key.\n const s = findSourceMapSafe(String(obj.url))\n if (!fileCovered(f, s?.payload, processInfo.files)) {\n return false\n }\n const { payload } = s || { payload: null }\n if (payload) {\n sourceMapCache[obj.url] = Object.assign(Object.create(null), {\n lineLengths: getLineLengths(f),\n data: payload,\n })\n }\n return true\n })\n\n writeFileSync(f, JSON.stringify(cov, null, 2) + '\\n', 'utf8')\n /* c8 ignore start */\n })\n}\n/* c8 ignore stop */\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"register-process-end.d.ts","sourceRoot":"","sources":["../../lib/register-process-end.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,QAAQ,YAqCpB,CAAA"}
1
+ {"version":3,"file":"register-process-end.d.ts","sourceRoot":"","sources":["../../lib/register-process-end.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,QAAQ,YAsCpB,CAAA"}
@@ -1,8 +1,8 @@
1
1
  import { onExit } from 'signal-exit';
2
2
  import { getProcessInfo } from './get-process-info.js';
3
3
  import { mkdirSync, writeFileSync } from 'fs';
4
- import { findSourceMap } from 'module';
5
4
  import { fileURLToPath } from 'url';
5
+ import { findSourceMapSafe } from './find-source-map-safe.js';
6
6
  import { coverageOnProcessEnd } from './register-coverage.js';
7
7
  const proc = process;
8
8
  const cwd = proc.env._TAPJS_PROCESSINFO_CWD_ || proc.cwd();
@@ -21,7 +21,7 @@ export const register = () => {
21
21
  // This can't be done up front, because the sourcemap isn't
22
22
  // present during the load phase, since it's in the contents.
23
23
  for (const file of processInfo.files) {
24
- const sm = sourceMaps.get(file) || findSourceMap(file);
24
+ const sm = sourceMaps.get(file) || findSourceMapSafe(file);
25
25
  if (sm && !sourceMaps.has(file))
26
26
  sourceMaps.set(file, sm);
27
27
  const sources = sm?.payload.sources?.map(s =>
@@ -1 +1 @@
1
- {"version":3,"file":"register-process-end.js","sourceRoot":"","sources":["../../lib/register-process-end.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAEtD,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,IAAI,CAAA;AAC7C,OAAO,EAAE,aAAa,EAAa,MAAM,QAAQ,CAAA;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAA;AACnC,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAE7D,MAAM,IAAI,GAAG,OAAO,CAAA;AAEpB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,uBAAuB,IAAI,IAAI,CAAC,GAAG,EAAE,CAAA;AAC1D,IAAI,CAAC,GAAG,CAAC,uBAAuB,GAAG,GAAG,CAAA;AACtC,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA;AAE5C,MAAM,UAAU,GAAG,IAAI,GAAG,EAAqB,CAAA;AAE/C,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,EAAE;IAC3B,MAAM,CACJ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE;QACf,MAAM,WAAW,GAAG,cAAc,EAAE,CAAA;QACpC,WAAW,CAAC,IAAI,GAAG,IAAI,CAAA;QACvB,WAAW,CAAC,MAAM,GAAG,MAAM,CAAA;QAC3B,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;QAChD,OAAO,WAAW,CAAC,OAAO,CAAA;QAC1B,WAAW,CAAC,KAAK,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAA;QACnD,wDAAwD;QACx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WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,CAAA;QACrE,oBAAoB,CAAC,GAAG,EAAE,WAAW,CAAC,CAAA;IACxC,CAAC,EACD,EAAE,UAAU,EAAE,IAAI,EAAE,CACrB,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { onExit } from 'signal-exit'\nimport { getProcessInfo } from './get-process-info.js'\n\nimport { mkdirSync, writeFileSync } from 'fs'\nimport { findSourceMap, SourceMap } from 'module'\nimport { fileURLToPath } from 'url'\nimport { coverageOnProcessEnd } from './register-coverage.js'\n\nconst proc = process\n\nconst cwd = proc.env._TAPJS_PROCESSINFO_CWD_ || proc.cwd()\nproc.env._TAPJS_PROCESSINFO_CWD_ = cwd\nconst globals = new Set(Object.keys(global))\n\nconst sourceMaps = new Map<string, SourceMap>()\n\nexport const register = () => {\n onExit(\n (code, signal) => {\n const processInfo = getProcessInfo()\n processInfo.code = code\n processInfo.signal = signal\n const runtime = proc.hrtime(processInfo.hrstart)\n delete processInfo.hrstart\n processInfo.files = [...new Set(processInfo.files)]\n // try to find the actual sources of the files we loaded\n // This can't be done up front, because the sourcemap isn't\n // present during the load phase, since it's in the contents.\n for (const file of processInfo.files) {\n const sm = sourceMaps.get(file) || findSourceMap(file)\n if (sm && !sourceMaps.has(file)) sourceMaps.set(file, sm)\n const sources = sm?.payload.sources?.map(s =>\n // it SHOULD always start with file://, but could in theory\n // be literally any string.\n /* c8 ignore start */\n s.startsWith('file://') ? fileURLToPath(s) : s\n /* c8 ignore stop */\n )\n if (sources) processInfo.sources[file] = sources\n }\n processInfo.runtime = runtime[0] * 1e3 + runtime[1] / 1e6\n const globalsAdded = Object.keys(global).filter(k => !globals.has(k))\n if (globalsAdded.length) {\n processInfo.globalsAdded = globalsAdded\n }\n\n const f = `${cwd}/.tap/processinfo/${processInfo.uuid}.json`\n mkdirSync(`${cwd}/.tap/processinfo`, { recursive: true })\n writeFileSync(f, JSON.stringify(processInfo, null, 2) + '\\n', 'utf8')\n coverageOnProcessEnd(cwd, processInfo)\n },\n { alwaysLast: true }\n )\n}\n"]}
1
+ {"version":3,"file":"register-process-end.js","sourceRoot":"","sources":["../../lib/register-process-end.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAEtD,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,IAAI,CAAA;AAE7C,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAA;AACnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAE7D,MAAM,IAAI,GAAG,OAAO,CAAA;AAEpB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,uBAAuB,IAAI,IAAI,CAAC,GAAG,EAAE,CAAA;AAC1D,IAAI,CAAC,GAAG,CAAC,uBAAuB,GAAG,GAAG,CAAA;AACtC,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA;AAE5C,MAAM,UAAU,GAAG,IAAI,GAAG,EAAqB,CAAA;AAE/C,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,EAAE;IAC3B,MAAM,CACJ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE;QACf,MAAM,WAAW,GAAG,cAAc,EAAE,CAAA;QACpC,WAAW,CAAC,IAAI,GAAG,IAAI,CAAA;QACvB,WAAW,CAAC,MAAM,GAAG,MAAM,CAAA;QAC3B,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;QAChD,OAAO,WAAW,CAAC,OAAO,CAAA;QAC1B,WAAW,CAAC,KAAK,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,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IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,CAAA;QACrE,oBAAoB,CAAC,GAAG,EAAE,WAAW,CAAC,CAAA;IACxC,CAAC,EACD,EAAE,UAAU,EAAE,IAAI,EAAE,CACrB,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { onExit } from 'signal-exit'\nimport { getProcessInfo } from './get-process-info.js'\n\nimport { mkdirSync, writeFileSync } from 'fs'\nimport { SourceMap } from 'module'\nimport { fileURLToPath } from 'url'\nimport { findSourceMapSafe } from './find-source-map-safe.js'\nimport { coverageOnProcessEnd } from './register-coverage.js'\n\nconst proc = process\n\nconst cwd = proc.env._TAPJS_PROCESSINFO_CWD_ || proc.cwd()\nproc.env._TAPJS_PROCESSINFO_CWD_ = cwd\nconst globals = new Set(Object.keys(global))\n\nconst sourceMaps = new Map<string, SourceMap>()\n\nexport const register = () => {\n onExit(\n (code, signal) => {\n const processInfo = getProcessInfo()\n processInfo.code = code\n processInfo.signal = signal\n const runtime = proc.hrtime(processInfo.hrstart)\n delete processInfo.hrstart\n processInfo.files = [...new Set(processInfo.files)]\n // try to find the actual sources of the files we loaded\n // This can't be done up front, because the sourcemap isn't\n // present during the load phase, since it's in the contents.\n for (const file of processInfo.files) {\n const sm = sourceMaps.get(file) || findSourceMapSafe(file)\n if (sm && !sourceMaps.has(file)) sourceMaps.set(file, sm)\n const sources = sm?.payload.sources?.map(\n s =>\n // it SHOULD always start with file://, but could in theory\n // be literally any string.\n /* c8 ignore start */\n s.startsWith('file://') ? fileURLToPath(s) : s\n /* c8 ignore stop */\n )\n if (sources) processInfo.sources[file] = sources\n }\n processInfo.runtime = runtime[0] * 1e3 + runtime[1] / 1e6\n const globalsAdded = Object.keys(global).filter(k => !globals.has(k))\n if (globalsAdded.length) {\n processInfo.globalsAdded = globalsAdded\n }\n\n const f = `${cwd}/.tap/processinfo/${processInfo.uuid}.json`\n mkdirSync(`${cwd}/.tap/processinfo`, { recursive: true })\n writeFileSync(f, JSON.stringify(processInfo, null, 2) + '\\n', 'utf8')\n coverageOnProcessEnd(cwd, processInfo)\n },\n { alwaysLast: true }\n )\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tapjs/processinfo",
3
- "version": "2.5.5",
3
+ "version": "2.5.6",
4
4
  "main": "./dist/cjs/index.js",
5
5
  "types": "./dist/cjs/index.d.ts",
6
6
  "module": "./dist/mjs/esm.mjs",