dragonfly_chrome_headless 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.travis.yml +12 -0
- data/Gemfile +4 -0
- data/README.md +53 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/dragonfly_chrome_headless.gemspec +27 -0
- data/lib/dragonfly_chrome_headless.rb +9 -0
- data/lib/dragonfly_chrome_headless/plugin.rb +17 -0
- data/lib/dragonfly_chrome_headless/processors/rasterize.rb +33 -0
- data/lib/dragonfly_chrome_headless/version.rb +3 -0
- data/node_modules/.bin/chrome-remote-interface +1 -0
- data/node_modules/.bin/mkdirp +1 -0
- data/node_modules/.bin/rimraf +1 -0
- data/node_modules/@types/core-js/LICENSE +21 -0
- data/node_modules/@types/core-js/README.md +16 -0
- data/node_modules/@types/core-js/index.d.ts +2452 -0
- data/node_modules/@types/core-js/package.json +85 -0
- data/node_modules/@types/mkdirp/README.md +18 -0
- data/node_modules/@types/mkdirp/index.d.ts +14 -0
- data/node_modules/@types/mkdirp/package.json +77 -0
- data/node_modules/@types/mkdirp/types-metadata.json +25 -0
- data/node_modules/@types/node/README.md +16 -0
- data/node_modules/@types/node/index.d.ts +4132 -0
- data/node_modules/@types/node/package.json +84 -0
- data/node_modules/balanced-match/.npmignore +5 -0
- data/node_modules/balanced-match/LICENSE.md +21 -0
- data/node_modules/balanced-match/README.md +91 -0
- data/node_modules/balanced-match/index.js +59 -0
- data/node_modules/balanced-match/package.json +112 -0
- data/node_modules/brace-expansion/README.md +123 -0
- data/node_modules/brace-expansion/index.js +201 -0
- data/node_modules/brace-expansion/package.json +114 -0
- data/node_modules/chrome-launcher/.clang-format +6 -0
- data/node_modules/chrome-launcher/.npmignore +11 -0
- data/node_modules/chrome-launcher/README.md +123 -0
- data/node_modules/chrome-launcher/ask.js +32 -0
- data/node_modules/chrome-launcher/ask.ts +35 -0
- data/node_modules/chrome-launcher/chrome-finder.js +157 -0
- data/node_modules/chrome-launcher/chrome-finder.ts +186 -0
- data/node_modules/chrome-launcher/chrome-launcher.js +245 -0
- data/node_modules/chrome-launcher/chrome-launcher.ts +312 -0
- data/node_modules/chrome-launcher/compiled-check.js +14 -0
- data/node_modules/chrome-launcher/flags.js +27 -0
- data/node_modules/chrome-launcher/flags.ts +26 -0
- data/node_modules/chrome-launcher/index.js +7 -0
- data/node_modules/chrome-launcher/index.ts +1 -0
- data/node_modules/chrome-launcher/manual-chrome-launcher.js +30 -0
- data/node_modules/chrome-launcher/package.json +116 -0
- data/node_modules/chrome-launcher/random-port.js +24 -0
- data/node_modules/chrome-launcher/random-port.ts +23 -0
- data/node_modules/chrome-launcher/tsconfig.json +19 -0
- data/node_modules/chrome-launcher/utils.js +52 -0
- data/node_modules/chrome-launcher/utils.ts +44 -0
- data/node_modules/chrome-launcher/yarn.lock +1486 -0
- data/node_modules/chrome-remote-interface/LICENSE +18 -0
- data/node_modules/chrome-remote-interface/README.md +849 -0
- data/node_modules/chrome-remote-interface/bin/client.js +337 -0
- data/node_modules/chrome-remote-interface/chrome-remote-interface.js +11 -0
- data/node_modules/chrome-remote-interface/index.js +39 -0
- data/node_modules/chrome-remote-interface/lib/api.js +84 -0
- data/node_modules/chrome-remote-interface/lib/chrome.js +307 -0
- data/node_modules/chrome-remote-interface/lib/defaults.js +4 -0
- data/node_modules/chrome-remote-interface/lib/devtools.js +245 -0
- data/node_modules/chrome-remote-interface/lib/external-request.js +28 -0
- data/node_modules/chrome-remote-interface/lib/protocol.json +13780 -0
- data/node_modules/chrome-remote-interface/lib/websocket-wrapper.js +32 -0
- data/node_modules/chrome-remote-interface/package.json +128 -0
- data/node_modules/chrome-remote-interface/webpack.config.js +55 -0
- data/node_modules/commander/Readme.md +195 -0
- data/node_modules/commander/index.js +851 -0
- data/node_modules/commander/package.json +92 -0
- data/node_modules/concat-map/.travis.yml +4 -0
- data/node_modules/concat-map/LICENSE +18 -0
- data/node_modules/concat-map/README.markdown +62 -0
- data/node_modules/concat-map/example/map.js +6 -0
- data/node_modules/concat-map/index.js +13 -0
- data/node_modules/concat-map/package.json +117 -0
- data/node_modules/concat-map/test/map.js +39 -0
- data/node_modules/debug/.coveralls.yml +1 -0
- data/node_modules/debug/.eslintrc +11 -0
- data/node_modules/debug/.npmignore +9 -0
- data/node_modules/debug/.travis.yml +14 -0
- data/node_modules/debug/CHANGELOG.md +357 -0
- data/node_modules/debug/LICENSE +19 -0
- data/node_modules/debug/Makefile +50 -0
- data/node_modules/debug/Readme.md +312 -0
- data/node_modules/debug/component.json +19 -0
- data/node_modules/debug/karma.conf.js +70 -0
- data/node_modules/debug/node.js +1 -0
- data/node_modules/debug/package.json +124 -0
- data/node_modules/debug/src/browser.js +185 -0
- data/node_modules/debug/src/debug.js +202 -0
- data/node_modules/debug/src/index.js +10 -0
- data/node_modules/debug/src/node.js +246 -0
- data/node_modules/fs.realpath/LICENSE +43 -0
- data/node_modules/fs.realpath/README.md +33 -0
- data/node_modules/fs.realpath/index.js +66 -0
- data/node_modules/fs.realpath/old.js +303 -0
- data/node_modules/fs.realpath/package.json +94 -0
- data/node_modules/glob/LICENSE +15 -0
- data/node_modules/glob/README.md +368 -0
- data/node_modules/glob/changelog.md +67 -0
- data/node_modules/glob/common.js +240 -0
- data/node_modules/glob/glob.js +790 -0
- data/node_modules/glob/package.json +112 -0
- data/node_modules/glob/sync.js +486 -0
- data/node_modules/html-pdf-chrome/.npmignore +9 -0
- data/node_modules/html-pdf-chrome/LICENSE +21 -0
- data/node_modules/html-pdf-chrome/README.md +165 -0
- data/node_modules/html-pdf-chrome/lib/src/ChromePrintOptions.d.ts +87 -0
- data/node_modules/html-pdf-chrome/lib/src/ChromePrintOptions.js +4 -0
- data/node_modules/html-pdf-chrome/lib/src/ChromePrintOptions.js.map +1 -0
- data/node_modules/html-pdf-chrome/lib/src/CompletionTrigger.d.ts +120 -0
- data/node_modules/html-pdf-chrome/lib/src/CompletionTrigger.js +206 -0
- data/node_modules/html-pdf-chrome/lib/src/CompletionTrigger.js.map +1 -0
- data/node_modules/html-pdf-chrome/lib/src/CreateResult.d.ts +70 -0
- data/node_modules/html-pdf-chrome/lib/src/CreateResult.js +98 -0
- data/node_modules/html-pdf-chrome/lib/src/CreateResult.js.map +1 -0
- data/node_modules/html-pdf-chrome/lib/src/index.d.ts +72 -0
- data/node_modules/html-pdf-chrome/lib/src/index.js +123 -0
- data/node_modules/html-pdf-chrome/lib/src/index.js.map +1 -0
- data/node_modules/html-pdf-chrome/package.json +133 -0
- data/node_modules/html-pdf-chrome/src/ChromePrintOptions.ts +99 -0
- data/node_modules/html-pdf-chrome/src/CompletionTrigger.ts +201 -0
- data/node_modules/html-pdf-chrome/src/CreateResult.ts +100 -0
- data/node_modules/html-pdf-chrome/src/index.ts +179 -0
- data/node_modules/inflight/LICENSE +15 -0
- data/node_modules/inflight/README.md +37 -0
- data/node_modules/inflight/inflight.js +54 -0
- data/node_modules/inflight/package.json +105 -0
- data/node_modules/inherits/LICENSE +16 -0
- data/node_modules/inherits/README.md +42 -0
- data/node_modules/inherits/inherits.js +7 -0
- data/node_modules/inherits/inherits_browser.js +23 -0
- data/node_modules/inherits/package.json +97 -0
- data/node_modules/lighthouse-logger/README.md +4 -0
- data/node_modules/lighthouse-logger/index.js +212 -0
- data/node_modules/lighthouse-logger/package.json +69 -0
- data/node_modules/lighthouse-logger/yarn.lock +13 -0
- data/node_modules/minimatch/LICENSE +15 -0
- data/node_modules/minimatch/README.md +209 -0
- data/node_modules/minimatch/minimatch.js +923 -0
- data/node_modules/minimatch/package.json +99 -0
- data/node_modules/minimist/.travis.yml +4 -0
- data/node_modules/minimist/LICENSE +18 -0
- data/node_modules/minimist/example/parse.js +2 -0
- data/node_modules/minimist/index.js +187 -0
- data/node_modules/minimist/package.json +101 -0
- data/node_modules/minimist/readme.markdown +73 -0
- data/node_modules/minimist/test/dash.js +24 -0
- data/node_modules/minimist/test/default_bool.js +20 -0
- data/node_modules/minimist/test/dotted.js +16 -0
- data/node_modules/minimist/test/long.js +31 -0
- data/node_modules/minimist/test/parse.js +318 -0
- data/node_modules/minimist/test/parse_modified.js +9 -0
- data/node_modules/minimist/test/short.js +67 -0
- data/node_modules/minimist/test/whitespace.js +8 -0
- data/node_modules/mkdirp/.travis.yml +8 -0
- data/node_modules/mkdirp/LICENSE +21 -0
- data/node_modules/mkdirp/bin/cmd.js +33 -0
- data/node_modules/mkdirp/bin/usage.txt +12 -0
- data/node_modules/mkdirp/examples/pow.js +6 -0
- data/node_modules/mkdirp/index.js +98 -0
- data/node_modules/mkdirp/package.json +93 -0
- data/node_modules/mkdirp/readme.markdown +100 -0
- data/node_modules/mkdirp/test/chmod.js +41 -0
- data/node_modules/mkdirp/test/clobber.js +38 -0
- data/node_modules/mkdirp/test/mkdirp.js +28 -0
- data/node_modules/mkdirp/test/opts_fs.js +29 -0
- data/node_modules/mkdirp/test/opts_fs_sync.js +27 -0
- data/node_modules/mkdirp/test/perm.js +32 -0
- data/node_modules/mkdirp/test/perm_sync.js +36 -0
- data/node_modules/mkdirp/test/race.js +37 -0
- data/node_modules/mkdirp/test/rel.js +32 -0
- data/node_modules/mkdirp/test/return.js +25 -0
- data/node_modules/mkdirp/test/return_sync.js +24 -0
- data/node_modules/mkdirp/test/root.js +19 -0
- data/node_modules/mkdirp/test/sync.js +32 -0
- data/node_modules/mkdirp/test/umask.js +28 -0
- data/node_modules/mkdirp/test/umask_sync.js +32 -0
- data/node_modules/ms/README.md +51 -0
- data/node_modules/ms/index.js +152 -0
- data/node_modules/ms/license.md +21 -0
- data/node_modules/ms/package.json +109 -0
- data/node_modules/once/LICENSE +15 -0
- data/node_modules/once/README.md +79 -0
- data/node_modules/once/once.js +42 -0
- data/node_modules/once/package.json +101 -0
- data/node_modules/path-is-absolute/index.js +20 -0
- data/node_modules/path-is-absolute/license +21 -0
- data/node_modules/path-is-absolute/package.json +111 -0
- data/node_modules/path-is-absolute/readme.md +59 -0
- data/node_modules/rimraf/LICENSE +15 -0
- data/node_modules/rimraf/README.md +101 -0
- data/node_modules/rimraf/bin.js +50 -0
- data/node_modules/rimraf/package.json +99 -0
- data/node_modules/rimraf/rimraf.js +363 -0
- data/node_modules/ultron/LICENSE +22 -0
- data/node_modules/ultron/index.js +138 -0
- data/node_modules/ultron/package.json +112 -0
- data/node_modules/wrappy/LICENSE +15 -0
- data/node_modules/wrappy/README.md +36 -0
- data/node_modules/wrappy/package.json +97 -0
- data/node_modules/wrappy/wrappy.js +33 -0
- data/node_modules/ws/LICENSE +21 -0
- data/node_modules/ws/README.md +259 -0
- data/node_modules/ws/SECURITY.md +33 -0
- data/node_modules/ws/index.js +15 -0
- data/node_modules/ws/lib/BufferUtil.fallback.js +56 -0
- data/node_modules/ws/lib/BufferUtil.js +15 -0
- data/node_modules/ws/lib/ErrorCodes.js +28 -0
- data/node_modules/ws/lib/EventTarget.js +158 -0
- data/node_modules/ws/lib/Extensions.js +69 -0
- data/node_modules/ws/lib/PerMessageDeflate.js +339 -0
- data/node_modules/ws/lib/Receiver.js +520 -0
- data/node_modules/ws/lib/Sender.js +438 -0
- data/node_modules/ws/lib/Validation.fallback.js +9 -0
- data/node_modules/ws/lib/Validation.js +17 -0
- data/node_modules/ws/lib/WebSocket.js +705 -0
- data/node_modules/ws/lib/WebSocketServer.js +336 -0
- data/node_modules/ws/package.json +122 -0
- data/package.json +26 -0
- data/samples/sample.html +13 -0
- data/script/rasterize.js +18 -0
- metadata +325 -0
@@ -0,0 +1,112 @@
|
|
1
|
+
{
|
2
|
+
"_args": [
|
3
|
+
[
|
4
|
+
{
|
5
|
+
"raw": "ultron@~1.1.0",
|
6
|
+
"scope": null,
|
7
|
+
"escapedName": "ultron",
|
8
|
+
"name": "ultron",
|
9
|
+
"rawSpec": "~1.1.0",
|
10
|
+
"spec": ">=1.1.0 <1.2.0",
|
11
|
+
"type": "range"
|
12
|
+
},
|
13
|
+
"/Users/tomascelizna/Devel/dragonfly_chrome_headless/node_modules/ws"
|
14
|
+
]
|
15
|
+
],
|
16
|
+
"_from": "ultron@>=1.1.0 <1.2.0",
|
17
|
+
"_id": "ultron@1.1.0",
|
18
|
+
"_inCache": true,
|
19
|
+
"_location": "/ultron",
|
20
|
+
"_nodeVersion": "6.2.1",
|
21
|
+
"_npmOperationalInternal": {
|
22
|
+
"host": "packages-12-west.internal.npmjs.com",
|
23
|
+
"tmp": "tmp/ultron-1.1.0.tgz_1483969751660_0.8877595944795758"
|
24
|
+
},
|
25
|
+
"_npmUser": {
|
26
|
+
"name": "3rdeden",
|
27
|
+
"email": "npm@3rd-Eden.com"
|
28
|
+
},
|
29
|
+
"_npmVersion": "3.9.3",
|
30
|
+
"_phantomChildren": {},
|
31
|
+
"_requested": {
|
32
|
+
"raw": "ultron@~1.1.0",
|
33
|
+
"scope": null,
|
34
|
+
"escapedName": "ultron",
|
35
|
+
"name": "ultron",
|
36
|
+
"rawSpec": "~1.1.0",
|
37
|
+
"spec": ">=1.1.0 <1.2.0",
|
38
|
+
"type": "range"
|
39
|
+
},
|
40
|
+
"_requiredBy": [
|
41
|
+
"/ws"
|
42
|
+
],
|
43
|
+
"_resolved": "https://registry.npmjs.org/ultron/-/ultron-1.1.0.tgz",
|
44
|
+
"_shasum": "b07a2e6a541a815fc6a34ccd4533baec307ca864",
|
45
|
+
"_shrinkwrap": null,
|
46
|
+
"_spec": "ultron@~1.1.0",
|
47
|
+
"_where": "/Users/tomascelizna/Devel/dragonfly_chrome_headless/node_modules/ws",
|
48
|
+
"author": {
|
49
|
+
"name": "Arnout Kazemier"
|
50
|
+
},
|
51
|
+
"bugs": {
|
52
|
+
"url": "https://github.com/unshiftio/ultron/issues"
|
53
|
+
},
|
54
|
+
"dependencies": {},
|
55
|
+
"description": "Ultron is high-intelligence robot. It gathers intel so it can start improving upon his rudimentary design",
|
56
|
+
"devDependencies": {
|
57
|
+
"assume": "1.4.x",
|
58
|
+
"eventemitter3": "2.0.x",
|
59
|
+
"istanbul": "0.4.x",
|
60
|
+
"mocha": "~3.2.0",
|
61
|
+
"pre-commit": "~1.2.0"
|
62
|
+
},
|
63
|
+
"directories": {},
|
64
|
+
"dist": {
|
65
|
+
"shasum": "b07a2e6a541a815fc6a34ccd4533baec307ca864",
|
66
|
+
"tarball": "https://registry.npmjs.org/ultron/-/ultron-1.1.0.tgz"
|
67
|
+
},
|
68
|
+
"gitHead": "6eb97b74402978aebda4a9d497cb6243ec80c9f1",
|
69
|
+
"homepage": "https://github.com/unshiftio/ultron",
|
70
|
+
"keywords": [
|
71
|
+
"Ultron",
|
72
|
+
"robot",
|
73
|
+
"gather",
|
74
|
+
"intelligence",
|
75
|
+
"event",
|
76
|
+
"events",
|
77
|
+
"eventemitter",
|
78
|
+
"emitter",
|
79
|
+
"cleanup"
|
80
|
+
],
|
81
|
+
"license": "MIT",
|
82
|
+
"main": "index.js",
|
83
|
+
"maintainers": [
|
84
|
+
{
|
85
|
+
"name": "unshift",
|
86
|
+
"email": "npm@unshift.io"
|
87
|
+
},
|
88
|
+
{
|
89
|
+
"name": "v1",
|
90
|
+
"email": "info@3rd-Eden.com"
|
91
|
+
},
|
92
|
+
{
|
93
|
+
"name": "3rdeden",
|
94
|
+
"email": "npm@3rd-Eden.com"
|
95
|
+
}
|
96
|
+
],
|
97
|
+
"name": "ultron",
|
98
|
+
"optionalDependencies": {},
|
99
|
+
"readme": "ERROR: No README data found!",
|
100
|
+
"repository": {
|
101
|
+
"type": "git",
|
102
|
+
"url": "git+https://github.com/unshiftio/ultron.git"
|
103
|
+
},
|
104
|
+
"scripts": {
|
105
|
+
"100%": "istanbul check-coverage --statements 100 --functions 100 --lines 100 --branches 100",
|
106
|
+
"coverage": "istanbul cover _mocha -- test.js",
|
107
|
+
"test": "mocha test.js",
|
108
|
+
"test-travis": "istanbul cover _mocha --report lcovonly -- test.js",
|
109
|
+
"watch": "mocha --watch test.js"
|
110
|
+
},
|
111
|
+
"version": "1.1.0"
|
112
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
The ISC License
|
2
|
+
|
3
|
+
Copyright (c) Isaac Z. Schlueter and Contributors
|
4
|
+
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
8
|
+
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
15
|
+
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# wrappy
|
2
|
+
|
3
|
+
Callback wrapping utility
|
4
|
+
|
5
|
+
## USAGE
|
6
|
+
|
7
|
+
```javascript
|
8
|
+
var wrappy = require("wrappy")
|
9
|
+
|
10
|
+
// var wrapper = wrappy(wrapperFunction)
|
11
|
+
|
12
|
+
// make sure a cb is called only once
|
13
|
+
// See also: http://npm.im/once for this specific use case
|
14
|
+
var once = wrappy(function (cb) {
|
15
|
+
var called = false
|
16
|
+
return function () {
|
17
|
+
if (called) return
|
18
|
+
called = true
|
19
|
+
return cb.apply(this, arguments)
|
20
|
+
}
|
21
|
+
})
|
22
|
+
|
23
|
+
function printBoo () {
|
24
|
+
console.log('boo')
|
25
|
+
}
|
26
|
+
// has some rando property
|
27
|
+
printBoo.iAmBooPrinter = true
|
28
|
+
|
29
|
+
var onlyPrintOnce = once(printBoo)
|
30
|
+
|
31
|
+
onlyPrintOnce() // prints 'boo'
|
32
|
+
onlyPrintOnce() // does nothing
|
33
|
+
|
34
|
+
// random property is retained!
|
35
|
+
assert.equal(onlyPrintOnce.iAmBooPrinter, true)
|
36
|
+
```
|
@@ -0,0 +1,97 @@
|
|
1
|
+
{
|
2
|
+
"_args": [
|
3
|
+
[
|
4
|
+
{
|
5
|
+
"raw": "wrappy@1",
|
6
|
+
"scope": null,
|
7
|
+
"escapedName": "wrappy",
|
8
|
+
"name": "wrappy",
|
9
|
+
"rawSpec": "1",
|
10
|
+
"spec": ">=1.0.0 <2.0.0",
|
11
|
+
"type": "range"
|
12
|
+
},
|
13
|
+
"/Users/tomascelizna/Devel/dragonfly_chrome_headless/node_modules/inflight"
|
14
|
+
]
|
15
|
+
],
|
16
|
+
"_from": "wrappy@>=1.0.0 <2.0.0",
|
17
|
+
"_id": "wrappy@1.0.2",
|
18
|
+
"_inCache": true,
|
19
|
+
"_location": "/wrappy",
|
20
|
+
"_nodeVersion": "5.10.1",
|
21
|
+
"_npmOperationalInternal": {
|
22
|
+
"host": "packages-16-east.internal.npmjs.com",
|
23
|
+
"tmp": "tmp/wrappy-1.0.2.tgz_1463527848281_0.037129373755306005"
|
24
|
+
},
|
25
|
+
"_npmUser": {
|
26
|
+
"name": "zkat",
|
27
|
+
"email": "kat@sykosomatic.org"
|
28
|
+
},
|
29
|
+
"_npmVersion": "3.9.1",
|
30
|
+
"_phantomChildren": {},
|
31
|
+
"_requested": {
|
32
|
+
"raw": "wrappy@1",
|
33
|
+
"scope": null,
|
34
|
+
"escapedName": "wrappy",
|
35
|
+
"name": "wrappy",
|
36
|
+
"rawSpec": "1",
|
37
|
+
"spec": ">=1.0.0 <2.0.0",
|
38
|
+
"type": "range"
|
39
|
+
},
|
40
|
+
"_requiredBy": [
|
41
|
+
"/inflight",
|
42
|
+
"/once"
|
43
|
+
],
|
44
|
+
"_resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
45
|
+
"_shasum": "b5243d8f3ec1aa35f1364605bc0d1036e30ab69f",
|
46
|
+
"_shrinkwrap": null,
|
47
|
+
"_spec": "wrappy@1",
|
48
|
+
"_where": "/Users/tomascelizna/Devel/dragonfly_chrome_headless/node_modules/inflight",
|
49
|
+
"author": {
|
50
|
+
"name": "Isaac Z. Schlueter",
|
51
|
+
"email": "i@izs.me",
|
52
|
+
"url": "http://blog.izs.me/"
|
53
|
+
},
|
54
|
+
"bugs": {
|
55
|
+
"url": "https://github.com/npm/wrappy/issues"
|
56
|
+
},
|
57
|
+
"dependencies": {},
|
58
|
+
"description": "Callback wrapping utility",
|
59
|
+
"devDependencies": {
|
60
|
+
"tap": "^2.3.1"
|
61
|
+
},
|
62
|
+
"directories": {
|
63
|
+
"test": "test"
|
64
|
+
},
|
65
|
+
"dist": {
|
66
|
+
"shasum": "b5243d8f3ec1aa35f1364605bc0d1036e30ab69f",
|
67
|
+
"tarball": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz"
|
68
|
+
},
|
69
|
+
"files": [
|
70
|
+
"wrappy.js"
|
71
|
+
],
|
72
|
+
"gitHead": "71d91b6dc5bdeac37e218c2cf03f9ab55b60d214",
|
73
|
+
"homepage": "https://github.com/npm/wrappy",
|
74
|
+
"license": "ISC",
|
75
|
+
"main": "wrappy.js",
|
76
|
+
"maintainers": [
|
77
|
+
{
|
78
|
+
"name": "isaacs",
|
79
|
+
"email": "i@izs.me"
|
80
|
+
},
|
81
|
+
{
|
82
|
+
"name": "zkat",
|
83
|
+
"email": "kat@sykosomatic.org"
|
84
|
+
}
|
85
|
+
],
|
86
|
+
"name": "wrappy",
|
87
|
+
"optionalDependencies": {},
|
88
|
+
"readme": "ERROR: No README data found!",
|
89
|
+
"repository": {
|
90
|
+
"type": "git",
|
91
|
+
"url": "git+https://github.com/npm/wrappy.git"
|
92
|
+
},
|
93
|
+
"scripts": {
|
94
|
+
"test": "tap --coverage test/*.js"
|
95
|
+
},
|
96
|
+
"version": "1.0.2"
|
97
|
+
}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
// Returns a wrapper function that returns a wrapped callback
|
2
|
+
// The wrapper function should do some stuff, and return a
|
3
|
+
// presumably different callback function.
|
4
|
+
// This makes sure that own properties are retained, so that
|
5
|
+
// decorations and such are not lost along the way.
|
6
|
+
module.exports = wrappy
|
7
|
+
function wrappy (fn, cb) {
|
8
|
+
if (fn && cb) return wrappy(fn)(cb)
|
9
|
+
|
10
|
+
if (typeof fn !== 'function')
|
11
|
+
throw new TypeError('need wrapper function')
|
12
|
+
|
13
|
+
Object.keys(fn).forEach(function (k) {
|
14
|
+
wrapper[k] = fn[k]
|
15
|
+
})
|
16
|
+
|
17
|
+
return wrapper
|
18
|
+
|
19
|
+
function wrapper() {
|
20
|
+
var args = new Array(arguments.length)
|
21
|
+
for (var i = 0; i < args.length; i++) {
|
22
|
+
args[i] = arguments[i]
|
23
|
+
}
|
24
|
+
var ret = fn.apply(this, args)
|
25
|
+
var cb = args[args.length-1]
|
26
|
+
if (typeof ret === 'function' && ret !== cb) {
|
27
|
+
Object.keys(cb).forEach(function (k) {
|
28
|
+
ret[k] = cb[k]
|
29
|
+
})
|
30
|
+
}
|
31
|
+
return ret
|
32
|
+
}
|
33
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2011 Einar Otto Stangvik <einaros@gmail.com>
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
@@ -0,0 +1,259 @@
|
|
1
|
+
# ws: a Node.js WebSocket library
|
2
|
+
|
3
|
+
[](https://www.npmjs.com/package/ws)
|
4
|
+
[](https://travis-ci.org/websockets/ws)
|
5
|
+
[](https://ci.appveyor.com/project/lpinca/ws)
|
6
|
+
[](https://coveralls.io/r/websockets/ws?branch=master)
|
7
|
+
|
8
|
+
`ws` is a simple to use, blazing fast, and thoroughly tested WebSocket client
|
9
|
+
and server implementation.
|
10
|
+
|
11
|
+
Passes the quite extensive Autobahn test suite. See http://websockets.github.io/ws/
|
12
|
+
for the full reports.
|
13
|
+
|
14
|
+
## Protocol support
|
15
|
+
|
16
|
+
* **HyBi drafts 07-12** (Use the option `protocolVersion: 8`)
|
17
|
+
* **HyBi drafts 13-17** (Current default, alternatively option `protocolVersion: 13`)
|
18
|
+
|
19
|
+
## Installing
|
20
|
+
|
21
|
+
```
|
22
|
+
npm install --save ws
|
23
|
+
```
|
24
|
+
|
25
|
+
### Opt-in for performance
|
26
|
+
|
27
|
+
There are 2 optional modules that can be installed along side with the `ws`
|
28
|
+
module. These modules are binary addons which improve certain operations, but as
|
29
|
+
they are binary addons they require compilation which can fail if no c++
|
30
|
+
compiler is installed on the host system.
|
31
|
+
|
32
|
+
- `npm install --save bufferutil`: Improves internal buffer operations which
|
33
|
+
allows for faster processing of masked WebSocket frames and general buffer
|
34
|
+
operations.
|
35
|
+
- `npm install --save utf-8-validate`: The specification requires validation of
|
36
|
+
invalid UTF-8 chars, some of these validations could not be done in JavaScript
|
37
|
+
hence the need for a binary addon. In most cases you will already be
|
38
|
+
validating the input that you receive for security purposes leading to double
|
39
|
+
validation. But if you want to be 100% spec-conforming and have fast
|
40
|
+
validation of UTF-8 then this module is a must.
|
41
|
+
|
42
|
+
## API Docs
|
43
|
+
|
44
|
+
See [`/doc/ws.md`](https://github.com/websockets/ws/blob/master/doc/ws.md)
|
45
|
+
for Node.js-like docs for the ws classes.
|
46
|
+
|
47
|
+
## WebSocket compression
|
48
|
+
|
49
|
+
`ws` supports the [permessage-deflate extension][permessage-deflate] extension
|
50
|
+
which enables the client and server to negotiate a compression algorithm and
|
51
|
+
its parameters, and then selectively apply it to the data payloads of each
|
52
|
+
WebSocket message.
|
53
|
+
|
54
|
+
The extension is enabled by default but adds a significant overhead in terms of
|
55
|
+
performance and memory comsumption. We suggest to use WebSocket compression
|
56
|
+
only if it is really needed.
|
57
|
+
|
58
|
+
To disable the extension you can set the `perMessageDeflate` option to `false`.
|
59
|
+
On the server:
|
60
|
+
|
61
|
+
```js
|
62
|
+
const WebSocket = require('ws');
|
63
|
+
|
64
|
+
const wss = new WebSocket.Server({
|
65
|
+
perMessageDeflate: false,
|
66
|
+
port: 8080
|
67
|
+
});
|
68
|
+
```
|
69
|
+
|
70
|
+
On the client:
|
71
|
+
|
72
|
+
```js
|
73
|
+
const WebSocket = require('ws');
|
74
|
+
|
75
|
+
const ws = new WebSocket('ws://www.host.com/path', {
|
76
|
+
perMessageDeflate: false
|
77
|
+
});
|
78
|
+
```
|
79
|
+
|
80
|
+
## Usage examples
|
81
|
+
|
82
|
+
### Sending and receiving text data
|
83
|
+
|
84
|
+
```js
|
85
|
+
const WebSocket = require('ws');
|
86
|
+
|
87
|
+
const ws = new WebSocket('ws://www.host.com/path');
|
88
|
+
|
89
|
+
ws.on('open', function open() {
|
90
|
+
ws.send('something');
|
91
|
+
});
|
92
|
+
|
93
|
+
ws.on('message', function incoming(data, flags) {
|
94
|
+
// flags.binary will be set if a binary data is received.
|
95
|
+
// flags.masked will be set if the data was masked.
|
96
|
+
});
|
97
|
+
```
|
98
|
+
|
99
|
+
### Sending binary data
|
100
|
+
|
101
|
+
```js
|
102
|
+
const WebSocket = require('ws');
|
103
|
+
|
104
|
+
const ws = new WebSocket('ws://www.host.com/path');
|
105
|
+
|
106
|
+
ws.on('open', function open() {
|
107
|
+
const array = new Float32Array(5);
|
108
|
+
|
109
|
+
for (var i = 0; i < array.length; ++i) {
|
110
|
+
array[i] = i / 2;
|
111
|
+
}
|
112
|
+
|
113
|
+
ws.send(array);
|
114
|
+
});
|
115
|
+
```
|
116
|
+
|
117
|
+
### Server example
|
118
|
+
|
119
|
+
```js
|
120
|
+
const WebSocket = require('ws');
|
121
|
+
|
122
|
+
const wss = new WebSocket.Server({ port: 8080 });
|
123
|
+
|
124
|
+
wss.on('connection', function connection(ws) {
|
125
|
+
ws.on('message', function incoming(message) {
|
126
|
+
console.log('received: %s', message);
|
127
|
+
});
|
128
|
+
|
129
|
+
ws.send('something');
|
130
|
+
});
|
131
|
+
```
|
132
|
+
|
133
|
+
### Broadcast example
|
134
|
+
|
135
|
+
```js
|
136
|
+
const WebSocket = require('ws');
|
137
|
+
|
138
|
+
const wss = new WebSocket.Server({ port: 8080 });
|
139
|
+
|
140
|
+
// Broadcast to all.
|
141
|
+
wss.broadcast = function broadcast(data) {
|
142
|
+
wss.clients.forEach(function each(client) {
|
143
|
+
if (client.readyState === WebSocket.OPEN) {
|
144
|
+
client.send(data);
|
145
|
+
}
|
146
|
+
});
|
147
|
+
};
|
148
|
+
|
149
|
+
wss.on('connection', function connection(ws) {
|
150
|
+
ws.on('message', function incoming(data) {
|
151
|
+
// Broadcast to everyone else.
|
152
|
+
wss.clients.forEach(function each(client) {
|
153
|
+
if (client !== ws && client.readyState === WebSocket.OPEN) {
|
154
|
+
client.send(data);
|
155
|
+
}
|
156
|
+
});
|
157
|
+
});
|
158
|
+
});
|
159
|
+
```
|
160
|
+
|
161
|
+
### ExpressJS example
|
162
|
+
|
163
|
+
```js
|
164
|
+
const express = require('express');
|
165
|
+
const http = require('http');
|
166
|
+
const url = require('url');
|
167
|
+
const WebSocket = require('ws');
|
168
|
+
|
169
|
+
const app = express();
|
170
|
+
|
171
|
+
app.use(function (req, res) {
|
172
|
+
res.send({ msg: "hello" });
|
173
|
+
});
|
174
|
+
|
175
|
+
const server = http.createServer(app);
|
176
|
+
const wss = new WebSocket.Server({ server });
|
177
|
+
|
178
|
+
wss.on('connection', function connection(ws) {
|
179
|
+
const location = url.parse(ws.upgradeReq.url, true);
|
180
|
+
// You might use location.query.access_token to authenticate or share sessions
|
181
|
+
// or ws.upgradeReq.headers.cookie (see http://stackoverflow.com/a/16395220/151312)
|
182
|
+
|
183
|
+
ws.on('message', function incoming(message) {
|
184
|
+
console.log('received: %s', message);
|
185
|
+
});
|
186
|
+
|
187
|
+
ws.send('something');
|
188
|
+
});
|
189
|
+
|
190
|
+
server.listen(8080, function listening() {
|
191
|
+
console.log('Listening on %d', server.address().port);
|
192
|
+
});
|
193
|
+
```
|
194
|
+
|
195
|
+
### echo.websocket.org demo
|
196
|
+
|
197
|
+
```js
|
198
|
+
const WebSocket = require('ws');
|
199
|
+
|
200
|
+
const ws = new WebSocket('wss://echo.websocket.org/', {
|
201
|
+
origin: 'https://websocket.org'
|
202
|
+
});
|
203
|
+
|
204
|
+
ws.on('open', function open() {
|
205
|
+
console.log('connected');
|
206
|
+
ws.send(Date.now());
|
207
|
+
});
|
208
|
+
|
209
|
+
ws.on('close', function close() {
|
210
|
+
console.log('disconnected');
|
211
|
+
});
|
212
|
+
|
213
|
+
ws.on('message', function incoming(data, flags) {
|
214
|
+
console.log(`Roundtrip time: ${Date.now() - data} ms`, flags);
|
215
|
+
|
216
|
+
setTimeout(function timeout() {
|
217
|
+
ws.send(Date.now());
|
218
|
+
}, 500);
|
219
|
+
});
|
220
|
+
```
|
221
|
+
|
222
|
+
### Other examples
|
223
|
+
|
224
|
+
For a full example with a browser client communicating with a ws server, see the
|
225
|
+
examples folder.
|
226
|
+
|
227
|
+
Otherwise, see the test cases.
|
228
|
+
|
229
|
+
## Error handling best practices
|
230
|
+
|
231
|
+
```js
|
232
|
+
// If the WebSocket is closed before the following send is attempted
|
233
|
+
ws.send('something');
|
234
|
+
|
235
|
+
// Errors (both immediate and async write errors) can be detected in an optional
|
236
|
+
// callback. The callback is also the only way of being notified that data has
|
237
|
+
// actually been sent.
|
238
|
+
ws.send('something', function ack(error) {
|
239
|
+
// If error is not defined, the send has been completed, otherwise the error
|
240
|
+
// object will indicate what failed.
|
241
|
+
});
|
242
|
+
|
243
|
+
// Immediate errors can also be handled with `try...catch`, but **note** that
|
244
|
+
// since sends are inherently asynchronous, socket write failures will *not* be
|
245
|
+
// captured when this technique is used.
|
246
|
+
try { ws.send('something'); }
|
247
|
+
catch (e) { /* handle error */ }
|
248
|
+
```
|
249
|
+
|
250
|
+
## Changelog
|
251
|
+
|
252
|
+
We're using the GitHub [`releases`](https://github.com/websockets/ws/releases)
|
253
|
+
for changelog entries.
|
254
|
+
|
255
|
+
## License
|
256
|
+
|
257
|
+
[MIT](LICENSE)
|
258
|
+
|
259
|
+
[permessage-deflate]: https://tools.ietf.org/html/rfc7692
|