@kokimoki/app 3.1.3 → 3.1.5
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/README.md +1 -2
- package/dist/core/kokimoki-client.d.ts +4 -4
- package/dist/core/kokimoki-client.js +4 -4
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -2
- package/dist/utils/valtio.d.ts +2 -5
- package/dist/utils/valtio.js +4 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/kokimoki-ai.instructions.md +4 -2
- package/docs/kokimoki-dynamic-stores.instructions.md +3 -3
- package/docs/kokimoki-i18n.instructions.md +1 -1
- package/docs/kokimoki-sdk.instructions.md +46 -7
- package/package.json +15 -2
- package/dist/fields.d.ts +0 -110
- package/dist/fields.js +0 -158
- package/dist/kokimoki-ai.d.ts +0 -153
- package/dist/kokimoki-ai.js +0 -164
- package/dist/kokimoki-awareness.d.ts +0 -21
- package/dist/kokimoki-awareness.js +0 -48
- package/dist/kokimoki-client-refactored.d.ts +0 -80
- package/dist/kokimoki-client-refactored.js +0 -400
- package/dist/kokimoki-client.d.ts +0 -362
- package/dist/kokimoki-client.js +0 -823
- package/dist/kokimoki-leaderboard.d.ts +0 -175
- package/dist/kokimoki-leaderboard.js +0 -203
- package/dist/kokimoki-local-store.d.ts +0 -11
- package/dist/kokimoki-local-store.js +0 -40
- package/dist/kokimoki-queue.d.ts +0 -0
- package/dist/kokimoki-queue.js +0 -38
- package/dist/kokimoki-req-res.d.ts +0 -0
- package/dist/kokimoki-req-res.js +0 -198
- package/dist/kokimoki-schema.d.ts +0 -113
- package/dist/kokimoki-schema.js +0 -162
- package/dist/kokimoki-storage.d.ts +0 -156
- package/dist/kokimoki-storage.js +0 -208
- package/dist/kokimoki-store.d.ts +0 -23
- package/dist/kokimoki-store.js +0 -117
- package/dist/kokimoki-transaction.d.ts +0 -18
- package/dist/kokimoki-transaction.js +0 -143
- package/dist/kokimoki.min.d.ts +0 -1244
- package/dist/kokimoki.min.js +0 -19108
- package/dist/kokimoki.min.js.map +0 -1
- package/dist/llms.txt +0 -665
- package/dist/message-queue.d.ts +0 -8
- package/dist/message-queue.js +0 -19
- package/dist/room-subscription-mode.d.ts +0 -5
- package/dist/room-subscription-mode.js +0 -6
- package/dist/room-subscription.d.ts +0 -15
- package/dist/room-subscription.js +0 -52
- package/dist/synced-schema.d.ts +0 -74
- package/dist/synced-schema.js +0 -83
- package/dist/synced-store.d.ts +0 -10
- package/dist/synced-store.js +0 -9
- package/dist/synced-types.d.ts +0 -47
- package/dist/synced-types.js +0 -67
- package/dist/ws-message-reader.d.ts +0 -11
- package/dist/ws-message-reader.js +0 -36
- package/dist/ws-message-type copy.d.ts +0 -6
- package/dist/ws-message-type copy.js +0 -7
- package/dist/ws-message-type.d.ts +0 -11
- package/dist/ws-message-type.js +0 -12
- package/dist/ws-message-writer.d.ts +0 -9
- package/dist/ws-message-writer.js +0 -45
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { KokimokiStore } from "./kokimoki-store";
|
|
2
|
-
import type { KokimokiClient } from "./kokimoki-client";
|
|
3
|
-
export declare class RoomSubscription {
|
|
4
|
-
private kmClient;
|
|
5
|
-
readonly store: KokimokiStore<any>;
|
|
6
|
-
private _joined;
|
|
7
|
-
private _roomHash?;
|
|
8
|
-
private _onDisconnect;
|
|
9
|
-
constructor(kmClient: KokimokiClient, store: KokimokiStore<any>);
|
|
10
|
-
get roomName(): string;
|
|
11
|
-
get roomHash(): number;
|
|
12
|
-
get joined(): boolean;
|
|
13
|
-
applyInitialResponse(roomHash: number, initialUpdate?: Uint8Array): Promise<void>;
|
|
14
|
-
close(): void;
|
|
15
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import * as Y from "yjs";
|
|
2
|
-
import { RoomSubscriptionMode } from "./room-subscription-mode";
|
|
3
|
-
export class RoomSubscription {
|
|
4
|
-
kmClient;
|
|
5
|
-
store;
|
|
6
|
-
_joined = false;
|
|
7
|
-
_roomHash;
|
|
8
|
-
_onDisconnect = () => {
|
|
9
|
-
this._joined = false;
|
|
10
|
-
};
|
|
11
|
-
constructor(kmClient, store) {
|
|
12
|
-
this.kmClient = kmClient;
|
|
13
|
-
this.store = store;
|
|
14
|
-
kmClient.on("disconnected", this._onDisconnect);
|
|
15
|
-
}
|
|
16
|
-
get roomName() {
|
|
17
|
-
return this.store.roomName;
|
|
18
|
-
}
|
|
19
|
-
get roomHash() {
|
|
20
|
-
if (!this._roomHash) {
|
|
21
|
-
throw new Error("Room not joined");
|
|
22
|
-
}
|
|
23
|
-
return this._roomHash;
|
|
24
|
-
}
|
|
25
|
-
get joined() {
|
|
26
|
-
return this._joined;
|
|
27
|
-
}
|
|
28
|
-
async applyInitialResponse(roomHash, initialUpdate) {
|
|
29
|
-
this._roomHash = roomHash;
|
|
30
|
-
// Apply initial state
|
|
31
|
-
if (initialUpdate) {
|
|
32
|
-
Y.applyUpdate(this.store.doc, initialUpdate, this);
|
|
33
|
-
}
|
|
34
|
-
// Set defaults if doc is empty after sync (only possible in ReadWrite mode)
|
|
35
|
-
if (this.store.mode === RoomSubscriptionMode.ReadWrite) {
|
|
36
|
-
await this.kmClient.transact([this.store], ([state]) => {
|
|
37
|
-
if (!("_connections" in state)) {
|
|
38
|
-
state._connections = {};
|
|
39
|
-
}
|
|
40
|
-
for (const key in this.store.defaultValue) {
|
|
41
|
-
if (!state.hasOwnProperty(key)) {
|
|
42
|
-
state[key] = this.store.defaultValue[key];
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
this._joined = true;
|
|
48
|
-
}
|
|
49
|
-
close() {
|
|
50
|
-
this.kmClient.off("disconnected", this._onDisconnect);
|
|
51
|
-
}
|
|
52
|
-
}
|
package/dist/synced-schema.d.ts
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
export declare abstract class SyncedGeneric<T> {
|
|
2
|
-
abstract get defaultValue(): T;
|
|
3
|
-
abstract set defaultValue(value: T);
|
|
4
|
-
}
|
|
5
|
-
export declare class SyncedNumber extends SyncedGeneric<number> {
|
|
6
|
-
defaultValue: number;
|
|
7
|
-
constructor(defaultValue?: number);
|
|
8
|
-
}
|
|
9
|
-
declare function syncedNumber(defaultValue?: number): SyncedNumber;
|
|
10
|
-
export declare class SyncedString extends SyncedGeneric<string> {
|
|
11
|
-
defaultValue: string;
|
|
12
|
-
constructor(defaultValue?: string);
|
|
13
|
-
}
|
|
14
|
-
declare function syncedString(defaultValue?: string): SyncedString;
|
|
15
|
-
export declare class SyncedBoolean extends SyncedGeneric<boolean> {
|
|
16
|
-
defaultValue: boolean;
|
|
17
|
-
constructor(defaultValue?: boolean);
|
|
18
|
-
}
|
|
19
|
-
declare function syncedBoolean(defaultValue?: boolean): SyncedBoolean;
|
|
20
|
-
export declare class SyncedObject<
|
|
21
|
-
Data extends Record<string, SyncedGeneric<unknown>>,
|
|
22
|
-
> extends SyncedGeneric<{
|
|
23
|
-
[key in keyof Data]: Data[key]["defaultValue"];
|
|
24
|
-
}> {
|
|
25
|
-
fields: Data;
|
|
26
|
-
constructor(fields: Data);
|
|
27
|
-
get defaultValue(): {
|
|
28
|
-
[key in keyof Data]: Data[key]["defaultValue"];
|
|
29
|
-
};
|
|
30
|
-
set defaultValue(value: {
|
|
31
|
-
[key in keyof Data]: Data[key]["defaultValue"];
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
declare function syncedObject<
|
|
35
|
-
Data extends Record<string, SyncedGeneric<unknown>>,
|
|
36
|
-
>(schema: Data): SyncedObject<Data>;
|
|
37
|
-
export declare class SyncedMap<T extends SyncedGeneric<unknown>> {
|
|
38
|
-
schema: T;
|
|
39
|
-
defaultValue: {
|
|
40
|
-
[key: string]: T["defaultValue"];
|
|
41
|
-
};
|
|
42
|
-
constructor(
|
|
43
|
-
schema: T,
|
|
44
|
-
defaultValue?: {
|
|
45
|
-
[key: string]: T["defaultValue"];
|
|
46
|
-
},
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
declare function syncedMap<T extends SyncedGeneric<unknown>>(
|
|
50
|
-
schema: T,
|
|
51
|
-
defaultValue?: {
|
|
52
|
-
[key: string]: T["defaultValue"];
|
|
53
|
-
},
|
|
54
|
-
): SyncedMap<T>;
|
|
55
|
-
export declare class SyncedArray<
|
|
56
|
-
T extends SyncedGeneric<unknown>,
|
|
57
|
-
> extends SyncedGeneric<T["defaultValue"][]> {
|
|
58
|
-
schema: T;
|
|
59
|
-
defaultValue: T["defaultValue"][];
|
|
60
|
-
constructor(schema: T, defaultValue?: T["defaultValue"][]);
|
|
61
|
-
}
|
|
62
|
-
declare function syncedArray<T extends SyncedGeneric<unknown>>(
|
|
63
|
-
schema: T,
|
|
64
|
-
defaultValue?: T["defaultValue"][],
|
|
65
|
-
): SyncedArray<T>;
|
|
66
|
-
export declare const S: {
|
|
67
|
-
number: typeof syncedNumber;
|
|
68
|
-
string: typeof syncedString;
|
|
69
|
-
boolean: typeof syncedBoolean;
|
|
70
|
-
object: typeof syncedObject;
|
|
71
|
-
map: typeof syncedMap;
|
|
72
|
-
array: typeof syncedArray;
|
|
73
|
-
};
|
|
74
|
-
export {};
|
package/dist/synced-schema.js
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
export class SyncedGeneric {}
|
|
2
|
-
export class SyncedNumber extends SyncedGeneric {
|
|
3
|
-
defaultValue;
|
|
4
|
-
constructor(defaultValue = 0) {
|
|
5
|
-
super();
|
|
6
|
-
this.defaultValue = defaultValue;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
function syncedNumber(defaultValue = 0) {
|
|
10
|
-
return new SyncedNumber(defaultValue);
|
|
11
|
-
}
|
|
12
|
-
export class SyncedString extends SyncedGeneric {
|
|
13
|
-
defaultValue;
|
|
14
|
-
constructor(defaultValue = "") {
|
|
15
|
-
super();
|
|
16
|
-
this.defaultValue = defaultValue;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
function syncedString(defaultValue = "") {
|
|
20
|
-
return new SyncedString(defaultValue);
|
|
21
|
-
}
|
|
22
|
-
export class SyncedBoolean extends SyncedGeneric {
|
|
23
|
-
defaultValue;
|
|
24
|
-
constructor(defaultValue = false) {
|
|
25
|
-
super();
|
|
26
|
-
this.defaultValue = defaultValue;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
function syncedBoolean(defaultValue = false) {
|
|
30
|
-
return new SyncedBoolean(defaultValue);
|
|
31
|
-
}
|
|
32
|
-
export class SyncedObject extends SyncedGeneric {
|
|
33
|
-
fields;
|
|
34
|
-
constructor(fields) {
|
|
35
|
-
super();
|
|
36
|
-
this.fields = fields;
|
|
37
|
-
}
|
|
38
|
-
get defaultValue() {
|
|
39
|
-
return Object.entries(this.fields).reduce((acc, [key, field]) => {
|
|
40
|
-
acc[key] = field.defaultValue;
|
|
41
|
-
return acc;
|
|
42
|
-
}, {});
|
|
43
|
-
}
|
|
44
|
-
set defaultValue(value) {
|
|
45
|
-
for (const [key, field] of Object.entries(this.fields)) {
|
|
46
|
-
field.defaultValue = value[key];
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
function syncedObject(schema) {
|
|
51
|
-
return new SyncedObject(schema);
|
|
52
|
-
}
|
|
53
|
-
export class SyncedMap {
|
|
54
|
-
schema;
|
|
55
|
-
defaultValue;
|
|
56
|
-
constructor(schema, defaultValue = {}) {
|
|
57
|
-
this.schema = schema;
|
|
58
|
-
this.defaultValue = defaultValue;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
function syncedMap(schema, defaultValue = {}) {
|
|
62
|
-
return new SyncedMap(schema, defaultValue);
|
|
63
|
-
}
|
|
64
|
-
export class SyncedArray extends SyncedGeneric {
|
|
65
|
-
schema;
|
|
66
|
-
defaultValue;
|
|
67
|
-
constructor(schema, defaultValue = []) {
|
|
68
|
-
super();
|
|
69
|
-
this.schema = schema;
|
|
70
|
-
this.defaultValue = defaultValue;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
function syncedArray(schema, defaultValue = []) {
|
|
74
|
-
return new SyncedArray(schema, defaultValue);
|
|
75
|
-
}
|
|
76
|
-
export const S = {
|
|
77
|
-
number: syncedNumber,
|
|
78
|
-
string: syncedString,
|
|
79
|
-
boolean: syncedBoolean,
|
|
80
|
-
object: syncedObject,
|
|
81
|
-
map: syncedMap,
|
|
82
|
-
array: syncedArray,
|
|
83
|
-
};
|
package/dist/synced-store.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type * as Y from "yjs";
|
|
2
|
-
import type {
|
|
3
|
-
DocTypeDescription,
|
|
4
|
-
MappedTypeDescription,
|
|
5
|
-
} from "@syncedstore/core/types/doc";
|
|
6
|
-
export declare class SyncedStore<T extends DocTypeDescription> {
|
|
7
|
-
readonly data: MappedTypeDescription<T>;
|
|
8
|
-
readonly doc: Y.Doc;
|
|
9
|
-
constructor(initialState: T);
|
|
10
|
-
}
|
package/dist/synced-store.js
DELETED
package/dist/synced-types.d.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
export declare abstract class SyncedGeneric<T> {
|
|
2
|
-
abstract get defaultValue(): T;
|
|
3
|
-
abstract set defaultValue(value: T);
|
|
4
|
-
}
|
|
5
|
-
export declare class SyncedNumber extends SyncedGeneric<number> {
|
|
6
|
-
defaultValue: number;
|
|
7
|
-
constructor(defaultValue?: number);
|
|
8
|
-
}
|
|
9
|
-
export declare function syncedNumber(defaultValue?: number): SyncedNumber;
|
|
10
|
-
export declare class SyncedString extends SyncedGeneric<string> {
|
|
11
|
-
defaultValue: string;
|
|
12
|
-
constructor(defaultValue?: string);
|
|
13
|
-
}
|
|
14
|
-
export declare function syncedString(defaultValue?: string): SyncedString;
|
|
15
|
-
export declare class SyncedBoolean extends SyncedGeneric<boolean> {
|
|
16
|
-
defaultValue: boolean;
|
|
17
|
-
constructor(defaultValue?: boolean);
|
|
18
|
-
}
|
|
19
|
-
export declare function syncedBoolean(defaultValue?: boolean): SyncedBoolean;
|
|
20
|
-
export declare class SyncedMap<
|
|
21
|
-
Data extends Record<string, SyncedGeneric<unknown>>,
|
|
22
|
-
> extends SyncedGeneric<{
|
|
23
|
-
[key in keyof Data]: Data[key]["defaultValue"];
|
|
24
|
-
}> {
|
|
25
|
-
fields: Data;
|
|
26
|
-
constructor(fields: Data);
|
|
27
|
-
get defaultValue(): {
|
|
28
|
-
[key in keyof Data]: Data[key]["defaultValue"];
|
|
29
|
-
};
|
|
30
|
-
set defaultValue(value: {
|
|
31
|
-
[key in keyof Data]: Data[key]["defaultValue"];
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
export declare function syncedMap<
|
|
35
|
-
T extends Record<string, SyncedGeneric<unknown>>,
|
|
36
|
-
>(schema: T): SyncedMap<T>;
|
|
37
|
-
export declare class SyncedArray<
|
|
38
|
-
T extends SyncedGeneric<unknown>,
|
|
39
|
-
> extends SyncedGeneric<T["defaultValue"][]> {
|
|
40
|
-
schema: T;
|
|
41
|
-
defaultValue: T["defaultValue"][];
|
|
42
|
-
constructor(schema: T, defaultValue?: T["defaultValue"][]);
|
|
43
|
-
}
|
|
44
|
-
export declare function syncedArray<T extends SyncedGeneric<unknown>>(
|
|
45
|
-
schema: T,
|
|
46
|
-
defaultValue?: T["defaultValue"][],
|
|
47
|
-
): SyncedArray<T>;
|
package/dist/synced-types.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import * as Y from "yjs";
|
|
2
|
-
import { proxy as yjsProxy } from "valtio";
|
|
3
|
-
import { bind as yjsBind } from "valtio-yjs";
|
|
4
|
-
export class SyncedGeneric {}
|
|
5
|
-
export class SyncedNumber extends SyncedGeneric {
|
|
6
|
-
defaultValue;
|
|
7
|
-
constructor(defaultValue = 0) {
|
|
8
|
-
super();
|
|
9
|
-
this.defaultValue = defaultValue;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
export function syncedNumber(defaultValue = 0) {
|
|
13
|
-
return new SyncedNumber(defaultValue);
|
|
14
|
-
}
|
|
15
|
-
export class SyncedString extends SyncedGeneric {
|
|
16
|
-
defaultValue;
|
|
17
|
-
constructor(defaultValue = "") {
|
|
18
|
-
super();
|
|
19
|
-
this.defaultValue = defaultValue;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
export function syncedString(defaultValue = "") {
|
|
23
|
-
return new SyncedString(defaultValue);
|
|
24
|
-
}
|
|
25
|
-
export class SyncedBoolean extends SyncedGeneric {
|
|
26
|
-
defaultValue;
|
|
27
|
-
constructor(defaultValue = false) {
|
|
28
|
-
super();
|
|
29
|
-
this.defaultValue = defaultValue;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
export function syncedBoolean(defaultValue = false) {
|
|
33
|
-
return new SyncedBoolean(defaultValue);
|
|
34
|
-
}
|
|
35
|
-
export class SyncedMap extends SyncedGeneric {
|
|
36
|
-
fields;
|
|
37
|
-
constructor(fields) {
|
|
38
|
-
super();
|
|
39
|
-
this.fields = fields;
|
|
40
|
-
}
|
|
41
|
-
get defaultValue() {
|
|
42
|
-
return Object.entries(this.fields).reduce((acc, [key, field]) => {
|
|
43
|
-
acc[key] = field.defaultValue;
|
|
44
|
-
return acc;
|
|
45
|
-
}, {});
|
|
46
|
-
}
|
|
47
|
-
set defaultValue(value) {
|
|
48
|
-
for (const [key, field] of Object.entries(this.fields)) {
|
|
49
|
-
field.defaultValue = value[key];
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
export function syncedMap(schema) {
|
|
54
|
-
return new SyncedMap(schema);
|
|
55
|
-
}
|
|
56
|
-
export class SyncedArray extends SyncedGeneric {
|
|
57
|
-
schema;
|
|
58
|
-
defaultValue;
|
|
59
|
-
constructor(schema, defaultValue = []) {
|
|
60
|
-
super();
|
|
61
|
-
this.schema = schema;
|
|
62
|
-
this.defaultValue = defaultValue;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
export function syncedArray(schema, defaultValue = []) {
|
|
66
|
-
return new SyncedArray(schema, defaultValue);
|
|
67
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export declare class WsMessageReader {
|
|
2
|
-
private buffer;
|
|
3
|
-
private _view;
|
|
4
|
-
private _offset;
|
|
5
|
-
constructor(buffer: ArrayBuffer);
|
|
6
|
-
readInt32(): number;
|
|
7
|
-
readUint32(): number;
|
|
8
|
-
readString(): string;
|
|
9
|
-
readUint8Array(): Uint8Array;
|
|
10
|
-
get end(): boolean;
|
|
11
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
export class WsMessageReader {
|
|
2
|
-
buffer;
|
|
3
|
-
_view;
|
|
4
|
-
_offset = 0;
|
|
5
|
-
constructor(buffer) {
|
|
6
|
-
this.buffer = buffer;
|
|
7
|
-
this._view = new DataView(buffer);
|
|
8
|
-
}
|
|
9
|
-
readInt32() {
|
|
10
|
-
const value = this._view.getInt32(this._offset, true);
|
|
11
|
-
this._offset += 4;
|
|
12
|
-
return value;
|
|
13
|
-
}
|
|
14
|
-
readUint32() {
|
|
15
|
-
const value = this._view.getUint32(this._offset, true);
|
|
16
|
-
this._offset += 4;
|
|
17
|
-
return value;
|
|
18
|
-
}
|
|
19
|
-
readString() {
|
|
20
|
-
const length = this.readInt32();
|
|
21
|
-
let value = "";
|
|
22
|
-
for (let i = 0; i < length; i++) {
|
|
23
|
-
value += String.fromCharCode(this._view.getUint8(this._offset++));
|
|
24
|
-
}
|
|
25
|
-
return value;
|
|
26
|
-
}
|
|
27
|
-
readUint8Array() {
|
|
28
|
-
const length = this.readInt32();
|
|
29
|
-
const value = new Uint8Array(this.buffer, this._offset, length);
|
|
30
|
-
this._offset += length;
|
|
31
|
-
return value;
|
|
32
|
-
}
|
|
33
|
-
get end() {
|
|
34
|
-
return this._offset === this.buffer.byteLength;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export var WsMessageType;
|
|
2
|
-
(function (WsMessageType) {
|
|
3
|
-
WsMessageType[(WsMessageType["SubscribeReq"] = 1)] = "SubscribeReq";
|
|
4
|
-
WsMessageType[(WsMessageType["SubscribeRes"] = 2)] = "SubscribeRes";
|
|
5
|
-
WsMessageType[(WsMessageType["Transaction"] = 3)] = "Transaction";
|
|
6
|
-
WsMessageType[(WsMessageType["RoomUpdate"] = 4)] = "RoomUpdate";
|
|
7
|
-
})(WsMessageType || (WsMessageType = {}));
|
package/dist/ws-message-type.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export var WsMessageType;
|
|
2
|
-
(function (WsMessageType) {
|
|
3
|
-
WsMessageType[WsMessageType["SubscribeReq"] = 1] = "SubscribeReq";
|
|
4
|
-
WsMessageType[WsMessageType["SubscribeRes"] = 2] = "SubscribeRes";
|
|
5
|
-
WsMessageType[WsMessageType["Transaction"] = 3] = "Transaction";
|
|
6
|
-
WsMessageType[WsMessageType["RoomUpdate"] = 4] = "RoomUpdate";
|
|
7
|
-
WsMessageType[WsMessageType["Error"] = 5] = "Error";
|
|
8
|
-
WsMessageType[WsMessageType["Ping"] = 6] = "Ping";
|
|
9
|
-
WsMessageType[WsMessageType["Pong"] = 7] = "Pong";
|
|
10
|
-
WsMessageType[WsMessageType["UnsubscribeReq"] = 8] = "UnsubscribeReq";
|
|
11
|
-
WsMessageType[WsMessageType["UnsubscribeRes"] = 9] = "UnsubscribeRes";
|
|
12
|
-
})(WsMessageType || (WsMessageType = {}));
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare class WsMessageWriter {
|
|
2
|
-
private _parts;
|
|
3
|
-
writeInt32(value: number): void;
|
|
4
|
-
writeUint32(value: number): void;
|
|
5
|
-
writeString(value: string): void;
|
|
6
|
-
writeChar(value: string): void;
|
|
7
|
-
writeUint8Array(value: Uint8Array): void;
|
|
8
|
-
getBuffer(): ArrayBuffer;
|
|
9
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
export class WsMessageWriter {
|
|
2
|
-
_parts = [];
|
|
3
|
-
writeInt32(value) {
|
|
4
|
-
const buffer = new Uint8Array(4);
|
|
5
|
-
const view = new DataView(buffer.buffer);
|
|
6
|
-
view.setInt32(0, value, true);
|
|
7
|
-
this._parts.push(buffer);
|
|
8
|
-
}
|
|
9
|
-
writeUint32(value) {
|
|
10
|
-
const buffer = new Uint8Array(4);
|
|
11
|
-
const view = new DataView(buffer.buffer);
|
|
12
|
-
view.setUint32(0, value, true);
|
|
13
|
-
this._parts.push(buffer);
|
|
14
|
-
}
|
|
15
|
-
writeString(value) {
|
|
16
|
-
// Write length
|
|
17
|
-
this.writeInt32(value.length);
|
|
18
|
-
// Write chars
|
|
19
|
-
const buffer = new Uint8Array(value.length);
|
|
20
|
-
for (let i = 0; i < value.length; i++) {
|
|
21
|
-
buffer[i] = value.charCodeAt(i);
|
|
22
|
-
}
|
|
23
|
-
this._parts.push(buffer);
|
|
24
|
-
}
|
|
25
|
-
writeChar(value) {
|
|
26
|
-
const buffer = new Uint8Array(1);
|
|
27
|
-
buffer[0] = value.charCodeAt(0);
|
|
28
|
-
this._parts.push(buffer);
|
|
29
|
-
}
|
|
30
|
-
writeUint8Array(value) {
|
|
31
|
-
this.writeInt32(value.byteLength);
|
|
32
|
-
this._parts.push(value);
|
|
33
|
-
}
|
|
34
|
-
getBuffer() {
|
|
35
|
-
const size = this._parts.reduce((acc, part) => acc + part.byteLength, 0);
|
|
36
|
-
const buffer = new ArrayBuffer(size);
|
|
37
|
-
let offset = 0;
|
|
38
|
-
for (const part of this._parts) {
|
|
39
|
-
const view = new Uint8Array(buffer, offset);
|
|
40
|
-
view.set(part);
|
|
41
|
-
offset += part.byteLength;
|
|
42
|
-
}
|
|
43
|
-
return buffer;
|
|
44
|
-
}
|
|
45
|
-
}
|