UNPKG

one

Version:

One is a React framework for web, iOS, and Android apps.

118 lines (116 loc) • 3.45 kB
function _class_call_check(instance, Constructor) { if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function"); } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _create_class(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _define_property(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true }); } else obj[key] = value; return obj; } var FileSystemReadableStreamSource = /* @__PURE__ */ (function() { "use strict"; function FileSystemReadableStreamSource2(handle) { _class_call_check(this, FileSystemReadableStreamSource2); _define_property(this, "handle", void 0); _define_property(this, "size", 1024); _define_property(this, "type", "bytes"); this.handle = handle; } _create_class(FileSystemReadableStreamSource2, [{ key: "cancel", value: function cancel() { this.handle.close(); } }, { key: "pull", value: async function pull(controller) { var _controller_byobRequest, _controller_byobRequest1; var view = (_controller_byobRequest = controller.byobRequest) === null || _controller_byobRequest === void 0 ? void 0 : _controller_byobRequest.view; var bytes; try { bytes = await this.handle.readBytes(view ? view.byteLength : this.size); } catch (error) { try { this.handle.close(); } catch (unused) {} throw error; } if (!view) { if (bytes.length === 0) { this.handle.close(); controller.close(); return; } controller.enqueue(bytes); return; } if (bytes.length === 0) { var _controller_byobRequest2; this.handle.close(); controller.close(); (_controller_byobRequest2 = controller.byobRequest) === null || _controller_byobRequest2 === void 0 ? void 0 : _controller_byobRequest2.respond(0); return; } new Uint8Array(view.buffer, view.byteOffset, view.byteLength).set(bytes); (_controller_byobRequest1 = controller.byobRequest) === null || _controller_byobRequest1 === void 0 ? void 0 : _controller_byobRequest1.respond(bytes.length); } }]); return FileSystemReadableStreamSource2; })(); var FileSystemWritableSink = /* @__PURE__ */ (function() { "use strict"; function FileSystemWritableSink2(handle) { _class_call_check(this, FileSystemWritableSink2); _define_property(this, "handle", void 0); this.handle = handle; } _create_class(FileSystemWritableSink2, [ { key: "abort", value: function abort() { this.close(); } }, { key: "close", value: function close() { this.handle.close(); } }, { key: "write", value: async function write(chunk) { try { await this.handle.writeBytes(chunk); } catch (error) { try { this.handle.close(); } catch (unused) {} throw error; } } } ]); return FileSystemWritableSink2; })(); export { FileSystemReadableStreamSource, FileSystemWritableSink }; //# sourceMappingURL=streams.native.js.map