@uploadcare/file-uploader 1.19.1 → 1.20.0-rc.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.
Files changed (114) hide show
  1. package/abstract/Block.d.ts +11 -2
  2. package/abstract/Block.d.ts.map +1 -1
  3. package/abstract/Block.js +29 -3
  4. package/abstract/CTX.d.ts +2 -2
  5. package/abstract/CTX.d.ts.map +1 -1
  6. package/abstract/CTX.js +1 -1
  7. package/abstract/SolutionBlock.d.ts +1 -1
  8. package/abstract/UploaderBlock.d.ts +3 -3
  9. package/abstract/UploaderBlock.d.ts.map +1 -1
  10. package/abstract/UploaderBlock.js +2 -2
  11. package/abstract/l10nProcessor.js +1 -1
  12. package/abstract/{LocaleManager.d.ts → managers/LocaleManager.d.ts} +8 -8
  13. package/abstract/{LocaleManager.d.ts.map → managers/LocaleManager.d.ts.map} +1 -1
  14. package/abstract/{LocaleManager.js → managers/LocaleManager.js} +8 -8
  15. package/abstract/{ModalManager.d.ts → managers/ModalManager.d.ts} +7 -7
  16. package/abstract/{ModalManager.d.ts.map → managers/ModalManager.d.ts.map} +1 -1
  17. package/abstract/{ModalManager.js → managers/ModalManager.js} +3 -3
  18. package/abstract/managers/SecureUploadsManager.d.ts +22 -0
  19. package/abstract/{SecureUploadsManager.d.ts.map → managers/SecureUploadsManager.d.ts.map} +1 -1
  20. package/abstract/{SecureUploadsManager.js → managers/SecureUploadsManager.js} +5 -5
  21. package/abstract/managers/TelemetryManager.d.ts +66 -0
  22. package/abstract/managers/TelemetryManager.d.ts.map +1 -0
  23. package/abstract/managers/TelemetryManager.js +204 -0
  24. package/abstract/{ValidationManager.d.ts → managers/ValidationManager.d.ts} +7 -7
  25. package/abstract/{ValidationManager.d.ts.map → managers/ValidationManager.d.ts.map} +1 -1
  26. package/abstract/{ValidationManager.js → managers/ValidationManager.js} +14 -14
  27. package/abstract/{a11y.d.ts → managers/a11y.d.ts} +2 -2
  28. package/abstract/managers/a11y.d.ts.map +1 -0
  29. package/abstract/{a11y.js → managers/a11y.js} +1 -1
  30. package/blocks/CameraSource/CameraSource.d.ts +1 -1
  31. package/blocks/CloudImageEditor/src/EditorCropButtonControl.d.ts.map +1 -1
  32. package/blocks/CloudImageEditor/src/EditorCropButtonControl.js +8 -1
  33. package/blocks/CloudImageEditor/src/EditorFilterControl.d.ts.map +1 -1
  34. package/blocks/CloudImageEditor/src/EditorFilterControl.js +7 -1
  35. package/blocks/CloudImageEditor/src/EditorOperationControl.d.ts +1 -1
  36. package/blocks/CloudImageEditor/src/EditorOperationControl.d.ts.map +1 -1
  37. package/blocks/CloudImageEditor/src/EditorOperationControl.js +9 -3
  38. package/blocks/CloudImageEditor/src/EditorToolbar.d.ts +8 -4
  39. package/blocks/CloudImageEditor/src/EditorToolbar.d.ts.map +1 -1
  40. package/blocks/CloudImageEditor/src/EditorToolbar.js +24 -4
  41. package/blocks/CloudImageEditor/src/toolbar-constants.d.ts +1 -0
  42. package/blocks/CloudImageEditor/src/toolbar-constants.d.ts.map +1 -1
  43. package/blocks/CloudImageEditor/src/toolbar-constants.js +2 -0
  44. package/blocks/CloudImageEditor/src/utils/parseFilterValue.d.ts +11 -0
  45. package/blocks/CloudImageEditor/src/utils/parseFilterValue.d.ts.map +1 -0
  46. package/blocks/CloudImageEditor/src/utils/parseFilterValue.js +11 -0
  47. package/blocks/Config/initialConfig.d.ts.map +1 -1
  48. package/blocks/Config/initialConfig.js +2 -0
  49. package/blocks/Config/normalizeConfigValue.d.ts.map +1 -1
  50. package/blocks/Config/normalizeConfigValue.js +2 -0
  51. package/blocks/DropArea/DropArea.d.ts +1 -1
  52. package/blocks/ExternalSource/ExternalSource.d.ts +1 -1
  53. package/blocks/FileItem/FileItem.d.ts +1 -1
  54. package/blocks/FileItem/FileItem.d.ts.map +1 -1
  55. package/blocks/FileItem/FileItem.js +16 -0
  56. package/blocks/Modal/Modal.d.ts +6 -6
  57. package/blocks/Modal/Modal.d.ts.map +1 -1
  58. package/blocks/Modal/Modal.js +10 -12
  59. package/blocks/SimpleBtn/SimpleBtn.d.ts +1 -1
  60. package/blocks/SourceBtn/SourceBtn.d.ts +1 -1
  61. package/blocks/Thumb/Thumb.d.ts +1 -1
  62. package/blocks/UploadCtxProvider/EventEmitter.d.ts +17 -4
  63. package/blocks/UploadCtxProvider/EventEmitter.d.ts.map +1 -1
  64. package/blocks/UploadCtxProvider/EventEmitter.js +14 -2
  65. package/blocks/UploadList/UploadList.d.ts +1 -1
  66. package/env.d.ts +1 -1
  67. package/env.js +1 -1
  68. package/index.d.ts +1 -1
  69. package/index.js +1 -1
  70. package/index.ssr.d.ts +3 -1
  71. package/index.ssr.d.ts.map +1 -1
  72. package/index.ssr.js +5 -1
  73. package/package.json +6 -3
  74. package/solutions/cloud-image-editor/CloudImageEditor.d.ts +34 -0
  75. package/solutions/cloud-image-editor/CloudImageEditor.d.ts.map +1 -1
  76. package/solutions/cloud-image-editor/CloudImageEditor.js +12 -0
  77. package/solutions/file-uploader/inline/FileUploaderInline.d.ts +2 -1
  78. package/solutions/file-uploader/inline/FileUploaderInline.d.ts.map +1 -1
  79. package/solutions/file-uploader/inline/FileUploaderInline.js +4 -0
  80. package/solutions/file-uploader/minimal/FileUploaderMinimal.d.ts +10 -9
  81. package/solutions/file-uploader/minimal/FileUploaderMinimal.d.ts.map +1 -1
  82. package/solutions/file-uploader/minimal/FileUploaderMinimal.js +7 -3
  83. package/solutions/file-uploader/regular/FileUploaderRegular.d.ts +2 -1
  84. package/solutions/file-uploader/regular/FileUploaderRegular.d.ts.map +1 -1
  85. package/solutions/file-uploader/regular/FileUploaderRegular.js +4 -0
  86. package/types/events.d.ts +1 -1
  87. package/types/exported.d.ts +54 -52
  88. package/utils/validators/collection/validateCollectionUploadError.d.ts +2 -2
  89. package/utils/validators/collection/validateCollectionUploadError.d.ts.map +1 -1
  90. package/utils/validators/collection/validateCollectionUploadError.js +1 -1
  91. package/utils/validators/collection/validateMultiple.d.ts +2 -2
  92. package/utils/validators/collection/validateMultiple.d.ts.map +1 -1
  93. package/utils/validators/collection/validateMultiple.js +1 -1
  94. package/utils/validators/file/validateFileType.d.ts +2 -2
  95. package/utils/validators/file/validateFileType.d.ts.map +1 -1
  96. package/utils/validators/file/validateFileType.js +1 -1
  97. package/utils/validators/file/validateIsImage.d.ts +2 -2
  98. package/utils/validators/file/validateIsImage.d.ts.map +1 -1
  99. package/utils/validators/file/validateIsImage.js +1 -1
  100. package/utils/validators/file/validateMaxSizeLimit.d.ts +2 -2
  101. package/utils/validators/file/validateMaxSizeLimit.d.ts.map +1 -1
  102. package/utils/validators/file/validateMaxSizeLimit.js +1 -1
  103. package/utils/validators/file/validateUploadError.d.ts +2 -2
  104. package/utils/validators/file/validateUploadError.d.ts.map +1 -1
  105. package/utils/validators/file/validateUploadError.js +1 -1
  106. package/web/file-uploader.iife.min.js +4 -4
  107. package/web/file-uploader.min.js +4 -4
  108. package/web/uc-cloud-image-editor.min.js +4 -4
  109. package/web/uc-file-uploader-inline.min.js +4 -4
  110. package/web/uc-file-uploader-minimal.min.js +4 -4
  111. package/web/uc-file-uploader-regular.min.js +4 -4
  112. package/web/uc-img.min.js +1 -1
  113. package/abstract/SecureUploadsManager.d.ts +0 -22
  114. package/abstract/a11y.d.ts.map +0 -1
@@ -0,0 +1,204 @@
1
+ // @ts-check
2
+ import { TelemetryAPIService } from '@uploadcare/quality-insights';
3
+
4
+ import { Queue } from '@uploadcare/upload-client';
5
+ import { PACKAGE_VERSION, PACKAGE_NAME } from '../../env.js';
6
+ import { initialConfig } from '../../blocks/Config/initialConfig.js';
7
+ import { EventType } from '../../blocks/UploadCtxProvider/EventEmitter.js';
8
+
9
+ /** @typedef {import('@uploadcare/quality-insights').TelemetryRequest & { eventTimestamp: number }} TelemetryState */
10
+
11
+ export class TelemetryManager {
12
+ /** @type {ReturnType<Crypto['randomUUID']>} */
13
+ _sessionId = crypto.randomUUID();
14
+
15
+ /** @type {TelemetryAPIService | null} */
16
+ _telemetryInstance = null;
17
+
18
+ /** @type {import('../Block.js').Block | null} */
19
+ _block = null;
20
+
21
+ _config = initialConfig;
22
+
23
+ /** @type {boolean} */
24
+ _initialized = false;
25
+
26
+ /** @type {TelemetryState | null} */
27
+ _lastPayload = null;
28
+
29
+ /** @type {import('@uploadcare/upload-client').Queue | null} */
30
+ _queue = null;
31
+
32
+ /** @param {import('../Block.js').Block} block */
33
+ constructor(block) {
34
+ this._block = block;
35
+
36
+ this._telemetryInstance = new TelemetryAPIService();
37
+
38
+ this._queue = new Queue(10);
39
+
40
+ for (const key of /** @type {(keyof import('../../types/exported').ConfigType)[]} */ (Object.keys(initialConfig))) {
41
+ block.subConfigValue(key, (value) => {
42
+ if (this._initialized && this._config[key] !== value) {
43
+ console.log({ key, value });
44
+
45
+ this._block?.emit(EventType.CHANGE_CONFIG, undefined);
46
+ }
47
+
48
+ this._setConfig(key, value);
49
+ });
50
+ }
51
+ }
52
+
53
+ /** @param {keyof import('../../blocks/UploadCtxProvider/EventEmitter.js').EventPayload | undefined} type */
54
+ _init(type) {
55
+ if (type === EventType.INIT_SOLUTION && !this._initialized) {
56
+ this._initialized = true;
57
+ }
58
+ }
59
+
60
+ /**
61
+ * @template {keyof import('../../types').ConfigType} T
62
+ * @param {T} key
63
+ * @param {import('../../types').ConfigType[T]} value
64
+ */
65
+ _setConfig(key, value) {
66
+ if (this._config[key] === value) {
67
+ return;
68
+ }
69
+
70
+ this._config[key] = value;
71
+ }
72
+
73
+ /**
74
+ * @param {Pick<TelemetryState, 'eventType' | 'payload' | 'config'>} body
75
+ * @returns {TelemetryState}
76
+ */
77
+ _formattingPayload(body) {
78
+ const payload = body.payload ? { ...body.payload } : {};
79
+ if (payload.activity) payload.activity = undefined;
80
+
81
+ const result = { ...body };
82
+ if (body.eventType === EventType.INIT_SOLUTION || body.eventType === EventType.CHANGE_CONFIG) {
83
+ result.config = this._config;
84
+ }
85
+
86
+ return {
87
+ ...result,
88
+
89
+ appVersion: PACKAGE_VERSION,
90
+ appName: PACKAGE_NAME,
91
+ sessionId: this._sessionId,
92
+ component: this._solution,
93
+ activity: this._activity,
94
+ projectPubkey: this._config?.pubkey,
95
+ userAgent: navigator.userAgent,
96
+ eventType: result.eventType ?? '',
97
+ eventTimestamp: this._timestamp,
98
+
99
+ payload: {
100
+ ...payload,
101
+ },
102
+ };
103
+ }
104
+
105
+ /** @param {keyof import('../../blocks/UploadCtxProvider/EventEmitter.js').EventPayload | undefined} type */
106
+ _excludedEvents(type) {
107
+ if (
108
+ type &&
109
+ [
110
+ EventType.CHANGE,
111
+ EventType.COMMON_UPLOAD_PROGRESS,
112
+ EventType.FILE_ADDED,
113
+ EventType.FILE_REMOVED,
114
+ EventType.FILE_UPLOAD_START,
115
+ EventType.FILE_UPLOAD_PROGRESS,
116
+ EventType.FILE_UPLOAD_SUCCESS,
117
+ EventType.FILE_UPLOAD_FAILED,
118
+ EventType.FILE_URL_CHANGED,
119
+ EventType.GROUP_CREATED,
120
+ ].includes(type)
121
+ ) {
122
+ return true;
123
+ }
124
+
125
+ return false;
126
+ }
127
+
128
+ /**
129
+ * @param {Partial<Pick<TelemetryState, 'eventType' | 'payload'>> & {
130
+ * modalId?: string;
131
+ * eventType?: keyof import('../../blocks/UploadCtxProvider/EventEmitter.js').EventPayload;
132
+ * }} body
133
+ */
134
+ sendEvent(body) {
135
+ const payload = this._formattingPayload(
136
+ /** @type {Pick<TelemetryState, 'eventType' | 'payload' | 'config'>} */ (body),
137
+ );
138
+
139
+ this._init(body.eventType);
140
+
141
+ const hasExcludedEvents = this._excludedEvents(body.eventType);
142
+ if (hasExcludedEvents) return null;
143
+
144
+ const hasDataSame = this._lastPayload && this._checkObj(this._lastPayload, payload);
145
+ if (hasDataSame) return null;
146
+
147
+ this._queue?.add(async () => {
148
+ this._lastPayload = payload;
149
+ await this._telemetryInstance?.sendEvent(/** @type {TelemetryState} */ (payload));
150
+ });
151
+ }
152
+
153
+ /**
154
+ * Method to send telemetry event for Cloud Image Editor.
155
+ *
156
+ * @param {MouseEvent} e
157
+ * @param {string} tabId
158
+ * @param {Record<string, unknown>} options
159
+ */
160
+ sendEventCloudImageEditor(e, tabId, options = {}) {
161
+ this.sendEvent({
162
+ payload: {
163
+ metadata: {
164
+ tabId,
165
+ node: /** @type {HTMLElement} */ (e.currentTarget)?.tagName,
166
+ event: e.type,
167
+ ...options,
168
+ },
169
+ },
170
+ });
171
+ }
172
+
173
+ /**
174
+ * Deeply compares two objects and returns true if they are equal, false otherwise.
175
+ *
176
+ * @param {any} last
177
+ * @param {any} current
178
+ */
179
+ _checkObj(last, current) {
180
+ if (JSON.stringify(last) === JSON.stringify(current)) return true;
181
+ if (typeof last !== 'object' || typeof current !== 'object' || last == null || current == null) return false;
182
+ const lastKeys = Object.keys(last);
183
+ const currentKeys = Object.keys(current);
184
+ if (lastKeys.length !== currentKeys.length) return false;
185
+ for (const key of lastKeys) {
186
+ if (!Object.prototype.hasOwnProperty.call(current, key)) return false;
187
+ if (!this._checkObj(last[key], current[key])) return false;
188
+ }
189
+
190
+ return true;
191
+ }
192
+
193
+ get _timestamp() {
194
+ return Date.now();
195
+ }
196
+
197
+ get _solution() {
198
+ return this._block?.has('*solution') ? this._block?.$['*solution'].toLowerCase() : null;
199
+ }
200
+
201
+ get _activity() {
202
+ return this._block?.has('*currentActivity') ? this._block?.$['*currentActivity'] : null;
203
+ }
204
+ }
@@ -1,16 +1,16 @@
1
1
  export class ValidationManager {
2
- /** @param {import('./UploaderBlock.js').UploaderBlock} blockInstance */
3
- constructor(blockInstance: import("./UploaderBlock.js").UploaderBlock);
2
+ /** @param {import('../UploaderBlock.js').UploaderBlock} blockInstance */
3
+ constructor(blockInstance: import("../UploaderBlock.js").UploaderBlock);
4
4
  /**
5
5
  * @private
6
- * @type {import('./UploaderBlock.js').UploaderBlock}
6
+ * @type {import('../UploaderBlock.js').UploaderBlock}
7
7
  */
8
8
  private _blockInstance;
9
9
  /** @type {FuncFileValidator[]} */
10
10
  _fileValidators: FuncFileValidator[];
11
11
  /** @type {FuncCollectionValidator[]} */
12
12
  _collectionValidators: FuncCollectionValidator[];
13
- _uploadCollection: import("./TypedCollection.js").TypedCollection<Readonly<{
13
+ _uploadCollection: import("../TypedCollection.js").TypedCollection<Readonly<{
14
14
  file: Readonly<{
15
15
  type: {
16
16
  new (fileBits: BlobPart[], fileName: string, options?: FilePropertyBag): File;
@@ -135,7 +135,7 @@ export class ValidationManager {
135
135
  runCollectionValidators(): void;
136
136
  /**
137
137
  * @private
138
- * @param {import('./TypedData.js').TypedData<typeof import('./uploadEntrySchema.js').uploadEntrySchema>} entry
138
+ * @param {import('../TypedData.js').TypedData<typeof import('../uploadEntrySchema.js').uploadEntrySchema>} entry
139
139
  */
140
140
  private _runFileValidatorsForEntry;
141
141
  /**
@@ -145,6 +145,6 @@ export class ValidationManager {
145
145
  */
146
146
  _addCustomTypeToValidators<T>(validators: T[]): T[];
147
147
  }
148
- export type FuncFileValidator = (outputEntry: import("../types").OutputFileEntry, api: import("./UploaderPublicApi.js").UploaderPublicApi) => undefined | import("../types").OutputErrorFile;
149
- export type FuncCollectionValidator = (collection: ReturnType<typeof import("./buildOutputCollectionState.js").buildOutputCollectionState<import("../types").OutputCollectionStatus>>, api: import("./UploaderPublicApi.js").UploaderPublicApi) => undefined | import("../types").OutputErrorCollection;
148
+ export type FuncFileValidator = (outputEntry: import("../../types/index.js").OutputFileEntry, api: import("../UploaderPublicApi.js").UploaderPublicApi) => undefined | import("../../types/index.js").OutputErrorFile;
149
+ export type FuncCollectionValidator = (collection: ReturnType<typeof import("../buildOutputCollectionState.js").buildOutputCollectionState<import("../../types/index.js").OutputCollectionStatus>>, api: import("../UploaderPublicApi.js").UploaderPublicApi) => undefined | import("../../types/index.js").OutputErrorCollection;
150
150
  //# sourceMappingURL=ValidationManager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ValidationManager.d.ts","sourceRoot":"","sources":["ValidationManager.js"],"names":[],"mappings":"AAkCA;IAaE,wEAAwE;IACxE,2BADY,OAAO,oBAAoB,EAAE,aAAa,EAiBrD;IA7BD;;;OAGG;IACH,uBAAe;IAEf,kCAAkC;IAClC,iBADW,iBAAiB,EAAE,CACmE;IAEjG,wCAAwC;IACxC,uBADW,uBAAuB,EAAE,CACsC;IAMxE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAA6D;IAe/D,mCAAmC;IACnC,6BADY,MAAM,EAAE,QASnB;IAED,gCAqCC;IAED;;;OAGG;IACH,mCAyBC;IAED;;;;OAIG;IACH,2BAJa,CAAC,cACH,CAAC,EAAE,GACD,CAAC,EAAE,CAUf;CACF;gCAtJY,CACR,WAAW,EAAE,OAAO,UAAU,EAAE,eAAe,EAC/C,GAAG,EAAE,OAAO,wBAAwB,EAAE,iBAAiB,KACpD,SAAS,GAAG,OAAO,UAAU,EAAE,eAAe;sCAIzC,CACR,UAAU,EAAE,UAAU,CAC1B,cAAoB,iCAAiC,EAAE,0BAA0B,CACjF,OAAe,UAAU,EAAE,sBAAsB,CAC1C,CACF,EACD,GAAG,EAAE,OAAO,wBAAwB,EAAE,iBAAiB,KACpD,SAAS,GAAG,OAAO,UAAU,EAAE,qBAAqB"}
1
+ {"version":3,"file":"ValidationManager.d.ts","sourceRoot":"","sources":["ValidationManager.js"],"names":[],"mappings":"AAkCA;IAaE,yEAAyE;IACzE,2BADY,OAAO,qBAAqB,EAAE,aAAa,EAiBtD;IA7BD;;;OAGG;IACH,uBAAe;IAEf,kCAAkC;IAClC,iBADW,iBAAiB,EAAE,CACmE;IAEjG,wCAAwC;IACxC,uBADW,uBAAuB,EAAE,CACsC;IAMxE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAA6D;IAe/D,mCAAmC;IACnC,6BADY,MAAM,EAAE,QASnB;IAED,gCAqCC;IAED;;;OAGG;IACH,mCAyBC;IAED;;;;OAIG;IACH,2BAJa,CAAC,cACH,CAAC,EAAE,GACD,CAAC,EAAE,CAUf;CACF;gCAtJY,CACR,WAAW,EAAE,OAAO,sBAAsB,EAAE,eAAe,EAC3D,GAAG,EAAE,OAAO,yBAAyB,EAAE,iBAAiB,KACrD,SAAS,GAAG,OAAO,sBAAsB,EAAE,eAAe;sCAIrD,CACR,UAAU,EAAE,UAAU,CAC1B,cAAoB,kCAAkC,EAAE,0BAA0B,CAClF,OAAe,sBAAsB,EAAE,sBAAsB,CACtD,CACF,EACD,GAAG,EAAE,OAAO,yBAAyB,EAAE,iBAAiB,KACrD,SAAS,GAAG,OAAO,sBAAsB,EAAE,qBAAqB"}
@@ -1,29 +1,29 @@
1
1
  // @ts-check
2
- import { EventType } from '../blocks/UploadCtxProvider/EventEmitter.js';
2
+ import { EventType } from '../../blocks/UploadCtxProvider/EventEmitter.js';
3
3
  import {
4
4
  validateIsImage,
5
5
  validateFileType,
6
6
  validateMaxSizeLimit,
7
7
  validateUploadError,
8
- } from '../utils/validators/file/index.js';
9
- import { validateMultiple, validateCollectionUploadError } from '../utils/validators/collection/index.js';
8
+ } from '../../utils/validators/file/index.js';
9
+ import { validateMultiple, validateCollectionUploadError } from '../../utils/validators/collection/index.js';
10
10
 
11
11
  /**
12
12
  * @typedef {(
13
- * outputEntry: import('../types').OutputFileEntry,
14
- * api: import('./UploaderPublicApi.js').UploaderPublicApi,
15
- * ) => undefined | import('../types').OutputErrorFile} FuncFileValidator
13
+ * outputEntry: import('../../types/index.js').OutputFileEntry,
14
+ * api: import('../UploaderPublicApi.js').UploaderPublicApi,
15
+ * ) => undefined | import('../../types/index.js').OutputErrorFile} FuncFileValidator
16
16
  */
17
17
 
18
18
  /**
19
19
  * @typedef {(
20
20
  * collection: ReturnType<
21
- * typeof import('./buildOutputCollectionState.js').buildOutputCollectionState<
22
- * import('../types').OutputCollectionStatus
21
+ * typeof import('../buildOutputCollectionState.js').buildOutputCollectionState<
22
+ * import('../../types/index.js').OutputCollectionStatus
23
23
  * >
24
24
  * >,
25
- * api: import('./UploaderPublicApi.js').UploaderPublicApi,
26
- * ) => undefined | import('../types').OutputErrorCollection} FuncCollectionValidator
25
+ * api: import('../UploaderPublicApi.js').UploaderPublicApi,
26
+ * ) => undefined | import('../../types/index.js').OutputErrorCollection} FuncCollectionValidator
27
27
  */
28
28
 
29
29
  const LOGGER = {
@@ -35,7 +35,7 @@ const LOGGER = {
35
35
  export class ValidationManager {
36
36
  /**
37
37
  * @private
38
- * @type {import('./UploaderBlock.js').UploaderBlock}
38
+ * @type {import('../UploaderBlock.js').UploaderBlock}
39
39
  */
40
40
  _blockInstance;
41
41
 
@@ -45,7 +45,7 @@ export class ValidationManager {
45
45
  /** @type {FuncCollectionValidator[]} */
46
46
  _collectionValidators = [validateMultiple, validateCollectionUploadError];
47
47
 
48
- /** @param {import('./UploaderBlock.js').UploaderBlock} blockInstance */
48
+ /** @param {import('../UploaderBlock.js').UploaderBlock} blockInstance */
49
49
  constructor(blockInstance) {
50
50
  this._blockInstance = blockInstance;
51
51
 
@@ -106,7 +106,7 @@ export class ValidationManager {
106
106
  this._blockInstance.emit(
107
107
  EventType.COMMON_UPLOAD_FAILED,
108
108
  () =>
109
- /** @type {import('../types').OutputCollectionState<'failed'>} */ (
109
+ /** @type {import('../../types/index.js').OutputCollectionState<'failed'>} */ (
110
110
  this._blockInstance.api.getOutputCollectionState()
111
111
  ),
112
112
  { debounce: true },
@@ -116,7 +116,7 @@ export class ValidationManager {
116
116
 
117
117
  /**
118
118
  * @private
119
- * @param {import('./TypedData.js').TypedData<typeof import('./uploadEntrySchema.js').uploadEntrySchema>} entry
119
+ * @param {import('../TypedData.js').TypedData<typeof import('../uploadEntrySchema.js').uploadEntrySchema>} entry
120
120
  */
121
121
  _runFileValidatorsForEntry(entry) {
122
122
  const outputEntry = this._blockInstance.api.getOutputItem(entry.uid);
@@ -9,8 +9,8 @@ export class A11y {
9
9
  * @type {ScopedMinimalWindow}
10
10
  */
11
11
  private _scopedWindow;
12
- /** @param {import('./Block.js').Block} scope */
13
- registerBlock(scope: import("./Block.js").Block): void;
12
+ /** @param {import('../Block.js').Block} scope */
13
+ registerBlock(scope: import("../Block.js").Block): void;
14
14
  destroy(): void;
15
15
  }
16
16
  /**
@@ -0,0 +1 @@
1
+ {"version":3,"file":"a11y.d.ts","sourceRoot":"","sources":["a11y.js"],"names":[],"mappings":"AAqFA;IACE;;;OAGG;IACH,sBAAc;IAEd;;;OAGG;IACH,sBAAc;IAYd,iDAAiD;IACjD,qBADY,OAAO,aAAa,EAAE,KAAK,QAGtC;IAED,gBAGC;CACF;;;;4BA/GY,UAAU,CAAC,OAAO,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC"}
@@ -106,7 +106,7 @@ export class A11y {
106
106
  ]);
107
107
  }
108
108
 
109
- /** @param {import('./Block.js').Block} scope */
109
+ /** @param {import('../Block.js').Block} scope */
110
110
  registerBlock(scope) {
111
111
  this._scopedWindow.registerScope(scope);
112
112
  }
@@ -68,7 +68,7 @@ export class CameraSource extends UploaderBlock {
68
68
  '*collectionState': import("../../index.js").OutputCollectionState | null;
69
69
  '*groupInfo': import("@uploadcare/upload-client").UploadcareGroup | null;
70
70
  '*uploadTrigger': Set<string>;
71
- '*secureUploadsManager': import("../../abstract/SecureUploadsManager.js").SecureUploadsManager | null;
71
+ '*secureUploadsManager': import("../../abstract/managers/SecureUploadsManager.js").SecureUploadsManager | null;
72
72
  '*currentActivity': null;
73
73
  '*currentActivityParams': {};
74
74
  '*history': never[];
@@ -1 +1 @@
1
- {"version":3,"file":"EditorCropButtonControl.d.ts","sourceRoot":"","sources":["EditorCropButtonControl.js"],"names":[],"mappings":"AAkBA;IASM,eAAe;IACf,mBAA2B;CAehC;oCA3CmC,0BAA0B"}
1
+ {"version":3,"file":"EditorCropButtonControl.d.ts","sourceRoot":"","sources":["EditorCropButtonControl.js"],"names":[],"mappings":"AAkBA;IASM,eAAe;IACf,mBAA2B;CAsBhC;oCAlDmC,0BAA0B"}
@@ -35,9 +35,16 @@ export class EditorCropButtonControl extends EditorButtonControl {
35
35
  );
36
36
  });
37
37
 
38
- this.$['on.click'] = () => {
38
+ this.$['on.click'] = (e) => {
39
39
  let prev = this.$['*cropperEl'].getValue(this._operation);
40
40
  let next = nextValue(this._operation, prev);
41
+
42
+ this.telemetryManager.sendEventCloudImageEditor(e, this.$['*tabId'], {
43
+ operation: this._operation,
44
+ next,
45
+ prev,
46
+ });
47
+
41
48
  this.$['*cropperEl'].setValue(this._operation, next);
42
49
  };
43
50
  }
@@ -1 +1 @@
1
- {"version":3,"file":"EditorFilterControl.d.ts","sourceRoot":"","sources":["EditorFilterControl.js"],"names":[],"mappings":"AAOA;IAeE,sBA2BC;IAED;;;OAGG;IACH,2BAHW,yBAAyB,EAAE,YAC3B,oBAAoB,iBAuB9B;IAfG,yCAA4B;IAoC1B,+BAA0B;IAC1B,4BAAqB;IAYzB,4CAEE;IAGF,kBAA+B;CAgDlC;;;;oCAjKmC,0BAA0B"}
1
+ {"version":3,"file":"EditorFilterControl.d.ts","sourceRoot":"","sources":["EditorFilterControl.js"],"names":[],"mappings":"AAQA;IAeE,sBA2BC;IAED;;;OAGG;IACH,2BAHW,yBAAyB,EAAE,YAC3B,oBAAoB,iBAuB9B;IAfG,yCAA4B;IAyC1B,+BAA0B;IAC1B,4BAAqB;IAYzB,4CAEE;IAGF,kBAA+B;CAgDlC;;;;oCAvKmC,0BAA0B"}
@@ -4,6 +4,7 @@ import { EditorButtonControl } from './EditorButtonControl.js';
4
4
  import { FAKE_ORIGINAL_FILTER } from './EditorSlider.js';
5
5
  import { COMMON_OPERATIONS, transformationsToOperations } from './lib/transformationUtils.js';
6
6
  import { preloadImage } from '../../utils/preloadImage.js';
7
+ import { parseFilterValue } from './utils/parseFilterValue.js';
7
8
 
8
9
  export class EditorFilterControl extends EditorButtonControl {
9
10
  constructor() {
@@ -79,7 +80,8 @@ export class EditorFilterControl extends EditorButtonControl {
79
80
  initCallback() {
80
81
  super.initCallback();
81
82
 
82
- this.$['on.click'] = () => {
83
+ /** @param {MouseEvent} e */
84
+ this.$['on.click'] = (e) => {
83
85
  if (!this.$.active) {
84
86
  this.$['*sliderEl'].setOperation(this._operation, this._filter);
85
87
  this.$['*sliderEl'].apply();
@@ -88,6 +90,10 @@ export class EditorFilterControl extends EditorButtonControl {
88
90
  this.$['*showSlider'] = true;
89
91
  }
90
92
 
93
+ this.telemetryManager.sendEventCloudImageEditor(e, this.$['*tabId'], {
94
+ operation: parseFilterValue(this.$['*operationTooltip']),
95
+ });
96
+
91
97
  this.$['*currentFilter'] = this._filter;
92
98
  };
93
99
 
@@ -1,7 +1,7 @@
1
1
  export class EditorOperationControl extends EditorButtonControl {
2
2
  /**
3
3
  * @private
4
- * @type {String}
4
+ * @type {import('./toolbar-constants.js').ColorOperation | ''}
5
5
  */
6
6
  private _operation;
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"EditorOperationControl.d.ts","sourceRoot":"","sources":["EditorOperationControl.js"],"names":[],"mappings":"AAGA;IACE;;;OAGG;IACH,mBAAgB;CAmCjB;oCA3CmC,0BAA0B"}
1
+ {"version":3,"file":"EditorOperationControl.d.ts","sourceRoot":"","sources":["EditorOperationControl.js"],"names":[],"mappings":"AAKA;IACE;;;OAGG;IACH,mBAAgB;CAuCjB;oCAhDmC,0BAA0B"}
@@ -1,23 +1,29 @@
1
+ //@ts-check
1
2
  import { EditorButtonControl } from './EditorButtonControl.js';
2
3
  import { COLOR_OPERATIONS_CONFIG } from './toolbar-constants.js';
4
+ import { parseFilterValue } from './utils/parseFilterValue.js';
3
5
 
4
6
  export class EditorOperationControl extends EditorButtonControl {
5
7
  /**
6
8
  * @private
7
- * @type {String}
9
+ * @type {import('./toolbar-constants.js').ColorOperation | ''}
8
10
  */
9
11
  _operation = '';
10
12
 
11
13
  initCallback() {
12
14
  super.initCallback();
13
15
 
14
- this.$['on.click'] = (e) => {
16
+ this.$['on.click'] = (/** @type {MouseEvent} */ e) => {
15
17
  this.$['*sliderEl'].setOperation(this._operation);
16
18
  this.$['*showSlider'] = true;
17
19
  this.$['*currentOperation'] = this._operation;
20
+
21
+ this.telemetryManager.sendEventCloudImageEditor(e, this.$['*tabId'], {
22
+ operation: parseFilterValue(this.$['*operationTooltip']),
23
+ });
18
24
  };
19
25
 
20
- this.defineAccessor('operation', (operation) => {
26
+ this.defineAccessor('operation', (/** @type {import('./toolbar-constants.js').ColorOperation} */ operation) => {
21
27
  if (operation) {
22
28
  this._operation = operation;
23
29
  this.$['icon'] = operation;
@@ -40,10 +40,14 @@ export class EditorToolbar extends Block {
40
40
  hidden: string;
41
41
  visible: string;
42
42
  };
43
- 'on.cancel': () => void;
44
- 'on.apply': () => void;
45
- 'on.applySlider': () => void;
46
- 'on.cancelSlider': () => void;
43
+ /** @param {MouseEvent} e */
44
+ 'on.cancel': (e: MouseEvent) => void;
45
+ /** @param {MouseEvent} e */
46
+ 'on.apply': (e: MouseEvent) => void;
47
+ /** @param {MouseEvent} e */
48
+ 'on.applySlider': (e: MouseEvent) => void;
49
+ /** @param {MouseEvent} e */
50
+ 'on.cancelSlider': (e: MouseEvent) => void;
47
51
  /** @param {MouseEvent} e */
48
52
  'on.clickTab': (e: MouseEvent) => void;
49
53
  tab_role: string;
@@ -1 +1 @@
1
- {"version":3,"file":"EditorToolbar.d.ts","sourceRoot":"","sources":["EditorToolbar.js"],"names":[],"mappings":"AA2DA;IAII;;QAGE,qDAAqD;8BAA1C,OAAO,YAAY,EAAE,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAuDjD,4BAA4B;2BAAhB,UAAU;;;;;;;MAgBvB;IAED,eAAe;IAEf,6BAAsE;IAGxE,eAAe;IACf,uBAKC;IAED;;;OAGG;IACH,gCAKC;IAED;;;OAGG;IACH,6BAKC;IAED;;;OAGG;IACH,6BAKC;IAED;;;OAGG;IACH,4BAoCC;IAED;;;;OAIG;IACH,qBAyBC;IAED;;;OAGG;IACH,4BAKC;IAED,eAAe;IACf,0BAIC;IAED,eAAe;IACf,4BAWC;IALG,oBAGC;IAIL;;;OAGG;IACH,oBAEC;IAED;;MAwBM;CAqFP;;;;sBAtZqB,4BAA4B"}
1
+ {"version":3,"file":"EditorToolbar.d.ts","sourceRoot":"","sources":["EditorToolbar.js"],"names":[],"mappings":"AA4DA;IAII;;QAGE,qDAAqD;8BAA1C,OAAO,YAAY,EAAE,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAwCjD,4BAA4B;yBAAhB,UAAU;QAStB,4BAA4B;wBAAhB,UAAU;QAOtB,4BAA4B;8BAAhB,UAAU;QAStB,4BAA4B;+BAAhB,UAAU;QAQtB,4BAA4B;2BAAhB,UAAU;;;;;;;MAiBvB;IAED,eAAe;IAEf,6BAAsE;IAGxE,eAAe;IACf,uBAKC;IAED;;;OAGG;IACH,gCAKC;IAED;;;OAGG;IACH,6BAKC;IAED;;;OAGG;IACH,6BAKC;IAED;;;OAGG;IACH,4BAoCC;IAED;;;;OAIG;IACH,qBAyBC;IAED;;;OAGG;IACH,4BAKC;IAED,eAAe;IACf,0BAIC;IAED,eAAe;IACf,4BAWC;IALG,oBAGC;IAIL;;;OAGG;IACH,oBAEC;IAED;;MAwBM;CAqFP;;;;sBA1aqB,4BAA4B"}
@@ -15,6 +15,7 @@ import {
15
15
  TabId,
16
16
  } from './toolbar-constants.js';
17
17
  import { viewerImageSrc } from './util.js';
18
+ import { parseFilterValue } from './utils/parseFilterValue.js';
18
19
 
19
20
  /** @param {String} id */
20
21
  function renderTabToggle(id) {
@@ -104,18 +105,36 @@ export class EditorToolbar extends Block {
104
105
  hidden: 'uc-tab-toggles--hidden',
105
106
  visible: 'uc-tab-toggles--visible',
106
107
  },
107
- 'on.cancel': () => {
108
+ /** @param {MouseEvent} e */
109
+ 'on.cancel': (e) => {
110
+ this.telemetryManager.sendEventCloudImageEditor(e, this.$['*tabId'], {
111
+ action: 'cancel',
112
+ });
113
+
108
114
  this._cancelPreload?.();
109
115
  this.$['*on.cancel']();
110
116
  },
111
- 'on.apply': () => {
117
+ /** @param {MouseEvent} e */
118
+ 'on.apply': (e) => {
119
+ this.telemetryManager.sendEventCloudImageEditor(e, this.$['*tabId'], {
120
+ action: 'apply',
121
+ });
112
122
  this.$['*on.apply'](this.$['*editorTransformations']);
113
123
  },
114
- 'on.applySlider': () => {
124
+ /** @param {MouseEvent} e */
125
+ 'on.applySlider': (e) => {
126
+ this.telemetryManager.sendEventCloudImageEditor(e, this.$['*tabId'], {
127
+ action: 'apply-slider',
128
+ operation: parseFilterValue(this.$['*operationTooltip']),
129
+ });
115
130
  this.ref['slider-el'].apply();
116
131
  this._onSliderClose();
117
132
  },
118
- 'on.cancelSlider': () => {
133
+ /** @param {MouseEvent} e */
134
+ 'on.cancelSlider': (e) => {
135
+ this.telemetryManager.sendEventCloudImageEditor(e, this.$['*tabId'], {
136
+ action: 'cancel-slider',
137
+ });
119
138
  this.ref['slider-el'].cancel();
120
139
  this._onSliderClose();
121
140
  },
@@ -123,6 +142,7 @@ export class EditorToolbar extends Block {
123
142
  'on.clickTab': (e) => {
124
143
  const id = /** @type {HTMLElement} */ (e.currentTarget).getAttribute('data-id');
125
144
  if (id) {
145
+ this.telemetryManager.sendEventCloudImageEditor(e, id);
126
146
  this._activateTab(id, { fromViewer: false });
127
147
  }
128
148
  },
@@ -55,4 +55,5 @@ export const COLOR_OPERATIONS_CONFIG: Readonly<{
55
55
  keypointsNumber: number;
56
56
  };
57
57
  }>;
58
+ export type ColorOperation = keyof typeof COLOR_OPERATIONS_CONFIG;
58
59
  //# sourceMappingURL=toolbar-constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"toolbar-constants.d.ts","sourceRoot":"","sources":["toolbar-constants.js"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,yDAAkE;AAElE,4CASE;AAEF,mCAyCE;AAEF,2CAAgE;AAEhE,iGAAiG;AACjG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG"}
1
+ {"version":3,"file":"toolbar-constants.d.ts","sourceRoot":"","sources":["toolbar-constants.js"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,yDAAkE;AAElE,4CASE;AAEF,mCAyCE;AAEF,2CAAgE;AAEhE,iGAAiG;AACjG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;6BAEW,MAAM,OAAO,uBAAuB"}
@@ -112,3 +112,5 @@ export const COLOR_OPERATIONS_CONFIG = Object.freeze({
112
112
  keypointsNumber: 1,
113
113
  },
114
114
  });
115
+
116
+ /** @typedef {keyof typeof COLOR_OPERATIONS_CONFIG} ColorOperation */
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Parses a string like "iothari 100" into an object { filter: "iothari", value: 100 }
3
+ *
4
+ * @param {string} str
5
+ * @returns {{ filter: string; value: number } | null}
6
+ */
7
+ export function parseFilterValue(str: string): {
8
+ filter: string;
9
+ value: number;
10
+ } | null;
11
+ //# sourceMappingURL=parseFilterValue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseFilterValue.d.ts","sourceRoot":"","sources":["parseFilterValue.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,sCAHW,MAAM,GACJ;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAMpD"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Parses a string like "iothari 100" into an object { filter: "iothari", value: 100 }
3
+ *
4
+ * @param {string} str
5
+ * @returns {{ filter: string; value: number } | null}
6
+ */
7
+ export function parseFilterValue(str) {
8
+ const match = str.match(/^(\w+)\s+(\d+)$/);
9
+ if (!match) return null;
10
+ return { filter: match[1], value: Number(match[2]) };
11
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"initialConfig.d.ts","sourceRoot":"","sources":["initialConfig.js"],"names":[],"mappings":"AAKA,gCAAiC,sBAAsB,CAAC;AACxD,+BAAgC,+BAA+B,CAAC;AAChE,sCAAuC,+BAA+B,CAAC;AACvE,+CAAgD,qBAAqB,CAAC;AAEtE,wDAAwD;AACxD,4BADW,OAAO,sBAAsB,EAAE,UAAU,CA8ElD"}
1
+ {"version":3,"file":"initialConfig.d.ts","sourceRoot":"","sources":["initialConfig.js"],"names":[],"mappings":"AAKA,gCAAiC,sBAAsB,CAAC;AACxD,+BAAgC,+BAA+B,CAAC;AAChE,sCAAuC,+BAA+B,CAAC;AACvE,+CAAgD,qBAAqB,CAAC;AAEtE,wDAAwD;AACxD,4BADW,OAAO,sBAAsB,EAAE,UAAU,CAgFlD"}
@@ -86,4 +86,6 @@ export const initialConfig = {
86
86
  cloudImageEditorMaskHref: null,
87
87
 
88
88
  testMode: false,
89
+
90
+ qualityInsights: true,
89
91
  };
@@ -1 +1 @@
1
- {"version":3,"file":"normalizeConfigValue.d.ts","sourceRoot":"","sources":["normalizeConfigValue.js"],"names":[],"mappings":"AAiHO,qCAL+C,CAAC,SAA1C,MAAO,OAAO,aAAa,EAAE,UAAW,OAC1C,CAAC,SACD,OAAO,GACL,OAAO,aAAa,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,SAAS,CAa3D"}
1
+ {"version":3,"file":"normalizeConfigValue.d.ts","sourceRoot":"","sources":["normalizeConfigValue.js"],"names":[],"mappings":"AAmHO,qCAL+C,CAAC,SAA1C,MAAO,OAAO,aAAa,EAAE,UAAW,OAC1C,CAAC,SACD,OAAO,GACL,OAAO,aAAa,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,SAAS,CAa3D"}
@@ -103,6 +103,8 @@ const mapping = {
103
103
  cloudImageEditorMaskHref: asString,
104
104
 
105
105
  testMode: asBoolean,
106
+
107
+ qualityInsights: asBoolean,
106
108
  };
107
109
 
108
110
  /**
@@ -16,7 +16,7 @@ export class DropArea extends UploaderBlock {
16
16
  '*collectionState': import("../../index.js").OutputCollectionState | null;
17
17
  '*groupInfo': import("@uploadcare/upload-client").UploadcareGroup | null;
18
18
  '*uploadTrigger': Set<string>;
19
- '*secureUploadsManager': import("../../abstract/SecureUploadsManager.js").SecureUploadsManager | null;
19
+ '*secureUploadsManager': import("../../abstract/managers/SecureUploadsManager.js").SecureUploadsManager | null;
20
20
  '*currentActivity': null;
21
21
  '*currentActivityParams': {};
22
22
  '*history': never[];