@christianriedl/utils 1.0.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/jsdir/utils/src/helper.d.ts +28 -0
- package/jsdir/utils/src/helper.js +144 -0
- package/jsdir/utils/src/helper.js.map +1 -0
- package/jsdir/utils/src/iLocalStorage.d.ts +7 -0
- package/jsdir/utils/src/iLocalStorage.js +2 -0
- package/jsdir/utils/src/iLocalStorage.js.map +1 -0
- package/jsdir/utils/src/localStorage.d.ts +20 -0
- package/jsdir/utils/src/localStorage.js +57 -0
- package/jsdir/utils/src/localStorage.js.map +1 -0
- package/jsdir/utils/src/registerserviceworker.d.ts +31 -0
- package/jsdir/utils/src/registerserviceworker.js +251 -0
- package/jsdir/utils/src/registerserviceworker.js.map +1 -0
- package/package.json +22 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare type Dictionary<T> = {
|
|
2
|
+
[key: string]: T;
|
|
3
|
+
};
|
|
4
|
+
export interface IValueText {
|
|
5
|
+
value: number;
|
|
6
|
+
text: string;
|
|
7
|
+
}
|
|
8
|
+
export default class Helper {
|
|
9
|
+
static fromMilliseconds1970(ms: number): Date;
|
|
10
|
+
static toTicks(dt: Date): number;
|
|
11
|
+
static toUnixTime(dt: Date): number;
|
|
12
|
+
static fromTicks(ticks: number): Date;
|
|
13
|
+
static fromUnixTime(unixTime: number): Date;
|
|
14
|
+
static toUTC(dt: Date): Date;
|
|
15
|
+
static toLocal(dt: Date): Date;
|
|
16
|
+
static round(value: number, digits: number | undefined): string;
|
|
17
|
+
static formatTime(dt: Date, withSeconds?: boolean): string;
|
|
18
|
+
static formatDayTime(dt: Date, withSeconds?: boolean): string;
|
|
19
|
+
private static padNumber2;
|
|
20
|
+
static toColor(red: number, green: number, blue: number): string;
|
|
21
|
+
static generateUUID(): string;
|
|
22
|
+
static deepCompare(o: any, p: any): boolean;
|
|
23
|
+
static isMobileDevice(): boolean;
|
|
24
|
+
static wait(ms: number): Promise<void>;
|
|
25
|
+
static enumToString(en: any, value: unknown): string;
|
|
26
|
+
static stringToEnum(en: any, value: unknown): number;
|
|
27
|
+
static getEnumOptions(en: any): IValueText[];
|
|
28
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
const dec = [1, 10, 100, 1000, 10000, 100000, 1000000];
|
|
2
|
+
const ms1970m1d1 = 62135596800000;
|
|
3
|
+
export default class Helper {
|
|
4
|
+
static fromMilliseconds1970(ms) {
|
|
5
|
+
ms = ms - ms1970m1d1;
|
|
6
|
+
return new Date(ms); // 1.1.1970 utc in ms
|
|
7
|
+
}
|
|
8
|
+
static toTicks(dt) {
|
|
9
|
+
return ((dt.getTime() * 10000) + 621355968000000000);
|
|
10
|
+
}
|
|
11
|
+
static toUnixTime(dt) {
|
|
12
|
+
return Math.round(dt.getTime() / 1000);
|
|
13
|
+
}
|
|
14
|
+
static fromTicks(ticks) {
|
|
15
|
+
return new Date((ticks - 621355968000000000) / 1000);
|
|
16
|
+
}
|
|
17
|
+
static fromUnixTime(unixTime) {
|
|
18
|
+
return new Date(unixTime * 1000);
|
|
19
|
+
}
|
|
20
|
+
static toUTC(dt) {
|
|
21
|
+
return new Date(dt.getUTCFullYear(), dt.getUTCMonth(), dt.getUTCDate(), dt.getUTCHours(), dt.getUTCMinutes(), dt.getUTCSeconds());
|
|
22
|
+
}
|
|
23
|
+
static toLocal(dt) {
|
|
24
|
+
let d = dt.getTime() - dt.getTimezoneOffset() * 60000;
|
|
25
|
+
return new Date(d);
|
|
26
|
+
}
|
|
27
|
+
static round(value, digits) {
|
|
28
|
+
if (!digits) {
|
|
29
|
+
digits = 0;
|
|
30
|
+
}
|
|
31
|
+
value = Math.round(value * dec[digits]) / dec[digits];
|
|
32
|
+
return value.toString();
|
|
33
|
+
}
|
|
34
|
+
static formatTime(dt, withSeconds) {
|
|
35
|
+
let s = Helper.padNumber2(dt.getHours()) + ':' + Helper.padNumber2(dt.getMinutes());
|
|
36
|
+
if (withSeconds) {
|
|
37
|
+
s = s + ':' + this.padNumber2(dt.getSeconds());
|
|
38
|
+
}
|
|
39
|
+
return s;
|
|
40
|
+
}
|
|
41
|
+
static formatDayTime(dt, withSeconds) {
|
|
42
|
+
let s = dt.getDate() + ' ' + Helper.padNumber2(dt.getHours()) + ':' + Helper.padNumber2(dt.getMinutes());
|
|
43
|
+
if (withSeconds) {
|
|
44
|
+
s = s + ':' + this.padNumber2(dt.getSeconds());
|
|
45
|
+
}
|
|
46
|
+
return s;
|
|
47
|
+
}
|
|
48
|
+
static padNumber2(num, radix) {
|
|
49
|
+
let s = num.toString(radix);
|
|
50
|
+
if (s.length < 2)
|
|
51
|
+
s = '0' + s;
|
|
52
|
+
return s;
|
|
53
|
+
}
|
|
54
|
+
static toColor(red, green, blue) {
|
|
55
|
+
return '#' + Helper.padNumber2(red, 16) + Helper.padNumber2(green, 16) + Helper.padNumber2(blue, 16);
|
|
56
|
+
}
|
|
57
|
+
static generateUUID() {
|
|
58
|
+
var d = new Date().getTime();
|
|
59
|
+
d += performance.now(); //use high-precision timer if available
|
|
60
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
61
|
+
var r = (d + Math.random() * 16) % 16 | 0;
|
|
62
|
+
d = Math.floor(d / 16);
|
|
63
|
+
return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
static deepCompare(o, p) {
|
|
67
|
+
if (typeof o == 'undefined' || typeof p == 'undefined') {
|
|
68
|
+
return typeof o == typeof p;
|
|
69
|
+
}
|
|
70
|
+
var i, keysO = Object.keys(o).sort(), keysP = Object.keys(p).sort();
|
|
71
|
+
if (keysO.length !== keysP.length)
|
|
72
|
+
return false; //not the same nr of keys
|
|
73
|
+
if (keysO.join('') !== keysP.join(''))
|
|
74
|
+
return false; //different keys
|
|
75
|
+
for (i = 0; i < keysO.length; ++i) {
|
|
76
|
+
if (o[keysO[i]] instanceof Array) {
|
|
77
|
+
if (!(p[keysO[i]] instanceof Array))
|
|
78
|
+
return false;
|
|
79
|
+
//if (compareObjects(o[keysO[i]], p[keysO[i]] === false) return false
|
|
80
|
+
//would work, too, and perhaps is a better fit, still, this is easy, too
|
|
81
|
+
if (p[keysO[i]].sort().join('') !== o[keysO[i]].sort().join(''))
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
else if (o[keysO[i]] instanceof Date) {
|
|
85
|
+
if (!(p[keysO[i]] instanceof Date))
|
|
86
|
+
return false;
|
|
87
|
+
if (('' + o[keysO[i]]) !== ('' + p[keysO[i]]))
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
else if (o[keysO[i]] instanceof Function) {
|
|
91
|
+
if (!(p[keysO[i]] instanceof Function))
|
|
92
|
+
return false;
|
|
93
|
+
//ignore functions, or check them regardless?
|
|
94
|
+
}
|
|
95
|
+
else if (o[keysO[i]] instanceof Object) {
|
|
96
|
+
if (!(p[keysO[i]] instanceof Object))
|
|
97
|
+
return false;
|
|
98
|
+
if (o[keysO[i]] === o) { //self reference?
|
|
99
|
+
if (p[keysO[i]] !== p)
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
else if (Helper.deepCompare(o[keysO[i]], p[keysO[i]]) === false)
|
|
103
|
+
return false; //WARNING: does not deal with circular refs other than ^^
|
|
104
|
+
}
|
|
105
|
+
else if (o[keysO[i]] !== p[keysO[i]]) //change !== to != for loose comparison
|
|
106
|
+
return false; //not the same value
|
|
107
|
+
}
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
static isMobileDevice() {
|
|
111
|
+
return (typeof window.orientation !== "undefined");
|
|
112
|
+
}
|
|
113
|
+
static wait(ms) {
|
|
114
|
+
return new Promise(r => setTimeout(r, ms));
|
|
115
|
+
}
|
|
116
|
+
static enumToString(en, value) {
|
|
117
|
+
if (typeof value === 'string')
|
|
118
|
+
return value;
|
|
119
|
+
if (typeof value === 'number')
|
|
120
|
+
return en[value];
|
|
121
|
+
return '';
|
|
122
|
+
}
|
|
123
|
+
static stringToEnum(en, value) {
|
|
124
|
+
if (typeof value === 'string') {
|
|
125
|
+
return en[value];
|
|
126
|
+
//const e = en as { [key: string]: number };
|
|
127
|
+
//return e[value];
|
|
128
|
+
}
|
|
129
|
+
if (typeof value === 'number')
|
|
130
|
+
return value;
|
|
131
|
+
return -1;
|
|
132
|
+
}
|
|
133
|
+
static getEnumOptions(en) {
|
|
134
|
+
const options = [];
|
|
135
|
+
for (const key in en) {
|
|
136
|
+
const val = en[key];
|
|
137
|
+
if (typeof val === 'number') {
|
|
138
|
+
options.push({ value: val, text: key });
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return options;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helper.js","sourceRoot":"","sources":["../../../src/helper.ts"],"names":[],"mappings":"AAKA,MAAM,GAAG,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AACvD,MAAM,UAAU,GAAG,cAAc,CAAC;AAElC,MAAM,CAAC,OAAO,OAAO,MAAM;IACvB,MAAM,CAAC,oBAAoB,CAAC,EAAU;QAClC,EAAE,GAAG,EAAE,GAAG,UAAU,CAAC;QACrB,OAAO,IAAI,IAAI,CAAC,EAAE,CAAC,CAAC,CAAE,qBAAqB;IAC/C,CAAC;IACD,MAAM,CAAC,OAAO,CAAC,EAAQ;QACnB,OAAO,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,CAAC,GAAG,kBAAkB,CAAC,CAAC;IACzD,CAAC;IACD,MAAM,CAAC,UAAU,CAAC,EAAQ;QACtB,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC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M,GAAG,IAAI,EAAE,EAAE;YAClB,MAAM,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;YACpB,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;gBACzB,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC;aAC3C;SACJ;QACD,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface ILocalStorage {
|
|
2
|
+
getItem(name: string): string | null;
|
|
3
|
+
getItemString(name: string, def?: string): string;
|
|
4
|
+
getItemNumber(name: string, def?: number): number;
|
|
5
|
+
getItemBoolean(name: string, def?: boolean): boolean;
|
|
6
|
+
setItem(name: string, value: string | number | boolean | null): void;
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iLocalStorage.js","sourceRoot":"","sources":["../../../src/iLocalStorage.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ILocalStorage } from './iLocalStorage';
|
|
2
|
+
export * from './iLocalStorage';
|
|
3
|
+
export declare class LocalStorageDummy implements ILocalStorage {
|
|
4
|
+
prefix: string;
|
|
5
|
+
constructor(prefix: string);
|
|
6
|
+
getItem(name: string): string | null;
|
|
7
|
+
getItemString(name: string, def?: string): string;
|
|
8
|
+
getItemNumber(name: string, def?: number): number;
|
|
9
|
+
getItemBoolean(name: string, def?: boolean): boolean;
|
|
10
|
+
setItem(name: string, value: string | number | boolean | null): void;
|
|
11
|
+
}
|
|
12
|
+
export default class LocalStorage implements ILocalStorage {
|
|
13
|
+
prefix: string;
|
|
14
|
+
constructor(prefix: string);
|
|
15
|
+
getItem(name: string): string | null;
|
|
16
|
+
getItemString(name: string, def?: string): string;
|
|
17
|
+
getItemNumber(name: string, def?: number): number;
|
|
18
|
+
getItemBoolean(name: string, def?: boolean): boolean;
|
|
19
|
+
setItem(name: string, value: string | number | boolean | null): void;
|
|
20
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export * from './iLocalStorage';
|
|
2
|
+
export class LocalStorageDummy {
|
|
3
|
+
prefix = "";
|
|
4
|
+
constructor(prefix) {
|
|
5
|
+
if (prefix)
|
|
6
|
+
this.prefix = prefix + '_';
|
|
7
|
+
}
|
|
8
|
+
getItem(name) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
getItemString(name, def) {
|
|
12
|
+
return def ? def : "";
|
|
13
|
+
}
|
|
14
|
+
getItemNumber(name, def) {
|
|
15
|
+
return def ? def : 0;
|
|
16
|
+
}
|
|
17
|
+
getItemBoolean(name, def) {
|
|
18
|
+
return def ? def : false;
|
|
19
|
+
}
|
|
20
|
+
setItem(name, value) {
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export default class LocalStorage {
|
|
24
|
+
prefix = "";
|
|
25
|
+
constructor(prefix) {
|
|
26
|
+
if (prefix)
|
|
27
|
+
this.prefix = prefix + '_';
|
|
28
|
+
}
|
|
29
|
+
getItem(name) {
|
|
30
|
+
return window.localStorage.getItem(this.prefix + name);
|
|
31
|
+
}
|
|
32
|
+
getItemString(name, def) {
|
|
33
|
+
let str = window.localStorage.getItem(this.prefix + name);
|
|
34
|
+
if (str === null) {
|
|
35
|
+
if (def)
|
|
36
|
+
this.setItem(name, def);
|
|
37
|
+
str = def ? def : "";
|
|
38
|
+
}
|
|
39
|
+
return str;
|
|
40
|
+
}
|
|
41
|
+
getItemNumber(name, def) {
|
|
42
|
+
const str = window.localStorage.getItem(this.prefix + name);
|
|
43
|
+
if (str === null)
|
|
44
|
+
return def ? def : 0;
|
|
45
|
+
return Number(str);
|
|
46
|
+
}
|
|
47
|
+
getItemBoolean(name, def) {
|
|
48
|
+
const str = window.localStorage.getItem(this.prefix + name);
|
|
49
|
+
if (str === null)
|
|
50
|
+
return def ? def : false;
|
|
51
|
+
return str === "true";
|
|
52
|
+
}
|
|
53
|
+
setItem(name, value) {
|
|
54
|
+
window.localStorage.setItem(this.prefix + name, (value ? value.toString() : null));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=localStorage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localStorage.js","sourceRoot":"","sources":["../../../src/localStorage.ts"],"names":[],"mappings":"AACA,cAAc,iBAAiB,CAAC;AAEhC,MAAM,OAAO,iBAAiB;IAC1B,MAAM,GAAG,EAAE,CAAC;IACZ,YAAY,MAAc;QACtB,IAAI,MAAM;YACN,IAAI,CAAC,MAAM,GAAG,MAAM,GAAG,GAAG,CAAC;IACnC,CAAC;IACD,OAAO,CAAC,IAAY;QAChB,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,aAAa,CAAC,IAAY,EAAE,GAAY;QACpC,OAAO,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1B,CAAC;IACD,aAAa,CAAC,IAAY,EAAE,GAAY;QACpC,OAAO,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACzB,CAAC;IACD,cAAc,CAAC,IAAY,EAAE,GAAa;QACtC,OAAO,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC;IAC7B,CAAC;IACD,OAAO,CAAC,IAAY,EAAE,KAAuC;IAC7D,CAAC;CACJ;AACD,MAAM,CAAC,OAAO,OAAO,YAAY;IAC7B,MAAM,GAAG,EAAE,CAAC;IACZ,YAAY,MAAc;QACtB,IAAI,MAAM;YACN,IAAI,CAAC,MAAM,GAAG,MAAM,GAAG,GAAG,CAAC;IACnC,CAAC;IACD,OAAO,CAAC,IAAY;QAChB,OAAO,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC3D,CAAC;IACD,aAAa,CAAC,IAAY,EAAE,GAAY;QAC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IHook {
|
|
3
|
+
log: ILogger;
|
|
4
|
+
online(value: boolean): void;
|
|
5
|
+
ready(): void;
|
|
6
|
+
updated(): void;
|
|
7
|
+
cached(): void;
|
|
8
|
+
registered(): void;
|
|
9
|
+
error(reason: any): void;
|
|
10
|
+
subscribed?(isSubscribed: boolean): void;
|
|
11
|
+
}
|
|
12
|
+
export default class RegisterServiceWorker {
|
|
13
|
+
applicationServerPublicKey: string | undefined;
|
|
14
|
+
isOnline: boolean;
|
|
15
|
+
isSubscribed?: boolean;
|
|
16
|
+
static instance: RegisterServiceWorker;
|
|
17
|
+
private _rsw;
|
|
18
|
+
private _hook;
|
|
19
|
+
constructor(hook: IHook, applicationServerPublicKey?: string);
|
|
20
|
+
get registration(): ServiceWorkerRegistration;
|
|
21
|
+
register(swUrl: string, scope?: string): void;
|
|
22
|
+
private registerValidSW;
|
|
23
|
+
private processMessage;
|
|
24
|
+
notify(msg: any): void;
|
|
25
|
+
private checkValidServiceWorker;
|
|
26
|
+
unregister(): void;
|
|
27
|
+
getSubscription(): Promise<PushSubscription | null>;
|
|
28
|
+
subscribeUser(): Promise<PushSubscription>;
|
|
29
|
+
unsubscribeUser(): Promise<PushSubscription>;
|
|
30
|
+
private static urlB64ToUint8Array;
|
|
31
|
+
}
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
// Register a service worker to serve assets from local cache.
|
|
2
|
+
// This lets the app load faster on subsequent visits in production, and gives
|
|
3
|
+
// it offline capabilities. However, it also means that developers (and users)
|
|
4
|
+
// will only see deployed updates on the "N+1" visit to a page, since previously
|
|
5
|
+
// cached resources are updated in the background.
|
|
6
|
+
const isLocalhost = Boolean(window.location.hostname === 'localhost' ||
|
|
7
|
+
// [::1] is the IPv6 localhost address.
|
|
8
|
+
window.location.hostname === '[::1]' ||
|
|
9
|
+
// 127.0.0.1/8 is considered localhost for IPv4.
|
|
10
|
+
window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/));
|
|
11
|
+
export default class RegisterServiceWorker {
|
|
12
|
+
applicationServerPublicKey;
|
|
13
|
+
isOnline;
|
|
14
|
+
isSubscribed;
|
|
15
|
+
static instance;
|
|
16
|
+
_rsw = null;
|
|
17
|
+
_hook;
|
|
18
|
+
constructor(hook, applicationServerPublicKey) {
|
|
19
|
+
RegisterServiceWorker.instance = this;
|
|
20
|
+
this._hook = hook;
|
|
21
|
+
this.isOnline = navigator.onLine;
|
|
22
|
+
this.applicationServerPublicKey = applicationServerPublicKey;
|
|
23
|
+
this._hook.online(this.isOnline);
|
|
24
|
+
window.ononline = (ev) => {
|
|
25
|
+
this._hook.online(true);
|
|
26
|
+
this.isOnline = true;
|
|
27
|
+
};
|
|
28
|
+
window.onoffline = (ev) => {
|
|
29
|
+
this._hook.online(false);
|
|
30
|
+
this.isOnline = false;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
get registration() {
|
|
34
|
+
return this._rsw;
|
|
35
|
+
}
|
|
36
|
+
register(swUrl, scope) {
|
|
37
|
+
const self = this;
|
|
38
|
+
if ('serviceWorker' in navigator) {
|
|
39
|
+
this._hook.log.info('Register service worker');
|
|
40
|
+
window.addEventListener('load', () => {
|
|
41
|
+
if (isLocalhost) {
|
|
42
|
+
// This is running on localhost. Lets check if a service worker still exists or not.
|
|
43
|
+
self.checkValidServiceWorker(swUrl);
|
|
44
|
+
navigator.serviceWorker.ready
|
|
45
|
+
.then(() => {
|
|
46
|
+
this._hook.ready();
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
// Is not local host. Just register service worker
|
|
51
|
+
self.registerValidSW(swUrl, scope);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
registerValidSW(swUrl, scope) {
|
|
57
|
+
const self = this;
|
|
58
|
+
navigator.serviceWorker
|
|
59
|
+
.register(swUrl, { scope: scope })
|
|
60
|
+
.then(registration => {
|
|
61
|
+
self._rsw = registration;
|
|
62
|
+
if (navigator.serviceWorker.onmessage != null) {
|
|
63
|
+
navigator.serviceWorker.addEventListener('message', (swevent) => {
|
|
64
|
+
const reply = self.processMessage(swevent.data);
|
|
65
|
+
if (swevent.ports !== null)
|
|
66
|
+
swevent.ports[0].postMessage(reply);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
registration.onupdatefound = () => {
|
|
70
|
+
const installingWorker = registration.installing;
|
|
71
|
+
self._hook.log.info('Update found');
|
|
72
|
+
if (installingWorker !== null) {
|
|
73
|
+
installingWorker.onstatechange = () => {
|
|
74
|
+
if (installingWorker) {
|
|
75
|
+
self._hook.log.info('State changed ' + installingWorker.state);
|
|
76
|
+
if (installingWorker.state === 'installed') {
|
|
77
|
+
if (navigator.serviceWorker.controller) {
|
|
78
|
+
// At this point, the old content will have been purged and
|
|
79
|
+
// the fresh content will have been added to the cache.
|
|
80
|
+
// It's the perfect time to display a "New content is
|
|
81
|
+
// available; please refresh." message in your web app.
|
|
82
|
+
self._hook.updated();
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
// At this point, everything has been precached.
|
|
86
|
+
// It's the perfect time to display a
|
|
87
|
+
// "Content is cached for offline use." message.
|
|
88
|
+
self._hook.cached();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
self._hook.log.info('Registered at scope ' + registration.scope);
|
|
96
|
+
self._hook.registered();
|
|
97
|
+
})
|
|
98
|
+
.catch(error => {
|
|
99
|
+
self._hook.error(error);
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
processMessage(msgObj) {
|
|
103
|
+
try {
|
|
104
|
+
this._hook.log.info("Message " + JSON.stringify(msgObj));
|
|
105
|
+
if (msgObj.type === 1) {
|
|
106
|
+
this.notify(msgObj.message);
|
|
107
|
+
return "received";
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
catch (err) {
|
|
111
|
+
this._hook.log.warning("Message " + JSON.stringify(err));
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
notify(msg) {
|
|
115
|
+
if (!("Notification" in window)) {
|
|
116
|
+
alert("This browser does not support desktop notification");
|
|
117
|
+
}
|
|
118
|
+
else if (Notification.permission === "granted") {
|
|
119
|
+
// If it's okay let's create a notification
|
|
120
|
+
const notification = new Notification(msg);
|
|
121
|
+
}
|
|
122
|
+
else if (Notification.permission !== "denied") {
|
|
123
|
+
Notification.requestPermission(function (permission) {
|
|
124
|
+
// If the user accepts, let's create a notification
|
|
125
|
+
if (permission === "granted") {
|
|
126
|
+
const notification = new Notification(msg);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
checkValidServiceWorker(swUrl) {
|
|
132
|
+
// Check if the service worker can be found.
|
|
133
|
+
const self = this;
|
|
134
|
+
fetch(swUrl)
|
|
135
|
+
.then(response => {
|
|
136
|
+
// Ensure service worker exists, and that we really are getting a JS file.
|
|
137
|
+
if (response.status === 404 || response.headers.get('content-type').indexOf('javascript') === -1) {
|
|
138
|
+
// No service worker found.
|
|
139
|
+
self._hook.error(`Service worker not found at ${swUrl}`);
|
|
140
|
+
self.unregister();
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
// Service worker found. Proceed as normal.
|
|
144
|
+
this.registerValidSW(swUrl);
|
|
145
|
+
}
|
|
146
|
+
})
|
|
147
|
+
.catch(error => {
|
|
148
|
+
if (!navigator.onLine) {
|
|
149
|
+
self._hook.online(false);
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
self._hook.error(error);
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
unregister() {
|
|
157
|
+
if ('serviceWorker' in navigator) {
|
|
158
|
+
this._hook.log.info('Unregister service worker');
|
|
159
|
+
navigator.serviceWorker.ready
|
|
160
|
+
.then(registration => registration.unregister());
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
getSubscription() {
|
|
164
|
+
this._hook.log.trace('get subscription');
|
|
165
|
+
const self = this;
|
|
166
|
+
const promise = new Promise(function (resolve, reject) {
|
|
167
|
+
if (self._rsw === null) {
|
|
168
|
+
reject(new Error('No service worker registered'));
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
self.registration.pushManager.getSubscription()
|
|
172
|
+
.then(subscription => {
|
|
173
|
+
resolve(subscription);
|
|
174
|
+
self.isSubscribed = subscription !== null;
|
|
175
|
+
if (self._hook.subscribed)
|
|
176
|
+
self._hook.subscribed(self.isSubscribed);
|
|
177
|
+
})
|
|
178
|
+
.catch(error => reject(error));
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
return promise;
|
|
182
|
+
}
|
|
183
|
+
subscribeUser() {
|
|
184
|
+
this._hook.log.info('subscribe user');
|
|
185
|
+
const self = this;
|
|
186
|
+
const promise = new Promise(function (resolve, reject) {
|
|
187
|
+
if (!self.applicationServerPublicKey) {
|
|
188
|
+
reject(new Error("Application server public key missing"));
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
const applicationServerKey = RegisterServiceWorker.urlB64ToUint8Array(self.applicationServerPublicKey);
|
|
192
|
+
if (self._rsw === null) {
|
|
193
|
+
reject(new Error('No service worker registered'));
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
const options = {
|
|
197
|
+
userVisibleOnly: true,
|
|
198
|
+
applicationServerKey: applicationServerKey
|
|
199
|
+
};
|
|
200
|
+
self.registration.pushManager.subscribe(options)
|
|
201
|
+
.then(subscription => {
|
|
202
|
+
resolve(subscription);
|
|
203
|
+
self.isSubscribed = subscription !== null;
|
|
204
|
+
if (self._hook.subscribed)
|
|
205
|
+
self._hook.subscribed(self.isSubscribed);
|
|
206
|
+
})
|
|
207
|
+
.catch(err => reject(err));
|
|
208
|
+
});
|
|
209
|
+
return promise;
|
|
210
|
+
}
|
|
211
|
+
unsubscribeUser() {
|
|
212
|
+
this._hook.log.info('unsubscribe user');
|
|
213
|
+
const self = this;
|
|
214
|
+
const promise = new Promise(function (resolve, reject) {
|
|
215
|
+
if (self._rsw === null) {
|
|
216
|
+
reject(new Error('No service worker registered'));
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
self.registration.pushManager.getSubscription()
|
|
220
|
+
.then(subscription => {
|
|
221
|
+
if (subscription !== null) {
|
|
222
|
+
subscription.unsubscribe()
|
|
223
|
+
.then((res) => {
|
|
224
|
+
resolve(subscription);
|
|
225
|
+
if (res) {
|
|
226
|
+
self.isSubscribed = false;
|
|
227
|
+
if (self._hook.subscribed)
|
|
228
|
+
self._hook.subscribed(self.isSubscribed);
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
})
|
|
233
|
+
.catch(error => reject(error));
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
return promise;
|
|
237
|
+
}
|
|
238
|
+
static urlB64ToUint8Array(base64String) {
|
|
239
|
+
const padding = '='.repeat((4 - base64String.length % 4) % 4);
|
|
240
|
+
const base64 = (base64String + padding)
|
|
241
|
+
.replace(/\-/g, '+')
|
|
242
|
+
.replace(/_/g, '/');
|
|
243
|
+
const rawData = window.atob(base64);
|
|
244
|
+
const outputArray = new Uint8Array(rawData.length);
|
|
245
|
+
for (let i = 0; i < rawData.length; ++i) {
|
|
246
|
+
outputArray[i] = rawData.charCodeAt(i);
|
|
247
|
+
}
|
|
248
|
+
return outputArray;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
//# sourceMappingURL=registerserviceworker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registerserviceworker.js","sourceRoot":"","sources":["../../../src/registerserviceworker.ts"],"names":[],"mappings":"AAEA,8DAA8D;AAE9D,8EAA8E;AAC9E,8EAA8E;AAC9E,gFAAgF;AAChF,kDAAkD;AAElD,MAAM,WAAW,GAAG,OAAO,CACvB,MAAM,CAAC,QAAQ,CAAC,QAAQ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AU,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAEnD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;YACrC,WAAW,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;SAC1C;QACD,OAAO,WAAW,CAAC;IACvB,CAAC;CACJ"}
|
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@christianriedl/utils",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
|
|
6
|
+
"main": "jsdir/utils/src/utils.js",
|
|
7
|
+
"types": "jsdir/utils/src/utils.d.ts",
|
|
8
|
+
|
|
9
|
+
"files": [
|
|
10
|
+
"jsdir/utils/*"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsc",
|
|
14
|
+
"clean": "tsc --build --clean"
|
|
15
|
+
},
|
|
16
|
+
"author": "Christian Riedl",
|
|
17
|
+
"license": "ISC",
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"typescript": "^4.5.4",
|
|
20
|
+
"@types/node": "^17.0.8"
|
|
21
|
+
}
|
|
22
|
+
}
|