psionic 0.1.14 → 0.3.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/adapters/reconnect.d.mts +10 -0
- package/adapters/reconnect.mjs +42 -0
- package/adapters/reconnect.mjs.map +1 -0
- package/adapters/resend.d.mts +13 -0
- package/adapters/resend.mjs +29 -0
- package/adapters/resend.mjs.map +1 -0
- package/adapters/socket.d.mts +14 -0
- package/adapters/socket.mjs +160 -0
- package/adapters/socket.mjs.map +1 -0
- package/adapters/websocket.d.mts +20 -0
- package/adapters/websocket.mjs +124 -0
- package/adapters/websocket.mjs.map +1 -0
- package/adapters/webworker.d.mts +8 -0
- package/adapters/webworker.mjs +42 -0
- package/adapters/webworker.mjs.map +1 -0
- package/codecs/cbor.d.mts +12 -0
- package/codecs/cbor.mjs +198 -0
- package/codecs/cbor.mjs.map +1 -0
- package/codecs/psionic.d.mts +12 -0
- package/codecs/psionic.mjs +57 -0
- package/codecs/psionic.mjs.map +1 -0
- package/package.json +44 -28
- package/psionic.d.mts +203 -0
- package/psionic.mjs +671 -0
- package/psionic.mjs.map +1 -0
- package/session.d.mts +63 -0
- package/session.mjs +92 -0
- package/session.mjs.map +1 -0
- package/utils/react-hooks.d.mts +24 -0
- package/utils/react-hooks.mjs +37 -0
- package/utils/react-hooks.mjs.map +1 -0
- package/.npmignore +0 -38
- package/README.md +0 -331
- package/dist/psionic.min.js +0 -11
- package/dist/psionic.min.js.map +0 -1
- package/examples/.babelrc +0 -4
- package/examples/browser/.babelrc +0 -4
- package/examples/browser/README.md +0 -14
- package/examples/browser/client.js +0 -73
- package/examples/browser/index.html +0 -10
- package/examples/browser/package.json +0 -28
- package/examples/browser/server.js +0 -33
- package/examples/browser/testdataset.json +0 -1
- package/examples/browser/webpack.config.js +0 -16
- package/examples/browser/webpack.devserver.js +0 -12
- package/examples/simple-socket/.babelrc +0 -3
- package/examples/simple-socket/README.md +0 -8
- package/examples/simple-socket/client.js +0 -12
- package/examples/simple-socket/package.json +0 -17
- package/examples/simple-socket/server.js +0 -15
- package/examples/socket-server/.babelrc +0 -3
- package/examples/socket-server/README.md +0 -8
- package/examples/socket-server/client.js +0 -34
- package/examples/socket-server/package.json +0 -17
- package/examples/socket-server/server.js +0 -41
- package/lib/browser.js +0 -7
- package/lib/index.js +0 -7
- package/lib/shared.js +0 -157
- package/lib/socket/client.js +0 -46
- package/lib/socket/index.js +0 -3
- package/lib/socket/server.js +0 -51
- package/lib/socket.io/browser.client.js +0 -63
- package/lib/socket.io/browser.index.js +0 -2
- package/lib/socket.io/index.js +0 -2
- package/lib/socket.io/package.json +0 -4
- package/lib/socket.io/server.js +0 -42
- package/lib/websocket/browser.client.js +0 -44
- package/lib/websocket/browser.index.js +0 -2
- package/lib/websocket/client.js +0 -55
- package/lib/websocket/index.js +0 -3
- package/lib/websocket/package.json +0 -4
- package/lib/websocket/server.js +0 -41
- package/webpack.config.js +0 -15
package/examples/.babelrc
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
# Websocket example
|
|
2
|
-
|
|
3
|
-
This example sets up a small webserver, and connects a react component to a psionic backend.
|
|
4
|
-
|
|
5
|
-
## Running
|
|
6
|
-
|
|
7
|
-
babel-node server.js
|
|
8
|
-
|
|
9
|
-
Then navigate a browser to http://localhost:3000/
|
|
10
|
-
|
|
11
|
-
## Data
|
|
12
|
-
|
|
13
|
-
The dataset used can be found on [data.gov](http://catalog.data.gov/dataset/the-white-house-nominations-appointments-new).
|
|
14
|
-
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
// importing the browser bundle exposes a 'Psionic' global
|
|
2
|
-
// import '../../dist/psionic.min.js';
|
|
3
|
-
|
|
4
|
-
import psionic from '../..'; // import psionic from 'psionic';
|
|
5
|
-
import React from 'react';
|
|
6
|
-
import ReactDOM from 'react-dom';
|
|
7
|
-
|
|
8
|
-
class App extends React.Component {
|
|
9
|
-
async componentWillMount() { await this.search(); }
|
|
10
|
-
setPage(page) { this.setState({ page }); }
|
|
11
|
-
setSort(sort) { this.setState({ sort, page: 0 }); }
|
|
12
|
-
|
|
13
|
-
async search() {
|
|
14
|
-
let state = this.state || { };
|
|
15
|
-
let results = await this.props.client.Nominations.query({
|
|
16
|
-
page: state.page,
|
|
17
|
-
sort: state.sort
|
|
18
|
-
});
|
|
19
|
-
this.setState({ results });
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
async componentDidUpdate(prevProps, prevState) {
|
|
23
|
-
if (prevState && (
|
|
24
|
-
(prevState.page !== this.state.page) ||
|
|
25
|
-
(prevState.sort !== this.state.sort)
|
|
26
|
-
)) {
|
|
27
|
-
await this.search();
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
render() {
|
|
32
|
-
if (!this.state) return <div />;
|
|
33
|
-
let page = this.state.results.page, max = this.state.results.totalPages;
|
|
34
|
-
let prevPage = <li onClick={e => this.setPage(page - 1)} className="previous"><a>Back</a></li>;
|
|
35
|
-
let nextPage = <li onClick={e => this.setPage(page + 1)} className="next"><a>Next</a></li>;
|
|
36
|
-
|
|
37
|
-
return <div className="container">
|
|
38
|
-
<ul className="pager">
|
|
39
|
-
{ page > 0 && prevPage }
|
|
40
|
-
<span>Page {page + 1} of {max + 1}</span>
|
|
41
|
-
{ page < max && nextPage }
|
|
42
|
-
</ul>
|
|
43
|
-
<table className="table table-bordered table-striped">
|
|
44
|
-
<thead>
|
|
45
|
-
<tr>
|
|
46
|
-
<th onClick={e => this.setSort('name')}>Name</th>
|
|
47
|
-
<th onClick={e => this.setSort('position_title')}>Position</th>
|
|
48
|
-
<th onClick={e => this.setSort('agency_name')}>Agency</th>
|
|
49
|
-
</tr>
|
|
50
|
-
</thead>
|
|
51
|
-
<tbody>
|
|
52
|
-
{this.state.results.items.map(p => (
|
|
53
|
-
<tr key={p[':sid']}>
|
|
54
|
-
<td className="col-sm-4">{p.name}</td>
|
|
55
|
-
<td className="col-sm-4">{p.position_title}</td>
|
|
56
|
-
<td className="col-sm-4">{p.agency_name}</td>
|
|
57
|
-
</tr>
|
|
58
|
-
))}
|
|
59
|
-
</tbody>
|
|
60
|
-
</table>
|
|
61
|
-
</div>
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
(async function run() {
|
|
66
|
-
let client = await psionic.webSocket.connect('ws://' + location.host, {
|
|
67
|
-
describe: { token: 'hello' }
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
window.client = client;
|
|
71
|
-
ReactDOM.render(<App client={client} />, document.getElementById('root'));
|
|
72
|
-
})()
|
|
73
|
-
.catch(ex => console.error(ex.stack));
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "examples",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"private": true,
|
|
5
|
-
"description": "",
|
|
6
|
-
"main": "index.js",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
9
|
-
},
|
|
10
|
-
"author": "",
|
|
11
|
-
"license": "ISC",
|
|
12
|
-
"devDependencies": {
|
|
13
|
-
"babel-core": "^6.4.0",
|
|
14
|
-
"babel-loader": "^6.2.1",
|
|
15
|
-
"babel-plugin-transform-runtime": "^6.4.3",
|
|
16
|
-
"babel-preset-es2015": "^6.3.13",
|
|
17
|
-
"babel-preset-react": "^6.3.13",
|
|
18
|
-
"babel-preset-stage-1": "^6.3.13",
|
|
19
|
-
"es6-promise": "^3.0.2",
|
|
20
|
-
"express": "^4.13.3",
|
|
21
|
-
"lodash": "^4.0.0",
|
|
22
|
-
"react": "^0.14.6",
|
|
23
|
-
"react-dom": "^0.14.6",
|
|
24
|
-
"webpack": "^1.12.11",
|
|
25
|
-
"webpack-dev-middleware": "^1.4.0"
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
// to run the examples, you need babel-cli:
|
|
2
|
-
// $ npm i -g babel-cli
|
|
3
|
-
// $ babel-node server.js
|
|
4
|
-
|
|
5
|
-
var httpd = require('./webpack.devserver');
|
|
6
|
-
var psionic = require('../../lib/websocket');
|
|
7
|
-
var _ = require('lodash');
|
|
8
|
-
|
|
9
|
-
var dataset = require('./testdataset.json');
|
|
10
|
-
|
|
11
|
-
let Nominations = {
|
|
12
|
-
query: function (opts) {
|
|
13
|
-
opts = Object.assign({ page: 0, pageSize: 25, sort: 'name' }, opts);
|
|
14
|
-
var items = _.sortBy(dataset, opts.sort);
|
|
15
|
-
var page = {
|
|
16
|
-
page: opts.page,
|
|
17
|
-
pageSize: opts.pageSize,
|
|
18
|
-
totalPages: Math.floor(dataset.length / opts.pageSize)
|
|
19
|
-
};
|
|
20
|
-
page.items = items.slice(opts.page * opts.pageSize, (opts.page + 1) * opts.pageSize);
|
|
21
|
-
return page;
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
// WS.createServer accepts an http server, or port/host options to
|
|
26
|
-
// start a standalone server.
|
|
27
|
-
psionic.createServer({ server: httpd }, function (client) {
|
|
28
|
-
if (!client.token || client.token.length !== 5) {
|
|
29
|
-
return client.describe({ failed: true });
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
client.describe({ Nominations });
|
|
33
|
-
});
|