Skip to content
This repository was archived by the owner on Dec 1, 2023. It is now read-only.

Add Vue 2.x typings for TypeScript #611

Merged
merged 10 commits into from
Feb 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ $ npm install vue-resource
```

### CDN
Available on [jsdelivr](https://cdn.jsdelivr.net/npm/[email protected].4), [unpkg](https://unpkg.com/[email protected].4) or [cdnjs](https://cdnjs.com/libraries/vue-resource).
Available on [jsdelivr](https://cdn.jsdelivr.net/npm/[email protected].5), [unpkg](https://unpkg.com/[email protected].5) or [cdnjs](https://cdnjs.com/libraries/vue-resource).
```html
<script src="https://cdn.jsdelivr.net/npm/[email protected].4"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected].5"></script>
```

## Example
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vue-resource",
"main": "dist/vue-resource.js",
"version": "1.3.4",
"version": "1.3.5",
"description": "The HTTP client for Vue.js",
"homepage": "https://github.com/pagekit/vue-resource",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion build/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ rollup.rollup({
format: 'es',
banner: banner,
footer: 'export { Url, Http, Resource };'
}).then(({code}) => write('dist/vue-resource.es2015.js', code, bundle))
}).then(({code}) => write('dist/vue-resource.esm.js', code, bundle))
)
.then(bundle =>
bundle.generate({
Expand Down
71 changes: 36 additions & 35 deletions dist/vue-resource.common.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* vue-resource v1.3.4
* vue-resource v1.3.5
* https://github.com/pagekit/vue-resource
* Released under the MIT License.
*/
Expand Down Expand Up @@ -272,13 +272,13 @@ var ntick;

var inBrowser = typeof window !== 'undefined';

var Util = function (ref) {
function Util (ref) {
var config = ref.config;
var nextTick = ref.nextTick;

ntick = nextTick;
debug = config.debug || !config.silent;
};
}

function warn(msg) {
if (typeof console !== 'undefined' && debug) {
Expand Down Expand Up @@ -451,7 +451,7 @@ function _merge(target, source, deep) {
* Root Prefix Transform.
*/

var root = function (options$$1, next) {
function root (options$$1, next) {

var url = next(options$$1);

Expand All @@ -460,13 +460,13 @@ var root = function (options$$1, next) {
}

return url;
};
}

/**
* Query Parameter Transform.
*/

var query = function (options$$1, next) {
function query (options$$1, next) {

var urlParams = Object.keys(Url.options.params), query = {}, url = next(options$$1);

Expand All @@ -483,7 +483,7 @@ var query = function (options$$1, next) {
}

return url;
};
}

/**
* URL Template v2.0.6 (https://github.com/bramstein/url-template)
Expand Down Expand Up @@ -640,7 +640,7 @@ function encodeReserved(str) {
* URL Template (RFC 6570) Transform.
*/

var template = function (options) {
function template (options) {

var variables = [], url = expand(options.url, options.params, variables);

Expand All @@ -649,7 +649,7 @@ var template = function (options) {
});

return url;
};
}

/**
* Service for URL templating.
Expand Down Expand Up @@ -786,7 +786,7 @@ function serialize(params, obj, scope) {
* XDomain client (Internet Explorer).
*/

var xdrClient = function (request) {
function xdrClient (request) {
return new PromiseObj(function (resolve) {

var xdr = new XDomainRequest(), handler = function (ref) {
Expand Down Expand Up @@ -819,15 +819,15 @@ var xdrClient = function (request) {
xdr.onprogress = function () {};
xdr.send(request.getBody());
});
};
}

/**
* CORS Interceptor.
*/

var SUPPORTS_CORS = inBrowser && 'withCredentials' in new XMLHttpRequest();

var cors = function (request, next) {
function cors (request, next) {

if (inBrowser) {

Expand All @@ -846,13 +846,13 @@ var cors = function (request, next) {
}

next();
};
}

/**
* Form data Interceptor.
*/

var form = function (request, next) {
function form (request, next) {

if (isFormData(request.body)) {

Expand All @@ -865,13 +865,13 @@ var form = function (request, next) {
}

next();
};
}

/**
* JSON Interceptor.
*/

var json = function (request, next) {
function json (request, next) {

var type = request.headers.get('Content-Type') || '';

Expand Down Expand Up @@ -902,20 +902,21 @@ var json = function (request, next) {
}) : response;

});
};
}

function isJson(str) {

var start = str.match(/^\[|^\{(?!\{)/), end = {'[': /]$/, '{': /}$/};
var start = str.match(/^\s*(\[|\{)/);
var end = {'[': /]\s*$/, '{': /}\s*$/};

return start && end[start[0]].test(str);
return start && end[start[1]].test(str);
}

/**
* JSONP client (Browser).
*/

var jsonpClient = function (request) {
function jsonpClient (request) {
return new PromiseObj(function (resolve) {

var name = request.jsonp || 'callback', callback = request.jsonpCallback || '_jsonp' + Math.random().toString(36).substr(2), body = null, handler, script;
Expand Down Expand Up @@ -963,53 +964,53 @@ var jsonpClient = function (request) {

document.body.appendChild(script);
});
};
}

/**
* JSONP Interceptor.
*/

var jsonp = function (request, next) {
function jsonp (request, next) {

if (request.method == 'JSONP') {
request.client = jsonpClient;
}

next();
};
}

/**
* Before Interceptor.
*/

var before = function (request, next) {
function before (request, next) {

if (isFunction(request.before)) {
request.before.call(this, request);
}

next();
};
}

/**
* HTTP method override Interceptor.
*/

var method = function (request, next) {
function method (request, next) {

if (request.emulateHTTP && /^(PUT|PATCH|DELETE)$/i.test(request.method)) {
request.headers.set('X-HTTP-Method-Override', request.method);
request.method = 'POST';
}

next();
};
}

/**
* Header Interceptor.
*/

var header = function (request, next) {
function header (request, next) {

var headers = assign({}, Http.headers.common,
!request.crossOrigin ? Http.headers.custom : {},
Expand All @@ -1023,13 +1024,13 @@ var header = function (request, next) {
});

next();
};
}

/**
* XMLHttp client (Browser).
*/

var xhrClient = function (request) {
function xhrClient (request) {
return new PromiseObj(function (resolve) {

var xhr = new XMLHttpRequest(), handler = function (event) {
Expand Down Expand Up @@ -1086,13 +1087,13 @@ var xhrClient = function (request) {
xhr.ontimeout = handler;
xhr.send(request.getBody());
});
};
}

/**
* Http client (Node).
*/

var nodeClient = function (request) {
function nodeClient (request) {

var client = require('got');

Expand Down Expand Up @@ -1123,13 +1124,13 @@ var nodeClient = function (request) {

}, function (error$$1) { return handler(error$$1.response); });
});
};
}

/**
* Base client.
*/

var Client = function (context) {
function Client (context) {

var reqHandlers = [sendRequest], resHandlers = [], handler;

Expand Down Expand Up @@ -1184,7 +1185,7 @@ var Client = function (context) {
};

return Client;
};
}

function sendRequest(request, resolve) {

Expand Down
Loading