@diory/client-js 0.2.0-rc18 → 0.2.0-rc19
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/connectionClient/connectionClient.d.ts +3 -3
- package/dist/connectionClient/connectionClient.js +4 -5
- package/dist/connectionClient/utils/debounce.d.ts +1 -1
- package/dist/dioryClient/dioryClient.js +3 -2
- package/package.json +1 -1
- package/src/connectionClient/connectionClient.ts +4 -5
- package/src/connectionClient/utils/debounce.ts +1 -1
- package/src/dioryClient/dioryClient.ts +3 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IDiographObject } from '@diograph/diograph';
|
|
2
|
-
import { IConnectionObject } from '@diory/diosphere-js';
|
|
2
|
+
import { IConnectionObject, IDiosphereObject } from '@diory/diosphere-js';
|
|
3
3
|
import { IConnectionClient, IDataClient } from '../types';
|
|
4
4
|
declare class ConnectionClient implements IConnectionClient {
|
|
5
5
|
type: string;
|
|
@@ -7,9 +7,9 @@ declare class ConnectionClient implements IConnectionClient {
|
|
|
7
7
|
connection: IConnectionObject;
|
|
8
8
|
constructor(dataClient: IDataClient, connection: IConnectionObject);
|
|
9
9
|
getDiosphere: () => Promise<any>;
|
|
10
|
-
saveDiosphere: () =>
|
|
10
|
+
saveDiosphere: (diosphereObject: IDiosphereObject) => Promise<boolean>;
|
|
11
11
|
getDiograph: () => Promise<any>;
|
|
12
|
-
saveDiograph: () =>
|
|
12
|
+
saveDiograph: (diographObject: IDiographObject) => Promise<boolean>;
|
|
13
13
|
generateDiograph: () => Promise<IDiographObject>;
|
|
14
14
|
}
|
|
15
15
|
export { ConnectionClient };
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ConnectionClient = void 0;
|
|
4
4
|
const path_browserify_1 = require("path-browserify");
|
|
5
5
|
const folder_generator_1 = require("@diograph/folder-generator");
|
|
6
|
-
const debounce_1 = require("./utils/debounce");
|
|
7
6
|
const DIOSPHERE_JSON = 'diosphere.json';
|
|
8
7
|
const DIOGRAPH_JSON = 'diograph.json';
|
|
9
8
|
class ConnectionClient {
|
|
@@ -13,21 +12,21 @@ class ConnectionClient {
|
|
|
13
12
|
const diosphereString = await this.client.readTextItem(path);
|
|
14
13
|
return JSON.parse(diosphereString);
|
|
15
14
|
};
|
|
16
|
-
this.saveDiosphere =
|
|
15
|
+
this.saveDiosphere = async (diosphereObject) => {
|
|
17
16
|
const path = (0, path_browserify_1.join)(this.connection.address, DIOSPHERE_JSON);
|
|
18
17
|
const diosphereString = JSON.stringify(diosphereObject, null, 2);
|
|
19
18
|
return this.client.writeItem(path, diosphereString);
|
|
20
|
-
}
|
|
19
|
+
};
|
|
21
20
|
this.getDiograph = async () => {
|
|
22
21
|
const path = (0, path_browserify_1.join)(this.connection.address, DIOGRAPH_JSON);
|
|
23
22
|
const diographString = await this.client.readTextItem(path);
|
|
24
23
|
return JSON.parse(diographString);
|
|
25
24
|
};
|
|
26
|
-
this.saveDiograph =
|
|
25
|
+
this.saveDiograph = async (diographObject) => {
|
|
27
26
|
const path = (0, path_browserify_1.join)(this.connection.address, DIOGRAPH_JSON);
|
|
28
27
|
const diographString = JSON.stringify(diographObject, null, 2);
|
|
29
28
|
return this.client.writeItem(path, diographString);
|
|
30
|
-
}
|
|
29
|
+
};
|
|
31
30
|
this.generateDiograph = async () => {
|
|
32
31
|
const { diograph } = await (0, folder_generator_1.generateDiograph)(this.connection.address, this.client);
|
|
33
32
|
return diograph.toObject();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function debounce(func: any, wait: number, immediate?: boolean): () =>
|
|
1
|
+
export declare function debounce(func: any, wait: number, immediate?: boolean): () => typeof func;
|
|
@@ -6,6 +6,7 @@ const diograph_1 = require("@diograph/diograph");
|
|
|
6
6
|
const getConnectionClients_1 = require("../utils/getConnectionClients");
|
|
7
7
|
const getDefaultDiosphere_1 = require("./getDefaultDiosphere");
|
|
8
8
|
const getDefaultDiograph_1 = require("./getDefaultDiograph");
|
|
9
|
+
const debounce_1 = require("../connectionClient/utils/debounce");
|
|
9
10
|
class DioryClient {
|
|
10
11
|
constructor(dataClients) {
|
|
11
12
|
this.dataClients = [];
|
|
@@ -121,8 +122,8 @@ class DioryClient {
|
|
|
121
122
|
this.dataClients = dataClients;
|
|
122
123
|
this.diosphere = new diosphere_js_1.Diosphere();
|
|
123
124
|
this.diograph = new diograph_1.Diograph();
|
|
124
|
-
this.diosphere.saveDiosphere = this.saveDiosphere;
|
|
125
|
-
this.diograph.saveDiograph = this.saveDiograph;
|
|
125
|
+
this.diosphere.saveDiosphere = (0, debounce_1.debounce)(this.saveDiosphere, 1000);
|
|
126
|
+
this.diograph.saveDiograph = (0, debounce_1.debounce)(this.saveDiograph, 1000);
|
|
126
127
|
}
|
|
127
128
|
}
|
|
128
129
|
exports.DioryClient = DioryClient;
|
package/package.json
CHANGED
|
@@ -4,7 +4,6 @@ import { generateDiograph } from '@diograph/folder-generator'
|
|
|
4
4
|
import { IDiographObject } from '@diograph/diograph'
|
|
5
5
|
import { IConnectionObject, IDiosphereObject } from '@diory/diosphere-js'
|
|
6
6
|
import { IConnectionClient, IDataClient } from '../types'
|
|
7
|
-
import { debounce } from './utils/debounce'
|
|
8
7
|
|
|
9
8
|
const DIOSPHERE_JSON = 'diosphere.json'
|
|
10
9
|
const DIOGRAPH_JSON = 'diograph.json'
|
|
@@ -26,11 +25,11 @@ class ConnectionClient implements IConnectionClient {
|
|
|
26
25
|
return JSON.parse(diosphereString)
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
saveDiosphere =
|
|
28
|
+
saveDiosphere = async (diosphereObject: IDiosphereObject) => {
|
|
30
29
|
const path = join(this.connection.address, DIOSPHERE_JSON)
|
|
31
30
|
const diosphereString = JSON.stringify(diosphereObject, null, 2)
|
|
32
31
|
return this.client.writeItem(path, diosphereString)
|
|
33
|
-
}
|
|
32
|
+
}
|
|
34
33
|
|
|
35
34
|
getDiograph = async () => {
|
|
36
35
|
const path = join(this.connection.address, DIOGRAPH_JSON)
|
|
@@ -38,11 +37,11 @@ class ConnectionClient implements IConnectionClient {
|
|
|
38
37
|
return JSON.parse(diographString)
|
|
39
38
|
}
|
|
40
39
|
|
|
41
|
-
saveDiograph =
|
|
40
|
+
saveDiograph = async (diographObject: IDiographObject) => {
|
|
42
41
|
const path = join(this.connection.address, DIOGRAPH_JSON)
|
|
43
42
|
const diographString = JSON.stringify(diographObject, null, 2)
|
|
44
43
|
return this.client.writeItem(path, diographString)
|
|
45
|
-
}
|
|
44
|
+
}
|
|
46
45
|
|
|
47
46
|
generateDiograph = async (): Promise<IDiographObject> => {
|
|
48
47
|
const { diograph } = await generateDiograph(this.connection.address, this.client)
|
|
@@ -13,6 +13,7 @@ import { getConnectionClients } from '../utils/getConnectionClients'
|
|
|
13
13
|
|
|
14
14
|
import { getDefaultDiosphere } from './getDefaultDiosphere'
|
|
15
15
|
import { getDefaultDiograph } from './getDefaultDiograph'
|
|
16
|
+
import { debounce } from '../connectionClient/utils/debounce'
|
|
16
17
|
|
|
17
18
|
class DioryClient implements IDioryClient {
|
|
18
19
|
dataClients: IDataClient[] = []
|
|
@@ -28,8 +29,8 @@ class DioryClient implements IDioryClient {
|
|
|
28
29
|
this.diosphere = new Diosphere()
|
|
29
30
|
this.diograph = new Diograph()
|
|
30
31
|
|
|
31
|
-
this.diosphere.saveDiosphere = this.saveDiosphere
|
|
32
|
-
this.diograph.saveDiograph = this.saveDiograph
|
|
32
|
+
this.diosphere.saveDiosphere = debounce(this.saveDiosphere, 1000)
|
|
33
|
+
this.diograph.saveDiograph = debounce(this.saveDiograph, 1000)
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
selectRoom = (roomObject: IRoomObject): IRoom => {
|