@tapjs/processinfo 2.1.4 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,6 +11,7 @@ export interface ProcessInfoNodeData {
11
11
  parent: string | null;
12
12
  uuid: string;
13
13
  files: string[];
14
+ sources: Record<string, string[]>;
14
15
  root?: string | null;
15
16
  externalID?: string | null;
16
17
  code?: number | null;
@@ -1 +1 @@
1
- {"version":3,"file":"get-process-info.d.ts","sourceRoot":"","sources":["../../lib/get-process-info.ts"],"names":[],"mappings":";AAOA,MAAM,WAAW,mBAAmB;IAElC,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAG1B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,EAAE,CAAA;IAGf,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,CAAA;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;CACxB;AA2BD,eAAO,MAAM,KAAK;0BAKgB,mBAAmB;CAFpD,CAAA;AAED,eAAO,MAAM,cAAc,QAAO,mBAsCjC,CAAA"}
1
+ {"version":3,"file":"get-process-info.d.ts","sourceRoot":"","sources":["../../lib/get-process-info.ts"],"names":[],"mappings":";AAOA,MAAM,WAAW,mBAAmB;IAElC,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAG1B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;IAGjC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,CAAA;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;CACxB;AA2BD,eAAO,MAAM,KAAK;0BAKgB,mBAAmB;CAFpD,CAAA;AAED,eAAO,MAAM,cAAc,QAAO,mBAuCjC,CAAA"}
@@ -43,6 +43,7 @@ const getProcessInfo = () => {
43
43
  parent: getEnv('parent') || null,
44
44
  uuid: (0, uuid_1.v4)(),
45
45
  files: [],
46
+ sources: Object.create(null),
46
47
  };
47
48
  if (!g[kProcessInfo].parent) {
48
49
  g[kProcessInfo].root = g[kProcessInfo].uuid;
@@ -1 +1 @@
1
- {"version":3,"file":"get-process-info.js","sourceRoot":"","sources":["../../lib/get-process-info.ts"],"names":[],"mappings":";;;AAAA,sBAAsB;AACtB,MAAM,CAAC,GAAG,OAET,CAAA;AAC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\nconst p = process as NodeJS.Process & {\n setSourceMapsEnabled(v: boolean): void\n}\np.setSourceMapsEnabled(true)\n\nimport { v4 as uuid } from 'uuid'\nexport interface ProcessInfoNodeData {\n // set initially, but deleted before it is written\n hrstart?: [number, number]\n\n // always set\n date: string\n argv: string[]\n execArgv: string[]\n NODE_OPTIONS?: string\n cwd: string\n pid: number\n ppid: number\n parent: string | null\n uuid: string\n files: string[]\n\n // fields that are only set when the process completes\n root?: string | null\n externalID?: string | null\n code?: number | null\n signal?: NodeJS.Signals | null\n runtime?: number\n globalsAdded?: string[]\n}\n\n\nconst envKey = (k: string) => `_TAPJS_PROCESSINFO_${k.toUpperCase()}_`\nconst getEnv = (k: string) => process.env[envKey(k)]\nconst setEnv = (k: string, v: string) => (process.env[envKey(k)] = v)\nconst delEnv = (k: string) => delete process.env[envKey(k)]\n\nimport { register as registerCoverage } from './register-coverage.js'\nimport { register as registerEnv } from './register-env.js'\nimport { register as registerProcessEnd } from './register-process-end.js'\nimport { register as registerCJS } from './register-cjs.js'\n\n// this module is hybridized. In node v20, it's the *commonjs* one that\n// gets loaded, because the esm loader context can't modify the main thread\n// except via communication over the port to the globalPreload env.\n// So, we have to store our singleton on the global.\n//\n// If it later loads the esm form of this module, that's fine, because it'll\n// see the global processInfo object, and not re-register anything.\n\nconst kProcessInfo = Symbol.for('@tapjs/processinfo.ProcessInfoNodeData')\nconst g = global as typeof globalThis & {\n [kProcessInfo]?: ProcessInfoNodeData\n}\n\n// only used for tests so we can simulate multiple processes\nexport const reset = () => {\n g[kProcessInfo] = undefined\n return { getProcessInfo }\n}\n\nexport const getProcessInfo = (): ProcessInfoNodeData => {\n if (g[kProcessInfo]) return g[kProcessInfo]\n\n g[kProcessInfo] = {\n hrstart: process.hrtime(),\n date: new Date().toISOString(),\n argv: process.argv,\n execArgv: process.execArgv,\n NODE_OPTIONS: process.env.NODE_OPTIONS,\n cwd: process.cwd(),\n pid: process.pid,\n ppid: process.ppid,\n parent: getEnv('parent') || null,\n uuid: uuid(),\n files: [],\n }\n\n if (!g[kProcessInfo].parent) {\n g[kProcessInfo].root = g[kProcessInfo].uuid\n setEnv('root', g[kProcessInfo].uuid)\n } else {\n g[kProcessInfo].root = getEnv('root')\n }\n // this is the parent of any further child processes\n setEnv('parent', g[kProcessInfo].uuid)\n const externalID = getEnv('external_id')\n if (externalID) {\n g[kProcessInfo].externalID = externalID\n // externalID only applies to ONE process, not all its children.\n delEnv('external_id')\n }\n\n registerCJS()\n registerEnv()\n registerCoverage()\n registerProcessEnd()\n\n return g[kProcessInfo]\n}\n"]}
1
+ {"version":3,"file":"get-process-info.js","sourceRoot":"","sources":["../../lib/get-process-info.ts"],"names":[],"mappings":";;;AAAA,sBAAsB;AACtB,MAAM,CAAC,GAAG,OAET,CAAA;AACD,CAAC,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAA;AAE5B,+BAAiC;AA4BjC,MAAM,MAAM,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,sBAAsB,CAAC,CAAC,WAAW,EAAE,GAAG,CAAA;AACtE,MAAM,MAAM,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;AACpD,MAAM,MAAM,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;AACrE,MAAM,MAAM,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;AAE3D,iEAAqE;AACrE,uDAA2D;AAC3D,uEAA0E;AAC1E,uDAA2D;AAE3D,wEAAwE;AACxE,2EAA2E;AAC3E,mEAAmE;AACnE,oDAAoD;AACpD,EAAE;AACF,4EAA4E;AAC5E,mEAAmE;AAEnE,MAAM,YAAY,GAAG,MAAM,CAAC,G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AM,CAAC,CAAA;KACtC;IACD,oDAAoD;IACpD,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,CAAA;IACtC,MAAM,UAAU,GAAG,MAAM,CAAC,aAAa,CAAC,CAAA;IACxC,IAAI,UAAU,EAAE;QACd,CAAC,CAAC,YAAY,CAAC,CAAC,UAAU,GAAG,UAAU,CAAA;QACvC,gEAAgE;QAChE,MAAM,CAAC,aAAa,CAAC,CAAA;KACtB;IAED,IAAA,0BAAW,GAAE,CAAA;IACb,IAAA,0BAAW,GAAE,CAAA;IACb,IAAA,+BAAgB,GAAE,CAAA;IAClB,IAAA,kCAAkB,GAAE,CAAA;IAEpB,OAAO,CAAC,CAAC,YAAY,CAAC,CAAA;AACxB,CAAC,CAAA;AAvCY,QAAA,cAAc,kBAuC1B","sourcesContent":["// we always want this\nconst p = process as NodeJS.Process & {\n setSourceMapsEnabled(v: boolean): void\n}\np.setSourceMapsEnabled(true)\n\nimport { v4 as uuid } from 'uuid'\nexport interface ProcessInfoNodeData {\n // set initially, but deleted before it is written\n hrstart?: [number, number]\n\n // always set\n date: string\n argv: string[]\n execArgv: string[]\n NODE_OPTIONS?: string\n cwd: string\n pid: number\n ppid: number\n parent: string | null\n uuid: string\n files: string[]\n sources: Record<string, string[]>\n\n // fields that are only set when the process completes\n root?: string | null\n externalID?: string | null\n code?: number | null\n signal?: NodeJS.Signals | null\n runtime?: number\n globalsAdded?: string[]\n}\n\n\nconst envKey = (k: string) => `_TAPJS_PROCESSINFO_${k.toUpperCase()}_`\nconst getEnv = (k: string) => process.env[envKey(k)]\nconst setEnv = (k: string, v: string) => (process.env[envKey(k)] = v)\nconst delEnv = (k: string) => delete process.env[envKey(k)]\n\nimport { register as registerCoverage } from './register-coverage.js'\nimport { register as registerEnv } from './register-env.js'\nimport { register as registerProcessEnd } from './register-process-end.js'\nimport { register as registerCJS } from './register-cjs.js'\n\n// this module is hybridized. In node v20, it's the *commonjs* one that\n// gets loaded, because the esm loader context can't modify the main thread\n// except via communication over the port to the globalPreload env.\n// So, we have to store our singleton on the global.\n//\n// If it later loads the esm form of this module, that's fine, because it'll\n// see the global processInfo object, and not re-register anything.\n\nconst kProcessInfo = Symbol.for('@tapjs/processinfo.ProcessInfoNodeData')\nconst g = global as typeof globalThis & {\n [kProcessInfo]?: ProcessInfoNodeData\n}\n\n// only used for tests so we can simulate multiple processes\nexport const reset = () => {\n g[kProcessInfo] = undefined\n return { getProcessInfo }\n}\n\nexport const getProcessInfo = (): ProcessInfoNodeData => {\n if (g[kProcessInfo]) return g[kProcessInfo]\n\n g[kProcessInfo] = {\n hrstart: process.hrtime(),\n date: new Date().toISOString(),\n argv: process.argv,\n execArgv: process.execArgv,\n NODE_OPTIONS: process.env.NODE_OPTIONS,\n cwd: process.cwd(),\n pid: process.pid,\n ppid: process.ppid,\n parent: getEnv('parent') || null,\n uuid: uuid(),\n files: [],\n sources: Object.create(null),\n }\n\n if (!g[kProcessInfo].parent) {\n g[kProcessInfo].root = g[kProcessInfo].uuid\n setEnv('root', g[kProcessInfo].uuid)\n } else {\n g[kProcessInfo].root = getEnv('root')\n }\n // this is the parent of any further child processes\n setEnv('parent', g[kProcessInfo].uuid)\n const externalID = getEnv('external_id')\n if (externalID) {\n g[kProcessInfo].externalID = externalID\n // externalID only applies to ONE process, not all its children.\n delEnv('external_id')\n }\n\n registerCJS()\n registerEnv()\n registerCoverage()\n registerProcessEnd()\n\n return g[kProcessInfo]\n}\n"]}
@@ -11,6 +11,7 @@ export declare class ProcessInfoNode {
11
11
  ppid: number;
12
12
  uuid: string;
13
13
  files: string[];
14
+ sources: Record<string, string[]>;
14
15
  parent?: ProcessInfoNode | null;
15
16
  root?: ProcessInfoNode | null;
16
17
  children?: Set<ProcessInfoNode> | null;
@@ -1 +1 @@
1
- {"version":3,"file":"process-info-node.d.ts","sourceRoot":"","sources":["../../lib/process-info-node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE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EAAE,MAAM,EAAE,CAAC,CAAsB;IACvD,MAAM,CAAC,EAAE,eAAe,GAAG,IAAI,CAAO;IACtC,IAAI,CAAC,EAAE,eAAe,GAAG,IAAI,CAAO;IACpC,QAAQ,CAAC,EAAE,GAAG,CAAC,eAAe,CAAC,GAAG,IAAI,CAAO;IAC7C,UAAU,EAAE,MAAM,GAAG,IAAI,CAAO;gBAIpB,IAAI,EAAE,mBAAmB;IAKrC,MAAM;;;IAcN,IAAI,CAAC,EAAE,EAAE,WAAW;CAiErB"}
@@ -11,6 +11,7 @@ class ProcessInfoNode {
11
11
  ppid;
12
12
  uuid;
13
13
  files = [];
14
+ sources = Object.create(null);
14
15
  parent = null;
15
16
  root = null;
16
17
  children = null;
@@ -1 +1 @@
1
- {"version":3,"file":"process-info-node.js","sourceRoot":"","sources":["../../lib/process-info-node.ts"],"names":[],"mappings":";;;AAGA,MAAa,eAAe;IAC1B,IAAI,CAAS;IACb,IAAI,CAAW;IACf,QAAQ,CAAW;IACnB,YAAY,CAAS;IACrB,GAAG,CAAS;IACZ,GAAG,CAAS;IACZ,IAAI,CAAS;IACb,IAAI,CAAS;IACb,KAAK,GAAa,EAAE,CAAA;IACpB,MAAM,GAA4B,IAAI,CAAA;IACtC,IAAI,GAA4B,IAAI,CAAA;IACpC,QAAQ,GAAiC,IAAI,CAAA;IAC7C,UAAU,GAAkB,IAAI,CAAA;IAEhC,KAAK,CAAqB;IAE1B,YAAY,IAAyB;QACnC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;QACjB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IAC3B,CAAC;IAED,MAAM;QACJ,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC;aACjB,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,CAAC;aACvD,GAAG,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,CAAA;YAC7B,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE;gBAC7B,CAAC,CAAC,MAAM,GAAG,IAAI,CAAA;aAChB;YACD,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;SACnC;QAED,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,KAAiB,EAAE;YACtC,MAAM,KAAK,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;YAC7B,IAAI,CAAC,KAAK,EAAE;gBACV,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,GAAG,CAAkB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;aAClD;iBAAM;gBACL,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;aAChB;SACF;QAED,IAAI,IAAI,CAAC,UAAU,EAAE;YACnB,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;SAC1C;IACH,CAAC;CACF;AArGD,0CAqGC","sourcesContent":["import type { ProcessInfo } from './index.js'\nimport type { ProcessInfoNodeData } from './get-process-info.js'\n\nexport class ProcessInfoNode {\n date!: string\n argv!: string[]\n execArgv!: string[]\n NODE_OPTIONS?: string\n cwd!: string\n pid!: number\n ppid!: number\n uuid!: string\n files: string[] = []\n parent?: ProcessInfoNode | null = null\n root?: ProcessInfoNode | null = null\n children?: Set<ProcessInfoNode> | null = null\n externalID: string | null = null\n\n #data: ProcessInfoNodeData\n\n constructor(data: ProcessInfoNodeData) {\n this.#data = data\n Object.assign(this, data)\n }\n\n toJSON() {\n return Object.fromEntries(\n Object.entries(this)\n .filter(([_, val]) => val !== null && val !== undefined)\n .map(([key, val]) =>\n val instanceof ProcessInfoNode\n ? [key, val.uuid]\n : key === 'children'\n ? [key, [...val].map(c => c.uuid)]\n : [key, val]\n )\n )\n }\n\n link(db: ProcessInfo) {\n db.uuids.set(this.uuid, this)\n if (this.#data.parent) {\n this.parent = db.uuids.get(this.#data.parent) || this.parent\n }\n if (this.#data.root) {\n this.root = db.uuids.get(this.#data.root) ?? this.root\n }\n\n if (this.parent === null) {\n this.root = this\n const pendingRoot = db.pendingRoot.get(this.uuid)\n if (pendingRoot) {\n for (const n of pendingRoot) {\n n.root = this\n }\n db.pendingRoot.delete(this.uuid)\n }\n db.roots.add(this)\n } else if (typeof this.root === 'string') {\n const pendingRoot = db.pendingRoot.get(this.root)\n if (pendingRoot) {\n pendingRoot.add(this)\n } else {\n db.pendingRoot.set(this.root, new Set([this]))\n }\n }\n\n if (typeof this.parent === 'string') {\n const pendingParent = db.pendingParent.get(this.parent)\n if (pendingParent) {\n pendingParent.add(this)\n } else {\n db.pendingParent.set(this.parent, new Set([this]))\n }\n } else if (this.parent) {\n if (!this.parent.children) {\n this.parent.children = new Set([this])\n } else {\n this.parent.children.add(this)\n }\n }\n\n const pendingParent = db.pendingParent.get(this.uuid)\n if (pendingParent) {\n this.children = pendingParent\n for (const n of this.children) {\n n.parent = this\n }\n db.pendingParent.delete(this.uuid)\n }\n\n for (const f of this.files as string[]) {\n const files = db.files.get(f)\n if (!files) {\n db.files.set(f, new Set<ProcessInfoNode>([this]))\n } else {\n files.add(this)\n }\n }\n\n if (this.externalID) {\n db.externalIDs.set(this.externalID, this)\n }\n }\n}\n"]}
1
+ {"version":3,"file":"process-info-node.js","sourceRoot":"","sources":["../../lib/process-info-node.ts"],"names":[],"mappings":";;;AAGA,MAAa,eAAe;IAC1B,IAAI,CAAS;IACb,IAAI,CAAW;IACf,QAAQ,CAAW;IACnB,YAAY,CAAS;IACrB,GAAG,CAAS;IACZ,GAAG,CAAS;IACZ,IAAI,CAAS;IACb,IAAI,CAAS;IACb,KAAK,GAAa,EAAE,CAAA;IACpB,OAAO,GAA6B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACvD,MAAM,GAA4B,IAAI,CAAA;IACtC,IAAI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C,CAAC,CAAA;aACnD;SACF;aAAM,IAAI,IAAI,CAAC,MAAM,EAAE;YACtB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE;gBACzB,IAAI,CAAC,MAAM,CAAC,QAAQ,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAA;aACvC;iBAAM;gBACL,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;aAC/B;SACF;QAED,MAAM,aAAa,GAAG,EAAE,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACrD,IAAI,aAAa,EAAE;YACjB,IAAI,CAAC,QAAQ,GAAG,aAAa,CAAA;YAC7B,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE;gBAC7B,CAAC,CAAC,MAAM,GAAG,IAAI,CAAA;aAChB;YACD,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;SACnC;QAED,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,KAAiB,EAAE;YACtC,MAAM,KAAK,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;YAC7B,IAAI,CAAC,KAAK,EAAE;gBACV,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,GAAG,CAAkB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;aAClD;iBAAM;gBACL,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;aAChB;SACF;QAED,IAAI,IAAI,CAAC,UAAU,EAAE;YACnB,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;SAC1C;IACH,CAAC;CACF;AAtGD,0CAsGC","sourcesContent":["import type { ProcessInfo } from './index.js'\nimport type { ProcessInfoNodeData } from './get-process-info.js'\n\nexport class ProcessInfoNode {\n date!: string\n argv!: string[]\n execArgv!: string[]\n NODE_OPTIONS?: string\n cwd!: string\n pid!: number\n ppid!: number\n uuid!: string\n files: string[] = []\n sources: Record<string, string[]> = Object.create(null)\n parent?: ProcessInfoNode | null = null\n root?: ProcessInfoNode | null = null\n children?: Set<ProcessInfoNode> | null = null\n externalID: string | null = null\n\n #data: ProcessInfoNodeData\n\n constructor(data: ProcessInfoNodeData) {\n this.#data = data\n Object.assign(this, data)\n }\n\n toJSON() {\n return Object.fromEntries(\n Object.entries(this)\n .filter(([_, val]) => val !== null && val !== undefined)\n .map(([key, val]) =>\n val instanceof ProcessInfoNode\n ? [key, val.uuid]\n : key === 'children'\n ? [key, [...val].map(c => c.uuid)]\n : [key, val]\n )\n )\n }\n\n link(db: ProcessInfo) {\n db.uuids.set(this.uuid, this)\n if (this.#data.parent) {\n this.parent = db.uuids.get(this.#data.parent) || this.parent\n }\n if (this.#data.root) {\n this.root = db.uuids.get(this.#data.root) ?? this.root\n }\n\n if (this.parent === null) {\n this.root = this\n const pendingRoot = db.pendingRoot.get(this.uuid)\n if (pendingRoot) {\n for (const n of pendingRoot) {\n n.root = this\n }\n db.pendingRoot.delete(this.uuid)\n }\n db.roots.add(this)\n } else if (typeof this.root === 'string') {\n const pendingRoot = db.pendingRoot.get(this.root)\n if (pendingRoot) {\n pendingRoot.add(this)\n } else {\n db.pendingRoot.set(this.root, new Set([this]))\n }\n }\n\n if (typeof this.parent === 'string') {\n const pendingParent = db.pendingParent.get(this.parent)\n if (pendingParent) {\n pendingParent.add(this)\n } else {\n db.pendingParent.set(this.parent, new Set([this]))\n }\n } else if (this.parent) {\n if (!this.parent.children) {\n this.parent.children = new Set([this])\n } else {\n this.parent.children.add(this)\n }\n }\n\n const pendingParent = db.pendingParent.get(this.uuid)\n if (pendingParent) {\n this.children = pendingParent\n for (const n of this.children) {\n n.parent = this\n }\n db.pendingParent.delete(this.uuid)\n }\n\n for (const f of this.files as string[]) {\n const files = db.files.get(f)\n if (!files) {\n db.files.set(f, new Set<ProcessInfoNode>([this]))\n } else {\n files.add(this)\n }\n }\n\n if (this.externalID) {\n db.externalIDs.set(this.externalID, this)\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"register-process-end.d.ts","sourceRoot":"","sources":["../../lib/register-process-end.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,QAAQ,YAsBpB,CAAA"}
1
+ {"version":3,"file":"register-process-end.d.ts","sourceRoot":"","sources":["../../lib/register-process-end.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,QAAQ,YAqCpB,CAAA"}
@@ -4,10 +4,13 @@ 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
+ const url_1 = require("url");
7
9
  const register_coverage_js_1 = require("./register-coverage.js");
8
10
  const cwd = process.env._TAPJS_PROCESSINFO_CWD_ || process.cwd();
9
11
  process.env._TAPJS_PROCESSINFO_CWD_ = cwd;
10
12
  const globals = new Set(Object.keys(global));
13
+ const sourceMaps = new Map();
11
14
  const register = () => {
12
15
  (0, signal_exit_1.onExit)((code, signal) => {
13
16
  const processInfo = (0, get_process_info_js_1.getProcessInfo)();
@@ -16,6 +19,23 @@ const register = () => {
16
19
  const runtime = process.hrtime(processInfo.hrstart);
17
20
  delete processInfo.hrstart;
18
21
  processInfo.files = [...new Set(processInfo.files)];
22
+ // try to find the actual sources of the files we loaded
23
+ // This can't be done up front, because the sourcemap isn't
24
+ // present during the load phase, since it's in the contents.
25
+ for (const file of processInfo.files) {
26
+ const sm = sourceMaps.get(file) || (0, module_1.findSourceMap)(file);
27
+ if (sm && !sourceMaps.has(file))
28
+ sourceMaps.set(file, sm);
29
+ const sources = sm?.payload.sources?.map(s =>
30
+ // it SHOULD always start with file://, but could in theory
31
+ // be literally any string.
32
+ /* c8 ignore start */
33
+ s.startsWith('file://') ? (0, url_1.fileURLToPath)(s) : s
34
+ /* c8 ignore stop */
35
+ );
36
+ if (sources)
37
+ processInfo.sources[file] = sources;
38
+ }
19
39
  processInfo.runtime = runtime[0] * 1e3 + runtime[1] / 1e6;
20
40
  const globalsAdded = Object.keys(global).filter(k => !globals.has(k));
21
41
  if (globalsAdded.length) {
@@ -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,iEAA6D;AAE7D,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,uBAAuB,IAAI,OAAO,CAAC,GAAG,EAAE,CAAA;AAChE,OAAO,CAAC,GAAG,CAAC,uBAAuB,GAAG,GAAG,CAAA;AACzC,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA;AAErC,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,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;QACnD,OAAO,WAAW,CAAC,OAAO,CAAA;QAC1B,WAAW,CAAC,KAAK,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAA;QACnD,WAAW,CAAC,OAAO,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;AAtBY,QAAA,QAAQ,YAsBpB","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'\n\nconst cwd = process.env._TAPJS_PROCESSINFO_CWD_ || process.cwd()\nprocess.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 = process.hrtime(processInfo.hrstart)\n delete processInfo.hrstart\n processInfo.files = [...new Set(processInfo.files)]\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;AAC7C,mCAAiD;AACjD,6BAAmC;AACnC,iEAA6D;AAE7D,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,uBAAuB,IAAI,OAAO,CAAC,GAAG,EAAE,CAAA;AAChE,OAAO,CAAC,GAAG,CAAC,uBAAuB,GAAG,GAAG,CAAA;AACzC,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,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;QACnD,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,sBAAa,EAAC,IAAI,CAAC,CAAA;YACtD,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,C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AQ,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 cwd = process.env._TAPJS_PROCESSINFO_CWD_ || process.cwd()\nprocess.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 = process.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,4 +1,11 @@
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ import type { Serializable } from 'worker_threads';
1
3
  export * from './index.js';
2
- export declare const globalPreload: () => string;
4
+ type GPPort = {
5
+ postMessage: (x: Serializable) => any;
6
+ };
7
+ export declare const globalPreload: (context: {
8
+ port?: GPPort;
9
+ }) => string;
3
10
  export declare const load: (url: string, context: any, nextLoad: Function) => Promise<any>;
4
11
  //# sourceMappingURL=esm.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"esm.d.mts","sourceRoot":"","sources":["../../lib/esm.mts"],"names":[],"mappings":"AAOA,cAAc,YAAY,CAAA;AAa1B,eAAO,MAAM,aAAa,cAczB,CAAA;AAGD,eAAO,MAAM,IAAI,QACV,MAAM,WACF,GAAG,YACF,QAAQ,iBASnB,CAAA"}
1
+ {"version":3,"file":"esm.d.mts","sourceRoot":"","sources":["../../lib/esm.mts"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAOlD,cAAc,YAAY,CAAA;AAU1B,KAAK,MAAM,GAAG;IACZ,WAAW,EAAE,CAAC,CAAC,EAAE,YAAY,KAAK,GAAG,CAAA;CACtC,CAAA;AAED,eAAO,MAAM,aAAa,YAAa;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,WAsBvD,CAAA;AAGD,eAAO,MAAM,IAAI,QACV,MAAM,WACF,GAAG,YACF,QAAQ,iBAcnB,CAAA"}
package/dist/mjs/esm.mjs CHANGED
@@ -1,33 +1,33 @@
1
1
  // usage: node '--loader=@tapjs/processinfo/esm' foo.mjs
2
2
  import { fileURLToPath } from 'url';
3
3
  import { getExclude } from './get-exclude.js';
4
+ import { getProcessInfo } from './get-process-info.js';
4
5
  import { resolve } from './require-resolve.js';
5
6
  // copy main module so that we can --loader=@tapjs/processinfo and use
6
7
  // this as the entry point as well.
7
8
  export * from './index.js';
8
- import { channel } from 'diagnostics_channel';
9
- const PORT = channel('@tapjs/processinfo.files-loaded');
10
- // on Node v20, loaders are executed in a separate isolated environment
11
- // As a result, to register coverage and track files, we need to act in
12
- // the globalPreload function. The load() method posts a message with the
13
- // filename being loaded, because any registrations that happen in the
14
- // loader thread will not have any effect.
15
- // Using diagnostics channel means that this will keep working in all
16
- // the versions supported, and easily be transferrable to an --import
17
- // argument that attaches the loaders at run-time.
18
- export const globalPreload = () => {
9
+ let PORT = undefined;
10
+ export const globalPreload = (context) => {
19
11
  // this will be something like path/to/dist/mjs/lib/esm.mjs
20
12
  // but we need path/to/dist/cjs/cjs.js
21
13
  const base = resolve('../cjs/cjs.js');
14
+ const { port } = context || {};
15
+ PORT = port;
22
16
  return `
23
- const { createRequire } = getBuiltin('module')
24
- const require = createRequire(${JSON.stringify(base)})
25
- const { getProcessInfo } = require('./get-process-info.js')
26
- const processInfo = getProcessInfo()
27
- const { channel, subscribe } = require('diagnostics_channel')
28
- subscribe('@tapjs/processinfo.files-loaded',
29
- (e) => processInfo.files.push(e)
30
- )
17
+ if (typeof port !== 'undefined') {
18
+ const { createRequire, findSourceMap } = getBuiltin('module')
19
+ const { fileURLToPath } = getBuiltin('url')
20
+ const require = createRequire(${JSON.stringify(base)})
21
+ const { getProcessInfo } = require('./get-process-info.js')
22
+ // must be called eagerly here.
23
+ // this does all the registration as well.
24
+ const processInfo = getProcessInfo()
25
+ port.onmessage = (e) => {
26
+ const filename = e.data
27
+ processInfo.files.push(filename)
28
+ }
29
+ port.unref()
30
+ }
31
31
  `;
32
32
  };
33
33
  const exclude = getExclude('_TAPJS_PROCESSINFO_EXCLUDE_');
@@ -35,7 +35,13 @@ export const load = async (url, context, nextLoad) => {
35
35
  if (/^file:/.test(url)) {
36
36
  const filename = fileURLToPath(url);
37
37
  if (!exclude.test(filename)) {
38
- PORT.publish(filename);
38
+ if (PORT) {
39
+ PORT.postMessage(filename);
40
+ }
41
+ else {
42
+ // call lazily so we don't double-register
43
+ getProcessInfo().files.push(filename);
44
+ }
39
45
  }
40
46
  }
41
47
  return nextLoad(url, context);
@@ -1 +1 @@
1
- {"version":3,"file":"esm.mjs","sourceRoot":"","sources":["../../lib/esm.mts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAA;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAE9C,sEAAsE;AACtE,mCAAmC;AACnC,cAAc,YAAY,CAAA;AAE1B,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAC7C,MAAM,IAAI,GAAG,OAAO,CAAC,iCAAiC,CAAC,CAAA;AAEvD,uEAAuE;AACvE,uEAAuE;AACvE,yEAAyE;AACzE,sEAAsE;AACtE,0CAA0C;AAC1C,qEAAqE;AACrE,qEAAqE;AACrE,kDAAkD;AAClD,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE;IAChC,2DAA2D;IAC3D,sCAAsC;IACtC,MAAM,IAAI,GAAG,OAAO,CAAC,eAAe,CAAC,CAAA;IACrC,OAAO;;gCAEuB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;;;;;;;CAOnD,CAAA;AACD,CAAC,CAAA;AAED,MAAM,OAAO,GAAG,UAAU,CAAC,6BAA6B,CAAC,CAAA;AACzD,MAAM,CAAC,MAAM,IAAI,GAAG,KAAK,EACvB,GAAW,EACX,OAAY,EACZ,QAAkB,EAClB,EAAE;IACF,IAAI,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QACtB,MAAM,QAAQ,GAAG,aAAa,CAAC,GAAG,CAAC,CAAA;QACnC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;YAC3B,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;SACvB;KACF;IACD,OAAO,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;AAC/B,CAAC,CAAA","sourcesContent":["// usage: node '--loader=@tapjs/processinfo/esm' foo.mjs\nimport { fileURLToPath } from 'url'\nimport { getExclude } from './get-exclude.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\nimport { channel } from 'diagnostics_channel'\nconst PORT = channel('@tapjs/processinfo.files-loaded')\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// Using diagnostics channel means that this will keep working in all\n// the versions supported, and easily be transferrable to an --import\n// argument that attaches the loaders at run-time.\nexport const globalPreload = () => {\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 return `\nconst { createRequire } = getBuiltin('module')\nconst require = createRequire(${JSON.stringify(base)})\nconst { getProcessInfo } = require('./get-process-info.js')\nconst processInfo = getProcessInfo()\nconst { channel, subscribe } = require('diagnostics_channel')\nsubscribe('@tapjs/processinfo.files-loaded',\n (e) => processInfo.files.push(e)\n)\n`\n}\n\nconst exclude = getExclude('_TAPJS_PROCESSINFO_EXCLUDE_')\nexport const load = async (\n url: string,\n context: any,\n nextLoad: Function\n) => {\n if (/^file:/.test(url)) {\n const filename = fileURLToPath(url)\n if (!exclude.test(filename)) {\n PORT.publish(filename)\n }\n }\n return nextLoad(url, context)\n}\n"]}
1
+ {"version":3,"file":"esm.mjs","sourceRoot":"","sources":["../../lib/esm.mts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,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,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAE9C,sEAAsE;AACtE,mCAAmC;AACnC,cAAc,YAAY,CAAA;AAa1B,IAAI,IAAI,GAAuB,SAAS,CAAA;AACxC,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,OAA0B,EAAE,EAAE;IAC1D,2DAA2D;IAC3D,sCAAsC;IACtC,MAAM,IAAI,GAAG,OAAO,CAAC,eAAe,CAAC,CAAA;IACrC,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,IAAI,EAAE,CAAA;IAC9B,IAAI,GAAG,IAAI,CAAA;IACX,OAAO;;;;kCAIyB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;;;;;;;;;;;CAWrD,CAAA;AACD,CAAC,CAAA;AAED,MAAM,OAAO,GAAG,UAAU,CAAC,6BAA6B,CAAC,CAAA;AACzD,MAAM,CAAC,MAAM,IAAI,GAAG,KAAK,EACvB,GAAW,EACX,OAAY,EACZ,QAAkB,EAClB,EAAE;IACF,IAAI,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QACtB,MAAM,QAAQ,GAAG,aAAa,CAAC,GAAG,CAAC,CAAA;QACnC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;YAC3B,IAAI,IAAI,EAAE;gBACR,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAA;aAC3B;iBAAM;gBACL,0CAA0C;gBAC1C,cAAc,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;aACtC;SACF;KACF;IACD,OAAO,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;AAC/B,CAAC,CAAA","sourcesContent":["// usage: node '--loader=@tapjs/processinfo/esm' foo.mjs\nimport { fileURLToPath } from 'url'\nimport type { Serializable } from 'worker_threads'\nimport { getExclude } from './get-exclude.js'\nimport { getProcessInfo } from './get-process-info.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 // must be called eagerly here.\n // this does all the registration as well.\n const processInfo = getProcessInfo()\n port.onmessage = (e) => {\n const filename = e.data\n processInfo.files.push(filename)\n }\n port.unref()\n}\n`\n}\n\nconst exclude = getExclude('_TAPJS_PROCESSINFO_EXCLUDE_')\nexport const load = async (\n url: string,\n context: any,\n nextLoad: Function\n) => {\n if (/^file:/.test(url)) {\n const filename = fileURLToPath(url)\n if (!exclude.test(filename)) {\n if (PORT) {\n PORT.postMessage(filename)\n } else {\n // call lazily so we don't double-register\n getProcessInfo().files.push(filename)\n }\n }\n }\n return nextLoad(url, context)\n}\n"]}
@@ -11,6 +11,7 @@ export interface ProcessInfoNodeData {
11
11
  parent: string | null;
12
12
  uuid: string;
13
13
  files: string[];
14
+ sources: Record<string, string[]>;
14
15
  root?: string | null;
15
16
  externalID?: string | null;
16
17
  code?: number | null;
@@ -1 +1 @@
1
- {"version":3,"file":"get-process-info.d.ts","sourceRoot":"","sources":["../../lib/get-process-info.ts"],"names":[],"mappings":";AAOA,MAAM,WAAW,mBAAmB;IAElC,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAG1B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,YAAY,CAAC,EAAE,MAAM,CAAA;IAC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AAG,IAAI,CAAA;IAC1B,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,CAAA;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;CACxB;AA2BD,eAAO,MAAM,KAAK;0BAKgB,mBAAmB;CAFpD,CAAA;AAED,eAAO,MAAM,cAAc,QAAO,mBAuCjC,CAAA"}
@@ -39,6 +39,7 @@ export const getProcessInfo = () => {
39
39
  parent: getEnv('parent') || null,
40
40
  uuid: uuid(),
41
41
  files: [],
42
+ sources: Object.create(null),
42
43
  };
43
44
  if (!g[kProcessInfo].parent) {
44
45
  g[kProcessInfo].root = g[kProcessInfo].uuid;
@@ -1 +1 @@
1
- {"version":3,"file":"get-process-info.js","sourceRoot":"","sources":["../../lib/get-process-info.ts"],"names":[],"mappings":"AAAA,sBAAsB;AACtB,MAAM,CAAC,GAAG,OAET,CAAA;AACD,CAAC,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAA;AAE5B,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAA;AA2BjC,MAAM,MAAM,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,sBAAsB,CAAC,CAAC,WAAW,EAAE,GAAG,CAAA;AACtE,MAAM,MAAM,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;AACpD,MAAM,MAAM,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;AACrE,MAAM,MAAM,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;AA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AAE,EAAE;KACV,CAAA;IAED,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,MAAM,EAAE;QAC3B,CAAC,CAAC,YAAY,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,YAAY,CAAC,CAAC,IAAI,CAAA;QAC3C,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,CAAA;KACrC;SAAM;QACL,CAAC,CAAC,YAAY,CAAC,CAAC,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,CAAA;KACtC;IACD,oDAAoD;IACpD,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,CAAA;IACtC,MAAM,UAAU,GAAG,MAAM,CAAC,aAAa,CAAC,CAAA;IACxC,IAAI,UAAU,EAAE;QACd,CAAC,CAAC,YAAY,CAAC,CAAC,UAAU,GAAG,UAAU,CAAA;QACvC,gEAAgE;QAChE,MAAM,CAAC,aAAa,CAAC,CAAA;KACtB;IAED,WAAW,EAAE,CAAA;IACb,WAAW,EAAE,CAAA;IACb,gBAAgB,EAAE,CAAA;IAClB,kBAAkB,EAAE,CAAA;IAEpB,OAAO,CAAC,CAAC,YAAY,CAAC,CAAA;AACxB,CAAC,CAAA","sourcesContent":["// we always want this\nconst p = process as NodeJS.Process & {\n setSourceMapsEnabled(v: boolean): void\n}\np.setSourceMapsEnabled(true)\n\nimport { v4 as uuid } from 'uuid'\nexport interface ProcessInfoNodeData {\n // set initially, but deleted before it is written\n hrstart?: [number, number]\n\n // always set\n date: string\n argv: string[]\n execArgv: string[]\n NODE_OPTIONS?: string\n cwd: string\n pid: number\n ppid: number\n parent: string | null\n uuid: string\n files: string[]\n\n // fields that are only set when the process completes\n root?: string | null\n externalID?: string | null\n code?: number | null\n signal?: NodeJS.Signals | null\n runtime?: number\n globalsAdded?: string[]\n}\n\n\nconst envKey = (k: string) => `_TAPJS_PROCESSINFO_${k.toUpperCase()}_`\nconst getEnv = (k: string) => process.env[envKey(k)]\nconst setEnv = (k: string, v: string) => (process.env[envKey(k)] = v)\nconst delEnv = (k: string) => delete process.env[envKey(k)]\n\nimport { register as registerCoverage } from './register-coverage.js'\nimport { register as registerEnv } from './register-env.js'\nimport { register as registerProcessEnd } from './register-process-end.js'\nimport { register as registerCJS } from './register-cjs.js'\n\n// this module is hybridized. In node v20, it's the *commonjs* one that\n// gets loaded, because the esm loader context can't modify the main thread\n// except via communication over the port to the globalPreload env.\n// So, we have to store our singleton on the global.\n//\n// If it later loads the esm form of this module, that's fine, because it'll\n// see the global processInfo object, and not re-register anything.\n\nconst kProcessInfo = Symbol.for('@tapjs/processinfo.ProcessInfoNodeData')\nconst g = global as typeof globalThis & {\n [kProcessInfo]?: ProcessInfoNodeData\n}\n\n// only used for tests so we can simulate multiple processes\nexport const reset = () => {\n g[kProcessInfo] = undefined\n return { getProcessInfo }\n}\n\nexport const getProcessInfo = (): ProcessInfoNodeData => {\n if (g[kProcessInfo]) return g[kProcessInfo]\n\n g[kProcessInfo] = {\n hrstart: process.hrtime(),\n date: new Date().toISOString(),\n argv: process.argv,\n execArgv: process.execArgv,\n NODE_OPTIONS: process.env.NODE_OPTIONS,\n cwd: process.cwd(),\n pid: process.pid,\n ppid: process.ppid,\n parent: getEnv('parent') || null,\n uuid: uuid(),\n files: [],\n }\n\n if (!g[kProcessInfo].parent) {\n g[kProcessInfo].root = g[kProcessInfo].uuid\n setEnv('root', g[kProcessInfo].uuid)\n } else {\n g[kProcessInfo].root = getEnv('root')\n }\n // this is the parent of any further child processes\n setEnv('parent', g[kProcessInfo].uuid)\n const externalID = getEnv('external_id')\n if (externalID) {\n g[kProcessInfo].externalID = externalID\n // externalID only applies to ONE process, not all its children.\n delEnv('external_id')\n }\n\n registerCJS()\n registerEnv()\n registerCoverage()\n registerProcessEnd()\n\n return g[kProcessInfo]\n}\n"]}
1
+ {"version":3,"file":"get-process-info.js","sourceRoot":"","sources":["../../lib/get-process-info.ts"],"names":[],"mapp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AC,CAAC,YAAY,CAAC,CAAC,UAAU,GAAG,UAAU,CAAA;QACvC,gEAAgE;QAChE,MAAM,CAAC,aAAa,CAAC,CAAA;KACtB;IAED,WAAW,EAAE,CAAA;IACb,WAAW,EAAE,CAAA;IACb,gBAAgB,EAAE,CAAA;IAClB,kBAAkB,EAAE,CAAA;IAEpB,OAAO,CAAC,CAAC,YAAY,CAAC,CAAA;AACxB,CAAC,CAAA","sourcesContent":["// we always want this\nconst p = process as NodeJS.Process & {\n setSourceMapsEnabled(v: boolean): void\n}\np.setSourceMapsEnabled(true)\n\nimport { v4 as uuid } from 'uuid'\nexport interface ProcessInfoNodeData {\n // set initially, but deleted before it is written\n hrstart?: [number, number]\n\n // always set\n date: string\n argv: string[]\n execArgv: string[]\n NODE_OPTIONS?: string\n cwd: string\n pid: number\n ppid: number\n parent: string | null\n uuid: string\n files: string[]\n sources: Record<string, string[]>\n\n // fields that are only set when the process completes\n root?: string | null\n externalID?: string | null\n code?: number | null\n signal?: NodeJS.Signals | null\n runtime?: number\n globalsAdded?: string[]\n}\n\n\nconst envKey = (k: string) => `_TAPJS_PROCESSINFO_${k.toUpperCase()}_`\nconst getEnv = (k: string) => process.env[envKey(k)]\nconst setEnv = (k: string, v: string) => (process.env[envKey(k)] = v)\nconst delEnv = (k: string) => delete process.env[envKey(k)]\n\nimport { register as registerCoverage } from './register-coverage.js'\nimport { register as registerEnv } from './register-env.js'\nimport { register as registerProcessEnd } from './register-process-end.js'\nimport { register as registerCJS } from './register-cjs.js'\n\n// this module is hybridized. In node v20, it's the *commonjs* one that\n// gets loaded, because the esm loader context can't modify the main thread\n// except via communication over the port to the globalPreload env.\n// So, we have to store our singleton on the global.\n//\n// If it later loads the esm form of this module, that's fine, because it'll\n// see the global processInfo object, and not re-register anything.\n\nconst kProcessInfo = Symbol.for('@tapjs/processinfo.ProcessInfoNodeData')\nconst g = global as typeof globalThis & {\n [kProcessInfo]?: ProcessInfoNodeData\n}\n\n// only used for tests so we can simulate multiple processes\nexport const reset = () => {\n g[kProcessInfo] = undefined\n return { getProcessInfo }\n}\n\nexport const getProcessInfo = (): ProcessInfoNodeData => {\n if (g[kProcessInfo]) return g[kProcessInfo]\n\n g[kProcessInfo] = {\n hrstart: process.hrtime(),\n date: new Date().toISOString(),\n argv: process.argv,\n execArgv: process.execArgv,\n NODE_OPTIONS: process.env.NODE_OPTIONS,\n cwd: process.cwd(),\n pid: process.pid,\n ppid: process.ppid,\n parent: getEnv('parent') || null,\n uuid: uuid(),\n files: [],\n sources: Object.create(null),\n }\n\n if (!g[kProcessInfo].parent) {\n g[kProcessInfo].root = g[kProcessInfo].uuid\n setEnv('root', g[kProcessInfo].uuid)\n } else {\n g[kProcessInfo].root = getEnv('root')\n }\n // this is the parent of any further child processes\n setEnv('parent', g[kProcessInfo].uuid)\n const externalID = getEnv('external_id')\n if (externalID) {\n g[kProcessInfo].externalID = externalID\n // externalID only applies to ONE process, not all its children.\n delEnv('external_id')\n }\n\n registerCJS()\n registerEnv()\n registerCoverage()\n registerProcessEnd()\n\n return g[kProcessInfo]\n}\n"]}
@@ -11,6 +11,7 @@ export declare class ProcessInfoNode {
11
11
  ppid: number;
12
12
  uuid: string;
13
13
  files: string[];
14
+ sources: Record<string, string[]>;
14
15
  parent?: ProcessInfoNode | null;
15
16
  root?: ProcessInfoNode | null;
16
17
  children?: Set<ProcessInfoNode> | null;
@@ -1 +1 @@
1
- {"version":3,"file":"process-info-node.d.ts","sourceRoot":"","sources":["../../lib/process-info-node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAC7C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAEhE,qBAAa,eAAe;;IAC1B,IAAI,EAAG,MAAM,CAAA;IACb,IAAI,EAAG,MAAM,EAAE,CAAA;IACf,QAAQ,EAAG,MAAM,EAAE,CAAA;IACnB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,GAAG,EAA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AE,mBAAmB;IAKrC,MAAM;;;IAcN,IAAI,CAAC,EAAE,EAAE,WAAW;CAiErB"}
@@ -8,6 +8,7 @@ export class ProcessInfoNode {
8
8
  ppid;
9
9
  uuid;
10
10
  files = [];
11
+ sources = Object.create(null);
11
12
  parent = null;
12
13
  root = null;
13
14
  children = null;
@@ -1 +1 @@
1
- {"version":3,"file":"process-info-node.js","sourceRoot":"","sources":["../../lib/process-info-node.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,eAAe;IAC1B,IAAI,CAAS;IACb,IAAI,CAAW;IACf,QAAQ,CAAW;IACnB,YAAY,CAAS;IACrB,GAAG,CAAS;IACZ,GAAG,CAAS;IACZ,IAAI,CAAS;IACb,IAAI,CAAS;IACb,KAAK,GAAa,EAAE,CAAA;IACpB,MAAM,GAA4B,IAAI,CAAA;IACtC,IAAI,GAA4B,IAAI,CAAA;IACpC,QAAQ,GAAiC,IAAI,CAAA;IAC7C,UAAU,GAAkB,IAAI,CAAA;IAEhC,KAAK,CAAqB;IAE1B,YAAY,IAAyB;QACnC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;QACjB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IAC3B,CAAC;IAED,MAAM;QACJ,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC;aACjB,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,CAAC;aACvD,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,CAClB,GAAG,YAAY,eAAe;YAC5B,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,CAAC;YACjB,CAAC,CAAC,GAAG,KAAK,UAAU;gBACpB,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,C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,MAAM,KAAK,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;YAC7B,IAAI,CAAC,KAAK,EAAE;gBACV,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,GAAG,CAAkB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;aAClD;iBAAM;gBACL,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;aAChB;SACF;QAED,IAAI,IAAI,CAAC,UAAU,EAAE;YACnB,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;SAC1C;IACH,CAAC;CACF","sourcesContent":["import type { ProcessInfo } from './index.js'\nimport type { ProcessInfoNodeData } from './get-process-info.js'\n\nexport class ProcessInfoNode {\n date!: string\n argv!: string[]\n execArgv!: string[]\n NODE_OPTIONS?: string\n cwd!: string\n pid!: number\n ppid!: number\n uuid!: string\n files: string[] = []\n parent?: ProcessInfoNode | null = null\n root?: ProcessInfoNode | null = null\n children?: Set<ProcessInfoNode> | null = null\n externalID: string | null = null\n\n #data: ProcessInfoNodeData\n\n constructor(data: ProcessInfoNodeData) {\n this.#data = data\n Object.assign(this, data)\n }\n\n toJSON() {\n return Object.fromEntries(\n Object.entries(this)\n .filter(([_, val]) => val !== null && val !== undefined)\n .map(([key, val]) =>\n val instanceof ProcessInfoNode\n ? [key, val.uuid]\n : key === 'children'\n ? [key, [...val].map(c => c.uuid)]\n : [key, val]\n )\n )\n }\n\n link(db: ProcessInfo) {\n db.uuids.set(this.uuid, this)\n if (this.#data.parent) {\n this.parent = db.uuids.get(this.#data.parent) || this.parent\n }\n if (this.#data.root) {\n this.root = db.uuids.get(this.#data.root) ?? this.root\n }\n\n if (this.parent === null) {\n this.root = this\n const pendingRoot = db.pendingRoot.get(this.uuid)\n if (pendingRoot) {\n for (const n of pendingRoot) {\n n.root = this\n }\n db.pendingRoot.delete(this.uuid)\n }\n db.roots.add(this)\n } else if (typeof this.root === 'string') {\n const pendingRoot = db.pendingRoot.get(this.root)\n if (pendingRoot) {\n pendingRoot.add(this)\n } else {\n db.pendingRoot.set(this.root, new Set([this]))\n }\n }\n\n if (typeof this.parent === 'string') {\n const pendingParent = db.pendingParent.get(this.parent)\n if (pendingParent) {\n pendingParent.add(this)\n } else {\n db.pendingParent.set(this.parent, new Set([this]))\n }\n } else if (this.parent) {\n if (!this.parent.children) {\n this.parent.children = new Set([this])\n } else {\n this.parent.children.add(this)\n }\n }\n\n const pendingParent = db.pendingParent.get(this.uuid)\n if (pendingParent) {\n this.children = pendingParent\n for (const n of this.children) {\n n.parent = this\n }\n db.pendingParent.delete(this.uuid)\n }\n\n for (const f of this.files as string[]) {\n const files = db.files.get(f)\n if (!files) {\n db.files.set(f, new Set<ProcessInfoNode>([this]))\n } else {\n files.add(this)\n }\n }\n\n if (this.externalID) {\n db.externalIDs.set(this.externalID, this)\n }\n }\n}\n"]}
1
+ {"version":3,"file":"process-info-node.js","sourceRoot":"","sources":["../../lib/process-info-node.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,eAAe;IAC1B,IAAI,CAAS;IACb,IAAI,CAAW;IACf,QAAQ,CAAW;IACnB,YAAY,CAAS;IACrB,GAAG,CAAS;IACZ,GAAG,CAAS;IACZ,IAAI,CAAS;IACb,IAAI,CAAS;IACb,KAAK,GAAa,EAAE,CAAA;IACpB,OAAO,GAA6B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACvD,MAAM,GAA4B,IAAI,CAAA;IACtC,IAAI,GAA4B,IAAI,CAAA;IACpC,QAAQ,GAAiC,IAAI,CAAA;IAC7C,UAAU,GAAkB,IAAI,CAAA;IAEhC,KAAK,CAAqB;IAE1B,YAAY,IAAyB;QACnC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;QACjB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IAC3B,CAAC;IAED,MAAM;QACJ,OA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AAC,GAAG,CAAC,IAAI,CAAC,CAAA;aAC/B;SACF;QAED,MAAM,aAAa,GAAG,EAAE,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACrD,IAAI,aAAa,EAAE;YACjB,IAAI,CAAC,QAAQ,GAAG,aAAa,CAAA;YAC7B,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE;gBAC7B,CAAC,CAAC,MAAM,GAAG,IAAI,CAAA;aAChB;YACD,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;SACnC;QAED,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,KAAiB,EAAE;YACtC,MAAM,KAAK,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;YAC7B,IAAI,CAAC,KAAK,EAAE;gBACV,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,GAAG,CAAkB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;aAClD;iBAAM;gBACL,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;aAChB;SACF;QAED,IAAI,IAAI,CAAC,UAAU,EAAE;YACnB,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;SAC1C;IACH,CAAC;CACF","sourcesContent":["import type { ProcessInfo } from './index.js'\nimport type { ProcessInfoNodeData } from './get-process-info.js'\n\nexport class ProcessInfoNode {\n date!: string\n argv!: string[]\n execArgv!: string[]\n NODE_OPTIONS?: string\n cwd!: string\n pid!: number\n ppid!: number\n uuid!: string\n files: string[] = []\n sources: Record<string, string[]> = Object.create(null)\n parent?: ProcessInfoNode | null = null\n root?: ProcessInfoNode | null = null\n children?: Set<ProcessInfoNode> | null = null\n externalID: string | null = null\n\n #data: ProcessInfoNodeData\n\n constructor(data: ProcessInfoNodeData) {\n this.#data = data\n Object.assign(this, data)\n }\n\n toJSON() {\n return Object.fromEntries(\n Object.entries(this)\n .filter(([_, val]) => val !== null && val !== undefined)\n .map(([key, val]) =>\n val instanceof ProcessInfoNode\n ? [key, val.uuid]\n : key === 'children'\n ? [key, [...val].map(c => c.uuid)]\n : [key, val]\n )\n )\n }\n\n link(db: ProcessInfo) {\n db.uuids.set(this.uuid, this)\n if (this.#data.parent) {\n this.parent = db.uuids.get(this.#data.parent) || this.parent\n }\n if (this.#data.root) {\n this.root = db.uuids.get(this.#data.root) ?? this.root\n }\n\n if (this.parent === null) {\n this.root = this\n const pendingRoot = db.pendingRoot.get(this.uuid)\n if (pendingRoot) {\n for (const n of pendingRoot) {\n n.root = this\n }\n db.pendingRoot.delete(this.uuid)\n }\n db.roots.add(this)\n } else if (typeof this.root === 'string') {\n const pendingRoot = db.pendingRoot.get(this.root)\n if (pendingRoot) {\n pendingRoot.add(this)\n } else {\n db.pendingRoot.set(this.root, new Set([this]))\n }\n }\n\n if (typeof this.parent === 'string') {\n const pendingParent = db.pendingParent.get(this.parent)\n if (pendingParent) {\n pendingParent.add(this)\n } else {\n db.pendingParent.set(this.parent, new Set([this]))\n }\n } else if (this.parent) {\n if (!this.parent.children) {\n this.parent.children = new Set([this])\n } else {\n this.parent.children.add(this)\n }\n }\n\n const pendingParent = db.pendingParent.get(this.uuid)\n if (pendingParent) {\n this.children = pendingParent\n for (const n of this.children) {\n n.parent = this\n }\n db.pendingParent.delete(this.uuid)\n }\n\n for (const f of this.files as string[]) {\n const files = db.files.get(f)\n if (!files) {\n db.files.set(f, new Set<ProcessInfoNode>([this]))\n } else {\n files.add(this)\n }\n }\n\n if (this.externalID) {\n db.externalIDs.set(this.externalID, this)\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"register-process-end.d.ts","sourceRoot":"","sources":["../../lib/register-process-end.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,QAAQ,YAsBpB,CAAA"}
1
+ {"version":3,"file":"register-process-end.d.ts","sourceRoot":"","sources":["../../lib/register-process-end.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,QAAQ,YAqCpB,CAAA"}
@@ -1,10 +1,13 @@
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
+ import { fileURLToPath } from 'url';
4
6
  import { coverageOnProcessEnd } from './register-coverage.js';
5
7
  const cwd = process.env._TAPJS_PROCESSINFO_CWD_ || process.cwd();
6
8
  process.env._TAPJS_PROCESSINFO_CWD_ = cwd;
7
9
  const globals = new Set(Object.keys(global));
10
+ const sourceMaps = new Map();
8
11
  export const register = () => {
9
12
  onExit((code, signal) => {
10
13
  const processInfo = getProcessInfo();
@@ -13,6 +16,23 @@ export const register = () => {
13
16
  const runtime = process.hrtime(processInfo.hrstart);
14
17
  delete processInfo.hrstart;
15
18
  processInfo.files = [...new Set(processInfo.files)];
19
+ // try to find the actual sources of the files we loaded
20
+ // This can't be done up front, because the sourcemap isn't
21
+ // present during the load phase, since it's in the contents.
22
+ for (const file of processInfo.files) {
23
+ const sm = sourceMaps.get(file) || findSourceMap(file);
24
+ if (sm && !sourceMaps.has(file))
25
+ sourceMaps.set(file, sm);
26
+ const sources = sm?.payload.sources?.map(s =>
27
+ // it SHOULD always start with file://, but could in theory
28
+ // be literally any string.
29
+ /* c8 ignore start */
30
+ s.startsWith('file://') ? fileURLToPath(s) : s
31
+ /* c8 ignore stop */
32
+ );
33
+ if (sources)
34
+ processInfo.sources[file] = sources;
35
+ }
16
36
  processInfo.runtime = runtime[0] * 1e3 + runtime[1] / 1e6;
17
37
  const globalsAdded = Object.keys(global).filter(k => !globals.has(k));
18
38
  if (globalsAdded.length) {
@@ -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,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G,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 { coverageOnProcessEnd } from './register-coverage.js'\n\nconst cwd = process.env._TAPJS_PROCESSINFO_CWD_ || process.cwd()\nprocess.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 = process.hrtime(processInfo.hrstart)\n delete processInfo.hrstart\n processInfo.files = [...new Set(processInfo.files)]\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,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-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 cwd = process.env._TAPJS_PROCESSINFO_CWD_ || process.cwd()\nprocess.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 = process.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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tapjs/processinfo",
3
- "version": "2.1.4",
3
+ "version": "2.2.0",
4
4
  "main": "./dist/cjs/index.js",
5
5
  "types": "./dist/cjs/index.d.ts",
6
6
  "module": "./dist/mjs/esm.mjs",