@tapjs/processinfo 3.1.0 → 3.1.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.
Files changed (43) hide show
  1. package/dist/cjs/find-source-map-safe.d.ts +2 -1
  2. package/dist/cjs/find-source-map-safe.d.ts.map +1 -1
  3. package/dist/cjs/find-source-map-safe.js +15 -4
  4. package/dist/cjs/find-source-map-safe.js.map +1 -1
  5. package/dist/cjs/path-to-url.d.ts +2 -0
  6. package/dist/cjs/path-to-url.d.ts.map +1 -0
  7. package/dist/cjs/path-to-url.js +11 -0
  8. package/dist/cjs/path-to-url.js.map +1 -0
  9. package/dist/cjs/register-coverage.js +1 -1
  10. package/dist/cjs/register-coverage.js.map +1 -1
  11. package/dist/cjs/register-process-end.d.ts.map +1 -1
  12. package/dist/cjs/register-process-end.js +2 -15
  13. package/dist/cjs/register-process-end.js.map +1 -1
  14. package/dist/cjs/set-sources.d.ts +2 -0
  15. package/dist/cjs/set-sources.d.ts.map +1 -0
  16. package/dist/cjs/set-sources.js +20 -0
  17. package/dist/cjs/set-sources.js.map +1 -0
  18. package/dist/cjs/url-to-path.d.ts +2 -0
  19. package/dist/cjs/url-to-path.d.ts.map +1 -0
  20. package/dist/cjs/url-to-path.js +7 -0
  21. package/dist/cjs/url-to-path.js.map +1 -0
  22. package/dist/mjs/find-source-map-safe.d.ts +2 -1
  23. package/dist/mjs/find-source-map-safe.d.ts.map +1 -1
  24. package/dist/mjs/find-source-map-safe.js +15 -4
  25. package/dist/mjs/find-source-map-safe.js.map +1 -1
  26. package/dist/mjs/path-to-url.d.ts +2 -0
  27. package/dist/mjs/path-to-url.d.ts.map +1 -0
  28. package/dist/mjs/path-to-url.js +7 -0
  29. package/dist/mjs/path-to-url.js.map +1 -0
  30. package/dist/mjs/register-coverage.js +1 -1
  31. package/dist/mjs/register-coverage.js.map +1 -1
  32. package/dist/mjs/register-process-end.d.ts.map +1 -1
  33. package/dist/mjs/register-process-end.js +2 -15
  34. package/dist/mjs/register-process-end.js.map +1 -1
  35. package/dist/mjs/set-sources.d.ts +2 -0
  36. package/dist/mjs/set-sources.d.ts.map +1 -0
  37. package/dist/mjs/set-sources.js +16 -0
  38. package/dist/mjs/set-sources.js.map +1 -0
  39. package/dist/mjs/url-to-path.d.ts +2 -0
  40. package/dist/mjs/url-to-path.d.ts.map +1 -0
  41. package/dist/mjs/url-to-path.js +3 -0
  42. package/dist/mjs/url-to-path.js.map +1 -0
  43. package/package.json +1 -1
@@ -1,3 +1,4 @@
1
1
  /// <reference types="node" />
2
- export declare const findSourceMapSafe: (s: string) => import("module").SourceMap | undefined;
2
+ import { SourceMap } from 'module';
3
+ export declare const findSourceMapSafe: (s: string | URL) => SourceMap | undefined;
3
4
  //# sourceMappingURL=find-source-map-safe.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"find-source-map-safe.d.ts","sourceRoot":"","sources":["../../src/find-source-map-safe.ts"],"names":[],"mappings":";AAIA,eAAO,MAAM,iBAAiB,MAAO,MAAM,2CAI1C,CAAA"}
1
+ {"version":3,"file":"find-source-map-safe.d.ts","sourceRoot":"","sources":["../../src/find-source-map-safe.ts"],"names":[],"mappings":";AAAA,OAAO,EAAiB,SAAS,EAAE,MAAM,QAAQ,CAAA;AAKjD,eAAO,MAAM,iBAAiB,MAAO,MAAM,GAAG,GAAG,0BAehD,CAAA"}
@@ -2,14 +2,25 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.findSourceMapSafe = void 0;
4
4
  const module_1 = require("module");
5
- // this can throw in some cases in node 19
6
- /* c8 ignore start */
5
+ const path_to_url_js_1 = require("./path-to-url.js");
6
+ const sourceMaps = new Map();
7
7
  const findSourceMapSafe = (s) => {
8
+ // Have to look up by URL, because the ?tapmock param will be in
9
+ // the internal key used by node, as those are "different" modules.
10
+ const mod = (0, path_to_url_js_1.pathToURL)(s);
11
+ const c = sourceMaps.get(mod);
12
+ if (c)
13
+ return c;
14
+ // this can throw in some cases in node 19
8
15
  try {
9
- return (0, module_1.findSourceMap)(s);
16
+ const sm = (0, module_1.findSourceMap)(mod);
17
+ if (sm)
18
+ sourceMaps.set(mod, sm);
19
+ return sm;
20
+ /* c8 ignore start */
10
21
  }
11
22
  catch { }
23
+ /* c8 ignore stop */
12
24
  };
13
25
  exports.findSourceMapSafe = findSourceMapSafe;
14
- /* c8 ignore stop */
15
26
  //# sourceMappingURL=find-source-map-safe.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"find-source-map-safe.js","sourceRoot":"","sources":["../../src/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
+ {"version":3,"file":"find-source-map-safe.js","sourceRoot":"","sources":["../../src/find-source-map-safe.ts"],"names":[],"mappings":";;;AAAA,mCAAiD;AACjD,qDAA4C;AAE5C,MAAM,UAAU,GAAG,IAAI,GAAG,EAAqB,CAAA;AAExC,MAAM,iBAAiB,GAAG,CAAC,CAAe,EAAE,EAAE;IACnD,gEAAgE;IAChE,mEAAmE;IACnE,MAAM,GAAG,GAAG,IAAA,0BAAS,EAAC,CAAC,CAAC,CAAA;IACxB,MAAM,CAAC,GAAG,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IAC7B,IAAI,CAAC;QAAE,OAAO,CAAC,CAAA;IAEf,0CAA0C;IAC1C,IAAI;QACF,MAAM,EAAE,GAAG,IAAA,sBAAa,EAAC,GAAG,CAAC,CAAA;QAC7B,IAAI,EAAE;YAAE,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;QAC/B,OAAO,EAAE,CAAA;QACT,qBAAqB;KACtB;IAAC,MAAM,GAAE;IACV,oBAAoB;AACtB,CAAC,CAAA;AAfY,QAAA,iBAAiB,qBAe7B","sourcesContent":["import { findSourceMap, SourceMap } from 'module'\nimport { pathToURL } from './path-to-url.js'\n\nconst sourceMaps = new Map<string, SourceMap>()\n\nexport const findSourceMapSafe = (s: string | URL) => {\n // Have to look up by URL, because the ?tapmock param will be in\n // the internal key used by node, as those are \"different\" modules.\n const mod = pathToURL(s)\n const c = sourceMaps.get(mod)\n if (c) return c\n\n // this can throw in some cases in node 19\n try {\n const sm = findSourceMap(mod)\n if (sm) sourceMaps.set(mod, sm)\n return sm\n /* c8 ignore start */\n } catch {}\n /* c8 ignore stop */\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export declare const pathToURL: (s: string | URL) => string;
2
+ //# sourceMappingURL=path-to-url.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path-to-url.d.ts","sourceRoot":"","sources":["../../src/path-to-url.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,MAAO,MAAM,GAAG,GAAG,KAAG,MAKd,CAAA"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pathToURL = void 0;
4
+ const url_1 = require("url");
5
+ const pathToURL = (s) => typeof s === 'object'
6
+ ? String(s)
7
+ : s.startsWith('file://')
8
+ ? s
9
+ : String((0, url_1.pathToFileURL)(s));
10
+ exports.pathToURL = pathToURL;
11
+ //# sourceMappingURL=path-to-url.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path-to-url.js","sourceRoot":"","sources":["../../src/path-to-url.ts"],"names":[],"mappings":";;;AAAA,6BAAmC;AAE5B,MAAM,SAAS,GAAG,CAAC,CAAe,EAAU,EAAE,CACnD,OAAO,CAAC,KAAK,QAAQ;IACnB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IACX,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC;QACzB,CAAC,CAAC,CAAC;QACH,CAAC,CAAC,MAAM,CAAC,IAAA,mBAAa,EAAC,CAAC,CAAC,CAAC,CAAA;AALjB,QAAA,SAAS,aAKQ","sourcesContent":["import { pathToFileURL } from 'url'\n\nexport const pathToURL = (s: string | URL): string =>\n typeof s === 'object'\n ? String(s)\n : s.startsWith('file://')\n ? s\n : String(pathToFileURL(s))\n"]}
@@ -107,7 +107,7 @@ const coverageOnProcessEnd = (cwd, processInfo) => {
107
107
  // see if it has a source map
108
108
  // need to look up via the url, not the file path, because mocks
109
109
  // attach a tapmock search param, which is in node's internal key.
110
- const s = (0, find_source_map_safe_js_1.findSourceMapSafe)(String(obj.url));
110
+ const s = (0, find_source_map_safe_js_1.findSourceMapSafe)(obj.url);
111
111
  if (!fileCovered(f, s?.payload, processInfo.files)) {
112
112
  return false;
113
113
  }
@@ -1 +1 @@
1
- {"version":3,"file":"register-coverage.js","sourceRoot":"","sources":["../../src/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;AAC7C,uDAAkD;AAGvC,QAAA,OAAO,GAAwB,SAAS,CAAA;AAEnD,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,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,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 { 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 { getLineLengths } from './line-lengths.js'\nimport { ProcessInfoNodeData } from './process-info-node.js'\n\nexport let SESSION: Session | undefined = undefined\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)\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 cxEnv = p.env._TAPJS_PROCESSINFO_COV_EXCLUDE_FILES_ || ''\nconst uncoveredFiles: string[] = cxEnv\n .trim()\n .split('\\n')\n .filter(f => !!f)\n\nconst exclude = p.env._TAPJS_PROCESSINFO_COV_EXCLUDE_\n ? getExclude('_TAPJS_PROCESSINFO_COV_EXCLUDE_', false)\n : undefined\n\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\n // never include coverage if the file is fully ignored.\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 // if any of the filenames are explicitly excluded, no coverage\n // otherwise, it is covered\n return !testFiles.some(\n f => uncoveredFiles.includes(f) || exclude?.test(f)\n )\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":["../../src/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;AAC7C,uDAAkD;AAGvC,QAAA,OAAO,GAAwB,SAAS,CAAA;AAEnD,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;AAEnB,uDAAuD;AACvD,oDAAoD;AACpD,qDAAqD;AACrD,MAAM,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,qCAAqC,IAAI,EAAE,CAAA;AAC/D,MAAM,cAAc,GAAa,KAAK;KACnC,IAAI,EAAE;KACN,KAAK,CAAC,IAAI,CAAC;KACX,MAAM,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AE,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,IAAA,wBAAa,EAAC,GAAG,CAAC,GAAG,CAAC,CAAA;YAChC,6BAA6B;YAC7B,gEAAgE;YAChE,kEAAkE;YAClE,MAAM,CAAC,GAAG,IAAA,2CAAiB,EAAC,GAAG,CAAC,GAAG,CAAC,CAAA;YACpC,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 { 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 { getLineLengths } from './line-lengths.js'\nimport { ProcessInfoNodeData } from './process-info-node.js'\n\nexport let SESSION: Session | undefined = undefined\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)\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 cxEnv = p.env._TAPJS_PROCESSINFO_COV_EXCLUDE_FILES_ || ''\nconst uncoveredFiles: string[] = cxEnv\n .trim()\n .split('\\n')\n .filter(f => !!f)\n\nconst exclude = p.env._TAPJS_PROCESSINFO_COV_EXCLUDE_\n ? getExclude('_TAPJS_PROCESSINFO_COV_EXCLUDE_', false)\n : undefined\n\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\n // never include coverage if the file is fully ignored.\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 // if any of the filenames are explicitly excluded, no coverage\n // otherwise, it is covered\n return !testFiles.some(\n f => uncoveredFiles.includes(f) || exclude?.test(f)\n )\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(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":["../../src/register-process-end.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,QAAQ,YAsCpB,CAAA"}
1
+ {"version":3,"file":"register-process-end.d.ts","sourceRoot":"","sources":["../../src/register-process-end.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,QAAQ,YA4BpB,CAAA"}
@@ -4,14 +4,12 @@ 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 url_1 = require("url");
8
- const find_source_map_safe_js_1 = require("./find-source-map-safe.js");
9
7
  const register_coverage_js_1 = require("./register-coverage.js");
8
+ const set_sources_js_1 = require("./set-sources.js");
10
9
  const proc = process;
11
10
  const cwd = proc.env._TAPJS_PROCESSINFO_CWD_ || proc.cwd();
12
11
  proc.env._TAPJS_PROCESSINFO_CWD_ = cwd;
13
12
  const globals = new Set(Object.keys(global));
14
- const sourceMaps = new Map();
15
13
  const register = () => {
16
14
  (0, signal_exit_1.onExit)((code, signal) => {
17
15
  const processInfo = (0, get_process_info_js_1.getProcessInfo)();
@@ -24,18 +22,7 @@ const register = () => {
24
22
  // This can't be done up front, because the sourcemap isn't
25
23
  // present during the load phase, since it's in the contents.
26
24
  for (const file of processInfo.files) {
27
- const sm = sourceMaps.get(file) || (0, find_source_map_safe_js_1.findSourceMapSafe)(file);
28
- if (sm && !sourceMaps.has(file))
29
- sourceMaps.set(file, sm);
30
- const sources = sm?.payload.sources?.map(s =>
31
- // it SHOULD always start with file://, but could in theory
32
- // be literally any string.
33
- /* c8 ignore start */
34
- s.startsWith('file://') ? (0, url_1.fileURLToPath)(s) : s
35
- /* c8 ignore stop */
36
- );
37
- if (sources)
38
- processInfo.sources[file] = sources;
25
+ (0, set_sources_js_1.setSources)(file);
39
26
  }
40
27
  processInfo.runtime = runtime[0] * 1e3 + runtime[1] / 1e6;
41
28
  const globalsAdded = Object.keys(global).filter(k => !globals.has(k));
@@ -1 +1 @@
1
- {"version":3,"file":"register-process-end.js","sourceRoot":"","sources":["../../src/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,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE;QACf,MAAM,WAAW,GAAG,IAAA,oCAAc,GAAE,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;QACxD,2DAA2D;QAC3D,6DAA6D;QAC7D,KAAK,MAAM,IAAI,IAAI,WAAW,CAAC,KAAK,EAAE;YACpC,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAA,2CAAiB,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AAC,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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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;AA5BY,QAAA,QAAQ,YA4BpB","sourcesContent":["import { onExit } from 'signal-exit'\nimport { getProcessInfo } from './get-process-info.js'\n\nimport { mkdirSync, writeFileSync } from 'fs'\nimport { coverageOnProcessEnd } from './register-coverage.js'\nimport { setSources } from './set-sources.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\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 setSources(file)\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"]}
@@ -0,0 +1,2 @@
1
+ export declare const setSources: (file: string) => void;
2
+ //# sourceMappingURL=set-sources.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set-sources.d.ts","sourceRoot":"","sources":["../../src/set-sources.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,UAAU,SAAU,MAAM,SAOtC,CAAA"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setSources = void 0;
4
+ const find_source_map_safe_js_1 = require("./find-source-map-safe.js");
5
+ const get_process_info_js_1 = require("./get-process-info.js");
6
+ const url_to_path_js_1 = require("./url-to-path.js");
7
+ // set the processInfo.sources for a given file, but don't clobber
8
+ // if called multiple times, or create duplicate entries.
9
+ // Should only be called *after* the file in question has been loaded.
10
+ const setSources = (file) => {
11
+ const sm = (0, find_source_map_safe_js_1.findSourceMapSafe)(file);
12
+ if (!sm)
13
+ return;
14
+ const pi = (0, get_process_info_js_1.getProcessInfo)();
15
+ const s = pi.sources[file] || [];
16
+ s.push(...sm.payload.sources.map(s => (0, url_to_path_js_1.urlToPath)(s)));
17
+ pi.sources[file] = [...new Set(s)];
18
+ };
19
+ exports.setSources = setSources;
20
+ //# sourceMappingURL=set-sources.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set-sources.js","sourceRoot":"","sources":["../../src/set-sources.ts"],"names":[],"mappings":";;;AAAA,uEAA6D;AAC7D,+DAAsD;AACtD,qDAA0C;AAE1C,kEAAkE;AAClE,yDAAyD;AACzD,sEAAsE;AAC/D,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,EAAE;IACzC,MAAM,EAAE,GAAG,IAAA,2CAAiB,EAAC,IAAI,CAAC,CAAA;IAClC,IAAI,CAAC,EAAE;QAAE,OAAM;IACf,MAAM,EAAE,GAAG,IAAA,oCAAc,GAAE,CAAA;IAC3B,MAAM,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,CAAA;IAChC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAA,0BAAS,EAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IACpD,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;AACpC,CAAC,CAAA;AAPY,QAAA,UAAU,cAOtB","sourcesContent":["import { findSourceMapSafe } from './find-source-map-safe.js'\nimport { getProcessInfo } from './get-process-info.js'\nimport {urlToPath} from './url-to-path.js'\n\n// set the processInfo.sources for a given file, but don't clobber\n// if called multiple times, or create duplicate entries.\n// Should only be called *after* the file in question has been loaded.\nexport const setSources = (file: string) => {\n const sm = findSourceMapSafe(file)\n if (!sm) return\n const pi = getProcessInfo()\n const s = pi.sources[file] || []\n s.push(...sm.payload.sources.map(s => urlToPath(s)))\n pi.sources[file] = [...new Set(s)]\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export declare const urlToPath: (s: string | URL) => string;
2
+ //# sourceMappingURL=url-to-path.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url-to-path.d.ts","sourceRoot":"","sources":["../../src/url-to-path.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,MAAO,MAAM,GAAG,GAAG,WACgC,CAAA"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.urlToPath = void 0;
4
+ const url_1 = require("url");
5
+ const urlToPath = (s) => typeof s === 'object' || s.startsWith('file://') ? (0, url_1.fileURLToPath)(s) : s;
6
+ exports.urlToPath = urlToPath;
7
+ //# sourceMappingURL=url-to-path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url-to-path.js","sourceRoot":"","sources":["../../src/url-to-path.ts"],"names":[],"mappings":";;;AAAA,6BAAmC;AAE5B,MAAM,SAAS,GAAG,CAAC,CAAe,EAAE,EAAE,CAC3C,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAA,mBAAa,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAD5D,QAAA,SAAS,aACmD","sourcesContent":["import { fileURLToPath } from 'url'\n\nexport const urlToPath = (s: string | URL) =>\n typeof s === 'object' || s.startsWith('file://') ? fileURLToPath(s) : s\n"]}
@@ -1,3 +1,4 @@
1
1
  /// <reference types="node" />
2
- export declare const findSourceMapSafe: (s: string) => import("module").SourceMap | undefined;
2
+ import { SourceMap } from 'module';
3
+ export declare const findSourceMapSafe: (s: string | URL) => SourceMap | undefined;
3
4
  //# sourceMappingURL=find-source-map-safe.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"find-source-map-safe.d.ts","sourceRoot":"","sources":["../../src/find-source-map-safe.ts"],"names":[],"mappings":";AAIA,eAAO,MAAM,iBAAiB,MAAO,MAAM,2CAI1C,CAAA"}
1
+ {"version":3,"file":"find-source-map-safe.d.ts","sourceRoot":"","sources":["../../src/find-source-map-safe.ts"],"names":[],"mappings":";AAAA,OAAO,EAAiB,SAAS,EAAE,MAAM,QAAQ,CAAA;AAKjD,eAAO,MAAM,iBAAiB,MAAO,MAAM,GAAG,GAAG,0BAehD,CAAA"}
@@ -1,11 +1,22 @@
1
1
  import { findSourceMap } from 'module';
2
- // this can throw in some cases in node 19
3
- /* c8 ignore start */
2
+ import { pathToURL } from './path-to-url.js';
3
+ const sourceMaps = new Map();
4
4
  export const findSourceMapSafe = (s) => {
5
+ // Have to look up by URL, because the ?tapmock param will be in
6
+ // the internal key used by node, as those are "different" modules.
7
+ const mod = pathToURL(s);
8
+ const c = sourceMaps.get(mod);
9
+ if (c)
10
+ return c;
11
+ // this can throw in some cases in node 19
5
12
  try {
6
- return findSourceMap(s);
13
+ const sm = findSourceMap(mod);
14
+ if (sm)
15
+ sourceMaps.set(mod, sm);
16
+ return sm;
17
+ /* c8 ignore start */
7
18
  }
8
19
  catch { }
20
+ /* c8 ignore stop */
9
21
  };
10
- /* c8 ignore stop */
11
22
  //# sourceMappingURL=find-source-map-safe.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"find-source-map-safe.js","sourceRoot":"","sources":["../../src/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
+ {"version":3,"file":"find-source-map-safe.js","sourceRoot":"","sources":["../../src/find-source-map-safe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAa,MAAM,QAAQ,CAAA;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAE5C,MAAM,UAAU,GAAG,IAAI,GAAG,EAAqB,CAAA;AAE/C,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAe,EAAE,EAAE;IACnD,gEAAgE;IAChE,mEAAmE;IACnE,MAAM,GAAG,GAAG,SAAS,CAAC,CAAC,CAAC,CAAA;IACxB,MAAM,CAAC,GAAG,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IAC7B,IAAI,CAAC;QAAE,OAAO,CAAC,CAAA;IAEf,0CAA0C;IAC1C,IAAI;QACF,MAAM,EAAE,GAAG,aAAa,CAAC,GAAG,CAAC,CAAA;QAC7B,IAAI,EAAE;YAAE,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;QAC/B,OAAO,EAAE,CAAA;QACT,qBAAqB;KACtB;IAAC,MAAM,GAAE;IACV,oBAAoB;AACtB,CAAC,CAAA","sourcesContent":["import { findSourceMap, SourceMap } from 'module'\nimport { pathToURL } from './path-to-url.js'\n\nconst sourceMaps = new Map<string, SourceMap>()\n\nexport const findSourceMapSafe = (s: string | URL) => {\n // Have to look up by URL, because the ?tapmock param will be in\n // the internal key used by node, as those are \"different\" modules.\n const mod = pathToURL(s)\n const c = sourceMaps.get(mod)\n if (c) return c\n\n // this can throw in some cases in node 19\n try {\n const sm = findSourceMap(mod)\n if (sm) sourceMaps.set(mod, sm)\n return sm\n /* c8 ignore start */\n } catch {}\n /* c8 ignore stop */\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export declare const pathToURL: (s: string | URL) => string;
2
+ //# sourceMappingURL=path-to-url.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path-to-url.d.ts","sourceRoot":"","sources":["../../src/path-to-url.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,MAAO,MAAM,GAAG,GAAG,KAAG,MAKd,CAAA"}
@@ -0,0 +1,7 @@
1
+ import { pathToFileURL } from 'url';
2
+ export const pathToURL = (s) => typeof s === 'object'
3
+ ? String(s)
4
+ : s.startsWith('file://')
5
+ ? s
6
+ : String(pathToFileURL(s));
7
+ //# sourceMappingURL=path-to-url.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path-to-url.js","sourceRoot":"","sources":["../../src/path-to-url.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAA;AAEnC,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAe,EAAU,EAAE,CACnD,OAAO,CAAC,KAAK,QAAQ;IACnB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IACX,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC;QACzB,CAAC,CAAC,CAAC;QACH,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAA","sourcesContent":["import { pathToFileURL } from 'url'\n\nexport const pathToURL = (s: string | URL): string =>\n typeof s === 'object'\n ? String(s)\n : s.startsWith('file://')\n ? s\n : String(pathToFileURL(s))\n"]}
@@ -103,7 +103,7 @@ export const coverageOnProcessEnd = (cwd, processInfo) => {
103
103
  // see if it has a source map
104
104
  // need to look up via the url, not the file path, because mocks
105
105
  // attach a tapmock search param, which is in node's internal key.
106
- const s = findSourceMapSafe(String(obj.url));
106
+ const s = findSourceMapSafe(obj.url);
107
107
  if (!fileCovered(f, s?.payload, processInfo.files)) {
108
108
  return false;
109
109
  }
@@ -1 +1 @@
1
- {"version":3,"file":"register-coverage.js","sourceRoot":"","sources":["../../src/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;AAExC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,cAAc,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AG,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 { getLineLengths } from './line-lengths.js'\nimport { ProcessInfoNodeData } from './process-info-node.js'\n\nexport let SESSION: Session | undefined = undefined\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)\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 cxEnv = p.env._TAPJS_PROCESSINFO_COV_EXCLUDE_FILES_ || ''\nconst uncoveredFiles: string[] = cxEnv\n .trim()\n .split('\\n')\n .filter(f => !!f)\n\nconst exclude = p.env._TAPJS_PROCESSINFO_COV_EXCLUDE_\n ? getExclude('_TAPJS_PROCESSINFO_COV_EXCLUDE_', false)\n : undefined\n\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\n // never include coverage if the file is fully ignored.\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 // if any of the filenames are explicitly excluded, no coverage\n // otherwise, it is covered\n return !testFiles.some(\n f => uncoveredFiles.includes(f) || exclude?.test(f)\n )\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":["../../src/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;AAExC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAGlD,MAAM,CAAC,IAAI,OAAO,GAAwB,SAAS,CAAA;AAEnD,4DAA4D;AAC5D,gEAAgE;AA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AAE,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 { getLineLengths } from './line-lengths.js'\nimport { ProcessInfoNodeData } from './process-info-node.js'\n\nexport let SESSION: Session | undefined = undefined\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)\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 cxEnv = p.env._TAPJS_PROCESSINFO_COV_EXCLUDE_FILES_ || ''\nconst uncoveredFiles: string[] = cxEnv\n .trim()\n .split('\\n')\n .filter(f => !!f)\n\nconst exclude = p.env._TAPJS_PROCESSINFO_COV_EXCLUDE_\n ? getExclude('_TAPJS_PROCESSINFO_COV_EXCLUDE_', false)\n : undefined\n\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\n // never include coverage if the file is fully ignored.\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 // if any of the filenames are explicitly excluded, no coverage\n // otherwise, it is covered\n return !testFiles.some(\n f => uncoveredFiles.includes(f) || exclude?.test(f)\n )\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(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":["../../src/register-process-end.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,QAAQ,YAsCpB,CAAA"}
1
+ {"version":3,"file":"register-process-end.d.ts","sourceRoot":"","sources":["../../src/register-process-end.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,QAAQ,YA4BpB,CAAA"}
@@ -1,14 +1,12 @@
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 { fileURLToPath } from 'url';
5
- import { findSourceMapSafe } from './find-source-map-safe.js';
6
4
  import { coverageOnProcessEnd } from './register-coverage.js';
5
+ import { setSources } from './set-sources.js';
7
6
  const proc = process;
8
7
  const cwd = proc.env._TAPJS_PROCESSINFO_CWD_ || proc.cwd();
9
8
  proc.env._TAPJS_PROCESSINFO_CWD_ = cwd;
10
9
  const globals = new Set(Object.keys(global));
11
- const sourceMaps = new Map();
12
10
  export const register = () => {
13
11
  onExit((code, signal) => {
14
12
  const processInfo = getProcessInfo();
@@ -21,18 +19,7 @@ export const register = () => {
21
19
  // This can't be done up front, because the sourcemap isn't
22
20
  // present during the load phase, since it's in the contents.
23
21
  for (const file of processInfo.files) {
24
- const sm = sourceMaps.get(file) || findSourceMapSafe(file);
25
- if (sm && !sourceMaps.has(file))
26
- sourceMaps.set(file, sm);
27
- const sources = sm?.payload.sources?.map(s =>
28
- // it SHOULD always start with file://, but could in theory
29
- // be literally any string.
30
- /* c8 ignore start */
31
- s.startsWith('file://') ? fileURLToPath(s) : s
32
- /* c8 ignore stop */
33
- );
34
- if (sources)
35
- processInfo.sources[file] = sources;
22
+ setSources(file);
36
23
  }
37
24
  processInfo.runtime = runtime[0] * 1e3 + runtime[1] / 1e6;
38
25
  const globalsAdded = Object.keys(global).filter(k => !globals.has(k));
@@ -1 +1 @@
1
- {"version":3,"file":"register-process-end.js","sourceRoot":"","sources":["../../src/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,WA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,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,SAAS,CAAC,GAAG,GAAG,mBAAmB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;QACzD,aAAa,CAAC,CAAC,EAAE,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"]}
1
+ {"version":3,"file":"register-process-end.js","sourceRoot":"","sources":["../../src/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,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE7C,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,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,I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'./get-process-info.js'\n\nimport { mkdirSync, writeFileSync } from 'fs'\nimport { coverageOnProcessEnd } from './register-coverage.js'\nimport { setSources } from './set-sources.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\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 setSources(file)\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"]}
@@ -0,0 +1,2 @@
1
+ export declare const setSources: (file: string) => void;
2
+ //# sourceMappingURL=set-sources.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set-sources.d.ts","sourceRoot":"","sources":["../../src/set-sources.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,UAAU,SAAU,MAAM,SAOtC,CAAA"}
@@ -0,0 +1,16 @@
1
+ import { findSourceMapSafe } from './find-source-map-safe.js';
2
+ import { getProcessInfo } from './get-process-info.js';
3
+ import { urlToPath } from './url-to-path.js';
4
+ // set the processInfo.sources for a given file, but don't clobber
5
+ // if called multiple times, or create duplicate entries.
6
+ // Should only be called *after* the file in question has been loaded.
7
+ export const setSources = (file) => {
8
+ const sm = findSourceMapSafe(file);
9
+ if (!sm)
10
+ return;
11
+ const pi = getProcessInfo();
12
+ const s = pi.sources[file] || [];
13
+ s.push(...sm.payload.sources.map(s => urlToPath(s)));
14
+ pi.sources[file] = [...new Set(s)];
15
+ };
16
+ //# sourceMappingURL=set-sources.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set-sources.js","sourceRoot":"","sources":["../../src/set-sources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAC,SAAS,EAAC,MAAM,kBAAkB,CAAA;AAE1C,kEAAkE;AAClE,yDAAyD;AACzD,sEAAsE;AACtE,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,EAAE;IACzC,MAAM,EAAE,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAA;IAClC,IAAI,CAAC,EAAE;QAAE,OAAM;IACf,MAAM,EAAE,GAAG,cAAc,EAAE,CAAA;IAC3B,MAAM,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,CAAA;IAChC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IACpD,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;AACpC,CAAC,CAAA","sourcesContent":["import { findSourceMapSafe } from './find-source-map-safe.js'\nimport { getProcessInfo } from './get-process-info.js'\nimport {urlToPath} from './url-to-path.js'\n\n// set the processInfo.sources for a given file, but don't clobber\n// if called multiple times, or create duplicate entries.\n// Should only be called *after* the file in question has been loaded.\nexport const setSources = (file: string) => {\n const sm = findSourceMapSafe(file)\n if (!sm) return\n const pi = getProcessInfo()\n const s = pi.sources[file] || []\n s.push(...sm.payload.sources.map(s => urlToPath(s)))\n pi.sources[file] = [...new Set(s)]\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export declare const urlToPath: (s: string | URL) => string;
2
+ //# sourceMappingURL=url-to-path.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url-to-path.d.ts","sourceRoot":"","sources":["../../src/url-to-path.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,MAAO,MAAM,GAAG,GAAG,WACgC,CAAA"}
@@ -0,0 +1,3 @@
1
+ import { fileURLToPath } from 'url';
2
+ export const urlToPath = (s) => typeof s === 'object' || s.startsWith('file://') ? fileURLToPath(s) : s;
3
+ //# sourceMappingURL=url-to-path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url-to-path.js","sourceRoot":"","sources":["../../src/url-to-path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAA;AAEnC,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAe,EAAE,EAAE,CAC3C,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA","sourcesContent":["import { fileURLToPath } from 'url'\n\nexport const urlToPath = (s: string | URL) =>\n typeof s === 'object' || s.startsWith('file://') ? fileURLToPath(s) : s\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tapjs/processinfo",
3
- "version": "3.1.0",
3
+ "version": "3.1.1",
4
4
  "files": [
5
5
  "dist"
6
6
  ],