[advancedcontentfilter] Remove JS Composer dependencies

- Remove bower-asset/vue
- Remove bower-asset/vue-resource
- Remove fxp/composer-asset-plugin
pull/586/head
Hypolite Petovan 5 years ago
parent faad559799
commit cefb58374e

@ -11,12 +11,9 @@
}
],
"require": {
"php": ">=5.5.0",
"php": ">=5.6.0",
"slim/slim": "^3.1",
"symfony/expression-language": "^3.4",
"fxp/composer-asset-plugin": "~1.3",
"bower-asset/vue": "^2.5",
"bower-asset/vue-resource": "^1.5"
"symfony/expression-language": "^3.4"
},
"license": "3-clause BSD license",
"minimum-stability": "stable",

@ -4,60 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "ac524148018bc5ba29d74e49492be515",
"content-hash": "d0e3662dd9d910ffe4f71d325bc39319",
"packages": [
{
"name": "bower-asset/vue",
"version": "v2.5.16",
"source": {
"type": "git",
"url": "https://github.com/vuejs/vue.git",
"reference": "25342194016dc3bcc81cb3e8e229b0fb7ba1d1d6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/vuejs/vue/zipball/25342194016dc3bcc81cb3e8e229b0fb7ba1d1d6",
"reference": "25342194016dc3bcc81cb3e8e229b0fb7ba1d1d6",
"shasum": ""
},
"type": "bower-asset-library"
},
{
"name": "bower-asset/vue-resource",
"version": "1.5.0",
"source": {
"type": "git",
"url": "https://github.com/pagekit/vue-resource.git",
"reference": "9a34f881f56f64b923572541d1753cb6cdd63d40"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pagekit/vue-resource/zipball/9a34f881f56f64b923572541d1753cb6cdd63d40",
"reference": "9a34f881f56f64b923572541d1753cb6cdd63d40",
"shasum": ""
},
"type": "bower-asset-library",
"extra": {
"bower-asset-main": "dist/vue-resource.js",
"bower-asset-ignore": [
".*",
"build",
"docs",
"package.json"
]
},
"license": [
"MIT"
],
"description": "The HTTP client for Vue.js",
"keywords": [
"ajax",
"http",
"vue",
"xhr"
],
"time": "2018-03-03T07:42:38+00:00"
},
{
"name": "container-interop/container-interop",
"version": "1.2.0",
@ -89,65 +37,6 @@
"homepage": "https://github.com/container-interop/container-interop",
"time": "2017-02-14T19:40:03+00:00"
},
{
"name": "fxp/composer-asset-plugin",
"version": "v1.4.2",
"source": {
"type": "git",
"url": "https://github.com/fxpio/composer-asset-plugin.git",
"reference": "61352d99940d2b2392a5d2db83b8c0ef5faf222a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fxpio/composer-asset-plugin/zipball/61352d99940d2b2392a5d2db83b8c0ef5faf222a",
"reference": "61352d99940d2b2392a5d2db83b8c0ef5faf222a",
"shasum": ""
},
"require": {
"composer-plugin-api": "^1.0",
"php": ">=5.3.3"
},
"require-dev": {
"composer/composer": "^1.4.0"
},
"type": "composer-plugin",
"extra": {
"class": "Fxp\\Composer\\AssetPlugin\\FxpAssetPlugin",
"branch-alias": {
"dev-master": "1.4-dev"
}
},
"autoload": {
"psr-4": {
"Fxp\\Composer\\AssetPlugin\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "François Pluchino",
"email": "francois.pluchino@gmail.com"
}
],
"description": "NPM/Bower Dependency Manager for Composer",
"homepage": "https://github.com/fxpio/composer-asset-plugin",
"keywords": [
"asset",
"bower",
"composer",
"dependency manager",
"nodejs",
"npm",
"package"
],
"time": "2017-10-20T06:53:56+00:00"
},
{
"name": "nikic/fast-route",
"version": "v1.3.0",
@ -739,7 +628,7 @@
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
"php": ">=5.5.0"
"php": ">=5.6.0"
},
"platform-dev": []
}

@ -1,21 +0,0 @@
The MIT License (MIT)
Copyright (c) 2015-2017 steffans
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

@ -1,59 +0,0 @@
# vue-resource [![Build](https://img.shields.io/circleci/project/pagekit/vue-resource/develop.svg)](https://circleci.com/gh/pagekit/vue-resource) [![Downloads](https://img.shields.io/npm/dm/vue-resource.svg)](https://www.npmjs.com/package/vue-resource) [![jsdelivr](https://data.jsdelivr.com/v1/package/npm/vue-resource/badge?style=rounded)](https://www.jsdelivr.com/package/npm/vue-resource) [![Version](https://img.shields.io/npm/v/vue-resource.svg)](https://www.npmjs.com/package/vue-resource) [![License](https://img.shields.io/npm/l/vue-resource.svg)](https://www.npmjs.com/package/vue-resource)
The plugin for [Vue.js](http://vuejs.org) provides services for making web requests and handle responses using a [XMLHttpRequest](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest) or JSONP.
## Features
- Supports the [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) API and [URI Templates](https://medialize.github.io/URI.js/uri-template.html)
- Supports [interceptors](docs/http.md#interceptors) for request and response
- Supports latest Firefox, Chrome, Safari, Opera and IE9+
- Supports Vue 1.0 & Vue 2.0
- Compact size 14KB (5.3KB gzipped)
## Installation
You can install it via [yarn](https://yarnpkg.com/) or [NPM](http://npmjs.org/).
```
$ yarn add vue-resource
$ npm install vue-resource
```
### CDN
Available on [jsdelivr](https://cdn.jsdelivr.net/npm/vue-resource@1.5.0), [unpkg](https://unpkg.com/vue-resource@1.5.0) or [cdnjs](https://cdnjs.com/libraries/vue-resource).
```html
<script src="https://cdn.jsdelivr.net/npm/vue-resource@1.5.0"></script>
```
## Example
```js
{
// GET /someUrl
this.$http.get('/someUrl').then(response => {
// get body data
this.someData = response.body;
}, response => {
// error callback
});
}
```
## Documentation
- [Configuration](docs/config.md)
- [HTTP Requests/Response](docs/http.md)
- [Creating Resources](docs/resource.md)
- [Code Recipes](docs/recipes.md)
- [API Reference](docs/api.md)
## Changelog
Details changes for each release are documented in the [release notes](https://github.com/pagekit/vue-resource/releases).
## Contribution
If you find a bug or want to contribute to the code or documentation, you can help by submitting an [issue](https://github.com/pagekit/vue-resource/issues) or a [pull request](https://github.com/pagekit/vue-resource/pulls).
## License
[MIT](http://opensource.org/licenses/MIT)

@ -1,20 +0,0 @@
{
"name": "vue-resource",
"main": "dist/vue-resource.js",
"version": "1.5.0",
"description": "The HTTP client for Vue.js",
"homepage": "https://github.com/pagekit/vue-resource",
"license": "MIT",
"keywords": [
"vue",
"xhr",
"http",
"ajax"
],
"ignore": [
".*",
"build",
"docs",
"package.json"
]
}

@ -1,3 +0,0 @@
# NOTE!
The `dist` folder contains the standalone build for vue-resource, however files here are only checked-in when a release happens. If you are on the `dev` branch, files here are **NOT** up to date. Only the `master` branch contains the built files for the latest stable version.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

@ -1,65 +0,0 @@
/**
* Base client.
*/
import Promise from '../../promise';
import xhrClient from './xhr';
import nodeClient from './node';
import {warn, when, isObject, isFunction, inBrowser} from '../../util';
export default function (context) {
const reqHandlers = [sendRequest], resHandlers = [];
if (!isObject(context)) {
context = null;
}
function Client(request) {
while (reqHandlers.length) {
const handler = reqHandlers.pop();
if (isFunction(handler)) {
let response, next;
response = handler.call(context, request, val => next = val) || next;
if (isObject(response)) {
return new Promise((resolve, reject) => {
resHandlers.forEach(handler => {
response = when(response, response => {
return handler.call(context, response) || response;
}, reject);
});
when(response, resolve, reject);
}, context);
}
if (isFunction(response)) {
resHandlers.unshift(response);
}
} else {
warn(`Invalid interceptor of type ${typeof handler}, must be a function`);
}
}
}
Client.use = handler => {
reqHandlers.push(handler);
};
return Client;
}
function sendRequest(request) {
const client = request.client || (inBrowser ? xhrClient : nodeClient);
return client(request);
}

@ -1,53 +0,0 @@
/**
* JSONP client (Browser).
*/
import Promise from '../../promise';
export default function (request) {
return new Promise(resolve => {
var name = request.jsonp || 'callback', callback = request.jsonpCallback || '_jsonp' + Math.random().toString(36).substr(2), body = null, handler, script;
handler = ({type}) => {
var status = 0;
if (type === 'load' && body !== null) {
status = 200;
} else if (type === 'error') {
status = 500;
}
if (status && window[callback]) {
delete window[callback];
document.body.removeChild(script);
}
resolve(request.respondWith(body, {status}));
};
window[callback] = result => {
body = JSON.stringify(result);
};
request.abort = () => {
handler({type: 'abort'});
};
request.params[name] = callback;
if (request.timeout) {
setTimeout(request.abort, request.timeout);
}
script = document.createElement('script');
script.src = request.getUrl();
script.type = 'text/javascript';
script.async = true;
script.onload = handler;
script.onerror = handler;
document.body.appendChild(script);
});
}

@ -1,38 +0,0 @@
/**
* Http client (Node).
*/
import Promise from '../../promise';
import {each, trim} from '../../util';
export default function (request) {
const client = require('got');
return new Promise(resolve => {
var url = request.getUrl();
var body = request.getBody();
var method = request.method;
var headers = {}, handler;
request.headers.forEach((value, name) => {
headers[name] = value;
});
client(url, {body, method, headers}).then(handler = (resp) => {
var response = request.respondWith(resp.body, {
status: resp.statusCode,
statusText: trim(resp.statusMessage)
});
each(resp.headers, (value, name) => {
response.headers.set(name, value);
});
resolve(response);
}, error => handler(error.response));
});
}

@ -1,38 +0,0 @@
/**
* XDomain client (Internet Explorer).
*/
import Promise from '../../promise';
export default function (request) {
return new Promise(resolve => {
var xdr = new XDomainRequest(), handler = ({type}) => {
var status = 0;
if (type === 'load') {
status = 200;
} else if (type === 'error') {
status = 500;
}
resolve(request.respondWith(xdr.responseText, {status}));
};
request.abort = () => xdr.abort();
xdr.open(request.method, request.getUrl());
if (request.timeout) {
xdr.timeout = request.timeout;
}
xdr.onload = handler;
xdr.onabort = handler;
xdr.onerror = handler;
xdr.ontimeout = handler;
xdr.onprogress = () => {};
xdr.send(request.getBody());
});
}

@ -1,74 +0,0 @@
/**
* XMLHttp client (Browser).
*/
import Promise from '../../promise';
import {each, trim, isFunction} from '../../util';
export default function (request) {
return new Promise(resolve => {
var xhr = new XMLHttpRequest(), handler = (event) => {
var response = request.respondWith(
'response' in xhr ? xhr.response : xhr.responseText, {
status: xhr.status === 1223 ? 204 : xhr.status, // IE9 status bug
statusText: xhr.status === 1223 ? 'No Content' : trim(xhr.statusText)
});
each(trim(xhr.getAllResponseHeaders()).split('\n'), row => {
response.headers.append(row.slice(0, row.indexOf(':')), row.slice(row.indexOf(':') + 1));
});
resolve(response);
};
request.abort = () => xhr.abort();
xhr.open(request.method, request.getUrl(), true);
if (request.timeout) {
xhr.timeout = request.timeout;
}
if (request.responseType && 'responseType' in xhr) {
xhr.responseType = request.responseType;
}
if (request.withCredentials || request.credentials) {
xhr.withCredentials = true;
}
if (!request.crossOrigin) {
request.headers.set('X-Requested-With', 'XMLHttpRequest');
}
// deprecated use downloadProgress
if (isFunction(request.progress) && request.method === 'GET') {
xhr.addEventListener('progress', request.progress);
}
if (isFunction(request.downloadProgress)) {
xhr.addEventListener('progress', request.downloadProgress);
}
// deprecated use uploadProgress
if (isFunction(request.progress) && /^(POST|PUT)$/i.test(request.method)) {
xhr.upload.addEventListener('progress', request.progress);
}
if (isFunction(request.uploadProgress) && xhr.upload) {
xhr.upload.addEventListener('progress', request.uploadProgress);
}
request.headers.forEach((value, name) => {
xhr.setRequestHeader(name, value);
});
xhr.onload = handler;
xhr.onabort = handler;
xhr.onerror = handler;
xhr.ontimeout = handler;
xhr.send(request.getBody());
});
}

@ -1,75 +0,0 @@
/**
* HTTP Headers.
*/
import {each, trim, toLower} from '../util';
export default class Headers {
constructor(headers) {
this.map = {};
each(headers, (value, name) => this.append(name, value));
}
has(name) {
return getName(this.map, name) !== null;
}
get(name) {
var list = this.map[getName(this.map, name)];
return list ? list.join() : null;
}
getAll(name) {
return this.map[getName(this.map, name)] || [];
}
set(name, value) {
this.map[normalizeName(getName(this.map, name) || name)] = [trim(value)];
}
append(name, value) {
var list = this.map[getName(this.map, name)];
if (list) {
list.push(trim(value));
} else {
this.set(name, value);
}
}
delete(name) {
delete this.map[getName(this.map, name)];
}
deleteAll() {
this.map = {};
}
forEach(callback, thisArg) {
each(this.map, (list, name) => {
each(list, value => callback.call(thisArg, value, name, this));
});
}
}
function getName(map, name) {
return Object.keys(map).reduce((prev, curr) => {
return toLower(name) === toLower(curr) ? curr : prev;
}, null);
}
function normalizeName(name) {
if (/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(name)) {
throw new TypeError('Invalid character in header field name');
}
return trim(name);
}

@ -1,80 +0,0 @@
/**
* Service for sending network requests.
*/
const COMMON_HEADERS = {'Accept': 'application/json, text/plain, */*'};
const JSON_CONTENT_TYPE = {'Content-Type': 'application/json;charset=utf-8'};
import cors from './interceptor/cors';
import form from './interceptor/form';
import json from './interceptor/json';
import jsonp from './interceptor/jsonp';
import before from './interceptor/before';
import method from './interceptor/method';
import header from './interceptor/header';
import Client from './client/index';
import Request from './request';
import Promise from '../promise';
import {assign, defaults, error, isString, isFunction} from '../util';
export default function Http(options) {
var self = this || {}, client = Client(self.$vm);
defaults(options || {}, self.$options, Http.options);
Http.interceptors.forEach(handler => {
if (isString(handler)) {
handler = Http.interceptor[handler];
}
if (isFunction(handler)) {
client.use(handler);
}
});
return client(new Request(options)).then(response => {
return response.ok ? response : Promise.reject(response);
}, response => {
if (response instanceof Error) {
error(response);
}
return Promise.reject(response);
});
}
Http.options = {};
Http.headers = {
put: JSON_CONTENT_TYPE,
post: JSON_CONTENT_TYPE,
patch: JSON_CONTENT_TYPE,
delete: JSON_CONTENT_TYPE,
common: COMMON_HEADERS,
custom: {}
};
Http.interceptor = {before, method, jsonp, json, form, header, cors};
Http.interceptors = ['before', 'method', 'jsonp', 'json', 'form', 'header', 'cors'];
['get', 'delete', 'head', 'jsonp'].forEach(method => {
Http[method] = function (url, options) {
return this(assign(options || {}, {url, method}));
};
});
['post', 'put', 'patch'].forEach(method => {
Http[method] = function (url, body, options) {
return this(assign(options || {}, {url, method, body}));
};
});

@ -1,13 +0,0 @@
/**
* Before Interceptor.
*/
import {isFunction} from '../../util';
export default function (request) {
if (isFunction(request.before)) {
request.before.call(this, request);
}
}

@ -1,29 +0,0 @@
/**
* CORS Interceptor.
*/
import Url from '../../url/index';
import xdrClient from '../client/xdr';
import {inBrowser} from '../../util';
const SUPPORTS_CORS = inBrowser && 'withCredentials' in new XMLHttpRequest();
export default function (request) {
if (inBrowser) {
const orgUrl = Url.parse(location.href);
const reqUrl = Url.parse(request.getUrl());
if (reqUrl.protocol !== orgUrl.protocol || reqUrl.host !== orgUrl.host) {
request.crossOrigin = true;
request.emulateHTTP = false;
if (!SUPPORTS_CORS) {
request.client = xdrClient;
}
}
}
}

@ -1,17 +0,0 @@
/**
* Form data Interceptor.
*/
import Url from '../../url/index';
import {isObject, isFormData} from '../../util';
export default function (request) {
if (isFormData(request.body)) {
request.headers.delete('Content-Type');
} else if (isObject(request.body) && request.emulateJSON) {
request.body = Url.params(request.body);
request.headers.set('Content-Type', 'application/x-www-form-urlencoded');
}
}

@ -1,21 +0,0 @@
/**
* Header Interceptor.
*/
import Http from '../index';
import {assign, each, toLower} from '../../util';
export default function (request) {
const headers = assign({}, Http.headers.common,
!request.crossOrigin ? Http.headers.custom : {},
Http.headers[toLower(request.method)]
);
each(headers, (value, name) => {
if (!request.headers.has(name)) {
request.headers.set(name, value);
}
});
}

@ -1,46 +0,0 @@
/**
* JSON Interceptor.
*/
import {when, isObject} from '../../util';
export default function (request) {
const type = request.headers.get('Content-Type') || '';
if (isObject(request.body) && type.indexOf('application/json') === 0) {
request.body = JSON.stringify(request.body);
}
return response => {
return response.bodyText ? when(response.text(), text => {
const type = response.headers.get('Content-Type') || '';
if (type.indexOf('application/json') === 0 || isJson(text)) {
try {
response.body = JSON.parse(text);
} catch (e) {
response.body = null;
}
} else {
response.body = text;
}
return response;
}) : response;
};
}
function isJson(str) {
const start = str.match(/^\s*(\[|\{)/);
const end = {'[': /]\s*$/, '{': /}\s*$/};
return start && end[start[1]].test(str);
}

@ -1,13 +0,0 @@
/**
* JSONP Interceptor.
*/
import jsonpClient from '../client/jsonp';
export default function (request) {
if (request.method == 'JSONP') {
request.client = jsonpClient;
}
}

@ -1,12 +0,0 @@
/**
* HTTP method override Interceptor.
*/
export default function (request) {
if (request.emulateHTTP && /^(PUT|PATCH|DELETE)$/i.test(request.method)) {
request.headers.set('X-HTTP-Method-Override', request.method);
request.method = 'POST';
}
}

@ -1,38 +0,0 @@
/**
* HTTP Request.
*/
import Url from '../url/index';
import Headers from './headers';
import Response from './response';
import {assign, toUpper} from '../util';
export default class Request {
constructor(options) {
this.body = null;
this.params = {};
assign(this, options, {
method: toUpper(options.method || 'GET')
});
if (!(this.headers instanceof Headers)) {
this.headers = new Headers(this.headers);
}
}
getUrl() {
return Url(this);
}
getBody() {
return this.body;
}
respondWith(body, options) {
return new Response(body, assign(options || {}, {url: this.getUrl()}));
}
}

@ -1,75 +0,0 @@
/**
* HTTP Response.
*/
import Headers from './headers';
import Promise from '../promise';
import {when, isBlob, isString} from '../util';
export default class Response {
constructor(body, {url, headers, status, statusText}) {
this.url = url;
this.ok = status >= 200 && status < 300;
this.status = status || 0;
this.statusText = statusText || '';
this.headers = new Headers(headers);
this.body = body;
if (isString(body)) {
this.bodyText = body;
} else if (isBlob(body)) {
this.bodyBlob = body;
if (isBlobText(body)) {
this.bodyText = blobText(body);
}
}
}
blob() {
return when(this.bodyBlob);
}
text() {
return when(this.bodyText);
}
json() {
return when(this.text(), text => JSON.parse(text));
}
}
Object.defineProperty(Response.prototype, 'data', {
get() {
return this.body;
},
set(body) {
this.body = body;
}
});
function blobText(body) {
return new Promise((resolve) => {
var reader = new FileReader();
reader.readAsText(body);
reader.onload = () => {
resolve(reader.result);
};
});
}
function isBlobText(body) {
return body.type.indexOf('text') === 0 || body.type.indexOf('json') !== -1;
}

@ -1,57 +0,0 @@
/**
* Install plugin.
*/
import Url from './url/index';
import Http from './http/index';
import Promise from './promise';
import Resource from './resource';
import Util, {options} from './util';
function plugin(Vue) {
if (plugin.installed) {
return;
}
Util(Vue);
Vue.url = Url;
Vue.http = Http;
Vue.resource = Resource;
Vue.Promise = Promise;
Object.defineProperties(Vue.prototype, {
$url: {
get() {
return options(Vue.url, this, this.$options.url);
}
},
$http: {
get() {
return options(Vue.http, this, this.$options.http);
}
},
$resource: {
get() {
return Vue.resource.bind(this);
}
},
$promise: {
get() {
return (executor) => new Vue.Promise(executor, this);
}
}
});
}
if (typeof window !== 'undefined' && window.Vue) {
window.Vue.use(plugin);
}
export default plugin;

@ -1,177 +0,0 @@
/**
* Promises/A+ polyfill v1.1.4 (https://github.com/bramstein/promis)
*/
const RESOLVED = 0;
const REJECTED = 1;
const PENDING = 2;
import {nextTick} from '../util';
export default function Promise(executor) {
this.state = PENDING;
this.value = undefined;
this.deferred = [];
var promise = this;
try {
executor(function (x) {
promise.resolve(x);
}, function (r) {
promise.reject(r);
});
} catch (e) {
promise.reject(e);
}
}
Promise.reject = function (r) {
return new Promise(function (resolve, reject) {
reject(r);
});
};
Promise.resolve = function (x) {
return new Promise(function (resolve, reject) {
resolve(x);
});
};
Promise.all = function all(iterable) {
return new Promise(function (resolve, reject) {
var count = 0, result = [];
if (iterable.length === 0) {
resolve(result);
}
function resolver(i) {
return function (x) {
result[i] = x;
count += 1;
if (count === iterable.length) {
resolve(result);
}
};
}
for (var i = 0; i < iterable.length; i += 1) {
Promise.resolve(iterable[i]).then(resolver(i), reject);
}
});
};
Promise.race = function race(iterable) {
return new Promise(function (resolve, reject) {
for (var i = 0; i < iterable.length; i += 1) {
Promise.resolve(iterable[i]).then(resolve, reject);
}
});
};
var p = Promise.prototype;
p.resolve = function resolve(x) {
var promise = this;
if (promise.state === PENDING) {
if (x === promise) {
throw new TypeError('Promise settled with itself.');
}
var called = false;
try {
var then = x && x['then'];
if (x !== null && typeof x === 'object' && typeof then === 'function') {
then.call(x, function (x) {
if (!called) {
promise.resolve(x);
}
called = true;
}, function (r) {
if (!called) {
promise.reject(r);
}
called = true;
});
return;
}
} catch (e) {
if (!called) {
promise.reject(e);
}
return;
}
promise.state = RESOLVED;
promise.value = x;
promise.notify();
}
};
p.reject = function reject(reason) {
var promise = this;
if (promise.state === PENDING) {
if (reason === promise) {
throw new TypeError('Promise settled with itself.');
}
promise.state = REJECTED;
promise.value = reason;
promise.notify();
}
};
p.notify = function notify() {
var promise = this;
nextTick(function () {
if (promise.state !== PENDING) {
while (promise.deferred.length) {
var deferred = promise.deferred.shift(),
onResolved = deferred[0],
onRejected = deferred[1],
resolve = deferred[2],
reject = deferred[3];
try {
if (promise.state === RESOLVED) {
if (typeof onResolved === 'function') {
resolve(onResolved.call(undefined, promise.value));
} else {
resolve(promise.value);
}
} else if (promise.state === REJECTED) {
if (typeof onRejected === 'function') {
resolve(onRejected.call(undefined, promise.value));
} else {
reject(promise.value);
}
}
} catch (e) {
reject(e);
}
}
}
});
};
p.then = function then(onResolved, onRejected) {
var promise = this;
return new Promise(function (resolve, reject) {
promise.deferred.push([onResolved, onRejected, resolve, reject]);
promise.notify();
});
};
p.catch = function (onRejected) {
return this.then(undefined, onRejected);
};

@ -1,150 +0,0 @@
/**
* URL Template v2.0.6 (https://github.com/bramstein/url-template)
*/
export function expand(url, params, variables) {
var tmpl = parse(url), expanded = tmpl.expand(params);
if (variables) {
variables.push.apply(variables, tmpl.vars);
}
return expanded;
}
export function parse(template) {
var operators = ['+', '#', '.', '/', ';', '?', '&'], variables = [];
return {
vars: variables,
expand(context) {
return template.replace(/\{([^{}]+)\}|([^{}]+)/g, (_, expression, literal) => {
if (expression) {
var operator = null, values = [];
if (operators.indexOf(expression.charAt(0)) !== -1) {
operator = expression.charAt(0);
expression = expression.substr(1);
}
expression.split(/,/g).forEach((variable) => {
var tmp = /([^:*]*)(?::(\d+)|(\*))?/.exec(variable);
values.push.apply(values, getValues(context, operator, tmp[1], tmp[2] || tmp[3]));
variables.push(tmp[1]);
});
if (operator && operator !== '+') {
var separator = ',';
if (operator === '?') {
separator = '&';
} else if (operator !== '#') {
separator = operator;
}
return (values.length !== 0 ? operator : '') + values.join(separator);
} else {
return values.join(',');
}
} else {
return encodeReserved(literal);
}
});
}
};
}
function getValues(context, operator, key, modifier) {
var value = context[key], result = [];
if (isDefined(value) && value !== '') {
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
value = value.toString();
if (modifier && modifier !== '*') {
value = value.substring(0, parseInt(modifier, 10));
}
result.push(encodeValue(operator, value, isKeyOperator(operator) ? key : null));
} else {
if (modifier === '*') {
if (Array.isArray(value)) {
value.filter(isDefined).forEach((value) => {
result.push(encodeValue(operator, value, isKeyOperator(operator) ? key : null));
});
} else {
Object.keys(value).forEach((k) => {
if (isDefined(value[k])) {
result.push(encodeValue(operator, value[k], k));
}
});
}
} else {
var tmp = [];
if (Array.isArray(value)) {
value.filter(isDefined).forEach((value) => {
tmp.push(encodeValue(operator, value));
});
} else {
Object.keys(value).forEach((k) => {
if (isDefined(value[k])) {
tmp.push(encodeURIComponent(k));
tmp.push(encodeValue(operator, value[k].toString()));
}
});
}
if (isKeyOperator(operator)) {
result.push(encodeURIComponent(key) + '=' + tmp.join(','));
} else if (tmp.length !== 0) {
result.push(tmp.join(','));
}
}
}
} else {
if (operator === ';') {
result.push(encodeURIComponent(key));
} else if (value === '' && (operator === '&' || operator === '?')) {
result.push(encodeURIComponent(key) + '=');
} else if (value === '') {
result.push('');
}
}
return result;
}
function isDefined(value) {
return value !== undefined && value !== null;
}
function isKeyOperator(operator) {
return operator === ';' || operator === '&' || operator === '?';
}
function encodeValue(operator, value, key) {
value = (operator === '+' || operator === '#') ? encodeReserved(value) : encodeURIComponent(value);
if (key) {
return encodeURIComponent(key) + '=' + value;
} else {
return value;
}
}
function encodeReserved(str) {
return str.split(/(%[0-9A-Fa-f]{2})/g).map((part) => {
if (!/%[0-9A-Fa-f]/.test(part)) {
part = encodeURI(part);
}
return part;
}).join('');
}

@ -1,77 +0,0 @@
/**
* Promise adapter.
*/
import PromiseLib from './lib/promise';
if (typeof Promise === 'undefined') {
window.Promise = PromiseLib;
}
export default function PromiseObj(executor, context) {
if (executor instanceof Promise) {
this.promise = executor;
} else {
this.promise = new Promise(executor.bind(context));
}
this.context = context;
}
PromiseObj.all = function (iterable, context) {
return new PromiseObj(Promise.all(iterable), context);
};
PromiseObj.resolve = function (value, context) {
return new PromiseObj(Promise.resolve(value), context);
};
PromiseObj.reject = function (reason, context) {
return new PromiseObj(Promise.reject(reason), context);
};
PromiseObj.race = function (iterable, context) {
return new PromiseObj(Promise.race(iterable), context);
};
var p = PromiseObj.prototype;
p.bind = function (context) {
this.context = context;
return this;
};
p.then = function (fulfilled, rejected) {
if (fulfilled && fulfilled.bind && this.context) {
fulfilled = fulfilled.bind(this.context);
}
if (rejected && rejected.bind && this.context) {
rejected = rejected.bind(this.context);
}
return new PromiseObj(this.promise.then(fulfilled, rejected), this.context);
};
p.catch = function (rejected) {
if (rejected && rejected.bind && this.context) {
rejected = rejected.bind(this.context);
}
return new PromiseObj(this.promise.catch(rejected), this.context);
};
p.finally = function (callback) {
return this.then(function (value) {
callback.call(this);
return value;
}, function (reason) {