@esmx/fetch 3.0.0-rc.10 → 3.0.0-rc.103

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Esmx Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,58 @@
1
+ <div align="center">
2
+ <img src="https://esmx.dev/logo.svg?t=2025" width="120" alt="Esmx Logo" />
3
+ <h1>@esmx/fetch</h1>
4
+
5
+ <div>
6
+ <a href="https://www.npmjs.com/package/@esmx/fetch">
7
+ <img src="https://img.shields.io/npm/v/@esmx/fetch.svg" alt="npm version" />
8
+ </a>
9
+ <a href="https://github.com/esmnext/esmx/actions/workflows/build.yml">
10
+ <img src="https://github.com/esmnext/esmx/actions/workflows/build.yml/badge.svg" alt="Build" />
11
+ </a>
12
+ <a href="https://esmx.dev/coverage/">
13
+ <img src="https://img.shields.io/badge/coverage-live%20report-brightgreen" alt="Coverage Report" />
14
+ </a>
15
+ <a href="https://nodejs.org/">
16
+ <img src="https://img.shields.io/node/v/@esmx/fetch.svg" alt="node version" />
17
+ </a>
18
+ <a href="https://bundlephobia.com/package/@esmx/fetch">
19
+ <img src="https://img.shields.io/bundlephobia/minzip/@esmx/fetch" alt="size" />
20
+ </a>
21
+ </div>
22
+
23
+ <p>Universal HTTP client for Esmx framework with caching and progress support</p>
24
+
25
+ <p>
26
+ English | <a href="https://github.com/esmnext/esmx/blob/master/packages/fetch/README.zh-CN.md">中文</a>
27
+ </p>
28
+ </div>
29
+
30
+ ## 🚀 Features
31
+
32
+ - **Node.js Optimized** - Specifically designed for Node.js server-side environments
33
+ - **Smart Caching** - Built-in intelligent caching mechanism
34
+ - **Progress Tracking** - Download progress support with CLI progress bars
35
+ - **TypeScript Ready** - Full TypeScript support with excellent type safety
36
+ - **Axios Based** - Built on top of the reliable Axios library
37
+ - **Lightweight** - Minimal footprint with essential features
38
+
39
+ ## 📦 Installation
40
+
41
+ ```bash
42
+ # npm
43
+ npm install @esmx/fetch
44
+
45
+ # pnpm
46
+ pnpm add @esmx/fetch
47
+
48
+ # yarn
49
+ yarn add @esmx/fetch
50
+ ```
51
+
52
+ ## 📚 Documentation
53
+
54
+ Visit the [official documentation](https://esmx.dev) for detailed usage guides and API reference.
55
+
56
+ ## 📄 License
57
+
58
+ MIT © [Esmx Team](https://github.com/esmnext/esmx)
@@ -0,0 +1,58 @@
1
+ <div align="center">
2
+ <img src="https://esmx.dev/logo.svg?t=2025" width="120" alt="Esmx Logo" />
3
+ <h1>@esmx/fetch</h1>
4
+
5
+ <div>
6
+ <a href="https://www.npmjs.com/package/@esmx/fetch">
7
+ <img src="https://img.shields.io/npm/v/@esmx/fetch.svg" alt="npm version" />
8
+ </a>
9
+ <a href="https://github.com/esmnext/esmx/actions/workflows/build.yml">
10
+ <img src="https://github.com/esmnext/esmx/actions/workflows/build.yml/badge.svg" alt="Build" />
11
+ </a>
12
+ <a href="https://esmx.dev/coverage/">
13
+ <img src="https://img.shields.io/badge/coverage-live%20report-brightgreen" alt="Coverage Report" />
14
+ </a>
15
+ <a href="https://nodejs.org/">
16
+ <img src="https://img.shields.io/node/v/@esmx/fetch.svg" alt="node version" />
17
+ </a>
18
+ <a href="https://bundlephobia.com/package/@esmx/fetch">
19
+ <img src="https://img.shields.io/bundlephobia/minzip/@esmx/fetch" alt="size" />
20
+ </a>
21
+ </div>
22
+
23
+ <p>为 Esmx 框架提供的通用 HTTP 客户端,支持缓存和进度追踪</p>
24
+
25
+ <p>
26
+ <a href="https://github.com/esmnext/esmx/blob/master/packages/fetch/README.md">English</a> | 中文
27
+ </p>
28
+ </div>
29
+
30
+ ## 🚀 特性
31
+
32
+ - **Node.js 优化** - 专为 Node.js 服务端环境设计
33
+ - **智能缓存** - 内置智能缓存机制
34
+ - **进度追踪** - 下载进度支持和 CLI 进度条
35
+ - **TypeScript 就绪** - 完整的 TypeScript 支持,出色的类型安全
36
+ - **基于 Axios** - 构建在可靠的 Axios 库之上
37
+ - **轻量级** - 最小化体积,包含核心功能
38
+
39
+ ## 📦 安装
40
+
41
+ ```bash
42
+ # npm
43
+ npm install @esmx/fetch
44
+
45
+ # pnpm
46
+ pnpm add @esmx/fetch
47
+
48
+ # yarn
49
+ yarn add @esmx/fetch
50
+ ```
51
+
52
+ ## 📚 文档
53
+
54
+ 访问[官方文档](https://esmx.dev)获取详细的使用指南和 API 参考。
55
+
56
+ ## 📄 许可证
57
+
58
+ MIT © [Esmx Team](https://github.com/esmnext/esmx)
@@ -11,7 +11,7 @@ test("base", async () => {
11
11
  await fetchPkgsWithProgress({
12
12
  outputDir,
13
13
  axiosReqCfg: {
14
- baseURL: "https://www.esmnext.com",
14
+ baseURL: "https://esmx.dev",
15
15
  timeout: 4500
16
16
  },
17
17
  packs: urls.map((url) => ({ url, name: url.split("/")[0] }))
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export * from './types';
2
1
  export * from './fetch-pkg';
3
2
  export * from './fetch-pkgs';
3
+ export * from './types';
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- export * from "./types.mjs";
2
1
  export * from "./fetch-pkg.mjs";
3
2
  export * from "./fetch-pkgs.mjs";
3
+ export * from "./types.mjs";
package/package.json CHANGED
@@ -1,31 +1,47 @@
1
1
  {
2
2
  "name": "@esmx/fetch",
3
3
  "template": "library-node",
4
+ "contributors": [
5
+ {
6
+ "name": "lzxb",
7
+ "url": "https://github.com/lzxb"
8
+ },
9
+ {
10
+ "name": "RockShi1994",
11
+ "url": "https://github.com/RockShi1994"
12
+ },
13
+ {
14
+ "name": "jerrychan7",
15
+ "url": "https://github.com/jerrychan7"
16
+ },
17
+ {
18
+ "name": "wesloong",
19
+ "url": "https://github.com/wesloong"
20
+ }
21
+ ],
4
22
  "scripts": {
5
- "lint:css": "stylelint '**/*.{css,vue}' --fix --aei",
23
+ "lint:css": "pnpm run lint:js",
6
24
  "lint:type": "tsc --noEmit",
7
- "test": "vitest --pass-with-no-tests",
25
+ "test": "vitest run --pass-with-no-tests",
8
26
  "coverage": "vitest run --coverage --pass-with-no-tests",
9
27
  "lint:js": "biome check --write --no-errors-on-unmatched",
10
28
  "build": "unbuild"
11
29
  },
12
30
  "dependencies": {
13
- "axios": "^1.7.7",
31
+ "axios": "^1.13.2",
14
32
  "cachedir": "^2.4.0",
15
33
  "cli-progress": "^3.12.0"
16
34
  },
17
35
  "devDependencies": {
18
- "@biomejs/biome": "1.9.4",
19
- "@esmx/lint": "3.0.0-rc.10",
36
+ "@biomejs/biome": "2.3.7",
20
37
  "@types/cli-progress": "^3.11.6",
21
- "@types/node": "22.9.0",
22
- "@vitest/coverage-v8": "2.1.5",
23
- "stylelint": "16.10.0",
24
- "typescript": "5.6.3",
25
- "unbuild": "2.0.0",
26
- "vitest": "2.1.5"
38
+ "@types/node": "^24.0.0",
39
+ "@vitest/coverage-v8": "3.2.4",
40
+ "typescript": "5.9.3",
41
+ "unbuild": "3.6.1",
42
+ "vitest": "3.2.4"
27
43
  },
28
- "version": "3.0.0-rc.10",
44
+ "version": "3.0.0-rc.103",
29
45
  "type": "module",
30
46
  "private": false,
31
47
  "exports": {
@@ -37,11 +53,12 @@
37
53
  "module": "dist/index.mjs",
38
54
  "types": "./dist/index.d.ts",
39
55
  "files": [
56
+ "lib",
40
57
  "src",
41
58
  "dist",
42
59
  "*.mjs",
43
60
  "template",
44
61
  "public"
45
62
  ],
46
- "gitHead": "4a528ffecfdc6f2c6e7d97bc952427745f467691"
63
+ "gitHead": "1f2c436d0d57d587756c4012fbf5df2bebcc874f"
47
64
  }
package/src/fetch-pkgs.ts CHANGED
@@ -4,10 +4,10 @@ import { MultiBar } from 'cli-progress';
4
4
  import { fetchPkg } from './fetch-pkg';
5
5
  import type {
6
6
  FetchPkgOptions,
7
- FetchPkgWithBarLogger,
8
- FetchPkgWithBarOptions,
9
7
  FetchPkgsOptions,
10
8
  FetchPkgsWithBarOptions,
9
+ FetchPkgWithBarLogger,
10
+ FetchPkgWithBarOptions,
11
11
  FetchResult,
12
12
  FetchResults
13
13
  } from './types';
package/src/fetch.test.ts CHANGED
@@ -12,7 +12,7 @@ test('base', async () => {
12
12
  await fetchPkgsWithProgress({
13
13
  outputDir,
14
14
  axiosReqCfg: {
15
- baseURL: 'https://www.esmnext.com',
15
+ baseURL: 'https://esmx.dev',
16
16
  timeout: 4500
17
17
  },
18
18
  packs: urls.map((url) => ({ url, name: url.split('/')[0] }))
package/src/index.ts CHANGED
@@ -14,7 +14,7 @@ const outputDir = path.join(path.dirname(fileURLToPath(import.meta.url)), 'outpu
14
14
  fetchPkgsWithProgress({
15
15
  outputDir,
16
16
  axiosReqCfg: {
17
- baseURL: 'https://js-esm.github.io/esmx/',
17
+ baseURL: 'https://esmx.dev/',
18
18
  timeout: 10000,
19
19
  },
20
20
  packs: urls.map(url => ({ url, name: url.split('/')[0] })),
@@ -26,6 +26,6 @@ fetchPkgsWithProgress({
26
26
 
27
27
  */
28
28
 
29
- export * from './types';
30
29
  export * from './fetch-pkg';
31
30
  export * from './fetch-pkgs';
31
+ export * from './types';
package/src/utils.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import crypto from 'node:crypto';
2
2
  import fs from 'node:fs';
3
- import axios, { type AxiosResponse, type AxiosRequestConfig } from 'axios';
3
+ import axios, { type AxiosRequestConfig, type AxiosResponse } from 'axios';
4
4
 
5
5
  /**
6
6
  * 获取 hash 文件的值
@@ -59,7 +59,7 @@ export async function downloadFile(
59
59
  const hashStream = hash ? crypto.createHash(hashAlg) : null;
60
60
  const fileStream = fs.createWriteStream(filePath);
61
61
 
62
- const streamPromise = new Promise((resolve, reject) => {
62
+ const streamPromise = new Promise<void>((resolve, reject) => {
63
63
  fileStream.on('finish', resolve);
64
64
  fileStream.on('error', reject);
65
65
  });