@vrowser/node-polyfill 0.0.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.
Files changed (61) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +121 -0
  3. package/dist/crypto.d.ts +48 -0
  4. package/dist/crypto.d.ts.map +1 -0
  5. package/dist/crypto.js +232 -0
  6. package/dist/crypto.js.map +1 -0
  7. package/dist/dns.d.ts +74 -0
  8. package/dist/dns.d.ts.map +1 -0
  9. package/dist/dns.js +172 -0
  10. package/dist/dns.js.map +1 -0
  11. package/dist/dns_promises.d.ts +2 -0
  12. package/dist/dns_promises.js +3 -0
  13. package/dist/events.d.ts +99 -0
  14. package/dist/events.d.ts.map +1 -0
  15. package/dist/events.js +480 -0
  16. package/dist/events.js.map +1 -0
  17. package/dist/module.d.ts +40 -0
  18. package/dist/module.d.ts.map +1 -0
  19. package/dist/module.js +72 -0
  20. package/dist/module.js.map +1 -0
  21. package/dist/net.d.ts +38 -0
  22. package/dist/net.d.ts.map +1 -0
  23. package/dist/net.js +53 -0
  24. package/dist/net.js.map +1 -0
  25. package/dist/os.d.ts +96 -0
  26. package/dist/os.d.ts.map +1 -0
  27. package/dist/os.js +140 -0
  28. package/dist/os.js.map +1 -0
  29. package/dist/perf_hooks.d.ts +124 -0
  30. package/dist/perf_hooks.d.ts.map +1 -0
  31. package/dist/perf_hooks.js +105 -0
  32. package/dist/perf_hooks.js.map +1 -0
  33. package/dist/process.d.ts +147 -0
  34. package/dist/process.d.ts.map +1 -0
  35. package/dist/process.js +209 -0
  36. package/dist/process.js.map +1 -0
  37. package/dist/readline.d.ts +93 -0
  38. package/dist/readline.d.ts.map +1 -0
  39. package/dist/readline.js +268 -0
  40. package/dist/readline.js.map +1 -0
  41. package/dist/timers.d.ts +36 -0
  42. package/dist/timers.d.ts.map +1 -0
  43. package/dist/timers.js +54 -0
  44. package/dist/timers.js.map +1 -0
  45. package/dist/timers_promises.d.ts +22 -0
  46. package/dist/timers_promises.d.ts.map +1 -0
  47. package/dist/timers_promises.js +102 -0
  48. package/dist/timers_promises.js.map +1 -0
  49. package/dist/tty.d.ts +48 -0
  50. package/dist/tty.d.ts.map +1 -0
  51. package/dist/tty.js +67 -0
  52. package/dist/tty.js.map +1 -0
  53. package/dist/url.d.ts +39 -0
  54. package/dist/url.d.ts.map +1 -0
  55. package/dist/url.js +41 -0
  56. package/dist/url.js.map +1 -0
  57. package/dist/util.d.ts +66 -0
  58. package/dist/util.d.ts.map +1 -0
  59. package/dist/util.js +117 -0
  60. package/dist/util.js.map +1 -0
  61. package/package.json +125 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.js","names":["builtinModules: string[]"],"sources":["../src/module.ts"],"sourcesContent":["/**\n * `node:module` compatible entry point\n *\n * Browser/Worker environments cannot use `require()`.\n * `createRequire()` returns a stub that throws on invocation.\n *\n * @module module\n */\n\n/**\n * @author kazuya kawaguchi (a.k.a. kazupon)\n * @license MIT\n */\n\ninterface RequireFunction {\n (id: string): never\n resolve: (id: string) => string\n cache: Record<string, unknown>\n}\n\n/**\n * Create a require function bound to the given URL.\n * In browser/Worker environments, the returned `require()` throws on invocation\n * since CommonJS modules cannot be loaded.\n */\nexport function createRequire(_url: string | URL): RequireFunction {\n function require(_id: string): never {\n throw new Error(`[vrowser] require() is not supported in browser/Worker environment`)\n }\n require.resolve = (id: string): string => id\n require.cache = {} as Record<string, unknown>\n return require\n}\n\n/**\n * List of Node.js builtin module names (without `node:` prefix).\n */\nexport const builtinModules: string[] = [\n 'assert',\n 'buffer',\n 'child_process',\n 'cluster',\n 'console',\n 'constants',\n 'crypto',\n 'dgram',\n 'dns',\n 'domain',\n 'events',\n 'fs',\n 'http',\n 'https',\n 'module',\n 'net',\n 'os',\n 'path',\n 'perf_hooks',\n 'process',\n 'punycode',\n 'querystring',\n 'readline',\n 'repl',\n 'stream',\n 'string_decoder',\n 'sys',\n 'timers',\n 'tls',\n 'tty',\n 'url',\n 'util',\n 'v8',\n 'vm',\n 'worker_threads',\n 'zlib'\n]\n\nconst _builtinSet = new Set(builtinModules)\n\n/**\n * Check if a module name is a Node.js builtin module.\n */\nexport function isBuiltin(moduleName: string): boolean {\n const name = moduleName.startsWith('node:') ? moduleName.slice(5) : moduleName\n return _builtinSet.has(name)\n}\n\nexport default {\n createRequire,\n builtinModules,\n isBuiltin\n}\n"],"mappings":";;;;;;AAyBA,SAAgB,cAAc,MAAqC;CACjE,SAAS,QAAQ,KAAoB;AACnC,QAAM,IAAI,MAAM,qEAAqE;;AAEvF,SAAQ,WAAW,OAAuB;AAC1C,SAAQ,QAAQ,EAAE;AAClB,QAAO;;;;;AAMT,MAAaA,iBAA2B;CACtC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAM,cAAc,IAAI,IAAI,eAAe;;;;AAK3C,SAAgB,UAAU,YAA6B;CACrD,MAAM,OAAO,WAAW,WAAW,QAAQ,GAAG,WAAW,MAAM,EAAE,GAAG;AACpE,QAAO,YAAY,IAAI,KAAK;;AAG9B,qBAAe;CACb;CACA;CACA;CACD"}
package/dist/net.d.ts ADDED
@@ -0,0 +1,38 @@
1
+ //#region src/net.d.ts
2
+ /**
3
+ * `node:net` stub for browser/Worker environments.
4
+ *
5
+ * Provides minimal no-op exports so that modules importing `node:net`
6
+ * can load without errors. Network socket APIs are not available in browsers.
7
+ *
8
+ * @module net
9
+ */
10
+ /**
11
+ * @author kazuya kawaguchi (a.k.a. kazupon)
12
+ * @license MIT
13
+ */
14
+ declare function createServer(): void;
15
+ declare function createConnection(): void;
16
+ declare const connect: typeof createConnection;
17
+ declare function isIP(_input: string): number;
18
+ declare function isIPv4(_input: string): boolean;
19
+ declare function isIPv6(_input: string): boolean;
20
+ declare class Socket {
21
+ constructor();
22
+ }
23
+ declare class Server {
24
+ constructor();
25
+ }
26
+ declare const _default: {
27
+ createServer: typeof createServer;
28
+ createConnection: typeof createConnection;
29
+ connect: typeof createConnection;
30
+ isIP: typeof isIP;
31
+ isIPv4: typeof isIPv4;
32
+ isIPv6: typeof isIPv6;
33
+ Socket: typeof Socket;
34
+ Server: typeof Server;
35
+ };
36
+ //#endregion
37
+ export { Server, Socket, connect, createConnection, createServer, _default as default, isIP, isIPv4, isIPv6 };
38
+ //# sourceMappingURL=net.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"net.d.ts","names":[],"sources":["../src/net.ts"],"sourcesContent":[],"mappings":";;;;;;AAcA;AAIA;AAMA;AAEA;AAIA;AAIA;AAIA;AAMa,iBA9BG,YAAA,CAAA,CA8BG,EAAA,IAAA;AAIlB,iBA9Be,gBAAA,CAAA,CA8Bf,EAAA,IAAA;cAxBY,gBAAO;iBAEJ,IAAA;iBAIA,MAAA;iBAIA,MAAA;cAIH,MAAA;;;cAMA,MAAA;;;cAIZ"}
package/dist/net.js ADDED
@@ -0,0 +1,53 @@
1
+ //#region src/net.ts
2
+ /**
3
+ * `node:net` stub for browser/Worker environments.
4
+ *
5
+ * Provides minimal no-op exports so that modules importing `node:net`
6
+ * can load without errors. Network socket APIs are not available in browsers.
7
+ *
8
+ * @module net
9
+ */
10
+ /**
11
+ * @author kazuya kawaguchi (a.k.a. kazupon)
12
+ * @license MIT
13
+ */
14
+ function createServer() {
15
+ throw new Error("[vrowser] node:net createServer is not supported in browser/Worker environment");
16
+ }
17
+ function createConnection() {
18
+ throw new Error("[vrowser] node:net createConnection is not supported in browser/Worker environment");
19
+ }
20
+ const connect = createConnection;
21
+ function isIP(_input) {
22
+ return 0;
23
+ }
24
+ function isIPv4(_input) {
25
+ return false;
26
+ }
27
+ function isIPv6(_input) {
28
+ return false;
29
+ }
30
+ var Socket = class {
31
+ constructor() {
32
+ throw new Error("[vrowser] node:net Socket is not supported in browser/Worker environment");
33
+ }
34
+ };
35
+ var Server = class {
36
+ constructor() {
37
+ throw new Error("[vrowser] node:net Server is not supported in browser/Worker environment");
38
+ }
39
+ };
40
+ var net_default = {
41
+ createServer,
42
+ createConnection,
43
+ connect,
44
+ isIP,
45
+ isIPv4,
46
+ isIPv6,
47
+ Socket,
48
+ Server
49
+ };
50
+
51
+ //#endregion
52
+ export { Server, Socket, connect, createConnection, createServer, net_default as default, isIP, isIPv4, isIPv6 };
53
+ //# sourceMappingURL=net.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"net.js","names":[],"sources":["../src/net.ts"],"sourcesContent":["/**\n * `node:net` stub for browser/Worker environments.\n *\n * Provides minimal no-op exports so that modules importing `node:net`\n * can load without errors. Network socket APIs are not available in browsers.\n *\n * @module net\n */\n\n/**\n * @author kazuya kawaguchi (a.k.a. kazupon)\n * @license MIT\n */\n\nexport function createServer() {\n throw new Error('[vrowser] node:net createServer is not supported in browser/Worker environment')\n}\n\nexport function createConnection() {\n throw new Error(\n '[vrowser] node:net createConnection is not supported in browser/Worker environment'\n )\n}\n\nexport const connect = createConnection\n\nexport function isIP(_input: string): number {\n return 0\n}\n\nexport function isIPv4(_input: string): boolean {\n return false\n}\n\nexport function isIPv6(_input: string): boolean {\n return false\n}\n\nexport class Socket {\n constructor() {\n throw new Error('[vrowser] node:net Socket is not supported in browser/Worker environment')\n }\n}\n\nexport class Server {\n constructor() {\n throw new Error('[vrowser] node:net Server is not supported in browser/Worker environment')\n }\n}\n\nexport default {\n createServer,\n createConnection,\n connect,\n isIP,\n isIPv4,\n isIPv6,\n Socket,\n Server\n}\n"],"mappings":";;;;;;;;;;;;;AAcA,SAAgB,eAAe;AAC7B,OAAM,IAAI,MAAM,iFAAiF;;AAGnG,SAAgB,mBAAmB;AACjC,OAAM,IAAI,MACR,qFACD;;AAGH,MAAa,UAAU;AAEvB,SAAgB,KAAK,QAAwB;AAC3C,QAAO;;AAGT,SAAgB,OAAO,QAAyB;AAC9C,QAAO;;AAGT,SAAgB,OAAO,QAAyB;AAC9C,QAAO;;AAGT,IAAa,SAAb,MAAoB;CAClB,cAAc;AACZ,QAAM,IAAI,MAAM,2EAA2E;;;AAI/F,IAAa,SAAb,MAAoB;CAClB,cAAc;AACZ,QAAM,IAAI,MAAM,2EAA2E;;;AAI/F,kBAAe;CACb;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD"}
package/dist/os.d.ts ADDED
@@ -0,0 +1,96 @@
1
+ //#region src/os.d.ts
2
+ /**
3
+ * `node:os` compatible entry point
4
+ *
5
+ * Based on rollup-plugin-polyfill-node os.js polyfill, enhanced with
6
+ * Node.js APIs that are missing from the original polyfill.
7
+ * Browser-implementable APIs use real browser APIs where possible.
8
+ * Node.js-specific APIs are provided as stubs.
9
+ *
10
+ * @module os
11
+ */
12
+ /**
13
+ * Forked from:
14
+ * - rollup-plugin-polyfill-node (https://github.com/nicolo-ribaudo/rollup-plugin-polyfill-node)
15
+ * - node:os (https://github.com/nodejs/node/tree/main/lib/os.js)
16
+ * @author kazuya kawaguchi (a.k.a. kazupon)
17
+ * @license MIT
18
+ */
19
+ declare function endianness(): 'BE' | 'LE';
20
+ declare function hostname(): string;
21
+ declare function loadavg(): [number, number, number];
22
+ declare function uptime(): number;
23
+ declare function freemem(): number;
24
+ declare function totalmem(): number;
25
+ declare function cpus(): object[];
26
+ declare function type(): string;
27
+ declare function release(): string;
28
+ declare function networkInterfaces(): Record<string, never>;
29
+ declare function arch(): string;
30
+ declare function platform(): string;
31
+ declare function tmpdir(): string;
32
+ declare function homedir(): string;
33
+ declare const EOL = "\n";
34
+ declare function availableParallelism(): number;
35
+ declare function version(): string;
36
+ declare function machine(): string;
37
+ declare const devNull = "/dev/null";
38
+ declare const constants: Readonly<{
39
+ signals: Readonly<{}>;
40
+ errno: Readonly<{}>;
41
+ }>;
42
+ /**
43
+ * Stub for `getPriority`.
44
+ * Process priority is not available in browsers.
45
+ */
46
+ declare function getPriority(_pid?: number): number;
47
+ /**
48
+ * Stub for `setPriority`.
49
+ * Process priority is not available in browsers.
50
+ */
51
+ declare function setPriority(_pidOrPriority?: number, _priority?: number): void;
52
+ interface UserInfo {
53
+ uid: number;
54
+ gid: number;
55
+ username: string;
56
+ homedir: string;
57
+ shell: string | null;
58
+ }
59
+ /**
60
+ * Stub for `userInfo`.
61
+ * User information is not available in browsers.
62
+ */
63
+ declare function userInfo(_options?: {
64
+ encoding?: string;
65
+ }): UserInfo;
66
+ declare const _default: {
67
+ endianness: typeof endianness;
68
+ hostname: typeof hostname;
69
+ loadavg: typeof loadavg;
70
+ uptime: typeof uptime;
71
+ freemem: typeof freemem;
72
+ totalmem: typeof totalmem;
73
+ cpus: typeof cpus;
74
+ type: typeof type;
75
+ release: typeof release;
76
+ networkInterfaces: typeof networkInterfaces;
77
+ arch: typeof arch;
78
+ platform: typeof platform;
79
+ tmpdir: typeof tmpdir;
80
+ homedir: typeof homedir;
81
+ EOL: string;
82
+ availableParallelism: typeof availableParallelism;
83
+ version: typeof version;
84
+ machine: typeof machine;
85
+ devNull: string;
86
+ constants: Readonly<{
87
+ signals: Readonly<{}>;
88
+ errno: Readonly<{}>;
89
+ }>;
90
+ getPriority: typeof getPriority;
91
+ setPriority: typeof setPriority;
92
+ userInfo: typeof userInfo;
93
+ };
94
+ //#endregion
95
+ export { EOL, arch, availableParallelism, constants, cpus, _default as default, devNull, endianness, freemem, getPriority, homedir, hostname, loadavg, machine, networkInterfaces, platform, release, setPriority, tmpdir, totalmem, type, uptime, userInfo, version };
96
+ //# sourceMappingURL=os.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"os.d.ts","names":[],"sources":["../src/os.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AAmBA;AAMA;AAOA;AAIA;AAIA;AAIA;AAIA;AAIA;AAIA;AAOgB,iBA5CA,UAAA,CAAA,CA4CqB,EAAA,IAAA,GAAM,IAAA;AAI3B,iBA1CA,QAAA,CAAA,CA0CI,EAAA,MAAA;AAIJ,iBAvCA,OAAA,CAAA,CAuCQ,EAAA,CAAA,MAAA,EAAA,MAAA,EAAA,MAAA,CAAA;AAIR,iBAvCA,MAAA,CAAA,CAuCM,EAAA,MAAA;AAIN,iBAvCA,OAAA,CAAA,CAuCO,EAAA,MAAA;AAIV,iBAvCG,QAAA,CAAA,CAuCA,EAAA,MAAA;AAEA,iBArCA,IAAA,CAAA,CAqCoB,EAAA,MAAA,EAAA;AAOpB,iBAxCA,IAAA,CAAA,CAwCO,EAAA,MAAA;AAOP,iBA3CA,OAAA,CAAA,CA2CO,EAAA,MAAA;AAOV,iBA3CG,iBAAA,CAAA,CA2CI,EA3CiB,MA2CjB,CAAA,MAAA,EAAA,KAAA,CAAA;AAEP,iBAzCG,IAAA,CAAA,CA4Cd,EAAA,MAAA;iBAxCc,QAAA,CAAA;iBAIA,MAAA,CAAA;AAiCM,iBA7BN,OAAA,CAAA,CA6BM,EAAA,MAAA;AAAA,cAzBT,GAAA,GAyBS,IAAA;AASN,iBAhCA,oBAAA,CAAA,CAgCW,EAAA,MAAA;AAQX,iBAjCA,OAAA,CAAA,CAiCW,EAAA,MAAA;AAIjB,iBA9BM,OAAA,CAAA,CA8BE,EAAA,MAAA;AAYF,cAnCH,OAAA,GAmC+C,WAAQ;AAQnE,cAzCY,SAyCZ,EAzCqB,QAyCrB,CAAA;;;;;;;;iBAhCe,WAAA;;;;;iBAQA,WAAA;UAIN,QAAA;;;;;;;;;;;iBAYM,QAAA;;IAA4C;cAQ3D"}
package/dist/os.js ADDED
@@ -0,0 +1,140 @@
1
+ //#region src/os.ts
2
+ /**
3
+ * `node:os` compatible entry point
4
+ *
5
+ * Based on rollup-plugin-polyfill-node os.js polyfill, enhanced with
6
+ * Node.js APIs that are missing from the original polyfill.
7
+ * Browser-implementable APIs use real browser APIs where possible.
8
+ * Node.js-specific APIs are provided as stubs.
9
+ *
10
+ * @module os
11
+ */
12
+ /**
13
+ * Forked from:
14
+ * - rollup-plugin-polyfill-node (https://github.com/nicolo-ribaudo/rollup-plugin-polyfill-node)
15
+ * - node:os (https://github.com/nodejs/node/tree/main/lib/os.js)
16
+ * @author kazuya kawaguchi (a.k.a. kazupon)
17
+ * @license MIT
18
+ */
19
+ function endianness() {
20
+ const buffer = /* @__PURE__ */ new ArrayBuffer(2);
21
+ new DataView(buffer).setInt16(0, 256, true);
22
+ return new Int16Array(buffer)[0] === 256 ? "LE" : "BE";
23
+ }
24
+ function hostname() {
25
+ if (typeof globalThis.location !== "undefined") return globalThis.location.hostname;
26
+ return "";
27
+ }
28
+ function loadavg() {
29
+ return [
30
+ 0,
31
+ 0,
32
+ 0
33
+ ];
34
+ }
35
+ function uptime() {
36
+ return 0;
37
+ }
38
+ function freemem() {
39
+ return Number.MAX_VALUE;
40
+ }
41
+ function totalmem() {
42
+ return Number.MAX_VALUE;
43
+ }
44
+ function cpus() {
45
+ return [];
46
+ }
47
+ function type() {
48
+ return "Browser";
49
+ }
50
+ function release() {
51
+ if (typeof navigator !== "undefined" && navigator.appVersion) return navigator.appVersion;
52
+ return "";
53
+ }
54
+ function networkInterfaces() {
55
+ return {};
56
+ }
57
+ function arch() {
58
+ return "javascript";
59
+ }
60
+ function platform() {
61
+ return "browser";
62
+ }
63
+ function tmpdir() {
64
+ return "/tmp";
65
+ }
66
+ function homedir() {
67
+ return "/";
68
+ }
69
+ const EOL = "\n";
70
+ function availableParallelism() {
71
+ if (typeof navigator !== "undefined" && navigator.hardwareConcurrency) return navigator.hardwareConcurrency;
72
+ return 1;
73
+ }
74
+ function version() {
75
+ if (typeof navigator !== "undefined" && navigator.appVersion) return navigator.appVersion;
76
+ return "";
77
+ }
78
+ function machine() {
79
+ if (typeof navigator !== "undefined" && navigator.platform) return navigator.platform;
80
+ return "unknown";
81
+ }
82
+ const devNull = "/dev/null";
83
+ const constants = Object.freeze({
84
+ signals: Object.freeze({}),
85
+ errno: Object.freeze({})
86
+ });
87
+ /**
88
+ * Stub for `getPriority`.
89
+ * Process priority is not available in browsers.
90
+ */
91
+ function getPriority(_pid) {
92
+ return 0;
93
+ }
94
+ /**
95
+ * Stub for `setPriority`.
96
+ * Process priority is not available in browsers.
97
+ */
98
+ function setPriority(_pidOrPriority, _priority) {}
99
+ /**
100
+ * Stub for `userInfo`.
101
+ * User information is not available in browsers.
102
+ */
103
+ function userInfo(_options) {
104
+ return {
105
+ uid: -1,
106
+ gid: -1,
107
+ username: "",
108
+ homedir: "/",
109
+ shell: null
110
+ };
111
+ }
112
+ var os_default = {
113
+ endianness,
114
+ hostname,
115
+ loadavg,
116
+ uptime,
117
+ freemem,
118
+ totalmem,
119
+ cpus,
120
+ type,
121
+ release,
122
+ networkInterfaces,
123
+ arch,
124
+ platform,
125
+ tmpdir,
126
+ homedir,
127
+ EOL,
128
+ availableParallelism,
129
+ version,
130
+ machine,
131
+ devNull,
132
+ constants,
133
+ getPriority,
134
+ setPriority,
135
+ userInfo
136
+ };
137
+
138
+ //#endregion
139
+ export { EOL, arch, availableParallelism, constants, cpus, os_default as default, devNull, endianness, freemem, getPriority, homedir, hostname, loadavg, machine, networkInterfaces, platform, release, setPriority, tmpdir, totalmem, type, uptime, userInfo, version };
140
+ //# sourceMappingURL=os.js.map
package/dist/os.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"os.js","names":[],"sources":["../src/os.ts"],"sourcesContent":["/**\n * `node:os` compatible entry point\n *\n * Based on rollup-plugin-polyfill-node os.js polyfill, enhanced with\n * Node.js APIs that are missing from the original polyfill.\n * Browser-implementable APIs use real browser APIs where possible.\n * Node.js-specific APIs are provided as stubs.\n *\n * @module os\n */\n\n/**\n * Forked from:\n * - rollup-plugin-polyfill-node (https://github.com/nicolo-ribaudo/rollup-plugin-polyfill-node)\n * - node:os (https://github.com/nodejs/node/tree/main/lib/os.js)\n * @author kazuya kawaguchi (a.k.a. kazupon)\n * @license MIT\n */\n\nexport function endianness(): 'BE' | 'LE' {\n const buffer = new ArrayBuffer(2)\n new DataView(buffer).setInt16(0, 256, true)\n return new Int16Array(buffer)[0] === 256 ? 'LE' : 'BE'\n}\n\nexport function hostname(): string {\n if (typeof globalThis.location !== 'undefined') {\n return globalThis.location.hostname\n }\n return ''\n}\n\nexport function loadavg(): [number, number, number] {\n return [0, 0, 0]\n}\n\nexport function uptime(): number {\n return 0\n}\n\nexport function freemem(): number {\n return Number.MAX_VALUE\n}\n\nexport function totalmem(): number {\n return Number.MAX_VALUE\n}\n\nexport function cpus(): object[] {\n return []\n}\n\nexport function type(): string {\n return 'Browser'\n}\n\nexport function release(): string {\n if (typeof navigator !== 'undefined' && navigator.appVersion) {\n return navigator.appVersion\n }\n return ''\n}\n\nexport function networkInterfaces(): Record<string, never> {\n return {}\n}\n\nexport function arch(): string {\n return 'javascript'\n}\n\nexport function platform(): string {\n return 'browser'\n}\n\nexport function tmpdir(): string {\n return '/tmp'\n}\n\nexport function homedir(): string {\n return '/'\n}\n\nexport const EOL = '\\n'\n\nexport function availableParallelism(): number {\n if (typeof navigator !== 'undefined' && navigator.hardwareConcurrency) {\n return navigator.hardwareConcurrency\n }\n return 1\n}\n\nexport function version(): string {\n if (typeof navigator !== 'undefined' && navigator.appVersion) {\n return navigator.appVersion\n }\n return ''\n}\n\nexport function machine(): string {\n if (typeof navigator !== 'undefined' && navigator.platform) {\n return navigator.platform\n }\n return 'unknown'\n}\n\nexport const devNull = '/dev/null'\n\nexport const constants = Object.freeze({\n signals: Object.freeze({}),\n errno: Object.freeze({})\n})\n\n/**\n * Stub for `getPriority`.\n * Process priority is not available in browsers.\n */\nexport function getPriority(_pid?: number): number {\n return 0\n}\n\n/**\n * Stub for `setPriority`.\n * Process priority is not available in browsers.\n */\nexport function setPriority(_pidOrPriority?: number, _priority?: number): void {\n // no-op\n}\n\ninterface UserInfo {\n uid: number\n gid: number\n username: string\n homedir: string\n shell: string | null\n}\n\n/**\n * Stub for `userInfo`.\n * User information is not available in browsers.\n */\nexport function userInfo(_options?: { encoding?: string }): UserInfo {\n return {\n uid: -1,\n gid: -1,\n username: '',\n homedir: '/',\n shell: null\n }\n}\n\nexport default {\n endianness,\n hostname,\n loadavg,\n uptime,\n freemem,\n totalmem,\n cpus,\n type,\n release,\n networkInterfaces,\n arch,\n platform,\n tmpdir,\n homedir,\n EOL,\n availableParallelism,\n version,\n machine,\n devNull,\n constants,\n getPriority,\n setPriority,\n userInfo\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAmBA,SAAgB,aAA0B;CACxC,MAAM,yBAAS,IAAI,YAAY,EAAE;AACjC,KAAI,SAAS,OAAO,CAAC,SAAS,GAAG,KAAK,KAAK;AAC3C,QAAO,IAAI,WAAW,OAAO,CAAC,OAAO,MAAM,OAAO;;AAGpD,SAAgB,WAAmB;AACjC,KAAI,OAAO,WAAW,aAAa,YACjC,QAAO,WAAW,SAAS;AAE7B,QAAO;;AAGT,SAAgB,UAAoC;AAClD,QAAO;EAAC;EAAG;EAAG;EAAE;;AAGlB,SAAgB,SAAiB;AAC/B,QAAO;;AAGT,SAAgB,UAAkB;AAChC,QAAO,OAAO;;AAGhB,SAAgB,WAAmB;AACjC,QAAO,OAAO;;AAGhB,SAAgB,OAAiB;AAC/B,QAAO,EAAE;;AAGX,SAAgB,OAAe;AAC7B,QAAO;;AAGT,SAAgB,UAAkB;AAChC,KAAI,OAAO,cAAc,eAAe,UAAU,WAChD,QAAO,UAAU;AAEnB,QAAO;;AAGT,SAAgB,oBAA2C;AACzD,QAAO,EAAE;;AAGX,SAAgB,OAAe;AAC7B,QAAO;;AAGT,SAAgB,WAAmB;AACjC,QAAO;;AAGT,SAAgB,SAAiB;AAC/B,QAAO;;AAGT,SAAgB,UAAkB;AAChC,QAAO;;AAGT,MAAa,MAAM;AAEnB,SAAgB,uBAA+B;AAC7C,KAAI,OAAO,cAAc,eAAe,UAAU,oBAChD,QAAO,UAAU;AAEnB,QAAO;;AAGT,SAAgB,UAAkB;AAChC,KAAI,OAAO,cAAc,eAAe,UAAU,WAChD,QAAO,UAAU;AAEnB,QAAO;;AAGT,SAAgB,UAAkB;AAChC,KAAI,OAAO,cAAc,eAAe,UAAU,SAChD,QAAO,UAAU;AAEnB,QAAO;;AAGT,MAAa,UAAU;AAEvB,MAAa,YAAY,OAAO,OAAO;CACrC,SAAS,OAAO,OAAO,EAAE,CAAC;CAC1B,OAAO,OAAO,OAAO,EAAE,CAAC;CACzB,CAAC;;;;;AAMF,SAAgB,YAAY,MAAuB;AACjD,QAAO;;;;;;AAOT,SAAgB,YAAY,gBAAyB,WAA0B;;;;;AAgB/E,SAAgB,SAAS,UAA4C;AACnE,QAAO;EACL,KAAK;EACL,KAAK;EACL,UAAU;EACV,SAAS;EACT,OAAO;EACR;;AAGH,iBAAe;CACb;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD"}
@@ -0,0 +1,124 @@
1
+ //#region src/perf_hooks.d.ts
2
+ /**
3
+ * `node:perf_hooks` compatible entry point
4
+ *
5
+ * Browser-native Performance APIs are re-exported directly.
6
+ * Node.js-specific APIs (monitorEventLoopDelay, createHistogram,
7
+ * eventLoopUtilization, timerify) are provided as noop stubs.
8
+ *
9
+ * @module perf_hooks
10
+ */
11
+ /**
12
+ * @author kazuya kawaguchi (a.k.a. kazupon)
13
+ * @license MIT
14
+ */
15
+ declare const performance: Performance;
16
+ declare const PerformanceEntry: {
17
+ new (): PerformanceEntry;
18
+ prototype: PerformanceEntry;
19
+ };
20
+ declare const PerformanceMark: {
21
+ new (markName: string, markOptions?: PerformanceMarkOptions): PerformanceMark;
22
+ prototype: PerformanceMark;
23
+ };
24
+ declare const PerformanceMeasure: {
25
+ new (): PerformanceMeasure;
26
+ prototype: PerformanceMeasure;
27
+ };
28
+ declare const PerformanceObserver: {
29
+ new (callback: PerformanceObserverCallback): PerformanceObserver;
30
+ prototype: PerformanceObserver;
31
+ readonly supportedEntryTypes: ReadonlyArray<string>;
32
+ };
33
+ declare const PerformanceObserverEntryList: {
34
+ new (): PerformanceObserverEntryList;
35
+ prototype: PerformanceObserverEntryList;
36
+ };
37
+ declare const PerformanceResourceTiming: {
38
+ new (): PerformanceResourceTiming;
39
+ prototype: PerformanceResourceTiming;
40
+ };
41
+ interface Histogram {
42
+ enable(): void;
43
+ disable(): void;
44
+ reset(): void;
45
+ record(val: number): void;
46
+ recordDelta(): void;
47
+ readonly min: number;
48
+ readonly max: number;
49
+ readonly mean: number;
50
+ readonly exceeds: number;
51
+ readonly stddev: number;
52
+ percentile(pct: number): number;
53
+ readonly percentiles: Map<number, number>;
54
+ }
55
+ /**
56
+ * Stub for `monitorEventLoopDelay`.
57
+ * Returns a no-op histogram object with `enable()`, `disable()`, etc.
58
+ */
59
+ declare function monitorEventLoopDelay(_options?: {
60
+ resolution?: number;
61
+ }): Histogram;
62
+ /**
63
+ * Stub for `createHistogram`.
64
+ * Returns a no-op histogram object.
65
+ */
66
+ declare function createHistogram(_options?: {
67
+ lowest?: number;
68
+ highest?: number;
69
+ figures?: number;
70
+ }): Histogram;
71
+ /**
72
+ * Stub for `eventLoopUtilization`.
73
+ * Returns zeroed utilization metrics.
74
+ */
75
+ declare function eventLoopUtilization(): {
76
+ idle: number;
77
+ active: number;
78
+ utilization: number;
79
+ };
80
+ /**
81
+ * Stub for `timerify`.
82
+ * Returns the function as-is without wrapping.
83
+ */
84
+ declare function timerify<T extends Function>(fn: T): T;
85
+ /**
86
+ * Stub for perf_hooks constants.
87
+ */
88
+ declare const constants: Readonly<{}>;
89
+ declare const _default: {
90
+ performance: Performance;
91
+ PerformanceEntry: {
92
+ new (): PerformanceEntry;
93
+ prototype: PerformanceEntry;
94
+ };
95
+ PerformanceMark: {
96
+ new (markName: string, markOptions?: PerformanceMarkOptions): PerformanceMark;
97
+ prototype: PerformanceMark;
98
+ };
99
+ PerformanceMeasure: {
100
+ new (): PerformanceMeasure;
101
+ prototype: PerformanceMeasure;
102
+ };
103
+ PerformanceObserver: {
104
+ new (callback: PerformanceObserverCallback): PerformanceObserver;
105
+ prototype: PerformanceObserver;
106
+ readonly supportedEntryTypes: ReadonlyArray<string>;
107
+ };
108
+ PerformanceObserverEntryList: {
109
+ new (): PerformanceObserverEntryList;
110
+ prototype: PerformanceObserverEntryList;
111
+ };
112
+ PerformanceResourceTiming: {
113
+ new (): PerformanceResourceTiming;
114
+ prototype: PerformanceResourceTiming;
115
+ };
116
+ monitorEventLoopDelay: typeof monitorEventLoopDelay;
117
+ createHistogram: typeof createHistogram;
118
+ eventLoopUtilization: typeof eventLoopUtilization;
119
+ timerify: typeof timerify;
120
+ constants: Readonly<{}>;
121
+ };
122
+ //#endregion
123
+ export { PerformanceEntry, PerformanceMark, PerformanceMeasure, PerformanceObserver, PerformanceObserverEntryList, PerformanceResourceTiming, constants, createHistogram, _default as default, eventLoopUtilization, monitorEventLoopDelay, performance, timerify };
124
+ //# sourceMappingURL=perf_hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"perf_hooks.d.ts","names":[],"sources":["../src/perf_hooks.ts"],"sourcesContent":[],"mappings":";;;;;;AAeA;AAEA;AACA;;;;;AACA;AACa,cALA,WAKoD,EALzC,WAKyC;cAHpD;UAA8C;aAAA;;cAC9C;EAGA,KAAA,QAAA,EAAA,MAAA,EAAA,WAAsE,CAAA,wBAAA,CAAA,iBAAA;EACtE,SAAA,iBAAA;AAAgE,CAAA;AAoD7D,cAvDH,kBAuDwB,EAAsC;EAQ3D,MAAA,EA/D+C,kBA+DhC;EAYf,SAAA,EA3E+C,kBA2E3B;AAYpC,CAAA;AAAmC,cAtFtB,mBAsFsB,EAAA;EAAc,KAAA,QAAA,6BAAA,CAAA,qBAAA;EAAI,SAAA,qBAAA;EAAC,SAAA,mBAAA,eAAA,CAAA,MAAA,CAAA;AAOtD,CAAA;AAA0C,cA5F7B,4BA4F6B,EAAA;UA5FyC;aAAA;;cACtE;UAAgE;aAAA;;UAEnE,SAAA;;;;;;;;;;;;wBAYc;;;;;;iBAsCR,qBAAA;;IAA2D;;;;;iBAQ3D,eAAA;;;;IAIZ;;;;;iBAQY,oBAAA,CAAA;;;;;;;;;iBAYA,mBAAmB,cAAc,IAAI;;;;cAOxC,WAAS;cAAoB"}
@@ -0,0 +1,105 @@
1
+ //#region src/perf_hooks.ts
2
+ /**
3
+ * `node:perf_hooks` compatible entry point
4
+ *
5
+ * Browser-native Performance APIs are re-exported directly.
6
+ * Node.js-specific APIs (monitorEventLoopDelay, createHistogram,
7
+ * eventLoopUtilization, timerify) are provided as noop stubs.
8
+ *
9
+ * @module perf_hooks
10
+ */
11
+ /**
12
+ * @author kazuya kawaguchi (a.k.a. kazupon)
13
+ * @license MIT
14
+ */
15
+ const performance = globalThis.performance;
16
+ const PerformanceEntry = globalThis.PerformanceEntry;
17
+ const PerformanceMark = globalThis.PerformanceMark;
18
+ const PerformanceMeasure = globalThis.PerformanceMeasure;
19
+ const PerformanceObserver = globalThis.PerformanceObserver;
20
+ const PerformanceObserverEntryList = globalThis.PerformanceObserverEntryList;
21
+ const PerformanceResourceTiming = globalThis.PerformanceResourceTiming;
22
+ function createNoopHistogram() {
23
+ return {
24
+ enable() {},
25
+ disable() {},
26
+ reset() {},
27
+ record(_val) {},
28
+ recordDelta() {},
29
+ get min() {
30
+ return 0;
31
+ },
32
+ get max() {
33
+ return 0;
34
+ },
35
+ get mean() {
36
+ return 0;
37
+ },
38
+ get exceeds() {
39
+ return 0;
40
+ },
41
+ get stddev() {
42
+ return 0;
43
+ },
44
+ percentile(_pct) {
45
+ return 0;
46
+ },
47
+ get percentiles() {
48
+ return /* @__PURE__ */ new Map();
49
+ }
50
+ };
51
+ }
52
+ /**
53
+ * Stub for `monitorEventLoopDelay`.
54
+ * Returns a no-op histogram object with `enable()`, `disable()`, etc.
55
+ */
56
+ function monitorEventLoopDelay(_options) {
57
+ return createNoopHistogram();
58
+ }
59
+ /**
60
+ * Stub for `createHistogram`.
61
+ * Returns a no-op histogram object.
62
+ */
63
+ function createHistogram(_options) {
64
+ return createNoopHistogram();
65
+ }
66
+ /**
67
+ * Stub for `eventLoopUtilization`.
68
+ * Returns zeroed utilization metrics.
69
+ */
70
+ function eventLoopUtilization() {
71
+ return {
72
+ idle: 0,
73
+ active: 0,
74
+ utilization: 0
75
+ };
76
+ }
77
+ /**
78
+ * Stub for `timerify`.
79
+ * Returns the function as-is without wrapping.
80
+ */
81
+ function timerify(fn) {
82
+ return fn;
83
+ }
84
+ /**
85
+ * Stub for perf_hooks constants.
86
+ */
87
+ const constants = Object.freeze({});
88
+ var perf_hooks_default = {
89
+ performance,
90
+ PerformanceEntry,
91
+ PerformanceMark,
92
+ PerformanceMeasure,
93
+ PerformanceObserver,
94
+ PerformanceObserverEntryList,
95
+ PerformanceResourceTiming,
96
+ monitorEventLoopDelay,
97
+ createHistogram,
98
+ eventLoopUtilization,
99
+ timerify,
100
+ constants
101
+ };
102
+
103
+ //#endregion
104
+ export { PerformanceEntry, PerformanceMark, PerformanceMeasure, PerformanceObserver, PerformanceObserverEntryList, PerformanceResourceTiming, constants, createHistogram, perf_hooks_default as default, eventLoopUtilization, monitorEventLoopDelay, performance, timerify };
105
+ //# sourceMappingURL=perf_hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"perf_hooks.js","names":[],"sources":["../src/perf_hooks.ts"],"sourcesContent":["/**\n * `node:perf_hooks` compatible entry point\n *\n * Browser-native Performance APIs are re-exported directly.\n * Node.js-specific APIs (monitorEventLoopDelay, createHistogram,\n * eventLoopUtilization, timerify) are provided as noop stubs.\n *\n * @module perf_hooks\n */\n\n/**\n * @author kazuya kawaguchi (a.k.a. kazupon)\n * @license MIT\n */\n\nexport const performance = globalThis.performance\n\nexport const PerformanceEntry = globalThis.PerformanceEntry\nexport const PerformanceMark = globalThis.PerformanceMark\nexport const PerformanceMeasure = globalThis.PerformanceMeasure\nexport const PerformanceObserver = globalThis.PerformanceObserver\nexport const PerformanceObserverEntryList = globalThis.PerformanceObserverEntryList\nexport const PerformanceResourceTiming = globalThis.PerformanceResourceTiming\n\ninterface Histogram {\n enable(): void\n disable(): void\n reset(): void\n record(val: number): void\n recordDelta(): void\n readonly min: number\n readonly max: number\n readonly mean: number\n readonly exceeds: number\n readonly stddev: number\n percentile(pct: number): number\n readonly percentiles: Map<number, number>\n}\n\nfunction createNoopHistogram(): Histogram {\n return {\n enable() {},\n disable() {},\n reset() {},\n record(_val: number) {},\n recordDelta() {},\n get min() {\n return 0\n },\n get max() {\n return 0\n },\n get mean() {\n return 0\n },\n get exceeds() {\n return 0\n },\n get stddev() {\n return 0\n },\n percentile(_pct: number) {\n return 0\n },\n get percentiles() {\n return new Map<number, number>()\n }\n }\n}\n\n/**\n * Stub for `monitorEventLoopDelay`.\n * Returns a no-op histogram object with `enable()`, `disable()`, etc.\n */\nexport function monitorEventLoopDelay(_options?: { resolution?: number }): Histogram {\n return createNoopHistogram()\n}\n\n/**\n * Stub for `createHistogram`.\n * Returns a no-op histogram object.\n */\nexport function createHistogram(_options?: {\n lowest?: number\n highest?: number\n figures?: number\n}): Histogram {\n return createNoopHistogram()\n}\n\n/**\n * Stub for `eventLoopUtilization`.\n * Returns zeroed utilization metrics.\n */\nexport function eventLoopUtilization(): {\n idle: number\n active: number\n utilization: number\n} {\n return { idle: 0, active: 0, utilization: 0 }\n}\n\n/**\n * Stub for `timerify`.\n * Returns the function as-is without wrapping.\n */\nexport function timerify<T extends Function>(fn: T): T {\n return fn\n}\n\n/**\n * Stub for perf_hooks constants.\n */\nexport const constants = Object.freeze({})\n\nexport default {\n performance,\n PerformanceEntry,\n PerformanceMark,\n PerformanceMeasure,\n PerformanceObserver,\n PerformanceObserverEntryList,\n PerformanceResourceTiming,\n monitorEventLoopDelay,\n createHistogram,\n eventLoopUtilization,\n timerify,\n constants\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,MAAa,cAAc,WAAW;AAEtC,MAAa,mBAAmB,WAAW;AAC3C,MAAa,kBAAkB,WAAW;AAC1C,MAAa,qBAAqB,WAAW;AAC7C,MAAa,sBAAsB,WAAW;AAC9C,MAAa,+BAA+B,WAAW;AACvD,MAAa,4BAA4B,WAAW;AAiBpD,SAAS,sBAAiC;AACxC,QAAO;EACL,SAAS;EACT,UAAU;EACV,QAAQ;EACR,OAAO,MAAc;EACrB,cAAc;EACd,IAAI,MAAM;AACR,UAAO;;EAET,IAAI,MAAM;AACR,UAAO;;EAET,IAAI,OAAO;AACT,UAAO;;EAET,IAAI,UAAU;AACZ,UAAO;;EAET,IAAI,SAAS;AACX,UAAO;;EAET,WAAW,MAAc;AACvB,UAAO;;EAET,IAAI,cAAc;AAChB,0BAAO,IAAI,KAAqB;;EAEnC;;;;;;AAOH,SAAgB,sBAAsB,UAA+C;AACnF,QAAO,qBAAqB;;;;;;AAO9B,SAAgB,gBAAgB,UAIlB;AACZ,QAAO,qBAAqB;;;;;;AAO9B,SAAgB,uBAId;AACA,QAAO;EAAE,MAAM;EAAG,QAAQ;EAAG,aAAa;EAAG;;;;;;AAO/C,SAAgB,SAA6B,IAAU;AACrD,QAAO;;;;;AAMT,MAAa,YAAY,OAAO,OAAO,EAAE,CAAC;AAE1C,yBAAe;CACb;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD"}