@powfix/core-js 0.9.26 → 0.9.27
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.
|
@@ -3,10 +3,6 @@ export declare enum TimeServiceStatus {
|
|
|
3
3
|
STOPPED = 0,
|
|
4
4
|
RUNNING = 1
|
|
5
5
|
}
|
|
6
|
-
export declare enum TimeServiceEvent {
|
|
7
|
-
SYNCED = "SYNCED",
|
|
8
|
-
SYNC_INTERVAL_CHANGED = "SYNC_INTERVAL_CHANGED"
|
|
9
|
-
}
|
|
10
6
|
export declare class TimeService {
|
|
11
7
|
private static readonly DEFAULT_SYNC_INTERVAL;
|
|
12
8
|
protected status: TimeServiceStatus;
|
|
@@ -14,8 +10,8 @@ export declare class TimeService {
|
|
|
14
10
|
private option;
|
|
15
11
|
private syncedAt?;
|
|
16
12
|
private emitter;
|
|
17
|
-
readonly on: <T extends
|
|
18
|
-
readonly off: <T extends
|
|
13
|
+
readonly on: <T extends TimeService.Event>(event: T, fn: (...args: any[]) => void, context?: any) => EventEmitter3<TimeService.Event, any>;
|
|
14
|
+
readonly off: <T extends TimeService.Event>(event: T, fn?: ((...args: any[]) => void) | undefined, context?: any, once?: boolean | undefined) => EventEmitter3<TimeService.Event, any>;
|
|
19
15
|
private readonly emit;
|
|
20
16
|
static calculateNTPResultOffset(ntpResult: TimeService.NTPResult): TimeService.Offset;
|
|
21
17
|
constructor(option: TimeService.Option);
|
|
@@ -50,6 +46,7 @@ export declare namespace TimeService {
|
|
|
50
46
|
t3: TimeStamp;
|
|
51
47
|
t4: TimeStamp;
|
|
52
48
|
}
|
|
49
|
+
type Event = 'SYNCED' | 'SYNC_INTERVAL_CHANGED';
|
|
53
50
|
interface ServerNTPResult extends Pick<NTPResult, 't2' | 't3'> {
|
|
54
51
|
}
|
|
55
52
|
type ClientTimeProvider = () => TimeStamp;
|
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.TimeService = exports.
|
|
15
|
+
exports.TimeService = exports.TimeServiceStatus = void 0;
|
|
16
16
|
const eventemitter3_1 = __importDefault(require("eventemitter3"));
|
|
17
17
|
const LOG_TAG = 'TimeService';
|
|
18
18
|
var TimeServiceStatus;
|
|
@@ -20,11 +20,6 @@ var TimeServiceStatus;
|
|
|
20
20
|
TimeServiceStatus[TimeServiceStatus["STOPPED"] = 0] = "STOPPED";
|
|
21
21
|
TimeServiceStatus[TimeServiceStatus["RUNNING"] = 1] = "RUNNING";
|
|
22
22
|
})(TimeServiceStatus || (exports.TimeServiceStatus = TimeServiceStatus = {}));
|
|
23
|
-
var TimeServiceEvent;
|
|
24
|
-
(function (TimeServiceEvent) {
|
|
25
|
-
TimeServiceEvent["SYNCED"] = "SYNCED";
|
|
26
|
-
TimeServiceEvent["SYNC_INTERVAL_CHANGED"] = "SYNC_INTERVAL_CHANGED";
|
|
27
|
-
})(TimeServiceEvent || (exports.TimeServiceEvent = TimeServiceEvent = {}));
|
|
28
23
|
class TimeService {
|
|
29
24
|
static calculateNTPResultOffset(ntpResult) {
|
|
30
25
|
const { t1, t2, t3, t4 } = ntpResult;
|
|
@@ -83,7 +78,7 @@ class TimeService {
|
|
|
83
78
|
setSyncedAt(syncedAt) {
|
|
84
79
|
this.syncedAt = syncedAt;
|
|
85
80
|
// Emit
|
|
86
|
-
this.emit(
|
|
81
|
+
this.emit('SYNCED', syncedAt);
|
|
87
82
|
return syncedAt;
|
|
88
83
|
}
|
|
89
84
|
getSyncInterval() {
|
|
@@ -100,7 +95,7 @@ class TimeService {
|
|
|
100
95
|
setSyncInterval(interval) {
|
|
101
96
|
this.option.syncInterval = interval;
|
|
102
97
|
// Emit
|
|
103
|
-
this.emit(
|
|
98
|
+
this.emit('SYNC_INTERVAL_CHANGED', interval);
|
|
104
99
|
if (this.status === TimeServiceStatus.RUNNING) {
|
|
105
100
|
if (this.syncHandler !== undefined) {
|
|
106
101
|
this.stopSync();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powfix/core-js",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.27",
|
|
4
4
|
"description": "core package",
|
|
5
5
|
"author": "Kwon Kyung-Min <powfix@gmail.com>",
|
|
6
6
|
"private": false,
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"browser": "dist/browser.js",
|
|
20
20
|
"scripts": {
|
|
21
21
|
"clean": "rm -rf dist",
|
|
22
|
-
"build": "yarn clean
|
|
22
|
+
"build": "yarn clean; tsc -p ."
|
|
23
23
|
},
|
|
24
24
|
"files": [
|
|
25
25
|
"dist"
|