@neurosity/sdk 6.4.0-next.0 → 6.4.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/dist/browser/neurosity.iife.js +777 -806
- package/dist/browser/neurosity.js +13 -13
- package/dist/browser/neurosity.js.map +1 -1
- package/dist/cjs/Neurosity.d.ts +5 -0
- package/dist/cjs/Neurosity.js +18 -6
- package/dist/cjs/api/bluetooth/BluetoothClient.d.ts +3 -3
- package/dist/cjs/api/bluetooth/BluetoothClient.js +34 -33
- package/dist/cjs/api/bluetooth/react-native/ReactNativeTransport.d.ts +4 -5
- package/dist/cjs/api/bluetooth/react-native/ReactNativeTransport.js +38 -48
- package/dist/cjs/api/bluetooth/web/WebBluetoothTransport.d.ts +4 -5
- package/dist/cjs/api/bluetooth/web/WebBluetoothTransport.js +36 -46
- package/dist/electron/index.js +9 -9
- package/dist/electron/index.js.map +1 -1
- package/dist/esm/Neurosity.d.ts +5 -0
- package/dist/esm/Neurosity.js +19 -7
- package/dist/esm/api/bluetooth/BluetoothClient.d.ts +3 -3
- package/dist/esm/api/bluetooth/BluetoothClient.js +35 -34
- package/dist/esm/api/bluetooth/react-native/ReactNativeTransport.d.ts +4 -5
- package/dist/esm/api/bluetooth/react-native/ReactNativeTransport.js +35 -45
- package/dist/esm/api/bluetooth/web/WebBluetoothTransport.d.ts +4 -5
- package/dist/esm/api/bluetooth/web/WebBluetoothTransport.js +35 -45
- package/dist/esm/neurosity.mjs +777 -806
- package/dist/examples/neurosity.iife.js +777 -806
- package/dist/examples/neurosity.js +13 -13
- package/dist/examples/neurosity.mjs +777 -806
- package/package.json +1 -1
package/dist/esm/neurosity.mjs
CHANGED
|
@@ -2304,11 +2304,6 @@ function merge() {
|
|
|
2304
2304
|
|
|
2305
2305
|
var NEVER = new Observable(noop);
|
|
2306
2306
|
|
|
2307
|
-
var isArray$2 = Array.isArray;
|
|
2308
|
-
function argsOrArgArray(args) {
|
|
2309
|
-
return args.length === 1 && isArray$2(args[0]) ? args[0] : args;
|
|
2310
|
-
}
|
|
2311
|
-
|
|
2312
2307
|
function filter(predicate, thisArg) {
|
|
2313
2308
|
return operate(function (source, subscriber) {
|
|
2314
2309
|
var index = 0;
|
|
@@ -2437,27 +2432,6 @@ function scanInternals(accumulator, seed, hasSeed, emitOnNext, emitBeforeComplet
|
|
|
2437
2432
|
};
|
|
2438
2433
|
}
|
|
2439
2434
|
|
|
2440
|
-
function combineLatest$1() {
|
|
2441
|
-
var args = [];
|
|
2442
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2443
|
-
args[_i] = arguments[_i];
|
|
2444
|
-
}
|
|
2445
|
-
var resultSelector = popResultSelector(args);
|
|
2446
|
-
return resultSelector
|
|
2447
|
-
? pipe(combineLatest$1.apply(void 0, __spreadArray([], __read(args))), mapOneOrManyArgs(resultSelector))
|
|
2448
|
-
: operate(function (source, subscriber) {
|
|
2449
|
-
combineLatestInit(__spreadArray([source], __read(argsOrArgArray(args))))(subscriber);
|
|
2450
|
-
});
|
|
2451
|
-
}
|
|
2452
|
-
|
|
2453
|
-
function combineLatestWith() {
|
|
2454
|
-
var otherSources = [];
|
|
2455
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2456
|
-
otherSources[_i] = arguments[_i];
|
|
2457
|
-
}
|
|
2458
|
-
return combineLatest$1.apply(void 0, __spreadArray([], __read(otherSources)));
|
|
2459
|
-
}
|
|
2460
|
-
|
|
2461
2435
|
function concatMap(project, resultSelector) {
|
|
2462
2436
|
return isFunction(resultSelector) ? mergeMap(project, resultSelector, 1) : mergeMap(project, 1);
|
|
2463
2437
|
}
|
|
@@ -45777,684 +45751,110 @@ const DEFAULT_ACTION_RESPONSE_TIMEOUT = 1000 * 60; // 1 minute
|
|
|
45777
45751
|
// Reverse BLUETOOTH_CHARACTERISTICS key/values for easy lookup
|
|
45778
45752
|
const CHARACTERISTIC_UUIDS_TO_NAMES = Object.fromEntries(Object.entries(BLUETOOTH_CHARACTERISTICS).map((entries) => entries.reverse()));
|
|
45779
45753
|
|
|
45780
|
-
|
|
45781
|
-
|
|
45782
|
-
|
|
45783
|
-
|
|
45784
|
-
|
|
45785
|
-
) ? (
|
|
45786
|
-
|
|
45787
|
-
|
|
45788
|
-
var debug_1 = debug;
|
|
45789
|
-
|
|
45790
|
-
// Note: this is the semver.org version of the spec that it implements
|
|
45791
|
-
// Not necessarily the package version of this code.
|
|
45792
|
-
const SEMVER_SPEC_VERSION = '2.0.0';
|
|
45793
|
-
|
|
45794
|
-
const MAX_LENGTH = 256;
|
|
45795
|
-
const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
|
|
45796
|
-
/* istanbul ignore next */ 9007199254740991;
|
|
45797
|
-
|
|
45798
|
-
// Max safe segment length for coercion.
|
|
45799
|
-
const MAX_SAFE_COMPONENT_LENGTH = 16;
|
|
45800
|
-
|
|
45801
|
-
var constants = {
|
|
45802
|
-
SEMVER_SPEC_VERSION,
|
|
45803
|
-
MAX_LENGTH,
|
|
45804
|
-
MAX_SAFE_INTEGER,
|
|
45805
|
-
MAX_SAFE_COMPONENT_LENGTH,
|
|
45806
|
-
};
|
|
45807
|
-
|
|
45808
|
-
function createCommonjsModule(fn, module) {
|
|
45809
|
-
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
45810
|
-
}
|
|
45811
|
-
|
|
45812
|
-
var re_1 = createCommonjsModule(function (module, exports) {
|
|
45813
|
-
const { MAX_SAFE_COMPONENT_LENGTH } = constants;
|
|
45814
|
-
|
|
45815
|
-
exports = module.exports = {};
|
|
45816
|
-
|
|
45817
|
-
// The actual regexps go on exports.re
|
|
45818
|
-
const re = exports.re = [];
|
|
45819
|
-
const src = exports.src = [];
|
|
45820
|
-
const t = exports.t = {};
|
|
45821
|
-
let R = 0;
|
|
45822
|
-
|
|
45823
|
-
const createToken = (name, value, isGlobal) => {
|
|
45824
|
-
const index = R++;
|
|
45825
|
-
debug_1(name, index, value);
|
|
45826
|
-
t[name] = index;
|
|
45827
|
-
src[index] = value;
|
|
45828
|
-
re[index] = new RegExp(value, isGlobal ? 'g' : undefined);
|
|
45829
|
-
};
|
|
45830
|
-
|
|
45831
|
-
// The following Regular Expressions can be used for tokenizing,
|
|
45832
|
-
// validating, and parsing SemVer version strings.
|
|
45833
|
-
|
|
45834
|
-
// ## Numeric Identifier
|
|
45835
|
-
// A single `0`, or a non-zero digit followed by zero or more digits.
|
|
45836
|
-
|
|
45837
|
-
createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*');
|
|
45838
|
-
createToken('NUMERICIDENTIFIERLOOSE', '[0-9]+');
|
|
45839
|
-
|
|
45840
|
-
// ## Non-numeric Identifier
|
|
45841
|
-
// Zero or more digits, followed by a letter or hyphen, and then zero or
|
|
45842
|
-
// more letters, digits, or hyphens.
|
|
45843
|
-
|
|
45844
|
-
createToken('NONNUMERICIDENTIFIER', '\\d*[a-zA-Z-][a-zA-Z0-9-]*');
|
|
45845
|
-
|
|
45846
|
-
// ## Main Version
|
|
45847
|
-
// Three dot-separated numeric identifiers.
|
|
45848
|
-
|
|
45849
|
-
createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` +
|
|
45850
|
-
`(${src[t.NUMERICIDENTIFIER]})\\.` +
|
|
45851
|
-
`(${src[t.NUMERICIDENTIFIER]})`);
|
|
45852
|
-
|
|
45853
|
-
createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
|
|
45854
|
-
`(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
|
|
45855
|
-
`(${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
|
45856
|
-
|
|
45857
|
-
// ## Pre-release Version Identifier
|
|
45858
|
-
// A numeric identifier, or a non-numeric identifier.
|
|
45859
|
-
|
|
45860
|
-
createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER]
|
|
45861
|
-
}|${src[t.NONNUMERICIDENTIFIER]})`);
|
|
45862
|
-
|
|
45863
|
-
createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE]
|
|
45864
|
-
}|${src[t.NONNUMERICIDENTIFIER]})`);
|
|
45865
|
-
|
|
45866
|
-
// ## Pre-release Version
|
|
45867
|
-
// Hyphen, followed by one or more dot-separated pre-release version
|
|
45868
|
-
// identifiers.
|
|
45869
|
-
|
|
45870
|
-
createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER]
|
|
45871
|
-
}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
|
|
45872
|
-
|
|
45873
|
-
createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]
|
|
45874
|
-
}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
|
|
45875
|
-
|
|
45876
|
-
// ## Build Metadata Identifier
|
|
45877
|
-
// Any combination of digits, letters, or hyphens.
|
|
45878
|
-
|
|
45879
|
-
createToken('BUILDIDENTIFIER', '[0-9A-Za-z-]+');
|
|
45880
|
-
|
|
45881
|
-
// ## Build Metadata
|
|
45882
|
-
// Plus sign, followed by one or more period-separated build metadata
|
|
45883
|
-
// identifiers.
|
|
45884
|
-
|
|
45885
|
-
createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER]
|
|
45886
|
-
}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
|
|
45887
|
-
|
|
45888
|
-
// ## Full Version String
|
|
45889
|
-
// A main version, followed optionally by a pre-release version and
|
|
45890
|
-
// build metadata.
|
|
45891
|
-
|
|
45892
|
-
// Note that the only major, minor, patch, and pre-release sections of
|
|
45893
|
-
// the version string are capturing groups. The build metadata is not a
|
|
45894
|
-
// capturing group, because it should not ever be used in version
|
|
45895
|
-
// comparison.
|
|
45896
|
-
|
|
45897
|
-
createToken('FULLPLAIN', `v?${src[t.MAINVERSION]
|
|
45898
|
-
}${src[t.PRERELEASE]}?${
|
|
45899
|
-
src[t.BUILD]}?`);
|
|
45900
|
-
|
|
45901
|
-
createToken('FULL', `^${src[t.FULLPLAIN]}$`);
|
|
45902
|
-
|
|
45903
|
-
// like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
|
|
45904
|
-
// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
|
|
45905
|
-
// common in the npm registry.
|
|
45906
|
-
createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE]
|
|
45907
|
-
}${src[t.PRERELEASELOOSE]}?${
|
|
45908
|
-
src[t.BUILD]}?`);
|
|
45909
|
-
|
|
45910
|
-
createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`);
|
|
45911
|
-
|
|
45912
|
-
createToken('GTLT', '((?:<|>)?=?)');
|
|
45913
|
-
|
|
45914
|
-
// Something like "2.*" or "1.2.x".
|
|
45915
|
-
// Note that "x.x" is a valid xRange identifer, meaning "any version"
|
|
45916
|
-
// Only the first item is strictly required.
|
|
45917
|
-
createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
|
|
45918
|
-
createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
|
|
45919
|
-
|
|
45920
|
-
createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` +
|
|
45921
|
-
`(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
|
|
45922
|
-
`(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
|
|
45923
|
-
`(?:${src[t.PRERELEASE]})?${
|
|
45924
|
-
src[t.BUILD]}?` +
|
|
45925
|
-
`)?)?`);
|
|
45926
|
-
|
|
45927
|
-
createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` +
|
|
45928
|
-
`(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
|
|
45929
|
-
`(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
|
|
45930
|
-
`(?:${src[t.PRERELEASELOOSE]})?${
|
|
45931
|
-
src[t.BUILD]}?` +
|
|
45932
|
-
`)?)?`);
|
|
45933
|
-
|
|
45934
|
-
createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
|
|
45935
|
-
createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
|
|
45936
|
-
|
|
45937
|
-
// Coercion.
|
|
45938
|
-
// Extract anything that could conceivably be a part of a valid semver
|
|
45939
|
-
createToken('COERCE', `${'(^|[^\\d])' +
|
|
45940
|
-
'(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` +
|
|
45941
|
-
`(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
|
|
45942
|
-
`(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
|
|
45943
|
-
`(?:$|[^\\d])`);
|
|
45944
|
-
createToken('COERCERTL', src[t.COERCE], true);
|
|
45945
|
-
|
|
45946
|
-
// Tilde ranges.
|
|
45947
|
-
// Meaning is "reasonably at or greater than"
|
|
45948
|
-
createToken('LONETILDE', '(?:~>?)');
|
|
45949
|
-
|
|
45950
|
-
createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true);
|
|
45951
|
-
exports.tildeTrimReplace = '$1~';
|
|
45952
|
-
|
|
45953
|
-
createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
|
|
45954
|
-
createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
45955
|
-
|
|
45956
|
-
// Caret ranges.
|
|
45957
|
-
// Meaning is "at least and backwards compatible with"
|
|
45958
|
-
createToken('LONECARET', '(?:\\^)');
|
|
45959
|
-
|
|
45960
|
-
createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true);
|
|
45961
|
-
exports.caretTrimReplace = '$1^';
|
|
45962
|
-
|
|
45963
|
-
createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
|
|
45964
|
-
createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
45965
|
-
|
|
45966
|
-
// A simple gt/lt/eq thing, or just "" to indicate "any version"
|
|
45967
|
-
createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
|
|
45968
|
-
createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
|
|
45969
|
-
|
|
45970
|
-
// An expression to strip any whitespace between the gtlt and the thing
|
|
45971
|
-
// it modifies, so that `> 1.2.3` ==> `>1.2.3`
|
|
45972
|
-
createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT]
|
|
45973
|
-
}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
|
|
45974
|
-
exports.comparatorTrimReplace = '$1$2$3';
|
|
45975
|
-
|
|
45976
|
-
// Something like `1.2.3 - 1.2.4`
|
|
45977
|
-
// Note that these all use the loose form, because they'll be
|
|
45978
|
-
// checked against either the strict or loose comparator form
|
|
45979
|
-
// later.
|
|
45980
|
-
createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` +
|
|
45981
|
-
`\\s+-\\s+` +
|
|
45982
|
-
`(${src[t.XRANGEPLAIN]})` +
|
|
45983
|
-
`\\s*$`);
|
|
45984
|
-
|
|
45985
|
-
createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` +
|
|
45986
|
-
`\\s+-\\s+` +
|
|
45987
|
-
`(${src[t.XRANGEPLAINLOOSE]})` +
|
|
45988
|
-
`\\s*$`);
|
|
45989
|
-
|
|
45990
|
-
// Star ranges basically just allow anything at all.
|
|
45991
|
-
createToken('STAR', '(<|>)?=?\\s*\\*');
|
|
45992
|
-
// >=0.0.0 is like a star
|
|
45993
|
-
createToken('GTE0', '^\\s*>=\\s*0\\.0\\.0\\s*$');
|
|
45994
|
-
createToken('GTE0PRE', '^\\s*>=\\s*0\\.0\\.0-0\\s*$');
|
|
45995
|
-
});
|
|
45996
|
-
var re_2 = re_1.re;
|
|
45997
|
-
var re_3 = re_1.src;
|
|
45998
|
-
var re_4 = re_1.t;
|
|
45999
|
-
var re_5 = re_1.tildeTrimReplace;
|
|
46000
|
-
var re_6 = re_1.caretTrimReplace;
|
|
46001
|
-
var re_7 = re_1.comparatorTrimReplace;
|
|
46002
|
-
|
|
46003
|
-
// parse out just the options we care about so we always get a consistent
|
|
46004
|
-
// obj with keys in a consistent order.
|
|
46005
|
-
const opts = ['includePrerelease', 'loose', 'rtl'];
|
|
46006
|
-
const parseOptions = options =>
|
|
46007
|
-
!options ? {}
|
|
46008
|
-
: typeof options !== 'object' ? { loose: true }
|
|
46009
|
-
: opts.filter(k => options[k]).reduce((o, k) => {
|
|
46010
|
-
o[k] = true;
|
|
46011
|
-
return o
|
|
46012
|
-
}, {});
|
|
46013
|
-
var parseOptions_1 = parseOptions;
|
|
46014
|
-
|
|
46015
|
-
const numeric = /^[0-9]+$/;
|
|
46016
|
-
const compareIdentifiers = (a, b) => {
|
|
46017
|
-
const anum = numeric.test(a);
|
|
46018
|
-
const bnum = numeric.test(b);
|
|
46019
|
-
|
|
46020
|
-
if (anum && bnum) {
|
|
46021
|
-
a = +a;
|
|
46022
|
-
b = +b;
|
|
46023
|
-
}
|
|
46024
|
-
|
|
46025
|
-
return a === b ? 0
|
|
46026
|
-
: (anum && !bnum) ? -1
|
|
46027
|
-
: (bnum && !anum) ? 1
|
|
46028
|
-
: a < b ? -1
|
|
46029
|
-
: 1
|
|
45754
|
+
var __awaiter$d = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
45755
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
45756
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
45757
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
45758
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
45759
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
45760
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
45761
|
+
});
|
|
46030
45762
|
};
|
|
46031
|
-
|
|
46032
|
-
|
|
46033
|
-
|
|
46034
|
-
var identifiers = {
|
|
46035
|
-
compareIdentifiers,
|
|
46036
|
-
rcompareIdentifiers,
|
|
45763
|
+
const defaultOptions$1 = {
|
|
45764
|
+
autoConnect: true
|
|
46037
45765
|
};
|
|
46038
|
-
|
|
46039
|
-
|
|
46040
|
-
|
|
46041
|
-
|
|
46042
|
-
|
|
46043
|
-
|
|
46044
|
-
|
|
46045
|
-
|
|
46046
|
-
|
|
46047
|
-
|
|
46048
|
-
|
|
46049
|
-
|
|
46050
|
-
|
|
46051
|
-
|
|
46052
|
-
|
|
46053
|
-
|
|
46054
|
-
|
|
46055
|
-
} else if (typeof version !== 'string') {
|
|
46056
|
-
throw new TypeError(`Invalid Version: ${version}`)
|
|
46057
|
-
}
|
|
46058
|
-
|
|
46059
|
-
if (version.length > MAX_LENGTH$1) {
|
|
46060
|
-
throw new TypeError(
|
|
46061
|
-
`version is longer than ${MAX_LENGTH$1} characters`
|
|
46062
|
-
)
|
|
46063
|
-
}
|
|
46064
|
-
|
|
46065
|
-
debug_1('SemVer', version, options);
|
|
46066
|
-
this.options = options;
|
|
46067
|
-
this.loose = !!options.loose;
|
|
46068
|
-
// this isn't actually relevant for versions, but keep it so that we
|
|
46069
|
-
// don't run into trouble passing this.options around.
|
|
46070
|
-
this.includePrerelease = !!options.includePrerelease;
|
|
46071
|
-
|
|
46072
|
-
const m = version.trim().match(options.loose ? re$1[t$1.LOOSE] : re$1[t$1.FULL]);
|
|
46073
|
-
|
|
46074
|
-
if (!m) {
|
|
46075
|
-
throw new TypeError(`Invalid Version: ${version}`)
|
|
46076
|
-
}
|
|
46077
|
-
|
|
46078
|
-
this.raw = version;
|
|
46079
|
-
|
|
46080
|
-
// these are actually numbers
|
|
46081
|
-
this.major = +m[1];
|
|
46082
|
-
this.minor = +m[2];
|
|
46083
|
-
this.patch = +m[3];
|
|
46084
|
-
|
|
46085
|
-
if (this.major > MAX_SAFE_INTEGER$1 || this.major < 0) {
|
|
46086
|
-
throw new TypeError('Invalid major version')
|
|
46087
|
-
}
|
|
46088
|
-
|
|
46089
|
-
if (this.minor > MAX_SAFE_INTEGER$1 || this.minor < 0) {
|
|
46090
|
-
throw new TypeError('Invalid minor version')
|
|
46091
|
-
}
|
|
46092
|
-
|
|
46093
|
-
if (this.patch > MAX_SAFE_INTEGER$1 || this.patch < 0) {
|
|
46094
|
-
throw new TypeError('Invalid patch version')
|
|
46095
|
-
}
|
|
46096
|
-
|
|
46097
|
-
// numberify any prerelease numeric ids
|
|
46098
|
-
if (!m[4]) {
|
|
46099
|
-
this.prerelease = [];
|
|
46100
|
-
} else {
|
|
46101
|
-
this.prerelease = m[4].split('.').map((id) => {
|
|
46102
|
-
if (/^[0-9]+$/.test(id)) {
|
|
46103
|
-
const num = +id;
|
|
46104
|
-
if (num >= 0 && num < MAX_SAFE_INTEGER$1) {
|
|
46105
|
-
return num
|
|
46106
|
-
}
|
|
45766
|
+
class WebBluetoothTransport {
|
|
45767
|
+
constructor(options = {}) {
|
|
45768
|
+
this.type = TRANSPORT_TYPE.WEB;
|
|
45769
|
+
this.characteristicsByName = {};
|
|
45770
|
+
this.connection$ = new BehaviorSubject(BLUETOOTH_CONNECTION.DISCONNECTED);
|
|
45771
|
+
this.pendingActions$ = new BehaviorSubject([]);
|
|
45772
|
+
this.logs$ = new ReplaySubject(10);
|
|
45773
|
+
this.onDisconnected$ = this._onDisconnected().pipe(share());
|
|
45774
|
+
this.connectionStream$ = this.connection$
|
|
45775
|
+
.asObservable()
|
|
45776
|
+
.pipe(filter((connection) => !!connection), distinctUntilChanged(), shareReplay(1));
|
|
45777
|
+
this._isAutoConnectEnabled$ = new ReplaySubject(1);
|
|
45778
|
+
this.options = Object.assign(Object.assign({}, defaultOptions$1), options);
|
|
45779
|
+
if (!isWebBluetoothSupported()) {
|
|
45780
|
+
const errorMessage = "Web Bluetooth is not supported";
|
|
45781
|
+
this.addLog(errorMessage);
|
|
45782
|
+
throw new Error(errorMessage);
|
|
46107
45783
|
}
|
|
46108
|
-
|
|
46109
|
-
|
|
45784
|
+
this._isAutoConnectEnabled$.subscribe((autoConnect) => {
|
|
45785
|
+
this.addLog(`Auto connect: ${autoConnect ? "enabled" : "disabled"}`);
|
|
45786
|
+
});
|
|
45787
|
+
this._isAutoConnectEnabled$.next(this.options.autoConnect);
|
|
45788
|
+
this.connection$.asObservable().subscribe((connection) => {
|
|
45789
|
+
this.addLog(`connection status is ${connection}`);
|
|
45790
|
+
});
|
|
45791
|
+
this.onDisconnected$.subscribe(() => {
|
|
45792
|
+
this.connection$.next(BLUETOOTH_CONNECTION.DISCONNECTED);
|
|
45793
|
+
});
|
|
46110
45794
|
}
|
|
46111
|
-
|
|
46112
|
-
|
|
46113
|
-
|
|
46114
|
-
|
|
46115
|
-
|
|
46116
|
-
format () {
|
|
46117
|
-
this.version = `${this.major}.${this.minor}.${this.patch}`;
|
|
46118
|
-
if (this.prerelease.length) {
|
|
46119
|
-
this.version += `-${this.prerelease.join('.')}`;
|
|
45795
|
+
_getPairedDevices() {
|
|
45796
|
+
return __awaiter$d(this, void 0, void 0, function* () {
|
|
45797
|
+
return yield navigator.bluetooth.getDevices();
|
|
45798
|
+
});
|
|
46120
45799
|
}
|
|
46121
|
-
|
|
46122
|
-
|
|
46123
|
-
|
|
46124
|
-
|
|
46125
|
-
|
|
46126
|
-
|
|
46127
|
-
|
|
46128
|
-
|
|
46129
|
-
|
|
46130
|
-
|
|
46131
|
-
|
|
46132
|
-
|
|
46133
|
-
|
|
46134
|
-
|
|
45800
|
+
_autoConnect(selectedDevice$) {
|
|
45801
|
+
return this._isAutoConnectEnabled$.pipe(switchMap((isAutoConnectEnabled) => isAutoConnectEnabled
|
|
45802
|
+
? merge(selectedDevice$, this.onDisconnected$.pipe(switchMap(() => selectedDevice$)))
|
|
45803
|
+
: NEVER), switchMap((selectedDevice) => __awaiter$d(this, void 0, void 0, function* () {
|
|
45804
|
+
var _a;
|
|
45805
|
+
const { deviceNickname } = selectedDevice;
|
|
45806
|
+
if (this.isConnected()) {
|
|
45807
|
+
this.addLog(`Auto connect: ${deviceNickname} is already connected. Skipping auto connect.`);
|
|
45808
|
+
return;
|
|
45809
|
+
}
|
|
45810
|
+
const [devicesError, devices] = yield this._getPairedDevices()
|
|
45811
|
+
.then((devices) => [null, devices])
|
|
45812
|
+
.catch((error) => [error, null]);
|
|
45813
|
+
if (devicesError) {
|
|
45814
|
+
throw new Error(`failed to get devices: ${(_a = devicesError === null || devicesError === void 0 ? void 0 : devicesError.message) !== null && _a !== void 0 ? _a : devicesError}`);
|
|
45815
|
+
}
|
|
45816
|
+
this.addLog(`Auto connect: found ${devices.length} devices ${devices
|
|
45817
|
+
.map(({ name }) => name)
|
|
45818
|
+
.join(", ")}`);
|
|
45819
|
+
// @important - Using `findLast` instead of `find` because somehow the browser
|
|
45820
|
+
// is finding multiple peripherals with the same name
|
|
45821
|
+
const device = devices.findLast((device) => device.name === deviceNickname);
|
|
45822
|
+
if (!device) {
|
|
45823
|
+
throw new Error(`couldn't find selected device in the list of paired devices.`);
|
|
45824
|
+
}
|
|
45825
|
+
this.addLog(`Auto connect: ${deviceNickname} was detected and previously paired`);
|
|
45826
|
+
return device;
|
|
45827
|
+
})), tap(() => {
|
|
45828
|
+
this.connection$.next(BLUETOOTH_CONNECTION.SCANNING);
|
|
45829
|
+
}), switchMap((device) => onAdvertisementReceived(device)), switchMap((advertisement) => __awaiter$d(this, void 0, void 0, function* () {
|
|
45830
|
+
this.addLog(`Advertisement received for ${advertisement.device.name}`);
|
|
45831
|
+
return yield this.getServerServiceAndCharacteristics(advertisement.device);
|
|
45832
|
+
})));
|
|
46135
45833
|
}
|
|
46136
|
-
|
|
46137
|
-
|
|
46138
|
-
return 0
|
|
45834
|
+
enableAutoConnect(autoConnect) {
|
|
45835
|
+
this._isAutoConnectEnabled$.next(autoConnect);
|
|
46139
45836
|
}
|
|
46140
|
-
|
|
46141
|
-
|
|
46142
|
-
}
|
|
46143
|
-
|
|
46144
|
-
compareMain (other) {
|
|
46145
|
-
if (!(other instanceof SemVer)) {
|
|
46146
|
-
other = new SemVer(other, this.options);
|
|
45837
|
+
addLog(log) {
|
|
45838
|
+
this.logs$.next(log);
|
|
46147
45839
|
}
|
|
46148
|
-
|
|
46149
|
-
|
|
46150
|
-
|
|
46151
|
-
compareIdentifiers$1(this.minor, other.minor) ||
|
|
46152
|
-
compareIdentifiers$1(this.patch, other.patch)
|
|
46153
|
-
)
|
|
46154
|
-
}
|
|
46155
|
-
|
|
46156
|
-
comparePre (other) {
|
|
46157
|
-
if (!(other instanceof SemVer)) {
|
|
46158
|
-
other = new SemVer(other, this.options);
|
|
45840
|
+
isConnected() {
|
|
45841
|
+
const connection = this.connection$.getValue();
|
|
45842
|
+
return connection === BLUETOOTH_CONNECTION.CONNECTED;
|
|
46159
45843
|
}
|
|
46160
|
-
|
|
46161
|
-
|
|
46162
|
-
if (this.prerelease.length && !other.prerelease.length) {
|
|
46163
|
-
return -1
|
|
46164
|
-
} else if (!this.prerelease.length && other.prerelease.length) {
|
|
46165
|
-
return 1
|
|
46166
|
-
} else if (!this.prerelease.length && !other.prerelease.length) {
|
|
46167
|
-
return 0
|
|
45844
|
+
connection() {
|
|
45845
|
+
return this.connectionStream$;
|
|
46168
45846
|
}
|
|
46169
|
-
|
|
46170
|
-
|
|
46171
|
-
|
|
46172
|
-
|
|
46173
|
-
|
|
46174
|
-
|
|
46175
|
-
|
|
46176
|
-
|
|
46177
|
-
|
|
46178
|
-
|
|
46179
|
-
|
|
46180
|
-
return -1
|
|
46181
|
-
} else if (a === b) {
|
|
46182
|
-
continue
|
|
46183
|
-
} else {
|
|
46184
|
-
return compareIdentifiers$1(a, b)
|
|
46185
|
-
}
|
|
46186
|
-
} while (++i)
|
|
46187
|
-
}
|
|
46188
|
-
|
|
46189
|
-
compareBuild (other) {
|
|
46190
|
-
if (!(other instanceof SemVer)) {
|
|
46191
|
-
other = new SemVer(other, this.options);
|
|
46192
|
-
}
|
|
46193
|
-
|
|
46194
|
-
let i = 0;
|
|
46195
|
-
do {
|
|
46196
|
-
const a = this.build[i];
|
|
46197
|
-
const b = other.build[i];
|
|
46198
|
-
debug_1('prerelease compare', i, a, b);
|
|
46199
|
-
if (a === undefined && b === undefined) {
|
|
46200
|
-
return 0
|
|
46201
|
-
} else if (b === undefined) {
|
|
46202
|
-
return 1
|
|
46203
|
-
} else if (a === undefined) {
|
|
46204
|
-
return -1
|
|
46205
|
-
} else if (a === b) {
|
|
46206
|
-
continue
|
|
46207
|
-
} else {
|
|
46208
|
-
return compareIdentifiers$1(a, b)
|
|
46209
|
-
}
|
|
46210
|
-
} while (++i)
|
|
46211
|
-
}
|
|
46212
|
-
|
|
46213
|
-
// preminor will bump the version up to the next minor release, and immediately
|
|
46214
|
-
// down to pre-release. premajor and prepatch work the same way.
|
|
46215
|
-
inc (release, identifier) {
|
|
46216
|
-
switch (release) {
|
|
46217
|
-
case 'premajor':
|
|
46218
|
-
this.prerelease.length = 0;
|
|
46219
|
-
this.patch = 0;
|
|
46220
|
-
this.minor = 0;
|
|
46221
|
-
this.major++;
|
|
46222
|
-
this.inc('pre', identifier);
|
|
46223
|
-
break
|
|
46224
|
-
case 'preminor':
|
|
46225
|
-
this.prerelease.length = 0;
|
|
46226
|
-
this.patch = 0;
|
|
46227
|
-
this.minor++;
|
|
46228
|
-
this.inc('pre', identifier);
|
|
46229
|
-
break
|
|
46230
|
-
case 'prepatch':
|
|
46231
|
-
// If this is already a prerelease, it will bump to the next version
|
|
46232
|
-
// drop any prereleases that might already exist, since they are not
|
|
46233
|
-
// relevant at this point.
|
|
46234
|
-
this.prerelease.length = 0;
|
|
46235
|
-
this.inc('patch', identifier);
|
|
46236
|
-
this.inc('pre', identifier);
|
|
46237
|
-
break
|
|
46238
|
-
// If the input is a non-prerelease version, this acts the same as
|
|
46239
|
-
// prepatch.
|
|
46240
|
-
case 'prerelease':
|
|
46241
|
-
if (this.prerelease.length === 0) {
|
|
46242
|
-
this.inc('patch', identifier);
|
|
46243
|
-
}
|
|
46244
|
-
this.inc('pre', identifier);
|
|
46245
|
-
break
|
|
46246
|
-
|
|
46247
|
-
case 'major':
|
|
46248
|
-
// If this is a pre-major version, bump up to the same major version.
|
|
46249
|
-
// Otherwise increment major.
|
|
46250
|
-
// 1.0.0-5 bumps to 1.0.0
|
|
46251
|
-
// 1.1.0 bumps to 2.0.0
|
|
46252
|
-
if (
|
|
46253
|
-
this.minor !== 0 ||
|
|
46254
|
-
this.patch !== 0 ||
|
|
46255
|
-
this.prerelease.length === 0
|
|
46256
|
-
) {
|
|
46257
|
-
this.major++;
|
|
46258
|
-
}
|
|
46259
|
-
this.minor = 0;
|
|
46260
|
-
this.patch = 0;
|
|
46261
|
-
this.prerelease = [];
|
|
46262
|
-
break
|
|
46263
|
-
case 'minor':
|
|
46264
|
-
// If this is a pre-minor version, bump up to the same minor version.
|
|
46265
|
-
// Otherwise increment minor.
|
|
46266
|
-
// 1.2.0-5 bumps to 1.2.0
|
|
46267
|
-
// 1.2.1 bumps to 1.3.0
|
|
46268
|
-
if (this.patch !== 0 || this.prerelease.length === 0) {
|
|
46269
|
-
this.minor++;
|
|
46270
|
-
}
|
|
46271
|
-
this.patch = 0;
|
|
46272
|
-
this.prerelease = [];
|
|
46273
|
-
break
|
|
46274
|
-
case 'patch':
|
|
46275
|
-
// If this is not a pre-release version, it will increment the patch.
|
|
46276
|
-
// If it is a pre-release it will bump up to the same patch version.
|
|
46277
|
-
// 1.2.0-5 patches to 1.2.0
|
|
46278
|
-
// 1.2.0 patches to 1.2.1
|
|
46279
|
-
if (this.prerelease.length === 0) {
|
|
46280
|
-
this.patch++;
|
|
46281
|
-
}
|
|
46282
|
-
this.prerelease = [];
|
|
46283
|
-
break
|
|
46284
|
-
// This probably shouldn't be used publicly.
|
|
46285
|
-
// 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
|
|
46286
|
-
case 'pre':
|
|
46287
|
-
if (this.prerelease.length === 0) {
|
|
46288
|
-
this.prerelease = [0];
|
|
46289
|
-
} else {
|
|
46290
|
-
let i = this.prerelease.length;
|
|
46291
|
-
while (--i >= 0) {
|
|
46292
|
-
if (typeof this.prerelease[i] === 'number') {
|
|
46293
|
-
this.prerelease[i]++;
|
|
46294
|
-
i = -2;
|
|
46295
|
-
}
|
|
46296
|
-
}
|
|
46297
|
-
if (i === -1) {
|
|
46298
|
-
// didn't increment anything
|
|
46299
|
-
this.prerelease.push(0);
|
|
46300
|
-
}
|
|
46301
|
-
}
|
|
46302
|
-
if (identifier) {
|
|
46303
|
-
// 1.2.0-beta.1 bumps to 1.2.0-beta.2,
|
|
46304
|
-
// 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
|
|
46305
|
-
if (compareIdentifiers$1(this.prerelease[0], identifier) === 0) {
|
|
46306
|
-
if (isNaN(this.prerelease[1])) {
|
|
46307
|
-
this.prerelease = [identifier, 0];
|
|
46308
|
-
}
|
|
46309
|
-
} else {
|
|
46310
|
-
this.prerelease = [identifier, 0];
|
|
46311
|
-
}
|
|
46312
|
-
}
|
|
46313
|
-
break
|
|
46314
|
-
|
|
46315
|
-
default:
|
|
46316
|
-
throw new Error(`invalid increment argument: ${release}`)
|
|
46317
|
-
}
|
|
46318
|
-
this.format();
|
|
46319
|
-
this.raw = this.version;
|
|
46320
|
-
return this
|
|
46321
|
-
}
|
|
46322
|
-
}
|
|
46323
|
-
|
|
46324
|
-
var semver = SemVer;
|
|
46325
|
-
|
|
46326
|
-
const compare = (a, b, loose) =>
|
|
46327
|
-
new semver(a, loose).compare(new semver(b, loose));
|
|
46328
|
-
|
|
46329
|
-
var compare_1 = compare;
|
|
46330
|
-
|
|
46331
|
-
const gte = (a, b, loose) => compare_1(a, b, loose) >= 0;
|
|
46332
|
-
var gte_1 = gte;
|
|
46333
|
-
|
|
46334
|
-
function osHasBluetoothSupport(selectedDevice, osVersion) {
|
|
46335
|
-
if (!selectedDevice) {
|
|
46336
|
-
return false;
|
|
46337
|
-
}
|
|
46338
|
-
// Only the Crown supports Bluetooth
|
|
46339
|
-
const isCrown = Number(selectedDevice.modelVersion) >= 3;
|
|
46340
|
-
if (!isCrown) {
|
|
46341
|
-
return false;
|
|
46342
|
-
}
|
|
46343
|
-
const isEmulator = !!(selectedDevice === null || selectedDevice === void 0 ? void 0 : selectedDevice.emulator);
|
|
46344
|
-
if (isEmulator) {
|
|
46345
|
-
return false;
|
|
46346
|
-
}
|
|
46347
|
-
// `osVersion` is updated in real time,
|
|
46348
|
-
// unlike accessing via `selectedDevice.osVersion`
|
|
46349
|
-
return gte_1(osVersion !== null && osVersion !== void 0 ? osVersion : selectedDevice.osVersion, "16.0.0");
|
|
46350
|
-
}
|
|
46351
|
-
|
|
46352
|
-
var __awaiter$d = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
46353
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
46354
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
46355
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
46356
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
46357
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
46358
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
46359
|
-
});
|
|
46360
|
-
};
|
|
46361
|
-
const defaultOptions$1 = {
|
|
46362
|
-
autoConnect: true
|
|
46363
|
-
};
|
|
46364
|
-
class WebBluetoothTransport {
|
|
46365
|
-
constructor(options = {}) {
|
|
46366
|
-
this.type = TRANSPORT_TYPE.WEB;
|
|
46367
|
-
this.characteristicsByName = {};
|
|
46368
|
-
this.connection$ = new BehaviorSubject(BLUETOOTH_CONNECTION.DISCONNECTED);
|
|
46369
|
-
this.pendingActions$ = new BehaviorSubject([]);
|
|
46370
|
-
this.logs$ = new ReplaySubject(10);
|
|
46371
|
-
this.onDisconnected$ = this._onDisconnected().pipe(share());
|
|
46372
|
-
this.connectionStream$ = this.connection$
|
|
46373
|
-
.asObservable()
|
|
46374
|
-
.pipe(filter((connection) => !!connection), distinctUntilChanged(), shareReplay(1));
|
|
46375
|
-
this._isAutoConnectEnabled$ = new ReplaySubject(1);
|
|
46376
|
-
this.options = Object.assign(Object.assign({}, defaultOptions$1), options);
|
|
46377
|
-
if (!isWebBluetoothSupported()) {
|
|
46378
|
-
const errorMessage = "Web Bluetooth is not supported";
|
|
46379
|
-
this.addLog(errorMessage);
|
|
46380
|
-
throw new Error(errorMessage);
|
|
46381
|
-
}
|
|
46382
|
-
this._isAutoConnectEnabled$.subscribe((autoConnect) => {
|
|
46383
|
-
this.addLog(`Auto connect: ${autoConnect ? "enabled" : "disabled"}`);
|
|
46384
|
-
});
|
|
46385
|
-
this._isAutoConnectEnabled$.next(this.options.autoConnect);
|
|
46386
|
-
this.connection$.asObservable().subscribe((connection) => {
|
|
46387
|
-
this.addLog(`connection status is ${connection}`);
|
|
46388
|
-
});
|
|
46389
|
-
this.onDisconnected$.subscribe(() => {
|
|
46390
|
-
this.connection$.next(BLUETOOTH_CONNECTION.DISCONNECTED);
|
|
46391
|
-
});
|
|
46392
|
-
}
|
|
46393
|
-
_getPairedDevices() {
|
|
46394
|
-
return __awaiter$d(this, void 0, void 0, function* () {
|
|
46395
|
-
return yield navigator.bluetooth.getDevices();
|
|
46396
|
-
});
|
|
46397
|
-
}
|
|
46398
|
-
_autoConnect(selectedDevice$, osVersion$) {
|
|
46399
|
-
return this._isAutoConnectEnabled$.pipe(switchMap((isAutoConnectEnabled) => isAutoConnectEnabled
|
|
46400
|
-
? merge(selectedDevice$, this.onDisconnected$.pipe(switchMap(() => selectedDevice$)))
|
|
46401
|
-
: NEVER), combineLatestWith(osVersion$), switchMap(([selectedDevice, osVersion]) => osHasBluetoothSupport(selectedDevice, osVersion)
|
|
46402
|
-
? of(selectedDevice)
|
|
46403
|
-
: EMPTY), switchMap((selectedDevice) => __awaiter$d(this, void 0, void 0, function* () {
|
|
46404
|
-
var _a;
|
|
46405
|
-
const { deviceNickname } = selectedDevice;
|
|
46406
|
-
if (this.isConnected()) {
|
|
46407
|
-
this.addLog(`Auto connect: ${deviceNickname} is already connected. Skipping auto connect.`);
|
|
46408
|
-
return;
|
|
46409
|
-
}
|
|
46410
|
-
const [devicesError, devices] = yield this._getPairedDevices()
|
|
46411
|
-
.then((devices) => [null, devices])
|
|
46412
|
-
.catch((error) => [error, null]);
|
|
46413
|
-
if (devicesError) {
|
|
46414
|
-
throw new Error(`failed to get devices: ${(_a = devicesError === null || devicesError === void 0 ? void 0 : devicesError.message) !== null && _a !== void 0 ? _a : devicesError}`);
|
|
46415
|
-
}
|
|
46416
|
-
this.addLog(`Auto connect: found ${devices.length} devices ${devices
|
|
46417
|
-
.map(({ name }) => name)
|
|
46418
|
-
.join(", ")}`);
|
|
46419
|
-
// @important - Using `findLast` instead of `find` because somehow the browser
|
|
46420
|
-
// is finding multiple peripherals with the same name
|
|
46421
|
-
const device = devices.findLast((device) => device.name === deviceNickname);
|
|
46422
|
-
if (!device) {
|
|
46423
|
-
throw new Error(`couldn't find selected device in the list of paired devices.`);
|
|
46424
|
-
}
|
|
46425
|
-
this.addLog(`Auto connect: ${deviceNickname} was detected and previously paired`);
|
|
46426
|
-
return device;
|
|
46427
|
-
})), tap(() => {
|
|
46428
|
-
this.connection$.next(BLUETOOTH_CONNECTION.SCANNING);
|
|
46429
|
-
}), switchMap((device) => onAdvertisementReceived(device)), switchMap((advertisement) => __awaiter$d(this, void 0, void 0, function* () {
|
|
46430
|
-
this.addLog(`Advertisement received for ${advertisement.device.name}`);
|
|
46431
|
-
return yield this.getServerServiceAndCharacteristics(advertisement.device);
|
|
46432
|
-
})));
|
|
46433
|
-
}
|
|
46434
|
-
enableAutoConnect(autoConnect) {
|
|
46435
|
-
this._isAutoConnectEnabled$.next(autoConnect);
|
|
46436
|
-
}
|
|
46437
|
-
addLog(log) {
|
|
46438
|
-
this.logs$.next(log);
|
|
46439
|
-
}
|
|
46440
|
-
isConnected() {
|
|
46441
|
-
const connection = this.connection$.getValue();
|
|
46442
|
-
return connection === BLUETOOTH_CONNECTION.CONNECTED;
|
|
46443
|
-
}
|
|
46444
|
-
connection() {
|
|
46445
|
-
return this.connectionStream$;
|
|
46446
|
-
}
|
|
46447
|
-
connect(deviceNickname) {
|
|
46448
|
-
return __awaiter$d(this, void 0, void 0, function* () {
|
|
46449
|
-
try {
|
|
46450
|
-
// requires user gesture
|
|
46451
|
-
const device = yield this.requestDevice(deviceNickname);
|
|
46452
|
-
yield this.getServerServiceAndCharacteristics(device);
|
|
46453
|
-
}
|
|
46454
|
-
catch (error) {
|
|
46455
|
-
return Promise.reject(error);
|
|
46456
|
-
}
|
|
46457
|
-
});
|
|
45847
|
+
connect(deviceNickname) {
|
|
45848
|
+
return __awaiter$d(this, void 0, void 0, function* () {
|
|
45849
|
+
try {
|
|
45850
|
+
// requires user gesture
|
|
45851
|
+
const device = yield this.requestDevice(deviceNickname);
|
|
45852
|
+
yield this.getServerServiceAndCharacteristics(device);
|
|
45853
|
+
}
|
|
45854
|
+
catch (error) {
|
|
45855
|
+
return Promise.reject(error);
|
|
45856
|
+
}
|
|
45857
|
+
});
|
|
46458
45858
|
}
|
|
46459
45859
|
requestDevice(deviceNickname) {
|
|
46460
45860
|
return __awaiter$d(this, void 0, void 0, function* () {
|
|
@@ -46640,45 +46040,38 @@ class WebBluetoothTransport {
|
|
|
46640
46040
|
const actions = this.pendingActions$.getValue();
|
|
46641
46041
|
this.pendingActions$.next(actions.filter((id) => id !== actionId));
|
|
46642
46042
|
}
|
|
46643
|
-
_autoToggleActionNotifications(
|
|
46644
|
-
|
|
46645
|
-
|
|
46646
|
-
|
|
46647
|
-
|
|
46648
|
-
|
|
46649
|
-
|
|
46650
|
-
|
|
46651
|
-
|
|
46652
|
-
|
|
46653
|
-
|
|
46654
|
-
|
|
46655
|
-
|
|
46656
|
-
|
|
46657
|
-
|
|
46658
|
-
|
|
46659
|
-
this.addLog(`Started notifications for [actions] characteristic`);
|
|
46660
|
-
}
|
|
46661
|
-
catch (error) {
|
|
46662
|
-
this.addLog(`Attemped to start notifications for [actions] characteristic: ${(_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : error}`);
|
|
46663
|
-
}
|
|
46043
|
+
_autoToggleActionNotifications() {
|
|
46044
|
+
let actionsCharacteristic;
|
|
46045
|
+
let started = false;
|
|
46046
|
+
return this.connection$.asObservable().pipe(switchMap((connection) => connection === BLUETOOTH_CONNECTION.CONNECTED
|
|
46047
|
+
? defer(() => this.getCharacteristicByName("actions")).pipe(switchMap((characteristic) => {
|
|
46048
|
+
actionsCharacteristic = characteristic;
|
|
46049
|
+
return this.pendingActions$;
|
|
46050
|
+
}))
|
|
46051
|
+
: NEVER), tap((pendingActions) => __awaiter$d(this, void 0, void 0, function* () {
|
|
46052
|
+
var _a, _b;
|
|
46053
|
+
const hasPendingActions = !!pendingActions.length;
|
|
46054
|
+
if (hasPendingActions && !started) {
|
|
46055
|
+
started = true;
|
|
46056
|
+
try {
|
|
46057
|
+
yield actionsCharacteristic.startNotifications();
|
|
46058
|
+
this.addLog(`Started notifications for [actions] characteristic`);
|
|
46664
46059
|
}
|
|
46665
|
-
|
|
46666
|
-
|
|
46667
|
-
try {
|
|
46668
|
-
yield actionsCharacteristic.stopNotifications();
|
|
46669
|
-
this.addLog(`Stopped notifications for actions characteristic`);
|
|
46670
|
-
}
|
|
46671
|
-
catch (error) {
|
|
46672
|
-
this.addLog(`Attemped to stop notifications for [actions] characteristic: ${(_b = error === null || error === void 0 ? void 0 : error.message) !== null && _b !== void 0 ? _b : error}`);
|
|
46673
|
-
}
|
|
46060
|
+
catch (error) {
|
|
46061
|
+
this.addLog(`Attemped to start notifications for [actions] characteristic: ${(_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : error}`);
|
|
46674
46062
|
}
|
|
46675
|
-
}
|
|
46676
|
-
|
|
46677
|
-
|
|
46678
|
-
|
|
46679
|
-
|
|
46680
|
-
|
|
46681
|
-
|
|
46063
|
+
}
|
|
46064
|
+
if (!hasPendingActions && started) {
|
|
46065
|
+
started = false;
|
|
46066
|
+
try {
|
|
46067
|
+
yield actionsCharacteristic.stopNotifications();
|
|
46068
|
+
this.addLog(`Stopped notifications for actions characteristic`);
|
|
46069
|
+
}
|
|
46070
|
+
catch (error) {
|
|
46071
|
+
this.addLog(`Attemped to stop notifications for [actions] characteristic: ${(_b = error === null || error === void 0 ? void 0 : error.message) !== null && _b !== void 0 ? _b : error}`);
|
|
46072
|
+
}
|
|
46073
|
+
}
|
|
46074
|
+
})));
|
|
46682
46075
|
}
|
|
46683
46076
|
dispatchAction({ characteristicName, action }) {
|
|
46684
46077
|
return __awaiter$d(this, void 0, void 0, function* () {
|
|
@@ -46849,16 +46242,14 @@ class ReactNativeTransport {
|
|
|
46849
46242
|
const connection = this.connection$.getValue();
|
|
46850
46243
|
return connection === BLUETOOTH_CONNECTION.CONNECTED;
|
|
46851
46244
|
}
|
|
46852
|
-
_autoConnect(selectedDevice
|
|
46245
|
+
_autoConnect(selectedDevice$) {
|
|
46853
46246
|
const selectedDeviceAfterDisconnect$ = this.onDisconnected$.pipe(switchMap(() => selectedDevice$));
|
|
46854
46247
|
return this._isAutoConnectEnabled$.pipe(switchMap((isAutoConnectEnabled) => isAutoConnectEnabled
|
|
46855
46248
|
? merge(selectedDevice$, selectedDeviceAfterDisconnect$)
|
|
46856
|
-
: NEVER),
|
|
46857
|
-
?
|
|
46858
|
-
|
|
46859
|
-
|
|
46860
|
-
return peripheralMatch ? of(peripheralMatch) : NEVER;
|
|
46861
|
-
}), distinct((peripheral) => peripheral.id), take(1))), switchMap((peripheral) => __awaiter$e(this, void 0, void 0, function* () {
|
|
46249
|
+
: NEVER), switchMap((selectedDevice) => this.scan().pipe(switchMap((peripherals) => {
|
|
46250
|
+
const peripheralMatch = peripherals.find((peripheral) => peripheral.name === (selectedDevice === null || selectedDevice === void 0 ? void 0 : selectedDevice.deviceNickname));
|
|
46251
|
+
return peripheralMatch ? of(peripheralMatch) : NEVER;
|
|
46252
|
+
}), distinct((peripheral) => peripheral.id), take(1))), switchMap((peripheral) => __awaiter$e(this, void 0, void 0, function* () {
|
|
46862
46253
|
return yield this.connect(peripheral);
|
|
46863
46254
|
})));
|
|
46864
46255
|
}
|
|
@@ -47081,42 +46472,35 @@ class ReactNativeTransport {
|
|
|
47081
46472
|
const actions = this.pendingActions$.getValue();
|
|
47082
46473
|
this.pendingActions$.next(actions.filter((id) => id !== actionId));
|
|
47083
46474
|
}
|
|
47084
|
-
_autoToggleActionNotifications(
|
|
47085
|
-
|
|
47086
|
-
|
|
47087
|
-
|
|
47088
|
-
|
|
47089
|
-
|
|
47090
|
-
|
|
47091
|
-
|
|
47092
|
-
|
|
47093
|
-
|
|
47094
|
-
|
|
47095
|
-
|
|
47096
|
-
|
|
47097
|
-
this.addLog(`Started notifications for [actions] characteristic`);
|
|
47098
|
-
}
|
|
47099
|
-
catch (error) {
|
|
47100
|
-
this.addLog(`Attemped to start notifications for [actions] characteristic: ${(_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : error}`);
|
|
47101
|
-
}
|
|
46475
|
+
_autoToggleActionNotifications() {
|
|
46476
|
+
let started = false;
|
|
46477
|
+
return this.connection$.asObservable().pipe(switchMap((connection) => connection === BLUETOOTH_CONNECTION.CONNECTED
|
|
46478
|
+
? this.pendingActions$
|
|
46479
|
+
: NEVER), tap((pendingActions) => __awaiter$e(this, void 0, void 0, function* () {
|
|
46480
|
+
var _a, _b;
|
|
46481
|
+
const { peripheralId, serviceUUID, characteristicUUID } = this.getCharacteristicByName("actions");
|
|
46482
|
+
const hasPendingActions = !!pendingActions.length;
|
|
46483
|
+
if (hasPendingActions && !started) {
|
|
46484
|
+
started = true;
|
|
46485
|
+
try {
|
|
46486
|
+
yield this.BleManager.startNotification(peripheralId, serviceUUID, characteristicUUID);
|
|
46487
|
+
this.addLog(`Started notifications for [actions] characteristic`);
|
|
47102
46488
|
}
|
|
47103
|
-
|
|
47104
|
-
|
|
47105
|
-
try {
|
|
47106
|
-
yield this.BleManager.stopNotification(peripheralId, serviceUUID, characteristicUUID);
|
|
47107
|
-
this.addLog(`Stopped notifications for actions characteristic`);
|
|
47108
|
-
}
|
|
47109
|
-
catch (error) {
|
|
47110
|
-
this.addLog(`Attemped to stop notifications for [actions] characteristic: ${(_b = error === null || error === void 0 ? void 0 : error.message) !== null && _b !== void 0 ? _b : error}`);
|
|
47111
|
-
}
|
|
46489
|
+
catch (error) {
|
|
46490
|
+
this.addLog(`Attemped to start notifications for [actions] characteristic: ${(_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : error}`);
|
|
47112
46491
|
}
|
|
47113
|
-
}
|
|
47114
|
-
|
|
47115
|
-
|
|
47116
|
-
|
|
47117
|
-
|
|
47118
|
-
|
|
47119
|
-
|
|
46492
|
+
}
|
|
46493
|
+
if (!hasPendingActions && started) {
|
|
46494
|
+
started = false;
|
|
46495
|
+
try {
|
|
46496
|
+
yield this.BleManager.stopNotification(peripheralId, serviceUUID, characteristicUUID);
|
|
46497
|
+
this.addLog(`Stopped notifications for actions characteristic`);
|
|
46498
|
+
}
|
|
46499
|
+
catch (error) {
|
|
46500
|
+
this.addLog(`Attemped to stop notifications for [actions] characteristic: ${(_b = error === null || error === void 0 ? void 0 : error.message) !== null && _b !== void 0 ? _b : error}`);
|
|
46501
|
+
}
|
|
46502
|
+
}
|
|
46503
|
+
})));
|
|
47120
46504
|
}
|
|
47121
46505
|
dispatchAction({ characteristicName, action }) {
|
|
47122
46506
|
return __awaiter$e(this, void 0, void 0, function* () {
|
|
@@ -47267,9 +46651,9 @@ var __awaiter$f = (undefined && undefined.__awaiter) || function (thisArg, _argu
|
|
|
47267
46651
|
class BluetoothClient {
|
|
47268
46652
|
constructor(options) {
|
|
47269
46653
|
this.selectedDevice$ = new ReplaySubject(1);
|
|
47270
|
-
this.
|
|
46654
|
+
this.osHasBluetoothSupport$ = new ReplaySubject(1);
|
|
47271
46655
|
this.isAuthenticated$ = new ReplaySubject(1);
|
|
47272
|
-
const { transport, selectedDevice$, createBluetoothToken } = options !== null && options !== void 0 ? options : {};
|
|
46656
|
+
const { transport, selectedDevice$, osHasBluetoothSupport$, createBluetoothToken } = options !== null && options !== void 0 ? options : {};
|
|
47273
46657
|
if (!transport) {
|
|
47274
46658
|
throw new Error(`No bluetooth transport provided.`);
|
|
47275
46659
|
}
|
|
@@ -47278,9 +46662,14 @@ class BluetoothClient {
|
|
|
47278
46662
|
if (selectedDevice$) {
|
|
47279
46663
|
selectedDevice$.subscribe(this.selectedDevice$);
|
|
47280
46664
|
}
|
|
47281
|
-
//
|
|
47282
|
-
|
|
47283
|
-
|
|
46665
|
+
// Pass events to the internal osHasBluetoothSupport$ if osHasBluetoothSupport$ is passed via options
|
|
46666
|
+
if (osHasBluetoothSupport$) {
|
|
46667
|
+
osHasBluetoothSupport$.subscribe(this.osHasBluetoothSupport$);
|
|
46668
|
+
}
|
|
46669
|
+
this.osHasBluetoothSupport$
|
|
46670
|
+
.pipe(switchMap((osHasBluetoothSupport) => osHasBluetoothSupport
|
|
46671
|
+
? this.transport._autoConnect(this.selectedDevice$)
|
|
46672
|
+
: EMPTY))
|
|
47284
46673
|
.subscribe({
|
|
47285
46674
|
error: (error) => {
|
|
47286
46675
|
var _a;
|
|
@@ -47296,7 +46685,11 @@ class BluetoothClient {
|
|
|
47296
46685
|
this.transport.addLog("Auto authentication not enabled");
|
|
47297
46686
|
}
|
|
47298
46687
|
// Auto manage action notifications
|
|
47299
|
-
this.
|
|
46688
|
+
this.osHasBluetoothSupport$
|
|
46689
|
+
.pipe(switchMap((osHasBluetoothSupport) => osHasBluetoothSupport
|
|
46690
|
+
? this.transport._autoToggleActionNotifications()
|
|
46691
|
+
: EMPTY))
|
|
46692
|
+
.subscribe();
|
|
47300
46693
|
// Multicast metrics (share)
|
|
47301
46694
|
this._focus$ = this._subscribeWhileAuthenticated("focus");
|
|
47302
46695
|
this._calm$ = this._subscribeWhileAuthenticated("calm");
|
|
@@ -47320,28 +46713,24 @@ class BluetoothClient {
|
|
|
47320
46713
|
const reauthenticateInterval$ = timer(0, REAUTHENTICATE_INTERVAL).pipe(tap(() => {
|
|
47321
46714
|
this.transport.addLog(`Auto authentication in progress...`);
|
|
47322
46715
|
}));
|
|
47323
|
-
return this.
|
|
47324
|
-
?
|
|
47325
|
-
: this
|
|
47326
|
-
|
|
47327
|
-
|
|
47328
|
-
|
|
47329
|
-
|
|
47330
|
-
|
|
47331
|
-
|
|
47332
|
-
|
|
47333
|
-
|
|
47334
|
-
}
|
|
47335
|
-
})))));
|
|
46716
|
+
return this.osHasBluetoothSupport$.pipe(switchMap((osHasBluetoothSupport) => osHasBluetoothSupport ? this.connection() : EMPTY), switchMap((connection) => connection === BLUETOOTH_CONNECTION.CONNECTED
|
|
46717
|
+
? reauthenticateInterval$
|
|
46718
|
+
: EMPTY), switchMap(() => __awaiter$f(this, void 0, void 0, function* () { return yield this.isAuthenticated(); })), tap(([isAuthenticated]) => __awaiter$f(this, void 0, void 0, function* () {
|
|
46719
|
+
if (!isAuthenticated) {
|
|
46720
|
+
const token = yield createBluetoothToken();
|
|
46721
|
+
yield this.authenticate(token);
|
|
46722
|
+
}
|
|
46723
|
+
else {
|
|
46724
|
+
this.transport.addLog(`Already authenticated`);
|
|
46725
|
+
}
|
|
46726
|
+
})));
|
|
47336
46727
|
}
|
|
47337
46728
|
enableAutoConnect(autoConnect) {
|
|
47338
46729
|
this.transport.enableAutoConnect(autoConnect);
|
|
47339
46730
|
}
|
|
47340
46731
|
_hasBluetoothSupport() {
|
|
47341
46732
|
return __awaiter$f(this, void 0, void 0, function* () {
|
|
47342
|
-
|
|
47343
|
-
const osVersion = yield firstValueFrom(this.osVersion$);
|
|
47344
|
-
return osHasBluetoothSupport(selectedDevice, osVersion);
|
|
46733
|
+
return yield firstValueFrom(this.osHasBluetoothSupport$);
|
|
47345
46734
|
});
|
|
47346
46735
|
}
|
|
47347
46736
|
authenticate(token) {
|
|
@@ -47422,13 +46811,11 @@ class BluetoothClient {
|
|
|
47422
46811
|
});
|
|
47423
46812
|
}
|
|
47424
46813
|
_subscribeWhileAuthenticated(characteristicName) {
|
|
47425
|
-
return this.
|
|
47426
|
-
?
|
|
47427
|
-
|
|
47428
|
-
|
|
47429
|
-
|
|
47430
|
-
})
|
|
47431
|
-
: EMPTY))), share());
|
|
46814
|
+
return this.osHasBluetoothSupport$.pipe(switchMap((osHasBluetoothSupport) => osHasBluetoothSupport ? this.isAuthenticated$ : EMPTY), distinctUntilChanged(), switchMap((isAuthenticated) => isAuthenticated
|
|
46815
|
+
? this.transport.subscribeToCharacteristic({
|
|
46816
|
+
characteristicName
|
|
46817
|
+
})
|
|
46818
|
+
: EMPTY), share());
|
|
47432
46819
|
}
|
|
47433
46820
|
focus() {
|
|
47434
46821
|
return this._focus$;
|
|
@@ -47557,6 +46944,578 @@ class BluetoothClient {
|
|
|
47557
46944
|
}
|
|
47558
46945
|
}
|
|
47559
46946
|
|
|
46947
|
+
const debug = (
|
|
46948
|
+
typeof process === 'object' &&
|
|
46949
|
+
process.env &&
|
|
46950
|
+
process.env.NODE_DEBUG &&
|
|
46951
|
+
/\bsemver\b/i.test(process.env.NODE_DEBUG)
|
|
46952
|
+
) ? (...args) => console.error('SEMVER', ...args)
|
|
46953
|
+
: () => {};
|
|
46954
|
+
|
|
46955
|
+
var debug_1 = debug;
|
|
46956
|
+
|
|
46957
|
+
// Note: this is the semver.org version of the spec that it implements
|
|
46958
|
+
// Not necessarily the package version of this code.
|
|
46959
|
+
const SEMVER_SPEC_VERSION = '2.0.0';
|
|
46960
|
+
|
|
46961
|
+
const MAX_LENGTH = 256;
|
|
46962
|
+
const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
|
|
46963
|
+
/* istanbul ignore next */ 9007199254740991;
|
|
46964
|
+
|
|
46965
|
+
// Max safe segment length for coercion.
|
|
46966
|
+
const MAX_SAFE_COMPONENT_LENGTH = 16;
|
|
46967
|
+
|
|
46968
|
+
var constants = {
|
|
46969
|
+
SEMVER_SPEC_VERSION,
|
|
46970
|
+
MAX_LENGTH,
|
|
46971
|
+
MAX_SAFE_INTEGER,
|
|
46972
|
+
MAX_SAFE_COMPONENT_LENGTH,
|
|
46973
|
+
};
|
|
46974
|
+
|
|
46975
|
+
function createCommonjsModule(fn, module) {
|
|
46976
|
+
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
46977
|
+
}
|
|
46978
|
+
|
|
46979
|
+
var re_1 = createCommonjsModule(function (module, exports) {
|
|
46980
|
+
const { MAX_SAFE_COMPONENT_LENGTH } = constants;
|
|
46981
|
+
|
|
46982
|
+
exports = module.exports = {};
|
|
46983
|
+
|
|
46984
|
+
// The actual regexps go on exports.re
|
|
46985
|
+
const re = exports.re = [];
|
|
46986
|
+
const src = exports.src = [];
|
|
46987
|
+
const t = exports.t = {};
|
|
46988
|
+
let R = 0;
|
|
46989
|
+
|
|
46990
|
+
const createToken = (name, value, isGlobal) => {
|
|
46991
|
+
const index = R++;
|
|
46992
|
+
debug_1(name, index, value);
|
|
46993
|
+
t[name] = index;
|
|
46994
|
+
src[index] = value;
|
|
46995
|
+
re[index] = new RegExp(value, isGlobal ? 'g' : undefined);
|
|
46996
|
+
};
|
|
46997
|
+
|
|
46998
|
+
// The following Regular Expressions can be used for tokenizing,
|
|
46999
|
+
// validating, and parsing SemVer version strings.
|
|
47000
|
+
|
|
47001
|
+
// ## Numeric Identifier
|
|
47002
|
+
// A single `0`, or a non-zero digit followed by zero or more digits.
|
|
47003
|
+
|
|
47004
|
+
createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*');
|
|
47005
|
+
createToken('NUMERICIDENTIFIERLOOSE', '[0-9]+');
|
|
47006
|
+
|
|
47007
|
+
// ## Non-numeric Identifier
|
|
47008
|
+
// Zero or more digits, followed by a letter or hyphen, and then zero or
|
|
47009
|
+
// more letters, digits, or hyphens.
|
|
47010
|
+
|
|
47011
|
+
createToken('NONNUMERICIDENTIFIER', '\\d*[a-zA-Z-][a-zA-Z0-9-]*');
|
|
47012
|
+
|
|
47013
|
+
// ## Main Version
|
|
47014
|
+
// Three dot-separated numeric identifiers.
|
|
47015
|
+
|
|
47016
|
+
createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` +
|
|
47017
|
+
`(${src[t.NUMERICIDENTIFIER]})\\.` +
|
|
47018
|
+
`(${src[t.NUMERICIDENTIFIER]})`);
|
|
47019
|
+
|
|
47020
|
+
createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
|
|
47021
|
+
`(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
|
|
47022
|
+
`(${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
|
47023
|
+
|
|
47024
|
+
// ## Pre-release Version Identifier
|
|
47025
|
+
// A numeric identifier, or a non-numeric identifier.
|
|
47026
|
+
|
|
47027
|
+
createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER]
|
|
47028
|
+
}|${src[t.NONNUMERICIDENTIFIER]})`);
|
|
47029
|
+
|
|
47030
|
+
createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE]
|
|
47031
|
+
}|${src[t.NONNUMERICIDENTIFIER]})`);
|
|
47032
|
+
|
|
47033
|
+
// ## Pre-release Version
|
|
47034
|
+
// Hyphen, followed by one or more dot-separated pre-release version
|
|
47035
|
+
// identifiers.
|
|
47036
|
+
|
|
47037
|
+
createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER]
|
|
47038
|
+
}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
|
|
47039
|
+
|
|
47040
|
+
createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]
|
|
47041
|
+
}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
|
|
47042
|
+
|
|
47043
|
+
// ## Build Metadata Identifier
|
|
47044
|
+
// Any combination of digits, letters, or hyphens.
|
|
47045
|
+
|
|
47046
|
+
createToken('BUILDIDENTIFIER', '[0-9A-Za-z-]+');
|
|
47047
|
+
|
|
47048
|
+
// ## Build Metadata
|
|
47049
|
+
// Plus sign, followed by one or more period-separated build metadata
|
|
47050
|
+
// identifiers.
|
|
47051
|
+
|
|
47052
|
+
createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER]
|
|
47053
|
+
}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
|
|
47054
|
+
|
|
47055
|
+
// ## Full Version String
|
|
47056
|
+
// A main version, followed optionally by a pre-release version and
|
|
47057
|
+
// build metadata.
|
|
47058
|
+
|
|
47059
|
+
// Note that the only major, minor, patch, and pre-release sections of
|
|
47060
|
+
// the version string are capturing groups. The build metadata is not a
|
|
47061
|
+
// capturing group, because it should not ever be used in version
|
|
47062
|
+
// comparison.
|
|
47063
|
+
|
|
47064
|
+
createToken('FULLPLAIN', `v?${src[t.MAINVERSION]
|
|
47065
|
+
}${src[t.PRERELEASE]}?${
|
|
47066
|
+
src[t.BUILD]}?`);
|
|
47067
|
+
|
|
47068
|
+
createToken('FULL', `^${src[t.FULLPLAIN]}$`);
|
|
47069
|
+
|
|
47070
|
+
// like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
|
|
47071
|
+
// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
|
|
47072
|
+
// common in the npm registry.
|
|
47073
|
+
createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE]
|
|
47074
|
+
}${src[t.PRERELEASELOOSE]}?${
|
|
47075
|
+
src[t.BUILD]}?`);
|
|
47076
|
+
|
|
47077
|
+
createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`);
|
|
47078
|
+
|
|
47079
|
+
createToken('GTLT', '((?:<|>)?=?)');
|
|
47080
|
+
|
|
47081
|
+
// Something like "2.*" or "1.2.x".
|
|
47082
|
+
// Note that "x.x" is a valid xRange identifer, meaning "any version"
|
|
47083
|
+
// Only the first item is strictly required.
|
|
47084
|
+
createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
|
|
47085
|
+
createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
|
|
47086
|
+
|
|
47087
|
+
createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` +
|
|
47088
|
+
`(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
|
|
47089
|
+
`(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
|
|
47090
|
+
`(?:${src[t.PRERELEASE]})?${
|
|
47091
|
+
src[t.BUILD]}?` +
|
|
47092
|
+
`)?)?`);
|
|
47093
|
+
|
|
47094
|
+
createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` +
|
|
47095
|
+
`(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
|
|
47096
|
+
`(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
|
|
47097
|
+
`(?:${src[t.PRERELEASELOOSE]})?${
|
|
47098
|
+
src[t.BUILD]}?` +
|
|
47099
|
+
`)?)?`);
|
|
47100
|
+
|
|
47101
|
+
createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
|
|
47102
|
+
createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
|
|
47103
|
+
|
|
47104
|
+
// Coercion.
|
|
47105
|
+
// Extract anything that could conceivably be a part of a valid semver
|
|
47106
|
+
createToken('COERCE', `${'(^|[^\\d])' +
|
|
47107
|
+
'(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` +
|
|
47108
|
+
`(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
|
|
47109
|
+
`(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
|
|
47110
|
+
`(?:$|[^\\d])`);
|
|
47111
|
+
createToken('COERCERTL', src[t.COERCE], true);
|
|
47112
|
+
|
|
47113
|
+
// Tilde ranges.
|
|
47114
|
+
// Meaning is "reasonably at or greater than"
|
|
47115
|
+
createToken('LONETILDE', '(?:~>?)');
|
|
47116
|
+
|
|
47117
|
+
createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true);
|
|
47118
|
+
exports.tildeTrimReplace = '$1~';
|
|
47119
|
+
|
|
47120
|
+
createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
|
|
47121
|
+
createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
47122
|
+
|
|
47123
|
+
// Caret ranges.
|
|
47124
|
+
// Meaning is "at least and backwards compatible with"
|
|
47125
|
+
createToken('LONECARET', '(?:\\^)');
|
|
47126
|
+
|
|
47127
|
+
createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true);
|
|
47128
|
+
exports.caretTrimReplace = '$1^';
|
|
47129
|
+
|
|
47130
|
+
createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
|
|
47131
|
+
createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
47132
|
+
|
|
47133
|
+
// A simple gt/lt/eq thing, or just "" to indicate "any version"
|
|
47134
|
+
createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
|
|
47135
|
+
createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
|
|
47136
|
+
|
|
47137
|
+
// An expression to strip any whitespace between the gtlt and the thing
|
|
47138
|
+
// it modifies, so that `> 1.2.3` ==> `>1.2.3`
|
|
47139
|
+
createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT]
|
|
47140
|
+
}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
|
|
47141
|
+
exports.comparatorTrimReplace = '$1$2$3';
|
|
47142
|
+
|
|
47143
|
+
// Something like `1.2.3 - 1.2.4`
|
|
47144
|
+
// Note that these all use the loose form, because they'll be
|
|
47145
|
+
// checked against either the strict or loose comparator form
|
|
47146
|
+
// later.
|
|
47147
|
+
createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` +
|
|
47148
|
+
`\\s+-\\s+` +
|
|
47149
|
+
`(${src[t.XRANGEPLAIN]})` +
|
|
47150
|
+
`\\s*$`);
|
|
47151
|
+
|
|
47152
|
+
createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` +
|
|
47153
|
+
`\\s+-\\s+` +
|
|
47154
|
+
`(${src[t.XRANGEPLAINLOOSE]})` +
|
|
47155
|
+
`\\s*$`);
|
|
47156
|
+
|
|
47157
|
+
// Star ranges basically just allow anything at all.
|
|
47158
|
+
createToken('STAR', '(<|>)?=?\\s*\\*');
|
|
47159
|
+
// >=0.0.0 is like a star
|
|
47160
|
+
createToken('GTE0', '^\\s*>=\\s*0\\.0\\.0\\s*$');
|
|
47161
|
+
createToken('GTE0PRE', '^\\s*>=\\s*0\\.0\\.0-0\\s*$');
|
|
47162
|
+
});
|
|
47163
|
+
var re_2 = re_1.re;
|
|
47164
|
+
var re_3 = re_1.src;
|
|
47165
|
+
var re_4 = re_1.t;
|
|
47166
|
+
var re_5 = re_1.tildeTrimReplace;
|
|
47167
|
+
var re_6 = re_1.caretTrimReplace;
|
|
47168
|
+
var re_7 = re_1.comparatorTrimReplace;
|
|
47169
|
+
|
|
47170
|
+
// parse out just the options we care about so we always get a consistent
|
|
47171
|
+
// obj with keys in a consistent order.
|
|
47172
|
+
const opts = ['includePrerelease', 'loose', 'rtl'];
|
|
47173
|
+
const parseOptions = options =>
|
|
47174
|
+
!options ? {}
|
|
47175
|
+
: typeof options !== 'object' ? { loose: true }
|
|
47176
|
+
: opts.filter(k => options[k]).reduce((o, k) => {
|
|
47177
|
+
o[k] = true;
|
|
47178
|
+
return o
|
|
47179
|
+
}, {});
|
|
47180
|
+
var parseOptions_1 = parseOptions;
|
|
47181
|
+
|
|
47182
|
+
const numeric = /^[0-9]+$/;
|
|
47183
|
+
const compareIdentifiers = (a, b) => {
|
|
47184
|
+
const anum = numeric.test(a);
|
|
47185
|
+
const bnum = numeric.test(b);
|
|
47186
|
+
|
|
47187
|
+
if (anum && bnum) {
|
|
47188
|
+
a = +a;
|
|
47189
|
+
b = +b;
|
|
47190
|
+
}
|
|
47191
|
+
|
|
47192
|
+
return a === b ? 0
|
|
47193
|
+
: (anum && !bnum) ? -1
|
|
47194
|
+
: (bnum && !anum) ? 1
|
|
47195
|
+
: a < b ? -1
|
|
47196
|
+
: 1
|
|
47197
|
+
};
|
|
47198
|
+
|
|
47199
|
+
const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a);
|
|
47200
|
+
|
|
47201
|
+
var identifiers = {
|
|
47202
|
+
compareIdentifiers,
|
|
47203
|
+
rcompareIdentifiers,
|
|
47204
|
+
};
|
|
47205
|
+
|
|
47206
|
+
const { MAX_LENGTH: MAX_LENGTH$1, MAX_SAFE_INTEGER: MAX_SAFE_INTEGER$1 } = constants;
|
|
47207
|
+
const { re: re$1, t: t$1 } = re_1;
|
|
47208
|
+
|
|
47209
|
+
|
|
47210
|
+
const { compareIdentifiers: compareIdentifiers$1 } = identifiers;
|
|
47211
|
+
class SemVer {
|
|
47212
|
+
constructor (version, options) {
|
|
47213
|
+
options = parseOptions_1(options);
|
|
47214
|
+
|
|
47215
|
+
if (version instanceof SemVer) {
|
|
47216
|
+
if (version.loose === !!options.loose &&
|
|
47217
|
+
version.includePrerelease === !!options.includePrerelease) {
|
|
47218
|
+
return version
|
|
47219
|
+
} else {
|
|
47220
|
+
version = version.version;
|
|
47221
|
+
}
|
|
47222
|
+
} else if (typeof version !== 'string') {
|
|
47223
|
+
throw new TypeError(`Invalid Version: ${version}`)
|
|
47224
|
+
}
|
|
47225
|
+
|
|
47226
|
+
if (version.length > MAX_LENGTH$1) {
|
|
47227
|
+
throw new TypeError(
|
|
47228
|
+
`version is longer than ${MAX_LENGTH$1} characters`
|
|
47229
|
+
)
|
|
47230
|
+
}
|
|
47231
|
+
|
|
47232
|
+
debug_1('SemVer', version, options);
|
|
47233
|
+
this.options = options;
|
|
47234
|
+
this.loose = !!options.loose;
|
|
47235
|
+
// this isn't actually relevant for versions, but keep it so that we
|
|
47236
|
+
// don't run into trouble passing this.options around.
|
|
47237
|
+
this.includePrerelease = !!options.includePrerelease;
|
|
47238
|
+
|
|
47239
|
+
const m = version.trim().match(options.loose ? re$1[t$1.LOOSE] : re$1[t$1.FULL]);
|
|
47240
|
+
|
|
47241
|
+
if (!m) {
|
|
47242
|
+
throw new TypeError(`Invalid Version: ${version}`)
|
|
47243
|
+
}
|
|
47244
|
+
|
|
47245
|
+
this.raw = version;
|
|
47246
|
+
|
|
47247
|
+
// these are actually numbers
|
|
47248
|
+
this.major = +m[1];
|
|
47249
|
+
this.minor = +m[2];
|
|
47250
|
+
this.patch = +m[3];
|
|
47251
|
+
|
|
47252
|
+
if (this.major > MAX_SAFE_INTEGER$1 || this.major < 0) {
|
|
47253
|
+
throw new TypeError('Invalid major version')
|
|
47254
|
+
}
|
|
47255
|
+
|
|
47256
|
+
if (this.minor > MAX_SAFE_INTEGER$1 || this.minor < 0) {
|
|
47257
|
+
throw new TypeError('Invalid minor version')
|
|
47258
|
+
}
|
|
47259
|
+
|
|
47260
|
+
if (this.patch > MAX_SAFE_INTEGER$1 || this.patch < 0) {
|
|
47261
|
+
throw new TypeError('Invalid patch version')
|
|
47262
|
+
}
|
|
47263
|
+
|
|
47264
|
+
// numberify any prerelease numeric ids
|
|
47265
|
+
if (!m[4]) {
|
|
47266
|
+
this.prerelease = [];
|
|
47267
|
+
} else {
|
|
47268
|
+
this.prerelease = m[4].split('.').map((id) => {
|
|
47269
|
+
if (/^[0-9]+$/.test(id)) {
|
|
47270
|
+
const num = +id;
|
|
47271
|
+
if (num >= 0 && num < MAX_SAFE_INTEGER$1) {
|
|
47272
|
+
return num
|
|
47273
|
+
}
|
|
47274
|
+
}
|
|
47275
|
+
return id
|
|
47276
|
+
});
|
|
47277
|
+
}
|
|
47278
|
+
|
|
47279
|
+
this.build = m[5] ? m[5].split('.') : [];
|
|
47280
|
+
this.format();
|
|
47281
|
+
}
|
|
47282
|
+
|
|
47283
|
+
format () {
|
|
47284
|
+
this.version = `${this.major}.${this.minor}.${this.patch}`;
|
|
47285
|
+
if (this.prerelease.length) {
|
|
47286
|
+
this.version += `-${this.prerelease.join('.')}`;
|
|
47287
|
+
}
|
|
47288
|
+
return this.version
|
|
47289
|
+
}
|
|
47290
|
+
|
|
47291
|
+
toString () {
|
|
47292
|
+
return this.version
|
|
47293
|
+
}
|
|
47294
|
+
|
|
47295
|
+
compare (other) {
|
|
47296
|
+
debug_1('SemVer.compare', this.version, this.options, other);
|
|
47297
|
+
if (!(other instanceof SemVer)) {
|
|
47298
|
+
if (typeof other === 'string' && other === this.version) {
|
|
47299
|
+
return 0
|
|
47300
|
+
}
|
|
47301
|
+
other = new SemVer(other, this.options);
|
|
47302
|
+
}
|
|
47303
|
+
|
|
47304
|
+
if (other.version === this.version) {
|
|
47305
|
+
return 0
|
|
47306
|
+
}
|
|
47307
|
+
|
|
47308
|
+
return this.compareMain(other) || this.comparePre(other)
|
|
47309
|
+
}
|
|
47310
|
+
|
|
47311
|
+
compareMain (other) {
|
|
47312
|
+
if (!(other instanceof SemVer)) {
|
|
47313
|
+
other = new SemVer(other, this.options);
|
|
47314
|
+
}
|
|
47315
|
+
|
|
47316
|
+
return (
|
|
47317
|
+
compareIdentifiers$1(this.major, other.major) ||
|
|
47318
|
+
compareIdentifiers$1(this.minor, other.minor) ||
|
|
47319
|
+
compareIdentifiers$1(this.patch, other.patch)
|
|
47320
|
+
)
|
|
47321
|
+
}
|
|
47322
|
+
|
|
47323
|
+
comparePre (other) {
|
|
47324
|
+
if (!(other instanceof SemVer)) {
|
|
47325
|
+
other = new SemVer(other, this.options);
|
|
47326
|
+
}
|
|
47327
|
+
|
|
47328
|
+
// NOT having a prerelease is > having one
|
|
47329
|
+
if (this.prerelease.length && !other.prerelease.length) {
|
|
47330
|
+
return -1
|
|
47331
|
+
} else if (!this.prerelease.length && other.prerelease.length) {
|
|
47332
|
+
return 1
|
|
47333
|
+
} else if (!this.prerelease.length && !other.prerelease.length) {
|
|
47334
|
+
return 0
|
|
47335
|
+
}
|
|
47336
|
+
|
|
47337
|
+
let i = 0;
|
|
47338
|
+
do {
|
|
47339
|
+
const a = this.prerelease[i];
|
|
47340
|
+
const b = other.prerelease[i];
|
|
47341
|
+
debug_1('prerelease compare', i, a, b);
|
|
47342
|
+
if (a === undefined && b === undefined) {
|
|
47343
|
+
return 0
|
|
47344
|
+
} else if (b === undefined) {
|
|
47345
|
+
return 1
|
|
47346
|
+
} else if (a === undefined) {
|
|
47347
|
+
return -1
|
|
47348
|
+
} else if (a === b) {
|
|
47349
|
+
continue
|
|
47350
|
+
} else {
|
|
47351
|
+
return compareIdentifiers$1(a, b)
|
|
47352
|
+
}
|
|
47353
|
+
} while (++i)
|
|
47354
|
+
}
|
|
47355
|
+
|
|
47356
|
+
compareBuild (other) {
|
|
47357
|
+
if (!(other instanceof SemVer)) {
|
|
47358
|
+
other = new SemVer(other, this.options);
|
|
47359
|
+
}
|
|
47360
|
+
|
|
47361
|
+
let i = 0;
|
|
47362
|
+
do {
|
|
47363
|
+
const a = this.build[i];
|
|
47364
|
+
const b = other.build[i];
|
|
47365
|
+
debug_1('prerelease compare', i, a, b);
|
|
47366
|
+
if (a === undefined && b === undefined) {
|
|
47367
|
+
return 0
|
|
47368
|
+
} else if (b === undefined) {
|
|
47369
|
+
return 1
|
|
47370
|
+
} else if (a === undefined) {
|
|
47371
|
+
return -1
|
|
47372
|
+
} else if (a === b) {
|
|
47373
|
+
continue
|
|
47374
|
+
} else {
|
|
47375
|
+
return compareIdentifiers$1(a, b)
|
|
47376
|
+
}
|
|
47377
|
+
} while (++i)
|
|
47378
|
+
}
|
|
47379
|
+
|
|
47380
|
+
// preminor will bump the version up to the next minor release, and immediately
|
|
47381
|
+
// down to pre-release. premajor and prepatch work the same way.
|
|
47382
|
+
inc (release, identifier) {
|
|
47383
|
+
switch (release) {
|
|
47384
|
+
case 'premajor':
|
|
47385
|
+
this.prerelease.length = 0;
|
|
47386
|
+
this.patch = 0;
|
|
47387
|
+
this.minor = 0;
|
|
47388
|
+
this.major++;
|
|
47389
|
+
this.inc('pre', identifier);
|
|
47390
|
+
break
|
|
47391
|
+
case 'preminor':
|
|
47392
|
+
this.prerelease.length = 0;
|
|
47393
|
+
this.patch = 0;
|
|
47394
|
+
this.minor++;
|
|
47395
|
+
this.inc('pre', identifier);
|
|
47396
|
+
break
|
|
47397
|
+
case 'prepatch':
|
|
47398
|
+
// If this is already a prerelease, it will bump to the next version
|
|
47399
|
+
// drop any prereleases that might already exist, since they are not
|
|
47400
|
+
// relevant at this point.
|
|
47401
|
+
this.prerelease.length = 0;
|
|
47402
|
+
this.inc('patch', identifier);
|
|
47403
|
+
this.inc('pre', identifier);
|
|
47404
|
+
break
|
|
47405
|
+
// If the input is a non-prerelease version, this acts the same as
|
|
47406
|
+
// prepatch.
|
|
47407
|
+
case 'prerelease':
|
|
47408
|
+
if (this.prerelease.length === 0) {
|
|
47409
|
+
this.inc('patch', identifier);
|
|
47410
|
+
}
|
|
47411
|
+
this.inc('pre', identifier);
|
|
47412
|
+
break
|
|
47413
|
+
|
|
47414
|
+
case 'major':
|
|
47415
|
+
// If this is a pre-major version, bump up to the same major version.
|
|
47416
|
+
// Otherwise increment major.
|
|
47417
|
+
// 1.0.0-5 bumps to 1.0.0
|
|
47418
|
+
// 1.1.0 bumps to 2.0.0
|
|
47419
|
+
if (
|
|
47420
|
+
this.minor !== 0 ||
|
|
47421
|
+
this.patch !== 0 ||
|
|
47422
|
+
this.prerelease.length === 0
|
|
47423
|
+
) {
|
|
47424
|
+
this.major++;
|
|
47425
|
+
}
|
|
47426
|
+
this.minor = 0;
|
|
47427
|
+
this.patch = 0;
|
|
47428
|
+
this.prerelease = [];
|
|
47429
|
+
break
|
|
47430
|
+
case 'minor':
|
|
47431
|
+
// If this is a pre-minor version, bump up to the same minor version.
|
|
47432
|
+
// Otherwise increment minor.
|
|
47433
|
+
// 1.2.0-5 bumps to 1.2.0
|
|
47434
|
+
// 1.2.1 bumps to 1.3.0
|
|
47435
|
+
if (this.patch !== 0 || this.prerelease.length === 0) {
|
|
47436
|
+
this.minor++;
|
|
47437
|
+
}
|
|
47438
|
+
this.patch = 0;
|
|
47439
|
+
this.prerelease = [];
|
|
47440
|
+
break
|
|
47441
|
+
case 'patch':
|
|
47442
|
+
// If this is not a pre-release version, it will increment the patch.
|
|
47443
|
+
// If it is a pre-release it will bump up to the same patch version.
|
|
47444
|
+
// 1.2.0-5 patches to 1.2.0
|
|
47445
|
+
// 1.2.0 patches to 1.2.1
|
|
47446
|
+
if (this.prerelease.length === 0) {
|
|
47447
|
+
this.patch++;
|
|
47448
|
+
}
|
|
47449
|
+
this.prerelease = [];
|
|
47450
|
+
break
|
|
47451
|
+
// This probably shouldn't be used publicly.
|
|
47452
|
+
// 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
|
|
47453
|
+
case 'pre':
|
|
47454
|
+
if (this.prerelease.length === 0) {
|
|
47455
|
+
this.prerelease = [0];
|
|
47456
|
+
} else {
|
|
47457
|
+
let i = this.prerelease.length;
|
|
47458
|
+
while (--i >= 0) {
|
|
47459
|
+
if (typeof this.prerelease[i] === 'number') {
|
|
47460
|
+
this.prerelease[i]++;
|
|
47461
|
+
i = -2;
|
|
47462
|
+
}
|
|
47463
|
+
}
|
|
47464
|
+
if (i === -1) {
|
|
47465
|
+
// didn't increment anything
|
|
47466
|
+
this.prerelease.push(0);
|
|
47467
|
+
}
|
|
47468
|
+
}
|
|
47469
|
+
if (identifier) {
|
|
47470
|
+
// 1.2.0-beta.1 bumps to 1.2.0-beta.2,
|
|
47471
|
+
// 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
|
|
47472
|
+
if (compareIdentifiers$1(this.prerelease[0], identifier) === 0) {
|
|
47473
|
+
if (isNaN(this.prerelease[1])) {
|
|
47474
|
+
this.prerelease = [identifier, 0];
|
|
47475
|
+
}
|
|
47476
|
+
} else {
|
|
47477
|
+
this.prerelease = [identifier, 0];
|
|
47478
|
+
}
|
|
47479
|
+
}
|
|
47480
|
+
break
|
|
47481
|
+
|
|
47482
|
+
default:
|
|
47483
|
+
throw new Error(`invalid increment argument: ${release}`)
|
|
47484
|
+
}
|
|
47485
|
+
this.format();
|
|
47486
|
+
this.raw = this.version;
|
|
47487
|
+
return this
|
|
47488
|
+
}
|
|
47489
|
+
}
|
|
47490
|
+
|
|
47491
|
+
var semver = SemVer;
|
|
47492
|
+
|
|
47493
|
+
const compare = (a, b, loose) =>
|
|
47494
|
+
new semver(a, loose).compare(new semver(b, loose));
|
|
47495
|
+
|
|
47496
|
+
var compare_1 = compare;
|
|
47497
|
+
|
|
47498
|
+
const gte = (a, b, loose) => compare_1(a, b, loose) >= 0;
|
|
47499
|
+
var gte_1 = gte;
|
|
47500
|
+
|
|
47501
|
+
function osHasBluetoothSupport(selectedDevice, osVersion) {
|
|
47502
|
+
if (!selectedDevice) {
|
|
47503
|
+
return false;
|
|
47504
|
+
}
|
|
47505
|
+
// Only the Crown supports Bluetooth
|
|
47506
|
+
const isCrown = Number(selectedDevice.modelVersion) >= 3;
|
|
47507
|
+
if (!isCrown) {
|
|
47508
|
+
return false;
|
|
47509
|
+
}
|
|
47510
|
+
const isEmulator = !!(selectedDevice === null || selectedDevice === void 0 ? void 0 : selectedDevice.emulator);
|
|
47511
|
+
if (isEmulator) {
|
|
47512
|
+
return false;
|
|
47513
|
+
}
|
|
47514
|
+
// `osVersion` is updated in real time,
|
|
47515
|
+
// unlike accessing via `selectedDevice.osVersion`
|
|
47516
|
+
return gte_1(osVersion !== null && osVersion !== void 0 ? osVersion : selectedDevice.osVersion, "16.0.0");
|
|
47517
|
+
}
|
|
47518
|
+
|
|
47560
47519
|
var __awaiter$g = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
47561
47520
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
47562
47521
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -47609,7 +47568,7 @@ class Neurosity {
|
|
|
47609
47568
|
if (!!bluetoothTransport) {
|
|
47610
47569
|
this.bluetoothClient = new BluetoothClient({
|
|
47611
47570
|
selectedDevice$: this.onDeviceChange(),
|
|
47612
|
-
|
|
47571
|
+
osHasBluetoothSupport$: this._osHasBluetoothSupport(),
|
|
47613
47572
|
createBluetoothToken: this.createBluetoothToken.bind(this),
|
|
47614
47573
|
transport: bluetoothTransport
|
|
47615
47574
|
});
|
|
@@ -47640,6 +47599,16 @@ class Neurosity {
|
|
|
47640
47599
|
this.streamingMode$.next(streamingMode);
|
|
47641
47600
|
}
|
|
47642
47601
|
}
|
|
47602
|
+
/**
|
|
47603
|
+
*
|
|
47604
|
+
* @hidden
|
|
47605
|
+
*/
|
|
47606
|
+
_osHasBluetoothSupport() {
|
|
47607
|
+
return combineLatest({
|
|
47608
|
+
selectedDevice: this.onDeviceChange(),
|
|
47609
|
+
osVersion: this.osVersion().pipe(startWith(null))
|
|
47610
|
+
}).pipe(map(({ selectedDevice, osVersion }) => osHasBluetoothSupport(selectedDevice, osVersion)));
|
|
47611
|
+
}
|
|
47643
47612
|
/**
|
|
47644
47613
|
* Subscribe to the device's streaming state changes and the current strategy
|
|
47645
47614
|
*
|
|
@@ -47655,12 +47624,14 @@ class Neurosity {
|
|
|
47655
47624
|
streamingState() {
|
|
47656
47625
|
const isWifiOnline = (state) => [STATUS.ONLINE, STATUS.UPDATING].includes(state);
|
|
47657
47626
|
return this.streamingMode$.pipe(switchMap((streamingMode) => {
|
|
47658
|
-
return
|
|
47659
|
-
|
|
47627
|
+
return combineLatest({
|
|
47628
|
+
selectedDevice: this.onDeviceChange(),
|
|
47629
|
+
osHasBluetoothSupport: this._osHasBluetoothSupport()
|
|
47630
|
+
}).pipe(switchMap(({ selectedDevice, osHasBluetoothSupport: osHasBluetoothSupport$$1 }) => {
|
|
47631
|
+
if (!selectedDevice) {
|
|
47660
47632
|
return EMPTY;
|
|
47661
47633
|
}
|
|
47662
|
-
const isUnableToUseBluetooth = this.isMissingBluetoothTransport ||
|
|
47663
|
-
!osHasBluetoothSupport(selectDevice, osVersion);
|
|
47634
|
+
const isUnableToUseBluetooth = this.isMissingBluetoothTransport || !osHasBluetoothSupport$$1;
|
|
47664
47635
|
if (isUnableToUseBluetooth) {
|
|
47665
47636
|
return this.cloudClient.status().pipe(map(({ state }) => ({
|
|
47666
47637
|
connected: isWifiOnline(state),
|