videomail-client 9.2.2 → 9.2.3

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.
@@ -11,6 +11,7 @@
11
11
  ],
12
12
  "cSpell.words": [
13
13
  "animitter",
14
+ "autobuffer",
14
15
  "bytediff",
15
16
  "classlist",
16
17
  "cssnano",
@@ -23,6 +24,7 @@
23
24
  "keymirror",
24
25
  "Mbit",
25
26
  "packagejson",
27
+ "playsinline",
26
28
  "plusplus",
27
29
  "preend",
28
30
  "rubberband",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "videomail-client",
3
- "version": "9.2.2",
3
+ "version": "9.2.3",
4
4
  "description": "A wicked npm package to record videos directly in the browser, wohooo!",
5
5
  "keywords": [
6
6
  "webcam",
@@ -17267,7 +17267,7 @@ function wrappy (fn, cb) {
17267
17267
  },{}],116:[function(_dereq_,module,exports){
17268
17268
  module.exports={
17269
17269
  "name": "videomail-client",
17270
- "version": "9.2.2",
17270
+ "version": "9.2.3",
17271
17271
  "description": "A wicked npm package to record videos directly in the browser, wohooo!",
17272
17272
  "keywords": [
17273
17273
  "webcam",
@@ -17415,7 +17415,6 @@ var _collectLogger = _interopRequireDefault(_dereq_("./util/collectLogger"));
17415
17415
  var _eventEmitter = _interopRequireDefault(_dereq_("./util/eventEmitter"));
17416
17416
  var _container = _interopRequireDefault(_dereq_("./wrappers/container"));
17417
17417
  var _optionsWrapper = _interopRequireDefault(_dereq_("./wrappers/optionsWrapper"));
17418
- var _replay = _interopRequireDefault(_dereq_("./wrappers/visuals/replay"));
17419
17418
  var collectLogger;
17420
17419
  var browser;
17421
17420
  function adjustOptions() {
@@ -17441,7 +17440,6 @@ var VideomailClient = function VideomailClient(options) {
17441
17440
  var localOptions = adjustOptions(options);
17442
17441
  var container = new _container.default(localOptions);
17443
17442
  var debug = localOptions.debug;
17444
- var replay;
17445
17443
  this.events = _events.default;
17446
17444
  _eventEmitter.default.call(this, localOptions, "VideomailClient");
17447
17445
  this.build = function () {
@@ -17466,47 +17464,31 @@ var VideomailClient = function VideomailClient(options) {
17466
17464
  };
17467
17465
 
17468
17466
  /*
17469
- * automatically adds a <video> element inside the given parentElement and loads
17470
- * it with the videomail
17467
+ * Automatically adds a <video> element inside the given parentElement and
17468
+ * loads it with the videomail
17471
17469
  */
17472
- this.replay = function (videomail, parentElement) {
17473
- function buildReplay() {
17474
- if (typeof parentElement === "string") {
17475
- parentElement = document.getElementById(parentElement);
17476
- }
17477
- if (!parentElement) {
17478
- if (!container.isBuilt()) {
17479
- // this will try build all over again
17480
- container.build(true);
17481
- }
17482
- if (!container.hasElement()) {
17483
- throw new Error("Unable to replay video without a container nor parent element.");
17484
- }
17485
- } else if (container.isOutsideElementOf(parentElement)) {
17486
- replay = new _replay.default(parentElement, localOptions);
17487
- replay.build();
17488
- }
17489
- if (!replay) {
17490
- replay = container.getReplay();
17491
- }
17492
- if (!parentElement) {
17493
- parentElement = replay.getParentElement();
17494
- }
17495
- if (videomail) {
17496
- videomail = container.addPlayerDimensions(videomail, parentElement);
17497
- }
17498
- container.buildForm(videomail);
17499
- container.loadForm(videomail);
17500
-
17501
- // slight delay needed to avoid HTTP 416 errors (request range unavailable)
17502
- setTimeout(function () {
17503
- replay.setVideomail(videomail);
17504
- container.showReplayOnly();
17505
- }, 10e1); // not sure, but probably can be reduced a bit
17470
+ this.replay = function (videomail, replayParentElement) {
17471
+ if (!container.isBuilt()) {
17472
+ container.build(true, replayParentElement);
17473
+ }
17474
+ if (!container.hasElement()) {
17475
+ throw new Error("Unable to replay video without a container nor parent element.");
17476
+ }
17477
+ if (videomail) {
17478
+ videomail = container.addPlayerDimensions(videomail);
17506
17479
  }
17507
- buildReplay();
17480
+ container.buildForm();
17481
+ container.loadForm(videomail);
17482
+
17483
+ // slight delay needed to avoid HTTP 416 errors (request range unavailable)
17484
+ setTimeout(function () {
17485
+ var replay = container.getReplay();
17486
+ replay.setVideomail(videomail);
17487
+ container.showReplayOnly();
17488
+ }, 50); // not sure, but probably can be reduced a bit
17508
17489
  };
17509
17490
  this.startOver = function (params) {
17491
+ var replay = container.getReplay();
17510
17492
  if (replay) {
17511
17493
  replay.hide();
17512
17494
  replay.reset();
@@ -17574,7 +17556,7 @@ Object.keys(_constants.default.public).forEach(function (name) {
17574
17556
  VideomailClient.Events = _events.default;
17575
17557
  var _default = exports.default = VideomailClient;
17576
17558
 
17577
- },{"./constants":118,"./events":119,"./options":120,"./resource":121,"./util/browser":123,"./util/collectLogger":124,"./util/eventEmitter":125,"./wrappers/container":132,"./wrappers/optionsWrapper":135,"./wrappers/visuals/replay":145,"@babel/runtime/helpers/interopRequireDefault":4,"deepmerge":28,"inherits":66}],118:[function(_dereq_,module,exports){
17559
+ },{"./constants":118,"./events":119,"./options":120,"./resource":121,"./util/browser":123,"./util/collectLogger":124,"./util/eventEmitter":125,"./wrappers/container":132,"./wrappers/optionsWrapper":135,"@babel/runtime/helpers/interopRequireDefault":4,"deepmerge":28,"inherits":66}],118:[function(_dereq_,module,exports){
17578
17560
  "use strict";
17579
17561
 
17580
17562
  Object.defineProperty(exports, "__esModule", {
@@ -19766,6 +19748,7 @@ var Container = function Container(options) {
19766
19748
  var containerElement;
19767
19749
  var built;
19768
19750
  var form;
19751
+ validateOptions();
19769
19752
  function prependDefaultCss() {
19770
19753
  (0, _insertCss.default)(_mainMinCss.default, {
19771
19754
  prepend: true
@@ -19793,7 +19776,6 @@ var Container = function Container(options) {
19793
19776
  }
19794
19777
  var formElement = getFormElement();
19795
19778
  if (formElement) {
19796
- debug("Container: buildForm()");
19797
19779
  form = new _form.default(self, formElement, options);
19798
19780
  var submitButton = form.findSubmitButton();
19799
19781
  if (submitButton) {
@@ -19804,7 +19786,8 @@ var Container = function Container(options) {
19804
19786
  };
19805
19787
  function buildChildren() {
19806
19788
  var playerOnly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
19807
- debug("Container: buildChildren (playerOnly = ".concat(playerOnly, ")"));
19789
+ var replayParentElement = arguments.length > 1 ? arguments[1] : undefined;
19790
+ debug("Container: buildChildren (playerOnly = ".concat(playerOnly).concat(replayParentElement ? ", replayParentElement=\"".concat(replayParentElement, "\"") : "", ")"));
19808
19791
  if (!containerElement.classList) {
19809
19792
  self.emit(_events.default.ERROR, _videomailError.default.create("Sorry, your browser is too old!", options));
19810
19793
  } else {
@@ -19812,7 +19795,7 @@ var Container = function Container(options) {
19812
19795
  if (!playerOnly) {
19813
19796
  buttons.build();
19814
19797
  }
19815
- visuals.build(playerOnly);
19798
+ visuals.build(playerOnly, replayParentElement);
19816
19799
  }
19817
19800
  }
19818
19801
  function processError(err) {
@@ -19903,7 +19886,7 @@ var Container = function Container(options) {
19903
19886
  }
19904
19887
 
19905
19888
  /*
19906
- * this will just set the width but not the height because
19889
+ * This will just set the width but not the height because
19907
19890
  * it can be a form with more inputs elements
19908
19891
  */
19909
19892
  function correctDimensions() {
@@ -20001,16 +19984,18 @@ var Container = function Container(options) {
20001
19984
  }
20002
19985
  }
20003
19986
  }
20004
- this.addPlayerDimensions = function (videomail, element) {
19987
+ this.addPlayerDimensions = function (videomail) {
20005
19988
  try {
20006
19989
  if (!videomail) {
20007
19990
  throw new Error("Videomail data is missing for attaching player dimensions");
20008
19991
  }
19992
+ var replay = self.getReplay();
19993
+ var replayParentElement = replay.getParentElement();
20009
19994
  videomail.playerHeight = self.calculateHeight({
20010
19995
  responsive: true,
20011
19996
  videoWidth: videomail.width,
20012
19997
  ratio: videomail.height / videomail.width
20013
- }, element);
19998
+ }, replayParentElement);
20014
19999
  videomail.playerWidth = self.calculateWidth({
20015
20000
  responsive: true,
20016
20001
  videoHeight: videomail.playerHeight,
@@ -20049,24 +20034,24 @@ var Container = function Container(options) {
20049
20034
  };
20050
20035
  this.build = function () {
20051
20036
  var playerOnly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
20052
- debug("Container: build (playerOnly = ".concat(playerOnly, ")"));
20037
+ var replayParentElement = arguments.length > 1 ? arguments[1] : undefined;
20038
+ debug("Container: build (playerOnly = ".concat(playerOnly).concat(replayParentElement ? ", replayParentElement=\"".concat(replayParentElement, "\"") : "", ")"));
20053
20039
  try {
20054
20040
  containerElement = document.getElementById(options.selectors.containerId);
20055
20041
 
20056
20042
  /*
20057
- * only build when a container element hast been found, otherwise
20058
- * be silent and do nothing
20043
+ * Only build when a container element hast been found,
20044
+ * otherwise be silent and do nothing
20059
20045
  */
20060
20046
  if (containerElement) {
20061
20047
  options.insertCss && prependDefaultCss();
20062
20048
  !built && initEvents(playerOnly);
20063
- validateOptions();
20064
20049
  correctDimensions();
20065
20050
 
20066
20051
  // Building form also applies for when `playerOnly` because of
20067
20052
  // correcting mode on Videomail. This function will skip if there is no form. Easy.
20068
20053
  self.buildForm();
20069
- buildChildren(playerOnly);
20054
+ buildChildren(playerOnly, replayParentElement);
20070
20055
  if (!hasError) {
20071
20056
  debug("Container: built.");
20072
20057
  built = true;
@@ -20076,16 +20061,12 @@ var Container = function Container(options) {
20076
20061
  }
20077
20062
  } else {
20078
20063
  /*
20079
- * commented out since it does too much noise on videomail's view page which is fine
20064
+ * Commented out since it does too much noise on videomail's view page which is fine
20080
20065
  * debug('Container: no container element with ID ' + options.selectors.containerId + ' found. Do nothing.')
20081
20066
  */
20082
20067
  }
20083
20068
  } catch (exc) {
20084
- if (visuals.isNotifierBuilt()) {
20085
- self.emit(_events.default.ERROR, exc);
20086
- } else {
20087
- throw exc;
20088
- }
20069
+ self.emit(_events.default.ERROR, exc);
20089
20070
  }
20090
20071
  };
20091
20072
  this.getSubmitButton = function () {
@@ -20223,9 +20204,6 @@ var Container = function Container(options) {
20223
20204
  }
20224
20205
  if (!valid) {
20225
20206
  whyInvalid = "Don't forget to record a video 😉";
20226
- invalidData = {
20227
- key: undefined
20228
- };
20229
20207
  }
20230
20208
  }
20231
20209
  } else {
@@ -20289,8 +20267,10 @@ var Container = function Container(options) {
20289
20267
  }
20290
20268
  if (valid) {
20291
20269
  self.emit(_events.default.VALID);
20292
- } else {
20270
+ } else if (invalidData) {
20293
20271
  self.emit(_events.default.INVALID, whyInvalid, invalidData);
20272
+ } else {
20273
+ self.emit(_events.default.INVALID, whyInvalid);
20294
20274
  }
20295
20275
  lastValidation = valid;
20296
20276
  }
@@ -20315,7 +20295,7 @@ var Container = function Container(options) {
20315
20295
  return method && method.toUpperCase() === "PUT";
20316
20296
  }
20317
20297
  this.submitAll = function (formData, method, url) {
20318
- debug("Container: submitAll(".concat(method, ": ").concat(url, ")"));
20298
+ debug("Container: submitAll(".concat(method, ": \"").concat(url, "\")"));
20319
20299
  var post = isPost(method);
20320
20300
  var hasVideomailKey = Boolean(formData[options.selectors.keyInputName]);
20321
20301
  function startSubmission() {
@@ -20934,13 +20914,14 @@ var Visuals = function Visuals(container, options) {
20934
20914
  }
20935
20915
  function buildChildren() {
20936
20916
  var playerOnly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
20937
- debug("Visuals: buildChildren (playerOnly = ".concat(playerOnly, ")"));
20917
+ var replayParentElement = arguments.length > 1 ? arguments[1] : undefined;
20918
+ debug("Visuals: buildChildren (playerOnly = ".concat(playerOnly).concat(replayParentElement ? ", replayParentElement=\"".concat(replayParentElement, "\"") : "", ")"));
20938
20919
  buildNoScriptTag();
20939
20920
  if (!playerOnly) {
20940
20921
  notifier.build();
20941
20922
  recorderInsides.build();
20942
20923
  }
20943
- replay.build();
20924
+ replay.build(replayParentElement);
20944
20925
  }
20945
20926
  function initEvents() {
20946
20927
  var playerOnly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
@@ -21000,6 +20981,7 @@ var Visuals = function Visuals(container, options) {
21000
20981
  };
21001
20982
  this.build = function () {
21002
20983
  var playerOnly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
20984
+ var replayParentElement = arguments.length > 1 ? arguments[1] : undefined;
21003
20985
  visualsElement = container.querySelector(".".concat(options.selectors.visualsClass));
21004
20986
  if (!visualsElement) {
21005
20987
  visualsElement = (0, _hyperscript.default)("div.".concat(options.selectors.visualsClass));
@@ -21024,7 +21006,7 @@ var Visuals = function Visuals(container, options) {
21024
21006
  visualsElement.classList.add("visuals");
21025
21007
  correctDimensions();
21026
21008
  !built && initEvents(playerOnly);
21027
- buildChildren(playerOnly);
21009
+ buildChildren(playerOnly, replayParentElement);
21028
21010
 
21029
21011
  // needed for replay handling and container.isOutsideElementOf()
21030
21012
  self.parentNode = visualsElement.parentNode;
@@ -21088,7 +21070,7 @@ var Visuals = function Visuals(container, options) {
21088
21070
  debug("Visuals: unload(".concat(e ? (0, _safeJsonStringify.default)(e) : "", ")"));
21089
21071
  recorder.unload(e);
21090
21072
  recorderInsides.unload(e);
21091
- replay.unload(e);
21073
+ replay.unload();
21092
21074
  built = false;
21093
21075
  } catch (exc) {
21094
21076
  this.emit(_events.default.ERROR, exc);
@@ -23127,12 +23109,15 @@ var Replay = function Replay(parentElement, options) {
23127
23109
  var replayElement;
23128
23110
  var videomail;
23129
23111
  function buildElement() {
23130
- debug("Replay: buildElement()");
23112
+ var replayParentElement = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : parentElement;
23131
23113
  replayElement = (0, _hyperscript.default)("video.".concat(options.selectors.replayClass));
23132
23114
  if (!replayElement.setAttribute) {
23133
23115
  throw _videomailError.default.create("Please upgrade browser", options);
23134
23116
  }
23135
- parentElement.appendChild(replayElement);
23117
+ if (typeof replayParentElement === "string") {
23118
+ replayParentElement = document.getElementById(replayParentElement);
23119
+ }
23120
+ replayParentElement.appendChild(replayElement);
23136
23121
  }
23137
23122
  function isStandalone() {
23138
23123
  return parentElement.constructor.name === "HTMLDivElement";
@@ -23242,11 +23227,11 @@ var Replay = function Replay(parentElement, options) {
23242
23227
  self.emit(_events.default.REPLAY_SHOWN);
23243
23228
  }
23244
23229
  };
23245
- this.build = function () {
23246
- debug("Replay: build()");
23230
+ this.build = function (replayParentElement) {
23231
+ debug("Replay: build (".concat(replayParentElement ? "replayParentElement=\"".concat(replayParentElement, "\"") : "", ")"));
23247
23232
  replayElement = parentElement.querySelector("video.".concat(options.selectors.replayClass));
23248
23233
  if (!replayElement) {
23249
- buildElement();
23234
+ buildElement(replayParentElement);
23250
23235
  }
23251
23236
  this.hide();
23252
23237
  replayElement.setAttribute("autoplay", true);