@uploadcare/file-uploader 1.24.0-alpha.2 → 1.24.1

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/dist/index.js CHANGED
@@ -1216,7 +1216,7 @@ import { TelemetryAPIService } from "@uploadcare/quality-insights";
1216
1216
  import { Queue as Queue2 } from "@uploadcare/upload-client";
1217
1217
 
1218
1218
  // package.json
1219
- var version = "1.24.0-alpha.2";
1219
+ var version = "1.24.1";
1220
1220
 
1221
1221
  // src/env.ts
1222
1222
  var PACKAGE_NAME = "blocks";
@@ -1547,7 +1547,7 @@ var Block = class extends BaseComponent {
1547
1547
  return testId;
1548
1548
  }
1549
1549
  get modalManager() {
1550
- return this.has("*modalManager") && this.$["*modalManager"];
1550
+ return this.has("*modalManager") ? this.$["*modalManager"] : void 0;
1551
1551
  }
1552
1552
  get telemetryManager() {
1553
1553
  if (!this.cfg.qualityInsights) {
@@ -1590,7 +1590,7 @@ var Block = class extends BaseComponent {
1590
1590
  destroyCtxCallback() {
1591
1591
  Data.deleteCtx(this.ctxName);
1592
1592
  this.localeManager?.destroy();
1593
- this.modalManager && this.modalManager?.destroy();
1593
+ this.modalManager?.destroy();
1594
1594
  }
1595
1595
  async proxyUrl(url) {
1596
1596
  if (this.cfg.secureDeliveryProxy && this.cfg.secureDeliveryProxyUrlResolver) {
@@ -1741,7 +1741,7 @@ var ActivityBlock = class _ActivityBlock extends Block {
1741
1741
  }
1742
1742
  }
1743
1743
  _isActivityRegistered() {
1744
- return this.activityType && _ActivityBlock._activityCallbacks.has(this);
1744
+ return !!this.activityType && _ActivityBlock._activityCallbacks.has(this);
1745
1745
  }
1746
1746
  static _activityCallbacks = /* @__PURE__ */ new Map();
1747
1747
  // declare static activities to satisfy type references below
@@ -3511,11 +3511,7 @@ var UploaderPublicApi = class {
3511
3511
  /**
3512
3512
  * TODO: Probably we should not allow user to override `source` property
3513
3513
  */
3514
- addFileFromUrl = (url, {
3515
- silent,
3516
- fileName,
3517
- source
3518
- } = {}) => {
3514
+ addFileFromUrl = (url, { silent, fileName, source } = {}) => {
3519
3515
  const internalId = this._uploadCollection.add({
3520
3516
  externalUrl: url,
3521
3517
  fileName: fileName ?? null,
@@ -3524,11 +3520,7 @@ var UploaderPublicApi = class {
3524
3520
  });
3525
3521
  return this.getOutputItem(internalId);
3526
3522
  };
3527
- addFileFromUuid = (uuid, {
3528
- silent,
3529
- fileName,
3530
- source
3531
- } = {}) => {
3523
+ addFileFromUuid = (uuid, { silent, fileName, source } = {}) => {
3532
3524
  const internalId = this._uploadCollection.add({
3533
3525
  uuid,
3534
3526
  fileName: fileName ?? null,
@@ -3537,11 +3529,7 @@ var UploaderPublicApi = class {
3537
3529
  });
3538
3530
  return this.getOutputItem(internalId);
3539
3531
  };
3540
- addFileFromCdnUrl = (cdnUrl, {
3541
- silent,
3542
- fileName,
3543
- source
3544
- } = {}) => {
3532
+ addFileFromCdnUrl = (cdnUrl, { silent, fileName, source } = {}) => {
3545
3533
  const parsedCdnUrl = parseCdnUrl({
3546
3534
  url: cdnUrl,
3547
3535
  cdnBase: this.cfg.cdnCname
@@ -3603,10 +3591,7 @@ var UploaderPublicApi = class {
3603
3591
  };
3604
3592
  openSystemDialog = (options = {}) => {
3605
3593
  const accept = serializeCsv(
3606
- mergeFileTypes([
3607
- this.cfg.accept ?? "",
3608
- ...this.cfg.imgOnly ? IMAGE_ACCEPT_LIST : []
3609
- ])
3594
+ mergeFileTypes([this.cfg.accept ?? "", ...this.cfg.imgOnly ? IMAGE_ACCEPT_LIST : []])
3610
3595
  );
3611
3596
  const INPUT_ATTR_NAME = "uploadcare-file-input";
3612
3597
  const fileInput = document.createElement("input");
@@ -3624,18 +3609,13 @@ var UploaderPublicApi = class {
3624
3609
  fileInput.multiple = this.cfg.multiple;
3625
3610
  if (options.captureCamera) {
3626
3611
  fileInput.capture = this.cfg.cameraCapture;
3627
- const { isPhotoEnabled, isVideoRecordingEnabled } = calcCameraModes(
3628
- this.cfg
3629
- );
3612
+ const { isPhotoEnabled, isVideoRecordingEnabled } = calcCameraModes(this.cfg);
3630
3613
  if (options.modeCamera === CameraSourceTypes.PHOTO && isPhotoEnabled) {
3631
3614
  fileInput.accept = BASIC_IMAGE_WILDCARD;
3632
3615
  } else if (options.modeCamera === CameraSourceTypes.VIDEO && isVideoRecordingEnabled) {
3633
3616
  fileInput.accept = BASIC_VIDEO_WILDCARD;
3634
3617
  } else {
3635
- fileInput.accept = [
3636
- BASIC_IMAGE_WILDCARD,
3637
- isVideoRecordingEnabled && BASIC_VIDEO_WILDCARD
3638
- ].filter(Boolean).join(",");
3618
+ fileInput.accept = [BASIC_IMAGE_WILDCARD, isVideoRecordingEnabled && BASIC_VIDEO_WILDCARD].filter(Boolean).join(",");
3639
3619
  }
3640
3620
  } else {
3641
3621
  fileInput.accept = accept;
@@ -3713,9 +3693,7 @@ var UploaderPublicApi = class {
3713
3693
  return;
3714
3694
  }
3715
3695
  if (srcKey === "camera" && browserFeatures.htmlMediaCapture) {
3716
- const { isPhotoEnabled, isVideoRecordingEnabled } = calcCameraModes(
3717
- this.cfg
3718
- );
3696
+ const { isPhotoEnabled, isVideoRecordingEnabled } = calcCameraModes(this.cfg);
3719
3697
  if (isPhotoEnabled && isVideoRecordingEnabled) {
3720
3698
  this._ctx.set$({
3721
3699
  "*currentActivity": ActivityBlock.activities.START_FROM
@@ -3773,9 +3751,7 @@ var UploaderPublicApi = class {
3773
3751
  };
3774
3752
  setModalState = (opened) => {
3775
3753
  if (opened && !this._ctx.$["*currentActivity"]) {
3776
- console.warn(
3777
- `Can't open modal without current activity. Please use "setCurrentActivity" method first.`
3778
- );
3754
+ console.warn(`Can't open modal without current activity. Please use "setCurrentActivity" method first.`);
3779
3755
  return;
3780
3756
  }
3781
3757
  if (opened) {
@@ -4425,9 +4401,7 @@ var CameraSource = class extends UploaderBlock {
4425
4401
  }
4426
4402
  };
4427
4403
  _updateTimer = () => {
4428
- const currentTime = Math.floor(
4429
- (performance.now() - this.$._startTime + this.$._elapsedTime) / 1e3
4430
- );
4404
+ const currentTime = Math.floor((performance.now() - this.$._startTime + this.$._elapsedTime) / 1e3);
4431
4405
  if (typeof this.cfg.maxVideoRecordingDuration === "number" && this.cfg.maxVideoRecordingDuration > 0) {
4432
4406
  const remainingTime = this.cfg.maxVideoRecordingDuration - currentTime;
4433
4407
  if (remainingTime <= 0) {
@@ -4496,22 +4470,16 @@ var CameraSource = class extends UploaderBlock {
4496
4470
  if (this._stream) {
4497
4471
  this._mediaRecorder = new MediaRecorder(this._stream, this._options);
4498
4472
  this._mediaRecorder.start();
4499
- this._mediaRecorder.addEventListener(
4500
- "dataavailable",
4501
- (event) => {
4502
- this._chunks.push(event.data);
4503
- }
4504
- );
4473
+ this._mediaRecorder.addEventListener("dataavailable", (event) => {
4474
+ this._chunks.push(event.data);
4475
+ });
4505
4476
  this._startTimer();
4506
4477
  this.classList.add("uc-recording");
4507
4478
  this._setCameraState(CameraSourceEvents.PLAY);
4508
4479
  }
4509
4480
  } catch (error) {
4510
4481
  console.error("Failed to start recording", error);
4511
- this.telemetryManager.sendEventError(
4512
- error,
4513
- "camera recording. Failed to start recording"
4514
- );
4482
+ this.telemetryManager.sendEventError(error, "camera recording. Failed to start recording");
4515
4483
  }
4516
4484
  };
4517
4485
  _stopRecording = () => {
@@ -4570,10 +4538,7 @@ var CameraSource = class extends UploaderBlock {
4570
4538
  });
4571
4539
  } catch (error) {
4572
4540
  console.error("Failed to preview video", error);
4573
- this.telemetryManager.sendEventError(
4574
- error,
4575
- "camera previewing. Failed to preview video"
4576
- );
4541
+ this.telemetryManager.sendEventError(error, "camera previewing. Failed to preview video");
4577
4542
  }
4578
4543
  };
4579
4544
  _retake = () => {
@@ -4594,12 +4559,7 @@ var CameraSource = class extends UploaderBlock {
4594
4559
  if (!blob2) {
4595
4560
  return;
4596
4561
  }
4597
- const file2 = this._createFile(
4598
- "camera",
4599
- "jpeg",
4600
- DEFAULT_PICTURE_FORMAT,
4601
- blob2
4602
- );
4562
+ const file2 = this._createFile("camera", "jpeg", DEFAULT_PICTURE_FORMAT, blob2);
4603
4563
  this._toSend(file2);
4604
4564
  }, DEFAULT_PICTURE_FORMAT);
4605
4565
  return;
@@ -4760,47 +4720,44 @@ var CameraSource = class extends UploaderBlock {
4760
4720
  (mode) => mode === CameraSourceTypes.PHOTO || mode === CameraSourceTypes.VIDEO
4761
4721
  );
4762
4722
  }
4763
- _setPermissionsState = debounce(
4764
- (state) => {
4765
- this.classList.toggle("uc-initialized", state === "granted");
4766
- const visibleAudio = this._activeTab === CameraSourceTypes.VIDEO && this.cfg.enableAudioRecording;
4767
- const currentIcon = this._activeTab === CameraSourceTypes.PHOTO ? "camera-full" : "video-camera-full";
4768
- if (state === "granted") {
4769
- this.set$({
4770
- videoHidden: false,
4771
- cameraHidden: false,
4772
- tabCameraHidden: !this._cameraModes.includes(CameraSourceTypes.PHOTO),
4773
- tabVideoHidden: !this._cameraModes.includes(CameraSourceTypes.VIDEO),
4774
- messageHidden: true,
4775
- timerHidden: true,
4776
- currentIcon,
4777
- audioToggleMicrophoneHidden: !visibleAudio,
4778
- audioSelectHidden: !visibleAudio
4779
- });
4780
- } else if (state === "prompt") {
4781
- this.$.l10nMessage = "camera-permissions-prompt";
4782
- this.set$({
4783
- videoHidden: true,
4784
- cameraHidden: true,
4785
- tabCameraHidden: true,
4786
- messageHidden: false
4787
- });
4788
- this._stopCapture();
4789
- } else {
4790
- this.$.l10nMessage = "camera-permissions-denied";
4791
- this.set$({
4792
- videoHidden: true,
4793
- messageHidden: false,
4794
- tabCameraHidden: !this._cameraModes.includes(CameraSourceTypes.PHOTO),
4795
- tabVideoHidden: !this._cameraModes.includes(CameraSourceTypes.VIDEO),
4796
- cameraActionsHidden: true,
4797
- mutableClassButton: "uc-shot-btn uc-camera-action"
4798
- });
4799
- this._stopCapture();
4800
- }
4801
- },
4802
- 300
4803
- );
4723
+ _setPermissionsState = debounce((state) => {
4724
+ this.classList.toggle("uc-initialized", state === "granted");
4725
+ const visibleAudio = this._activeTab === CameraSourceTypes.VIDEO && this.cfg.enableAudioRecording;
4726
+ const currentIcon = this._activeTab === CameraSourceTypes.PHOTO ? "camera-full" : "video-camera-full";
4727
+ if (state === "granted") {
4728
+ this.set$({
4729
+ videoHidden: false,
4730
+ cameraHidden: false,
4731
+ tabCameraHidden: !this._cameraModes.includes(CameraSourceTypes.PHOTO),
4732
+ tabVideoHidden: !this._cameraModes.includes(CameraSourceTypes.VIDEO),
4733
+ messageHidden: true,
4734
+ timerHidden: true,
4735
+ currentIcon,
4736
+ audioToggleMicrophoneHidden: !visibleAudio,
4737
+ audioSelectHidden: !visibleAudio
4738
+ });
4739
+ } else if (state === "prompt") {
4740
+ this.$.l10nMessage = "camera-permissions-prompt";
4741
+ this.set$({
4742
+ videoHidden: true,
4743
+ cameraHidden: true,
4744
+ tabCameraHidden: true,
4745
+ messageHidden: false
4746
+ });
4747
+ this._stopCapture();
4748
+ } else {
4749
+ this.$.l10nMessage = "camera-permissions-denied";
4750
+ this.set$({
4751
+ videoHidden: true,
4752
+ messageHidden: false,
4753
+ tabCameraHidden: !this._cameraModes.includes(CameraSourceTypes.PHOTO),
4754
+ tabVideoHidden: !this._cameraModes.includes(CameraSourceTypes.VIDEO),
4755
+ cameraActionsHidden: true,
4756
+ mutableClassButton: "uc-shot-btn uc-camera-action"
4757
+ });
4758
+ this._stopCapture();
4759
+ }
4760
+ }, 300);
4804
4761
  _makeStreamInactive = () => {
4805
4762
  if (!this._stream) return false;
4806
4763
  const audioTracks = this._stream?.getAudioTracks();
@@ -4858,10 +4815,7 @@ var CameraSource = class extends UploaderBlock {
4858
4815
  } catch (error) {
4859
4816
  this._setPermissionsState("denied");
4860
4817
  console.log("Failed to capture camera", error);
4861
- this.telemetryManager.sendEventError(
4862
- error,
4863
- "camera capturing. Failed to capture camera"
4864
- );
4818
+ this.telemetryManager.sendEventError(error, "camera capturing. Failed to capture camera");
4865
4819
  }
4866
4820
  };
4867
4821
  _handlePermissionsChange = () => {
@@ -4877,14 +4831,8 @@ var CameraSource = class extends UploaderBlock {
4877
4831
  response.addEventListener("change", this._handlePermissionsChange);
4878
4832
  }
4879
4833
  } catch (error) {
4880
- console.log(
4881
- "Failed to use permissions API. Fallback to manual request mode.",
4882
- error
4883
- );
4884
- this.telemetryManager.sendEventError(
4885
- error,
4886
- "camera permissions. Failed to use permissions API"
4887
- );
4834
+ console.log("Failed to use permissions API. Fallback to manual request mode.", error);
4835
+ this.telemetryManager.sendEventError(error, "camera permissions. Failed to use permissions API");
4888
4836
  this._capture();
4889
4837
  }
4890
4838
  };
@@ -4899,10 +4847,7 @@ var CameraSource = class extends UploaderBlock {
4899
4847
  await this._getDevices();
4900
4848
  navigator.mediaDevices.addEventListener("devicechange", this._getDevices);
4901
4849
  } catch (error) {
4902
- this.telemetryManager.sendEventError(
4903
- error,
4904
- "camera devices. Failed to get user media"
4905
- );
4850
+ this.telemetryManager.sendEventError(error, "camera devices. Failed to get user media");
4906
4851
  console.log("Failed to get user media", error);
4907
4852
  }
4908
4853
  };
@@ -4932,10 +4877,7 @@ var CameraSource = class extends UploaderBlock {
4932
4877
  }
4933
4878
  this._selectedAudioId = this._audioDevices[0]?.value ?? null;
4934
4879
  } catch (error) {
4935
- this.telemetryManager.sendEventError(
4936
- error,
4937
- "camera devices. Failed to get devices"
4938
- );
4880
+ this.telemetryManager.sendEventError(error, "camera devices. Failed to get devices");
4939
4881
  console.log("Failed to get devices", error);
4940
4882
  }
4941
4883
  };
@@ -4949,9 +4891,7 @@ var CameraSource = class extends UploaderBlock {
4949
4891
  if (this._unsubPermissions) {
4950
4892
  this._unsubPermissions();
4951
4893
  }
4952
- const isChromium = Boolean(
4953
- window.chrome
4954
- );
4894
+ const isChromium = Boolean(window.chrome);
4955
4895
  if (!isChromium) {
4956
4896
  this._setPermissionsState("denied");
4957
4897
  }
@@ -4990,15 +4930,9 @@ var CameraSource = class extends UploaderBlock {
4990
4930
  }
4991
4931
  _destroy() {
4992
4932
  for (const permission of DEFAULT_PERMISSIONS) {
4993
- this._permissionResponses[permission]?.removeEventListener(
4994
- "change",
4995
- this._handlePermissionsChange
4996
- );
4933
+ this._permissionResponses[permission]?.removeEventListener("change", this._handlePermissionsChange);
4997
4934
  }
4998
- navigator.mediaDevices?.removeEventListener(
4999
- "devicechange",
5000
- this._getDevices
5001
- );
4935
+ navigator.mediaDevices?.removeEventListener("devicechange", this._getDevices);
5002
4936
  }
5003
4937
  async destroyCallback() {
5004
4938
  super.destroyCallback();
@@ -6127,9 +6061,7 @@ function batchPreloadImages(list) {
6127
6061
  preloaders.push(preload);
6128
6062
  }
6129
6063
  const images = preloaders.map((preload) => preload.image);
6130
- const promise = Promise.allSettled(
6131
- preloaders.map((preload) => preload.promise)
6132
- );
6064
+ const promise = Promise.allSettled(preloaders.map((preload) => preload.promise));
6133
6065
  const cancel = () => {
6134
6066
  preloaders.forEach((preload) => {
6135
6067
  preload.cancel();
@@ -8247,6 +8179,110 @@ var runAssertions = debounce((cfg) => {
8247
8179
  }
8248
8180
  }, 0);
8249
8181
 
8182
+ // src/blocks/Config/computed-properties.ts
8183
+ import { getPrefixedCdnBaseAsync, isPrefixedCdnBase } from "@uploadcare/cname-prefix/async";
8184
+
8185
+ // src/utils/isPromiseLike.ts
8186
+ var isPromiseLike = (value) => {
8187
+ return value instanceof Promise || Boolean(
8188
+ value && typeof value === "object" && "then" in value && typeof value.then === "function"
8189
+ );
8190
+ };
8191
+
8192
+ // src/blocks/Config/computed-properties.ts
8193
+ var defineComputedProperty = (declaration) => declaration;
8194
+ var COMPUTED_PROPERTIES = [
8195
+ defineComputedProperty({
8196
+ key: "cameraModes",
8197
+ deps: ["enableVideoRecording"],
8198
+ fn: ({ cameraModes, enableVideoRecording }) => {
8199
+ if (enableVideoRecording === null) {
8200
+ return cameraModes;
8201
+ }
8202
+ let cameraModesCsv = deserializeCsv(cameraModes);
8203
+ if (enableVideoRecording && !cameraModesCsv.includes("video")) {
8204
+ cameraModesCsv = cameraModesCsv.concat("video");
8205
+ } else if (!enableVideoRecording) {
8206
+ cameraModesCsv = cameraModesCsv.filter((mode) => mode !== "video");
8207
+ }
8208
+ return serializeCsv(cameraModesCsv);
8209
+ }
8210
+ }),
8211
+ defineComputedProperty({
8212
+ key: "cameraModes",
8213
+ deps: ["defaultCameraMode"],
8214
+ fn: ({ cameraModes, defaultCameraMode }) => {
8215
+ if (defaultCameraMode === null) {
8216
+ return cameraModes;
8217
+ }
8218
+ let cameraModesCsv = deserializeCsv(cameraModes);
8219
+ cameraModesCsv = cameraModesCsv.sort((a, b) => {
8220
+ if (a === defaultCameraMode) return -1;
8221
+ if (b === defaultCameraMode) return 1;
8222
+ return 0;
8223
+ });
8224
+ return serializeCsv(cameraModesCsv);
8225
+ }
8226
+ }),
8227
+ defineComputedProperty({
8228
+ key: "cdnCname",
8229
+ deps: ["pubkey", "cdnCnamePrefixed"],
8230
+ fn: ({ pubkey, cdnCname, cdnCnamePrefixed }) => {
8231
+ if (pubkey && (cdnCname === DEFAULT_CDN_CNAME || isPrefixedCdnBase(cdnCname, cdnCnamePrefixed))) {
8232
+ return getPrefixedCdnBaseAsync(pubkey, cdnCnamePrefixed);
8233
+ }
8234
+ return cdnCname;
8235
+ }
8236
+ })
8237
+ ];
8238
+ var abortControllers = /* @__PURE__ */ new Map();
8239
+ var computeProperty = ({ key, setValue, getValue }) => {
8240
+ for (const computed of COMPUTED_PROPERTIES) {
8241
+ if (computed.deps.includes(key)) {
8242
+ const args = {
8243
+ [computed.key]: getValue(computed.key)
8244
+ };
8245
+ for (const dep of computed.deps) {
8246
+ args[dep] = getValue(dep);
8247
+ }
8248
+ const abortController = new AbortController();
8249
+ abortControllers.get(computed.key)?.abort();
8250
+ abortControllers.set(computed.key, abortController);
8251
+ let result;
8252
+ try {
8253
+ result = computed.fn(args, {
8254
+ signal: abortController.signal
8255
+ });
8256
+ } catch (error) {
8257
+ if (abortControllers.get(computed.key) === abortController) {
8258
+ abortControllers.delete(computed.key);
8259
+ }
8260
+ console.error(`Failed to compute value for "${computed.key}"`, error);
8261
+ return;
8262
+ }
8263
+ if (isPromiseLike(result)) {
8264
+ result.then((resolvedValue) => {
8265
+ if (abortController.signal.aborted) {
8266
+ return;
8267
+ }
8268
+ setValue(computed.key, resolvedValue);
8269
+ }).catch((error) => {
8270
+ if (abortController.signal.aborted) {
8271
+ return;
8272
+ }
8273
+ console.error(`Failed to compute value for "${computed.key}"`, error);
8274
+ }).finally(() => {
8275
+ if (abortControllers.get(computed.key) === abortController) {
8276
+ abortControllers.delete(computed.key);
8277
+ }
8278
+ });
8279
+ } else {
8280
+ setValue(computed.key, result);
8281
+ }
8282
+ }
8283
+ }
8284
+ };
8285
+
8250
8286
  // src/blocks/Config/validatorsType.ts
8251
8287
  var asString = (value) => String(value);
8252
8288
  var asNumber2 = (value) => {
@@ -8406,89 +8442,6 @@ var normalizeConfigValue = (key, value) => {
8406
8442
  }
8407
8443
  };
8408
8444
 
8409
- // src/blocks/Config/side-effects.ts
8410
- import { getPrefixedCdnBaseAsync, isPrefixedCdnBase } from "@uploadcare/cname-prefix/async";
8411
-
8412
- // src/utils/isPromiseLike.ts
8413
- var isPromiseLike = (value) => {
8414
- return value instanceof Promise || Boolean(
8415
- value && typeof value === "object" && "then" in value && typeof value.then === "function"
8416
- );
8417
- };
8418
-
8419
- // src/blocks/Config/side-effects.ts
8420
- var defineComputedProperty = (declaration) => declaration;
8421
- var COMPUTED_PROPERTIES = [
8422
- defineComputedProperty({
8423
- key: "cameraModes",
8424
- deps: ["enableVideoRecording"],
8425
- fn: ({ cameraModes, enableVideoRecording }) => {
8426
- if (enableVideoRecording === null) {
8427
- return cameraModes;
8428
- }
8429
- let cameraModesCsv = deserializeCsv(cameraModes);
8430
- if (enableVideoRecording && !cameraModesCsv.includes("video")) {
8431
- cameraModesCsv = cameraModesCsv.concat("video");
8432
- } else if (!enableVideoRecording) {
8433
- cameraModesCsv = cameraModesCsv.filter((mode) => mode !== "video");
8434
- }
8435
- return serializeCsv(cameraModesCsv);
8436
- }
8437
- }),
8438
- defineComputedProperty({
8439
- key: "cameraModes",
8440
- deps: ["defaultCameraMode"],
8441
- fn: ({ cameraModes, defaultCameraMode }) => {
8442
- if (defaultCameraMode === null) {
8443
- return cameraModes;
8444
- }
8445
- let cameraModesCsv = deserializeCsv(cameraModes);
8446
- cameraModesCsv = cameraModesCsv.sort((a, b) => {
8447
- if (a === defaultCameraMode) return -1;
8448
- if (b === defaultCameraMode) return 1;
8449
- return 0;
8450
- });
8451
- return serializeCsv(cameraModesCsv);
8452
- }
8453
- }),
8454
- defineComputedProperty({
8455
- key: "cdnCname",
8456
- deps: ["pubkey", "cdnCnamePrefixed"],
8457
- fn: ({ pubkey, cdnCname, cdnCnamePrefixed }) => {
8458
- if (pubkey && (cdnCname === DEFAULT_CDN_CNAME || isPrefixedCdnBase(cdnCname, cdnCnamePrefixed))) {
8459
- return getPrefixedCdnBaseAsync(pubkey, cdnCnamePrefixed);
8460
- }
8461
- return cdnCname;
8462
- }
8463
- })
8464
- ];
8465
- var runSideEffects = ({ key, setValue, getValue }) => {
8466
- for (const computed of COMPUTED_PROPERTIES) {
8467
- if (computed.deps.includes(key)) {
8468
- const args = {
8469
- [computed.key]: getValue(computed.key)
8470
- };
8471
- for (const dep of computed.deps) {
8472
- args[dep] = getValue(dep);
8473
- }
8474
- const result = computed.fn(args);
8475
- if (isPromiseLike(result)) {
8476
- const prevValue = getValue(computed.key);
8477
- result.then((resolvedValue) => {
8478
- const currentValue = getValue(computed.key);
8479
- if (currentValue === prevValue) {
8480
- setValue(computed.key, resolvedValue);
8481
- }
8482
- }).catch((error) => {
8483
- console.error(`Failed to compute value for "${computed.key}"`, error);
8484
- });
8485
- } else {
8486
- setValue(computed.key, result);
8487
- }
8488
- }
8489
- }
8490
- };
8491
-
8492
8445
  // src/blocks/Config/Config.ts
8493
8446
  var allConfigKeys = [
8494
8447
  // "debug" option should go first to be able to print debug messages from the very beginning
@@ -8558,11 +8511,6 @@ var Config = class extends Block {
8558
8511
  this._flushValueToState(key, normalizedValue);
8559
8512
  this.debugPrint(`[uc-config] "${key}"`, normalizedValue);
8560
8513
  runAssertions(this.cfg);
8561
- runSideEffects({
8562
- key,
8563
- setValue: this._setValue.bind(this),
8564
- getValue: this._getValue.bind(this)
8565
- });
8566
8514
  }
8567
8515
  _getValue(key) {
8568
8516
  const anyThis = this;
@@ -8608,10 +8556,14 @@ var Config = class extends Block {
8608
8556
  return this._getValue(key);
8609
8557
  }
8610
8558
  });
8611
- runSideEffects({
8612
- key,
8613
- setValue: this._setValue.bind(this),
8614
- getValue: this._getValue.bind(this)
8559
+ }
8560
+ for (const key of allConfigKeys) {
8561
+ this.sub(sharedConfigKey(key), () => {
8562
+ computeProperty({
8563
+ key,
8564
+ setValue: this._setValue.bind(this),
8565
+ getValue: this._getValue.bind(this)
8566
+ });
8615
8567
  });
8616
8568
  }
8617
8569
  }
@@ -9180,8 +9132,10 @@ var isWhitelistedMessage = (message) => {
9180
9132
  var MessageBridge = class {
9181
9133
  _handlerMap = /* @__PURE__ */ new Map();
9182
9134
  _context;
9183
- constructor(context) {
9135
+ _getTargetOrigin;
9136
+ constructor(context, getTargetOrigin) {
9184
9137
  this._context = context;
9138
+ this._getTargetOrigin = getTargetOrigin;
9185
9139
  window.addEventListener("message", this._handleMessage);
9186
9140
  }
9187
9141
  _handleMessage = (e) => {
@@ -9207,7 +9161,8 @@ var MessageBridge = class {
9207
9161
  handlers.add(handler);
9208
9162
  }
9209
9163
  send(message) {
9210
- this._context.postMessage(message, "*");
9164
+ const targetOrigin = this._getTargetOrigin();
9165
+ this._context.postMessage(message, targetOrigin);
9211
9166
  }
9212
9167
  destroy() {
9213
9168
  window.removeEventListener("message", this._handleMessage);
@@ -9247,6 +9202,7 @@ var ExternalSource = class extends UploaderBlock {
9247
9202
  couldSelectAll: false,
9248
9203
  couldDeselectAll: false,
9249
9204
  showSelectionStatus: false,
9205
+ showDoneBtn: false,
9250
9206
  counterText: "",
9251
9207
  doneBtnTextClass: "uc-hidden",
9252
9208
  toolbarVisible: true,
@@ -9356,7 +9312,8 @@ var ExternalSource = class extends UploaderBlock {
9356
9312
  showSelectionStatus: message.isMultipleMode && message.total > 0,
9357
9313
  couldSelectAll: message.selectedCount < message.total,
9358
9314
  couldDeselectAll: message.selectedCount === message.total,
9359
- selectedList: message.selectedFiles
9315
+ selectedList: message.selectedFiles,
9316
+ showDoneBtn: message.total > 0
9360
9317
  });
9361
9318
  }
9362
9319
  handleIframeLoad() {
@@ -9419,7 +9376,7 @@ var ExternalSource = class extends UploaderBlock {
9419
9376
  return;
9420
9377
  }
9421
9378
  this._messageBridge?.destroy();
9422
- this._messageBridge = new MessageBridge(iframe.contentWindow);
9379
+ this._messageBridge = new MessageBridge(iframe.contentWindow, () => this.cfg.socialBaseUrl);
9423
9380
  this._messageBridge.on("selected-files-change", this.handleSelectedFilesChange.bind(this));
9424
9381
  this._messageBridge.on("toolbar-state-change", this.handleToolbarStateChange.bind(this));
9425
9382
  this.resetSelectionStatus();
@@ -9437,7 +9394,8 @@ var ExternalSource = class extends UploaderBlock {
9437
9394
  isDoneBtnEnabled: false,
9438
9395
  couldSelectAll: false,
9439
9396
  couldDeselectAll: false,
9440
- showSelectionStatus: false
9397
+ showSelectionStatus: false,
9398
+ showDoneBtn: false
9441
9399
  });
9442
9400
  }
9443
9401
  };
@@ -9462,7 +9420,11 @@ ExternalSource.template = /* HTML */
9462
9420
  <button type="button" set="onclick: onSelectAll; @hidden: !couldSelectAll" l10n="select-all"></button>
9463
9421
  <button type="button" set="onclick: onDeselectAll; @hidden: !couldDeselectAll" l10n="deselect-all"></button>
9464
9422
  </div>
9465
- <button type="button" class="uc-done-btn uc-primary-btn" set="onclick: onDone; @disabled: !isDoneBtnEnabled;">
9423
+ <button
9424
+ type="button"
9425
+ class="uc-done-btn uc-primary-btn"
9426
+ set="onclick: onDone; @disabled: !isDoneBtnEnabled; @hidden: !showDoneBtn"
9427
+ >
9466
9428
  <uc-spinner set="@hidden: isSelectionReady"></uc-spinner>
9467
9429
  <span l10n="done" set="@class: doneBtnTextClass"></span>
9468
9430
  </button>
@@ -9631,6 +9593,7 @@ var FileItem = class _FileItem extends FileItemConfig {
9631
9593
  const errorText = entry.getValue("errors")?.[0]?.message;
9632
9594
  const source = entry.getValue("source");
9633
9595
  const externalUrl = entry.getValue("externalUrl");
9596
+ const isFinished = state === FileItemState.FINISHED;
9634
9597
  const isUploading = state === FileItemState.UPLOADING;
9635
9598
  const isQueuedForUploading = state === FileItemState.QUEUED_UPLOADING;
9636
9599
  const isQueuedForValidation = state === FileItemState.QUEUED_VALIDATION;
@@ -9639,7 +9602,7 @@ var FileItem = class _FileItem extends FileItemConfig {
9639
9602
  let hint = "";
9640
9603
  if (errorText) {
9641
9604
  hint = "";
9642
- } else if (externalUrl && source && Object.values(ExternalUploadSource).includes(source)) {
9605
+ } else if (!isFinished && externalUrl && source && Object.values(ExternalUploadSource).includes(source)) {
9643
9606
  hint = this.l10n("waiting-for", { source: this.l10n(`src-type-${source}`) });
9644
9607
  }
9645
9608
  this.set$({
@@ -11121,6 +11084,7 @@ var Thumb = class extends FileItemConfig {
11121
11084
  }
11122
11085
  return Math.min(size, CDN_MAX_OUTPUT_DIMENSION);
11123
11086
  }
11087
+ // biome-ignore lint/style/noInferrableTypes: Here the type is needed because `_withEntry` could not infer it correctly
11124
11088
  _generateThumbnail = this._withEntry(async (entry, force = false) => {
11125
11089
  const fileInfo = entry.getValue("fileInfo");
11126
11090
  const isImage = entry.getValue("isImage");