box-content-preview 3.42.0 → 3.44.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
  [![Mergify Status](https://img.shields.io/endpoint.svg?url=https://gh.mergify.io/badges/box/box-content-preview&style=flat)](https://mergify.io)
3
3
  [![Styled With Prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
4
4
  [![build status](https://img.shields.io/travis/box/box-content-preview/master.svg?style=flat-square)](https://travis-ci.org/box/box-content-preview)
5
- [![version](https://img.shields.io/badge/version-v3.42.0-blue.svg?style=flat-square)](https://github.com/box/box-content-preview)
5
+ [![version](https://img.shields.io/badge/version-v3.44.0-blue.svg?style=flat-square)](https://github.com/box/box-content-preview)
6
6
  [![npm version](https://img.shields.io/npm/v/box-ui-elements.svg?style=flat-square)](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.42.0
25
+ - Version: v3.44.0
26
26
  - Locale: en-US
27
27
 
28
- https://cdn01.boxcdn.net/platform/preview/3.42.0/en-US/preview.js
29
- https://cdn01.boxcdn.net/platform/preview/3.42.0/en-US/preview.css
28
+ https://cdn01.boxcdn.net/platform/preview/3.44.0/en-US/preview.js
29
+ https://cdn01.boxcdn.net/platform/preview/3.44.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.42.0/en-US/preview.js"></script>
55
+ <script src="https://cdn01.boxcdn.net/platform/preview/3.44.0/en-US/preview.js"></script>
56
56
  <link
57
57
  rel="stylesheet"
58
- href="https://cdn01.boxcdn.net/platform/preview/3.42.0/en-US/preview.css"
58
+ href="https://cdn01.boxcdn.net/platform/preview/3.44.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.42.0`
79
+ - Check out a specific version with `git checkout v3.44.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
@@ -9340,7 +9340,7 @@ function util_toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var
9340
9340
  const CLIENT_NAME = "box-content-preview"; // eslint-disable-line no-undef
9341
9341
  const CLIENT_NAME_KEY = 'box_client_name';
9342
9342
  const CLIENT_VERSION_KEY = 'box_client_version';
9343
- const CLIENT_VERSION = "3.42.0"; // eslint-disable-line no-undef
9343
+ const CLIENT_VERSION = "3.44.0"; // eslint-disable-line no-undef
9344
9344
  const HEADER_CLIENT_NAME = 'X-Box-Client-Name';
9345
9345
  const HEADER_CLIENT_VERSION = 'X-Box-Client-Version';
9346
9346
  const PROMISE_MAP = {};
@@ -11058,7 +11058,7 @@ class Browser {
11058
11058
  ;// ./src/lib/Logger.js
11059
11059
  /* eslint-disable no-undef */
11060
11060
  const Logger_CLIENT_NAME = "box-content-preview";
11061
- const Logger_CLIENT_VERSION = "3.42.0";
11061
+ const Logger_CLIENT_VERSION = "3.44.0";
11062
11062
  /* eslint-enable no-undef */
11063
11063
 
11064
11064
  class Logger {
@@ -13752,6 +13752,7 @@ class ControlsRoot {
13752
13752
  let {
13753
13753
  className = 'bp-ControlsRoot',
13754
13754
  containerEl,
13755
+ fileExtension,
13755
13756
  fileId,
13756
13757
  onHide = (noop_default()),
13757
13758
  onShow = (noop_default())
@@ -13783,6 +13784,7 @@ class ControlsRoot {
13783
13784
  this.controlsEl.setAttribute('data-testid', 'bp-controls');
13784
13785
  this.controlsEl.setAttribute('data-resin-component', 'toolbar');
13785
13786
  this.controlsEl.setAttribute('data-resin-fileid', fileId);
13787
+ this.controlsEl.setAttribute('data-resin-fileextension', fileExtension || '');
13786
13788
  this.containerEl = containerEl;
13787
13789
  this.containerEl.addEventListener('mousemove', this.handleMouseMove);
13788
13790
  this.containerEl.addEventListener('touchstart', this.handleTouchStart);
@@ -14028,6 +14030,7 @@ class ImageBaseViewer extends viewers_BaseViewer {
14028
14030
  loadUI() {
14029
14031
  this.controls = new ControlsRoot({
14030
14032
  containerEl: this.containerEl,
14033
+ fileExtension: this.options.file.extension,
14031
14034
  fileId: this.options.file.id
14032
14035
  });
14033
14036
  }
@@ -14174,6 +14177,13 @@ class ImageBaseViewer extends viewers_BaseViewer {
14174
14177
  return;
14175
14178
  }
14176
14179
  this.isPinching = true;
14180
+ this.options.resin?.recordAction({
14181
+ action: 'programmatic',
14182
+ component: 'toolbar',
14183
+ target: event.deltaY > 0 ? 'zoomOut' : 'zoomIn',
14184
+ fileId: this.options.file.id,
14185
+ fileExtension: this.options.file.extension
14186
+ });
14177
14187
  }
14178
14188
 
14179
14189
  // Reset pinch session after a brief idle (no explicit "pinch end" event exists)
@@ -19428,8 +19438,23 @@ class TextBaseViewer extends viewers_BaseViewer {
19428
19438
  wheelZoomHandler(event) {
19429
19439
  const textEl = this.containerEl && this.containerEl.querySelector('.bp-text');
19430
19440
  if (!event.ctrlKey || !textEl) {
19441
+ this.isPinching = false;
19431
19442
  return;
19432
19443
  }
19444
+ if (!this.isPinching) {
19445
+ this.isPinching = true;
19446
+ this.options.resin?.recordAction({
19447
+ action: 'programmatic',
19448
+ component: 'toolbar',
19449
+ target: event.deltaY > 0 ? 'zoomOut' : 'zoomIn',
19450
+ fileId: this.options.file.id,
19451
+ fileExtension: this.options.file.extension
19452
+ });
19453
+ }
19454
+ clearTimeout(this.pinchIdleTimer);
19455
+ this.pinchIdleTimer = setTimeout(() => {
19456
+ this.isPinching = false;
19457
+ }, 200);
19433
19458
  event.preventDefault();
19434
19459
  const scaleDelta = -event.deltaY * WHEEL_ZOOM_SCALE_FACTOR;
19435
19460
  const newScale = Math.min(ZOOM_MAX, Math.max(ZOOM_MIN, this.scale + scaleDelta));
@@ -19550,6 +19575,7 @@ class TextBaseViewer extends viewers_BaseViewer {
19550
19575
  loadUI() {
19551
19576
  this.controls = new ControlsRoot({
19552
19577
  containerEl: this.containerEl,
19578
+ fileExtension: this.options.file.extension,
19553
19579
  fileId: this.options.file.id
19554
19580
  });
19555
19581
  this.bindDOMListeners();
@@ -31829,12 +31855,9 @@ class DocBaseViewer extends viewers_BaseViewer {
31829
31855
  }
31830
31856
  }
31831
31857
 
31832
- // Clean up viewer and PDF document object
31858
+ // Clean up viewer
31833
31859
  if (this.pdfViewer) {
31834
31860
  this.pdfViewer.cleanup();
31835
- if (this.pdfViewer.pdfDocument) {
31836
- this.pdfViewer.pdfDocument.destroy();
31837
- }
31838
31861
  }
31839
31862
  if (this.printPopup) {
31840
31863
  this.printPopup.destroy();
@@ -32064,9 +32087,24 @@ class DocBaseViewer extends viewers_BaseViewer {
32064
32087
  * Loads the viewer assets as opposed to just prefetching them as a performance optimization. This means that the libraries will be loaded
32065
32088
  * into memory eliminating the need to load them when a preview is clicked.
32066
32089
  *
32090
+ * @param {Object} [options]
32091
+ * @param {boolean} [options.isUseNpmPdfjsEnabled] - Warm up the npm-bundled
32092
+ * pdfjs chunks instead of the legacy CDN scripts so this matches what
32093
+ * `load()` will use when the flag is on.
32067
32094
  * @return {void}
32068
32095
  */
32069
32096
  loadViewerAssets() {
32097
+ let {
32098
+ isUseNpmPdfjsEnabled = false
32099
+ } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
32100
+ if (isUseNpmPdfjsEnabled) {
32101
+ this.loadAssets(EXIF_READER, []);
32102
+ // Kick off the dynamic imports so the pdfjs chunks land in cache
32103
+ // before per-file load() awaits them. Errors are swallowed; load()
32104
+ // will surface them later.
32105
+ this.loadPdfjsFromNpm().catch(() => {});
32106
+ return;
32107
+ }
32070
32108
  const ASSETS = [...JS_NO_EXIF, ...EXIF_READER];
32071
32109
  this.loadAssets(ASSETS, docAssets_CSS);
32072
32110
  this.loadAssets(PRELOAD_JS, []);
@@ -32940,6 +32978,7 @@ class DocBaseViewer extends viewers_BaseViewer {
32940
32978
  loadUI() {
32941
32979
  this.controls = new ControlsRoot({
32942
32980
  containerEl: this.containerEl,
32981
+ fileExtension: this.options.file.extension,
32943
32982
  fileId: this.options.file.id
32944
32983
  });
32945
32984
  this.annotationControlsFSM.subscribe(() => this.renderUI());
@@ -33364,8 +33403,23 @@ class DocBaseViewer extends viewers_BaseViewer {
33364
33403
  }
33365
33404
  trackpadPinchToZoomHandler(event) {
33366
33405
  if (!event.ctrlKey) {
33406
+ this.isTrackpadPinching = false;
33367
33407
  return;
33368
33408
  }
33409
+ if (!this.isTrackpadPinching) {
33410
+ this.isTrackpadPinching = true;
33411
+ this.options.resin?.recordAction({
33412
+ action: 'programmatic',
33413
+ component: 'toolbar',
33414
+ target: event.deltaY > 0 ? 'zoomOut' : 'zoomIn',
33415
+ fileId: this.options.file.id,
33416
+ fileExtension: this.options.file.extension
33417
+ });
33418
+ }
33419
+ clearTimeout(this.trackpadPinchIdleTimer);
33420
+ this.trackpadPinchIdleTimer = setTimeout(() => {
33421
+ this.isTrackpadPinching = false;
33422
+ }, 200);
33369
33423
  event.preventDefault();
33370
33424
  const {
33371
33425
  currentScale
@@ -40193,16 +40247,18 @@ class Preview extends (events_default()) {
40193
40247
  *
40194
40248
  * @public
40195
40249
  * @param {string[]} [viewerNames] - Names of viewers to load assets for, defaults to none
40250
+ * @param {Object} [options] - Options forwarded to the viewer's loadViewerAssets
40196
40251
  * @return {void}
40197
40252
  */
40198
40253
  loadViewers() {
40199
40254
  let viewerNames = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
40255
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
40200
40256
  this.getViewers().filter(viewer => viewerNames.includes(viewer.NAME)).forEach(viewer => {
40201
40257
  const viewerInstance = new viewer.CONSTRUCTOR(this.createViewerOptions({
40202
40258
  viewer
40203
40259
  }));
40204
40260
  if (typeof viewerInstance.loadViewerAssets === 'function') {
40205
- viewerInstance.loadViewerAssets();
40261
+ viewerInstance.loadViewerAssets(options);
40206
40262
  }
40207
40263
  });
40208
40264
  }
@@ -40501,6 +40557,9 @@ class Preview extends (events_default()) {
40501
40557
  this.options.preloadStatus = options.preloadStatus;
40502
40558
  this.options.clientName = options.clientName;
40503
40559
 
40560
+ // Optional resin analytics instance for tracking user interactions
40561
+ this.options.resin = options.resin;
40562
+
40504
40563
  // Options that are applicable to certain file ids
40505
40564
  this.options.fileOptions = options.fileOptions || {};
40506
40565
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "box-content-preview",
3
- "version": "3.42.0",
3
+ "version": "3.44.0",
4
4
  "description": "Box Content Preview UI Element",
5
5
  "author": "Box (https://www.box.com/)",
6
6
  "license": "SEE LICENSE IN LICENSE",