@meshagent/meshagent 0.3.1 → 0.4.1
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/CHANGELOG.md +6 -0
- package/dist/browser/entrypoint.js +7956 -5611
- package/dist/browser/helpers.d.ts +10 -4
- package/dist/browser/helpers.js +14 -39
- package/dist/browser/index.d.ts +1 -0
- package/dist/browser/index.js +1 -0
- package/dist/browser/participant-token.d.ts +4 -4
- package/dist/browser/participant-token.js +4 -9
- package/dist/browser/protocol.d.ts +5 -1
- package/dist/browser/protocol.js +7 -2
- package/dist/browser/room-client.d.ts +4 -1
- package/dist/browser/room-client.js +2 -2
- package/dist/browser/sync-client.d.ts +5 -1
- package/dist/browser/sync-client.js +13 -2
- package/dist/esm/agent-client.d.ts +88 -0
- package/dist/esm/agent-client.js +166 -0
- package/dist/esm/agent.d.ts +103 -0
- package/dist/esm/agent.js +218 -0
- package/dist/esm/client.d.ts +90 -0
- package/dist/esm/client.js +443 -0
- package/dist/esm/completer.d.ts +9 -0
- package/dist/esm/completer.js +21 -0
- package/dist/esm/data-types.d.ts +44 -0
- package/dist/esm/data-types.js +110 -0
- package/dist/esm/database-client.d.ts +77 -0
- package/dist/esm/database-client.js +109 -0
- package/dist/esm/developer-client.d.ts +13 -0
- package/dist/esm/developer-client.js +31 -0
- package/dist/esm/document.d.ts +84 -0
- package/dist/esm/document.js +522 -0
- package/dist/esm/entrypoint.d.ts +49722 -0
- package/dist/esm/entrypoint.js +6313 -0
- package/dist/esm/event-emitter.d.ts +13 -0
- package/dist/esm/event-emitter.js +34 -0
- package/dist/esm/helpers.d.ts +32 -0
- package/dist/esm/helpers.js +46 -0
- package/dist/esm/index.d.ts +25 -0
- package/dist/esm/index.js +25 -0
- package/dist/esm/messaging-client.d.ts +76 -0
- package/dist/esm/messaging-client.js +241 -0
- package/dist/esm/participant-token.d.ts +36 -0
- package/dist/esm/participant-token.js +91 -0
- package/dist/esm/participant.d.ts +18 -0
- package/dist/esm/participant.js +36 -0
- package/dist/esm/protocol.d.ts +91 -0
- package/dist/esm/protocol.js +287 -0
- package/dist/esm/queues-client.d.ts +26 -0
- package/dist/esm/queues-client.js +42 -0
- package/dist/esm/requirement.d.ts +25 -0
- package/dist/esm/requirement.js +42 -0
- package/dist/esm/response.d.ts +60 -0
- package/dist/esm/response.js +128 -0
- package/dist/esm/room-client.d.ts +46 -0
- package/dist/esm/room-client.js +106 -0
- package/dist/esm/room-event.d.ts +60 -0
- package/dist/esm/room-event.js +72 -0
- package/dist/esm/room-server-client.d.ts +19 -0
- package/dist/esm/room-server-client.js +45 -0
- package/dist/esm/runtime.d.ts +6 -0
- package/dist/esm/runtime.js +1 -0
- package/dist/esm/schema.d.ts +83 -0
- package/dist/esm/schema.js +312 -0
- package/dist/esm/storage-client.d.ts +38 -0
- package/dist/esm/storage-client.js +79 -0
- package/dist/esm/stream-controller.d.ts +8 -0
- package/dist/esm/stream-controller.js +51 -0
- package/dist/esm/sync-client.d.ts +37 -0
- package/dist/esm/sync-client.js +125 -0
- package/dist/esm/utils.d.ts +14 -0
- package/dist/esm/utils.js +44 -0
- package/dist/node/entrypoint.js +9 -4
- package/dist/node/helpers.d.ts +10 -4
- package/dist/node/helpers.js +14 -39
- package/dist/node/index.d.ts +1 -0
- package/dist/node/index.js +1 -0
- package/dist/node/participant-token.d.ts +4 -4
- package/dist/node/participant-token.js +4 -9
- package/dist/node/protocol.d.ts +5 -1
- package/dist/node/protocol.js +7 -2
- package/dist/node/room-client.d.ts +4 -1
- package/dist/node/room-client.js +2 -2
- package/dist/node/sync-client.d.ts +5 -1
- package/dist/node/sync-client.js +13 -2
- package/package.json +4 -3
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Protocol } from "./protocol";
|
|
2
|
+
import { LocalParticipant } from "./participant";
|
|
3
|
+
import { SyncClient } from "./sync-client";
|
|
4
|
+
import { DeveloperClient } from "./developer-client";
|
|
5
|
+
import { StorageClient } from "./storage-client";
|
|
6
|
+
import { MessagingClient } from "./messaging-client";
|
|
7
|
+
import { QueuesClient } from "./queues-client";
|
|
8
|
+
import { DatabaseClient } from "./database-client";
|
|
9
|
+
import { AgentsClient } from "./agent-client";
|
|
10
|
+
import { RoomEvent } from "./room-event";
|
|
11
|
+
import { Response } from "./response";
|
|
12
|
+
interface RequestHeader {
|
|
13
|
+
[key: string]: any;
|
|
14
|
+
}
|
|
15
|
+
export declare class RoomClient {
|
|
16
|
+
protocol: Protocol;
|
|
17
|
+
readonly sync: SyncClient;
|
|
18
|
+
readonly storage: StorageClient;
|
|
19
|
+
readonly developer: DeveloperClient;
|
|
20
|
+
readonly messaging: MessagingClient;
|
|
21
|
+
readonly queues: QueuesClient;
|
|
22
|
+
readonly database: DatabaseClient;
|
|
23
|
+
readonly agents: AgentsClient;
|
|
24
|
+
private _pendingRequests;
|
|
25
|
+
private _ready;
|
|
26
|
+
private _localParticipant;
|
|
27
|
+
private _eventsController;
|
|
28
|
+
constructor({ protocol }: {
|
|
29
|
+
protocol: Protocol;
|
|
30
|
+
});
|
|
31
|
+
get localParticipant(): LocalParticipant | null;
|
|
32
|
+
get ready(): Promise<boolean>;
|
|
33
|
+
start({ onDone, onError }?: {
|
|
34
|
+
onDone?: () => void;
|
|
35
|
+
onError?: (error: Error) => void;
|
|
36
|
+
}): Promise<void>;
|
|
37
|
+
dispose(): void;
|
|
38
|
+
sendRequest(type: string, request: RequestHeader, data?: Uint8Array): Promise<Response>;
|
|
39
|
+
private _handleResponse;
|
|
40
|
+
private _handleRoomReady;
|
|
41
|
+
private _onParticipantInit;
|
|
42
|
+
private _handleParticipant;
|
|
43
|
+
emit(event: RoomEvent): void;
|
|
44
|
+
listen(): AsyncIterable<RoomEvent>;
|
|
45
|
+
}
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { Completer } from "./completer";
|
|
2
|
+
import { packMessage, unpackMessage } from "./utils";
|
|
3
|
+
import { LocalParticipant } from "./participant";
|
|
4
|
+
import { StreamController } from "./stream-controller";
|
|
5
|
+
import { SyncClient } from "./sync-client";
|
|
6
|
+
import { DeveloperClient } from "./developer-client";
|
|
7
|
+
import { StorageClient } from "./storage-client";
|
|
8
|
+
import { MessagingClient } from "./messaging-client";
|
|
9
|
+
import { QueuesClient } from "./queues-client";
|
|
10
|
+
import { DatabaseClient } from "./database-client";
|
|
11
|
+
import { AgentsClient } from "./agent-client";
|
|
12
|
+
import { ErrorResponse, unpackResponse } from "./response";
|
|
13
|
+
export class RoomClient {
|
|
14
|
+
constructor({ protocol }) {
|
|
15
|
+
this._pendingRequests = new Map();
|
|
16
|
+
this._ready = new Completer();
|
|
17
|
+
this._localParticipant = null;
|
|
18
|
+
this._eventsController = new StreamController();
|
|
19
|
+
this.protocol = protocol;
|
|
20
|
+
protocol.addHandler("room_ready", this._handleRoomReady.bind(this));
|
|
21
|
+
protocol.addHandler("connected", this._handleParticipant.bind(this));
|
|
22
|
+
protocol.addHandler("__response__", this._handleResponse.bind(this));
|
|
23
|
+
this.sync = new SyncClient({ room: this });
|
|
24
|
+
this.storage = new StorageClient({ room: this });
|
|
25
|
+
this.developer = new DeveloperClient({ room: this });
|
|
26
|
+
this.messaging = new MessagingClient({ room: this });
|
|
27
|
+
this.queues = new QueuesClient({ room: this });
|
|
28
|
+
this.database = new DatabaseClient({ room: this });
|
|
29
|
+
this.agents = new AgentsClient({ room: this });
|
|
30
|
+
}
|
|
31
|
+
get localParticipant() {
|
|
32
|
+
return this._localParticipant;
|
|
33
|
+
}
|
|
34
|
+
get ready() {
|
|
35
|
+
return this._ready.fut;
|
|
36
|
+
}
|
|
37
|
+
async start({ onDone, onError } = {}) {
|
|
38
|
+
this.sync.start({ onDone, onError });
|
|
39
|
+
await this.ready;
|
|
40
|
+
}
|
|
41
|
+
dispose() {
|
|
42
|
+
for (const prKey of this._pendingRequests.keys()) {
|
|
43
|
+
const pr = this._pendingRequests.get(prKey);
|
|
44
|
+
pr?.reject(new Error("Disposed"));
|
|
45
|
+
this._pendingRequests.delete(prKey);
|
|
46
|
+
}
|
|
47
|
+
this.sync.dispose();
|
|
48
|
+
this.protocol.dispose();
|
|
49
|
+
this._localParticipant = null;
|
|
50
|
+
}
|
|
51
|
+
async sendRequest(type, request, data) {
|
|
52
|
+
const requestId = this.protocol.getNextMessageId();
|
|
53
|
+
const pr = new Completer();
|
|
54
|
+
this._pendingRequests.set(requestId, pr);
|
|
55
|
+
const message = packMessage(request, data);
|
|
56
|
+
await this.protocol.send(type, message, requestId);
|
|
57
|
+
return await pr.fut;
|
|
58
|
+
}
|
|
59
|
+
async _handleResponse(protocol, messageId, type, data) {
|
|
60
|
+
if (!data) {
|
|
61
|
+
console.error("No data in response");
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const response = unpackResponse(data);
|
|
65
|
+
console.log("GOT RESPONSE", response);
|
|
66
|
+
if (!response) {
|
|
67
|
+
console.error("No response");
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (this._pendingRequests.has(messageId)) {
|
|
71
|
+
const pr = this._pendingRequests.get(messageId);
|
|
72
|
+
this._pendingRequests.delete(messageId);
|
|
73
|
+
if (response instanceof ErrorResponse) {
|
|
74
|
+
pr.reject(new Error(response.text));
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
pr.resolve(response);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
console.warn(`Received a response for a request that is not pending ${messageId}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
async _handleRoomReady(protocol, messageId, type, data) {
|
|
85
|
+
const [message, _] = unpackMessage(data);
|
|
86
|
+
this._ready.complete(message["room_name"]);
|
|
87
|
+
}
|
|
88
|
+
_onParticipantInit(participantId, attributes) {
|
|
89
|
+
this._localParticipant = new LocalParticipant(this, participantId);
|
|
90
|
+
for (const k in attributes) {
|
|
91
|
+
this._localParticipant.setAttribute(k, attributes[k]);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
async _handleParticipant(protocol, messageId, type, data) {
|
|
95
|
+
const [message, _] = unpackMessage(data);
|
|
96
|
+
switch (message["type"]) {
|
|
97
|
+
case "init": this._onParticipantInit(message["participantId"], message["attributes"]);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
emit(event) {
|
|
101
|
+
this._eventsController.add(event);
|
|
102
|
+
}
|
|
103
|
+
listen() {
|
|
104
|
+
return this._eventsController.stream;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export declare abstract class RoomEvent {
|
|
2
|
+
abstract get name(): string;
|
|
3
|
+
abstract get description(): string;
|
|
4
|
+
}
|
|
5
|
+
export declare class RoomMessage {
|
|
6
|
+
fromParticipantId: string;
|
|
7
|
+
type: string;
|
|
8
|
+
message: Record<string, any>;
|
|
9
|
+
local: boolean;
|
|
10
|
+
attachment?: Uint8Array;
|
|
11
|
+
constructor({ fromParticipantId, type, message, local, attachment }: {
|
|
12
|
+
fromParticipantId: string;
|
|
13
|
+
type: string;
|
|
14
|
+
message: Record<string, any>;
|
|
15
|
+
local?: boolean;
|
|
16
|
+
attachment?: Uint8Array;
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
export declare class RoomMessageEvent extends RoomEvent {
|
|
20
|
+
message: RoomMessage;
|
|
21
|
+
constructor({ message }: {
|
|
22
|
+
message: RoomMessage;
|
|
23
|
+
});
|
|
24
|
+
get name(): string;
|
|
25
|
+
get description(): string;
|
|
26
|
+
}
|
|
27
|
+
export declare class FileCreatedEvent extends RoomEvent {
|
|
28
|
+
path: string;
|
|
29
|
+
constructor({ path }: {
|
|
30
|
+
path: string;
|
|
31
|
+
});
|
|
32
|
+
get name(): string;
|
|
33
|
+
get description(): string;
|
|
34
|
+
}
|
|
35
|
+
export declare class FileDeletedEvent extends RoomEvent {
|
|
36
|
+
path: string;
|
|
37
|
+
constructor({ path }: {
|
|
38
|
+
path: string;
|
|
39
|
+
});
|
|
40
|
+
get name(): string;
|
|
41
|
+
get description(): string;
|
|
42
|
+
}
|
|
43
|
+
export declare class FileUpdatedEvent extends RoomEvent {
|
|
44
|
+
path: string;
|
|
45
|
+
constructor({ path }: {
|
|
46
|
+
path: string;
|
|
47
|
+
});
|
|
48
|
+
get name(): string;
|
|
49
|
+
get description(): string;
|
|
50
|
+
}
|
|
51
|
+
export declare class RoomLogEvent extends RoomEvent {
|
|
52
|
+
type: string;
|
|
53
|
+
data: Record<string, any>;
|
|
54
|
+
constructor({ type, data }: {
|
|
55
|
+
type: string;
|
|
56
|
+
data: Record<string, any>;
|
|
57
|
+
});
|
|
58
|
+
get name(): string;
|
|
59
|
+
get description(): string;
|
|
60
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export class RoomEvent {
|
|
2
|
+
}
|
|
3
|
+
export class RoomMessage {
|
|
4
|
+
constructor({ fromParticipantId, type, message, local = false, attachment }) {
|
|
5
|
+
this.fromParticipantId = fromParticipantId;
|
|
6
|
+
this.type = type;
|
|
7
|
+
this.message = message;
|
|
8
|
+
this.local = local;
|
|
9
|
+
this.attachment = attachment;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export class RoomMessageEvent extends RoomEvent {
|
|
13
|
+
constructor({ message }) {
|
|
14
|
+
super();
|
|
15
|
+
this.message = message;
|
|
16
|
+
}
|
|
17
|
+
get name() {
|
|
18
|
+
return this.message.type;
|
|
19
|
+
}
|
|
20
|
+
get description() {
|
|
21
|
+
return `a message was received ${JSON.stringify(this.message.message)}`;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export class FileCreatedEvent extends RoomEvent {
|
|
25
|
+
constructor({ path }) {
|
|
26
|
+
super();
|
|
27
|
+
this.path = path;
|
|
28
|
+
}
|
|
29
|
+
get name() {
|
|
30
|
+
return "file created";
|
|
31
|
+
}
|
|
32
|
+
get description() {
|
|
33
|
+
return `a file was created at the path ${this.path}`;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export class FileDeletedEvent extends RoomEvent {
|
|
37
|
+
constructor({ path }) {
|
|
38
|
+
super();
|
|
39
|
+
this.path = path;
|
|
40
|
+
}
|
|
41
|
+
get name() {
|
|
42
|
+
return "file deleted";
|
|
43
|
+
}
|
|
44
|
+
get description() {
|
|
45
|
+
return `a file was deleted at the path ${this.path}`;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export class FileUpdatedEvent extends RoomEvent {
|
|
49
|
+
constructor({ path }) {
|
|
50
|
+
super();
|
|
51
|
+
this.path = path;
|
|
52
|
+
}
|
|
53
|
+
get name() {
|
|
54
|
+
return "file updated";
|
|
55
|
+
}
|
|
56
|
+
get description() {
|
|
57
|
+
return `a file was updated at the path ${this.path}`;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
export class RoomLogEvent extends RoomEvent {
|
|
61
|
+
constructor({ type, data }) {
|
|
62
|
+
super();
|
|
63
|
+
this.type = type;
|
|
64
|
+
this.data = data;
|
|
65
|
+
}
|
|
66
|
+
get name() {
|
|
67
|
+
return this.type;
|
|
68
|
+
}
|
|
69
|
+
get description() {
|
|
70
|
+
return JSON.stringify(this.data);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { RuntimeDocument } from "./document";
|
|
2
|
+
import { MeshSchema } from "./schema";
|
|
3
|
+
export type Uint8List = Uint8Array;
|
|
4
|
+
export declare class RoomServerException extends Error {
|
|
5
|
+
constructor(message: string);
|
|
6
|
+
}
|
|
7
|
+
export declare class MeshDocument extends RuntimeDocument {
|
|
8
|
+
private _synchronized;
|
|
9
|
+
constructor({ schema, sendChangesToBackend }: {
|
|
10
|
+
schema: MeshSchema;
|
|
11
|
+
sendChangesToBackend?: (base64: string) => void;
|
|
12
|
+
});
|
|
13
|
+
onSendUpdateToBackend: (base64: string) => void;
|
|
14
|
+
onSendUpdateToClient: (base64: string) => void;
|
|
15
|
+
get synchronized(): Promise<boolean>;
|
|
16
|
+
get isSynchronized(): boolean;
|
|
17
|
+
setSynchronizedComplete(): void;
|
|
18
|
+
dispose(): void;
|
|
19
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { v4 as uuidv4 } from "uuid";
|
|
2
|
+
import { RuntimeDocument } from "./document";
|
|
3
|
+
import { Completer } from "./completer";
|
|
4
|
+
import { registerDocument, unregisterDocument, applyChanges, } from "./runtime";
|
|
5
|
+
export class RoomServerException extends Error {
|
|
6
|
+
constructor(message) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.name = "RoomServerException";
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export class MeshDocument extends RuntimeDocument {
|
|
12
|
+
constructor({ schema, sendChangesToBackend }) {
|
|
13
|
+
super({
|
|
14
|
+
id: uuidv4(),
|
|
15
|
+
schema,
|
|
16
|
+
sendChanges: (base64) => applyChanges(base64),
|
|
17
|
+
sendChangesToBackend,
|
|
18
|
+
});
|
|
19
|
+
this._synchronized = new Completer();
|
|
20
|
+
this.onSendUpdateToBackend = (base64) => {
|
|
21
|
+
const parsed = JSON.parse(base64);
|
|
22
|
+
if (this.sendChangesToBackend) {
|
|
23
|
+
this.sendChangesToBackend(parsed.data);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
this.onSendUpdateToClient = (base64) => {
|
|
27
|
+
const parsed = JSON.parse(base64);
|
|
28
|
+
this.receiveChanges(parsed.data);
|
|
29
|
+
};
|
|
30
|
+
registerDocument(this.id, null, false, this.onSendUpdateToBackend, this.onSendUpdateToClient);
|
|
31
|
+
}
|
|
32
|
+
get synchronized() {
|
|
33
|
+
return this._synchronized.fut;
|
|
34
|
+
}
|
|
35
|
+
get isSynchronized() {
|
|
36
|
+
return this._synchronized.completed;
|
|
37
|
+
}
|
|
38
|
+
setSynchronizedComplete() {
|
|
39
|
+
this._synchronized.complete(true);
|
|
40
|
+
}
|
|
41
|
+
dispose() {
|
|
42
|
+
super.dispose();
|
|
43
|
+
unregisterDocument(this.id);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { applyBackendChanges, applyChanges, registerDocument, unregisterDocument, } from './entrypoint.js';
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
export declare class MeshSchemaValidationException extends Error {
|
|
2
|
+
constructor(message: string);
|
|
3
|
+
}
|
|
4
|
+
export declare enum SimpleValue {
|
|
5
|
+
number = "number",
|
|
6
|
+
string = "string",
|
|
7
|
+
nullValue = "null",
|
|
8
|
+
boolean = "boolean"
|
|
9
|
+
}
|
|
10
|
+
export declare namespace SimpleValue {
|
|
11
|
+
function fromString(val: string): SimpleValue | null;
|
|
12
|
+
}
|
|
13
|
+
export declare abstract class ElementProperty {
|
|
14
|
+
readonly name: string;
|
|
15
|
+
readonly description?: string;
|
|
16
|
+
constructor({ name, description }: {
|
|
17
|
+
name: string;
|
|
18
|
+
description?: string;
|
|
19
|
+
});
|
|
20
|
+
abstract validate(schema: MeshSchema): void;
|
|
21
|
+
abstract toJson(): Record<string, any>;
|
|
22
|
+
}
|
|
23
|
+
export declare class ValueProperty extends ElementProperty {
|
|
24
|
+
readonly type: SimpleValue;
|
|
25
|
+
readonly enumValues?: any[];
|
|
26
|
+
constructor({ name, description, type, enumValues }: {
|
|
27
|
+
name: string;
|
|
28
|
+
description?: string;
|
|
29
|
+
type: SimpleValue;
|
|
30
|
+
enumValues?: any[];
|
|
31
|
+
});
|
|
32
|
+
validate(_: MeshSchema): void;
|
|
33
|
+
toJson(): Record<string, any>;
|
|
34
|
+
}
|
|
35
|
+
export declare class ChildProperty extends ElementProperty {
|
|
36
|
+
private readonly _childTagNames;
|
|
37
|
+
readonly ordered: boolean;
|
|
38
|
+
constructor({ name, description, childTagNames, ordered }: {
|
|
39
|
+
name: string;
|
|
40
|
+
description?: string;
|
|
41
|
+
childTagNames: string[];
|
|
42
|
+
ordered?: boolean;
|
|
43
|
+
});
|
|
44
|
+
validate(schema: MeshSchema): void;
|
|
45
|
+
isTagAllowed(tagName: string): boolean;
|
|
46
|
+
get childTagNames(): string[];
|
|
47
|
+
toJson(): Record<string, any>;
|
|
48
|
+
}
|
|
49
|
+
export declare class ElementType {
|
|
50
|
+
private readonly _tagName;
|
|
51
|
+
private readonly _properties;
|
|
52
|
+
private readonly _description?;
|
|
53
|
+
private readonly _propertyLookup;
|
|
54
|
+
private _childPropertyName?;
|
|
55
|
+
constructor(params: {
|
|
56
|
+
tagName: string;
|
|
57
|
+
description?: string;
|
|
58
|
+
properties: ElementProperty[];
|
|
59
|
+
});
|
|
60
|
+
static fromJson(json: Record<string, any>): ElementType;
|
|
61
|
+
toJson(): Record<string, any>;
|
|
62
|
+
validate(schema: MeshSchema): void;
|
|
63
|
+
get childPropertyName(): string | undefined;
|
|
64
|
+
get tagName(): string;
|
|
65
|
+
get description(): string | undefined;
|
|
66
|
+
get properties(): ElementProperty[];
|
|
67
|
+
property(name: string): ElementProperty;
|
|
68
|
+
}
|
|
69
|
+
export declare class MeshSchema {
|
|
70
|
+
private readonly _rootTagName;
|
|
71
|
+
private readonly _elements;
|
|
72
|
+
readonly elementsByTagName: Record<string, ElementType>;
|
|
73
|
+
constructor(params: {
|
|
74
|
+
rootTagName: string;
|
|
75
|
+
elements: ElementType[];
|
|
76
|
+
});
|
|
77
|
+
static fromJson(json: Record<string, any>): MeshSchema;
|
|
78
|
+
toJson(): Record<string, any>;
|
|
79
|
+
element(name: string): ElementType;
|
|
80
|
+
validate(): void;
|
|
81
|
+
get root(): ElementType;
|
|
82
|
+
get elements(): ElementType[];
|
|
83
|
+
}
|