browsed 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/Gemfile.lock +2 -2
- data/README.md +12 -17
- data/bin/browse +13 -10
- data/lib/browsed.rb +9 -2
- data/lib/browsed/browser.rb +82 -0
- data/lib/browsed/chrome.rb +21 -12
- data/lib/browsed/client.rb +48 -130
- data/lib/browsed/constants.rb +7 -1
- data/lib/browsed/errors.rb +1 -0
- data/lib/browsed/extensions/hash.rb +27 -0
- data/lib/browsed/firefox.rb +18 -17
- data/lib/browsed/manager.rb +5 -5
- data/lib/browsed/{poltergeist.rb → phantomjs.rb} +2 -2
- data/lib/browsed/proxies.rb +26 -0
- data/lib/browsed/{extensions → proxies}/chrome/proxy_authentication.rb +3 -3
- data/lib/browsed/proxies/proxy-chain-server/node_modules/.bin/portastic +1 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/LICENSE +21 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/README.md +57 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/changelog.md +1 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/browser/bluebird.core.js +3824 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/browser/bluebird.core.min.js +31 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/browser/bluebird.js +5666 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/browser/bluebird.min.js +31 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/any.js +21 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/assert.js +55 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/async.js +165 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/bind.js +67 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/bluebird.js +11 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/call_get.js +123 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/cancel.js +129 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/catch_filter.js +42 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/context.js +69 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/debuggability.js +934 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/direct_resolve.js +46 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/each.js +30 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/errors.js +116 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/es5.js +80 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/filter.js +12 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/finally.js +146 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/generators.js +223 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/join.js +168 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/map.js +168 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/method.js +55 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/nodeback.js +51 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/nodeify.js +58 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/promise.js +789 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/promise_array.js +185 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/promisify.js +314 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/props.js +118 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/queue.js +73 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/race.js +49 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/reduce.js +172 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/schedule.js +62 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/settle.js +43 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/some.js +148 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/synchronous_inspection.js +103 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/thenables.js +86 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/timers.js +93 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/using.js +226 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/util.js +389 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/package.json +102 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/commander/CHANGELOG.md +408 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/commander/LICENSE +22 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/commander/Readme.md +428 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/commander/index.js +1224 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/commander/package.json +70 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/commander/typings/index.d.ts +310 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/.coveralls.yml +1 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/.eslintrc +11 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/.npmignore +9 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/.travis.yml +14 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/CHANGELOG.md +362 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/LICENSE +19 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/Makefile +50 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/README.md +312 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/component.json +19 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/karma.conf.js +70 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/node.js +1 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/package.json +88 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/src/browser.js +185 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/src/debug.js +202 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/src/index.js +10 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/src/inspector-log.js +15 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/src/node.js +248 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/ms/index.js +152 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/ms/license.md +21 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/ms/package.json +69 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/ms/readme.md +51 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/LICENSE +13 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/README.md +148 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/bin/portastic +65 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/history.md +7 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/index.js +4 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/lib/monitor.js +59 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/lib/portastic.js +167 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/LICENSE +21 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/README.md +677 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/changelog.md +1730 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/browser/bluebird.js +4892 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/browser/bluebird.min.js +31 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/any.js +21 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/assert.js +55 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/async.js +150 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/bind.js +72 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/bluebird.js +11 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/call_get.js +123 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/cancel.js +48 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/captured_trace.js +493 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/catch_filter.js +66 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/context.js +38 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/debuggability.js +162 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/direct_resolve.js +63 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/each.js +12 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/errors.js +111 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/es5.js +80 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/filter.js +12 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/finally.js +98 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/generators.js +136 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/join.js +107 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/map.js +133 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/method.js +44 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/nodeify.js +59 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/progress.js +76 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/promise.js +759 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/promise_array.js +142 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/promise_resolver.js +123 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/promisify.js +307 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/props.js +79 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/queue.js +90 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/race.js +47 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/reduce.js +148 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/schedule.js +35 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/settle.js +40 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/some.js +125 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/synchronous_inspection.js +94 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/thenables.js +84 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/timers.js +64 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/using.js +213 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/util.js +321 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/package.json +103 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/package.json +69 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/CHANGELOG.md +109 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/LICENSE +201 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/README.md +278 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/anonymize_proxy.js +100 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/handler_base.js +319 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/handler_custom_response.js +96 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/handler_forward.js +173 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/handler_tunnel_chain.js +132 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/handler_tunnel_direct.js +89 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/handler_tunnel_tcp_chain.js +271 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/index.js +26 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/run_locally.js +66 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/server.js +595 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/tcp_tunnel.js +138 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/testing_tcp_service.js +37 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/tools.js +220 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/package.json +104 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/underscore/LICENSE +23 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/underscore/README.md +28 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/underscore/package.json +81 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/underscore/underscore-min.js +5 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/underscore/underscore-min.js.map +1 -0
- data/lib/browsed/proxies/proxy-chain-server/node_modules/underscore/underscore.js +1692 -0
- data/lib/browsed/proxies/proxy-chain-server/package-lock.json +63 -0
- data/lib/browsed/proxies/proxy-chain-server/package.json +15 -0
- data/lib/browsed/proxies/proxy-chain-server/server.js +25 -0
- data/lib/browsed/proxies/proxy_chain.rb +36 -0
- data/lib/browsed/version.rb +1 -1
- metadata +160 -4
@@ -0,0 +1,226 @@
|
|
1
|
+
"use strict";
|
2
|
+
module.exports = function (Promise, apiRejection, tryConvertToPromise,
|
3
|
+
createContext, INTERNAL, debug) {
|
4
|
+
var util = require("./util");
|
5
|
+
var TypeError = require("./errors").TypeError;
|
6
|
+
var inherits = require("./util").inherits;
|
7
|
+
var errorObj = util.errorObj;
|
8
|
+
var tryCatch = util.tryCatch;
|
9
|
+
var NULL = {};
|
10
|
+
|
11
|
+
function thrower(e) {
|
12
|
+
setTimeout(function(){throw e;}, 0);
|
13
|
+
}
|
14
|
+
|
15
|
+
function castPreservingDisposable(thenable) {
|
16
|
+
var maybePromise = tryConvertToPromise(thenable);
|
17
|
+
if (maybePromise !== thenable &&
|
18
|
+
typeof thenable._isDisposable === "function" &&
|
19
|
+
typeof thenable._getDisposer === "function" &&
|
20
|
+
thenable._isDisposable()) {
|
21
|
+
maybePromise._setDisposable(thenable._getDisposer());
|
22
|
+
}
|
23
|
+
return maybePromise;
|
24
|
+
}
|
25
|
+
function dispose(resources, inspection) {
|
26
|
+
var i = 0;
|
27
|
+
var len = resources.length;
|
28
|
+
var ret = new Promise(INTERNAL);
|
29
|
+
function iterator() {
|
30
|
+
if (i >= len) return ret._fulfill();
|
31
|
+
var maybePromise = castPreservingDisposable(resources[i++]);
|
32
|
+
if (maybePromise instanceof Promise &&
|
33
|
+
maybePromise._isDisposable()) {
|
34
|
+
try {
|
35
|
+
maybePromise = tryConvertToPromise(
|
36
|
+
maybePromise._getDisposer().tryDispose(inspection),
|
37
|
+
resources.promise);
|
38
|
+
} catch (e) {
|
39
|
+
return thrower(e);
|
40
|
+
}
|
41
|
+
if (maybePromise instanceof Promise) {
|
42
|
+
return maybePromise._then(iterator, thrower,
|
43
|
+
null, null, null);
|
44
|
+
}
|
45
|
+
}
|
46
|
+
iterator();
|
47
|
+
}
|
48
|
+
iterator();
|
49
|
+
return ret;
|
50
|
+
}
|
51
|
+
|
52
|
+
function Disposer(data, promise, context) {
|
53
|
+
this._data = data;
|
54
|
+
this._promise = promise;
|
55
|
+
this._context = context;
|
56
|
+
}
|
57
|
+
|
58
|
+
Disposer.prototype.data = function () {
|
59
|
+
return this._data;
|
60
|
+
};
|
61
|
+
|
62
|
+
Disposer.prototype.promise = function () {
|
63
|
+
return this._promise;
|
64
|
+
};
|
65
|
+
|
66
|
+
Disposer.prototype.resource = function () {
|
67
|
+
if (this.promise().isFulfilled()) {
|
68
|
+
return this.promise().value();
|
69
|
+
}
|
70
|
+
return NULL;
|
71
|
+
};
|
72
|
+
|
73
|
+
Disposer.prototype.tryDispose = function(inspection) {
|
74
|
+
var resource = this.resource();
|
75
|
+
var context = this._context;
|
76
|
+
if (context !== undefined) context._pushContext();
|
77
|
+
var ret = resource !== NULL
|
78
|
+
? this.doDispose(resource, inspection) : null;
|
79
|
+
if (context !== undefined) context._popContext();
|
80
|
+
this._promise._unsetDisposable();
|
81
|
+
this._data = null;
|
82
|
+
return ret;
|
83
|
+
};
|
84
|
+
|
85
|
+
Disposer.isDisposer = function (d) {
|
86
|
+
return (d != null &&
|
87
|
+
typeof d.resource === "function" &&
|
88
|
+
typeof d.tryDispose === "function");
|
89
|
+
};
|
90
|
+
|
91
|
+
function FunctionDisposer(fn, promise, context) {
|
92
|
+
this.constructor$(fn, promise, context);
|
93
|
+
}
|
94
|
+
inherits(FunctionDisposer, Disposer);
|
95
|
+
|
96
|
+
FunctionDisposer.prototype.doDispose = function (resource, inspection) {
|
97
|
+
var fn = this.data();
|
98
|
+
return fn.call(resource, resource, inspection);
|
99
|
+
};
|
100
|
+
|
101
|
+
function maybeUnwrapDisposer(value) {
|
102
|
+
if (Disposer.isDisposer(value)) {
|
103
|
+
this.resources[this.index]._setDisposable(value);
|
104
|
+
return value.promise();
|
105
|
+
}
|
106
|
+
return value;
|
107
|
+
}
|
108
|
+
|
109
|
+
function ResourceList(length) {
|
110
|
+
this.length = length;
|
111
|
+
this.promise = null;
|
112
|
+
this[length-1] = null;
|
113
|
+
}
|
114
|
+
|
115
|
+
ResourceList.prototype._resultCancelled = function() {
|
116
|
+
var len = this.length;
|
117
|
+
for (var i = 0; i < len; ++i) {
|
118
|
+
var item = this[i];
|
119
|
+
if (item instanceof Promise) {
|
120
|
+
item.cancel();
|
121
|
+
}
|
122
|
+
}
|
123
|
+
};
|
124
|
+
|
125
|
+
Promise.using = function () {
|
126
|
+
var len = arguments.length;
|
127
|
+
if (len < 2) return apiRejection(
|
128
|
+
"you must pass at least 2 arguments to Promise.using");
|
129
|
+
var fn = arguments[len - 1];
|
130
|
+
if (typeof fn !== "function") {
|
131
|
+
return apiRejection("expecting a function but got " + util.classString(fn));
|
132
|
+
}
|
133
|
+
var input;
|
134
|
+
var spreadArgs = true;
|
135
|
+
if (len === 2 && Array.isArray(arguments[0])) {
|
136
|
+
input = arguments[0];
|
137
|
+
len = input.length;
|
138
|
+
spreadArgs = false;
|
139
|
+
} else {
|
140
|
+
input = arguments;
|
141
|
+
len--;
|
142
|
+
}
|
143
|
+
var resources = new ResourceList(len);
|
144
|
+
for (var i = 0; i < len; ++i) {
|
145
|
+
var resource = input[i];
|
146
|
+
if (Disposer.isDisposer(resource)) {
|
147
|
+
var disposer = resource;
|
148
|
+
resource = resource.promise();
|
149
|
+
resource._setDisposable(disposer);
|
150
|
+
} else {
|
151
|
+
var maybePromise = tryConvertToPromise(resource);
|
152
|
+
if (maybePromise instanceof Promise) {
|
153
|
+
resource =
|
154
|
+
maybePromise._then(maybeUnwrapDisposer, null, null, {
|
155
|
+
resources: resources,
|
156
|
+
index: i
|
157
|
+
}, undefined);
|
158
|
+
}
|
159
|
+
}
|
160
|
+
resources[i] = resource;
|
161
|
+
}
|
162
|
+
|
163
|
+
var reflectedResources = new Array(resources.length);
|
164
|
+
for (var i = 0; i < reflectedResources.length; ++i) {
|
165
|
+
reflectedResources[i] = Promise.resolve(resources[i]).reflect();
|
166
|
+
}
|
167
|
+
|
168
|
+
var resultPromise = Promise.all(reflectedResources)
|
169
|
+
.then(function(inspections) {
|
170
|
+
for (var i = 0; i < inspections.length; ++i) {
|
171
|
+
var inspection = inspections[i];
|
172
|
+
if (inspection.isRejected()) {
|
173
|
+
errorObj.e = inspection.error();
|
174
|
+
return errorObj;
|
175
|
+
} else if (!inspection.isFulfilled()) {
|
176
|
+
resultPromise.cancel();
|
177
|
+
return;
|
178
|
+
}
|
179
|
+
inspections[i] = inspection.value();
|
180
|
+
}
|
181
|
+
promise._pushContext();
|
182
|
+
|
183
|
+
fn = tryCatch(fn);
|
184
|
+
var ret = spreadArgs
|
185
|
+
? fn.apply(undefined, inspections) : fn(inspections);
|
186
|
+
var promiseCreated = promise._popContext();
|
187
|
+
debug.checkForgottenReturns(
|
188
|
+
ret, promiseCreated, "Promise.using", promise);
|
189
|
+
return ret;
|
190
|
+
});
|
191
|
+
|
192
|
+
var promise = resultPromise.lastly(function() {
|
193
|
+
var inspection = new Promise.PromiseInspection(resultPromise);
|
194
|
+
return dispose(resources, inspection);
|
195
|
+
});
|
196
|
+
resources.promise = promise;
|
197
|
+
promise._setOnCancel(resources);
|
198
|
+
return promise;
|
199
|
+
};
|
200
|
+
|
201
|
+
Promise.prototype._setDisposable = function (disposer) {
|
202
|
+
this._bitField = this._bitField | 131072;
|
203
|
+
this._disposer = disposer;
|
204
|
+
};
|
205
|
+
|
206
|
+
Promise.prototype._isDisposable = function () {
|
207
|
+
return (this._bitField & 131072) > 0;
|
208
|
+
};
|
209
|
+
|
210
|
+
Promise.prototype._getDisposer = function () {
|
211
|
+
return this._disposer;
|
212
|
+
};
|
213
|
+
|
214
|
+
Promise.prototype._unsetDisposable = function () {
|
215
|
+
this._bitField = this._bitField & (~131072);
|
216
|
+
this._disposer = undefined;
|
217
|
+
};
|
218
|
+
|
219
|
+
Promise.prototype.disposer = function (fn) {
|
220
|
+
if (typeof fn === "function") {
|
221
|
+
return new FunctionDisposer(fn, this, createContext());
|
222
|
+
}
|
223
|
+
throw new TypeError();
|
224
|
+
};
|
225
|
+
|
226
|
+
};
|
@@ -0,0 +1,389 @@
|
|
1
|
+
"use strict";
|
2
|
+
var es5 = require("./es5");
|
3
|
+
var canEvaluate = typeof navigator == "undefined";
|
4
|
+
|
5
|
+
var errorObj = {e: {}};
|
6
|
+
var tryCatchTarget;
|
7
|
+
var globalObject = typeof self !== "undefined" ? self :
|
8
|
+
typeof window !== "undefined" ? window :
|
9
|
+
typeof global !== "undefined" ? global :
|
10
|
+
this !== undefined ? this : null;
|
11
|
+
|
12
|
+
function tryCatcher() {
|
13
|
+
try {
|
14
|
+
var target = tryCatchTarget;
|
15
|
+
tryCatchTarget = null;
|
16
|
+
return target.apply(this, arguments);
|
17
|
+
} catch (e) {
|
18
|
+
errorObj.e = e;
|
19
|
+
return errorObj;
|
20
|
+
}
|
21
|
+
}
|
22
|
+
function tryCatch(fn) {
|
23
|
+
tryCatchTarget = fn;
|
24
|
+
return tryCatcher;
|
25
|
+
}
|
26
|
+
|
27
|
+
var inherits = function(Child, Parent) {
|
28
|
+
var hasProp = {}.hasOwnProperty;
|
29
|
+
|
30
|
+
function T() {
|
31
|
+
this.constructor = Child;
|
32
|
+
this.constructor$ = Parent;
|
33
|
+
for (var propertyName in Parent.prototype) {
|
34
|
+
if (hasProp.call(Parent.prototype, propertyName) &&
|
35
|
+
propertyName.charAt(propertyName.length-1) !== "$"
|
36
|
+
) {
|
37
|
+
this[propertyName + "$"] = Parent.prototype[propertyName];
|
38
|
+
}
|
39
|
+
}
|
40
|
+
}
|
41
|
+
T.prototype = Parent.prototype;
|
42
|
+
Child.prototype = new T();
|
43
|
+
return Child.prototype;
|
44
|
+
};
|
45
|
+
|
46
|
+
|
47
|
+
function isPrimitive(val) {
|
48
|
+
return val == null || val === true || val === false ||
|
49
|
+
typeof val === "string" || typeof val === "number";
|
50
|
+
|
51
|
+
}
|
52
|
+
|
53
|
+
function isObject(value) {
|
54
|
+
return typeof value === "function" ||
|
55
|
+
typeof value === "object" && value !== null;
|
56
|
+
}
|
57
|
+
|
58
|
+
function maybeWrapAsError(maybeError) {
|
59
|
+
if (!isPrimitive(maybeError)) return maybeError;
|
60
|
+
|
61
|
+
return new Error(safeToString(maybeError));
|
62
|
+
}
|
63
|
+
|
64
|
+
function withAppended(target, appendee) {
|
65
|
+
var len = target.length;
|
66
|
+
var ret = new Array(len + 1);
|
67
|
+
var i;
|
68
|
+
for (i = 0; i < len; ++i) {
|
69
|
+
ret[i] = target[i];
|
70
|
+
}
|
71
|
+
ret[i] = appendee;
|
72
|
+
return ret;
|
73
|
+
}
|
74
|
+
|
75
|
+
function getDataPropertyOrDefault(obj, key, defaultValue) {
|
76
|
+
if (es5.isES5) {
|
77
|
+
var desc = Object.getOwnPropertyDescriptor(obj, key);
|
78
|
+
|
79
|
+
if (desc != null) {
|
80
|
+
return desc.get == null && desc.set == null
|
81
|
+
? desc.value
|
82
|
+
: defaultValue;
|
83
|
+
}
|
84
|
+
} else {
|
85
|
+
return {}.hasOwnProperty.call(obj, key) ? obj[key] : undefined;
|
86
|
+
}
|
87
|
+
}
|
88
|
+
|
89
|
+
function notEnumerableProp(obj, name, value) {
|
90
|
+
if (isPrimitive(obj)) return obj;
|
91
|
+
var descriptor = {
|
92
|
+
value: value,
|
93
|
+
configurable: true,
|
94
|
+
enumerable: false,
|
95
|
+
writable: true
|
96
|
+
};
|
97
|
+
es5.defineProperty(obj, name, descriptor);
|
98
|
+
return obj;
|
99
|
+
}
|
100
|
+
|
101
|
+
function thrower(r) {
|
102
|
+
throw r;
|
103
|
+
}
|
104
|
+
|
105
|
+
var inheritedDataKeys = (function() {
|
106
|
+
var excludedPrototypes = [
|
107
|
+
Array.prototype,
|
108
|
+
Object.prototype,
|
109
|
+
Function.prototype
|
110
|
+
];
|
111
|
+
|
112
|
+
var isExcludedProto = function(val) {
|
113
|
+
for (var i = 0; i < excludedPrototypes.length; ++i) {
|
114
|
+
if (excludedPrototypes[i] === val) {
|
115
|
+
return true;
|
116
|
+
}
|
117
|
+
}
|
118
|
+
return false;
|
119
|
+
};
|
120
|
+
|
121
|
+
if (es5.isES5) {
|
122
|
+
var getKeys = Object.getOwnPropertyNames;
|
123
|
+
return function(obj) {
|
124
|
+
var ret = [];
|
125
|
+
var visitedKeys = Object.create(null);
|
126
|
+
while (obj != null && !isExcludedProto(obj)) {
|
127
|
+
var keys;
|
128
|
+
try {
|
129
|
+
keys = getKeys(obj);
|
130
|
+
} catch (e) {
|
131
|
+
return ret;
|
132
|
+
}
|
133
|
+
for (var i = 0; i < keys.length; ++i) {
|
134
|
+
var key = keys[i];
|
135
|
+
if (visitedKeys[key]) continue;
|
136
|
+
visitedKeys[key] = true;
|
137
|
+
var desc = Object.getOwnPropertyDescriptor(obj, key);
|
138
|
+
if (desc != null && desc.get == null && desc.set == null) {
|
139
|
+
ret.push(key);
|
140
|
+
}
|
141
|
+
}
|
142
|
+
obj = es5.getPrototypeOf(obj);
|
143
|
+
}
|
144
|
+
return ret;
|
145
|
+
};
|
146
|
+
} else {
|
147
|
+
var hasProp = {}.hasOwnProperty;
|
148
|
+
return function(obj) {
|
149
|
+
if (isExcludedProto(obj)) return [];
|
150
|
+
var ret = [];
|
151
|
+
|
152
|
+
/*jshint forin:false */
|
153
|
+
enumeration: for (var key in obj) {
|
154
|
+
if (hasProp.call(obj, key)) {
|
155
|
+
ret.push(key);
|
156
|
+
} else {
|
157
|
+
for (var i = 0; i < excludedPrototypes.length; ++i) {
|
158
|
+
if (hasProp.call(excludedPrototypes[i], key)) {
|
159
|
+
continue enumeration;
|
160
|
+
}
|
161
|
+
}
|
162
|
+
ret.push(key);
|
163
|
+
}
|
164
|
+
}
|
165
|
+
return ret;
|
166
|
+
};
|
167
|
+
}
|
168
|
+
|
169
|
+
})();
|
170
|
+
|
171
|
+
var thisAssignmentPattern = /this\s*\.\s*\S+\s*=/;
|
172
|
+
function isClass(fn) {
|
173
|
+
try {
|
174
|
+
if (typeof fn === "function") {
|
175
|
+
var keys = es5.names(fn.prototype);
|
176
|
+
|
177
|
+
var hasMethods = es5.isES5 && keys.length > 1;
|
178
|
+
var hasMethodsOtherThanConstructor = keys.length > 0 &&
|
179
|
+
!(keys.length === 1 && keys[0] === "constructor");
|
180
|
+
var hasThisAssignmentAndStaticMethods =
|
181
|
+
thisAssignmentPattern.test(fn + "") && es5.names(fn).length > 0;
|
182
|
+
|
183
|
+
if (hasMethods || hasMethodsOtherThanConstructor ||
|
184
|
+
hasThisAssignmentAndStaticMethods) {
|
185
|
+
return true;
|
186
|
+
}
|
187
|
+
}
|
188
|
+
return false;
|
189
|
+
} catch (e) {
|
190
|
+
return false;
|
191
|
+
}
|
192
|
+
}
|
193
|
+
|
194
|
+
function toFastProperties(obj) {
|
195
|
+
/*jshint -W027,-W055,-W031*/
|
196
|
+
function FakeConstructor() {}
|
197
|
+
FakeConstructor.prototype = obj;
|
198
|
+
var receiver = new FakeConstructor();
|
199
|
+
function ic() {
|
200
|
+
return typeof receiver.foo;
|
201
|
+
}
|
202
|
+
ic();
|
203
|
+
ic();
|
204
|
+
return obj;
|
205
|
+
eval(obj);
|
206
|
+
}
|
207
|
+
|
208
|
+
var rident = /^[a-z$_][a-z$_0-9]*$/i;
|
209
|
+
function isIdentifier(str) {
|
210
|
+
return rident.test(str);
|
211
|
+
}
|
212
|
+
|
213
|
+
function filledRange(count, prefix, suffix) {
|
214
|
+
var ret = new Array(count);
|
215
|
+
for(var i = 0; i < count; ++i) {
|
216
|
+
ret[i] = prefix + i + suffix;
|
217
|
+
}
|
218
|
+
return ret;
|
219
|
+
}
|
220
|
+
|
221
|
+
function safeToString(obj) {
|
222
|
+
try {
|
223
|
+
return obj + "";
|
224
|
+
} catch (e) {
|
225
|
+
return "[no string representation]";
|
226
|
+
}
|
227
|
+
}
|
228
|
+
|
229
|
+
function isError(obj) {
|
230
|
+
return obj instanceof Error ||
|
231
|
+
(obj !== null &&
|
232
|
+
typeof obj === "object" &&
|
233
|
+
typeof obj.message === "string" &&
|
234
|
+
typeof obj.name === "string");
|
235
|
+
}
|
236
|
+
|
237
|
+
function markAsOriginatingFromRejection(e) {
|
238
|
+
try {
|
239
|
+
notEnumerableProp(e, "isOperational", true);
|
240
|
+
}
|
241
|
+
catch(ignore) {}
|
242
|
+
}
|
243
|
+
|
244
|
+
function originatesFromRejection(e) {
|
245
|
+
if (e == null) return false;
|
246
|
+
return ((e instanceof Error["__BluebirdErrorTypes__"].OperationalError) ||
|
247
|
+
e["isOperational"] === true);
|
248
|
+
}
|
249
|
+
|
250
|
+
function canAttachTrace(obj) {
|
251
|
+
return isError(obj) && es5.propertyIsWritable(obj, "stack");
|
252
|
+
}
|
253
|
+
|
254
|
+
var ensureErrorObject = (function() {
|
255
|
+
if (!("stack" in new Error())) {
|
256
|
+
return function(value) {
|
257
|
+
if (canAttachTrace(value)) return value;
|
258
|
+
try {throw new Error(safeToString(value));}
|
259
|
+
catch(err) {return err;}
|
260
|
+
};
|
261
|
+
} else {
|
262
|
+
return function(value) {
|
263
|
+
if (canAttachTrace(value)) return value;
|
264
|
+
return new Error(safeToString(value));
|
265
|
+
};
|
266
|
+
}
|
267
|
+
})();
|
268
|
+
|
269
|
+
function classString(obj) {
|
270
|
+
return {}.toString.call(obj);
|
271
|
+
}
|
272
|
+
|
273
|
+
function copyDescriptors(from, to, filter) {
|
274
|
+
var keys = es5.names(from);
|
275
|
+
for (var i = 0; i < keys.length; ++i) {
|
276
|
+
var key = keys[i];
|
277
|
+
if (filter(key)) {
|
278
|
+
try {
|
279
|
+
es5.defineProperty(to, key, es5.getDescriptor(from, key));
|
280
|
+
} catch (ignore) {}
|
281
|
+
}
|
282
|
+
}
|
283
|
+
}
|
284
|
+
|
285
|
+
var asArray = function(v) {
|
286
|
+
if (es5.isArray(v)) {
|
287
|
+
return v;
|
288
|
+
}
|
289
|
+
return null;
|
290
|
+
};
|
291
|
+
|
292
|
+
if (typeof Symbol !== "undefined" && Symbol.iterator) {
|
293
|
+
var ArrayFrom = typeof Array.from === "function" ? function(v) {
|
294
|
+
return Array.from(v);
|
295
|
+
} : function(v) {
|
296
|
+
var ret = [];
|
297
|
+
var it = v[Symbol.iterator]();
|
298
|
+
var itResult;
|
299
|
+
while (!((itResult = it.next()).done)) {
|
300
|
+
ret.push(itResult.value);
|
301
|
+
}
|
302
|
+
return ret;
|
303
|
+
};
|
304
|
+
|
305
|
+
asArray = function(v) {
|
306
|
+
if (es5.isArray(v)) {
|
307
|
+
return v;
|
308
|
+
} else if (v != null && typeof v[Symbol.iterator] === "function") {
|
309
|
+
return ArrayFrom(v);
|
310
|
+
}
|
311
|
+
return null;
|
312
|
+
};
|
313
|
+
}
|
314
|
+
|
315
|
+
var isNode = typeof process !== "undefined" &&
|
316
|
+
classString(process).toLowerCase() === "[object process]";
|
317
|
+
|
318
|
+
var hasEnvVariables = typeof process !== "undefined" &&
|
319
|
+
typeof process.env !== "undefined";
|
320
|
+
|
321
|
+
function env(key) {
|
322
|
+
return hasEnvVariables ? process.env[key] : undefined;
|
323
|
+
}
|
324
|
+
|
325
|
+
function getNativePromise() {
|
326
|
+
if (typeof Promise === "function") {
|
327
|
+
try {
|
328
|
+
var promise = new Promise(function(){});
|
329
|
+
if ({}.toString.call(promise) === "[object Promise]") {
|
330
|
+
return Promise;
|
331
|
+
}
|
332
|
+
} catch (e) {}
|
333
|
+
}
|
334
|
+
}
|
335
|
+
|
336
|
+
function domainBind(self, cb) {
|
337
|
+
return self.bind(cb);
|
338
|
+
}
|
339
|
+
|
340
|
+
var ret = {
|
341
|
+
isClass: isClass,
|
342
|
+
isIdentifier: isIdentifier,
|
343
|
+
inheritedDataKeys: inheritedDataKeys,
|
344
|
+
getDataPropertyOrDefault: getDataPropertyOrDefault,
|
345
|
+
thrower: thrower,
|
346
|
+
isArray: es5.isArray,
|
347
|
+
asArray: asArray,
|
348
|
+
notEnumerableProp: notEnumerableProp,
|
349
|
+
isPrimitive: isPrimitive,
|
350
|
+
isObject: isObject,
|
351
|
+
isError: isError,
|
352
|
+
canEvaluate: canEvaluate,
|
353
|
+
errorObj: errorObj,
|
354
|
+
tryCatch: tryCatch,
|
355
|
+
inherits: inherits,
|
356
|
+
withAppended: withAppended,
|
357
|
+
maybeWrapAsError: maybeWrapAsError,
|
358
|
+
toFastProperties: toFastProperties,
|
359
|
+
filledRange: filledRange,
|
360
|
+
toString: safeToString,
|
361
|
+
canAttachTrace: canAttachTrace,
|
362
|
+
ensureErrorObject: ensureErrorObject,
|
363
|
+
originatesFromRejection: originatesFromRejection,
|
364
|
+
markAsOriginatingFromRejection: markAsOriginatingFromRejection,
|
365
|
+
classString: classString,
|
366
|
+
copyDescriptors: copyDescriptors,
|
367
|
+
hasDevTools: typeof chrome !== "undefined" && chrome &&
|
368
|
+
typeof chrome.loadTimes === "function",
|
369
|
+
isNode: isNode,
|
370
|
+
hasEnvVariables: hasEnvVariables,
|
371
|
+
env: env,
|
372
|
+
global: globalObject,
|
373
|
+
getNativePromise: getNativePromise,
|
374
|
+
domainBind: domainBind
|
375
|
+
};
|
376
|
+
ret.isRecentNode = ret.isNode && (function() {
|
377
|
+
var version;
|
378
|
+
if (process.versions && process.versions.node) {
|
379
|
+
version = process.versions.node.split(".").map(Number);
|
380
|
+
} else if (process.version) {
|
381
|
+
version = process.version.split(".").map(Number);
|
382
|
+
}
|
383
|
+
return (version[0] === 0 && version[1] > 10) || (version[0] > 0);
|
384
|
+
})();
|
385
|
+
|
386
|
+
if (ret.isNode) ret.toFastProperties(process);
|
387
|
+
|
388
|
+
try {throw new Error(); } catch (e) {ret.lastLineError = e;}
|
389
|
+
module.exports = ret;
|