@diory/client-js 0.4.0-rc2 → 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/dist/dioryClient/dioryClient.d.ts +2 -3
- package/dist/dioryClient/dioryClient.js +8 -5
- package/dist/types.d.ts +2 -2
- package/dist/utils/addDefaultDiograph.d.ts +1 -1
- package/dist/utils/addDefaultRoom.d.ts +1 -1
- package/package.json +10 -9
- package/src/dioryClient/dioryClient.ts +26 -7
- package/src/types.ts +2 -2
- package/src/utils/addDefaultDiograph.ts +1 -1
- package/src/utils/addDefaultRoom.ts +1 -1
- package/dist/connectionClient/connectionClient.d.ts +0 -17
- package/dist/connectionClient/connectionClient.js +0 -95
- package/dist/connectionClient/connectionClient.spec.d.ts +0 -0
- package/dist/connectionClient/connectionClient.spec.js +0 -18
- package/dist/connectionClient/utils/debounce.d.ts +0 -1
- package/dist/connectionClient/utils/debounce.js +0 -22
- package/dist/dioryClient/addDefaultDiograph.d.ts +0 -2
- package/dist/dioryClient/addDefaultDiograph.js +0 -17
- package/dist/dioryClient/addDefaultRoom.d.ts +0 -5
- package/dist/dioryClient/addDefaultRoom.js +0 -13
- package/dist/dioryClient/defaultDiograph.json +0 -24
- package/dist/dioryClient/defaultDiosphere.d.ts +0 -21
- package/dist/dioryClient/defaultDiosphere.js +0 -26
- package/dist/dioryClient/defaultDiosphere.json +0 -23
- package/dist/dioryClient/getDefaultDiograph.d.ts +0 -2
- package/dist/dioryClient/getDefaultDiograph.js +0 -20
- package/dist/dioryClient/getDefaultDiosphere.d.ts +0 -2
- package/dist/dioryClient/getDefaultDiosphere.js +0 -16
- package/dist/utils/debounce.d.ts +0 -1
- package/dist/utils/debounce.js +0 -24
- package/dist/utils/getConnectionClients.d.ts +0 -7
- package/dist/utils/getConnectionClients.js +0 -16
- package/src/utils/debounce.ts +0 -18
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { IConnectionObject, IDiosphere, IRoom, IRoomObject } from '@diory/
|
|
2
|
-
import { IDiograph, IDiory, IDioryObject } from '@diograph/diograph';
|
|
3
|
-
import { IDataClient } from '@diograph/local-client';
|
|
1
|
+
import { IConnectionObject, IDiosphere, IRoom, IRoomObject, IDiograph, IDiory, IDioryObject, IDataClient } from '@diory/types';
|
|
4
2
|
import { IDioryClient } from '../types';
|
|
5
3
|
declare class DioryClient implements IDioryClient {
|
|
4
|
+
dataClients: IDataClient[];
|
|
6
5
|
diosphere: IDiosphere;
|
|
7
6
|
diograph: IDiograph;
|
|
8
7
|
room?: IRoom;
|
|
@@ -3,14 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DioryClient = void 0;
|
|
4
4
|
const diosphere_js_1 = require("@diory/diosphere-js");
|
|
5
5
|
const diograph_1 = require("@diograph/diograph");
|
|
6
|
-
const
|
|
6
|
+
const connection_client_js_1 = require("@diory/connection-client-js");
|
|
7
7
|
const addDefaultRoom_1 = require("../utils/addDefaultRoom");
|
|
8
8
|
const addDefaultDiograph_1 = require("../utils/addDefaultDiograph");
|
|
9
9
|
class DioryClient {
|
|
10
10
|
constructor(dataClients) {
|
|
11
11
|
this.initialiseDiosphere = async (connections) => {
|
|
12
12
|
console.info('initialiseDiosphere: connections', connections);
|
|
13
|
-
this.
|
|
13
|
+
const connectionClient = new connection_client_js_1.ConnectionClient(this.dataClients, connections);
|
|
14
|
+
this.diosphere.connect(connectionClient);
|
|
14
15
|
await this.diosphere.getDiosphere();
|
|
15
16
|
if (!Object.keys(this.diosphere.rooms)) {
|
|
16
17
|
(0, addDefaultRoom_1.addDefaultRoom)(this.diosphere, connections);
|
|
@@ -23,7 +24,8 @@ class DioryClient {
|
|
|
23
24
|
console.info('initialiseDiograph: room', roomObject);
|
|
24
25
|
this.selectRoom(roomObject);
|
|
25
26
|
if ((_a = this.room) === null || _a === void 0 ? void 0 : _a.connections) {
|
|
26
|
-
this.
|
|
27
|
+
const connectionClient = new connection_client_js_1.ConnectionClient(this.dataClients, (_b = this.room) === null || _b === void 0 ? void 0 : _b.connections);
|
|
28
|
+
this.diograph.connect(connectionClient);
|
|
27
29
|
await this.diograph.getDiograph();
|
|
28
30
|
if (!Object.keys(this.diograph.diograph)) {
|
|
29
31
|
(0, addDefaultDiograph_1.addDefaultDiograph)(this.diograph);
|
|
@@ -38,8 +40,9 @@ class DioryClient {
|
|
|
38
40
|
this.focusDiory = (dioryObject) => {
|
|
39
41
|
return (this.diory = this.diograph.getDiory(dioryObject));
|
|
40
42
|
};
|
|
41
|
-
this.
|
|
42
|
-
this.
|
|
43
|
+
this.dataClients = dataClients;
|
|
44
|
+
this.diosphere = new diosphere_js_1.Diosphere();
|
|
45
|
+
this.diograph = new diograph_1.Diograph();
|
|
43
46
|
}
|
|
44
47
|
}
|
|
45
48
|
exports.DioryClient = DioryClient;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IConnectionObject, IDiosphere, IRoom, IRoomObject } from '@diory/
|
|
2
|
-
import { IDiograph, IDiory, IDioryObject } from '@
|
|
1
|
+
import { IConnectionObject, IDiosphere, IRoom, IRoomObject } from '@diory/types';
|
|
2
|
+
import { IDiograph, IDiory, IDioryObject } from '@diory/types';
|
|
3
3
|
export interface IDioryClient {
|
|
4
4
|
diosphere: IDiosphere;
|
|
5
5
|
diograph: IDiograph;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { IDiograph } from '@
|
|
1
|
+
import { IDiograph } from '@diory/types';
|
|
2
2
|
export declare const addDefaultDiograph: (diograph: IDiograph) => void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { IConnectionObject, IDiosphere } from '@diory/
|
|
1
|
+
import { IConnectionObject, IDiosphere } from '@diory/types';
|
|
2
2
|
export declare const addDefaultRoom: (diosphere: IDiosphere, connections: IConnectionObject[]) => void;
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@diory/client-js",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"author": "Olli-Pekka Pohjola <op@diory.me>, Jouni Alanen <jouni@diory.me>",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@diograph/diograph": "^0.4.
|
|
10
|
-
"@
|
|
11
|
-
"@
|
|
12
|
-
"@diory/diosphere-js": "^0.4.0-rc1",
|
|
9
|
+
"@diograph/diograph": "^0.4.1",
|
|
10
|
+
"@diory/connection-client-js": "^0.4.1",
|
|
11
|
+
"@diory/diosphere-js": "^0.4.1",
|
|
13
12
|
"path-browserify": "^1.0.1",
|
|
14
13
|
"uuid": "8.3.2"
|
|
15
14
|
},
|
|
16
15
|
"devDependencies": {
|
|
16
|
+
"@diory/types": "^0.4.2",
|
|
17
17
|
"@types/jest": "^27.4.0",
|
|
18
18
|
"@types/path-browserify": "^1.0.2",
|
|
19
19
|
"@types/uuid": "8.3.2",
|
|
@@ -41,14 +41,15 @@
|
|
|
41
41
|
},
|
|
42
42
|
"repository": {
|
|
43
43
|
"type": "git",
|
|
44
|
-
"url": "git+https://github.com/DioryMe/
|
|
44
|
+
"url": "git+https://github.com/DioryMe/diory-client-js.git"
|
|
45
45
|
},
|
|
46
46
|
"keywords": [
|
|
47
47
|
"diory",
|
|
48
|
-
"diosphere"
|
|
48
|
+
"diosphere",
|
|
49
|
+
"diograph"
|
|
49
50
|
],
|
|
50
51
|
"bugs": {
|
|
51
|
-
"url": "https://github.com/DioryMe/
|
|
52
|
+
"url": "https://github.com/DioryMe/diory-client-js/issues"
|
|
52
53
|
},
|
|
53
|
-
"homepage": "https://github.com/DioryMe/
|
|
54
|
+
"homepage": "https://github.com/DioryMe/diory-client-js#readme"
|
|
54
55
|
}
|
|
@@ -1,6 +1,18 @@
|
|
|
1
|
-
import { Diosphere
|
|
2
|
-
import { Diograph
|
|
3
|
-
import {
|
|
1
|
+
import { Diosphere } from '@diory/diosphere-js'
|
|
2
|
+
import { Diograph } from '@diograph/diograph'
|
|
3
|
+
import { ConnectionClient } from '@diory/connection-client-js'
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
IConnectionObject,
|
|
7
|
+
IDiosphere,
|
|
8
|
+
IRoom,
|
|
9
|
+
IRoomObject,
|
|
10
|
+
IDiograph,
|
|
11
|
+
IDiory,
|
|
12
|
+
IDioryObject,
|
|
13
|
+
IDataClient,
|
|
14
|
+
IConnectionClient,
|
|
15
|
+
} from '@diory/types'
|
|
4
16
|
|
|
5
17
|
import { IDioryClient } from '../types'
|
|
6
18
|
|
|
@@ -8,20 +20,23 @@ import { addDefaultRoom } from '../utils/addDefaultRoom'
|
|
|
8
20
|
import { addDefaultDiograph } from '../utils/addDefaultDiograph'
|
|
9
21
|
|
|
10
22
|
class DioryClient implements IDioryClient {
|
|
23
|
+
dataClients: IDataClient[]
|
|
11
24
|
diosphere: IDiosphere
|
|
12
25
|
diograph: IDiograph
|
|
13
26
|
room?: IRoom
|
|
14
27
|
diory?: IDiory
|
|
15
28
|
|
|
16
29
|
constructor(dataClients: IDataClient[]) {
|
|
17
|
-
this.
|
|
18
|
-
this.
|
|
30
|
+
this.dataClients = dataClients
|
|
31
|
+
this.diosphere = new Diosphere()
|
|
32
|
+
this.diograph = new Diograph()
|
|
19
33
|
}
|
|
20
34
|
|
|
21
35
|
initialiseDiosphere = async (connections: IConnectionObject[]): Promise<IDiosphere> => {
|
|
22
36
|
console.info('initialiseDiosphere: connections', connections)
|
|
23
37
|
|
|
24
|
-
this.
|
|
38
|
+
const connectionClient: IConnectionClient = new ConnectionClient(this.dataClients, connections)
|
|
39
|
+
this.diosphere.connect(connectionClient)
|
|
25
40
|
await this.diosphere.getDiosphere()
|
|
26
41
|
|
|
27
42
|
if (!Object.keys(this.diosphere.rooms)) {
|
|
@@ -38,7 +53,11 @@ class DioryClient implements IDioryClient {
|
|
|
38
53
|
this.selectRoom(roomObject)
|
|
39
54
|
|
|
40
55
|
if (this.room?.connections) {
|
|
41
|
-
|
|
56
|
+
const connectionClient: IConnectionClient = new ConnectionClient(
|
|
57
|
+
this.dataClients,
|
|
58
|
+
this.room?.connections,
|
|
59
|
+
)
|
|
60
|
+
this.diograph.connect(connectionClient)
|
|
42
61
|
await this.diograph.getDiograph()
|
|
43
62
|
|
|
44
63
|
if (!Object.keys(this.diograph.diograph)) {
|
package/src/types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IConnectionObject, IDiosphere, IRoom, IRoomObject } from '@diory/
|
|
2
|
-
import { IDiograph, IDiory, IDioryObject } from '@
|
|
1
|
+
import { IConnectionObject, IDiosphere, IRoom, IRoomObject } from '@diory/types'
|
|
2
|
+
import { IDiograph, IDiory, IDioryObject } from '@diory/types'
|
|
3
3
|
|
|
4
4
|
export interface IDioryClient {
|
|
5
5
|
diosphere: IDiosphere
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { IDiographObject } from '@diograph/diograph'
|
|
2
|
-
import { IConnectionObject, IDiosphereObject } from '@diory/diosphere-js'
|
|
3
|
-
import { IDataClient } from '@diograph/local-client'
|
|
4
|
-
import { IConnectionClient } from '../types'
|
|
5
|
-
declare class ConnectionClient implements IConnectionClient {
|
|
6
|
-
dataClients: IDataClient[]
|
|
7
|
-
connections: IConnectionObject[]
|
|
8
|
-
constructor(dataClients: IDataClient[])
|
|
9
|
-
initialiseConnections: (connections?: IConnectionObject[]) => IConnectionClient
|
|
10
|
-
findDataClient: ({ client }: IConnectionObject) => IDataClient | undefined
|
|
11
|
-
getDiosphere: () => Promise<IDiosphereObject | undefined>
|
|
12
|
-
saveDiosphere: (diosphereObject: IDiosphereObject) => Promise<void>
|
|
13
|
-
getDiograph: () => Promise<IDiographObject | undefined>
|
|
14
|
-
saveDiograph: (diographObject: IDiographObject) => Promise<void>
|
|
15
|
-
generateDiograph: () => Promise<IDiographObject>
|
|
16
|
-
}
|
|
17
|
-
export { ConnectionClient }
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
Object.defineProperty(exports, '__esModule', { value: true })
|
|
3
|
-
exports.ConnectionClient = void 0
|
|
4
|
-
const path_browserify_1 = require('path-browserify')
|
|
5
|
-
const folder_generator_1 = require('@diograph/folder-generator')
|
|
6
|
-
const DIOSPHERE_JSON = 'diosphere.json'
|
|
7
|
-
const DIOGRAPH_JSON = 'diograph.json'
|
|
8
|
-
class ConnectionClient {
|
|
9
|
-
constructor(dataClients) {
|
|
10
|
-
this.connections = []
|
|
11
|
-
this.initialiseConnections = (connections = []) => {
|
|
12
|
-
this.connections = connections
|
|
13
|
-
return this
|
|
14
|
-
}
|
|
15
|
-
this.findDataClient = ({ client }) => {
|
|
16
|
-
return this.dataClients.find(({ type }) => type === client)
|
|
17
|
-
}
|
|
18
|
-
this.getDiosphere = async () => {
|
|
19
|
-
let diosphereObject
|
|
20
|
-
await Promise.all(
|
|
21
|
-
this.connections.map(async (connection) => {
|
|
22
|
-
const client = this.findDataClient(connection)
|
|
23
|
-
if (client) {
|
|
24
|
-
const path = (0, path_browserify_1.join)(connection.address, DIOSPHERE_JSON)
|
|
25
|
-
const diosphereString = await client.readTextItem(path)
|
|
26
|
-
diosphereObject = JSON.parse(diosphereString)
|
|
27
|
-
}
|
|
28
|
-
}),
|
|
29
|
-
)
|
|
30
|
-
// @ts-ignore
|
|
31
|
-
return diosphereObject
|
|
32
|
-
}
|
|
33
|
-
this.saveDiosphere = async (diosphereObject) => {
|
|
34
|
-
await Promise.all(
|
|
35
|
-
this.connections.map(async (connection) => {
|
|
36
|
-
const client = this.findDataClient(connection)
|
|
37
|
-
if (client) {
|
|
38
|
-
const path = (0, path_browserify_1.join)(connection.address, DIOSPHERE_JSON)
|
|
39
|
-
const diosphereString = JSON.stringify(diosphereObject, null, 2)
|
|
40
|
-
return client.writeItem(path, diosphereString)
|
|
41
|
-
}
|
|
42
|
-
}),
|
|
43
|
-
)
|
|
44
|
-
return
|
|
45
|
-
}
|
|
46
|
-
this.getDiograph = async () => {
|
|
47
|
-
let diographObject
|
|
48
|
-
await Promise.all(
|
|
49
|
-
this.connections.map(async (connection) => {
|
|
50
|
-
const client = this.findDataClient(connection)
|
|
51
|
-
if (client) {
|
|
52
|
-
const path = (0, path_browserify_1.join)(connection.address, DIOGRAPH_JSON)
|
|
53
|
-
const diographString = await client.readTextItem(path)
|
|
54
|
-
diographObject = JSON.parse(diographString)
|
|
55
|
-
}
|
|
56
|
-
}),
|
|
57
|
-
)
|
|
58
|
-
// @ts-ignore
|
|
59
|
-
return diographObject
|
|
60
|
-
}
|
|
61
|
-
this.saveDiograph = async (diographObject) => {
|
|
62
|
-
await Promise.all(
|
|
63
|
-
this.connections.map(async (connection) => {
|
|
64
|
-
const client = this.findDataClient(connection)
|
|
65
|
-
if (client) {
|
|
66
|
-
const path = (0, path_browserify_1.join)(connection.address, DIOGRAPH_JSON)
|
|
67
|
-
const diosphereString = JSON.stringify(diographObject, null, 2)
|
|
68
|
-
return client.writeItem(path, diosphereString)
|
|
69
|
-
}
|
|
70
|
-
}),
|
|
71
|
-
)
|
|
72
|
-
return
|
|
73
|
-
}
|
|
74
|
-
this.generateDiograph = async () => {
|
|
75
|
-
let diographObject
|
|
76
|
-
await Promise.all(
|
|
77
|
-
this.connections.map(async (connection) => {
|
|
78
|
-
const client = this.findDataClient(connection)
|
|
79
|
-
if (client) {
|
|
80
|
-
const { diograph } = await (0, folder_generator_1.generateDiograph)(
|
|
81
|
-
connection.address,
|
|
82
|
-
client,
|
|
83
|
-
)
|
|
84
|
-
diographObject = diograph.toObject()
|
|
85
|
-
return
|
|
86
|
-
}
|
|
87
|
-
}),
|
|
88
|
-
)
|
|
89
|
-
// @ts-ignore
|
|
90
|
-
return diographObject
|
|
91
|
-
}
|
|
92
|
-
this.dataClients = dataClients
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
exports.ConnectionClient = ConnectionClient
|
|
File without changes
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
describe('connectionClient', () => {
|
|
3
|
-
describe('construct()', () => {
|
|
4
|
-
it('should construct with dataClient and connection', () => {
|
|
5
|
-
expect(true).toEqual(true)
|
|
6
|
-
})
|
|
7
|
-
})
|
|
8
|
-
describe('getDiosphere()', () => {
|
|
9
|
-
it('should get diosphere', () => {
|
|
10
|
-
expect(true).toEqual(true)
|
|
11
|
-
})
|
|
12
|
-
})
|
|
13
|
-
describe('saveDiosphere()', () => {
|
|
14
|
-
it('should save diosphere object', () => {
|
|
15
|
-
expect(true).toEqual(true)
|
|
16
|
-
})
|
|
17
|
-
})
|
|
18
|
-
})
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function debounce(func: any, wait: number, immediate?: boolean): () => typeof func
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
Object.defineProperty(exports, '__esModule', { value: true })
|
|
3
|
-
exports.debounce = void 0
|
|
4
|
-
function debounce(func, wait, immediate = false) {
|
|
5
|
-
let timeout
|
|
6
|
-
// eslint-disable-next-line func-names
|
|
7
|
-
return () => {
|
|
8
|
-
// @ts-ignore
|
|
9
|
-
const context = this
|
|
10
|
-
const args = arguments
|
|
11
|
-
// eslint-disable-next-line func-names
|
|
12
|
-
const later = function () {
|
|
13
|
-
timeout = null
|
|
14
|
-
if (!immediate) func.apply(context, args)
|
|
15
|
-
}
|
|
16
|
-
const callNow = immediate && !timeout
|
|
17
|
-
clearTimeout(timeout)
|
|
18
|
-
timeout = setTimeout(later, wait)
|
|
19
|
-
if (callNow) func.apply(context, args)
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
exports.debounce = debounce
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
Object.defineProperty(exports, '__esModule', { value: true })
|
|
3
|
-
exports.addDefaultDiograph = void 0
|
|
4
|
-
const addDefaultDiograph = (diograph) => {
|
|
5
|
-
const diory = diograph.addDiory({
|
|
6
|
-
text: 'Welcome to Diory',
|
|
7
|
-
latlng: '60.01366036242365, 20.007133483886722',
|
|
8
|
-
})
|
|
9
|
-
diograph.addDiory(
|
|
10
|
-
{
|
|
11
|
-
text: 'Root diory',
|
|
12
|
-
links: [{ id: diory.id }],
|
|
13
|
-
},
|
|
14
|
-
'/',
|
|
15
|
-
)
|
|
16
|
-
}
|
|
17
|
-
exports.addDefaultDiograph = addDefaultDiograph
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
Object.defineProperty(exports, '__esModule', { value: true })
|
|
3
|
-
exports.addDefaultRoom = void 0
|
|
4
|
-
const addDefaultRoom = (diosphere, connections) => {
|
|
5
|
-
diosphere.addRoom(
|
|
6
|
-
{
|
|
7
|
-
text: 'Home room',
|
|
8
|
-
connections,
|
|
9
|
-
},
|
|
10
|
-
'/',
|
|
11
|
-
)
|
|
12
|
-
}
|
|
13
|
-
exports.addDefaultRoom = addDefaultRoom
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"/": {
|
|
3
|
-
"id": "welcome-root-diory"
|
|
4
|
-
},
|
|
5
|
-
"welcome-root-diory": {
|
|
6
|
-
"id": "welcome-root-diory",
|
|
7
|
-
"text": "Room",
|
|
8
|
-
"image": "",
|
|
9
|
-
"links": [
|
|
10
|
-
{
|
|
11
|
-
"id": "welcome-diory"
|
|
12
|
-
}
|
|
13
|
-
],
|
|
14
|
-
"modified": "2020-01-03T14:03:04.751Z"
|
|
15
|
-
},
|
|
16
|
-
"welcome-diory": {
|
|
17
|
-
"id": "welcome-diory",
|
|
18
|
-
"image": "",
|
|
19
|
-
"modified": "2020-01-03T14:03:04.751Z",
|
|
20
|
-
"text": "Welcome to Diory",
|
|
21
|
-
"latitude": 60.01366036242365,
|
|
22
|
-
"longitude": 20.007133483886722
|
|
23
|
-
}
|
|
24
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export declare const diosphere: {
|
|
2
|
-
rooms: {
|
|
3
|
-
'/': {
|
|
4
|
-
id: string
|
|
5
|
-
created: string
|
|
6
|
-
modified: string
|
|
7
|
-
}
|
|
8
|
-
'welcome-room': {
|
|
9
|
-
id: string
|
|
10
|
-
text: string
|
|
11
|
-
doors: never[]
|
|
12
|
-
connections: {
|
|
13
|
-
id: string
|
|
14
|
-
client: string
|
|
15
|
-
address: string
|
|
16
|
-
}[]
|
|
17
|
-
created: string
|
|
18
|
-
modified: string
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
Object.defineProperty(exports, '__esModule', { value: true })
|
|
3
|
-
exports.diosphere = void 0
|
|
4
|
-
exports.diosphere = {
|
|
5
|
-
rooms: {
|
|
6
|
-
'/': {
|
|
7
|
-
id: 'welcome-room',
|
|
8
|
-
created: '2024-03-24T14:56:21.243Z',
|
|
9
|
-
modified: '2024-03-24T14:56:21.243Z',
|
|
10
|
-
},
|
|
11
|
-
'welcome-room': {
|
|
12
|
-
id: 'welcome-room',
|
|
13
|
-
text: 'Wellcome',
|
|
14
|
-
doors: [],
|
|
15
|
-
connections: [
|
|
16
|
-
{
|
|
17
|
-
id: 'welcome-connection',
|
|
18
|
-
client: 'LocalClient',
|
|
19
|
-
address: 'public/welcome-room',
|
|
20
|
-
},
|
|
21
|
-
],
|
|
22
|
-
created: '2024-03-24T14:56:21.243Z',
|
|
23
|
-
modified: '2024-03-24T14:56:21.243Z',
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"rooms": {
|
|
3
|
-
"/": {
|
|
4
|
-
"id": "welcome-room",
|
|
5
|
-
"created": "2024-03-24T14:56:21.243Z",
|
|
6
|
-
"modified": "2024-03-24T14:56:21.243Z"
|
|
7
|
-
},
|
|
8
|
-
"welcome-room": {
|
|
9
|
-
"id": "welcome-room",
|
|
10
|
-
"text": "Wellcome room",
|
|
11
|
-
"doors": [],
|
|
12
|
-
"connections": [
|
|
13
|
-
{
|
|
14
|
-
"id": "welcome-room",
|
|
15
|
-
"client": "LocalClient",
|
|
16
|
-
"address": "public/welcome-room"
|
|
17
|
-
}
|
|
18
|
-
],
|
|
19
|
-
"created": "2024-03-24T14:56:21.243Z",
|
|
20
|
-
"modified": "2024-03-24T14:56:21.243Z"
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
Object.defineProperty(exports, '__esModule', { value: true })
|
|
3
|
-
exports.getDefaultDiograph = void 0
|
|
4
|
-
const diograph_1 = require('@diograph/diograph')
|
|
5
|
-
const getDefaultDiograph = () => {
|
|
6
|
-
const diograph = new diograph_1.Diograph()
|
|
7
|
-
const diory = diograph.addDiory({
|
|
8
|
-
text: 'Welcome to Diory',
|
|
9
|
-
latlng: '60.01366036242365, 20.007133483886722',
|
|
10
|
-
})
|
|
11
|
-
diograph.addDiory(
|
|
12
|
-
{
|
|
13
|
-
text: 'Root',
|
|
14
|
-
links: [{ id: diory.id }],
|
|
15
|
-
},
|
|
16
|
-
'/',
|
|
17
|
-
)
|
|
18
|
-
return diograph.toObject()
|
|
19
|
-
}
|
|
20
|
-
exports.getDefaultDiograph = getDefaultDiograph
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
Object.defineProperty(exports, '__esModule', { value: true })
|
|
3
|
-
exports.getDefaultDiosphere = void 0
|
|
4
|
-
const diosphere_js_1 = require('@diory/diosphere-js')
|
|
5
|
-
const getDefaultDiosphere = (connections) => {
|
|
6
|
-
const diosphere = new diosphere_js_1.Diosphere()
|
|
7
|
-
diosphere.addRoom(
|
|
8
|
-
{
|
|
9
|
-
text: 'Room',
|
|
10
|
-
connections,
|
|
11
|
-
},
|
|
12
|
-
'/',
|
|
13
|
-
)
|
|
14
|
-
return diosphere.toObject()
|
|
15
|
-
}
|
|
16
|
-
exports.getDefaultDiosphere = getDefaultDiosphere
|
package/dist/utils/debounce.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function debounce(func: any, wait: number, immediate?: boolean): () => typeof func;
|
package/dist/utils/debounce.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.debounce = void 0;
|
|
4
|
-
function debounce(func, wait, immediate = false) {
|
|
5
|
-
let timeout;
|
|
6
|
-
// eslint-disable-next-line func-names
|
|
7
|
-
return () => {
|
|
8
|
-
// @ts-ignore
|
|
9
|
-
const context = this;
|
|
10
|
-
const args = arguments;
|
|
11
|
-
// eslint-disable-next-line func-names
|
|
12
|
-
const later = function () {
|
|
13
|
-
timeout = null;
|
|
14
|
-
if (!immediate)
|
|
15
|
-
func.apply(context, args);
|
|
16
|
-
};
|
|
17
|
-
const callNow = immediate && !timeout;
|
|
18
|
-
clearTimeout(timeout);
|
|
19
|
-
timeout = setTimeout(later, wait);
|
|
20
|
-
if (callNow)
|
|
21
|
-
func.apply(context, args);
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
exports.debounce = debounce;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { IConnectionObject } from '@diory/diosphere-js'
|
|
2
|
-
import { IDataClient } from '@diograph/local-client'
|
|
3
|
-
import { IConnectionClient } from '../types'
|
|
4
|
-
export declare function getConnectionClients(
|
|
5
|
-
dataClients: IDataClient[],
|
|
6
|
-
connections?: IConnectionObject[],
|
|
7
|
-
): IConnectionClient[]
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
Object.defineProperty(exports, '__esModule', { value: true })
|
|
3
|
-
exports.getConnectionClients = void 0
|
|
4
|
-
const connectionClient_1 = require('../connectionClient/connectionClient')
|
|
5
|
-
function getDataClient(dataClients, { client }) {
|
|
6
|
-
return dataClients.find(({ type }) => type === client)
|
|
7
|
-
}
|
|
8
|
-
function getConnectionClients(dataClients, connections = []) {
|
|
9
|
-
return connections
|
|
10
|
-
.filter(({ client }) => dataClients.some(({ type }) => type === client))
|
|
11
|
-
.map((connection) => {
|
|
12
|
-
const dataClient = getDataClient(dataClients, connection)
|
|
13
|
-
return new connectionClient_1.ConnectionClient(dataClient, connection)
|
|
14
|
-
})
|
|
15
|
-
}
|
|
16
|
-
exports.getConnectionClients = getConnectionClients
|
package/src/utils/debounce.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export function debounce(func: any, wait: number, immediate = false) {
|
|
2
|
-
let timeout: any
|
|
3
|
-
// eslint-disable-next-line func-names
|
|
4
|
-
return (): typeof func => {
|
|
5
|
-
// @ts-ignore
|
|
6
|
-
const context = this
|
|
7
|
-
const args = arguments
|
|
8
|
-
// eslint-disable-next-line func-names
|
|
9
|
-
const later = function () {
|
|
10
|
-
timeout = null
|
|
11
|
-
if (!immediate) func.apply(context, args)
|
|
12
|
-
}
|
|
13
|
-
const callNow = immediate && !timeout
|
|
14
|
-
clearTimeout(timeout)
|
|
15
|
-
timeout = setTimeout(later, wait)
|
|
16
|
-
if (callNow) func.apply(context, args)
|
|
17
|
-
}
|
|
18
|
-
}
|