@diory/client-js 0.2.0-rc12 → 0.2.0-rc13

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.
@@ -0,0 +1,23 @@
1
+ {
2
+ "/": {
3
+ "id": "welcome-root-diory"
4
+ },
5
+ "welcome-root-diory": {
6
+ "id": "welcome-root-diory",
7
+ "image": "",
8
+ "links": [
9
+ {
10
+ "id": "welcome-diory"
11
+ }
12
+ ],
13
+ "modified": "2020-01-03T14:03:04.751Z"
14
+ },
15
+ "welcome-diory": {
16
+ "id": "welcome-diory",
17
+ "image": "",
18
+ "modified": "2020-01-03T14:03:04.751Z",
19
+ "text": "Welcome to Diory",
20
+ "latitude": 60.01366036242365,
21
+ "longitude": 20.007133483886722
22
+ }
23
+ }
@@ -0,0 +1,23 @@
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,5 +1,5 @@
1
- import { IConnectionObject, IDiosphere, IRoom, IRoomObject } from '@diory/diosphere-js';
2
- import { IDiograph, IDiory, IDioryObject } from '@diograph/diograph';
1
+ import { IConnectionObject, IDiosphere, IDiosphereObject, IRoom, IRoomObject } from '@diory/diosphere-js';
2
+ import { IDiograph, IDiographObject, IDiory, IDioryObject } from '@diograph/diograph';
3
3
  import { IDioryClient, IDataClient } from '../types';
4
4
  declare class DioryClient implements IDioryClient {
5
5
  dataClients: IDataClient[];
@@ -9,16 +9,16 @@ declare class DioryClient implements IDioryClient {
9
9
  diograph: IDiograph;
10
10
  diory?: IDiory;
11
11
  constructor(dataClients: IDataClient[]);
12
- initialise: (connections: IConnectionObject[]) => Promise<IDioryClient>;
13
12
  selectRoom: (roomObject: IRoomObject) => IRoom;
14
- enterRoom: (roomObject: IRoomObject) => Promise<IRoom>;
15
- focusDiory: (dioryObject: IDioryObject) => IDiory;
16
13
  getDiosphereClients: (connections?: IConnectionObject[]) => import("../types").IConnectionClient[];
14
+ initialiseDiosphere: (connections: IConnectionObject[]) => Promise<IDiosphere>;
15
+ getDiosphere: (connections?: IConnectionObject[]) => Promise<IDiosphereObject | undefined>;
16
+ saveDiosphere: (connections?: IConnectionObject[]) => Promise<IDiosphereObject>;
17
17
  getDiographClients: (connections?: IConnectionObject[]) => import("../types").IConnectionClient[];
18
- getDiosphere: (connections?: IConnectionObject[]) => Promise<IDiosphere>;
19
- saveDiosphere: (connections?: IConnectionObject[]) => Promise<IDiosphere>;
20
- getDiograph: (connections?: IConnectionObject[]) => Promise<IDiograph>;
21
- saveDiograph: (connections?: IConnectionObject[]) => Promise<IDiograph>;
18
+ focusDiory: (dioryObject: IDioryObject) => IDiory;
19
+ initialiseDiograph: (roomObject: IRoomObject) => Promise<IDiograph>;
20
+ getDiograph: (connections?: IConnectionObject[]) => Promise<IDiographObject | undefined>;
21
+ saveDiograph: (connections?: IConnectionObject[]) => Promise<IDiographObject>;
22
22
  generateDiograph: (connections?: IConnectionObject[]) => Promise<IDiograph>;
23
23
  }
24
24
  export { DioryClient };
@@ -1,48 +1,40 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.DioryClient = void 0;
4
7
  const diosphere_js_1 = require("@diory/diosphere-js");
5
8
  const diograph_1 = require("@diograph/diograph");
6
9
  const getConnectionClients_1 = require("../utils/getConnectionClients");
10
+ const defaultDiosphere_json_1 = __importDefault(require("./defaultDiosphere.json"));
11
+ const defaultDiograph_json_1 = __importDefault(require("./defaultDiograph.json"));
7
12
  class DioryClient {
8
13
  constructor(dataClients) {
9
14
  this.dataClients = [];
10
15
  this.connections = [];
11
- this.initialise = async (connections) => {
12
- console.info('initialise', connections);
13
- this.connections = connections;
14
- this.diosphere.resetRooms();
15
- console.info(this.diosphere);
16
- return this;
17
- };
18
16
  this.selectRoom = (roomObject) => {
19
17
  return (this.room = this.diosphere.getRoom(roomObject));
20
18
  };
21
- this.enterRoom = async (roomObject) => {
22
- console.info('enterRoom', roomObject);
23
- this.selectRoom(roomObject);
24
- this.diograph.resetDiograph();
25
- await this.getDiograph();
26
- console.info(this.room);
27
- return this.room;
28
- };
29
- this.focusDiory = (dioryObject) => {
30
- return (this.diory = this.diograph.getDiory(dioryObject));
31
- };
32
19
  this.getDiosphereClients = (connections) => {
33
20
  return (0, getConnectionClients_1.getConnectionClients)(this.dataClients, connections !== null && connections !== void 0 ? connections : this.connections);
34
21
  };
35
- this.getDiographClients = (connections) => {
22
+ this.initialiseDiosphere = async (connections) => {
36
23
  var _a;
37
- return (0, getConnectionClients_1.getConnectionClients)(this.dataClients, connections !== null && connections !== void 0 ? connections : (_a = this.room) === null || _a === void 0 ? void 0 : _a.connections);
24
+ console.info('initialiseDiosphere', connections);
25
+ this.connections = connections;
26
+ this.diosphere.resetRooms();
27
+ const diosphereObject = (_a = (await this.getDiosphere())) !== null && _a !== void 0 ? _a : defaultDiosphere_json_1.default;
28
+ this.diosphere.addDiosphere(diosphereObject);
29
+ this.selectRoom({ id: '/' });
30
+ return this.diosphere;
38
31
  };
39
32
  this.getDiosphere = async (connections) => {
40
33
  console.info('getDiosphere', connections);
34
+ let diosphereObject;
41
35
  await Promise.all(this.getDiosphereClients(connections).map(async (connectionClient) => {
42
36
  try {
43
- const diosphereObject = await connectionClient.getDiosphere();
44
- this.diosphere.addDiosphere(diosphereObject);
45
- this.selectRoom({ id: '/' });
37
+ diosphereObject = await connectionClient.getDiosphere();
46
38
  console.info(this.diosphere.toObject());
47
39
  }
48
40
  catch (error) {
@@ -50,41 +42,59 @@ class DioryClient {
50
42
  }
51
43
  return;
52
44
  }));
53
- return this.diosphere;
45
+ return diosphereObject;
54
46
  };
55
47
  this.saveDiosphere = async (connections) => {
56
48
  console.info('saveDiosphere', connections);
49
+ const diosphereObject = this.diosphere.toObject();
57
50
  await Promise.all(this.getDiosphereClients(connections).map(async (connectionClient) => {
58
- await connectionClient.saveDiosphere(this.diosphere.toObject());
59
- console.info(this.diosphere.toObject());
51
+ await connectionClient.saveDiosphere(diosphereObject);
52
+ console.info(diosphereObject);
60
53
  return;
61
54
  }));
62
- return this.diosphere;
55
+ return diosphereObject;
56
+ };
57
+ this.getDiographClients = (connections) => {
58
+ var _a;
59
+ return (0, getConnectionClients_1.getConnectionClients)(this.dataClients, connections !== null && connections !== void 0 ? connections : (_a = this.room) === null || _a === void 0 ? void 0 : _a.connections);
60
+ };
61
+ this.focusDiory = (dioryObject) => {
62
+ return (this.diory = this.diograph.getDiory(dioryObject));
63
+ };
64
+ this.initialiseDiograph = async (roomObject) => {
65
+ var _a;
66
+ console.info('initialiseDiograph', roomObject);
67
+ this.selectRoom(roomObject);
68
+ this.diograph.resetDiograph();
69
+ const diographObject = (_a = (await this.getDiograph())) !== null && _a !== void 0 ? _a : defaultDiograph_json_1.default;
70
+ this.diograph.addDiograph(diographObject);
71
+ this.focusDiory({ id: '/' });
72
+ return this.diograph;
63
73
  };
64
74
  this.getDiograph = async (connections) => {
65
75
  console.info('getDiograph', connections);
76
+ let diographObject;
66
77
  await Promise.all(this.getDiographClients(connections).map(async (connectionClient) => {
67
78
  try {
68
- const diographObject = await connectionClient.getDiograph();
69
- this.diograph.addDiograph(diographObject);
70
- this.focusDiory({ id: '/' });
71
- console.info(this.diograph.toObject());
79
+ diographObject = await connectionClient.getDiograph();
80
+ console.info(diographObject);
72
81
  }
73
82
  catch (error) {
74
83
  console.error(error);
75
84
  }
76
85
  return;
77
86
  }));
78
- return this.diograph;
87
+ return diographObject;
79
88
  };
80
89
  this.saveDiograph = async (connections) => {
81
90
  console.info('saveDiograph', connections);
91
+ const diographObject = this.diograph.toObject();
82
92
  await Promise.all(this.getDiographClients(connections).map(async (connectionClient) => {
83
- await connectionClient.saveDiograph(this.diograph.toObject());
84
- console.info(this.diograph.toObject());
93
+ await connectionClient.saveDiograph(diographObject);
94
+ console.info(diographObject);
85
95
  return;
86
96
  }));
87
- return this.diograph;
97
+ return diographObject;
88
98
  };
89
99
  this.generateDiograph = async (connections) => {
90
100
  console.info('generateDiograph', connections);
package/dist/types.d.ts CHANGED
@@ -48,13 +48,13 @@ export interface IDioryClient {
48
48
  room?: IRoom;
49
49
  diograph: IDiograph;
50
50
  diory?: IDiory;
51
- initialise: (connections: IConnectionObject[]) => Promise<IDioryClient>;
52
51
  selectRoom: (roomObject: IRoomObject) => IRoom;
53
- enterRoom: (roomObject: IRoomObject) => Promise<IRoom>;
52
+ getDiosphere: () => Promise<IDiosphereObject | undefined>;
53
+ saveDiosphere: () => Promise<IDiosphereObject>;
54
+ initialiseDiosphere: (connections: IConnectionObject[]) => Promise<IDiosphere>;
54
55
  focusDiory: (dioryObject: IDioryObject) => IDiory;
55
- getDiosphere: () => Promise<IDiosphere>;
56
- saveDiosphere: () => Promise<IDiosphere>;
57
- getDiograph: () => Promise<IDiograph>;
58
- saveDiograph: () => Promise<IDiograph>;
56
+ getDiograph: () => Promise<IDiographObject | undefined>;
57
+ saveDiograph: () => Promise<IDiographObject>;
58
+ initialiseDiograph: (roomObject: IRoomObject) => Promise<IDiograph>;
59
59
  generateDiograph: () => Promise<IDiograph>;
60
60
  }
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@diory/client-js",
3
- "version": "0.2.0-rc12",
3
+ "version": "0.2.0-rc13",
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.3.0-rc15",
9
+ "@diograph/diograph": "0.3.0-rc16",
10
10
  "@diograph/folder-generator": "^0.3.0-rc3",
11
- "@diory/diosphere-js": "^0.2.6-rc3",
11
+ "@diory/diosphere-js": "0.2.6-rc4",
12
12
  "path-browserify": "^1.0.1",
13
13
  "uuid": "8.3.2"
14
14
  },
@@ -0,0 +1,23 @@
1
+ {
2
+ "/": {
3
+ "id": "welcome-root-diory"
4
+ },
5
+ "welcome-root-diory": {
6
+ "id": "welcome-root-diory",
7
+ "image": "",
8
+ "links": [
9
+ {
10
+ "id": "welcome-diory"
11
+ }
12
+ ],
13
+ "modified": "2020-01-03T14:03:04.751Z"
14
+ },
15
+ "welcome-diory": {
16
+ "id": "welcome-diory",
17
+ "image": "",
18
+ "modified": "2020-01-03T14:03:04.751Z",
19
+ "text": "Welcome to Diory",
20
+ "latitude": 60.01366036242365,
21
+ "longitude": 20.007133483886722
22
+ }
23
+ }
@@ -0,0 +1,23 @@
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,9 +1,19 @@
1
- import { Diosphere, IConnectionObject, IDiosphere, IRoom, IRoomObject } from '@diory/diosphere-js'
2
- import { Diograph, IDiograph, IDiory, IDioryObject } from '@diograph/diograph'
1
+ import {
2
+ Diosphere,
3
+ IConnectionObject,
4
+ IDiosphere,
5
+ IDiosphereObject,
6
+ IRoom,
7
+ IRoomObject,
8
+ } from '@diory/diosphere-js'
9
+ import { Diograph, IDiograph, IDiographObject, IDiory, IDioryObject } from '@diograph/diograph'
3
10
 
4
11
  import { IDioryClient, IDataClient } from '../types'
5
12
  import { getConnectionClients } from '../utils/getConnectionClients'
6
13
 
14
+ import defaultDiosphere from './defaultDiosphere.json'
15
+ import defaultDiograph from './defaultDiograph.json'
16
+
7
17
  class DioryClient implements IDioryClient {
8
18
  dataClients: IDataClient[] = []
9
19
  connections: IConnectionObject[] = []
@@ -22,112 +32,116 @@ class DioryClient implements IDioryClient {
22
32
  this.diograph.saveDiograph = this.saveDiograph
23
33
  }
24
34
 
25
- initialise = async (connections: IConnectionObject[]): Promise<IDioryClient> => {
26
- console.info('initialise', connections)
27
-
28
- this.connections = connections
29
- this.diosphere.resetRooms()
30
- console.info(this.diosphere)
31
-
32
- return this
33
- }
34
-
35
35
  selectRoom = (roomObject: IRoomObject): IRoom => {
36
36
  return (this.room = this.diosphere.getRoom(roomObject))
37
37
  }
38
38
 
39
- enterRoom = async (roomObject: IRoomObject): Promise<IRoom> => {
40
- console.info('enterRoom', roomObject)
41
-
42
- this.selectRoom(roomObject)
43
- this.diograph.resetDiograph()
44
- await this.getDiograph()
45
- console.info(this.room)
46
-
47
- return this.room as IRoom
48
- }
49
-
50
- focusDiory = (dioryObject: IDioryObject): IDiory => {
51
- return (this.diory = this.diograph.getDiory(dioryObject))
52
- }
53
-
54
39
  getDiosphereClients = (connections?: IConnectionObject[]) => {
55
40
  return getConnectionClients(this.dataClients, connections ?? this.connections)
56
41
  }
57
42
 
58
- getDiographClients = (connections?: IConnectionObject[]) => {
59
- return getConnectionClients(this.dataClients, connections ?? this.room?.connections)
43
+ initialiseDiosphere = async (connections: IConnectionObject[]): Promise<IDiosphere> => {
44
+ console.info('initialiseDiosphere', connections)
45
+ this.connections = connections
46
+
47
+ this.diosphere.resetRooms()
48
+ const diosphereObject = (await this.getDiosphere()) ?? defaultDiosphere
49
+ this.diosphere.addDiosphere(diosphereObject)
50
+
51
+ this.selectRoom({ id: '/' })
52
+
53
+ return this.diosphere
60
54
  }
61
55
 
62
- getDiosphere = async (connections?: IConnectionObject[]): Promise<IDiosphere> => {
56
+ getDiosphere = async (
57
+ connections?: IConnectionObject[],
58
+ ): Promise<IDiosphereObject | undefined> => {
63
59
  console.info('getDiosphere', connections)
60
+
61
+ let diosphereObject
64
62
  await Promise.all(
65
63
  this.getDiosphereClients(connections).map(async (connectionClient) => {
66
64
  try {
67
- const diosphereObject = await connectionClient.getDiosphere()
68
- this.diosphere.addDiosphere(diosphereObject)
69
- this.selectRoom({ id: '/' })
65
+ diosphereObject = await connectionClient.getDiosphere()
70
66
  console.info(this.diosphere.toObject())
71
67
  } catch (error) {
72
68
  console.error(error)
73
69
  }
74
-
75
70
  return
76
71
  }),
77
72
  )
78
73
 
79
- return this.diosphere
74
+ return diosphereObject
80
75
  }
81
76
 
82
- saveDiosphere = async (connections?: IConnectionObject[]): Promise<IDiosphere> => {
77
+ saveDiosphere = async (connections?: IConnectionObject[]): Promise<IDiosphereObject> => {
83
78
  console.info('saveDiosphere', connections)
84
79
 
80
+ const diosphereObject = this.diosphere.toObject()
85
81
  await Promise.all(
86
82
  this.getDiosphereClients(connections).map(async (connectionClient) => {
87
- await connectionClient.saveDiosphere(this.diosphere.toObject())
88
- console.info(this.diosphere.toObject())
89
-
83
+ await connectionClient.saveDiosphere(diosphereObject)
84
+ console.info(diosphereObject)
90
85
  return
91
86
  }),
92
87
  )
93
88
 
94
- return this.diosphere
89
+ return diosphereObject
90
+ }
91
+
92
+ getDiographClients = (connections?: IConnectionObject[]) => {
93
+ return getConnectionClients(this.dataClients, connections ?? this.room?.connections)
94
+ }
95
+
96
+ focusDiory = (dioryObject: IDioryObject): IDiory => {
97
+ return (this.diory = this.diograph.getDiory(dioryObject))
98
+ }
99
+
100
+ initialiseDiograph = async (roomObject: IRoomObject): Promise<IDiograph> => {
101
+ console.info('initialiseDiograph', roomObject)
102
+ this.selectRoom(roomObject)
103
+
104
+ this.diograph.resetDiograph()
105
+ const diographObject = (await this.getDiograph()) ?? defaultDiograph
106
+ this.diograph.addDiograph(diographObject)
107
+
108
+ this.focusDiory({ id: '/' })
109
+
110
+ return this.diograph
95
111
  }
96
112
 
97
- getDiograph = async (connections?: IConnectionObject[]): Promise<IDiograph> => {
113
+ getDiograph = async (connections?: IConnectionObject[]): Promise<IDiographObject | undefined> => {
98
114
  console.info('getDiograph', connections)
99
115
 
116
+ let diographObject
100
117
  await Promise.all(
101
118
  this.getDiographClients(connections).map(async (connectionClient) => {
102
119
  try {
103
- const diographObject = await connectionClient.getDiograph()
104
- this.diograph.addDiograph(diographObject)
105
- this.focusDiory({ id: '/' })
106
- console.info(this.diograph.toObject())
120
+ diographObject = await connectionClient.getDiograph()
121
+ console.info(diographObject)
107
122
  } catch (error) {
108
123
  console.error(error)
109
124
  }
110
-
111
125
  return
112
126
  }),
113
127
  )
114
128
 
115
- return this.diograph
129
+ return diographObject
116
130
  }
117
131
 
118
- saveDiograph = async (connections?: IConnectionObject[]): Promise<IDiograph> => {
132
+ saveDiograph = async (connections?: IConnectionObject[]): Promise<IDiographObject> => {
119
133
  console.info('saveDiograph', connections)
120
134
 
135
+ const diographObject = this.diograph.toObject()
121
136
  await Promise.all(
122
137
  this.getDiographClients(connections).map(async (connectionClient) => {
123
- await connectionClient.saveDiograph(this.diograph.toObject())
124
- console.info(this.diograph.toObject())
125
-
138
+ await connectionClient.saveDiograph(diographObject)
139
+ console.info(diographObject)
126
140
  return
127
141
  }),
128
142
  )
129
143
 
130
- return this.diograph
144
+ return diographObject
131
145
  }
132
146
 
133
147
  generateDiograph = async (connections?: IConnectionObject[]): Promise<IDiograph> => {
package/src/types.ts CHANGED
@@ -58,13 +58,13 @@ export interface IDioryClient {
58
58
  room?: IRoom
59
59
  diograph: IDiograph
60
60
  diory?: IDiory
61
- initialise: (connections: IConnectionObject[]) => Promise<IDioryClient>
62
61
  selectRoom: (roomObject: IRoomObject) => IRoom
63
- enterRoom: (roomObject: IRoomObject) => Promise<IRoom>
62
+ getDiosphere: () => Promise<IDiosphereObject | undefined>
63
+ saveDiosphere: () => Promise<IDiosphereObject>
64
+ initialiseDiosphere: (connections: IConnectionObject[]) => Promise<IDiosphere>
64
65
  focusDiory: (dioryObject: IDioryObject) => IDiory
65
- getDiosphere: () => Promise<IDiosphere>
66
- saveDiosphere: () => Promise<IDiosphere>
67
- getDiograph: () => Promise<IDiograph>
68
- saveDiograph: () => Promise<IDiograph>
66
+ getDiograph: () => Promise<IDiographObject | undefined>
67
+ saveDiograph: () => Promise<IDiographObject>
68
+ initialiseDiograph: (roomObject: IRoomObject) => Promise<IDiograph>
69
69
  generateDiograph: () => Promise<IDiograph>
70
70
  }
package/tsconfig.json CHANGED
@@ -5,7 +5,9 @@
5
5
  "target": "es2017",
6
6
  "module": "commonjs",
7
7
  "strict": true,
8
- "forceConsistentCasingInFileNames": true
8
+ "forceConsistentCasingInFileNames": true,
9
+ "resolveJsonModule": true,
10
+ "esModuleInterop": true
9
11
  },
10
12
  "exclude": ["node_modules", "dist"]
11
13
  }