diff --git a/package-lock.json b/package-lock.json index ba96cba..0a6f0a1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "azion", - "version": "1.9.0", + "version": "1.13.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "azion", - "version": "1.9.0", + "version": "1.13.1", "hasInstallScript": true, "license": "MIT", "workspaces": [ @@ -2262,6 +2262,10 @@ "resolved": "packages/storage", "link": true }, + "node_modules/@lib/unenv-preset": { + "resolved": "packages/unenv-preset", + "link": true + }, "node_modules/@lib/utils": { "resolved": "packages/utils", "link": true @@ -3276,215 +3280,6 @@ "@sinonjs/commons": "^3.0.0" } }, - "node_modules/@swc/core": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.7.0.tgz", - "integrity": "sha512-d4vMzH6ICllDwlPuhset2h8gu/USHdbyfJim+2hQEdxC0UONtfpmu38XBgNqRjStrji1Q5M10jfeUZL3cu1i8g==", - "dev": true, - "hasInstallScript": true, - "peer": true, - "dependencies": { - "@swc/counter": "^0.1.3", - "@swc/types": "^0.1.9" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/swc" - }, - "optionalDependencies": { - "@swc/core-darwin-arm64": "1.7.0", - "@swc/core-darwin-x64": "1.7.0", - "@swc/core-linux-arm-gnueabihf": "1.7.0", - "@swc/core-linux-arm64-gnu": "1.7.0", - "@swc/core-linux-arm64-musl": "1.7.0", - "@swc/core-linux-x64-gnu": "1.7.0", - "@swc/core-linux-x64-musl": "1.7.0", - "@swc/core-win32-arm64-msvc": "1.7.0", - "@swc/core-win32-ia32-msvc": "1.7.0", - "@swc/core-win32-x64-msvc": "1.7.0" - }, - "peerDependencies": { - "@swc/helpers": "*" - }, - "peerDependenciesMeta": { - "@swc/helpers": { - "optional": true - } - } - }, - "node_modules/@swc/core-darwin-arm64": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.7.0.tgz", - "integrity": "sha512-2ylhM7f0HwUwLrFYZAe/dse8PCbPsYcJS3Dt7Q8NT3PUn7vy6QOMxNcOPPuDrnmaXqQQO3oxdmRapguTxaat9g==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ], - "peer": true, - "engines": { - "node": ">=10" - } - }, - "node_modules/@swc/core-darwin-x64": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.7.0.tgz", - "integrity": "sha512-SgVnN4gT1Rb9YfTkp4FCUITqSs7Yj0uB2SUciu5CV3HuGvS5YXCUzh+KrwpLFtx8NIgivISKcNnb41mJi98X8Q==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ], - "peer": true, - "engines": { - "node": ">=10" - } - }, - "node_modules/@swc/core-linux-arm-gnueabihf": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.7.0.tgz", - "integrity": "sha512-+Z9Dayart1iKJQEJJ9N/KS4z5EdXJE3WPFikY0jonKTo4Dd8RuyVz5yLvqcIMeVdz/SwximATaL6iJXw7hZS9A==", - "cpu": [ - "arm" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "engines": { - "node": ">=10" - } - }, - "node_modules/@swc/core-linux-arm64-gnu": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.7.0.tgz", - "integrity": "sha512-UnLrCiZ1EI4shznJn0xP6DLgsXUSwtfsdgHhGYCrvbgVBBve3S9iFgVFEB3SPl7Q/TdowNbrN4zHU0oChfiNfw==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "engines": { - "node": ">=10" - } - }, - "node_modules/@swc/core-linux-arm64-musl": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.7.0.tgz", - "integrity": "sha512-H724UANA+ptsfwKRr9mnaDa9cb5fw0oFysiGKTgb3DMYcgk3Od0jMTnXVPFSVpo7FlmyxeC9K8ueUPBOoOK6XA==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "engines": { - "node": ">=10" - } - }, - "node_modules/@swc/core-linux-x64-gnu": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.7.0.tgz", - "integrity": "sha512-SY3HA0K0Dpqt1HIfMLGpwL4hd4UaL2xHP5oZXPlRQPhUDZrbb4PbI3ZJnh66c63eL4ZR8EJ+HRFI0Alx5p69Zw==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "engines": { - "node": ">=10" - } - }, - "node_modules/@swc/core-linux-x64-musl": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.7.0.tgz", - "integrity": "sha512-cEJ2ebtV1v/5Ilb55E05J6F5SrHKQWzUttIhR5Mkayyo+yvPslcpByuFC3D+J7X1ebziTOBpWuMpUdjLfh3SMQ==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "peer": true, - "engines": { - "node": ">=10" - } - }, - "node_modules/@swc/core-win32-arm64-msvc": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.7.0.tgz", - "integrity": "sha512-ecQOOmzEssz+m0pR4xDYCGuvn3E/l0nQ3tk5jp1NA1lsAy4bMV0YbYCHjptYvWL/UjhIerIp3IlCJ8x5DodSog==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ], - "peer": true, - "engines": { - "node": ">=10" - } - }, - "node_modules/@swc/core-win32-ia32-msvc": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.7.0.tgz", - "integrity": "sha512-gz81seZkRn3zMnVOc7L5k6F4vQC82gIxmHiL+GedK+A37XI/X26AASU3zxvORnqQbwQYXQ+AEVckxBmFlz3v2g==", - "cpu": [ - "ia32" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ], - "peer": true, - "engines": { - "node": ">=10" - } - }, - "node_modules/@swc/core-win32-x64-msvc": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.7.0.tgz", - "integrity": "sha512-b5Fd1xEOw9uqBpj2lqsaR4Iq9UhiL84hNDcEsi6DQA7Y1l85waQAslTbS0E4/pJ1PISAs0jW0zIGLco1eaWBOg==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ], - "peer": true, - "engines": { - "node": ">=10" - } - }, "node_modules/@swc/counter": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/@swc/counter/-/counter-0.1.3.tgz", @@ -3508,16 +3303,6 @@ "@swc/core": "*" } }, - "node_modules/@swc/types": { - "version": "0.1.9", - "resolved": "https://registry.npmjs.org/@swc/types/-/types-0.1.9.tgz", - "integrity": "sha512-qKnCno++jzcJ4lM4NTfYifm1EFSCeIfKiAHAfkENZAV5Kl9PjJIyd2yeeVv6c/2CckuLyv2NmRC5pv6pm2WQBg==", - "dev": true, - "peer": true, - "dependencies": { - "@swc/counter": "^0.1.3" - } - }, "node_modules/@tsconfig/node10": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz", @@ -4138,6 +3923,21 @@ "node": ">=0.10.0" } }, + "node_modules/asn1.js": { + "version": "4.10.1", + "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.10.1.tgz", + "integrity": "sha512-p32cOF5q0Zqs9uBiONKYLm6BClCoBCM5O9JfeUSlnQLBTxYdTK+pW+nXflm8UkKd2UYlEbYz5qEi0JuZR9ckSw==", + "dependencies": { + "bn.js": "^4.0.0", + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0" + } + }, + "node_modules/asn1.js/node_modules/bn.js": { + "version": "4.12.1", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.1.tgz", + "integrity": "sha512-k8TVBiPkPJT9uHLdOKfFpqcfprwBFOAAXXozRubr7R7PfIuKvQlzcI4M0pALeqXN09vdaMbUdUj+pass+uULAg==" + }, "node_modules/asn1js": { "version": "3.0.5", "resolved": "https://registry.npmjs.org/asn1js/-/asn1js-3.0.5.tgz", @@ -4323,6 +4123,11 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/bn.js": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", + "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==" + }, "node_modules/bottleneck": { "version": "2.19.5", "resolved": "https://registry.npmjs.org/bottleneck/-/bottleneck-2.19.5.tgz", @@ -4351,6 +4156,116 @@ "node": ">=8" } }, + "node_modules/brorand": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", + "integrity": "sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w==" + }, + "node_modules/browserify-aes": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", + "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", + "dependencies": { + "buffer-xor": "^1.0.3", + "cipher-base": "^1.0.0", + "create-hash": "^1.1.0", + "evp_bytestokey": "^1.0.3", + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/browserify-cipher": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/browserify-cipher/-/browserify-cipher-1.0.1.tgz", + "integrity": "sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w==", + "dependencies": { + "browserify-aes": "^1.0.4", + "browserify-des": "^1.0.0", + "evp_bytestokey": "^1.0.0" + } + }, + "node_modules/browserify-des": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.2.tgz", + "integrity": "sha512-BioO1xf3hFwz4kc6iBhI3ieDFompMhrMlnDFC4/0/vd5MokpuAc3R+LYbwTA9A5Yc9pq9UYPqffKpW2ObuwX5A==", + "dependencies": { + "cipher-base": "^1.0.1", + "des.js": "^1.0.0", + "inherits": "^2.0.1", + "safe-buffer": "^5.1.2" + } + }, + "node_modules/browserify-rsa": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.1.1.tgz", + "integrity": "sha512-YBjSAiTqM04ZVei6sXighu679a3SqWORA3qZTEqZImnlkDIFtKc6pNutpjyZ8RJTjQtuYfeetkxM11GwoYXMIQ==", + "dependencies": { + "bn.js": "^5.2.1", + "randombytes": "^2.1.0", + "safe-buffer": "^5.2.1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/browserify-rsa/node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/browserify-sign": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/browserify-sign/-/browserify-sign-4.2.3.tgz", + "integrity": "sha512-JWCZW6SKhfhjJxO8Tyiiy+XYB7cqd2S5/+WeYHsKdNKFlCBhKbblba1A/HN/90YwtxKc8tCErjffZl++UNmGiw==", + "dependencies": { + "bn.js": "^5.2.1", + "browserify-rsa": "^4.1.0", + "create-hash": "^1.2.0", + "create-hmac": "^1.1.7", + "elliptic": "^6.5.5", + "hash-base": "~3.0", + "inherits": "^2.0.4", + "parse-asn1": "^5.1.7", + "readable-stream": "^2.3.8", + "safe-buffer": "^5.2.1" + }, + "engines": { + "node": ">= 0.12" + } + }, + "node_modules/browserify-sign/node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, "node_modules/browserslist": { "version": "4.23.2", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.23.2.tgz", @@ -4410,6 +4325,11 @@ "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", "dev": true }, + "node_modules/buffer-xor": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz", + "integrity": "sha512-571s0T7nZWK6vB67HI5dyUF7wXiNcfaPPPTl6zYCNApANjIvYJTg7hlud/+cJpdAhS7dVzqMLmfhfHR3rAcOjQ==" + }, "node_modules/bundle-require": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/bundle-require/-/bundle-require-5.0.0.tgz", @@ -4573,6 +4493,37 @@ "node": ">=8" } }, + "node_modules/cipher-base": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.6.tgz", + "integrity": "sha512-3Ek9H3X6pj5TgenXYtNWdaBon1tgYCaebd+XPg0keyjEbEfkD4KkmAxkQ/i1vYvxdcT5nscLBfq9VJRmCBcFSw==", + "dependencies": { + "inherits": "^2.0.4", + "safe-buffer": "^5.2.1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/cipher-base/node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, "node_modules/cjs-module-lexer": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-1.3.1.tgz", @@ -4806,8 +4757,7 @@ "node_modules/core-util-is": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", - "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", - "dev": true + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" }, "node_modules/cosmiconfig": { "version": "8.3.6", @@ -4852,6 +4802,45 @@ "typescript": ">=4" } }, + "node_modules/create-ecdh": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.4.tgz", + "integrity": "sha512-mf+TCx8wWc9VpuxfP2ht0iSISLZnt0JgWlrOKZiNqyUZWnjIaCIVNQArMHnCZKfEYRg6IM7A+NeJoN8gf/Ws0A==", + "dependencies": { + "bn.js": "^4.1.0", + "elliptic": "^6.5.3" + } + }, + "node_modules/create-ecdh/node_modules/bn.js": { + "version": "4.12.1", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.1.tgz", + "integrity": "sha512-k8TVBiPkPJT9uHLdOKfFpqcfprwBFOAAXXozRubr7R7PfIuKvQlzcI4M0pALeqXN09vdaMbUdUj+pass+uULAg==" + }, + "node_modules/create-hash": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", + "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==", + "dependencies": { + "cipher-base": "^1.0.1", + "inherits": "^2.0.1", + "md5.js": "^1.3.4", + "ripemd160": "^2.0.1", + "sha.js": "^2.4.0" + } + }, + "node_modules/create-hmac": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", + "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", + "dependencies": { + "cipher-base": "^1.0.3", + "create-hash": "^1.1.0", + "inherits": "^2.0.1", + "ripemd160": "^2.0.0", + "safe-buffer": "^5.0.1", + "sha.js": "^2.4.8" + } + }, "node_modules/create-jest": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/create-jest/-/create-jest-29.7.0.tgz", @@ -4909,6 +4898,31 @@ "node": ">= 8" } }, + "node_modules/crypto-browserify": { + "version": "3.12.1", + "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.1.tgz", + "integrity": "sha512-r4ESw/IlusD17lgQi1O20Fa3qNnsckR126TdUuBgAu7GBYSIPvdNyONd3Zrxh0xCwA4+6w/TDArBPsMvhur+KQ==", + "dependencies": { + "browserify-cipher": "^1.0.1", + "browserify-sign": "^4.2.3", + "create-ecdh": "^4.0.4", + "create-hash": "^1.2.0", + "create-hmac": "^1.1.7", + "diffie-hellman": "^5.0.3", + "hash-base": "~3.0.4", + "inherits": "^2.0.4", + "pbkdf2": "^3.1.2", + "public-encrypt": "^4.0.3", + "randombytes": "^2.1.0", + "randomfill": "^1.0.4" + }, + "engines": { + "node": ">= 0.10" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/crypto-random-string": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-4.0.0.tgz", @@ -5054,6 +5068,15 @@ "integrity": "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==", "dev": true }, + "node_modules/des.js": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/des.js/-/des.js-1.1.0.tgz", + "integrity": "sha512-r17GxjhUCjSRy8aiJpr8/UadFIzMzJGexI3Nmz4ADi9LYSFx4gTBp80+NaX/YsXWWLhpZ7v/v/ubEc/bCNfKwg==", + "dependencies": { + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0" + } + }, "node_modules/detect-newline": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-3.1.0.tgz", @@ -5081,6 +5104,21 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, + "node_modules/diffie-hellman": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", + "integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==", + "dependencies": { + "bn.js": "^4.1.0", + "miller-rabin": "^4.0.0", + "randombytes": "^2.0.0" + } + }, + "node_modules/diffie-hellman/node_modules/bn.js": { + "version": "4.12.1", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.1.tgz", + "integrity": "sha512-k8TVBiPkPJT9uHLdOKfFpqcfprwBFOAAXXozRubr7R7PfIuKvQlzcI4M0pALeqXN09vdaMbUdUj+pass+uULAg==" + }, "node_modules/dir-glob": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", @@ -5153,6 +5191,25 @@ "integrity": "sha512-TrPKKH20HeN0J1LHzsYLs2qwXrp8TF4nHdu4sq61ozGbzMpWhI7iIOPYPPkxeq1azMT9PZ8enPFcftbs/Npcjg==", "dev": true }, + "node_modules/elliptic": { + "version": "6.6.1", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.6.1.tgz", + "integrity": "sha512-RaddvvMatK2LJHqFJ+YA4WysVN5Ita9E35botqIYspQ4TkRAlCicdzKOjlyv/1Za5RyTNn7di//eEV0uTAfe3g==", + "dependencies": { + "bn.js": "^4.11.9", + "brorand": "^1.1.0", + "hash.js": "^1.0.0", + "hmac-drbg": "^1.0.1", + "inherits": "^2.0.4", + "minimalistic-assert": "^1.0.1", + "minimalistic-crypto-utils": "^1.0.1" + } + }, + "node_modules/elliptic/node_modules/bn.js": { + "version": "4.12.1", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.1.tgz", + "integrity": "sha512-k8TVBiPkPJT9uHLdOKfFpqcfprwBFOAAXXozRubr7R7PfIuKvQlzcI4M0pALeqXN09vdaMbUdUj+pass+uULAg==" + }, "node_modules/emittery": { "version": "0.13.1", "resolved": "https://registry.npmjs.org/emittery/-/emittery-0.13.1.tgz", @@ -5609,6 +5666,15 @@ "node": ">=0.10.0" } }, + "node_modules/evp_bytestokey": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz", + "integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==", + "dependencies": { + "md5.js": "^1.3.4", + "safe-buffer": "^5.1.1" + } + }, "node_modules/execa": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz", @@ -6217,6 +6283,46 @@ "node": ">=8" } }, + "node_modules/hash-base": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.0.5.tgz", + "integrity": "sha512-vXm0l45VbcHEVlTCzs8M+s0VeYsB2lnlAaThoLKGXr3bE/VWDOelNUnycUPEhKEaXARL2TEFjBOyUiM6+55KBg==", + "dependencies": { + "inherits": "^2.0.4", + "safe-buffer": "^5.2.1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/hash-base/node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/hash.js": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", + "integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==", + "dependencies": { + "inherits": "^2.0.3", + "minimalistic-assert": "^1.0.1" + } + }, "node_modules/hasown": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", @@ -6229,6 +6335,16 @@ "node": ">= 0.4" } }, + "node_modules/hmac-drbg": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", + "integrity": "sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg==", + "dependencies": { + "hash.js": "^1.0.3", + "minimalistic-assert": "^1.0.0", + "minimalistic-crypto-utils": "^1.0.1" + } + }, "node_modules/hook-std": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/hook-std/-/hook-std-3.0.0.tgz", @@ -6406,8 +6522,7 @@ "node_modules/inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, "node_modules/ini": { "version": "1.3.8", @@ -6578,8 +6693,7 @@ "node_modules/isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==", - "dev": true + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==" }, "node_modules/isexe": { "version": "2.0.0", @@ -8071,6 +8185,16 @@ "node": ">= 18" } }, + "node_modules/md5.js": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", + "integrity": "sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==", + "dependencies": { + "hash-base": "^3.0.0", + "inherits": "^2.0.1", + "safe-buffer": "^5.1.2" + } + }, "node_modules/meow": { "version": "8.1.2", "resolved": "https://registry.npmjs.org/meow/-/meow-8.1.2.tgz", @@ -8253,6 +8377,23 @@ "node": ">=8.6" } }, + "node_modules/miller-rabin": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/miller-rabin/-/miller-rabin-4.0.1.tgz", + "integrity": "sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA==", + "dependencies": { + "bn.js": "^4.0.0", + "brorand": "^1.0.1" + }, + "bin": { + "miller-rabin": "bin/miller-rabin" + } + }, + "node_modules/miller-rabin/node_modules/bn.js": { + "version": "4.12.1", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.1.tgz", + "integrity": "sha512-k8TVBiPkPJT9uHLdOKfFpqcfprwBFOAAXXozRubr7R7PfIuKvQlzcI4M0pALeqXN09vdaMbUdUj+pass+uULAg==" + }, "node_modules/mime": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/mime/-/mime-4.0.4.tgz", @@ -8286,6 +8427,16 @@ "node": ">=4" } }, + "node_modules/minimalistic-assert": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", + "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==" + }, + "node_modules/minimalistic-crypto-utils": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", + "integrity": "sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg==" + }, "node_modules/minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", @@ -11891,6 +12042,41 @@ "node": ">=6" } }, + "node_modules/parse-asn1": { + "version": "5.1.7", + "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.7.tgz", + "integrity": "sha512-CTM5kuWR3sx9IFamcl5ErfPl6ea/N8IYwiJ+vpeB2g+1iknv7zBl5uPwbMbRVznRVbrNY6lGuDoE5b30grmbqg==", + "dependencies": { + "asn1.js": "^4.10.1", + "browserify-aes": "^1.2.0", + "evp_bytestokey": "^1.0.3", + "hash-base": "~3.0", + "pbkdf2": "^3.1.2", + "safe-buffer": "^5.2.1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/parse-asn1/node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, "node_modules/parse-json": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", @@ -11973,6 +12159,21 @@ "node": ">=8" } }, + "node_modules/pbkdf2": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.1.2.tgz", + "integrity": "sha512-iuh7L6jA7JEGu2WxDwtQP1ddOpaJNC4KlDEFfdQajSGgGPNi4OyDc2R7QnbY2bR9QjBVGwgvTdNJZoE7RaxUMA==", + "dependencies": { + "create-hash": "^1.1.2", + "create-hmac": "^1.1.4", + "ripemd160": "^2.0.1", + "safe-buffer": "^5.0.1", + "sha.js": "^2.4.8" + }, + "engines": { + "node": ">=0.12" + } + }, "node_modules/picocolors": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.1.tgz", @@ -12248,8 +12449,7 @@ "node_modules/process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", - "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", - "dev": true + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" }, "node_modules/progress": { "version": "2.0.3", @@ -12278,6 +12478,24 @@ "integrity": "sha512-vtK/94akxsTMhe0/cbfpR+syPuszcuwhqVjJq26CuNDgFGj682oRBXOP5MJpv2r7JtE8MsiepGIqvvOTBwn2vA==", "dev": true }, + "node_modules/public-encrypt": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.3.tgz", + "integrity": "sha512-zVpa8oKZSz5bTMTFClc1fQOnyyEzpl5ozpi1B5YcvBrdohMjH2rfsBtyXcuNuwjsDIXmBYlF2N5FlJYhR29t8Q==", + "dependencies": { + "bn.js": "^4.1.0", + "browserify-rsa": "^4.0.0", + "create-hash": "^1.1.0", + "parse-asn1": "^5.0.0", + "randombytes": "^2.0.1", + "safe-buffer": "^5.1.2" + } + }, + "node_modules/public-encrypt/node_modules/bn.js": { + "version": "4.12.1", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.1.tgz", + "integrity": "sha512-k8TVBiPkPJT9uHLdOKfFpqcfprwBFOAAXXozRubr7R7PfIuKvQlzcI4M0pALeqXN09vdaMbUdUj+pass+uULAg==" + }, "node_modules/punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", @@ -12361,6 +12579,23 @@ "node": ">=8" } }, + "node_modules/randombytes": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", + "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", + "dependencies": { + "safe-buffer": "^5.1.0" + } + }, + "node_modules/randomfill": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/randomfill/-/randomfill-1.0.4.tgz", + "integrity": "sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw==", + "dependencies": { + "randombytes": "^2.0.5", + "safe-buffer": "^5.1.0" + } + }, "node_modules/rc": { "version": "1.2.8", "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", @@ -12617,7 +12852,6 @@ "version": "2.3.8", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", - "dev": true, "dependencies": { "core-util-is": "~1.0.0", "inherits": "~2.0.3", @@ -12781,6 +13015,15 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/ripemd160": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz", + "integrity": "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==", + "dependencies": { + "hash-base": "^3.0.0", + "inherits": "^2.0.1" + } + }, "node_modules/rollup": { "version": "4.18.1", "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.18.1.tgz", @@ -12842,8 +13085,7 @@ "node_modules/safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" }, "node_modules/seedrandom": { "version": "3.0.5", @@ -13174,6 +13416,18 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/sha.js": { + "version": "2.4.11", + "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", + "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", + "dependencies": { + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" + }, + "bin": { + "sha.js": "bin.js" + } + }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -13435,7 +13689,6 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, "dependencies": { "safe-buffer": "~5.1.0" } @@ -14263,8 +14516,7 @@ "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", - "dev": true + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" }, "node_modules/v8-compile-cache-lib": { "version": "3.0.1", @@ -14574,6 +14826,12 @@ "typescript": "^5.5.3" } }, + "packages/polyfills": { + "name": "@lib/polyfills", + "version": "1.0.0", + "extraneous": true, + "license": "MIT" + }, "packages/presets": { "name": "@lib/presets", "version": "1.0.0", @@ -14616,6 +14874,14 @@ "version": "1.0.0", "license": "MIT" }, + "packages/unenv-preset": { + "name": "@lib/unenv-preset", + "version": "1.0.0", + "license": "MIT", + "dependencies": { + "crypto-browserify": "^3.12.1" + } + }, "packages/utils": { "name": "@lib/utils", "version": "1.0.0", diff --git a/package.json b/package.json index 2f66596..33da296 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,8 @@ "README.md", "package.json", "packages/**/dist/**/*", - "cli/**/*" + "cli/**/*", + "packages/unenv-preset/src/polyfills/*" ], "exports": { ".": { @@ -87,6 +88,11 @@ "import": "./packages/presets/dist/index.mjs", "types": "./packages/presets/dist/index.d.ts" }, + "./unenv-preset": { + "require": "./packages/unenv-preset/dist/index.js", + "import": "./packages/unenv-preset/dist/index.mjs", + "types": "./packages/unenv-preset/dist/index.d.ts" + }, "./ai": { "require": "./packages/ai/dist/index.js", "import": "./packages/ai/dist/index.mjs", @@ -161,6 +167,9 @@ "presets": [ "./packages/presets/dist/index.d.ts" ], + "unenv-preset": [ + "./packages/unenv-preset/dist/index.d.ts" + ], "application": [ "./packages/application/dist/index.d.ts" ], diff --git a/packages/unenv-preset/.gitignore b/packages/unenv-preset/.gitignore new file mode 100644 index 0000000..76add87 --- /dev/null +++ b/packages/unenv-preset/.gitignore @@ -0,0 +1,2 @@ +node_modules +dist \ No newline at end of file diff --git a/packages/unenv-preset/README.md b/packages/unenv-preset/README.md new file mode 100644 index 0000000..e69de29 diff --git a/packages/unenv-preset/jest.config.js b/packages/unenv-preset/jest.config.js new file mode 100644 index 0000000..9e3e5f1 --- /dev/null +++ b/packages/unenv-preset/jest.config.js @@ -0,0 +1,10 @@ +/** @type {import('ts-jest').JestConfigWithTsJest} */ +module.exports = { + displayName: 'Unenv Preset', + preset: 'ts-jest', + transform: { + '^.+\\.(t|j)s?$': '@swc/jest', + }, + testPathIgnorePatterns: ['/node_modules/', '/dist/'], + testEnvironment: 'node', +}; diff --git a/packages/unenv-preset/package.json b/packages/unenv-preset/package.json new file mode 100644 index 0000000..82bcd85 --- /dev/null +++ b/packages/unenv-preset/package.json @@ -0,0 +1,27 @@ +{ + "name": "@lib/unenv-preset", + "version": "1.0.0", + "description": "Azion Unenv preset.", + "main": "./dist/index.js", + "module": "./dist/index.mjs", + "types": "./dist/index.d.ts", + "scripts": { + "compile": "tsup --config ../../tsup.config.json", + "lint": "eslint .", + "lint:fix": "eslint --fix .", + "prettier": "prettier --write .", + "test": "jest --clearCache && jest -c jest.config.js .", + "test:watch": "jest -c jest.config.js . --watch", + "test:coverage": "jest --clearCache && jest -c jest.config.js . --coverage" + }, + "author": "aziontech", + "license": "MIT", + "files": [ + "dist", + "package.json", + "src/polyfills/*" + ], + "dependencies": { + "crypto-browserify": "^3.12.1" + } +} diff --git a/packages/unenv-preset/src/index.test.ts b/packages/unenv-preset/src/index.test.ts new file mode 100644 index 0000000..e69de29 diff --git a/packages/unenv-preset/src/index.ts b/packages/unenv-preset/src/index.ts new file mode 100644 index 0000000..f54d631 --- /dev/null +++ b/packages/unenv-preset/src/index.ts @@ -0,0 +1,43 @@ +import path from 'path'; +import { fileURLToPath } from 'url'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); + +const getAbsolutePath = () => path.resolve(__dirname, '../', 'src'); + +const nextNodePresetPath = `${getAbsolutePath()}/polyfills/node/frameworks/next`; +const polyfillsPath = `${getAbsolutePath()}/polyfills`; + +export default { + inject: { + __dirname: `${polyfillsPath}/node/globals/path-dirname.js`, + __filename: `${polyfillsPath}/node/globals/path-filename.js`, + process: `${polyfillsPath}/node/globals/process.cjs`, + }, + alias: { + 'azion/utils': 'azion/utils', + '@fastly/http-compute-js': '@fastly/http-compute-js', + 'next/dist/compiled/etag': `${nextNodePresetPath}/custom-server/12.3.x/util/etag.js`, + accepts: 'accepts', + crypto: `${polyfillsPath}/node/crypto.js`, + events: 'events/events.js', + http: 'stream-http', + module: `${polyfillsPath}/node/module.js`, + stream: 'stream-browserify/', + string_decoder: 'string_decoder/lib/string_decoder.js', + url: 'url/url.js', + util: 'util/util.js', + timers: 'timers-browserify/', + inherits: 'inherits/inherits_browser.js', + vm: 'vm-browserify/', + zlib: 'browserify-zlib', + }, + external: ['node:async_hooks', 'node:fs/promises'], + polyfill: [ + 'aziondev:async_hooks:/async-hooks/async-hooks.polyfills.js', + 'aziondev:fs:/fs/fs.polyfills.js', + 'aziondev:fs/promises:/fs/promises/promises.polyfills.js', + `azionprd:fs:/fs.js`, + ], +}; diff --git a/packages/unenv-preset/src/polyfills/node/crypto.js b/packages/unenv-preset/src/polyfills/node/crypto.js new file mode 100644 index 0000000..6a6f509 --- /dev/null +++ b/packages/unenv-preset/src/polyfills/node/crypto.js @@ -0,0 +1,70 @@ +/* eslint-disable */ +import crypto from 'crypto-browserify'; + +crypto.webcrypto = globalThis.crypto; +export default crypto; +export var { Cipher } = crypto; +export var { Cipheriv } = crypto; +export var { Decipher } = crypto; +export var { Decipheriv } = crypto; +export var { DiffieHellman } = crypto; +export var { DiffieHellmanGroup } = crypto; +export var { Hash } = crypto; +export var { Hmac } = crypto; +export var { Sign } = crypto; +export var { Verify } = crypto; +export var { constants } = crypto; +export var { createCipher } = crypto; +export var { createCipheriv } = crypto; +export var { createCredentials } = crypto; +export var { createDecipher } = crypto; +export var { createDecipheriv } = crypto; +export var { createDiffieHellman } = crypto; +export var { createDiffieHellmanGroup } = crypto; +export var { createECDH } = crypto; +export var { createHash } = crypto; +export var { createHmac } = crypto; +export var { createSign } = crypto; +export var { createVerify } = crypto; +export var { getCiphers } = crypto; +export var { getDiffieHellman } = crypto; +export var { getHashes } = crypto; +export var { listCiphers } = crypto; +export var { pbkdf2 } = crypto; +export var { pbkdf2Sync } = crypto; +export var { privateDecrypt } = crypto; +export var { privateEncrypt } = crypto; +export var { prng } = crypto; +export var { pseudoRandomBytes } = crypto; +export var { publicDecrypt } = crypto; +export var { publicEncrypt } = crypto; +export var { randomBytes } = crypto; +export var { randomFill } = crypto; +export var { randomFillSync } = crypto; +export var { rng } = crypto; +export var { webcrypto } = crypto; + +export var getRandomValues = function (abv) { + let l = abv.length; + while (l--) { + const bytes = randomBytes(7); + let randomFloat = (bytes[0] % 32) / 32; + + for (let i = 0; i < bytes.length; i++) { + const byte = bytes[i]; + randomFloat = (randomFloat + byte) / 256; + } + + abv[l] = Math.floor(randomFloat * 256); + } + return abv; +}; + +export var randomUUID = function () { + return '10000000-1000-4000-8000-100000000000'.replace(/[018]/g, function (c) { + return ( + c ^ + (getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4))) + ).toString(16); + }); +}; diff --git a/packages/unenv-preset/src/polyfills/node/frameworks/next/custom-server/12.3.x/util/etag.js b/packages/unenv-preset/src/polyfills/node/frameworks/next/custom-server/12.3.x/util/etag.js new file mode 100644 index 0000000..b719577 --- /dev/null +++ b/packages/unenv-preset/src/polyfills/node/frameworks/next/custom-server/12.3.x/util/etag.js @@ -0,0 +1,33 @@ +/* + * Copyright Azion + * Licensed under the MIT license. See LICENSE file for details. + * + * Portions of this file Copyright Fastly, Inc, licensed under the MIT license. See LICENSE file for details. + */ + +import { Buffer } from 'buffer'; +import crypto from 'crypto'; + +/** + * Generates an etag string based on a payload. + * (An adaptation for Compute@Edge of function in Next.js of the same name, + * found at next/server/api-utils/web.ts) + * @param {string} payload data to generate etag + * @returns {string} the generated etag + */ +export default function generateETag(payload) { + if (payload.length === 0) { + // fast-path empty + return '"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk"'; + } + + // compute hash of entity + // Do this without using crypto.subtle, as the crypto + // polyfill doesn't support it. + const hash = crypto.createHash('sha1').update(payload, 'utf8').digest('base64').substring(0, 27); + + // compute length of entity + const len = Buffer.byteLength(payload); + + return `"${len.toString(16)}-${hash}"`; +} diff --git a/packages/unenv-preset/src/polyfills/node/fs.js b/packages/unenv-preset/src/polyfills/node/fs.js new file mode 100644 index 0000000..fb50809 --- /dev/null +++ b/packages/unenv-preset/src/polyfills/node/fs.js @@ -0,0 +1,524 @@ +/* eslint-disable max-classes-per-file */ +import bPath from 'path'; +import { Buffer } from 'buffer'; + +/* eslint-disable */ + +const MEM_FILES = globalThis.vulcan.__FILES__; + +globalThis.vulcan.FS_PATHS_CHANGED = false; + +/** + * fix mapped files paths based on path prefix + */ +function fixMappedFilesPaths() { + const prefix = globalThis.vulcan.FS_PATH_PREFIX_TO_REMOVE; + if (!globalThis.vulcan.FS_PATHS_CHANGED && prefix !== "") { + Object.keys(MEM_FILES).forEach((e) => { + const newKey = e.replace(prefix, ''); + MEM_FILES[newKey] = MEM_FILES[e]; + delete MEM_FILES[e]; + }); + } + + globalThis.vulcan.FS_PATHS_CHANGED = true; +} + +// ### fs polyfill utils +/** + * Get file object stored in mem + * @returns {any} file object + */ +function getFile(path) { + fixMappedFilesPaths(); + + return MEM_FILES[path]; +} + +/** + * Decode file content to return + * @returns {string|Buffer} the file content + */ +function getFileContent(file, returnBuffer = true) { + const buff = Buffer.from(file.content, 'base64'); + + if (returnBuffer) { + return buff; + } else { + return buff.toString('utf8'); + } +} + +/** + * Get available files in worker memory + * @returns {string[]} list of mapped files paths + */ +function getAvailableFiles() { + if (MEM_FILES && typeof MEM_FILES === 'object') { + return Object.keys(MEM_FILES); + } + + return []; +} + +/** + * Get available dirs based on mapped files + * @param {string[]} - files paths + * @returns {string[]} - list of available dirs + */ +function getAvailableDirs(files) { + if (files.length > 0) { + const existingDirs = new Set(); + + files.forEach((filePath) => { + const dirPath = bPath.dirname(filePath); + + let currentPath = '/'; + let pathSegments = dirPath.split('/'); + for (let i = 0; i < pathSegments.length; i++) { + currentPath = bPath.join(currentPath, pathSegments[i]); + if (!existingDirs.has(currentPath)) { + existingDirs.add(currentPath); + } + } + }); + + const dirs = Array.from(existingDirs); + + return dirs; + } + + return []; +} + +/** + * Get mapped files infos + * @returns {object} - object with files, dirs and paths + */ +function getFilesInfos() { + fixMappedFilesPaths(); + + const files = getAvailableFiles(); + const dirs = getAvailableDirs(files); + + return { + files, + dirs, + paths: [...files, ...dirs], + }; +} + +/** + * Returns a valid path + * @returns {string} - path to fix + */ +function getValidatedPath(path) { + if (path.endsWith('/')) { + path = path.slice(0, -1); + } + + if (!path.startsWith('/')) { + path = bPath.join('/', path); + } + + return path; +} + +function generateDefaultStat() { + const defaultDate = new Date(); + + return { + dev: 16777231, + mode: 33188, + nlink: 1, + uid: 503, + gid: 20, + rdev: 0, + blksize: 4096, + ino: 99415867, + size: 4037, + blocks: 8, + atimeMs: 1696531597782.944, + mtimeMs: 1696531596158.1772, + ctimeMs: 1696531596158.1772, + birthtimeMs: 1695652120928.4453, + atime: defaultDate, + mtime: defaultDate, + ctime: defaultDate, + birthtime: defaultDate, + }; +} + +// ### fs polyfills +// code based on node implementations + +const UV_DIRENT_FILE = 1; +const UV_DIRENT_DIR = 2; +const UV_DIRENT_LINK = 3; +const UV_DIRENT_FIFO = 4; +const UV_DIRENT_SOCKET = 5; +const UV_DIRENT_CHAR = 6; +const UV_DIRENT_BLOCK = 7; + +const kType = Symbol('type'); + +class CustomDirent { + constructor(name, type, path) { + this.name = name; + this.path = path; + this[kType] = type; + } + + isDirectory() { + return this[kType] === UV_DIRENT_DIR; + } + + isFile() { + return this[kType] === UV_DIRENT_FILE; + } + + isBlockDevice() { + return this[kType] === UV_DIRENT_BLOCK; + } + + isCharacterDevice() { + return this[kType] === UV_DIRENT_CHAR; + } + + isSymbolicLink() { + return this[kType] === UV_DIRENT_LINK; + } + + isFIFO() { + return this[kType] === UV_DIRENT_FIFO; + } + + isSocket() { + return this[kType] === UV_DIRENT_SOCKET; + } +} + +const kEmptyObject = { __proto__: null }; + +function defaultCloseCallback(err) { + if (err != null) throw err; +} + +function assertEncoding(encoding) { + if (encoding && !Buffer.isEncoding(encoding)) { + throw new Error('Invalid encoding!'); + } +} + +function getOptions(options, defaultOptions = kEmptyObject) { + if (options == null || typeof options === 'function') { + return defaultOptions; + } + + if (typeof options === 'string') { + defaultOptions = { ...defaultOptions }; + defaultOptions.encoding = options; + options = defaultOptions; + } else if (typeof options !== 'object') { + throw new Error('Invalid options!'); + } + + if (options.encoding !== 'buffer') assertEncoding(options.encoding); + + if (options.signal !== undefined) { + // validateAbortSignal(options.signal, 'options.signal'); + } + + return options; +} + +/** + * Closes the file descriptor. + * @param {number} fd + * @param {function(Error): any} [callback] + * @returns {void} + */ +function close(fd, callback = defaultCloseCallback) { + setTimeout(() => { + // (In-memory implementation doesn't require explicit closing) + callback(null); + }, 0); +} + +/** + * Synchronously closes the file descriptor. + * @param {number} fd + * @returns {void} + */ +function closeSync(fd) { + // (In-memory implementation doesn't require explicit closing) +} + +/** + * Synchronously opens a file. + * @param {string | Buffer | URL} path + * @param {string | number} [flags] + * @param {string | number} [mode] + * @returns {number} + */ +function openSync(path, flags, mode) { + path = getValidatedPath(path); + const file = getFile(path); + if (file !== undefined) { + const fileDescriptor = Symbol(`File Descriptor for ${path}`); + + return fileDescriptor; + } else { + const error = new Error( + `ENOENT: no such file or directory, fs.openSync call for path '${path}'`, + ); + error.code = 'ENOENT'; + + throw error; + } +} + +/** + * Synchronously retrieves the `fs.Stats` + * for the `path`. + * @param {string | Buffer | URL} path + * @param {Object} [options] + * @param {boolean} [options.bigint] + * @param {boolean} [options.throwIfNoEntry] + * @returns {any} + */ +function statSync(path, options = {}) { + // checks final + path = getValidatedPath(path); + + // Synchronous method to get file information + const filesInfos = getFilesInfos(); + if (!filesInfos.paths.includes(path)) { + const error = new Error( + `ENOENT: no such file or directory, fs.statSync call for path '${path}'`, + ); + error.code = 'ENOENT'; + throw error; + } + + const file = getFile(path); + + const isFile = filesInfos.files.includes(path); + const size = isFile ? file.content.length : 0; + + // generate file informations + const stats = generateDefaultStat(); + stats.size = size; + stats.isFile = () => isFile; + stats.isDirectory = () => !isFile; + + return stats; +} + +/** + * Synchronously reads the entire contents of a file. + * @param {string | Buffer | URL | number} path + * @param {Object | string} [options] - Options object or encoding string. + * @param {string} [options.encoding] - The file encoding. + * @param {string} [options.flag] - The flag. + * @returns {string | Buffer} + */ +function readFileSync(path, options = {}) { + path = getValidatedPath(path); + options = getOptions(options, { flag: 'r' }); + + const file = getFile(path); + if (file !== undefined) { + let content; + if (options?.encoding === 'utf-8') { + content = getFileContent(file, false); + } else { + content = getFileContent(file, true); + } + return content; + } else { + const error = new Error( + `ENOENT: no such file or directory, fs.readFileSync call for path '${path}'`, + ); + error.code = 'ENOENT'; + throw error; + } +} + +/** + * Synchronously reads the contents of a directory. + * @param {string | Object} [options] - Options object or encoding string. + * @param {string} [options.encoding] - The encoding. + * @param {boolean} [options.withFileTypes] - Whether to include file types. + * @param {boolean} [options.recursive] - Whether to include subdirectories. + */ +function readdirSync(path, options = {}) { + path = getValidatedPath(path); + + const filesInfos = getFilesInfos(); + const stats = statSync(path); + + if (!stats.isDirectory()) { + const error = new Error( + `ENOTDIR: not a directory, scandir - fs.readdirSync call for path '${path}'`, + ); + error.code = 'ENOTDIR'; + throw error; + } + + let result = []; + const matchedElements = filesInfos.paths.filter( + (dir) => dir.startsWith(path) && path !== dir, + ); + let elementsInDir; + if (path === '/') { + elementsInDir = matchedElements.filter( + (element) => !element.substring(1).includes('/'), + ); + } else { + elementsInDir = [ + ...new Set( + matchedElements.map( + (element) => element.replace(`${path}/`, '').split('/')[0], + ), + ), + ]; + } + // generate the list of elements in dir (strings or Dirents) + if (options.withFileTypes) { + result = elementsInDir.map((element) => { + const name = element; + const isFile = filesInfos.files.includes(`${path}/${element}`); + const type = isFile ? UV_DIRENT_FILE : UV_DIRENT_DIR; + return new CustomDirent(name, type, `${path}/${element}`); + }); + } else { + result = elementsInDir; + } + + return result; +} + +// Use Cells node:fs API +const fsPolyfill = Object.create(SRC_NODE_FS); +fsPolyfill.close = close; +fsPolyfill.closeSync = closeSync; +fsPolyfill.openSync = openSync; +fsPolyfill.statSync = statSync; +fsPolyfill.lstatSync = statSync; +fsPolyfill.readFileSync = readFileSync; +fsPolyfill.readdirSync = readdirSync; + +export default fsPolyfill; + +export { + close, + closeSync, + openSync, + statSync, + statSync as lstatSync, + readFileSync, + readdirSync, +}; + +export const { + access, + accessSync, + appendFile, + appendFileSync, + chmod, + chmodSync, + chown, + chownSync, + constants, + copyFile, + copyFileSync, + cp, + cpSync, + createReadStream, + createWriteStream, + Dir, + Dirent, + exists, + existsSync, + F_OK, + fdatasync, + fdatasyncSync, + fstat, + fstatSync, + fsync, + fsyncSync, + ftruncate, + ftruncateSync, + futimes, + futimesSync, + link, + linkSync, + lstat, + mkdir, + mkdirSync, + mkdtemp, + mkdtempSync, + O_APPEND, + O_CREAT, + O_DIRECTORY, + O_DSYNC, + O_EXCL, + O_NOCTTY, + O_NOFOLLOW, + O_NONBLOCK, + O_RDONLY, + O_RDWR, + O_SYMLINK, + O_SYNC, + O_TRUNC, + O_WRONLY, + open, + opendir, + opendirSync, + read, + readSync, + promises, + R_OK, + readdir, + readFile, + readlink, + readlinkSync, + ReadStream, + realpath, + realpathSync, + readv, + readvSync, + rename, + renameSync, + rmdir, + rmdirSync, + rm, + rmSync, + stat, + Stats, + statfs, + statfsSync, + symlink, + symlinkSync, + truncate, + truncateSync, + unlink, + unlinkSync, + unwatchFile, + utimes, + utimesSync, + W_OK, + watch, + watchFile, + write, + writeFile, + writev, + writevSync, + writeFileSync, + WriteStream, + writeSync, + X_OK, +} = SRC_NODE_FS; + +/* eslint-enable */ diff --git a/packages/unenv-preset/src/polyfills/node/fs.promises.js b/packages/unenv-preset/src/polyfills/node/fs.promises.js new file mode 100644 index 0000000..e69de29 diff --git a/packages/unenv-preset/src/polyfills/node/globals/path-dirname.js b/packages/unenv-preset/src/polyfills/node/globals/path-dirname.js new file mode 100644 index 0000000..2348521 --- /dev/null +++ b/packages/unenv-preset/src/polyfills/node/globals/path-dirname.js @@ -0,0 +1,5 @@ +/* eslint-disable */ +import _path from 'path'; +import process from 'process'; +globalThis.__dirname = _path.dirname(process.cwd()); +export default globalThis.__dirname; diff --git a/packages/unenv-preset/src/polyfills/node/globals/path-filename.js b/packages/unenv-preset/src/polyfills/node/globals/path-filename.js new file mode 100644 index 0000000..d5edb84 --- /dev/null +++ b/packages/unenv-preset/src/polyfills/node/globals/path-filename.js @@ -0,0 +1,4 @@ +/* eslint-disable */ +import process from 'process'; +globalThis.__filename = process.cwd(); +export default globalThis.__filename; diff --git a/packages/unenv-preset/src/polyfills/node/globals/process.cjs b/packages/unenv-preset/src/polyfills/node/globals/process.cjs new file mode 100644 index 0000000..d235bd7 --- /dev/null +++ b/packages/unenv-preset/src/polyfills/node/globals/process.cjs @@ -0,0 +1,203 @@ +/* eslint-disable */ +// shim for using process in browser +var processShim = (module.exports = {}); + +/* + * Copyright Azion + * Licensed under the MIT license. See LICENSE file for details. + * + * Portions of this file Copyright Roman Shtylman, licensed under the MIT license. + * npmjs: https://www.npmjs.com/package/process + * repo: https://github.com/defunctzombie/node-process + */ + +var cachedSetTimeout; +var cachedClearTimeout; + +function defaultSetTimout() { + throw new Error('setTimeout has not been defined'); +} +function defaultClearTimeout() { + throw new Error('clearTimeout has not been defined'); +} +(function () { + try { + if (typeof setTimeout === 'function') { + cachedSetTimeout = setTimeout; + } else { + cachedSetTimeout = defaultSetTimout; + } + } catch (e) { + cachedSetTimeout = defaultSetTimout; + } + try { + if (typeof clearTimeout === 'function') { + cachedClearTimeout = clearTimeout; + } else { + cachedClearTimeout = defaultClearTimeout; + } + } catch (e) { + cachedClearTimeout = defaultClearTimeout; + } +})(); +function runTimeout(fun) { + if (cachedSetTimeout === setTimeout) { + //normal enviroments in sane situations + return setTimeout(fun, 0); + } + // if setTimeout wasn't available but was latter defined + if ( + (cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && + setTimeout + ) { + cachedSetTimeout = setTimeout; + return setTimeout(fun, 0); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedSetTimeout(fun, 0); + } catch (e) { + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedSetTimeout.call(null, fun, 0); + } catch (e) { + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error + return cachedSetTimeout.call(this, fun, 0); + } + } +} +function runClearTimeout(marker) { + if (cachedClearTimeout === clearTimeout) { + //normal enviroments in sane situations + return clearTimeout(marker); + } + // if clearTimeout wasn't available but was latter defined + if ( + (cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && + clearTimeout + ) { + cachedClearTimeout = clearTimeout; + return clearTimeout(marker); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedClearTimeout(marker); + } catch (e) { + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedClearTimeout.call(null, marker); + } catch (e) { + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. + // Some versions of I.E. have different rules for clearTimeout vs setTimeout + return cachedClearTimeout.call(this, marker); + } + } +} +var queue = []; +var draining = false; +var currentQueue; +var queueIndex = -1; + +function cleanUpNextTick() { + if (!draining || !currentQueue) { + return; + } + draining = false; + if (currentQueue.length) { + queue = currentQueue.concat(queue); + } else { + queueIndex = -1; + } + if (queue.length) { + drainQueue(); + } +} + +function drainQueue() { + if (draining) { + return; + } + var timeout = runTimeout(cleanUpNextTick); + draining = true; + + var len = queue.length; + while (len) { + currentQueue = queue; + queue = []; + while (++queueIndex < len) { + if (currentQueue) { + currentQueue[queueIndex].run(); + } + } + queueIndex = -1; + len = queue.length; + } + currentQueue = null; + draining = false; + runClearTimeout(timeout); +} + +processShim.nextTick = function (fun) { + var args = new Array(arguments.length - 1); + if (arguments.length > 1) { + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + } + queue.push(new Item(fun, args)); + if (queue.length === 1 && !draining) { + runTimeout(drainQueue); + } +}; + +// v8 likes predictible objects +function Item(fun, array) { + this.fun = fun; + this.array = array; +} +Item.prototype.run = function () { + this.fun.apply(null, this.array); +}; +processShim.title = 'browser'; +processShim.browser = true; +processShim.env = processShim.env = + typeof globalThis.process !== 'undefined' && globalThis.process.env + ? globalThis.process.env + : {}; +processShim.argv = []; +processShim.version = ''; // empty string to avoid regexp issues +processShim.versions = { node: '18.3.1' }; + +function noop() {} + +processShim.on = noop; +processShim.addListener = noop; +processShim.once = noop; +processShim.off = noop; +processShim.removeListener = noop; +processShim.removeAllListeners = noop; +processShim.emit = noop; +processShim.prependListener = noop; +processShim.prependOnceListener = noop; + +processShim.listeners = function (name) { + return []; +}; + +processShim.binding = function (name) { + throw new Error('process.binding is not supported'); +}; + +processShim.cwd = function () { + return '/'; +}; + +processShim.chdir = function (dir) { + throw new Error('process.chdir is not supported'); +}; +processShim.umask = function () { + return 0; +}; + +globalThis.process = processShim; +globalThis.process.env = processShim.env; diff --git a/packages/unenv-preset/src/polyfills/node/module.js b/packages/unenv-preset/src/polyfills/node/module.js new file mode 100644 index 0000000..31569dc --- /dev/null +++ b/packages/unenv-preset/src/polyfills/node/module.js @@ -0,0 +1,138 @@ +/* eslint-disable */ + +function createRequire(...args) { + /* EMPTY */ +} + +function unimplemented() { + throw new Error('Not implemented yet!'); +} + +var builtinModules = [ + '_http_agent', + '_http_client', + '_http_common', + '_http_incoming', + '_http_outgoing', + '_http_server', + '_stream_duplex', + '_stream_passthrough', + '_stream_readable', + '_stream_transform', + '_stream_wrap', + '_stream_writable', + '_tls_common', + '_tls_wrap', + 'assert', + 'assert/strict', + 'async_hooks', + 'buffer', + 'child_process', + 'cluster', + 'console', + 'constants', + 'crypto', + 'dgram', + 'diagnostics_channel', + 'dns', + 'dns/promises', + 'domain', + 'events', + 'fs', + 'fs/promises', + 'http', + 'http2', + 'https', + 'inspector', + 'module', + 'net', + 'os', + 'path', + 'path/posix', + 'path/win32', + 'perf_hooks', + 'process', + 'punycode', + 'querystring', + 'readline', + 'repl', + 'stream', + 'stream/consumers', + 'stream/promises', + 'stream/web', + 'string_decoder', + 'sys', + 'timers', + 'timers/promises', + 'tls', + 'trace_events', + 'tty', + 'url', + 'util', + 'util/types', + 'v8', + 'vm', + 'worker_threads', + 'zlib', +]; + +function _load(...args) { + /* EMPTY */ +} + +function _nodeModulePaths(...args) { + /* EMPTY */ +} + +function _resolveFilename(...args) { + /* EMPTY */ +} + +export default { + builtinModules: builtinModules, + _cache: null, + _pathCache: null, + _extensions: null, + globalPaths: null, + _debug: unimplemented, + _findPath: unimplemented, + _nodeModulePaths: _nodeModulePaths, + _resolveLookupPaths: unimplemented, + _load: _load, + _resolveFilename: _resolveFilename, + createRequireFromPath: unimplemented, + createRequire: createRequire, + _initPaths: unimplemented, + _preloadModules: unimplemented, + syncBuiltinESMExports: unimplemented, + Module: unimplemented, + runMain: unimplemented, + findSourceMap: unimplemented, + SourceMap: unimplemented, +}; + +export var _cache = null, + _pathCache = null, + _extensions = null, + globalPaths = null; + +export { + builtinModules, + unimplemented as _debug, + unimplemented as _findPath, + unimplemented as _nodeModulePaths, + unimplemented as _resolveLookupPaths, + unimplemented as _load, + unimplemented as _resolveFilename, + createRequire as createRequireFromPath, + createRequire as createRequire, + unimplemented as _initPaths, + unimplemented as _preloadModules, + unimplemented as syncBuiltinESMExports, + unimplemented as Module, + unimplemented as runMain, + unimplemented as findSourceMap, + unimplemented as SourceMap, +}; + +/* eslint-enable */ diff --git a/packages/unenv-preset/src/types.ts b/packages/unenv-preset/src/types.ts new file mode 100644 index 0000000..f072fad --- /dev/null +++ b/packages/unenv-preset/src/types.ts @@ -0,0 +1,31 @@ +export interface Environment { + alias: { [key: string]: string }; + inject: { [key: string]: string | string[] }; + polyfill: string[]; + external: string[]; +} + +export interface Preset { + meta?: { + /** + * Preset name. + */ + readonly name?: string; + + /** + * Preset version. + */ + readonly version?: string; + + /** + * Path or URL to preset entry (used for resolving absolute paths). + */ + readonly url?: string | URL; + }; + + alias?: Environment['alias']; + // inject's value is nullable to support overrides/subtraction + inject?: { [key: string]: string | string[] | false }; + polyfill?: Environment['polyfill']; + external?: Environment['external']; +} diff --git a/packages/unenv-preset/tsconfig.json b/packages/unenv-preset/tsconfig.json new file mode 100644 index 0000000..68f8166 --- /dev/null +++ b/packages/unenv-preset/tsconfig.json @@ -0,0 +1,14 @@ +{ + "compilerOptions": { + "target": "es2022", + "module": "ESNext", + "outDir": "./dist", + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "strict": true, + "skipLibCheck": true, + "moduleResolution": "bundler", + "isolatedModules": true, + "resolveJsonModule": true + } +}