videomail-client 9.2.2 → 9.2.4

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.4",
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.4",
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,11 +19748,7 @@ var Container = function Container(options) {
19766
19748
  var containerElement;
19767
19749
  var built;
19768
19750
  var form;
19769
- function prependDefaultCss() {
19770
- (0, _insertCss.default)(_mainMinCss.default, {
19771
- prepend: true
19772
- });
19773
- }
19751
+ validateOptions();
19774
19752
 
19775
19753
  // since https://github.com/binarykitchen/videomail-client/issues/87
19776
19754
  function findParentFormElement() {
@@ -19793,7 +19771,6 @@ var Container = function Container(options) {
19793
19771
  }
19794
19772
  var formElement = getFormElement();
19795
19773
  if (formElement) {
19796
- debug("Container: buildForm()");
19797
19774
  form = new _form.default(self, formElement, options);
19798
19775
  var submitButton = form.findSubmitButton();
19799
19776
  if (submitButton) {
@@ -19804,7 +19781,8 @@ var Container = function Container(options) {
19804
19781
  };
19805
19782
  function buildChildren() {
19806
19783
  var playerOnly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
19807
- debug("Container: buildChildren (playerOnly = ".concat(playerOnly, ")"));
19784
+ var replayParentElement = arguments.length > 1 ? arguments[1] : undefined;
19785
+ debug("Container: buildChildren (playerOnly = ".concat(playerOnly).concat(replayParentElement ? ", replayParentElement=\"".concat(replayParentElement, "\"") : "", ")"));
19808
19786
  if (!containerElement.classList) {
19809
19787
  self.emit(_events.default.ERROR, _videomailError.default.create("Sorry, your browser is too old!", options));
19810
19788
  } else {
@@ -19812,7 +19790,7 @@ var Container = function Container(options) {
19812
19790
  if (!playerOnly) {
19813
19791
  buttons.build();
19814
19792
  }
19815
- visuals.build(playerOnly);
19793
+ visuals.build(playerOnly, replayParentElement);
19816
19794
  }
19817
19795
  }
19818
19796
  function processError(err) {
@@ -19903,7 +19881,7 @@ var Container = function Container(options) {
19903
19881
  }
19904
19882
 
19905
19883
  /*
19906
- * this will just set the width but not the height because
19884
+ * This will just set the width but not the height because
19907
19885
  * it can be a form with more inputs elements
19908
19886
  */
19909
19887
  function correctDimensions() {
@@ -20001,16 +19979,18 @@ var Container = function Container(options) {
20001
19979
  }
20002
19980
  }
20003
19981
  }
20004
- this.addPlayerDimensions = function (videomail, element) {
19982
+ this.addPlayerDimensions = function (videomail) {
20005
19983
  try {
20006
19984
  if (!videomail) {
20007
19985
  throw new Error("Videomail data is missing for attaching player dimensions");
20008
19986
  }
19987
+ var replay = self.getReplay();
19988
+ var replayParentElement = replay.getParentElement();
20009
19989
  videomail.playerHeight = self.calculateHeight({
20010
19990
  responsive: true,
20011
19991
  videoWidth: videomail.width,
20012
19992
  ratio: videomail.height / videomail.width
20013
- }, element);
19993
+ }, replayParentElement);
20014
19994
  videomail.playerWidth = self.calculateWidth({
20015
19995
  responsive: true,
20016
19996
  videoHeight: videomail.playerHeight,
@@ -20047,45 +20027,36 @@ var Container = function Container(options) {
20047
20027
  this.hasElement = function () {
20048
20028
  return Boolean(containerElement);
20049
20029
  };
20030
+ function prependDefaultCss() {
20031
+ (0, _insertCss.default)(_mainMinCss.default, {
20032
+ prepend: true
20033
+ });
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
- containerElement = document.getElementById(options.selectors.containerId);
20040
+ options.insertCss && prependDefaultCss();
20055
20041
 
20056
- /*
20057
- * only build when a container element hast been found, otherwise
20058
- * be silent and do nothing
20059
- */
20060
- if (containerElement) {
20061
- options.insertCss && prependDefaultCss();
20062
- !built && initEvents(playerOnly);
20063
- validateOptions();
20064
- correctDimensions();
20042
+ // Note, it can be undefined when e.g. just replaying a videomail
20043
+ containerElement = document.getElementById(options.selectors.containerId);
20044
+ !built && initEvents(playerOnly);
20045
+ correctDimensions();
20065
20046
 
20066
- // Building form also applies for when `playerOnly` because of
20067
- // correcting mode on Videomail. This function will skip if there is no form. Easy.
20068
- self.buildForm();
20069
- buildChildren(playerOnly);
20070
- if (!hasError) {
20071
- debug("Container: built.");
20072
- built = true;
20073
- self.emit(_events.default.BUILT);
20074
- } else {
20075
- debug("Container: building failed due to an error.");
20076
- }
20047
+ // Building form also applies for when `playerOnly` because of
20048
+ // correcting mode on Videomail. This function will skip if there is no form. Easy.
20049
+ self.buildForm();
20050
+ buildChildren(playerOnly, replayParentElement);
20051
+ if (!hasError) {
20052
+ debug("Container: built.");
20053
+ built = true;
20054
+ self.emit(_events.default.BUILT);
20077
20055
  } else {
20078
- /*
20079
- * commented out since it does too much noise on videomail's view page which is fine
20080
- * debug('Container: no container element with ID ' + options.selectors.containerId + ' found. Do nothing.')
20081
- */
20056
+ debug("Container: building failed due to an error.");
20082
20057
  }
20083
20058
  } catch (exc) {
20084
- if (visuals.isNotifierBuilt()) {
20085
- self.emit(_events.default.ERROR, exc);
20086
- } else {
20087
- throw exc;
20088
- }
20059
+ self.emit(_events.default.ERROR, exc);
20089
20060
  }
20090
20061
  };
20091
20062
  this.getSubmitButton = function () {
@@ -20223,9 +20194,6 @@ var Container = function Container(options) {
20223
20194
  }
20224
20195
  if (!valid) {
20225
20196
  whyInvalid = "Don't forget to record a video 😉";
20226
- invalidData = {
20227
- key: undefined
20228
- };
20229
20197
  }
20230
20198
  }
20231
20199
  } else {
@@ -20289,8 +20257,10 @@ var Container = function Container(options) {
20289
20257
  }
20290
20258
  if (valid) {
20291
20259
  self.emit(_events.default.VALID);
20292
- } else {
20260
+ } else if (invalidData) {
20293
20261
  self.emit(_events.default.INVALID, whyInvalid, invalidData);
20262
+ } else {
20263
+ self.emit(_events.default.INVALID, whyInvalid);
20294
20264
  }
20295
20265
  lastValidation = valid;
20296
20266
  }
@@ -20315,7 +20285,7 @@ var Container = function Container(options) {
20315
20285
  return method && method.toUpperCase() === "PUT";
20316
20286
  }
20317
20287
  this.submitAll = function (formData, method, url) {
20318
- debug("Container: submitAll(".concat(method, ": ").concat(url, ")"));
20288
+ debug("Container: submitAll(".concat(method, ": \"").concat(url, "\")"));
20319
20289
  var post = isPost(method);
20320
20290
  var hasVideomailKey = Boolean(formData[options.selectors.keyInputName]);
20321
20291
  function startSubmission() {
@@ -20934,13 +20904,14 @@ var Visuals = function Visuals(container, options) {
20934
20904
  }
20935
20905
  function buildChildren() {
20936
20906
  var playerOnly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
20937
- debug("Visuals: buildChildren (playerOnly = ".concat(playerOnly, ")"));
20907
+ var replayParentElement = arguments.length > 1 ? arguments[1] : undefined;
20908
+ debug("Visuals: buildChildren (playerOnly = ".concat(playerOnly).concat(replayParentElement ? ", replayParentElement=\"".concat(replayParentElement, "\"") : "", ")"));
20938
20909
  buildNoScriptTag();
20939
20910
  if (!playerOnly) {
20940
20911
  notifier.build();
20941
20912
  recorderInsides.build();
20942
20913
  }
20943
- replay.build();
20914
+ replay.build(replayParentElement);
20944
20915
  }
20945
20916
  function initEvents() {
20946
20917
  var playerOnly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
@@ -21000,6 +20971,7 @@ var Visuals = function Visuals(container, options) {
21000
20971
  };
21001
20972
  this.build = function () {
21002
20973
  var playerOnly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
20974
+ var replayParentElement = arguments.length > 1 ? arguments[1] : undefined;
21003
20975
  visualsElement = container.querySelector(".".concat(options.selectors.visualsClass));
21004
20976
  if (!visualsElement) {
21005
20977
  visualsElement = (0, _hyperscript.default)("div.".concat(options.selectors.visualsClass));
@@ -21024,7 +20996,7 @@ var Visuals = function Visuals(container, options) {
21024
20996
  visualsElement.classList.add("visuals");
21025
20997
  correctDimensions();
21026
20998
  !built && initEvents(playerOnly);
21027
- buildChildren(playerOnly);
20999
+ buildChildren(playerOnly, replayParentElement);
21028
21000
 
21029
21001
  // needed for replay handling and container.isOutsideElementOf()
21030
21002
  self.parentNode = visualsElement.parentNode;
@@ -21088,7 +21060,7 @@ var Visuals = function Visuals(container, options) {
21088
21060
  debug("Visuals: unload(".concat(e ? (0, _safeJsonStringify.default)(e) : "", ")"));
21089
21061
  recorder.unload(e);
21090
21062
  recorderInsides.unload(e);
21091
- replay.unload(e);
21063
+ replay.unload();
21092
21064
  built = false;
21093
21065
  } catch (exc) {
21094
21066
  this.emit(_events.default.ERROR, exc);
@@ -23127,12 +23099,15 @@ var Replay = function Replay(parentElement, options) {
23127
23099
  var replayElement;
23128
23100
  var videomail;
23129
23101
  function buildElement() {
23130
- debug("Replay: buildElement()");
23102
+ var replayParentElement = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : parentElement;
23131
23103
  replayElement = (0, _hyperscript.default)("video.".concat(options.selectors.replayClass));
23132
23104
  if (!replayElement.setAttribute) {
23133
23105
  throw _videomailError.default.create("Please upgrade browser", options);
23134
23106
  }
23135
- parentElement.appendChild(replayElement);
23107
+ if (typeof replayParentElement === "string") {
23108
+ replayParentElement = document.getElementById(replayParentElement);
23109
+ }
23110
+ replayParentElement.appendChild(replayElement);
23136
23111
  }
23137
23112
  function isStandalone() {
23138
23113
  return parentElement.constructor.name === "HTMLDivElement";
@@ -23242,11 +23217,11 @@ var Replay = function Replay(parentElement, options) {
23242
23217
  self.emit(_events.default.REPLAY_SHOWN);
23243
23218
  }
23244
23219
  };
23245
- this.build = function () {
23246
- debug("Replay: build()");
23220
+ this.build = function (replayParentElement) {
23221
+ debug("Replay: build (".concat(replayParentElement ? "replayParentElement=\"".concat(replayParentElement, "\"") : "", ")"));
23247
23222
  replayElement = parentElement.querySelector("video.".concat(options.selectors.replayClass));
23248
23223
  if (!replayElement) {
23249
- buildElement();
23224
+ buildElement(replayParentElement);
23250
23225
  }
23251
23226
  this.hide();
23252
23227
  replayElement.setAttribute("autoplay", true);