@backblaze-labs/b2-sdk 0.1.0
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/CHANGELOG.md +121 -0
- package/LICENSE +21 -0
- package/README.md +664 -0
- package/dist/auth/account-info.d.cts +51 -0
- package/dist/auth/account-info.d.cts.map +1 -0
- package/dist/auth/account-info.d.ts +51 -0
- package/dist/auth/account-info.d.ts.map +1 -0
- package/dist/auth/file.cjs +210 -0
- package/dist/auth/file.cjs.map +1 -0
- package/dist/auth/file.d.cts +157 -0
- package/dist/auth/file.d.cts.map +1 -0
- package/dist/auth/file.d.ts +157 -0
- package/dist/auth/file.d.ts.map +1 -0
- package/dist/auth/file.js +210 -0
- package/dist/auth/file.js.map +1 -0
- package/dist/auth/in-memory.cjs +184 -0
- package/dist/auth/in-memory.cjs.map +1 -0
- package/dist/auth/in-memory.d.cts +147 -0
- package/dist/auth/in-memory.d.cts.map +1 -0
- package/dist/auth/in-memory.d.ts +147 -0
- package/dist/auth/in-memory.d.ts.map +1 -0
- package/dist/auth/in-memory.js +184 -0
- package/dist/auth/in-memory.js.map +1 -0
- package/dist/auth/index.cjs +10 -0
- package/dist/auth/index.cjs.map +1 -0
- package/dist/auth/index.d.cts +6 -0
- package/dist/auth/index.d.cts.map +1 -0
- package/dist/auth/index.d.ts +6 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +10 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/realms.cjs +12 -0
- package/dist/auth/realms.cjs.map +1 -0
- package/dist/auth/realms.d.cts +12 -0
- package/dist/auth/realms.d.cts.map +1 -0
- package/dist/auth/realms.d.ts +12 -0
- package/dist/auth/realms.d.ts.map +1 -0
- package/dist/auth/realms.js +12 -0
- package/dist/auth/realms.js.map +1 -0
- package/dist/auth/upload-url-pool.cjs +52 -0
- package/dist/auth/upload-url-pool.cjs.map +1 -0
- package/dist/auth/upload-url-pool.d.cts +35 -0
- package/dist/auth/upload-url-pool.d.cts.map +1 -0
- package/dist/auth/upload-url-pool.d.ts +35 -0
- package/dist/auth/upload-url-pool.d.ts.map +1 -0
- package/dist/auth/upload-url-pool.js +52 -0
- package/dist/auth/upload-url-pool.js.map +1 -0
- package/dist/bucket.cjs +789 -0
- package/dist/bucket.cjs.map +1 -0
- package/dist/bucket.d.cts +659 -0
- package/dist/bucket.d.cts.map +1 -0
- package/dist/bucket.d.ts +659 -0
- package/dist/bucket.d.ts.map +1 -0
- package/dist/bucket.js +789 -0
- package/dist/bucket.js.map +1 -0
- package/dist/client.cjs +230 -0
- package/dist/client.cjs.map +1 -0
- package/dist/client.d.cts +222 -0
- package/dist/client.d.cts.map +1 -0
- package/dist/client.d.ts +222 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +230 -0
- package/dist/client.js.map +1 -0
- package/dist/copy/large.cjs +74 -0
- package/dist/copy/large.cjs.map +1 -0
- package/dist/copy/large.d.cts +53 -0
- package/dist/copy/large.d.cts.map +1 -0
- package/dist/copy/large.d.ts +53 -0
- package/dist/copy/large.d.ts.map +1 -0
- package/dist/copy/large.js +74 -0
- package/dist/copy/large.js.map +1 -0
- package/dist/download/parallel.cjs +122 -0
- package/dist/download/parallel.cjs.map +1 -0
- package/dist/download/parallel.d.cts +42 -0
- package/dist/download/parallel.d.cts.map +1 -0
- package/dist/download/parallel.d.ts +42 -0
- package/dist/download/parallel.d.ts.map +1 -0
- package/dist/download/parallel.js +122 -0
- package/dist/download/parallel.js.map +1 -0
- package/dist/download/single.cjs +117 -0
- package/dist/download/single.cjs.map +1 -0
- package/dist/download/single.d.cts +152 -0
- package/dist/download/single.d.cts.map +1 -0
- package/dist/download/single.d.ts +152 -0
- package/dist/download/single.d.ts.map +1 -0
- package/dist/download/single.js +117 -0
- package/dist/download/single.js.map +1 -0
- package/dist/errors/index.cjs +268 -0
- package/dist/errors/index.cjs.map +1 -0
- package/dist/errors/index.d.cts +264 -0
- package/dist/errors/index.d.cts.map +1 -0
- package/dist/errors/index.d.ts +264 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +268 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/http/retry.cjs +36 -0
- package/dist/http/retry.cjs.map +1 -0
- package/dist/http/retry.d.cts +34 -0
- package/dist/http/retry.d.cts.map +1 -0
- package/dist/http/retry.d.ts +34 -0
- package/dist/http/retry.d.ts.map +1 -0
- package/dist/http/retry.js +36 -0
- package/dist/http/retry.js.map +1 -0
- package/dist/http/transport.cjs +143 -0
- package/dist/http/transport.cjs.map +1 -0
- package/dist/http/transport.d.cts +122 -0
- package/dist/http/transport.d.cts.map +1 -0
- package/dist/http/transport.d.ts +122 -0
- package/dist/http/transport.d.ts.map +1 -0
- package/dist/http/transport.js +143 -0
- package/dist/http/transport.js.map +1 -0
- package/dist/http/url-guard.cjs +97 -0
- package/dist/http/url-guard.cjs.map +1 -0
- package/dist/http/url-guard.d.cts +88 -0
- package/dist/http/url-guard.d.cts.map +1 -0
- package/dist/http/url-guard.d.ts +88 -0
- package/dist/http/url-guard.d.ts.map +1 -0
- package/dist/http/url-guard.js +97 -0
- package/dist/http/url-guard.js.map +1 -0
- package/dist/http/user-agent.cjs +51 -0
- package/dist/http/user-agent.cjs.map +1 -0
- package/dist/http/user-agent.d.cts +28 -0
- package/dist/http/user-agent.d.cts.map +1 -0
- package/dist/http/user-agent.d.ts +28 -0
- package/dist/http/user-agent.d.ts.map +1 -0
- package/dist/http/user-agent.js +51 -0
- package/dist/http/user-agent.js.map +1 -0
- package/dist/index.cjs +78 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +39 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +78 -0
- package/dist/index.js.map +1 -0
- package/dist/notifications/index.cjs +7 -0
- package/dist/notifications/index.cjs.map +1 -0
- package/dist/notifications/index.d.cts +3 -0
- package/dist/notifications/index.d.cts.map +1 -0
- package/dist/notifications/index.d.ts +3 -0
- package/dist/notifications/index.d.ts.map +1 -0
- package/dist/notifications/index.js +7 -0
- package/dist/notifications/index.js.map +1 -0
- package/dist/notifications/webhook.cjs +106 -0
- package/dist/notifications/webhook.cjs.map +1 -0
- package/dist/notifications/webhook.d.cts +146 -0
- package/dist/notifications/webhook.d.cts.map +1 -0
- package/dist/notifications/webhook.d.ts +146 -0
- package/dist/notifications/webhook.d.ts.map +1 -0
- package/dist/notifications/webhook.js +106 -0
- package/dist/notifications/webhook.js.map +1 -0
- package/dist/object.cjs +212 -0
- package/dist/object.cjs.map +1 -0
- package/dist/object.d.cts +263 -0
- package/dist/object.d.cts.map +1 -0
- package/dist/object.d.ts +263 -0
- package/dist/object.d.ts.map +1 -0
- package/dist/object.js +212 -0
- package/dist/object.js.map +1 -0
- package/dist/package.json.cjs +9 -0
- package/dist/package.json.cjs.map +1 -0
- package/dist/package.json.js +9 -0
- package/dist/package.json.js.map +1 -0
- package/dist/raw/encoding.cjs +47 -0
- package/dist/raw/encoding.cjs.map +1 -0
- package/dist/raw/encoding.d.cts +46 -0
- package/dist/raw/encoding.d.cts.map +1 -0
- package/dist/raw/encoding.d.ts +46 -0
- package/dist/raw/encoding.d.ts.map +1 -0
- package/dist/raw/encoding.js +47 -0
- package/dist/raw/encoding.js.map +1 -0
- package/dist/raw/index.cjs +600 -0
- package/dist/raw/index.cjs.map +1 -0
- package/dist/raw/index.d.cts +381 -0
- package/dist/raw/index.d.cts.map +1 -0
- package/dist/raw/index.d.ts +381 -0
- package/dist/raw/index.d.ts.map +1 -0
- package/dist/raw/index.js +601 -0
- package/dist/raw/index.js.map +1 -0
- package/dist/s3/index.cjs +23 -0
- package/dist/s3/index.cjs.map +1 -0
- package/dist/s3/index.d.cts +74 -0
- package/dist/s3/index.d.cts.map +1 -0
- package/dist/s3/index.d.ts +74 -0
- package/dist/s3/index.d.ts.map +1 -0
- package/dist/s3/index.js +23 -0
- package/dist/s3/index.js.map +1 -0
- package/dist/simulator/capabilities.cjs +53 -0
- package/dist/simulator/capabilities.cjs.map +1 -0
- package/dist/simulator/capabilities.d.cts +15 -0
- package/dist/simulator/capabilities.d.cts.map +1 -0
- package/dist/simulator/capabilities.d.ts +15 -0
- package/dist/simulator/capabilities.d.ts.map +1 -0
- package/dist/simulator/capabilities.js +53 -0
- package/dist/simulator/capabilities.js.map +1 -0
- package/dist/simulator/index.cjs +1559 -0
- package/dist/simulator/index.cjs.map +1 -0
- package/dist/simulator/index.d.cts +495 -0
- package/dist/simulator/index.d.cts.map +1 -0
- package/dist/simulator/index.d.ts +495 -0
- package/dist/simulator/index.d.ts.map +1 -0
- package/dist/simulator/index.js +1560 -0
- package/dist/simulator/index.js.map +1 -0
- package/dist/simulator/validation.cjs +174 -0
- package/dist/simulator/validation.cjs.map +1 -0
- package/dist/simulator/validation.d.cts +104 -0
- package/dist/simulator/validation.d.cts.map +1 -0
- package/dist/simulator/validation.d.ts +104 -0
- package/dist/simulator/validation.d.ts.map +1 -0
- package/dist/simulator/validation.js +174 -0
- package/dist/simulator/validation.js.map +1 -0
- package/dist/streams/collect.cjs +26 -0
- package/dist/streams/collect.cjs.map +1 -0
- package/dist/streams/collect.d.cts +18 -0
- package/dist/streams/collect.d.cts.map +1 -0
- package/dist/streams/collect.d.ts +18 -0
- package/dist/streams/collect.d.ts.map +1 -0
- package/dist/streams/collect.js +26 -0
- package/dist/streams/collect.js.map +1 -0
- package/dist/streams/hash.cjs +123 -0
- package/dist/streams/hash.cjs.map +1 -0
- package/dist/streams/hash.d.cts +42 -0
- package/dist/streams/hash.d.cts.map +1 -0
- package/dist/streams/hash.d.ts +42 -0
- package/dist/streams/hash.d.ts.map +1 -0
- package/dist/streams/hash.js +101 -0
- package/dist/streams/hash.js.map +1 -0
- package/dist/streams/index.cjs +13 -0
- package/dist/streams/index.cjs.map +1 -0
- package/dist/streams/index.d.cts +7 -0
- package/dist/streams/index.d.cts.map +1 -0
- package/dist/streams/index.d.ts +7 -0
- package/dist/streams/index.d.ts.map +1 -0
- package/dist/streams/index.js +13 -0
- package/dist/streams/index.js.map +1 -0
- package/dist/streams/progress.cjs +47 -0
- package/dist/streams/progress.cjs.map +1 -0
- package/dist/streams/progress.d.cts +53 -0
- package/dist/streams/progress.d.cts.map +1 -0
- package/dist/streams/progress.d.ts +53 -0
- package/dist/streams/progress.d.ts.map +1 -0
- package/dist/streams/progress.js +47 -0
- package/dist/streams/progress.js.map +1 -0
- package/dist/streams/source.cjs +155 -0
- package/dist/streams/source.cjs.map +1 -0
- package/dist/streams/source.d.cts +140 -0
- package/dist/streams/source.d.cts.map +1 -0
- package/dist/streams/source.d.ts +140 -0
- package/dist/streams/source.d.ts.map +1 -0
- package/dist/streams/source.js +155 -0
- package/dist/streams/source.js.map +1 -0
- package/dist/sync/actions/index.cjs +191 -0
- package/dist/sync/actions/index.cjs.map +1 -0
- package/dist/sync/actions/index.d.cts +167 -0
- package/dist/sync/actions/index.d.cts.map +1 -0
- package/dist/sync/actions/index.d.ts +167 -0
- package/dist/sync/actions/index.d.ts.map +1 -0
- package/dist/sync/actions/index.js +191 -0
- package/dist/sync/actions/index.js.map +1 -0
- package/dist/sync/index.cjs +23 -0
- package/dist/sync/index.cjs.map +1 -0
- package/dist/sync/index.d.cts +21 -0
- package/dist/sync/index.d.cts.map +1 -0
- package/dist/sync/index.d.ts +21 -0
- package/dist/sync/index.d.ts.map +1 -0
- package/dist/sync/index.js +23 -0
- package/dist/sync/index.js.map +1 -0
- package/dist/sync/pairing.cjs +31 -0
- package/dist/sync/pairing.cjs.map +1 -0
- package/dist/sync/pairing.d.cts +13 -0
- package/dist/sync/pairing.d.cts.map +1 -0
- package/dist/sync/pairing.d.ts +13 -0
- package/dist/sync/pairing.d.ts.map +1 -0
- package/dist/sync/pairing.js +31 -0
- package/dist/sync/pairing.js.map +1 -0
- package/dist/sync/policies/compare.cjs +14 -0
- package/dist/sync/policies/compare.cjs.map +1 -0
- package/dist/sync/policies/compare.d.cts +13 -0
- package/dist/sync/policies/compare.d.cts.map +1 -0
- package/dist/sync/policies/compare.d.ts +13 -0
- package/dist/sync/policies/compare.d.ts.map +1 -0
- package/dist/sync/policies/compare.js +14 -0
- package/dist/sync/policies/compare.js.map +1 -0
- package/dist/sync/policies/index.cjs +74 -0
- package/dist/sync/policies/index.cjs.map +1 -0
- package/dist/sync/policies/index.d.cts +42 -0
- package/dist/sync/policies/index.d.cts.map +1 -0
- package/dist/sync/policies/index.d.ts +42 -0
- package/dist/sync/policies/index.d.ts.map +1 -0
- package/dist/sync/policies/index.js +74 -0
- package/dist/sync/policies/index.js.map +1 -0
- package/dist/sync/scanners/b2.cjs +57 -0
- package/dist/sync/scanners/b2.cjs.map +1 -0
- package/dist/sync/scanners/b2.d.cts +20 -0
- package/dist/sync/scanners/b2.d.cts.map +1 -0
- package/dist/sync/scanners/b2.d.ts +20 -0
- package/dist/sync/scanners/b2.d.ts.map +1 -0
- package/dist/sync/scanners/b2.js +57 -0
- package/dist/sync/scanners/b2.js.map +1 -0
- package/dist/sync/scanners/local.cjs +58 -0
- package/dist/sync/scanners/local.cjs.map +1 -0
- package/dist/sync/scanners/local.d.cts +24 -0
- package/dist/sync/scanners/local.d.cts.map +1 -0
- package/dist/sync/scanners/local.d.ts +24 -0
- package/dist/sync/scanners/local.d.ts.map +1 -0
- package/dist/sync/scanners/local.js +58 -0
- package/dist/sync/scanners/local.js.map +1 -0
- package/dist/sync/synchronizer.cjs +203 -0
- package/dist/sync/synchronizer.cjs.map +1 -0
- package/dist/sync/synchronizer.d.cts +52 -0
- package/dist/sync/synchronizer.d.cts.map +1 -0
- package/dist/sync/synchronizer.d.ts +52 -0
- package/dist/sync/synchronizer.d.ts.map +1 -0
- package/dist/sync/synchronizer.js +181 -0
- package/dist/sync/synchronizer.js.map +1 -0
- package/dist/sync/types.d.cts +121 -0
- package/dist/sync/types.d.cts.map +1 -0
- package/dist/sync/types.d.ts +121 -0
- package/dist/sync/types.d.ts.map +1 -0
- package/dist/types/auth.cjs +58 -0
- package/dist/types/auth.cjs.map +1 -0
- package/dist/types/auth.d.cts +150 -0
- package/dist/types/auth.d.cts.map +1 -0
- package/dist/types/auth.d.ts +150 -0
- package/dist/types/auth.d.ts.map +1 -0
- package/dist/types/auth.js +58 -0
- package/dist/types/auth.js.map +1 -0
- package/dist/types/bucket.cjs +44 -0
- package/dist/types/bucket.cjs.map +1 -0
- package/dist/types/bucket.d.cts +245 -0
- package/dist/types/bucket.d.cts.map +1 -0
- package/dist/types/bucket.d.ts +245 -0
- package/dist/types/bucket.d.ts.map +1 -0
- package/dist/types/bucket.js +44 -0
- package/dist/types/bucket.js.map +1 -0
- package/dist/types/download.d.cts +110 -0
- package/dist/types/download.d.cts.map +1 -0
- package/dist/types/download.d.ts +110 -0
- package/dist/types/download.d.ts.map +1 -0
- package/dist/types/encryption.cjs +343 -0
- package/dist/types/encryption.cjs.map +1 -0
- package/dist/types/encryption.d.cts +132 -0
- package/dist/types/encryption.d.cts.map +1 -0
- package/dist/types/encryption.d.ts +132 -0
- package/dist/types/encryption.d.ts.map +1 -0
- package/dist/types/encryption.js +321 -0
- package/dist/types/encryption.js.map +1 -0
- package/dist/types/errors.d.cts +16 -0
- package/dist/types/errors.d.cts.map +1 -0
- package/dist/types/errors.d.ts +16 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/file.cjs +23 -0
- package/dist/types/file.cjs.map +1 -0
- package/dist/types/file.d.cts +220 -0
- package/dist/types/file.d.cts.map +1 -0
- package/dist/types/file.d.ts +220 -0
- package/dist/types/file.d.ts.map +1 -0
- package/dist/types/file.js +23 -0
- package/dist/types/file.js.map +1 -0
- package/dist/types/ids.cjs +27 -0
- package/dist/types/ids.cjs.map +1 -0
- package/dist/types/ids.d.cts +84 -0
- package/dist/types/ids.d.cts.map +1 -0
- package/dist/types/ids.d.ts +84 -0
- package/dist/types/ids.d.ts.map +1 -0
- package/dist/types/ids.js +27 -0
- package/dist/types/ids.js.map +1 -0
- package/dist/types/index.d.cts +25 -0
- package/dist/types/index.d.cts.map +1 -0
- package/dist/types/index.d.ts +25 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/key.d.cts +84 -0
- package/dist/types/key.d.cts.map +1 -0
- package/dist/types/key.d.ts +84 -0
- package/dist/types/key.d.ts.map +1 -0
- package/dist/types/lock.cjs +17 -0
- package/dist/types/lock.cjs.map +1 -0
- package/dist/types/lock.d.cts +92 -0
- package/dist/types/lock.d.cts.map +1 -0
- package/dist/types/lock.d.ts +92 -0
- package/dist/types/lock.d.ts.map +1 -0
- package/dist/types/lock.js +17 -0
- package/dist/types/lock.js.map +1 -0
- package/dist/types/notifications.cjs +24 -0
- package/dist/types/notifications.cjs.map +1 -0
- package/dist/types/notifications.d.cts +97 -0
- package/dist/types/notifications.d.cts.map +1 -0
- package/dist/types/notifications.d.ts +97 -0
- package/dist/types/notifications.d.ts.map +1 -0
- package/dist/types/notifications.js +24 -0
- package/dist/types/notifications.js.map +1 -0
- package/dist/types/replication.d.cts +42 -0
- package/dist/types/replication.d.cts.map +1 -0
- package/dist/types/replication.d.ts +42 -0
- package/dist/types/replication.d.ts.map +1 -0
- package/dist/types/upload.d.cts +219 -0
- package/dist/types/upload.d.cts.map +1 -0
- package/dist/types/upload.d.ts +219 -0
- package/dist/types/upload.d.ts.map +1 -0
- package/dist/upload/cancel.cjs +10 -0
- package/dist/upload/cancel.cjs.map +1 -0
- package/dist/upload/cancel.d.cts +23 -0
- package/dist/upload/cancel.d.cts.map +1 -0
- package/dist/upload/cancel.d.ts +23 -0
- package/dist/upload/cancel.d.ts.map +1 -0
- package/dist/upload/cancel.js +10 -0
- package/dist/upload/cancel.js.map +1 -0
- package/dist/upload/concurrency.cjs +54 -0
- package/dist/upload/concurrency.cjs.map +1 -0
- package/dist/upload/concurrency.d.cts +46 -0
- package/dist/upload/concurrency.d.cts.map +1 -0
- package/dist/upload/concurrency.d.ts +46 -0
- package/dist/upload/concurrency.d.ts.map +1 -0
- package/dist/upload/concurrency.js +54 -0
- package/dist/upload/concurrency.js.map +1 -0
- package/dist/upload/large.cjs +222 -0
- package/dist/upload/large.cjs.map +1 -0
- package/dist/upload/large.d.cts +71 -0
- package/dist/upload/large.d.cts.map +1 -0
- package/dist/upload/large.d.ts +71 -0
- package/dist/upload/large.d.ts.map +1 -0
- package/dist/upload/large.js +222 -0
- package/dist/upload/large.js.map +1 -0
- package/dist/upload/resume.cjs +34 -0
- package/dist/upload/resume.cjs.map +1 -0
- package/dist/upload/resume.d.cts +33 -0
- package/dist/upload/resume.d.cts.map +1 -0
- package/dist/upload/resume.d.ts +33 -0
- package/dist/upload/resume.d.ts.map +1 -0
- package/dist/upload/resume.js +34 -0
- package/dist/upload/resume.js.map +1 -0
- package/dist/upload/single.cjs +47 -0
- package/dist/upload/single.cjs.map +1 -0
- package/dist/upload/single.d.cts +51 -0
- package/dist/upload/single.d.cts.map +1 -0
- package/dist/upload/single.d.ts +51 -0
- package/dist/upload/single.d.ts.map +1 -0
- package/dist/upload/single.js +47 -0
- package/dist/upload/single.js.map +1 -0
- package/dist/upload/stream.cjs +198 -0
- package/dist/upload/stream.cjs.map +1 -0
- package/dist/upload/stream.d.cts +61 -0
- package/dist/upload/stream.d.cts.map +1 -0
- package/dist/upload/stream.d.ts +61 -0
- package/dist/upload/stream.d.ts.map +1 -0
- package/dist/upload/stream.js +198 -0
- package/dist/upload/stream.js.map +1 -0
- package/dist/util/best-effort.cjs +10 -0
- package/dist/util/best-effort.cjs.map +1 -0
- package/dist/util/best-effort.d.cts +31 -0
- package/dist/util/best-effort.d.cts.map +1 -0
- package/dist/util/best-effort.d.ts +31 -0
- package/dist/util/best-effort.d.ts.map +1 -0
- package/dist/util/best-effort.js +10 -0
- package/dist/util/best-effort.js.map +1 -0
- package/dist/util/defaults.cjs +11 -0
- package/dist/util/defaults.cjs.map +1 -0
- package/dist/util/defaults.d.cts +54 -0
- package/dist/util/defaults.d.cts.map +1 -0
- package/dist/util/defaults.d.ts +54 -0
- package/dist/util/defaults.d.ts.map +1 -0
- package/dist/util/defaults.js +11 -0
- package/dist/util/defaults.js.map +1 -0
- package/dist/util/normalize.cjs +16 -0
- package/dist/util/normalize.cjs.map +1 -0
- package/dist/util/normalize.d.cts +62 -0
- package/dist/util/normalize.d.cts.map +1 -0
- package/dist/util/normalize.d.ts +62 -0
- package/dist/util/normalize.d.ts.map +1 -0
- package/dist/util/normalize.js +16 -0
- package/dist/util/normalize.js.map +1 -0
- package/dist/util/paginator.cjs +20 -0
- package/dist/util/paginator.cjs.map +1 -0
- package/dist/util/paginator.d.cts +120 -0
- package/dist/util/paginator.d.cts.map +1 -0
- package/dist/util/paginator.d.ts +120 -0
- package/dist/util/paginator.d.ts.map +1 -0
- package/dist/util/paginator.js +20 -0
- package/dist/util/paginator.js.map +1 -0
- package/dist/util/plan-ranges.cjs +28 -0
- package/dist/util/plan-ranges.cjs.map +1 -0
- package/dist/util/plan-ranges.d.cts +56 -0
- package/dist/util/plan-ranges.d.cts.map +1 -0
- package/dist/util/plan-ranges.d.ts +56 -0
- package/dist/util/plan-ranges.d.ts.map +1 -0
- package/dist/util/plan-ranges.js +28 -0
- package/dist/util/plan-ranges.js.map +1 -0
- package/dist/util/text-codec.cjs +7 -0
- package/dist/util/text-codec.cjs.map +1 -0
- package/dist/util/text-codec.d.cts +26 -0
- package/dist/util/text-codec.d.cts.map +1 -0
- package/dist/util/text-codec.d.ts +26 -0
- package/dist/util/text-codec.d.ts.map +1 -0
- package/dist/util/text-codec.js +7 -0
- package/dist/util/text-codec.js.map +1 -0
- package/dist/util/to-error.cjs +7 -0
- package/dist/util/to-error.cjs.map +1 -0
- package/dist/util/to-error.d.cts +15 -0
- package/dist/util/to-error.d.cts.map +1 -0
- package/dist/util/to-error.d.ts +15 -0
- package/dist/util/to-error.d.ts.map +1 -0
- package/dist/util/to-error.js +7 -0
- package/dist/util/to-error.js.map +1 -0
- package/dist/version.cjs +6 -0
- package/dist/version.cjs.map +1 -0
- package/dist/version.d.cts +14 -0
- package/dist/version.d.cts.map +1 -0
- package/dist/version.d.ts +14 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +6 -0
- package/dist/version.js.map +1 -0
- package/package.json +198 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
let nodeCreateHash;
|
|
2
|
+
async function getNodeCreateHash() {
|
|
3
|
+
if (nodeCreateHash !== void 0) return nodeCreateHash;
|
|
4
|
+
try {
|
|
5
|
+
const crypto2 = await import("node:crypto");
|
|
6
|
+
if (typeof crypto2.createHash !== "function") throw new Error("createHash unavailable");
|
|
7
|
+
nodeCreateHash = (algo) => {
|
|
8
|
+
const h = crypto2.createHash(algo);
|
|
9
|
+
return {
|
|
10
|
+
update(data) {
|
|
11
|
+
h.update(data);
|
|
12
|
+
},
|
|
13
|
+
digest(encoding) {
|
|
14
|
+
return h.digest(encoding);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
} catch {
|
|
19
|
+
nodeCreateHash = null;
|
|
20
|
+
}
|
|
21
|
+
return nodeCreateHash;
|
|
22
|
+
}
|
|
23
|
+
class IncrementalSha1 {
|
|
24
|
+
/** Buffered chunks for WebCrypto fallback path. */
|
|
25
|
+
chunks = [];
|
|
26
|
+
/** Total bytes fed into the hash so far. */
|
|
27
|
+
totalLength = 0;
|
|
28
|
+
/** Node.js hash instance, or null if using WebCrypto fallback. */
|
|
29
|
+
nodeHash = null;
|
|
30
|
+
/** Resolves once the crypto backend has been loaded. */
|
|
31
|
+
initPromise;
|
|
32
|
+
/** Creates a new IncrementalSha1 and lazily initializes the crypto backend. */
|
|
33
|
+
constructor() {
|
|
34
|
+
this.initPromise = getNodeCreateHash().then((factory) => {
|
|
35
|
+
if (factory) this.nodeHash = factory("sha1");
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Feed data into the hash. Async because it lazily initializes the crypto backend.
|
|
40
|
+
* @param data - The bytes to include in the hash computation.
|
|
41
|
+
*
|
|
42
|
+
* @returns A promise that resolves once the data has been consumed.
|
|
43
|
+
*/
|
|
44
|
+
async update(data) {
|
|
45
|
+
await this.initPromise;
|
|
46
|
+
if (this.nodeHash) {
|
|
47
|
+
this.nodeHash.update(data);
|
|
48
|
+
} else {
|
|
49
|
+
this.chunks.push(new Uint8Array(data));
|
|
50
|
+
}
|
|
51
|
+
this.totalLength += data.byteLength;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Finalize the hash and return the hex-encoded SHA-1 digest.
|
|
55
|
+
* @returns The lowercase hex-encoded SHA-1 digest of all data fed so far.
|
|
56
|
+
*/
|
|
57
|
+
async digest() {
|
|
58
|
+
await this.initPromise;
|
|
59
|
+
if (this.nodeHash) {
|
|
60
|
+
return this.nodeHash.digest("hex");
|
|
61
|
+
}
|
|
62
|
+
const combined = new Uint8Array(this.totalLength);
|
|
63
|
+
let offset = 0;
|
|
64
|
+
for (const chunk of this.chunks) {
|
|
65
|
+
combined.set(chunk, offset);
|
|
66
|
+
offset += chunk.byteLength;
|
|
67
|
+
}
|
|
68
|
+
const hashBuffer = await crypto.subtle.digest("SHA-1", combined.buffer);
|
|
69
|
+
return hexEncode(new Uint8Array(hashBuffer));
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Total number of bytes fed into the hash so far.
|
|
73
|
+
*
|
|
74
|
+
* @returns The cumulative byte count across all update calls.
|
|
75
|
+
*/
|
|
76
|
+
get bytesProcessed() {
|
|
77
|
+
return this.totalLength;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function hexEncode(bytes) {
|
|
81
|
+
const hex = [];
|
|
82
|
+
for (const b of bytes) {
|
|
83
|
+
hex.push(b.toString(16).padStart(2, "0"));
|
|
84
|
+
}
|
|
85
|
+
return hex.join("");
|
|
86
|
+
}
|
|
87
|
+
async function sha1Hex(data) {
|
|
88
|
+
const factory = await getNodeCreateHash();
|
|
89
|
+
if (factory) {
|
|
90
|
+
const h = factory("sha1");
|
|
91
|
+
h.update(data);
|
|
92
|
+
return h.digest("hex");
|
|
93
|
+
}
|
|
94
|
+
const hashBuffer = await crypto.subtle.digest("SHA-1", data.buffer);
|
|
95
|
+
return hexEncode(new Uint8Array(hashBuffer));
|
|
96
|
+
}
|
|
97
|
+
export {
|
|
98
|
+
IncrementalSha1,
|
|
99
|
+
sha1Hex
|
|
100
|
+
};
|
|
101
|
+
//# sourceMappingURL=hash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash.js","sources":["../../src/streams/hash.ts"],"sourcesContent":["/** Internal wrapper around a Node.js Hash instance. */\ntype NodeHasher = { update(data: Uint8Array): void; digest(encoding: string): string }\n\n/** Factory that creates a NodeHasher for a given algorithm name. */\ntype NodeHashFactory = (algorithm: string) => NodeHasher\n\nlet nodeCreateHash: NodeHashFactory | null | undefined\n\n/**\n * Lazily loads `node:crypto` and caches the factory. Returns null in non-Node runtimes.\n *\n * @returns The cached hash factory, or null if Node crypto is unavailable.\n */\nasync function getNodeCreateHash(): Promise<NodeHashFactory | null> {\n if (nodeCreateHash !== undefined) return nodeCreateHash\n try {\n // @ts-ignore -- node:crypto may not exist in browser/edge runtimes\n const crypto = await import('node:crypto')\n // Vite's browser shim resolves the import but does not implement\n // `createHash`. Probe explicitly so we fall through to the WebCrypto\n // path instead of returning a broken factory.\n if (typeof crypto.createHash !== 'function') throw new Error('createHash unavailable')\n nodeCreateHash = (algo: string) => {\n const h = crypto.createHash(algo)\n return {\n update(data: Uint8Array) {\n h.update(data)\n },\n digest(encoding: string) {\n return h.digest(encoding as 'hex') as string\n },\n }\n }\n /* v8 ignore next 3 -- non-Node runtime fallback, unreachable in Node tests */\n } catch {\n nodeCreateHash = null\n }\n return nodeCreateHash\n}\n\n/**\n * Incrementally computes SHA-1 hashes over streaming data.\n * Uses Node.js `crypto` when available, falling back to WebCrypto.\n */\nexport class IncrementalSha1 {\n /** Buffered chunks for WebCrypto fallback path. */\n private chunks: Uint8Array[] = []\n /** Total bytes fed into the hash so far. */\n private totalLength = 0\n /** Node.js hash instance, or null if using WebCrypto fallback. */\n private nodeHash: NodeHasher | null = null\n /** Resolves once the crypto backend has been loaded. */\n private initPromise: Promise<void>\n\n /** Creates a new IncrementalSha1 and lazily initializes the crypto backend. */\n constructor() {\n this.initPromise = getNodeCreateHash().then((factory) => {\n if (factory) this.nodeHash = factory('sha1')\n })\n }\n\n /**\n * Feed data into the hash. Async because it lazily initializes the crypto backend.\n * @param data - The bytes to include in the hash computation.\n *\n * @returns A promise that resolves once the data has been consumed.\n */\n async update(data: Uint8Array): Promise<void> {\n await this.initPromise\n if (this.nodeHash) {\n this.nodeHash.update(data)\n } else {\n this.chunks.push(new Uint8Array(data))\n }\n this.totalLength += data.byteLength\n }\n\n /**\n * Finalize the hash and return the hex-encoded SHA-1 digest.\n * @returns The lowercase hex-encoded SHA-1 digest of all data fed so far.\n */\n async digest(): Promise<string> {\n await this.initPromise\n if (this.nodeHash) {\n return this.nodeHash.digest('hex')\n }\n\n /* v8 ignore start -- WebCrypto fallback path, only reachable when node:crypto is unavailable */\n const combined = new Uint8Array(this.totalLength)\n let offset = 0\n for (const chunk of this.chunks) {\n combined.set(chunk, offset)\n offset += chunk.byteLength\n }\n\n const hashBuffer = await crypto.subtle.digest('SHA-1', combined.buffer as ArrayBuffer)\n return hexEncode(new Uint8Array(hashBuffer))\n /* v8 ignore stop */\n }\n\n /**\n * Total number of bytes fed into the hash so far.\n *\n * @returns The cumulative byte count across all update calls.\n */\n get bytesProcessed(): number {\n return this.totalLength\n }\n}\n\n/* v8 ignore start -- WebCrypto fallback path, only reachable when node:crypto is unavailable (browser/edge runtimes) */\n/**\n * Convert a byte array to a lowercase hex string.\n * @param bytes - The raw bytes to encode as hexadecimal characters.\n *\n * @returns The lowercase hex-encoded string representation of the input bytes.\n */\nfunction hexEncode(bytes: Uint8Array): string {\n const hex: string[] = []\n for (const b of bytes) {\n hex.push(b.toString(16).padStart(2, '0'))\n }\n return hex.join('')\n}\n/* v8 ignore stop */\n\n/**\n * Compute the SHA-1 hex digest of a complete byte array in one shot.\n * @param data - The byte array to hash.\n *\n * @returns The lowercase hex-encoded SHA-1 digest of the input.\n */\nexport async function sha1Hex(data: Uint8Array): Promise<string> {\n const factory = await getNodeCreateHash()\n if (factory) {\n const h = factory('sha1')\n h.update(data)\n return h.digest('hex')\n }\n /* v8 ignore next 2 -- WebCrypto fallback, only reachable when node:crypto is unavailable */\n const hashBuffer = await crypto.subtle.digest('SHA-1', data.buffer as ArrayBuffer)\n return hexEncode(new Uint8Array(hashBuffer))\n}\n"],"names":["crypto"],"mappings":"AAMA,IAAI;AAOJ,eAAe,oBAAqD;AAClE,MAAI,mBAAmB,OAAW,QAAO;AACzC,MAAI;AAEF,UAAMA,UAAS,MAAM,OAAO,aAAa;AAIzC,QAAI,OAAOA,QAAO,eAAe,WAAY,OAAM,IAAI,MAAM,wBAAwB;AACrF,qBAAiB,CAAC,SAAiB;AACjC,YAAM,IAAIA,QAAO,WAAW,IAAI;AAChC,aAAO;AAAA,QACL,OAAO,MAAkB;AACvB,YAAE,OAAO,IAAI;AAAA,QACf;AAAA,QACA,OAAO,UAAkB;AACvB,iBAAO,EAAE,OAAO,QAAiB;AAAA,QACnC;AAAA,MAAA;AAAA,IAEJ;AAAA,EAEF,QAAQ;AACN,qBAAiB;AAAA,EACnB;AACA,SAAO;AACT;AAMO,MAAM,gBAAgB;AAAA;AAAA,EAEnB,SAAuB,CAAA;AAAA;AAAA,EAEvB,cAAc;AAAA;AAAA,EAEd,WAA8B;AAAA;AAAA,EAE9B;AAAA;AAAA,EAGR,cAAc;AACZ,SAAK,cAAc,kBAAA,EAAoB,KAAK,CAAC,YAAY;AACvD,UAAI,QAAS,MAAK,WAAW,QAAQ,MAAM;AAAA,IAC7C,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,OAAO,MAAiC;AAC5C,UAAM,KAAK;AACX,QAAI,KAAK,UAAU;AACjB,WAAK,SAAS,OAAO,IAAI;AAAA,IAC3B,OAAO;AACL,WAAK,OAAO,KAAK,IAAI,WAAW,IAAI,CAAC;AAAA,IACvC;AACA,SAAK,eAAe,KAAK;AAAA,EAC3B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,SAA0B;AAC9B,UAAM,KAAK;AACX,QAAI,KAAK,UAAU;AACjB,aAAO,KAAK,SAAS,OAAO,KAAK;AAAA,IACnC;AAGA,UAAM,WAAW,IAAI,WAAW,KAAK,WAAW;AAChD,QAAI,SAAS;AACb,eAAW,SAAS,KAAK,QAAQ;AAC/B,eAAS,IAAI,OAAO,MAAM;AAC1B,gBAAU,MAAM;AAAA,IAClB;AAEA,UAAM,aAAa,MAAM,OAAO,OAAO,OAAO,SAAS,SAAS,MAAqB;AACrF,WAAO,UAAU,IAAI,WAAW,UAAU,CAAC;AAAA,EAE7C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,IAAI,iBAAyB;AAC3B,WAAO,KAAK;AAAA,EACd;AACF;AASA,SAAS,UAAU,OAA2B;AAC5C,QAAM,MAAgB,CAAA;AACtB,aAAW,KAAK,OAAO;AACrB,QAAI,KAAK,EAAE,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,CAAC;AAAA,EAC1C;AACA,SAAO,IAAI,KAAK,EAAE;AACpB;AASA,eAAsB,QAAQ,MAAmC;AAC/D,QAAM,UAAU,MAAM,kBAAA;AACtB,MAAI,SAAS;AACX,UAAM,IAAI,QAAQ,MAAM;AACxB,MAAE,OAAO,IAAI;AACb,WAAO,EAAE,OAAO,KAAK;AAAA,EACvB;AAEA,QAAM,aAAa,MAAM,OAAO,OAAO,OAAO,SAAS,KAAK,MAAqB;AACjF,SAAO,UAAU,IAAI,WAAW,UAAU,CAAC;AAC7C;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const hash = require("./hash.cjs");
|
|
4
|
+
const source = require("./source.cjs");
|
|
5
|
+
const encryption = require("../types/encryption.cjs");
|
|
6
|
+
exports.IncrementalSha1 = hash.IncrementalSha1;
|
|
7
|
+
exports.sha1Hex = hash.sha1Hex;
|
|
8
|
+
exports.BlobSource = source.BlobSource;
|
|
9
|
+
exports.BufferSource = source.BufferSource;
|
|
10
|
+
exports.StreamSource = source.StreamSource;
|
|
11
|
+
exports.toContentSource = source.toContentSource;
|
|
12
|
+
exports.EncryptionKey = encryption.EncryptionKey;
|
|
13
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** @packageDocumentation */
|
|
2
|
+
export { IncrementalSha1, sha1Hex } from './hash.js';
|
|
3
|
+
export type { ProgressEvent, ProgressListener } from './progress.js';
|
|
4
|
+
export type { ContentSource } from './source.js';
|
|
5
|
+
export { BlobSource, BufferSource, StreamSource, toContentSource } from './source.js';
|
|
6
|
+
export { EncryptionKey } from '../types/encryption.js';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/streams/index.js"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACpD,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AACpE,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAMrF,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** @packageDocumentation */
|
|
2
|
+
export { IncrementalSha1, sha1Hex } from './hash.js';
|
|
3
|
+
export type { ProgressEvent, ProgressListener } from './progress.js';
|
|
4
|
+
export type { ContentSource } from './source.js';
|
|
5
|
+
export { BlobSource, BufferSource, StreamSource, toContentSource } from './source.js';
|
|
6
|
+
export { EncryptionKey } from '../types/encryption.js';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/streams/index.js"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACpD,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AACpE,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAMrF,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IncrementalSha1, sha1Hex } from "./hash.js";
|
|
2
|
+
import { BlobSource, BufferSource, StreamSource, toContentSource } from "./source.js";
|
|
3
|
+
import { EncryptionKey } from "../types/encryption.js";
|
|
4
|
+
export {
|
|
5
|
+
BlobSource,
|
|
6
|
+
BufferSource,
|
|
7
|
+
EncryptionKey,
|
|
8
|
+
IncrementalSha1,
|
|
9
|
+
StreamSource,
|
|
10
|
+
sha1Hex,
|
|
11
|
+
toContentSource
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
class ProgressTracker {
|
|
4
|
+
/**
|
|
5
|
+
* Creates a new ProgressTracker.
|
|
6
|
+
* @param listener - Callback to receive progress events, or undefined to disable.
|
|
7
|
+
* @param totalBytes - Expected total bytes, or null if unknown.
|
|
8
|
+
* @param totalParts - Expected total parts, or null if not a multipart transfer.
|
|
9
|
+
*/
|
|
10
|
+
constructor(listener, totalBytes, totalParts) {
|
|
11
|
+
this.listener = listener;
|
|
12
|
+
this.totalBytes = totalBytes;
|
|
13
|
+
this.totalParts = totalParts;
|
|
14
|
+
this.startTime = Date.now();
|
|
15
|
+
}
|
|
16
|
+
/** Running total of bytes transferred. */
|
|
17
|
+
bytesTransferred = 0;
|
|
18
|
+
/** Running count of completed parts. */
|
|
19
|
+
partsCompleted = 0;
|
|
20
|
+
/** Timestamp when tracking began. */
|
|
21
|
+
startTime;
|
|
22
|
+
/**
|
|
23
|
+
* Record that additional bytes have been transferred and notify the listener.
|
|
24
|
+
* @param count - The number of additional bytes that were transferred.
|
|
25
|
+
*/
|
|
26
|
+
addBytes(count) {
|
|
27
|
+
this.bytesTransferred += count;
|
|
28
|
+
this.emit();
|
|
29
|
+
}
|
|
30
|
+
/** Record that a multipart part has completed and notify the listener. */
|
|
31
|
+
completePart() {
|
|
32
|
+
this.partsCompleted++;
|
|
33
|
+
this.emit();
|
|
34
|
+
}
|
|
35
|
+
/** Emit the current progress snapshot to the listener, if one is registered. */
|
|
36
|
+
emit() {
|
|
37
|
+
this.listener?.({
|
|
38
|
+
bytesTransferred: this.bytesTransferred,
|
|
39
|
+
totalBytes: this.totalBytes,
|
|
40
|
+
partsCompleted: this.partsCompleted,
|
|
41
|
+
totalParts: this.totalParts,
|
|
42
|
+
elapsedMs: Date.now() - this.startTime
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.ProgressTracker = ProgressTracker;
|
|
47
|
+
//# sourceMappingURL=progress.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.cjs","sources":["../../src/streams/progress.ts"],"sourcesContent":["/** Snapshot of upload or download progress at a point in time. */\nexport interface ProgressEvent {\n /** Number of bytes transferred so far. */\n readonly bytesTransferred: number\n /** Total bytes expected, or null if unknown. */\n readonly totalBytes: number | null\n /** Number of multipart parts completed so far. */\n readonly partsCompleted: number\n /** Total number of parts expected, or null if unknown. */\n readonly totalParts: number | null\n /** Milliseconds elapsed since the operation started. */\n readonly elapsedMs: number\n}\n\n/** Callback invoked each time transfer progress changes. */\nexport type ProgressListener = (event: ProgressEvent) => void\n\n/**\n * Accumulates byte and part counts and emits {@link ProgressEvent}s to a listener.\n *\n * Internal building block. The SDK wires one of these inside every\n * transfer that accepts an `onProgress` option; users supply the\n * listener callback, not the tracker. Exported only so SDK source\n * modules can import it; not re-exported through any subpath.\n *\n * @internal\n */\nexport class ProgressTracker {\n /** Running total of bytes transferred. */\n private bytesTransferred = 0\n /** Running count of completed parts. */\n private partsCompleted = 0\n /** Timestamp when tracking began. */\n private readonly startTime: number\n\n /**\n * Creates a new ProgressTracker.\n * @param listener - Callback to receive progress events, or undefined to disable.\n * @param totalBytes - Expected total bytes, or null if unknown.\n * @param totalParts - Expected total parts, or null if not a multipart transfer.\n */\n constructor(\n private readonly listener: ProgressListener | undefined,\n private readonly totalBytes: number | null,\n private readonly totalParts: number | null,\n ) {\n this.startTime = Date.now()\n }\n\n /**\n * Record that additional bytes have been transferred and notify the listener.\n * @param count - The number of additional bytes that were transferred.\n */\n addBytes(count: number): void {\n this.bytesTransferred += count\n this.emit()\n }\n\n /** Record that a multipart part has completed and notify the listener. */\n completePart(): void {\n this.partsCompleted++\n this.emit()\n }\n\n /** Emit the current progress snapshot to the listener, if one is registered. */\n private emit(): void {\n this.listener?.({\n bytesTransferred: this.bytesTransferred,\n totalBytes: this.totalBytes,\n partsCompleted: this.partsCompleted,\n totalParts: this.totalParts,\n elapsedMs: Date.now() - this.startTime,\n })\n }\n}\n"],"names":[],"mappings":";;AA2BO,MAAM,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAc3B,YACmB,UACA,YACA,YACjB;AAHiB,SAAA,WAAA;AACA,SAAA,aAAA;AACA,SAAA,aAAA;AAEjB,SAAK,YAAY,KAAK,IAAA;AAAA,EACxB;AAAA;AAAA,EAlBQ,mBAAmB;AAAA;AAAA,EAEnB,iBAAiB;AAAA;AAAA,EAER;AAAA;AAAA;AAAA;AAAA;AAAA,EAoBjB,SAAS,OAAqB;AAC5B,SAAK,oBAAoB;AACzB,SAAK,KAAA;AAAA,EACP;AAAA;AAAA,EAGA,eAAqB;AACnB,SAAK;AACL,SAAK,KAAA;AAAA,EACP;AAAA;AAAA,EAGQ,OAAa;AACnB,SAAK,WAAW;AAAA,MACd,kBAAkB,KAAK;AAAA,MACvB,YAAY,KAAK;AAAA,MACjB,gBAAgB,KAAK;AAAA,MACrB,YAAY,KAAK;AAAA,MACjB,WAAW,KAAK,IAAA,IAAQ,KAAK;AAAA,IAAA,CAC9B;AAAA,EACH;AACF;;"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/** Snapshot of upload or download progress at a point in time. */
|
|
2
|
+
export interface ProgressEvent {
|
|
3
|
+
/** Number of bytes transferred so far. */
|
|
4
|
+
readonly bytesTransferred: number;
|
|
5
|
+
/** Total bytes expected, or null if unknown. */
|
|
6
|
+
readonly totalBytes: number | null;
|
|
7
|
+
/** Number of multipart parts completed so far. */
|
|
8
|
+
readonly partsCompleted: number;
|
|
9
|
+
/** Total number of parts expected, or null if unknown. */
|
|
10
|
+
readonly totalParts: number | null;
|
|
11
|
+
/** Milliseconds elapsed since the operation started. */
|
|
12
|
+
readonly elapsedMs: number;
|
|
13
|
+
}
|
|
14
|
+
/** Callback invoked each time transfer progress changes. */
|
|
15
|
+
export type ProgressListener = (event: ProgressEvent) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Accumulates byte and part counts and emits {@link ProgressEvent}s to a listener.
|
|
18
|
+
*
|
|
19
|
+
* Internal building block. The SDK wires one of these inside every
|
|
20
|
+
* transfer that accepts an `onProgress` option; users supply the
|
|
21
|
+
* listener callback, not the tracker. Exported only so SDK source
|
|
22
|
+
* modules can import it; not re-exported through any subpath.
|
|
23
|
+
*
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
export declare class ProgressTracker {
|
|
27
|
+
private readonly listener;
|
|
28
|
+
private readonly totalBytes;
|
|
29
|
+
private readonly totalParts;
|
|
30
|
+
/** Running total of bytes transferred. */
|
|
31
|
+
private bytesTransferred;
|
|
32
|
+
/** Running count of completed parts. */
|
|
33
|
+
private partsCompleted;
|
|
34
|
+
/** Timestamp when tracking began. */
|
|
35
|
+
private readonly startTime;
|
|
36
|
+
/**
|
|
37
|
+
* Creates a new ProgressTracker.
|
|
38
|
+
* @param listener - Callback to receive progress events, or undefined to disable.
|
|
39
|
+
* @param totalBytes - Expected total bytes, or null if unknown.
|
|
40
|
+
* @param totalParts - Expected total parts, or null if not a multipart transfer.
|
|
41
|
+
*/
|
|
42
|
+
constructor(listener: ProgressListener | undefined, totalBytes: number | null, totalParts: number | null);
|
|
43
|
+
/**
|
|
44
|
+
* Record that additional bytes have been transferred and notify the listener.
|
|
45
|
+
* @param count - The number of additional bytes that were transferred.
|
|
46
|
+
*/
|
|
47
|
+
addBytes(count: number): void;
|
|
48
|
+
/** Record that a multipart part has completed and notify the listener. */
|
|
49
|
+
completePart(): void;
|
|
50
|
+
/** Emit the current progress snapshot to the listener, if one is registered. */
|
|
51
|
+
private emit;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=progress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../../src/streams/progress.js"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,MAAM,WAAW,aAAa;IAC5B,0CAA0C;IAC1C,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAA;IACjC,gDAAgD;IAChD,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IAClC,kDAAkD;IAClD,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;IAC/B,0DAA0D;IAC1D,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IAClC,wDAAwD;IACxD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;CAC3B;AAED,4DAA4D;AAC5D,MAAM,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAA;AAE7D;;;;;;;;;GASG;AACH,qBAAa,eAAe;IAexB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,UAAU;IAhB7B,0CAA0C;IAC1C,OAAO,CAAC,gBAAgB,CAAI;IAC5B,wCAAwC;IACxC,OAAO,CAAC,cAAc,CAAI;IAC1B,qCAAqC;IACrC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAQ;IAElC;;;;;OAKG;gBAEgB,QAAQ,EAAE,gBAAgB,GAAG,SAAS,EACtC,UAAU,EAAE,MAAM,GAAG,IAAI,EACzB,UAAU,EAAE,MAAM,GAAG,IAAI;IAK5C;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK7B,0EAA0E;IAC1E,YAAY,IAAI,IAAI;IAKpB,gFAAgF;IAChF,OAAO,CAAC,IAAI;CASb"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/** Snapshot of upload or download progress at a point in time. */
|
|
2
|
+
export interface ProgressEvent {
|
|
3
|
+
/** Number of bytes transferred so far. */
|
|
4
|
+
readonly bytesTransferred: number;
|
|
5
|
+
/** Total bytes expected, or null if unknown. */
|
|
6
|
+
readonly totalBytes: number | null;
|
|
7
|
+
/** Number of multipart parts completed so far. */
|
|
8
|
+
readonly partsCompleted: number;
|
|
9
|
+
/** Total number of parts expected, or null if unknown. */
|
|
10
|
+
readonly totalParts: number | null;
|
|
11
|
+
/** Milliseconds elapsed since the operation started. */
|
|
12
|
+
readonly elapsedMs: number;
|
|
13
|
+
}
|
|
14
|
+
/** Callback invoked each time transfer progress changes. */
|
|
15
|
+
export type ProgressListener = (event: ProgressEvent) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Accumulates byte and part counts and emits {@link ProgressEvent}s to a listener.
|
|
18
|
+
*
|
|
19
|
+
* Internal building block. The SDK wires one of these inside every
|
|
20
|
+
* transfer that accepts an `onProgress` option; users supply the
|
|
21
|
+
* listener callback, not the tracker. Exported only so SDK source
|
|
22
|
+
* modules can import it; not re-exported through any subpath.
|
|
23
|
+
*
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
export declare class ProgressTracker {
|
|
27
|
+
private readonly listener;
|
|
28
|
+
private readonly totalBytes;
|
|
29
|
+
private readonly totalParts;
|
|
30
|
+
/** Running total of bytes transferred. */
|
|
31
|
+
private bytesTransferred;
|
|
32
|
+
/** Running count of completed parts. */
|
|
33
|
+
private partsCompleted;
|
|
34
|
+
/** Timestamp when tracking began. */
|
|
35
|
+
private readonly startTime;
|
|
36
|
+
/**
|
|
37
|
+
* Creates a new ProgressTracker.
|
|
38
|
+
* @param listener - Callback to receive progress events, or undefined to disable.
|
|
39
|
+
* @param totalBytes - Expected total bytes, or null if unknown.
|
|
40
|
+
* @param totalParts - Expected total parts, or null if not a multipart transfer.
|
|
41
|
+
*/
|
|
42
|
+
constructor(listener: ProgressListener | undefined, totalBytes: number | null, totalParts: number | null);
|
|
43
|
+
/**
|
|
44
|
+
* Record that additional bytes have been transferred and notify the listener.
|
|
45
|
+
* @param count - The number of additional bytes that were transferred.
|
|
46
|
+
*/
|
|
47
|
+
addBytes(count: number): void;
|
|
48
|
+
/** Record that a multipart part has completed and notify the listener. */
|
|
49
|
+
completePart(): void;
|
|
50
|
+
/** Emit the current progress snapshot to the listener, if one is registered. */
|
|
51
|
+
private emit;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=progress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../../src/streams/progress.js"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,MAAM,WAAW,aAAa;IAC5B,0CAA0C;IAC1C,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAA;IACjC,gDAAgD;IAChD,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IAClC,kDAAkD;IAClD,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;IAC/B,0DAA0D;IAC1D,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IAClC,wDAAwD;IACxD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;CAC3B;AAED,4DAA4D;AAC5D,MAAM,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAA;AAE7D;;;;;;;;;GASG;AACH,qBAAa,eAAe;IAexB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,UAAU;IAhB7B,0CAA0C;IAC1C,OAAO,CAAC,gBAAgB,CAAI;IAC5B,wCAAwC;IACxC,OAAO,CAAC,cAAc,CAAI;IAC1B,qCAAqC;IACrC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAQ;IAElC;;;;;OAKG;gBAEgB,QAAQ,EAAE,gBAAgB,GAAG,SAAS,EACtC,UAAU,EAAE,MAAM,GAAG,IAAI,EACzB,UAAU,EAAE,MAAM,GAAG,IAAI;IAK5C;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK7B,0EAA0E;IAC1E,YAAY,IAAI,IAAI;IAKpB,gFAAgF;IAChF,OAAO,CAAC,IAAI;CASb"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
class ProgressTracker {
|
|
2
|
+
/**
|
|
3
|
+
* Creates a new ProgressTracker.
|
|
4
|
+
* @param listener - Callback to receive progress events, or undefined to disable.
|
|
5
|
+
* @param totalBytes - Expected total bytes, or null if unknown.
|
|
6
|
+
* @param totalParts - Expected total parts, or null if not a multipart transfer.
|
|
7
|
+
*/
|
|
8
|
+
constructor(listener, totalBytes, totalParts) {
|
|
9
|
+
this.listener = listener;
|
|
10
|
+
this.totalBytes = totalBytes;
|
|
11
|
+
this.totalParts = totalParts;
|
|
12
|
+
this.startTime = Date.now();
|
|
13
|
+
}
|
|
14
|
+
/** Running total of bytes transferred. */
|
|
15
|
+
bytesTransferred = 0;
|
|
16
|
+
/** Running count of completed parts. */
|
|
17
|
+
partsCompleted = 0;
|
|
18
|
+
/** Timestamp when tracking began. */
|
|
19
|
+
startTime;
|
|
20
|
+
/**
|
|
21
|
+
* Record that additional bytes have been transferred and notify the listener.
|
|
22
|
+
* @param count - The number of additional bytes that were transferred.
|
|
23
|
+
*/
|
|
24
|
+
addBytes(count) {
|
|
25
|
+
this.bytesTransferred += count;
|
|
26
|
+
this.emit();
|
|
27
|
+
}
|
|
28
|
+
/** Record that a multipart part has completed and notify the listener. */
|
|
29
|
+
completePart() {
|
|
30
|
+
this.partsCompleted++;
|
|
31
|
+
this.emit();
|
|
32
|
+
}
|
|
33
|
+
/** Emit the current progress snapshot to the listener, if one is registered. */
|
|
34
|
+
emit() {
|
|
35
|
+
this.listener?.({
|
|
36
|
+
bytesTransferred: this.bytesTransferred,
|
|
37
|
+
totalBytes: this.totalBytes,
|
|
38
|
+
partsCompleted: this.partsCompleted,
|
|
39
|
+
totalParts: this.totalParts,
|
|
40
|
+
elapsedMs: Date.now() - this.startTime
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export {
|
|
45
|
+
ProgressTracker
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=progress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.js","sources":["../../src/streams/progress.ts"],"sourcesContent":["/** Snapshot of upload or download progress at a point in time. */\nexport interface ProgressEvent {\n /** Number of bytes transferred so far. */\n readonly bytesTransferred: number\n /** Total bytes expected, or null if unknown. */\n readonly totalBytes: number | null\n /** Number of multipart parts completed so far. */\n readonly partsCompleted: number\n /** Total number of parts expected, or null if unknown. */\n readonly totalParts: number | null\n /** Milliseconds elapsed since the operation started. */\n readonly elapsedMs: number\n}\n\n/** Callback invoked each time transfer progress changes. */\nexport type ProgressListener = (event: ProgressEvent) => void\n\n/**\n * Accumulates byte and part counts and emits {@link ProgressEvent}s to a listener.\n *\n * Internal building block. The SDK wires one of these inside every\n * transfer that accepts an `onProgress` option; users supply the\n * listener callback, not the tracker. Exported only so SDK source\n * modules can import it; not re-exported through any subpath.\n *\n * @internal\n */\nexport class ProgressTracker {\n /** Running total of bytes transferred. */\n private bytesTransferred = 0\n /** Running count of completed parts. */\n private partsCompleted = 0\n /** Timestamp when tracking began. */\n private readonly startTime: number\n\n /**\n * Creates a new ProgressTracker.\n * @param listener - Callback to receive progress events, or undefined to disable.\n * @param totalBytes - Expected total bytes, or null if unknown.\n * @param totalParts - Expected total parts, or null if not a multipart transfer.\n */\n constructor(\n private readonly listener: ProgressListener | undefined,\n private readonly totalBytes: number | null,\n private readonly totalParts: number | null,\n ) {\n this.startTime = Date.now()\n }\n\n /**\n * Record that additional bytes have been transferred and notify the listener.\n * @param count - The number of additional bytes that were transferred.\n */\n addBytes(count: number): void {\n this.bytesTransferred += count\n this.emit()\n }\n\n /** Record that a multipart part has completed and notify the listener. */\n completePart(): void {\n this.partsCompleted++\n this.emit()\n }\n\n /** Emit the current progress snapshot to the listener, if one is registered. */\n private emit(): void {\n this.listener?.({\n bytesTransferred: this.bytesTransferred,\n totalBytes: this.totalBytes,\n partsCompleted: this.partsCompleted,\n totalParts: this.totalParts,\n elapsedMs: Date.now() - this.startTime,\n })\n }\n}\n"],"names":[],"mappings":"AA2BO,MAAM,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAc3B,YACmB,UACA,YACA,YACjB;AAHiB,SAAA,WAAA;AACA,SAAA,aAAA;AACA,SAAA,aAAA;AAEjB,SAAK,YAAY,KAAK,IAAA;AAAA,EACxB;AAAA;AAAA,EAlBQ,mBAAmB;AAAA;AAAA,EAEnB,iBAAiB;AAAA;AAAA,EAER;AAAA;AAAA;AAAA;AAAA;AAAA,EAoBjB,SAAS,OAAqB;AAC5B,SAAK,oBAAoB;AACzB,SAAK,KAAA;AAAA,EACP;AAAA;AAAA,EAGA,eAAqB;AACnB,SAAK;AACL,SAAK,KAAA;AAAA,EACP;AAAA;AAAA,EAGQ,OAAa;AACnB,SAAK,WAAW;AAAA,MACd,kBAAkB,KAAK;AAAA,MACvB,YAAY,KAAK;AAAA,MACjB,gBAAgB,KAAK;AAAA,MACrB,YAAY,KAAK;AAAA,MACjB,WAAW,KAAK,IAAA,IAAQ,KAAK;AAAA,IAAA,CAC9B;AAAA,EACH;AACF;"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const collect = require("./collect.cjs");
|
|
4
|
+
class BlobSource {
|
|
5
|
+
/**
|
|
6
|
+
* Create a BlobSource wrapping the given Blob.
|
|
7
|
+
* @param blob - The Blob or File to use as the underlying content.
|
|
8
|
+
*/
|
|
9
|
+
constructor(blob) {
|
|
10
|
+
this.blob = blob;
|
|
11
|
+
this.size = blob.size;
|
|
12
|
+
}
|
|
13
|
+
/** {@inheritDoc} */
|
|
14
|
+
size;
|
|
15
|
+
/** Random-access: `Blob.slice()` is cheap and returns a new Blob view. */
|
|
16
|
+
canSlice = true;
|
|
17
|
+
/**
|
|
18
|
+
* Return a new BlobSource covering the specified byte range.
|
|
19
|
+
* @param start - The zero-based byte offset to begin the slice.
|
|
20
|
+
* @param end - The exclusive byte offset where the slice ends.
|
|
21
|
+
*
|
|
22
|
+
* @returns A new ContentSource representing the requested sub-range.
|
|
23
|
+
*/
|
|
24
|
+
slice(start, end) {
|
|
25
|
+
return new BlobSource(this.blob.slice(start, end));
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Open the Blob content as a ReadableStream.
|
|
29
|
+
* @returns A ReadableStream of the Blob bytes.
|
|
30
|
+
*/
|
|
31
|
+
stream() {
|
|
32
|
+
return this.blob.stream();
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Read the entire Blob content into an ArrayBuffer.
|
|
36
|
+
* @returns A promise that resolves with the full content as an ArrayBuffer.
|
|
37
|
+
*/
|
|
38
|
+
toArrayBuffer() {
|
|
39
|
+
return this.blob.arrayBuffer();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
class BufferSource {
|
|
43
|
+
/**
|
|
44
|
+
* Create a BufferSource wrapping the given Uint8Array.
|
|
45
|
+
* @param buffer - The byte buffer to use as the underlying content.
|
|
46
|
+
*/
|
|
47
|
+
constructor(buffer) {
|
|
48
|
+
this.buffer = buffer;
|
|
49
|
+
this.size = buffer.byteLength;
|
|
50
|
+
}
|
|
51
|
+
/** {@inheritDoc} */
|
|
52
|
+
size;
|
|
53
|
+
/** Random-access: the entire payload lives in memory. */
|
|
54
|
+
canSlice = true;
|
|
55
|
+
/**
|
|
56
|
+
* Return a new BufferSource covering the specified byte range.
|
|
57
|
+
* @param start - The zero-based byte offset to begin the slice.
|
|
58
|
+
* @param end - The exclusive byte offset where the slice ends.
|
|
59
|
+
*
|
|
60
|
+
* @returns A new ContentSource representing the requested sub-range.
|
|
61
|
+
*/
|
|
62
|
+
slice(start, end) {
|
|
63
|
+
return new BufferSource(this.buffer.slice(start, end));
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Open the buffer content as a ReadableStream.
|
|
67
|
+
* @returns A ReadableStream that emits the buffer bytes in a single chunk.
|
|
68
|
+
*/
|
|
69
|
+
stream() {
|
|
70
|
+
const buffer = this.buffer;
|
|
71
|
+
return new ReadableStream({
|
|
72
|
+
start(controller) {
|
|
73
|
+
controller.enqueue(buffer);
|
|
74
|
+
controller.close();
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Read the entire buffer content into an ArrayBuffer.
|
|
80
|
+
* @returns A promise that resolves with the full content as an ArrayBuffer.
|
|
81
|
+
*/
|
|
82
|
+
toArrayBuffer() {
|
|
83
|
+
return Promise.resolve(
|
|
84
|
+
this.buffer.buffer.slice(
|
|
85
|
+
this.buffer.byteOffset,
|
|
86
|
+
this.buffer.byteOffset + this.buffer.byteLength
|
|
87
|
+
)
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
class StreamSource {
|
|
92
|
+
/**
|
|
93
|
+
* Create a StreamSource wrapping the given ReadableStream with a known byte size.
|
|
94
|
+
* @param readable - The ReadableStream to wrap as a content source.
|
|
95
|
+
* @param size - The total number of bytes the stream will produce.
|
|
96
|
+
*/
|
|
97
|
+
constructor(readable, size) {
|
|
98
|
+
this.readable = readable;
|
|
99
|
+
this.size = size;
|
|
100
|
+
}
|
|
101
|
+
/** {@inheritDoc} */
|
|
102
|
+
size;
|
|
103
|
+
/**
|
|
104
|
+
* Forward-only: ReadableStreams cannot be repositioned, so multipart
|
|
105
|
+
* uploads must take the sequential path. See the interface comment on
|
|
106
|
+
* `canSlice` for what the engine does with this flag.
|
|
107
|
+
*/
|
|
108
|
+
canSlice = false;
|
|
109
|
+
/** Whether the stream has already been read. */
|
|
110
|
+
consumed = false;
|
|
111
|
+
/**
|
|
112
|
+
* Always throws because streams cannot be sliced. Buffer the stream first.
|
|
113
|
+
*
|
|
114
|
+
* @throws If slicing is attempted on a stream-backed source.
|
|
115
|
+
*/
|
|
116
|
+
slice() {
|
|
117
|
+
throw new Error("StreamSource does not support slicing. Buffer the stream first.");
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Open the underlying ReadableStream. Can only be called once.
|
|
121
|
+
* @returns The underlying ReadableStream of bytes.
|
|
122
|
+
*
|
|
123
|
+
* @throws If the stream has already been consumed.
|
|
124
|
+
*/
|
|
125
|
+
stream() {
|
|
126
|
+
if (this.consumed) throw new Error("StreamSource can only be consumed once.");
|
|
127
|
+
this.consumed = true;
|
|
128
|
+
return this.readable;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Read the entire stream into an ArrayBuffer.
|
|
132
|
+
* @returns A promise that resolves with the full content as an ArrayBuffer.
|
|
133
|
+
*/
|
|
134
|
+
async toArrayBuffer() {
|
|
135
|
+
const bytes = await collect.collectStream(this.stream());
|
|
136
|
+
return bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
function toContentSource(input, size) {
|
|
140
|
+
if (input instanceof Uint8Array) {
|
|
141
|
+
return new BufferSource(input);
|
|
142
|
+
}
|
|
143
|
+
if (input instanceof Blob) {
|
|
144
|
+
return new BlobSource(input);
|
|
145
|
+
}
|
|
146
|
+
if (size === void 0) {
|
|
147
|
+
throw new Error("size is required when using a ReadableStream as input.");
|
|
148
|
+
}
|
|
149
|
+
return new StreamSource(input, size);
|
|
150
|
+
}
|
|
151
|
+
exports.BlobSource = BlobSource;
|
|
152
|
+
exports.BufferSource = BufferSource;
|
|
153
|
+
exports.StreamSource = StreamSource;
|
|
154
|
+
exports.toContentSource = toContentSource;
|
|
155
|
+
//# sourceMappingURL=source.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source.cjs","sources":["../../src/streams/source.ts"],"sourcesContent":["import { collectStream } from './collect.ts'\n\n/**\n * Uniform adapter for upload content. Wraps File, Blob, Buffer, or ReadableStream\n * behind a common interface so upload logic does not depend on the input type.\n */\nexport interface ContentSource {\n /** Total size of the content in bytes. */\n readonly size: number\n /** Pre-computed SHA-1 hex digest, if available. */\n readonly sha1?: string\n /**\n * Whether {@link slice} is safe to call on this source.\n *\n * `true` for in-memory / random-access sources (`BufferSource`,\n * `BlobSource`) — the multipart upload engine can dispatch part reads\n * in parallel by slicing the source into disjoint ranges. `false`\n * for forward-only sources (`StreamSource`) — the engine must read\n * sequentially, one `partSize` chunk at a time. Callers that branch\n * on this flag are expected to fall back to the sequential path\n * rather than call `slice()` and catch the throw.\n */\n readonly canSlice: boolean\n /** Return a sub-range of this source as a new ContentSource. */\n slice(start: number, end: number): ContentSource\n /** Open the content as a ReadableStream. */\n stream(): ReadableStream<Uint8Array>\n /** Read the entire content into an ArrayBuffer. */\n toArrayBuffer(): Promise<ArrayBuffer>\n}\n\n/** ContentSource backed by a Blob or File. */\nexport class BlobSource implements ContentSource {\n /** {@inheritDoc} */\n readonly size: number\n /** Random-access: `Blob.slice()` is cheap and returns a new Blob view. */\n readonly canSlice = true\n\n /**\n * Create a BlobSource wrapping the given Blob.\n * @param blob - The Blob or File to use as the underlying content.\n */\n constructor(private readonly blob: Blob) {\n this.size = blob.size\n }\n\n /**\n * Return a new BlobSource covering the specified byte range.\n * @param start - The zero-based byte offset to begin the slice.\n * @param end - The exclusive byte offset where the slice ends.\n *\n * @returns A new ContentSource representing the requested sub-range.\n */\n slice(start: number, end: number): ContentSource {\n return new BlobSource(this.blob.slice(start, end))\n }\n\n /**\n * Open the Blob content as a ReadableStream.\n * @returns A ReadableStream of the Blob bytes.\n */\n stream(): ReadableStream<Uint8Array> {\n return this.blob.stream() as ReadableStream<Uint8Array>\n }\n\n /**\n * Read the entire Blob content into an ArrayBuffer.\n * @returns A promise that resolves with the full content as an ArrayBuffer.\n */\n toArrayBuffer(): Promise<ArrayBuffer> {\n return this.blob.arrayBuffer()\n }\n}\n\n/** ContentSource backed by a Uint8Array buffer. */\nexport class BufferSource implements ContentSource {\n /** {@inheritDoc} */\n readonly size: number\n /** Random-access: the entire payload lives in memory. */\n readonly canSlice = true\n\n /**\n * Create a BufferSource wrapping the given Uint8Array.\n * @param buffer - The byte buffer to use as the underlying content.\n */\n constructor(private readonly buffer: Uint8Array) {\n this.size = buffer.byteLength\n }\n\n /**\n * Return a new BufferSource covering the specified byte range.\n * @param start - The zero-based byte offset to begin the slice.\n * @param end - The exclusive byte offset where the slice ends.\n *\n * @returns A new ContentSource representing the requested sub-range.\n */\n slice(start: number, end: number): ContentSource {\n return new BufferSource(this.buffer.slice(start, end))\n }\n\n /**\n * Open the buffer content as a ReadableStream.\n * @returns A ReadableStream that emits the buffer bytes in a single chunk.\n */\n stream(): ReadableStream<Uint8Array> {\n const buffer = this.buffer\n return new ReadableStream({\n start(controller) {\n controller.enqueue(buffer)\n controller.close()\n },\n })\n }\n\n /**\n * Read the entire buffer content into an ArrayBuffer.\n * @returns A promise that resolves with the full content as an ArrayBuffer.\n */\n toArrayBuffer(): Promise<ArrayBuffer> {\n return Promise.resolve(\n this.buffer.buffer.slice(\n this.buffer.byteOffset,\n this.buffer.byteOffset + this.buffer.byteLength,\n ) as ArrayBuffer,\n )\n }\n}\n\n/** ContentSource backed by a ReadableStream. Can only be consumed once and does not support slicing. */\nexport class StreamSource implements ContentSource {\n /** {@inheritDoc} */\n readonly size: number\n /**\n * Forward-only: ReadableStreams cannot be repositioned, so multipart\n * uploads must take the sequential path. See the interface comment on\n * `canSlice` for what the engine does with this flag.\n */\n readonly canSlice = false\n /** Whether the stream has already been read. */\n private consumed = false\n\n /**\n * Create a StreamSource wrapping the given ReadableStream with a known byte size.\n * @param readable - The ReadableStream to wrap as a content source.\n * @param size - The total number of bytes the stream will produce.\n */\n constructor(\n private readonly readable: ReadableStream<Uint8Array>,\n size: number,\n ) {\n this.size = size\n }\n\n /**\n * Always throws because streams cannot be sliced. Buffer the stream first.\n *\n * @throws If slicing is attempted on a stream-backed source.\n */\n slice(): ContentSource {\n throw new Error('StreamSource does not support slicing. Buffer the stream first.')\n }\n\n /**\n * Open the underlying ReadableStream. Can only be called once.\n * @returns The underlying ReadableStream of bytes.\n *\n * @throws If the stream has already been consumed.\n */\n stream(): ReadableStream<Uint8Array> {\n if (this.consumed) throw new Error('StreamSource can only be consumed once.')\n this.consumed = true\n return this.readable\n }\n\n /**\n * Read the entire stream into an ArrayBuffer.\n * @returns A promise that resolves with the full content as an ArrayBuffer.\n */\n async toArrayBuffer(): Promise<ArrayBuffer> {\n const bytes = await collectStream(this.stream())\n return bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength) as ArrayBuffer\n }\n}\n\n/**\n * Convert a Uint8Array, Blob, or ReadableStream into a {@link ContentSource}.\n * When passing a ReadableStream, the `size` parameter is required.\n * @param input - The content to wrap, as a Uint8Array, Blob, or ReadableStream.\n * @param size - The total byte length, required when input is a ReadableStream.\n *\n * @returns A ContentSource adapter for the given input.\n *\n * @throws If input is a ReadableStream and size is not provided.\n */\nexport function toContentSource(\n input: Uint8Array | Blob | ReadableStream<Uint8Array>,\n size?: number,\n): ContentSource {\n if (input instanceof Uint8Array) {\n return new BufferSource(input)\n }\n if (input instanceof Blob) {\n return new BlobSource(input)\n }\n if (size === undefined) {\n throw new Error('size is required when using a ReadableStream as input.')\n }\n return new StreamSource(input, size)\n}\n"],"names":["collectStream"],"mappings":";;;AAgCO,MAAM,WAAoC;AAAA;AAAA;AAAA;AAAA;AAAA,EAU/C,YAA6B,MAAY;AAAZ,SAAA,OAAA;AAC3B,SAAK,OAAO,KAAK;AAAA,EACnB;AAAA;AAAA,EAVS;AAAA;AAAA,EAEA,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiBpB,MAAM,OAAe,KAA4B;AAC/C,WAAO,IAAI,WAAW,KAAK,KAAK,MAAM,OAAO,GAAG,CAAC;AAAA,EACnD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,SAAqC;AACnC,WAAO,KAAK,KAAK,OAAA;AAAA,EACnB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,gBAAsC;AACpC,WAAO,KAAK,KAAK,YAAA;AAAA,EACnB;AACF;AAGO,MAAM,aAAsC;AAAA;AAAA;AAAA;AAAA;AAAA,EAUjD,YAA6B,QAAoB;AAApB,SAAA,SAAA;AAC3B,SAAK,OAAO,OAAO;AAAA,EACrB;AAAA;AAAA,EAVS;AAAA;AAAA,EAEA,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiBpB,MAAM,OAAe,KAA4B;AAC/C,WAAO,IAAI,aAAa,KAAK,OAAO,MAAM,OAAO,GAAG,CAAC;AAAA,EACvD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,SAAqC;AACnC,UAAM,SAAS,KAAK;AACpB,WAAO,IAAI,eAAe;AAAA,MACxB,MAAM,YAAY;AAChB,mBAAW,QAAQ,MAAM;AACzB,mBAAW,MAAA;AAAA,MACb;AAAA,IAAA,CACD;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,gBAAsC;AACpC,WAAO,QAAQ;AAAA,MACb,KAAK,OAAO,OAAO;AAAA,QACjB,KAAK,OAAO;AAAA,QACZ,KAAK,OAAO,aAAa,KAAK,OAAO;AAAA,MAAA;AAAA,IACvC;AAAA,EAEJ;AACF;AAGO,MAAM,aAAsC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiBjD,YACmB,UACjB,MACA;AAFiB,SAAA,WAAA;AAGjB,SAAK,OAAO;AAAA,EACd;AAAA;AAAA,EApBS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,WAAW;AAAA;AAAA,EAEZ,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAmBnB,QAAuB;AACrB,UAAM,IAAI,MAAM,iEAAiE;AAAA,EACnF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,SAAqC;AACnC,QAAI,KAAK,SAAU,OAAM,IAAI,MAAM,yCAAyC;AAC5E,SAAK,WAAW;AAChB,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,gBAAsC;AAC1C,UAAM,QAAQ,MAAMA,QAAAA,cAAc,KAAK,QAAQ;AAC/C,WAAO,MAAM,OAAO,MAAM,MAAM,YAAY,MAAM,aAAa,MAAM,UAAU;AAAA,EACjF;AACF;AAYO,SAAS,gBACd,OACA,MACe;AACf,MAAI,iBAAiB,YAAY;AAC/B,WAAO,IAAI,aAAa,KAAK;AAAA,EAC/B;AACA,MAAI,iBAAiB,MAAM;AACzB,WAAO,IAAI,WAAW,KAAK;AAAA,EAC7B;AACA,MAAI,SAAS,QAAW;AACtB,UAAM,IAAI,MAAM,wDAAwD;AAAA,EAC1E;AACA,SAAO,IAAI,aAAa,OAAO,IAAI;AACrC;;;;;"}
|