box-content-preview 3.95.0 → 3.96.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/README.md +7 -7
- package/dist/lib/index.js +92 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
[](https://mergify.io)
|
|
3
3
|
[](https://github.com/prettier/prettier)
|
|
4
4
|
[](https://travis-ci.org/box/box-content-preview)
|
|
5
|
-
[](https://github.com/box/box-content-preview)
|
|
6
6
|
[](https://www.npmjs.com/package/box-ui-elements)
|
|
7
7
|
|
|
8
8
|
# [Box Content Preview](https://developer.box.com/docs/box-content-preview)
|
|
@@ -22,11 +22,11 @@ We encourage all users to update their applications to utilize modern browsers f
|
|
|
22
22
|
|
|
23
23
|
## Current Version
|
|
24
24
|
|
|
25
|
-
- Version: v3.
|
|
25
|
+
- Version: v3.96.0
|
|
26
26
|
- Locale: en-US
|
|
27
27
|
|
|
28
|
-
https://cdn01.boxcdn.net/platform/preview/3.
|
|
29
|
-
https://cdn01.boxcdn.net/platform/preview/3.
|
|
28
|
+
https://cdn01.boxcdn.net/platform/preview/3.96.0/en-US/preview.js
|
|
29
|
+
https://cdn01.boxcdn.net/platform/preview/3.96.0/en-US/preview.css
|
|
30
30
|
|
|
31
31
|
## Supported Locales
|
|
32
32
|
|
|
@@ -52,10 +52,10 @@ You can self-host the Box Content Preview library or reference the versions avai
|
|
|
52
52
|
<title>Box Content Preview Demo</title>
|
|
53
53
|
|
|
54
54
|
<!-- Latest version of Preview SDK for your locale -->
|
|
55
|
-
<script src="https://cdn01.boxcdn.net/platform/preview/3.
|
|
55
|
+
<script src="https://cdn01.boxcdn.net/platform/preview/3.96.0/en-US/preview.js"></script>
|
|
56
56
|
<link
|
|
57
57
|
rel="stylesheet"
|
|
58
|
-
href="https://cdn01.boxcdn.net/platform/preview/3.
|
|
58
|
+
href="https://cdn01.boxcdn.net/platform/preview/3.96.0/en-US/preview.css"
|
|
59
59
|
/>
|
|
60
60
|
</head>
|
|
61
61
|
<body>
|
|
@@ -76,7 +76,7 @@ To self-host the Box Content Preview library, follow these steps:
|
|
|
76
76
|
|
|
77
77
|
1. Either fork the repo and check out the version you want to host or download the specific version as a zip:
|
|
78
78
|
|
|
79
|
-
- Check out a specific version with `git checkout v3.
|
|
79
|
+
- Check out a specific version with `git checkout v3.96.0`
|
|
80
80
|
- Download a specific version as a zip from https://github.com/box/box-content-preview/releases
|
|
81
81
|
|
|
82
82
|
2. Install dependencies and build the library with `yarn install && yarn build:i18n && yarn build:prod`
|
package/dist/lib/index.js
CHANGED
|
@@ -314,6 +314,7 @@ class PreviewError extends Error {
|
|
|
314
314
|
/* harmony export */ Ci: () => (/* binding */ CLASS_BOX_PREVIEW_VIDEO_PRELOAD_PLAY_OVERLAY),
|
|
315
315
|
/* harmony export */ D4: () => (/* binding */ CLASS_ANNOTATIONS_VIDEO_FTUX_CURSOR_SEEN),
|
|
316
316
|
/* harmony export */ EP: () => (/* binding */ ORIGINAL_REP_NAME),
|
|
317
|
+
/* harmony export */ Ed: () => (/* binding */ BLUEPRINT_MIGRATION_SUPPORTING_UI),
|
|
317
318
|
/* harmony export */ Ev: () => (/* binding */ BROWSERS),
|
|
318
319
|
/* harmony export */ FD: () => (/* binding */ SELECTOR_BOX_PREVIEW_LOGO_DEFAULT),
|
|
319
320
|
/* harmony export */ GA: () => (/* binding */ ANNOTATOR_EVENT),
|
|
@@ -337,6 +338,7 @@ class PreviewError extends Error {
|
|
|
337
338
|
/* harmony export */ Mi: () => (/* binding */ PDFJS_CSS_UNITS),
|
|
338
339
|
/* harmony export */ Mj: () => (/* binding */ CLASS_BOX_PREVIEW_THUMBNAILS_CLOSE_ACTIVE),
|
|
339
340
|
/* harmony export */ N7: () => (/* binding */ DISCOVERABILITY_ATTRIBUTE),
|
|
341
|
+
/* harmony export */ OQ: () => (/* binding */ BLUEPRINT_MIGRATION_CONTROLS_BAR),
|
|
340
342
|
/* harmony export */ OW: () => (/* binding */ PRELOAD_REP_NAME),
|
|
341
343
|
/* harmony export */ Oo: () => (/* binding */ CLASS_ANNOTATIONS_CREATE_REGION),
|
|
342
344
|
/* harmony export */ P8: () => (/* binding */ CLASS_BOX_PREVIEW_HAS_HEADER),
|
|
@@ -367,9 +369,11 @@ class PreviewError extends Error {
|
|
|
367
369
|
/* harmony export */ bE: () => (/* binding */ SELECTOR_BOX_PREVIEW_CONTENT),
|
|
368
370
|
/* harmony export */ br: () => (/* binding */ FILE_OPTION_FILE_VERSION_ID),
|
|
369
371
|
/* harmony export */ c6: () => (/* binding */ PRELOAD_PAGED_REP_NAME),
|
|
372
|
+
/* harmony export */ cA: () => (/* binding */ BLUEPRINT_MIGRATION_ARCHIVE),
|
|
370
373
|
/* harmony export */ cP: () => (/* binding */ CLASS_BOX_PREVIEW_PRELOAD_WRAPPER_VIDEO),
|
|
371
374
|
/* harmony export */ cR: () => (/* binding */ TEXT_STATIC_ASSETS_VERSION),
|
|
372
375
|
/* harmony export */ cZ: () => (/* binding */ CLASS_ANNOTATIONS_DISCOVERABLE),
|
|
376
|
+
/* harmony export */ dR: () => (/* binding */ BLUEPRINT_MIGRATION_MEDIA_CONTROLS),
|
|
373
377
|
/* harmony export */ eA: () => (/* binding */ SUBTITLES_OFF),
|
|
374
378
|
/* harmony export */ eF: () => (/* binding */ CLASS_BOX_PREVIEW_PRELOAD_CONTENT),
|
|
375
379
|
/* harmony export */ eM: () => (/* binding */ CLASS_BOX_PREVIEW_HAS_NAVIGATION),
|
|
@@ -525,6 +529,13 @@ const X_REP_HINT_VIDEO_MP4 = '[mp4]';
|
|
|
525
529
|
const X_REP_HINT_WAVEFORM = '[waveform]';
|
|
526
530
|
const AI_TRANSCRIPTION_FOR_VIDEO_SUBTITLES = 'aiTranscriptionForVideoSubtitles';
|
|
527
531
|
const AUDIO_PLAYER_V2 = 'audioPlayerV2.enabled';
|
|
532
|
+
|
|
533
|
+
// One per wave of the Blueprint migration. Each is reported as its own metric dimension so a
|
|
534
|
+
// dashboard can compare a wave's timings with its flag on against the same wave with it off.
|
|
535
|
+
const BLUEPRINT_MIGRATION_ARCHIVE = 'blueprintMigrationArchive.enabled';
|
|
536
|
+
const BLUEPRINT_MIGRATION_CONTROLS_BAR = 'blueprintMigrationControlsBar.enabled';
|
|
537
|
+
const BLUEPRINT_MIGRATION_MEDIA_CONTROLS = 'blueprintMigrationMediaControls.enabled';
|
|
538
|
+
const BLUEPRINT_MIGRATION_SUPPORTING_UI = 'blueprintMigrationSupportingUi.enabled';
|
|
528
539
|
const PDFJS_CSS_UNITS = 96.0 / 72.0; // Should match CSS_UNITS in pdf_viewer.js
|
|
529
540
|
const PDFJS_MAX_AUTO_SCALE = 1.25; // Should match MAX_AUTO_SCALE in pdf_viewer.js
|
|
530
541
|
const PDFJS_WIDTH_PADDING_PX = 40; // Should match SCROLLBAR_PADDING in pdf_viewer.js
|
|
@@ -1018,7 +1029,7 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
1018
1029
|
const CLIENT_NAME = "box-content-preview"; // eslint-disable-line no-undef
|
|
1019
1030
|
const CLIENT_NAME_KEY = 'box_client_name';
|
|
1020
1031
|
const CLIENT_VERSION_KEY = 'box_client_version';
|
|
1021
|
-
const CLIENT_VERSION = "3.
|
|
1032
|
+
const CLIENT_VERSION = "3.96.0"; // eslint-disable-line no-undef
|
|
1022
1033
|
const HEADER_CLIENT_NAME = 'X-Box-Client-Name';
|
|
1023
1034
|
const HEADER_CLIENT_VERSION = 'X-Box-Client-Version';
|
|
1024
1035
|
const PROMISE_MAP = {};
|
|
@@ -24650,7 +24661,7 @@ class Browser {
|
|
|
24650
24661
|
;// ./src/lib/Logger.js
|
|
24651
24662
|
/* eslint-disable no-undef */
|
|
24652
24663
|
const CLIENT_NAME = "box-content-preview";
|
|
24653
|
-
const CLIENT_VERSION = "3.
|
|
24664
|
+
const CLIENT_VERSION = "3.96.0";
|
|
24654
24665
|
/* eslint-enable no-undef */
|
|
24655
24666
|
|
|
24656
24667
|
class Logger {
|
|
@@ -56121,11 +56132,18 @@ class Preview extends (events_default()) {
|
|
|
56121
56132
|
loadFromCache() {
|
|
56122
56133
|
// Log cache hit
|
|
56123
56134
|
this.logger.setCached();
|
|
56124
|
-
|
|
56125
|
-
// Finally load the viewer
|
|
56126
|
-
this.loadViewer();
|
|
56127
56135
|
const needsVideoReps = this.isVideoFileByExtension() && !this.hasPlayableVideoReps(this.file);
|
|
56128
|
-
|
|
56136
|
+
const needsTranscriptionRep = isFeatureEnabled(this.options.features, constants/* AI_TRANSCRIPTION_FOR_VIDEO_SUBTITLES */.Iu) && this.isVideoFileByExtension() && !this.hasTranscriptionRep(this.file);
|
|
56137
|
+
// Captions are optional — do not treat a missing extracted_text rep like missing
|
|
56138
|
+
// dash/mp4. skipServerUpdate still skips this refresh; default reopen already
|
|
56139
|
+
// calls loadFromServer() because skipServerUpdate is false.
|
|
56140
|
+
const needsServerRefresh = !this.options.skipServerUpdate || needsVideoReps || needsTranscriptionRep;
|
|
56141
|
+
|
|
56142
|
+
// Play from cache immediately. Default reopen still refreshes file info in the
|
|
56143
|
+
// background; handleFileInfoResponse then updates the live viewer if extracted_text
|
|
56144
|
+
// arrived. A failed captions-only refresh must not uncache or destroy playback.
|
|
56145
|
+
this.loadViewer();
|
|
56146
|
+
if (needsServerRefresh) {
|
|
56129
56147
|
this.loadFromServer();
|
|
56130
56148
|
}
|
|
56131
56149
|
}
|
|
@@ -56156,7 +56174,14 @@ class Preview extends (events_default()) {
|
|
|
56156
56174
|
const fileInfoUrl = (0,util/* appendQueryParams */.Ne)(getURL(this.file.id, fileVersionId, apiHost), params);
|
|
56157
56175
|
this.api.get(fileInfoUrl, {
|
|
56158
56176
|
headers: this.getRequestHeaders()
|
|
56159
|
-
}).then(this.handleFileInfoResponse).catch(
|
|
56177
|
+
}).then(this.handleFileInfoResponse).catch(err => {
|
|
56178
|
+
// Captions are optional. If a cache-hit viewer is already playing dash/mp4,
|
|
56179
|
+
// a failed background file-info refresh must not uncache or triggerError.
|
|
56180
|
+
if (this.viewer && this.hasPlayableVideoReps(this.file)) {
|
|
56181
|
+
return;
|
|
56182
|
+
}
|
|
56183
|
+
this.handleFetchError(err);
|
|
56184
|
+
});
|
|
56160
56185
|
}
|
|
56161
56186
|
|
|
56162
56187
|
/**
|
|
@@ -56247,6 +56272,7 @@ class Preview extends (events_default()) {
|
|
|
56247
56272
|
if (this.isVideoFileByExtension() && !this.hasPlayableVideoReps(file)) {
|
|
56248
56273
|
throw new PreviewError/* default */.A(lib_events/* ERROR_CODE */.bo.ACCOUNT, "This preview didn’t load because your account is unable to preview this file type. Please try to open or download the file to view.");
|
|
56249
56274
|
}
|
|
56275
|
+
const needsTranscriptionReload = this.canUseDash() && isFeatureEnabled(this.options.features, constants/* AI_TRANSCRIPTION_FOR_VIDEO_SUBTITLES */.Iu) && this.isVideoFileByExtension() && !this.hasTranscriptionRep(cachedFile) && this.hasTranscriptionRep(file);
|
|
56250
56276
|
|
|
56251
56277
|
// Should load viewer for first time if:
|
|
56252
56278
|
// - File isn't cached OR
|
|
@@ -56260,6 +56286,18 @@ class Preview extends (events_default()) {
|
|
|
56260
56286
|
} else if (cachedFile.file_version.sha1 !== file.file_version.sha1 || isFileWatermarked) {
|
|
56261
56287
|
this.logger.setCacheStale(); // Log that cache is stale
|
|
56262
56288
|
this.reload(true); // Reload viewer without fetching updated file info from server
|
|
56289
|
+
} else if (needsTranscriptionReload) {
|
|
56290
|
+
// Cache was valid but lacked extracted_text (e.g. prefetch without the hint).
|
|
56291
|
+
// Server refresh now has the rep — update the already-playing viewer so
|
|
56292
|
+
// loadTranscription can attach captions. Only call it after loadeddata;
|
|
56293
|
+
// calling earlier duplicates the Auto-generated Shaka track and can throw
|
|
56294
|
+
// if UI is not ready. If loadeddata has not fired, the handler uses this file.
|
|
56295
|
+
if (this.viewer) {
|
|
56296
|
+
this.viewer.options.file = this.file;
|
|
56297
|
+
if (this.viewer.isLoaded() && typeof this.viewer.loadTranscription === 'function') {
|
|
56298
|
+
this.viewer.loadTranscription();
|
|
56299
|
+
}
|
|
56300
|
+
}
|
|
56263
56301
|
}
|
|
56264
56302
|
} catch (err) {
|
|
56265
56303
|
const error = err instanceof PreviewError/* default */.A ? err : new PreviewError/* default */.A(lib_events/* ERROR_CODE */.bo.LOAD_VIEWER, "This preview didn’t load. Please try to open or download the file to view.", {}, err.message);
|
|
@@ -56380,6 +56418,31 @@ class Preview extends (events_default()) {
|
|
|
56380
56418
|
});
|
|
56381
56419
|
}
|
|
56382
56420
|
|
|
56421
|
+
/**
|
|
56422
|
+
* Returns true if file has an extracted_text transcription rep with a content URL.
|
|
56423
|
+
*
|
|
56424
|
+
* @private
|
|
56425
|
+
* @param {Object} file - File object
|
|
56426
|
+
* @return {boolean}
|
|
56427
|
+
*/
|
|
56428
|
+
hasTranscriptionRep(file) {
|
|
56429
|
+
if (!file?.representations?.entries) {
|
|
56430
|
+
return false;
|
|
56431
|
+
}
|
|
56432
|
+
const extractedText = getRepresentation(file, 'extracted_text');
|
|
56433
|
+
return !!extractedText?.content?.url_template;
|
|
56434
|
+
}
|
|
56435
|
+
|
|
56436
|
+
/**
|
|
56437
|
+
* Returns true when Dash playback is available and not disabled.
|
|
56438
|
+
*
|
|
56439
|
+
* @private
|
|
56440
|
+
* @return {boolean}
|
|
56441
|
+
*/
|
|
56442
|
+
canUseDash() {
|
|
56443
|
+
return lib_Browser.canPlayDash() && !this.disabledViewers.Dash;
|
|
56444
|
+
}
|
|
56445
|
+
|
|
56383
56446
|
/**
|
|
56384
56447
|
* Returns true if file has playable video representations (dash or mp4).
|
|
56385
56448
|
*
|
|
@@ -56834,7 +56897,7 @@ class Preview extends (events_default()) {
|
|
|
56834
56897
|
previewMode,
|
|
56835
56898
|
sharedLinkAuth
|
|
56836
56899
|
} = this.options || {};
|
|
56837
|
-
this.emit(name, Preview_objectSpread(Preview_objectSpread({}, payload), {}, {
|
|
56900
|
+
this.emit(name, Preview_objectSpread(Preview_objectSpread(Preview_objectSpread({}, payload), this.getBlueprintMigrationTags()), {}, {
|
|
56838
56901
|
access_pattern: accessPattern,
|
|
56839
56902
|
client_name: clientName,
|
|
56840
56903
|
content_type: (0,util/* getProp */.GT)(this.viewer, 'options.viewer.NAME', ''),
|
|
@@ -56852,6 +56915,26 @@ class Preview extends (events_default()) {
|
|
|
56852
56915
|
}, getClientLogDetails()));
|
|
56853
56916
|
}
|
|
56854
56917
|
|
|
56918
|
+
/**
|
|
56919
|
+
* Returns the state of each Blueprint migration wave for this preview session. Every metric
|
|
56920
|
+
* and error carries all four, including the waves that are off, so the flag-off side of a
|
|
56921
|
+
* rollout is measured the same way as the flag-on side rather than inferred from its absence.
|
|
56922
|
+
*
|
|
56923
|
+
* @private
|
|
56924
|
+
* @return {Object} Blueprint migration dimensions
|
|
56925
|
+
*/
|
|
56926
|
+
getBlueprintMigrationTags() {
|
|
56927
|
+
const {
|
|
56928
|
+
features
|
|
56929
|
+
} = this.options || {};
|
|
56930
|
+
return {
|
|
56931
|
+
blueprint_archive: isFeatureEnabled(features, constants/* BLUEPRINT_MIGRATION_ARCHIVE */.cA),
|
|
56932
|
+
blueprint_controls_bar: isFeatureEnabled(features, constants/* BLUEPRINT_MIGRATION_CONTROLS_BAR */.OQ),
|
|
56933
|
+
blueprint_media_controls: isFeatureEnabled(features, constants/* BLUEPRINT_MIGRATION_MEDIA_CONTROLS */.dR),
|
|
56934
|
+
blueprint_supporting_ui: isFeatureEnabled(features, constants/* BLUEPRINT_MIGRATION_SUPPORTING_UI */.Ed)
|
|
56935
|
+
};
|
|
56936
|
+
}
|
|
56937
|
+
|
|
56855
56938
|
/**
|
|
56856
56939
|
* Returns the prefetch/preload dimensions for this preview session. Only attached to
|
|
56857
56940
|
* the load event, preview_preload_outcome counter, and preview_error — exactly one
|
|
@@ -56875,7 +56958,7 @@ class Preview extends (events_default()) {
|
|
|
56875
56958
|
* @return {Object} Headers
|
|
56876
56959
|
*/
|
|
56877
56960
|
getRequestHeaders(token) {
|
|
56878
|
-
const isDash =
|
|
56961
|
+
const isDash = this.canUseDash();
|
|
56879
56962
|
let videoHint = isDash ? constants/* X_REP_HINT_VIDEO_DASH */.yF : constants/* X_REP_HINT_VIDEO_MP4 */.Zg;
|
|
56880
56963
|
if (isDash && isFeatureEnabled(this.options.features, constants/* AI_TRANSCRIPTION_FOR_VIDEO_SUBTITLES */.Iu)) {
|
|
56881
56964
|
videoHint += constants/* X_REP_HINT_VIDEO_DASH_EXTRACTED_TEXT */.xU;
|