@osimatic/helpers-js 1.0.14 → 1.0.17

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.
Files changed (3) hide show
  1. package/index.js +2 -2
  2. package/media.js +4 -18
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -8,7 +8,7 @@ require('./array');
8
8
  // exports d'ojets non natif
9
9
  const { HTTPRequest, Cookie, UrlAndQueryString } = require('./network');
10
10
  const { IBAN, BankCard } = require('./bank');
11
- const { AudioMedia } = require('./media');
11
+ const { AudioMedia, UserMedia } = require('./media');
12
12
  const { PersonName, Email, TelephoneNumber } = require('./contact_details');
13
13
  const { DateTime, TimestampUnix, SqlDate, SqlTime, SqlDateTime, InputPeriod } = require('./date_time');
14
14
  const { Duration } = require('./duration');
@@ -43,7 +43,7 @@ const { NumberValue } = require('./number');
43
43
 
44
44
  module.exports = {
45
45
  Array, Object, Number, String,
46
- HTTPRequest, Cookie, UrlAndQueryString, IBAN, BankCard, AudioMedia, PersonName, Email, TelephoneNumber, DateTime, TimestampUnix, SqlDate, SqlTime, SqlDateTime, InputPeriod, Duration, File, CSV, Img, FormHelper, Country, PostalAddress, Location, SocialNetwork, NumberValue,
46
+ HTTPRequest, Cookie, UrlAndQueryString, IBAN, BankCard, AudioMedia, UserMedia, PersonName, Email, TelephoneNumber, DateTime, TimestampUnix, SqlDate, SqlTime, SqlDateTime, InputPeriod, Duration, File, CSV, Img, FormHelper, Country, PostalAddress, Location, SocialNetwork, NumberValue,
47
47
  DataTable, Pagination, Navigation, DetailsSubArray, SelectAll, MultipleActionInTable, ShoppingCart, FlashMessage, CountDown, ImportFromCsv, JwtToken, JwtSession, ListBox,
48
48
  sleep, refresh, chr, ord, trim, empty,
49
49
  GoogleCharts, GoogleRecaptcha, GoogleMap, OpenStreetMap
package/media.js CHANGED
@@ -83,27 +83,13 @@ class UserMedia {
83
83
 
84
84
  static requestMediaPermissions(constraints) {
85
85
  return new Promise((resolve, reject) => {
86
- let userAgent = navigator.userAgent;
87
- let browser;
88
-
89
- if (userAgent.match(/chrome|chromium|crios/i)) {
90
- browser = "Chrome";
91
- } else if (userAgent.match(/firefox|fxios/i)) {
92
- browser = "firefox";
93
- } else if (userAgent.match(/safari/i)) {
94
- browser = "Safari";
95
- } else if(userAgent.match(/opr\//i)) {
96
- browser = "Opera";
97
- } else if (userAgent.match(/edg/i)) {
98
- browser = "Edge";
99
- } else {
100
- browser = "No browser detection";
101
- }
102
-
86
+ const bowser = require('bowser');
87
+ const browser = bowser.getParser(window.navigator.userAgent).getBrowserName();
88
+
103
89
  navigator.mediaDevices.getUserMedia(constraints !== 'undefined' ? constraints : { audio: true, video: true })
104
90
  .then((stream) => {
105
91
  stream.getTracks().forEach((track) => track.stop());
106
- resolve();
92
+ resolve(stream);
107
93
  }).catch((error) => {
108
94
  const errName = error.name;
109
95
  const errMessage = error.message;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osimatic/helpers-js",
3
- "version": "1.0.14",
3
+ "version": "1.0.17",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"