@live-change/peer-connection-frontend 0.9.203 → 0.9.204

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.
@@ -102,36 +102,6 @@ const createPeer = async ({
102
102
  }
103
103
  watch(computedLocalPeerState, (newState) => updatePeerState(newState), { immediate: true })
104
104
 
105
- const messagesReader = inboxReader(
106
- (rawPosition, bucketSize) => {
107
- const path = ['peerConnection', 'messages', {
108
- peer: peerId, gt: rawPosition, limit: bucketSize
109
- }]
110
- console.log("P", path)
111
- return path
112
- },
113
- (message) => {
114
- console.log("GOT MESSAGE!", message)
115
- //console.log("HANDLE PEER MESSAGE", message)
116
- if(message.from) {
117
- let connection = connections.value.find(c => c.to === message.from)
118
- if(!connection) connection = waitingConnections.value.find(c => c.to === message.from)
119
- if(!connection) {
120
- connection = createPeerConnection(peerInternal, message.from)
121
- waitingConnections.value.push(connection)
122
- }
123
- connection.handleMessage(message)
124
- } else {
125
- throw new Error('messages from server not implemented')
126
- }
127
- },
128
- '',
129
- {
130
- bucketSize: 32,
131
- context: appContext
132
- }
133
- )
134
-
135
105
  function updateConnections() {
136
106
  const peers = isConnectionPossible.value ? otherPeersOnline.value : []
137
107
  for(let connectionId = 0; connectionId < connections.value.length; connectionId++) {
@@ -159,21 +129,6 @@ const createPeer = async ({
159
129
  }
160
130
  }
161
131
 
162
- watch(() => isConnectionPossible.value && otherPeersOnline.value, () => {
163
- updateConnections()
164
- }, { immediate: true })
165
-
166
- onUnmountedCb(() => {
167
- finished.value = true
168
- messagesReader.dispose()
169
- for(const connection of waitingConnections.value) {
170
- connection.dispose()
171
- }
172
- for(const connection of connections.value) {
173
- connection.dispose()
174
- }
175
- })
176
-
177
132
  const summary = computed(() => ({
178
133
  peerId, online: online.value, finished: finished.value,
179
134
  computedLocalPeerState: computedLocalPeerState.value,
@@ -198,6 +153,36 @@ const createPeer = async ({
198
153
  track.track.enabled = v
199
154
  }
200
155
 
156
+ const messagesReader = inboxReader(
157
+ (rawPosition, bucketSize) => {
158
+ const path = ['peerConnection', 'messages', {
159
+ peer: peerId, gt: rawPosition, limit: bucketSize
160
+ }]
161
+ console.log("P", path)
162
+ return path
163
+ },
164
+ (message) => {
165
+ console.log("GOT MESSAGE!", message)
166
+ //console.log("HANDLE PEER MESSAGE", message)
167
+ if(message.from) {
168
+ let connection = connections.value.find(c => c.to === message.from)
169
+ if(!connection) connection = waitingConnections.value.find(c => c.to === message.from)
170
+ if(!connection) {
171
+ connection = createPeerConnection(peerInternal, message.from)
172
+ waitingConnections.value.push(connection)
173
+ }
174
+ connection.handleMessage(message)
175
+ } else {
176
+ throw new Error('messages from server not implemented')
177
+ }
178
+ },
179
+ '',
180
+ {
181
+ bucketSize: 32,
182
+ context: appContext
183
+ }
184
+ )
185
+
201
186
  const peerPublic = {
202
187
  peerId, online, isConnectionPossible,
203
188
  connections, localTracks,
@@ -216,6 +201,23 @@ const createPeer = async ({
216
201
  peerId
217
202
  }
218
203
 
204
+
205
+ watch(() => isConnectionPossible.value && otherPeersOnline.value, () => {
206
+ updateConnections()
207
+ }, { immediate: true })
208
+
209
+ onUnmountedCb(() => {
210
+ finished.value = true
211
+ messagesReader.dispose()
212
+ for(const connection of waitingConnections.value) {
213
+ connection.dispose()
214
+ }
215
+ for(const connection of connections.value) {
216
+ connection.dispose()
217
+ }
218
+ })
219
+
220
+
219
221
  return {
220
222
  ...peerPublic
221
223
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/peer-connection-frontend",
3
- "version": "0.9.203",
3
+ "version": "0.9.204",
4
4
  "scripts": {
5
5
  "memDev": "dotenvx run -- node server/start.js memDev --enableSessions --initScript ./init.js --dbAccess",
6
6
  "localDevInit": "rm tmp.db; dotenvx run -- node server/start.js localDev --enableSessions --initScript ./init.js",
@@ -22,19 +22,19 @@
22
22
  },
23
23
  "type": "module",
24
24
  "dependencies": {
25
- "@live-change/cli": "^0.9.203",
26
- "@live-change/dao": "^0.9.203",
27
- "@live-change/dao-vue3": "^0.9.203",
28
- "@live-change/dao-websocket": "^0.9.203",
29
- "@live-change/framework": "^0.9.203",
30
- "@live-change/password-authentication-service": "^0.9.203",
31
- "@live-change/secret-code-service": "^0.9.203",
32
- "@live-change/secret-link-service": "^0.9.203",
33
- "@live-change/session-service": "^0.9.203",
34
- "@live-change/user-frontend": "^0.9.203",
35
- "@live-change/user-service": "^0.9.203",
36
- "@live-change/vue3-components": "^0.9.203",
37
- "@live-change/vue3-ssr": "^0.9.203",
25
+ "@live-change/cli": "^0.9.204",
26
+ "@live-change/dao": "^0.9.204",
27
+ "@live-change/dao-vue3": "^0.9.204",
28
+ "@live-change/dao-websocket": "^0.9.204",
29
+ "@live-change/framework": "^0.9.204",
30
+ "@live-change/password-authentication-service": "^0.9.204",
31
+ "@live-change/secret-code-service": "^0.9.204",
32
+ "@live-change/secret-link-service": "^0.9.204",
33
+ "@live-change/session-service": "^0.9.204",
34
+ "@live-change/user-frontend": "^0.9.204",
35
+ "@live-change/user-service": "^0.9.204",
36
+ "@live-change/vue3-components": "^0.9.204",
37
+ "@live-change/vue3-ssr": "^0.9.204",
38
38
  "@vueuse/core": "^12.3.0",
39
39
  "boxicons": "^2.1.4",
40
40
  "codeceptjs-assert": "^0.0.5",
@@ -54,7 +54,7 @@
54
54
  "vue3-scroll-border": "0.1.7"
55
55
  },
56
56
  "devDependencies": {
57
- "@live-change/codeceptjs-helper": "^0.9.203",
57
+ "@live-change/codeceptjs-helper": "^0.9.204",
58
58
  "codeceptjs": "^3.7.6",
59
59
  "generate-password": "1.7.1",
60
60
  "playwright": "1.49.1",
@@ -65,5 +65,5 @@
65
65
  "author": "Michał Łaszczewski <michal@laszczewski.pl>",
66
66
  "license": "BSD-3-Clause",
67
67
  "description": "",
68
- "gitHead": "4d4ce413fe747da2c398eb4ad378e37cc81874b3"
68
+ "gitHead": "6ac17ccf3c184ca4d7ef920f63827dbfd8749f96"
69
69
  }