@hyperserve/hyperserve-js 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 +291 -0
- package/dist/browser.cjs +91 -0
- package/dist/browser.cjs.map +1 -0
- package/dist/browser.d.cts +28 -0
- package/dist/browser.d.ts +28 -0
- package/dist/browser.js +86 -0
- package/dist/browser.js.map +1 -0
- package/dist/errors-C89laaKB.d.cts +176 -0
- package/dist/errors-C89laaKB.d.ts +176 -0
- package/dist/index.cjs +342 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +88 -0
- package/dist/index.d.ts +88 -0
- package/dist/index.js +333 -0
- package/dist/index.js.map +1 -0
- package/dist/react-native.cjs +97 -0
- package/dist/react-native.cjs.map +1 -0
- package/dist/react-native.d.cts +40 -0
- package/dist/react-native.d.ts +40 -0
- package/dist/react-native.js +92 -0
- package/dist/react-native.js.map +1 -0
- package/package.json +89 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/errors.ts
|
|
4
|
+
var HyperserveError = class extends Error {
|
|
5
|
+
constructor(message, statusCode) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.statusCode = statusCode;
|
|
8
|
+
this.name = "HyperserveError";
|
|
9
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
var HyperserveUploadError = class extends HyperserveError {
|
|
13
|
+
constructor(message, uploadStatus) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.uploadStatus = uploadStatus;
|
|
16
|
+
this.name = "HyperserveUploadError";
|
|
17
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
var HyperserveTimeoutError = class extends HyperserveError {
|
|
21
|
+
constructor(message = "Request timed out") {
|
|
22
|
+
super(message);
|
|
23
|
+
this.name = "HyperserveTimeoutError";
|
|
24
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// src/storage.ts
|
|
29
|
+
async function putToStorage(uploadUrl, contentType, body, onProgress) {
|
|
30
|
+
if (onProgress !== void 0 && typeof XMLHttpRequest !== "undefined" && !(body instanceof ReadableStream)) {
|
|
31
|
+
return putWithXhr(uploadUrl, contentType, body, onProgress);
|
|
32
|
+
}
|
|
33
|
+
return putWithFetch(uploadUrl, contentType, body);
|
|
34
|
+
}
|
|
35
|
+
function putWithFetch(uploadUrl, contentType, body) {
|
|
36
|
+
return fetch(uploadUrl, {
|
|
37
|
+
method: "PUT",
|
|
38
|
+
headers: { "Content-Type": contentType },
|
|
39
|
+
// duplex is required for ReadableStream bodies in some runtimes (Node 18)
|
|
40
|
+
...body instanceof ReadableStream ? { duplex: "half" } : {},
|
|
41
|
+
body
|
|
42
|
+
}).then((response) => {
|
|
43
|
+
if (!response.ok) {
|
|
44
|
+
throw new HyperserveUploadError(
|
|
45
|
+
`Storage PUT failed with status ${response.status}`,
|
|
46
|
+
response.status
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
function putWithXhr(uploadUrl, contentType, body, onProgress) {
|
|
52
|
+
return new Promise((resolve, reject) => {
|
|
53
|
+
const xhr = new XMLHttpRequest();
|
|
54
|
+
xhr.open("PUT", uploadUrl);
|
|
55
|
+
xhr.setRequestHeader("Content-Type", contentType);
|
|
56
|
+
xhr.upload.addEventListener("progress", (event) => {
|
|
57
|
+
if (event.lengthComputable) {
|
|
58
|
+
onProgress(Math.round(event.loaded / event.total * 100));
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
xhr.addEventListener("load", () => {
|
|
62
|
+
if (xhr.status >= 200 && xhr.status < 300) {
|
|
63
|
+
onProgress(100);
|
|
64
|
+
resolve();
|
|
65
|
+
} else {
|
|
66
|
+
reject(
|
|
67
|
+
new HyperserveUploadError(`Storage PUT failed with status ${xhr.status}`, xhr.status)
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
xhr.addEventListener("timeout", () => {
|
|
72
|
+
reject(new HyperserveTimeoutError("Storage PUT timed out"));
|
|
73
|
+
});
|
|
74
|
+
xhr.addEventListener("error", () => {
|
|
75
|
+
reject(new HyperserveUploadError("Storage PUT failed due to a network error"));
|
|
76
|
+
});
|
|
77
|
+
xhr.send(body);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// src/react-native.ts
|
|
82
|
+
async function putVideoToStorage(options) {
|
|
83
|
+
const { uploadUrl, contentType, uri, onProgress } = options;
|
|
84
|
+
const localResponse = await fetch(uri);
|
|
85
|
+
if (!localResponse.ok) {
|
|
86
|
+
throw new HyperserveUploadError(`Failed to read local file: ${uri}`);
|
|
87
|
+
}
|
|
88
|
+
const blob = await localResponse.blob();
|
|
89
|
+
return putToStorage(uploadUrl, contentType, blob, onProgress);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
exports.HyperserveError = HyperserveError;
|
|
93
|
+
exports.HyperserveTimeoutError = HyperserveTimeoutError;
|
|
94
|
+
exports.HyperserveUploadError = HyperserveUploadError;
|
|
95
|
+
exports.putVideoToStorage = putVideoToStorage;
|
|
96
|
+
//# sourceMappingURL=react-native.cjs.map
|
|
97
|
+
//# sourceMappingURL=react-native.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts","../src/storage.ts","../src/react-native.ts"],"names":[],"mappings":";;;AAGO,IAAM,eAAA,GAAN,cAA8B,KAAA,CAAM;AAAA,EAC1C,WAAA,CACC,SACgB,UAAA,EACf;AACD,IAAA,KAAA,CAAM,OAAO,CAAA;AAFG,IAAA,IAAA,CAAA,UAAA,GAAA,UAAA;AAGhB,IAAA,IAAA,CAAK,IAAA,GAAO,iBAAA;AAEZ,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,GAAA,CAA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W,MAAM;AACrC,MAAA,MAAA,CAAO,IAAI,sBAAA,CAAuB,uBAAuB,CAAC,CAAA;AAAA,IAC3D,CAAC,CAAA;AAED,IAAA,GAAA,CAAI,gBAAA,CAAiB,SAAS,MAAM;AACnC,MAAA,MAAA,CAAO,IAAI,qBAAA,CAAsB,2CAA2C,CAAC,CAAA;AAAA,IAC9E,CAAC,CAAA;AAED,IAAA,GAAA,CAAI,KAAK,IAAI,CAAA;AAAA,EACd,CAAC,CAAA;AACF;;;AC7CA,eAAsB,kBAAkB,OAAA,EAAoD;AAC3F,EAAA,MAAM,EAAE,SAAA,EAAW,WAAA,EAAa,GAAA,EAAK,YAAW,GAAI,OAAA;AAIpD,EAAA,MAAM,aAAA,GAAgB,MAAM,KAAA,CAAM,GAAG,CAAA;AACrC,EAAA,IAAI,CAAC,cAAc,EAAA,EAAI;AACtB,IAAA,MAAM,IAAI,qBAAA,CAAsB,CAAA,2BAAA,EAA8B,GAAG,CAAA,CAAE,CAAA;AAAA,EACpE;AACA,EAAA,MAAM,IAAA,GAAO,MAAM,aAAA,CAAc,IAAA,EAAK;AAEtC,EAAA,OAAO,YAAA,CAAa,SAAA,EAAW,WAAA,EAAa,IAAA,EAAM,UAAU,CAAA;AAC7D","file":"react-native.cjs","sourcesContent":["/**\n * Base class for all Hyperserve SDK errors.\n */\nexport class HyperserveError extends Error {\n\tconstructor(\n\t\tmessage: string,\n\t\tpublic readonly statusCode?: number,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"HyperserveError\";\n\t\t// Maintain proper prototype chain in transpiled environments\n\t\tObject.setPrototypeOf(this, new.target.prototype);\n\t}\n}\n\n/**\n * The Hyperserve API returned a 4xx response.\n * Typically indicates a validation problem: unsupported file format,\n * file too large, invalid resolutions, video not in expected state, etc.\n */\nexport class HyperserveValidationError extends HyperserveError {\n\tconstructor(\n\t\tmessage: string,\n\t\tstatusCode: number,\n\t\tpublic readonly detail?: unknown,\n\t) {\n\t\tsuper(message, statusCode);\n\t\tthis.name = \"HyperserveValidationError\";\n\t\tObject.setPrototypeOf(this, new.target.prototype);\n\t}\n}\n\n/**\n * The Hyperserve API returned a 404 response.\n */\nexport class HyperserveNotFoundError extends HyperserveError {\n\tconstructor(message = \"Resource not found\") {\n\t\tsuper(message, 404);\n\t\tthis.name = \"HyperserveNotFoundError\";\n\t\tObject.setPrototypeOf(this, new.target.prototype);\n\t}\n}\n\n/**\n * The Hyperserve API returned a 5xx response.\n */\nexport class HyperserveApiError extends HyperserveError {\n\tconstructor(message: string, statusCode: number) {\n\t\tsuper(message, statusCode);\n\t\tthis.name = \"HyperserveApiError\";\n\t\tObject.setPrototypeOf(this, new.target.prototype);\n\t}\n}\n\n/**\n * The storage PUT request failed.\n */\nexport class HyperserveUploadError extends HyperserveError {\n\tconstructor(\n\t\tmessage: string,\n\t\tpublic readonly uploadStatus?: number,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"HyperserveUploadError\";\n\t\tObject.setPrototypeOf(this, new.target.prototype);\n\t}\n}\n\n/**\n * A request exceeded the configured timeoutMs.\n */\nexport class HyperserveTimeoutError extends HyperserveError {\n\tconstructor(message = \"Request timed out\") {\n\t\tsuper(message);\n\t\tthis.name = \"HyperserveTimeoutError\";\n\t\tObject.setPrototypeOf(this, new.target.prototype);\n\t}\n}\n","import { HyperserveTimeoutError, HyperserveUploadError } from \"./errors.js\";\n\n/**\n * PUT a file to a presigned S3 URL.\n * Used internally by uploadVideo (server) and exported as putVideoToStorage (browser).\n *\n * When onProgress is provided, uses XMLHttpRequest for upload progress events.\n * Falls back to fetch otherwise.\n */\nexport async function putToStorage(\n\tuploadUrl: string,\n\tcontentType: string,\n\tbody: Blob | ReadableStream,\n\tonProgress?: (percent: number) => void,\n): Promise<void> {\n\t// XHR is used for progress reporting but does not support ReadableStream bodies.\n\t// Fall back to fetch (no progress) when the body is a stream.\n\tif (\n\t\tonProgress !== undefined &&\n\t\ttypeof XMLHttpRequest !== \"undefined\" &&\n\t\t!(body instanceof ReadableStream)\n\t) {\n\t\treturn putWithXhr(uploadUrl, contentType, body, onProgress);\n\t}\n\treturn putWithFetch(uploadUrl, contentType, body);\n}\n\nfunction putWithFetch(\n\tuploadUrl: string,\n\tcontentType: string,\n\tbody: Blob | ReadableStream,\n): Promise<void> {\n\treturn fetch(uploadUrl, {\n\t\tmethod: \"PUT\",\n\t\theaders: { \"Content-Type\": contentType },\n\t\t// duplex is required for ReadableStream bodies in some runtimes (Node 18)\n\t\t...(body instanceof ReadableStream ? { duplex: \"half\" } : {}),\n\t\tbody: body as BodyInit,\n\t}).then((response) => {\n\t\tif (!response.ok) {\n\t\t\tthrow new HyperserveUploadError(\n\t\t\t\t`Storage PUT failed with status ${response.status}`,\n\t\t\t\tresponse.status,\n\t\t\t);\n\t\t}\n\t});\n}\n\nfunction putWithXhr(\n\tuploadUrl: string,\n\tcontentType: string,\n\tbody: Blob,\n\tonProgress: (percent: number) => void,\n): Promise<void> {\n\treturn new Promise((resolve, reject) => {\n\t\tconst xhr = new XMLHttpRequest();\n\n\t\txhr.open(\"PUT\", uploadUrl);\n\t\txhr.setRequestHeader(\"Content-Type\", contentType);\n\n\t\txhr.upload.addEventListener(\"progress\", (event) => {\n\t\t\tif (event.lengthComputable) {\n\t\t\t\tonProgress(Math.round((event.loaded / event.total) * 100));\n\t\t\t}\n\t\t});\n\n\t\txhr.addEventListener(\"load\", () => {\n\t\t\tif (xhr.status >= 200 && xhr.status < 300) {\n\t\t\t\tonProgress(100);\n\t\t\t\tresolve();\n\t\t\t} else {\n\t\t\t\treject(\n\t\t\t\t\tnew HyperserveUploadError(`Storage PUT failed with status ${xhr.status}`, xhr.status),\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\n\t\txhr.addEventListener(\"timeout\", () => {\n\t\t\treject(new HyperserveTimeoutError(\"Storage PUT timed out\"));\n\t\t});\n\n\t\txhr.addEventListener(\"error\", () => {\n\t\t\treject(new HyperserveUploadError(\"Storage PUT failed due to a network error\"));\n\t\t});\n\n\t\txhr.send(body);\n\t});\n}\n","/**\n * React Native utilities for the Hyperserve SDK.\n *\n * Import from '@hyperserve/hyperserve-js/react-native' — this entry point contains no\n * API key logic and is safe to bundle into your React Native app.\n *\n * Usage:\n * import { putVideoToStorage } from '@hyperserve/hyperserve-js/react-native';\n *\n * // uri comes from expo-image-picker, react-native-image-picker, etc.\n * await putVideoToStorage({ uploadUrl, contentType, uri: asset.uri, onProgress });\n *\n * Note: your backend (not this utility) should hold the API key and call\n * createVideo / completeUpload on your app's behalf.\n */\n\nimport { HyperserveError, HyperserveTimeoutError, HyperserveUploadError } from \"./errors.js\";\n\nexport type { PutVideoToStorageRNOptions, VideoResolution, VideoStatus } from \"./types.js\";\nexport { HyperserveError, HyperserveTimeoutError, HyperserveUploadError };\n\nimport { putToStorage } from \"./storage.js\";\nimport type { PutVideoToStorageRNOptions } from \"./types.js\";\n\n/**\n * PUT a video file to the presigned storage URL obtained from your backend.\n * Accepts a local file URI from a React Native video/image picker.\n * No API key required — this call goes directly to storage, not to the Hyperserve API.\n *\n * @example\n * const { uploadUrl, contentType } = await fetch('https://your-api.com/create-upload', {\n * method: 'POST',\n * body: JSON.stringify({ filename: asset.fileName, fileSizeBytes: asset.fileSize }),\n * }).then(r => r.json());\n *\n * await putVideoToStorage({ uploadUrl, contentType, uri: asset.uri, onProgress: (p) => setProgress(p) });\n *\n * await fetch('https://your-api.com/complete-upload', {\n * method: 'POST',\n * body: JSON.stringify({ videoId }),\n * });\n */\nexport async function putVideoToStorage(options: PutVideoToStorageRNOptions): Promise<void> {\n\tconst { uploadUrl, contentType, uri, onProgress } = options;\n\n\t// Fetch the local file URI to obtain a Blob. React Native's fetch implementation\n\t// supports file:// URIs, allowing us to read local files from the device.\n\tconst localResponse = await fetch(uri);\n\tif (!localResponse.ok) {\n\t\tthrow new HyperserveUploadError(`Failed to read local file: ${uri}`);\n\t}\n\tconst blob = await localResponse.blob();\n\n\treturn putToStorage(uploadUrl, contentType, blob, onProgress);\n}\n"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { j as PutVideoToStorageRNOptions } from './errors-C89laaKB.cjs';
|
|
2
|
+
export { e as HyperserveError, g as HyperserveTimeoutError, h as HyperserveUploadError, k as VideoResolution, m as VideoStatus } from './errors-C89laaKB.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* React Native utilities for the Hyperserve SDK.
|
|
6
|
+
*
|
|
7
|
+
* Import from '@hyperserve/hyperserve-js/react-native' — this entry point contains no
|
|
8
|
+
* API key logic and is safe to bundle into your React Native app.
|
|
9
|
+
*
|
|
10
|
+
* Usage:
|
|
11
|
+
* import { putVideoToStorage } from '@hyperserve/hyperserve-js/react-native';
|
|
12
|
+
*
|
|
13
|
+
* // uri comes from expo-image-picker, react-native-image-picker, etc.
|
|
14
|
+
* await putVideoToStorage({ uploadUrl, contentType, uri: asset.uri, onProgress });
|
|
15
|
+
*
|
|
16
|
+
* Note: your backend (not this utility) should hold the API key and call
|
|
17
|
+
* createVideo / completeUpload on your app's behalf.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* PUT a video file to the presigned storage URL obtained from your backend.
|
|
22
|
+
* Accepts a local file URI from a React Native video/image picker.
|
|
23
|
+
* No API key required — this call goes directly to storage, not to the Hyperserve API.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* const { uploadUrl, contentType } = await fetch('https://your-api.com/create-upload', {
|
|
27
|
+
* method: 'POST',
|
|
28
|
+
* body: JSON.stringify({ filename: asset.fileName, fileSizeBytes: asset.fileSize }),
|
|
29
|
+
* }).then(r => r.json());
|
|
30
|
+
*
|
|
31
|
+
* await putVideoToStorage({ uploadUrl, contentType, uri: asset.uri, onProgress: (p) => setProgress(p) });
|
|
32
|
+
*
|
|
33
|
+
* await fetch('https://your-api.com/complete-upload', {
|
|
34
|
+
* method: 'POST',
|
|
35
|
+
* body: JSON.stringify({ videoId }),
|
|
36
|
+
* });
|
|
37
|
+
*/
|
|
38
|
+
declare function putVideoToStorage(options: PutVideoToStorageRNOptions): Promise<void>;
|
|
39
|
+
|
|
40
|
+
export { PutVideoToStorageRNOptions, putVideoToStorage };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { j as PutVideoToStorageRNOptions } from './errors-C89laaKB.js';
|
|
2
|
+
export { e as HyperserveError, g as HyperserveTimeoutError, h as HyperserveUploadError, k as VideoResolution, m as VideoStatus } from './errors-C89laaKB.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* React Native utilities for the Hyperserve SDK.
|
|
6
|
+
*
|
|
7
|
+
* Import from '@hyperserve/hyperserve-js/react-native' — this entry point contains no
|
|
8
|
+
* API key logic and is safe to bundle into your React Native app.
|
|
9
|
+
*
|
|
10
|
+
* Usage:
|
|
11
|
+
* import { putVideoToStorage } from '@hyperserve/hyperserve-js/react-native';
|
|
12
|
+
*
|
|
13
|
+
* // uri comes from expo-image-picker, react-native-image-picker, etc.
|
|
14
|
+
* await putVideoToStorage({ uploadUrl, contentType, uri: asset.uri, onProgress });
|
|
15
|
+
*
|
|
16
|
+
* Note: your backend (not this utility) should hold the API key and call
|
|
17
|
+
* createVideo / completeUpload on your app's behalf.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* PUT a video file to the presigned storage URL obtained from your backend.
|
|
22
|
+
* Accepts a local file URI from a React Native video/image picker.
|
|
23
|
+
* No API key required — this call goes directly to storage, not to the Hyperserve API.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* const { uploadUrl, contentType } = await fetch('https://your-api.com/create-upload', {
|
|
27
|
+
* method: 'POST',
|
|
28
|
+
* body: JSON.stringify({ filename: asset.fileName, fileSizeBytes: asset.fileSize }),
|
|
29
|
+
* }).then(r => r.json());
|
|
30
|
+
*
|
|
31
|
+
* await putVideoToStorage({ uploadUrl, contentType, uri: asset.uri, onProgress: (p) => setProgress(p) });
|
|
32
|
+
*
|
|
33
|
+
* await fetch('https://your-api.com/complete-upload', {
|
|
34
|
+
* method: 'POST',
|
|
35
|
+
* body: JSON.stringify({ videoId }),
|
|
36
|
+
* });
|
|
37
|
+
*/
|
|
38
|
+
declare function putVideoToStorage(options: PutVideoToStorageRNOptions): Promise<void>;
|
|
39
|
+
|
|
40
|
+
export { PutVideoToStorageRNOptions, putVideoToStorage };
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// src/errors.ts
|
|
2
|
+
var HyperserveError = class extends Error {
|
|
3
|
+
constructor(message, statusCode) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.statusCode = statusCode;
|
|
6
|
+
this.name = "HyperserveError";
|
|
7
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var HyperserveUploadError = class extends HyperserveError {
|
|
11
|
+
constructor(message, uploadStatus) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.uploadStatus = uploadStatus;
|
|
14
|
+
this.name = "HyperserveUploadError";
|
|
15
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
var HyperserveTimeoutError = class extends HyperserveError {
|
|
19
|
+
constructor(message = "Request timed out") {
|
|
20
|
+
super(message);
|
|
21
|
+
this.name = "HyperserveTimeoutError";
|
|
22
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// src/storage.ts
|
|
27
|
+
async function putToStorage(uploadUrl, contentType, body, onProgress) {
|
|
28
|
+
if (onProgress !== void 0 && typeof XMLHttpRequest !== "undefined" && !(body instanceof ReadableStream)) {
|
|
29
|
+
return putWithXhr(uploadUrl, contentType, body, onProgress);
|
|
30
|
+
}
|
|
31
|
+
return putWithFetch(uploadUrl, contentType, body);
|
|
32
|
+
}
|
|
33
|
+
function putWithFetch(uploadUrl, contentType, body) {
|
|
34
|
+
return fetch(uploadUrl, {
|
|
35
|
+
method: "PUT",
|
|
36
|
+
headers: { "Content-Type": contentType },
|
|
37
|
+
// duplex is required for ReadableStream bodies in some runtimes (Node 18)
|
|
38
|
+
...body instanceof ReadableStream ? { duplex: "half" } : {},
|
|
39
|
+
body
|
|
40
|
+
}).then((response) => {
|
|
41
|
+
if (!response.ok) {
|
|
42
|
+
throw new HyperserveUploadError(
|
|
43
|
+
`Storage PUT failed with status ${response.status}`,
|
|
44
|
+
response.status
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
function putWithXhr(uploadUrl, contentType, body, onProgress) {
|
|
50
|
+
return new Promise((resolve, reject) => {
|
|
51
|
+
const xhr = new XMLHttpRequest();
|
|
52
|
+
xhr.open("PUT", uploadUrl);
|
|
53
|
+
xhr.setRequestHeader("Content-Type", contentType);
|
|
54
|
+
xhr.upload.addEventListener("progress", (event) => {
|
|
55
|
+
if (event.lengthComputable) {
|
|
56
|
+
onProgress(Math.round(event.loaded / event.total * 100));
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
xhr.addEventListener("load", () => {
|
|
60
|
+
if (xhr.status >= 200 && xhr.status < 300) {
|
|
61
|
+
onProgress(100);
|
|
62
|
+
resolve();
|
|
63
|
+
} else {
|
|
64
|
+
reject(
|
|
65
|
+
new HyperserveUploadError(`Storage PUT failed with status ${xhr.status}`, xhr.status)
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
xhr.addEventListener("timeout", () => {
|
|
70
|
+
reject(new HyperserveTimeoutError("Storage PUT timed out"));
|
|
71
|
+
});
|
|
72
|
+
xhr.addEventListener("error", () => {
|
|
73
|
+
reject(new HyperserveUploadError("Storage PUT failed due to a network error"));
|
|
74
|
+
});
|
|
75
|
+
xhr.send(body);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// src/react-native.ts
|
|
80
|
+
async function putVideoToStorage(options) {
|
|
81
|
+
const { uploadUrl, contentType, uri, onProgress } = options;
|
|
82
|
+
const localResponse = await fetch(uri);
|
|
83
|
+
if (!localResponse.ok) {
|
|
84
|
+
throw new HyperserveUploadError(`Failed to read local file: ${uri}`);
|
|
85
|
+
}
|
|
86
|
+
const blob = await localResponse.blob();
|
|
87
|
+
return putToStorage(uploadUrl, contentType, blob, onProgress);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export { HyperserveError, HyperserveTimeoutError, HyperserveUploadError, putVideoToStorage };
|
|
91
|
+
//# sourceMappingURL=react-native.js.map
|
|
92
|
+
//# sourceMappingURL=react-native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts","../src/storage.ts","../src/react-native.ts"],"names":[],"mappings":";AAGO,IAAM,eAAA,GAAN,cAA8B,KAAA,CAAM;AAAA,EAC1C,WAAA,CACC,SACgB,UAAA,EACf;AACD,IAAA,KAAA,CAAM,OAAO,CAAA;AAFG,IAAA,IAAA,CAAA,UAAA,GAAA,UAAA;AAGhB,IAAA,IAAA,CAAK,IAAA,GAAO,iBAAA;AAEZ,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,GAAA,CAAA,MAAA,CAAW,SAAS,CAAA;AAAA,EACjD;AACD;AA4CO,IAAM,qBAAA,GAAN,cAAoC,eAAA,CAAgB;AAAA,EAC1D,WAAA,CACC,SACgB,YAAA,EACf;AACD,IAAA,KAAA,CAAM,OAAO,CAAA;AAFG,IAAA,IAAA,CAAA,YAAA,GAAA,YAAA;AAGhB,IAAA,IAAA,CAAK,IAAA,GAAO,uBAAA;AACZ,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,GAAA,CAAA,MAAA,CAAW,SAAS,CAAA;AAAA,EACjD;AACD;AAKO,IAAM,sBAAA,GAAN,cAAqC,eAAA,CAAgB;AAAA,EAC3D,WAAA,CAAY,UAAU,mBAAA,EAAqB;AAC1C,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAA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c,EAAA,EAAI;AACtB,IAAA,MAAM,IAAI,qBAAA,CAAsB,CAAA,2BAAA,EAA8B,GAAG,CAAA,CAAE,CAAA;AAAA,EACpE;AACA,EAAA,MAAM,IAAA,GAAO,MAAM,aAAA,CAAc,IAAA,EAAK;AAEtC,EAAA,OAAO,YAAA,CAAa,SAAA,EAAW,WAAA,EAAa,IAAA,EAAM,UAAU,CAAA;AAC7D","file":"react-native.js","sourcesContent":["/**\n * Base class for all Hyperserve SDK errors.\n */\nexport class HyperserveError extends Error {\n\tconstructor(\n\t\tmessage: string,\n\t\tpublic readonly statusCode?: number,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"HyperserveError\";\n\t\t// Maintain proper prototype chain in transpiled environments\n\t\tObject.setPrototypeOf(this, new.target.prototype);\n\t}\n}\n\n/**\n * The Hyperserve API returned a 4xx response.\n * Typically indicates a validation problem: unsupported file format,\n * file too large, invalid resolutions, video not in expected state, etc.\n */\nexport class HyperserveValidationError extends HyperserveError {\n\tconstructor(\n\t\tmessage: string,\n\t\tstatusCode: number,\n\t\tpublic readonly detail?: unknown,\n\t) {\n\t\tsuper(message, statusCode);\n\t\tthis.name = \"HyperserveValidationError\";\n\t\tObject.setPrototypeOf(this, new.target.prototype);\n\t}\n}\n\n/**\n * The Hyperserve API returned a 404 response.\n */\nexport class HyperserveNotFoundError extends HyperserveError {\n\tconstructor(message = \"Resource not found\") {\n\t\tsuper(message, 404);\n\t\tthis.name = \"HyperserveNotFoundError\";\n\t\tObject.setPrototypeOf(this, new.target.prototype);\n\t}\n}\n\n/**\n * The Hyperserve API returned a 5xx response.\n */\nexport class HyperserveApiError extends HyperserveError {\n\tconstructor(message: string, statusCode: number) {\n\t\tsuper(message, statusCode);\n\t\tthis.name = \"HyperserveApiError\";\n\t\tObject.setPrototypeOf(this, new.target.prototype);\n\t}\n}\n\n/**\n * The storage PUT request failed.\n */\nexport class HyperserveUploadError extends HyperserveError {\n\tconstructor(\n\t\tmessage: string,\n\t\tpublic readonly uploadStatus?: number,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"HyperserveUploadError\";\n\t\tObject.setPrototypeOf(this, new.target.prototype);\n\t}\n}\n\n/**\n * A request exceeded the configured timeoutMs.\n */\nexport class HyperserveTimeoutError extends HyperserveError {\n\tconstructor(message = \"Request timed out\") {\n\t\tsuper(message);\n\t\tthis.name = \"HyperserveTimeoutError\";\n\t\tObject.setPrototypeOf(this, new.target.prototype);\n\t}\n}\n","import { HyperserveTimeoutError, HyperserveUploadError } from \"./errors.js\";\n\n/**\n * PUT a file to a presigned S3 URL.\n * Used internally by uploadVideo (server) and exported as putVideoToStorage (browser).\n *\n * When onProgress is provided, uses XMLHttpRequest for upload progress events.\n * Falls back to fetch otherwise.\n */\nexport async function putToStorage(\n\tuploadUrl: string,\n\tcontentType: string,\n\tbody: Blob | ReadableStream,\n\tonProgress?: (percent: number) => void,\n): Promise<void> {\n\t// XHR is used for progress reporting but does not support ReadableStream bodies.\n\t// Fall back to fetch (no progress) when the body is a stream.\n\tif (\n\t\tonProgress !== undefined &&\n\t\ttypeof XMLHttpRequest !== \"undefined\" &&\n\t\t!(body instanceof ReadableStream)\n\t) {\n\t\treturn putWithXhr(uploadUrl, contentType, body, onProgress);\n\t}\n\treturn putWithFetch(uploadUrl, contentType, body);\n}\n\nfunction putWithFetch(\n\tuploadUrl: string,\n\tcontentType: string,\n\tbody: Blob | ReadableStream,\n): Promise<void> {\n\treturn fetch(uploadUrl, {\n\t\tmethod: \"PUT\",\n\t\theaders: { \"Content-Type\": contentType },\n\t\t// duplex is required for ReadableStream bodies in some runtimes (Node 18)\n\t\t...(body instanceof ReadableStream ? { duplex: \"half\" } : {}),\n\t\tbody: body as BodyInit,\n\t}).then((response) => {\n\t\tif (!response.ok) {\n\t\t\tthrow new HyperserveUploadError(\n\t\t\t\t`Storage PUT failed with status ${response.status}`,\n\t\t\t\tresponse.status,\n\t\t\t);\n\t\t}\n\t});\n}\n\nfunction putWithXhr(\n\tuploadUrl: string,\n\tcontentType: string,\n\tbody: Blob,\n\tonProgress: (percent: number) => void,\n): Promise<void> {\n\treturn new Promise((resolve, reject) => {\n\t\tconst xhr = new XMLHttpRequest();\n\n\t\txhr.open(\"PUT\", uploadUrl);\n\t\txhr.setRequestHeader(\"Content-Type\", contentType);\n\n\t\txhr.upload.addEventListener(\"progress\", (event) => {\n\t\t\tif (event.lengthComputable) {\n\t\t\t\tonProgress(Math.round((event.loaded / event.total) * 100));\n\t\t\t}\n\t\t});\n\n\t\txhr.addEventListener(\"load\", () => {\n\t\t\tif (xhr.status >= 200 && xhr.status < 300) {\n\t\t\t\tonProgress(100);\n\t\t\t\tresolve();\n\t\t\t} else {\n\t\t\t\treject(\n\t\t\t\t\tnew HyperserveUploadError(`Storage PUT failed with status ${xhr.status}`, xhr.status),\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\n\t\txhr.addEventListener(\"timeout\", () => {\n\t\t\treject(new HyperserveTimeoutError(\"Storage PUT timed out\"));\n\t\t});\n\n\t\txhr.addEventListener(\"error\", () => {\n\t\t\treject(new HyperserveUploadError(\"Storage PUT failed due to a network error\"));\n\t\t});\n\n\t\txhr.send(body);\n\t});\n}\n","/**\n * React Native utilities for the Hyperserve SDK.\n *\n * Import from '@hyperserve/hyperserve-js/react-native' — this entry point contains no\n * API key logic and is safe to bundle into your React Native app.\n *\n * Usage:\n * import { putVideoToStorage } from '@hyperserve/hyperserve-js/react-native';\n *\n * // uri comes from expo-image-picker, react-native-image-picker, etc.\n * await putVideoToStorage({ uploadUrl, contentType, uri: asset.uri, onProgress });\n *\n * Note: your backend (not this utility) should hold the API key and call\n * createVideo / completeUpload on your app's behalf.\n */\n\nimport { HyperserveError, HyperserveTimeoutError, HyperserveUploadError } from \"./errors.js\";\n\nexport type { PutVideoToStorageRNOptions, VideoResolution, VideoStatus } from \"./types.js\";\nexport { HyperserveError, HyperserveTimeoutError, HyperserveUploadError };\n\nimport { putToStorage } from \"./storage.js\";\nimport type { PutVideoToStorageRNOptions } from \"./types.js\";\n\n/**\n * PUT a video file to the presigned storage URL obtained from your backend.\n * Accepts a local file URI from a React Native video/image picker.\n * No API key required — this call goes directly to storage, not to the Hyperserve API.\n *\n * @example\n * const { uploadUrl, contentType } = await fetch('https://your-api.com/create-upload', {\n * method: 'POST',\n * body: JSON.stringify({ filename: asset.fileName, fileSizeBytes: asset.fileSize }),\n * }).then(r => r.json());\n *\n * await putVideoToStorage({ uploadUrl, contentType, uri: asset.uri, onProgress: (p) => setProgress(p) });\n *\n * await fetch('https://your-api.com/complete-upload', {\n * method: 'POST',\n * body: JSON.stringify({ videoId }),\n * });\n */\nexport async function putVideoToStorage(options: PutVideoToStorageRNOptions): Promise<void> {\n\tconst { uploadUrl, contentType, uri, onProgress } = options;\n\n\t// Fetch the local file URI to obtain a Blob. React Native's fetch implementation\n\t// supports file:// URIs, allowing us to read local files from the device.\n\tconst localResponse = await fetch(uri);\n\tif (!localResponse.ok) {\n\t\tthrow new HyperserveUploadError(`Failed to read local file: ${uri}`);\n\t}\n\tconst blob = await localResponse.blob();\n\n\treturn putToStorage(uploadUrl, contentType, blob, onProgress);\n}\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hyperserve/hyperserve-js",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "TypeScript SDK for the Hyperserve video infrastructure API",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Ryan Trann <admin@hyperserve.io>",
|
|
7
|
+
"homepage": "https://hyperserve.io",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/hyper-serve/hyperserve-js"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/hyper-serve/hyperserve-js/issues"
|
|
14
|
+
},
|
|
15
|
+
"type": "module",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"import": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"default": "./dist/index.js"
|
|
21
|
+
},
|
|
22
|
+
"require": {
|
|
23
|
+
"types": "./dist/index.d.cts",
|
|
24
|
+
"default": "./dist/index.cjs"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"./browser": {
|
|
28
|
+
"import": {
|
|
29
|
+
"types": "./dist/browser.d.ts",
|
|
30
|
+
"default": "./dist/browser.js"
|
|
31
|
+
},
|
|
32
|
+
"require": {
|
|
33
|
+
"types": "./dist/browser.d.cts",
|
|
34
|
+
"default": "./dist/browser.cjs"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"./react-native": {
|
|
38
|
+
"react-native": "./dist/react-native.js",
|
|
39
|
+
"import": {
|
|
40
|
+
"types": "./dist/react-native.d.ts",
|
|
41
|
+
"default": "./dist/react-native.js"
|
|
42
|
+
},
|
|
43
|
+
"require": {
|
|
44
|
+
"types": "./dist/react-native.d.cts",
|
|
45
|
+
"default": "./dist/react-native.cjs"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"sideEffects": false,
|
|
50
|
+
"main": "./dist/index.cjs",
|
|
51
|
+
"module": "./dist/index.js",
|
|
52
|
+
"types": "./dist/index.d.ts",
|
|
53
|
+
"files": [
|
|
54
|
+
"dist"
|
|
55
|
+
],
|
|
56
|
+
"scripts": {
|
|
57
|
+
"build": "tsup",
|
|
58
|
+
"dev": "tsup --watch",
|
|
59
|
+
"typecheck": "tsc --noEmit",
|
|
60
|
+
"lint": "biome lint ./src",
|
|
61
|
+
"lint:fix": "biome lint --write ./src",
|
|
62
|
+
"format": "biome format ./src",
|
|
63
|
+
"format:write": "biome format --write ./src",
|
|
64
|
+
"check": "biome check ./src",
|
|
65
|
+
"check:write": "biome check --write ./src",
|
|
66
|
+
"test": "vitest run",
|
|
67
|
+
"test:watch": "vitest",
|
|
68
|
+
"prepublishOnly": "npm run build && npm run typecheck",
|
|
69
|
+
"prepare": "husky"
|
|
70
|
+
},
|
|
71
|
+
"devDependencies": {
|
|
72
|
+
"@biomejs/biome": "^2.4.9",
|
|
73
|
+
"@types/node": "^22.0.0",
|
|
74
|
+
"husky": "^9.1.7",
|
|
75
|
+
"tsup": "^8.5.1",
|
|
76
|
+
"typescript": "^6.0.2",
|
|
77
|
+
"vitest": "^4.1.2"
|
|
78
|
+
},
|
|
79
|
+
"engines": {
|
|
80
|
+
"node": ">=18"
|
|
81
|
+
},
|
|
82
|
+
"keywords": [
|
|
83
|
+
"hyperserve",
|
|
84
|
+
"video",
|
|
85
|
+
"sdk",
|
|
86
|
+
"upload",
|
|
87
|
+
"transcoding"
|
|
88
|
+
]
|
|
89
|
+
}
|