Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- worker/node_modules/blake3-wasm/LICENSE +21 -0
- worker/node_modules/blake3-wasm/benchmark.js +22 -0
- worker/node_modules/blake3-wasm/browser.js +6 -0
- worker/node_modules/blake3-wasm/changelog.md +60 -0
- worker/node_modules/blake3-wasm/package.json +63 -0
- worker/node_modules/blake3-wasm/readme.md +406 -0
- worker/node_modules/blake3-wasm/targets.json +1 -0
- worker/node_modules/color-convert/CHANGELOG.md +54 -0
- worker/node_modules/color-convert/LICENSE +21 -0
- worker/node_modules/color-convert/README.md +68 -0
- worker/node_modules/color-convert/conversions.js +839 -0
- worker/node_modules/color-convert/index.js +81 -0
- worker/node_modules/color-convert/package.json +48 -0
- worker/node_modules/color-convert/route.js +97 -0
- worker/node_modules/color-name/LICENSE +8 -0
- worker/node_modules/color-name/README.md +11 -0
- worker/node_modules/color-name/index.js +152 -0
- worker/node_modules/color-name/package.json +28 -0
- worker/node_modules/color-string/LICENSE +21 -0
- worker/node_modules/color-string/README.md +62 -0
- worker/node_modules/color-string/index.js +242 -0
- worker/node_modules/color-string/package.json +39 -0
- worker/node_modules/color/LICENSE +21 -0
- worker/node_modules/color/README.md +123 -0
- worker/node_modules/color/index.js +496 -0
- worker/node_modules/color/package.json +47 -0
- worker/node_modules/cookie/LICENSE +24 -0
- worker/node_modules/cookie/README.md +317 -0
- worker/node_modules/cookie/SECURITY.md +25 -0
- worker/node_modules/cookie/index.js +335 -0
- worker/node_modules/cookie/package.json +44 -0
- worker/node_modules/data-uri-to-buffer/.travis.yml +25 -0
- worker/node_modules/data-uri-to-buffer/History.md +55 -0
- worker/node_modules/data-uri-to-buffer/README.md +88 -0
- worker/node_modules/data-uri-to-buffer/index.d.ts +10 -0
- worker/node_modules/data-uri-to-buffer/index.js +70 -0
- worker/node_modules/data-uri-to-buffer/package.json +34 -0
- worker/node_modules/defu/LICENSE +21 -0
- worker/node_modules/defu/README.md +171 -0
- worker/node_modules/defu/package.json +43 -0
- worker/node_modules/detect-libc/LICENSE +201 -0
- worker/node_modules/detect-libc/README.md +163 -0
- worker/node_modules/detect-libc/index.d.ts +14 -0
- worker/node_modules/detect-libc/package.json +44 -0
- worker/node_modules/esbuild/LICENSE.md +21 -0
- worker/node_modules/esbuild/README.md +3 -0
- worker/node_modules/esbuild/install.js +287 -0
- worker/node_modules/esbuild/package.json +42 -0
- worker/node_modules/escape-string-regexp/index.d.ts +18 -0
- worker/node_modules/escape-string-regexp/index.js +13 -0
worker/node_modules/blake3-wasm/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2019 Connor Peet
|
| 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.
|
worker/node_modules/blake3-wasm/benchmark.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const { hash: hashWasm } = require('./dist/node');
|
| 2 |
+
const { hash: hashNative } = require('./dist/node-native');
|
| 3 |
+
const { createHash } = require('crypto');
|
| 4 |
+
|
| 5 |
+
[
|
| 6 |
+
{ size: '64B', data: Buffer.alloc(64) },
|
| 7 |
+
{ size: '64KB', data: Buffer.alloc(1024 * 64) },
|
| 8 |
+
{ size: '6MB', data: Buffer.alloc(1024 * 1024 * 6) },
|
| 9 |
+
].forEach(({ size, data }) =>
|
| 10 |
+
suite(size, () => {
|
| 11 |
+
['md5', 'sha1', 'sha256'].forEach(alg =>
|
| 12 |
+
bench(alg, () =>
|
| 13 |
+
createHash(alg)
|
| 14 |
+
.update(data)
|
| 15 |
+
.digest(),
|
| 16 |
+
),
|
| 17 |
+
);
|
| 18 |
+
|
| 19 |
+
bench('blake3 wasm', () => hashWasm(data));
|
| 20 |
+
bench('blake3 native', () => hashNative(data));
|
| 21 |
+
}),
|
| 22 |
+
);
|
worker/node_modules/blake3-wasm/browser.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { provideWasm } from './esm/browser/wasm';
|
| 2 |
+
import * as wasm from './dist/wasm/browser';
|
| 3 |
+
|
| 4 |
+
provideWasm(wasm);
|
| 5 |
+
|
| 6 |
+
export * from './esm/browser';
|
worker/node_modules/blake3-wasm/changelog.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Changelog
|
| 2 |
+
|
| 3 |
+
## 2.1.5 - 2020-11-28
|
| 4 |
+
|
| 5 |
+
- fix version matching on postinstall
|
| 6 |
+
- build for node 15
|
| 7 |
+
|
| 8 |
+
## 2.1.4 - 2020-05-11
|
| 9 |
+
|
| 10 |
+
- add support for Node 14
|
| 11 |
+
- validate native bindings before switching to them
|
| 12 |
+
|
| 13 |
+
## 2.1.3 - 2020-03-06
|
| 14 |
+
|
| 15 |
+
- update to BLAKE3@0.2, providing significant speed improvements for native Node
|
| 16 |
+
- fixed missing file causing installation of native Node extensions to fail
|
| 17 |
+
|
| 18 |
+
## 2.1.2 - 2020-03-01
|
| 19 |
+
|
| 20 |
+
- fix missing createKeyed function in browsers
|
| 21 |
+
|
| 22 |
+
## 2.1.1 - 2020-02-11
|
| 23 |
+
|
| 24 |
+
- allow importing the module without a bundler or with tools like Parcel
|
| 25 |
+
|
| 26 |
+
## 2.1.0 - 2020-01-23
|
| 27 |
+
|
| 28 |
+
- add keyed hash and key derivation support (fixes [#2](https://github.com/connor4312/blake3/issues/2), [#9](https://github.com/connor4312/blake3/issues/9))
|
| 29 |
+
- fixed a bug in hex encoding in the browser
|
| 30 |
+
|
| 31 |
+
## 2.0.1 - 2020-01-23
|
| 32 |
+
|
| 33 |
+
- fix browser bundle to use pure es modules (fixes [#8](https://github.com/connor4312/blake3/issues/8))
|
| 34 |
+
|
| 35 |
+
## 2.0.0 - 2020-01-19
|
| 36 |
+
|
| 37 |
+
- **breaking** the simple `hash` function no longer takes an encoding in its second parameter. Use `hash(data).toString(<encoding>)` instead.
|
| 38 |
+
- allow configuring the hash length in `hash()` and `hasher.digest()`
|
| 39 |
+
- add `using()` helper to deal with disposables
|
| 40 |
+
- add `dispose: boolean` option to Hashers' `.digest()` methods, so that you can read a head while continuing to update it
|
| 41 |
+
- add `hasher.reader()` method to retrieve a hash reader object, which allows seeking through and reading arbitrary amounts of data from the hash
|
| 42 |
+
- add helper methods for encoding and constant-time equality checking in the returned Hash within the browser
|
| 43 |
+
|
| 44 |
+
## 1.2.0 - 2020-01-14
|
| 45 |
+
|
| 46 |
+
- add native Node.js bindings
|
| 47 |
+
|
| 48 |
+
## 1.2.0-0 - 2020-01-14 (prerelease)
|
| 49 |
+
|
| 50 |
+
- add native Node.js bindings
|
| 51 |
+
|
| 52 |
+
## 1.1.0 - 2020-01-12
|
| 53 |
+
|
| 54 |
+
- add support for usage in browsers
|
| 55 |
+
- fix potential memory unsafety in WebAssembly land
|
| 56 |
+
- add support for output encoding in `Hash.digest([encoding])`
|
| 57 |
+
|
| 58 |
+
## 1.0.0 - 2020-01-09
|
| 59 |
+
|
| 60 |
+
Initial release
|
worker/node_modules/blake3-wasm/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "blake3-wasm",
|
| 3 |
+
"version": "2.1.5",
|
| 4 |
+
"description": "BLAKE3 hashing for JavaScript: native Node bindings (where available) and WebAssembly",
|
| 5 |
+
"keywords": [
|
| 6 |
+
"blake3",
|
| 7 |
+
"node-addon",
|
| 8 |
+
"hash",
|
| 9 |
+
"webassembly",
|
| 10 |
+
"wasm"
|
| 11 |
+
],
|
| 12 |
+
"module": "./esm/index",
|
| 13 |
+
"browser": "./esm/browser/index",
|
| 14 |
+
"main": "./dist/index",
|
| 15 |
+
"scripts": {
|
| 16 |
+
"prepack": "make clean && make MODE=release && npm test && rimraf dist/native.node",
|
| 17 |
+
"test": "mocha --require source-map-support/register --recursive \"dist/**/*.test.js\" --timeout 5000",
|
| 18 |
+
"fmt": "make fmt",
|
| 19 |
+
"compile": "tsc && tsc -p tsconfig.esm.json && node dist/build/add-js-extensions",
|
| 20 |
+
"watch": "tsc --watch"
|
| 21 |
+
},
|
| 22 |
+
"repository": {
|
| 23 |
+
"type": "git",
|
| 24 |
+
"url": "git+https://github.com/connor4312/blake3.git"
|
| 25 |
+
},
|
| 26 |
+
"bugs": {
|
| 27 |
+
"url": "https://github.com/connor4312/blake3/issues"
|
| 28 |
+
},
|
| 29 |
+
"homepage": "https://github.com/connor4312/blake3#readme",
|
| 30 |
+
"author": "Connor Peet <connor@peet.io>",
|
| 31 |
+
"license": "MIT",
|
| 32 |
+
"devDependencies": {
|
| 33 |
+
"@types/chai": "^4.2.7",
|
| 34 |
+
"@types/js-yaml": "^3.12.1",
|
| 35 |
+
"@types/mocha": "^5.2.7",
|
| 36 |
+
"@types/node": "^13.1.6",
|
| 37 |
+
"@types/node-fetch": "^2.5.4",
|
| 38 |
+
"@types/puppeteer": "^2.0.0",
|
| 39 |
+
"@types/serve-handler": "^6.1.0",
|
| 40 |
+
"@types/stream-buffers": "^3.0.3",
|
| 41 |
+
"@types/webpack": "^4.41.2",
|
| 42 |
+
"chai": "^4.2.0",
|
| 43 |
+
"js-yaml": "^3.13.1",
|
| 44 |
+
"mocha": "^7.0.0",
|
| 45 |
+
"neon-cli": "^0.3.3",
|
| 46 |
+
"node-fetch": "^2.6.0",
|
| 47 |
+
"prettier": "^1.19.1",
|
| 48 |
+
"puppeteer": "^2.0.0",
|
| 49 |
+
"remark-cli": "^7.0.1",
|
| 50 |
+
"remark-toc": "^6.0.0",
|
| 51 |
+
"rimraf": "^3.0.0",
|
| 52 |
+
"serve-handler": "^6.1.2",
|
| 53 |
+
"source-map-support": "^0.5.16",
|
| 54 |
+
"stream-buffers": "^3.0.2",
|
| 55 |
+
"typescript": "^3.8.0-beta",
|
| 56 |
+
"webpack": "^4.41.5"
|
| 57 |
+
},
|
| 58 |
+
"prettier": {
|
| 59 |
+
"printWidth": 100,
|
| 60 |
+
"singleQuote": true,
|
| 61 |
+
"trailingComma": "all"
|
| 62 |
+
}
|
| 63 |
+
}
|
worker/node_modules/blake3-wasm/readme.md
ADDED
|
@@ -0,0 +1,406 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# BLAKE3
|
| 2 |
+
|
| 3 |
+
[BLAKE3](https://github.com/BLAKE3-team/BLAKE3) running in JavaScript (node.js and browsers) via native bindings, where available, or WebAssembly.
|
| 4 |
+
|
| 5 |
+
npm install blake3
|
| 6 |
+
|
| 7 |
+
Additionally, there's a flavor of the package which is identical except that it will not download native Node.js bindings:
|
| 8 |
+
|
| 9 |
+
npm install blake3-wasm
|
| 10 |
+
|
| 11 |
+
## Table of Contents
|
| 12 |
+
|
| 13 |
+
- [Quickstart](#quickstart)
|
| 14 |
+
- [API](#api)
|
| 15 |
+
- [Node.js](#nodejs)
|
| 16 |
+
- [`hash(data: BinaryLike, options?: { length: number }): Buffer`](#hashdata-binarylike-options--length-number--buffer)
|
| 17 |
+
- [`keyedHash(key: Buffer, data: BinaryLike, options?: { length: number }): Buffer`](#keyedhashkey-buffer-data-binarylike-options--length-number--buffer)
|
| 18 |
+
- [`deriveKey(context: string, material: BinaryLike, options?: { length: number }): Buffer`](#derivekeycontext-string-material-binarylike-options--length-number--buffer)
|
| 19 |
+
- [Hasher](#hasher)
|
| 20 |
+
- [`createHash(): Hasher`](#createhash-hasher)
|
| 21 |
+
- [`createKeyed(key: Buffer): Hasher`](#createkeyedkey-buffer-hasher)
|
| 22 |
+
- [`createDeriveKey(context: string): Hasher`](#createderivekeycontext-string-hasher)
|
| 23 |
+
- [`hasher.update(data: BinaryLike): this`](#hasherupdatedata-binarylike-this)
|
| 24 |
+
- [`hasher.digest(encoding?: string, options?: { length: number, dispose: boolean })): Buffer | string`](#hasherdigestencoding-string-options--length-number-dispose-boolean--buffer--string)
|
| 25 |
+
- [`hasher.reader(options?: { dispose: boolean }): HashReader`](#hasherreaderoptions--dispose-boolean--hashreader)
|
| 26 |
+
- [`hasher.dispose()`](#hasherdispose)
|
| 27 |
+
- [HashReader](#hashreader)
|
| 28 |
+
- [`reader.position: bigint`](#readerposition-bigint)
|
| 29 |
+
- [`reader.readInto(target: Buffer): void`](#readerreadintotarget-buffer-void)
|
| 30 |
+
- [`reader.read(bytes: number): Buffer`](#readerreadbytes-number-buffer)
|
| 31 |
+
- [`reader.toString([encoding]): string`](#readertostringencoding-string)
|
| 32 |
+
- [`reader.toBuffer(): Buffer`](#readertobuffer-buffer)
|
| 33 |
+
- [`reader.dispose()`](#readerdispose)
|
| 34 |
+
- [`using(disposable: IDisposable, fn: disposable => T): T`](#usingdisposable-idisposable-fn-disposable--t-t)
|
| 35 |
+
- [Browser](#browser)
|
| 36 |
+
- [`hash(data: BinaryLike, options?: { length: number }): Hash`](#hashdata-binarylike-options--length-number--hash)
|
| 37 |
+
- [`keyedHash(key: Buffer, data: BinaryLike, options?: { length: number }): Hash`](#keyedhashkey-buffer-data-binarylike-options--length-number--hash)
|
| 38 |
+
- [`deriveKey(context: string, material: BinaryLike, options?: { length: number }): Hash`](#derivekeycontext-string-material-binarylike-options--length-number--hash)
|
| 39 |
+
- [`Hash`](#hash)
|
| 40 |
+
- [`hash.equals(other: Uint8Array)`](#hashequalsother-uint8array)
|
| 41 |
+
- [`hash.toString(encoding: 'hex' | 'base64' | 'utf8'): string`](#hashtostringencoding-hex--base64--utf8-string)
|
| 42 |
+
- [Hasher](#hasher-1)
|
| 43 |
+
- [`createHash(): Hasher`](#createhash-hasher-1)
|
| 44 |
+
- [`createKeyed(key: Buffer): Hasher`](#createkeyedkey-buffer-hasher-1)
|
| 45 |
+
- [`createDeriveKey(context: string): Hasher`](#createderivekeycontext-string-hasher-1)
|
| 46 |
+
- [`hasher.update(data: BinaryLike): this`](#hasherupdatedata-binarylike-this-1)
|
| 47 |
+
- [`hasher.digest(encoding?: 'hex' | 'base64' | 'utf8', options?: { length: number, dispose: boolean })): Hash | string`](#hasherdigestencoding-hex--base64--utf8-options--length-number-dispose-boolean--hash--string)
|
| 48 |
+
- [`hasher.reader(options?: { dispose: boolean }): HashReader`](#hasherreaderoptions--dispose-boolean--hashreader-1)
|
| 49 |
+
- [`hasher.dispose()`](#hasherdispose-1)
|
| 50 |
+
- [HashReader](#hashreader-1)
|
| 51 |
+
- [`reader.position: bigint`](#readerposition-bigint-1)
|
| 52 |
+
- [`reader.readInto(target: Uint8Array): void`](#readerreadintotarget-uint8array-void)
|
| 53 |
+
- [`reader.read(bytes: number): Hash`](#readerreadbytes-number-hash)
|
| 54 |
+
- [`reader.toString(encoding?: string): string`](#readertostringencoding-string-string)
|
| 55 |
+
- [`reader.toArray(): Uint8Array`](#readertoarray-uint8array)
|
| 56 |
+
- [`reader.dispose()`](#readerdispose-1)
|
| 57 |
+
- [`using(disposable: IDisposable, fn: disposable => T): T`](#usingdisposable-idisposable-fn-disposable--t-t-1)
|
| 58 |
+
- [Speed](#speed)
|
| 59 |
+
- [Contributing](#contributing)
|
| 60 |
+
- [Publishing](#publishing)
|
| 61 |
+
|
| 62 |
+
## Quickstart
|
| 63 |
+
|
| 64 |
+
If you're on Node, import the module via
|
| 65 |
+
|
| 66 |
+
```js
|
| 67 |
+
const blake3 = require('blake3');
|
| 68 |
+
|
| 69 |
+
blake3.hash('foo'); // => Buffer
|
| 70 |
+
```
|
| 71 |
+
|
| 72 |
+
If you're in the browser, import `blake3/browser`. This includes a WebAssembly binary, so you probably want to import it asynchronously, like so:
|
| 73 |
+
|
| 74 |
+
```js
|
| 75 |
+
import('blake3/browser').then(blake3 => {
|
| 76 |
+
blake3.hash('foo'); // => Uint8Array
|
| 77 |
+
});
|
| 78 |
+
```
|
| 79 |
+
|
| 80 |
+
The API is very similar in Node.js and browsers, but Node supports and returns Buffers and a wider range of input and output encoding.
|
| 81 |
+
|
| 82 |
+
More complete example:
|
| 83 |
+
|
| 84 |
+
```js
|
| 85 |
+
const { hash, createHash } = require('blake3');
|
| 86 |
+
|
| 87 |
+
hash('some string'); // => hash a string to a uint8array
|
| 88 |
+
|
| 89 |
+
// Update incrementally (Node and Browsers):
|
| 90 |
+
const hash = createHash();
|
| 91 |
+
stream.on('data', d => hash.update(d));
|
| 92 |
+
stream.on('error', err => {
|
| 93 |
+
// hashes use unmanaged memory in WebAssembly, always free them if you don't digest()!
|
| 94 |
+
hash.dispose();
|
| 95 |
+
throw err;
|
| 96 |
+
});
|
| 97 |
+
stream.on('end', () => finishedHash(hash.digest()));
|
| 98 |
+
|
| 99 |
+
// Or, in Node, it's also a transform stream:
|
| 100 |
+
createReadStream('file.txt')
|
| 101 |
+
.pipe(createHash())
|
| 102 |
+
.on('data', hash => console.log(hash.toString('hex')));
|
| 103 |
+
```
|
| 104 |
+
|
| 105 |
+
## API
|
| 106 |
+
|
| 107 |
+
### Node.js
|
| 108 |
+
|
| 109 |
+
The Node API can be imported via `require('blake3')`.
|
| 110 |
+
|
| 111 |
+
#### `hash(data: BinaryLike, options?: { length: number }): Buffer`
|
| 112 |
+
|
| 113 |
+
Returns a hash for the given data. The data can be a string, buffer, typedarray, array buffer, or array. By default, it generates the first 32 bytes of the hash for the data, but this is configurable. It returns a Buffer.
|
| 114 |
+
|
| 115 |
+
#### `keyedHash(key: Buffer, data: BinaryLike, options?: { length: number }): Buffer`
|
| 116 |
+
|
| 117 |
+
Returns keyed a hash for the given data. The key must be exactly 32 bytes. The data can be a string, buffer, typedarray, array buffer, or array. By default, it generates the first 32 bytes of the hash for the data, but this is configurable. It returns a Buffer.
|
| 118 |
+
|
| 119 |
+
For more information, see [the blake3 docs](https://docs.rs/blake3/0.1.3/blake3/fn.keyed_hash.html).
|
| 120 |
+
|
| 121 |
+
#### `deriveKey(context: string, material: BinaryLike, options?: { length: number }): Buffer`
|
| 122 |
+
|
| 123 |
+
The key derivation function. The data can be a string, buffer, typedarray, array buffer, or array. By default, it generates the first 32 bytes of the hash for the data, but this is configurable. It returns a Buffer.
|
| 124 |
+
|
| 125 |
+
For more information, see [the blake3 docs](https://docs.rs/blake3/0.1.3/blake3/fn.derive_key.html).
|
| 126 |
+
|
| 127 |
+
#### Hasher
|
| 128 |
+
|
| 129 |
+
The hasher is a type that lets you incrementally build a hash. It's compatible with Node's crypto hash instance. For instance, it implements a transform stream, so you could do something like:
|
| 130 |
+
|
| 131 |
+
```js
|
| 132 |
+
createReadStream('file.txt')
|
| 133 |
+
.pipe(createHash())
|
| 134 |
+
.on('data', hash => console.log(hash.toString('hex')));
|
| 135 |
+
```
|
| 136 |
+
|
| 137 |
+
##### `createHash(): Hasher`
|
| 138 |
+
|
| 139 |
+
Creates a new hasher instance using the standard hash function.
|
| 140 |
+
|
| 141 |
+
##### `createKeyed(key: Buffer): Hasher`
|
| 142 |
+
|
| 143 |
+
Creates a new hasher instance for a keyed hash. For more information, see [the blake3 docs](https://docs.rs/blake3/0.1.3/blake3/fn.keyed_hash.html).
|
| 144 |
+
|
| 145 |
+
##### `createDeriveKey(context: string): Hasher`
|
| 146 |
+
|
| 147 |
+
Creates a new hasher instance for the key derivation function. For more information, see [the blake3 docs](https://docs.rs/blake3/0.1.3/blake3/fn.derive_key.html).
|
| 148 |
+
|
| 149 |
+
##### `hasher.update(data: BinaryLike): this`
|
| 150 |
+
|
| 151 |
+
Adds data to a hash. The data can be a string, buffer, typedarray, array buffer, or array. This will throw if called after `digest()` or `dispose()`.
|
| 152 |
+
|
| 153 |
+
##### `hasher.digest(encoding?: string, options?: { length: number, dispose: boolean })): Buffer | string`
|
| 154 |
+
|
| 155 |
+
Returns the hash of the data. If an `encoding` is given, a string will be returned. Otherwise, a Buffer is returned. Optionally, you can specify the requested byte length of the hash.
|
| 156 |
+
|
| 157 |
+
If `dispose: false` is given in the options, the hash will not automatically be disposed of, allowing you to continue updating it after obtaining the current reader.
|
| 158 |
+
|
| 159 |
+
##### `hasher.reader(options?: { dispose: boolean }): HashReader`
|
| 160 |
+
|
| 161 |
+
Returns a [HashReader](#HashReader) for the current hash.
|
| 162 |
+
|
| 163 |
+
If `dispose: false` is given in the options, the hash will not automatically be disposed of, allowing you to continue updating it after obtaining the current reader.
|
| 164 |
+
|
| 165 |
+
##### `hasher.dispose()`
|
| 166 |
+
|
| 167 |
+
Disposes of unmanaged resources. You should _always_ call this if you don't call `digest()` to free umanaged (WebAssembly-based) memory.
|
| 168 |
+
|
| 169 |
+
#### HashReader
|
| 170 |
+
|
| 171 |
+
The hash reader can be returned from hashing functions. Up to 2<sup>64</sup>-1 bytes of data can be read from BLAKE3 hashes; this structure lets you read those. Note that, like `hash`, this is an object which needs to be manually disposed of.
|
| 172 |
+
|
| 173 |
+
##### `reader.position: bigint`
|
| 174 |
+
|
| 175 |
+
A property which gets or sets the position of the reader in the output stream. A `RangeError` is thrown if setting this to a value less than 0 or greater than 2<sup>64</sup>-1. Note that this is a bigint, not a standard number.
|
| 176 |
+
|
| 177 |
+
```js
|
| 178 |
+
reader.position += 32n; // advance the reader 32 bytes
|
| 179 |
+
```
|
| 180 |
+
|
| 181 |
+
##### `reader.readInto(target: Buffer): void`
|
| 182 |
+
|
| 183 |
+
Reads bytes into the target array, filling it up and advancing the reader's position. A `RangeError` is thrown if reading this data puts the reader past 2<sup>64</sup>-1 bytes.
|
| 184 |
+
|
| 185 |
+
##### `reader.read(bytes: number): Buffer`
|
| 186 |
+
|
| 187 |
+
Reads and returns the given number of bytes from the reader, and advances the position. A `RangeError` is thrown if reading this data puts the reader past 2<sup>64</sup>-1 bytes.
|
| 188 |
+
|
| 189 |
+
##### `reader.toString([encoding]): string`
|
| 190 |
+
|
| 191 |
+
Converts first 32 bytes of the hash to a string with the given encoding. Defaults to hex encoding.
|
| 192 |
+
|
| 193 |
+
##### `reader.toBuffer(): Buffer`
|
| 194 |
+
|
| 195 |
+
Converts first 32 bytes of the hash to a Buffer.
|
| 196 |
+
|
| 197 |
+
##### `reader.dispose()`
|
| 198 |
+
|
| 199 |
+
Disposes of unmanaged resources. You should _always_ call this to free umanaged (WebAssembly-based) memory, or you application will leak memory.
|
| 200 |
+
|
| 201 |
+
#### `using(disposable: IDisposable, fn: disposable => T): T`
|
| 202 |
+
|
| 203 |
+
A helper method that takes a disposable, and automatically calls the dispose method when the function returns, or the promise returned from the function is settled.
|
| 204 |
+
|
| 205 |
+
```js
|
| 206 |
+
// read and auto-dispose the first 64 bytes
|
| 207 |
+
const first64Bytes = using(hash.reader(), reader => reader.toBuffer(64));
|
| 208 |
+
|
| 209 |
+
// you can also return promises/use async methods:
|
| 210 |
+
using(hash.reader(), async reader => {
|
| 211 |
+
do {
|
| 212 |
+
await send(reader.read(64));
|
| 213 |
+
} while (needsMoreData());
|
| 214 |
+
});
|
| 215 |
+
```
|
| 216 |
+
|
| 217 |
+
### Browser
|
| 218 |
+
|
| 219 |
+
The browser API can be imported via `import('blake3/browser')`, which works well with Webpack.
|
| 220 |
+
|
| 221 |
+
If you aren't using a bundler or using a more "pure" bundler like Parcel, you can import `blake3/browser-async` which exports a function to asynchronously load the WebAssembly code and resolves to the package contents.
|
| 222 |
+
|
| 223 |
+
```js
|
| 224 |
+
import load from 'blake3/browser-async';
|
| 225 |
+
|
| 226 |
+
load().then(blake3 => {
|
| 227 |
+
console.log(blake3.hash('hello world'));
|
| 228 |
+
});
|
| 229 |
+
```
|
| 230 |
+
|
| 231 |
+
#### `hash(data: BinaryLike, options?: { length: number }): Hash`
|
| 232 |
+
|
| 233 |
+
Returns a hash for the given data. The data can be a string, typedarray, array buffer, or array. By default, it generates the first 32 bytes of the hash for the data, but this is configurable. It returns a [Hash](#Hash) instance.
|
| 234 |
+
|
| 235 |
+
#### `keyedHash(key: Buffer, data: BinaryLike, options?: { length: number }): Hash`
|
| 236 |
+
|
| 237 |
+
Returns keyed a hash for the given data. The key must be exactly 32 bytes. The data can be a string, typedarray, array buffer, or array. By default, it generates the first 32 bytes of the hash for the data, but this is configurable. It returns a [Hash](#Hash) instance.
|
| 238 |
+
|
| 239 |
+
For more information, see [the blake3 docs](https://docs.rs/blake3/0.1.3/blake3/fn.keyed_hash.html).
|
| 240 |
+
|
| 241 |
+
#### `deriveKey(context: string, material: BinaryLike, options?: { length: number }): Hash`
|
| 242 |
+
|
| 243 |
+
The key derivation function. The data can be a string, typedarray, array buffer, or array. By default, it generates the first 32 bytes of the hash for the data, but this is configurable. It returns a [Hash](#Hash) instance.
|
| 244 |
+
|
| 245 |
+
For more information, see [the blake3 docs](https://docs.rs/blake3/0.1.3/blake3/fn.derive_key.html).
|
| 246 |
+
|
| 247 |
+
#### `Hash`
|
| 248 |
+
|
| 249 |
+
A Hash is the type returned from hash functions and the hasher in the browser. It's a `Uint8Array` with a few additional helper methods.
|
| 250 |
+
|
| 251 |
+
##### `hash.equals(other: Uint8Array)`
|
| 252 |
+
|
| 253 |
+
Returns whether this hash equals the other hash, via a constant-time equality check.
|
| 254 |
+
|
| 255 |
+
##### `hash.toString(encoding: 'hex' | 'base64' | 'utf8'): string`
|
| 256 |
+
|
| 257 |
+
#### Hasher
|
| 258 |
+
|
| 259 |
+
The hasher is a type that lets you incrementally build a hash. For instance, you can hash a `fetch`ed page like:
|
| 260 |
+
|
| 261 |
+
```js
|
| 262 |
+
const res = await fetch('https://example.com');
|
| 263 |
+
const body = await res.body;
|
| 264 |
+
|
| 265 |
+
const hasher = blake3.createHash();
|
| 266 |
+
const reader = body.getReader();
|
| 267 |
+
|
| 268 |
+
while (true) {
|
| 269 |
+
const { done, value } = await reader.read();
|
| 270 |
+
if (done) {
|
| 271 |
+
break;
|
| 272 |
+
}
|
| 273 |
+
|
| 274 |
+
hasher.update(value);
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
console.log('Hash of', res.url, 'is', hasher.digest('hex'));
|
| 278 |
+
```
|
| 279 |
+
|
| 280 |
+
Converts the hash to a string with the given encoding.
|
| 281 |
+
|
| 282 |
+
##### `createHash(): Hasher`
|
| 283 |
+
|
| 284 |
+
Creates a new hasher instance using the standard hash function.
|
| 285 |
+
|
| 286 |
+
##### `createKeyed(key: Buffer): Hasher`
|
| 287 |
+
|
| 288 |
+
Creates a new hasher instance for a keyed hash. For more information, see [the blake3 docs](https://docs.rs/blake3/0.1.3/blake3/fn.keyed_hash.html).
|
| 289 |
+
|
| 290 |
+
##### `createDeriveKey(context: string): Hasher`
|
| 291 |
+
|
| 292 |
+
Creates a new hasher instance for the key derivation function. For more information, see [the blake3 docs](https://docs.rs/blake3/0.1.3/blake3/fn.derive_key.html).
|
| 293 |
+
|
| 294 |
+
##### `hasher.update(data: BinaryLike): this`
|
| 295 |
+
|
| 296 |
+
Adds data to a hash. The data can be a string, buffer, typedarray, array buffer, or array. This will throw if called after `digest()` or `dispose()`.
|
| 297 |
+
|
| 298 |
+
##### `hasher.digest(encoding?: 'hex' | 'base64' | 'utf8', options?: { length: number, dispose: boolean })): Hash | string`
|
| 299 |
+
|
| 300 |
+
Returns the hash of the data. If an `encoding` is given, a string will be returned. Otherwise, a [Hash](#hash) is returned. Optionally, you can specify the requested byte length of the hash.
|
| 301 |
+
|
| 302 |
+
If `dispose: false` is given in the options, the hash will not automatically be disposed of, allowing you to continue updating it after obtaining the current reader.
|
| 303 |
+
|
| 304 |
+
##### `hasher.reader(options?: { dispose: boolean }): HashReader`
|
| 305 |
+
|
| 306 |
+
Returns a [HashReader](#HashReader) for the current hash.
|
| 307 |
+
|
| 308 |
+
If `dispose: false` is given in the options, the hash will not automatically be disposed of, allowing you to continue updating it after obtaining the current reader.
|
| 309 |
+
|
| 310 |
+
##### `hasher.dispose()`
|
| 311 |
+
|
| 312 |
+
Disposes of unmanaged resources. You should _always_ call this if you don't call `digest()` to free umanaged (WebAssembly-based) memory.
|
| 313 |
+
|
| 314 |
+
#### HashReader
|
| 315 |
+
|
| 316 |
+
The hash reader can be returned from hashing functions. Up to 2<sup>64</sup>-1 bytes of data can be read from BLAKE3 hashes; this structure lets you read those. Note that, like `hash`, this is an object which needs to be manually disposed of.
|
| 317 |
+
|
| 318 |
+
##### `reader.position: bigint`
|
| 319 |
+
|
| 320 |
+
A property which gets or sets the position of the reader in the output stream. A `RangeError` is thrown if setting this to a value less than 0 or greater than 2<sup>64</sup>-1. Note that this is a bigint, not a standard number.
|
| 321 |
+
|
| 322 |
+
```js
|
| 323 |
+
reader.position += 32n; // advance the reader 32 bytes
|
| 324 |
+
```
|
| 325 |
+
|
| 326 |
+
##### `reader.readInto(target: Uint8Array): void`
|
| 327 |
+
|
| 328 |
+
Reads bytes into the target array, filling it up and advancing the reader's position. A `RangeError` is thrown if reading this data puts the reader past 2<sup>64</sup>-1 bytes.
|
| 329 |
+
|
| 330 |
+
##### `reader.read(bytes: number): Hash`
|
| 331 |
+
|
| 332 |
+
Reads and returns the given number of bytes from the reader, and advances the position. A `RangeError` is thrown if reading this data puts the reader past 2<sup>64</sup>-1 bytes.
|
| 333 |
+
|
| 334 |
+
##### `reader.toString(encoding?: string): string`
|
| 335 |
+
|
| 336 |
+
Converts first 32 bytes of the hash to a string with the given encoding. Defaults to hex encoding.
|
| 337 |
+
|
| 338 |
+
##### `reader.toArray(): Uint8Array`
|
| 339 |
+
|
| 340 |
+
Converts first 32 bytes of the hash to an array.
|
| 341 |
+
|
| 342 |
+
##### `reader.dispose()`
|
| 343 |
+
|
| 344 |
+
Disposes of unmanaged resources. You should _always_ call this to free umanaged (WebAssembly-based) memory, or you application will leak memory.
|
| 345 |
+
|
| 346 |
+
#### `using(disposable: IDisposable, fn: disposable => T): T`
|
| 347 |
+
|
| 348 |
+
A helper method that takes a disposable, and automatically calls the dispose method when the function returns, or the promise returned from the function is settled.
|
| 349 |
+
|
| 350 |
+
```js
|
| 351 |
+
// read and auto-dispose the first 64 bytes
|
| 352 |
+
const first64Bytes = using(hash.reader(), reader => reader.toArray(64));
|
| 353 |
+
|
| 354 |
+
// you can also return promises/use async methods:
|
| 355 |
+
using(hash.reader(), async reader => {
|
| 356 |
+
do {
|
| 357 |
+
await send(reader.read(64));
|
| 358 |
+
} while (needsMoreData());
|
| 359 |
+
});
|
| 360 |
+
```
|
| 361 |
+
|
| 362 |
+
## Speed
|
| 363 |
+
|
| 364 |
+
> Native Node.js bindings are a work in progress.
|
| 365 |
+
|
| 366 |
+
You can run benchmarks by installing `npm install -g @c4312/matcha`, then running `matcha benchmark.js`. These are the results running on Node 12 on my MacBook. Blake3 is significantly faster than Node's built-in hashing.
|
| 367 |
+
|
| 368 |
+
276,000 ops/sec > 64B#md5 (4,240x)
|
| 369 |
+
263,000 ops/sec > 64B#sha1 (4,040x)
|
| 370 |
+
271,000 ops/sec > 64B#sha256 (4,160x)
|
| 371 |
+
1,040,000 ops/sec > 64B#blake3 wasm (15,900x)
|
| 372 |
+
625,000 ops/sec > 64B#blake3 native (9,590x)
|
| 373 |
+
|
| 374 |
+
9,900 ops/sec > 64KB#md5 (152x)
|
| 375 |
+
13,900 ops/sec > 64KB#sha1 (214x)
|
| 376 |
+
6,470 ops/sec > 64KB#sha256 (99.2x)
|
| 377 |
+
6,410 ops/sec > 64KB#blake3 wasm (98.4x)
|
| 378 |
+
48,900 ops/sec > 64KB#blake3 native (750x)
|
| 379 |
+
|
| 380 |
+
106 ops/sec > 6MB#md5 (1.63x)
|
| 381 |
+
150 ops/sec > 6MB#sha1 (2.3x)
|
| 382 |
+
69.2 ops/sec > 6MB#sha256 (1.06x)
|
| 383 |
+
65.2 ops/sec > 6MB#blake3 wasm (1x)
|
| 384 |
+
502 ops/sec > 6MB#blake3 native (7.7x)
|
| 385 |
+
|
| 386 |
+
## Contributing
|
| 387 |
+
|
| 388 |
+
This build is a little esoteric due to the mixing of languages. We use a `Makefile` to coodinate things.
|
| 389 |
+
|
| 390 |
+
To get set up, you'll want to open the repository in VS Code. Make sure you have [Remote Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) installed, and then accept the "Reopen in Container" prompt when opening the folder. This will get the environment set up with everything you need. Then, run `make prepare` to install local dependencies.
|
| 391 |
+
|
| 392 |
+
Finally, `make` will create a build for you; you can run `make MODE=release` for a production release, and certainly should if you want to [benchmark it](#speed).
|
| 393 |
+
|
| 394 |
+
- Rust code is compiled from `src/lib.rs` to `pkg/browser` and `pkg/node`
|
| 395 |
+
- TypeScript code is compiled from `ts/*.ts` into `dist`
|
| 396 |
+
|
| 397 |
+
### Publishing
|
| 398 |
+
|
| 399 |
+
In case I get hit by a bus or get other contributors, these are the steps for publishing:
|
| 400 |
+
|
| 401 |
+
1. Get all your code ready to go in master, pushed up to Github.
|
| 402 |
+
2. Run `make prepare-binaries`. This will update the branch `generate-binary`, which kicks off a build via Github actions to create `.node` binaries for every relevant Node.js version.
|
| 403 |
+
3. When the build completes, it'll generate a zip file of artifacts. Download those.
|
| 404 |
+
4. Back on master, run `npm version <type>` to update the version in git. `git push --tags`.
|
| 405 |
+
5. On Github, upload the contents of the artifacts folder to the release for the newly tagged version.
|
| 406 |
+
6. Run `npm publish`.
|
worker/node_modules/blake3-wasm/targets.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"v15.3.0":88,"v15.2.1":88,"v15.2.0":88,"v15.1.0":88,"v15.0.1":88,"v15.0.0":88,"v14.15.1":83,"v14.15.0":83,"v14.14.0":83,"v14.13.1":83,"v14.13.0":83,"v14.12.0":83,"v14.11.0":83,"v14.10.1":83,"v14.10.0":83,"v14.9.0":83,"v14.8.0":83,"v14.7.0":83,"v14.6.0":83,"v14.5.0":83,"v14.4.0":83,"v14.3.0":83,"v14.2.0":83,"v14.1.0":83,"v14.0.0":83,"v13.14.0":79,"v13.13.0":79,"v13.12.0":79,"v13.11.0":79,"v13.10.1":79,"v13.10.0":79,"v13.9.0":79,"v13.8.0":79,"v13.7.0":79,"v13.6.0":79,"v13.5.0":79,"v13.4.0":79,"v13.3.0":79,"v13.2.0":79,"v13.1.0":79,"v13.0.1":79,"v13.0.0":79,"v12.20.0":72,"v12.19.1":72,"v12.19.0":72,"v12.18.4":72,"v12.18.3":72,"v12.18.2":72,"v12.18.1":72,"v12.18.0":72,"v12.17.0":72,"v12.16.3":72,"v12.16.2":72,"v12.16.1":72,"v12.16.0":72,"v12.15.0":72,"v12.14.1":72,"v12.14.0":72,"v12.13.1":72,"v12.13.0":72,"v12.12.0":72,"v12.11.1":72,"v12.11.0":72,"v12.10.0":72,"v12.9.1":72,"v12.9.0":72,"v12.8.1":72,"v12.8.0":72,"v12.7.0":72,"v12.6.0":72,"v12.5.0":72,"v12.4.0":72,"v12.3.1":72,"v12.3.0":72,"v12.2.0":72,"v12.1.0":72,"v12.0.0":72,"v11.15.0":67,"v11.14.0":67,"v11.13.0":67,"v11.12.0":67,"v11.11.0":67,"v11.10.1":67,"v11.10.0":67,"v11.9.0":67,"v11.8.0":67,"v11.7.0":67,"v11.6.0":67,"v11.5.0":67,"v11.4.0":67,"v11.3.0":67,"v11.2.0":67,"v11.1.0":67,"v11.0.0":67,"v10.23.0":64,"v10.22.1":64,"v10.22.0":64,"v10.21.0":64,"v10.20.1":64,"v10.20.0":64,"v10.19.0":64,"v10.18.1":64,"v10.18.0":64,"v10.17.0":64,"v10.16.3":64,"v10.16.2":64,"v10.16.1":64,"v10.16.0":64,"v10.15.3":64,"v10.15.2":64,"v10.15.1":64,"v10.15.0":64,"v10.14.2":64,"v10.14.1":64,"v10.14.0":64,"v10.13.0":64,"v10.12.0":64,"v10.11.0":64,"v10.10.0":64,"v10.9.0":64,"v10.8.0":64,"v10.7.0":64,"v10.6.0":64,"v10.5.0":64,"v10.4.1":64,"v10.4.0":64,"v10.3.0":64,"v10.2.1":64,"v10.2.0":64,"v10.1.0":64,"v10.0.0":64}
|
worker/node_modules/color-convert/CHANGELOG.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 1.0.0 - 2016-01-07
|
| 2 |
+
|
| 3 |
+
- Removed: unused speed test
|
| 4 |
+
- Added: Automatic routing between previously unsupported conversions
|
| 5 |
+
([#27](https://github.com/Qix-/color-convert/pull/27))
|
| 6 |
+
- Removed: `xxx2xxx()` and `xxx2xxxRaw()` functions
|
| 7 |
+
([#27](https://github.com/Qix-/color-convert/pull/27))
|
| 8 |
+
- Removed: `convert()` class
|
| 9 |
+
([#27](https://github.com/Qix-/color-convert/pull/27))
|
| 10 |
+
- Changed: all functions to lookup dictionary
|
| 11 |
+
([#27](https://github.com/Qix-/color-convert/pull/27))
|
| 12 |
+
- Changed: `ansi` to `ansi256`
|
| 13 |
+
([#27](https://github.com/Qix-/color-convert/pull/27))
|
| 14 |
+
- Fixed: argument grouping for functions requiring only one argument
|
| 15 |
+
([#27](https://github.com/Qix-/color-convert/pull/27))
|
| 16 |
+
|
| 17 |
+
# 0.6.0 - 2015-07-23
|
| 18 |
+
|
| 19 |
+
- Added: methods to handle
|
| 20 |
+
[ANSI](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors) 16/256 colors:
|
| 21 |
+
- rgb2ansi16
|
| 22 |
+
- rgb2ansi
|
| 23 |
+
- hsl2ansi16
|
| 24 |
+
- hsl2ansi
|
| 25 |
+
- hsv2ansi16
|
| 26 |
+
- hsv2ansi
|
| 27 |
+
- hwb2ansi16
|
| 28 |
+
- hwb2ansi
|
| 29 |
+
- cmyk2ansi16
|
| 30 |
+
- cmyk2ansi
|
| 31 |
+
- keyword2ansi16
|
| 32 |
+
- keyword2ansi
|
| 33 |
+
- ansi162rgb
|
| 34 |
+
- ansi162hsl
|
| 35 |
+
- ansi162hsv
|
| 36 |
+
- ansi162hwb
|
| 37 |
+
- ansi162cmyk
|
| 38 |
+
- ansi162keyword
|
| 39 |
+
- ansi2rgb
|
| 40 |
+
- ansi2hsl
|
| 41 |
+
- ansi2hsv
|
| 42 |
+
- ansi2hwb
|
| 43 |
+
- ansi2cmyk
|
| 44 |
+
- ansi2keyword
|
| 45 |
+
([#18](https://github.com/harthur/color-convert/pull/18))
|
| 46 |
+
|
| 47 |
+
# 0.5.3 - 2015-06-02
|
| 48 |
+
|
| 49 |
+
- Fixed: hsl2hsv does not return `NaN` anymore when using `[0,0,0]`
|
| 50 |
+
([#15](https://github.com/harthur/color-convert/issues/15))
|
| 51 |
+
|
| 52 |
+
---
|
| 53 |
+
|
| 54 |
+
Check out commit logs for older releases
|
worker/node_modules/color-convert/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Copyright (c) 2011-2016 Heather Arthur <fayearthur@gmail.com>
|
| 2 |
+
|
| 3 |
+
Permission is hereby granted, free of charge, to any person obtaining
|
| 4 |
+
a copy of this software and associated documentation files (the
|
| 5 |
+
"Software"), to deal in the Software without restriction, including
|
| 6 |
+
without limitation the rights to use, copy, modify, merge, publish,
|
| 7 |
+
distribute, sublicense, and/or sell copies of the Software, and to
|
| 8 |
+
permit persons to whom the Software is furnished to do so, subject to
|
| 9 |
+
the following conditions:
|
| 10 |
+
|
| 11 |
+
The above copyright notice and this permission notice shall be
|
| 12 |
+
included in all copies or substantial portions of the Software.
|
| 13 |
+
|
| 14 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 15 |
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
| 16 |
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 17 |
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
| 18 |
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
| 19 |
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
| 20 |
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
| 21 |
+
|
worker/node_modules/color-convert/README.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# color-convert
|
| 2 |
+
|
| 3 |
+
[](https://travis-ci.org/Qix-/color-convert)
|
| 4 |
+
|
| 5 |
+
Color-convert is a color conversion library for JavaScript and node.
|
| 6 |
+
It converts all ways between `rgb`, `hsl`, `hsv`, `hwb`, `cmyk`, `ansi`, `ansi16`, `hex` strings, and CSS `keyword`s (will round to closest):
|
| 7 |
+
|
| 8 |
+
```js
|
| 9 |
+
var convert = require('color-convert');
|
| 10 |
+
|
| 11 |
+
convert.rgb.hsl(140, 200, 100); // [96, 48, 59]
|
| 12 |
+
convert.keyword.rgb('blue'); // [0, 0, 255]
|
| 13 |
+
|
| 14 |
+
var rgbChannels = convert.rgb.channels; // 3
|
| 15 |
+
var cmykChannels = convert.cmyk.channels; // 4
|
| 16 |
+
var ansiChannels = convert.ansi16.channels; // 1
|
| 17 |
+
```
|
| 18 |
+
|
| 19 |
+
# Install
|
| 20 |
+
|
| 21 |
+
```console
|
| 22 |
+
$ npm install color-convert
|
| 23 |
+
```
|
| 24 |
+
|
| 25 |
+
# API
|
| 26 |
+
|
| 27 |
+
Simply get the property of the _from_ and _to_ conversion that you're looking for.
|
| 28 |
+
|
| 29 |
+
All functions have a rounded and unrounded variant. By default, return values are rounded. To get the unrounded (raw) results, simply tack on `.raw` to the function.
|
| 30 |
+
|
| 31 |
+
All 'from' functions have a hidden property called `.channels` that indicates the number of channels the function expects (not including alpha).
|
| 32 |
+
|
| 33 |
+
```js
|
| 34 |
+
var convert = require('color-convert');
|
| 35 |
+
|
| 36 |
+
// Hex to LAB
|
| 37 |
+
convert.hex.lab('DEADBF'); // [ 76, 21, -2 ]
|
| 38 |
+
convert.hex.lab.raw('DEADBF'); // [ 75.56213190997677, 20.653827952644754, -2.290532499330533 ]
|
| 39 |
+
|
| 40 |
+
// RGB to CMYK
|
| 41 |
+
convert.rgb.cmyk(167, 255, 4); // [ 35, 0, 98, 0 ]
|
| 42 |
+
convert.rgb.cmyk.raw(167, 255, 4); // [ 34.509803921568626, 0, 98.43137254901961, 0 ]
|
| 43 |
+
```
|
| 44 |
+
|
| 45 |
+
### Arrays
|
| 46 |
+
All functions that accept multiple arguments also support passing an array.
|
| 47 |
+
|
| 48 |
+
Note that this does **not** apply to functions that convert from a color that only requires one value (e.g. `keyword`, `ansi256`, `hex`, etc.)
|
| 49 |
+
|
| 50 |
+
```js
|
| 51 |
+
var convert = require('color-convert');
|
| 52 |
+
|
| 53 |
+
convert.rgb.hex(123, 45, 67); // '7B2D43'
|
| 54 |
+
convert.rgb.hex([123, 45, 67]); // '7B2D43'
|
| 55 |
+
```
|
| 56 |
+
|
| 57 |
+
## Routing
|
| 58 |
+
|
| 59 |
+
Conversions that don't have an _explicitly_ defined conversion (in [conversions.js](conversions.js)), but can be converted by means of sub-conversions (e.g. XYZ -> **RGB** -> CMYK), are automatically routed together. This allows just about any color model supported by `color-convert` to be converted to any other model, so long as a sub-conversion path exists. This is also true for conversions requiring more than one step in between (e.g. LCH -> **LAB** -> **XYZ** -> **RGB** -> Hex).
|
| 60 |
+
|
| 61 |
+
Keep in mind that extensive conversions _may_ result in a loss of precision, and exist only to be complete. For a list of "direct" (single-step) conversions, see [conversions.js](conversions.js).
|
| 62 |
+
|
| 63 |
+
# Contribute
|
| 64 |
+
|
| 65 |
+
If there is a new model you would like to support, or want to add a direct conversion between two existing models, please send us a pull request.
|
| 66 |
+
|
| 67 |
+
# License
|
| 68 |
+
Copyright © 2011-2016, Heather Arthur and Josh Junon. Licensed under the [MIT License](LICENSE).
|
worker/node_modules/color-convert/conversions.js
ADDED
|
@@ -0,0 +1,839 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* MIT license */
|
| 2 |
+
/* eslint-disable no-mixed-operators */
|
| 3 |
+
const cssKeywords = require('color-name');
|
| 4 |
+
|
| 5 |
+
// NOTE: conversions should only return primitive values (i.e. arrays, or
|
| 6 |
+
// values that give correct `typeof` results).
|
| 7 |
+
// do not use box values types (i.e. Number(), String(), etc.)
|
| 8 |
+
|
| 9 |
+
const reverseKeywords = {};
|
| 10 |
+
for (const key of Object.keys(cssKeywords)) {
|
| 11 |
+
reverseKeywords[cssKeywords[key]] = key;
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
const convert = {
|
| 15 |
+
rgb: {channels: 3, labels: 'rgb'},
|
| 16 |
+
hsl: {channels: 3, labels: 'hsl'},
|
| 17 |
+
hsv: {channels: 3, labels: 'hsv'},
|
| 18 |
+
hwb: {channels: 3, labels: 'hwb'},
|
| 19 |
+
cmyk: {channels: 4, labels: 'cmyk'},
|
| 20 |
+
xyz: {channels: 3, labels: 'xyz'},
|
| 21 |
+
lab: {channels: 3, labels: 'lab'},
|
| 22 |
+
lch: {channels: 3, labels: 'lch'},
|
| 23 |
+
hex: {channels: 1, labels: ['hex']},
|
| 24 |
+
keyword: {channels: 1, labels: ['keyword']},
|
| 25 |
+
ansi16: {channels: 1, labels: ['ansi16']},
|
| 26 |
+
ansi256: {channels: 1, labels: ['ansi256']},
|
| 27 |
+
hcg: {channels: 3, labels: ['h', 'c', 'g']},
|
| 28 |
+
apple: {channels: 3, labels: ['r16', 'g16', 'b16']},
|
| 29 |
+
gray: {channels: 1, labels: ['gray']}
|
| 30 |
+
};
|
| 31 |
+
|
| 32 |
+
module.exports = convert;
|
| 33 |
+
|
| 34 |
+
// Hide .channels and .labels properties
|
| 35 |
+
for (const model of Object.keys(convert)) {
|
| 36 |
+
if (!('channels' in convert[model])) {
|
| 37 |
+
throw new Error('missing channels property: ' + model);
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
if (!('labels' in convert[model])) {
|
| 41 |
+
throw new Error('missing channel labels property: ' + model);
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
if (convert[model].labels.length !== convert[model].channels) {
|
| 45 |
+
throw new Error('channel and label counts mismatch: ' + model);
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
const {channels, labels} = convert[model];
|
| 49 |
+
delete convert[model].channels;
|
| 50 |
+
delete convert[model].labels;
|
| 51 |
+
Object.defineProperty(convert[model], 'channels', {value: channels});
|
| 52 |
+
Object.defineProperty(convert[model], 'labels', {value: labels});
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
convert.rgb.hsl = function (rgb) {
|
| 56 |
+
const r = rgb[0] / 255;
|
| 57 |
+
const g = rgb[1] / 255;
|
| 58 |
+
const b = rgb[2] / 255;
|
| 59 |
+
const min = Math.min(r, g, b);
|
| 60 |
+
const max = Math.max(r, g, b);
|
| 61 |
+
const delta = max - min;
|
| 62 |
+
let h;
|
| 63 |
+
let s;
|
| 64 |
+
|
| 65 |
+
if (max === min) {
|
| 66 |
+
h = 0;
|
| 67 |
+
} else if (r === max) {
|
| 68 |
+
h = (g - b) / delta;
|
| 69 |
+
} else if (g === max) {
|
| 70 |
+
h = 2 + (b - r) / delta;
|
| 71 |
+
} else if (b === max) {
|
| 72 |
+
h = 4 + (r - g) / delta;
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
h = Math.min(h * 60, 360);
|
| 76 |
+
|
| 77 |
+
if (h < 0) {
|
| 78 |
+
h += 360;
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
const l = (min + max) / 2;
|
| 82 |
+
|
| 83 |
+
if (max === min) {
|
| 84 |
+
s = 0;
|
| 85 |
+
} else if (l <= 0.5) {
|
| 86 |
+
s = delta / (max + min);
|
| 87 |
+
} else {
|
| 88 |
+
s = delta / (2 - max - min);
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
return [h, s * 100, l * 100];
|
| 92 |
+
};
|
| 93 |
+
|
| 94 |
+
convert.rgb.hsv = function (rgb) {
|
| 95 |
+
let rdif;
|
| 96 |
+
let gdif;
|
| 97 |
+
let bdif;
|
| 98 |
+
let h;
|
| 99 |
+
let s;
|
| 100 |
+
|
| 101 |
+
const r = rgb[0] / 255;
|
| 102 |
+
const g = rgb[1] / 255;
|
| 103 |
+
const b = rgb[2] / 255;
|
| 104 |
+
const v = Math.max(r, g, b);
|
| 105 |
+
const diff = v - Math.min(r, g, b);
|
| 106 |
+
const diffc = function (c) {
|
| 107 |
+
return (v - c) / 6 / diff + 1 / 2;
|
| 108 |
+
};
|
| 109 |
+
|
| 110 |
+
if (diff === 0) {
|
| 111 |
+
h = 0;
|
| 112 |
+
s = 0;
|
| 113 |
+
} else {
|
| 114 |
+
s = diff / v;
|
| 115 |
+
rdif = diffc(r);
|
| 116 |
+
gdif = diffc(g);
|
| 117 |
+
bdif = diffc(b);
|
| 118 |
+
|
| 119 |
+
if (r === v) {
|
| 120 |
+
h = bdif - gdif;
|
| 121 |
+
} else if (g === v) {
|
| 122 |
+
h = (1 / 3) + rdif - bdif;
|
| 123 |
+
} else if (b === v) {
|
| 124 |
+
h = (2 / 3) + gdif - rdif;
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
if (h < 0) {
|
| 128 |
+
h += 1;
|
| 129 |
+
} else if (h > 1) {
|
| 130 |
+
h -= 1;
|
| 131 |
+
}
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
return [
|
| 135 |
+
h * 360,
|
| 136 |
+
s * 100,
|
| 137 |
+
v * 100
|
| 138 |
+
];
|
| 139 |
+
};
|
| 140 |
+
|
| 141 |
+
convert.rgb.hwb = function (rgb) {
|
| 142 |
+
const r = rgb[0];
|
| 143 |
+
const g = rgb[1];
|
| 144 |
+
let b = rgb[2];
|
| 145 |
+
const h = convert.rgb.hsl(rgb)[0];
|
| 146 |
+
const w = 1 / 255 * Math.min(r, Math.min(g, b));
|
| 147 |
+
|
| 148 |
+
b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
|
| 149 |
+
|
| 150 |
+
return [h, w * 100, b * 100];
|
| 151 |
+
};
|
| 152 |
+
|
| 153 |
+
convert.rgb.cmyk = function (rgb) {
|
| 154 |
+
const r = rgb[0] / 255;
|
| 155 |
+
const g = rgb[1] / 255;
|
| 156 |
+
const b = rgb[2] / 255;
|
| 157 |
+
|
| 158 |
+
const k = Math.min(1 - r, 1 - g, 1 - b);
|
| 159 |
+
const c = (1 - r - k) / (1 - k) || 0;
|
| 160 |
+
const m = (1 - g - k) / (1 - k) || 0;
|
| 161 |
+
const y = (1 - b - k) / (1 - k) || 0;
|
| 162 |
+
|
| 163 |
+
return [c * 100, m * 100, y * 100, k * 100];
|
| 164 |
+
};
|
| 165 |
+
|
| 166 |
+
function comparativeDistance(x, y) {
|
| 167 |
+
/*
|
| 168 |
+
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
|
| 169 |
+
*/
|
| 170 |
+
return (
|
| 171 |
+
((x[0] - y[0]) ** 2) +
|
| 172 |
+
((x[1] - y[1]) ** 2) +
|
| 173 |
+
((x[2] - y[2]) ** 2)
|
| 174 |
+
);
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
convert.rgb.keyword = function (rgb) {
|
| 178 |
+
const reversed = reverseKeywords[rgb];
|
| 179 |
+
if (reversed) {
|
| 180 |
+
return reversed;
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
let currentClosestDistance = Infinity;
|
| 184 |
+
let currentClosestKeyword;
|
| 185 |
+
|
| 186 |
+
for (const keyword of Object.keys(cssKeywords)) {
|
| 187 |
+
const value = cssKeywords[keyword];
|
| 188 |
+
|
| 189 |
+
// Compute comparative distance
|
| 190 |
+
const distance = comparativeDistance(rgb, value);
|
| 191 |
+
|
| 192 |
+
// Check if its less, if so set as closest
|
| 193 |
+
if (distance < currentClosestDistance) {
|
| 194 |
+
currentClosestDistance = distance;
|
| 195 |
+
currentClosestKeyword = keyword;
|
| 196 |
+
}
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
+
return currentClosestKeyword;
|
| 200 |
+
};
|
| 201 |
+
|
| 202 |
+
convert.keyword.rgb = function (keyword) {
|
| 203 |
+
return cssKeywords[keyword];
|
| 204 |
+
};
|
| 205 |
+
|
| 206 |
+
convert.rgb.xyz = function (rgb) {
|
| 207 |
+
let r = rgb[0] / 255;
|
| 208 |
+
let g = rgb[1] / 255;
|
| 209 |
+
let b = rgb[2] / 255;
|
| 210 |
+
|
| 211 |
+
// Assume sRGB
|
| 212 |
+
r = r > 0.04045 ? (((r + 0.055) / 1.055) ** 2.4) : (r / 12.92);
|
| 213 |
+
g = g > 0.04045 ? (((g + 0.055) / 1.055) ** 2.4) : (g / 12.92);
|
| 214 |
+
b = b > 0.04045 ? (((b + 0.055) / 1.055) ** 2.4) : (b / 12.92);
|
| 215 |
+
|
| 216 |
+
const x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805);
|
| 217 |
+
const y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722);
|
| 218 |
+
const z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505);
|
| 219 |
+
|
| 220 |
+
return [x * 100, y * 100, z * 100];
|
| 221 |
+
};
|
| 222 |
+
|
| 223 |
+
convert.rgb.lab = function (rgb) {
|
| 224 |
+
const xyz = convert.rgb.xyz(rgb);
|
| 225 |
+
let x = xyz[0];
|
| 226 |
+
let y = xyz[1];
|
| 227 |
+
let z = xyz[2];
|
| 228 |
+
|
| 229 |
+
x /= 95.047;
|
| 230 |
+
y /= 100;
|
| 231 |
+
z /= 108.883;
|
| 232 |
+
|
| 233 |
+
x = x > 0.008856 ? (x ** (1 / 3)) : (7.787 * x) + (16 / 116);
|
| 234 |
+
y = y > 0.008856 ? (y ** (1 / 3)) : (7.787 * y) + (16 / 116);
|
| 235 |
+
z = z > 0.008856 ? (z ** (1 / 3)) : (7.787 * z) + (16 / 116);
|
| 236 |
+
|
| 237 |
+
const l = (116 * y) - 16;
|
| 238 |
+
const a = 500 * (x - y);
|
| 239 |
+
const b = 200 * (y - z);
|
| 240 |
+
|
| 241 |
+
return [l, a, b];
|
| 242 |
+
};
|
| 243 |
+
|
| 244 |
+
convert.hsl.rgb = function (hsl) {
|
| 245 |
+
const h = hsl[0] / 360;
|
| 246 |
+
const s = hsl[1] / 100;
|
| 247 |
+
const l = hsl[2] / 100;
|
| 248 |
+
let t2;
|
| 249 |
+
let t3;
|
| 250 |
+
let val;
|
| 251 |
+
|
| 252 |
+
if (s === 0) {
|
| 253 |
+
val = l * 255;
|
| 254 |
+
return [val, val, val];
|
| 255 |
+
}
|
| 256 |
+
|
| 257 |
+
if (l < 0.5) {
|
| 258 |
+
t2 = l * (1 + s);
|
| 259 |
+
} else {
|
| 260 |
+
t2 = l + s - l * s;
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
const t1 = 2 * l - t2;
|
| 264 |
+
|
| 265 |
+
const rgb = [0, 0, 0];
|
| 266 |
+
for (let i = 0; i < 3; i++) {
|
| 267 |
+
t3 = h + 1 / 3 * -(i - 1);
|
| 268 |
+
if (t3 < 0) {
|
| 269 |
+
t3++;
|
| 270 |
+
}
|
| 271 |
+
|
| 272 |
+
if (t3 > 1) {
|
| 273 |
+
t3--;
|
| 274 |
+
}
|
| 275 |
+
|
| 276 |
+
if (6 * t3 < 1) {
|
| 277 |
+
val = t1 + (t2 - t1) * 6 * t3;
|
| 278 |
+
} else if (2 * t3 < 1) {
|
| 279 |
+
val = t2;
|
| 280 |
+
} else if (3 * t3 < 2) {
|
| 281 |
+
val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
|
| 282 |
+
} else {
|
| 283 |
+
val = t1;
|
| 284 |
+
}
|
| 285 |
+
|
| 286 |
+
rgb[i] = val * 255;
|
| 287 |
+
}
|
| 288 |
+
|
| 289 |
+
return rgb;
|
| 290 |
+
};
|
| 291 |
+
|
| 292 |
+
convert.hsl.hsv = function (hsl) {
|
| 293 |
+
const h = hsl[0];
|
| 294 |
+
let s = hsl[1] / 100;
|
| 295 |
+
let l = hsl[2] / 100;
|
| 296 |
+
let smin = s;
|
| 297 |
+
const lmin = Math.max(l, 0.01);
|
| 298 |
+
|
| 299 |
+
l *= 2;
|
| 300 |
+
s *= (l <= 1) ? l : 2 - l;
|
| 301 |
+
smin *= lmin <= 1 ? lmin : 2 - lmin;
|
| 302 |
+
const v = (l + s) / 2;
|
| 303 |
+
const sv = l === 0 ? (2 * smin) / (lmin + smin) : (2 * s) / (l + s);
|
| 304 |
+
|
| 305 |
+
return [h, sv * 100, v * 100];
|
| 306 |
+
};
|
| 307 |
+
|
| 308 |
+
convert.hsv.rgb = function (hsv) {
|
| 309 |
+
const h = hsv[0] / 60;
|
| 310 |
+
const s = hsv[1] / 100;
|
| 311 |
+
let v = hsv[2] / 100;
|
| 312 |
+
const hi = Math.floor(h) % 6;
|
| 313 |
+
|
| 314 |
+
const f = h - Math.floor(h);
|
| 315 |
+
const p = 255 * v * (1 - s);
|
| 316 |
+
const q = 255 * v * (1 - (s * f));
|
| 317 |
+
const t = 255 * v * (1 - (s * (1 - f)));
|
| 318 |
+
v *= 255;
|
| 319 |
+
|
| 320 |
+
switch (hi) {
|
| 321 |
+
case 0:
|
| 322 |
+
return [v, t, p];
|
| 323 |
+
case 1:
|
| 324 |
+
return [q, v, p];
|
| 325 |
+
case 2:
|
| 326 |
+
return [p, v, t];
|
| 327 |
+
case 3:
|
| 328 |
+
return [p, q, v];
|
| 329 |
+
case 4:
|
| 330 |
+
return [t, p, v];
|
| 331 |
+
case 5:
|
| 332 |
+
return [v, p, q];
|
| 333 |
+
}
|
| 334 |
+
};
|
| 335 |
+
|
| 336 |
+
convert.hsv.hsl = function (hsv) {
|
| 337 |
+
const h = hsv[0];
|
| 338 |
+
const s = hsv[1] / 100;
|
| 339 |
+
const v = hsv[2] / 100;
|
| 340 |
+
const vmin = Math.max(v, 0.01);
|
| 341 |
+
let sl;
|
| 342 |
+
let l;
|
| 343 |
+
|
| 344 |
+
l = (2 - s) * v;
|
| 345 |
+
const lmin = (2 - s) * vmin;
|
| 346 |
+
sl = s * vmin;
|
| 347 |
+
sl /= (lmin <= 1) ? lmin : 2 - lmin;
|
| 348 |
+
sl = sl || 0;
|
| 349 |
+
l /= 2;
|
| 350 |
+
|
| 351 |
+
return [h, sl * 100, l * 100];
|
| 352 |
+
};
|
| 353 |
+
|
| 354 |
+
// http://dev.w3.org/csswg/css-color/#hwb-to-rgb
|
| 355 |
+
convert.hwb.rgb = function (hwb) {
|
| 356 |
+
const h = hwb[0] / 360;
|
| 357 |
+
let wh = hwb[1] / 100;
|
| 358 |
+
let bl = hwb[2] / 100;
|
| 359 |
+
const ratio = wh + bl;
|
| 360 |
+
let f;
|
| 361 |
+
|
| 362 |
+
// Wh + bl cant be > 1
|
| 363 |
+
if (ratio > 1) {
|
| 364 |
+
wh /= ratio;
|
| 365 |
+
bl /= ratio;
|
| 366 |
+
}
|
| 367 |
+
|
| 368 |
+
const i = Math.floor(6 * h);
|
| 369 |
+
const v = 1 - bl;
|
| 370 |
+
f = 6 * h - i;
|
| 371 |
+
|
| 372 |
+
if ((i & 0x01) !== 0) {
|
| 373 |
+
f = 1 - f;
|
| 374 |
+
}
|
| 375 |
+
|
| 376 |
+
const n = wh + f * (v - wh); // Linear interpolation
|
| 377 |
+
|
| 378 |
+
let r;
|
| 379 |
+
let g;
|
| 380 |
+
let b;
|
| 381 |
+
/* eslint-disable max-statements-per-line,no-multi-spaces */
|
| 382 |
+
switch (i) {
|
| 383 |
+
default:
|
| 384 |
+
case 6:
|
| 385 |
+
case 0: r = v; g = n; b = wh; break;
|
| 386 |
+
case 1: r = n; g = v; b = wh; break;
|
| 387 |
+
case 2: r = wh; g = v; b = n; break;
|
| 388 |
+
case 3: r = wh; g = n; b = v; break;
|
| 389 |
+
case 4: r = n; g = wh; b = v; break;
|
| 390 |
+
case 5: r = v; g = wh; b = n; break;
|
| 391 |
+
}
|
| 392 |
+
/* eslint-enable max-statements-per-line,no-multi-spaces */
|
| 393 |
+
|
| 394 |
+
return [r * 255, g * 255, b * 255];
|
| 395 |
+
};
|
| 396 |
+
|
| 397 |
+
convert.cmyk.rgb = function (cmyk) {
|
| 398 |
+
const c = cmyk[0] / 100;
|
| 399 |
+
const m = cmyk[1] / 100;
|
| 400 |
+
const y = cmyk[2] / 100;
|
| 401 |
+
const k = cmyk[3] / 100;
|
| 402 |
+
|
| 403 |
+
const r = 1 - Math.min(1, c * (1 - k) + k);
|
| 404 |
+
const g = 1 - Math.min(1, m * (1 - k) + k);
|
| 405 |
+
const b = 1 - Math.min(1, y * (1 - k) + k);
|
| 406 |
+
|
| 407 |
+
return [r * 255, g * 255, b * 255];
|
| 408 |
+
};
|
| 409 |
+
|
| 410 |
+
convert.xyz.rgb = function (xyz) {
|
| 411 |
+
const x = xyz[0] / 100;
|
| 412 |
+
const y = xyz[1] / 100;
|
| 413 |
+
const z = xyz[2] / 100;
|
| 414 |
+
let r;
|
| 415 |
+
let g;
|
| 416 |
+
let b;
|
| 417 |
+
|
| 418 |
+
r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986);
|
| 419 |
+
g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415);
|
| 420 |
+
b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570);
|
| 421 |
+
|
| 422 |
+
// Assume sRGB
|
| 423 |
+
r = r > 0.0031308
|
| 424 |
+
? ((1.055 * (r ** (1.0 / 2.4))) - 0.055)
|
| 425 |
+
: r * 12.92;
|
| 426 |
+
|
| 427 |
+
g = g > 0.0031308
|
| 428 |
+
? ((1.055 * (g ** (1.0 / 2.4))) - 0.055)
|
| 429 |
+
: g * 12.92;
|
| 430 |
+
|
| 431 |
+
b = b > 0.0031308
|
| 432 |
+
? ((1.055 * (b ** (1.0 / 2.4))) - 0.055)
|
| 433 |
+
: b * 12.92;
|
| 434 |
+
|
| 435 |
+
r = Math.min(Math.max(0, r), 1);
|
| 436 |
+
g = Math.min(Math.max(0, g), 1);
|
| 437 |
+
b = Math.min(Math.max(0, b), 1);
|
| 438 |
+
|
| 439 |
+
return [r * 255, g * 255, b * 255];
|
| 440 |
+
};
|
| 441 |
+
|
| 442 |
+
convert.xyz.lab = function (xyz) {
|
| 443 |
+
let x = xyz[0];
|
| 444 |
+
let y = xyz[1];
|
| 445 |
+
let z = xyz[2];
|
| 446 |
+
|
| 447 |
+
x /= 95.047;
|
| 448 |
+
y /= 100;
|
| 449 |
+
z /= 108.883;
|
| 450 |
+
|
| 451 |
+
x = x > 0.008856 ? (x ** (1 / 3)) : (7.787 * x) + (16 / 116);
|
| 452 |
+
y = y > 0.008856 ? (y ** (1 / 3)) : (7.787 * y) + (16 / 116);
|
| 453 |
+
z = z > 0.008856 ? (z ** (1 / 3)) : (7.787 * z) + (16 / 116);
|
| 454 |
+
|
| 455 |
+
const l = (116 * y) - 16;
|
| 456 |
+
const a = 500 * (x - y);
|
| 457 |
+
const b = 200 * (y - z);
|
| 458 |
+
|
| 459 |
+
return [l, a, b];
|
| 460 |
+
};
|
| 461 |
+
|
| 462 |
+
convert.lab.xyz = function (lab) {
|
| 463 |
+
const l = lab[0];
|
| 464 |
+
const a = lab[1];
|
| 465 |
+
const b = lab[2];
|
| 466 |
+
let x;
|
| 467 |
+
let y;
|
| 468 |
+
let z;
|
| 469 |
+
|
| 470 |
+
y = (l + 16) / 116;
|
| 471 |
+
x = a / 500 + y;
|
| 472 |
+
z = y - b / 200;
|
| 473 |
+
|
| 474 |
+
const y2 = y ** 3;
|
| 475 |
+
const x2 = x ** 3;
|
| 476 |
+
const z2 = z ** 3;
|
| 477 |
+
y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
|
| 478 |
+
x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
|
| 479 |
+
z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
|
| 480 |
+
|
| 481 |
+
x *= 95.047;
|
| 482 |
+
y *= 100;
|
| 483 |
+
z *= 108.883;
|
| 484 |
+
|
| 485 |
+
return [x, y, z];
|
| 486 |
+
};
|
| 487 |
+
|
| 488 |
+
convert.lab.lch = function (lab) {
|
| 489 |
+
const l = lab[0];
|
| 490 |
+
const a = lab[1];
|
| 491 |
+
const b = lab[2];
|
| 492 |
+
let h;
|
| 493 |
+
|
| 494 |
+
const hr = Math.atan2(b, a);
|
| 495 |
+
h = hr * 360 / 2 / Math.PI;
|
| 496 |
+
|
| 497 |
+
if (h < 0) {
|
| 498 |
+
h += 360;
|
| 499 |
+
}
|
| 500 |
+
|
| 501 |
+
const c = Math.sqrt(a * a + b * b);
|
| 502 |
+
|
| 503 |
+
return [l, c, h];
|
| 504 |
+
};
|
| 505 |
+
|
| 506 |
+
convert.lch.lab = function (lch) {
|
| 507 |
+
const l = lch[0];
|
| 508 |
+
const c = lch[1];
|
| 509 |
+
const h = lch[2];
|
| 510 |
+
|
| 511 |
+
const hr = h / 360 * 2 * Math.PI;
|
| 512 |
+
const a = c * Math.cos(hr);
|
| 513 |
+
const b = c * Math.sin(hr);
|
| 514 |
+
|
| 515 |
+
return [l, a, b];
|
| 516 |
+
};
|
| 517 |
+
|
| 518 |
+
convert.rgb.ansi16 = function (args, saturation = null) {
|
| 519 |
+
const [r, g, b] = args;
|
| 520 |
+
let value = saturation === null ? convert.rgb.hsv(args)[2] : saturation; // Hsv -> ansi16 optimization
|
| 521 |
+
|
| 522 |
+
value = Math.round(value / 50);
|
| 523 |
+
|
| 524 |
+
if (value === 0) {
|
| 525 |
+
return 30;
|
| 526 |
+
}
|
| 527 |
+
|
| 528 |
+
let ansi = 30
|
| 529 |
+
+ ((Math.round(b / 255) << 2)
|
| 530 |
+
| (Math.round(g / 255) << 1)
|
| 531 |
+
| Math.round(r / 255));
|
| 532 |
+
|
| 533 |
+
if (value === 2) {
|
| 534 |
+
ansi += 60;
|
| 535 |
+
}
|
| 536 |
+
|
| 537 |
+
return ansi;
|
| 538 |
+
};
|
| 539 |
+
|
| 540 |
+
convert.hsv.ansi16 = function (args) {
|
| 541 |
+
// Optimization here; we already know the value and don't need to get
|
| 542 |
+
// it converted for us.
|
| 543 |
+
return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
|
| 544 |
+
};
|
| 545 |
+
|
| 546 |
+
convert.rgb.ansi256 = function (args) {
|
| 547 |
+
const r = args[0];
|
| 548 |
+
const g = args[1];
|
| 549 |
+
const b = args[2];
|
| 550 |
+
|
| 551 |
+
// We use the extended greyscale palette here, with the exception of
|
| 552 |
+
// black and white. normal palette only has 4 greyscale shades.
|
| 553 |
+
if (r === g && g === b) {
|
| 554 |
+
if (r < 8) {
|
| 555 |
+
return 16;
|
| 556 |
+
}
|
| 557 |
+
|
| 558 |
+
if (r > 248) {
|
| 559 |
+
return 231;
|
| 560 |
+
}
|
| 561 |
+
|
| 562 |
+
return Math.round(((r - 8) / 247) * 24) + 232;
|
| 563 |
+
}
|
| 564 |
+
|
| 565 |
+
const ansi = 16
|
| 566 |
+
+ (36 * Math.round(r / 255 * 5))
|
| 567 |
+
+ (6 * Math.round(g / 255 * 5))
|
| 568 |
+
+ Math.round(b / 255 * 5);
|
| 569 |
+
|
| 570 |
+
return ansi;
|
| 571 |
+
};
|
| 572 |
+
|
| 573 |
+
convert.ansi16.rgb = function (args) {
|
| 574 |
+
let color = args % 10;
|
| 575 |
+
|
| 576 |
+
// Handle greyscale
|
| 577 |
+
if (color === 0 || color === 7) {
|
| 578 |
+
if (args > 50) {
|
| 579 |
+
color += 3.5;
|
| 580 |
+
}
|
| 581 |
+
|
| 582 |
+
color = color / 10.5 * 255;
|
| 583 |
+
|
| 584 |
+
return [color, color, color];
|
| 585 |
+
}
|
| 586 |
+
|
| 587 |
+
const mult = (~~(args > 50) + 1) * 0.5;
|
| 588 |
+
const r = ((color & 1) * mult) * 255;
|
| 589 |
+
const g = (((color >> 1) & 1) * mult) * 255;
|
| 590 |
+
const b = (((color >> 2) & 1) * mult) * 255;
|
| 591 |
+
|
| 592 |
+
return [r, g, b];
|
| 593 |
+
};
|
| 594 |
+
|
| 595 |
+
convert.ansi256.rgb = function (args) {
|
| 596 |
+
// Handle greyscale
|
| 597 |
+
if (args >= 232) {
|
| 598 |
+
const c = (args - 232) * 10 + 8;
|
| 599 |
+
return [c, c, c];
|
| 600 |
+
}
|
| 601 |
+
|
| 602 |
+
args -= 16;
|
| 603 |
+
|
| 604 |
+
let rem;
|
| 605 |
+
const r = Math.floor(args / 36) / 5 * 255;
|
| 606 |
+
const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
|
| 607 |
+
const b = (rem % 6) / 5 * 255;
|
| 608 |
+
|
| 609 |
+
return [r, g, b];
|
| 610 |
+
};
|
| 611 |
+
|
| 612 |
+
convert.rgb.hex = function (args) {
|
| 613 |
+
const integer = ((Math.round(args[0]) & 0xFF) << 16)
|
| 614 |
+
+ ((Math.round(args[1]) & 0xFF) << 8)
|
| 615 |
+
+ (Math.round(args[2]) & 0xFF);
|
| 616 |
+
|
| 617 |
+
const string = integer.toString(16).toUpperCase();
|
| 618 |
+
return '000000'.substring(string.length) + string;
|
| 619 |
+
};
|
| 620 |
+
|
| 621 |
+
convert.hex.rgb = function (args) {
|
| 622 |
+
const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
|
| 623 |
+
if (!match) {
|
| 624 |
+
return [0, 0, 0];
|
| 625 |
+
}
|
| 626 |
+
|
| 627 |
+
let colorString = match[0];
|
| 628 |
+
|
| 629 |
+
if (match[0].length === 3) {
|
| 630 |
+
colorString = colorString.split('').map(char => {
|
| 631 |
+
return char + char;
|
| 632 |
+
}).join('');
|
| 633 |
+
}
|
| 634 |
+
|
| 635 |
+
const integer = parseInt(colorString, 16);
|
| 636 |
+
const r = (integer >> 16) & 0xFF;
|
| 637 |
+
const g = (integer >> 8) & 0xFF;
|
| 638 |
+
const b = integer & 0xFF;
|
| 639 |
+
|
| 640 |
+
return [r, g, b];
|
| 641 |
+
};
|
| 642 |
+
|
| 643 |
+
convert.rgb.hcg = function (rgb) {
|
| 644 |
+
const r = rgb[0] / 255;
|
| 645 |
+
const g = rgb[1] / 255;
|
| 646 |
+
const b = rgb[2] / 255;
|
| 647 |
+
const max = Math.max(Math.max(r, g), b);
|
| 648 |
+
const min = Math.min(Math.min(r, g), b);
|
| 649 |
+
const chroma = (max - min);
|
| 650 |
+
let grayscale;
|
| 651 |
+
let hue;
|
| 652 |
+
|
| 653 |
+
if (chroma < 1) {
|
| 654 |
+
grayscale = min / (1 - chroma);
|
| 655 |
+
} else {
|
| 656 |
+
grayscale = 0;
|
| 657 |
+
}
|
| 658 |
+
|
| 659 |
+
if (chroma <= 0) {
|
| 660 |
+
hue = 0;
|
| 661 |
+
} else
|
| 662 |
+
if (max === r) {
|
| 663 |
+
hue = ((g - b) / chroma) % 6;
|
| 664 |
+
} else
|
| 665 |
+
if (max === g) {
|
| 666 |
+
hue = 2 + (b - r) / chroma;
|
| 667 |
+
} else {
|
| 668 |
+
hue = 4 + (r - g) / chroma;
|
| 669 |
+
}
|
| 670 |
+
|
| 671 |
+
hue /= 6;
|
| 672 |
+
hue %= 1;
|
| 673 |
+
|
| 674 |
+
return [hue * 360, chroma * 100, grayscale * 100];
|
| 675 |
+
};
|
| 676 |
+
|
| 677 |
+
convert.hsl.hcg = function (hsl) {
|
| 678 |
+
const s = hsl[1] / 100;
|
| 679 |
+
const l = hsl[2] / 100;
|
| 680 |
+
|
| 681 |
+
const c = l < 0.5 ? (2.0 * s * l) : (2.0 * s * (1.0 - l));
|
| 682 |
+
|
| 683 |
+
let f = 0;
|
| 684 |
+
if (c < 1.0) {
|
| 685 |
+
f = (l - 0.5 * c) / (1.0 - c);
|
| 686 |
+
}
|
| 687 |
+
|
| 688 |
+
return [hsl[0], c * 100, f * 100];
|
| 689 |
+
};
|
| 690 |
+
|
| 691 |
+
convert.hsv.hcg = function (hsv) {
|
| 692 |
+
const s = hsv[1] / 100;
|
| 693 |
+
const v = hsv[2] / 100;
|
| 694 |
+
|
| 695 |
+
const c = s * v;
|
| 696 |
+
let f = 0;
|
| 697 |
+
|
| 698 |
+
if (c < 1.0) {
|
| 699 |
+
f = (v - c) / (1 - c);
|
| 700 |
+
}
|
| 701 |
+
|
| 702 |
+
return [hsv[0], c * 100, f * 100];
|
| 703 |
+
};
|
| 704 |
+
|
| 705 |
+
convert.hcg.rgb = function (hcg) {
|
| 706 |
+
const h = hcg[0] / 360;
|
| 707 |
+
const c = hcg[1] / 100;
|
| 708 |
+
const g = hcg[2] / 100;
|
| 709 |
+
|
| 710 |
+
if (c === 0.0) {
|
| 711 |
+
return [g * 255, g * 255, g * 255];
|
| 712 |
+
}
|
| 713 |
+
|
| 714 |
+
const pure = [0, 0, 0];
|
| 715 |
+
const hi = (h % 1) * 6;
|
| 716 |
+
const v = hi % 1;
|
| 717 |
+
const w = 1 - v;
|
| 718 |
+
let mg = 0;
|
| 719 |
+
|
| 720 |
+
/* eslint-disable max-statements-per-line */
|
| 721 |
+
switch (Math.floor(hi)) {
|
| 722 |
+
case 0:
|
| 723 |
+
pure[0] = 1; pure[1] = v; pure[2] = 0; break;
|
| 724 |
+
case 1:
|
| 725 |
+
pure[0] = w; pure[1] = 1; pure[2] = 0; break;
|
| 726 |
+
case 2:
|
| 727 |
+
pure[0] = 0; pure[1] = 1; pure[2] = v; break;
|
| 728 |
+
case 3:
|
| 729 |
+
pure[0] = 0; pure[1] = w; pure[2] = 1; break;
|
| 730 |
+
case 4:
|
| 731 |
+
pure[0] = v; pure[1] = 0; pure[2] = 1; break;
|
| 732 |
+
default:
|
| 733 |
+
pure[0] = 1; pure[1] = 0; pure[2] = w;
|
| 734 |
+
}
|
| 735 |
+
/* eslint-enable max-statements-per-line */
|
| 736 |
+
|
| 737 |
+
mg = (1.0 - c) * g;
|
| 738 |
+
|
| 739 |
+
return [
|
| 740 |
+
(c * pure[0] + mg) * 255,
|
| 741 |
+
(c * pure[1] + mg) * 255,
|
| 742 |
+
(c * pure[2] + mg) * 255
|
| 743 |
+
];
|
| 744 |
+
};
|
| 745 |
+
|
| 746 |
+
convert.hcg.hsv = function (hcg) {
|
| 747 |
+
const c = hcg[1] / 100;
|
| 748 |
+
const g = hcg[2] / 100;
|
| 749 |
+
|
| 750 |
+
const v = c + g * (1.0 - c);
|
| 751 |
+
let f = 0;
|
| 752 |
+
|
| 753 |
+
if (v > 0.0) {
|
| 754 |
+
f = c / v;
|
| 755 |
+
}
|
| 756 |
+
|
| 757 |
+
return [hcg[0], f * 100, v * 100];
|
| 758 |
+
};
|
| 759 |
+
|
| 760 |
+
convert.hcg.hsl = function (hcg) {
|
| 761 |
+
const c = hcg[1] / 100;
|
| 762 |
+
const g = hcg[2] / 100;
|
| 763 |
+
|
| 764 |
+
const l = g * (1.0 - c) + 0.5 * c;
|
| 765 |
+
let s = 0;
|
| 766 |
+
|
| 767 |
+
if (l > 0.0 && l < 0.5) {
|
| 768 |
+
s = c / (2 * l);
|
| 769 |
+
} else
|
| 770 |
+
if (l >= 0.5 && l < 1.0) {
|
| 771 |
+
s = c / (2 * (1 - l));
|
| 772 |
+
}
|
| 773 |
+
|
| 774 |
+
return [hcg[0], s * 100, l * 100];
|
| 775 |
+
};
|
| 776 |
+
|
| 777 |
+
convert.hcg.hwb = function (hcg) {
|
| 778 |
+
const c = hcg[1] / 100;
|
| 779 |
+
const g = hcg[2] / 100;
|
| 780 |
+
const v = c + g * (1.0 - c);
|
| 781 |
+
return [hcg[0], (v - c) * 100, (1 - v) * 100];
|
| 782 |
+
};
|
| 783 |
+
|
| 784 |
+
convert.hwb.hcg = function (hwb) {
|
| 785 |
+
const w = hwb[1] / 100;
|
| 786 |
+
const b = hwb[2] / 100;
|
| 787 |
+
const v = 1 - b;
|
| 788 |
+
const c = v - w;
|
| 789 |
+
let g = 0;
|
| 790 |
+
|
| 791 |
+
if (c < 1) {
|
| 792 |
+
g = (v - c) / (1 - c);
|
| 793 |
+
}
|
| 794 |
+
|
| 795 |
+
return [hwb[0], c * 100, g * 100];
|
| 796 |
+
};
|
| 797 |
+
|
| 798 |
+
convert.apple.rgb = function (apple) {
|
| 799 |
+
return [(apple[0] / 65535) * 255, (apple[1] / 65535) * 255, (apple[2] / 65535) * 255];
|
| 800 |
+
};
|
| 801 |
+
|
| 802 |
+
convert.rgb.apple = function (rgb) {
|
| 803 |
+
return [(rgb[0] / 255) * 65535, (rgb[1] / 255) * 65535, (rgb[2] / 255) * 65535];
|
| 804 |
+
};
|
| 805 |
+
|
| 806 |
+
convert.gray.rgb = function (args) {
|
| 807 |
+
return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
|
| 808 |
+
};
|
| 809 |
+
|
| 810 |
+
convert.gray.hsl = function (args) {
|
| 811 |
+
return [0, 0, args[0]];
|
| 812 |
+
};
|
| 813 |
+
|
| 814 |
+
convert.gray.hsv = convert.gray.hsl;
|
| 815 |
+
|
| 816 |
+
convert.gray.hwb = function (gray) {
|
| 817 |
+
return [0, 100, gray[0]];
|
| 818 |
+
};
|
| 819 |
+
|
| 820 |
+
convert.gray.cmyk = function (gray) {
|
| 821 |
+
return [0, 0, 0, gray[0]];
|
| 822 |
+
};
|
| 823 |
+
|
| 824 |
+
convert.gray.lab = function (gray) {
|
| 825 |
+
return [gray[0], 0, 0];
|
| 826 |
+
};
|
| 827 |
+
|
| 828 |
+
convert.gray.hex = function (gray) {
|
| 829 |
+
const val = Math.round(gray[0] / 100 * 255) & 0xFF;
|
| 830 |
+
const integer = (val << 16) + (val << 8) + val;
|
| 831 |
+
|
| 832 |
+
const string = integer.toString(16).toUpperCase();
|
| 833 |
+
return '000000'.substring(string.length) + string;
|
| 834 |
+
};
|
| 835 |
+
|
| 836 |
+
convert.rgb.gray = function (rgb) {
|
| 837 |
+
const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
|
| 838 |
+
return [val / 255 * 100];
|
| 839 |
+
};
|
worker/node_modules/color-convert/index.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const conversions = require('./conversions');
|
| 2 |
+
const route = require('./route');
|
| 3 |
+
|
| 4 |
+
const convert = {};
|
| 5 |
+
|
| 6 |
+
const models = Object.keys(conversions);
|
| 7 |
+
|
| 8 |
+
function wrapRaw(fn) {
|
| 9 |
+
const wrappedFn = function (...args) {
|
| 10 |
+
const arg0 = args[0];
|
| 11 |
+
if (arg0 === undefined || arg0 === null) {
|
| 12 |
+
return arg0;
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
if (arg0.length > 1) {
|
| 16 |
+
args = arg0;
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
return fn(args);
|
| 20 |
+
};
|
| 21 |
+
|
| 22 |
+
// Preserve .conversion property if there is one
|
| 23 |
+
if ('conversion' in fn) {
|
| 24 |
+
wrappedFn.conversion = fn.conversion;
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
return wrappedFn;
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
function wrapRounded(fn) {
|
| 31 |
+
const wrappedFn = function (...args) {
|
| 32 |
+
const arg0 = args[0];
|
| 33 |
+
|
| 34 |
+
if (arg0 === undefined || arg0 === null) {
|
| 35 |
+
return arg0;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
if (arg0.length > 1) {
|
| 39 |
+
args = arg0;
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
const result = fn(args);
|
| 43 |
+
|
| 44 |
+
// We're assuming the result is an array here.
|
| 45 |
+
// see notice in conversions.js; don't use box types
|
| 46 |
+
// in conversion functions.
|
| 47 |
+
if (typeof result === 'object') {
|
| 48 |
+
for (let len = result.length, i = 0; i < len; i++) {
|
| 49 |
+
result[i] = Math.round(result[i]);
|
| 50 |
+
}
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
return result;
|
| 54 |
+
};
|
| 55 |
+
|
| 56 |
+
// Preserve .conversion property if there is one
|
| 57 |
+
if ('conversion' in fn) {
|
| 58 |
+
wrappedFn.conversion = fn.conversion;
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
return wrappedFn;
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
models.forEach(fromModel => {
|
| 65 |
+
convert[fromModel] = {};
|
| 66 |
+
|
| 67 |
+
Object.defineProperty(convert[fromModel], 'channels', {value: conversions[fromModel].channels});
|
| 68 |
+
Object.defineProperty(convert[fromModel], 'labels', {value: conversions[fromModel].labels});
|
| 69 |
+
|
| 70 |
+
const routes = route(fromModel);
|
| 71 |
+
const routeModels = Object.keys(routes);
|
| 72 |
+
|
| 73 |
+
routeModels.forEach(toModel => {
|
| 74 |
+
const fn = routes[toModel];
|
| 75 |
+
|
| 76 |
+
convert[fromModel][toModel] = wrapRounded(fn);
|
| 77 |
+
convert[fromModel][toModel].raw = wrapRaw(fn);
|
| 78 |
+
});
|
| 79 |
+
});
|
| 80 |
+
|
| 81 |
+
module.exports = convert;
|
worker/node_modules/color-convert/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "color-convert",
|
| 3 |
+
"description": "Plain color conversion functions",
|
| 4 |
+
"version": "2.0.1",
|
| 5 |
+
"author": "Heather Arthur <fayearthur@gmail.com>",
|
| 6 |
+
"license": "MIT",
|
| 7 |
+
"repository": "Qix-/color-convert",
|
| 8 |
+
"scripts": {
|
| 9 |
+
"pretest": "xo",
|
| 10 |
+
"test": "node test/basic.js"
|
| 11 |
+
},
|
| 12 |
+
"engines": {
|
| 13 |
+
"node": ">=7.0.0"
|
| 14 |
+
},
|
| 15 |
+
"keywords": [
|
| 16 |
+
"color",
|
| 17 |
+
"colour",
|
| 18 |
+
"convert",
|
| 19 |
+
"converter",
|
| 20 |
+
"conversion",
|
| 21 |
+
"rgb",
|
| 22 |
+
"hsl",
|
| 23 |
+
"hsv",
|
| 24 |
+
"hwb",
|
| 25 |
+
"cmyk",
|
| 26 |
+
"ansi",
|
| 27 |
+
"ansi16"
|
| 28 |
+
],
|
| 29 |
+
"files": [
|
| 30 |
+
"index.js",
|
| 31 |
+
"conversions.js",
|
| 32 |
+
"route.js"
|
| 33 |
+
],
|
| 34 |
+
"xo": {
|
| 35 |
+
"rules": {
|
| 36 |
+
"default-case": 0,
|
| 37 |
+
"no-inline-comments": 0,
|
| 38 |
+
"operator-linebreak": 0
|
| 39 |
+
}
|
| 40 |
+
},
|
| 41 |
+
"devDependencies": {
|
| 42 |
+
"chalk": "^2.4.2",
|
| 43 |
+
"xo": "^0.24.0"
|
| 44 |
+
},
|
| 45 |
+
"dependencies": {
|
| 46 |
+
"color-name": "~1.1.4"
|
| 47 |
+
}
|
| 48 |
+
}
|
worker/node_modules/color-convert/route.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const conversions = require('./conversions');
|
| 2 |
+
|
| 3 |
+
/*
|
| 4 |
+
This function routes a model to all other models.
|
| 5 |
+
|
| 6 |
+
all functions that are routed have a property `.conversion` attached
|
| 7 |
+
to the returned synthetic function. This property is an array
|
| 8 |
+
of strings, each with the steps in between the 'from' and 'to'
|
| 9 |
+
color models (inclusive).
|
| 10 |
+
|
| 11 |
+
conversions that are not possible simply are not included.
|
| 12 |
+
*/
|
| 13 |
+
|
| 14 |
+
function buildGraph() {
|
| 15 |
+
const graph = {};
|
| 16 |
+
// https://jsperf.com/object-keys-vs-for-in-with-closure/3
|
| 17 |
+
const models = Object.keys(conversions);
|
| 18 |
+
|
| 19 |
+
for (let len = models.length, i = 0; i < len; i++) {
|
| 20 |
+
graph[models[i]] = {
|
| 21 |
+
// http://jsperf.com/1-vs-infinity
|
| 22 |
+
// micro-opt, but this is simple.
|
| 23 |
+
distance: -1,
|
| 24 |
+
parent: null
|
| 25 |
+
};
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
return graph;
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
// https://en.wikipedia.org/wiki/Breadth-first_search
|
| 32 |
+
function deriveBFS(fromModel) {
|
| 33 |
+
const graph = buildGraph();
|
| 34 |
+
const queue = [fromModel]; // Unshift -> queue -> pop
|
| 35 |
+
|
| 36 |
+
graph[fromModel].distance = 0;
|
| 37 |
+
|
| 38 |
+
while (queue.length) {
|
| 39 |
+
const current = queue.pop();
|
| 40 |
+
const adjacents = Object.keys(conversions[current]);
|
| 41 |
+
|
| 42 |
+
for (let len = adjacents.length, i = 0; i < len; i++) {
|
| 43 |
+
const adjacent = adjacents[i];
|
| 44 |
+
const node = graph[adjacent];
|
| 45 |
+
|
| 46 |
+
if (node.distance === -1) {
|
| 47 |
+
node.distance = graph[current].distance + 1;
|
| 48 |
+
node.parent = current;
|
| 49 |
+
queue.unshift(adjacent);
|
| 50 |
+
}
|
| 51 |
+
}
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
return graph;
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
function link(from, to) {
|
| 58 |
+
return function (args) {
|
| 59 |
+
return to(from(args));
|
| 60 |
+
};
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
function wrapConversion(toModel, graph) {
|
| 64 |
+
const path = [graph[toModel].parent, toModel];
|
| 65 |
+
let fn = conversions[graph[toModel].parent][toModel];
|
| 66 |
+
|
| 67 |
+
let cur = graph[toModel].parent;
|
| 68 |
+
while (graph[cur].parent) {
|
| 69 |
+
path.unshift(graph[cur].parent);
|
| 70 |
+
fn = link(conversions[graph[cur].parent][cur], fn);
|
| 71 |
+
cur = graph[cur].parent;
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
fn.conversion = path;
|
| 75 |
+
return fn;
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
module.exports = function (fromModel) {
|
| 79 |
+
const graph = deriveBFS(fromModel);
|
| 80 |
+
const conversion = {};
|
| 81 |
+
|
| 82 |
+
const models = Object.keys(graph);
|
| 83 |
+
for (let len = models.length, i = 0; i < len; i++) {
|
| 84 |
+
const toModel = models[i];
|
| 85 |
+
const node = graph[toModel];
|
| 86 |
+
|
| 87 |
+
if (node.parent === null) {
|
| 88 |
+
// No possible conversion, or this node is the source model.
|
| 89 |
+
continue;
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
conversion[toModel] = wrapConversion(toModel, graph);
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
return conversion;
|
| 96 |
+
};
|
| 97 |
+
|
worker/node_modules/color-name/LICENSE
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
The MIT License (MIT)
|
| 2 |
+
Copyright (c) 2015 Dmitry Ivanov
|
| 3 |
+
|
| 4 |
+
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:
|
| 5 |
+
|
| 6 |
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
| 7 |
+
|
| 8 |
+
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.
|
worker/node_modules/color-name/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
A JSON with color names and its values. Based on http://dev.w3.org/csswg/css-color/#named-colors.
|
| 2 |
+
|
| 3 |
+
[](https://nodei.co/npm/color-name/)
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
```js
|
| 7 |
+
var colors = require('color-name');
|
| 8 |
+
colors.red //[255,0,0]
|
| 9 |
+
```
|
| 10 |
+
|
| 11 |
+
<a href="LICENSE"><img src="https://upload.wikimedia.org/wikipedia/commons/0/0c/MIT_logo.svg" width="120"/></a>
|
worker/node_modules/color-name/index.js
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict'
|
| 2 |
+
|
| 3 |
+
module.exports = {
|
| 4 |
+
"aliceblue": [240, 248, 255],
|
| 5 |
+
"antiquewhite": [250, 235, 215],
|
| 6 |
+
"aqua": [0, 255, 255],
|
| 7 |
+
"aquamarine": [127, 255, 212],
|
| 8 |
+
"azure": [240, 255, 255],
|
| 9 |
+
"beige": [245, 245, 220],
|
| 10 |
+
"bisque": [255, 228, 196],
|
| 11 |
+
"black": [0, 0, 0],
|
| 12 |
+
"blanchedalmond": [255, 235, 205],
|
| 13 |
+
"blue": [0, 0, 255],
|
| 14 |
+
"blueviolet": [138, 43, 226],
|
| 15 |
+
"brown": [165, 42, 42],
|
| 16 |
+
"burlywood": [222, 184, 135],
|
| 17 |
+
"cadetblue": [95, 158, 160],
|
| 18 |
+
"chartreuse": [127, 255, 0],
|
| 19 |
+
"chocolate": [210, 105, 30],
|
| 20 |
+
"coral": [255, 127, 80],
|
| 21 |
+
"cornflowerblue": [100, 149, 237],
|
| 22 |
+
"cornsilk": [255, 248, 220],
|
| 23 |
+
"crimson": [220, 20, 60],
|
| 24 |
+
"cyan": [0, 255, 255],
|
| 25 |
+
"darkblue": [0, 0, 139],
|
| 26 |
+
"darkcyan": [0, 139, 139],
|
| 27 |
+
"darkgoldenrod": [184, 134, 11],
|
| 28 |
+
"darkgray": [169, 169, 169],
|
| 29 |
+
"darkgreen": [0, 100, 0],
|
| 30 |
+
"darkgrey": [169, 169, 169],
|
| 31 |
+
"darkkhaki": [189, 183, 107],
|
| 32 |
+
"darkmagenta": [139, 0, 139],
|
| 33 |
+
"darkolivegreen": [85, 107, 47],
|
| 34 |
+
"darkorange": [255, 140, 0],
|
| 35 |
+
"darkorchid": [153, 50, 204],
|
| 36 |
+
"darkred": [139, 0, 0],
|
| 37 |
+
"darksalmon": [233, 150, 122],
|
| 38 |
+
"darkseagreen": [143, 188, 143],
|
| 39 |
+
"darkslateblue": [72, 61, 139],
|
| 40 |
+
"darkslategray": [47, 79, 79],
|
| 41 |
+
"darkslategrey": [47, 79, 79],
|
| 42 |
+
"darkturquoise": [0, 206, 209],
|
| 43 |
+
"darkviolet": [148, 0, 211],
|
| 44 |
+
"deeppink": [255, 20, 147],
|
| 45 |
+
"deepskyblue": [0, 191, 255],
|
| 46 |
+
"dimgray": [105, 105, 105],
|
| 47 |
+
"dimgrey": [105, 105, 105],
|
| 48 |
+
"dodgerblue": [30, 144, 255],
|
| 49 |
+
"firebrick": [178, 34, 34],
|
| 50 |
+
"floralwhite": [255, 250, 240],
|
| 51 |
+
"forestgreen": [34, 139, 34],
|
| 52 |
+
"fuchsia": [255, 0, 255],
|
| 53 |
+
"gainsboro": [220, 220, 220],
|
| 54 |
+
"ghostwhite": [248, 248, 255],
|
| 55 |
+
"gold": [255, 215, 0],
|
| 56 |
+
"goldenrod": [218, 165, 32],
|
| 57 |
+
"gray": [128, 128, 128],
|
| 58 |
+
"green": [0, 128, 0],
|
| 59 |
+
"greenyellow": [173, 255, 47],
|
| 60 |
+
"grey": [128, 128, 128],
|
| 61 |
+
"honeydew": [240, 255, 240],
|
| 62 |
+
"hotpink": [255, 105, 180],
|
| 63 |
+
"indianred": [205, 92, 92],
|
| 64 |
+
"indigo": [75, 0, 130],
|
| 65 |
+
"ivory": [255, 255, 240],
|
| 66 |
+
"khaki": [240, 230, 140],
|
| 67 |
+
"lavender": [230, 230, 250],
|
| 68 |
+
"lavenderblush": [255, 240, 245],
|
| 69 |
+
"lawngreen": [124, 252, 0],
|
| 70 |
+
"lemonchiffon": [255, 250, 205],
|
| 71 |
+
"lightblue": [173, 216, 230],
|
| 72 |
+
"lightcoral": [240, 128, 128],
|
| 73 |
+
"lightcyan": [224, 255, 255],
|
| 74 |
+
"lightgoldenrodyellow": [250, 250, 210],
|
| 75 |
+
"lightgray": [211, 211, 211],
|
| 76 |
+
"lightgreen": [144, 238, 144],
|
| 77 |
+
"lightgrey": [211, 211, 211],
|
| 78 |
+
"lightpink": [255, 182, 193],
|
| 79 |
+
"lightsalmon": [255, 160, 122],
|
| 80 |
+
"lightseagreen": [32, 178, 170],
|
| 81 |
+
"lightskyblue": [135, 206, 250],
|
| 82 |
+
"lightslategray": [119, 136, 153],
|
| 83 |
+
"lightslategrey": [119, 136, 153],
|
| 84 |
+
"lightsteelblue": [176, 196, 222],
|
| 85 |
+
"lightyellow": [255, 255, 224],
|
| 86 |
+
"lime": [0, 255, 0],
|
| 87 |
+
"limegreen": [50, 205, 50],
|
| 88 |
+
"linen": [250, 240, 230],
|
| 89 |
+
"magenta": [255, 0, 255],
|
| 90 |
+
"maroon": [128, 0, 0],
|
| 91 |
+
"mediumaquamarine": [102, 205, 170],
|
| 92 |
+
"mediumblue": [0, 0, 205],
|
| 93 |
+
"mediumorchid": [186, 85, 211],
|
| 94 |
+
"mediumpurple": [147, 112, 219],
|
| 95 |
+
"mediumseagreen": [60, 179, 113],
|
| 96 |
+
"mediumslateblue": [123, 104, 238],
|
| 97 |
+
"mediumspringgreen": [0, 250, 154],
|
| 98 |
+
"mediumturquoise": [72, 209, 204],
|
| 99 |
+
"mediumvioletred": [199, 21, 133],
|
| 100 |
+
"midnightblue": [25, 25, 112],
|
| 101 |
+
"mintcream": [245, 255, 250],
|
| 102 |
+
"mistyrose": [255, 228, 225],
|
| 103 |
+
"moccasin": [255, 228, 181],
|
| 104 |
+
"navajowhite": [255, 222, 173],
|
| 105 |
+
"navy": [0, 0, 128],
|
| 106 |
+
"oldlace": [253, 245, 230],
|
| 107 |
+
"olive": [128, 128, 0],
|
| 108 |
+
"olivedrab": [107, 142, 35],
|
| 109 |
+
"orange": [255, 165, 0],
|
| 110 |
+
"orangered": [255, 69, 0],
|
| 111 |
+
"orchid": [218, 112, 214],
|
| 112 |
+
"palegoldenrod": [238, 232, 170],
|
| 113 |
+
"palegreen": [152, 251, 152],
|
| 114 |
+
"paleturquoise": [175, 238, 238],
|
| 115 |
+
"palevioletred": [219, 112, 147],
|
| 116 |
+
"papayawhip": [255, 239, 213],
|
| 117 |
+
"peachpuff": [255, 218, 185],
|
| 118 |
+
"peru": [205, 133, 63],
|
| 119 |
+
"pink": [255, 192, 203],
|
| 120 |
+
"plum": [221, 160, 221],
|
| 121 |
+
"powderblue": [176, 224, 230],
|
| 122 |
+
"purple": [128, 0, 128],
|
| 123 |
+
"rebeccapurple": [102, 51, 153],
|
| 124 |
+
"red": [255, 0, 0],
|
| 125 |
+
"rosybrown": [188, 143, 143],
|
| 126 |
+
"royalblue": [65, 105, 225],
|
| 127 |
+
"saddlebrown": [139, 69, 19],
|
| 128 |
+
"salmon": [250, 128, 114],
|
| 129 |
+
"sandybrown": [244, 164, 96],
|
| 130 |
+
"seagreen": [46, 139, 87],
|
| 131 |
+
"seashell": [255, 245, 238],
|
| 132 |
+
"sienna": [160, 82, 45],
|
| 133 |
+
"silver": [192, 192, 192],
|
| 134 |
+
"skyblue": [135, 206, 235],
|
| 135 |
+
"slateblue": [106, 90, 205],
|
| 136 |
+
"slategray": [112, 128, 144],
|
| 137 |
+
"slategrey": [112, 128, 144],
|
| 138 |
+
"snow": [255, 250, 250],
|
| 139 |
+
"springgreen": [0, 255, 127],
|
| 140 |
+
"steelblue": [70, 130, 180],
|
| 141 |
+
"tan": [210, 180, 140],
|
| 142 |
+
"teal": [0, 128, 128],
|
| 143 |
+
"thistle": [216, 191, 216],
|
| 144 |
+
"tomato": [255, 99, 71],
|
| 145 |
+
"turquoise": [64, 224, 208],
|
| 146 |
+
"violet": [238, 130, 238],
|
| 147 |
+
"wheat": [245, 222, 179],
|
| 148 |
+
"white": [255, 255, 255],
|
| 149 |
+
"whitesmoke": [245, 245, 245],
|
| 150 |
+
"yellow": [255, 255, 0],
|
| 151 |
+
"yellowgreen": [154, 205, 50]
|
| 152 |
+
};
|
worker/node_modules/color-name/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "color-name",
|
| 3 |
+
"version": "1.1.4",
|
| 4 |
+
"description": "A list of color names and its values",
|
| 5 |
+
"main": "index.js",
|
| 6 |
+
"files": [
|
| 7 |
+
"index.js"
|
| 8 |
+
],
|
| 9 |
+
"scripts": {
|
| 10 |
+
"test": "node test.js"
|
| 11 |
+
},
|
| 12 |
+
"repository": {
|
| 13 |
+
"type": "git",
|
| 14 |
+
"url": "git@github.com:colorjs/color-name.git"
|
| 15 |
+
},
|
| 16 |
+
"keywords": [
|
| 17 |
+
"color-name",
|
| 18 |
+
"color",
|
| 19 |
+
"color-keyword",
|
| 20 |
+
"keyword"
|
| 21 |
+
],
|
| 22 |
+
"author": "DY <dfcreative@gmail.com>",
|
| 23 |
+
"license": "MIT",
|
| 24 |
+
"bugs": {
|
| 25 |
+
"url": "https://github.com/colorjs/color-name/issues"
|
| 26 |
+
},
|
| 27 |
+
"homepage": "https://github.com/colorjs/color-name"
|
| 28 |
+
}
|
worker/node_modules/color-string/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Copyright (c) 2011 Heather Arthur <fayearthur@gmail.com>
|
| 2 |
+
|
| 3 |
+
Permission is hereby granted, free of charge, to any person obtaining
|
| 4 |
+
a copy of this software and associated documentation files (the
|
| 5 |
+
"Software"), to deal in the Software without restriction, including
|
| 6 |
+
without limitation the rights to use, copy, modify, merge, publish,
|
| 7 |
+
distribute, sublicense, and/or sell copies of the Software, and to
|
| 8 |
+
permit persons to whom the Software is furnished to do so, subject to
|
| 9 |
+
the following conditions:
|
| 10 |
+
|
| 11 |
+
The above copyright notice and this permission notice shall be
|
| 12 |
+
included in all copies or substantial portions of the Software.
|
| 13 |
+
|
| 14 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 15 |
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
| 16 |
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 17 |
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
| 18 |
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
| 19 |
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
| 20 |
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
| 21 |
+
|
worker/node_modules/color-string/README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# color-string
|
| 2 |
+
|
| 3 |
+
> library for parsing and generating CSS color strings.
|
| 4 |
+
|
| 5 |
+
## Install
|
| 6 |
+
|
| 7 |
+
With [npm](http://npmjs.org/):
|
| 8 |
+
|
| 9 |
+
```console
|
| 10 |
+
$ npm install color-string
|
| 11 |
+
```
|
| 12 |
+
|
| 13 |
+
## Usage
|
| 14 |
+
|
| 15 |
+
### Parsing
|
| 16 |
+
|
| 17 |
+
```js
|
| 18 |
+
colorString.get('#FFF') // {model: 'rgb', value: [255, 255, 255, 1]}
|
| 19 |
+
colorString.get('#FFFA') // {model: 'rgb', value: [255, 255, 255, 0.67]}
|
| 20 |
+
colorString.get('#FFFFFFAA') // {model: 'rgb', value: [255, 255, 255, 0.67]}
|
| 21 |
+
colorString.get('hsl(360, 100%, 50%)') // {model: 'hsl', value: [0, 100, 50, 1]}
|
| 22 |
+
colorString.get('hsl(360 100% 50%)') // {model: 'hsl', value: [0, 100, 50, 1]}
|
| 23 |
+
colorString.get('hwb(60, 3%, 60%)') // {model: 'hwb', value: [60, 3, 60, 1]}
|
| 24 |
+
|
| 25 |
+
colorString.get.rgb('#FFF') // [255, 255, 255, 1]
|
| 26 |
+
colorString.get.rgb('blue') // [0, 0, 255, 1]
|
| 27 |
+
colorString.get.rgb('rgba(200, 60, 60, 0.3)') // [200, 60, 60, 0.3]
|
| 28 |
+
colorString.get.rgb('rgba(200 60 60 / 0.3)') // [200, 60, 60, 0.3]
|
| 29 |
+
colorString.get.rgb('rgba(200 60 60 / 30%)') // [200, 60, 60, 0.3]
|
| 30 |
+
colorString.get.rgb('rgb(200, 200, 200)') // [200, 200, 200, 1]
|
| 31 |
+
colorString.get.rgb('rgb(200 200 200)') // [200, 200, 200, 1]
|
| 32 |
+
|
| 33 |
+
colorString.get.hsl('hsl(360, 100%, 50%)') // [0, 100, 50, 1]
|
| 34 |
+
colorString.get.hsl('hsl(360 100% 50%)') // [0, 100, 50, 1]
|
| 35 |
+
colorString.get.hsl('hsla(360, 60%, 50%, 0.4)') // [0, 60, 50, 0.4]
|
| 36 |
+
colorString.get.hsl('hsl(360 60% 50% / 0.4)') // [0, 60, 50, 0.4]
|
| 37 |
+
|
| 38 |
+
colorString.get.hwb('hwb(60, 3%, 60%)') // [60, 3, 60, 1]
|
| 39 |
+
colorString.get.hwb('hwb(60, 3%, 60%, 0.6)') // [60, 3, 60, 0.6]
|
| 40 |
+
|
| 41 |
+
colorString.get.rgb('invalid color string') // null
|
| 42 |
+
```
|
| 43 |
+
|
| 44 |
+
### Generation
|
| 45 |
+
|
| 46 |
+
```js
|
| 47 |
+
colorString.to.hex([255, 255, 255]) // "#FFFFFF"
|
| 48 |
+
colorString.to.hex([0, 0, 255, 0.4]) // "#0000FF66"
|
| 49 |
+
colorString.to.hex([0, 0, 255], 0.4) // "#0000FF66"
|
| 50 |
+
colorString.to.rgb([255, 255, 255]) // "rgb(255, 255, 255)"
|
| 51 |
+
colorString.to.rgb([0, 0, 255, 0.4]) // "rgba(0, 0, 255, 0.4)"
|
| 52 |
+
colorString.to.rgb([0, 0, 255], 0.4) // "rgba(0, 0, 255, 0.4)"
|
| 53 |
+
colorString.to.rgb.percent([0, 0, 255]) // "rgb(0%, 0%, 100%)"
|
| 54 |
+
colorString.to.keyword([255, 255, 0]) // "yellow"
|
| 55 |
+
colorString.to.hsl([360, 100, 100]) // "hsl(360, 100%, 100%)"
|
| 56 |
+
colorString.to.hwb([50, 3, 15]) // "hwb(50, 3%, 15%)"
|
| 57 |
+
|
| 58 |
+
// all functions also support swizzling
|
| 59 |
+
colorString.to.rgb(0, [0, 255], 0.4) // "rgba(0, 0, 255, 0.4)"
|
| 60 |
+
colorString.to.rgb([0, 0], [255], 0.4) // "rgba(0, 0, 255, 0.4)"
|
| 61 |
+
colorString.to.rgb([0], 0, [255, 0.4]) // "rgba(0, 0, 255, 0.4)"
|
| 62 |
+
```
|
worker/node_modules/color-string/index.js
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* MIT license */
|
| 2 |
+
var colorNames = require('color-name');
|
| 3 |
+
var swizzle = require('simple-swizzle');
|
| 4 |
+
var hasOwnProperty = Object.hasOwnProperty;
|
| 5 |
+
|
| 6 |
+
var reverseNames = Object.create(null);
|
| 7 |
+
|
| 8 |
+
// create a list of reverse color names
|
| 9 |
+
for (var name in colorNames) {
|
| 10 |
+
if (hasOwnProperty.call(colorNames, name)) {
|
| 11 |
+
reverseNames[colorNames[name]] = name;
|
| 12 |
+
}
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
var cs = module.exports = {
|
| 16 |
+
to: {},
|
| 17 |
+
get: {}
|
| 18 |
+
};
|
| 19 |
+
|
| 20 |
+
cs.get = function (string) {
|
| 21 |
+
var prefix = string.substring(0, 3).toLowerCase();
|
| 22 |
+
var val;
|
| 23 |
+
var model;
|
| 24 |
+
switch (prefix) {
|
| 25 |
+
case 'hsl':
|
| 26 |
+
val = cs.get.hsl(string);
|
| 27 |
+
model = 'hsl';
|
| 28 |
+
break;
|
| 29 |
+
case 'hwb':
|
| 30 |
+
val = cs.get.hwb(string);
|
| 31 |
+
model = 'hwb';
|
| 32 |
+
break;
|
| 33 |
+
default:
|
| 34 |
+
val = cs.get.rgb(string);
|
| 35 |
+
model = 'rgb';
|
| 36 |
+
break;
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
if (!val) {
|
| 40 |
+
return null;
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
return {model: model, value: val};
|
| 44 |
+
};
|
| 45 |
+
|
| 46 |
+
cs.get.rgb = function (string) {
|
| 47 |
+
if (!string) {
|
| 48 |
+
return null;
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
var abbr = /^#([a-f0-9]{3,4})$/i;
|
| 52 |
+
var hex = /^#([a-f0-9]{6})([a-f0-9]{2})?$/i;
|
| 53 |
+
var rgba = /^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/;
|
| 54 |
+
var per = /^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/;
|
| 55 |
+
var keyword = /^(\w+)$/;
|
| 56 |
+
|
| 57 |
+
var rgb = [0, 0, 0, 1];
|
| 58 |
+
var match;
|
| 59 |
+
var i;
|
| 60 |
+
var hexAlpha;
|
| 61 |
+
|
| 62 |
+
if (match = string.match(hex)) {
|
| 63 |
+
hexAlpha = match[2];
|
| 64 |
+
match = match[1];
|
| 65 |
+
|
| 66 |
+
for (i = 0; i < 3; i++) {
|
| 67 |
+
// https://jsperf.com/slice-vs-substr-vs-substring-methods-long-string/19
|
| 68 |
+
var i2 = i * 2;
|
| 69 |
+
rgb[i] = parseInt(match.slice(i2, i2 + 2), 16);
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
if (hexAlpha) {
|
| 73 |
+
rgb[3] = parseInt(hexAlpha, 16) / 255;
|
| 74 |
+
}
|
| 75 |
+
} else if (match = string.match(abbr)) {
|
| 76 |
+
match = match[1];
|
| 77 |
+
hexAlpha = match[3];
|
| 78 |
+
|
| 79 |
+
for (i = 0; i < 3; i++) {
|
| 80 |
+
rgb[i] = parseInt(match[i] + match[i], 16);
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
if (hexAlpha) {
|
| 84 |
+
rgb[3] = parseInt(hexAlpha + hexAlpha, 16) / 255;
|
| 85 |
+
}
|
| 86 |
+
} else if (match = string.match(rgba)) {
|
| 87 |
+
for (i = 0; i < 3; i++) {
|
| 88 |
+
rgb[i] = parseInt(match[i + 1], 0);
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
if (match[4]) {
|
| 92 |
+
if (match[5]) {
|
| 93 |
+
rgb[3] = parseFloat(match[4]) * 0.01;
|
| 94 |
+
} else {
|
| 95 |
+
rgb[3] = parseFloat(match[4]);
|
| 96 |
+
}
|
| 97 |
+
}
|
| 98 |
+
} else if (match = string.match(per)) {
|
| 99 |
+
for (i = 0; i < 3; i++) {
|
| 100 |
+
rgb[i] = Math.round(parseFloat(match[i + 1]) * 2.55);
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
if (match[4]) {
|
| 104 |
+
if (match[5]) {
|
| 105 |
+
rgb[3] = parseFloat(match[4]) * 0.01;
|
| 106 |
+
} else {
|
| 107 |
+
rgb[3] = parseFloat(match[4]);
|
| 108 |
+
}
|
| 109 |
+
}
|
| 110 |
+
} else if (match = string.match(keyword)) {
|
| 111 |
+
if (match[1] === 'transparent') {
|
| 112 |
+
return [0, 0, 0, 0];
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
if (!hasOwnProperty.call(colorNames, match[1])) {
|
| 116 |
+
return null;
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
rgb = colorNames[match[1]];
|
| 120 |
+
rgb[3] = 1;
|
| 121 |
+
|
| 122 |
+
return rgb;
|
| 123 |
+
} else {
|
| 124 |
+
return null;
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
for (i = 0; i < 3; i++) {
|
| 128 |
+
rgb[i] = clamp(rgb[i], 0, 255);
|
| 129 |
+
}
|
| 130 |
+
rgb[3] = clamp(rgb[3], 0, 1);
|
| 131 |
+
|
| 132 |
+
return rgb;
|
| 133 |
+
};
|
| 134 |
+
|
| 135 |
+
cs.get.hsl = function (string) {
|
| 136 |
+
if (!string) {
|
| 137 |
+
return null;
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
var hsl = /^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/;
|
| 141 |
+
var match = string.match(hsl);
|
| 142 |
+
|
| 143 |
+
if (match) {
|
| 144 |
+
var alpha = parseFloat(match[4]);
|
| 145 |
+
var h = ((parseFloat(match[1]) % 360) + 360) % 360;
|
| 146 |
+
var s = clamp(parseFloat(match[2]), 0, 100);
|
| 147 |
+
var l = clamp(parseFloat(match[3]), 0, 100);
|
| 148 |
+
var a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);
|
| 149 |
+
|
| 150 |
+
return [h, s, l, a];
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
return null;
|
| 154 |
+
};
|
| 155 |
+
|
| 156 |
+
cs.get.hwb = function (string) {
|
| 157 |
+
if (!string) {
|
| 158 |
+
return null;
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
var hwb = /^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/;
|
| 162 |
+
var match = string.match(hwb);
|
| 163 |
+
|
| 164 |
+
if (match) {
|
| 165 |
+
var alpha = parseFloat(match[4]);
|
| 166 |
+
var h = ((parseFloat(match[1]) % 360) + 360) % 360;
|
| 167 |
+
var w = clamp(parseFloat(match[2]), 0, 100);
|
| 168 |
+
var b = clamp(parseFloat(match[3]), 0, 100);
|
| 169 |
+
var a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);
|
| 170 |
+
return [h, w, b, a];
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
return null;
|
| 174 |
+
};
|
| 175 |
+
|
| 176 |
+
cs.to.hex = function () {
|
| 177 |
+
var rgba = swizzle(arguments);
|
| 178 |
+
|
| 179 |
+
return (
|
| 180 |
+
'#' +
|
| 181 |
+
hexDouble(rgba[0]) +
|
| 182 |
+
hexDouble(rgba[1]) +
|
| 183 |
+
hexDouble(rgba[2]) +
|
| 184 |
+
(rgba[3] < 1
|
| 185 |
+
? (hexDouble(Math.round(rgba[3] * 255)))
|
| 186 |
+
: '')
|
| 187 |
+
);
|
| 188 |
+
};
|
| 189 |
+
|
| 190 |
+
cs.to.rgb = function () {
|
| 191 |
+
var rgba = swizzle(arguments);
|
| 192 |
+
|
| 193 |
+
return rgba.length < 4 || rgba[3] === 1
|
| 194 |
+
? 'rgb(' + Math.round(rgba[0]) + ', ' + Math.round(rgba[1]) + ', ' + Math.round(rgba[2]) + ')'
|
| 195 |
+
: 'rgba(' + Math.round(rgba[0]) + ', ' + Math.round(rgba[1]) + ', ' + Math.round(rgba[2]) + ', ' + rgba[3] + ')';
|
| 196 |
+
};
|
| 197 |
+
|
| 198 |
+
cs.to.rgb.percent = function () {
|
| 199 |
+
var rgba = swizzle(arguments);
|
| 200 |
+
|
| 201 |
+
var r = Math.round(rgba[0] / 255 * 100);
|
| 202 |
+
var g = Math.round(rgba[1] / 255 * 100);
|
| 203 |
+
var b = Math.round(rgba[2] / 255 * 100);
|
| 204 |
+
|
| 205 |
+
return rgba.length < 4 || rgba[3] === 1
|
| 206 |
+
? 'rgb(' + r + '%, ' + g + '%, ' + b + '%)'
|
| 207 |
+
: 'rgba(' + r + '%, ' + g + '%, ' + b + '%, ' + rgba[3] + ')';
|
| 208 |
+
};
|
| 209 |
+
|
| 210 |
+
cs.to.hsl = function () {
|
| 211 |
+
var hsla = swizzle(arguments);
|
| 212 |
+
return hsla.length < 4 || hsla[3] === 1
|
| 213 |
+
? 'hsl(' + hsla[0] + ', ' + hsla[1] + '%, ' + hsla[2] + '%)'
|
| 214 |
+
: 'hsla(' + hsla[0] + ', ' + hsla[1] + '%, ' + hsla[2] + '%, ' + hsla[3] + ')';
|
| 215 |
+
};
|
| 216 |
+
|
| 217 |
+
// hwb is a bit different than rgb(a) & hsl(a) since there is no alpha specific syntax
|
| 218 |
+
// (hwb have alpha optional & 1 is default value)
|
| 219 |
+
cs.to.hwb = function () {
|
| 220 |
+
var hwba = swizzle(arguments);
|
| 221 |
+
|
| 222 |
+
var a = '';
|
| 223 |
+
if (hwba.length >= 4 && hwba[3] !== 1) {
|
| 224 |
+
a = ', ' + hwba[3];
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
return 'hwb(' + hwba[0] + ', ' + hwba[1] + '%, ' + hwba[2] + '%' + a + ')';
|
| 228 |
+
};
|
| 229 |
+
|
| 230 |
+
cs.to.keyword = function (rgb) {
|
| 231 |
+
return reverseNames[rgb.slice(0, 3)];
|
| 232 |
+
};
|
| 233 |
+
|
| 234 |
+
// helpers
|
| 235 |
+
function clamp(num, min, max) {
|
| 236 |
+
return Math.min(Math.max(min, num), max);
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
function hexDouble(num) {
|
| 240 |
+
var str = Math.round(num).toString(16).toUpperCase();
|
| 241 |
+
return (str.length < 2) ? '0' + str : str;
|
| 242 |
+
}
|
worker/node_modules/color-string/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "color-string",
|
| 3 |
+
"description": "Parser and generator for CSS color strings",
|
| 4 |
+
"version": "1.9.1",
|
| 5 |
+
"author": "Heather Arthur <fayearthur@gmail.com>",
|
| 6 |
+
"contributors": [
|
| 7 |
+
"Maxime Thirouin",
|
| 8 |
+
"Dyma Ywanov <dfcreative@gmail.com>",
|
| 9 |
+
"Josh Junon"
|
| 10 |
+
],
|
| 11 |
+
"repository": "Qix-/color-string",
|
| 12 |
+
"scripts": {
|
| 13 |
+
"pretest": "xo",
|
| 14 |
+
"test": "node test/basic.js"
|
| 15 |
+
},
|
| 16 |
+
"license": "MIT",
|
| 17 |
+
"files": [
|
| 18 |
+
"index.js"
|
| 19 |
+
],
|
| 20 |
+
"xo": {
|
| 21 |
+
"rules": {
|
| 22 |
+
"no-cond-assign": 0,
|
| 23 |
+
"operator-linebreak": 0
|
| 24 |
+
}
|
| 25 |
+
},
|
| 26 |
+
"dependencies": {
|
| 27 |
+
"color-name": "^1.0.0",
|
| 28 |
+
"simple-swizzle": "^0.2.2"
|
| 29 |
+
},
|
| 30 |
+
"devDependencies": {
|
| 31 |
+
"xo": "^0.12.1"
|
| 32 |
+
},
|
| 33 |
+
"keywords": [
|
| 34 |
+
"color",
|
| 35 |
+
"colour",
|
| 36 |
+
"rgb",
|
| 37 |
+
"css"
|
| 38 |
+
]
|
| 39 |
+
}
|
worker/node_modules/color/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Copyright (c) 2012 Heather Arthur
|
| 2 |
+
|
| 3 |
+
Permission is hereby granted, free of charge, to any person obtaining
|
| 4 |
+
a copy of this software and associated documentation files (the
|
| 5 |
+
"Software"), to deal in the Software without restriction, including
|
| 6 |
+
without limitation the rights to use, copy, modify, merge, publish,
|
| 7 |
+
distribute, sublicense, and/or sell copies of the Software, and to
|
| 8 |
+
permit persons to whom the Software is furnished to do so, subject to
|
| 9 |
+
the following conditions:
|
| 10 |
+
|
| 11 |
+
The above copyright notice and this permission notice shall be
|
| 12 |
+
included in all copies or substantial portions of the Software.
|
| 13 |
+
|
| 14 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 15 |
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
| 16 |
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 17 |
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
| 18 |
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
| 19 |
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
| 20 |
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
| 21 |
+
|
worker/node_modules/color/README.md
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# color
|
| 2 |
+
|
| 3 |
+
> JavaScript library for immutable color conversion and manipulation with support for CSS color strings.
|
| 4 |
+
|
| 5 |
+
```js
|
| 6 |
+
const color = Color('#7743CE').alpha(0.5).lighten(0.5);
|
| 7 |
+
console.log(color.hsl().string()); // 'hsla(262, 59%, 81%, 0.5)'
|
| 8 |
+
|
| 9 |
+
console.log(color.cmyk().round().array()); // [ 16, 25, 0, 8, 0.5 ]
|
| 10 |
+
|
| 11 |
+
console.log(color.ansi256().object()); // { ansi256: 183, alpha: 0.5 }
|
| 12 |
+
```
|
| 13 |
+
|
| 14 |
+
## Install
|
| 15 |
+
```console
|
| 16 |
+
$ npm install color
|
| 17 |
+
```
|
| 18 |
+
|
| 19 |
+
## Usage
|
| 20 |
+
```js
|
| 21 |
+
const Color = require('color');
|
| 22 |
+
```
|
| 23 |
+
|
| 24 |
+
### Constructors
|
| 25 |
+
```js
|
| 26 |
+
const color = Color('rgb(255, 255, 255)')
|
| 27 |
+
const color = Color({r: 255, g: 255, b: 255})
|
| 28 |
+
const color = Color.rgb(255, 255, 255)
|
| 29 |
+
const color = Color.rgb([255, 255, 255])
|
| 30 |
+
```
|
| 31 |
+
|
| 32 |
+
Set the values for individual channels with `alpha`, `red`, `green`, `blue`, `hue`, `saturationl` (hsl), `saturationv` (hsv), `lightness`, `whiteness`, `blackness`, `cyan`, `magenta`, `yellow`, `black`
|
| 33 |
+
|
| 34 |
+
String constructors are handled by [color-string](https://www.npmjs.com/package/color-string)
|
| 35 |
+
|
| 36 |
+
### Getters
|
| 37 |
+
```js
|
| 38 |
+
color.hsl();
|
| 39 |
+
```
|
| 40 |
+
Convert a color to a different space (`hsl()`, `cmyk()`, etc.).
|
| 41 |
+
|
| 42 |
+
```js
|
| 43 |
+
color.object(); // {r: 255, g: 255, b: 255}
|
| 44 |
+
```
|
| 45 |
+
Get a hash of the color value. Reflects the color's current model (see above).
|
| 46 |
+
|
| 47 |
+
```js
|
| 48 |
+
color.rgb().array() // [255, 255, 255]
|
| 49 |
+
```
|
| 50 |
+
Get an array of the values with `array()`. Reflects the color's current model (see above).
|
| 51 |
+
|
| 52 |
+
```js
|
| 53 |
+
color.rgbNumber() // 16777215 (0xffffff)
|
| 54 |
+
```
|
| 55 |
+
Get the rgb number value.
|
| 56 |
+
|
| 57 |
+
```js
|
| 58 |
+
color.hex() // #ffffff
|
| 59 |
+
```
|
| 60 |
+
Get the hex value. (**NOTE:** `.hex()` does not return alpha values; use `.hexa()` for an RGBA representation)
|
| 61 |
+
|
| 62 |
+
```js
|
| 63 |
+
color.red() // 255
|
| 64 |
+
```
|
| 65 |
+
Get the value for an individual channel.
|
| 66 |
+
|
| 67 |
+
### CSS Strings
|
| 68 |
+
```js
|
| 69 |
+
color.hsl().string() // 'hsl(320, 50%, 100%)'
|
| 70 |
+
```
|
| 71 |
+
|
| 72 |
+
Calling `.string()` with a number rounds the numbers to that decimal place. It defaults to 1.
|
| 73 |
+
|
| 74 |
+
### Luminosity
|
| 75 |
+
```js
|
| 76 |
+
color.luminosity(); // 0.412
|
| 77 |
+
```
|
| 78 |
+
The [WCAG luminosity](http://www.w3.org/TR/WCAG20/#relativeluminancedef) of the color. 0 is black, 1 is white.
|
| 79 |
+
|
| 80 |
+
```js
|
| 81 |
+
color.contrast(Color("blue")) // 12
|
| 82 |
+
```
|
| 83 |
+
The [WCAG contrast ratio](http://www.w3.org/TR/WCAG20/#contrast-ratiodef) to another color, from 1 (same color) to 21 (contrast b/w white and black).
|
| 84 |
+
|
| 85 |
+
```js
|
| 86 |
+
color.isLight(); // true
|
| 87 |
+
color.isDark(); // false
|
| 88 |
+
```
|
| 89 |
+
Get whether the color is "light" or "dark", useful for deciding text color.
|
| 90 |
+
|
| 91 |
+
### Manipulation
|
| 92 |
+
```js
|
| 93 |
+
color.negate() // rgb(0, 100, 255) -> rgb(255, 155, 0)
|
| 94 |
+
|
| 95 |
+
color.lighten(0.5) // hsl(100, 50%, 50%) -> hsl(100, 50%, 75%)
|
| 96 |
+
color.lighten(0.5) // hsl(100, 50%, 0) -> hsl(100, 50%, 0)
|
| 97 |
+
color.darken(0.5) // hsl(100, 50%, 50%) -> hsl(100, 50%, 25%)
|
| 98 |
+
color.darken(0.5) // hsl(100, 50%, 0) -> hsl(100, 50%, 0)
|
| 99 |
+
|
| 100 |
+
color.lightness(50) // hsl(100, 50%, 10%) -> hsl(100, 50%, 50%)
|
| 101 |
+
|
| 102 |
+
color.saturate(0.5) // hsl(100, 50%, 50%) -> hsl(100, 75%, 50%)
|
| 103 |
+
color.desaturate(0.5) // hsl(100, 50%, 50%) -> hsl(100, 25%, 50%)
|
| 104 |
+
color.grayscale() // #5CBF54 -> #969696
|
| 105 |
+
|
| 106 |
+
color.whiten(0.5) // hwb(100, 50%, 50%) -> hwb(100, 75%, 50%)
|
| 107 |
+
color.blacken(0.5) // hwb(100, 50%, 50%) -> hwb(100, 50%, 75%)
|
| 108 |
+
|
| 109 |
+
color.fade(0.5) // rgba(10, 10, 10, 0.8) -> rgba(10, 10, 10, 0.4)
|
| 110 |
+
color.opaquer(0.5) // rgba(10, 10, 10, 0.8) -> rgba(10, 10, 10, 1.0)
|
| 111 |
+
|
| 112 |
+
color.rotate(180) // hsl(60, 20%, 20%) -> hsl(240, 20%, 20%)
|
| 113 |
+
color.rotate(-90) // hsl(60, 20%, 20%) -> hsl(330, 20%, 20%)
|
| 114 |
+
|
| 115 |
+
color.mix(Color("yellow")) // cyan -> rgb(128, 255, 128)
|
| 116 |
+
color.mix(Color("yellow"), 0.3) // cyan -> rgb(77, 255, 179)
|
| 117 |
+
|
| 118 |
+
// chaining
|
| 119 |
+
color.green(100).grayscale().lighten(0.6)
|
| 120 |
+
```
|
| 121 |
+
|
| 122 |
+
## Propers
|
| 123 |
+
The API was inspired by [color-js](https://github.com/brehaut/color-js). Manipulation functions by CSS tools like Sass, LESS, and Stylus.
|
worker/node_modules/color/index.js
ADDED
|
@@ -0,0 +1,496 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const colorString = require('color-string');
|
| 2 |
+
const convert = require('color-convert');
|
| 3 |
+
|
| 4 |
+
const skippedModels = [
|
| 5 |
+
// To be honest, I don't really feel like keyword belongs in color convert, but eh.
|
| 6 |
+
'keyword',
|
| 7 |
+
|
| 8 |
+
// Gray conflicts with some method names, and has its own method defined.
|
| 9 |
+
'gray',
|
| 10 |
+
|
| 11 |
+
// Shouldn't really be in color-convert either...
|
| 12 |
+
'hex',
|
| 13 |
+
];
|
| 14 |
+
|
| 15 |
+
const hashedModelKeys = {};
|
| 16 |
+
for (const model of Object.keys(convert)) {
|
| 17 |
+
hashedModelKeys[[...convert[model].labels].sort().join('')] = model;
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
const limiters = {};
|
| 21 |
+
|
| 22 |
+
function Color(object, model) {
|
| 23 |
+
if (!(this instanceof Color)) {
|
| 24 |
+
return new Color(object, model);
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
if (model && model in skippedModels) {
|
| 28 |
+
model = null;
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
if (model && !(model in convert)) {
|
| 32 |
+
throw new Error('Unknown model: ' + model);
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
let i;
|
| 36 |
+
let channels;
|
| 37 |
+
|
| 38 |
+
if (object == null) { // eslint-disable-line no-eq-null,eqeqeq
|
| 39 |
+
this.model = 'rgb';
|
| 40 |
+
this.color = [0, 0, 0];
|
| 41 |
+
this.valpha = 1;
|
| 42 |
+
} else if (object instanceof Color) {
|
| 43 |
+
this.model = object.model;
|
| 44 |
+
this.color = [...object.color];
|
| 45 |
+
this.valpha = object.valpha;
|
| 46 |
+
} else if (typeof object === 'string') {
|
| 47 |
+
const result = colorString.get(object);
|
| 48 |
+
if (result === null) {
|
| 49 |
+
throw new Error('Unable to parse color from string: ' + object);
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
this.model = result.model;
|
| 53 |
+
channels = convert[this.model].channels;
|
| 54 |
+
this.color = result.value.slice(0, channels);
|
| 55 |
+
this.valpha = typeof result.value[channels] === 'number' ? result.value[channels] : 1;
|
| 56 |
+
} else if (object.length > 0) {
|
| 57 |
+
this.model = model || 'rgb';
|
| 58 |
+
channels = convert[this.model].channels;
|
| 59 |
+
const newArray = Array.prototype.slice.call(object, 0, channels);
|
| 60 |
+
this.color = zeroArray(newArray, channels);
|
| 61 |
+
this.valpha = typeof object[channels] === 'number' ? object[channels] : 1;
|
| 62 |
+
} else if (typeof object === 'number') {
|
| 63 |
+
// This is always RGB - can be converted later on.
|
| 64 |
+
this.model = 'rgb';
|
| 65 |
+
this.color = [
|
| 66 |
+
(object >> 16) & 0xFF,
|
| 67 |
+
(object >> 8) & 0xFF,
|
| 68 |
+
object & 0xFF,
|
| 69 |
+
];
|
| 70 |
+
this.valpha = 1;
|
| 71 |
+
} else {
|
| 72 |
+
this.valpha = 1;
|
| 73 |
+
|
| 74 |
+
const keys = Object.keys(object);
|
| 75 |
+
if ('alpha' in object) {
|
| 76 |
+
keys.splice(keys.indexOf('alpha'), 1);
|
| 77 |
+
this.valpha = typeof object.alpha === 'number' ? object.alpha : 0;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
const hashedKeys = keys.sort().join('');
|
| 81 |
+
if (!(hashedKeys in hashedModelKeys)) {
|
| 82 |
+
throw new Error('Unable to parse color from object: ' + JSON.stringify(object));
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
this.model = hashedModelKeys[hashedKeys];
|
| 86 |
+
|
| 87 |
+
const {labels} = convert[this.model];
|
| 88 |
+
const color = [];
|
| 89 |
+
for (i = 0; i < labels.length; i++) {
|
| 90 |
+
color.push(object[labels[i]]);
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
this.color = zeroArray(color);
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
// Perform limitations (clamping, etc.)
|
| 97 |
+
if (limiters[this.model]) {
|
| 98 |
+
channels = convert[this.model].channels;
|
| 99 |
+
for (i = 0; i < channels; i++) {
|
| 100 |
+
const limit = limiters[this.model][i];
|
| 101 |
+
if (limit) {
|
| 102 |
+
this.color[i] = limit(this.color[i]);
|
| 103 |
+
}
|
| 104 |
+
}
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
this.valpha = Math.max(0, Math.min(1, this.valpha));
|
| 108 |
+
|
| 109 |
+
if (Object.freeze) {
|
| 110 |
+
Object.freeze(this);
|
| 111 |
+
}
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
Color.prototype = {
|
| 115 |
+
toString() {
|
| 116 |
+
return this.string();
|
| 117 |
+
},
|
| 118 |
+
|
| 119 |
+
toJSON() {
|
| 120 |
+
return this[this.model]();
|
| 121 |
+
},
|
| 122 |
+
|
| 123 |
+
string(places) {
|
| 124 |
+
let self = this.model in colorString.to ? this : this.rgb();
|
| 125 |
+
self = self.round(typeof places === 'number' ? places : 1);
|
| 126 |
+
const args = self.valpha === 1 ? self.color : [...self.color, this.valpha];
|
| 127 |
+
return colorString.to[self.model](args);
|
| 128 |
+
},
|
| 129 |
+
|
| 130 |
+
percentString(places) {
|
| 131 |
+
const self = this.rgb().round(typeof places === 'number' ? places : 1);
|
| 132 |
+
const args = self.valpha === 1 ? self.color : [...self.color, this.valpha];
|
| 133 |
+
return colorString.to.rgb.percent(args);
|
| 134 |
+
},
|
| 135 |
+
|
| 136 |
+
array() {
|
| 137 |
+
return this.valpha === 1 ? [...this.color] : [...this.color, this.valpha];
|
| 138 |
+
},
|
| 139 |
+
|
| 140 |
+
object() {
|
| 141 |
+
const result = {};
|
| 142 |
+
const {channels} = convert[this.model];
|
| 143 |
+
const {labels} = convert[this.model];
|
| 144 |
+
|
| 145 |
+
for (let i = 0; i < channels; i++) {
|
| 146 |
+
result[labels[i]] = this.color[i];
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
if (this.valpha !== 1) {
|
| 150 |
+
result.alpha = this.valpha;
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
return result;
|
| 154 |
+
},
|
| 155 |
+
|
| 156 |
+
unitArray() {
|
| 157 |
+
const rgb = this.rgb().color;
|
| 158 |
+
rgb[0] /= 255;
|
| 159 |
+
rgb[1] /= 255;
|
| 160 |
+
rgb[2] /= 255;
|
| 161 |
+
|
| 162 |
+
if (this.valpha !== 1) {
|
| 163 |
+
rgb.push(this.valpha);
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
return rgb;
|
| 167 |
+
},
|
| 168 |
+
|
| 169 |
+
unitObject() {
|
| 170 |
+
const rgb = this.rgb().object();
|
| 171 |
+
rgb.r /= 255;
|
| 172 |
+
rgb.g /= 255;
|
| 173 |
+
rgb.b /= 255;
|
| 174 |
+
|
| 175 |
+
if (this.valpha !== 1) {
|
| 176 |
+
rgb.alpha = this.valpha;
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
return rgb;
|
| 180 |
+
},
|
| 181 |
+
|
| 182 |
+
round(places) {
|
| 183 |
+
places = Math.max(places || 0, 0);
|
| 184 |
+
return new Color([...this.color.map(roundToPlace(places)), this.valpha], this.model);
|
| 185 |
+
},
|
| 186 |
+
|
| 187 |
+
alpha(value) {
|
| 188 |
+
if (value !== undefined) {
|
| 189 |
+
return new Color([...this.color, Math.max(0, Math.min(1, value))], this.model);
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
return this.valpha;
|
| 193 |
+
},
|
| 194 |
+
|
| 195 |
+
// Rgb
|
| 196 |
+
red: getset('rgb', 0, maxfn(255)),
|
| 197 |
+
green: getset('rgb', 1, maxfn(255)),
|
| 198 |
+
blue: getset('rgb', 2, maxfn(255)),
|
| 199 |
+
|
| 200 |
+
hue: getset(['hsl', 'hsv', 'hsl', 'hwb', 'hcg'], 0, value => ((value % 360) + 360) % 360),
|
| 201 |
+
|
| 202 |
+
saturationl: getset('hsl', 1, maxfn(100)),
|
| 203 |
+
lightness: getset('hsl', 2, maxfn(100)),
|
| 204 |
+
|
| 205 |
+
saturationv: getset('hsv', 1, maxfn(100)),
|
| 206 |
+
value: getset('hsv', 2, maxfn(100)),
|
| 207 |
+
|
| 208 |
+
chroma: getset('hcg', 1, maxfn(100)),
|
| 209 |
+
gray: getset('hcg', 2, maxfn(100)),
|
| 210 |
+
|
| 211 |
+
white: getset('hwb', 1, maxfn(100)),
|
| 212 |
+
wblack: getset('hwb', 2, maxfn(100)),
|
| 213 |
+
|
| 214 |
+
cyan: getset('cmyk', 0, maxfn(100)),
|
| 215 |
+
magenta: getset('cmyk', 1, maxfn(100)),
|
| 216 |
+
yellow: getset('cmyk', 2, maxfn(100)),
|
| 217 |
+
black: getset('cmyk', 3, maxfn(100)),
|
| 218 |
+
|
| 219 |
+
x: getset('xyz', 0, maxfn(95.047)),
|
| 220 |
+
y: getset('xyz', 1, maxfn(100)),
|
| 221 |
+
z: getset('xyz', 2, maxfn(108.833)),
|
| 222 |
+
|
| 223 |
+
l: getset('lab', 0, maxfn(100)),
|
| 224 |
+
a: getset('lab', 1),
|
| 225 |
+
b: getset('lab', 2),
|
| 226 |
+
|
| 227 |
+
keyword(value) {
|
| 228 |
+
if (value !== undefined) {
|
| 229 |
+
return new Color(value);
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
return convert[this.model].keyword(this.color);
|
| 233 |
+
},
|
| 234 |
+
|
| 235 |
+
hex(value) {
|
| 236 |
+
if (value !== undefined) {
|
| 237 |
+
return new Color(value);
|
| 238 |
+
}
|
| 239 |
+
|
| 240 |
+
return colorString.to.hex(this.rgb().round().color);
|
| 241 |
+
},
|
| 242 |
+
|
| 243 |
+
hexa(value) {
|
| 244 |
+
if (value !== undefined) {
|
| 245 |
+
return new Color(value);
|
| 246 |
+
}
|
| 247 |
+
|
| 248 |
+
const rgbArray = this.rgb().round().color;
|
| 249 |
+
|
| 250 |
+
let alphaHex = Math.round(this.valpha * 255).toString(16).toUpperCase();
|
| 251 |
+
if (alphaHex.length === 1) {
|
| 252 |
+
alphaHex = '0' + alphaHex;
|
| 253 |
+
}
|
| 254 |
+
|
| 255 |
+
return colorString.to.hex(rgbArray) + alphaHex;
|
| 256 |
+
},
|
| 257 |
+
|
| 258 |
+
rgbNumber() {
|
| 259 |
+
const rgb = this.rgb().color;
|
| 260 |
+
return ((rgb[0] & 0xFF) << 16) | ((rgb[1] & 0xFF) << 8) | (rgb[2] & 0xFF);
|
| 261 |
+
},
|
| 262 |
+
|
| 263 |
+
luminosity() {
|
| 264 |
+
// http://www.w3.org/TR/WCAG20/#relativeluminancedef
|
| 265 |
+
const rgb = this.rgb().color;
|
| 266 |
+
|
| 267 |
+
const lum = [];
|
| 268 |
+
for (const [i, element] of rgb.entries()) {
|
| 269 |
+
const chan = element / 255;
|
| 270 |
+
lum[i] = (chan <= 0.04045) ? chan / 12.92 : ((chan + 0.055) / 1.055) ** 2.4;
|
| 271 |
+
}
|
| 272 |
+
|
| 273 |
+
return 0.2126 * lum[0] + 0.7152 * lum[1] + 0.0722 * lum[2];
|
| 274 |
+
},
|
| 275 |
+
|
| 276 |
+
contrast(color2) {
|
| 277 |
+
// http://www.w3.org/TR/WCAG20/#contrast-ratiodef
|
| 278 |
+
const lum1 = this.luminosity();
|
| 279 |
+
const lum2 = color2.luminosity();
|
| 280 |
+
|
| 281 |
+
if (lum1 > lum2) {
|
| 282 |
+
return (lum1 + 0.05) / (lum2 + 0.05);
|
| 283 |
+
}
|
| 284 |
+
|
| 285 |
+
return (lum2 + 0.05) / (lum1 + 0.05);
|
| 286 |
+
},
|
| 287 |
+
|
| 288 |
+
level(color2) {
|
| 289 |
+
// https://www.w3.org/TR/WCAG/#contrast-enhanced
|
| 290 |
+
const contrastRatio = this.contrast(color2);
|
| 291 |
+
if (contrastRatio >= 7) {
|
| 292 |
+
return 'AAA';
|
| 293 |
+
}
|
| 294 |
+
|
| 295 |
+
return (contrastRatio >= 4.5) ? 'AA' : '';
|
| 296 |
+
},
|
| 297 |
+
|
| 298 |
+
isDark() {
|
| 299 |
+
// YIQ equation from http://24ways.org/2010/calculating-color-contrast
|
| 300 |
+
const rgb = this.rgb().color;
|
| 301 |
+
const yiq = (rgb[0] * 2126 + rgb[1] * 7152 + rgb[2] * 722) / 10000;
|
| 302 |
+
return yiq < 128;
|
| 303 |
+
},
|
| 304 |
+
|
| 305 |
+
isLight() {
|
| 306 |
+
return !this.isDark();
|
| 307 |
+
},
|
| 308 |
+
|
| 309 |
+
negate() {
|
| 310 |
+
const rgb = this.rgb();
|
| 311 |
+
for (let i = 0; i < 3; i++) {
|
| 312 |
+
rgb.color[i] = 255 - rgb.color[i];
|
| 313 |
+
}
|
| 314 |
+
|
| 315 |
+
return rgb;
|
| 316 |
+
},
|
| 317 |
+
|
| 318 |
+
lighten(ratio) {
|
| 319 |
+
const hsl = this.hsl();
|
| 320 |
+
hsl.color[2] += hsl.color[2] * ratio;
|
| 321 |
+
return hsl;
|
| 322 |
+
},
|
| 323 |
+
|
| 324 |
+
darken(ratio) {
|
| 325 |
+
const hsl = this.hsl();
|
| 326 |
+
hsl.color[2] -= hsl.color[2] * ratio;
|
| 327 |
+
return hsl;
|
| 328 |
+
},
|
| 329 |
+
|
| 330 |
+
saturate(ratio) {
|
| 331 |
+
const hsl = this.hsl();
|
| 332 |
+
hsl.color[1] += hsl.color[1] * ratio;
|
| 333 |
+
return hsl;
|
| 334 |
+
},
|
| 335 |
+
|
| 336 |
+
desaturate(ratio) {
|
| 337 |
+
const hsl = this.hsl();
|
| 338 |
+
hsl.color[1] -= hsl.color[1] * ratio;
|
| 339 |
+
return hsl;
|
| 340 |
+
},
|
| 341 |
+
|
| 342 |
+
whiten(ratio) {
|
| 343 |
+
const hwb = this.hwb();
|
| 344 |
+
hwb.color[1] += hwb.color[1] * ratio;
|
| 345 |
+
return hwb;
|
| 346 |
+
},
|
| 347 |
+
|
| 348 |
+
blacken(ratio) {
|
| 349 |
+
const hwb = this.hwb();
|
| 350 |
+
hwb.color[2] += hwb.color[2] * ratio;
|
| 351 |
+
return hwb;
|
| 352 |
+
},
|
| 353 |
+
|
| 354 |
+
grayscale() {
|
| 355 |
+
// http://en.wikipedia.org/wiki/Grayscale#Converting_color_to_grayscale
|
| 356 |
+
const rgb = this.rgb().color;
|
| 357 |
+
const value = rgb[0] * 0.3 + rgb[1] * 0.59 + rgb[2] * 0.11;
|
| 358 |
+
return Color.rgb(value, value, value);
|
| 359 |
+
},
|
| 360 |
+
|
| 361 |
+
fade(ratio) {
|
| 362 |
+
return this.alpha(this.valpha - (this.valpha * ratio));
|
| 363 |
+
},
|
| 364 |
+
|
| 365 |
+
opaquer(ratio) {
|
| 366 |
+
return this.alpha(this.valpha + (this.valpha * ratio));
|
| 367 |
+
},
|
| 368 |
+
|
| 369 |
+
rotate(degrees) {
|
| 370 |
+
const hsl = this.hsl();
|
| 371 |
+
let hue = hsl.color[0];
|
| 372 |
+
hue = (hue + degrees) % 360;
|
| 373 |
+
hue = hue < 0 ? 360 + hue : hue;
|
| 374 |
+
hsl.color[0] = hue;
|
| 375 |
+
return hsl;
|
| 376 |
+
},
|
| 377 |
+
|
| 378 |
+
mix(mixinColor, weight) {
|
| 379 |
+
// Ported from sass implementation in C
|
| 380 |
+
// https://github.com/sass/libsass/blob/0e6b4a2850092356aa3ece07c6b249f0221caced/functions.cpp#L209
|
| 381 |
+
if (!mixinColor || !mixinColor.rgb) {
|
| 382 |
+
throw new Error('Argument to "mix" was not a Color instance, but rather an instance of ' + typeof mixinColor);
|
| 383 |
+
}
|
| 384 |
+
|
| 385 |
+
const color1 = mixinColor.rgb();
|
| 386 |
+
const color2 = this.rgb();
|
| 387 |
+
const p = weight === undefined ? 0.5 : weight;
|
| 388 |
+
|
| 389 |
+
const w = 2 * p - 1;
|
| 390 |
+
const a = color1.alpha() - color2.alpha();
|
| 391 |
+
|
| 392 |
+
const w1 = (((w * a === -1) ? w : (w + a) / (1 + w * a)) + 1) / 2;
|
| 393 |
+
const w2 = 1 - w1;
|
| 394 |
+
|
| 395 |
+
return Color.rgb(
|
| 396 |
+
w1 * color1.red() + w2 * color2.red(),
|
| 397 |
+
w1 * color1.green() + w2 * color2.green(),
|
| 398 |
+
w1 * color1.blue() + w2 * color2.blue(),
|
| 399 |
+
color1.alpha() * p + color2.alpha() * (1 - p));
|
| 400 |
+
},
|
| 401 |
+
};
|
| 402 |
+
|
| 403 |
+
// Model conversion methods and static constructors
|
| 404 |
+
for (const model of Object.keys(convert)) {
|
| 405 |
+
if (skippedModels.includes(model)) {
|
| 406 |
+
continue;
|
| 407 |
+
}
|
| 408 |
+
|
| 409 |
+
const {channels} = convert[model];
|
| 410 |
+
|
| 411 |
+
// Conversion methods
|
| 412 |
+
Color.prototype[model] = function (...args) {
|
| 413 |
+
if (this.model === model) {
|
| 414 |
+
return new Color(this);
|
| 415 |
+
}
|
| 416 |
+
|
| 417 |
+
if (args.length > 0) {
|
| 418 |
+
return new Color(args, model);
|
| 419 |
+
}
|
| 420 |
+
|
| 421 |
+
return new Color([...assertArray(convert[this.model][model].raw(this.color)), this.valpha], model);
|
| 422 |
+
};
|
| 423 |
+
|
| 424 |
+
// 'static' construction methods
|
| 425 |
+
Color[model] = function (...args) {
|
| 426 |
+
let color = args[0];
|
| 427 |
+
if (typeof color === 'number') {
|
| 428 |
+
color = zeroArray(args, channels);
|
| 429 |
+
}
|
| 430 |
+
|
| 431 |
+
return new Color(color, model);
|
| 432 |
+
};
|
| 433 |
+
}
|
| 434 |
+
|
| 435 |
+
function roundTo(number, places) {
|
| 436 |
+
return Number(number.toFixed(places));
|
| 437 |
+
}
|
| 438 |
+
|
| 439 |
+
function roundToPlace(places) {
|
| 440 |
+
return function (number) {
|
| 441 |
+
return roundTo(number, places);
|
| 442 |
+
};
|
| 443 |
+
}
|
| 444 |
+
|
| 445 |
+
function getset(model, channel, modifier) {
|
| 446 |
+
model = Array.isArray(model) ? model : [model];
|
| 447 |
+
|
| 448 |
+
for (const m of model) {
|
| 449 |
+
(limiters[m] || (limiters[m] = []))[channel] = modifier;
|
| 450 |
+
}
|
| 451 |
+
|
| 452 |
+
model = model[0];
|
| 453 |
+
|
| 454 |
+
return function (value) {
|
| 455 |
+
let result;
|
| 456 |
+
|
| 457 |
+
if (value !== undefined) {
|
| 458 |
+
if (modifier) {
|
| 459 |
+
value = modifier(value);
|
| 460 |
+
}
|
| 461 |
+
|
| 462 |
+
result = this[model]();
|
| 463 |
+
result.color[channel] = value;
|
| 464 |
+
return result;
|
| 465 |
+
}
|
| 466 |
+
|
| 467 |
+
result = this[model]().color[channel];
|
| 468 |
+
if (modifier) {
|
| 469 |
+
result = modifier(result);
|
| 470 |
+
}
|
| 471 |
+
|
| 472 |
+
return result;
|
| 473 |
+
};
|
| 474 |
+
}
|
| 475 |
+
|
| 476 |
+
function maxfn(max) {
|
| 477 |
+
return function (v) {
|
| 478 |
+
return Math.max(0, Math.min(max, v));
|
| 479 |
+
};
|
| 480 |
+
}
|
| 481 |
+
|
| 482 |
+
function assertArray(value) {
|
| 483 |
+
return Array.isArray(value) ? value : [value];
|
| 484 |
+
}
|
| 485 |
+
|
| 486 |
+
function zeroArray(array, length) {
|
| 487 |
+
for (let i = 0; i < length; i++) {
|
| 488 |
+
if (typeof array[i] !== 'number') {
|
| 489 |
+
array[i] = 0;
|
| 490 |
+
}
|
| 491 |
+
}
|
| 492 |
+
|
| 493 |
+
return array;
|
| 494 |
+
}
|
| 495 |
+
|
| 496 |
+
module.exports = Color;
|
worker/node_modules/color/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "color",
|
| 3 |
+
"version": "4.2.3",
|
| 4 |
+
"description": "Color conversion and manipulation with CSS string support",
|
| 5 |
+
"sideEffects": false,
|
| 6 |
+
"keywords": [
|
| 7 |
+
"color",
|
| 8 |
+
"colour",
|
| 9 |
+
"css"
|
| 10 |
+
],
|
| 11 |
+
"authors": [
|
| 12 |
+
"Josh Junon <josh@junon.me>",
|
| 13 |
+
"Heather Arthur <fayearthur@gmail.com>",
|
| 14 |
+
"Maxime Thirouin"
|
| 15 |
+
],
|
| 16 |
+
"license": "MIT",
|
| 17 |
+
"repository": "Qix-/color",
|
| 18 |
+
"xo": {
|
| 19 |
+
"rules": {
|
| 20 |
+
"no-cond-assign": 0,
|
| 21 |
+
"new-cap": 0,
|
| 22 |
+
"unicorn/prefer-module": 0,
|
| 23 |
+
"no-mixed-operators": 0,
|
| 24 |
+
"complexity": 0,
|
| 25 |
+
"unicorn/numeric-separators-style": 0
|
| 26 |
+
}
|
| 27 |
+
},
|
| 28 |
+
"files": [
|
| 29 |
+
"LICENSE",
|
| 30 |
+
"index.js"
|
| 31 |
+
],
|
| 32 |
+
"scripts": {
|
| 33 |
+
"pretest": "xo",
|
| 34 |
+
"test": "mocha"
|
| 35 |
+
},
|
| 36 |
+
"engines": {
|
| 37 |
+
"node": ">=12.5.0"
|
| 38 |
+
},
|
| 39 |
+
"dependencies": {
|
| 40 |
+
"color-convert": "^2.0.1",
|
| 41 |
+
"color-string": "^1.9.0"
|
| 42 |
+
},
|
| 43 |
+
"devDependencies": {
|
| 44 |
+
"mocha": "9.0.2",
|
| 45 |
+
"xo": "0.42.0"
|
| 46 |
+
}
|
| 47 |
+
}
|
worker/node_modules/cookie/LICENSE
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
(The MIT License)
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2012-2014 Roman Shtylman <shtylman@gmail.com>
|
| 4 |
+
Copyright (c) 2015 Douglas Christopher Wilson <doug@somethingdoug.com>
|
| 5 |
+
|
| 6 |
+
Permission is hereby granted, free of charge, to any person obtaining
|
| 7 |
+
a copy of this software and associated documentation files (the
|
| 8 |
+
'Software'), to deal in the Software without restriction, including
|
| 9 |
+
without limitation the rights to use, copy, modify, merge, publish,
|
| 10 |
+
distribute, sublicense, and/or sell copies of the Software, and to
|
| 11 |
+
permit persons to whom the Software is furnished to do so, subject to
|
| 12 |
+
the following conditions:
|
| 13 |
+
|
| 14 |
+
The above copyright notice and this permission notice shall be
|
| 15 |
+
included in all copies or substantial portions of the Software.
|
| 16 |
+
|
| 17 |
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
| 18 |
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
| 19 |
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
| 20 |
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
| 21 |
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
| 22 |
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
| 23 |
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
| 24 |
+
|
worker/node_modules/cookie/README.md
ADDED
|
@@ -0,0 +1,317 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# cookie
|
| 2 |
+
|
| 3 |
+
[![NPM Version][npm-version-image]][npm-url]
|
| 4 |
+
[![NPM Downloads][npm-downloads-image]][npm-url]
|
| 5 |
+
[![Node.js Version][node-image]][node-url]
|
| 6 |
+
[![Build Status][ci-image]][ci-url]
|
| 7 |
+
[![Coverage Status][coveralls-image]][coveralls-url]
|
| 8 |
+
|
| 9 |
+
Basic HTTP cookie parser and serializer for HTTP servers.
|
| 10 |
+
|
| 11 |
+
## Installation
|
| 12 |
+
|
| 13 |
+
This is a [Node.js](https://nodejs.org/en/) module available through the
|
| 14 |
+
[npm registry](https://www.npmjs.com/). Installation is done using the
|
| 15 |
+
[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
|
| 16 |
+
|
| 17 |
+
```sh
|
| 18 |
+
$ npm install cookie
|
| 19 |
+
```
|
| 20 |
+
|
| 21 |
+
## API
|
| 22 |
+
|
| 23 |
+
```js
|
| 24 |
+
var cookie = require('cookie');
|
| 25 |
+
```
|
| 26 |
+
|
| 27 |
+
### cookie.parse(str, options)
|
| 28 |
+
|
| 29 |
+
Parse an HTTP `Cookie` header string and returning an object of all cookie name-value pairs.
|
| 30 |
+
The `str` argument is the string representing a `Cookie` header value and `options` is an
|
| 31 |
+
optional object containing additional parsing options.
|
| 32 |
+
|
| 33 |
+
```js
|
| 34 |
+
var cookies = cookie.parse('foo=bar; equation=E%3Dmc%5E2');
|
| 35 |
+
// { foo: 'bar', equation: 'E=mc^2' }
|
| 36 |
+
```
|
| 37 |
+
|
| 38 |
+
#### Options
|
| 39 |
+
|
| 40 |
+
`cookie.parse` accepts these properties in the options object.
|
| 41 |
+
|
| 42 |
+
##### decode
|
| 43 |
+
|
| 44 |
+
Specifies a function that will be used to decode a cookie's value. Since the value of a cookie
|
| 45 |
+
has a limited character set (and must be a simple string), this function can be used to decode
|
| 46 |
+
a previously-encoded cookie value into a JavaScript string or other object.
|
| 47 |
+
|
| 48 |
+
The default function is the global `decodeURIComponent`, which will decode any URL-encoded
|
| 49 |
+
sequences into their byte representations.
|
| 50 |
+
|
| 51 |
+
**note** if an error is thrown from this function, the original, non-decoded cookie value will
|
| 52 |
+
be returned as the cookie's value.
|
| 53 |
+
|
| 54 |
+
### cookie.serialize(name, value, options)
|
| 55 |
+
|
| 56 |
+
Serialize a cookie name-value pair into a `Set-Cookie` header string. The `name` argument is the
|
| 57 |
+
name for the cookie, the `value` argument is the value to set the cookie to, and the `options`
|
| 58 |
+
argument is an optional object containing additional serialization options.
|
| 59 |
+
|
| 60 |
+
```js
|
| 61 |
+
var setCookie = cookie.serialize('foo', 'bar');
|
| 62 |
+
// foo=bar
|
| 63 |
+
```
|
| 64 |
+
|
| 65 |
+
#### Options
|
| 66 |
+
|
| 67 |
+
`cookie.serialize` accepts these properties in the options object.
|
| 68 |
+
|
| 69 |
+
##### domain
|
| 70 |
+
|
| 71 |
+
Specifies the value for the [`Domain` `Set-Cookie` attribute][rfc-6265-5.2.3]. By default, no
|
| 72 |
+
domain is set, and most clients will consider the cookie to apply to only the current domain.
|
| 73 |
+
|
| 74 |
+
##### encode
|
| 75 |
+
|
| 76 |
+
Specifies a function that will be used to encode a cookie's value. Since value of a cookie
|
| 77 |
+
has a limited character set (and must be a simple string), this function can be used to encode
|
| 78 |
+
a value into a string suited for a cookie's value.
|
| 79 |
+
|
| 80 |
+
The default function is the global `encodeURIComponent`, which will encode a JavaScript string
|
| 81 |
+
into UTF-8 byte sequences and then URL-encode any that fall outside of the cookie range.
|
| 82 |
+
|
| 83 |
+
##### expires
|
| 84 |
+
|
| 85 |
+
Specifies the `Date` object to be the value for the [`Expires` `Set-Cookie` attribute][rfc-6265-5.2.1].
|
| 86 |
+
By default, no expiration is set, and most clients will consider this a "non-persistent cookie" and
|
| 87 |
+
will delete it on a condition like exiting a web browser application.
|
| 88 |
+
|
| 89 |
+
**note** the [cookie storage model specification][rfc-6265-5.3] states that if both `expires` and
|
| 90 |
+
`maxAge` are set, then `maxAge` takes precedence, but it is possible not all clients by obey this,
|
| 91 |
+
so if both are set, they should point to the same date and time.
|
| 92 |
+
|
| 93 |
+
##### httpOnly
|
| 94 |
+
|
| 95 |
+
Specifies the `boolean` value for the [`HttpOnly` `Set-Cookie` attribute][rfc-6265-5.2.6]. When truthy,
|
| 96 |
+
the `HttpOnly` attribute is set, otherwise it is not. By default, the `HttpOnly` attribute is not set.
|
| 97 |
+
|
| 98 |
+
**note** be careful when setting this to `true`, as compliant clients will not allow client-side
|
| 99 |
+
JavaScript to see the cookie in `document.cookie`.
|
| 100 |
+
|
| 101 |
+
##### maxAge
|
| 102 |
+
|
| 103 |
+
Specifies the `number` (in seconds) to be the value for the [`Max-Age` `Set-Cookie` attribute][rfc-6265-5.2.2].
|
| 104 |
+
The given number will be converted to an integer by rounding down. By default, no maximum age is set.
|
| 105 |
+
|
| 106 |
+
**note** the [cookie storage model specification][rfc-6265-5.3] states that if both `expires` and
|
| 107 |
+
`maxAge` are set, then `maxAge` takes precedence, but it is possible not all clients by obey this,
|
| 108 |
+
so if both are set, they should point to the same date and time.
|
| 109 |
+
|
| 110 |
+
##### partitioned
|
| 111 |
+
|
| 112 |
+
Specifies the `boolean` value for the [`Partitioned` `Set-Cookie`](rfc-cutler-httpbis-partitioned-cookies)
|
| 113 |
+
attribute. When truthy, the `Partitioned` attribute is set, otherwise it is not. By default, the
|
| 114 |
+
`Partitioned` attribute is not set.
|
| 115 |
+
|
| 116 |
+
**note** This is an attribute that has not yet been fully standardized, and may change in the future.
|
| 117 |
+
This also means many clients may ignore this attribute until they understand it.
|
| 118 |
+
|
| 119 |
+
More information about can be found in [the proposal](https://github.com/privacycg/CHIPS).
|
| 120 |
+
|
| 121 |
+
##### path
|
| 122 |
+
|
| 123 |
+
Specifies the value for the [`Path` `Set-Cookie` attribute][rfc-6265-5.2.4]. By default, the path
|
| 124 |
+
is considered the ["default path"][rfc-6265-5.1.4].
|
| 125 |
+
|
| 126 |
+
##### priority
|
| 127 |
+
|
| 128 |
+
Specifies the `string` to be the value for the [`Priority` `Set-Cookie` attribute][rfc-west-cookie-priority-00-4.1].
|
| 129 |
+
|
| 130 |
+
- `'low'` will set the `Priority` attribute to `Low`.
|
| 131 |
+
- `'medium'` will set the `Priority` attribute to `Medium`, the default priority when not set.
|
| 132 |
+
- `'high'` will set the `Priority` attribute to `High`.
|
| 133 |
+
|
| 134 |
+
More information about the different priority levels can be found in
|
| 135 |
+
[the specification][rfc-west-cookie-priority-00-4.1].
|
| 136 |
+
|
| 137 |
+
**note** This is an attribute that has not yet been fully standardized, and may change in the future.
|
| 138 |
+
This also means many clients may ignore this attribute until they understand it.
|
| 139 |
+
|
| 140 |
+
##### sameSite
|
| 141 |
+
|
| 142 |
+
Specifies the `boolean` or `string` to be the value for the [`SameSite` `Set-Cookie` attribute][rfc-6265bis-09-5.4.7].
|
| 143 |
+
|
| 144 |
+
- `true` will set the `SameSite` attribute to `Strict` for strict same site enforcement.
|
| 145 |
+
- `false` will not set the `SameSite` attribute.
|
| 146 |
+
- `'lax'` will set the `SameSite` attribute to `Lax` for lax same site enforcement.
|
| 147 |
+
- `'none'` will set the `SameSite` attribute to `None` for an explicit cross-site cookie.
|
| 148 |
+
- `'strict'` will set the `SameSite` attribute to `Strict` for strict same site enforcement.
|
| 149 |
+
|
| 150 |
+
More information about the different enforcement levels can be found in
|
| 151 |
+
[the specification][rfc-6265bis-09-5.4.7].
|
| 152 |
+
|
| 153 |
+
**note** This is an attribute that has not yet been fully standardized, and may change in the future.
|
| 154 |
+
This also means many clients may ignore this attribute until they understand it.
|
| 155 |
+
|
| 156 |
+
##### secure
|
| 157 |
+
|
| 158 |
+
Specifies the `boolean` value for the [`Secure` `Set-Cookie` attribute][rfc-6265-5.2.5]. When truthy,
|
| 159 |
+
the `Secure` attribute is set, otherwise it is not. By default, the `Secure` attribute is not set.
|
| 160 |
+
|
| 161 |
+
**note** be careful when setting this to `true`, as compliant clients will not send the cookie back to
|
| 162 |
+
the server in the future if the browser does not have an HTTPS connection.
|
| 163 |
+
|
| 164 |
+
## Example
|
| 165 |
+
|
| 166 |
+
The following example uses this module in conjunction with the Node.js core HTTP server
|
| 167 |
+
to prompt a user for their name and display it back on future visits.
|
| 168 |
+
|
| 169 |
+
```js
|
| 170 |
+
var cookie = require('cookie');
|
| 171 |
+
var escapeHtml = require('escape-html');
|
| 172 |
+
var http = require('http');
|
| 173 |
+
var url = require('url');
|
| 174 |
+
|
| 175 |
+
function onRequest(req, res) {
|
| 176 |
+
// Parse the query string
|
| 177 |
+
var query = url.parse(req.url, true, true).query;
|
| 178 |
+
|
| 179 |
+
if (query && query.name) {
|
| 180 |
+
// Set a new cookie with the name
|
| 181 |
+
res.setHeader('Set-Cookie', cookie.serialize('name', String(query.name), {
|
| 182 |
+
httpOnly: true,
|
| 183 |
+
maxAge: 60 * 60 * 24 * 7 // 1 week
|
| 184 |
+
}));
|
| 185 |
+
|
| 186 |
+
// Redirect back after setting cookie
|
| 187 |
+
res.statusCode = 302;
|
| 188 |
+
res.setHeader('Location', req.headers.referer || '/');
|
| 189 |
+
res.end();
|
| 190 |
+
return;
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
// Parse the cookies on the request
|
| 194 |
+
var cookies = cookie.parse(req.headers.cookie || '');
|
| 195 |
+
|
| 196 |
+
// Get the visitor name set in the cookie
|
| 197 |
+
var name = cookies.name;
|
| 198 |
+
|
| 199 |
+
res.setHeader('Content-Type', 'text/html; charset=UTF-8');
|
| 200 |
+
|
| 201 |
+
if (name) {
|
| 202 |
+
res.write('<p>Welcome back, <b>' + escapeHtml(name) + '</b>!</p>');
|
| 203 |
+
} else {
|
| 204 |
+
res.write('<p>Hello, new visitor!</p>');
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
res.write('<form method="GET">');
|
| 208 |
+
res.write('<input placeholder="enter your name" name="name"> <input type="submit" value="Set Name">');
|
| 209 |
+
res.end('</form>');
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
http.createServer(onRequest).listen(3000);
|
| 213 |
+
```
|
| 214 |
+
|
| 215 |
+
## Testing
|
| 216 |
+
|
| 217 |
+
```sh
|
| 218 |
+
$ npm test
|
| 219 |
+
```
|
| 220 |
+
|
| 221 |
+
## Benchmark
|
| 222 |
+
|
| 223 |
+
```
|
| 224 |
+
$ npm run bench
|
| 225 |
+
|
| 226 |
+
> cookie@0.5.0 bench
|
| 227 |
+
> node benchmark/index.js
|
| 228 |
+
|
| 229 |
+
node@18.18.2
|
| 230 |
+
acorn@8.10.0
|
| 231 |
+
ada@2.6.0
|
| 232 |
+
ares@1.19.1
|
| 233 |
+
brotli@1.0.9
|
| 234 |
+
cldr@43.1
|
| 235 |
+
icu@73.2
|
| 236 |
+
llhttp@6.0.11
|
| 237 |
+
modules@108
|
| 238 |
+
napi@9
|
| 239 |
+
nghttp2@1.57.0
|
| 240 |
+
nghttp3@0.7.0
|
| 241 |
+
ngtcp2@0.8.1
|
| 242 |
+
openssl@3.0.10+quic
|
| 243 |
+
simdutf@3.2.14
|
| 244 |
+
tz@2023c
|
| 245 |
+
undici@5.26.3
|
| 246 |
+
unicode@15.0
|
| 247 |
+
uv@1.44.2
|
| 248 |
+
uvwasi@0.0.18
|
| 249 |
+
v8@10.2.154.26-node.26
|
| 250 |
+
zlib@1.2.13.1-motley
|
| 251 |
+
|
| 252 |
+
> node benchmark/parse-top.js
|
| 253 |
+
|
| 254 |
+
cookie.parse - top sites
|
| 255 |
+
|
| 256 |
+
14 tests completed.
|
| 257 |
+
|
| 258 |
+
parse accounts.google.com x 2,588,913 ops/sec ±0.74% (186 runs sampled)
|
| 259 |
+
parse apple.com x 2,370,002 ops/sec ±0.69% (186 runs sampled)
|
| 260 |
+
parse cloudflare.com x 2,213,102 ops/sec ±0.88% (188 runs sampled)
|
| 261 |
+
parse docs.google.com x 2,194,157 ops/sec ±1.03% (184 runs sampled)
|
| 262 |
+
parse drive.google.com x 2,265,084 ops/sec ±0.79% (187 runs sampled)
|
| 263 |
+
parse en.wikipedia.org x 457,099 ops/sec ±0.81% (186 runs sampled)
|
| 264 |
+
parse linkedin.com x 504,407 ops/sec ±0.89% (186 runs sampled)
|
| 265 |
+
parse maps.google.com x 1,230,959 ops/sec ±0.98% (186 runs sampled)
|
| 266 |
+
parse microsoft.com x 926,294 ops/sec ±0.88% (184 runs sampled)
|
| 267 |
+
parse play.google.com x 2,311,338 ops/sec ±0.83% (185 runs sampled)
|
| 268 |
+
parse support.google.com x 1,508,850 ops/sec ±0.86% (186 runs sampled)
|
| 269 |
+
parse www.google.com x 1,022,582 ops/sec ±1.32% (182 runs sampled)
|
| 270 |
+
parse youtu.be x 332,136 ops/sec ±1.02% (185 runs sampled)
|
| 271 |
+
parse youtube.com x 323,833 ops/sec ±0.77% (183 runs sampled)
|
| 272 |
+
|
| 273 |
+
> node benchmark/parse.js
|
| 274 |
+
|
| 275 |
+
cookie.parse - generic
|
| 276 |
+
|
| 277 |
+
6 tests completed.
|
| 278 |
+
|
| 279 |
+
simple x 3,214,032 ops/sec ±1.61% (183 runs sampled)
|
| 280 |
+
decode x 587,237 ops/sec ±1.16% (187 runs sampled)
|
| 281 |
+
unquote x 2,954,618 ops/sec ±1.35% (183 runs sampled)
|
| 282 |
+
duplicates x 857,008 ops/sec ±0.89% (187 runs sampled)
|
| 283 |
+
10 cookies x 292,133 ops/sec ±0.89% (187 runs sampled)
|
| 284 |
+
100 cookies x 22,610 ops/sec ±0.68% (187 runs sampled)
|
| 285 |
+
```
|
| 286 |
+
|
| 287 |
+
## References
|
| 288 |
+
|
| 289 |
+
- [RFC 6265: HTTP State Management Mechanism][rfc-6265]
|
| 290 |
+
- [Same-site Cookies][rfc-6265bis-09-5.4.7]
|
| 291 |
+
|
| 292 |
+
[rfc-cutler-httpbis-partitioned-cookies]: https://tools.ietf.org/html/draft-cutler-httpbis-partitioned-cookies/
|
| 293 |
+
[rfc-west-cookie-priority-00-4.1]: https://tools.ietf.org/html/draft-west-cookie-priority-00#section-4.1
|
| 294 |
+
[rfc-6265bis-09-5.4.7]: https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-09#section-5.4.7
|
| 295 |
+
[rfc-6265]: https://tools.ietf.org/html/rfc6265
|
| 296 |
+
[rfc-6265-5.1.4]: https://tools.ietf.org/html/rfc6265#section-5.1.4
|
| 297 |
+
[rfc-6265-5.2.1]: https://tools.ietf.org/html/rfc6265#section-5.2.1
|
| 298 |
+
[rfc-6265-5.2.2]: https://tools.ietf.org/html/rfc6265#section-5.2.2
|
| 299 |
+
[rfc-6265-5.2.3]: https://tools.ietf.org/html/rfc6265#section-5.2.3
|
| 300 |
+
[rfc-6265-5.2.4]: https://tools.ietf.org/html/rfc6265#section-5.2.4
|
| 301 |
+
[rfc-6265-5.2.5]: https://tools.ietf.org/html/rfc6265#section-5.2.5
|
| 302 |
+
[rfc-6265-5.2.6]: https://tools.ietf.org/html/rfc6265#section-5.2.6
|
| 303 |
+
[rfc-6265-5.3]: https://tools.ietf.org/html/rfc6265#section-5.3
|
| 304 |
+
|
| 305 |
+
## License
|
| 306 |
+
|
| 307 |
+
[MIT](LICENSE)
|
| 308 |
+
|
| 309 |
+
[ci-image]: https://badgen.net/github/checks/jshttp/cookie/master?label=ci
|
| 310 |
+
[ci-url]: https://github.com/jshttp/cookie/actions/workflows/ci.yml
|
| 311 |
+
[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/cookie/master
|
| 312 |
+
[coveralls-url]: https://coveralls.io/r/jshttp/cookie?branch=master
|
| 313 |
+
[node-image]: https://badgen.net/npm/node/cookie
|
| 314 |
+
[node-url]: https://nodejs.org/en/download
|
| 315 |
+
[npm-downloads-image]: https://badgen.net/npm/dm/cookie
|
| 316 |
+
[npm-url]: https://npmjs.org/package/cookie
|
| 317 |
+
[npm-version-image]: https://badgen.net/npm/v/cookie
|
worker/node_modules/cookie/SECURITY.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Security Policies and Procedures
|
| 2 |
+
|
| 3 |
+
## Reporting a Bug
|
| 4 |
+
|
| 5 |
+
The `cookie` team and community take all security bugs seriously. Thank
|
| 6 |
+
you for improving the security of the project. We appreciate your efforts and
|
| 7 |
+
responsible disclosure and will make every effort to acknowledge your
|
| 8 |
+
contributions.
|
| 9 |
+
|
| 10 |
+
Report security bugs by emailing the current owner(s) of `cookie`. This
|
| 11 |
+
information can be found in the npm registry using the command
|
| 12 |
+
`npm owner ls cookie`.
|
| 13 |
+
If unsure or unable to get the information from the above, open an issue
|
| 14 |
+
in the [project issue tracker](https://github.com/jshttp/cookie/issues)
|
| 15 |
+
asking for the current contact information.
|
| 16 |
+
|
| 17 |
+
To ensure the timely response to your report, please ensure that the entirety
|
| 18 |
+
of the report is contained within the email body and not solely behind a web
|
| 19 |
+
link or an attachment.
|
| 20 |
+
|
| 21 |
+
At least one owner will acknowledge your email within 48 hours, and will send a
|
| 22 |
+
more detailed response within 48 hours indicating the next steps in handling
|
| 23 |
+
your report. After the initial reply to your report, the owners will
|
| 24 |
+
endeavor to keep you informed of the progress towards a fix and full
|
| 25 |
+
announcement, and may ask for additional information or guidance.
|
worker/node_modules/cookie/index.js
ADDED
|
@@ -0,0 +1,335 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*!
|
| 2 |
+
* cookie
|
| 3 |
+
* Copyright(c) 2012-2014 Roman Shtylman
|
| 4 |
+
* Copyright(c) 2015 Douglas Christopher Wilson
|
| 5 |
+
* MIT Licensed
|
| 6 |
+
*/
|
| 7 |
+
|
| 8 |
+
'use strict';
|
| 9 |
+
|
| 10 |
+
/**
|
| 11 |
+
* Module exports.
|
| 12 |
+
* @public
|
| 13 |
+
*/
|
| 14 |
+
|
| 15 |
+
exports.parse = parse;
|
| 16 |
+
exports.serialize = serialize;
|
| 17 |
+
|
| 18 |
+
/**
|
| 19 |
+
* Module variables.
|
| 20 |
+
* @private
|
| 21 |
+
*/
|
| 22 |
+
|
| 23 |
+
var __toString = Object.prototype.toString
|
| 24 |
+
var __hasOwnProperty = Object.prototype.hasOwnProperty
|
| 25 |
+
|
| 26 |
+
/**
|
| 27 |
+
* RegExp to match cookie-name in RFC 6265 sec 4.1.1
|
| 28 |
+
* This refers out to the obsoleted definition of token in RFC 2616 sec 2.2
|
| 29 |
+
* which has been replaced by the token definition in RFC 7230 appendix B.
|
| 30 |
+
*
|
| 31 |
+
* cookie-name = token
|
| 32 |
+
* token = 1*tchar
|
| 33 |
+
* tchar = "!" / "#" / "$" / "%" / "&" / "'" /
|
| 34 |
+
* "*" / "+" / "-" / "." / "^" / "_" /
|
| 35 |
+
* "`" / "|" / "~" / DIGIT / ALPHA
|
| 36 |
+
*/
|
| 37 |
+
|
| 38 |
+
var cookieNameRegExp = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
|
| 39 |
+
|
| 40 |
+
/**
|
| 41 |
+
* RegExp to match cookie-value in RFC 6265 sec 4.1.1
|
| 42 |
+
*
|
| 43 |
+
* cookie-value = *cookie-octet / ( DQUOTE *cookie-octet DQUOTE )
|
| 44 |
+
* cookie-octet = %x21 / %x23-2B / %x2D-3A / %x3C-5B / %x5D-7E
|
| 45 |
+
* ; US-ASCII characters excluding CTLs,
|
| 46 |
+
* ; whitespace DQUOTE, comma, semicolon,
|
| 47 |
+
* ; and backslash
|
| 48 |
+
*/
|
| 49 |
+
|
| 50 |
+
var cookieValueRegExp = /^("?)[\u0021\u0023-\u002B\u002D-\u003A\u003C-\u005B\u005D-\u007E]*\1$/;
|
| 51 |
+
|
| 52 |
+
/**
|
| 53 |
+
* RegExp to match domain-value in RFC 6265 sec 4.1.1
|
| 54 |
+
*
|
| 55 |
+
* domain-value = <subdomain>
|
| 56 |
+
* ; defined in [RFC1034], Section 3.5, as
|
| 57 |
+
* ; enhanced by [RFC1123], Section 2.1
|
| 58 |
+
* <subdomain> = <label> | <subdomain> "." <label>
|
| 59 |
+
* <label> = <let-dig> [ [ <ldh-str> ] <let-dig> ]
|
| 60 |
+
* Labels must be 63 characters or less.
|
| 61 |
+
* 'let-dig' not 'letter' in the first char, per RFC1123
|
| 62 |
+
* <ldh-str> = <let-dig-hyp> | <let-dig-hyp> <ldh-str>
|
| 63 |
+
* <let-dig-hyp> = <let-dig> | "-"
|
| 64 |
+
* <let-dig> = <letter> | <digit>
|
| 65 |
+
* <letter> = any one of the 52 alphabetic characters A through Z in
|
| 66 |
+
* upper case and a through z in lower case
|
| 67 |
+
* <digit> = any one of the ten digits 0 through 9
|
| 68 |
+
*
|
| 69 |
+
* Keep support for leading dot: https://github.com/jshttp/cookie/issues/173
|
| 70 |
+
*
|
| 71 |
+
* > (Note that a leading %x2E ("."), if present, is ignored even though that
|
| 72 |
+
* character is not permitted, but a trailing %x2E ("."), if present, will
|
| 73 |
+
* cause the user agent to ignore the attribute.)
|
| 74 |
+
*/
|
| 75 |
+
|
| 76 |
+
var domainValueRegExp = /^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i;
|
| 77 |
+
|
| 78 |
+
/**
|
| 79 |
+
* RegExp to match path-value in RFC 6265 sec 4.1.1
|
| 80 |
+
*
|
| 81 |
+
* path-value = <any CHAR except CTLs or ";">
|
| 82 |
+
* CHAR = %x01-7F
|
| 83 |
+
* ; defined in RFC 5234 appendix B.1
|
| 84 |
+
*/
|
| 85 |
+
|
| 86 |
+
var pathValueRegExp = /^[\u0020-\u003A\u003D-\u007E]*$/;
|
| 87 |
+
|
| 88 |
+
/**
|
| 89 |
+
* Parse a cookie header.
|
| 90 |
+
*
|
| 91 |
+
* Parse the given cookie header string into an object
|
| 92 |
+
* The object has the various cookies as keys(names) => values
|
| 93 |
+
*
|
| 94 |
+
* @param {string} str
|
| 95 |
+
* @param {object} [opt]
|
| 96 |
+
* @return {object}
|
| 97 |
+
* @public
|
| 98 |
+
*/
|
| 99 |
+
|
| 100 |
+
function parse(str, opt) {
|
| 101 |
+
if (typeof str !== 'string') {
|
| 102 |
+
throw new TypeError('argument str must be a string');
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
var obj = {};
|
| 106 |
+
var len = str.length;
|
| 107 |
+
// RFC 6265 sec 4.1.1, RFC 2616 2.2 defines a cookie name consists of one char minimum, plus '='.
|
| 108 |
+
if (len < 2) return obj;
|
| 109 |
+
|
| 110 |
+
var dec = (opt && opt.decode) || decode;
|
| 111 |
+
var index = 0;
|
| 112 |
+
var eqIdx = 0;
|
| 113 |
+
var endIdx = 0;
|
| 114 |
+
|
| 115 |
+
do {
|
| 116 |
+
eqIdx = str.indexOf('=', index);
|
| 117 |
+
if (eqIdx === -1) break; // No more cookie pairs.
|
| 118 |
+
|
| 119 |
+
endIdx = str.indexOf(';', index);
|
| 120 |
+
|
| 121 |
+
if (endIdx === -1) {
|
| 122 |
+
endIdx = len;
|
| 123 |
+
} else if (eqIdx > endIdx) {
|
| 124 |
+
// backtrack on prior semicolon
|
| 125 |
+
index = str.lastIndexOf(';', eqIdx - 1) + 1;
|
| 126 |
+
continue;
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
var keyStartIdx = startIndex(str, index, eqIdx);
|
| 130 |
+
var keyEndIdx = endIndex(str, eqIdx, keyStartIdx);
|
| 131 |
+
var key = str.slice(keyStartIdx, keyEndIdx);
|
| 132 |
+
|
| 133 |
+
// only assign once
|
| 134 |
+
if (!__hasOwnProperty.call(obj, key)) {
|
| 135 |
+
var valStartIdx = startIndex(str, eqIdx + 1, endIdx);
|
| 136 |
+
var valEndIdx = endIndex(str, endIdx, valStartIdx);
|
| 137 |
+
|
| 138 |
+
if (str.charCodeAt(valStartIdx) === 0x22 /* " */ && str.charCodeAt(valEndIdx - 1) === 0x22 /* " */) {
|
| 139 |
+
valStartIdx++;
|
| 140 |
+
valEndIdx--;
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
var val = str.slice(valStartIdx, valEndIdx);
|
| 144 |
+
obj[key] = tryDecode(val, dec);
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
index = endIdx + 1
|
| 148 |
+
} while (index < len);
|
| 149 |
+
|
| 150 |
+
return obj;
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
function startIndex(str, index, max) {
|
| 154 |
+
do {
|
| 155 |
+
var code = str.charCodeAt(index);
|
| 156 |
+
if (code !== 0x20 /* */ && code !== 0x09 /* \t */) return index;
|
| 157 |
+
} while (++index < max);
|
| 158 |
+
return max;
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
function endIndex(str, index, min) {
|
| 162 |
+
while (index > min) {
|
| 163 |
+
var code = str.charCodeAt(--index);
|
| 164 |
+
if (code !== 0x20 /* */ && code !== 0x09 /* \t */) return index + 1;
|
| 165 |
+
}
|
| 166 |
+
return min;
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
/**
|
| 170 |
+
* Serialize data into a cookie header.
|
| 171 |
+
*
|
| 172 |
+
* Serialize a name value pair into a cookie string suitable for
|
| 173 |
+
* http headers. An optional options object specifies cookie parameters.
|
| 174 |
+
*
|
| 175 |
+
* serialize('foo', 'bar', { httpOnly: true })
|
| 176 |
+
* => "foo=bar; httpOnly"
|
| 177 |
+
*
|
| 178 |
+
* @param {string} name
|
| 179 |
+
* @param {string} val
|
| 180 |
+
* @param {object} [opt]
|
| 181 |
+
* @return {string}
|
| 182 |
+
* @public
|
| 183 |
+
*/
|
| 184 |
+
|
| 185 |
+
function serialize(name, val, opt) {
|
| 186 |
+
var enc = (opt && opt.encode) || encodeURIComponent;
|
| 187 |
+
|
| 188 |
+
if (typeof enc !== 'function') {
|
| 189 |
+
throw new TypeError('option encode is invalid');
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
if (!cookieNameRegExp.test(name)) {
|
| 193 |
+
throw new TypeError('argument name is invalid');
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
var value = enc(val);
|
| 197 |
+
|
| 198 |
+
if (!cookieValueRegExp.test(value)) {
|
| 199 |
+
throw new TypeError('argument val is invalid');
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
var str = name + '=' + value;
|
| 203 |
+
if (!opt) return str;
|
| 204 |
+
|
| 205 |
+
if (null != opt.maxAge) {
|
| 206 |
+
var maxAge = Math.floor(opt.maxAge);
|
| 207 |
+
|
| 208 |
+
if (!isFinite(maxAge)) {
|
| 209 |
+
throw new TypeError('option maxAge is invalid')
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
str += '; Max-Age=' + maxAge;
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
if (opt.domain) {
|
| 216 |
+
if (!domainValueRegExp.test(opt.domain)) {
|
| 217 |
+
throw new TypeError('option domain is invalid');
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
str += '; Domain=' + opt.domain;
|
| 221 |
+
}
|
| 222 |
+
|
| 223 |
+
if (opt.path) {
|
| 224 |
+
if (!pathValueRegExp.test(opt.path)) {
|
| 225 |
+
throw new TypeError('option path is invalid');
|
| 226 |
+
}
|
| 227 |
+
|
| 228 |
+
str += '; Path=' + opt.path;
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
if (opt.expires) {
|
| 232 |
+
var expires = opt.expires
|
| 233 |
+
|
| 234 |
+
if (!isDate(expires) || isNaN(expires.valueOf())) {
|
| 235 |
+
throw new TypeError('option expires is invalid');
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
str += '; Expires=' + expires.toUTCString()
|
| 239 |
+
}
|
| 240 |
+
|
| 241 |
+
if (opt.httpOnly) {
|
| 242 |
+
str += '; HttpOnly';
|
| 243 |
+
}
|
| 244 |
+
|
| 245 |
+
if (opt.secure) {
|
| 246 |
+
str += '; Secure';
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
if (opt.partitioned) {
|
| 250 |
+
str += '; Partitioned'
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
if (opt.priority) {
|
| 254 |
+
var priority = typeof opt.priority === 'string'
|
| 255 |
+
? opt.priority.toLowerCase() : opt.priority;
|
| 256 |
+
|
| 257 |
+
switch (priority) {
|
| 258 |
+
case 'low':
|
| 259 |
+
str += '; Priority=Low'
|
| 260 |
+
break
|
| 261 |
+
case 'medium':
|
| 262 |
+
str += '; Priority=Medium'
|
| 263 |
+
break
|
| 264 |
+
case 'high':
|
| 265 |
+
str += '; Priority=High'
|
| 266 |
+
break
|
| 267 |
+
default:
|
| 268 |
+
throw new TypeError('option priority is invalid')
|
| 269 |
+
}
|
| 270 |
+
}
|
| 271 |
+
|
| 272 |
+
if (opt.sameSite) {
|
| 273 |
+
var sameSite = typeof opt.sameSite === 'string'
|
| 274 |
+
? opt.sameSite.toLowerCase() : opt.sameSite;
|
| 275 |
+
|
| 276 |
+
switch (sameSite) {
|
| 277 |
+
case true:
|
| 278 |
+
str += '; SameSite=Strict';
|
| 279 |
+
break;
|
| 280 |
+
case 'lax':
|
| 281 |
+
str += '; SameSite=Lax';
|
| 282 |
+
break;
|
| 283 |
+
case 'strict':
|
| 284 |
+
str += '; SameSite=Strict';
|
| 285 |
+
break;
|
| 286 |
+
case 'none':
|
| 287 |
+
str += '; SameSite=None';
|
| 288 |
+
break;
|
| 289 |
+
default:
|
| 290 |
+
throw new TypeError('option sameSite is invalid');
|
| 291 |
+
}
|
| 292 |
+
}
|
| 293 |
+
|
| 294 |
+
return str;
|
| 295 |
+
}
|
| 296 |
+
|
| 297 |
+
/**
|
| 298 |
+
* URL-decode string value. Optimized to skip native call when no %.
|
| 299 |
+
*
|
| 300 |
+
* @param {string} str
|
| 301 |
+
* @returns {string}
|
| 302 |
+
*/
|
| 303 |
+
|
| 304 |
+
function decode (str) {
|
| 305 |
+
return str.indexOf('%') !== -1
|
| 306 |
+
? decodeURIComponent(str)
|
| 307 |
+
: str
|
| 308 |
+
}
|
| 309 |
+
|
| 310 |
+
/**
|
| 311 |
+
* Determine if value is a Date.
|
| 312 |
+
*
|
| 313 |
+
* @param {*} val
|
| 314 |
+
* @private
|
| 315 |
+
*/
|
| 316 |
+
|
| 317 |
+
function isDate (val) {
|
| 318 |
+
return __toString.call(val) === '[object Date]';
|
| 319 |
+
}
|
| 320 |
+
|
| 321 |
+
/**
|
| 322 |
+
* Try decoding a string using a decoding function.
|
| 323 |
+
*
|
| 324 |
+
* @param {string} str
|
| 325 |
+
* @param {function} decode
|
| 326 |
+
* @private
|
| 327 |
+
*/
|
| 328 |
+
|
| 329 |
+
function tryDecode(str, decode) {
|
| 330 |
+
try {
|
| 331 |
+
return decode(str);
|
| 332 |
+
} catch (e) {
|
| 333 |
+
return str;
|
| 334 |
+
}
|
| 335 |
+
}
|
worker/node_modules/cookie/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "cookie",
|
| 3 |
+
"description": "HTTP server cookie parsing and serialization",
|
| 4 |
+
"version": "0.7.2",
|
| 5 |
+
"author": "Roman Shtylman <shtylman@gmail.com>",
|
| 6 |
+
"contributors": [
|
| 7 |
+
"Douglas Christopher Wilson <doug@somethingdoug.com>"
|
| 8 |
+
],
|
| 9 |
+
"license": "MIT",
|
| 10 |
+
"keywords": [
|
| 11 |
+
"cookie",
|
| 12 |
+
"cookies"
|
| 13 |
+
],
|
| 14 |
+
"repository": "jshttp/cookie",
|
| 15 |
+
"devDependencies": {
|
| 16 |
+
"beautify-benchmark": "0.2.4",
|
| 17 |
+
"benchmark": "2.1.4",
|
| 18 |
+
"eslint": "8.53.0",
|
| 19 |
+
"eslint-plugin-markdown": "3.0.1",
|
| 20 |
+
"mocha": "10.2.0",
|
| 21 |
+
"nyc": "15.1.0",
|
| 22 |
+
"safe-buffer": "5.2.1",
|
| 23 |
+
"top-sites": "1.1.194"
|
| 24 |
+
},
|
| 25 |
+
"files": [
|
| 26 |
+
"HISTORY.md",
|
| 27 |
+
"LICENSE",
|
| 28 |
+
"README.md",
|
| 29 |
+
"SECURITY.md",
|
| 30 |
+
"index.js"
|
| 31 |
+
],
|
| 32 |
+
"main": "index.js",
|
| 33 |
+
"engines": {
|
| 34 |
+
"node": ">= 0.6"
|
| 35 |
+
},
|
| 36 |
+
"scripts": {
|
| 37 |
+
"bench": "node benchmark/index.js",
|
| 38 |
+
"lint": "eslint .",
|
| 39 |
+
"test": "mocha --reporter spec --bail --check-leaks test/",
|
| 40 |
+
"test-ci": "nyc --reporter=lcov --reporter=text npm test",
|
| 41 |
+
"test-cov": "nyc --reporter=html --reporter=text npm test",
|
| 42 |
+
"update-bench": "node scripts/update-benchmark.js"
|
| 43 |
+
}
|
| 44 |
+
}
|
worker/node_modules/data-uri-to-buffer/.travis.yml
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
sudo: false
|
| 2 |
+
|
| 3 |
+
language: node_js
|
| 4 |
+
|
| 5 |
+
node_js:
|
| 6 |
+
- "1"
|
| 7 |
+
- "2"
|
| 8 |
+
- "3"
|
| 9 |
+
- "4"
|
| 10 |
+
- "5"
|
| 11 |
+
- "6"
|
| 12 |
+
- "7"
|
| 13 |
+
- "8"
|
| 14 |
+
|
| 15 |
+
install:
|
| 16 |
+
- PATH="`npm bin`:`npm bin -g`:$PATH"
|
| 17 |
+
# Install dependencies and build
|
| 18 |
+
- npm install
|
| 19 |
+
|
| 20 |
+
script:
|
| 21 |
+
# Output useful info for debugging
|
| 22 |
+
- node --version
|
| 23 |
+
- npm --version
|
| 24 |
+
# Run tests
|
| 25 |
+
- npm test
|
worker/node_modules/data-uri-to-buffer/History.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
2.0.0 / 2017-07-18
|
| 3 |
+
==================
|
| 4 |
+
|
| 5 |
+
* More correct media type handling
|
| 6 |
+
* add typings for Typescript
|
| 7 |
+
|
| 8 |
+
1.2.0 / 2017-07-18
|
| 9 |
+
==================
|
| 10 |
+
|
| 11 |
+
* Essentially identical to v1.0.0. Reverting changes from v1.1.0 because they are breaking changes and should be part of a major version bump
|
| 12 |
+
* Revert "More correct media type handling"
|
| 13 |
+
* Revert "add typings for Typescript"
|
| 14 |
+
|
| 15 |
+
1.1.0 / 2017-07-17
|
| 16 |
+
==================
|
| 17 |
+
|
| 18 |
+
* More correct media type handling
|
| 19 |
+
* Add typings for Typescript
|
| 20 |
+
|
| 21 |
+
1.0.0 / 2017-06-09
|
| 22 |
+
==================
|
| 23 |
+
|
| 24 |
+
* Bumping to v1.0.0 for semver semantics
|
| 25 |
+
* random updates for newer Node.js versions
|
| 26 |
+
* travis: test more node versions and fix v0.8
|
| 27 |
+
|
| 28 |
+
0.0.4 / 2015-06-29
|
| 29 |
+
==================
|
| 30 |
+
|
| 31 |
+
* package: update "mocha" to v2
|
| 32 |
+
* package: add RFC to the "keywords" section
|
| 33 |
+
* travis: test node v0.8, v0.10, and v0.12
|
| 34 |
+
* README: use SVG for Travis-CI badge
|
| 35 |
+
* test: more tests
|
| 36 |
+
|
| 37 |
+
0.0.3 / 2014-01-08
|
| 38 |
+
==================
|
| 39 |
+
|
| 40 |
+
* index: fix a URI with a comma in the data portion
|
| 41 |
+
|
| 42 |
+
0.0.2 / 2014-01-08
|
| 43 |
+
==================
|
| 44 |
+
|
| 45 |
+
* index: use unescape() instead of decodeURIComponent()
|
| 46 |
+
* test: add more tests from Mozilla
|
| 47 |
+
|
| 48 |
+
0.0.1 / 2014-01-02
|
| 49 |
+
==================
|
| 50 |
+
|
| 51 |
+
* add `README.md`
|
| 52 |
+
* index: default the `charset` property to "US-ASCII"
|
| 53 |
+
* default encoding is "ascii"
|
| 54 |
+
* default `type` to "text/plain" when none is given
|
| 55 |
+
* initial commit
|
worker/node_modules/data-uri-to-buffer/README.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
data-uri-to-buffer
|
| 2 |
+
==================
|
| 3 |
+
### Generate a Buffer instance from a [Data URI][rfc] string
|
| 4 |
+
[](https://travis-ci.org/TooTallNate/node-data-uri-to-buffer)
|
| 5 |
+
|
| 6 |
+
This module accepts a ["data" URI][rfc] String of data, and returns a
|
| 7 |
+
node.js `Buffer` instance with the decoded data.
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
Installation
|
| 11 |
+
------------
|
| 12 |
+
|
| 13 |
+
Install with `npm`:
|
| 14 |
+
|
| 15 |
+
``` bash
|
| 16 |
+
$ npm install data-uri-to-buffer
|
| 17 |
+
```
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
Example
|
| 21 |
+
-------
|
| 22 |
+
|
| 23 |
+
``` js
|
| 24 |
+
var dataUriToBuffer = require('data-uri-to-buffer');
|
| 25 |
+
|
| 26 |
+
// plain-text data is supported
|
| 27 |
+
var uri = 'data:,Hello%2C%20World!';
|
| 28 |
+
var decoded = dataUriToBuffer(uri);
|
| 29 |
+
console.log(decoded.toString());
|
| 30 |
+
// 'Hello, World!'
|
| 31 |
+
|
| 32 |
+
// base64-encoded data is supported
|
| 33 |
+
uri = 'data:text/plain;base64,SGVsbG8sIFdvcmxkIQ%3D%3D';
|
| 34 |
+
decoded = dataUriToBuffer(uri);
|
| 35 |
+
console.log(decoded.toString());
|
| 36 |
+
// 'Hello, World!'
|
| 37 |
+
```
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
API
|
| 41 |
+
---
|
| 42 |
+
|
| 43 |
+
### dataUriToBuffer(String uri) → Buffer
|
| 44 |
+
|
| 45 |
+
The `type` property on the Buffer instance gets set to the main type portion of
|
| 46 |
+
the "mediatype" portion of the "data" URI, or defaults to `"text/plain"` if not
|
| 47 |
+
specified.
|
| 48 |
+
|
| 49 |
+
The `typeFull` property on the Buffer instance gets set to the entire
|
| 50 |
+
"mediatype" portion of the "data" URI (including all parameters), or defaults
|
| 51 |
+
to `"text/plain;charset=US-ASCII"` if not specified.
|
| 52 |
+
|
| 53 |
+
The `charset` property on the Buffer instance gets set to the Charset portion of
|
| 54 |
+
the "mediatype" portion of the "data" URI, or defaults to `"US-ASCII"` if the
|
| 55 |
+
entire type is not specified, or defaults to `""` otherwise.
|
| 56 |
+
|
| 57 |
+
*Note*: If the only the main type is specified but not the charset, e.g.
|
| 58 |
+
`"data:text/plain,abc"`, the charset is set to the empty string. The spec only
|
| 59 |
+
defaults to US-ASCII as charset if the entire type is not specified.
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
License
|
| 63 |
+
-------
|
| 64 |
+
|
| 65 |
+
(The MIT License)
|
| 66 |
+
|
| 67 |
+
Copyright (c) 2014 Nathan Rajlich <nathan@tootallnate.net>
|
| 68 |
+
|
| 69 |
+
Permission is hereby granted, free of charge, to any person obtaining
|
| 70 |
+
a copy of this software and associated documentation files (the
|
| 71 |
+
'Software'), to deal in the Software without restriction, including
|
| 72 |
+
without limitation the rights to use, copy, modify, merge, publish,
|
| 73 |
+
distribute, sublicense, and/or sell copies of the Software, and to
|
| 74 |
+
permit persons to whom the Software is furnished to do so, subject to
|
| 75 |
+
the following conditions:
|
| 76 |
+
|
| 77 |
+
The above copyright notice and this permission notice shall be
|
| 78 |
+
included in all copies or substantial portions of the Software.
|
| 79 |
+
|
| 80 |
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
| 81 |
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
| 82 |
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
| 83 |
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
| 84 |
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
| 85 |
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
| 86 |
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
| 87 |
+
|
| 88 |
+
[rfc]: http://tools.ietf.org/html/rfc2397
|
worker/node_modules/data-uri-to-buffer/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/// <reference types="node" />
|
| 2 |
+
|
| 3 |
+
declare class MimeBuffer extends Buffer {
|
| 4 |
+
type: string;
|
| 5 |
+
typeFull: string;
|
| 6 |
+
charset: string;
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
declare function dataUriToBuffer(uri: string): MimeBuffer;
|
| 10 |
+
export = dataUriToBuffer;
|
worker/node_modules/data-uri-to-buffer/index.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* Module exports.
|
| 5 |
+
*/
|
| 6 |
+
|
| 7 |
+
module.exports = dataUriToBuffer;
|
| 8 |
+
|
| 9 |
+
/**
|
| 10 |
+
* Returns a `Buffer` instance from the given data URI `uri`.
|
| 11 |
+
*
|
| 12 |
+
* @param {String} uri Data URI to turn into a Buffer instance
|
| 13 |
+
* @return {Buffer} Buffer instance from Data URI
|
| 14 |
+
* @api public
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
function dataUriToBuffer(uri) {
|
| 18 |
+
if (!/^data\:/i.test(uri)) {
|
| 19 |
+
throw new TypeError(
|
| 20 |
+
'`uri` does not appear to be a Data URI (must begin with "data:")'
|
| 21 |
+
);
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
// strip newlines
|
| 25 |
+
uri = uri.replace(/\r?\n/g, '');
|
| 26 |
+
|
| 27 |
+
// split the URI up into the "metadata" and the "data" portions
|
| 28 |
+
var firstComma = uri.indexOf(',');
|
| 29 |
+
if (-1 === firstComma || firstComma <= 4) {
|
| 30 |
+
throw new TypeError('malformed data: URI');
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
// remove the "data:" scheme and parse the metadata
|
| 34 |
+
var meta = uri.substring(5, firstComma).split(';');
|
| 35 |
+
|
| 36 |
+
var type = meta[0] || 'text/plain';
|
| 37 |
+
var typeFull = type;
|
| 38 |
+
var base64 = false;
|
| 39 |
+
var charset = '';
|
| 40 |
+
for (var i = 1; i < meta.length; i++) {
|
| 41 |
+
if ('base64' == meta[i]) {
|
| 42 |
+
base64 = true;
|
| 43 |
+
} else {
|
| 44 |
+
typeFull += ';' + meta[i];
|
| 45 |
+
if (0 == meta[i].indexOf('charset=')) {
|
| 46 |
+
charset = meta[i].substring(8);
|
| 47 |
+
}
|
| 48 |
+
}
|
| 49 |
+
}
|
| 50 |
+
// defaults to US-ASCII only if type is not provided
|
| 51 |
+
if (!meta[0] && !charset.length) {
|
| 52 |
+
typeFull += ';charset=US-ASCII';
|
| 53 |
+
charset = 'US-ASCII';
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
// get the encoded data portion and decode URI-encoded chars
|
| 57 |
+
var data = unescape(uri.substring(firstComma + 1));
|
| 58 |
+
|
| 59 |
+
var encoding = base64 ? 'base64' : 'ascii';
|
| 60 |
+
var buffer = Buffer.from ? Buffer.from(data, encoding) : new Buffer(data, encoding);
|
| 61 |
+
|
| 62 |
+
// set `.type` and `.typeFull` properties to MIME type
|
| 63 |
+
buffer.type = type;
|
| 64 |
+
buffer.typeFull = typeFull;
|
| 65 |
+
|
| 66 |
+
// set the `.charset` property
|
| 67 |
+
buffer.charset = charset;
|
| 68 |
+
|
| 69 |
+
return buffer;
|
| 70 |
+
}
|
worker/node_modules/data-uri-to-buffer/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "data-uri-to-buffer",
|
| 3 |
+
"version": "2.0.2",
|
| 4 |
+
"description": "Generate a Buffer instance from a Data URI string",
|
| 5 |
+
"main": "index.js",
|
| 6 |
+
"types": "index.d.ts",
|
| 7 |
+
"scripts": {
|
| 8 |
+
"test": "mocha --reporter spec"
|
| 9 |
+
},
|
| 10 |
+
"repository": {
|
| 11 |
+
"type": "git",
|
| 12 |
+
"url": "git://github.com/TooTallNate/node-data-uri-to-buffer.git"
|
| 13 |
+
},
|
| 14 |
+
"keywords": [
|
| 15 |
+
"data",
|
| 16 |
+
"uri",
|
| 17 |
+
"datauri",
|
| 18 |
+
"data-uri",
|
| 19 |
+
"buffer",
|
| 20 |
+
"convert",
|
| 21 |
+
"rfc2397",
|
| 22 |
+
"2397"
|
| 23 |
+
],
|
| 24 |
+
"author": "Nathan Rajlich <nathan@tootallnate.net> (http://n8.io/)",
|
| 25 |
+
"license": "MIT",
|
| 26 |
+
"bugs": {
|
| 27 |
+
"url": "https://github.com/TooTallNate/node-data-uri-to-buffer/issues"
|
| 28 |
+
},
|
| 29 |
+
"homepage": "https://github.com/TooTallNate/node-data-uri-to-buffer",
|
| 30 |
+
"devDependencies": {
|
| 31 |
+
"@types/node": "^8.0.7",
|
| 32 |
+
"mocha": "^3.4.2"
|
| 33 |
+
}
|
| 34 |
+
}
|
worker/node_modules/defu/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) Pooya Parsa <pooya@pi0.io>
|
| 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.
|
worker/node_modules/defu/README.md
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 🌊 defu
|
| 2 |
+
|
| 3 |
+
Assign default properties, recursively. Lightweight and Fast.
|
| 4 |
+
|
| 5 |
+
[![npm version][npm-version-src]][npm-version-href]
|
| 6 |
+
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
| 7 |
+
[![bundle][bundle-src]][bundle-href]
|
| 8 |
+
[![Codecov][codecov-src]][codecov-href]
|
| 9 |
+
[![License][license-src]][license-href]
|
| 10 |
+
|
| 11 |
+
## Install
|
| 12 |
+
|
| 13 |
+
Install package:
|
| 14 |
+
|
| 15 |
+
```bash
|
| 16 |
+
# yarn
|
| 17 |
+
yarn add defu
|
| 18 |
+
# npm
|
| 19 |
+
npm install defu
|
| 20 |
+
# pnpm
|
| 21 |
+
pnpm install defu
|
| 22 |
+
```
|
| 23 |
+
|
| 24 |
+
## Usage
|
| 25 |
+
|
| 26 |
+
```js
|
| 27 |
+
import { defu } from "defu";
|
| 28 |
+
|
| 29 |
+
const options = defu(object, ...defaults);
|
| 30 |
+
```
|
| 31 |
+
|
| 32 |
+
Leftmost arguments have more priority when assigning defaults.
|
| 33 |
+
|
| 34 |
+
### Arguments
|
| 35 |
+
|
| 36 |
+
- **object (Object):** The destination object.
|
| 37 |
+
- **source (Object):** The source object.
|
| 38 |
+
|
| 39 |
+
```js
|
| 40 |
+
import { defu } from "defu";
|
| 41 |
+
|
| 42 |
+
console.log(defu({ a: { b: 2 } }, { a: { b: 1, c: 3 } }));
|
| 43 |
+
// => { a: { b: 2, c: 3 } }
|
| 44 |
+
```
|
| 45 |
+
|
| 46 |
+
### Using with CommonJS
|
| 47 |
+
|
| 48 |
+
```js
|
| 49 |
+
const { defu } = require("defu");
|
| 50 |
+
```
|
| 51 |
+
|
| 52 |
+
## Custom Merger
|
| 53 |
+
|
| 54 |
+
Sometimes default merging strategy is not desirable. Using `createDefu` we can create a custom instance with different merging strategy.
|
| 55 |
+
|
| 56 |
+
This function accepts `obj` (source object), `key` and `value` (current value) and should return `true` if applied custom merging.
|
| 57 |
+
|
| 58 |
+
**Example:** Sum numbers instead of overriding
|
| 59 |
+
|
| 60 |
+
```js
|
| 61 |
+
import { createDefu } from "defu";
|
| 62 |
+
|
| 63 |
+
const ext = createDefu((obj, key, value) => {
|
| 64 |
+
if (typeof obj[key] === "number" && typeof value === "number") {
|
| 65 |
+
obj[key] += value;
|
| 66 |
+
return true;
|
| 67 |
+
}
|
| 68 |
+
});
|
| 69 |
+
|
| 70 |
+
ext({ cost: 15 }, { cost: 10 }); // { cost: 25 }
|
| 71 |
+
```
|
| 72 |
+
|
| 73 |
+
## Function Merger
|
| 74 |
+
|
| 75 |
+
Using `defuFn`, if user provided a function, it will be called with default value instead of merging.
|
| 76 |
+
|
| 77 |
+
It can be useful for default values manipulation.
|
| 78 |
+
|
| 79 |
+
**Example:** Filter some items from defaults (array) and add 20 to the count default value.
|
| 80 |
+
|
| 81 |
+
```js
|
| 82 |
+
import { defuFn } from "defu";
|
| 83 |
+
|
| 84 |
+
defuFn(
|
| 85 |
+
{
|
| 86 |
+
ignore: (val) => val.filter((item) => item !== "dist"),
|
| 87 |
+
count: (count) => count + 20,
|
| 88 |
+
},
|
| 89 |
+
{
|
| 90 |
+
ignore: ["node_modules", "dist"],
|
| 91 |
+
count: 10,
|
| 92 |
+
},
|
| 93 |
+
);
|
| 94 |
+
/*
|
| 95 |
+
{
|
| 96 |
+
ignore: ['node_modules'],
|
| 97 |
+
count: 30
|
| 98 |
+
}
|
| 99 |
+
*/
|
| 100 |
+
```
|
| 101 |
+
|
| 102 |
+
**Note:** if the default value is not defined, the function defined won't be called and kept as value.
|
| 103 |
+
|
| 104 |
+
## Array Function Merger
|
| 105 |
+
|
| 106 |
+
`defuArrayFn` is similar to `defuFn` but **only applies to array values defined in defaults**.
|
| 107 |
+
|
| 108 |
+
**Example:** Filter some items from defaults (array) and add 20 to the count default value.
|
| 109 |
+
|
| 110 |
+
```js
|
| 111 |
+
import { defuArrayFn } from 'defu'
|
| 112 |
+
|
| 113 |
+
defuArrayFn({
|
| 114 |
+
ignore: (val) => val.filter(i => i !== 'dist'),
|
| 115 |
+
count: () => 20
|
| 116 |
+
}, {
|
| 117 |
+
ignore: [
|
| 118 |
+
'node_modules',
|
| 119 |
+
'dist'
|
| 120 |
+
],
|
| 121 |
+
count: 10
|
| 122 |
+
})
|
| 123 |
+
/*
|
| 124 |
+
{
|
| 125 |
+
ignore: ['node_modules'],
|
| 126 |
+
count: () => 20
|
| 127 |
+
}
|
| 128 |
+
*/
|
| 129 |
+
```
|
| 130 |
+
|
| 131 |
+
**Note:** the function is called only if the value defined in defaults is an aray.
|
| 132 |
+
|
| 133 |
+
### Remarks
|
| 134 |
+
|
| 135 |
+
- `object` and `defaults` are not modified
|
| 136 |
+
- Nullish values ([`null`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null) and [`undefined`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined)) are skipped. Please use [defaults-deep](https://www.npmjs.com/package/defaults-deep) or [omit-deep](http://npmjs.com/package/omit-deep) or [lodash.defaultsdeep](https://www.npmjs.com/package/lodash.defaultsdeep) if you need to preserve or different behavior.
|
| 137 |
+
- Assignment of `__proto__` and `constructor` keys will be skipped to prevent security issues with object pollution.
|
| 138 |
+
- Will concat `array` values (if default property is defined)
|
| 139 |
+
|
| 140 |
+
```js
|
| 141 |
+
console.log(defu({ array: ["b", "c"] }, { array: ["a"] }));
|
| 142 |
+
// => { array: ['b', 'c', 'a'] }
|
| 143 |
+
```
|
| 144 |
+
|
| 145 |
+
## Type
|
| 146 |
+
|
| 147 |
+
We expose `Defu` as a type utility to return a merged type that follows the rules that defu follows.
|
| 148 |
+
|
| 149 |
+
```js
|
| 150 |
+
import type { Defu } from 'defu'
|
| 151 |
+
|
| 152 |
+
type Options = Defu<{ foo: 'bar' }, [{}, { bar: 'baz' }, { something: 42 }]>
|
| 153 |
+
// returns { foo: 'bar', bar: 'baz', 'something': 42 }
|
| 154 |
+
```
|
| 155 |
+
|
| 156 |
+
## License
|
| 157 |
+
|
| 158 |
+
MIT. Made with 💖
|
| 159 |
+
|
| 160 |
+
<!-- Refs -->
|
| 161 |
+
|
| 162 |
+
[npm-version-src]: https://img.shields.io/npm/v/defu?style=flat&colorA=18181B&colorB=F0DB4F
|
| 163 |
+
[npm-version-href]: https://npmjs.com/package/defu
|
| 164 |
+
[npm-downloads-src]: https://img.shields.io/npm/dm/defu?style=flat&colorA=18181B&colorB=F0DB4F
|
| 165 |
+
[npm-downloads-href]: https://npmjs.com/package/defu
|
| 166 |
+
[codecov-src]: https://img.shields.io/codecov/c/gh/unjs/defu/main?style=flat&colorA=18181B&colorB=F0DB4F
|
| 167 |
+
[codecov-href]: https://codecov.io/gh/unjs/defu
|
| 168 |
+
[bundle-src]: https://img.shields.io/bundlephobia/minzip/defu?style=flat&colorA=18181B&colorB=F0DB4F
|
| 169 |
+
[bundle-href]: https://bundlephobia.com/result?p=defu
|
| 170 |
+
[license-src]: https://img.shields.io/github/license/unjs/defu.svg?style=flat&colorA=18181B&colorB=F0DB4F
|
| 171 |
+
[license-href]: https://github.com/unjs/defu/blob/main/LICENSE
|
worker/node_modules/defu/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "defu",
|
| 3 |
+
"version": "6.1.4",
|
| 4 |
+
"description": "Recursively assign default properties. Lightweight and Fast!",
|
| 5 |
+
"repository": "unjs/defu",
|
| 6 |
+
"license": "MIT",
|
| 7 |
+
"exports": {
|
| 8 |
+
".": {
|
| 9 |
+
"types": "./dist/defu.d.ts",
|
| 10 |
+
"import": "./dist/defu.mjs",
|
| 11 |
+
"require": "./lib/defu.cjs"
|
| 12 |
+
}
|
| 13 |
+
},
|
| 14 |
+
"main": "./lib/defu.cjs",
|
| 15 |
+
"module": "./dist/defu.mjs",
|
| 16 |
+
"types": "./dist/defu.d.ts",
|
| 17 |
+
"files": [
|
| 18 |
+
"dist",
|
| 19 |
+
"lib"
|
| 20 |
+
],
|
| 21 |
+
"devDependencies": {
|
| 22 |
+
"@types/node": "^20.10.6",
|
| 23 |
+
"@vitest/coverage-v8": "^1.1.3",
|
| 24 |
+
"changelogen": "^0.5.5",
|
| 25 |
+
"eslint": "^8.56.0",
|
| 26 |
+
"eslint-config-unjs": "^0.2.1",
|
| 27 |
+
"expect-type": "^0.17.3",
|
| 28 |
+
"prettier": "^3.1.1",
|
| 29 |
+
"typescript": "^5.3.3",
|
| 30 |
+
"unbuild": "^2.0.0",
|
| 31 |
+
"vitest": "^1.1.3"
|
| 32 |
+
},
|
| 33 |
+
"packageManager": "pnpm@8.10.2",
|
| 34 |
+
"scripts": {
|
| 35 |
+
"build": "unbuild",
|
| 36 |
+
"dev": "vitest",
|
| 37 |
+
"lint": "eslint --ext .ts src && prettier -c src test",
|
| 38 |
+
"lint:fix": "eslint --ext .ts src --fix && prettier -w src test",
|
| 39 |
+
"release": "pnpm test && changelogen --release && git push --follow-tags && pnpm publish",
|
| 40 |
+
"test": "pnpm lint && pnpm vitest run",
|
| 41 |
+
"test:types": "tsc --noEmit"
|
| 42 |
+
}
|
| 43 |
+
}
|
worker/node_modules/detect-libc/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Apache License
|
| 2 |
+
Version 2.0, January 2004
|
| 3 |
+
http://www.apache.org/licenses/
|
| 4 |
+
|
| 5 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
| 6 |
+
|
| 7 |
+
1. Definitions.
|
| 8 |
+
|
| 9 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
| 10 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
| 11 |
+
|
| 12 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
| 13 |
+
the copyright owner that is granting the License.
|
| 14 |
+
|
| 15 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
| 16 |
+
other entities that control, are controlled by, or are under common
|
| 17 |
+
control with that entity. For the purposes of this definition,
|
| 18 |
+
"control" means (i) the power, direct or indirect, to cause the
|
| 19 |
+
direction or management of such entity, whether by contract or
|
| 20 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
| 21 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
| 22 |
+
|
| 23 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
| 24 |
+
exercising permissions granted by this License.
|
| 25 |
+
|
| 26 |
+
"Source" form shall mean the preferred form for making modifications,
|
| 27 |
+
including but not limited to software source code, documentation
|
| 28 |
+
source, and configuration files.
|
| 29 |
+
|
| 30 |
+
"Object" form shall mean any form resulting from mechanical
|
| 31 |
+
transformation or translation of a Source form, including but
|
| 32 |
+
not limited to compiled object code, generated documentation,
|
| 33 |
+
and conversions to other media types.
|
| 34 |
+
|
| 35 |
+
"Work" shall mean the work of authorship, whether in Source or
|
| 36 |
+
Object form, made available under the License, as indicated by a
|
| 37 |
+
copyright notice that is included in or attached to the work
|
| 38 |
+
(an example is provided in the Appendix below).
|
| 39 |
+
|
| 40 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
| 41 |
+
form, that is based on (or derived from) the Work and for which the
|
| 42 |
+
editorial revisions, annotations, elaborations, or other modifications
|
| 43 |
+
represent, as a whole, an original work of authorship. For the purposes
|
| 44 |
+
of this License, Derivative Works shall not include works that remain
|
| 45 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
| 46 |
+
the Work and Derivative Works thereof.
|
| 47 |
+
|
| 48 |
+
"Contribution" shall mean any work of authorship, including
|
| 49 |
+
the original version of the Work and any modifications or additions
|
| 50 |
+
to that Work or Derivative Works thereof, that is intentionally
|
| 51 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
| 52 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
| 53 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
| 54 |
+
means any form of electronic, verbal, or written communication sent
|
| 55 |
+
to the Licensor or its representatives, including but not limited to
|
| 56 |
+
communication on electronic mailing lists, source code control systems,
|
| 57 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
| 58 |
+
Licensor for the purpose of discussing and improving the Work, but
|
| 59 |
+
excluding communication that is conspicuously marked or otherwise
|
| 60 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
| 61 |
+
|
| 62 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
| 63 |
+
on behalf of whom a Contribution has been received by Licensor and
|
| 64 |
+
subsequently incorporated within the Work.
|
| 65 |
+
|
| 66 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
| 67 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 68 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 69 |
+
copyright license to reproduce, prepare Derivative Works of,
|
| 70 |
+
publicly display, publicly perform, sublicense, and distribute the
|
| 71 |
+
Work and such Derivative Works in Source or Object form.
|
| 72 |
+
|
| 73 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
| 74 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 75 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 76 |
+
(except as stated in this section) patent license to make, have made,
|
| 77 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
| 78 |
+
where such license applies only to those patent claims licensable
|
| 79 |
+
by such Contributor that are necessarily infringed by their
|
| 80 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
| 81 |
+
with the Work to which such Contribution(s) was submitted. If You
|
| 82 |
+
institute patent litigation against any entity (including a
|
| 83 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
| 84 |
+
or a Contribution incorporated within the Work constitutes direct
|
| 85 |
+
or contributory patent infringement, then any patent licenses
|
| 86 |
+
granted to You under this License for that Work shall terminate
|
| 87 |
+
as of the date such litigation is filed.
|
| 88 |
+
|
| 89 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
| 90 |
+
Work or Derivative Works thereof in any medium, with or without
|
| 91 |
+
modifications, and in Source or Object form, provided that You
|
| 92 |
+
meet the following conditions:
|
| 93 |
+
|
| 94 |
+
(a) You must give any other recipients of the Work or
|
| 95 |
+
Derivative Works a copy of this License; and
|
| 96 |
+
|
| 97 |
+
(b) You must cause any modified files to carry prominent notices
|
| 98 |
+
stating that You changed the files; and
|
| 99 |
+
|
| 100 |
+
(c) You must retain, in the Source form of any Derivative Works
|
| 101 |
+
that You distribute, all copyright, patent, trademark, and
|
| 102 |
+
attribution notices from the Source form of the Work,
|
| 103 |
+
excluding those notices that do not pertain to any part of
|
| 104 |
+
the Derivative Works; and
|
| 105 |
+
|
| 106 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
| 107 |
+
distribution, then any Derivative Works that You distribute must
|
| 108 |
+
include a readable copy of the attribution notices contained
|
| 109 |
+
within such NOTICE file, excluding those notices that do not
|
| 110 |
+
pertain to any part of the Derivative Works, in at least one
|
| 111 |
+
of the following places: within a NOTICE text file distributed
|
| 112 |
+
as part of the Derivative Works; within the Source form or
|
| 113 |
+
documentation, if provided along with the Derivative Works; or,
|
| 114 |
+
within a display generated by the Derivative Works, if and
|
| 115 |
+
wherever such third-party notices normally appear. The contents
|
| 116 |
+
of the NOTICE file are for informational purposes only and
|
| 117 |
+
do not modify the License. You may add Your own attribution
|
| 118 |
+
notices within Derivative Works that You distribute, alongside
|
| 119 |
+
or as an addendum to the NOTICE text from the Work, provided
|
| 120 |
+
that such additional attribution notices cannot be construed
|
| 121 |
+
as modifying the License.
|
| 122 |
+
|
| 123 |
+
You may add Your own copyright statement to Your modifications and
|
| 124 |
+
may provide additional or different license terms and conditions
|
| 125 |
+
for use, reproduction, or distribution of Your modifications, or
|
| 126 |
+
for any such Derivative Works as a whole, provided Your use,
|
| 127 |
+
reproduction, and distribution of the Work otherwise complies with
|
| 128 |
+
the conditions stated in this License.
|
| 129 |
+
|
| 130 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
| 131 |
+
any Contribution intentionally submitted for inclusion in the Work
|
| 132 |
+
by You to the Licensor shall be under the terms and conditions of
|
| 133 |
+
this License, without any additional terms or conditions.
|
| 134 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
| 135 |
+
the terms of any separate license agreement you may have executed
|
| 136 |
+
with Licensor regarding such Contributions.
|
| 137 |
+
|
| 138 |
+
6. Trademarks. This License does not grant permission to use the trade
|
| 139 |
+
names, trademarks, service marks, or product names of the Licensor,
|
| 140 |
+
except as required for reasonable and customary use in describing the
|
| 141 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
| 142 |
+
|
| 143 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
| 144 |
+
agreed to in writing, Licensor provides the Work (and each
|
| 145 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
| 146 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
| 147 |
+
implied, including, without limitation, any warranties or conditions
|
| 148 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
| 149 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
| 150 |
+
appropriateness of using or redistributing the Work and assume any
|
| 151 |
+
risks associated with Your exercise of permissions under this License.
|
| 152 |
+
|
| 153 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
| 154 |
+
whether in tort (including negligence), contract, or otherwise,
|
| 155 |
+
unless required by applicable law (such as deliberate and grossly
|
| 156 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
| 157 |
+
liable to You for damages, including any direct, indirect, special,
|
| 158 |
+
incidental, or consequential damages of any character arising as a
|
| 159 |
+
result of this License or out of the use or inability to use the
|
| 160 |
+
Work (including but not limited to damages for loss of goodwill,
|
| 161 |
+
work stoppage, computer failure or malfunction, or any and all
|
| 162 |
+
other commercial damages or losses), even if such Contributor
|
| 163 |
+
has been advised of the possibility of such damages.
|
| 164 |
+
|
| 165 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
| 166 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
| 167 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
| 168 |
+
or other liability obligations and/or rights consistent with this
|
| 169 |
+
License. However, in accepting such obligations, You may act only
|
| 170 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
| 171 |
+
of any other Contributor, and only if You agree to indemnify,
|
| 172 |
+
defend, and hold each Contributor harmless for any liability
|
| 173 |
+
incurred by, or claims asserted against, such Contributor by reason
|
| 174 |
+
of your accepting any such warranty or additional liability.
|
| 175 |
+
|
| 176 |
+
END OF TERMS AND CONDITIONS
|
| 177 |
+
|
| 178 |
+
APPENDIX: How to apply the Apache License to your work.
|
| 179 |
+
|
| 180 |
+
To apply the Apache License to your work, attach the following
|
| 181 |
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
| 182 |
+
replaced with your own identifying information. (Don't include
|
| 183 |
+
the brackets!) The text should be enclosed in the appropriate
|
| 184 |
+
comment syntax for the file format. We also recommend that a
|
| 185 |
+
file or class name and description of purpose be included on the
|
| 186 |
+
same "printed page" as the copyright notice for easier
|
| 187 |
+
identification within third-party archives.
|
| 188 |
+
|
| 189 |
+
Copyright {yyyy} {name of copyright owner}
|
| 190 |
+
|
| 191 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
| 192 |
+
you may not use this file except in compliance with the License.
|
| 193 |
+
You may obtain a copy of the License at
|
| 194 |
+
|
| 195 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
| 196 |
+
|
| 197 |
+
Unless required by applicable law or agreed to in writing, software
|
| 198 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
| 199 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 200 |
+
See the License for the specific language governing permissions and
|
| 201 |
+
limitations under the License.
|
worker/node_modules/detect-libc/README.md
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# detect-libc
|
| 2 |
+
|
| 3 |
+
Node.js module to detect details of the C standard library (libc)
|
| 4 |
+
implementation provided by a given Linux system.
|
| 5 |
+
|
| 6 |
+
Currently supports detection of GNU glibc and MUSL libc.
|
| 7 |
+
|
| 8 |
+
Provides asychronous and synchronous functions for the
|
| 9 |
+
family (e.g. `glibc`, `musl`) and version (e.g. `1.23`, `1.2.3`).
|
| 10 |
+
|
| 11 |
+
The version numbers of libc implementations
|
| 12 |
+
are not guaranteed to be semver-compliant.
|
| 13 |
+
|
| 14 |
+
For previous v1.x releases, please see the
|
| 15 |
+
[v1](https://github.com/lovell/detect-libc/tree/v1) branch.
|
| 16 |
+
|
| 17 |
+
## Install
|
| 18 |
+
|
| 19 |
+
```sh
|
| 20 |
+
npm install detect-libc
|
| 21 |
+
```
|
| 22 |
+
|
| 23 |
+
## API
|
| 24 |
+
|
| 25 |
+
### GLIBC
|
| 26 |
+
|
| 27 |
+
```ts
|
| 28 |
+
const GLIBC: string = 'glibc';
|
| 29 |
+
```
|
| 30 |
+
|
| 31 |
+
A String constant containing the value `glibc`.
|
| 32 |
+
|
| 33 |
+
### MUSL
|
| 34 |
+
|
| 35 |
+
```ts
|
| 36 |
+
const MUSL: string = 'musl';
|
| 37 |
+
```
|
| 38 |
+
|
| 39 |
+
A String constant containing the value `musl`.
|
| 40 |
+
|
| 41 |
+
### family
|
| 42 |
+
|
| 43 |
+
```ts
|
| 44 |
+
function family(): Promise<string | null>;
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
Resolves asychronously with:
|
| 48 |
+
|
| 49 |
+
* `glibc` or `musl` when the libc family can be determined
|
| 50 |
+
* `null` when the libc family cannot be determined
|
| 51 |
+
* `null` when run on a non-Linux platform
|
| 52 |
+
|
| 53 |
+
```js
|
| 54 |
+
const { family, GLIBC, MUSL } = require('detect-libc');
|
| 55 |
+
|
| 56 |
+
switch (await family()) {
|
| 57 |
+
case GLIBC: ...
|
| 58 |
+
case MUSL: ...
|
| 59 |
+
case null: ...
|
| 60 |
+
}
|
| 61 |
+
```
|
| 62 |
+
|
| 63 |
+
### familySync
|
| 64 |
+
|
| 65 |
+
```ts
|
| 66 |
+
function familySync(): string | null;
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
Synchronous version of `family()`.
|
| 70 |
+
|
| 71 |
+
```js
|
| 72 |
+
const { familySync, GLIBC, MUSL } = require('detect-libc');
|
| 73 |
+
|
| 74 |
+
switch (familySync()) {
|
| 75 |
+
case GLIBC: ...
|
| 76 |
+
case MUSL: ...
|
| 77 |
+
case null: ...
|
| 78 |
+
}
|
| 79 |
+
```
|
| 80 |
+
|
| 81 |
+
### version
|
| 82 |
+
|
| 83 |
+
```ts
|
| 84 |
+
function version(): Promise<string | null>;
|
| 85 |
+
```
|
| 86 |
+
|
| 87 |
+
Resolves asychronously with:
|
| 88 |
+
|
| 89 |
+
* The version when it can be determined
|
| 90 |
+
* `null` when the libc family cannot be determined
|
| 91 |
+
* `null` when run on a non-Linux platform
|
| 92 |
+
|
| 93 |
+
```js
|
| 94 |
+
const { version } = require('detect-libc');
|
| 95 |
+
|
| 96 |
+
const v = await version();
|
| 97 |
+
if (v) {
|
| 98 |
+
const [major, minor, patch] = v.split('.');
|
| 99 |
+
}
|
| 100 |
+
```
|
| 101 |
+
|
| 102 |
+
### versionSync
|
| 103 |
+
|
| 104 |
+
```ts
|
| 105 |
+
function versionSync(): string | null;
|
| 106 |
+
```
|
| 107 |
+
|
| 108 |
+
Synchronous version of `version()`.
|
| 109 |
+
|
| 110 |
+
```js
|
| 111 |
+
const { versionSync } = require('detect-libc');
|
| 112 |
+
|
| 113 |
+
const v = versionSync();
|
| 114 |
+
if (v) {
|
| 115 |
+
const [major, minor, patch] = v.split('.');
|
| 116 |
+
}
|
| 117 |
+
```
|
| 118 |
+
|
| 119 |
+
### isNonGlibcLinux
|
| 120 |
+
|
| 121 |
+
```ts
|
| 122 |
+
function isNonGlibcLinux(): Promise<boolean>;
|
| 123 |
+
```
|
| 124 |
+
|
| 125 |
+
Resolves asychronously with:
|
| 126 |
+
|
| 127 |
+
* `false` when the libc family is `glibc`
|
| 128 |
+
* `true` when the libc family is not `glibc`
|
| 129 |
+
* `false` when run on a non-Linux platform
|
| 130 |
+
|
| 131 |
+
```js
|
| 132 |
+
const { isNonGlibcLinux } = require('detect-libc');
|
| 133 |
+
|
| 134 |
+
if (await isNonGlibcLinux()) { ... }
|
| 135 |
+
```
|
| 136 |
+
|
| 137 |
+
### isNonGlibcLinuxSync
|
| 138 |
+
|
| 139 |
+
```ts
|
| 140 |
+
function isNonGlibcLinuxSync(): boolean;
|
| 141 |
+
```
|
| 142 |
+
|
| 143 |
+
Synchronous version of `isNonGlibcLinux()`.
|
| 144 |
+
|
| 145 |
+
```js
|
| 146 |
+
const { isNonGlibcLinuxSync } = require('detect-libc');
|
| 147 |
+
|
| 148 |
+
if (isNonGlibcLinuxSync()) { ... }
|
| 149 |
+
```
|
| 150 |
+
|
| 151 |
+
## Licensing
|
| 152 |
+
|
| 153 |
+
Copyright 2017 Lovell Fuller and others.
|
| 154 |
+
|
| 155 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
| 156 |
+
you may not use this file except in compliance with the License.
|
| 157 |
+
You may obtain a copy of the License at [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0.html)
|
| 158 |
+
|
| 159 |
+
Unless required by applicable law or agreed to in writing, software
|
| 160 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
| 161 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 162 |
+
See the License for the specific language governing permissions and
|
| 163 |
+
limitations under the License.
|
worker/node_modules/detect-libc/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Copyright 2017 Lovell Fuller and others.
|
| 2 |
+
// SPDX-License-Identifier: Apache-2.0
|
| 3 |
+
|
| 4 |
+
export const GLIBC: 'glibc';
|
| 5 |
+
export const MUSL: 'musl';
|
| 6 |
+
|
| 7 |
+
export function family(): Promise<string | null>;
|
| 8 |
+
export function familySync(): string | null;
|
| 9 |
+
|
| 10 |
+
export function isNonGlibcLinux(): Promise<boolean>;
|
| 11 |
+
export function isNonGlibcLinuxSync(): boolean;
|
| 12 |
+
|
| 13 |
+
export function version(): Promise<string | null>;
|
| 14 |
+
export function versionSync(): string | null;
|
worker/node_modules/detect-libc/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "detect-libc",
|
| 3 |
+
"version": "2.1.2",
|
| 4 |
+
"description": "Node.js module to detect the C standard library (libc) implementation family and version",
|
| 5 |
+
"main": "lib/detect-libc.js",
|
| 6 |
+
"files": [
|
| 7 |
+
"lib/",
|
| 8 |
+
"index.d.ts"
|
| 9 |
+
],
|
| 10 |
+
"scripts": {
|
| 11 |
+
"test": "semistandard && nyc --reporter=text --check-coverage --branches=100 ava test/unit.js",
|
| 12 |
+
"changelog": "conventional-changelog -i CHANGELOG.md -s",
|
| 13 |
+
"bench": "node benchmark/detect-libc",
|
| 14 |
+
"bench:calls": "node benchmark/call-familySync.js && sleep 1 && node benchmark/call-isNonGlibcLinuxSync.js && sleep 1 && node benchmark/call-versionSync.js"
|
| 15 |
+
},
|
| 16 |
+
"repository": {
|
| 17 |
+
"type": "git",
|
| 18 |
+
"url": "git://github.com/lovell/detect-libc.git"
|
| 19 |
+
},
|
| 20 |
+
"keywords": [
|
| 21 |
+
"libc",
|
| 22 |
+
"glibc",
|
| 23 |
+
"musl"
|
| 24 |
+
],
|
| 25 |
+
"author": "Lovell Fuller <npm@lovell.info>",
|
| 26 |
+
"contributors": [
|
| 27 |
+
"Niklas Salmoukas <niklas@salmoukas.com>",
|
| 28 |
+
"Vinícius Lourenço <vinyygamerlol@gmail.com>"
|
| 29 |
+
],
|
| 30 |
+
"license": "Apache-2.0",
|
| 31 |
+
"devDependencies": {
|
| 32 |
+
"ava": "^2.4.0",
|
| 33 |
+
"benchmark": "^2.1.4",
|
| 34 |
+
"conventional-changelog-cli": "^5.0.0",
|
| 35 |
+
"eslint-config-standard": "^13.0.1",
|
| 36 |
+
"nyc": "^15.1.0",
|
| 37 |
+
"proxyquire": "^2.1.3",
|
| 38 |
+
"semistandard": "^14.2.3"
|
| 39 |
+
},
|
| 40 |
+
"engines": {
|
| 41 |
+
"node": ">=8"
|
| 42 |
+
},
|
| 43 |
+
"types": "index.d.ts"
|
| 44 |
+
}
|
worker/node_modules/esbuild/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2020 Evan Wallace
|
| 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.
|
worker/node_modules/esbuild/README.md
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# esbuild
|
| 2 |
+
|
| 3 |
+
This is a JavaScript bundler and minifier. See https://github.com/evanw/esbuild and the [JavaScript API documentation](https://esbuild.github.io/api/) for details.
|
worker/node_modules/esbuild/install.js
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var __create = Object.create;
|
| 3 |
+
var __defProp = Object.defineProperty;
|
| 4 |
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
| 5 |
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
| 6 |
+
var __getProtoOf = Object.getPrototypeOf;
|
| 7 |
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
| 8 |
+
var __copyProps = (to, from, except, desc) => {
|
| 9 |
+
if (from && typeof from === "object" || typeof from === "function") {
|
| 10 |
+
for (let key of __getOwnPropNames(from))
|
| 11 |
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
| 12 |
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
| 13 |
+
}
|
| 14 |
+
return to;
|
| 15 |
+
};
|
| 16 |
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
| 17 |
+
// If the importer is in node compatibility mode or this is not an ESM
|
| 18 |
+
// file that has been converted to a CommonJS file using a Babel-
|
| 19 |
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
| 20 |
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
| 21 |
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
| 22 |
+
mod
|
| 23 |
+
));
|
| 24 |
+
|
| 25 |
+
// lib/npm/node-platform.ts
|
| 26 |
+
var fs = require("fs");
|
| 27 |
+
var os = require("os");
|
| 28 |
+
var path = require("path");
|
| 29 |
+
var ESBUILD_BINARY_PATH = process.env.ESBUILD_BINARY_PATH || ESBUILD_BINARY_PATH;
|
| 30 |
+
var isValidBinaryPath = (x) => !!x && x !== "/usr/bin/esbuild";
|
| 31 |
+
var knownWindowsPackages = {
|
| 32 |
+
"win32 arm64 LE": "@esbuild/win32-arm64",
|
| 33 |
+
"win32 ia32 LE": "@esbuild/win32-ia32",
|
| 34 |
+
"win32 x64 LE": "@esbuild/win32-x64"
|
| 35 |
+
};
|
| 36 |
+
var knownUnixlikePackages = {
|
| 37 |
+
"android arm64 LE": "@esbuild/android-arm64",
|
| 38 |
+
"darwin arm64 LE": "@esbuild/darwin-arm64",
|
| 39 |
+
"darwin x64 LE": "@esbuild/darwin-x64",
|
| 40 |
+
"freebsd arm64 LE": "@esbuild/freebsd-arm64",
|
| 41 |
+
"freebsd x64 LE": "@esbuild/freebsd-x64",
|
| 42 |
+
"linux arm LE": "@esbuild/linux-arm",
|
| 43 |
+
"linux arm64 LE": "@esbuild/linux-arm64",
|
| 44 |
+
"linux ia32 LE": "@esbuild/linux-ia32",
|
| 45 |
+
"linux mips64el LE": "@esbuild/linux-mips64el",
|
| 46 |
+
"linux ppc64 LE": "@esbuild/linux-ppc64",
|
| 47 |
+
"linux riscv64 LE": "@esbuild/linux-riscv64",
|
| 48 |
+
"linux s390x BE": "@esbuild/linux-s390x",
|
| 49 |
+
"linux x64 LE": "@esbuild/linux-x64",
|
| 50 |
+
"linux loong64 LE": "@esbuild/linux-loong64",
|
| 51 |
+
"netbsd x64 LE": "@esbuild/netbsd-x64",
|
| 52 |
+
"openbsd x64 LE": "@esbuild/openbsd-x64",
|
| 53 |
+
"sunos x64 LE": "@esbuild/sunos-x64"
|
| 54 |
+
};
|
| 55 |
+
var knownWebAssemblyFallbackPackages = {
|
| 56 |
+
"android arm LE": "@esbuild/android-arm",
|
| 57 |
+
"android x64 LE": "@esbuild/android-x64"
|
| 58 |
+
};
|
| 59 |
+
function pkgAndSubpathForCurrentPlatform() {
|
| 60 |
+
let pkg;
|
| 61 |
+
let subpath;
|
| 62 |
+
let isWASM = false;
|
| 63 |
+
let platformKey = `${process.platform} ${os.arch()} ${os.endianness()}`;
|
| 64 |
+
if (platformKey in knownWindowsPackages) {
|
| 65 |
+
pkg = knownWindowsPackages[platformKey];
|
| 66 |
+
subpath = "esbuild.exe";
|
| 67 |
+
} else if (platformKey in knownUnixlikePackages) {
|
| 68 |
+
pkg = knownUnixlikePackages[platformKey];
|
| 69 |
+
subpath = "bin/esbuild";
|
| 70 |
+
} else if (platformKey in knownWebAssemblyFallbackPackages) {
|
| 71 |
+
pkg = knownWebAssemblyFallbackPackages[platformKey];
|
| 72 |
+
subpath = "bin/esbuild";
|
| 73 |
+
isWASM = true;
|
| 74 |
+
} else {
|
| 75 |
+
throw new Error(`Unsupported platform: ${platformKey}`);
|
| 76 |
+
}
|
| 77 |
+
return { pkg, subpath, isWASM };
|
| 78 |
+
}
|
| 79 |
+
function downloadedBinPath(pkg, subpath) {
|
| 80 |
+
const esbuildLibDir = path.dirname(require.resolve("esbuild"));
|
| 81 |
+
return path.join(esbuildLibDir, `downloaded-${pkg.replace("/", "-")}-${path.basename(subpath)}`);
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
// lib/npm/node-install.ts
|
| 85 |
+
var fs2 = require("fs");
|
| 86 |
+
var os2 = require("os");
|
| 87 |
+
var path2 = require("path");
|
| 88 |
+
var zlib = require("zlib");
|
| 89 |
+
var https = require("https");
|
| 90 |
+
var child_process = require("child_process");
|
| 91 |
+
var versionFromPackageJSON = require(path2.join(__dirname, "package.json")).version;
|
| 92 |
+
var toPath = path2.join(__dirname, "bin", "esbuild");
|
| 93 |
+
var isToPathJS = true;
|
| 94 |
+
function validateBinaryVersion(...command) {
|
| 95 |
+
command.push("--version");
|
| 96 |
+
let stdout;
|
| 97 |
+
try {
|
| 98 |
+
stdout = child_process.execFileSync(command.shift(), command, {
|
| 99 |
+
// Without this, this install script strangely crashes with the error
|
| 100 |
+
// "EACCES: permission denied, write" but only on Ubuntu Linux when node is
|
| 101 |
+
// installed from the Snap Store. This is not a problem when you download
|
| 102 |
+
// the official version of node. The problem appears to be that stderr
|
| 103 |
+
// (i.e. file descriptor 2) isn't writable?
|
| 104 |
+
//
|
| 105 |
+
// More info:
|
| 106 |
+
// - https://snapcraft.io/ (what the Snap Store is)
|
| 107 |
+
// - https://nodejs.org/dist/ (download the official version of node)
|
| 108 |
+
// - https://github.com/evanw/esbuild/issues/1711#issuecomment-1027554035
|
| 109 |
+
//
|
| 110 |
+
stdio: "pipe"
|
| 111 |
+
}).toString().trim();
|
| 112 |
+
} catch (err) {
|
| 113 |
+
if (os2.platform() === "darwin" && /_SecTrustEvaluateWithError/.test(err + "")) {
|
| 114 |
+
let os3 = "this version of macOS";
|
| 115 |
+
try {
|
| 116 |
+
os3 = "macOS " + child_process.execFileSync("sw_vers", ["-productVersion"]).toString().trim();
|
| 117 |
+
} catch {
|
| 118 |
+
}
|
| 119 |
+
throw new Error(`The "esbuild" package cannot be installed because ${os3} is too outdated.
|
| 120 |
+
|
| 121 |
+
The Go compiler (which esbuild relies on) no longer supports ${os3},
|
| 122 |
+
which means the "esbuild" binary executable can't be run. You can either:
|
| 123 |
+
|
| 124 |
+
* Update your version of macOS to one that the Go compiler supports
|
| 125 |
+
* Use the "esbuild-wasm" package instead of the "esbuild" package
|
| 126 |
+
* Build esbuild yourself using an older version of the Go compiler
|
| 127 |
+
`);
|
| 128 |
+
}
|
| 129 |
+
throw err;
|
| 130 |
+
}
|
| 131 |
+
if (stdout !== versionFromPackageJSON) {
|
| 132 |
+
throw new Error(`Expected ${JSON.stringify(versionFromPackageJSON)} but got ${JSON.stringify(stdout)}`);
|
| 133 |
+
}
|
| 134 |
+
}
|
| 135 |
+
function isYarn() {
|
| 136 |
+
const { npm_config_user_agent } = process.env;
|
| 137 |
+
if (npm_config_user_agent) {
|
| 138 |
+
return /\byarn\//.test(npm_config_user_agent);
|
| 139 |
+
}
|
| 140 |
+
return false;
|
| 141 |
+
}
|
| 142 |
+
function fetch(url) {
|
| 143 |
+
return new Promise((resolve, reject) => {
|
| 144 |
+
https.get(url, (res) => {
|
| 145 |
+
if ((res.statusCode === 301 || res.statusCode === 302) && res.headers.location)
|
| 146 |
+
return fetch(res.headers.location).then(resolve, reject);
|
| 147 |
+
if (res.statusCode !== 200)
|
| 148 |
+
return reject(new Error(`Server responded with ${res.statusCode}`));
|
| 149 |
+
let chunks = [];
|
| 150 |
+
res.on("data", (chunk) => chunks.push(chunk));
|
| 151 |
+
res.on("end", () => resolve(Buffer.concat(chunks)));
|
| 152 |
+
}).on("error", reject);
|
| 153 |
+
});
|
| 154 |
+
}
|
| 155 |
+
function extractFileFromTarGzip(buffer, subpath) {
|
| 156 |
+
try {
|
| 157 |
+
buffer = zlib.unzipSync(buffer);
|
| 158 |
+
} catch (err) {
|
| 159 |
+
throw new Error(`Invalid gzip data in archive: ${err && err.message || err}`);
|
| 160 |
+
}
|
| 161 |
+
let str = (i, n) => String.fromCharCode(...buffer.subarray(i, i + n)).replace(/\0.*$/, "");
|
| 162 |
+
let offset = 0;
|
| 163 |
+
subpath = `package/${subpath}`;
|
| 164 |
+
while (offset < buffer.length) {
|
| 165 |
+
let name = str(offset, 100);
|
| 166 |
+
let size = parseInt(str(offset + 124, 12), 8);
|
| 167 |
+
offset += 512;
|
| 168 |
+
if (!isNaN(size)) {
|
| 169 |
+
if (name === subpath)
|
| 170 |
+
return buffer.subarray(offset, offset + size);
|
| 171 |
+
offset += size + 511 & ~511;
|
| 172 |
+
}
|
| 173 |
+
}
|
| 174 |
+
throw new Error(`Could not find ${JSON.stringify(subpath)} in archive`);
|
| 175 |
+
}
|
| 176 |
+
function installUsingNPM(pkg, subpath, binPath) {
|
| 177 |
+
const env = { ...process.env, npm_config_global: void 0 };
|
| 178 |
+
const esbuildLibDir = path2.dirname(require.resolve("esbuild"));
|
| 179 |
+
const installDir = path2.join(esbuildLibDir, "npm-install");
|
| 180 |
+
fs2.mkdirSync(installDir);
|
| 181 |
+
try {
|
| 182 |
+
fs2.writeFileSync(path2.join(installDir, "package.json"), "{}");
|
| 183 |
+
child_process.execSync(
|
| 184 |
+
`npm install --loglevel=error --prefer-offline --no-audit --progress=false ${pkg}@${versionFromPackageJSON}`,
|
| 185 |
+
{ cwd: installDir, stdio: "pipe", env }
|
| 186 |
+
);
|
| 187 |
+
const installedBinPath = path2.join(installDir, "node_modules", pkg, subpath);
|
| 188 |
+
fs2.renameSync(installedBinPath, binPath);
|
| 189 |
+
} finally {
|
| 190 |
+
try {
|
| 191 |
+
removeRecursive(installDir);
|
| 192 |
+
} catch {
|
| 193 |
+
}
|
| 194 |
+
}
|
| 195 |
+
}
|
| 196 |
+
function removeRecursive(dir) {
|
| 197 |
+
for (const entry of fs2.readdirSync(dir)) {
|
| 198 |
+
const entryPath = path2.join(dir, entry);
|
| 199 |
+
let stats;
|
| 200 |
+
try {
|
| 201 |
+
stats = fs2.lstatSync(entryPath);
|
| 202 |
+
} catch {
|
| 203 |
+
continue;
|
| 204 |
+
}
|
| 205 |
+
if (stats.isDirectory())
|
| 206 |
+
removeRecursive(entryPath);
|
| 207 |
+
else
|
| 208 |
+
fs2.unlinkSync(entryPath);
|
| 209 |
+
}
|
| 210 |
+
fs2.rmdirSync(dir);
|
| 211 |
+
}
|
| 212 |
+
function applyManualBinaryPathOverride(overridePath) {
|
| 213 |
+
const pathString = JSON.stringify(overridePath);
|
| 214 |
+
fs2.writeFileSync(toPath, `#!/usr/bin/env node
|
| 215 |
+
require('child_process').execFileSync(${pathString}, process.argv.slice(2), { stdio: 'inherit' });
|
| 216 |
+
`);
|
| 217 |
+
const libMain = path2.join(__dirname, "lib", "main.js");
|
| 218 |
+
const code = fs2.readFileSync(libMain, "utf8");
|
| 219 |
+
fs2.writeFileSync(libMain, `var ESBUILD_BINARY_PATH = ${pathString};
|
| 220 |
+
${code}`);
|
| 221 |
+
}
|
| 222 |
+
function maybeOptimizePackage(binPath) {
|
| 223 |
+
if (os2.platform() !== "win32" && !isYarn()) {
|
| 224 |
+
const tempPath = path2.join(__dirname, "bin-esbuild");
|
| 225 |
+
try {
|
| 226 |
+
fs2.linkSync(binPath, tempPath);
|
| 227 |
+
fs2.renameSync(tempPath, toPath);
|
| 228 |
+
isToPathJS = false;
|
| 229 |
+
fs2.unlinkSync(tempPath);
|
| 230 |
+
} catch {
|
| 231 |
+
}
|
| 232 |
+
}
|
| 233 |
+
}
|
| 234 |
+
async function downloadDirectlyFromNPM(pkg, subpath, binPath) {
|
| 235 |
+
const url = `https://registry.npmjs.org/${pkg}/-/${pkg.replace("@esbuild/", "")}-${versionFromPackageJSON}.tgz`;
|
| 236 |
+
console.error(`[esbuild] Trying to download ${JSON.stringify(url)}`);
|
| 237 |
+
try {
|
| 238 |
+
fs2.writeFileSync(binPath, extractFileFromTarGzip(await fetch(url), subpath));
|
| 239 |
+
fs2.chmodSync(binPath, 493);
|
| 240 |
+
} catch (e) {
|
| 241 |
+
console.error(`[esbuild] Failed to download ${JSON.stringify(url)}: ${e && e.message || e}`);
|
| 242 |
+
throw e;
|
| 243 |
+
}
|
| 244 |
+
}
|
| 245 |
+
async function checkAndPreparePackage() {
|
| 246 |
+
if (isValidBinaryPath(ESBUILD_BINARY_PATH)) {
|
| 247 |
+
if (!fs2.existsSync(ESBUILD_BINARY_PATH)) {
|
| 248 |
+
console.warn(`[esbuild] Ignoring bad configuration: ESBUILD_BINARY_PATH=${ESBUILD_BINARY_PATH}`);
|
| 249 |
+
} else {
|
| 250 |
+
applyManualBinaryPathOverride(ESBUILD_BINARY_PATH);
|
| 251 |
+
return;
|
| 252 |
+
}
|
| 253 |
+
}
|
| 254 |
+
const { pkg, subpath } = pkgAndSubpathForCurrentPlatform();
|
| 255 |
+
let binPath;
|
| 256 |
+
try {
|
| 257 |
+
binPath = require.resolve(`${pkg}/${subpath}`);
|
| 258 |
+
} catch (e) {
|
| 259 |
+
console.error(`[esbuild] Failed to find package "${pkg}" on the file system
|
| 260 |
+
|
| 261 |
+
This can happen if you use the "--no-optional" flag. The "optionalDependencies"
|
| 262 |
+
package.json feature is used by esbuild to install the correct binary executable
|
| 263 |
+
for your current platform. This install script will now attempt to work around
|
| 264 |
+
this. If that fails, you need to remove the "--no-optional" flag to use esbuild.
|
| 265 |
+
`);
|
| 266 |
+
binPath = downloadedBinPath(pkg, subpath);
|
| 267 |
+
try {
|
| 268 |
+
console.error(`[esbuild] Trying to install package "${pkg}" using npm`);
|
| 269 |
+
installUsingNPM(pkg, subpath, binPath);
|
| 270 |
+
} catch (e2) {
|
| 271 |
+
console.error(`[esbuild] Failed to install package "${pkg}" using npm: ${e2 && e2.message || e2}`);
|
| 272 |
+
try {
|
| 273 |
+
await downloadDirectlyFromNPM(pkg, subpath, binPath);
|
| 274 |
+
} catch (e3) {
|
| 275 |
+
throw new Error(`Failed to install package "${pkg}"`);
|
| 276 |
+
}
|
| 277 |
+
}
|
| 278 |
+
}
|
| 279 |
+
maybeOptimizePackage(binPath);
|
| 280 |
+
}
|
| 281 |
+
checkAndPreparePackage().then(() => {
|
| 282 |
+
if (isToPathJS) {
|
| 283 |
+
validateBinaryVersion(process.execPath, toPath);
|
| 284 |
+
} else {
|
| 285 |
+
validateBinaryVersion(toPath);
|
| 286 |
+
}
|
| 287 |
+
});
|
worker/node_modules/esbuild/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "esbuild",
|
| 3 |
+
"version": "0.17.19",
|
| 4 |
+
"description": "An extremely fast JavaScript and CSS bundler and minifier.",
|
| 5 |
+
"repository": "https://github.com/evanw/esbuild",
|
| 6 |
+
"scripts": {
|
| 7 |
+
"postinstall": "node install.js"
|
| 8 |
+
},
|
| 9 |
+
"main": "lib/main.js",
|
| 10 |
+
"types": "lib/main.d.ts",
|
| 11 |
+
"engines": {
|
| 12 |
+
"node": ">=12"
|
| 13 |
+
},
|
| 14 |
+
"bin": {
|
| 15 |
+
"esbuild": "bin/esbuild"
|
| 16 |
+
},
|
| 17 |
+
"optionalDependencies": {
|
| 18 |
+
"@esbuild/android-arm": "0.17.19",
|
| 19 |
+
"@esbuild/android-arm64": "0.17.19",
|
| 20 |
+
"@esbuild/android-x64": "0.17.19",
|
| 21 |
+
"@esbuild/darwin-arm64": "0.17.19",
|
| 22 |
+
"@esbuild/darwin-x64": "0.17.19",
|
| 23 |
+
"@esbuild/freebsd-arm64": "0.17.19",
|
| 24 |
+
"@esbuild/freebsd-x64": "0.17.19",
|
| 25 |
+
"@esbuild/linux-arm": "0.17.19",
|
| 26 |
+
"@esbuild/linux-arm64": "0.17.19",
|
| 27 |
+
"@esbuild/linux-ia32": "0.17.19",
|
| 28 |
+
"@esbuild/linux-loong64": "0.17.19",
|
| 29 |
+
"@esbuild/linux-mips64el": "0.17.19",
|
| 30 |
+
"@esbuild/linux-ppc64": "0.17.19",
|
| 31 |
+
"@esbuild/linux-riscv64": "0.17.19",
|
| 32 |
+
"@esbuild/linux-s390x": "0.17.19",
|
| 33 |
+
"@esbuild/linux-x64": "0.17.19",
|
| 34 |
+
"@esbuild/netbsd-x64": "0.17.19",
|
| 35 |
+
"@esbuild/openbsd-x64": "0.17.19",
|
| 36 |
+
"@esbuild/sunos-x64": "0.17.19",
|
| 37 |
+
"@esbuild/win32-arm64": "0.17.19",
|
| 38 |
+
"@esbuild/win32-ia32": "0.17.19",
|
| 39 |
+
"@esbuild/win32-x64": "0.17.19"
|
| 40 |
+
},
|
| 41 |
+
"license": "MIT"
|
| 42 |
+
}
|
worker/node_modules/escape-string-regexp/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
Escape RegExp special characters.
|
| 3 |
+
|
| 4 |
+
You can also use this to escape a string that is inserted into the middle of a regex, for example, into a character class.
|
| 5 |
+
|
| 6 |
+
@example
|
| 7 |
+
```
|
| 8 |
+
import escapeStringRegexp = require('escape-string-regexp');
|
| 9 |
+
|
| 10 |
+
const escapedString = escapeStringRegexp('How much $ for a 🦄?');
|
| 11 |
+
//=> 'How much \\$ for a 🦄\\?'
|
| 12 |
+
|
| 13 |
+
new RegExp(escapedString);
|
| 14 |
+
```
|
| 15 |
+
*/
|
| 16 |
+
declare const escapeStringRegexp: (string: string) => string;
|
| 17 |
+
|
| 18 |
+
export = escapeStringRegexp;
|
worker/node_modules/escape-string-regexp/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
module.exports = string => {
|
| 4 |
+
if (typeof string !== 'string') {
|
| 5 |
+
throw new TypeError('Expected a string');
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
// Escape characters with special meaning either inside or outside character sets.
|
| 9 |
+
// Use a simple backslash escape when it’s always valid, and a \unnnn escape when the simpler form would be disallowed by Unicode patterns’ stricter grammar.
|
| 10 |
+
return string
|
| 11 |
+
.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&')
|
| 12 |
+
.replace(/-/g, '\\x2d');
|
| 13 |
+
};
|