@dereekb/browser 10.0.5 → 10.0.7
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/index.cjs.d.ts +1 -0
- package/index.cjs.js +2850 -0
- package/index.esm.js +2813 -0
- package/package.json +17 -3
- package/src/lib/service.d.ts +2 -2
- package/CHANGELOG.md +0 -1333
- package/src/index.js +0 -5
- package/src/index.js.map +0 -1
- package/src/lib/index.js +0 -7
- package/src/lib/index.js.map +0 -1
- package/src/lib/service.js +0 -97
- package/src/lib/service.js.map +0 -1
- package/src/lib/vh100.js +0 -24
- package/src/lib/vh100.js.map +0 -1
- package/src/lib/window.js +0 -25
- package/src/lib/window.js.map +0 -1
package/src/index.js
DELETED
package/src/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/browser/src/index.ts"],"names":[],"mappings":";;;AAAA,gDAAsB"}
|
package/src/lib/index.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./service"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./vh100"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./window"), exports);
|
|
7
|
-
//# sourceMappingURL=index.js.map
|
package/src/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/browser/src/lib/index.ts"],"names":[],"mappings":";;;AAAA,oDAA0B;AAC1B,kDAAwB;AACxB,mDAAyB"}
|
package/src/lib/service.js
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AbstractAsyncWindowLoadedService = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const rxjs_1 = require("@dereekb/rxjs");
|
|
6
|
-
const rxjs_2 = require("rxjs");
|
|
7
|
-
/**
|
|
8
|
-
* Used for loading services in the browser that are imported from other scripts, such as Facebook, Segment, Stripe, etc.
|
|
9
|
-
*/
|
|
10
|
-
class AbstractAsyncWindowLoadedService {
|
|
11
|
-
/**
|
|
12
|
-
* @param _windowKey Key that is attached to the window for the object that is the service when finished loading.
|
|
13
|
-
* @param _callbackKey Optional key attached to window that is a function that is executed when the setup is complete.
|
|
14
|
-
*/
|
|
15
|
-
constructor(_windowKey, _callbackKey, _serviceName = _windowKey, preload = true) {
|
|
16
|
-
this._windowKey = _windowKey;
|
|
17
|
-
this._callbackKey = _callbackKey;
|
|
18
|
-
this._serviceName = _serviceName;
|
|
19
|
-
this._loading = new rxjs_2.BehaviorSubject(undefined);
|
|
20
|
-
this.loading$ = this._loading.pipe((0, rxjs_1.tapFirst)(() => this.loadService()), (0, rxjs_1.filterMaybe)(), (0, rxjs_2.shareReplay)(1));
|
|
21
|
-
this.service$ = this.loading$.pipe((0, rxjs_2.switchMap)((x) => (0, rxjs_2.from)(x)), (0, rxjs_2.shareReplay)(1));
|
|
22
|
-
if (preload) {
|
|
23
|
-
// Begin loading the service immediately.
|
|
24
|
-
setTimeout(() => this.loadService().catch());
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
destroy() {
|
|
28
|
-
this._loading.complete();
|
|
29
|
-
}
|
|
30
|
-
getService() {
|
|
31
|
-
return (0, rxjs_2.firstValueFrom)(this.service$);
|
|
32
|
-
}
|
|
33
|
-
// MARK: Loading
|
|
34
|
-
loadService() {
|
|
35
|
-
if (!this._loading.value) {
|
|
36
|
-
const loadingPromise = new Promise((resolve, reject) => {
|
|
37
|
-
let loadTry = 0;
|
|
38
|
-
const rejectWithError = () => {
|
|
39
|
-
reject(new Error(`Service "${this._serviceName}" failed loading with windowKey "${this._windowKey}"`));
|
|
40
|
-
};
|
|
41
|
-
const tryLoad = () => {
|
|
42
|
-
const windowRef = window;
|
|
43
|
-
// Loaded before the promise.
|
|
44
|
-
if (windowRef[this._windowKey]) {
|
|
45
|
-
// Not yet finished loading async. Intercept the function.
|
|
46
|
-
// console.log('Window key.');
|
|
47
|
-
return resolve(this.completeLoadingService());
|
|
48
|
-
}
|
|
49
|
-
else if (this._callbackKey && windowRef[this._callbackKey]) {
|
|
50
|
-
// console.log('Callback key.');
|
|
51
|
-
windowRef[this._callbackKey] = () => resolve(this.completeLoadingService());
|
|
52
|
-
}
|
|
53
|
-
else if (loadTry < 10) {
|
|
54
|
-
loadTry += 1;
|
|
55
|
-
// console.log('Try reload...');
|
|
56
|
-
setTimeout(() => tryLoad(), 1000);
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
const retry = this._onLoadServiceFailure();
|
|
60
|
-
if (retry) {
|
|
61
|
-
retry.then((x) => resolve(x)).catch(() => rejectWithError());
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
rejectWithError();
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
tryLoad();
|
|
69
|
-
});
|
|
70
|
-
this._loading.next(loadingPromise);
|
|
71
|
-
}
|
|
72
|
-
return this._loading.value;
|
|
73
|
-
}
|
|
74
|
-
_onLoadServiceFailure() {
|
|
75
|
-
// override in parent if needed.
|
|
76
|
-
}
|
|
77
|
-
completeLoadingService() {
|
|
78
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
79
|
-
yield this._prepareCompleteLoadingService();
|
|
80
|
-
const service = window[this._windowKey];
|
|
81
|
-
if (!service) {
|
|
82
|
-
throw new Error(`Service "${this._serviceName}" could not complete loading.`);
|
|
83
|
-
}
|
|
84
|
-
// Init the API
|
|
85
|
-
const initializedService = yield this._initService(service);
|
|
86
|
-
return initializedService !== null && initializedService !== void 0 ? initializedService : service;
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
_prepareCompleteLoadingService() {
|
|
90
|
-
return Promise.resolve();
|
|
91
|
-
}
|
|
92
|
-
_initService(service) {
|
|
93
|
-
return Promise.resolve(service);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
exports.AbstractAsyncWindowLoadedService = AbstractAsyncWindowLoadedService;
|
|
97
|
-
//# sourceMappingURL=service.js.map
|
package/src/lib/service.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../../../../packages/browser/src/lib/service.ts"],"names":[],"mappings":";;;;AAGA,wCAAsD;AACtD,+BAAiG;AAKjG;;GAEG;AACH,MAAsB,gCAAgC;IAcpD;;;OAGG;IACH,YAAoB,UAAkB,EAAU,YAAqB,EAAU,eAAuB,UAAU,EAAE,UAAmB,IAAI;QAArH,eAAU,GAAV,UAAU,CAAQ;QAAU,iBAAY,GAAZ,YAAY,CAAS;QAAU,iBAAY,GAAZ,YAAY,CAAqB;QAjBxG,aAAQ,GAAG,IAAI,sBAAe,CAAoB,SAAS,CAAC,CAAC;QAE5D,aAAQ,GAA2B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAC5D,IAAA,eAAQ,EAAC,GAAG,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,EAClC,IAAA,kBAAW,GAAE,EACb,IAAA,kBAAW,EAAC,CAAC,CAAC,CACf,CAAC;QAEO,aAAQ,GAAkB,IAAI,CAAC,QAAQ,CAAC,IAAI,CACnD,IAAA,gBAAS,EAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,WAAI,EAAC,CAAC,CAAC,CAAC,EACzB,IAAA,kBAAW,EAAC,CAAC,CAAC,CACf,CAAC;QAOA,IAAI,OAAO,EAAE;YACX,yCAAyC;YACzC,UAAU,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC;SAC9C;IACH,CAAC;IAED,OAAO;QACL,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE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,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,eAAe,EAAE,CAAC,CAAC;yBAC9D;6BAAM;4BACL,eAAe,EAAE,CAAC;yBACnB;qBACF;gBACH,CAAC,CAAC;gBAEF,OAAO,EAAE,CAAC;YACZ,CAAC,CAAC,CAAC;YAEH,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;SACpC;QAED,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAmB,CAAC;IAC3C,CAAC;IAES,qBAAqB;QAC7B,gCAAgC;IAClC,CAAC;IAEa,sBAAsB;;YAClC,MAAM,IAAI,CAAC,8BAA8B,EAAE,CAAC;YAC5C,MAAM,OAAO,GAAc,MAAwC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAErF,IAAI,CAAC,OAAO,EAAE;gBACZ,MAAM,IAAI,KAAK,CAAC,YAAY,IAAI,CAAC,YAAY,+BAA+B,CAAC,CAAC;aAC/E;YAED,eAAe;YACf,MAAM,kBAAkB,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;YAC5D,OAAO,kBAAkB,aAAlB,kBAAkB,cAAlB,kBAAkB,GAAI,OAAO,CAAC;QACvC,CAAC;KAAA;IAES,8BAA8B;QACtC,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAES,YAAY,CAAC,OAAU;QAC/B,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAClC,CAAC;CACF;AAtGD,4EAsGC"}
|
package/src/lib/vh100.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// https://dev.to/maciejtrzcinski/100vh-problem-with-ios-safari-3ge9
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.watchWindowAndUpdateVh100StyleProperty = exports.refreshVh100Function = exports.DEFAULT_VH100_VARIABLE_NAME = void 0;
|
|
5
|
-
exports.DEFAULT_VH100_VARIABLE_NAME = 'vh100';
|
|
6
|
-
function refreshVh100Function(cssVariableName = exports.DEFAULT_VH100_VARIABLE_NAME) {
|
|
7
|
-
const cssProperty = `--${cssVariableName}`;
|
|
8
|
-
return () => {
|
|
9
|
-
const doc = document.documentElement;
|
|
10
|
-
doc.style.setProperty(cssProperty, `${window.innerHeight}px`);
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
exports.refreshVh100Function = refreshVh100Function;
|
|
14
|
-
/**
|
|
15
|
-
* Adds window event listeners to populate the css variable `vh100`, or another input variable name, with the current window height.
|
|
16
|
-
*/
|
|
17
|
-
function watchWindowAndUpdateVh100StyleProperty(cssVariableName) {
|
|
18
|
-
const refreshPropertyValue = refreshVh100Function(cssVariableName);
|
|
19
|
-
window.addEventListener('resize', refreshPropertyValue);
|
|
20
|
-
window.addEventListener('orientationchange', refreshPropertyValue);
|
|
21
|
-
refreshPropertyValue();
|
|
22
|
-
}
|
|
23
|
-
exports.watchWindowAndUpdateVh100StyleProperty = watchWindowAndUpdateVh100StyleProperty;
|
|
24
|
-
//# sourceMappingURL=vh100.js.map
|
package/src/lib/vh100.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vh100.js","sourceRoot":"","sources":["../../../../../packages/browser/src/lib/vh100.ts"],"names":[],"mappings":";AAAA,oEAAoE;;;AAEvD,QAAA,2BAA2B,GAAG,OAAO,CAAC;AAEnD,SAAgB,oBAAoB,CAAC,eAAe,GAAG,mCAA2B;IAChF,MAAM,WAAW,GAAG,KAAK,eAAe,EAAE,CAAC;IAC3C,OAAO,GAAG,EAAE;QACV,MAAM,GAAG,GAAG,QAAQ,CAAC,eAAe,CAAC;QACrC,GAAG,CAAC,KAAK,CAAC,WAAW,CAAC,WAAW,EAAE,GAAG,MAAM,CAAC,WAAW,IAAI,CAAC,CAAC;IAChE,CAAC,CAAC;AACJ,CAAC;AAND,oDAMC;AAED;;GAEG;AACH,SAAgB,sCAAsC,CAAC,eAAwB;IAC7E,MAAM,oBAAoB,GAAG,oBAAoB,CAAC,eAAe,CAAC,CAAC;IAEnE,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;IACxD,MAAM,CAAC,gBAAgB,CAAC,mBAAmB,EAAE,oBAAoB,CAAC,CAAC;IACnE,oBAAoB,EAAE,CAAC;AACzB,CAAC;AAND,wFAMC"}
|
package/src/lib/window.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// MARK: Window Location Utiltiies
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.getWindowPathNameWithQuery = exports.getBaseWindowUrl = exports.makeWindowPath = exports.isLocalhost = void 0;
|
|
5
|
-
/**
|
|
6
|
-
* Whether or not the current host is localhost. Useful for determining local dev environments.
|
|
7
|
-
*/
|
|
8
|
-
function isLocalhost() {
|
|
9
|
-
return window.location.hostname === 'localhost';
|
|
10
|
-
}
|
|
11
|
-
exports.isLocalhost = isLocalhost;
|
|
12
|
-
function makeWindowPath(path) {
|
|
13
|
-
return `${getBaseWindowUrl()}${path}`;
|
|
14
|
-
}
|
|
15
|
-
exports.makeWindowPath = makeWindowPath;
|
|
16
|
-
function getBaseWindowUrl() {
|
|
17
|
-
const port = window.location.port ? ':' + window.location.port : '';
|
|
18
|
-
return `${window.location.protocol}//${window.location.hostname}${port}`;
|
|
19
|
-
}
|
|
20
|
-
exports.getBaseWindowUrl = getBaseWindowUrl;
|
|
21
|
-
function getWindowPathNameWithQuery() {
|
|
22
|
-
return window.location.pathname + window.location.search;
|
|
23
|
-
}
|
|
24
|
-
exports.getWindowPathNameWithQuery = getWindowPathNameWithQuery;
|
|
25
|
-
//# sourceMappingURL=window.js.map
|
package/src/lib/window.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"window.js","sourceRoot":"","sources":["../../../../../packages/browser/src/lib/window.ts"],"names":[],"mappings":";AAAA,kCAAkC;;;AAElC;;GAEG;AACH,SAAgB,WAAW;IACzB,OAAO,MAAM,CAAC,QAAQ,CAAC,QAAQ,KAAK,WAAW,CAAC;AAClD,CAAC;AAFD,kCAEC;AAED,SAAgB,cAAc,CAAC,IAAY;IACzC,OAAO,GAAG,gBAAgB,EAAE,GAAG,IAAI,EAAE,CAAC;AACxC,CAAC;AAFD,wCAEC;AAED,SAAgB,gBAAgB;IAC9B,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;IACpE,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,QAAQ,KAAK,MAAM,CAAC,QAAQ,CAAC,QAAQ,GAAG,IAAI,EAAE,CAAC;AAC3E,CAAC;AAHD,4CAGC;AAED,SAAgB,0BAA0B;IACxC,OAAO,MAAM,CAAC,QAAQ,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;AAC3D,CAAC;AAFD,gEAEC"}
|