Skip to content

Commit e8e0e5b

Browse files
committed
tinker with browser build
1 parent 6565c5f commit e8e0e5b

6 files changed

Lines changed: 43 additions & 34 deletions

File tree

package.json

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@dataparty/api",
33
"private": false,
4-
"version": "1.2.12",
4+
"version": "1.2.13",
55
"main": "dist/dataparty.js",
66
"frontend": "dist/dataparty-browser.js",
77
"backend": "dist/dataparty.js",
@@ -13,7 +13,7 @@
1313
"frontend": {
1414
"context": "browser",
1515
"source": "src/index-browser.js",
16-
"includeNodeModules": true,
16+
"optimize": false,
1717
"engines": {
1818
"browsers": "Chrome 80"
1919
}
@@ -43,9 +43,10 @@
4343
],
4444
"scripts": {
4545
"test": "npx lab",
46-
"build": "parcel build --no-scope-hoist",
46+
"build": "npx parcel build ",
4747
"prepare": "npm run build",
4848
"watch": "parcel watch",
49+
"clean": "rm -rf node_modules; rm package-lock.json; npm i",
4950
"build-test": "node ./examples/party/example-build.js",
5051
"watch-test": "DEBUG=* nodemon --ignore service test/test-service-compile.js",
5152
"build-docs": "npx jsdoc -c jsdoc.json"
@@ -54,9 +55,9 @@
5455
"@dataparty/bouncer-db": "1.0.1",
5556
"@dataparty/crypto": "datapartyjs/dataparty-crypto#parcel-build",
5657
"@hapi/joi": "^17.1.1",
57-
"@hapi/wreck": "18.0.0",
5858
"@zeit/ncc": "^0.22.3",
5959
"ajv": "6.9.1",
60+
"axios": "^0.27.2",
6061
"body-parser": "^1.19.0",
6162
"bson": "^4.6.1",
6263
"bson-objectid": "^1.3.0",
@@ -83,9 +84,9 @@
8384
"parse-url": "^5.0.1",
8485
"promisfy": "^1.2.0",
8586
"prompt": "^1.0.0",
86-
"roslib": "^0.20.0",
87+
"roslib": "^1.3.0",
8788
"sanitize-filename": "^1.6.3",
88-
"simple-peer": "^9.7.2",
89+
"simple-peer": "9.7.2",
8990
"source-map": "^0.7.3",
9091
"store-js": "^2.0.4",
9192
"tingodb": "^0.6.1",
@@ -94,21 +95,29 @@
9495
"uuid": "^3.2.1",
9596
"uuidv4": "^6.2.12",
9697
"vm2": "^3.9.2",
97-
"websocket": "github:sevenbitbyte/WebSocket-Node#parcel-build",
98-
"zangodb": "github:sevenbitbyte/zangodb#hash-patch"
98+
"websocket": "github:sevenbitbyte/WebSocket-Node#parcel-build"
9999
},
100100
"devDependencies": {
101101
"@dataparty/bouncer-model": "1.4.3",
102102
"@hapi/code": "^9.0.1",
103103
"@hapi/lab": "^25.0.1",
104+
"assert": "^2.0.0",
104105
"better-docs": "^1.1.6",
106+
"browserify-zlib": "^0.2.0",
105107
"docdash": "^1.1.1",
106108
"fake-indexeddb": "^4.0.0",
109+
"https-browserify": "^1.0.0",
107110
"jsdoc": "^3.6.2",
108111
"minami": "^1.2.3",
109112
"mongodb-client-encryption": "^2.2.1",
110113
"parcel": "^2.3.1",
114+
"process": "^0.11.10",
115+
"querystring-es3": "^0.2.1",
116+
"stream-browserify": "^3.0.0",
117+
"stream-http": "^3.2.0",
111118
"tmp": "^0.2.1",
119+
"url": "^0.11.0",
120+
"util": "^0.12.4",
112121
"wrtc": "^0.4.7"
113122
},
114123
"repository": {

public/example.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<html>
2+
<head>
3+
<script type="module" src="dist/dataparty-browser.js">
4+
console.log(Dataparty)
5+
</script>
6+
</head>
7+
8+
</html>

src/bouncer/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ module.exports = {
77

88
LokiDb: require('./db/loki-db'),
99
TingoDb: require('./db/tingo-db'),
10-
ZangoDb: require('./db/zango-db')
10+
//ZangoDb: require('./db/zango-db')
1111
}

src/comms/rest-comms.js

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
const Wreck = require('@hapi/wreck')
1+
const axios = require('axios')
22
const EventEmitter = require('eventemitter3')
33
const debug = require('debug')('dataparty.comms.rest')
44

5-
const WebsocketComms = require('./websocket-comms')
65
const dataparty_crypto = require('@dataparty/crypto')
76

7+
const WebsocketComms = require('./websocket-comms')
88
const AuthError = require('../errors/auth-error')
99

10+
11+
const DEFAULT_REST_TIMEOUT = 30000
12+
13+
1014
class RestComms extends EventEmitter {
1115
constructor({ remoteIdentity, config, party }) {
1216
super()
@@ -348,30 +352,18 @@ class RestComms extends EventEmitter {
348352
}
349353

350354
static async HttpRequest(verb, url, data) {
351-
// debug(typeof data)
352-
const payload = JSON.stringify(data)
353-
debug(`${verb} - ${url}`)
354-
// debug('sending - ', payload)
355-
try {
356-
const res = await Wreck.request(verb, url, {
357-
payload,
358-
headers: {
359-
'content-type': 'application/json'
360-
}
361-
})
362-
363-
const body = await Wreck.read(res, {
364-
timeout: 30000
365-
})
366355

367-
const str = body.toString()
356+
debug(`${verb} - ${url}`)
368357

369-
debug(str)
358+
const response = await axios({
359+
method: verb,
360+
url,
361+
data,
362+
headers: {'Content-Type': 'application/json'},
363+
timeout: DEFAULT_REST_TIMEOUT
364+
})
370365

371-
return str
372-
} catch (error) {
373-
throw error
374-
}
366+
return response.data
375367
}
376368

377369
static async HttpGet(url) {

src/comms/ros-shim.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const debug = require('debug')('dataparty.comms.ros-shim')
2-
const ROSLIB = require('roslib/src/RosLib')
2+
const ROSLIB = require('roslib')
33

44
class RosShim extends ROSLIB.Ros {
55
constructor(socket){

src/party/index-browser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const IParty = require('./iparty')
22
const PeerParty = require('./peer/peer-party')
33
const CloudParty = require('./cloud/cloud-party')
44
const LokiParty = require('./local/loki-party')
5-
const ZangoParty = require('./local/zango-party')
5+
const ZangoParty = null//require('./local/zango-party')
66

77
const IDocument = require('./idocument')
88
const DocumentFactory = require('./document-factory')

0 commit comments

Comments
 (0)