unenv
Advanced tools
Comparing version 1.4.1 to 1.5.1
{ | ||
"name": "unenv", | ||
"version": "1.4.1", | ||
"version": "1.5.1", | ||
"description": "", | ||
@@ -28,19 +28,19 @@ "repository": "unjs/unenv", | ||
"dependencies": { | ||
"consola": "^3.1.0", | ||
"defu": "^6.1.2", | ||
"mime": "^3.0.0", | ||
"node-fetch-native": "^1.1.0", | ||
"node-fetch-native": "^1.1.1", | ||
"pathe": "^1.1.0" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^18.15.11", | ||
"changelogen": "^0.5.2", | ||
"consola": "^3.0.1", | ||
"eslint": "^8.38.0", | ||
"eslint-config-unjs": "^0.1.0", | ||
"@types/node": "^20.2.3", | ||
"changelogen": "^0.5.3", | ||
"eslint": "^8.41.0", | ||
"eslint-config-unjs": "^0.2.0", | ||
"jiti": "^1.18.2", | ||
"prettier": "^2.8.7", | ||
"prettier": "^2.8.8", | ||
"typescript": "^5.0.4", | ||
"unbuild": "^1.2.0" | ||
"unbuild": "^1.2.1" | ||
}, | ||
"packageManager": "pnpm@8.1.1", | ||
"packageManager": "pnpm@8.5.1", | ||
"scripts": { | ||
@@ -47,0 +47,0 @@ "build": "unbuild", |
141
README.md
@@ -7,3 +7,2 @@ # unenv | ||
```bash | ||
@@ -25,5 +24,5 @@ # Using npm | ||
```js | ||
import { env, node, nodeless } from 'unenv' | ||
import { env, node, nodeless } from "unenv"; | ||
const { alias, inject, polyfill, external } = env(...presets) | ||
const { alias, inject, polyfill, external } = env(...presets); | ||
``` | ||
@@ -48,52 +47,52 @@ | ||
Module | Status | Source | ||
-------|--------|--------------- | ||
[node:assert](https://nodejs.org/api/assert.html) | Mocked | - | ||
[node:async_hooks](https://nodejs.org/api/async_hooks.html) | Mocked | - | ||
[node:buffer](https://nodejs.org/api/buffer.html) | Polyfilled | [unenv/node/buffer](./src/runtime/node/buffer) | ||
[node:child_process](https://nodejs.org/api/child_process.html) | Mocked | - | ||
[node:cluster](https://nodejs.org/api/cluster.html) | Mocked | - | ||
[node:console](https://nodejs.org/api/console.html) | Mocked | - | ||
[node:constants](https://nodejs.org/api/constants.html) | Mocked | - | ||
[node:crypto](https://nodejs.org/api/crypto.html) | Polyfilled | [unenv/node/crypto](./src/runtime/node/crypto) | ||
[node:dgram](https://nodejs.org/api/dgram.html) | Mocked | - | ||
[node:diagnostics_channel](https://nodejs.org/api/diagnostics_channel.html) | Mocked | - | ||
[node:dns](https://nodejs.org/api/dns.html) | Mocked | - | ||
[node:domain](https://nodejs.org/api/domain.html) | Mocked | - | ||
[node:events](https://nodejs.org/api/events.html) | Polyfilled | [unenv/node/events](./src/runtime/node/events) | ||
[node:fs](https://nodejs.org/api/fs.html) | Polyfilled | [unenv/node/fs](./src/runtime/node/fs) | ||
[node:fs/promises](https://nodejs.org/api/fs/promises.html) | Polyfilled | [unenv/node/fs/promises](./src/runtime/node/fs/promises) | ||
[node:http2](https://nodejs.org/api/http2.html) | Mocked | - | ||
[node:http](https://nodejs.org/api/http.html) | Polyfilled | [unenv/node/http](./src/runtime/node/http) | ||
[node:https](https://nodejs.org/api/https.html) | Mocked | - | ||
[node:inspector](https://nodejs.org/api/inspector.html) | Mocked | - | ||
[node:module](https://nodejs.org/api/module.html) | Mocked | - | ||
[node:net](https://nodejs.org/api/net.html) | Polyfilled | [unenv/node/net](./src/runtime/node/net) | ||
[node:os](https://nodejs.org/api/os.html) | Mocked | - | ||
[node:path](https://nodejs.org/api/path.html) | Polyfilled | [unenv/node/path](./src/runtime/node/path) | ||
[node:perf_hooks](https://nodejs.org/api/perf_hooks.html) | Mocked | - | ||
[node:process](https://nodejs.org/api/process.html) | Polyfilled | [unenv/node/process](./src/runtime/node/process) | ||
[node:punycode](https://nodejs.org/api/punycode.html) | Mocked | - | ||
[node:querystring](https://nodejs.org/api/querystring.html) | Mocked | - | ||
[node:readline](https://nodejs.org/api/readline.html) | Mocked | - | ||
[node:repl](https://nodejs.org/api/repl.html) | Mocked | - | ||
[node:stream](https://nodejs.org/api/stream.html) | Polyfilled | [unenv/node/stream](./src/runtime/node/stream) | ||
[node:stream/consumers](https://nodejs.org/api/stream.html) | Mocked | [unenv/node/stream/consumers](./src/runtime/node/stream/consumers) | ||
[node:stream/promises](https://nodejs.org/api/stream.html) | Mocked | [unenv/node/stream/promises](./src/runtime/node/stream/promises) | ||
[node:stream/web](https://nodejs.org/api/stream.html) | Native | [unenv/node/stream/web](./src/runtime/node/stream/web) | ||
[node:string_decoder](https://nodejs.org/api/string_decoder.html) | Mocked | - | ||
[node:sys](https://nodejs.org/api/sys.html) | Mocked | - | ||
[node:timers](https://nodejs.org/api/timers.html) | Mocked | - | ||
[node:timers/promises](https://nodejs.org/api/timers.html) | Mocked | - | ||
[node:tls](https://nodejs.org/api/tls.html) | Mocked | - | ||
[node:trace_events](https://nodejs.org/api/trace_events.html) | Mocked | - | ||
[node:tty](https://nodejs.org/api/tty.html) | Mocked | - | ||
[node:url](https://nodejs.org/api/url.html) | Polyfilled | [unenv/node/url](./src/runtime/node/url) | ||
[node:util](https://nodejs.org/api/util.html) | Polyfilled | [unenv/node/util](./src/runtime/node/util) | ||
[node:util/types](https://nodejs.org/api/util.html) | Polyfilled | [unenv/node/util/types](./src/runtime/node/util/types) | ||
[node:v8](https://nodejs.org/api/v8.html) | Mocked | - | ||
[node:vm](https://nodejs.org/api/vm.html) | Mocked | - | ||
[node:wasi](https://nodejs.org/api/wasi.html) | Mocked | - | ||
[node:worker_threads](https://nodejs.org/api/worker_threads.html) | Mocked | - | ||
[node:zlib](https://nodejs.org/api/zlib.html) | Mocked | - | ||
| Module | Status | Source | | ||
| --------------------------------------------------------------------------- | ---------- | ------------------------------------------------------------------ | | ||
| [node:assert](https://nodejs.org/api/assert.html) | Mocked | - | | ||
| [node:async_hooks](https://nodejs.org/api/async_hooks.html) | Polyfilled | [unenv/node/async_hooks](./src/runtime/node/async_hooks) | | ||
| [node:buffer](https://nodejs.org/api/buffer.html) | Polyfilled | [unenv/node/buffer](./src/runtime/node/buffer) | | ||
| [node:child_process](https://nodejs.org/api/child_process.html) | Mocked | - | | ||
| [node:cluster](https://nodejs.org/api/cluster.html) | Mocked | - | | ||
| [node:console](https://nodejs.org/api/console.html) | Mocked | - | | ||
| [node:constants](https://nodejs.org/api/constants.html) | Mocked | - | | ||
| [node:crypto](https://nodejs.org/api/crypto.html) | Polyfilled | [unenv/node/crypto](./src/runtime/node/crypto) | | ||
| [node:dgram](https://nodejs.org/api/dgram.html) | Mocked | - | | ||
| [node:diagnostics_channel](https://nodejs.org/api/diagnostics_channel.html) | Mocked | - | | ||
| [node:dns](https://nodejs.org/api/dns.html) | Mocked | - | | ||
| [node:domain](https://nodejs.org/api/domain.html) | Mocked | - | | ||
| [node:events](https://nodejs.org/api/events.html) | Polyfilled | [unenv/node/events](./src/runtime/node/events) | | ||
| [node:fs](https://nodejs.org/api/fs.html) | Polyfilled | [unenv/node/fs](./src/runtime/node/fs) | | ||
| [node:fs/promises](https://nodejs.org/api/fs/promises.html) | Polyfilled | [unenv/node/fs/promises](./src/runtime/node/fs/promises) | | ||
| [node:http2](https://nodejs.org/api/http2.html) | Mocked | - | | ||
| [node:http](https://nodejs.org/api/http.html) | Polyfilled | [unenv/node/http](./src/runtime/node/http) | | ||
| [node:https](https://nodejs.org/api/https.html) | Mocked | - | | ||
| [node:inspector](https://nodejs.org/api/inspector.html) | Mocked | - | | ||
| [node:module](https://nodejs.org/api/module.html) | Mocked | - | | ||
| [node:net](https://nodejs.org/api/net.html) | Polyfilled | [unenv/node/net](./src/runtime/node/net) | | ||
| [node:os](https://nodejs.org/api/os.html) | Mocked | - | | ||
| [node:path](https://nodejs.org/api/path.html) | Polyfilled | [unenv/node/path](./src/runtime/node/path) | | ||
| [node:perf_hooks](https://nodejs.org/api/perf_hooks.html) | Mocked | - | | ||
| [node:process](https://nodejs.org/api/process.html) | Polyfilled | [unenv/node/process](./src/runtime/node/process) | | ||
| [node:punycode](https://nodejs.org/api/punycode.html) | Mocked | - | | ||
| [node:querystring](https://nodejs.org/api/querystring.html) | Mocked | - | | ||
| [node:readline](https://nodejs.org/api/readline.html) | Mocked | - | | ||
| [node:repl](https://nodejs.org/api/repl.html) | Mocked | - | | ||
| [node:stream](https://nodejs.org/api/stream.html) | Polyfilled | [unenv/node/stream](./src/runtime/node/stream) | | ||
| [node:stream/consumers](https://nodejs.org/api/stream.html) | Mocked | [unenv/node/stream/consumers](./src/runtime/node/stream/consumers) | | ||
| [node:stream/promises](https://nodejs.org/api/stream.html) | Mocked | [unenv/node/stream/promises](./src/runtime/node/stream/promises) | | ||
| [node:stream/web](https://nodejs.org/api/stream.html) | Native | [unenv/node/stream/web](./src/runtime/node/stream/web) | | ||
| [node:string_decoder](https://nodejs.org/api/string_decoder.html) | Mocked | - | | ||
| [node:sys](https://nodejs.org/api/sys.html) | Mocked | - | | ||
| [node:timers](https://nodejs.org/api/timers.html) | Mocked | - | | ||
| [node:timers/promises](https://nodejs.org/api/timers.html) | Mocked | - | | ||
| [node:tls](https://nodejs.org/api/tls.html) | Mocked | - | | ||
| [node:trace_events](https://nodejs.org/api/trace_events.html) | Mocked | - | | ||
| [node:tty](https://nodejs.org/api/tty.html) | Mocked | - | | ||
| [node:url](https://nodejs.org/api/url.html) | Polyfilled | [unenv/node/url](./src/runtime/node/url) | | ||
| [node:util](https://nodejs.org/api/util.html) | Polyfilled | [unenv/node/util](./src/runtime/node/util) | | ||
| [node:util/types](https://nodejs.org/api/util.html) | Polyfilled | [unenv/node/util/types](./src/runtime/node/util/types) | | ||
| [node:v8](https://nodejs.org/api/v8.html) | Mocked | - | | ||
| [node:vm](https://nodejs.org/api/vm.html) | Mocked | - | | ||
| [node:wasi](https://nodejs.org/api/wasi.html) | Mocked | - | | ||
| [node:worker_threads](https://nodejs.org/api/worker_threads.html) | Mocked | - | | ||
| [node:zlib](https://nodejs.org/api/zlib.html) | Mocked | - | | ||
@@ -104,13 +103,13 @@ ## npm packages | ||
Package | Status | Source | ||
-------|--------|--------------- | ||
[npm/consola](https://www.npmjs.com/package/consola) | Use native `console` | [unenv/runtime/npm/consola](./src/runtime/npm/consola.ts) | ||
[npm/cross-fetch](https://www.npmjs.com/package/node-fetch) | Use native `fetch` | [unenv/runtime/npm/cross-fetch](./src/runtime/npm/cross-fetch.ts) | ||
[npm/debug](https://www.npmjs.com/package/debug) | Mocked with `console.debug` | [unenv/runtime/npm/debug](./src/runtime/npm/debug.ts) | ||
[npm/fsevents](https://www.npmjs.com/package/fsevents) | Mocked | [unenv/runtime/npm/fsevents](./src/runtime/npm/fsevents.ts) | ||
[npm/inherits](https://www.npmjs.com/package/inherits) | Inlined | [unenv/runtime/npm/inherits](./src/runtime/npm/inherits.ts) | ||
[npm/mime-db](https://www.npmjs.com/package/mime-db) | Minimized | [unenv/runtime/npm/mime-db](./src/runtime/npm/mime-db.ts) | ||
[npm/mime](https://www.npmjs.com/package/mime) | Minimized | [unenv/runtime/npm/mime](./src/runtime/npm/mime.ts) | ||
[npm/node-fetch](https://www.npmjs.com/package/node-fetch) | Use native `fetch` | [unenv/runtime/npm/node-fetch](./src/runtime/npm/node-fetch.ts) | ||
[npm/whatwg-url](https://www.npmjs.com/package/whatwg-url) | Use native `URL` | [unenv/runtime/npm/whatwg-url](./src/runtime/npm/whatwg-url.ts) | ||
| Package | Status | Source | | ||
| ----------------------------------------------------------- | --------------------------- | ----------------------------------------------------------------- | | ||
| [npm/consola](https://www.npmjs.com/package/consola) | Use native `console` | [unenv/runtime/npm/consola](./src/runtime/npm/consola.ts) | | ||
| [npm/cross-fetch](https://www.npmjs.com/package/node-fetch) | Use native `fetch` | [unenv/runtime/npm/cross-fetch](./src/runtime/npm/cross-fetch.ts) | | ||
| [npm/debug](https://www.npmjs.com/package/debug) | Mocked with `console.debug` | [unenv/runtime/npm/debug](./src/runtime/npm/debug.ts) | | ||
| [npm/fsevents](https://www.npmjs.com/package/fsevents) | Mocked | [unenv/runtime/npm/fsevents](./src/runtime/npm/fsevents.ts) | | ||
| [npm/inherits](https://www.npmjs.com/package/inherits) | Inlined | [unenv/runtime/npm/inherits](./src/runtime/npm/inherits.ts) | | ||
| [npm/mime-db](https://www.npmjs.com/package/mime-db) | Minimized | [unenv/runtime/npm/mime-db](./src/runtime/npm/mime-db.ts) | | ||
| [npm/mime](https://www.npmjs.com/package/mime) | Minimized | [unenv/runtime/npm/mime](./src/runtime/npm/mime.ts) | | ||
| [npm/node-fetch](https://www.npmjs.com/package/node-fetch) | Use native `fetch` | [unenv/runtime/npm/node-fetch](./src/runtime/npm/node-fetch.ts) | | ||
| [npm/whatwg-url](https://www.npmjs.com/package/whatwg-url) | Use native `URL` | [unenv/runtime/npm/whatwg-url](./src/runtime/npm/whatwg-url.ts) | | ||
@@ -120,9 +119,7 @@ ## Auto-mocking proxy | ||
```js | ||
import MockProxy from 'unenv/runtime/mock/proxy' | ||
import MockProxy from "unenv/runtime/mock/proxy"; | ||
console.log(MockProxy().foo.bar()[0]) | ||
console.log(MockProxy().foo.bar()[0]); | ||
``` | ||
Above package doesn't work outside of Node.js and neither we need any platform specific logic! When aliasing `os` to `mock/proxy-cjs`, it will be auto mocked using a [Proxy Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy) which can be recursively traversed like an `Object`, called like a `Function`, Iterated like an `Array`, or instantiated like a `Class`. | ||
@@ -133,5 +130,7 @@ | ||
```js | ||
const os = require('os') | ||
if (os.platform() === 'windows') { /* do some fix */ } | ||
module.exports = () => 'Hello world' | ||
const os = require("os"); | ||
if (os.platform() === "windows") { | ||
/* do some fix */ | ||
} | ||
module.exports = () => "Hello world"; | ||
``` | ||
@@ -138,0 +137,0 @@ |
@@ -0,1 +1,2 @@ | ||
/// <reference types="node" /> | ||
import type nodeCrypto from "node:crypto"; | ||
@@ -5,3 +6,4 @@ export declare const subtle: typeof nodeCrypto.subtle; | ||
export declare const getRandomValues: typeof nodeCrypto.getRandomValues; | ||
export declare const randomBytes: (size: number, cb?: ((err: Error | null, buf: Buffer) => void) | undefined) => Buffer | undefined; | ||
declare const _default: any; | ||
export default _default; |
@@ -25,2 +25,4 @@ import type http from "node:http"; | ||
setTimeout(_msecs: number, _callback?: () => void): this; | ||
get headersDistinct(): Record<string, string[]>; | ||
get trailersDistinct(): Record<string, string[]>; | ||
} |
@@ -16,2 +16,3 @@ /// <reference types="node" /> | ||
headersSent: boolean; | ||
strictContentLength: boolean; | ||
connection: Socket | null; | ||
@@ -29,2 +30,3 @@ socket: Socket | null; | ||
setTimeout(_msecs: number, _callback?: Callback): this; | ||
appendHeader(name: string, value: string | string[]): this; | ||
setHeader(name: string, value: number | string | ReadonlyArray<string>): this; | ||
@@ -31,0 +33,0 @@ getHeader(name: string): number | string | string[] | undefined; |
@@ -13,2 +13,3 @@ import type util from "node:util"; | ||
export declare const _extend: () => any; | ||
export declare const aborted: typeof util.aborted; | ||
export declare const callbackify: typeof util.callbackify; | ||
@@ -15,0 +16,0 @@ export declare const getSystemErrorMap: typeof util.getSystemErrorMap; |
@@ -1,2 +0,3 @@ | ||
export declare const consola: any; | ||
export declare function createConsola(options?: any): import("consola/dist/consola-3fef035a").a; | ||
export declare const consola: import("consola/dist/consola-3fef035a").a; | ||
export default consola; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
358180
8
193
10673
5
141
+ Addedconsola@^3.1.0
+ Addedconsola@3.2.3(transitive)
Updatednode-fetch-native@^1.1.1