@cero-base/cero 1.3.0 → 1.4.0
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/package.json +2 -2
- package/src/bluetooth.js +9 -4
- package/types/bluetooth.d.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cero-base/cero",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "The ideal p2p API — everything is a handle, handles contain refs, refs contain rows.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"test:bare": "npx bare test/bare-smoke.js"
|
|
87
87
|
},
|
|
88
88
|
"dependencies": {
|
|
89
|
-
"@cero-base/core": "^1.
|
|
89
|
+
"@cero-base/core": "^1.4.0",
|
|
90
90
|
"b4a": "^1.8.1",
|
|
91
91
|
"bare-abort-controller": "^1.1.2",
|
|
92
92
|
"bare-crypto": "^1.15.3",
|
package/src/bluetooth.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import ReadyResource from 'ready-resource'
|
|
2
2
|
import safetyCatch from 'safety-catch'
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { BLETransport } from '@cero-base/core/network/transports/ble'
|
|
5
5
|
import { Pairing } from '@cero-base/core/pairing'
|
|
6
6
|
import { Invite } from '@cero-base/core/invite'
|
|
7
7
|
|
|
@@ -71,7 +71,7 @@ export class Bluetooth extends ReadyResource {
|
|
|
71
71
|
const topic = Pairing.inviteTopic(invite)
|
|
72
72
|
if (!topic) return () => {}
|
|
73
73
|
|
|
74
|
-
const transport = new
|
|
74
|
+
const transport = new BLETransport({
|
|
75
75
|
backend: this._backend,
|
|
76
76
|
network: this._handle.network,
|
|
77
77
|
uuid: topic,
|
|
@@ -129,7 +129,7 @@ export class Bluetooth extends ReadyResource {
|
|
|
129
129
|
}
|
|
130
130
|
const handle = this._handle
|
|
131
131
|
|
|
132
|
-
this._transport = new
|
|
132
|
+
this._transport = new BLETransport({
|
|
133
133
|
backend: this._backend,
|
|
134
134
|
network: handle.network,
|
|
135
135
|
// channel isolation for free: same channel → same UUID, like the swarm.
|
|
@@ -138,7 +138,12 @@ export class Bluetooth extends ReadyResource {
|
|
|
138
138
|
? Buffer.from(handle.network.channel)
|
|
139
139
|
: handle.identity.publicKey,
|
|
140
140
|
nodeId: handle.identity.publicKey,
|
|
141
|
-
name: this._name || ''
|
|
141
|
+
name: this._name || '',
|
|
142
|
+
// Android scans in a battery-saver mode by default — too slow for a mesh
|
|
143
|
+
scanOptions:
|
|
144
|
+
typeof Bare !== 'undefined' && Bare.platform === 'android'
|
|
145
|
+
? { scanMode: this._backend.Central.SCAN_MODE_LOW_LATENCY }
|
|
146
|
+
: undefined
|
|
142
147
|
})
|
|
143
148
|
this._transport.on('update', () => {
|
|
144
149
|
this.state = this._transport.state
|
package/types/bluetooth.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export class Bluetooth extends ReadyResource {
|
|
|
27
27
|
_handle: any;
|
|
28
28
|
_backend: any;
|
|
29
29
|
_autoStart: boolean;
|
|
30
|
-
_transport:
|
|
30
|
+
_transport: BLETransport;
|
|
31
31
|
_name: any;
|
|
32
32
|
_announces: Set<any>;
|
|
33
33
|
/** @type {'unsupported'|'unauthorized'|'off'|'waiting'|'starting'|'on'} */
|
|
@@ -63,4 +63,4 @@ export class Bluetooth extends ReadyResource {
|
|
|
63
63
|
stop(): Promise<void>;
|
|
64
64
|
}
|
|
65
65
|
import ReadyResource from 'ready-resource';
|
|
66
|
-
import {
|
|
66
|
+
import { BLETransport } from '@cero-base/core/network/transports/ble';
|