@uploadcare/file-uploader 1.15.0-alpha.8 → 1.15.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.
Files changed (282) hide show
  1. package/abstract/ActivityBlock.d.ts +5 -5
  2. package/abstract/ActivityBlock.d.ts.map +1 -1
  3. package/abstract/ActivityBlock.js +0 -3
  4. package/abstract/Block.d.ts +3 -9
  5. package/abstract/Block.d.ts.map +1 -1
  6. package/abstract/Block.js +1 -1
  7. package/abstract/CTX.d.ts +6 -6
  8. package/abstract/CTX.d.ts.map +1 -1
  9. package/abstract/LocaleManager.d.ts +3 -3
  10. package/abstract/LocaleManager.d.ts.map +1 -1
  11. package/abstract/ModalManager.d.ts +26 -17
  12. package/abstract/ModalManager.d.ts.map +1 -1
  13. package/abstract/ModalManager.js +31 -18
  14. package/abstract/SecureUploadsManager.d.ts +2 -2
  15. package/abstract/SecureUploadsManager.d.ts.map +1 -1
  16. package/abstract/SolutionBlock.d.ts +2 -2
  17. package/abstract/SolutionBlock.d.ts.map +1 -1
  18. package/abstract/TypedCollection.d.ts +44 -44
  19. package/abstract/TypedCollection.d.ts.map +1 -1
  20. package/abstract/TypedCollection.js +53 -33
  21. package/abstract/TypedData.d.ts +71 -25
  22. package/abstract/TypedData.d.ts.map +1 -1
  23. package/abstract/TypedData.js +74 -17
  24. package/abstract/UploaderBlock.d.ts +10 -10
  25. package/abstract/UploaderBlock.d.ts.map +1 -1
  26. package/abstract/UploaderBlock.js +22 -10
  27. package/abstract/UploaderPublicApi.d.ts +24 -23
  28. package/abstract/UploaderPublicApi.d.ts.map +1 -1
  29. package/abstract/UploaderPublicApi.js +21 -10
  30. package/abstract/ValidationManager.d.ts +125 -6
  31. package/abstract/ValidationManager.d.ts.map +1 -1
  32. package/abstract/ValidationManager.js +1 -1
  33. package/abstract/a11y.d.ts +2 -2
  34. package/abstract/a11y.d.ts.map +1 -1
  35. package/abstract/buildOutputCollectionState.d.ts +1 -1
  36. package/abstract/buildOutputCollectionState.d.ts.map +1 -1
  37. package/abstract/defineComponents.d.ts.map +1 -1
  38. package/abstract/l10nProcessor.d.ts.map +1 -1
  39. package/abstract/loadFileUploaderFrom.d.ts +1 -1
  40. package/abstract/loadFileUploaderFrom.d.ts.map +1 -1
  41. package/abstract/localeRegistry.d.ts.map +1 -1
  42. package/abstract/sharedConfigKey.d.ts.map +1 -1
  43. package/abstract/uploadEntrySchema.d.ts +123 -63
  44. package/abstract/uploadEntrySchema.d.ts.map +1 -1
  45. package/abstract/uploadEntrySchema.js +66 -81
  46. package/blocks/CameraSource/CameraSource.d.ts +9 -9
  47. package/blocks/CameraSource/CameraSource.d.ts.map +1 -1
  48. package/blocks/CameraSource/calcCameraModes.d.ts +1 -1
  49. package/blocks/CameraSource/constants.d.ts.map +1 -1
  50. package/blocks/CloudImageEditor/src/CloudImageEditorBlock.d.ts.map +1 -1
  51. package/blocks/CloudImageEditor/src/CropFrame.d.ts +1 -1
  52. package/blocks/CloudImageEditor/src/EditorFilterControl.js +1 -1
  53. package/blocks/CloudImageEditor/src/EditorImageCropper.d.ts +3 -3
  54. package/blocks/CloudImageEditor/src/EditorImageCropper.js +1 -1
  55. package/blocks/CloudImageEditor/src/EditorImageFader.d.ts +1 -1
  56. package/blocks/CloudImageEditor/src/EditorImageFader.d.ts.map +1 -1
  57. package/blocks/CloudImageEditor/src/EditorImageFader.js +1 -1
  58. package/blocks/CloudImageEditor/src/EditorSlider.d.ts +1 -1
  59. package/blocks/CloudImageEditor/src/EditorSlider.d.ts.map +1 -1
  60. package/blocks/CloudImageEditor/src/EditorToolbar.d.ts +1 -1
  61. package/blocks/CloudImageEditor/src/EditorToolbar.js +1 -1
  62. package/blocks/CloudImageEditor/src/crop-utils.d.ts +14 -14
  63. package/blocks/CloudImageEditor/src/crop-utils.d.ts.map +1 -1
  64. package/blocks/CloudImageEditor/src/cropper-constants.d.ts.map +1 -1
  65. package/blocks/CloudImageEditor/src/lib/applyFocusVisiblePolyfill.d.ts +1 -1
  66. package/blocks/CloudImageEditor/src/lib/applyFocusVisiblePolyfill.d.ts.map +1 -1
  67. package/blocks/CloudImageEditor/src/lib/parseCropPreset.d.ts +1 -1
  68. package/blocks/CloudImageEditor/src/lib/transformationUtils.d.ts +3 -3
  69. package/blocks/CloudImageEditor/src/lib/transformationUtils.d.ts.map +1 -1
  70. package/blocks/CloudImageEditor/src/state.d.ts +4 -4
  71. package/blocks/CloudImageEditor/src/svg-sprite.d.ts.map +1 -1
  72. package/blocks/CloudImageEditor/src/types.d.ts +8 -58
  73. package/blocks/CloudImageEditor/src/types.d.ts.map +1 -1
  74. package/blocks/CloudImageEditorActivity/CloudImageEditorActivity.d.ts +5 -2
  75. package/blocks/CloudImageEditorActivity/CloudImageEditorActivity.d.ts.map +1 -1
  76. package/blocks/CloudImageEditorActivity/CloudImageEditorActivity.js +7 -3
  77. package/blocks/Config/Config.d.ts +3 -12
  78. package/blocks/Config/Config.d.ts.map +1 -1
  79. package/blocks/Config/assertions.d.ts +1 -1
  80. package/blocks/Config/initialConfig.d.ts +1 -1
  81. package/blocks/Config/initialConfig.d.ts.map +1 -1
  82. package/blocks/Config/initialConfig.js +1 -1
  83. package/blocks/Config/normalizeConfigValue.d.ts.map +1 -1
  84. package/blocks/Config/side-effects.d.ts.map +1 -1
  85. package/blocks/Config/validatorsType.d.ts +1 -1
  86. package/blocks/Config/validatorsType.d.ts.map +1 -1
  87. package/blocks/DropArea/DropArea.d.ts +2 -2
  88. package/blocks/DropArea/DropArea.d.ts.map +1 -1
  89. package/blocks/DropArea/addDropzone.d.ts.map +1 -1
  90. package/blocks/DropArea/drop-area.css +4 -2
  91. package/blocks/DropArea/getDropItems.d.ts +2 -2
  92. package/blocks/DropArea/getDropItems.d.ts.map +1 -1
  93. package/blocks/ExternalSource/ExternalSource.d.ts +3 -3
  94. package/blocks/ExternalSource/ExternalSource.d.ts.map +1 -1
  95. package/blocks/ExternalSource/MessageBridge.d.ts +3 -3
  96. package/blocks/ExternalSource/MessageBridge.d.ts.map +1 -1
  97. package/blocks/ExternalSource/query-string.d.ts.map +1 -1
  98. package/blocks/ExternalSource/types.d.ts +64 -64
  99. package/blocks/ExternalSource/types.d.ts.map +1 -1
  100. package/blocks/FileItem/FileItem.d.ts +13 -40
  101. package/blocks/FileItem/FileItem.d.ts.map +1 -1
  102. package/blocks/FileItem/FileItem.js +119 -172
  103. package/blocks/FileItem/FileItemConfig.d.ts +28 -0
  104. package/blocks/FileItem/FileItemConfig.d.ts.map +1 -0
  105. package/blocks/FileItem/FileItemConfig.js +74 -0
  106. package/blocks/FileItem/file-item.css +21 -6
  107. package/blocks/Img/ImgBase.d.ts +3 -3
  108. package/blocks/Img/ImgBase.d.ts.map +1 -1
  109. package/blocks/Img/ImgBase.js +9 -9
  110. package/blocks/Img/ImgConfig.d.ts.map +1 -1
  111. package/blocks/Img/configurations.d.ts.map +1 -1
  112. package/blocks/Modal/Modal.d.ts +21 -0
  113. package/blocks/Modal/Modal.d.ts.map +1 -1
  114. package/blocks/Modal/Modal.js +37 -16
  115. package/blocks/ProgressBar/ProgressBar.d.ts +6 -1
  116. package/blocks/ProgressBar/ProgressBar.d.ts.map +1 -1
  117. package/blocks/ProgressBar/ProgressBar.js +41 -44
  118. package/blocks/ProgressBar/progress-bar.css +8 -6
  119. package/blocks/Range/Range.d.ts.map +1 -1
  120. package/blocks/SimpleBtn/SimpleBtn.d.ts +2 -2
  121. package/blocks/SimpleBtn/SimpleBtn.d.ts.map +1 -1
  122. package/blocks/SourceBtn/SourceBtn.d.ts +2 -5
  123. package/blocks/SourceBtn/SourceBtn.d.ts.map +1 -1
  124. package/blocks/SourceBtn/SourceBtn.js +5 -5
  125. package/blocks/SourceList/SourceList.js +2 -2
  126. package/blocks/Spinner/Spinner.d.ts.map +1 -1
  127. package/blocks/Thumb/Thumb.d.ts +30 -4
  128. package/blocks/Thumb/Thumb.d.ts.map +1 -1
  129. package/blocks/Thumb/Thumb.js +197 -12
  130. package/blocks/UploadCtxProvider/EventEmitter.d.ts +20 -20
  131. package/blocks/UploadCtxProvider/EventEmitter.d.ts.map +1 -1
  132. package/blocks/UploadCtxProvider/UploadCtxProvider.d.ts +4 -4
  133. package/blocks/UploadCtxProvider/UploadCtxProvider.d.ts.map +1 -1
  134. package/blocks/UploadList/UploadList.d.ts +3 -3
  135. package/blocks/UploadList/UploadList.d.ts.map +1 -1
  136. package/blocks/svg-backgrounds/svg-backgrounds.d.ts +3 -3
  137. package/blocks/svg-backgrounds/svg-backgrounds.d.ts.map +1 -1
  138. package/blocks/themes/uc-basic/svg-sprite.d.ts.map +1 -1
  139. package/blocks/utils/UploadSource.d.ts.map +1 -1
  140. package/blocks/utils/debounce.d.ts +3 -1
  141. package/blocks/utils/debounce.d.ts.map +1 -1
  142. package/blocks/{CloudImageEditor/src/lib → utils}/preloadImage.js +1 -1
  143. package/blocks/utils/resizeImage.d.ts +1 -1
  144. package/blocks/utils/resizeImage.d.ts.map +1 -1
  145. package/blocks/utils/throttle.d.ts +3 -1
  146. package/blocks/utils/throttle.d.ts.map +1 -1
  147. package/blocks/utils/userAgent.d.ts +1 -1
  148. package/blocks/utils/userAgent.d.ts.map +1 -1
  149. package/env.d.ts +1 -1
  150. package/env.d.ts.map +1 -1
  151. package/env.js +1 -1
  152. package/index.d.ts +1 -0
  153. package/index.js +1 -0
  154. package/index.ssr.d.ts +9 -1
  155. package/index.ssr.d.ts.map +1 -1
  156. package/index.ssr.js +17 -11
  157. package/locales/file-uploader/ar.d.ts +1 -0
  158. package/locales/file-uploader/ar.js +1 -0
  159. package/locales/file-uploader/az.d.ts +1 -0
  160. package/locales/file-uploader/az.js +1 -0
  161. package/locales/file-uploader/ca.d.ts +1 -0
  162. package/locales/file-uploader/ca.js +1 -0
  163. package/locales/file-uploader/cs.d.ts +1 -0
  164. package/locales/file-uploader/cs.js +1 -0
  165. package/locales/file-uploader/da.d.ts +1 -0
  166. package/locales/file-uploader/da.js +1 -0
  167. package/locales/file-uploader/de.d.ts +1 -0
  168. package/locales/file-uploader/de.js +1 -0
  169. package/locales/file-uploader/el.d.ts +1 -0
  170. package/locales/file-uploader/el.js +1 -0
  171. package/locales/file-uploader/en.d.ts +1 -0
  172. package/locales/file-uploader/en.js +1 -0
  173. package/locales/file-uploader/es.d.ts +1 -0
  174. package/locales/file-uploader/es.js +1 -0
  175. package/locales/file-uploader/et.d.ts +1 -0
  176. package/locales/file-uploader/et.js +1 -0
  177. package/locales/file-uploader/fi.d.ts +1 -0
  178. package/locales/file-uploader/fi.js +1 -0
  179. package/locales/file-uploader/fr.d.ts +1 -0
  180. package/locales/file-uploader/fr.js +1 -0
  181. package/locales/file-uploader/he.d.ts +1 -0
  182. package/locales/file-uploader/he.js +1 -0
  183. package/locales/file-uploader/hy.d.ts +1 -0
  184. package/locales/file-uploader/hy.js +1 -0
  185. package/locales/file-uploader/is.d.ts +1 -0
  186. package/locales/file-uploader/is.js +1 -0
  187. package/locales/file-uploader/it.d.ts +1 -0
  188. package/locales/file-uploader/it.js +1 -0
  189. package/locales/file-uploader/ja.d.ts +1 -0
  190. package/locales/file-uploader/ja.js +1 -0
  191. package/locales/file-uploader/ka.d.ts +1 -0
  192. package/locales/file-uploader/ka.js +1 -0
  193. package/locales/file-uploader/kk.d.ts +1 -0
  194. package/locales/file-uploader/kk.js +1 -0
  195. package/locales/file-uploader/ko.d.ts +1 -0
  196. package/locales/file-uploader/ko.js +1 -0
  197. package/locales/file-uploader/lv.d.ts +1 -0
  198. package/locales/file-uploader/lv.js +1 -0
  199. package/locales/file-uploader/nb.d.ts +1 -0
  200. package/locales/file-uploader/nb.js +1 -0
  201. package/locales/file-uploader/nl.d.ts +1 -0
  202. package/locales/file-uploader/nl.js +1 -0
  203. package/locales/file-uploader/pl.d.ts +1 -0
  204. package/locales/file-uploader/pl.js +1 -0
  205. package/locales/file-uploader/pt.d.ts +1 -0
  206. package/locales/file-uploader/pt.js +1 -0
  207. package/locales/file-uploader/ro.d.ts +1 -0
  208. package/locales/file-uploader/ro.js +1 -0
  209. package/locales/file-uploader/ru.d.ts +1 -0
  210. package/locales/file-uploader/ru.js +1 -0
  211. package/locales/file-uploader/sk.d.ts +1 -0
  212. package/locales/file-uploader/sk.js +1 -0
  213. package/locales/file-uploader/sr.d.ts +1 -0
  214. package/locales/file-uploader/sr.js +1 -0
  215. package/locales/file-uploader/sv.d.ts +1 -0
  216. package/locales/file-uploader/sv.js +1 -0
  217. package/locales/file-uploader/tr.d.ts +1 -0
  218. package/locales/file-uploader/tr.js +1 -0
  219. package/locales/file-uploader/uk.d.ts +1 -0
  220. package/locales/file-uploader/uk.js +1 -0
  221. package/locales/file-uploader/vi.d.ts +1 -0
  222. package/locales/file-uploader/vi.js +1 -0
  223. package/locales/file-uploader/zh-TW.d.ts +1 -0
  224. package/locales/file-uploader/zh-TW.js +1 -0
  225. package/locales/file-uploader/zh.d.ts +1 -0
  226. package/locales/file-uploader/zh.js +1 -0
  227. package/package.json +7 -8
  228. package/solutions/file-uploader/inline/FileUploaderInline.d.ts +2 -2
  229. package/solutions/file-uploader/inline/FileUploaderInline.d.ts.map +1 -1
  230. package/solutions/file-uploader/minimal/FileUploaderMinimal.d.ts +18 -2
  231. package/solutions/file-uploader/minimal/FileUploaderMinimal.d.ts.map +1 -1
  232. package/solutions/file-uploader/minimal/FileUploaderMinimal.js +46 -35
  233. package/solutions/file-uploader/minimal/index.css +5 -23
  234. package/solutions/file-uploader/regular/FileUploaderRegular.d.ts +2 -2
  235. package/solutions/file-uploader/regular/FileUploaderRegular.d.ts.map +1 -1
  236. package/types/jsx.d.ts +1 -1
  237. package/utils/browser-info.d.ts +13 -0
  238. package/utils/browser-info.d.ts.map +1 -0
  239. package/utils/browser-info.js +22 -0
  240. package/utils/browser-info.test.d.ts +2 -0
  241. package/utils/browser-info.test.d.ts.map +1 -0
  242. package/utils/browser-info.test.js +109 -0
  243. package/utils/cdn-utils.d.ts +3 -3
  244. package/utils/cdn-utils.d.ts.map +1 -1
  245. package/utils/fileTypes.d.ts +5 -1
  246. package/utils/fileTypes.d.ts.map +1 -1
  247. package/utils/fileTypes.js +18 -2
  248. package/utils/getPluralForm.d.ts.map +1 -1
  249. package/utils/isSecureTokenExpired.d.ts +1 -1
  250. package/utils/memoize.d.ts.map +1 -1
  251. package/utils/mixinClass.d.ts +3 -1
  252. package/utils/mixinClass.d.ts.map +1 -1
  253. package/utils/prettyBytes.d.ts.map +1 -1
  254. package/utils/template-utils.d.ts +1 -1
  255. package/utils/template-utils.d.ts.map +1 -1
  256. package/utils/toKebabCase.d.ts.map +1 -1
  257. package/utils/transparentPixelSrc.d.ts.map +1 -1
  258. package/utils/uniqueArray.d.ts.map +1 -1
  259. package/utils/validators/collection/validateCollectionUploadError.d.ts +1 -1
  260. package/utils/validators/collection/validateMultiple.d.ts +1 -1
  261. package/utils/validators/file/validateFileType.d.ts +1 -1
  262. package/utils/validators/file/validateIsImage.d.ts +1 -1
  263. package/utils/validators/file/validateMaxSizeLimit.d.ts +1 -1
  264. package/utils/validators/file/validateUploadError.d.ts +1 -1
  265. package/utils/waitForAttribute.d.ts +1 -1
  266. package/utils/waitForAttribute.d.ts.map +1 -1
  267. package/web/file-uploader.iife.min.js +4 -4
  268. package/web/file-uploader.min.js +4 -4
  269. package/web/uc-basic.min.css +1 -1
  270. package/web/uc-cloud-image-editor.min.js +2 -2
  271. package/web/uc-file-uploader-inline.min.css +1 -1
  272. package/web/uc-file-uploader-inline.min.js +4 -4
  273. package/web/uc-file-uploader-minimal.min.css +1 -1
  274. package/web/uc-file-uploader-minimal.min.js +4 -4
  275. package/web/uc-file-uploader-regular.min.css +1 -1
  276. package/web/uc-file-uploader-regular.min.js +4 -4
  277. package/web/uc-img.min.js +2 -2
  278. package/blocks/utils/supportCapture.d.ts +0 -2
  279. package/blocks/utils/supportCapture.d.ts.map +0 -1
  280. package/blocks/utils/supportCapture.js +0 -3
  281. /package/blocks/{CloudImageEditor/src/lib → utils}/preloadImage.d.ts +0 -0
  282. /package/blocks/{CloudImageEditor/src/lib → utils}/preloadImage.d.ts.map +0 -0
@@ -1,23 +1,30 @@
1
+ // @ts-check
1
2
  import { Data, UID } from '@symbiotejs/symbiote';
2
3
  import { TypedData } from './TypedData.js';
3
4
 
5
+ /**
6
+ * @template {import('./TypedData.js').TypedSchema} T
7
+ * @typedef {(list: string[], added: Set<import('./TypedData.js').TypedData<T>>, removed: Set<TypedData<T>>) => void} TypedCollectionObserverHandler
8
+ */
9
+
10
+ /** @template {import('./TypedData.js').TypedSchema} T */
4
11
  export class TypedCollection {
5
12
  /**
6
13
  * @param {Object} options
7
- * @param {Object<string, { type: any; value: any }>} options.typedSchema
8
- * @param {String[]} [options.watchList]
9
- * @param {(list: string[], added: Set<any>, removed: Set<any>) => void} [options.handler]
10
- * @param {String} [options.ctxName]
14
+ * @param {T} options.typedSchema
15
+ * @param {import('./TypedData.js').ExtractKeysFromSchema<T>[]} [options.watchList]
16
+ * @param {TypedCollectionObserverHandler<T>} [options.handler]
17
+ * @param {string} [options.ctxName]
11
18
  */
12
19
  constructor(options) {
13
20
  /**
14
21
  * @private
15
- * @type {Object<string, { type: any; value: any }>}
22
+ * @type {T}
16
23
  */
17
24
  this.__typedSchema = options.typedSchema;
18
25
  /**
19
26
  * @private
20
- * @type {String}
27
+ * @type {string}
21
28
  */
22
29
  this.__ctxId = options.ctxName || UID.generate();
23
30
  /**
@@ -27,12 +34,12 @@ export class TypedCollection {
27
34
  this.__data = Data.registerCtx({}, this.__ctxId);
28
35
  /**
29
36
  * @private
30
- * @type {string[]}
37
+ * @type {import('./TypedData.js').ExtractKeysFromSchema<T>[]}
31
38
  */
32
39
  this.__watchList = options.watchList || [];
33
40
  /**
34
41
  * @private
35
- * @type {Object<string, any>}
42
+ * @type {Object<string, ReturnType<TypedData<T>['subscribe']>[]>}
36
43
  */
37
44
  this.__subsMap = Object.create(null);
38
45
  /**
@@ -42,7 +49,7 @@ export class TypedCollection {
42
49
  this.__propertyObservers = new Set();
43
50
  /**
44
51
  * @private
45
- * @type {Set<(list: string[], added: Set<any>, removed: Set<any>) => void>}
52
+ * @type {Set<TypedCollectionObserverHandler<T>>}
46
53
  */
47
54
  this.__collectionObservers = new Set();
48
55
  /**
@@ -52,12 +59,12 @@ export class TypedCollection {
52
59
  this.__items = new Set();
53
60
  /**
54
61
  * @private
55
- * @type {Set<any>}
62
+ * @type {Set<import('./TypedData.js').TypedData<T>>}
56
63
  */
57
64
  this.__removed = new Set();
58
65
  /**
59
66
  * @private
60
- * @type {Set<any>}
67
+ * @type {Set<import('./TypedData.js').TypedData<T>>}
61
68
  */
62
69
  this.__added = new Set();
63
70
 
@@ -105,7 +112,7 @@ export class TypedCollection {
105
112
  });
106
113
  }
107
114
 
108
- /** @param {(list: string[], added: Set<any>, removed: Set<any>) => void} handler */
115
+ /** @param {TypedCollectionObserverHandler<T>} handler */
109
116
  observeCollection(handler) {
110
117
  this.__collectionObservers.add(handler);
111
118
 
@@ -118,19 +125,19 @@ export class TypedCollection {
118
125
  };
119
126
  }
120
127
 
121
- /** @param {Function} handler */
128
+ /** @param {TypedCollectionObserverHandler<T>} handler */
122
129
  unobserveCollection(handler) {
123
130
  this.__collectionObservers?.delete(handler);
124
131
  }
125
132
 
126
133
  /**
127
- * @param {Object<string, any>} init
134
+ * @param {Partial<import('./TypedData.js').ExtractDataFromSchema<T>>} init
128
135
  * @returns {string}
129
136
  */
130
137
  add(init) {
131
138
  let item = new TypedData(this.__typedSchema);
132
- for (let prop in init) {
133
- item.setValue(prop, init[prop]);
139
+ for (let [prop, value] of Object.entries(init)) {
140
+ item.setValue(/** @type {import('./TypedData.js').ExtractKeysFromSchema<T>} */ (prop), value);
134
141
  }
135
142
  this.__items.add(item.uid);
136
143
  this.notify();
@@ -139,7 +146,7 @@ export class TypedCollection {
139
146
  this.__added.add(item);
140
147
  this.__watchList.forEach((propName) => {
141
148
  if (!this.__subsMap[item.uid]) {
142
- this.__subsMap[item.uid] = [];
149
+ this.__subsMap[item.uid] = /** @type {ReturnType<TypedData<T>['subscribe']>[]} */ ([]);
143
150
  }
144
151
  this.__subsMap[item.uid].push(
145
152
  item.subscribe(propName, () => {
@@ -151,37 +158,49 @@ export class TypedCollection {
151
158
  }
152
159
 
153
160
  /**
154
- * @param {String} id
155
- * @returns {TypedData}
161
+ * @param {string} id
162
+ * @returns {TypedData<T> | null}
156
163
  */
157
164
  read(id) {
158
165
  return this.__data.read(id);
159
166
  }
160
167
 
161
168
  /**
162
- * @param {String} id
163
- * @param {String} propName
164
- * @returns {any}
169
+ * @template {import('./TypedData.js').ExtractKeysFromSchema<T>} K
170
+ * @param {string} id
171
+ * @param {K} propName
172
+ * @returns {import('./TypedData.js').ExtractDataFromSchema<T>[propName] | null}
165
173
  */
166
174
  readProp(id, propName) {
167
175
  let item = this.read(id);
176
+ if (!item) {
177
+ console.warn(`Item with id ${id} not found`);
178
+ return null;
179
+ }
168
180
  return item.getValue(propName);
169
181
  }
170
182
 
171
183
  /**
172
- * @template T
173
- * @param {String} id
174
- * @param {String} propName
175
- * @param {T} value
184
+ * @template {import('./TypedData.js').ExtractKeysFromSchema<T>} K
185
+ * @param {string} id
186
+ * @param {K} propName
187
+ * @param {import('./TypedData.js').ExtractDataFromSchema<T>[K]} value
176
188
  */
177
189
  publishProp(id, propName, value) {
178
190
  let item = this.read(id);
191
+ if (!item) {
192
+ console.warn(`Item with id ${id} not found`);
193
+ return;
194
+ }
179
195
  item.setValue(propName, value);
180
196
  }
181
197
 
182
- /** @param {String} id */
198
+ /** @param {string} id */
183
199
  remove(id) {
184
- this.__removed.add(this.__data.read(id));
200
+ let item = this.read(id);
201
+ if (item) {
202
+ this.__removed.add(item);
203
+ }
185
204
  this.__items.delete(id);
186
205
  this.notify();
187
206
  this.__data.pub(id, null);
@@ -209,14 +228,15 @@ export class TypedCollection {
209
228
  }
210
229
 
211
230
  /**
212
- * @param {(item: TypedData) => Boolean} checkFn
213
- * @returns {String[]}
231
+ * @param {(item: TypedData<T>) => Boolean} checkFn
232
+ * @returns {string[]}
214
233
  */
215
234
  findItems(checkFn) {
235
+ /** @type {string[]} */
216
236
  let result = [];
217
237
  this.__items.forEach((id) => {
218
238
  let item = this.read(id);
219
- if (checkFn(item)) {
239
+ if (item && checkFn(item)) {
220
240
  result.push(id);
221
241
  }
222
242
  });
@@ -233,8 +253,8 @@ export class TypedCollection {
233
253
 
234
254
  destroy() {
235
255
  Data.deleteCtx(this.__ctxId);
236
- this.__propertyObservers = null;
237
- this.__collectionObservers = null;
256
+ this.__propertyObservers = new Set();
257
+ this.__collectionObservers = new Set();
238
258
  for (let id in this.__subsMap) {
239
259
  this.__subsMap[id].forEach((sub) => {
240
260
  sub.remove();
@@ -1,47 +1,93 @@
1
- export class TypedData {
1
+ /** @typedef {Record<string, { type: unknown; value: unknown; nullable?: boolean }>} TypedSchema */
2
+ /**
3
+ * @template {any} [T=any] Default is `any`
4
+ * @typedef {new (...args: any[]) => T} Constructor
5
+ */
6
+ /**
7
+ * @template {unknown} T
8
+ * @template {unknown} V
9
+ * @typedef {T extends StringConstructor
10
+ * ? string
11
+ * : T extends BooleanConstructor
12
+ * ? boolean
13
+ * : T extends NumberConstructor
14
+ * ? number
15
+ * : T extends ArrayConstructor
16
+ * ? V
17
+ * : T extends Constructor
18
+ * ? InstanceType<T>
19
+ * : T} ExtractType
20
+ */
21
+ /**
22
+ * @template {TypedSchema} T
23
+ * @typedef {{
24
+ * [K in keyof T]: ExtractType<T[K]['type'], T[K]['value']> | (T[K]['nullable'] extends true ? null : never);
25
+ * }} ExtractDataFromSchema
26
+ */
27
+ /**
28
+ * @template {TypedSchema} T
29
+ * @typedef {Extract<keyof T, string>} ExtractKeysFromSchema
30
+ */
31
+ /** @template {TypedSchema} T */
32
+ export class TypedData<T extends TypedSchema> {
2
33
  /**
3
- * @param {Object<string, { type: any; value: any; nullable?: Boolean }>} typedSchema
34
+ * @param {T} typedSchema
4
35
  * @param {String} [ctxName]
5
36
  */
6
- constructor(typedSchema: {
7
- [x: string]: {
8
- type: any;
9
- value: any;
10
- nullable?: boolean;
11
- };
12
- }, ctxName?: string | undefined);
13
- /** @private */
37
+ constructor(typedSchema: T, ctxName?: string);
38
+ /**
39
+ * @private
40
+ * @type {T}
41
+ */
14
42
  private __typedSchema;
15
- /** @private */
43
+ /**
44
+ * @private
45
+ * @type {string}
46
+ */
16
47
  private __ctxId;
17
- /** @private */
48
+ /**
49
+ * @private
50
+ * @type {ExtractDataFromSchema<T>}
51
+ */
18
52
  private __schema;
19
53
  /**
20
54
  * @private
21
55
  * @type {Data}
22
56
  */
23
57
  private __data;
24
- /** @returns {String} */
58
+ /** @returns {string} */
25
59
  get uid(): string;
26
60
  /**
27
- * @param {String} prop
28
- * @param {any} value
61
+ * @param {ExtractKeysFromSchema<T>} prop
62
+ * @param {ExtractDataFromSchema<T>[prop]} value
63
+ */
64
+ setValue(prop: ExtractKeysFromSchema<T>, value: ExtractDataFromSchema<T>[Extract<keyof T, string>]): void;
65
+ /** @param {Partial<ExtractDataFromSchema<T>>} updObj */
66
+ setMultipleValues(updObj: Partial<ExtractDataFromSchema<T>>): void;
67
+ /**
68
+ * @template {ExtractKeysFromSchema<T>} K
69
+ * @param {K} prop
70
+ * @returns {ExtractDataFromSchema<T>[K]}
29
71
  */
30
- setValue(prop: string, value: any): void;
31
- /** @param {Object<string, any>} updObj */
32
- setMultipleValues(updObj: {
33
- [x: string]: any;
34
- }): void;
35
- /** @param {String} prop */
36
- getValue(prop: string): any;
72
+ getValue<K extends ExtractKeysFromSchema<T>>(prop: K): ExtractDataFromSchema<T>[K];
37
73
  /**
38
- * @param {String} prop
39
- * @param {(newVal: any) => void} handler
74
+ * @template {ExtractKeysFromSchema<T>} K
75
+ * @param {K} prop
76
+ * @param {(newVal: ExtractDataFromSchema<T>[K]) => void} handler
40
77
  */
41
- subscribe(prop: string, handler: (newVal: any) => void): {
78
+ subscribe<K extends ExtractKeysFromSchema<T>>(prop: K, handler: (newVal: ExtractDataFromSchema<T>[K]) => void): {
42
79
  remove: () => void;
43
80
  callback: Function;
44
81
  };
45
82
  remove(): void;
46
83
  }
84
+ export type TypedSchema = Record<string, {
85
+ type: unknown;
86
+ value: unknown;
87
+ nullable?: boolean;
88
+ }>;
89
+ export type Constructor<T extends unknown = any> = new (...args: any[]) => T;
90
+ export type ExtractType<T extends unknown, V extends unknown> = T extends StringConstructor ? string : T extends BooleanConstructor ? boolean : T extends NumberConstructor ? number : T extends ArrayConstructor ? V : T extends Constructor ? InstanceType<T> : T;
91
+ export type ExtractDataFromSchema<T extends TypedSchema> = { [K in keyof T]: ExtractType<T[K]["type"], T[K]["value"]> | (T[K]["nullable"] extends true ? null : never); };
92
+ export type ExtractKeysFromSchema<T extends TypedSchema> = Extract<keyof T, string>;
47
93
  //# sourceMappingURL=TypedData.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TypedData.d.ts","sourceRoot":"","sources":["TypedData.js"],"names":[],"mappings":"AAKA;IACE;;;OAGG;IACH;YAHkB,MAAM,GAAE;YAAE,IAAI,EAAE,GAAG,CAAC;YAAC,KAAK,EAAE,GAAG,CAAC;YAAC,QAAQ,CAAC,UAAS;SAAE;qCAkBtE;IAdC,eAAe;IACf,sBAAgC;IAChC,eAAe;IACf,gBAAwC;IACxC,eAAe;IACf,iBAGM;IACN;;;OAGG;IACH,eAA2D;IAG7D,wBAAwB;IACxB,kBAEC;IAED;;;OAGG;IACH,8BAFW,GAAG,QAab;IAED,0CAA0C;IAC1C;YADmB,MAAM,GAAE,GAAG;aAK7B;IAED,2BAA2B;IAC3B,4BAMC;IAED;;;OAGG;IACH,0CAFoB,GAAG,KAAK,IAAI;;;MAI/B;IAED,eAEC;CACF"}
1
+ {"version":3,"file":"TypedData.d.ts","sourceRoot":"","sources":["TypedData.js"],"names":[],"mappings":"AAMA,mGAAmG;AAEnG;;;GAGG;AAEH;;;;;;;;;;;;;;GAcG;AAEH;;;;;GAKG;AAEH;;;GAGG;AAEH,gCAAgC;AAChC,uBAD4B,CAAC,SAAd,WAAY;IAEzB;;;OAGG;IACH,yBAHW,CAAC,oBA6BX;IAzBC;;;OAGG;IACH,sBAAgC;IAEhC;;;OAGG;IACH,gBAAwC;IAExC;;;OAGG;IACH,iBAGgD;IAChD;;;OAGG;IACH,eAA2D;IAG7D,wBAAwB;IACxB,WADc,MAAM,CAGnB;IAED;;;OAGG;IACH,eAHW,qBAAqB,CAAC,CAAC,CAAC,SACxB,qBAAqB,CAAC,CAAC,CAAC,0BAAM,QAkBxC;IAED,wDAAwD;IACxD,0BADY,OAAO,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,QAK5C;IAED;;;;OAIG;IACH,SAJwC,CAAC,SAA3B,qBAAqB,CAAC,CAAC,CAAE,QAC5B,CAAC,GACC,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAOvC;IAED;;;;OAIG;IACH,UAJwC,CAAC,SAA3B,qBAAqB,CAAC,CAAC,CAAE,QAC5B,CAAC,WACD,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI;;;MAIvD;IAED,eAEC;CACF;0BA/Ha,MAAM,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;wBAG/D,CAAC,0BACR,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC;wBAIf,CAAC,SAAX,OAAS,EACC,CAAC,SAAX,OAAS,IACT,CAAC,SAAS,iBAAiB,GACjC,MAAM,GACN,CAAC,SAAS,kBAAkB,GAC1B,OAAO,GACP,CAAC,SAAS,iBAAiB,GACzB,MAAM,GACN,CAAC,SAAS,gBAAgB,GACxB,CAAC,GACD,CAAC,SAAS,WAAW,GACnB,YAAY,CAAC,CAAC,CAAC,GACf,CAAC;kCAIW,CAAC,SAAd,WAAY,IACb,GACP,CAAC,IAAI,MAAM,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,SAAS,IAAI,GAAG,IAAI,GAAG,KAAK,CAAC,GAC1G;kCAIuB,CAAC,SAAd,WAAY,IACb,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC"}
@@ -1,23 +1,71 @@
1
+ // @ts-check
1
2
  import { Data, UID } from '@symbiotejs/symbiote';
2
3
 
3
4
  const MSG_NAME = '[Typed State] Wrong property name: ';
4
5
  const MSG_TYPE = '[Typed State] Wrong property type: ';
5
6
 
7
+ /** @typedef {Record<string, { type: unknown; value: unknown; nullable?: boolean }>} TypedSchema */
8
+
9
+ /**
10
+ * @template {any} [T=any] Default is `any`
11
+ * @typedef {new (...args: any[]) => T} Constructor
12
+ */
13
+
14
+ /**
15
+ * @template {unknown} T
16
+ * @template {unknown} V
17
+ * @typedef {T extends StringConstructor
18
+ * ? string
19
+ * : T extends BooleanConstructor
20
+ * ? boolean
21
+ * : T extends NumberConstructor
22
+ * ? number
23
+ * : T extends ArrayConstructor
24
+ * ? V
25
+ * : T extends Constructor
26
+ * ? InstanceType<T>
27
+ * : T} ExtractType
28
+ */
29
+
30
+ /**
31
+ * @template {TypedSchema} T
32
+ * @typedef {{
33
+ * [K in keyof T]: ExtractType<T[K]['type'], T[K]['value']> | (T[K]['nullable'] extends true ? null : never);
34
+ * }} ExtractDataFromSchema
35
+ */
36
+
37
+ /**
38
+ * @template {TypedSchema} T
39
+ * @typedef {Extract<keyof T, string>} ExtractKeysFromSchema
40
+ */
41
+
42
+ /** @template {TypedSchema} T */
6
43
  export class TypedData {
7
44
  /**
8
- * @param {Object<string, { type: any; value: any; nullable?: Boolean }>} typedSchema
45
+ * @param {T} typedSchema
9
46
  * @param {String} [ctxName]
10
47
  */
11
48
  constructor(typedSchema, ctxName) {
12
- /** @private */
49
+ /**
50
+ * @private
51
+ * @type {T}
52
+ */
13
53
  this.__typedSchema = typedSchema;
14
- /** @private */
54
+
55
+ /**
56
+ * @private
57
+ * @type {string}
58
+ */
15
59
  this.__ctxId = ctxName || UID.generate();
16
- /** @private */
60
+
61
+ /**
62
+ * @private
63
+ * @type {ExtractDataFromSchema<T>}
64
+ */
17
65
  this.__schema = Object.keys(typedSchema).reduce((acc, key) => {
18
- acc[key] = typedSchema[key].value;
66
+ /** @type {any} */ (acc)[key] = typedSchema[key].value;
19
67
  return acc;
20
- }, {});
68
+ }, /** @type {ExtractDataFromSchema<T>} */ ({}));
21
69
  /**
22
70
  * @private
23
71
  * @type {Data}
@@ -25,14 +73,14 @@ export class TypedData {
25
73
  this.__data = Data.registerCtx(this.__schema, this.__ctxId);
26
74
  }
27
75
 
28
- /** @returns {String} */
76
+ /** @returns {string} */
29
77
  get uid() {
30
78
  return this.__ctxId;
31
79
  }
32
80
 
33
81
  /**
34
- * @param {String} prop
35
- * @param {any} value
82
+ * @param {ExtractKeysFromSchema<T>} prop
83
+ * @param {ExtractDataFromSchema<T>[prop]} value
36
84
  */
37
85
  setValue(prop, value) {
38
86
  if (!this.__typedSchema.hasOwnProperty(prop)) {
@@ -40,32 +88,41 @@ export class TypedData {
40
88
  return;
41
89
  }
42
90
  let pDesc = this.__typedSchema[prop];
43
- if (value?.constructor === pDesc.type || value instanceof pDesc.type || (pDesc.nullable && value === null)) {
91
+
92
+ let isMatchConstructorType = value?.constructor === pDesc.type;
93
+ let isMatchInstanceType = /** @type {any} */ (value) instanceof /** @type {any} */ (pDesc['type']);
94
+ let isMatchNullable = pDesc.nullable && value === null;
95
+
96
+ if (isMatchConstructorType || isMatchInstanceType || isMatchNullable) {
44
97
  this.__data.pub(prop, value);
45
98
  return;
46
99
  }
47
100
  console.warn(MSG_TYPE + prop);
48
101
  }
49
102
 
50
- /** @param {Object<string, any>} updObj */
103
+ /** @param {Partial<ExtractDataFromSchema<T>>} updObj */
51
104
  setMultipleValues(updObj) {
52
- for (let prop in updObj) {
53
- this.setValue(prop, updObj[prop]);
105
+ for (let [prop, value] of Object.entries(updObj)) {
106
+ this.setValue(/** @type {ExtractKeysFromSchema<T>} */ (prop), value);
54
107
  }
55
108
  }
56
109
 
57
- /** @param {String} prop */
110
+ /**
111
+ * @template {ExtractKeysFromSchema<T>} K
112
+ * @param {K} prop
113
+ * @returns {ExtractDataFromSchema<T>[K]}
114
+ */
58
115
  getValue(prop) {
59
116
  if (!this.__typedSchema.hasOwnProperty(prop)) {
60
117
  console.warn(MSG_NAME + prop);
61
- return undefined;
62
118
  }
63
119
  return this.__data.read(prop);
64
120
  }
65
121
 
66
122
  /**
67
- * @param {String} prop
68
- * @param {(newVal: any) => void} handler
123
+ * @template {ExtractKeysFromSchema<T>} K
124
+ * @param {K} prop
125
+ * @param {(newVal: ExtractDataFromSchema<T>[K]) => void} handler
69
126
  */
70
127
  subscribe(prop, handler) {
71
128
  return this.__data.sub(prop, handler);
@@ -7,11 +7,11 @@ export class UploaderBlock extends ActivityBlock {
7
7
  '*commonProgress': number;
8
8
  '*uploadList': never[];
9
9
  '*uploadQueue': import("@uploadcare/upload-client").Queue;
10
- '*collectionErrors': any[];
11
- '*collectionState': import("../types").OutputCollectionState<import("../types").OutputCollectionStatus, "maybe-has-group"> | null;
10
+ '*collectionErrors': ReturnType<import("../types").OutputErrorCollection>[];
11
+ '*collectionState': import("../types").OutputCollectionState | null;
12
12
  '*groupInfo': import("@uploadcare/upload-client").UploadcareGroup | null;
13
13
  '*uploadTrigger': Set<string>;
14
- '*secureUploadsManager': SecureUploadsManager | null;
14
+ '*secureUploadsManager': import("./SecureUploadsManager.js").SecureUploadsManager | null;
15
15
  '*currentActivity': null;
16
16
  '*currentActivityParams': {};
17
17
  '*history': never[];
@@ -28,8 +28,8 @@ export class UploaderBlock extends ActivityBlock {
28
28
  /** @returns {UploaderPublicApi} */
29
29
  get api(): UploaderPublicApi;
30
30
  getAPI(): UploaderPublicApi;
31
- /** @returns {TypedCollection} */
32
- get uploadCollection(): TypedCollection;
31
+ /** @returns {TypedCollection<typeof uploadEntrySchema>} */
32
+ get uploadCollection(): TypedCollection<typeof uploadEntrySchema>;
33
33
  /** @private */
34
34
  private initCtxOwner;
35
35
  /** @private */
@@ -45,13 +45,12 @@ export class UploaderBlock extends ActivityBlock {
45
45
  private _flushOutputItems;
46
46
  /**
47
47
  * @private
48
- * @type {Parameters<import('./TypedCollection.js').TypedCollection['observeCollection']>[0]}
49
- * @param {Set<import('./TypedData.js').TypedData>} removed
48
+ * @type {import('./TypedCollection.js').TypedCollectionObserverHandler<typeof uploadEntrySchema>}
50
49
  */
51
50
  private _handleCollectionUpdate;
52
51
  /**
53
52
  * @private
54
- * @param {Record<keyof import('./uploadEntrySchema.js').UploadEntry, Set<string>>} changeMap
53
+ * @param {Record<keyof import('./uploadEntrySchema.js').UploadEntryData, Set<string>>} changeMap
55
54
  */
56
55
  private _handleCollectionPropertiesUpdate;
57
56
  /** @private */
@@ -68,9 +67,9 @@ export class UploaderBlock extends ActivityBlock {
68
67
  * @returns {Promise<import('@uploadcare/upload-client').FileFromOptions>}
69
68
  * @protected
70
69
  */
71
- protected getUploadClientOptions(): Promise<import('@uploadcare/upload-client').FileFromOptions>;
70
+ protected getUploadClientOptions(): Promise<import("@uploadcare/upload-client").FileFromOptions>;
72
71
  /** @returns {import('../types/exported.js').OutputFileEntry[]} */
73
- getOutputData(): import('../types/exported.js').OutputFileEntry[];
72
+ getOutputData(): import("../types/exported.js").OutputFileEntry[];
74
73
  }
75
74
  export namespace UploaderBlock {
76
75
  type extSrcList = string;
@@ -114,4 +113,5 @@ import { SecureUploadsManager } from './SecureUploadsManager.js';
114
113
  import { ValidationManager } from './ValidationManager.js';
115
114
  import { UploaderPublicApi } from './UploaderPublicApi.js';
116
115
  import { TypedCollection } from './TypedCollection.js';
116
+ import { uploadEntrySchema } from './uploadEntrySchema.js';
117
117
  //# sourceMappingURL=UploaderBlock.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"UploaderBlock.d.ts","sourceRoot":"","sources":["UploaderBlock.js"],"names":[],"mappings":"AAmBA;IACE,iBAAiB;IACjB,mCAAwB;IAExB,eAAe;IACf,mBAAmB;IAEnB;;;;;;;;;;;;;;MAA+B;IAE/B,eAAe;IACf,0BAOC;IA2BD;;;OAGG;IACH,qDAKC;IAED,mCAAmC;IACnC,6BAKC;IAED,4BAEC;IAED,iCAAiC;IACjC,wCAKC;IAYD,eAAe;IACf,qBAkBC;IAfC,eAAe;IACf,6BAAiG;IAEjG,eAAe;IACf,uCAEC;IAWH;;;OAGG;IACH,qBAkBC;IAED,eAAe;IACf,0BAYQ;IAER;;;;OAIG;IACH,gCAiCE;IAEF;;;OAGG;IACH,0CA6FE;IAEF,eAAe;IACf,mCAoBE;IAEF,6BAiBC;IAED,eAAe;IACf,uBAwCC;IAED;;;OAGG;IACH,kCAHW,MAAM,qEAWhB;IAED;;;OAGG;IACH,oCAHa,QAAQ,OAAO,2BAA2B,EAAE,eAAe,CAAC,CA2BxE;IAED,kEAAkE;IAClE,iBADc,OAAO,sBAAsB,EAAE,eAAe,EAAE,CAK7D;CACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8BArb6B,oBAAoB;qCAWb,2BAA2B;kCAG9B,wBAAwB;kCADxB,wBAAwB;gCAD1B,sBAAsB"}
1
+ {"version":3,"file":"UploaderBlock.d.ts","sourceRoot":"","sources":["UploaderBlock.js"],"names":[],"mappings":"AAmBA;IACE,iBAAiB;IACjB,mCAAwB;IAExB,eAAe;IACf,mBAAmB;IAEnB;;;;+CAdA,UAAU;mCACa,UAAS;6BAEjC,2BAA2B;;wCAEW,2BAA2B;;;;;;MASjC;IAE/B,eAAe;IACf,0BAOC;IA2BD;;;OAGG;IACH,mCAHa,iBAAiB,CAQ7B;IAED,mCAAmC;IACnC,WADc,iBAAiB,CAM9B;IAED,4BAEC;IAED,2DAA2D;IAC3D,wBADc,eAAe,CAAC,OAAO,iBAAiB,CAAC,CAMtD;IAYD,eAAe;IACf,qBAkBC;IAfC,eAAe;IACf,6BAAiG;IAEjG,eAAe;IACf,uCAEC;IAWH;;;OAGG;IACH,qBAkBC;IAED,eAAe;IACf,0BAYQ;IAER;;;OAGG;IACH,gCAkCE;IAEF;;;OAGG;IACH,0CA6FE;IAEF,eAAe;IACf,mCAsBE;IAEF,6BAiBC;IAED,eAAe;IACf,uBAkDC;IAED;;;OAGG;IACH,kCAHW,MAAM,qEAWhB;IAED;;;OAGG;IACH,oCAHa,OAAO,CAAC,OAAO,2BAA2B,EAAE,eAAe,CAAC,CA2BxE;IAED,kEAAkE;IAClE,iBADc,OAAO,sBAAsB,EAAE,eAAe,EAAE,CAK7D;CACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8BAjc6B,oBAAoB;qCAWb,2BAA2B;kCAG9B,wBAAwB;kCADxB,wBAAwB;gCAD1B,sBAAsB;kCAGpB,wBAAwB"}
@@ -84,7 +84,7 @@ export class UploaderBlock extends ActivityBlock {
84
84
  return this.api;
85
85
  }
86
86
 
87
- /** @returns {TypedCollection} */
87
+ /** @returns {TypedCollection<typeof uploadEntrySchema>} */
88
88
  get uploadCollection() {
89
89
  if (!this.has('*uploadCollection')) {
90
90
  throw new Error('Unexpected error: TypedCollection is not initialized');
@@ -164,8 +164,7 @@ export class UploaderBlock extends ActivityBlock {
164
164
 
165
165
  /**
166
166
  * @private
167
- * @type {Parameters<import('./TypedCollection.js').TypedCollection['observeCollection']>[0]}
168
- * @param {Set<import('./TypedData.js').TypedData>} removed
167
+ * @type {import('./TypedCollection.js').TypedCollectionObserverHandler<typeof uploadEntrySchema>}
169
168
  */
170
169
  _handleCollectionUpdate = (entries, added, removed) => {
171
170
  if (added.size || removed.size) {
@@ -190,7 +189,8 @@ export class UploaderBlock extends ActivityBlock {
190
189
  isUploading: false,
191
190
  uploadProgress: 0,
192
191
  });
193
- URL.revokeObjectURL(entry?.getValue('thumbUrl'));
192
+ const thumbUrl = entry?.getValue('thumbUrl');
193
+ thumbUrl && URL.revokeObjectURL(thumbUrl);
194
194
  this.emit(EventType.FILE_REMOVED, this.api.getOutputItem(entry.uid));
195
195
  }
196
196
 
@@ -204,7 +204,7 @@ export class UploaderBlock extends ActivityBlock {
204
204
 
205
205
  /**
206
206
  * @private
207
- * @param {Record<keyof import('./uploadEntrySchema.js').UploadEntry, Set<string>>} changeMap
207
+ * @param {Record<keyof import('./uploadEntrySchema.js').UploadEntryData, Set<string>>} changeMap
208
208
  */
209
209
  _handleCollectionPropertiesUpdate = (changeMap) => {
210
210
  this._flushOutputItems();
@@ -309,7 +309,9 @@ export class UploaderBlock extends ActivityBlock {
309
309
  const items = [...uploadTrigger].filter((id) => !!this.uploadCollection.read(id));
310
310
  items.forEach((id) => {
311
311
  const uploadProgress = this.uploadCollection.readProp(id, 'uploadProgress');
312
- commonProgress += uploadProgress;
312
+ if (typeof uploadProgress === 'number') {
313
+ commonProgress += uploadProgress;
314
+ }
313
315
  });
314
316
  const progress = items.length ? Math.round(commonProgress / items.length) : 0;
315
317
 
@@ -326,7 +328,7 @@ export class UploaderBlock extends ActivityBlock {
326
328
 
327
329
  openCloudImageEditor() {
328
330
  const [entry] = this.uploadCollection
329
- .findItems((entry) => entry.getValue('fileInfo') && entry.getValue('isImage'))
331
+ .findItems((entry) => !!entry.getValue('fileInfo') && entry.getValue('isImage'))
330
332
  .map((id) => this.uploadCollection.read(id));
331
333
 
332
334
  if (
@@ -352,14 +354,19 @@ export class UploaderBlock extends ActivityBlock {
352
354
  const entries = this.uploadCollection
353
355
  .findItems(
354
356
  (entry) =>
355
- entry.getValue('fileInfo') &&
357
+ !!entry.getValue('fileInfo') &&
356
358
  entry.getValue('isImage') &&
357
359
  !entry.getValue('cdnUrlModifiers')?.includes('/crop/'),
358
360
  )
359
- .map((id) => this.uploadCollection.read(id));
361
+ .map((id) => this.uploadCollection.read(id))
362
+ .filter(Boolean);
360
363
 
361
364
  for (const entry of entries) {
362
365
  const fileInfo = entry.getValue('fileInfo');
366
+ if (!fileInfo || !fileInfo.imageInfo) {
367
+ console.warn('Failed to get image info for entry', entry.uid);
368
+ continue;
369
+ }
363
370
  const { width, height } = fileInfo.imageInfo;
364
371
  const expectedAspectRatio = aspectRatioPreset.width / aspectRatioPreset.height;
365
372
  const crop = calculateMaxCenteredCropFrame(width, height, expectedAspectRatio);
@@ -367,9 +374,14 @@ export class UploaderBlock extends ActivityBlock {
367
374
  `crop/${crop.width}x${crop.height}/${crop.x},${crop.y}`,
368
375
  'preview',
369
376
  );
377
+ const cdnUrl = entry.getValue('cdnUrl');
378
+ if (!cdnUrl) {
379
+ console.warn('Failed to get cdnUrl for entry', entry.uid);
380
+ continue;
381
+ }
370
382
  entry.setMultipleValues({
371
383
  cdnUrlModifiers,
372
- cdnUrl: createCdnUrl(entry.getValue('cdnUrl'), cdnUrlModifiers),
384
+ cdnUrl: createCdnUrl(cdnUrl, cdnUrlModifiers),
373
385
  });
374
386
  if (
375
387
  this.uploadCollection.size === 1 &&