@meowpanel/api 0.1.0-alpha.11 → 1.0.0-beta.2
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/LICENSE +1 -1
- package/README.md +40 -0
- package/esm/mod.d.ts +87 -1
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +85 -1
- package/esm/src/client.d.ts +248 -0
- package/esm/src/client.d.ts.map +1 -0
- package/esm/src/client.js +235 -0
- package/esm/src/emitter.d.ts +53 -0
- package/esm/src/emitter.d.ts.map +1 -0
- package/esm/src/emitter.js +55 -0
- package/esm/src/errors.d.ts +42 -0
- package/esm/src/errors.d.ts.map +1 -0
- package/esm/src/errors.js +45 -0
- package/esm/src/http.d.ts +157 -0
- package/esm/src/http.d.ts.map +1 -0
- package/esm/src/http.js +317 -0
- package/esm/src/namespace.d.ts +59 -0
- package/esm/src/namespace.d.ts.map +1 -0
- package/esm/src/namespace.js +79 -0
- package/esm/src/reactive.d.ts +29 -0
- package/esm/src/reactive.d.ts.map +1 -0
- package/esm/src/reactive.js +35 -0
- package/esm/src/resources/account.d.ts +125 -0
- package/esm/src/resources/account.d.ts.map +1 -0
- package/esm/src/resources/account.js +151 -0
- package/esm/src/resources/api-keys.d.ts +116 -0
- package/esm/src/resources/api-keys.d.ts.map +1 -0
- package/esm/src/resources/api-keys.js +105 -0
- package/esm/src/resources/auth.d.ts +57 -0
- package/esm/src/resources/auth.d.ts.map +1 -0
- package/esm/src/resources/auth.js +39 -0
- package/esm/src/resources/eggs.d.ts +238 -0
- package/esm/src/resources/eggs.d.ts.map +1 -0
- package/esm/src/resources/eggs.js +187 -0
- package/esm/src/resources/hosts.d.ts +62 -0
- package/esm/src/resources/hosts.d.ts.map +1 -0
- package/esm/src/resources/hosts.js +62 -0
- package/esm/src/resources/members.d.ts +138 -0
- package/esm/src/resources/members.d.ts.map +1 -0
- package/esm/src/resources/members.js +122 -0
- package/esm/src/resources/nodes.d.ts +397 -0
- package/esm/src/resources/nodes.d.ts.map +1 -0
- package/esm/src/resources/nodes.js +352 -0
- package/esm/src/resources/server-groups.d.ts +150 -0
- package/esm/src/resources/server-groups.d.ts.map +1 -0
- package/esm/src/resources/server-groups.js +111 -0
- package/esm/src/resources/servers/activity.d.ts +120 -0
- package/esm/src/resources/servers/activity.d.ts.map +1 -0
- package/esm/src/resources/servers/activity.js +163 -0
- package/esm/src/resources/servers/allocations.d.ts +125 -0
- package/esm/src/resources/servers/allocations.d.ts.map +1 -0
- package/esm/src/resources/servers/allocations.js +137 -0
- package/esm/src/resources/servers/connection.d.ts +108 -0
- package/esm/src/resources/servers/connection.d.ts.map +1 -0
- package/esm/src/resources/servers/connection.js +169 -0
- package/esm/src/resources/servers/files.d.ts +164 -0
- package/esm/src/resources/servers/files.d.ts.map +1 -0
- package/esm/src/resources/servers/files.js +281 -0
- package/esm/src/resources/servers/index.d.ts +126 -0
- package/esm/src/resources/servers/index.d.ts.map +1 -0
- package/esm/src/resources/servers/index.js +135 -0
- package/esm/src/resources/servers/profiles.d.ts +138 -0
- package/esm/src/resources/servers/profiles.d.ts.map +1 -0
- package/esm/src/resources/servers/profiles.js +177 -0
- package/esm/src/resources/servers/server.d.ts +136 -0
- package/esm/src/resources/servers/server.d.ts.map +1 -0
- package/esm/src/resources/servers/server.js +202 -0
- package/esm/src/resources/servers/sftp.d.ts +147 -0
- package/esm/src/resources/servers/sftp.d.ts.map +1 -0
- package/esm/src/resources/servers/sftp.js +153 -0
- package/esm/src/resources/servers/types.d.ts +199 -0
- package/esm/src/resources/servers/types.d.ts.map +1 -0
- package/esm/src/resources/servers/types.js +1 -0
- package/esm/src/sse.d.ts +53 -0
- package/esm/src/sse.d.ts.map +1 -0
- package/esm/src/sse.js +133 -0
- package/esm/src/types.d.ts +126 -0
- package/esm/src/types.d.ts.map +1 -0
- package/esm/src/types.js +21 -0
- package/package.json +4 -92
- package/script/mod.d.ts +87 -1
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +132 -3
- package/script/src/client.d.ts +248 -0
- package/script/src/client.d.ts.map +1 -0
- package/script/src/client.js +239 -0
- package/script/src/emitter.d.ts +53 -0
- package/script/src/emitter.d.ts.map +1 -0
- package/script/src/emitter.js +59 -0
- package/script/src/errors.d.ts +42 -0
- package/script/src/errors.d.ts.map +1 -0
- package/script/src/errors.js +49 -0
- package/script/src/http.d.ts +157 -0
- package/script/src/http.d.ts.map +1 -0
- package/script/src/http.js +321 -0
- package/script/src/namespace.d.ts +59 -0
- package/script/src/namespace.d.ts.map +1 -0
- package/script/src/namespace.js +83 -0
- package/script/src/reactive.d.ts +29 -0
- package/script/src/reactive.d.ts.map +1 -0
- package/script/src/reactive.js +39 -0
- package/script/src/resources/account.d.ts +125 -0
- package/script/src/resources/account.d.ts.map +1 -0
- package/script/src/resources/account.js +158 -0
- package/script/src/resources/api-keys.d.ts +116 -0
- package/script/src/resources/api-keys.d.ts.map +1 -0
- package/script/src/resources/api-keys.js +110 -0
- package/script/src/resources/auth.d.ts +57 -0
- package/script/src/resources/auth.d.ts.map +1 -0
- package/script/src/resources/auth.js +43 -0
- package/script/src/resources/eggs.d.ts +238 -0
- package/script/src/resources/eggs.d.ts.map +1 -0
- package/script/src/resources/eggs.js +193 -0
- package/script/src/resources/hosts.d.ts +62 -0
- package/script/src/resources/hosts.d.ts.map +1 -0
- package/script/src/resources/hosts.js +67 -0
- package/script/src/resources/members.d.ts +138 -0
- package/script/src/resources/members.d.ts.map +1 -0
- package/script/src/resources/members.js +127 -0
- package/script/src/resources/nodes.d.ts +397 -0
- package/script/src/resources/nodes.d.ts.map +1 -0
- package/script/src/resources/nodes.js +362 -0
- package/script/src/resources/server-groups.d.ts +150 -0
- package/script/src/resources/server-groups.d.ts.map +1 -0
- package/script/src/resources/server-groups.js +116 -0
- package/script/src/resources/servers/activity.d.ts +120 -0
- package/script/src/resources/servers/activity.d.ts.map +1 -0
- package/script/src/resources/servers/activity.js +170 -0
- package/script/src/resources/servers/allocations.d.ts +125 -0
- package/script/src/resources/servers/allocations.d.ts.map +1 -0
- package/script/src/resources/servers/allocations.js +142 -0
- package/script/src/resources/servers/connection.d.ts +108 -0
- package/script/src/resources/servers/connection.d.ts.map +1 -0
- package/script/src/resources/servers/connection.js +173 -0
- package/script/src/resources/servers/files.d.ts +164 -0
- package/script/src/resources/servers/files.d.ts.map +1 -0
- package/script/src/resources/servers/files.js +286 -0
- package/script/src/resources/servers/index.d.ts +126 -0
- package/script/src/resources/servers/index.d.ts.map +1 -0
- package/script/src/resources/servers/index.js +139 -0
- package/script/src/resources/servers/profiles.d.ts +138 -0
- package/script/src/resources/servers/profiles.d.ts.map +1 -0
- package/script/src/resources/servers/profiles.js +182 -0
- package/script/src/resources/servers/server.d.ts +136 -0
- package/script/src/resources/servers/server.d.ts.map +1 -0
- package/script/src/resources/servers/server.js +206 -0
- package/script/src/resources/servers/sftp.d.ts +147 -0
- package/script/src/resources/servers/sftp.d.ts.map +1 -0
- package/script/src/resources/servers/sftp.js +158 -0
- package/script/src/resources/servers/types.d.ts +199 -0
- package/script/src/resources/servers/types.d.ts.map +1 -0
- package/script/src/resources/servers/types.js +2 -0
- package/script/src/sse.d.ts +53 -0
- package/script/src/sse.d.ts.map +1 -0
- package/script/src/sse.js +137 -0
- package/script/src/types.d.ts +126 -0
- package/script/src/types.d.ts.map +1 -0
- package/script/src/types.js +25 -0
- package/esm/api.d.ts +0 -76
- package/esm/api.d.ts.map +0 -1
- package/esm/api.js +0 -187
- package/esm/components/auth.d.ts +0 -15
- package/esm/components/auth.d.ts.map +0 -1
- package/esm/components/auth.js +0 -13
- package/esm/components/connection/abstract.d.ts +0 -23
- package/esm/components/connection/abstract.d.ts.map +0 -1
- package/esm/components/connection/abstract.js +0 -43
- package/esm/components/connection/sse.d.ts +0 -20
- package/esm/components/connection/sse.d.ts.map +0 -1
- package/esm/components/connection/sse.js +0 -65
- package/esm/components/egg/egg.d.ts +0 -32
- package/esm/components/egg/egg.d.ts.map +0 -1
- package/esm/components/egg/egg.js +0 -70
- package/esm/components/group.d.ts +0 -14
- package/esm/components/group.d.ts.map +0 -1
- package/esm/components/group.js +0 -33
- package/esm/components/member_2.d.ts +0 -69
- package/esm/components/member_2.d.ts.map +0 -1
- package/esm/components/member_2.js +0 -140
- package/esm/components/node.d.ts +0 -78
- package/esm/components/node.d.ts.map +0 -1
- package/esm/components/node.js +0 -342
- package/esm/components/server/activity.d.ts +0 -45
- package/esm/components/server/activity.d.ts.map +0 -1
- package/esm/components/server/activity.js +0 -158
- package/esm/components/server/allocations.d.ts +0 -45
- package/esm/components/server/allocations.d.ts.map +0 -1
- package/esm/components/server/allocations.js +0 -146
- package/esm/components/server/files.d.ts +0 -50
- package/esm/components/server/files.d.ts.map +0 -1
- package/esm/components/server/files.js +0 -90
- package/esm/components/server/power.d.ts +0 -21
- package/esm/components/server/power.d.ts.map +0 -1
- package/esm/components/server/power.js +0 -43
- package/esm/components/server/profiles.d.ts +0 -63
- package/esm/components/server/profiles.d.ts.map +0 -1
- package/esm/components/server/profiles.js +0 -163
- package/esm/components/server/server.d.ts +0 -141
- package/esm/components/server/server.d.ts.map +0 -1
- package/esm/components/server/server.js +0 -358
- package/esm/components/server/sftp.d.ts +0 -31
- package/esm/components/server/sftp.d.ts.map +0 -1
- package/esm/components/server/sftp.js +0 -84
- package/esm/components/server/startup.d.ts +0 -17
- package/esm/components/server/startup.d.ts.map +0 -1
- package/esm/components/server/startup.js +0 -21
- package/esm/components/server/stats.d.ts +0 -19
- package/esm/components/server/stats.d.ts.map +0 -1
- package/esm/components/server/stats.js +0 -46
- package/esm/utils/cache.d.ts +0 -20
- package/esm/utils/cache.d.ts.map +0 -1
- package/esm/utils/cache.js +0 -66
- package/esm/utils/event.d.ts +0 -38
- package/esm/utils/event.d.ts.map +0 -1
- package/esm/utils/event.js +0 -71
- package/esm/utils/object.d.ts +0 -58
- package/esm/utils/object.d.ts.map +0 -1
- package/esm/utils/object.js +0 -86
- package/esm/utils/subscribe.d.ts +0 -37
- package/esm/utils/subscribe.d.ts.map +0 -1
- package/esm/utils/subscribe.js +0 -29
- package/esm/utils/timer.d.ts +0 -13
- package/esm/utils/timer.d.ts.map +0 -1
- package/esm/utils/timer.js +0 -32
- package/esm/utils/units.d.ts +0 -18
- package/esm/utils/units.d.ts.map +0 -1
- package/esm/utils/units.js +0 -82
- package/script/api.d.ts +0 -76
- package/script/api.d.ts.map +0 -1
- package/script/api.js +0 -192
- package/script/components/auth.d.ts +0 -15
- package/script/components/auth.d.ts.map +0 -1
- package/script/components/auth.js +0 -17
- package/script/components/connection/abstract.d.ts +0 -23
- package/script/components/connection/abstract.d.ts.map +0 -1
- package/script/components/connection/abstract.js +0 -47
- package/script/components/connection/sse.d.ts +0 -20
- package/script/components/connection/sse.d.ts.map +0 -1
- package/script/components/connection/sse.js +0 -69
- package/script/components/egg/egg.d.ts +0 -32
- package/script/components/egg/egg.d.ts.map +0 -1
- package/script/components/egg/egg.js +0 -74
- package/script/components/group.d.ts +0 -14
- package/script/components/group.d.ts.map +0 -1
- package/script/components/group.js +0 -37
- package/script/components/member_2.d.ts +0 -69
- package/script/components/member_2.d.ts.map +0 -1
- package/script/components/member_2.js +0 -146
- package/script/components/node.d.ts +0 -78
- package/script/components/node.d.ts.map +0 -1
- package/script/components/node.js +0 -349
- package/script/components/server/activity.d.ts +0 -45
- package/script/components/server/activity.d.ts.map +0 -1
- package/script/components/server/activity.js +0 -164
- package/script/components/server/allocations.d.ts +0 -45
- package/script/components/server/allocations.d.ts.map +0 -1
- package/script/components/server/allocations.js +0 -152
- package/script/components/server/files.d.ts +0 -50
- package/script/components/server/files.d.ts.map +0 -1
- package/script/components/server/files.js +0 -94
- package/script/components/server/power.d.ts +0 -21
- package/script/components/server/power.d.ts.map +0 -1
- package/script/components/server/power.js +0 -47
- package/script/components/server/profiles.d.ts +0 -63
- package/script/components/server/profiles.d.ts.map +0 -1
- package/script/components/server/profiles.js +0 -168
- package/script/components/server/server.d.ts +0 -141
- package/script/components/server/server.d.ts.map +0 -1
- package/script/components/server/server.js +0 -362
- package/script/components/server/sftp.d.ts +0 -31
- package/script/components/server/sftp.d.ts.map +0 -1
- package/script/components/server/sftp.js +0 -88
- package/script/components/server/startup.d.ts +0 -17
- package/script/components/server/startup.d.ts.map +0 -1
- package/script/components/server/startup.js +0 -25
- package/script/components/server/stats.d.ts +0 -19
- package/script/components/server/stats.d.ts.map +0 -1
- package/script/components/server/stats.js +0 -50
- package/script/utils/cache.d.ts +0 -20
- package/script/utils/cache.d.ts.map +0 -1
- package/script/utils/cache.js +0 -70
- package/script/utils/event.d.ts +0 -38
- package/script/utils/event.d.ts.map +0 -1
- package/script/utils/event.js +0 -75
- package/script/utils/object.d.ts +0 -58
- package/script/utils/object.d.ts.map +0 -1
- package/script/utils/object.js +0 -90
- package/script/utils/subscribe.d.ts +0 -37
- package/script/utils/subscribe.d.ts.map +0 -1
- package/script/utils/subscribe.js +0 -32
- package/script/utils/timer.d.ts +0 -13
- package/script/utils/timer.d.ts.map +0 -1
- package/script/utils/timer.js +0 -36
- package/script/utils/units.d.ts +0 -18
- package/script/utils/units.d.ts.map +0 -1
- package/script/utils/units.js +0 -86
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StartupParameters = void 0;
|
|
4
|
-
class StartupParameters {
|
|
5
|
-
constructor(data) {
|
|
6
|
-
Object.defineProperty(this, "command", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
configurable: true,
|
|
9
|
-
writable: true,
|
|
10
|
-
value: void 0
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(this, "variables", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
configurable: true,
|
|
15
|
-
writable: true,
|
|
16
|
-
value: void 0
|
|
17
|
-
});
|
|
18
|
-
this.command = data.command;
|
|
19
|
-
this.variables = {};
|
|
20
|
-
for (const [key, value] of Object.entries(data.variables)) {
|
|
21
|
-
this.variables[key] = { ...value, key };
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
exports.StartupParameters = StartupParameters;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Timer } from '../../utils/timer.js';
|
|
2
|
-
import { ByteUnit } from '../../utils/units.js';
|
|
3
|
-
import { PowerStateEvent } from './power.js';
|
|
4
|
-
import type { ServerResponse } from './server_2';
|
|
5
|
-
import type { Server } from './server.js';
|
|
6
|
-
export declare class ServerStatsEvent {
|
|
7
|
-
protected readonly server: Server;
|
|
8
|
-
private stats?;
|
|
9
|
-
constructor(server: Server, stats?: ServerResponse['status']);
|
|
10
|
-
readonly limits: {};
|
|
11
|
-
get powerState(): PowerStateEvent;
|
|
12
|
-
get uptime(): Timer;
|
|
13
|
-
get cpuUsage(): number;
|
|
14
|
-
get memoryUsage(): ByteUnit;
|
|
15
|
-
get storageUsage(): ByteUnit;
|
|
16
|
-
get networkRx(): ByteUnit;
|
|
17
|
-
get networkTx(): ByteUnit;
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=stats.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stats.d.ts","sourceRoot":"","sources":["../../../src/components/server/stats.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,qBAAa,gBAAgB;IAE3B,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM;IACjC,OAAO,CAAC,KAAK,CAAC;gBADK,MAAM,EAAE,MAAM,EACzB,KAAK,CAAC,EAAE,cAAc,CAAC,QAAQ,CAAC;IAGzC,SAAgB,MAAM,KAAM;IAE5B,IAAW,UAAU,IAAI,eAAe,CAEvC;IAED,IAAW,MAAM,IAAI,KAAK,CAEzB;IAED,IAAW,QAAQ,IAAI,MAAM,CAE5B;IAED,IAAW,WAAW,IAAI,QAAQ,CAEjC;IAED,IAAW,YAAY,IAAI,QAAQ,CAElC;IAED,IAAW,SAAS,IAAI,QAAQ,CAE/B;IAED,IAAW,SAAS,IAAI,QAAQ,CAE/B;CACD"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ServerStatsEvent = void 0;
|
|
4
|
-
const timer_js_1 = require("../../utils/timer.js");
|
|
5
|
-
const units_js_1 = require("../../utils/units.js");
|
|
6
|
-
const power_js_1 = require("./power.js");
|
|
7
|
-
class ServerStatsEvent {
|
|
8
|
-
constructor(server, stats) {
|
|
9
|
-
Object.defineProperty(this, "server", {
|
|
10
|
-
enumerable: true,
|
|
11
|
-
configurable: true,
|
|
12
|
-
writable: true,
|
|
13
|
-
value: server
|
|
14
|
-
});
|
|
15
|
-
Object.defineProperty(this, "stats", {
|
|
16
|
-
enumerable: true,
|
|
17
|
-
configurable: true,
|
|
18
|
-
writable: true,
|
|
19
|
-
value: stats
|
|
20
|
-
});
|
|
21
|
-
Object.defineProperty(this, "limits", {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
configurable: true,
|
|
24
|
-
writable: true,
|
|
25
|
-
value: {}
|
|
26
|
-
}); // TODO: use the server limit class
|
|
27
|
-
}
|
|
28
|
-
get powerState() {
|
|
29
|
-
return new power_js_1.PowerStateEvent(this.stats?.state || 'error');
|
|
30
|
-
}
|
|
31
|
-
get uptime() {
|
|
32
|
-
return new timer_js_1.Timer(this.stats?.utilization.uptime ?? 0);
|
|
33
|
-
}
|
|
34
|
-
get cpuUsage() {
|
|
35
|
-
return this.stats?.utilization.cpu_absolute ?? 0;
|
|
36
|
-
}
|
|
37
|
-
get memoryUsage() {
|
|
38
|
-
return this.stats ? new units_js_1.ByteUnit(this.stats.utilization.memory_bytes, 'b') : units_js_1.ByteUnit.ZERO;
|
|
39
|
-
}
|
|
40
|
-
get storageUsage() {
|
|
41
|
-
return this.stats ? new units_js_1.ByteUnit(this.stats.utilization.disk_bytes, 'b') : units_js_1.ByteUnit.ZERO;
|
|
42
|
-
}
|
|
43
|
-
get networkRx() {
|
|
44
|
-
return this.stats ? new units_js_1.ByteUnit(this.stats.utilization.network.rx_bytes, 'b') : units_js_1.ByteUnit.ZERO;
|
|
45
|
-
}
|
|
46
|
-
get networkTx() {
|
|
47
|
-
return this.stats ? new units_js_1.ByteUnit(this.stats.utilization.network.tx_bytes, 'b') : units_js_1.ByteUnit.ZERO;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
exports.ServerStatsEvent = ServerStatsEvent;
|
package/script/utils/cache.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Simple cache wrapper that remembers the content of a function call.
|
|
3
|
-
*/
|
|
4
|
-
export declare class CachedRelation<T> {
|
|
5
|
-
private readonly _get;
|
|
6
|
-
protected cacheId: string | undefined;
|
|
7
|
-
protected cache: T | undefined;
|
|
8
|
-
protected fetchTime: number | undefined;
|
|
9
|
-
protected readonly lifetimeMs: number;
|
|
10
|
-
protected getCache(): T | undefined;
|
|
11
|
-
get(): Promise<T>;
|
|
12
|
-
clear(): void;
|
|
13
|
-
setCache(data: T): void;
|
|
14
|
-
constructor(_get: () => Promise<T> | T,
|
|
15
|
-
/**
|
|
16
|
-
* Time in seconds that the data is valid for before calling the {@link get()} function again.
|
|
17
|
-
*/
|
|
18
|
-
lifetimeSeconds?: number);
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=cache.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/utils/cache.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,cAAc,CAAC,CAAC;IAmC3B,OAAO,CAAC,QAAQ,CAAC,IAAI;IAlCtB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,SAAS,CAAC,KAAK,EAAE,CAAC,GAAG,SAAS,CAAC;IAC/B,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAEtC,SAAS,CAAC,QAAQ,IAAI,CAAC,GAAG,SAAS;IAQtB,GAAG,IAAI,OAAO,CAAC,CAAC,CAAC;IASvB,KAAK;IAKL,QAAQ,CAAC,IAAI,EAAE,CAAC;gBAOL,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;IAC3C;;OAEG;IACH,eAAe,GAAE,MAAgB;CAIlC"}
|
package/script/utils/cache.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CachedRelation = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Simple cache wrapper that remembers the content of a function call.
|
|
6
|
-
*/
|
|
7
|
-
class CachedRelation {
|
|
8
|
-
getCache() {
|
|
9
|
-
if (this.fetchTime && Date.now() - this.fetchTime < this.lifetimeMs) {
|
|
10
|
-
this.clear();
|
|
11
|
-
}
|
|
12
|
-
return this.cache;
|
|
13
|
-
}
|
|
14
|
-
async get() {
|
|
15
|
-
const cache = this.getCache();
|
|
16
|
-
if (cache)
|
|
17
|
-
return cache;
|
|
18
|
-
const data = await this._get();
|
|
19
|
-
this.cache = data;
|
|
20
|
-
return data;
|
|
21
|
-
}
|
|
22
|
-
clear() {
|
|
23
|
-
this.cache = undefined;
|
|
24
|
-
this.fetchTime = undefined;
|
|
25
|
-
}
|
|
26
|
-
setCache(data) {
|
|
27
|
-
if (!data)
|
|
28
|
-
return;
|
|
29
|
-
this.cache = data;
|
|
30
|
-
this.fetchTime = Date.now();
|
|
31
|
-
}
|
|
32
|
-
constructor(_get,
|
|
33
|
-
/**
|
|
34
|
-
* Time in seconds that the data is valid for before calling the {@link get()} function again.
|
|
35
|
-
*/
|
|
36
|
-
lifetimeSeconds = 30 * 60) {
|
|
37
|
-
Object.defineProperty(this, "_get", {
|
|
38
|
-
enumerable: true,
|
|
39
|
-
configurable: true,
|
|
40
|
-
writable: true,
|
|
41
|
-
value: _get
|
|
42
|
-
});
|
|
43
|
-
Object.defineProperty(this, "cacheId", {
|
|
44
|
-
enumerable: true,
|
|
45
|
-
configurable: true,
|
|
46
|
-
writable: true,
|
|
47
|
-
value: void 0
|
|
48
|
-
});
|
|
49
|
-
Object.defineProperty(this, "cache", {
|
|
50
|
-
enumerable: true,
|
|
51
|
-
configurable: true,
|
|
52
|
-
writable: true,
|
|
53
|
-
value: void 0
|
|
54
|
-
});
|
|
55
|
-
Object.defineProperty(this, "fetchTime", {
|
|
56
|
-
enumerable: true,
|
|
57
|
-
configurable: true,
|
|
58
|
-
writable: true,
|
|
59
|
-
value: void 0
|
|
60
|
-
});
|
|
61
|
-
Object.defineProperty(this, "lifetimeMs", {
|
|
62
|
-
enumerable: true,
|
|
63
|
-
configurable: true,
|
|
64
|
-
writable: true,
|
|
65
|
-
value: void 0
|
|
66
|
-
});
|
|
67
|
-
this.lifetimeMs = lifetimeSeconds * 1000;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
exports.CachedRelation = CachedRelation;
|
package/script/utils/event.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
export interface EventFunction<T extends object, K extends keyof T> {
|
|
2
|
-
(value: T[K]): unknown;
|
|
3
|
-
}
|
|
4
|
-
export interface EventManagerListener<T extends object> {
|
|
5
|
-
/**
|
|
6
|
-
* Add an event listener to a specific event.
|
|
7
|
-
* When the event is triggered, the listener is called with the value of the event.
|
|
8
|
-
*
|
|
9
|
-
* @returns a unique id that can be used to remove the listener.
|
|
10
|
-
*/
|
|
11
|
-
on<K extends keyof T>(event: K, func: EventFunction<T, K>): number;
|
|
12
|
-
/**
|
|
13
|
-
* Remove an event listener from a specific event.
|
|
14
|
-
*
|
|
15
|
-
* @param func The listener to remove (must be the same function reference) or the id returned from {@link on}.
|
|
16
|
-
* @returns true if the listener was removed
|
|
17
|
-
*/
|
|
18
|
-
off<K extends keyof T>(event: K | number, func?: EventFunction<T, K> | number): boolean;
|
|
19
|
-
}
|
|
20
|
-
export declare class EventManager<T extends object> implements EventManagerListener<T> {
|
|
21
|
-
private static idCounter;
|
|
22
|
-
constructor();
|
|
23
|
-
protected get nextId(): number;
|
|
24
|
-
private readonly eventListeners;
|
|
25
|
-
on<K extends keyof T>(event: K, func: EventFunction<T, K>): number;
|
|
26
|
-
off<K extends keyof T>(event: K | number, func?: EventFunction<T, K> | number): boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Dispatch an event to all listeners.
|
|
29
|
-
*/
|
|
30
|
-
dispatch<K extends keyof T>(event: K, value: T[K]): void;
|
|
31
|
-
/**
|
|
32
|
-
* Assign all event listeners to a function.
|
|
33
|
-
* Useful for assigning to event listener handlers.
|
|
34
|
-
*/
|
|
35
|
-
assignAllEvents(applyFunc: <K extends keyof T>(event: K, id: number, func: (value: T[K]) => unknown) => void): void;
|
|
36
|
-
removeAll(): void;
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=event.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../src/utils/event.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,CAAC;IACjE,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,oBAAoB,CAAC,CAAC,SAAS,MAAM;IACrD;;;;;OAKG;IACH,EAAE,CAAC,CAAC,SAAS,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC;IACnE;;;;;OAKG;IACH,GAAG,CAAC,CAAC,SAAS,MAAM,CAAC,EACpB,KAAK,EAAE,CAAC,GAAG,MAAM,EACjB,IAAI,CAAC,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,GACjC,OAAO,CAAC;CACX;AAED,qBAAa,YAAY,CAAC,CAAC,SAAS,MAAM,CAAE,YAAW,oBAAoB,CAAC,CAAC,CAAC;IAC7E,OAAO,CAAC,MAAM,CAAC,SAAS,CAAK;;IAI7B,SAAS,KAAK,MAAM,IAAI,MAAM,CAE7B;IAED,OAAO,CAAC,QAAQ,CAAC,cAAc,CAG3B;IAEG,EAAE,CAAC,CAAC,SAAS,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM;IAUlE,GAAG,CAAC,CAAC,SAAS,MAAM,CAAC,EAC3B,KAAK,EAAE,CAAC,GAAG,MAAM,EACjB,IAAI,CAAC,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,GACjC,OAAO;IA4BV;;OAEG;IACI,QAAQ,CAAC,CAAC,SAAS,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;IAIxD;;;OAGG;IACI,eAAe,CACrB,SAAS,EAAE,CAAC,CAAC,SAAS,MAAM,CAAC,EAC5B,KAAK,EAAE,CAAC,EACR,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,OAAO,KAC1B,IAAI;IASH,SAAS;CAGhB"}
|
package/script/utils/event.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EventManager = void 0;
|
|
4
|
-
class EventManager {
|
|
5
|
-
constructor() {
|
|
6
|
-
Object.defineProperty(this, "eventListeners", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
configurable: true,
|
|
9
|
-
writable: true,
|
|
10
|
-
value: new Map()
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
get nextId() {
|
|
14
|
-
return ++EventManager.idCounter;
|
|
15
|
-
}
|
|
16
|
-
on(event, func) {
|
|
17
|
-
if (!this.eventListeners.has(event)) {
|
|
18
|
-
this.eventListeners.set(event, new Map());
|
|
19
|
-
}
|
|
20
|
-
const id = this.nextId;
|
|
21
|
-
this.eventListeners.get(event).set(id, func);
|
|
22
|
-
return id;
|
|
23
|
-
}
|
|
24
|
-
off(event, func) {
|
|
25
|
-
if (typeof event === 'number') {
|
|
26
|
-
for (const value of this.eventListeners.values()) {
|
|
27
|
-
const deleted = value.delete(event);
|
|
28
|
-
if (deleted)
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
if (!this.eventListeners.has(event))
|
|
34
|
-
return false;
|
|
35
|
-
const listeners = this.eventListeners.get(event);
|
|
36
|
-
if (typeof func === 'number') {
|
|
37
|
-
listeners.delete(func);
|
|
38
|
-
return true;
|
|
39
|
-
}
|
|
40
|
-
for (const [id, listener] of listeners) {
|
|
41
|
-
if (listener === func) {
|
|
42
|
-
listeners.delete(id);
|
|
43
|
-
return true;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Dispatch an event to all listeners.
|
|
50
|
-
*/
|
|
51
|
-
dispatch(event, value) {
|
|
52
|
-
this.eventListeners.get(event)?.forEach((func) => func(value));
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Assign all event listeners to a function.
|
|
56
|
-
* Useful for assigning to event listener handlers.
|
|
57
|
-
*/
|
|
58
|
-
assignAllEvents(applyFunc) {
|
|
59
|
-
this.eventListeners.forEach((funcs, event) => {
|
|
60
|
-
funcs.forEach((func, id) => {
|
|
61
|
-
applyFunc(event, id, func);
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
removeAll() {
|
|
66
|
-
this.eventListeners.clear();
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
exports.EventManager = EventManager;
|
|
70
|
-
Object.defineProperty(EventManager, "idCounter", {
|
|
71
|
-
enumerable: true,
|
|
72
|
-
configurable: true,
|
|
73
|
-
writable: true,
|
|
74
|
-
value: 0
|
|
75
|
-
});
|
package/script/utils/object.d.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import type { MeowPanelApi } from '../api.js';
|
|
2
|
-
import type { Extended } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* Base class for objects that can be updated with new data from the API.
|
|
5
|
-
*
|
|
6
|
-
* @param data The initial response data for the object
|
|
7
|
-
* @param endpoint The endpoint to the linked object that can be used to fetch the updated data.
|
|
8
|
-
*/
|
|
9
|
-
export declare abstract class UpdatableObject<Response extends object, AdjustedResponse extends object, IncludeParam extends string, ModifiedResponse = Extended<Response, AdjustedResponse>> {
|
|
10
|
-
protected readonly api: MeowPanelApi;
|
|
11
|
-
protected readonly endpoint: `/${string}`;
|
|
12
|
-
constructor(api: MeowPanelApi, data: Response, endpoint: `/${string}`);
|
|
13
|
-
protected readonly response: ModifiedResponse;
|
|
14
|
-
/**
|
|
15
|
-
* Updates the {@link response} object with new properties provided.
|
|
16
|
-
* It doesn't automatically update the {@link response} object.
|
|
17
|
-
*
|
|
18
|
-
* Assign here any additiona properties to update that should match the {@link ModifiedResponse} type parameter.
|
|
19
|
-
*
|
|
20
|
-
* @param data The new properties
|
|
21
|
-
* @returns The updated object
|
|
22
|
-
*/
|
|
23
|
-
protected updateSelf(data: Response): ModifiedResponse;
|
|
24
|
-
/**
|
|
25
|
-
* Creates an {@link AdjustedResponse} object from the received {@link Response} from the API.
|
|
26
|
-
* This is used within the {@link updateSelf} function to apply the additional properties when creating
|
|
27
|
-
* or updating new API data to the {@link response} object.
|
|
28
|
-
*
|
|
29
|
-
* Make use of `oldData?.[key]` to pass old data if it exists, use {@link _CachedRelation CachedRelation} class for partial properties.
|
|
30
|
-
*
|
|
31
|
-
* @param oldData The previous {@link response} object. Can be `undefined` if the object is new.
|
|
32
|
-
* @param newData The {@link Response response} of the API
|
|
33
|
-
* @returns The {@link AdjustedResponse} object to apply the {@link response} object to.
|
|
34
|
-
*/
|
|
35
|
-
protected abstract applyResponse(oldData: ModifiedResponse | undefined, newData: Response): AdjustedResponse;
|
|
36
|
-
/**
|
|
37
|
-
* Fetches new data from the API and updates the {@link response} object.
|
|
38
|
-
* Only updates new properties fetched.
|
|
39
|
-
*
|
|
40
|
-
* Also updates the {@link response} object with new data wrapping to {@link updateSelf}.
|
|
41
|
-
*
|
|
42
|
-
* @param include A list of properties to include in the response
|
|
43
|
-
*/
|
|
44
|
-
protected fetchSelf(include: IncludeParam[]): Promise<Response>;
|
|
45
|
-
/**
|
|
46
|
-
* Fetches new data from the API and updates the object with new data.
|
|
47
|
-
* Useful to fetch and cache multiple API calls into a single call.
|
|
48
|
-
*
|
|
49
|
-
* @param include A list of properties to include in the response
|
|
50
|
-
*/
|
|
51
|
-
fetch(include: IncludeParam[]): Promise<void>;
|
|
52
|
-
/**
|
|
53
|
-
* Send a PATCH request to the server with the given body
|
|
54
|
-
* @returns The new server response
|
|
55
|
-
*/
|
|
56
|
-
protected callPatch(body: Record<string, unknown>): Promise<Response>;
|
|
57
|
-
}
|
|
58
|
-
//# sourceMappingURL=object.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"object.d.ts","sourceRoot":"","sources":["../../src/utils/object.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAE9C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC;;;;;GAKG;AACH,8BAAsB,eAAe,CACpC,QAAQ,SAAS,MAAM,EACvB,gBAAgB,SAAS,MAAM,EAC/B,YAAY,SAAS,MAAM,EAC3B,gBAAgB,GAAG,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IAGtD,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,YAAY;IAEpC,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,IAAI,MAAM,EAAE;gBAFtB,GAAG,EAAE,YAAY,EACpC,IAAI,EAAE,QAAQ,EACK,QAAQ,EAAE,IAAI,MAAM,EAAE;IAK1C,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IAE9C;;;;;;;;OAQG;IACH,SAAS,CAAC,UAAU,CAAC,IAAI,EAAE,QAAQ,GAAG,gBAAgB;IAoBtD;;;;;;;;;;OAUG;IACH,SAAS,CAAC,QAAQ,CAAC,aAAa,CAC/B,OAAO,EAAE,gBAAgB,GAAG,SAAS,EACrC,OAAO,EAAE,QAAQ,GACf,gBAAgB;IAEnB;;;;;;;OAOG;cACa,SAAS,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,QAAQ,CAAC;IAcrE;;;;;OAKG;IACU,KAAK,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAI1D;;;OAGG;cACa,SAAS,CACxB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC3B,OAAO,CAAC,QAAQ,CAAC;CAUpB"}
|
package/script/utils/object.js
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UpdatableObject = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Base class for objects that can be updated with new data from the API.
|
|
6
|
-
*
|
|
7
|
-
* @param data The initial response data for the object
|
|
8
|
-
* @param endpoint The endpoint to the linked object that can be used to fetch the updated data.
|
|
9
|
-
*/
|
|
10
|
-
class UpdatableObject {
|
|
11
|
-
constructor(api, data, endpoint) {
|
|
12
|
-
Object.defineProperty(this, "api", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
configurable: true,
|
|
15
|
-
writable: true,
|
|
16
|
-
value: api
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(this, "endpoint", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
configurable: true,
|
|
21
|
-
writable: true,
|
|
22
|
-
value: endpoint
|
|
23
|
-
});
|
|
24
|
-
Object.defineProperty(this, "response", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
configurable: true,
|
|
27
|
-
writable: true,
|
|
28
|
-
value: void 0
|
|
29
|
-
});
|
|
30
|
-
this.response = this.updateSelf(data);
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Updates the {@link response} object with new properties provided.
|
|
34
|
-
* It doesn't automatically update the {@link response} object.
|
|
35
|
-
*
|
|
36
|
-
* Assign here any additiona properties to update that should match the {@link ModifiedResponse} type parameter.
|
|
37
|
-
*
|
|
38
|
-
* @param data The new properties
|
|
39
|
-
* @returns The updated object
|
|
40
|
-
*/
|
|
41
|
-
updateSelf(data) {
|
|
42
|
-
const response = this.response || {};
|
|
43
|
-
for (const [key, value] of Object.entries(data)) {
|
|
44
|
-
if (['string', 'number', 'boolean', 'null', 'undefined'].includes(typeof response[key])) {
|
|
45
|
-
response[key] = value;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
const modified = this.applyResponse(this.response, data);
|
|
49
|
-
for (const [key, value] of Object.entries(modified)) {
|
|
50
|
-
response[key] = value;
|
|
51
|
-
}
|
|
52
|
-
return response;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Fetches new data from the API and updates the {@link response} object.
|
|
56
|
-
* Only updates new properties fetched.
|
|
57
|
-
*
|
|
58
|
-
* Also updates the {@link response} object with new data wrapping to {@link updateSelf}.
|
|
59
|
-
*
|
|
60
|
-
* @param include A list of properties to include in the response
|
|
61
|
-
*/
|
|
62
|
-
async fetchSelf(include) {
|
|
63
|
-
const response = await this.api.request('GET', this.endpoint, {
|
|
64
|
-
params: {
|
|
65
|
-
include: include.join(','),
|
|
66
|
-
},
|
|
67
|
-
});
|
|
68
|
-
this.updateSelf(response.data);
|
|
69
|
-
return response.data;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Fetches new data from the API and updates the object with new data.
|
|
73
|
-
* Useful to fetch and cache multiple API calls into a single call.
|
|
74
|
-
*
|
|
75
|
-
* @param include A list of properties to include in the response
|
|
76
|
-
*/
|
|
77
|
-
async fetch(include) {
|
|
78
|
-
await this.fetchSelf(include);
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Send a PATCH request to the server with the given body
|
|
82
|
-
* @returns The new server response
|
|
83
|
-
*/
|
|
84
|
-
async callPatch(body) {
|
|
85
|
-
const { data } = await this.api.request('PATCH', this.endpoint, { body });
|
|
86
|
-
this.updateSelf(data);
|
|
87
|
-
return data;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
exports.UpdatableObject = UpdatableObject;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The function that controls updates the value of a subscription
|
|
3
|
-
*/
|
|
4
|
-
export type SubscriptionNotifier<T> = (
|
|
5
|
-
/**
|
|
6
|
-
* Set the new value and notify the subscribers
|
|
7
|
-
*/
|
|
8
|
-
set: (value: T) => void,
|
|
9
|
-
/**
|
|
10
|
-
* Update the value with access to current one and notify the subscribers
|
|
11
|
-
*/
|
|
12
|
-
update: (
|
|
13
|
-
/**
|
|
14
|
-
* Update the value and notify the subscribers
|
|
15
|
-
* @returns the new value to be set
|
|
16
|
-
*/
|
|
17
|
-
func: (currentValue: T) => T | PromiseLike<T>) => void) => void;
|
|
18
|
-
export interface Subscription<T> {
|
|
19
|
-
/**
|
|
20
|
-
* Subscribe to changes. Immediately calls the function with the current value.
|
|
21
|
-
*
|
|
22
|
-
* @returns the unsubscribe function
|
|
23
|
-
*/
|
|
24
|
-
subscribe(fn: (value: T) => void): () => void;
|
|
25
|
-
}
|
|
26
|
-
export interface Subscriable {
|
|
27
|
-
subscribe(): Subscription<this>;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Create a variable that can be subscribed to for changes.
|
|
31
|
-
*
|
|
32
|
-
* @param initValue The initial value
|
|
33
|
-
* @param notifier The {@link SubscriptionNotifier} function called on initialization, controlling the current value
|
|
34
|
-
* @returns A subscription object allowing to subscribe
|
|
35
|
-
*/
|
|
36
|
-
export declare function createSubscription<T>(initValue: T, notifier: SubscriptionNotifier<T>): Subscription<T>;
|
|
37
|
-
//# sourceMappingURL=subscribe.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"subscribe.d.ts","sourceRoot":"","sources":["../../src/utils/subscribe.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAAI;AACrC;;GAEG;AACH,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI;AACvB;;GAEG;AACH,MAAM,EAAE;AACP;;;GAGG;AACH,IAAI,EAAE,CAAC,YAAY,EAAE,CAAC,KAAK,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,KACzC,IAAI,KACL,IAAI,CAAC;AAEV,MAAM,WAAW,YAAY,CAAC,CAAC;IAC9B;;;;OAIG;IACH,SAAS,CAAC,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CAC9C;AAED,MAAM,WAAW,WAAW;IAC3B,SAAS,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC;CAChC;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EACnC,SAAS,EAAE,CAAC,EACZ,QAAQ,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAC/B,YAAY,CAAC,CAAC,CAAC,CA0BjB"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createSubscription = createSubscription;
|
|
4
|
-
/**
|
|
5
|
-
* Create a variable that can be subscribed to for changes.
|
|
6
|
-
*
|
|
7
|
-
* @param initValue The initial value
|
|
8
|
-
* @param notifier The {@link SubscriptionNotifier} function called on initialization, controlling the current value
|
|
9
|
-
* @returns A subscription object allowing to subscribe
|
|
10
|
-
*/
|
|
11
|
-
function createSubscription(initValue, notifier) {
|
|
12
|
-
let currentValue = initValue;
|
|
13
|
-
const subscribers = new Set();
|
|
14
|
-
function set(value) {
|
|
15
|
-
currentValue = value;
|
|
16
|
-
subscribers.forEach((fn) => fn(currentValue));
|
|
17
|
-
}
|
|
18
|
-
async function update(value) {
|
|
19
|
-
currentValue = await value(currentValue);
|
|
20
|
-
subscribers.forEach((fn) => fn(currentValue));
|
|
21
|
-
}
|
|
22
|
-
notifier(set, update);
|
|
23
|
-
return {
|
|
24
|
-
subscribe(fn) {
|
|
25
|
-
subscribers.add(fn);
|
|
26
|
-
fn(currentValue);
|
|
27
|
-
return () => {
|
|
28
|
-
subscribers.delete(fn);
|
|
29
|
-
};
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
}
|
package/script/utils/timer.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A simple class for converting milliseconds to hours, minutes and seconds.
|
|
3
|
-
*/
|
|
4
|
-
export declare class Timer extends Number {
|
|
5
|
-
private readonly timerMs;
|
|
6
|
-
constructor(timerMs: number);
|
|
7
|
-
get hour(): number;
|
|
8
|
-
get minute(): number;
|
|
9
|
-
get second(): number;
|
|
10
|
-
get millisecond(): number;
|
|
11
|
-
toString(): string;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=timer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"timer.d.ts","sourceRoot":"","sources":["../../src/utils/timer.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,KAAM,SAAQ,MAAM;IACb,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,MAAM;IAInD,IAAW,IAAI,IAAI,MAAM,CAExB;IAED,IAAW,MAAM,IAAI,MAAM,CAE1B;IAED,IAAW,MAAM,IAAI,MAAM,CAE1B;IAED,IAAW,WAAW,IAAI,MAAM,CAE/B;IAEe,QAAQ,IAAI,MAAM;CAMlC"}
|
package/script/utils/timer.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Timer = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* A simple class for converting milliseconds to hours, minutes and seconds.
|
|
6
|
-
*/
|
|
7
|
-
class Timer extends Number {
|
|
8
|
-
constructor(timerMs) {
|
|
9
|
-
super(timerMs);
|
|
10
|
-
Object.defineProperty(this, "timerMs", {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
configurable: true,
|
|
13
|
-
writable: true,
|
|
14
|
-
value: timerMs
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
get hour() {
|
|
18
|
-
return Math.floor(this.timerMs / 1000 / 60 / 60);
|
|
19
|
-
}
|
|
20
|
-
get minute() {
|
|
21
|
-
return Math.floor(this.timerMs / 1000 / 60);
|
|
22
|
-
}
|
|
23
|
-
get second() {
|
|
24
|
-
return Math.floor(this.timerMs / 1000);
|
|
25
|
-
}
|
|
26
|
-
get millisecond() {
|
|
27
|
-
return this.timerMs;
|
|
28
|
-
}
|
|
29
|
-
toString() {
|
|
30
|
-
const hour = this.hour.toString().padStart(2, '0');
|
|
31
|
-
const minute = this.minute.toString().padStart(2, '0');
|
|
32
|
-
const second = this.second.toString().padStart(2, '0');
|
|
33
|
-
return `${hour}:${minute}:${second}`;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
exports.Timer = Timer;
|
package/script/utils/units.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A simple class for converting bytes to other units.
|
|
3
|
-
*/
|
|
4
|
-
export declare class ByteUnit {
|
|
5
|
-
protected static readonly KB = 1024;
|
|
6
|
-
protected static readonly MB: number;
|
|
7
|
-
protected static readonly GB: number;
|
|
8
|
-
static stringify(value: number, unit?: 'b' | 'kb' | 'mb' | 'gb'): string;
|
|
9
|
-
static readonly ZERO: ByteUnit;
|
|
10
|
-
protected readonly valueBytes: number;
|
|
11
|
-
constructor(value: number, unit?: 'b' | 'kb' | 'mb' | 'gb');
|
|
12
|
-
get bytes(): number;
|
|
13
|
-
get kb(): number;
|
|
14
|
-
get mb(): number;
|
|
15
|
-
get gb(): number;
|
|
16
|
-
toString(): string;
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=units.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"units.d.ts","sourceRoot":"","sources":["../../src/utils/units.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,QAAQ;IACpB,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,QAAQ;IACpC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,SAAe;IAC3C,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,SAAsB;WAEpC,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,GAAE,GAAG,GAAG,IAAI,GAAG,IAAI,GAAG,IAAU,GAAG,MAAM;IAIpF,gBAAuB,IAAI,EAAE,QAAQ,CAAmB;IAExD,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;gBACnB,KAAK,EAAE,MAAM,EAAE,IAAI,GAAE,GAAG,GAAG,IAAI,GAAG,IAAI,GAAG,IAAU;IAmBtE,IAAW,KAAK,IAAI,MAAM,CAEzB;IAED,IAAW,EAAE,IAAI,MAAM,CAEtB;IAED,IAAW,EAAE,IAAI,MAAM,CAEtB;IAED,IAAW,EAAE,IAAI,MAAM,CAEtB;IAEM,QAAQ,IAAI,MAAM;CAWzB"}
|