@esmx/fetch 3.0.0-rc.11 → 3.0.0-rc.110

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2020 Vanelink
3
+ Copyright (c) 2020 Esmx Team
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
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
@@ -20,30 +20,28 @@
20
20
  }
21
21
  ],
22
22
  "scripts": {
23
- "lint:css": "stylelint '**/*.{css,vue}' --fix --aei",
23
+ "lint:css": "pnpm run lint:js",
24
24
  "lint:type": "tsc --noEmit",
25
- "test": "vitest --pass-with-no-tests",
25
+ "test": "vitest run --pass-with-no-tests",
26
26
  "coverage": "vitest run --coverage --pass-with-no-tests",
27
27
  "lint:js": "biome check --write --no-errors-on-unmatched",
28
28
  "build": "unbuild"
29
29
  },
30
30
  "dependencies": {
31
- "axios": "^1.7.7",
31
+ "axios": "^1.13.2",
32
32
  "cachedir": "^2.4.0",
33
33
  "cli-progress": "^3.12.0"
34
34
  },
35
35
  "devDependencies": {
36
- "@biomejs/biome": "1.9.4",
37
- "@esmx/lint": "3.0.0-rc.11",
36
+ "@biomejs/biome": "2.3.7",
38
37
  "@types/cli-progress": "^3.11.6",
39
- "@types/node": "22.9.0",
40
- "@vitest/coverage-v8": "2.1.5",
41
- "stylelint": "16.10.0",
42
- "typescript": "5.6.3",
43
- "unbuild": "2.0.0",
44
- "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"
45
43
  },
46
- "version": "3.0.0-rc.11",
44
+ "version": "3.0.0-rc.110",
47
45
  "type": "module",
48
46
  "private": false,
49
47
  "exports": {
@@ -55,11 +53,12 @@
55
53
  "module": "dist/index.mjs",
56
54
  "types": "./dist/index.d.ts",
57
55
  "files": [
56
+ "lib",
58
57
  "src",
59
58
  "dist",
60
59
  "*.mjs",
61
60
  "template",
62
61
  "public"
63
62
  ],
64
- "gitHead": "0920e0485284528eb642a7078f4cb48b013352a5"
63
+ "gitHead": "0cea5581bcb0774a0350565bcda33073c3123a3d"
65
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
  });