diff --git a/js/packages/api/api.js b/js/packages/api/api.js
index 67556d0d3..a911e21ee 100644
--- a/js/packages/api/api.js
+++ b/js/packages/api/api.js
@@ -17,8 +17,8 @@
import EventEmitter from 'eventemitter3';
import Contract from './contract';
-import { PromiseProvider, Http as HttpProvider, PostMessage as PostMessageProvider, WsSecure as WsSecureProvider } from './provider';
-import { Http as HttpTransport, WsSecure as WsSecureTransport } from './transport';
+import { PromiseProvider, Http as HttpProvider, PostMessage as PostMessageProvider, Ws as WsProvider } from './provider';
+import { Http as HttpTransport, Ws as WsTransport } from './transport';
import { Db, Eth, Parity, Net, Personal, Shell, Shh, Signer, Trace, Web3 } from './rpc';
import Subscriptions from './subscriptions';
@@ -36,7 +36,6 @@ export default class Api extends EventEmitter {
console.log(provider);
console.warn(new Error('deprecated: Api needs provider with send() function, old-style Transport found instead'));
}
-
// does use new provider interface (not promiseProvider)
if (provider && isFunction(provider.subscribe)) {
this._pubsub = new Pubsub(provider);
@@ -187,12 +186,12 @@ export default class Api extends EventEmitter {
static Provider = {
Http: HttpProvider,
PostMessage: PostMessageProvider,
- WsSecure: WsSecureProvider
+ Ws: WsProvider
}
// NOTE: kept for backwards compatibility
static Transport = {
Http: HttpTransport,
- WsSecure: WsSecureTransport
+ Ws: WsTransport
}
}
diff --git a/js/src/api/provider/ws.js b/js/packages/api/provider/ws.js
similarity index 100%
rename from js/src/api/provider/ws.js
rename to js/packages/api/provider/ws.js
diff --git a/js/src/api/transport/ws/index.js b/js/packages/api/transport/ws/index.js
similarity index 100%
rename from js/src/api/transport/ws/index.js
rename to js/packages/api/transport/ws/index.js
diff --git a/js/src/api/transport/ws/ws.e2e.js b/js/packages/api/transport/ws/ws.e2e.js
similarity index 100%
rename from js/src/api/transport/ws/ws.e2e.js
rename to js/packages/api/transport/ws/ws.e2e.js
diff --git a/js/src/api/transport/ws/ws.js b/js/packages/api/transport/ws/ws.js
similarity index 100%
rename from js/src/api/transport/ws/ws.js
rename to js/packages/api/transport/ws/ws.js
diff --git a/js/src/api/transport/ws/ws.spec.js b/js/packages/api/transport/ws/ws.spec.js
similarity index 100%
rename from js/src/api/transport/ws/ws.spec.js
rename to js/packages/api/transport/ws/ws.spec.js
diff --git a/js/packages/ui/Form/Tab/index.js b/js/packages/ui/Form/Tab/index.js
new file mode 100644
index 000000000..5c539709f
--- /dev/null
+++ b/js/packages/ui/Form/Tab/index.js
@@ -0,0 +1,17 @@
+// Copyright 2015-2017 Parity Technologies (UK) Ltd.
+// This file is part of Parity.
+
+// Parity is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Parity is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Parity. If not, see .
+
+export default from './tab';
diff --git a/js/packages/ui/Form/Tab/tab.js b/js/packages/ui/Form/Tab/tab.js
new file mode 100644
index 000000000..d6448d35f
--- /dev/null
+++ b/js/packages/ui/Form/Tab/tab.js
@@ -0,0 +1,42 @@
+// Copyright 2015-2017 Parity Technologies (UK) Ltd.
+// This file is part of Parity.
+
+// Parity is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Parity is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Parity. If not, see .
+
+import React, { PropTypes } from 'react';
+
+import { Tab as SemanticTab } from 'semantic-ui-react';
+
+export default function Tab ({ activeIndex, as, defaultActiveIndex, menu, onTabChange, panes, label }) {
+ return (
+
+ );
+}
+
+Tab.propTypes = {
+ activeIndex: PropTypes.number || PropTypes.string,
+ as: PropTypes.any,
+ defaultActiveIndex: PropTypes.number || PropTypes.string,
+ menu: PropTypes.number,
+ onTabChange: PropTypes.func,
+ panes: PropTypes.array,
+ label: PropTypes.node
+};
diff --git a/js/packages/ui/Form/index.js b/js/packages/ui/Form/index.js
index 97ad70fef..d103c90ad 100644
--- a/js/packages/ui/Form/index.js
+++ b/js/packages/ui/Form/index.js
@@ -29,5 +29,6 @@ export RadioButtons from './RadioButtons';
export Toggle from './Toggle';
export TypedInput from './TypedInput';
export VaultSelect from './VaultSelect';
+export Tab from './Tab';
export default from './form';
diff --git a/js/packages/ui/index.js b/js/packages/ui/index.js
index ae8efd4f6..de8b2d03e 100644
--- a/js/packages/ui/index.js
+++ b/js/packages/ui/index.js
@@ -33,7 +33,7 @@ export DappIcon from './DappIcon';
export DappLink from './DappLink';
export Errors from './Errors';
export Features, { FEATURES, FeaturesStore } from './Features';
-export Form, { AddressSelect, Checkbox, DappUrlInput, Dropdown, FileSelect, Input, InputAddress, InputAddressSelect, InputChip, InputDateTime, Label, RadioButtons, Slider, Toggle, TypedInput, VaultSelect } from './Form';
+export Form, { AddressSelect, Checkbox, DappUrlInput, Dropdown, FileSelect, Input, InputAddress, InputAddressSelect, InputChip, InputDateTime, Label, RadioButtons, Slider, Toggle, TypedInput, VaultSelect, Tab } from './Form';
export GasPriceEditor from './GasPriceEditor';
export GasPriceSelector from './GasPriceSelector';
export IconCache from './IconCache';
@@ -61,7 +61,6 @@ export Snackbar from './Snackbar';
export StatusIndicator from './StatusIndicator';
export Tabs from './Tabs';
export Tags from './Tags';
-export Theme from './Theme';
export Title from './Title';
export TokenImage from './TokenImage';
export TxHash from './TxHash';
diff --git a/js/src/api/api.js b/js/src/api/api.js
deleted file mode 100644
index 28dae19d1..000000000
--- a/js/src/api/api.js
+++ /dev/null
@@ -1,197 +0,0 @@
-// Copyright 2015-2017 Parity Technologies (UK) Ltd.
-// This file is part of Parity.
-
-// Parity is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// Parity is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with Parity. If not, see .
-
-import EventEmitter from 'eventemitter3';
-
-import Contract from './contract';
-import { PromiseProvider, Http as HttpProvider, PostMessage as PostMessageProvider, Ws as WsProvider } from './provider';
-import { Http as HttpTransport, Ws as WsTransport } from './transport';
-
-import { Db, Eth, Parity, Net, Personal, Shell, Shh, Signer, Trace, Web3 } from './rpc';
-import Subscriptions from './subscriptions';
-import Pubsub from './pubsub';
-import util from './util';
-import { isFunction } from './util/types';
-
-import LocalAccountsMiddleware from '~/api/local';
-
-export default class Api extends EventEmitter {
- constructor (provider, allowSubscriptions = true) {
- super();
-
- if (!provider || !isFunction(provider.send)) {
- console.log(provider);
- console.warn(new Error('deprecated: Api needs provider with send() function, old-style Transport found instead'));
- }
- // does use new provider interface (not promiseProvider)
- if (provider && isFunction(provider.subscribe)) {
- this._pubsub = new Pubsub(provider);
- }
-
- this._provider = new PromiseProvider(provider);
-
- this._db = new Db(this._provider);
- this._eth = new Eth(this._provider);
- this._net = new Net(this._provider);
- this._parity = new Parity(this._provider);
- this._personal = new Personal(this._provider);
- this._shell = new Shell(this._provider);
- this._shh = new Shh(this._provider);
- this._signer = new Signer(this._provider);
- this._trace = new Trace(this._provider);
- this._web3 = new Web3(this._provider);
-
- if (allowSubscriptions) {
- this._subscriptions = new Subscriptions(this);
- }
- // Doing a request here in test env would cause an error
- if (LocalAccountsMiddleware && process.env.NODE_ENV !== 'test') {
- const middleware = this.parity
- .nodeKind()
- .then((nodeKind) => {
- if (nodeKind.availability === 'public') {
- return LocalAccountsMiddleware;
- }
-
- return null;
- })
- .catch(() => null);
-
- provider.addMiddleware(middleware);
- }
- }
-
- get pubsub () {
- if (!this._pubsub) {
- throw Error('Pubsub is only available with a subscribing-supported transport injected!');
- }
- return this._pubsub;
- }
-
- get db () {
- return this._db;
- }
-
- get eth () {
- return this._eth;
- }
-
- get parity () {
- return this._parity;
- }
-
- get net () {
- return this._net;
- }
-
- get personal () {
- return this._personal;
- }
-
- get provider () {
- return this._provider.provider;
- }
-
- get shell () {
- return this._shell;
- }
-
- get shh () {
- return this._shh;
- }
-
- get signer () {
- return this._signer;
- }
-
- get trace () {
- return this._trace;
- }
-
- get transport () {
- return this.provider;
- }
-
- get web3 () {
- return this._web3;
- }
-
- get util () {
- return util;
- }
-
- newContract (abi, address) {
- return new Contract(this, abi).at(address);
- }
-
- subscribe (subscriptionName, callback) {
- if (!this._subscriptions) {
- return Promise.resolve(1);
- }
-
- return this._subscriptions.subscribe(subscriptionName, callback);
- }
-
- unsubscribe (subscriptionId) {
- if (!this._subscriptions) {
- return Promise.resolve(true);
- }
-
- return this._subscriptions.unsubscribe(subscriptionId);
- }
-
- pollMethod (method, input, validate) {
- const [_group, endpoint] = method.split('_');
- const group = `_${_group}`;
-
- return new Promise((resolve, reject) => {
- const timeout = () => {
- this[group][endpoint](input)
- .then((result) => {
- if (validate ? validate(result) : result) {
- resolve(result);
- } else {
- setTimeout(timeout, 500);
- }
- })
- .catch((error) => {
- // Don't print if the request is rejected: that's ok
- if (error.type !== 'REQUEST_REJECTED') {
- console.error('pollMethod', error);
- }
-
- reject(error);
- });
- };
-
- timeout();
- });
- }
-
- static util = util
-
- static Provider = {
- Http: HttpProvider,
- PostMessage: PostMessageProvider,
- Ws: WsProvider
- }
-
- // NOTE: kept for backwards compatibility
- static Transport = {
- Http: HttpTransport,
- Ws: WsTransport
- }
-}
diff --git a/js/src/api/provider/postMessage.js b/js/src/api/provider/postMessage.js
deleted file mode 100644
index 86d2d031f..000000000
--- a/js/src/api/provider/postMessage.js
+++ /dev/null
@@ -1,100 +0,0 @@
-// Copyright 2015-2017 Parity Technologies (UK) Ltd.
-// This file is part of Parity.
-
-// Parity is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// Parity is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with Parity. If not, see .
-
-export default class PostMessage {
- id = 0;
- _messages = {};
-
- constructor (token, destination) {
- this._token = token;
- this._destination = destination;
-
- window.addEventListener('message', this.receiveMessage, false);
- }
-
- addMiddleware () {
- }
-
- _send (data) {
- this._destination.postMessage(data, '*');
- }
-
- send = (method, params, callback) => {
- const id = ++this.id;
-
- this._messages[id] = { callback };
- this._send({
- id,
- from: this._token,
- method,
- params,
- token: this._token
- });
- }
-
- subscribe = (api, callback, params) => {
- console.log('paritySubscribe', JSON.stringify(params), api, callback);
- return new Promise((resolve, reject) => {
- const id = ++this.id;
-
- this._messages[id] = { callback, resolve, reject, subscription: true, initial: true };
- this._send({
- id,
- from: this._token,
- api,
- params,
- token: this._token
- });
- });
- }
-
- unsubscribe = (subId) => {
- return new Promise((resolve, reject) => {
- const id = ++this.id;
-
- this._messages[id] = { callback: (e, v) => e ? reject(e) : resolve(v) };
- this._send({
- id,
- from: this._token,
- subId,
- token: this._token
- });
- });
- }
-
- unsubscribeAll () {
- return this.unsubscribe('*');
- }
-
- receiveMessage = ({ data: { id, error, from, token, result }, origin, source }) => {
- if (from !== 'shell' || token !== this._token) {
- return;
- }
-
- if (error) {
- console.error(from, error);
- }
-
- if (this._messages[id].subscription) {
- console.log('subscription', result, 'initial?', this._messages[id].initial);
- this._messages[id].initial ? this._messages[id].resolve(result) : this._messages[id].callback(error && new Error(error), result);
- this._messages[id].initial = false;
- } else {
- this._messages[id].callback(error && new Error(error), result);
- this._messages[id] = null;
- }
- }
-}
diff --git a/js/src/library.parity.js b/js/src/library.parity.js
new file mode 100644
index 000000000..778b1ba34
--- /dev/null
+++ b/js/src/library.parity.js
@@ -0,0 +1,37 @@
+// Copyright 2015-2017 Parity Technologies (UK) Ltd.
+// This file is part of Parity.
+
+// Parity is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Parity is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Parity. If not, see .
+
+import es6Promise from 'es6-promise';
+es6Promise.polyfill();
+
+const isNode = typeof global !== 'undefined' && typeof global !== 'undefined';
+const isBrowser = typeof self !== 'undefined' && typeof self.window !== 'undefined';
+
+if (isBrowser) {
+ require('whatwg-fetch');
+}
+
+if (isNode) {
+ global.fetch = require('node-fetch');
+}
+
+import Abi from '@parity/abi';
+import Api from '@parity/api';
+
+const Parity = { Api, Abi };
+
+export default Parity;
+export { Api, Abi };