@uploadcare/file-uploader 1.19.1 → 1.19.3

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":"side-effects.d.ts","sourceRoot":"","sources":["side-effects.js"],"names":[],"mappings":"AAwFO,+BAZ+C,CAAC,SAA1C,MAAO,OAAO,aAAa,EAAE,UAAW,+BAC1C;IACN,GAAG,EAAE,CAAC,CAAC;IACP,QAAQ,EAAE,CAAC,SAAS,SAAS,MAAM,OAAO,aAAa,EAAE,UAAU,EACjE,GAAG,EAAE,SAAS,EACd,KAAK,EAAE,OAAO,aAAa,EAAE,UAAU,CAAC,SAAS,CAAC,KAC/C,IAAI,CAAC;IACV,QAAQ,EAAE,CAAC,SAAS,SAAS,MAAM,OAAO,aAAa,EAAE,UAAU,EACjE,GAAG,EAAE,SAAS,KACX,OAAO,aAAa,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC;CAClD,QAqCH;wCAlHqD,IAAI,SAA7C,MAAO,OAAO,aAAa,EAAE,UAAW,EACkB,KAAK,SAA9D,OAAO,CAAC,MAAM,OAAO,aAAa,EAAE,UAAU,EAAE,IAAI,CAAC,EAAG;SAExD,IAAI;UACJ,KAAK;QACL,CACT,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,OAAO,aAAa,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC,GAAG,GAC1D,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,OAAO,aAAa,EAAE,UAAU,CAAC,CAAC,CAAC,GAC1D,KACE,OAAO,aAAa,EAAE,UAAU,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,OAAO,aAAa,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC"}
1
+ {"version":3,"file":"side-effects.d.ts","sourceRoot":"","sources":["side-effects.js"],"names":[],"mappings":"AA0FO,+BAZ+C,CAAC,SAA1C,MAAO,OAAO,aAAa,EAAE,UAAW,+BAC1C;IACN,GAAG,EAAE,CAAC,CAAC;IACP,QAAQ,EAAE,CAAC,SAAS,SAAS,MAAM,OAAO,aAAa,EAAE,UAAU,EACjE,GAAG,EAAE,SAAS,EACd,KAAK,EAAE,OAAO,aAAa,EAAE,UAAU,CAAC,SAAS,CAAC,KAC/C,IAAI,CAAC;IACV,QAAQ,EAAE,CAAC,SAAS,SAAS,MAAM,OAAO,aAAa,EAAE,UAAU,EACjE,GAAG,EAAE,SAAS,KACX,OAAO,aAAa,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC;CAClD,QAqCH;wCAnHqD,IAAI,SAA7C,MAAO,OAAO,aAAa,EAAE,UAAW,EACkB,KAAK,SAA9D,OAAO,CAAC,MAAM,OAAO,aAAa,EAAE,UAAU,EAAE,IAAI,CAAC,EAAG;SAExD,IAAI;UACJ,KAAK;QACL,CACT,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,OAAO,aAAa,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC,GAAG,GAC1D,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,OAAO,aAAa,EAAE,UAAU,CAAC,CAAC,CAAC,GAC1D,KACE,OAAO,aAAa,EAAE,UAAU,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,OAAO,aAAa,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC"}
@@ -2,9 +2,10 @@
2
2
 
3
3
  // TODO: Here is troubles with tsd: it can't resolve types from `@uploadcare/cname-prefix/async` due to unsupported bundler moduleResolution.
4
4
  // @ts-ignore
5
- import { getPrefixedCdnBaseAsync } from '@uploadcare/cname-prefix/async';
5
+ import { getPrefixedCdnBaseAsync, isPrefixedCdnBase } from '@uploadcare/cname-prefix/async';
6
6
  import { deserializeCsv, serializeCsv } from '../utils/comma-separated.js';
7
7
  import { DEFAULT_CDN_CNAME } from './initialConfig.js';
8
+ import { isPromiseLike } from '../../utils/isPromiseLike.js';
8
9
 
9
10
  /**
10
11
  * @template {keyof import('../../types').ConfigType} TKey
@@ -65,10 +66,11 @@ const COMPUTED_PROPERTIES = [
65
66
  key: 'cdnCname',
66
67
  deps: ['pubkey', 'cdnCnamePrefixed'],
67
68
  fn: ({ pubkey, cdnCname, cdnCnamePrefixed }) => {
68
- if (cdnCname !== DEFAULT_CDN_CNAME) {
69
- return cdnCname;
69
+ if (pubkey && (cdnCname === DEFAULT_CDN_CNAME || isPrefixedCdnBase(cdnCname, cdnCnamePrefixed))) {
70
+ return getPrefixedCdnBaseAsync(pubkey, cdnCnamePrefixed);
70
71
  }
71
- return getPrefixedCdnBaseAsync(pubkey, cdnCnamePrefixed);
72
+
73
+ return cdnCname;
72
74
  },
73
75
  }),
74
76
  ];
@@ -104,7 +106,7 @@ export const runSideEffects = ({ key, setValue, getValue }) => {
104
106
  ),
105
107
  };
106
108
  const result = computed.fn(args);
107
- if (result instanceof Promise) {
109
+ if (isPromiseLike(result)) {
108
110
  const prevValue = getValue(computed.key);
109
111
  result
110
112
  .then((resolvedValue) => {
@@ -2,9 +2,9 @@
2
2
  import { shrinkFile } from '@uploadcare/image-shrink';
3
3
  import { CancelError, UploadcareError, uploadFile } from '@uploadcare/upload-client';
4
4
  import { ActivityBlock } from '../../abstract/ActivityBlock.js';
5
- import { debounce } from '../utils/debounce.js';
6
5
  import { parseShrink } from '../../utils/parseShrink.js';
7
- import { UploadSource } from '../utils/UploadSource.js';
6
+ import { ExternalUploadSource } from '../utils/UploadSource.js';
7
+ import { debounce } from '../utils/debounce.js';
8
8
  import { throttle } from '../utils/throttle.js';
9
9
  import { FileItemConfig } from './FileItemConfig.js';
10
10
 
@@ -118,7 +118,7 @@ export class FileItem extends FileItemConfig {
118
118
  return;
119
119
  }
120
120
 
121
- if (externalUrl && source && source !== UploadSource.URL) {
121
+ if (externalUrl && source && Object.values(ExternalUploadSource).includes(source)) {
122
122
  const hint = this.l10n('waiting-for', { source: this.l10n(`src-type-${source}`) });
123
123
  this.$.hint = hint;
124
124
  return;
package/env.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  /** Do not edit this file manually. It's generated during build process. */
2
2
  export const PACKAGE_NAME: "blocks";
3
- export const PACKAGE_VERSION: "1.19.1";
3
+ export const PACKAGE_VERSION: "1.19.3";
4
4
  //# sourceMappingURL=env.d.ts.map
package/env.js CHANGED
@@ -1,3 +1,3 @@
1
1
  /** Do not edit this file manually. It's generated during build process. */
2
2
  export const PACKAGE_NAME = 'blocks';
3
- export const PACKAGE_VERSION = '1.19.1';
3
+ export const PACKAGE_VERSION = '1.19.3';
package/index.ssr.d.ts CHANGED
@@ -550,7 +550,7 @@ export namespace ModalEvents {
550
550
  let DESTROY: string;
551
551
  }
552
552
  export const PACKAGE_NAME: "blocks";
553
- export const PACKAGE_VERSION: "1.19.1";
553
+ export const PACKAGE_VERSION: "1.19.3";
554
554
  export const PresenceToggle: {
555
555
  new (): {};
556
556
  template: string;
package/index.ssr.js CHANGED
@@ -1070,7 +1070,7 @@ export const ModalEvents = {
1070
1070
  DESTROY: "modal:destroy",
1071
1071
  };
1072
1072
  export const PACKAGE_NAME = `blocks`;
1073
- export const PACKAGE_VERSION = `1.19.1`;
1073
+ export const PACKAGE_VERSION = `1.19.3`;
1074
1074
  export const PresenceToggle = class {
1075
1075
  static template = `<slot></slot> `;
1076
1076
  static reg = () => {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uploadcare/file-uploader",
3
- "version": "1.19.1",
3
+ "version": "1.19.3",
4
4
  "description": "Building blocks for Uploadcare products integration",
5
5
  "keywords": [
6
6
  "web components",
@@ -141,9 +141,9 @@
141
141
  "license": "MIT",
142
142
  "dependencies": {
143
143
  "@symbiotejs/symbiote": "^1.11.7",
144
- "@uploadcare/cname-prefix": "^6.16.2",
145
- "@uploadcare/image-shrink": "^6.16.1",
146
- "@uploadcare/upload-client": "^6.16.1",
144
+ "@uploadcare/cname-prefix": "^6.17.0",
145
+ "@uploadcare/image-shrink": "^6.17.0",
146
+ "@uploadcare/upload-client": "^6.17.0",
147
147
  "keyux": "^0.7.1"
148
148
  }
149
149
  }
@@ -0,0 +1,2 @@
1
+ export function isPromiseLike(value: unknown): value is Promise<any>;
2
+ //# sourceMappingURL=isPromiseLike.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isPromiseLike.d.ts","sourceRoot":"","sources":["isPromiseLike.js"],"names":[],"mappings":"AAMO,qCAHI,OAAO,GACL,KAAK,gBAAW,CAO5B"}
@@ -0,0 +1,12 @@
1
+ // @ts-check
2
+
3
+ /**
4
+ * @param {unknown} value
5
+ * @returns {value is Promise}
6
+ */
7
+ export const isPromiseLike = (value) => {
8
+ return (
9
+ value instanceof Promise ||
10
+ Boolean(value && typeof value === 'object' && 'then' in value && typeof value.then === 'function')
11
+ );
12
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=isPromiseLike.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isPromiseLike.test.d.ts","sourceRoot":"","sources":["isPromiseLike.test.js"],"names":[],"mappings":""}
@@ -0,0 +1,20 @@
1
+ import { isPromiseLike } from './isPromiseLike';
2
+ import { expect } from '@esm-bundle/chai';
3
+
4
+ describe('isPromiseLike', () => {
5
+ it('should return true for Promise instances', () => {
6
+ expect(isPromiseLike(Promise.resolve())).to.be.true;
7
+ });
8
+
9
+ it('should return true for thenable objects', () => {
10
+ const thenable = { then: () => {} };
11
+ expect(isPromiseLike(thenable)).to.be.true;
12
+ });
13
+
14
+ it('should return false for non-thenable objects', () => {
15
+ expect(isPromiseLike({})).to.be.false;
16
+ expect(isPromiseLike(null)).to.be.false;
17
+ expect(isPromiseLike(42)).to.be.false;
18
+ expect(isPromiseLike('string')).to.be.false;
19
+ });
20
+ });