first commit
This commit is contained in:
2
build/node_modules/phantomjs-prebuilt/.eslintignore
generated
vendored
Normal file
2
build/node_modules/phantomjs-prebuilt/.eslintignore
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
lib/phantom
|
||||
lib/location.js
|
||||
22
build/node_modules/phantomjs-prebuilt/.eslintrc
generated
vendored
Normal file
22
build/node_modules/phantomjs-prebuilt/.eslintrc
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"rules": {
|
||||
"no-console": 0,
|
||||
"quotes": [
|
||||
2,
|
||||
"single"
|
||||
],
|
||||
"linebreak-style": [
|
||||
2,
|
||||
"unix"
|
||||
],
|
||||
"semi": [
|
||||
2,
|
||||
"never"
|
||||
]
|
||||
},
|
||||
"env": {
|
||||
"node": true,
|
||||
"phantomjs": true
|
||||
},
|
||||
"extends": "eslint:recommended"
|
||||
}
|
||||
4
build/node_modules/phantomjs-prebuilt/.jshintrc
generated
vendored
Normal file
4
build/node_modules/phantomjs-prebuilt/.jshintrc
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"asi": true,
|
||||
"node": true
|
||||
}
|
||||
5
build/node_modules/phantomjs-prebuilt/.npmignore
generated
vendored
Normal file
5
build/node_modules/phantomjs-prebuilt/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
/node_modules
|
||||
/lib/phantom
|
||||
/lib/location.js
|
||||
/tmp
|
||||
npm-debug.log
|
||||
7
build/node_modules/phantomjs-prebuilt/.travis.yml
generated
vendored
Normal file
7
build/node_modules/phantomjs-prebuilt/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
language: node_js
|
||||
sudo: false
|
||||
node_js:
|
||||
- "5"
|
||||
- "4"
|
||||
- "0.12"
|
||||
- "0.10"
|
||||
194
build/node_modules/phantomjs-prebuilt/LICENSE.txt
generated
vendored
Normal file
194
build/node_modules/phantomjs-prebuilt/LICENSE.txt
generated
vendored
Normal file
@@ -0,0 +1,194 @@
|
||||
Copyright 2012 The Obvious Corporation.
|
||||
http://obvious.com/
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
308
build/node_modules/phantomjs-prebuilt/README.md
generated
vendored
Normal file
308
build/node_modules/phantomjs-prebuilt/README.md
generated
vendored
Normal file
@@ -0,0 +1,308 @@
|
||||
phantomjs-prebuilt
|
||||
==================
|
||||
|
||||
An NPM installer for [PhantomJS](http://phantomjs.org/), headless webkit with JS API.
|
||||
|
||||
[](https://travis-ci.org/Medium/phantomjs)
|
||||
|
||||
Building and Installing
|
||||
-----------------------
|
||||
|
||||
```shell
|
||||
npm install phantomjs-prebuilt
|
||||
```
|
||||
|
||||
Or grab the source and
|
||||
|
||||
```shell
|
||||
node ./install.js
|
||||
```
|
||||
|
||||
What this installer is really doing is just grabbing a particular "blessed" (by
|
||||
this module) version of Phantom. As new versions of Phantom are released
|
||||
and vetted, this module will be updated accordingly.
|
||||
|
||||
Running
|
||||
-------
|
||||
|
||||
```shell
|
||||
bin/phantomjs [phantom arguments]
|
||||
```
|
||||
|
||||
And npm will install a link to the binary in `node_modules/.bin` as
|
||||
it is wont to do.
|
||||
|
||||
Running via node
|
||||
----------------
|
||||
|
||||
The package exports a `path` string that contains the path to the
|
||||
phantomjs binary/executable.
|
||||
|
||||
Below is an example of using this package via node.
|
||||
|
||||
```javascript
|
||||
var path = require('path')
|
||||
var childProcess = require('child_process')
|
||||
var phantomjs = require('phantomjs-prebuilt')
|
||||
var binPath = phantomjs.path
|
||||
|
||||
var childArgs = [
|
||||
path.join(__dirname, 'phantomjs-script.js'),
|
||||
'some other argument (passed to phantomjs script)'
|
||||
]
|
||||
|
||||
childProcess.execFile(binPath, childArgs, function(err, stdout, stderr) {
|
||||
// handle results
|
||||
})
|
||||
|
||||
```
|
||||
|
||||
Or `exec()` method is also provided for convenience:
|
||||
|
||||
```javascript
|
||||
var phantomjs = require('phantomjs-prebuilt')
|
||||
var program = phantomjs.exec('phantomjs-script.js', 'arg1', 'arg2')
|
||||
program.stdout.pipe(process.stdout)
|
||||
program.stderr.pipe(process.stderr)
|
||||
program.on('exit', code => {
|
||||
// do something on end
|
||||
})
|
||||
```
|
||||
|
||||
Note: [childProcess.spawn()](https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options) is called inside `exec()`.
|
||||
|
||||
Running with WebDriver
|
||||
----------------------
|
||||
|
||||
`run()` method detects when PhantomJS gets ready. It's handy to use with WebDriver (Selenium).
|
||||
|
||||
```javascript
|
||||
var phantomjs = require('phantomjs-prebuilt')
|
||||
var webdriverio = require('webdriverio')
|
||||
var wdOpts = { desiredCapabilities: { browserName: 'phantomjs' } }
|
||||
|
||||
phantomjs.run('--webdriver=4444').then(program => {
|
||||
webdriverio.remote(wdOpts).init()
|
||||
.url('https://developer.mozilla.org/en-US/')
|
||||
.getTitle().then(title => {
|
||||
console.log(title) // 'Mozilla Developer Network'
|
||||
program.kill() // quits PhantomJS
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
Versioning
|
||||
----------
|
||||
|
||||
The major and minor number tracks the version of PhantomJS that will be
|
||||
installed. The patch number is incremented when there is either an installer
|
||||
update or a patch build of the phantom binary.
|
||||
|
||||
Pre-2.0, this package was published to NPM as [phantomjs](https://www.npmjs.com/package/phantomjs).
|
||||
We changed the name to [phantomjs-prebuilt](https://www.npmjs.com/package/phantomjs-prebuilt) at
|
||||
the request of PhantomJS team.
|
||||
|
||||
Continuous Integration
|
||||
----------------------
|
||||
|
||||
Please **do not** download PhantomJS for every CI job because it can quickly
|
||||
overload our CDNs. Instead take advantage of CI caching.
|
||||
|
||||
In [Travis-CI](https://travis-ci.org/) add the following to your `.travis.yml`
|
||||
to [enable caching](https://docs.travis-ci.com/user/caching/) & avoid repeated
|
||||
downloads of PhantomJS.
|
||||
|
||||
#### .travis.yml
|
||||
```yml
|
||||
cache:
|
||||
directories:
|
||||
- travis_phantomjs
|
||||
|
||||
before_install:
|
||||
# Upgrade PhantomJS to v2.1.1.
|
||||
- "export PHANTOMJS_VERSION=2.1.1"
|
||||
- "export PATH=$PWD/travis_phantomjs/phantomjs-$PHANTOMJS_VERSION-linux-x86_64/bin:$PATH"
|
||||
- "if [ $(phantomjs --version) != $PHANTOMJS_VERSION ]; then rm -rf $PWD/travis_phantomjs; mkdir -p $PWD/travis_phantomjs; fi"
|
||||
- "if [ $(phantomjs --version) != $PHANTOMJS_VERSION ]; then wget https://github.com/Medium/phantomjs/releases/download/v$PHANTOMJS_VERSION/phantomjs-$PHANTOMJS_VERSION-linux-x86_64.tar.bz2 -O $PWD/travis_phantomjs/phantomjs-$PHANTOMJS_VERSION-linux-x86_64.tar.bz2; fi"
|
||||
- "if [ $(phantomjs --version) != $PHANTOMJS_VERSION ]; then tar -xvf $PWD/travis_phantomjs/phantomjs-$PHANTOMJS_VERSION-linux-x86_64.tar.bz2 -C $PWD/travis_phantomjs; fi"
|
||||
- "phantomjs --version"
|
||||
```
|
||||
|
||||
Deciding Where To Get PhantomJS
|
||||
-------------------------------
|
||||
|
||||
By default, this package will download phantomjs from our [releases](https://github.com/Medium/phantomjs/releases/).
|
||||
This should work fine for most people.
|
||||
|
||||
##### Downloading from a custom URL
|
||||
|
||||
If github is down, or the Great Firewall is blocking github, you may need to use
|
||||
a different download mirror. To set a mirror, set npm config property `phantomjs_cdnurl`.
|
||||
|
||||
Alternatives include `https://bitbucket.org/ariya/phantomjs/downloads` (the official download site)
|
||||
and `http://cnpmjs.org/downloads`.
|
||||
|
||||
```Shell
|
||||
npm install phantomjs-prebuilt --phantomjs_cdnurl=https://bitbucket.org/ariya/phantomjs/downloads
|
||||
```
|
||||
|
||||
Or add property into your `.npmrc` file (https://www.npmjs.org/doc/files/npmrc.html)
|
||||
|
||||
```
|
||||
phantomjs_cdnurl=https://bitbucket.org/ariya/phantomjs/downloads
|
||||
```
|
||||
|
||||
Another option is to use PATH variable `PHANTOMJS_CDNURL`.
|
||||
```shell
|
||||
PHANTOMJS_CDNURL=https://bitbucket.org/ariya/phantomjs/downloads npm install phantomjs
|
||||
```
|
||||
|
||||
##### Using PhantomJS from disk
|
||||
|
||||
If you plan to install phantomjs many times on a single machine, you can
|
||||
install the `phantomjs` binary on PATH. The installer will automatically detect
|
||||
and use that for non-global installs.
|
||||
|
||||
Cross-Platform Repositories
|
||||
---------------------------
|
||||
|
||||
PhantomJS needs to be compiled separately for each platform. This installer
|
||||
finds a prebuilt binary for your operating system, and downloads it.
|
||||
|
||||
If you check your dependencies into git, and work on a cross-platform
|
||||
team, then you need to tell NPM to rebuild any platform-specific dependencies. Run
|
||||
|
||||
```shell
|
||||
npm rebuild
|
||||
```
|
||||
|
||||
as part of your build process. This problem is not specific to PhantomJS, and this
|
||||
solution will work for any NodeJS package with native or platform-specific code.
|
||||
|
||||
If you know in advance that you want to install PhantomJS for a specific architecture,
|
||||
you can set the environment variables: `PHANTOMJS_PLATFORM`
|
||||
(to set target platform) and `PHANTOMJS_ARCH` (to set target
|
||||
arch), where `platform` and `arch` are valid values for
|
||||
[process.platform and process.arch](https://nodejs.org/api/process.html).
|
||||
|
||||
A Note on PhantomJS
|
||||
-------------------
|
||||
|
||||
PhantomJS is not a library for NodeJS. It's a separate environment and code
|
||||
written for node is unlikely to be compatible. In particular PhantomJS does
|
||||
not expose a Common JS package loader.
|
||||
|
||||
This is an _NPM wrapper_ and can be used to conveniently make Phantom available.
|
||||
It is not a Node JS wrapper.
|
||||
|
||||
I have had reasonable experiences writing standalone Phantom scripts which I
|
||||
then drive from within a node program by spawning phantom in a child process.
|
||||
|
||||
Read the PhantomJS FAQ for more details: http://phantomjs.org/faq.html
|
||||
|
||||
### Linux Note
|
||||
|
||||
An extra note on Linux usage, from the PhantomJS download page:
|
||||
|
||||
> There is no requirement to install Qt, WebKit, or any other libraries. It
|
||||
> however still relies on Fontconfig (the package fontconfig or libfontconfig,
|
||||
> depending on the distribution).
|
||||
|
||||
Troubleshooting
|
||||
---------------
|
||||
|
||||
##### Installation fails with `spawn ENOENT`
|
||||
|
||||
This is NPM's way of telling you that it was not able to start a process. It usually means:
|
||||
|
||||
- `node` is not on your PATH, or otherwise not correctly installed.
|
||||
- `tar` is not on your PATH. This package expects `tar` on your PATH on Linux-based platforms.
|
||||
- `bzip2` is not on your PATH.
|
||||
|
||||
Check your specific error message for more information.
|
||||
|
||||
##### Installation fails with `Error: EPERM` or `operation not permitted` or `permission denied`
|
||||
|
||||
This error means that NPM was not able to install phantomjs to the file system. There are three
|
||||
major reasons why this could happen:
|
||||
|
||||
- You don't have write access to the installation directory.
|
||||
- The permissions in the NPM cache got messed up, and you need to run `npm cache clean` to fix them.
|
||||
- You have over-zealous anti-virus software installed, and it's blocking file system writes.
|
||||
|
||||
##### Installation fails with `Error: read ECONNRESET` or `Error: connect ETIMEDOUT`
|
||||
|
||||
This error means that something went wrong with your internet connection, and the installer
|
||||
was not able to download the PhantomJS binary for your platform. Please try again.
|
||||
|
||||
##### I tried again, but I get `ECONNRESET` or `ETIMEDOUT` consistently.
|
||||
|
||||
Do you live in China, or a country with an authoritarian government? We've seen problems where
|
||||
the GFW or local ISP blocks github, preventing the installer from downloading the binary.
|
||||
|
||||
Try visiting [the download page](https://bitbucket.org/ariya/phantomjs/downloads) manually.
|
||||
If that page is blocked, you can try using a different CDN with the `PHANTOMJS_CDNURL`
|
||||
env variable described above.
|
||||
|
||||
##### I am behind a corporate proxy that uses self-signed SSL certificates to intercept encrypted traffic.
|
||||
|
||||
You can tell NPM and the PhantomJS installer to skip validation of ssl keys with NPM's
|
||||
[strict-ssl](https://www.npmjs.org/doc/misc/npm-config.html#strict-ssl) setting:
|
||||
|
||||
```
|
||||
npm set strict-ssl false
|
||||
```
|
||||
|
||||
WARNING: Turning off `strict-ssl` leaves you vulnerable to attackers reading
|
||||
your encrypted traffic, so run this at your own risk!
|
||||
|
||||
##### I tried everything, but my network is b0rked. What do I do?
|
||||
|
||||
If you install PhantomJS manually, and put it on PATH, the installer will try to
|
||||
use the manually-installed binaries.
|
||||
|
||||
##### I'm on Debian or Ubuntu, and the installer failed because it couldn't find `node`
|
||||
|
||||
Some Linux distros tried to rename `node` to `nodejs` due to a package
|
||||
conflict. This is a non-portable change, and we do not try to support this. The
|
||||
[official documentation](https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager#ubuntu-mint-elementary-os)
|
||||
recommends that you run `apt-get install nodejs-legacy` to symlink `node` to `nodejs`
|
||||
on those platforms, or many NodeJS programs won't work properly.
|
||||
|
||||
##### I'm using an unsupported version of Linux or an ARM processor. I get errors about "Unexpected platform or architecture". What do I do?
|
||||
|
||||
We only have binaries available for common OS / processor configurations. Sorry.
|
||||
|
||||
You may be able to get a PhantomJS binary from your operating system's package
|
||||
manager. Or you can build your own from source. If you put that binary on PATH,
|
||||
this installer will use it (see "Deciding Where to Get PhantomJS" above).
|
||||
|
||||
|
||||
Contributing
|
||||
------------
|
||||
|
||||
Questions, comments, bug reports, and pull requests are all welcome. Submit them at
|
||||
[the project on GitHub](https://github.com/Medium/phantomjs/). If you haven't contributed to an
|
||||
[Medium](http://github.com/Medium/) project before please head over to the
|
||||
[Open Source Project](https://github.com/Medium/open-source#note-to-external-contributors) and fill
|
||||
out an OCLA (it should be pretty painless).
|
||||
|
||||
Bug reports that include steps-to-reproduce (including code) are the
|
||||
best. Even better, make them in the form of pull requests.
|
||||
|
||||
Author
|
||||
------
|
||||
|
||||
[Dan Pupius](https://github.com/dpup)
|
||||
([personal website](http://pupius.co.uk)) and
|
||||
[Nick Santos](https://github.com/nicks), supported by
|
||||
[A Medium Corporation](http://medium.com/).
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
Copyright 2012 [A Medium Corporation](http://medium.com/).
|
||||
|
||||
Licensed under the Apache License, Version 2.0.
|
||||
See the top-level file `LICENSE.txt` and
|
||||
(http://www.apache.org/licenses/LICENSE-2.0).
|
||||
42
build/node_modules/phantomjs-prebuilt/bin/phantomjs
generated
vendored
Executable file
42
build/node_modules/phantomjs-prebuilt/bin/phantomjs
generated
vendored
Executable file
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* Script that will execute the downloaded phantomjs binary. stdio are
|
||||
* forwarded to and from the child process.
|
||||
*
|
||||
* The following is for an ugly hack to avoid a problem where the installer
|
||||
* finds the bin script npm creates during global installation.
|
||||
*
|
||||
* {NPM_INSTALL_MARKER}
|
||||
*/
|
||||
|
||||
var path = require('path')
|
||||
var spawn = require('child_process').spawn
|
||||
|
||||
var binPath = require(path.join(__dirname, '..', 'lib', 'phantomjs')).path
|
||||
|
||||
var args = process.argv.slice(2)
|
||||
|
||||
// For Node 0.6 compatibility, pipe the streams manually, instead of using
|
||||
// `{ stdio: 'inherit' }`.
|
||||
var cp = spawn(binPath, args)
|
||||
cp.stdout.pipe(process.stdout)
|
||||
cp.stderr.pipe(process.stderr)
|
||||
process.stdin.pipe(cp.stdin)
|
||||
|
||||
cp.on('error', function (err) {
|
||||
console.error('Error executing phantom at', binPath)
|
||||
console.error(err.stack)
|
||||
})
|
||||
|
||||
cp.on('exit', function(code){
|
||||
// Wait few ms for error to be printed.
|
||||
setTimeout(function(){
|
||||
process.exit(code)
|
||||
}, 20)
|
||||
});
|
||||
|
||||
process.on('SIGTERM', function() {
|
||||
cp.kill('SIGTERM')
|
||||
process.exit(1)
|
||||
})
|
||||
438
build/node_modules/phantomjs-prebuilt/install.js
generated
vendored
Normal file
438
build/node_modules/phantomjs-prebuilt/install.js
generated
vendored
Normal file
@@ -0,0 +1,438 @@
|
||||
// Copyright 2012 The Obvious Corporation.
|
||||
|
||||
/*
|
||||
* This simply fetches the right version of phantom for the current platform.
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
var requestProgress = require('request-progress')
|
||||
var progress = require('progress')
|
||||
var extractZip = require('extract-zip')
|
||||
var cp = require('child_process')
|
||||
var fs = require('fs-extra')
|
||||
var helper = require('./lib/phantomjs')
|
||||
var kew = require('kew')
|
||||
var path = require('path')
|
||||
var request = require('request')
|
||||
var url = require('url')
|
||||
var util = require('./lib/util')
|
||||
var which = require('which')
|
||||
var os = require('os')
|
||||
|
||||
var originalPath = process.env.PATH
|
||||
|
||||
var checkPhantomjsVersion = util.checkPhantomjsVersion
|
||||
var getTargetPlatform = util.getTargetPlatform
|
||||
var getTargetArch = util.getTargetArch
|
||||
var getDownloadSpec = util.getDownloadSpec
|
||||
var findValidPhantomJsBinary = util.findValidPhantomJsBinary
|
||||
var verifyChecksum = util.verifyChecksum
|
||||
var writeLocationFile = util.writeLocationFile
|
||||
|
||||
// If the process exits without going through exit(), then we did not complete.
|
||||
var validExit = false
|
||||
|
||||
process.on('exit', function () {
|
||||
if (!validExit) {
|
||||
console.log('Install exited unexpectedly')
|
||||
exit(1)
|
||||
}
|
||||
})
|
||||
|
||||
// NPM adds bin directories to the path, which will cause `which` to find the
|
||||
// bin for this package not the actual phantomjs bin. Also help out people who
|
||||
// put ./bin on their path
|
||||
process.env.PATH = helper.cleanPath(originalPath)
|
||||
|
||||
var libPath = path.join(__dirname, 'lib')
|
||||
var pkgPath = path.join(libPath, 'phantom')
|
||||
var phantomPath = null
|
||||
|
||||
// If the user manually installed PhantomJS, we want
|
||||
// to use the existing version.
|
||||
//
|
||||
// Do not re-use a manually-installed PhantomJS with
|
||||
// a different version.
|
||||
//
|
||||
// Do not re-use an npm-installed PhantomJS, because
|
||||
// that can lead to weird circular dependencies between
|
||||
// local versions and global versions.
|
||||
// https://github.com/Obvious/phantomjs/issues/85
|
||||
// https://github.com/Medium/phantomjs/pull/184
|
||||
kew.resolve(true)
|
||||
.then(tryPhantomjsInLib)
|
||||
.then(tryPhantomjsOnPath)
|
||||
.then(downloadPhantomjs)
|
||||
.then(extractDownload)
|
||||
.then(function (extractedPath) {
|
||||
return copyIntoPlace(extractedPath, pkgPath)
|
||||
})
|
||||
.then(function () {
|
||||
var location = getTargetPlatform() === 'win32' ?
|
||||
path.join(pkgPath, 'bin', 'phantomjs.exe') :
|
||||
path.join(pkgPath, 'bin' ,'phantomjs')
|
||||
|
||||
try {
|
||||
// Ensure executable is executable by all users
|
||||
fs.chmodSync(location, '755')
|
||||
} catch (err) {
|
||||
if (err.code == 'ENOENT') {
|
||||
console.error('chmod failed: phantomjs was not successfully copied to', location)
|
||||
exit(1)
|
||||
}
|
||||
throw err
|
||||
}
|
||||
|
||||
var relativeLocation = path.relative(libPath, location)
|
||||
writeLocationFile(relativeLocation)
|
||||
|
||||
console.log('Done. Phantomjs binary available at', location)
|
||||
exit(0)
|
||||
})
|
||||
.fail(function (err) {
|
||||
console.error('Phantom installation failed', err, err.stack)
|
||||
exit(1)
|
||||
})
|
||||
|
||||
function exit(code) {
|
||||
validExit = true
|
||||
process.env.PATH = originalPath
|
||||
process.exit(code || 0)
|
||||
}
|
||||
|
||||
|
||||
function findSuitableTempDirectory() {
|
||||
var now = Date.now()
|
||||
var candidateTmpDirs = [
|
||||
process.env.npm_config_tmp,
|
||||
os.tmpdir(),
|
||||
path.join(process.cwd(), 'tmp')
|
||||
]
|
||||
|
||||
for (var i = 0; i < candidateTmpDirs.length; i++) {
|
||||
var candidatePath = candidateTmpDirs[i]
|
||||
if (!candidatePath) continue
|
||||
|
||||
try {
|
||||
candidatePath = path.join(path.resolve(candidatePath), 'phantomjs')
|
||||
fs.mkdirsSync(candidatePath, '0777')
|
||||
// Make double sure we have 0777 permissions; some operating systems
|
||||
// default umask does not allow write by default.
|
||||
fs.chmodSync(candidatePath, '0777')
|
||||
var testFile = path.join(candidatePath, now + '.tmp')
|
||||
fs.writeFileSync(testFile, 'test')
|
||||
fs.unlinkSync(testFile)
|
||||
return candidatePath
|
||||
} catch (e) {
|
||||
console.log(candidatePath, 'is not writable:', e.message)
|
||||
}
|
||||
}
|
||||
|
||||
console.error('Can not find a writable tmp directory, please report issue ' +
|
||||
'on https://github.com/Medium/phantomjs/issues with as much ' +
|
||||
'information as possible.')
|
||||
exit(1)
|
||||
}
|
||||
|
||||
|
||||
function getRequestOptions() {
|
||||
var strictSSL = !!process.env.npm_config_strict_ssl
|
||||
if (process.version == 'v0.10.34') {
|
||||
console.log('Node v0.10.34 detected, turning off strict ssl due to https://github.com/joyent/node/issues/8894')
|
||||
strictSSL = false
|
||||
}
|
||||
|
||||
var options = {
|
||||
uri: getDownloadUrl(),
|
||||
encoding: null, // Get response as a buffer
|
||||
followRedirect: true, // The default download path redirects to a CDN URL.
|
||||
headers: {},
|
||||
strictSSL: strictSSL
|
||||
}
|
||||
|
||||
var proxyUrl = process.env.npm_config_https_proxy ||
|
||||
process.env.npm_config_http_proxy ||
|
||||
process.env.npm_config_proxy
|
||||
if (proxyUrl) {
|
||||
|
||||
// Print using proxy
|
||||
var proxy = url.parse(proxyUrl)
|
||||
if (proxy.auth) {
|
||||
// Mask password
|
||||
proxy.auth = proxy.auth.replace(/:.*$/, ':******')
|
||||
}
|
||||
console.log('Using proxy ' + url.format(proxy))
|
||||
|
||||
// Enable proxy
|
||||
options.proxy = proxyUrl
|
||||
}
|
||||
|
||||
// Use the user-agent string from the npm config
|
||||
options.headers['User-Agent'] = process.env.npm_config_user_agent
|
||||
|
||||
// Use certificate authority settings from npm
|
||||
var ca = process.env.npm_config_ca
|
||||
if (!ca && process.env.npm_config_cafile) {
|
||||
try {
|
||||
ca = fs.readFileSync(process.env.npm_config_cafile, {encoding: 'utf8'})
|
||||
.split(/\n(?=-----BEGIN CERTIFICATE-----)/g)
|
||||
|
||||
// Comments at the beginning of the file result in the first
|
||||
// item not containing a certificate - in this case the
|
||||
// download will fail
|
||||
if (ca.length > 0 && !/-----BEGIN CERTIFICATE-----/.test(ca[0])) {
|
||||
ca.shift()
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
console.error('Could not read cafile', process.env.npm_config_cafile, e)
|
||||
}
|
||||
}
|
||||
|
||||
if (ca) {
|
||||
console.log('Using npmconf ca')
|
||||
options.agentOptions = {
|
||||
ca: ca
|
||||
}
|
||||
options.ca = ca
|
||||
}
|
||||
|
||||
return options
|
||||
}
|
||||
|
||||
function handleRequestError(error) {
|
||||
if (error && error.stack && error.stack.indexOf('SELF_SIGNED_CERT_IN_CHAIN') != -1) {
|
||||
console.error('Error making request, SELF_SIGNED_CERT_IN_CHAIN. ' +
|
||||
'Please read https://github.com/Medium/phantomjs#i-am-behind-a-corporate-proxy-that-uses-self-signed-ssl-certificates-to-intercept-encrypted-traffic')
|
||||
exit(1)
|
||||
} else if (error) {
|
||||
console.error('Error making request.\n' + error.stack + '\n\n' +
|
||||
'Please report this full log at https://github.com/Medium/phantomjs')
|
||||
exit(1)
|
||||
} else {
|
||||
console.error('Something unexpected happened, please report this full ' +
|
||||
'log at https://github.com/Medium/phantomjs')
|
||||
exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
function requestBinary(requestOptions, filePath) {
|
||||
var deferred = kew.defer()
|
||||
|
||||
var writePath = filePath + '-download-' + Date.now()
|
||||
|
||||
console.log('Receiving...')
|
||||
var bar = null
|
||||
requestProgress(request(requestOptions, function (error, response, body) {
|
||||
console.log('')
|
||||
if (!error && response.statusCode === 200) {
|
||||
fs.writeFileSync(writePath, body)
|
||||
console.log('Received ' + Math.floor(body.length / 1024) + 'K total.')
|
||||
fs.renameSync(writePath, filePath)
|
||||
deferred.resolve(filePath)
|
||||
|
||||
} else if (response) {
|
||||
console.error('Error requesting archive.\n' +
|
||||
'Status: ' + response.statusCode + '\n' +
|
||||
'Request options: ' + JSON.stringify(requestOptions, null, 2) + '\n' +
|
||||
'Response headers: ' + JSON.stringify(response.headers, null, 2) + '\n' +
|
||||
'Make sure your network and proxy settings are correct.\n\n' +
|
||||
'If you continue to have issues, please report this full log at ' +
|
||||
'https://github.com/Medium/phantomjs')
|
||||
exit(1)
|
||||
} else {
|
||||
handleRequestError(error)
|
||||
}
|
||||
})).on('progress', function (state) {
|
||||
try {
|
||||
if (!bar) {
|
||||
bar = new progress(' [:bar] :percent', {total: state.size.total, width: 40})
|
||||
}
|
||||
bar.curr = state.size.transferred
|
||||
bar.tick()
|
||||
} catch (e) {
|
||||
// It doesn't really matter if the progress bar doesn't update.
|
||||
}
|
||||
})
|
||||
.on('error', handleRequestError)
|
||||
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
|
||||
function extractDownload(filePath) {
|
||||
var deferred = kew.defer()
|
||||
// extract to a unique directory in case multiple processes are
|
||||
// installing and extracting at once
|
||||
var extractedPath = filePath + '-extract-' + Date.now()
|
||||
var options = {cwd: extractedPath}
|
||||
|
||||
fs.mkdirsSync(extractedPath, '0777')
|
||||
// Make double sure we have 0777 permissions; some operating systems
|
||||
// default umask does not allow write by default.
|
||||
fs.chmodSync(extractedPath, '0777')
|
||||
|
||||
if (filePath.substr(-4) === '.zip') {
|
||||
console.log('Extracting zip contents')
|
||||
extractZip(path.resolve(filePath), {dir: extractedPath}, function(err) {
|
||||
if (err) {
|
||||
console.error('Error extracting zip')
|
||||
deferred.reject(err)
|
||||
} else {
|
||||
deferred.resolve(extractedPath)
|
||||
}
|
||||
})
|
||||
|
||||
} else {
|
||||
console.log('Extracting tar contents (via spawned process)')
|
||||
cp.execFile('tar', ['jxf', path.resolve(filePath)], options, function (err) {
|
||||
if (err) {
|
||||
console.error('Error extracting archive')
|
||||
deferred.reject(err)
|
||||
} else {
|
||||
deferred.resolve(extractedPath)
|
||||
}
|
||||
})
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
|
||||
function copyIntoPlace(extractedPath, targetPath) {
|
||||
console.log('Removing', targetPath)
|
||||
return kew.nfcall(fs.remove, targetPath).then(function () {
|
||||
// Look for the extracted directory, so we can rename it.
|
||||
var files = fs.readdirSync(extractedPath)
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
var file = path.join(extractedPath, files[i])
|
||||
if (fs.statSync(file).isDirectory() && file.indexOf(helper.version) != -1) {
|
||||
console.log('Copying extracted folder', file, '->', targetPath)
|
||||
return kew.nfcall(fs.move, file, targetPath)
|
||||
}
|
||||
}
|
||||
|
||||
console.log('Could not find extracted file', files)
|
||||
throw new Error('Could not find extracted file')
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if the binary in lib is OK to use. If successful, exit the process.
|
||||
*/
|
||||
function tryPhantomjsInLib() {
|
||||
return kew.fcall(function () {
|
||||
return findValidPhantomJsBinary(path.resolve(__dirname, './lib/location.js'))
|
||||
}).then(function (binaryLocation) {
|
||||
if (binaryLocation) {
|
||||
console.log('PhantomJS is previously installed at', binaryLocation)
|
||||
exit(0)
|
||||
}
|
||||
}).fail(function () {
|
||||
// silently swallow any errors
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if the binary on PATH is OK to use. If successful, exit the process.
|
||||
*/
|
||||
function tryPhantomjsOnPath() {
|
||||
if (getTargetPlatform() != process.platform || getTargetArch() != process.arch) {
|
||||
console.log('Building for target platform ' + getTargetPlatform() + '/' + getTargetArch() +
|
||||
'. Skipping PATH search')
|
||||
return kew.resolve(false)
|
||||
}
|
||||
|
||||
return kew.nfcall(which, 'phantomjs')
|
||||
.then(function (result) {
|
||||
phantomPath = result
|
||||
console.log('Considering PhantomJS found at', phantomPath)
|
||||
|
||||
// Horrible hack to avoid problems during global install. We check to see if
|
||||
// the file `which` found is our own bin script.
|
||||
if (phantomPath.indexOf(path.join('npm', 'phantomjs')) !== -1) {
|
||||
console.log('Looks like an `npm install -g` on windows; skipping installed version.')
|
||||
return
|
||||
}
|
||||
|
||||
var contents = fs.readFileSync(phantomPath, 'utf8')
|
||||
if (/NPM_INSTALL_MARKER/.test(contents)) {
|
||||
console.log('Looks like an `npm install -g`')
|
||||
|
||||
var phantomLibPath = path.resolve(fs.realpathSync(phantomPath), '../../lib/location')
|
||||
return findValidPhantomJsBinary(phantomLibPath)
|
||||
.then(function (binaryLocation) {
|
||||
if (binaryLocation) {
|
||||
writeLocationFile(binaryLocation)
|
||||
console.log('PhantomJS linked at', phantomLibPath)
|
||||
exit(0)
|
||||
}
|
||||
console.log('Could not link global install, skipping...')
|
||||
})
|
||||
} else {
|
||||
return checkPhantomjsVersion(phantomPath).then(function (matches) {
|
||||
if (matches) {
|
||||
writeLocationFile(phantomPath)
|
||||
console.log('PhantomJS is already installed on PATH at', phantomPath)
|
||||
exit(0)
|
||||
}
|
||||
})
|
||||
}
|
||||
}, function () {
|
||||
console.log('PhantomJS not found on PATH')
|
||||
})
|
||||
.fail(function (err) {
|
||||
console.error('Error checking path, continuing', err)
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {?string} Get the download URL for phantomjs.
|
||||
* May return null if no download url exists.
|
||||
*/
|
||||
function getDownloadUrl() {
|
||||
var spec = getDownloadSpec()
|
||||
return spec && spec.url
|
||||
}
|
||||
|
||||
/**
|
||||
* Download phantomjs, reusing the existing copy on disk if available.
|
||||
* Exits immediately if there is no binary to download.
|
||||
* @return {Promise.<string>} The path to the downloaded file.
|
||||
*/
|
||||
function downloadPhantomjs() {
|
||||
var downloadSpec = getDownloadSpec()
|
||||
if (!downloadSpec) {
|
||||
console.error(
|
||||
'Unexpected platform or architecture: ' + getTargetPlatform() + '/' + getTargetArch() + '\n' +
|
||||
'It seems there is no binary available for your platform/architecture\n' +
|
||||
'Try to install PhantomJS globally')
|
||||
exit(1)
|
||||
}
|
||||
|
||||
var downloadUrl = downloadSpec.url
|
||||
var downloadedFile
|
||||
|
||||
return kew.fcall(function () {
|
||||
// Can't use a global version so start a download.
|
||||
var tmpPath = findSuitableTempDirectory()
|
||||
var fileName = downloadUrl.split('/').pop()
|
||||
downloadedFile = path.join(tmpPath, fileName)
|
||||
|
||||
if (fs.existsSync(downloadedFile)) {
|
||||
console.log('Download already available at', downloadedFile)
|
||||
return verifyChecksum(downloadedFile, downloadSpec.checksum)
|
||||
}
|
||||
return false
|
||||
}).then(function (verified) {
|
||||
if (verified) {
|
||||
return downloadedFile
|
||||
}
|
||||
|
||||
// Start the install.
|
||||
console.log('Downloading', downloadUrl)
|
||||
console.log('Saving to', downloadedFile)
|
||||
return requestBinary(getRequestOptions(), downloadedFile)
|
||||
})
|
||||
}
|
||||
3
build/node_modules/phantomjs-prebuilt/lib/location.js
generated
vendored
Normal file
3
build/node_modules/phantomjs-prebuilt/lib/location.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
module.exports.location = "/usr/local/bin/phantomjs"
|
||||
module.exports.platform = "darwin"
|
||||
module.exports.arch = "x64"
|
||||
124
build/node_modules/phantomjs-prebuilt/lib/phantomjs.js
generated
vendored
Normal file
124
build/node_modules/phantomjs-prebuilt/lib/phantomjs.js
generated
vendored
Normal file
@@ -0,0 +1,124 @@
|
||||
// Copyright 2013 The Obvious Corporation.
|
||||
|
||||
/**
|
||||
* @fileoverview Helpers made available via require('phantomjs') once package is
|
||||
* installed.
|
||||
*/
|
||||
|
||||
var fs = require('fs')
|
||||
var path = require('path')
|
||||
var spawn = require('child_process').spawn
|
||||
var Promise = require('es6-promise').Promise
|
||||
|
||||
|
||||
/**
|
||||
* Where the phantom binary can be found.
|
||||
* @type {string}
|
||||
*/
|
||||
try {
|
||||
var location = require('./location')
|
||||
exports.path = path.resolve(__dirname, location.location)
|
||||
exports.platform = location.platform
|
||||
exports.arch = location.arch
|
||||
} catch(e) {
|
||||
// Must be running inside install script.
|
||||
exports.path = null
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The version of phantomjs installed by this package.
|
||||
* @type {number}
|
||||
*/
|
||||
exports.version = '2.1.1'
|
||||
|
||||
|
||||
/**
|
||||
* Returns a clean path that helps avoid `which` finding bin files installed
|
||||
* by NPM for this repo.
|
||||
* @param {string} path
|
||||
* @return {string}
|
||||
*/
|
||||
exports.cleanPath = function (path) {
|
||||
return path
|
||||
.replace(/:[^:]*node_modules[^:]*/g, '')
|
||||
.replace(/(^|:)\.\/bin(\:|$)/g, ':')
|
||||
.replace(/^:+/, '')
|
||||
.replace(/:+$/, '')
|
||||
}
|
||||
|
||||
|
||||
// Make sure the binary is executable. For some reason doing this inside
|
||||
// install does not work correctly, likely due to some NPM step.
|
||||
if (exports.path) {
|
||||
try {
|
||||
// avoid touching the binary if it's already got the correct permissions
|
||||
var st = fs.statSync(exports.path)
|
||||
var mode = st.mode | parseInt('0555', 8)
|
||||
if (mode !== st.mode) {
|
||||
fs.chmodSync(exports.path, mode)
|
||||
}
|
||||
} catch (e) {
|
||||
// Just ignore error if we don't have permission.
|
||||
// We did our best. Likely because phantomjs was already installed.
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a script or just runs PhantomJS
|
||||
*/
|
||||
exports.exec = function () {
|
||||
var args = Array.prototype.slice.call(arguments)
|
||||
return spawn(exports.path, args)
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs PhantomJS with provided options
|
||||
* @example
|
||||
* // handy with WebDriver
|
||||
* phantomjs.run('--webdriver=4444').then(program => {
|
||||
* // do something
|
||||
* program.kill()
|
||||
* })
|
||||
* @returns {Promise} the process of PhantomJS
|
||||
*/
|
||||
exports.run = function () {
|
||||
var args = arguments
|
||||
return new Promise(function (resolve, reject) {
|
||||
try {
|
||||
var program = exports.exec.apply(null, args)
|
||||
var isFirst = true
|
||||
var stderr = ''
|
||||
program.stdout.on('data', function () {
|
||||
// This detects PhantomJS instance get ready.
|
||||
if (!isFirst) return
|
||||
isFirst = false
|
||||
resolve(program)
|
||||
})
|
||||
program.stderr.on('data', function (data) {
|
||||
stderr = stderr + data.toString('utf8')
|
||||
})
|
||||
program.on('error', function (err) {
|
||||
if (!isFirst) return
|
||||
isFirst = false
|
||||
reject(err)
|
||||
})
|
||||
program.on('exit', function (code) {
|
||||
if (!isFirst) return
|
||||
isFirst = false
|
||||
if (code == 0) {
|
||||
// PhantomJS doesn't use exit codes correctly :(
|
||||
if (stderr.indexOf('Error:') == 0) {
|
||||
reject(new Error(stderr))
|
||||
} else {
|
||||
resolve(program)
|
||||
}
|
||||
} else {
|
||||
reject(new Error('Exit code: ' + code))
|
||||
}
|
||||
})
|
||||
} catch (err) {
|
||||
reject(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
161
build/node_modules/phantomjs-prebuilt/lib/util.js
generated
vendored
Normal file
161
build/node_modules/phantomjs-prebuilt/lib/util.js
generated
vendored
Normal file
@@ -0,0 +1,161 @@
|
||||
/**
|
||||
* @fileoverview Package-private helpers for the installer.
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
var cp = require('child_process')
|
||||
var fs = require('fs-extra')
|
||||
var hasha = require('hasha')
|
||||
var helper = require('./phantomjs')
|
||||
var kew = require('kew')
|
||||
var path = require('path')
|
||||
|
||||
var DEFAULT_CDN = 'https://github.com/Medium/phantomjs/releases/download/v2.1.1'
|
||||
var libPath = __dirname
|
||||
|
||||
/**
|
||||
* Given a lib/location file of a PhantomJS previously installed with NPM,
|
||||
* is there a valid PhantomJS binary at this lib/location.
|
||||
* @return {Promise<string>} resolved location of phantomjs binary on success
|
||||
*/
|
||||
function findValidPhantomJsBinary(libPath) {
|
||||
return kew.fcall(function () {
|
||||
var libModule = require(libPath)
|
||||
if (libModule.location &&
|
||||
getTargetPlatform() == libModule.platform &&
|
||||
getTargetArch() == libModule.arch) {
|
||||
var resolvedLocation = path.resolve(path.dirname(libPath), libModule.location)
|
||||
if (fs.statSync(resolvedLocation)) {
|
||||
return checkPhantomjsVersion(resolvedLocation).then(function (matches) {
|
||||
if (matches) {
|
||||
return kew.resolve(resolvedLocation)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
return false
|
||||
}).fail(function () {
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to make sure a given binary is the right version.
|
||||
* @return {kew.Promise.<boolean>}
|
||||
*/
|
||||
function checkPhantomjsVersion(phantomPath) {
|
||||
console.log('Found PhantomJS at', phantomPath, '...verifying')
|
||||
return kew.nfcall(cp.execFile, phantomPath, ['--version']).then(function (stdout) {
|
||||
var version = stdout.trim()
|
||||
if (helper.version == version) {
|
||||
return true
|
||||
} else {
|
||||
console.log('PhantomJS detected, but wrong version', stdout.trim(), '@', phantomPath + '.')
|
||||
return false
|
||||
}
|
||||
}).fail(function (err) {
|
||||
console.error('Error verifying phantomjs, continuing', err)
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the location file with location and platform/arch metadata about the
|
||||
* binary.
|
||||
*/
|
||||
function writeLocationFile(location) {
|
||||
console.log('Writing location.js file')
|
||||
if (getTargetPlatform() === 'win32') {
|
||||
location = location.replace(/\\/g, '\\\\')
|
||||
}
|
||||
|
||||
var platform = getTargetPlatform()
|
||||
var arch = getTargetArch()
|
||||
|
||||
var contents = 'module.exports.location = "' + location + '"\n'
|
||||
|
||||
if (/^[a-zA-Z0-9]*$/.test(platform) && /^[a-zA-Z0-9]*$/.test(arch)) {
|
||||
contents +=
|
||||
'module.exports.platform = "' + getTargetPlatform() + '"\n' +
|
||||
'module.exports.arch = "' + getTargetArch() + '"\n'
|
||||
}
|
||||
|
||||
fs.writeFileSync(path.join(libPath, 'location.js'), contents)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {?{url: string, checksum: string}} Get the download URL and expected
|
||||
* SHA-256 checksum for phantomjs. May return null if no download url exists.
|
||||
*/
|
||||
function getDownloadSpec() {
|
||||
var cdnUrl = process.env.npm_config_phantomjs_cdnurl ||
|
||||
process.env.PHANTOMJS_CDNURL ||
|
||||
DEFAULT_CDN
|
||||
var downloadUrl = cdnUrl + '/phantomjs-' + helper.version + '-'
|
||||
var checksum = ''
|
||||
|
||||
var platform = getTargetPlatform()
|
||||
var arch = getTargetArch()
|
||||
if (platform === 'linux' && arch === 'x64') {
|
||||
downloadUrl += 'linux-x86_64.tar.bz2'
|
||||
checksum = '86dd9a4bf4aee45f1a84c9f61cf1947c1d6dce9b9e8d2a907105da7852460d2f'
|
||||
} else if (platform === 'linux' && arch == 'ia32') {
|
||||
downloadUrl += 'linux-i686.tar.bz2'
|
||||
checksum = '80e03cfeb22cc4dfe4e73b68ab81c9fdd7c78968cfd5358e6af33960464f15e3'
|
||||
} else if (platform === 'darwin') {
|
||||
downloadUrl += 'macosx.zip'
|
||||
checksum = '538cf488219ab27e309eafc629e2bcee9976990fe90b1ec334f541779150f8c1'
|
||||
} else if (platform === 'win32') {
|
||||
downloadUrl += 'windows.zip'
|
||||
checksum = 'd9fb05623d6b26d3654d008eab3adafd1f6350433dfd16138c46161f42c7dcc8'
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
return {url: downloadUrl, checksum: checksum}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to make sure that the file matches the checksum.
|
||||
* @param {string} fileName
|
||||
* @param {string} checksum
|
||||
* @return {Promise.<boolean>}
|
||||
*/
|
||||
function verifyChecksum(fileName, checksum) {
|
||||
return kew.resolve(hasha.fromFile(fileName, {algorithm: 'sha256'})).then(function (hash) {
|
||||
var result = checksum == hash
|
||||
if (result) {
|
||||
console.log('Verified checksum of previously downloaded file')
|
||||
} else {
|
||||
console.log('Checksum did not match')
|
||||
}
|
||||
return result
|
||||
}).fail(function (err) {
|
||||
console.error('Failed to verify checksum: ', err)
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
function getTargetPlatform() {
|
||||
return process.env.PHANTOMJS_PLATFORM || process.platform
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
function getTargetArch() {
|
||||
return process.env.PHANTOMJS_ARCH || process.arch
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
checkPhantomjsVersion: checkPhantomjsVersion,
|
||||
getDownloadSpec: getDownloadSpec,
|
||||
getTargetPlatform: getTargetPlatform,
|
||||
getTargetArch: getTargetArch,
|
||||
findValidPhantomJsBinary: findValidPhantomJsBinary,
|
||||
verifyChecksum: verifyChecksum,
|
||||
writeLocationFile: writeLocationFile
|
||||
}
|
||||
122
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/CHANGELOG.md
generated
vendored
Normal file
122
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,122 @@
|
||||
# Master
|
||||
|
||||
# 4.1.0
|
||||
|
||||
* [BUGFIX] Fix memory leak [#269]
|
||||
* [BUGFIX] Auto Bundles within an AMD Environment [#263]
|
||||
|
||||
# 4.0.5
|
||||
|
||||
* fix require('es6-promise/auto') for Node < 4
|
||||
|
||||
# 4.0.4
|
||||
|
||||
* fix asap when using https://github.com/Kinvey/titanium-sdk
|
||||
|
||||
# 4.0.3
|
||||
|
||||
* fix Readme links
|
||||
|
||||
# 4.0.2
|
||||
|
||||
* fix require('es6-promise/auto');
|
||||
|
||||
# 4.0.0
|
||||
|
||||
* no longer polyfill automatically, if needed one can still invoke
|
||||
`require('es6-promise/auto')` directly.
|
||||
|
||||
# 3.3.1
|
||||
|
||||
* fix links in readme
|
||||
|
||||
# 3.3.0
|
||||
|
||||
* support polyfil on WebMAF (playstation env)
|
||||
* fix tampering related bug global `constructor` was referenced by mistake.
|
||||
* provide TS Typings
|
||||
* increase compatibliity with sinon.useFakeTimers();
|
||||
* update build tools (use rollup)
|
||||
* directly export promise;
|
||||
|
||||
# 3.2.2
|
||||
|
||||
* IE8: use isArray
|
||||
* update build dependencies
|
||||
|
||||
# 3.2.1
|
||||
|
||||
* fix race tampering issue
|
||||
* use eslint
|
||||
* fix Promise.all tampering
|
||||
* remove unused code
|
||||
* fix issues with NWJS/electron
|
||||
|
||||
# 3.2.0
|
||||
|
||||
* improve tamper resistence of Promise.all Promise.race and
|
||||
Promise.prototype.then (note, this isn't complete, but addresses an exception
|
||||
when used \w core-js, follow up work will address entirely)
|
||||
* remove spec incompatible then chaining fast-path
|
||||
* add eslint
|
||||
* update build deps
|
||||
|
||||
# 3.1.2
|
||||
|
||||
* fix node detection issues with NWJS/electron
|
||||
|
||||
# 3.1.0
|
||||
|
||||
* improve performance of Promise.all when it encounters a non-promise input object input
|
||||
* then/resolve tamper protection
|
||||
* reduce AST size of promise constructor, to facilitate more inlining
|
||||
* Update README.md with details about PhantomJS requirement for running tests
|
||||
* Mangle and compress the minified version
|
||||
|
||||
# 3.0.2
|
||||
|
||||
* correctly bump both bower and package.json versions
|
||||
|
||||
# 3.0.1
|
||||
|
||||
* no longer include dist/test in npm releases
|
||||
|
||||
# 3.0.0
|
||||
|
||||
* use nextTick() instead of setImmediate() to schedule microtasks with node 0.10. Later versions of
|
||||
nodes are not affected as they were already using nextTick(). Note that using nextTick() might
|
||||
trigger a depreciation warning on 0.10 as described at https://github.com/cujojs/when/issues/410.
|
||||
The reason why nextTick() is preferred is that is setImmediate() would schedule a macrotask
|
||||
instead of a microtask and might result in a different scheduling.
|
||||
If needed you can revert to the former behavior as follow:
|
||||
|
||||
var Promise = require('es6-promise').Promise;
|
||||
Promise._setScheduler(setImmediate);
|
||||
|
||||
# 2.3.0
|
||||
|
||||
* #121: Ability to override the internal asap implementation
|
||||
* #120: Use an ascii character for an apostrophe, for source maps
|
||||
|
||||
# 2.2.0
|
||||
|
||||
* #116: Expose asap() and a way to override the scheduling mechanism on Promise
|
||||
* Lock to v0.2.3 of ember-cli
|
||||
|
||||
# 2.1.1
|
||||
|
||||
* Fix #100 via #105: tell browserify to ignore vertx require
|
||||
* Fix #101 via #102: "follow thenable state, not own state"
|
||||
|
||||
# 2.1.0
|
||||
|
||||
* #59: Automatic polyfill. No need to invoke `ES6Promise.polyfill()` anymore.
|
||||
* ... (see the commit log)
|
||||
|
||||
# 2.0.0
|
||||
|
||||
* re-sync with RSVP. Many large performance improvements and bugfixes.
|
||||
|
||||
# 1.0.0
|
||||
|
||||
* first subset of RSVP
|
||||
19
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/LICENSE
generated
vendored
Normal file
19
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors
|
||||
|
||||
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.
|
||||
97
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/README.md
generated
vendored
Normal file
97
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/README.md
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
# ES6-Promise (subset of [rsvp.js](https://github.com/tildeio/rsvp.js)) [](https://travis-ci.org/stefanpenner/es6-promise)
|
||||
|
||||
This is a polyfill of the [ES6 Promise](http://www.ecma-international.org/ecma-262/6.0/#sec-promise-constructor). The implementation is a subset of [rsvp.js](https://github.com/tildeio/rsvp.js) extracted by @jakearchibald, if you're wanting extra features and more debugging options, check out the [full library](https://github.com/tildeio/rsvp.js).
|
||||
|
||||
For API details and how to use promises, see the <a href="http://www.html5rocks.com/en/tutorials/es6/promises/">JavaScript Promises HTML5Rocks article</a>.
|
||||
|
||||
## Downloads
|
||||
|
||||
* [es6-promise 27.86 KB (7.33 KB gzipped)](https://cdn.jsdelivr.net/npm/es6-promise/dist/es6-promise.js)
|
||||
* [es6-promise-auto 27.78 KB (7.3 KB gzipped)](https://cdn.jsdelivr.net/npm/es6-promise/dist/es6-promise.auto.js) - Automatically provides/replaces `Promise` if missing or broken.
|
||||
* [es6-promise-min 6.17 KB (2.4 KB gzipped)](https://cdn.jsdelivr.net/npm/es6-promise/dist/es6-promise.min.js)
|
||||
* [es6-promise-auto-min 6.19 KB (2.4 KB gzipped)](https://cdn.jsdelivr.net/npm/es6-promise/dist/es6-promise.auto.min.js) - Minified version of `es6-promise-auto` above.
|
||||
|
||||
## CDN
|
||||
|
||||
To use via a CDN include this in your html:
|
||||
|
||||
```html
|
||||
<!-- Automatically provides/replaces `Promise` if missing or broken. -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/es6-promise@4/dist/es6-promise.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/es6-promise@4/dist/es6-promise.auto.js"></script>
|
||||
|
||||
<!-- Minified version of `es6-promise-auto` below. -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/es6-promise@4/dist/es6-promise.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/es6-promise@4/dist/es6-promise.auto.min.js"></script>
|
||||
|
||||
```
|
||||
|
||||
## Node.js
|
||||
|
||||
To install:
|
||||
|
||||
```sh
|
||||
yarn add es6-promise
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```sh
|
||||
npm install es6-promise
|
||||
```
|
||||
|
||||
To use:
|
||||
|
||||
```js
|
||||
var Promise = require('es6-promise').Promise;
|
||||
```
|
||||
|
||||
|
||||
## Usage in IE<9
|
||||
|
||||
`catch` and `finally` are reserved keywords in IE<9, meaning
|
||||
`promise.catch(func)` or `promise.finally(func)` throw a syntax error. To work
|
||||
around this, you can use a string to access the property as shown in the
|
||||
following example.
|
||||
|
||||
However most minifiers will automatically fix this for you, making the
|
||||
resulting code safe for old browsers and production:
|
||||
|
||||
```js
|
||||
promise['catch'](function(err) {
|
||||
// ...
|
||||
});
|
||||
```
|
||||
|
||||
```js
|
||||
promise['finally'](function() {
|
||||
// ...
|
||||
});
|
||||
```
|
||||
|
||||
## Auto-polyfill
|
||||
|
||||
To polyfill the global environment (either in Node or in the browser via CommonJS) use the following code snippet:
|
||||
|
||||
```js
|
||||
require('es6-promise').polyfill();
|
||||
```
|
||||
|
||||
Alternatively
|
||||
|
||||
```js
|
||||
require('es6-promise/auto');
|
||||
```
|
||||
|
||||
Notice that we don't assign the result of `polyfill()` to any variable. The `polyfill()` method will patch the global environment (in this case to the `Promise` name) when called.
|
||||
|
||||
## Building & Testing
|
||||
|
||||
You will need to have PhantomJS installed globally in order to run the tests.
|
||||
|
||||
`npm install -g phantomjs`
|
||||
|
||||
* `npm run build` to build
|
||||
* `npm test` to run tests
|
||||
* `npm start` to run a build watcher, and webserver to test
|
||||
* `npm run test:server` for a testem test runner and watching builder
|
||||
4
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/auto.js
generated
vendored
Normal file
4
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/auto.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
// This file can be required in Browserify and Node.js for automatic polyfill
|
||||
// To use it: require('es6-promise/auto');
|
||||
'use strict';
|
||||
module.exports = require('./').polyfill();
|
||||
1192
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/dist/es6-promise.auto.js
generated
vendored
Normal file
1192
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/dist/es6-promise.auto.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/dist/es6-promise.auto.map
generated
vendored
Normal file
1
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/dist/es6-promise.auto.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/dist/es6-promise.auto.min.js
generated
vendored
Normal file
1
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/dist/es6-promise.auto.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/dist/es6-promise.auto.min.map
generated
vendored
Normal file
1
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/dist/es6-promise.auto.min.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1190
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/dist/es6-promise.js
generated
vendored
Normal file
1190
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/dist/es6-promise.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/dist/es6-promise.map
generated
vendored
Normal file
1
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/dist/es6-promise.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/dist/es6-promise.min.js
generated
vendored
Normal file
1
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/dist/es6-promise.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/dist/es6-promise.min.map
generated
vendored
Normal file
1
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/dist/es6-promise.min.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
81
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/es6-promise.d.ts
generated
vendored
Normal file
81
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/es6-promise.d.ts
generated
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
export interface Thenable <R> {
|
||||
then <U> (onFulfilled?: (value: R) => U | Thenable<U>, onRejected?: (error: any) => U | Thenable<U>): Thenable<U>;
|
||||
then <U> (onFulfilled?: (value: R) => U | Thenable<U>, onRejected?: (error: any) => void): Thenable<U>;
|
||||
}
|
||||
|
||||
export class Promise <R> implements Thenable <R> {
|
||||
/**
|
||||
* If you call resolve in the body of the callback passed to the constructor,
|
||||
* your promise is fulfilled with result object passed to resolve.
|
||||
* If you call reject your promise is rejected with the object passed to resolve.
|
||||
* For consistency and debugging (eg stack traces), obj should be an instanceof Error.
|
||||
* Any errors thrown in the constructor callback will be implicitly passed to reject().
|
||||
*/
|
||||
constructor (callback: (resolve : (value?: R | Thenable<R>) => void, reject: (error?: any) => void) => void);
|
||||
|
||||
/**
|
||||
* onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects.
|
||||
* Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called.
|
||||
* Both callbacks have a single parameter , the fulfillment value or rejection reason.
|
||||
* "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve.
|
||||
* If an error is thrown in the callback, the returned promise rejects with that error.
|
||||
*
|
||||
* @param onFulfilled called when/if "promise" resolves
|
||||
* @param onRejected called when/if "promise" rejects
|
||||
*/
|
||||
then <U> (onFulfilled?: (value: R) => U | Thenable<U>, onRejected?: (error: any) => U | Thenable<U>): Promise<U>;
|
||||
then <U> (onFulfilled?: (value: R) => U | Thenable<U>, onRejected?: (error: any) => void): Promise<U>;
|
||||
|
||||
/**
|
||||
* Sugar for promise.then(undefined, onRejected)
|
||||
*
|
||||
* @param onRejected called when/if "promise" rejects
|
||||
*/
|
||||
catch <U> (onRejected?: (error: any) => U | Thenable<U>): Promise<U>;
|
||||
|
||||
/**
|
||||
* onSettled is invoked when/if the "promise" settles (either rejects or fulfills);
|
||||
*
|
||||
* @param onFinally called when/if "promise" settles
|
||||
*/
|
||||
finally <U> (onFinally?: (callback: any) => U | Thenable<U>): Promise<U>;
|
||||
|
||||
/**
|
||||
* Make a new promise from the thenable.
|
||||
* A thenable is promise-like in as far as it has a "then" method.
|
||||
*/
|
||||
static resolve (): Promise<void>;
|
||||
static resolve <R> (value: R | Thenable<R>): Promise<R>;
|
||||
|
||||
/**
|
||||
* Make a promise that rejects to obj. For consistency and debugging (eg stack traces), obj should be an instanceof Error
|
||||
*/
|
||||
static reject <R> (error: any): Promise<R>;
|
||||
|
||||
/**
|
||||
* Make a promise that fulfills when every item in the array fulfills, and rejects if (and when) any item rejects.
|
||||
* the array passed to all can be a mixture of promise-like objects and other objects.
|
||||
* The fulfillment value is an array (in order) of fulfillment values. The rejection value is the first rejection value.
|
||||
*/
|
||||
static all<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(values: [T1 | Thenable<T1>, T2 | Thenable<T2>, T3 | Thenable<T3>, T4 | Thenable <T4>, T5 | Thenable<T5>, T6 | Thenable<T6>, T7 | Thenable<T7>, T8 | Thenable<T8>, T9 | Thenable<T9>, T10 | Thenable<T10>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>;
|
||||
static all<T1, T2, T3, T4, T5, T6, T7, T8, T9>(values: [T1 | Thenable<T1>, T2 | Thenable<T2>, T3 | Thenable<T3>, T4 | Thenable <T4>, T5 | Thenable<T5>, T6 | Thenable<T6>, T7 | Thenable<T7>, T8 | Thenable<T8>, T9 | Thenable<T9>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>;
|
||||
static all<T1, T2, T3, T4, T5, T6, T7, T8>(values: [T1 | Thenable<T1>, T2 | Thenable<T2>, T3 | Thenable<T3>, T4 | Thenable <T4>, T5 | Thenable<T5>, T6 | Thenable<T6>, T7 | Thenable<T7>, T8 | Thenable<T8>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>;
|
||||
static all<T1, T2, T3, T4, T5, T6, T7>(values: [T1 | Thenable<T1>, T2 | Thenable<T2>, T3 | Thenable<T3>, T4 | Thenable <T4>, T5 | Thenable<T5>, T6 | Thenable<T6>, T7 | Thenable<T7>]): Promise<[T1, T2, T3, T4, T5, T6, T7]>;
|
||||
static all<T1, T2, T3, T4, T5, T6>(values: [T1 | Thenable<T1>, T2 | Thenable<T2>, T3 | Thenable<T3>, T4 | Thenable <T4>, T5 | Thenable<T5>, T6 | Thenable<T6>]): Promise<[T1, T2, T3, T4, T5, T6]>;
|
||||
static all<T1, T2, T3, T4, T5>(values: [T1 | Thenable<T1>, T2 | Thenable<T2>, T3 | Thenable<T3>, T4 | Thenable <T4>, T5 | Thenable<T5>]): Promise<[T1, T2, T3, T4, T5]>;
|
||||
static all<T1, T2, T3, T4>(values: [T1 | Thenable<T1>, T2 | Thenable<T2>, T3 | Thenable<T3>, T4 | Thenable <T4>]): Promise<[T1, T2, T3, T4]>;
|
||||
static all<T1, T2, T3>(values: [T1 | Thenable<T1>, T2 | Thenable<T2>, T3 | Thenable<T3>]): Promise<[T1, T2, T3]>;
|
||||
static all<T1, T2>(values: [T1 | Thenable<T1>, T2 | Thenable<T2>]): Promise<[T1, T2]>;
|
||||
static all<T1>(values: [T1 | Thenable<T1>]): Promise<[T1]>;
|
||||
static all<TAll>(values: Array<TAll | Thenable<TAll>>): Promise<TAll[]>;
|
||||
|
||||
/**
|
||||
* Make a Promise that fulfills when any item fulfills, and rejects if any item rejects.
|
||||
*/
|
||||
static race <R> (promises: (R | Thenable<R>)[]): Promise<R>;
|
||||
}
|
||||
|
||||
/**
|
||||
* The polyfill method will patch the global environment (in this case to the Promise name) when called.
|
||||
*/
|
||||
export function polyfill (): void;
|
||||
3
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/lib/es6-promise.auto.js
generated
vendored
Normal file
3
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/lib/es6-promise.auto.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import Promise from './es6-promise';
|
||||
Promise.polyfill();
|
||||
export default Promise;
|
||||
7
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/lib/es6-promise.js
generated
vendored
Normal file
7
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/lib/es6-promise.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import Promise from './es6-promise/promise';
|
||||
import polyfill from './es6-promise/polyfill';
|
||||
|
||||
// Strange compat..
|
||||
Promise.polyfill = polyfill;
|
||||
Promise.Promise = Promise;
|
||||
export default Promise;
|
||||
271
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/lib/es6-promise/-internal.js
generated
vendored
Normal file
271
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/lib/es6-promise/-internal.js
generated
vendored
Normal file
@@ -0,0 +1,271 @@
|
||||
import {
|
||||
objectOrFunction,
|
||||
isFunction
|
||||
} from './utils';
|
||||
|
||||
import {
|
||||
asap
|
||||
} from './asap';
|
||||
|
||||
import originalThen from './then';
|
||||
import originalResolve from './promise/resolve';
|
||||
|
||||
export const PROMISE_ID = Math.random().toString(36).substring(16);
|
||||
|
||||
function noop() {}
|
||||
|
||||
const PENDING = void 0;
|
||||
const FULFILLED = 1;
|
||||
const REJECTED = 2;
|
||||
|
||||
const GET_THEN_ERROR = new ErrorObject();
|
||||
|
||||
function selfFulfillment() {
|
||||
return new TypeError("You cannot resolve a promise with itself");
|
||||
}
|
||||
|
||||
function cannotReturnOwn() {
|
||||
return new TypeError('A promises callback cannot return that same promise.');
|
||||
}
|
||||
|
||||
function getThen(promise) {
|
||||
try {
|
||||
return promise.then;
|
||||
} catch(error) {
|
||||
GET_THEN_ERROR.error = error;
|
||||
return GET_THEN_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
function tryThen(then, value, fulfillmentHandler, rejectionHandler) {
|
||||
try {
|
||||
then.call(value, fulfillmentHandler, rejectionHandler);
|
||||
} catch(e) {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
|
||||
function handleForeignThenable(promise, thenable, then) {
|
||||
asap(promise => {
|
||||
var sealed = false;
|
||||
var error = tryThen(then, thenable, value => {
|
||||
if (sealed) { return; }
|
||||
sealed = true;
|
||||
if (thenable !== value) {
|
||||
resolve(promise, value);
|
||||
} else {
|
||||
fulfill(promise, value);
|
||||
}
|
||||
}, reason => {
|
||||
if (sealed) { return; }
|
||||
sealed = true;
|
||||
|
||||
reject(promise, reason);
|
||||
}, 'Settle: ' + (promise._label || ' unknown promise'));
|
||||
|
||||
if (!sealed && error) {
|
||||
sealed = true;
|
||||
reject(promise, error);
|
||||
}
|
||||
}, promise);
|
||||
}
|
||||
|
||||
function handleOwnThenable(promise, thenable) {
|
||||
if (thenable._state === FULFILLED) {
|
||||
fulfill(promise, thenable._result);
|
||||
} else if (thenable._state === REJECTED) {
|
||||
reject(promise, thenable._result);
|
||||
} else {
|
||||
subscribe(thenable, undefined, value => resolve(promise, value),
|
||||
reason => reject(promise, reason))
|
||||
}
|
||||
}
|
||||
|
||||
function handleMaybeThenable(promise, maybeThenable, then) {
|
||||
if (maybeThenable.constructor === promise.constructor &&
|
||||
then === originalThen &&
|
||||
maybeThenable.constructor.resolve === originalResolve) {
|
||||
handleOwnThenable(promise, maybeThenable);
|
||||
} else {
|
||||
if (then === GET_THEN_ERROR) {
|
||||
reject(promise, GET_THEN_ERROR.error);
|
||||
GET_THEN_ERROR.error = null;
|
||||
} else if (then === undefined) {
|
||||
fulfill(promise, maybeThenable);
|
||||
} else if (isFunction(then)) {
|
||||
handleForeignThenable(promise, maybeThenable, then);
|
||||
} else {
|
||||
fulfill(promise, maybeThenable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function resolve(promise, value) {
|
||||
if (promise === value) {
|
||||
reject(promise, selfFulfillment());
|
||||
} else if (objectOrFunction(value)) {
|
||||
handleMaybeThenable(promise, value, getThen(value));
|
||||
} else {
|
||||
fulfill(promise, value);
|
||||
}
|
||||
}
|
||||
|
||||
function publishRejection(promise) {
|
||||
if (promise._onerror) {
|
||||
promise._onerror(promise._result);
|
||||
}
|
||||
|
||||
publish(promise);
|
||||
}
|
||||
|
||||
function fulfill(promise, value) {
|
||||
if (promise._state !== PENDING) { return; }
|
||||
|
||||
promise._result = value;
|
||||
promise._state = FULFILLED;
|
||||
|
||||
if (promise._subscribers.length !== 0) {
|
||||
asap(publish, promise);
|
||||
}
|
||||
}
|
||||
|
||||
function reject(promise, reason) {
|
||||
if (promise._state !== PENDING) { return; }
|
||||
promise._state = REJECTED;
|
||||
promise._result = reason;
|
||||
|
||||
asap(publishRejection, promise);
|
||||
}
|
||||
|
||||
function subscribe(parent, child, onFulfillment, onRejection) {
|
||||
let { _subscribers } = parent;
|
||||
let { length } = _subscribers;
|
||||
|
||||
parent._onerror = null;
|
||||
|
||||
_subscribers[length] = child;
|
||||
_subscribers[length + FULFILLED] = onFulfillment;
|
||||
_subscribers[length + REJECTED] = onRejection;
|
||||
|
||||
if (length === 0 && parent._state) {
|
||||
asap(publish, parent);
|
||||
}
|
||||
}
|
||||
|
||||
function publish(promise) {
|
||||
let subscribers = promise._subscribers;
|
||||
let settled = promise._state;
|
||||
|
||||
if (subscribers.length === 0) { return; }
|
||||
|
||||
let child, callback, detail = promise._result;
|
||||
|
||||
for (let i = 0; i < subscribers.length; i += 3) {
|
||||
child = subscribers[i];
|
||||
callback = subscribers[i + settled];
|
||||
|
||||
if (child) {
|
||||
invokeCallback(settled, child, callback, detail);
|
||||
} else {
|
||||
callback(detail);
|
||||
}
|
||||
}
|
||||
|
||||
promise._subscribers.length = 0;
|
||||
}
|
||||
|
||||
function ErrorObject() {
|
||||
this.error = null;
|
||||
}
|
||||
|
||||
const TRY_CATCH_ERROR = new ErrorObject();
|
||||
|
||||
function tryCatch(callback, detail) {
|
||||
try {
|
||||
return callback(detail);
|
||||
} catch(e) {
|
||||
TRY_CATCH_ERROR.error = e;
|
||||
return TRY_CATCH_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
function invokeCallback(settled, promise, callback, detail) {
|
||||
let hasCallback = isFunction(callback),
|
||||
value, error, succeeded, failed;
|
||||
|
||||
if (hasCallback) {
|
||||
value = tryCatch(callback, detail);
|
||||
|
||||
if (value === TRY_CATCH_ERROR) {
|
||||
failed = true;
|
||||
error = value.error;
|
||||
value.error = null;
|
||||
} else {
|
||||
succeeded = true;
|
||||
}
|
||||
|
||||
if (promise === value) {
|
||||
reject(promise, cannotReturnOwn());
|
||||
return;
|
||||
}
|
||||
|
||||
} else {
|
||||
value = detail;
|
||||
succeeded = true;
|
||||
}
|
||||
|
||||
if (promise._state !== PENDING) {
|
||||
// noop
|
||||
} else if (hasCallback && succeeded) {
|
||||
resolve(promise, value);
|
||||
} else if (failed) {
|
||||
reject(promise, error);
|
||||
} else if (settled === FULFILLED) {
|
||||
fulfill(promise, value);
|
||||
} else if (settled === REJECTED) {
|
||||
reject(promise, value);
|
||||
}
|
||||
}
|
||||
|
||||
function initializePromise(promise, resolver) {
|
||||
try {
|
||||
resolver(function resolvePromise(value){
|
||||
resolve(promise, value);
|
||||
}, function rejectPromise(reason) {
|
||||
reject(promise, reason);
|
||||
});
|
||||
} catch(e) {
|
||||
reject(promise, e);
|
||||
}
|
||||
}
|
||||
|
||||
let id = 0;
|
||||
function nextId() {
|
||||
return id++;
|
||||
}
|
||||
|
||||
function makePromise(promise) {
|
||||
promise[PROMISE_ID] = id++;
|
||||
promise._state = undefined;
|
||||
promise._result = undefined;
|
||||
promise._subscribers = [];
|
||||
}
|
||||
|
||||
export {
|
||||
nextId,
|
||||
makePromise,
|
||||
getThen,
|
||||
noop,
|
||||
resolve,
|
||||
reject,
|
||||
fulfill,
|
||||
subscribe,
|
||||
publish,
|
||||
publishRejection,
|
||||
initializePromise,
|
||||
invokeCallback,
|
||||
FULFILLED,
|
||||
REJECTED,
|
||||
PENDING,
|
||||
handleMaybeThenable
|
||||
};
|
||||
120
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/lib/es6-promise/asap.js
generated
vendored
Normal file
120
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/lib/es6-promise/asap.js
generated
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
let len = 0;
|
||||
let vertxNext;
|
||||
let customSchedulerFn;
|
||||
|
||||
export var asap = function asap(callback, arg) {
|
||||
queue[len] = callback;
|
||||
queue[len + 1] = arg;
|
||||
len += 2;
|
||||
if (len === 2) {
|
||||
// If len is 2, that means that we need to schedule an async flush.
|
||||
// If additional callbacks are queued before the queue is flushed, they
|
||||
// will be processed by this flush that we are scheduling.
|
||||
if (customSchedulerFn) {
|
||||
customSchedulerFn(flush);
|
||||
} else {
|
||||
scheduleFlush();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function setScheduler(scheduleFn) {
|
||||
customSchedulerFn = scheduleFn;
|
||||
}
|
||||
|
||||
export function setAsap(asapFn) {
|
||||
asap = asapFn;
|
||||
}
|
||||
|
||||
const browserWindow = (typeof window !== 'undefined') ? window : undefined;
|
||||
const browserGlobal = browserWindow || {};
|
||||
const BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver;
|
||||
const isNode = typeof self === 'undefined' && typeof process !== 'undefined' && {}.toString.call(process) === '[object process]';
|
||||
|
||||
// test for web worker but not in IE10
|
||||
const isWorker = typeof Uint8ClampedArray !== 'undefined' &&
|
||||
typeof importScripts !== 'undefined' &&
|
||||
typeof MessageChannel !== 'undefined';
|
||||
|
||||
// node
|
||||
function useNextTick() {
|
||||
// node version 0.10.x displays a deprecation warning when nextTick is used recursively
|
||||
// see https://github.com/cujojs/when/issues/410 for details
|
||||
return () => process.nextTick(flush);
|
||||
}
|
||||
|
||||
// vertx
|
||||
function useVertxTimer() {
|
||||
if (typeof vertxNext !== 'undefined') {
|
||||
return function() {
|
||||
vertxNext(flush);
|
||||
};
|
||||
}
|
||||
|
||||
return useSetTimeout();
|
||||
}
|
||||
|
||||
function useMutationObserver() {
|
||||
let iterations = 0;
|
||||
const observer = new BrowserMutationObserver(flush);
|
||||
const node = document.createTextNode('');
|
||||
observer.observe(node, { characterData: true });
|
||||
|
||||
return () => {
|
||||
node.data = (iterations = ++iterations % 2);
|
||||
};
|
||||
}
|
||||
|
||||
// web worker
|
||||
function useMessageChannel() {
|
||||
const channel = new MessageChannel();
|
||||
channel.port1.onmessage = flush;
|
||||
return () => channel.port2.postMessage(0);
|
||||
}
|
||||
|
||||
function useSetTimeout() {
|
||||
// Store setTimeout reference so es6-promise will be unaffected by
|
||||
// other code modifying setTimeout (like sinon.useFakeTimers())
|
||||
const globalSetTimeout = setTimeout;
|
||||
return () => globalSetTimeout(flush, 1);
|
||||
}
|
||||
|
||||
const queue = new Array(1000);
|
||||
function flush() {
|
||||
for (let i = 0; i < len; i+=2) {
|
||||
let callback = queue[i];
|
||||
let arg = queue[i+1];
|
||||
|
||||
callback(arg);
|
||||
|
||||
queue[i] = undefined;
|
||||
queue[i+1] = undefined;
|
||||
}
|
||||
|
||||
len = 0;
|
||||
}
|
||||
|
||||
function attemptVertx() {
|
||||
try {
|
||||
const r = require;
|
||||
const vertx = r('vertx');
|
||||
vertxNext = vertx.runOnLoop || vertx.runOnContext;
|
||||
return useVertxTimer();
|
||||
} catch(e) {
|
||||
return useSetTimeout();
|
||||
}
|
||||
}
|
||||
|
||||
let scheduleFlush;
|
||||
// Decide what async method to use to triggering processing of queued callbacks:
|
||||
if (isNode) {
|
||||
scheduleFlush = useNextTick();
|
||||
} else if (BrowserMutationObserver) {
|
||||
scheduleFlush = useMutationObserver();
|
||||
} else if (isWorker) {
|
||||
scheduleFlush = useMessageChannel();
|
||||
} else if (browserWindow === undefined && typeof require === 'function') {
|
||||
scheduleFlush = attemptVertx();
|
||||
} else {
|
||||
scheduleFlush = useSetTimeout();
|
||||
}
|
||||
115
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/lib/es6-promise/enumerator.js
generated
vendored
Normal file
115
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/lib/es6-promise/enumerator.js
generated
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
import {
|
||||
isArray,
|
||||
isMaybeThenable
|
||||
} from './utils';
|
||||
|
||||
import {
|
||||
noop,
|
||||
reject,
|
||||
fulfill,
|
||||
subscribe,
|
||||
FULFILLED,
|
||||
REJECTED,
|
||||
PENDING,
|
||||
getThen,
|
||||
handleMaybeThenable
|
||||
} from './-internal';
|
||||
|
||||
import then from './then';
|
||||
import Promise from './promise';
|
||||
import originalResolve from './promise/resolve';
|
||||
import originalThen from './then';
|
||||
import { makePromise, PROMISE_ID } from './-internal';
|
||||
|
||||
function validationError() {
|
||||
return new Error('Array Methods must be provided an Array');
|
||||
}
|
||||
|
||||
function validationError() {
|
||||
return new Error('Array Methods must be provided an Array');
|
||||
};
|
||||
|
||||
export default class Enumerator {
|
||||
constructor(Constructor, input) {
|
||||
this._instanceConstructor = Constructor;
|
||||
this.promise = new Constructor(noop);
|
||||
|
||||
if (!this.promise[PROMISE_ID]) {
|
||||
makePromise(this.promise);
|
||||
}
|
||||
|
||||
if (isArray(input)) {
|
||||
this.length = input.length;
|
||||
this._remaining = input.length;
|
||||
|
||||
this._result = new Array(this.length);
|
||||
|
||||
if (this.length === 0) {
|
||||
fulfill(this.promise, this._result);
|
||||
} else {
|
||||
this.length = this.length || 0;
|
||||
this._enumerate(input);
|
||||
if (this._remaining === 0) {
|
||||
fulfill(this.promise, this._result);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
reject(this.promise, validationError());
|
||||
}
|
||||
}
|
||||
_enumerate(input) {
|
||||
for (let i = 0; this._state === PENDING && i < input.length; i++) {
|
||||
this._eachEntry(input[i], i);
|
||||
}
|
||||
}
|
||||
|
||||
_eachEntry(entry, i) {
|
||||
let c = this._instanceConstructor;
|
||||
let { resolve } = c;
|
||||
|
||||
if (resolve === originalResolve) {
|
||||
let then = getThen(entry);
|
||||
|
||||
if (then === originalThen &&
|
||||
entry._state !== PENDING) {
|
||||
this._settledAt(entry._state, i, entry._result);
|
||||
} else if (typeof then !== 'function') {
|
||||
this._remaining--;
|
||||
this._result[i] = entry;
|
||||
} else if (c === Promise) {
|
||||
let promise = new c(noop);
|
||||
handleMaybeThenable(promise, entry, then);
|
||||
this._willSettleAt(promise, i);
|
||||
} else {
|
||||
this._willSettleAt(new c(resolve => resolve(entry)), i);
|
||||
}
|
||||
} else {
|
||||
this._willSettleAt(resolve(entry), i);
|
||||
}
|
||||
}
|
||||
|
||||
_settledAt(state, i, value) {
|
||||
let { promise } = this;
|
||||
|
||||
if (promise._state === PENDING) {
|
||||
this._remaining--;
|
||||
|
||||
if (state === REJECTED) {
|
||||
reject(promise, value);
|
||||
} else {
|
||||
this._result[i] = value;
|
||||
}
|
||||
}
|
||||
|
||||
if (this._remaining === 0) {
|
||||
fulfill(promise, this._result);
|
||||
}
|
||||
}
|
||||
|
||||
_willSettleAt(promise, i) {
|
||||
let enumerator = this;
|
||||
|
||||
subscribe(promise, undefined, value => enumerator._settledAt(FULFILLED, i, value),
|
||||
reason => enumerator._settledAt(REJECTED, i, reason));
|
||||
}
|
||||
}
|
||||
35
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/lib/es6-promise/polyfill.js
generated
vendored
Normal file
35
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/lib/es6-promise/polyfill.js
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
/*global self*/
|
||||
import Promise from './promise';
|
||||
|
||||
export default function polyfill() {
|
||||
let local;
|
||||
|
||||
if (typeof global !== 'undefined') {
|
||||
local = global;
|
||||
} else if (typeof self !== 'undefined') {
|
||||
local = self;
|
||||
} else {
|
||||
try {
|
||||
local = Function('return this')();
|
||||
} catch (e) {
|
||||
throw new Error('polyfill failed because global object is unavailable in this environment');
|
||||
}
|
||||
}
|
||||
|
||||
let P = local.Promise;
|
||||
|
||||
if (P) {
|
||||
var promiseToString = null;
|
||||
try {
|
||||
promiseToString = Object.prototype.toString.call(P.resolve());
|
||||
} catch(e) {
|
||||
// silently ignored
|
||||
}
|
||||
|
||||
if (promiseToString === '[object Promise]' && !P.cast){
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
local.Promise = Promise;
|
||||
}
|
||||
429
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/lib/es6-promise/promise.js
generated
vendored
Normal file
429
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/lib/es6-promise/promise.js
generated
vendored
Normal file
@@ -0,0 +1,429 @@
|
||||
import {
|
||||
isFunction
|
||||
} from './utils';
|
||||
|
||||
import {
|
||||
noop,
|
||||
nextId,
|
||||
PROMISE_ID,
|
||||
initializePromise
|
||||
} from './-internal';
|
||||
|
||||
import {
|
||||
asap,
|
||||
setAsap,
|
||||
setScheduler
|
||||
} from './asap';
|
||||
|
||||
import all from './promise/all';
|
||||
import race from './promise/race';
|
||||
import Resolve from './promise/resolve';
|
||||
import Reject from './promise/reject';
|
||||
import then from './then';
|
||||
|
||||
function needsResolver() {
|
||||
throw new TypeError('You must pass a resolver function as the first argument to the promise constructor');
|
||||
}
|
||||
|
||||
function needsNew() {
|
||||
throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");
|
||||
}
|
||||
|
||||
/**
|
||||
Promise objects represent the eventual result of an asynchronous operation. The
|
||||
primary way of interacting with a promise is through its `then` method, which
|
||||
registers callbacks to receive either a promise's eventual value or the reason
|
||||
why the promise cannot be fulfilled.
|
||||
|
||||
Terminology
|
||||
-----------
|
||||
|
||||
- `promise` is an object or function with a `then` method whose behavior conforms to this specification.
|
||||
- `thenable` is an object or function that defines a `then` method.
|
||||
- `value` is any legal JavaScript value (including undefined, a thenable, or a promise).
|
||||
- `exception` is a value that is thrown using the throw statement.
|
||||
- `reason` is a value that indicates why a promise was rejected.
|
||||
- `settled` the final resting state of a promise, fulfilled or rejected.
|
||||
|
||||
A promise can be in one of three states: pending, fulfilled, or rejected.
|
||||
|
||||
Promises that are fulfilled have a fulfillment value and are in the fulfilled
|
||||
state. Promises that are rejected have a rejection reason and are in the
|
||||
rejected state. A fulfillment value is never a thenable.
|
||||
|
||||
Promises can also be said to *resolve* a value. If this value is also a
|
||||
promise, then the original promise's settled state will match the value's
|
||||
settled state. So a promise that *resolves* a promise that rejects will
|
||||
itself reject, and a promise that *resolves* a promise that fulfills will
|
||||
itself fulfill.
|
||||
|
||||
|
||||
Basic Usage:
|
||||
------------
|
||||
|
||||
```js
|
||||
let promise = new Promise(function(resolve, reject) {
|
||||
// on success
|
||||
resolve(value);
|
||||
|
||||
// on failure
|
||||
reject(reason);
|
||||
});
|
||||
|
||||
promise.then(function(value) {
|
||||
// on fulfillment
|
||||
}, function(reason) {
|
||||
// on rejection
|
||||
});
|
||||
```
|
||||
|
||||
Advanced Usage:
|
||||
---------------
|
||||
|
||||
Promises shine when abstracting away asynchronous interactions such as
|
||||
`XMLHttpRequest`s.
|
||||
|
||||
```js
|
||||
function getJSON(url) {
|
||||
return new Promise(function(resolve, reject){
|
||||
let xhr = new XMLHttpRequest();
|
||||
|
||||
xhr.open('GET', url);
|
||||
xhr.onreadystatechange = handler;
|
||||
xhr.responseType = 'json';
|
||||
xhr.setRequestHeader('Accept', 'application/json');
|
||||
xhr.send();
|
||||
|
||||
function handler() {
|
||||
if (this.readyState === this.DONE) {
|
||||
if (this.status === 200) {
|
||||
resolve(this.response);
|
||||
} else {
|
||||
reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']'));
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
getJSON('/posts.json').then(function(json) {
|
||||
// on fulfillment
|
||||
}, function(reason) {
|
||||
// on rejection
|
||||
});
|
||||
```
|
||||
|
||||
Unlike callbacks, promises are great composable primitives.
|
||||
|
||||
```js
|
||||
Promise.all([
|
||||
getJSON('/posts'),
|
||||
getJSON('/comments')
|
||||
]).then(function(values){
|
||||
values[0] // => postsJSON
|
||||
values[1] // => commentsJSON
|
||||
|
||||
return values;
|
||||
});
|
||||
```
|
||||
|
||||
@class Promise
|
||||
@param {Function} resolver
|
||||
Useful for tooling.
|
||||
@constructor
|
||||
*/
|
||||
|
||||
class Promise {
|
||||
constructor(resolver) {
|
||||
this[PROMISE_ID] = nextId();
|
||||
this._result = this._state = undefined;
|
||||
this._subscribers = [];
|
||||
|
||||
if (noop !== resolver) {
|
||||
typeof resolver !== 'function' && needsResolver();
|
||||
this instanceof Promise ? initializePromise(this, resolver) : needsNew();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
The primary way of interacting with a promise is through its `then` method,
|
||||
which registers callbacks to receive either a promise's eventual value or the
|
||||
reason why the promise cannot be fulfilled.
|
||||
|
||||
```js
|
||||
findUser().then(function(user){
|
||||
// user is available
|
||||
}, function(reason){
|
||||
// user is unavailable, and you are given the reason why
|
||||
});
|
||||
```
|
||||
|
||||
Chaining
|
||||
--------
|
||||
|
||||
The return value of `then` is itself a promise. This second, 'downstream'
|
||||
promise is resolved with the return value of the first promise's fulfillment
|
||||
or rejection handler, or rejected if the handler throws an exception.
|
||||
|
||||
```js
|
||||
findUser().then(function (user) {
|
||||
return user.name;
|
||||
}, function (reason) {
|
||||
return 'default name';
|
||||
}).then(function (userName) {
|
||||
// If `findUser` fulfilled, `userName` will be the user's name, otherwise it
|
||||
// will be `'default name'`
|
||||
});
|
||||
|
||||
findUser().then(function (user) {
|
||||
throw new Error('Found user, but still unhappy');
|
||||
}, function (reason) {
|
||||
throw new Error('`findUser` rejected and we're unhappy');
|
||||
}).then(function (value) {
|
||||
// never reached
|
||||
}, function (reason) {
|
||||
// if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'.
|
||||
// If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'.
|
||||
});
|
||||
```
|
||||
If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream.
|
||||
|
||||
```js
|
||||
findUser().then(function (user) {
|
||||
throw new PedagogicalException('Upstream error');
|
||||
}).then(function (value) {
|
||||
// never reached
|
||||
}).then(function (value) {
|
||||
// never reached
|
||||
}, function (reason) {
|
||||
// The `PedgagocialException` is propagated all the way down to here
|
||||
});
|
||||
```
|
||||
|
||||
Assimilation
|
||||
------------
|
||||
|
||||
Sometimes the value you want to propagate to a downstream promise can only be
|
||||
retrieved asynchronously. This can be achieved by returning a promise in the
|
||||
fulfillment or rejection handler. The downstream promise will then be pending
|
||||
until the returned promise is settled. This is called *assimilation*.
|
||||
|
||||
```js
|
||||
findUser().then(function (user) {
|
||||
return findCommentsByAuthor(user);
|
||||
}).then(function (comments) {
|
||||
// The user's comments are now available
|
||||
});
|
||||
```
|
||||
|
||||
If the assimliated promise rejects, then the downstream promise will also reject.
|
||||
|
||||
```js
|
||||
findUser().then(function (user) {
|
||||
return findCommentsByAuthor(user);
|
||||
}).then(function (comments) {
|
||||
// If `findCommentsByAuthor` fulfills, we'll have the value here
|
||||
}, function (reason) {
|
||||
// If `findCommentsByAuthor` rejects, we'll have the reason here
|
||||
});
|
||||
```
|
||||
|
||||
Simple Example
|
||||
--------------
|
||||
|
||||
Synchronous Example
|
||||
|
||||
```javascript
|
||||
let result;
|
||||
|
||||
try {
|
||||
result = findResult();
|
||||
// success
|
||||
} catch(reason) {
|
||||
// failure
|
||||
}
|
||||
```
|
||||
|
||||
Errback Example
|
||||
|
||||
```js
|
||||
findResult(function(result, err){
|
||||
if (err) {
|
||||
// failure
|
||||
} else {
|
||||
// success
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
Promise Example;
|
||||
|
||||
```javascript
|
||||
findResult().then(function(result){
|
||||
// success
|
||||
}, function(reason){
|
||||
// failure
|
||||
});
|
||||
```
|
||||
|
||||
Advanced Example
|
||||
--------------
|
||||
|
||||
Synchronous Example
|
||||
|
||||
```javascript
|
||||
let author, books;
|
||||
|
||||
try {
|
||||
author = findAuthor();
|
||||
books = findBooksByAuthor(author);
|
||||
// success
|
||||
} catch(reason) {
|
||||
// failure
|
||||
}
|
||||
```
|
||||
|
||||
Errback Example
|
||||
|
||||
```js
|
||||
|
||||
function foundBooks(books) {
|
||||
|
||||
}
|
||||
|
||||
function failure(reason) {
|
||||
|
||||
}
|
||||
|
||||
findAuthor(function(author, err){
|
||||
if (err) {
|
||||
failure(err);
|
||||
// failure
|
||||
} else {
|
||||
try {
|
||||
findBoooksByAuthor(author, function(books, err) {
|
||||
if (err) {
|
||||
failure(err);
|
||||
} else {
|
||||
try {
|
||||
foundBooks(books);
|
||||
} catch(reason) {
|
||||
failure(reason);
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch(error) {
|
||||
failure(err);
|
||||
}
|
||||
// success
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
Promise Example;
|
||||
|
||||
```javascript
|
||||
findAuthor().
|
||||
then(findBooksByAuthor).
|
||||
then(function(books){
|
||||
// found books
|
||||
}).catch(function(reason){
|
||||
// something went wrong
|
||||
});
|
||||
```
|
||||
|
||||
@method then
|
||||
@param {Function} onFulfilled
|
||||
@param {Function} onRejected
|
||||
Useful for tooling.
|
||||
@return {Promise}
|
||||
*/
|
||||
|
||||
/**
|
||||
`catch` is simply sugar for `then(undefined, onRejection)` which makes it the same
|
||||
as the catch block of a try/catch statement.
|
||||
|
||||
```js
|
||||
function findAuthor(){
|
||||
throw new Error('couldn't find that author');
|
||||
}
|
||||
|
||||
// synchronous
|
||||
try {
|
||||
findAuthor();
|
||||
} catch(reason) {
|
||||
// something went wrong
|
||||
}
|
||||
|
||||
// async with promises
|
||||
findAuthor().catch(function(reason){
|
||||
// something went wrong
|
||||
});
|
||||
```
|
||||
|
||||
@method catch
|
||||
@param {Function} onRejection
|
||||
Useful for tooling.
|
||||
@return {Promise}
|
||||
*/
|
||||
catch(onRejection) {
|
||||
return this.then(null, onRejection);
|
||||
}
|
||||
|
||||
/**
|
||||
`finally` will be invoked regardless of the promise's fate just as native
|
||||
try/catch/finally behaves
|
||||
|
||||
Synchronous example:
|
||||
|
||||
```js
|
||||
findAuthor() {
|
||||
if (Math.random() > 0.5) {
|
||||
throw new Error();
|
||||
}
|
||||
return new Author();
|
||||
}
|
||||
|
||||
try {
|
||||
return findAuthor(); // succeed or fail
|
||||
} catch(error) {
|
||||
return findOtherAuther();
|
||||
} finally {
|
||||
// always runs
|
||||
// doesn't affect the return value
|
||||
}
|
||||
```
|
||||
|
||||
Asynchronous example:
|
||||
|
||||
```js
|
||||
findAuthor().catch(function(reason){
|
||||
return findOtherAuther();
|
||||
}).finally(function(){
|
||||
// author was either found, or not
|
||||
});
|
||||
```
|
||||
|
||||
@method finally
|
||||
@param {Function} callback
|
||||
@return {Promise}
|
||||
*/
|
||||
finally(callback) {
|
||||
let promise = this;
|
||||
let constructor = promise.constructor;
|
||||
|
||||
return promise.then(value => constructor.resolve(callback()).then(() => value),
|
||||
reason => constructor.resolve(callback()).then(() => { throw reason; }));
|
||||
}
|
||||
}
|
||||
|
||||
Promise.prototype.then = then;
|
||||
export default Promise;
|
||||
Promise.all = all;
|
||||
Promise.race = race;
|
||||
Promise.resolve = Resolve;
|
||||
Promise.reject = Reject;
|
||||
Promise._setScheduler = setScheduler;
|
||||
Promise._setAsap = setAsap;
|
||||
Promise._asap = asap;
|
||||
|
||||
52
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/lib/es6-promise/promise/all.js
generated
vendored
Normal file
52
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/lib/es6-promise/promise/all.js
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
import Enumerator from '../enumerator';
|
||||
|
||||
/**
|
||||
`Promise.all` accepts an array of promises, and returns a new promise which
|
||||
is fulfilled with an array of fulfillment values for the passed promises, or
|
||||
rejected with the reason of the first passed promise to be rejected. It casts all
|
||||
elements of the passed iterable to promises as it runs this algorithm.
|
||||
|
||||
Example:
|
||||
|
||||
```javascript
|
||||
let promise1 = resolve(1);
|
||||
let promise2 = resolve(2);
|
||||
let promise3 = resolve(3);
|
||||
let promises = [ promise1, promise2, promise3 ];
|
||||
|
||||
Promise.all(promises).then(function(array){
|
||||
// The array here would be [ 1, 2, 3 ];
|
||||
});
|
||||
```
|
||||
|
||||
If any of the `promises` given to `all` are rejected, the first promise
|
||||
that is rejected will be given as an argument to the returned promises's
|
||||
rejection handler. For example:
|
||||
|
||||
Example:
|
||||
|
||||
```javascript
|
||||
let promise1 = resolve(1);
|
||||
let promise2 = reject(new Error("2"));
|
||||
let promise3 = reject(new Error("3"));
|
||||
let promises = [ promise1, promise2, promise3 ];
|
||||
|
||||
Promise.all(promises).then(function(array){
|
||||
// Code here never runs because there are rejected promises!
|
||||
}, function(error) {
|
||||
// error.message === "2"
|
||||
});
|
||||
```
|
||||
|
||||
@method all
|
||||
@static
|
||||
@param {Array} entries array of promises
|
||||
@param {String} label optional string for labeling the promise.
|
||||
Useful for tooling.
|
||||
@return {Promise} promise that is fulfilled when all `promises` have been
|
||||
fulfilled, or rejected if any of them become rejected.
|
||||
@static
|
||||
*/
|
||||
export default function all(entries) {
|
||||
return new Enumerator(this, entries).promise;
|
||||
}
|
||||
84
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/lib/es6-promise/promise/race.js
generated
vendored
Normal file
84
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/lib/es6-promise/promise/race.js
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
import {
|
||||
isArray
|
||||
} from "../utils";
|
||||
|
||||
/**
|
||||
`Promise.race` returns a new promise which is settled in the same way as the
|
||||
first passed promise to settle.
|
||||
|
||||
Example:
|
||||
|
||||
```javascript
|
||||
let promise1 = new Promise(function(resolve, reject){
|
||||
setTimeout(function(){
|
||||
resolve('promise 1');
|
||||
}, 200);
|
||||
});
|
||||
|
||||
let promise2 = new Promise(function(resolve, reject){
|
||||
setTimeout(function(){
|
||||
resolve('promise 2');
|
||||
}, 100);
|
||||
});
|
||||
|
||||
Promise.race([promise1, promise2]).then(function(result){
|
||||
// result === 'promise 2' because it was resolved before promise1
|
||||
// was resolved.
|
||||
});
|
||||
```
|
||||
|
||||
`Promise.race` is deterministic in that only the state of the first
|
||||
settled promise matters. For example, even if other promises given to the
|
||||
`promises` array argument are resolved, but the first settled promise has
|
||||
become rejected before the other promises became fulfilled, the returned
|
||||
promise will become rejected:
|
||||
|
||||
```javascript
|
||||
let promise1 = new Promise(function(resolve, reject){
|
||||
setTimeout(function(){
|
||||
resolve('promise 1');
|
||||
}, 200);
|
||||
});
|
||||
|
||||
let promise2 = new Promise(function(resolve, reject){
|
||||
setTimeout(function(){
|
||||
reject(new Error('promise 2'));
|
||||
}, 100);
|
||||
});
|
||||
|
||||
Promise.race([promise1, promise2]).then(function(result){
|
||||
// Code here never runs
|
||||
}, function(reason){
|
||||
// reason.message === 'promise 2' because promise 2 became rejected before
|
||||
// promise 1 became fulfilled
|
||||
});
|
||||
```
|
||||
|
||||
An example real-world use case is implementing timeouts:
|
||||
|
||||
```javascript
|
||||
Promise.race([ajax('foo.json'), timeout(5000)])
|
||||
```
|
||||
|
||||
@method race
|
||||
@static
|
||||
@param {Array} promises array of promises to observe
|
||||
Useful for tooling.
|
||||
@return {Promise} a promise which settles in the same way as the first passed
|
||||
promise to settle.
|
||||
*/
|
||||
export default function race(entries) {
|
||||
/*jshint validthis:true */
|
||||
let Constructor = this;
|
||||
|
||||
if (!isArray(entries)) {
|
||||
return new Constructor((_, reject) => reject(new TypeError('You must pass an array to race.')));
|
||||
} else {
|
||||
return new Constructor((resolve, reject) => {
|
||||
let length = entries.length;
|
||||
for (let i = 0; i < length; i++) {
|
||||
Constructor.resolve(entries[i]).then(resolve, reject);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
46
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/lib/es6-promise/promise/reject.js
generated
vendored
Normal file
46
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/lib/es6-promise/promise/reject.js
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
import {
|
||||
noop,
|
||||
reject as _reject
|
||||
} from '../-internal';
|
||||
|
||||
/**
|
||||
`Promise.reject` returns a promise rejected with the passed `reason`.
|
||||
It is shorthand for the following:
|
||||
|
||||
```javascript
|
||||
let promise = new Promise(function(resolve, reject){
|
||||
reject(new Error('WHOOPS'));
|
||||
});
|
||||
|
||||
promise.then(function(value){
|
||||
// Code here doesn't run because the promise is rejected!
|
||||
}, function(reason){
|
||||
// reason.message === 'WHOOPS'
|
||||
});
|
||||
```
|
||||
|
||||
Instead of writing the above, your code now simply becomes the following:
|
||||
|
||||
```javascript
|
||||
let promise = Promise.reject(new Error('WHOOPS'));
|
||||
|
||||
promise.then(function(value){
|
||||
// Code here doesn't run because the promise is rejected!
|
||||
}, function(reason){
|
||||
// reason.message === 'WHOOPS'
|
||||
});
|
||||
```
|
||||
|
||||
@method reject
|
||||
@static
|
||||
@param {Any} reason value that the returned promise will be rejected with.
|
||||
Useful for tooling.
|
||||
@return {Promise} a promise rejected with the given `reason`.
|
||||
*/
|
||||
export default function reject(reason) {
|
||||
/*jshint validthis:true */
|
||||
let Constructor = this;
|
||||
let promise = new Constructor(noop);
|
||||
_reject(promise, reason);
|
||||
return promise;
|
||||
}
|
||||
48
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/lib/es6-promise/promise/resolve.js
generated
vendored
Normal file
48
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/lib/es6-promise/promise/resolve.js
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
import {
|
||||
noop,
|
||||
resolve as _resolve
|
||||
} from '../-internal';
|
||||
|
||||
/**
|
||||
`Promise.resolve` returns a promise that will become resolved with the
|
||||
passed `value`. It is shorthand for the following:
|
||||
|
||||
```javascript
|
||||
let promise = new Promise(function(resolve, reject){
|
||||
resolve(1);
|
||||
});
|
||||
|
||||
promise.then(function(value){
|
||||
// value === 1
|
||||
});
|
||||
```
|
||||
|
||||
Instead of writing the above, your code now simply becomes the following:
|
||||
|
||||
```javascript
|
||||
let promise = Promise.resolve(1);
|
||||
|
||||
promise.then(function(value){
|
||||
// value === 1
|
||||
});
|
||||
```
|
||||
|
||||
@method resolve
|
||||
@static
|
||||
@param {Any} value value that the returned promise will be resolved with
|
||||
Useful for tooling.
|
||||
@return {Promise} a promise that will become fulfilled with the given
|
||||
`value`
|
||||
*/
|
||||
export default function resolve(object) {
|
||||
/*jshint validthis:true */
|
||||
let Constructor = this;
|
||||
|
||||
if (object && typeof object === 'object' && object.constructor === Constructor) {
|
||||
return object;
|
||||
}
|
||||
|
||||
let promise = new Constructor(noop);
|
||||
_resolve(promise, object);
|
||||
return promise;
|
||||
}
|
||||
32
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/lib/es6-promise/then.js
generated
vendored
Normal file
32
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/lib/es6-promise/then.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
import {
|
||||
invokeCallback,
|
||||
subscribe,
|
||||
FULFILLED,
|
||||
REJECTED,
|
||||
noop,
|
||||
makePromise,
|
||||
PROMISE_ID
|
||||
} from './-internal';
|
||||
|
||||
import { asap } from './asap';
|
||||
|
||||
export default function then(onFulfillment, onRejection) {
|
||||
const parent = this;
|
||||
|
||||
const child = new this.constructor(noop);
|
||||
|
||||
if (child[PROMISE_ID] === undefined) {
|
||||
makePromise(child);
|
||||
}
|
||||
|
||||
const { _state } = parent;
|
||||
|
||||
if (_state) {
|
||||
const callback = arguments[_state - 1];
|
||||
asap(() => invokeCallback(_state, child, callback, parent._result));
|
||||
} else {
|
||||
subscribe(parent, child, onFulfillment, onRejection);
|
||||
}
|
||||
|
||||
return child;
|
||||
}
|
||||
21
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/lib/es6-promise/utils.js
generated
vendored
Normal file
21
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/lib/es6-promise/utils.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
export function objectOrFunction(x) {
|
||||
let type = typeof x;
|
||||
return x !== null && (type === 'object' || type === 'function');
|
||||
}
|
||||
|
||||
export function isFunction(x) {
|
||||
return typeof x === 'function';
|
||||
}
|
||||
|
||||
export function isMaybeThenable(x) {
|
||||
return x !== null && typeof x === 'object';
|
||||
}
|
||||
|
||||
let _isArray;
|
||||
if (Array.isArray) {
|
||||
_isArray = Array.isArray;
|
||||
} else {
|
||||
_isArray = x => Object.prototype.toString.call(x) === '[object Array]';
|
||||
}
|
||||
|
||||
export const isArray = _isArray;
|
||||
104
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/package.json
generated
vendored
Normal file
104
build/node_modules/phantomjs-prebuilt/node_modules/es6-promise/package.json
generated
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
{
|
||||
"_from": "es6-promise@^4.0.3",
|
||||
"_id": "es6-promise@4.2.2",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-LSas5vsuA6Q4nEdf9wokY5/AJYXry98i0IzXsv49rYsgDGDNDPbqAYR1Pe23iFxygfbGZNR/5VrHXBCh2BhvUQ==",
|
||||
"_location": "/phantomjs-prebuilt/es6-promise",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "es6-promise@^4.0.3",
|
||||
"name": "es6-promise",
|
||||
"escapedName": "es6-promise",
|
||||
"rawSpec": "^4.0.3",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^4.0.3"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/phantomjs-prebuilt"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.2.tgz",
|
||||
"_shasum": "f722d7769af88bd33bc13ec6605e1f92966b82d9",
|
||||
"_spec": "es6-promise@^4.0.3",
|
||||
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build/node_modules/phantomjs-prebuilt",
|
||||
"author": {
|
||||
"name": "Yehuda Katz, Tom Dale, Stefan Penner and contributors",
|
||||
"url": "Conversion to ES6 API by Jake Archibald"
|
||||
},
|
||||
"browser": {
|
||||
"vertx": false
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/stefanpenner/es6-promise/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {},
|
||||
"deprecated": false,
|
||||
"description": "A lightweight library that provides tools for organizing asynchronous code",
|
||||
"devDependencies": {
|
||||
"babel-plugin-transform-es2015-arrow-functions": "^6.22.0",
|
||||
"babel-plugin-transform-es2015-block-scoping": "^6.24.1",
|
||||
"babel-plugin-transform-es2015-classes": "^6.24.1",
|
||||
"babel-plugin-transform-es2015-computed-properties": "^6.24.1",
|
||||
"babel-plugin-transform-es2015-constants": "^6.1.4",
|
||||
"babel-plugin-transform-es2015-destructuring": "^6.23.0",
|
||||
"babel-plugin-transform-es2015-parameters": "^6.24.1",
|
||||
"babel-plugin-transform-es2015-shorthand-properties": "^6.24.1",
|
||||
"babel-plugin-transform-es2015-spread": "^6.22.0",
|
||||
"babel-plugin-transform-es2015-template-literals": "^6.22.0",
|
||||
"babel6-plugin-strip-class-callcheck": "^6.0.0",
|
||||
"broccoli-babel-transpiler": "^6.0.0",
|
||||
"broccoli-concat": "^3.1.0",
|
||||
"broccoli-merge-trees": "^2.0.0",
|
||||
"broccoli-rollup": "^2.0.0",
|
||||
"broccoli-stew": "^1.5.0",
|
||||
"broccoli-uglify-js": "^0.2.0",
|
||||
"broccoli-watchify": "^1.0.1",
|
||||
"ember-cli": "2.18.0-beta.2",
|
||||
"ember-cli-dependency-checker": "^2.1.0",
|
||||
"git-repo-version": "1.0.1",
|
||||
"json3": "^3.3.2",
|
||||
"mocha": "^4.0.1",
|
||||
"promises-aplus-tests-phantom": "^2.1.0-revise"
|
||||
},
|
||||
"directories": {
|
||||
"lib": "lib"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"lib",
|
||||
"es6-promise.d.ts",
|
||||
"auto.js",
|
||||
"!dist/test"
|
||||
],
|
||||
"homepage": "https://github.com/stefanpenner/es6-promise#readme",
|
||||
"keywords": [
|
||||
"promises",
|
||||
"promise",
|
||||
"polyfill",
|
||||
"futures"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "dist/es6-promise.js",
|
||||
"name": "es6-promise",
|
||||
"namespace": "es6-promise",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/stefanpenner/es6-promise.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "ember build --environment production",
|
||||
"prepublishOnly": "ember build --environment production",
|
||||
"start": "ember s",
|
||||
"test": "ember test",
|
||||
"test:browser": "ember test --launch PhantomJS",
|
||||
"test:node": "ember test --launch Mocha",
|
||||
"test:server": "ember test --server"
|
||||
},
|
||||
"spm": {
|
||||
"main": "dist/es6-promise.js"
|
||||
},
|
||||
"typings": "es6-promise.d.ts",
|
||||
"version": "4.2.2"
|
||||
}
|
||||
85
build/node_modules/phantomjs-prebuilt/package.json
generated
vendored
Normal file
85
build/node_modules/phantomjs-prebuilt/package.json
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
{
|
||||
"_from": "phantomjs-prebuilt@^2.1.10",
|
||||
"_id": "phantomjs-prebuilt@2.1.16",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-79ISpKOWbTZHaE6ouniFSb4q7+8=",
|
||||
"_location": "/phantomjs-prebuilt",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "phantomjs-prebuilt@^2.1.10",
|
||||
"name": "phantomjs-prebuilt",
|
||||
"escapedName": "phantomjs-prebuilt",
|
||||
"rawSpec": "^2.1.10",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^2.1.10"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/svg2png"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/phantomjs-prebuilt/-/phantomjs-prebuilt-2.1.16.tgz",
|
||||
"_shasum": "efd212a4a3966d3647684ea8ba788549be2aefef",
|
||||
"_spec": "phantomjs-prebuilt@^2.1.10",
|
||||
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build/node_modules/svg2png",
|
||||
"author": {
|
||||
"name": "Dan Pupius",
|
||||
"email": "dan@obvious.com",
|
||||
"url": "http://pupius.co.uk"
|
||||
},
|
||||
"bin": {
|
||||
"phantomjs": "./bin/phantomjs"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/Medium/phantomjs/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"es6-promise": "^4.0.3",
|
||||
"extract-zip": "^1.6.5",
|
||||
"fs-extra": "^1.0.0",
|
||||
"hasha": "^2.2.0",
|
||||
"kew": "^0.7.0",
|
||||
"progress": "^1.1.8",
|
||||
"request": "^2.81.0",
|
||||
"request-progress": "^2.0.1",
|
||||
"which": "^1.2.10"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Headless WebKit with JS API",
|
||||
"devDependencies": {
|
||||
"eslint": "2.7.0",
|
||||
"nodeunit": "0.9.1",
|
||||
"webdriverio": "~4.2.3"
|
||||
},
|
||||
"homepage": "https://github.com/Medium/phantomjs",
|
||||
"keywords": [
|
||||
"phantomjs",
|
||||
"headless",
|
||||
"webkit"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"main": "lib/phantomjs",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "Dan Pupius",
|
||||
"email": "dan@medium.com",
|
||||
"url": "http://pupius.co.uk/"
|
||||
},
|
||||
{
|
||||
"name": "Nick Santos",
|
||||
"email": "nick@medium.com",
|
||||
"url": "http://nick-santos.com/"
|
||||
}
|
||||
],
|
||||
"name": "phantomjs-prebuilt",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/Medium/phantomjs.git"
|
||||
},
|
||||
"scripts": {
|
||||
"install": "node install.js",
|
||||
"test": "nodeunit --reporter=minimal test/tests.js && eslint ."
|
||||
},
|
||||
"version": "2.1.16"
|
||||
}
|
||||
1
build/node_modules/phantomjs-prebuilt/test/exit.js
generated
vendored
Normal file
1
build/node_modules/phantomjs-prebuilt/test/exit.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
phantom.exit(123)
|
||||
25
build/node_modules/phantomjs-prebuilt/test/loadspeed.js
generated
vendored
Normal file
25
build/node_modules/phantomjs-prebuilt/test/loadspeed.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
// phantomjs test script
|
||||
// opens url and reports time to load
|
||||
// requires an active internet connection
|
||||
var page = require('webpage').create()
|
||||
var system = require('system')
|
||||
var t
|
||||
var address
|
||||
|
||||
if (system.args.length === 1) {
|
||||
console.log('Usage: loadspeed.js <some URL>')
|
||||
phantom.exit()
|
||||
}
|
||||
|
||||
t = Date.now()
|
||||
address = system.args[1]
|
||||
page.open(address, function (status) {
|
||||
if (status !== 'success') {
|
||||
console.log('FAIL to load the address')
|
||||
} else {
|
||||
t = Date.now() - t
|
||||
console.log('Loading time ' + t + ' msec')
|
||||
}
|
||||
|
||||
phantom.exit()
|
||||
})
|
||||
136
build/node_modules/phantomjs-prebuilt/test/tests.js
generated
vendored
Normal file
136
build/node_modules/phantomjs-prebuilt/test/tests.js
generated
vendored
Normal file
@@ -0,0 +1,136 @@
|
||||
/**
|
||||
* Nodeunit functional tests. Requires internet connection to validate phantom
|
||||
* functions correctly.
|
||||
*/
|
||||
|
||||
var childProcess = require('child_process')
|
||||
var fs = require('fs')
|
||||
var path = require('path')
|
||||
var webdriverio = require('webdriverio')
|
||||
var phantomjs = require('../lib/phantomjs')
|
||||
var util = require('../lib/util')
|
||||
|
||||
exports.testDownload = function (test) {
|
||||
test.expect(1)
|
||||
test.ok(fs.existsSync(phantomjs.path), 'Binary file should have been downloaded')
|
||||
test.done()
|
||||
}
|
||||
|
||||
|
||||
exports.testPhantomExecutesTestScript = function (test) {
|
||||
test.expect(1)
|
||||
|
||||
var childArgs = [
|
||||
path.join(__dirname, 'loadspeed.js'),
|
||||
'http://www.google.com/'
|
||||
]
|
||||
|
||||
childProcess.execFile(phantomjs.path, childArgs, function (err, stdout) {
|
||||
var value = (stdout.indexOf('msec') !== -1)
|
||||
test.ok(value, 'Test script should have executed and returned run time')
|
||||
test.done()
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
exports.testPhantomExitCode = function (test) {
|
||||
test.expect(1)
|
||||
childProcess.execFile(phantomjs.path, [path.join(__dirname, 'exit.js')], function (err) {
|
||||
test.equals(err.code, 123, 'Exit code should be returned from phantom script')
|
||||
test.done()
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
exports.testBinFile = function (test) {
|
||||
test.expect(1)
|
||||
|
||||
var binPath = process.platform === 'win32' ?
|
||||
path.join(__dirname, '..', 'lib', 'phantom', 'phantomjs.exe') :
|
||||
path.join(__dirname, '..', 'bin', 'phantomjs')
|
||||
|
||||
childProcess.execFile(binPath, ['--version'], function (err, stdout) {
|
||||
test.equal(phantomjs.version, stdout.trim(), 'Version should be match')
|
||||
test.done()
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
exports.testCleanPath = function (test) {
|
||||
test.expect(5)
|
||||
test.equal('/Users/dan/bin', phantomjs.cleanPath('/Users/dan/bin:./bin'))
|
||||
test.equal('/Users/dan/bin:/usr/bin', phantomjs.cleanPath('/Users/dan/bin:./bin:/usr/bin'))
|
||||
test.equal('/usr/bin', phantomjs.cleanPath('./bin:/usr/bin'))
|
||||
test.equal('', phantomjs.cleanPath('./bin'))
|
||||
test.equal('/Work/bin:/usr/bin', phantomjs.cleanPath('/Work/bin:/Work/phantomjs/node_modules/.bin:/usr/bin'))
|
||||
test.done()
|
||||
}
|
||||
|
||||
exports.testBogusReinstallLocation = function (test) {
|
||||
util.findValidPhantomJsBinary('./blargh')
|
||||
.then(function (binaryLocation) {
|
||||
test.ok(!binaryLocation, 'Expected link to fail')
|
||||
test.done()
|
||||
})
|
||||
}
|
||||
|
||||
exports.testSuccessfulReinstallLocation = function (test) {
|
||||
util.findValidPhantomJsBinary(path.resolve(__dirname, '../lib/location'))
|
||||
.then(function (binaryLocation) {
|
||||
test.ok(binaryLocation, 'Expected link to succeed')
|
||||
test.done()
|
||||
})
|
||||
}
|
||||
|
||||
exports.testBogusVerifyChecksum = function (test) {
|
||||
util.verifyChecksum(path.resolve(__dirname, './exit.js'), 'blargh')
|
||||
.then(function (success) {
|
||||
test.ok(!success, 'Expected checksum to fail')
|
||||
test.done()
|
||||
})
|
||||
}
|
||||
|
||||
exports.testSuccessfulVerifyChecksum = function (test) {
|
||||
util.verifyChecksum(path.resolve(__dirname, './exit.js'),
|
||||
'217b7bccebefe5f5e267162060660b03de577867b6123ecfd3b26b5c6af2e92b')
|
||||
.then(function (success) {
|
||||
test.ok(success, 'Expected checksum to succeed')
|
||||
test.done()
|
||||
})
|
||||
}
|
||||
|
||||
exports.testPhantomExec = function (test) {
|
||||
test.expect(1)
|
||||
var p = phantomjs.exec(path.join(__dirname, 'exit.js'))
|
||||
p.on('exit', function (code) {
|
||||
test.equals(code, 123, 'Exit code should be returned from phantom script')
|
||||
test.done()
|
||||
})
|
||||
}
|
||||
|
||||
exports.testPhantomRun = function (test) {
|
||||
test.expect(1)
|
||||
var wdOpts = { desiredCapabilities: { browserName: 'phantomjs' } }
|
||||
phantomjs.run('--webdriver=4444').then(function (p) {
|
||||
webdriverio.remote(wdOpts).init()
|
||||
.url('https://developer.mozilla.org/en-US/')
|
||||
.getTitle().then(function (title) {
|
||||
test.equals(title, 'Mozilla Developer Network', 'Page title')
|
||||
})
|
||||
.then(function () {
|
||||
p.kill()
|
||||
test.done()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
exports.testPhantomRunError = function (test) {
|
||||
test.expect(1)
|
||||
phantomjs.run('--bogus').then(function () {
|
||||
test.ok(false, 'Expected not to start')
|
||||
test.done()
|
||||
}, function (err) {
|
||||
test.equal('Error: Unknown option: bogus\n', err.message)
|
||||
test.done()
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user