commit
Showing
125 changed files
with
4865 additions
and
0 deletions
node_modules/decompress-response/index.d.ts
0 → 100644
| 1 | /// <reference types="node"/> | ||
| 2 | import {IncomingMessage} from 'http'; | ||
| 3 | |||
| 4 | /** | ||
| 5 | Decompress a HTTP response if needed. | ||
| 6 | |||
| 7 | @param response - The HTTP incoming stream with compressed data. | ||
| 8 | @returns The decompressed HTTP response stream. | ||
| 9 | |||
| 10 | @example | ||
| 11 | ``` | ||
| 12 | import {http} from 'http'; | ||
| 13 | import decompressResponse = require('decompress-response'); | ||
| 14 | |||
| 15 | http.get('https://sindresorhus.com', response => { | ||
| 16 | response = decompressResponse(response); | ||
| 17 | }); | ||
| 18 | ``` | ||
| 19 | */ | ||
| 20 | declare function decompressResponse(response: IncomingMessage): IncomingMessage; | ||
| 21 | |||
| 22 | export = decompressResponse; |
node_modules/decompress-response/index.js
0 → 100644
| 1 | 'use strict'; | ||
| 2 | const {Transform, PassThrough} = require('stream'); | ||
| 3 | const zlib = require('zlib'); | ||
| 4 | const mimicResponse = require('mimic-response'); | ||
| 5 | |||
| 6 | module.exports = response => { | ||
| 7 | const contentEncoding = (response.headers['content-encoding'] || '').toLowerCase(); | ||
| 8 | |||
| 9 | if (!['gzip', 'deflate', 'br'].includes(contentEncoding)) { | ||
| 10 | return response; | ||
| 11 | } | ||
| 12 | |||
| 13 | // TODO: Remove this when targeting Node.js 12. | ||
| 14 | const isBrotli = contentEncoding === 'br'; | ||
| 15 | if (isBrotli && typeof zlib.createBrotliDecompress !== 'function') { | ||
| 16 | response.destroy(new Error('Brotli is not supported on Node.js < 12')); | ||
| 17 | return response; | ||
| 18 | } | ||
| 19 | |||
| 20 | let isEmpty = true; | ||
| 21 | |||
| 22 | const checker = new Transform({ | ||
| 23 | transform(data, _encoding, callback) { | ||
| 24 | isEmpty = false; | ||
| 25 | |||
| 26 | callback(null, data); | ||
| 27 | }, | ||
| 28 | |||
| 29 | flush(callback) { | ||
| 30 | callback(); | ||
| 31 | } | ||
| 32 | }); | ||
| 33 | |||
| 34 | const finalStream = new PassThrough({ | ||
| 35 | autoDestroy: false, | ||
| 36 | destroy(error, callback) { | ||
| 37 | response.destroy(); | ||
| 38 | |||
| 39 | callback(error); | ||
| 40 | } | ||
| 41 | }); | ||
| 42 | |||
| 43 | const decompressStream = isBrotli ? zlib.createBrotliDecompress() : zlib.createUnzip(); | ||
| 44 | |||
| 45 | decompressStream.once('error', error => { | ||
| 46 | if (isEmpty && !response.readable) { | ||
| 47 | finalStream.end(); | ||
| 48 | return; | ||
| 49 | } | ||
| 50 | |||
| 51 | finalStream.destroy(error); | ||
| 52 | }); | ||
| 53 | |||
| 54 | mimicResponse(response, finalStream); | ||
| 55 | response.pipe(checker).pipe(decompressStream).pipe(finalStream); | ||
| 56 | |||
| 57 | return finalStream; | ||
| 58 | }; |
node_modules/decompress-response/license
0 → 100644
| 1 | MIT License | ||
| 2 | |||
| 3 | Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com) | ||
| 4 | |||
| 5 | 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: | ||
| 6 | |||
| 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
| 8 | |||
| 9 | 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. |
| 1 | { | ||
| 2 | "_from": "decompress-response@^6.0.0", | ||
| 3 | "_id": "decompress-response@6.0.0", | ||
| 4 | "_inBundle": false, | ||
| 5 | "_integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==", | ||
| 6 | "_location": "/decompress-response", | ||
| 7 | "_phantomChildren": {}, | ||
| 8 | "_requested": { | ||
| 9 | "type": "range", | ||
| 10 | "registry": true, | ||
| 11 | "raw": "decompress-response@^6.0.0", | ||
| 12 | "name": "decompress-response", | ||
| 13 | "escapedName": "decompress-response", | ||
| 14 | "rawSpec": "^6.0.0", | ||
| 15 | "saveSpec": null, | ||
| 16 | "fetchSpec": "^6.0.0" | ||
| 17 | }, | ||
| 18 | "_requiredBy": [ | ||
| 19 | "/simple-get" | ||
| 20 | ], | ||
| 21 | "_resolved": "https://registry.npmmirror.com/decompress-response/-/decompress-response-6.0.0.tgz", | ||
| 22 | "_shasum": "ca387612ddb7e104bd16d85aab00d5ecf09c66fc", | ||
| 23 | "_spec": "decompress-response@^6.0.0", | ||
| 24 | "_where": "/Users/zhanghao/brcode/br-client/node_modules/simple-get", | ||
| 25 | "author": { | ||
| 26 | "name": "Sindre Sorhus", | ||
| 27 | "email": "sindresorhus@gmail.com", | ||
| 28 | "url": "https://sindresorhus.com" | ||
| 29 | }, | ||
| 30 | "bugs": { | ||
| 31 | "url": "https://github.com/sindresorhus/decompress-response/issues" | ||
| 32 | }, | ||
| 33 | "bundleDependencies": false, | ||
| 34 | "dependencies": { | ||
| 35 | "mimic-response": "^3.1.0" | ||
| 36 | }, | ||
| 37 | "deprecated": false, | ||
| 38 | "description": "Decompress a HTTP response if needed", | ||
| 39 | "devDependencies": { | ||
| 40 | "@types/node": "^14.0.1", | ||
| 41 | "ava": "^2.2.0", | ||
| 42 | "get-stream": "^5.0.0", | ||
| 43 | "pify": "^5.0.0", | ||
| 44 | "tsd": "^0.11.0", | ||
| 45 | "xo": "^0.30.0" | ||
| 46 | }, | ||
| 47 | "engines": { | ||
| 48 | "node": ">=10" | ||
| 49 | }, | ||
| 50 | "files": [ | ||
| 51 | "index.js", | ||
| 52 | "index.d.ts" | ||
| 53 | ], | ||
| 54 | "funding": "https://github.com/sponsors/sindresorhus", | ||
| 55 | "homepage": "https://github.com/sindresorhus/decompress-response#readme", | ||
| 56 | "keywords": [ | ||
| 57 | "decompress", | ||
| 58 | "response", | ||
| 59 | "http", | ||
| 60 | "https", | ||
| 61 | "zlib", | ||
| 62 | "gzip", | ||
| 63 | "zip", | ||
| 64 | "deflate", | ||
| 65 | "unzip", | ||
| 66 | "ungzip", | ||
| 67 | "incoming", | ||
| 68 | "message", | ||
| 69 | "stream", | ||
| 70 | "compressed", | ||
| 71 | "brotli" | ||
| 72 | ], | ||
| 73 | "license": "MIT", | ||
| 74 | "name": "decompress-response", | ||
| 75 | "repository": { | ||
| 76 | "type": "git", | ||
| 77 | "url": "git+https://github.com/sindresorhus/decompress-response.git" | ||
| 78 | }, | ||
| 79 | "scripts": { | ||
| 80 | "test": "xo && ava && tsd" | ||
| 81 | }, | ||
| 82 | "version": "6.0.0", | ||
| 83 | "xo": { | ||
| 84 | "rules": { | ||
| 85 | "@typescript-eslint/prefer-readonly-parameter-types": "off" | ||
| 86 | } | ||
| 87 | } | ||
| 88 | } |
node_modules/decompress-response/readme.md
0 → 100644
| 1 | # decompress-response [](https://travis-ci.com/sindresorhus/decompress-response) | ||
| 2 | |||
| 3 | > Decompress a HTTP response if needed | ||
| 4 | |||
| 5 | Decompresses the [response](https://nodejs.org/api/http.html#http_class_http_incomingmessage) from [`http.request`](https://nodejs.org/api/http.html#http_http_request_options_callback) if it's gzipped, deflated or compressed with Brotli, otherwise just passes it through. | ||
| 6 | |||
| 7 | Used by [`got`](https://github.com/sindresorhus/got). | ||
| 8 | |||
| 9 | ## Install | ||
| 10 | |||
| 11 | ``` | ||
| 12 | $ npm install decompress-response | ||
| 13 | ``` | ||
| 14 | |||
| 15 | ## Usage | ||
| 16 | |||
| 17 | ```js | ||
| 18 | const http = require('http'); | ||
| 19 | const decompressResponse = require('decompress-response'); | ||
| 20 | |||
| 21 | http.get('https://sindresorhus.com', response => { | ||
| 22 | response = decompressResponse(response); | ||
| 23 | }); | ||
| 24 | ``` | ||
| 25 | |||
| 26 | ## API | ||
| 27 | |||
| 28 | ### decompressResponse(response) | ||
| 29 | |||
| 30 | Returns the decompressed HTTP response stream. | ||
| 31 | |||
| 32 | #### response | ||
| 33 | |||
| 34 | Type: [`http.IncomingMessage`](https://nodejs.org/api/http.html#http_class_http_incomingmessage) | ||
| 35 | |||
| 36 | The HTTP incoming stream with compressed data. | ||
| 37 | |||
| 38 | --- | ||
| 39 | |||
| 40 | <div align="center"> | ||
| 41 | <b> | ||
| 42 | <a href="https://tidelift.com/subscription/pkg/npm-decompress-response?utm_source=npm-decompress-response&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a> | ||
| 43 | </b> | ||
| 44 | <br> | ||
| 45 | <sub> | ||
| 46 | Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies. | ||
| 47 | </sub> | ||
| 48 | </div> |
node_modules/js-binary-schema-parser/LICENSE
0 → 100644
| 1 | The MIT License (MIT) | ||
| 2 | |||
| 3 | Copyright (c) 2015 Matt Way | ||
| 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. | ||
| 22 |
| 1 | # js Binary Schema Parser | ||
| 2 | |||
| 3 | Parse binary files in javascript using a schema to convert to plain objects. | ||
| 4 | |||
| 5 | Years ago I needed to parse GIF images for our **[Ruffle][1]** messaging app. While this readme describes how to parse binary files in general, our _[GIF Parser][2]_ library exhibits a full use of this library (including a _[demo][2]_). I suggest looking at the other library for a quick understanding. | ||
| 6 | |||
| 7 | Basically, you provide a schema object and some data, and it will step through the binary data, and convert it into the object defined by your schema. Included in this library is a parser for the `Uint8TypedArray`, but it is easy to add them for your own types if necessary. It can parse bytes, arrays, chunks, conditionals, loops, etc. | ||
| 8 | |||
| 9 | ### How to Use | ||
| 10 | |||
| 11 | _Installation:_ | ||
| 12 | |||
| 13 | npm install js-binary-schema-parser | ||
| 14 | |||
| 15 | _Create a schema and parse a file:_ | ||
| 16 | |||
| 17 | import { parse, conditional } from 'js-binary-schema-parser' | ||
| 18 | import { buildStream, readByte } from 'js-binary-schema-parser/lib/parsers/uint8' | ||
| 19 | |||
| 20 | const schema = [ | ||
| 21 | // part definitions... | ||
| 22 | { someKey: readByte() } | ||
| 23 | ]; | ||
| 24 | |||
| 25 | // get the input file data | ||
| 26 | const data = new Uint8Array(fileArrayBuffer); | ||
| 27 | // create a stream object and parse it | ||
| 28 | const parsedObject = parse(buildStream(data), schema) | ||
| 29 | |||
| 30 | ### Schemas | ||
| 31 | |||
| 32 | So far in this library there is only one built in schema, which is for the GIF format. You can import included schemas like: | ||
| 33 | |||
| 34 | import GIF from 'js-binary-schema-parser/lib/schemas/gif' | ||
| 35 | |||
| 36 | Schemas are an array of _parts_, which are objects containing a single key label, and the parser to use at that point in time. This format was chosen to ensure parse ordering was consistent. _Parts_ can also contain other parts internally, and include syntax for loops, and conditionals. You can also include your own custom functions for parsing, providing direct access to the given data stream. Below is an example of a schema using the `Uint8TypedArray` parser provided to parse the GIF format header. You can also see a full example [here][2] of parsing entire GIF files. | ||
| 37 | |||
| 38 | ### Example | ||
| 39 | |||
| 40 | var gifSchema = [ | ||
| 41 | { | ||
| 42 | label: 'header', // gif header | ||
| 43 | parts: [ | ||
| 44 | { label: 'signature', parser: Parsers.readString(3) }, | ||
| 45 | { label: 'version', parser: Parsers.readString(3) } | ||
| 46 | ] | ||
| 47 | },{ | ||
| 48 | label: 'lsd', // local screen descriptor | ||
| 49 | parts: [ | ||
| 50 | { label: 'width', parser: Parsers.readUnsigned(true) }, | ||
| 51 | { label: 'height', parser: Parsers.readUnsigned(true) }, | ||
| 52 | { label: 'gct', bits: { | ||
| 53 | exists: { index: 0 }, | ||
| 54 | resolution: { index: 1, length: 3 }, | ||
| 55 | sort: { index: 4 }, | ||
| 56 | size: { index: 5, length: 3 } | ||
| 57 | }}, | ||
| 58 | { label: 'backgroundColorIndex', parser: Parsers.readByte() }, | ||
| 59 | { label: 'pixelAspectRatio', parser: Parsers.readByte() } | ||
| 60 | ] | ||
| 61 | } | ||
| 62 | ]; | ||
| 63 | |||
| 64 | ### Why this parser? | ||
| 65 | |||
| 66 | There are other good parsers around, like [jBinary][4], but we weren't a fan of relying on object key ordering, and defining parser types as strings. This one is also extremely small, and easily exstensible in any way you want. | ||
| 67 | |||
| 68 | ### Demo | ||
| 69 | |||
| 70 | You can see a full demo **[here][2]** which uses this lib to parse GIF files for manipulation. | ||
| 71 | |||
| 72 | ### Who are we? | ||
| 73 | |||
| 74 | [Matt Way][3] & [Nick Drewe][5] | ||
| 75 | |||
| 76 | [Wethrift.com][6] | ||
| 77 | |||
| 78 | [1]: https://www.producthunt.com/posts/ruffle | ||
| 79 | [2]: https://github.com/matt-way/gifuct-js | ||
| 80 | [3]: https://twitter.com/_MattWay | ||
| 81 | [4]: https://github.com/jDataView/jBinary | ||
| 82 | [5]: https://twitter.com/nickdrewe | ||
| 83 | [6]: https://wethrift.com |
69 Bytes
75.8 KB
2.91 MB
| 1 | "use strict"; | ||
| 2 | |||
| 3 | Object.defineProperty(exports, "__esModule", { | ||
| 4 | value: true | ||
| 5 | }); | ||
| 6 | exports.loop = exports.conditional = exports.parse = void 0; | ||
| 7 | |||
| 8 | var parse = function parse(stream, schema) { | ||
| 9 | var result = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
| 10 | var parent = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : result; | ||
| 11 | |||
| 12 | if (Array.isArray(schema)) { | ||
| 13 | schema.forEach(function (partSchema) { | ||
| 14 | return parse(stream, partSchema, result, parent); | ||
| 15 | }); | ||
| 16 | } else if (typeof schema === 'function') { | ||
| 17 | schema(stream, result, parent, parse); | ||
| 18 | } else { | ||
| 19 | var key = Object.keys(schema)[0]; | ||
| 20 | |||
| 21 | if (Array.isArray(schema[key])) { | ||
| 22 | parent[key] = {}; | ||
| 23 | parse(stream, schema[key], result, parent[key]); | ||
| 24 | } else { | ||
| 25 | parent[key] = schema[key](stream, result, parent, parse); | ||
| 26 | } | ||
| 27 | } | ||
| 28 | |||
| 29 | return result; | ||
| 30 | }; | ||
| 31 | |||
| 32 | exports.parse = parse; | ||
| 33 | |||
| 34 | var conditional = function conditional(schema, conditionFunc) { | ||
| 35 | return function (stream, result, parent, parse) { | ||
| 36 | if (conditionFunc(stream, result, parent)) { | ||
| 37 | parse(stream, schema, result, parent); | ||
| 38 | } | ||
| 39 | }; | ||
| 40 | }; | ||
| 41 | |||
| 42 | exports.conditional = conditional; | ||
| 43 | |||
| 44 | var loop = function loop(schema, continueFunc) { | ||
| 45 | return function (stream, result, parent, parse) { | ||
| 46 | var arr = []; | ||
| 47 | var lastStreamPos = stream.pos; | ||
| 48 | |||
| 49 | while (continueFunc(stream, result, parent)) { | ||
| 50 | var newParent = {}; | ||
| 51 | parse(stream, schema, result, newParent); // cases when whole file is parsed but no termination is there and stream position is not getting updated as well | ||
| 52 | // it falls into infinite recursion, null check to avoid the same | ||
| 53 | |||
| 54 | if (stream.pos === lastStreamPos) { | ||
| 55 | break; | ||
| 56 | } | ||
| 57 | |||
| 58 | lastStreamPos = stream.pos; | ||
| 59 | arr.push(newParent); | ||
| 60 | } | ||
| 61 | |||
| 62 | return arr; | ||
| 63 | }; | ||
| 64 | }; | ||
| 65 | |||
| 66 | exports.loop = loop; | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | "use strict"; | ||
| 2 | |||
| 3 | Object.defineProperty(exports, "__esModule", { | ||
| 4 | value: true | ||
| 5 | }); | ||
| 6 | exports.readBits = exports.readArray = exports.readUnsigned = exports.readString = exports.peekBytes = exports.readBytes = exports.peekByte = exports.readByte = exports.buildStream = void 0; | ||
| 7 | |||
| 8 | // Default stream and parsers for Uint8TypedArray data type | ||
| 9 | var buildStream = function buildStream(uint8Data) { | ||
| 10 | return { | ||
| 11 | data: uint8Data, | ||
| 12 | pos: 0 | ||
| 13 | }; | ||
| 14 | }; | ||
| 15 | |||
| 16 | exports.buildStream = buildStream; | ||
| 17 | |||
| 18 | var readByte = function readByte() { | ||
| 19 | return function (stream) { | ||
| 20 | return stream.data[stream.pos++]; | ||
| 21 | }; | ||
| 22 | }; | ||
| 23 | |||
| 24 | exports.readByte = readByte; | ||
| 25 | |||
| 26 | var peekByte = function peekByte() { | ||
| 27 | var offset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; | ||
| 28 | return function (stream) { | ||
| 29 | return stream.data[stream.pos + offset]; | ||
| 30 | }; | ||
| 31 | }; | ||
| 32 | |||
| 33 | exports.peekByte = peekByte; | ||
| 34 | |||
| 35 | var readBytes = function readBytes(length) { | ||
| 36 | return function (stream) { | ||
| 37 | return stream.data.subarray(stream.pos, stream.pos += length); | ||
| 38 | }; | ||
| 39 | }; | ||
| 40 | |||
| 41 | exports.readBytes = readBytes; | ||
| 42 | |||
| 43 | var peekBytes = function peekBytes(length) { | ||
| 44 | return function (stream) { | ||
| 45 | return stream.data.subarray(stream.pos, stream.pos + length); | ||
| 46 | }; | ||
| 47 | }; | ||
| 48 | |||
| 49 | exports.peekBytes = peekBytes; | ||
| 50 | |||
| 51 | var readString = function readString(length) { | ||
| 52 | return function (stream) { | ||
| 53 | return Array.from(readBytes(length)(stream)).map(function (value) { | ||
| 54 | return String.fromCharCode(value); | ||
| 55 | }).join(''); | ||
| 56 | }; | ||
| 57 | }; | ||
| 58 | |||
| 59 | exports.readString = readString; | ||
| 60 | |||
| 61 | var readUnsigned = function readUnsigned(littleEndian) { | ||
| 62 | return function (stream) { | ||
| 63 | var bytes = readBytes(2)(stream); | ||
| 64 | return littleEndian ? (bytes[1] << 8) + bytes[0] : (bytes[0] << 8) + bytes[1]; | ||
| 65 | }; | ||
| 66 | }; | ||
| 67 | |||
| 68 | exports.readUnsigned = readUnsigned; | ||
| 69 | |||
| 70 | var readArray = function readArray(byteSize, totalOrFunc) { | ||
| 71 | return function (stream, result, parent) { | ||
| 72 | var total = typeof totalOrFunc === 'function' ? totalOrFunc(stream, result, parent) : totalOrFunc; | ||
| 73 | var parser = readBytes(byteSize); | ||
| 74 | var arr = new Array(total); | ||
| 75 | |||
| 76 | for (var i = 0; i < total; i++) { | ||
| 77 | arr[i] = parser(stream); | ||
| 78 | } | ||
| 79 | |||
| 80 | return arr; | ||
| 81 | }; | ||
| 82 | }; | ||
| 83 | |||
| 84 | exports.readArray = readArray; | ||
| 85 | |||
| 86 | var subBitsTotal = function subBitsTotal(bits, startIndex, length) { | ||
| 87 | var result = 0; | ||
| 88 | |||
| 89 | for (var i = 0; i < length; i++) { | ||
| 90 | result += bits[startIndex + i] && Math.pow(2, length - i - 1); | ||
| 91 | } | ||
| 92 | |||
| 93 | return result; | ||
| 94 | }; | ||
| 95 | |||
| 96 | var readBits = function readBits(schema) { | ||
| 97 | return function (stream) { | ||
| 98 | var _byte = readByte()(stream); // convert the byte to bit array | ||
| 99 | |||
| 100 | |||
| 101 | var bits = new Array(8); | ||
| 102 | |||
| 103 | for (var i = 0; i < 8; i++) { | ||
| 104 | bits[7 - i] = !!(_byte & 1 << i); | ||
| 105 | } // convert the bit array to values based on the schema | ||
| 106 | |||
| 107 | |||
| 108 | return Object.keys(schema).reduce(function (res, key) { | ||
| 109 | var def = schema[key]; | ||
| 110 | |||
| 111 | if (def.length) { | ||
| 112 | res[key] = subBitsTotal(bits, def.index, def.length); | ||
| 113 | } else { | ||
| 114 | res[key] = bits[def.index]; | ||
| 115 | } | ||
| 116 | |||
| 117 | return res; | ||
| 118 | }, {}); | ||
| 119 | }; | ||
| 120 | }; | ||
| 121 | |||
| 122 | exports.readBits = readBits; | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | "use strict"; | ||
| 2 | |||
| 3 | Object.defineProperty(exports, "__esModule", { | ||
| 4 | value: true | ||
| 5 | }); | ||
| 6 | exports["default"] = void 0; | ||
| 7 | |||
| 8 | var _ = require("../"); | ||
| 9 | |||
| 10 | var _uint = require("../parsers/uint8"); | ||
| 11 | |||
| 12 | // a set of 0x00 terminated subblocks | ||
| 13 | var subBlocksSchema = { | ||
| 14 | blocks: function blocks(stream) { | ||
| 15 | var terminator = 0x00; | ||
| 16 | var chunks = []; | ||
| 17 | var streamSize = stream.data.length; | ||
| 18 | var total = 0; | ||
| 19 | |||
| 20 | for (var size = (0, _uint.readByte)()(stream); size !== terminator; size = (0, _uint.readByte)()(stream)) { | ||
| 21 | // size becomes undefined for some case when file is corrupted and terminator is not proper | ||
| 22 | // null check to avoid recursion | ||
| 23 | if (!size) break; // catch corrupted files with no terminator | ||
| 24 | |||
| 25 | if (stream.pos + size >= streamSize) { | ||
| 26 | var availableSize = streamSize - stream.pos; | ||
| 27 | chunks.push((0, _uint.readBytes)(availableSize)(stream)); | ||
| 28 | total += availableSize; | ||
| 29 | break; | ||
| 30 | } | ||
| 31 | |||
| 32 | chunks.push((0, _uint.readBytes)(size)(stream)); | ||
| 33 | total += size; | ||
| 34 | } | ||
| 35 | |||
| 36 | var result = new Uint8Array(total); | ||
| 37 | var offset = 0; | ||
| 38 | |||
| 39 | for (var i = 0; i < chunks.length; i++) { | ||
| 40 | result.set(chunks[i], offset); | ||
| 41 | offset += chunks[i].length; | ||
| 42 | } | ||
| 43 | |||
| 44 | return result; | ||
| 45 | } | ||
| 46 | }; // global control extension | ||
| 47 | |||
| 48 | var gceSchema = (0, _.conditional)({ | ||
| 49 | gce: [{ | ||
| 50 | codes: (0, _uint.readBytes)(2) | ||
| 51 | }, { | ||
| 52 | byteSize: (0, _uint.readByte)() | ||
| 53 | }, { | ||
| 54 | extras: (0, _uint.readBits)({ | ||
| 55 | future: { | ||
| 56 | index: 0, | ||
| 57 | length: 3 | ||
| 58 | }, | ||
| 59 | disposal: { | ||
| 60 | index: 3, | ||
| 61 | length: 3 | ||
| 62 | }, | ||
| 63 | userInput: { | ||
| 64 | index: 6 | ||
| 65 | }, | ||
| 66 | transparentColorGiven: { | ||
| 67 | index: 7 | ||
| 68 | } | ||
| 69 | }) | ||
| 70 | }, { | ||
| 71 | delay: (0, _uint.readUnsigned)(true) | ||
| 72 | }, { | ||
| 73 | transparentColorIndex: (0, _uint.readByte)() | ||
| 74 | }, { | ||
| 75 | terminator: (0, _uint.readByte)() | ||
| 76 | }] | ||
| 77 | }, function (stream) { | ||
| 78 | var codes = (0, _uint.peekBytes)(2)(stream); | ||
| 79 | return codes[0] === 0x21 && codes[1] === 0xf9; | ||
| 80 | }); // image pipeline block | ||
| 81 | |||
| 82 | var imageSchema = (0, _.conditional)({ | ||
| 83 | image: [{ | ||
| 84 | code: (0, _uint.readByte)() | ||
| 85 | }, { | ||
| 86 | descriptor: [{ | ||
| 87 | left: (0, _uint.readUnsigned)(true) | ||
| 88 | }, { | ||
| 89 | top: (0, _uint.readUnsigned)(true) | ||
| 90 | }, { | ||
| 91 | width: (0, _uint.readUnsigned)(true) | ||
| 92 | }, { | ||
| 93 | height: (0, _uint.readUnsigned)(true) | ||
| 94 | }, { | ||
| 95 | lct: (0, _uint.readBits)({ | ||
| 96 | exists: { | ||
| 97 | index: 0 | ||
| 98 | }, | ||
| 99 | interlaced: { | ||
| 100 | index: 1 | ||
| 101 | }, | ||
| 102 | sort: { | ||
| 103 | index: 2 | ||
| 104 | }, | ||
| 105 | future: { | ||
| 106 | index: 3, | ||
| 107 | length: 2 | ||
| 108 | }, | ||
| 109 | size: { | ||
| 110 | index: 5, | ||
| 111 | length: 3 | ||
| 112 | } | ||
| 113 | }) | ||
| 114 | }] | ||
| 115 | }, (0, _.conditional)({ | ||
| 116 | lct: (0, _uint.readArray)(3, function (stream, result, parent) { | ||
| 117 | return Math.pow(2, parent.descriptor.lct.size + 1); | ||
| 118 | }) | ||
| 119 | }, function (stream, result, parent) { | ||
| 120 | return parent.descriptor.lct.exists; | ||
| 121 | }), { | ||
| 122 | data: [{ | ||
| 123 | minCodeSize: (0, _uint.readByte)() | ||
| 124 | }, subBlocksSchema] | ||
| 125 | }] | ||
| 126 | }, function (stream) { | ||
| 127 | return (0, _uint.peekByte)()(stream) === 0x2c; | ||
| 128 | }); // plain text block | ||
| 129 | |||
| 130 | var textSchema = (0, _.conditional)({ | ||
| 131 | text: [{ | ||
| 132 | codes: (0, _uint.readBytes)(2) | ||
| 133 | }, { | ||
| 134 | blockSize: (0, _uint.readByte)() | ||
| 135 | }, { | ||
| 136 | preData: function preData(stream, result, parent) { | ||
| 137 | return (0, _uint.readBytes)(parent.text.blockSize)(stream); | ||
| 138 | } | ||
| 139 | }, subBlocksSchema] | ||
| 140 | }, function (stream) { | ||
| 141 | var codes = (0, _uint.peekBytes)(2)(stream); | ||
| 142 | return codes[0] === 0x21 && codes[1] === 0x01; | ||
| 143 | }); // application block | ||
| 144 | |||
| 145 | var applicationSchema = (0, _.conditional)({ | ||
| 146 | application: [{ | ||
| 147 | codes: (0, _uint.readBytes)(2) | ||
| 148 | }, { | ||
| 149 | blockSize: (0, _uint.readByte)() | ||
| 150 | }, { | ||
| 151 | id: function id(stream, result, parent) { | ||
| 152 | return (0, _uint.readString)(parent.blockSize)(stream); | ||
| 153 | } | ||
| 154 | }, subBlocksSchema] | ||
| 155 | }, function (stream) { | ||
| 156 | var codes = (0, _uint.peekBytes)(2)(stream); | ||
| 157 | return codes[0] === 0x21 && codes[1] === 0xff; | ||
| 158 | }); // comment block | ||
| 159 | |||
| 160 | var commentSchema = (0, _.conditional)({ | ||
| 161 | comment: [{ | ||
| 162 | codes: (0, _uint.readBytes)(2) | ||
| 163 | }, subBlocksSchema] | ||
| 164 | }, function (stream) { | ||
| 165 | var codes = (0, _uint.peekBytes)(2)(stream); | ||
| 166 | return codes[0] === 0x21 && codes[1] === 0xfe; | ||
| 167 | }); | ||
| 168 | var schema = [{ | ||
| 169 | header: [{ | ||
| 170 | signature: (0, _uint.readString)(3) | ||
| 171 | }, { | ||
| 172 | version: (0, _uint.readString)(3) | ||
| 173 | }] | ||
| 174 | }, { | ||
| 175 | lsd: [{ | ||
| 176 | width: (0, _uint.readUnsigned)(true) | ||
| 177 | }, { | ||
| 178 | height: (0, _uint.readUnsigned)(true) | ||
| 179 | }, { | ||
| 180 | gct: (0, _uint.readBits)({ | ||
| 181 | exists: { | ||
| 182 | index: 0 | ||
| 183 | }, | ||
| 184 | resolution: { | ||
| 185 | index: 1, | ||
| 186 | length: 3 | ||
| 187 | }, | ||
| 188 | sort: { | ||
| 189 | index: 4 | ||
| 190 | }, | ||
| 191 | size: { | ||
| 192 | index: 5, | ||
| 193 | length: 3 | ||
| 194 | } | ||
| 195 | }) | ||
| 196 | }, { | ||
| 197 | backgroundColorIndex: (0, _uint.readByte)() | ||
| 198 | }, { | ||
| 199 | pixelAspectRatio: (0, _uint.readByte)() | ||
| 200 | }] | ||
| 201 | }, (0, _.conditional)({ | ||
| 202 | gct: (0, _uint.readArray)(3, function (stream, result) { | ||
| 203 | return Math.pow(2, result.lsd.gct.size + 1); | ||
| 204 | }) | ||
| 205 | }, function (stream, result) { | ||
| 206 | return result.lsd.gct.exists; | ||
| 207 | }), // content frames | ||
| 208 | { | ||
| 209 | frames: (0, _.loop)([gceSchema, applicationSchema, commentSchema, imageSchema, textSchema], function (stream) { | ||
| 210 | var nextCode = (0, _uint.peekByte)()(stream); // rather than check for a terminator, we should check for the existence | ||
| 211 | // of an ext or image block to avoid infinite loops | ||
| 212 | //var terminator = 0x3B; | ||
| 213 | //return nextCode !== terminator; | ||
| 214 | |||
| 215 | return nextCode === 0x21 || nextCode === 0x2c; | ||
| 216 | }) | ||
| 217 | }]; | ||
| 218 | var _default = schema; | ||
| 219 | exports["default"] = _default; | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | { | ||
| 2 | "_from": "js-binary-schema-parser@^2.0.2", | ||
| 3 | "_id": "js-binary-schema-parser@2.0.3", | ||
| 4 | "_inBundle": false, | ||
| 5 | "_integrity": "sha512-xezGJmOb4lk/M1ZZLTR/jaBHQ4gG/lqQnJqdIv4721DMggsa1bDVlHXNeHYogaIEHD9vCRv0fcL4hMA+Coarkg==", | ||
| 6 | "_location": "/js-binary-schema-parser", | ||
| 7 | "_phantomChildren": {}, | ||
| 8 | "_requested": { | ||
| 9 | "type": "range", | ||
| 10 | "registry": true, | ||
| 11 | "raw": "js-binary-schema-parser@^2.0.2", | ||
| 12 | "name": "js-binary-schema-parser", | ||
| 13 | "escapedName": "js-binary-schema-parser", | ||
| 14 | "rawSpec": "^2.0.2", | ||
| 15 | "saveSpec": null, | ||
| 16 | "fetchSpec": "^2.0.2" | ||
| 17 | }, | ||
| 18 | "_requiredBy": [ | ||
| 19 | "/vue-qr" | ||
| 20 | ], | ||
| 21 | "_resolved": "https://registry.npmmirror.com/js-binary-schema-parser/-/js-binary-schema-parser-2.0.3.tgz", | ||
| 22 | "_shasum": "3d7848748e8586e63b34e8911b643f59cfb6396e", | ||
| 23 | "_spec": "js-binary-schema-parser@^2.0.2", | ||
| 24 | "_where": "/Users/zhanghao/brcode/br-client/node_modules/vue-qr", | ||
| 25 | "author": { | ||
| 26 | "name": "Matt Way" | ||
| 27 | }, | ||
| 28 | "bugs": { | ||
| 29 | "url": "https://github.com/matt-way/jsBinarySchemaParser/issues" | ||
| 30 | }, | ||
| 31 | "bundleDependencies": false, | ||
| 32 | "dependencies": {}, | ||
| 33 | "deprecated": false, | ||
| 34 | "description": "Parse binary files with a schema into nicely readable objects", | ||
| 35 | "devDependencies": { | ||
| 36 | "@babel/cli": "^7.8.4", | ||
| 37 | "@babel/core": "^7.8.4", | ||
| 38 | "@babel/node": "^7.8.4", | ||
| 39 | "@babel/preset-env": "^7.8.4" | ||
| 40 | }, | ||
| 41 | "homepage": "https://github.com/matt-way/jsBinarySchemaParser", | ||
| 42 | "keywords": [ | ||
| 43 | "javascript", | ||
| 44 | "binary", | ||
| 45 | "file", | ||
| 46 | "parser", | ||
| 47 | "schema" | ||
| 48 | ], | ||
| 49 | "license": "MIT", | ||
| 50 | "main": "lib/index.js", | ||
| 51 | "name": "js-binary-schema-parser", | ||
| 52 | "repository": { | ||
| 53 | "type": "git", | ||
| 54 | "url": "git+https://github.com/matt-way/jsBinarySchemaParser.git" | ||
| 55 | }, | ||
| 56 | "scripts": { | ||
| 57 | "build": "babel src --out-dir lib", | ||
| 58 | "example": "babel-node ./example/index.js", | ||
| 59 | "example-debug": "babel-node --inspect-brk ./example/index.js" | ||
| 60 | }, | ||
| 61 | "version": "2.0.3" | ||
| 62 | } |
| 1 | export const parse = (stream, schema, result = {}, parent = result) => { | ||
| 2 | if (Array.isArray(schema)) { | ||
| 3 | schema.forEach(partSchema => parse(stream, partSchema, result, parent)) | ||
| 4 | } else if (typeof schema === 'function') { | ||
| 5 | schema(stream, result, parent, parse) | ||
| 6 | } else { | ||
| 7 | const key = Object.keys(schema)[0] | ||
| 8 | if (Array.isArray(schema[key])) { | ||
| 9 | parent[key] = {} | ||
| 10 | parse(stream, schema[key], result, parent[key]) | ||
| 11 | } else { | ||
| 12 | parent[key] = schema[key](stream, result, parent, parse) | ||
| 13 | } | ||
| 14 | } | ||
| 15 | return result | ||
| 16 | } | ||
| 17 | |||
| 18 | export const conditional = (schema, conditionFunc) => ( | ||
| 19 | stream, | ||
| 20 | result, | ||
| 21 | parent, | ||
| 22 | parse | ||
| 23 | ) => { | ||
| 24 | if (conditionFunc(stream, result, parent)) { | ||
| 25 | parse(stream, schema, result, parent) | ||
| 26 | } | ||
| 27 | } | ||
| 28 | |||
| 29 | export const loop = (schema, continueFunc) => ( | ||
| 30 | stream, | ||
| 31 | result, | ||
| 32 | parent, | ||
| 33 | parse | ||
| 34 | ) => { | ||
| 35 | const arr = [] | ||
| 36 | let lastStreamPos = stream.pos; | ||
| 37 | while (continueFunc(stream, result, parent)) { | ||
| 38 | const newParent = {} | ||
| 39 | parse(stream, schema, result, newParent) | ||
| 40 | // cases when whole file is parsed but no termination is there and stream position is not getting updated as well | ||
| 41 | // it falls into infinite recursion, null check to avoid the same | ||
| 42 | if(stream.pos === lastStreamPos) { | ||
| 43 | break | ||
| 44 | } | ||
| 45 | lastStreamPos = stream.pos | ||
| 46 | arr.push(newParent) | ||
| 47 | } | ||
| 48 | return arr | ||
| 49 | } |
| 1 | // Default stream and parsers for Uint8TypedArray data type | ||
| 2 | |||
| 3 | export const buildStream = uint8Data => ({ | ||
| 4 | data: uint8Data, | ||
| 5 | pos: 0 | ||
| 6 | }) | ||
| 7 | |||
| 8 | export const readByte = () => stream => { | ||
| 9 | return stream.data[stream.pos++] | ||
| 10 | } | ||
| 11 | |||
| 12 | export const peekByte = (offset = 0) => stream => { | ||
| 13 | return stream.data[stream.pos + offset] | ||
| 14 | } | ||
| 15 | |||
| 16 | export const readBytes = length => stream => { | ||
| 17 | return stream.data.subarray(stream.pos, (stream.pos += length)) | ||
| 18 | } | ||
| 19 | |||
| 20 | export const peekBytes = length => stream => { | ||
| 21 | return stream.data.subarray(stream.pos, stream.pos + length) | ||
| 22 | } | ||
| 23 | |||
| 24 | export const readString = length => stream => { | ||
| 25 | return Array.from(readBytes(length)(stream)) | ||
| 26 | .map(value => String.fromCharCode(value)) | ||
| 27 | .join('') | ||
| 28 | } | ||
| 29 | |||
| 30 | export const readUnsigned = littleEndian => stream => { | ||
| 31 | const bytes = readBytes(2)(stream) | ||
| 32 | return littleEndian ? (bytes[1] << 8) + bytes[0] : (bytes[0] << 8) + bytes[1] | ||
| 33 | } | ||
| 34 | |||
| 35 | export const readArray = (byteSize, totalOrFunc) => ( | ||
| 36 | stream, | ||
| 37 | result, | ||
| 38 | parent | ||
| 39 | ) => { | ||
| 40 | const total = | ||
| 41 | typeof totalOrFunc === 'function' | ||
| 42 | ? totalOrFunc(stream, result, parent) | ||
| 43 | : totalOrFunc | ||
| 44 | |||
| 45 | const parser = readBytes(byteSize) | ||
| 46 | const arr = new Array(total) | ||
| 47 | for (var i = 0; i < total; i++) { | ||
| 48 | arr[i] = parser(stream) | ||
| 49 | } | ||
| 50 | return arr | ||
| 51 | } | ||
| 52 | |||
| 53 | const subBitsTotal = (bits, startIndex, length) => { | ||
| 54 | var result = 0 | ||
| 55 | for (var i = 0; i < length; i++) { | ||
| 56 | result += bits[startIndex + i] && 2 ** (length - i - 1) | ||
| 57 | } | ||
| 58 | return result | ||
| 59 | } | ||
| 60 | |||
| 61 | export const readBits = schema => stream => { | ||
| 62 | const byte = readByte()(stream) | ||
| 63 | // convert the byte to bit array | ||
| 64 | const bits = new Array(8) | ||
| 65 | for (var i = 0; i < 8; i++) { | ||
| 66 | bits[7 - i] = !!(byte & (1 << i)) | ||
| 67 | } | ||
| 68 | // convert the bit array to values based on the schema | ||
| 69 | return Object.keys(schema).reduce((res, key) => { | ||
| 70 | const def = schema[key] | ||
| 71 | if (def.length) { | ||
| 72 | res[key] = subBitsTotal(bits, def.index, def.length) | ||
| 73 | } else { | ||
| 74 | res[key] = bits[def.index] | ||
| 75 | } | ||
| 76 | return res | ||
| 77 | }, {}) | ||
| 78 | } |
| 1 | import { conditional, loop } from '../' | ||
| 2 | import { | ||
| 3 | readByte, | ||
| 4 | peekByte, | ||
| 5 | readBytes, | ||
| 6 | peekBytes, | ||
| 7 | readString, | ||
| 8 | readUnsigned, | ||
| 9 | readArray, | ||
| 10 | readBits, | ||
| 11 | } from '../parsers/uint8' | ||
| 12 | |||
| 13 | // a set of 0x00 terminated subblocks | ||
| 14 | var subBlocksSchema = { | ||
| 15 | blocks: (stream) => { | ||
| 16 | const terminator = 0x00 | ||
| 17 | const chunks = [] | ||
| 18 | const streamSize = stream.data.length | ||
| 19 | var total = 0 | ||
| 20 | for ( | ||
| 21 | var size = readByte()(stream); | ||
| 22 | size !== terminator; | ||
| 23 | size = readByte()(stream) | ||
| 24 | ) { | ||
| 25 | // size becomes undefined for some case when file is corrupted and terminator is not proper | ||
| 26 | // null check to avoid recursion | ||
| 27 | if(!size) break; | ||
| 28 | // catch corrupted files with no terminator | ||
| 29 | if (stream.pos + size >= streamSize) { | ||
| 30 | const availableSize = streamSize - stream.pos | ||
| 31 | chunks.push(readBytes(availableSize)(stream)) | ||
| 32 | total += availableSize | ||
| 33 | break | ||
| 34 | } | ||
| 35 | chunks.push(readBytes(size)(stream)) | ||
| 36 | total += size | ||
| 37 | } | ||
| 38 | const result = new Uint8Array(total) | ||
| 39 | var offset = 0 | ||
| 40 | for (var i = 0; i < chunks.length; i++) { | ||
| 41 | result.set(chunks[i], offset) | ||
| 42 | offset += chunks[i].length | ||
| 43 | } | ||
| 44 | return result | ||
| 45 | }, | ||
| 46 | } | ||
| 47 | |||
| 48 | // global control extension | ||
| 49 | const gceSchema = conditional( | ||
| 50 | { | ||
| 51 | gce: [ | ||
| 52 | { codes: readBytes(2) }, | ||
| 53 | { byteSize: readByte() }, | ||
| 54 | { | ||
| 55 | extras: readBits({ | ||
| 56 | future: { index: 0, length: 3 }, | ||
| 57 | disposal: { index: 3, length: 3 }, | ||
| 58 | userInput: { index: 6 }, | ||
| 59 | transparentColorGiven: { index: 7 }, | ||
| 60 | }), | ||
| 61 | }, | ||
| 62 | { delay: readUnsigned(true) }, | ||
| 63 | { transparentColorIndex: readByte() }, | ||
| 64 | { terminator: readByte() }, | ||
| 65 | ], | ||
| 66 | }, | ||
| 67 | (stream) => { | ||
| 68 | var codes = peekBytes(2)(stream) | ||
| 69 | return codes[0] === 0x21 && codes[1] === 0xf9 | ||
| 70 | } | ||
| 71 | ) | ||
| 72 | |||
| 73 | // image pipeline block | ||
| 74 | const imageSchema = conditional( | ||
| 75 | { | ||
| 76 | image: [ | ||
| 77 | { code: readByte() }, | ||
| 78 | { | ||
| 79 | descriptor: [ | ||
| 80 | { left: readUnsigned(true) }, | ||
| 81 | { top: readUnsigned(true) }, | ||
| 82 | { width: readUnsigned(true) }, | ||
| 83 | { height: readUnsigned(true) }, | ||
| 84 | { | ||
| 85 | lct: readBits({ | ||
| 86 | exists: { index: 0 }, | ||
| 87 | interlaced: { index: 1 }, | ||
| 88 | sort: { index: 2 }, | ||
| 89 | future: { index: 3, length: 2 }, | ||
| 90 | size: { index: 5, length: 3 }, | ||
| 91 | }), | ||
| 92 | }, | ||
| 93 | ], | ||
| 94 | }, | ||
| 95 | conditional( | ||
| 96 | { | ||
| 97 | lct: readArray(3, (stream, result, parent) => { | ||
| 98 | return Math.pow(2, parent.descriptor.lct.size + 1) | ||
| 99 | }), | ||
| 100 | }, | ||
| 101 | (stream, result, parent) => { | ||
| 102 | return parent.descriptor.lct.exists | ||
| 103 | } | ||
| 104 | ), | ||
| 105 | { data: [{ minCodeSize: readByte() }, subBlocksSchema] }, | ||
| 106 | ], | ||
| 107 | }, | ||
| 108 | (stream) => { | ||
| 109 | return peekByte()(stream) === 0x2c | ||
| 110 | } | ||
| 111 | ) | ||
| 112 | |||
| 113 | // plain text block | ||
| 114 | const textSchema = conditional( | ||
| 115 | { | ||
| 116 | text: [ | ||
| 117 | { codes: readBytes(2) }, | ||
| 118 | { blockSize: readByte() }, | ||
| 119 | { | ||
| 120 | preData: (stream, result, parent) => | ||
| 121 | readBytes(parent.text.blockSize)(stream), | ||
| 122 | }, | ||
| 123 | subBlocksSchema, | ||
| 124 | ], | ||
| 125 | }, | ||
| 126 | (stream) => { | ||
| 127 | var codes = peekBytes(2)(stream) | ||
| 128 | return codes[0] === 0x21 && codes[1] === 0x01 | ||
| 129 | } | ||
| 130 | ) | ||
| 131 | |||
| 132 | // application block | ||
| 133 | const applicationSchema = conditional( | ||
| 134 | { | ||
| 135 | application: [ | ||
| 136 | { codes: readBytes(2) }, | ||
| 137 | { blockSize: readByte() }, | ||
| 138 | { id: (stream, result, parent) => readString(parent.blockSize)(stream) }, | ||
| 139 | subBlocksSchema, | ||
| 140 | ], | ||
| 141 | }, | ||
| 142 | (stream) => { | ||
| 143 | var codes = peekBytes(2)(stream) | ||
| 144 | return codes[0] === 0x21 && codes[1] === 0xff | ||
| 145 | } | ||
| 146 | ) | ||
| 147 | |||
| 148 | // comment block | ||
| 149 | const commentSchema = conditional( | ||
| 150 | { | ||
| 151 | comment: [{ codes: readBytes(2) }, subBlocksSchema], | ||
| 152 | }, | ||
| 153 | (stream) => { | ||
| 154 | var codes = peekBytes(2)(stream) | ||
| 155 | return codes[0] === 0x21 && codes[1] === 0xfe | ||
| 156 | } | ||
| 157 | ) | ||
| 158 | |||
| 159 | const schema = [ | ||
| 160 | { header: [{ signature: readString(3) }, { version: readString(3) }] }, | ||
| 161 | { | ||
| 162 | lsd: [ | ||
| 163 | { width: readUnsigned(true) }, | ||
| 164 | { height: readUnsigned(true) }, | ||
| 165 | { | ||
| 166 | gct: readBits({ | ||
| 167 | exists: { index: 0 }, | ||
| 168 | resolution: { index: 1, length: 3 }, | ||
| 169 | sort: { index: 4 }, | ||
| 170 | size: { index: 5, length: 3 }, | ||
| 171 | }), | ||
| 172 | }, | ||
| 173 | { backgroundColorIndex: readByte() }, | ||
| 174 | { pixelAspectRatio: readByte() }, | ||
| 175 | ], | ||
| 176 | }, | ||
| 177 | conditional( | ||
| 178 | { | ||
| 179 | gct: readArray(3, (stream, result) => | ||
| 180 | Math.pow(2, result.lsd.gct.size + 1) | ||
| 181 | ), | ||
| 182 | }, | ||
| 183 | (stream, result) => result.lsd.gct.exists | ||
| 184 | ), | ||
| 185 | // content frames | ||
| 186 | { | ||
| 187 | frames: loop( | ||
| 188 | [gceSchema, applicationSchema, commentSchema, imageSchema, textSchema], | ||
| 189 | (stream) => { | ||
| 190 | var nextCode = peekByte()(stream) | ||
| 191 | // rather than check for a terminator, we should check for the existence | ||
| 192 | // of an ext or image block to avoid infinite loops | ||
| 193 | //var terminator = 0x3B; | ||
| 194 | //return nextCode !== terminator; | ||
| 195 | return nextCode === 0x21 || nextCode === 0x2c | ||
| 196 | } | ||
| 197 | ), | ||
| 198 | }, | ||
| 199 | ] | ||
| 200 | |||
| 201 | export default schema |
node_modules/mimic-response/index.d.ts
0 → 100644
| 1 | import {IncomingMessage} from 'http'; | ||
| 2 | |||
| 3 | /** | ||
| 4 | Mimic a [Node.js HTTP response stream](https://nodejs.org/api/http.html#http_class_http_incomingmessage) | ||
| 5 | |||
| 6 | Makes `toStream` include the properties from `fromStream`. | ||
| 7 | |||
| 8 | @param fromStream - The stream to copy the properties from. | ||
| 9 | @param toStream - The stream to copy the properties to. | ||
| 10 | @return The same object as `toStream`. | ||
| 11 | */ | ||
| 12 | declare function mimicResponse<T extends NodeJS.ReadableStream>( | ||
| 13 | fromStream: IncomingMessage, // eslint-disable-line @typescript-eslint/prefer-readonly-parameter-types | ||
| 14 | toStream: T, | ||
| 15 | ): T & IncomingMessage; | ||
| 16 | |||
| 17 | export = mimicResponse; |
node_modules/mimic-response/index.js
0 → 100644
| 1 | 'use strict'; | ||
| 2 | |||
| 3 | // We define these manually to ensure they're always copied | ||
| 4 | // even if they would move up the prototype chain | ||
| 5 | // https://nodejs.org/api/http.html#http_class_http_incomingmessage | ||
| 6 | const knownProperties = [ | ||
| 7 | 'aborted', | ||
| 8 | 'complete', | ||
| 9 | 'headers', | ||
| 10 | 'httpVersion', | ||
| 11 | 'httpVersionMinor', | ||
| 12 | 'httpVersionMajor', | ||
| 13 | 'method', | ||
| 14 | 'rawHeaders', | ||
| 15 | 'rawTrailers', | ||
| 16 | 'setTimeout', | ||
| 17 | 'socket', | ||
| 18 | 'statusCode', | ||
| 19 | 'statusMessage', | ||
| 20 | 'trailers', | ||
| 21 | 'url' | ||
| 22 | ]; | ||
| 23 | |||
| 24 | module.exports = (fromStream, toStream) => { | ||
| 25 | if (toStream._readableState.autoDestroy) { | ||
| 26 | throw new Error('The second stream must have the `autoDestroy` option set to `false`'); | ||
| 27 | } | ||
| 28 | |||
| 29 | const fromProperties = new Set(Object.keys(fromStream).concat(knownProperties)); | ||
| 30 | |||
| 31 | const properties = {}; | ||
| 32 | |||
| 33 | for (const property of fromProperties) { | ||
| 34 | // Don't overwrite existing properties. | ||
| 35 | if (property in toStream) { | ||
| 36 | continue; | ||
| 37 | } | ||
| 38 | |||
| 39 | properties[property] = { | ||
| 40 | get() { | ||
| 41 | const value = fromStream[property]; | ||
| 42 | const isFunction = typeof value === 'function'; | ||
| 43 | |||
| 44 | return isFunction ? value.bind(fromStream) : value; | ||
| 45 | }, | ||
| 46 | set(value) { | ||
| 47 | fromStream[property] = value; | ||
| 48 | }, | ||
| 49 | enumerable: true, | ||
| 50 | configurable: false | ||
| 51 | }; | ||
| 52 | } | ||
| 53 | |||
| 54 | Object.defineProperties(toStream, properties); | ||
| 55 | |||
| 56 | fromStream.once('aborted', () => { | ||
| 57 | toStream.destroy(); | ||
| 58 | |||
| 59 | toStream.emit('aborted'); | ||
| 60 | }); | ||
| 61 | |||
| 62 | fromStream.once('close', () => { | ||
| 63 | if (fromStream.complete) { | ||
| 64 | if (toStream.readable) { | ||
| 65 | toStream.once('end', () => { | ||
| 66 | toStream.emit('close'); | ||
| 67 | }); | ||
| 68 | } else { | ||
| 69 | toStream.emit('close'); | ||
| 70 | } | ||
| 71 | } else { | ||
| 72 | toStream.emit('close'); | ||
| 73 | } | ||
| 74 | }); | ||
| 75 | |||
| 76 | return toStream; | ||
| 77 | }; |
node_modules/mimic-response/license
0 → 100644
| 1 | MIT License | ||
| 2 | |||
| 3 | Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com) | ||
| 4 | |||
| 5 | 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: | ||
| 6 | |||
| 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
| 8 | |||
| 9 | 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. |
node_modules/mimic-response/package.json
0 → 100644
| 1 | { | ||
| 2 | "_from": "mimic-response@^3.1.0", | ||
| 3 | "_id": "mimic-response@3.1.0", | ||
| 4 | "_inBundle": false, | ||
| 5 | "_integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==", | ||
| 6 | "_location": "/mimic-response", | ||
| 7 | "_phantomChildren": {}, | ||
| 8 | "_requested": { | ||
| 9 | "type": "range", | ||
| 10 | "registry": true, | ||
| 11 | "raw": "mimic-response@^3.1.0", | ||
| 12 | "name": "mimic-response", | ||
| 13 | "escapedName": "mimic-response", | ||
| 14 | "rawSpec": "^3.1.0", | ||
| 15 | "saveSpec": null, | ||
| 16 | "fetchSpec": "^3.1.0" | ||
| 17 | }, | ||
| 18 | "_requiredBy": [ | ||
| 19 | "/decompress-response" | ||
| 20 | ], | ||
| 21 | "_resolved": "https://registry.npmmirror.com/mimic-response/-/mimic-response-3.1.0.tgz", | ||
| 22 | "_shasum": "2d1d59af9c1b129815accc2c46a022a5ce1fa3c9", | ||
| 23 | "_spec": "mimic-response@^3.1.0", | ||
| 24 | "_where": "/Users/zhanghao/brcode/br-client/node_modules/decompress-response", | ||
| 25 | "author": { | ||
| 26 | "name": "Sindre Sorhus", | ||
| 27 | "email": "sindresorhus@gmail.com", | ||
| 28 | "url": "https://sindresorhus.com" | ||
| 29 | }, | ||
| 30 | "bugs": { | ||
| 31 | "url": "https://github.com/sindresorhus/mimic-response/issues" | ||
| 32 | }, | ||
| 33 | "bundleDependencies": false, | ||
| 34 | "deprecated": false, | ||
| 35 | "description": "Mimic a Node.js HTTP response stream", | ||
| 36 | "devDependencies": { | ||
| 37 | "@types/node": "^14.0.1", | ||
| 38 | "ava": "^2.4.0", | ||
| 39 | "create-test-server": "^2.4.0", | ||
| 40 | "p-event": "^4.1.0", | ||
| 41 | "pify": "^5.0.0", | ||
| 42 | "tsd": "^0.11.0", | ||
| 43 | "xo": "^0.30.0" | ||
| 44 | }, | ||
| 45 | "engines": { | ||
| 46 | "node": ">=10" | ||
| 47 | }, | ||
| 48 | "files": [ | ||
| 49 | "index.d.ts", | ||
| 50 | "index.js" | ||
| 51 | ], | ||
| 52 | "funding": "https://github.com/sponsors/sindresorhus", | ||
| 53 | "homepage": "https://github.com/sindresorhus/mimic-response#readme", | ||
| 54 | "keywords": [ | ||
| 55 | "mimic", | ||
| 56 | "response", | ||
| 57 | "stream", | ||
| 58 | "http", | ||
| 59 | "https", | ||
| 60 | "request", | ||
| 61 | "get", | ||
| 62 | "core" | ||
| 63 | ], | ||
| 64 | "license": "MIT", | ||
| 65 | "name": "mimic-response", | ||
| 66 | "repository": { | ||
| 67 | "type": "git", | ||
| 68 | "url": "git+https://github.com/sindresorhus/mimic-response.git" | ||
| 69 | }, | ||
| 70 | "scripts": { | ||
| 71 | "test": "xo && ava && tsd" | ||
| 72 | }, | ||
| 73 | "version": "3.1.0" | ||
| 74 | } |
node_modules/mimic-response/readme.md
0 → 100644
| 1 | # mimic-response [](https://travis-ci.com/sindresorhus/mimic-response) | ||
| 2 | |||
| 3 | > Mimic a [Node.js HTTP response stream](https://nodejs.org/api/http.html#http_class_http_incomingmessage) | ||
| 4 | |||
| 5 | ## Install | ||
| 6 | |||
| 7 | ``` | ||
| 8 | $ npm install mimic-response | ||
| 9 | ``` | ||
| 10 | |||
| 11 | ## Usage | ||
| 12 | |||
| 13 | ```js | ||
| 14 | const stream = require('stream'); | ||
| 15 | const mimicResponse = require('mimic-response'); | ||
| 16 | |||
| 17 | const responseStream = getHttpResponseStream(); | ||
| 18 | const myStream = new stream.PassThrough(); | ||
| 19 | |||
| 20 | mimicResponse(responseStream, myStream); | ||
| 21 | |||
| 22 | console.log(myStream.statusCode); | ||
| 23 | //=> 200 | ||
| 24 | ``` | ||
| 25 | |||
| 26 | ## API | ||
| 27 | |||
| 28 | ### mimicResponse(from, to) | ||
| 29 | |||
| 30 | **Note #1:** The `from.destroy(error)` function is not proxied. You have to call it manually: | ||
| 31 | |||
| 32 | ```js | ||
| 33 | const stream = require('stream'); | ||
| 34 | const mimicResponse = require('mimic-response'); | ||
| 35 | |||
| 36 | const responseStream = getHttpResponseStream(); | ||
| 37 | |||
| 38 | const myStream = new stream.PassThrough({ | ||
| 39 | destroy(error, callback) { | ||
| 40 | responseStream.destroy(); | ||
| 41 | |||
| 42 | callback(error); | ||
| 43 | } | ||
| 44 | }); | ||
| 45 | |||
| 46 | myStream.destroy(); | ||
| 47 | ``` | ||
| 48 | |||
| 49 | Please note that `myStream` and `responseStream` never throws. The error is passed to the request instead. | ||
| 50 | |||
| 51 | #### from | ||
| 52 | |||
| 53 | Type: `Stream` | ||
| 54 | |||
| 55 | [Node.js HTTP response stream.](https://nodejs.org/api/http.html#http_class_http_incomingmessage) | ||
| 56 | |||
| 57 | #### to | ||
| 58 | |||
| 59 | Type: `Stream` | ||
| 60 | |||
| 61 | Any stream. | ||
| 62 | |||
| 63 | ## Related | ||
| 64 | |||
| 65 | - [mimic-fn](https://github.com/sindresorhus/mimic-fn) - Make a function mimic another one | ||
| 66 | - [clone-response](https://github.com/lukechilds/clone-response) - Clone a Node.js response stream | ||
| 67 | |||
| 68 | --- | ||
| 69 | |||
| 70 | <div align="center"> | ||
| 71 | <b> | ||
| 72 | <a href="https://tidelift.com/subscription/pkg/npm-mimic-response?utm_source=npm-mimic-response&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a> | ||
| 73 | </b> | ||
| 74 | <br> | ||
| 75 | <sub> | ||
| 76 | Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies. | ||
| 77 | </sub> | ||
| 78 | </div> |
node_modules/parenthesis/LICENSE
0 → 100644
| 1 | The MIT License (MIT) | ||
| 2 | Copyright © 2016 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. | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
node_modules/parenthesis/README.md
0 → 100644
| 1 | # parenthesis [](https://travis-ci.org/dy/parenthesis) | ||
| 2 | |||
| 3 | Parse parentheses from a string, return folded arrays. | ||
| 4 | |||
| 5 | [](https://npmjs.org/package/parenthesis/) | ||
| 6 | |||
| 7 | |||
| 8 | ```js | ||
| 9 | var parse = require('parenthesis') | ||
| 10 | |||
| 11 | // Parse into nested format | ||
| 12 | parse('a(b[c{d}])') | ||
| 13 | // ['a(', ['b[', ['c{', ['d'], '}'], ']'], ')'] | ||
| 14 | |||
| 15 | // Parse into flat format with cross-references | ||
| 16 | parse('a(b[c{d}])', { | ||
| 17 | brackets: ['()'], | ||
| 18 | escape: '\\', | ||
| 19 | flat: true | ||
| 20 | }) | ||
| 21 | // ['a(\\1)', 'b[c{d}]'] | ||
| 22 | |||
| 23 | |||
| 24 | // Stringify nested format | ||
| 25 | parse.stringify(['a(', ['b[', ['c{', ['d'], '}'], ']'], ')']) | ||
| 26 | // 'a(b[c{d}])' | ||
| 27 | |||
| 28 | // Stringify flat format with cross-references | ||
| 29 | parse.stringify(['a(\\1)', 'b[c{d}]'], {flat: true, escape: '\\'}) | ||
| 30 | // 'a(b[c{d}])' | ||
| 31 | ``` | ||
| 32 | |||
| 33 | ## API | ||
| 34 | |||
| 35 | ### tokens = paren.parse(string, brackets|opts?) | ||
| 36 | |||
| 37 | Return array with tokens. | ||
| 38 | |||
| 39 | Option | Default | Meaning | ||
| 40 | ---|---|--- | ||
| 41 | `brackets` | `['{}', '[]', '()']` | Single brackets string or list of strings to detect brackets. Can be repeating brackets eg. `"" or ''`. | ||
| 42 | `escape` | `'___'` | Escape prefix for flat references. | ||
| 43 | `flat` | `false` | Return flat array instead of nested arrays. | ||
| 44 | |||
| 45 | ### str = paren.stringify(tokens, {flat}?) | ||
| 46 | |||
| 47 | Stringify tokens back. Pass `{flat: true}` flag for flat tokens array. | ||
| 48 | |||
| 49 | ## Related | ||
| 50 | |||
| 51 | * [balanced-match](http://npmjs.org/package/balanced-match) | ||
| 52 | |||
| 53 | |||
| 54 | ## License | ||
| 55 | |||
| 56 | © 2018 Dmitry Yv. MIT License |
node_modules/parenthesis/index.d.ts
0 → 100644
| 1 | declare module "parenthesis" { | ||
| 2 | namespace parens { | ||
| 3 | // One entry in the returned nested array | ||
| 4 | type Node = string | ArrayTree; | ||
| 5 | // A nested array of strings | ||
| 6 | interface ArrayTree extends Array<Node> {} | ||
| 7 | // Second-argument options used by the function | ||
| 8 | interface Opts { | ||
| 9 | // Single brackets string or list of strings to detect brackets. Can be repeating brackets eg. "" or ''. | ||
| 10 | brackets?: string | string[], | ||
| 11 | // Escape prefix for flat references. | ||
| 12 | escape?: string, | ||
| 13 | // `flat` is a boolean but since it affects return type, it's explicitly specified below | ||
| 14 | } | ||
| 15 | |||
| 16 | // Parse parentheses from a string, return folded arrays | ||
| 17 | function parse( | ||
| 18 | str: string, | ||
| 19 | opts?: string | string[] | (parens.Opts & { flat?: false }) | ||
| 20 | ): parens.ArrayTree; | ||
| 21 | // Parse parentheses from a string, return flat array | ||
| 22 | function parse( | ||
| 23 | str: string, | ||
| 24 | opts: (parens.Opts & { flat: true }) | ||
| 25 | ): string[]; | ||
| 26 | |||
| 27 | // Stringify tokens back. Pass {flat: true} flag for flat tokens array. | ||
| 28 | function stringify(tokens: ArrayTree, opts?: {flat: boolean}): string; | ||
| 29 | } | ||
| 30 | |||
| 31 | // Parse parentheses from a string, return folded arrays | ||
| 32 | function parens( | ||
| 33 | str: string, | ||
| 34 | opts?: string | string[] | (parens.Opts & { flat?: false }) | ||
| 35 | ): parens.ArrayTree; | ||
| 36 | // Parse parentheses from a string, return flat array | ||
| 37 | function parens( | ||
| 38 | str: string, | ||
| 39 | opts: (parens.Opts & { flat: true }) | ||
| 40 | ): string[]; | ||
| 41 | function parens(tokens: parens.ArrayTree, opts?: {flat: boolean}): string; | ||
| 42 | |||
| 43 | // imports via `import paren from "parenthesis", can call the export | ||
| 44 | // directly or use `paren.parse` / `paren.stringify`. | ||
| 45 | export = parens; | ||
| 46 | } |
node_modules/parenthesis/index.js
0 → 100644
| 1 | 'use strict' | ||
| 2 | |||
| 3 | /** | ||
| 4 | * @module parenthesis | ||
| 5 | */ | ||
| 6 | |||
| 7 | function parse (str, opts) { | ||
| 8 | // pretend non-string parsed per-se | ||
| 9 | if (typeof str !== 'string') return [str] | ||
| 10 | |||
| 11 | var res = [str] | ||
| 12 | |||
| 13 | if (typeof opts === 'string' || Array.isArray(opts)) { | ||
| 14 | opts = {brackets: opts} | ||
| 15 | } | ||
| 16 | else if (!opts) opts = {} | ||
| 17 | |||
| 18 | var brackets = opts.brackets ? (Array.isArray(opts.brackets) ? opts.brackets : [opts.brackets]) : ['{}', '[]', '()'] | ||
| 19 | |||
| 20 | var escape = opts.escape || '___' | ||
| 21 | |||
| 22 | var flat = !!opts.flat | ||
| 23 | |||
| 24 | brackets.forEach(function (bracket) { | ||
| 25 | // create parenthesis regex | ||
| 26 | var pRE = new RegExp(['\\', bracket[0], '[^\\', bracket[0], '\\', bracket[1], ']*\\', bracket[1]].join('')) | ||
| 27 | |||
| 28 | var ids = [] | ||
| 29 | |||
| 30 | function replaceToken(token, idx, str){ | ||
| 31 | // save token to res | ||
| 32 | var refId = res.push(token.slice(bracket[0].length, -bracket[1].length)) - 1 | ||
| 33 | |||
| 34 | ids.push(refId) | ||
| 35 | |||
| 36 | return escape + refId + escape | ||
| 37 | } | ||
| 38 | |||
| 39 | res.forEach(function (str, i) { | ||
| 40 | var prevStr | ||
| 41 | |||
| 42 | // replace paren tokens till there’s none | ||
| 43 | var a = 0 | ||
| 44 | while (str != prevStr) { | ||
| 45 | prevStr = str | ||
| 46 | str = str.replace(pRE, replaceToken) | ||
| 47 | if (a++ > 10e3) throw Error('References have circular dependency. Please, check them.') | ||
| 48 | } | ||
| 49 | |||
| 50 | res[i] = str | ||
| 51 | }) | ||
| 52 | |||
| 53 | // wrap found refs to brackets | ||
| 54 | ids = ids.reverse() | ||
| 55 | res = res.map(function (str) { | ||
| 56 | ids.forEach(function (id) { | ||
| 57 | str = str.replace(new RegExp('(\\' + escape + id + '\\' + escape + ')', 'g'), bracket[0] + '$1' + bracket[1]) | ||
| 58 | }) | ||
| 59 | return str | ||
| 60 | }) | ||
| 61 | }) | ||
| 62 | |||
| 63 | var re = new RegExp('\\' + escape + '([0-9]+)' + '\\' + escape) | ||
| 64 | |||
| 65 | // transform references to tree | ||
| 66 | function nest (str, refs, escape) { | ||
| 67 | var res = [], match | ||
| 68 | |||
| 69 | var a = 0 | ||
| 70 | while (match = re.exec(str)) { | ||
| 71 | if (a++ > 10e3) throw Error('Circular references in parenthesis') | ||
| 72 | |||
| 73 | res.push(str.slice(0, match.index)) | ||
| 74 | |||
| 75 | res.push(nest(refs[match[1]], refs)) | ||
| 76 | |||
| 77 | str = str.slice(match.index + match[0].length) | ||
| 78 | } | ||
| 79 | |||
| 80 | res.push(str) | ||
| 81 | |||
| 82 | return res | ||
| 83 | } | ||
| 84 | |||
| 85 | return flat ? res : nest(res[0], res) | ||
| 86 | } | ||
| 87 | |||
| 88 | function stringify (arg, opts) { | ||
| 89 | if (opts && opts.flat) { | ||
| 90 | var escape = opts && opts.escape || '___' | ||
| 91 | |||
| 92 | var str = arg[0], prevStr | ||
| 93 | |||
| 94 | // pretend bad string stringified with no parentheses | ||
| 95 | if (!str) return '' | ||
| 96 | |||
| 97 | |||
| 98 | var re = new RegExp('\\' + escape + '([0-9]+)' + '\\' + escape) | ||
| 99 | |||
| 100 | var a = 0 | ||
| 101 | while (str != prevStr) { | ||
| 102 | if (a++ > 10e3) throw Error('Circular references in ' + arg) | ||
| 103 | prevStr = str | ||
| 104 | str = str.replace(re, replaceRef) | ||
| 105 | } | ||
| 106 | |||
| 107 | return str | ||
| 108 | } | ||
| 109 | |||
| 110 | return arg.reduce(function f (prev, curr) { | ||
| 111 | if (Array.isArray(curr)) { | ||
| 112 | curr = curr.reduce(f, '') | ||
| 113 | } | ||
| 114 | return prev + curr | ||
| 115 | }, '') | ||
| 116 | |||
| 117 | function replaceRef(match, idx){ | ||
| 118 | if (arg[idx] == null) throw Error('Reference ' + idx + 'is undefined') | ||
| 119 | return arg[idx] | ||
| 120 | } | ||
| 121 | } | ||
| 122 | |||
| 123 | function parenthesis (arg, opts) { | ||
| 124 | if (Array.isArray(arg)) { | ||
| 125 | return stringify(arg, opts) | ||
| 126 | } | ||
| 127 | else { | ||
| 128 | return parse(arg, opts) | ||
| 129 | } | ||
| 130 | } | ||
| 131 | |||
| 132 | parenthesis.parse = parse | ||
| 133 | parenthesis.stringify = stringify | ||
| 134 | |||
| 135 | module.exports = parenthesis |
node_modules/parenthesis/package.json
0 → 100644
| 1 | { | ||
| 2 | "_from": "parenthesis@^3.1.5", | ||
| 3 | "_id": "parenthesis@3.1.8", | ||
| 4 | "_inBundle": false, | ||
| 5 | "_integrity": "sha512-KF/U8tk54BgQewkJPvB4s/US3VQY68BRDpH638+7O/n58TpnwiwnOtGIOsT2/i+M78s61BBpeC83STB88d8sqw==", | ||
| 6 | "_location": "/parenthesis", | ||
| 7 | "_phantomChildren": {}, | ||
| 8 | "_requested": { | ||
| 9 | "type": "range", | ||
| 10 | "registry": true, | ||
| 11 | "raw": "parenthesis@^3.1.5", | ||
| 12 | "name": "parenthesis", | ||
| 13 | "escapedName": "parenthesis", | ||
| 14 | "rawSpec": "^3.1.5", | ||
| 15 | "saveSpec": null, | ||
| 16 | "fetchSpec": "^3.1.5" | ||
| 17 | }, | ||
| 18 | "_requiredBy": [ | ||
| 19 | "/string-split-by" | ||
| 20 | ], | ||
| 21 | "_resolved": "https://registry.npmmirror.com/parenthesis/-/parenthesis-3.1.8.tgz", | ||
| 22 | "_shasum": "3457fccb8f05db27572b841dad9d2630b912f125", | ||
| 23 | "_spec": "parenthesis@^3.1.5", | ||
| 24 | "_where": "/Users/zhanghao/brcode/br-client/node_modules/string-split-by", | ||
| 25 | "author": { | ||
| 26 | "name": "Dmitry Yv", | ||
| 27 | "email": "df.creative@gmail.com", | ||
| 28 | "url": "http://github.com/dy" | ||
| 29 | }, | ||
| 30 | "bugs": { | ||
| 31 | "url": "https://github.com/dy/parenthesis/issues" | ||
| 32 | }, | ||
| 33 | "bundleDependencies": false, | ||
| 34 | "dependencies": {}, | ||
| 35 | "deprecated": false, | ||
| 36 | "description": "Parse parentheses from a string", | ||
| 37 | "devDependencies": { | ||
| 38 | "tape": "^4.9.0" | ||
| 39 | }, | ||
| 40 | "files": [ | ||
| 41 | "index.js", | ||
| 42 | "index.d.ts" | ||
| 43 | ], | ||
| 44 | "homepage": "https://github.com/dy/parenthesis", | ||
| 45 | "keywords": [ | ||
| 46 | "paren", | ||
| 47 | "parenthesis", | ||
| 48 | "parse", | ||
| 49 | "brackets", | ||
| 50 | "parser", | ||
| 51 | "regexp", | ||
| 52 | "stringify", | ||
| 53 | "tokenizer", | ||
| 54 | "replace", | ||
| 55 | "csv", | ||
| 56 | "string" | ||
| 57 | ], | ||
| 58 | "license": "MIT", | ||
| 59 | "main": "index.js", | ||
| 60 | "name": "parenthesis", | ||
| 61 | "repository": { | ||
| 62 | "type": "git", | ||
| 63 | "url": "git://github.com/dy/parenthesis.git" | ||
| 64 | }, | ||
| 65 | "scripts": { | ||
| 66 | "test": "node test.js", | ||
| 67 | "test:browser": "budo test.js" | ||
| 68 | }, | ||
| 69 | "types": "index.d.ts", | ||
| 70 | "version": "3.1.8" | ||
| 71 | } |
node_modules/simple-concat/.travis.yml
0 → 100644
node_modules/simple-concat/LICENSE
0 → 100644
| 1 | The MIT License (MIT) | ||
| 2 | |||
| 3 | Copyright (c) Feross Aboukhadijeh | ||
| 4 | |||
| 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
| 6 | this software and associated documentation files (the "Software"), to deal in | ||
| 7 | the Software without restriction, including without limitation the rights to | ||
| 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
| 9 | the Software, and to permit persons to whom the Software is furnished to do so, | ||
| 10 | 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, FITNESS | ||
| 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
| 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
| 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
| 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
node_modules/simple-concat/README.md
0 → 100644
| 1 | # simple-concat [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url] | ||
| 2 | |||
| 3 | [travis-image]: https://img.shields.io/travis/feross/simple-concat/master.svg | ||
| 4 | [travis-url]: https://travis-ci.org/feross/simple-concat | ||
| 5 | [npm-image]: https://img.shields.io/npm/v/simple-concat.svg | ||
| 6 | [npm-url]: https://npmjs.org/package/simple-concat | ||
| 7 | [downloads-image]: https://img.shields.io/npm/dm/simple-concat.svg | ||
| 8 | [downloads-url]: https://npmjs.org/package/simple-concat | ||
| 9 | [standard-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg | ||
| 10 | [standard-url]: https://standardjs.com | ||
| 11 | |||
| 12 | ### Super-minimalist version of [`concat-stream`](https://github.com/maxogden/concat-stream). Less than 15 lines! | ||
| 13 | |||
| 14 | ## install | ||
| 15 | |||
| 16 | ``` | ||
| 17 | npm install simple-concat | ||
| 18 | ``` | ||
| 19 | |||
| 20 | ## usage | ||
| 21 | |||
| 22 | This example is longer than the implementation. | ||
| 23 | |||
| 24 | ```js | ||
| 25 | var s = new stream.PassThrough() | ||
| 26 | concat(s, function (err, buf) { | ||
| 27 | if (err) throw err | ||
| 28 | console.error(buf) | ||
| 29 | }) | ||
| 30 | s.write('abc') | ||
| 31 | setTimeout(function () { | ||
| 32 | s.write('123') | ||
| 33 | }, 10) | ||
| 34 | setTimeout(function () { | ||
| 35 | s.write('456') | ||
| 36 | }, 20) | ||
| 37 | setTimeout(function () { | ||
| 38 | s.end('789') | ||
| 39 | }, 30) | ||
| 40 | ``` | ||
| 41 | |||
| 42 | ## license | ||
| 43 | |||
| 44 | MIT. Copyright (c) [Feross Aboukhadijeh](http://feross.org). |
node_modules/simple-concat/index.js
0 → 100644
| 1 | /*! simple-concat. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */ | ||
| 2 | module.exports = function (stream, cb) { | ||
| 3 | var chunks = [] | ||
| 4 | stream.on('data', function (chunk) { | ||
| 5 | chunks.push(chunk) | ||
| 6 | }) | ||
| 7 | stream.once('end', function () { | ||
| 8 | if (cb) cb(null, Buffer.concat(chunks)) | ||
| 9 | cb = null | ||
| 10 | }) | ||
| 11 | stream.once('error', function (err) { | ||
| 12 | if (cb) cb(err) | ||
| 13 | cb = null | ||
| 14 | }) | ||
| 15 | } |
node_modules/simple-concat/package.json
0 → 100644
| 1 | { | ||
| 2 | "_from": "simple-concat@^1.0.0", | ||
| 3 | "_id": "simple-concat@1.0.1", | ||
| 4 | "_inBundle": false, | ||
| 5 | "_integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==", | ||
| 6 | "_location": "/simple-concat", | ||
| 7 | "_phantomChildren": {}, | ||
| 8 | "_requested": { | ||
| 9 | "type": "range", | ||
| 10 | "registry": true, | ||
| 11 | "raw": "simple-concat@^1.0.0", | ||
| 12 | "name": "simple-concat", | ||
| 13 | "escapedName": "simple-concat", | ||
| 14 | "rawSpec": "^1.0.0", | ||
| 15 | "saveSpec": null, | ||
| 16 | "fetchSpec": "^1.0.0" | ||
| 17 | }, | ||
| 18 | "_requiredBy": [ | ||
| 19 | "/simple-get" | ||
| 20 | ], | ||
| 21 | "_resolved": "https://registry.npmmirror.com/simple-concat/-/simple-concat-1.0.1.tgz", | ||
| 22 | "_shasum": "f46976082ba35c2263f1c8ab5edfe26c41c9552f", | ||
| 23 | "_spec": "simple-concat@^1.0.0", | ||
| 24 | "_where": "/Users/zhanghao/brcode/br-client/node_modules/simple-get", | ||
| 25 | "author": { | ||
| 26 | "name": "Feross Aboukhadijeh", | ||
| 27 | "email": "feross@feross.org", | ||
| 28 | "url": "https://feross.org" | ||
| 29 | }, | ||
| 30 | "bugs": { | ||
| 31 | "url": "https://github.com/feross/simple-concat/issues" | ||
| 32 | }, | ||
| 33 | "bundleDependencies": false, | ||
| 34 | "dependencies": {}, | ||
| 35 | "deprecated": false, | ||
| 36 | "description": "Super-minimalist version of `concat-stream`. Less than 15 lines!", | ||
| 37 | "devDependencies": { | ||
| 38 | "standard": "*", | ||
| 39 | "tape": "^5.0.1" | ||
| 40 | }, | ||
| 41 | "funding": [ | ||
| 42 | { | ||
| 43 | "type": "github", | ||
| 44 | "url": "https://github.com/sponsors/feross" | ||
| 45 | }, | ||
| 46 | { | ||
| 47 | "type": "patreon", | ||
| 48 | "url": "https://www.patreon.com/feross" | ||
| 49 | }, | ||
| 50 | { | ||
| 51 | "type": "consulting", | ||
| 52 | "url": "https://feross.org/support" | ||
| 53 | } | ||
| 54 | ], | ||
| 55 | "homepage": "https://github.com/feross/simple-concat", | ||
| 56 | "keywords": [ | ||
| 57 | "concat", | ||
| 58 | "concat-stream", | ||
| 59 | "concat stream" | ||
| 60 | ], | ||
| 61 | "license": "MIT", | ||
| 62 | "main": "index.js", | ||
| 63 | "name": "simple-concat", | ||
| 64 | "repository": { | ||
| 65 | "type": "git", | ||
| 66 | "url": "git://github.com/feross/simple-concat.git" | ||
| 67 | }, | ||
| 68 | "scripts": { | ||
| 69 | "test": "standard && tape test/*.js" | ||
| 70 | }, | ||
| 71 | "version": "1.0.1" | ||
| 72 | } |
node_modules/simple-concat/test/basic.js
0 → 100644
| 1 | var concat = require('../') | ||
| 2 | var stream = require('stream') | ||
| 3 | var test = require('tape') | ||
| 4 | |||
| 5 | test('basic', function (t) { | ||
| 6 | t.plan(2) | ||
| 7 | var s = new stream.PassThrough() | ||
| 8 | concat(s, function (err, buf) { | ||
| 9 | t.error(err) | ||
| 10 | t.deepEqual(buf, Buffer.from('abc123456789')) | ||
| 11 | }) | ||
| 12 | s.write('abc') | ||
| 13 | setTimeout(function () { | ||
| 14 | s.write('123') | ||
| 15 | }, 10) | ||
| 16 | setTimeout(function () { | ||
| 17 | s.write('456') | ||
| 18 | }, 20) | ||
| 19 | setTimeout(function () { | ||
| 20 | s.end('789') | ||
| 21 | }, 30) | ||
| 22 | }) | ||
| 23 | |||
| 24 | test('error', function (t) { | ||
| 25 | t.plan(2) | ||
| 26 | var s = new stream.PassThrough() | ||
| 27 | concat(s, function (err, buf) { | ||
| 28 | t.ok(err, 'got expected error') | ||
| 29 | t.ok(!buf) | ||
| 30 | }) | ||
| 31 | s.write('abc') | ||
| 32 | setTimeout(function () { | ||
| 33 | s.write('123') | ||
| 34 | }, 10) | ||
| 35 | setTimeout(function () { | ||
| 36 | s.write('456') | ||
| 37 | }, 20) | ||
| 38 | setTimeout(function () { | ||
| 39 | s.emit('error', new Error('error')) | ||
| 40 | }, 30) | ||
| 41 | }) |
| 1 | name: ci | ||
| 2 | 'on': | ||
| 3 | - push | ||
| 4 | - pull_request | ||
| 5 | jobs: | ||
| 6 | test: | ||
| 7 | name: Node ${{ matrix.node }} / ${{ matrix.os }} | ||
| 8 | runs-on: ${{ matrix.os }} | ||
| 9 | strategy: | ||
| 10 | fail-fast: false | ||
| 11 | matrix: | ||
| 12 | os: | ||
| 13 | - ubuntu-latest | ||
| 14 | node: | ||
| 15 | - '14' | ||
| 16 | steps: | ||
| 17 | - uses: actions/checkout@v2 | ||
| 18 | - uses: actions/setup-node@v2 | ||
| 19 | with: | ||
| 20 | node-version: ${{ matrix.node }} | ||
| 21 | - run: npm install | ||
| 22 | - run: npm run build --if-present | ||
| 23 | - run: npm test |
node_modules/simple-get/LICENSE
0 → 100644
| 1 | The MIT License (MIT) | ||
| 2 | |||
| 3 | Copyright (c) Feross Aboukhadijeh | ||
| 4 | |||
| 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
| 6 | this software and associated documentation files (the "Software"), to deal in | ||
| 7 | the Software without restriction, including without limitation the rights to | ||
| 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
| 9 | the Software, and to permit persons to whom the Software is furnished to do so, | ||
| 10 | 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, FITNESS | ||
| 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
| 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
| 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
| 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
node_modules/simple-get/README.md
0 → 100644
| 1 | # simple-get [![ci][ci-image]][ci-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url] | ||
| 2 | |||
| 3 | [ci-image]: https://img.shields.io/github/workflow/status/feross/simple-get/ci/master | ||
| 4 | [ci-url]: https://github.com/feross/simple-get/actions | ||
| 5 | [npm-image]: https://img.shields.io/npm/v/simple-get.svg | ||
| 6 | [npm-url]: https://npmjs.org/package/simple-get | ||
| 7 | [downloads-image]: https://img.shields.io/npm/dm/simple-get.svg | ||
| 8 | [downloads-url]: https://npmjs.org/package/simple-get | ||
| 9 | [standard-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg | ||
| 10 | [standard-url]: https://standardjs.com | ||
| 11 | |||
| 12 | ### Simplest way to make http get requests | ||
| 13 | |||
| 14 | ## features | ||
| 15 | |||
| 16 | This module is the lightest possible wrapper on top of node.js `http`, but supporting these essential features: | ||
| 17 | |||
| 18 | - follows redirects | ||
| 19 | - automatically handles gzip/deflate responses | ||
| 20 | - supports HTTPS | ||
| 21 | - supports specifying a timeout | ||
| 22 | - supports convenience `url` key so there's no need to use `url.parse` on the url when specifying options | ||
| 23 | - composes well with npm packages for features like cookies, proxies, form data, & OAuth | ||
| 24 | |||
| 25 | All this in < 100 lines of code. | ||
| 26 | |||
| 27 | ## install | ||
| 28 | |||
| 29 | ``` | ||
| 30 | npm install simple-get | ||
| 31 | ``` | ||
| 32 | |||
| 33 | ## usage | ||
| 34 | |||
| 35 | Note, all these examples also work in the browser with [browserify](http://browserify.org/). | ||
| 36 | |||
| 37 | ### simple GET request | ||
| 38 | |||
| 39 | Doesn't get easier than this: | ||
| 40 | |||
| 41 | ```js | ||
| 42 | const get = require('simple-get') | ||
| 43 | |||
| 44 | get('http://example.com', function (err, res) { | ||
| 45 | if (err) throw err | ||
| 46 | console.log(res.statusCode) // 200 | ||
| 47 | res.pipe(process.stdout) // `res` is a stream | ||
| 48 | }) | ||
| 49 | ``` | ||
| 50 | |||
| 51 | ### even simpler GET request | ||
| 52 | |||
| 53 | If you just want the data, and don't want to deal with streams: | ||
| 54 | |||
| 55 | ```js | ||
| 56 | const get = require('simple-get') | ||
| 57 | |||
| 58 | get.concat('http://example.com', function (err, res, data) { | ||
| 59 | if (err) throw err | ||
| 60 | console.log(res.statusCode) // 200 | ||
| 61 | console.log(data) // Buffer('this is the server response') | ||
| 62 | }) | ||
| 63 | ``` | ||
| 64 | |||
| 65 | ### POST, PUT, PATCH, HEAD, DELETE support | ||
| 66 | |||
| 67 | For `POST`, call `get.post` or use option `{ method: 'POST' }`. | ||
| 68 | |||
| 69 | ```js | ||
| 70 | const get = require('simple-get') | ||
| 71 | |||
| 72 | const opts = { | ||
| 73 | url: 'http://example.com', | ||
| 74 | body: 'this is the POST body' | ||
| 75 | } | ||
| 76 | get.post(opts, function (err, res) { | ||
| 77 | if (err) throw err | ||
| 78 | res.pipe(process.stdout) // `res` is a stream | ||
| 79 | }) | ||
| 80 | ``` | ||
| 81 | |||
| 82 | #### A more complex example: | ||
| 83 | |||
| 84 | ```js | ||
| 85 | const get = require('simple-get') | ||
| 86 | |||
| 87 | get({ | ||
| 88 | url: 'http://example.com', | ||
| 89 | method: 'POST', | ||
| 90 | body: 'this is the POST body', | ||
| 91 | |||
| 92 | // simple-get accepts all options that node.js `http` accepts | ||
| 93 | // See: http://nodejs.org/api/http.html#http_http_request_options_callback | ||
| 94 | headers: { | ||
| 95 | 'user-agent': 'my cool app' | ||
| 96 | } | ||
| 97 | }, function (err, res) { | ||
| 98 | if (err) throw err | ||
| 99 | |||
| 100 | // All properties/methods from http.IncomingResponse are available, | ||
| 101 | // even if a gunzip/inflate transform stream was returned. | ||
| 102 | // See: http://nodejs.org/api/http.html#http_http_incomingmessage | ||
| 103 | res.setTimeout(10000) | ||
| 104 | console.log(res.headers) | ||
| 105 | |||
| 106 | res.on('data', function (chunk) { | ||
| 107 | // `chunk` is the decoded response, after it's been gunzipped or inflated | ||
| 108 | // (if applicable) | ||
| 109 | console.log('got a chunk of the response: ' + chunk) | ||
| 110 | })) | ||
| 111 | |||
| 112 | }) | ||
| 113 | ``` | ||
| 114 | |||
| 115 | ### JSON | ||
| 116 | |||
| 117 | You can serialize/deserialize request and response with JSON: | ||
| 118 | |||
| 119 | ```js | ||
| 120 | const get = require('simple-get') | ||
| 121 | |||
| 122 | const opts = { | ||
| 123 | method: 'POST', | ||
| 124 | url: 'http://example.com', | ||
| 125 | body: { | ||
| 126 | key: 'value' | ||
| 127 | }, | ||
| 128 | json: true | ||
| 129 | } | ||
| 130 | get.concat(opts, function (err, res, data) { | ||
| 131 | if (err) throw err | ||
| 132 | console.log(data.key) // `data` is an object | ||
| 133 | }) | ||
| 134 | ``` | ||
| 135 | |||
| 136 | ### Timeout | ||
| 137 | |||
| 138 | You can set a timeout (in milliseconds) on the request with the `timeout` option. | ||
| 139 | If the request takes longer than `timeout` to complete, then the entire request | ||
| 140 | will fail with an `Error`. | ||
| 141 | |||
| 142 | ```js | ||
| 143 | const get = require('simple-get') | ||
| 144 | |||
| 145 | const opts = { | ||
| 146 | url: 'http://example.com', | ||
| 147 | timeout: 2000 // 2 second timeout | ||
| 148 | } | ||
| 149 | |||
| 150 | get(opts, function (err, res) {}) | ||
| 151 | ``` | ||
| 152 | |||
| 153 | ### One Quick Tip | ||
| 154 | |||
| 155 | It's a good idea to set the `'user-agent'` header so the provider can more easily | ||
| 156 | see how their resource is used. | ||
| 157 | |||
| 158 | ```js | ||
| 159 | const get = require('simple-get') | ||
| 160 | const pkg = require('./package.json') | ||
| 161 | |||
| 162 | get('http://example.com', { | ||
| 163 | headers: { | ||
| 164 | 'user-agent': `my-module/${pkg.version} (https://github.com/username/my-module)` | ||
| 165 | } | ||
| 166 | }) | ||
| 167 | ``` | ||
| 168 | |||
| 169 | ### Proxies | ||
| 170 | |||
| 171 | You can use the [`tunnel`](https://github.com/koichik/node-tunnel) module with the | ||
| 172 | `agent` option to work with proxies: | ||
| 173 | |||
| 174 | ```js | ||
| 175 | const get = require('simple-get') | ||
| 176 | const tunnel = require('tunnel') | ||
| 177 | |||
| 178 | const opts = { | ||
| 179 | url: 'http://example.com', | ||
| 180 | agent: tunnel.httpOverHttp({ | ||
| 181 | proxy: { | ||
| 182 | host: 'localhost' | ||
| 183 | } | ||
| 184 | }) | ||
| 185 | } | ||
| 186 | |||
| 187 | get(opts, function (err, res) {}) | ||
| 188 | ``` | ||
| 189 | |||
| 190 | ### Cookies | ||
| 191 | |||
| 192 | You can use the [`cookie`](https://github.com/jshttp/cookie) module to include | ||
| 193 | cookies in a request: | ||
| 194 | |||
| 195 | ```js | ||
| 196 | const get = require('simple-get') | ||
| 197 | const cookie = require('cookie') | ||
| 198 | |||
| 199 | const opts = { | ||
| 200 | url: 'http://example.com', | ||
| 201 | headers: { | ||
| 202 | cookie: cookie.serialize('foo', 'bar') | ||
| 203 | } | ||
| 204 | } | ||
| 205 | |||
| 206 | get(opts, function (err, res) {}) | ||
| 207 | ``` | ||
| 208 | |||
| 209 | ### Form data | ||
| 210 | |||
| 211 | You can use the [`form-data`](https://github.com/form-data/form-data) module to | ||
| 212 | create POST request with form data: | ||
| 213 | |||
| 214 | ```js | ||
| 215 | const fs = require('fs') | ||
| 216 | const get = require('simple-get') | ||
| 217 | const FormData = require('form-data') | ||
| 218 | const form = new FormData() | ||
| 219 | |||
| 220 | form.append('my_file', fs.createReadStream('/foo/bar.jpg')) | ||
| 221 | |||
| 222 | const opts = { | ||
| 223 | url: 'http://example.com', | ||
| 224 | body: form | ||
| 225 | } | ||
| 226 | |||
| 227 | get.post(opts, function (err, res) {}) | ||
| 228 | ``` | ||
| 229 | |||
| 230 | #### Or, include `application/x-www-form-urlencoded` form data manually: | ||
| 231 | |||
| 232 | ```js | ||
| 233 | const get = require('simple-get') | ||
| 234 | |||
| 235 | const opts = { | ||
| 236 | url: 'http://example.com', | ||
| 237 | form: { | ||
| 238 | key: 'value' | ||
| 239 | } | ||
| 240 | } | ||
| 241 | get.post(opts, function (err, res) {}) | ||
| 242 | ``` | ||
| 243 | |||
| 244 | ### Specifically disallowing redirects | ||
| 245 | |||
| 246 | ```js | ||
| 247 | const get = require('simple-get') | ||
| 248 | |||
| 249 | const opts = { | ||
| 250 | url: 'http://example.com/will-redirect-elsewhere', | ||
| 251 | followRedirects: false | ||
| 252 | } | ||
| 253 | // res.statusCode will be 301, no error thrown | ||
| 254 | get(opts, function (err, res) {}) | ||
| 255 | ``` | ||
| 256 | |||
| 257 | ### Basic Auth | ||
| 258 | |||
| 259 | ```js | ||
| 260 | const user = 'someuser' | ||
| 261 | const pass = 'pa$$word' | ||
| 262 | const encodedAuth = Buffer.from(`${user}:${pass}`).toString('base64') | ||
| 263 | |||
| 264 | get('http://example.com', { | ||
| 265 | headers: { | ||
| 266 | authorization: `Basic ${encodedAuth}` | ||
| 267 | } | ||
| 268 | }) | ||
| 269 | ``` | ||
| 270 | |||
| 271 | ### OAuth | ||
| 272 | |||
| 273 | You can use the [`oauth-1.0a`](https://github.com/ddo/oauth-1.0a) module to create | ||
| 274 | a signed OAuth request: | ||
| 275 | |||
| 276 | ```js | ||
| 277 | const get = require('simple-get') | ||
| 278 | const crypto = require('crypto') | ||
| 279 | const OAuth = require('oauth-1.0a') | ||
| 280 | |||
| 281 | const oauth = OAuth({ | ||
| 282 | consumer: { | ||
| 283 | key: process.env.CONSUMER_KEY, | ||
| 284 | secret: process.env.CONSUMER_SECRET | ||
| 285 | }, | ||
| 286 | signature_method: 'HMAC-SHA1', | ||
| 287 | hash_function: (baseString, key) => crypto.createHmac('sha1', key).update(baseString).digest('base64') | ||
| 288 | }) | ||
| 289 | |||
| 290 | const token = { | ||
| 291 | key: process.env.ACCESS_TOKEN, | ||
| 292 | secret: process.env.ACCESS_TOKEN_SECRET | ||
| 293 | } | ||
| 294 | |||
| 295 | const url = 'https://api.twitter.com/1.1/statuses/home_timeline.json' | ||
| 296 | |||
| 297 | const opts = { | ||
| 298 | url: url, | ||
| 299 | headers: oauth.toHeader(oauth.authorize({url, method: 'GET'}, token)), | ||
| 300 | json: true | ||
| 301 | } | ||
| 302 | |||
| 303 | get(opts, function (err, res) {}) | ||
| 304 | ``` | ||
| 305 | |||
| 306 | ### Throttle requests | ||
| 307 | |||
| 308 | You can use [limiter](https://github.com/jhurliman/node-rate-limiter) to throttle requests. This is useful when calling an API that is rate limited. | ||
| 309 | |||
| 310 | ```js | ||
| 311 | const simpleGet = require('simple-get') | ||
| 312 | const RateLimiter = require('limiter').RateLimiter | ||
| 313 | const limiter = new RateLimiter(1, 'second') | ||
| 314 | |||
| 315 | const get = (opts, cb) => limiter.removeTokens(1, () => simpleGet(opts, cb)) | ||
| 316 | get.concat = (opts, cb) => limiter.removeTokens(1, () => simpleGet.concat(opts, cb)) | ||
| 317 | |||
| 318 | var opts = { | ||
| 319 | url: 'http://example.com' | ||
| 320 | } | ||
| 321 | |||
| 322 | get.concat(opts, processResult) | ||
| 323 | get.concat(opts, processResult) | ||
| 324 | |||
| 325 | function processResult (err, res, data) { | ||
| 326 | if (err) throw err | ||
| 327 | console.log(data.toString()) | ||
| 328 | } | ||
| 329 | ``` | ||
| 330 | |||
| 331 | ## license | ||
| 332 | |||
| 333 | MIT. Copyright (c) [Feross Aboukhadijeh](http://feross.org). |
node_modules/simple-get/index.js
0 → 100644
| 1 | /*! simple-get. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */ | ||
| 2 | module.exports = simpleGet | ||
| 3 | |||
| 4 | const concat = require('simple-concat') | ||
| 5 | const decompressResponse = require('decompress-response') // excluded from browser build | ||
| 6 | const http = require('http') | ||
| 7 | const https = require('https') | ||
| 8 | const once = require('once') | ||
| 9 | const querystring = require('querystring') | ||
| 10 | const url = require('url') | ||
| 11 | |||
| 12 | const isStream = o => o !== null && typeof o === 'object' && typeof o.pipe === 'function' | ||
| 13 | |||
| 14 | function simpleGet (opts, cb) { | ||
| 15 | opts = Object.assign({ maxRedirects: 10 }, typeof opts === 'string' ? { url: opts } : opts) | ||
| 16 | cb = once(cb) | ||
| 17 | |||
| 18 | if (opts.url) { | ||
| 19 | const { hostname, port, protocol, auth, path } = url.parse(opts.url) // eslint-disable-line node/no-deprecated-api | ||
| 20 | delete opts.url | ||
| 21 | if (!hostname && !port && !protocol && !auth) opts.path = path // Relative redirect | ||
| 22 | else Object.assign(opts, { hostname, port, protocol, auth, path }) // Absolute redirect | ||
| 23 | } | ||
| 24 | |||
| 25 | const headers = { 'accept-encoding': 'gzip, deflate' } | ||
| 26 | if (opts.headers) Object.keys(opts.headers).forEach(k => (headers[k.toLowerCase()] = opts.headers[k])) | ||
| 27 | opts.headers = headers | ||
| 28 | |||
| 29 | let body | ||
| 30 | if (opts.body) { | ||
| 31 | body = opts.json && !isStream(opts.body) ? JSON.stringify(opts.body) : opts.body | ||
| 32 | } else if (opts.form) { | ||
| 33 | body = typeof opts.form === 'string' ? opts.form : querystring.stringify(opts.form) | ||
| 34 | opts.headers['content-type'] = 'application/x-www-form-urlencoded' | ||
| 35 | } | ||
| 36 | |||
| 37 | if (body) { | ||
| 38 | if (!opts.method) opts.method = 'POST' | ||
| 39 | if (!isStream(body)) opts.headers['content-length'] = Buffer.byteLength(body) | ||
| 40 | if (opts.json && !opts.form) opts.headers['content-type'] = 'application/json' | ||
| 41 | } | ||
| 42 | delete opts.body; delete opts.form | ||
| 43 | |||
| 44 | if (opts.json) opts.headers.accept = 'application/json' | ||
| 45 | if (opts.method) opts.method = opts.method.toUpperCase() | ||
| 46 | |||
| 47 | const originalHost = opts.hostname // hostname before potential redirect | ||
| 48 | const protocol = opts.protocol === 'https:' ? https : http // Support http/https urls | ||
| 49 | const req = protocol.request(opts, res => { | ||
| 50 | if (opts.followRedirects !== false && res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) { | ||
| 51 | opts.url = res.headers.location // Follow 3xx redirects | ||
| 52 | delete opts.headers.host // Discard `host` header on redirect (see #32) | ||
| 53 | res.resume() // Discard response | ||
| 54 | |||
| 55 | const redirectHost = url.parse(opts.url).hostname // eslint-disable-line node/no-deprecated-api | ||
| 56 | // If redirected host is different than original host, drop headers to prevent cookie leak (#73) | ||
| 57 | if (redirectHost !== null && redirectHost !== originalHost) { | ||
| 58 | delete opts.headers.cookie | ||
| 59 | delete opts.headers.authorization | ||
| 60 | } | ||
| 61 | |||
| 62 | if (opts.method === 'POST' && [301, 302].includes(res.statusCode)) { | ||
| 63 | opts.method = 'GET' // On 301/302 redirect, change POST to GET (see #35) | ||
| 64 | delete opts.headers['content-length']; delete opts.headers['content-type'] | ||
| 65 | } | ||
| 66 | |||
| 67 | if (opts.maxRedirects-- === 0) return cb(new Error('too many redirects')) | ||
| 68 | else return simpleGet(opts, cb) | ||
| 69 | } | ||
| 70 | |||
| 71 | const tryUnzip = typeof decompressResponse === 'function' && opts.method !== 'HEAD' | ||
| 72 | cb(null, tryUnzip ? decompressResponse(res) : res) | ||
| 73 | }) | ||
| 74 | req.on('timeout', () => { | ||
| 75 | req.abort() | ||
| 76 | cb(new Error('Request timed out')) | ||
| 77 | }) | ||
| 78 | req.on('error', cb) | ||
| 79 | |||
| 80 | if (isStream(body)) body.on('error', cb).pipe(req) | ||
| 81 | else req.end(body) | ||
| 82 | |||
| 83 | return req | ||
| 84 | } | ||
| 85 | |||
| 86 | simpleGet.concat = (opts, cb) => { | ||
| 87 | return simpleGet(opts, (err, res) => { | ||
| 88 | if (err) return cb(err) | ||
| 89 | concat(res, (err, data) => { | ||
| 90 | if (err) return cb(err) | ||
| 91 | if (opts.json) { | ||
| 92 | try { | ||
| 93 | data = JSON.parse(data.toString()) | ||
| 94 | } catch (err) { | ||
| 95 | return cb(err, res, data) | ||
| 96 | } | ||
| 97 | } | ||
| 98 | cb(null, res, data) | ||
| 99 | }) | ||
| 100 | }) | ||
| 101 | } | ||
| 102 | |||
| 103 | ;['get', 'post', 'put', 'patch', 'head', 'delete'].forEach(method => { | ||
| 104 | simpleGet[method] = (opts, cb) => { | ||
| 105 | if (typeof opts === 'string') opts = { url: opts } | ||
| 106 | return simpleGet(Object.assign({ method: method.toUpperCase() }, opts), cb) | ||
| 107 | } | ||
| 108 | }) |
node_modules/simple-get/package.json
0 → 100644
| 1 | { | ||
| 2 | "_from": "simple-get@^4.0.1", | ||
| 3 | "_id": "simple-get@4.0.1", | ||
| 4 | "_inBundle": false, | ||
| 5 | "_integrity": "sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==", | ||
| 6 | "_location": "/simple-get", | ||
| 7 | "_phantomChildren": {}, | ||
| 8 | "_requested": { | ||
| 9 | "type": "range", | ||
| 10 | "registry": true, | ||
| 11 | "raw": "simple-get@^4.0.1", | ||
| 12 | "name": "simple-get", | ||
| 13 | "escapedName": "simple-get", | ||
| 14 | "rawSpec": "^4.0.1", | ||
| 15 | "saveSpec": null, | ||
| 16 | "fetchSpec": "^4.0.1" | ||
| 17 | }, | ||
| 18 | "_requiredBy": [ | ||
| 19 | "/vue-qr" | ||
| 20 | ], | ||
| 21 | "_resolved": "https://registry.npmmirror.com/simple-get/-/simple-get-4.0.1.tgz", | ||
| 22 | "_shasum": "4a39db549287c979d352112fa03fd99fd6bc3543", | ||
| 23 | "_spec": "simple-get@^4.0.1", | ||
| 24 | "_where": "/Users/zhanghao/brcode/br-client/node_modules/vue-qr", | ||
| 25 | "author": { | ||
| 26 | "name": "Feross Aboukhadijeh", | ||
| 27 | "email": "feross@feross.org", | ||
| 28 | "url": "https://feross.org" | ||
| 29 | }, | ||
| 30 | "browser": { | ||
| 31 | "decompress-response": false | ||
| 32 | }, | ||
| 33 | "bugs": { | ||
| 34 | "url": "https://github.com/feross/simple-get/issues" | ||
| 35 | }, | ||
| 36 | "bundleDependencies": false, | ||
| 37 | "dependencies": { | ||
| 38 | "decompress-response": "^6.0.0", | ||
| 39 | "once": "^1.3.1", | ||
| 40 | "simple-concat": "^1.0.0" | ||
| 41 | }, | ||
| 42 | "deprecated": false, | ||
| 43 | "description": "Simplest way to make http get requests. Supports HTTPS, redirects, gzip/deflate, streams in < 100 lines.", | ||
| 44 | "devDependencies": { | ||
| 45 | "self-signed-https": "^1.0.5", | ||
| 46 | "standard": "*", | ||
| 47 | "string-to-stream": "^3.0.0", | ||
| 48 | "tape": "^5.0.0" | ||
| 49 | }, | ||
| 50 | "funding": [ | ||
| 51 | { | ||
| 52 | "type": "github", | ||
| 53 | "url": "https://github.com/sponsors/feross" | ||
| 54 | }, | ||
| 55 | { | ||
| 56 | "type": "patreon", | ||
| 57 | "url": "https://www.patreon.com/feross" | ||
| 58 | }, | ||
| 59 | { | ||
| 60 | "type": "consulting", | ||
| 61 | "url": "https://feross.org/support" | ||
| 62 | } | ||
| 63 | ], | ||
| 64 | "homepage": "https://github.com/feross/simple-get", | ||
| 65 | "keywords": [ | ||
| 66 | "request", | ||
| 67 | "http", | ||
| 68 | "GET", | ||
| 69 | "get request", | ||
| 70 | "http.get", | ||
| 71 | "redirects", | ||
| 72 | "follow redirects", | ||
| 73 | "gzip", | ||
| 74 | "deflate", | ||
| 75 | "https", | ||
| 76 | "http-https", | ||
| 77 | "stream", | ||
| 78 | "simple request", | ||
| 79 | "simple get" | ||
| 80 | ], | ||
| 81 | "license": "MIT", | ||
| 82 | "main": "index.js", | ||
| 83 | "name": "simple-get", | ||
| 84 | "repository": { | ||
| 85 | "type": "git", | ||
| 86 | "url": "git://github.com/feross/simple-get.git" | ||
| 87 | }, | ||
| 88 | "scripts": { | ||
| 89 | "test": "standard && tape test/*.js" | ||
| 90 | }, | ||
| 91 | "version": "4.0.1" | ||
| 92 | } |
node_modules/string-split-by/.eslintrc.json
0 → 100644
| 1 | { | ||
| 2 | "env": { | ||
| 3 | "browser": true, | ||
| 4 | "node": true, | ||
| 5 | "commonjs": true, | ||
| 6 | "es6": true | ||
| 7 | }, | ||
| 8 | "extends": "eslint:recommended", | ||
| 9 | "rules": { | ||
| 10 | "strict": 2, | ||
| 11 | "indent": 0, | ||
| 12 | "linebreak-style": 0, | ||
| 13 | "quotes": 0, | ||
| 14 | "semi": 0, | ||
| 15 | "no-cond-assign": 1, | ||
| 16 | "no-constant-condition": 1, | ||
| 17 | "no-duplicate-case": 1, | ||
| 18 | "no-empty": 1, | ||
| 19 | "no-ex-assign": 1, | ||
| 20 | "no-extra-boolean-cast": 1, | ||
| 21 | "no-extra-semi": 1, | ||
| 22 | "no-fallthrough": 1, | ||
| 23 | "no-func-assign": 1, | ||
| 24 | "no-global-assign": 1, | ||
| 25 | "no-implicit-globals": 2, | ||
| 26 | "no-inner-declarations": ["error", "functions"], | ||
| 27 | "no-irregular-whitespace": 2, | ||
| 28 | "no-loop-func": 1, | ||
| 29 | "no-magic-numbers": ["warn", { "ignore": [1, 0, -1], "ignoreArrayIndexes": true}], | ||
| 30 | "no-multi-str": 1, | ||
| 31 | "no-mixed-spaces-and-tabs": 1, | ||
| 32 | "no-proto": 1, | ||
| 33 | "no-sequences": 1, | ||
| 34 | "no-throw-literal": 1, | ||
| 35 | "no-unmodified-loop-condition": 1, | ||
| 36 | "no-useless-call": 1, | ||
| 37 | "no-void": 1, | ||
| 38 | "no-with": 2, | ||
| 39 | "wrap-iife": 1, | ||
| 40 | "no-redeclare": 1, | ||
| 41 | "no-unused-vars": ["error", { "vars": "all", "args": "none" }], | ||
| 42 | "no-sparse-arrays": 1 | ||
| 43 | } | ||
| 44 | } |
node_modules/string-split-by/.travis.yml
0 → 100644
node_modules/string-split-by/index.js
0 → 100644
| 1 | 'use strict' | ||
| 2 | |||
| 3 | var paren = require('parenthesis') | ||
| 4 | |||
| 5 | module.exports = function splitBy (string, separator, o) { | ||
| 6 | if (string == null) throw Error('First argument should be a string') | ||
| 7 | if (separator == null) throw Error('Separator should be a string or a RegExp') | ||
| 8 | |||
| 9 | if (!o) o = {} | ||
| 10 | else if (typeof o === 'string' || Array.isArray(o)) { | ||
| 11 | o = {ignore: o} | ||
| 12 | } | ||
| 13 | |||
| 14 | if (o.escape == null) o.escape = true | ||
| 15 | if (o.ignore == null) o.ignore = ['[]', '()', '{}', '<>', '""', "''", '``', '“”', '«»'] | ||
| 16 | else { | ||
| 17 | if (typeof o.ignore === 'string') {o.ignore = [o.ignore]} | ||
| 18 | |||
| 19 | o.ignore = o.ignore.map(function (pair) { | ||
| 20 | // '"' → '""' | ||
| 21 | if (pair.length === 1) pair = pair + pair | ||
| 22 | return pair | ||
| 23 | }) | ||
| 24 | } | ||
| 25 | |||
| 26 | var tokens = paren.parse(string, {flat: true, brackets: o.ignore}) | ||
| 27 | var str = tokens[0] | ||
| 28 | |||
| 29 | var parts = str.split(separator) | ||
| 30 | |||
| 31 | // join parts separated by escape | ||
| 32 | if (o.escape) { | ||
| 33 | var cleanParts = [] | ||
| 34 | for (var i = 0; i < parts.length; i++) { | ||
| 35 | var prev = parts[i] | ||
| 36 | var part = parts[i + 1] | ||
| 37 | |||
| 38 | if (prev[prev.length - 1] === '\\' && prev[prev.length - 2] !== '\\') { | ||
| 39 | cleanParts.push(prev + separator + part) | ||
| 40 | i++ | ||
| 41 | } | ||
| 42 | else { | ||
| 43 | cleanParts.push(prev) | ||
| 44 | } | ||
| 45 | } | ||
| 46 | parts = cleanParts | ||
| 47 | } | ||
| 48 | |||
| 49 | // open parens pack & apply unquotes, if any | ||
| 50 | for (var i = 0; i < parts.length; i++) { | ||
| 51 | tokens[0] = parts[i] | ||
| 52 | parts[i] = paren.stringify(tokens, {flat: true}) | ||
| 53 | } | ||
| 54 | |||
| 55 | return parts | ||
| 56 | } |
node_modules/string-split-by/package.json
0 → 100644
| 1 | { | ||
| 2 | "_from": "string-split-by@^1.0.0", | ||
| 3 | "_id": "string-split-by@1.0.0", | ||
| 4 | "_inBundle": false, | ||
| 5 | "_integrity": "sha512-KaJKY+hfpzNyet/emP81PJA9hTVSfxNLS9SFTWxdCnnW1/zOOwiV248+EfoX7IQFcBaOp4G5YE6xTJMF+pLg6A==", | ||
| 6 | "_location": "/string-split-by", | ||
| 7 | "_phantomChildren": {}, | ||
| 8 | "_requested": { | ||
| 9 | "type": "range", | ||
| 10 | "registry": true, | ||
| 11 | "raw": "string-split-by@^1.0.0", | ||
| 12 | "name": "string-split-by", | ||
| 13 | "escapedName": "string-split-by", | ||
| 14 | "rawSpec": "^1.0.0", | ||
| 15 | "saveSpec": null, | ||
| 16 | "fetchSpec": "^1.0.0" | ||
| 17 | }, | ||
| 18 | "_requiredBy": [ | ||
| 19 | "/vue-qr" | ||
| 20 | ], | ||
| 21 | "_resolved": "https://registry.npmmirror.com/string-split-by/-/string-split-by-1.0.0.tgz", | ||
| 22 | "_shasum": "53895fb3397ebc60adab1f1e3a131f5372586812", | ||
| 23 | "_spec": "string-split-by@^1.0.0", | ||
| 24 | "_where": "/Users/zhanghao/brcode/br-client/node_modules/vue-qr", | ||
| 25 | "author": { | ||
| 26 | "name": "Dmitry Yv", | ||
| 27 | "email": "dfcreative@gmail.com" | ||
| 28 | }, | ||
| 29 | "bugs": { | ||
| 30 | "url": "https://github.com/dy/string-split-by/issues" | ||
| 31 | }, | ||
| 32 | "bundleDependencies": false, | ||
| 33 | "dependencies": { | ||
| 34 | "parenthesis": "^3.1.5" | ||
| 35 | }, | ||
| 36 | "deprecated": false, | ||
| 37 | "description": "Split string by any separator excluding brackets, quotes and escaped characters", | ||
| 38 | "devDependencies": { | ||
| 39 | "tape": "^4.9.0" | ||
| 40 | }, | ||
| 41 | "homepage": "https://github.com/dy/string-split-by#readme", | ||
| 42 | "keywords": [ | ||
| 43 | "split-string", | ||
| 44 | "string-split", | ||
| 45 | "split-stirng-words", | ||
| 46 | "space", | ||
| 47 | "string", | ||
| 48 | "split" | ||
| 49 | ], | ||
| 50 | "license": "MIT", | ||
| 51 | "main": "index.js", | ||
| 52 | "name": "string-split-by", | ||
| 53 | "repository": { | ||
| 54 | "type": "git", | ||
| 55 | "url": "git+https://github.com/dy/string-split-by.git" | ||
| 56 | }, | ||
| 57 | "scripts": { | ||
| 58 | "test": "node test.js" | ||
| 59 | }, | ||
| 60 | "version": "1.0.0" | ||
| 61 | } |
node_modules/string-split-by/readme.md
0 → 100644
| 1 | # string-split-by [](http://github.com/badges/stability-badges) [](https://travis-ci.org/dy/string-split-by) | ||
| 2 | |||
| 3 | Split string by a separator with respect to brackets, quotes and escape markers. Optimized version of [string-split](https://github.com/jonschlinkert/split-string). | ||
| 4 | |||
| 5 | ## Usage | ||
| 6 | |||
| 7 | [](https://npmjs.org/package/string-split-by/) | ||
| 8 | |||
| 9 | |||
| 10 | ```js | ||
| 11 | var split = require('string-split-by') | ||
| 12 | |||
| 13 | split('a."b.c".d.{.e.f.g.}.h', '.') | ||
| 14 | // ['a', '"b.c"', 'd', '{.e.f.g.}', 'h'] | ||
| 15 | |||
| 16 | split('a."b.c".d.{.e.f.g.}.h', '.', {ignore: '""'}) | ||
| 17 | // ['a', '"b.c"', 'd', '{', 'e', 'f', 'g', '}', 'h'] | ||
| 18 | ``` | ||
| 19 | |||
| 20 | ## API | ||
| 21 | |||
| 22 | ### parts = splitBy(string, separator, options?) | ||
| 23 | |||
| 24 | Return array with parts split from string by a separator, which can be whether _String_ or _RegExp_. Options can define: | ||
| 25 | |||
| 26 | Option | Default | Meaning | ||
| 27 | ---|---|--- | ||
| 28 | `ignore` | ``['"', "'", '`', '“”', '«»', '[]', '()', '{}']`` | Avoid splitting content enclosed in the character pairs. Can be a string or a list of strings. | ||
| 29 | `escape` | `true` | Avoid splitting at the escaped separator, eg. `\.` won't be separated by `'.'` separator. | ||
| 30 | |||
| 31 | |||
| 32 | ## Related | ||
| 33 | |||
| 34 | * [parenthesis](http://npmjs.org/package/parenthesis) | ||
| 35 | |||
| 36 | ## License | ||
| 37 | |||
| 38 | © 2018 Dmitry Yv. MIT License |
node_modules/string-split-by/test.js
0 → 100644
| 1 | 'use strict'; | ||
| 2 | |||
| 3 | var t = require('tape') | ||
| 4 | var split = require('.'); | ||
| 5 | |||
| 6 | t('should throw an error when arguments are invalid', t => { | ||
| 7 | t.throws(() => split()); | ||
| 8 | t.end() | ||
| 9 | }); | ||
| 10 | |||
| 11 | t('readme', t => { | ||
| 12 | |||
| 13 | t.deepEqual( | ||
| 14 | split('a."b.c".d.{.e.f.g.}.h', '.'), | ||
| 15 | ['a', '"b.c"', 'd', '{.e.f.g.}', 'h'] | ||
| 16 | ) | ||
| 17 | |||
| 18 | t.deepEqual( | ||
| 19 | split('a."b.c".d.{.e.f.g.}.h', '.', {ignore: '""'}), | ||
| 20 | ['a', '"b.c"', 'd', '{', 'e', 'f', 'g', '}', 'h'] | ||
| 21 | ) | ||
| 22 | t.end() | ||
| 23 | }) | ||
| 24 | |||
| 25 | t('should not split on escaped dots:', t => { | ||
| 26 | t.deepEqual(split('a.b.c\\.d', '.'), ['a', 'b', 'c\\.d']); | ||
| 27 | t.deepEqual(split('a.b.c\\.d.e', '.'), ['a', 'b', 'c\\.d', 'e']); | ||
| 28 | t.end() | ||
| 29 | }); | ||
| 30 | |||
| 31 | t('should keep escaping when followed by a backslash:', t => { | ||
| 32 | t.deepEqual(split('a.b.c\\\\.d', '.'), ['a', 'b', 'c\\\\', 'd']); | ||
| 33 | t.deepEqual(split('a.b.c\\\\d', '.'), ['a', 'b', 'c\\\\d']); | ||
| 34 | t.end() | ||
| 35 | }); | ||
| 36 | |||
| 37 | t('should split a string on dots by default:', t => { | ||
| 38 | t.deepEqual(split('a.b.c', '.'), ['a', 'b', 'c']); | ||
| 39 | t.end() | ||
| 40 | }); | ||
| 41 | |||
| 42 | t('should respect double-quoted strings', t => { | ||
| 43 | t.deepEqual(split('"b.c"', '.'), ['"b.c"']); | ||
| 44 | t.deepEqual(split('a."b.c"', '.'), ['a', '"b.c"']); | ||
| 45 | t.deepEqual(split('a".b.c"', '.'), ['a".b.c"']); | ||
| 46 | t.deepEqual(split('a."b.c".d', '.'), ['a', '"b.c"', 'd']); | ||
| 47 | t.deepEqual(split('a."b.c".d.".e.f.g.".h', '.'), ['a', '"b.c"', 'd', '".e.f.g."', 'h']); | ||
| 48 | t.end() | ||
| 49 | }); | ||
| 50 | |||
| 51 | t('should respect singlequoted strings', t => { | ||
| 52 | t.deepEqual(split('\'b.c\'', '.'), ['\'b.c\'']); | ||
| 53 | t.deepEqual(split('a.\'b.c\'', '.'), ['a', '\'b.c\'']); | ||
| 54 | t.deepEqual(split('a.\'b.c\'.d', '.'), ['a', '\'b.c\'', 'd']); | ||
| 55 | t.deepEqual(split('a.\'b.c\'.d.\'.e.f.g.\'.h', '.'), ['a', '\'b.c\'', 'd', '\'.e.f.g.\'', 'h']); | ||
| 56 | t.end() | ||
| 57 | }); | ||
| 58 | |||
| 59 | t('should respect strings in backticks', t => { | ||
| 60 | t.deepEqual(split('`b.c`', '.'), ['`b.c`']); | ||
| 61 | t.deepEqual(split('a.`b.c`', '.'), ['a', '`b.c`']); | ||
| 62 | t.deepEqual(split('a.`b.c`.d', '.'), ['a', '`b.c`', 'd']); | ||
| 63 | t.deepEqual(split('a.`b.c`.d.`.e.f.g.`.h', '.'), ['a', '`b.c`', 'd', '`.e.f.g.`', 'h']); | ||
| 64 | t.end() | ||
| 65 | }); | ||
| 66 | |||
| 67 | t('should respect strings in double smart-quotes: “”', t => { | ||
| 68 | t.deepEqual(split('“b.c”', '.'), ['“b.c”']); | ||
| 69 | t.deepEqual(split('a.“b.c”', '.'), ['a', '“b.c”']); | ||
| 70 | t.deepEqual(split('a.“b.c”.d', '.'), ['a', '“b.c”', 'd']); | ||
| 71 | t.deepEqual(split('a.“b.c”.d.“.e.f.g.”.h', '.'), ['a', '“b.c”', 'd', '“.e.f.g.”', 'h']); | ||
| 72 | t.end() | ||
| 73 | }); | ||
| 74 | |||
| 75 | t('should retain unclosed double quotes in the results', t => { | ||
| 76 | t.deepEqual(split('a."b.c', '.'), ['a', '"b', 'c']); | ||
| 77 | t.end() | ||
| 78 | }); | ||
| 79 | |||
| 80 | t('should retain unclosed single quotes in the results', t => { | ||
| 81 | t.deepEqual(split('brian\'s', '.'), ['brian\'s']); | ||
| 82 | t.deepEqual(split('a.\'b.c', '.'), ['a', '\'b', 'c']); | ||
| 83 | t.end() | ||
| 84 | }); | ||
| 85 | |||
| 86 | |||
| 87 | |||
| 88 | t('should split on a custom separator', t => { | ||
| 89 | t.deepEqual(split('a/b/c', '/'), ['a', 'b', 'c']); | ||
| 90 | t.deepEqual(split('a,b,c', ','), ['a', 'b', 'c']); | ||
| 91 | t.end() | ||
| 92 | }); | ||
| 93 | |||
| 94 | t('should not split on an escaped custom separator:', t => { | ||
| 95 | t.deepEqual(split('a/b/c\\/d', '/'), ['a', 'b', 'c\\/d']); | ||
| 96 | t.end() | ||
| 97 | }); | ||
| 98 | |||
| 99 | t('should disable quotes support', t => { | ||
| 100 | t.deepEqual(split('a.\'b.c\'."d"', '.', {ignore: '"'}), ['a', '\'b', 'c\'', '"d"']); | ||
| 101 | t.end() | ||
| 102 | }); | ||
| 103 | |||
| 104 | t('should keep single quotes', t => { | ||
| 105 | t.deepEqual(split('a.\'b.c\'."d"', '.', {ignore: '\''}), ['a', '\'b.c\'', '"d"']); | ||
| 106 | t.end() | ||
| 107 | }); | ||
| 108 | |||
| 109 | t('should keep double quotes', t => { | ||
| 110 | t.deepEqual(split('a."b.c".d', '.', '"'), ['a', '"b.c"', 'd']); | ||
| 111 | t.end() | ||
| 112 | }); | ||
| 113 | |||
| 114 | t('should keep “” double quotes', t => { | ||
| 115 | t.deepEqual(split('a.“b.c”.d', '.', '“”'), ['a', '“b.c”', 'd']); | ||
| 116 | t.end() | ||
| 117 | }); | ||
| 118 | |||
| 119 | t('should keep backticks', t => { | ||
| 120 | t.deepEqual(split('a.`b.c`.d', '.', {ignore: '`'}), ['a', '`b.c`', 'd']); | ||
| 121 | t.end() | ||
| 122 | }); | ||
| 123 | |||
| 124 | t('should allow custom quotes object', t => { | ||
| 125 | t.deepEqual(split('a.^b.c$', '.', {ignore: '^$'}), ['a', '^b.c$']); | ||
| 126 | t.deepEqual(split('a.^b.c^', '.', {ignore: '^^'}), ['a', '^b.c^']); | ||
| 127 | t.deepEqual(split('a.~b.c~', '.', {ignore: '~~'}), ['a', '~b.c~']); | ||
| 128 | t.end() | ||
| 129 | }); | ||
| 130 | |||
| 131 | t('should keep escape characters', t => { | ||
| 132 | t.deepEqual(split('a.b\\.c', '.', {escape: true}), ['a', 'b\\.c']); | ||
| 133 | t.end() | ||
| 134 | }); | ||
| 135 | |||
| 136 | t.skip('should throw when brackets are unclosed', t => { | ||
| 137 | t.throws(function() { | ||
| 138 | }, /unclosed/); | ||
| 139 | t.end() | ||
| 140 | }); | ||
| 141 | |||
| 142 | t('should not split inside brackets', t => { | ||
| 143 | t.deepEqual(split('a.(b.c).d', '.'), ['a', '(b.c)', 'd']); | ||
| 144 | t.deepEqual(split('a.[(b.c)].d', '.'), ['a', '[(b.c)]', 'd']); | ||
| 145 | t.deepEqual(split('a.[b.c].d', '.'), ['a', '[b.c]', 'd']); | ||
| 146 | t.deepEqual(split('a.{b.c}.d', '.'), ['a', '{b.c}', 'd']); | ||
| 147 | t.deepEqual(split('a.<b.c>.d', '.'), ['a', '<b.c>', 'd']); | ||
| 148 | t.end() | ||
| 149 | }); | ||
| 150 | |||
| 151 | t('should support nested brackets', t => { | ||
| 152 | t.deepEqual(split('a.{b.{c}.d}.e', '.'), ['a', '{b.{c}.d}', 'e']); | ||
| 153 | t.deepEqual(split('a.{b.{c.d}.e}.f', '.'), ['a', '{b.{c.d}.e}', 'f']); | ||
| 154 | t.deepEqual(split('a.{[b.{{c.d}}.e]}.f', '.'), ['a', '{[b.{{c.d}}.e]}', 'f']); | ||
| 155 | t.end() | ||
| 156 | }); | ||
| 157 | |||
| 158 | t.skip('should support escaped brackets', t => { | ||
| 159 | t.deepEqual(split('a.\\{b.{c.c}.d}.e', '.'), ['a', '{b', '{c.c}', 'd}', 'e']); | ||
| 160 | t.deepEqual(split('a.{b.c}.\\{d.e}.f', '.'), ['a', '{b.c}', '{d', 'e}', 'f']); | ||
| 161 | t.end() | ||
| 162 | }); | ||
| 163 | |||
| 164 | t('should support quoted brackets', t => { | ||
| 165 | t.deepEqual(split('a.{b.c}."{d.e}".f', '.'), ['a', '{b.c}', '"{d.e}"', 'f']); | ||
| 166 | t.deepEqual(split('a.{b.c}.{"d.e"}.f', '.'), ['a', '{b.c}', '{"d.e"}', 'f']); | ||
| 167 | t.end() | ||
| 168 | }); | ||
| 169 | |||
| 170 | t('should ignore imbalanced brackets', t => { | ||
| 171 | t.deepEqual(split('a.{b.c', '.'), ['a', '{b', 'c']); | ||
| 172 | t.deepEqual(split('a.{a.{b.c}.d', '.'), ['a', '{a', '{b.c}', 'd']); | ||
| 173 | t.end() | ||
| 174 | }); | ||
| 175 |
node_modules/vue-qr/.babelrc
0 → 100644
node_modules/vue-qr/.editorconfig
0 → 100644
node_modules/vue-qr/.postcssrc.js
0 → 100644
node_modules/vue-qr/CHANGELOG.MD
0 → 100644
| 1 | # Changelog | ||
| 2 | ## 4.0.9 | 2022.05.24 | ||
| 3 | - Fix `path-browserify` export error | ||
| 4 | |||
| 5 | ## 4.0.6 | 2022.04.14 | ||
| 6 | - Fix dependency error position | ||
| 7 | |||
| 8 | ## 4.0.5 | 2022.04.13 | ||
| 9 | - Remove `canvas` dependency | ||
| 10 | |||
| 11 | ## 3.2.4 | 2022.01.19 | ||
| 12 | - Update `canvas` version | ||
| 13 | |||
| 14 | ## 3.2.2 | 2021.10.13 | ||
| 15 | - Bugfix: components default value [#100](https://github.com/Binaryify/vue-qr/pull/100) | ||
| 16 | |||
| 17 | - Update `components` default value | ||
| 18 | |||
| 19 | ## 3.2.0 | 2021.10.12 | ||
| 20 | - Add `components` params [#98](https://github.com/Binaryify/vue-qr/issues/98) | ||
| 21 | |||
| 22 | ## 3.1.0 | 2021.10.05 | ||
| 23 | - Support Vite [#90](https://github.com/Binaryify/vue-qr/issues/90) [#96](https://github.com/Binaryify/vue-qr/issues/96) | ||
| 24 | |||
| 25 | ## 3.0.0 | 2021.10.02 | ||
| 26 | - Using Awesome-qr.js v2.0 | ||
| 27 | |||
| 28 | - Support Vue v3.0(not support Vite yet) [#82](https://github.com/Binaryify/vue-qr/issues/82) | ||
| 29 | |||
| 30 | ## 2.3.1 | 2021.05.03 | ||
| 31 | - Fixed [#86](https://github.com/Binaryify/vue-qr/issues/86) | ||
| 32 | |||
| 33 | ## 2.3.0 | 2020.10.05 | ||
| 34 | - Support SSR | ||
| 35 | |||
| 36 | ## 2.2.0 | ||
| 37 | - Fixed [#65](https://github.com/Binaryify/vue-qr/issues/65) [#68](https://github.com/Binaryify/vue-qr/issues/68) | ||
| 38 | |||
| 39 | - Set `dotScale` default value to 1 | ||
| 40 | |||
| 41 | ## 2.1.0 | ||
| 42 | - Fixed qr margin offset when logo is added (via:[https://github.com/SumiMakito/Awesome-qr.js/pull/38](https://github.com/SumiMakito/Awesome-qr.js/pull/38)) | ||
| 43 | |||
| 44 | |||
| 45 | ## 2.0.7 | ||
| 46 | - Improve image load function | ||
| 47 | |||
| 48 | ## 2.0.6 | ||
| 49 | - Remove babel-polyfill [#53](https://github.com/Binaryify/vue-qr/issues/53) | ||
| 50 | - add .npmignore | ||
| 51 | |||
| 52 | ## 2.0.4 | ||
| 53 | - Fix dotScale defalut value bug | ||
| 54 | |||
| 55 | ## 2.0.2 | ||
| 56 | - Fix bug | ||
| 57 | |||
| 58 | ## 2.0.2 | ||
| 59 | - Update README.MD | ||
| 60 | |||
| 61 | ## 2.0.1 | ||
| 62 | - Fix colorLight can't set bug | ||
| 63 | - Support background color and logo background | ||
| 64 | |||
| 65 | |||
| 66 | ## 2.0.0 | ||
| 67 | - Refactoring | ||
| 68 | - Support gif background |
node_modules/vue-qr/LICENSE.txt
0 → 100644
| 1 | The MIT License (MIT) | ||
| 2 | |||
| 3 | Copyright (c) 2013-2022 Binaryify | ||
| 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 | ||
| 13 | all 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 | ||
| 21 | THE SOFTWARE. |
node_modules/vue-qr/README.md
0 → 100644
| 1 | # vue-qr | ||
| 2 | <a href="https://www.npmjs.com/package/vue-qr"><img src="https://img.shields.io/npm/v/vue-qr.svg" alt="Version"></a> | ||
| 3 | <a href="https://www.npmjs.com/package/vue-qr"><img src="https://img.shields.io/npm/l/vue-qr.svg" alt="License"></a> | ||
| 4 | |||
| 5 | |||
| 6 | The Vue Component for [SumiMakito's Awesome-qr.js](https://github.com/SumiMakito/Awesome-qr.js). Support Vue2/Vue3/Vite | ||
| 7 | |||
| 8 | The only one qr code component for Vue.js you need ! | ||
| 9 | |||
| 10 | ### Notice | ||
| 11 | Not support IE 不支持IE浏览器 | ||
| 12 | |||
| 13 | ### Examples, 样例 | ||
| 14 | |||
| 15 | > Try to scan these QR codes below with your smart phone. | ||
| 16 | |||
| 17 | Example 1|Example 2|Example 3|Example 4 | ||
| 18 | ------------ | ------------- | -------------| ------------- | ||
| 19 | <img src="https://raw.githubusercontent.com/Binaryify/vue-qr/master/src/assets/result1.png" width="300"> | <img src="https://raw.githubusercontent.com/Binaryify/vue-qr/master/src/assets/result2.png" width="300"> | <img src="https://raw.githubusercontent.com/Binaryify/vue-qr/master/src/assets/result3.png" width="300"> | <img src="https://raw.githubusercontent.com/Binaryify/vue-qr/master/src/assets/result4.gif" width="300"> | ||
| 20 | |||
| 21 | ### Demo | ||
| 22 | Run `npm run dev` or `yarn dev` | ||
| 23 | |||
| 24 | 运行 `npm run dev` or `yarn dev` | ||
| 25 | |||
| 26 | ## Installation | ||
| 27 | **install with NPM** | ||
| 28 | ```bash | ||
| 29 | npm install vue-qr --save | ||
| 30 | ``` | ||
| 31 | **Import** | ||
| 32 | ```js | ||
| 33 | // vue2.0 | ||
| 34 | import VueQr from 'vue-qr' | ||
| 35 | |||
| 36 | // vue3.0 (support vite) | ||
| 37 | import vueQr from 'vue-qr/src/packages/vue-qr.vue' | ||
| 38 | ... | ||
| 39 | { | ||
| 40 | components: {VueQr} | ||
| 41 | } | ||
| 42 | ``` | ||
| 43 | ## Usage | ||
| 44 | **In template** | ||
| 45 | |||
| 46 | ```html | ||
| 47 | <vue-qr :bgSrc='src' :logoSrc="src2" text="Hello world!" :size="200"></vue-qr> | ||
| 48 | <vue-qr text="Hello world!" :callback="test" qid="testid"></vue-qr> | ||
| 49 | ``` | ||
| 50 | |||
| 51 | ```js | ||
| 52 | export default { | ||
| 53 | methods:{ | ||
| 54 | test(dataUrl,id){ | ||
| 55 | console.log(url, id) | ||
| 56 | } | ||
| 57 | } | ||
| 58 | } | ||
| 59 | ``` | ||
| 60 | Parameter | Explanation | ||
| 61 | ----|---- | ||
| 62 | text | Contents to encode. 欲编码的内容 | ||
| 63 | correctLevel| Correct Level 0-3 容错级别 0-3 | ||
| 64 | size | Width as well as the height of the output QR code, includes margin. 尺寸, 长宽一致, 包含外边距 | ||
| 65 | margin | Margin to add around the QR code, default 20px. 二维码图像的外边距, 默认 20px | ||
| 66 | colorDark | Color of "true" blocks. Works only when both colorDark and colorLight are set. (BYTE_DTA, BYTE_POS, BYTE_AGN, BYTE_TMG) 实点的颜色 | ||
| 67 | colorLight | Color of empty space, or "false" blocks. Works only when both colorDark and colorLight are set. (BYTE_EPT) 空白区的颜色 | ||
| 68 | components | Controls the appearances of parts in the QR code. Read section [ComponentOptions](#componentoptions) to learn more. 阅读 [ComponentOptions](#componentoptions) 了解更多信息。 | ||
| 69 | bgSrc | Background url to embed in the QR code. 欲嵌入的背景图地址 | ||
| 70 | gifBgSrc | Gif background url to embed in the QR code, If gifBackground is set, backgroundImage will be ignored. This option will affects performance. 欲嵌入的背景图 gif 地址,设置后普通的背景图将失效。设置此选项会影响性能 | ||
| 71 | backgroundColor | Background color 背景色 | ||
| 72 | backgroundDimming | Color mask to add above the background image. Helpful when having problems with decoding. 叠加在背景图上的颜色, 在解码有难度的时有一定帮助 | ||
| 73 | logoSrc | Logo url to embed at the center of generated QR code 嵌入至二维码中心的 LOGO 地址 | ||
| 74 | logoScale | Value used to scale the logo image. Larger value may result in decode failure. Size of the logo equals to `logoScale*(size-2*margin)`. Default is 0.2. 用于计算 LOGO 大小的值, 过大将导致解码失败, LOGO 尺寸计算公式 `logoScale*(size-2*margin)`, 默认 0.2 | ||
| 75 | logoMargin | White margin that appears around the logo image. Default is 0. LOGO 标识周围的空白边框, 默认为0 | ||
| 76 | logoBackgroundColor | Logo background color, need set logo margin. Logo 背景色,需要设置 logo margin | ||
| 77 | logoCornerRadius | Radius of the logo's corners.Default is 0 LOGO 标识及其边框的圆角半径, 默认为0 | ||
| 78 | whiteMargin | If set to true, a white border will appear around the background image. Default is true. 若设为 true, 背景图外将绘制白色边框 | ||
| 79 | dotScale | Value used to scale down the data dots' size. (0 < scale < 1.0) default 1 数据区域点缩小比例,默认为1 | ||
| 80 | autoColor | If set to true, the dominant color of backgroundImage will be used as colorDark. Default is true. 若为 true, 背景图的主要颜色将作为实点的颜色, 即 colorDark,默认 true | ||
| 81 | binarize | If set to true, the whole image will be binarized with the given threshold, or default threshold if not specified. Default is false. 若为 true, 图像将被二值化处理, 未指定阈值则使用默认值 | ||
| 82 | binarizeThreshold | Threshold used to binarize the whole image. Default is 128. (0 < threshold < 255) 二值化处理的阈值 | ||
| 83 | callback | Data URI of the generated QR code will be available here. 生成的二维码 Data URI 可以在回调中取得,第一个参数为二维码 data URL, 第二个参数为 props 传过来的 qid(因为二维码生成是异步的,所以加个 id 用于排序) | ||
| 84 | bindElement | If set to true, the generated QR will bind to a HTML element automatically. Default is true. 指定是否需要自动将生成的二维码绑定到HTML上, 默认是true | ||
| 85 | |||
| 86 | ## ComponentOptions | ||
| 87 | |||
| 88 | > _ComponentOptions_ controls the appearances of parts in the QR code.组件选项控制二维码中零件的外观。 | ||
| 89 | |||
| 90 | ```ts | ||
| 91 | type ComponentOptions = { | ||
| 92 | data?: { | ||
| 93 | scale?: number; | ||
| 94 | }; | ||
| 95 | timing?: { | ||
| 96 | scale?: number; | ||
| 97 | protectors?: boolean; | ||
| 98 | }; | ||
| 99 | alignment?: { | ||
| 100 | scale?: number; | ||
| 101 | protectors?: boolean; | ||
| 102 | }; | ||
| 103 | cornerAlignment?: { | ||
| 104 | scale?: number; | ||
| 105 | protectors?: boolean; | ||
| 106 | }; | ||
| 107 | }; | ||
| 108 | ``` | ||
| 109 | |||
| 110 | ```ts | ||
| 111 | // default ComponentOptions | ||
| 112 | |||
| 113 | { | ||
| 114 | data: { | ||
| 115 | scale: 1, | ||
| 116 | }, | ||
| 117 | timing: { | ||
| 118 | scale: 1, | ||
| 119 | protectors: false, | ||
| 120 | }, | ||
| 121 | alignment: { | ||
| 122 | scale: 1, | ||
| 123 | protectors: false, | ||
| 124 | }, | ||
| 125 | cornerAlignment: { | ||
| 126 | scale: 1, | ||
| 127 | protectors: true, | ||
| 128 | }, | ||
| 129 | } | ||
| 130 | ``` | ||
| 131 | |||
| 132 | ### scale 比例尺 | ||
| 133 | Type number? | ||
| 134 | |||
| 135 | Scale factor for blocks in the specified area of the QR code. | ||
| 136 | 在 QR 码指定区域的块的比例。 | ||
| 137 | |||
| 138 | ### protectors | ||
| 139 | |||
| 140 | **Type** `boolean?` | ||
| 141 | |||
| 142 | Controls whether or not to draw the translucent protectors under the specified area in the QR code.控制是否在 QR 码的指定区域下绘制半透明保护器。 | ||
| 143 | |||
| 144 | |||
| 145 | For more details you should definitely check out [Awesome-qr.js ](https://github.com/SumiMakito/Awesome-qr.js) |
node_modules/vue-qr/dist/vue-qr.js
0 → 100644
This diff is collapsed.
Click to expand it.
node_modules/vue-qr/dist/vue-qr.js.map
0 → 100644
This diff could not be displayed because it is too large.
node_modules/vue-qr/index.html
0 → 100644
| 1 | MIT License | ||
| 2 | |||
| 3 | Copyright (c) 2013 Julian Gruber <julian@juliangruber.com> | ||
| 4 | |||
| 5 | Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 6 | of this software and associated documentation files (the "Software"), to deal | ||
| 7 | in the Software without restriction, including without limitation the rights | ||
| 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 9 | copies of the Software, and to permit persons to whom the Software is | ||
| 10 | furnished to do so, subject to the following conditions: | ||
| 11 | |||
| 12 | The above copyright notice and this permission notice shall be included in all | ||
| 13 | copies or substantial portions of the Software. | ||
| 14 | |||
| 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| 21 | SOFTWARE. |
| 1 | # brace-expansion | ||
| 2 | |||
| 3 | [Brace expansion](https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html), | ||
| 4 | as known from sh/bash, in JavaScript. | ||
| 5 | |||
| 6 | [](http://travis-ci.org/juliangruber/brace-expansion) | ||
| 7 | [](https://www.npmjs.org/package/brace-expansion) | ||
| 8 | [](https://greenkeeper.io/) | ||
| 9 | |||
| 10 | [](https://ci.testling.com/juliangruber/brace-expansion) | ||
| 11 | |||
| 12 | ## Example | ||
| 13 | |||
| 14 | ```js | ||
| 15 | var expand = require('brace-expansion'); | ||
| 16 | |||
| 17 | expand('file-{a,b,c}.jpg') | ||
| 18 | // => ['file-a.jpg', 'file-b.jpg', 'file-c.jpg'] | ||
| 19 | |||
| 20 | expand('-v{,,}') | ||
| 21 | // => ['-v', '-v', '-v'] | ||
| 22 | |||
| 23 | expand('file{0..2}.jpg') | ||
| 24 | // => ['file0.jpg', 'file1.jpg', 'file2.jpg'] | ||
| 25 | |||
| 26 | expand('file-{a..c}.jpg') | ||
| 27 | // => ['file-a.jpg', 'file-b.jpg', 'file-c.jpg'] | ||
| 28 | |||
| 29 | expand('file{2..0}.jpg') | ||
| 30 | // => ['file2.jpg', 'file1.jpg', 'file0.jpg'] | ||
| 31 | |||
| 32 | expand('file{0..4..2}.jpg') | ||
| 33 | // => ['file0.jpg', 'file2.jpg', 'file4.jpg'] | ||
| 34 | |||
| 35 | expand('file-{a..e..2}.jpg') | ||
| 36 | // => ['file-a.jpg', 'file-c.jpg', 'file-e.jpg'] | ||
| 37 | |||
| 38 | expand('file{00..10..5}.jpg') | ||
| 39 | // => ['file00.jpg', 'file05.jpg', 'file10.jpg'] | ||
| 40 | |||
| 41 | expand('{{A..C},{a..c}}') | ||
| 42 | // => ['A', 'B', 'C', 'a', 'b', 'c'] | ||
| 43 | |||
| 44 | expand('ppp{,config,oe{,conf}}') | ||
| 45 | // => ['ppp', 'pppconfig', 'pppoe', 'pppoeconf'] | ||
| 46 | ``` | ||
| 47 | |||
| 48 | ## API | ||
| 49 | |||
| 50 | ```js | ||
| 51 | var expand = require('brace-expansion'); | ||
| 52 | ``` | ||
| 53 | |||
| 54 | ### var expanded = expand(str) | ||
| 55 | |||
| 56 | Return an array of all possible and valid expansions of `str`. If none are | ||
| 57 | found, `[str]` is returned. | ||
| 58 | |||
| 59 | Valid expansions are: | ||
| 60 | |||
| 61 | ```js | ||
| 62 | /^(.*,)+(.+)?$/ | ||
| 63 | // {a,b,...} | ||
| 64 | ``` | ||
| 65 | |||
| 66 | A comma separated list of options, like `{a,b}` or `{a,{b,c}}` or `{,a,}`. | ||
| 67 | |||
| 68 | ```js | ||
| 69 | /^-?\d+\.\.-?\d+(\.\.-?\d+)?$/ | ||
| 70 | // {x..y[..incr]} | ||
| 71 | ``` | ||
| 72 | |||
| 73 | A numeric sequence from `x` to `y` inclusive, with optional increment. | ||
| 74 | If `x` or `y` start with a leading `0`, all the numbers will be padded | ||
| 75 | to have equal length. Negative numbers and backwards iteration work too. | ||
| 76 | |||
| 77 | ```js | ||
| 78 | /^-?\d+\.\.-?\d+(\.\.-?\d+)?$/ | ||
| 79 | // {x..y[..incr]} | ||
| 80 | ``` | ||
| 81 | |||
| 82 | An alphabetic sequence from `x` to `y` inclusive, with optional increment. | ||
| 83 | `x` and `y` must be exactly one character, and if given, `incr` must be a | ||
| 84 | number. | ||
| 85 | |||
| 86 | For compatibility reasons, the string `${` is not eligible for brace expansion. | ||
| 87 | |||
| 88 | ## Installation | ||
| 89 | |||
| 90 | With [npm](https://npmjs.org) do: | ||
| 91 | |||
| 92 | ```bash | ||
| 93 | npm install brace-expansion | ||
| 94 | ``` | ||
| 95 | |||
| 96 | ## Contributors | ||
| 97 | |||
| 98 | - [Julian Gruber](https://github.com/juliangruber) | ||
| 99 | - [Isaac Z. Schlueter](https://github.com/isaacs) | ||
| 100 | |||
| 101 | ## Sponsors | ||
| 102 | |||
| 103 | This module is proudly supported by my [Sponsors](https://github.com/juliangruber/sponsors)! | ||
| 104 | |||
| 105 | Do you want to support modules like this to improve their quality, stability and weigh in on new features? Then please consider donating to my [Patreon](https://www.patreon.com/juliangruber). Not sure how much of my modules you're using? Try [feross/thanks](https://github.com/feross/thanks)! | ||
| 106 | |||
| 107 | ## Security contact information | ||
| 108 | |||
| 109 | To report a security vulnerability, please use the | ||
| 110 | [Tidelift security contact](https://tidelift.com/security). | ||
| 111 | Tidelift will coordinate the fix and disclosure. | ||
| 112 | |||
| 113 | ## License | ||
| 114 | |||
| 115 | (MIT) | ||
| 116 | |||
| 117 | Copyright (c) 2013 Julian Gruber <julian@juliangruber.com> | ||
| 118 | |||
| 119 | Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
| 120 | this software and associated documentation files (the "Software"), to deal in | ||
| 121 | the Software without restriction, including without limitation the rights to | ||
| 122 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | ||
| 123 | of the Software, and to permit persons to whom the Software is furnished to do | ||
| 124 | so, subject to the following conditions: | ||
| 125 | |||
| 126 | The above copyright notice and this permission notice shall be included in all | ||
| 127 | copies or substantial portions of the Software. | ||
| 128 | |||
| 129 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 130 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 131 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 132 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 133 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 134 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| 135 | SOFTWARE. |
| 1 | var balanced = require('balanced-match'); | ||
| 2 | |||
| 3 | module.exports = expandTop; | ||
| 4 | |||
| 5 | var escSlash = '\0SLASH'+Math.random()+'\0'; | ||
| 6 | var escOpen = '\0OPEN'+Math.random()+'\0'; | ||
| 7 | var escClose = '\0CLOSE'+Math.random()+'\0'; | ||
| 8 | var escComma = '\0COMMA'+Math.random()+'\0'; | ||
| 9 | var escPeriod = '\0PERIOD'+Math.random()+'\0'; | ||
| 10 | |||
| 11 | function numeric(str) { | ||
| 12 | return parseInt(str, 10) == str | ||
| 13 | ? parseInt(str, 10) | ||
| 14 | : str.charCodeAt(0); | ||
| 15 | } | ||
| 16 | |||
| 17 | function escapeBraces(str) { | ||
| 18 | return str.split('\\\\').join(escSlash) | ||
| 19 | .split('\\{').join(escOpen) | ||
| 20 | .split('\\}').join(escClose) | ||
| 21 | .split('\\,').join(escComma) | ||
| 22 | .split('\\.').join(escPeriod); | ||
| 23 | } | ||
| 24 | |||
| 25 | function unescapeBraces(str) { | ||
| 26 | return str.split(escSlash).join('\\') | ||
| 27 | .split(escOpen).join('{') | ||
| 28 | .split(escClose).join('}') | ||
| 29 | .split(escComma).join(',') | ||
| 30 | .split(escPeriod).join('.'); | ||
| 31 | } | ||
| 32 | |||
| 33 | |||
| 34 | // Basically just str.split(","), but handling cases | ||
| 35 | // where we have nested braced sections, which should be | ||
| 36 | // treated as individual members, like {a,{b,c},d} | ||
| 37 | function parseCommaParts(str) { | ||
| 38 | if (!str) | ||
| 39 | return ['']; | ||
| 40 | |||
| 41 | var parts = []; | ||
| 42 | var m = balanced('{', '}', str); | ||
| 43 | |||
| 44 | if (!m) | ||
| 45 | return str.split(','); | ||
| 46 | |||
| 47 | var pre = m.pre; | ||
| 48 | var body = m.body; | ||
| 49 | var post = m.post; | ||
| 50 | var p = pre.split(','); | ||
| 51 | |||
| 52 | p[p.length-1] += '{' + body + '}'; | ||
| 53 | var postParts = parseCommaParts(post); | ||
| 54 | if (post.length) { | ||
| 55 | p[p.length-1] += postParts.shift(); | ||
| 56 | p.push.apply(p, postParts); | ||
| 57 | } | ||
| 58 | |||
| 59 | parts.push.apply(parts, p); | ||
| 60 | |||
| 61 | return parts; | ||
| 62 | } | ||
| 63 | |||
| 64 | function expandTop(str) { | ||
| 65 | if (!str) | ||
| 66 | return []; | ||
| 67 | |||
| 68 | // I don't know why Bash 4.3 does this, but it does. | ||
| 69 | // Anything starting with {} will have the first two bytes preserved | ||
| 70 | // but *only* at the top level, so {},a}b will not expand to anything, | ||
| 71 | // but a{},b}c will be expanded to [a}c,abc]. | ||
| 72 | // One could argue that this is a bug in Bash, but since the goal of | ||
| 73 | // this module is to match Bash's rules, we escape a leading {} | ||
| 74 | if (str.substr(0, 2) === '{}') { | ||
| 75 | str = '\\{\\}' + str.substr(2); | ||
| 76 | } | ||
| 77 | |||
| 78 | return expand(escapeBraces(str), true).map(unescapeBraces); | ||
| 79 | } | ||
| 80 | |||
| 81 | function embrace(str) { | ||
| 82 | return '{' + str + '}'; | ||
| 83 | } | ||
| 84 | function isPadded(el) { | ||
| 85 | return /^-?0\d/.test(el); | ||
| 86 | } | ||
| 87 | |||
| 88 | function lte(i, y) { | ||
| 89 | return i <= y; | ||
| 90 | } | ||
| 91 | function gte(i, y) { | ||
| 92 | return i >= y; | ||
| 93 | } | ||
| 94 | |||
| 95 | function expand(str, isTop) { | ||
| 96 | var expansions = []; | ||
| 97 | |||
| 98 | var m = balanced('{', '}', str); | ||
| 99 | if (!m) return [str]; | ||
| 100 | |||
| 101 | // no need to expand pre, since it is guaranteed to be free of brace-sets | ||
| 102 | var pre = m.pre; | ||
| 103 | var post = m.post.length | ||
| 104 | ? expand(m.post, false) | ||
| 105 | : ['']; | ||
| 106 | |||
| 107 | if (/\$$/.test(m.pre)) { | ||
| 108 | for (var k = 0; k < post.length; k++) { | ||
| 109 | var expansion = pre+ '{' + m.body + '}' + post[k]; | ||
| 110 | expansions.push(expansion); | ||
| 111 | } | ||
| 112 | } else { | ||
| 113 | var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body); | ||
| 114 | var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body); | ||
| 115 | var isSequence = isNumericSequence || isAlphaSequence; | ||
| 116 | var isOptions = m.body.indexOf(',') >= 0; | ||
| 117 | if (!isSequence && !isOptions) { | ||
| 118 | // {a},b} | ||
| 119 | if (m.post.match(/,.*\}/)) { | ||
| 120 | str = m.pre + '{' + m.body + escClose + m.post; | ||
| 121 | return expand(str); | ||
| 122 | } | ||
| 123 | return [str]; | ||
| 124 | } | ||
| 125 | |||
| 126 | var n; | ||
| 127 | if (isSequence) { | ||
| 128 | n = m.body.split(/\.\./); | ||
| 129 | } else { | ||
| 130 | n = parseCommaParts(m.body); | ||
| 131 | if (n.length === 1) { | ||
| 132 | // x{{a,b}}y ==> x{a}y x{b}y | ||
| 133 | n = expand(n[0], false).map(embrace); | ||
| 134 | if (n.length === 1) { | ||
| 135 | return post.map(function(p) { | ||
| 136 | return m.pre + n[0] + p; | ||
| 137 | }); | ||
| 138 | } | ||
| 139 | } | ||
| 140 | } | ||
| 141 | |||
| 142 | // at this point, n is the parts, and we know it's not a comma set | ||
| 143 | // with a single entry. | ||
| 144 | var N; | ||
| 145 | |||
| 146 | if (isSequence) { | ||
| 147 | var x = numeric(n[0]); | ||
| 148 | var y = numeric(n[1]); | ||
| 149 | var width = Math.max(n[0].length, n[1].length) | ||
| 150 | var incr = n.length == 3 | ||
| 151 | ? Math.abs(numeric(n[2])) | ||
| 152 | : 1; | ||
| 153 | var test = lte; | ||
| 154 | var reverse = y < x; | ||
| 155 | if (reverse) { | ||
| 156 | incr *= -1; | ||
| 157 | test = gte; | ||
| 158 | } | ||
| 159 | var pad = n.some(isPadded); | ||
| 160 | |||
| 161 | N = []; | ||
| 162 | |||
| 163 | for (var i = x; test(i, y); i += incr) { | ||
| 164 | var c; | ||
| 165 | if (isAlphaSequence) { | ||
| 166 | c = String.fromCharCode(i); | ||
| 167 | if (c === '\\') | ||
| 168 | c = ''; | ||
| 169 | } else { | ||
| 170 | c = String(i); | ||
| 171 | if (pad) { | ||
| 172 | var need = width - c.length; | ||
| 173 | if (need > 0) { | ||
| 174 | var z = new Array(need + 1).join('0'); | ||
| 175 | if (i < 0) | ||
| 176 | c = '-' + z + c.slice(1); | ||
| 177 | else | ||
| 178 | c = z + c; | ||
| 179 | } | ||
| 180 | } | ||
| 181 | } | ||
| 182 | N.push(c); | ||
| 183 | } | ||
| 184 | } else { | ||
| 185 | N = []; | ||
| 186 | |||
| 187 | for (var j = 0; j < n.length; j++) { | ||
| 188 | N.push.apply(N, expand(n[j], false)); | ||
| 189 | } | ||
| 190 | } | ||
| 191 | |||
| 192 | for (var j = 0; j < N.length; j++) { | ||
| 193 | for (var k = 0; k < post.length; k++) { | ||
| 194 | var expansion = pre + N[j] + post[k]; | ||
| 195 | if (!isTop || isSequence || expansion) | ||
| 196 | expansions.push(expansion); | ||
| 197 | } | ||
| 198 | } | ||
| 199 | } | ||
| 200 | |||
| 201 | return expansions; | ||
| 202 | } | ||
| 203 |
| 1 | { | ||
| 2 | "_from": "brace-expansion@^2.0.1", | ||
| 3 | "_id": "brace-expansion@2.0.1", | ||
| 4 | "_inBundle": false, | ||
| 5 | "_integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", | ||
| 6 | "_location": "/vue-qr/brace-expansion", | ||
| 7 | "_phantomChildren": {}, | ||
| 8 | "_requested": { | ||
| 9 | "type": "range", | ||
| 10 | "registry": true, | ||
| 11 | "raw": "brace-expansion@^2.0.1", | ||
| 12 | "name": "brace-expansion", | ||
| 13 | "escapedName": "brace-expansion", | ||
| 14 | "rawSpec": "^2.0.1", | ||
| 15 | "saveSpec": null, | ||
| 16 | "fetchSpec": "^2.0.1" | ||
| 17 | }, | ||
| 18 | "_requiredBy": [ | ||
| 19 | "/vue-qr/minimatch" | ||
| 20 | ], | ||
| 21 | "_resolved": "https://registry.npmmirror.com/brace-expansion/-/brace-expansion-2.0.1.tgz", | ||
| 22 | "_shasum": "1edc459e0f0c548486ecf9fc99f2221364b9a0ae", | ||
| 23 | "_spec": "brace-expansion@^2.0.1", | ||
| 24 | "_where": "/Users/zhanghao/brcode/br-client/node_modules/vue-qr/node_modules/minimatch", | ||
| 25 | "author": { | ||
| 26 | "name": "Julian Gruber", | ||
| 27 | "email": "mail@juliangruber.com", | ||
| 28 | "url": "http://juliangruber.com" | ||
| 29 | }, | ||
| 30 | "bugs": { | ||
| 31 | "url": "https://github.com/juliangruber/brace-expansion/issues" | ||
| 32 | }, | ||
| 33 | "bundleDependencies": false, | ||
| 34 | "dependencies": { | ||
| 35 | "balanced-match": "^1.0.0" | ||
| 36 | }, | ||
| 37 | "deprecated": false, | ||
| 38 | "description": "Brace expansion as known from sh/bash", | ||
| 39 | "devDependencies": { | ||
| 40 | "@c4312/matcha": "^1.3.1", | ||
| 41 | "tape": "^4.6.0" | ||
| 42 | }, | ||
| 43 | "homepage": "https://github.com/juliangruber/brace-expansion", | ||
| 44 | "keywords": [], | ||
| 45 | "license": "MIT", | ||
| 46 | "main": "index.js", | ||
| 47 | "name": "brace-expansion", | ||
| 48 | "repository": { | ||
| 49 | "type": "git", | ||
| 50 | "url": "git://github.com/juliangruber/brace-expansion.git" | ||
| 51 | }, | ||
| 52 | "scripts": { | ||
| 53 | "bench": "matcha test/perf/bench.js", | ||
| 54 | "gentest": "bash test/generate.sh", | ||
| 55 | "test": "tape test/*.js" | ||
| 56 | }, | ||
| 57 | "testling": { | ||
| 58 | "files": "test/*.js", | ||
| 59 | "browsers": [ | ||
| 60 | "ie/8..latest", | ||
| 61 | "firefox/20..latest", | ||
| 62 | "firefox/nightly", | ||
| 63 | "chrome/25..latest", | ||
| 64 | "chrome/canary", | ||
| 65 | "opera/12..latest", | ||
| 66 | "opera/next", | ||
| 67 | "safari/5.1..latest", | ||
| 68 | "ipad/6.0..latest", | ||
| 69 | "iphone/6.0..latest", | ||
| 70 | "android-browser/4.2..latest" | ||
| 71 | ] | ||
| 72 | }, | ||
| 73 | "version": "2.0.1" | ||
| 74 | } |
| 1 | The ISC License | ||
| 2 | |||
| 3 | Copyright (c) 2009-2022 Isaac Z. Schlueter and Contributors | ||
| 4 | |||
| 5 | Permission to use, copy, modify, and/or distribute this software for any | ||
| 6 | purpose with or without fee is hereby granted, provided that the above | ||
| 7 | copyright notice and this permission notice appear in all copies. | ||
| 8 | |||
| 9 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
| 10 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
| 11 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
| 12 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
| 13 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
| 14 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR | ||
| 15 | IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
This diff is collapsed.
Click to expand it.
| 1 | exports.setopts = setopts | ||
| 2 | exports.ownProp = ownProp | ||
| 3 | exports.makeAbs = makeAbs | ||
| 4 | exports.finish = finish | ||
| 5 | exports.mark = mark | ||
| 6 | exports.isIgnored = isIgnored | ||
| 7 | exports.childrenIgnored = childrenIgnored | ||
| 8 | |||
| 9 | function ownProp (obj, field) { | ||
| 10 | return Object.prototype.hasOwnProperty.call(obj, field) | ||
| 11 | } | ||
| 12 | |||
| 13 | var fs = require("fs") | ||
| 14 | var path = require("path") | ||
| 15 | var minimatch = require("minimatch") | ||
| 16 | var isAbsolute = require("path").isAbsolute | ||
| 17 | var Minimatch = minimatch.Minimatch | ||
| 18 | |||
| 19 | function alphasort (a, b) { | ||
| 20 | return a.localeCompare(b, 'en') | ||
| 21 | } | ||
| 22 | |||
| 23 | function setupIgnores (self, options) { | ||
| 24 | self.ignore = options.ignore || [] | ||
| 25 | |||
| 26 | if (!Array.isArray(self.ignore)) | ||
| 27 | self.ignore = [self.ignore] | ||
| 28 | |||
| 29 | if (self.ignore.length) { | ||
| 30 | self.ignore = self.ignore.map(ignoreMap) | ||
| 31 | } | ||
| 32 | } | ||
| 33 | |||
| 34 | // ignore patterns are always in dot:true mode. | ||
| 35 | function ignoreMap (pattern) { | ||
| 36 | var gmatcher = null | ||
| 37 | if (pattern.slice(-3) === '/**') { | ||
| 38 | var gpattern = pattern.replace(/(\/\*\*)+$/, '') | ||
| 39 | gmatcher = new Minimatch(gpattern, { dot: true }) | ||
| 40 | } | ||
| 41 | |||
| 42 | return { | ||
| 43 | matcher: new Minimatch(pattern, { dot: true }), | ||
| 44 | gmatcher: gmatcher | ||
| 45 | } | ||
| 46 | } | ||
| 47 | |||
| 48 | function setopts (self, pattern, options) { | ||
| 49 | if (!options) | ||
| 50 | options = {} | ||
| 51 | |||
| 52 | // base-matching: just use globstar for that. | ||
| 53 | if (options.matchBase && -1 === pattern.indexOf("/")) { | ||
| 54 | if (options.noglobstar) { | ||
| 55 | throw new Error("base matching requires globstar") | ||
| 56 | } | ||
| 57 | pattern = "**/" + pattern | ||
| 58 | } | ||
| 59 | |||
| 60 | self.silent = !!options.silent | ||
| 61 | self.pattern = pattern | ||
| 62 | self.strict = options.strict !== false | ||
| 63 | self.realpath = !!options.realpath | ||
| 64 | self.realpathCache = options.realpathCache || Object.create(null) | ||
| 65 | self.follow = !!options.follow | ||
| 66 | self.dot = !!options.dot | ||
| 67 | self.mark = !!options.mark | ||
| 68 | self.nodir = !!options.nodir | ||
| 69 | if (self.nodir) | ||
| 70 | self.mark = true | ||
| 71 | self.sync = !!options.sync | ||
| 72 | self.nounique = !!options.nounique | ||
| 73 | self.nonull = !!options.nonull | ||
| 74 | self.nosort = !!options.nosort | ||
| 75 | self.nocase = !!options.nocase | ||
| 76 | self.stat = !!options.stat | ||
| 77 | self.noprocess = !!options.noprocess | ||
| 78 | self.absolute = !!options.absolute | ||
| 79 | self.fs = options.fs || fs | ||
| 80 | |||
| 81 | self.maxLength = options.maxLength || Infinity | ||
| 82 | self.cache = options.cache || Object.create(null) | ||
| 83 | self.statCache = options.statCache || Object.create(null) | ||
| 84 | self.symlinks = options.symlinks || Object.create(null) | ||
| 85 | |||
| 86 | setupIgnores(self, options) | ||
| 87 | |||
| 88 | self.changedCwd = false | ||
| 89 | var cwd = process.cwd() | ||
| 90 | if (!ownProp(options, "cwd")) | ||
| 91 | self.cwd = path.resolve(cwd) | ||
| 92 | else { | ||
| 93 | self.cwd = path.resolve(options.cwd) | ||
| 94 | self.changedCwd = self.cwd !== cwd | ||
| 95 | } | ||
| 96 | |||
| 97 | self.root = options.root || path.resolve(self.cwd, "/") | ||
| 98 | self.root = path.resolve(self.root) | ||
| 99 | |||
| 100 | // TODO: is an absolute `cwd` supposed to be resolved against `root`? | ||
| 101 | // e.g. { cwd: '/test', root: __dirname } === path.join(__dirname, '/test') | ||
| 102 | self.cwdAbs = isAbsolute(self.cwd) ? self.cwd : makeAbs(self, self.cwd) | ||
| 103 | self.nomount = !!options.nomount | ||
| 104 | |||
| 105 | if (process.platform === "win32") { | ||
| 106 | self.root = self.root.replace(/\\/g, "/") | ||
| 107 | self.cwd = self.cwd.replace(/\\/g, "/") | ||
| 108 | self.cwdAbs = self.cwdAbs.replace(/\\/g, "/") | ||
| 109 | } | ||
| 110 | |||
| 111 | // disable comments and negation in Minimatch. | ||
| 112 | // Note that they are not supported in Glob itself anyway. | ||
| 113 | options.nonegate = true | ||
| 114 | options.nocomment = true | ||
| 115 | // always treat \ in patterns as escapes, not path separators | ||
| 116 | options.allowWindowsEscape = true | ||
| 117 | |||
| 118 | self.minimatch = new Minimatch(pattern, options) | ||
| 119 | self.options = self.minimatch.options | ||
| 120 | } | ||
| 121 | |||
| 122 | function finish (self) { | ||
| 123 | var nou = self.nounique | ||
| 124 | var all = nou ? [] : Object.create(null) | ||
| 125 | |||
| 126 | for (var i = 0, l = self.matches.length; i < l; i ++) { | ||
| 127 | var matches = self.matches[i] | ||
| 128 | if (!matches || Object.keys(matches).length === 0) { | ||
| 129 | if (self.nonull) { | ||
| 130 | // do like the shell, and spit out the literal glob | ||
| 131 | var literal = self.minimatch.globSet[i] | ||
| 132 | if (nou) | ||
| 133 | all.push(literal) | ||
| 134 | else | ||
| 135 | all[literal] = true | ||
| 136 | } | ||
| 137 | } else { | ||
| 138 | // had matches | ||
| 139 | var m = Object.keys(matches) | ||
| 140 | if (nou) | ||
| 141 | all.push.apply(all, m) | ||
| 142 | else | ||
| 143 | m.forEach(function (m) { | ||
| 144 | all[m] = true | ||
| 145 | }) | ||
| 146 | } | ||
| 147 | } | ||
| 148 | |||
| 149 | if (!nou) | ||
| 150 | all = Object.keys(all) | ||
| 151 | |||
| 152 | if (!self.nosort) | ||
| 153 | all = all.sort(alphasort) | ||
| 154 | |||
| 155 | // at *some* point we statted all of these | ||
| 156 | if (self.mark) { | ||
| 157 | for (var i = 0; i < all.length; i++) { | ||
| 158 | all[i] = self._mark(all[i]) | ||
| 159 | } | ||
| 160 | if (self.nodir) { | ||
| 161 | all = all.filter(function (e) { | ||
| 162 | var notDir = !(/\/$/.test(e)) | ||
| 163 | var c = self.cache[e] || self.cache[makeAbs(self, e)] | ||
| 164 | if (notDir && c) | ||
| 165 | notDir = c !== 'DIR' && !Array.isArray(c) | ||
| 166 | return notDir | ||
| 167 | }) | ||
| 168 | } | ||
| 169 | } | ||
| 170 | |||
| 171 | if (self.ignore.length) | ||
| 172 | all = all.filter(function(m) { | ||
| 173 | return !isIgnored(self, m) | ||
| 174 | }) | ||
| 175 | |||
| 176 | self.found = all | ||
| 177 | } | ||
| 178 | |||
| 179 | function mark (self, p) { | ||
| 180 | var abs = makeAbs(self, p) | ||
| 181 | var c = self.cache[abs] | ||
| 182 | var m = p | ||
| 183 | if (c) { | ||
| 184 | var isDir = c === 'DIR' || Array.isArray(c) | ||
| 185 | var slash = p.slice(-1) === '/' | ||
| 186 | |||
| 187 | if (isDir && !slash) | ||
| 188 | m += '/' | ||
| 189 | else if (!isDir && slash) | ||
| 190 | m = m.slice(0, -1) | ||
| 191 | |||
| 192 | if (m !== p) { | ||
| 193 | var mabs = makeAbs(self, m) | ||
| 194 | self.statCache[mabs] = self.statCache[abs] | ||
| 195 | self.cache[mabs] = self.cache[abs] | ||
| 196 | } | ||
| 197 | } | ||
| 198 | |||
| 199 | return m | ||
| 200 | } | ||
| 201 | |||
| 202 | // lotta situps... | ||
| 203 | function makeAbs (self, f) { | ||
| 204 | var abs = f | ||
| 205 | if (f.charAt(0) === '/') { | ||
| 206 | abs = path.join(self.root, f) | ||
| 207 | } else if (isAbsolute(f) || f === '') { | ||
| 208 | abs = f | ||
| 209 | } else if (self.changedCwd) { | ||
| 210 | abs = path.resolve(self.cwd, f) | ||
| 211 | } else { | ||
| 212 | abs = path.resolve(f) | ||
| 213 | } | ||
| 214 | |||
| 215 | if (process.platform === 'win32') | ||
| 216 | abs = abs.replace(/\\/g, '/') | ||
| 217 | |||
| 218 | return abs | ||
| 219 | } | ||
| 220 | |||
| 221 | |||
| 222 | // Return true, if pattern ends with globstar '**', for the accompanying parent directory. | ||
| 223 | // Ex:- If node_modules/** is the pattern, add 'node_modules' to ignore list along with it's contents | ||
| 224 | function isIgnored (self, path) { | ||
| 225 | if (!self.ignore.length) | ||
| 226 | return false | ||
| 227 | |||
| 228 | return self.ignore.some(function(item) { | ||
| 229 | return item.matcher.match(path) || !!(item.gmatcher && item.gmatcher.match(path)) | ||
| 230 | }) | ||
| 231 | } | ||
| 232 | |||
| 233 | function childrenIgnored (self, path) { | ||
| 234 | if (!self.ignore.length) | ||
| 235 | return false | ||
| 236 | |||
| 237 | return self.ignore.some(function(item) { | ||
| 238 | return !!(item.gmatcher && item.gmatcher.match(path)) | ||
| 239 | }) | ||
| 240 | } |
This diff is collapsed.
Click to expand it.
| 1 | { | ||
| 2 | "_from": "glob@^8.0.1", | ||
| 3 | "_id": "glob@8.0.3", | ||
| 4 | "_inBundle": false, | ||
| 5 | "_integrity": "sha512-ull455NHSHI/Y1FqGaaYFaLGkNMMJbavMrEGFXG/PGrg6y7sutWHUHrz6gy6WEBH6akM1M414dWKCNs+IhKdiQ==", | ||
| 6 | "_location": "/vue-qr/glob", | ||
| 7 | "_phantomChildren": {}, | ||
| 8 | "_requested": { | ||
| 9 | "type": "range", | ||
| 10 | "registry": true, | ||
| 11 | "raw": "glob@^8.0.1", | ||
| 12 | "name": "glob", | ||
| 13 | "escapedName": "glob", | ||
| 14 | "rawSpec": "^8.0.1", | ||
| 15 | "saveSpec": null, | ||
| 16 | "fetchSpec": "^8.0.1" | ||
| 17 | }, | ||
| 18 | "_requiredBy": [ | ||
| 19 | "/vue-qr" | ||
| 20 | ], | ||
| 21 | "_resolved": "https://registry.npmmirror.com/glob/-/glob-8.0.3.tgz", | ||
| 22 | "_shasum": "415c6eb2deed9e502c68fa44a272e6da6eeca42e", | ||
| 23 | "_spec": "glob@^8.0.1", | ||
| 24 | "_where": "/Users/zhanghao/brcode/br-client/node_modules/vue-qr", | ||
| 25 | "author": { | ||
| 26 | "name": "Isaac Z. Schlueter", | ||
| 27 | "email": "i@izs.me", | ||
| 28 | "url": "http://blog.izs.me/" | ||
| 29 | }, | ||
| 30 | "bugs": { | ||
| 31 | "url": "https://github.com/isaacs/node-glob/issues" | ||
| 32 | }, | ||
| 33 | "bundleDependencies": false, | ||
| 34 | "dependencies": { | ||
| 35 | "fs.realpath": "^1.0.0", | ||
| 36 | "inflight": "^1.0.4", | ||
| 37 | "inherits": "2", | ||
| 38 | "minimatch": "^5.0.1", | ||
| 39 | "once": "^1.3.0" | ||
| 40 | }, | ||
| 41 | "deprecated": false, | ||
| 42 | "description": "a little globber", | ||
| 43 | "devDependencies": { | ||
| 44 | "memfs": "^3.2.0", | ||
| 45 | "mkdirp": "0", | ||
| 46 | "rimraf": "^2.2.8", | ||
| 47 | "tap": "^16.0.1", | ||
| 48 | "tick": "0.0.6" | ||
| 49 | }, | ||
| 50 | "engines": { | ||
| 51 | "node": ">=12" | ||
| 52 | }, | ||
| 53 | "files": [ | ||
| 54 | "glob.js", | ||
| 55 | "sync.js", | ||
| 56 | "common.js" | ||
| 57 | ], | ||
| 58 | "funding": { | ||
| 59 | "url": "https://github.com/sponsors/isaacs" | ||
| 60 | }, | ||
| 61 | "homepage": "https://github.com/isaacs/node-glob#readme", | ||
| 62 | "license": "ISC", | ||
| 63 | "main": "glob.js", | ||
| 64 | "name": "glob", | ||
| 65 | "repository": { | ||
| 66 | "type": "git", | ||
| 67 | "url": "git://github.com/isaacs/node-glob.git" | ||
| 68 | }, | ||
| 69 | "scripts": { | ||
| 70 | "bench": "bash benchmark.sh", | ||
| 71 | "benchclean": "node benchclean.js", | ||
| 72 | "prepublish": "npm run benchclean", | ||
| 73 | "prof": "bash prof.sh && cat profile.txt", | ||
| 74 | "profclean": "rm -f v8.log profile.txt", | ||
| 75 | "test": "tap", | ||
| 76 | "test-regen": "npm run profclean && TEST_REGEN=1 node test/00-setup.js" | ||
| 77 | }, | ||
| 78 | "tap": { | ||
| 79 | "before": "test/00-setup.js", | ||
| 80 | "after": "test/zz-cleanup.js", | ||
| 81 | "statements": 90, | ||
| 82 | "branches": 90, | ||
| 83 | "functions": 90, | ||
| 84 | "lines": 90, | ||
| 85 | "jobs": 1 | ||
| 86 | }, | ||
| 87 | "version": "8.0.3" | ||
| 88 | } |
This diff is collapsed.
Click to expand it.
| 1 | The ISC License | ||
| 2 | |||
| 3 | Copyright (c) 2011-2022 Isaac Z. Schlueter and Contributors | ||
| 4 | |||
| 5 | Permission to use, copy, modify, and/or distribute this software for any | ||
| 6 | purpose with or without fee is hereby granted, provided that the above | ||
| 7 | copyright notice and this permission notice appear in all copies. | ||
| 8 | |||
| 9 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
| 10 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
| 11 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
| 12 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
| 13 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
| 14 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR | ||
| 15 | IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 1 | # minimatch | ||
| 2 | |||
| 3 | A minimal matching utility. | ||
| 4 | |||
| 5 | [](http://travis-ci.org/isaacs/minimatch) | ||
| 6 | |||
| 7 | |||
| 8 | This is the matching library used internally by npm. | ||
| 9 | |||
| 10 | It works by converting glob expressions into JavaScript `RegExp` | ||
| 11 | objects. | ||
| 12 | |||
| 13 | ## Usage | ||
| 14 | |||
| 15 | ```javascript | ||
| 16 | var minimatch = require("minimatch") | ||
| 17 | |||
| 18 | minimatch("bar.foo", "*.foo") // true! | ||
| 19 | minimatch("bar.foo", "*.bar") // false! | ||
| 20 | minimatch("bar.foo", "*.+(bar|foo)", { debug: true }) // true, and noisy! | ||
| 21 | ``` | ||
| 22 | |||
| 23 | ## Features | ||
| 24 | |||
| 25 | Supports these glob features: | ||
| 26 | |||
| 27 | * Brace Expansion | ||
| 28 | * Extended glob matching | ||
| 29 | * "Globstar" `**` matching | ||
| 30 | |||
| 31 | See: | ||
| 32 | |||
| 33 | * `man sh` | ||
| 34 | * `man bash` | ||
| 35 | * `man 3 fnmatch` | ||
| 36 | * `man 5 gitignore` | ||
| 37 | |||
| 38 | ## Windows | ||
| 39 | |||
| 40 | **Please only use forward-slashes in glob expressions.** | ||
| 41 | |||
| 42 | Though windows uses either `/` or `\` as its path separator, only `/` | ||
| 43 | characters are used by this glob implementation. You must use | ||
| 44 | forward-slashes **only** in glob expressions. Back-slashes in patterns | ||
| 45 | will always be interpreted as escape characters, not path separators. | ||
| 46 | |||
| 47 | Note that `\` or `/` _will_ be interpreted as path separators in paths on | ||
| 48 | Windows, and will match against `/` in glob expressions. | ||
| 49 | |||
| 50 | So just always use `/` in patterns. | ||
| 51 | |||
| 52 | ## Minimatch Class | ||
| 53 | |||
| 54 | Create a minimatch object by instantiating the `minimatch.Minimatch` class. | ||
| 55 | |||
| 56 | ```javascript | ||
| 57 | var Minimatch = require("minimatch").Minimatch | ||
| 58 | var mm = new Minimatch(pattern, options) | ||
| 59 | ``` | ||
| 60 | |||
| 61 | ### Properties | ||
| 62 | |||
| 63 | * `pattern` The original pattern the minimatch object represents. | ||
| 64 | * `options` The options supplied to the constructor. | ||
| 65 | * `set` A 2-dimensional array of regexp or string expressions. | ||
| 66 | Each row in the | ||
| 67 | array corresponds to a brace-expanded pattern. Each item in the row | ||
| 68 | corresponds to a single path-part. For example, the pattern | ||
| 69 | `{a,b/c}/d` would expand to a set of patterns like: | ||
| 70 | |||
| 71 | [ [ a, d ] | ||
| 72 | , [ b, c, d ] ] | ||
| 73 | |||
| 74 | If a portion of the pattern doesn't have any "magic" in it | ||
| 75 | (that is, it's something like `"foo"` rather than `fo*o?`), then it | ||
| 76 | will be left as a string rather than converted to a regular | ||
| 77 | expression. | ||
| 78 | |||
| 79 | * `regexp` Created by the `makeRe` method. A single regular expression | ||
| 80 | expressing the entire pattern. This is useful in cases where you wish | ||
| 81 | to use the pattern somewhat like `fnmatch(3)` with `FNM_PATH` enabled. | ||
| 82 | * `negate` True if the pattern is negated. | ||
| 83 | * `comment` True if the pattern is a comment. | ||
| 84 | * `empty` True if the pattern is `""`. | ||
| 85 | |||
| 86 | ### Methods | ||
| 87 | |||
| 88 | * `makeRe` Generate the `regexp` member if necessary, and return it. | ||
| 89 | Will return `false` if the pattern is invalid. | ||
| 90 | * `match(fname)` Return true if the filename matches the pattern, or | ||
| 91 | false otherwise. | ||
| 92 | * `matchOne(fileArray, patternArray, partial)` Take a `/`-split | ||
| 93 | filename, and match it against a single row in the `regExpSet`. This | ||
| 94 | method is mainly for internal use, but is exposed so that it can be | ||
| 95 | used by a glob-walker that needs to avoid excessive filesystem calls. | ||
| 96 | |||
| 97 | All other methods are internal, and will be called as necessary. | ||
| 98 | |||
| 99 | ### minimatch(path, pattern, options) | ||
| 100 | |||
| 101 | Main export. Tests a path against the pattern using the options. | ||
| 102 | |||
| 103 | ```javascript | ||
| 104 | var isJS = minimatch(file, "*.js", { matchBase: true }) | ||
| 105 | ``` | ||
| 106 | |||
| 107 | ### minimatch.filter(pattern, options) | ||
| 108 | |||
| 109 | Returns a function that tests its | ||
| 110 | supplied argument, suitable for use with `Array.filter`. Example: | ||
| 111 | |||
| 112 | ```javascript | ||
| 113 | var javascripts = fileList.filter(minimatch.filter("*.js", {matchBase: true})) | ||
| 114 | ``` | ||
| 115 | |||
| 116 | ### minimatch.match(list, pattern, options) | ||
| 117 | |||
| 118 | Match against the list of | ||
| 119 | files, in the style of fnmatch or glob. If nothing is matched, and | ||
| 120 | options.nonull is set, then return a list containing the pattern itself. | ||
| 121 | |||
| 122 | ```javascript | ||
| 123 | var javascripts = minimatch.match(fileList, "*.js", {matchBase: true}) | ||
| 124 | ``` | ||
| 125 | |||
| 126 | ### minimatch.makeRe(pattern, options) | ||
| 127 | |||
| 128 | Make a regular expression object from the pattern. | ||
| 129 | |||
| 130 | ## Options | ||
| 131 | |||
| 132 | All options are `false` by default. | ||
| 133 | |||
| 134 | ### debug | ||
| 135 | |||
| 136 | Dump a ton of stuff to stderr. | ||
| 137 | |||
| 138 | ### nobrace | ||
| 139 | |||
| 140 | Do not expand `{a,b}` and `{1..3}` brace sets. | ||
| 141 | |||
| 142 | ### noglobstar | ||
| 143 | |||
| 144 | Disable `**` matching against multiple folder names. | ||
| 145 | |||
| 146 | ### dot | ||
| 147 | |||
| 148 | Allow patterns to match filenames starting with a period, even if | ||
| 149 | the pattern does not explicitly have a period in that spot. | ||
| 150 | |||
| 151 | Note that by default, `a/**/b` will **not** match `a/.d/b`, unless `dot` | ||
| 152 | is set. | ||
| 153 | |||
| 154 | ### noext | ||
| 155 | |||
| 156 | Disable "extglob" style patterns like `+(a|b)`. | ||
| 157 | |||
| 158 | ### nocase | ||
| 159 | |||
| 160 | Perform a case-insensitive match. | ||
| 161 | |||
| 162 | ### nonull | ||
| 163 | |||
| 164 | When a match is not found by `minimatch.match`, return a list containing | ||
| 165 | the pattern itself if this option is set. When not set, an empty list | ||
| 166 | is returned if there are no matches. | ||
| 167 | |||
| 168 | ### matchBase | ||
| 169 | |||
| 170 | If set, then patterns without slashes will be matched | ||
| 171 | against the basename of the path if it contains slashes. For example, | ||
| 172 | `a?b` would match the path `/xyz/123/acb`, but not `/xyz/acb/123`. | ||
| 173 | |||
| 174 | ### nocomment | ||
| 175 | |||
| 176 | Suppress the behavior of treating `#` at the start of a pattern as a | ||
| 177 | comment. | ||
| 178 | |||
| 179 | ### nonegate | ||
| 180 | |||
| 181 | Suppress the behavior of treating a leading `!` character as negation. | ||
| 182 | |||
| 183 | ### flipNegate | ||
| 184 | |||
| 185 | Returns from negate expressions the same as if they were not negated. | ||
| 186 | (Ie, true on a hit, false on a miss.) | ||
| 187 | |||
| 188 | ### partial | ||
| 189 | |||
| 190 | Compare a partial path to a pattern. As long as the parts of the path that | ||
| 191 | are present are not contradicted by the pattern, it will be treated as a | ||
| 192 | match. This is useful in applications where you're walking through a | ||
| 193 | folder structure, and don't yet have the full path, but want to ensure that | ||
| 194 | you do not walk down paths that can never be a match. | ||
| 195 | |||
| 196 | For example, | ||
| 197 | |||
| 198 | ```js | ||
| 199 | minimatch('/a/b', '/a/*/c/d', { partial: true }) // true, might be /a/b/c/d | ||
| 200 | minimatch('/a/b', '/**/d', { partial: true }) // true, might be /a/b/.../d | ||
| 201 | minimatch('/x/y/z', '/a/**/z', { partial: true }) // false, because x !== a | ||
| 202 | ``` | ||
| 203 | |||
| 204 | ### windowsPathsNoEscape | ||
| 205 | |||
| 206 | Use `\\` as a path separator _only_, and _never_ as an escape | ||
| 207 | character. If set, all `\\` characters are replaced with `/` in | ||
| 208 | the pattern. Note that this makes it **impossible** to match | ||
| 209 | against paths containing literal glob pattern characters, but | ||
| 210 | allows matching with patterns constructed using `path.join()` and | ||
| 211 | `path.resolve()` on Windows platforms, mimicking the (buggy!) | ||
| 212 | behavior of earlier versions on Windows. Please use with | ||
| 213 | caution, and be mindful of [the caveat about Windows | ||
| 214 | paths](#windows). | ||
| 215 | |||
| 216 | For legacy reasons, this is also set if | ||
| 217 | `options.allowWindowsEscape` is set to the exact value `false`. | ||
| 218 | |||
| 219 | ## Comparisons to other fnmatch/glob implementations | ||
| 220 | |||
| 221 | While strict compliance with the existing standards is a worthwhile | ||
| 222 | goal, some discrepancies exist between minimatch and other | ||
| 223 | implementations, and are intentional. | ||
| 224 | |||
| 225 | If the pattern starts with a `!` character, then it is negated. Set the | ||
| 226 | `nonegate` flag to suppress this behavior, and treat leading `!` | ||
| 227 | characters normally. This is perhaps relevant if you wish to start the | ||
| 228 | pattern with a negative extglob pattern like `!(a|B)`. Multiple `!` | ||
| 229 | characters at the start of a pattern will negate the pattern multiple | ||
| 230 | times. | ||
| 231 | |||
| 232 | If a pattern starts with `#`, then it is treated as a comment, and | ||
| 233 | will not match anything. Use `\#` to match a literal `#` at the | ||
| 234 | start of a line, or set the `nocomment` flag to suppress this behavior. | ||
| 235 | |||
| 236 | The double-star character `**` is supported by default, unless the | ||
| 237 | `noglobstar` flag is set. This is supported in the manner of bsdglob | ||
| 238 | and bash 4.1, where `**` only has special significance if it is the only | ||
| 239 | thing in a path part. That is, `a/**/b` will match `a/x/y/b`, but | ||
| 240 | `a/**b` will not. | ||
| 241 | |||
| 242 | If an escaped pattern has no matches, and the `nonull` flag is set, | ||
| 243 | then minimatch.match returns the pattern as-provided, rather than | ||
| 244 | interpreting the character escapes. For example, | ||
| 245 | `minimatch.match([], "\\*a\\?")` will return `"\\*a\\?"` rather than | ||
| 246 | `"*a?"`. This is akin to setting the `nullglob` option in bash, except | ||
| 247 | that it does not resolve escaped pattern characters. | ||
| 248 | |||
| 249 | If brace expansion is not disabled, then it is performed before any | ||
| 250 | other interpretation of the glob pattern. Thus, a pattern like | ||
| 251 | `+(a|{b),c)}`, which would not be valid in bash or zsh, is expanded | ||
| 252 | **first** into the set of `+(a|b)` and `+(a|c)`, and those patterns are | ||
| 253 | checked for validity. Since those two are valid, matching proceeds. | ||
| 254 | |||
| 255 | Note that `fnmatch(3)` in libc is an extremely naive string comparison | ||
| 256 | matcher, which does not do anything special for slashes. This library is | ||
| 257 | designed to be used in glob searching and file walkers, and so it does do | ||
| 258 | special things with `/`. Thus, `foo*` will not match `foo/bar` in this | ||
| 259 | library, even though it would in `fnmatch(3)`. |
This diff is collapsed.
Click to expand it.
| 1 | { | ||
| 2 | "_from": "minimatch@^5.0.1", | ||
| 3 | "_id": "minimatch@5.1.0", | ||
| 4 | "_inBundle": false, | ||
| 5 | "_integrity": "sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==", | ||
| 6 | "_location": "/vue-qr/minimatch", | ||
| 7 | "_phantomChildren": {}, | ||
| 8 | "_requested": { | ||
| 9 | "type": "range", | ||
| 10 | "registry": true, | ||
| 11 | "raw": "minimatch@^5.0.1", | ||
| 12 | "name": "minimatch", | ||
| 13 | "escapedName": "minimatch", | ||
| 14 | "rawSpec": "^5.0.1", | ||
| 15 | "saveSpec": null, | ||
| 16 | "fetchSpec": "^5.0.1" | ||
| 17 | }, | ||
| 18 | "_requiredBy": [ | ||
| 19 | "/vue-qr/glob" | ||
| 20 | ], | ||
| 21 | "_resolved": "https://registry.npmmirror.com/minimatch/-/minimatch-5.1.0.tgz", | ||
| 22 | "_shasum": "1717b464f4971b144f6aabe8f2d0b8e4511e09c7", | ||
| 23 | "_spec": "minimatch@^5.0.1", | ||
| 24 | "_where": "/Users/zhanghao/brcode/br-client/node_modules/vue-qr/node_modules/glob", | ||
| 25 | "author": { | ||
| 26 | "name": "Isaac Z. Schlueter", | ||
| 27 | "email": "i@izs.me", | ||
| 28 | "url": "http://blog.izs.me" | ||
| 29 | }, | ||
| 30 | "bugs": { | ||
| 31 | "url": "https://github.com/isaacs/minimatch/issues" | ||
| 32 | }, | ||
| 33 | "bundleDependencies": false, | ||
| 34 | "dependencies": { | ||
| 35 | "brace-expansion": "^2.0.1" | ||
| 36 | }, | ||
| 37 | "deprecated": false, | ||
| 38 | "description": "a glob matcher in javascript", | ||
| 39 | "devDependencies": { | ||
| 40 | "tap": "^15.1.6" | ||
| 41 | }, | ||
| 42 | "engines": { | ||
| 43 | "node": ">=10" | ||
| 44 | }, | ||
| 45 | "files": [ | ||
| 46 | "minimatch.js", | ||
| 47 | "lib" | ||
| 48 | ], | ||
| 49 | "homepage": "https://github.com/isaacs/minimatch#readme", | ||
| 50 | "license": "ISC", | ||
| 51 | "main": "minimatch.js", | ||
| 52 | "name": "minimatch", | ||
| 53 | "repository": { | ||
| 54 | "type": "git", | ||
| 55 | "url": "git://github.com/isaacs/minimatch.git" | ||
| 56 | }, | ||
| 57 | "scripts": { | ||
| 58 | "postversion": "npm publish", | ||
| 59 | "prepublishOnly": "git push origin --follow-tags", | ||
| 60 | "preversion": "npm test", | ||
| 61 | "snap": "tap", | ||
| 62 | "test": "tap" | ||
| 63 | }, | ||
| 64 | "version": "5.1.0" | ||
| 65 | } |
node_modules/vue-qr/package.json
0 → 100644
| 1 | { | ||
| 2 | "_from": "vue-qr", | ||
| 3 | "_id": "vue-qr@4.0.9", | ||
| 4 | "_inBundle": false, | ||
| 5 | "_integrity": "sha512-pAISV94T0MNEYA3NGjykUpsXRE2QfaNxlu9ZhEL6CERgqNc21hJYuP3hRVzAWfBQlgO18DPmZTbrFerJC3+Ikw==", | ||
| 6 | "_location": "/vue-qr", | ||
| 7 | "_phantomChildren": { | ||
| 8 | "balanced-match": "1.0.0", | ||
| 9 | "fs.realpath": "1.0.0", | ||
| 10 | "inflight": "1.0.6", | ||
| 11 | "inherits": "2.0.4", | ||
| 12 | "once": "1.4.0" | ||
| 13 | }, | ||
| 14 | "_requested": { | ||
| 15 | "type": "tag", | ||
| 16 | "registry": true, | ||
| 17 | "raw": "vue-qr", | ||
| 18 | "name": "vue-qr", | ||
| 19 | "escapedName": "vue-qr", | ||
| 20 | "rawSpec": "", | ||
| 21 | "saveSpec": null, | ||
| 22 | "fetchSpec": "latest" | ||
| 23 | }, | ||
| 24 | "_requiredBy": [ | ||
| 25 | "#USER", | ||
| 26 | "/" | ||
| 27 | ], | ||
| 28 | "_resolved": "https://registry.npmmirror.com/vue-qr/-/vue-qr-4.0.9.tgz", | ||
| 29 | "_shasum": "6cb965dd0c5a0dff947e6ef582ef149b0780b986", | ||
| 30 | "_spec": "vue-qr", | ||
| 31 | "_where": "/Users/zhanghao/brcode/br-client", | ||
| 32 | "author": { | ||
| 33 | "name": "Binaryify" | ||
| 34 | }, | ||
| 35 | "browserslist": [ | ||
| 36 | "> 1%", | ||
| 37 | "last 2 versions", | ||
| 38 | "not ie <= 8" | ||
| 39 | ], | ||
| 40 | "bugs": { | ||
| 41 | "url": "https://github.com/Binaryify/vue-qr/issues" | ||
| 42 | }, | ||
| 43 | "bundleDependencies": false, | ||
| 44 | "dependencies": { | ||
| 45 | "glob": "^8.0.1", | ||
| 46 | "js-binary-schema-parser": "^2.0.2", | ||
| 47 | "simple-get": "^4.0.1", | ||
| 48 | "string-split-by": "^1.0.0" | ||
| 49 | }, | ||
| 50 | "deprecated": false, | ||
| 51 | "description": "The Vue 2.x component of Awesome-qr.js", | ||
| 52 | "devDependencies": { | ||
| 53 | "@babel/cli": "^7.11.6", | ||
| 54 | "@babel/core": "^7.11.6", | ||
| 55 | "@babel/plugin-proposal-class-properties": "^7.16.7", | ||
| 56 | "@babel/plugin-transform-runtime": "^7.11.5", | ||
| 57 | "@babel/preset-env": "^7.11.5", | ||
| 58 | "@babel/preset-stage-0": "^7.8.3", | ||
| 59 | "babel-loader": "^8.1.0", | ||
| 60 | "babel-plugin-lodash": "^3.3.4", | ||
| 61 | "cross-env": "^7.0.2", | ||
| 62 | "css-loader": "^4.3.0", | ||
| 63 | "file-loader": "^6.1.0", | ||
| 64 | "uuid": "^8.3.1", | ||
| 65 | "vue": "^2.6.12", | ||
| 66 | "vue-loader": "^15.9.3", | ||
| 67 | "vue-template-compiler": "^2.6.12", | ||
| 68 | "webpack": "^4.44.2", | ||
| 69 | "webpack-cli": "^3.3.12", | ||
| 70 | "webpack-dev-server": "^3.11.0" | ||
| 71 | }, | ||
| 72 | "homepage": "https://github.com/Binaryify/vue-qr#readme", | ||
| 73 | "keywords": [ | ||
| 74 | "vue-qr", | ||
| 75 | "vue qr", | ||
| 76 | "vue qrcode", | ||
| 77 | "qr", | ||
| 78 | "vue" | ||
| 79 | ], | ||
| 80 | "license": "MIT", | ||
| 81 | "main": "dist/vue-qr.js", | ||
| 82 | "name": "vue-qr", | ||
| 83 | "repository": { | ||
| 84 | "type": "git", | ||
| 85 | "url": "git+https://github.com/Binaryify/vue-qr.git" | ||
| 86 | }, | ||
| 87 | "scripts": { | ||
| 88 | "build": "cross-env NODE_ENV=production webpack --progress --hide-modules", | ||
| 89 | "dev": "cross-env NODE_ENV=development webpack-dev-server --open --hot --host 0.0.0.0" | ||
| 90 | }, | ||
| 91 | "version": "4.0.9" | ||
| 92 | } |
This diff is collapsed.
Click to expand it.
| 1 | "use strict"; | ||
| 2 | |||
| 3 | // const {asBuffer, asDownload, asZipDownload, atScale, options} = require('./io') | ||
| 4 | import io from "./io"; | ||
| 5 | const { asBuffer, asDownload, asZipDownload, atScale, options } = io; | ||
| 6 | // | ||
| 7 | // Browser equivalents of the skia-canvas convenience initializers and polyfills for | ||
| 8 | // the Canvas object’s newPage & export methods | ||
| 9 | // | ||
| 10 | |||
| 11 | const _toURL_ = Symbol.for("toDataURL"); | ||
| 12 | |||
| 13 | const loadImage = src => | ||
| 14 | new Promise((onload, onerror) => | ||
| 15 | Object.assign(new Image(), { | ||
| 16 | crossOrigin: "Anonymous", | ||
| 17 | onload, | ||
| 18 | onerror, | ||
| 19 | src | ||
| 20 | }) | ||
| 21 | ); | ||
| 22 | |||
| 23 | class Canvas { | ||
| 24 | constructor(width, height) { | ||
| 25 | // alert(1) | ||
| 26 | let elt = document.createElement("canvas"), | ||
| 27 | pages = []; | ||
| 28 | |||
| 29 | Object.defineProperty(elt, "async", { | ||
| 30 | value: true, | ||
| 31 | writable: false, | ||
| 32 | enumerable: true | ||
| 33 | }); | ||
| 34 | |||
| 35 | for (var [prop, get] of Object.entries({ | ||
| 36 | png: () => asBuffer(elt, "image/png"), | ||
| 37 | jpg: () => asBuffer(elt, "image/jpeg"), | ||
| 38 | pages: () => pages.concat(elt).map(c => c.getContext("2d")) | ||
| 39 | })) | ||
| 40 | Object.defineProperty(elt, prop, { get }); | ||
| 41 | |||
| 42 | return Object.assign(elt, { | ||
| 43 | width, | ||
| 44 | height, | ||
| 45 | |||
| 46 | newPage(...size) { | ||
| 47 | var { width, height } = elt, | ||
| 48 | page = Object.assign(document.createElement("canvas"), { | ||
| 49 | width, | ||
| 50 | height | ||
| 51 | }); | ||
| 52 | page.getContext("2d").drawImage(elt, 0, 0); | ||
| 53 | pages.push(page); | ||
| 54 | |||
| 55 | var [width, height] = size.length ? size : [width, height]; | ||
| 56 | return Object.assign(elt, { width, height }).getContext("2d"); | ||
| 57 | }, | ||
| 58 | |||
| 59 | saveAs(filename, args) { | ||
| 60 | args = typeof args == "number" ? { quality: args } : args; | ||
| 61 | let opts = options(this.pages, { filename, ...args }), | ||
| 62 | { pattern, padding, mime, quality, matte, density, archive } = opts, | ||
| 63 | pages = atScale(opts.pages, density); | ||
| 64 | return padding == undefined | ||
| 65 | ? asDownload(pages[0], mime, quality, matte, filename) | ||
| 66 | : asZipDownload( | ||
| 67 | pages, | ||
| 68 | mime, | ||
| 69 | quality, | ||
| 70 | matte, | ||
| 71 | archive, | ||
| 72 | pattern, | ||
| 73 | padding | ||
| 74 | ); | ||
| 75 | }, | ||
| 76 | |||
| 77 | toBuffer(extension = "png", args = {}) { | ||
| 78 | args = typeof args == "number" ? { quality: args } : args; | ||
| 79 | let opts = options(this.pages, { extension, ...args }), | ||
| 80 | { mime, quality, matte, pages, density } = opts, | ||
| 81 | canvas = atScale(pages, density, matte)[0]; | ||
| 82 | return asBuffer(canvas, mime, quality, matte); | ||
| 83 | }, | ||
| 84 | |||
| 85 | [_toURL_]: elt.toDataURL.bind(elt), | ||
| 86 | toDataURL(extension = "png", args = {}) { | ||
| 87 | args = typeof args == "number" ? { quality: args } : args; | ||
| 88 | let opts = options(this.pages, { extension, ...args }), | ||
| 89 | { mime, quality, matte, pages, density } = opts, | ||
| 90 | canvas = atScale(pages, density, matte)[0], | ||
| 91 | url = canvas[canvas === elt ? _toURL_ : "toDataURL"](mime, quality); | ||
| 92 | return Promise.resolve(url); | ||
| 93 | } | ||
| 94 | }); | ||
| 95 | } | ||
| 96 | } | ||
| 97 | |||
| 98 | const { | ||
| 99 | CanvasRenderingContext2D, | ||
| 100 | CanvasGradient, | ||
| 101 | CanvasPattern, | ||
| 102 | Image, | ||
| 103 | ImageData, | ||
| 104 | Path2D, | ||
| 105 | DOMMatrix, | ||
| 106 | DOMRect, | ||
| 107 | DOMPoint | ||
| 108 | } = window; | ||
| 109 | |||
| 110 | // module.exports = { | ||
| 111 | // Canvas, | ||
| 112 | // loadImage, | ||
| 113 | // CanvasRenderingContext2D, | ||
| 114 | // CanvasGradient, | ||
| 115 | // CanvasPattern, | ||
| 116 | // Image, | ||
| 117 | // ImageData, | ||
| 118 | // Path2D, | ||
| 119 | // DOMMatrix, | ||
| 120 | // DOMRect, | ||
| 121 | // DOMPoint | ||
| 122 | // }; | ||
| 123 | |||
| 124 | const obj = { | ||
| 125 | Canvas, | ||
| 126 | loadImage, | ||
| 127 | CanvasRenderingContext2D, | ||
| 128 | CanvasGradient, | ||
| 129 | CanvasPattern, | ||
| 130 | Image, | ||
| 131 | ImageData, | ||
| 132 | Path2D, | ||
| 133 | DOMMatrix, | ||
| 134 | DOMRect, | ||
| 135 | DOMPoint | ||
| 136 | }; | ||
| 137 | export default obj; |
| 1 | "use strict"; | ||
| 2 | |||
| 3 | // | ||
| 4 | // Parsers for properties that take CSS-style strings as values | ||
| 5 | // | ||
| 6 | |||
| 7 | // -- Font & Variant -------------------------------------------------------------------- | ||
| 8 | // https://developer.mozilla.org/en-US/docs/Web/CSS/font-variant | ||
| 9 | // https://www.w3.org/TR/css-fonts-3/#font-size-prop | ||
| 10 | import splitBy from "string-split-by"; | ||
| 11 | var m, | ||
| 12 | cache = { font: {}, variant: {} }; | ||
| 13 | |||
| 14 | const styleRE = /^(normal|italic|oblique)$/, | ||
| 15 | smallcapsRE = /^(normal|small-caps)$/, | ||
| 16 | stretchRE = /^(normal|(semi-|extra-|ultra-)?(condensed|expanded))$/, | ||
| 17 | namedSizeRE = /(?:xx?-)?small|smaller|medium|larger|(?:xx?-)?large|normal/, | ||
| 18 | numSizeRE = /^([\d\.]+)(px|pt|pc|in|cm|mm|%|em|ex|ch|rem|q)/, | ||
| 19 | namedWeightRE = /^(normal|bold(er)?|lighter)$/, | ||
| 20 | numWeightRE = /^(1000|\d{1,3})$/, | ||
| 21 | parameterizedRE = /([\w\-]+)\((.*?)\)/, | ||
| 22 | unquote = s => s.replace(/^(['"])(.*?)\1$/, "$2"), | ||
| 23 | isSize = s => namedSizeRE.test(s) || numSizeRE.test(s), | ||
| 24 | isWeight = s => namedWeightRE.test(s) || numWeightRE.test(s); | ||
| 25 | |||
| 26 | function parseFont(str) { | ||
| 27 | if (cache.font[str] === undefined) { | ||
| 28 | try { | ||
| 29 | if (typeof str !== "string") | ||
| 30 | throw new Error("Font specification must be a string"); | ||
| 31 | if (!str) throw new Error("Font specification cannot be an empty string"); | ||
| 32 | |||
| 33 | let font = { | ||
| 34 | style: "normal", | ||
| 35 | variant: "normal", | ||
| 36 | weight: "normal", | ||
| 37 | stretch: "normal" | ||
| 38 | }, | ||
| 39 | value = str.replace(/\s*\/\*s/, "/"), | ||
| 40 | tokens = splitBy(value, /\s+/), | ||
| 41 | token; | ||
| 42 | |||
| 43 | while ((token = tokens.shift())) { | ||
| 44 | let match = styleRE.test(token) | ||
| 45 | ? "style" | ||
| 46 | : smallcapsRE.test(token) | ||
| 47 | ? "variant" | ||
| 48 | : stretchRE.test(token) | ||
| 49 | ? "stretch" | ||
| 50 | : isWeight(token) | ||
| 51 | ? "weight" | ||
| 52 | : isSize(token) | ||
| 53 | ? "size" | ||
| 54 | : null; | ||
| 55 | |||
| 56 | switch (match) { | ||
| 57 | case "style": | ||
| 58 | case "variant": | ||
| 59 | case "stretch": | ||
| 60 | case "weight": | ||
| 61 | font[match] = token; | ||
| 62 | break; | ||
| 63 | |||
| 64 | case "size": | ||
| 65 | // size is the pivot point between the style fields and the family name stack, | ||
| 66 | // so start processing what's been collected | ||
| 67 | let [emSize, leading] = splitBy(token, "/"), | ||
| 68 | size = parseSize(emSize), | ||
| 69 | lineHeight = parseSize( | ||
| 70 | (leading || "1.2").replace(/(\d)$/, "$1em"), | ||
| 71 | size | ||
| 72 | ), | ||
| 73 | weight = parseWeight(font.weight), | ||
| 74 | family = splitBy(tokens.join(" "), /\s*,\s*/).map(unquote), | ||
| 75 | features = | ||
| 76 | font.variant == "small-caps" ? { on: ["smcp", "onum"] } : {}, | ||
| 77 | { style, stretch, variant } = font; | ||
| 78 | |||
| 79 | // make sure all the numeric fields have legitimate values | ||
| 80 | let invalid = !isFinite(size) | ||
| 81 | ? `font size "${emSize}"` | ||
| 82 | : !isFinite(lineHeight) | ||
| 83 | ? `line height "${leading}"` | ||
| 84 | : !isFinite(weight) | ||
| 85 | ? `font weight "${font.weight}"` | ||
| 86 | : family.length == 0 | ||
| 87 | ? `font family "${tokens.join(", ")}"` | ||
| 88 | : false; | ||
| 89 | |||
| 90 | if (!invalid) { | ||
| 91 | // include a re-stringified version of the decoded/absified values | ||
| 92 | return (cache.font[str] = Object.assign(font, { | ||
| 93 | size, | ||
| 94 | lineHeight, | ||
| 95 | weight, | ||
| 96 | family, | ||
| 97 | features, | ||
| 98 | canonical: [ | ||
| 99 | style, | ||
| 100 | variant !== style && variant, | ||
| 101 | [variant, style].indexOf(weight) == -1 && weight, | ||
| 102 | [variant, style, weight].indexOf(stretch) == -1 && stretch, | ||
| 103 | `${size}px/${lineHeight}px`, | ||
| 104 | family.map(nm => (nm.match(/\s/) ? `"${nm}"` : nm)).join(", ") | ||
| 105 | ] | ||
| 106 | .filter(Boolean) | ||
| 107 | .join(" ") | ||
| 108 | })); | ||
| 109 | } | ||
| 110 | throw new Error(`Invalid ${invalid}`); | ||
| 111 | |||
| 112 | default: | ||
| 113 | throw new Error(`Unrecognized font attribute "${token}"`); | ||
| 114 | } | ||
| 115 | } | ||
| 116 | throw new Error("Could not find a font size value"); | ||
| 117 | } catch (e) { | ||
| 118 | // console.warn(Object.assign(e, {name:"Warning"})) | ||
| 119 | cache.font[str] = null; | ||
| 120 | } | ||
| 121 | } | ||
| 122 | return cache.font[str]; | ||
| 123 | } | ||
| 124 | |||
| 125 | function parseSize(str, emSize = 16) { | ||
| 126 | if ((m = numSizeRE.exec(str))) { | ||
| 127 | let [size, unit] = [parseFloat(m[1]), m[2]]; | ||
| 128 | return ( | ||
| 129 | size * | ||
| 130 | (unit == "px" | ||
| 131 | ? 1 | ||
| 132 | : unit == "pt" | ||
| 133 | ? 1 / 0.75 | ||
| 134 | : unit == "%" | ||
| 135 | ? emSize / 100 | ||
| 136 | : unit == "pc" | ||
| 137 | ? 16 | ||
| 138 | : unit == "in" | ||
| 139 | ? 96 | ||
| 140 | : unit == "cm" | ||
| 141 | ? 96.0 / 2.54 | ||
| 142 | : unit == "mm" | ||
| 143 | ? 96.0 / 25.4 | ||
| 144 | : unit == "q" | ||
| 145 | ? 96 / 25.4 / 4 | ||
| 146 | : unit.match("r?em") | ||
| 147 | ? emSize | ||
| 148 | : NaN) | ||
| 149 | ); | ||
| 150 | } | ||
| 151 | |||
| 152 | if ((m = namedSizeRE.exec(str))) { | ||
| 153 | return emSize * (sizeMap[m[0]] || 1.0); | ||
| 154 | } | ||
| 155 | |||
| 156 | return NaN; | ||
| 157 | } | ||
| 158 | |||
| 159 | function parseWeight(str) { | ||
| 160 | return (m = numWeightRE.exec(str)) | ||
| 161 | ? parseInt(m[0]) || NaN | ||
| 162 | : (m = namedWeightRE.exec(str)) | ||
| 163 | ? weightMap[m[0]] | ||
| 164 | : NaN; | ||
| 165 | } | ||
| 166 | |||
| 167 | function parseVariant(str) { | ||
| 168 | if (cache.variant[str] === undefined) { | ||
| 169 | let variants = [], | ||
| 170 | features = { on: [], off: [] }; | ||
| 171 | |||
| 172 | for (let token of splitBy(str, /\s+/)) { | ||
| 173 | if (token == "normal") { | ||
| 174 | return { variants: [token], features: { on: [], off: [] } }; | ||
| 175 | } else if (token in featureMap) { | ||
| 176 | featureMap[token].forEach(feat => { | ||
| 177 | if (feat[0] == "-") features.off.push(feat.slice(1)); | ||
| 178 | else features.on.push(feat); | ||
| 179 | }); | ||
| 180 | variants.push(token); | ||
| 181 | } else if ((m = parameterizedRE.exec(token))) { | ||
| 182 | let subPattern = alternatesMap[m[1]], | ||
| 183 | subValue = Math.max(0, Math.min(99, parseInt(m[2], 10))), | ||
| 184 | [feat, val] = subPattern | ||
| 185 | .replace(/##/, subValue < 10 ? "0" + subValue : subValue) | ||
| 186 | .replace(/#/, Math.min(9, subValue)) | ||
| 187 | .split(" "); | ||
| 188 | if (typeof val == "undefined") features.on.push(feat); | ||
| 189 | else features[feat] = parseInt(val, 10); | ||
| 190 | variants.push(`${m[1]}(${subValue})`); | ||
| 191 | } else { | ||
| 192 | throw new Error(`Invalid font variant "${token}"`); | ||
| 193 | } | ||
| 194 | } | ||
| 195 | |||
| 196 | cache.variant[str] = { variant: variants.join(" "), features: features }; | ||
| 197 | } | ||
| 198 | |||
| 199 | return cache.variant[str]; | ||
| 200 | } | ||
| 201 | |||
| 202 | // -- Image Filters ----------------------------------------------------------------------- | ||
| 203 | // https://developer.mozilla.org/en-US/docs/Web/CSS/filter | ||
| 204 | |||
| 205 | var plainFilterRE = /(blur|hue-rotate|brightness|contrast|grayscale|invert|opacity|saturate|sepia)\((.*?)\)/, | ||
| 206 | shadowFilterRE = /drop-shadow\((.*)\)/, | ||
| 207 | percentValueRE = /^(\+|-)?\d+%$/, | ||
| 208 | angleValueRE = /([\d\.]+)(deg|g?rad|turn)/; | ||
| 209 | |||
| 210 | function parseFilter(str) { | ||
| 211 | let filters = {}; | ||
| 212 | let canonical = []; | ||
| 213 | |||
| 214 | for (var spec of splitBy(str, /\s+/) || []) { | ||
| 215 | if ((m = shadowFilterRE.exec(spec))) { | ||
| 216 | let kind = "drop-shadow", | ||
| 217 | args = m[1].trim().split(/\s+/), | ||
| 218 | lengths = args.slice(0, 3), | ||
| 219 | color = args.slice(3).join(" "), | ||
| 220 | dims = lengths.map(s => parseSize(s)).filter(isFinite); | ||
| 221 | if (dims.length == 3 && !!color) { | ||
| 222 | filters[kind] = [...dims, color]; | ||
| 223 | canonical.push( | ||
| 224 | `${kind}(${lengths.join(" ")} ${color.replace(/ /g, "")})` | ||
| 225 | ); | ||
| 226 | } | ||
| 227 | } else if ((m = plainFilterRE.exec(spec))) { | ||
| 228 | let [kind, arg] = m.slice(1); | ||
| 229 | let val = | ||
| 230 | kind == "blur" | ||
| 231 | ? parseSize(arg) | ||
| 232 | : kind == "hue-rotate" | ||
| 233 | ? parseAngle(arg) | ||
| 234 | : parsePercentage(arg); | ||
| 235 | if (isFinite(val)) { | ||
| 236 | filters[kind] = val; | ||
| 237 | canonical.push(`${kind}(${arg.trim()})`); | ||
| 238 | } | ||
| 239 | } | ||
| 240 | } | ||
| 241 | |||
| 242 | return str.trim() == "none" | ||
| 243 | ? { canonical: "none", filters } | ||
| 244 | : canonical.length | ||
| 245 | ? { canonical: canonical.join(" "), filters } | ||
| 246 | : null; | ||
| 247 | } | ||
| 248 | |||
| 249 | function parsePercentage(str) { | ||
| 250 | return percentValueRE.test(str.trim()) ? parseInt(str, 10) / 100 : NaN; | ||
| 251 | } | ||
| 252 | |||
| 253 | function parseAngle(str) { | ||
| 254 | if ((m = angleValueRE.exec(str.trim()))) { | ||
| 255 | let [amt, unit] = [parseFloat(m[1]), m[2]]; | ||
| 256 | return unit == "deg" | ||
| 257 | ? amt | ||
| 258 | : unit == "rad" | ||
| 259 | ? (360 * amt) / (2 * Math.PI) | ||
| 260 | : unit == "grad" | ||
| 261 | ? (360 * amt) / 400 | ||
| 262 | : unit == "turn" | ||
| 263 | ? 360 * amt | ||
| 264 | : NaN; | ||
| 265 | } | ||
| 266 | } | ||
| 267 | |||
| 268 | // | ||
| 269 | // Font attribute keywords & corresponding values | ||
| 270 | // | ||
| 271 | |||
| 272 | const weightMap = { | ||
| 273 | lighter: 300, | ||
| 274 | normal: 400, | ||
| 275 | bold: 700, | ||
| 276 | bolder: 800 | ||
| 277 | }; | ||
| 278 | |||
| 279 | const sizeMap = { | ||
| 280 | "xx-small": 3 / 5, | ||
| 281 | "x-small": 3 / 4, | ||
| 282 | small: 8 / 9, | ||
| 283 | smaller: 8 / 9, | ||
| 284 | large: 6 / 5, | ||
| 285 | larger: 6 / 5, | ||
| 286 | "x-large": 3 / 2, | ||
| 287 | "xx-large": 2 / 1, | ||
| 288 | normal: 1.2 // special case for lineHeight | ||
| 289 | }; | ||
| 290 | |||
| 291 | const featureMap = { | ||
| 292 | normal: [], | ||
| 293 | |||
| 294 | // font-variant-ligatures | ||
| 295 | "common-ligatures": ["liga", "clig"], | ||
| 296 | "no-common-ligatures": ["-liga", "-clig"], | ||
| 297 | "discretionary-ligatures": ["dlig"], | ||
| 298 | "no-discretionary-ligatures": ["-dlig"], | ||
| 299 | "historical-ligatures": ["hlig"], | ||
| 300 | "no-historical-ligatures": ["-hlig"], | ||
| 301 | contextual: ["calt"], | ||
| 302 | "no-contextual": ["-calt"], | ||
| 303 | |||
| 304 | // font-variant-position | ||
| 305 | super: ["sups"], | ||
| 306 | sub: ["subs"], | ||
| 307 | |||
| 308 | // font-variant-caps | ||
| 309 | "small-caps": ["smcp"], | ||
| 310 | "all-small-caps": ["c2sc", "smcp"], | ||
| 311 | "petite-caps": ["pcap"], | ||
| 312 | "all-petite-caps": ["c2pc", "pcap"], | ||
| 313 | unicase: ["unic"], | ||
| 314 | "titling-caps": ["titl"], | ||
| 315 | |||
| 316 | // font-variant-numeric | ||
| 317 | "lining-nums": ["lnum"], | ||
| 318 | "oldstyle-nums": ["onum"], | ||
| 319 | "proportional-nums": ["pnum"], | ||
| 320 | "tabular-nums": ["tnum"], | ||
| 321 | "diagonal-fractions": ["frac"], | ||
| 322 | "stacked-fractions": ["afrc"], | ||
| 323 | ordinal: ["ordn"], | ||
| 324 | "slashed-zero": ["zero"], | ||
| 325 | |||
| 326 | // font-variant-east-asian | ||
| 327 | jis78: ["jp78"], | ||
| 328 | jis83: ["jp83"], | ||
| 329 | jis90: ["jp90"], | ||
| 330 | jis04: ["jp04"], | ||
| 331 | simplified: ["smpl"], | ||
| 332 | traditional: ["trad"], | ||
| 333 | "full-width": ["fwid"], | ||
| 334 | "proportional-width": ["pwid"], | ||
| 335 | ruby: ["ruby"], | ||
| 336 | |||
| 337 | // font-variant-alternates (non-parameterized) | ||
| 338 | "historical-forms": ["hist"] | ||
| 339 | }; | ||
| 340 | |||
| 341 | const alternatesMap = { | ||
| 342 | stylistic: "salt #", | ||
| 343 | styleset: "ss##", | ||
| 344 | "character-variant": "cv##", | ||
| 345 | swash: "swsh #", | ||
| 346 | ornaments: "ornm #", | ||
| 347 | annotation: "nalt #" | ||
| 348 | }; | ||
| 349 | |||
| 350 | // module.exports = { | ||
| 351 | // font: parseFont, | ||
| 352 | // variant: parseVariant, | ||
| 353 | // size: parseSize, | ||
| 354 | // filter: parseFilter | ||
| 355 | // }; | ||
| 356 | export default { | ||
| 357 | font: parseFont, | ||
| 358 | variant: parseVariant, | ||
| 359 | size: parseSize, | ||
| 360 | filter: parseFilter | ||
| 361 | }; |
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
No preview for this file type
This diff is collapsed.
Click to expand it.
node_modules/vue-qr/src/App.vue
0 → 100644
This diff is collapsed.
Click to expand it.
node_modules/vue-qr/src/assets/avatar.png
0 → 100644
13.3 KB
node_modules/vue-qr/src/assets/bg1.png
0 → 100644
54.1 KB
node_modules/vue-qr/src/assets/bg2.jpg
0 → 100644
37.2 KB
node_modules/vue-qr/src/assets/bg3.jpg
0 → 100644
752 KB
node_modules/vue-qr/src/assets/dog.gif
0 → 100644
493 KB
node_modules/vue-qr/src/assets/logo.png
0 → 100644
6.69 KB
node_modules/vue-qr/src/assets/result1.png
0 → 100644
188 KB
node_modules/vue-qr/src/assets/result2.png
0 → 100644
36.5 KB
node_modules/vue-qr/src/assets/result3.png
0 → 100644
94.8 KB
node_modules/vue-qr/src/assets/result4.gif
0 → 100644
1.46 MB
node_modules/vue-qr/src/assets/scare.gif
0 → 100644
858 KB
node_modules/vue-qr/src/index.js
0 → 100644
This diff is collapsed.
Click to expand it.
node_modules/vue-qr/src/lib/awesome-qr.d.ts
0 → 100644
This diff is collapsed.
Click to expand it.
node_modules/vue-qr/src/lib/awesome-qr.js
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
node_modules/vue-qr/src/lib/gifuct-js/lzw.js
0 → 100644
This diff is collapsed.
Click to expand it.
node_modules/vue-qr/src/lib/index.d.ts
0 → 100644
This diff is collapsed.
Click to expand it.
node_modules/vue-qr/src/lib/index.js
0 → 100644
This diff is collapsed.
Click to expand it.
node_modules/vue-qr/src/lib/qrcode.d.ts
0 → 100644
This diff is collapsed.
Click to expand it.
node_modules/vue-qr/src/lib/qrcode.js
0 → 100644
This diff is collapsed.
Click to expand it.
node_modules/vue-qr/src/main.js
0 → 100644
This diff is collapsed.
Click to expand it.
node_modules/vue-qr/src/packages/index.js
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
node_modules/vue-qr/src/packages/util.js
0 → 100644
This diff is collapsed.
Click to expand it.
node_modules/vue-qr/src/packages/vue-qr.vue
0 → 100644
This diff is collapsed.
Click to expand it.
node_modules/vue-qr/webpack.config.js
0 → 100644
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
-
Please register or sign in to post a comment