@omujs/omu 0.9.48 → 0.9.50
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/address.js +1 -0
- package/dist/address.js.map +7 -0
- package/dist/api/asset/extension.d.ts +25 -0
- package/dist/api/asset/extension.js +2 -0
- package/dist/api/asset/extension.js.map +7 -0
- package/dist/api/asset/index.d.ts +2 -0
- package/dist/api/asset/index.js +2 -0
- package/dist/api/asset/index.js.map +7 -0
- package/dist/api/dashboard/extension.d.ts +181 -0
- package/dist/api/dashboard/extension.js +2 -0
- package/dist/api/dashboard/extension.js.map +7 -0
- package/{src/api/dashboard/handler.ts → dist/api/dashboard/handler.d.ts} +3 -5
- package/dist/api/dashboard/handler.js +1 -0
- package/dist/api/dashboard/handler.js.map +7 -0
- package/dist/api/dashboard/index.d.ts +3 -0
- package/dist/api/dashboard/index.js +2 -0
- package/dist/api/dashboard/index.js.map +7 -0
- package/dist/api/dashboard/packets.d.ts +63 -0
- package/dist/api/dashboard/packets.js +2 -0
- package/dist/api/dashboard/packets.js.map +7 -0
- package/dist/api/endpoint/endpoint.d.ts +21 -0
- package/dist/api/endpoint/endpoint.js +2 -0
- package/dist/api/endpoint/endpoint.js.map +7 -0
- package/dist/api/endpoint/extension.d.ts +17 -0
- package/dist/api/endpoint/extension.js +2 -0
- package/dist/api/endpoint/extension.js.map +7 -0
- package/{src/api/endpoint/index.ts → dist/api/endpoint/index.d.ts} +0 -1
- package/dist/api/endpoint/index.js +2 -0
- package/dist/api/endpoint/index.js.map +7 -0
- package/dist/api/endpoint/packets.d.ts +51 -0
- package/dist/api/endpoint/packets.js +2 -0
- package/dist/api/endpoint/packets.js.map +7 -0
- package/dist/api/extension-registry.d.ts +8 -0
- package/dist/api/extension-registry.js +2 -0
- package/dist/api/extension-registry.js.map +7 -0
- package/dist/api/extension.d.ts +11 -0
- package/dist/api/extension.js +2 -0
- package/dist/api/extension.js.map +7 -0
- package/dist/api/http/extension.d.ts +41 -0
- package/dist/api/http/extension.js +2 -0
- package/dist/api/http/extension.js.map +7 -0
- package/dist/api/http/http.d.ts +36 -0
- package/dist/api/http/http.js +2 -0
- package/dist/api/http/http.js.map +7 -0
- package/{src/api/http/index.ts → dist/api/http/index.d.ts} +0 -1
- package/dist/api/http/index.js +2 -0
- package/dist/api/http/index.js.map +7 -0
- package/dist/api/http/websocket.d.ts +125 -0
- package/dist/api/http/websocket.js +2 -0
- package/dist/api/http/websocket.js.map +7 -0
- package/dist/api/i18n/extension.d.ts +19 -0
- package/dist/api/i18n/extension.js +2 -0
- package/dist/api/i18n/extension.js.map +7 -0
- package/{src/api/i18n/index.ts → dist/api/i18n/index.d.ts} +0 -1
- package/dist/api/i18n/index.js +2 -0
- package/dist/api/i18n/index.js.map +7 -0
- package/dist/api/index.d.ts +2 -0
- package/dist/api/index.js +2 -0
- package/dist/api/index.js.map +7 -0
- package/dist/api/logger/extension.d.ts +25 -0
- package/dist/api/logger/extension.js +2 -0
- package/dist/api/logger/extension.js.map +7 -0
- package/dist/api/logger/index.d.ts +1 -0
- package/dist/api/logger/index.js +2 -0
- package/dist/api/logger/index.js.map +7 -0
- package/dist/api/logger/packets.d.ts +18 -0
- package/dist/api/logger/packets.js +2 -0
- package/dist/api/logger/packets.js.map +7 -0
- package/dist/api/permission/extension.d.ts +19 -0
- package/dist/api/permission/extension.js +2 -0
- package/dist/api/permission/extension.js.map +7 -0
- package/{src/api/permission/index.ts → dist/api/permission/index.d.ts} +0 -1
- package/dist/api/permission/index.js +2 -0
- package/dist/api/permission/index.js.map +7 -0
- package/dist/api/permission/permission.d.ts +25 -0
- package/dist/api/permission/permission.js +2 -0
- package/dist/api/permission/permission.js.map +7 -0
- package/dist/api/plugin/extension.d.ts +43 -0
- package/dist/api/plugin/extension.js +2 -0
- package/dist/api/plugin/extension.js.map +7 -0
- package/{src/api/plugin/index.ts → dist/api/plugin/index.d.ts} +0 -1
- package/dist/api/plugin/index.js +2 -0
- package/dist/api/plugin/index.js.map +7 -0
- package/{src/api/plugin/package-info.ts → dist/api/plugin/package-info.d.ts} +0 -7
- package/dist/api/plugin/package-info.js +1 -0
- package/dist/api/plugin/package-info.js.map +7 -0
- package/dist/api/registry/extension.d.ts +23 -0
- package/dist/api/registry/extension.js +2 -0
- package/dist/api/registry/extension.js.map +7 -0
- package/{src/api/registry/index.ts → dist/api/registry/index.d.ts} +0 -1
- package/dist/api/registry/index.js +2 -0
- package/dist/api/registry/index.js.map +7 -0
- package/dist/api/registry/packets.d.ts +20 -0
- package/dist/api/registry/packets.js +2 -0
- package/dist/api/registry/packets.js.map +7 -0
- package/{src/api/registry/registry.ts → dist/api/registry/registry.d.ts} +11 -53
- package/dist/api/registry/registry.js +2 -0
- package/dist/api/registry/registry.js.map +7 -0
- package/dist/api/server/extension.d.ts +61 -0
- package/dist/api/server/extension.js +2 -0
- package/dist/api/server/extension.js.map +7 -0
- package/dist/api/server/index.d.ts +1 -0
- package/dist/api/server/index.js +2 -0
- package/dist/api/server/index.js.map +7 -0
- package/dist/api/session/extension.d.ts +52 -0
- package/dist/api/session/extension.js +2 -0
- package/dist/api/session/extension.js.map +7 -0
- package/dist/api/session/index.d.ts +1 -0
- package/dist/api/session/index.js +2 -0
- package/dist/api/session/index.js.map +7 -0
- package/dist/api/signal/extension.d.ts +19 -0
- package/dist/api/signal/extension.js +2 -0
- package/dist/api/signal/extension.js.map +7 -0
- package/dist/api/signal/index.d.ts +1 -0
- package/dist/api/signal/index.js +2 -0
- package/dist/api/signal/index.js.map +7 -0
- package/dist/api/signal/packets.d.ts +21 -0
- package/dist/api/signal/packets.js +2 -0
- package/dist/api/signal/packets.js.map +7 -0
- package/dist/api/signal/signal.d.ts +33 -0
- package/dist/api/signal/signal.js +2 -0
- package/dist/api/signal/signal.js.map +7 -0
- package/dist/api/table/extension.d.ts +26 -0
- package/dist/api/table/extension.js +2 -0
- package/dist/api/table/extension.js.map +7 -0
- package/{src/api/table/index.ts → dist/api/table/index.d.ts} +0 -1
- package/dist/api/table/index.js +2 -0
- package/dist/api/table/index.js.map +7 -0
- package/dist/api/table/packets.d.ts +65 -0
- package/dist/api/table/packets.js +2 -0
- package/dist/api/table/packets.js.map +7 -0
- package/dist/api/table/table.d.ts +75 -0
- package/dist/api/table/table.js +2 -0
- package/dist/api/table/table.js.map +7 -0
- package/dist/app.d.ts +49 -0
- package/dist/app.js +2 -0
- package/dist/app.js.map +7 -0
- package/dist/const.d.ts +2 -0
- package/dist/const.js +2 -0
- package/dist/const.js.map +7 -0
- package/dist/errors.d.ts +36 -0
- package/dist/errors.js +2 -0
- package/dist/errors.js.map +7 -0
- package/dist/event/index.d.ts +6 -0
- package/dist/event/index.js +2 -0
- package/dist/event/index.js.map +7 -0
- package/dist/helper.d.ts +10 -0
- package/dist/helper.js +2 -0
- package/dist/helper.js.map +7 -0
- package/dist/identifier.d.ts +51 -0
- package/dist/identifier.js +2 -0
- package/dist/identifier.js.map +7 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +7 -0
- package/{src/localization/index.ts → dist/localization/index.d.ts} +0 -1
- package/dist/localization/index.js +2 -0
- package/dist/localization/index.js.map +7 -0
- package/dist/localization/locale.d.ts +735 -0
- package/dist/localization/locale.js +2 -0
- package/dist/localization/locale.js.map +7 -0
- package/{src/localization/localization.ts → dist/localization/localization.d.ts} +0 -2
- package/dist/localization/localization.js +1 -0
- package/dist/localization/localization.js.map +7 -0
- package/dist/lock.d.ts +6 -0
- package/dist/lock.js +2 -0
- package/dist/lock.js.map +7 -0
- package/dist/network/connection.d.ts +17 -0
- package/dist/network/connection.js +2 -0
- package/dist/network/connection.js.map +7 -0
- package/dist/network/encryption.d.ts +38 -0
- package/dist/network/encryption.js +2 -0
- package/dist/network/encryption.js.map +7 -0
- package/dist/network/frame-transport.d.ts +22 -0
- package/dist/network/frame-transport.js +2 -0
- package/dist/network/frame-transport.js.map +7 -0
- package/{src/network/index.ts → dist/network/index.d.ts} +0 -1
- package/dist/network/index.js +2 -0
- package/dist/network/index.js.map +7 -0
- package/dist/network/network.d.ts +59 -0
- package/dist/network/network.js +2 -0
- package/dist/network/network.js.map +7 -0
- package/{src/network/packet/index.ts → dist/network/packet/index.d.ts} +0 -1
- package/dist/network/packet/index.js +2 -0
- package/dist/network/packet/index.js.map +7 -0
- package/dist/network/packet/packet-types.d.ts +84 -0
- package/dist/network/packet/packet-types.js +2 -0
- package/dist/network/packet/packet-types.js.map +7 -0
- package/dist/network/packet/packet.d.ts +25 -0
- package/dist/network/packet/packet.js +2 -0
- package/dist/network/packet/packet.js.map +7 -0
- package/dist/network/websocket-transport.d.ts +24 -0
- package/dist/network/websocket-transport.js +2 -0
- package/dist/network/websocket-transport.js.map +7 -0
- package/dist/omu.d.ts +61 -0
- package/dist/omu.js +2 -0
- package/dist/omu.js.map +7 -0
- package/dist/result.d.ts +26 -0
- package/dist/result.js +2 -0
- package/dist/result.js.map +7 -0
- package/dist/serialize/bytebuffer.d.ts +73 -0
- package/dist/serialize/bytebuffer.js +2 -0
- package/dist/serialize/bytebuffer.js.map +7 -0
- package/dist/serialize/index.d.ts +2 -0
- package/dist/serialize/index.js +2 -0
- package/dist/serialize/index.js.map +7 -0
- package/dist/serialize/serializer.d.ts +26 -0
- package/dist/serialize/serializer.js +2 -0
- package/dist/serialize/serializer.js.map +7 -0
- package/dist/token.d.ts +14 -0
- package/dist/token.js +2 -0
- package/dist/token.js.map +7 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +2 -0
- package/dist/version.js.map +7 -0
- package/package.json +12 -9
- package/CHANGELOG.md +0 -1845
- package/src/api/asset/extension.ts +0 -193
- package/src/api/asset/index.ts +0 -5
- package/src/api/dashboard/extension.ts +0 -651
- package/src/api/dashboard/index.ts +0 -38
- package/src/api/dashboard/packets.ts +0 -126
- package/src/api/endpoint/endpoint.ts +0 -56
- package/src/api/endpoint/extension.ts +0 -133
- package/src/api/endpoint/packets.ts +0 -176
- package/src/api/extension-registry.ts +0 -17
- package/src/api/extension.ts +0 -19
- package/src/api/http/extension.ts +0 -401
- package/src/api/http/http.ts +0 -79
- package/src/api/http/websocket.ts +0 -283
- package/src/api/i18n/extension.ts +0 -65
- package/src/api/index.ts +0 -3
- package/src/api/logger/extension.ts +0 -75
- package/src/api/logger/index.ts +0 -4
- package/src/api/logger/packets.ts +0 -38
- package/src/api/permission/extension.ts +0 -107
- package/src/api/permission/permission.ts +0 -53
- package/src/api/plugin/extension.ts +0 -100
- package/src/api/registry/extension.ts +0 -326
- package/src/api/registry/packets.ts +0 -64
- package/src/api/server/extension.ts +0 -155
- package/src/api/server/index.ts +0 -11
- package/src/api/session/extension.ts +0 -205
- package/src/api/session/index.ts +0 -7
- package/src/api/signal/extension.ts +0 -125
- package/src/api/signal/index.ts +0 -1
- package/src/api/signal/packets.ts +0 -61
- package/src/api/signal/signal.ts +0 -67
- package/src/api/table/extension.ts +0 -554
- package/src/api/table/packets.ts +0 -252
- package/src/api/table/table.ts +0 -113
- package/src/app.ts +0 -95
- package/src/const.ts +0 -2
- package/src/errors.ts +0 -70
- package/src/event/index.ts +0 -18
- package/src/helper.ts +0 -16
- package/src/identifier.ts +0 -256
- package/src/index.ts +0 -87
- package/src/localization/locale.ts +0 -737
- package/src/lock.ts +0 -43
- package/src/network/connection.ts +0 -45
- package/src/network/encryption.ts +0 -221
- package/src/network/frame-transport.ts +0 -186
- package/src/network/network.ts +0 -322
- package/src/network/packet/packet-types.ts +0 -164
- package/src/network/packet/packet.ts +0 -55
- package/src/network/websocket-transport.ts +0 -123
- package/src/omu.ts +0 -156
- package/src/result.ts +0 -78
- package/src/serialize/bytebuffer.ts +0 -432
- package/src/serialize/index.ts +0 -2
- package/src/serialize/serializer.ts +0 -149
- package/src/token.ts +0 -39
- package/src/version.ts +0 -2
- package/tsconfig.json +0 -18
- /package/{src/address.ts → dist/address.d.ts} +0 -0
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { Identifier } from '../../identifier';
|
|
2
|
-
import { PacketType } from '../../network/packet/packet.js';
|
|
3
|
-
import { Omu } from '../../omu';
|
|
4
|
-
import { EndpointType } from '../endpoint/endpoint.js';
|
|
5
|
-
import { ExtensionType } from '../extension.js';
|
|
6
|
-
import { Table, TableType } from '../table/table.js';
|
|
7
|
-
|
|
8
|
-
export const PLUGIN_EXTENSION_TYPE: ExtensionType<PluginExtension> = new ExtensionType(
|
|
9
|
-
'plugin',
|
|
10
|
-
(omu: Omu) => new PluginExtension(omu),
|
|
11
|
-
);
|
|
12
|
-
|
|
13
|
-
export class PluginExtension {
|
|
14
|
-
public readonly type: ExtensionType<PluginExtension> = PLUGIN_EXTENSION_TYPE;
|
|
15
|
-
private readonly requiredPlugins: Map<string, string | null> = new Map();
|
|
16
|
-
|
|
17
|
-
constructor(private readonly omu: Omu) {
|
|
18
|
-
omu.network.registerPacket(PLUGIN_REQUIRE_PACKET);
|
|
19
|
-
omu.network.addTask(() => this.onTask());
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
public getAllowedPackages(): Table<PluginPackageInfo> {
|
|
23
|
-
return this.omu.tables.get(PLUGIN_ALLOWED_PACKAGE_TABLE);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
public reload(options: ReloadOptions): void {
|
|
27
|
-
this.omu.endpoints.call(PLUGIN_RELOAD_ENDPOINT_TYPE, options);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
private async onTask(): Promise<void> {
|
|
31
|
-
this.omu.send(PLUGIN_REQUIRE_PACKET, Object.fromEntries(this.requiredPlugins));
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
public require(plugins: Record<string, string | null>): void {
|
|
35
|
-
if (this.omu.running) {
|
|
36
|
-
throw new Error('Plugins must be required before the client starts');
|
|
37
|
-
}
|
|
38
|
-
for (const [key, value] of Object.entries(plugins)) {
|
|
39
|
-
this.requiredPlugins.set(key, value);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const PLUGIN_REQUIRE_PACKET = PacketType.createJson<Record<string, string | null>>(
|
|
45
|
-
PLUGIN_EXTENSION_TYPE,
|
|
46
|
-
{
|
|
47
|
-
name: 'require',
|
|
48
|
-
},
|
|
49
|
-
);
|
|
50
|
-
export class PluginPackageInfo {
|
|
51
|
-
public package: string;
|
|
52
|
-
public version: string;
|
|
53
|
-
|
|
54
|
-
constructor(_package: string, version: string) {
|
|
55
|
-
this.package = _package;
|
|
56
|
-
this.version = version;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
public static serialize(data: PluginPackageInfo): { package: string; version: string } {
|
|
60
|
-
return data.toJson();
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
public static deserialize(data: { package: string; version: string }): PluginPackageInfo {
|
|
64
|
-
return PluginPackageInfo.fromJson(data);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
public static fromJson(json: { package: string; version: string }): PluginPackageInfo {
|
|
68
|
-
return new PluginPackageInfo(json.package, json.version);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
public toJson(): { package: string; version: string } {
|
|
72
|
-
return { package: this.package, version: this.version };
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
public key(): string {
|
|
76
|
-
return this.package;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export const PLUGIN_READ_PACKAGE_PERMISSION_ID: Identifier = PLUGIN_EXTENSION_TYPE.join('package', 'read');
|
|
81
|
-
export const PLUGIN_MANAGE_PACKAGE_PERMISSION_ID: Identifier = PLUGIN_EXTENSION_TYPE.join('package', 'manage');
|
|
82
|
-
|
|
83
|
-
const PLUGIN_ALLOWED_PACKAGE_TABLE = TableType.createJson(PLUGIN_EXTENSION_TYPE, {
|
|
84
|
-
name: 'allowed_package',
|
|
85
|
-
serializer: PluginPackageInfo,
|
|
86
|
-
key: (item) => item.key(),
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
type ReloadOptions = {
|
|
90
|
-
packages: string[] | null;
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
type ReloadResult = {
|
|
94
|
-
packages: Record<string, string>;
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
const PLUGIN_RELOAD_ENDPOINT_TYPE = EndpointType.createJson<ReloadOptions, ReloadResult>(PLUGIN_EXTENSION_TYPE, {
|
|
98
|
-
name: 'reload',
|
|
99
|
-
permissionId: PLUGIN_MANAGE_PACKAGE_PERMISSION_ID,
|
|
100
|
-
});
|
|
@@ -1,326 +0,0 @@
|
|
|
1
|
-
import type { Unlisten } from '../../event';
|
|
2
|
-
import { EventEmitter } from '../../event';
|
|
3
|
-
import { Identifier, IdentifierMap } from '../../identifier';
|
|
4
|
-
import { Lock } from '../../lock.js';
|
|
5
|
-
import { PacketType } from '../../network/packet';
|
|
6
|
-
import { Omu } from '../../omu';
|
|
7
|
-
import { JsonType, Serializer } from '../../serialize';
|
|
8
|
-
import { EndpointType } from '../endpoint/endpoint.js';
|
|
9
|
-
import { type Extension, ExtensionType } from '../extension.js';
|
|
10
|
-
|
|
11
|
-
import { RegisterPacket, RegistryPacket } from './packets.js';
|
|
12
|
-
import { type Registry, RegistryType, Writable } from './registry.js';
|
|
13
|
-
|
|
14
|
-
export class RegistryExtension implements Extension {
|
|
15
|
-
public readonly type: ExtensionType<RegistryExtension> = REGISTRY_EXTENSION_TYPE;
|
|
16
|
-
private readonly registries = new IdentifierMap<Registry<unknown>>();
|
|
17
|
-
|
|
18
|
-
constructor(private readonly omu: Omu) {
|
|
19
|
-
omu.network.registerPacket(
|
|
20
|
-
REGISTRY_REGISTER_PACKET,
|
|
21
|
-
REGISTRY_UPDATE_PACKET,
|
|
22
|
-
REGISTRY_LISTEN_PACKET,
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
private createRegistry<T>(registryType: RegistryType<T>): Registry<T> {
|
|
27
|
-
if (this.registries.has(registryType.id)) {
|
|
28
|
-
throw new Error(`Registry with identifier '${registryType.id}' already exists`);
|
|
29
|
-
}
|
|
30
|
-
return new RegistryImpl(this.omu, registryType);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
public get<T>(registryType: RegistryType<T>): Registry<T> {
|
|
34
|
-
const identifier = registryType.id;
|
|
35
|
-
let registry = this.registries.get(identifier);
|
|
36
|
-
if (registry === undefined) {
|
|
37
|
-
registry = this.createRegistry(registryType);
|
|
38
|
-
this.registries.set(identifier, registry);
|
|
39
|
-
}
|
|
40
|
-
return registry as Registry<T>;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
public json<T, D extends JsonType = JsonType>(name: string, options: { default: T; serializer?: Serializer<T, D> }): Registry<T> {
|
|
44
|
-
const identifier = this.omu.app.id.base.join(name);
|
|
45
|
-
if (this.registries.has(identifier)) {
|
|
46
|
-
throw new Error(`Registry with name '${name}' already exists`);
|
|
47
|
-
}
|
|
48
|
-
const tableType = RegistryType.createJson<T>(identifier, {
|
|
49
|
-
name,
|
|
50
|
-
defaultValue: options.default,
|
|
51
|
-
serializer: options.serializer,
|
|
52
|
-
});
|
|
53
|
-
return this.createRegistry(tableType);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
public serialized<T>(name: string, options: { default: T; serializer: Serializer<T, Uint8Array> }): Registry<T> {
|
|
57
|
-
const identifier = this.omu.app.id.base.join(name);
|
|
58
|
-
if (this.registries.has(identifier)) {
|
|
59
|
-
throw new Error(`Registry with name '${name}' already exists`);
|
|
60
|
-
}
|
|
61
|
-
const tableType = RegistryType.createSerialized<T>(identifier, {
|
|
62
|
-
name,
|
|
63
|
-
defaultValue: options.default,
|
|
64
|
-
serializer: options.serializer,
|
|
65
|
-
});
|
|
66
|
-
return this.createRegistry(tableType);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
class RegistryImpl<T> implements Registry<T> {
|
|
71
|
-
private readonly eventEmitter: EventEmitter<[T]> = new EventEmitter();
|
|
72
|
-
private readonly lock: Lock = new Lock();
|
|
73
|
-
private listening = false;
|
|
74
|
-
public value: T;
|
|
75
|
-
|
|
76
|
-
constructor(
|
|
77
|
-
private readonly omu: Omu,
|
|
78
|
-
public readonly type: RegistryType<T>,
|
|
79
|
-
) {
|
|
80
|
-
this.value = type.defaultValue;
|
|
81
|
-
omu.network.addPacketHandler(REGISTRY_UPDATE_PACKET, (packet) =>
|
|
82
|
-
this.handleUpdate(packet),
|
|
83
|
-
);
|
|
84
|
-
omu.network.addTask(() => this.onTask());
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
async #get(): Promise<T> {
|
|
88
|
-
const result = await this.omu.endpoints.call(REGISTRY_GET_ENDPOINT, this.type.id);
|
|
89
|
-
if (result.value === null) {
|
|
90
|
-
return this.type.defaultValue;
|
|
91
|
-
}
|
|
92
|
-
return this.type.serializer.deserialize(result.value);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
async #set(value: T): Promise<void> {
|
|
96
|
-
this.omu.send(REGISTRY_UPDATE_PACKET, {
|
|
97
|
-
id: this.type.id,
|
|
98
|
-
value: this.type.serializer.serialize(value),
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
public async get(): Promise<T> {
|
|
103
|
-
const value = await this.lock.use(async () => this.#get());
|
|
104
|
-
this.eventEmitter.emit(value);
|
|
105
|
-
return value;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
public async set(value: T): Promise<void> {
|
|
109
|
-
await this.lock.use(async () => this.#set(value));
|
|
110
|
-
this.eventEmitter.emit(value);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
public async update(fn: (value: T) => PromiseLike<T> | T): Promise<T> {
|
|
114
|
-
const value = await this.lock.use(async () => {
|
|
115
|
-
const value = await this.#get();
|
|
116
|
-
const newValue = await fn(value);
|
|
117
|
-
await this.#set(newValue);
|
|
118
|
-
return newValue;
|
|
119
|
-
});
|
|
120
|
-
this.eventEmitter.emit(value);
|
|
121
|
-
return value;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
public async modify(fn: (value: T) => PromiseLike<void> | void): Promise<T> {
|
|
125
|
-
const value = await this.lock.use(async () => {
|
|
126
|
-
const value = await this.#get();
|
|
127
|
-
await fn(value);
|
|
128
|
-
await this.#set(value);
|
|
129
|
-
return value;
|
|
130
|
-
});
|
|
131
|
-
this.eventEmitter.emit(value);
|
|
132
|
-
return value;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
public listen(handler: (value: T) => Promise<void> | void): Unlisten {
|
|
136
|
-
if (!this.listening && this.omu.ready) {
|
|
137
|
-
this.omu.send(REGISTRY_LISTEN_PACKET, this.type.id);
|
|
138
|
-
}
|
|
139
|
-
this.listening = true;
|
|
140
|
-
return this.eventEmitter.listen(handler);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
private handleUpdate(data: RegistryPacket): void {
|
|
144
|
-
if (!data.id.isEqual(this.type.id)) {
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
if (data.value !== null) {
|
|
148
|
-
this.value = this.type.serializer.deserialize(data.value);
|
|
149
|
-
}
|
|
150
|
-
this.eventEmitter.emit(this.value);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
private onTask(): void {
|
|
154
|
-
if (this.listening) {
|
|
155
|
-
this.omu.send(REGISTRY_LISTEN_PACKET, this.type.id);
|
|
156
|
-
}
|
|
157
|
-
if (!this.type.id.isSubpathOf(this.omu.app.id)) {
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
this.omu.send(REGISTRY_REGISTER_PACKET, {
|
|
161
|
-
id: this.type.id,
|
|
162
|
-
permissions: this.type.permissions,
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
public compatSvelte(): Writable<T> {
|
|
167
|
-
let isReady = false;
|
|
168
|
-
const context = {
|
|
169
|
-
changed: false,
|
|
170
|
-
markChanged: () => {
|
|
171
|
-
context.changed = true;
|
|
172
|
-
this.#set(this.value);
|
|
173
|
-
handle(this.value);
|
|
174
|
-
},
|
|
175
|
-
};
|
|
176
|
-
const listeners = new Set<(value: T) => void>();
|
|
177
|
-
|
|
178
|
-
const handle = (newValue: T) => {
|
|
179
|
-
isReady = true;
|
|
180
|
-
emit(newValue);
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
const unsubscribe = this.listen(handle);
|
|
184
|
-
|
|
185
|
-
const emit = (value: T) => {
|
|
186
|
-
this.value = value;
|
|
187
|
-
const proxied = proxy(value, context);
|
|
188
|
-
listeners.forEach(listener => listener(proxied));
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
return {
|
|
192
|
-
set: (value: T) => {
|
|
193
|
-
if (!isReady) {
|
|
194
|
-
throw new Error(`Registry ${this.type.id.key()} is not ready`);
|
|
195
|
-
}
|
|
196
|
-
const proxied = value?.[PROXIED_SYMBOL];
|
|
197
|
-
if (proxied && !context.changed) return;
|
|
198
|
-
this.#set(value);
|
|
199
|
-
emit(value);
|
|
200
|
-
context.changed = false;
|
|
201
|
-
},
|
|
202
|
-
subscribe: (run: (value: T) => void) => {
|
|
203
|
-
listeners.add(run);
|
|
204
|
-
run(proxy(this.value, context));
|
|
205
|
-
|
|
206
|
-
return () => {
|
|
207
|
-
listeners.delete(run);
|
|
208
|
-
if (listeners.size === 0) {
|
|
209
|
-
unsubscribe?.();
|
|
210
|
-
}
|
|
211
|
-
};
|
|
212
|
-
},
|
|
213
|
-
update: (fn: (value: T) => T) => {
|
|
214
|
-
if (!isReady) {
|
|
215
|
-
throw new Error(`Registry ${this.type.id.key()} is not ready`);
|
|
216
|
-
}
|
|
217
|
-
this.update(fn);
|
|
218
|
-
},
|
|
219
|
-
wait: (): Promise<T> => {
|
|
220
|
-
return isReady
|
|
221
|
-
? Promise.resolve(this.value)
|
|
222
|
-
: new Promise(resolve => {
|
|
223
|
-
const unsubscribe = this.listen((value: T) => {
|
|
224
|
-
unsubscribe?.();
|
|
225
|
-
resolve(value);
|
|
226
|
-
});
|
|
227
|
-
});
|
|
228
|
-
},
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
const PROXIED_SYMBOL = Symbol('ProxiedRegistry');
|
|
234
|
-
|
|
235
|
-
function deepEqual(objA, objB) {
|
|
236
|
-
if (objA === objB) return true; // Check for referential equality and primitive values
|
|
237
|
-
|
|
238
|
-
if (
|
|
239
|
-
typeof objA !== 'object' ||
|
|
240
|
-
typeof objB !== 'object' ||
|
|
241
|
-
objA === null ||
|
|
242
|
-
objB === null
|
|
243
|
-
) {
|
|
244
|
-
return false;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
const keysA = Object.keys(objA);
|
|
248
|
-
const keysB = Object.keys(objB);
|
|
249
|
-
|
|
250
|
-
if (keysA.length !== keysB.length) return false; // Different number of properties
|
|
251
|
-
|
|
252
|
-
for (const key of keysA) {
|
|
253
|
-
if (!keysB.includes(key) || !deepEqual(objA[key], objB[key])) {
|
|
254
|
-
return false; // Property missing or values are not deeply equal
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
return true; // All properties and their values are deeply equal
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
type ProxyContext = {
|
|
262
|
-
changed: boolean;
|
|
263
|
-
markChanged: () => void;
|
|
264
|
-
};
|
|
265
|
-
|
|
266
|
-
function proxy<T>(
|
|
267
|
-
value: T,
|
|
268
|
-
context: ProxyContext,
|
|
269
|
-
) {
|
|
270
|
-
if (typeof value !== 'object' || value === null) {
|
|
271
|
-
return value;
|
|
272
|
-
}
|
|
273
|
-
if (PROXIED_SYMBOL in value) {
|
|
274
|
-
return value;
|
|
275
|
-
}
|
|
276
|
-
let changed = false;
|
|
277
|
-
return new Proxy(value, {
|
|
278
|
-
set(target, prop, value) {
|
|
279
|
-
changed = !deepEqual(target[prop], value);
|
|
280
|
-
if (!changed) return true;
|
|
281
|
-
target[prop] = value;
|
|
282
|
-
context.markChanged();
|
|
283
|
-
return true;
|
|
284
|
-
},
|
|
285
|
-
get(target, prop) {
|
|
286
|
-
if (prop === PROXIED_SYMBOL) {
|
|
287
|
-
return value;
|
|
288
|
-
}
|
|
289
|
-
return proxy(target[prop], context);
|
|
290
|
-
},
|
|
291
|
-
has(target, p) {
|
|
292
|
-
if (p === PROXIED_SYMBOL) return true;
|
|
293
|
-
return p in target;
|
|
294
|
-
},
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
export const REGISTRY_EXTENSION_TYPE: ExtensionType<RegistryExtension> = new ExtensionType(
|
|
299
|
-
'registry',
|
|
300
|
-
(omu: Omu) => new RegistryExtension(omu),
|
|
301
|
-
);
|
|
302
|
-
export const REGISTRY_PERMISSION_ID: Identifier = REGISTRY_EXTENSION_TYPE.join('permission');
|
|
303
|
-
const REGISTRY_REGISTER_PACKET = PacketType.createJson<RegisterPacket>(REGISTRY_EXTENSION_TYPE, {
|
|
304
|
-
name: 'register',
|
|
305
|
-
serializer: RegisterPacket,
|
|
306
|
-
});
|
|
307
|
-
const REGISTRY_UPDATE_PACKET = PacketType.createSerialized<RegistryPacket>(
|
|
308
|
-
REGISTRY_EXTENSION_TYPE,
|
|
309
|
-
{
|
|
310
|
-
name: 'update',
|
|
311
|
-
serializer: RegistryPacket,
|
|
312
|
-
},
|
|
313
|
-
);
|
|
314
|
-
const REGISTRY_LISTEN_PACKET = PacketType.createJson<Identifier>(REGISTRY_EXTENSION_TYPE, {
|
|
315
|
-
name: 'listen',
|
|
316
|
-
serializer: Identifier,
|
|
317
|
-
});
|
|
318
|
-
const REGISTRY_GET_ENDPOINT = EndpointType.createSerialized<Identifier, RegistryPacket>(
|
|
319
|
-
REGISTRY_EXTENSION_TYPE,
|
|
320
|
-
{
|
|
321
|
-
name: 'get',
|
|
322
|
-
requestSerializer: Serializer.of(Identifier).toJson(),
|
|
323
|
-
responseSerializer: RegistryPacket,
|
|
324
|
-
permissionId: REGISTRY_PERMISSION_ID,
|
|
325
|
-
},
|
|
326
|
-
);
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { Identifier } from '../../identifier';
|
|
2
|
-
import { ByteReader, ByteWriter } from '../../serialize';
|
|
3
|
-
import { RegistryPermissions, RegistryPermissionsJSON } from './registry';
|
|
4
|
-
|
|
5
|
-
export class RegistryPacket {
|
|
6
|
-
constructor(
|
|
7
|
-
public readonly id: Identifier,
|
|
8
|
-
public readonly value: Uint8Array | null,
|
|
9
|
-
) { }
|
|
10
|
-
|
|
11
|
-
public static serialize(packet: RegistryPacket): Uint8Array {
|
|
12
|
-
const writer = new ByteWriter();
|
|
13
|
-
writer.writeString(packet.id.key());
|
|
14
|
-
writer.writeBoolean(packet.value !== null);
|
|
15
|
-
if (packet.value !== null) {
|
|
16
|
-
writer.writeUint8Array(packet.value);
|
|
17
|
-
}
|
|
18
|
-
return writer.finish();
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
public static deserialize(data: Uint8Array): RegistryPacket {
|
|
22
|
-
const reader = ByteReader.fromUint8Array(data);
|
|
23
|
-
const id = Identifier.fromKey(reader.readString());
|
|
24
|
-
const existing = reader.readBoolean();
|
|
25
|
-
const value = existing ? reader.readUint8Array() : null;
|
|
26
|
-
return new RegistryPacket(id, value);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface RegisterPacketJSON {
|
|
31
|
-
id: string;
|
|
32
|
-
permissions: RegistryPermissionsJSON;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export class RegisterPacket {
|
|
36
|
-
constructor(
|
|
37
|
-
public readonly id: Identifier,
|
|
38
|
-
public readonly permissions: RegistryPermissions,
|
|
39
|
-
) {}
|
|
40
|
-
|
|
41
|
-
public static serialize(packet: RegisterPacket): RegisterPacketJSON {
|
|
42
|
-
const { permissions: perms } = packet;
|
|
43
|
-
return {
|
|
44
|
-
id: packet.id.key(),
|
|
45
|
-
permissions: {
|
|
46
|
-
all: perms.all ? Identifier.from(perms.all).key() : undefined,
|
|
47
|
-
read: perms.read ? Identifier.from(perms.read).key() : undefined,
|
|
48
|
-
write: perms.write ? Identifier.from(perms.write).key() : undefined,
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
public static deserialize(data: RegisterPacketJSON): RegisterPacket {
|
|
54
|
-
const { permissions: perms } = data;
|
|
55
|
-
return new RegisterPacket(
|
|
56
|
-
Identifier.from(data.id),
|
|
57
|
-
{
|
|
58
|
-
all: perms.all ? Identifier.from(perms.all) : undefined,
|
|
59
|
-
read: perms.read ? Identifier.from(perms.read) : undefined,
|
|
60
|
-
write: perms.write ? Identifier.from(perms.write) : undefined,
|
|
61
|
-
},
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import { App, AppJson } from '../../app.js';
|
|
2
|
-
import { Identifier, IdentifierMap, IntoId } from '../../identifier';
|
|
3
|
-
import { LocalizedText } from '../../localization/localization.js';
|
|
4
|
-
import { Omu } from '../../omu.js';
|
|
5
|
-
import { EndpointType } from '../endpoint/endpoint.js';
|
|
6
|
-
import { ExtensionType, type Extension } from '../extension.js';
|
|
7
|
-
import { Registry, RegistryType } from '../registry';
|
|
8
|
-
import { TableType, type Table } from '../table';
|
|
9
|
-
|
|
10
|
-
export const SERVER_EXTENSION_TYPE: ExtensionType<ServerExtension> = new ExtensionType(
|
|
11
|
-
'server',
|
|
12
|
-
(omu: Omu) => new ServerExtension(omu),
|
|
13
|
-
);
|
|
14
|
-
|
|
15
|
-
export interface AppIndexEntry {
|
|
16
|
-
url: string;
|
|
17
|
-
meta?: AppIndexRegistryMeta;
|
|
18
|
-
added_at: string;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export interface AppIndex {
|
|
22
|
-
indexes: Record<string, AppIndexEntry>;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export const SERVER_APPS_READ_PERMISSION_ID: Identifier = SERVER_EXTENSION_TYPE.join('apps', 'read');
|
|
26
|
-
export const SERVER_APPS_WRITE_PERMISSION_ID: Identifier = SERVER_EXTENSION_TYPE.join('apps', 'write');
|
|
27
|
-
export const SERVER_INDEX_READ_PERMISSION_ID: Identifier = SERVER_EXTENSION_TYPE.join('index', 'read');
|
|
28
|
-
export const SERVER_INDEX_REGISTRY_TYPE: RegistryType<AppIndex> = RegistryType.createJson<AppIndex>(SERVER_EXTENSION_TYPE, {
|
|
29
|
-
name: 'index',
|
|
30
|
-
defaultValue: { 'indexes': {} },
|
|
31
|
-
permissions: {
|
|
32
|
-
write: SERVER_APPS_WRITE_PERMISSION_ID,
|
|
33
|
-
read: SERVER_INDEX_READ_PERMISSION_ID,
|
|
34
|
-
},
|
|
35
|
-
});
|
|
36
|
-
const APP_TABLE_TYPE = TableType.createJson(SERVER_EXTENSION_TYPE, {
|
|
37
|
-
name: 'apps',
|
|
38
|
-
serializer: App,
|
|
39
|
-
key: (app) => app.id.key(),
|
|
40
|
-
permissions: {
|
|
41
|
-
all: SERVER_APPS_WRITE_PERMISSION_ID,
|
|
42
|
-
read: SERVER_APPS_READ_PERMISSION_ID,
|
|
43
|
-
},
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
export const SERVER_SHUTDOWN_PERMISSION_ID: Identifier = SERVER_EXTENSION_TYPE.join('shutdown');
|
|
47
|
-
const SHUTDOWN_ENDPOINT_TYPE = EndpointType.createJson<boolean, boolean>(SERVER_EXTENSION_TYPE, {
|
|
48
|
-
name: 'shutdown',
|
|
49
|
-
permissionId: SERVER_SHUTDOWN_PERMISSION_ID,
|
|
50
|
-
});
|
|
51
|
-
export const TRUSTED_ORIGINS_GET_PERMISSION_ID: Identifier = SERVER_EXTENSION_TYPE.join('trusted_origins', 'get');
|
|
52
|
-
export const TRUSTED_ORIGINS_SET_PERMISSION_ID: Identifier = SERVER_EXTENSION_TYPE.join('trusted_origins', 'set');
|
|
53
|
-
const TRUSTED_HOSTS_REGISTRY_TYPE = RegistryType.createJson<Record<string, string>>(SERVER_EXTENSION_TYPE, {
|
|
54
|
-
name: 'trusted_hosts',
|
|
55
|
-
defaultValue: {},
|
|
56
|
-
permissions: {
|
|
57
|
-
read: TRUSTED_ORIGINS_GET_PERMISSION_ID,
|
|
58
|
-
write: TRUSTED_ORIGINS_SET_PERMISSION_ID,
|
|
59
|
-
},
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
export class ServerExtension implements Extension {
|
|
63
|
-
public readonly type: ExtensionType<ServerExtension> = SERVER_EXTENSION_TYPE;
|
|
64
|
-
public readonly apps: Table<App>;
|
|
65
|
-
public readonly index: Registry<AppIndex>;
|
|
66
|
-
public readonly trustedHosts: Registry<Record<string, string>>;
|
|
67
|
-
|
|
68
|
-
constructor(private readonly omu: Omu) {
|
|
69
|
-
this.apps = omu.tables.get(APP_TABLE_TYPE);
|
|
70
|
-
this.index = omu.registries.get(SERVER_INDEX_REGISTRY_TYPE);
|
|
71
|
-
this.trustedHosts = omu.registries.get(TRUSTED_HOSTS_REGISTRY_TYPE);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
public async shutdown(restart?: boolean): Promise<boolean> {
|
|
75
|
-
this.omu.endpoints.call(SHUTDOWN_ENDPOINT_TYPE, restart ?? false);
|
|
76
|
-
await new Promise<void>((resolve) => {
|
|
77
|
-
const unlisten = this.omu.network.event.disconnected.listen(() => {
|
|
78
|
-
resolve();
|
|
79
|
-
unlisten();
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
return true;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export class SessionObserver {
|
|
87
|
-
constructor(
|
|
88
|
-
public readonly onConnectCallbacks: Array<(app: App) => Promise<void> | void>,
|
|
89
|
-
public readonly onDisconnectCallbacks: Array<(app: App) => Promise<void> | void>,
|
|
90
|
-
) { }
|
|
91
|
-
|
|
92
|
-
public onConnect(callback: (app: App) => Promise<void> | void): void {
|
|
93
|
-
this.onConnectCallbacks.push(callback);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
public onDisconnect(callback: (app: App) => Promise<void> | void): void {
|
|
97
|
-
this.onDisconnectCallbacks.push(callback);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export type AppIndexRegistryMeta = {
|
|
102
|
-
name: LocalizedText;
|
|
103
|
-
note: LocalizedText;
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
export interface AppIndexRegistryJSON {
|
|
107
|
-
id: string;
|
|
108
|
-
meta?: AppIndexRegistryMeta;
|
|
109
|
-
apps: Record<string, AppJson>;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export class AppIndexRegistry {
|
|
113
|
-
constructor(
|
|
114
|
-
public id: Identifier,
|
|
115
|
-
public apps: IdentifierMap<App>,
|
|
116
|
-
public meta: AppIndexRegistryMeta | undefined,
|
|
117
|
-
) { }
|
|
118
|
-
|
|
119
|
-
public static build(options: { id: IntoId; meta: AppIndexRegistryMeta; apps: App[] }): AppIndexRegistry {
|
|
120
|
-
return new AppIndexRegistry(
|
|
121
|
-
Identifier.from(options.id),
|
|
122
|
-
new IdentifierMap(options.apps.map((app) => [app.id, app])),
|
|
123
|
-
options.meta,
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
public static fromJSON(json: AppIndexRegistryJSON): AppIndexRegistry {
|
|
128
|
-
const id = Identifier.fromKey(json['id']);
|
|
129
|
-
const apps = new IdentifierMap<App>();
|
|
130
|
-
for (const [idStr, appJSON] of Object.entries(json['apps'])) {
|
|
131
|
-
const id = Identifier.fromKey(idStr);
|
|
132
|
-
const app = App.deserialize(appJSON);
|
|
133
|
-
if (!id.isNamespaceEqual(app.id)) {
|
|
134
|
-
throw new Error(`App ID does not match the ID in the index. ${app.id} != ${id}`);
|
|
135
|
-
}
|
|
136
|
-
apps.set(id, app);
|
|
137
|
-
}
|
|
138
|
-
return new AppIndexRegistry(
|
|
139
|
-
id,
|
|
140
|
-
apps,
|
|
141
|
-
json.meta,
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
public toJSON(): AppIndexRegistryJSON {
|
|
146
|
-
return {
|
|
147
|
-
id: this.id.key(),
|
|
148
|
-
meta: this.meta,
|
|
149
|
-
apps: Object.fromEntries([...this.apps.entries()].map(([id, app]) => [
|
|
150
|
-
id.key(),
|
|
151
|
-
App.serialize(app),
|
|
152
|
-
])),
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
}
|
package/src/api/server/index.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export {
|
|
2
|
-
AppIndexRegistry,
|
|
3
|
-
SERVER_APPS_READ_PERMISSION_ID,
|
|
4
|
-
SERVER_SHUTDOWN_PERMISSION_ID,
|
|
5
|
-
TRUSTED_ORIGINS_GET_PERMISSION_ID,
|
|
6
|
-
TRUSTED_ORIGINS_SET_PERMISSION_ID,
|
|
7
|
-
type AppIndex,
|
|
8
|
-
type AppIndexEntry,
|
|
9
|
-
type AppIndexRegistryJSON,
|
|
10
|
-
} from './extension.js';
|
|
11
|
-
|