1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
export type ValInfo = {
stack: string[];
endpoint: string;
user: string;
name: string;
};
function info(): ValInfo {
try {
throw new Error();
} catch (e) {
console.error(e);
const stack = e.stack.split("\n");
const [kind, user, name] = stack
.filter(v => v.includes("esm.town"))
.at(-1)
.split("esm.town/")
.at(1)
?.split("?")
.at(0)
?.split("/");
const endpoint = kind == "v" ? `${user}-${name}.web.val.run` : "";
return { stack, endpoint, user, name };
}
}
export default info;