{"_id":"@bunny.net/upload-core","_rev":"2-2102ca8a9d1ca20d2920def4559ac30a","name":"@bunny.net/upload-core","dist-tags":{"latest":"0.0.2"},"versions":{"0.0.1":{"name":"@bunny.net/upload-core","version":"0.0.1","_id":"@bunny.net/upload-core@0.0.1","maintainers":[{"name":"kevin_at_bunny","email":"kevin@bunny.net"},{"name":"antho-bunny","email":"anthony@bunny.net"},{"name":"notrab","email":"jamie@notrab.dev"},{"name":"bogdan-at-bunny","email":"bogdan@bunny.net"}],"dist":{"shasum":"543f749e06df8ff95abfde501c1c6068a6ff713a","tarball":"https://registry.npmjs.org/@bunny.net/upload-core/-/upload-core-0.0.1.tgz","fileCount":11,"integrity":"sha512-rp19m5nP/XWiBkMvbtxt3D7BvUW18cZ174H0M4nFIMKwvHq8iCX6pFx0idTyFIh42EXGvLRev+s4ARsIFIcoNA==","signatures":[{"sig":"MEQCICsJWX1Egt2HBuON7d5njMsOi01e5ULbwAP3Vrvb1S9uAiBzrX8hiyA4OlBxDJOZFGne1iWV4pFjrDIimA80E5Tdog==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":153682},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}},"./styles.css":"./styles.css"},"gitHead":"e30b7b82d2997aaa97925aead3cee193bfe1935e","scripts":{"dev":"tsup --watch","test":"vitest run --passWithNoTests","build":"tsup","clean":"rm -rf dist","typecheck":"tsc --noEmit"},"_npmUser":{"name":"notrab","email":"jamie@notrab.dev"},"_npmVersion":"10.8.2","description":"Framework-agnostic upload engine for [bunny-upload](../../README.md).","directories":{},"_nodeVersion":"20.20.1","dependencies":{"@bunny.net/upload-shared":"workspace:*"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","vitest":"^2.0.0","typescript":"^5.5.0"},"_npmOperationalInternal":{"tmp":"tmp/upload-core_0.0.1_1774534837898_0.5846856121408639","host":"s3://npm-registry-packages-npm-production"}},"0.0.2":{"name":"@bunny.net/upload-core","publishConfig":{"access":"public"},"version":"0.0.2","type":"module","main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}},"./styles.css":"./styles.css"},"scripts":{"build":"tsup","dev":"tsup --watch","test":"vitest run --passWithNoTests","typecheck":"tsc --noEmit","clean":"rm -rf dist"},"dependencies":{"@bunny.net/upload-shared":"0.0.2"},"devDependencies":{"tsup":"^8.0.0","typescript":"^5.5.0","vitest":"^2.0.0"},"_id":"@bunny.net/upload-core@0.0.2","gitHead":"93aa8ca7a45d19966df2a8f738e18ca517a03e01","description":"Framework-agnostic upload engine for [bunny-upload](../../README.md).","_nodeVersion":"20.20.1","_npmVersion":"10.8.2","dist":{"integrity":"sha512-Lxs8qc4vsyXmSZD/A0Rntx0/uLxOZWSwyIO+1Dwxs3b/ldWbx2qHq8vCwX2azrdUQVFEU0K2T4dy1cnfndQWpQ==","shasum":"286c2fbbca6c64e345438a6bbbea8a1741e89f2c","tarball":"https://registry.npmjs.org/@bunny.net/upload-core/-/upload-core-0.0.2.tgz","fileCount":11,"unpackedSize":153676,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDv0FDt0Eijy8cxgw6oxKMorehUMJsosyOC1VX22GRpPAIhANeCD9+NTcCsf7P6aZ0SmfgaJNVX3Hglkl6CXnLkwRb0"}]},"_npmUser":{"name":"notrab","email":"jamie@notrab.dev"},"directories":{},"maintainers":[{"name":"kevin_at_bunny","email":"kevin@bunny.net"},{"name":"antho-bunny","email":"anthony@bunny.net"},{"name":"notrab","email":"jamie@notrab.dev"},{"name":"bogdan-at-bunny","email":"bogdan@bunny.net"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/upload-core_0.0.2_1774539272073_0.40768151496543203"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-26T14:20:37.828Z","modified":"2026-03-26T15:34:32.370Z","0.0.1":"2026-03-26T14:20:38.042Z","0.0.2":"2026-03-26T15:34:32.208Z"},"description":"Framework-agnostic upload engine for [bunny-upload](../../README.md).","maintainers":[{"name":"kevin_at_bunny","email":"kevin@bunny.net"},{"name":"antho-bunny","email":"anthony@bunny.net"},{"name":"notrab","email":"jamie@notrab.dev"},{"name":"bogdan-at-bunny","email":"bogdan@bunny.net"}],"readme":"# @bunny.net/upload-core\n\nFramework-agnostic upload engine for [bunny-upload](../../README.md).\n\nYou probably don't need to use this package directly — use [`@bunny.net/upload-react`](../react), [`@bunny.net/upload-vue`](../vue), or [`@bunny.net/upload-angular`](../angular) instead. This package is the shared foundation they all build on.\n\n## Install\n\n```bash\nnpm install @bunny.net/upload-core\n```\n\n## Usage\n\n```ts\nimport { createUploader } from \"@bunny.net/upload-core\";\n\nconst uploader = createUploader({\n  endpoint: \"/.bunny/upload\", // default\n  restrictions: {\n    maxFileSize: \"10mb\",\n    allowedTypes: [\"image/*\"],\n    maxFiles: 5,\n  },\n});\n\n// Listen for events\nuploader.on(\"state-change\", (files) => console.log(files));\nuploader.on(\"complete\", (results) => console.log(results));\nuploader.on(\"error\", (error, file) => console.error(error));\n\n// Add files (from an <input> or drag-and-drop)\nuploader.addFiles(fileInput.files);\n\n// Upload\nconst results = await uploader.upload();\n// [{ name: \"photo.jpg\", path: \"/uploads/photo.jpg\", size: 102400, url: \"https://cdn.example.com/uploads/photo.jpg\" }]\n```\n\n## API\n\n### `createUploader(options?)`\n\nCreates a new `Uploader` instance.\n\n#### Options\n\n| Option | Type | Default | Description |\n|---|---|---|---|\n| `endpoint` | `string` | `\"/.bunny/upload\"` | Server endpoint to upload to |\n| `restrictions.maxFileSize` | `string \\| number` | — | Max file size (e.g. `\"10mb\"`, `1048576`) |\n| `restrictions.allowedTypes` | `string[]` | — | Allowed MIME types (supports globs like `\"image/*\"`) |\n| `restrictions.maxFiles` | `number` | — | Max number of files |\n\n### `Uploader`\n\n| Method | Description |\n|---|---|\n| `addFiles(files)` | Add files from a `FileList` or `File[]`. Returns added `FileState[]`. |\n| `removeFile(id)` | Remove a file by ID |\n| `upload()` | Upload all pending files. Returns `Promise<UploadResult[]>`. |\n| `reset()` | Clear all files |\n| `getFiles()` | Get current file states |\n| `on(event, fn)` | Subscribe to an event. Returns an unsubscribe function. |\n| `off(event, fn)` | Unsubscribe from an event |\n\n### Events\n\n| Event | Payload | Description |\n|---|---|---|\n| `state-change` | `FileState[]` | Any file state changed |\n| `complete` | `UploadResult[]` | All uploads finished |\n| `error` | `Error, FileState?` | An upload failed |\n| `file-added` | `FileState` | A file was added |\n| `file-removed` | `FileState` | A file was removed |\n| `upload-progress` | `FileState` | Upload progress updated |\n\n### Utilities\n\n```ts\nimport { parseFileSize, matchesMimeType, formatBytes } from \"@bunny.net/upload-core\";\n\nparseFileSize(\"10mb\"); // 10485760\nmatchesMimeType(\"image/png\", \"image/*\"); // true\nformatBytes(10485760); // \"10 MB\"\n```\n","readmeFilename":"README.md"}