@antcde/connect-ts 0.4.33-rc.6 → 0.4.33-rc.7

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.
@@ -1 +1 @@
1
- {"version":3,"file":"dmsUpload.d.ts","sourceRoot":"","sources":["../../src/comms/dmsUpload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAkB,oBAAoB,EAAE,MAAM,mBAAmB,CAAA;AACjH,OAAO,KAAK,EAAE,UAAU,EAAE,sBAAoB;AAU9C,MAAM,WAAW,iBAAkB,SAAQ,oBAAoB;IAC7D,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,CAAA;IAChC,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,IAAI,EAAE,CAAA;IACb,IAAI,EAAE,CAAC,QAAQ,EAAE,iBAAiB,KAAK,IAAI,CAAA;CAC5C;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,OAAO,CAAC,eAAe,EAAE,CAAC,CAAA;IAChC,MAAM,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;CACjC;AAOD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,iBAAiB,GAAG,YAAY,CA4FrE"}
1
+ {"version":3,"file":"dmsUpload.d.ts","sourceRoot":"","sources":["../../src/comms/dmsUpload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAkB,oBAAoB,EAAE,MAAM,mBAAmB,CAAA;AACjH,OAAO,KAAK,EAAE,UAAU,EAAE,sBAAoB;AAU9C,MAAM,WAAW,iBAAkB,SAAQ,oBAAoB;IAC7D,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,CAAA;IAChC,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,IAAI,EAAE,CAAA;IACb,IAAI,EAAE,CAAC,QAAQ,EAAE,iBAAiB,KAAK,IAAI,CAAA;CAC5C;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,OAAO,CAAC,eAAe,EAAE,CAAC,CAAA;IAChC,MAAM,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;CACjC;AAOD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,iBAAiB,GAAG,YAAY,CAmGrE"}
@@ -24,14 +24,20 @@ export function startDmsUpload(input) {
24
24
  results[index] = { index, filename: file.name, ...result };
25
25
  emit({ index, status: result.status, loaded: result.status === 'done' ? file.size : 0, total: file.size, file: result.file, error: result.error });
26
26
  };
27
+ // A function, not an inline check: cancelOne changes the status while we await, and
28
+ // TypeScript would otherwise keep the narrowing from an earlier check.
29
+ const isCancelled = () => slot.status === 'cancelled';
27
30
  try {
28
31
  const unreadable = await unreadableReason(file);
32
+ // Cancelled while reading: cancelOne already emitted the final event.
33
+ if (isCancelled())
34
+ return;
29
35
  if (unreadable)
30
36
  return settle({ status: 'error', error: unreadable });
31
37
  for (let attempt = 0;; attempt++) {
32
38
  // URLs are requested only when a file is about to start: they expire 300 s after issue.
33
39
  const target = await requestUrl(file.name);
34
- if (slot.status === 'cancelled')
40
+ if (isCancelled())
35
41
  return;
36
42
  slot.status = 'uploading';
37
43
  emit({ index, status: 'uploading', loaded: 0, total: file.size });
@@ -1 +1 @@
1
- {"version":3,"file":"dmsUploadErrors.d.ts","sourceRoot":"","sources":["../../src/comms/dmsUploadErrors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAMhD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU,EAAE,IAAI,GAAG,SAAS,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAWpH;AAED,kGAAkG;AAClG,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAQzE"}
1
+ {"version":3,"file":"dmsUploadErrors.d.ts","sourceRoot":"","sources":["../../src/comms/dmsUploadErrors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAMhD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU,EAAE,IAAI,GAAG,SAAS,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAWpH;AAED,kGAAkG;AAClG,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAUzE"}
@@ -20,6 +20,8 @@ export async function unreadableReason(file) {
20
20
  return null;
21
21
  }
22
22
  catch (error) {
23
- return `The file could not be read in ${here()}: ${error instanceof Error ? error.message : String(error)}`;
23
+ const reason = error instanceof Error ? error.message : String(error);
24
+ return `The file could not be read in ${here()}, the page uploading it for the app (it may have been moved, `
25
+ + `changed or deleted since it was picked): ${reason}`;
24
26
  }
25
27
  }
@@ -1 +1 @@
1
- {"version":3,"file":"dmsUploadPut.d.ts","sourceRoot":"","sources":["../../src/comms/dmsUploadPut.ts"],"names":[],"mappings":"AAAA,iHAAiH;AACjH,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAA;AAEzF;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EACjC,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,GACnC;IAAE,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IAAC,KAAK,EAAE,MAAM,IAAI,CAAA;CAAE,CAuBlD"}
1
+ {"version":3,"file":"dmsUploadPut.d.ts","sourceRoot":"","sources":["../../src/comms/dmsUploadPut.ts"],"names":[],"mappings":"AAAA,iHAAiH;AACjH,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAA;AAEzF;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EACjC,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,GACnC;IAAE,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IAAC,KAAK,EAAE,MAAM,IAAI,CAAA;CAAE,CA0BlD"}
@@ -21,6 +21,9 @@ export function putToStorage(url, headers, file, onProgress) {
21
21
  xhr.onerror = () => resolve({ network: true, sentBytes });
22
22
  xhr.onabort = () => resolve('aborted');
23
23
  });
24
- xhr.send(file);
24
+ // Send a slice, never the File itself. A File picked in another site's frame is backed by a disk
25
+ // path only that frame's process may read, so Chrome refuses it as a request body here
26
+ // (net::ERR_ACCESS_DENIED). A slice goes through the blob handle this page holds: no copy.
27
+ xhr.send(file.slice(0, file.size, file.type));
25
28
  return { done, abort: () => xhr.abort() };
26
29
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antcde/connect-ts",
3
- "version": "0.4.33-rc.6",
3
+ "version": "0.4.33-rc.7",
4
4
  "description": "Helper to connect to the ANT api",
5
5
  "type": "module",
6
6
  "main": "build/index.js",