vuejs-rails 2.1.10 → 2.2.1
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.
- checksums.yaml +4 -4
- data/Readme.md +5 -3
- data/lib/vuejs-rails/version.rb +1 -1
- data/vendor/assets/javascripts/vue-resource.js +342 -332
- data/vendor/assets/javascripts/vue-router.js +4 -5
- data/vendor/assets/javascripts/vue.js +5104 -4497
- data/vendor/assets/javascripts/vuex.js +811 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e31ad5112a87297ecdd603a3a16dd8d2bab31caf
|
4
|
+
data.tar.gz: e6556db586b0861086b28ce702962dc2b162b801
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a08f876ae280979642268d30c1c31c2ee955690004db34afc320e7b20250df6ecf9c3107113349574d299a6ae4976124c3eb1249d1c454a529e9e653e1bae914
|
7
|
+
data.tar.gz: 2bccc97acd3b1f64ca01a2cb7286968d6f6a450c5fe7f03d399280c942ded97e4166140ce1d6bd3d70796416bea840a40f99e92b7396b8b4709feb4ef497aac7
|
data/Readme.md
CHANGED
@@ -9,9 +9,10 @@ Rails 3.1+ asset-pipeline gem to provide Vue.js
|
|
9
9
|
|
10
10
|
### Package Versions
|
11
11
|
|
12
|
-
- vue v2.1
|
13
|
-
- vue-router v2.2.
|
14
|
-
- vue-resource v1.
|
12
|
+
- vue v2.2.1
|
13
|
+
- vue-router v2.2.1
|
14
|
+
- vue-resource v1.2.1
|
15
|
+
- vuex v2.2.1
|
15
16
|
|
16
17
|
### Setup
|
17
18
|
|
@@ -27,6 +28,7 @@ And in your application.js manifest:
|
|
27
28
|
//= require vue
|
28
29
|
//= require vue-router (optional)
|
29
30
|
//= require vue-resource (optional)
|
31
|
+
//= require vuex (optional)
|
30
32
|
```
|
31
33
|
|
32
34
|
If your `application.js` requires TurboLinks (a default setting for new Rails apps), you should strongly consider disabling it, as it will cause pages to load without reloading the Javascript.
|
data/lib/vuejs-rails/version.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
/*!
|
2
|
-
* vue-resource v1.
|
3
|
-
* https://github.com/
|
2
|
+
* vue-resource v1.2.1
|
3
|
+
* https://github.com/pagekit/vue-resource
|
4
4
|
* Released under the MIT License.
|
5
5
|
*/
|
6
6
|
|
7
7
|
(function (global, factory) {
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
9
|
+
typeof define === 'function' && define.amd ? define(factory) :
|
10
|
+
(global.VueResource = factory());
|
11
11
|
}(this, (function () { 'use strict';
|
12
12
|
|
13
13
|
/**
|
@@ -16,7 +16,7 @@
|
|
16
16
|
|
17
17
|
var RESOLVED = 0;
|
18
18
|
var REJECTED = 1;
|
19
|
-
var PENDING
|
19
|
+
var PENDING = 2;
|
20
20
|
|
21
21
|
function Promise$1(executor) {
|
22
22
|
|
@@ -51,8 +51,7 @@ Promise$1.resolve = function (x) {
|
|
51
51
|
|
52
52
|
Promise$1.all = function all(iterable) {
|
53
53
|
return new Promise$1(function (resolve, reject) {
|
54
|
-
var count = 0,
|
55
|
-
result = [];
|
54
|
+
var count = 0, result = [];
|
56
55
|
|
57
56
|
if (iterable.length === 0) {
|
58
57
|
resolve(result);
|
@@ -104,6 +103,7 @@ p$1.resolve = function resolve(x) {
|
|
104
103
|
promise.resolve(x);
|
105
104
|
}
|
106
105
|
called = true;
|
106
|
+
|
107
107
|
}, function (r) {
|
108
108
|
if (!called) {
|
109
109
|
promise.reject(r);
|
@@ -253,25 +253,36 @@ p.catch = function (rejected) {
|
|
253
253
|
p.finally = function (callback) {
|
254
254
|
|
255
255
|
return this.then(function (value) {
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
256
|
+
callback.call(this);
|
257
|
+
return value;
|
258
|
+
}, function (reason) {
|
259
|
+
callback.call(this);
|
260
|
+
return Promise.reject(reason);
|
261
|
+
}
|
262
|
+
);
|
262
263
|
};
|
263
264
|
|
264
265
|
/**
|
265
266
|
* Utility functions.
|
266
267
|
*/
|
267
268
|
|
268
|
-
var
|
269
|
+
var ref = {};
|
270
|
+
var hasOwnProperty = ref.hasOwnProperty;
|
269
271
|
|
272
|
+
var ref$1 = [];
|
273
|
+
var slice = ref$1.slice;
|
274
|
+
var debug = false;
|
275
|
+
var ntick;
|
270
276
|
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
277
|
+
var inBrowser = typeof window !== 'undefined';
|
278
|
+
|
279
|
+
var Util = function (ref) {
|
280
|
+
var config = ref.config;
|
281
|
+
var nextTick = ref.nextTick;
|
282
|
+
|
283
|
+
ntick = nextTick;
|
284
|
+
debug = config.debug || !config.silent;
|
285
|
+
};
|
275
286
|
|
276
287
|
function warn(msg) {
|
277
288
|
if (typeof console !== 'undefined' && debug) {
|
@@ -286,11 +297,11 @@ function error(msg) {
|
|
286
297
|
}
|
287
298
|
|
288
299
|
function nextTick(cb, ctx) {
|
289
|
-
return
|
300
|
+
return ntick(cb, ctx);
|
290
301
|
}
|
291
302
|
|
292
303
|
function trim(str) {
|
293
|
-
return str.replace(/^\s*|\s*$/g, '');
|
304
|
+
return str ? str.replace(/^\s*|\s*$/g, '') : '';
|
294
305
|
}
|
295
306
|
|
296
307
|
function toLower(str) {
|
@@ -307,9 +318,7 @@ function isString(val) {
|
|
307
318
|
return typeof val === 'string';
|
308
319
|
}
|
309
320
|
|
310
|
-
|
311
|
-
return val === true || val === false;
|
312
|
-
}
|
321
|
+
|
313
322
|
|
314
323
|
function isFunction(val) {
|
315
324
|
return typeof val === 'function';
|
@@ -350,20 +359,20 @@ function options(fn, obj, opts) {
|
|
350
359
|
opts = opts.call(obj);
|
351
360
|
}
|
352
361
|
|
353
|
-
return merge(fn.bind({
|
362
|
+
return merge(fn.bind({$vm: obj, $options: opts}), fn, {$options: opts});
|
354
363
|
}
|
355
364
|
|
356
365
|
function each(obj, iterator) {
|
357
366
|
|
358
367
|
var i, key;
|
359
368
|
|
360
|
-
if (obj
|
369
|
+
if (isArray(obj)) {
|
361
370
|
for (i = 0; i < obj.length; i++) {
|
362
371
|
iterator.call(obj[i], obj[i], i);
|
363
372
|
}
|
364
373
|
} else if (isObject(obj)) {
|
365
374
|
for (key in obj) {
|
366
|
-
if (
|
375
|
+
if (hasOwnProperty.call(obj, key)) {
|
367
376
|
iterator.call(obj[key], obj[key], key);
|
368
377
|
}
|
369
378
|
}
|
@@ -396,6 +405,7 @@ function defaults(target) {
|
|
396
405
|
target[key] = source[key];
|
397
406
|
}
|
398
407
|
}
|
408
|
+
|
399
409
|
});
|
400
410
|
|
401
411
|
return target;
|
@@ -432,28 +442,26 @@ function _merge(target, source, deep) {
|
|
432
442
|
* Root Prefix Transform.
|
433
443
|
*/
|
434
444
|
|
435
|
-
|
445
|
+
var root = function (options$$1, next) {
|
436
446
|
|
437
|
-
var url = next(options);
|
447
|
+
var url = next(options$$1);
|
438
448
|
|
439
|
-
if (isString(options.root) && !url.match(/^(https?:)?\//)) {
|
440
|
-
url = options.root + '/' + url;
|
449
|
+
if (isString(options$$1.root) && !url.match(/^(https?:)?\//)) {
|
450
|
+
url = options$$1.root + '/' + url;
|
441
451
|
}
|
442
452
|
|
443
453
|
return url;
|
444
|
-
}
|
454
|
+
};
|
445
455
|
|
446
456
|
/**
|
447
457
|
* Query Parameter Transform.
|
448
458
|
*/
|
449
459
|
|
450
|
-
|
460
|
+
var query = function (options$$1, next) {
|
451
461
|
|
452
|
-
var urlParams = Object.keys(Url.options.params),
|
453
|
-
query = {},
|
454
|
-
url = next(options);
|
462
|
+
var urlParams = Object.keys(Url.options.params), query = {}, url = next(options$$1);
|
455
463
|
|
456
|
-
each(options.params, function (value, key) {
|
464
|
+
each(options$$1.params, function (value, key) {
|
457
465
|
if (urlParams.indexOf(key) === -1) {
|
458
466
|
query[key] = value;
|
459
467
|
}
|
@@ -466,7 +474,7 @@ function query (options, next) {
|
|
466
474
|
}
|
467
475
|
|
468
476
|
return url;
|
469
|
-
}
|
477
|
+
};
|
470
478
|
|
471
479
|
/**
|
472
480
|
* URL Template v2.0.6 (https://github.com/bramstein/url-template)
|
@@ -474,8 +482,7 @@ function query (options, next) {
|
|
474
482
|
|
475
483
|
function expand(url, params, variables) {
|
476
484
|
|
477
|
-
var tmpl = parse(url),
|
478
|
-
expanded = tmpl.expand(params);
|
485
|
+
var tmpl = parse(url), expanded = tmpl.expand(params);
|
479
486
|
|
480
487
|
if (variables) {
|
481
488
|
variables.push.apply(variables, tmpl.vars);
|
@@ -486,17 +493,15 @@ function expand(url, params, variables) {
|
|
486
493
|
|
487
494
|
function parse(template) {
|
488
495
|
|
489
|
-
var operators = ['+', '#', '.', '/', ';', '?', '&'],
|
490
|
-
variables = [];
|
496
|
+
var operators = ['+', '#', '.', '/', ';', '?', '&'], variables = [];
|
491
497
|
|
492
498
|
return {
|
493
499
|
vars: variables,
|
494
|
-
expand: function (context) {
|
500
|
+
expand: function expand(context) {
|
495
501
|
return template.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g, function (_, expression, literal) {
|
496
502
|
if (expression) {
|
497
503
|
|
498
|
-
var operator = null,
|
499
|
-
values = [];
|
504
|
+
var operator = null, values = [];
|
500
505
|
|
501
506
|
if (operators.indexOf(expression.charAt(0)) !== -1) {
|
502
507
|
operator = expression.charAt(0);
|
@@ -523,6 +528,7 @@ function parse(template) {
|
|
523
528
|
} else {
|
524
529
|
return values.join(',');
|
525
530
|
}
|
531
|
+
|
526
532
|
} else {
|
527
533
|
return encodeReserved(literal);
|
528
534
|
}
|
@@ -533,8 +539,7 @@ function parse(template) {
|
|
533
539
|
|
534
540
|
function getValues(context, operator, key, modifier) {
|
535
541
|
|
536
|
-
var value = context[key],
|
537
|
-
result = [];
|
542
|
+
var value = context[key], result = [];
|
538
543
|
|
539
544
|
if (isDefined(value) && value !== '') {
|
540
545
|
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
@@ -604,7 +609,7 @@ function isKeyOperator(operator) {
|
|
604
609
|
|
605
610
|
function encodeValue(operator, value, key) {
|
606
611
|
|
607
|
-
value = operator === '+' || operator === '#' ? encodeReserved(value) : encodeURIComponent(value);
|
612
|
+
value = (operator === '+' || operator === '#') ? encodeReserved(value) : encodeURIComponent(value);
|
608
613
|
|
609
614
|
if (key) {
|
610
615
|
return encodeURIComponent(key) + '=' + value;
|
@@ -626,42 +631,36 @@ function encodeReserved(str) {
|
|
626
631
|
* URL Template (RFC 6570) Transform.
|
627
632
|
*/
|
628
633
|
|
629
|
-
|
634
|
+
var template = function (options) {
|
630
635
|
|
631
|
-
var variables = [],
|
632
|
-
url = expand(options.url, options.params, variables);
|
636
|
+
var variables = [], url = expand(options.url, options.params, variables);
|
633
637
|
|
634
638
|
variables.forEach(function (key) {
|
635
639
|
delete options.params[key];
|
636
640
|
});
|
637
641
|
|
638
642
|
return url;
|
639
|
-
}
|
643
|
+
};
|
640
644
|
|
641
645
|
/**
|
642
646
|
* Service for URL templating.
|
643
647
|
*/
|
644
648
|
|
645
|
-
var ie = document.documentMode;
|
646
|
-
var el = document.createElement('a');
|
647
|
-
|
648
649
|
function Url(url, params) {
|
649
650
|
|
650
|
-
var self = this || {},
|
651
|
-
options = url,
|
652
|
-
transform;
|
651
|
+
var self = this || {}, options$$1 = url, transform;
|
653
652
|
|
654
653
|
if (isString(url)) {
|
655
|
-
options = {
|
654
|
+
options$$1 = {url: url, params: params};
|
656
655
|
}
|
657
656
|
|
658
|
-
options = merge({}, Url.options, self.$options, options);
|
657
|
+
options$$1 = merge({}, Url.options, self.$options, options$$1);
|
659
658
|
|
660
659
|
Url.transforms.forEach(function (handler) {
|
661
660
|
transform = factory(handler, transform, self.$vm);
|
662
661
|
});
|
663
662
|
|
664
|
-
return transform(options);
|
663
|
+
return transform(options$$1);
|
665
664
|
}
|
666
665
|
|
667
666
|
/**
|
@@ -688,8 +687,7 @@ Url.transforms = [template, query, root];
|
|
688
687
|
|
689
688
|
Url.params = function (obj) {
|
690
689
|
|
691
|
-
var params = [],
|
692
|
-
escape = encodeURIComponent;
|
690
|
+
var params = [], escape = encodeURIComponent;
|
693
691
|
|
694
692
|
params.add = function (key, value) {
|
695
693
|
|
@@ -717,7 +715,9 @@ Url.params = function (obj) {
|
|
717
715
|
|
718
716
|
Url.parse = function (url) {
|
719
717
|
|
720
|
-
|
718
|
+
var el = document.createElement('a');
|
719
|
+
|
720
|
+
if (document.documentMode) {
|
721
721
|
el.href = url;
|
722
722
|
url = el.href;
|
723
723
|
}
|
@@ -737,16 +737,14 @@ Url.parse = function (url) {
|
|
737
737
|
};
|
738
738
|
|
739
739
|
function factory(handler, next, vm) {
|
740
|
-
return function (options) {
|
741
|
-
return handler.call(vm, options, next);
|
740
|
+
return function (options$$1) {
|
741
|
+
return handler.call(vm, options$$1, next);
|
742
742
|
};
|
743
743
|
}
|
744
744
|
|
745
745
|
function serialize(params, obj, scope) {
|
746
746
|
|
747
|
-
var array = isArray(obj),
|
748
|
-
plain = isPlainObject(obj),
|
749
|
-
hash;
|
747
|
+
var array = isArray(obj), plain = isPlainObject(obj), hash;
|
750
748
|
|
751
749
|
each(obj, function (value, key) {
|
752
750
|
|
@@ -770,12 +768,11 @@ function serialize(params, obj, scope) {
|
|
770
768
|
* XDomain client (Internet Explorer).
|
771
769
|
*/
|
772
770
|
|
773
|
-
|
771
|
+
var xdrClient = function (request) {
|
774
772
|
return new PromiseObj(function (resolve) {
|
775
773
|
|
776
|
-
var xdr = new XDomainRequest(),
|
777
|
-
|
778
|
-
var type = _ref.type;
|
774
|
+
var xdr = new XDomainRequest(), handler = function (ref) {
|
775
|
+
var type = ref.type;
|
779
776
|
|
780
777
|
|
781
778
|
var status = 0;
|
@@ -786,64 +783,63 @@ function xdrClient (request) {
|
|
786
783
|
status = 500;
|
787
784
|
}
|
788
785
|
|
789
|
-
resolve(request.respondWith(xdr.responseText, {
|
786
|
+
resolve(request.respondWith(xdr.responseText, {status: status}));
|
790
787
|
};
|
791
788
|
|
792
|
-
request.abort = function () {
|
793
|
-
return xdr.abort();
|
794
|
-
};
|
789
|
+
request.abort = function () { return xdr.abort(); };
|
795
790
|
|
796
791
|
xdr.open(request.method, request.getUrl());
|
797
|
-
|
792
|
+
|
793
|
+
if (request.timeout) {
|
794
|
+
xdr.timeout = request.timeout;
|
795
|
+
}
|
796
|
+
|
798
797
|
xdr.onload = handler;
|
798
|
+
xdr.onabort = handler;
|
799
799
|
xdr.onerror = handler;
|
800
800
|
xdr.ontimeout = handler;
|
801
801
|
xdr.onprogress = function () {};
|
802
802
|
xdr.send(request.getBody());
|
803
803
|
});
|
804
|
-
}
|
804
|
+
};
|
805
805
|
|
806
806
|
/**
|
807
807
|
* CORS Interceptor.
|
808
808
|
*/
|
809
809
|
|
810
|
-
var
|
811
|
-
var SUPPORTS_CORS = 'withCredentials' in new XMLHttpRequest();
|
810
|
+
var SUPPORTS_CORS = inBrowser && 'withCredentials' in new XMLHttpRequest();
|
812
811
|
|
813
|
-
|
812
|
+
var cors = function (request, next) {
|
814
813
|
|
815
|
-
if (
|
816
|
-
request.crossOrigin = true;
|
817
|
-
}
|
814
|
+
if (inBrowser) {
|
818
815
|
|
819
|
-
|
816
|
+
var orgUrl = Url.parse(location.href);
|
817
|
+
var reqUrl = Url.parse(request.getUrl());
|
820
818
|
|
821
|
-
if (
|
822
|
-
request.client = xdrClient;
|
823
|
-
}
|
819
|
+
if (reqUrl.protocol !== orgUrl.protocol || reqUrl.host !== orgUrl.host) {
|
824
820
|
|
825
|
-
|
821
|
+
request.crossOrigin = true;
|
822
|
+
request.emulateHTTP = false;
|
823
|
+
|
824
|
+
if (!SUPPORTS_CORS) {
|
825
|
+
request.client = xdrClient;
|
826
|
+
}
|
827
|
+
}
|
826
828
|
}
|
827
829
|
|
828
830
|
next();
|
829
|
-
}
|
830
|
-
|
831
|
-
function crossOrigin(request) {
|
832
|
-
|
833
|
-
var requestUrl = Url.parse(Url(request));
|
834
|
-
|
835
|
-
return requestUrl.protocol !== ORIGIN_URL.protocol || requestUrl.host !== ORIGIN_URL.host;
|
836
|
-
}
|
831
|
+
};
|
837
832
|
|
838
833
|
/**
|
839
834
|
* Body Interceptor.
|
840
835
|
*/
|
841
836
|
|
842
|
-
|
837
|
+
var body = function (request, next) {
|
843
838
|
|
844
839
|
if (isFormData(request.body)) {
|
845
840
|
|
846
841
|
request.headers.delete('Content-Type');
|
842
|
+
|
847
843
|
} else if (isObject(request.body) || isArray(request.body)) {
|
848
844
|
|
849
845
|
if (request.emulateJSON) {
|
@@ -857,49 +853,58 @@ function body (request, next) {
|
|
857
853
|
next(function (response) {
|
858
854
|
|
859
855
|
Object.defineProperty(response, 'data', {
|
860
|
-
|
856
|
+
|
857
|
+
get: function get() {
|
861
858
|
return this.body;
|
862
859
|
},
|
863
|
-
|
860
|
+
|
861
|
+
set: function set(body) {
|
864
862
|
this.body = body;
|
865
863
|
}
|
864
|
+
|
866
865
|
});
|
867
866
|
|
868
867
|
return response.bodyText ? when(response.text(), function (text) {
|
869
868
|
|
870
|
-
var type = response.headers.get('Content-Type');
|
869
|
+
var type = response.headers.get('Content-Type') || '';
|
871
870
|
|
872
|
-
if (
|
871
|
+
if (type.indexOf('application/json') === 0 || isJson(text)) {
|
873
872
|
|
874
873
|
try {
|
875
874
|
response.body = JSON.parse(text);
|
876
875
|
} catch (e) {
|
877
876
|
response.body = null;
|
878
877
|
}
|
878
|
+
|
879
879
|
} else {
|
880
880
|
response.body = text;
|
881
881
|
}
|
882
882
|
|
883
883
|
return response;
|
884
|
+
|
884
885
|
}) : response;
|
886
|
+
|
885
887
|
});
|
888
|
+
};
|
889
|
+
|
890
|
+
function isJson(str) {
|
891
|
+
|
892
|
+
var start = str.match(/^\[|^\{(?!\{)/), end = {'[': /]$/, '{': /}$/};
|
893
|
+
|
894
|
+
return start && end[start[0]].test(str);
|
886
895
|
}
|
887
896
|
|
888
897
|
/**
|
889
|
-
* JSONP client.
|
898
|
+
* JSONP client (Browser).
|
890
899
|
*/
|
891
900
|
|
892
|
-
|
901
|
+
var jsonpClient = function (request) {
|
893
902
|
return new PromiseObj(function (resolve) {
|
894
903
|
|
895
|
-
var name = request.jsonp || 'callback',
|
896
|
-
callback = '_jsonp' + Math.random().toString(36).substr(2),
|
897
|
-
body = null,
|
898
|
-
handler,
|
899
|
-
script;
|
904
|
+
var name = request.jsonp || 'callback', callback = request.jsonpCallback || '_jsonp' + Math.random().toString(36).substr(2), body = null, handler, script;
|
900
905
|
|
901
|
-
handler = function (
|
902
|
-
var type =
|
906
|
+
handler = function (ref) {
|
907
|
+
var type = ref.type;
|
903
908
|
|
904
909
|
|
905
910
|
var status = 0;
|
@@ -910,18 +915,28 @@ function jsonpClient (request) {
|
|
910
915
|
status = 500;
|
911
916
|
}
|
912
917
|
|
913
|
-
|
918
|
+
if (status && window[callback]) {
|
919
|
+
delete window[callback];
|
920
|
+
document.body.removeChild(script);
|
921
|
+
}
|
914
922
|
|
915
|
-
|
916
|
-
document.body.removeChild(script);
|
923
|
+
resolve(request.respondWith(body, {status: status}));
|
917
924
|
};
|
918
925
|
|
919
|
-
request.params[name] = callback;
|
920
|
-
|
921
926
|
window[callback] = function (result) {
|
922
927
|
body = JSON.stringify(result);
|
923
928
|
};
|
924
929
|
|
930
|
+
request.abort = function () {
|
931
|
+
handler({type: 'abort'});
|
932
|
+
};
|
933
|
+
|
934
|
+
request.params[name] = callback;
|
935
|
+
|
936
|
+
if (request.timeout) {
|
937
|
+
setTimeout(request.abort, request.timeout);
|
938
|
+
}
|
939
|
+
|
925
940
|
script = document.createElement('script');
|
926
941
|
script.src = request.getUrl();
|
927
942
|
script.type = 'text/javascript';
|
@@ -931,50 +946,39 @@ function jsonpClient (request) {
|
|
931
946
|
|
932
947
|
document.body.appendChild(script);
|
933
948
|
});
|
934
|
-
}
|
949
|
+
};
|
935
950
|
|
936
951
|
/**
|
937
952
|
* JSONP Interceptor.
|
938
953
|
*/
|
939
954
|
|
940
|
-
|
955
|
+
var jsonp = function (request, next) {
|
941
956
|
|
942
957
|
if (request.method == 'JSONP') {
|
943
958
|
request.client = jsonpClient;
|
944
959
|
}
|
945
960
|
|
946
|
-
next(
|
947
|
-
|
948
|
-
if (request.method == 'JSONP') {
|
949
|
-
|
950
|
-
return when(response.json(), function (json) {
|
951
|
-
|
952
|
-
response.body = json;
|
953
|
-
|
954
|
-
return response;
|
955
|
-
});
|
956
|
-
}
|
957
|
-
});
|
958
|
-
}
|
961
|
+
next();
|
962
|
+
};
|
959
963
|
|
960
964
|
/**
|
961
965
|
* Before Interceptor.
|
962
966
|
*/
|
963
967
|
|
964
|
-
|
968
|
+
var before = function (request, next) {
|
965
969
|
|
966
970
|
if (isFunction(request.before)) {
|
967
971
|
request.before.call(this, request);
|
968
972
|
}
|
969
973
|
|
970
974
|
next();
|
971
|
-
}
|
975
|
+
};
|
972
976
|
|
973
977
|
/**
|
974
978
|
* HTTP method override Interceptor.
|
975
979
|
*/
|
976
980
|
|
977
|
-
|
981
|
+
var method = function (request, next) {
|
978
982
|
|
979
983
|
if (request.emulateHTTP && /^(PUT|PATCH|DELETE)$/i.test(request.method)) {
|
980
984
|
request.headers.set('X-HTTP-Method-Override', request.method);
|
@@ -982,15 +986,18 @@ function method (request, next) {
|
|
982
986
|
}
|
983
987
|
|
984
988
|
next();
|
985
|
-
}
|
989
|
+
};
|
986
990
|
|
987
991
|
/**
|
988
992
|
* Header Interceptor.
|
989
993
|
*/
|
990
994
|
|
991
|
-
|
995
|
+
var header = function (request, next) {
|
992
996
|
|
993
|
-
var headers = assign({}, Http.headers.common,
|
997
|
+
var headers = assign({}, Http.headers.common,
|
998
|
+
!request.crossOrigin ? Http.headers.custom : {},
|
999
|
+
Http.headers[toLower(request.method)]
|
1000
|
+
);
|
994
1001
|
|
995
1002
|
each(headers, function (value, name) {
|
996
1003
|
if (!request.headers.has(name)) {
|
@@ -999,42 +1006,25 @@ function header (request, next) {
|
|
999
1006
|
});
|
1000
1007
|
|
1001
1008
|
next();
|
1002
|
-
}
|
1009
|
+
};
|
1003
1010
|
|
1004
1011
|
/**
|
1005
|
-
*
|
1012
|
+
* XMLHttp client (Browser).
|
1006
1013
|
*/
|
1007
1014
|
|
1008
|
-
|
1009
|
-
|
1010
|
-
var timeout;
|
1011
|
-
|
1012
|
-
if (request.timeout) {
|
1013
|
-
timeout = setTimeout(function () {
|
1014
|
-
request.abort();
|
1015
|
-
}, request.timeout);
|
1016
|
-
}
|
1017
|
-
|
1018
|
-
next(function (response) {
|
1019
|
-
|
1020
|
-
clearTimeout(timeout);
|
1021
|
-
});
|
1022
|
-
}
|
1015
|
+
var SUPPORTS_BLOB = typeof Blob !== 'undefined' && typeof FileReader !== 'undefined';
|
1023
1016
|
|
1024
|
-
|
1025
|
-
* XMLHttp client.
|
1026
|
-
*/
|
1027
|
-
|
1028
|
-
function xhrClient (request) {
|
1017
|
+
var xhrClient = function (request) {
|
1029
1018
|
return new PromiseObj(function (resolve) {
|
1030
1019
|
|
1031
|
-
var xhr = new XMLHttpRequest(),
|
1032
|
-
handler = function (event) {
|
1020
|
+
var xhr = new XMLHttpRequest(), handler = function (event) {
|
1033
1021
|
|
1034
|
-
var response = request.respondWith(
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1022
|
+
var response = request.respondWith(
|
1023
|
+
'response' in xhr ? xhr.response : xhr.responseText, {
|
1024
|
+
status: xhr.status === 1223 ? 204 : xhr.status, // IE9 status bug
|
1025
|
+
statusText: xhr.status === 1223 ? 'No Content' : trim(xhr.statusText)
|
1026
|
+
}
|
1027
|
+
);
|
1038
1028
|
|
1039
1029
|
each(trim(xhr.getAllResponseHeaders()).split('\n'), function (row) {
|
1040
1030
|
response.headers.append(row.slice(0, row.indexOf(':')), row.slice(row.indexOf(':') + 1));
|
@@ -1043,9 +1033,7 @@ function xhrClient (request) {
|
|
1043
1033
|
resolve(response);
|
1044
1034
|
};
|
1045
1035
|
|
1046
|
-
request.abort = function () {
|
1047
|
-
return xhr.abort();
|
1048
|
-
};
|
1036
|
+
request.abort = function () { return xhr.abort(); };
|
1049
1037
|
|
1050
1038
|
if (request.progress) {
|
1051
1039
|
if (request.method === 'GET') {
|
@@ -1057,34 +1045,78 @@ function xhrClient (request) {
|
|
1057
1045
|
|
1058
1046
|
xhr.open(request.method, request.getUrl(), true);
|
1059
1047
|
|
1060
|
-
if (
|
1061
|
-
xhr.
|
1048
|
+
if (request.timeout) {
|
1049
|
+
xhr.timeout = request.timeout;
|
1062
1050
|
}
|
1063
1051
|
|
1064
1052
|
if (request.credentials === true) {
|
1065
1053
|
xhr.withCredentials = true;
|
1066
1054
|
}
|
1067
1055
|
|
1056
|
+
if (!request.crossOrigin) {
|
1057
|
+
request.headers.set('X-Requested-With', 'XMLHttpRequest');
|
1058
|
+
}
|
1059
|
+
|
1060
|
+
if ('responseType' in xhr && SUPPORTS_BLOB) {
|
1061
|
+
xhr.responseType = 'blob';
|
1062
|
+
}
|
1063
|
+
|
1068
1064
|
request.headers.forEach(function (value, name) {
|
1069
1065
|
xhr.setRequestHeader(name, value);
|
1070
1066
|
});
|
1071
1067
|
|
1072
|
-
xhr.timeout = 0;
|
1073
1068
|
xhr.onload = handler;
|
1069
|
+
xhr.onabort = handler;
|
1074
1070
|
xhr.onerror = handler;
|
1071
|
+
xhr.ontimeout = handler;
|
1075
1072
|
xhr.send(request.getBody());
|
1076
1073
|
});
|
1077
|
-
}
|
1074
|
+
};
|
1075
|
+
|
1076
|
+
/**
|
1077
|
+
* Http client (Node).
|
1078
|
+
*/
|
1079
|
+
|
1080
|
+
var nodeClient = function (request) {
|
1081
|
+
|
1082
|
+
var client = require('got');
|
1083
|
+
|
1084
|
+
return new PromiseObj(function (resolve) {
|
1085
|
+
|
1086
|
+
var url = request.getUrl();
|
1087
|
+
var body = request.getBody();
|
1088
|
+
var method = request.method;
|
1089
|
+
var headers = {}, handler;
|
1090
|
+
|
1091
|
+
request.headers.forEach(function (value, name) {
|
1092
|
+
headers[name] = value;
|
1093
|
+
});
|
1094
|
+
|
1095
|
+
client(url, {body: body, method: method, headers: headers}).then(handler = function (resp) {
|
1096
|
+
|
1097
|
+
var response = request.respondWith(resp.body, {
|
1098
|
+
status: resp.statusCode,
|
1099
|
+
statusText: trim(resp.statusMessage)
|
1100
|
+
}
|
1101
|
+
);
|
1102
|
+
|
1103
|
+
each(resp.headers, function (value, name) {
|
1104
|
+
response.headers.set(name, value);
|
1105
|
+
});
|
1106
|
+
|
1107
|
+
resolve(response);
|
1108
|
+
|
1109
|
+
}, function (error$$1) { return handler(error$$1.response); });
|
1110
|
+
});
|
1111
|
+
};
|
1078
1112
|
|
1079
1113
|
/**
|
1080
1114
|
* Base client.
|
1081
1115
|
*/
|
1082
1116
|
|
1083
|
-
|
1117
|
+
var Client = function (context) {
|
1084
1118
|
|
1085
|
-
var reqHandlers = [sendRequest],
|
1086
|
-
resHandlers = [],
|
1087
|
-
handler;
|
1119
|
+
var reqHandlers = [sendRequest], resHandlers = [], handler;
|
1088
1120
|
|
1089
1121
|
if (!isObject(context)) {
|
1090
1122
|
context = null;
|
@@ -1100,7 +1132,7 @@ function Client (context) {
|
|
1100
1132
|
if (isFunction(handler)) {
|
1101
1133
|
handler.call(context, request, next);
|
1102
1134
|
} else {
|
1103
|
-
warn(
|
1135
|
+
warn(("Invalid interceptor of type " + (typeof handler) + ", must be a function"));
|
1104
1136
|
next();
|
1105
1137
|
}
|
1106
1138
|
}
|
@@ -1110,6 +1142,7 @@ function Client (context) {
|
|
1110
1142
|
if (isFunction(response)) {
|
1111
1143
|
|
1112
1144
|
resHandlers.unshift(response);
|
1145
|
+
|
1113
1146
|
} else if (isObject(response)) {
|
1114
1147
|
|
1115
1148
|
resHandlers.forEach(function (handler) {
|
@@ -1127,6 +1160,7 @@ function Client (context) {
|
|
1127
1160
|
}
|
1128
1161
|
|
1129
1162
|
exec();
|
1163
|
+
|
1130
1164
|
}, context);
|
1131
1165
|
}
|
1132
1166
|
|
@@ -1135,85 +1169,73 @@ function Client (context) {
|
|
1135
1169
|
};
|
1136
1170
|
|
1137
1171
|
return Client;
|
1138
|
-
}
|
1172
|
+
};
|
1139
1173
|
|
1140
1174
|
function sendRequest(request, resolve) {
|
1141
1175
|
|
1142
|
-
var client = request.client || xhrClient;
|
1176
|
+
var client = request.client || (inBrowser ? xhrClient : nodeClient);
|
1143
1177
|
|
1144
1178
|
resolve(client(request));
|
1145
1179
|
}
|
1146
1180
|
|
1147
|
-
var classCallCheck = function (instance, Constructor) {
|
1148
|
-
if (!(instance instanceof Constructor)) {
|
1149
|
-
throw new TypeError("Cannot call a class as a function");
|
1150
|
-
}
|
1151
|
-
};
|
1152
|
-
|
1153
1181
|
/**
|
1154
1182
|
* HTTP Headers.
|
1155
1183
|
*/
|
1156
1184
|
|
1157
|
-
var Headers = function () {
|
1158
|
-
|
1159
|
-
var _this = this;
|
1185
|
+
var Headers = function Headers(headers) {
|
1186
|
+
var this$1 = this;
|
1160
1187
|
|
1161
|
-
classCallCheck(this, Headers);
|
1162
1188
|
|
1189
|
+
this.map = {};
|
1163
1190
|
|
1164
|
-
|
1165
|
-
|
1166
|
-
each(headers, function (value, name) {
|
1167
|
-
return _this.append(name, value);
|
1168
|
-
});
|
1169
|
-
}
|
1191
|
+
each(headers, function (value, name) { return this$1.append(name, value); });
|
1192
|
+
};
|
1170
1193
|
|
1171
|
-
|
1172
|
-
|
1173
|
-
|
1194
|
+
Headers.prototype.has = function has (name) {
|
1195
|
+
return getName(this.map, name) !== null;
|
1196
|
+
};
|
1174
1197
|
|
1175
|
-
|
1198
|
+
Headers.prototype.get = function get (name) {
|
1176
1199
|
|
1177
|
-
|
1200
|
+
var list = this.map[getName(this.map, name)];
|
1178
1201
|
|
1179
|
-
|
1180
|
-
|
1202
|
+
return list ? list.join() : null;
|
1203
|
+
};
|
1181
1204
|
|
1182
|
-
|
1183
|
-
|
1184
|
-
|
1205
|
+
Headers.prototype.getAll = function getAll (name) {
|
1206
|
+
return this.map[getName(this.map, name)] || [];
|
1207
|
+
};
|
1185
1208
|
|
1186
|
-
|
1187
|
-
|
1188
|
-
|
1209
|
+
Headers.prototype.set = function set (name, value) {
|
1210
|
+
this.map[normalizeName(getName(this.map, name) || name)] = [trim(value)];
|
1211
|
+
};
|
1189
1212
|
|
1190
|
-
|
1213
|
+
Headers.prototype.append = function append (name, value){
|
1191
1214
|
|
1192
|
-
|
1215
|
+
var list = this.map[getName(this.map, name)];
|
1193
1216
|
|
1194
|
-
|
1195
|
-
|
1196
|
-
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1217
|
+
if (list) {
|
1218
|
+
list.push(trim(value));
|
1219
|
+
} else {
|
1220
|
+
this.set(name, value);
|
1221
|
+
}
|
1222
|
+
};
|
1200
1223
|
|
1201
|
-
|
1202
|
-
|
1203
|
-
|
1224
|
+
Headers.prototype.delete = function delete$1 (name){
|
1225
|
+
delete this.map[getName(this.map, name)];
|
1226
|
+
};
|
1204
1227
|
|
1205
|
-
|
1206
|
-
|
1228
|
+
Headers.prototype.deleteAll = function deleteAll (){
|
1229
|
+
this.map = {};
|
1230
|
+
};
|
1207
1231
|
|
1208
|
-
|
1209
|
-
|
1210
|
-
return callback.call(thisArg, value, name, _this2);
|
1211
|
-
});
|
1212
|
-
});
|
1213
|
-
};
|
1232
|
+
Headers.prototype.forEach = function forEach (callback, thisArg) {
|
1233
|
+
var this$1 = this;
|
1214
1234
|
|
1215
|
-
|
1216
|
-
|
1235
|
+
each(this.map, function (list, name) {
|
1236
|
+
each(list, function (value) { return callback.call(thisArg, value, name, this$1); });
|
1237
|
+
});
|
1238
|
+
};
|
1217
1239
|
|
1218
1240
|
function getName(map, name) {
|
1219
1241
|
return Object.keys(map).reduce(function (prev, curr) {
|
@@ -1234,51 +1256,45 @@ function normalizeName(name) {
|
|
1234
1256
|
* HTTP Response.
|
1235
1257
|
*/
|
1236
1258
|
|
1237
|
-
var Response = function () {
|
1238
|
-
|
1239
|
-
|
1240
|
-
|
1241
|
-
|
1242
|
-
var statusText = _ref.statusText;
|
1243
|
-
classCallCheck(this, Response);
|
1259
|
+
var Response = function Response(body, ref) {
|
1260
|
+
var url = ref.url;
|
1261
|
+
var headers = ref.headers;
|
1262
|
+
var status = ref.status;
|
1263
|
+
var statusText = ref.statusText;
|
1244
1264
|
|
1245
1265
|
|
1246
|
-
|
1247
|
-
|
1248
|
-
|
1249
|
-
|
1250
|
-
|
1251
|
-
|
1266
|
+
this.url = url;
|
1267
|
+
this.ok = status >= 200 && status < 300;
|
1268
|
+
this.status = status || 0;
|
1269
|
+
this.statusText = statusText || '';
|
1270
|
+
this.headers = new Headers(headers);
|
1271
|
+
this.body = body;
|
1252
1272
|
|
1253
|
-
|
1273
|
+
if (isString(body)) {
|
1254
1274
|
|
1255
|
-
|
1256
|
-
} else if (isBlob(body)) {
|
1275
|
+
this.bodyText = body;
|
1257
1276
|
|
1258
|
-
|
1277
|
+
} else if (isBlob(body)) {
|
1259
1278
|
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
1279
|
+
this.bodyBlob = body;
|
1280
|
+
|
1281
|
+
if (isBlobText(body)) {
|
1282
|
+
this.bodyText = blobText(body);
|
1263
1283
|
}
|
1264
1284
|
}
|
1285
|
+
};
|
1265
1286
|
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
Response.prototype.text = function text() {
|
1271
|
-
return when(this.bodyText);
|
1272
|
-
};
|
1287
|
+
Response.prototype.blob = function blob () {
|
1288
|
+
return when(this.bodyBlob);
|
1289
|
+
};
|
1273
1290
|
|
1274
|
-
|
1275
|
-
|
1276
|
-
|
1277
|
-
});
|
1278
|
-
};
|
1291
|
+
Response.prototype.text = function text () {
|
1292
|
+
return when(this.bodyText);
|
1293
|
+
};
|
1279
1294
|
|
1280
|
-
|
1281
|
-
|
1295
|
+
Response.prototype.json = function json () {
|
1296
|
+
return when(this.text(), function (text) { return JSON.parse(text); });
|
1297
|
+
};
|
1282
1298
|
|
1283
1299
|
function blobText(body) {
|
1284
1300
|
return new PromiseObj(function (resolve) {
|
@@ -1289,6 +1305,7 @@ function blobText(body) {
|
|
1289
1305
|
reader.onload = function () {
|
1290
1306
|
resolve(reader.result);
|
1291
1307
|
};
|
1308
|
+
|
1292
1309
|
});
|
1293
1310
|
}
|
1294
1311
|
|
@@ -1300,60 +1317,53 @@ function isBlobText(body) {
|
|
1300
1317
|
* HTTP Request.
|
1301
1318
|
*/
|
1302
1319
|
|
1303
|
-
var Request = function () {
|
1304
|
-
function Request(options) {
|
1305
|
-
classCallCheck(this, Request);
|
1306
|
-
|
1320
|
+
var Request = function Request(options$$1) {
|
1307
1321
|
|
1308
|
-
|
1309
|
-
|
1322
|
+
this.body = null;
|
1323
|
+
this.params = {};
|
1310
1324
|
|
1311
|
-
|
1312
|
-
|
1313
|
-
|
1325
|
+
assign(this, options$$1, {
|
1326
|
+
method: toUpper(options$$1.method || 'GET')
|
1327
|
+
});
|
1314
1328
|
|
1315
|
-
|
1316
|
-
|
1317
|
-
}
|
1329
|
+
if (!(this.headers instanceof Headers)) {
|
1330
|
+
this.headers = new Headers(this.headers);
|
1318
1331
|
}
|
1332
|
+
};
|
1319
1333
|
|
1320
|
-
|
1321
|
-
|
1322
|
-
|
1323
|
-
|
1324
|
-
Request.prototype.getBody = function getBody() {
|
1325
|
-
return this.body;
|
1326
|
-
};
|
1334
|
+
Request.prototype.getUrl = function getUrl (){
|
1335
|
+
return Url(this);
|
1336
|
+
};
|
1327
1337
|
|
1328
|
-
|
1329
|
-
|
1330
|
-
|
1338
|
+
Request.prototype.getBody = function getBody (){
|
1339
|
+
return this.body;
|
1340
|
+
};
|
1331
1341
|
|
1332
|
-
|
1333
|
-
}();
|
1342
|
+
Request.prototype.respondWith = function respondWith (body, options$$1) {
|
1343
|
+
return new Response(body, assign(options$$1 || {}, {url: this.getUrl()}));
|
1344
|
+
};
|
1334
1345
|
|
1335
1346
|
/**
|
1336
1347
|
* Service for sending network requests.
|
1337
1348
|
*/
|
1338
1349
|
|
1339
|
-
var
|
1340
|
-
var
|
1341
|
-
var JSON_CONTENT_TYPE = { 'Content-Type': 'application/json;charset=utf-8' };
|
1350
|
+
var COMMON_HEADERS = {'Accept': 'application/json, text/plain, */*'};
|
1351
|
+
var JSON_CONTENT_TYPE = {'Content-Type': 'application/json;charset=utf-8'};
|
1342
1352
|
|
1343
|
-
function Http(options) {
|
1353
|
+
function Http(options$$1) {
|
1344
1354
|
|
1345
|
-
var self = this || {},
|
1346
|
-
client = Client(self.$vm);
|
1355
|
+
var self = this || {}, client = Client(self.$vm);
|
1347
1356
|
|
1348
|
-
defaults(options || {}, self.$options, Http.options);
|
1357
|
+
defaults(options$$1 || {}, self.$options, Http.options);
|
1349
1358
|
|
1350
1359
|
Http.interceptors.forEach(function (handler) {
|
1351
1360
|
client.use(handler);
|
1352
1361
|
});
|
1353
1362
|
|
1354
|
-
return client(new Request(options)).then(function (response) {
|
1363
|
+
return client(new Request(options$$1)).then(function (response) {
|
1355
1364
|
|
1356
1365
|
return response.ok ? response : PromiseObj.reject(response);
|
1366
|
+
|
1357
1367
|
}, function (response) {
|
1358
1368
|
|
1359
1369
|
if (response instanceof Error) {
|
@@ -1371,40 +1381,44 @@ Http.headers = {
|
|
1371
1381
|
post: JSON_CONTENT_TYPE,
|
1372
1382
|
patch: JSON_CONTENT_TYPE,
|
1373
1383
|
delete: JSON_CONTENT_TYPE,
|
1374
|
-
|
1375
|
-
|
1384
|
+
common: COMMON_HEADERS,
|
1385
|
+
custom: {}
|
1376
1386
|
};
|
1377
1387
|
|
1378
|
-
Http.interceptors = [before,
|
1388
|
+
Http.interceptors = [before, method, body, jsonp, header, cors];
|
1379
1389
|
|
1380
|
-
['get', 'delete', 'head', 'jsonp'].forEach(function (method) {
|
1390
|
+
['get', 'delete', 'head', 'jsonp'].forEach(function (method$$1) {
|
1381
1391
|
|
1382
|
-
Http[method] = function (url, options) {
|
1383
|
-
return this(assign(options || {}, {
|
1392
|
+
Http[method$$1] = function (url, options$$1) {
|
1393
|
+
return this(assign(options$$1 || {}, {url: url, method: method$$1}));
|
1384
1394
|
};
|
1395
|
+
|
1385
1396
|
});
|
1386
1397
|
|
1387
|
-
['post', 'put', 'patch'].forEach(function (method) {
|
1398
|
+
['post', 'put', 'patch'].forEach(function (method$$1) {
|
1388
1399
|
|
1389
|
-
Http[method] = function (url, body, options) {
|
1390
|
-
return this(assign(options || {}, {
|
1400
|
+
Http[method$$1] = function (url, body$$1, options$$1) {
|
1401
|
+
return this(assign(options$$1 || {}, {url: url, method: method$$1, body: body$$1}));
|
1391
1402
|
};
|
1403
|
+
|
1392
1404
|
});
|
1393
1405
|
|
1394
1406
|
/**
|
1395
1407
|
* Service for interacting with RESTful services.
|
1396
1408
|
*/
|
1397
1409
|
|
1398
|
-
function Resource(url, params, actions, options) {
|
1410
|
+
function Resource(url, params, actions, options$$1) {
|
1399
1411
|
|
1400
|
-
var self = this || {},
|
1401
|
-
resource = {};
|
1412
|
+
var self = this || {}, resource = {};
|
1402
1413
|
|
1403
|
-
actions = assign({},
|
1414
|
+
actions = assign({},
|
1415
|
+
Resource.actions,
|
1416
|
+
actions
|
1417
|
+
);
|
1404
1418
|
|
1405
1419
|
each(actions, function (action, name) {
|
1406
1420
|
|
1407
|
-
action = merge({
|
1421
|
+
action = merge({url: url, params: assign({}, params)}, options$$1, action);
|
1408
1422
|
|
1409
1423
|
resource[name] = function () {
|
1410
1424
|
return (self.$http || Http)(opts(action, arguments));
|
@@ -1416,9 +1430,7 @@ function Resource(url, params, actions, options) {
|
|
1416
1430
|
|
1417
1431
|
function opts(action, args) {
|
1418
1432
|
|
1419
|
-
var options = assign({}, action),
|
1420
|
-
params = {},
|
1421
|
-
body;
|
1433
|
+
var options$$1 = assign({}, action), params = {}, body;
|
1422
1434
|
|
1423
1435
|
switch (args.length) {
|
1424
1436
|
|
@@ -1431,7 +1443,7 @@ function opts(action, args) {
|
|
1431
1443
|
|
1432
1444
|
case 1:
|
1433
1445
|
|
1434
|
-
if (/^(POST|PUT|PATCH)$/i.test(options.method)) {
|
1446
|
+
if (/^(POST|PUT|PATCH)$/i.test(options$$1.method)) {
|
1435
1447
|
body = args[0];
|
1436
1448
|
} else {
|
1437
1449
|
params = args[0];
|
@@ -1445,23 +1457,23 @@ function opts(action, args) {
|
|
1445
1457
|
|
1446
1458
|
default:
|
1447
1459
|
|
1448
|
-
throw 'Expected up to
|
1460
|
+
throw 'Expected up to 2 arguments [params, body], got ' + args.length + ' arguments';
|
1449
1461
|
}
|
1450
1462
|
|
1451
|
-
options.body = body;
|
1452
|
-
options.params = assign({}, options.params, params);
|
1463
|
+
options$$1.body = body;
|
1464
|
+
options$$1.params = assign({}, options$$1.params, params);
|
1453
1465
|
|
1454
|
-
return options;
|
1466
|
+
return options$$1;
|
1455
1467
|
}
|
1456
1468
|
|
1457
1469
|
Resource.actions = {
|
1458
1470
|
|
1459
|
-
get: {
|
1460
|
-
save: {
|
1461
|
-
query: {
|
1462
|
-
update: {
|
1463
|
-
remove: {
|
1464
|
-
delete: {
|
1471
|
+
get: {method: 'GET'},
|
1472
|
+
save: {method: 'POST'},
|
1473
|
+
query: {method: 'GET'},
|
1474
|
+
update: {method: 'PUT'},
|
1475
|
+
remove: {method: 'DELETE'},
|
1476
|
+
delete: {method: 'DELETE'}
|
1465
1477
|
|
1466
1478
|
};
|
1467
1479
|
|
@@ -1485,30 +1497,28 @@ function plugin(Vue) {
|
|
1485
1497
|
Object.defineProperties(Vue.prototype, {
|
1486
1498
|
|
1487
1499
|
$url: {
|
1488
|
-
get: function () {
|
1500
|
+
get: function get() {
|
1489
1501
|
return options(Vue.url, this, this.$options.url);
|
1490
1502
|
}
|
1491
1503
|
},
|
1492
1504
|
|
1493
1505
|
$http: {
|
1494
|
-
get: function () {
|
1506
|
+
get: function get() {
|
1495
1507
|
return options(Vue.http, this, this.$options.http);
|
1496
1508
|
}
|
1497
1509
|
},
|
1498
1510
|
|
1499
1511
|
$resource: {
|
1500
|
-
get: function () {
|
1512
|
+
get: function get() {
|
1501
1513
|
return Vue.resource.bind(this);
|
1502
1514
|
}
|
1503
1515
|
},
|
1504
1516
|
|
1505
1517
|
$promise: {
|
1506
|
-
get: function () {
|
1507
|
-
var
|
1518
|
+
get: function get() {
|
1519
|
+
var this$1 = this;
|
1508
1520
|
|
1509
|
-
return function (executor) {
|
1510
|
-
return new Vue.Promise(executor, _this);
|
1511
|
-
};
|
1521
|
+
return function (executor) { return new Vue.Promise(executor, this$1); };
|
1512
1522
|
}
|
1513
1523
|
}
|
1514
1524
|
|