Skip to content
This repository has been archived by the owner on Nov 2, 2020. It is now read-only.

Commit

Permalink
chore(release): 2.0.0-alpha.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tannerntannern committed Nov 26, 2018
1 parent c1200ce commit 5c85ed6
Show file tree
Hide file tree
Showing 29 changed files with 448 additions and 241 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,16 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

<a name="2.0.0-alpha.0"></a>
# [2.0.0-alpha.0](https://github.com/tannerntannern/table-talk/compare/v1.0.0-beta.5...v2.0.0-alpha.0) (2018-11-26)


### Features

* BREAKING CHANGE: made socket.io-client and axios external modules ([38b1ce3](https://github.com/tannerntannern/table-talk/commit/38b1ce3))



<a name="1.0.0-beta.5"></a>
# [1.0.0-beta.5](https://github.com/tannerntannern/table-talk/compare/v1.0.0-beta.4...v1.0.0-beta.5) (2018-11-24)

Expand Down
7 changes: 6 additions & 1 deletion dist/client/express-client.d.ts
@@ -1,10 +1,15 @@
import { AxiosRequestConfig } from 'axios';
import { HttpInterface, Methods } from '../interface/http-interface';
import _axios, { AxiosRequestConfig } from 'axios';
/**
* Basic AJAX class than can be used in Node or the browser. Essentially just wraps around some axios methods and
* provides the proper typing based on the given HttpInterface, so that no requests are malformed.
*/
export declare class ExpressClient<API extends HttpInterface> {
/**
* Reference to the axios library. If the client is running in the browser, it is assumed that axios will be
* available on `window`.
*/
static axios: typeof _axios;
/**
* The base hostname/URL that the client should send its requests to.
*/
Expand Down
23 changes: 16 additions & 7 deletions dist/client/express-client.js
@@ -1,6 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var axios_1 = require("axios");
/**
* Basic AJAX class than can be used in Node or the browser. Essentially just wraps around some axios methods and
* provides the proper typing based on the given HttpInterface, so that no requests are malformed.
Expand All @@ -12,6 +11,11 @@ var ExpressClient = /** @class */ (function () {
function ExpressClient(host) {
if (host === void 0) { host = ''; }
this.host = host;
// Make sure we have a valid axios reference
if (!ExpressClient.axios)
throw new Error('Axios reference not detected. If you are running in the browser, be sure to include the axios ' +
'library beforehand. If you are running under Node.js, you must assign the ExpressClient.axios property ' +
'manually before instantiating an ExpressClient.');
}
/**
* General HTTP request method.
Expand All @@ -20,7 +24,7 @@ var ExpressClient = /** @class */ (function () {
Object.assign(config, {
url: this.host + endpoint
});
return axios_1.default.request(config);
return ExpressClient.axios.request(config);
};
/**
* Sends a GET request to the given endpoint. Note that since GET requests cannot have a body, the args are passed
Expand All @@ -30,7 +34,7 @@ var ExpressClient = /** @class */ (function () {
if (config === undefined)
config = {};
config.params = args;
return axios_1.default.get(this.host + endpoint, config);
return ExpressClient.axios.get(this.host + endpoint, config);
};
/**
* Sends a DELETE request to the given endpoint. Note that since DELETE requests cannot have a body, the args are
Expand All @@ -40,26 +44,31 @@ var ExpressClient = /** @class */ (function () {
if (config === undefined)
config = {};
config.params = args;
return axios_1.default.delete(this.host + endpoint, config);
return ExpressClient.axios.delete(this.host + endpoint, config);
};
/**
* Sends a POST request to the given endpoint with the given arguments.
*/
ExpressClient.prototype.post = function (endpoint, args, config) {
return axios_1.default.post(this.host + endpoint, args, config);
return ExpressClient.axios.post(this.host + endpoint, args, config);
};
/**
* Sends a PUT request to the given endpoint with the given arguments.
*/
ExpressClient.prototype.put = function (endpoint, args, config) {
return axios_1.default.put(this.host + endpoint, args, config);
return ExpressClient.axios.put(this.host + endpoint, args, config);
};
/**
* Sends a PATCH request to the given endpoint with the given arguments.
*/
ExpressClient.prototype.patch = function (endpoint, args, config) {
return axios_1.default.patch(this.host + endpoint, args, config);
return ExpressClient.axios.patch(this.host + endpoint, args, config);
};
/**
* Reference to the axios library. If the client is running in the browser, it is assumed that axios will be
* available on `window`.
*/
ExpressClient.axios = (typeof window !== 'undefined') && window.axios ? window.axios : null;
return ExpressClient;
}());
exports.ExpressClient = ExpressClient;
10 changes: 10 additions & 0 deletions dist/client/socket-client.d.ts
@@ -1,6 +1,7 @@
import { SocketHandlers, SocketInterface } from '../interface/socket-interface';
import { SocketMixin } from '../lib/socket-mixin';
import { Socket, ConnectOpts } from '../lib/types';
import * as _io from 'socket.io-client';
/**
* Describes the shape of the `this` context that will be available in every SocketClient handler.
*/
Expand All @@ -12,6 +13,11 @@ export declare type HandlerCtx<API extends SocketInterface> = {
* Basic socket client that can be used in Node or in the browser.
*/
export declare abstract class SocketClient<API extends SocketInterface> extends SocketMixin<API, 'client'> {
/**
* Reference to the socket.io-client library. If the client is running in the browser, it is assumed that `io` will
* be available on `window`.
*/
static io: typeof _io;
/**
* Socket.io Socket instance for internal use.
*/
Expand All @@ -21,6 +27,10 @@ export declare abstract class SocketClient<API extends SocketInterface> extends
* SocketServer that implements the same API.
*/
protected abstract socketHandlers: SocketHandlers<API, 'client', HandlerCtx<API>>;
/**
* Constructs a new SocketClient.
*/
constructor();
/**
* Sets up the socket handlers for the client.
*/
Expand Down
18 changes: 15 additions & 3 deletions dist/client/socket-client.js
Expand Up @@ -13,19 +13,26 @@ var __extends = (this && this.__extends) || (function () {
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var socketio = require("socket.io-client");
var socket_mixin_1 = require("../lib/socket-mixin");
/**
* Basic socket client that can be used in Node or in the browser.
*/
var SocketClient = /** @class */ (function (_super) {
__extends(SocketClient, _super);
/**
* Constructs a new SocketClient.
*/
function SocketClient() {
var _this = _super !== null && _super.apply(this, arguments) || this;
var _this = _super.call(this) || this;
/**
* Socket.io Socket instance for internal use.
*/
_this.socket = null;
// Make sure we have a valid io reference
if (!SocketClient.io)
throw new Error('Socket.io reference not detected. If you are running in the browser, be sure to include the ' +
'socket.io-client library beforehand. If you are running under Node.js, you must assign the ' +
'SocketClient.io property manually before instantiating a SocketClient.');
return _this;
}
/**
Expand Down Expand Up @@ -79,7 +86,7 @@ var SocketClient = /** @class */ (function (_super) {
Object.assign(options, {
autoConnect: false
});
this.socket = socketio(url, options);
this.socket = SocketClient.io(url, options);
this.attachSocketHandlers();
this.socket.open();
if (typeof waitFor === 'string')
Expand Down Expand Up @@ -111,6 +118,11 @@ var SocketClient = /** @class */ (function (_super) {
var _a;
(_a = this.socket).emit.apply(_a, [response.name].concat(response.args));
};
/**
* Reference to the socket.io-client library. If the client is running in the browser, it is assumed that `io` will
* be available on `window`.
*/
SocketClient.io = (typeof window !== 'undefined') && window.axios ? window.axios : null;
return SocketClient;
}(socket_mixin_1.SocketMixin));
exports.SocketClient = SocketClient;
2 changes: 1 addition & 1 deletion docs/assets/js/search.js

Large diffs are not rendered by default.

39 changes: 31 additions & 8 deletions docs/classes/_client_express_client_.expressclient.html
Expand Up @@ -112,6 +112,7 @@ <h3>Constructors</h3>
<h3>Properties</h3>
<ul class="tsd-index-list">
<li class="tsd-kind-property tsd-parent-kind-class"><a href="_client_express_client_.expressclient.html#host" class="tsd-kind-icon">host</a></li>
<li class="tsd-kind-property tsd-parent-kind-class tsd-is-static"><a href="_client_express_client_.expressclient.html#axios" class="tsd-kind-icon">axios</a></li>
</ul>
</section>
<section class="tsd-index-section ">
Expand Down Expand Up @@ -140,7 +141,7 @@ <h3>constructor</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/tannerntannern/table-talk/blob/8248f4a/src/client/express-client.ts#L12">client/express-client.ts:12</a></li>
<li>Defined in <a href="https://github.com/tannerntannern/table-talk/blob/c1200ce/src/client/express-client.ts#L20">client/express-client.ts:20</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand All @@ -167,7 +168,7 @@ <h3>host</h3>
<div class="tsd-signature tsd-kind-icon">host<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/tannerntannern/table-talk/blob/8248f4a/src/client/express-client.ts#L12">client/express-client.ts:12</a></li>
<li>Defined in <a href="https://github.com/tannerntannern/table-talk/blob/c1200ce/src/client/express-client.ts#L20">client/express-client.ts:20</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand All @@ -176,6 +177,22 @@ <h3>host</h3>
</div>
</div>
</section>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-static">
<a name="axios" class="tsd-anchor"></a>
<h3><span class="tsd-flag ts-flagStatic">Static</span> axios</h3>
<div class="tsd-signature tsd-kind-icon">axios<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">AxiosStatic</span><span class="tsd-signature-symbol"> =&nbsp;(typeof window !&#x3D;&#x3D; &#x27;undefined&#x27;) &amp;&amp; window.axios ? window.axios : null</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/tannerntannern/table-talk/blob/c1200ce/src/client/express-client.ts#L15">client/express-client.ts:15</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>Reference to the axios library. If the client is running in the browser, it is assumed that axios will be
available on <code>window</code>.</p>
</div>
</div>
</section>
</section>
<section class="tsd-panel-group tsd-member-group ">
<h2>Methods</h2>
Expand All @@ -189,7 +206,7 @@ <h3>delete</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/tannerntannern/table-talk/blob/8248f4a/src/client/express-client.ts#L50">client/express-client.ts:50</a></li>
<li>Defined in <a href="https://github.com/tannerntannern/table-talk/blob/c1200ce/src/client/express-client.ts#L65">client/express-client.ts:65</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -230,7 +247,7 @@ <h3>get</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/tannerntannern/table-talk/blob/8248f4a/src/client/express-client.ts#L39">client/express-client.ts:39</a></li>
<li>Defined in <a href="https://github.com/tannerntannern/table-talk/blob/c1200ce/src/client/express-client.ts#L54">client/express-client.ts:54</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -271,7 +288,7 @@ <h3>patch</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/tannerntannern/table-talk/blob/8248f4a/src/client/express-client.ts#L74">client/express-client.ts:74</a></li>
<li>Defined in <a href="https://github.com/tannerntannern/table-talk/blob/c1200ce/src/client/express-client.ts#L89">client/express-client.ts:89</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -311,7 +328,7 @@ <h3>post</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/tannerntannern/table-talk/blob/8248f4a/src/client/express-client.ts#L60">client/express-client.ts:60</a></li>
<li>Defined in <a href="https://github.com/tannerntannern/table-talk/blob/c1200ce/src/client/express-client.ts#L75">client/express-client.ts:75</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -351,7 +368,7 @@ <h3>put</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/tannerntannern/table-talk/blob/8248f4a/src/client/express-client.ts#L67">client/express-client.ts:67</a></li>
<li>Defined in <a href="https://github.com/tannerntannern/table-talk/blob/c1200ce/src/client/express-client.ts#L82">client/express-client.ts:82</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -391,7 +408,7 @@ <h3>request</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/tannerntannern/table-talk/blob/8248f4a/src/client/express-client.ts#L24">client/express-client.ts:24</a></li>
<li>Defined in <a href="https://github.com/tannerntannern/table-talk/blob/c1200ce/src/client/express-client.ts#L39">client/express-client.ts:39</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down Expand Up @@ -477,6 +494,9 @@ <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</
<li class=" tsd-kind-property tsd-parent-kind-class">
<a href="_client_express_client_.expressclient.html#host" class="tsd-kind-icon">host</a>
</li>
<li class=" tsd-kind-property tsd-parent-kind-class tsd-is-static">
<a href="_client_express_client_.expressclient.html#axios" class="tsd-kind-icon">axios</a>
</li>
<li class=" tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter">
<a href="_client_express_client_.expressclient.html#delete" class="tsd-kind-icon">delete</a>
</li>
Expand All @@ -499,6 +519,9 @@ <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</
</li>
</ul>
<ul class="after-current">
<li class=" tsd-kind-variable tsd-parent-kind-external-module tsd-is-not-exported">
<a href="../modules/_client_express_client_.html#window" class="tsd-kind-icon">window</a>
</li>
</ul>
</nav>
</div>
Expand Down

0 comments on commit 5c85ed6

Please sign in to comment.