@daugasauron/dolly-host-upload 0.1.4 → 0.1.5-rc.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/abi.mjs CHANGED
@@ -14,4 +14,4 @@ export const DOLLY_UPLOAD_CHUNK_CAPACITY = 1048576;
14
14
  export const DOLLY_UPLOAD_MAX_SIZE = 1073741824;
15
15
  export const DOLLY_UPLOAD_FILE = 57;
16
16
  export const DOLLY_ERRNO = Object.freeze({ E2BIG: 1, EACCES: 2, EADDRINUSE: 3, EADDRNOTAVAIL: 4, EAFNOSUPPORT: 5, EAGAIN: 6, EALREADY: 7, EBADF: 8, EBADMSG: 9, EBUSY: 10, ECANCELED: 11, ECHILD: 12, ECONNABORTED: 13, ECONNREFUSED: 14, ECONNRESET: 15, EDEADLK: 16, EDESTADDRREQ: 17, EDOM: 18, EDQUOT: 19, EEXIST: 20, EFAULT: 21, EFBIG: 22, EHOSTUNREACH: 23, EIDRM: 24, EILSEQ: 25, EINPROGRESS: 26, EINTR: 27, EINVAL: 28, EIO: 29, EISCONN: 30, EISDIR: 31, ELOOP: 32, EMFILE: 33, EMLINK: 34, EMSGSIZE: 35, EMULTIHOP: 36, ENAMETOOLONG: 37, ENETDOWN: 38, ENETRESET: 39, ENETUNREACH: 40, ENFILE: 41, ENOBUFS: 42, ENODEV: 43, ENOENT: 44, ENOEXEC: 45, ENOLCK: 46, ENOLINK: 47, ENOMEM: 48, ENOMSG: 49, ENOPROTOOPT: 50, ENOSPC: 51, ENOSYS: 52, ENOTCONN: 53, ENOTDIR: 54, ENOTEMPTY: 55, ENOTRECOVERABLE: 56, ENOTSOCK: 57, ENOTTY: 59, ENXIO: 60, EOVERFLOW: 61, EOWNERDEAD: 62, EPERM: 63, EPIPE: 64, EPROTO: 65, EPROTONOSUPPORT: 66, EPROTOTYPE: 67, ERANGE: 68, EROFS: 69, ESPIPE: 70, ESRCH: 71, ESTALE: 72, ETIMEDOUT: 73, ETXTBSY: 74, EXDEV: 75, ENODATA: 116, ENOTSUP: 138 });
17
- export const DOLLY_UPLOAD_ABI_DIGEST = "31e7e9d53cf59e23fc88b4d3d283cb4d9f1a85498628a9137065a476245029fc";
17
+ export const DOLLY_UPLOAD_ABI_DIGEST = "c3381d9b3756bee2ae96859da6ffe3c725a8b683d85e19af6cc80bbc8728aeef";
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
- "version": "0.1.4",
2
+ "version": "0.1.5-rc.0",
3
3
  "type": "module",
4
4
  "name": "@daugasauron/dolly-host-upload",
5
5
  "license": "MIT",
6
6
  "dependencies": {
7
- "@daugasauron/dolly": "0.1.4"
7
+ "@daugasauron/dolly": "0.1.5-rc.0"
8
8
  },
9
9
  "description": "Dolly's upload@0 host module: ask for a file; the user picks it.",
10
10
  "repository": {
package/transport.mjs CHANGED
@@ -70,8 +70,10 @@ export class UploadTransport {
70
70
  else if (!(file instanceof Blob) || file.size > DOLLY_UPLOAD_MAX_SIZE) {
71
71
  await publish(new Uint8Array(), true, errno.EFBIG);
72
72
  } else {
73
- // One reused staging buffer: reading allocates nothing per chunk.
74
- const reader = file.stream().getReader({ mode: "byob" });
73
+ // One reused staging buffer: reading allocates nothing per chunk. The
74
+ // transfer holds its reader: Chrome collects a Blob's stream that only
75
+ // its pending BYOB read reaches, and that read never ends.
76
+ const reader = this.active.reader = file.stream().getReader({ mode: "byob" });
75
77
  let staging = new ArrayBuffer(chunkCapacity), sent = 0;
76
78
  size = file.size;
77
79
  do {
@@ -114,7 +116,7 @@ export class UploadTransport {
114
116
  }
115
117
 
116
118
  // One modal dialog per request: the picker, then progress until the transfer ends.
117
- export function chooseUploadFile(controller) {
119
+ export function chooseUploadFile(mount, controller) {
118
120
  return new Promise(resolve => {
119
121
  const { signal } = controller;
120
122
  if (signal.aborted) { resolve(null); return; }
@@ -143,7 +145,7 @@ export function chooseUploadFile(controller) {
143
145
  resolve(file);
144
146
  });
145
147
  signal.addEventListener("abort", () => { dialog.close(); dialog.remove(); resolve(null); }, { once: true });
146
- document.body.append(dialog);
148
+ mount.append(dialog);
147
149
  if (document.pointerLockElement) document.exitPointerLock();
148
150
  dialog.showModal();
149
151
  });
package/upload.mjs CHANGED
@@ -5,7 +5,7 @@ export { DOLLY_UPLOAD_ABI_DIGEST as digest } from "./abi.mjs";
5
5
  // The page shows the picker and the progress; the Worker asks for a file,
6
6
  // reads it and writes it into the mailbox. The user's Cancel reaches the
7
7
  // Worker, and the Worker's end of a transfer closes the dialog.
8
- export function browser({ send }) {
8
+ export function browser({ mount, send }) {
9
9
  let controller = null;
10
10
  return {
11
11
  messages: {
@@ -16,7 +16,7 @@ export function browser({ send }) {
16
16
  controller = null;
17
17
  send({ type: "upload-cancel" });
18
18
  }, { once: true });
19
- return chooseUploadFile(current);
19
+ return chooseUploadFile(mount, current);
20
20
  },
21
21
  "upload-progress"({ sent, size }) { showUploadProgress(sent, size); },
22
22
  "upload-close"() {