@hostr/upload 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/README.md +298 -0
- package/dist/api/client.d.ts +71 -0
- package/dist/browser/index.d.ts +50 -0
- package/dist/browser.js +1061 -0
- package/dist/core/engine.d.ts +150 -0
- package/dist/core/events.d.ts +33 -0
- package/dist/core/retry.d.ts +20 -0
- package/dist/core/session.d.ts +28 -0
- package/dist/core/types.d.ts +44 -0
- package/dist/core/upload.d.ts +32 -0
- package/dist/hash/composite.d.ts +2 -0
- package/dist/hash/hasher.d.ts +2 -0
- package/dist/hash/hex.d.ts +2 -0
- package/dist/hash/md5.d.ts +24 -0
- package/dist/hash/sha256.d.ts +25 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +1012 -0
- package/dist/node/hasher.d.ts +2 -0
- package/dist/node/index.d.ts +43 -0
- package/dist/node.js +1089 -0
- package/dist/react-native/background-plan.d.ts +57 -0
- package/dist/react-native/background.d.ts +126 -0
- package/dist/react-native/fs.d.ts +28 -0
- package/dist/react-native/index.d.ts +69 -0
- package/dist/react-native/native-upload.d.ts +76 -0
- package/dist/react-native.js +896 -0
- package/package.json +48 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { FileSource, HttpTransport, StateStore } from '../core/types.js';
|
|
2
|
+
import { type Upload } from '../core/upload.js';
|
|
3
|
+
export { createUploadSession, mintUploadToken } from '../api/client.js';
|
|
4
|
+
export { NetworkError, ApiError } from '../api/client.js';
|
|
5
|
+
export { IntegrityError } from '../core/engine.js';
|
|
6
|
+
export { nodeHasher } from './hasher.js';
|
|
7
|
+
export type { Upload } from '../core/upload.js';
|
|
8
|
+
/** Opens `path` and holds the `FileHandle` open for the adapter's lifetime;
|
|
9
|
+
* callers must `close()` it when done (createUpload does this implicitly
|
|
10
|
+
* never — it hands the FileSource to the engine, which only ever reads).
|
|
11
|
+
* Identity is `path:size:mtimeMs-floored` so a relaunch against the same
|
|
12
|
+
* file resolves to the same session, and a modified file (different size
|
|
13
|
+
* or mtime) correctly starts a fresh one. */
|
|
14
|
+
export declare function nodeFileSource(path: string): Promise<FileSource>;
|
|
15
|
+
/** One file per key under `dir`, created on first write. Keys are sanitized
|
|
16
|
+
* to filesystem-safe names — collisions between distinct keys that
|
|
17
|
+
* sanitize identically are possible but not a concern in practice (session
|
|
18
|
+
* keys are namespaced storage keys, not arbitrary user input). */
|
|
19
|
+
export declare function fileStateStore(dir: string): StateStore;
|
|
20
|
+
/** Default transport: a plain `fetch` PUT. Node's `fetch` exposes no
|
|
21
|
+
* upload-progress events, so `onProgress` is documented (not simulated) to
|
|
22
|
+
* fire exactly once, with the full body length, after the PUT resolves —
|
|
23
|
+
* callers wanting finer-grained progress must supply their own `transport`. */
|
|
24
|
+
export declare function nodeTransport(fetchFn?: typeof fetch): HttpTransport;
|
|
25
|
+
export type CreateUploadOptions = {
|
|
26
|
+
endpoint: string;
|
|
27
|
+
uploadToken: string;
|
|
28
|
+
assetId: string;
|
|
29
|
+
/** Filesystem path to the file to upload. */
|
|
30
|
+
file: string;
|
|
31
|
+
/** Directory for the persisted session; defaults to `${os.tmpdir()}/hostr-upload`. */
|
|
32
|
+
stateDir?: string;
|
|
33
|
+
concurrency?: number;
|
|
34
|
+
checksum?: 'sha256' | 'none';
|
|
35
|
+
onTokenExpired?: (assetId: string) => Promise<string>;
|
|
36
|
+
/** Advanced: override the fetch implementation used for API calls and the
|
|
37
|
+
* default transport's PUTs. Mainly for tests. */
|
|
38
|
+
fetchFn?: typeof fetch;
|
|
39
|
+
/** Advanced: override the PUT transport entirely (e.g. to inject failures
|
|
40
|
+
* or corruption in tests) instead of the default `fetch`-based one. */
|
|
41
|
+
transport?: HttpTransport;
|
|
42
|
+
};
|
|
43
|
+
export declare function createUpload(opts: CreateUploadOptions): Promise<Upload>;
|