@atlaskit/media-card 72.1.0 → 73.2.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.
- package/CHANGELOG.md +89 -0
- package/dist/cjs/actions.js +2 -2
- package/dist/cjs/errors.js +11 -7
- package/dist/cjs/files/cardImageView/cardOverlay/styled.js +1 -1
- package/dist/cjs/files/cardImageView/index.js +52 -42
- package/dist/cjs/files/cardImageView/styled.js +1 -1
- package/dist/cjs/index.js +8 -8
- package/dist/cjs/root/card/cardAnalytics.js +2 -2
- package/dist/cjs/root/card/cardState.js +2 -2
- package/dist/cjs/root/card/getCardPreview/cache.js +5 -5
- package/dist/cjs/root/card/getCardPreview/filePreviewStatus.js +4 -1
- package/dist/cjs/root/card/getCardPreview/helpers.js +1 -1
- package/dist/cjs/root/card/getCardPreview/index.js +18 -9
- package/dist/cjs/root/card/getCardStatus.js +1 -1
- package/dist/cjs/root/card/index.js +279 -159
- package/dist/cjs/root/cardView.js +130 -118
- package/dist/cjs/root/inline/loader.js +45 -14
- package/dist/cjs/root/inline/mediaInlineCard.js +24 -9
- package/dist/cjs/root/inlinePlayer.js +80 -25
- package/dist/cjs/root/styled.js +7 -3
- package/dist/cjs/root/ui/actionsBar/styled.js +1 -1
- package/dist/cjs/root/ui/blanket/styled.js +1 -1
- package/dist/cjs/root/ui/common.js +1 -1
- package/dist/cjs/root/ui/iconMessage/index.js +5 -3
- package/dist/cjs/root/ui/iconWrapper/styled.js +1 -1
- package/dist/cjs/root/ui/imageRenderer/imageRenderer.js +14 -6
- package/dist/cjs/root/ui/loadingRateLimited/loadingRateLimited.js +4 -2
- package/dist/cjs/root/ui/loadingRateLimited/styled.js +2 -2
- package/dist/cjs/root/ui/playButton/styled.js +1 -1
- package/dist/cjs/root/ui/progressBar/progressBar.js +5 -2
- package/dist/cjs/root/ui/progressBar/styled.js +7 -6
- package/dist/cjs/root/ui/styled.js +6 -6
- package/dist/cjs/root/ui/tickBox/styled.js +1 -1
- package/dist/cjs/root/ui/titleBox/failedTitleBox.js +4 -2
- package/dist/cjs/root/ui/titleBox/styled.js +1 -1
- package/dist/cjs/root/ui/titleBox/titleBox.js +2 -2
- package/dist/cjs/styles/index.js +25 -23
- package/dist/cjs/styles/mixins.js +1 -1
- package/dist/cjs/types.js +10 -1
- package/dist/cjs/utils/analytics.js +24 -7
- package/dist/cjs/utils/breakpoint.js +1 -1
- package/dist/cjs/utils/cardActions/cardActionsDropdownMenu.js +3 -1
- package/dist/cjs/utils/cardActions/index.js +10 -10
- package/dist/cjs/utils/cardActions/styled.js +1 -1
- package/dist/cjs/utils/cardDimensions.js +1 -1
- package/dist/cjs/utils/dimensionComparer.js +7 -13
- package/dist/cjs/utils/getErrorMessage.js +2 -2
- package/dist/cjs/utils/getMediaCardCursor.js +29 -0
- package/dist/cjs/utils/globalScope/getSSRData.js +20 -0
- package/dist/cjs/utils/globalScope/globalScope.js +94 -0
- package/dist/cjs/utils/globalScope/index.js +39 -0
- package/dist/cjs/utils/globalScope/types.js +5 -0
- package/dist/cjs/utils/index.js +46 -46
- package/dist/cjs/utils/lightCards/styled.js +1 -1
- package/dist/cjs/utils/objectURLCache.js +1 -1
- package/dist/cjs/utils/printScript.js +44 -0
- package/dist/cjs/utils/viewportDetector.js +49 -22
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/files/cardImageView/index.js +19 -5
- package/dist/es2019/root/card/cardAnalytics.js +1 -1
- package/dist/es2019/root/card/getCardPreview/filePreviewStatus.js +4 -1
- package/dist/es2019/root/card/getCardPreview/index.js +1 -0
- package/dist/es2019/root/card/index.js +150 -49
- package/dist/es2019/root/cardView.js +40 -30
- package/dist/es2019/root/inline/loader.js +15 -4
- package/dist/es2019/root/inline/mediaInlineCard.js +23 -8
- package/dist/es2019/root/inlinePlayer.js +59 -5
- package/dist/es2019/root/styled.js +2 -1
- package/dist/es2019/root/ui/iconMessage/index.js +3 -2
- package/dist/es2019/root/ui/imageRenderer/imageRenderer.js +14 -6
- package/dist/es2019/root/ui/loadingRateLimited/loadingRateLimited.js +3 -2
- package/dist/es2019/root/ui/loadingRateLimited/styled.js +1 -1
- package/dist/es2019/root/ui/progressBar/progressBar.js +4 -2
- package/dist/es2019/root/ui/progressBar/styled.js +6 -4
- package/dist/es2019/root/ui/styled.js +5 -5
- package/dist/es2019/root/ui/titleBox/failedTitleBox.js +3 -2
- package/dist/es2019/root/ui/titleBox/titleBox.js +1 -1
- package/dist/es2019/types.js +7 -1
- package/dist/es2019/utils/analytics.js +8 -3
- package/dist/es2019/utils/dimensionComparer.js +6 -13
- package/dist/es2019/utils/getErrorMessage.js +1 -1
- package/dist/es2019/utils/getMediaCardCursor.js +19 -0
- package/dist/es2019/utils/globalScope/getSSRData.js +10 -0
- package/dist/es2019/utils/globalScope/globalScope.js +62 -0
- package/dist/es2019/utils/globalScope/index.js +2 -0
- package/dist/es2019/utils/globalScope/types.js +1 -0
- package/dist/es2019/utils/printScript.js +19 -0
- package/dist/es2019/utils/viewportDetector.js +48 -18
- package/dist/es2019/version.json +1 -1
- package/dist/esm/actions.js +2 -2
- package/dist/esm/errors.js +6 -5
- package/dist/esm/files/cardImageView/index.js +53 -41
- package/dist/esm/root/card/cardAnalytics.js +1 -1
- package/dist/esm/root/card/cardState.js +2 -2
- package/dist/esm/root/card/getCardPreview/cache.js +3 -2
- package/dist/esm/root/card/getCardPreview/filePreviewStatus.js +4 -1
- package/dist/esm/root/card/getCardPreview/index.js +5 -2
- package/dist/esm/root/card/index.js +266 -145
- package/dist/esm/root/cardView.js +128 -117
- package/dist/esm/root/inline/loader.js +46 -14
- package/dist/esm/root/inline/mediaInlineCard.js +23 -8
- package/dist/esm/root/inlinePlayer.js +77 -24
- package/dist/esm/root/styled.js +3 -2
- package/dist/esm/root/ui/iconMessage/index.js +3 -2
- package/dist/esm/root/ui/imageRenderer/imageRenderer.js +14 -6
- package/dist/esm/root/ui/loadingRateLimited/loadingRateLimited.js +3 -2
- package/dist/esm/root/ui/loadingRateLimited/styled.js +1 -1
- package/dist/esm/root/ui/progressBar/progressBar.js +5 -2
- package/dist/esm/root/ui/progressBar/styled.js +6 -5
- package/dist/esm/root/ui/styled.js +5 -5
- package/dist/esm/root/ui/titleBox/failedTitleBox.js +3 -2
- package/dist/esm/root/ui/titleBox/titleBox.js +1 -1
- package/dist/esm/types.js +7 -1
- package/dist/esm/utils/analytics.js +17 -6
- package/dist/esm/utils/cardActions/cardActionsDropdownMenu.js +2 -1
- package/dist/esm/utils/dimensionComparer.js +8 -13
- package/dist/esm/utils/getErrorMessage.js +1 -1
- package/dist/esm/utils/getMediaCardCursor.js +19 -0
- package/dist/esm/utils/globalScope/getSSRData.js +10 -0
- package/dist/esm/utils/globalScope/globalScope.js +69 -0
- package/dist/esm/utils/globalScope/index.js +2 -0
- package/dist/esm/utils/globalScope/types.js +1 -0
- package/dist/esm/utils/printScript.js +30 -0
- package/dist/esm/utils/viewportDetector.js +48 -21
- package/dist/esm/version.json +1 -1
- package/dist/types/errors.d.ts +1 -1
- package/dist/types/files/cardImageView/index.d.ts +6 -2
- package/dist/types/index.d.ts +1 -0
- package/dist/types/root/card/cardLoader.d.ts +2 -2
- package/dist/types/root/card/getCardPreview/index.d.ts +1 -0
- package/dist/types/root/card/index.d.ts +10 -9
- package/dist/types/root/cardView.d.ts +10 -8
- package/dist/types/root/inline/loader.d.ts +2 -0
- package/dist/types/root/inline/mediaInlineCard.d.ts +3 -5
- package/dist/types/root/inlinePlayer.d.ts +10 -1
- package/dist/types/root/styled.d.ts +1 -0
- package/dist/types/root/ui/iconMessage/index.d.ts +2 -2
- package/dist/types/root/ui/imageRenderer/imageRenderer.d.ts +4 -4
- package/dist/types/root/ui/loadingRateLimited/loadingRateLimited.d.ts +1 -0
- package/dist/types/root/ui/playButton/playButton.d.ts +1 -0
- package/dist/types/root/ui/progressBar/progressBar.d.ts +3 -1
- package/dist/types/root/ui/progressBar/styled.d.ts +2 -1
- package/dist/types/root/ui/styled.d.ts +2 -1
- package/dist/types/root/ui/tickBox/tickBox.d.ts +1 -0
- package/dist/types/root/ui/titleBox/failedTitleBox.d.ts +2 -2
- package/dist/types/root/ui/titleBox/titleBox.d.ts +1 -9
- package/dist/types/types.d.ts +6 -1
- package/dist/types/utils/analytics.d.ts +6 -0
- package/dist/types/utils/getErrorMessage.d.ts +1 -0
- package/dist/types/utils/getMediaCardCursor.d.ts +2 -0
- package/dist/types/utils/globalScope/getSSRData.d.ts +3 -0
- package/dist/types/utils/globalScope/globalScope.d.ts +21 -0
- package/dist/types/utils/globalScope/index.d.ts +4 -0
- package/dist/types/utils/globalScope/types.d.ts +8 -0
- package/dist/types/utils/printScript.d.ts +2 -0
- package/dist/types/utils/viewportDetector.d.ts +13 -5
- package/package.json +14 -16
- package/dist/cjs/utils/lazyContent/index.js +0 -56
- package/dist/cjs/utils/lazyContent/styled.js +0 -23
- package/dist/es2019/utils/lazyContent/index.js +0 -18
- package/dist/es2019/utils/lazyContent/styled.js +0 -12
- package/dist/esm/utils/lazyContent/index.js +0 -41
- package/dist/esm/utils/lazyContent/styled.js +0 -14
- package/dist/types/utils/lazyContent/index.d.ts +0 -11
- package/dist/types/utils/lazyContent/styled.d.ts +0 -5
|
@@ -20,6 +20,10 @@ import { CustomMediaPlayer, InactivityDetector } from '@atlaskit/media-ui';
|
|
|
20
20
|
import { InlinePlayerWrapper } from './styled';
|
|
21
21
|
import { defaultImageCardDimensions } from '..';
|
|
22
22
|
import { CardLoading } from '../utils/lightCards/cardLoading';
|
|
23
|
+
import { ProgressBar } from './ui/progressBar/progressBar';
|
|
24
|
+
import { calcBreakpointSize } from './ui/styled';
|
|
25
|
+
import { isValidPercentageUnit } from '../utils/isValidPercentageUnit';
|
|
26
|
+
import { getElementDimension } from '../utils/getElementDimension';
|
|
23
27
|
export var inlinePlayerClassName = 'media-card-inline-player';
|
|
24
28
|
export var getPreferredVideoArtifact = function getPreferredVideoArtifact(fileState) {
|
|
25
29
|
if (fileState.status === 'processed' || fileState.status === 'processing') {
|
|
@@ -52,6 +56,8 @@ export var InlinePlayerBase = /*#__PURE__*/function (_Component) {
|
|
|
52
56
|
|
|
53
57
|
_defineProperty(_assertThisInitialized(_this), "state", {});
|
|
54
58
|
|
|
59
|
+
_defineProperty(_assertThisInitialized(_this), "divRef", /*#__PURE__*/React.createRef());
|
|
60
|
+
|
|
55
61
|
_defineProperty(_assertThisInitialized(_this), "setFileSrc", function (fileSrc) {
|
|
56
62
|
_this.setState({
|
|
57
63
|
fileSrc: fileSrc
|
|
@@ -126,6 +132,24 @@ export var InlinePlayerBase = /*#__PURE__*/function (_Component) {
|
|
|
126
132
|
});
|
|
127
133
|
});
|
|
128
134
|
|
|
135
|
+
_defineProperty(_assertThisInitialized(_this), "saveElementWidth", function () {
|
|
136
|
+
var dimensions = _this.props.dimensions;
|
|
137
|
+
|
|
138
|
+
if (!dimensions) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
var width = dimensions.width;
|
|
143
|
+
|
|
144
|
+
if (width && isValidPercentageUnit(width) && !!_this.divRef.current) {
|
|
145
|
+
var elementWidth = getElementDimension(_this.divRef.current, 'width');
|
|
146
|
+
|
|
147
|
+
_this.setState({
|
|
148
|
+
elementWidth: elementWidth
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
|
|
129
153
|
return _this;
|
|
130
154
|
}
|
|
131
155
|
|
|
@@ -134,6 +158,7 @@ export var InlinePlayerBase = /*#__PURE__*/function (_Component) {
|
|
|
134
158
|
value: function componentDidMount() {
|
|
135
159
|
var _this2 = this;
|
|
136
160
|
|
|
161
|
+
this.saveElementWidth();
|
|
137
162
|
var _this$props3 = this.props,
|
|
138
163
|
mediaClient = _this$props3.mediaClient,
|
|
139
164
|
identifier = _this$props3.identifier;
|
|
@@ -152,30 +177,41 @@ export var InlinePlayerBase = /*#__PURE__*/function (_Component) {
|
|
|
152
177
|
while (1) {
|
|
153
178
|
switch (_context2.prev = _context2.next) {
|
|
154
179
|
case 0:
|
|
180
|
+
if (fileState.status === 'uploading') {
|
|
181
|
+
_this2.setState({
|
|
182
|
+
isUploading: true,
|
|
183
|
+
progress: fileState.progress
|
|
184
|
+
});
|
|
185
|
+
} else {
|
|
186
|
+
_this2.setState({
|
|
187
|
+
isUploading: false
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
|
|
155
191
|
existingFileSrc = _this2.state.fileSrc; // we want to reuse the existing fileSrc to prevent re renders
|
|
156
192
|
|
|
157
193
|
if (!existingFileSrc) {
|
|
158
|
-
_context2.next =
|
|
194
|
+
_context2.next = 4;
|
|
159
195
|
break;
|
|
160
196
|
}
|
|
161
197
|
|
|
162
198
|
return _context2.abrupt("return");
|
|
163
199
|
|
|
164
|
-
case
|
|
200
|
+
case 4:
|
|
165
201
|
if (!(fileState.status !== 'error' && fileState.preview)) {
|
|
166
|
-
_context2.next =
|
|
202
|
+
_context2.next = 13;
|
|
167
203
|
break;
|
|
168
204
|
}
|
|
169
205
|
|
|
170
|
-
_context2.next =
|
|
206
|
+
_context2.next = 7;
|
|
171
207
|
return fileState.preview;
|
|
172
208
|
|
|
173
|
-
case
|
|
209
|
+
case 7:
|
|
174
210
|
_yield$fileState$prev = _context2.sent;
|
|
175
211
|
value = _yield$fileState$prev.value;
|
|
176
212
|
|
|
177
213
|
if (!(value instanceof Blob && value.type.indexOf('video/') === 0)) {
|
|
178
|
-
_context2.next =
|
|
214
|
+
_context2.next = 13;
|
|
179
215
|
break;
|
|
180
216
|
}
|
|
181
217
|
|
|
@@ -185,9 +221,9 @@ export var InlinePlayerBase = /*#__PURE__*/function (_Component) {
|
|
|
185
221
|
|
|
186
222
|
return _context2.abrupt("return");
|
|
187
223
|
|
|
188
|
-
case
|
|
224
|
+
case 13:
|
|
189
225
|
if (!(fileState.status === 'processed' || fileState.status === 'processing')) {
|
|
190
|
-
_context2.next =
|
|
226
|
+
_context2.next = 30;
|
|
191
227
|
break;
|
|
192
228
|
}
|
|
193
229
|
|
|
@@ -195,7 +231,7 @@ export var InlinePlayerBase = /*#__PURE__*/function (_Component) {
|
|
|
195
231
|
artifacts = fileState.artifacts;
|
|
196
232
|
|
|
197
233
|
if (!(!artifactName || !artifacts)) {
|
|
198
|
-
_context2.next =
|
|
234
|
+
_context2.next = 19;
|
|
199
235
|
break;
|
|
200
236
|
}
|
|
201
237
|
|
|
@@ -203,34 +239,34 @@ export var InlinePlayerBase = /*#__PURE__*/function (_Component) {
|
|
|
203
239
|
|
|
204
240
|
return _context2.abrupt("return");
|
|
205
241
|
|
|
206
|
-
case
|
|
207
|
-
_context2.prev =
|
|
208
|
-
_context2.next =
|
|
242
|
+
case 19:
|
|
243
|
+
_context2.prev = 19;
|
|
244
|
+
_context2.next = 22;
|
|
209
245
|
return mediaClient.file.getArtifactURL(artifacts, artifactName, collectionName);
|
|
210
246
|
|
|
211
|
-
case
|
|
247
|
+
case 22:
|
|
212
248
|
_fileSrc = _context2.sent;
|
|
213
249
|
|
|
214
250
|
_this2.setFileSrc(_fileSrc);
|
|
215
251
|
|
|
216
|
-
_context2.next =
|
|
252
|
+
_context2.next = 30;
|
|
217
253
|
break;
|
|
218
254
|
|
|
219
|
-
case
|
|
220
|
-
_context2.prev =
|
|
221
|
-
_context2.t0 = _context2["catch"](
|
|
255
|
+
case 26:
|
|
256
|
+
_context2.prev = 26;
|
|
257
|
+
_context2.t0 = _context2["catch"](19);
|
|
222
258
|
onError = _this2.props.onError;
|
|
223
259
|
|
|
224
260
|
if (onError) {
|
|
225
261
|
onError(_context2.t0);
|
|
226
262
|
}
|
|
227
263
|
|
|
228
|
-
case
|
|
264
|
+
case 30:
|
|
229
265
|
case "end":
|
|
230
266
|
return _context2.stop();
|
|
231
267
|
}
|
|
232
268
|
}
|
|
233
|
-
}, _callee2, null, [[
|
|
269
|
+
}, _callee2, null, [[19, 26]]);
|
|
234
270
|
}));
|
|
235
271
|
|
|
236
272
|
function next(_x) {
|
|
@@ -247,6 +283,12 @@ export var InlinePlayerBase = /*#__PURE__*/function (_Component) {
|
|
|
247
283
|
this.unsubscribe();
|
|
248
284
|
this.revoke();
|
|
249
285
|
}
|
|
286
|
+
}, {
|
|
287
|
+
key: "breakpoint",
|
|
288
|
+
get: function get() {
|
|
289
|
+
var width = this.state.elementWidth || (this.props.dimensions ? this.props.dimensions.width : '') || defaultImageCardDimensions.width;
|
|
290
|
+
return calcBreakpointSize(parseInt("".concat(width), 10));
|
|
291
|
+
}
|
|
250
292
|
}, {
|
|
251
293
|
key: "render",
|
|
252
294
|
value: function render() {
|
|
@@ -259,8 +301,13 @@ export var InlinePlayerBase = /*#__PURE__*/function (_Component) {
|
|
|
259
301
|
selected = _this$props4.selected,
|
|
260
302
|
testId = _this$props4.testId,
|
|
261
303
|
identifier = _this$props4.identifier,
|
|
262
|
-
forwardRef = _this$props4.forwardRef
|
|
263
|
-
|
|
304
|
+
forwardRef = _this$props4.forwardRef,
|
|
305
|
+
autoplay = _this$props4.autoplay,
|
|
306
|
+
cardPreview = _this$props4.cardPreview;
|
|
307
|
+
var _this$state = this.state,
|
|
308
|
+
fileSrc = _this$state.fileSrc,
|
|
309
|
+
isUploading = _this$state.isUploading,
|
|
310
|
+
progress = _this$state.progress;
|
|
264
311
|
|
|
265
312
|
if (!fileSrc) {
|
|
266
313
|
return /*#__PURE__*/React.createElement(CardLoading, {
|
|
@@ -281,7 +328,7 @@ export var InlinePlayerBase = /*#__PURE__*/function (_Component) {
|
|
|
281
328
|
type: "video",
|
|
282
329
|
src: fileSrc,
|
|
283
330
|
fileId: identifier.id,
|
|
284
|
-
isAutoPlay:
|
|
331
|
+
isAutoPlay: autoplay,
|
|
285
332
|
isHDAvailable: false,
|
|
286
333
|
onDownloadClick: _this3.onDownloadClick,
|
|
287
334
|
onFirstPlay: _this3.onFirstPlay,
|
|
@@ -289,9 +336,15 @@ export var InlinePlayerBase = /*#__PURE__*/function (_Component) {
|
|
|
289
336
|
contentId: identifier.id
|
|
290
337
|
},
|
|
291
338
|
originalDimensions: originalDimensions,
|
|
292
|
-
showControls: checkMouseMovement
|
|
339
|
+
showControls: checkMouseMovement,
|
|
340
|
+
poster: cardPreview === null || cardPreview === void 0 ? void 0 : cardPreview.dataURI
|
|
293
341
|
});
|
|
294
|
-
})
|
|
342
|
+
}), isUploading ? /*#__PURE__*/React.createElement(ProgressBar, {
|
|
343
|
+
progress: progress,
|
|
344
|
+
breakpoint: this.breakpoint,
|
|
345
|
+
positionBottom: true,
|
|
346
|
+
showOnTop: true
|
|
347
|
+
}) : null);
|
|
295
348
|
}
|
|
296
349
|
}]);
|
|
297
350
|
|
package/dist/esm/root/styled.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
2
|
|
|
3
|
-
var _templateObject, _templateObject2;
|
|
3
|
+
var _templateObject, _templateObject2, _templateObject3;
|
|
4
4
|
|
|
5
5
|
import styled from 'styled-components';
|
|
6
6
|
import { borderRadius } from '@atlaskit/theme/constants';
|
|
@@ -32,4 +32,5 @@ export var InlinePlayerWrapper = styled.div(_templateObject2 || (_templateObject
|
|
|
32
32
|
}, function (props) {
|
|
33
33
|
return getDimensionsWithDefault(props.dimensions).height || 'auto';
|
|
34
34
|
}, borderRadius(), getSelectedBorderStyle);
|
|
35
|
-
InlinePlayerWrapper.displayName = 'InlinePlayerWrapper';
|
|
35
|
+
InlinePlayerWrapper.displayName = 'InlinePlayerWrapper';
|
|
36
|
+
export var FormattedMessageWrapper = styled.span(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral([""])));
|
|
@@ -2,7 +2,8 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { IconMessageWrapper } from './styled';
|
|
4
4
|
import { messages } from '@atlaskit/media-ui';
|
|
5
|
-
import { FormattedMessage } from 'react-intl';
|
|
5
|
+
import { FormattedMessage } from 'react-intl-next';
|
|
6
|
+
import { FormattedMessageWrapper } from '../../styled';
|
|
6
7
|
export var IconMessage = function IconMessage(_ref) {
|
|
7
8
|
var messageDescriptor = _ref.messageDescriptor,
|
|
8
9
|
_ref$animated = _ref.animated,
|
|
@@ -12,7 +13,7 @@ export var IconMessage = function IconMessage(_ref) {
|
|
|
12
13
|
return /*#__PURE__*/React.createElement(IconMessageWrapper, {
|
|
13
14
|
animated: animated,
|
|
14
15
|
reducedFont: reducedFont
|
|
15
|
-
}, /*#__PURE__*/React.createElement(FormattedMessage, messageDescriptor));
|
|
16
|
+
}, /*#__PURE__*/React.createElement(FormattedMessageWrapper, null, /*#__PURE__*/React.createElement(FormattedMessage, messageDescriptor)));
|
|
16
17
|
};
|
|
17
18
|
export var CreatingPreview = function CreatingPreview(_ref2) {
|
|
18
19
|
var disableAnimation = _ref2.disableAnimation;
|
|
@@ -3,8 +3,7 @@ import React, { useEffect } from 'react';
|
|
|
3
3
|
import { MediaImage } from '@atlaskit/media-ui';
|
|
4
4
|
import { resizeModeToMediaImageProps } from '../../../utils/resizeModeToMediaImageProps';
|
|
5
5
|
export var ImageRenderer = function ImageRenderer(_ref) {
|
|
6
|
-
var
|
|
7
|
-
previewOrientation = _ref.previewOrientation,
|
|
6
|
+
var cardPreview = _ref.cardPreview,
|
|
8
7
|
alt = _ref.alt,
|
|
9
8
|
resizeMode = _ref.resizeMode,
|
|
10
9
|
onImageLoad = _ref.onImageLoad,
|
|
@@ -19,12 +18,21 @@ export var ImageRenderer = function ImageRenderer(_ref) {
|
|
|
19
18
|
onDisplayImage();
|
|
20
19
|
}
|
|
21
20
|
}, [mediaType, onDisplayImage]);
|
|
21
|
+
|
|
22
|
+
var onLoad = function onLoad() {
|
|
23
|
+
onImageLoad && onImageLoad(cardPreview);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
var onError = function onError() {
|
|
27
|
+
onImageError && onImageError(cardPreview);
|
|
28
|
+
};
|
|
29
|
+
|
|
22
30
|
return /*#__PURE__*/React.createElement(MediaImage, _extends({
|
|
23
|
-
dataURI: dataURI,
|
|
31
|
+
dataURI: cardPreview.dataURI,
|
|
24
32
|
alt: alt,
|
|
25
|
-
previewOrientation:
|
|
26
|
-
onImageLoad:
|
|
27
|
-
onImageError:
|
|
33
|
+
previewOrientation: cardPreview.orientation,
|
|
34
|
+
onImageLoad: onLoad,
|
|
35
|
+
onImageError: onError,
|
|
28
36
|
loading: nativeLazyLoad ? 'lazy' : undefined,
|
|
29
37
|
forceSyncDisplay: forceSyncDisplay
|
|
30
38
|
}, resizeModeToMediaImageProps(resizeMode)));
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { errorIcon } from '@atlaskit/media-ui/errorIcon';
|
|
3
3
|
import { WarningIconWrapper, LoadingRateLimitedContainer, CouldntLoadWrapper, ErrorWrapper, LoadingRateLimitedTextWrapper } from './styled';
|
|
4
|
+
import { FormattedMessageWrapper } from '../../styled';
|
|
4
5
|
import { messages } from '@atlaskit/media-ui';
|
|
5
|
-
import { FormattedMessage } from 'react-intl';
|
|
6
|
+
import { FormattedMessage } from 'react-intl-next';
|
|
6
7
|
import { Breakpoint } from '../common';
|
|
7
8
|
export var LoadingRateLimited = function LoadingRateLimited(_ref) {
|
|
8
9
|
var _ref$breakpoint = _ref.breakpoint,
|
|
@@ -12,5 +13,5 @@ export var LoadingRateLimited = function LoadingRateLimited(_ref) {
|
|
|
12
13
|
return /*#__PURE__*/React.createElement(LoadingRateLimitedContainer, null, /*#__PURE__*/React.createElement(WarningIconWrapper, null, errorIcon), /*#__PURE__*/React.createElement(LoadingRateLimitedTextWrapper, {
|
|
13
14
|
breakpoint: breakpoint,
|
|
14
15
|
positionBottom: positionBottom
|
|
15
|
-
}, /*#__PURE__*/React.createElement(CouldntLoadWrapper, null, /*#__PURE__*/React.createElement(FormattedMessage, messages.couldnt_load_file)), /*#__PURE__*/React.createElement(ErrorWrapper, null, /*#__PURE__*/React.createElement(FormattedMessage, messages.error_429))));
|
|
16
|
+
}, /*#__PURE__*/React.createElement(CouldntLoadWrapper, null, /*#__PURE__*/React.createElement(FormattedMessageWrapper, null, /*#__PURE__*/React.createElement(FormattedMessage, messages.couldnt_load_file))), /*#__PURE__*/React.createElement(ErrorWrapper, null, /*#__PURE__*/React.createElement(FormattedMessageWrapper, null, /*#__PURE__*/React.createElement(FormattedMessage, messages.error_429)))));
|
|
16
17
|
};
|
|
@@ -10,7 +10,7 @@ export var WarningIconWrapper = styled.div(_templateObject2 || (_templateObject2
|
|
|
10
10
|
export var LoadingRateLimitedTextWrapper = styled.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n ", "\n"])), function (_ref) {
|
|
11
11
|
var breakpoint = _ref.breakpoint,
|
|
12
12
|
positionBottom = _ref.positionBottom;
|
|
13
|
-
return "\n margin-top: 10px;\n overflow: hidden;\n color: ".concat(N300, ";\n display: block;\n width:100%;\n text-align:center;\n ").concat(generateResponsiveStyles(breakpoint, positionBottom, 1), "\n ");
|
|
13
|
+
return "\n margin-top: 10px;\n overflow: hidden;\n color: ".concat(N300, ";\n display: block;\n width:100%;\n text-align:center;\n ").concat(generateResponsiveStyles(breakpoint, positionBottom, false, 1), "\n ");
|
|
14
14
|
});
|
|
15
15
|
LoadingRateLimitedTextWrapper.displayName = 'LoadingRateLimitedTextWrapper';
|
|
16
16
|
export var CouldntLoadWrapper = styled.div(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n font-weight: 550;\n"])));
|
|
@@ -6,11 +6,14 @@ export var ProgressBar = function ProgressBar(_ref) {
|
|
|
6
6
|
_ref$breakpoint = _ref.breakpoint,
|
|
7
7
|
breakpoint = _ref$breakpoint === void 0 ? Breakpoint.SMALL : _ref$breakpoint,
|
|
8
8
|
_ref$positionBottom = _ref.positionBottom,
|
|
9
|
-
positionBottom = _ref$positionBottom === void 0 ? false : _ref$positionBottom
|
|
9
|
+
positionBottom = _ref$positionBottom === void 0 ? false : _ref$positionBottom,
|
|
10
|
+
_ref$showOnTop = _ref.showOnTop,
|
|
11
|
+
showOnTop = _ref$showOnTop === void 0 ? false : _ref$showOnTop;
|
|
10
12
|
var normalizedProgress = Math.min(1, Math.max(0, progress || 0)) * 100;
|
|
11
13
|
return /*#__PURE__*/React.createElement(StyledBar, {
|
|
12
14
|
progress: normalizedProgress,
|
|
13
15
|
breakpoint: breakpoint,
|
|
14
|
-
positionBottom: positionBottom
|
|
16
|
+
positionBottom: positionBottom,
|
|
17
|
+
showOnTop: showOnTop
|
|
15
18
|
});
|
|
16
19
|
};
|
|
@@ -19,17 +19,18 @@ var smallSizeSettings = {
|
|
|
19
19
|
var largeSizeSettings = {
|
|
20
20
|
marginBottom: 12
|
|
21
21
|
};
|
|
22
|
-
export function generateResponsiveStyles(breakpoint, positionBottom) {
|
|
23
|
-
var multiplier = arguments.length >
|
|
22
|
+
export function generateResponsiveStyles(breakpoint, positionBottom, showOnTop) {
|
|
23
|
+
var multiplier = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
|
|
24
24
|
var setting = breakpoint === Breakpoint.SMALL ? smallSizeSettings : largeSizeSettings;
|
|
25
25
|
var marginPositionBottom = responsiveSettings[breakpoint].titleBox.verticalPadding;
|
|
26
26
|
var marginBottom = setting.marginBottom * multiplier + (positionBottom ? marginPositionBottom : getTitleBoxHeight(breakpoint));
|
|
27
|
-
return "\n bottom: ".concat(marginBottom, "px\n ");
|
|
27
|
+
return "\n ".concat(showOnTop ? 'top' : 'bottom', ": ").concat(marginBottom, "px\n ");
|
|
28
28
|
}
|
|
29
29
|
export var StyledBar = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n ", "\n"])), function (_ref) {
|
|
30
30
|
var progress = _ref.progress,
|
|
31
31
|
breakpoint = _ref.breakpoint,
|
|
32
|
-
positionBottom = _ref.positionBottom
|
|
33
|
-
|
|
32
|
+
positionBottom = _ref.positionBottom,
|
|
33
|
+
showOnTop = _ref.showOnTop;
|
|
34
|
+
return "\n ".concat(borderRadius, "\n overflow: hidden;\n position: absolute;\n width: ").concat(width, "%;\n left: ").concat(left, "%;\n background-color: ").concat(rgba(N0, 0.8), ";\n height: ").concat(height + padding * 2, "px;\n padding: ").concat(padding, "px;\n box-sizing: border-box;\n\n ::before {\n content: '';\n width: ").concat(progress, "%;\n height: 100%;\n background-color: ").concat(N400, ";\n ").concat(borderRadius, "\n display: block;\n }\n\n ").concat(generateResponsiveStyles(breakpoint, positionBottom, showOnTop), "\n");
|
|
34
35
|
});
|
|
35
36
|
StyledBar.displayName = 'StyledProgressBar';
|
|
@@ -61,8 +61,8 @@ var getWrapperShadow = function getWrapperShadow(disableOverlay, selected) {
|
|
|
61
61
|
return shadow ? "box-shadow: ".concat(shadow, ";") : '';
|
|
62
62
|
};
|
|
63
63
|
|
|
64
|
-
var getCursorStyle = function getCursorStyle(
|
|
65
|
-
return "cursor: ".concat(
|
|
64
|
+
var getCursorStyle = function getCursorStyle(cursor) {
|
|
65
|
+
return "cursor: ".concat(cursor, ";");
|
|
66
66
|
};
|
|
67
67
|
|
|
68
68
|
var getClickablePlayButtonStyles = function getClickablePlayButtonStyles(isPlayButtonClickable) {
|
|
@@ -85,14 +85,14 @@ export var NewFileExperienceWrapper = styled.div(_templateObject || (_templateOb
|
|
|
85
85
|
var breakpoint = _ref6.breakpoint,
|
|
86
86
|
dimensions = _ref6.dimensions,
|
|
87
87
|
appearance = _ref6.appearance,
|
|
88
|
-
shouldUsePointerCursor = _ref6.shouldUsePointerCursor,
|
|
89
88
|
disableOverlay = _ref6.disableOverlay,
|
|
90
89
|
displayBackground = _ref6.displayBackground,
|
|
91
90
|
selected = _ref6.selected,
|
|
92
91
|
isPlayButtonClickable = _ref6.isPlayButtonClickable,
|
|
93
92
|
isTickBoxSelectable = _ref6.isTickBoxSelectable,
|
|
94
|
-
shouldDisplayTooltip = _ref6.shouldDisplayTooltip
|
|
95
|
-
|
|
93
|
+
shouldDisplayTooltip = _ref6.shouldDisplayTooltip,
|
|
94
|
+
mediaCardCursor = _ref6.mediaCardCursor;
|
|
95
|
+
return "\n ".concat(transition(), "\n box-sizing: border-box;\n * {\n box-sizing: border-box;\n }\n position: relative;\n font-family: ").concat(fontFamily(), ";\n ").concat(getWrapperDimensions(dimensions, appearance), "\n ").concat(displayBackground ? "background-color: ".concat(N20, ";") : '', "\n ").concat(borderRadius, "\n ").concat(getCursorStyle(mediaCardCursor), "\n ").concat(getWrapperShadow(disableOverlay, selected), "\n ").concat(generateResponsiveStyles(breakpoint), "\n ").concat(hideNativeBrowserTextSelectionStyles, "\n\n /* We use classnames from here exceptionally to be able to handle styles when the Card is on hover */\n ").concat(getClickablePlayButtonStyles(isPlayButtonClickable), "\n ").concat(getSelectableTickBoxStyles(isTickBoxSelectable), "\n &:hover .").concat(blanketClassName, " {\n ").concat(fixedBlanketStyles, "\n }\n\n &:hover .").concat(actionsBarClassName, " {\n ").concat(fixedActionBarStyles, "\n }\n\n /* Tooltip does not support percentage dimensions. We enforce them here */\n ").concat(shouldDisplayTooltip ? "> div { width: 100%; height: 100% }" : '', "\n");
|
|
96
96
|
});
|
|
97
97
|
NewFileExperienceWrapper.displayName = 'NewFileExperienceWrapper';
|
|
98
98
|
export var CardImageContainer = styled.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n display: flex;\n position: relative;\n max-width: 100%;\n width: 100%;\n height: 100%;\n max-height: 100%;\n overflow: hidden;\n ", "\n"])), borderRadius);
|
|
@@ -3,7 +3,8 @@ import { TitleBoxWrapper, ErrorMessageWrapper } from './styled';
|
|
|
3
3
|
import EditorWarningIcon from '@atlaskit/icon/glyph/editor/warning';
|
|
4
4
|
import { messages } from '@atlaskit/media-ui';
|
|
5
5
|
import { R300 } from '@atlaskit/theme/colors';
|
|
6
|
-
import { FormattedMessage } from 'react-intl';
|
|
6
|
+
import { FormattedMessage } from 'react-intl-next';
|
|
7
|
+
import { FormattedMessageWrapper } from '../../styled';
|
|
7
8
|
export var FailedTitleBox = function FailedTitleBox(_ref) {
|
|
8
9
|
var breakpoint = _ref.breakpoint,
|
|
9
10
|
_ref$customMessage = _ref.customMessage,
|
|
@@ -14,5 +15,5 @@ export var FailedTitleBox = function FailedTitleBox(_ref) {
|
|
|
14
15
|
label: 'Warning',
|
|
15
16
|
size: 'small',
|
|
16
17
|
primaryColor: R300
|
|
17
|
-
}), /*#__PURE__*/React.createElement(FormattedMessage, customMessage)));
|
|
18
|
+
}), /*#__PURE__*/React.createElement(FormattedMessageWrapper, null, /*#__PURE__*/React.createElement(FormattedMessage, customMessage))));
|
|
18
19
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import LockFilledIcon from '@atlaskit/icon/glyph/lock-filled';
|
|
3
|
-
import { injectIntl } from 'react-intl';
|
|
3
|
+
import { injectIntl } from 'react-intl-next';
|
|
4
4
|
import { TitleBoxWrapper, TitleBoxHeader, TitleBoxFooter, TitleBoxIcon } from './styled';
|
|
5
5
|
import { Truncate } from '@atlaskit/media-ui/truncateText';
|
|
6
6
|
import { formatDate } from '@atlaskit/media-ui/formatDate';
|
package/dist/esm/types.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
|
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
+
|
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
+
|
|
1
7
|
import { getMediaClientErrorReason, isRequestError } from '@atlaskit/media-client';
|
|
2
8
|
import { ANALYTICS_MEDIA_CHANNEL } from '@atlaskit/media-common';
|
|
3
9
|
import { createAndFireEvent } from '@atlaskit/analytics-next';
|
|
@@ -89,20 +95,25 @@ export var getRenderErrorRequestMetadata = function getRenderErrorRequestMetadat
|
|
|
89
95
|
return error.secondaryError.metadata;
|
|
90
96
|
}
|
|
91
97
|
};
|
|
98
|
+
export var extractErrorInfo = function extractErrorInfo(error) {
|
|
99
|
+
return {
|
|
100
|
+
failReason: getRenderErrorFailReason(error),
|
|
101
|
+
error: getRenderErrorErrorReason(error),
|
|
102
|
+
errorDetail: getRenderErrorErrorDetail(error)
|
|
103
|
+
};
|
|
104
|
+
};
|
|
92
105
|
export var getRenderErrorEventPayload = function getRenderErrorEventPayload(fileAttributes, performanceAttributes, error) {
|
|
93
106
|
return {
|
|
94
107
|
eventType: 'operational',
|
|
95
108
|
action: 'failed',
|
|
96
109
|
actionSubject: 'mediaCardRender',
|
|
97
|
-
attributes: {
|
|
110
|
+
attributes: _objectSpread(_objectSpread({
|
|
98
111
|
fileAttributes: fileAttributes,
|
|
99
112
|
performanceAttributes: performanceAttributes,
|
|
100
|
-
status: 'fail'
|
|
101
|
-
|
|
102
|
-
error: getRenderErrorErrorReason(error),
|
|
103
|
-
errorDetail: getRenderErrorErrorDetail(error),
|
|
113
|
+
status: 'fail'
|
|
114
|
+
}, extractErrorInfo(error)), {}, {
|
|
104
115
|
request: getRenderErrorRequestMetadata(error)
|
|
105
|
-
}
|
|
116
|
+
})
|
|
106
117
|
};
|
|
107
118
|
};
|
|
108
119
|
export var getRenderFailedFileStatusPayload = function getRenderFailedFileStatusPayload(fileAttributes, performanceAttributes) {
|
|
@@ -5,6 +5,7 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
5
5
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
6
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
7
|
import _extends from "@babel/runtime/helpers/extends";
|
|
8
|
+
var _excluded = ["triggerRef"];
|
|
8
9
|
|
|
9
10
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
10
11
|
|
|
@@ -85,7 +86,7 @@ export var CardActionsDropdownMenu = /*#__PURE__*/function (_Component) {
|
|
|
85
86
|
onOpenChange: onOpenChange,
|
|
86
87
|
trigger: function trigger(_ref) {
|
|
87
88
|
var triggerRef = _ref.triggerRef,
|
|
88
|
-
providedProps = _objectWithoutProperties(_ref,
|
|
89
|
+
providedProps = _objectWithoutProperties(_ref, _excluded);
|
|
89
90
|
|
|
90
91
|
return /*#__PURE__*/React.createElement(CardActionButtonWithAnalytics, _extends({
|
|
91
92
|
variant: triggerVariant,
|
|
@@ -1,23 +1,18 @@
|
|
|
1
1
|
import { isValidPercentageUnit } from './isValidPercentageUnit';
|
|
2
2
|
import { containsPixelUnit } from './containsPixelUnit';
|
|
3
|
+
|
|
4
|
+
var isPixelEquivalent = function isPixelEquivalent(dimension) {
|
|
5
|
+
return typeof dimension === 'number' || containsPixelUnit("".concat(dimension));
|
|
6
|
+
};
|
|
7
|
+
|
|
3
8
|
export var canCompareDimension = function canCompareDimension(current, next) {
|
|
4
9
|
if (!current || !next) {
|
|
5
10
|
return false;
|
|
6
11
|
}
|
|
7
12
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (containsPixelUnit("".concat(current)) && containsPixelUnit("".concat(next))) {
|
|
13
|
-
return true;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
if (typeof current === 'number' && typeof next === 'number') {
|
|
17
|
-
return true;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return false;
|
|
13
|
+
var bothPixelEquivalent = isPixelEquivalent(current) && isPixelEquivalent(next);
|
|
14
|
+
var bothPercentage = isValidPercentageUnit(current) && isValidPercentageUnit(next);
|
|
15
|
+
return bothPixelEquivalent || bothPercentage;
|
|
21
16
|
};
|
|
22
17
|
export var isBigger = function isBigger(current, next) {
|
|
23
18
|
if (!!current && !!next && canCompareDimension(current.width, next.width) && canCompareDimension(current.height, next.height)) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { FormattedMessage } from 'react-intl';
|
|
2
|
+
import { FormattedMessage } from 'react-intl-next';
|
|
3
3
|
import { messages } from '@atlaskit/media-ui';
|
|
4
4
|
export var getErrorMessage = function getErrorMessage(status) {
|
|
5
5
|
return status === 'error' && /*#__PURE__*/React.createElement(FormattedMessage, messages.failed_to_load);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { MediaCardCursor } from '../types';
|
|
2
|
+
export var getMediaCardCursor = function getMediaCardCursor(useInlinePlayer, useMediaViewer, isErrorStatus, hasCardPreview, mediaType) {
|
|
3
|
+
// If error status or no action is requested = NoAction
|
|
4
|
+
if (isErrorStatus || !useInlinePlayer && !useMediaViewer) {
|
|
5
|
+
return MediaCardCursor.NoAction;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
if (!mediaType && (useInlinePlayer || useInlinePlayer && useMediaViewer)) {
|
|
9
|
+
return MediaCardCursor.NotReady;
|
|
10
|
+
} else if (mediaType === 'video' && hasCardPreview && useInlinePlayer) {
|
|
11
|
+
return MediaCardCursor.Action;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (useMediaViewer) {
|
|
15
|
+
return MediaCardCursor.Action;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return MediaCardCursor.NoAction;
|
|
19
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { printFunctionCall, printScript } from '../printScript';
|
|
3
|
+
// ----- WARNING -----
|
|
4
|
+
// This is a very sensitive fraction of code.
|
|
5
|
+
// Any changes to this file must be tested directly in product before merging.
|
|
6
|
+
// The scripts printed here might differ from what we observe in our internal tests
|
|
7
|
+
// due to minimification, for example.
|
|
8
|
+
export var GLOBAL_MEDIA_CARD_SSR = 'mediaCardSsr';
|
|
9
|
+
export var GLOBAL_MEDIA_NAMESPACE = '__MEDIA_INTERNAL';
|
|
10
|
+
export function getMediaGlobalScope() {
|
|
11
|
+
var globalScope = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window;
|
|
12
|
+
// Must match GLOBAL_MEDIA_NAMESPACE. Can't reference the constant from here.
|
|
13
|
+
var namespace = '__MEDIA_INTERNAL';
|
|
14
|
+
|
|
15
|
+
if (!globalScope[namespace]) {
|
|
16
|
+
globalScope[namespace] = {};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return globalScope[namespace];
|
|
20
|
+
}
|
|
21
|
+
export function getMediaCardSSR() {
|
|
22
|
+
var globalScope = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window;
|
|
23
|
+
var globalMedia = getMediaGlobalScope(globalScope); // Must match GLOBAL_MEDIA_CARD_SSR. Can't reference the constant from here.
|
|
24
|
+
|
|
25
|
+
var key = 'mediaCardSsr';
|
|
26
|
+
|
|
27
|
+
if (!globalMedia[key]) {
|
|
28
|
+
globalMedia[key] = {};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return globalMedia[key];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
var dashed = function dashed(param) {
|
|
35
|
+
return param ? "-".concat(param) : '';
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export var getKey = function getKey(_ref) {
|
|
39
|
+
var id = _ref.id,
|
|
40
|
+
collectionName = _ref.collectionName,
|
|
41
|
+
occurrenceKey = _ref.occurrenceKey;
|
|
42
|
+
return "".concat(id).concat(dashed(collectionName)).concat(dashed(occurrenceKey));
|
|
43
|
+
};
|
|
44
|
+
export var storeDataURI = function storeDataURI(key, dataURI, dimensions, error) {
|
|
45
|
+
var globalScope = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : window;
|
|
46
|
+
var mediaCardSsr = getMediaCardSSR(globalScope);
|
|
47
|
+
mediaCardSsr[key] = {
|
|
48
|
+
dataURI: dataURI,
|
|
49
|
+
dimensions: dimensions,
|
|
50
|
+
error: error
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
var generateScript = function generateScript(identifier, dataURI, dimensions, error) {
|
|
55
|
+
var functionCall = printFunctionCall(storeDataURI, getKey(identifier), dataURI, dimensions, error);
|
|
56
|
+
return printScript([getMediaCardSSR.toString(), getMediaGlobalScope.toString(), functionCall]);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export var StoreSSRDataScript = function StoreSSRDataScript(_ref2) {
|
|
60
|
+
var dataURI = _ref2.dataURI,
|
|
61
|
+
identifier = _ref2.identifier,
|
|
62
|
+
dimensions = _ref2.dimensions,
|
|
63
|
+
error = _ref2.error;
|
|
64
|
+
return /*#__PURE__*/React.createElement("script", {
|
|
65
|
+
dangerouslySetInnerHTML: {
|
|
66
|
+
__html: generateScript(identifier, dataURI, dimensions, error)
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|