@atlaskit/media-card 74.5.2 → 74.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/cjs/card/card.js +203 -123
- package/dist/cjs/card/getCardPreview/index.js +4 -2
- package/dist/cjs/card/media-card-analytics-error-boundary.js +1 -1
- package/dist/cjs/inline/mediaInlineAnalyticsErrorBoundary.js +1 -1
- package/dist/cjs/utils/ufoExperiences.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/card/card.js +99 -40
- package/dist/es2019/card/getCardPreview/index.js +4 -2
- package/dist/es2019/card/media-card-analytics-error-boundary.js +1 -1
- package/dist/es2019/inline/mediaInlineAnalyticsErrorBoundary.js +1 -1
- package/dist/es2019/utils/ufoExperiences.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/card/card.js +203 -123
- package/dist/esm/card/getCardPreview/index.js +4 -2
- package/dist/esm/card/media-card-analytics-error-boundary.js +1 -1
- package/dist/esm/inline/mediaInlineAnalyticsErrorBoundary.js +1 -1
- package/dist/esm/utils/ufoExperiences.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/card/card.d.ts +3 -0
- package/dist/types/card/getCardPreview/index.d.ts +2 -1
- package/dist/types/types.d.ts +1 -0
- package/package.json +7 -5
- package/report.api.md +2 -0
package/dist/es2019/card/card.js
CHANGED
|
@@ -26,7 +26,7 @@ import { getMediaCardCursor } from '../utils/getMediaCardCursor';
|
|
|
26
26
|
import { completeUfoExperience, startUfoExperience } from '../utils/ufoExperiences';
|
|
27
27
|
import { generateUniqueId } from '../utils/generateUniqueId';
|
|
28
28
|
const packageName = "@atlaskit/media-card";
|
|
29
|
-
const packageVersion = "74.
|
|
29
|
+
const packageVersion = "74.6.1";
|
|
30
30
|
export class CardBase extends Component {
|
|
31
31
|
// An internalOccurrenceKey is a randomly generated value to differentiate various instances
|
|
32
32
|
// of Cards regardless of whether it shares the same file (either internal or external)
|
|
@@ -117,11 +117,7 @@ export class CardBase extends Component {
|
|
|
117
117
|
};
|
|
118
118
|
});
|
|
119
119
|
_defineProperty(this, "setCacheSSRPreview", identifier => {
|
|
120
|
-
|
|
121
|
-
mediaClient,
|
|
122
|
-
dimensions = {}
|
|
123
|
-
} = this.props;
|
|
124
|
-
fetchAndCacheRemotePreview(mediaClient, identifier.id, dimensions, this.getImageURLParams(identifier), this.getMediaBlobUrlAttrs(identifier)).catch(() => {
|
|
120
|
+
this.fetchAndCacheRemotePreview(identifier).catch(() => {
|
|
125
121
|
// No need to log this error.
|
|
126
122
|
// If preview fails, it will be refetched later
|
|
127
123
|
//TODO: test this catch
|
|
@@ -129,12 +125,8 @@ export class CardBase extends Component {
|
|
|
129
125
|
});
|
|
130
126
|
});
|
|
131
127
|
_defineProperty(this, "refetchSSRPreview", async identifier => {
|
|
132
|
-
const {
|
|
133
|
-
mediaClient,
|
|
134
|
-
dimensions = {}
|
|
135
|
-
} = this.props;
|
|
136
128
|
try {
|
|
137
|
-
const cardPreview = await
|
|
129
|
+
const cardPreview = await this.fetchAndCacheRemotePreview(identifier);
|
|
138
130
|
this.safeSetState({
|
|
139
131
|
cardPreview
|
|
140
132
|
});
|
|
@@ -143,6 +135,44 @@ export class CardBase extends Component {
|
|
|
143
135
|
this.fireNonCriticalErrorEvent(wrappedError);
|
|
144
136
|
}
|
|
145
137
|
});
|
|
138
|
+
_defineProperty(this, "resolveUpfrontPreview", async identifier => {
|
|
139
|
+
const requestedDimensions = {
|
|
140
|
+
...this.props.dimensions
|
|
141
|
+
};
|
|
142
|
+
try {
|
|
143
|
+
const cardPreview = await this.fetchAndCacheRemotePreview(identifier);
|
|
144
|
+
const {
|
|
145
|
+
dimensions: currentDimensions
|
|
146
|
+
} = this.props;
|
|
147
|
+
const areValidRequestedDimensions = !isBigger(requestedDimensions, currentDimensions);
|
|
148
|
+
|
|
149
|
+
// If there are new and bigger dimensions in the props, and the upfront preview is still resolving,
|
|
150
|
+
// the fetched preview is no longer valid, and thus, we dismiss it and set the flag wasResolvedUpfrontPreview = true
|
|
151
|
+
// to trigger a normal preview fetch.
|
|
152
|
+
if (areValidRequestedDimensions) {
|
|
153
|
+
this.safeSetState({
|
|
154
|
+
cardPreview,
|
|
155
|
+
wasResolvedUpfrontPreview: true
|
|
156
|
+
});
|
|
157
|
+
} else {
|
|
158
|
+
this.safeSetState({
|
|
159
|
+
wasResolvedUpfrontPreview: true
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
} catch (e) {
|
|
163
|
+
this.safeSetState({
|
|
164
|
+
wasResolvedUpfrontPreview: true
|
|
165
|
+
});
|
|
166
|
+
// NO need to log error. If this call fails, a refetch will happen after
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
_defineProperty(this, "fetchAndCacheRemotePreview", identifier => {
|
|
170
|
+
const {
|
|
171
|
+
mediaClient,
|
|
172
|
+
dimensions = {}
|
|
173
|
+
} = this.props;
|
|
174
|
+
return fetchAndCacheRemotePreview(mediaClient, identifier.id, dimensions, this.getImageURLParams(identifier), this.getMediaBlobUrlAttrs(identifier));
|
|
175
|
+
});
|
|
146
176
|
_defineProperty(this, "resolvePreview", async (identifier, fileState) => {
|
|
147
177
|
try {
|
|
148
178
|
const params = this.getCardPreviewParams(identifier, fileState);
|
|
@@ -604,29 +634,7 @@ export class CardBase extends Component {
|
|
|
604
634
|
const fileImageMode = imageResizeModeToFileImageMode(_resizeMode);
|
|
605
635
|
_cardPreview = getCardPreviewFromCache(id, fileImageMode);
|
|
606
636
|
if (!_cardPreview && _ssr) {
|
|
607
|
-
|
|
608
|
-
this.ssrData = getSSRData(_identifier);
|
|
609
|
-
if ((_this$ssrData = this.ssrData) !== null && _this$ssrData !== void 0 && _this$ssrData.error) {
|
|
610
|
-
this.ssrReliability.server = {
|
|
611
|
-
status: 'fail',
|
|
612
|
-
...this.ssrData.error
|
|
613
|
-
};
|
|
614
|
-
}
|
|
615
|
-
if (!((_this$ssrData2 = this.ssrData) !== null && _this$ssrData2 !== void 0 && _this$ssrData2.dataURI)) {
|
|
616
|
-
try {
|
|
617
|
-
_cardPreview = getSSRCardPreview(_ssr, _mediaClient, _identifier.id, this.getImageURLParams(_identifier), this.getMediaBlobUrlAttrs(_identifier));
|
|
618
|
-
} catch (e) {
|
|
619
|
-
this.ssrReliability[_ssr] = {
|
|
620
|
-
status: 'fail',
|
|
621
|
-
...extractErrorInfo(e)
|
|
622
|
-
};
|
|
623
|
-
}
|
|
624
|
-
} else {
|
|
625
|
-
_cardPreview = {
|
|
626
|
-
dataURI: this.ssrData.dataURI,
|
|
627
|
-
source: 'ssr-data'
|
|
628
|
-
};
|
|
629
|
-
}
|
|
637
|
+
_cardPreview = this.getSSRPreview(_ssr, _identifier, _mediaClient);
|
|
630
638
|
}
|
|
631
639
|
} else if (isExternalImageIdentifier(_identifier)) {
|
|
632
640
|
this.fireCommencedEvent();
|
|
@@ -655,9 +663,35 @@ export class CardBase extends Component {
|
|
|
655
663
|
cardRef: null,
|
|
656
664
|
isBannedLocalPreview: false,
|
|
657
665
|
previewDidRender: false,
|
|
658
|
-
error: _error
|
|
666
|
+
error: _error,
|
|
667
|
+
wasResolvedUpfrontPreview: false
|
|
659
668
|
};
|
|
660
669
|
}
|
|
670
|
+
getSSRPreview(ssr, identifier, mediaClient) {
|
|
671
|
+
var _this$ssrData, _this$ssrData2;
|
|
672
|
+
this.ssrData = getSSRData(identifier);
|
|
673
|
+
if ((_this$ssrData = this.ssrData) !== null && _this$ssrData !== void 0 && _this$ssrData.error) {
|
|
674
|
+
this.ssrReliability.server = {
|
|
675
|
+
status: 'fail',
|
|
676
|
+
...this.ssrData.error
|
|
677
|
+
};
|
|
678
|
+
}
|
|
679
|
+
if (!((_this$ssrData2 = this.ssrData) !== null && _this$ssrData2 !== void 0 && _this$ssrData2.dataURI)) {
|
|
680
|
+
try {
|
|
681
|
+
return getSSRCardPreview(ssr, mediaClient, identifier.id, this.getImageURLParams(identifier), this.getMediaBlobUrlAttrs(identifier));
|
|
682
|
+
} catch (e) {
|
|
683
|
+
this.ssrReliability[ssr] = {
|
|
684
|
+
status: 'fail',
|
|
685
|
+
...extractErrorInfo(e)
|
|
686
|
+
};
|
|
687
|
+
}
|
|
688
|
+
} else {
|
|
689
|
+
return {
|
|
690
|
+
dataURI: this.ssrData.dataURI,
|
|
691
|
+
source: 'ssr-data'
|
|
692
|
+
};
|
|
693
|
+
}
|
|
694
|
+
}
|
|
661
695
|
componentDidMount() {
|
|
662
696
|
var _getDocument;
|
|
663
697
|
this.hasBeenMounted = true;
|
|
@@ -672,6 +706,9 @@ export class CardBase extends Component {
|
|
|
672
706
|
} = this.props;
|
|
673
707
|
if (isCardVisible && isFileIdentifier(identifier)) {
|
|
674
708
|
this.updateStateForIdentifier(identifier);
|
|
709
|
+
if (!cardPreview) {
|
|
710
|
+
this.resolveUpfrontPreview(identifier);
|
|
711
|
+
}
|
|
675
712
|
}
|
|
676
713
|
if (isCardVisible && !!ssr && !!cardPreview && isFileIdentifier(identifier)) {
|
|
677
714
|
var _this$ssrData3;
|
|
@@ -699,7 +736,8 @@ export class CardBase extends Component {
|
|
|
699
736
|
dimensions: prevDimensions
|
|
700
737
|
} = prevProps;
|
|
701
738
|
const {
|
|
702
|
-
isCardVisible: prevIsCardVisible
|
|
739
|
+
isCardVisible: prevIsCardVisible,
|
|
740
|
+
cardPreview: prevCardPreview
|
|
703
741
|
} = prevState;
|
|
704
742
|
const {
|
|
705
743
|
mediaClient,
|
|
@@ -708,7 +746,8 @@ export class CardBase extends Component {
|
|
|
708
746
|
featureFlags,
|
|
709
747
|
useInlinePlayer,
|
|
710
748
|
disableOverlay,
|
|
711
|
-
resizeMode
|
|
749
|
+
resizeMode,
|
|
750
|
+
ssr
|
|
712
751
|
} = this.props;
|
|
713
752
|
const {
|
|
714
753
|
isCardVisible,
|
|
@@ -717,10 +756,24 @@ export class CardBase extends Component {
|
|
|
717
756
|
fileState,
|
|
718
757
|
isBannedLocalPreview,
|
|
719
758
|
previewDidRender,
|
|
720
|
-
isPlayingFile
|
|
759
|
+
isPlayingFile,
|
|
760
|
+
wasResolvedUpfrontPreview
|
|
721
761
|
} = this.state;
|
|
722
762
|
const isDifferent = isDifferentIdentifier(prevIdentifier, identifier);
|
|
763
|
+
/**
|
|
764
|
+
* Variable turnedVisible should only be true when media card
|
|
765
|
+
* was invisible in the previous state and is visible in the current one
|
|
766
|
+
*
|
|
767
|
+
* prevIsCardVisible | isCardVisible | turnedVisible
|
|
768
|
+
* ----------------------------------------------------
|
|
769
|
+
* false | false | false
|
|
770
|
+
* false | true | true
|
|
771
|
+
* true | true | false
|
|
772
|
+
* true | false | false (unreachable case)
|
|
773
|
+
* ----------------------------------------------------
|
|
774
|
+
*/
|
|
723
775
|
const turnedVisible = !prevIsCardVisible && isCardVisible;
|
|
776
|
+
const hadSSRCardPreview = !!prevCardPreview && isSSRClientPreview(prevCardPreview) && !cardPreview;
|
|
724
777
|
const isNewMediaClient = prevMediaClient !== mediaClient;
|
|
725
778
|
const fileImageMode = imageResizeModeToFileImageMode(resizeMode);
|
|
726
779
|
this.updateFileStateFlag(fileState);
|
|
@@ -748,7 +801,12 @@ export class CardBase extends Component {
|
|
|
748
801
|
this.fireScreenEvent();
|
|
749
802
|
}
|
|
750
803
|
}
|
|
751
|
-
if (isFileIdentifier(identifier) &&
|
|
804
|
+
if (isFileIdentifier(identifier) && (turnedVisible || ssr === 'client' && hadSSRCardPreview) && !cardPreview && !wasResolvedUpfrontPreview) {
|
|
805
|
+
// This is a one-off call, only meant to happen once in the component's lifecycle. Mainly when either:
|
|
806
|
+
// - turnedVisible = true
|
|
807
|
+
// - ssr = client and has no preview (the dataURI failed to load in the previous state, most likely because of an initial auth issue)
|
|
808
|
+
this.resolveUpfrontPreview(identifier);
|
|
809
|
+
} else if (isFileIdentifier(identifier) && fileState && shouldResolvePreview({
|
|
752
810
|
status,
|
|
753
811
|
fileState,
|
|
754
812
|
prevDimensions,
|
|
@@ -757,7 +815,8 @@ export class CardBase extends Component {
|
|
|
757
815
|
fileImageMode,
|
|
758
816
|
featureFlags,
|
|
759
817
|
hasCardPreview: !!cardPreview,
|
|
760
|
-
isBannedLocalPreview
|
|
818
|
+
isBannedLocalPreview,
|
|
819
|
+
wasResolvedUpfrontPreview
|
|
761
820
|
})) {
|
|
762
821
|
this.resolvePreview(identifier, fileState);
|
|
763
822
|
}
|
|
@@ -146,11 +146,13 @@ export const shouldResolvePreview = ({
|
|
|
146
146
|
fileImageMode,
|
|
147
147
|
hasCardPreview,
|
|
148
148
|
isBannedLocalPreview,
|
|
149
|
-
featureFlags
|
|
149
|
+
featureFlags,
|
|
150
|
+
wasResolvedUpfrontPreview
|
|
150
151
|
}) => {
|
|
151
152
|
const statusIsPreviewable = isPreviewableStatus(status, extractFilePreviewStatus(fileState, isBannedLocalPreview, featureFlags));
|
|
152
153
|
const dimensionsAreBigger = isBigger(prevDimensions, dimensions);
|
|
153
|
-
|
|
154
|
+
// We should not fetch the preview if the upfront one hasn't been resolved yet (it could be resolving now), even if there are new dimensions.
|
|
155
|
+
return wasResolvedUpfrontPreview && statusIsPreviewable && (!hasCardPreview || dimensionsAreBigger);
|
|
154
156
|
};
|
|
155
157
|
export const getSSRCardPreview = (ssr, mediaClient, id, params, mediaBlobUrlAttrs) => {
|
|
156
158
|
let dataURI;
|
|
@@ -66,7 +66,7 @@ class WrappedMediaCardAnalyticsErrorBoundary extends React.Component {
|
|
|
66
66
|
}
|
|
67
67
|
_defineProperty(WrappedMediaCardAnalyticsErrorBoundary, "displayName", 'MediaCardAnalyticsErrorBoundary');
|
|
68
68
|
const packageName = "@atlaskit/media-card";
|
|
69
|
-
const packageVersion = "74.
|
|
69
|
+
const packageVersion = "74.6.1";
|
|
70
70
|
const MediaCardAnalyticsErrorBoundary = withMediaAnalyticsContext({
|
|
71
71
|
packageVersion,
|
|
72
72
|
packageName,
|
|
@@ -54,7 +54,7 @@ class WrappedMediaInlineAnalyticsErrorBoundary extends React.Component {
|
|
|
54
54
|
}
|
|
55
55
|
_defineProperty(WrappedMediaInlineAnalyticsErrorBoundary, "displayName", 'MediaInlineAnalyticsErrorBoundary');
|
|
56
56
|
const packageName = "@atlaskit/media-card";
|
|
57
|
-
const packageVersion = "74.
|
|
57
|
+
const packageVersion = "74.6.1";
|
|
58
58
|
const MediaInlineAnalyticsErrorBoundary = withMediaAnalyticsContext({
|
|
59
59
|
packageVersion,
|
|
60
60
|
packageName,
|
|
@@ -3,7 +3,7 @@ import { extractErrorInfo, getRenderErrorRequestMetadata, LOGGED_FEATURE_FLAG_KE
|
|
|
3
3
|
import { MediaCardError } from '../errors';
|
|
4
4
|
import { getMediaEnvironment, getMediaRegion } from '@atlaskit/media-client';
|
|
5
5
|
const packageName = "@atlaskit/media-card";
|
|
6
|
-
const packageVersion = "74.
|
|
6
|
+
const packageVersion = "74.6.1";
|
|
7
7
|
let concurrentExperience;
|
|
8
8
|
const getExperience = id => {
|
|
9
9
|
if (!concurrentExperience) {
|
package/dist/es2019/version.json
CHANGED