videomail-client 9.2.1 → 9.2.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "videomail-client",
3
- "version": "9.2.1",
3
+ "version": "9.2.2",
4
4
  "description": "A wicked npm package to record videos directly in the browser, wohooo!",
5
5
  "keywords": [
6
6
  "webcam",
@@ -112,7 +112,7 @@
112
112
  "prettier": "3.3.3",
113
113
  "prettier-plugin-curly": "0.2.2",
114
114
  "prettier-plugin-organize-imports": "4.0.0",
115
- "prettier-plugin-packagejson": "2.5.1",
115
+ "prettier-plugin-packagejson": "2.5.2",
116
116
  "prettier-plugin-sh": "0.14.0",
117
117
  "router": "1.3.8",
118
118
  "tape": "5.8.1",
@@ -0,0 +1,23 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <title>videomail-client examples</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1" />
6
+ </head>
7
+ <body>
8
+ <h1>Attempt to get a snapshot of a non-existing videomail</h1>
9
+ <p>This is how error responses are processed:</p>
10
+ <div id="videomail"></div>
11
+ <pre><code id="error"></code></pre>
12
+ <script src="/js/videomail-client.js"></script>
13
+ <script>
14
+ var videomailClient = new VideomailClient.default();
15
+
16
+ // This showcases how the packError fn works
17
+ videomailClient.get("i do not exist", function (err, videomail) {
18
+ var errorEl = document.getElementById("error");
19
+ errorEl.innerHTML = JSON.stringify(err, null, 4);
20
+ });
21
+ </script>
22
+ </body>
23
+ </html>
@@ -499,6 +499,12 @@
499
499
  ><span class="size">2710</span><span class="date">2019-9-13 11:11:53</span></a
500
500
  >
501
501
  </li>
502
+ <li>
503
+ <a href="/error_handling.html" class="" title="error_handling.html"
504
+ ><span class="name">error_handling.html</span><span class="size">???</span
505
+ ><span class="date">???</span></a
506
+ >
507
+ </li>
502
508
  </ul>
503
509
  </div>
504
510
  </body>
@@ -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.1",
17270
+ "version": "9.2.2",
17271
17271
  "description": "A wicked npm package to record videos directly in the browser, wohooo!",
17272
17272
  "keywords": [
17273
17273
  "webcam",
@@ -17379,7 +17379,7 @@ module.exports={
17379
17379
  "prettier": "3.3.3",
17380
17380
  "prettier-plugin-curly": "0.2.2",
17381
17381
  "prettier-plugin-organize-imports": "4.0.0",
17382
- "prettier-plugin-packagejson": "2.5.1",
17382
+ "prettier-plugin-packagejson": "2.5.2",
17383
17383
  "prettier-plugin-sh": "0.14.0",
17384
17384
  "router": "1.3.8",
17385
17385
  "tape": "5.8.1",
@@ -17922,23 +17922,37 @@ function _default(options) {
17922
17922
  }
17923
17923
  return videomail;
17924
17924
  }
17925
+ function setProperty(packedError, property, value) {
17926
+ Object.defineProperty(packedError, property, {
17927
+ value: value,
17928
+ enumerable: true,
17929
+ configurable: true,
17930
+ writable: true
17931
+ });
17932
+ }
17925
17933
  function packError(err, res) {
17926
17934
  if (res && res.body && res.body.error) {
17927
- // use the server generated text instead of the superagent's default text
17928
- err = res.body.error;
17929
- if (!err.message && res.text) {
17930
- err.message = res.text;
17931
- }
17935
+ var originalError = res.body.error;
17936
+ var packedError = new Error();
17937
+ setProperty(packedError, "name", originalError.name);
17938
+ setProperty(packedError, "message", originalError.message || res.statusText);
17939
+ setProperty(packedError, "cause", originalError.cause);
17940
+ setProperty(packedError, "status", originalError.status);
17941
+ setProperty(packedError, "code", originalError.code);
17942
+ setProperty(packedError, "errno", originalError.errno);
17943
+ setProperty(packedError, "details", originalError.details);
17944
+ setProperty(packedError, "stack", originalError.stack);
17945
+ return packedError;
17932
17946
  }
17933
17947
  return err;
17934
17948
  }
17935
17949
  function fetch(identifierName, identifierValue, cb) {
17936
17950
  var url = "".concat(options.baseUrl, "/videomail/").concat(identifierName, "/").concat(identifierValue, "/snapshot");
17937
17951
  var request = (0, _superagent.default)("get", url);
17938
- request.set("Accept", "application/json").set("Timezone-Id", timezoneId).set(_constants.default.SITE_NAME_LABEL, options.siteName).timeout(options.timeouts.connection).end(function (err, res) {
17939
- err = packError(err, res);
17952
+ request.type("json").set("Accept", "application/json").set("Timezone-Id", timezoneId).set(_constants.default.SITE_NAME_LABEL, options.siteName).timeout(options.timeouts.connection).end(function (err, res) {
17940
17953
  if (err) {
17941
- cb(err);
17954
+ var prettyError = packError(err, res);
17955
+ cb(prettyError);
17942
17956
  } else {
17943
17957
  var videomail = res.body ? res.body : null;
17944
17958
  cb(null, videomail);
@@ -17958,9 +17972,9 @@ function _default(options) {
17958
17972
  var request = (0, _superagent.default)(method, url);
17959
17973
  queryParams[_constants.default.SITE_NAME_LABEL] = options.siteName;
17960
17974
  request.query(queryParams).set("Timezone-Id", timezoneId).send(videomail).timeout(options.timeout).end(function (err, res) {
17961
- err = packError(err, res);
17962
17975
  if (err) {
17963
- cb(err);
17976
+ var prettyError = packError(err, res);
17977
+ cb(prettyError);
17964
17978
  } else {
17965
17979
  var returnedVideomail = res.body && res.body.videomail ? res.body.videomail : null;
17966
17980
  cb(null, returnedVideomail, res.body);
@@ -17979,9 +17993,9 @@ function _default(options) {
17979
17993
  var request = (0, _superagent.default)("post", url);
17980
17994
  queryParams[_constants.default.SITE_NAME_LABEL] = options.siteName;
17981
17995
  request.query(queryParams).send(err).timeout(options.timeout).end(function (err, res) {
17982
- err = packError(err, res);
17983
17996
  if (err) {
17984
- cb && cb(err);
17997
+ var prettyError = packError(err, res);
17998
+ cb && cb(prettyError);
17985
17999
  } else {
17986
18000
  cb && cb();
17987
18001
  }
@@ -18027,9 +18041,9 @@ function _default(options) {
18027
18041
  }
18028
18042
  if (formType) {
18029
18043
  _superagent.default.post(url).type(formType).set("Timezone-Id", timezoneId).send(formData).timeout(options.timeout).end(function (err, res) {
18030
- err = packError(err, res);
18031
18044
  if (err) {
18032
- cb(err);
18045
+ var prettyError = packError(err, res);
18046
+ cb(prettyError);
18033
18047
  } else {
18034
18048
  cb(null, res);
18035
18049
  }
@@ -19989,6 +20003,9 @@ var Container = function Container(options) {
19989
20003
  }
19990
20004
  this.addPlayerDimensions = function (videomail, element) {
19991
20005
  try {
20006
+ if (!videomail) {
20007
+ throw new Error("Videomail data is missing for attaching player dimensions");
20008
+ }
19992
20009
  videomail.playerHeight = self.calculateHeight({
19993
20010
  responsive: true,
19994
20011
  videoWidth: videomail.width,