{"_id":"@admni/file-uploader","_rev":"2-f87e6c9d60844e2b3e349219a01b9f1f","name":"@admni/file-uploader","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@admni/file-uploader","version":"1.0.0","license":"MIT","_id":"@admni/file-uploader@1.0.0","maintainers":[{"name":"admni","email":"2353243699@qq.com"}],"dist":{"shasum":"4da25a2e84523f4691bf5ace71260cf938adb191","tarball":"https://registry.npmjs.org/@admni/file-uploader/-/file-uploader-1.0.0.tgz","fileCount":83,"integrity":"sha512-CFgqnbXcF+HYf1bSJWrElwJ2zvhM9sIUvXQcaKgmIvrCv326Wfcz49tScuH5sDzGEOTzb+XinB0NpDSkP7O5wg==","signatures":[{"sig":"MEYCIQDv7uToI2iXorUco5pKcGK+BqZdo1eBFRAOWD0on7ZvmwIhAPuPk4lNb4nC5T9U2hkO8+mXa1w3Qmy0XzLYJQG1/Le3","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":127298},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"scripts":{"build":"tsc -p tsconfig.build.json","typecheck":"tsc --noEmit","pack:check":"npm pack --dry-run","prepublishOnly":"npm run typecheck && npm run build"},"_npmUser":{"name":"admni","email":"2353243699@qq.com"},"_npmVersion":"11.11.0","description":"Browser file uploader SDK with queue, chunk upload, instant upload and pause/resume support.","directories":{},"_nodeVersion":"25.8.1","dependencies":{"@aws-sdk/client-s3":"latest","esdk-obs-browserjs":"latest","murmurhash3js-revisited":"latest"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"latest"},"_npmOperationalInternal":{"tmp":"tmp/file-uploader_1.0.0_1777456873506_0.8639272382934031","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@admni/file-uploader","version":"1.0.1","description":"Browser file uploader SDK with queue, chunk upload, instant upload and pause/resume support.","license":"MIT","type":"module","main":"./dist/index.js","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"scripts":{"build":"tsc -p tsconfig.build.json","typecheck":"tsc --noEmit","pack:check":"npm pack --dry-run","prepublishOnly":"npm run typecheck && npm run build"},"dependencies":{"@aws-sdk/client-s3":"latest","esdk-obs-browserjs":"latest","murmurhash3js-revisited":"latest"},"devDependencies":{"typescript":"latest"},"publishConfig":{"access":"public"},"_id":"@admni/file-uploader@1.0.1","_nodeVersion":"25.8.1","_npmVersion":"11.11.0","dist":{"integrity":"sha512-8pUTdGK7UE7TCKEE5Omp2rE4dGNouungXu6fQmErFkWbB+lokFZQOpE+FEDvWWVn4gMaex47FscBcq/yRlCyfA==","shasum":"5d94876db3a4cfc156626ca43e82430151833d0a","tarball":"https://registry.npmjs.org/@admni/file-uploader/-/file-uploader-1.0.1.tgz","fileCount":83,"unpackedSize":127900,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDjZIRxQo4pkk5EpoU9oQ3E1wqlsKz1B6QgPAo0AmiD4gIgJ1JHJku7AnlWNgZOtPFmdYw2lHiVWHJD9P4DDT/1/Gk="}]},"_npmUser":{"name":"admni","email":"2353243699@qq.com"},"directories":{},"maintainers":[{"name":"admni","email":"2353243699@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/file-uploader_1.0.1_1777457645348_0.28224236956325255"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-29T10:01:13.331Z","modified":"2026-04-29T10:14:05.603Z","1.0.0":"2026-04-29T10:01:13.642Z","1.0.1":"2026-04-29T10:14:05.493Z"},"license":"MIT","description":"Browser file uploader SDK with queue, chunk upload, instant upload and pause/resume support.","maintainers":[{"name":"admni","email":"2353243699@qq.com"}],"readme":"# @admni/file-uploader\n\n浏览器端文件上传 SDK（TypeScript），按 `v1.0.md` 设计基线实现，支持：\n\n- 上传队列与并发调度（`UploadQueue`）\n- 单文件完整生命周期（`FileUploader`）\n- 直传 / 分片上传（滑动窗口并发）\n- 暂停 / 继续 / 取消（含网络自动暂停恢复）\n- 秒传（`identical_storage`）与同 hash 去重\n- 业务 code 拦截（`onConfigResponse`）与 `bizCode` 透传\n- Worker hash 并行计算（`hashConcurrency`）\n\n> 内部维护文档见 `INTERNAL.md`；完整规范源见 `../file-upload/v1.0.md`。\n\n## 安装\n\n```bash\nnpm i @admni/file-uploader\n```\n\n## 快速开始\n\n```ts\nimport { UploadQueue, UploadBizError } from \"@admni/file-uploader\"\n\nconst queue = new UploadQueue({\n  concurrency: 3,\n  hashConcurrency: 2,\n  onTaskChange(task) {\n    console.log(task.taskId, task.fileName, task.state, task.progress)\n  },\n  // 可选：统一处理服务端 code\n  onConfigResponse: async (response, retry, ctx) => {\n    if (response.code === 0 && response.data) return response.data\n    if (response.code === 1012) return retry() // 例如 token 刷新后重试\n    throw new UploadBizError(\n      \"CONFIG_FAILED\",\n      response.message || `config failed: ${response.code}`,\n      response.code,\n      { ctx, response },\n    )\n  },\n})\n\nconst taskId = queue.add(file, {\n  async getUploadConfig({ fileHash, fileName, fileSize, fileType }) {\n    const res = await fetch(\"/api/upload/config\", {\n      method: \"POST\",\n      headers: { \"Content-Type\": \"application/json\" },\n      body: JSON.stringify({ fileHash, fileName, fileSize, fileType }),\n    })\n    return await res.json()\n  },\n  async notifyComplete(params) {\n    await fetch(\"/api/upload/complete\", {\n      method: \"POST\",\n      headers: { \"Content-Type\": \"application/json\" },\n      body: JSON.stringify(params),\n    })\n  },\n})\n\n// 控制任务\nqueue.pause(taskId)\nqueue.resume(taskId)\nqueue.cancel(taskId)\n```\n\n## 核心能力\n\n- 状态机：`pending -> hashing -> configuring -> uploading -> (merging) -> notifying -> success`\n- 秒传：`identical_storage=true` 时跳过 uploading/merging\n- 可插拔策略：`onConfigResponse` 可处理业务码、重试、终止\n- 存储适配：内置 OBS / S3 / Custom（fetch PUT）\n- 可观测性：插件钩子（step start/end/error, network change）\n\n## API 速览\n\n- `new UploadQueue(options)`\n- `queue.add(file, options)`\n- `queue.pause(taskId)` / `queue.resume(taskId)` / `queue.cancel(taskId)`\n- `queue.pauseAll()` / `queue.resumeAll()` / `queue.getTasks()` / `queue.destroy()`\n\n## 发布到 npm（维护者）\n\n```bash\nnpm login\nnpm run typecheck\nnpm run build\nnpm run pack:check\nnpm publish --access public\n```\n","readmeFilename":"README.md"}