Skip to content

Commit dc6242c

Browse files
authored
Merge pull request #33 from datapartyjs/browser-bundle
Browser bundle
2 parents 8dd76dd + c77df85 commit dc6242c

5 files changed

Lines changed: 48 additions & 33 deletions

File tree

package.json

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
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",
88
"embedded": "dist/dataparty-embedded.js",
99
"alias": {
10-
"events": "eventemitter3"
10+
"events": "eventemitter3",
11+
"process": "process/browser.js",
12+
"assert": "assert",
13+
"crypto": "crypto-browserify"
1114
},
1215
"targets": {
1316
"frontend": {
1417
"context": "browser",
1518
"source": "src/index-browser.js",
19+
"optimize": false,
1620
"includeNodeModules": true,
21+
"scopeHoist": false,
1722
"engines": {
1823
"browsers": "Chrome 80"
1924
}
@@ -43,9 +48,10 @@
4348
],
4449
"scripts": {
4550
"test": "npx lab",
46-
"build": "parcel build --no-scope-hoist",
51+
"build": "npx parcel build",
4752
"prepare": "npm run build",
4853
"watch": "parcel watch",
54+
"clean": "rm -rf node_modules; rm package-lock.json; npm i",
4955
"build-test": "node ./examples/party/example-build.js",
5056
"watch-test": "DEBUG=* nodemon --ignore service test/test-service-compile.js",
5157
"build-docs": "npx jsdoc -c jsdoc.json"
@@ -54,9 +60,9 @@
5460
"@dataparty/bouncer-db": "1.0.1",
5561
"@dataparty/crypto": "datapartyjs/dataparty-crypto#parcel-build",
5662
"@hapi/joi": "^17.1.1",
57-
"@hapi/wreck": "18.0.0",
5863
"@zeit/ncc": "^0.22.3",
5964
"ajv": "6.9.1",
65+
"axios": "^0.27.2",
6066
"body-parser": "^1.19.0",
6167
"bson": "^4.6.1",
6268
"bson-objectid": "^1.3.0",
@@ -79,14 +85,13 @@
7985
"morgan": "^1.10.0",
8086
"nconf": "^0.10.0",
8187
"node-persist": "^3.0.1",
82-
"nodemon-webpack-plugin": "^3.0.1",
8388
"origin-router": "^1.6.4",
8489
"parse-url": "^5.0.1",
8590
"promisfy": "^1.2.0",
8691
"prompt": "^1.0.0",
87-
"roslib": "^0.20.0",
92+
"roslib": "^1.3.0",
8893
"sanitize-filename": "^1.6.3",
89-
"simple-peer": "^9.7.2",
94+
"simple-peer": "9.7.2",
9095
"source-map": "^0.7.3",
9196
"store-js": "^2.0.4",
9297
"tingodb": "^0.6.1",
@@ -102,14 +107,24 @@
102107
"@dataparty/bouncer-model": "1.4.3",
103108
"@hapi/code": "^9.0.1",
104109
"@hapi/lab": "^25.0.1",
110+
"assert": "^2.0.0",
105111
"better-docs": "^1.1.6",
112+
"browserify-zlib": "^0.2.0",
113+
"crypto-browserify": "^3.12.0",
106114
"docdash": "^1.1.1",
107115
"fake-indexeddb": "^4.0.0",
116+
"https-browserify": "^1.0.0",
108117
"jsdoc": "^3.6.2",
109118
"minami": "^1.2.3",
110119
"mongodb-client-encryption": "^2.2.1",
111120
"parcel": "^2.3.1",
121+
"process": "^0.11.10",
122+
"querystring-es3": "^0.2.1",
123+
"stream-browserify": "^3.0.0",
124+
"stream-http": "^3.2.0",
112125
"tmp": "^0.2.1",
126+
"url": "^0.11.0",
127+
"util": "^0.12.4",
113128
"wrtc": "^0.4.7"
114129
},
115130
"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 src="dist/dataparty-browser.js">
4+
5+
</script>
6+
</head>
7+
8+
</html>

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){

test/zango-party-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ if (!process.browser) {
1010
const fs = require('fs/promises')
1111
const debug = require('debug')('test.local-db')
1212
const ExampleModel = require('../examples/dataparty/@dataparty-api.dataparty-schema.json')
13-
//const Dataparty = require('../dist/dataparty.js')
14-
const Dataparty = require('../src/index')
13+
const Dataparty = require('../dist/dataparty.js')
14+
//const Dataparty = require('../src/index')
1515

1616
const Lab = require('@hapi/lab')
1717
const { expect } = require('@hapi/code');

0 commit comments

Comments
 (0)