@uploadcare/file-uploader 1.1.1 → 1.3.0-alpha.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 (231) hide show
  1. package/README.md +7 -7
  2. package/abstract/ActivityBlock.d.ts +1 -1
  3. package/abstract/ActivityBlock.d.ts.map +1 -1
  4. package/abstract/ActivityBlock.js +2 -0
  5. package/abstract/Block.d.ts +6 -11
  6. package/abstract/Block.d.ts.map +1 -1
  7. package/abstract/Block.js +37 -18
  8. package/abstract/CTX.d.ts +6 -6
  9. package/abstract/CTX.d.ts.map +1 -1
  10. package/abstract/LocaleManager.d.ts +3 -3
  11. package/abstract/SecureUploadsManager.d.ts +2 -2
  12. package/abstract/SecureUploadsManager.d.ts.map +1 -1
  13. package/abstract/SolutionBlock.d.ts +2 -2
  14. package/abstract/SolutionBlock.d.ts.map +1 -1
  15. package/abstract/TypedCollection.d.ts +1 -1
  16. package/abstract/TypedCollection.d.ts.map +1 -1
  17. package/abstract/TypedCollection.js +4 -4
  18. package/abstract/TypedData.d.ts +2 -2
  19. package/abstract/TypedData.d.ts.map +1 -1
  20. package/abstract/TypedData.js +4 -4
  21. package/abstract/UploaderBlock.d.ts +5 -5
  22. package/abstract/UploaderBlock.d.ts.map +1 -1
  23. package/abstract/UploaderBlock.js +5 -5
  24. package/abstract/UploaderPublicApi.d.ts +22 -21
  25. package/abstract/UploaderPublicApi.d.ts.map +1 -1
  26. package/abstract/UploaderPublicApi.js +3 -3
  27. package/abstract/ValidationManager.d.ts +3 -3
  28. package/abstract/ValidationManager.d.ts.map +1 -1
  29. package/abstract/a11y.d.ts +2 -2
  30. package/abstract/a11y.d.ts.map +1 -1
  31. package/abstract/bindCompatibilityFallbackProcessor.d.ts +3 -0
  32. package/abstract/bindCompatibilityFallbackProcessor.d.ts.map +1 -0
  33. package/abstract/bindCompatibilityFallbackProcessor.js +16 -0
  34. package/abstract/buildOutputCollectionState.d.ts +1 -1
  35. package/abstract/buildOutputCollectionState.d.ts.map +1 -1
  36. package/abstract/defineComponents.d.ts +5 -0
  37. package/abstract/defineComponents.d.ts.map +1 -0
  38. package/abstract/{registerBlocks.js → defineComponents.js} +6 -1
  39. package/abstract/l10nProcessor.d.ts.map +1 -1
  40. package/abstract/l10nProcessor.js +3 -3
  41. package/abstract/loadFileUploaderFrom.d.ts +8 -0
  42. package/abstract/loadFileUploaderFrom.d.ts.map +1 -0
  43. package/abstract/{connectBlocksFrom.js → loadFileUploaderFrom.js} +4 -4
  44. package/abstract/localeRegistry.d.ts.map +1 -1
  45. package/abstract/sharedConfigKey.d.ts.map +1 -1
  46. package/abstract/uploadEntrySchema.d.ts +2 -2
  47. package/abstract/uploadEntrySchema.d.ts.map +1 -1
  48. package/abstract/uploadEntrySchema.js +1 -1
  49. package/blocks/CameraSource/CameraSource.d.ts.map +1 -1
  50. package/blocks/CameraSource/CameraSource.js +12 -11
  51. package/blocks/CloudImageEditor/src/CloudImageEditorBlock.d.ts.map +1 -1
  52. package/blocks/CloudImageEditor/src/CropFrame.d.ts +11 -11
  53. package/blocks/CloudImageEditor/src/CropFrame.d.ts.map +1 -1
  54. package/blocks/CloudImageEditor/src/CropFrame.js +2 -1
  55. package/blocks/CloudImageEditor/src/EditorButtonControl.d.ts.map +1 -1
  56. package/blocks/CloudImageEditor/src/EditorButtonControl.js +3 -2
  57. package/blocks/CloudImageEditor/src/EditorCropButtonControl.js +1 -1
  58. package/blocks/CloudImageEditor/src/EditorFilterControl.d.ts.map +1 -1
  59. package/blocks/CloudImageEditor/src/EditorFilterControl.js +4 -3
  60. package/blocks/CloudImageEditor/src/EditorImageCropper.d.ts +3 -3
  61. package/blocks/CloudImageEditor/src/EditorImageCropper.js +2 -2
  62. package/blocks/CloudImageEditor/src/EditorImageFader.d.ts +1 -1
  63. package/blocks/CloudImageEditor/src/EditorImageFader.d.ts.map +1 -1
  64. package/blocks/CloudImageEditor/src/EditorOperationControl.js +1 -1
  65. package/blocks/CloudImageEditor/src/EditorScroller.d.ts.map +1 -1
  66. package/blocks/CloudImageEditor/src/EditorScroller.js +2 -1
  67. package/blocks/CloudImageEditor/src/EditorSlider.d.ts.map +1 -1
  68. package/blocks/CloudImageEditor/src/EditorSlider.js +3 -2
  69. package/blocks/CloudImageEditor/src/EditorToolbar.d.ts +1 -1
  70. package/blocks/CloudImageEditor/src/EditorToolbar.d.ts.map +1 -1
  71. package/blocks/CloudImageEditor/src/EditorToolbar.js +15 -14
  72. package/blocks/CloudImageEditor/src/crop-utils.d.ts +14 -14
  73. package/blocks/CloudImageEditor/src/crop-utils.d.ts.map +1 -1
  74. package/blocks/CloudImageEditor/src/elements/button/BtnUi.d.ts.map +1 -1
  75. package/blocks/CloudImageEditor/src/elements/button/BtnUi.js +5 -5
  76. package/blocks/CloudImageEditor/src/elements/line-loader/LineLoaderUi.d.ts.map +1 -1
  77. package/blocks/CloudImageEditor/src/elements/line-loader/LineLoaderUi.js +2 -1
  78. package/blocks/CloudImageEditor/src/elements/presence-toggle/PresenceToggle.d.ts.map +1 -1
  79. package/blocks/CloudImageEditor/src/elements/presence-toggle/PresenceToggle.js +3 -2
  80. package/blocks/CloudImageEditor/src/elements/slider/SliderUi.d.ts.map +1 -1
  81. package/blocks/CloudImageEditor/src/elements/slider/SliderUi.js +3 -2
  82. package/blocks/CloudImageEditor/src/lib/parseCropPreset.d.ts +1 -1
  83. package/blocks/CloudImageEditor/src/lib/transformationUtils.d.ts +3 -3
  84. package/blocks/CloudImageEditor/src/lib/transformationUtils.d.ts.map +1 -1
  85. package/blocks/CloudImageEditor/src/state.d.ts +4 -4
  86. package/blocks/CloudImageEditor/src/svg-sprite.d.ts +1 -1
  87. package/blocks/CloudImageEditor/src/svg-sprite.js +1 -1
  88. package/blocks/CloudImageEditor/src/template.d.ts.map +1 -1
  89. package/blocks/CloudImageEditor/src/template.js +5 -4
  90. package/blocks/CloudImageEditor/src/types.d.ts +2 -2
  91. package/blocks/CloudImageEditor/src/types.d.ts.map +1 -1
  92. package/blocks/CloudImageEditorActivity/CloudImageEditorActivity.d.ts +3 -3
  93. package/blocks/CloudImageEditorActivity/CloudImageEditorActivity.d.ts.map +1 -1
  94. package/blocks/CloudImageEditorActivity/CloudImageEditorActivity.js +2 -1
  95. package/blocks/CloudImageEditorActivity/test.js +1 -1
  96. package/blocks/Config/Config.d.ts +3 -11
  97. package/blocks/Config/Config.d.ts.map +1 -1
  98. package/blocks/Config/initialConfig.d.ts +1 -1
  99. package/blocks/Config/normalizeConfigValue.d.ts.map +1 -1
  100. package/blocks/Copyright/Copyright.d.ts.map +1 -1
  101. package/blocks/Copyright/Copyright.js +2 -1
  102. package/blocks/DropArea/DropArea.d.ts +2 -2
  103. package/blocks/DropArea/DropArea.d.ts.map +1 -1
  104. package/blocks/DropArea/DropArea.js +5 -5
  105. package/blocks/DropArea/addDropzone.d.ts.map +1 -1
  106. package/blocks/DropArea/getDropItems.d.ts +2 -2
  107. package/blocks/DropArea/getDropItems.d.ts.map +1 -1
  108. package/blocks/ExternalSource/ExternalSource.d.ts +5 -5
  109. package/blocks/ExternalSource/ExternalSource.d.ts.map +1 -1
  110. package/blocks/ExternalSource/ExternalSource.js +9 -9
  111. package/blocks/ExternalSource/buildStyles.js +2 -2
  112. package/blocks/ExternalSource/query-string.d.ts.map +1 -1
  113. package/blocks/FileItem/FileItem.d.ts +3 -3
  114. package/blocks/FileItem/FileItem.d.ts.map +1 -1
  115. package/blocks/FileItem/FileItem.js +12 -11
  116. package/blocks/Icon/Icon.d.ts.map +1 -1
  117. package/blocks/Icon/Icon.js +3 -2
  118. package/blocks/Img/ImgBase.js +9 -9
  119. package/blocks/Img/ImgConfig.d.ts +2 -2
  120. package/blocks/Img/ImgConfig.d.ts.map +1 -1
  121. package/blocks/Img/ImgConfig.js +3 -3
  122. package/blocks/Img/utils/parseObjectToString.js +1 -1
  123. package/blocks/Modal/Modal.d.ts.map +1 -1
  124. package/blocks/Modal/Modal.js +2 -1
  125. package/blocks/ProgressBar/ProgressBar.d.ts.map +1 -1
  126. package/blocks/ProgressBar/ProgressBar.js +2 -1
  127. package/blocks/ProgressBarCommon/ProgressBarCommon.d.ts.map +1 -1
  128. package/blocks/ProgressBarCommon/ProgressBarCommon.js +2 -1
  129. package/blocks/Select/Select.d.ts.map +1 -1
  130. package/blocks/Select/Select.js +14 -9
  131. package/blocks/SimpleBtn/SimpleBtn.d.ts +2 -2
  132. package/blocks/SimpleBtn/SimpleBtn.d.ts.map +1 -1
  133. package/blocks/SimpleBtn/SimpleBtn.js +4 -3
  134. package/blocks/SourceBtn/SourceBtn.d.ts +2 -2
  135. package/blocks/SourceBtn/SourceBtn.d.ts.map +1 -1
  136. package/blocks/SourceBtn/SourceBtn.js +4 -4
  137. package/blocks/SourceList/SourceList.d.ts.map +1 -1
  138. package/blocks/SourceList/SourceList.js +5 -4
  139. package/blocks/StartFrom/StartFrom.d.ts.map +1 -1
  140. package/blocks/StartFrom/StartFrom.js +2 -1
  141. package/blocks/UploadCtxProvider/EventEmitter.d.ts +19 -19
  142. package/blocks/UploadCtxProvider/EventEmitter.d.ts.map +1 -1
  143. package/blocks/UploadCtxProvider/UploadCtxProvider.d.ts +4 -4
  144. package/blocks/UploadCtxProvider/UploadCtxProvider.d.ts.map +1 -1
  145. package/blocks/UploadList/UploadList.d.ts +2 -2
  146. package/blocks/UploadList/UploadList.d.ts.map +1 -1
  147. package/blocks/UploadList/UploadList.js +10 -11
  148. package/blocks/UrlSource/UrlSource.d.ts.map +1 -1
  149. package/blocks/UrlSource/UrlSource.js +7 -6
  150. package/blocks/themes/uc-basic/index.css +0 -1
  151. package/blocks/themes/uc-basic/svg-sprite.d.ts +1 -1
  152. package/blocks/themes/uc-basic/svg-sprite.js +1 -1
  153. package/blocks/utils/debounce.d.ts +3 -1
  154. package/blocks/utils/debounce.d.ts.map +1 -1
  155. package/blocks/utils/throttle.d.ts +3 -1
  156. package/blocks/utils/throttle.d.ts.map +1 -1
  157. package/blocks/utils/userAgent.d.ts +1 -1
  158. package/blocks/utils/userAgent.d.ts.map +1 -1
  159. package/env.d.ts +1 -1
  160. package/env.js +1 -1
  161. package/index.d.ts +3 -3
  162. package/index.js +3 -3
  163. package/index.ssr.d.ts +118 -4
  164. package/index.ssr.d.ts.map +1 -1
  165. package/index.ssr.js +193 -81
  166. package/package.json +10 -8
  167. package/solutions/cloud-image-editor/index.d.ts +1 -1
  168. package/solutions/cloud-image-editor/index.js +1 -1
  169. package/solutions/file-uploader/inline/FileUploaderInline.d.ts +2 -2
  170. package/solutions/file-uploader/inline/FileUploaderInline.d.ts.map +1 -1
  171. package/solutions/file-uploader/inline/FileUploaderInline.js +3 -2
  172. package/solutions/file-uploader/minimal/FileUploaderMinimal.d.ts.map +1 -1
  173. package/solutions/file-uploader/minimal/FileUploaderMinimal.js +2 -1
  174. package/solutions/file-uploader/minimal/index.d.ts +1 -1
  175. package/solutions/file-uploader/minimal/index.js +1 -1
  176. package/solutions/file-uploader/regular/FileUploaderRegular.d.ts +2 -2
  177. package/solutions/file-uploader/regular/FileUploaderRegular.d.ts.map +1 -1
  178. package/solutions/file-uploader/regular/FileUploaderRegular.js +4 -3
  179. package/types/global.d.ts +1 -1
  180. package/types/jsx.d.ts +1 -1
  181. package/utils/getPluralForm.d.ts.map +1 -1
  182. package/utils/isSecureTokenExpired.d.ts +1 -1
  183. package/utils/memoize.d.ts.map +1 -1
  184. package/utils/mixinClass.d.ts +3 -1
  185. package/utils/mixinClass.d.ts.map +1 -1
  186. package/utils/prettyBytes.d.ts.map +1 -1
  187. package/utils/template-utils.d.ts.map +1 -1
  188. package/utils/toKebabCase.d.ts.map +1 -1
  189. package/utils/uniqueArray.d.ts.map +1 -1
  190. package/utils/validators/collection/validateCollectionUploadError.d.ts +1 -1
  191. package/utils/validators/collection/validateMultiple.d.ts +1 -1
  192. package/utils/validators/file/validateFileType.d.ts +1 -1
  193. package/utils/validators/file/validateIsImage.d.ts +1 -1
  194. package/utils/validators/file/validateMaxSizeLimit.d.ts +1 -1
  195. package/utils/validators/file/validateUploadError.d.ts +1 -1
  196. package/utils/waitForAttribute.d.ts +12 -6
  197. package/utils/waitForAttribute.d.ts.map +1 -1
  198. package/utils/waitForAttribute.js +38 -8
  199. package/utils/waitForAttribute.test.js +10 -47
  200. package/utils/withResolvers.d.ts +7 -0
  201. package/utils/withResolvers.d.ts.map +1 -0
  202. package/utils/withResolvers.js +17 -0
  203. package/utils/withResolvers.test.d.ts +2 -0
  204. package/utils/withResolvers.test.d.ts.map +1 -0
  205. package/utils/withResolvers.test.js +27 -0
  206. package/web/file-uploader.iife.min.js +29 -0
  207. package/web/file-uploader.min.js +29 -0
  208. package/web/uc-basic.min.css +1 -1
  209. package/web/uc-cloud-image-editor.min.js +4 -4
  210. package/web/uc-file-uploader-inline.min.css +1 -1
  211. package/web/uc-file-uploader-inline.min.js +4 -4
  212. package/web/uc-file-uploader-minimal.min.js +3 -3
  213. package/web/uc-file-uploader-regular.min.css +1 -1
  214. package/web/uc-file-uploader-regular.min.js +4 -4
  215. package/web/uc-img.min.js +3 -3
  216. package/abstract/connectBlocksFrom.d.ts +0 -8
  217. package/abstract/connectBlocksFrom.d.ts.map +0 -1
  218. package/abstract/registerBlocks.d.ts +0 -5
  219. package/abstract/registerBlocks.d.ts.map +0 -1
  220. package/blocks/CloudImageEditor/src/lib/FocusVisible.d.ts +0 -15
  221. package/blocks/CloudImageEditor/src/lib/FocusVisible.d.ts.map +0 -1
  222. package/blocks/CloudImageEditor/src/lib/FocusVisible.js +0 -33
  223. package/blocks/CloudImageEditor/src/lib/applyFocusVisiblePolyfill.d.ts +0 -10
  224. package/blocks/CloudImageEditor/src/lib/applyFocusVisiblePolyfill.d.ts.map +0 -1
  225. package/blocks/CloudImageEditor/src/lib/applyFocusVisiblePolyfill.js +0 -256
  226. package/blocks/Range/Range.d.ts +0 -16
  227. package/blocks/Range/Range.d.ts.map +0 -1
  228. package/blocks/Range/Range.js +0 -44
  229. package/blocks/Range/range.css +0 -65
  230. package/web/blocks.iife.min.js +0 -29
  231. package/web/blocks.min.js +0 -29
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uploadcare/file-uploader",
3
- "version": "1.1.1",
3
+ "version": "1.3.0-alpha.0",
4
4
  "description": "Building blocks for Uploadcare products integration",
5
5
  "keywords": [
6
6
  "web components",
@@ -43,7 +43,7 @@
43
43
  "browser": "./index.js",
44
44
  "default": "./index.js"
45
45
  },
46
- "./abstract/connectBlocksFrom.js": "./abstract/connectBlocksFrom.js",
46
+ "./abstract/loadFileUploaderFrom.js": "./abstract/loadFileUploaderFrom.js",
47
47
  "./env": "./env.js",
48
48
  "./web/*": "./web/*",
49
49
  "./types/*": "./types/*",
@@ -99,12 +99,12 @@
99
99
  "@happy-dom/global-registrator": "^9.8.4",
100
100
  "@jam-do/jam-tools": "^0.0.4",
101
101
  "@total-typescript/ts-reset": "^0.5.1",
102
- "@types/chai": "^4.3.4",
102
+ "@types/chai": "^4.3.17",
103
103
  "@types/mocha": "^10.0.1",
104
104
  "@types/node": "^18.15.11",
105
105
  "@types/react": "^18.2.34",
106
- "@web/dev-server": "^0.1.38",
107
- "@web/test-runner": "^0.15.3",
106
+ "@web/dev-server": "^0.4.6",
107
+ "@web/test-runner": "^0.18.2",
108
108
  "esbuild": "^0.19.9",
109
109
  "eslint": "^8.56.0",
110
110
  "eslint-config-prettier": "^9.1.0",
@@ -128,15 +128,17 @@
128
128
  "stylelint-declaration-block-no-ignored-properties": "^2.7.0",
129
129
  "stylelint-order": "^6.0.3",
130
130
  "svg-sprite": "^2.0.4",
131
- "tsd": "^0.29.0",
132
- "typescript": "^5.2.2"
131
+ "tsd": "^0.31.1",
132
+ "typescript": "^5.5.4"
133
133
  },
134
134
  "author": "Uploadcare Inc.",
135
135
  "license": "MIT",
136
136
  "dependencies": {
137
- "@symbiotejs/symbiote": "^1.11.7",
137
+ "@symbiotejs/symbiote": "^2.3.0",
138
+ "@types/sinon": "^17.0.3",
138
139
  "@uploadcare/image-shrink": "^6.14.1",
139
140
  "@uploadcare/upload-client": "^6.14.1",
141
+ "D": "^1.0.0",
140
142
  "keyux": "^0.7.1"
141
143
  }
142
144
  }
@@ -1,6 +1,6 @@
1
1
  export * from "../../blocks/CloudImageEditor/index.js";
2
2
  export * from "./CloudImageEditor.js";
3
3
  export { Icon } from "../../blocks/Icon/Icon.js";
4
- export { registerBlocks } from "../../abstract/registerBlocks.js";
4
+ export { defineComponents } from "../../abstract/defineComponents.js";
5
5
  export { Config } from "../../blocks/Config/Config.js";
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -7,5 +7,5 @@ Then we can check whether the dependent tag is registered in the CustomElementRe
7
7
  If not, register it from default ones or just log the warning */
8
8
 
9
9
  export { Icon } from '../../blocks/Icon/Icon.js';
10
- export { registerBlocks } from '../../abstract/registerBlocks.js';
10
+ export { defineComponents } from '../../abstract/defineComponents.js';
11
11
  export { Config } from '../../blocks/Config/Config.js';
@@ -6,8 +6,8 @@ export class FileUploaderInline extends SolutionBlock {
6
6
  '*uploadList': never[];
7
7
  '*focusedEntry': null;
8
8
  '*uploadQueue': import("@uploadcare/upload-client").Queue;
9
- '*collectionErrors': any[];
10
- '*collectionState': import("./index.js").OutputCollectionState<import("./index.js").OutputCollectionStatus, "maybe-has-group"> | null;
9
+ '*collectionErrors': ReturnType<import("./index.js").OutputErrorCollection>[];
10
+ '*collectionState': import("./index.js").OutputCollectionState | null;
11
11
  '*groupInfo': import("@uploadcare/upload-client").UploadcareGroup | null;
12
12
  '*uploadTrigger': Set<string>;
13
13
  '*secureUploadsManager': import("../../../abstract/SecureUploadsManager.js").SecureUploadsManager | null;
@@ -1 +1 @@
1
- {"version":3,"file":"FileUploaderInline.d.ts","sourceRoot":"","sources":["FileUploaderInline.js"],"names":[],"mappings":"AAIA;IAMI;;;;;;;;;;;;;;;;;MAUC;IAGH,gCAGC;IAED,6BAEC;CA0BF;;;;8BAtD6B,oCAAoC"}
1
+ {"version":3,"file":"FileUploaderInline.d.ts","sourceRoot":"","sources":["FileUploaderInline.js"],"names":[],"mappings":"AAKA;IAMI;;;;;;;+CAamB,YACjB;mCACsC,YAAU;6BAIhD,2BAA2B;;wCAMS,2CAA2B;;;;;;MAfhE;IAGH,gCAGC;IAED,6BAEC;CA0BF;;;;8BAtD6B,oCAAoC"}
@@ -1,4 +1,5 @@
1
1
  // @ts-check
2
+ import { html } from '@symbiotejs/symbiote';
2
3
  import { ActivityBlock } from '../../../abstract/ActivityBlock.js';
3
4
  import { SolutionBlock } from '../../../abstract/SolutionBlock.js';
4
5
 
@@ -56,14 +57,14 @@ export class FileUploaderInline extends SolutionBlock {
56
57
  }
57
58
  }
58
59
 
59
- FileUploaderInline.template = /* HTML */ ` <uc-start-from>
60
+ FileUploaderInline.template = html` <uc-start-from>
60
61
  <uc-drop-area with-icon clickable></uc-drop-area>
61
62
  <uc-source-list wrap></uc-source-list>
62
63
  <button
63
64
  type="button"
64
65
  l10n="start-from-cancel"
65
66
  class="uc-cancel-btn uc-secondary-btn"
66
- set="onclick: cancel; @hidden: !couldCancel"
67
+ bind="onclick: cancel; @hidden: !couldCancel"
67
68
  ></button>
68
69
  <uc-copyright></uc-copyright>
69
70
  </uc-start-from>
@@ -1 +1 @@
1
- {"version":3,"file":"FileUploaderMinimal.d.ts","sourceRoot":"","sources":["FileUploaderMinimal.js"],"names":[],"mappings":"AAGA;CAkCC;;;;8BApC6B,oCAAoC"}
1
+ {"version":3,"file":"FileUploaderMinimal.d.ts","sourceRoot":"","sources":["FileUploaderMinimal.js"],"names":[],"mappings":"AAIA;CAkCC;;;;8BApC6B,oCAAoC"}
@@ -1,3 +1,4 @@
1
+ import { html } from '@symbiotejs/symbiote';
1
2
  import { ActivityBlock } from '../../../abstract/ActivityBlock.js';
2
3
  import { SolutionBlock } from '../../../abstract/SolutionBlock.js';
3
4
 
@@ -37,7 +38,7 @@ export class FileUploaderMinimal extends SolutionBlock {
37
38
  }
38
39
  }
39
40
 
40
- FileUploaderMinimal.template = /* HTML */ `
41
+ FileUploaderMinimal.template = html`
41
42
  <uc-start-from>
42
43
  <uc-drop-area tabindex="0" clickable l10n="choose-file"></uc-drop-area>
43
44
  <uc-copyright></uc-copyright>
@@ -1,4 +1,4 @@
1
- export { registerBlocks } from "../../../abstract/registerBlocks.js";
1
+ export { defineComponents } from "../../../abstract/defineComponents.js";
2
2
  export { defineLocale } from "../../../abstract/localeRegistry.js";
3
3
  export { FileUploaderMinimal } from "./FileUploaderMinimal.js";
4
4
  export { StartFrom } from "../../../blocks/StartFrom/StartFrom.js";
@@ -1,4 +1,4 @@
1
- export { registerBlocks } from '../../../abstract/registerBlocks.js';
1
+ export { defineComponents } from '../../../abstract/defineComponents.js';
2
2
  export { defineLocale } from '../../../abstract/localeRegistry.js';
3
3
  export { FileUploaderMinimal } from './FileUploaderMinimal.js';
4
4
  export { StartFrom } from '../../../blocks/StartFrom/StartFrom.js';
@@ -5,8 +5,8 @@ export class FileUploaderRegular extends SolutionBlock {
5
5
  '*uploadList': never[];
6
6
  '*focusedEntry': null;
7
7
  '*uploadQueue': import("@uploadcare/upload-client").Queue;
8
- '*collectionErrors': any[];
9
- '*collectionState': import("./index.js").OutputCollectionState<import("./index.js").OutputCollectionStatus, "maybe-has-group"> | null;
8
+ '*collectionErrors': ReturnType<import("./index.js").OutputErrorCollection>[];
9
+ '*collectionState': import("./index.js").OutputCollectionState | null;
10
10
  '*groupInfo': import("@uploadcare/upload-client").UploadcareGroup | null;
11
11
  '*uploadTrigger': Set<string>;
12
12
  '*secureUploadsManager': import("../../../abstract/SecureUploadsManager.js").SecureUploadsManager | null;
@@ -1 +1 @@
1
- {"version":3,"file":"FileUploaderRegular.d.ts","sourceRoot":"","sources":["FileUploaderRegular.js"],"names":[],"mappings":"AAKA;IAMI;;;;;;;;;;;;;;;;MAGC;IAoBG,eAAe;IACf,yBAAmC;CAK1C;;;;8BAvC6B,oCAAoC"}
1
+ {"version":3,"file":"FileUploaderRegular.d.ts","sourceRoot":"","sources":["FileUploaderRegular.js"],"names":[],"mappings":"AAMA;IAMI;;;;;;+CAY2B,YAAU;mCAM1B,YACf;6BAC8B,2BAA2B;;wCAIhB,2CAGxC;;;;;;MAxBI;IAoBG,eAAe;IACf,yBAAmC;CAK1C;;;;8BAvC6B,oCAAoC"}
@@ -1,4 +1,5 @@
1
1
  // @ts-check
2
+ import { html } from '@symbiotejs/symbiote';
2
3
  import { SolutionBlock } from '../../../abstract/SolutionBlock.js';
3
4
  import { asBoolean } from '../../../blocks/Config/normalizeConfigValue.js';
4
5
  import { EventType } from '../../../blocks/UploadCtxProvider/EventEmitter.js';
@@ -40,14 +41,14 @@ export class FileUploaderRegular extends SolutionBlock {
40
41
  }
41
42
  }
42
43
 
43
- FileUploaderRegular.template = /* HTML */ `
44
- <uc-simple-btn set="@hidden: isHidden"></uc-simple-btn>
44
+ FileUploaderRegular.template = html`
45
+ <uc-simple-btn bind="@hidden: isHidden"></uc-simple-btn>
45
46
 
46
47
  <uc-modal strokes block-body-scrolling>
47
48
  <uc-start-from>
48
49
  <uc-drop-area with-icon clickable></uc-drop-area>
49
50
  <uc-source-list wrap></uc-source-list>
50
- <button type="button" l10n="start-from-cancel" class="uc-secondary-btn" set="onclick: *historyBack"></button>
51
+ <button type="button" l10n="start-from-cancel" class="uc-secondary-btn" bind="onclick: *historyBack"></button>
51
52
  <uc-copyright></uc-copyright>
52
53
  </uc-start-from>
53
54
  <uc-upload-list></uc-upload-list>
package/types/global.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { UC_WINDOW_KEY } from '../abstract/connectBlocksFrom.js';
1
+ import { UC_WINDOW_KEY } from '../abstract/loadFileUploaderFrom.js';
2
2
  import * as blocks from '../index.js';
3
3
 
4
4
  declare global {
package/types/jsx.d.ts CHANGED
@@ -9,7 +9,7 @@ type FileUploaderMinimal = import('../index.js').FileUploaderMinimal;
9
9
  type FormInput = import('../index.js').FormInput;
10
10
  type CloudImageEditorBlock = import('../index.js').CloudImageEditorBlock;
11
11
  type CtxAttributes = {
12
- 'ctx-name': string;
12
+ ctx: string;
13
13
  };
14
14
  type CommonHtmlAttributes<T> = Partial<
15
15
  Pick<React.HTMLAttributes<T>, 'id' | 'children' | 'hidden'> & { class: React.HTMLAttributes<T>['className'] }
@@ -1 +1 @@
1
- {"version":3,"file":"getPluralForm.d.ts","sourceRoot":"","sources":["getPluralForm.js"],"names":[],"mappings":"AASO,sCAJI,MAAM,SACN,MAAM,GACJ,UAAU,CAKtB;yBAVa,KAAK,cAAc"}
1
+ {"version":3,"file":"getPluralForm.d.ts","sourceRoot":"","sources":["getPluralForm.js"],"names":[],"mappings":"AASO,sCAJI,MAAM,SACN,MAAM,GACJ,UAAU,CAKtB;yBAVa,IAAI,CAAC,cAAc"}
@@ -1,4 +1,4 @@
1
- export function isSecureTokenExpired(secureToken: import('../types').SecureUploadsSignatureAndExpire, { threshold }: {
1
+ export function isSecureTokenExpired(secureToken: import("../types").SecureUploadsSignatureAndExpire, { threshold }: {
2
2
  threshold?: number;
3
3
  }): boolean;
4
4
  //# sourceMappingURL=isSecureTokenExpired.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"memoize.d.ts","sourceRoot":"","sources":["memoize.js"],"names":[],"mappings":"AASO,uHAaN"}
1
+ {"version":3,"file":"memoize.d.ts","sourceRoot":"","sources":["memoize.js"],"names":[],"mappings":"AASO,wBANc,KAAK,SAAZ,GAAG,EAAG,EACD,OAAO,kBACiB,CAAC,SAA/B,CAAE,GAAG,IAAI,EAAE,KAAK,KAAK,OAAQ,MAC/B,CAAC,GACC,CAAC,CAeb"}
@@ -4,5 +4,7 @@ export type GConstructor<T> = new (...args: any[]) => T;
4
4
  * are some dynamic generated properties or native overrides in the class. We're use it to define dynamic access
5
5
  * properties and events to subscribe to.
6
6
  */
7
- export type MixinClass<Base extends GConstructor<HTMLElement>, InstanceProperties extends Record<string, any> = {}> = (new (...args: ConstructorParameters<Base>) => InstanceProperties & InstanceType<Base>) & Omit<Base, "new">;
7
+ export type MixinClass<Base extends GConstructor<HTMLElement>, InstanceProperties extends Record<string, any> = {}> = {
8
+ new (...args: ConstructorParameters<Base>): InstanceProperties & InstanceType<Base>;
9
+ } & Omit<Base, "new">;
8
10
  //# sourceMappingURL=mixinClass.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mixinClass.d.ts","sourceRoot":"","sources":["mixinClass.js"],"names":[],"mappings":"4CAE2B,GAAG,EAAE,KAAK,CAAC;;;;;;qIAWnB,sBAAsB,IAAI,CAAC,KAAG,kBAAkB,GAAG,aAAa,IAAI,CAAC"}
1
+ {"version":3,"file":"mixinClass.d.ts","sourceRoot":"","sources":["mixinClass.js"],"names":[],"mappings":"yBACa,CAAC,IACD,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC;;;;;;uBAQG,IAAI,SAA/B,YAAY,CAAC,WAAW,CAAE,EACJ,kBAAkB,SAAxC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAE,SACrB;IACZ,KAAS,GAAG,IAAI,EAAE,qBAAqB,CAAC,IAAI,CAAC,GAAG,kBAAkB,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;CACrF,GAAG,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"prettyBytes.d.ts","sourceRoot":"","sources":["prettyBytes.js"],"names":[],"mappings":"AAKA;;;;;;;;GAQG;AAiBI,mCAJI,MAAM,SACN,CAAC,mBAAmB,CAAC,CAAC,MAAM,mBAAmB,CAAC,GAC9C,MAAM,CAmClB"}
1
+ {"version":3,"file":"prettyBytes.d.ts","sourceRoot":"","sources":["prettyBytes.js"],"names":[],"mappings":"AAKA;;;;;;;;GAQG;AAiBI,mCAJI,MAAM,SACN,CAAC,OAAO,YAAY,EAAE,MAAM,OAAO,YAAY,CAAC,GAC9C,MAAM,CAmClB"}
@@ -1 +1 @@
1
- {"version":3,"file":"template-utils.d.ts","sourceRoot":"","sources":["template-utils.js"],"names":[],"mappings":"AAOA;;;;;GAKG;AAEH;;;;;GAKG;AACH,yHAQC;AAED;;;GAGG;AACH,oDAFa;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,EAAE,CAiB5E"}
1
+ {"version":3,"file":"template-utils.d.ts","sourceRoot":"","sources":["template-utils.js"],"names":[],"mappings":"AAOA;;;;;GAKG;AAEH;;;;;GAKG;AACH,yHAQC;AAED;;;GAGG;AACH,oDAFa;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,EAAE,CAiB5E;;;;;;;;;;;;;;;wBAjDa;IAAE,CAAC,GAAG,QAAQ,GAAG,4BAA4B,SAAS,CAAA;CAAE"}
@@ -1 +1 @@
1
- {"version":3,"file":"toKebabCase.d.ts","sourceRoot":"","sources":["toKebabCase.js"],"names":[],"mappings":"AAUO,oEAIO"}
1
+ {"version":3,"file":"toKebabCase.d.ts","sourceRoot":"","sources":["toKebabCase.js"],"names":[],"mappings":"AAUO,4BAJe,CAAC,SAAV,MAAQ,OACV,CAAC,GACC,SAAS,CAAC,CAAC,CAAC,CAMX;sBAbQ,CAAC,SAAV,MAAQ,IACR,CAAC,SAAS,GAAG,MAAM,IAAI,IAAI,MAAM,IAAI,EAAE,GAAG,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC,IAAI,CAAC,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"uniqueArray.d.ts","sourceRoot":"","sources":["uniqueArray.js"],"names":[],"mappings":"AAKO,8CAEN"}
1
+ {"version":3,"file":"uniqueArray.d.ts","sourceRoot":"","sources":["uniqueArray.js"],"names":[],"mappings":"AAKO,4BAJM,CAAC,OACH,CAAC,EAAE,GACD,CAAC,EAAE,CAIf"}
@@ -1,3 +1,3 @@
1
1
  /** @type {import('../../../abstract/ValidationManager.js').FuncCollectionValidator} */
2
- export const validateCollectionUploadError: import('../../../abstract/ValidationManager.js').FuncCollectionValidator;
2
+ export const validateCollectionUploadError: import("../../../abstract/ValidationManager.js").FuncCollectionValidator;
3
3
  //# sourceMappingURL=validateCollectionUploadError.d.ts.map
@@ -1,3 +1,3 @@
1
1
  /** @type {import('../../../abstract/ValidationManager.js').FuncCollectionValidator} */
2
- export const validateMultiple: import('../../../abstract/ValidationManager.js').FuncCollectionValidator;
2
+ export const validateMultiple: import("../../../abstract/ValidationManager.js").FuncCollectionValidator;
3
3
  //# sourceMappingURL=validateMultiple.d.ts.map
@@ -1,3 +1,3 @@
1
1
  /** @type {import('../../../abstract/ValidationManager.js').FuncFileValidator} */
2
- export const validateFileType: import('../../../abstract/ValidationManager.js').FuncFileValidator;
2
+ export const validateFileType: import("../../../abstract/ValidationManager.js").FuncFileValidator;
3
3
  //# sourceMappingURL=validateFileType.d.ts.map
@@ -1,3 +1,3 @@
1
1
  /** @type {import('../../../abstract/ValidationManager.js').FuncFileValidator} */
2
- export const validateIsImage: import('../../../abstract/ValidationManager.js').FuncFileValidator;
2
+ export const validateIsImage: import("../../../abstract/ValidationManager.js").FuncFileValidator;
3
3
  //# sourceMappingURL=validateIsImage.d.ts.map
@@ -1,3 +1,3 @@
1
1
  /** @type {import('../../../abstract/ValidationManager.js').FuncFileValidator} */
2
- export const validateMaxSizeLimit: import('../../../abstract/ValidationManager.js').FuncFileValidator;
2
+ export const validateMaxSizeLimit: import("../../../abstract/ValidationManager.js").FuncFileValidator;
3
3
  //# sourceMappingURL=validateMaxSizeLimit.d.ts.map
@@ -1,3 +1,3 @@
1
1
  /** @type {import('../../../abstract/ValidationManager.js').FuncFileValidator} */
2
- export const validateUploadError: import('../../../abstract/ValidationManager.js').FuncFileValidator;
2
+ export const validateUploadError: import("../../../abstract/ValidationManager.js").FuncFileValidator;
3
3
  //# sourceMappingURL=validateUploadError.d.ts.map
@@ -1,8 +1,14 @@
1
- export function waitForAttribute({ element, attribute, onSuccess, onTimeout, timeout }: {
1
+ export function waitForAttribute<T extends string>({ element, attribute, timeout }: {
2
2
  element: HTMLElement;
3
- attribute: string;
4
- onSuccess: (value: string) => void;
5
- onTimeout: () => void;
6
- timeout?: number | undefined;
7
- }): void;
3
+ attribute: T;
4
+ timeout?: number;
5
+ }): Promise<ReturnType<T>>;
6
+ export type ReturnType<T extends string> = {
7
+ success: true;
8
+ attribute: T;
9
+ value: string;
10
+ } | {
11
+ success: false;
12
+ attribute: T;
13
+ };
8
14
  //# sourceMappingURL=waitForAttribute.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"waitForAttribute.d.ts","sourceRoot":"","sources":["waitForAttribute.js"],"names":[],"mappings":"AAWO;aAPO,WAAW;eACT,MAAM;uBACE,MAAM,KAAK,IAAI;eACvB,MAAM,IAAI;;SAmCzB"}
1
+ {"version":3,"file":"waitForAttribute.d.ts","sourceRoot":"","sources":["waitForAttribute.js"],"names":[],"mappings":"AA0BO,iCARe,CAAC,SAAV,MAAQ,mCACV;IACV,OAAW,EAAE,WAAW,CAAC;IACzB,SAAa,EAAE,CAAC,CAAC;IACjB,OAAW,CAAC,EAAE,MAAM,CAAC;CAClB,GACS,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAgDlC;uBAnEqB,CAAC,SAAV,MAAQ,IACR;IACZ,OAAe,EAAE,IAAI,CAAC;IACtB,SAAiB,EAAE,CAAC,CAAC;IACrB,KAAa,EAAE,MAAM,CAAC;CACf,GACD;IACN,OAAe,EAAE,KAAK,CAAC;IACvB,SAAiB,EAAE,CAAC,CAAC;CACd"}
@@ -1,19 +1,40 @@
1
1
  // @ts-check
2
2
 
3
+ import { withResolvers } from './withResolvers.js';
4
+
5
+ /**
6
+ * @template {string} T
7
+ * @typedef {{
8
+ * success: true;
9
+ * attribute: T;
10
+ * value: string;
11
+ * }
12
+ * | {
13
+ * success: false;
14
+ * attribute: T;
15
+ * }} ReturnType
16
+ */
17
+
3
18
  /**
19
+ * @template {string} T
4
20
  * @param {{
5
21
  * element: HTMLElement;
6
- * attribute: string;
7
- * onSuccess: (value: string) => void;
8
- * onTimeout: () => void;
22
+ * attribute: T;
9
23
  * timeout?: number;
10
24
  * }} options
25
+ * @returns {Promise<ReturnType<T>>}
11
26
  */
12
- export const waitForAttribute = ({ element, attribute, onSuccess, onTimeout, timeout = 300 }) => {
27
+ export const waitForAttribute = async ({ element, attribute, timeout = 300 }) => {
28
+ const { promise, resolve } = /** @type {typeof withResolvers<ReturnType<T>>} */ (withResolvers)();
29
+
13
30
  const currentAttrValue = element.getAttribute(attribute);
14
31
  if (currentAttrValue !== null) {
15
- onSuccess(currentAttrValue);
16
- return;
32
+ resolve({
33
+ success: true,
34
+ value: currentAttrValue,
35
+ attribute,
36
+ });
37
+ return promise;
17
38
  }
18
39
 
19
40
  const observer = new MutationObserver((mutations) => {
@@ -28,7 +49,10 @@ export const waitForAttribute = ({ element, attribute, onSuccess, onTimeout, tim
28
49
 
29
50
  const timeoutId = setTimeout(() => {
30
51
  observer.disconnect();
31
- onTimeout();
52
+ resolve({
53
+ success: false,
54
+ attribute,
55
+ });
32
56
  }, timeout);
33
57
 
34
58
  /** @param {MutationRecord} mutation */
@@ -37,7 +61,13 @@ export const waitForAttribute = ({ element, attribute, onSuccess, onTimeout, tim
37
61
  if (mutation.type === 'attributes' && mutation.attributeName === attribute && attrValue !== null) {
38
62
  clearTimeout(timeoutId);
39
63
  observer.disconnect();
40
- onSuccess(attrValue);
64
+ resolve({
65
+ success: true,
66
+ value: attrValue,
67
+ attribute,
68
+ });
41
69
  }
42
70
  };
71
+
72
+ return promise;
43
73
  };
@@ -1,78 +1,41 @@
1
+ // @ts-check
1
2
  import { expect } from '@esm-bundle/chai';
2
- import { spy } from 'sinon';
3
3
  import { delay } from './delay';
4
4
  import { waitForAttribute } from './waitForAttribute';
5
5
 
6
6
  const TEST_ATTRIBUTE = 'test-attribute';
7
7
 
8
8
  describe('waitForAttribute', () => {
9
- it('should call onTimeout callback when timeout is over', async () => {
9
+ it('should resolve success false when timeout is over', async () => {
10
10
  const element = document.createElement('div');
11
- const onSuccess = spy();
12
- const onTimeout = spy();
13
- waitForAttribute({
11
+ const promise = waitForAttribute({
14
12
  element,
15
13
  attribute: TEST_ATTRIBUTE,
16
- onSuccess,
17
- onTimeout,
18
14
  timeout: 10,
19
15
  });
20
16
  await delay(100);
21
- expect(onSuccess.called).to.be.false;
22
- expect(onTimeout.calledOnce).to.be.true;
17
+ expect(await promise).to.be.eql({ success: false, attribute: TEST_ATTRIBUTE });
23
18
  });
24
- it('should call onSuccess callback when attribute is set async', async () => {
19
+ it('should resolve success true when attribute is set async', async () => {
25
20
  const element = document.createElement('div');
26
- const onSuccess = spy();
27
- const onTimeout = spy();
28
- waitForAttribute({
21
+ const promise = waitForAttribute({
29
22
  element,
30
23
  attribute: TEST_ATTRIBUTE,
31
- onSuccess,
32
- onTimeout,
33
24
  timeout: 10,
34
25
  });
35
26
  element.setAttribute(TEST_ATTRIBUTE, 'test');
36
27
  await delay(100);
37
- expect(onSuccess.calledOnce).to.be.true;
38
- expect(onSuccess.getCall(0).args[0]).to.equal('test');
39
- expect(onTimeout.called).to.be.false;
28
+ expect(await promise).to.be.eql({ success: true, attribute: TEST_ATTRIBUTE, value: 'test' });
40
29
  });
41
- it('should call onSuccess callback when attribute is set sync', async () => {
30
+ it('should resolve success true when attribute is set sync', async () => {
42
31
  const element = document.createElement('div');
43
32
  element.setAttribute(TEST_ATTRIBUTE, 'test');
44
- const onSuccess = spy();
45
- const onTimeout = spy();
46
- waitForAttribute({
33
+ const promise = waitForAttribute({
47
34
  element,
48
35
  attribute: TEST_ATTRIBUTE,
49
- onSuccess,
50
- onTimeout,
51
36
  timeout: 10,
52
37
  });
53
38
  await delay(100);
54
- expect(onSuccess.calledOnce).to.be.true;
55
- expect(onSuccess.getCall(0).args[0]).to.equal('test');
56
- expect(onTimeout.called).to.be.false;
57
- });
58
-
59
- it('should not call onSuccess on the second attribute change', async () => {
60
- const element = document.createElement('div');
61
- element.setAttribute(TEST_ATTRIBUTE, 'test');
62
- const onSuccess = spy();
63
- const onTimeout = spy();
64
- waitForAttribute({
65
- element,
66
- attribute: TEST_ATTRIBUTE,
67
- onSuccess,
68
- onTimeout,
69
- timeout: 10,
70
- });
71
- await delay(100);
72
- element.setAttribute(TEST_ATTRIBUTE, 'tes2');
73
- await delay(100);
74
- expect(onSuccess.calledOnce).to.be.true;
75
- expect(onSuccess.getCall(0).args[0]).to.equal('test');
76
- expect(onTimeout.called).to.be.false;
39
+ expect(await promise).to.be.eql({ success: true, attribute: TEST_ATTRIBUTE, value: 'test' });
77
40
  });
78
41
  });
@@ -0,0 +1,7 @@
1
+ /** @template T */
2
+ export function withResolvers<T>(): {
3
+ resolve: (value: T | PromiseLike<T>) => void;
4
+ reject: (value?: unknown) => void;
5
+ promise: Promise<T>;
6
+ };
7
+ //# sourceMappingURL=withResolvers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withResolvers.d.ts","sourceRoot":"","sources":["withResolvers.js"],"names":[],"mappings":"AAEA,kBAAkB;AAClB,8BADc,CAAC;aAUS,CAAC,KAAK,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI;YACpC,CAAC,KAAK,CAAC,EAAE,OAAO,KAAK,IAAI;;EAG/C"}
@@ -0,0 +1,17 @@
1
+ // @ts-check
2
+
3
+ /** @template T */
4
+ export function withResolvers() {
5
+ let resolve;
6
+ let reject;
7
+ /** @type {Promise<T>} */
8
+ const promise = new Promise((_resolve, _reject) => {
9
+ resolve = _resolve;
10
+ reject = _reject;
11
+ });
12
+ return {
13
+ resolve: /** @type {(value: T | PromiseLike<T>) => void} */ (/** @type {unknown} */ (resolve)),
14
+ reject: /** @type {(value?: unknown) => void} */ (/** @type {unknown} */ (reject)),
15
+ promise,
16
+ };
17
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=withResolvers.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withResolvers.test.d.ts","sourceRoot":"","sources":["withResolvers.test.js"],"names":[],"mappings":""}
@@ -0,0 +1,27 @@
1
+ import { expect } from '@esm-bundle/chai';
2
+ import { withResolvers } from './withResolvers';
3
+
4
+ describe('withResolvers', () => {
5
+ it('should return resolve, reject and promise', () => {
6
+ const { resolve, reject, promise } = withResolvers();
7
+ expect(resolve).to.be.a('function');
8
+ expect(reject).to.be.a('function');
9
+ expect(promise).to.be.instanceOf(Promise);
10
+ });
11
+
12
+ it('should resolve promise', async () => {
13
+ const { resolve, promise } = withResolvers();
14
+ resolve('resolved');
15
+ expect(await promise).to.equal('resolved');
16
+ });
17
+
18
+ it('should reject promise', async () => {
19
+ const { reject, promise } = withResolvers();
20
+ reject(new Error('rejected'));
21
+ try {
22
+ await promise;
23
+ } catch (error) {
24
+ expect(error.message).to.equal('rejected');
25
+ }
26
+ });
27
+ });