diff --git a/packages/expo-blob/build/BlobModule.d.ts b/packages/expo-blob/build/BlobModule.d.ts index d7cda196885f19..478f8d8227a18d 100644 --- a/packages/expo-blob/build/BlobModule.d.ts +++ b/packages/expo-blob/build/BlobModule.d.ts @@ -1,16 +1,4 @@ -import { NativeModule, SharedObject } from 'expo'; -import { Blob, BlobPart } from './BlobModule.types'; -declare class NativeBlob extends SharedObject { - readonly size: number; - readonly type: string; - constructor(blobParts?: BlobPart[], options?: BlobPropertyBag); - slice(start?: number, end?: number, contentType?: string): ExpoBlob; - bytes(): Promise; - text(): Promise; -} -declare class ExpoBlobModule extends NativeModule { - Blob: typeof NativeBlob; -} +import { Blob, ExpoBlobModule } from './BlobModule.types'; declare const NativeBlobModule: ExpoBlobModule; export declare class ExpoBlob extends NativeBlobModule.Blob implements Blob { constructor(blobParts?: any[] | Iterable, options?: BlobPropertyBag); diff --git a/packages/expo-blob/build/BlobModule.d.ts.map b/packages/expo-blob/build/BlobModule.d.ts.map index db56c2511ba493..22a51687917a3a 100644 --- a/packages/expo-blob/build/BlobModule.d.ts.map +++ b/packages/expo-blob/build/BlobModule.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"BlobModule.d.ts","sourceRoot":"","sources":["../src/BlobModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAuB,YAAY,EAAE,MAAM,MAAM,CAAC;AAEvE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAQpD,OAAO,OAAO,UAAW,SAAQ,YAAY;IAC3C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBACV,SAAS,CAAC,EAAE,QAAQ,EAAE,EAAE,OAAO,CAAC,EAAE,eAAe;IAC7D,KAAK,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,QAAQ;IACnE,KAAK,IAAI,OAAO,CAAC,UAAU,CAAC;IAC5B,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC;CACxB;AAED,OAAO,OAAO,cAAe,SAAQ,YAAY;IAC/C,IAAI,EAAE,OAAO,UAAU,CAAC;CACzB;AAED,QAAA,MAAM,gBAAgB,gBAAkD,CAAC;AAEzE,qBAAa,QAAS,SAAQ,gBAAgB,CAAC,IAAK,YAAW,IAAI;gBACrD,SAAS,CAAC,EAAE,GAAG,EAAE,GAAG,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,EAAE,eAAe;IAyBxE,KAAK,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,QAAQ;IAOnE,MAAM,IAAI,cAAc;IAsClB,WAAW,IAAI,OAAO,CAAC,eAAe,CAAC;IAQ7C,QAAQ,IAAI,MAAM;IAKlB,MAAM,KAAK,MAAM,WAEhB;CACF"} \ No newline at end of file +{"version":3,"file":"BlobModule.d.ts","sourceRoot":"","sources":["../src/BlobModule.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAQ1D,QAAA,MAAM,gBAAgB,gBAAkD,CAAC;AAEzE,qBAAa,QAAS,SAAQ,gBAAgB,CAAC,IAAK,YAAW,IAAI;gBACrD,SAAS,CAAC,EAAE,GAAG,EAAE,GAAG,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,EAAE,eAAe;IAyBxE,KAAK,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,QAAQ;IAOnE,MAAM,IAAI,cAAc;IAsClB,WAAW,IAAI,OAAO,CAAC,eAAe,CAAC;IAQ7C,QAAQ,IAAI,MAAM;IAKlB,MAAM,KAAK,MAAM,WAEhB;CACF"} \ No newline at end of file diff --git a/packages/expo-blob/build/BlobModule.js b/packages/expo-blob/build/BlobModule.js index 51ec65683c18bb..749ad8cda63e20 100644 --- a/packages/expo-blob/build/BlobModule.js +++ b/packages/expo-blob/build/BlobModule.js @@ -1,5 +1,5 @@ import { requireNativeModule } from 'expo'; -import { isTypedArray, normalizedContentType, preprocessOptions, DEFAULT_CHUNK_SIZE, } from './utils'; +import { DEFAULT_CHUNK_SIZE, isTypedArray, normalizedContentType, preprocessOptions, } from './utils'; const NativeBlobModule = requireNativeModule('ExpoBlob'); export class ExpoBlob extends NativeBlobModule.Blob { constructor(blobParts, options) { diff --git a/packages/expo-blob/build/BlobModule.js.map b/packages/expo-blob/build/BlobModule.js.map index 27f9d646b5ebab..869f012bb91f84 100644 --- a/packages/expo-blob/build/BlobModule.js.map +++ b/packages/expo-blob/build/BlobModule.js.map @@ -1 +1 @@ -{"version":3,"file":"BlobModule.js","sourceRoot":"","sources":["../src/BlobModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,mBAAmB,EAAgB,MAAM,MAAM,CAAC;AAGvE,OAAO,EACL,YAAY,EACZ,qBAAqB,EACrB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,SAAS,CAAC;AAejB,MAAM,gBAAgB,GAAG,mBAAmB,CAAiB,UAAU,CAAC,CAAC;AAEzE,MAAM,OAAO,QAAS,SAAQ,gBAAgB,CAAC,IAAI;IACjD,YAAY,SAAiC,EAAE,OAAyB;QACtE,MAAM,YAAY,GAAG,CAAC,CAAM,EAAE,EAAE;YAC9B,IAAI,CAAC,YAAY,WAAW,EAAE,CAAC;gBAC7B,OAAO,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;YAC3B,CAAC;YACD,IAAI,CAAC,YAAY,QAAQ,IAAI,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC7C,OAAO,CAAC,CAAC;YACX,CAAC;YACD,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;QACnB,CAAC,CAAC;QAEF,MAAM,GAAG,GAAU,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IAED,6EAA6E;IAC7E,MAAM,KAAK,MAAM;QACf,OAAO,CAAC,CAAC;IACX,CAAC;CACF","sourcesContent":["import { NativeModule, requireNativeModule, SharedObject } from 'expo';\n\nimport { Blob, BlobPart } from './BlobModule.types';\nimport {\n isTypedArray,\n normalizedContentType,\n preprocessOptions,\n DEFAULT_CHUNK_SIZE,\n} from './utils';\n\ndeclare class NativeBlob extends SharedObject {\n readonly size: number;\n readonly type: string;\n constructor(blobParts?: BlobPart[], options?: BlobPropertyBag);\n slice(start?: number, end?: number, contentType?: string): ExpoBlob;\n bytes(): Promise;\n text(): Promise;\n}\n\ndeclare class ExpoBlobModule extends NativeModule {\n Blob: typeof NativeBlob;\n}\n\nconst NativeBlobModule = requireNativeModule('ExpoBlob');\n\nexport class ExpoBlob extends NativeBlobModule.Blob implements Blob {\n constructor(blobParts?: any[] | Iterable, options?: BlobPropertyBag) {\n const inputMapping = (v: any) => {\n if (v instanceof ArrayBuffer) {\n return new Uint8Array(v);\n }\n if (v instanceof ExpoBlob || isTypedArray(v)) {\n return v;\n }\n return String(v);\n };\n\n const bps: any[] = [];\n\n if (blobParts === undefined) {\n super([], preprocessOptions(options));\n } else if (blobParts === null || typeof blobParts !== 'object') {\n throw TypeError();\n } else {\n for (const bp of blobParts) {\n bps.push(inputMapping(bp));\n }\n super(bps, preprocessOptions(options));\n }\n }\n\n slice(start?: number, end?: number, contentType?: string): ExpoBlob {\n const normalizedType = normalizedContentType(contentType);\n const slicedBlob = super.slice(start, end, normalizedType);\n Object.setPrototypeOf(slicedBlob, ExpoBlob.prototype);\n return slicedBlob;\n }\n\n stream(): ReadableStream {\n const self = this;\n let offset = 0;\n let bytesPromise: Promise | null = null;\n\n return new ReadableStream({\n type: 'bytes',\n async pull(controller: any) {\n if (!bytesPromise) {\n bytesPromise = self.bytes();\n }\n const bytes = await bytesPromise;\n if (offset >= bytes.length) {\n controller.close();\n return;\n }\n\n if (controller.byobRequest?.view) {\n const view = controller.byobRequest.view;\n const end = Math.min(offset + view.byteLength, bytes.length);\n const chunk = bytes.subarray(offset, end);\n view.set(chunk, 0);\n controller.byobRequest.respond(chunk.length);\n offset = end;\n if (offset >= bytes.length) {\n controller.close();\n }\n return;\n }\n\n const chunkSize = DEFAULT_CHUNK_SIZE;\n const end = Math.min(offset + chunkSize, bytes.length);\n controller.enqueue(bytes.subarray(offset, end));\n offset = end;\n },\n });\n }\n\n async arrayBuffer(): Promise {\n return super\n .bytes()\n .then((bytes: Uint8Array) =>\n bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength)\n );\n }\n\n toString(): string {\n return '[object Blob]';\n }\n\n // Changed the length property to match that of the default js implementation\n static get length() {\n return 0;\n }\n}\n"]} \ No newline at end of file +{"version":3,"file":"BlobModule.js","sourceRoot":"","sources":["../src/BlobModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAG3C,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,SAAS,CAAC;AAEjB,MAAM,gBAAgB,GAAG,mBAAmB,CAAiB,UAAU,CAAC,CAAC;AAEzE,MAAM,OAAO,QAAS,SAAQ,gBAAgB,CAAC,IAAI;IACjD,YAAY,SAAiC,EAAE,OAAyB;QACtE,MAAM,YAAY,GAAG,CAAC,CAAM,EAAE,EAAE;YAC9B,IAAI,CAAC,YAAY,WAAW,EAAE,CAAC;gBAC7B,OAAO,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;YAC3B,CAAC;YACD,IAAI,CAAC,YAAY,QAAQ,IAAI,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC7C,OAAO,CAAC,CAAC;YACX,CAAC;YACD,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;QACnB,CAAC,CAAC;QAEF,MAAM,GAAG,GAAU,EAAE,CAAC;QAEtB,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;YAC5B,KAAK,CAAC,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F","sourcesContent":["import { requireNativeModule } from 'expo';\n\nimport { Blob, ExpoBlobModule } from './BlobModule.types';\nimport {\n DEFAULT_CHUNK_SIZE,\n isTypedArray,\n normalizedContentType,\n preprocessOptions,\n} from './utils';\n\nconst NativeBlobModule = requireNativeModule('ExpoBlob');\n\nexport class ExpoBlob extends NativeBlobModule.Blob implements Blob {\n constructor(blobParts?: any[] | Iterable, options?: BlobPropertyBag) {\n const inputMapping = (v: any) => {\n if (v instanceof ArrayBuffer) {\n return new Uint8Array(v);\n }\n if (v instanceof ExpoBlob || isTypedArray(v)) {\n return v;\n }\n return String(v);\n };\n\n const bps: any[] = [];\n\n if (blobParts === undefined) {\n super([], preprocessOptions(options));\n } else if (blobParts === null || typeof blobParts !== 'object') {\n throw TypeError();\n } else {\n for (const bp of blobParts) {\n bps.push(inputMapping(bp));\n }\n super(bps, preprocessOptions(options));\n }\n }\n\n slice(start?: number, end?: number, contentType?: string): ExpoBlob {\n const normalizedType = normalizedContentType(contentType);\n const slicedBlob = super.slice(start, end, normalizedType);\n Object.setPrototypeOf(slicedBlob, ExpoBlob.prototype);\n return slicedBlob;\n }\n\n stream(): ReadableStream {\n const self = this;\n let offset = 0;\n let bytesPromise: Promise | null = null;\n\n return new ReadableStream({\n type: 'bytes',\n async pull(controller: any) {\n if (!bytesPromise) {\n bytesPromise = self.bytes();\n }\n const bytes = await bytesPromise;\n if (offset >= bytes.length) {\n controller.close();\n return;\n }\n\n if (controller.byobRequest?.view) {\n const view = controller.byobRequest.view;\n const end = Math.min(offset + view.byteLength, bytes.length);\n const chunk = bytes.subarray(offset, end);\n view.set(chunk, 0);\n controller.byobRequest.respond(chunk.length);\n offset = end;\n if (offset >= bytes.length) {\n controller.close();\n }\n return;\n }\n\n const chunkSize = DEFAULT_CHUNK_SIZE;\n const end = Math.min(offset + chunkSize, bytes.length);\n controller.enqueue(bytes.subarray(offset, end));\n offset = end;\n },\n });\n }\n\n async arrayBuffer(): Promise {\n return super\n .bytes()\n .then((bytes: Uint8Array) =>\n bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength)\n );\n }\n\n toString(): string {\n return '[object Blob]';\n }\n\n // Changed the length property to match that of the default js implementation\n static get length() {\n return 0;\n }\n}\n"]} \ No newline at end of file diff --git a/packages/expo-blob/build/BlobModule.types.d.ts b/packages/expo-blob/build/BlobModule.types.d.ts index 67ee05e989afee..fbe845f468bf0c 100644 --- a/packages/expo-blob/build/BlobModule.types.d.ts +++ b/packages/expo-blob/build/BlobModule.types.d.ts @@ -1,9 +1,85 @@ +import { NativeModule, SharedObject } from 'expo'; +import { ExpoBlob } from './BlobModule'; +/** + * Represents immutable raw binary data, similar to the web Blob API. + * Allows for efficient storage and manipulation of binary data, such as files or network responses. + */ export declare class Blob { - constructor(blobParts?: any, options?: BlobPropertyBag); + /** + * Creates a new Blob object containing a concatenation of the given blobParts. + * @param blobParts An array of BlobPart to include in the Blob. + * @param options An optional BlobPropertyBag dictionary that may specify the endings and MIME type. + */ + constructor(blobParts?: BlobPart[], options?: BlobPropertyBag); + /** + * Returns a new Blob object containing the data in the specified range of bytes of the source Blob. + * @param start The starting byte index (inclusive). + * @param end The ending byte index (exclusive). + * @param contentType The MIME type of the new Blob. If not provided, defaults to an empty string. + * @returns A new Blob object containing the specified bytes. + */ slice(start?: number, end?: number, contentType?: string): Blob; + /** + * Returns a ReadableStream that allows streaming the Blob's data in chunks. + * Note: The current implementation loads the entire Blob into memory before streaming. + * @returns A ReadableStream of the Blob's data. + */ stream(): ReadableStream; - text(): Promise; + /** + * Returns a Promise that resolves with the entire contents of the Blob as an ArrayBuffer. + * @returns Promise resolving to the Blob's binary data as an ArrayBuffer. + */ arrayBuffer(): Promise; } +/** + * Native representation of a Blob, used for communication with the native layer. + * Exposes methods for slicing and retrieving the Blob's data as bytes or text. + */ +export declare class NativeBlob extends SharedObject { + /** + * The size of the Blob in bytes. + */ + readonly size: number; + /** + * The MIME type of the Blob. + */ + readonly type: string; + /** + * Creates a new NativeBlob object from the given parts and options. + * @param blobParts An array of BlobPart to include in the Blob. + * @param options An optional BlobPropertyBag dictionary. + */ + constructor(blobParts?: BlobPart[], options?: BlobPropertyBag); + /** + * Returns a new Blob from native implementation object containing the data in the specified range of bytes of the source Blob. + * @param start The starting byte index (inclusive). + * @param end The ending byte index (exclusive). + * @param contentType The MIME type of the new Blob. If not provided, defaults to an empty string. + * @returns A new Blob from native implementation object containing the specified bytes. + */ + slice(start?: number, end?: number, contentType?: string): ExpoBlob; + /** + * Returns a Promise that resolves with the entire contents of the Blob as a Uint8Array. + * @returns Promise resolving to the Blob's binary data as a Uint8Array. + */ + bytes(): Promise; + /** + * Returns a Promise that resolves with the entire contents of the Blob as a UTF-8 string. + * @returns Promise resolving to the Blob's text contents. + */ + text(): Promise; +} +/** + * Native module interface for ExpoBlob, exposing the Blob class to JavaScript. + */ +export declare class ExpoBlobModule extends NativeModule { + /** + * The native Blob class constructor. + */ + Blob: typeof NativeBlob; +} +/** + * Represents a part of a Blob. Can be a string, ArrayBuffer, ArrayBufferView, or another Blob. + */ export type BlobPart = string | ArrayBuffer | ArrayBufferView | Blob; //# sourceMappingURL=BlobModule.types.d.ts.map \ No newline at end of file diff --git a/packages/expo-blob/build/BlobModule.types.d.ts.map b/packages/expo-blob/build/BlobModule.types.d.ts.map index 9122531242939c..0911bd817857e0 100644 --- a/packages/expo-blob/build/BlobModule.types.d.ts.map +++ b/packages/expo-blob/build/BlobModule.types.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"BlobModule.types.d.ts","sourceRoot":"","sources":["../src/BlobModule.types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,IAAI;gBACX,SAAS,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,eAAe;IAEtD,KAAK,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI;IAC/D,MAAM,IAAI,cAAc;IACxB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xB;AAED;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,YAAY;IACtD;;OAEG;IACH,IAAI,EAAE,OAAO,UAAU,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,eAAe,GAAG,IAAI,CAAC"} \ No newline at end of file diff --git a/packages/expo-blob/build/BlobModule.types.js.map b/packages/expo-blob/build/BlobModule.types.js.map index c059672ea228a4..ca238959deb010 100644 --- a/packages/expo-blob/build/BlobModule.types.js.map +++ b/packages/expo-blob/build/BlobModule.types.js.map @@ -1 +1 @@ -{"version":3,"file":"BlobModule.types.js","sourceRoot":"","sources":["../src/BlobModule.types.ts"],"names":[],"mappings":"","sourcesContent":["export declare class Blob {\n constructor(blobParts?: any, options?: BlobPropertyBag);\n\n slice(start?: number, end?: number, contentType?: string): Blob;\n stream(): ReadableStream;\n text(): Promise;\n arrayBuffer(): Promise;\n}\n\nexport type BlobPart = string | ArrayBuffer | ArrayBufferView | Blob;\n"]} \ No newline at end of file +{"version":3,"file":"BlobModule.types.js","sourceRoot":"","sources":["../src/BlobModule.types.ts"],"names":[],"mappings":"","sourcesContent":["import { NativeModule, SharedObject } from 'expo';\n\nimport { ExpoBlob } from './BlobModule';\n\n/**\n * Represents immutable raw binary data, similar to the web Blob API.\n * Allows for efficient storage and manipulation of binary data, such as files or network responses.\n */\nexport declare class Blob {\n /**\n * Creates a new Blob object containing a concatenation of the given blobParts.\n * @param blobParts An array of BlobPart to include in the Blob.\n * @param options An optional BlobPropertyBag dictionary that may specify the endings and MIME type.\n */\n constructor(blobParts?: BlobPart[], options?: BlobPropertyBag);\n\n /**\n * Returns a new Blob object containing the data in the specified range of bytes of the source Blob.\n * @param start The starting byte index (inclusive).\n * @param end The ending byte index (exclusive).\n * @param contentType The MIME type of the new Blob. If not provided, defaults to an empty string.\n * @returns A new Blob object containing the specified bytes.\n */\n slice(start?: number, end?: number, contentType?: string): Blob;\n\n /**\n * Returns a ReadableStream that allows streaming the Blob's data in chunks.\n * Note: The current implementation loads the entire Blob into memory before streaming.\n * @returns A ReadableStream of the Blob's data.\n */\n stream(): ReadableStream;\n\n /**\n * Returns a Promise that resolves with the entire contents of the Blob as an ArrayBuffer.\n * @returns Promise resolving to the Blob's binary data as an ArrayBuffer.\n */\n arrayBuffer(): Promise;\n}\n\n/**\n * Native representation of a Blob, used for communication with the native layer.\n * Exposes methods for slicing and retrieving the Blob's data as bytes or text.\n */\nexport declare class NativeBlob extends SharedObject {\n /**\n * The size of the Blob in bytes.\n */\n readonly size: number;\n /**\n * The MIME type of the Blob.\n */\n readonly type: string;\n\n /**\n * Creates a new NativeBlob object from the given parts and options.\n * @param blobParts An array of BlobPart to include in the Blob.\n * @param options An optional BlobPropertyBag dictionary.\n */\n constructor(blobParts?: BlobPart[], options?: BlobPropertyBag);\n\n /**\n * Returns a new Blob from native implementation object containing the data in the specified range of bytes of the source Blob.\n * @param start The starting byte index (inclusive).\n * @param end The ending byte index (exclusive).\n * @param contentType The MIME type of the new Blob. If not provided, defaults to an empty string.\n * @returns A new Blob from native implementation object containing the specified bytes.\n */\n slice(start?: number, end?: number, contentType?: string): ExpoBlob;\n\n /**\n * Returns a Promise that resolves with the entire contents of the Blob as a Uint8Array.\n * @returns Promise resolving to the Blob's binary data as a Uint8Array.\n */\n bytes(): Promise;\n\n /**\n * Returns a Promise that resolves with the entire contents of the Blob as a UTF-8 string.\n * @returns Promise resolving to the Blob's text contents.\n */\n text(): Promise;\n}\n\n/**\n * Native module interface for ExpoBlob, exposing the Blob class to JavaScript.\n */\nexport declare class ExpoBlobModule extends NativeModule {\n /**\n * The native Blob class constructor.\n */\n Blob: typeof NativeBlob;\n}\n\n/**\n * Represents a part of a Blob. Can be a string, ArrayBuffer, ArrayBufferView, or another Blob.\n */\nexport type BlobPart = string | ArrayBuffer | ArrayBufferView | Blob;\n"]} \ No newline at end of file diff --git a/packages/expo-blob/build/index.d.ts b/packages/expo-blob/build/index.d.ts index f2e8b3e90aa870..8864f4f17f1fac 100644 --- a/packages/expo-blob/build/index.d.ts +++ b/packages/expo-blob/build/index.d.ts @@ -1,2 +1,3 @@ -export { ExpoBlob } from './BlobModule'; +export * from './BlobModule'; +export * from './BlobModule.types'; //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/packages/expo-blob/build/index.d.ts.map b/packages/expo-blob/build/index.d.ts.map index 90104b5f7df38a..41b03bc6adb9bf 100644 --- a/packages/expo-blob/build/index.d.ts.map +++ b/packages/expo-blob/build/index.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC"} \ No newline at end of file +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC"} \ No newline at end of file diff --git a/packages/expo-blob/build/index.js b/packages/expo-blob/build/index.js index 46e4c4acee532f..fab175466bad41 100644 --- a/packages/expo-blob/build/index.js +++ b/packages/expo-blob/build/index.js @@ -1,2 +1,3 @@ -export { ExpoBlob } from './BlobModule'; +export * from './BlobModule'; +export * from './BlobModule.types'; //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/packages/expo-blob/build/index.js.map b/packages/expo-blob/build/index.js.map index 91de68fbd14439..d168ac2058411e 100644 --- a/packages/expo-blob/build/index.js.map +++ b/packages/expo-blob/build/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC","sourcesContent":["export { ExpoBlob } from './BlobModule';\n"]} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC","sourcesContent":["export * from './BlobModule';\nexport * from './BlobModule.types';\n"]} \ No newline at end of file diff --git a/packages/expo-blob/ios/ExpoBlob.swift b/packages/expo-blob/ios/ExpoBlob.swift index c767ff5c16a77f..ed14d5f3bb99d8 100644 --- a/packages/expo-blob/ios/ExpoBlob.swift +++ b/packages/expo-blob/ios/ExpoBlob.swift @@ -44,10 +44,6 @@ public class ExpoBlob: Module { return blob.slice(start: relativeStart, end: relativeEnd, contentType: contentType ?? "") } - Function("syncText") { (blob: Blob) in - blob.text() - } - AsyncFunction("text") { (blob: Blob) in blob.text() } diff --git a/packages/expo-blob/src/BlobModule.ts b/packages/expo-blob/src/BlobModule.ts index d34b04b6cbed6e..6840282c597a3e 100644 --- a/packages/expo-blob/src/BlobModule.ts +++ b/packages/expo-blob/src/BlobModule.ts @@ -1,26 +1,13 @@ -import { NativeModule, requireNativeModule, SharedObject } from 'expo'; +import { requireNativeModule } from 'expo'; -import { Blob, BlobPart } from './BlobModule.types'; +import { Blob, ExpoBlobModule } from './BlobModule.types'; import { + DEFAULT_CHUNK_SIZE, isTypedArray, normalizedContentType, preprocessOptions, - DEFAULT_CHUNK_SIZE, } from './utils'; -declare class NativeBlob extends SharedObject { - readonly size: number; - readonly type: string; - constructor(blobParts?: BlobPart[], options?: BlobPropertyBag); - slice(start?: number, end?: number, contentType?: string): ExpoBlob; - bytes(): Promise; - text(): Promise; -} - -declare class ExpoBlobModule extends NativeModule { - Blob: typeof NativeBlob; -} - const NativeBlobModule = requireNativeModule('ExpoBlob'); export class ExpoBlob extends NativeBlobModule.Blob implements Blob { diff --git a/packages/expo-blob/src/BlobModule.types.ts b/packages/expo-blob/src/BlobModule.types.ts index 4cc74d6ccef999..f2e06767aa9173 100644 --- a/packages/expo-blob/src/BlobModule.types.ts +++ b/packages/expo-blob/src/BlobModule.types.ts @@ -1,10 +1,96 @@ +import { NativeModule, SharedObject } from 'expo'; + +import { ExpoBlob } from './BlobModule'; + +/** + * Represents immutable raw binary data, similar to the web Blob API. + * Allows for efficient storage and manipulation of binary data, such as files or network responses. + */ export declare class Blob { - constructor(blobParts?: any, options?: BlobPropertyBag); + /** + * Creates a new Blob object containing a concatenation of the given blobParts. + * @param blobParts An array of BlobPart to include in the Blob. + * @param options An optional BlobPropertyBag dictionary that may specify the endings and MIME type. + */ + constructor(blobParts?: BlobPart[], options?: BlobPropertyBag); + /** + * Returns a new Blob object containing the data in the specified range of bytes of the source Blob. + * @param start The starting byte index (inclusive). + * @param end The ending byte index (exclusive). + * @param contentType The MIME type of the new Blob. If not provided, defaults to an empty string. + * @returns A new Blob object containing the specified bytes. + */ slice(start?: number, end?: number, contentType?: string): Blob; + + /** + * Returns a ReadableStream that allows streaming the Blob's data in chunks. + * Note: The current implementation loads the entire Blob into memory before streaming. + * @returns A ReadableStream of the Blob's data. + */ stream(): ReadableStream; - text(): Promise; + + /** + * Returns a Promise that resolves with the entire contents of the Blob as an ArrayBuffer. + * @returns Promise resolving to the Blob's binary data as an ArrayBuffer. + */ arrayBuffer(): Promise; } +/** + * Native representation of a Blob, used for communication with the native layer. + * Exposes methods for slicing and retrieving the Blob's data as bytes or text. + */ +export declare class NativeBlob extends SharedObject { + /** + * The size of the Blob in bytes. + */ + readonly size: number; + /** + * The MIME type of the Blob. + */ + readonly type: string; + + /** + * Creates a new NativeBlob object from the given parts and options. + * @param blobParts An array of BlobPart to include in the Blob. + * @param options An optional BlobPropertyBag dictionary. + */ + constructor(blobParts?: BlobPart[], options?: BlobPropertyBag); + + /** + * Returns a new Blob from native implementation object containing the data in the specified range of bytes of the source Blob. + * @param start The starting byte index (inclusive). + * @param end The ending byte index (exclusive). + * @param contentType The MIME type of the new Blob. If not provided, defaults to an empty string. + * @returns A new Blob from native implementation object containing the specified bytes. + */ + slice(start?: number, end?: number, contentType?: string): ExpoBlob; + + /** + * Returns a Promise that resolves with the entire contents of the Blob as a Uint8Array. + * @returns Promise resolving to the Blob's binary data as a Uint8Array. + */ + bytes(): Promise; + + /** + * Returns a Promise that resolves with the entire contents of the Blob as a UTF-8 string. + * @returns Promise resolving to the Blob's text contents. + */ + text(): Promise; +} + +/** + * Native module interface for ExpoBlob, exposing the Blob class to JavaScript. + */ +export declare class ExpoBlobModule extends NativeModule { + /** + * The native Blob class constructor. + */ + Blob: typeof NativeBlob; +} + +/** + * Represents a part of a Blob. Can be a string, ArrayBuffer, ArrayBufferView, or another Blob. + */ export type BlobPart = string | ArrayBuffer | ArrayBufferView | Blob; diff --git a/packages/expo-blob/src/index.ts b/packages/expo-blob/src/index.ts index dbf1ed535c5b25..9474bf2998775d 100644 --- a/packages/expo-blob/src/index.ts +++ b/packages/expo-blob/src/index.ts @@ -1 +1,2 @@ -export { ExpoBlob } from './BlobModule'; +export * from './BlobModule'; +export * from './BlobModule.types';