box-content-preview 3.73.0 → 3.75.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
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.75.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.75.0/en-US/preview.js
|
|
29
|
+
https://cdn01.boxcdn.net/platform/preview/3.75.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.75.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.75.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.75.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
|
@@ -6793,7 +6793,7 @@ module.exports = webpackEmptyAsyncContext;
|
|
|
6793
6793
|
/***/ 824
|
|
6794
6794
|
(module, __unused_webpack_exports, __webpack_require__) {
|
|
6795
6795
|
|
|
6796
|
-
module.exports = __webpack_require__.p + "
|
|
6796
|
+
module.exports = __webpack_require__.p + "pdf.worker.min.mjs";
|
|
6797
6797
|
|
|
6798
6798
|
/***/ },
|
|
6799
6799
|
|
|
@@ -15388,7 +15388,7 @@ function util_toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var
|
|
|
15388
15388
|
const CLIENT_NAME = "box-content-preview"; // eslint-disable-line no-undef
|
|
15389
15389
|
const CLIENT_NAME_KEY = 'box_client_name';
|
|
15390
15390
|
const CLIENT_VERSION_KEY = 'box_client_version';
|
|
15391
|
-
const CLIENT_VERSION = "3.
|
|
15391
|
+
const CLIENT_VERSION = "3.75.0"; // eslint-disable-line no-undef
|
|
15392
15392
|
const HEADER_CLIENT_NAME = 'X-Box-Client-Name';
|
|
15393
15393
|
const HEADER_CLIENT_VERSION = 'X-Box-Client-Version';
|
|
15394
15394
|
const PROMISE_MAP = {};
|
|
@@ -16487,7 +16487,9 @@ const X_REP_HINT_BASE = '[3d][pdf][text][mp3][json]';
|
|
|
16487
16487
|
const X_REP_HINT_DOC_THUMBNAIL = '[jpg?dimensions=1024x1024&paged=false]';
|
|
16488
16488
|
const X_REP_HINT_IMAGE = '[jpg?dimensions=2048x2048,png?dimensions=2048x2048]';
|
|
16489
16489
|
const X_REP_HINT_VIDEO_DASH = '[dash,mp4][filmstrip]';
|
|
16490
|
+
const X_REP_HINT_VIDEO_DASH_EXTRACTED_TEXT = '[extracted_text]';
|
|
16490
16491
|
const X_REP_HINT_VIDEO_MP4 = '[mp4]';
|
|
16492
|
+
const AI_TRANSCRIPTION_FOR_VIDEO_SUBTITLES = 'aiTranscriptionForVideoSubtitles';
|
|
16491
16493
|
const PDFJS_CSS_UNITS = 96.0 / 72.0; // Should match CSS_UNITS in pdf_viewer.js
|
|
16492
16494
|
const PDFJS_MAX_AUTO_SCALE = 1.25; // Should match MAX_AUTO_SCALE in pdf_viewer.js
|
|
16493
16495
|
const PDFJS_WIDTH_PADDING_PX = 40; // Should match SCROLLBAR_PADDING in pdf_viewer.js
|
|
@@ -17083,7 +17085,7 @@ class Browser {
|
|
|
17083
17085
|
;// ./src/lib/Logger.js
|
|
17084
17086
|
/* eslint-disable no-undef */
|
|
17085
17087
|
const Logger_CLIENT_NAME = "box-content-preview";
|
|
17086
|
-
const Logger_CLIENT_VERSION = "3.
|
|
17088
|
+
const Logger_CLIENT_VERSION = "3.75.0";
|
|
17087
17089
|
/* eslint-enable no-undef */
|
|
17088
17090
|
|
|
17089
17091
|
class Logger {
|
|
@@ -27374,6 +27376,23 @@ class Settings extends (events_default()) {
|
|
|
27374
27376
|
this.reset();
|
|
27375
27377
|
}
|
|
27376
27378
|
|
|
27379
|
+
/**
|
|
27380
|
+
* Appends a single subtitle entry to the settings menu without disturbing
|
|
27381
|
+
* existing items or the user's current selection.
|
|
27382
|
+
*
|
|
27383
|
+
* @param {string} subtitle - Display name for the subtitle track
|
|
27384
|
+
* @param {number} idx - data-value index for the new menu item
|
|
27385
|
+
* @return {void}
|
|
27386
|
+
*/
|
|
27387
|
+
addSubtitle(subtitle, idx) {
|
|
27388
|
+
const subtitlesSubMenu = this.settingsEl.querySelector('.bp-media-settings-menu-subtitles');
|
|
27389
|
+
insertTemplate(subtitlesSubMenu, SUBMENU_SUBITEM_TEMPLATE.replace(/{{dataType}}/g, 'subtitles').replace(/{{dataValue}}/g, idx));
|
|
27390
|
+
const languageNode = subtitlesSubMenu.lastChild.querySelector('.bp-media-settings-value');
|
|
27391
|
+
languageNode.textContent = subtitle;
|
|
27392
|
+
this.subtitles.push(subtitle);
|
|
27393
|
+
this.reset();
|
|
27394
|
+
}
|
|
27395
|
+
|
|
27377
27396
|
/**
|
|
27378
27397
|
* Takes an ordered list of audio languages and populates the settings menu
|
|
27379
27398
|
*
|
|
@@ -34426,6 +34445,8 @@ class DashViewer extends media_VideoBaseViewer {
|
|
|
34426
34445
|
DashViewer_defineProperty(this, "filmstripInterval", void 0);
|
|
34427
34446
|
/** @property {Object} - Status of the filmstrip representation */
|
|
34428
34447
|
DashViewer_defineProperty(this, "filmstripStatus", void 0);
|
|
34448
|
+
/** @property {Object} - Status of the extracted_text (transcription) representation */
|
|
34449
|
+
DashViewer_defineProperty(this, "transcriptionStatus", void 0);
|
|
34429
34450
|
/** @property {string} - URL for the filmstrip image */
|
|
34430
34451
|
DashViewer_defineProperty(this, "filmstripUrl", void 0);
|
|
34431
34452
|
/** @property {string} - ID of the selected audio track */
|
|
@@ -34518,6 +34539,9 @@ class DashViewer extends media_VideoBaseViewer {
|
|
|
34518
34539
|
if (this.filmstripUrl && this.filmstripUrl.startsWith('blob:')) {
|
|
34519
34540
|
URL.revokeObjectURL(this.filmstripUrl);
|
|
34520
34541
|
}
|
|
34542
|
+
if (this.transcriptionStatus) {
|
|
34543
|
+
this.transcriptionStatus.destroy();
|
|
34544
|
+
}
|
|
34521
34545
|
clearInterval(this.statsIntervalId);
|
|
34522
34546
|
if (this.player) {
|
|
34523
34547
|
this.player.destroy();
|
|
@@ -35040,6 +35064,20 @@ class DashViewer extends media_VideoBaseViewer {
|
|
|
35040
35064
|
this.mediaControls.addListener('audiochange', this.handleAudioTrack);
|
|
35041
35065
|
}
|
|
35042
35066
|
|
|
35067
|
+
/**
|
|
35068
|
+
* Returns the display-friendly name for a text track's language.
|
|
35069
|
+
* Maps the undetermined language code 'und' to a localized "Auto-Generated" label.
|
|
35070
|
+
*
|
|
35071
|
+
* @param {Object} track - A Shaka text track object
|
|
35072
|
+
* @return {string} Localized language name or the raw language code
|
|
35073
|
+
*/
|
|
35074
|
+
getTrackDisplayLanguage(track) {
|
|
35075
|
+
if (this.featureEnabled(AI_TRANSCRIPTION_FOR_VIDEO_SUBTITLES) && track.language === 'und') {
|
|
35076
|
+
return "Auto-Generated";
|
|
35077
|
+
}
|
|
35078
|
+
return getLanguageName(track.language) || track.language;
|
|
35079
|
+
}
|
|
35080
|
+
|
|
35043
35081
|
/**
|
|
35044
35082
|
* Loads captions/subtitles into the settings menu
|
|
35045
35083
|
*
|
|
@@ -35052,7 +35090,7 @@ class DashViewer extends media_VideoBaseViewer {
|
|
|
35052
35090
|
if (this.useReactControls()) {
|
|
35053
35091
|
this.initSubtitles();
|
|
35054
35092
|
} else {
|
|
35055
|
-
this.mediaControls.initSubtitles(this.textTracks.map(track =>
|
|
35093
|
+
this.mediaControls.initSubtitles(this.textTracks.map(track => this.getTrackDisplayLanguage(track)), getLanguageName(this.options.location.locale.substring(0, 2)));
|
|
35056
35094
|
}
|
|
35057
35095
|
}
|
|
35058
35096
|
}
|
|
@@ -35086,7 +35124,7 @@ class DashViewer extends media_VideoBaseViewer {
|
|
|
35086
35124
|
this.cache.set('media-subtitles-toggle', true, true);
|
|
35087
35125
|
}
|
|
35088
35126
|
this.textTracks = this.textTracks.map(track => DashViewer_objectSpread(DashViewer_objectSpread({}, track), {}, {
|
|
35089
|
-
displayLanguage:
|
|
35127
|
+
displayLanguage: this.getTrackDisplayLanguage(track)
|
|
35090
35128
|
}));
|
|
35091
35129
|
|
|
35092
35130
|
// Do intelligent selection: Prefer user's language, fallback to English, then first subtitle in list
|
|
@@ -35244,6 +35282,7 @@ class DashViewer extends media_VideoBaseViewer {
|
|
|
35244
35282
|
this.startBandwidthTracking();
|
|
35245
35283
|
this.loadFilmStrip();
|
|
35246
35284
|
this.loadSubtitles();
|
|
35285
|
+
this.loadTranscription();
|
|
35247
35286
|
this.loadAlternateAudio();
|
|
35248
35287
|
this.showPlayButton();
|
|
35249
35288
|
if (this.userRequestedPlay) {
|
|
@@ -35348,6 +35387,58 @@ class DashViewer extends media_VideoBaseViewer {
|
|
|
35348
35387
|
}
|
|
35349
35388
|
}
|
|
35350
35389
|
|
|
35390
|
+
/**
|
|
35391
|
+
* Loads the extracted_text transcription (.vtt) as a text track when available
|
|
35392
|
+
*
|
|
35393
|
+
* @private
|
|
35394
|
+
* @return {void}
|
|
35395
|
+
*/
|
|
35396
|
+
async loadTranscription() {
|
|
35397
|
+
if (!this.featureEnabled(AI_TRANSCRIPTION_FOR_VIDEO_SUBTITLES)) {
|
|
35398
|
+
return;
|
|
35399
|
+
}
|
|
35400
|
+
const extractedText = getRepresentation(this.options.file, 'extracted_text');
|
|
35401
|
+
if (!extractedText?.content?.url_template) {
|
|
35402
|
+
return;
|
|
35403
|
+
}
|
|
35404
|
+
const transcriptionUrl = this.featureEnabled('migrateAccessTokenToHeader') ? this.createContentUrlV2(extractedText.content.url_template) : this.createContentUrlWithAuthParams(extractedText.content.url_template);
|
|
35405
|
+
this.transcriptionStatus = this.getRepStatus(extractedText);
|
|
35406
|
+
try {
|
|
35407
|
+
await this.transcriptionStatus.getPromise();
|
|
35408
|
+
if (this.isDestroyed() || !this.player) {
|
|
35409
|
+
return;
|
|
35410
|
+
}
|
|
35411
|
+
await this.player.addTextTrackAsync(transcriptionUrl, 'und', 'subtitles', 'text/vtt', undefined, "Auto-Generated");
|
|
35412
|
+
if (this.isDestroyed()) {
|
|
35413
|
+
return;
|
|
35414
|
+
}
|
|
35415
|
+
if (this.textTracks.length > 0) {
|
|
35416
|
+
// Subtitles were already initialized — append only the new track(s) at the
|
|
35417
|
+
// end of `this.textTracks`. We must not re-sort: in the non-React path, the
|
|
35418
|
+
// user's selection is cached as an INDEX into `this.textTracks` (see
|
|
35419
|
+
// handleSubtitle) and Settings menu items use the same number as their
|
|
35420
|
+
// `data-value`, so reordering would silently swap which track plays.
|
|
35421
|
+
const existingIds = new Set(this.textTracks.map(t => t.id));
|
|
35422
|
+
const newTracks = this.player.getTextTracks().filter(t => !existingIds.has(t.id));
|
|
35423
|
+
if (this.useReactControls()) {
|
|
35424
|
+
this.textTracks = [...this.textTracks, ...newTracks].map(track => DashViewer_objectSpread(DashViewer_objectSpread({}, track), {}, {
|
|
35425
|
+
displayLanguage: this.getTrackDisplayLanguage(track)
|
|
35426
|
+
}));
|
|
35427
|
+
this.renderUI();
|
|
35428
|
+
} else {
|
|
35429
|
+
newTracks.forEach(track => {
|
|
35430
|
+
this.textTracks.push(track);
|
|
35431
|
+
this.mediaControls.settings.addSubtitle(this.getTrackDisplayLanguage(track), this.textTracks.length - 1);
|
|
35432
|
+
});
|
|
35433
|
+
}
|
|
35434
|
+
} else {
|
|
35435
|
+
this.loadSubtitles();
|
|
35436
|
+
}
|
|
35437
|
+
} catch {
|
|
35438
|
+
// Transcription is non-critical; allow the viewer to continue without it
|
|
35439
|
+
}
|
|
35440
|
+
}
|
|
35441
|
+
|
|
35351
35442
|
/**
|
|
35352
35443
|
* Calculates the video dimension based on representations
|
|
35353
35444
|
*
|
|
@@ -49846,7 +49937,11 @@ class Preview extends (events_default()) {
|
|
|
49846
49937
|
* @return {Object} Headers
|
|
49847
49938
|
*/
|
|
49848
49939
|
getRequestHeaders(token) {
|
|
49849
|
-
const
|
|
49940
|
+
const isDash = lib_Browser.canPlayDash() && !this.disabledViewers.Dash;
|
|
49941
|
+
let videoHint = isDash ? X_REP_HINT_VIDEO_DASH : X_REP_HINT_VIDEO_MP4;
|
|
49942
|
+
if (isDash && isFeatureEnabled(this.options.features, AI_TRANSCRIPTION_FOR_VIDEO_SUBTITLES)) {
|
|
49943
|
+
videoHint += X_REP_HINT_VIDEO_DASH_EXTRACTED_TEXT;
|
|
49944
|
+
}
|
|
49850
49945
|
const headers = {
|
|
49851
49946
|
'X-Rep-Hints': `${X_REP_HINT_BASE}${X_REP_HINT_DOC_THUMBNAIL}${X_REP_HINT_IMAGE}${videoHint}`
|
|
49852
49947
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "box-content-preview",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.75.0",
|
|
4
4
|
"description": "Box Content Preview UI Element",
|
|
5
5
|
"author": "Box (https://www.box.com/)",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"default": "./dist/lib/index.js"
|
|
19
19
|
},
|
|
20
20
|
"./styles.css": "./dist/lib/index.css",
|
|
21
|
+
"./pdf.worker.min.mjs": "./dist/lib/pdf.worker.min.mjs",
|
|
21
22
|
"./package.json": "./package.json"
|
|
22
23
|
},
|
|
23
24
|
"files": [
|
|
@@ -113,7 +114,7 @@
|
|
|
113
114
|
"mock-local-storage": "^1.1.15",
|
|
114
115
|
"mojito-rb-gen": "^0.0.1",
|
|
115
116
|
"npm-run-all": "^4.1.5",
|
|
116
|
-
"postcss": "^8.5.
|
|
117
|
+
"postcss": "^8.5.18",
|
|
117
118
|
"postcss-loader": "^8.1.1",
|
|
118
119
|
"prettier": "^1.19.1",
|
|
119
120
|
"raw-loader": "^4.0.2",
|
|
@@ -196,8 +197,15 @@
|
|
|
196
197
|
"**/react-intl/**/@types/react": "18.3.1",
|
|
197
198
|
"@types/node": "^22.18.10",
|
|
198
199
|
"acorn": "8.14.0",
|
|
200
|
+
"brace-expansion": "^1.1.16",
|
|
199
201
|
"canvas": "^3.2.3",
|
|
200
202
|
"cheerio": "1.0.0-rc.12",
|
|
201
|
-
"
|
|
203
|
+
"cipher-base": "^1.0.5",
|
|
204
|
+
"fast-uri": "^3.1.4",
|
|
205
|
+
"js-yaml": "^4.3.0",
|
|
206
|
+
"minimatch": "^3.1.4",
|
|
207
|
+
"mojito-rb-gen/merge": "1.2.1",
|
|
208
|
+
"serialize-javascript": "^7.0.5",
|
|
209
|
+
"tar": "^7.5.21"
|
|
202
210
|
}
|
|
203
211
|
}
|
|
File without changes
|