Initial commit

This commit is contained in:
Adhiraj
2020-03-16 16:06:30 +05:30
commit 5bd524ca1f
319 changed files with 76526 additions and 0 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

2
.gitattributes vendored Normal file
View File

@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
node_modules
auth_info.json

10
README.md Normal file
View File

@@ -0,0 +1,10 @@
# Baileys
Reverse Engineered WhatsApp Web API in Node.js
Thank you to [Sigalor](https://github.com/sigalor/whatsapp-web-reveng) for writing the guide reverse engineering WhatsApp Web and to the go reimplementation written by [Rhymen](https://github.com/Rhymen/go-whatsapp/tree/484cfe758705761d76724e01839d6fc473dc10c4)
To use Baileys: ``` js const WhatsAppWeb = require('Baileys') ```
Check out test.js to see exactly how to use Baileys.
# Note
I am in no way affiliated with WhatsApp. This is purely for educational purposes.

205
WhatsAppWeb.Recv.js Normal file
View File

@@ -0,0 +1,205 @@
const Utils = require("./WhatsAppWeb.Utils")
/*
Contains the code for recieving messages and forwarding what to do with them to the correct functions
*/
module.exports = function(WhatsAppWeb) {
const Status = WhatsAppWeb.Status
WhatsAppWeb.prototype.onMessageRecieved = function (message) {
if (message[0] === "!") { // when the first character in the message is an '!', the server is updating on the last seen
const timestamp = message.slice(1,message.length)
this.lastSeen = new Date( parseInt(timestamp) )
} else {
const commaIndex = message.indexOf(",") // all whatsapp messages have a tag and a comma, followed by the actual message
if (commaIndex < 0) { // if there was no comma, then this message must be not be valid
return this.gotError([2, "invalid message", message])
}
var data = message.slice(commaIndex+1, message.length)
if (data.length === 0) {
// got an empty message, usually get one after sending a message or something, just return then
return
}
let json
if (data[0] === "[" || data[0] === "{") { // if the first character is a "[", then the data must just be plain JSON array or object
json = JSON.parse( data ) // simply parse the JSON
} else if (this.status === Status.connected) {
/*
If the data recieved was not a JSON, then it must be an encrypted message.
Such a message can only be decrypted if we're connected successfully to the servers & have encryption keys
*/
data = Buffer.from(data, 'binary') // convert the string to a buffer
const checksum = data.slice(0, 32) // the first 32 bytes of the buffer are the HMAC sign of the message
data = data.slice(32, data.length) // the actual message
const computedChecksum = Utils.hmacSign(data, this.authInfo.macKey) // compute the sign of the message we recieved using our macKey
if (checksum.equals(computedChecksum)) { // the checksum the server sent, must match the one we computed for the message to be valid
const decrypted = Utils.aesDecrypt(data, this.authInfo.encKey) // decrypt using AES
json = this.decoder.read( decrypted ) // decode the binary message into a JSON array
} else {
return this.gotError([7, "checksums don't match"])
}
//console.log("enc_json: " + JSON.stringify(json))
} else {
// if we recieved a message that was encrypted but we weren't conencted, then there must be an error
return this.gotError([3, "recieved encrypted message when not connected: " + this.status, message])
}
//console.log(json)
// the first item in the recieved JSON, if it exists, it tells us what the message is about
switch (json[0]) {
case "Conn":
/*
we get this message when a new connection is established,
whether we're starting a new session or are logging back in.
Sometimes, we also recieve it when one opens their phone
*/
this.validateNewConnection(json[1])
return
case "Cmd":
/*
WhatsApp usually sends this when we're trying to restore a closed session,
WhatsApp will challenge us to see whether we still have the keys
*/
if (json[1].type === "challenge") { // if it really is a challenge
this.respondToChallenge(json[1].challenge)
}
return
case "action":
/*
this is when some action was taken on a chat or that we recieve a message.
json[1] tells us more about the message, it can be null
*/
if (!json[1]) { // if json[1] is null
json = json[2][0] // set json to the first element in json[2]; it contains the relevant part
if (json[0] === "read") { // if one marked a chat as read or unread on the phone
const id = json[1].jid.replace("@c.us", "@s.whatsapp.net") // format the sender's ID
if (this.chats[id] && json[1].type === 'false') { // if it was marked unread
this.chats[id].user.count = 1 // up the read count
this.clearUnreadMessages(id) // send notification to the handler about the unread message
} else { // if it was marked read
this.chats[id].user.count = 0 // set the read count to zero
}
}
} else if (json[1].add === "relay") { // if we just recieved a new message sent to us
this.onNewMessage( json[2][0][2] ) // handle this new message
} else if (json[1].add === "before" || json[1].add === "last") {
/*
if we're recieving a full chat log
if json[1].add equals before: if its non-recent messages
if json[1].add equals last: contains the last message of the conversation between the sender and us
*/
json = json[2] // json[2] is the relevant part
/* reverse for loop, because messages are sent ordered by most recent
I can order them by recency if I add them in reverse order */
for (var k = json.length-1;k >= 0;k--) {
const message = json[k]
const id = message[2].key.remoteJid
if (!this.chats[ id ]) { // if we haven't added this ID before, add them now
this.chats[ id ] = {user: { jid: id, count: 0 }, messages: []}
}
this.chats[id].messages.push(message[2]) // append this message to the array
}
const id = json[0][2].key.remoteJid // get the ID whose chats we just processed
this.clearUnreadMessages(id) // forward to the handler any any unread messages
}
break
case "response":
// if it is the list of all the people the WhatsApp account has chats with
if (json[1].type === "chat") {
json[2].forEach (chat => {
if (chat[0] === "chat" && chat[1].jid) {
const jid = chat[1].jid.replace("@c.us", "@s.whatsapp.net") // format ID
this.chats[ jid ] = {
user: {
jid: jid, // the ID of the person
count: chat[1].count}, // number of unread messages we have from them
messages: [ ] // empty messages, is filled by content in the previous section
}
}
})
}
break
default:
break
}
// if the recieved JSON wasn't an array, then we must have recieved a status for a request we made
// this would include creating new sessions & logging in
switch (json.status) {
case 200: // all good and we can procede to generate a QR code for new connection, or can now login given present auth info
if (this.status === Status.creatingNewConnection){ // if we're trying to start a connection
if (this.authInfo.encKey && this.authInfo.macKey) { // if we have the info to restore a closed session
this.status = Status.loggingIn
// create the login request
const data = ["admin", "login", this.authInfo.clientToken, this.authInfo.serverToken, this.authInfo.clientID, "takeover"]
this.sendJSON( data )
} else {
this.generateKeysForAuth(json.ref)
}
} else {
}
break
case 401: // if the phone was unpaired
this.close()
return this.gotError([json.status, "unpaired from phone", message])
case 429: // request to login was denied, don't know why it happens
this.close()
return this.gotError([ json.status, "request denied, try reconnecting", message ])
case 304: // request to generate a new key for a QR code was denied
console.log("reuse previous ref")
return this.gotError([ json.status, "request for new key denied", message ])
default:
break
}
}
}
// shoot off notifications to the handler that new unread message are available
WhatsAppWeb.prototype.clearUnreadMessages = function (id) {
const chat = this.chats[id] // get the chat
var j = 0
let unreadMessages = chat.user.count
while (unreadMessages > 0) {
if (!chat.messages[j].key.fromMe) { // only forward if the message is from the sender
this.handlers.onUnreadMessage( chat.messages[j] ) // send off the unread message
unreadMessages -= 1 // reduce
}
j += 1
}
}
// when a new message is recieved
WhatsAppWeb.prototype.onNewMessage = function (message) {
if (message && message.message) { // confirm that the message really is valid
if (!this.chats[message.key.remoteJid]) { // if we don't have any chats from this ID before, add them to our DB
this.chats[message.key.remoteJid] = {
user: { jid: message.key.remoteJid, count: 0 },
messages: [ message ]
}
} else {
// if the chat was already there, then insert the message at the front of the array
this.chats[ message.key.remoteJid ].messages.splice(0, 0, message)
}
if (!message.key.fromMe) { // if this message was sent to us, notify the handler
this.handlers.onUnreadMessage ( message )
}
}
}
}

85
WhatsAppWeb.Send.js Normal file
View File

@@ -0,0 +1,85 @@
const Utils = require("./WhatsAppWeb.Utils")
/*
Contains the code for sending stuff to WhatsApp
*/
module.exports = function(WhatsAppWeb) {
// send a read receipt to the given ID on a certain message
WhatsAppWeb.prototype.sendReadReceipt = function (jid, messageID) {
const json = [
"action",
{ epoch: this.msgCount.toString(), type: "set" },
[ ["read", {count: "1", index: messageID, jid: jid, owner: "false"}, null] ]
]
this.sendBinary(json, [10, 128]) // encrypt and send off
if (this.chats[ jid ]) {
this.chats[jid].user.count = 0 // reset read count
}
}
// tell someone about your presence -- online, typing, offline etc.
WhatsAppWeb.prototype.updatePresence = function (jid, type) {
const json = [
"action",
{ epoch: this.msgCount.toString(), type: "set" },
[ ["presence", {type: type, to: jid}, null] ]
]
this.sendBinary(json, [10, 128])
}
// send a text message to someone, optionally you can provide the time at which you want the message to be sent
WhatsAppWeb.prototype.sendTextMessage = function (id, txt, timestamp=null) {
const message = {conversation: txt}
return this.sendMessage(id, message, timestamp)
}
// generic send message construct
WhatsAppWeb.prototype.sendMessage = function (id, message, timestamp=null) {
if (!timestamp) { // if no timestamp was provided,
timestamp = new Date() // set timestamp to now
}
timestamp = timestamp.getTime()/1000
const messageJSON = {
key: {
remoteJid: id,
fromMe: true,
id: Utils.generateMessageID()
},
message: message,
messageTimestamp: timestamp,
status: "ERROR"
}
const json = [
"action",
{epoch: this.msgCount.toString(), type: "relay" },
[ ['message', null, messageJSON] ]
]
return this.sendBinary(json, [16, 128])
}
// send a binary message, the tags parameter tell WhatsApp what the message is all about
WhatsAppWeb.prototype.sendBinary = function (json, tags) {
const binary = this.encoder.write(json) // encode the JSON to the WhatsApp binary format
var buff = Utils.aesEncrypt(binary, this.authInfo.encKey) // encrypt it using AES and our encKey
const sign = Utils.hmacSign(buff, this.authInfo.macKey) // sign the message using HMAC and our macKey
buff = Buffer.concat([
Buffer.from( Utils.generateMessageTag() + "," ), // generate & prefix the message tag
Buffer.from(tags), // prefix some bytes that tell whatsapp what the message is about
sign, // the HMAC sign of the message
buff // the actual encrypted buffer
])
this.send(buff) // send it off
}
// send a JSON message to WhatsApp servers
WhatsAppWeb.prototype.sendJSON = function (json) {
const str = JSON.stringify(json)
this.send( Utils.generateMessageTag() + "," + str )
}
WhatsAppWeb.prototype.send = function (m) {
this.msgCount += 1 // increment message count, it makes the 'epoch' field when sending binary messages
this.conn.send( m )
}
}

200
WhatsAppWeb.Session.js Normal file
View File

@@ -0,0 +1,200 @@
const WebSocket = require('ws')
const Curve = require ('curve25519-js')
const HKDF = require('futoin-hkdf')
const Utils = require('./WhatsAppWeb.Utils')
const QR = require('qrcode-terminal')
/*
Contains the code for connecting to WhatsApp Web, establishing a new session & logging back in
*/
module.exports = function (WhatsAppWeb) {
const Status = WhatsAppWeb.Status
// connect to the WhatsApp Web servers
WhatsAppWeb.prototype.connect = function () {
if (this.status != Status.notConnected) {
return this.gotError([1, "already connected or connecting"])
}
this.status = Status.connecting
this.conn = new WebSocket("wss://web.whatsapp.com/ws", {origin: "https://web.whatsapp.com"})
this.conn.on('open', () => this.onConnect())
this.conn.on('message', (m) => this.onMessageRecieved(m)) // in WhatsAppWeb.Recv.js
this.conn.on('error', (error) => { // if there was an error in the WebSocket
this.close()
this.gotError([20, error])
})
this.conn.on('close', () => { })
}
// once a connection has been successfully established
WhatsAppWeb.prototype.onConnect = function () {
console.log("connected to WhatsApp Web")
this.status = Status.creatingNewConnection
if (!this.authInfo) { // if no auth info is present, that is, a new session has to be established
this.authInfo = { clientID: Utils.generateClientID() } // generate a client ID
}
const data = ["admin", "init", WhatsAppWeb.version, WhatsAppWeb.browserDescriptions, this.authInfo.clientID, true]
this.sendJSON( data )
}
// restore a previously closed session using the given authentication information
WhatsAppWeb.prototype.login = function (authInfo) {
this.authInfo = {
clientID: authInfo.clientID,
serverToken: authInfo.serverToken,
clientToken: authInfo.clientToken,
encKey: Buffer.from( authInfo.encKey, 'base64' ),
macKey: Buffer.from( authInfo.macKey, 'base64' )
}
this.connect()
}
// once the QR code is scanned and we can validate our connection,
// or we resolved the challenge when logging back in
WhatsAppWeb.prototype.validateNewConnection = function (json) {
if (json.connected) { // only if we're connected
if (!json.secret) { // if we didn't get a secret, that is we don't need it
return this.didConnectSuccessfully()
}
const secret = Buffer.from(json.secret, 'base64')
if (secret.length !== 144) {
return this.gotError([4, "incorrect secret length: " + secret.length])
}
// generate shared key from our private key & the secret shared by the server
const sharedKey = Curve.sharedKey( this.curveKeys.private, secret.slice(0, 32) )
// expand the key to 80 bytes using HKDF
const expandedKey = HKDF(sharedKey, 80, [ Buffer.alloc(32), '', 'SHA-256' ])
// perform HMAC validation.
const hmacValidationKey = expandedKey.slice(32, 64)
const hmacValidationMessage = Buffer.concat( [ secret.slice(0, 32), secret.slice(64, secret.length) ] )
const hmac = Utils.hmacSign(hmacValidationMessage, hmacValidationKey)
if ( hmac.equals(secret.slice(32, 64)) ) { // computed HMAC should equal secret[32:64]
// expandedKey[64:] + secret[64:] are the keys, encrypted using AES, that are used to encrypt/decrypt the messages recieved from WhatsApp
// they are encrypted using key: expandedKey[0:32]
const encryptedAESKeys = Buffer.concat([ expandedKey.slice(64, expandedKey.length), secret.slice(64, secret.length) ])
const decryptedKeys = Utils.aesDecrypt(encryptedAESKeys, expandedKey.slice(0,32))
// this data is required to restore closed sessions
this.authInfo = {
encKey: decryptedKeys.slice(0, 32), // first 32 bytes form the key to encrypt/decrypt messages
macKey: decryptedKeys.slice(32, 64), // last 32 bytes from the key to sign messages
clientToken: json.clientToken,
serverToken: json.serverToken,
clientID: this.authInfo.clientID
}
this.userMetaData = {
id: json.wid, // one's WhatsApp ID [cc][number]@s.whatsapp.net
name: json.pushname, // name set on whatsapp
phone: json.phone // information about the phone one has logged in to
}
this.status = Status.CONNECTED
this.didConnectSuccessfully()
} else { // if the checksums didn't match
this.close()
this.gotError([5, "HMAC validation failed"])
}
} else { // if we didn't get the connected field (usually we get this message when one opens WhatsApp on their phone)
if (this.status !== Status.connected) { // and we're not already connected
this.close()
this.gotError([6, "json connection failed", json])
}
}
}
/*
when logging back in (restoring a previously closed session), WhatsApp may challenge one to check if one still has the encryption keys
WhatsApp does that by asking for us to sign a string it sends with our macKey
*/
WhatsAppWeb.prototype.respondToChallenge = function (challenge) {
const bytes = Buffer.from(challenge, 'base64') // decode the base64 encoded challenge string
const signed = Utils.hmacSign(bytes, this.authInfo.macKey).toString('base64') // sign the challenge string with our macKey
const data = ["admin", "challenge", signed, this.authInfo.serverToken, this.authInfo.clientID] // prepare to send this signed string with the serverToken & clientID
console.log( "resolving challenge" )
this.sendJSON( data )
}
/*
when starting a new session, generate a QR code by generating a private/public key pair & the keys the server sends
*/
WhatsAppWeb.prototype.generateKeysForAuth = function (ref) {
this.curveKeys = Curve.generateKeyPair( Utils.randomBytes(32) )
const publicKeyStr = Buffer.from(this.curveKeys.public).toString('base64')
//console.log ("private key: " + Buffer.from(this.curveKeys.private) )
let str = ref + "," + publicKeyStr + "," + this.authInfo.clientID
console.log("authenticating... Converting to QR: " + str)
QR.generate(str, {small: true})
}
// send a keep alive request every 25 seconds, server updates & responds with last seen
WhatsAppWeb.prototype.startKeepAliveRequest = function () {
this.keepAliveReq = setInterval(() => {
const diff = (new Date().getTime()-this.lastSeen.getTime())/1000
/*
check if it's been a suspicious amount of time since the server responded with our last seen
could be that the network is down, or the phone got disconnected or unpaired
*/
if (diff > 25+10) {
console.log("disconnected")
this.close()
if (this.handlers.onDisconnect)
this.handlers.onDisconnect()
if (this.autoReconnect) { // attempt reconnecting if the user wants us to
// keep trying to connect
this.reconnectLoop = setInterval( () => {
// only connect if we're not already in the prcoess of connectin
if (this.status === Status.notConnected) {
this.connect()
}
}, 10 * 1000)
}
} else { // if its all good, send a keep alive request
this.send( "?,," )
}
}, 25 * 1000)
}
WhatsAppWeb.prototype.disconnect = function () {
if (this.status === Status.connected) {
this.conn.send('goodbye,["admin","Conn","disconnect"]', null, () => {
this.conn.close()
if (this.handlers.onDisconnect)
this.handlers.onDisconnect()
})
} else if (this.conn) {
this.close()
}
}
WhatsAppWeb.prototype.close = function () {
this.conn.close()
this.conn = null
this.status = Status.notConnected
this.msgCount = 0
this.chats = {}
if (this.keepAliveReq) {
clearInterval(this.keepAliveReq)
}
}
// request a new QR code from the server (HAVEN'T TESTED THIS OUT YET)
WhatsAppWeb.prototype.requestNewQRCode = function () {
if (this.status !== Status.creatingNewConnection) { // if we're not in the process of connecting
return
}
const json = ["admin", "Conn", "reref"]
this.sendJSON(json)
}
}

31
WhatsAppWeb.Utils.js Normal file
View File

@@ -0,0 +1,31 @@
const Crypto = require("crypto")
/*
Basic cryptographic utilities to interact with WhatsApp servers
*/
module.exports = {
// decrypt AES 256 CBC; where the IV is prefixed to the buffer
aesDecrypt: function (buffer, key) {
const aes = Crypto.createDecipheriv('aes-256-cbc', key, buffer.slice(0,16) ) // first 16 bytes of buffer is IV
return Buffer.concat( [ aes.update(buffer.slice(16, buffer.length)), aes.final() ] )
},
// encrypt AES 256 CBC; where the IV is prefixed to the buffer
aesEncrypt: function (buffer, key) {
const IV = this.randomBytes(16)
const aes = Crypto.createCipheriv('aes-256-cbc', key, IV)
return Buffer.concat( [ IV, aes.update(buffer), aes.final() ] ) // prefix IV to the buffer
},
// sign HMAC using SHA 256
hmacSign: function (buffer, key) {
return Crypto.createHmac('sha256', key).update(buffer).digest()
},
// generate a buffer with random bytes of the specified length
randomBytes: function (length) { return Crypto.randomBytes(length) },
// whatsapp requires a message tag for every message, we just use the timestamp as one
generateMessageTag: function () { return new Date().getTime().toString() },
// generate a random 16 byte client ID
generateClientID: function () { return this.randomBytes(16).toString('base64') },
// generate a random 10 byte ID to attach to a message
generateMessageID: function () { return this.randomBytes(10).toString('hex').toUpperCase() }
}

79
WhatsAppWeb.js Normal file
View File

@@ -0,0 +1,79 @@
const BinaryCoding = require('./binary_coding/binary_encoder.js')
class WhatsAppWeb {
static version = [0,4,1296] // the version of WhatsApp Web we're telling the servers we are
static browserDescriptions = ["Baileys", "Baileys"]
static Status = {
notConnected: 0,
connecting: 1,
creatingNewConnection: 3,
loggingIn: 4,
connected: 5
}
// set of statuses visible to other people; see updatePresence() in WhatsAppWeb.Send
static Presence = {
available: "available", // "online"
unavailable: "unavailable", // offline
composing: "composing", // "typing..."
recording: "recording", // "recording..."
paused: "paused" // I have no clue
}
constructor() {
this.conn = null // the websocket connection
this.authInfo = null // the auth info used to extablish new connections & restore connections
this.userMetaData = null // metadata of the user i.e. name, phone number, phone stats
this.chats = {} // all chats of the user, mapped by the user ID
this.handlers = {} // data for the event handlers
this.msgCount = 0 // number of messages sent to the server; required field for sending messages etc.
this.autoReconnect = true // reconnect automatically after an unexpected disconnect
this.lastSeen = null // updated by sending a keep alive request to the server, and the server responds with our updated last seen
this.encoder = new BinaryCoding.Encoder()
this.decoder = new BinaryCoding.Decoder()
this.status = WhatsAppWeb.Status.notConnected
}
// error is a json array: [errorCode, "error description", optionalDescription]
gotError (error) {
this.handlers.onError(error) // tell the handler, we got an error
}
// called when established a connection to the WhatsApp servers successfully
didConnectSuccessfully () {
console.log("connected successfully")
this.status = WhatsAppWeb.Status.connected // update our status
this.lastSeen = new Date() // set last seen to right now
this.startKeepAliveRequest() // start sending keep alive requests (keeps the WebSocket alive & updates our last seen)
if (this.reconnectLoop) { // if we connected after being disconnected
clearInterval(this.reconnectLoop) // kill the loop to reconnect us
} else { // if we connected for the first time, i.e. not after being disconnected
if (this.handlers.onConnected) // tell the handler that we're connected
this.handlers.onConnected()
}
}
// base 64 encode the authentication credentials and return them, these can then be saved used to login again
// see login () in WhatsAppWeb.Session
base64EncodedAuthInfo () {
return {
clientID: this.authInfo.clientID,
serverToken: this.authInfo.serverToken,
clientToken: this.authInfo.clientToken,
encKey: this.authInfo.encKey.toString('base64'),
macKey: this.authInfo.macKey.toString('base64')
}
}
}
/* import the rest of the code */
require("./WhatsAppWeb.Session.js")(WhatsAppWeb)
require("./WhatsAppWeb.Recv.js")(WhatsAppWeb)
require("./WhatsAppWeb.Send.js")(WhatsAppWeb)
module.exports = WhatsAppWeb

BIN
binary_coding/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -0,0 +1,25 @@
const assert = require('assert').strict
const BinaryCoding = require("./binary_encoder.js")
const testingPairs = [
[
"f806092f5a0a10f804f80234fc6c0a350a1b39313735323938373131313740732e77686174736170702e6e657410011a143345423030393637354537454433374141424632122b0a292a7069616e6f20726f6f6d2074696d696e6773206172653a2a0a20363a3030414d2d31323a3030414d18b3faa7f3052003f80234fc4c0a410a1b39313735323938373131313740732e77686174736170702e6e657410001a20304643454335333330463634393239433645394132434646443242433845414418bdfaa7f305c00101f80234fc930a350a1b39313735323938373131313740732e77686174736170702e6e657410011a14334542303033433742353339414644303937353312520a50536f727279206672656e2c204920636f756c646e277420756e6465727374616e6420274c69627261272e2054797065202768656c702720746f206b6e6f77207768617420616c6c20492063616e20646f18c1faa7f3052003f80234fc540a410a1b39313735323938373131313740732e77686174736170702e6e657410001a20413132333042384436423041314437393345433241453245413043313638443812090a076c69627261727918c2faa7f305",
["action",{"last":"true","add":"before"},[["message",null,{"key":{"remoteJid":"917529871117@s.whatsapp.net","fromMe":true,"id":"3EB009675E7ED37AABF2"},"message":{"conversation":"*piano room timings are:*\n 6:00AM-12:00AM"},"messageTimestamp":"1584004403","status":"DELIVERY_ACK"}],["message",null,{"key":{"remoteJid":"917529871117@s.whatsapp.net","fromMe":false,"id":"0FCEC5330F64929C6E9A2CFFD2BC8EAD"},"messageTimestamp":"1584004413","messageStubType":"REVOKE"}],["message",null,{"key":{"remoteJid":"917529871117@s.whatsapp.net","fromMe":true,"id":"3EB003C7B539AFD09753"},"message":{"conversation":"Sorry fren, I couldn't understand 'Libra'. Type 'help' to know what all I can do"},"messageTimestamp":"1584004417","status":"DELIVERY_ACK"}],["message",null,{"key":{"remoteJid":"917529871117@s.whatsapp.net","fromMe":false,"id":"A1230B8D6B0A1D793EC2AE2EA0C168D8"},"message":{"conversation":"library"},"messageTimestamp":"1584004418"}]]]
]
]
function testCoding () {
const encoder = new BinaryCoding.Encoder()
const decoder = new BinaryCoding.Decoder()
testingPairs.forEach(pair => {
const buff = Buffer.from(pair[0], 'hex')
const decoded = decoder.read(buff)
assert.deepEqual( JSON.stringify( decoded ), JSON.stringify( pair[1] ))
const encoded = encoder.write(decoded)
assert.deepEqual(encoded, buff)
})
console.log("all coding tests passed")
}
testCoding()

View File

@@ -0,0 +1,476 @@
const ProtoBuf = require("protobufjs")
const WATags = {
LIST_EMPTY: 0,
STREAM_END: 2,
DICTIONARY_0: 236,
DICTIONARY_1: 237,
DICTIONARY_2: 238,
DICTIONARY_3: 239,
LIST_8 : 248,
LIST_16 : 249,
JID_PAIR : 250,
HEX_8 : 251,
BINARY_8 : 252,
BINARY_20 : 253,
BINARY_32 : 254,
NIBBLE_8 : 255,
SINGLE_BYTE_MAX: 256,
PACKED_MAX: 254
}
const WADoubleByteTokens = []
const WASingleByteTokens = [
null,null,null,"200","400","404","500","501","502","action","add",
"after","archive","author","available","battery","before","body",
"broadcast","chat","clear","code","composing","contacts","count",
"create","debug","delete","demote","duplicate","encoding","error",
"false","filehash","from","g.us","group","groups_v2","height","id",
"image","in","index","invis","item","jid","kind","last","leave",
"live","log","media","message","mimetype","missing","modify","name",
"notification","notify","out","owner","participant","paused",
"picture","played","presence","preview","promote","query","raw",
"read","receipt","received","recipient","recording","relay",
"remove","response","resume","retry","s.whatsapp.net","seconds",
"set","size","status","subject","subscribe","t","text","to","true",
"type","unarchive","unavailable","url","user","value","web","width",
"mute","read_only","admin","creator","short","update","powersave",
"checksum","epoch","block","previous","409","replaced","reason",
"spam","modify_tag","message_info","delivery","emoji","title",
"description","canonical-url","matched-text","star","unstar",
"media_key","filename","identity","unread","page","page_count",
"search","media_message","security","call_log","profile","ciphertext",
"invite","gif","vcard","frequent","privacy","blacklist","whitelist",
"verify","location","document","elapsed","revoke_invite","expiration",
"unsubscribe","disable","vname","old_jid","new_jid","announcement",
"locked","prop","label","color","call","offer","call-id",
"quick_reply", "sticker", "pay_t", "accept", "reject", "sticker_pack",
"invalid", "canceled", "missed", "connected", "result", "audio",
"video", "recent"
]
const WebMessageInfo = ProtoBuf.Root.fromJSON( require("./whatsapp_message_coding.json") ).lookupType("proto.WebMessageInfo")
class WhatsAppBinaryEncoder {
constructor () {
this.data = []
}
pushByte (value) {
this.data.push((value & 0xFF))
}
pushInt (value, n, littleEndian=false) {
for (var i = 0; i < n;i++) {
const curShift = littleEndian ? i : (n-1-i)
this.data.push( (value>>(curShift*8)) & 0xFF )
}
}
pushInt20 (value) {
this.pushBytes ( [(value >> 16) & 0x0F, (value >> 8) & 0xFF, value & 0xFF] )
}
pushInt16 (value) {
this.pushInt(value, 2)
}
pushInt32 (value) {
this.pushInt(value, 4)
}
pushInt64 (value) {
this.pushInt(value, 8)
}
pushBytes (bytes) {
this.data.push.apply(this.data, bytes)
}
pushString (str) {
const bytes = new TextEncoder('utf-8').encode(str)
this.pushBytes(bytes)
}
writeByteLength (length) {
if (length >= 4294967296) {
throw "string too large to encode: " + length
}
if (length >= (1<<20)) {
this.pushByte(WATags.BINARY_32)
this.pushInt32(length)
} else if (length >= 256) {
this.pushByte(WATags.BINARY_20)
this.pushInt20(length)
} else {
this.pushByte(WATags.BINARY_8)
this.pushByte(length)
}
}
writeStringRaw (string) {
this.writeByteLength( string.length )
this.pushString(string)
}
writeJid(left,right) {
this.pushByte(WATags.JID_PAIR)
if (left && left.length > 0) {
this.writeString(left)
} else {
this.writeToken(WATags.LIST_EMPTY)
}
this.writeString(right)
}
writeToken (token) {
if (token < 245) {
this.pushByte(token)
} else if (token <= 500) {
throw "invalid token"
}
}
writeString(token, i=null) {
if (typeof token !== "string") {
throw "invalid string: " + token
}
if (token === "c.us") {
token = "s.whatsapp.net"
}
const tokenIndex = WASingleByteTokens.indexOf(token)
if (!i && token === "s.whatsapp.net") {
this.writeToken( tokenIndex )
} else if ( tokenIndex >= 0 ) {
if (tokenIndex < WATags.SINGLE_BYTE_MAX) {
this.writeToken(tokenIndex)
} else {
const overflow = tokenIndex-WATags.SINGLE_BYTE_MAX
const dictionaryIndex = overflow >> 8
if (dictionaryIndex < 0 || dictionaryIndex > 3) {
throw "double byte dict token out of range: " + token + ", " + tokenIndex
}
this.writeToken(WATags.DICTIONARY_0 + dictionaryIndex)
this.writeToken(overflow % 256)
}
} else {
const jidSepIndex = token.indexOf("@")
if (jidSepIndex <= 0) {
this.writeStringRaw(token)
} else {
this.writeJid(token.slice(0,jidSepIndex), token.slice(jidSepIndex+1, token.length))
}
}
}
writeAttributes (attrs) {
if (!attrs) {
return
}
Object.keys(attrs).forEach (key => {
this.writeString( key )
this.writeString( attrs[key] )
})
}
writeListStart (listSize) {
if (listSize === 0) {
this.pushByte(WATags.LIST_EMPTY)
} else if (listSize < 256) {
this.pushBytes([WATags.LIST_8, listSize])
} else {
this.pushByte([WATags.LIST_16, listSize])
}
}
writeChildren (children) {
if (!children) {
return
}
if (typeof children === "string") {
this.writeString(children, true)
} else if (typeof children === "Buffer" || typeof children === "Uint8Array") {
this.writeByteLength(children.length)
this.pushBytes(children)
} else if (Array.isArray(children)) {
this.writeListStart(children.length)
children.forEach (c => {
this.writeNode(c)
})
} else if (typeof children === "object") {
//console.log(children)
const buff = WebMessageInfo.encode(children).finish()
this.writeByteLength(buff.length)
this.pushBytes(buff)
} else {
throw "invalid children: " + children + " (" + (typeof children) + ")"
}
}
getNumValidKeys (arr) {
return arr ? Object.keys(arr).length : 0
}
writeNode (node) {
if (!node) {
return
} else if (!Array.isArray(node) || node.length !== 3) {
throw "invalid node given: " + node
}
const numAttributes = this.getNumValidKeys(node[1])
this.writeListStart( 2*numAttributes + 1 + ( node[2] ? 1 : 0 ) )
this.writeString(node[0])
this.writeAttributes(node[1])
this.writeChildren(node[2])
}
write (data) {
this.data = new Array()
this.writeNode(data)
return Buffer.from(this.data)
}
}
class WhatsAppBinaryDecoder {
constructor () {
this.buffer = null
this.index = 0
}
checkEOS (length) {
if (this.index+length > this.buffer.length) {
throw "end of stream"
}
}
next () {
const value = this.buffer[this.index]
this.index += 1
return value
}
readByte () {
this.checkEOS(1)
return this.next()
}
readInt (n, littleEndian=false) {
this.checkEOS(n)
let val = 0
for (var i = 0; i < n;i++) {
const shift = (littleEndian) ? i : (n-1-i)
val |= this.next() << (shift*8)
}
return val
}
readInt16 (littleEndian=false) {
return this.readInt(2, littleEndian)
}
readInt20 () {
this.checkEOS(3)
return ( (this.next() & 15) << 16 ) + (this.next()<<8) + this.next()
}
readInt32 (littleEndian=false) {
return this.readInt(4, littleEndian)
}
readInt64 (littleEndian=false) {
return this.readInt(8, littleEndian)
}
unpackHex (value) {
if (value >= 0 && value < 16) {
return value<10 ? ('0'.charCodeAt(0)+value) : ('A'.charCodeAt(0)+value-10)
}
throw "invalid hex: " + value
}
unpackNibble(value) {
if (value >= 0 && value <= 9) {
return '0'.charCodeAt(0)+value
}
switch (value) {
case 10:
return '-'.charCodeAt(0)
case 11:
return '.'.charCodeAt(0)
case 15:
return '\0'.charCodeAt(0)
default:
throw "invalid nibble: " + value
}
}
unpackByte (tag, value) {
if (tag === WATags.NIBBLE_8) {
return this.unpackNibble(value)
} else if (tag === WATags.HEX_8) {
return this.unpackHex(value)
} else {
throw "unknown tag: " + tag
}
}
readPacked8(tag) {
const startByte = this.readByte()
let value = ""
for (var i = 0; i < (startByte&127);i++) {
let curByte = this.readByte()
value += String.fromCharCode( this.unpackByte(tag, (curByte&0xF0) >> 4) )
value += String.fromCharCode( this.unpackByte(tag, curByte&0x0F) )
}
if ((startByte >> 7) !== 0) {
value = value.slice(0,-1)
}
return value
}
readRangedVarInt (min, max, description="unknown") {
// value =
throw "WTF"
}
isListTag (tag) {
return tag === WATags.LIST_EMPTY || tag === WATags.LIST_8 || tag === WATags.LIST_16
}
readListSize (tag) {
switch (tag) {
case WATags.LIST_EMPTY:
return 0
case WATags.LIST_8:
return this.readByte()
case WATags.LIST_16:
return this.readInt16()
default:
throw "invalid tag for list size: " + tag
}
}
readStringFromChars (length) {
this.checkEOS(length)
const value = this.buffer.slice(this.index, this.index+length)
this.index += length
return new TextDecoder('utf-8').decode(value)
}
readString (tag) {
if (tag >= 3 && tag <= 235) {
const token = this.getToken(tag)
return token === "s.whatsapp.net" ? "c.us" : token
}
switch (tag) {
case WATags.DICTIONARY_0:
case WATags.DICTIONARY_1:
case WATags.DICTIONARY_2:
case WATags.DICTIONARY_3:
return this.getTokenDouble( tag - WATags.DICTIONARY_0, this.readByte() )
case WATags.LIST_EMPTY:
return null
case WATags.BINARY_8:
return this.readStringFromChars( this.readByte() )
case WATags.BINARY_20:
return this.readStringFromChars( this.readInt20() )
case WATags.BINARY_32:
return this.readStringFromChars( this.readInt32() )
case WATags.JID_PAIR:
const i = this.readString( this.readByte() )
const j = this.readString( this.readByte() )
if (i && j) {
return i + "@" + j
}
throw "invalid jid pair: " + i + ", " + j
case WATags.HEX_8:
case WATags.NIBBLE_8:
return this.readPacked8(tag)
default:
throw "invalid string with tag: " + tag
}
}
readAttributes (n) {
if (n !== 0) {
let attributes = {}
for (var i = 0;i < n;i++) {
const index = this.readString(this.readByte())
const b = this.readByte()
attributes[index] = this.readString(b)
}
return attributes
} else {
return null
}
}
readList (tag) {
let list = Array( this.readListSize(tag) )
for (var i = 0;i < list.length;i++) {
list[i] = this.readNode()
}
return list
}
readBytes (n) {
this.checkEOS(n)
const value = this.buffer.slice(this.index, this.index+n)
this.index += n
return value
}
getToken (index) {
if (index < 3 || index >= WASingleByteTokens.length) {
throw "invalid token index: " + index
}
return WASingleByteTokens[index]
}
getTokenDouble (index1, index2) {
const n = 256*index1 + index2
if (n < 0 || n > WADoubleByteTokens.length) {
throw "invalid double token index: " + n
}
return WADoubleByteTokens[n]
}
readNode () {
const listSize = this.readListSize( this.readByte() )
const descrTag = this.readByte()
if (descrTag === WATags.STREAM_END) {
throw "unexpected stream end"
}
const descr = this.readString(descrTag)
if (listSize === 0 || !descr) {
throw "invalid node"
}
//console.log(descr + "," + listSize)
let attrs = this.readAttributes( (listSize-1) >> 1 )
let content = null
if (listSize%2 === 0) {
const tag = this.readByte()
if (this.isListTag(tag)) {
content = this.readList(tag)
} else {
switch (tag) {
case WATags.BINARY_8:
content = this.readBytes( this.readByte() )
break
case WATags.BINARY_20:
content = this.readBytes( this.readInt20() )
break
case WATags.BINARY_32:
content = this.readBytes( this.readInt32() )
break
default:
content = this.readString(tag)
break
}
}
}
//console.log( descr + "," + JSON.stringify(attrs) + ", " + content)
return [descr, attrs, content]
}
read (buffer) {
this.buffer = buffer
this.index = 0
let node = this.readNode()
if (node[2]) {
for (var i = 0; i < node[2].length;i++) {
if (node[2][0][0] === "message") {
node[2][i][2] = WebMessageInfo.decode( node[2][i][2] )
}
}
}
return node
}
}
module.exports = { Encoder: WhatsAppBinaryEncoder, Decoder: WhatsAppBinaryDecoder }

671
binary_coding/def.proto Normal file
View File

@@ -0,0 +1,671 @@
syntax = "proto2";
package proto;
message HydratedQuickReplyButton {
optional string displayText = 1;
optional string id = 2;
}
message HydratedURLButton {
optional string displayText = 1;
optional string url = 2;
}
message HydratedCallButton {
optional string displayText = 1;
optional string phoneNumber = 2;
}
message HydratedTemplateButton {
optional uint32 index = 4;
oneof hydratedButton {
HydratedQuickReplyButton quickReplyButton = 1;
HydratedURLButton urlButton = 2;
HydratedCallButton callButton = 3;
}
}
message QuickReplyButton {
optional HighlyStructuredMessage displayText = 1;
optional string id = 2;
}
message URLButton {
optional HighlyStructuredMessage displayText = 1;
optional HighlyStructuredMessage url = 2;
}
message CallButton {
optional HighlyStructuredMessage displayText = 1;
optional HighlyStructuredMessage phoneNumber = 2;
}
message TemplateButton {
optional uint32 index = 4;
oneof button {
QuickReplyButton quickReplyButton = 1;
URLButton urlButton = 2;
CallButton callButton = 3;
}
}
message Location {
optional double degreesLatitude = 1;
optional double degreesLongitude = 2;
optional string name = 3;
}
message Point {
optional double x = 3;
optional double y = 4;
}
message InteractiveAnnotation {
repeated Point polygonVertices = 1;
oneof action {
Location location = 2;
}
}
message AdReplyInfo {
optional string advertiserName = 1;
enum AD_REPLY_INFO_MEDIATYPE {
NONE = 0;
IMAGE = 1;
VIDEO = 2;
}
optional AD_REPLY_INFO_MEDIATYPE mediaType = 2;
optional bytes jpegThumbnail = 16;
optional string caption = 17;
}
message ContextInfo {
optional string stanzaId = 1;
optional string participant = 2;
optional Message quotedMessage = 3;
optional string remoteJid = 4;
repeated string mentionedJid = 15;
optional string conversionSource = 18;
optional bytes conversionData = 19;
optional uint32 conversionDelaySeconds = 20;
optional uint32 forwardingScore = 21;
optional bool isForwarded = 22;
optional AdReplyInfo quotedAd = 23;
optional MessageKey placeholderKey = 24;
optional uint32 expiration = 25;
}
message SenderKeyDistributionMessage {
optional string groupId = 1;
optional bytes axolotlSenderKeyDistributionMessage = 2;
}
message ImageMessage {
optional string url = 1;
optional string mimetype = 2;
optional string caption = 3;
optional bytes fileSha256 = 4;
optional uint64 fileLength = 5;
optional uint32 height = 6;
optional uint32 width = 7;
optional bytes mediaKey = 8;
optional bytes fileEncSha256 = 9;
repeated InteractiveAnnotation interactiveAnnotations = 10;
optional string directPath = 11;
optional int64 mediaKeyTimestamp = 12;
optional bytes jpegThumbnail = 16;
optional ContextInfo contextInfo = 17;
optional bytes firstScanSidecar = 18;
optional uint32 firstScanLength = 19;
optional uint32 experimentGroupId = 20;
optional bytes scansSidecar = 21;
repeated uint32 scanLengths = 22;
optional bytes midQualityFileSha256 = 23;
optional bytes midQualityFileEncSha256 = 24;
}
message ContactMessage {
optional string displayName = 1;
optional string vcard = 16;
optional ContextInfo contextInfo = 17;
}
message LocationMessage {
optional double degreesLatitude = 1;
optional double degreesLongitude = 2;
optional string name = 3;
optional string address = 4;
optional string url = 5;
optional bytes jpegThumbnail = 16;
optional ContextInfo contextInfo = 17;
}
message ExtendedTextMessage {
optional string text = 1;
optional string matchedText = 2;
optional string canonicalUrl = 4;
optional string description = 5;
optional string title = 6;
optional fixed32 textArgb = 7;
optional fixed32 backgroundArgb = 8;
enum EXTENDED_TEXT_MESSAGE_FONTTYPE {
SANS_SERIF = 0;
SERIF = 1;
NORICAN_REGULAR = 2;
BRYNDAN_WRITE = 3;
BEBASNEUE_REGULAR = 4;
OSWALD_HEAVY = 5;
}
optional EXTENDED_TEXT_MESSAGE_FONTTYPE font = 9;
enum EXTENDED_TEXT_MESSAGE_PREVIEWTYPE {
NONE = 0;
VIDEO = 1;
}
optional EXTENDED_TEXT_MESSAGE_PREVIEWTYPE previewType = 10;
optional bytes jpegThumbnail = 16;
optional ContextInfo contextInfo = 17;
optional bool doNotPlayInline = 18;
}
message DocumentMessage {
optional string url = 1;
optional string mimetype = 2;
optional string title = 3;
optional bytes fileSha256 = 4;
optional uint64 fileLength = 5;
optional uint32 pageCount = 6;
optional bytes mediaKey = 7;
optional string fileName = 8;
optional bytes fileEncSha256 = 9;
optional string directPath = 10;
optional int64 mediaKeyTimestamp = 11;
optional bytes jpegThumbnail = 16;
optional ContextInfo contextInfo = 17;
}
message AudioMessage {
optional string url = 1;
optional string mimetype = 2;
optional bytes fileSha256 = 3;
optional uint64 fileLength = 4;
optional uint32 seconds = 5;
optional bool ptt = 6;
optional bytes mediaKey = 7;
optional bytes fileEncSha256 = 8;
optional string directPath = 9;
optional int64 mediaKeyTimestamp = 10;
optional ContextInfo contextInfo = 17;
optional bytes streamingSidecar = 18;
}
message VideoMessage {
optional string url = 1;
optional string mimetype = 2;
optional bytes fileSha256 = 3;
optional uint64 fileLength = 4;
optional uint32 seconds = 5;
optional bytes mediaKey = 6;
optional string caption = 7;
optional bool gifPlayback = 8;
optional uint32 height = 9;
optional uint32 width = 10;
optional bytes fileEncSha256 = 11;
repeated InteractiveAnnotation interactiveAnnotations = 12;
optional string directPath = 13;
optional int64 mediaKeyTimestamp = 14;
optional bytes jpegThumbnail = 16;
optional ContextInfo contextInfo = 17;
optional bytes streamingSidecar = 18;
enum VIDEO_MESSAGE_ATTRIBUTION {
NONE = 0;
GIPHY = 1;
TENOR = 2;
}
optional VIDEO_MESSAGE_ATTRIBUTION gifAttribution = 19;
}
message Call {
optional bytes callKey = 1;
}
message Chat {
optional string displayName = 1;
optional string id = 2;
}
message ProtocolMessage {
optional MessageKey key = 1;
enum PROTOCOL_MESSAGE_TYPE {
REVOKE = 0;
EPHEMERAL_SETTING = 3;
}
optional PROTOCOL_MESSAGE_TYPE type = 2;
optional uint32 ephemeralExpiration = 4;
}
message ContactsArrayMessage {
optional string displayName = 1;
repeated ContactMessage contacts = 2;
optional ContextInfo contextInfo = 17;
}
message HSMCurrency {
optional string currencyCode = 1;
optional int64 amount1000 = 2;
}
message HSMDateTimeComponent {
enum HSM_DATE_TIME_COMPONENT_DAYOFWEEKTYPE {
MONDAY = 1;
TUESDAY = 2;
WEDNESDAY = 3;
THURSDAY = 4;
FRIDAY = 5;
SATURDAY = 6;
SUNDAY = 7;
}
optional HSM_DATE_TIME_COMPONENT_DAYOFWEEKTYPE dayOfWeek = 1;
optional uint32 year = 2;
optional uint32 month = 3;
optional uint32 dayOfMonth = 4;
optional uint32 hour = 5;
optional uint32 minute = 6;
enum HSM_DATE_TIME_COMPONENT_CALENDARTYPE {
GREGORIAN = 1;
SOLAR_HIJRI = 2;
}
optional HSM_DATE_TIME_COMPONENT_CALENDARTYPE calendar = 7;
}
message HSMDateTimeUnixEpoch {
optional int64 timestamp = 1;
}
message HSMDateTime {
oneof datetimeOneof {
HSMDateTimeComponent component = 1;
HSMDateTimeUnixEpoch unixEpoch = 2;
}
}
message HSMLocalizableParameter {
optional string default = 1;
oneof paramOneof {
HSMCurrency currency = 2;
HSMDateTime dateTime = 3;
}
}
message HighlyStructuredMessage {
optional string namespace = 1;
optional string elementName = 2;
repeated string params = 3;
optional string fallbackLg = 4;
optional string fallbackLc = 5;
repeated HSMLocalizableParameter localizableParams = 6;
optional string deterministicLg = 7;
optional string deterministicLc = 8;
optional TemplateMessage hydratedHsm = 9;
}
message SendPaymentMessage {
optional Message noteMessage = 2;
optional MessageKey requestMessageKey = 3;
}
message RequestPaymentMessage {
optional Message noteMessage = 4;
optional string currencyCodeIso4217 = 1;
optional uint64 amount1000 = 2;
optional string requestFrom = 3;
optional int64 expiryTimestamp = 5;
}
message DeclinePaymentRequestMessage {
optional MessageKey key = 1;
}
message CancelPaymentRequestMessage {
optional MessageKey key = 1;
}
message LiveLocationMessage {
optional double degreesLatitude = 1;
optional double degreesLongitude = 2;
optional uint32 accuracyInMeters = 3;
optional float speedInMps = 4;
optional uint32 degreesClockwiseFromMagneticNorth = 5;
optional string caption = 6;
optional int64 sequenceNumber = 7;
optional uint32 timeOffset = 8;
optional bytes jpegThumbnail = 16;
optional ContextInfo contextInfo = 17;
}
message StickerMessage {
optional string url = 1;
optional bytes fileSha256 = 2;
optional bytes fileEncSha256 = 3;
optional bytes mediaKey = 4;
optional string mimetype = 5;
optional uint32 height = 6;
optional uint32 width = 7;
optional string directPath = 8;
optional uint64 fileLength = 9;
optional int64 mediaKeyTimestamp = 10;
optional uint32 firstFrameLength = 11;
optional bytes firstFrameSidecar = 12;
optional ContextInfo contextInfo = 17;
}
message FourRowTemplate {
optional HighlyStructuredMessage content = 6;
optional HighlyStructuredMessage footer = 7;
repeated TemplateButton buttons = 8;
oneof title {
DocumentMessage documentMessage = 1;
HighlyStructuredMessage highlyStructuredMessage = 2;
ImageMessage imageMessage = 3;
VideoMessage videoMessage = 4;
LocationMessage locationMessage = 5;
}
}
message HydratedFourRowTemplate {
optional string hydratedContentText = 6;
optional string hydratedFooterText = 7;
repeated HydratedTemplateButton hydratedButtons = 8;
optional string templateId = 9;
oneof title {
DocumentMessage documentMessage = 1;
string hydratedTitleText = 2;
ImageMessage imageMessage = 3;
VideoMessage videoMessage = 4;
LocationMessage locationMessage = 5;
}
}
message TemplateMessage {
optional ContextInfo contextInfo = 3;
optional HydratedFourRowTemplate hydratedTemplate = 4;
oneof format {
FourRowTemplate fourRowTemplate = 1;
HydratedFourRowTemplate hydratedFourRowTemplate = 2;
}
}
message TemplateButtonReplyMessage {
optional string selectedId = 1;
optional string selectedDisplayText = 2;
optional ContextInfo contextInfo = 3;
optional uint32 selectedIndex = 4;
}
message ProductSnapshot {
optional ImageMessage productImage = 1;
optional string productId = 2;
optional string title = 3;
optional string description = 4;
optional string currencyCode = 5;
optional int64 priceAmount1000 = 6;
optional string retailerId = 7;
optional string url = 8;
optional uint32 productImageCount = 9;
optional string firstImageId = 11;
}
message ProductMessage {
optional ProductSnapshot product = 1;
optional string businessOwnerJid = 2;
optional ContextInfo contextInfo = 17;
}
message GroupInviteMessage {
optional string groupJid = 1;
optional string inviteCode = 2;
optional int64 inviteExpiration = 3;
optional string groupName = 4;
optional bytes jpegThumbnail = 5;
optional string caption = 6;
optional ContextInfo contextInfo = 7;
}
message DeviceSentMessage {
optional string destinationJid = 1;
optional Message message = 2;
}
message DeviceSyncMessage {
optional bytes serializedXmlBytes = 1;
}
message Message {
optional string conversation = 1;
optional SenderKeyDistributionMessage senderKeyDistributionMessage = 2;
optional ImageMessage imageMessage = 3;
optional ContactMessage contactMessage = 4;
optional LocationMessage locationMessage = 5;
optional ExtendedTextMessage extendedTextMessage = 6;
optional DocumentMessage documentMessage = 7;
optional AudioMessage audioMessage = 8;
optional VideoMessage videoMessage = 9;
optional Call call = 10;
optional Chat chat = 11;
optional ProtocolMessage protocolMessage = 12;
optional ContactsArrayMessage contactsArrayMessage = 13;
optional HighlyStructuredMessage highlyStructuredMessage = 14;
optional SenderKeyDistributionMessage fastRatchetKeySenderKeyDistributionMessage = 15;
optional SendPaymentMessage sendPaymentMessage = 16;
optional LiveLocationMessage liveLocationMessage = 18;
optional RequestPaymentMessage requestPaymentMessage = 22;
optional DeclinePaymentRequestMessage declinePaymentRequestMessage = 23;
optional CancelPaymentRequestMessage cancelPaymentRequestMessage = 24;
optional TemplateMessage templateMessage = 25;
optional StickerMessage stickerMessage = 26;
optional GroupInviteMessage groupInviteMessage = 28;
optional TemplateButtonReplyMessage templateButtonReplyMessage = 29;
optional ProductMessage productMessage = 30;
optional DeviceSentMessage deviceSentMessage = 31;
optional DeviceSyncMessage deviceSyncMessage = 32;
}
message MessageKey {
optional string remoteJid = 1;
optional bool fromMe = 2;
optional string id = 3;
optional string participant = 4;
}
message WebFeatures {
enum WEB_FEATURES_FLAG {
NOT_STARTED = 0;
FORCE_UPGRADE = 1;
DEVELOPMENT = 2;
PRODUCTION = 3;
}
optional WEB_FEATURES_FLAG labelsDisplay = 1;
optional WEB_FEATURES_FLAG voipIndividualOutgoing = 2;
optional WEB_FEATURES_FLAG groupsV3 = 3;
optional WEB_FEATURES_FLAG groupsV3Create = 4;
optional WEB_FEATURES_FLAG changeNumberV2 = 5;
optional WEB_FEATURES_FLAG queryStatusV3Thumbnail = 6;
optional WEB_FEATURES_FLAG liveLocations = 7;
optional WEB_FEATURES_FLAG queryVname = 8;
optional WEB_FEATURES_FLAG voipIndividualIncoming = 9;
optional WEB_FEATURES_FLAG quickRepliesQuery = 10;
optional WEB_FEATURES_FLAG payments = 11;
optional WEB_FEATURES_FLAG stickerPackQuery = 12;
optional WEB_FEATURES_FLAG liveLocationsFinal = 13;
optional WEB_FEATURES_FLAG labelsEdit = 14;
optional WEB_FEATURES_FLAG mediaUpload = 15;
optional WEB_FEATURES_FLAG mediaUploadRichQuickReplies = 18;
optional WEB_FEATURES_FLAG vnameV2 = 19;
optional WEB_FEATURES_FLAG videoPlaybackUrl = 20;
optional WEB_FEATURES_FLAG statusRanking = 21;
optional WEB_FEATURES_FLAG voipIndividualVideo = 22;
optional WEB_FEATURES_FLAG thirdPartyStickers = 23;
optional WEB_FEATURES_FLAG frequentlyForwardedSetting = 24;
optional WEB_FEATURES_FLAG groupsV4JoinPermission = 25;
optional WEB_FEATURES_FLAG recentStickers = 26;
optional WEB_FEATURES_FLAG catalog = 27;
optional WEB_FEATURES_FLAG starredStickers = 28;
optional WEB_FEATURES_FLAG voipGroupCall = 29;
optional WEB_FEATURES_FLAG templateMessage = 30;
optional WEB_FEATURES_FLAG templateMessageInteractivity = 31;
optional WEB_FEATURES_FLAG ephemeralMessages = 32;
}
message TabletNotificationsInfo {
optional uint64 timestamp = 2;
optional uint32 unreadChats = 3;
optional uint32 notifyMessageCount = 4;
repeated NotificationMessageInfo notifyMessage = 5;
}
message NotificationMessageInfo {
optional MessageKey key = 1;
optional Message message = 2;
optional uint64 messageTimestamp = 3;
optional string participant = 4;
}
message WebNotificationsInfo {
optional uint64 timestamp = 2;
optional uint32 unreadChats = 3;
optional uint32 notifyMessageCount = 4;
repeated WebMessageInfo notifyMessages = 5;
}
message PaymentInfo {
optional uint64 amount1000 = 2;
optional string receiverJid = 3;
enum PAYMENT_INFO_STATUS {
UNKNOWN_STATUS = 0;
PROCESSING = 1;
SENT = 2;
NEED_TO_ACCEPT = 3;
COMPLETE = 4;
COULD_NOT_COMPLETE = 5;
REFUNDED = 6;
EXPIRED = 7;
REJECTED = 8;
CANCELLED = 9;
WAITING_FOR_PAYER = 10;
WAITING = 11;
}
optional PAYMENT_INFO_STATUS status = 4;
optional uint64 transactionTimestamp = 5;
optional MessageKey requestMessageKey = 6;
optional uint64 expiryTimestamp = 7;
optional bool futureproofed = 8;
optional string currency = 9;
}
message WebMessageInfo {
required MessageKey key = 1;
optional Message message = 2;
optional uint64 messageTimestamp = 3;
enum WEB_MESSAGE_INFO_STATUS {
ERROR = 0;
PENDING = 1;
SERVER_ACK = 2;
DELIVERY_ACK = 3;
READ = 4;
PLAYED = 5;
}
optional WEB_MESSAGE_INFO_STATUS status = 4;
optional string participant = 5;
optional bool ignore = 16;
optional bool starred = 17;
optional bool broadcast = 18;
optional string pushName = 19;
optional bytes mediaCiphertextSha256 = 20;
optional bool multicast = 21;
optional bool urlText = 22;
optional bool urlNumber = 23;
enum WEB_MESSAGE_INFO_STUBTYPE {
UNKNOWN = 0;
REVOKE = 1;
CIPHERTEXT = 2;
FUTUREPROOF = 3;
NON_VERIFIED_TRANSITION = 4;
UNVERIFIED_TRANSITION = 5;
VERIFIED_TRANSITION = 6;
VERIFIED_LOW_UNKNOWN = 7;
VERIFIED_HIGH = 8;
VERIFIED_INITIAL_UNKNOWN = 9;
VERIFIED_INITIAL_LOW = 10;
VERIFIED_INITIAL_HIGH = 11;
VERIFIED_TRANSITION_ANY_TO_NONE = 12;
VERIFIED_TRANSITION_ANY_TO_HIGH = 13;
VERIFIED_TRANSITION_HIGH_TO_LOW = 14;
VERIFIED_TRANSITION_HIGH_TO_UNKNOWN = 15;
VERIFIED_TRANSITION_UNKNOWN_TO_LOW = 16;
VERIFIED_TRANSITION_LOW_TO_UNKNOWN = 17;
VERIFIED_TRANSITION_NONE_TO_LOW = 18;
VERIFIED_TRANSITION_NONE_TO_UNKNOWN = 19;
GROUP_CREATE = 20;
GROUP_CHANGE_SUBJECT = 21;
GROUP_CHANGE_ICON = 22;
GROUP_CHANGE_INVITE_LINK = 23;
GROUP_CHANGE_DESCRIPTION = 24;
GROUP_CHANGE_RESTRICT = 25;
GROUP_CHANGE_ANNOUNCE = 26;
GROUP_PARTICIPANT_ADD = 27;
GROUP_PARTICIPANT_REMOVE = 28;
GROUP_PARTICIPANT_PROMOTE = 29;
GROUP_PARTICIPANT_DEMOTE = 30;
GROUP_PARTICIPANT_INVITE = 31;
GROUP_PARTICIPANT_LEAVE = 32;
GROUP_PARTICIPANT_CHANGE_NUMBER = 33;
BROADCAST_CREATE = 34;
BROADCAST_ADD = 35;
BROADCAST_REMOVE = 36;
GENERIC_NOTIFICATION = 37;
E2E_IDENTITY_CHANGED = 38;
E2E_ENCRYPTED = 39;
CALL_MISSED_VOICE = 40;
CALL_MISSED_VIDEO = 41;
INDIVIDUAL_CHANGE_NUMBER = 42;
GROUP_DELETE = 43;
GROUP_ANNOUNCE_MODE_MESSAGE_BOUNCE = 44;
CALL_MISSED_GROUP_VOICE = 45;
CALL_MISSED_GROUP_VIDEO = 46;
PAYMENT_CIPHERTEXT = 47;
PAYMENT_FUTUREPROOF = 48;
PAYMENT_TRANSACTION_STATUS_UPDATE_FAILED = 49;
PAYMENT_TRANSACTION_STATUS_UPDATE_REFUNDED = 50;
PAYMENT_TRANSACTION_STATUS_UPDATE_REFUND_FAILED = 51;
PAYMENT_TRANSACTION_STATUS_RECEIVER_PENDING_SETUP = 52;
PAYMENT_TRANSACTION_STATUS_RECEIVER_SUCCESS_AFTER_HICCUP = 53;
PAYMENT_ACTION_ACCOUNT_SETUP_REMINDER = 54;
PAYMENT_ACTION_SEND_PAYMENT_REMINDER = 55;
PAYMENT_ACTION_SEND_PAYMENT_INVITATION = 56;
PAYMENT_ACTION_REQUEST_DECLINED = 57;
PAYMENT_ACTION_REQUEST_EXPIRED = 58;
PAYMENT_ACTION_REQUEST_CANCELLED = 59;
BIZ_VERIFIED_TRANSITION_TOP_TO_BOTTOM = 60;
BIZ_VERIFIED_TRANSITION_BOTTOM_TO_TOP = 61;
BIZ_INTRO_TOP = 62;
BIZ_INTRO_BOTTOM = 63;
BIZ_NAME_CHANGE = 64;
BIZ_MOVE_TO_CONSUMER_APP = 65;
BIZ_TWO_TIER_MIGRATION_TOP = 66;
BIZ_TWO_TIER_MIGRATION_BOTTOM = 67;
OVERSIZED = 68;
GROUP_CHANGE_NO_FREQUENTLY_FORWARDED = 69;
GROUP_V4_ADD_INVITE_SENT = 70;
GROUP_PARTICIPANT_ADD_REQUEST_JOIN = 71;
CHANGE_EPHEMERAL_SETTING = 72;
}
optional WEB_MESSAGE_INFO_STUBTYPE messageStubType = 24;
optional bool clearMedia = 25;
repeated string messageStubParameters = 26;
optional uint32 duration = 27;
repeated string labels = 28;
optional PaymentInfo paymentInfo = 29;
optional LiveLocationMessage finalLiveLocation = 30;
optional PaymentInfo quotedPaymentInfo = 31;
optional uint64 ephemeralStartTimestamp = 32;
optional uint32 ephemeralDuration = 33;
}

File diff suppressed because it is too large Load Diff

BIN
node_modules/.DS_Store generated vendored Normal file

Binary file not shown.

1
node_modules/.bin/pbjs generated vendored Symbolic link
View File

@@ -0,0 +1 @@
../protobufjs/bin/pbjs

1
node_modules/.bin/pbts generated vendored Symbolic link
View File

@@ -0,0 +1 @@
../protobufjs/bin/pbts

1
node_modules/.bin/qrcode-terminal generated vendored Symbolic link
View File

@@ -0,0 +1 @@
../qrcode-terminal/bin/qrcode-terminal.js

26
node_modules/@protobufjs/aspromise/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,26 @@
Copyright (c) 2016, Daniel Wirtz All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of its author, nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

13
node_modules/@protobufjs/aspromise/README.md generated vendored Normal file
View File

@@ -0,0 +1,13 @@
@protobufjs/aspromise
=====================
[![npm](https://img.shields.io/npm/v/@protobufjs/aspromise.svg)](https://www.npmjs.com/package/@protobufjs/aspromise)
Returns a promise from a node-style callback function.
API
---
* **asPromise(fn: `function`, ctx: `Object`, ...params: `*`): `Promise<*>`**<br />
Returns a promise from a node-style callback function.
**License:** [BSD 3-Clause License](https://opensource.org/licenses/BSD-3-Clause)

13
node_modules/@protobufjs/aspromise/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,13 @@
export = asPromise;
type asPromiseCallback = (error: Error | null, ...params: any[]) => {};
/**
* Returns a promise from a node-style callback function.
* @memberof util
* @param {asPromiseCallback} fn Function to call
* @param {*} ctx Function context
* @param {...*} params Function arguments
* @returns {Promise<*>} Promisified function
*/
declare function asPromise(fn: asPromiseCallback, ctx: any, ...params: any[]): Promise<any>;

52
node_modules/@protobufjs/aspromise/index.js generated vendored Normal file
View File

@@ -0,0 +1,52 @@
"use strict";
module.exports = asPromise;
/**
* Callback as used by {@link util.asPromise}.
* @typedef asPromiseCallback
* @type {function}
* @param {Error|null} error Error, if any
* @param {...*} params Additional arguments
* @returns {undefined}
*/
/**
* Returns a promise from a node-style callback function.
* @memberof util
* @param {asPromiseCallback} fn Function to call
* @param {*} ctx Function context
* @param {...*} params Function arguments
* @returns {Promise<*>} Promisified function
*/
function asPromise(fn, ctx/*, varargs */) {
var params = new Array(arguments.length - 1),
offset = 0,
index = 2,
pending = true;
while (index < arguments.length)
params[offset++] = arguments[index++];
return new Promise(function executor(resolve, reject) {
params[offset] = function callback(err/*, varargs */) {
if (pending) {
pending = false;
if (err)
reject(err);
else {
var params = new Array(arguments.length - 1),
offset = 0;
while (offset < params.length)
params[offset++] = arguments[offset];
resolve.apply(null, params);
}
}
};
try {
fn.apply(ctx || null, params);
} catch (err) {
if (pending) {
pending = false;
reject(err);
}
}
});
}

25
node_modules/@protobufjs/aspromise/package.json generated vendored Normal file
View File

@@ -0,0 +1,25 @@
{
"name": "@protobufjs/aspromise",
"description": "Returns a promise from a node-style callback function.",
"version": "1.1.2",
"author": "Daniel Wirtz <dcode+protobufjs@dcode.io>",
"repository": {
"type": "git",
"url": "https://github.com/dcodeIO/protobuf.js.git"
},
"license": "BSD-3-Clause",
"main": "index.js",
"types": "index.d.ts",
"devDependencies": {
"istanbul": "^0.4.5",
"tape": "^4.6.3"
},
"scripts": {
"test": "tape tests/*.js",
"coverage": "istanbul cover node_modules/tape/bin/tape tests/*.js"
}
,"_resolved": "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz"
,"_integrity": "sha1-m4sMxmPWaafY9vXQiToU00jzD78="
,"_from": "@protobufjs/aspromise@1.1.2"
}

130
node_modules/@protobufjs/aspromise/tests/index.js generated vendored Normal file
View File

@@ -0,0 +1,130 @@
var tape = require("tape");
var asPromise = require("..");
tape.test("aspromise", function(test) {
test.test(this.name + " - resolve", function(test) {
function fn(arg1, arg2, callback) {
test.equal(this, ctx, "function should be called with this = ctx");
test.equal(arg1, 1, "function should be called with arg1 = 1");
test.equal(arg2, 2, "function should be called with arg2 = 2");
callback(null, arg2);
}
var ctx = {};
var promise = asPromise(fn, ctx, 1, 2);
promise.then(function(arg2) {
test.equal(arg2, 2, "promise should be resolved with arg2 = 2");
test.end();
}).catch(function(err) {
test.fail("promise should not be rejected (" + err + ")");
});
});
test.test(this.name + " - reject", function(test) {
function fn(arg1, arg2, callback) {
test.equal(this, ctx, "function should be called with this = ctx");
test.equal(arg1, 1, "function should be called with arg1 = 1");
test.equal(arg2, 2, "function should be called with arg2 = 2");
callback(arg1);
}
var ctx = {};
var promise = asPromise(fn, ctx, 1, 2);
promise.then(function() {
test.fail("promise should not be resolved");
}).catch(function(err) {
test.equal(err, 1, "promise should be rejected with err = 1");
test.end();
});
});
test.test(this.name + " - resolve twice", function(test) {
function fn(arg1, arg2, callback) {
test.equal(this, ctx, "function should be called with this = ctx");
test.equal(arg1, 1, "function should be called with arg1 = 1");
test.equal(arg2, 2, "function should be called with arg2 = 2");
callback(null, arg2);
callback(null, arg1);
}
var ctx = {};
var count = 0;
var promise = asPromise(fn, ctx, 1, 2);
promise.then(function(arg2) {
test.equal(arg2, 2, "promise should be resolved with arg2 = 2");
if (++count > 1)
test.fail("promise should not be resolved twice");
test.end();
}).catch(function(err) {
test.fail("promise should not be rejected (" + err + ")");
});
});
test.test(this.name + " - reject twice", function(test) {
function fn(arg1, arg2, callback) {
test.equal(this, ctx, "function should be called with this = ctx");
test.equal(arg1, 1, "function should be called with arg1 = 1");
test.equal(arg2, 2, "function should be called with arg2 = 2");
callback(arg1);
callback(arg2);
}
var ctx = {};
var count = 0;
var promise = asPromise(fn, ctx, 1, 2);
promise.then(function() {
test.fail("promise should not be resolved");
}).catch(function(err) {
test.equal(err, 1, "promise should be rejected with err = 1");
if (++count > 1)
test.fail("promise should not be rejected twice");
test.end();
});
});
test.test(this.name + " - reject error", function(test) {
function fn(callback) {
test.ok(arguments.length === 1 && typeof callback === "function", "function should be called with just a callback");
throw 3;
}
var promise = asPromise(fn, null);
promise.then(function() {
test.fail("promise should not be resolved");
}).catch(function(err) {
test.equal(err, 3, "promise should be rejected with err = 3");
test.end();
});
});
test.test(this.name + " - reject and error", function(test) {
function fn(callback) {
callback(3);
throw 4;
}
var count = 0;
var promise = asPromise(fn, null);
promise.then(function() {
test.fail("promise should not be resolved");
}).catch(function(err) {
test.equal(err, 3, "promise should be rejected with err = 3");
if (++count > 1)
test.fail("promise should not be rejected twice");
test.end();
});
});
});

26
node_modules/@protobufjs/base64/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,26 @@
Copyright (c) 2016, Daniel Wirtz All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of its author, nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

19
node_modules/@protobufjs/base64/README.md generated vendored Normal file
View File

@@ -0,0 +1,19 @@
@protobufjs/base64
==================
[![npm](https://img.shields.io/npm/v/@protobufjs/base64.svg)](https://www.npmjs.com/package/@protobufjs/base64)
A minimal base64 implementation for number arrays.
API
---
* **base64.length(string: `string`): `number`**<br />
Calculates the byte length of a base64 encoded string.
* **base64.encode(buffer: `Uint8Array`, start: `number`, end: `number`): `string`**<br />
Encodes a buffer to a base64 encoded string.
* **base64.decode(string: `string`, buffer: `Uint8Array`, offset: `number`): `number`**<br />
Decodes a base64 encoded string to a buffer.
**License:** [BSD 3-Clause License](https://opensource.org/licenses/BSD-3-Clause)

32
node_modules/@protobufjs/base64/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,32 @@
/**
* Calculates the byte length of a base64 encoded string.
* @param {string} string Base64 encoded string
* @returns {number} Byte length
*/
export function length(string: string): number;
/**
* Encodes a buffer to a base64 encoded string.
* @param {Uint8Array} buffer Source buffer
* @param {number} start Source start
* @param {number} end Source end
* @returns {string} Base64 encoded string
*/
export function encode(buffer: Uint8Array, start: number, end: number): string;
/**
* Decodes a base64 encoded string to a buffer.
* @param {string} string Source string
* @param {Uint8Array} buffer Destination buffer
* @param {number} offset Destination offset
* @returns {number} Number of bytes written
* @throws {Error} If encoding is invalid
*/
export function decode(string: string, buffer: Uint8Array, offset: number): number;
/**
* Tests if the specified string appears to be base64 encoded.
* @param {string} string String to test
* @returns {boolean} `true` if it appears to be base64 encoded, otherwise false
*/
export function test(string: string): boolean;

139
node_modules/@protobufjs/base64/index.js generated vendored Normal file
View File

@@ -0,0 +1,139 @@
"use strict";
/**
* A minimal base64 implementation for number arrays.
* @memberof util
* @namespace
*/
var base64 = exports;
/**
* Calculates the byte length of a base64 encoded string.
* @param {string} string Base64 encoded string
* @returns {number} Byte length
*/
base64.length = function length(string) {
var p = string.length;
if (!p)
return 0;
var n = 0;
while (--p % 4 > 1 && string.charAt(p) === "=")
++n;
return Math.ceil(string.length * 3) / 4 - n;
};
// Base64 encoding table
var b64 = new Array(64);
// Base64 decoding table
var s64 = new Array(123);
// 65..90, 97..122, 48..57, 43, 47
for (var i = 0; i < 64;)
s64[b64[i] = i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i - 59 | 43] = i++;
/**
* Encodes a buffer to a base64 encoded string.
* @param {Uint8Array} buffer Source buffer
* @param {number} start Source start
* @param {number} end Source end
* @returns {string} Base64 encoded string
*/
base64.encode = function encode(buffer, start, end) {
var parts = null,
chunk = [];
var i = 0, // output index
j = 0, // goto index
t; // temporary
while (start < end) {
var b = buffer[start++];
switch (j) {
case 0:
chunk[i++] = b64[b >> 2];
t = (b & 3) << 4;
j = 1;
break;
case 1:
chunk[i++] = b64[t | b >> 4];
t = (b & 15) << 2;
j = 2;
break;
case 2:
chunk[i++] = b64[t | b >> 6];
chunk[i++] = b64[b & 63];
j = 0;
break;
}
if (i > 8191) {
(parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
i = 0;
}
}
if (j) {
chunk[i++] = b64[t];
chunk[i++] = 61;
if (j === 1)
chunk[i++] = 61;
}
if (parts) {
if (i)
parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
return parts.join("");
}
return String.fromCharCode.apply(String, chunk.slice(0, i));
};
var invalidEncoding = "invalid encoding";
/**
* Decodes a base64 encoded string to a buffer.
* @param {string} string Source string
* @param {Uint8Array} buffer Destination buffer
* @param {number} offset Destination offset
* @returns {number} Number of bytes written
* @throws {Error} If encoding is invalid
*/
base64.decode = function decode(string, buffer, offset) {
var start = offset;
var j = 0, // goto index
t; // temporary
for (var i = 0; i < string.length;) {
var c = string.charCodeAt(i++);
if (c === 61 && j > 1)
break;
if ((c = s64[c]) === undefined)
throw Error(invalidEncoding);
switch (j) {
case 0:
t = c;
j = 1;
break;
case 1:
buffer[offset++] = t << 2 | (c & 48) >> 4;
t = c;
j = 2;
break;
case 2:
buffer[offset++] = (t & 15) << 4 | (c & 60) >> 2;
t = c;
j = 3;
break;
case 3:
buffer[offset++] = (t & 3) << 6 | c;
j = 0;
break;
}
}
if (j === 1)
throw Error(invalidEncoding);
return offset - start;
};
/**
* Tests if the specified string appears to be base64 encoded.
* @param {string} string String to test
* @returns {boolean} `true` if probably base64 encoded, otherwise false
*/
base64.test = function test(string) {
return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(string);
};

25
node_modules/@protobufjs/base64/package.json generated vendored Normal file
View File

@@ -0,0 +1,25 @@
{
"name": "@protobufjs/base64",
"description": "A minimal base64 implementation for number arrays.",
"version": "1.1.2",
"author": "Daniel Wirtz <dcode+protobufjs@dcode.io>",
"repository": {
"type": "git",
"url": "https://github.com/dcodeIO/protobuf.js.git"
},
"license": "BSD-3-Clause",
"main": "index.js",
"types": "index.d.ts",
"devDependencies": {
"istanbul": "^0.4.5",
"tape": "^4.6.3"
},
"scripts": {
"test": "tape tests/*.js",
"coverage": "istanbul cover node_modules/tape/bin/tape tests/*.js"
}
,"_resolved": "https://registry.npmjs.org/@protobufjs/base64/-/base64-1.1.2.tgz"
,"_integrity": "sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg=="
,"_from": "@protobufjs/base64@1.1.2"
}

46
node_modules/@protobufjs/base64/tests/index.js generated vendored Normal file
View File

@@ -0,0 +1,46 @@
var tape = require("tape");
var base64 = require("..");
var strings = {
"": "",
"a": "YQ==",
"ab": "YWI=",
"abcdefg": "YWJjZGVmZw==",
"abcdefgh": "YWJjZGVmZ2g=",
"abcdefghi": "YWJjZGVmZ2hp"
};
tape.test("base64", function(test) {
Object.keys(strings).forEach(function(str) {
var enc = strings[str];
test.equal(base64.test(enc), true, "should detect '" + enc + "' to be base64 encoded");
var len = base64.length(enc);
test.equal(len, str.length, "should calculate '" + enc + "' as " + str.length + " bytes");
var buf = new Array(len);
var len2 = base64.decode(enc, buf, 0);
test.equal(len2, len, "should decode '" + enc + "' to " + len + " bytes");
test.equal(String.fromCharCode.apply(String, buf), str, "should decode '" + enc + "' to '" + str + "'");
var enc2 = base64.encode(buf, 0, buf.length);
test.equal(enc2, enc, "should encode '" + str + "' to '" + enc + "'");
});
test.throws(function() {
var buf = new Array(10);
base64.decode("YQ!", buf, 0);
}, Error, "should throw if encoding is invalid");
test.throws(function() {
var buf = new Array(10);
base64.decode("Y", buf, 0);
}, Error, "should throw if string is truncated");
test.end();
});

26
node_modules/@protobufjs/codegen/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,26 @@
Copyright (c) 2016, Daniel Wirtz All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of its author, nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

49
node_modules/@protobufjs/codegen/README.md generated vendored Normal file
View File

@@ -0,0 +1,49 @@
@protobufjs/codegen
===================
[![npm](https://img.shields.io/npm/v/@protobufjs/codegen.svg)](https://www.npmjs.com/package/@protobufjs/codegen)
A minimalistic code generation utility.
API
---
* **codegen([functionParams: `string[]`], [functionName: string]): `Codegen`**<br />
Begins generating a function.
* **codegen.verbose = `false`**<br />
When set to true, codegen will log generated code to console. Useful for debugging.
Invoking **codegen** returns an appender function that appends code to the function's body and returns itself:
* **Codegen(formatString: `string`, [...formatParams: `any`]): Codegen**<br />
Appends code to the function's body. The format string can contain placeholders specifying the types of inserted format parameters:
* `%d`: Number (integer or floating point value)
* `%f`: Floating point value
* `%i`: Integer value
* `%j`: JSON.stringify'ed value
* `%s`: String value
* `%%`: Percent sign<br />
* **Codegen([scope: `Object.<string,*>`]): `Function`**<br />
Finishes the function and returns it.
* **Codegen.toString([functionNameOverride: `string`]): `string`**<br />
Returns the function as a string.
Example
-------
```js
var codegen = require("@protobufjs/codegen");
var add = codegen(["a", "b"], "add") // A function with parameters "a" and "b" named "add"
("// awesome comment") // adds the line to the function's body
("return a + b - c + %d", 1) // replaces %d with 1 and adds the line to the body
({ c: 1 }); // adds "c" with a value of 1 to the function's scope
console.log(add.toString()); // function add(a, b) { return a + b - c + 1 }
console.log(add(1, 2)); // calculates 1 + 2 - 1 + 1 = 3
```
**License:** [BSD 3-Clause License](https://opensource.org/licenses/BSD-3-Clause)

31
node_modules/@protobufjs/codegen/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,31 @@
export = codegen;
/**
* Appends code to the function's body.
* @param [formatStringOrScope] Format string or, to finish the function, an object of additional scope variables, if any
* @param [formatParams] Format parameters
* @returns Itself or the generated function if finished
* @throws {Error} If format parameter counts do not match
*/
type Codegen = (formatStringOrScope?: (string|{ [k: string]: any }), ...formatParams: any[]) => (Codegen|Function);
/**
* Begins generating a function.
* @param functionParams Function parameter names
* @param [functionName] Function name if not anonymous
* @returns Appender that appends code to the function's body
*/
declare function codegen(functionParams: string[], functionName?: string): Codegen;
/**
* Begins generating a function.
* @param [functionName] Function name if not anonymous
* @returns Appender that appends code to the function's body
*/
declare function codegen(functionName?: string): Codegen;
declare namespace codegen {
/** When set to `true`, codegen will log generated code to console. Useful for debugging. */
let verbose: boolean;
}

99
node_modules/@protobufjs/codegen/index.js generated vendored Normal file
View File

@@ -0,0 +1,99 @@
"use strict";
module.exports = codegen;
/**
* Begins generating a function.
* @memberof util
* @param {string[]} functionParams Function parameter names
* @param {string} [functionName] Function name if not anonymous
* @returns {Codegen} Appender that appends code to the function's body
*/
function codegen(functionParams, functionName) {
/* istanbul ignore if */
if (typeof functionParams === "string") {
functionName = functionParams;
functionParams = undefined;
}
var body = [];
/**
* Appends code to the function's body or finishes generation.
* @typedef Codegen
* @type {function}
* @param {string|Object.<string,*>} [formatStringOrScope] Format string or, to finish the function, an object of additional scope variables, if any
* @param {...*} [formatParams] Format parameters
* @returns {Codegen|Function} Itself or the generated function if finished
* @throws {Error} If format parameter counts do not match
*/
function Codegen(formatStringOrScope) {
// note that explicit array handling below makes this ~50% faster
// finish the function
if (typeof formatStringOrScope !== "string") {
var source = toString();
if (codegen.verbose)
console.log("codegen: " + source); // eslint-disable-line no-console
source = "return " + source;
if (formatStringOrScope) {
var scopeKeys = Object.keys(formatStringOrScope),
scopeParams = new Array(scopeKeys.length + 1),
scopeValues = new Array(scopeKeys.length),
scopeOffset = 0;
while (scopeOffset < scopeKeys.length) {
scopeParams[scopeOffset] = scopeKeys[scopeOffset];
scopeValues[scopeOffset] = formatStringOrScope[scopeKeys[scopeOffset++]];
}
scopeParams[scopeOffset] = source;
return Function.apply(null, scopeParams).apply(null, scopeValues); // eslint-disable-line no-new-func
}
return Function(source)(); // eslint-disable-line no-new-func
}
// otherwise append to body
var formatParams = new Array(arguments.length - 1),
formatOffset = 0;
while (formatOffset < formatParams.length)
formatParams[formatOffset] = arguments[++formatOffset];
formatOffset = 0;
formatStringOrScope = formatStringOrScope.replace(/%([%dfijs])/g, function replace($0, $1) {
var value = formatParams[formatOffset++];
switch ($1) {
case "d": case "f": return String(Number(value));
case "i": return String(Math.floor(value));
case "j": return JSON.stringify(value);
case "s": return String(value);
}
return "%";
});
if (formatOffset !== formatParams.length)
throw Error("parameter count mismatch");
body.push(formatStringOrScope);
return Codegen;
}
function toString(functionNameOverride) {
return "function " + (functionNameOverride || functionName || "") + "(" + (functionParams && functionParams.join(",") || "") + "){\n " + body.join("\n ") + "\n}";
}
Codegen.toString = toString;
return Codegen;
}
/**
* Begins generating a function.
* @memberof util
* @function codegen
* @param {string} [functionName] Function name if not anonymous
* @returns {Codegen} Appender that appends code to the function's body
* @variation 2
*/
/**
* When set to `true`, codegen will log generated code to console. Useful for debugging.
* @name util.codegen.verbose
* @type {boolean}
*/
codegen.verbose = false;

17
node_modules/@protobufjs/codegen/package.json generated vendored Normal file
View File

@@ -0,0 +1,17 @@
{
"name": "@protobufjs/codegen",
"description": "A minimalistic code generation utility.",
"version": "2.0.4",
"author": "Daniel Wirtz <dcode+protobufjs@dcode.io>",
"repository": {
"type": "git",
"url": "https://github.com/dcodeIO/protobuf.js.git"
},
"license": "BSD-3-Clause",
"main": "index.js",
"types": "index.d.ts"
,"_resolved": "https://registry.npmjs.org/@protobufjs/codegen/-/codegen-2.0.4.tgz"
,"_integrity": "sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg=="
,"_from": "@protobufjs/codegen@2.0.4"
}

13
node_modules/@protobufjs/codegen/tests/index.js generated vendored Normal file
View File

@@ -0,0 +1,13 @@
var codegen = require("..");
// new require("benchmark").Suite().add("add", function() {
var add = codegen(["a", "b"], "add")
("// awesome comment")
("return a + b - c + %d", 1)
({ c: 1 });
if (add(1, 2) !== 3)
throw Error("failed");
// }).on("cycle", function(event) { process.stdout.write(String(event.target) + "\n"); }).run();

26
node_modules/@protobufjs/eventemitter/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,26 @@
Copyright (c) 2016, Daniel Wirtz All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of its author, nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

22
node_modules/@protobufjs/eventemitter/README.md generated vendored Normal file
View File

@@ -0,0 +1,22 @@
@protobufjs/eventemitter
========================
[![npm](https://img.shields.io/npm/v/@protobufjs/eventemitter.svg)](https://www.npmjs.com/package/@protobufjs/eventemitter)
A minimal event emitter.
API
---
* **new EventEmitter()**<br />
Constructs a new event emitter instance.
* **EventEmitter#on(evt: `string`, fn: `function`, [ctx: `Object`]): `EventEmitter`**<br />
Registers an event listener.
* **EventEmitter#off([evt: `string`], [fn: `function`]): `EventEmitter`**<br />
Removes an event listener or any matching listeners if arguments are omitted.
* **EventEmitter#emit(evt: `string`, ...args: `*`): `EventEmitter`**<br />
Emits an event by calling its listeners with the specified arguments.
**License:** [BSD 3-Clause License](https://opensource.org/licenses/BSD-3-Clause)

43
node_modules/@protobufjs/eventemitter/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,43 @@
export = EventEmitter;
/**
* Constructs a new event emitter instance.
* @classdesc A minimal event emitter.
* @memberof util
* @constructor
*/
declare class EventEmitter {
/**
* Constructs a new event emitter instance.
* @classdesc A minimal event emitter.
* @memberof util
* @constructor
*/
constructor();
/**
* Registers an event listener.
* @param {string} evt Event name
* @param {function} fn Listener
* @param {*} [ctx] Listener context
* @returns {util.EventEmitter} `this`
*/
on(evt: string, fn: () => any, ctx?: any): EventEmitter;
/**
* Removes an event listener or any matching listeners if arguments are omitted.
* @param {string} [evt] Event name. Removes all listeners if omitted.
* @param {function} [fn] Listener to remove. Removes all listeners of `evt` if omitted.
* @returns {util.EventEmitter} `this`
*/
off(evt?: string, fn?: () => any): EventEmitter;
/**
* Emits an event by calling its listeners with the specified arguments.
* @param {string} evt Event name
* @param {...*} args Arguments
* @returns {util.EventEmitter} `this`
*/
emit(evt: string, ...args: any[]): EventEmitter;
}

76
node_modules/@protobufjs/eventemitter/index.js generated vendored Normal file
View File

@@ -0,0 +1,76 @@
"use strict";
module.exports = EventEmitter;
/**
* Constructs a new event emitter instance.
* @classdesc A minimal event emitter.
* @memberof util
* @constructor
*/
function EventEmitter() {
/**
* Registered listeners.
* @type {Object.<string,*>}
* @private
*/
this._listeners = {};
}
/**
* Registers an event listener.
* @param {string} evt Event name
* @param {function} fn Listener
* @param {*} [ctx] Listener context
* @returns {util.EventEmitter} `this`
*/
EventEmitter.prototype.on = function on(evt, fn, ctx) {
(this._listeners[evt] || (this._listeners[evt] = [])).push({
fn : fn,
ctx : ctx || this
});
return this;
};
/**
* Removes an event listener or any matching listeners if arguments are omitted.
* @param {string} [evt] Event name. Removes all listeners if omitted.
* @param {function} [fn] Listener to remove. Removes all listeners of `evt` if omitted.
* @returns {util.EventEmitter} `this`
*/
EventEmitter.prototype.off = function off(evt, fn) {
if (evt === undefined)
this._listeners = {};
else {
if (fn === undefined)
this._listeners[evt] = [];
else {
var listeners = this._listeners[evt];
for (var i = 0; i < listeners.length;)
if (listeners[i].fn === fn)
listeners.splice(i, 1);
else
++i;
}
}
return this;
};
/**
* Emits an event by calling its listeners with the specified arguments.
* @param {string} evt Event name
* @param {...*} args Arguments
* @returns {util.EventEmitter} `this`
*/
EventEmitter.prototype.emit = function emit(evt) {
var listeners = this._listeners[evt];
if (listeners) {
var args = [],
i = 1;
for (; i < arguments.length;)
args.push(arguments[i++]);
for (i = 0; i < listeners.length;)
listeners[i].fn.apply(listeners[i++].ctx, args);
}
return this;
};

25
node_modules/@protobufjs/eventemitter/package.json generated vendored Normal file
View File

@@ -0,0 +1,25 @@
{
"name": "@protobufjs/eventemitter",
"description": "A minimal event emitter.",
"version": "1.1.0",
"author": "Daniel Wirtz <dcode+protobufjs@dcode.io>",
"repository": {
"type": "git",
"url": "https://github.com/dcodeIO/protobuf.js.git"
},
"license": "BSD-3-Clause",
"main": "index.js",
"types": "index.d.ts",
"devDependencies": {
"istanbul": "^0.4.5",
"tape": "^4.6.3"
},
"scripts": {
"test": "tape tests/*.js",
"coverage": "istanbul cover node_modules/tape/bin/tape tests/*.js"
}
,"_resolved": "https://registry.npmjs.org/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz"
,"_integrity": "sha1-NVy8mLr61ZePntCV85diHx0Ga3A="
,"_from": "@protobufjs/eventemitter@1.1.0"
}

47
node_modules/@protobufjs/eventemitter/tests/index.js generated vendored Normal file
View File

@@ -0,0 +1,47 @@
var tape = require("tape");
var EventEmitter = require("..");
tape.test("eventemitter", function(test) {
var ee = new EventEmitter();
var fn;
var ctx = {};
test.doesNotThrow(function() {
ee.emit("a", 1);
ee.off();
ee.off("a");
ee.off("a", function() {});
}, "should not throw if no listeners are registered");
test.equal(ee.on("a", function(arg1) {
test.equal(this, ctx, "should be called with this = ctx");
test.equal(arg1, 1, "should be called with arg1 = 1");
}, ctx), ee, "should return itself when registering events");
ee.emit("a", 1);
ee.off("a");
test.same(ee._listeners, { a: [] }, "should remove all listeners of the respective event when calling off(evt)");
ee.off();
test.same(ee._listeners, {}, "should remove all listeners when just calling off()");
ee.on("a", fn = function(arg1) {
test.equal(this, ctx, "should be called with this = ctx");
test.equal(arg1, 1, "should be called with arg1 = 1");
}, ctx).emit("a", 1);
ee.off("a", fn);
test.same(ee._listeners, { a: [] }, "should remove the exact listener when calling off(evt, fn)");
ee.on("a", function() {
test.equal(this, ee, "should be called with this = ee");
}).emit("a");
test.doesNotThrow(function() {
ee.off("a", fn);
}, "should not throw if no such listener is found");
test.end();
});

26
node_modules/@protobufjs/fetch/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,26 @@
Copyright (c) 2016, Daniel Wirtz All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of its author, nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

13
node_modules/@protobufjs/fetch/README.md generated vendored Normal file
View File

@@ -0,0 +1,13 @@
@protobufjs/fetch
=================
[![npm](https://img.shields.io/npm/v/@protobufjs/fetch.svg)](https://www.npmjs.com/package/@protobufjs/fetch)
Fetches the contents of a file accross node and browsers.
API
---
* **fetch(path: `string`, [options: { binary: boolean } ], [callback: `function(error: ?Error, [contents: string])`]): `Promise<string|Uint8Array>|undefined`**
Fetches the contents of a file.
**License:** [BSD 3-Clause License](https://opensource.org/licenses/BSD-3-Clause)

56
node_modules/@protobufjs/fetch/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,56 @@
export = fetch;
/**
* Node-style callback as used by {@link util.fetch}.
* @typedef FetchCallback
* @type {function}
* @param {?Error} error Error, if any, otherwise `null`
* @param {string} [contents] File contents, if there hasn't been an error
* @returns {undefined}
*/
type FetchCallback = (error: Error, contents?: string) => void;
/**
* Options as used by {@link util.fetch}.
* @typedef FetchOptions
* @type {Object}
* @property {boolean} [binary=false] Whether expecting a binary response
* @property {boolean} [xhr=false] If `true`, forces the use of XMLHttpRequest
*/
interface FetchOptions {
binary?: boolean;
xhr?: boolean
}
/**
* Fetches the contents of a file.
* @memberof util
* @param {string} filename File path or url
* @param {FetchOptions} options Fetch options
* @param {FetchCallback} callback Callback function
* @returns {undefined}
*/
declare function fetch(filename: string, options: FetchOptions, callback: FetchCallback): void;
/**
* Fetches the contents of a file.
* @name util.fetch
* @function
* @param {string} path File path or url
* @param {FetchCallback} callback Callback function
* @returns {undefined}
* @variation 2
*/
declare function fetch(path: string, callback: FetchCallback): void;
/**
* Fetches the contents of a file.
* @name util.fetch
* @function
* @param {string} path File path or url
* @param {FetchOptions} [options] Fetch options
* @returns {Promise<string|Uint8Array>} Promise
* @variation 3
*/
declare function fetch(path: string, options?: FetchOptions): Promise<(string|Uint8Array)>;

115
node_modules/@protobufjs/fetch/index.js generated vendored Normal file
View File

@@ -0,0 +1,115 @@
"use strict";
module.exports = fetch;
var asPromise = require("@protobufjs/aspromise"),
inquire = require("@protobufjs/inquire");
var fs = inquire("fs");
/**
* Node-style callback as used by {@link util.fetch}.
* @typedef FetchCallback
* @type {function}
* @param {?Error} error Error, if any, otherwise `null`
* @param {string} [contents] File contents, if there hasn't been an error
* @returns {undefined}
*/
/**
* Options as used by {@link util.fetch}.
* @typedef FetchOptions
* @type {Object}
* @property {boolean} [binary=false] Whether expecting a binary response
* @property {boolean} [xhr=false] If `true`, forces the use of XMLHttpRequest
*/
/**
* Fetches the contents of a file.
* @memberof util
* @param {string} filename File path or url
* @param {FetchOptions} options Fetch options
* @param {FetchCallback} callback Callback function
* @returns {undefined}
*/
function fetch(filename, options, callback) {
if (typeof options === "function") {
callback = options;
options = {};
} else if (!options)
options = {};
if (!callback)
return asPromise(fetch, this, filename, options); // eslint-disable-line no-invalid-this
// if a node-like filesystem is present, try it first but fall back to XHR if nothing is found.
if (!options.xhr && fs && fs.readFile)
return fs.readFile(filename, function fetchReadFileCallback(err, contents) {
return err && typeof XMLHttpRequest !== "undefined"
? fetch.xhr(filename, options, callback)
: err
? callback(err)
: callback(null, options.binary ? contents : contents.toString("utf8"));
});
// use the XHR version otherwise.
return fetch.xhr(filename, options, callback);
}
/**
* Fetches the contents of a file.
* @name util.fetch
* @function
* @param {string} path File path or url
* @param {FetchCallback} callback Callback function
* @returns {undefined}
* @variation 2
*/
/**
* Fetches the contents of a file.
* @name util.fetch
* @function
* @param {string} path File path or url
* @param {FetchOptions} [options] Fetch options
* @returns {Promise<string|Uint8Array>} Promise
* @variation 3
*/
/**/
fetch.xhr = function fetch_xhr(filename, options, callback) {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange /* works everywhere */ = function fetchOnReadyStateChange() {
if (xhr.readyState !== 4)
return undefined;
// local cors security errors return status 0 / empty string, too. afaik this cannot be
// reliably distinguished from an actually empty file for security reasons. feel free
// to send a pull request if you are aware of a solution.
if (xhr.status !== 0 && xhr.status !== 200)
return callback(Error("status " + xhr.status));
// if binary data is expected, make sure that some sort of array is returned, even if
// ArrayBuffers are not supported. the binary string fallback, however, is unsafe.
if (options.binary) {
var buffer = xhr.response;
if (!buffer) {
buffer = [];
for (var i = 0; i < xhr.responseText.length; ++i)
buffer.push(xhr.responseText.charCodeAt(i) & 255);
}
return callback(null, typeof Uint8Array !== "undefined" ? new Uint8Array(buffer) : buffer);
}
return callback(null, xhr.responseText);
};
if (options.binary) {
// ref: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Sending_and_Receiving_Binary_Data#Receiving_binary_data_in_older_browsers
if ("overrideMimeType" in xhr)
xhr.overrideMimeType("text/plain; charset=x-user-defined");
xhr.responseType = "arraybuffer";
}
xhr.open("GET", filename);
xhr.send();
};

29
node_modules/@protobufjs/fetch/package.json generated vendored Normal file
View File

@@ -0,0 +1,29 @@
{
"name": "@protobufjs/fetch",
"description": "Fetches the contents of a file accross node and browsers.",
"version": "1.1.0",
"author": "Daniel Wirtz <dcode+protobufjs@dcode.io>",
"repository": {
"type": "git",
"url": "https://github.com/dcodeIO/protobuf.js.git"
},
"dependencies": {
"@protobufjs/aspromise": "^1.1.1",
"@protobufjs/inquire": "^1.1.0"
},
"license": "BSD-3-Clause",
"main": "index.js",
"types": "index.d.ts",
"devDependencies": {
"istanbul": "^0.4.5",
"tape": "^4.6.3"
},
"scripts": {
"test": "tape tests/*.js",
"coverage": "istanbul cover node_modules/tape/bin/tape tests/*.js"
}
,"_resolved": "https://registry.npmjs.org/@protobufjs/fetch/-/fetch-1.1.0.tgz"
,"_integrity": "sha1-upn7WYYUr2VwDBYZ/wbUVLDYTEU="
,"_from": "@protobufjs/fetch@1.1.0"
}

16
node_modules/@protobufjs/fetch/tests/index.js generated vendored Normal file
View File

@@ -0,0 +1,16 @@
var tape = require("tape");
var fetch = require("..");
tape.test("fetch", function(test) {
if (typeof Promise !== "undefined") {
var promise = fetch("NOTFOUND");
promise.catch(function() {});
test.ok(promise instanceof Promise, "should return a promise if callback has been omitted");
}
// TODO - some way to test this properly?
test.end();
});

26
node_modules/@protobufjs/float/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,26 @@
Copyright (c) 2016, Daniel Wirtz All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of its author, nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

102
node_modules/@protobufjs/float/README.md generated vendored Normal file
View File

@@ -0,0 +1,102 @@
@protobufjs/float
=================
[![npm](https://img.shields.io/npm/v/@protobufjs/float.svg)](https://www.npmjs.com/package/@protobufjs/float)
Reads / writes floats / doubles from / to buffers in both modern and ancient browsers. Fast.
API
---
* **writeFloatLE(val: `number`, buf: `Uint8Array`, pos: `number`)**<br />
Writes a 32 bit float to a buffer using little endian byte order.
* **writeFloatBE(val: `number`, buf: `Uint8Array`, pos: `number`)**<br />
Writes a 32 bit float to a buffer using big endian byte order.
* **readFloatLE(buf: `Uint8Array`, pos: `number`): `number`**<br />
Reads a 32 bit float from a buffer using little endian byte order.
* **readFloatBE(buf: `Uint8Array`, pos: `number`): `number`**<br />
Reads a 32 bit float from a buffer using big endian byte order.
* **writeDoubleLE(val: `number`, buf: `Uint8Array`, pos: `number`)**<br />
Writes a 64 bit double to a buffer using little endian byte order.
* **writeDoubleBE(val: `number`, buf: `Uint8Array`, pos: `number`)**<br />
Writes a 64 bit double to a buffer using big endian byte order.
* **readDoubleLE(buf: `Uint8Array`, pos: `number`): `number`**<br />
Reads a 64 bit double from a buffer using little endian byte order.
* **readDoubleBE(buf: `Uint8Array`, pos: `number`): `number`**<br />
Reads a 64 bit double from a buffer using big endian byte order.
Performance
-----------
There is a simple benchmark included comparing raw read/write performance of this library (float), float's fallback for old browsers, the [ieee754](https://www.npmjs.com/package/ieee754) module and node's [buffer](https://nodejs.org/api/buffer.html). On an i7-2600k running node 6.9.1 it yields:
```
benchmarking writeFloat performance ...
float x 42,741,625 ops/sec ±1.75% (81 runs sampled)
float (fallback) x 11,272,532 ops/sec ±1.12% (85 runs sampled)
ieee754 x 8,653,337 ops/sec ±1.18% (84 runs sampled)
buffer x 12,412,414 ops/sec ±1.41% (83 runs sampled)
buffer (noAssert) x 13,471,149 ops/sec ±1.09% (84 runs sampled)
float was fastest
float (fallback) was 73.5% slower
ieee754 was 79.6% slower
buffer was 70.9% slower
buffer (noAssert) was 68.3% slower
benchmarking readFloat performance ...
float x 44,382,729 ops/sec ±1.70% (84 runs sampled)
float (fallback) x 20,925,938 ops/sec ±0.86% (87 runs sampled)
ieee754 x 17,189,009 ops/sec ±1.01% (87 runs sampled)
buffer x 10,518,437 ops/sec ±1.04% (83 runs sampled)
buffer (noAssert) x 11,031,636 ops/sec ±1.15% (87 runs sampled)
float was fastest
float (fallback) was 52.5% slower
ieee754 was 61.0% slower
buffer was 76.1% slower
buffer (noAssert) was 75.0% slower
benchmarking writeDouble performance ...
float x 38,624,906 ops/sec ±0.93% (83 runs sampled)
float (fallback) x 10,457,811 ops/sec ±1.54% (85 runs sampled)
ieee754 x 7,681,130 ops/sec ±1.11% (83 runs sampled)
buffer x 12,657,876 ops/sec ±1.03% (83 runs sampled)
buffer (noAssert) x 13,372,795 ops/sec ±0.84% (85 runs sampled)
float was fastest
float (fallback) was 73.1% slower
ieee754 was 80.1% slower
buffer was 67.3% slower
buffer (noAssert) was 65.3% slower
benchmarking readDouble performance ...
float x 40,527,888 ops/sec ±1.05% (84 runs sampled)
float (fallback) x 18,696,480 ops/sec ±0.84% (86 runs sampled)
ieee754 x 14,074,028 ops/sec ±1.04% (87 runs sampled)
buffer x 10,092,367 ops/sec ±1.15% (84 runs sampled)
buffer (noAssert) x 10,623,793 ops/sec ±0.96% (84 runs sampled)
float was fastest
float (fallback) was 53.8% slower
ieee754 was 65.3% slower
buffer was 75.1% slower
buffer (noAssert) was 73.8% slower
```
To run it yourself:
```
$> npm run bench
```
**License:** [BSD 3-Clause License](https://opensource.org/licenses/BSD-3-Clause)

87
node_modules/@protobufjs/float/bench/index.js generated vendored Normal file
View File

@@ -0,0 +1,87 @@
"use strict";
var float = require(".."),
ieee754 = require("ieee754"),
newSuite = require("./suite");
var F32 = Float32Array;
var F64 = Float64Array;
delete global.Float32Array;
delete global.Float64Array;
var floatFallback = float({});
global.Float32Array = F32;
global.Float64Array = F64;
var buf = new Buffer(8);
newSuite("writeFloat")
.add("float", function() {
float.writeFloatLE(0.1, buf, 0);
})
.add("float (fallback)", function() {
floatFallback.writeFloatLE(0.1, buf, 0);
})
.add("ieee754", function() {
ieee754.write(buf, 0.1, 0, true, 23, 4);
})
.add("buffer", function() {
buf.writeFloatLE(0.1, 0);
})
.add("buffer (noAssert)", function() {
buf.writeFloatLE(0.1, 0, true);
})
.run();
newSuite("readFloat")
.add("float", function() {
float.readFloatLE(buf, 0);
})
.add("float (fallback)", function() {
floatFallback.readFloatLE(buf, 0);
})
.add("ieee754", function() {
ieee754.read(buf, 0, true, 23, 4);
})
.add("buffer", function() {
buf.readFloatLE(0);
})
.add("buffer (noAssert)", function() {
buf.readFloatLE(0, true);
})
.run();
newSuite("writeDouble")
.add("float", function() {
float.writeDoubleLE(0.1, buf, 0);
})
.add("float (fallback)", function() {
floatFallback.writeDoubleLE(0.1, buf, 0);
})
.add("ieee754", function() {
ieee754.write(buf, 0.1, 0, true, 52, 8);
})
.add("buffer", function() {
buf.writeDoubleLE(0.1, 0);
})
.add("buffer (noAssert)", function() {
buf.writeDoubleLE(0.1, 0, true);
})
.run();
newSuite("readDouble")
.add("float", function() {
float.readDoubleLE(buf, 0);
})
.add("float (fallback)", function() {
floatFallback.readDoubleLE(buf, 0);
})
.add("ieee754", function() {
ieee754.read(buf, 0, true, 52, 8);
})
.add("buffer", function() {
buf.readDoubleLE(0);
})
.add("buffer (noAssert)", function() {
buf.readDoubleLE(0, true);
})
.run();

46
node_modules/@protobufjs/float/bench/suite.js generated vendored Normal file
View File

@@ -0,0 +1,46 @@
"use strict";
module.exports = newSuite;
var benchmark = require("benchmark"),
chalk = require("chalk");
var padSize = 27;
function newSuite(name) {
var benches = [];
return new benchmark.Suite(name)
.on("add", function(event) {
benches.push(event.target);
})
.on("start", function() {
process.stdout.write("benchmarking " + name + " performance ...\n\n");
})
.on("cycle", function(event) {
process.stdout.write(String(event.target) + "\n");
})
.on("complete", function() {
if (benches.length > 1) {
var fastest = this.filter("fastest"), // eslint-disable-line no-invalid-this
fastestHz = getHz(fastest[0]);
process.stdout.write("\n" + chalk.white(pad(fastest[0].name, padSize)) + " was " + chalk.green("fastest") + "\n");
benches.forEach(function(bench) {
if (fastest.indexOf(bench) === 0)
return;
var hz = hz = getHz(bench);
var percent = (1 - hz / fastestHz) * 100;
process.stdout.write(chalk.white(pad(bench.name, padSize)) + " was " + chalk.red(percent.toFixed(1) + "% slower") + "\n");
});
}
process.stdout.write("\n");
});
}
function getHz(bench) {
return 1 / (bench.stats.mean + bench.stats.moe);
}
function pad(str, len, l) {
while (str.length < len)
str = l ? str + " " : " " + str;
return str;
}

83
node_modules/@protobufjs/float/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,83 @@
/**
* Writes a 32 bit float to a buffer using little endian byte order.
* @name writeFloatLE
* @function
* @param {number} val Value to write
* @param {Uint8Array} buf Target buffer
* @param {number} pos Target buffer offset
* @returns {undefined}
*/
export function writeFloatLE(val: number, buf: Uint8Array, pos: number): void;
/**
* Writes a 32 bit float to a buffer using big endian byte order.
* @name writeFloatBE
* @function
* @param {number} val Value to write
* @param {Uint8Array} buf Target buffer
* @param {number} pos Target buffer offset
* @returns {undefined}
*/
export function writeFloatBE(val: number, buf: Uint8Array, pos: number): void;
/**
* Reads a 32 bit float from a buffer using little endian byte order.
* @name readFloatLE
* @function
* @param {Uint8Array} buf Source buffer
* @param {number} pos Source buffer offset
* @returns {number} Value read
*/
export function readFloatLE(buf: Uint8Array, pos: number): number;
/**
* Reads a 32 bit float from a buffer using big endian byte order.
* @name readFloatBE
* @function
* @param {Uint8Array} buf Source buffer
* @param {number} pos Source buffer offset
* @returns {number} Value read
*/
export function readFloatBE(buf: Uint8Array, pos: number): number;
/**
* Writes a 64 bit double to a buffer using little endian byte order.
* @name writeDoubleLE
* @function
* @param {number} val Value to write
* @param {Uint8Array} buf Target buffer
* @param {number} pos Target buffer offset
* @returns {undefined}
*/
export function writeDoubleLE(val: number, buf: Uint8Array, pos: number): void;
/**
* Writes a 64 bit double to a buffer using big endian byte order.
* @name writeDoubleBE
* @function
* @param {number} val Value to write
* @param {Uint8Array} buf Target buffer
* @param {number} pos Target buffer offset
* @returns {undefined}
*/
export function writeDoubleBE(val: number, buf: Uint8Array, pos: number): void;
/**
* Reads a 64 bit double from a buffer using little endian byte order.
* @name readDoubleLE
* @function
* @param {Uint8Array} buf Source buffer
* @param {number} pos Source buffer offset
* @returns {number} Value read
*/
export function readDoubleLE(buf: Uint8Array, pos: number): number;
/**
* Reads a 64 bit double from a buffer using big endian byte order.
* @name readDoubleBE
* @function
* @param {Uint8Array} buf Source buffer
* @param {number} pos Source buffer offset
* @returns {number} Value read
*/
export function readDoubleBE(buf: Uint8Array, pos: number): number;

335
node_modules/@protobufjs/float/index.js generated vendored Normal file
View File

@@ -0,0 +1,335 @@
"use strict";
module.exports = factory(factory);
/**
* Reads / writes floats / doubles from / to buffers.
* @name util.float
* @namespace
*/
/**
* Writes a 32 bit float to a buffer using little endian byte order.
* @name util.float.writeFloatLE
* @function
* @param {number} val Value to write
* @param {Uint8Array} buf Target buffer
* @param {number} pos Target buffer offset
* @returns {undefined}
*/
/**
* Writes a 32 bit float to a buffer using big endian byte order.
* @name util.float.writeFloatBE
* @function
* @param {number} val Value to write
* @param {Uint8Array} buf Target buffer
* @param {number} pos Target buffer offset
* @returns {undefined}
*/
/**
* Reads a 32 bit float from a buffer using little endian byte order.
* @name util.float.readFloatLE
* @function
* @param {Uint8Array} buf Source buffer
* @param {number} pos Source buffer offset
* @returns {number} Value read
*/
/**
* Reads a 32 bit float from a buffer using big endian byte order.
* @name util.float.readFloatBE
* @function
* @param {Uint8Array} buf Source buffer
* @param {number} pos Source buffer offset
* @returns {number} Value read
*/
/**
* Writes a 64 bit double to a buffer using little endian byte order.
* @name util.float.writeDoubleLE
* @function
* @param {number} val Value to write
* @param {Uint8Array} buf Target buffer
* @param {number} pos Target buffer offset
* @returns {undefined}
*/
/**
* Writes a 64 bit double to a buffer using big endian byte order.
* @name util.float.writeDoubleBE
* @function
* @param {number} val Value to write
* @param {Uint8Array} buf Target buffer
* @param {number} pos Target buffer offset
* @returns {undefined}
*/
/**
* Reads a 64 bit double from a buffer using little endian byte order.
* @name util.float.readDoubleLE
* @function
* @param {Uint8Array} buf Source buffer
* @param {number} pos Source buffer offset
* @returns {number} Value read
*/
/**
* Reads a 64 bit double from a buffer using big endian byte order.
* @name util.float.readDoubleBE
* @function
* @param {Uint8Array} buf Source buffer
* @param {number} pos Source buffer offset
* @returns {number} Value read
*/
// Factory function for the purpose of node-based testing in modified global environments
function factory(exports) {
// float: typed array
if (typeof Float32Array !== "undefined") (function() {
var f32 = new Float32Array([ -0 ]),
f8b = new Uint8Array(f32.buffer),
le = f8b[3] === 128;
function writeFloat_f32_cpy(val, buf, pos) {
f32[0] = val;
buf[pos ] = f8b[0];
buf[pos + 1] = f8b[1];
buf[pos + 2] = f8b[2];
buf[pos + 3] = f8b[3];
}
function writeFloat_f32_rev(val, buf, pos) {
f32[0] = val;
buf[pos ] = f8b[3];
buf[pos + 1] = f8b[2];
buf[pos + 2] = f8b[1];
buf[pos + 3] = f8b[0];
}
/* istanbul ignore next */
exports.writeFloatLE = le ? writeFloat_f32_cpy : writeFloat_f32_rev;
/* istanbul ignore next */
exports.writeFloatBE = le ? writeFloat_f32_rev : writeFloat_f32_cpy;
function readFloat_f32_cpy(buf, pos) {
f8b[0] = buf[pos ];
f8b[1] = buf[pos + 1];
f8b[2] = buf[pos + 2];
f8b[3] = buf[pos + 3];
return f32[0];
}
function readFloat_f32_rev(buf, pos) {
f8b[3] = buf[pos ];
f8b[2] = buf[pos + 1];
f8b[1] = buf[pos + 2];
f8b[0] = buf[pos + 3];
return f32[0];
}
/* istanbul ignore next */
exports.readFloatLE = le ? readFloat_f32_cpy : readFloat_f32_rev;
/* istanbul ignore next */
exports.readFloatBE = le ? readFloat_f32_rev : readFloat_f32_cpy;
// float: ieee754
})(); else (function() {
function writeFloat_ieee754(writeUint, val, buf, pos) {
var sign = val < 0 ? 1 : 0;
if (sign)
val = -val;
if (val === 0)
writeUint(1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, buf, pos);
else if (isNaN(val))
writeUint(2143289344, buf, pos);
else if (val > 3.4028234663852886e+38) // +-Infinity
writeUint((sign << 31 | 2139095040) >>> 0, buf, pos);
else if (val < 1.1754943508222875e-38) // denormal
writeUint((sign << 31 | Math.round(val / 1.401298464324817e-45)) >>> 0, buf, pos);
else {
var exponent = Math.floor(Math.log(val) / Math.LN2),
mantissa = Math.round(val * Math.pow(2, -exponent) * 8388608) & 8388607;
writeUint((sign << 31 | exponent + 127 << 23 | mantissa) >>> 0, buf, pos);
}
}
exports.writeFloatLE = writeFloat_ieee754.bind(null, writeUintLE);
exports.writeFloatBE = writeFloat_ieee754.bind(null, writeUintBE);
function readFloat_ieee754(readUint, buf, pos) {
var uint = readUint(buf, pos),
sign = (uint >> 31) * 2 + 1,
exponent = uint >>> 23 & 255,
mantissa = uint & 8388607;
return exponent === 255
? mantissa
? NaN
: sign * Infinity
: exponent === 0 // denormal
? sign * 1.401298464324817e-45 * mantissa
: sign * Math.pow(2, exponent - 150) * (mantissa + 8388608);
}
exports.readFloatLE = readFloat_ieee754.bind(null, readUintLE);
exports.readFloatBE = readFloat_ieee754.bind(null, readUintBE);
})();
// double: typed array
if (typeof Float64Array !== "undefined") (function() {
var f64 = new Float64Array([-0]),
f8b = new Uint8Array(f64.buffer),
le = f8b[7] === 128;
function writeDouble_f64_cpy(val, buf, pos) {
f64[0] = val;
buf[pos ] = f8b[0];
buf[pos + 1] = f8b[1];
buf[pos + 2] = f8b[2];
buf[pos + 3] = f8b[3];
buf[pos + 4] = f8b[4];
buf[pos + 5] = f8b[5];
buf[pos + 6] = f8b[6];
buf[pos + 7] = f8b[7];
}
function writeDouble_f64_rev(val, buf, pos) {
f64[0] = val;
buf[pos ] = f8b[7];
buf[pos + 1] = f8b[6];
buf[pos + 2] = f8b[5];
buf[pos + 3] = f8b[4];
buf[pos + 4] = f8b[3];
buf[pos + 5] = f8b[2];
buf[pos + 6] = f8b[1];
buf[pos + 7] = f8b[0];
}
/* istanbul ignore next */
exports.writeDoubleLE = le ? writeDouble_f64_cpy : writeDouble_f64_rev;
/* istanbul ignore next */
exports.writeDoubleBE = le ? writeDouble_f64_rev : writeDouble_f64_cpy;
function readDouble_f64_cpy(buf, pos) {
f8b[0] = buf[pos ];
f8b[1] = buf[pos + 1];
f8b[2] = buf[pos + 2];
f8b[3] = buf[pos + 3];
f8b[4] = buf[pos + 4];
f8b[5] = buf[pos + 5];
f8b[6] = buf[pos + 6];
f8b[7] = buf[pos + 7];
return f64[0];
}
function readDouble_f64_rev(buf, pos) {
f8b[7] = buf[pos ];
f8b[6] = buf[pos + 1];
f8b[5] = buf[pos + 2];
f8b[4] = buf[pos + 3];
f8b[3] = buf[pos + 4];
f8b[2] = buf[pos + 5];
f8b[1] = buf[pos + 6];
f8b[0] = buf[pos + 7];
return f64[0];
}
/* istanbul ignore next */
exports.readDoubleLE = le ? readDouble_f64_cpy : readDouble_f64_rev;
/* istanbul ignore next */
exports.readDoubleBE = le ? readDouble_f64_rev : readDouble_f64_cpy;
// double: ieee754
})(); else (function() {
function writeDouble_ieee754(writeUint, off0, off1, val, buf, pos) {
var sign = val < 0 ? 1 : 0;
if (sign)
val = -val;
if (val === 0) {
writeUint(0, buf, pos + off0);
writeUint(1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, buf, pos + off1);
} else if (isNaN(val)) {
writeUint(0, buf, pos + off0);
writeUint(2146959360, buf, pos + off1);
} else if (val > 1.7976931348623157e+308) { // +-Infinity
writeUint(0, buf, pos + off0);
writeUint((sign << 31 | 2146435072) >>> 0, buf, pos + off1);
} else {
var mantissa;
if (val < 2.2250738585072014e-308) { // denormal
mantissa = val / 5e-324;
writeUint(mantissa >>> 0, buf, pos + off0);
writeUint((sign << 31 | mantissa / 4294967296) >>> 0, buf, pos + off1);
} else {
var exponent = Math.floor(Math.log(val) / Math.LN2);
if (exponent === 1024)
exponent = 1023;
mantissa = val * Math.pow(2, -exponent);
writeUint(mantissa * 4503599627370496 >>> 0, buf, pos + off0);
writeUint((sign << 31 | exponent + 1023 << 20 | mantissa * 1048576 & 1048575) >>> 0, buf, pos + off1);
}
}
}
exports.writeDoubleLE = writeDouble_ieee754.bind(null, writeUintLE, 0, 4);
exports.writeDoubleBE = writeDouble_ieee754.bind(null, writeUintBE, 4, 0);
function readDouble_ieee754(readUint, off0, off1, buf, pos) {
var lo = readUint(buf, pos + off0),
hi = readUint(buf, pos + off1);
var sign = (hi >> 31) * 2 + 1,
exponent = hi >>> 20 & 2047,
mantissa = 4294967296 * (hi & 1048575) + lo;
return exponent === 2047
? mantissa
? NaN
: sign * Infinity
: exponent === 0 // denormal
? sign * 5e-324 * mantissa
: sign * Math.pow(2, exponent - 1075) * (mantissa + 4503599627370496);
}
exports.readDoubleLE = readDouble_ieee754.bind(null, readUintLE, 0, 4);
exports.readDoubleBE = readDouble_ieee754.bind(null, readUintBE, 4, 0);
})();
return exports;
}
// uint helpers
function writeUintLE(val, buf, pos) {
buf[pos ] = val & 255;
buf[pos + 1] = val >>> 8 & 255;
buf[pos + 2] = val >>> 16 & 255;
buf[pos + 3] = val >>> 24;
}
function writeUintBE(val, buf, pos) {
buf[pos ] = val >>> 24;
buf[pos + 1] = val >>> 16 & 255;
buf[pos + 2] = val >>> 8 & 255;
buf[pos + 3] = val & 255;
}
function readUintLE(buf, pos) {
return (buf[pos ]
| buf[pos + 1] << 8
| buf[pos + 2] << 16
| buf[pos + 3] << 24) >>> 0;
}
function readUintBE(buf, pos) {
return (buf[pos ] << 24
| buf[pos + 1] << 16
| buf[pos + 2] << 8
| buf[pos + 3]) >>> 0;
}

30
node_modules/@protobufjs/float/package.json generated vendored Normal file
View File

@@ -0,0 +1,30 @@
{
"name": "@protobufjs/float",
"description": "Reads / writes floats / doubles from / to buffers in both modern and ancient browsers.",
"version": "1.0.2",
"author": "Daniel Wirtz <dcode+protobufjs@dcode.io>",
"repository": {
"type": "git",
"url": "https://github.com/dcodeIO/protobuf.js.git"
},
"dependencies": {},
"license": "BSD-3-Clause",
"main": "index.js",
"types": "index.d.ts",
"devDependencies": {
"benchmark": "^2.1.4",
"chalk": "^1.1.3",
"ieee754": "^1.1.8",
"istanbul": "^0.4.5",
"tape": "^4.6.3"
},
"scripts": {
"test": "tape tests/*.js",
"coverage": "istanbul cover node_modules/tape/bin/tape tests/*.js",
"bench": "node bench"
}
,"_resolved": "https://registry.npmjs.org/@protobufjs/float/-/float-1.0.2.tgz"
,"_integrity": "sha1-Xp4avctz/Ap8uLKR33jIy9l7h9E="
,"_from": "@protobufjs/float@1.0.2"
}

100
node_modules/@protobufjs/float/tests/index.js generated vendored Normal file
View File

@@ -0,0 +1,100 @@
var tape = require("tape");
var float = require("..");
tape.test("float", function(test) {
// default
test.test(test.name + " - typed array", function(test) {
runTest(float, test);
});
// ieee754
test.test(test.name + " - fallback", function(test) {
var F32 = global.Float32Array,
F64 = global.Float64Array;
delete global.Float32Array;
delete global.Float64Array;
runTest(float({}), test);
global.Float32Array = F32;
global.Float64Array = F64;
});
});
function runTest(float, test) {
var common = [
0,
-0,
Infinity,
-Infinity,
0.125,
1024.5,
-4096.5,
NaN
];
test.test(test.name + " - using 32 bits", function(test) {
common.concat([
3.4028234663852886e+38,
1.1754943508222875e-38,
1.1754946310819804e-39
])
.forEach(function(value) {
var strval = value === 0 && 1 / value < 0 ? "-0" : value.toString();
test.ok(
checkValue(value, 4, float.readFloatLE, float.writeFloatLE, Buffer.prototype.writeFloatLE),
"should write and read back " + strval + " (32 bit LE)"
);
test.ok(
checkValue(value, 4, float.readFloatBE, float.writeFloatBE, Buffer.prototype.writeFloatBE),
"should write and read back " + strval + " (32 bit BE)"
);
});
test.end();
});
test.test(test.name + " - using 64 bits", function(test) {
common.concat([
1.7976931348623157e+308,
2.2250738585072014e-308,
2.2250738585072014e-309
])
.forEach(function(value) {
var strval = value === 0 && 1 / value < 0 ? "-0" : value.toString();
test.ok(
checkValue(value, 8, float.readDoubleLE, float.writeDoubleLE, Buffer.prototype.writeDoubleLE),
"should write and read back " + strval + " (64 bit LE)"
);
test.ok(
checkValue(value, 8, float.readDoubleBE, float.writeDoubleBE, Buffer.prototype.writeDoubleBE),
"should write and read back " + strval + " (64 bit BE)"
);
});
test.end();
});
test.end();
}
function checkValue(value, size, read, write, write_comp) {
var buffer = new Buffer(size);
write(value, buffer, 0);
var value_comp = read(buffer, 0);
var strval = value === 0 && 1 / value < 0 ? "-0" : value.toString();
if (value !== value) {
if (value_comp === value_comp)
return false;
} else if (value_comp !== value)
return false;
var buffer_comp = new Buffer(size);
write_comp.call(buffer_comp, value, 0);
for (var i = 0; i < size; ++i)
if (buffer[i] !== buffer_comp[i]) {
console.error(">", buffer, buffer_comp);
return false;
}
return true;
}

3
node_modules/@protobufjs/inquire/.npmignore generated vendored Normal file
View File

@@ -0,0 +1,3 @@
npm-debug.*
node_modules/
coverage/

26
node_modules/@protobufjs/inquire/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,26 @@
Copyright (c) 2016, Daniel Wirtz All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of its author, nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

13
node_modules/@protobufjs/inquire/README.md generated vendored Normal file
View File

@@ -0,0 +1,13 @@
@protobufjs/inquire
===================
[![npm](https://img.shields.io/npm/v/@protobufjs/inquire.svg)](https://www.npmjs.com/package/@protobufjs/inquire)
Requires a module only if available and hides the require call from bundlers.
API
---
* **inquire(moduleName: `string`): `?Object`**<br />
Requires a module only if available.
**License:** [BSD 3-Clause License](https://opensource.org/licenses/BSD-3-Clause)

9
node_modules/@protobufjs/inquire/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,9 @@
export = inquire;
/**
* Requires a module only if available.
* @memberof util
* @param {string} moduleName Module to require
* @returns {?Object} Required module if available and not empty, otherwise `null`
*/
declare function inquire(moduleName: string): Object;

17
node_modules/@protobufjs/inquire/index.js generated vendored Normal file
View File

@@ -0,0 +1,17 @@
"use strict";
module.exports = inquire;
/**
* Requires a module only if available.
* @memberof util
* @param {string} moduleName Module to require
* @returns {?Object} Required module if available and not empty, otherwise `null`
*/
function inquire(moduleName) {
try {
var mod = eval("quire".replace(/^/,"re"))(moduleName); // eslint-disable-line no-eval
if (mod && (mod.length || Object.keys(mod).length))
return mod;
} catch (e) {} // eslint-disable-line no-empty
return null;
}

25
node_modules/@protobufjs/inquire/package.json generated vendored Normal file
View File

@@ -0,0 +1,25 @@
{
"name": "@protobufjs/inquire",
"description": "Requires a module only if available and hides the require call from bundlers.",
"version": "1.1.0",
"author": "Daniel Wirtz <dcode+protobufjs@dcode.io>",
"repository": {
"type": "git",
"url": "https://github.com/dcodeIO/protobuf.js.git"
},
"license": "BSD-3-Clause",
"main": "index.js",
"types": "index.d.ts",
"devDependencies": {
"istanbul": "^0.4.5",
"tape": "^4.6.3"
},
"scripts": {
"test": "tape tests/*.js",
"coverage": "istanbul cover node_modules/tape/bin/tape tests/*.js"
}
,"_resolved": "https://registry.npmjs.org/@protobufjs/inquire/-/inquire-1.1.0.tgz"
,"_integrity": "sha1-/yAOPnzyQp4tyvwRQIKOjMY48Ik="
,"_from": "@protobufjs/inquire@1.1.0"
}

1
node_modules/@protobufjs/inquire/tests/data/array.js generated vendored Normal file
View File

@@ -0,0 +1 @@
module.exports = [1];

View File

@@ -0,0 +1 @@
module.exports = [];

View File

@@ -0,0 +1 @@
module.exports = {};

View File

@@ -0,0 +1 @@
module.exports = { a: 1 };

20
node_modules/@protobufjs/inquire/tests/index.js generated vendored Normal file
View File

@@ -0,0 +1,20 @@
var tape = require("tape");
var inquire = require("..");
tape.test("inquire", function(test) {
test.equal(inquire("buffer").Buffer, Buffer, "should be able to require \"buffer\"");
test.equal(inquire("%invalid"), null, "should not be able to require \"%invalid\"");
test.equal(inquire("./tests/data/emptyObject"), null, "should return null when requiring a module exporting an empty object");
test.equal(inquire("./tests/data/emptyArray"), null, "should return null when requiring a module exporting an empty array");
test.same(inquire("./tests/data/object"), { a: 1 }, "should return the object if a non-empty object");
test.same(inquire("./tests/data/array"), [ 1 ], "should return the module if a non-empty array");
test.end();
});

26
node_modules/@protobufjs/path/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,26 @@
Copyright (c) 2016, Daniel Wirtz All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of its author, nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

19
node_modules/@protobufjs/path/README.md generated vendored Normal file
View File

@@ -0,0 +1,19 @@
@protobufjs/path
================
[![npm](https://img.shields.io/npm/v/@protobufjs/path.svg)](https://www.npmjs.com/package/@protobufjs/path)
A minimal path module to resolve Unix, Windows and URL paths alike.
API
---
* **path.isAbsolute(path: `string`): `boolean`**<br />
Tests if the specified path is absolute.
* **path.normalize(path: `string`): `string`**<br />
Normalizes the specified path.
* **path.resolve(originPath: `string`, includePath: `string`, [alreadyNormalized=false: `boolean`]): `string`**<br />
Resolves the specified include path against the specified origin path.
**License:** [BSD 3-Clause License](https://opensource.org/licenses/BSD-3-Clause)

22
node_modules/@protobufjs/path/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,22 @@
/**
* Tests if the specified path is absolute.
* @param {string} path Path to test
* @returns {boolean} `true` if path is absolute
*/
export function isAbsolute(path: string): boolean;
/**
* Normalizes the specified path.
* @param {string} path Path to normalize
* @returns {string} Normalized path
*/
export function normalize(path: string): string;
/**
* Resolves the specified include path against the specified origin path.
* @param {string} originPath Path to the origin file
* @param {string} includePath Include path relative to origin path
* @param {boolean} [alreadyNormalized=false] `true` if both paths are already known to be normalized
* @returns {string} Path to the include file
*/
export function resolve(originPath: string, includePath: string, alreadyNormalized?: boolean): string;

65
node_modules/@protobufjs/path/index.js generated vendored Normal file
View File

@@ -0,0 +1,65 @@
"use strict";
/**
* A minimal path module to resolve Unix, Windows and URL paths alike.
* @memberof util
* @namespace
*/
var path = exports;
var isAbsolute =
/**
* Tests if the specified path is absolute.
* @param {string} path Path to test
* @returns {boolean} `true` if path is absolute
*/
path.isAbsolute = function isAbsolute(path) {
return /^(?:\/|\w+:)/.test(path);
};
var normalize =
/**
* Normalizes the specified path.
* @param {string} path Path to normalize
* @returns {string} Normalized path
*/
path.normalize = function normalize(path) {
path = path.replace(/\\/g, "/")
.replace(/\/{2,}/g, "/");
var parts = path.split("/"),
absolute = isAbsolute(path),
prefix = "";
if (absolute)
prefix = parts.shift() + "/";
for (var i = 0; i < parts.length;) {
if (parts[i] === "..") {
if (i > 0 && parts[i - 1] !== "..")
parts.splice(--i, 2);
else if (absolute)
parts.splice(i, 1);
else
++i;
} else if (parts[i] === ".")
parts.splice(i, 1);
else
++i;
}
return prefix + parts.join("/");
};
/**
* Resolves the specified include path against the specified origin path.
* @param {string} originPath Path to the origin file
* @param {string} includePath Include path relative to origin path
* @param {boolean} [alreadyNormalized=false] `true` if both paths are already known to be normalized
* @returns {string} Path to the include file
*/
path.resolve = function resolve(originPath, includePath, alreadyNormalized) {
if (!alreadyNormalized)
includePath = normalize(includePath);
if (isAbsolute(includePath))
return includePath;
if (!alreadyNormalized)
originPath = normalize(originPath);
return (originPath = originPath.replace(/(?:\/|^)[^/]+$/, "")).length ? normalize(originPath + "/" + includePath) : includePath;
};

25
node_modules/@protobufjs/path/package.json generated vendored Normal file
View File

@@ -0,0 +1,25 @@
{
"name": "@protobufjs/path",
"description": "A minimal path module to resolve Unix, Windows and URL paths alike.",
"version": "1.1.2",
"author": "Daniel Wirtz <dcode+protobufjs@dcode.io>",
"repository": {
"type": "git",
"url": "https://github.com/dcodeIO/protobuf.js.git"
},
"license": "BSD-3-Clause",
"main": "index.js",
"types": "index.d.ts",
"devDependencies": {
"istanbul": "^0.4.5",
"tape": "^4.6.3"
},
"scripts": {
"test": "tape tests/*.js",
"coverage": "istanbul cover node_modules/tape/bin/tape tests/*.js"
}
,"_resolved": "https://registry.npmjs.org/@protobufjs/path/-/path-1.1.2.tgz"
,"_integrity": "sha1-bMKyDFya1q0NzP0hynZz2Nf79o0="
,"_from": "@protobufjs/path@1.1.2"
}

60
node_modules/@protobufjs/path/tests/index.js generated vendored Normal file
View File

@@ -0,0 +1,60 @@
var tape = require("tape");
var path = require("..");
tape.test("path", function(test) {
test.ok(path.isAbsolute("X:\\some\\path\\file.js"), "should identify absolute windows paths");
test.ok(path.isAbsolute("/some/path/file.js"), "should identify absolute unix paths");
test.notOk(path.isAbsolute("some\\path\\file.js"), "should identify relative windows paths");
test.notOk(path.isAbsolute("some/path/file.js"), "should identify relative unix paths");
var paths = [
{
actual: "X:\\some\\..\\.\\path\\\\file.js",
normal: "X:/path/file.js",
resolve: {
origin: "X:/path/origin.js",
expected: "X:/path/file.js"
}
}, {
actual: "some\\..\\.\\path\\\\file.js",
normal: "path/file.js",
resolve: {
origin: "X:/path/origin.js",
expected: "X:/path/path/file.js"
}
}, {
actual: "/some/.././path//file.js",
normal: "/path/file.js",
resolve: {
origin: "/path/origin.js",
expected: "/path/file.js"
}
}, {
actual: "some/.././path//file.js",
normal: "path/file.js",
resolve: {
origin: "",
expected: "path/file.js"
}
}, {
actual: ".././path//file.js",
normal: "../path/file.js"
}, {
actual: "/.././path//file.js",
normal: "/path/file.js"
}
];
paths.forEach(function(p) {
test.equal(path.normalize(p.actual), p.normal, "should normalize " + p.actual);
if (p.resolve) {
test.equal(path.resolve(p.resolve.origin, p.actual), p.resolve.expected, "should resolve " + p.actual);
test.equal(path.resolve(p.resolve.origin, p.normal, true), p.resolve.expected, "should resolve " + p.normal + " (already normalized)");
}
});
test.end();
});

3
node_modules/@protobufjs/pool/.npmignore generated vendored Normal file
View File

@@ -0,0 +1,3 @@
npm-debug.*
node_modules/
coverage/

26
node_modules/@protobufjs/pool/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,26 @@
Copyright (c) 2016, Daniel Wirtz All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of its author, nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

13
node_modules/@protobufjs/pool/README.md generated vendored Normal file
View File

@@ -0,0 +1,13 @@
@protobufjs/pool
================
[![npm](https://img.shields.io/npm/v/@protobufjs/pool.svg)](https://www.npmjs.com/package/@protobufjs/pool)
A general purpose buffer pool.
API
---
* **pool(alloc: `function(size: number): Uint8Array`, slice: `function(this: Uint8Array, start: number, end: number): Uint8Array`, [size=8192: `number`]): `function(size: number): Uint8Array`**<br />
Creates a pooled allocator.
**License:** [BSD 3-Clause License](https://opensource.org/licenses/BSD-3-Clause)

32
node_modules/@protobufjs/pool/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,32 @@
export = pool;
/**
* An allocator as used by {@link util.pool}.
* @typedef PoolAllocator
* @type {function}
* @param {number} size Buffer size
* @returns {Uint8Array} Buffer
*/
type PoolAllocator = (size: number) => Uint8Array;
/**
* A slicer as used by {@link util.pool}.
* @typedef PoolSlicer
* @type {function}
* @param {number} start Start offset
* @param {number} end End offset
* @returns {Uint8Array} Buffer slice
* @this {Uint8Array}
*/
type PoolSlicer = (this: Uint8Array, start: number, end: number) => Uint8Array;
/**
* A general purpose buffer pool.
* @memberof util
* @function
* @param {PoolAllocator} alloc Allocator
* @param {PoolSlicer} slice Slicer
* @param {number} [size=8192] Slab size
* @returns {PoolAllocator} Pooled allocator
*/
declare function pool(alloc: PoolAllocator, slice: PoolSlicer, size?: number): PoolAllocator;

48
node_modules/@protobufjs/pool/index.js generated vendored Normal file
View File

@@ -0,0 +1,48 @@
"use strict";
module.exports = pool;
/**
* An allocator as used by {@link util.pool}.
* @typedef PoolAllocator
* @type {function}
* @param {number} size Buffer size
* @returns {Uint8Array} Buffer
*/
/**
* A slicer as used by {@link util.pool}.
* @typedef PoolSlicer
* @type {function}
* @param {number} start Start offset
* @param {number} end End offset
* @returns {Uint8Array} Buffer slice
* @this {Uint8Array}
*/
/**
* A general purpose buffer pool.
* @memberof util
* @function
* @param {PoolAllocator} alloc Allocator
* @param {PoolSlicer} slice Slicer
* @param {number} [size=8192] Slab size
* @returns {PoolAllocator} Pooled allocator
*/
function pool(alloc, slice, size) {
var SIZE = size || 8192;
var MAX = SIZE >>> 1;
var slab = null;
var offset = SIZE;
return function pool_alloc(size) {
if (size < 1 || size > MAX)
return alloc(size);
if (offset + size > SIZE) {
slab = alloc(SIZE);
offset = 0;
}
var buf = slice.call(slab, offset, offset += size);
if (offset & 7) // align to 32 bit
offset = (offset | 7) + 1;
return buf;
};
}

25
node_modules/@protobufjs/pool/package.json generated vendored Normal file
View File

@@ -0,0 +1,25 @@
{
"name": "@protobufjs/pool",
"description": "A general purpose buffer pool.",
"version": "1.1.0",
"author": "Daniel Wirtz <dcode+protobufjs@dcode.io>",
"repository": {
"type": "git",
"url": "https://github.com/dcodeIO/protobuf.js.git"
},
"license": "BSD-3-Clause",
"main": "index.js",
"types": "index.d.ts",
"devDependencies": {
"istanbul": "^0.4.5",
"tape": "^4.6.3"
},
"scripts": {
"test": "tape tests/*.js",
"coverage": "istanbul cover node_modules/tape/bin/tape tests/*.js"
}
,"_resolved": "https://registry.npmjs.org/@protobufjs/pool/-/pool-1.1.0.tgz"
,"_integrity": "sha1-Cf0V8tbTq/qbZbw2ZQbWrXhG/1Q="
,"_from": "@protobufjs/pool@1.1.0"
}

33
node_modules/@protobufjs/pool/tests/index.js generated vendored Normal file
View File

@@ -0,0 +1,33 @@
var tape = require("tape");
var pool = require("..");
if (typeof Uint8Array !== "undefined")
tape.test("pool", function(test) {
var alloc = pool(function(size) { return new Uint8Array(size); }, Uint8Array.prototype.subarray);
var buf1 = alloc(0);
test.equal(buf1.length, 0, "should allocate a buffer of size 0");
var buf2 = alloc(1);
test.equal(buf2.length, 1, "should allocate a buffer of size 1 (initializes slab)");
test.notEqual(buf2.buffer, buf1.buffer, "should not reference the same backing buffer if previous buffer had size 0");
test.equal(buf2.byteOffset, 0, "should allocate at byteOffset 0 when using a new slab");
buf1 = alloc(1);
test.equal(buf1.buffer, buf2.buffer, "should reference the same backing buffer when allocating a chunk fitting into the slab");
test.equal(buf1.byteOffset, 8, "should align slices to 32 bit and this allocate at byteOffset 8");
var buf3 = alloc(4097);
test.notEqual(buf3.buffer, buf2.buffer, "should not reference the same backing buffer when allocating a buffer larger than half the backing buffer's size");
buf2 = alloc(4096);
test.equal(buf2.buffer, buf1.buffer, "should reference the same backing buffer when allocating a buffer smaller or equal than half the backing buffer's size");
buf1 = alloc(4096);
test.notEqual(buf1.buffer, buf2.buffer, "should not reference the same backing buffer when the slab is exhausted (initializes new slab)");
test.end();
});

3
node_modules/@protobufjs/utf8/.npmignore generated vendored Normal file
View File

@@ -0,0 +1,3 @@
npm-debug.*
node_modules/
coverage/

26
node_modules/@protobufjs/utf8/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,26 @@
Copyright (c) 2016, Daniel Wirtz All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of its author, nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

20
node_modules/@protobufjs/utf8/README.md generated vendored Normal file
View File

@@ -0,0 +1,20 @@
@protobufjs/utf8
================
[![npm](https://img.shields.io/npm/v/@protobufjs/utf8.svg)](https://www.npmjs.com/package/@protobufjs/utf8)
A minimal UTF8 implementation for number arrays.
API
---
* **utf8.length(string: `string`): `number`**<br />
Calculates the UTF8 byte length of a string.
* **utf8.read(buffer: `Uint8Array`, start: `number`, end: `number`): `string`**<br />
Reads UTF8 bytes as a string.
* **utf8.write(string: `string`, buffer: `Uint8Array`, offset: `number`): `number`**<br />
Writes a string as UTF8 bytes.
**License:** [BSD 3-Clause License](https://opensource.org/licenses/BSD-3-Clause)

24
node_modules/@protobufjs/utf8/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,24 @@
/**
* Calculates the UTF8 byte length of a string.
* @param {string} string String
* @returns {number} Byte length
*/
export function length(string: string): number;
/**
* Reads UTF8 bytes as a string.
* @param {Uint8Array} buffer Source buffer
* @param {number} start Source start
* @param {number} end Source end
* @returns {string} String read
*/
export function read(buffer: Uint8Array, start: number, end: number): string;
/**
* Writes a string as UTF8 bytes.
* @param {string} string Source string
* @param {Uint8Array} buffer Destination buffer
* @param {number} offset Destination offset
* @returns {number} Bytes written
*/
export function write(string: string, buffer: Uint8Array, offset: number): number;

105
node_modules/@protobufjs/utf8/index.js generated vendored Normal file
View File

@@ -0,0 +1,105 @@
"use strict";
/**
* A minimal UTF8 implementation for number arrays.
* @memberof util
* @namespace
*/
var utf8 = exports;
/**
* Calculates the UTF8 byte length of a string.
* @param {string} string String
* @returns {number} Byte length
*/
utf8.length = function utf8_length(string) {
var len = 0,
c = 0;
for (var i = 0; i < string.length; ++i) {
c = string.charCodeAt(i);
if (c < 128)
len += 1;
else if (c < 2048)
len += 2;
else if ((c & 0xFC00) === 0xD800 && (string.charCodeAt(i + 1) & 0xFC00) === 0xDC00) {
++i;
len += 4;
} else
len += 3;
}
return len;
};
/**
* Reads UTF8 bytes as a string.
* @param {Uint8Array} buffer Source buffer
* @param {number} start Source start
* @param {number} end Source end
* @returns {string} String read
*/
utf8.read = function utf8_read(buffer, start, end) {
var len = end - start;
if (len < 1)
return "";
var parts = null,
chunk = [],
i = 0, // char offset
t; // temporary
while (start < end) {
t = buffer[start++];
if (t < 128)
chunk[i++] = t;
else if (t > 191 && t < 224)
chunk[i++] = (t & 31) << 6 | buffer[start++] & 63;
else if (t > 239 && t < 365) {
t = ((t & 7) << 18 | (buffer[start++] & 63) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63) - 0x10000;
chunk[i++] = 0xD800 + (t >> 10);
chunk[i++] = 0xDC00 + (t & 1023);
} else
chunk[i++] = (t & 15) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63;
if (i > 8191) {
(parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
i = 0;
}
}
if (parts) {
if (i)
parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
return parts.join("");
}
return String.fromCharCode.apply(String, chunk.slice(0, i));
};
/**
* Writes a string as UTF8 bytes.
* @param {string} string Source string
* @param {Uint8Array} buffer Destination buffer
* @param {number} offset Destination offset
* @returns {number} Bytes written
*/
utf8.write = function utf8_write(string, buffer, offset) {
var start = offset,
c1, // character 1
c2; // character 2
for (var i = 0; i < string.length; ++i) {
c1 = string.charCodeAt(i);
if (c1 < 128) {
buffer[offset++] = c1;
} else if (c1 < 2048) {
buffer[offset++] = c1 >> 6 | 192;
buffer[offset++] = c1 & 63 | 128;
} else if ((c1 & 0xFC00) === 0xD800 && ((c2 = string.charCodeAt(i + 1)) & 0xFC00) === 0xDC00) {
c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF);
++i;
buffer[offset++] = c1 >> 18 | 240;
buffer[offset++] = c1 >> 12 & 63 | 128;
buffer[offset++] = c1 >> 6 & 63 | 128;
buffer[offset++] = c1 & 63 | 128;
} else {
buffer[offset++] = c1 >> 12 | 224;
buffer[offset++] = c1 >> 6 & 63 | 128;
buffer[offset++] = c1 & 63 | 128;
}
}
return offset - start;
};

25
node_modules/@protobufjs/utf8/package.json generated vendored Normal file
View File

@@ -0,0 +1,25 @@
{
"name": "@protobufjs/utf8",
"description": "A minimal UTF8 implementation for number arrays.",
"version": "1.1.0",
"author": "Daniel Wirtz <dcode+protobufjs@dcode.io>",
"repository": {
"type": "git",
"url": "https://github.com/dcodeIO/protobuf.js.git"
},
"license": "BSD-3-Clause",
"main": "index.js",
"types": "index.d.ts",
"devDependencies": {
"istanbul": "^0.4.5",
"tape": "^4.6.3"
},
"scripts": {
"test": "tape tests/*.js",
"coverage": "istanbul cover node_modules/tape/bin/tape tests/*.js"
}
,"_resolved": "https://registry.npmjs.org/@protobufjs/utf8/-/utf8-1.1.0.tgz"
,"_integrity": "sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA="
,"_from": "@protobufjs/utf8@1.1.0"
}

216
node_modules/@protobufjs/utf8/tests/data/utf8.txt generated vendored Normal file
View File

@@ -0,0 +1,216 @@
UTF-8 encoded sample plain-text file
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
Markus Kuhn [ˈmaʳkʊs kuːn] <http://www.cl.cam.ac.uk/~mgk25/> — 2002-07-25 CC BY
The ASCII compatible UTF-8 encoding used in this plain-text file
is defined in Unicode, ISO 10646-1, and RFC 2279.
Using Unicode/UTF-8, you can write in emails and source code things such as
Mathematics and sciences:
∮ E⋅da = Q, n → ∞, ∑ f(i) = ∏ g(i), ⎧⎡⎛┌─────┐⎞⎤⎫
⎪⎢⎜│a²+b³ ⎟⎥⎪
∀x∈: ⌈x⌉ = x⌋, α ∧ ¬β = ¬(¬α β), ⎪⎢⎜│───── ⎟⎥⎪
⎪⎢⎜⎷ c₈ ⎟⎥⎪
⊆ ℕ₀ ⊂ , ⎨⎢⎜ ⎟⎥⎬
⎪⎢⎜ ∞ ⎟⎥⎪
⊥ < a ≠ b ≡ c ≤ d ≪ ⇒ (⟦A⟧ ⇔ ⟪B⟫), ⎪⎢⎜ ⎲ ⎟⎥⎪
⎪⎢⎜ ⎳aⁱ-bⁱ⎟⎥⎪
2H₂ + O₂ ⇌ 2H₂O, R = 4.7 kΩ, ⌀ 200 mm ⎩⎣⎝i=1 ⎠⎦⎭
Linguistics and dictionaries:
ði ıntəˈnæʃənəl fəˈnɛtık əsoʊsiˈeıʃn
Y [ˈʏpsilɔn], Yen [jɛn], Yoga [ˈjoːgɑ]
APL:
((VV)=V)/V←,V ⌷←⍳→⍴∆∇⊃‾⍎⍕⌈
Nicer typography in plain text files:
╔══════════════════════════════════════════╗
║ ║
║ • single and “double” quotes ║
║ ║
║ • Curly apostrophes: “Weve been here” ║
║ ║
║ • Latin-1 apostrophe and accents: '´` ║
║ ║
║ • deutsche „Anführungszeichen“ ║
║ ║
║ • †, ‡, ‰, •, 34, —, 5/+5, ™, … ║
║ ║
║ • ASCII safety test: 1lI|, 0OD, 8B ║
║ ╭─────────╮ ║
║ • the euro symbol: │ 14.95 € │ ║
║ ╰─────────╯ ║
╚══════════════════════════════════════════╝
Combining characters:
STARGΛ̊TE SG-1, a = v̇ = r̈, a⃑ ⊥ b⃑
Greek (in Polytonic):
The Greek anthem:
Σὲ γνωρίζω ἀπὸ τὴν κόψη
τοῦ σπαθιοῦ τὴν τρομερή,
σὲ γνωρίζω ἀπὸ τὴν ὄψη
ποὺ μὲ βία μετράει τὴ γῆ.
᾿Απ᾿ τὰ κόκκαλα βγαλμένη
τῶν ῾Ελλήνων τὰ ἱερά
καὶ σὰν πρῶτα ἀνδρειωμένη
χαῖρε, ὦ χαῖρε, ᾿Ελευθεριά!
From a speech of Demosthenes in the 4th century BC:
Οὐχὶ ταὐτὰ παρίσταταί μοι γιγνώσκειν, ὦ ἄνδρες ᾿Αθηναῖοι,
ὅταν τ᾿ εἰς τὰ πράγματα ἀποβλέψω καὶ ὅταν πρὸς τοὺς
λόγους οὓς ἀκούω· τοὺς μὲν γὰρ λόγους περὶ τοῦ
τιμωρήσασθαι Φίλιππον ὁρῶ γιγνομένους, τὰ δὲ πράγματ᾿
εἰς τοῦτο προήκοντα, ὥσθ᾿ ὅπως μὴ πεισόμεθ᾿ αὐτοὶ
πρότερον κακῶς σκέψασθαι δέον. οὐδέν οὖν ἄλλο μοι δοκοῦσιν
οἱ τὰ τοιαῦτα λέγοντες ἢ τὴν ὑπόθεσιν, περὶ ἧς βουλεύεσθαι,
οὐχὶ τὴν οὖσαν παριστάντες ὑμῖν ἁμαρτάνειν. ἐγὼ δέ, ὅτι μέν
ποτ᾿ ἐξῆν τῇ πόλει καὶ τὰ αὑτῆς ἔχειν ἀσφαλῶς καὶ Φίλιππον
τιμωρήσασθαι, καὶ μάλ᾿ ἀκριβῶς οἶδα· ἐπ᾿ ἐμοῦ γάρ, οὐ πάλαι
γέγονεν ταῦτ᾿ ἀμφότερα· νῦν μέντοι πέπεισμαι τοῦθ᾿ ἱκανὸν
προλαβεῖν ἡμῖν εἶναι τὴν πρώτην, ὅπως τοὺς συμμάχους
σώσομεν. ἐὰν γὰρ τοῦτο βεβαίως ὑπάρξῃ, τότε καὶ περὶ τοῦ
τίνα τιμωρήσεταί τις καὶ ὃν τρόπον ἐξέσται σκοπεῖν· πρὶν δὲ
τὴν ἀρχὴν ὀρθῶς ὑποθέσθαι, μάταιον ἡγοῦμαι περὶ τῆς
τελευτῆς ὁντινοῦν ποιεῖσθαι λόγον.
Δημοσθένους, Γ´ ᾿Ολυνθιακὸς
Georgian:
From a Unicode conference invitation:
გთხოვთ ახლავე გაიაროთ რეგისტრაცია Unicode-ის მეათე საერთაშორისო
კონფერენციაზე დასასწრებად, რომელიც გაიმართება 10-12 მარტს,
ქ. მაინცში, გერმანიაში. კონფერენცია შეჰკრებს ერთად მსოფლიოს
ექსპერტებს ისეთ დარგებში როგორიცაა ინტერნეტი და Unicode-ი,
ინტერნაციონალიზაცია და ლოკალიზაცია, Unicode-ის გამოყენება
ოპერაციულ სისტემებსა, და გამოყენებით პროგრამებში, შრიფტებში,
ტექსტების დამუშავებასა და მრავალენოვან კომპიუტერულ სისტემებში.
Russian:
From a Unicode conference invitation:
Зарегистрируйтесь сейчас на Десятую Международную Конференцию по
Unicode, которая состоится 10-12 марта 1997 года в Майнце в Германии.
Конференция соберет широкий круг экспертов по вопросам глобального
Интернета и Unicode, локализации и интернационализации, воплощению и
применению Unicode в различных операционных системах и программных
приложениях, шрифтах, верстке и многоязычных компьютерных системах.
Thai (UCS Level 2):
Excerpt from a poetry on The Romance of The Three Kingdoms (a Chinese
classic 'San Gua'):
[----------------------------|------------------------]
๏ แผ่นดินฮั่นเสื่อมโทรมแสนสังเวช พระปกเกศกองบู๊กู้ขึ้นใหม่
สิบสองกษัตริย์ก่อนหน้าแลถัดไป สององค์ไซร้โง่เขลาเบาปัญญา
ทรงนับถือขันทีเป็นที่พึ่ง บ้านเมืองจึงวิปริตเป็นนักหนา
โฮจิ๋นเรียกทัพทั่วหัวเมืองมา หมายจะฆ่ามดชั่วตัวสำคัญ
เหมือนขับไสไล่เสือจากเคหา รับหมาป่าเข้ามาเลยอาสัญ
ฝ่ายอ้องอุ้นยุแยกให้แตกกัน ใช้สาวนั้นเป็นชนวนชื่นชวนใจ
พลันลิฉุยกุยกีกลับก่อเหตุ ช่างอาเพศจริงหนาฟ้าร้องไห้
ต้องรบราฆ่าฟันจนบรรลัย ฤๅหาใครค้ำชูกู้บรรลังก์ ฯ
(The above is a two-column text. If combining characters are handled
correctly, the lines of the second column should be aligned with the
| character above.)
Ethiopian:
Proverbs in the Amharic language:
ሰማይ አይታረስ ንጉሥ አይከሰስ።
ብላ ካለኝ እንደአባቴ በቆመጠኝ።
ጌጥ ያለቤቱ ቁምጥና ነው።
ደሀ በሕልሙ ቅቤ ባይጠጣ ንጣት በገደለው።
የአፍ ወለምታ በቅቤ አይታሽም።
አይጥ በበላ ዳዋ ተመታ።
ሲተረጉሙ ይደረግሙ።
ቀስ በቀስ፥ ዕንቁላል በእግሩ ይሄዳል።
ድር ቢያብር አንበሳ ያስር።
ሰው እንደቤቱ እንጅ እንደ ጉረቤቱ አይተዳደርም።
እግዜር የከፈተውን ጉሮሮ ሳይዘጋው አይድርም።
የጎረቤት ሌባ፥ ቢያዩት ይስቅ ባያዩት ያጠልቅ።
ሥራ ከመፍታት ልጄን ላፋታት።
ዓባይ ማደሪያ የለው፥ ግንድ ይዞ ይዞራል።
የእስላም አገሩ መካ የአሞራ አገሩ ዋርካ።
ተንጋሎ ቢተፉ ተመልሶ ባፉ።
ወዳጅህ ማር ቢሆን ጨርስህ አትላሰው።
እግርህን በፍራሽህ ልክ ዘርጋ።
Runes:
ᚻᛖ ᚳᚹᚫᚦ ᚦᚫᛏ ᚻᛖ ᛒᚢᛞᛖ ᚩᚾ ᚦᚫᛗ ᛚᚪᚾᛞᛖ ᚾᚩᚱᚦᚹᛖᚪᚱᛞᚢᛗ ᚹᛁᚦ ᚦᚪ ᚹᛖᛥᚫ
(Old English, which transcribed into Latin reads 'He cwaeth that he
bude thaem lande northweardum with tha Westsae.' and means 'He said
that he lived in the northern land near the Western Sea.')
Braille:
⡌⠁⠧⠑ ⠼⠁⠒ ⡍⠜⠇⠑⠹⠰⠎ ⡣⠕⠌
⡍⠜⠇⠑⠹ ⠺⠁⠎ ⠙⠑⠁⠙⠒ ⠞⠕ ⠃⠑⠛⠔ ⠺⠊⠹⠲ ⡹⠻⠑ ⠊⠎ ⠝⠕ ⠙⠳⠃⠞
⠱⠁⠞⠑⠧⠻ ⠁⠃⠳⠞ ⠹⠁⠞⠲ ⡹⠑ ⠗⠑⠛⠊⠌⠻ ⠕⠋ ⠙⠊⠎ ⠃⠥⠗⠊⠁⠇ ⠺⠁⠎
⠎⠊⠛⠝⠫ ⠃⠹ ⠹⠑ ⠊⠇⠻⠛⠹⠍⠁⠝⠂ ⠹⠑ ⠊⠇⠻⠅⠂ ⠹⠑ ⠥⠝⠙⠻⠞⠁⠅⠻⠂
⠁⠝⠙ ⠹⠑ ⠡⠊⠑⠋ ⠍⠳⠗⠝⠻⠲ ⡎⠊⠗⠕⠕⠛⠑ ⠎⠊⠛⠝⠫ ⠊⠞⠲ ⡁⠝⠙
⡎⠊⠗⠕⠕⠛⠑⠰⠎ ⠝⠁⠍⠑ ⠺⠁⠎ ⠛⠕⠕⠙ ⠥⠏⠕⠝ ⠰⡡⠁⠝⠛⠑⠂ ⠋⠕⠗ ⠁⠝⠹⠹⠔⠛ ⠙⠑
⠡⠕⠎⠑ ⠞⠕ ⠏⠥⠞ ⠙⠊⠎ ⠙⠁⠝⠙ ⠞⠕⠲
⡕⠇⠙ ⡍⠜⠇⠑⠹ ⠺⠁⠎ ⠁⠎ ⠙⠑⠁⠙ ⠁⠎ ⠁ ⠙⠕⠕⠗⠤⠝⠁⠊⠇⠲
⡍⠔⠙⠖ ⡊ ⠙⠕⠝⠰⠞ ⠍⠑⠁⠝ ⠞⠕ ⠎⠁⠹ ⠹⠁⠞ ⡊ ⠅⠝⠪⠂ ⠕⠋ ⠍⠹
⠪⠝ ⠅⠝⠪⠇⠫⠛⠑⠂ ⠱⠁⠞ ⠹⠻⠑ ⠊⠎ ⠏⠜⠞⠊⠊⠥⠇⠜⠇⠹ ⠙⠑⠁⠙ ⠁⠃⠳⠞
⠁ ⠙⠕⠕⠗⠤⠝⠁⠊⠇⠲ ⡊ ⠍⠊⠣⠞ ⠙⠁⠧⠑ ⠃⠑⠲ ⠔⠊⠇⠔⠫⠂ ⠍⠹⠎⠑⠇⠋⠂ ⠞⠕
⠗⠑⠛⠜⠙ ⠁ ⠊⠕⠋⠋⠔⠤⠝⠁⠊⠇ ⠁⠎ ⠹⠑ ⠙⠑⠁⠙⠑⠌ ⠏⠊⠑⠊⠑ ⠕⠋ ⠊⠗⠕⠝⠍⠕⠝⠛⠻⠹
⠔ ⠹⠑ ⠞⠗⠁⠙⠑⠲ ⡃⠥⠞ ⠹⠑ ⠺⠊⠎⠙⠕⠍ ⠕⠋ ⠳⠗ ⠁⠝⠊⠑⠌⠕⠗⠎
⠊⠎ ⠔ ⠹⠑ ⠎⠊⠍⠊⠇⠑⠆ ⠁⠝⠙ ⠍⠹ ⠥⠝⠙⠁⠇⠇⠪⠫ ⠙⠁⠝⠙⠎
⠩⠁⠇⠇ ⠝⠕⠞ ⠙⠊⠌⠥⠗⠃ ⠊⠞⠂ ⠕⠗ ⠹⠑ ⡊⠳⠝⠞⠗⠹⠰⠎ ⠙⠕⠝⠑ ⠋⠕⠗⠲ ⡹⠳
⠺⠊⠇⠇ ⠹⠻⠑⠋⠕⠗⠑ ⠏⠻⠍⠊⠞ ⠍⠑ ⠞⠕ ⠗⠑⠏⠑⠁⠞⠂ ⠑⠍⠏⠙⠁⠞⠊⠊⠁⠇⠇⠹⠂ ⠹⠁⠞
⡍⠜⠇⠑⠹ ⠺⠁⠎ ⠁⠎ ⠙⠑⠁⠙ ⠁⠎ ⠁ ⠙⠕⠕⠗⠤⠝⠁⠊⠇⠲
(The first couple of paragraphs of "A Christmas Carol" by Dickens)
Compact font selection example text:
ABCDEFGHIJKLMNOPQRSTUVWXYZ /0123456789
abcdefghijklmnopqrstuvwxyz £©µÀÆÖÞßéöÿ
–—‘“”„†•…‰™œŠŸž€ ΑΒΓΔΩαβγδω АБВГДабвгд
∀∂∈ℝ∧∪≡∞ ↑↗↨↻⇣ ┐┼╔╘░►☺♀ fi<>⑀₂ἠḂӥẄɐː⍎אԱა
Greetings in various languages:
Hello world, Καλημέρα κόσμε, コンニチハ
Box drawing alignment tests: █
╔══╦══╗ ┌──┬──┐ ╭──┬──╮ ╭──┬──╮ ┏━━┳━━┓ ┎┒┏┑ ╷ ╻ ┏┯┓ ┌┰┐ ▊ ╱╲╱╲╳╳╳
║┌─╨─┐║ │╔═╧═╗│ │╒═╪═╕│ │╓─╁─╖│ ┃┌─╂─┐┃ ┗╃╄┙ ╶┼╴╺╋╸┠┼┨ ┝╋┥ ▋ ╲╱╲╱╳╳╳
║│╲ ╱│║ │║ ║│ ││ │ ││ │║ ┃ ║│ ┃│ ╿ │┃ ┍╅╆┓ ╵ ╹ ┗┷┛ └┸┘ ▌ ╱╲╱╲╳╳╳
╠╡ ╞╣ ├╢ ╟┤ ├┼─┼─┼┤ ├╫─╂─╫┤ ┣┿╾┼╼┿┫ ┕┛┖┚ ┌┄┄┐ ╎ ┏┅┅┓ ┋ ▍ ╲╱╲╱╳╳╳
║│╱ ╲│║ │║ ║│ ││ │ ││ │║ ┃ ║│ ┃│ ╽ │┃ ░░▒▒▓▓██ ┊ ┆ ╎ ╏ ┇ ┋ ▎
║└─╥─┘║ │╚═╤═╝│ │╘═╪═╛│ │╙─╀─╜│ ┃└─╂─┘┃ ░░▒▒▓▓██ ┊ ┆ ╎ ╏ ┇ ┋ ▏
╚══╩══╝ └──┴──┘ ╰──┴──╯ ╰──┴──╯ ┗━━┻━━┛ ▗▄▖▛▀▜ └╌╌┘ ╎ ┗╍╍┛ ┋ ▁▂▃▄▅▆▇█
▝▀▘▙▄▟
Surrogates:
𠜎 𠜱 𠝹 𠱓 𠱸 𠲖 𠳏 𠳕 𠴕 𠵼 𠵿 𠸎 𠸏 𠹷 𠺝 𠺢 𠻗 𠻹 𠻺 𠼭 𠼮 𠽌 𠾴 𠾼 𠿪 𡁜 𡁯 𡁵 𡁶 𡁻 𡃁
𡃉 𡇙 𢃇 𢞵 𢫕 𢭃 𢯊 𢱑 𢱕 𢳂 𢴈 𢵌 𢵧 𢺳 𣲷 𤓓 𤶸 𤷪 𥄫 𦉘 𦟌 𦧲 𦧺 𧨾 𨅝 𨈇 𨋢 𨳊 𨳍 𨳒 𩶘

57
node_modules/@protobufjs/utf8/tests/index.js generated vendored Normal file
View File

@@ -0,0 +1,57 @@
var tape = require("tape");
var utf8 = require("..");
var data = require("fs").readFileSync(require.resolve("./data/utf8.txt")),
dataStr = data.toString("utf8");
tape.test("utf8", function(test) {
test.test(test.name + " - length", function(test) {
test.equal(utf8.length(""), 0, "should return a byte length of zero for an empty string");
test.equal(utf8.length(dataStr), Buffer.byteLength(dataStr), "should return the same byte length as node buffers");
test.end();
});
test.test(test.name + " - read", function(test) {
var comp = utf8.read([], 0, 0);
test.equal(comp, "", "should decode an empty buffer to an empty string");
comp = utf8.read(data, 0, data.length);
test.equal(comp, data.toString("utf8"), "should decode to the same byte data as node buffers");
var longData = Buffer.concat([data, data, data, data]);
comp = utf8.read(longData, 0, longData.length);
test.equal(comp, longData.toString("utf8"), "should decode to the same byte data as node buffers (long)");
var chunkData = new Buffer(data.toString("utf8").substring(0, 8192));
comp = utf8.read(chunkData, 0, chunkData.length);
test.equal(comp, chunkData.toString("utf8"), "should decode to the same byte data as node buffers (chunk size)");
test.end();
});
test.test(test.name + " - write", function(test) {
var buf = new Buffer(0);
test.equal(utf8.write("", buf, 0), 0, "should encode an empty string to an empty buffer");
var len = utf8.length(dataStr);
buf = new Buffer(len);
test.equal(utf8.write(dataStr, buf, 0), len, "should encode to exactly " + len + " bytes");
test.equal(buf.length, data.length, "should encode to a buffer length equal to that of node buffers");
for (var i = 0; i < buf.length; ++i) {
if (buf[i] !== data[i]) {
test.fail("should encode to the same buffer data as node buffers (offset " + i + ")");
return;
}
}
test.pass("should encode to the same buffer data as node buffers");
test.end();
});
});

21
node_modules/@types/long/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) Microsoft Corporation. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE

16
node_modules/@types/long/README.md generated vendored Normal file
View File

@@ -0,0 +1,16 @@
# Installation
> `npm install --save @types/long`
# Summary
This package contains type definitions for long.js (https://github.com/dcodeIO/long.js).
# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/long.
### Additional Details
* Last updated: Wed, 22 Jan 2020 19:19:46 GMT
* Dependencies: none
* Global values: `Long`
# Credits
These definitions were written by Peter Kooijmans (https://github.com/peterkooijmans).

389
node_modules/@types/long/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,389 @@
// Type definitions for long.js 4.0.0
// Project: https://github.com/dcodeIO/long.js
// Definitions by: Peter Kooijmans <https://github.com/peterkooijmans>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Definitions by: Denis Cappellin <https://github.com/cappellin>
export = Long;
export as namespace Long;
declare const Long: Long.LongConstructor;
type Long = Long.Long;
declare namespace Long {
interface LongConstructor {
/**
* Constructs a 64 bit two's-complement integer, given its low and high 32 bit values as signed integers. See the from* functions below for more convenient ways of constructing Longs.
*/
new( low: number, high?: number, unsigned?: boolean ): Long;
prototype: Long;
/**
* Maximum unsigned value.
*/
MAX_UNSIGNED_VALUE: Long;
/**
* Maximum signed value.
*/
MAX_VALUE: Long;
/**
* Minimum signed value.
*/
MIN_VALUE: Long;
/**
* Signed negative one.
*/
NEG_ONE: Long;
/**
* Signed one.
*/
ONE: Long;
/**
* Unsigned one.
*/
UONE: Long;
/**
* Unsigned zero.
*/
UZERO: Long;
/**
* Signed zero
*/
ZERO: Long;
/**
* Returns a Long representing the 64 bit integer that comes by concatenating the given low and high bits. Each is assumed to use 32 bits.
*/
fromBits( lowBits:number, highBits:number, unsigned?:boolean ): Long;
/**
* Returns a Long representing the given 32 bit integer value.
*/
fromInt( value: number, unsigned?: boolean ): Long;
/**
* Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned.
*/
fromNumber( value: number, unsigned?: boolean ): Long;
/**
* Returns a Long representation of the given string, written using the specified radix.
*/
fromString( str: string, unsigned?: boolean | number, radix?: number ): Long;
/**
* Creates a Long from its byte representation.
*/
fromBytes( bytes: number[], unsigned?: boolean, le?: boolean ): Long;
/**
* Creates a Long from its little endian byte representation.
*/
fromBytesLE( bytes: number[], unsigned?: boolean ): Long;
/**
* Creates a Long from its little endian byte representation.
*/
fromBytesBE( bytes: number[], unsigned?: boolean ): Long;
/**
* Tests if the specified object is a Long.
*/
isLong( obj: any ): obj is Long;
/**
* Converts the specified value to a Long.
*/
fromValue( val: Long | number | string | {low: number, high: number, unsigned: boolean} ): Long;
}
interface Long
{
/**
* The high 32 bits as a signed value.
*/
high: number;
/**
* The low 32 bits as a signed value.
*/
low: number;
/**
* Whether unsigned or not.
*/
unsigned: boolean;
/**
* Returns the sum of this and the specified Long.
*/
add( addend: number | Long | string ): Long;
/**
* Returns the bitwise AND of this Long and the specified.
*/
and( other: Long | number | string ): Long;
/**
* Compares this Long's value with the specified's.
*/
compare( other: Long | number | string ): number;
/**
* Compares this Long's value with the specified's.
*/
comp( other: Long | number | string ): number;
/**
* Returns this Long divided by the specified.
*/
divide( divisor: Long | number | string ): Long;
/**
* Returns this Long divided by the specified.
*/
div( divisor: Long | number | string ): Long;
/**
* Tests if this Long's value equals the specified's.
*/
equals( other: Long | number | string ): boolean;
/**
* Tests if this Long's value equals the specified's.
*/
eq( other: Long | number | string ): boolean;
/**
* Gets the high 32 bits as a signed integer.
*/
getHighBits(): number;
/**
* Gets the high 32 bits as an unsigned integer.
*/
getHighBitsUnsigned(): number;
/**
* Gets the low 32 bits as a signed integer.
*/
getLowBits(): number;
/**
* Gets the low 32 bits as an unsigned integer.
*/
getLowBitsUnsigned(): number;
/**
* Gets the number of bits needed to represent the absolute value of this Long.
*/
getNumBitsAbs(): number;
/**
* Tests if this Long's value is greater than the specified's.
*/
greaterThan( other: Long | number | string ): boolean;
/**
* Tests if this Long's value is greater than the specified's.
*/
gt( other: Long | number | string ): boolean;
/**
* Tests if this Long's value is greater than or equal the specified's.
*/
greaterThanOrEqual( other: Long | number | string ): boolean;
/**
* Tests if this Long's value is greater than or equal the specified's.
*/
gte( other: Long | number | string ): boolean;
/**
* Tests if this Long's value is even.
*/
isEven(): boolean;
/**
* Tests if this Long's value is negative.
*/
isNegative(): boolean;
/**
* Tests if this Long's value is odd.
*/
isOdd(): boolean;
/**
* Tests if this Long's value is positive.
*/
isPositive(): boolean;
/**
* Tests if this Long's value equals zero.
*/
isZero(): boolean;
/**
* Tests if this Long's value is less than the specified's.
*/
lessThan( other: Long | number | string ): boolean;
/**
* Tests if this Long's value is less than the specified's.
*/
lt( other: Long | number | string ): boolean;
/**
* Tests if this Long's value is less than or equal the specified's.
*/
lessThanOrEqual( other: Long | number | string ): boolean;
/**
* Tests if this Long's value is less than or equal the specified's.
*/
lte( other: Long | number | string ): boolean;
/**
* Returns this Long modulo the specified.
*/
modulo( other: Long | number | string ): Long;
/**
* Returns this Long modulo the specified.
*/
mod( other: Long | number | string ): Long;
/**
* Returns the product of this and the specified Long.
*/
multiply( multiplier: Long | number | string ): Long;
/**
* Returns the product of this and the specified Long.
*/
mul( multiplier: Long | number | string ): Long;
/**
* Negates this Long's value.
*/
negate(): Long;
/**
* Negates this Long's value.
*/
neg(): Long;
/**
* Returns the bitwise NOT of this Long.
*/
not(): Long;
/**
* Tests if this Long's value differs from the specified's.
*/
notEquals( other: Long | number | string ): boolean;
/**
* Tests if this Long's value differs from the specified's.
*/
neq( other: Long | number | string ): boolean;
/**
* Returns the bitwise OR of this Long and the specified.
*/
or( other: Long | number | string ): Long;
/**
* Returns this Long with bits shifted to the left by the given amount.
*/
shiftLeft( numBits: number | Long ): Long;
/**
* Returns this Long with bits shifted to the left by the given amount.
*/
shl( numBits: number | Long ): Long;
/**
* Returns this Long with bits arithmetically shifted to the right by the given amount.
*/
shiftRight( numBits: number | Long ): Long;
/**
* Returns this Long with bits arithmetically shifted to the right by the given amount.
*/
shr( numBits: number | Long ): Long;
/**
* Returns this Long with bits logically shifted to the right by the given amount.
*/
shiftRightUnsigned( numBits: number | Long ): Long;
/**
* Returns this Long with bits logically shifted to the right by the given amount.
*/
shru( numBits: number | Long ): Long;
/**
* Returns the difference of this and the specified Long.
*/
subtract( subtrahend: number | Long | string ): Long;
/**
* Returns the difference of this and the specified Long.
*/
sub( subtrahend: number | Long |string ): Long;
/**
* Converts the Long to a 32 bit integer, assuming it is a 32 bit integer.
*/
toInt(): number;
/**
* Converts the Long to a the nearest floating-point representation of this value (double, 53 bit mantissa).
*/
toNumber(): number;
/**
* Converts this Long to its byte representation.
*/
toBytes( le?: boolean ): number[];
/**
* Converts this Long to its little endian byte representation.
*/
toBytesLE(): number[];
/**
* Converts this Long to its big endian byte representation.
*/
toBytesBE(): number[];
/**
* Converts this Long to signed.
*/
toSigned(): Long;
/**
* Converts the Long to a string written in the specified radix.
*/
toString( radix?: number ): string;
/**
* Converts this Long to unsigned.
*/
toUnsigned(): Long;
/**
* Returns the bitwise XOR of this Long and the given one.
*/
xor( other: Long | number | string ): Long;
}
}

28
node_modules/@types/long/package.json generated vendored Normal file
View File

@@ -0,0 +1,28 @@
{
"name": "@types/long",
"version": "4.0.1",
"description": "TypeScript definitions for long.js",
"license": "MIT",
"contributors": [
{
"name": "Peter Kooijmans",
"url": "https://github.com/peterkooijmans",
"githubUsername": "peterkooijmans"
}
],
"main": "",
"types": "index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
"directory": "types/long"
},
"scripts": {},
"dependencies": {},
"typesPublisherContentHash": "5a2ae1424989c49d7303e1f5cc510288bfab1e71e0e2143cdcb9d24ff1c3dc8e",
"typeScriptVersion": "2.8"
,"_resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.1.tgz"
,"_integrity": "sha512-5tXH6Bx/kNGd3MgffdmP4dy2Z+G4eaXw0SE81Tq3BNadtnMR5/ySMzX4SLEzHJzSmPNn4HIdpQsBvXMUykr58w=="
,"_from": "@types/long@4.0.1"
}

21
node_modules/@types/node/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) Microsoft Corporation. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE

16
node_modules/@types/node/README.md generated vendored Normal file
View File

@@ -0,0 +1,16 @@
# Installation
> `npm install --save @types/node`
# Summary
This package contains type definitions for Node.js (http://nodejs.org/).
# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node/v10.
### Additional Details
* Last updated: Fri, 28 Feb 2020 18:57:47 GMT
* Dependencies: none
* Global values: `Buffer`, `NodeJS`, `Symbol`, `__dirname`, `__filename`, `clearImmediate`, `clearInterval`, `clearTimeout`, `console`, `exports`, `global`, `module`, `process`, `require`, `setImmediate`, `setInterval`, `setTimeout`
# Credits
These definitions were written by [Microsoft TypeScript](https://github.com/Microsoft), [DefinitelyTyped](https://github.com/DefinitelyTyped), [Alberto Schiabel](https://github.com/jkomyno), [Alexander T.](https://github.com/a-tarasyuk), [Alvis HT Tang](https://github.com/alvis), [Andrew Makarov](https://github.com/r3nya), [Bruno Scheufler](https://github.com/brunoscheufler), [Chigozirim C.](https://github.com/smac89), [Christian Vaagland Tellnes](https://github.com/tellnes), [Deividas Bakanas](https://github.com/DeividasBakanas), [Eugene Y. Q. Shen](https://github.com/eyqs), [Flarna](https://github.com/Flarna), [Hannes Magnusson](https://github.com/Hannes-Magnusson-CK), [Hoàng Văn Khải](https://github.com/KSXGitHub), [Huw](https://github.com/hoo29), [Kelvin Jin](https://github.com/kjin), [Klaus Meinhardt](https://github.com/ajafff), [Lishude](https://github.com/islishude), [Mariusz Wiktorczyk](https://github.com/mwiktorczyk), [Mohsen Azimi](https://github.com/mohsen1), [Nicolas Even](https://github.com/n-e), [Nicolas Voigt](https://github.com/octo-sniffle), [Nikita Galkin](https://github.com/galkin), [Parambir Singh](https://github.com/parambirs), [Sebastian Silbermann](https://github.com/eps1lon), [Simon Schick](https://github.com/SimonSchick), [Thomas den Hollander](https://github.com/ThomasdenH), [Wilco Bakker](https://github.com/WilcoBakker), [wwwy3y3](https://github.com/wwwy3y3), [Zane Hannan AU](https://github.com/ZaneHannanAU), [Jeremie Rodriguez](https://github.com/jeremiergz), [Samuel Ainsworth](https://github.com/samuela), [Kyle Uehlein](https://github.com/kuehlein), [Jordi Oliveras Rovira](https://github.com/j-oliveras), [Thanik Bhongbhibhat](https://github.com/bhongy), [Minh Son Nguyen](https://github.com/nguymin4), and [ExE Boss](https://github.com/ExE-Boss).

52
node_modules/@types/node/assert.d.ts generated vendored Normal file
View File

@@ -0,0 +1,52 @@
declare module "assert" {
function internal(value: any, message?: string | Error): void;
namespace internal {
class AssertionError implements Error {
name: string;
message: string;
actual: any;
expected: any;
operator: string;
generatedMessage: boolean;
code: 'ERR_ASSERTION';
constructor(options?: {
message?: string; actual?: any; expected?: any;
operator?: string; stackStartFn?: Function
});
}
function fail(message?: string | Error): never;
/** @deprecated since v10.0.0 - use fail([message]) or other assert functions instead. */
function fail(actual: any, expected: any, message?: string | Error, operator?: string, stackStartFn?: Function): never;
function ok(value: any, message?: string | Error): void;
/** @deprecated since v9.9.0 - use strictEqual() instead. */
function equal(actual: any, expected: any, message?: string | Error): void;
/** @deprecated since v9.9.0 - use notStrictEqual() instead. */
function notEqual(actual: any, expected: any, message?: string | Error): void;
/** @deprecated since v9.9.0 - use deepStrictEqual() instead. */
function deepEqual(actual: any, expected: any, message?: string | Error): void;
/** @deprecated since v9.9.0 - use notDeepStrictEqual() instead. */
function notDeepEqual(actual: any, expected: any, message?: string | Error): void;
function strictEqual(actual: any, expected: any, message?: string | Error): void;
function notStrictEqual(actual: any, expected: any, message?: string | Error): void;
function deepStrictEqual(actual: any, expected: any, message?: string | Error): void;
function notDeepStrictEqual(actual: any, expected: any, message?: string | Error): void;
function throws(block: Function, message?: string | Error): void;
function throws(block: Function, error: RegExp | Function | Object | Error, message?: string | Error): void;
function doesNotThrow(block: Function, message?: string | Error): void;
function doesNotThrow(block: Function, error: RegExp | Function, message?: string | Error): void;
function ifError(value: any): void;
function rejects(block: Function | Promise<any>, message?: string | Error): Promise<void>;
function rejects(block: Function | Promise<any>, error: RegExp | Function | Object | Error, message?: string | Error): Promise<void>;
function doesNotReject(block: Function | Promise<any>, message?: string | Error): Promise<void>;
function doesNotReject(block: Function | Promise<any>, error: RegExp | Function, message?: string | Error): Promise<void>;
const strict: typeof internal;
}
export = internal;
}

144
node_modules/@types/node/async_hooks.d.ts generated vendored Normal file
View File

@@ -0,0 +1,144 @@
/**
* Async Hooks module: https://nodejs.org/api/async_hooks.html
*/
declare module "async_hooks" {
/**
* Returns the asyncId of the current execution context.
*/
function executionAsyncId(): number;
/**
* Returns the ID of the resource responsible for calling the callback that is currently being executed.
*/
function triggerAsyncId(): number;
interface HookCallbacks {
/**
* Called when a class is constructed that has the possibility to emit an asynchronous event.
* @param asyncId a unique ID for the async resource
* @param type the type of the async resource
* @param triggerAsyncId the unique ID of the async resource in whose execution context this async resource was created
* @param resource reference to the resource representing the async operation, needs to be released during destroy
*/
init?(asyncId: number, type: string, triggerAsyncId: number, resource: Object): void;
/**
* When an asynchronous operation is initiated or completes a callback is called to notify the user.
* The before callback is called just before said callback is executed.
* @param asyncId the unique identifier assigned to the resource about to execute the callback.
*/
before?(asyncId: number): void;
/**
* Called immediately after the callback specified in before is completed.
* @param asyncId the unique identifier assigned to the resource which has executed the callback.
*/
after?(asyncId: number): void;
/**
* Called when a promise has resolve() called. This may not be in the same execution id
* as the promise itself.
* @param asyncId the unique id for the promise that was resolve()d.
*/
promiseResolve?(asyncId: number): void;
/**
* Called after the resource corresponding to asyncId is destroyed
* @param asyncId a unique ID for the async resource
*/
destroy?(asyncId: number): void;
}
interface AsyncHook {
/**
* Enable the callbacks for a given AsyncHook instance. If no callbacks are provided enabling is a noop.
*/
enable(): this;
/**
* Disable the callbacks for a given AsyncHook instance from the global pool of AsyncHook callbacks to be executed. Once a hook has been disabled it will not be called again until enabled.
*/
disable(): this;
}
/**
* Registers functions to be called for different lifetime events of each async operation.
* @param options the callbacks to register
* @return an AsyncHooks instance used for disabling and enabling hooks
*/
function createHook(options: HookCallbacks): AsyncHook;
interface AsyncResourceOptions {
/**
* The ID of the execution context that created this async event.
* Default: `executionAsyncId()`
*/
triggerAsyncId?: number;
/**
* Disables automatic `emitDestroy` when the object is garbage collected.
* This usually does not need to be set (even if `emitDestroy` is called
* manually), unless the resource's `asyncId` is retrieved and the
* sensitive API's `emitDestroy` is called with it.
* Default: `false`
*/
requireManualDestroy?: boolean;
}
/**
* The class AsyncResource was designed to be extended by the embedder's async resources.
* Using this users can easily trigger the lifetime events of their own resources.
*/
class AsyncResource {
/**
* AsyncResource() is meant to be extended. Instantiating a
* new AsyncResource() also triggers init. If triggerAsyncId is omitted then
* async_hook.executionAsyncId() is used.
* @param type The type of async event.
* @param triggerAsyncId The ID of the execution context that created
* this async event (default: `executionAsyncId()`), or an
* AsyncResourceOptions object (since 9.3)
*/
constructor(type: string, triggerAsyncId?: number|AsyncResourceOptions);
/**
* Call AsyncHooks before callbacks.
* @deprecated since 9.6 - Use asyncResource.runInAsyncScope() instead.
*/
emitBefore(): void;
/**
* Call AsyncHooks after callbacks.
* @deprecated since 9.6 - Use asyncResource.runInAsyncScope() instead.
*/
emitAfter(): void;
/**
* Call the provided function with the provided arguments in the
* execution context of the async resource. This will establish the
* context, trigger the AsyncHooks before callbacks, call the function,
* trigger the AsyncHooks after callbacks, and then restore the original
* execution context.
* @param fn The function to call in the execution context of this
* async resource.
* @param thisArg The receiver to be used for the function call.
* @param args Optional arguments to pass to the function.
*/
runInAsyncScope<This, Result>(fn: (this: This, ...args: any[]) => Result, thisArg?: This, ...args: any[]): Result;
/**
* Call AsyncHooks destroy callbacks.
*/
emitDestroy(): void;
/**
* @return the unique ID assigned to this AsyncResource instance.
*/
asyncId(): number;
/**
* @return the trigger ID for this AsyncResource instance.
*/
triggerAsyncId(): number;
}
}

41
node_modules/@types/node/base.d.ts generated vendored Normal file
View File

@@ -0,0 +1,41 @@
// base definnitions for all NodeJS modules that are not specific to any version of TypeScript
/// <reference path="globals.d.ts" />
/// <reference path="assert.d.ts" />
/// <reference path="async_hooks.d.ts" />
/// <reference path="buffer.d.ts" />
/// <reference path="child_process.d.ts" />
/// <reference path="cluster.d.ts" />
/// <reference path="console.d.ts" />
/// <reference path="constants.d.ts" />
/// <reference path="crypto.d.ts" />
/// <reference path="dgram.d.ts" />
/// <reference path="dns.d.ts" />
/// <reference path="domain.d.ts" />
/// <reference path="events.d.ts" />
/// <reference path="fs.d.ts" />
/// <reference path="http.d.ts" />
/// <reference path="http2.d.ts" />
/// <reference path="https.d.ts" />
/// <reference path="inspector.d.ts" />
/// <reference path="module.d.ts" />
/// <reference path="net.d.ts" />
/// <reference path="os.d.ts" />
/// <reference path="path.d.ts" />
/// <reference path="perf_hooks.d.ts" />
/// <reference path="process.d.ts" />
/// <reference path="punycode.d.ts" />
/// <reference path="querystring.d.ts" />
/// <reference path="readline.d.ts" />
/// <reference path="repl.d.ts" />
/// <reference path="stream.d.ts" />
/// <reference path="string_decoder.d.ts" />
/// <reference path="timers.d.ts" />
/// <reference path="tls.d.ts" />
/// <reference path="trace_events.d.ts" />
/// <reference path="tty.d.ts" />
/// <reference path="url.d.ts" />
/// <reference path="util.d.ts" />
/// <reference path="v8.d.ts" />
/// <reference path="vm.d.ts" />
/// <reference path="worker_threads.d.ts" />
/// <reference path="zlib.d.ts" />

16
node_modules/@types/node/buffer.d.ts generated vendored Normal file
View File

@@ -0,0 +1,16 @@
declare module "buffer" {
export const INSPECT_MAX_BYTES: number;
const BuffType: typeof Buffer;
export type TranscodeEncoding = "ascii" | "utf8" | "utf16le" | "ucs2" | "latin1" | "binary";
export function transcode(source: Buffer | Uint8Array, fromEnc: TranscodeEncoding, toEnc: TranscodeEncoding): Buffer;
export const SlowBuffer: {
/** @deprecated since v6.0.0, use Buffer.allocUnsafeSlow() */
new(size: number): Buffer;
prototype: Buffer;
};
export { BuffType as Buffer };
}

366
node_modules/@types/node/child_process.d.ts generated vendored Normal file
View File

@@ -0,0 +1,366 @@
declare module "child_process" {
import * as events from "events";
import * as stream from "stream";
import * as net from "net";
interface ChildProcess extends events.EventEmitter {
stdin: stream.Writable;
stdout: stream.Readable;
stderr: stream.Readable;
readonly channel?: stream.Pipe | null;
stdio: [stream.Writable, stream.Readable, stream.Readable];
killed: boolean;
pid: number;
kill(signal?: string): void;
send(message: any, callback?: (error: Error) => void): boolean;
send(message: any, sendHandle?: net.Socket | net.Server, callback?: (error: Error) => void): boolean;
send(message: any, sendHandle?: net.Socket | net.Server, options?: MessageOptions, callback?: (error: Error) => void): boolean;
connected: boolean;
disconnect(): void;
unref(): void;
ref(): void;
/**
* events.EventEmitter
* 1. close
* 2. disconnect
* 3. error
* 4. exit
* 5. message
*/
addListener(event: string, listener: (...args: any[]) => void): this;
addListener(event: "close", listener: (code: number, signal: string) => void): this;
addListener(event: "disconnect", listener: () => void): this;
addListener(event: "error", listener: (err: Error) => void): this;
addListener(event: "exit", listener: (code: number | null, signal: string | null) => void): this;
addListener(event: "message", listener: (message: any, sendHandle: net.Socket | net.Server) => void): this;
emit(event: string | symbol, ...args: any[]): boolean;
emit(event: "close", code: number, signal: string): boolean;
emit(event: "disconnect"): boolean;
emit(event: "error", err: Error): boolean;
emit(event: "exit", code: number | null, signal: string | null): boolean;
emit(event: "message", message: any, sendHandle: net.Socket | net.Server): boolean;
on(event: string, listener: (...args: any[]) => void): this;
on(event: "close", listener: (code: number, signal: string) => void): this;
on(event: "disconnect", listener: () => void): this;
on(event: "error", listener: (err: Error) => void): this;
on(event: "exit", listener: (code: number | null, signal: string | null) => void): this;
on(event: "message", listener: (message: any, sendHandle: net.Socket | net.Server) => void): this;
once(event: string, listener: (...args: any[]) => void): this;
once(event: "close", listener: (code: number, signal: string) => void): this;
once(event: "disconnect", listener: () => void): this;
once(event: "error", listener: (err: Error) => void): this;
once(event: "exit", listener: (code: number | null, signal: string | null) => void): this;
once(event: "message", listener: (message: any, sendHandle: net.Socket | net.Server) => void): this;
prependListener(event: string, listener: (...args: any[]) => void): this;
prependListener(event: "close", listener: (code: number, signal: string) => void): this;
prependListener(event: "disconnect", listener: () => void): this;
prependListener(event: "error", listener: (err: Error) => void): this;
prependListener(event: "exit", listener: (code: number | null, signal: string | null) => void): this;
prependListener(event: "message", listener: (message: any, sendHandle: net.Socket | net.Server) => void): this;
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
prependOnceListener(event: "close", listener: (code: number, signal: string) => void): this;
prependOnceListener(event: "disconnect", listener: () => void): this;
prependOnceListener(event: "error", listener: (err: Error) => void): this;
prependOnceListener(event: "exit", listener: (code: number | null, signal: string | null) => void): this;
prependOnceListener(event: "message", listener: (message: any, sendHandle: net.Socket | net.Server) => void): this;
}
interface MessageOptions {
keepOpen?: boolean;
}
type StdioOptions = "pipe" | "ignore" | "inherit" | Array<("pipe" | "ipc" | "ignore" | "inherit" | stream.Stream | number | null | undefined)>;
interface SpawnOptions {
cwd?: string;
env?: NodeJS.ProcessEnv;
argv0?: string;
stdio?: StdioOptions;
detached?: boolean;
uid?: number;
gid?: number;
shell?: boolean | string;
windowsVerbatimArguments?: boolean;
windowsHide?: boolean;
}
function spawn(command: string, options?: SpawnOptions): ChildProcess;
function spawn(command: string, args?: ReadonlyArray<string>, options?: SpawnOptions): ChildProcess;
interface ExecOptions {
cwd?: string;
env?: NodeJS.ProcessEnv;
shell?: string;
timeout?: number;
maxBuffer?: number;
killSignal?: string;
uid?: number;
gid?: number;
windowsHide?: boolean;
}
interface ExecOptionsWithStringEncoding extends ExecOptions {
encoding: BufferEncoding;
}
interface ExecOptionsWithBufferEncoding extends ExecOptions {
encoding: string | null; // specify `null`.
}
interface ExecException extends Error {
cmd?: string;
killed?: boolean;
code?: number;
signal?: string;
}
// no `options` definitely means stdout/stderr are `string`.
function exec(command: string, callback?: (error: ExecException | null, stdout: string, stderr: string) => void): ChildProcess;
// `options` with `"buffer"` or `null` for `encoding` means stdout/stderr are definitely `Buffer`.
function exec(command: string, options: { encoding: "buffer" | null } & ExecOptions, callback?: (error: ExecException | null, stdout: Buffer, stderr: Buffer) => void): ChildProcess;
// `options` with well known `encoding` means stdout/stderr are definitely `string`.
function exec(command: string, options: { encoding: BufferEncoding } & ExecOptions, callback?: (error: ExecException | null, stdout: string, stderr: string) => void): ChildProcess;
// `options` with an `encoding` whose type is `string` means stdout/stderr could either be `Buffer` or `string`.
// There is no guarantee the `encoding` is unknown as `string` is a superset of `BufferEncoding`.
function exec(command: string, options: { encoding: string } & ExecOptions, callback?: (error: ExecException | null, stdout: string | Buffer, stderr: string | Buffer) => void): ChildProcess;
// `options` without an `encoding` means stdout/stderr are definitely `string`.
function exec(command: string, options: ExecOptions, callback?: (error: ExecException | null, stdout: string, stderr: string) => void): ChildProcess;
// fallback if nothing else matches. Worst case is always `string | Buffer`.
function exec(
command: string,
options: ({ encoding?: string | null } & ExecOptions) | undefined | null,
callback?: (error: ExecException | null, stdout: string | Buffer, stderr: string | Buffer) => void,
): ChildProcess;
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
namespace exec {
function __promisify__(command: string): Promise<{ stdout: string, stderr: string }>;
function __promisify__(command: string, options: { encoding: "buffer" | null } & ExecOptions): Promise<{ stdout: Buffer, stderr: Buffer }>;
function __promisify__(command: string, options: { encoding: BufferEncoding } & ExecOptions): Promise<{ stdout: string, stderr: string }>;
function __promisify__(command: string, options: ExecOptions): Promise<{ stdout: string, stderr: string }>;
function __promisify__(command: string, options?: ({ encoding?: string | null } & ExecOptions) | null): Promise<{ stdout: string | Buffer, stderr: string | Buffer }>;
}
interface ExecFileOptions {
cwd?: string;
env?: NodeJS.ProcessEnv;
timeout?: number;
maxBuffer?: number;
killSignal?: string;
uid?: number;
gid?: number;
windowsHide?: boolean;
windowsVerbatimArguments?: boolean;
shell?: boolean | string;
}
interface ExecFileOptionsWithStringEncoding extends ExecFileOptions {
encoding: BufferEncoding;
}
interface ExecFileOptionsWithBufferEncoding extends ExecFileOptions {
encoding: 'buffer' | null;
}
interface ExecFileOptionsWithOtherEncoding extends ExecFileOptions {
encoding: string;
}
function execFile(file: string): ChildProcess;
function execFile(file: string, options: ({ encoding?: string | null } & ExecFileOptions) | undefined | null): ChildProcess;
function execFile(file: string, args?: ReadonlyArray<string> | null): ChildProcess;
function execFile(file: string, args: ReadonlyArray<string> | undefined | null, options: ({ encoding?: string | null } & ExecFileOptions) | undefined | null): ChildProcess;
// no `options` definitely means stdout/stderr are `string`.
function execFile(file: string, callback: (error: ExecException | null, stdout: string, stderr: string) => void): ChildProcess;
function execFile(file: string, args: ReadonlyArray<string> | undefined | null, callback: (error: ExecException | null, stdout: string, stderr: string) => void): ChildProcess;
// `options` with `"buffer"` or `null` for `encoding` means stdout/stderr are definitely `Buffer`.
function execFile(file: string, options: ExecFileOptionsWithBufferEncoding, callback: (error: ExecException | null, stdout: Buffer, stderr: Buffer) => void): ChildProcess;
function execFile(
file: string,
args: ReadonlyArray<string> | undefined | null,
options: ExecFileOptionsWithBufferEncoding,
callback: (error: ExecException | null, stdout: Buffer, stderr: Buffer) => void,
): ChildProcess;
// `options` with well known `encoding` means stdout/stderr are definitely `string`.
function execFile(file: string, options: ExecFileOptionsWithStringEncoding, callback: (error: ExecException | null, stdout: string, stderr: string) => void): ChildProcess;
function execFile(
file: string,
args: ReadonlyArray<string> | undefined | null,
options: ExecFileOptionsWithStringEncoding,
callback: (error: ExecException | null, stdout: string, stderr: string) => void,
): ChildProcess;
// `options` with an `encoding` whose type is `string` means stdout/stderr could either be `Buffer` or `string`.
// There is no guarantee the `encoding` is unknown as `string` is a superset of `BufferEncoding`.
function execFile(
file: string,
options: ExecFileOptionsWithOtherEncoding,
callback: (error: ExecException | null, stdout: string | Buffer, stderr: string | Buffer) => void,
): ChildProcess;
function execFile(
file: string,
args: ReadonlyArray<string> | undefined | null,
options: ExecFileOptionsWithOtherEncoding,
callback: (error: ExecException | null, stdout: string | Buffer, stderr: string | Buffer) => void,
): ChildProcess;
// `options` without an `encoding` means stdout/stderr are definitely `string`.
function execFile(file: string, options: ExecFileOptions, callback: (error: ExecException | null, stdout: string, stderr: string) => void): ChildProcess;
function execFile(
file: string,
args: ReadonlyArray<string> | undefined | null,
options: ExecFileOptions,
callback: (error: ExecException | null, stdout: string, stderr: string) => void
): ChildProcess;
// fallback if nothing else matches. Worst case is always `string | Buffer`.
function execFile(
file: string,
options: ({ encoding?: string | null } & ExecFileOptions) | undefined | null,
callback: ((error: ExecException | null, stdout: string | Buffer, stderr: string | Buffer) => void) | undefined | null,
): ChildProcess;
function execFile(
file: string,
args: ReadonlyArray<string> | undefined | null,
options: ({ encoding?: string | null } & ExecFileOptions) | undefined | null,
callback: ((error: ExecException | null, stdout: string | Buffer, stderr: string | Buffer) => void) | undefined | null,
): ChildProcess;
// NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
namespace execFile {
function __promisify__(file: string): Promise<{ stdout: string, stderr: string }>;
function __promisify__(file: string, args: string[] | undefined | null): Promise<{ stdout: string, stderr: string }>;
function __promisify__(file: string, options: ExecFileOptionsWithBufferEncoding): Promise<{ stdout: Buffer, stderr: Buffer }>;
function __promisify__(file: string, args: string[] | undefined | null, options: ExecFileOptionsWithBufferEncoding): Promise<{ stdout: Buffer, stderr: Buffer }>;
function __promisify__(file: string, options: ExecFileOptionsWithStringEncoding): Promise<{ stdout: string, stderr: string }>;
function __promisify__(file: string, args: string[] | undefined | null, options: ExecFileOptionsWithStringEncoding): Promise<{ stdout: string, stderr: string }>;
function __promisify__(file: string, options: ExecFileOptionsWithOtherEncoding): Promise<{ stdout: string | Buffer, stderr: string | Buffer }>;
function __promisify__(file: string, args: string[] | undefined | null, options: ExecFileOptionsWithOtherEncoding): Promise<{ stdout: string | Buffer, stderr: string | Buffer }>;
function __promisify__(file: string, options: ExecFileOptions): Promise<{ stdout: string, stderr: string }>;
function __promisify__(file: string, args: string[] | undefined | null, options: ExecFileOptions): Promise<{ stdout: string, stderr: string }>;
function __promisify__(file: string, options: ({ encoding?: string | null } & ExecFileOptions) | undefined | null): Promise<{ stdout: string | Buffer, stderr: string | Buffer }>;
function __promisify__(
file: string,
args: string[] | undefined | null,
options: ({ encoding?: string | null } & ExecFileOptions) | undefined | null,
): Promise<{ stdout: string | Buffer, stderr: string | Buffer }>;
}
interface ForkOptions {
cwd?: string;
env?: NodeJS.ProcessEnv;
execPath?: string;
execArgv?: string[];
silent?: boolean;
stdio?: StdioOptions;
detached?: boolean;
windowsVerbatimArguments?: boolean;
uid?: number;
gid?: number;
}
function fork(modulePath: string, args?: ReadonlyArray<string>, options?: ForkOptions): ChildProcess;
interface SpawnSyncOptions {
argv0?: string; // Not specified in the docs
cwd?: string;
input?: string | Buffer | NodeJS.TypedArray | DataView;
stdio?: StdioOptions;
env?: NodeJS.ProcessEnv;
uid?: number;
gid?: number;
timeout?: number;
killSignal?: string | number;
maxBuffer?: number;
encoding?: string;
shell?: boolean | string;
windowsVerbatimArguments?: boolean;
windowsHide?: boolean;
}
interface SpawnSyncOptionsWithStringEncoding extends SpawnSyncOptions {
encoding: BufferEncoding;
}
interface SpawnSyncOptionsWithBufferEncoding extends SpawnSyncOptions {
encoding: string; // specify `null`.
}
interface SpawnSyncReturns<T> {
pid: number;
output: string[];
stdout: T;
stderr: T;
status: number | null;
signal: string | null;
error?: Error;
}
function spawnSync(command: string): SpawnSyncReturns<Buffer>;
function spawnSync(command: string, options?: SpawnSyncOptionsWithStringEncoding): SpawnSyncReturns<string>;
function spawnSync(command: string, options?: SpawnSyncOptionsWithBufferEncoding): SpawnSyncReturns<Buffer>;
function spawnSync(command: string, options?: SpawnSyncOptions): SpawnSyncReturns<Buffer>;
function spawnSync(command: string, args?: ReadonlyArray<string>, options?: SpawnSyncOptionsWithStringEncoding): SpawnSyncReturns<string>;
function spawnSync(command: string, args?: ReadonlyArray<string>, options?: SpawnSyncOptionsWithBufferEncoding): SpawnSyncReturns<Buffer>;
function spawnSync(command: string, args?: ReadonlyArray<string>, options?: SpawnSyncOptions): SpawnSyncReturns<Buffer>;
interface ExecSyncOptions {
cwd?: string;
input?: string | Buffer | Uint8Array;
stdio?: StdioOptions;
env?: NodeJS.ProcessEnv;
shell?: string;
uid?: number;
gid?: number;
timeout?: number;
killSignal?: string | number;
maxBuffer?: number;
encoding?: string;
windowsHide?: boolean;
}
interface ExecSyncOptionsWithStringEncoding extends ExecSyncOptions {
encoding: BufferEncoding;
}
interface ExecSyncOptionsWithBufferEncoding extends ExecSyncOptions {
encoding: string; // specify `null`.
}
function execSync(command: string): Buffer;
function execSync(command: string, options?: ExecSyncOptionsWithStringEncoding): string;
function execSync(command: string, options?: ExecSyncOptionsWithBufferEncoding): Buffer;
function execSync(command: string, options?: ExecSyncOptions): Buffer;
interface ExecFileSyncOptions {
cwd?: string;
input?: string | Buffer | NodeJS.TypedArray | DataView;
stdio?: StdioOptions;
env?: NodeJS.ProcessEnv;
uid?: number;
gid?: number;
timeout?: number;
killSignal?: string | number;
maxBuffer?: number;
encoding?: string;
windowsHide?: boolean;
shell?: boolean | string;
}
interface ExecFileSyncOptionsWithStringEncoding extends ExecFileSyncOptions {
encoding: BufferEncoding;
}
interface ExecFileSyncOptionsWithBufferEncoding extends ExecFileSyncOptions {
encoding: string; // specify `null`.
}
function execFileSync(command: string): Buffer;
function execFileSync(command: string, options?: ExecFileSyncOptionsWithStringEncoding): string;
function execFileSync(command: string, options?: ExecFileSyncOptionsWithBufferEncoding): Buffer;
function execFileSync(command: string, options?: ExecFileSyncOptions): Buffer;
function execFileSync(command: string, args?: ReadonlyArray<string>, options?: ExecFileSyncOptionsWithStringEncoding): string;
function execFileSync(command: string, args?: ReadonlyArray<string>, options?: ExecFileSyncOptionsWithBufferEncoding): Buffer;
function execFileSync(command: string, args?: ReadonlyArray<string>, options?: ExecFileSyncOptions): Buffer;
}

260
node_modules/@types/node/cluster.d.ts generated vendored Normal file
View File

@@ -0,0 +1,260 @@
declare module "cluster" {
import * as child from "child_process";
import * as events from "events";
import * as net from "net";
// interfaces
interface ClusterSettings {
execArgv?: string[]; // default: process.execArgv
exec?: string;
args?: string[];
silent?: boolean;
stdio?: any[];
uid?: number;
gid?: number;
inspectPort?: number | (() => number);
}
interface Address {
address: string;
port: number;
addressType: number | "udp4" | "udp6"; // 4, 6, -1, "udp4", "udp6"
}
class Worker extends events.EventEmitter {
id: number;
process: child.ChildProcess;
send(message: any, sendHandle?: any, callback?: (error: Error) => void): boolean;
kill(signal?: string): void;
destroy(signal?: string): void;
disconnect(): void;
isConnected(): boolean;
isDead(): boolean;
exitedAfterDisconnect: boolean;
/**
* events.EventEmitter
* 1. disconnect
* 2. error
* 3. exit
* 4. listening
* 5. message
* 6. online
*/
addListener(event: string, listener: (...args: any[]) => void): this;
addListener(event: "disconnect", listener: () => void): this;
addListener(event: "error", listener: (error: Error) => void): this;
addListener(event: "exit", listener: (code: number, signal: string) => void): this;
addListener(event: "listening", listener: (address: Address) => void): this;
addListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
addListener(event: "online", listener: () => void): this;
emit(event: string | symbol, ...args: any[]): boolean;
emit(event: "disconnect"): boolean;
emit(event: "error", error: Error): boolean;
emit(event: "exit", code: number, signal: string): boolean;
emit(event: "listening", address: Address): boolean;
emit(event: "message", message: any, handle: net.Socket | net.Server): boolean;
emit(event: "online"): boolean;
on(event: string, listener: (...args: any[]) => void): this;
on(event: "disconnect", listener: () => void): this;
on(event: "error", listener: (error: Error) => void): this;
on(event: "exit", listener: (code: number, signal: string) => void): this;
on(event: "listening", listener: (address: Address) => void): this;
on(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
on(event: "online", listener: () => void): this;
once(event: string, listener: (...args: any[]) => void): this;
once(event: "disconnect", listener: () => void): this;
once(event: "error", listener: (error: Error) => void): this;
once(event: "exit", listener: (code: number, signal: string) => void): this;
once(event: "listening", listener: (address: Address) => void): this;
once(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
once(event: "online", listener: () => void): this;
prependListener(event: string, listener: (...args: any[]) => void): this;
prependListener(event: "disconnect", listener: () => void): this;
prependListener(event: "error", listener: (error: Error) => void): this;
prependListener(event: "exit", listener: (code: number, signal: string) => void): this;
prependListener(event: "listening", listener: (address: Address) => void): this;
prependListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
prependListener(event: "online", listener: () => void): this;
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
prependOnceListener(event: "disconnect", listener: () => void): this;
prependOnceListener(event: "error", listener: (error: Error) => void): this;
prependOnceListener(event: "exit", listener: (code: number, signal: string) => void): this;
prependOnceListener(event: "listening", listener: (address: Address) => void): this;
prependOnceListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
prependOnceListener(event: "online", listener: () => void): this;
}
interface Cluster extends events.EventEmitter {
Worker: Worker;
disconnect(callback?: Function): void;
fork(env?: any): Worker;
isMaster: boolean;
isWorker: boolean;
// TODO: cluster.schedulingPolicy
settings: ClusterSettings;
setupMaster(settings?: ClusterSettings): void;
worker?: Worker;
workers?: {
[index: string]: Worker | undefined
};
/**
* events.EventEmitter
* 1. disconnect
* 2. exit
* 3. fork
* 4. listening
* 5. message
* 6. online
* 7. setup
*/
addListener(event: string, listener: (...args: any[]) => void): this;
addListener(event: "disconnect", listener: (worker: Worker) => void): this;
addListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
addListener(event: "fork", listener: (worker: Worker) => void): this;
addListener(event: "listening", listener: (worker: Worker, address: Address) => void): this;
addListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
addListener(event: "online", listener: (worker: Worker) => void): this;
addListener(event: "setup", listener: (settings: any) => void): this;
emit(event: string | symbol, ...args: any[]): boolean;
emit(event: "disconnect", worker: Worker): boolean;
emit(event: "exit", worker: Worker, code: number, signal: string): boolean;
emit(event: "fork", worker: Worker): boolean;
emit(event: "listening", worker: Worker, address: Address): boolean;
emit(event: "message", worker: Worker, message: any, handle: net.Socket | net.Server): boolean;
emit(event: "online", worker: Worker): boolean;
emit(event: "setup", settings: any): boolean;
on(event: string, listener: (...args: any[]) => void): this;
on(event: "disconnect", listener: (worker: Worker) => void): this;
on(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
on(event: "fork", listener: (worker: Worker) => void): this;
on(event: "listening", listener: (worker: Worker, address: Address) => void): this;
on(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
on(event: "online", listener: (worker: Worker) => void): this;
on(event: "setup", listener: (settings: any) => void): this;
once(event: string, listener: (...args: any[]) => void): this;
once(event: "disconnect", listener: (worker: Worker) => void): this;
once(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
once(event: "fork", listener: (worker: Worker) => void): this;
once(event: "listening", listener: (worker: Worker, address: Address) => void): this;
once(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
once(event: "online", listener: (worker: Worker) => void): this;
once(event: "setup", listener: (settings: any) => void): this;
prependListener(event: string, listener: (...args: any[]) => void): this;
prependListener(event: "disconnect", listener: (worker: Worker) => void): this;
prependListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
prependListener(event: "fork", listener: (worker: Worker) => void): this;
prependListener(event: "listening", listener: (worker: Worker, address: Address) => void): this;
prependListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
prependListener(event: "online", listener: (worker: Worker) => void): this;
prependListener(event: "setup", listener: (settings: any) => void): this;
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
prependOnceListener(event: "disconnect", listener: (worker: Worker) => void): this;
prependOnceListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
prependOnceListener(event: "fork", listener: (worker: Worker) => void): this;
prependOnceListener(event: "listening", listener: (worker: Worker, address: Address) => void): this;
// the handle is a net.Socket or net.Server object, or undefined.
prependOnceListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this;
prependOnceListener(event: "online", listener: (worker: Worker) => void): this;
prependOnceListener(event: "setup", listener: (settings: any) => void): this;
}
function disconnect(callback?: Function): void;
function fork(env?: any): Worker;
const isMaster: boolean;
const isWorker: boolean;
// TODO: cluster.schedulingPolicy
const settings: ClusterSettings;
function setupMaster(settings?: ClusterSettings): void;
const worker: Worker;
const workers: {
[index: string]: Worker | undefined
};
/**
* events.EventEmitter
* 1. disconnect
* 2. exit
* 3. fork
* 4. listening
* 5. message
* 6. online
* 7. setup
*/
function addListener(event: string, listener: (...args: any[]) => void): Cluster;
function addListener(event: "disconnect", listener: (worker: Worker) => void): Cluster;
function addListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster;
function addListener(event: "fork", listener: (worker: Worker) => void): Cluster;
function addListener(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster;
// the handle is a net.Socket or net.Server object, or undefined.
function addListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster;
function addListener(event: "online", listener: (worker: Worker) => void): Cluster;
function addListener(event: "setup", listener: (settings: any) => void): Cluster;
function emit(event: string | symbol, ...args: any[]): boolean;
function emit(event: "disconnect", worker: Worker): boolean;
function emit(event: "exit", worker: Worker, code: number, signal: string): boolean;
function emit(event: "fork", worker: Worker): boolean;
function emit(event: "listening", worker: Worker, address: Address): boolean;
function emit(event: "message", worker: Worker, message: any, handle: net.Socket | net.Server): boolean;
function emit(event: "online", worker: Worker): boolean;
function emit(event: "setup", settings: any): boolean;
function on(event: string, listener: (...args: any[]) => void): Cluster;
function on(event: "disconnect", listener: (worker: Worker) => void): Cluster;
function on(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster;
function on(event: "fork", listener: (worker: Worker) => void): Cluster;
function on(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster;
function on(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster; // the handle is a net.Socket or net.Server object, or undefined.
function on(event: "online", listener: (worker: Worker) => void): Cluster;
function on(event: "setup", listener: (settings: any) => void): Cluster;
function once(event: string, listener: (...args: any[]) => void): Cluster;
function once(event: "disconnect", listener: (worker: Worker) => void): Cluster;
function once(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster;
function once(event: "fork", listener: (worker: Worker) => void): Cluster;
function once(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster;
function once(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster; // the handle is a net.Socket or net.Server object, or undefined.
function once(event: "online", listener: (worker: Worker) => void): Cluster;
function once(event: "setup", listener: (settings: any) => void): Cluster;
function removeListener(event: string, listener: (...args: any[]) => void): Cluster;
function removeAllListeners(event?: string): Cluster;
function setMaxListeners(n: number): Cluster;
function getMaxListeners(): number;
function listeners(event: string): Function[];
function listenerCount(type: string): number;
function prependListener(event: string, listener: (...args: any[]) => void): Cluster;
function prependListener(event: "disconnect", listener: (worker: Worker) => void): Cluster;
function prependListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster;
function prependListener(event: "fork", listener: (worker: Worker) => void): Cluster;
function prependListener(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster;
// the handle is a net.Socket or net.Server object, or undefined.
function prependListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster;
function prependListener(event: "online", listener: (worker: Worker) => void): Cluster;
function prependListener(event: "setup", listener: (settings: any) => void): Cluster;
function prependOnceListener(event: string, listener: (...args: any[]) => void): Cluster;
function prependOnceListener(event: "disconnect", listener: (worker: Worker) => void): Cluster;
function prependOnceListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster;
function prependOnceListener(event: "fork", listener: (worker: Worker) => void): Cluster;
function prependOnceListener(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster;
// the handle is a net.Socket or net.Server object, or undefined.
function prependOnceListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster;
function prependOnceListener(event: "online", listener: (worker: Worker) => void): Cluster;
function prependOnceListener(event: "setup", listener: (settings: any) => void): Cluster;
function eventNames(): string[];
}

Some files were not shown because too many files have changed in this diff Show More